Search in sources :

Example 1 with IdentityMappingScript

use of gov.ca.cwds.service.scripts.IdentityMappingScript in project perry by ca-cwds.

the class IdentityMappingService method map.

public String map(UniversalUserToken subject, String providerId) {
    IdentityMappingScript mappingScript = loadMappingScriptForServiceProvider(providerId);
    if (mappingScript != null) {
        UserAuthorization authorization = userAuthorizationService.find(subject.getUserId());
        subject.setAuthorization(authorization);
        try {
            return mappingScript.map(subject);
        } catch (ScriptException e) {
            throw new IllegalArgumentException("Identity Mapping failed for service provider: " + providerId, e);
        }
    }
    return subject.getUserId();
}
Also used : ScriptException(javax.script.ScriptException) UserAuthorization(gov.ca.cwds.rest.api.domain.auth.UserAuthorization) IdentityMappingScript(gov.ca.cwds.service.scripts.IdentityMappingScript)

Aggregations

UserAuthorization (gov.ca.cwds.rest.api.domain.auth.UserAuthorization)1 IdentityMappingScript (gov.ca.cwds.service.scripts.IdentityMappingScript)1 ScriptException (javax.script.ScriptException)1