List of usage examples for org.springframework.security.oauth2.provider OAuth2Request getAuthorities
public Collection<? extends GrantedAuthority> getAuthorities()
From source file:org.mitre.oauth2.model.AuthenticationHolderEntity.java
public void setAuthentication(OAuth2Authentication authentication) { // pull apart the request and save its bits OAuth2Request o2Request = authentication.getOAuth2Request(); setAuthorities(o2Request.getAuthorities()); setClientId(o2Request.getClientId()); setExtensions(o2Request.getExtensions()); setRedirectUri(o2Request.getRedirectUri()); setRequestParameters(o2Request.getRequestParameters()); setResourceIds(o2Request.getResourceIds()); setResponseTypes(o2Request.getResponseTypes()); setScope(o2Request.getScope()); setApproved(o2Request.isApproved()); if (authentication.getUserAuthentication() != null) { this.userAuth = new SavedUserAuthentication(authentication.getUserAuthentication()); } else {/*from w ww .j av a 2 s .c om*/ this.userAuth = null; } }
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 ww w.ja v a2 s .c om 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; }