use of org.orcid.jaxb.model.clientgroup.RedirectUris in project ORCID-Source by ORCID.
the class Client method valueOf.
public static Client valueOf(OrcidClient orcidClient) {
Client client = new Client();
client.setClientId(Text.valueOf(orcidClient.getClientId()));
client.setClientSecret(Text.valueOf(orcidClient.getClientSecret()));
client.setDisplayName(Text.valueOf(orcidClient.getDisplayName()));
client.setShortDescription(Text.valueOf(orcidClient.getShortDescription()));
if (orcidClient.getType() != null)
client.setType(Text.valueOf(orcidClient.getType().value()));
client.setWebsite(Text.valueOf(orcidClient.getWebsite()));
Checkbox persistentTokenEnabled = new Checkbox();
persistentTokenEnabled.setValue(orcidClient.isPersistentTokenEnabled());
client.setPersistentTokenEnabled(persistentTokenEnabled);
List<RedirectUri> redirectUris = new ArrayList<RedirectUri>();
RedirectUris orcidRedirectUris = orcidClient.getRedirectUris();
if (orcidRedirectUris != null && orcidRedirectUris.getRedirectUri() != null) {
for (org.orcid.jaxb.model.clientgroup.RedirectUri orcidRedirectUri : orcidRedirectUris.getRedirectUri()) {
redirectUris.add(RedirectUri.toRedirectUri(orcidRedirectUri));
}
}
if (orcidClient.getIdp() != null) {
client.setAuthenticationProviderId(Text.valueOf(orcidClient.getIdp()));
}
client.setRedirectUris(redirectUris);
client.setAllowAutoDeprecate(Checkbox.valueOf(orcidClient.getAllowAutoDeprecate()));
return client;
}
use of org.orcid.jaxb.model.clientgroup.RedirectUris 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.RedirectUris 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.RedirectUris in project ORCID-Source by ORCID.
the class Client method toOrcidClient.
public OrcidClient toOrcidClient() {
OrcidClient orcidClient = new OrcidClient();
orcidClient.setDisplayName(this.displayName.getValue());
orcidClient.setWebsite(this.website.getValue());
orcidClient.setShortDescription(this.shortDescription.getValue());
orcidClient.setClientId(this.clientId.getValue());
if (this.getAuthenticationProviderId() != null) {
orcidClient.setIdp(this.getAuthenticationProviderId().getValue());
}
if (!PojoUtil.isEmpty(this.clientSecret))
orcidClient.setClientSecret(this.clientSecret.getValue());
if (!PojoUtil.isEmpty(this.type))
orcidClient.setType(ClientType.fromValue(this.type.getValue()));
RedirectUris redirectUris = new RedirectUris();
for (RedirectUri redirectUri : this.redirectUris) {
redirectUris.getRedirectUri().add(redirectUri.toRedirectUri());
}
orcidClient.setRedirectUris(redirectUris);
if (persistentTokenEnabled != null)
orcidClient.setPersistentTokenEnabled(persistentTokenEnabled.getValue());
orcidClient.setAllowAutoDeprecate(this.getAllowAutoDeprecate() == null ? false : this.getAllowAutoDeprecate().getValue());
return orcidClient;
}
use of org.orcid.jaxb.model.clientgroup.RedirectUris in project ORCID-Source by ORCID.
the class Jpa2JaxbAdapterImpl method toOrcidClient.
@Override
public OrcidClient toOrcidClient(ClientDetailsEntity clientDetailsEntity) {
OrcidClient client = new OrcidClient();
client.setClientId(clientDetailsEntity.getId());
client.setType(clientDetailsEntity.getClientType());
if (clientDetailsEntity != null) {
client.setClientSecret(clientDetailsEntity.getClientSecretForJpa());
client.setDisplayName(clientDetailsEntity.getClientName());
client.setShortDescription(clientDetailsEntity.getClientDescription());
client.setWebsite(clientDetailsEntity.getClientWebsite());
client.setPersistentTokenEnabled(clientDetailsEntity.isPersistentTokensEnabled());
client.setIdp(clientDetailsEntity.getAuthenticationProviderId());
client.setAllowAutoDeprecate(clientDetailsEntity.getAllowAutoDeprecate());
Set<ClientRedirectUriEntity> redirectUriEntities = clientDetailsEntity.getClientRegisteredRedirectUris();
RedirectUris redirectUris = new RedirectUris();
client.setRedirectUris(redirectUris);
for (ClientRedirectUriEntity redirectUriEntity : redirectUriEntities) {
RedirectUri redirectUri = new RedirectUri(redirectUriEntity.getRedirectUri());
redirectUri.setType(RedirectUriType.fromValue(redirectUriEntity.getRedirectUriType()));
String predefinedScope = redirectUriEntity.getPredefinedClientScope();
if (StringUtils.isNotBlank(predefinedScope)) {
List<ScopePathType> scopePathType = new ArrayList<ScopePathType>(ScopePathType.getScopesFromSpaceSeparatedString(predefinedScope));
redirectUri.setScope(scopePathType);
}
redirectUri.setActType(redirectUriEntity.getUriActType());
redirectUri.setGeoArea(redirectUriEntity.getUriGeoArea());
redirectUris.getRedirectUri().add(redirectUri);
}
}
return client;
}
Aggregations