use of gov.ca.cwds.UniversalUserToken in project perry by ca-cwds.
the class DevAuthenticationProvider method authenticate.
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
tryAuthenticate(authentication);
String json = authentication.getName();
String userName = getUserName(json);
UniversalUserToken userToken = new UniversalUserToken();
userToken.setToken(UUID.randomUUID().toString());
userToken.setUserId(userName);
userToken.setParameter(IDENTITY, json);
return new UsernamePasswordAuthenticationToken(userToken, "N/A", Collections.singletonList(new SimpleGrantedAuthority("ROLE_USER")));
}
use of gov.ca.cwds.UniversalUserToken in project perry by ca-cwds.
the class LoginServiceDev method issueAccessCode.
@Override
public String issueAccessCode(String providerId) {
SecurityContext securityContext = SecurityContextHolder.getContext();
DefaultOAuth2AccessToken accessToken = new DefaultOAuth2AccessToken("test");
accessToken.setAdditionalInformation(new HashMap<>());
UniversalUserToken userToken = (UniversalUserToken) securityContext.getAuthentication().getPrincipal();
accessToken.getAdditionalInformation().put(Constants.IDENTITY, userToken.getParameter(IDENTITY));
return tokenService.issueAccessCode(userToken, accessToken);
}
use of gov.ca.cwds.UniversalUserToken in project perry by ca-cwds.
the class LoginServiceImpl method issueAccessCode.
@Override
public String issueAccessCode(String providerId) {
SecurityContext securityContext = SecurityContextHolder.getContext();
OAuth2Authentication authentication = (OAuth2Authentication) securityContext.getAuthentication();
UniversalUserToken userToken = (UniversalUserToken) authentication.getPrincipal();
OAuth2AccessToken accessToken = clientContext.getAccessToken();
String identity = identityMappingService.map(userToken, providerId);
accessToken.getAdditionalInformation().put(Constants.IDENTITY, identity);
return tokenService.issueAccessCode(userToken, accessToken);
}
use of gov.ca.cwds.UniversalUserToken in project perry by ca-cwds.
the class UniversalUserTokenExtractor method extractPrincipal.
@Override
public UniversalUserToken extractPrincipal(Map<String, Object> map) {
try {
UniversalUserToken userToken = configuration.getIdentityProvider().getIdpMapping().map(map);
userToken.setToken(generateToken());
return userToken;
} catch (ScriptException e) {
throw new RuntimeException(e);
}
}
use of gov.ca.cwds.UniversalUserToken in project perry by ca-cwds.
the class IdpMappingScript method map.
public UniversalUserToken map(Map idpToken) throws ScriptException {
UniversalUserToken universalUserToken = new UniversalUserToken();
eval(universalUserToken, idpToken);
return universalUserToken;
}
Aggregations