Package org.apache.jetspeed.security

Examples of org.apache.jetspeed.security.UserManager


        exportRoles();
        /** get the groups */
        exportGroups();

        /** users */
        UserManager userManager = (UserManager) getCM()
                .getComponent("org.apache.jetspeed.security.UserManager");
        if (userManager == null)
            throw new SerializerException(
                    SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
                            .create("org.apache.jetspeed.security.UserManager"));
        Iterator list = null;
        try
        {
            list = userManager.getUsers("");
        } catch (Exception e)
        {
            throw new SerializerException(
                    SerializerException.GET_EXISTING_OBJECTS
                            .create(new String[]
View Full Code Here


        .getComponent("org.apache.jetspeed.security.RoleManager");
        if (roleManager == null)
            throw new SerializerException(
                    SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
                            .create("org.apache.jetspeed.security.RoleManager"));
        UserManager userManager = (UserManager) getCM()
        .getComponent("org.apache.jetspeed.security.UserManager");
        if (userManager == null)
          throw new SerializerException(
            SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
                    .create("org.apache.jetspeed.security.UserManager"));

       
       
       
        JSGroups groups = null;
        JSRoles roles = null;
        Iterator _it = null;
        groups = ((JSSeedData)getSnapshot()).getGroups();
        if (groups != null)
        {
         _it = groups.iterator();
        while (_it.hasNext())
        {
          String name = ((JSGroup)_it.next()).getName();

          try
          {
            if (!(groupManager.groupExists(name)))
              groupManager.addGroup(name);
            Group group = groupManager.getGroup(name);
            this.groupMap.put(name, group.getPrincipal());
          } catch (Exception e)
          {
              throw new SerializerException(
                      SerializerException.CREATE_OBJECT_FAILED
                              .create(new String[]
                              { "Group", e.getMessage()}));
          }
        }
        }
      logMe("recreateGroups - done");
      logMe("processing roles");

        roles = ((JSSeedData)getSnapshot()).getRoles();
        if (roles!= null)
        {     
        _it = roles.iterator();
       
        while (_it.hasNext())
        {
          String name = ((JSRole)_it.next()).getName();

          try
          {
            if (!(roleManager.roleExists(name)))
              roleManager.addRole(name);
            Role role = roleManager.getRole(name);
            this.roleMap.put(name, role.getPrincipal());
          } catch (Exception e)
          {
              throw new SerializerException(
                      SerializerException.CREATE_OBJECT_FAILED
                              .create(new String[]
                              { "Role", e.getMessage()}));
          }
        }
        }
        logMe("recreateRoles - done");
      logMe("processing users");

      /** determine whether passwords can be reconstructed or not */
      int passwordEncoding = compareCurrentSecurityProvider((JSSeedData)getSnapshot());
        JSUsers users = null;
        users = ((JSSeedData)getSnapshot()).getUsers();
        if(users!=null)
        {_it = users.iterator();
        while (_it.hasNext())
        {
         
          JSUser jsuser = (JSUser)_it.next();

          try
          {
            User user = null;
            if (userManager.userExists(jsuser.getName()))
            {
              user = userManager.getUser(jsuser.getName());
            }
        if ((this.getSetting(JetspeedSerializer.KEY_OVERWRITE_EXISTING)) || (user == null))
        {
          if (user == null) //create new one
          {
              String password = recreatePassword(jsuser.getPassword());
                logMe("add User "+ jsuser.getName() + " with password " + password);
                 userManager.importUser(jsuser.getName(), password,(passwordEncoding == PASSTHRU_REQUIRED));
                logMe("add User done ");
            user = userManager.getUser(jsuser.getName());
          }
          try
          {
            userManager.setPasswordEnabled(jsuser.getName(), jsuser.getPwEnabled());           
            userManager.setPasswordUpdateRequired(jsuser.getName(), jsuser.getPwRequiredUpdate());
            java.sql.Date d = jsuser.getPwExpirationDate();
            if (d != null)
              userManager.setPasswordExpiration(jsuser.getName(), d);           
          }
          catch (Exception e)
          {
            // most likely caused by protected users (like "guest")
            logMe("setting userinfo for "+ jsuser.getName() + " failed because of " + e.getLocalizedMessage());
View Full Code Here

    /**
     * @see JetspeedSecurityServiceMBean#getUserManager()
     */
    public UserManager getUserManager()
    {
        UserManager um = (UserManager) ctx.getBean("org.apache.jetspeed.security.UserManager");
        return um;
    }
View Full Code Here

        .getComponent("org.apache.jetspeed.security.RoleManager");
        if (roleManager == null)
            throw new SerializerException(
                    SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
                            .create("org.apache.jetspeed.security.RoleManager"));
        UserManager userManager = (UserManager) getCM()
        .getComponent("org.apache.jetspeed.security.UserManager");
        if (userManager == null)
          throw new SerializerException(
            SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
                    .create("org.apache.jetspeed.security.UserManager"));

       
       
       
        JSGroups groups = null;
        JSRoles roles = null;

        groups = ((JSSeedData)getSnapshot()).getGroups();
       
        Iterator _it = groups.iterator();
        while (_it.hasNext())
        {
          String name = ((JSGroup)_it.next()).getName();

          try
          {
            if (!(groupManager.groupExists(name)))
              groupManager.addGroup(name);
            Group group = groupManager.getGroup(name);
            this.groupMap.put(name, group.getPrincipal());
          } catch (Exception e)
          {
              throw new SerializerException(
                      SerializerException.CREATE_OBJECT_FAILED
                              .create(new String[]
                              { "Group", e.getMessage()}));
          }
        }
      logMe("recreateGroups - done");
      logMe("processing roles");

        roles = ((JSSeedData)getSnapshot()).getRoles();
       
        _it = roles.iterator();
        while (_it.hasNext())
        {
          String name = ((JSRole)_it.next()).getName();

          try
          {
            if (!(roleManager.roleExists(name)))
              roleManager.addRole(name);
            Role role = roleManager.getRole(name);
            this.roleMap.put(name, role.getPrincipal());
          } catch (Exception e)
          {
              throw new SerializerException(
                      SerializerException.CREATE_OBJECT_FAILED
                              .create(new String[]
                              { "Role", e.getMessage()}));
          }
        }
      logMe("recreateRoles - done");
      logMe("processing users");

      /** determine whether passwords can be reconstructed or not */
      int passwordEncoding = compareCurrentSecurityProvider((JSSeedData)getSnapshot());
        JSUsers users = null;
        users = ((JSSeedData)getSnapshot()).getUsers();
       
        _it = users.iterator();
        while (_it.hasNext())
        {
         
          JSUser jsuser = (JSUser)_it.next();

          try
          {
            User user = null;
            if (userManager.userExists(jsuser.getName()))
            {
              user = userManager.getUser(jsuser.getName());
            }
        if ((this.getSetting(JetspeedSerializer.KEY_OVERWRITE_EXISTING)) || (user == null))
        {
          if (user == null) //create new one
          {
              String password = recreatePassword(jsuser.getPassword());
                logMe("add User "+ jsuser.getName() + " with password " + password);
                 userManager.importUser(jsuser.getName(), password,(passwordEncoding == PASSTHRU_REQUIRED));
                logMe("add User done ");
            user = userManager.getUser(jsuser.getName());
          }
          try
          {
            userManager.setPasswordEnabled(jsuser.getName(), jsuser.getPwEnabled());           
            userManager.setPasswordUpdateRequired(jsuser.getName(), jsuser.getPwRequiredUpdate());
            java.sql.Date d = jsuser.getPwExpirationDate();
            if (d != null)
              userManager.setPasswordExpiration(jsuser.getName(), d);           
          }
          catch (Exception e)
          {
            // most likely caused by protected users (like "guest")
            logMe("setting userinfo for "+ jsuser.getName() + " failed because of " + e.getLocalizedMessage());
View Full Code Here

        if (pm == null)

          throw new SerializerException(
            SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
                    .create("org.apache.jetspeed.profiler.Profiler"));
        UserManager userManager = (UserManager) getCM()
        .getComponent("org.apache.jetspeed.security.UserManager");
        if (userManager == null)
          throw new SerializerException(
            SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
                    .create("org.apache.jetspeed.security.UserManager"));

        // get Rules for each user

        Iterator _itUsers = ((JSSeedData)getSnapshot()).getUsers().iterator();
        while (_itUsers.hasNext())
        {
            JSUser _user = (JSUser) _itUsers.next();
            JSPrincipalRules jsRules = _user.getRules();
            try
            {
              User user = userManager.getUser(_user.getName());
              Principal principal = getUserPrincipal(user);
              if (jsRules != null)
              {
                Iterator _itRoles = jsRules.iterator();
                  while (_itRoles.hasNext())
View Full Code Here

        exportRoles();
        /** get the groups */
        exportGroups();

        /** users */
        UserManager userManager = (UserManager) getCM()
                .getComponent("org.apache.jetspeed.security.UserManager");
        if (userManager == null)
            throw new SerializerException(
                    SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
                            .create("org.apache.jetspeed.security.UserManager"));
        Iterator list = null;
        try
        {
            list = userManager.getUsers("");
        } catch (Exception e)
        {
            throw new SerializerException(
                    SerializerException.GET_EXISTING_OBJECTS
                            .create(new String[]
View Full Code Here

            HttpServletRequest request = (HttpServletRequest)sRequest;
            String username = request.getParameter(LoginConstants.USERNAME);
            String password = request.getParameter(LoginConstants.PASSWORD);           
            if (username != null)
            {
                UserManager userManager = (UserManager)Jetspeed.getComponentManager().getComponent("org.apache.jetspeed.security.UserManager");
                boolean success = userManager.authenticate(username, password);
                if (success)
                {
                    Set principals = new PrincipalsSet();
                    Subject subject = new Subject(true, principals, new HashSet(), new HashSet());
                    UserPrincipal userPrincipal = new UserSubjectPrincipalImpl(username, subject);
View Full Code Here

                {
                    // we have a login attempt failure
                    String userName = (String)request.getSessionAttribute(LoginConstants.USERNAME);
                    if ( userName != null && !userName.equals(""))
                    {
                        UserManager um = (UserManager)Jetspeed.getComponentManager().getComponent(UserManager.class);
                        if ( um != null )
                        {
                            User user = null;
                            try
                            {
                                user = um.getUser(userName);
                                UserPrincipal userPrincipal = (UserPrincipal)SecurityHelper.getPrincipal(user.getSubject(), UserPrincipal.class);
                                if ( !userPrincipal.isEnabled() )
                                {
                                    request.setSessionAttribute(LoginConstants.ERRORCODE, LoginConstants.ERROR_USER_DISABLED);
                                }
View Full Code Here

            {
                Principal userPrincipal = SecurityHelper.getPrincipal(subject, UserPrincipal.class);
                if (null != userPrincipal)
                {
                    log.debug("Got user principal: " + userPrincipal.getName());
                    UserManager userMgr = (UserManager) Jetspeed.getComponentManager().getComponent(UserManager.class);
                    try
                    {
                        if (!userMgr.getAnonymousUser().equals(userPrincipal.getName())
                                && userMgr.userExists(userPrincipal.getName()))
                        {
                            User user = userMgr.getUser(userPrincipal.getName());
                            // TODO if preferred lang or locale is defined in PLT.D, it's better to use it
                            Preferences prefs = user.getPreferences();
                            String localeString = prefs.get(PortalReservedParameters.PREFERED_LOCALE_ATTRIBUTE, null);
                            if (localeString != null)
                            {
View Full Code Here

    /**
     * @see JetspeedSecurityServiceMBean#getUserManager()
     */
    public UserManager getUserManager()
    {
        UserManager um = (UserManager) ctx.getBean("org.apache.jetspeed.security.UserManager");
        return um;
    }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.security.UserManager

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.