RestSTSInstanceConfig.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.
*/
/**
* Class which encapsulates all of the user-provided config information necessary to create an instance of the
* STS.
* It is an immutable object with getter methods to obtain all of the necessary information needed by the various
* guice modules and providers to inject the object graph corresponding to a fully-configured STS instance.
*
* For an explanation of what's going on with the builders in this class,
*
* Also attempted to marshal the RestSTSInstanceConfig to/from json with the jackson ObjectMapper. But I was adding
* @JsonSerialize and @JsonDeserialize annotations, and because builder-based classes don't expose ctors which
* take the complete field set, I would have to create @JsonCreator instances which would have to pull all of the
* values out of a map anyway, which is 75% of the way towards a hand-rolled json marshalling implementation based on
* json-fluent. So a hand-rolled implementation it is.
*/
public class RestSTSInstanceConfig extends STSInstanceConfig {
public abstract static class RestSTSInstanceConfigBuilderBase<T extends RestSTSInstanceConfigBuilderBase<T>> extends STSInstanceConfig.STSInstanceConfigBuilderBase<T> {
private RestDeploymentConfig deploymentConfig;
private RestSTSInstanceConfigBuilderBase() {
}
this.deploymentConfig = deploymentConfig;
return self();
}
public T addSupportedTokenTranslation(
boolean invalidateInterimOpenAMSession) {
return self();
}
return self();
}
public RestSTSInstanceConfig build() {
return new RestSTSInstanceConfig(this);
}
}
public static class RestSTSInstanceConfigBuilder extends RestSTSInstanceConfigBuilderBase<RestSTSInstanceConfigBuilder> {
protected RestSTSInstanceConfigBuilder self() {
return this;
}
}
private final RestDeploymentConfig deploymentConfig;
super(builder);
/*
throw an exception if no SAML2Config is set, but a SAML token is specified as
output in one of the token transformations.
*/
if (this.saml2Config == null) {
throw new IllegalStateException("A SAML2 token is a transformation output, but no Saml2Config " +
"state has been specified to guide the production of SAML2 tokens.");
}
}
}
}
public static RestSTSInstanceConfigBuilderBase<?> builder() {
return new RestSTSInstanceConfigBuilder();
}
/**
* @return The RestDeploymentConfig instance which specifies the url of the deployed STS instance, its realm,
* and its OpenAM authN context for each validated token type.
*/
public RestDeploymentConfig getDeploymentConfig() {
return deploymentConfig;
}
/**
* @return The set of token transformation operations supported by this STS instance.
*/
return supportedTokenTranslations;
}
sb.append('\t').append("supportedTokenTranslations: ").append(supportedTokenTranslations).append('\n');
}
if (other instanceof RestSTSInstanceConfig) {
return super.equals(otherConfig) &&
}
return false;
}
public int hashCode() {
}
}
return baseValue;
}
throw new NullPointerException("JsonValue cannot be null!");
}
if (!supportedTranslations.isList()) {
throw new IllegalStateException("Unexpected value for the " + SUPPORTED_TOKEN_TRANSLATIONS + " field: "
}
}
}
}