/** * Initialize a request for external authentication by seeking out the information stored in * the servlet session and exposing it as request attributes. * * @param request servlet request * * @throws ExternalAuthenticationException if an error occurs */ protected void doStart(@Nonnull final HttpServletRequest request) throws ExternalAuthenticationException { throw new ExternalAuthenticationException("Not implemented"); }
/** * Get the {@link ProfileRequestContext} associated with a request. * * @param request servlet request * * @return the profile request context * @throws ExternalAuthenticationException if an error occurs */ @Nonnull protected ProfileRequestContext getProfileRequestContext(@Nonnull final HttpServletRequest request) throws ExternalAuthenticationException { throw new ExternalAuthenticationException("Not implemented"); }
/** * Complete a request for external authentication by seeking out the information stored in * request attributes and transferring to the session's conversation state, and then transfer * control back to the authentication web flow. * * @param request servlet request * @param response servlet response * * @throws ExternalAuthenticationException if an error occurs * @throws IOException if the redirect cannot be issued */ protected void doFinish(@Nonnull final HttpServletRequest request, @Nonnull final HttpServletResponse response) throws ExternalAuthenticationException, IOException { throw new ExternalAuthenticationException("Not implemented"); }
/** * Get the {@link ProfileRequestContext} associated with a request. * * @param key the value returned by {@link #startExternalAuthentication(HttpServletRequest)} * @param request servlet request * * @return the profile request context * @throws ExternalAuthenticationException if an error occurs */ @Nonnull public static ProfileRequestContext getProfileRequestContext(@Nonnull @NotEmpty final String key, @Nonnull final HttpServletRequest request) throws ExternalAuthenticationException { final Object obj = request.getSession().getAttribute(CONVERSATION_KEY + key); if (obj == null || !(obj instanceof ExternalAuthentication)) { throw new ExternalAuthenticationException("No conversation state found in session"); } return ((ExternalAuthentication) obj).getProfileRequestContext(request); }
/** * Initialize a request for external authentication by seeking out the information stored in * the servlet session and exposing it as request attributes. * * @param request servlet request * * @return a handle to subsequent use of * {@link #finishExternalAuthentication(java.lang.String, HttpServletRequest, HttpServletResponse)} * * @throws ExternalAuthenticationException if an error occurs */ @Nonnull @NotEmpty public static String startExternalAuthentication(@Nonnull final HttpServletRequest request) throws ExternalAuthenticationException { final String conv = request.getParameter(CONVERSATION_KEY); if (conv == null || conv.isEmpty()) { throw new ExternalAuthenticationException("No conversation key found in request"); } final Object obj = request.getSession().getAttribute(CONVERSATION_KEY + conv); if (obj == null || !(obj instanceof ExternalAuthentication)) { throw new ExternalAuthenticationException("No conversation state found in session for key (" + conv + ")"); } ((ExternalAuthentication) obj).doStart(request); return conv; }
/** * Complete a request for external authentication by seeking out the information stored in * request attributes and transferring to the session's conversation state, and then transfer * control back to the authentication web flow. * * @param key the value returned by {@link #startExternalAuthentication(HttpServletRequest)} * @param request servlet request * @param response servlet response * * @throws ExternalAuthenticationException if an error occurs * @throws IOException if the redirect cannot be issued */ public static void finishExternalAuthentication(@Nonnull @NotEmpty final String key, @Nonnull final HttpServletRequest request, @Nonnull final HttpServletResponse response) throws ExternalAuthenticationException, IOException { final Object obj = request.getSession().getAttribute(CONVERSATION_KEY + key); if (obj == null || !(obj instanceof ExternalAuthentication)) { throw new ExternalAuthenticationException("No conversation state found in session for key (" + key + ")"); } request.getSession().removeAttribute(CONVERSATION_KEY + key); ((ExternalAuthentication) obj).doFinish(request, response); }
/** {@inheritDoc} */ @SuppressWarnings("deprecation") @Override protected void doStart(@Nonnull final HttpServletRequest request) throws ExternalAuthenticationException { final AuthenticationContext authnContext = profileRequestContext.getSubcontext(AuthenticationContext.class); if (authnContext == null) { throw new ExternalAuthenticationException("No AuthenticationContext found"); } else if (authnContext.getAttemptedFlow() == null) { throw new ExternalAuthenticationException("No attempted authentication flow set"); } request.setAttribute(ProfileRequestContext.BINDING_KEY, profileRequestContext); request.setAttribute(EXTENDED_FLOW_PARAM, extendedFlow); request.setAttribute(PASSIVE_AUTHN_PARAM, authnContext.isPassive()); request.setAttribute(FORCE_AUTHN_PARAM, authnContext.isForceAuthn()); final Collection<Principal> principals = authnContext.getAttemptedFlow().getSupportedPrincipals(); if (!principals.isEmpty()) { request.setAttribute(AUTHN_METHOD_PARAM, principals.iterator().next().getName()); } final RelyingPartyContext rpCtx = relyingPartyContextLookupStrategy.apply(profileRequestContext); if (rpCtx != null) { request.setAttribute(RELYING_PARTY_PARAM, rpCtx.getRelyingPartyId()); } }
throw new ExternalAuthenticationException("Conversation key on query string doesn't match URL path");
final AuthenticationContext authnContext = profileRequestContext.getSubcontext(AuthenticationContext.class); if (authnContext == null) { throw new ExternalAuthenticationException("No AuthenticationContext found"); authnContext.getSubcontext(ExternalAuthenticationContext.class); if (extContext == null) { throw new ExternalAuthenticationException("No ExternalAuthenticationContext found"); } else if (extContext.getFlowExecutionUrl() == null) { throw new ExternalAuthenticationException("No flow execution URL found to return control");
log.error("Unable to create GSSContextAcceptor", e); finishWithException(conversationKey, httpRequest, httpResponse, new ExternalAuthenticationException(SPNEGO_NOT_AVAILABLE, e)); return null; acceptor.logout(); finishWithException(conversationKey, httpRequest, httpResponse, new ExternalAuthenticationException(SPNEGO_NOT_AVAILABLE, e)); return null; acceptor.logout(); finishWithException(conversationKey, httpRequest, httpResponse, new ExternalAuthenticationException(SPNEGO_NOT_AVAILABLE)); return null; acceptor.logout(); finishWithException(conversationKey, httpRequest, httpResponse, new ExternalAuthenticationException(SPNEGO_NOT_AVAILABLE, e));