Package javax.naming.directory

Examples of javax.naming.directory.Attribute


                   
              // Get all available attribute types and their associated values.
          // we can build a user object to return.
              Attributes attributes = sr.getAttributes();

              Attribute attr;
              NamingEnumeration<?> ne;

              // Iterate through the attributes.
              //String json = "{";
              for (NamingEnumeration<?> a = attributes.getAll(); a.hasMore();) {
                  attr = (Attribute)a.next();
                 
                  //json = json + attr.getID() + ": { ";
                  String json = "";
                  ne = attr.getAll();
                  while (ne.hasMore()) {
                      json = json + ne.next(); // should only be one entry for the attributes we retreive + ", ";
                  }

                  //json = json + "\n";
                  user.put(attr.getID(), json);
              }
              //json = json + "}";
              //user.put("jsonAttrib", json);
          }
          else {
View Full Code Here


            if (getUidAttributeID().equals(attributeName))
            {
               continue;
            }
            log.debug("adding attribute: " + attributeName);
            Attribute attr = new BasicAttribute(attributeName);
            Set attributeValues = (Set)attributesToAdd.get(attributeName);

            //values
            for (Iterator it2 = attributeValues.iterator(); it2.hasNext();)
            {
               String attrValue = (String)it2.next();
               log.debug("adding attribute value: " + attrValue);
               attr.add(attrValue);
            }
            attrs.put(attr);
         }

         if (!isSetPasswordAfterUserCreate())
View Full Code Here

         try
         {
            SearchResult u1 = (SearchResult)o1;
            SearchResult u2 = (SearchResult)o2;

            Attribute uida1 = u1.getAttributes().get(getUidAttributeID());
            Attribute uida2 = u2.getAttributes().get(getUidAttributeID());

            String name1 = uida1.get().toString();
            String name2 = uida2.get().toString();

            return name1.compareToIgnoreCase(name2);
         }
         catch(Throwable e)
         {
View Full Code Here

        Properties jndiEnvironmentProperties = new Properties()
        jndiEnvironmentProperties.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory")
        InitialDirContext initialDirContext = new InitialDirContext(jndiEnvironmentProperties)
        Attributes attributes = initialDirContext.getAttributes(host, new String[] {"MX"})
       
        Attribute attribute = attributes.get("MX")
        String[] servers = new String[attribute.size()]
        for (int i = 0; i < attribute.size(); i++) { 
            servers[i] = attribute.get(i).toString()
            servers[i]=servers[i].substring(servers[i].indexOf(" ") + 1, servers[i].length() -1)
           
       
        return servers; 
    }
View Full Code Here

            String fullname = null;
            String email = null;

            Attributes attrs = auth.getAttributes(npc.getName(), "uid", "cn", "mail");

            Attribute usernameAttr = attrs.get("uid");
            if (usernameAttr != null) {
                username = (String) usernameAttr.get();
            }

            Attribute fullnameAttr = attrs.get("cn");
            if (fullnameAttr != null) {
                fullname = (String) fullnameAttr.get();
            }

            Attribute emailAttr = attrs.get("mail");
            if (emailAttr != null) {
                email = (String) emailAttr.get();
            }
       
            logger.warning("un: " + username + " fn: " + fullname + " m: " + email);

            // make sure at least a username was specified
View Full Code Here

        assertTrue( results.hasMore() );
        SearchResult result = results.next();
        Attributes entry = result.getAttributes();

        Attribute objectClasses = entry.get( "objectClasses" );
        NamingEnumeration<?> ocs = objectClasses.getAll();

        while ( ocs.hasMore() )
        {
            String oc = ( String ) ocs.nextElement();
            if ( oc.startsWith( "( 2.5.6.6" ) )
View Full Code Here

        // First let's add a some binary data representing a userCertificate
        Attributes attrs = getPersonAttributes( "Bush", "Kate Bush" );
        attrs.put( "userCertificate", certData );

        Attribute objectClasses = attrs.get( "objectClass" );
        objectClasses.add( "strongAuthenticationUser" );

        sysRoot.createSubcontext( "cn=Kate Bush", attrs );

        // Search for kate by cn first
        SearchControls controls = new SearchControls();
View Full Code Here

        if ( result.hasMore() )
        {
            SearchResult entry = result.next();
            Attributes attrs = entry.getAttributes();
            Attribute cn = attrs.get( "cn" );

            assertNotNull( cn );
            assertEquals( "Heather Nova", cn.get().toString() );

            Attribute sn = attrs.get( "sn" );
            assertNull( sn );
        }
        else
        {
            fail( "entry " + RDN + " not found" );
View Full Code Here

            // We should have get cn and sn only
            assertEquals( 2, attrs.size() );

            // Check CN
            Attribute cn = attrs.get( "cn" );

            assertNotNull( cn );
            assertEquals( "Heather Nova", cn.get().toString() );

            // Assert SN
            Attribute sn = attrs.get( "sn" );
            assertNotNull( sn );
            assertEquals( "Nova", sn.get().toString() );
        }
        else
        {
            fail( "entry " + RDN + " not found" );
        }
View Full Code Here

        if ( result.hasMore() )
        {
            SearchResult entry = result.next();
            Attributes attrs = entry.getAttributes();
            Attribute cn = attrs.get( "cn" );

            assertNotNull( cn );
            assertEquals( "Heather Nova", cn.get().toString() );
        }
        else
        {
            fail( "entry " + RDN + " not found" );
        }
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.