use of org.orcid.pojo.ajaxForm.RedirectUri in project ORCID-Source by ORCID.
the class GroupAdministratorController method getEmptyRedirectUri.
@RequestMapping(value = "/get-empty-redirect-uri.json", method = RequestMethod.GET)
@ResponseBody
public RedirectUri getEmptyRedirectUri(HttpServletRequest request) {
RedirectUri result = new RedirectUri();
result.setValue(new Text());
result.setType(Text.valueOf(RedirectUriType.DEFAULT.value()));
result.setActType(Text.valueOf(""));
result.setGeoArea(Text.valueOf(""));
return result;
}
use of org.orcid.pojo.ajaxForm.RedirectUri in project ORCID-Source by ORCID.
the class DeveloperToolsController method getEmptyRedirectUri.
@RequestMapping(value = "/get-empty-redirect-uri.json", method = RequestMethod.GET)
@ResponseBody
public RedirectUri getEmptyRedirectUri(HttpServletRequest request) {
RedirectUri result = new RedirectUri();
result.setValue(new Text());
result.setActType(Text.valueOf(""));
result.setGeoArea(Text.valueOf(""));
result.setType(Text.valueOf(RedirectUriType.DEFAULT.name()));
return result;
}
use of org.orcid.pojo.ajaxForm.RedirectUri in project ORCID-Source by ORCID.
the class GroupAdministratorController method editClient.
@RequestMapping(value = "/edit-client.json", method = RequestMethod.POST)
@Produces(value = { MediaType.APPLICATION_JSON })
@ResponseBody
public Client editClient(@RequestBody Client client) {
// Clean the error list
client.setErrors(new ArrayList<String>());
// Validate fields
validateDisplayName(client);
validateWebsite(client);
validateShortDescription(client);
validateRedirectUris(client);
copyErrors(client.getDisplayName(), client);
copyErrors(client.getWebsite(), client);
copyErrors(client.getShortDescription(), client);
for (RedirectUri redirectUri : client.getRedirectUris()) {
copyErrors(redirectUri, client);
}
if (client.getErrors().size() == 0) {
OrcidProfile profile = getEffectiveProfile();
String groupOrcid = profile.getOrcidIdentifier().getPath();
if (profile.getType() == null || !profile.getType().equals(OrcidType.GROUP)) {
LOGGER.warn("Trying to edit client with non group user {}", profile.getOrcidIdentifier().getPath());
throw new OrcidClientGroupManagementException(getMessage("web.orcid.privilege.exception"));
}
OrcidClient result = null;
try {
result = orcidClientGroupManager.updateClient(groupOrcid, client.toOrcidClient());
clearCache();
} catch (OrcidClientGroupManagementException e) {
LOGGER.error(e.getMessage());
result = new OrcidClient();
result.setErrors(new ErrorDesc(getMessage("manage.developer_tools.group.unable_to_update")));
}
client = Client.valueOf(result);
}
return client;
}
use of org.orcid.pojo.ajaxForm.RedirectUri in project ORCID-Source by ORCID.
the class DeveloperToolsControllerTest method testSSOCredentialsValidation.
@Test
@Transactional("transactionManager")
public void testSSOCredentialsValidation() throws Exception {
//Test empty title
SSOCredentials ssoCredentials = new SSOCredentials();
ssoCredentials.setClientDescription(Text.valueOf("This is a description"));
ssoCredentials.setClientWebsite(Text.valueOf("http://client.com"));
Set<RedirectUri> redirectUris = new HashSet<RedirectUri>();
RedirectUri rUri = new RedirectUri();
rUri.setType(Text.valueOf("default"));
rUri.setValue(Text.valueOf("http://test.com"));
redirectUris.add(rUri);
ssoCredentials.setRedirectUris(redirectUris);
SSOCredentials result = developerToolsController.generateSSOCredentialsJson(ssoCredentials);
assertNotNull(result.getErrors());
assertEquals(result.getErrors().size(), 1);
assertEquals(result.getErrors().get(0), developerToolsController.getMessage("manage.developer_tools.name_not_empty"));
//Test empty description
ssoCredentials = new SSOCredentials();
ssoCredentials.setClientName(Text.valueOf("Client Name"));
ssoCredentials.setClientWebsite(Text.valueOf("http://client.com"));
redirectUris = new HashSet<RedirectUri>();
rUri = new RedirectUri();
rUri.setType(Text.valueOf("default"));
rUri.setValue(Text.valueOf("http://test.com"));
redirectUris.add(rUri);
ssoCredentials.setRedirectUris(redirectUris);
result = developerToolsController.generateSSOCredentialsJson(ssoCredentials);
assertNotNull(result.getErrors());
assertEquals(result.getErrors().size(), 1);
assertEquals(result.getErrors().get(0), developerToolsController.getMessage("manage.developer_tools.description_not_empty"));
//Test empty website
ssoCredentials = new SSOCredentials();
ssoCredentials.setClientName(Text.valueOf("Client Name"));
ssoCredentials.setClientDescription(Text.valueOf("This is a description"));
redirectUris = new HashSet<RedirectUri>();
rUri = new RedirectUri();
rUri.setType(Text.valueOf("default"));
rUri.setValue(Text.valueOf("http://test.com"));
redirectUris.add(rUri);
ssoCredentials.setRedirectUris(redirectUris);
result = developerToolsController.generateSSOCredentialsJson(ssoCredentials);
assertNotNull(result.getErrors());
assertEquals(result.getErrors().size(), 1);
assertEquals(result.getErrors().get(0), developerToolsController.getMessage("manage.developer_tools.website_not_empty"));
//Test empty redirect uris
ssoCredentials = new SSOCredentials();
ssoCredentials.setClientName(Text.valueOf("Client Name"));
ssoCredentials.setClientDescription(Text.valueOf("This is a description"));
ssoCredentials.setClientWebsite(Text.valueOf("http://client.com"));
result = developerToolsController.generateSSOCredentialsJson(ssoCredentials);
assertNotNull(result.getErrors());
assertEquals(result.getErrors().size(), 1);
assertEquals(result.getErrors().get(0), developerToolsController.getMessage("manage.developer_tools.at_least_one"));
}
use of org.orcid.pojo.ajaxForm.RedirectUri in project ORCID-Source by ORCID.
the class DeveloperToolsControllerTest method testUpdateSSOCredentials.
@Test
@Transactional("transactionManager")
public void testUpdateSSOCredentials() throws Exception {
SSOCredentials ssoCredentials = new SSOCredentials();
ssoCredentials.setClientName(Text.valueOf("Client Name"));
ssoCredentials.setClientDescription(Text.valueOf("This is a test"));
ssoCredentials.setClientWebsite(Text.valueOf("http://client.com"));
Set<RedirectUri> redirectUris = new HashSet<RedirectUri>();
RedirectUri rUri = new RedirectUri();
rUri.setType(Text.valueOf("default"));
rUri.setValue(Text.valueOf("http://test.com"));
redirectUris.add(rUri);
ssoCredentials.setRedirectUris(redirectUris);
SSOCredentials result = developerToolsController.generateSSOCredentialsJson(ssoCredentials);
assertNotNull(result);
assertNotNull(result.getErrors());
assertEquals(result.getErrors().size(), 0);
Text clientSecret = result.getClientSecret();
//Update values
ssoCredentials.setClientName(Text.valueOf("Updated client name"));
ssoCredentials.setClientDescription(Text.valueOf("Updated client description"));
ssoCredentials.setClientWebsite(Text.valueOf("http://updated.com"));
RedirectUri rUri2 = new RedirectUri();
rUri2.setType(Text.valueOf("default"));
rUri2.setValue(Text.valueOf("http://test2.com"));
redirectUris.add(rUri2);
ssoCredentials.setRedirectUris(redirectUris);
SSOCredentials updatedResult = developerToolsController.updateUserCredentials(ssoCredentials);
assertNotNull(updatedResult);
assertNotNull(updatedResult.getErrors());
assertEquals(updatedResult.getErrors().size(), 0);
Text updatedClientSecret = updatedResult.getClientSecret();
assertEquals(updatedClientSecret.toString(), clientSecret.toString());
assertEquals(updatedResult.getClientName().getValue(), "Updated client name");
assertEquals(updatedResult.getClientDescription().getValue(), "Updated client description");
assertEquals(updatedResult.getClientWebsite().getValue(), "http://updated.com");
assertNotNull(updatedResult.getRedirectUris());
assertEquals(updatedResult.getRedirectUris().size(), 2);
}
Aggregations