Search in sources :

Example 6 with SSOCredentials

use of org.orcid.pojo.ajaxForm.SSOCredentials in project ORCID-Source by ORCID.

the class DeveloperToolsControllerTest method testCrossSiteScriptingOnClientDescription.

@Test
@Transactional("transactionManager")
public void testCrossSiteScriptingOnClientDescription() throws Exception {
    SSOCredentials ssoCredentials = new SSOCredentials();
    ssoCredentials.setClientName(Text.valueOf("Client Name"));
    ssoCredentials.setClientDescription(Text.valueOf("This is a test to show that html is <script>alert('name')</script> throws an error"));
    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);
    assertEquals(1, result.getErrors().size());
    assertEquals(developerToolsController.getMessage("manage.developer_tools.description.html"), result.getErrors().get(0));
}
Also used : SSOCredentials(org.orcid.pojo.ajaxForm.SSOCredentials) RedirectUri(org.orcid.pojo.ajaxForm.RedirectUri) HashSet(java.util.HashSet) Test(org.junit.Test) BaseControllerTest(org.orcid.frontend.web.util.BaseControllerTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with SSOCredentials

use of org.orcid.pojo.ajaxForm.SSOCredentials in project ORCID-Source by ORCID.

the class DeveloperToolsControllerTest method testCrossSiteScriptingOnClientName.

@Test
@Transactional("transactionManager")
public void testCrossSiteScriptingOnClientName() throws Exception {
    SSOCredentials ssoCredentials = new SSOCredentials();
    ssoCredentials.setClientName(Text.valueOf("<script>alert('name')</script>"));
    ssoCredentials.setClientDescription(Text.valueOf("This is a short 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);
    assertEquals(1, result.getErrors().size());
    assertEquals(developerToolsController.getMessage("manage.developer_tools.name.html"), result.getErrors().get(0));
}
Also used : SSOCredentials(org.orcid.pojo.ajaxForm.SSOCredentials) RedirectUri(org.orcid.pojo.ajaxForm.RedirectUri) HashSet(java.util.HashSet) Test(org.junit.Test) BaseControllerTest(org.orcid.frontend.web.util.BaseControllerTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with SSOCredentials

use of org.orcid.pojo.ajaxForm.SSOCredentials 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;
}
Also used : SSOCredentials(org.orcid.pojo.ajaxForm.SSOCredentials) RedirectUri(org.orcid.pojo.ajaxForm.RedirectUri) Text(org.orcid.pojo.ajaxForm.Text) HashSet(java.util.HashSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

SSOCredentials (org.orcid.pojo.ajaxForm.SSOCredentials)8 HashSet (java.util.HashSet)7 RedirectUri (org.orcid.pojo.ajaxForm.RedirectUri)7 Test (org.junit.Test)6 BaseControllerTest (org.orcid.frontend.web.util.BaseControllerTest)6 Transactional (org.springframework.transaction.annotation.Transactional)5 Text (org.orcid.pojo.ajaxForm.Text)3 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 ClientSecretEntity (org.orcid.persistence.jpa.entities.ClientSecretEntity)1