当前位置: 首页>>代码示例>>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;未经允许,请勿转载。