List of usage examples for org.springframework.security.oauth2.provider.token UserAuthenticationConverter AUTHORITIES
String AUTHORITIES
To view the source code for org.springframework.security.oauth2.provider.token UserAuthenticationConverter AUTHORITIES.
Click Source Link
From source file:org.openlmis.fulfillment.security.CustomUserAuthenticationConverterTest.java
@Test public void shouldExtractAuthenticationWithPrincipalAndCommaSeparatedAuthorities() { Authentication authentication = userAuthenticationConverter .extractAuthentication(ImmutableMap.of(REFERENCE_DATA_USER_ID, userId.toString(), UserAuthenticationConverter.AUTHORITIES, "one,two,three")); checkAuthentication(userId, authentication); assertEquals(3, authentication.getAuthorities().size()); }
From source file:org.openlmis.fulfillment.security.CustomUserAuthenticationConverterTest.java
@Test public void shouldExtractAuthenticationWithPrincipalAndCollectionAuthorities() { Authentication authentication = userAuthenticationConverter .extractAuthentication(ImmutableMap.of(REFERENCE_DATA_USER_ID, userId.toString(), UserAuthenticationConverter.AUTHORITIES, Arrays.asList("one", "two"))); checkAuthentication(userId, authentication); assertEquals(2, authentication.getAuthorities().size()); }
From source file:no.imr.common.security.jwt.DefaultAccessTokenConverter.java
public Map<String, ?> convertAccessToken(OAuth2AccessToken token, OAuth2Authentication authentication) { Map<String, Object> response = new HashMap<String, Object>(); OAuth2Request clientToken = authentication.getOAuth2Request(); if (!authentication.isClientOnly()) { response.putAll(userTokenConverter.convertUserAuthentication(authentication.getUserAuthentication())); } else {//from w w w . j av a 2 s.c o m if (clientToken.getAuthorities() != null && !clientToken.getAuthorities().isEmpty()) { response.put(UserAuthenticationConverter.AUTHORITIES, AuthorityUtils.authorityListToSet(clientToken.getAuthorities())); } } if (token.getScope() != null) { response.put(SCOPE, token.getScope()); } if (token.getAdditionalInformation().containsKey(JTI)) { response.put(JTI, token.getAdditionalInformation().get(JTI)); } if (token.getExpiration() != null) { response.put(EXP, token.getExpiration().getTime() / 1000); } if (includeGrantType && authentication.getOAuth2Request().getGrantType() != null) { response.put(GRANT_TYPE, authentication.getOAuth2Request().getGrantType()); } response.putAll(token.getAdditionalInformation()); response.put(CLIENT_ID, clientToken.getClientId()); if (clientToken.getResourceIds() != null && !clientToken.getResourceIds().isEmpty()) { response.put(AUD, clientToken.getResourceIds()); } return response; }
From source file:org.openlmis.fulfillment.security.CustomUserAuthenticationConverterTest.java
@Test(expected = IllegalArgumentException.class) public void shouldNotExtractAuthenticationWhenAuthoritiesAreNotInSupportedFormat() { userAuthenticationConverter.extractAuthentication(ImmutableMap.of(REFERENCE_DATA_USER_ID, userId.toString(), UserAuthenticationConverter.AUTHORITIES, 10)); }