Search in sources :

Example 1 with AuthorityGranter

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
}
Also used : AuthorityGranter(org.springframework.security.authentication.jaas.AuthorityGranter) Principal(java.security.Principal) AuthenticationPrincipal(org.springframework.security.core.annotation.AuthenticationPrincipal) Test(org.junit.jupiter.api.Test)

Example 2 with AuthorityGranter

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;
}
Also used : AuthorityGranter(org.springframework.security.authentication.jaas.AuthorityGranter) UserPrincipalAuthorityGranter(com.thinkbiganalytics.auth.UserPrincipalAuthorityGranter) DefaultPrincipalAuthorityGranter(com.thinkbiganalytics.auth.DefaultPrincipalAuthorityGranter) GroupPrincipalAuthorityGranter(com.thinkbiganalytics.auth.GroupPrincipalAuthorityGranter) DefaultJaasAuthenticationProvider(org.springframework.security.authentication.jaas.DefaultJaasAuthenticationProvider) DefaultKyloJaasAuthenticationProvider(com.thinkbiganalytics.auth.jaas.DefaultKyloJaasAuthenticationProvider) Bean(org.springframework.context.annotation.Bean)

Example 3 with AuthorityGranter

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;
}
Also used : AuthorityGranter(org.springframework.security.authentication.jaas.AuthorityGranter) UserPrincipalAuthorityGranter(com.thinkbiganalytics.auth.UserPrincipalAuthorityGranter) DefaultPrincipalAuthorityGranter(com.thinkbiganalytics.auth.DefaultPrincipalAuthorityGranter) GroupPrincipalAuthorityGranter(com.thinkbiganalytics.auth.GroupPrincipalAuthorityGranter) UsernameJaasAuthenticationProvider(com.thinkbiganalytics.auth.jaas.UsernameJaasAuthenticationProvider) Bean(org.springframework.context.annotation.Bean)

Example 4 with AuthorityGranter

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;
}
Also used : AuthorityGranter(org.springframework.security.authentication.jaas.AuthorityGranter) UserPrincipalAuthorityGranter(com.thinkbiganalytics.auth.UserPrincipalAuthorityGranter) DefaultPrincipalAuthorityGranter(com.thinkbiganalytics.auth.DefaultPrincipalAuthorityGranter) GroupPrincipalAuthorityGranter(com.thinkbiganalytics.auth.GroupPrincipalAuthorityGranter) DefaultJaasAuthenticationProvider(org.springframework.security.authentication.jaas.DefaultJaasAuthenticationProvider) DefaultKyloJaasAuthenticationProvider(com.thinkbiganalytics.auth.jaas.DefaultKyloJaasAuthenticationProvider) Bean(org.springframework.context.annotation.Bean)

Example 5 with AuthorityGranter

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;
}
Also used : AuthorityGranter(org.springframework.security.authentication.jaas.AuthorityGranter) UserPrincipalAuthorityGranter(com.thinkbiganalytics.auth.UserPrincipalAuthorityGranter) DefaultPrincipalAuthorityGranter(com.thinkbiganalytics.auth.DefaultPrincipalAuthorityGranter) GroupPrincipalAuthorityGranter(com.thinkbiganalytics.auth.GroupPrincipalAuthorityGranter) UsernameJaasAuthenticationProvider(com.thinkbiganalytics.auth.jaas.UsernameJaasAuthenticationProvider) Bean(org.springframework.context.annotation.Bean)

Aggregations

AuthorityGranter (org.springframework.security.authentication.jaas.AuthorityGranter)5 DefaultPrincipalAuthorityGranter (com.thinkbiganalytics.auth.DefaultPrincipalAuthorityGranter)4 GroupPrincipalAuthorityGranter (com.thinkbiganalytics.auth.GroupPrincipalAuthorityGranter)4 UserPrincipalAuthorityGranter (com.thinkbiganalytics.auth.UserPrincipalAuthorityGranter)4 Bean (org.springframework.context.annotation.Bean)4 DefaultKyloJaasAuthenticationProvider (com.thinkbiganalytics.auth.jaas.DefaultKyloJaasAuthenticationProvider)2 UsernameJaasAuthenticationProvider (com.thinkbiganalytics.auth.jaas.UsernameJaasAuthenticationProvider)2 DefaultJaasAuthenticationProvider (org.springframework.security.authentication.jaas.DefaultJaasAuthenticationProvider)2 Principal (java.security.Principal)1 Test (org.junit.jupiter.api.Test)1 AuthenticationPrincipal (org.springframework.security.core.annotation.AuthenticationPrincipal)1