X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.enterprise%2Fsrc%2Forg%2Fargeo%2Fnaming%2FDistinguished.java;fp=org.argeo.enterprise%2Fsrc%2Forg%2Fargeo%2Fnaming%2FDistinguished.java;h=ba0db49552c7001a0ec058ff039d9cbfc2daef3e;hb=e4b44be13dde0ddc9acb794add1c9459e2483513;hp=0000000000000000000000000000000000000000;hpb=0fa50894e8e37d657924fd69cc29f46aae683e65;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.enterprise/src/org/argeo/naming/Distinguished.java b/org.argeo.enterprise/src/org/argeo/naming/Distinguished.java new file mode 100644 index 000000000..ba0db4955 --- /dev/null +++ b/org.argeo.enterprise/src/org/argeo/naming/Distinguished.java @@ -0,0 +1,23 @@ +package org.argeo.naming; + +import javax.naming.InvalidNameException; +import javax.naming.ldap.LdapName; + +/** + * An object that can be identified with an X.500 distinguished name. + * + * @see https://tools.ietf.org/html/rfc1779 + */ +public interface Distinguished { + /** The related distinguished name. */ + String dn(); + + /** The related distinguished name as an {@link LdapName}. */ + default LdapName distinguishedName() { + try { + return new LdapName(dn()); + } catch (InvalidNameException e) { + throw new IllegalArgumentException("Distinguished name " + dn() + " is not properly formatted.", e); + } + } +}