Minor cleanup tweaks.
This commit is contained in:
@@ -22,7 +22,7 @@ import org.w3c.dom.Element;
|
||||
/**
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
class ParserUtils {
|
||||
final class ParserUtils {
|
||||
static final String NAMESPACE = "http://www.springframework.org/schema/ldap";
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,7 +24,14 @@ import java.io.StringReader;
|
||||
* @author Mattias Hellborg Arthursson
|
||||
* @deprecated {@link DistinguishedName} and associated classes are deprecated as of 2.0.
|
||||
*/
|
||||
public class DefaultDnParserFactory {
|
||||
public final class DefaultDnParserFactory {
|
||||
/**
|
||||
* Not to be instantiated.
|
||||
*/
|
||||
private DefaultDnParserFactory() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DnParser instance.
|
||||
*
|
||||
|
||||
@@ -220,7 +220,7 @@ public class DistinguishedName implements Name {
|
||||
*
|
||||
* @param path the LDAP path to parse.
|
||||
*/
|
||||
protected void parse(String path) {
|
||||
protected final void parse(String path) {
|
||||
DnParser parser = DefaultDnParserFactory.createDnParser(unmangleCompositeName(path));
|
||||
DistinguishedName dn;
|
||||
try {
|
||||
@@ -445,10 +445,7 @@ public class DistinguishedName implements Name {
|
||||
}
|
||||
|
||||
// Done
|
||||
if (!shortiter.hasNext() && longname.equals(shortname))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return !shortiter.hasNext() && longname.equals(shortname);
|
||||
|
||||
}
|
||||
|
||||
@@ -522,8 +519,9 @@ public class DistinguishedName implements Name {
|
||||
*/
|
||||
public void removeFirst(Name path) {
|
||||
if (path != null && this.startsWith(path)) {
|
||||
for (int i = 0; i < path.size(); i++)
|
||||
for (int i = 0; i < path.size(); i++) {
|
||||
this.removeFirst();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ import java.util.Set;
|
||||
* @author Mattias Hellborg Arthursson
|
||||
* @since 2.0
|
||||
*/
|
||||
public class NameAwareAttribute implements Attribute {
|
||||
public final class NameAwareAttribute implements Attribute {
|
||||
|
||||
private final String id;
|
||||
private final boolean orderMatters;
|
||||
@@ -64,9 +64,9 @@ public class NameAwareAttribute implements Attribute {
|
||||
public NameAwareAttribute(Attribute attribute) {
|
||||
this(attribute.getID(), attribute.isOrdered());
|
||||
try {
|
||||
NamingEnumeration<?> values = attribute.getAll();
|
||||
while(values.hasMore()) {
|
||||
this.add(values.next());
|
||||
NamingEnumeration<?> incomingValues = attribute.getAll();
|
||||
while(incomingValues.hasMore()) {
|
||||
this.add(incomingValues.next());
|
||||
}
|
||||
} catch (NamingException e) {
|
||||
throw LdapUtils.convertLdapException(e);
|
||||
@@ -155,12 +155,12 @@ public class NameAwareAttribute implements Attribute {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<Name, String> valuesAsNames = new HashMap<Name, String>();
|
||||
Map<Name, String> newValuesAsNames = new HashMap<Name, String>();
|
||||
for (Object value : values) {
|
||||
if (value instanceof String) {
|
||||
String s = (String) value;
|
||||
try {
|
||||
valuesAsNames.put(LdapUtils.newLdapName(s), s);
|
||||
newValuesAsNames.put(LdapUtils.newLdapName(s), s);
|
||||
} catch (InvalidNameException e) {
|
||||
throw new IllegalArgumentException("This instance has values that are not valid distinguished names; " +
|
||||
"cannot handle Name values");
|
||||
@@ -171,7 +171,7 @@ public class NameAwareAttribute implements Attribute {
|
||||
}
|
||||
}
|
||||
|
||||
this.valuesAsNames = valuesAsNames;
|
||||
this.valuesAsNames = newValuesAsNames;
|
||||
}
|
||||
|
||||
public boolean hasValuesAsNames() {
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.util.Map;
|
||||
* @author Mattias Hellborg Arthursson
|
||||
* @since 2.0
|
||||
*/
|
||||
public class NameAwareAttributes implements Attributes {
|
||||
public final class NameAwareAttributes implements Attributes {
|
||||
private Map<String, NameAwareAttribute> attributes = new HashMap<String, NameAwareAttribute>();
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,7 +35,7 @@ class RangeOption implements Comparable<RangeOption> {
|
||||
private int initial = 0;
|
||||
private int terminal = TERMINAL_END_OF_RANGE;
|
||||
|
||||
private static Pattern RANGE_PATTERN = Pattern.compile("^Range=([0-9]+)(-([0-9]+|\\*))?$", Pattern.CASE_INSENSITIVE);
|
||||
private static final Pattern RANGE_PATTERN = Pattern.compile("^Range=([0-9]+)(-([0-9]+|\\*))?$", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
public RangeOption(int initial) {
|
||||
this(initial, TERMINAL_END_OF_RANGE);
|
||||
@@ -91,10 +91,11 @@ class RangeOption implements Comparable<RangeOption> {
|
||||
if (!isTerminalMissing()) {
|
||||
rangeBuilder.append('-');
|
||||
|
||||
if (isTerminalEndOfRange())
|
||||
if (isTerminalEndOfRange()) {
|
||||
rangeBuilder.append('*');
|
||||
else
|
||||
} else {
|
||||
rangeBuilder.append(terminal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,10 +116,11 @@ class RangeOption implements Comparable<RangeOption> {
|
||||
if (rangeMatcher.group(2) != null) {
|
||||
String terminalStr = rangeMatcher.group(3);
|
||||
|
||||
if ("*".equals(terminalStr))
|
||||
if ("*".equals(terminalStr)) {
|
||||
terminal = TERMINAL_END_OF_RANGE;
|
||||
else
|
||||
} else {
|
||||
terminal = Integer.parseInt(terminalStr);
|
||||
}
|
||||
}
|
||||
|
||||
return new RangeOption(initial, terminal);
|
||||
|
||||
@@ -16,14 +16,15 @@
|
||||
|
||||
package org.springframework.ldap.odm.core.impl;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
// A case independent String wrapper.
|
||||
/* package */ final class CaseIgnoreString implements Comparable<CaseIgnoreString> {
|
||||
private final String string;
|
||||
private final int hashCode;
|
||||
|
||||
public CaseIgnoreString(String string) {
|
||||
if (string == null)
|
||||
throw new NullPointerException();
|
||||
Assert.notNull(string, "string must not be null");
|
||||
this.string = string;
|
||||
hashCode = string.toUpperCase().hashCode();
|
||||
}
|
||||
@@ -38,7 +39,7 @@ package org.springframework.ldap.odm.core.impl;
|
||||
}
|
||||
|
||||
public int compareTo(CaseIgnoreString other) {
|
||||
CaseIgnoreString cis = (CaseIgnoreString)other;
|
||||
CaseIgnoreString cis = other;
|
||||
return String.CASE_INSENSITIVE_ORDER.compare(string, cis.string);
|
||||
}
|
||||
|
||||
|
||||
@@ -63,8 +63,8 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper {
|
||||
// The converter manager to use to translate values between LDAP and Java
|
||||
private ConverterManager converterManager;
|
||||
|
||||
private static String OBJECT_CLASS_ATTRIBUTE="objectclass";
|
||||
private static CaseIgnoreString OBJECT_CLASS_ATTRIBUTE_CI=new CaseIgnoreString(OBJECT_CLASS_ATTRIBUTE);
|
||||
private static final String OBJECT_CLASS_ATTRIBUTE="objectclass";
|
||||
private static final CaseIgnoreString OBJECT_CLASS_ATTRIBUTE_CI=new CaseIgnoreString(OBJECT_CLASS_ATTRIBUTE);
|
||||
|
||||
|
||||
public DefaultObjectDirectoryMapper() {
|
||||
@@ -137,18 +137,7 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper {
|
||||
for (Field field : metaData) {
|
||||
AttributeMetaData attributeInfo = metaData.getAttribute(field);
|
||||
if (!attributeInfo.isTransient() && !attributeInfo.isId() && !(attributeInfo.isObjectClass())) {
|
||||
Class<?> jndiClass = attributeInfo.getJndiClass();
|
||||
Class<?> javaClass = attributeInfo.getValueClass();
|
||||
if (!converterManager.canConvert(jndiClass, attributeInfo.getSyntax(), javaClass)) {
|
||||
throw new InvalidEntryException(String.format(
|
||||
"Missing converter from %1$s to %2$s, this is needed for field %3$s on Entry %4$s",
|
||||
jndiClass, javaClass, field.getName(), managedClass));
|
||||
}
|
||||
if (!converterManager.canConvert(javaClass, attributeInfo.getSyntax(), jndiClass)) {
|
||||
throw new InvalidEntryException(String.format(
|
||||
"Missing converter from %1$s to %2$s, this is needed for field %3$s on Entry %4$s",
|
||||
javaClass, jndiClass, field.getName(), managedClass));
|
||||
}
|
||||
verifyConversion(managedClass, field, attributeInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,6 +157,21 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper {
|
||||
return newValue;
|
||||
}
|
||||
|
||||
private void verifyConversion(Class<?> managedClass, Field field, AttributeMetaData attributeInfo) {
|
||||
Class<?> jndiClass = attributeInfo.getJndiClass();
|
||||
Class<?> javaClass = attributeInfo.getValueClass();
|
||||
if (!converterManager.canConvert(jndiClass, attributeInfo.getSyntax(), javaClass)) {
|
||||
throw new InvalidEntryException(String.format(
|
||||
"Missing converter from %1$s to %2$s, this is needed for field %3$s on Entry %4$s",
|
||||
jndiClass, javaClass, field.getName(), managedClass));
|
||||
}
|
||||
if (!converterManager.canConvert(javaClass, attributeInfo.getSyntax(), jndiClass)) {
|
||||
throw new InvalidEntryException(String.format(
|
||||
"Missing converter from %1$s to %2$s, this is needed for field %3$s on Entry %4$s",
|
||||
javaClass, jndiClass, field.getName(), managedClass));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapToLdapDataEntry(Object entry, LdapDataEntry context) {
|
||||
ObjectMetaData metaData=getEntityData(entry.getClass()).metaData;
|
||||
|
||||
@@ -91,7 +91,7 @@ import java.util.Set;
|
||||
* @author Paul Harvey <paul.at.pauls-place.me.uk>
|
||||
*/
|
||||
public final class ConverterManagerFactoryBean implements FactoryBean {
|
||||
private static Logger LOG = LoggerFactory.getLogger(ConverterManagerFactoryBean.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ConverterManagerFactoryBean.class);
|
||||
|
||||
/**
|
||||
* Configuration information for a single Converter instance.
|
||||
|
||||
@@ -238,9 +238,9 @@ public class DelegatingDirContext extends DelegatingContext implements DirContex
|
||||
/**
|
||||
* @see javax.naming.directory.DirContext#modifyAttributes(javax.naming.Name, int, javax.naming.directory.Attributes)
|
||||
*/
|
||||
public void modifyAttributes(Name name, int mod_op, Attributes attrs) throws NamingException {
|
||||
public void modifyAttributes(Name name, int modOp, Attributes attrs) throws NamingException {
|
||||
this.assertOpen();
|
||||
this.getDelegateDirContext().modifyAttributes(name, mod_op, attrs);
|
||||
this.getDelegateDirContext().modifyAttributes(name, modOp, attrs);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -254,9 +254,9 @@ public class DelegatingDirContext extends DelegatingContext implements DirContex
|
||||
/**
|
||||
* @see javax.naming.directory.DirContext#modifyAttributes(java.lang.String, int, javax.naming.directory.Attributes)
|
||||
*/
|
||||
public void modifyAttributes(String name, int mod_op, Attributes attrs) throws NamingException {
|
||||
public void modifyAttributes(String name, int modOp, Attributes attrs) throws NamingException {
|
||||
this.assertOpen();
|
||||
this.getDelegateDirContext().modifyAttributes(name, mod_op, attrs);
|
||||
this.getDelegateDirContext().modifyAttributes(name, modOp, attrs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,7 +53,7 @@ import java.text.MessageFormat;
|
||||
* @see org.springframework.ldap.core.LdapOperations#searchForObject(LdapQuery, org.springframework.ldap.core.ContextMapper)
|
||||
* @see org.springframework.ldap.core.LdapOperations#searchForContext(LdapQuery)
|
||||
*/
|
||||
public class LdapQueryBuilder implements LdapQuery {
|
||||
public final class LdapQueryBuilder implements LdapQuery {
|
||||
private Name base = LdapUtils.emptyLdapName();
|
||||
private SearchScope searchScope = null;
|
||||
private Integer countLimit = null;
|
||||
@@ -171,7 +171,7 @@ public class LdapQueryBuilder implements LdapQuery {
|
||||
* validated or escaped in any way. <b>Never</b> use direct user input and use it concatenating strings
|
||||
* to use as LDAP filters. Doing so opens up for "LDAP injection", where malicious user
|
||||
* may inject specifically constructed data to form filters at their convenience. When user input is used
|
||||
* consider using {@link #where(String)} or {@link #filter(String, String...)} instead.
|
||||
* consider using {@link #where(String)} or {@link #filter(String, Object...)} instead.
|
||||
*
|
||||
* @param hardcodedFilter The hardcoded filter string to use in the search.
|
||||
* @return this instance.
|
||||
|
||||
@@ -99,7 +99,7 @@ public class SimpleLdapRepository<T> implements LdapRepository<T> {
|
||||
ldapOperations.create(entity);
|
||||
} else {
|
||||
ldapOperations.update(entity);
|
||||
if (calculatedId != null && declaredId != calculatedId) {
|
||||
if (calculatedId != null && !calculatedId.equals(declaredId)) {
|
||||
odm.setId(entity, calculatedId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.ldap.BadLdapGrammarException;
|
||||
* @author Adam Skogman
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
public class LdapEncoder {
|
||||
public final class LdapEncoder {
|
||||
|
||||
private static String[] nameEscapeTable = new String[96];
|
||||
|
||||
@@ -75,10 +75,11 @@ public class LdapEncoder {
|
||||
|
||||
String raw = Integer.toHexString(c).toUpperCase();
|
||||
|
||||
if (raw.length() > 1)
|
||||
if (raw.length() > 1) {
|
||||
return raw;
|
||||
else
|
||||
} else {
|
||||
return "0" + raw;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,7 +29,7 @@ import javax.naming.ldap.Rdn;
|
||||
* @author Mattias Hellborg Arthursson
|
||||
* @since 2.0
|
||||
*/
|
||||
public class LdapNameBuilder {
|
||||
public final class LdapNameBuilder {
|
||||
|
||||
private final LdapName ldapName;
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.ldap.transaction.compensating.manager;
|
||||
import org.springframework.ldap.NamingException;
|
||||
import org.springframework.ldap.core.ContextSource;
|
||||
import org.springframework.ldap.core.DirContextProxy;
|
||||
import org.springframework.ldap.core.support.BaseLdapPathContextSource;
|
||||
import org.springframework.ldap.core.support.DelegatingBaseLdapPathContextSourceSupport;
|
||||
import org.springframework.ldap.support.LdapUtils;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
@@ -102,13 +101,4 @@ public class TransactionAwareContextSourceProxy
|
||||
public DirContext getContext(String principal, String credentials) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not supported on a transacted ContextSource");
|
||||
}
|
||||
|
||||
private BaseLdapPathContextSource convertToBaseLdapPathContextSource(ContextSource contextSource) {
|
||||
if (contextSource instanceof BaseLdapPathContextSource) {
|
||||
return (BaseLdapPathContextSource) contextSource;
|
||||
}
|
||||
|
||||
throw new UnsupportedOperationException("This operation is not supported on a target ContextSource that does not " +
|
||||
" implement BaseLdapPathContextSource");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,19 +16,19 @@
|
||||
|
||||
package org.springframework.transaction.compensating.support;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.transaction.compensating.CompensatingTransactionOperationManager;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* Common methods for use with compensating transactions.
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
* @since 1.2
|
||||
*/
|
||||
public class CompensatingTransactionUtils {
|
||||
public final class CompensatingTransactionUtils {
|
||||
|
||||
/**
|
||||
* Not to be instantiated.
|
||||
|
||||
@@ -136,16 +136,16 @@ public class LdapAttributes extends BasicAttributes {
|
||||
while (values.hasMore()) {
|
||||
Object value = values.next();
|
||||
|
||||
if (value instanceof String)
|
||||
if (value instanceof String) {
|
||||
sb.append(attribute.getID() + ": " + (String) value + "\n");
|
||||
|
||||
else if (value instanceof byte[])
|
||||
} else if (value instanceof byte[]) {
|
||||
sb.append(attribute.getID() + ":: " + new BASE64Encoder().encode((byte[]) value) + "\n");
|
||||
|
||||
else if (value instanceof URI)
|
||||
} else if (value instanceof URI) {
|
||||
sb.append(attribute.getID() + ":< " + (URI) value + "\n");
|
||||
|
||||
else {
|
||||
} else {
|
||||
sb.append(attribute.getID() + ": " + value + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,8 +290,9 @@ public class LdifParser implements Parser, InitializingBean {
|
||||
log.trace("...done parsing record. (EndOfRecord)");
|
||||
|
||||
//Validate record and return.
|
||||
if (record == null) return null;
|
||||
else {
|
||||
if (record == null) {
|
||||
return null;
|
||||
} else {
|
||||
try {
|
||||
//flush buffer.
|
||||
addAttributeToRecord(builder.toString(), record);
|
||||
|
||||
@@ -92,14 +92,14 @@ import java.util.regex.Pattern;
|
||||
*
|
||||
*/
|
||||
public final class SchemaToJava {
|
||||
private static Logger LOG = LoggerFactory.getLogger(SchemaToJava.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(SchemaToJava.class);
|
||||
|
||||
// Name of the FreeMarker template used to generate the Java code.
|
||||
private static String TEMPLATE_FILE = "oc-to-java.ftl";
|
||||
private static final String TEMPLATE_FILE = "oc-to-java.ftl";
|
||||
|
||||
// Name of file containing the list of attributes syntaxes to
|
||||
// returned as byte[] by the JNDI LDAP provider.
|
||||
private static String BINARY_FILE = "binary-attributes.txt";
|
||||
private static final String BINARY_FILE = "binary-attributes.txt";
|
||||
|
||||
// Class to use a base for loading resources
|
||||
private static final Class<?> loaderClass=SchemaToJava.class;
|
||||
@@ -155,6 +155,13 @@ public final class SchemaToJava {
|
||||
options.addOption(Flag.HELP.getShort(), Flag.HELP.getLong(), false, "Print this help message");
|
||||
}
|
||||
|
||||
/**
|
||||
* Not to be instantiated.
|
||||
*/
|
||||
private SchemaToJava() {
|
||||
|
||||
}
|
||||
|
||||
// Read list of LDAP syntaxes that are returned as byte[]
|
||||
private static Set<String> readBinarySet(File binarySetFile)
|
||||
throws IOException {
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package org.springframework.ldap.odm.tools;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.Hashtable;
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
|
||||
import javax.naming.AuthenticationException;
|
||||
import javax.naming.CommunicationException;
|
||||
@@ -14,13 +18,8 @@ import javax.naming.directory.Attribute;
|
||||
import javax.naming.directory.Attributes;
|
||||
import javax.naming.directory.DirContext;
|
||||
import javax.naming.directory.InitialDirContext;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import java.io.PrintStream;
|
||||
import java.util.Hashtable;
|
||||
|
||||
/**
|
||||
* A simple utility to list LDAP directory schema.
|
||||
@@ -111,6 +110,13 @@ public final class SchemaViewer {
|
||||
options.addOption(Flag.ERROR.getShort(), Flag.ERROR.getLong(), false, "Send output to standard error");
|
||||
}
|
||||
|
||||
/**
|
||||
* Not to be instantiated.
|
||||
*/
|
||||
private SchemaViewer() {
|
||||
|
||||
}
|
||||
|
||||
private static void printAttrs(Attributes attrs) throws NamingException {
|
||||
NamingEnumeration<? extends Attribute> attrsEnum = attrs.getAll();
|
||||
while (attrsEnum.hasMore()) {
|
||||
@@ -161,7 +167,7 @@ public final class SchemaViewer {
|
||||
}
|
||||
|
||||
private static PrintStream outstream=System.out;
|
||||
private static String WILDCARD = "?";
|
||||
private final static String WILDCARD = "?";
|
||||
|
||||
public static void main(String[] argv) {
|
||||
CommandLineParser parser = new PosixParser();
|
||||
|
||||
@@ -55,12 +55,12 @@ public class DummyDirContext implements DirContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyAttributes(Name name, int mod_op, Attributes attrs) throws NamingException {
|
||||
public void modifyAttributes(Name name, int modOp, Attributes attrs) throws NamingException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyAttributes(String name, int mod_op, Attributes attrs) throws NamingException {
|
||||
public void modifyAttributes(String name, int modOp, Attributes attrs) throws NamingException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.io.File;
|
||||
* @author Mattias Hellborg Arthursson
|
||||
* @since 1.3.2
|
||||
*/
|
||||
public class EmbeddedLdapServer {
|
||||
public final class EmbeddedLdapServer {
|
||||
private final DirectoryService directoryService;
|
||||
private final LdapServer ldapServer;
|
||||
|
||||
|
||||
@@ -27,22 +27,16 @@ import org.springframework.ldap.ldif.parser.LdifParser;
|
||||
import org.springframework.ldap.support.LdapUtils;
|
||||
|
||||
import javax.naming.Binding;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.ContextNotEmptyException;
|
||||
import javax.naming.Name;
|
||||
import javax.naming.NamingEnumeration;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.Attributes;
|
||||
import javax.naming.directory.BasicAttribute;
|
||||
import javax.naming.directory.BasicAttributes;
|
||||
import javax.naming.directory.DirContext;
|
||||
import javax.naming.ldap.LdapName;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -51,7 +45,7 @@ import java.util.Set;
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
public class LdapTestUtils {
|
||||
public final class LdapTestUtils {
|
||||
|
||||
public static final String DEFAULT_PRINCIPAL = "uid=admin,ou=system";
|
||||
public static final String DEFAULT_PASSWORD = "secret";
|
||||
@@ -271,30 +265,4 @@ public class LdapTestUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static Hashtable createEnv(String principal, String credentials) {
|
||||
Hashtable env = new Properties();
|
||||
|
||||
env.put(Context.PROVIDER_URL, "");
|
||||
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.directory.server.jndi.ServerContextFactory");
|
||||
|
||||
env.put(Context.SECURITY_PRINCIPAL, principal);
|
||||
env.put(Context.SECURITY_CREDENTIALS, credentials);
|
||||
env.put(Context.SECURITY_AUTHENTICATION, "simple");
|
||||
|
||||
return env;
|
||||
}
|
||||
|
||||
private static Attributes getRootPartitionAttributes(String defaultPartitionName) {
|
||||
BasicAttributes attributes = new BasicAttributes();
|
||||
BasicAttribute objectClassAttribute = new BasicAttribute("objectClass");
|
||||
objectClassAttribute.add("top");
|
||||
objectClassAttribute.add("domain");
|
||||
objectClassAttribute.add("extensibleObject");
|
||||
attributes.put(objectClassAttribute);
|
||||
attributes.put("dc", defaultPartitionName);
|
||||
|
||||
return attributes;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user