@@ -0,0 +1,2493 @@
+/*%0A * Copyright 2013-2014 the original author or authors.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22); you may not use this file except in compliance with%0A * the License. You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on%0A * an %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the%0A * specific language governing permissions and limitations under the License.%0A */%0A%0Apackage org.springframework.security.oauth2.provider.token;%0A%0Aimport static org.junit.Assert.*;%0A%0Aimport java.util.Collections;%0Aimport java.util.Map;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.springframework.security.authentication.UsernamePasswordAuthenticationToken;%0Aimport org.springframework.security.core.authority.AuthorityUtils;%0Aimport org.springframework.security.core.authority.SimpleGrantedAuthority;%0Aimport org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;%0Aimport org.springframework.security.oauth2.provider.OAuth2Authentication;%0Aimport org.springframework.security.oauth2.provider.OAuth2Request;%0Aimport org.springframework.security.oauth2.provider.RequestTokenFactory;%0A%0A/**%0A * @author Dave Syer%0A *%0A */%0Apublic class DefaultAccessTokenConverterTests %7B%0A%0A%09private DefaultAccessTokenConverter converter = new DefaultAccessTokenConverter();%0A%0A%09private UsernamePasswordAuthenticationToken userAuthentication = new UsernamePasswordAuthenticationToken(%22foo%22,%0A%09%09%09%22bar%22, Collections.singleton(new SimpleGrantedAuthority(%22ROLE_USER%22)));%0A%0A%09private OAuth2Authentication authentication;%0A%0A%09@Before%0A%09public void init() %7B%0A%09%09OAuth2Request request = RequestTokenFactory.createOAuth2Request(null, %22id%22,%0A%09%09%09%09AuthorityUtils.commaSeparatedStringToAuthorityList(%22ROLE_CLIENT%22), true, Collections.singleton(%22read%22),%0A%09%09%09%09Collections.singleton(%22resource%22), null, null, null);%0A%09%09authentication = new OAuth2Authentication(request, userAuthentication);%0A%09%7D%0A%0A%09@Test%0A%09public void extractAuthentication() %7B%0A%09%09DefaultOAuth2AccessToken token = new DefaultOAuth2AccessToken(%22FOO%22);%0A%09%09Map%3CString, ?%3E map = converter.convertAccessToken(token, authentication);%0A%09%09assertTrue(map.containsKey(AccessTokenConverter.AUD));%0A%09%09OAuth2Authentication extracted = converter.extractAuthentication(map);%0A%09%09assertTrue(extracted.getOAuth2Request().getResourceIds().contains(%22resource%22));%0A%09%7D%0A%0A%7D%0A

Add test for AUD claim in DefaultAccessTokenConverter