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


Java RequestContext类代码示例

本文整理汇总了Java中org.springframework.webflow.execution.RequestContext的典型用法代码示例。如果您正苦于以下问题:Java RequestContext类的具体用法?Java RequestContext怎么用?Java RequestContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testOIDCAuthnRequestNoFlags

import org.springframework.webflow.execution.RequestContext; //导入依赖的package包/类
/**
 * Test that the action functions properly if the inbound message is a oidc
 * authentication request. Check that client id is set to rp ctx.
 */
@Test
public void testOIDCAuthnRequestNoFlags() throws Exception {
    AuthenticationRequest req = AuthenticationRequest
            .parse("response_type=code&client_id=s6BhdRkqt3&login_hint=foo&redirect_uri=https%3A%2F%2Fclient.example.org%2Fcb&scope=openid%20profile&state=af0ifjsldkj&nonce=n-0S6_WzA2Mj");
    final RequestContext requestCtx = new RequestContextBuilder().setInboundMessage(req).buildRequestContext();
    @SuppressWarnings("rawtypes")
    final ProfileRequestContext prc = new WebflowRequestContextProfileRequestContextLookup().apply(requestCtx);
    final InitializeRelyingPartyContext action = new InitializeRelyingPartyContext();
    action.initialize();
    final Event event = action.execute(requestCtx);
    ActionTestingSupport.assertProceedEvent(event);
    RelyingPartyContext rpCtx = prc.getSubcontext(RelyingPartyContext.class);
    Assert.assertEquals(rpCtx.getRelyingPartyId(), "s6BhdRkqt3");

}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:20,代码来源:InitializeRelyingPartyContextTest.java

示例2: testOIDCAuthnRequestNoFlags

import org.springframework.webflow.execution.RequestContext; //导入依赖的package包/类
/**
 * Test that the action functions properly if the inbound message is a oidc
 * authentication request.
 */
@Test
public void testOIDCAuthnRequestNoFlags() throws Exception {
    AuthenticationRequest req = AuthenticationRequest
            .parse("response_type=code&client_id=s6BhdRkqt3&login_hint=foo&redirect_uri=https%3A%2F%2Fclient.example.org%2Fcb&scope=openid%20profile&state=af0ifjsldkj&nonce=n-0S6_WzA2Mj");
    final RequestContext requestCtx = new RequestContextBuilder().setInboundMessage(req).buildRequestContext();
    @SuppressWarnings("rawtypes")
    final ProfileRequestContext prc = new WebflowRequestContextProfileRequestContextLookup().apply(requestCtx);
    final InitializeAuthenticationContext action = new InitializeAuthenticationContext();
    action.initialize();
    final Event event = action.execute(requestCtx);
    ActionTestingSupport.assertProceedEvent(event);
    AuthenticationContext authnCtx = prc.getSubcontext(AuthenticationContext.class);
    Assert.assertFalse(authnCtx.isForceAuthn());
    Assert.assertFalse(authnCtx.isPassive());
    Assert.assertEquals(authnCtx.getHintedName(), "foo");

}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:22,代码来源:InitializeAuthenticationContextTest.java

示例3: constructCredentialsFromRequest

