Moved everything from mvn-build to trunk root.
This commit is contained in:
23
core-tiger/src/assemble/bin-with-source.xml
Normal file
23
core-tiger/src/assemble/bin-with-source.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<assembly>
|
||||
<id>assembly</id>
|
||||
<formats>
|
||||
<format>dir</format>
|
||||
</formats>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<directory>target</directory>
|
||||
<includes>
|
||||
<include>*.jar</include>
|
||||
</includes>
|
||||
<outputDirectory>dist</outputDirectory>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*.java</include>
|
||||
</includes>
|
||||
<outputDirectory>src</outputDirectory>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</assembly>
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2005-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.ldap.core.simple;
|
||||
|
||||
import org.springframework.ldap.core.DirContextOperations;
|
||||
|
||||
/**
|
||||
* Abstract superclass that may be used instead of implementing
|
||||
* {@link ParameterizedContextMapper} directly. Subclassing from this superclass,
|
||||
* the supplied context will be automatically cast to
|
||||
* <code>DirContextOperations</code>. Note that if you use your own
|
||||
* <code>DirObjectFactory</code>, this implementation will fail with a
|
||||
* <code>ClassCastException</code>.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractParameterizedContextMapper<T> implements ParameterizedContextMapper<T> {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.ldap.core.ContextMapper#mapFromContext(java.lang.Object)
|
||||
*/
|
||||
public final T mapFromContext(Object ctx) {
|
||||
return doMapFromContext((DirContextOperations) ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Map a single <code>DirContextOperation</code> to an object. The
|
||||
* supplied instance is the object supplied to
|
||||
* {@link #mapFromContext(Object)} cast to a
|
||||
* <code>DirContextOperations</code>.
|
||||
*
|
||||
* @param ctx the context to map to an object.
|
||||
* @return an object built from the data in the context.
|
||||
*/
|
||||
protected abstract T doMapFromContext(DirContextOperations ctx);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.springframework.ldap.core.simple;
|
||||
|
||||
import javax.naming.Binding;
|
||||
import javax.naming.directory.SearchResult;
|
||||
|
||||
import org.springframework.ldap.core.ContextMapper;
|
||||
|
||||
/**
|
||||
* Extension of the {@link ContextMapper} interface. Uses Java 5 covariant
|
||||
* return types to override the return type of the
|
||||
* {@link #mapFromContext(Object)} method to be the type parameter T.
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public interface ParameterizedContextMapper<T> extends ContextMapper {
|
||||
|
||||
/**
|
||||
* Map a single LDAP Context to an object. The supplied Object
|
||||
* <code>ctx</code> is the object from a single {@link SearchResult},
|
||||
* {@link Binding}, or a lookup operation.
|
||||
*
|
||||
* @param ctx the context to map to an object.
|
||||
* @return an object built from the data in the context.
|
||||
*/
|
||||
public T mapFromContext(Object ctx);
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Copyright 2005-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.ldap.core.simple;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.naming.directory.Attributes;
|
||||
import javax.naming.directory.SearchControls;
|
||||
|
||||
import org.springframework.ldap.NamingException;
|
||||
import org.springframework.ldap.core.DirContextOperations;
|
||||
import org.springframework.ldap.core.DirContextProcessor;
|
||||
import org.springframework.ldap.core.LdapOperations;
|
||||
|
||||
/**
|
||||
* LDAP operations interface usable on Java 5 and above, exposing a set of
|
||||
* common LDAP operations.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
*/
|
||||
public interface SimpleLdapOperations {
|
||||
|
||||
/**
|
||||
* Get the wrapped LdapOperations instance.
|
||||
*
|
||||
* @return the wrapped LdapOperations instance.
|
||||
* @throws NamingException if any error occurs.
|
||||
*/
|
||||
LdapOperations getLdapOperations();
|
||||
|
||||
/**
|
||||
* Search for a List of type T using the supplied filter and link
|
||||
* ParametrizedContextMapper.
|
||||
*
|
||||
* @param base Base DN relative to the base of the ContextSource - where to
|
||||
* start the search.
|
||||
* @param filter Search filter.
|
||||
* @param mapper the Mapper to supply all results to.
|
||||
* @return a List of type T containing objects for all entries found, as
|
||||
* mapped by the ParametrizedContextMapper.
|
||||
* @throws NamingException if any error occurs.
|
||||
*/
|
||||
<T> List<T> search(String base, String filter, ParameterizedContextMapper<T> mapper);
|
||||
|
||||
/**
|
||||
* Search for a List of type T using the supplied filter, SearchControls,
|
||||
* DirContextProcessor and ParametrizedContextMapper.
|
||||
*
|
||||
* @param base Base DN relative to the base of the ContextSource - where to
|
||||
* start the search.
|
||||
* @param filter Search filter.
|
||||
* @param controls the SearchControls. Make sure that the returningObjFlag
|
||||
* is set to <code>true</code>.
|
||||
* @param mapper the Mapper to supply all results to.
|
||||
* @param processor the DirContextProcessor to be used for applying pre/post
|
||||
* processing on the DirContext instance.
|
||||
* @return a List of type T containing objects for all entries found, as
|
||||
* mapped by the ParametrizedContextMapper.
|
||||
* @throws NamingException if any error occurs.
|
||||
*/
|
||||
<T> List<T> search(String base, String filter, SearchControls controls, ParameterizedContextMapper<T> mapper,
|
||||
DirContextProcessor processor);
|
||||
|
||||
/**
|
||||
* Perform a lookup of the specified DN and map the result using the mapper.
|
||||
*
|
||||
* @param dn the Distinguished Name to look up.
|
||||
* @param mapper the mapper to use.
|
||||
* @return the mapped object, as received by the ParametrizedContextMapper.
|
||||
* @throws NamingException if any error occurs.
|
||||
*/
|
||||
<T> T lookup(String dn, ParameterizedContextMapper<T> mapper);
|
||||
|
||||
/**
|
||||
* Look up the specified DN, and automatically cast it to a
|
||||
* {@link DirContextOperations} instance.
|
||||
*
|
||||
* @param dn The Distinguished Name of the entry to look up.
|
||||
* @return A {@link DirContextOperations} instance constructed from the
|
||||
* found entry.
|
||||
* @throws NamingException if any error occurs.
|
||||
*/
|
||||
DirContextOperations lookupContext(String dn);
|
||||
|
||||
/**
|
||||
* Create an entry in the LDAP tree. The attributes used to create the entry
|
||||
* are either retrieved from the <code>obj</code> parameter or the
|
||||
* <code>attributes</code> parameter (or both). One of these parameters
|
||||
* may be null but not both.
|
||||
*
|
||||
* @param dn The distinguished name to bind the object and attributes to.
|
||||
* @param obj The object to bind, may be null. Typically a DirContext
|
||||
* implementation.
|
||||
* @param attributes The attributes to bind, may be null.
|
||||
* @throws NamingException if any error occurs.
|
||||
*/
|
||||
void bind(String dn, Object obj, Attributes attributes);
|
||||
|
||||
/**
|
||||
* Remove an entry from the LDAP tree. The entry must not have any children.
|
||||
*
|
||||
* @param dn The distinguished name to unbind.
|
||||
* @throws NamingException if any error occurs.
|
||||
*/
|
||||
void unbind(String dn);
|
||||
|
||||
/**
|
||||
* Modify the Attributes of the entry corresponding to the supplied
|
||||
* {@link DirContextOperations} instance. The instance should have been
|
||||
* received from the {@link #lookupContext(String)} operation, and then modified to
|
||||
* match the current state of the matching domain object, e.g.:
|
||||
*
|
||||
* <pre>
|
||||
* public void update(Person person) {
|
||||
* DirContextOperations ctx = simpleLdapOperations.lookup(person.getDn());
|
||||
*
|
||||
* ctx.setAttributeValue("description", person.getDescription());
|
||||
* ctx.setAttributeValue("telephoneNumber", person.getPhone());
|
||||
* // More modifications here
|
||||
*
|
||||
* simpleLdapOperations.modifyAttributes(ctx);
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @param ctx the entry to update in the LDAP tree.
|
||||
* @throws NamingException if any error occurs.
|
||||
*/
|
||||
void modifyAttributes(DirContextOperations ctx);
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright 2005-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.ldap.core.simple;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.naming.directory.Attributes;
|
||||
import javax.naming.directory.SearchControls;
|
||||
|
||||
import org.springframework.ldap.core.ContextSource;
|
||||
import org.springframework.ldap.core.DirContextOperations;
|
||||
import org.springframework.ldap.core.DirContextProcessor;
|
||||
import org.springframework.ldap.core.LdapOperations;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
|
||||
/**
|
||||
* Java-5-based convenience wrapper for the classic LdapTemplate, adding some
|
||||
* convenient shortcuts and taking advantage of Java 5 Generics.
|
||||
*
|
||||
* Use the {@link #getLdapOperations()} method if you need to invoke less
|
||||
* commonly used template methods.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
*/
|
||||
public class SimpleLdapTemplate implements SimpleLdapOperations {
|
||||
|
||||
private LdapOperations ldapOperations;
|
||||
|
||||
/**
|
||||
* Constructs a new SimpleLdapTemplate instance wrapping the supplied
|
||||
* LdapOperations instance.
|
||||
*
|
||||
* @param ldapOperations the LdapOperations instance to wrap.
|
||||
*/
|
||||
public SimpleLdapTemplate(LdapOperations ldapOperations) {
|
||||
this.ldapOperations = ldapOperations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new SimpleLdapTemplate instance, automatically creating a
|
||||
* wrapped LdapTemplate instance to work with.
|
||||
*
|
||||
* @param contextSource
|
||||
*/
|
||||
public SimpleLdapTemplate(ContextSource contextSource) {
|
||||
this.ldapOperations = new LdapTemplate(contextSource);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.ldap.core.simple.SimpleLdapOperations#getLdapOperations()
|
||||
*/
|
||||
public LdapOperations getLdapOperations() {
|
||||
return ldapOperations;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.ldap.core.simple.SimpleLdapOperations#lookup(java.lang.String,
|
||||
* org.springframework.ldap.core.simple.ParametrizedContextMapper)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T lookup(String dn, ParameterizedContextMapper<T> mapper) {
|
||||
return (T) ldapOperations.lookup(dn, mapper);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.ldap.core.simple.SimpleLdapOperations#search(java.lang.String,
|
||||
* java.lang.String,
|
||||
* org.springframework.ldap.core.simple.ParametrizedContextMapper)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> List<T> search(String base, String filter, ParameterizedContextMapper<T> mapper) {
|
||||
return ldapOperations.search(base, filter, mapper);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.ldap.core.simple.SimpleLdapOperations#search(java.lang.String,
|
||||
* java.lang.String, javax.naming.directory.SearchControls,
|
||||
* org.springframework.ldap.core.simple.ParametrizedContextMapper,
|
||||
* org.springframework.ldap.core.DirContextProcessor)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> List<T> search(String base, String filter, SearchControls controls, ParameterizedContextMapper<T> mapper,
|
||||
DirContextProcessor processor) {
|
||||
return ldapOperations.search(base, filter, controls, mapper, processor);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.ldap.core.simple.SimpleLdapOperations#lookup(java.lang.String)
|
||||
*/
|
||||
public DirContextOperations lookupContext(String dn) {
|
||||
return ldapOperations.lookupContext(dn);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.ldap.core.simple.SimpleLdapOperations#modifyAttributes(org.springframework.ldap.core.DirContextOperations)
|
||||
*/
|
||||
public void modifyAttributes(DirContextOperations ctx) {
|
||||
ldapOperations.modifyAttributes(ctx);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.ldap.core.simple.SimpleLdapOperations#bind(java.lang.String,
|
||||
* java.lang.Object, javax.naming.directory.Attributes)
|
||||
*/
|
||||
public void bind(String dn, Object obj, Attributes attributes) {
|
||||
ldapOperations.bind(dn, obj, attributes);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.ldap.core.simple.SimpleLdapOperations#unbind(java.lang.String)
|
||||
*/
|
||||
public void unbind(String dn) {
|
||||
ldapOperations.unbind(dn);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<html>
|
||||
<body>
|
||||
|
||||
Simplification layer over LdapTemplate for Java 5 and above.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
3
core-tiger/src/main/java/overview.html
Normal file
3
core-tiger/src/main/java/overview.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<body>
|
||||
This document is the API specification for the Java5-specific parts of the Spring LDAP Framework.
|
||||
</body>
|
||||
Reference in New Issue
Block a user