Examples of LDAPUser


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

    public Iterator getGroups(String username)
        throws JetspeedSecurityException
    {
        Vector groups = new Vector();
        StringTokenizer st;
        LDAPUser user;

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

        try
        {
            for (Enumeration enum1 = user.getGroupRoles().elements() ;enum1.hasMoreElements() ;)
            {
                st = new StringTokenizer((String)enum1.nextElement(),",");
                groups.add(new LDAPGroup(st.nextToken(), false));
            }
        }
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 joinGroup(String username, String groupname)
        throws JetspeedSecurityException
    {
        LDAPUser user;
        try
        {
            user = (LDAPUser)JetspeedSecurity.getUser(new UserNamePrincipal(username));
        }
        catch(JetspeedSecurityException e)
        {
            throw new GroupException("Failed to Retrieve User: ", e);
        }
        try
        {
            user.addGroupRole(groupname, defaultRole);
            user.update(false);
        }
        catch(Exception e)
        {
            throw new GroupException("Failed to add group info ", 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 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);
        }
        catch(JetspeedSecurityException e)
        {
            throw new GroupException("Failed to Retrieve User: ", e);
        }
        try
        {
            user.addGroupRole(groupname, rolename);
            user.update(false);
        }
        catch(Exception e)
        {
            throw new GroupException("Failed to add group info ", 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 unjoinGroup(String username, String groupName)
        throws JetspeedSecurityException
    {
        LDAPUser user;

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

        try
        {
            user.removeGroup(groupName);
            user.update(false);
        }
        catch(Exception e)
        {
            throw new GroupException("Failed to add group info ", 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 unjoinGroup(String username, String groupName, String rolename)
        throws JetspeedSecurityException
    {
        LDAPUser user;

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

        try
        {
            user.removeGroup(groupName);
            user.update(false);
        }
        catch(Exception e)
        {
            throw new GroupException("Failed to add group info ", e);
        }
View Full Code Here

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

    public boolean inGroup(String username, String groupname)
        throws JetspeedSecurityException
    {
        Vector groups= new Vector();
        StringTokenizer st;
        LDAPUser user;

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

        try
        {
            for (Enumeration enum1 = user.getGroupRoles().elements() ;enum1.hasMoreElements() ;)
            {
                st = new StringTokenizer((String)enum1.nextElement(),",");

                if (st.nextToken().equalsIgnoreCase(groupname))
                {
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)
        {
            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
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.