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.k8s;
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.ArtifactForwarderConfigurationParameterGroup;
29 * Holds the parameters for the{@link K8sArtifactForwarder}.
31 public class K8sArtifactForwarderParameterGroup extends ArtifactForwarderConfigurationParameterGroup {
32 public static final String POLICY_FORWARDER_PLUGIN_CLASS = K8sArtifactForwarder.class.getCanonicalName();
34 private boolean useHttps;
35 private String hostname;
37 private String userName;
38 private String password;
39 private String clientAuth;
40 private boolean isManaged;
41 private String pdpGroup;
44 * Construct an instance.
46 * @param builder the builder create the instance from
48 private K8sArtifactForwarderParameterGroup(final K8sArtifactForwarderParameterGroupBuilder builder) {
49 this.useHttps = builder.useHttps;
50 this.hostname = builder.hostname;
51 this.port = builder.port;
52 this.userName = builder.userName;
53 this.password = builder.password;
54 this.clientAuth = builder.clientAuth;
55 this.isManaged = builder.isManaged;
56 this.pdpGroup = builder.pdpGroup;
59 public boolean isUseHttps() {
63 public String getHostname() {
67 public int getPort() {
71 public String getUserName() {
75 public String getPassword() {
79 public String getClientAuth() {
83 public boolean isManaged() {
87 public String getPdpGroup() {
92 * Builder for K8sArtifactForwarderParameterGroup.
94 public static class K8sArtifactForwarderParameterGroupBuilder {
95 private boolean useHttps = false;
96 private String hostname;
98 private String userName;
99 private String password;
100 private String clientAuth;
101 private boolean isManaged = true;
102 private String pdpGroup;
104 public K8sArtifactForwarderParameterGroupBuilder setUseHttps(final boolean useHttps) {
105 this.useHttps = useHttps;
109 public K8sArtifactForwarderParameterGroupBuilder setHostname(final String hostname) {
110 this.hostname = hostname;
114 public K8sArtifactForwarderParameterGroupBuilder setPort(final int port) {
119 public K8sArtifactForwarderParameterGroupBuilder setUserName(final String userName) {
120 this.userName = userName;
124 public K8sArtifactForwarderParameterGroupBuilder setPassword(final String password) {
125 this.password = password;
129 public K8sArtifactForwarderParameterGroupBuilder setClientAuth(final String clientAuth) {
130 this.clientAuth = clientAuth;
134 public K8sArtifactForwarderParameterGroupBuilder setIsManaged(final boolean isManaged) {
135 this.isManaged = isManaged;
139 public K8sArtifactForwarderParameterGroupBuilder setPdpGroup(final String pdpGroup) {
140 this.pdpGroup = pdpGroup;
145 * Creates a new XacmlPapServletArtifactForwarderParameterGroup instance.
147 public K8sArtifactForwarderParameterGroup build() {
148 return new K8sArtifactForwarderParameterGroup(this);
153 public GroupValidationResult validate() {
154 final GroupValidationResult validationResult = new GroupValidationResult(this);
155 if (!ParameterValidationUtils.validateStringParameter(hostname)) {
156 validationResult.setResult("hostname", ValidationStatus.INVALID,
157 "must be a non-blank string containing hostname/ipaddress");
159 if (!ParameterValidationUtils.validateIntParameter(port)) {
160 validationResult.setResult("port", ValidationStatus.INVALID, "must be a positive integer containing port");
162 if (!ParameterValidationUtils.validateStringParameter(userName)) {
163 validationResult.setResult("userName", ValidationStatus.INVALID,
164 "must be a non-blank string containing userName");
166 if (!ParameterValidationUtils.validateStringParameter(password)) {
167 validationResult.setResult("password", ValidationStatus.INVALID,
168 "must be a non-blank string containing password");
170 if (!ParameterValidationUtils.validateStringParameter(clientAuth)) {
171 validationResult.setResult("clientAuth", ValidationStatus.INVALID,
172 "must be a non-blank string containing clientAuth");
174 if (!ParameterValidationUtils.validateStringParameter(pdpGroup)) {
175 validationResult.setResult("pdpGroup", ValidationStatus.INVALID,
176 "must be a non-blank string containing pdpGroup");
178 return validationResult;