LDAP-258: Deprecated core-tiger module.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
* Copyright 2005-2013 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.
|
||||
@@ -26,7 +26,7 @@ import org.springframework.ldap.core.DirContextOperations;
|
||||
* <code>ClassCastException</code>.
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*
|
||||
* @deprecated Core classes are parameterized as of 2.0.
|
||||
*/
|
||||
public abstract class AbstractParameterizedContextMapper<T> implements ParameterizedContextMapper<T> {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
* Copyright 2005-2013 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.
|
||||
@@ -15,13 +15,13 @@
|
||||
*/
|
||||
package org.springframework.ldap.core.simple;
|
||||
|
||||
import org.springframework.ldap.core.ContextMapperCallbackHandler;
|
||||
import org.springframework.ldap.core.ObjectRetrievalException;
|
||||
|
||||
import javax.naming.Binding;
|
||||
import javax.naming.NameClassPair;
|
||||
import javax.naming.ldap.HasControls;
|
||||
|
||||
import org.springframework.ldap.core.ContextMapperCallbackHandler;
|
||||
import org.springframework.ldap.core.ObjectRetrievalException;
|
||||
|
||||
/**
|
||||
* Currently only per request controls can be inspected via the post process
|
||||
* method on a context processor. If a request control gives a different value
|
||||
@@ -34,6 +34,7 @@ import org.springframework.ldap.core.ObjectRetrievalException;
|
||||
*
|
||||
* @author Tim Terry
|
||||
* @author Ulrik Sandberg
|
||||
* @deprecated use {@link org.springframework.ldap.core.support.ContextMapperCallbackHandlerWithControls} instead.
|
||||
*/
|
||||
public class ContextMapperCallbackHandlerWithControls extends ContextMapperCallbackHandler {
|
||||
|
||||
|
||||
@@ -15,17 +15,18 @@
|
||||
*/
|
||||
package org.springframework.ldap.core.simple;
|
||||
|
||||
import org.springframework.ldap.core.ContextMapper;
|
||||
|
||||
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>
|
||||
* @deprecated Core classes are parameterized as of 2.0.
|
||||
*/
|
||||
public interface ParameterizedContextMapper<T> extends ContextMapper {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
* Copyright 2005-2013 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.
|
||||
@@ -26,8 +26,8 @@ import javax.naming.ldap.HasControls;
|
||||
*
|
||||
* @author Tim Terry
|
||||
* @author Ulrik Sandberg
|
||||
* @param <T> return type of the
|
||||
* {@link #mapFromContextWithControls(Object, HasControls)} method
|
||||
* @param <T> return type of the {@link #mapFromContextWithControls(Object, HasControls)} method.
|
||||
* @deprecated use {@link org.springframework.ldap.core.support.ContextMapperWithControls} instead.
|
||||
*/
|
||||
public interface ParameterizedContextMapperWithControls<T> extends ParameterizedContextMapper<T> {
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import java.util.List;
|
||||
* common LDAP operations.
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
* @deprecated Core classes are parameterized as of 2.0.
|
||||
*/
|
||||
public interface SimpleLdapOperations {
|
||||
|
||||
|
||||
@@ -15,18 +15,17 @@
|
||||
*/
|
||||
package org.springframework.ldap.core.simple;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.naming.Name;
|
||||
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;
|
||||
|
||||
import javax.naming.Name;
|
||||
import javax.naming.directory.Attributes;
|
||||
import javax.naming.directory.SearchControls;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Java-5-based convenience wrapper for the classic LdapTemplate, adding some
|
||||
* convenient shortcuts and taking advantage of Java 5 Generics.
|
||||
@@ -35,6 +34,7 @@ import org.springframework.ldap.core.LdapTemplate;
|
||||
* commonly used template methods.
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
* @deprecated Core classes are parameterized as of 2.0.
|
||||
*/
|
||||
public class SimpleLdapTemplate implements SimpleLdapOperations {
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<html>
|
||||
<body>
|
||||
|
||||
Simplification layer over LdapTemplate for Java 5 and above.
|
||||
Simplification layer over LdapTemplate for Java 5 and above. As of Spring LDAP 2.0 all interfaces and classes
|
||||
in this package are deprecated.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright 2005-2013 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.support;
|
||||
|
||||
import org.springframework.ldap.core.ContextMapperCallbackHandler;
|
||||
import org.springframework.ldap.core.ObjectRetrievalException;
|
||||
|
||||
import javax.naming.Binding;
|
||||
import javax.naming.NameClassPair;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.ldap.HasControls;
|
||||
|
||||
/**
|
||||
* Currently only per request controls can be inspected via the post process
|
||||
* method on a context processor. If a request control gives a different value
|
||||
* for each search result, then this cannot be inspected using the existing
|
||||
* support classes. An example control that requires this feature would be
|
||||
* 1.3.6.1.4.1.42.2.27.9.5.8 Account usability control, that can be used with
|
||||
* for example the Sun ONE or the OpenDS directory servers.
|
||||
*
|
||||
* The extended callback handler can pass hasControls to mapper.
|
||||
*
|
||||
* @author Tim Terry
|
||||
* @author Ulrik Sandberg
|
||||
*/
|
||||
public class ContextMapperCallbackHandlerWithControls<T> extends ContextMapperCallbackHandler<T> {
|
||||
|
||||
private ContextMapperWithControls<T> mapper = null;
|
||||
|
||||
public ContextMapperCallbackHandlerWithControls(final ContextMapperWithControls<T> mapper) {
|
||||
super(mapper);
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.springframework.ldap.core.ContextMapperCallbackHandler#
|
||||
* getObjectFromNameClassPair(javax.naming.NameClassPair)
|
||||
*/
|
||||
public T getObjectFromNameClassPair(final NameClassPair nameClassPair) throws NamingException{
|
||||
if (!(nameClassPair instanceof Binding)) {
|
||||
throw new IllegalArgumentException("Parameter must be an instance of Binding");
|
||||
}
|
||||
|
||||
Binding binding = (Binding) nameClassPair;
|
||||
Object object = binding.getObject();
|
||||
if (object == null) {
|
||||
throw new ObjectRetrievalException("Binding did not contain any object.");
|
||||
}
|
||||
T result;
|
||||
if (nameClassPair instanceof HasControls) {
|
||||
result = mapper.mapFromContextWithControls(object, (HasControls) nameClassPair);
|
||||
}
|
||||
else {
|
||||
result = mapper.mapFromContext(object);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2005-2013 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.support;
|
||||
|
||||
import org.springframework.ldap.core.ContextMapper;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.ldap.HasControls;
|
||||
|
||||
/**
|
||||
* Extension of the {@link org.springframework.ldap.core.ContextMapper} interface that allows
|
||||
* controls to be passed to the mapper implementation. Uses Java 5 covariant
|
||||
* return types to override the return type of the
|
||||
* {@link #mapFromContextWithControls(Object, javax.naming.ldap.HasControls)} method to be the
|
||||
* type parameter T.
|
||||
*
|
||||
* @author Tim Terry
|
||||
* @author Ulrik Sandberg
|
||||
* @param <T> return type of the
|
||||
* {@link #mapFromContextWithControls(Object, javax.naming.ldap.HasControls)} method
|
||||
*/
|
||||
public interface ContextMapperWithControls<T> extends ContextMapper<T> {
|
||||
T mapFromContextWithControls(final Object ctx, final HasControls hasControls) throws NamingException;
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright 2005-2013 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.support;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.ldap.core.ObjectRetrievalException;
|
||||
|
||||
import javax.naming.Binding;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.ldap.Control;
|
||||
import javax.naming.ldap.HasControls;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* @Ulrik Sandberg
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
public class ContextMapperCallbackHandlerWithControlsTest {
|
||||
private ContextMapperWithControls mapperMock;
|
||||
|
||||
private ContextMapperCallbackHandlerWithControls tested;
|
||||
|
||||
private static class MyBindingThatHasControls extends Binding implements HasControls {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public MyBindingThatHasControls(String name, Object obj) {
|
||||
super(name, obj);
|
||||
}
|
||||
|
||||
public Control[] getControls() throws NamingException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
mapperMock = mock(ContextMapperWithControls.class);
|
||||
tested = new ContextMapperCallbackHandlerWithControls(mapperMock);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testConstructorWithEmptyArgument() {
|
||||
new ContextMapperCallbackHandlerWithControls<Object>(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetObjectFromNameClassPair() throws NamingException {
|
||||
Object expectedObject = "object";
|
||||
Object expectedResult = "result";
|
||||
Binding expectedBinding = new Binding("some name", expectedObject);
|
||||
|
||||
when(mapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult);
|
||||
|
||||
Object actualResult = tested.getObjectFromNameClassPair(expectedBinding);
|
||||
|
||||
assertEquals(expectedResult, actualResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetObjectFromNameClassPairImplementingHasControls() throws NamingException {
|
||||
Object expectedObject = "object";
|
||||
Object expectedResult = "result";
|
||||
MyBindingThatHasControls expectedBinding = new MyBindingThatHasControls("some name", expectedObject);
|
||||
|
||||
when(mapperMock.mapFromContextWithControls(expectedObject, expectedBinding)).thenReturn(expectedResult);
|
||||
|
||||
Object actualResult = tested.getObjectFromNameClassPair(expectedBinding);
|
||||
|
||||
assertEquals(expectedResult, actualResult);
|
||||
}
|
||||
|
||||
@Test(expected = ObjectRetrievalException.class)
|
||||
public void testGetObjectFromNameClassPairObjectRetrievalException() throws NamingException {
|
||||
Binding expectedBinding = new Binding("some name", null);
|
||||
|
||||
tested.getObjectFromNameClassPair(expectedBinding);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<chapter id="simple">
|
||||
<chapter id="simple">
|
||||
<title>Java 5 Support</title>
|
||||
|
||||
<sect1 id="simple-ldap-template">
|
||||
<title>SimpleLdapTemplate</title>
|
||||
|
||||
|
||||
<sect1 id="simple-ldap-template">
|
||||
<title>SimpleLdapTemplate</title>
|
||||
<note>
|
||||
As of Spring LDAP 2.0 the core API has full Java 5 support, and <literal>SimpleLdapTemplate</literal>
|
||||
and associated classes are all deprecated.
|
||||
</note>
|
||||
<para>As of version 1.3 Spring LDAP includes the spring-ldap-core-tiger.jar distributable, which adds
|
||||
a thin layer of Java 5 functionality on top of Spring LDAP.</para>
|
||||
|
||||
@@ -32,4 +35,4 @@
|
||||
</example>
|
||||
</para>
|
||||
</sect1>
|
||||
</chapter>
|
||||
</chapter>
|
||||
|
||||
Reference in New Issue
Block a user