import org.springframework.webflow.execution.RequestContext; //导入依赖的package包/类
@Override
protected Credential constructCredentialsFromRequest(final RequestContext context) {
    final String ticketGrantingTicketId = WebUtils.getTicketGrantingTicketId(context);
    final String userName = this.extractor
            .extractLocalUsernameFromUri(context.getRequestParameters()
                    .get("openid.identity"));
    final Service service = WebUtils.getService(context);

    context.getExternalContext().getSessionMap().put("openIdLocalId", userName);

    // clear the service because otherwise we can fake the username
    if (service instanceof OpenIdService && userName == null) {
        context.getFlowScope().remove("service");
    }

    if (ticketGrantingTicketId == null || userName == null) {
        return null;
    }

    return new OpenIdCredential(
            ticketGrantingTicketId, userName);
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:23,代码来源:OpenIdSingleSignOnAction.java

示例4: constructCredentialsFromRequest

import org.springframework.webflow.execution.RequestContext; //导入依赖的package包/类
@Override
protected Credential constructCredentialsFromRequest(final RequestContext requestContext) {
    final HttpServletRequest request = WebUtils.getHttpServletRequest(requestContext);
    final HttpServletResponse response = WebUtils.getHttpServletResponse(requestContext);
    final BasicAuthExtractor extractor = new BasicAuthExtractor(this.getClass().getSimpleName());
    final WebContext webContext = new J2EContext(request, response);
    try {
        final UsernamePasswordCredentials credentials = extractor.extract(webContext);
        if (credentials != null) {
            LOGGER.debug("Received basic authentication request from credentials {} ", credentials);
            return new UsernamePasswordCredential(credentials.getUsername(), credentials.getPassword());
        }
    } catch (final Exception e) {
        LOGGER.warn(e.getMessage(), e);

    }
    return null;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:19,代码来源:BasicAuthenticationAction.java

示例5: constructCredentialsFromRequest

import org.springframework.webflow.execution.RequestContext; //导入依赖的package包/类
@Override
protected Credential constructCredentialsFromRequest(final RequestContext requestContext) {
    try {
        final HttpServletRequest request = WebUtils.getHttpServletRequest(requestContext);
        final HttpServletResponse response = WebUtils.getHttpServletResponse(requestContext);
        final BasicAuthExtractor extractor = new BasicAuthExtractor(this.getClass().getSimpleName());
        final WebContext webContext = WebUtils.getPac4jJ2EContext(request, response);
        final UsernamePasswordCredentials credentials = extractor.extract(webContext);
        if (credentials != null) {
            LOGGER.debug("Received basic authentication request from credentials [{}]", credentials);
            return new UsernamePasswordCredential(credentials.getUsername(), credentials.getPassword());
        }
    } catch (final Exception e) {
        LOGGER.warn(e.getMessage(), e);
    }
    return null;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:18,代码来源:BasicAuthenticationAction.java

示例6: constructCredentialsFromRequest

import org.springframework.webflow.execution.RequestContext; //导入依赖的package包/类
@Override
protected Credential constructCredentialsFromRequest(
        final RequestContext context) {
    final HttpServletRequest request = WebUtils
            .getHttpServletRequest(context);
    final Principal principal = request.getUserPrincipal();

    if (principal != null) {

        logger.debug("UserPrincipal [{}] found in HttpServletRequest", principal.getName());
        return new PrincipalBearingCredential(new SimplePrincipal(
                principal.getName()));
    }

    logger.debug("UserPrincipal not found in HttpServletRequest.");
    return null;
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:18,代码来源:PrincipalFromRequestUserPrincipalNonInteractiveCredentialsAction.java

示例7: isAuthenticationRenewed

import org.springframework.webflow.execution.RequestContext; //导入依赖的package包/类
/**
 * Tries to determine if authentication was created as part of a "renew" event.
 * Renewed authentications can occur if the service is not allowed to participate
 * in SSO or if a "renew" request parameter is specified.
 *
 * @param ctx the request context
 * @return true if renewed
 */
private boolean isAuthenticationRenewed(final RequestContext ctx) {
    if (ctx.getRequestParameters().contains(CasProtocolConstants.PARAMETER_RENEW)) {
        LOGGER.debug("[{}] is specified for the request. The authentication session will be considered renewed.",
                CasProtocolConstants.PARAMETER_RENEW);
        return true;
    }

    final Service service = WebUtils.getService(ctx);
    if (service != null) {
        final RegisteredService registeredService = this.servicesManager.findServiceBy(service);
        if (registeredService != null) {
            final boolean isAllowedForSso = registeredService.getAccessStrategy().isServiceAccessAllowedForSso();
            LOGGER.debug("Located [{}] in registry. Service access to participate in SSO is set to [{}]",
                    registeredService.getServiceId(), isAllowedForSso);
            return !isAllowedForSso;
        }
    }

    return false;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:29,代码来源:SendTicketGrantingTicketAction.java

示例8: setResponseHeader

import org.springframework.webflow.execution.RequestContext; //导入依赖的package包/类
/**
 * Sets the response header based on the retrieved token.
 *
 * @param context    the context
 */
private void setResponseHeader(final RequestContext context) {
    final Credential credential = WebUtils.getCredential(context);
    
    if (credential == null) {
        LOGGER.debug("No credential was provided. No response header set.");
        return;
    }

    final HttpServletResponse response = WebUtils.getHttpServletResponse(context);
    final SpnegoCredential spnegoCredentials = (SpnegoCredential) credential;
    final byte[] nextToken = spnegoCredentials.getNextToken();
    if (nextToken != null) {
        LOGGER.debug("Obtained output token: [{}]", new String(nextToken, Charset.defaultCharset()));
        response.setHeader(SpnegoConstants.HEADER_AUTHENTICATE, (this.ntlm
                ? SpnegoConstants.NTLM : SpnegoConstants.NEGOTIATE)
                + ' ' + EncodingUtils.encodeBase64(nextToken));
    } else {
        LOGGER.debug("Unable to obtain the output token required.");
    }

    if (spnegoCredentials.getPrincipal() == null && this.send401OnAuthenticationFailure) {
        LOGGER.debug("Setting HTTP Status to 401");
        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:31,代码来源:SpnegoCredentialsAction.java

示例9: constructCredentialsFromRequest

import org.springframework.webflow.execution.RequestContext; //导入依赖的package包/类
@Override
protected Credential constructCredentialsFromRequest(
        final RequestContext context) {
    final HttpServletRequest request = WebUtils
            .getHttpServletRequest(context);
    final Principal principal = request.getUserPrincipal();

    if (principal != null) {

        logger.debug("UserPrincipal [{}] found in HttpServletRequest", principal.getName());
        return new PrincipalBearingCredential(this.principalFactory.createPrincipal(principal.getName()));
    }

    logger.debug("UserPrincipal not found in HttpServletRequest.");
    return null;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:17,代码来源:PrincipalFromRequestUserPrincipalNonInteractiveCredentialsAction.java

示例10: getRemoteIp

import org.springframework.webflow.execution.RequestContext; //导入依赖的package包/类
/**
 * Pulls the remote IP from the current HttpServletRequest, or grabs the value
 * for the specified alternative attribute (say, for proxied requests).  Falls
 * back to providing the "normal" remote address if no value can be retrieved
 * from the specified alternative header value.
 * @param context the context
 * @return the remote ip
 */
private String getRemoteIp(@NotNull final RequestContext context) {
    final HttpServletRequest request = WebUtils.getHttpServletRequest(context);
    String userAddress = request.getRemoteAddr();
    logger.debug("Remote Address = {}", userAddress);

    if (StringUtils.isNotBlank(this.alternativeRemoteHostAttribute)) {

        userAddress = request.getHeader(this.alternativeRemoteHostAttribute);
        logger.debug("Header Attribute [{}] = [{}]", this.alternativeRemoteHostAttribute, userAddress);

        if (StringUtils.isBlank(userAddress)) {
            userAddress = request.getRemoteAddr();
            logger.warn("No value could be retrieved from the header [{}]. Falling back to [{}].",
                    this.alternativeRemoteHostAttribute, userAddress);
        }
    }
    return userAddress;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:27,代码来源:BaseSpnegoKnownClientSystemsFilterAction.java

示例11: doExecute

import org.springframework.webflow.execution.RequestContext; //导入依赖的package包/类
@Override
protected Event doExecute(final RequestContext requestContext) throws Exception {
    final HttpServletRequest request = WebUtils.getHttpServletRequest(requestContext);
    final String username = requestContext.getFlowScope().getString("username");
    final PasswordManagementProperties pm = casProperties.getAuthn().getPm();

    if (!pm.getReset().isSecurityQuestionsEnabled()) {
        LOGGER.debug("Security questions are not enabled");
        return success();
    }
    
    final Map<String, String> questions = passwordManagementService.getSecurityQuestions(username);
    final AtomicInteger i = new AtomicInteger(0);
    final long c = questions.values().stream().filter(v -> {
        final String answer = request.getParameter("q" + i.getAndIncrement());
        return answer.equals(v);
    }).count();
    if (c == questions.size()) {
        return success();
    }
    return error();
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:23,代码来源:VerifySecurityQuestionsAction.java

示例12: onSetUp

import org.springframework.webflow.execution.RequestContext; //导入依赖的package包/类
@Before
public void onSetUp() throws Exception {
    this.request = new MockHttpServletRequest();
    this.response = new MockHttpServletResponse();
    this.requestContext = mock(RequestContext.class);
    final ServletExternalContext servletExternalContext = mock(ServletExternalContext.class);
    when(this.requestContext.getExternalContext()).thenReturn(servletExternalContext);
    when(servletExternalContext.getNativeRequest()).thenReturn(request);
    when(servletExternalContext.getNativeResponse()).thenReturn(response);
    final LocalAttributeMap flowScope = new LocalAttributeMap();
    when(this.requestContext.getFlowScope()).thenReturn(flowScope);

    this.warnCookieGenerator = new CookieRetrievingCookieGenerator();
    this.serviceRegistryDao = new InMemoryServiceRegistryDaoImpl();
    this.serviceManager = new DefaultServicesManagerImpl(serviceRegistryDao);
    this.serviceManager.setApplicationEventPublisher(mock(ApplicationEventPublisher.class));
    this.serviceManager.reload();

    this.warnCookieGenerator.setCookieName("test");

    this.ticketGrantingTicketCookieGenerator = new CookieRetrievingCookieGenerator();
    this.ticketGrantingTicketCookieGenerator.setCookieName(COOKIE_TGC_ID);

    this.logoutAction = new LogoutAction();
    this.logoutAction.setServicesManager(this.serviceManager);
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:27,代码来源:LogoutActionTests.java

示例13: verifyGetServiceThemeDoesNotExist

import org.springframework.webflow.execution.RequestContext; //导入依赖的package包/类
@Test
public void verifyGetServiceThemeDoesNotExist() {
    final RegisteredServiceImpl r = new RegisteredServiceImpl();
    r.setTheme("myTheme");
    r.setId(1000);
    r.setName("Test Service");
    r.setServiceId("myServiceId");

    this.servicesManager.save(r);

    final MockHttpServletRequest request = new MockHttpServletRequest();
    final RequestContext ctx = mock(RequestContext.class);
    final MutableAttributeMap scope = new LocalAttributeMap();
    scope.put("service", org.jasig.cas.services.TestUtils.getService(r.getServiceId()));
    when(ctx.getFlowScope()).thenReturn(scope);
    RequestContextHolder.setRequestContext(ctx);
    request.addHeader("User-Agent", "Mozilla");
    assertEquals("test", this.serviceThemeResolver.resolveThemeName(request));
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:20,代码来源:ServiceThemeResolverTests.java

示例14: doExecute

import org.springframework.webflow.execution.RequestContext; //导入依赖的package包/类
@Override
protected Event doExecute(RequestContext context) throws Exception {
    Credential credential = WebUtils.getCredential(context);
    //系统信息不为空才检测校验码
    if(credential instanceof UsernamePasswordSysCredential && ((UsernamePasswordSysCredential) credential).getSystem() != null) {
        if (isEnable()) {
            LOGGER.debug("开始校验登录校验码");
            HttpServletRequest request = WebUtils.getHttpServletRequest();
            HttpSession httpSession = request.getSession();
            //校验码
            String inCode = request.getParameter(CODE_PARAM);
            //校验码失败跳转到登录页
            if(!this.captchaResultProvider.validate(httpSession, inCode)) {
                return getError(context);
            }
        }
    }
    return null;
}
 
开发者ID:kawhii,项目名称:sso,代码行数:20,代码来源:ValidateLoginCaptchaAction.java

示例15: isAuthenticationRenewed

import org.springframework.webflow.execution.RequestContext; //导入依赖的package包/类
/**
 * Tries to determine if authentication was created as part of a "renew" event.
 * Renewed authentications can occur if the service is not allowed to participate
 * in SSO or if a "renew" request parameter is specified.
 *
 * @param ctx the request context
 * @return true if renewed
 */
private boolean isAuthenticationRenewed(final RequestContext ctx) {
    if (ctx.getRequestParameters().contains(CasProtocolConstants.PARAMETER_RENEW)) {
        LOGGER.debug("[{}] is specified for the request. The authentication session will be considered renewed.", CasProtocolConstants.PARAMETER_RENEW);
        return true;
    }

    final Service service = WebUtils.getService(ctx);
    if (service != null) {
        final RegisteredService registeredService = this.servicesManager.findServiceBy(service);
        if (registeredService != null) {
            final boolean isAllowedForSso = registeredService.getAccessStrategy().isServiceAccessAllowedForSso();
            LOGGER.debug("Located [{}] in registry. Service access to participate in SSO is set to [{}]",
                    registeredService.getServiceId(), isAllowedForSso);
            return !isAllowedForSso;
        }
    }

    return false;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:28,代码来源:SendTicketGrantingTicketAction.java


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