2  * ============LICENSE_START=======================================================
 
   3  *  Copyright (C) 2018 Ericsson. All rights reserved.
 
   4  * ================================================================================
 
   5  * Licensed under the Apache License, Version 2.0 (the "License");
 
   6  * you may not use this file except in compliance with the License.
 
   7  * You may obtain a copy of the License at
 
   9  *      http://www.apache.org/licenses/LICENSE-2.0
 
  11  * Unless required by applicable law or agreed to in writing, software
 
  12  * distributed under the License is distributed on an "AS IS" BASIS,
 
  13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  14  * See the License for the specific language governing permissions and
 
  15  * limitations under the License.
 
  17  * SPDX-License-Identifier: Apache-2.0
 
  18  * ============LICENSE_END=========================================================
 
  21 package org.onap.policy.distribution.forwarding.xacml.pdp;
 
  23 import org.onap.policy.common.parameters.GroupValidationResult;
 
  24 import org.onap.policy.common.parameters.ValidationStatus;
 
  25 import org.onap.policy.common.utils.validation.ParameterValidationUtils;
 
  26 import org.onap.policy.distribution.main.parameters.PolicyForwarderConfigurationParameterGroup;
 
  29  * Holds the parameters for the{@link XacmlPdpPolicyForwarder}
 
  31 public class XacmlPdpPolicyForwarderParameterGroup extends PolicyForwarderConfigurationParameterGroup {
 
  33     public static final String POLICY_FORWARDER_PLUGIN_CLASS = XacmlPdpPolicyForwarder.class.getCanonicalName();
 
  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;
 
  44     public boolean isUseHttps() {
 
  48     public String getHostname() {
 
  52     public int getPort() {
 
  56     public String getUserName() {
 
  60     public String getPassword() {
 
  64     public String getClientAuth() {
 
  68     public boolean isManaged() {
 
  72     public String getPdpGroup() {
 
  77      * Builder for XacmlPdpPolicyForwarderParameterGroup.
 
  79     public static class XacmlPdpPolicyForwarderParameterGroupBuilder {
 
  80         private boolean useHttps = false;
 
  81         private String hostname;
 
  83         private String userName;
 
  84         private String password;
 
  85         private String clientAuth;
 
  86         private boolean isManaged = true;
 
  87         private String pdpGroup;
 
  89         public XacmlPdpPolicyForwarderParameterGroupBuilder setUseHttps(final boolean useHttps) {
 
  90             this.useHttps = useHttps;
 
  94         public XacmlPdpPolicyForwarderParameterGroupBuilder setHostname(final String hostname) {
 
  95             this.hostname = hostname;
 
  99         public XacmlPdpPolicyForwarderParameterGroupBuilder setPort(final int port) {
 
 104         public XacmlPdpPolicyForwarderParameterGroupBuilder setUserName(final String userName) {
 
 105             this.userName = userName;
 
 109         public XacmlPdpPolicyForwarderParameterGroupBuilder setPassword(final String password) {
 
 110             this.password = password;
 
 114         public XacmlPdpPolicyForwarderParameterGroupBuilder setClientAuth(final String clientAuth) {
 
 115             this.clientAuth = clientAuth;
 
 119         public XacmlPdpPolicyForwarderParameterGroupBuilder setIsManaged(final boolean isManaged) {
 
 120             this.isManaged = isManaged;
 
 124         public XacmlPdpPolicyForwarderParameterGroupBuilder setPdpGroup(final String pdpGroup) {
 
 125             this.pdpGroup = pdpGroup;
 
 130          * Creates a new XacmlPapServletPolicyForwarderParameterGroup instance.
 
 132         public XacmlPdpPolicyForwarderParameterGroup build() {
 
 133             return new XacmlPdpPolicyForwarderParameterGroup(this);
 
 138      * Construct an instance
 
 140      * @param builder the builder create the instance from
 
 142     private XacmlPdpPolicyForwarderParameterGroup(final XacmlPdpPolicyForwarderParameterGroupBuilder builder) {
 
 143         this.useHttps = builder.useHttps;
 
 144         this.hostname = builder.hostname;
 
 145         this.port = builder.port;
 
 146         this.userName = builder.userName;
 
 147         this.password = builder.password;
 
 148         this.clientAuth = builder.clientAuth;
 
 149         this.isManaged = builder.isManaged;
 
 150         this.pdpGroup = builder.pdpGroup;
 
 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;