diff options
Diffstat (limited to 'src/main/java')
7 files changed, 81 insertions, 36 deletions
diff --git a/src/main/java/org/onap/aai/auth/AAIMicroServiceAuth.java b/src/main/java/org/onap/aai/auth/AAIMicroServiceAuth.java index 8181b43..41306b2 100644 --- a/src/main/java/org/onap/aai/auth/AAIMicroServiceAuth.java +++ b/src/main/java/org/onap/aai/auth/AAIMicroServiceAuth.java @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * org.onap.aai * ================================================================================ - * Copyright ?? 2018-2019 AT&T Intellectual Property. All rights reserved. - * Copyright ?? 2018-2019 European Software Marketing Ltd. + * Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2018-2019 European Software Marketing Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ public class AAIMicroServiceAuth { /** * @param validationServiceAuthConfig * @throws AAIAuthException - * if the policy file cannot be loaded + * if the policy file cannot be loaded */ @Inject public AAIMicroServiceAuth(final ValidationServiceAuthConfig validationServiceAuthConfig) throws AAIAuthException { @@ -49,10 +49,33 @@ public class AAIMicroServiceAuth { } } + /** + * Check whether the given user may access the give function. + * + * @param username + * user to be authorized + * @param authFunction + * function the user wishes to access + * @return true if the user is authorized to access the function, false otherwsie + * @throws AAIAuthException + * if the auth object has not been initialized + */ public boolean authBasic(String username, String authFunction) throws AAIAuthException { return authCore.authorize(username, authFunction); } + + /** + * Check whether the given user may access the give function. + * + * @param username + * user to be authorized + * @param authFunction + * function the user wishes to access + * @return true if the user is authorized to access the function, false otherwsie + * @throws AAIAuthException + * if the auth object has not been initialized + */ public String authUser(String authUser, String authFunction) throws AAIAuthException { StringBuilder username = new StringBuilder(); diff --git a/src/main/java/org/onap/aai/auth/AAIMicroServiceAuthCore.java b/src/main/java/org/onap/aai/auth/AAIMicroServiceAuthCore.java index 681d0ea..63c1d6e 100644 --- a/src/main/java/org/onap/aai/auth/AAIMicroServiceAuthCore.java +++ b/src/main/java/org/onap/aai/auth/AAIMicroServiceAuthCore.java @@ -63,7 +63,8 @@ public class AAIMicroServiceAuthCore { /** * @param authPolicyFile - * @throws AAIAuthException if the policy file cannot be loaded + * @throws AAIAuthException + * if the policy file cannot be loaded */ public void init(String authPolicyFile) throws AAIAuthException { try { @@ -218,6 +219,17 @@ public class AAIMicroServiceAuthCore { } } + /** + * Check whether the given user may access the give function. + * + * @param username + * user to be authorized + * @param authFunction + * function the user wishes to access + * @return true if the user is authorized to access the function, false otherwsie + * @throws AAIAuthException + * of the auth object has not been initialized + */ public boolean authorize(String username, String authFunction) throws AAIAuthException { if (!usersInitialized || users == null) { throw new AAIAuthException("Auth module not initialized"); diff --git a/src/main/java/org/onap/aai/validation/config/TopicConfig.java b/src/main/java/org/onap/aai/validation/config/TopicConfig.java index f95a357..0db4e8e 100644 --- a/src/main/java/org/onap/aai/validation/config/TopicConfig.java +++ b/src/main/java/org/onap/aai/validation/config/TopicConfig.java @@ -1,19 +1,22 @@ -/* - * ============LICENSE_START=================================================== +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved. * Copyright (c) 2018-2019 European Software Marketing Ltd. - * ============================================================================ + * ================================================================================ * 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 + * 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. - * ============LICENSE_END===================================================== + * ============LICENSE_END========================================================= */ package org.onap.aai.validation.config; @@ -31,11 +34,9 @@ import org.springframework.beans.factory.annotation.Value; /** * Gets the configuration of the topics using Spring. */ - public class TopicConfig { private List<String> consumerTopicNames; - private List<String> publisherTopicNames; @Resource(name = "topicProperties") @@ -60,7 +61,6 @@ public class TopicConfig { return populateTopics(consumerTopics, consumerTopicNames); } - /** * Gets the configuration of topics for publishing. * @@ -74,9 +74,9 @@ public class TopicConfig { * Populates the topics list with topic objects created from each item in the topicNames list. * * @param topics - * The topic list to populate. + * The topic list to populate. * @param topicNames - * The list of topic names to populate the topic list with. + * The list of topic names to populate the topic list with. * @return The populated topic list. */ private List<Topic> populateTopics(List<Topic> topics, List<String> topicNames) { diff --git a/src/main/java/org/onap/aai/validation/factory/DMaaPEventPublisherFactory.java b/src/main/java/org/onap/aai/validation/factory/DMaaPEventPublisherFactory.java index 2990e31..518752a 100644 --- a/src/main/java/org/onap/aai/validation/factory/DMaaPEventPublisherFactory.java +++ b/src/main/java/org/onap/aai/validation/factory/DMaaPEventPublisherFactory.java @@ -18,12 +18,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.onap.aai.validation.factory; import org.onap.aai.event.client.DMaaPEventPublisher; -public class DMaaPEventPublisherFactory { +public class DMaaPEventPublisherFactory { public DMaaPEventPublisher createEventPublisher(String topicHost, String topicName, String topicUsername, String topicPassword, String transportType, String protocol) { diff --git a/src/main/java/org/onap/aai/validation/publisher/ValidationEventPublisher.java b/src/main/java/org/onap/aai/validation/publisher/ValidationEventPublisher.java index 4b0b583..71ebadb 100644 --- a/src/main/java/org/onap/aai/validation/publisher/ValidationEventPublisher.java +++ b/src/main/java/org/onap/aai/validation/publisher/ValidationEventPublisher.java @@ -36,7 +36,7 @@ import org.onap.aai.validation.logging.ApplicationMsgs; import org.onap.aai.validation.logging.LogHelper; /** - * Event Publisher + * Event Publisher. * */ public class ValidationEventPublisher implements MessagePublisher { diff --git a/src/main/java/org/onap/aai/validation/ruledriven/rule/GroovyRule.java b/src/main/java/org/onap/aai/validation/ruledriven/rule/GroovyRule.java index d8cd61e..93902c0 100644 --- a/src/main/java/org/onap/aai/validation/ruledriven/rule/GroovyRule.java +++ b/src/main/java/org/onap/aai/validation/ruledriven/rule/GroovyRule.java @@ -70,13 +70,15 @@ public class GroovyRule implements Rule { /** * @param ruleConfig + * @throws GroovyConfigurationException + * if the Groovy expression cannot be compiled + * @throws IOException + * if the Groovy class loader throws an internal exception * @throws InstantiationException * @throws IllegalAccessException - * @throws IOException - * @throws GroovyConfigurationException */ public GroovyRule(RuleSection ruleConfig) - throws InstantiationException, IllegalAccessException, IOException, GroovyConfigurationException { + throws GroovyConfigurationException, IOException, InstantiationException, IllegalAccessException { setName(ruleConfig.getName()); setErrorCategory(ruleConfig.getCategory()); setErrorMessage(ruleConfig.getErrorMessage()); @@ -142,7 +144,8 @@ public class GroovyRule implements Rule { * * @param values * - * @param groovyObject an instance/object of a Groovy class that implements one or more rule methods + * @param groovyObject + * an instance/object of a Groovy class that implements one or more rule methods * @return the result of evaluating the expression */ @Override @@ -222,20 +225,26 @@ public class GroovyRule implements Rule { } /** - * @param fields + * Create an anonymous Java Class implementing a Groovy Rule method for the supplied attributes and rule expression. + * + * @param attributes + * the attributes that form the parameters of the Groovy method * @param expression - * @return - * @throws IOException + * a valid Groovy method expression (implementing a rule) + * @return the Java Class for accessing the Groovy method * @throws GroovyConfigurationException + * if the Groovy expression cannot be compiled + * @throws IOException + * if the Groovy class loader throws an internal exception */ - private Class<?> createRule(List<String> fields, String expression) - throws IOException, GroovyConfigurationException { + private Class<?> createRule(List<String> attributes, String expression) + throws GroovyConfigurationException, IOException { originalExpression = expression; groovyExpression = expression; String methodParams = ""; int i = 1; - for (String attribute : fields) { + for (String attribute : attributes) { if (isValidAttributeName(attribute)) { String fieldName = "field" + i++; methodParams = appendParameter(methodParams, fieldName); @@ -295,20 +304,23 @@ public class GroovyRule implements Rule { } /** - * Load and parse a Groovy script to create an anonymous class + * Load and parse a Groovy script to create an anonymous Java Class. * - * @param script a file containing the Groovy scripting language - * @return the Java Class for accessing the Groovy methods - * @throws IOException + * @param script + * valid Groovy content (for the class) + * @return the Java Class for accessing the Groovy script * @throws GroovyConfigurationException + * if the Groovy script cannot be compiled + * @throws IOException + * if the Groovy class loader throws an internal exception */ @SuppressWarnings("rawtypes") - private static Class loadGroovyClass(String expression) throws IOException, GroovyConfigurationException { + private static Class loadGroovyClass(String script) throws GroovyConfigurationException, IOException { ClassLoader parent = GroovyRule.class.getClassLoader(); GroovyClassLoader loader = new GroovyClassLoader(parent); Class groovyClass; try { - groovyClass = loader.parseClass(expression); + groovyClass = loader.parseClass(script); } catch (CompilationFailedException e) { throw new GroovyConfigurationException(e); } finally { diff --git a/src/main/java/org/onap/aai/validation/services/EventPollingService.java b/src/main/java/org/onap/aai/validation/services/EventPollingService.java index bc0c260..332e283 100644 --- a/src/main/java/org/onap/aai/validation/services/EventPollingService.java +++ b/src/main/java/org/onap/aai/validation/services/EventPollingService.java @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * org.onap.aai * ================================================================================ - * Copyright © 2018-2019 AT&T Intellectual Property. All rights reserved. - * Copyright © 2018-2019 European Software Marketing Ltd. + * Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2018-2019 European Software Marketing Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.onap.aai.validation.services; import com.google.common.collect.Iterables; |