Package org.apache.jetspeed.om.security

Examples of org.apache.jetspeed.om.security.JetspeedUser


    public Profile createUserProfile(JetspeedUserProfile entity, Portlets portlets)
    {
        Profile profile = Profiler.createProfile();
        try
        {
            JetspeedUser user = JetspeedSecurity.getUser(entity.getUserName());
            if (null == user)
            {
                user = JetspeedUserFactory.getInstance();
                user.setUserName(entity.getUserName());
            }
            profile.setUser(user);

            profile.setMediaType(entity.getMediaType());
            profile.setLanguage(entity.getLanguage());
View Full Code Here


     * @param data
     * @return
     */
    public final Locale getLocale(RunData data)
    {
        JetspeedUser user = (JetspeedUser) data.getUser();
        if (user == null)
        {
            return getLocale(data.getRequest().getHeader(CustomLocalizationService.ACCEPT_LANGUAGE));
        }
        else
        {
            String lang = "null";

            try
            {
                if (user.getPerm("language") == null)
                {
                    return getLocale(data.getRequest().getHeader(CustomLocalizationService.ACCEPT_LANGUAGE));
                }
                else
                {
                    lang = user.getPerm("language").toString();
                    Locale locale = new Locale(lang, "");
                    return locale;
                }
            }
            catch (Exception use)
View Full Code Here

        if (disabled)
        {
            try
            {
                // disable the account
                JetspeedUser user = (JetspeedUser)JetspeedSecurity.getUser(username);
                if (user != null)
                {
                    user.setDisabled(true);
                    JetspeedSecurity.saveUser(user);
                }
            }
            catch (Exception e)
            {
View Full Code Here

    }

    protected JetspeedUser getUserFromContext()
    {
        JetspeedRunData rundata = getRunData();
        JetspeedUser user = null;
        if (rundata != null)
        {
            user = (JetspeedUser)rundata.getUser();
        }
        return user;
View Full Code Here

        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);
View Full Code Here

     * @exception LoginException if the authentication fails.
     */
    public JetspeedUser getAnonymousUser()
        throws LoginException
    {
        JetspeedUser user = null;

        try
        {
            user = JetspeedUserManagement.getUser(new UserNamePrincipal(anonymousUser));
            user.setHasLoggedIn(new Boolean(false));
            putUserIntoContext(user);
            if (cachingEnable)
            {
                JetspeedSecurityCache.load(user.getUserName());
            }

        }
        catch (JetspeedSecurityException e)
        {
View Full Code Here

    }

    protected JetspeedUser getUserFromContext()
    {
        JetspeedRunData rundata = getRunData();
        JetspeedUser user = null;
        if (rundata != null)
        {
            user = (JetspeedUser)rundata.getUser();
        }
        return user;
View Full Code Here

        if (systemUsers.contains(principal.getName()))
        {
            throw new UserException("[" + principal.getName() + "] is a system user and cannot be removed");
        }

        JetspeedUser user = getUser(principal);

        Criteria criteria = new Criteria();
        if (principal instanceof UserNamePrincipal)
        {
            criteria.add(TurbineUserPeer.LOGIN_NAME, principal.getName());
        }
        else if (principal instanceof UserIdPrincipal)
        {
            criteria.add(TurbineUserPeer.USER_ID, principal.getName());
        }
        else
        {
            throw new UserException("Invalid Principal Type in removeUser: " + principal.getClass().getName());
        }

        try
        {
            TurbineUserPeer.doDelete(criteria);
            PsmlManager.removeUserDocuments(user);
        }
        catch(Exception e)
        {
            String message = "Failed to remove account '" + user.getUserName() + "'";
            logger.error( message, e );
            throw new UserException( message, e );
        }

    }
View Full Code Here

     * @param data
     * @return
     */
    public final Locale getLocale(RunData data)
    {
        JetspeedUser user = (JetspeedUser) data.getUser();
        if (user == null)
        {
            return getLocale(data.getRequest().getHeader(CustomLocalizationService.ACCEPT_LANGUAGE));
        }
        else
        {
            String lang = "null";

            try
            {
                if (user.getPerm("language") == null)
                {
                    return getLocale(data.getRequest().getHeader(CustomLocalizationService.ACCEPT_LANGUAGE));
                }
                else
                {
                    lang = user.getPerm("language").toString();
                    Locale locale = new Locale(lang, "");
                    return locale;
                }
            }
            catch (Exception use)
View Full Code Here

     * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
     */
    public Iterator getRoles(String username)
        throws JetspeedSecurityException
    {
        JetspeedUser user = null;
        try
        {
            if (cachingEnable)
            {
                Iterator result = JetspeedSecurityCache.getRoles(username);
                if (null != result)
                {
                    return result;
                }
            }
            user = JetspeedSecurity.getUser(new UserNamePrincipal(username));
        }
        catch(JetspeedSecurityException e)
        {
            logger.error( "Failed to Retrieve User: " + username, e );
            throw new RoleException("Failed to Retrieve User: ", e);
        }
        Criteria criteria = new Criteria();
        criteria.add(TurbineUserGroupRolePeer.USER_ID, user.getUserId());
        List rels;
        HashMap roles;

        try
        {
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.om.security.JetspeedUser

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.