use of org.orcid.jaxb.model.clientgroup.OrcidClient 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.OrcidClient in project ORCID-Source by ORCID.
the class OrcidClientGroupManagerImpl method createOrUpdateOrcidClientGroup.
@Override
@Transactional
public OrcidClient createOrUpdateOrcidClientGroup(String groupOrcid, OrcidClient orcidClient) {
OrcidClient result = null;
// Use the profile DAO to link the clients to the group, so get the
// group profile entity.
ProfileEntity groupProfileEntity = profileDao.find(groupOrcid);
SortedSet<ClientDetailsEntity> clientDetailsEntities = groupProfileEntity.getClients();
if (clientDetailsEntities == null) {
clientDetailsEntities = new TreeSet<>(new OrcidEntityIdComparator<String>());
groupProfileEntity.setClients(clientDetailsEntities);
}
processClient(groupOrcid, clientDetailsEntities, orcidClient, getClientType(groupProfileEntity.getGroupType()));
OrcidClientGroup group = retrieveOrcidClientGroup(groupOrcid);
for (OrcidClient populatedClient : group.getOrcidClient()) {
if (compareClients(orcidClient, populatedClient))
result = populatedClient;
}
// Regenerate client group and return.
return result;
}
use of org.orcid.jaxb.model.clientgroup.OrcidClient in project ORCID-Source by ORCID.
the class WorkspaceController method getSourceGrantReadWizard.
@RequestMapping(value = "/my-orcid/sourceGrantReadWizard.json", method = RequestMethod.GET)
@ResponseBody
public ThirdPartyRedirect getSourceGrantReadWizard() {
ThirdPartyRedirect tpr = new ThirdPartyRedirect();
ProfileEntity profile = profileEntityCacheManager.retrieve(getEffectiveUserOrcid());
if (profile.getSource() == null || profile.getSource().getSourceId() == null) {
return tpr;
}
String sourcStr = profile.getSource().getSourceId();
// Check that the cache is up to date
evictThirdPartyLinkManagerCacheIfNeeded();
// Get list of clients
List<OrcidClient> orcidClients = thirdPartyLinkManager.findOrcidClientsWithPredefinedOauthScopeReadAccess();
for (OrcidClient orcidClient : orcidClients) {
if (sourcStr.equals(orcidClient.getClientId())) {
RedirectUri ru = orcidClient.getRedirectUris().getRedirectUri().get(0);
String redirect = getBaseUri() + "/oauth/authorize?client_id=" + orcidClient.getClientId() + "&response_type=code&scope=" + ru.getScopeAsSingleString() + "&redirect_uri=" + ru.getValue();
tpr.setUrl(redirect);
tpr.setDisplayName(orcidClient.getDisplayName());
tpr.setShortDescription(orcidClient.getShortDescription());
return tpr;
}
}
return tpr;
}
use of org.orcid.jaxb.model.clientgroup.OrcidClient 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;
}
use of org.orcid.jaxb.model.clientgroup.OrcidClient in project ORCID-Source by ORCID.
the class Jpa2JaxbAdapterImpl method toOrcidClientGroup.
@Override
public OrcidClientGroup toOrcidClientGroup(ProfileEntity profileEntity) {
OrcidClientGroup group = new OrcidClientGroup();
group.setGroupOrcid(profileEntity.getId());
if (profileEntity.getRecordNameEntity() != null) {
group.setGroupName(profileEntity.getRecordNameEntity().getCreditName());
}
group.setType(profileEntity.getGroupType());
Set<EmailEntity> emailEntities = profileEntity.getEmails();
for (EmailEntity emailEntity : emailEntities) {
group.setEmail(emailEntity.getId());
}
for (ClientDetailsEntity clientDetailsEntity : profileEntity.getClients()) {
OrcidClient client = toOrcidClient(clientDetailsEntity);
group.getOrcidClient().add(client);
}
return group;
}
Aggregations