Examples of GroupManager


Examples of org.apache.jetspeed.security.GroupManager

     * @throws SerializerException
     */
    private void recreateRolesGroupsUsers() throws SerializerException
    {
      logMe("recreateRolesGroupsUsers");
        GroupManager groupManager = (GroupManager) getCM()
                .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());
View Full Code Here

Examples of org.apache.jetspeed.security.GroupManager

     *
     * @throws SerializerException
     */
    private void exportGroups() throws SerializerException
    {
        GroupManager groupManager = (GroupManager) getCM()
                .getComponent("org.apache.jetspeed.security.GroupManager");
        if (groupManager == null)
            throw new SerializerException(
                    SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
                            .create("org.apache.jetspeed.security.GroupManager"));
        Iterator list = null;
        try
        {
            list = groupManager.getGroups("");
        } catch (Exception e)
        {
            throw new SerializerException(
                    SerializerException.GET_EXISTING_OBJECTS
                            .create(new String[]
View Full Code Here

Examples of org.apache.jetspeed.security.GroupManager

     * @throws SerializerException
     */
    private void recreateRolesGroupsUsers() throws SerializerException
    {
      logMe("recreateRolesGroupsUsers");
        GroupManager groupManager = (GroupManager) getCM()
                .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());
View Full Code Here

Examples of org.apache.jetspeed.security.GroupManager

     *
     * @throws SerializerException
     */
    private void exportGroups() throws SerializerException
    {
        GroupManager groupManager = (GroupManager) getCM()
                .getComponent("org.apache.jetspeed.security.GroupManager");
        if (groupManager == null)
            throw new SerializerException(
                    SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
                            .create("org.apache.jetspeed.security.GroupManager"));
        Iterator list = null;
        try
        {
            list = groupManager.getGroups("");
        } catch (Exception e)
        {
            throw new SerializerException(
                    SerializerException.GET_EXISTING_OBJECTS
                            .create(new String[]
View Full Code Here

Examples of org.apache.karaf.cellar.core.GroupManager

        System.err.println(executeCommand("cluster:group-list"));
        System.err.println(executeCommand("cluster:group-set testgroup " + localNode.getId()));
        System.err.println(executeCommand("cluster:group-list"));

        GroupManager groupManager = getOsgiService(GroupManager.class);
        assertNotNull(groupManager);

        Set<Group> groups = groupManager.listAllGroups();
        assertEquals("There should be 2 cellar groups", 2, groups.size());

        System.err.println(executeCommand("cluster:group-delete testgroup "));
        System.err.println(executeCommand("cluster:group-list"));
        groups = groupManager.listAllGroups();
        assertEquals("There should be a single cellar group", 1, groups.size());
    }
View Full Code Here

Examples of org.apache.karaf.cellar.core.GroupManager

        System.err.println(executeCommand("cluster:group-list"));
        System.err.println(executeCommand("cluster:group-set testgroup " + localNode.getId()));
        System.err.println(executeCommand("cluster:group-list"));

        GroupManager groupManager = getOsgiService(GroupManager.class);
        assertNotNull(groupManager);

        Set<Group> groups = groupManager.listAllGroups();
        assertEquals("There should be 2 cellar groups", 2, groups.size());

        System.err.println(executeCommand("cluster:group-delete testgroup "));
        System.err.println(executeCommand("cluster:group-list"));
        groups = groupManager.listAllGroups();
        assertEquals("There should be a single cellar group", 1, groups.size());
    }
View Full Code Here

Examples of org.apache.lenya.ac.GroupManager

        Configuration[] groups = config.getChildren(GROUPS);

        if (groups.length == 1) {
            groups = groups[0].getChildren(GROUP);

            GroupManager manager;
            try {
                manager = getAccreditableManager().getGroupManager();
            } catch (AccessControlException e) {
                throw new ConfigurationException("configuration failed: ", e);
            }

            for (int i = 0; i < groups.length; i++) {
                String groupId = groups[i].getValue();
                Group group = manager.getGroup(groupId);

                if (group == null) {
                    throw new ConfigurationException("Couldn't find Group for group name ["
                            + groupId + "]");
                }
View Full Code Here

Examples of org.apache.qpid.server.security.group.GroupManager

        List<GroupManager> groupManagerList = new ArrayList<GroupManager>();
        Configuration securityConfig = configuration.getConfig().subset("security");

        for(GroupManagerFactory factory : _groupManagerServiceLoader.instancesOf(GroupManagerFactory.class))
        {
            GroupManager groupManager = factory.createInstance(securityConfig);
            if (groupManager != null)
            {
                groupManagerList.add(groupManager);
                for(GroupManagerChangeListener listener : _groupManagerChangeListeners)
                {
View Full Code Here

Examples of org.apache.qpid.server.security.group.GroupManager

    private GroupProviderAdapter createGroupProvider(UUID id, Broker broker, Map<String, Object> attributes)
    {
        for (GroupManagerFactory factory : _factories.values())
        {
            GroupManager manager = factory.createInstance(attributes);
            if (manager != null)
            {
                verifyGroupManager(manager, broker);
                return new GroupProviderAdapter(id, broker, manager, attributes,factory.getAttributeNames());
            }
View Full Code Here

Examples of org.apache.qpid.server.security.group.GroupManager

        Collection<GroupProvider> groupProviders = broker.getGroupProviders();
        for (GroupProvider groupProvider : groupProviders)
        {
            if (groupProvider instanceof GroupProviderAdapter)
            {
                GroupManager providerManager = ((GroupProviderAdapter) groupProvider).getGroupManager();
                if (manager.equals(providerManager))
                {
                    throw new IllegalConfigurationException("A group provider with the same settings already exists");
                }
            }
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.