use of org.springframework.security.authentication.jaas.AuthorityGranter in project spring-security by spring-projects.
the class MiscHttpConfigTests method loginWhenUsingJaasApiProvisionThenJaasSubjectContainsUsername.
@Test
public void loginWhenUsingJaasApiProvisionThenJaasSubjectContainsUsername() throws Exception {
this.spring.configLocations(xml("Jaas")).autowire();
AuthorityGranter granter = this.spring.getContext().getBean(AuthorityGranter.class);
given(granter.grant(any(Principal.class))).willReturn(new HashSet<>(Arrays.asList("USER")));
// @formatter:off
this.mvc.perform(get("/username").with(userCredentials())).andExpect(content().string("user"));
// @formatter:on
}
use of org.springframework.security.authentication.jaas.AuthorityGranter in project kylo by Teradata.
the class JaasAuthConfig method servicesAuthenticationProvider.
@Bean(name = SERVICES_AUTH_PROVIDER)
public AbstractJaasAuthenticationProvider servicesAuthenticationProvider(@Named("jaasConfiguration") javax.security.auth.login.Configuration config, List<AuthorityGranter> authorityGranters) {
DefaultJaasAuthenticationProvider provider = new DefaultKyloJaasAuthenticationProvider();
provider.setCallbackHandlers(CALLBACK_HANDLERS);
provider.setConfiguration(config);
provider.setAuthorityGranters(authorityGranters.toArray(new AuthorityGranter[authorityGranters.size()]));
provider.setLoginContextName(JAAS_SERVICES);
return provider;
}
use of org.springframework.security.authentication.jaas.AuthorityGranter in project kylo by Teradata.
the class JaasAuthConfig method servicesTokenAuthenticationProvider.
@Bean(name = SERVICES_TOKEN_AUTH_PROVIDER)
public AbstractJaasAuthenticationProvider servicesTokenAuthenticationProvider(@Named("jaasConfiguration") javax.security.auth.login.Configuration config, List<AuthorityGranter> authorityGranters) {
UsernameJaasAuthenticationProvider provider = new UsernameJaasAuthenticationProvider();
provider.setCallbackHandlers(CALLBACK_HANDLERS);
provider.setConfiguration(config);
provider.setAuthorityGranters(authorityGranters.toArray(new AuthorityGranter[authorityGranters.size()]));
provider.setLoginContextName(JAAS_SERVICES_TOKEN);
return provider;
}
use of org.springframework.security.authentication.jaas.AuthorityGranter in project kylo by Teradata.
the class JaasAuthConfig method uiAuthenticationProvider.
@Bean(name = UI_AUTH_PROVIDER)
public AbstractJaasAuthenticationProvider uiAuthenticationProvider(@Named("jaasConfiguration") javax.security.auth.login.Configuration config, List<AuthorityGranter> authorityGranters) {
DefaultJaasAuthenticationProvider provider = new DefaultKyloJaasAuthenticationProvider();
provider.setCallbackHandlers(CALLBACK_HANDLERS);
provider.setConfiguration(config);
provider.setAuthorityGranters(authorityGranters.toArray(new AuthorityGranter[authorityGranters.size()]));
provider.setLoginContextName(JAAS_UI);
return provider;
}
use of org.springframework.security.authentication.jaas.AuthorityGranter in project kylo by Teradata.
the class JaasAuthConfig method uiTokenAuthenticationProvider.
@Bean(name = UI_TOKEN_AUTH_PROVIDER)
public AbstractJaasAuthenticationProvider uiTokenAuthenticationProvider(@Named("jaasConfiguration") javax.security.auth.login.Configuration config, List<AuthorityGranter> authorityGranters) {
UsernameJaasAuthenticationProvider provider = new UsernameJaasAuthenticationProvider();
provider.setCallbackHandlers(CALLBACK_HANDLERS);
provider.setConfiguration(config);
provider.setAuthorityGranters(authorityGranters.toArray(new AuthorityGranter[authorityGranters.size()]));
provider.setLoginContextName(JAAS_UI_TOKEN);
return provider;
}
Aggregations