Package org.picketlink.idm.impl.api

Examples of org.picketlink.idm.impl.api.PasswordCredential


                for (int i = 0; i < callbacks.length; i++) {
                    if (callbacks[i] instanceof NameCallback) {
                        ((NameCallback) callbacks[i]).setName(credentials.getUsername());
                    } else if (callbacks[i] instanceof PasswordCallback) {
                        if (credentials.getCredential() instanceof PasswordCredential) {
                            PasswordCredential credential = (PasswordCredential) credentials.getCredential();
                            ((PasswordCallback) callbacks[i]).setPassword(credential.getValue() != null ?
                                    credential.getValue().toCharArray() : null);
                        }
                    } else {
                        log.warn("Unsupported callback " + callbacks[i]);
                    }
                }
View Full Code Here


    @Inject
    private Identity identity;

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        creds.setCredential(new PasswordCredential("test"));
        creds.setUsername("test");

        identity.login();

        if (identity.isLoggedIn())
View Full Code Here

                ((PasswordCredential) credential).getValue() : null;
    }

    public void setPassword(String password) {
        if (this.credential == null) {
            this.credential = new PasswordCredential(password);
        } else if (this.credential != null && this.credential instanceof PasswordCredential &&
                ((PasswordCredential) this.credential).getValue() != password &&
                ((PasswordCredential) this.credential).getValue() == null ||
                !((PasswordCredential) this.credential).getValue().equals(password)) {
            this.credential = new PasswordCredential(password);
            invalid = false;
            manager.fireEvent(new CredentialsUpdatedEvent());
        }
    }
View Full Code Here

        }
    }

    protected void loginAs(String username) {
        credentials.setUsername(username);
        credentials.setCredential(new PasswordCredential(username));
        identity.login();
    }
View Full Code Here

        if (Strings.isBlank(user)) {
            throw new IllegalArgumentException("Missing 'user' parameter!");
        }

        credentials.setUsername(user);
        credentials.setCredential(new PasswordCredential("secret"));

        identity.login();

        if (identity.isLoggedIn()) {
            response.getOutputStream().print("SUCCESS");
View Full Code Here

               }
               else if (callbacks[i] instanceof PasswordCallback)
               {
                  if (credentials.getCredential() instanceof PasswordCredential)
                  {
                     PasswordCredential credential = (PasswordCredential) credentials.getCredential();
                     ( (PasswordCallback) callbacks[i] ).setPassword( credential.getValue() != null ?
                           credential.getValue().toCharArray() : null );                    
                  }
               }
               else
               {
                  log.warn("Unsupported callback " + callbacks[i]);
View Full Code Here

   @Inject IdentitySession identitySession;  
  
   public String changePassword() throws IdentityException
   {
      if (!identitySession.getAttributesManager().validateCredentials(identity.getUser(),
            new Credential[] { new PasswordCredential(oldPassword)}))
      {
         // TODO add a message
        
         return "failed";
      }
View Full Code Here

  
   public void setPassword(String password)
   {
      if (this.credential == null)
      {
         this.credential = new PasswordCredential(password);
      }
      else if (this.credential != null && this.credential instanceof PasswordCredential &&
            ((PasswordCredential) this.credential).getValue() != password &&
            ((PasswordCredential) this.credential).getValue() == null ||
            !((PasswordCredential) this.credential).getValue().equals(password))
      {
         this.credential = new PasswordCredential(password);
         invalid = false;
         manager.fireEvent(new CredentialsUpdatedEvent());
      }
   }
View Full Code Here

        if (username == null || !(credential instanceof PasswordCredential)) {
            setStatus(AuthenticationStatus.FAILURE);
            log.info("Demo login for user (" + username + ") failed: unsupported username/credential.");
            return;
        }
        PasswordCredential passwordCredential = (PasswordCredential) credentials.getCredential();
        if (!username.equals(passwordCredential.getValue())) {
            setStatus(AuthenticationStatus.FAILURE);
            log.info("Demo login for user (" + username + ") failed: wrong username/password.");
            return;
        }
        setStatus(AuthenticationStatus.SUCCESS);
View Full Code Here

            try {
                User u = em.createQuery("from User u join fetch u.contact where u.contact.emailAddress=:username", User.class)
                        .setParameter("username", credentials.getUsername()).getSingleResult();

                if (u != null) {
                    PasswordCredential password = (PasswordCredential) credentials.getCredential();
                    String hashedPassword = securityUtil.hash(u, password.getValue());
                    if (hashedPassword.equals(u.getPassword())) {
                        loginEvent.fire(u);
                        u.setDateLastLogin(new Date());
                        setUser(new SimpleUser(u.getContact().getEmailAddress()));
                        setStatus(AuthenticationStatus.SUCCESS);
View Full Code Here

TOP

Related Classes of org.picketlink.idm.impl.api.PasswordCredential

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.