use of org.orcid.pojo.ajaxForm.RedirectUri in project ORCID-Source by ORCID.
the class DeveloperToolsController method generateSSOCredentialsJson.
@RequestMapping(value = "/generate-sso-credentials.json", method = RequestMethod.POST)
@ResponseBody
public SSOCredentials generateSSOCredentialsJson(@RequestBody SSOCredentials ssoCredentials) {
boolean hasErrors = validateSSOCredentials(ssoCredentials);
if (!hasErrors) {
OrcidProfile profile = getEffectiveProfile();
String orcid = profile.getOrcidIdentifier().getPath();
Set<String> redirectUriStrings = new HashSet<String>();
for (RedirectUri redirectUri : ssoCredentials.getRedirectUris()) {
redirectUriStrings.add(redirectUri.getValue().getValue());
}
String clientName = ssoCredentials.getClientName().getValue();
String clientDescription = ssoCredentials.getClientDescription().getValue();
String clientWebsite = ssoCredentials.getClientWebsite().getValue();
ClientDetailsEntity clientDetails = orcidSSOManager.grantSSOAccess(orcid, clientName, clientDescription, clientWebsite, redirectUriStrings);
ssoCredentials = SSOCredentials.toSSOCredentials(clientDetails);
} else {
List<String> errors = ssoCredentials.getErrors();
if (errors == null)
errors = new ArrayList<String>();
if (ssoCredentials.getClientName().getErrors() != null && !ssoCredentials.getClientName().getErrors().isEmpty())
errors.addAll(ssoCredentials.getClientName().getErrors());
if (ssoCredentials.getClientDescription().getErrors() != null && !ssoCredentials.getClientDescription().getErrors().isEmpty())
errors.addAll(ssoCredentials.getClientDescription().getErrors());
if (ssoCredentials.getClientWebsite().getErrors() != null && !ssoCredentials.getClientWebsite().getErrors().isEmpty())
errors.addAll(ssoCredentials.getClientWebsite().getErrors());
if (ssoCredentials.getRedirectUris() != null) {
for (RedirectUri redirectUri : ssoCredentials.getRedirectUris()) {
if (redirectUri.getErrors() != null && !redirectUri.getErrors().isEmpty())
errors.addAll(redirectUri.getErrors());
}
}
ssoCredentials.setErrors(errors);
}
return ssoCredentials;
}
use of org.orcid.pojo.ajaxForm.RedirectUri in project ORCID-Source by ORCID.
the class DeveloperToolsController method getEmptySSOCredentials.
@RequestMapping(value = "/get-empty-sso-credential.json", method = RequestMethod.GET)
@ResponseBody
public SSOCredentials getEmptySSOCredentials(HttpServletRequest request) {
SSOCredentials emptyObject = new SSOCredentials();
emptyObject.setClientSecret(Text.valueOf(StringUtils.EMPTY));
RedirectUri redirectUri = new RedirectUri();
redirectUri.setValue(new Text());
redirectUri.setType(Text.valueOf(RedirectUriType.DEFAULT.name()));
Set<RedirectUri> set = new HashSet<RedirectUri>();
set.add(redirectUri);
emptyObject.setRedirectUris(set);
return emptyObject;
}
use of org.orcid.pojo.ajaxForm.RedirectUri in project ORCID-Source by ORCID.
the class GroupAdministratorControllerTest method testInvalidWebsite.
@Test
public void testInvalidWebsite() {
Client client = controller.getClient();
client.setRedirectUris(new ArrayList<RedirectUri>());
client.setDisplayName(Text.valueOf("This is a valid name"));
client.setShortDescription(Text.valueOf("This is a valid description"));
client.setWebsite(Text.valueOf("http:://orcid.org"));
client = controller.createClient(client);
assertNotNull(client);
assertEquals(1, client.getErrors().size());
assertEquals(controller.getMessage("common.invalid_url"), client.getErrors().get(0));
}
use of org.orcid.pojo.ajaxForm.RedirectUri in project ORCID-Source by ORCID.
the class ManageMembersControllerTest method findClientTest.
@Test
public void findClientTest() throws Exception {
//Client with all redirect uris default
Client client_0002 = manageMembers.findClient("APP-0000000000000002");
assertNotNull(client_0002);
assertNotNull(client_0002.getDisplayName());
assertEquals("Client # 2", client_0002.getDisplayName().getValue());
assertNotNull(client_0002.getRedirectUris());
assertEquals(1, client_0002.getRedirectUris().size());
assertEquals("http://www.google.com/APP-0000000000000002/redirect/oauth", client_0002.getRedirectUris().get(0).getValue().getValue());
//Client with redirect uri not default
Client client_0003 = manageMembers.findClient("APP-0000000000000003");
assertNotNull(client_0003);
assertNotNull(client_0003.getDisplayName());
assertEquals("Client # 3", client_0003.getDisplayName().getValue());
assertNotNull(client_0003.getRedirectUris());
assertEquals(2, client_0003.getRedirectUris().size());
RedirectUri rUri1 = client_0003.getRedirectUris().get(0);
if ("http://www.google.com/APP-0000000000000003/redirect/oauth".equals(rUri1.getValue().getValue())) {
assertNotNull(rUri1.getType());
assertEquals("default", rUri1.getType().getValue());
assertNotNull(rUri1.getScopes());
assertEquals(0, rUri1.getScopes().size());
} else if ("http://www.google.com/APP-0000000000000003/redirect/oauth/grant_read_wizard".equals(rUri1.getValue().getValue())) {
assertNotNull(rUri1.getType());
assertEquals("grant-read-wizard", rUri1.getType().getValue());
assertNotNull(rUri1.getScopes());
assertEquals(1, rUri1.getScopes().size());
assertEquals("/funding/read-limited", rUri1.getScopes().get(0));
} else {
fail("Invalid redirect uri: " + rUri1.getValue().getValue());
}
RedirectUri rUri2 = client_0003.getRedirectUris().get(1);
if ("http://www.google.com/APP-0000000000000003/redirect/oauth".equals(rUri2.getValue().getValue())) {
assertNotNull(rUri2.getType());
assertEquals("default", rUri2.getType().getValue());
assertNotNull(rUri2.getScopes());
assertEquals(1, rUri2.getScopes().size());
assertEquals("", rUri2.getScopes().get(0));
} else if ("http://www.google.com/APP-0000000000000003/redirect/oauth/grant_read_wizard".equals(rUri2.getValue().getValue())) {
assertNotNull(rUri2.getType());
assertEquals("grant-read-wizard", rUri2.getType().getValue());
assertNotNull(rUri2.getScopes());
assertEquals(1, rUri2.getScopes().size());
assertEquals("/funding/read-limited", rUri2.getScopes().get(0));
} else {
fail("Invalid redirect uri: " + rUri2.getValue().getValue());
}
}
use of org.orcid.pojo.ajaxForm.RedirectUri in project ORCID-Source by ORCID.
the class GroupAdministratorController method getClient.
@RequestMapping(value = "/client.json", method = RequestMethod.GET)
@ResponseBody
public Client getClient() {
Client emptyClient = new Client();
emptyClient.setDisplayName(new Text());
emptyClient.setWebsite(new Text());
emptyClient.setShortDescription(new Text());
emptyClient.setClientId(new Text());
emptyClient.setClientSecret(new Text());
emptyClient.setType(new Text());
emptyClient.setAllowAutoDeprecate(Checkbox.valueOf(false));
ArrayList<RedirectUri> redirectUris = new ArrayList<RedirectUri>();
RedirectUri emptyRedirectUri = new RedirectUri();
emptyRedirectUri.setValue(new Text());
emptyRedirectUri.setType(Text.valueOf(RedirectUriType.DEFAULT.value()));
emptyRedirectUri.setActType(Text.valueOf(""));
emptyRedirectUri.setGeoArea(Text.valueOf(""));
redirectUris.add(emptyRedirectUri);
emptyClient.setRedirectUris(redirectUris);
return emptyClient;
}
Aggregations