Skip to content

Commit

Permalink
Merge branch 'main' into 8802-add-field-that-identifies-search-and-li…
Browse files Browse the repository at this point in the history
…nk-wizards-to-dwclientdetails-in-panoply
  • Loading branch information
amontenegro authored Aug 30, 2023
2 parents 4e6741c + 5d2f3d6 commit 9e7d5b9
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 19 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
## v2.39.0 - 2023-08-30

[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.38.10...v2.39.0)

- [#6882](https://github.com/ORCID/ORCID-Source/pull/6882): Add url to summary
- [#6880](https://github.com/ORCID/ORCID-Source/pull/6880): Add url info to affiliations form

## v2.38.10 - 2023-08-23

[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.38.9...v2.38.10)

- [#6878](https://github.com/ORCID/ORCID-Source/pull/6878): Deactivate endpoint should return the email in a json object

## v2.38.9 - 2023-08-23

[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.38.8...v2.38.9)

- [#6877](https://github.com/ORCID/ORCID-Source/pull/6877): Remove tokens from cache

## v2.38.8 - 2023-08-22

[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.38.7...v2.38.8)

- [#6876](https://github.com/ORCID/ORCID-Source/pull/6876): Remove token from cache when it is revoked

## v2.38.7 - 2023-08-18

[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.38.6...v2.38.7)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.orcid.core.constants.OrcidOauth2Constants;
import org.orcid.core.exception.OrcidInvalidScopeException;
import org.orcid.core.locale.LocaleManager;
import org.orcid.core.manager.EncryptionManager;
import org.orcid.core.oauth.OAuthError;
import org.orcid.core.oauth.OAuthErrorUtils;
import org.orcid.core.utils.JsonUtils;
Expand Down Expand Up @@ -62,10 +61,7 @@ public class OrcidClientCredentialEndPointDelegatorImpl extends AbstractEndpoint
private ProfileLastModifiedDao profileLastModifiedDao;

@Resource
private RedisClient redisClient;

@Resource
private EncryptionManager encryptionManager;
private RedisClient redisClient;

@Value("${org.orcid.core.utils.cache.redis.enabled:true}")
private boolean isTokenCacheEnabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@

import org.orcid.core.constants.RevokeReason;
import org.orcid.core.oauth.OrcidOauth2TokenDetailService;
import org.orcid.core.utils.cache.redis.RedisClient;
import org.orcid.jaxb.model.message.ScopePathType;
import org.orcid.persistence.dao.OrcidOauth2TokenDetailDao;
import org.orcid.persistence.jpa.entities.OrcidOauth2TokenDetail;
import org.orcid.pojo.ajaxForm.PojoUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.security.oauth2.common.util.OAuth2Utils;
import org.springframework.stereotype.Service;
Expand All @@ -34,6 +36,12 @@ public class OrcidOauth2TokenDetailServiceImpl implements OrcidOauth2TokenDetail

@Resource(name="orcidOauth2TokenDetailDaoReadOnly")
private OrcidOauth2TokenDetailDao orcidOauth2TokenDetailDaoReadOnly;

@Resource
private RedisClient redisClient;

@Value("${org.orcid.core.utils.cache.redis.enabled:true}")
private boolean isTokenCacheEnabled;

@Override
public void setOrcidOauth2TokenDetailDao(OrcidOauth2TokenDetailDao orcidOauth2TokenDetailDao) {
Expand Down Expand Up @@ -128,6 +136,11 @@ public void disableAccessToken(String accessToken) {
@Override
@Transactional
public void revokeAccessToken(String accessToken) {
// Remove the token from the cache
if(isTokenCacheEnabled) {
redisClient.remove(accessToken);
}
// Revoke the token
orcidOauth2TokenDetailDao.revokeAccessToken(accessToken);
}

Expand Down Expand Up @@ -233,6 +246,16 @@ public void disableAccessTokenByUserOrcid(String userOrcid, RevokeReason reason)
@Override
@Transactional
public void disableClientAccess(String clientDetailsId, String userOrcid) {
// As a security measure, remove any user tokens from the cache
List<OrcidOauth2TokenDetail> userTokens = findByUserName(userOrcid);
if(userTokens != null && !userTokens.isEmpty()) {
for(OrcidOauth2TokenDetail token : userTokens) {
if(clientDetailsId.equals(token.getClientDetailsId())) {
redisClient.remove(token.getTokenValue());
}
}
}
// And then disable all user tokens
orcidOauth2TokenDetailDao.disableClientAccessTokensByUserOrcid(userOrcid, clientDetailsId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,21 @@ public String get(String key) {
LOG.debug("Reading Key: {}" , key);
return jedis.get(key);
}
}
}
return null;
}
}

public boolean remove(String key) {
if (enabled && pool != null) {
try (Jedis jedis = pool.getResource()) {
LOG.debug("Removing Key: {}", key);
if (jedis.exists(key)) {
return jedis.del(key) > 0;
} else {
return true;
}
}
}
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,9 @@ public static AffiliationForm valueOf(AffiliationSummary summary) {
form.setAffiliationExternalIdentifiers(affiliationExternalIdentifiers);
}

// Set empty url field
form.setUrl(new Text());
if(summary.getUrl() != null && summary.getUrl().getValue() != null) {
form.setUrl(Text.valueOf(summary.getUrl().getValue()));
}

form.setCreatedDate(Date.valueOf(summary.getCreatedDate()));
form.setLastModified(Date.valueOf(summary.getLastModifiedDate()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ public void equalsTest() {
public void fromAffiliationSummaryTest() {
AffiliationForm f1 = getAffiliationForm();
AffiliationSummary s1 = getAffiliationSummary();
// Summary doesn't have url
f1.setUrl(new Text());

AffiliationForm f2 = AffiliationForm.valueOf(s1);
f2.equals(f1);
assertEquals(f1, AffiliationForm.valueOf(s1));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ protected AffiliationSummary getAffiliationSummary() {
aff.setLastModifiedDate(new LastModifiedDate(lastModified));
aff.setPutCode(1L);
aff.setPath("/distinction/1");

aff.setUrl(new Url("https://test.orcid.org"));
aff.setDepartmentName("department-name");
aff.setDisplayIndex("0");
aff.setEndDate(new FuzzyDate(new Year(2018), new Month(1), new Day(1)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private AffiliationSummary getAff2() {

private AffiliationForm getForm1() {
AffiliationForm affForm = getAffiliationForm();
affForm.setUrl(new Text());
affForm.setUrl(Text.valueOf("https://test.orcid.org"));
affForm.setPutCode(Text.valueOf(2L));

Visibility v = new Visibility();
Expand All @@ -139,7 +139,7 @@ private AffiliationForm getForm1() {

private AffiliationForm getForm2() {
AffiliationForm affForm = getAffiliationForm();
affForm.setUrl(new Text());
affForm.setUrl(Text.valueOf("https://test.orcid.org"));
affForm.setPutCode(Text.valueOf(1L));

Visibility v = new Visibility();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.jasypt.exceptions.EncryptionOperationNotPossibleException;
import org.orcid.core.constants.EmailConstants;
import org.orcid.core.manager.AdminManager;
Expand Down Expand Up @@ -77,6 +79,8 @@
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.fasterxml.jackson.databind.JsonNode;

/**
* @author Declan Newman (declan) Date: 22/02/2012
*/
Expand Down Expand Up @@ -516,10 +520,13 @@ public ModelAndView confirmDeactivateOrcidAccount(HttpServletRequest request, Ht
}

@RequestMapping(value = "/send-deactivate-account.json", method = RequestMethod.POST)
public @ResponseBody String startDeactivateOrcidAccount(HttpServletRequest request) {
public @ResponseBody String startDeactivateOrcidAccount(HttpServletRequest request) throws JSONException {
String currentUserOrcid = getCurrentUserOrcid();
recordEmailSender.sendOrcidDeactivateEmail(currentUserOrcid);
return emailManager.findPrimaryEmail(currentUserOrcid).getEmail();
String primaryEmail = emailManager.findPrimaryEmail(currentUserOrcid).getEmail();
JSONObject response = new JSONObject();
response.put("email", primaryEmail);
return response.toString();
}

@RequestMapping(value = "/emails.json", method = RequestMethod.GET)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,7 @@ RecordSummary getSummary(String orcid) {
}
}
recordSummary.setName(displayName);
}

ActivitiesSummary activitiesSummary = record.getActivitiesSummary();
}

AffiliationGroupContainer groupedAffiliations = publicProfileController.getGroupedAffiliations(orcid);
List<AffiliationGroupForm> groupedEmployments = groupedAffiliations.getAffiliationGroups().get(AffiliationType.EMPLOYMENT);
Expand Down

0 comments on commit 9e7d5b9

Please sign in to comment.