本文整理汇总了Java中org.pac4j.core.context.WebContext.getRequestParameter方法的典型用法代码示例。如果您正苦于以下问题:Java WebContext.getRequestParameter方法的具体用法?Java WebContext.getRequestParameter怎么用?Java WebContext.getRequestParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pac4j.core.context.WebContext
的用法示例。
在下文中一共展示了WebContext.getRequestParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extract
import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
public TokenCredentials extract(WebContext context) throws HttpAction {
final String method = context.getRequestMethod();
if ("GET".equals(method) && !supportGetRequest) {
throw new CredentialsException("GET requests not supported");
} else if ("POST".equals(method) && !supportPostRequest) {
throw new CredentialsException("POST requests not supported");
}
final String value = context.getRequestParameter(this.parameterName);
if (value == null) {
return null;
}
return new TokenCredentials(value, clientName);
}
示例2: retrieveCredentials
import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
protected UsernamePasswordCredentials retrieveCredentials(final WebContext context) throws HttpAction {
CommonHelper.assertNotNull("credentialsExtractor", getCredentialsExtractor());
CommonHelper.assertNotNull("authenticator", getAuthenticator());
final String username = context.getRequestParameter(this.usernameParameter);
UsernamePasswordCredentials credentials;
try {
// retrieve credentials
credentials = getCredentialsExtractor().extract(context);
logger.debug("usernamePasswordCredentials: {}", credentials);
if (credentials == null) {
throw handleInvalidCredentials(context, username, "Username and password cannot be blank -> return to the form with error", MISSING_FIELD_ERROR, 401);
}
// validate credentials
getAuthenticator().validate(credentials, context);
} catch (final CredentialsException e) {
throw handleInvalidCredentials(context, username, "Credentials validation fails -> return to the form with error", computeErrorMessage(e), 403);
}
return credentials;
}
示例3: computeRedirectionToServerIfNecessary
import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
private void computeRedirectionToServerIfNecessary(final WebContext context) throws HttpAction {
final String relayStateValue = context.getRequestParameter(CasConfiguration.RELAY_STATE_PARAMETER);
// if we have a state value -> redirect to the CAS server to continue the logout process
if (CommonUtils.isNotBlank(relayStateValue)) {
final StringBuilder buffer = new StringBuilder();
buffer.append(configuration.getPrefixUrl());
if (!configuration.getPrefixUrl().endsWith("/")) {
buffer.append("/");
}
buffer.append("logout?_eventId=next&");
buffer.append(CasConfiguration.RELAY_STATE_PARAMETER);
buffer.append("=");
buffer.append(CommonUtils.urlEncode(relayStateValue));
final String redirectUrl = buffer.toString();
logger.debug("Redirection url to the CAS server: {}", redirectUrl);
throw HttpAction.redirect("Force redirect to CAS server for front channel logout", context, redirectUrl);
}
}
示例4: getOAuthCredentials
import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
protected OAuthCredentials getOAuthCredentials(final WebContext context) throws HttpAction {
final String tokenParameter = context.getRequestParameter(OAUTH_TOKEN);
final String verifierParameter = context.getRequestParameter(OAUTH_VERIFIER);
if (tokenParameter != null && verifierParameter != null) {
// get request token from session
final OAuth1RequestToken tokenSession = (OAuth1RequestToken) context.getSessionAttribute(getRequestTokenSessionAttributeName());
logger.debug("tokenRequest: {}", tokenSession);
final String token = OAuthEncoder.decode(tokenParameter);
final String verifier = OAuthEncoder.decode(verifierParameter);
logger.debug("token: {} / verifier: {}", token, verifier);
return new OAuth10Credentials(tokenSession, token, verifier, getName());
} else {
final String message = "No credential found";
throw new OAuthCredentialsException(message);
}
}
示例5: retrieveCredentials
import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
protected OpenIdCredentials retrieveCredentials(final WebContext context) throws HttpAction {
final String mode = context.getRequestParameter(OPENID_MODE);
// cancelled authentication
if (CommonHelper.areEquals(mode, CANCEL_MODE)) {
logger.debug("authentication cancelled");
return null;
}
// parameters list returned by the provider
final ParameterList parameterList = new ParameterList(context.getRequestParameters());
// retrieve the previously stored discovery information
final DiscoveryInformation discoveryInformation = (DiscoveryInformation) context
.getSessionAttribute(getDiscoveryInformationSessionAttributeName());
// create credentials
final OpenIdCredentials credentials = new OpenIdCredentials(discoveryInformation, parameterList, getName());
logger.debug("credentials: {}", credentials);
return credentials;
}
示例6: validate
import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
public void validate(final UsernamePasswordCredentials credentials, final WebContext context) throws CredentialsException {
final UsernamePasswordCredential casCredential = new UsernamePasswordCredential(credentials.getUsername(), credentials.getPassword());
try {
final String clientId = context.getRequestParameter(OAuth20Constants.CLIENT_ID);
final Service service = this.webApplicationServiceFactory.createService(clientId);
final RegisteredService registeredService = OAuth20Utils.getRegisteredOAuthService(this.servicesManager, clientId);
RegisteredServiceAccessStrategyUtils.ensureServiceAccessIsAllowed(registeredService);
final AuthenticationResult authenticationResult = this.authenticationSystemSupport
.handleAndFinalizeSingleAuthenticationTransaction(null, casCredential);
final Authentication authentication = authenticationResult.getAuthentication();
final Principal principal = authentication.getPrincipal();
final OAuthUserProfile profile = new OAuthUserProfile();
final String id = registeredService.getUsernameAttributeProvider().resolveUsername(principal, service, registeredService);
LOGGER.debug("Created profile id [{}]", id);
profile.setId(id);
final Map<String, Object> attributes = registeredService.getAttributeReleasePolicy().getAttributes(principal, service,
registeredService);
profile.addAttributes(attributes);
LOGGER.debug("Authenticated user profile [{}]", profile);
credentials.setUserProfile(profile);
} catch (final Exception e) {
throw new CredentialsException("Cannot login user using CAS internal authentication", e);
}
}
示例7: findClient
import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
/**
* Return the right client according to the web context.
*
* @param context web context
* @return the right client
*/
public T findClient(final WebContext<?> context) {
init();
final String name = context.getRequestParameter(this.clientNameParameter);
if (name == null && defaultClient != null) {
return defaultClient;
}
CommonHelper.assertNotBlank("name", name);
return findClient(name);
}
示例8: isAuthorized
import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
public boolean isAuthorized(final WebContext context, final List<CommonProfile> profiles) throws HttpAction {
final boolean checkRequest = !onlyCheckPostRequest || ContextHelper.isPost(context);
if (checkRequest) {
final String parameterToken = context.getRequestParameter(parameterName);
final String headerToken = context.getRequestHeader(headerName);
final String sessionToken = (String) context.getSessionAttribute(Pac4jConstants.CSRF_TOKEN);
return sessionToken != null && (sessionToken.equals(parameterToken) || sessionToken.equals(headerToken));
} else {
return true;
}
}
示例9: findClient
import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
/**
* Return the right client according to the web context.
*
* @param context web context
* @return the right client
*/
public Client findClient(final WebContext context) {
init();
final String name = context.getRequestParameter(this.clientNameParameter);
if (name == null && defaultClient != null) {
return defaultClient;
}
CommonHelper.assertNotBlank("name", name);
return findClient(name);
}
示例10: extract
import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
public UsernamePasswordCredentials extract(WebContext context) throws HttpAction {
final String username = context.getRequestParameter(this.usernameParameter);
final String password = context.getRequestParameter(this.passwordParameter);
if (username == null || password == null) {
return null;
}
return new UsernamePasswordCredentials(username, password, clientName);
}
示例11: hasBeenCancelled
import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
protected boolean hasBeenCancelled(final WebContext context) {
final String error = context.getRequestParameter(OAuthCredentialsException.ERROR);
// user has denied permissions
if ("access_denied".equals(error)) {
return true;
}
return false;
}
示例12: hasBeenCancelled
import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
protected boolean hasBeenCancelled(final WebContext context) {
final String error = context.getRequestParameter(OAuthCredentialsException.ERROR);
final String errorReason = context.getRequestParameter(OAuthCredentialsException.ERROR_REASON);
// user has denied permissions
if ("access_denied".equals(error) && "user_denied".equals(errorReason)) {
return true;
} else {
return false;
}
}
示例13: hasBeenCancelled
import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
protected boolean hasBeenCancelled(WebContext context) {
final String error = context.getRequestParameter(OAuthCredentialsException.ERROR);
final String errorDescription = context.getRequestParameter(OAuthCredentialsException.ERROR_DESCRIPTION);
// user has denied permissions
if ("access_denied".equals(error) && "User denied access".equals(errorDescription)) {
return true;
} else {
return false;
}
}
示例14: hasBeenCancelled
import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
protected boolean hasBeenCancelled(final WebContext context) {
final String error = context.getRequestParameter(OAuthCredentialsException.ERROR);
final String errorDescription = context.getRequestParameter(OAuthCredentialsException.ERROR_DESCRIPTION);
// user has denied permissions
if ("access_denied".equals(error)
&& ("the+user+denied+your+request".equals(errorDescription) || "the user denied your request"
.equals(errorDescription))) {
return true;
} else {
return false;
}
}
示例15: hasBeenCancelled
import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
protected boolean hasBeenCancelled(final WebContext context) {
final String denied = context.getRequestParameter("denied");
if (CommonHelper.isNotBlank(denied)) {
return true;
} else {
return false;
}
}