@Test public void shouldFailNoFileOptionProvided() throws Exception { context.checking(new Expectations() { { oneOf(configuration).getAppConfigurationEntry(REALM_NAME); final String fileLoginModuleName = "org.kaazing.gateway.security.auth.FileLoginModule"; final HashMap<String, Object> fileOptions = new HashMap<>(); final AppConfigurationEntry fileEntry = new AppConfigurationEntry(fileLoginModuleName, REQUIRED, fileOptions); will(returnValue(new AppConfigurationEntry[]{fileEntry})); } }); Subject subject = new Subject(); DispatchCallbackHandler handler = new DispatchCallbackHandler(); DefaultLoginResult loginResult = new DefaultLoginResult(); handler.register(LoginResultCallback.class, new LoginResultCallbackHandler(loginResult)); LoginContext loginContext = new ResultAwareLoginContext("demo", subject, handler, configuration, loginResult); context.assertIsSatisfied(); assertNotNull(loginContext); thrown.expect(LoginException.class); loginContext.login(); }
@Override public boolean login() throws LoginException { switch (state) { case INITIALIZE_COMPLETE: return login0(); case LOGIN_COMPLETE: return login0(); case COMMIT_COMPLETE: return true; case INITIALIZE_REQUIRED: default: throw new LoginException("Login module is not initialized"); } }
FileLoginModule implements LoginModule { @Override public boolean login() throws LoginException { switch (state) { case INITIALIZE_COMPLETE: return login0(); case LOGIN_COMPLETE: return login0(); case COMMIT_COMPLETE: return true; case INITIALIZE_REQUIRED: default: throw new LoginException("Login module is not initialized"); } } }
FileLoginModule implements LoginModule { @Override public boolean login() throws LoginException { switch (state) { case INITIALIZE_COMPLETE: return login0(); case LOGIN_COMPLETE: return login0(); case COMMIT_COMPLETE: return true; case INITIALIZE_REQUIRED: default: throw new LoginException("Login module is not initialized"); } } FileLoginModule(); }
FileLoginModule implements LoginModule { @Override public boolean login() throws LoginException { switch (state) { case INITIALIZE_COMPLETE: return login0(); case LOGIN_COMPLETE: return login0(); case COMMIT_COMPLETE: return true; case INITIALIZE_REQUIRED: default: throw new LoginException("Login module is not initialized"); } } FileLoginModule(); @Override void initialize(Subject subject, CallbackHandler callback,
                           Map<String, ?> sharedState, Map<String, ?> options); @Override boolean login(); @Override boolean logout(); @Override boolean commit(); @Override boolean abort(); }
FileLoginModule implements LoginModule { @Override public boolean login() throws LoginException { switch (state) { case INITIALIZE_COMPLETE: return login0(); case LOGIN_COMPLETE: return login0(); case COMMIT_COMPLETE: return true; case INITIALIZE_REQUIRED: default: throw new LoginException("Login module is not initialized"); } } FileLoginModule(); @Override void initialize(Subject subject, CallbackHandler callback,
                           Map<String, ?> sharedState, Map<String, ?> options); @Override boolean login(); @Override boolean logout(); @Override boolean commit(); @Override boolean abort(); static final String CLASS_NAME; static final Logger LOG; }