use of org.orcid.persistence.jpa.entities.ClientDetailsEntity in project ORCID-Source by ORCID.
the class LoginController method handleOauthSignIn.
private ModelAndView handleOauthSignIn(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException {
String queryString = request.getQueryString();
String redirectUri = null;
// Get and save the request information form
RequestInfoForm requestInfoForm = generateRequestInfoForm(queryString);
request.getSession().setAttribute(REQUEST_INFO_FORM, requestInfoForm);
// Save also the original query string
request.getSession().setAttribute("queryString", queryString);
// Save a flag to indicate this is a request from the new
request.getSession().setAttribute("OAUTH_2SCREENS", true);
// Redirect URI
redirectUri = requestInfoForm.getRedirectUrl();
// Check that the client have the required permissions
// Get client name
String clientId = requestInfoForm.getClientId();
if (PojoUtil.isEmpty(clientId)) {
String redirectUriWithParams = redirectUri + "?error=invalid_client&error_description=invalid client_id";
return new ModelAndView(new RedirectView(redirectUriWithParams));
}
// Validate client details
ClientDetailsEntity clientDetails = clientDetailsEntityCacheManager.retrieve(clientId);
try {
orcidOAuth2RequestValidator.validateClientIsEnabled(clientDetails);
} catch (LockedException e) {
String redirectUriWithParams = redirectUri + "?error=client_locked&error_description=" + e.getMessage();
return new ModelAndView(new RedirectView(redirectUriWithParams));
}
// validate client scopes
try {
authorizationEndpoint.validateScope(requestInfoForm.getScopesAsString(), clientDetails);
} catch (InvalidScopeException e) {
String redirectUriWithParams = redirectUri + "?error=invalid_scope&error_description=" + e.getMessage();
return new ModelAndView(new RedirectView(redirectUriWithParams));
}
ModelAndView mav = new ModelAndView("login");
mav.addObject("hideUserVoiceScript", true);
mav.addObject("oauth2Screens", true);
return mav;
}
use of org.orcid.persistence.jpa.entities.ClientDetailsEntity in project ORCID-Source by ORCID.
the class NotificationController method getInstitutionalConnectionNotificationHtml.
@RequestMapping(value = "/INSTITUTIONAL_CONNECTION/{id}/notification.html", produces = OrcidApiConstants.HTML_UTF)
public ModelAndView getInstitutionalConnectionNotificationHtml(@PathVariable("id") String id) throws UnsupportedEncodingException {
ModelAndView mav = new ModelAndView();
Notification notification = notificationManager.findByOrcidAndId(getCurrentUserOrcid(), Long.valueOf(id));
String clientId = notification.getSource().retrieveSourcePath();
ClientDetailsEntity clientDetails = clientDetailsEntityCacheManager.retrieve(clientId);
String authorizationUrl = notificationManager.buildAuthorizationUrlForInstitutionalSignIn(clientDetails);
addSourceDescription(notification);
mav.addObject("notification", notification);
mav.addObject("baseUri", getBaseUri());
mav.addObject("clientId", clientId);
mav.addObject("authorizationUrl", authorizationUrl);
mav.setViewName("notification/institutional_connection_notification");
mav.addObject("noIndex", true);
return mav;
}
use of org.orcid.persistence.jpa.entities.ClientDetailsEntity in project ORCID-Source by ORCID.
the class Jpa2JaxbAdapterImpl method getSponsor.
private Source getSponsor(ProfileEntity profileEntity) {
SourceEntity sourceEntity = profileEntity.getSource();
if (sourceEntity != null) {
Source sponsor = new Source();
SourceName sponsorName = new SourceName(sourceEntity.getSourceName());
sponsor.setSourceName(sponsorName);
ClientDetailsEntity sourceClient = sourceEntity.getSourceClient();
if (sourceClient != null && !OrcidStringUtils.isValidOrcid(sourceClient.getClientId())) {
SourceClientId sourceClientId = new SourceClientId(getOrcidIdBase(sourceClient.getId()));
sponsor.setSourceClientId(sourceClientId);
} else {
SourceOrcid sponsorOrcid = StringUtils.isNotBlank(sourceEntity.getSourceId()) ? new SourceOrcid(getOrcidIdBase(sourceEntity.getSourceId())) : null;
sponsor.setSourceOrcid(sponsorOrcid);
}
return sponsor;
}
return null;
}
use of org.orcid.persistence.jpa.entities.ClientDetailsEntity in project ORCID-Source by ORCID.
the class MapperFacadeFactory method getClientMapperFacade.
public MapperFacade getClientMapperFacade() {
MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
ClassMapBuilder<Client, ClientDetailsEntity> clientClassMap = mapperFactory.classMap(Client.class, ClientDetailsEntity.class);
clientClassMap.field("name", "clientName");
clientClassMap.field("description", "clientDescription");
clientClassMap.byDefault();
clientClassMap.register();
return mapperFactory.getMapperFacade();
}
use of org.orcid.persistence.jpa.entities.ClientDetailsEntity 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;
}
Aggregations