Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SHIRO-807] remove deprecated method signature #272

Merged
merged 1 commit into from
Jan 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -205,25 +205,6 @@ public LdapContext getSystemLdapContext() throws NamingException {
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>");
Expand Down Expand Up @@ -314,4 +295,4 @@ private void validateAuthenticationInfo(Hashtable<String, Object> environment)
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -399,23 +399,7 @@ public String getSystemUsername() {
* @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());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,6 @@ public interface LdapContextFactory {
*/
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ public void testGetLdapContext() throws NamingException {
//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");
}


Expand All @@ -76,25 +76,25 @@ public void testGetLdapContextWithoutUrl() throws NamingException {
@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);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void testGetLdapContext() throws NamingException {
//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
Expand Down Expand Up @@ -105,7 +105,7 @@ public void testCustomEnvironment() {

@Test(expected = IllegalStateException.class)
public void testGetLdapContextWithoutUrl() throws NamingException {
factory.getLdapContext((Object) "foo", "bar");
factory.getLdapContext("foo", "bar");
}

@Test
Expand All @@ -123,7 +123,7 @@ protected LdapContext createLdapContext(Hashtable env) throws NamingException {
};

factory.setUrl("ldap://localhost:389");
factory.getLdapContext((Object) "foo", "bar");
factory.getLdapContext("foo", "bar");
}

@SuppressWarnings({"deprecation"})
Expand Down Expand Up @@ -189,25 +189,25 @@ protected LdapContext createLdapContext(Hashtable env) throws NamingException {
@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);
}


Expand Down