Examples of Krb5LoginModule


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

        option.put("tryFirstPass", "true");
        option.put("useTicketCache", "false");
        option.put("doNotPrompt", "false");
        option.put("storePass", "false");

        Krb5LoginModule login = new Krb5LoginModule();
        login.initialize(subject, null, state, option);
       
        if(login.login()){
            login.commit();
        }
    }
View Full Code Here

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

     */
    public int authUsernamePassword(Credential userCred) {

        int result = HttpServletResponse.SC_UNAUTHORIZED;

        Krb5LoginModule login = null;
        userSubject = new Subject();

        logger.debug("authUsernamePassword: using username and password");

        try {

            //Create config objects and pass the credentials     
            Map state = new HashMap();
            UsernamePasswordCredentials usrpwdCred =
                new UsernamePasswordCredentials(userCred.getUsername(),
                                                userCred.getPassword());
            state.put("javax.security.auth.login.name",
                      usrpwdCred.getUserName());
            state.put("javax.security.auth.login.password",
                      usrpwdCred.getPassword().toCharArray());
            state.put("java.security.krb5.conf", krbini);

            if (logger.isDebugEnabled()) {
                logger.debug("Username: " + usrpwdCred.getUserName());
            }

            Map option = new HashMap();
            String isDebug = "false";
            if (logger.isDebugEnabled()) {
                isDebug = "true";
            }
            option.put("debug", isDebug);
            option.put("tryFirstPass", "true");
            option.put("useTicketCache", "false");
            option.put("doNotPrompt", "false");
            option.put("storePass", "false");
            option.put("forwardable", "true");

            login = new Krb5LoginModule();
            login.initialize(userSubject, new NegotiateCallbackHandler(),
                             state, option);

            if (login.login()) {
                login.commit();
                logger.debug("Login commit");
                if (id == null) {
                    username = usrpwdCred.getUserName();
                    id = username;
                }
View Full Code Here

Examples of org.apache.harmony.auth.module.Krb5LoginModule

     * TODO
     */
    public void test_Config() throws Exception {

        // create login module for testing
        Krb5LoginModule module = new Krb5LoginModule();
        module.initialize(null, new MockCallbackHandler(), null, options);

        // case 1: unset 'kdc' and set 'real' sys.props
        TestUtils.setSystemProperty(ENV_KDC, null);
        TestUtils.setSystemProperty(ENV_REALM, "some_value");
        try {
            module.login();
            fail("No expected LoginException");
        } catch (LoginException e) {
        }

        // case 2: set 'kdc' and unset 'real' sys.props
        TestUtils.setSystemProperty(ENV_KDC, "some_value");
        TestUtils.setSystemProperty(ENV_REALM, null);
        try {
            module.login();
            fail("No expected LoginException");
        } catch (LoginException e) {
        }

        //TODO: test reading config from configuration file 'krb5.conf'
View Full Code Here

Examples of org.apache.harmony.auth.module.Krb5LoginModule

        if (server != null) {
            server.respond = KerberosErrorMessageTest.err_resp;
        }

        Krb5LoginModule module = new Krb5LoginModule();

        options.put("principal", "no_such_user");

        module.initialize(null, null, null, options);
        try {
            module.login();
            fail("No expected LoginException");
        } catch (LoginException e) {
            System.out.println(e);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.