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


Java Attribute.add方法代碼示例

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


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

示例1: testConvertAttributesfromLdif

import javax.naming.directory.Attribute; //導入方法依賴的package包/類
/**
 * Test a conversion of an attributes from a LDIF file
 * @throws org.apache.directory.api.ldap.model.ldif.LdapLdifException
 */
@Test
public void testConvertAttributesfromLdif() throws LdapException, LdapLdifException
{
    Attributes attributes = new BasicAttributes( true );

    Attribute oc = new BasicAttribute( "objectclass" );
    oc.add( "top" );
    oc.add( "person" );
    oc.add( "inetorgPerson" );

    attributes.put( oc );

    attributes.put( "cn", "Saarbrucken" );
    attributes.put( "sn", "test" );

    String ldif = LdifUtils.convertToLdif( attributes, ( Dn ) null, 15 );
    Attributes result = LdifUtils.getJndiAttributesFromLdif( ldif );
    assertEquals( attributes, result );
}
 
開發者ID:apache,項目名稱:directory-ldap-api,代碼行數:24,代碼來源:LdifUtilsTest.java

示例2: createTriggerExecutionSubentry

import javax.naming.directory.Attribute; //導入方法依賴的package包/類
/**
 * Create the Trigger execution subentry
 * 
 * @param apCtx The administration point context
 * @param subentryCN The CN used by the suentry
 * @param subtreeSpec The subtree specification
 * @param prescriptiveTriggerSpec The prescriptive trigger specification
 * @throws NamingException If the operation failed
 */
public static void createTriggerExecutionSubentry(
    LdapContext apCtx,
    String subentryCN,
    String subtreeSpec,
    String prescriptiveTriggerSpec ) throws NamingException
{
    Attributes subentry = new BasicAttributes( SchemaConstants.CN_AT, subentryCN, true );
    Attribute objectClass = new BasicAttribute( SchemaConstants.OBJECT_CLASS_AT );
    subentry.put( objectClass );
    objectClass.add( SchemaConstants.TOP_OC );
    objectClass.add( SchemaConstants.SUBENTRY_OC );
    objectClass.add( SchemaConstants.TRIGGER_EXECUTION_SUBENTRY_OC );
    subentry.put( SchemaConstants.SUBTREE_SPECIFICATION_AT, subtreeSpec );
    subentry.put( SchemaConstants.PRESCRIPTIVE_TRIGGER_SPECIFICATION_AT, prescriptiveTriggerSpec );
    apCtx.createSubcontext( "cn=" + subentryCN, subentry );
}
 
開發者ID:apache,項目名稱:directory-ldap-api,代碼行數:26,代碼來源:TriggerUtils.java

示例3: setupMocksBase

import javax.naming.directory.Attribute; //導入方法依賴的package包/類
@Before
public void setupMocksBase() throws NamingException {
  mockContext = mock(DirContext.class);
  doReturn(mockContext).when(mappingSpy).getDirContext();

  // We only ever call hasMoreElements once for the user NamingEnum, so
  // we can just have one return value
  when(mockUserNamingEnum.hasMoreElements()).thenReturn(true);

  SearchResult mockGroupResult = mock(SearchResult.class);
  // We're going to have to define the loop here. We want two iterations,
  // to get both the groups
  when(mockGroupNamingEnum.hasMoreElements()).thenReturn(true, true, false);
  when(mockGroupNamingEnum.nextElement()).thenReturn(mockGroupResult);

  // Define the attribute for the name of the first group
  Attribute group1Attr = new BasicAttribute("cn");
  group1Attr.add(testGroups[0]);
  Attributes group1Attrs = new BasicAttributes();
  group1Attrs.put(group1Attr);

  // Define the attribute for the name of the second group
  Attribute group2Attr = new BasicAttribute("cn");
  group2Attr.add(testGroups[1]);
  Attributes group2Attrs = new BasicAttributes();
  group2Attrs.put(group2Attr);

  // This search result gets reused, so return group1, then group2
  when(mockGroupResult.getAttributes()).thenReturn(group1Attrs, group2Attrs);
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:31,代碼來源:TestLdapGroupsMappingBase.java

示例4: toAttributes

import javax.naming.directory.Attribute; //導入方法依賴的package包/類
Attributes toAttributes() {
    Attributes attrs = new BasicAttributes(true);
    TypeAndValue tv;
    Attribute attr;

    for (int i = 0; i < tvs.size(); i++) {
        tv = tvs.elementAt(i);
        if ((attr = attrs.get(tv.getType())) == null) {
            attrs.put(tv.getType(), tv.getUnescapedValue());
        } else {
            attr.add(tv.getUnescapedValue());
        }
    }
    return attrs;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:16,代碼來源:LdapName.java

示例5: toAttributes

import javax.naming.directory.Attribute; //導入方法依賴的package包/類
/**
 * Retrieves the {@link javax.naming.directory.Attributes Attributes}
 * view of the type/value mappings contained in this Rdn.
 *
 * @return  The non-null attributes containing the type/value
 *          mappings of this Rdn.
 */
public Attributes toAttributes() {
    Attributes attrs = new BasicAttributes(true);
    for (int i = 0; i < entries.size(); i++) {
        RdnEntry entry = entries.get(i);
        Attribute attr = attrs.put(entry.getType(), entry.getValue());
        if (attr != null) {
            attr.add(entry.getValue());
            attrs.put(attr);
        }
    }
    return attrs;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:20,代碼來源:Rdn.java

示例6: setupMocks

import javax.naming.directory.Attribute; //導入方法依賴的package包/類
@Before
public void setupMocks() throws NamingException {
  mockContext = mock(DirContext.class);
  doReturn(mockContext).when(mappingSpy).getDirContext();
          
  SearchResult mockUserResult = mock(SearchResult.class);
  // We only ever call hasMoreElements once for the user NamingEnum, so 
  // we can just have one return value
  when(mockUserNamingEnum.hasMoreElements()).thenReturn(true);
  when(mockUserNamingEnum.nextElement()).thenReturn(mockUserResult);
  when(mockUserResult.getNameInNamespace()).thenReturn("CN=some_user,DC=test,DC=com");
  
  SearchResult mockGroupResult = mock(SearchResult.class);
  // We're going to have to define the loop here. We want two iterations,
  // to get both the groups
  when(mockGroupNamingEnum.hasMoreElements()).thenReturn(true, true, false);
  when(mockGroupNamingEnum.nextElement()).thenReturn(mockGroupResult);
  
  // Define the attribute for the name of the first group
  Attribute group1Attr = new BasicAttribute("cn");
  group1Attr.add(testGroups[0]);
  Attributes group1Attrs = new BasicAttributes();
  group1Attrs.put(group1Attr);
  
  // Define the attribute for the name of the second group
  Attribute group2Attr = new BasicAttribute("cn");
  group2Attr.add(testGroups[1]);
  Attributes group2Attrs = new BasicAttributes();
  group2Attrs.put(group2Attr);
  
  // This search result gets reused, so return group1, then group2
  when(mockGroupResult.getAttributes()).thenReturn(group1Attrs, group2Attrs);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:34,代碼來源:TestLdapGroupsMapping.java


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