Class RedirectionBasedGrantService
- java.lang.Object
-
- org.apache.cxf.rs.security.oauth2.services.AbstractOAuthService
-
- org.apache.cxf.rs.security.oauth2.services.RedirectionBasedGrantService
-
- Direct Known Subclasses:
AbstractImplicitGrantService,AuthorizationCodeGrantService
public abstract class RedirectionBasedGrantService extends AbstractOAuthService
The Base Redirection-Based Grant Service
-
-
Field Summary
-
Fields inherited from class org.apache.cxf.rs.security.oauth2.services.AbstractOAuthService
LOG
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedRedirectionBasedGrantService(String supportedResponseType, String supportedGrantType)protectedRedirectionBasedGrantService(Set<String> supportedResponseTypes, String supportedGrantType)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description javax.ws.rs.core.Responseauthorize()Handles the initial authorization request by preparing the authorization challenge data and returning it to the user.javax.ws.rs.core.ResponseauthorizeDecision()Processes the end user decisionjavax.ws.rs.core.ResponseauthorizeDecisionForm(javax.ws.rs.core.MultivaluedMap<String,String> params)Processes the end user decisionjavax.ws.rs.core.ResponseauthorizePost(javax.ws.rs.core.MultivaluedMap<String,String> params)Handles the initial authorization request by preparing the authorization challenge data and returning it to the user.protected booleancanAccessTokenBeReturned(String responseType)protected booleancanAuthorizationBeSkipped(javax.ws.rs.core.MultivaluedMap<String,String> params, Client client, UserSubject userSubject, List<String> requestedScope, List<OAuthPermission> permissions)protected abstract booleancanRedirectUriBeEmpty(Client c)protected abstract booleancanSupportPublicClient(Client c)protected javax.ws.rs.core.ResponsecompleteAuthorization(javax.ws.rs.core.MultivaluedMap<String,String> params)Completes the authorization processprotected OAuthAuthorizationDatacreateAuthorizationData(Client client, javax.ws.rs.core.MultivaluedMap<String,String> params, String redirectUri, UserSubject subject, List<OAuthPermission> requestedPerms, List<OAuthPermission> alreadyAuthorizedPerms, boolean authorizationCanBeSkipped)Create the authorization challenge dataprotected abstract javax.ws.rs.core.ResponsecreateErrorResponse(String state, String redirectUri, String error)protected javax.ws.rs.core.ResponsecreateErrorResponse(javax.ws.rs.core.MultivaluedMap<String,String> params, String redirectUri, String error)protected abstract javax.ws.rs.core.ResponsecreateGrant(OAuthRedirectionState state, Client client, List<String> requestedScope, List<String> approvedScope, UserSubject userSubject, ServerAccessToken preAuthorizedToken)protected javax.ws.rs.core.ResponsecreateHtmlResponse(Object response)protected UserSubjectcreateUserSubject(SecurityContext securityContext, javax.ws.rs.core.MultivaluedMap<String,String> params)protected SecurityContextgetAndValidateSecurityContext(javax.ws.rs.core.MultivaluedMap<String,String> params)protected List<String>getApprovedScope(List<String> requestedScope, List<String> approvedScope)protected ClientgetClient(String clientId, javax.ws.rs.core.MultivaluedMap<String,String> params)Get theClientreferenceprotected StringgetSupportedGrantType()Set<String>getSupportedResponseTypes()protected booleanisFormResponse(OAuthRedirectionState state)booleanisRevokePreauthorizedTokenOnApproval()protected booleannoConsentForRequestedScopes(javax.ws.rs.core.MultivaluedMap<String,String> params, Client client, UserSubject userSubject, List<String> requestedScope, List<OAuthPermission> permissions)protected voidpersonalizeData(OAuthAuthorizationData data, UserSubject userSubject)protected OAuthRedirectionStaterecreateRedirectionStateFromParams(javax.ws.rs.core.MultivaluedMap<String,String> params)protected OAuthRedirectionStaterecreateRedirectionStateFromSession(UserSubject subject, String sessionToken)voidsetAuthorizationFilter(AuthorizationRequestFilter authorizationFilter)voidsetHidePreauthorizedScopesInForm(boolean hidePreauthorizedScopesInForm)voidsetMatchRedirectUriWithApplicationUri(boolean matchRedirectUriWithApplicationUri)voidsetMaxDefaultSessionInterval(int maxDefaultSessionInterval)voidsetPartialMatchScopeValidation(boolean partialMatchScopeValidation)voidsetResourceOwnerNameProvider(ResourceOwnerNameProvider resourceOwnerNameProvider)voidsetRevokePreauthorizedTokenOnApproval(boolean revoke)voidsetScopesRequiringNoConsent(List<String> scopesRequiringNoConsent)voidsetSessionAuthenticityTokenProvider(SessionAuthenticityTokenProvider sessionAuthenticityTokenProvider)voidsetSubjectCreator(SubjectCreator creator)voidsetSupportSinglePageApplications(boolean supportSinglePageApplications)voidsetUseAllClientScopes(boolean useAllClientScopes)voidsetUseRegisteredRedirectUriIfPossible(boolean use)If a client does not include a redirect_uri parameter but has an exactly one pre-registered redirect_uri then use that redirect_uriprotected javax.ws.rs.core.ResponsestartAuthorization(javax.ws.rs.core.MultivaluedMap<String,String> params)Starts the authorization processprotected javax.ws.rs.core.ResponsestartAuthorization(javax.ws.rs.core.MultivaluedMap<String,String> params, UserSubject userSubject, Client client, String redirectUri)protected StringvalidateRedirectUri(Client client, String redirectUri)-
Methods inherited from class org.apache.cxf.rs.security.oauth2.services.AbstractOAuthService
checkTransportSecurity, getDataProvider, getMessageContext, getQueryParameters, getValidClient, getValidClient, injectContextIntoOAuthProviders, isWriteOptionalParameters, reportInvalidRequestError, reportInvalidRequestError, reportInvalidRequestError, reportInvalidRequestError, setBlockUnsecureRequests, setDataProvider, setMessageContext, setWriteOptionalParameters
-
-
-
-
Method Detail
-
authorize
@GET @Produces({"application/xhtml+xml","text/html","application/xml","application/json"}) public javax.ws.rs.core.Response authorize()Handles the initial authorization request by preparing the authorization challenge data and returning it to the user. Typically the data are expected to be presented in the HTML form- Returns:
- the authorization data
-
authorizePost
@POST @Consumes("application/x-www-form-urlencoded") @Produces({"application/xhtml+xml","text/html","application/xml","application/json"}) public javax.ws.rs.core.Response authorizePost(javax.ws.rs.core.MultivaluedMap<String,String> params)Handles the initial authorization request by preparing the authorization challenge data and returning it to the user. Typically the data are expected to be presented in the HTML form- Returns:
- the authorization data
-
authorizeDecision
@GET @Path("/decision") public javax.ws.rs.core.Response authorizeDecision()Processes the end user decision- Returns:
- The grant value, authorization code or the token
-
authorizeDecisionForm
@POST @Path("/decision") @Consumes("application/x-www-form-urlencoded") public javax.ws.rs.core.Response authorizeDecisionForm(javax.ws.rs.core.MultivaluedMap<String,String> params)Processes the end user decision- Returns:
- The grant value, authorization code or the token
-
startAuthorization
protected javax.ws.rs.core.Response startAuthorization(javax.ws.rs.core.MultivaluedMap<String,String> params)
Starts the authorization process
-
startAuthorization
protected javax.ws.rs.core.Response startAuthorization(javax.ws.rs.core.MultivaluedMap<String,String> params, UserSubject userSubject, Client client, String redirectUri)
-
canAuthorizationBeSkipped
protected boolean canAuthorizationBeSkipped(javax.ws.rs.core.MultivaluedMap<String,String> params, Client client, UserSubject userSubject, List<String> requestedScope, List<OAuthPermission> permissions)
-
noConsentForRequestedScopes
protected boolean noConsentForRequestedScopes(javax.ws.rs.core.MultivaluedMap<String,String> params, Client client, UserSubject userSubject, List<String> requestedScope, List<OAuthPermission> permissions)
-
createAuthorizationData
protected OAuthAuthorizationData createAuthorizationData(Client client, javax.ws.rs.core.MultivaluedMap<String,String> params, String redirectUri, UserSubject subject, List<OAuthPermission> requestedPerms, List<OAuthPermission> alreadyAuthorizedPerms, boolean authorizationCanBeSkipped)
Create the authorization challenge data
-
recreateRedirectionStateFromSession
protected OAuthRedirectionState recreateRedirectionStateFromSession(UserSubject subject, String sessionToken)
-
recreateRedirectionStateFromParams
protected OAuthRedirectionState recreateRedirectionStateFromParams(javax.ws.rs.core.MultivaluedMap<String,String> params)
-
personalizeData
protected void personalizeData(OAuthAuthorizationData data, UserSubject userSubject)
-
getApprovedScope
protected List<String> getApprovedScope(List<String> requestedScope, List<String> approvedScope)
-
completeAuthorization
protected javax.ws.rs.core.Response completeAuthorization(javax.ws.rs.core.MultivaluedMap<String,String> params)
Completes the authorization process
-
isRevokePreauthorizedTokenOnApproval
public boolean isRevokePreauthorizedTokenOnApproval()
-
setRevokePreauthorizedTokenOnApproval
public void setRevokePreauthorizedTokenOnApproval(boolean revoke)
-
setSessionAuthenticityTokenProvider
public void setSessionAuthenticityTokenProvider(SessionAuthenticityTokenProvider sessionAuthenticityTokenProvider)
-
setSubjectCreator
public void setSubjectCreator(SubjectCreator creator)
-
createUserSubject
protected UserSubject createUserSubject(SecurityContext securityContext, javax.ws.rs.core.MultivaluedMap<String,String> params)
-
createErrorResponse
protected javax.ws.rs.core.Response createErrorResponse(javax.ws.rs.core.MultivaluedMap<String,String> params, String redirectUri, String error)
-
canAccessTokenBeReturned
protected boolean canAccessTokenBeReturned(String responseType)
-
createErrorResponse
protected abstract javax.ws.rs.core.Response createErrorResponse(String state, String redirectUri, String error)
-
createGrant
protected abstract javax.ws.rs.core.Response createGrant(OAuthRedirectionState state, Client client, List<String> requestedScope, List<String> approvedScope, UserSubject userSubject, ServerAccessToken preAuthorizedToken)
-
getAndValidateSecurityContext
protected SecurityContext getAndValidateSecurityContext(javax.ws.rs.core.MultivaluedMap<String,String> params)
-
getClient
protected Client getClient(String clientId, javax.ws.rs.core.MultivaluedMap<String,String> params)
Get theClientreference- Parameters:
params- request parameters- Returns:
- Client the client reference
-
createHtmlResponse
protected javax.ws.rs.core.Response createHtmlResponse(Object response)
-
isFormResponse
protected boolean isFormResponse(OAuthRedirectionState state)
-
getSupportedGrantType
protected String getSupportedGrantType()
-
setResourceOwnerNameProvider
public void setResourceOwnerNameProvider(ResourceOwnerNameProvider resourceOwnerNameProvider)
-
setPartialMatchScopeValidation
public void setPartialMatchScopeValidation(boolean partialMatchScopeValidation)
-
setUseAllClientScopes
public void setUseAllClientScopes(boolean useAllClientScopes)
-
setUseRegisteredRedirectUriIfPossible
public void setUseRegisteredRedirectUriIfPossible(boolean use)
If a client does not include a redirect_uri parameter but has an exactly one pre-registered redirect_uri then use that redirect_uri- Parameters:
use- allows to use a single registered redirect_uri if set to true (default)
-
canSupportPublicClient
protected abstract boolean canSupportPublicClient(Client c)
-
canRedirectUriBeEmpty
protected abstract boolean canRedirectUriBeEmpty(Client c)
-
setMaxDefaultSessionInterval
public void setMaxDefaultSessionInterval(int maxDefaultSessionInterval)
-
setMatchRedirectUriWithApplicationUri
public void setMatchRedirectUriWithApplicationUri(boolean matchRedirectUriWithApplicationUri)
-
setHidePreauthorizedScopesInForm
public void setHidePreauthorizedScopesInForm(boolean hidePreauthorizedScopesInForm)
-
setAuthorizationFilter
public void setAuthorizationFilter(AuthorizationRequestFilter authorizationFilter)
-
setScopesRequiringNoConsent
public void setScopesRequiringNoConsent(List<String> scopesRequiringNoConsent)
-
setSupportSinglePageApplications
public void setSupportSinglePageApplications(boolean supportSinglePageApplications)
-
-