use of org.orcid.jaxb.model.clientgroup.OrcidClientGroup in project ORCID-Source by ORCID.
the class OrcidClientGroupManagerImpl method retrieveOrcidClientGroup.
@Override
@Transactional
public OrcidClientGroup retrieveOrcidClientGroup(String groupOrcid) {
ProfileEntity profileEntity = profileDao.find(groupOrcid);
if (profileEntity == null) {
return null;
}
OrcidClientGroup group = adapter.toOrcidClientGroup(profileEntity);
for (OrcidClient client : group.getOrcidClient()) {
client.setClientSecret(encryptionManager.decryptForInternalUse(client.getClientSecret()));
}
return group;
}
use of org.orcid.jaxb.model.clientgroup.OrcidClientGroup in project ORCID-Source by ORCID.
the class OrcidClientGroupManagerImpl method createOrUpdateOrcidClientGroupForAPIRequest.
@Override
@Transactional
public OrcidClientGroup createOrUpdateOrcidClientGroupForAPIRequest(OrcidClientGroup orcidClientGroup) {
OrcidClientGroup result = createOrUpdateOrcidClientGroup(orcidClientGroup);
modifyClientTypesForAPIRequest(result);
return result;
}
use of org.orcid.jaxb.model.clientgroup.OrcidClientGroup in project ORCID-Source by ORCID.
the class OrcidClientGroupManagerTest method testCreateOrcidCreatorClientGroup.
@Test
public void testCreateOrcidCreatorClientGroup() {
OrcidClientGroup createdGroup = orcidClientGroupManager.createOrUpdateOrcidClientGroup(group);
assertNotNull(createdGroup);
assertEquals(group.getGroupName(), createdGroup.getGroupName());
assertEquals(group.getEmail(), createdGroup.getEmail());
assertNotNull(createdGroup.getGroupOrcid());
List<OrcidClient> createdClients = createdGroup.getOrcidClient();
assertNotNull(createdClients);
assertEquals(2, createdClients.size());
Map<String, OrcidClient> createdClientsMappedByName = new HashMap<String, OrcidClient>();
for (OrcidClient createdClient : createdClients) {
assertNotNull(createdClient.getClientId());
assertNotNull(createdClient.getClientSecret());
assertNotNull(createdClient.getIdp());
createdClientsMappedByName.put(createdClient.getDisplayName(), createdClient);
}
OrcidClient complexityClient = createdClientsMappedByName.get("Ecological Complexity");
assertNotNull(complexityClient);
assertEquals("http://www.journals.elsevier.com/ecological-complexity", complexityClient.getWebsite());
assertEquals("An International Journal on Biocomplexity in the Environment and Theoretical Ecology", complexityClient.getShortDescription());
List<RedirectUri> createdRedirectUris = complexityClient.getRedirectUris().getRedirectUri();
assertNotNull(createdRedirectUris);
assertEquals(1, createdRedirectUris.size());
assertEquals("http://www.journals.elsevier.com/ecological-complexity/orcid-callback", createdRedirectUris.get(0).getValue());
// Look up client details directly to check scopes
ClientDetailsEntity complexityEntity = clientDetailsManager.findByClientId(complexityClient.getClientId());
Set<String> clientScopeTypes = complexityEntity.getScope();
assertNotNull(clientScopeTypes);
assertTrue(clientScopeTypes.contains("/orcid-profile/read-limited"));
assertTrue(clientScopeTypes.contains("/orcid-bio/read-limited"));
assertTrue(clientScopeTypes.contains("/orcid-works/read-limited"));
}
use of org.orcid.jaxb.model.clientgroup.OrcidClientGroup in project ORCID-Source by ORCID.
the class OrcidClientGroupManagerTest method testAddCreatorToPremiumGroup.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testAddCreatorToPremiumGroup() {
final OrcidClientGroup group = new OrcidClientGroup();
group.setGroupName("Elsevier");
group.setEmail("premium-member@elsevier.com" + System.currentTimeMillis());
group.setType(MemberType.PREMIUM);
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 creator client to a premium group should fail
try {
OrcidClient orcidClient = orcidClientGroupManager.createAndPersistClientProfile(createdGroup.getGroupOrcid(), client1);
assertEquals(orcidClient.getType(), ClientType.PREMIUM_UPDATER);
} catch (OrcidClientGroupManagementException e) {
}
}
use of org.orcid.jaxb.model.clientgroup.OrcidClientGroup 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) {
}
}
Aggregations