Package org.apache.jetspeed.security

Examples of org.apache.jetspeed.security.PasswordCredential


    }
   
    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


                        log.debug("add User " + jsuser.getName() + " with password " + (password));
                       
                        user = userManager.addUser(jsuser.getName());
                        if (password != null && password.length() > 0)
                        {
                            PasswordCredential pwc = userManager.getPasswordCredential(user);
                            pwc.setPassword(null, password);
                            pwc.setEncoded((passwordEncoding == JetspeedSerializer.PASSTHRU_REQUIRED));
                            userManager.storePasswordCredential(pwc);
                        }
                        log.debug("add User done ");
                    }
                    try
                    {
                        PasswordCredential pwc = userManager.getPasswordCredential(user);
                        pwc.setEnabled(jsuser.getPwDataValueAsBoolean("enabled"));
                        pwc.setUpdateRequired(jsuser.getPwDataValueAsBoolean("requiresUpdate"));
                        java.sql.Date d = jsuser.getPwExpirationDate();
                        if (d != null)
                            pwc.setExpirationDate(d);
                        userManager.storePasswordCredential(pwc);
                    }
                    catch (Exception e)
                    {
                        // most likely caused by protected users (like "guest")
View Full Code Here

                    log.debug("add User " + jsuser.getName() + " with password " + (password));
                   
                    user = userManager.addUser(jsuser.getName(), jsuser.isMapped());
                    if (password != null && password.length() > 0)
                    {
                        PasswordCredential pwc = userManager.getPasswordCredential(user);
                        pwc.setPassword(null, password);
                        pwc.setEncoded((passwordEncoding == JetspeedSerializer.PASSTHRU_REQUIRED));
                        userManager.storePasswordCredential(pwc);
                    }
                    log.debug("add User done ");
                }
                try
                {
                    PasswordCredential pwc = userManager.getPasswordCredential(user);
                    pwc.setEnabled(jsuser.getPwDataValueAsBoolean("enabled"));
                    pwc.setUpdateRequired(jsuser.getPwDataValueAsBoolean("requiresUpdate"));
                    java.sql.Date d = jsuser.getPwDataValueAsDate("expirationDate");
                    if (d != null)
                        pwc.setExpirationDate(d);
                    userManager.storePasswordCredential(pwc);
                }
                catch (Exception e)
                {
                    // most likely caused by protected users (like "guest")
View Full Code Here

    {
        if (credential == null)
            return;
        if (credential instanceof PasswordCredential)
        {
            PasswordCredential pw = (PasswordCredential) credential;
            char [] pwdChars = (pw.getPassword() != null ? pw.getPassword().toCharArray() : null);
            newPrincipal.setCredential(pw.getUserName(), pwdChars, pw.getExpirationDate(), pw.isEnabled(),
                                      pw.isExpired(), pw.isUpdateRequired());
            return;
        }
        else if (isPublic)
            newPrincipal.addPublicCredential(credential);
        else
View Full Code Here

                                error(e.getMessage());
                            }
                        }
                        userManager.updateUser(user);
                                               
                        PasswordCredential credential = userManager
                                .getPasswordCredential(user);
                        if (!StringUtils.isEmpty(getPassword()))
                        {
                            credential.setPassword(getPassword(), false);
                        }
                        credential.setUpdateRequired(isCheckpass());
                        userManager.storePasswordCredential(credential);
                        setPrincipal(user);
                        controlPannels(true);
                    }
                    catch (SecurityException jSx)
View Full Code Here

   
    public PasswordCredential getPasswordCredential(User user) throws SecurityException
    {
        if (isPersistCredentials())
        {
            PasswordCredential credential = upcsm.getPasswordCredential(user);
            if (!credential.isNew() && upcpm != null)
            {
                if (upcpm.onLoad(credential, user.getName()))
                {
                    upcsm.storePasswordCredential(credential);               
                }
            }
            return credential;
        }
        else
        {
            // create new transient credential
            PasswordCredentialImpl credential = new PasswordCredentialImpl();
            credential.setUser(user);
            return credential;
        }
    }
