Search in sources :

Example 66 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 67 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 68 with ProfileEntity

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

the class ClaimController method resendClaimEmail.

@RequestMapping(value = "/resend-claim.json", method = RequestMethod.POST)
@ResponseBody
public EmailRequest resendClaimEmail(@RequestBody EmailRequest resendClaimRequest) {
    String email = resendClaimRequest.getEmail();
    List<String> errors = new ArrayList<>();
    resendClaimRequest.setErrors(errors);
    if (!validateEmailAddress(email)) {
        errors.add(getMessage("Email.resetPasswordForm.invalidEmail"));
        return resendClaimRequest;
    }
    if (!emailManager.emailExists(email)) {
        errors.add(getMessage("orcid.frontend.reset.password.email_not_found", email));
        return resendClaimRequest;
    }
    String orcid = emailManager.findOrcidIdByEmail(email);
    ProfileEntity profile = profileEntityCacheManager.retrieve(orcid);
    if (profile != null && profile.getClaimed()) {
        errors.add(getMessage("orcid.frontend.security.already_claimed_with_link"));
        return resendClaimRequest;
    }
    notificationManager.sendApiRecordCreationEmail(email, orcid);
    resendClaimRequest.setSuccessMessage(getMessage("resend_claim.successful_resend"));
    return resendClaimRequest;
}
Also used : ArrayList(java.util.ArrayList) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 69 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 70 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)231 Test (org.junit.Test)65 Date (java.util.Date)64 Transactional (org.springframework.transaction.annotation.Transactional)58 DBUnitTest (org.orcid.test.DBUnitTest)44 HashMap (java.util.HashMap)41 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)37 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)36 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)33 HashSet (java.util.HashSet)30 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)28 Rollback (org.springframework.test.annotation.Rollback)25 RecordNameEntity (org.orcid.persistence.jpa.entities.RecordNameEntity)20 Set (java.util.Set)16 ArrayList (java.util.ArrayList)15 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)14 EmailEntity (org.orcid.persistence.jpa.entities.EmailEntity)14 OAuth2Authentication (org.springframework.security.oauth2.provider.OAuth2Authentication)13 OAuth2Request (org.springframework.security.oauth2.provider.OAuth2Request)13 Authentication (org.springframework.security.core.Authentication)12