Examples of RoleManager


Examples of org.apache.jetspeed.security.RoleManager

                .getComponent("org.apache.jetspeed.security.GroupManager");
        if (groupManager == null)
            throw new SerializerException(
                    SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
                            .create("org.apache.jetspeed.security.GroupManager"));
        RoleManager roleManager = (RoleManager) getCM()
        .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());
          }
         
        //credentials
              Subject subject = user.getSubject();

          ArrayList listTemp = jsuser.getPrivateCredentials();
          if ((listTemp != null) && (listTemp.size()>0))
          {
            Iterator _itTemp = listTemp.iterator();
            while (_itTemp.hasNext())
            {
              subject.getPrivateCredentials().add(_itTemp.next());
            }
          }
          listTemp = jsuser.getPublicCredentials();
          if ((listTemp != null) && (listTemp.size()>0))
          {
            Iterator _itTemp = listTemp.iterator();
            while (_itTemp.hasNext())
            {
              subject.getPublicCredentials().add(_itTemp.next());
            }
          }
          JSUserGroups jsUserGroups = jsuser.getGroupString();
          if (jsUserGroups != null)
            listTemp = this.getTokens(jsUserGroups.toString());
          else
            listTemp = null;
          if ((listTemp != null) && (listTemp.size()>0))
          {
            Iterator _itTemp = listTemp.iterator();
            while (_itTemp.hasNext())
            {
              groupManager.addUserToGroup(jsuser.getName(), (String)_itTemp.next());
            }
          }
          JSUserRoles jsUserRoles = jsuser.getRoleString();
          if (jsUserRoles != null)
            listTemp = this.getTokens(jsUserRoles.toString());
          else
            listTemp = null;
          if ((listTemp != null) && (listTemp.size()>0))
          {
            Iterator _itTemp = listTemp.iterator();
            while (_itTemp.hasNext())
            {
              roleManager.addRoleToUser(jsuser.getName(), (String)_itTemp.next());
            }
          }
            JSUserAttributes attributes = jsuser.getUserInfo();
          if (attributes != null)
          {
View Full Code Here

Examples of org.apache.jetspeed.security.RoleManager

   *
   * @return
   */
    private void exportRoles() throws SerializerException
    {
        RoleManager roleManager = (RoleManager) getCM()
                .getComponent("org.apache.jetspeed.security.RoleManager");
        if (roleManager == null)
            throw new SerializerException(
                    SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
                            .create("org.apache.jetspeed.security.RoleManager"));

        Iterator list = null;
        try
        {
            list = roleManager.getRoles("");
        } catch (Exception e)
        {
            throw new SerializerException(
                    SerializerException.GET_EXISTING_OBJECTS
                            .create(new String[]
View Full Code Here

Examples of org.apache.jetspeed.security.RoleManager

                .getComponent("org.apache.jetspeed.security.GroupManager");
        if (groupManager == null)
            throw new SerializerException(
                    SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
                            .create("org.apache.jetspeed.security.GroupManager"));
        RoleManager roleManager = (RoleManager) getCM()
        .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());
          }
         
        //credentials
              Subject subject = user.getSubject();

          ArrayList listTemp = jsuser.getPrivateCredentials();
          if ((listTemp != null) && (listTemp.size()>0))
          {
            Iterator _itTemp = listTemp.iterator();
            while (_itTemp.hasNext())
            {
              subject.getPrivateCredentials().add(_itTemp.next());
            }
          }
          listTemp = jsuser.getPublicCredentials();
          if ((listTemp != null) && (listTemp.size()>0))
          {
            Iterator _itTemp = listTemp.iterator();
            while (_itTemp.hasNext())
            {
              subject.getPublicCredentials().add(_itTemp.next());
            }
          }
          JSUserGroups jsUserGroups = jsuser.getGroupString();
          if (jsUserGroups != null)
            listTemp = this.getTokens(jsUserGroups.toString());
          else
            listTemp = null;
          if ((listTemp != null) && (listTemp.size()>0))
          {
            Iterator _itTemp = listTemp.iterator();
            while (_itTemp.hasNext())
            {
              groupManager.addUserToGroup(jsuser.getName(), (String)_itTemp.next());
            }
          }
          JSUserRoles jsUserRoles = jsuser.getRoleString();
          if (jsUserRoles != null)
            listTemp = this.getTokens(jsUserRoles.toString());
          else
            listTemp = null;
          if ((listTemp != null) && (listTemp.size()>0))
          {
            Iterator _itTemp = listTemp.iterator();
            while (_itTemp.hasNext())
            {
              roleManager.addRoleToUser(jsuser.getName(), (String)_itTemp.next());
            }
          }
            JSUserAttributes attributes = jsuser.getUserInfo();
          if (attributes != null)
          {
View Full Code Here

Examples of org.apache.jetspeed.security.RoleManager

   *
   * @return
   */
    private void exportRoles() throws SerializerException
    {
        RoleManager roleManager = (RoleManager) getCM()
                .getComponent("org.apache.jetspeed.security.RoleManager");
        if (roleManager == null)
            throw new SerializerException(
                    SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
                            .create("org.apache.jetspeed.security.RoleManager"));

        Iterator list = null;
        try
        {
            list = roleManager.getRoles("");
        } catch (Exception e)
        {
            throw new SerializerException(
                    SerializerException.GET_EXISTING_OBJECTS
                            .create(new String[]
View Full Code Here

Examples of org.apache.jetspeed.security.RoleManager

                .getComponent("org.apache.jetspeed.security.GroupManager");
        if (groupManager == null)
            throw new SerializerException(
                    SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
                            .create("org.apache.jetspeed.security.GroupManager"));
        RoleManager roleManager = (RoleManager) getCM()
        .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());
          }
         
        //credentials
              Subject subject = user.getSubject();

          ArrayList listTemp = jsuser.getPrivateCredentials();
          if ((listTemp != null) && (listTemp.size()>0))
          {
            Iterator _itTemp = listTemp.iterator();
            while (_itTemp.hasNext())
            {
              subject.getPrivateCredentials().add(_itTemp.next());
            }
          }
          listTemp = jsuser.getPublicCredentials();
          if ((listTemp != null) && (listTemp.size()>0))
          {
            Iterator _itTemp = listTemp.iterator();
            while (_itTemp.hasNext())
            {
              subject.getPublicCredentials().add(_itTemp.next());
            }
          }
          JSUserGroups jsUserGroups = jsuser.getGroupString();
          if (jsUserGroups != null)
            listTemp = this.getTokens(jsUserGroups.toString());
          else
            listTemp = null;
          if ((listTemp != null) && (listTemp.size()>0))
          {
            Iterator _itTemp = listTemp.iterator();
            while (_itTemp.hasNext())
            {
              groupManager.addUserToGroup(jsuser.getName(), (String)_itTemp.next());
            }
          }
          JSUserRoles jsUserRoles = jsuser.getRoleString();
          if (jsUserRoles != null)
            listTemp = this.getTokens(jsUserRoles.toString());
          else
            listTemp = null;
          if ((listTemp != null) && (listTemp.size()>0))
          {
            Iterator _itTemp = listTemp.iterator();
            while (_itTemp.hasNext())
            {
              roleManager.addRoleToUser(jsuser.getName(), (String)_itTemp.next());
            }
          }
            JSUserAttributes attributes = jsuser.getUserInfo();
          if (attributes != null)
          {
View Full Code Here

Examples of org.apache.jetspeed.security.RoleManager

   *
   * @return
   */
    private void exportRoles() throws SerializerException
    {
        RoleManager roleManager = (RoleManager) getCM()
                .getComponent("org.apache.jetspeed.security.RoleManager");
        if (roleManager == null)
            throw new SerializerException(
                    SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
                            .create("org.apache.jetspeed.security.RoleManager"));

        Iterator list = null;
        try
        {
            list = roleManager.getRoles("");
        } catch (Exception e)
        {
            throw new SerializerException(
                    SerializerException.GET_EXISTING_OBJECTS
                            .create(new String[]
View Full Code Here

Examples of org.apache.jetspeed.security.RoleManager

                public void onSubmit()
                {
                    UserManager userManager = (UserManager)getManager();
                    JetspeedPrincipal principal = getManager().newPrincipal(
                            getUserName(), false);
                    RoleManager roleManager = ((AbstractAdminWebApplication)getApplication()).getServiceLocator().getRoleManager();
                    PageManager pageManager = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPageManager();
                    try
                    {
                        getManager().addPrincipal(principal, null);
                        User user = userManager.getUser(getUserName());

                        if(!StringUtils.isEmpty(defaultRole))
                        {
                            roleManager.addRoleToUser(getUserName(), defaultRole);
                        }
                        if(!StringUtils.isEmpty(requiredRole))
                        {
                            roleManager.addRoleToUser(getUserName(), requiredRole);
                        }
                       
                        Profiler profiler = getServiceLocator().getProfiler();
                       
                        if (!StringUtils.isEmpty(getProfilingRule()))
View Full Code Here

Examples of org.apache.jetspeed.security.RoleManager

     */
    public void addRole()
    {
        ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
        Map appMap = (Map) externalContext.getApplicationMap();
        RoleManager roleMgr = (RoleManager) appMap.get(CommonPortletServices.CPS_ROLE_MANAGER_COMPONENT)
        try
        {
            String roleToAddPath = getRoleName();
            // If the role to add is relative to a selected parent.
            if (!getParentRole().getRoleName().equals(DEFAULT_PARENT_ROLE_NAME))
            {
                roleToAddPath = getParentRole().getRoleName() + "." + roleToAddPath;
            }
            if (log.isDebugEnabled())
            {
                log.debug("Adding role: " + roleToAddPath);
            }
            // Add role.
            roleMgr.addRole(roleToAddPath);
            // Get the newly added role.
            Role addedRole = roleMgr.getRole(roleToAddPath);
            // Resolve the tree table.
            FacesContext facesContext = FacesContext.getCurrentInstance();
            VariableResolver vr = facesContext.getApplication().getVariableResolver();
            RoleTreeTable roleTree = (RoleTreeTable) vr.resolveVariable(facesContext, RoleTreeTable.ROLE_TREE_TABLE);
            // Get the listeners registered.
View Full Code Here

Examples of org.apache.jetspeed.security.RoleManager

     */
    public void init(PortletConfig config) throws PortletException
    {
        super.init(config);

        RoleManager roleMgr = (RoleManager) getPortletContext().getAttribute(CommonPortletServices.CPS_ROLE_MANAGER_COMPONENT);
        if (null == roleMgr)
        {
            throw new PortletException("Failed to find the role manager on portlet initialization.");
        }
    }
View Full Code Here

Examples of org.apache.lenya.ac.RoleManager

            PolicyManager policyManager = accessController.getPolicyManager();
            Identity identity = workflowable.getSession().getIdentity();
            AccreditableManager accreditableMgr = accessController
            .getAccreditableManager();
            Policy policy = policyManager.getPolicy(accreditableMgr, url);
            RoleManager roleManager = accreditableMgr.getRoleManager();
           
            boolean complied = false;
           
            for (Iterator i = this.roleIds.iterator(); i.hasNext(); ) {
                String roleId = (String) i.next();
                Role role = roleManager.getRole(roleId);
                if (policy.check(identity, role) == Policy.RESULT_GRANTED) {
                    complied = true;
                }
            }
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.