Package com.sun.security.auth.module

Examples of com.sun.security.auth.module.LdapLoginModule


    private static void testInvalidOptions() throws Exception {

        // empty set of options

        LdapLoginModule ldap = new LdapLoginModule();
        Subject subject = new Subject();
        ldap.initialize(subject, null, null, Collections.EMPTY_MAP);

        try {
            ldap.login();
            throw new SecurityException("expected a LoginException");

        } catch (LoginException le) {
            // expected behaviour
            System.out.println("Caught a LoginException, as expected");
        }

        // bad value for userProvider option

        Map<String, String> options = new HashMap<String, String>();
        options.put(USER_PROVIDER_OPTION, "ldap://localhost:23456");
        ldap.initialize(subject, null, null, options);

        try {
            ldap.login();
            throw new SecurityException("expected a LoginException");

        } catch (LoginException le) {
            // expected behaviour
            System.out.println("Caught a LoginException, as expected");
View Full Code Here


    private static void testNullCallbackHandler() throws Exception {

        // empty set of options

        LdapLoginModule ldap = new LdapLoginModule();
        Subject subject = new Subject();
        Map<String, String> options = new HashMap<String, String>();
        ldap.initialize(subject, null, null, options);

        try {
            ldap.login();
            throw new SecurityException("expected LoginException");

        } catch (LoginException le) {
            // expected behaviour
            System.out.println("Caught a LoginException, as expected");
View Full Code Here

        }
    }

    private static void testWithCallbackHandler() throws Exception {

        LdapLoginModule ldap = new LdapLoginModule();
        Subject subject = new Subject();
        Map<String, String> options = new HashMap<String, String>();

        CallbackHandler goodHandler = new MyCallbackHandler(true);
        ldap.initialize(subject, goodHandler, null, options);

        try {
            ldap.login();
            throw new SecurityException("expected LoginException");

        } catch (LoginException le) {
            // expected behaviour
            System.out.println("Caught a LoginException, as expected");
        }

        CallbackHandler badHandler = new MyCallbackHandler(false);
        ldap.initialize(subject, badHandler, null, options);

        try {
            ldap.login();
            throw new SecurityException("expected LoginException");

        } catch (LoginException le) {
            // expected behaviour
            System.out.println("Caught a LoginException, as expected");
View Full Code Here

TOP

Related Classes of com.sun.security.auth.module.LdapLoginModule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.