Package org.apache.jetspeed.security

Examples of org.apache.jetspeed.security.PasswordCredential


        try
        {
            if ( request.getRequest().getUserPrincipal() != null )
            {
                Subject subject = request.getSubject();
                PasswordCredential pwdCredential = SecurityHelper.getPasswordCredential(subject);
                Integer passwordDaysValid = null;
               
                // check for an existing password credential
                if ( pwdCredential != null )
                {
                    if ( pwdCredential.isUpdateRequired() )
                    {
                        passwordDaysValid = new Integer(0); // required change
                    }
                    if ( request.getSessionAttribute(CHECKED_KEY) == null  )
                    {
                        request.setSessionAttribute(CHECKED_KEY,Boolean.TRUE);
                        if ( pwdCredential.getPreviousAuthenticationDate() != null &&
                                pwdCredential.getLastAuthenticationDate() != null &&
                                pwdCredential.getExpirationDate() != null )
                        {
                            long expirationTime = pwdCredential.getExpirationDate().getTime();
                            long lastAuthTime = pwdCredential.getLastAuthenticationDate().getTime();
                            int lastAuthDaysBeforeExpiration = (int)((expirationTime-lastAuthTime)/(24*60*60*1000));
                            if lastAuthDaysBeforeExpiration < 1 )
                            {
                                passwordDaysValid = new Integer(1);
                            }
                            else if (expirationWarningDays.length > 0)
                            {
                                long prevAuthTime = Long.MIN_VALUE;
                                if (pwdCredential.getPreviousAuthenticationDate() != null )
                                {
                                    prevAuthTime = pwdCredential.getPreviousAuthenticationDate().getTime();
                                }
                                int prevAuthDaysBeforeExpiration = (int)((expirationTime-prevAuthTime)/(24*60*60*1000));
                                if ( prevAuthDaysBeforeExpiration > lastAuthDaysBeforeExpiration )
                                {
                                    for ( int i = 0; i < expirationWarningDays.length; i++ )
View Full Code Here


    {
        Set credentials = crHandler.getPrivateCredentials(uid1);

        assertTrue("getPrivateCredentials found no credentials for user:" + uid1, credentials.size() > 0);

        PasswordCredential cred = (PasswordCredential) credentials.iterator().next();

        assertEquals(password, String.valueOf(cred.getPassword()));
    }
View Full Code Here

            Object credential)
    {
        if (credential == null) return;
        if (credential instanceof PasswordCredential)
        {
            PasswordCredential pw = (PasswordCredential) credential;
            newUser.setUserCredential(pw.getUserName(), pw.getPassword(),pw.getExpirationDate(),pw.isEnabled(), pw.isExpired(), pw.isUpdateRequired());
            return;
        } else if (isPublic)
            newUser.addPublicCredential(credential);
        else
            newUser.addPrivateCredential(credential);
View Full Code Here

                .println("Error!!! PasswordCredentialProvider not available");
        return ENCODING_STRING;
    }
    try
    {
      PasswordCredential credential = provider.create(JETSPEED,ENCODING_STRING);
      if ((credential != null) && (credential.getPassword() != null))
        return new String(credential.getPassword());
      else
          return ENCODING_STRING;
    }
    catch (Exception e)
    {
View Full Code Here

        try
        {
            if ( request.getRequest().getUserPrincipal() != null )
            {
                Subject subject = request.getSubject();
                PasswordCredential pwdCredential = SecurityHelper.getPasswordCredential(subject);
                Integer passwordDaysValid = null;
               
                // check for an existing password credential
                if ( pwdCredential != null )
                {
                    if ( pwdCredential.isUpdateRequired() )
                    {
                        passwordDaysValid = new Integer(0); // required change
                    }
                    if ( request.getSessionAttribute(CHECKED_KEY) == null  )
                    {
                        request.setSessionAttribute(CHECKED_KEY,Boolean.TRUE);
                        if ( pwdCredential.getPreviousAuthenticationDate() != null &&
                                pwdCredential.getLastAuthenticationDate() != null &&
                                pwdCredential.getExpirationDate() != null )
                        {
                            long expirationTime = pwdCredential.getExpirationDate().getTime();
                            long lastAuthTime = pwdCredential.getLastAuthenticationDate().getTime();
                            int lastAuthDaysBeforeExpiration = (int)((expirationTime-lastAuthTime)/(24*60*60*1000));
                            if lastAuthDaysBeforeExpiration < 1 )
                            {
                                passwordDaysValid = new Integer(1);
                            }
                            else if (expirationWarningDays.length > 0)
                            {
                                long prevAuthTime = Long.MIN_VALUE;
                                if (pwdCredential.getPreviousAuthenticationDate() != null )
                                {
                                    prevAuthTime = pwdCredential.getPreviousAuthenticationDate().getTime();
                                }
                                int prevAuthDaysBeforeExpiration = (int)((expirationTime-prevAuthTime)/(24*60*60*1000));
                                if ( prevAuthDaysBeforeExpiration > lastAuthDaysBeforeExpiration )
                                {
                                    for ( int i = 0; i < expirationWarningDays.length; i++ )
View Full Code Here

    {
        Set credentials = crHandler.getPrivateCredentials(uid1);

        assertTrue("getPrivateCredentials found no credentials for user:" + uid1, credentials.size() > 0);

        PasswordCredential cred = (PasswordCredential) credentials.iterator().next();

        assertEquals(password, String.valueOf(cred.getPassword()));
    }
View Full Code Here

                                {
                                    request.setSessionAttribute(LoginConstants.ERRORCODE, LoginConstants.ERROR_USER_DISABLED);
                                }
                                else
                                {
                                    PasswordCredential pwdCredential = SecurityHelper.getPasswordCredential(user.getSubject());
                                    if ( pwdCredential == null || !pwdCredential.isEnabled() )
                                    {
                                        request.setSessionAttribute(LoginConstants.ERRORCODE, LoginConstants.ERROR_CREDENTIAL_DISABLED);
                                    }
                                    else if ( pwdCredential.isExpired() )
                                    {
                                        request.setSessionAttribute(LoginConstants.ERRORCODE, LoginConstants.ERROR_CREDENTIAL_EXPIRED);
                                    }
                                    else if ( maxNumberOfAuthenticationFailures > 1 && pwdCredential.getAuthenticationFailures() == maxNumberOfAuthenticationFailures -)
                                    {
                                        request.setSessionAttribute(LoginConstants.ERRORCODE, LoginConstants.ERROR_FINAL_LOGIN_ATTEMPT);
                                    }
                                    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

                {
                    try
                    {
                        boolean passwordSet = false;
                        UserManager manager = (UserManager) getManager();
                        PasswordCredential credential = manager
                                .getPasswordCredential((User) getPrincipal());
                        if (getCredentialValue() != null
                                && getCredentialValue().trim().length() > 0)
                        {
                            credential.setPassword(null, getCredentialValue());
                            getServiceLocator()
                                    .getAuditActivity()
                                    .logAdminCredentialActivity(
                                            getPortletRequest()
                                                    .getUserPrincipal()
                                                    .getName(),
                                            getIPAddress(),
                                            getPrincipal().getName(),
                                            AuditActivity.PASSWORD_RESET,
                                            AdminPortletWebPage.USER_ADMINISTRATION);
                            passwordSet = true;
                        }
                        if (getCredentialUpdateRequired() != credential
                                .isUpdateRequired())
                        {
                            credential
                                    .setUpdateRequired(getCredentialUpdateRequired());
                            getServiceLocator()
                                    .getAuditActivity()
                                    .logAdminCredentialActivity(
                                            getPortletRequest()
                                                    .getUserPrincipal()
                                                    .getName(),
                                            getIPAddress(),
                                            getPrincipal().getName(),
                                            AuditActivity.PASSWORD_UPDATE_REQUIRED,
                                            AdminPortletWebPage.USER_ADMINISTRATION);
                        }
                        if (getCredentialEnabled() != credential.isEnabled())
                        {
                            credential.setEnabled(getCredentialEnabled());
                            String activity = (getCredentialEnabled() ? AuditActivity.PASSWORD_ENABLED
                                    : AuditActivity.PASSWORD_DISABLED);
                            getServiceLocator()
                                    .getAuditActivity()
                                    .logAdminCredentialActivity(
                                            getPortletRequest()
                                                    .getUserPrincipal()
                                                    .getName(),
                                            getIPAddress(),
                                            getPrincipal().getName(),
                                            activity,
                                            AdminPortletWebPage.USER_ADMINISTRATION);
                        }
                        String expiredFlagStr = getUserExpiredFlag();
                        if (expiredFlagStr != null)
                        {
                            if (!passwordSet
                                    && expiredFlagStr.equals("expired"))
                            {
                                java.sql.Date today = new java.sql.Date(
                                        new Date().getTime());
                                credential.setExpirationDate(today);
                                getServiceLocator()
                                        .getAuditActivity()
                                        .logAdminCredentialActivity(
                                                getPortletRequest()
                                                        .getUserPrincipal()
                                                        .getName(),
                                                getIPAddress(),
                                                getPrincipal().getName(),
                                                AuditActivity.PASSWORD_EXPIRE,
                                                AdminPortletWebPage.USER_ADMINISTRATION);
                            } else if (expiredFlagStr.equals("extend"))
                            {
                                // getUserManager().setPasswordExpiration(getUserName(),
                                // null);
                                // TODO confirm with Ate/David
                                credential.setExpirationDate(MAX_DATE);
                                getServiceLocator()
                                        .getAuditActivity()
                                        .logAdminCredentialActivity(
                                                getPortletRequest()
                                                        .getUserPrincipal()
                                                        .getName(),
                                                getIPAddress(),
                                                getPrincipal().getName(),
                                                AuditActivity.PASSWORD_EXTEND,
                                                AdminPortletWebPage.USER_ADMINISTRATION);
                            } else if (expiredFlagStr.equals("unlimited"))
                            {
                                credential.setExpirationDate(MAX_DATE);
                                getServiceLocator()
                                        .getAuditActivity()
                                        .logAdminCredentialActivity(
                                                getPortletRequest()
                                                        .getUserPrincipal()
View Full Code Here

            try
            {
                SSOUser remoteUser = SSOPortletUtil.getRemoteUser(sso, request, site);
                if (remoteUser != null)
                {
                    PasswordCredential pwc = sso.getCredentials(remoteUser);
                    getContext(request).put(SSO_FORM_PRINCIPAL, pwc.getUserName());
                    getContext(request).put(SSO_FORM_CREDENTIAL, pwc.getPassword());
                }
                else
                {
                    getContext(request).put(SSO_FORM_PRINCIPAL, "");
                    getContext(request).put(SSO_FORM_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.