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


Java RequestContextHolder类代码示例

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


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

示例1: verifyGetServiceThemeDoesNotExist

import org.springframework.webflow.execution.RequestContextHolder; //导入依赖的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:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:20,代码来源:ServiceThemeResolverTests.java

示例2: verifyGetServiceWithTheme

import org.springframework.webflow.execution.RequestContextHolder; //导入依赖的package包/类
@Test
public void verifyGetServiceWithTheme() throws Exception {
    final MockRequestContext requestContext = new MockRequestContext();
    RequestContextHolder.setRequestContext(requestContext);

    final WebApplicationService webApplicationService = new WebApplicationServiceFactory().createService("myServiceId");
    requestContext.getFlowScope().put("service", webApplicationService);

    final ResourceLoader loader = mock(ResourceLoader.class);
    final Resource resource = mock(Resource.class);
    when(resource.exists()).thenReturn(true);
    when(loader.getResource(anyString())).thenReturn(resource);

    this.registeredServiceThemeBasedViewResolver.setResourceLoader(loader);

    assertEquals("/WEB-INF/view/jsp/myTheme/ui/casLoginView",
            this.registeredServiceThemeBasedViewResolver.buildView("casLoginView").getUrl());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:19,代码来源:RegisteredServiceThemeBasedViewResolverTests.java

示例3: verifyGetServiceThemeDoesNotExist

import org.springframework.webflow.execution.RequestContextHolder; //导入依赖的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", TestUtils.getService(r.getServiceId()));
    when(ctx.getFlowScope()).thenReturn(scope);
    RequestContextHolder.setRequestContext(ctx);
    request.addHeader("User-Agent", "Mozilla");
    assertEquals("test", this.serviceThemeResolver.resolveThemeName(request));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:20,代码来源:ServiceThemeResolverTests.java

示例4: doAuthentication

import org.springframework.webflow.execution.RequestContextHolder; //导入依赖的package包/类
@Override
protected HandlerResult doAuthentication(final Credential credential) throws GeneralSecurityException, PreventedException {
    try {
        final RadiusTokenCredential radiusCredential = (RadiusTokenCredential) credential;
        final String password = radiusCredential.getToken();

        final RequestContext context = RequestContextHolder.getRequestContext();
        final String username = WebUtils.getAuthentication(context).getPrincipal().getId();

        final Pair<Boolean, Optional<Map<String, Object>>> result =
                RadiusUtils.authenticate(username, password, this.servers,
                        this.failoverOnAuthenticationFailure, this.failoverOnException);
        if (result.getKey()) {
            return createHandlerResult(credential,
                    this.principalFactory.createPrincipal(username, result.getValue().get()),
                    new ArrayList<>());
        }
        throw new FailedLoginException("Radius authentication failed for user " + username);
    } catch (final Exception e) {
        throw new FailedLoginException("Radius authentication failed " + e.getMessage());
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:23,代码来源:RadiusTokenAuthenticationHandler.java

示例5: doAuthentication

import org.springframework.webflow.execution.RequestContextHolder; //导入依赖的package包/类
@Override
protected HandlerResult doAuthentication(final Credential credential) throws GeneralSecurityException, PreventedException {
    try {
        final AzureAuthenticatorTokenCredential c = (AzureAuthenticatorTokenCredential) credential;
        final RequestContext context = RequestContextHolder.getRequestContext();
        final Principal principal = WebUtils.getAuthentication(context).getPrincipal();

        LOGGER.debug("Received principal id [{}]", principal.getId());
        final PFAuthParams params = authenticationRequestBuilder.build(principal, c);
        final PFAuthResult r = azureAuthenticatorInstance.authenticate(params);

        if (r.getAuthenticated()) {
            return createHandlerResult(c, principalFactory.createPrincipal(principal.getId()), null);
        }
        LOGGER.error("Authentication failed. Call status: [{}]-[{}]. Error: [{}]", r.getCallStatus(),
                r.getCallStatusString(), r.getMessageError());

    } catch (final Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
    throw new FailedLoginException("Failed to authenticate user");
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:23,代码来源:AzureAuthenticatorAuthenticationHandler.java

示例6: verifyGetServiceThemeDoesNotExist

import org.springframework.webflow.execution.RequestContextHolder; //导入依赖的package包/类
@Test
public void verifyGetServiceThemeDoesNotExist() {
    final RegexRegisteredService r = new RegexRegisteredService();
    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", RegisteredServiceTestUtils.getService(r.getServiceId()));
    when(ctx.getFlowScope()).thenReturn(scope);
    RequestContextHolder.setRequestContext(ctx);
    request.addHeader(WebUtils.USER_AGENT_HEADER, MOZILLA);
    assertEquals(DEFAULT_THEME_NAME, this.serviceThemeResolver.resolveThemeName(request));
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:20,代码来源:ServiceThemeResolverTests.java

示例7: doExecute

import org.springframework.webflow.execution.RequestContextHolder; //导入依赖的package包/类
@Override
protected Event doExecute(final RequestContext requestContext) throws Exception {
    final RequestContext context = RequestContextHolder.getRequestContext();
    final String uid = WebUtils.getAuthentication(context).getPrincipal().getId();

    final String secretKey = repository.getSecret(uid);
    if (StringUtils.isBlank(secretKey)) {
        final OneTimeTokenAccount keyAccount = this.repository.create(uid);
        final String keyUri = "otpauth://totp/" + this.label + ':' + uid + "?secret=" + keyAccount.getSecretKey() + "&issuer=" + this.issuer;
        requestContext.getFlowScope().put("key", keyAccount);
        requestContext.getFlowScope().put("keyUri", keyUri);
        LOGGER.debug("Registration key URI is [{}]", keyUri);
        return new EventFactorySupport().event(this, "register");
    }
    return success();
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:17,代码来源:OneTimeTokenAccountCheckRegistrationAction.java

示例8: doAuthentication

import org.springframework.webflow.execution.RequestContextHolder; //导入依赖的package包/类
@Override
protected HandlerResult doAuthentication(final Credential credential) throws GeneralSecurityException, PreventedException {
    final AuthyTokenCredential tokenCredential = (AuthyTokenCredential) credential;
    final RequestContext context = RequestContextHolder.getRequestContext();
    final Principal principal = WebUtils.getAuthentication(context).getPrincipal();

    final User user = instance.getOrCreateUser(principal);
    if (!user.isOk()) {
        throw new FailedLoginException(AuthyClientInstance.getErrorMessage(user.getError()));
    }

    final Map<String, String> options = new HashMap<>(1);
    options.put("force", this.forceVerification.toString());

    final Token verification = this.instance.getAuthyTokens().verify(user.getId(), tokenCredential.getToken(), options);

    if (!verification.isOk()) {
        throw new FailedLoginException(AuthyClientInstance.getErrorMessage(verification.getError()));
    }

    return createHandlerResult(tokenCredential, principal, new ArrayList<>());
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:23,代码来源:AuthyAuthenticationHandler.java

示例9: getLocaleUrl

import org.springframework.webflow.execution.RequestContextHolder; //导入依赖的package包/类
public String getLocaleUrl(String locale) throws Exception {
    UriComponentsBuilder builder = ServletUriComponentsBuilder.fromCurrentRequest().replaceQueryParam("locale", locale);
    RequestAttributes attributes = org.springframework.web.context.request.RequestContextHolder.currentRequestAttributes();
    if (attributes instanceof ServletRequestAttributes) {
        int statusCode = ((ServletRequestAttributes) attributes).getResponse().getStatus();
        switch (statusCode) {
            case 200:
                break;
            case 404:
                builder.replacePath("" + statusCode);
                break;
            default:
                builder.replacePath("error");
        }
    }
    URI serverUri = new URI(this.casConfigurationProperties.getServer().getName());
    if ("https".equalsIgnoreCase(serverUri.getScheme())) {
        builder.port((serverUri.getPort() == -1) ? 443 : serverUri.getPort());
    }
    return builder.scheme(serverUri.getScheme()).host(serverUri.getHost()).build(true).toUriString();
}
 
开发者ID:e-gov,项目名称:TARA-Server,代码行数:22,代码来源:TaraProperties.java

示例10: findBean

import org.springframework.webflow.execution.RequestContextHolder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <T> T findBean(String beanName) {
    FacesContext context = FacesContext.getCurrentInstance();
    if (context != null) {
        try {
            return (T) context.getApplication().evaluateExpressionGet(context, "#{" + beanName + "}", Object.class);
           } catch (ELException e) {}
    }
    final RequestContext rc = RequestContextHolder.getRequestContext();
    T r;
       r = (T) rc.getFlowScope().get(beanName);
       if (r == null)
           r = (T) rc.getRequestScope().get(beanName);
       if (r == null)
           r = (T) rc.getViewScope().get(beanName);
       return r;
}
 
开发者ID:suewonjp,项目名称:civilizer,代码行数:18,代码来源:ViewUtil.java

示例11: doExecute

import org.springframework.webflow.execution.RequestContextHolder; //导入依赖的package包/类
/** {@inheritDoc} */
@Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext,
        @Nonnull final ProfileInterceptorContext interceptorContext) {

    final RequestContext requestContext =
            RequestContextHolder.getRequestContext();

    final MutableAttributeMap<Object> flowScope =
            requestContext.getFlowScope();

    // full name?
    flowScope.put("userName",
            IdPHelper.getPrincipalName(profileRequestContext));

    log.debug("{} Decorated user name", getLogPrefix());
}
 
开发者ID:cmu-cylab-privacylens,项目名称:PrivacyLens,代码行数:17,代码来源:DecorateUserName.java

示例12: doExecute

import org.springframework.webflow.execution.RequestContextHolder; //导入依赖的package包/类
/** {@inheritDoc} */
@Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext,
        @Nonnull final ProfileInterceptorContext interceptorContext) {

    final RequestContext requestContext =
            RequestContextHolder.getRequestContext();

    final MutableAttributeMap<Object> flowScope =
            requestContext.getFlowScope();

    final String relyingPartyId =
            IdPHelper.getRelyingPartyId(profileRequestContext);
    flowScope.put("service",
            Oracle.getInstance().getServiceName(relyingPartyId));
    flowScope.put("idpOrganization", General.getInstance().getOrganizationName());

    log.debug("{} Decorated other data", getLogPrefix());
}
 
开发者ID:cmu-cylab-privacylens,项目名称:PrivacyLens,代码行数:19,代码来源:DecorateOther.java

示例13: doExecute

import org.springframework.webflow.execution.RequestContextHolder; //导入依赖的package包/类
/** {@inheritDoc} */
@Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext,
        @Nonnull final ProfileInterceptorContext interceptorContext) {

    final RequestContext requestContext =
            RequestContextHolder.getRequestContext();

    final MutableAttributeMap<Object> flowScope =
            requestContext.getFlowScope();
    flowScope.put("adminUrl", General.getInstance().getAdminUrl());
    flowScope.put("adminMail", General.getInstance().getAdminMail());
    flowScope.put("IdPName", General.getInstance().getIdpName());
    flowScope.put("credits", General.getInstance().getCredits());

    log.debug("{} Decorated general data", getLogPrefix());
}
 
开发者ID:cmu-cylab-privacylens,项目名称:PrivacyLens,代码行数:17,代码来源:DecorateGeneral.java

示例14: doExecute

import org.springframework.webflow.execution.RequestContextHolder; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected void doExecute(
        @Nonnull final ProfileRequestContext profileRequestContext,
        @Nonnull final ProfileInterceptorContext interceptorContext) {

    final RequestContext requestContext =
            RequestContextHolder.getRequestContext();

    final MutableAttributeMap<Object> flowScope =
            requestContext.getFlowScope();

    final HttpServletRequest request =
            (HttpServletRequest) requestContext.getExternalContext()
                    .getNativeRequest();

    // CHANGEME use previous consents
    final List<Attribute> attributes =
            (List<Attribute>) flowScope.get("attributes");

    final String attributeList = getReminderAttributes(attributes);

    flowScope.put("attributeList", attributeList);

    log.debug("{} added reminder list", getLogPrefix());
}
 
开发者ID:cmu-cylab-privacylens,项目名称:PrivacyLens,代码行数:27,代码来源:ReminderAttributeService.java

示例15: populateAttributes

import org.springframework.webflow.execution.RequestContextHolder; //导入依赖的package包/类
@Override
public void populateAttributes(final AuthenticationBuilder authenticationBuilder, final Credential credential) {
    final RequestContext context = RequestContextHolder.getRequestContext();
    if (context != null) {
        final Service svc = WebUtils.getService(context);

        if (svc instanceof MultiFactorAuthenticationSupportingWebApplicationService) {
            final MultiFactorAuthenticationSupportingWebApplicationService mfaSvc =
                    (MultiFactorAuthenticationSupportingWebApplicationService) svc;

            authenticationBuilder.addAttribute(
                    MultiFactorAuthenticationSupportingWebApplicationService.CONST_PARAM_AUTHN_METHOD,
                    mfaSvc.getAuthenticationMethod());

            logger.debug("Captured authentication method [{}] into the authentication context",
                    mfaSvc.getAuthenticationMethod());
        }
    }
}
 
开发者ID:Unicon,项目名称:cas-mfa,代码行数:20,代码来源:RememberAuthenticationMethodMetaDataPopulator.java


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