本文整理汇总了Java中org.pac4j.core.context.J2EContext.getRequestParameter方法的典型用法代码示例。如果您正苦于以下问题:Java J2EContext.getRequestParameter方法的具体用法?Java J2EContext.getRequestParameter怎么用?Java J2EContext.getRequestParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pac4j.core.context.J2EContext
的用法示例。
在下文中一共展示了J2EContext.getRequestParameter方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleRequest
import org.pac4j.core.context.J2EContext; //导入方法依赖的package包/类
@GetMapping(
path = {"/oauth2.0/authorize"}
)
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
J2EContext context = WebUtils.getPac4jJ2EContext(request, response);
ProfileManager manager = WebUtils.getPac4jProfileManager(request, response);
if(this.verifyAuthorizeRequest(request) && isRequestAuthenticated(manager, context)) {
String clientId = context.getRequestParameter("client_id");
OAuthRegisteredService registeredService = this.getRegisteredServiceByClientId(clientId);
try {
RegisteredServiceAccessStrategyUtils.ensureServiceAccessIsAllowed(clientId, registeredService);
} catch (Exception var8) {
LOGGER.error(var8.getMessage(), var8);
return OAuth20Utils.produceUnauthorizedErrorView();
}
ModelAndView mv = this.consentApprovalViewResolver.resolve(context, registeredService);
return !mv.isEmpty() && mv.hasView()?mv:this.redirectToCallbackRedirectUrl(manager, registeredService, context, clientId);
} else {
LOGGER.error("Authorize request verification failed");
return OAuth20Utils.produceUnauthorizedErrorView();
}
}
示例2: resolve
import org.pac4j.core.context.J2EContext; //导入方法依赖的package包/类
@Override
public ModelAndView resolve(final J2EContext context, final OAuthRegisteredService service) {
final String bypassApprovalParameter = context.getRequestParameter(OAuth20Constants.BYPASS_APPROVAL_PROMPT);
LOGGER.debug("bypassApprovalParameter: [{}]", bypassApprovalParameter);
/*
* Inbound request; approval handled already.
*/
if (StringUtils.isNotBlank(bypassApprovalParameter) || isConsentApprovalBypassed(context, service)) {
return new ModelAndView();
}
return redirectToApproveView(context, service);
}
示例3: handleRequest
import org.pac4j.core.context.J2EContext; //导入方法依赖的package包/类
/**
* Handle request internal model and view.
*
* @param request the request
* @param response the response
* @return the model and view
* @throws Exception the exception
*/
@GetMapping(path = OAuth20Constants.BASE_OAUTH20_URL + '/' + OAuth20Constants.AUTHORIZE_URL)
public ModelAndView handleRequest(final HttpServletRequest request, final HttpServletResponse response) throws Exception {
final J2EContext context = WebUtils.getPac4jJ2EContext(request, response);
final ProfileManager manager = WebUtils.getPac4jProfileManager(request, response);
if (!verifyAuthorizeRequest(request) || !isRequestAuthenticated(manager, context)) {
LOGGER.error("Authorize request verification failed");
return OAuth20Utils.produceUnauthorizedErrorView();
}
final String clientId = context.getRequestParameter(OAuth20Constants.CLIENT_ID);
final OAuthRegisteredService registeredService = getRegisteredServiceByClientId(clientId);
try {
RegisteredServiceAccessStrategyUtils.ensureServiceAccessIsAllowed(clientId, registeredService);
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
return OAuth20Utils.produceUnauthorizedErrorView();
}
final ModelAndView mv = this.consentApprovalViewResolver.resolve(context, registeredService);
if (!mv.isEmpty() && mv.hasView()) {
return mv;
}
return redirectToCallbackRedirectUrl(manager, registeredService, context, clientId);
}
示例4: getOAuth20ResponseType
import org.pac4j.core.context.J2EContext; //导入方法依赖的package包/类
private static OAuth20ResponseTypes getOAuth20ResponseType(final J2EContext context) {
final String responseType = context.getRequestParameter(OAuth20Constants.RESPONSE_TYPE);
final OAuth20ResponseTypes type = Arrays.stream(OAuth20ResponseTypes.values())
.filter(t -> t.getType().equalsIgnoreCase(responseType))
.findFirst()
.orElse(OAuth20ResponseTypes.CODE);
LOGGER.debug("OAuth response type is [{}]", type);
return type;
}
示例5: validate
import org.pac4j.core.context.J2EContext; //导入方法依赖的package包/类
public static Optional<Integer> validate(final J2EContext context, final RequestParameter parameter) {
try {
String[] values = context.getRequest().getParameterValues(parameter.getParameterKey());
if (values != null && values.length > 1) {
return resultOfBadRequest(ErrorResponse.of(context, "invalid_request",
String.format("Multiple values found in the request for <%s> parameter", parameter.getParameterKey())));
}
String parameterValue = context.getRequestParameter(parameter.getParameterKey());
boolean isValueMandatory = parameter.isMandatory() || context.getRequestParameters().containsKey(parameter.getParameterKey());
if (StringUtils.isBlank(parameterValue) && isValueMandatory) {
return resultOfBadRequest(ErrorResponse.of(context, parameter.getError(),
String.format("No value found in the request for <%s> parameter", parameter.getParameterKey())));
}
Optional<Integer> code;
switch (parameter) {
case SCOPE:
code = validateScopeValue(context);
break;
case RESPONSE_TYPE:
code = validateResponseType(context);
break;
default:
code = Optional.empty();
}
return code;
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.error("Error while validating OIDC request", e);
} else {
log.error("Error while validating OIDC request: {}", e.getMessage());
}
return resultOfInternalServerError(ErrorResponse.of(context, "server_error"));
}
}
示例6: validateScopeValue
import org.pac4j.core.context.J2EContext; //导入方法依赖的package包/类
private static Optional<Integer> validateScopeValue(final J2EContext context) throws Exception {
String scope = context.getRequestParameter(RequestParameter.SCOPE.name().toLowerCase());
if (!"openid".equals(scope)) {
return resultOfBadRequest(ErrorResponse.of(context, "invalid_scope",
String.format("Provided scope <%s> is not allowed by TARA, only <%s> is permitted. TARA do not allow this request to be processed", scope, "openid")));
}
return Optional.empty();
}
示例7: validateResponseType
import org.pac4j.core.context.J2EContext; //导入方法依赖的package包/类
private static Optional<Integer> validateResponseType(final J2EContext context) {
String responseType = context.getRequestParameter(RequestParameter.RESPONSE_TYPE.name().toLowerCase());
if (!"code".equals(responseType)) {
return resultOfBadRequest(ErrorResponse.of(context, "unsupported_response_type",
String.format("Provided response type <%s> is not allowed by TARA, only <%s> is permitted. TARA do not allow this request to be processed", responseType, "code")));
}
return Optional.empty();
}
示例8: redirectToCallbackRedirectUrl
import org.pac4j.core.context.J2EContext; //导入方法依赖的package包/类
protected ModelAndView redirectToCallbackRedirectUrl(ProfileManager manager, OAuthRegisteredService registeredService, J2EContext context, String clientId) throws Exception {
Optional profile = manager.get(true);
if(profile != null && profile.isPresent()) {
Service service = this.authenticationBuilder.buildService(registeredService, context, false);
LOGGER.debug("Created service [{}] based on registered service [{}]", service, registeredService);
Authentication authentication = this.authenticationBuilder.build((UserProfile)profile.get(), registeredService, context, service);
LOGGER.debug("Created OAuth authentication [{}] for service [{}]", service, authentication);
try {
RegisteredServiceAccessStrategyUtils.ensurePrincipalAccessIsAllowedForService(service, registeredService, authentication);
} catch (PrincipalException | UnauthorizedServiceException var13) {
LOGGER.error(var13.getMessage(), var13);
return OAuth20Utils.produceUnauthorizedErrorView();
}
String redirectUri = context.getRequestParameter("redirect_uri");
LOGGER.debug("Authorize request verification successful for client [{}] with redirect uri [{}]", clientId, redirectUri);
String responseType = context.getRequestParameter("response_type");
TicketGrantingTicket ticketGrantingTicket = CookieUtils.getTicketGrantingTicketFromRequest(this.ticketGrantingTicketCookieGenerator, this.ticketRegistry, context.getRequest());
String callbackUrl;
if(OAuth20Utils.isResponseType(responseType, OAuth20ResponseTypes.CODE)) {
callbackUrl = this.buildCallbackUrlForAuthorizationCodeResponseType(authentication, service, redirectUri, ticketGrantingTicket);
} else if(OAuth20Utils.isResponseType(responseType, OAuth20ResponseTypes.TOKEN)) {
AccessTokenRequestDataHolder holder = new AccessTokenRequestDataHolder(service, authentication, registeredService, ticketGrantingTicket);
callbackUrl = this.buildCallbackUrlForImplicitTokenResponseType(holder, redirectUri);
} else {
callbackUrl = this.buildCallbackUrlForTokenResponseType(context, authentication, service, redirectUri, responseType, clientId);
}
LOGGER.debug("Callback URL to redirect: [{}]", callbackUrl);
context.getRequest().getSession().invalidate();
removeCookie(context);
return StringUtils.isBlank(callbackUrl)?OAuth20Utils.produceUnauthorizedErrorView():OAuth20Utils.redirectTo(callbackUrl);
} else {
LOGGER.error("Unexpected null profile from profile manager. Request is not fully authenticated.");
return OAuth20Utils.produceUnauthorizedErrorView();
}
}
示例9: getOAuth20ResponseType
import org.pac4j.core.context.J2EContext; //导入方法依赖的package包/类
private static OAuth20ResponseTypes getOAuth20ResponseType(J2EContext context) {
String responseType = context.getRequestParameter("response_type");
OAuth20ResponseTypes type = Arrays.stream(OAuth20ResponseTypes.values()).filter((t) ->
t.getType().equalsIgnoreCase(responseType)
).findFirst().orElse(OAuth20ResponseTypes.CODE);
LOGGER.debug("OAuth response type is [{}]", type);
return type;
}
示例10: redirectToCallbackRedirectUrl
import org.pac4j.core.context.J2EContext; //导入方法依赖的package包/类
/**
* Redirect to callback redirect url model and view.
*
* @param manager the manager
* @param registeredService the registered service
* @param context the context
* @param clientId the client id
* @return the model and view
* @throws Exception the exception
*/
protected ModelAndView redirectToCallbackRedirectUrl(final ProfileManager manager,
final OAuthRegisteredService registeredService,
final J2EContext context,
final String clientId) throws Exception {
final Optional<UserProfile> profile = manager.get(true);
if (profile == null || !profile.isPresent()) {
LOGGER.error("Unexpected null profile from profile manager. Request is not fully authenticated.");
return OAuth20Utils.produceUnauthorizedErrorView();
}
final Service service = this.authenticationBuilder.buildService(registeredService, context, false);
LOGGER.debug("Created service [{}] based on registered service [{}]", service, registeredService);
final Authentication authentication = this.authenticationBuilder.build(profile.get(), registeredService, context, service);
LOGGER.debug("Created OAuth authentication [{}] for service [{}]", service, authentication);
try {
RegisteredServiceAccessStrategyUtils.ensurePrincipalAccessIsAllowedForService(service, registeredService, authentication);
} catch (final UnauthorizedServiceException | PrincipalException e) {
LOGGER.error(e.getMessage(), e);
return OAuth20Utils.produceUnauthorizedErrorView();
}
final String redirectUri = context.getRequestParameter(OAuth20Constants.REDIRECT_URI);
LOGGER.debug("Authorize request verification successful for client [{}] with redirect uri [{}]", clientId, redirectUri);
final String responseType = context.getRequestParameter(OAuth20Constants.RESPONSE_TYPE);
final TicketGrantingTicket ticketGrantingTicket = CookieUtils.getTicketGrantingTicketFromRequest(
ticketGrantingTicketCookieGenerator, this.ticketRegistry, context.getRequest());
final String callbackUrl;
if (OAuth20Utils.isResponseType(responseType, OAuth20ResponseTypes.CODE)) {
callbackUrl = buildCallbackUrlForAuthorizationCodeResponseType(authentication, service, redirectUri, ticketGrantingTicket);
} else if (OAuth20Utils.isResponseType(responseType, OAuth20ResponseTypes.TOKEN)) {
final AccessTokenRequestDataHolder holder = new AccessTokenRequestDataHolder(service, authentication,
registeredService, ticketGrantingTicket);
callbackUrl = buildCallbackUrlForImplicitTokenResponseType(holder, redirectUri);
} else {
callbackUrl = buildCallbackUrlForTokenResponseType(context, authentication, service, redirectUri, responseType, clientId);
}
LOGGER.debug("Callback URL to redirect: [{}]", callbackUrl);
if (StringUtils.isBlank(callbackUrl)) {
return OAuth20Utils.produceUnauthorizedErrorView();
}
return OAuth20Utils.redirectTo(callbackUrl);
}