View Full Code Here

            if (synchronizer != null)
            {
                synchronizer.synchronizeUserPrincipal(userName);
            }
        }
        PasswordCredential credential = isPersistCredentials() ? upcam.getPasswordCredential(userName) : new PasswordCredentialImpl();
        if (credential == null)
        {
            credential = new PasswordCredentialImpl();
            // persistCredentials but user credentials not yet synchronized/stored
            if (um == null)
            {
                log.error("New User PasswordCredential cannot be persisted: requires UserManager to be set!!!");
            }
            else
            {
                // to be able to store the new password credential it needs the User to be set
                ((PasswordCredentialImpl)credential).setUser(um.getUser(userName));
            }
        }
        boolean setPassword = false;
        if (isPersistCredentials() && (!credential.isNew() || credential.getUser() != null))
        {
            if (credential.isNew())
            {
                setPassword = true;
            }
            else
            {
                String encodedPassword = password;
                if (upcpm != null && upcpm.getCredentialPasswordEncoder() != null && credential.isEncoded())
                {
                    CredentialPasswordEncoder encoder = upcpm.getCredentialPasswordEncoder();
                    if (upcpm.getCredentialPasswordEncoder() instanceof AlgorithmUpgradeCredentialPasswordEncoder)
                    {
                        encodedPassword = ((AlgorithmUpgradeCredentialPasswordEncoder)encoder).encode(credential, password);
                    }
                    else
                    {
                        encodedPassword = encoder.encode(userName, password);
                    }
                }
                if (!credential.getPassword().equals(encodedPassword))
                {
                    setPassword = true;
                }
            }
            if (setPassword)
            {
                credential.setPassword(null, password);
                boolean synchronizing = SynchronizationStateAccess.isSynchronizing();
                try
                {
                    SynchronizationStateAccess.setSynchronizing(Boolean.TRUE);
                    storePasswordCredential(credential);
                }
                finally
                {
                    SynchronizationStateAccess.setSynchronizing(synchronizing ? Boolean.TRUE : Boolean.FALSE);
                }               
            }
           
            if (upcpm != null)
            {
                if (upcpm.onLoad(credential, userName))
                {
                    upcsm.storePasswordCredential(credential);
                }
                if (credential.isEnabled() && !credential.isExpired())
                {
                    if (upcpm.authenticate(credential, userName, password, true))
                    {
                        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);
                    }
                }
            }
        }
        if (credential.getUser() == null)
        {
            if (!credential.isNew())
            {           
                try
                {
                    upcam.loadPasswordCredentialUser(credential);
                }
View Full Code Here

        checkPrivilege(servletRequest, JetspeedActions.VIEW);
       
        try
        {
            User user = userManager.getUser(userName);
            PasswordCredential credential = userManager.getPasswordCredential(user);
            List<Role> roles = roleManager.getRolesForUser(user.getName());
            List<String> availableRoles = roleManager.getRoleNames(null);
            List<Group> groups = groupManager.getGroupsForUser(user.getName());
            List<String> availableGroups = groupManager.getGroupNames(null);
           
View Full Code Here

            if (credentialUpdateRequired == null)
            {
                credentialUpdateRequired = false;
            }
           
            PasswordCredential credential = userManager.getPasswordCredential(user);
           
            if (changePassword)
            {
                credential.setPassword(password, false);
            }
           
            credential.setUpdateRequired(credentialUpdateRequired);
           
            userManager.storePasswordCredential(credential);
           
            // merge roles
            List<Role> currentRoles = roleManager.getRolesForUser(user.getName());
View Full Code Here

            if (credentialUpdateRequired == null)
            {
                credentialUpdateRequired = false;
            }
           
            PasswordCredential credential = userManager.getPasswordCredential(user);
           
            if (changePassword)
            {
                credential.setPassword(password, false);
            }
           
            credential.setUpdateRequired(credentialUpdateRequired);
            userManager.storePasswordCredential(credential);
           
            // add default user roles
            String[] defaultUserRoles = Jetspeed.getConfiguration().getStringArray(PortalConfigurationConstants.REGISTRATION_ROLES_DEFAULT);
           
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.