2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 AT&T Intellectual Property. 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.pdpx.main.parameters;
23 import org.onap.policy.common.parameters.GroupValidationResult;
24 import org.onap.policy.common.parameters.ParameterGroup;
25 import org.onap.policy.common.parameters.ValidationStatus;
26 import org.onap.policy.common.utils.validation.ParameterValidationUtils;
29 * Class to hold all parameters needed for xacml pdp rest server.
32 public class RestServerParameters implements ParameterGroup {
36 private String userName;
37 private String password;
38 private boolean https;
42 * Constructor for instantiating RestServerParameters.
44 * @param builder the RestServer builder
46 public RestServerParameters(final RestServerBuilder builder) {
48 this.host = builder.getHost();
49 this.port = builder.getPort();
50 this.userName = builder.getUserName();
51 this.password = builder.getPassword();
52 this.https = builder.isHttps();
53 this.aaf = builder.isAaf();
57 * Return the name of this RestServerParameters instance.
59 * @return name the name of this RestServerParameters
62 public String getName() {
67 * Return the host of this RestServerParameters instance.
71 public String getHost() {
76 * Return the port of this RestServerParameters instance.
80 public int getPort() {
85 * Return the user name of this RestServerParameters instance.
87 * @return the userName
89 public String getUserName() {
94 * Return the password of this RestServerParameters instance.
96 * @return the password
98 public String getPassword() {
103 * Return the https flag of this RestServerParameters instance.
105 * @return the https flag
107 public boolean isHttps() {
112 * Return the aaf flag of this RestServerParameters instance.
114 * @return the aaf flag
116 public boolean isAaf() {
121 * Set the name of this RestServerParameters instance.
123 * @param name the name to set
126 public void setName(final String name) {
131 * Validate the rest server parameters.
133 * @return the result of the validation
136 public GroupValidationResult validate() {
137 final GroupValidationResult validationResult = new GroupValidationResult(this);
138 if (!ParameterValidationUtils.validateStringParameter(host)) {
139 validationResult.setResult("host", ValidationStatus.INVALID,
140 "must be a non-blank string containing hostname/ipaddress of the xacml pdp rest server");
142 if (!ParameterValidationUtils.validateStringParameter(userName)) {
143 validationResult.setResult("userName", ValidationStatus.INVALID,
144 "must be a non-blank string containing userName for xacml pdp rest server credentials");
146 if (!ParameterValidationUtils.validateStringParameter(password)) {
147 validationResult.setResult("password", ValidationStatus.INVALID,
148 "must be a non-blank string containing password for xacml pdp rest server credentials");
150 if (!ParameterValidationUtils.validateIntParameter(port)) {
151 validationResult.setResult("port", ValidationStatus.INVALID,
152 "must be a positive integer containing port of the xacml pdp rest server");
154 return validationResult;