]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.util/src/org/argeo/util/naming/Distinguished.java
6aefc161724c7f5bbfb8cf31753ff0ef63ee9c2d
1 package org
.argeo
.util
.naming
;
3 import java
.util
.EnumSet
;
5 import java
.util
.TreeSet
;
7 import javax
.naming
.InvalidNameException
;
8 import javax
.naming
.ldap
.LdapName
;
11 * An object that can be identified with an X.500 distinguished name.
13 * @see https://tools.ietf.org/html/rfc1779
15 public interface Distinguished
{
16 /** The related distinguished name. */
19 /** The related distinguished name as an {@link LdapName}. */
20 default LdapName
distinguishedName() {
22 return new LdapName(dn());
23 } catch (InvalidNameException e
) {
24 throw new IllegalArgumentException("Distinguished name " + dn() + " is not properly formatted.", e
);
28 /** List all DNs of an enumeration as strings. */
29 static Set
<String
> enumToDns(EnumSet
<?
extends Distinguished
> enumSet
) {
30 Set
<String
> res
= new TreeSet
<>();
31 for (Enum
<?
extends Distinguished
> enm
: enumSet
) {
32 res
.add(((Distinguished
) enm
).dn());