Search in sources :

Example 21 with RedirectUri

use of org.orcid.jaxb.model.clientgroup.RedirectUri 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.isAllowAutoDeprecate());
        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;
}
Also used : OrcidClient(org.orcid.jaxb.model.clientgroup.OrcidClient) ArrayList(java.util.ArrayList) RedirectUris(org.orcid.jaxb.model.clientgroup.RedirectUris) RedirectUri(org.orcid.jaxb.model.clientgroup.RedirectUri) ClientRedirectUriEntity(org.orcid.persistence.jpa.entities.ClientRedirectUriEntity)

Aggregations

RedirectUri (org.orcid.jaxb.model.clientgroup.RedirectUri)21 Test (org.junit.Test)11 OrcidClient (org.orcid.jaxb.model.clientgroup.OrcidClient)11 BaseTest (org.orcid.core.BaseTest)9 OrcidClientGroup (org.orcid.jaxb.model.clientgroup.OrcidClientGroup)9 Transactional (org.springframework.transaction.annotation.Transactional)9 RedirectUris (org.orcid.jaxb.model.clientgroup.RedirectUris)8 ArrayList (java.util.ArrayList)7 HashSet (java.util.HashSet)7 TransactionStatus (org.springframework.transaction.TransactionStatus)7 OrcidClientGroupManagementException (org.orcid.core.exception.OrcidClientGroupManagementException)6 ScopePathType (org.orcid.jaxb.model.message.ScopePathType)6 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)5 ClientRedirectUriEntity (org.orcid.persistence.jpa.entities.ClientRedirectUriEntity)5 HashMap (java.util.HashMap)3 TreeSet (java.util.TreeSet)2 DBUnitTest (org.orcid.test.DBUnitTest)2 Rollback (org.springframework.test.annotation.Rollback)2 ClientType (org.orcid.jaxb.model.clientgroup.ClientType)1