STSInstanceConfig.java revision 954d71f34d584a7bcc51a5df9933427542081d62
/*
* 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.
*/
/**
* Base class encapsulating STS configuration state common to both the REST and SOAP STS. A builder builds this
* For an explanation of what's going on with the builders in this class and its subclasses,
*
* 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. See toJson and fromJson methods.
*/
public class STSInstanceConfig {
/*
Define the names of fields to aid in json marshalling. Note that these names match the names of the AttributeSchema
entries in restSTS.xml, as this aids in marshalling an instance of this class into the attribute map needed for
SMS persistence.
*/
protected final String issuerName;
protected final SAML2Config saml2Config;
public static abstract class STSInstanceConfigBuilderBase<T extends STSInstanceConfigBuilderBase<T>> {
private String issuerName;
private SAML2Config saml2Config;
protected abstract T self();
this.issuerName = issuerName;
return self();
}
this.saml2Config = saml2Config;
return self();
}
public STSInstanceConfig build() {
return new STSInstanceConfig(this);
}
}
public static class STSInstanceConfigBuilder extends STSInstanceConfigBuilderBase<STSInstanceConfigBuilder> {
protected STSInstanceConfigBuilder self() {
return this;
}
}
}
/**
* @return The issuerName in tokens (e.g. SAML2) generated by the STS.
*/
public String getIssuerName() {
return issuerName;
}
/**
*
* @return The SAML2Config object which specifies the state necessary for STS-instance-specific SAML2 assertions to
* be generated. This state is used by the token generation service.
*/
public SAML2Config getSaml2Config() {
return saml2Config;
}
public static STSInstanceConfigBuilderBase<?> builder() {
return new STSInstanceConfigBuilder();
}
}
if (other instanceof STSInstanceConfig) {
((saml2Config != null ? saml2Config.equals(otherConfig.getSaml2Config()) : (otherConfig.getSaml2Config() == null)));
}
return false;
}
if (saml2Config == null) {
return jsonValue;
} else {
return jsonValue;
}
}
if (samlConfig.isNull()) {
} else {
}
}
/*
the Map<String, Object> expected by the SMS is a flat structure - so I need to flatten all
nested elements.
*/
if (saml2Config != null) {
}
return attributes;
}
/*
If SAML2Config state is not present, null will be returned. That will tell me that no SAML2Config
had been present initially.
*/
if (saml2Config != null) {
}
}
}