use of org.orcid.persistence.jpa.entities.ProfileEntity in project ORCID-Source by ORCID.
the class RecordNameManagerImpl method updateRecordName.
@Override
public boolean updateRecordName(String orcid, Name name) {
if (name == null) {
return false;
}
RecordNameEntity entity = jpaJaxbNameAdapter.toRecordNameEntity(name);
if (entity.getProfile() == null || PojoUtil.isEmpty(entity.getProfile().getId())) {
entity.setProfile(new ProfileEntity(orcid));
}
entity.setLastModified(new Date());
recordNameDao.updateRecordName(entity);
// Evict the name in the source name manager
sourceNameCacheManager.remove(orcid);
return true;
}
use of org.orcid.persistence.jpa.entities.ProfileEntity in project ORCID-Source by ORCID.
the class ContributorUtils method filterContributorPrivateData.
public void filterContributorPrivateData(Funding funding) {
if (funding.getContributors() != null && funding.getContributors().getContributor() != null) {
for (FundingContributor contributor : funding.getContributors().getContributor()) {
contributor.setContributorEmail(null);
if (!PojoUtil.isEmpty(contributor.getContributorOrcid())) {
String contributorOrcid = contributor.getContributorOrcid().getPath();
if (profileEntityManager.orcidExists(contributorOrcid)) {
// contributor is an ORCID user - visibility of user's
// name in record must be taken into account
ProfileEntity profileEntity = profileEntityCacheManager.retrieve(contributorOrcid);
String publicContributorCreditName = cacheManager.getPublicCreditName(profileEntity);
CreditName creditName = new CreditName(publicContributorCreditName != null ? publicContributorCreditName : "");
contributor.setCreditName(creditName);
}
}
}
}
}
use of org.orcid.persistence.jpa.entities.ProfileEntity in project ORCID-Source by ORCID.
the class SecurityContextTestUtils method setUpSecurityContext.
public static void setUpSecurityContext(String userOrcid, String clientId, ScopePathType... scopePathTypes) {
SecurityContextImpl securityContext = new SecurityContextImpl();
OrcidOAuth2Authentication mockedAuthentication = mock(OrcidOAuth2Authentication.class);
securityContext.setAuthentication(mockedAuthentication);
SecurityContextHolder.setContext(securityContext);
ProfileEntity userProfileEntity = new ProfileEntity(userOrcid);
when(mockedAuthentication.getPrincipal()).thenReturn(userProfileEntity);
Authentication userAuthentication = mock(Authentication.class);
when(userAuthentication.getPrincipal()).thenReturn(userProfileEntity);
when(mockedAuthentication.getUserAuthentication()).thenReturn(userAuthentication);
Set<String> scopes = new HashSet<String>();
if (scopePathTypes != null) {
for (ScopePathType scopePathType : scopePathTypes) {
scopes.add(scopePathType.value());
}
}
OAuth2Request authorizationRequest = new OAuth2Request(Collections.<String, String>emptyMap(), clientId, Collections.<GrantedAuthority>emptyList(), true, scopes, Collections.<String>emptySet(), null, Collections.<String>emptySet(), Collections.<String, Serializable>emptyMap());
when(mockedAuthentication.getOAuth2Request()).thenReturn(authorizationRequest);
when(mockedAuthentication.isAuthenticated()).thenReturn(true);
}
use of org.orcid.persistence.jpa.entities.ProfileEntity in project ORCID-Source by ORCID.
the class SecurityContextTestUtils method setUpSecurityContextForClientOnly.
public static void setUpSecurityContextForClientOnly(String clientId, Set<String> scopes) {
SecurityContextImpl securityContext = new SecurityContextImpl();
OrcidOAuth2Authentication mockedAuthentication = mock(OrcidOAuth2Authentication.class);
securityContext.setAuthentication(mockedAuthentication);
SecurityContextHolder.setContext(securityContext);
when(mockedAuthentication.getPrincipal()).thenReturn(new ProfileEntity(clientId));
when(mockedAuthentication.isClientOnly()).thenReturn(true);
OAuth2Request authorizationRequest = new OAuth2Request(Collections.<String, String>emptyMap(), clientId, Collections.<GrantedAuthority>emptyList(), true, scopes, Collections.<String>emptySet(), null, Collections.<String>emptySet(), Collections.<String, Serializable>emptyMap());
when(mockedAuthentication.getOAuth2Request()).thenReturn(authorizationRequest);
when(mockedAuthentication.isAuthenticated()).thenReturn(true);
when(mockedAuthentication.getName()).thenReturn(clientId);
}
use of org.orcid.persistence.jpa.entities.ProfileEntity in project ORCID-Source by ORCID.
the class JpaJaxbAddressAdapterTest method getAddressEntity.
private AddressEntity getAddressEntity() {
AddressEntity result = new AddressEntity();
result.setId(Long.valueOf(1));
result.setDateCreated(new Date());
result.setLastModified(new Date());
result.setIso2Country(Iso3166Country.US);
result.setUser(new ProfileEntity("0000-0000-0000-0000"));
result.setVisibility(Visibility.PUBLIC);
result.setClientSourceId("APP-000000001");
return result;
}
Aggregations