/** Runs after any method that updates a record. * Updates the last modified and refreshes the request-scope last modified cache. * * @param joinPoint * @param orcid */ @AfterReturning(POINTCUT_DEFINITION_BASE + " && args(orcid, ..)") public void updateProfileLastModified(JoinPoint joinPoint, String orcid) { if (!enabled) { return; } if (LOGGER.isDebugEnabled()) { if (!OrcidStringUtils.isValidOrcid(orcid)) { LOGGER.debug("Invalid ORCID for last modified date update: orcid={}, join point={}", orcid, joinPoint); } } //update and clear scope cache this.updateLastModifiedDateAndIndexingStatus(orcid); }
/** * Returns the location of the primary record for a deprecated record */ private String getPrimaryRecordLocation(Map<String, String> params) { String deprecatedOrcid = OrcidStringUtils.getOrcidNumber(httpRequest.getRequestURI()); String primaryOrcid = OrcidStringUtils.getOrcidNumber(params.get(OrcidDeprecatedException.ORCID)); String originalRequest = httpRequest.getRequestURL().toString(); if (OrcidUrlManager.isSecure(httpRequest)) { if (originalRequest.startsWith("http:")) { originalRequest = originalRequest.replaceFirst("http:", "https:"); } } return originalRequest.replace(deprecatedOrcid, primaryOrcid); } }
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws AuthenticationException, IOException, ServletException { String clientId = request.getParameter("client_id"); if (!(request instanceof HttpServletRequest) || !(response instanceof HttpServletResponse)) { throw new ServletException("RevokeTokenEndpointFilter just supports HTTP requests"); } if (clientId != null && (OrcidStringUtils.isValidOrcid(clientId) || OrcidStringUtils.isClientId(clientId))) { String clientSecret = request.getParameter("client_secret"); if (clientSecret == null) { clientSecret = ""; } UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(clientId, clientSecret); try { Authentication auth = clientAuthenticationProvider.authenticate(authRequest); SecurityContextHolder.getContext().setAuthentication(auth); } catch (AuthenticationException failed) { oauthAuthenticationEntryPoint.commence((HttpServletRequest) request, (HttpServletResponse) response, failed); return; } } chain.doFilter(request, response); }
private boolean isClient(String sourceId) { return OrcidStringUtils.isClientId(sourceId) || clientDetailsManagerReadOnly.isLegacyClientId(sourceId); }
ContributorOrcid contributorOrcid = contributor.getContributorOrcid(); if (!PojoUtil.isEmpty(contributorOrcid.getUri())) { if (!OrcidStringUtils.isValidOrcidUri(contributorOrcid.getUri())) { throw new OrcidValidationException("Invalid contributor URI"); if (!OrcidStringUtils.isValidOrcid(contributorOrcid.getPath())) { throw new OrcidValidationException("Invalid contributor ORCID");
ContributorOrcid contributorOrcid = contributor.getContributorOrcid(); if (!PojoUtil.isEmpty(contributorOrcid.getUri())) { if (!OrcidStringUtils.isValidOrcid2_1Uri(contributorOrcid.getUri())) { throw new OrcidValidationException("Invalid contributor URI"); if (!OrcidStringUtils.isValidOrcid(contributorOrcid.getPath())) { throw new OrcidValidationException("Invalid contributor ORCID");
int urlCompare = OrcidStringUtils.compareStrings(url, other.getUrl()); if(urlCompare != 0) { return urlCompare; int extIdsCompare = OrcidStringUtils.compareStrings(externalIdentifiersJson, other.getExternalIdentifiersJson()); if(extIdsCompare != 0) { return extIdsCompare; int compareOrgName = OrcidStringUtils.compareStrings(org.getName(), other.getOrg().getName()); if (compareOrgName != 0) { return compareOrgName; int compareOrgCountry = OrcidStringUtils.compareStrings(org.getCountry() == null ? null : org.getCountry(), other.getOrg().getCountry() == null ? null : other.getOrg() .getCountry()); if (compareOrgCountry != 0) { int compareOrgCity = OrcidStringUtils.compareStrings(org.getCity(), other.getOrg().getCity()); if (compareOrgCity != 0) { return compareOrgCity; int subjectExtIdCompare = OrcidStringUtils.compareStrings(subjectExternalIdentifiersJson, other.getSubjectExternalIdentifiersJson()); if(subjectExtIdCompare != 0) { return subjectExtIdCompare; int subjectContainerNameCompare = OrcidStringUtils.compareStrings(subjectContainerName, other.getSubjectContainerName()); if(subjectContainerNameCompare != 0) { return subjectContainerNameCompare; int subjectNameCompare = OrcidStringUtils.compareStrings(subjectName, other.getSubjectName());
public void setValue(String value) { this.value = OrcidStringUtils.filterInvalidXMLCharacters(value); }
/** * Strips html and restore the following characters: ' " & > < If the string * resulting after that process doesnt match the given string, we can say it * contains html * * @param s * String to be cleared * @return true if the give string has html tags in it * */ public static boolean hasHtml(String s) { String striped = simpleHtml(s); return !striped.equals(s); }
@Cacheable(value = "locale-messages", key = "#locale.toString().concat('-javascript')") public org.orcid.pojo.Local getJavascriptMessages(Locale locale) { org.orcid.pojo.Local lPojo = new org.orcid.pojo.Local(); lPojo.setLocale(locale.toString()); ResourceBundle resource = ResourceBundle.getBundle("i18n/javascript", locale, new UTF8Control()); lPojo.setMessages(OrcidStringUtils.resourceBundleToMap(resource)); return lPojo; }
public OrcidIdBase getOrcidIdBase(String id) { OrcidIdBase orcidId = new OrcidIdBase(); String correctedBaseUri = baseUri.replace("https", "http"); try { URI uri = new URI(correctedBaseUri); orcidId.setHost(uri.getHost()); } catch (URISyntaxException e) { throw new RuntimeException("Error parsing base uri", e); } if (OrcidStringUtils.isClientId(id)) { correctedBaseUri += "/client"; } orcidId.setUri(correctedBaseUri + "/" + id); orcidId.setPath(id); return orcidId; } }
int compareTitles = OrcidStringUtils.compareStrings(title, other.getTitle()); if (compareTitles != 0) { return compareTitles; int compareDescriptions = OrcidStringUtils.compareStrings(description, other.getDescription()); if (compareDescriptions != 0) { return compareDescriptions; int compareCurrency = OrcidStringUtils.compareStrings(currencyCode, other.getCurrencyCode()); if (compareCurrency != 0) { return compareCurrency; int compareOrgName = OrcidStringUtils.compareStrings(org.getName(), other.getOrg().getName()); if (compareOrgName != 0) { return compareOrgName; int compareOrgCountry = OrcidStringUtils.compareStrings(org.getCountry() == null ? null : org.getCountry(), other.getOrg().getCountry() == null ? null : other.getOrg() .getCountry()); if (compareOrgCountry != 0) { int compareOrgCity = OrcidStringUtils.compareStrings(org.getCity(), other.getOrg().getCity()); if (compareOrgCity != 0) { return compareOrgCity; int compareExternalIds = OrcidStringUtils.compareStrings(externalIdentifiersJson, other.getExternalIdentifiersJson()); if (compareExternalIds != 0) return compareExternalIds; return OrcidStringUtils.compareStrings(url, other.getUrl());
private ProfileEntity obtainEntity(String username) { ProfileEntity profile = null; if (!StringUtils.isEmpty(username)) { if (OrcidStringUtils.isValidOrcid(username)) { profile = profileDao.find(username); } else { String orcid = emailManagerReadOnly.findOrcidIdByEmail(username); if (!PojoUtil.isEmpty(orcid)) { profile = profileDao.find(orcid); } } } return profile; }
@Override public OrcidIdBase getOrcidIdBase(String id) { OrcidIdBase orcidId = new OrcidIdBase(); String correctedBaseUri = baseUri.replace("https", "http"); try { URI uri = new URI(correctedBaseUri); orcidId.setHost(uri.getHost()); } catch (URISyntaxException e) { throw new RuntimeException("Error parsing base uri", e); } if (OrcidStringUtils.isClientId(id)) { correctedBaseUri += "/client"; } orcidId.setUri(correctedBaseUri + "/" + id); orcidId.setPath(id); return orcidId; }
@Override public ProfileEntity toProfileEntity(OrcidProfile profile, ProfileEntity existingProfileEntity, UpdateOptions updateOptions) { Assert.notNull(profile, "Cannot convert a null OrcidProfile"); ProfileEntity profileEntity = existingProfileEntity == null ? new ProfileEntity() : existingProfileEntity; // if orcid-id exist us it String orcidString = profile.getOrcidIdentifier().getPath(); if (profile.retrieveOrcidUriAsString() != null && !profile.retrieveOrcidUriAsString().isEmpty()) { orcidString = OrcidStringUtils.getOrcidNumber(profile.retrieveOrcidUriAsString()); } profileEntity.setId(orcidString); profileEntity.setOrcidType(profile.getType().name()); profileEntity.setGroupType(profile.getGroupType() != null ? profile.getGroupType().name() : null); setBioDetails(profileEntity, profile.getOrcidBio()); setHistoryDetails(profileEntity, profile.getOrcidHistory()); setActivityDetails(profileEntity, profile.getOrcidActivities(), updateOptions); setInternalDetails(profileEntity, profile.getOrcidInternal()); setPreferencesDetails(profileEntity, profile.getOrcidPreferences()); profileEntity.setUserLastIp(profile.getUserLastIp()); profileEntity.setReviewed(profile.isReviewed()); if(profileEntity.getUsedRecaptchaOnRegistration() == null) { profileEntity.setUsedRecaptchaOnRegistration(false); } return profileEntity; }
Member member = new Member(); String orcid = memberId; if (!OrcidStringUtils.isValidOrcid(memberId)) { Map<String, String> ids = emailManager.findOricdIdsByCommaSeparatedEmails(memberId);
org.orcid.jaxb.model.v3.rc2.common.Source source = new org.orcid.jaxb.model.v3.rc2.common.Source(); if(OrcidStringUtils.isClientId(this.getSource())) { source.setSourceClientId(new SourceClientId(this.getSource())); } else {
private Source getSponsor(ProfileEntity profileEntity) { SourceEntity sourceEntity = profileEntity.getSource(); if (sourceEntity != null) { Source sponsor = new Source(); SourceName sponsorName = new SourceName(SourceEntityUtils.getSourceName(sourceEntity)); 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(SourceEntityUtils.getSourceId(sourceEntity)) ? new SourceOrcid(getOrcidIdBase(SourceEntityUtils.getSourceId(sourceEntity))) : null; sponsor.setSourceOrcid(sponsorOrcid); } return sponsor; } return null; }
org.orcid.jaxb.model.v3.rc2.common.Source source = new org.orcid.jaxb.model.v3.rc2.common.Source(); if(OrcidStringUtils.isClientId(this.getSource())) { source.setSourceClientId(new SourceClientId(this.getSource())); } else {
private void setEmails(ProfileEntity profileEntity, ContactDetails contactDetails) { // The new way of doing emails. Set<EmailEntity> emailEntities = profileEntity.getEmails(); List<Email> emailList = contactDetails.getEmail(); if (emailEntities != null) { for (EmailEntity emailEntity : emailEntities) { Email email = new Email(emailEntity.getEmail()); email.setPrimary(emailEntity.getPrimary()); email.setCurrent(emailEntity.getCurrent()); email.setVerified(emailEntity.getVerified()); email.setVisibility(emailEntity.getVisibility() == null ? OrcidVisibilityDefaults.PRIMARY_EMAIL_DEFAULT.getVisibility() : org.orcid.jaxb.model.message.Visibility.valueOf(emailEntity.getVisibility())); email.setSource(emailEntity.getSourceId()); if(!PojoUtil.isEmpty(emailEntity.getClientSourceId())) { if(OrcidStringUtils.isValidOrcid(emailEntity.getClientSourceId())) { email.setSource(emailEntity.getClientSourceId()); } else { email.setSourceClientId(emailEntity.getClientSourceId()); } } emailList.add(email); } } }