Package org.apache.jetspeed.security

Examples of org.apache.jetspeed.security.PasswordCredential


    {
        try
        {
            // create the user
            User user =  userManager.addUser(userName);
            PasswordCredential pwc = userManager.getPasswordCredential(user);
            pwc.setPassword(null, password);
            userManager.storePasswordCredential(pwc);
                      
            // assign roles to user
            if (roles == null || roles.isEmpty())
            {
View Full Code Here


        this.upcpm = upcpm;
    }

    public PasswordCredential getPasswordCredential(User user) throws SecurityException
    {
        PasswordCredential credential = upcsm.getPasswordCredential(user);
        if (!credential.isNew() && upcpm != null)
        {
            upcpm.onLoad(credential, user.getName());
        }
        return credential;
    }
View Full Code Here

        upcsm.storePasswordCredential(credential);
    }

    public PasswordCredential getAuthenticatedPasswordCredential(String userName, String password) throws SecurityException
    {
        PasswordCredential credential = upcam.getPasswordCredential(userName);
        if (credential == null)
        {
            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER, userName));
        }
       
        if (upcpm != null)
        {
            if (upcpm.onLoad(credential, userName))
            {
                upcsm.storePasswordCredential(credential);
            }
            if (credential.isEnabled() && !credential.isExpired())
            {
                if (upcpm.authenticate(credential, userName, password))
                {
                    upcsm.storePasswordCredential(credential);
                }
                if (!credential.isEnabled() || credential.isExpired())
                {
                    throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER, userName));
                }
                else if (credential.getAuthenticationFailures() != 0)
                {
                    throw new SecurityException(SecurityException.INVALID_PASSWORD);
                }
            }
        }
        else
        {
            if (password == null)
            {
                throw new SecurityException(SecurityException.PASSWORD_REQUIRED);
            }
            else if (credential.getPassword() == null || !password.equals(new String(credential.getPassword())))
            {
                throw new SecurityException(SecurityException.INVALID_PASSWORD);
            }
            if (!credential.isEnabled() || credential.isExpired())
            {
                throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER, userName));
            }
        }
       
        try
        {
            upcam.loadPasswordCredentialUser(credential);
        }
        catch (Exception e)
        {
            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER, userName), e);
        }
       
        if (credential.getUser() == null || !credential.getUser().isEnabled())
        {
            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER, userName));
        }
        return credential;
    }
View Full Code Here

        this.upcm = upcm;
    }

    public AuthenticatedUser authenticate(String userName, String password) throws SecurityException
    {
        PasswordCredential credential = upcm.getAuthenticatedPasswordCredential(userName, password);
        return new AuthenticatedUserImpl(credential.getUser(), new UserCredentialImpl(credential));
    }
View Full Code Here

        return new TestSuite(TestCredentialPasswordEncoder.class);
    }

    public void testEncodedPassword() throws Exception
    {
        PasswordCredential pwc = ums.getPasswordCredential(ums.getUser("testcred"));
        assertNotNull(pwc);
        assertEquals("testcred", pwc.getUserName());
        assertNotSame("Password should be not same (encoded)", "password", new String(pwc.getPassword()));
    }
View Full Code Here

    private SSOSiteManagerSPI ssoSiteManagerSPI;
   
    private Long defaultDomainId;
   
    public SSOClient getClient(SSOSite site, SSOUser remoteUser) throws SSOException {
        PasswordCredential pwdCred = getCredentials(remoteUser);
        return new SSOClientImpl(site,pwdCred);
    }
View Full Code Here

    }
   
   
    public void setPassword(SSOUser user, String pwd) throws SSOException
    {
      PasswordCredential pwdCred = null;
     
      try{
          pwdCred=ssoUserManagerSPI.getPasswordCredential(user);
      } catch (SecurityException secex){
         
      }
      if (pwdCred != null){
          pwdCred.setPassword(pwd, false);
      } else {
            pwdCred=new PasswordCredentialImpl(user,pwd);
      }
     
      try{
View Full Code Here

    {
        addTestUser();
        addTestSite();
       
        SSOUser someRemoteUser = ssoManager.addUser(testSite, testuser, "someRemoteUser", "someRemotePwd");
        PasswordCredential pwd = ssoManager.getCredentials(someRemoteUser);
        assertEquals("someRemotePwd",pwd.getPassword());
       
        ssoManager.setPassword(someRemoteUser,"anotherPassword");
        pwd = ssoManager.getCredentials(someRemoteUser);
        assertEquals("anotherPassword",pwd.getPassword());

    }
View Full Code Here

    }
   
    protected User addUser(String name, String password) throws SecurityException
    {
        User user = ums.addUser(name);           
        PasswordCredential credential = ums.getPasswordCredential(user);
        credential.setPassword(password, false);
        ums.storePasswordCredential(credential);
        return user;
    }
View Full Code Here

  public Subject getSubject(User user) throws SecurityException
  {
    if (credentialManager != null)
    {
      PasswordCredential pwc = getPasswordCredential(user);
      if (pwc != null)
      {
        UserCredential credential = new UserCredentialImpl(pwc);
        HashSet<Object> privateCred = new HashSet<Object>();
        privateCred.add(credential);
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.security.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.