/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @author Vincent Ryan
* @bug 4814522
* @summary Check that an LdapLoginModule can be initialized using various
* JAAS configurations.
* (LdapLoginModule replaces the JndiLoginModule for LDAP access)
*
* Run this test twice, once using the default security manager:
*
*/
public class CheckConfigs {
? "[security manager is not running]"
: "[security manager is running: " +
init();
}
}
// search-first mode
try {
throw new SecurityException("expected a LoginException");
} catch (LoginException le) {
// expected behaviour (because no LDAP server is available)
throw le;
}
}
// authentication-first mode
try {
throw new SecurityException("expected a LoginException");
} catch (LoginException le) {
// expected behaviour (because no LDAP server is available)
throw le;
}
}
// authentication-only mode
try {
throw new SecurityException("expected a LoginException");
} catch (LoginException le) {
// expected behaviour (because no LDAP server is available)
throw le;
}
}
}
throws IOException, UnsupportedCallbackException {
if (callbacks[i] instanceof NameCallback) {
} else if (callbacks[i] instanceof PasswordCallback) {
((PasswordCallback)callbacks[i])
} else {
throw new UnsupportedCallbackException
(callbacks[i], "Unrecognized callback");
}
}
}
}
}
// The JAAS configuration name for ldap-based authentication
// The JAAS configuration for ldap-based authentication
// The classname of the login module for ldap-based authentication
LdapLoginModule.class.getName();
/**
* Gets the JAAS configuration for ldap-based authentication
*/
}
/**
* Refreshes the configuration.
*/
public void refresh() {
// the configuration is fixed
}
}
/**
* This class defines the JAAS configuration for ldap-based authentication.
* It is equivalent to the following textual configuration entry:
* <pre>
* TestAuth {
* com.sun.security.auth.module.LdapLoginModule REQUIRED
* userProvider="ldap://localhost:23456/dc=example,dc=com"
* userFilter="(&(uid={USERNAME})(objectClass=inetOrgPerson))"
* authzIdentity="{EMPLOYEENUMBER}"
* debug=true;
* };
* </pre>
*/
public SearchFirstMode() {
super();
"(&(uid={USERNAME})(objectClass=inetOrgPerson))");
entries = new AppConfigurationEntry[] {
};
}
}
/**
* This class defines the JAAS configuration for ldap-based authentication.
* It is equivalent to the following textual configuration entry:
* <pre>
* TestAuth {
* com.sun.security.auth.module.LdapLoginModule REQUIRED
* userProvider="ldap://localhost:23456/dc=example,dc=com"
* authIdentity="{USERNAME}"
* userFilter="(&(|(samAccountName={USERNAME})(userPrincipalName={USERNAME})(cn={USERNAME}))(objectClass=user))"
* useSSL=false
* debug=true;
* };
* </pre>
*/
public AuthFirstMode() {
super();
"(&(|(samAccountName={USERNAME})(userPrincipalName={USERNAME})" +
"(cn={USERNAME}))(objectClass=user))");
entries = new AppConfigurationEntry[] {
};
}
}
/**
* This class defines the JAAS configuration for ldap-based authentication.
* It is equivalent to the following textual configuration entry:
* <pre>
* TestAuth {
* com.sun.security.auth.module.LdapLoginModule REQUIRED
* userProvider="ldap://localhost:23456 ldap://localhost:23457"
* authIdentity="cn={USERNAME},ou=people,dc=example,dc=com"
* authzIdentity="staff"
* debug=true;
* };
* </pre>
*/
public AuthOnlyMode() {
super();
"ldap://localhost:23456 ldap://localhost:23457");
"cn={USERNAME},ou=people,dc=example,dc=com");
entries = new AppConfigurationEntry[] {
};
}
}