Cleaned up usage of DistinguishedName from satellite modules, samples and tests.
This commit is contained in:
@@ -79,6 +79,7 @@ public class LdapAttributes extends BasicAttributes {
|
||||
*
|
||||
* @return {@link org.springframework.ldap.core.DistinguishedName} specifying the name to which the object is bound.
|
||||
* @deprecated {@link DistinguishedName and associated classes and methods are deprecated as of 2.0}.
|
||||
* use {@link #getName()} instead.
|
||||
*/
|
||||
public DistinguishedName getDN() {
|
||||
return new DistinguishedName(dn);
|
||||
@@ -98,6 +99,7 @@ public class LdapAttributes extends BasicAttributes {
|
||||
*
|
||||
* @param dn {@link org.springframework.ldap.core.DistinguishedName} specifying the name to which the object is bound.
|
||||
* @deprecated {@link DistinguishedName and associated classes and methods are deprecated as of 2.0}.
|
||||
* use {@link #setName(javax.naming.Name)} instead.
|
||||
*/
|
||||
public void setDN(DistinguishedName dn) {
|
||||
this.dn = LdapUtils.newLdapName(dn);
|
||||
@@ -117,7 +119,7 @@ public class LdapAttributes extends BasicAttributes {
|
||||
|
||||
try {
|
||||
|
||||
DistinguishedName dn = getDN();
|
||||
LdapName dn = getName();
|
||||
|
||||
if (!dn.toString().matches(SAFE_INIT_CHAR + SAFE_CHAR + "*")) {
|
||||
sb.append("dn:: " + new BASE64Encoder().encode(dn.toString().getBytes()) + "\n");
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package org.springframework.ldap.schema;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
import org.springframework.ldap.core.LdapAttributes;
|
||||
import org.springframework.ldap.core.LdapRdn;
|
||||
|
||||
import sun.misc.BASE64Encoder;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.ldap.LdapName;
|
||||
import javax.naming.ldap.Rdn;
|
||||
|
||||
/**
|
||||
* BasicSchemaSpecification establishes a minimal set of requirements for object classes.
|
||||
* <p>
|
||||
@@ -33,25 +32,25 @@ public class BasicSchemaSpecification implements Specification<LdapAttributes> {
|
||||
if (record != null) {
|
||||
|
||||
//DN is required.
|
||||
DistinguishedName dn = record.getDN();
|
||||
LdapName dn = record.getName();
|
||||
if (dn != null) {
|
||||
|
||||
//objectClass definition is required.
|
||||
if (record.get("objectClass") != null) {
|
||||
|
||||
//Naming attribute is required.
|
||||
LdapRdn rdn = dn.getLdapRdn(dn.size() - 1);
|
||||
if (record.get(rdn.getKey()) != null) {
|
||||
Object object = record.get(rdn.getKey()).get();
|
||||
Rdn rdn = dn.getRdn(dn.size() - 1);
|
||||
if (record.get(rdn.getType()) != null) {
|
||||
Object object = record.get(rdn.getType()).get();
|
||||
|
||||
if (object instanceof String) {
|
||||
String value = (String) object;
|
||||
if (rdn.getValue().equalsIgnoreCase(value)) {
|
||||
if (((String)rdn.getValue()).equalsIgnoreCase(value)) {
|
||||
return true;
|
||||
}
|
||||
} else if(object instanceof byte[]) {
|
||||
BASE64Encoder encoder = new BASE64Encoder();
|
||||
String rdnValue = encoder.encode(rdn.getValue().getBytes());
|
||||
String rdnValue = encoder.encode(((String)rdn.getValue()).getBytes());
|
||||
String attributeValue = encoder.encode((byte[]) object);
|
||||
if (rdnValue.equals(attributeValue)) return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user