org.springframework.security.authentication.jaas.AuthorityGranter Java Examples

The following examples show how to use org.springframework.security.authentication.jaas.AuthorityGranter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JaasAuthenticationProvider.java    From unitime with Apache License 2.0 6 votes vote down vote up
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;
			}
		}
	});
}