diff options
Diffstat (limited to 'plugins/forwarding-plugins/src/main/java')
7 files changed, 148 insertions, 392 deletions
diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarderParameterBuilder.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarderParameterBuilder.java deleted file mode 100644 index faa066fe..00000000 --- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarderParameterBuilder.java +++ /dev/null @@ -1,111 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.distribution.forwarding.apex.pdp; - -/** - * This builder holds all the parameters needed to build an instance of {@link ApexPdpPolicyForwarderParameterGroup} - * class. - * - * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com) - */ -public class ApexPdpPolicyForwarderParameterBuilder { - - private String hostname; - private int port; - private boolean ignoreConflicts; - private boolean forceUpdate; - - /** - * Set host name to this {@link ApexPdpPolicyForwarderParameterBuilder} instance. - * - * @param hostname the host name - */ - public ApexPdpPolicyForwarderParameterBuilder setHostname(final String hostname) { - this.hostname = hostname; - return this; - } - - /** - * Set port to this {@link ApexPdpPolicyForwarderParameterBuilder} instance. - * - * @param port the port number - */ - public ApexPdpPolicyForwarderParameterBuilder setPort(final int port) { - this.port = port; - return this; - } - - /** - * Set ignore conflicts flag to this {@link ApexPdpPolicyForwarderParameterBuilder} instance. - * - * @param ignoreConflicts the ignore conflicts flag - */ - public ApexPdpPolicyForwarderParameterBuilder setIgnoreConflicts(final boolean ignoreConflicts) { - this.ignoreConflicts = ignoreConflicts; - return this; - } - - /** - * Set force update flag to this {@link ApexPdpPolicyForwarderParameterBuilder} instance. - * - * @param forceUpdate the force update flag - */ - public ApexPdpPolicyForwarderParameterBuilder setForceUpdate(final boolean forceUpdate) { - this.forceUpdate = forceUpdate; - return this; - } - - /** - * Returns the host name of this {@link ApexPdpPolicyForwarderParameterBuilder} instance. - * - * @return the host name - */ - public String getHostname() { - return hostname; - } - - /** - * Returns the port of this {@link ApexPdpPolicyForwarderParameterBuilder} instance. - * - * @return the port - */ - public int getPort() { - return port; - } - - /** - * Returns the ignore conflicts flag of this {@link ApexPdpPolicyForwarderParameterBuilder} instance. - * - * @return the ignoreConflicts - */ - public boolean isIgnoreConflicts() { - return ignoreConflicts; - } - - /** - * Returns the force update flag of this {@link ApexPdpPolicyForwarderParameterBuilder} instance. - * - * @return the forceUpdate - */ - public boolean isForceUpdate() { - return forceUpdate; - } -} diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarderParameterGroup.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarderParameterGroup.java index bd954d8f..77c98a2d 100644 --- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarderParameterGroup.java +++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarderParameterGroup.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,60 +22,29 @@ package org.onap.policy.distribution.forwarding.apex.pdp; -import org.onap.policy.common.parameters.GroupValidationResult; -import org.onap.policy.common.parameters.ValidationStatus; -import org.onap.policy.common.utils.validation.ParameterValidationUtils; +import lombok.Getter; + +import org.onap.policy.common.parameters.annotations.Min; +import org.onap.policy.common.parameters.annotations.NotBlank; +import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.distribution.main.parameters.PolicyForwarderConfigurationParameterGroup; /** * Holds the parameters for the{@link ApexPdpPolicyForwarder}. */ +@Getter +@NotNull +@NotBlank public class ApexPdpPolicyForwarderParameterGroup extends PolicyForwarderConfigurationParameterGroup { public static final String POLICY_FORWARDER_PLUGIN_CLASS = ApexPdpPolicyForwarder.class.getName(); private String hostname; + @Min(value = 1) private int port; private boolean ignoreConflicts; private boolean forceUpdate; - /** - * Constructor for instantiating {@link ApexPdpPolicyForwarderParameterGroup} class. - * - * @param builder the apex forwarder parameter builder - */ - public ApexPdpPolicyForwarderParameterGroup(final ApexPdpPolicyForwarderParameterBuilder builder) { - this.hostname = builder.getHostname(); - this.port = builder.getPort(); - this.ignoreConflicts = builder.isIgnoreConflicts(); - this.forceUpdate = builder.isForceUpdate(); - } - - public String getHostname() { - return hostname; - } - - public int getPort() { - return port; - } - - public boolean isIgnoreConflicts() { - return ignoreConflicts; - } - - public boolean isForceUpdate() { - return forceUpdate; - } - - @Override - public GroupValidationResult validate() { - final GroupValidationResult validationResult = new GroupValidationResult(this); - if (!ParameterValidationUtils.validateStringParameter(hostname)) { - validationResult.setResult("hostname", ValidationStatus.INVALID, - "must be a non-blank string containing hostname/ipaddress"); - } - if (!ParameterValidationUtils.validateIntParameter(port)) { - validationResult.setResult("port", ValidationStatus.INVALID, "must be a positive integer containing port"); - } - return validationResult; + public ApexPdpPolicyForwarderParameterGroup() { + super(ApexPdpPolicyForwarderParameterGroup.class.getSimpleName()); } } diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarderParameterBuilder.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarderParameterBuilder.java deleted file mode 100644 index f5281e6b..00000000 --- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarderParameterBuilder.java +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Intel Corp. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.distribution.forwarding.file; - -/** - * This builder holds all the parameters needed to build an instance of {@link FilePolicyForwarderParameterGroup} - * class. - */ -public class FilePolicyForwarderParameterBuilder { - - private String path; - private boolean verbose = false; - - /** - * Set path to this {@link FilePolicyForwarderParameterBuilder} instance. - * - * @param path the directory to store the policies - */ - public FilePolicyForwarderParameterBuilder setPath(final String path) { - this.path = path; - return this; - } - - - /** - * Set verbose flag to this {@link FilePolicyForwarderParameterBuilder} instance. - * - * @param verbose the verbose flag - */ - public FilePolicyForwarderParameterBuilder setVerbose(final boolean verbose) { - this.verbose = verbose; - return this; - } - - /** - * Returns the path of this {@link FilePolicyForwarderParameterBuilder} instance. - * - * @return the directory - */ - public String getPath() { - return path; - } - - /** - * Returns the verbose flag of this {@link FilePolicyForwarderParameterBuilder} instance. - * - * @return the verbose - */ - public boolean isVerbose() { - return verbose; - } -} diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarderParameterGroup.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarderParameterGroup.java index 79ab4f7f..e932d61c 100644 --- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarderParameterGroup.java +++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarderParameterGroup.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019 Intel Corp. All rights reserved. * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,45 +22,27 @@ package org.onap.policy.distribution.forwarding.file; -import org.onap.policy.common.parameters.GroupValidationResult; -import org.onap.policy.common.parameters.ValidationStatus; -import org.onap.policy.common.utils.validation.ParameterValidationUtils; +import lombok.Getter; +import lombok.Setter; + +import org.onap.policy.common.parameters.annotations.NotBlank; +import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.distribution.main.parameters.PolicyForwarderConfigurationParameterGroup; /** * Holds the parameters for the{@link FilePolicyForwarder}. */ +@Getter +@Setter +@NotNull +@NotBlank public class FilePolicyForwarderParameterGroup extends PolicyForwarderConfigurationParameterGroup { public static final String POLICY_FORWARDER_PLUGIN_CLASS = FilePolicyForwarder.class.getName(); private String path; private boolean verbose; - /** - * Constructor for instantiating {@link FilePolicyForwarderParameterGroup} class. - * - * @param builder the apex forwarder parameter builder - */ - public FilePolicyForwarderParameterGroup(final FilePolicyForwarderParameterBuilder builder) { - this.path = builder.getPath(); - this.verbose = builder.isVerbose(); - } - - public String getPath() { - return path; - } - - public boolean isVerbose() { - return verbose; - } - - @Override - public GroupValidationResult validate() { - final GroupValidationResult validationResult = new GroupValidationResult(this); - if (!ParameterValidationUtils.validateStringParameter(path)) { - validationResult.setResult("path", ValidationStatus.INVALID, - "must be a non-blank string containing path directory"); - } - return validationResult; + public FilePolicyForwarderParameterGroup() { + super(FilePolicyForwarderParameterGroup.class.getSimpleName()); } } diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java new file mode 100644 index 00000000..4b8acb10 --- /dev/null +++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.distribution.forwarding.lifecycle.api; + +import java.util.Collection; + +import org.onap.policy.common.parameters.ParameterService; +import org.onap.policy.distribution.forwarding.PolicyForwarder; +import org.onap.policy.distribution.forwarding.PolicyForwardingException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity; + +/** + * This class provides an implementation of {@link PolicyForwarder} interface for forwarding the given policies & policy + * types to the life cycle api's of policy framework. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +public class LifecycleApiPolicyForwarder implements PolicyForwarder { + + private LifecycleApiPolicyForwarderParameterGroup forwarderParameters; + + /** + * {@inheritDoc}. + */ + @Override + public void configure(final String parameterGroupName) { + forwarderParameters = ParameterService.get(parameterGroupName); + } + + /** + * {@inheritDoc}. + */ + @Override + public void forward(final Collection<ToscaEntity> policies) throws PolicyForwardingException { + // TODO: add implementation + } + +} + diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarderParameterGroup.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarderParameterGroup.java new file mode 100644 index 00000000..8ba7bdbe --- /dev/null +++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarderParameterGroup.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.distribution.forwarding.lifecycle.api; + +import lombok.Getter; + +import org.onap.policy.common.parameters.annotations.Min; +import org.onap.policy.common.parameters.annotations.NotBlank; +import org.onap.policy.common.parameters.annotations.NotNull; +import org.onap.policy.distribution.main.parameters.PolicyForwarderConfigurationParameterGroup; + +/** + * Holds the parameters for the{@link LifecycleApiPolicyForwarder}. + */ +@Getter +@NotNull +@NotBlank +public class LifecycleApiPolicyForwarderParameterGroup extends PolicyForwarderConfigurationParameterGroup { + public static final String POLICY_FORWARDER_PLUGIN_CLASS = LifecycleApiPolicyForwarder.class.getName(); + + private String policyApiHostName; + @Min(value = 1) + private int policyApiPort; + private String policyApiUserName; + private String policyApiPassword; + private String policyPapHostName; + @Min(value = 1) + private int policyPapPort; + private String policyPapUserName; + private String policyPapPassword; + private boolean isHttps; + private boolean deployPolicies = true; + + public LifecycleApiPolicyForwarderParameterGroup() { + super(LifecycleApiPolicyForwarderParameterGroup.class.getSimpleName()); + } +} diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpPolicyForwarderParameterGroup.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpPolicyForwarderParameterGroup.java index 5c547673..4ce35f20 100644 --- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpPolicyForwarderParameterGroup.java +++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpPolicyForwarderParameterGroup.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,19 +22,25 @@ package org.onap.policy.distribution.forwarding.xacml.pdp; -import org.onap.policy.common.parameters.GroupValidationResult; -import org.onap.policy.common.parameters.ValidationStatus; -import org.onap.policy.common.utils.validation.ParameterValidationUtils; +import lombok.Getter; + +import org.onap.policy.common.parameters.annotations.Min; +import org.onap.policy.common.parameters.annotations.NotBlank; +import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.distribution.main.parameters.PolicyForwarderConfigurationParameterGroup; /** * Holds the parameters for the{@link XacmlPdpPolicyForwarder}. */ +@Getter +@NotNull +@NotBlank public class XacmlPdpPolicyForwarderParameterGroup extends PolicyForwarderConfigurationParameterGroup { public static final String POLICY_FORWARDER_PLUGIN_CLASS = XacmlPdpPolicyForwarder.class.getName(); private boolean useHttps; private String hostname; + @Min(value = 1) private int port; private String userName; private String password; @@ -41,142 +48,7 @@ public class XacmlPdpPolicyForwarderParameterGroup extends PolicyForwarderConfig private boolean isManaged; private String pdpGroup; - /** - * Construct an instance. - * - * @param builder the builder create the instance from - */ - private XacmlPdpPolicyForwarderParameterGroup(final XacmlPdpPolicyForwarderParameterGroupBuilder builder) { - this.useHttps = builder.useHttps; - this.hostname = builder.hostname; - this.port = builder.port; - this.userName = builder.userName; - this.password = builder.password; - this.clientAuth = builder.clientAuth; - this.isManaged = builder.isManaged; - this.pdpGroup = builder.pdpGroup; - } - - public boolean isUseHttps() { - return useHttps; - } - - public String getHostname() { - return hostname; - } - - public int getPort() { - return port; - } - - public String getUserName() { - return userName; - } - - public String getPassword() { - return password; - } - - public String getClientAuth() { - return clientAuth; - } - - public boolean isManaged() { - return isManaged; + public XacmlPdpPolicyForwarderParameterGroup() { + super(XacmlPdpPolicyForwarderParameterGroup.class.getSimpleName()); } - - public String getPdpGroup() { - return pdpGroup; - } - - /** - * Builder for XacmlPdpPolicyForwarderParameterGroup. - */ - public static class XacmlPdpPolicyForwarderParameterGroupBuilder { - private boolean useHttps = false; - private String hostname; - private int port; - private String userName; - private String password; - private String clientAuth; - private boolean isManaged = true; - private String pdpGroup; - - public XacmlPdpPolicyForwarderParameterGroupBuilder setUseHttps(final boolean useHttps) { - this.useHttps = useHttps; - return this; - } - - public XacmlPdpPolicyForwarderParameterGroupBuilder setHostname(final String hostname) { - this.hostname = hostname; - return this; - } - - public XacmlPdpPolicyForwarderParameterGroupBuilder setPort(final int port) { - this.port = port; - return this; - } - - public XacmlPdpPolicyForwarderParameterGroupBuilder setUserName(final String userName) { - this.userName = userName; - return this; - } - - public XacmlPdpPolicyForwarderParameterGroupBuilder setPassword(final String password) { - this.password = password; - return this; - } - - public XacmlPdpPolicyForwarderParameterGroupBuilder setClientAuth(final String clientAuth) { - this.clientAuth = clientAuth; - return this; - } - - public XacmlPdpPolicyForwarderParameterGroupBuilder setIsManaged(final boolean isManaged) { - this.isManaged = isManaged; - return this; - } - - public XacmlPdpPolicyForwarderParameterGroupBuilder setPdpGroup(final String pdpGroup) { - this.pdpGroup = pdpGroup; - return this; - } - - /** - * Creates a new XacmlPapServletPolicyForwarderParameterGroup instance. - */ - public XacmlPdpPolicyForwarderParameterGroup build() { - return new XacmlPdpPolicyForwarderParameterGroup(this); - } - } - - @Override - public GroupValidationResult validate() { - final GroupValidationResult validationResult = new GroupValidationResult(this); - if (!ParameterValidationUtils.validateStringParameter(hostname)) { - validationResult.setResult("hostname", ValidationStatus.INVALID, - "must be a non-blank string containing hostname/ipaddress"); - } - if (!ParameterValidationUtils.validateIntParameter(port)) { - validationResult.setResult("port", ValidationStatus.INVALID, "must be a positive integer containing port"); - } - if (!ParameterValidationUtils.validateStringParameter(userName)) { - validationResult.setResult("userName", ValidationStatus.INVALID, - "must be a non-blank string containing userName"); - } - if (!ParameterValidationUtils.validateStringParameter(password)) { - validationResult.setResult("password", ValidationStatus.INVALID, - "must be a non-blank string containing password"); - } - if (!ParameterValidationUtils.validateStringParameter(clientAuth)) { - validationResult.setResult("clientAuth", ValidationStatus.INVALID, - "must be a non-blank string containing clientAuth"); - } - if (!ParameterValidationUtils.validateStringParameter(pdpGroup)) { - validationResult.setResult("pdpGroup", ValidationStatus.INVALID, - "must be a non-blank string containing pdpGroup"); - } - return validationResult; - } - } |