当前位置: 首页>>代码示例>>Java>>正文


Java WebContext.setSessionAttribute方法代码示例

本文整理汇总了Java中org.pac4j.core.context.WebContext.setSessionAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java WebContext.setSessionAttribute方法的具体用法?Java WebContext.setSessionAttribute怎么用?Java WebContext.setSessionAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.pac4j.core.context.WebContext的用法示例。


在下文中一共展示了WebContext.setSessionAttribute方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: get

import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
public String get(final WebContext context) {
    String token = (String) context.getSessionAttribute(Pac4jConstants.CSRF_TOKEN);
    if (token == null) {
        synchronized (this) {
            token = (String) context.getSessionAttribute(Pac4jConstants.CSRF_TOKEN);
            if (token == null) {
                token = java.util.UUID.randomUUID().toString();
                context.setSessionAttribute(Pac4jConstants.CSRF_TOKEN, token);
            }
        }
    }
    return token;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:15,代码来源:DefaultCsrfTokenGenerator.java

示例2: getCredentials

import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
/**
 * <p>Get the credentials from the web context. In some cases, a {@link HttpAction} may be thrown:</p>
 * <ul>
 * <li>if the <code>CasClient</code> receives a logout request, it returns a 200 HTTP status code</li>
 * <li>for the <code>IndirectBasicAuthClient</code>, if no credentials are sent to the callback url, an unauthorized response (401 HTTP status
 * code) is returned to request credentials through a popup.</li>
 * </ul>
 *
 * @param context the current web context
 * @return the credentials
 * @throws HttpAction whether an additional HTTP action is required
 */
@Override
public final C getCredentials(final WebContext context) throws HttpAction {
    init(context);
    final C credentials = retrieveCredentials(context);
    // no credentials -> save this authentication has already been tried and failed
    if (credentials == null) {
        context.setSessionAttribute(getName() + ATTEMPTED_AUTHENTICATION_SUFFIX, "true");
    } else {
        cleanAttemptedAuthentication(context);
    }
    return credentials;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:25,代码来源:IndirectClient.java

示例3: addStateAndNonceParameters

import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
protected void addStateAndNonceParameters(final WebContext context, final Map<String, String> params) {
    // Init state for CSRF mitigation
    State state = new State();
    params.put(OidcConfiguration.STATE, state.getValue());
    context.setSessionAttribute(OidcConfiguration.STATE_SESSION_ATTRIBUTE, state);
    // Init nonce for replay attack mitigation
    if (configuration.isUseNonce()) {
        Nonce nonce = new Nonce();
        params.put(OidcConfiguration.NONCE, nonce.getValue());
        context.setSessionAttribute(OidcConfiguration.NONCE_SESSION_ATTRIBUTE, nonce.getValue());
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:13,代码来源:OidcRedirectActionBuilder.java

示例4: getStateParameter

import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
protected String getStateParameter(final WebContext webContext) {
    final String relayState = (String) webContext.getSessionAttribute(SAML_RELAY_STATE_ATTRIBUTE);
    // clean from session after retrieving it
    webContext.setSessionAttribute(SAML_RELAY_STATE_ATTRIBUTE, "");
    return (relayState == null) ? computeFinalCallbackUrl(webContext) : relayState;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:8,代码来源:SAML2Client.java

示例5: testRelayState

import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Test
public void testRelayState() throws HttpAction {
    final SAML2Client client = getClient();
    final WebContext context = new J2EContext(new MockHttpServletRequest(), new MockHttpServletResponse());
    context.setSessionAttribute(SAML2Client.SAML_RELAY_STATE_ATTRIBUTE, "relayState");
    final RedirectAction action = client.getRedirectAction(context);
    assertTrue(action.getContent().contains("<input type=\"hidden\" name=\"RelayState\" value=\"relayState\"/>"));
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:9,代码来源:PostSAML2ClientTests.java

示例6: testRelayState

import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Test
public void testRelayState() throws Exception {
    final SAML2Client client = getClient();
    final WebContext context = new J2EContext(new MockHttpServletRequest(), new MockHttpServletResponse());
    context.setSessionAttribute(SAML2Client.SAML_RELAY_STATE_ATTRIBUTE, "relayState");
    final RedirectAction action = client.getRedirectAction(context);
    assertTrue(action.getLocation().contains("RelayState=relayState"));
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:9,代码来源:RedirectSAML2ClientTests.java

示例7: retrieveAuthorizationUrl

import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
protected String retrieveAuthorizationUrl(final WebContext context) throws HttpAction {
    final OAuth1RequestToken requestToken = this.service.getRequestToken();
    logger.debug("requestToken: {}", requestToken);
    // save requestToken in user session
    context.setSessionAttribute(getRequestTokenSessionAttributeName(), requestToken);
    final String authorizationUrl = this.service.getAuthorizationUrl(requestToken);
    logger.debug("authorizationUrl: {}", authorizationUrl);
    return authorizationUrl;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:11,代码来源:BaseOAuth10Client.java

示例8: buildOAuthConfig

import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
protected OAuthConfig buildOAuthConfig(WebContext context) {
    final String state = getStateParameter(context);
    logger.debug("save sessionState: {}", state);
    // the state is held in a specific context.
    context.setSessionAttribute(getName() + STATE_PARAMETER, state);
    return new OAuthConfig(this.getKey(), this.getSecret(), computeFinalCallbackUrl(context),
            SignatureType.Header, getOAuthScope(), null, this.getConnectTimeout(), this.getReadTimeout(), hasOAuthGrantType() ? "authorization_code" : null, state, this.getResponseType());
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:10,代码来源:BaseOAuth20StateClient.java

示例9: retrieveRedirectAction

import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
@SuppressWarnings("rawtypes")
protected RedirectAction retrieveRedirectAction(final WebContext context) throws HttpAction {
    final String userIdentifier = getUser(context);
    CommonHelper.assertNotBlank("openIdUser", userIdentifier);

    try {
        // perform discovery on the user-supplied identifier
        final List discoveries = this.consumerManager.discover(userIdentifier);

        // attempt to associate with the OpenID provider
        // and retrieve one service endpoint for authentication
        final DiscoveryInformation discoveryInformation = this.consumerManager.associate(discoveries);

        // save discovery information in session
        context.setSessionAttribute(getDiscoveryInformationSessionAttributeName(), discoveryInformation);

        // create authentication request to be sent to the OpenID provider
        final AuthRequest authRequest = this.consumerManager.authenticate(discoveryInformation,
                computeFinalCallbackUrl(context));

        // create fetch request for attributes
        final FetchRequest fetchRequest = getFetchRequest();
        if (fetchRequest != null) {
            authRequest.addExtension(fetchRequest);
        }

        final String redirectionUrl = authRequest.getDestinationUrl(true);
        logger.debug("redirectionUrl: {}", redirectionUrl);
        return RedirectAction.redirect(redirectionUrl);
    } catch (final OpenIDException e) {
        throw new TechnicalException("OpenID exception", e);
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:35,代码来源:BaseOpenIdClient.java

示例10: cleanRequestedUrl

import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
private void cleanRequestedUrl(final WebContext context) {
    context.setSessionAttribute(Pac4jConstants.REQUESTED_URL, "");
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:4,代码来源:IndirectClient.java

示例11: cleanAttemptedAuthentication

import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
private void cleanAttemptedAuthentication(final WebContext context) {
    context.setSessionAttribute(getName() + ATTEMPTED_AUTHENTICATION_SUFFIX, "");
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:4,代码来源:IndirectClient.java


注:本文中的org.pac4j.core.context.WebContext.setSessionAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。