本文整理汇总了Java中org.springframework.webflow.execution.RequestContextHolder类的典型用法代码示例。如果您正苦于以下问题:Java RequestContextHolder类的具体用法?Java RequestContextHolder怎么用?Java RequestContextHolder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RequestContextHolder类属于org.springframework.webflow.execution包,在下文中一共展示了RequestContextHolder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: resolveThemeName
import org.springframework.webflow.execution.RequestContextHolder; //导入依赖的package包/类
@Override
public String resolveThemeName(final HttpServletRequest request) {
if (this.servicesManager == null) {
return getDefaultThemeName();
}
// retrieve the user agent string from the request
final String userAgent = request.getHeader("User-Agent");
if (StringUtils.isBlank(userAgent)) {
return getDefaultThemeName();
}
for (final Map.Entry<Pattern, String> entry : this.overrides.entrySet()) {
if (entry.getKey().matcher(userAgent).matches()) {
request.setAttribute("isMobile", "true");
request.setAttribute("browserType", entry.getValue());
break;
}
}
final RequestContext context = RequestContextHolder.getRequestContext();
final Service service = WebUtils.getService(context);
if (service != null) {
final RegisteredService rService = this.servicesManager.findServiceBy(service);
if (rService != null && rService.getAccessStrategy().isServiceAccessAllowed()
&& StringUtils.isNotBlank(rService.getTheme())) {
LOGGER.debug("Service [{}] is configured to use a custom theme [{}]", rService, rService.getTheme());
final CasThemeResourceBundleMessageSource messageSource = new CasThemeResourceBundleMessageSource();
messageSource.setBasename(rService.getTheme());
if (messageSource.doGetBundle(rService.getTheme(), request.getLocale()) != null) {
LOGGER.debug("Found custom theme [{}] for service [{}]", rService.getTheme(), rService);
return rService.getTheme();
} else {
LOGGER.warn("Custom theme {} for service {} cannot be located. Falling back to default theme...",
rService.getTheme(), rService);
}
}
}
return getDefaultThemeName();
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:41,代码来源:ServiceThemeResolver.java
示例17: verifyGetServiceWithDefault
import org.springframework.webflow.execution.RequestContextHolder; //导入依赖的package包/类
@Test
public void verifyGetServiceWithDefault() throws Exception {
final MockRequestContext requestContext = new MockRequestContext();
RequestContextHolder.setRequestContext(requestContext);
final WebApplicationService webApplicationService = new WebApplicationServiceFactory().createService("myDefaultId");
requestContext.getFlowScope().put("service", webApplicationService);
assertEquals("/WEB-INF/view/jsp/default/ui/casLoginView",
this.registeredServiceThemeBasedViewResolver.buildView("casLoginView").getUrl());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:12,代码来源:RegisteredServiceThemeBasedViewResolverTests.java
示例18: verifyNoService
import org.springframework.webflow.execution.RequestContextHolder; //导入依赖的package包/类
@Test
public void verifyNoService() throws Exception {
final MockRequestContext requestContext = new MockRequestContext();
RequestContextHolder.setRequestContext(requestContext);
assertEquals("/WEB-INF/view/jsp/default/ui/casLoginView",
this.registeredServiceThemeBasedViewResolver.buildView("casLoginView").getUrl());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:9,代码来源:RegisteredServiceThemeBasedViewResolverTests.java
示例19: buildView
import org.springframework.webflow.execution.RequestContextHolder; //导入依赖的package包/类
/**
* Uses the viewName and the theme associated with the service.
* being requested and returns the appropriate view.
* @param viewName the name of the view to be resolved
* @return a theme-based UrlBasedView
* @throws Exception an exception
*/
@Override
protected AbstractUrlBasedView buildView(final String viewName) throws Exception {
final RequestContext requestContext = RequestContextHolder.getRequestContext();
final WebApplicationService service = WebUtils.getService(requestContext);
final RegisteredService registeredService = this.servicesManager.findServiceBy(service);
final String themeId = service != null && registeredService != null
&& registeredService.getAccessStrategy().isServiceAccessAllowed()
&& StringUtils.hasText(registeredService.getTheme()) ? registeredService.getTheme() : defaultThemeId;
final String themePrefix = String.format("%s/%s/ui/", pathPrefix, themeId);
LOGGER.debug("Prefix {} set for service {} with theme {}", themePrefix, service, themeId);
//Build up the view like the base classes do, but we need to forcefully set the prefix for each request.
//From UrlBasedViewResolver.buildView
final InternalResourceView view = (InternalResourceView) BeanUtils.instantiateClass(getViewClass());
view.setUrl(themePrefix + viewName + getSuffix());
final String contentType = getContentType();
if (contentType != null) {
view.setContentType(contentType);
}
view.setRequestContextAttribute(getRequestContextAttribute());
view.setAttributesMap(getAttributesMap());
//From InternalResourceViewResolver.buildView
view.setAlwaysInclude(false);
view.setExposeContextBeansAsAttributes(false);
view.setPreventDispatchLoop(true);
LOGGER.debug("View resolved: {}", view.getUrl());
return view;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:41,代码来源:RegisteredServiceThemeBasedViewResolver.java
示例20: 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 SimpleWebApplicationServiceImpl("myServiceId");
requestContext.getFlowScope().put("service", webApplicationService);
assertEquals("/WEB-INF/view/jsp/myTheme/ui/casLoginView",
this.registeredServiceThemeBasedViewResolver.buildView("casLoginView").getUrl());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:12,代码来源:RegisteredServiceThemeBasedViewResolverTests.java
注:本文中的org.springframework.webflow.execution.RequestContextHolder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论