Search in sources :

Example 56 with ClientDetailsEntity

use of org.orcid.persistence.jpa.entities.ClientDetailsEntity in project ORCID-Source by ORCID.

the class ProfileFundingManagerTest method displayIndexIsSetTo_1_FromUI.

@Test
public void displayIndexIsSetTo_1_FromUI() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    Funding f1 = getFunding("fromUI-1");
    f1 = profileFundingManager.createFunding(claimedOrcid, f1, false);
    ProfileFundingEntity f = profileFundingDao.find(f1.getPutCode());
    assertNotNull(f);
    assertEquals(Long.valueOf(1), f.getDisplayIndex());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) Funding(org.orcid.jaxb.model.record_v2.Funding) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 57 with ClientDetailsEntity

use of org.orcid.persistence.jpa.entities.ClientDetailsEntity in project ORCID-Source by ORCID.

the class OrcidClientCredentialEndPointDelegatorTest method createAuthorizationCode.

private OrcidOauth2AuthoriziationCodeDetail createAuthorizationCode(String value, String clientId, String redirectUri, boolean persistent, String... scopes) {
    OrcidOauth2AuthoriziationCodeDetail authorizationCode = new OrcidOauth2AuthoriziationCodeDetail();
    authorizationCode.setId(value);
    authorizationCode.setApproved(true);
    authorizationCode.setScopes(new HashSet<String>(Arrays.asList(scopes)));
    authorizationCode.setClientDetailsEntity(new ClientDetailsEntity(clientId));
    authorizationCode.setPersistent(persistent);
    authorizationCode.setProfileEntity(new ProfileEntity(USER_ORCID));
    authorizationCode.setRedirectUri(redirectUri);
    authorizationCode.setResourceIds(new HashSet<String>(Arrays.asList("orcid")));
    authorizationCode.setAuthenticated(true);
    orcidOauth2AuthoriziationCodeDetailDao.persist(authorizationCode);
    return authorizationCode;
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) OrcidOauth2AuthoriziationCodeDetail(org.orcid.persistence.jpa.entities.OrcidOauth2AuthoriziationCodeDetail) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity)

Example 58 with ClientDetailsEntity

use of org.orcid.persistence.jpa.entities.ClientDetailsEntity 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 59 with ClientDetailsEntity

use of org.orcid.persistence.jpa.entities.ClientDetailsEntity in project ORCID-Source by ORCID.

the class ClientDetailsDaoImpl method removeClient.

@Override
@Transactional
public void removeClient(String clientId) {
    ClientDetailsEntity clientDetailsEntity = this.find(clientId);
    this.remove(clientDetailsEntity);
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) Transactional(org.springframework.transaction.annotation.Transactional)

Example 60 with ClientDetailsEntity

use of org.orcid.persistence.jpa.entities.ClientDetailsEntity 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)

Aggregations

ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)149 Test (org.junit.Test)75 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)57 BaseTest (org.orcid.core.BaseTest)51 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)33 Date (java.util.Date)23 Transactional (org.springframework.transaction.annotation.Transactional)16 HashSet (java.util.HashSet)15 DBUnitTest (org.orcid.test.DBUnitTest)15 HashMap (java.util.HashMap)14 Authentication (org.springframework.security.core.Authentication)13 OAuth2Authentication (org.springframework.security.oauth2.provider.OAuth2Authentication)13 OAuth2Request (org.springframework.security.oauth2.provider.OAuth2Request)11 Work (org.orcid.jaxb.model.record_v2.Work)9 Before (org.junit.Before)8 ArrayList (java.util.ArrayList)7 OrcidClient (org.orcid.jaxb.model.clientgroup.OrcidClient)7 ClientSecretEntity (org.orcid.persistence.jpa.entities.ClientSecretEntity)7 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)6 Funding (org.orcid.jaxb.model.record_v2.Funding)6