Package org.apache.jetspeed.services.security

Examples of org.apache.jetspeed.services.security.LoginException


        throws LoginException
    {

        if (username.equals(this.anonymousUser))
        {
            throw new LoginException("Anonymous user cannot login");
        }

        JetspeedUser user = null;

        username = JetspeedSecurity.convertUserName(username);
        password = JetspeedSecurity.convertPassword(password);
      
        try
        {
            user = JetspeedUserManagement.getUser(new UserNamePrincipal(username));
            password = JetspeedSecurity.encryptPassword(password);
        }                           
        catch (UnknownUserException e)
        {
            logger.warn("Unknown user attempted access: " + username, e);
            throw new FailedLoginException(e.toString());
        }
        catch (JetspeedSecurityException e)
        {
            logger.warn("User denied authentication: " + username, e);
            throw new LoginException(e.toString());
        }

        if(!user.getPassword().equals(password))
        {
            logger.error("Invalid password for user: " + username);
            throw new FailedLoginException("Credential authentication failure");
       

        // Check for password expiration
        if (this.expirationPeriod > 0)
        {
            Date passwordLastChangedDate = user.getPasswordChanged();
            Date passwordExpireDate = null;
            if (passwordLastChangedDate != null) {
                GregorianCalendar gcal = (GregorianCalendar) GregorianCalendar.getInstance();
                gcal.setTime(passwordLastChangedDate);
                gcal.add(GregorianCalendar.DATE, this.expirationPeriod);
                passwordExpireDate = gcal.getTime();
                if (logger.isDebugEnabled())
                {
                    logger.debug("TurbineAuthentication: password last changed = " + passwordLastChangedDate.toString() +
                              ", password expires = " + passwordExpireDate.toString());
                }
            }

            if (passwordExpireDate == null || (new Date().getTime() > passwordExpireDate.getTime())) {
                throw new CredentialExpiredException("Password expired");
            }

        }

        // Mark the user as being logged in.
        user.setHasLoggedIn(new Boolean(true));

        // Set the last_login date in the database.
        try
        {
            user.updateLastLogin();
            putUserIntoContext(user);
            if (cachingEnable)
            {
                JetspeedSecurityCache.load(username);
            }
        }
        catch (Exception e)
        {
            logger.error( "Failed to update last login ", e);
            putUserIntoContext(JetspeedSecurity.getAnonymousUser());
            throw new LoginException("Failed to update last login ", e);
        }

        return user;
       
    }
View Full Code Here


            }
        }
        catch (JetspeedSecurityException e)
        {
            logger.error( "Failed to get anonymous user: ", e );
            throw new LoginException("Failed to get anonymous user: ", e);
        }
        return user;
    }
View Full Code Here

            getAnonymousUser();
        }
        catch (Exception e)
        {
            logger.error( "Exception logging user out ", e );
            throw new LoginException("Exception logging user out ", e );
        }
    }
View Full Code Here

        throws LoginException
    {

        if (username.equals(this.anonymousUser))
        {
            throw new LoginException("Anonymous user cannot login");
        }

        JetspeedUser user = null;
        BasicAttributes attr= new BasicAttributes();
        String[] attrs = {"ou", "userPassword", "uid", "mail"};
        String dN = null;

        username = JetspeedSecurity.convertUserName(username);
        password = JetspeedSecurity.convertPassword(password);

        try
        {
            user = JetspeedUserManagement.getUser(new UserNamePrincipal(username));
        }
        catch (UnknownUserException e)
        {
            throw new FailedLoginException(e.toString());
        }
        catch (JetspeedSecurityException e)
        {
            throw new LoginException(e.toString());
        }

        if(!LDAPUserManagement.passwordsMatch(user, password))
        {
            throw new FailedLoginException("Credential authentication failure");
        }

        // Mark the user as being logged in.
        user.setHasLoggedIn(new Boolean(true));

        // Store the clear-text password to session if some of the
        // portlets need it (for example to single-signon functionality)
        user.setTemp( "sessionPassword", password );

        // Set the last_login date in the database.
        try
        {
            user.updateLastLogin();
            putUserIntoContext(user);

            if (cachingEnable)
            {
                JetspeedSecurityCache.load(username);
            }
        }
        catch (Exception e)
        {
            putUserIntoContext(JetspeedSecurity.getAnonymousUser());
            throw new LoginException("Failed to update last login ", e);
        }

        return user;

    }
