use of org.orcid.persistence.jpa.entities.ProfileEntity in project ORCID-Source by ORCID.
the class OrcidRefreshTokenTokenGranterTest method createToken.
private OrcidOauth2TokenDetail createToken(String clientId, String userOrcid, String tokenValue, String refreshTokenValue, Date expirationDate, String scopes) {
OrcidOauth2TokenDetail token = new OrcidOauth2TokenDetail();
token.setApproved(true);
token.setClientDetailsId(clientId);
token.setDateCreated(new Date());
token.setLastModified(new Date());
token.setProfile(new ProfileEntity(userOrcid));
token.setScope(scopes);
token.setTokenDisabled(false);
token.setTokenExpiration(expirationDate);
token.setTokenType("bearer");
token.setTokenValue(tokenValue);
token.setRefreshTokenValue(refreshTokenValue);
orcidOauth2TokenDetailService.saveOrUpdate(token);
return token;
}
use of org.orcid.persistence.jpa.entities.ProfileEntity in project ORCID-Source by ORCID.
the class OrcidClientCredentialsCheckerTest method setupMocks.
private void setupMocks(String clientId, String memberId) {
ClientDetailsEntity clientDetailsEntity = new ClientDetailsEntity();
Set<ClientScopeEntity> scopes = new HashSet<ClientScopeEntity>(3);
scopes.add(new ClientScopeEntity(ScopePathType.ORCID_WORKS_UPDATE.value()));
scopes.add(new ClientScopeEntity(ScopePathType.ORCID_BIO_READ_LIMITED.value()));
scopes.add(new ClientScopeEntity(ScopePathType.ORCID_PROFILE_CREATE.value()));
clientDetailsEntity.setClientScopes(scopes);
clientDetailsEntity.setGroupProfileId(memberId);
ProfileEntity profile = new ProfileEntity(memberId);
profile.setRecordLocked(false);
when(clientDetailsService.loadClientByClientId(clientId)).thenReturn(clientDetailsEntity);
when(clientDetailsEntityCacheManager.retrieve(clientId)).thenReturn(clientDetailsEntity);
}
use of org.orcid.persistence.jpa.entities.ProfileEntity in project ORCID-Source by ORCID.
the class ProfileLastModifiedAspect method updateProfileLastModified.
@AfterReturning(POINTCUT_DEFINITION_BASE + " && args(profileAware, ..)")
public void updateProfileLastModified(JoinPoint joinPoint, ProfileAware profileAware) {
if (!enabled) {
return;
}
ProfileEntity profile = profileAware.getProfile();
if (profile != null) {
String orcid = profile.getId();
updateProfileLastModified(joinPoint, orcid);
}
}
use of org.orcid.persistence.jpa.entities.ProfileEntity in project ORCID-Source by ORCID.
the class GroupAdministratorController method resetClientSecret.
/**
* Reset client secret
* */
@RequestMapping(value = "/reset-client-secret.json", method = RequestMethod.POST)
@ResponseBody
public boolean resetClientSecret(@RequestBody String clientId) {
//Verify this client belongs to the member
ClientDetailsEntity clientDetails = clientDetailsManager.findByClientId(clientId);
if (clientDetails == null)
return false;
ProfileEntity groupProfile = profileEntityCacheManager.retrieve(clientDetails.getGroupProfileId());
if (groupProfile == null)
return false;
if (!groupProfile.getId().equals(getCurrentUserOrcid()))
return false;
return orcidSSOManager.resetClientSecret(clientId);
}
use of org.orcid.persistence.jpa.entities.ProfileEntity in project ORCID-Source by ORCID.
the class DeveloperToolsController method resetClientSecret.
@RequestMapping(value = "/reset-client-secret", method = RequestMethod.POST)
@ResponseBody
public boolean resetClientSecret(@RequestBody String clientId) {
//Verify this client belongs to the user
ClientDetailsEntity clientDetails = clientDetailsManager.findByClientId(clientId);
if (clientDetails == null)
return false;
ProfileEntity groupProfile = profileEntityCacheManager.retrieve(clientDetails.getGroupProfileId());
if (groupProfile == null)
return false;
if (!groupProfile.getId().equals(getCurrentUserOrcid()))
return false;
return orcidSSOManager.resetClientSecret(clientId);
}
Aggregations