public class OAuth20Utils
extends java.lang.Object
| Constructor and Description |
|---|
OAuth20Utils() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
casOAuthCallbackUrl(java.lang.String serverPrefixUrl)
Cas oauth callback url.
|
static boolean |
checkCallbackValid(org.apereo.cas.services.RegisteredService registeredService,
java.lang.String redirectUri)
Check if the callback url is valid.
|
static boolean |
checkClientSecret(org.apereo.cas.support.oauth.services.OAuthRegisteredService registeredService,
java.lang.String clientSecret)
Check the client secret.
|
static boolean |
checkResponseTypes(java.lang.String type,
OAuth20ResponseTypes... expectedTypes)
Check the response type against expected response types.
|
static org.apereo.cas.support.oauth.services.OAuthRegisteredService |
getRegisteredOAuthServiceByClientId(org.apereo.cas.services.ServicesManager servicesManager,
java.lang.String clientId)
Locate the requested instance of
OAuthRegisteredService by the given clientId. |
static org.apereo.cas.support.oauth.services.OAuthRegisteredService |
getRegisteredOAuthServiceByRedirectUri(org.apereo.cas.services.ServicesManager servicesManager,
java.lang.String redirectUri)
Gets registered oauth service by redirect uri.
|
static java.util.Collection<java.lang.String> |
getRequestedScopes(javax.servlet.http.HttpServletRequest context)
Gets requested scopes.
|
static java.util.Collection<java.lang.String> |
getRequestedScopes(org.pac4j.core.context.J2EContext context)
Gets requested scopes.
|
static java.util.Map<java.lang.String,java.lang.Object> |
getRequestParameters(java.util.Collection<java.lang.String> attributes,
javax.servlet.http.HttpServletRequest context)
Gets attributes.
|
static OAuth20ResponseTypes |
getResponseType(org.pac4j.core.context.J2EContext context)
Gets response type.
|
static java.lang.String |
getServiceRequestHeaderIfAny(javax.servlet.http.HttpServletRequest context)
Gets service request header if any.
|
static boolean |
isAuthorizedGrantTypeForService(org.pac4j.core.context.J2EContext context,
org.apereo.cas.support.oauth.services.OAuthRegisteredService registeredService)
Is authorized grant type for service?
|
static boolean |
isAuthorizedGrantTypeForService(java.lang.String grantType,
org.apereo.cas.support.oauth.services.OAuthRegisteredService registeredService)
Is authorized grant type for service?
|
static boolean |
isAuthorizedResponseTypeForService(org.pac4j.core.context.J2EContext context,
org.apereo.cas.support.oauth.services.OAuthRegisteredService registeredService)
Is authorized response type for service?
|
static boolean |
isGrantType(java.lang.String type,
OAuth20GrantTypes expectedType)
Check the grant type against an expected grant type.
|
static boolean |
isResponseType(java.lang.String type,
OAuth20ResponseTypes expectedType)
Check the response type against an expected response type.
|
static java.lang.String |
jsonify(java.util.Map map)
Jsonify string.
|
static java.util.Set<java.lang.String> |
parseRequestScopes(javax.servlet.http.HttpServletRequest context)
Parse request scopes set.
|
static java.util.Set<java.lang.String> |
parseRequestScopes(org.pac4j.core.context.J2EContext context)
Parse request scopes set.
|
static org.springframework.web.servlet.ModelAndView |
produceErrorView(java.lang.Exception e)
Produce error view model and view.
|
static org.springframework.web.servlet.ModelAndView |
produceUnauthorizedErrorView()
Produce unauthorized error view model and view.
|
static org.springframework.web.servlet.ModelAndView |
redirectTo(org.springframework.web.servlet.View view)
Redirect to model and view.
|
static org.springframework.web.servlet.ModelAndView |
writeText(javax.servlet.http.HttpServletResponse response,
java.lang.String text,
int status)
Write to the output the text and return a null view.
|
static org.springframework.web.servlet.ModelAndView |
writeTextError(javax.servlet.http.HttpServletResponse response,
java.lang.String error)
Write to the output this error text and return a null view.
|
public static org.springframework.web.servlet.ModelAndView writeTextError(javax.servlet.http.HttpServletResponse response,
java.lang.String error)
response - http responseerror - error messagepublic static org.springframework.web.servlet.ModelAndView writeText(javax.servlet.http.HttpServletResponse response,
java.lang.String text,
int status)
response - http responsetext - output textstatus - status codepublic static org.springframework.web.servlet.ModelAndView redirectTo(org.springframework.web.servlet.View view)
view - the viewpublic static org.apereo.cas.support.oauth.services.OAuthRegisteredService getRegisteredOAuthServiceByClientId(org.apereo.cas.services.ServicesManager servicesManager,
java.lang.String clientId)
OAuthRegisteredService by the given clientId.servicesManager - the service registry DAO instance.clientId - the client id by which the OAuthRegisteredService is to be located.OAuthRegisteredService instance in the service registry.public static org.apereo.cas.support.oauth.services.OAuthRegisteredService getRegisteredOAuthServiceByRedirectUri(org.apereo.cas.services.ServicesManager servicesManager,
java.lang.String redirectUri)
servicesManager - the services managerredirectUri - the redirect uripublic static java.util.Map<java.lang.String,java.lang.Object> getRequestParameters(java.util.Collection<java.lang.String> attributes,
javax.servlet.http.HttpServletRequest context)
attributes - the attributescontext - the contextpublic static java.util.Collection<java.lang.String> getRequestedScopes(org.pac4j.core.context.J2EContext context)
context - the contextpublic static java.util.Collection<java.lang.String> getRequestedScopes(javax.servlet.http.HttpServletRequest context)
context - the contextpublic static org.springframework.web.servlet.ModelAndView produceUnauthorizedErrorView()
public static org.springframework.web.servlet.ModelAndView produceErrorView(java.lang.Exception e)
e - the epublic static java.lang.String casOAuthCallbackUrl(java.lang.String serverPrefixUrl)
serverPrefixUrl - the server prefix urlpublic static java.lang.String jsonify(java.util.Map map)
map - the mappublic static OAuth20ResponseTypes getResponseType(org.pac4j.core.context.J2EContext context)
context - the contextpublic static boolean isGrantType(java.lang.String type,
OAuth20GrantTypes expectedType)
type - the given grant typeexpectedType - the expected grant typepublic static boolean isResponseType(java.lang.String type,
OAuth20ResponseTypes expectedType)
type - the given response typeexpectedType - the expected response typepublic static boolean isAuthorizedResponseTypeForService(org.pac4j.core.context.J2EContext context,
org.apereo.cas.support.oauth.services.OAuthRegisteredService registeredService)
context - the contextregisteredService - the registered servicepublic static boolean isAuthorizedGrantTypeForService(java.lang.String grantType,
org.apereo.cas.support.oauth.services.OAuthRegisteredService registeredService)
grantType - the grant typeregisteredService - the registered servicepublic static boolean isAuthorizedGrantTypeForService(org.pac4j.core.context.J2EContext context,
org.apereo.cas.support.oauth.services.OAuthRegisteredService registeredService)
context - the contextregisteredService - the registered servicepublic static java.util.Set<java.lang.String> parseRequestScopes(org.pac4j.core.context.J2EContext context)
context - the contextpublic static java.util.Set<java.lang.String> parseRequestScopes(javax.servlet.http.HttpServletRequest context)
context - the contextpublic static java.lang.String getServiceRequestHeaderIfAny(javax.servlet.http.HttpServletRequest context)
context - the contextpublic static boolean checkCallbackValid(@NonNull
org.apereo.cas.services.RegisteredService registeredService,
java.lang.String redirectUri)
registeredService - the registered serviceredirectUri - the callback urlpublic static boolean checkClientSecret(org.apereo.cas.support.oauth.services.OAuthRegisteredService registeredService,
java.lang.String clientSecret)
registeredService - the registered serviceclientSecret - the client secretpublic static boolean checkResponseTypes(java.lang.String type,
OAuth20ResponseTypes... expectedTypes)
type - the current response typeexpectedTypes - the expected response types