2  * ============LICENSE_START=======================================================
 
   3  *  Copyright (C) 2018 Ericsson. All rights reserved.
 
   4  *  Modifications Copyright (C) 2019 AT&T Intellectual Property.
 
   5  * ================================================================================
 
   6  * Licensed under the Apache License, Version 2.0 (the "License");
 
   7  * you may not use this file except in compliance with the License.
 
   8  * You may obtain a copy of the License at
 
  10  *      http://www.apache.org/licenses/LICENSE-2.0
 
  12  * Unless required by applicable law or agreed to in writing, software
 
  13  * distributed under the License is distributed on an "AS IS" BASIS,
 
  14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  15  * See the License for the specific language governing permissions and
 
  16  * limitations under the License.
 
  18  * SPDX-License-Identifier: Apache-2.0
 
  19  * ============LICENSE_END=========================================================
 
  22 package org.onap.policy.distribution.forwarding.xacml.pdp;
 
  24 import org.onap.policy.common.parameters.GroupValidationResult;
 
  25 import org.onap.policy.common.parameters.ValidationStatus;
 
  26 import org.onap.policy.common.utils.validation.ParameterValidationUtils;
 
  27 import org.onap.policy.distribution.main.parameters.PolicyForwarderConfigurationParameterGroup;
 
  30  * Holds the parameters for the{@link XacmlPdpPolicyForwarder}.
 
  32 public class XacmlPdpPolicyForwarderParameterGroup extends PolicyForwarderConfigurationParameterGroup {
 
  33     public static final String POLICY_FORWARDER_PLUGIN_CLASS = XacmlPdpPolicyForwarder.class.getName();
 
  35     private boolean useHttps;
 
  36     private String hostname;
 
  38     private String userName;
 
  39     private String password;
 
  40     private String clientAuth;
 
  41     private boolean isManaged;
 
  42     private String pdpGroup;
 
  45      * Construct an instance.
 
  47      * @param builder the builder create the instance from
 
  49     private XacmlPdpPolicyForwarderParameterGroup(final XacmlPdpPolicyForwarderParameterGroupBuilder builder) {
 
  50         this.useHttps = builder.useHttps;
 
  51         this.hostname = builder.hostname;
 
  52         this.port = builder.port;
 
  53         this.userName = builder.userName;
 
  54         this.password = builder.password;
 
  55         this.clientAuth = builder.clientAuth;
 
  56         this.isManaged = builder.isManaged;
 
  57         this.pdpGroup = builder.pdpGroup;
 
  60     public boolean isUseHttps() {
 
  64     public String getHostname() {
 
  68     public int getPort() {
 
  72     public String getUserName() {
 
  76     public String getPassword() {
 
  80     public String getClientAuth() {
 
  84     public boolean isManaged() {
 
  88     public String getPdpGroup() {
 
  93      * Builder for XacmlPdpPolicyForwarderParameterGroup.
 
  95     public static class XacmlPdpPolicyForwarderParameterGroupBuilder {
 
  96         private boolean useHttps = false;
 
  97         private String hostname;
 
  99         private String userName;
 
 100         private String password;
 
 101         private String clientAuth;
 
 102         private boolean isManaged = true;
 
 103         private String pdpGroup;
 
 105         public XacmlPdpPolicyForwarderParameterGroupBuilder setUseHttps(final boolean useHttps) {
 
 106             this.useHttps = useHttps;
 
 110         public XacmlPdpPolicyForwarderParameterGroupBuilder setHostname(final String hostname) {
 
 111             this.hostname = hostname;
 
 115         public XacmlPdpPolicyForwarderParameterGroupBuilder setPort(final int port) {
 
 120         public XacmlPdpPolicyForwarderParameterGroupBuilder setUserName(final String userName) {
 
 121             this.userName = userName;
 
 125         public XacmlPdpPolicyForwarderParameterGroupBuilder setPassword(final String password) {
 
 126             this.password = password;
 
 130         public XacmlPdpPolicyForwarderParameterGroupBuilder setClientAuth(final String clientAuth) {
 
 131             this.clientAuth = clientAuth;
 
 135         public XacmlPdpPolicyForwarderParameterGroupBuilder setIsManaged(final boolean isManaged) {
 
 136             this.isManaged = isManaged;
 
 140         public XacmlPdpPolicyForwarderParameterGroupBuilder setPdpGroup(final String pdpGroup) {
 
 141             this.pdpGroup = pdpGroup;
 
 146          * Creates a new XacmlPapServletPolicyForwarderParameterGroup instance.
 
 148         public XacmlPdpPolicyForwarderParameterGroup build() {
 
 149             return new XacmlPdpPolicyForwarderParameterGroup(this);
 
 154     public GroupValidationResult validate() {
 
 155         final GroupValidationResult validationResult = new GroupValidationResult(this);
 
 156         if (!ParameterValidationUtils.validateStringParameter(hostname)) {
 
 157             validationResult.setResult("hostname", ValidationStatus.INVALID,
 
 158                     "must be a non-blank string containing hostname/ipaddress");
 
 160         if (!ParameterValidationUtils.validateIntParameter(port)) {
 
 161             validationResult.setResult("port", ValidationStatus.INVALID, "must be a positive integer containing port");
 
 163         if (!ParameterValidationUtils.validateStringParameter(userName)) {
 
 164             validationResult.setResult("userName", ValidationStatus.INVALID,
 
 165                     "must be a non-blank string containing userName");
 
 167         if (!ParameterValidationUtils.validateStringParameter(password)) {
 
 168             validationResult.setResult("password", ValidationStatus.INVALID,
 
 169                     "must be a non-blank string containing password");
 
 171         if (!ParameterValidationUtils.validateStringParameter(clientAuth)) {
 
 172             validationResult.setResult("clientAuth", ValidationStatus.INVALID,
 
 173                     "must be a non-blank string containing clientAuth");
 
 175         if (!ParameterValidationUtils.validateStringParameter(pdpGroup)) {
 
 176             validationResult.setResult("pdpGroup", ValidationStatus.INVALID,
 
 177                     "must be a non-blank string containing pdpGroup");
 
 179         return validationResult;