use of org.orcid.core.oauth.OrcidProfileUserDetails in project ORCID-Source by ORCID.
the class FundingsControllerTest method getAuthentication.
@Override
protected Authentication getAuthentication() {
orcidProfile = orcidProfileManager.retrieveOrcidProfile("4444-4444-4444-4443");
List<OrcidWebRole> roles = Arrays.asList(OrcidWebRole.ROLE_USER);
OrcidProfileUserDetails details = new OrcidProfileUserDetails(orcidProfile.retrieveOrcidPath(), orcidProfile.getOrcidBio().getContactDetails().retrievePrimaryEmail().getValue(), null, roles);
UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken("4444-4444-4444-4443", details.getPassword(), roles);
auth.setDetails(details);
return auth;
}
use of org.orcid.core.oauth.OrcidProfileUserDetails in project ORCID-Source by ORCID.
the class GetMyDataControllerTest method getAuthentication.
private Authentication getAuthentication() {
List<OrcidWebRole> roles = Arrays.asList(OrcidWebRole.ROLE_USER);
OrcidProfileUserDetails details = new OrcidProfileUserDetails(ORCID, "user_1@test.orcid.org", null, roles);
UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken(ORCID, null, roles);
auth.setDetails(details);
return auth;
}
use of org.orcid.core.oauth.OrcidProfileUserDetails in project ORCID-Source by ORCID.
the class LoginApplicationListener method onApplicationEvent.
/**
* Handle an application event.
*
* @param event
* the event to respond to
*/
@Override
public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof AuthenticationSuccessEvent) {
Object source = event.getSource();
if (source instanceof UsernamePasswordAuthenticationToken) {
UsernamePasswordAuthenticationToken token = (UsernamePasswordAuthenticationToken) source;
Object principal = token.getPrincipal();
if (principal instanceof OrcidProfileUserDetails) {
OrcidProfileUserDetails userDetails = (OrcidProfileUserDetails) principal;
String orcid = userDetails.getOrcid();
String email = userDetails.getPrimaryEmail();
String sessionId = RequestContextHolder.currentRequestAttributes().getSessionId();
LOGGER.info("User logged in with orcid={}, email={}, sessionid={}", new Object[] { orcid, email, sessionId });
}
}
}
}
Aggregations