[SHIRO-807] remove deprecated method signature
- remove `public LdapContext getLdapContext(String username, String password)`
- remove now redundant casts
diff --git a/core/src/main/java/org/apache/shiro/realm/ldap/DefaultLdapContextFactory.java b/core/src/main/java/org/apache/shiro/realm/ldap/DefaultLdapContextFactory.java
index db2b72c..8b8f4d5 100644
--- a/core/src/main/java/org/apache/shiro/realm/ldap/DefaultLdapContextFactory.java
+++ b/core/src/main/java/org/apache/shiro/realm/ldap/DefaultLdapContextFactory.java
@@ -205,25 +205,6 @@
return getLdapContext(systemUsername, systemPassword);
}
- /**
- * Deprecated - use {@link #getLdapContext(Object, Object)} instead. This will be removed before Apache Shiro 2.0.
- *
- * @param username the username to use when creating the connection.
- * @param password the password to use when creating the connection.
- * @return a {@code LdapContext} bound using the given username and password.
- * @throws javax.naming.NamingException if there is an error creating the context.
- * @deprecated the {@link #getLdapContext(Object, Object)} method should be used in all cases to ensure more than
- * String principals and credentials can be used. Shiro no longer calls this method - it will be
- * removed before the 2.0 release.
- */
- @Deprecated
- public LdapContext getLdapContext(String username, String password) throws NamingException {
- if (username != null && principalSuffix != null) {
- username += principalSuffix;
- }
- return getLdapContext((Object) username, password);
- }
-
public LdapContext getLdapContext(Object principal, Object credentials) throws NamingException {
if (url == null) {
throw new IllegalStateException("An LDAP URL must be specified of the form ldap://<hostname>:<port>");
@@ -314,4 +295,4 @@
}
}
-}
\ No newline at end of file
+}
diff --git a/core/src/main/java/org/apache/shiro/realm/ldap/JndiLdapContextFactory.java b/core/src/main/java/org/apache/shiro/realm/ldap/JndiLdapContextFactory.java
index 548057e..b1b22d8 100644
--- a/core/src/main/java/org/apache/shiro/realm/ldap/JndiLdapContextFactory.java
+++ b/core/src/main/java/org/apache/shiro/realm/ldap/JndiLdapContextFactory.java
@@ -399,23 +399,7 @@
* @throws NamingException if there is a problem connecting to the LDAP directory
*/
public LdapContext getSystemLdapContext() throws NamingException {
- return getLdapContext((Object)getSystemUsername(), getSystemPassword());
- }
-
- /**
- * Deprecated - use {@link #getLdapContext(Object, Object)} instead. This will be removed before Apache Shiro 2.0.
- *
- * @param username the username to use when creating the connection.
- * @param password the password to use when creating the connection.
- * @return a {@code LdapContext} bound using the given username and password.
- * @throws javax.naming.NamingException if there is an error creating the context.
- * @deprecated the {@link #getLdapContext(Object, Object)} method should be used in all cases to ensure more than
- * String principals and credentials can be used. Shiro no longer calls this method - it will be
- * removed before the 2.0 release.
- */
- @Deprecated
- public LdapContext getLdapContext(String username, String password) throws NamingException {
- return getLdapContext((Object) username, password);
+ return getLdapContext(getSystemUsername(), getSystemPassword());
}
/**
diff --git a/core/src/main/java/org/apache/shiro/realm/ldap/LdapContextFactory.java b/core/src/main/java/org/apache/shiro/realm/ldap/LdapContextFactory.java
index 0cc90fe..373bff7 100644
--- a/core/src/main/java/org/apache/shiro/realm/ldap/LdapContextFactory.java
+++ b/core/src/main/java/org/apache/shiro/realm/ldap/LdapContextFactory.java
@@ -40,20 +40,6 @@
LdapContext getSystemLdapContext() throws NamingException;
/**
- * Creates (or retrieves from a pool) a {@code LdapContext} connection bound using the username and password
- * specified.
- *
- * @param username the username to use when creating the connection.
- * @param password the password to use when creating the connection.
- * @return a {@code LdapContext} bound using the given username and password.
- * @throws javax.naming.NamingException if there is an error creating the context.
- * @deprecated the {@link #getLdapContext(Object, Object)} method should be used in all cases to ensure more than
- * String principals and credentials can be used.
- */
- @Deprecated
- LdapContext getLdapContext(String username, String password) throws NamingException;
-
- /**
* Creates (or retrieves from a pool) an {@code LdapContext} connection bound using the specified principal and
* credentials. The format of the principal and credentials are whatever is supported by the underlying
* LDAP {@link javax.naming.spi.InitialContextFactory InitialContextFactory} implementation. The default Sun
diff --git a/core/src/test/java/org/apache/shiro/realm/ldap/DefaultLdapContextFactoryTest.java b/core/src/test/java/org/apache/shiro/realm/ldap/DefaultLdapContextFactoryTest.java
index 9a52a3b..b383fb7 100644
--- a/core/src/test/java/org/apache/shiro/realm/ldap/DefaultLdapContextFactoryTest.java
+++ b/core/src/test/java/org/apache/shiro/realm/ldap/DefaultLdapContextFactoryTest.java
@@ -61,12 +61,12 @@
//garbage URL to test that the context is being created, but fails:
String brokenHost = UUID.randomUUID().toString();
factory.setUrl("ldap://" + brokenHost + ":389");
- factory.getLdapContext((Object) "foo", "bar");
+ factory.getLdapContext("foo", "bar");
}
@Test(expected = IllegalStateException.class)
public void testGetLdapContextWithoutUrl() throws NamingException {
- factory.getLdapContext((Object) "foo", "bar");
+ factory.getLdapContext("foo", "bar");
}
@@ -76,25 +76,25 @@
@Test(expected = AuthenticationException.class)
public void testEmptyStringCredentials() throws NamingException {
factory.setUrl("ldap://localhost:389");
- factory.getLdapContext((Object)"jcoder", "");
+ factory.getLdapContext("jcoder", "");
}
@Test(expected = AuthenticationException.class)
public void testEmptyCharArrayCredentials() throws NamingException {
factory.setUrl("ldap://localhost:389");
- factory.getLdapContext((Object)"jcoder", new char[0]);
+ factory.getLdapContext("jcoder", new char[0]);
}
@Test(expected = AuthenticationException.class)
public void testEmptyByteArrayCredentials() throws NamingException {
factory.setUrl("ldap://localhost:389");
- factory.getLdapContext((Object)"jcoder", new byte[0]);
+ factory.getLdapContext("jcoder", new byte[0]);
}
@Test(expected = AuthenticationException.class)
public void testEmptyNullCredentials() throws NamingException {
factory.setUrl("ldap://localhost:389");
- factory.getLdapContext((Object)"jcoder", null);
+ factory.getLdapContext("jcoder", null);
}
diff --git a/core/src/test/java/org/apache/shiro/realm/ldap/JndiLdapContextFactoryTest.java b/core/src/test/java/org/apache/shiro/realm/ldap/JndiLdapContextFactoryTest.java
index 87ce184..a1e0ee7 100644
--- a/core/src/test/java/org/apache/shiro/realm/ldap/JndiLdapContextFactoryTest.java
+++ b/core/src/test/java/org/apache/shiro/realm/ldap/JndiLdapContextFactoryTest.java
@@ -66,7 +66,7 @@
//garbage URL to test that the context is being created, but fails:
String brokenHost = UUID.randomUUID().toString();
factory.setUrl("ldap://" + brokenHost + ":389");
- factory.getLdapContext((Object) "foo", "bar");
+ factory.getLdapContext("foo", "bar");
}
@Test
@@ -105,7 +105,7 @@
@Test(expected = IllegalStateException.class)
public void testGetLdapContextWithoutUrl() throws NamingException {
- factory.getLdapContext((Object) "foo", "bar");
+ factory.getLdapContext("foo", "bar");
}
@Test
@@ -123,7 +123,7 @@
};
factory.setUrl("ldap://localhost:389");
- factory.getLdapContext((Object) "foo", "bar");
+ factory.getLdapContext("foo", "bar");
}
@SuppressWarnings({"deprecation"})
@@ -189,25 +189,25 @@
@Test(expected = AuthenticationException.class)
public void testEmptyStringCredentials() throws NamingException {
factory.setUrl("ldap://localhost:389");
- factory.getLdapContext((Object)"jcoder", "");
+ factory.getLdapContext("jcoder", "");
}
@Test(expected = AuthenticationException.class)
public void testEmptyCharArrayCredentials() throws NamingException {
factory.setUrl("ldap://localhost:389");
- factory.getLdapContext((Object)"jcoder", new char[0]);
+ factory.getLdapContext("jcoder", new char[0]);
}
@Test(expected = AuthenticationException.class)
public void testEmptyByteArrayCredentials() throws NamingException {
factory.setUrl("ldap://localhost:389");
- factory.getLdapContext((Object)"jcoder", new byte[0]);
+ factory.getLdapContext("jcoder", new byte[0]);
}
@Test(expected = AuthenticationException.class)
public void testEmptyNullCredentials() throws NamingException {
factory.setUrl("ldap://localhost:389");
- factory.getLdapContext((Object)"jcoder", null);
+ factory.getLdapContext("jcoder", null);
}