Class LegacyImplicitResponseHandler
java.lang.Object
com.irurueta.authserver.authorization.api.web.implicit.LegacyImplicitResponseHandler
- All Implemented Interfaces:
org.springframework.security.web.authentication.AuthenticationSuccessHandler
public class LegacyImplicitResponseHandler
extends Object
implements org.springframework.security.web.authentication.AuthenticationSuccessHandler
Answers the authorization endpoint: for the two results of the legacy implicit flow it redirects with
302 to
the registered redirect URI and carries the token, or the error, in its fragment (so it never reaches a server log
as a query would); any other result is the framework's authorization code response and goes to the delegate. The
response is never cached and the browser sends no referrer, so the fragment does not leak through the next request.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringToken type reported to the client.private final org.springframework.security.web.authentication.AuthenticationSuccessHandlerAnswers the results that are not the legacy flow's.(package private) static final StringValue ofReferrer-Policyof the response.(package private) static final StringValue ofCache-Controlof the response.private static final StringName of theReferrer-Policyheader. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidAdds the state, when the request had one.private static StringerrorFragment(LegacyImplicitErrorToken refused) Builds the fragment of a refusal.private static longexpiresIn(org.springframework.security.oauth2.core.OAuth2AccessToken token) Computes the lifetime of a token in seconds.private static StringBuilds the fragment of a granted request.voidonAuthenticationSuccess(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.Authentication authentication) Answers a result.private static StringEncodes one parameter.private static voidSends the redirect, with the headers that keep the fragment private.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.security.web.authentication.AuthenticationSuccessHandler
onAuthenticationSuccess
-
Field Details
-
NO_STORE
Value ofCache-Controlof the response.- See Also:
-
NO_REFERRER
Value ofReferrer-Policyof the response.- See Also:
-
REFERRER_POLICY
Name of theReferrer-Policyheader.- See Also:
-
BEARER
Token type reported to the client.- See Also:
-
delegate
private final org.springframework.security.web.authentication.AuthenticationSuccessHandler delegateAnswers the results that are not the legacy flow's.
-
-
Constructor Details
-
LegacyImplicitResponseHandler
public LegacyImplicitResponseHandler()
-
-
Method Details
-
onAuthenticationSuccess
public void onAuthenticationSuccess(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.Authentication authentication) throws IOException, jakarta.servlet.ServletException Answers a result.- Specified by:
onAuthenticationSuccessin interfaceorg.springframework.security.web.authentication.AuthenticationSuccessHandler- Parameters:
request- the request.response- the response.authentication- the result of the authorization request.- Throws:
IOException- if the response cannot be written.jakarta.servlet.ServletException- if the delegate fails.
-
grantedFragment
Builds the fragment of a granted request.- Parameters:
granted- the result.- Returns:
- the encoded fragment.
-
errorFragment
Builds the fragment of a refusal.- Parameters:
refused- the result.- Returns:
- the encoded fragment.
-
addState
Adds the state, when the request had one.- Parameters:
parameters- the encoded parameters.state- the state, may benull.
-
parameter
Encodes one parameter.- Parameters:
name- name of the parameter.value- value of the parameter.- Returns:
name=value, with the value encoded.
-
expiresIn
private static long expiresIn(org.springframework.security.oauth2.core.OAuth2AccessToken token) Computes the lifetime of a token in seconds.- Parameters:
token- the token.- Returns:
- the seconds between its issue and its expiry.
-
redirect
private static void redirect(jakarta.servlet.http.HttpServletResponse response, String redirectUri, String fragment) throws IOException Sends the redirect, with the headers that keep the fragment private.- Parameters:
response- the response.redirectUri- the registered redirect URI.fragment- the encoded fragment.- Throws:
IOException- if the response cannot be written.
-