當前位置: 首頁>>代碼示例>>Java>>正文


Java BasicAttribute.add方法代碼示例

本文整理匯總了Java中javax.naming.directory.BasicAttribute.add方法的典型用法代碼示例。如果您正苦於以下問題:Java BasicAttribute.add方法的具體用法?Java BasicAttribute.add怎麽用?Java BasicAttribute.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.naming.directory.BasicAttribute的用法示例。


在下文中一共展示了BasicAttribute.add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getURLContext

import javax.naming.directory.BasicAttribute; //導入方法依賴的package包/類
public static Context getURLContext(
        String scheme, Hashtable<?,?> environment)
        throws NamingException {
    return new DnsContext("", null, new Hashtable<String,String>()) {
        public Attributes getAttributes(String name, String[] attrIds)
                throws NamingException {
            return new BasicAttributes() {
                public Attribute get(String attrID) {
                    BasicAttribute ba  = new BasicAttribute(attrID);
                    ba.add("1 1 99 b.com.");
                    ba.add("0 0 88 a.com.");    // 2nd has higher priority
                    return ba;
                }
            };
        }
    };
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:18,代碼來源:NamingManager.java

示例2: getURLContext

import javax.naming.directory.BasicAttribute; //導入方法依賴的package包/類
public static Context getURLContext(
        String scheme, Hashtable<?,?> environment)
        throws NamingException {
    return new InitialDirContext() {
        public Attributes getAttributes(String name, String[] attrIds)
                throws NamingException {
            return new BasicAttributes() {
                public Attribute get(String attrID) {
                    BasicAttribute ba  = new BasicAttribute(attrID);
                    ba.add("1 1 99 b.com.");
                    ba.add("0 0 88 a.com.");    // 2nd has higher priority
                    return ba;
                }
            };
        }
    };
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:18,代碼來源:NamingManager.java

示例3: getUserAttributes

import javax.naming.directory.BasicAttribute; //導入方法依賴的package包/類
/**
 * Collect all the value from the table (Arguments), using this create the
 * basicAttributes. This will create the Basic Attributes for the User
 * defined TestCase for Add Test.
 *
 * @return the BasicAttributes
 */
private BasicAttributes getUserAttributes() {
    BasicAttribute basicattribute = new BasicAttribute("objectclass"); //$NON-NLS-1$
    basicattribute.add("top"); //$NON-NLS-1$
    basicattribute.add("person"); //$NON-NLS-1$
    basicattribute.add("organizationalPerson"); //$NON-NLS-1$
    basicattribute.add("inetOrgPerson"); //$NON-NLS-1$
    BasicAttributes attrs = new BasicAttributes(true);
    attrs.put(basicattribute);
    BasicAttribute attr;

    for (JMeterProperty jMeterProperty : getArguments()) {
        Argument item = (Argument) jMeterProperty.getObjectValue();
        attr = getBasicAttribute(item.getName(), item.getValue());
        attrs.put(attr);
    }
    return attrs;
}
 
開發者ID:johrstrom,項目名稱:cloud-meter,代碼行數:25,代碼來源:LDAPSampler.java

示例4: getBasicAttributes

import javax.naming.directory.BasicAttribute; //導入方法依賴的package包/類
/**
 * This will create the Basic Attributes for the In build TestCase for Add
 * Test.
 *
 * @return the BasicAttributes
 */
private BasicAttributes getBasicAttributes() {
    BasicAttributes basicattributes = new BasicAttributes();
    BasicAttribute basicattribute = new BasicAttribute("objectclass"); //$NON-NLS-1$
    basicattribute.add("top"); //$NON-NLS-1$
    basicattribute.add("person"); //$NON-NLS-1$
    basicattribute.add("organizationalPerson"); //$NON-NLS-1$
    basicattribute.add("inetOrgPerson"); //$NON-NLS-1$
    basicattributes.put(basicattribute);
    String s1 = "User"; //$NON-NLS-1$
    String s3 = "Test"; //$NON-NLS-1$
    String s5 = "user"; //$NON-NLS-1$
    String s6 = "test"; //$NON-NLS-1$
    counter += 1;
    basicattributes.put(new BasicAttribute("givenname", s1)); //$NON-NLS-1$
    basicattributes.put(new BasicAttribute("sn", s3)); //$NON-NLS-1$
    basicattributes.put(new BasicAttribute("cn", "TestUser" + counter)); //$NON-NLS-1$ //$NON-NLS-2$
    basicattributes.put(new BasicAttribute("uid", s5)); //$NON-NLS-1$
    basicattributes.put(new BasicAttribute("userpassword", s6)); //$NON-NLS-1$
    setProperty(new StringProperty(ADD, "cn=TestUser" + counter)); //$NON-NLS-1$
    return basicattributes;
}
 
開發者ID:johrstrom,項目名稱:cloud-meter,代碼行數:28,代碼來源:LDAPSampler.java

示例5: toAttributeList

import javax.naming.directory.BasicAttribute; //導入方法依賴的package包/類
/**
 * A list of attributes, each attribute can contain more than one value
 * 
 * @return a list of Attribute
 */
public List toAttributeList() {
    List list = new ArrayList();
    for (Iterator iter = keySet().iterator(); iter.hasNext();) {
        ValueWrapper element = (ValueWrapper) iter.next();
        BasicAttribute ba = new BasicAttribute(element.getStringValue(),
                true);
        List list2 = (List) attributes.get(element);
        for (Iterator iterator = list2.iterator(); iterator.hasNext();) {
            ValueWrapper elementList = (ValueWrapper) iterator.next();
            ba.add(elementList.getValue());
        }
        list.add(ba);
    }
    return list;
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:21,代碼來源:LdapTypeAndValueList.java

示例6: toAttributes

import javax.naming.directory.BasicAttribute; //導入方法依賴的package包/類
public Attributes toAttributes() {
    BasicAttributes bas = new BasicAttributes(true);
    for (Iterator<Attribute> iter = list.iterator(); iter.hasNext();) {
        Attribute attr = iter.next();
        BasicAttribute ba = new BasicAttribute(attr.getID(), false);
        try {
            NamingEnumeration nameEnum = attr.getAll();
            while (nameEnum.hasMore()) {
                ba.add(nameEnum.next());
            }
        } catch (NamingException ne) {

        }
        bas.put(ba);
    }
    return bas;
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:18,代碼來源:Rdn.java

示例7: testClone_ordered

import javax.naming.directory.BasicAttribute; //導入方法依賴的package包/類
/**
 * test clone()
 */
public void testClone_ordered() throws NamingException {
	int count = 5;
	Person[] persons = new Person[count];
	for (int i = 0; i < count; i++) {
		persons[i] = Person.getInstance();
		orderedAttribute.add(persons[i]);
	}

	BasicAttribute cloneAttribute = (BasicAttribute) orderedAttribute
			.clone();

	for (int i = 0; i < count; i++) {
		assertSame(orderedAttribute.get(i), cloneAttribute.get(i));
	}
	assertTrue(cloneAttribute.isOrdered());
	assertEquals(orderedAttribute.getID(), cloneAttribute.getID());
	// assertNotSame(orderedAttribute.values, cloneAttribute.values);
	cloneAttribute.add("new object");
	assertEquals(orderedAttribute.size() + 1, cloneAttribute.size());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:24,代碼來源:BasicAttributeTest.java

示例8: testClone_unordered

import javax.naming.directory.BasicAttribute; //導入方法依賴的package包/類
public void testClone_unordered() throws NamingException {
	int count = 5;
	Person[] persons = new Person[count];
	for (int i = 0; i < count; i++) {
		persons[i] = Person.getInstance();
		unorderedAttribute.add(persons[i]);
	}

	BasicAttribute cloneAttribute = (BasicAttribute) unorderedAttribute
			.clone();

	for (int i = 0; i < count; i++) {
		assertSame(unorderedAttribute.get(i), cloneAttribute.get(i));
	}
	assertFalse(cloneAttribute.isOrdered());
	assertEquals(unorderedAttribute.getID(), cloneAttribute.getID());
	// assertNotSame(unorderedAttribute.values, cloneAttribute.values);
	cloneAttribute.add("new object");
	assertEquals(unorderedAttribute.size() + 1, cloneAttribute.size());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:21,代碼來源:BasicAttributeTest.java

示例9: testEquals_diff_ordered

import javax.naming.directory.BasicAttribute; //導入方法依賴的package包/類
public void testEquals_diff_ordered() {
	int count = 5;
	Person[] persons = new Person[count];
	for (int i = 0; i < count; i++) {
		persons[i] = Person.getInstance();
	}
	String id = "un-Ordered";
	BasicAttribute unordered0 = new BasicAttribute(id);
	BasicAttribute unordered1 = new BasicAttribute(id);
	for (int i = 0; i < count; i++) {
		unordered0.add(persons[i]);
	}

	for (int i = count - 1; i > -1; i--) {
		unordered1.add(persons[i]);
	}
	assertEquals(unordered0.size(), unordered1.size());
	assertTrue(unordered0.equals(unordered1));
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:20,代碼來源:BasicAttributeTest.java

示例10: testHashCode_intArrayValue

import javax.naming.directory.BasicAttribute; //導入方法依賴的package包/類
public void testHashCode_intArrayValue() {
	int[] numbers = new int[10];
	for (int i = 0; i < numbers.length; i++) {
		numbers[i] = i * 10;
	}
	String id = "int-Array";
	BasicAttribute attribute = new BasicAttribute(id, numbers);
	Person person = Person.getInstance();
	attribute.add(person);
	int hashCode = id.hashCode() + person.hashCode();
	for (int element : numbers) {
		hashCode += element;
	}

	assertEquals(hashCode, attribute.hashCode());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:17,代碼來源:BasicAttributeTest.java

示例11: testSerializable_compatibility

import javax.naming.directory.BasicAttribute; //導入方法依賴的package包/類
public void testSerializable_compatibility() throws ClassNotFoundException,
		IOException {
	ObjectInputStream ois = new ObjectInputStream(
               getClass()
                       .getClassLoader()
                       .getResourceAsStream(
                               "/serialization/javax/naming/directory/BasicAttribute.ser"));
	BasicAttribute attribute2 = (BasicAttribute) ois.readObject();

	BasicAttribute attribute = new BasicAttribute("serializeBasicAttribute");
	int count = 10;
	for (int i = 0; i < count; i++) {
		attribute.add("Int value: " + i * 10);
	}

	assertEquals(attribute, attribute2);
	// TO DO: cause an EOFException
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:19,代碼來源:BasicAttributeTest.java

示例12: toAttributes

import javax.naming.directory.BasicAttribute; //導入方法依賴的package包/類
@Override
public Attributes toAttributes (final LdapGebruiker gebruiker) throws NamingException {
	final Attributes attributes = new BasicAttributes ();
	final BasicAttribute objectClass = new BasicAttribute ("objectclass");
	
	objectClass.add ("inetOrgPerson");
	objectClass.add ("organizationalPerson");
	objectClass.add ("person");
	objectClass.add ("top");
	
	attributes.put (objectClass);
	attributes.put ("cn", gebruiker.getGebruikersnaam ());
	attributes.put ("sn", gebruiker.getGebruikersnaam ());
	attributes.put ("uid", gebruiker.getGebruikersnaam ());
	attributes.put ("mail", gebruiker.getEmail ());
	// Mobile is optional
	if (StringUtils.isNotBlank(gebruiker.getMobile())) {
		attributes.put ("mobile", gebruiker.getMobile ());
	}
	attributes.put ("userPassword", String.format ("{SHA}%s", gebruiker.getWachtwoordHash ()));
	
	return attributes;
}
 
開發者ID:CDS-INSPIRE,項目名稱:InSpider,代碼行數:24,代碼來源:GebruikerAttributesMapper.java

示例13: testUserAttributesMapper

import javax.naming.directory.BasicAttribute; //導入方法依賴的package包/類
/**
 * Test the user attributes mapping
 * 
 * @throws Exception
 *             in case the test failed
 */
@Test
public void testUserAttributesMapper() throws Exception {
    LdapUserAttributesMapper mapper = new LdapUserAttributesMapper(createTestLdapConfig(
            "alias", "mail", "fn", "ln", "guid", "userPrincipalName"));
    String emailValue = "[email protected]";
    String fnValue = UUID.randomUUID().toString();
    String lnValue = UUID.randomUUID().toString();
    String uidValue = UUID.randomUUID().toString();
    String aliasValue1 = "peter_test";
    String aliasValue2 = "petertest";
    String upnValue = emailValue;
    Attributes attributes = new BasicAttributes();

    BasicAttribute aliasAttribute = new BasicAttribute("alias", aliasValue1);
    aliasAttribute.add(aliasValue2);
    attributes.put(aliasAttribute);
    attributes.put(new BasicAttribute("mail", emailValue));
    attributes.put(new BasicAttribute("fn", fnValue));
    attributes.put(new BasicAttribute("ln", lnValue));
    attributes.put(new BasicAttribute("guid", uidValue));
    attributes.put(new BasicAttribute("userPrincipalName", upnValue));
    String userDN = "uid=user1,ou=test,dc=communote,dc=com";
    ExternalUserVO userVo = mapper.mapAttributes(userDN, attributes);
    Assert.assertNotNull(userVo);
    // ensure the first is taken
    Assert.assertEquals(aliasValue1, userVo.getExternalUserName());
    Assert.assertEquals(emailValue, userVo.getEmail());
    Assert.assertEquals(fnValue, userVo.getFirstName());
    Assert.assertEquals(lnValue, userVo.getLastName());
    Assert.assertEquals(uidValue, userVo.getPermanentId());
    Assert.assertEquals(userDN, userVo.getAdditionalProperty());
    StringPropertyTO[] properties = userVo.getProperties().toArray(
            new StringPropertyTO[userVo.getProperties().size()]);
    Assert.assertEquals(upnValue, properties[0].getPropertyValue());
}
 
開發者ID:Communote,項目名稱:communote-server,代碼行數:42,代碼來源:LdapAttributesMapperTest.java

示例14: createEntry

import javax.naming.directory.BasicAttribute; //導入方法依賴的package包/類
@LdapOperation
@ModifyOperation
public final void createEntry( final String entryDN, final Set<String> baseObjectClasses, final Map<String, String> stringAttributes )
        throws ChaiOperationException, ChaiUnavailableException
{
    activityPreCheck();
    getInputValidator().createEntry( entryDN, baseObjectClasses, stringAttributes );

    final Attributes attrs = new BasicAttributes();

    //Put in the base object class an attribute
    final BasicAttribute objectClassAttr = new BasicAttribute( ChaiConstant.ATTR_LDAP_OBJECTCLASS );
    for ( final String loopClass : baseObjectClasses )
    {
        objectClassAttr.add( loopClass );
    }
    attrs.put( objectClassAttr );

    //Add each of the attributes required.
    for ( final Map.Entry<String, String> entry : stringAttributes.entrySet() )
    {
        attrs.put( entry.getKey(), entry.getValue() );
    }

    // Create the object.
    final DirContext ldapConnection = getLdapConnection();
    try
    {
        ldapConnection.createSubcontext( addJndiEscape( entryDN ), attrs );
    }
    catch ( NamingException e )
    {
        convertNamingException( e );
    }
}
 
開發者ID:ldapchai,項目名稱:ldapchai,代碼行數:36,代碼來源:JNDIProviderImpl.java

示例15: registerUser

import javax.naming.directory.BasicAttribute; //導入方法依賴的package包/類
/**
 * Register a new user.
 * @param dirContext the directory context
 * @param user the subject user
 * @throws CredentialPolicyException if the username or password is empty
 * @throws NamingException if an LDAP naming exception occurs
 * @throws NameAlreadyBoundException if the new user DN already exists
 */
protected void registerUser(DirContext dirContext, User user) 
  throws CredentialPolicyException, NamingException, NameAlreadyBoundException {

  // initialize
  user.setDistinguishedName("");
  LdapUserProperties userProps = getConfiguration().getUserProperties();
  LdapGroupProperties groupProps = getConfiguration().getGroupProperties();
  UsernamePasswordCredentials upCreds;
  upCreds = user.getCredentials().getUsernamePasswordCredentials();
  if (upCreds != null) {
    user.setDistinguishedName(userProps.returnNewUserDN(upCreds.getUsername()));
  }
  
  if (upCreds == null) {
    throw new CredentialPolicyException("The credentials were not supplied.");
  } else if (user.getDistinguishedName().length() == 0) {
    throw new CredentialPolicyException("The supplied username is invalid.");
  } else if ((upCreds.getPassword() == null) || (upCreds.getPassword().length() == 0)) {
    throw new CredentialPolicyException("The supplied password is invalid.");
  }

  // prepare attributes and add the new user to LDAP
  Attributes attributes = prepareRegistrationAttributes(upCreds,user.getProfile());  
  addEntry(dirContext,user.getDistinguishedName(),attributes);

  // add user to general user group
  Roles configuredRoles = getConfiguration().getIdentityConfiguration().getConfiguredRoles();
  if (configuredRoles.getAuthenticatedUserRequiresRole()) {
    String sRoleRegistered = configuredRoles.getRegisteredUserRoleKey();
    Role roleRegistered = configuredRoles.get(sRoleRegistered);
    String sGeneralDN = roleRegistered.getDistinguishedName();
    String sGroupAttribute = groupProps.getGroupMemberAttribute();
    BasicAttribute groupAttribute = new BasicAttribute(sGroupAttribute);
    BasicAttributes groupAttributes = new BasicAttributes();
    groupAttribute.add(user.getDistinguishedName());
    groupAttributes.put(groupAttribute);
    addAttribute(dirContext,sGeneralDN,groupAttributes);
  }
}
 
開發者ID:GeoinformationSystems,項目名稱:GeoprocessingAppstore,代碼行數:48,代碼來源:LdapEditFunctions.java


注:本文中的javax.naming.directory.BasicAttribute.add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。