View Full Code Here

            }

        }
        catch (JetspeedSecurityException e)
        {
            throw new LoginException("Failed to get anonymous user: " + e);
        }
        return user;
    }
View Full Code Here

             // }
            getAnonymousUser();
        }
        catch (Exception e)
        {
            throw new LoginException("Exception logging user out ", e );
        }
    }
View Full Code Here

        throws LoginException
    {

        if (username.equals(this.anonymousUser))
        {
            throw new LoginException("Anonymous user cannot login");
        }

        JetspeedUser user = null;

        username = JetspeedSecurity.convertUserName(username);
        password = JetspeedSecurity.convertPassword(password);
      
        try
        {
            user = JetspeedUserManagement.getUser(new UserNamePrincipal(username));
            password = JetspeedSecurity.encryptPassword(password);
        }                           
        catch (UnknownUserException e)
        {
            logger.warn("Unknown user attempted access: " + username, e);
            throw new FailedLoginException(e.toString());
        }
        catch (JetspeedSecurityException e)
        {
            logger.warn("User denied authentication: " + username, e);
            throw new LoginException(e.toString());
        }

        if(!user.getPassword().equals(password))
        {
            logger.error("Invalid password for user: " + username);
            throw new FailedLoginException("Credential authentication failure");
       

        // Check for password expiration
        if (this.expirationPeriod > 0)
        {
            Date passwordLastChangedDate = user.getPasswordChanged();
            Date passwordExpireDate = null;
            if (passwordLastChangedDate != null) {
                GregorianCalendar gcal = (GregorianCalendar) GregorianCalendar.getInstance();
                gcal.setTime(passwordLastChangedDate);
                gcal.add(GregorianCalendar.DATE, this.expirationPeriod);
                passwordExpireDate = gcal.getTime();
                if (logger.isDebugEnabled())
                {
                    logger.debug("TurbineAuthentication: password last changed = " + passwordLastChangedDate.toString() +
                              ", password expires = " + passwordExpireDate.toString());
                }
            }

            if (passwordExpireDate == null || (new Date().getTime() > passwordExpireDate.getTime())) {
                throw new CredentialExpiredException("Password expired");
            }

        }

        // Mark the user as being logged in.
        user.setHasLoggedIn(new Boolean(true));

        // Set the last_login date in the database.
        try
        {
            user.updateLastLogin();
            putUserIntoContext(user);
            if (cachingEnable)
            {
                JetspeedSecurityCache.load(username);
            }
        }
        catch (Exception e)
        {
            logger.error( "Failed to update last login ", e);
            putUserIntoContext(JetspeedSecurity.getAnonymousUser());
            throw new LoginException("Failed to update last login ", e);
        }

        return user;
       
    }
View Full Code Here

            }
        }
        catch (JetspeedSecurityException e)
        {
            logger.error( "Failed to get anonymous user: ", e );
            throw new LoginException("Failed to get anonymous user: ", e);
        }
        return user;
    }
View Full Code Here

            getAnonymousUser();
        }
        catch (Exception e)
        {
            logger.error( "Exception logging user out ", e );
            throw new LoginException("Exception logging user out ", e );
        }
    }
View Full Code Here

             // }
            getAnonymousUser();
        }
        catch (Exception e)
        {
            throw new LoginException("Exception logging user out ", e );
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.services.security.LoginException

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.