本文整理汇总了Java中org.springframework.security.saml.SAMLDiscovery类的典型用法代码示例。如果您正苦于以下问题:Java SAMLDiscovery类的具体用法?Java SAMLDiscovery怎么用?Java SAMLDiscovery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SAMLDiscovery类属于org.springframework.security.saml包,在下文中一共展示了SAMLDiscovery类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: idpSelection
import org.springframework.security.saml.SAMLDiscovery; //导入依赖的package包/类
@RequestMapping(value = "/idpSelection", method = RequestMethod.GET)
public ModelAndView idpSelection(HttpServletRequest request, @CurrentUser ApplicationUser currentUser) {
if (!inLoginProcess(request, currentUser)) {
return new ModelAndView(NOT_IN_LOGIN_PROCESS_VIEW_NAME);
}
Map<String, Object> modelMap = new HashMap<>();
modelMap.put("idps", getIDPs());
modelMap.put("idpDiscoReturnURL", request.getAttribute(SAMLDiscovery.RETURN_URL));
modelMap.put("idpDiscoReturnParam", request.getAttribute(SAMLDiscovery.RETURN_PARAM));
return new ModelAndView("idpselection", modelMap);
}
示例2: configure
import org.springframework.security.saml.SAMLDiscovery; //导入依赖的package包/类
@Override
public void configure(ServiceProviderBuilder builder) throws Exception {
if (successHandler == null) {
SavedRequestAwareAuthenticationSuccessHandler successRedirectHandler = createDefaultSuccessHandler();
successRedirectHandler.setDefaultTargetUrl(Optional.ofNullable(defaultSuccessURL).orElseGet(config::getDefaultSuccessUrl));
successHandler = postProcess(successRedirectHandler);
}
defaultFailureURL = Optional.ofNullable(defaultFailureURL).orElseGet(config::getDefaultFailureUrl);
if (failureHandler == null) {
SimpleUrlAuthenticationFailureHandler authenticationFailureHandler = createDefaultFailureHandler();
authenticationFailureHandler.setDefaultFailureUrl(defaultFailureURL);
failureHandler = postProcess(authenticationFailureHandler);
}
endpoints.setDefaultFailureURL(defaultFailureURL);
SAMLProcessingFilter ssoFilter = createDefaultSamlProcessingFilter();
ssoFilter.setAuthenticationManager(authenticationManager);
ssoFilter.setAuthenticationSuccessHandler(successHandler);
ssoFilter.setAuthenticationFailureHandler(failureHandler);
ssoProcessingURL = Optional.ofNullable(ssoProcessingURL).orElseGet(config::getSsoProcessingUrl);
endpoints.setSsoProcessingURL(ssoProcessingURL);
ssoFilter.setFilterProcessesUrl(ssoProcessingURL);
SAMLWebSSOHoKProcessingFilter ssoHoKFilter = null;
if (Optional.ofNullable(enableSsoHoK).orElseGet(config::isEnableSsoHok)) {
ssoHoKFilter = createDefaultSamlHoKProcessingFilter();
ssoHoKFilter.setAuthenticationSuccessHandler(successHandler);
ssoHoKFilter.setAuthenticationManager(authenticationManager);
ssoHoKFilter.setAuthenticationFailureHandler(failureHandler);
ssoHoKProcessingURL = Optional.ofNullable(ssoHoKProcessingURL).orElseGet(config::getSsoHokProcessingUrl);
endpoints.setSsoHoKProcessingURL(ssoHoKProcessingURL);
ssoHoKFilter.setFilterProcessesUrl(ssoHoKProcessingURL);
}
SAMLDiscovery discoveryFilter = createDefaultSamlDiscoveryFilter();
discoveryProcessingURL = Optional.ofNullable(discoveryProcessingURL).orElseGet(config::getDiscoveryProcessingUrl);
endpoints.setDiscoveryProcessingURL(discoveryProcessingURL);
discoveryFilter.setFilterProcessesUrl(discoveryProcessingURL);
idpSelectionPageURL = Optional.ofNullable(idpSelectionPageURL).orElseGet(config::getIdpSelectionPageUrl);
endpoints.setIdpSelectionPageURL(idpSelectionPageURL);
discoveryFilter.setIdpSelectionPath(idpSelectionPageURL);
SAMLEntryPoint entryPoint = Optional.ofNullable(samlEntryPointBean).orElseGet(this::createDefaultSamlEntryPoint);
entryPoint.setDefaultProfileOptions(Optional.ofNullable(profileOptions).orElseGet(this::getProfileOptions));
ssoLoginURL = Optional.ofNullable(ssoLoginURL).orElseGet(config::getSsoLoginUrl);
endpoints.setSsoLoginURL(ssoLoginURL);
entryPoint.setFilterProcessesUrl(ssoLoginURL);
builder.setSharedObject(SAMLProcessingFilter.class, ssoFilter);
builder.setSharedObject(SAMLWebSSOHoKProcessingFilter.class, ssoHoKFilter);
builder.setSharedObject(SAMLDiscovery.class, discoveryFilter);
builder.setSharedObject(SAMLEntryPoint.class, entryPoint);
}
示例3: createDefaultSamlDiscoveryFilter
import org.springframework.security.saml.SAMLDiscovery; //导入依赖的package包/类
@VisibleForTesting
protected SAMLDiscovery createDefaultSamlDiscoveryFilter() {
return new SAMLDiscovery();
}
示例4: configure_defaults
import org.springframework.security.saml.SAMLDiscovery; //导入依赖的package包/类
@Test
public void configure_defaults() throws Exception {
SSOConfigurer configurer = spy(new SSOConfigurer());
SAMLProcessingFilter ssoFilter = mock(SAMLProcessingFilter.class);
when(configurer.createDefaultSamlProcessingFilter()).thenReturn(ssoFilter);
SAMLWebSSOHoKProcessingFilter ssoHoKFilter = mock(SAMLWebSSOHoKProcessingFilter.class);
when(configurer.createDefaultSamlHoKProcessingFilter()).thenReturn(ssoHoKFilter);
SAMLDiscovery discoveryFilter = mock(SAMLDiscovery.class);
when(configurer.createDefaultSamlDiscoveryFilter()).thenReturn(discoveryFilter);
SAMLEntryPoint entryPoint = mock(SAMLEntryPoint.class);
when(configurer.createDefaultSamlEntryPoint()).thenReturn(entryPoint);
SavedRequestAwareAuthenticationSuccessHandler successHandler = mock(SavedRequestAwareAuthenticationSuccessHandler.class);
when(configurer.createDefaultSuccessHandler()).thenReturn(successHandler);
SimpleUrlAuthenticationFailureHandler failureHandler = mock(SimpleUrlAuthenticationFailureHandler.class);
when(configurer.createDefaultFailureHandler()).thenReturn(failureHandler);
configurer.init(builder);
configurer.configure(builder);
verify(properties).getDefaultFailureUrl();
verify(properties).getDefaultSuccessUrl();
verify(properties).getDiscoveryProcessingUrl();
verify(properties).getIdpSelectionPageUrl();
verify(properties).getSsoHokProcessingUrl();
verify(properties).getSsoLoginUrl();
verify(properties).getSsoProcessingUrl();
verify(properties).getProfileOptions();
verify(successHandler).setDefaultTargetUrl(eq(properties.getDefaultSuccessUrl()));
verify(failureHandler).setDefaultFailureUrl(eq(properties.getDefaultFailureUrl()));
verify(ssoFilter).setAuthenticationManager(eq(authenticationManager));
verify(ssoFilter).setAuthenticationSuccessHandler(eq(successHandler));
verify(ssoFilter).setAuthenticationFailureHandler(eq(failureHandler));
verify(ssoFilter).setFilterProcessesUrl(eq(properties.getSsoProcessingUrl()));
verify(ssoHoKFilter).setAuthenticationManager(eq(authenticationManager));
verify(ssoHoKFilter).setAuthenticationSuccessHandler(eq(successHandler));
verify(ssoHoKFilter).setAuthenticationFailureHandler(eq(failureHandler));
verify(ssoHoKFilter).setFilterProcessesUrl(eq(properties.getSsoHokProcessingUrl()));
verify(serviceProviderEndpoints).setSsoProcessingURL(properties.getSsoProcessingUrl());
verify(serviceProviderEndpoints).setSsoHoKProcessingURL(properties.getSsoHokProcessingUrl());
verify(serviceProviderEndpoints).setDefaultFailureURL(properties.getDefaultFailureUrl());
verify(serviceProviderEndpoints).setDiscoveryProcessingURL(properties.getDiscoveryProcessingUrl());
verify(serviceProviderEndpoints).setIdpSelectionPageURL(properties.getIdpSelectionPageUrl());
verify(serviceProviderEndpoints).setSsoLoginURL(properties.getSsoLoginUrl());
verify(discoveryFilter).setFilterProcessesUrl(eq(properties.getDiscoveryProcessingUrl()));
verify(discoveryFilter).setIdpSelectionPath(eq(properties.getIdpSelectionPageUrl()));
verify(entryPoint).setFilterProcessesUrl(eq(properties.getSsoLoginUrl()));
ArgumentCaptor<WebSSOProfileOptions> optionsCaptor = ArgumentCaptor.forClass(WebSSOProfileOptions.class);
verify(entryPoint).setDefaultProfileOptions(optionsCaptor.capture());
WebSSOProfileOptions options = optionsCaptor.getValue();
Assertions.assertThat(options.isAllowCreate()).isEqualTo(properties.getProfileOptions().getAllowCreate());
Assertions.assertThat(options.getAllowedIDPs()).isEqualTo(properties.getProfileOptions().getAllowedIdps());
Assertions.assertThat(options.getAssertionConsumerIndex()).isEqualTo(properties.getProfileOptions().getAssertionConsumerIndex());
Assertions.assertThat(options.getAuthnContextComparison()).isEqualTo(properties.getProfileOptions().getAuthnContextComparison());
Assertions.assertThat(options.getAuthnContexts()).isEqualTo(properties.getProfileOptions().getAuthnContexts());
Assertions.assertThat(options.getBinding()).isEqualTo(properties.getProfileOptions().getBinding());
Assertions.assertThat(options.getForceAuthN()).isEqualTo(properties.getProfileOptions().getForceAuthn());
Assertions.assertThat(options.isIncludeScoping()).isEqualTo(properties.getProfileOptions().getIncludeScoping());
Assertions.assertThat(options.getNameID()).isEqualTo(properties.getProfileOptions().getNameId());
Assertions.assertThat(options.getPassive()).isEqualTo(properties.getProfileOptions().getPassive());
Assertions.assertThat(options.getProviderName()).isEqualTo(properties.getProfileOptions().getProviderName());
Assertions.assertThat(options.getProxyCount()).isEqualTo(properties.getProfileOptions().getProxyCount());
Assertions.assertThat(options.getRelayState()).isEqualTo(properties.getProfileOptions().getRelayState());
verify(builder).setSharedObject(eq(SAMLProcessingFilter.class), eq(ssoFilter));
verify(builder).setSharedObject(eq(SAMLWebSSOHoKProcessingFilter.class), eq(ssoHoKFilter));
verify(builder).setSharedObject(eq(SAMLDiscovery.class), eq(discoveryFilter));
verify(builder).setSharedObject(eq(SAMLEntryPoint.class), eq(entryPoint));
}
示例5: configure_custom_noHoK
import org.springframework.security.saml.SAMLDiscovery; //导入依赖的package包/类
@Test
public void configure_custom_noHoK() throws Exception {
SSOConfigurer configurer = spy(new SSOConfigurer());
SAMLProcessingFilter ssoFilter = mock(SAMLProcessingFilter.class);
when(configurer.createDefaultSamlProcessingFilter()).thenReturn(ssoFilter);
SAMLWebSSOHoKProcessingFilter ssoHoKFilter = mock(SAMLWebSSOHoKProcessingFilter.class);
when(configurer.createDefaultSamlHoKProcessingFilter()).thenReturn(ssoHoKFilter);
SAMLDiscovery discoveryFilter = mock(SAMLDiscovery.class);
when(configurer.createDefaultSamlDiscoveryFilter()).thenReturn(discoveryFilter);
SAMLEntryPoint entryPoint = mock(SAMLEntryPoint.class);
when(configurer.createDefaultSamlEntryPoint()).thenReturn(entryPoint);
SavedRequestAwareAuthenticationSuccessHandler successHandler = mock(SavedRequestAwareAuthenticationSuccessHandler.class);
SimpleUrlAuthenticationFailureHandler failureHandler = mock(SimpleUrlAuthenticationFailureHandler.class);
WebSSOProfileOptions profileOptions = mock(WebSSOProfileOptions.class);
configurer.init(builder);
configurer
.defaultSuccessURL("/success")
.failureHandler(failureHandler)
.successHandler(successHandler)
.defaultFailureURL("/failure")
.discoveryProcessingURL("/discovery")
.enableSsoHoK(false)
.idpSelectionPageURL("/idp")
.profileOptions(profileOptions)
.ssoHoKProcessingURL("/hok")
.ssoLoginURL("/login")
.ssoProcessingURL("/sso");
configurer.configure(builder);
verify(properties, never()).getDefaultFailureUrl();
verify(properties, never()).getDefaultSuccessUrl();
verify(properties, never()).getDiscoveryProcessingUrl();
verify(properties, never()).getIdpSelectionPageUrl();
verify(properties, never()).getSsoHokProcessingUrl();
verify(properties, never()).getSsoLoginUrl();
verify(properties, never()).getSsoProcessingUrl();
verify(properties, never()).getProfileOptions();
verify(successHandler, never()).setDefaultTargetUrl(eq("/success"));
verify(failureHandler, never()).setDefaultFailureUrl(eq("/failure"));
verify(ssoFilter).setAuthenticationManager(eq(authenticationManager));
verify(ssoFilter).setAuthenticationSuccessHandler(eq(successHandler));
verify(ssoFilter).setAuthenticationFailureHandler(eq(failureHandler));
verify(ssoFilter).setFilterProcessesUrl(eq("/sso"));
verify(ssoHoKFilter, never()).setAuthenticationManager(eq(authenticationManager));
verify(ssoHoKFilter, never()).setAuthenticationSuccessHandler(eq(successHandler));
verify(ssoHoKFilter, never()).setAuthenticationFailureHandler(eq(failureHandler));
verify(ssoHoKFilter, never()).setFilterProcessesUrl(eq("/hok"));
verify(serviceProviderEndpoints).setSsoProcessingURL("/sso");
verify(serviceProviderEndpoints, never()).setSsoHoKProcessingURL("/hok");
verify(serviceProviderEndpoints).setDefaultFailureURL("/failure");
verify(serviceProviderEndpoints).setDiscoveryProcessingURL("/discovery");
verify(serviceProviderEndpoints).setIdpSelectionPageURL("/idp");
verify(serviceProviderEndpoints).setSsoLoginURL("/login");
verify(discoveryFilter).setFilterProcessesUrl(eq("/discovery"));
verify(discoveryFilter).setIdpSelectionPath(eq("/idp"));
verify(entryPoint).setFilterProcessesUrl(eq("/login"));
verify(entryPoint).setDefaultProfileOptions(eq(profileOptions));
verify(builder).setSharedObject(eq(SAMLProcessingFilter.class), eq(ssoFilter));
verify(builder).setSharedObject(eq(SAMLWebSSOHoKProcessingFilter.class), eq(null));
verify(builder).setSharedObject(eq(SAMLDiscovery.class), eq(discoveryFilter));
verify(builder).setSharedObject(eq(SAMLEntryPoint.class), eq(entryPoint));
}
示例6: samlIDPDiscovery
import org.springframework.security.saml.SAMLDiscovery; //导入依赖的package包/类
@Bean
public SAMLDiscovery samlIDPDiscovery() {
return new SAMLDiscovery();
}
开发者ID:choonchernlim,项目名称:spring-security-adfs-saml2,代码行数:5,代码来源:SAMLWebSecurityConfigurerAdapter.java
示例7: comesFromDiscoveryFilter
import org.springframework.security.saml.SAMLDiscovery; //导入依赖的package包/类
private boolean comesFromDiscoveryFilter(HttpServletRequest request) {
return request.getAttribute(SAMLConstants.LOCAL_ENTITY_ID) != null &&
request.getAttribute(SAMLDiscovery.RETURN_URL) != null &&
request.getAttribute(SAMLDiscovery.RETURN_PARAM) != null;
}
示例8: samlIDPDiscovery
import org.springframework.security.saml.SAMLDiscovery; //导入依赖的package包/类
@Bean
public SAMLDiscovery samlIDPDiscovery() {
SAMLDiscovery idpDiscovery = new SAMLDiscovery();
idpDiscovery.setIdpSelectionPath("/saml/idpSelection");
return idpDiscovery;
}