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


Java Rdn.toAttributes方法代碼示例

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


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

示例1: addRdnAttributes

import javax.naming.ldap.Rdn; //導入方法依賴的package包/類
/**
 * Adds attributes from RDN to attrs if not already present.
 * Note that if attrs already contains an attribute by the same name,
 * or if the distinguished name is empty, then leave attrs unchanged.
 *
 * @param dn The non-null DN of the entry to add
 * @param attrs The non-null attributes of entry to add
 * @param directUpdate Whether attrs can be updated directly
 * @returns Non-null attributes with attributes from the RDN added
 */
private static Attributes addRdnAttributes(String dn, Attributes attrs,
    boolean directUpdate) throws NamingException {

        // Handle the empty name
        if (dn.equals("")) {
            return attrs;
        }

        // Parse string name into list of RDNs
        List<Rdn> rdnList = (new LdapName(dn)).getRdns();

        // Get leaf RDN
        Rdn rdn = rdnList.get(rdnList.size() - 1);
        Attributes nameAttrs = rdn.toAttributes();

        // Add attributes of RDN to attrs if not already there
        NamingEnumeration<? extends Attribute> enum_ = nameAttrs.getAll();
        Attribute nameAttr;
        while (enum_.hasMore()) {
            nameAttr = enum_.next();

            // If attrs already has the attribute, don't change or add to it
            if (attrs.get(nameAttr.getID()) ==  null) {

                /**
                 * When attrs.isCaseIgnored() is false, attrs.get() will
                 * return null when the case mis-matches for otherwise
                 * equal attrIDs.
                 * As the attrIDs' case is irrelevant for LDAP, ignore
                 * the case of attrIDs even when attrs.isCaseIgnored() is
                 * false. This is done by explicitly comparing the elements in
                 * the enumeration of IDs with their case ignored.
                 */
                if (!attrs.isCaseIgnored() &&
                        containsIgnoreCase(attrs.getIDs(), nameAttr.getID())) {
                    continue;
                }

                if (!directUpdate) {
                    attrs = (Attributes)attrs.clone();
                    directUpdate = true;
                }
                attrs.put(nameAttr);
            }
        }

        return attrs;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:59,代碼來源:LdapCtx.java

示例2: addRdnAttributes

import javax.naming.ldap.Rdn; //導入方法依賴的package包/類
/**
 * Adds attributes from RDN to attrs if not already present.
 * Note that if attrs already contains an attribute by the same name,
 * or if the distinguished name is empty, then leave attrs unchanged.
 *
 * @param dn The non-null DN of the entry to add
 * @param attrs The non-null attributes of entry to add
 * @param directUpdate Whether attrs can be updated directly
 * @return Non-null attributes with attributes from the RDN added
 */
private static Attributes addRdnAttributes(String dn, Attributes attrs,
    boolean directUpdate) throws NamingException {

        // Handle the empty name
        if (dn.equals("")) {
            return attrs;
        }

        // Parse string name into list of RDNs
        List<Rdn> rdnList = (new LdapName(dn)).getRdns();

        // Get leaf RDN
        Rdn rdn = rdnList.get(rdnList.size() - 1);
        Attributes nameAttrs = rdn.toAttributes();

        // Add attributes of RDN to attrs if not already there
        NamingEnumeration<? extends Attribute> enum_ = nameAttrs.getAll();
        Attribute nameAttr;
        while (enum_.hasMore()) {
            nameAttr = enum_.next();

            // If attrs already has the attribute, don't change or add to it
            if (attrs.get(nameAttr.getID()) ==  null) {

                /**
                 * When attrs.isCaseIgnored() is false, attrs.get() will
                 * return null when the case mis-matches for otherwise
                 * equal attrIDs.
                 * As the attrIDs' case is irrelevant for LDAP, ignore
                 * the case of attrIDs even when attrs.isCaseIgnored() is
                 * false. This is done by explicitly comparing the elements in
                 * the enumeration of IDs with their case ignored.
                 */
                if (!attrs.isCaseIgnored() &&
                        containsIgnoreCase(attrs.getIDs(), nameAttr.getID())) {
                    continue;
                }

                if (!directUpdate) {
                    attrs = (Attributes)attrs.clone();
                    directUpdate = true;
                }
                attrs.put(nameAttr);
            }
        }

        return attrs;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:59,代碼來源:LdapCtx.java

示例3: addRdnAttributes

import javax.naming.ldap.Rdn; //導入方法依賴的package包/類
/**
 * Adds attributes from RDN to attrs if not already present.
 * Note that if attrs already contains an attribute by the same name,
 * or if the distinguished name is empty, then leave attrs unchanged.
 *
 * @param dn The non-null DN of the entry to add
 * @param attrs The non-null attributes of entry to add
 * @param directUpdate Whether attrs can be updated directly
 * @returns Non-null attributes with attributes from the RDN added
 */
private static Attributes addRdnAttributes(String dn, Attributes attrs,
    boolean directUpdate) throws NamingException {

        // Handle the empty name
        if (dn.equals("")) {
            return attrs;
        }

        // Parse string name into list of RDNs
        //List<Rdn> rdnList = (new LdapName(dn)).rdns();
        List rdnList = (new LdapName(dn)).getRdns();

        // Get leaf RDN
        //Rdn rdn = rdnList.get(rdnList.size() - 1);
        Rdn rdn = (Rdn) rdnList.get(rdnList.size() - 1);
        Attributes nameAttrs = rdn.toAttributes();

        // Add attributes of RDN to attrs if not already there
        NamingEnumeration enum_ = nameAttrs.getAll();
        Attribute nameAttr;
        while (enum_.hasMore()) {
            nameAttr = (Attribute) enum_.next();

            // If attrs already has the attribute, don't change or add to it
            if (attrs.get(nameAttr.getID()) ==  null) {

                /**
                 * When attrs.isCaseIgnored() is false, attrs.get() will
                 * return null when the case mis-matches for otherwise
                 * equal attrIDs.
                 * As the attrIDs' case is irrelevant for LDAP, ignore
                 * the case of attrIDs even when attrs.isCaseIgnored() is
                 * false. This is done by explicitly comparing the elements in
                 * the enumeration of IDs with their case ignored.
                 */
                if (!attrs.isCaseIgnored() &&
                        containsIgnoreCase(attrs.getIDs(), nameAttr.getID())) {
                    continue;
                }

                if (!directUpdate) {
                    attrs = (Attributes)attrs.clone();
                    directUpdate = true;
                }
                attrs.put(nameAttr);
            }
        }

        return attrs;
}
 
開發者ID:openjdk,項目名稱:jdk7-jdk,代碼行數:61,代碼來源:LdapCtx.java

示例4: testToAttributes001

import javax.naming.ldap.Rdn; //導入方法依賴的package包/類
/**
 * <p>
 * Test method for 'javax.naming.ldap.Rdn.toAttributes()'
 * </p>
 * <p>
 * Here we are testing if this method correctly returns the Rdn's contents
 * as an Attributes map. For this test the Rdn is created with the string
 * "t=\\4C\\4c", notice that here the values are quoted.
 * </p>
 * <p>
 * The expected result is the map of the Rdn.
 * </p>
 */
public void testToAttributes001() throws Exception {
    BasicAttributes t = new BasicAttributes("t", "\\4C\\4C");
    Rdn rdn = new Rdn(t);
    BasicAttributes ba = (BasicAttributes) rdn.toAttributes();

    NamingEnumeration ne = ba.getAll();
    assertAttributesEqual(ne, t);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:22,代碼來源:RdnTest.java

示例5: testToAttributes002

import javax.naming.ldap.Rdn; //導入方法依賴的package包/類
/**
 * <p>
 * Test method for 'javax.naming.ldap.Rdn.toAttributes()'
 * </p>
 * <p>
 * Here we are testing if this method correctly returns the Rdn's contents
 * as an Attributes map. For this test the Rdn is created with the string
 * "", notice that here the name is empty.
 * </p>
 * <p>
 * The expected result is the map of the Rdn not null but empty.
 * </p>
 */
public void testToAttributes002() throws Exception {
    Rdn rdn = new Rdn("");
    BasicAttributes ba = (BasicAttributes) rdn.toAttributes();

    assertEquals(0, ba.size());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:20,代碼來源:RdnTest.java

示例6: testToAttributes003

import javax.naming.ldap.Rdn; //導入方法依賴的package包/類
/**
 * <p>
 * Test method for 'javax.naming.ldap.Rdn.toAttributes()'
 * </p>
 * <p>
 * Here we are testing if this method correctly returns the Rdn's contents
 * as an Attributes map. For this test the Rdn is created with the string
 * "t=hola", notice that here the values are not quoted.
 * </p>
 * <p>
 * The expected result is the map of the Rdn."
 * </p>
 */
public void testToAttributes003() throws Exception {
    BasicAttributes t = new BasicAttributes("t", "hola");
    Rdn rdn = new Rdn(t);
    BasicAttributes ba = (BasicAttributes) rdn.toAttributes();

    NamingEnumeration ne = ba.getAll();
    assertAttributesEqual(ne, t);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:22,代碼來源:RdnTest.java

示例7: testToAttributes004

import javax.naming.ldap.Rdn; //導入方法依賴的package包/類
/**
 * <p>
 * Test method for 'javax.naming.ldap.Rdn.toAttributes()'
 * </p>
 * <p>
 * Here we are testing if this method correctly returns the Rdn's contents
 * as an Attributes map. For this test the Rdn is created with the string
 * "t=", notice that here the values are not quoted.
 * </p>
 * <p>
 * The expected result is the map of the Rdn."
 * </p>
 */
public void testToAttributes004() throws Exception {
    BasicAttributes t = new BasicAttributes("t", "");
    Rdn rdn = new Rdn(t);
    BasicAttributes ba = (BasicAttributes) rdn.toAttributes();

    NamingEnumeration ne = ba.getAll();
    assertAttributesEqual(ne, t);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:22,代碼來源:RdnTest.java

示例8: testToAttributes005

import javax.naming.ldap.Rdn; //導入方法依賴的package包/類
/**
 * <p>
 * Test method for 'javax.naming.ldap.Rdn.toAttributes()'
 * </p>
 * <p>
 * Here we are testing if this method correctly returns the Rdn's contents
 * as an Attributes map. For this test the Rdn is created with the string
 * "t=test+a=test2+b=test3", notice that here the values are not
 * quoted.
 * </p>
 * <p>
 * The expected result is the map of the Rdn."
 * </p>
 */
public void testToAttributes005() throws Exception {
    BasicAttributes t = new BasicAttributes("t", "test+a=test2+b=test3");
    Rdn rdn = new Rdn(t);
    BasicAttributes ba = (BasicAttributes) rdn.toAttributes();

    NamingEnumeration ne = ba.getAll();
    assertAttributesEqual(ne, t);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:23,代碼來源:RdnTest.java

示例9: testToAttributes006

import javax.naming.ldap.Rdn; //導入方法依賴的package包/類
/**
 * <p>
 * Test method for 'javax.naming.ldap.Rdn.toAttributes()'
 * </p>
 * <p>
 * Here we are testing if this method correctly returns the Rdn's contents
 * as an Attributes map. For this test the Rdn is created with multiple
 * values.
 * </p>
 * <p>
 * The expected result is the map of the Rdn.
 * </p>
 */
public void testToAttributes006() throws Exception {
    BasicAttributes t = new BasicAttributes("t", "test+a=test2");
    Rdn rdn = new Rdn(t);
    BasicAttributes ba = (BasicAttributes) rdn.toAttributes();

    NamingEnumeration ne = ba.getAll();
    assertAttributesEqual(ne, t);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:22,代碼來源:RdnTest.java

示例10: testToAttributes007

import javax.naming.ldap.Rdn; //導入方法依賴的package包/類
/**
 * <p>
 * Test method for 'javax.naming.ldap.Rdn.toAttributes()'
 * </p>
 * <p>
 * Here we are testing if this method correctly returns the Rdn's contents
 * as an Attributes map. For this test the Rdn is created with multiple
 * values.
 * </p>
 * <p>
 * The expected result is the map of the Rdn.
 * </p>
 */
public void testToAttributes007() throws Exception {
    BasicAttributes t = new BasicAttributes("a", "test+a=test2");
    Rdn rdn = new Rdn(t);
    BasicAttributes ba = (BasicAttributes) rdn.toAttributes();

    NamingEnumeration ne = ba.getAll();
    assertAttributesEqual(ne, t);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:22,代碼來源:RdnTest.java

示例11: testToAttributes008

import javax.naming.ldap.Rdn; //導入方法依賴的package包/類
/**
 * <p>
 * Test method for 'javax.naming.ldap.Rdn.toAttributes()'
 * </p>
 * <p>
 * Here we are testing if this method correctly returns the Rdn's contents
 * as an Attributes map. For this test the Rdn is created with multiple
 * values.
 * </p>
 * <p>
 * The expected result is the map of the Rdn.
 * </p>
 */
public void testToAttributes008() throws Exception {
    BasicAttributes t = new BasicAttributes("a", ">asd+t=t+t=t=s<asd");
    Rdn rdn = new Rdn(t);
    BasicAttributes ba = (BasicAttributes) rdn.toAttributes();

    NamingEnumeration ne = ba.getAll();
    assertAttributesEqual(ne, t);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:22,代碼來源:RdnTest.java

示例12: testToAttributes009

import javax.naming.ldap.Rdn; //導入方法依賴的package包/類
/**
 * <p>
 * Test method for 'javax.naming.ldap.Rdn.toAttributes()'
 * </p>
 * <p>
 * Here we are testing if this method correctly returns the Rdn's contents
 * as an Attributes map. For this test the Rdn is created with multiple
 * values.
 * </p>
 * <p>
 * The expected result is the map of the Rdn.
 * </p>
 */
public void testToAttributes009() throws Exception {
    BasicAttributes t = new BasicAttributes("a", "+t=t=");
    Rdn rdn = new Rdn(t);
    BasicAttributes ba = (BasicAttributes) rdn.toAttributes();
    assertNotNull(ba);
    NamingEnumeration ne = ba.getAll();
    assertAttributesEqual(ne, t);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:22,代碼來源:RdnTest.java

示例13: testToAttributes010

import javax.naming.ldap.Rdn; //導入方法依賴的package包/類
/**
 * <p>
 * Test method for 'javax.naming.ldap.Rdn.toAttributes()'
 * </p>
 * <p>
 * Here we are testing if this method correctly returns the Rdn's contents
 * as an Attributes map. For this test the Rdn is created with multiple
 * values.
 * </p>
 * <p>
 * The expected result is the map of the Rdn.
 * </p>
 */
public void testToAttributes010() throws Exception {
    BasicAttributes t = new BasicAttributes("a", "t=t");
    Rdn rdn = new Rdn(t);
    BasicAttributes ba = (BasicAttributes) rdn.toAttributes();
    assertNotNull(ba);
    NamingEnumeration ne = ba.getAll();
    assertAttributesEqual(ne, t);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:22,代碼來源:RdnTest.java


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