Package org.apache.harmony.auth.module

Examples of org.apache.harmony.auth.module.LdapLoginModule.initialize()


        }
        Set<Principal> principals = subject.getPrincipals();
        assertFalse("Should get at least one principal", principals.isEmpty());
        subject = new Subject();
        subject.setReadOnly();
        module.initialize(subject, new MockCallbackHandler(), null, options);
        try {
            assertFalse("Commit shouldn't be successful", module.commit());
            fail("Should throw LoginException here because of trying to clear read-only subject");
        } catch (LoginException e) {
            // expected LoginException here
View Full Code Here


     * Test method for {@link org.apache.harmony.auth.module.LdapLoginModule#initialize(javax.security.auth.Subject, javax.security.auth.callback.CallbackHandler, java.util.Map, java.util.Map)}.
     */
    public void test_initialize() {
        LdapLoginModule module = new LdapLoginModule();
        try {
            module.initialize(null, null, null, null);
            fail("Should throw NullPointerException here.");
        } catch (NullPointerException e) {
            // expected NullPointerException
        }
    }
View Full Code Here

     * Test method for {@link org.apache.harmony.auth.module.LdapLoginModule#login()}.
     */
    public void test_login() {
        LdapLoginModule module = new LdapLoginModule();
        HashMap<String, String> emptyOptions = new HashMap<String, String>();
        module.initialize(null, new MockCallbackHandler(), null, emptyOptions);
        try {
            module.login();
            fail("Should throw LoginException here.");
        } catch (LoginException e) {
            // expected LoginException
View Full Code Here

            // expected LoginException
        }

        options.put("authIdentity","cn=Manager,dc=my-domain,dc=com");
        Subject subject = new Subject();
        module.initialize(subject, new MockCallbackHandler(), null, options);
        try {
            assertTrue("Login should be successful", module.login());
        } catch (LoginException e) {
            fail("Login shouldn't fail");
        }
View Full Code Here

        try {
            assertTrue("Login should be successful", module.login());
        } catch (LoginException e) {
            fail("Login shouldn't fail");
        }
        module.initialize(subject, new FaultCallbackHandler(), null, options);
        try {
            assertFalse("Login shouldn't be successful", module.login());
            fail("Login should fail");
        } catch (LoginException e) {
            // expected Loginexception here
View Full Code Here

     */
    public void test_logout() {
        LdapLoginModule module = new LdapLoginModule();
        Subject subject = new Subject();
        options.put("authIdentity","cn=Manager,dc=my-domain,dc=com");
        module.initialize(subject, new MockCallbackHandler(), null, options);
        try {
            assertTrue("Login should be successful", module.login());
            module.commit();
        } catch (LoginException e) {
            fail("Login shouldn't fail");
View Full Code Here

    public void test_optionsAndSharedStatus() throws LoginException{
        options.put("authIdentity","cn=Manager,dc=my-domain,dc=com");
        options.put("authzIdentity","testAuthzIdentityOption");
        LdapLoginModule module = new LdapLoginModule();
        Subject subject = new Subject();
        module.initialize(subject, new MockCallbackHandler(), null, options);
        try {
            module.login();
            module.commit();
            assertTrue("Should get a principal from authzIdentity option",subject.getPrincipals().contains(new UserPrincipal("testAuthzIdentityOption")));
        }
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.