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); }
@Test(expected = IllegalStateException.class) public void testGetLdapContextWithoutUrl() throws NamingException { factory.getLdapContext((Object) "foo", "bar"); }
@Test(expected = AuthenticationException.class) public void testEmptyByteArrayCredentials() throws NamingException { factory.setUrl("ldap://localhost:389"); factory.getLdapContext((Object)"jcoder", new byte[0]); }
@Test(expected = AuthenticationException.class) public void testEmptyNullCredentials() throws NamingException { factory.setUrl("ldap://localhost:389"); factory.getLdapContext((Object)"jcoder", null); }
/** * This is the only test that does not fake the JNDI environment. It is provided for 100% test coverage. * * @throws javax.naming.NamingException thrown because the host is always broken. */ @Test(expected = NamingException.class) public void testGetLdapContext() throws NamingException { factory = new DefaultLdapContextFactory(); //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"); }
@Test(expected = AuthenticationException.class) public void testEmptyStringCredentials() throws NamingException { factory.setUrl("ldap://localhost:389"); factory.getLdapContext((Object)"jcoder", ""); }
@Test(expected = AuthenticationException.class) public void testEmptyCharArrayCredentials() throws NamingException { factory.setUrl("ldap://localhost:389"); factory.getLdapContext((Object)"jcoder", new char[0]); }
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 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); }