c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * Copyright (c) 2016 ForgeRock AS. All Rights Reserved
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * The contents of this file are subject to the terms
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * of the Common Development and Distribution License
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * (the License). You may not use this file except in
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * compliance with the License.
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * You can obtain a copy of the License at legal/CDDLv1.0.txt.
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * See the License for the specific language governing
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * permission and limitations under the License.
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * When distributing Covered Code, include this CDDL
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * Header Notice in each file and include the License file at legal/CDDLv1.0.txt.
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * If applicable, add the following below the CDDL Header,
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * with the fields enclosed by brackets [] replaced by
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * your own identifying information:
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * "Portions Copyrighted [year] [name of copyright owner]"
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmithpackage com.forgerock.openam.functionaltest.sts.frmwk.rest;
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmithimport org.forgerock.openam.sts.config.user.CustomTokenOperation;
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmithimport org.forgerock.openam.sts.rest.config.user.TokenTransformConfig;
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * Encapsulates specification of custom token operations, for use in publishing rest-sts instances.
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith public static class CustomTokenOperationContextBuilder {
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith private final HashSet<CustomTokenOperation> customValidators;
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith private final HashSet<CustomTokenOperation> customProviders;
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith private final HashSet<TokenTransformConfig> customTransforms;
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith private CustomTokenOperationContextBuilder() {
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith public CustomTokenOperationContextBuilder addCustomTokenValidator(String customTokenId, String restTokenValidatorImplClass) {
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith customValidators.add(new CustomTokenOperation(customTokenId, restTokenValidatorImplClass));
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith public CustomTokenOperationContextBuilder addCustomTokenProvider(String customTokenId, String restTokenValidatorImplClass) {
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith customProviders.add(new CustomTokenOperation(customTokenId, restTokenValidatorImplClass));
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith public CustomTokenOperationContextBuilder addCustomTokenTransformation(String inputTokenType, String outputTokenType,
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith customTransforms.add(new TokenTransformConfig(inputTokenType, outputTokenType, invalidateInterimOpenAMSession));
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith public CustomTokenOperationContext build() {
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith return new CustomTokenOperationContext(this);
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith private final Set<CustomTokenOperation> customValidators;
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith private final Set<CustomTokenOperation> customProviders;
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith private final Set<TokenTransformConfig> customTransforms;
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith private CustomTokenOperationContext(CustomTokenOperationContextBuilder builder) {
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith this.customValidators = Collections.unmodifiableSet(builder.customValidators);
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith this.customProviders = Collections.unmodifiableSet(builder.customProviders);
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith this.customTransforms = Collections.unmodifiableSet(builder.customTransforms);
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith public static CustomTokenOperationContextBuilder builder() {
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith return new CustomTokenOperationContextBuilder();
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith public Set<CustomTokenOperation> getCustomValidators() { return customValidators; }
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith public Set<CustomTokenOperation> getCustomProviders() { return customProviders; }