use of org.orcid.pojo.ajaxForm.Client in project ORCID-Source by ORCID.
the class MembersManagerImpl method getClient.
@Override
public Client getClient(String clientId) {
Client result = new Client();
ClientDetailsEntity clientDetailsEntity = clientDetailsManager.findByClientId(clientId);
if (clientDetailsEntity != null) {
result = Client.valueOf(clientDetailsEntity);
//Set member name
result.setMemberName(Text.valueOf(clientDetailsManager.getMemberName(clientId)));
//Set client secret
if (clientDetailsEntity.getClientSecrets() != null) {
for (ClientSecretEntity secret : clientDetailsEntity.getClientSecrets()) {
if (secret.isPrimary()) {
result.setClientSecret(Text.valueOf(encryptionManager.decryptForInternalUse(secret.getClientSecret())));
}
}
}
} else {
result.getErrors().add(getMessage("admin.edit_client.invalid_orcid"));
}
return result;
}
use of org.orcid.pojo.ajaxForm.Client in project ORCID-Source by ORCID.
the class GroupAdministratorController method getClients.
@RequestMapping(value = "/get-clients.json", method = RequestMethod.GET)
@Produces(value = { MediaType.APPLICATION_JSON })
@ResponseBody
public List<Client> getClients() {
OrcidProfile profile = getEffectiveProfile();
String groupOrcid = profile.getOrcidIdentifier().getPath();
if (profile.getType() == null || !profile.getType().equals(OrcidType.GROUP)) {
LOGGER.warn("Trying to get clients of non group user {}", profile.getOrcidIdentifier().getPath());
throw new OrcidClientGroupManagementException(getMessage("web.orcid.privilege.exception"));
}
OrcidClientGroup group = orcidClientGroupManager.retrieveOrcidClientGroup(groupOrcid);
List<Client> clients = new ArrayList<Client>();
for (OrcidClient orcidClient : group.getOrcidClient()) {
clients.add(Client.valueOf(orcidClient));
}
return clients;
}
use of org.orcid.pojo.ajaxForm.Client in project ORCID-Source by ORCID.
the class GroupAdministratorControllerTest method invalidClientTest.
@Test
@Transactional("transactionManager")
@Rollback(true)
public void invalidClientTest() {
//Test invalid fields
Client client = controller.getClient();
String _151chars = new String();
for (int i = 0; i < 151; i++) _151chars += "a";
client.setDisplayName(Text.valueOf(_151chars));
client.setShortDescription(Text.valueOf("description"));
client.setWebsite(Text.valueOf("http://site.com"));
client = controller.createClient(client);
List<String> errors = client.getErrors();
assertEquals(2, errors.size());
assertTrue(errors.contains(controller.getMessage("manage.developer_tools.group.error.display_name.150")));
assertTrue(errors.contains(controller.getMessage("common.invalid_url")));
//Test invalid redirect uris
client = controller.getClient();
client.setDisplayName(Text.valueOf("Name"));
client.setShortDescription(Text.valueOf("Description"));
client.setWebsite(Text.valueOf("http://mysite.com"));
List<RedirectUri> redirectUris = new ArrayList<RedirectUri>();
RedirectUri one = new RedirectUri();
one.setType(Text.valueOf("default"));
one.setValue(new Text());
redirectUris.add(one);
client.setRedirectUris(redirectUris);
client = controller.createClient(client);
errors = client.getErrors();
assertEquals(1, errors.size());
assertTrue(errors.contains(controller.getMessage("common.invalid_url")));
RedirectUri two = new RedirectUri();
two.setType(Text.valueOf("grant-read-wizard"));
two.setValue(new Text());
redirectUris = new ArrayList<RedirectUri>();
redirectUris.add(two);
client.setRedirectUris(redirectUris);
client = controller.createClient(client);
errors = client.getErrors();
assertEquals(2, errors.size());
assertTrue(errors.contains(controller.getMessage("common.invalid_url")));
assertTrue(errors.contains(controller.getMessage("manage.developer_tools.group.error.empty_scopes")));
}
use of org.orcid.pojo.ajaxForm.Client in project ORCID-Source by ORCID.
the class ManageMembersControllerTest method editMemberDoesntChangePersistentTokenEnabledValueTest.
@Test
public void editMemberDoesntChangePersistentTokenEnabledValueTest() throws Exception {
Client clientWithPersistentTokensEnabled = manageMembers.findClient("APP-0000000000000001");
assertNotNull(clientWithPersistentTokensEnabled);
assertNotNull(clientWithPersistentTokensEnabled.getDisplayName());
assertEquals("Client # 1", clientWithPersistentTokensEnabled.getDisplayName().getValue());
assertNotNull(clientWithPersistentTokensEnabled.getPersistentTokenEnabled());
assertTrue(clientWithPersistentTokensEnabled.getPersistentTokenEnabled().getValue());
clientWithPersistentTokensEnabled.getDisplayName().setValue("Updated Name");
manageMembers.updateClient(clientWithPersistentTokensEnabled);
Client updatedClient = manageMembers.findClient("APP-0000000000000001");
assertNotNull(updatedClient);
assertNotNull(updatedClient.getDisplayName());
assertEquals("Updated Name", updatedClient.getDisplayName().getValue());
assertNotNull(updatedClient.getPersistentTokenEnabled());
assertTrue(updatedClient.getPersistentTokenEnabled().getValue());
}
use of org.orcid.pojo.ajaxForm.Client in project ORCID-Source by ORCID.
the class ResultContainer method findClient.
@RequestMapping(value = "/find-client.json", method = RequestMethod.GET)
@ResponseBody
public Client findClient(@RequestParam("orcid") String clientId) {
Client result = new Client();
if (PojoUtil.isEmpty(clientId)) {
result.getErrors().add(getMessage("manage_member.not_blank"));
} else {
org.orcid.jaxb.model.v3.dev1.client.Client modelClient = clientManagerReadOnly.get(clientId);
result = Client.fromModelObject(modelClient);
}
return result;
}
Aggregations