RestSTSInstanceConfigTest.java revision e6d7ebe1d98f7f030969e521b061f8643253475e
/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions Copyrighted [year] [name of copyright owner]".
*
* Copyright 2013-2014 ForgeRock AS. All rights reserved.
*/
/**
*/
public class RestSTSInstanceConfigTest {
@Test
public void testEquals() throws UnsupportedEncodingException {
}
@Test
public void testNotEquals() throws UnsupportedEncodingException {
}
public void testRejectIfNull() throws UnsupportedEncodingException {
}
public void testIllegalStateExceptionNoSaml2Config() throws UnsupportedEncodingException {
}
@Test
public void testJsonMarshalling() throws IOException {
}
@Test
public void testJsonStringMarshalling() throws IOException {
/*
This is how the Crest HttpServletAdapter ultimately constitutes a JsonValue from a json string. See the
org.forgerock.json.resource.servlet.HttpUtils.parseJsonBody (called from HttpServletAdapter.getJsonContent)
for details. This is using the older version of jackson
(org.codehaus.jackson.map.ObjectMapper), and I will do the same (albeit with the newer version), to reproduce
the same behavior.
*/
JsonParser parser = new ObjectMapper().getJsonFactory().createJsonParser(origConfig.toJson().toString());
}
@Test
public void testOldJacksonJsonStringMarhalling() throws IOException {
/*
This is how the Crest HttpServletAdapter ultimately constitutes a JsonValue from a json string. See the
org.forgerock.json.resource.servlet.HttpUtils.parseJsonBody (called from HttpServletAdapter.getJsonContent)
for details. This is using the older version of jackson
(org.codehaus.jackson.map.ObjectMapper), and I will do the same, to reproduce
the same behavior.
*/
new org.codehaus.jackson.map.ObjectMapper().getJsonFactory().createJsonParser(origConfig.toJson().toString());
}
private RestSTSInstanceConfig createInstanceConfig(String uriElement, String amDeploymentUrl) throws UnsupportedEncodingException {
.build();
.build();
.fileName("stsstore.jks")
.encryptionKeyAlias("mystskey")
.signatureKeyAlias("mystskey")
.build();
.nameIdFormat("transient")
.tokenLifetimeInSeconds(500000)
.build();
return RestSTSInstanceConfig.builder()
.amJsonRestBase("/json")
.amRestAuthNUriElement("/authenticate")
.amRestLogoutUriElement("/sessions/?_action=logout")
.amRestIdFromSessionUriElement("/users/?_action=idFromSession")
.amRestTokenGenerationServiceUriElement("/sts_tokengen/issue?_action=issue")
.amSessionCookieName("iPlanetDirectoryPro")
.issuerName("Cornholio")
.build();
}
private RestSTSInstanceConfig createIncompleteInstanceConfig() throws UnsupportedEncodingException {
//leave out the DeploymentConfig to test null rejection
.fileName("stsstore.jks")
.encryptionKeyAlias("mystskey")
.signatureKeyAlias("mystskey")
.build();
return RestSTSInstanceConfig.builder()
.amDeploymentUrl("whatever")
.amRestLogoutUriElement("/json/sessions/?_action=logout")
.amRestIdFromSessionUriElement("/json/users/?_action=idFromSession")
.amRestTokenGenerationServiceUriElement("/sts_tokengen/issue?_action=issue")
.amSessionCookieName("iPlanetDirectoryPro")
.issuerName("Cornholio")
.build();
}
/*
Create RestSTSInstanceConfig with SAML2 output tokens, but without SAML2Config, to test IllegalStateException
*/
private RestSTSInstanceConfig createInstanceConfigWithoutSaml2Config(String uriElement, String amDeploymentUrl) throws UnsupportedEncodingException {
.build();
.build();
.fileName("stsstore.jks")
.encryptionKeyAlias("mystskey")
.signatureKeyAlias("mystskey")
.build();
return RestSTSInstanceConfig.builder()
.amJsonRestBase("/json")
.amRestAuthNUriElement("/authenticate")
.amRestLogoutUriElement("/sessions/?_action=logout")
.amRestIdFromSessionUriElement("/users/?_action=idFromSession")
.amRestTokenGenerationServiceUriElement("/sts_tokengen/issue?_action=issue")
.amSessionCookieName("iPlanetDirectoryPro")
.issuerName("Cornholio")
.build();
}
}