use of org.orcid.persistence.jpa.entities.ClientGrantedAuthorityEntity in project ORCID-Source by ORCID.
the class ClientDetailsManagerImpl method getClientGrantedAuthorities.
private List<ClientGrantedAuthorityEntity> getClientGrantedAuthorities(List<String> clientGrantedAuthorities, ClientDetailsEntity clientDetailsEntity) {
List<ClientGrantedAuthorityEntity> clientGrantedAuthorityEntities = new ArrayList<ClientGrantedAuthorityEntity>(clientGrantedAuthorities.size());
for (String clientGrantedAuthority : clientGrantedAuthorities) {
ClientGrantedAuthorityEntity clientGrantedAuthorityEntity = new ClientGrantedAuthorityEntity();
clientGrantedAuthorityEntity.setClientDetailsEntity(clientDetailsEntity);
clientGrantedAuthorityEntity.setAuthority(clientGrantedAuthority);
clientGrantedAuthorityEntities.add(clientGrantedAuthorityEntity);
}
return clientGrantedAuthorityEntities;
}
use of org.orcid.persistence.jpa.entities.ClientGrantedAuthorityEntity in project ORCID-Source by ORCID.
the class OrcidSSOManagerImplTest method testGrantSSOAccessToUser.
@Test
@Rollback(true)
public void testGrantSSOAccessToUser() {
HashSet<String> uris = new HashSet<String>();
uris.add("http://1.com");
uris.add("http://2.com");
orcidSSOManager.grantSSOAccess(orcid1, "My App", "My Description", "MyWebsite", uris);
ClientDetailsEntity clientDetails = orcidSSOManager.getUserCredentials(orcid1);
assertNotNull(clientDetails);
assertNotNull(clientDetails.getAuthorizedGrantTypes());
assertTrue(clientDetails.getAuthorizedGrantTypes().contains("authorization_code"));
assertNotNull(clientDetails.getClientRegisteredRedirectUris());
assertEquals(clientDetails.getClientRegisteredRedirectUris().size(), 2);
for (ClientRedirectUriEntity redirectUri : clientDetails.getClientRegisteredRedirectUris()) {
assertTrue(redirectUri.getRedirectUri().equals("http://1.com") || redirectUri.getRedirectUri().equals("http://2.com"));
assertTrue(redirectUri.getRedirectUriType().equals(RedirectUriType.SSO_AUTHENTICATION.value()));
}
Set<ClientAuthorisedGrantTypeEntity> grantTypeList = clientDetails.getClientAuthorizedGrantTypes();
assertEquals(3, grantTypeList.size());
Set<String> grantTypes = clientDetails.getAuthorizedGrantTypes();
assertTrue(grantTypes.contains("authorization_code"));
assertTrue(grantTypes.contains("client_credentials"));
assertTrue(grantTypes.contains("refresh_token"));
List<ClientGrantedAuthorityEntity> grantedAuthList = clientDetails.getClientGrantedAuthorities();
assertEquals(1, grantedAuthList.size());
for (ClientGrantedAuthorityEntity grantedAuth : grantedAuthList) {
assertEquals(grantedAuth.getAuthority(), "ROLE_PUBLIC");
}
}
Aggregations