Package org.apache.jetspeed.om.security.ldap

Examples of org.apache.jetspeed.om.security.ldap.LDAPRole


        {
            for (Enumeration enum1 = user.getGroupRoles().elements(); enum1.hasMoreElements();)
            {
                st = new StringTokenizer((String)enum1.nextElement(), ",");
                LDAPGroup group = new LDAPGroup(st.nextToken(),false);
                LDAPRole role = new LDAPRole(st.nextToken(),false);
                BaseJetspeedGroupRole groupRole = new BaseJetspeedGroupRole();
                groupRole.setGroup(group);
                groupRole.setRole(role);
                roles.put(group.getName() + role.getName(), groupRole);
            }
        }
        catch(Exception e)
        {
            throw new RoleException("Failed to retrieve groups ", e);
View Full Code Here


            roleurls = JetspeedLDAP.search(JetspeedLDAP.buildURL("ou=roles"),"(objectclass=jetspeedrole)", ATTRS, true);
            if (roleurls.size() > 0)
            {
                for (Enumeration enum1 = roleurls.elements(); enum1.hasMoreElements() ;)
                {
                    roles.add(new LDAPRole((LDAPURL) (((Vector)enum1.nextElement()).firstElement())));
                }
            }
            else
            {
                throw new UnknownUserException("No role ");
View Full Code Here

     * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
     */
    public void addRole(Role role)
        throws JetspeedSecurityException
    {
      LDAPRole ldapRole = null;

        if(roleExists(role.getName()))
        {
            throw new RoleException("The role '" +
                role.getName() + "' already exists");
        }

        try
        {
            ldapRole = new LDAPRole(role.getName(), true);
            ldapRole.update(true);
        }
        catch(Exception e)
        {
            throw new RoleException("Failed to create role '" +
                role.getName() + "'", e);
        }

        if (cachingEnable)
        {
            JetspeedSecurityCache.addRole(ldapRole);
        }

        try
        {
            addDefaultRolePSML(ldapRole);
        }
        catch (Exception e)
        {
            try
            {
                removeRole(ldapRole.getName());
            }
            catch (Exception e2)
            {
            }
            throw new RoleException("failed to add default PSML for Role resource", e);
View Full Code Here

    public void removeRole(String roleName)
        throws JetspeedSecurityException
    {
        try
        {
            LDAPRole role = new LDAPRole(roleName, false);
            JetspeedLDAP.deleteEntry(role.getldapurl());
            PsmlManager.removeRoleDocuments(role);

            if(cascadeDelete)
            {
            }
View Full Code Here

    public void grantRole(String username, String roleName, String groupName)
        throws JetspeedSecurityException
    {
        LDAPUser user;
        LDAPRole role;
        try
        {
            user = (LDAPUser)JetspeedSecurity.getUser(new UserNamePrincipal(username));
            role = (LDAPRole)JetspeedSecurity.getRole(roleName);
        }
View Full Code Here

            roleurls = JetspeedLDAP.search(JetspeedLDAP.buildURL("ou=roles"),
                       "(&(uid=" + roleName + ")(objectclass=jetspeedrole))", ATTRS, true);

            if (roleurls.size() == 1)
            {
                return new LDAPRole((LDAPURL) ((Vector)roleurls.elementAt(0)).firstElement());
            }
            else if(roleurls.size() > 1)
            {
                throw new RoleException("Multiple roles with same name");
            }
View Full Code Here

     */
    public void joinGroup(String username, String groupname, String rolename)
        throws JetspeedSecurityException
    {
        LDAPUser user;
        LDAPRole role;

        try
        {
            user = (LDAPUser)JetspeedSecurity.getUser(new UserNamePrincipal(username));
            role = (LDAPRole)JetspeedSecurity.getRole(rolename);
View Full Code Here

    public Iterator getPermissions(String roleName)
        throws JetspeedSecurityException
    {
        Vector perms = new Vector();
        BasicAttributes attr= new BasicAttributes();
        LDAPRole role;
        LDAPPermission permission;
        Vector userurls;

        try
        {
            if (cachingEnable)
            {
                Iterator iterator = JetspeedSecurityCache.getPermissions(roleName);
                if (iterator != null)
                {
                    return iterator;
                }
            }

            userurls = JetspeedLDAP.search(JetspeedLDAP.buildURL("ou=roles"),
                       "(&(uid=" + roleName + ")(objectclass=jetspeedrole))", ATTRS, true);

            if (userurls.size() > 0)
            {
                role = new LDAPRole((LDAPURL) ((Vector)userurls.elementAt(0)).firstElement());
                for (Enumeration enum1= role.getRolePermissions().elements();enum1.hasMoreElements();)
                {
                    permission = new LDAPPermission((String)enum1.nextElement(), false);
                    perms.add(permission);
                }
            }
View Full Code Here

     */
    public void grantPermission(String roleName, String permissionName)
        throws JetspeedSecurityException
    {
        BasicAttributes attr = new BasicAttributes();
        LDAPRole role;
        LDAPPermission permission;

        try
        {
            role = (LDAPRole)JetspeedSecurity.getRole(roleName);
            permission = (LDAPPermission)JetspeedSecurity.getPermission(permissionName);

            role.addRolePermissions(permissionName);
            role.update(false);

            if (cachingEnable)
            {
                JetspeedSecurityCache.addPermission(roleName, permission);
            }
View Full Code Here

     */
    public void revokePermission(String roleName, String permissionName)
        throws JetspeedSecurityException
    {
        BasicAttributes attr= new BasicAttributes();
        LDAPRole role;
        Vector userurls;

        try
        {
            userurls = JetspeedLDAP.search(JetspeedLDAP.buildURL("ou=roles"),
                       "(&(uid="+ roleName+")(objectclass=jetspeedrole))", ATTRS, true);

            if (userurls.size() == 0)
            {
              throw new PermissionException("Role '" + roleName + "' does not exist!");
            }
            else
            {
                role = new LDAPRole((LDAPURL) ((Vector)userurls.elementAt(0)).firstElement());
                role.getRolePermissions().remove(permissionName);
                role.update(false);

                if (cachingEnable)
                {
                    JetspeedSecurityCache.removePermission(roleName, permissionName);
                }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.om.security.ldap.LDAPRole

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.