Package javax.security.auth.login

Examples of javax.security.auth.login.LoginContext.logout()


                    // Ignore
                }
            }
            if (lc != null) {
                try {
                    lc.logout();
                } catch (LoginException e) {
                    // Ignore
                }
            }
        }
View Full Code Here


                    boolean debug = log.isDebugEnabled();
                    if (loginContext != null) {
                        if (debug) {
                            log.debug("Logging principal: [" + token.getPrincipal() + "] out of LoginContext");
                        }
                        loginContext.logout();
                    } else if (debug) {
                        log.debug("Cannot logout principal: [" + token.getPrincipal() + "] from LoginContext. "
                                + "The LoginContext is unavailable");
                    }
                } catch (LoginException e) {
View Full Code Here

    context.login();
    Subject subject = context.getSubject();
    ParticipantPrincipal p = subject.getPrincipals(ParticipantPrincipal.class).iterator().next();
    assertEquals("haspwd@example.com", p.getName());

    context.logout();
    assertEquals(0, subject.getPrincipals(ParticipantPrincipal.class).size());
  }

  public void testMissingDomainIsAddedAutomatically() throws Exception {
    LoginContext context = makeLoginContext("haspwd", "pwd");
View Full Code Here

                + " isn't a valid user address.");
      }

      if (loggedInAddress == null) {
        try {
          context.logout();
        } catch (LoginException e) {
          // Logout failed. Absorb the error, since we're about to throw an
          // illegal state exception anyway.
        }
View Full Code Here

        NamedUsernamePasswordCredential namedupc = (NamedUsernamePasswordCredential) subject.getPrivateCredentials().toArray()[0];
        assertEquals("Credential name", "cred1", namedupc.getName());
        assertEquals("Username", "name1", namedupc.getUsername());
        assertEquals("Password", "pwd1", new String(namedupc.getPassword()));

        context.logout();

        assertEquals("Private credentials upon logout", 0, subject.getPrivateCredentials().size());
        assertTrue("id of server subject should be null", ContextManager.getSubjectId(subject) == null);
    }
View Full Code Here

        assertTrue("expected non-null subject", subject != null);

        subject.setReadOnly();

        try {
            context.logout();
        } catch(Exception e) {
            fail("logout failed");
        }
        NamedUsernamePasswordCredential namedupc = (NamedUsernamePasswordCredential) subject.getPrivateCredentials().toArray()[0];
        assertTrue("credential should have been destroyed", namedupc.isDestroyed());
View Full Code Here

            assertTrue("expected non-null subject", subject != null);
            assertTrue("id of subject should be null", ContextManager.getSubjectId(subject) == null);
            assertEquals("subject should have one principal", 1, subject.getPrincipals().size());
            assertEquals("subject should have no realm principal", 0, subject.getPrincipals(RealmPrincipal.class).size());

            context.logout();
        } catch (LoginException e) {
            e.printStackTrace();
            // May not have kerberos
        }
    }
View Full Code Here

        assertTrue("expected non-null subject", subject != null);
        assertEquals("Remote principals", 0, subject.getPrincipals(IdentificationPrincipal.class).size());
        assertEquals("Principals", 2, subject.getPrincipals().size());

        context.logout();
        assertEquals("Principals upon logout", 0, subject.getPrincipals().size());
        assertTrue("id of server subject should be null", ContextManager.getSubjectId(subject) == null);
    }
View Full Code Here

        context.login();
        Subject subject = context.getSubject();
        assertTrue("expected non-null subject", subject != null);
        assertEquals("Principals added upon failed login", 0, subject.getPrincipals().size());
        context.logout();
    }

    public void testLogoutWithReadOnlySubject() throws Exception {
        LoginContext context = new LoginContext(SIMPLE_REALM, new UsernamePasswordCallback("alan", "starcraft"));
View Full Code Here

        assertTrue("expected non-null subject", subject != null);

        subject.setReadOnly();

        try {
            context.logout();
        } catch(Exception e) {
            fail("logout failed");
        }
    }
}
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.