use of org.orcid.jaxb.model.clientgroup.RedirectUri in project ORCID-Source by ORCID.
the class OrcidClientGroupManagerTest method testAddMoreThanOneClientToBasicInstitutionGroup.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testAddMoreThanOneClientToBasicInstitutionGroup() {
final OrcidClientGroup group = new OrcidClientGroup();
group.setGroupName("Elsevier");
group.setEmail("basic-institution-member@elsevier.com" + System.currentTimeMillis());
group.setType(MemberType.BASIC_INSTITUTION);
OrcidClientGroup createdGroup = transactionTemplate.execute(new TransactionCallback<OrcidClientGroup>() {
public OrcidClientGroup doInTransaction(TransactionStatus status) {
return orcidClientGroupManager.createOrUpdateOrcidClientGroup(group);
}
});
RedirectUris redirectUris = new RedirectUris();
RedirectUri redirectUri = new RedirectUri("http://uri.com");
redirectUris.getRedirectUri().add(redirectUri);
OrcidClient client1 = new OrcidClient();
client1.setDisplayName("Name");
client1.setRedirectUris(redirectUris);
client1.setShortDescription("Description");
client1.setType(ClientType.CREATOR);
client1.setWebsite("http://site.com");
// Add one client
try {
orcidClientGroupManager.createAndPersistClientProfile(createdGroup.getGroupOrcid(), client1);
} catch (OrcidClientGroupManagementException e) {
fail();
}
OrcidClient client2 = new OrcidClient();
client2.setDisplayName("Name");
client2.setRedirectUris(redirectUris);
client2.setShortDescription("Description");
client2.setType(ClientType.CREATOR);
client2.setWebsite("http://site.com");
// Add other client should fail
try {
orcidClientGroupManager.createAndPersistClientProfile(createdGroup.getGroupOrcid(), client2);
fail();
} catch (OrcidClientGroupManagementException e) {
}
}
use of org.orcid.jaxb.model.clientgroup.RedirectUri in project ORCID-Source by ORCID.
the class ClientDetailsManagerImpl method getClientRegisteredRedirectUris.
private SortedSet<ClientRedirectUriEntity> getClientRegisteredRedirectUris(Set<RedirectUri> clientRegisteredRedirectUris, ClientDetailsEntity clientDetailsEntity) {
SortedSet<ClientRedirectUriEntity> clientRedirectUriEntities = new TreeSet<ClientRedirectUriEntity>();
for (RedirectUri clientRegisteredRedirectUri : clientRegisteredRedirectUris) {
ClientRedirectUriEntity clientRedirectUriEntity = new ClientRedirectUriEntity();
clientRedirectUriEntity.setClientDetailsEntity(clientDetailsEntity);
clientRedirectUriEntity.setRedirectUri(clientRegisteredRedirectUri.getValue());
clientRedirectUriEntity.setRedirectUriType(clientRegisteredRedirectUri.getType().value());
List<ScopePathType> scopesForRedirect = clientRegisteredRedirectUri.getScope();
String clientPredefinedScopes = scopesForRedirect != null ? ScopePathType.getScopesAsSingleString(scopesForRedirect) : null;
clientRedirectUriEntity.setPredefinedClientScope(clientPredefinedScopes);
clientRedirectUriEntity.setUriActType(clientRegisteredRedirectUri.getActType());
clientRedirectUriEntity.setUriGeoArea(clientRegisteredRedirectUri.getGeoArea());
clientRedirectUriEntities.add(clientRedirectUriEntity);
}
return clientRedirectUriEntities;
}
use of org.orcid.jaxb.model.clientgroup.RedirectUri in project ORCID-Source by ORCID.
the class ClientDetailsManagerImpl method getClientRegisteredRedirectUris.
private SortedSet<ClientRedirectUriEntity> getClientRegisteredRedirectUris(Set<RedirectUri> clientRegisteredRedirectUris, ClientDetailsEntity clientDetailsEntity) {
SortedSet<ClientRedirectUriEntity> clientRedirectUriEntities = new TreeSet<ClientRedirectUriEntity>();
for (RedirectUri clientRegisteredRedirectUri : clientRegisteredRedirectUris) {
ClientRedirectUriEntity clientRedirectUriEntity = new ClientRedirectUriEntity();
clientRedirectUriEntity.setClientDetailsEntity(clientDetailsEntity);
clientRedirectUriEntity.setRedirectUri(clientRegisteredRedirectUri.getValue());
clientRedirectUriEntity.setRedirectUriType(clientRegisteredRedirectUri.getType().value());
List<ScopePathType> scopesForRedirect = clientRegisteredRedirectUri.getScope();
String clientPredefinedScopes = scopesForRedirect != null ? ScopePathType.getScopesAsSingleString(scopesForRedirect) : null;
clientRedirectUriEntity.setPredefinedClientScope(clientPredefinedScopes);
clientRedirectUriEntity.setUriActType(clientRegisteredRedirectUri.getActType());
clientRedirectUriEntity.setUriGeoArea(clientRegisteredRedirectUri.getGeoArea());
clientRedirectUriEntities.add(clientRedirectUriEntity);
}
return clientRedirectUriEntities;
}
use of org.orcid.jaxb.model.clientgroup.RedirectUri in project ORCID-Source by ORCID.
the class ClientDetailsManagerTest method testCreateClientDetailsWithNonExistentOrcid.
@Test(expected = IllegalArgumentException.class)
@Rollback
@Transactional
public void testCreateClientDetailsWithNonExistentOrcid() throws Exception {
Set<String> clientScopes = new HashSet<String>();
clientScopes.add("/orcid-profile/create");
Set<String> clientResourceIds = new HashSet<String>();
clientResourceIds.add("orcid-t2-api");
Set<String> clientAuthorizedGrantTypes = new HashSet<String>();
clientAuthorizedGrantTypes.add("client_credentials");
clientAuthorizedGrantTypes.add("authorization_code");
clientAuthorizedGrantTypes.add("refresh_token");
Set<RedirectUri> clientRegisteredRedirectUris = new HashSet<RedirectUri>();
clientRegisteredRedirectUris.add(new RedirectUri("http://www.google.com/"));
List<String> clientGrantedAuthorities = new ArrayList<String>();
clientGrantedAuthorities.add("ROLE_ADMIN");
clientDetailsManager.createClientDetails("8888-9999-9999-9999", CLIENT_NAME, CLIENT_DESCRIPTION, null, CLIENT_WEBSITE, ClientType.CREATOR, clientScopes, clientResourceIds, clientAuthorizedGrantTypes, clientRegisteredRedirectUris, clientGrantedAuthorities, true);
}
use of org.orcid.jaxb.model.clientgroup.RedirectUri in project ORCID-Source by ORCID.
the class SetUpClientsAndUsers method createClient.
private void createClient(Map<String, String> params) {
Set<String> clientResourceIds = new HashSet<String>();
clientResourceIds.add("orcid");
Set<String> clientAuthorizedGrantTypes = new HashSet<String>();
clientAuthorizedGrantTypes.add("client_credentials");
clientAuthorizedGrantTypes.add("authorization_code");
clientAuthorizedGrantTypes.add("refresh_token");
ClientType clientType = ClientType.PREMIUM_CREATOR;
if (params.containsKey(CLIENT_TYPE)) {
clientType = ClientType.fromValue(params.get(CLIENT_TYPE));
}
Set<RedirectUri> redirectUrisToAdd = new HashSet<RedirectUri>();
RedirectUri redirectUri = new RedirectUri(params.get(REDIRECT_URI));
if (clientType.equals(ClientType.PUBLIC_CLIENT)) {
redirectUri.setType(RedirectUriType.SSO_AUTHENTICATION);
} else {
redirectUri.setType(RedirectUriType.DEFAULT);
}
redirectUrisToAdd.add(redirectUri);
List<String> clientGrantedAuthorities = new ArrayList<String>();
clientGrantedAuthorities.add("ROLE_CLIENT");
String name = params.get(CLIENT_NAME);
String description = params.get(CLIENT_DESCRIPTION);
String website = params.get(CLIENT_WEBSITE);
String clientId = params.get(CLIENT_ID);
String clientSecret = encryptionManager.encryptForInternalUse(params.get(CLIENT_SECRET));
String memberId = params.get(MEMBER_ID);
Set<String> scopes = null;
if (clientType.equals(ClientType.PUBLIC_CLIENT)) {
scopes = new HashSet<String>(Arrays.asList(ScopePathType.AUTHENTICATE.value(), ScopePathType.READ_PUBLIC.value()));
} else {
scopes = orcidClientGroupManager.premiumCreatorScopes();
if (params.containsKey(ADD_ORCID_INTERNAL_SCOPES)) {
scopes.add(ScopePathType.INTERNAL_PERSON_LAST_MODIFIED.value());
}
//Add scopes to allow group read and update
scopes.add(ScopePathType.GROUP_ID_RECORD_READ.value());
scopes.add(ScopePathType.GROUP_ID_RECORD_UPDATE.value());
//Add notifications scope
scopes.add(ScopePathType.PREMIUM_NOTIFICATION.value());
//Add openid scope
scopes.add(ScopePathType.OPENID.value());
}
clientDetailsManager.populateClientDetailsEntity(clientId, memberId, name, description, null, website, clientSecret, clientType, scopes, clientResourceIds, clientAuthorizedGrantTypes, redirectUrisToAdd, clientGrantedAuthorities, true);
}
Aggregations