2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.policy.pdp.rest.impl;
22 import java.util.Properties;
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26 import org.onap.policy.common.logging.eelf.MessageCodes;
27 import org.onap.policy.common.logging.eelf.PolicyLogger;
29 import org.onap.policy.xacml.api.XACMLErrorConstants;
30 import com.att.research.xacml.api.pip.PIPException;
31 import com.att.research.xacml.api.pip.PIPFinder;
32 import com.att.research.xacml.api.pip.PIPFinderFactory;
33 import com.att.research.xacml.std.pip.finders.ConfigurableEngineFinder;
34 import com.att.research.xacml.util.XACMLProperties;
36 public class XACMLPdpPIPFinderFactory extends PIPFinderFactory {
37 private ConfigurableEngineFinder pipFinder;
39 private static Log LOGGER = LogFactory.getLog(XACMLPdpPIPFinderFactory.class);
41 public XACMLPdpPIPFinderFactory() {
44 public XACMLPdpPIPFinderFactory(Properties properties) {
48 public PIPFinder getFinder() throws PIPException {
50 if (pipFinder == null) {
51 if (LOGGER.isDebugEnabled()) {
52 LOGGER.debug("Creating default configurable engine finder");
54 pipFinder = new ConfigurableEngineFinder();
55 Properties xacmlProperties = null;
57 xacmlProperties = XACMLProperties.getProperties();
58 } catch (Exception ex) {
59 LOGGER.error( XACMLErrorConstants.ERROR_SYSTEM_ERROR+ "Exception getting XACML properties: " + ex.getMessage(), ex);
60 PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, ex, "Exception getting XACML properties");
63 if (xacmlProperties != null) {
64 ((ConfigurableEngineFinder)pipFinder).configure(xacmlProperties);
72 public PIPFinder getFinder(Properties properties) throws PIPException {
74 if (pipFinder == null) {
75 if (LOGGER.isDebugEnabled()) {
76 LOGGER.debug("Creating configurable engine finder using: " + properties);
78 pipFinder = new ConfigurableEngineFinder();
79 ((ConfigurableEngineFinder)pipFinder).configure(properties);
82 return this.pipFinder;