Examples of JetspeedUser


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

        // Get  users from the UserGroupRole info
        Iterator iterator = users.iterator();
        while (iterator.hasNext())
        {
          JetspeedUser user = (JetspeedUser)iterator.next();
                    childrenVector.addElement(
            Utility.getUserParentUri() + "/" + user.getUserName());
        }

        Class objclass =
          Class.forName("org.apache.slide.structure.GroupNode");

        Class[] argClasses =
          {
            Class.forName("java.lang.String"),
            Class.forName("java.util.Vector"),
            Class.forName("java.util.Vector")
          };
        Object[] arguments =
          {
            uri.toString(),
            childrenVector,
            linksVector
          };

        Constructor constructor = objclass.getConstructor(argClasses);

        result = (ObjectNode)constructor.newInstance(arguments);

            // Check if parent uri name = the jetspeed user uri root
      }
      else if (uri.getParentUri()
            .toString()
            .equals(Utility.getUserParentUri()))
      {

                // Retrieve Jetspeed users
        String userName =
          uri.toString().substring(
            uri.toString().lastIndexOf('/') + 1);

                JetspeedSecurityService service = (JetspeedSecurityService) TurbineServices.getInstance().
                                         getService(JetspeedSecurityService.SERVICE_NAME);
                JetspeedUser user = service.getUser(userName);

                // Create and populate a Slide ObjectNode for this user
        Vector childrenVector = new Vector();
        Vector linksVector = new Vector();
View Full Code Here

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

    public void ExampleOfDisablingUser(JetspeedRunData rundata)
    {
        try
        {
            JetspeedUser user = user = rundata.getJetspeedUser();
            user.setDisabled(true);
            JetspeedUserManagement.saveUser(user);
        }
        catch (JetspeedSecurityException e)
        {
            Log.error("failed to save user", e);
View Full Code Here

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

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

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

     * @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)
        {
            logger.error( "Failed to get anonymous user: ", e );
View Full Code Here

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

    }

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

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

        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

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

     */
    public boolean alreadyImported()
    {
        try
        {
            JetspeedUser user = JetspeedSecurity.getUser("admin");
            QueryLocator ql = new QueryLocator(QueryLocator.QUERY_USER);
            ql.setUser(user);
            Iterator iterator = PsmlManager.query(ql);
            if (iterator.hasNext())
            {                     
View Full Code Here

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

            data.setMessage(message);
            data.setStackTrace(org.apache.turbine.util.StringUtils.stackTrace(other), other);
            return;
        }
    
        JetspeedUser user = (JetspeedUser)data.getUser();

        //if the user is not logged in and auto-login is enable - try and do it.
        if ( ( user==null || !user.hasLoggedIn() ) && JetspeedResources.getBoolean("automatic.logon.enable", false) ) {
          // need to make sure there are cookies - turbine does not handle this currently
          if ( data.getRequest().getCookies() != null )
          {
            //check for user in cookie
            String userName = data.getCookies().getString("username","");
            String loginCookieValue = data.getCookies().getString("logincookie","");

            if ( userName.length() > 0 && loginCookieValue.length() >0 )
            {
              try {
                user = JetspeedSecurity.getUser(userName);
                if (user.getPerm("logincookie","").equals(loginCookieValue)) {
                  //cookie is present and correct - log the user in
                  data.setUser(user);
                  user.setHasLoggedIn(new Boolean(true));
                  user.updateLastLogin();
                  data.save();
                }
              } catch (LoginException noSuchUser) {
                //user not found - ignore it - they will not be logged in automatically
        } catch (org.apache.jetspeed.services.security.UnknownUserException unknownUser) {
        //user not found - ignore it - they will not be logged in automatically
        logger.warn("Username from the cookie was not found: " + userName);
        } catch (Exception other){
        logger.error(other);         
        }
            }
          }
        }

        // now, define Jetspeed specific properties, using the customized
        // RunData properties
        JetspeedRunData jdata = null;
       
        try
        {
            jdata = (JetspeedRunData)data;
        }
        catch (ClassCastException e)
        {
            logger.error("The RunData object does not implement the expected interface, "
                       + "please verify the RunData factory settings", e);
            return;
        }
        String language = (String) data.getRequest().getParameter("js_language");

        if (null != language)
        {
            user.setPerm("language", language);
        }
       
        // Get the locale store it in the user object
        CustomLocalizationService locService = (CustomLocalizationService) ServiceUtil.getServiceByName(
            LocalizationService.SERVICE_NAME);
View Full Code Here

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

                Profile profile = (Profile)entry.getDocument();
                if (null == profile)
                {
                    continue;
                }
                JetspeedUser pUser = profile.getUser();
                if (null != pUser && pUser.getUserName().equals(user.getUserName()))
                {
                  it.remove();
                }
            }
        }
View Full Code Here

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

        StringBuffer path = new StringBuffer();

        // move the base dir is either user or role is specified
        Role role = locator.getRole();
        Group group = locator.getGroup();
        JetspeedUser user = locator.getUser();

        if (user != null)
        {
            path.append(PATH_USER);
            String name = user.getUserName();
            if (null != name && name.length() > 0)
            {
                path.append(File.separator)
                    .append(name);
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.