Examples of LDAPUser


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

    public JetspeedUser getUser(Principal principal)
        throws JetspeedSecurityException
    {
        BasicAttributes attr = new BasicAttributes();
        Vector userurls = new Vector();
        LDAPUser user = null;

        try
        {
            userurls = JetspeedLDAP.search(JetspeedLDAP.buildURL("ou=users"),
                       "(&(uid="+principal.getName()+")(objectclass=jetspeeduser))", ATTRS, true);
        }
        catch (Exception e)
        {
            logger.error( "Failed to retrieve user '" + principal.getName() + "'", e );
            throw new UserException("Failed to retrieve user '" + principal.getName() + "'", e);
        }
        
        if (userurls.size() == 1)
        {
            user = new LDAPUser((LDAPURL) ((Vector)userurls.elementAt(0)).firstElement());
            return user;
        }
        else if(userurls.size() > 1)
        {
            throw new UserException("Multiple Users with same username '" + principal.getName() + "'");
View Full Code Here

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

            DirContext ctx = JetspeedLDAP.getService().connect(url);
            userEnum = JetspeedLDAP.search(ctx, url.getDN(), filter, attributesToFetch, JetspeedLDAP.getService().SUB);

            while (userEnum.hasMoreElements())
            {
                LDAPUser user = buildUser(((SearchResult)userEnum.nextElement()).getAttributes());
                resultList.add( user );
            }

            JetspeedLDAP.getService().checkAndCloseContext(ctx);
        }
View Full Code Here

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

        return ( resultList.iterator() );
    }

    protected LDAPUser buildUser(Attributes attributes)
    {
        return new LDAPUser(attributes);
    }
View Full Code Here

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

    public void removeUser(Principal principal)
        throws JetspeedSecurityException
    {
        BasicAttributes attr= new BasicAttributes();
        Vector userurls = new Vector();
        LDAPUser user = (LDAPUser)getUser(principal);

        try
        {
            JetspeedLDAP.deleteEntry(user.getldapurl());
            PsmlManager.removeUserDocuments(user);
        }
        catch(Exception e)
        {
            logger.error( "Failed to remove account '" + user.getUserName() + "'", e );
            throw new UserException("Failed to remove account '" +
                user.getUserName() + "'", e);
        }

    }
View Full Code Here

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

     * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
     */
    public void grantRole(String username, String roleName)
        throws JetspeedSecurityException
    {
        LDAPUser user;
        LDAPRole role;
        try
        {
            user = (LDAPUser)JetspeedSecurity.getUser(new UserNamePrincipal(username));
            role = (LDAPRole)JetspeedSecurity.getRole(roleName);
        }
        catch(JetspeedSecurityException e)

        {
            throw new RoleException("Failed to Retrieve User or Role: ", e);
        }

        try
        {
            user.addGroupRole(JetspeedSecurity.JETSPEED_GROUP, roleName);
            user.update(false);

            if (cachingEnable)
            {
                JetspeedSecurityCache.addRole(username, role);
            }
View Full Code Here

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

     * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
     */
    public void revokeRole(String username, String roleName)
        throws JetspeedSecurityException
    {
        LDAPUser user;

        try
        {
            user = (LDAPUser)JetspeedSecurity.getUser(new UserNamePrincipal(username));
        }
        catch(JetspeedSecurityException e)
        {
            throw new RoleException("Failed to Retrieve User: ", e);
        }

        try
        {
            user.removeGroupRole(JetspeedSecurity.JETSPEED_GROUP, roleName);
            user.update(false);

            if (cachingEnable)
            {
                JetspeedSecurityCache.removeRole(username, roleName);
            }
View Full Code Here

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

    public JetspeedUser getUser(Principal principal)
        throws JetspeedSecurityException
    {
        BasicAttributes attr = new BasicAttributes();
        Vector userurls = new Vector();
        LDAPUser user = null;

        try
        {
            userurls = JetspeedLDAP.search(JetspeedLDAP.buildURL("ou=users"),
                       "(&(uid="+principal.getName()+")(objectclass=jetspeeduser))", ATTRS, true);
        }
        catch (Exception e)
        {
            throw new UserException("Failed to retrieve user '" + principal.getName() + "'", e);
        }
        
        if (userurls.size() == 1)
        {
            user = new LDAPUser((LDAPURL) ((Vector)userurls.elementAt(0)).firstElement());
            return user;
        }
        else if(userurls.size() > 1)
        {
            throw new UserException("Multiple Users with same username '" + principal.getName() + "'");
View Full Code Here

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

            DirContext ctx = JetspeedLDAP.getService().connect(url);
            userEnum = JetspeedLDAP.search(ctx, url.getDN(), filter, attributesToFetch, JetspeedLDAP.getService().SUB);

            while (userEnum.hasMoreElements())
            {
                LDAPUser user = buildUser(((SearchResult)userEnum.nextElement()).getAttributes());
                resultList.add( user );
            }

            JetspeedLDAP.getService().checkAndCloseContext(ctx);
        }
View Full Code Here

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

        return ( resultList.iterator() );
    }

    protected LDAPUser buildUser(Attributes attributes)
    {
        return new LDAPUser(attributes);
    }
View Full Code Here

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

    public void removeUser(Principal principal)
        throws JetspeedSecurityException
    {
        BasicAttributes attr= new BasicAttributes();
        Vector userurls = new Vector();
        LDAPUser user = (LDAPUser)getUser(principal);

        try
        {
            JetspeedLDAP.deleteEntry(user.getldapurl());
            PsmlManager.removeUserDocuments(user);
        }
        catch(Exception e)
        {
            throw new UserException("Failed to remove account '" +
                user.getUserName() + "'", e);
        }

    }
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.