PolicyEvaluatorFactory.java revision 6033fe2cfc1c391360277704d2c66456a33e9446
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the Common Development and Distribution License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (the License). You may not use this file except in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below the CDDL Header,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the fields enclosed by brackets [] replaced by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * your own identifying information:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: PolicyEvaluatorFactory.java,v 1.3 2008/06/25 05:43:46 qcheng Exp $
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Portions Copyrighted [2011] [ForgeRock AS]
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.security.AppSSOTokenProvider;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * This class acts as a factory to get an instance of
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>com.sun.idenity.policy.client.PolicyEvaluator</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @supported.all.api
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster static Debug debug = Debug.getInstance("amRemotePolicy");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static PolicyEvaluatorFactory factory; //singleton instance
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Constructs a policy evaluator factory
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster + "created singleton instance");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns an instance of
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>com.sun.identity.policy.client.PolicyEvaluatorFactory</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return an instance of
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>com.sun.identity.policy.client.PolicyEvaluatorFactory</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster synchronized public static PolicyEvaluatorFactory getInstance() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns an instance of
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>com.sun.identity.policy.client.PolicyEvaluator</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param serviceName name of the service for which to get the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>PolicyEvaluator</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return an instance of <code>PolicyEvaluator</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws PolicyException if creation of evaluator fails.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException if application single sign on token is invalid
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public PolicyEvaluator getPolicyEvaluator(String serviceName)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns an instance of
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>com.sun.identity.policy.client.PolicyEvaluator</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param serviceName name of the service for which to get the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>com.sun.identity.policy.client.PolicyEvaluator</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param appSSOTokenProvider application single sign on token Provider
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return an instance of
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>com.sun.identity.policy.client.PolicyEvaluator</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws PolicyException if creation of evaluator fails.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException if application single sign on token is invalid.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster synchronized public PolicyEvaluator getPolicyEvaluator(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.warning("PolicyEvaluatorFactory.getPolicyEvaluator():"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster + "serviceName is null");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } //else do the following
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Map appTokenEvaluatorsMap = (Map)evaluatorsCache.get(serviceName);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster evaluatorsCache.put(serviceName, appTokenEvaluatorsMap);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster pe = (PolicyEvaluator)appTokenEvaluatorsMap.get(appSSOTokenProvider);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.message("PolicyEvaluatorFactory.getPolicyEvaluator():"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster + ":creating new PolicyEvaluator");
6033fe2cfc1c391360277704d2c66456a33e9446sachiko pe = PolicyEvaluator.getInstance(serviceName, appSSOTokenProvider);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster appTokenEvaluatorsMap.put(appSSOTokenProvider, pe);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.message("PolicyEvaluatorFactory.getPolicyEvaluator():"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster + ":returning PolicyEvaluator from cache");