use of org.orcid.persistence.jpa.entities.ClientRedirectUriEntity in project ORCID-Source by ORCID.
the class SSOCredentials method toSSOCredentials.
public static SSOCredentials toSSOCredentials(ClientDetailsEntity clientDetails) {
SSOCredentials result = new SSOCredentials();
if (clientDetails != null) {
result.setClientName(Text.valueOf(clientDetails.getClientName()));
result.setClientDescription(Text.valueOf(clientDetails.getClientDescription()));
result.setClientWebsite(Text.valueOf(clientDetails.getClientWebsite()));
if (clientDetails.getClientSecrets() != null) {
for (ClientSecretEntity clientSecret : clientDetails.getClientSecrets()) {
if (clientSecret.isPrimary())
result.setClientSecret(Text.valueOf(clientSecret.getDecryptedClientSecret()));
}
}
result.setClientOrcid(Text.valueOf(clientDetails.getClientId()));
if (clientDetails.getClientRegisteredRedirectUris() != null && !clientDetails.getClientRegisteredRedirectUris().isEmpty()) {
result.redirectUris = new TreeSet<RedirectUri>();
for (ClientRedirectUriEntity redirectUri : clientDetails.getClientRegisteredRedirectUris()) {
if (RedirectUriType.SSO_AUTHENTICATION.value().equals(redirectUri.getRedirectUriType())) {
RedirectUri rUri = new RedirectUri();
rUri.setValue(Text.valueOf(redirectUri.getRedirectUri()));
result.redirectUris.add(rUri);
}
}
}
}
return result;
}
use of org.orcid.persistence.jpa.entities.ClientRedirectUriEntity in project ORCID-Source by ORCID.
the class Client method valueOf.
public static Client valueOf(ClientDetailsEntity clientDetails) {
Client client = new Client();
if (clientDetails != null) {
client.setClientId(Text.valueOf(clientDetails.getClientId()));
client.setDisplayName(Text.valueOf(clientDetails.getClientName()));
client.setShortDescription(Text.valueOf(clientDetails.getClientDescription()));
client.setWebsite(Text.valueOf(clientDetails.getClientWebsite()));
client.redirectUris = new ArrayList<RedirectUri>();
if (clientDetails.getClientRegisteredRedirectUris() != null) {
for (ClientRedirectUriEntity rUri : clientDetails.getClientRegisteredRedirectUris()) {
client.redirectUris.add(RedirectUri.valueOf(rUri));
}
}
client.persistentTokenEnabled = new Checkbox();
client.persistentTokenEnabled.setValue(clientDetails.isPersistentTokensEnabled());
if (clientDetails.getClientType() != null)
client.setType(Text.valueOf(clientDetails.getClientType().value()));
if (clientDetails.isScoped())
client.setScopes(clientDetails.getScope());
client.setMemberId(Text.valueOf(clientDetails.getGroupProfileId()));
if (!PojoUtil.isEmpty(clientDetails.getAuthenticationProviderId())) {
client.setAuthenticationProviderId(Text.valueOf(clientDetails.getAuthenticationProviderId()));
}
client.setAllowAutoDeprecate(Checkbox.valueOf(clientDetails.getAllowAutoDeprecate()));
}
return client;
}
use of org.orcid.persistence.jpa.entities.ClientRedirectUriEntity in project ORCID-Source by ORCID.
the class OrcidSSOManagerImpl method getUserCredentials.
@Override
public ClientDetailsEntity getUserCredentials(String orcid) {
ClientDetailsEntity existingClientDetails = clientDetailsManager.getPublicClient(orcid);
if (existingClientDetails != null) {
SortedSet<ClientRedirectUriEntity> allRedirectUris = existingClientDetails.getClientRegisteredRedirectUris();
SortedSet<ClientRedirectUriEntity> onlySSORedirectUris = new TreeSet<ClientRedirectUriEntity>();
if (allRedirectUris != null) {
for (ClientRedirectUriEntity rUri : allRedirectUris) {
// Leave only the redirect uris used for SSO authentication
if (SSO_REDIRECT_URI_TYPE.equals(rUri.getRedirectUriType())) {
onlySSORedirectUris.add(rUri);
}
}
}
existingClientDetails.setClientRegisteredRedirectUris(onlySSORedirectUris);
if (existingClientDetails.getClientSecrets() != null) {
for (ClientSecretEntity clientSecret : existingClientDetails.getClientSecrets()) {
clientSecret.setDecryptedClientSecret(encryptionManager.decryptForInternalUse(clientSecret.getClientSecret()));
}
}
}
return existingClientDetails;
}
use of org.orcid.persistence.jpa.entities.ClientRedirectUriEntity in project ORCID-Source by ORCID.
the class OrcidSSOManagerImpl method populateClientRedirectUriEntity.
private ClientRedirectUriEntity populateClientRedirectUriEntity(String redirectUri, ClientDetailsEntity clientDetailsEntity) {
ClientRedirectUriEntity clientRedirectUriEntity = new ClientRedirectUriEntity();
clientRedirectUriEntity.setClientDetailsEntity(clientDetailsEntity);
clientRedirectUriEntity.setRedirectUri(redirectUri);
clientRedirectUriEntity.setRedirectUriType(SSO_REDIRECT_URI_TYPE);
return clientRedirectUriEntity;
}
use of org.orcid.persistence.jpa.entities.ClientRedirectUriEntity 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;
}
Aggregations