public JaasAuthenticationProvider() { setAuthorityGranters(new AuthorityGranter[] { new AuthorityGranter() { @Override public Set<String> grant(Principal principal) { Set<String> roles = new HashSet<String>(); if (principal instanceof HasExternalId) { roles.add(((HasExternalId)principal).getExternalId()); } else { String user = principal.getName(); if (user.indexOf('@') >= 0) user = user.substring(0, user.indexOf('@')); roles.add(user); } return roles; } } }); }
@Bean public JaasAuthenticationProvider jaasAuthProvider() { JaasAuthenticationProvider authenticationProvider = new JaasAuthenticationProvider(); authenticationProvider.setAuthorityGranters(new AuthorityGranter[] { new RoleGranterFromMap() }); authenticationProvider.setCallbackHandlers(new JaasAuthenticationCallbackHandler[] { new JaasNameCallbackHandler(), new JaasPasswordCallbackHandler() }); authenticationProvider.setLoginContextName("taskana"); authenticationProvider.setLoginConfig(new ClassPathResource("pss_jaas.config")); return authenticationProvider; }