Package org.apache.jetspeed.security

Examples of org.apache.jetspeed.security.PasswordCredential


        try
        {
            SSOUser remoteUser = SSOPortletUtil.getRemoteUser(sso, request, site);
            if (remoteUser != null)
            {
                PasswordCredential pwc = sso.getCredentials(remoteUser);
                request.setAttribute(SSO_REQUEST_ATTRIBUTE_USERNAME, pwc.getUserName());
                request.setAttribute(SSO_REQUEST_ATTRIBUTE_PASSWORD, pwc.getPassword());
            }
            else
            {
                response.getWriter().print(SSOWebContentPortlet.NO_CREDENTIALS);
                return;
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

        try
        {
            SSOUser remoteUser = SSOPortletUtil.getRemoteUser(sso, request, site);
            if (remoteUser != null)
            {
                PasswordCredential pwc = sso.getCredentials(remoteUser);
                request.setAttribute(SSO_REQUEST_ATTRIBUTE_USERNAME, pwc.getUserName());
                request.setAttribute(SSO_REQUEST_ATTRIBUTE_PASSWORD, pwc.getPassword());
            }
            else
            {
                response.getWriter().print(SSOWebContentPortlet.NO_CREDENTIALS);
                return;
View Full Code Here

            response.getWriter().print(NO_CREDENTIALS);
            return;
        }
        else
        {
          PasswordCredential pwc = SSOPortletUtil.getCredentialsForSite(sso,siteName,request);
          if (pwc != null)
          {
                request.setAttribute(SSO_REQUEST_ATTRIBUTE_USERNAME, pwc.getUserName());
                request.setAttribute(SSO_REQUEST_ATTRIBUTE_PASSWORD, pwc.getPassword());
          } else
          {
                response.getWriter().print(NO_CREDENTIALS);
                return;
          }
View Full Code Here

    public void doEdit(RenderRequest request, RenderResponse response)
    throws PortletException, IOException
    {
        String site = request.getPreferences().getValue("SRC", "");
      PasswordCredential pwc = SSOPortletUtil.getCredentialsForSite(sso,site,request);
      if (pwc != null)
      {
            getContext(request).put(SSO_EDIT_FIELD_PRINCIPAL, pwc.getUserName());
            getContext(request).put(SSO_EDIT_FIELD_CREDENTIAL, pwc.getPassword());
        }
      else
      {
            // no credentials configured in SSO store
            // switch to SSO Configure View
View Full Code Here

    {
        try
        {
            Subject subject = request.getSubject();
            Iterator credentialsIter = subject.getPrivateCredentials().iterator();
            PasswordCredential pwdCredential = null;
            while ( credentialsIter.hasNext() )
            {
                Object credential = credentialsIter.next();
                if ( credential instanceof PasswordCredential )
                {
                    pwdCredential = (PasswordCredential)credential;
                    break;
                }
            }
            Integer passwordDaysValid = null;
           
            // check for an existing password credential
            // The only expected subject without a password credential is the anonymous user!
            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 )
                    {
                        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

     * @see org.apache.jetspeed.security.spi.PasswordCredentialProvider#create(java.lang.String, java.lang.String)
     */
    public PasswordCredential create(String userName, String password) throws SecurityException
    {
        validator.validate(password);
        PasswordCredential pc;
        if ( encoder != null )
        {
            pc = new DefaultPasswordCredentialImpl(userName, encoder.encode(userName, password).toCharArray());
        }
        else
View Full Code Here

        return null;
    }

    protected String getPassword(User user)
    {
        PasswordCredential credential = null;

        Set credentials = user.getSubject().getPrivateCredentials();
        Iterator iter = credentials.iterator();
        while (iter.hasNext())
        {
            Object o = iter.next();
            if (o instanceof PasswordCredential)
            {
                credential = (PasswordCredential) o;
                char[] charar = credential.getPassword();

                return new String(charar);
            }
        }
        return null;
View Full Code Here

                if ( password != null && password.trim().length() > 0 )
                {
                    userManager.setPassword(userName, null, password);
                    passwordSet = true;
                }
                PasswordCredential credential = getCredential(actionRequest, userName);
                if ( credential != null )
                {
                    String updateRequiredStr = actionRequest.getParameter("user_cred_updreq");
                    if (updateRequiredStr != null)
                    {
                        boolean updateRequired = Boolean.valueOf(updateRequiredStr).booleanValue();
                        if (updateRequired != credential.isUpdateRequired())
                        {
                            userManager.setPasswordUpdateRequired(userName,updateRequired);
                        }
                    }
                    String enabledStr = actionRequest.getParameter("user_cred_enabled");
                    if (enabledStr != null)
                    {
                        boolean enabled = Boolean.valueOf(enabledStr).booleanValue();
                        if (enabled != credential.isEnabled())
                        {
                            userManager.setPasswordEnabled(userName,enabled);
                        }
                    }
                    String expiredFlagStr = actionRequest.getParameter("user_expired_flag");
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.