@Test public void testBasicAuthCustomLoginModuleLoginSuccess() throws Exception { AuthenticationToken s = new DefaultAuthenticationToken("joe:welcome"); context.checking(new Expectations() { { oneOf(configuration).getAppConfigurationEntry(REALM_NAME); final String loginModuleName = "org.kaazing.gateway.security.auth.SimpleTestLoginModule"; final HashMap<String, Object> options = new HashMap<>(); final AppConfigurationEntry entry = new AppConfigurationEntry(loginModuleName, REQUIRED, options); will(returnValue(new AppConfigurationEntry[]{entry})); } }); final TypedCallbackHandlerMap additionalCallbacks = new TypedCallbackHandlerMap(); additionalCallbacks.put(AuthenticationTokenCallback.class, new AuthenticationTokenCallbackHandler(s)); LoginContext loginContext = factory.createLoginContext(additionalCallbacks); context.assertIsSatisfied(); assertNotNull(loginContext); loginContext.login(); }
@Override public LoginContext createLoginContext(TypedCallbackHandlerMap additionalCallbacks) throws LoginException { try { final DefaultLoginResult loginResult = new DefaultLoginResult(); DispatchCallbackHandler handler = createDefaultCallbackHandler(loginResult, additionalCallbacks); defineAuthenticationTokenScheme(additionalCallbacks); return createLoginContext(handler, loginResult); } catch (Exception e) { final String msg = String.format("%s", ERROR_MSG); if (logEnabled()) { LOG.trace(msg, e); } throw (LoginException) new LoginException(msg).initCause(e); } }
DefaultLoginContextFactory implements LoginContextFactory { @Override public LoginContext createLoginContext(TypedCallbackHandlerMap additionalCallbacks) throws LoginException { try { final DefaultLoginResult loginResult = new DefaultLoginResult(); DispatchCallbackHandler handler = createDefaultCallbackHandler(loginResult, additionalCallbacks); defineAuthenticationTokenScheme(additionalCallbacks); return createLoginContext(handler, loginResult); } catch (Exception e) { final String msg = String.format("%s", ERROR_MSG); if (logEnabled()) { LOG.trace(msg, e); } throw (LoginException) new LoginException(msg).initCause(e); } } }
DefaultLoginContextFactory implements LoginContextFactory { @Override public LoginContext createLoginContext(TypedCallbackHandlerMap additionalCallbacks) throws LoginException { try { final DefaultLoginResult loginResult = new DefaultLoginResult(); DispatchCallbackHandler handler = createDefaultCallbackHandler(loginResult, additionalCallbacks); defineAuthenticationTokenScheme(additionalCallbacks); return createLoginContext(handler, loginResult); } catch (Exception e) { final String msg = String.format("%s", ERROR_MSG); if (logEnabled()) { LOG.trace(msg, e); } throw (LoginException) new LoginException(msg).initCause(e); } } DefaultLoginContextFactory(String name,
                                      Configuration configuration); }
DefaultLoginContextFactory implements LoginContextFactory { @Override public LoginContext createLoginContext(TypedCallbackHandlerMap additionalCallbacks) throws LoginException { try { final DefaultLoginResult loginResult = new DefaultLoginResult(); DispatchCallbackHandler handler = createDefaultCallbackHandler(loginResult, additionalCallbacks); defineAuthenticationTokenScheme(additionalCallbacks); return createLoginContext(handler, loginResult); } catch (Exception e) { final String msg = String.format("%s", ERROR_MSG); if (logEnabled()) { LOG.trace(msg, e); } throw (LoginException) new LoginException(msg).initCause(e); } } DefaultLoginContextFactory(String name,
                                      Configuration configuration); String getName(); Configuration getConfiguration(); @Override LoginContext createLoginContext(TypedCallbackHandlerMap additionalCallbacks); @Override LoginContext createLoginContext(Subject subject, final String username, final char[] password); }
DefaultLoginContextFactory implements LoginContextFactory { @Override public LoginContext createLoginContext(TypedCallbackHandlerMap additionalCallbacks) throws LoginException { try { final DefaultLoginResult loginResult = new DefaultLoginResult(); DispatchCallbackHandler handler = createDefaultCallbackHandler(loginResult, additionalCallbacks); defineAuthenticationTokenScheme(additionalCallbacks); return createLoginContext(handler, loginResult); } catch (Exception e) { final String msg = String.format("%s", ERROR_MSG); if (logEnabled()) { LOG.trace(msg, e); } throw (LoginException) new LoginException(msg).initCause(e); } } DefaultLoginContextFactory(String name,
                                      Configuration configuration); String getName(); Configuration getConfiguration(); @Override LoginContext createLoginContext(TypedCallbackHandlerMap additionalCallbacks); @Override LoginContext createLoginContext(Subject subject, final String username, final char[] password);  }