use of org.orcid.jaxb.model.message.ScopePathType in project ORCID-Source by ORCID.
the class ProfileEntityManagerImpl method getApplications.
@Override
public List<ApplicationSummary> getApplications(String orcid) {
List<OrcidOauth2TokenDetail> tokenDetails = orcidOauth2TokenService.findByUserName(orcid);
List<ApplicationSummary> applications = new ArrayList<ApplicationSummary>();
Map<Pair<String, Set<ScopePathType>>, ApplicationSummary> existingApplications = new HashMap<Pair<String, Set<ScopePathType>>, ApplicationSummary>();
if (tokenDetails != null && !tokenDetails.isEmpty()) {
for (OrcidOauth2TokenDetail token : tokenDetails) {
if (token.getTokenDisabled() == null || !token.getTokenDisabled()) {
ClientDetailsEntity client = clientDetailsEntityCacheManager.retrieve(token.getClientDetailsId());
if (client != null) {
ApplicationSummary applicationSummary = new ApplicationSummary();
// Check the scopes
Set<ScopePathType> scopesGrantedToClient = ScopePathType.getScopesFromSpaceSeparatedString(token.getScope());
Map<ScopePathType, String> scopePathMap = new HashMap<ScopePathType, String>();
String scopeFullPath = ScopePathType.class.getName() + ".";
for (ScopePathType tempScope : scopesGrantedToClient) {
try {
scopePathMap.put(tempScope, localeManager.resolveMessage(scopeFullPath + tempScope.toString()));
} catch (NoSuchMessageException e) {
LOGGER.warn("No message to display for scope " + tempScope.toString());
}
}
// the application summary element
if (!scopePathMap.isEmpty()) {
applicationSummary.setScopePaths(scopePathMap);
applicationSummary.setOrcidHost(orcidUrlManager.getBaseHost());
applicationSummary.setOrcidUri(orcidUrlManager.getBaseUriHttp() + "/" + client.getId());
applicationSummary.setOrcidPath(client.getId());
applicationSummary.setName(client.getClientName());
applicationSummary.setWebsiteValue(client.getClientWebsite());
applicationSummary.setApprovalDate(token.getDateCreated());
applicationSummary.setTokenId(String.valueOf(token.getId()));
// Add member information
if (!PojoUtil.isEmpty(client.getGroupProfileId())) {
ProfileEntity member = profileEntityCacheManager.retrieve(client.getGroupProfileId());
applicationSummary.setGroupOrcidPath(member.getId());
applicationSummary.setGroupName(getMemberDisplayName(member));
}
if (shouldBeAddedToTheApplicationsList(applicationSummary, scopesGrantedToClient, existingApplications)) {
applications.add(applicationSummary);
}
}
}
}
}
}
return applications;
}
use of org.orcid.jaxb.model.message.ScopePathType in project ORCID-Source by ORCID.
the class JpaJaxbClientAdapterTest method getClient.
private Client getClient() {
Client client = new Client();
client.setAllowAutoDeprecate(true);
client.setPersistentTokensEnabled(true);
client.setClientType(ClientType.CREATOR);
client.setDescription("description");
client.setGroupProfileId("group-profile-id");
client.setId("id");
client.setName("client-name");
client.setWebsite("client-website");
client.setAuthenticationProviderId("authentication-provider-id");
Set<ClientRedirectUri> clientRedirectUris = new HashSet<ClientRedirectUri>();
ClientRedirectUri rUri1 = new ClientRedirectUri();
Set<ScopePathType> scopes1 = new HashSet<ScopePathType>();
scopes1.add(ScopePathType.ACTIVITIES_READ_LIMITED);
rUri1.setPredefinedClientScopes(scopes1);
rUri1.setRedirectUri("redirect-uri-1");
rUri1.setRedirectUriType("type-1");
rUri1.setUriActType("uri-act-type-1");
rUri1.setUriGeoArea("uri-geo-area-1");
ClientRedirectUri rUri2 = new ClientRedirectUri();
Set<ScopePathType> scopes2 = new HashSet<ScopePathType>();
scopes2.add(ScopePathType.ACTIVITIES_UPDATE);
rUri2.setPredefinedClientScopes(scopes2);
rUri2.setRedirectUri("redirect-uri-2");
rUri2.setRedirectUriType("type-2");
rUri2.setUriActType("uri-act-type-2");
rUri2.setUriGeoArea("uri-geo-area-2");
ClientRedirectUri rUri3 = new ClientRedirectUri();
Set<ScopePathType> scopes3 = new HashSet<ScopePathType>();
scopes3.add(ScopePathType.AFFILIATIONS_CREATE);
rUri3.setPredefinedClientScopes(scopes3);
rUri3.setRedirectUri("redirect-uri-3");
rUri3.setRedirectUriType("type-3");
rUri3.setUriActType("uri-act-type-3");
rUri3.setUriGeoArea("uri-geo-area-3");
clientRedirectUris.add(rUri1);
clientRedirectUris.add(rUri2);
clientRedirectUris.add(rUri3);
client.setClientRedirectUris(clientRedirectUris);
return client;
}
use of org.orcid.jaxb.model.message.ScopePathType in project ORCID-Source by ORCID.
the class Client method toModelObject.
public org.orcid.jaxb.model.v3.dev1.client.Client toModelObject() {
org.orcid.jaxb.model.v3.dev1.client.Client modelObject = new org.orcid.jaxb.model.v3.dev1.client.Client();
if (this.getAllowAutoDeprecate() != null) {
modelObject.setAllowAutoDeprecate(this.getAllowAutoDeprecate().getValue());
}
if (this.getAuthenticationProviderId() != null) {
modelObject.setAuthenticationProviderId(this.getAuthenticationProviderId().getValue());
}
if (this.getClientId() != null) {
modelObject.setId(this.getClientId().getValue());
}
if (this.getDisplayName() != null) {
modelObject.setName(this.getDisplayName().getValue());
}
if (this.getMemberId() != null) {
modelObject.setGroupProfileId(this.getMemberId().getValue());
}
if (this.getPersistentTokenEnabled() != null) {
modelObject.setPersistentTokensEnabled(this.getPersistentTokenEnabled().getValue());
}
if (this.getRedirectUris() != null) {
Set<ClientRedirectUri> redirectUriSet = new HashSet<ClientRedirectUri>();
for (RedirectUri rUri : this.getRedirectUris()) {
ClientRedirectUri redirectUri = new ClientRedirectUri();
if (rUri.getScopes() != null) {
Set<ScopePathType> scopes = new HashSet<ScopePathType>();
for (String scope : rUri.getScopes()) {
scopes.add(ScopePathType.fromValue(scope));
}
redirectUri.setPredefinedClientScopes(scopes);
}
redirectUri.setRedirectUri(rUri.getValue().getValue());
redirectUri.setRedirectUriType(rUri.getType().getValue());
if (rUri.getActType() != null) {
redirectUri.setUriActType(rUri.getActType().getValue());
}
if (rUri.getGeoArea() != null) {
redirectUri.setUriGeoArea(rUri.getGeoArea().getValue());
}
redirectUriSet.add(redirectUri);
}
modelObject.setClientRedirectUris(redirectUriSet);
}
if (this.getShortDescription() != null) {
modelObject.setDescription(this.getShortDescription().getValue());
}
if (this.getWebsite() != null) {
modelObject.setWebsite(this.getWebsite().getValue());
}
return modelObject;
}
use of org.orcid.jaxb.model.message.ScopePathType in project ORCID-Source by ORCID.
the class RedirectUri method fromModelObject.
public static RedirectUri fromModelObject(ClientRedirectUri modelObject) {
RedirectUri redirectUri = new RedirectUri();
if (modelObject.getPredefinedClientScopes() != null) {
for (ScopePathType scope : modelObject.getPredefinedClientScopes()) {
redirectUri.getScopes().add(scope.value());
}
}
redirectUri.setValue(Text.valueOf(modelObject.getRedirectUri()));
redirectUri.setType(Text.valueOf(modelObject.getRedirectUriType()));
redirectUri.setActType(Text.valueOf(modelObject.getUriActType()));
redirectUri.setGeoArea(Text.valueOf(modelObject.getUriGeoArea()));
return redirectUri;
}
use of org.orcid.jaxb.model.message.ScopePathType in project ORCID-Source by ORCID.
the class RedirectUri method fromModelObject.
public static RedirectUri fromModelObject(org.orcid.jaxb.model.client_v2.ClientRedirectUri modelObject) {
RedirectUri redirectUri = new RedirectUri();
if (modelObject.getPredefinedClientScopes() != null) {
for (ScopePathType scope : modelObject.getPredefinedClientScopes()) {
redirectUri.getScopes().add(scope.value());
}
}
redirectUri.setValue(Text.valueOf(modelObject.getRedirectUri()));
redirectUri.setType(Text.valueOf(modelObject.getRedirectUriType()));
redirectUri.setActType(Text.valueOf(modelObject.getUriActType()));
redirectUri.setGeoArea(Text.valueOf(modelObject.getUriGeoArea()));
return redirectUri;
}
Aggregations