protected void postAuthenticate(Authenticator activeAuthenticator) { activeAuthenticator.postAuthenticate(); if (!activeAuthenticator.getStatus().equals(AuthenticationStatus.SUCCESS)) { return; } beanManager.fireEvent(new PostAuthenticateEvent()); }
private Authenticator getAuthenticator() throws AuthenticationException { Authenticator authenticator = authenticatorInstance.isUnsatisfied() ? idmAuthenticatorInstance.get() : authenticatorInstance.get(); if (authenticator == null) { throw new AuthenticationException("No Authenticator has been configured."); } return authenticator; }
beanManager.fireEvent(new PreAuthenticateEvent()); Authenticator activeAuthenticator = authenticatorSelector.getSelectedAuthenticator(); throw new AuthenticationException("No Authenticator has been configured."); activeAuthenticator.authenticate(); if (activeAuthenticator.getStatus() == null) throw new AuthenticationException("Authenticator must return a valid authentication status"); if (activeAuthenticator.getStatus() == AuthenticationStatus.SUCCESS) this.user = activeAuthenticator.getUser(); return true; throw new AuthenticationException("Authentication failed.", ex);
protected Account authenticate() throws AuthenticationException { Account validatedAccount = null; if (authenticating) { authenticating = false; //X TODO discuss it throw new IllegalStateException("Authentication already in progress."); } try { authenticating = true; eventBridge.fireEvent(new PreAuthenticateEvent()); Authenticator authenticator = getAuthenticator(); if (AUTHENTICATION_LOGGER.isDebugEnabled()) { AUTHENTICATION_LOGGER.debugf("Authentication is going to be performed by authenticator [%s]", authenticator); } authenticator.authenticate(); if (authenticator.getStatus() == null) { throw new AuthenticationException("Authenticator must return a valid authentication status"); } if (authenticator.getStatus() == Authenticator.AuthenticationStatus.SUCCESS) { validatedAccount = authenticator.getAccount(); postAuthenticate(authenticator); } } catch (AuthenticationException e) { throw e; } catch (Throwable ex) { throw new AuthenticationException("Authentication failed.", ex); } finally { authenticating = false; } return validatedAccount; }
protected void postAuthenticate(Authenticator authenticator) { authenticator.postAuthenticate(); if (!authenticator.getStatus().equals(Authenticator.AuthenticationStatus.SUCCESS)) { return; } eventBridge.fireEvent(new PostAuthenticateEvent()); }
private Authenticator getAuthenticator() throws AuthenticationException { Authenticator authenticator = authenticatorInstance.isUnsatisfied() ? idmAuthenticatorInstance.get() : authenticatorInstance.get(); if (authenticator == null) { throw new AuthenticationException("No Authenticator has been configured."); } return authenticator; }
protected void postAuthenticate(Authenticator authenticator) { authenticator.postAuthenticate(); if (!authenticator.getStatus().equals(Authenticator.AuthenticationStatus.SUCCESS)) { return; } eventBridge.fireEvent(new PostAuthenticateEvent()); }
private Authenticator getAuthenticator() throws AuthenticationException { Authenticator authenticator = authenticatorInstance.isUnsatisfied() ? idmAuthenticatorInstance.get() : authenticatorInstance.get(); if (authenticator == null) { throw new AuthenticationException("No Authenticator has been configured."); } return authenticator; }
protected void postAuthenticate(Authenticator authenticator) { authenticator.postAuthenticate(); if (!authenticator.getStatus().equals(Authenticator.AuthenticationStatus.SUCCESS)) { return; } eventBridge.fireEvent(new PostAuthenticateEvent()); }
/** * <p>Writes the <code>issuedToken</code> to the {@link javax.servlet.http.HttpServletResponse}.</p> * * @param issuedToken * @param request * @param response */ protected void writeToken(String issuedToken, HttpServletRequest request, HttpServletResponse response) { try { response.setStatus(HttpServletResponse.SC_OK); PrintWriter writer = response.getWriter(); writer.print("{\"authctoken\":\"" + issuedToken + "\"}"); writer.flush(); } catch (Exception e) { throw new AuthenticationException("Could not write token to response.", e); } }
/** * <p>Writes the <code>issuedToken</code> to the {@link javax.servlet.http.HttpServletResponse}.</p> * * @param issuedToken * @param request * @param response */ protected void writeToken(String issuedToken, HttpServletRequest request, HttpServletResponse response) { try { response.setStatus(HttpServletResponse.SC_OK); PrintWriter writer = response.getWriter(); writer.print("{\"authctoken\":\"" + issuedToken + "\"}"); writer.flush(); } catch (Exception e) { throw new AuthenticationException("Could not write token to response.", e); } }
/** * <p>Writes the <code>issuedToken</code> to the {@link javax.servlet.http.HttpServletResponse}.</p> * * @param issuedToken * @param request * @param response */ protected void writeToken(String issuedToken, HttpServletRequest request, HttpServletResponse response) { try { response.setStatus(HttpServletResponse.SC_OK); PrintWriter writer = response.getWriter(); writer.print("{\"authctoken\":\"" + issuedToken + "\"}"); writer.flush(); } catch (Exception e) { throw new AuthenticationException("Could not write token to response.", e); } }
protected Consumer getTokenConsumer() { if (this.tokenConsumer.isAmbiguous()) { throw new AuthenticationException("You must provide exactly one " + Consumer.class.getName() + " implementation."); } if (!this.tokenConsumer.isUnsatisfied()) { return this.tokenConsumer.get(); } return null; }
protected Provider getTokenProvider() { if (this.tokenProvider.isAmbiguous()) { throw new AuthenticationException("You must provide exactly one " + Provider.class.getName() + " implementation."); } if (!this.tokenProvider.isUnsatisfied()) { return this.tokenProvider.get(); } return null; }
protected Provider getTokenProvider() { if (this.tokenProvider.isAmbiguous()) { throw new AuthenticationException("You must provide exactly one " + Provider.class.getName() + " implementation."); } if (!this.tokenProvider.isUnsatisfied()) { return this.tokenProvider.get(); } return null; }
protected Consumer getTokenConsumer() { if (this.tokenConsumer.isAmbiguous()) { throw new AuthenticationException("You must provide exactly one " + Consumer.class.getName() + " implementation."); } if (!this.tokenConsumer.isUnsatisfied()) { return this.tokenConsumer.get(); } return null; }
protected Provider getTokenProvider() { if (this.tokenProvider.isAmbiguous()) { throw new AuthenticationException("You must provide exactly one " + Provider.class.getName() + " implementation."); } if (!this.tokenProvider.isUnsatisfied()) { return this.tokenProvider.get(); } return null; }
protected Consumer getTokenConsumer() { if (this.tokenConsumer.isAmbiguous()) { throw new AuthenticationException("You must provide exactly one " + Consumer.class.getName() + " implementation."); } if (!this.tokenConsumer.isUnsatisfied()) { return this.tokenConsumer.get(); } return null; }
/** * <p>Issues a token for a previously authenticated {@link org.picketlink.idm.model.Account} using the * configured {@link org.picketlink.idm.credential.Token.Provider}.</p> * * @param request * @param response */ protected String issueToken(HttpServletRequest request, HttpServletResponse response) { Provider tokenProvider = getTokenProvider(); if (tokenProvider == null) { throw new AuthenticationException("No " + Provider.class.getName() + " was found."); } return tokenProvider.issue(getIdentity().getAccount()).getToken(); }
/** * <p>Issues a token for a previously authenticated {@link org.picketlink.idm.model.Account} using the * configured {@link org.picketlink.idm.credential.Token.Provider}.</p> * * @param request * @param response */ protected String issueToken(HttpServletRequest request, HttpServletResponse response) { Provider tokenProvider = getTokenProvider(); if (tokenProvider == null) { throw new AuthenticationException("No " + Provider.class.getName() + " was found."); } return tokenProvider.issue(getIdentity().getAccount()).getToken(); }