Search in sources :

Example 41 with ProfileEntity

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;
}
Also used : OrcidOauth2TokenDetail(org.orcid.persistence.jpa.entities.OrcidOauth2TokenDetail) Date(java.util.Date) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity)

Example 42 with ProfileEntity

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);
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) ClientScopeEntity(org.orcid.persistence.jpa.entities.ClientScopeEntity) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) HashSet(java.util.HashSet)

Example 43 with ProfileEntity

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);
    }
}
Also used : ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) AfterReturning(org.aspectj.lang.annotation.AfterReturning)

Example 44 with ProfileEntity

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);
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 45 with ProfileEntity

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);
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)374 Date (java.util.Date)107 Test (org.junit.Test)107 HashMap (java.util.HashMap)74 Transactional (org.springframework.transaction.annotation.Transactional)74 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)71 DBUnitTest (org.orcid.test.DBUnitTest)65 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)48 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)44 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)37 HashSet (java.util.HashSet)35 RecordNameEntity (org.orcid.persistence.jpa.entities.RecordNameEntity)35 Locale (java.util.Locale)34 Rollback (org.springframework.test.annotation.Rollback)27 OrgEntity (org.orcid.persistence.jpa.entities.OrgEntity)26 ArrayList (java.util.ArrayList)25 EmailEntity (org.orcid.persistence.jpa.entities.EmailEntity)21 Set (java.util.Set)17 Authentication (org.springframework.security.core.Authentication)17 OAuth2Authentication (org.springframework.security.oauth2.provider.OAuth2Authentication)16