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 {
49 if (pipFinder == null) {
51 if (pipFinder == null) {
52 if (LOGGER.isDebugEnabled()) {
53 LOGGER.debug("Creating default configurable engine finder");
55 pipFinder = new ConfigurableEngineFinder();
56 Properties xacmlProperties = null;
58 xacmlProperties = XACMLProperties.getProperties();
59 } catch (Exception ex) {
60 LOGGER.error( XACMLErrorConstants.ERROR_SYSTEM_ERROR+ "Exception getting XACML properties: " + ex.getMessage(), ex);
61 PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, ex, "Exception getting XACML properties");
64 if (xacmlProperties != null) {
65 ((ConfigurableEngineFinder)pipFinder).configure(xacmlProperties);
74 public PIPFinder getFinder(Properties properties) throws PIPException {
75 if (pipFinder == null) {
77 if (pipFinder == null) {
78 if (LOGGER.isDebugEnabled()) {
79 LOGGER.debug("Creating configurable engine finder using: " + properties);
81 pipFinder = new ConfigurableEngineFinder();
82 ((ConfigurableEngineFinder)pipFinder).configure(properties);
86 return this.pipFinder;