Class AbstractOIDCMessageEncoder
java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
org.opensaml.messaging.encoder.AbstractMessageEncoder
org.opensaml.messaging.encoder.servlet.AbstractHttpServletResponseMessageEncoder
net.shibboleth.oidc.profile.encoding.impl.AbstractOIDCMessageEncoder
- All Implemented Interfaces:
Predicate<OAuth2AuthorizationProfileConfiguration.HttpRequestMethod>,OIDCMessageEncoder,Component,DestructableComponent,InitializableComponent,UnmodifiableComponent,MessageEncoder,HttpServletResponseMessageEncoder
- Direct Known Subclasses:
HTTPPostAuthnRequestEncoder,HTTPRedirectAuthnRequestEncoder
public abstract class AbstractOIDCMessageEncoder
extends AbstractHttpServletResponseMessageEncoder
implements OIDCMessageEncoder
Base class for OIDC message encoders.
- Since:
- 2.2.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionA hook to allow additional checking of the authorization parameters after it is built.private final org.slf4j.LoggerClass logger.Fields inherited from class org.opensaml.messaging.encoder.AbstractMessageEncoder
BASE_PROTOCOL_MESSAGE_LOGGER_CATEGORY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreate a list of OAuth 2.0 authorization parameters from theOIDCAuthenticationRequestobject.private voidcreateParametersFromRequestWithoutRequestObject(List<Pair<String, String>> params, OIDCAuthenticationRequest req) Create the set of OAuth2.0 authorization and and OIDC authentication request parameters when no RequestObject has been built.private voidcreateParametersFromRequestWithRequestObject(List<Pair<String, String>> params, OIDCAuthenticationRequest req) Create the set of OAuth2.0 authorization and and OIDC authentication request parameters when a RequestObject is present.private voidcreateStandardOAuthParameters(List<Pair<String, String>> params, OIDCAuthenticationRequest req) Add the standard set of OAuth2 2.0 authorization parameters to the params list using the OAuth 2.0 request syntax.private booleanCheck if the value is contained (exact string match) in the parameter map as the first item of any pair.private booleanCheck if the value is contained (string containment) in the parameter map as the second item of a pair.protected StringSerialize OAuth 2.0 authorization parameters from the authentication request to a query string.protected voidserializeAuthorizationParamsToUrl(OIDCAuthenticationRequest request, URLBuilder builder) Serialize OAuth 2.0 authorization parameters from the authentication request to the query string of the URL.protected StringserializeMessageForLogging(Object message) voidSet a hook that allows the built authorization parameters to be validated before they are used.protected booleanvalidateParams(List<Pair<String, String>> params) Ensure the authorization parameters are valid.Methods inherited from class org.opensaml.messaging.encoder.servlet.AbstractHttpServletResponseMessageEncoder
doInitialize, getHttpServletResponse, getHttpServletResponseSupplier, setHttpServletResponseSupplierMethods inherited from class org.opensaml.messaging.encoder.AbstractMessageEncoder
doEncode, encode, getMessageContext, getMessageToLog, getProtocolMessageLogger, getProtocolMessageLoggerSubCategory, logEncodedMessage, prepareContext, setMessageContext, setProtocolMessageLoggerSubCategoryMethods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, doDestroy, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, initialize, isDestroyed, isInitializedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.shibboleth.shared.component.DestructableComponent
destroy, isDestroyedMethods inherited from interface net.shibboleth.shared.component.InitializableComponent
initialize, isInitializedMethods inherited from interface org.opensaml.messaging.encoder.MessageEncoder
encode, prepareContext, setMessageContext
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
authorizationParamsAreValidPredicate
A hook to allow additional checking of the authorization parameters after it is built.
-
-
Constructor Details
-
AbstractOIDCMessageEncoder
protected AbstractOIDCMessageEncoder()Constructor.
-
-
Method Details
-
setAuthorizationParamsAreValidPredicate
public void setAuthorizationParamsAreValidPredicate(@Nullable Predicate<List<Pair<String, String>>> predicate) Set a hook that allows the built authorization parameters to be validated before they are used. This is run in addition too, but before, the built in validation taken from the specification. If this returns false, the built in validation is not run, and validation fails.- Parameters:
predicate- the hook to run
-
serializeAuthorizationParamsToQueryString
protected String serializeAuthorizationParamsToQueryString(@Nonnull OIDCAuthenticationRequest request) throws MessageEncodingException Serialize OAuth 2.0 authorization parameters from the authentication request to a query string.- Parameters:
request- the authentication request query string.- Returns:
- the query string.
- Throws:
MessageEncodingException- on error building the parameters
-
createParametersFromRequest
@Nonnull protected List<Pair<String,String>> createParametersFromRequest(@Nonnull OIDCAuthenticationRequest req) throws MessageEncodingException Create a list of OAuth 2.0 authorization parameters from theOIDCAuthenticationRequestobject.Note, the parameters are not URL encoded here. This is left to the calling code e.g. the URLBuidler in the
serializeAuthorizationParamsToQueryString(OIDCAuthenticationRequest)method.- Parameters:
req- the authentication request- Returns:
- a list of authorization parameters.
- Throws:
MessageEncodingException- on error building the parameters
-
createStandardOAuthParameters
private void createStandardOAuthParameters(@Nonnull List<Pair<String, String>> params, @Nonnull OIDCAuthenticationRequest req) Add the standard set of OAuth2 2.0 authorization parameters to the params list using the OAuth 2.0 request syntax.- Parameters:
params- the parameter list to add thereq- the built authentication request
-
createParametersFromRequestWithRequestObject
private void createParametersFromRequestWithRequestObject(@Nonnull List<Pair<String, String>> params, @Nonnull OIDCAuthenticationRequest req) throws MessageEncodingExceptionCreate the set of OAuth2.0 authorization and and OIDC authentication request parameters when a RequestObject is present.- Parameters:
params- the OAuth2.0 authorization and and OIDC authentication request parameters to setreq- the current authentication request- Throws:
MessageEncodingException- if there is an error building the parameters
-
createParametersFromRequestWithoutRequestObject
private void createParametersFromRequestWithoutRequestObject(@Nonnull List<Pair<String, String>> params, @Nonnull OIDCAuthenticationRequest req) throws MessageEncodingExceptionCreate the set of OAuth2.0 authorization and and OIDC authentication request parameters when no RequestObject has been built. Note, ACRs are encoded into the requested claims as essential claims, the acr_values parameter is not used.- Parameters:
params- the OAuth2.0 authorization and and OIDC authentication request parameters to setreq- the current authentication request- Throws:
MessageEncodingException- if there is an error building the parameters
-
validateParams
Ensure the authorization parameters are valid.- Parameters:
params- the parameters- Returns:
- true if the authorization parameters are valid, false otherwise
-
pairFirstEquals
Check if the value is contained (exact string match) in the parameter map as the first item of any pair.- Parameters:
value- the value to check existsparams- the parameters to check- Returns:
- true iff the value exists as the first item of any pair, false otherwise
-
pairSecondContains
private boolean pairSecondContains(@Nonnull String key, @Nonnull String value, List<Pair<String, String>> params) Check if the value is contained (string containment) in the parameter map as the second item of a pair. The pair is chosen using the first parameter as a key. If they key does not exist in the list, false is returned.- Parameters:
key- the key used to find the pair that should contain the valuevalue- the value to check existsparams- the parameters to check- Returns:
- true iff the value is contained in the second item of the pair referenced by the key, false otherwise
-
serializeMessageForLogging
- Overrides:
serializeMessageForLoggingin classAbstractMessageEncoder
-