Examples of LoginModule


Examples of javax.security.auth.spi.LoginModule

    {
        try
        {
            // Log in with a user that isn't in the database
            CallbackHandler handler = new WikiCallbackHandler( m_engine, null, "user", "password" );
            LoginModule module = new UserDatabaseLoginModule();
            module.initialize( m_subject, handler,
                              new HashMap<String, Object>(),
                              new HashMap<String, Object>() );
            module.login();
            module.commit();
            Set principals = m_subject.getPrincipals();
            assertEquals( 1, principals.size() );
            assertTrue( principals.contains( new WikiPrincipal( "user", WikiPrincipal.LOGIN_NAME ) ) );
            assertFalse( principals.contains( Role.AUTHENTICATED ) );
            assertFalse( principals.contains( Role.ALL ) );
           
            // Login with a user that IS in the database
            m_subject = new Subject();
            handler = new WikiCallbackHandler( m_engine, null, "janne", "myP@5sw0rd" );
            module = new UserDatabaseLoginModule();
            module.initialize( m_subject, handler,
                              new HashMap<String, Object>(),
                              new HashMap<String, Object>() );
            module.login();
            module.commit();
            principals = m_subject.getPrincipals();
            assertEquals( 1, principals.size() );
            assertTrue( principals.contains( new WikiPrincipal( "janne", WikiPrincipal.LOGIN_NAME ) ) );
            assertFalse( principals.contains( Role.AUTHENTICATED ) );
            assertFalse( principals.contains( Role.ALL ) );           
View Full Code Here

Examples of javax.security.auth.spi.LoginModule

    public final void testLogout()
    {
        try
        {
            CallbackHandler handler = new WikiCallbackHandler( m_engine, null, "user", "password" );
            LoginModule module = new UserDatabaseLoginModule();
            module.initialize( m_subject, handler,
                              new HashMap<String, Object>(),
                              new HashMap<String, Object>() );
            module.login();
            module.commit();
            Set principals = m_subject.getPrincipals();
            assertEquals( 1, principals.size() );
            assertTrue( principals.contains( new WikiPrincipal( "user",  WikiPrincipal.LOGIN_NAME ) ) );
            assertFalse( principals.contains( Role.AUTHENTICATED ) );
            assertFalse( principals.contains( Role.ALL ) );
            module.logout();
            assertEquals( 0, principals.size() );
        }
        catch( LoginException e )
        {
            System.err.println( e.getMessage() );
View Full Code Here

Examples of javax.security.auth.spi.LoginModule

            // Test using Cookie and IP address (AnonymousLoginModule succeeds)
            Cookie cookie = new Cookie( CookieAssertionLoginModule.PREFS_COOKIE_NAME, "Bullwinkle" );
            request.setCookies( new Cookie[] { cookie } );
            m_subject = new Subject();
            CallbackHandler handler = new WebContainerCallbackHandler( m_engine, request );
            LoginModule module = new CookieAssertionLoginModule();
            module.initialize( m_subject, handler,
                              new HashMap<String, Object>(),
                              new HashMap<String, Object>() );
            module.login();
            module.commit();
            Set principals = m_subject.getPrincipals();
            assertEquals( 1, principals.size() );
            assertTrue( principals.contains( new WikiPrincipal( "Bullwinkle" ) ) );
            assertFalse( principals.contains( Role.ASSERTED ) );
            assertFalse( principals.contains( Role.ALL ) );
View Full Code Here

Examples of org.apache.geronimo.jee.loginconfig.LoginModule

      .getAttributeOrXmlAttributeOrReference();
    for (JAXBElement<?> ele : elelist) {
        if (XmlAttributeType.class.isInstance(ele.getValue())
          && ((XmlAttributeType) ele.getValue()).getName()
            .equals("LoginModuleConfiguration")) {
      LoginModule loginModule = (LoginModule) ((LoginConfig) ((XmlAttributeType) ele
        .getValue()).getAny())
        .getLoginModuleRefOrLoginModule().get(0);
      return loginModule.getLoginModuleClass();
        }
    }
    return null;
      } catch (NullPointerException e) {
    // ignore
View Full Code Here

Examples of org.nxplanner.security.LoginModule

            HttpServletRequest request, HttpServletResponse reply)
            throws ServletException {
        PersonEditorForm personForm = (PersonEditorForm)actionForm;
        String newPassword = personForm.getNewPassword();
        if (StringUtils.isNotEmpty(newPassword)) {
            LoginModule loginModule = AuthenticatorImpl.getLoginModule(request);
            if (loginModule != null) {
                try {
                    loginModule.changePassword(personForm.getUserId(), personForm.getNewPassword());
                } catch (AuthenticationException e) {
                    throw new ServletException(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.