本文整理了Java中com.unboundid.ldap.sdk.DN
类的一些代码示例,展示了DN
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DN
类的具体详情如下:
包路径:com.unboundid.ldap.sdk.DN
类名称:DN
[英]This class provides a data structure for holding information about an LDAP distinguished name (DN). A DN consists of a comma-delimited list of zero or more RDN components. See RFC 4514 for more information about representing DNs and RDNs as strings.
Examples of valid DNs (excluding the quotation marks, which are provided for clarity) include:
Distinguished names are hierarchical. The rightmost RDN refers to the root of the directory information tree (DIT), and each successive RDN to the left indicates the addition of another level of hierarchy. For example, in the DN " uid=john.doe,ou=People,o=example.com", the entry " o=example.com" is at the root of the DIT, the entry " ou=People,o=example.com" is an immediate descendant of the " o=example.com" entry, and the " uid=john.doe,ou=People,o=example.com" entry is an immediate descendant of the " ou=People,o=example.com" entry. Similarly, the entry " uid=jane.doe,ou=People,o=example.com" would be considered a peer of the " uid=john.doe,ou=People,o=example.com" entry because they have the same parent.
Note that in some cases, the root of the DIT may actually contain a DN with multiple RDNs. For example, in the DN " uid=john.doe,ou=People,dc=example,dc=com", the directory server may or may not actually have a " dc=com" entry. In many such cases, the base entry may actually be just " dc=example,dc=com". The DNs of the entries that are at the base of the directory information tree are called "naming contexts" or "suffixes" and they are generally available in the namingContexts attribute of the root DSE. See the RootDSEclass for more information about interacting with the server root DSE.
This class provides methods for making determinations based on the hierarchical relationships of DNs. For example, the DN#isAncestorOf and DN#isDescendantOf methods may be used to determine whether two DNs have a hierarchical relationship. In addition, this class implements the Comparable and Comparatorinterfaces so that it may be used to easily sort DNs (ancestors will always be sorted before descendants, and peers will always be sorted lexicographically based on their normalized representations).
[中]此类提供了一个数据结构,用于保存有关LDAP可分辨名称(DN)的信息。DN由零个或多个RDN组件的逗号分隔列表组成。有关将DNs和RDN表示为字符串的详细信息,请参见{$0$}。
有效DNs的示例(不包括为清晰起见提供的引号)包括:
*“”--这是长度为零的DN(也称为空DN),可用于引用目录服务器根DSE。
*“o=example.com”。这是一个带有单值RDN的DN。RDN属性为“o”,RDN值为“example.com”。
*“givenName=John+sn=Doe,ou=People,dc=example,dc=com”。这是一个包含四个不同RDN(“givenName=John+sn=Doe”、“ou=People”、“dc=example”和“dc=com”)的DN。第一个RDN使用属性值对“givenName=John”和“sn=Doe”进行多值化。
请注意,在可分辨名称的字符串表示中存在一些固有的歧义。特别是,间距可能存在差异(特别是逗号和等号周围,以及多值RDN中的加号),属性名称和/或值的大小写也可能存在差异。例如,字符串“uid=john.doe,ou=people,dc=example,dc=com”和“uid=john.doe,ou=people,dc=example,dc=com”实际上指的是相同的可分辨名称。为了处理这些差异,可以使用规范化表示。规范化表示是一种表示DN的标准化方法,它是通过消除任何不必要的空格并将所有不区分大小写的字符转换为小写来实现的。可以使用DN#toNormalizedString方法获得DN的规范化表示,并且可以使用标准DN#equals方法比较两个DN以确定它们是否相等。
可分辨名称是分层的。最右边的RDN表示目录信息树(DIT)的根,左边的每个连续RDN表示添加了另一层次结构。例如,在DN“uid=john.doe,ou=People,o=example.com”中,条目“o=example.com”位于DIT的根目录下,条目“ou=People,o=example.com”是“o=example.com”条目的直接后代,“uid=john.doe,ou=People,o=example.com”条目是“ou=People,o=example.com”条目的直接后代。类似地,条目“uid=jane.doe,ou=People,o=example.com”将被视为“uid=john.doe,ou=People,o=example.com”条目的对等项,因为它们具有相同的父项。
请注意,在某些情况下,DIT的根实际上可能包含具有多个RDN的DN。例如,在DN“uid=john.doe,ou=People,dc=example,dc=com”中,目录服务器可能有也可能没有“dc=com”条目。在许多这样的情况下,基本条目实际上可能只是“dc=example,dc=com”。位于目录信息树底部的条目的DNs称为“命名上下文”或“后缀”,它们通常在根DSE的namingContexts属性中可用。有关与服务器根DSE交互的更多信息,请参阅RootDSEclass。
此类提供了基于DNs的层次关系进行确定的方法。例如,DN#isAncestorOf和DN#isdescendatof方法可用于确定两个DN是否具有层次关系。此外,该类实现了Comparable和ComparatorInterface,因此可以使用它轻松地对DNs进行排序(祖先总是在后代之前进行排序,而对等体总是根据其规范化表示按字典顺序进行排序)。
代码示例来源:origin: kiegroup/jbpm
@Before
public void startDirectoryServer() throws LDAPException {
InMemoryListenerConfig listenerConfig = InMemoryListenerConfig.createLDAPConfig("default", PORT);
InMemoryDirectoryServerConfig serverConfig = new InMemoryDirectoryServerConfig(new DN(BASE_DN));
serverConfig.setListenerConfigs(listenerConfig);
serverConfig.addAdditionalBindCredentials(USER_DN, PASSWORD);
serverConfig.setSchema(null);
server = new InMemoryDirectoryServer(serverConfig);
server.importFromLDIF(false, "src/test/resources/ldap-config.ldif");
server.startListening();
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
/**
* Retrieves the set of RDNs that comprise the DN with the provided string
* representation.
*
* @param s The string representation of the DN for which to retrieve the
* RDNs. It must not be {@code null}.
*
* @return The set of RDNs that comprise the DN with the provided string
* representation.
*
* @throws LDAPException If the provided string cannot be parsed as a DN.
*/
public static RDN[] getRDNs(final String s)
throws LDAPException
{
return new DN(s).getRDNs();
}
代码示例来源:origin: spring-projects/spring-security
@Override
public void start() {
if (isRunning()) {
return;
}
try {
InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig(this.defaultPartitionSuffix);
config.addAdditionalBindCredentials("uid=admin,ou=system", "secret");
config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("LDAP", this.port));
config.setEnforceSingleStructuralObjectClass(false);
config.setEnforceAttributeSyntaxCompliance(true);
DN dn = new DN(this.defaultPartitionSuffix);
Entry entry = new Entry(dn);
entry.addAttribute("objectClass", "top", "domain", "extensibleObject");
entry.addAttribute("dc", dn.getRDN().getAttributeValues()[0]);
InMemoryDirectoryServer directoryServer = new InMemoryDirectoryServer(config);
directoryServer.add(entry);
importLdif(directoryServer);
directoryServer.startListening();
this.port = directoryServer.getListenPort();
this.directoryServer = directoryServer;
this.running = true;
} catch (LDAPException ex) {
throw new RuntimeException("Server startup failed", ex);
}
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
/**
* Retrieves the parent DN for this entry.
*
* @return The parent DN for this entry, or {@code null} if there is no
* parent.
*
* @throws LDAPException If the DN string cannot be parsed as a valid DN.
*/
public final DN getParentDN()
throws LDAPException
{
if (parsedDN == null)
{
parsedDN = new DN(dn, schema);
}
return parsedDN.getParent();
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-minimal-edition
/**
* Indicates whether the two provided strings represent the same DN.
*
* @param s1 The string representation of the first DN for which to make the
* determination. It must not be {@code null}.
* @param s2 The string representation of the second DN for which to make
* the determination. It must not be {@code null}.
*
* @return {@code true} if the provided strings represent the same DN, or
* {@code false} if not.
*
* @throws LDAPException If either of the provided strings cannot be parsed
* as a DN.
*/
public static boolean equals(final String s1, final String s2)
throws LDAPException
{
return new DN(s1).equals(new DN(s2));
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
/**
* Retrieves a normalized representation of the DN with the provided string
* representation.
*
* @param s The string representation of the DN to normalize. It must
* not be {@code null}.
* @param schema The schema to use to generate the normalized string
* representation of the DN. It may be {@code null} if no
* schema is available.
*
* @return The normalized representation of the DN with the provided string
* representation.
*
* @throws LDAPException If the provided string cannot be parsed as a DN.
*/
public static String normalize(final String s, final Schema schema)
throws LDAPException
{
return new DN(s, schema).toNormalizedString();
}
代码示例来源:origin: sakaiproject/sakai
DN dn = new DN(dnString);
DN containerDN = dn.getParent();
RDN[] containerRDNs = containerDN.getRDNs();
for (RDN rdn : containerRDNs) {
String mappedValue = mapRdn(rdn.toNormalizedString());
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
/**
* Appends a string representation of this DN to the provided buffer.
*
* @param buffer The buffer to which to append the string representation of
* this DN.
*/
public void toString(final StringBuilder buffer)
{
toString(buffer, false);
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
/**
* Retrieves the set of string representations of the RDNs that comprise this
* DN.
*
* @param s The string representation of the DN for which to retrieve the
* RDN strings. It must not be {@code null}.
*
* @return The set of string representations of the RDNs that comprise this
* DN.
*
* @throws LDAPException If the provided string cannot be parsed as a DN.
*/
public static String[] getRDNStrings(final String s)
throws LDAPException
{
return new DN(s).getRDNStrings();
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-minimal-edition
/**
* Retrieves the string representation of the DN that is the parent for the
* DN with the provided string representation. Note that neither the null DN
* nor DNs consisting of a single RDN component will be considered to have
* parent DNs.
*
* @param s The string representation of the DN for which to retrieve the
* parent. It must not be {@code null}.
*
* @return The DN that is the parent for this DN, or {@code null} if there
* is no parent.
*
* @throws LDAPException If the provided string cannot be parsed as a DN.
*/
public static String getParentString(final String s)
throws LDAPException
{
return new DN(s).getParentString();
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-minimal-edition
/**
* Indicates whether this DN falls within the range of the provided search
* base DN and scope.
*
* @param baseDN The base DN for which to make the determination. It must
* not be {@code null}.
* @param scope The scope for which to make the determination. It must not
* be {@code null}.
*
* @return {@code true} if this DN is within the range of the provided base
* and scope, or {@code false} if not.
*
* @throws LDAPException If a problem occurs while making the determination.
*/
public boolean matchesBaseAndScope(final String baseDN,
final SearchScope scope)
throws LDAPException
{
return matchesBaseAndScope(new DN(baseDN), scope);
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
/**
* Creates a new move subtree transformation with the provided information.
*
* @param sourceDN The source base DN to be replaced with the target base
* DN. It must not be {@code null}.
* @param targetDN The target base DN to use to replace the source base DN.
* It must not be {@code null}.
*/
public MoveSubtreeTransformation(final DN sourceDN, final DN targetDN)
{
this.sourceDN = sourceDN;
targetRDNs = Arrays.asList(targetDN.getRDNs());
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-minimal-edition
/**
* Retrieves the RDN for this entry.
*
* @return The RDN for this entry, or {@code null} if the DN is the null DN.
*
* @throws LDAPException If the DN string cannot be parsed as a valid DN.
*/
public final RDN getRDN()
throws LDAPException
{
return getParsedDN().getRDN();
}
代码示例来源:origin: com.nimbusds/common
/**
* Returns the authzId string representation of the specified
* distinguished name (DN).
*
* @param dn The distinguished name (DN). Must not be {@code null}.
*
* @return The authzId string.
*/
private static String toAuthzIdString(final DN dn) {
if (dn == null)
throw new IllegalArgumentException("The authzId DN must not be null");
if (dn.equals(DN.NULL_DN))
return "dn:";
else
return "dn:" + dn.toNormalizedString();
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
if (dn.isNullDN())
else if (dn.equals(subschemaSubentryDN))
代码示例来源:origin: com.nimbusds/common
/**
* Logs the configuration details at INFO level.
*/
@Override
public void log() {
Logger log = LogManager.getLogger(LOG_CATEGORY);
if (dn.equals(DN.NULL_DN))
log.info("[CM1050] Directory user DN: [anonymous]");
else
log.info("[CM1050] Directory user DN: {}", dn);
}
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-minimal-edition
/**
* Indicates whether the DN with the provided string representation is equal
* to this DN.
*
* @param s The string representation of the DN to compare with this DN.
*
* @return {@code true} if the DN with the provided string representation is
* equal to this DN, or {@code false} if not.
*
* @throws LDAPException If the provided string cannot be parsed as a DN.
*/
public boolean equals(final String s)
throws LDAPException
{
if (s == null)
{
return false;
}
return equals(new DN(s));
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-minimal-edition
/**
* Retrieves the parent DN for this entry.
*
* @return The parent DN for this entry, or {@code null} if there is no
* parent.
*
* @throws LDAPException If the DN string cannot be parsed as a valid DN.
*/
public final DN getParentDN()
throws LDAPException
{
if (parsedDN == null)
{
parsedDN = new DN(dn, schema);
}
return parsedDN.getParent();
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-minimal-edition
/**
* Retrieves a normalized representation of the DN with the provided string
* representation.
*
* @param s The string representation of the DN to normalize. It must
* not be {@code null}.
* @param schema The schema to use to generate the normalized string
* representation of the DN. It may be {@code null} if no
* schema is available.
*
* @return The normalized representation of the DN with the provided string
* representation.
*
* @throws LDAPException If the provided string cannot be parsed as a DN.
*/
public static String normalize(final String s, final Schema schema)
throws LDAPException
{
return new DN(s, schema).toNormalizedString();
}
代码示例来源:origin: com.nimbusds/common
/**
* Creates a new distinguished name (DN) identity.
*
* @param dn The DN, must not be {@code null}.
*/
public DNIdentity(final DN dn) {
super(dn.toString());
this.dn = dn;
}
内容来源于网络,如有侵权,请联系作者删除!