diff --git a/src/main/java/com/authlete/jakarta/AccessTokenValidator.java b/src/main/java/com/authlete/jakarta/AccessTokenValidator.java index d583897..f4ef661 100644 --- a/src/main/java/com/authlete/jakarta/AccessTokenValidator.java +++ b/src/main/java/com/authlete/jakarta/AccessTokenValidator.java @@ -57,6 +57,7 @@ public static class Params implements Serializable private String dpop; private String htm; private String htu; + private Options options; /** @@ -318,6 +319,39 @@ public Params setHtu(String htu) return this; } + + + /** + * Get the request options for {@code /api/auth/introspection} API. + * + * @return + * The request options for {@code /api/auth/introspection} API. + * + * @since 2.82 + */ + public Options getOptions() + { + return options; + } + + + /** + * Set the request options for {@code /api/auth/introspection} API. + * + * @param options + * The request options for {@code /api/auth/introspection} API. + * + * @return + * {@code this} object. + * + * @since 2.82 + */ + public Params setOptions(Options options) + { + this.options = options; + + return this; + } } @@ -493,8 +527,8 @@ public AccessTokenInfo validate( /** - * Validate an access token. This method is an alias of the - * {@link #validate(Params, Options)} method. + * Validate an access token. This method is an alias of the {@link #validate(Params)} + * method. * *

* When the given access token is not valid, this method throws a @@ -538,7 +572,7 @@ public AccessTokenInfo validate( * presented one does not match. * * - * @since 2.82 + * @since 2.27 */ public AccessTokenInfo validate( String accessToken, String[] requiredScopes, @@ -550,15 +584,15 @@ public AccessTokenInfo validate( .setRequiredScopes(requiredScopes) .setRequiredSubject(requiredSubject) .setClientCertificate(clientCertificate) + .setOptions(options) ; - return validate(params, options); + return validate(params); } /** - * Validate an access token. This method is an alias of - * {@link #validate(Params, Options) validate}{@code (params, null)}. + * Validate an access token. * * @param params * Parameters needed for access token validation. @@ -572,29 +606,6 @@ public AccessTokenInfo validate( * @since 2.27 */ public AccessTokenInfo validate(Params params) throws WebApplicationException - { - return validate(params, null); - } - - - /** - * Validate an access token. - * - * @param params - * Parameters needed for access token validation. - * - * @param options - * Request options for {@code /api/auth/introspection} API. - * - * @return - * Information about the access token. - * - * @throws WebApplicationException - * The access token is invalid. - * - * @since 2.82 - */ - public AccessTokenInfo validate(Params params, Options options) throws WebApplicationException { if (params == null || params.getAccessToken() == null) { @@ -604,7 +615,7 @@ public AccessTokenInfo validate(Params params, Options options) throws WebApplic try { - return process(params, options); + return process(params); } catch (WebApplicationException e) { @@ -681,8 +692,7 @@ public IntrospectionResponse validate( } - - private AccessTokenInfo process(Params params, Options options) throws WebApplicationException + private AccessTokenInfo process(Params params) throws WebApplicationException { // Call Authlete's /api/auth/introspection API. IntrospectionResponse response = getApiCaller().callIntrospection( @@ -693,7 +703,7 @@ private AccessTokenInfo process(Params params, Options options) throws WebApplic params.getDpop(), params.getHtm(), params.getHtu(), - options + params.getOptions() ); // Handle the response from the /auth/introspection API. diff --git a/src/main/java/com/authlete/jakarta/AuthorizationDecisionHandler.java b/src/main/java/com/authlete/jakarta/AuthorizationDecisionHandler.java index 72b9459..22e27c5 100644 --- a/src/main/java/com/authlete/jakarta/AuthorizationDecisionHandler.java +++ b/src/main/java/com/authlete/jakarta/AuthorizationDecisionHandler.java @@ -70,6 +70,9 @@ public static class Params implements Serializable private String[] requestedClaimsForTx; private StringArray[] requestedVerifiedClaimsForTx; private boolean oldIdaFormatUsed; + private Options authzOptions; + private Options authzIssueOptions; + private Options authzFailOptions; /** @@ -430,12 +433,111 @@ public Params setOldIdaFormatUsed(boolean used) } + /** + * Get the request options for {@code /api/auth/authorization} API. + * + * @return + * The request options for {@code /api/auth/authorization} API. + * + * @since 2.82 + */ + public Options getAuthzOptions() + { + return authzOptions; + } + + + /** + * Set the request options for {@code /api/auth/authorization} API. + * + * @param options + * The request options for {@code /api/auth/authorization} API. + * + * @return + * {@code this} object. + * + * @since 2.82 + */ + public Params setAuthzOptions(Options options) + { + authzOptions = options; + + return this; + } + + + /** + * Get the request options for {@code /api/auth/authorization/issue} API. + * + * @return + * The request options for {@code /api/auth/authorization/issue} API. + * + * @since 2.82 + */ + public Options getAuthzIssueOptions() + { + return authzIssueOptions; + } + + + /** + * Set the request options for {@code /api/auth/authorization/issue} API. + * + * @param options + * The request options for {@code /api/auth/authorization/issue} API. + * + * @return + * {@code this} object. + * + * @since 2.82 + */ + public Params setAuthzIssueOptions(Options options) + { + authzIssueOptions = options; + + return this; + } + + + /** + * Get the request options for {@code /api/auth/authorization/fail} API. + * + * @return + * The request options for {@code /api/auth/authorization/fail} API. + * + * @since 2.82 + */ + public Options getAuthzFailOptions() + { + return authzFailOptions; + } + + + /** + * Set the request options for {@code /api/auth/authorization/fail} API. + * + * @param options + * The request options for {@code /api/auth/authorization/fail} API. + * + * @return + * {@code this} object. + * + * @since 2.82 + */ + public Params setAuthzFailOptions(Options options) + { + authzFailOptions = options; + + return this; + } + + /** * Create a {@link Params} instance from an instance of * {@link AuthorizationResponse}. * * @param response - * An response from Authlete's {@code /api/auth/authorization} API. + * An response from Authlete's {@code /api/auth/authorization/issue} API. * * @return * A new {@code Params} instance built from the response. @@ -510,7 +612,7 @@ public Response handle(String ticket, String[] claimNames, String[] claimLocales /** * Handle an end-user's decision on an authorization request. This method is - * an alias of the {@link #handle(Params, Options, Options)} method. + * an alias of the {@link #handle(Params)} method. * * @param ticket * A ticket that was issued by Authlete's {@code /api/auth/authorization} API. @@ -535,8 +637,6 @@ public Response handle(String ticket, String[] claimNames, String[] claimLocales * * @throws WebApplicationException * An error occurred. - * - * @since 2.82 */ public Response handle( String ticket, String[] claimNames, String[] claimLocales, Options authzIssueOpts, @@ -546,15 +646,16 @@ public Response handle( .setTicket(ticket) .setClaimNames(claimNames) .setClaimLocales(claimLocales) + .setAuthzIssueOptions(authzFailOpts) + .setAuthzFailOptions(authzFailOpts) ; - return handle(params, authzIssueOpts, authzFailOpts); + return handle(params); } /** - * Handle an end-user's decision on an authorization request. This method is - * an alias of {@link #handle(Params, Options, Options) handle}{@code (params, null, null)}. + * Handle an end-user's decision on an authorization request. * * @param params * Parameters necessary to handle the decision. @@ -569,39 +670,11 @@ public Response handle( * @since 2.25 */ public Response handle(Params params) throws WebApplicationException - { - return handle(params, null, null); - } - - - /** - * Handle an end-user's decision on an authorization request. - * - * @param params - * Parameters necessary to handle the decision. - * - * @param authzIssueOpts - * Request options for the {@code /api/auth/authorization/issue} API. - * - * @param authzFailOpts - * Request options for the {@code /api/auth/authorization/fail} API. - * - * @return - * A response to the client application. Basically, the response - * will trigger redirection to the client's redirection endpoint. - * - * @throws WebApplicationException - * An error occurred. - * - * @since 2.82 - */ - public Response handle( - Params params, Options authzIssueOpts, Options authzFailOpts) throws WebApplicationException { try { // Process the end-user's decision. - return process(params, authzIssueOpts, authzFailOpts); + return process(params); } catch (WebApplicationException e) { @@ -618,13 +691,13 @@ public Response handle( /** * Process the end-user's decision. */ - private Response process(Params params, Options authzIssueOpts, Options authzFailOpts) + private Response process(Params params) { // If the end-user did not grant authorization to the client application. if (mSpi.isClientAuthorized() == false) { // The end-user denied the authorization request. - return fail(params.getTicket(), Reason.DENIED, authzFailOpts); + return fail(params.getTicket(), Reason.DENIED, params.getAuthzFailOptions()); } // The subject (= unique identifier) of the end-user. @@ -634,7 +707,7 @@ private Response process(Params params, Options authzIssueOpts, Options authzFai if (subject == null || subject.length() == 0) { // The end-user is not authenticated. - return fail(params.getTicket(), Reason.NOT_AUTHENTICATED, authzFailOpts); + return fail(params.getTicket(), Reason.NOT_AUTHENTICATED, params.getAuthzFailOptions()); } // the potentially pairwise subject of the end user @@ -689,7 +762,7 @@ private Response process(Params params, Options authzIssueOpts, Options authzFai // Authorize the authorization request. return authorize(params.getTicket(), subject, authTime, acr, claims, - properties, scopes, sub, claimsForTx, verifiedClaimsForTx, authzIssueOpts); + properties, scopes, sub, claimsForTx, verifiedClaimsForTx, params.getAuthzIssueOptions()); } @@ -1081,7 +1154,7 @@ private VerifiedClaimsCollector createVerifiedClaimsCollector() * {@code verified_claims/claims}. * * @param options - * Request options. + * Request options for {@code /auth/authorization/issue} API. * * @return * A response that should be returned to the client application. @@ -1123,7 +1196,7 @@ private Response authorize( * A reason of the failure of the authorization request. * * @param options - * Request options. + * Request options for {@code /auth/authorization/fail} API. * * @return * A response that should be returned to the client application. diff --git a/src/main/java/com/authlete/jakarta/BaseAuthorizationDecisionEndpoint.java b/src/main/java/com/authlete/jakarta/BaseAuthorizationDecisionEndpoint.java index 9a773d0..0a43e80 100644 --- a/src/main/java/com/authlete/jakarta/BaseAuthorizationDecisionEndpoint.java +++ b/src/main/java/com/authlete/jakarta/BaseAuthorizationDecisionEndpoint.java @@ -109,35 +109,11 @@ public Response handle( .setTicket(ticket) .setClaimNames(claimNames) .setClaimLocales(claimLocales) + .setAuthzIssueOptions(authzFailOpts) + .setAuthzFailOptions(authzFailOpts) ; - return handle(api, spi, params, authzIssueOpts, authzFailOpts); - } - - - /** - * Handle an authorization decision request. This method is an alias of - * {@link #handle(AuthleteApi, AuthorizationDecisionHandlerSpi, Params, Options, - * Options) handle}{@code (api, spi, params, null, null)}. - * - * @param api - * An implementation of {@link AuthleteApi}. - * - * @param spi - * An implementation of {@link AuthorizationDecisionHandlerSpi}. - * - * @param params - * Parameters necessary to handle the decision. - * - * @return - * A response that should be returned to the client application. - * - * @since 2.26 - */ - public Response handle( - AuthleteApi api, AuthorizationDecisionHandlerSpi spi, Params params) - { - return handle(api, spi, params, null, null); + return handle(api, spi, params); } @@ -169,20 +145,13 @@ public Response handle( * @param params * Parameters necessary to handle the decision. * - * @param authzIssueOpts - * Request options for the {@code /api/auth/authorization/issue} API. - * - * @param authzFailOpts - * Request options for the {@code /api/auth/authorization/fail} API. - * * @return * A response that should be returned to the client application. * - * @since 2.82 + * @since 2.26 */ public Response handle( - AuthleteApi api, AuthorizationDecisionHandlerSpi spi, Params params, - Options authzIssueOpts, Options authzFailOpts) + AuthleteApi api, AuthorizationDecisionHandlerSpi spi, Params params) { try { @@ -190,7 +159,7 @@ public Response handle( AuthorizationDecisionHandler handler = new AuthorizationDecisionHandler(api, spi); // Delegate the task to the handler. - return handler.handle(params, authzIssueOpts, authzFailOpts); + return handler.handle(params); } catch (WebApplicationException e) { diff --git a/src/main/java/com/authlete/jakarta/BaseIntrospectionEndpoint.java b/src/main/java/com/authlete/jakarta/BaseIntrospectionEndpoint.java index e775fb0..60ea3e8 100644 --- a/src/main/java/com/authlete/jakarta/BaseIntrospectionEndpoint.java +++ b/src/main/java/com/authlete/jakarta/BaseIntrospectionEndpoint.java @@ -81,34 +81,13 @@ public Response handle( { Params params = new Params() .setParameters(parameters) + .setOptions(options) ; return handle(api, params); } - /** - * Handle an introspection request. This method is an alias of {@link - * #handle(AuthleteApi, IntrospectionRequestHandler.Params, Options) - * handle}{@code (api, params, null)}. - * - * @param api - * An implementation of {@link AuthleteApi}. - * - * @param params - * Parameters needed to handle the introspection request. - * - * @return - * A response that should be returned to the resource server. - * - * @since 2.63 - */ - public Response handle(AuthleteApi api, Params params) - { - return handle(api, params, null); - } - - /** * Handle an introspection request. * @@ -138,15 +117,12 @@ public Response handle(AuthleteApi api, Params params) * @param params * Parameters needed to handle the introspection request. * - * @param options - * Request options for the {@code /api/auth/introspection} API. - * * @return * A response that should be returned to the resource server. * - * @since 2.82 + * @since 2.63 */ - public Response handle(AuthleteApi api, Params params, Options options) + public Response handle(AuthleteApi api, Params params) { try { @@ -154,7 +130,7 @@ public Response handle(AuthleteApi api, Params params, Options options) IntrospectionRequestHandler handler = new IntrospectionRequestHandler(api); // Delegate the task to the handler. - return handler.handle(params, options); + return handler.handle(params); } catch (WebApplicationException e) { diff --git a/src/main/java/com/authlete/jakarta/BasePushedAuthReqEndpoint.java b/src/main/java/com/authlete/jakarta/BasePushedAuthReqEndpoint.java index 2aef04c..37ee653 100644 --- a/src/main/java/com/authlete/jakarta/BasePushedAuthReqEndpoint.java +++ b/src/main/java/com/authlete/jakarta/BasePushedAuthReqEndpoint.java @@ -67,8 +67,7 @@ protected Response handle( /** - * Handle a pushed authorization request. This method is an alias of the {@link - * #handle(AuthleteApi, Params, Options)} method. + * Handle a pushed authorization request. * * @param api * An implementation of {@link AuthleteApi}. @@ -99,9 +98,10 @@ protected Response handle( .setParameters(parameters) .setAuthorization(authorization) .setClientCertificatePath(clientCertificates) + .setOptions(options) ; - return handle(api, params, options); + return handle(api, params); } @@ -109,26 +109,6 @@ protected Response handle( * Handle a PAR request. This method is an alias of the {@link * #handle(AuthleteApi, Params, Options) handle}{@code (api, params, null)}. * - * @param api - * An implementation of {@link AuthleteApi}. - * - * @param params - * Parameters needed to handle the PAR request. - * - * @return - * A response that should be returned to the client application. - * - * @since 2.70 - */ - public Response handle(AuthleteApi api, Params params) - { - return handle(api, params, null); - } - - - /** - * Handle a PAR request. - * *

* This method internally creates a {@link PushedAuthReqHandler} instance and * calls its {@link PushedAuthReqHandler#handle(PushedAuthReqHandler.Params, Options)} @@ -151,15 +131,12 @@ public Response handle(AuthleteApi api, Params params) * @param params * Parameters needed to handle the PAR request. * - * @param options - * Request options for the {@code /api/pushed_auth_req} API. - * * @return * A response that should be returned to the client application. * - * @since 2.82 + * @since 2.70 */ - public Response handle(AuthleteApi api, Params params, Options options) + public Response handle(AuthleteApi api, Params params) { try { @@ -167,7 +144,7 @@ public Response handle(AuthleteApi api, Params params, Options options) PushedAuthReqHandler handler = new PushedAuthReqHandler(api); // Delegate the task to the handler. - return handler.handle(params, options); + return handler.handle(params); } catch (WebApplicationException e) { diff --git a/src/main/java/com/authlete/jakarta/BaseResourceEndpoint.java b/src/main/java/com/authlete/jakarta/BaseResourceEndpoint.java index 8ce143b..0b7227d 100644 --- a/src/main/java/com/authlete/jakarta/BaseResourceEndpoint.java +++ b/src/main/java/com/authlete/jakarta/BaseResourceEndpoint.java @@ -403,17 +403,15 @@ public AccessTokenInfo validateAccessToken( .setRequiredScopes(requiredScopes) .setRequiredSubject(requiredSubject) .setClientCertificate(clientCertificate) + .setOptions(options) ; - return validateAccessToken(api, params, options); + return validateAccessToken(api, params); } /** - * Validate an access token. This method is an alias of {@link - * #validateAccessToken(AuthleteApi, AccessTokenValidator.Params, Options) - * validateAccessToken}{@code (api, params, null)}. - * . + * Validate an access token. * * @param api * Implementation of {@link AuthleteApi} interface. @@ -431,57 +429,11 @@ public AccessTokenInfo validateAccessToken( */ public AccessTokenInfo validateAccessToken( AuthleteApi api, Params params) throws WebApplicationException - { - return validateAccessToken(api, params, null); - } - - - /** - * Validate an access token. - * - *

- * This method internally creates an {@link AccessTokenValidator} instance - * and calls its {@link AccessTokenValidator#validate(Params) - * validate()} method. Then, this method uses the value returned from the - * {@code validate()} method as a response from this method. - *

- * - *

- * When {@code AccessTokenValidator.validate()} method raises a {@link - * WebApplicationException}, this method calls {@link - * #onError(WebApplicationException) onError()} method with the exception. - * The default implementation of {@code onError()} does nothing. You can - * override the method as necessary. After calling {@code onError()} - * method, this method re-throws the exception. The response contained in - * the exception complies with the requirements described in RFC 6750 (The OAuth 2.0 - * Authorization Framework: Bearer Token Usage). - *

- * - * @param api - * Implementation of {@link AuthleteApi} interface. - * - * @param params - * Parameters needed for access token validation. - * - * @param options - * Request options for {@code /api/auth/introspection} API. - * - * @return - * Information about the access token. - * - * @throws WebApplicationException - * The Access Token is invalid. - * - * @since 2.82 - */ - public AccessTokenInfo validateAccessToken( - AuthleteApi api, Params params, Options options) throws WebApplicationException { try { // Validate the access token and obtain the information about it. - return new AccessTokenValidator(api).validate(params, options); + return new AccessTokenValidator(api).validate(params); } catch (WebApplicationException e) { diff --git a/src/main/java/com/authlete/jakarta/BaseTokenEndpoint.java b/src/main/java/com/authlete/jakarta/BaseTokenEndpoint.java index 93ef025..26d66bf 100644 --- a/src/main/java/com/authlete/jakarta/BaseTokenEndpoint.java +++ b/src/main/java/com/authlete/jakarta/BaseTokenEndpoint.java @@ -192,35 +192,12 @@ public Response handle( .setParameters(parameters) .setAuthorization(authorization) .setClientCertificatePath(clientCertificatePath) + .setTokenOptions(tokenOpts) + .setTokenIssueOptions(tokenIssueOpts) + .setTokenFailOptions(tokenFailOpts) ; - return handle(api, spi, params, tokenOpts, tokenIssueOpts, tokenFailOpts); - } - - - /** - * Handle a token request. This method is an alias of {@link #handle(AuthleteApi, - * TokenRequestHandlerSpi, TokenRequestHandler.Params, Options, Options, Options) - * handle}{@code (api, spi, params, null, null, null)}. - * - * @param api - * An implementation of {@link AuthleteApi}. - * - * @param spi - * An implementation of {@link TokenRequestHandlerSpi}. - * - * @param params - * Parameters needed to handle the token request. - * - * @return - * A response that should be returned to the client application. - * - * @since 2.27 - */ - public Response handle( - AuthleteApi api, TokenRequestHandlerSpi spi, Params params) - { - return handle(api, spi, params, null, null, null); + return handle(api, spi, params); } @@ -236,11 +213,12 @@ public Response handle( * *

* When {@code TokenRequestHandler.handle()} method raises a {@link - * WebApplicationException}, this method calls {@link #onError(WebApplicationException) onError()} - * method with the exception. The default implementation of {@code onError()} - * does nothing. You can override the method as necessary. After calling - * {@code onError()} method, this method calls {@code getResponse()} method of - * the exception and uses the returned value as a response from this method. + * WebApplicationException}, this method calls {@link #onError(WebApplicationException) + * onError()} method with the exception. The default implementation of {@code + * onError()} does nothing. You can override the method as necessary. After + * calling {@code onError()} method, this method calls {@code getResponse()} + * method of the exception and uses the returned value as a response from this + * method. *

* * @param api @@ -252,23 +230,13 @@ public Response handle( * @param params * Parameters needed to handle the token request. * - * @param tokenOpts - * Request options for the {@code /api/auth/token} API. - * - * @param tokenIssueOpts - * Request options for the {@code /api/auth/token/issue} API. - * - * @param tokenFailOpts - * Request options for the {@code /api/auth/token/fail} API. - * * @return * A response that should be returned to the client application. * - * @since 2.82 + * @since 2.27 */ public Response handle( - AuthleteApi api, TokenRequestHandlerSpi spi, Params params, Options tokenOpts, - Options tokenIssueOpts, Options tokenFailOpts) + AuthleteApi api, TokenRequestHandlerSpi spi, Params params) { try { @@ -276,7 +244,7 @@ public Response handle( TokenRequestHandler handler = new TokenRequestHandler(api, spi); // Delegate the task to the handler. - return handler.handle(params, tokenOpts, tokenIssueOpts, tokenFailOpts); + return handler.handle(params); } catch (WebApplicationException e) { diff --git a/src/main/java/com/authlete/jakarta/BaseUserInfoEndpoint.java b/src/main/java/com/authlete/jakarta/BaseUserInfoEndpoint.java index 3275c63..48f6904 100644 --- a/src/main/java/com/authlete/jakarta/BaseUserInfoEndpoint.java +++ b/src/main/java/com/authlete/jakarta/BaseUserInfoEndpoint.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016-2022 Authlete, Inc. + * Copyright (C) 2016-2025 Authlete, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,10 +62,9 @@ public Response handle( /** - * Handle a userinfo request. - * - * This method is an alias of the {@link #handle(AuthleteApi, UserInfoRequestHandlerSpi, - * UserInfoRequestHandler.Params)} method. + * Handle a userinfo request. This method is an alias of the {@link + * #handle(AuthleteApi, UserInfoRequestHandlerSpi, UserInfoRequestHandler.Params)} + * method. * * @param api * An implementation of {@link AuthleteApi}. @@ -93,9 +92,11 @@ public Response handle( { Params params = new Params() .setAccessToken(accessToken) + .setUserInfoOptions(userInfoOpts) + .setUserInfoIssueOptions(userInfoIssueOpts) ; - return handle(api, spi, params, userInfoOpts, userInfoIssueOpts); + return handle(api, spi, params); } @@ -136,55 +137,6 @@ public Response handle( */ public Response handle( AuthleteApi api, UserInfoRequestHandlerSpi spi, Params params) - { - return handle(api, spi, params, null, null); - } - - - /** - * Handle a userinfo request. - * - *

- * This method internally creates a {@link UserInfoRequestHandler} instance - * and calls its - * {@link UserInfoRequestHandler#handle(UserInfoRequestHandler.Params) - * handle(Params)} method. Then, this method uses the value returned from - * the {@code handle()} method as a response from this method. - *

- * - *

- * When {@code UserInfoRequestHandler.handle()} method raises a {@link - * WebApplicationException}, this method calls {@link - * #onError(WebApplicationException) onError()} method with the exception. - * The default implementation of {@code onError()} does nothing. You can - * override the method as necessary. After calling {@code onError()} - * method, this method calls {@code getResponse()} method of the exception - * and uses the returned value as a response from this method. - *

- * - * @param api - * An implementation of {@link AuthleteApi}. - * - * @param spi - * An implementation of {@link UserInfoRequestHandlerSpi}. - * - * @param params - * Parameters needed to handle the userinfo request. - * - * @param userInfoOpts - * Request options for the {@code /api/auth/userinfo} API. - * - * @param userInfoIssueOpts - * Request options for the {@code /api/auth/userinfo/issue} API. - * - * @return - * A response that should be returned to the client application. - * - * @since 2.82 - */ - public Response handle( - AuthleteApi api, UserInfoRequestHandlerSpi spi, Params params, Options userInfoOpts, - Options userInfoIssueOpts) { try { @@ -192,7 +144,7 @@ public Response handle( UserInfoRequestHandler handler = new UserInfoRequestHandler(api, spi); // Delegate the task to the handler. - return handler.handle(params, userInfoOpts, userInfoIssueOpts); + return handler.handle(params); } catch (WebApplicationException e) { diff --git a/src/main/java/com/authlete/jakarta/IntrospectionRequestHandler.java b/src/main/java/com/authlete/jakarta/IntrospectionRequestHandler.java index 7b765ee..7b8fc23 100644 --- a/src/main/java/com/authlete/jakarta/IntrospectionRequestHandler.java +++ b/src/main/java/com/authlete/jakarta/IntrospectionRequestHandler.java @@ -73,6 +73,7 @@ public static class Params implements Serializable private String sharedKeyForSign; private String sharedKeyForEncryption; private String publicKeyForEncryption; + private Options options; /** @@ -452,6 +453,39 @@ public Params setPublicKeyForEncryption(String key) return this; } + + + /** + * Get the request options for {@code /api/auth/introspection} API. + * + * @return + * The request options for {@code /api/auth/introspection} API. + * + * @since 2.82 + */ + public Options getOptions() + { + return options; + } + + + /** + * Set the request options for {@code /api/auth/introspection} API. + * + * @param options + * The request options for {@code /api/auth/introspection} API. + * + * @return + * {@code this} object. + * + * @since 2.82 + */ + public Params setOptions(Options options) + { + this.options = options; + + return this; + } } @@ -491,8 +525,7 @@ public Response handle( /** * Handle an introspection request (RFC 7662). This method is an alias of the {@link #handle(Params, Options)} - * method. + * >RFC 7662). This method is an alias of the {@link #handle(Params)} method. * * @param parameters * Request parameters of an introspection request. @@ -514,16 +547,16 @@ public Response handle( { Params params = new Params() .setParameters(parameters) + .setOptions(options) ; - return handle(params, options); + return handle(params); } /** * Handle an introspection request (RFC 7662). This method is an alias of {@link #handle(Params, Options) - * handle}{@code (params, null)}. + * >RFC 7662). * * @param params * Parameters needed to handle the introspection request. @@ -539,32 +572,6 @@ public Response handle( * @since 2.63 */ public Response handle(Params params) throws WebApplicationException - { - return handle(params, null); - } - - - /** - * Handle an introspection request (RFC 7662). - * - * @param params - * Parameters needed to handle the introspection request. - * Must not be {@code null}. - * - * @param options - * Request options for the {@code /api/auth/introspection/standard} API. - * - * @return - * A response that should be returned from the endpoint to - * the resource server. - * - * @throws WebApplicationException - * An error occurred. - * - * @since 2.82 - */ - public Response handle(Params params, Options options) throws WebApplicationException { try { @@ -580,7 +587,7 @@ public Response handle(Params params, Options options) throws WebApplicationExce params.getSharedKeyForSign(), params.getSharedKeyForEncryption(), params.getPublicKeyForEncryption(), - options + params.getOptions() ); } catch (WebApplicationException e) diff --git a/src/main/java/com/authlete/jakarta/PushedAuthReqHandler.java b/src/main/java/com/authlete/jakarta/PushedAuthReqHandler.java index a78cbbd..a42652d 100644 --- a/src/main/java/com/authlete/jakarta/PushedAuthReqHandler.java +++ b/src/main/java/com/authlete/jakarta/PushedAuthReqHandler.java @@ -69,6 +69,7 @@ public static class Params implements Serializable private String dpop; private String htm; private String htu; + private Options options; /** @@ -295,6 +296,39 @@ public Params setHtu(String htu) return this; } + + + /** + * Get the request options for {@code /api/pushed_auth_req} API. + * + * @return + * The request options for {@code /api/pushed_auth_req} API. + * + * @since 2.82 + */ + public Options getOptions() + { + return options; + } + + + /** + * Set the request options for {@code /api/pushed_auth_req} API. + * + * @param options + * The request options for {@code /api/pushed_auth_req} API. + * + * @return + * {@code this} object. + * + * @since 2.82 + */ + public Params setOptions(Options options) + { + this.options = options; + + return this; + } } @@ -347,7 +381,7 @@ public Response handle( /** * Handle a pushed authorization request. This method is an alias of the {@link - * #handle(Params, Options)} method. + * #handle(Params)} method. * * @param parameters * Request parameters of a pushed authorization request. @@ -384,15 +418,15 @@ public Response handle( .setParameters(parameters) .setAuthorization(authorization) .setClientCertificatePath(clientCertificatePath) + .setOptions(options) ; - return handle(params, options); + return handle(params); } /** - * Handle a PAR request. This method is an alias of {@link #handle(Params, Options) - * handle}{@code (params, null)}. + * Handle a PAR request. * * @param params * Parameters needed to handle the PAR request. @@ -408,31 +442,6 @@ public Response handle( * @since 2.69 */ public Response handle(Params params) - { - return handle(params, null); - } - - - /** - * Handle a PAR request. - * - * @param params - * Parameters needed to handle the PAR request. - * Must not be {@code null}. - * - * @param options - * Request options for the {@code /api/pushed_auth_req} API. - * - * @return - * A response that should be returned from the endpoint to the - * client application. - * - * @throws WebApplicationException - * An error occurred. - * - * @since 2.82 - */ - public Response handle(Params params, Options options) { // Convert the value of Authorization header (credentials of // the client application), if any, into BasicCredentials. @@ -454,7 +463,7 @@ public Response handle(Params params, Options options) params.getDpop(), params.getHtm(), params.getHtu(), - options + params.getOptions() ); } catch (WebApplicationException e) diff --git a/src/main/java/com/authlete/jakarta/TokenRequestHandler.java b/src/main/java/com/authlete/jakarta/TokenRequestHandler.java index a23ad4f..9a350ea 100644 --- a/src/main/java/com/authlete/jakarta/TokenRequestHandler.java +++ b/src/main/java/com/authlete/jakarta/TokenRequestHandler.java @@ -60,7 +60,7 @@ public class TokenRequestHandler extends BaseHandler */ public static class Params implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 2L; private MultivaluedMap parameters; @@ -69,6 +69,9 @@ public static class Params implements Serializable private String dpop; private String htm; private String htu; + private Options tokenOptions; + private Options tokenIssueOptions; + private Options tokenFailOptions; /** @@ -289,6 +292,105 @@ public Params setHtu(String htu) return this; } + + + /** + * Get the request options for {@code /api/auth/token} API. + * + * @return + * The request options for {@code /api/auth/token} API. + * + * @since 2.82 + */ + public Options getTokenOptions() + { + return tokenOptions; + } + + + /** + * Set the request options for {@code /api/auth/token} API. + * + * @param options + * The request options for {@code /api/auth/token} API. + * + * @return + * {@code this} object. + * + * @since 2.82 + */ + public Params setTokenOptions(Options options) + { + tokenOptions = options; + + return this; + } + + + /** + * Get the request options for {@code /api/auth/token/issue} API. + * + * @return + * The request options for {@code /api/auth/token/issue} API. + * + * @since 2.82 + */ + public Options getTokenIssueOptions() + { + return tokenIssueOptions; + } + + + /** + * Set the request options for {@code /api/auth/token/issue} API. + * + * @param options + * The request options for {@code /api/auth/token/issue} API. + * + * @return + * {@code this} object. + * + * @since 2.82 + */ + public Params setTokenIssueOptions(Options options) + { + tokenIssueOptions = options; + + return this; + } + + + /** + * Get the request options for {@code /api/auth/token/fail} API. + * + * @return + * The request options for {@code /api/auth/token/fail} API. + * + * @since 2.82 + */ + public Options getTokenFailOptions() + { + return tokenFailOptions; + } + + + /** + * Set the request options for {@code /api/auth/token/fail} API. + * + * @param options + * The request options for {@code /api/auth/token/fail} API. + * + * @return + * {@code this} object. + * + * @since 2.82 + */ + public Params setTokenFailOptions(Options options) + { + tokenFailOptions = options; + + return this; + } } @@ -394,8 +496,9 @@ public Response handle( /** - * Handle a token request. This method is an alias of {@link #handle(MultivaluedMap, String, String[], Options, Options, Options) - * handle}{@code (parameters, authorization, clientCertificatePath, null, null, null)}. + * Handle a token request. This method is an alias of {@link + * #handle(MultivaluedMap, String, String[], Options, Options, Options) handle}{@code + * (parameters, authorization, clientCertificatePath, null, null, null)}. * * @param parameters * Request parameters of a token request. @@ -430,8 +533,8 @@ public Response handle( /** - * Handle a token request. This method is an alias of the {@link #handle(Params, - * Options, Options, Options)} method. + * Handle a token request. This method is an alias of the {@link #handle(Params)} + * method. * * @param parameters * Request parameters of a token request. @@ -475,15 +578,17 @@ public Response handle( .setParameters(parameters) .setAuthorization(authorization) .setClientCertificatePath(clientCertificatePath) + .setTokenOptions(tokenFailOpts) + .setTokenIssueOptions(tokenFailOpts) + .setTokenFailOptions(tokenFailOpts) ; - return handle(params, tokenOpts, tokenIssueOpts, tokenFailOpts); + return handle(params); } /** - * Handle a token request. This method is an alias of the {@link #handle(Params, - * Options, Options, Options) handle}{@code (params, null, null, null)}. + * Handle a token request. * * @param params * Parameters needed to handle the token request. @@ -499,39 +604,6 @@ public Response handle( * @since 2.27 */ public Response handle(Params params) throws WebApplicationException - { - return handle(params, null, null, null); - } - - - /** - * Handle a token request. - * - * @param params - * Parameters needed to handle the token request. - * Must not be {@code null}. - * - * @param tokenOpts - * Request options for the {@code /api/auth/token} API. - * - * @param tokenIssueOpts - * Request options for the {@code /api/auth/token/issue} API. - * - * @param tokenFailOpts - * Request options for the {@code /api/auth/token/fail} API. - * - * @return - * A response that should be returned from the endpoint to the - * client application. - * - * @throws WebApplicationException - * An error occurred. - * - * @since 2.82 - */ - public Response handle( - Params params, Options tokenOpts, Options tokenIssueOpts, Options tokenFailOpts) - throws WebApplicationException { // Convert the value of Authorization header (credentials of // the client application), if any, into BasicCredentials. @@ -553,9 +625,9 @@ public Response handle( params.getDpop(), params.getHtm(), params.getHtu(), - tokenOpts, - tokenIssueOpts, - tokenFailOpts + params.getTokenOptions(), + params.getTokenIssueOptions(), + params.getTokenFailOptions() ); } catch (WebApplicationException e) diff --git a/src/main/java/com/authlete/jakarta/UserInfoRequestHandler.java b/src/main/java/com/authlete/jakarta/UserInfoRequestHandler.java index 93c90af..49bb4be 100644 --- a/src/main/java/com/authlete/jakarta/UserInfoRequestHandler.java +++ b/src/main/java/com/authlete/jakarta/UserInfoRequestHandler.java @@ -72,6 +72,8 @@ public static class Params implements Serializable private String htm; private String htu; private boolean oldIdaFormatUsed; + private Options userInfoOptions; + private Options userInfoIssueOptions; /** @@ -381,6 +383,72 @@ public Params setOldIdaFormatUsed(boolean used) return this; } + + + /** + * Get the request options for {@code /api/auth/userinfo} API. + * + * @return + * The request options for {@code /api/auth/userinfo} API. + * + * @since 2.82 + */ + public Options getUserInfoOptions() + { + return userInfoOptions; + } + + + /** + * Set the request options for {@code /api/auth/userinfo} API. + * + * @param options + * The request options for {@code /api/auth/userinfo} API. + * + * @return + * {@code this} object. + * + * @since 2.82 + */ + public Params setUserInfoOptions(Options options) + { + userInfoOptions = options; + + return this; + } + + + /** + * Get the request options for {@code /api/auth/userinfo/issue} API. + * + * @return + * The request options for {@code /api/auth/userinfo/issue} API. + * + * @since 2.82 + */ + public Options getUserInfoIssueOptions() + { + return userInfoIssueOptions; + } + + + /** + * Set the request options for {@code /api/auth/userinfo/issue} API. + * + * @param options + * The request options for {@code /api/auth/userinfo/issue} API. + * + * @return + * {@code this} object. + * + * @since 2.82 + */ + public Params setUserInfoIssueOptions(Options options) + { + userInfoIssueOptions = options; + + return this; + } } @@ -470,29 +538,11 @@ public Response handle( { Params params = new Params() .setAccessToken(accessToken) + .setUserInfoOptions(userInfoOpts) + .setUserInfoIssueOptions(userInfoIssueOpts) ; - return handle(params, userInfoOpts, userInfoIssueOpts); - } - - - /** - * Handle a userinfo request. This method is an alias of {@link #handle(Params, Options, Options) - * handle}{@code (params, null, null)}. - * - * @param params - * Parameters needed to handle the userinfo request. - * - * @return - * A response that should be returned from the endpoint to the - * client application. - * - * @throws WebApplicationException - * An error occurred. - */ - public Response handle(Params params) throws WebApplicationException - { - return handle(params, null, null); + return handle(params); } @@ -502,24 +552,14 @@ public Response handle(Params params) throws WebApplicationException * @param params * Parameters needed to handle the userinfo request. * - * @param userInfoOpts - * Request options for the {@code /api/auth/userinfo} API. - * - * @param userInfoIssueOpts - * Request options for the {@code /api/auth/userinfo/issue} API. - * * @return * A response that should be returned from the endpoint to the * client application. * * @throws WebApplicationException * An error occurred. - * - * @since 2.82 */ - public Response handle( - Params params, Options userInfoOpts, Options userInfoIssueOpts) - throws WebApplicationException + public Response handle(Params params) throws WebApplicationException { // If an access token is not available. if (params == null || params.getAccessToken() == null) @@ -532,7 +572,7 @@ public Response handle( try { // Process the userinfo request. - return process(params, userInfoOpts, userInfoIssueOpts); + return process(params); } catch (WebApplicationException e) { @@ -549,7 +589,7 @@ public Response handle( /** * Process the userinfo request with the access token. */ - private Response process(Params params, Options userInfoOpts, Options userInfoIssueOpts) + private Response process(Params params) { // Call Authlete's /api/auth/userinfo API. UserInfoResponse response = getApiCaller().callUserInfo( @@ -558,7 +598,7 @@ private Response process(Params params, Options userInfoOpts, Options userInfoIs params.getDpop(), params.getHtm(), params.getHtu(), - userInfoOpts + params.getUserInfoOptions() ); // 'action' in the response denotes the next action which @@ -592,7 +632,7 @@ private Response process(Params params, Options userInfoOpts, Options userInfoIs case OK: // Return the user information. - return getUserInfo(params, response, headers, userInfoIssueOpts); + return getUserInfo(params, response, headers, params.getUserInfoIssueOptions()); default: // This never happens.