@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); }
if (!OrcidStringUtils.isValidOrcid(contributorOrcid.getPath())) { throw new OrcidValidationException("Invalid contributor ORCID");
if (!OrcidStringUtils.isValidOrcid(contributorOrcid.getPath())) { throw new OrcidValidationException("Invalid contributor ORCID");
/** 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); }
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; }
Member member = new Member(); String orcid = memberId; if (!OrcidStringUtils.isValidOrcid(memberId)) { Map<String, String> ids = emailManager.findOricdIdsByCommaSeparatedEmails(memberId);
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; }
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); } } }
private Source createSource() { SourceEntity entity = sourceManager.retrieveSourceEntity(); Source source = new Source(); if (entity.getSourceClient() != null && !PojoUtil.isEmpty(entity.getSourceClient().getId())) { if(OrcidStringUtils.isValidOrcid(entity.getSourceClient().getId())) { source.setSourceOrcid(new SourceOrcid(entity.getSourceClient().getId())); } else { source.setSourceClientId(new SourceClientId(entity.getSourceClient().getId())); } } else if(entity.getSourceProfile() != null && !PojoUtil.isEmpty(entity.getSourceProfile().getId())) { source.setSourceClientId(null); source.setSourceOrcid(new SourceOrcid(entity.getSourceProfile().getId())); } return source; }
/** * Get the source of a sowrceAware object * * @param sourceAwareEntity * The entity to obtain the source * @return the source of the object * */ private Source getSource(SourceAwareEntity<?> sourceAwareEntity) { if (sourceAwareEntity == null || PojoUtil.isEmpty(sourceAwareEntity.getElementSourceId())) { return null; } Source source = new Source(); if (!PojoUtil.isEmpty(sourceAwareEntity.getSourceId())) { source.setSourceOrcid(new SourceOrcid(getOrcidIdBase(sourceAwareEntity.getSourceId()))); } String clientSourceId = sourceAwareEntity.getClientSourceId(); if (!PojoUtil.isEmpty(clientSourceId)) { if (OrcidStringUtils.isValidOrcid(clientSourceId)) { source.setSourceOrcid(new SourceOrcid(getOrcidIdBase(clientSourceId))); } else { source.setSourceClientId(new SourceClientId(getOrcidIdBase(clientSourceId))); } } Date createdDate = sourceAwareEntity.getDateCreated(); source.setSourceDate(new SourceDate(DateUtils.convertToXMLGregorianCalendar(createdDate))); return source; }
private Source getSource() { SourceEntity sourceEntity = sourceManager.retrieveSourceEntity(); Source source = new Source(); if (sourceEntity.getSourceProfile() != null && !PojoUtil.isEmpty(sourceEntity.getSourceProfile().getId())) { source.setSourceOrcid(new SourceOrcid(getOrcidIdBase(sourceEntity.getSourceProfile().getId()))); } if (sourceEntity.getSourceClient() != null && !PojoUtil.isEmpty(sourceEntity.getSourceClient().getId())) { if(OrcidStringUtils.isValidOrcid(sourceEntity.getSourceClient().getId())) { source.setSourceOrcid(new SourceOrcid(getOrcidIdBase(sourceEntity.getSourceClient().getId()))); } else { source.setSourceClientId(new SourceClientId(getOrcidIdBase(sourceEntity.getSourceClient().getId()))); } } return source; }
if (referredBy != null && !OrcidStringUtils.isValidOrcid(referredBy.getPath())) { orcidInternal.setReferredBy(null);