Search in sources :

Example 1 with ClientRedirectUriEntity

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;
}
Also used : ClientSecretEntity(org.orcid.persistence.jpa.entities.ClientSecretEntity) ClientRedirectUriEntity(org.orcid.persistence.jpa.entities.ClientRedirectUriEntity)

Example 2 with ClientRedirectUriEntity

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;
}
Also used : OrcidClient(org.orcid.jaxb.model.clientgroup.OrcidClient) ClientRedirectUriEntity(org.orcid.persistence.jpa.entities.ClientRedirectUriEntity)

Example 3 with ClientRedirectUriEntity

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;
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) TreeSet(java.util.TreeSet) ClientSecretEntity(org.orcid.persistence.jpa.entities.ClientSecretEntity) ClientRedirectUriEntity(org.orcid.persistence.jpa.entities.ClientRedirectUriEntity)

Example 4 with ClientRedirectUriEntity

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;
}
Also used : ClientRedirectUriEntity(org.orcid.persistence.jpa.entities.ClientRedirectUriEntity)

Example 5 with 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;
}
Also used : ScopePathType(org.orcid.jaxb.model.message.ScopePathType) TreeSet(java.util.TreeSet) RedirectUri(org.orcid.jaxb.model.clientgroup.RedirectUri) ClientRedirectUriEntity(org.orcid.persistence.jpa.entities.ClientRedirectUriEntity)

Aggregations

ClientRedirectUriEntity (org.orcid.persistence.jpa.entities.ClientRedirectUriEntity)21 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)12 HashSet (java.util.HashSet)9 TreeSet (java.util.TreeSet)9 ArrayList (java.util.ArrayList)7 Date (java.util.Date)6 RedirectUri (org.orcid.jaxb.model.clientgroup.RedirectUri)5 ClientAuthorisedGrantTypeEntity (org.orcid.persistence.jpa.entities.ClientAuthorisedGrantTypeEntity)5 ClientGrantedAuthorityEntity (org.orcid.persistence.jpa.entities.ClientGrantedAuthorityEntity)5 ClientSecretEntity (org.orcid.persistence.jpa.entities.ClientSecretEntity)5 ScopePathType (org.orcid.jaxb.model.message.ScopePathType)4 ClientResourceIdEntity (org.orcid.persistence.jpa.entities.ClientResourceIdEntity)4 ClientScopeEntity (org.orcid.persistence.jpa.entities.ClientScopeEntity)4 CustomEmailEntity (org.orcid.persistence.jpa.entities.CustomEmailEntity)4 OrcidClient (org.orcid.jaxb.model.clientgroup.OrcidClient)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 MapperFactory (ma.glasnost.orika.MapperFactory)2 MappingContext (ma.glasnost.orika.MappingContext)2 DefaultMapperFactory (ma.glasnost.orika.impl.DefaultMapperFactory)2