Package javax.naming.directory

Examples of javax.naming.directory.Attribute


            while (answer.hasMore())
            {
                SearchResult sr = (SearchResult) answer.next();
                Attributes attribs = sr.getAttributes();
                Attribute attr = attribs.get("turbineRoleName");

                if (attr != null && attr.get() != null)
                {
                    Role role = getNewRole(attr.get().toString());

                    roles.add(role);
                }
                else
                {
View Full Code Here


            while (answer.hasMore())
            {
                SearchResult sr = (SearchResult) answer.next();
                Attributes attribs = sr.getAttributes();
                Attribute attr = attribs.get("turbinePermissionName");

                if (attr != null && attr.get() != null)
                {
                    Permission perm = getNewPermission(attr.get().toString());

                    permissions.add(perm);
                }
                else
                {
View Full Code Here

            while (answer.hasMore())
            {
                SearchResult sr = (SearchResult) answer.next();
                Attributes attribs = sr.getAttributes();
                Attribute attr = attribs.get("turbinePermissionName");

                if (attr != null)
                {
                    NamingEnumeration values = attr.getAll();

                    while (values.hasMore())
                    {
                        String permName = values.next().toString();
                        Permission perm = getNewPermission(permName);
View Full Code Here

     */
    public void setLDAPAttributes(Attributes attribs)
            throws NamingException
    {

        Attribute attr;
        String attrName;

        // Set the User id.
        attrName = LDAPSecurityConstants.getUserIdAttribute();
        if (attrName != null)
        {
            attr = attribs.get(attrName);
            if (attr != null && attr.get() != null)
            {
                try
                {
                    setPrimaryKey(new StringKey(attr.get().toString()));
                }
                catch (Exception ex)
                {
                    log.error("Exception caught:", ex);
                }
            }
        }

        // Set the Username.
        attrName = LDAPSecurityConstants.getNameAttribute();
        if (attrName != null)
        {
            attr = attribs.get(attrName);
            if (attr != null && attr.get() != null)
            {
                setUserName(attr.get().toString());
            }
        }
        else
        {
            log.error("There is no LDAP attribute for the username.");
        }

        // Set the Firstname.
        attrName = LDAPSecurityConstants.getFirstNameAttribute();
        if (attrName != null)
        {
            attr = attribs.get(attrName);
            if (attr != null && attr.get() != null)
            {
                setFirstName(attr.get().toString());
            }
        }

        // Set the Lastname.
        attrName = LDAPSecurityConstants.getLastNameAttribute();
        if (attrName != null)
        {
            attr = attribs.get(attrName);
            if (attr != null && attr.get() != null)
            {
                setLastName(attr.get().toString());
            }
        }

        // Set the E-Mail
        attrName = LDAPSecurityConstants.getEmailAttribute();
        if (attrName != null)
        {
            attr = attribs.get(attrName);
            if (attr != null && attr.get() != null)
            {
                setEmail(attr.get().toString());
            }
        }
    }
View Full Code Here

        {
            Object value = "turbineUser";

            if (value != null)
            {
                Attribute attr = new BasicAttribute(attrName, value);

                attribs.put(attr);
            }
        }

        // Set the User id.
        attrName = LDAPSecurityConstants.getUserIdAttribute();
        if (attrName != null)
        {
            Object value = getPrimaryKey();

            if (value != null)
            {
                Attribute attr = new BasicAttribute(attrName, value);

                attribs.put(attr);
            }
        }

        // Set the Username.
        attrName = LDAPSecurityConstants.getNameAttribute();
        if (attrName != null)
        {
            Object value = getName();

            if (value != null)
            {
                Attribute attr = new BasicAttribute(attrName, value);

                attribs.put(attr);
            }
        }

        // Set the Firstname.
        attrName = LDAPSecurityConstants.getFirstNameAttribute();
        if (attrName != null)
        {
            Object value = getFirstName();

            if (value != null)
            {
                Attribute attr = new BasicAttribute(attrName, value);

                attribs.put(attr);
            }
        }

        // Set the Lastname.
        attrName = LDAPSecurityConstants.getLastNameAttribute();
        if (attrName != null)
        {
            Object value = getLastName();

            if (value != null)
            {
                Attribute attr = new BasicAttribute(attrName, value);

                attribs.put(attr);
            }
        }

        // Set the E-Mail.
        attrName = LDAPSecurityConstants.getEmailAttribute();
        if (attrName != null)
        {
            Object value = getEmail();

            if (value != null)
            {
                Attribute attr = new BasicAttribute(attrName, value);

                attribs.put(attr);
            }
        }

        // Set the Password
        attrName = LDAPSecurityConstants.getPasswordAttribute();
        if (attrName != null)
        {
            Object value = getPassword();

            if (value != null)
            {
                Attribute attr = new BasicAttribute(attrName, value);

                attribs.put(attr);
            }
        }
View Full Code Here

     * @return the BasicAttributes
     */
    private ModificationItem[] getModificationItem() {
        ModificationItem[] mods = new ModificationItem[2];
        // replace (update) attribute
        Attribute mod0 = new BasicAttribute("userpassword", "secret"); //$NON-NLS-1$ //$NON-NLS-2$
        // add mobile phone number attribute
        Attribute mod1 = new BasicAttribute("mobile", "123-456-1234"); //$NON-NLS-1$ //$NON-NLS-2$

        mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, mod0);
        mods[1] = new ModificationItem(DirContext.ADD_ATTRIBUTE, mod1);

        return mods;
View Full Code Here

            final Attributes attrs = ( (DirContext)context ).getAttributes( "" );

            final NamingEnumeration attributes = attrs.getAll();
            while( attributes.hasMore() )
            {
                final Attribute attribute = (Attribute)attributes.next();
                final String id = attribute.getID();
                if( name.startsWith( id ) )
                {
                    name = (String)attribute.get();
                    if( m_enableNamespaces ) prefix = id;
                    attrs.remove( id );
                    break;
                }
            }
View Full Code Here

    private void copyAttributes( final Attributes attrs, final DefaultConfiguration configuration ) throws NamingException
    {
        final NamingEnumeration attributes = attrs.getAll();
        while( attributes.hasMore() )
        {
            final Attribute attribute = (Attribute)attributes.next();
            final String attrName = attribute.getID();
            final Object attrValue = attribute.get();
            configuration.setAttribute( attrName, attrValue.toString() );
        }
    }
View Full Code Here

                                    // create modification items
                                    List<ModificationItem> mis = new ArrayList<ModificationItem>();
                                    NamingEnumeration<? extends Attribute> all = newAttributes.getAll();
                                    while ( all.hasMore() )
                                    {
                                        Attribute attribute = all.next();
                                        ModificationItem mi = new ModificationItem( DirContext.REPLACE_ATTRIBUTE,
                                            attribute );
                                        mis.add( mi );
                                    }
View Full Code Here

    {
        // remove old RDN attributes and values
        for ( Iterator<AttributeTypeAndValue> it = oldRdn.iterator(); it.hasNext(); )
        {
            AttributeTypeAndValue atav = it.next();
            Attribute attribute = attributes.get( atav.getUpType() );
            if ( attribute != null )
            {
                attribute.remove( atav.getNormValue().getString() );
                if ( attribute.size() == 0 )
                {
                    attributes.remove( atav.getUpType() );
                }
            }
        }

        // add new RDN attributes and values
        for ( Iterator<AttributeTypeAndValue> it = newRdn.iterator(); it.hasNext(); )
        {
            AttributeTypeAndValue atav = it.next();
            Attribute attribute = attributes.get( atav.getUpType() );
            if ( attribute == null )
            {
                attribute = new BasicAttribute( atav.getUpType() );
                attributes.put( attribute );
            }
            if ( !attribute.contains( atav.getNormValue().getString() ) )
            {
                attribute.add( atav.getNormValue().getString() );
            }
        }
    }
View Full Code Here

TOP

Related Classes of javax.naming.directory.Attribute

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.