Fix formatting in the dashboard
Change-Id: I3e7718fee18e38697aa1ac4ac1f08d6aee499d92
Signed-off-by: RehanRaza <muhammad.rehan.raza@est.tech>
diff --git a/dashboard/webapp-backend/eclipse-formatter.xml b/dashboard/webapp-backend/eclipse-formatter.xml
new file mode 100644
index 0000000..7339434
--- /dev/null
+++ b/dashboard/webapp-backend/eclipse-formatter.xml
@@ -0,0 +1,315 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ * ========================LICENSE_START=================================
+ * O-RAN-SC
+ * %%
+ * 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.
+ * ========================LICENSE_END===================================
+ -->
+<profiles version="13">
+<profile kind="CodeFormatterProfile" name="java-formatter" version="12">
+<setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled"/>
+<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.8"/>
+<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.8"/>
+<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/>
+<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/>
+<setting id="org.eclipse.jdt.core.compiler.source" value="1.8"/>
+<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="48"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="2"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="120"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
+<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
+<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
+<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
+<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
+<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/>
+</profile>
+</profiles>
+
diff --git a/dashboard/webapp-backend/pom.xml b/dashboard/webapp-backend/pom.xml
index 80bb585..f089180 100644
--- a/dashboard/webapp-backend/pom.xml
+++ b/dashboard/webapp-backend/pom.xml
@@ -36,6 +36,8 @@
<properties>
<springfox.version>2.9.2</springfox.version>
<immutable.version>2.7.1</immutable.version>
+ <formatter-maven-plugin.version>2.8.1</formatter-maven-plugin.version>
+ <spotless-maven-plugin.version>1.18.0</spotless-maven-plugin.version>
<!-- Set by Jenkins -->
<build.number>0</build.number>
</properties>
@@ -176,6 +178,32 @@
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
+ <groupId>net.revelc.code.formatter</groupId>
+ <artifactId>formatter-maven-plugin</artifactId>
+ <version>${formatter-maven-plugin.version}</version>
+ <configuration>
+ <configFile>${project.basedir}/eclipse-formatter.xml</configFile>
+ </configuration>
+ <!-- https://code.revelc.net/formatter-maven-plugin/ use
+ mvn formatter:format spotless:apply process-sources -->
+ </plugin>
+ <plugin>
+ <groupId>com.diffplug.spotless</groupId>
+ <artifactId>spotless-maven-plugin</artifactId>
+ <version>${spotless-maven-plugin.version}</version>
+ <configuration>
+ <java>
+ <removeUnusedImports />
+ <importOrder>
+ <order>com,java,javax,org</order>
+ </importOrder>
+ </java>
+ </configuration>
+ <!-- https://github.com/diffplug/spotless/tree/master/plugin-maven
+ use mvn spotless:apply to rewrite source files use mvn spotless:check to
+ validate source files -->
+ </plugin>
+ <plugin>
<!-- Most configuration and all execution is inherited -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardApplication.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardApplication.java
index 333c532..2550b8e 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardApplication.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardApplication.java
@@ -7,9 +7,9 @@
* 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.
@@ -34,27 +34,27 @@
@ComponentScan("org.oransc.ric.portal.dashboard")
public class DashboardApplication {
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- public static void main(String[] args) throws IOException {
- SpringApplication.run(DashboardApplication.class, args);
- // Ensure this appears on the console by using level WARN
- logger.warn("main: version '{}' successful start",
- getImplementationVersion(MethodHandles.lookup().lookupClass()));
- }
+ public static void main(String[] args) throws IOException {
+ SpringApplication.run(DashboardApplication.class, args);
+ // Ensure this appears on the console by using level WARN
+ logger.warn("main: version '{}' successful start",
+ getImplementationVersion(MethodHandles.lookup().lookupClass()));
+ }
- /**
- * Gets version details for the specified class.
- *
- * @param clazz
- * Class to get the version
- *
- * @return the value of the MANIFEST.MF property Implementation-Version as
- * written by maven when packaged in a jar; 'unknown' otherwise.
- */
- public static String getImplementationVersion(Class<?> clazz) {
- String classPath = clazz.getResource(clazz.getSimpleName() + ".class").toString();
- return classPath.startsWith("jar") ? clazz.getPackage().getImplementationVersion() : "unknown-not-jar";
- }
+ /**
+ * Gets version details for the specified class.
+ *
+ * @param clazz
+ * Class to get the version
+ *
+ * @return the value of the MANIFEST.MF property Implementation-Version as
+ * written by maven when packaged in a jar; 'unknown' otherwise.
+ */
+ public static String getImplementationVersion(Class<?> clazz) {
+ String classPath = clazz.getResource(clazz.getSimpleName() + ".class").toString();
+ return classPath.startsWith("jar") ? clazz.getPackage().getImplementationVersion() : "unknown-not-jar";
+ }
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardConstants.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardConstants.java
index b82aa64..4b5d9a4 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardConstants.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardConstants.java
@@ -21,24 +21,24 @@
public abstract class DashboardConstants {
- private DashboardConstants() {
- // Sonar insists on hiding the constructor
- }
+ private DashboardConstants() {
+ // Sonar insists on hiding the constructor
+ }
- public static final String ENDPOINT_PREFIX = "/api";
- // Factor out method names used in multiple controllers
- public static final String VERSION_METHOD = "version";
- public static final String APP_NAME_AC = "AC";
- public static final String APP_NAME_MC = "MC";
- // The role names are defined by ONAP Portal.
- // The prefix "ROLE_" is required by Spring.
- // These are used in Java code annotations that require constants.
- public static final String ROLE_NAME_STANDARD = "Standard_User";
- public static final String ROLE_NAME_ADMIN = "System_Administrator";
- private static final String ROLE_PREFIX = "ROLE_";
- public static final String ROLE_ADMIN = ROLE_PREFIX + ROLE_NAME_ADMIN;
- public static final String ROLE_STANDARD = ROLE_PREFIX + ROLE_NAME_STANDARD;
- public static final String POLICY_CONTROLLER_USERNAME = "admin";
- public static final String POLICY_CONTROLLER_PASSWORD = "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U";
+ public static final String ENDPOINT_PREFIX = "/api";
+ // Factor out method names used in multiple controllers
+ public static final String VERSION_METHOD = "version";
+ public static final String APP_NAME_AC = "AC";
+ public static final String APP_NAME_MC = "MC";
+ // The role names are defined by ONAP Portal.
+ // The prefix "ROLE_" is required by Spring.
+ // These are used in Java code annotations that require constants.
+ public static final String ROLE_NAME_STANDARD = "Standard_User";
+ public static final String ROLE_NAME_ADMIN = "System_Administrator";
+ private static final String ROLE_PREFIX = "ROLE_";
+ public static final String ROLE_ADMIN = ROLE_PREFIX + ROLE_NAME_ADMIN;
+ public static final String ROLE_STANDARD = ROLE_PREFIX + ROLE_NAME_STANDARD;
+ public static final String POLICY_CONTROLLER_USERNAME = "admin";
+ public static final String POLICY_CONTROLLER_PASSWORD = "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U";
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardUserManager.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardUserManager.java
index c5fd101..ffb7396 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardUserManager.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardUserManager.java
@@ -7,9 +7,9 @@
* 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.
@@ -19,6 +19,11 @@
*/
package org.oransc.ric.portal.dashboard;
+import com.fasterxml.jackson.core.JsonGenerationException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
import java.io.File;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
@@ -33,152 +38,146 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.fasterxml.jackson.core.JsonGenerationException;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
/**
* Provides simple user-management services.
- *
+ *
* This first implementation serializes user details to a file.
- *
+ *
* TODO: migrate to a database.
*/
public class DashboardUserManager {
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- // This default value is only useful for development and testing.
- public static final String USER_FILE_PATH = "dashboard-users.json";
+ // This default value is only useful for development and testing.
+ public static final String USER_FILE_PATH = "dashboard-users.json";
- private final File userFile;
- private final List<EcompUser> users;
+ private final File userFile;
+ private final List<EcompUser> users;
- /**
- * Development/test-only constructor that uses default file path.
- *
- * @param clear
- * If true, start empty and remove any existing file.
- *
- * @throws IOException
- * On file error
- */
- public DashboardUserManager(boolean clear) throws IOException {
- this(USER_FILE_PATH);
- if (clear) {
- logger.debug("ctor: removing file {}", userFile.getAbsolutePath());
- File f = new File(DashboardUserManager.USER_FILE_PATH);
- if (f.exists())
- f.delete();
- users.clear();
- }
- }
+ /**
+ * Development/test-only constructor that uses default file path.
+ *
+ * @param clear
+ * If true, start empty and remove any existing file.
+ *
+ * @throws IOException
+ * On file error
+ */
+ public DashboardUserManager(boolean clear) throws IOException {
+ this(USER_FILE_PATH);
+ if (clear) {
+ logger.debug("ctor: removing file {}", userFile.getAbsolutePath());
+ File f = new File(DashboardUserManager.USER_FILE_PATH);
+ if (f.exists())
+ f.delete();
+ users.clear();
+ }
+ }
- /**
- * Constructur that accepts a file path
- *
- * @param userFilePath
- * File path
- * @throws IOException
- * If file cannot be read
- */
- public DashboardUserManager(final String userFilePath) throws IOException {
- logger.debug("ctor: userfile {}", userFilePath);
- if (userFilePath == null)
- throw new IllegalArgumentException("Missing or empty user file property");
- userFile = new File(userFilePath);
- logger.debug("ctor: managing users in file {}", userFile.getAbsolutePath());
- if (userFile.exists()) {
- final ObjectMapper mapper = new ObjectMapper();
- users = mapper.readValue(userFile, new TypeReference<List<EcompUser>>() {
- });
- } else {
- users = new ArrayList<>();
- }
- }
+ /**
+ * Constructur that accepts a file path
+ *
+ * @param userFilePath
+ * File path
+ * @throws IOException
+ * If file cannot be read
+ */
+ public DashboardUserManager(final String userFilePath) throws IOException {
+ logger.debug("ctor: userfile {}", userFilePath);
+ if (userFilePath == null)
+ throw new IllegalArgumentException("Missing or empty user file property");
+ userFile = new File(userFilePath);
+ logger.debug("ctor: managing users in file {}", userFile.getAbsolutePath());
+ if (userFile.exists()) {
+ final ObjectMapper mapper = new ObjectMapper();
+ users = mapper.readValue(userFile, new TypeReference<List<EcompUser>>() {});
+ } else {
+ users = new ArrayList<>();
+ }
+ }
- /**
- * Gets the current users.
- *
- * @return List of EcompUser objects, possibly empty
- */
- public List<EcompUser> getUsers() {
- return this.users;
- }
+ /**
+ * Gets the current users.
+ *
+ * @return List of EcompUser objects, possibly empty
+ */
+ public List<EcompUser> getUsers() {
+ return this.users;
+ }
- /**
- * Gets the user with the specified login Id
- *
- * @param loginId
- * Desired login Id
- * @return User object; null if Id is not known
- */
- public EcompUser getUser(String loginId) {
- for (EcompUser u : this.users) {
- if (u.getLoginId().equals(loginId)) {
- logger.debug("getUser: match on {}", loginId);
- return u;
- }
- }
- logger.debug("getUser: no match on {}", loginId);
- return null;
- }
+ /**
+ * Gets the user with the specified login Id
+ *
+ * @param loginId
+ * Desired login Id
+ * @return User object; null if Id is not known
+ */
+ public EcompUser getUser(String loginId) {
+ for (EcompUser u : this.users) {
+ if (u.getLoginId().equals(loginId)) {
+ logger.debug("getUser: match on {}", loginId);
+ return u;
+ }
+ }
+ logger.debug("getUser: no match on {}", loginId);
+ return null;
+ }
- private void saveUsers() throws JsonGenerationException, JsonMappingException, IOException {
- final ObjectMapper mapper = new ObjectMapper();
- mapper.writeValue(userFile, users);
- }
+ private void saveUsers() throws JsonGenerationException, JsonMappingException, IOException {
+ final ObjectMapper mapper = new ObjectMapper();
+ mapper.writeValue(userFile, users);
+ }
- /*
- * Allow at most one thread to create a user at one time.
- */
- public synchronized void createUser(EcompUser user) throws PortalAPIException {
- logger.debug("createUser: loginId is " + user.getLoginId());
- if (users.contains(user))
- throw new PortalAPIException("User exists: " + user.getLoginId());
- users.add(user);
- try {
- saveUsers();
- } catch (Exception ex) {
- throw new PortalAPIException("Save failed", ex);
- }
- }
+ /*
+ * Allow at most one thread to create a user at one time.
+ */
+ public synchronized void createUser(EcompUser user) throws PortalAPIException {
+ logger.debug("createUser: loginId is " + user.getLoginId());
+ if (users.contains(user))
+ throw new PortalAPIException("User exists: " + user.getLoginId());
+ users.add(user);
+ try {
+ saveUsers();
+ } catch (Exception ex) {
+ throw new PortalAPIException("Save failed", ex);
+ }
+ }
- /*
- * Allow at most one thread to modify a user at one time. We still have
- * last-edit-wins of course.
- */
- public synchronized void updateUser(String loginId, EcompUser user) throws PortalAPIException {
- logger.debug("editUser: loginId is " + loginId);
- int index = users.indexOf(user);
- if (index < 0)
- throw new PortalAPIException("User does not exist: " + user.getLoginId());
- users.remove(index);
- users.add(user);
- try {
- saveUsers();
- } catch (Exception ex) {
- throw new PortalAPIException("Save failed", ex);
- }
- }
+ /*
+ * Allow at most one thread to modify a user at one time. We still have
+ * last-edit-wins of course.
+ */
+ public synchronized void updateUser(String loginId, EcompUser user) throws PortalAPIException {
+ logger.debug("editUser: loginId is " + loginId);
+ int index = users.indexOf(user);
+ if (index < 0)
+ throw new PortalAPIException("User does not exist: " + user.getLoginId());
+ users.remove(index);
+ users.add(user);
+ try {
+ saveUsers();
+ } catch (Exception ex) {
+ throw new PortalAPIException("Save failed", ex);
+ }
+ }
- // Test infrastructure
- public static void main(String[] args) throws Exception {
- DashboardUserManager dum = new DashboardUserManager(false);
- EcompUser user = new EcompUser();
- user.setActive(true);
- user.setLoginId("demo");
- user.setFirstName("First");
- user.setLastName("Last");
- EcompRole role = new EcompRole();
- role.setId(1L);
- role.setName(DashboardConstants.ROLE_NAME_ADMIN);
- Set<EcompRole> roles = new HashSet<>();
- roles.add(role);
- user.setRoles(roles);
- dum.createUser(user);
- logger.debug("Created user {}", user);
- }
+ // Test infrastructure
+ public static void main(String[] args) throws Exception {
+ DashboardUserManager dum = new DashboardUserManager(false);
+ EcompUser user = new EcompUser();
+ user.setActive(true);
+ user.setLoginId("demo");
+ user.setFirstName("First");
+ user.setLastName("Last");
+ EcompRole role = new EcompRole();
+ role.setId(1L);
+ role.setName(DashboardConstants.ROLE_NAME_ADMIN);
+ Set<EcompRole> roles = new HashSet<>();
+ roles.add(role);
+ user.setRoles(roles);
+ dum.createUser(user);
+ logger.debug("Created user {}", user);
+ }
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/AdminConfiguration.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/AdminConfiguration.java
index 696d74f..8c646fe 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/AdminConfiguration.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/AdminConfiguration.java
@@ -38,21 +38,21 @@
@Profile("!test")
public class AdminConfiguration {
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- // Populated by the autowired constructor
- private final String userfile;
+ // Populated by the autowired constructor
+ private final String userfile;
- @Autowired
- public AdminConfiguration(@Value("${userfile}") final String userfile) {
- logger.debug("ctor userfile '{}'", userfile);
- this.userfile = userfile;
- }
+ @Autowired
+ public AdminConfiguration(@Value("${userfile}") final String userfile) {
+ logger.debug("ctor userfile '{}'", userfile);
+ this.userfile = userfile;
+ }
- @Bean
- // The bean (method) name must be globally unique
- public DashboardUserManager userManager() throws IOException {
- return new DashboardUserManager(userfile);
- }
+ @Bean
+ // The bean (method) name must be globally unique
+ public DashboardUserManager userManager() throws IOException {
+ return new DashboardUserManager(userfile);
+ }
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/PortalApiConfiguration.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/PortalApiConfiguration.java
index f318cad..520f27f 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/PortalApiConfiguration.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/PortalApiConfiguration.java
@@ -7,9 +7,9 @@
* 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.
@@ -34,24 +34,24 @@
@Profile("!test")
public class PortalApiConfiguration {
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- /**
- * Instantiates the EPSDK-FW servlet that implements the API called by Portal.
- * Needed because this app is not configured to scan the EPSDK-FW packages;
- * there's also a chance that Spring-Boot does not automatically
- * process @WebServlet annotations.
- *
- * @return Servlet registration bean for the Portal Rest API proxy servlet.
- */
- @Bean
- public ServletRegistrationBean<PortalRestAPIProxy> portalApiProxyServletBean() {
- logger.debug("portalApiProxyServletBean");
- PortalRestAPIProxy servlet = new PortalRestAPIProxy();
- final ServletRegistrationBean<PortalRestAPIProxy> servletBean = new ServletRegistrationBean<>(servlet,
- PortalApiConstants.API_PREFIX + "/*");
- servletBean.setName("PortalRestApiProxyServlet");
- return servletBean;
- }
+ /**
+ * Instantiates the EPSDK-FW servlet that implements the API called by Portal.
+ * Needed because this app is not configured to scan the EPSDK-FW packages;
+ * there's also a chance that Spring-Boot does not automatically
+ * process @WebServlet annotations.
+ *
+ * @return Servlet registration bean for the Portal Rest API proxy servlet.
+ */
+ @Bean
+ public ServletRegistrationBean<PortalRestAPIProxy> portalApiProxyServletBean() {
+ logger.debug("portalApiProxyServletBean");
+ PortalRestAPIProxy servlet = new PortalRestAPIProxy();
+ final ServletRegistrationBean<PortalRestAPIProxy> servletBean =
+ new ServletRegistrationBean<>(servlet, PortalApiConstants.API_PREFIX + "/*");
+ servletBean.setName("PortalRestApiProxyServlet");
+ return servletBean;
+ }
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/SpringContextCache.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/SpringContextCache.java
index 3a87782..a2f3d8f 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/SpringContextCache.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/SpringContextCache.java
@@ -30,15 +30,15 @@
@Component
public class SpringContextCache implements ApplicationContextAware {
- private static ApplicationContext applicationContext = null;
+ private static ApplicationContext applicationContext = null;
- @Override
- public void setApplicationContext(final ApplicationContext appContext) throws BeansException {
- applicationContext = appContext;
- }
+ @Override
+ public void setApplicationContext(final ApplicationContext appContext) throws BeansException {
+ applicationContext = appContext;
+ }
- public static ApplicationContext getApplicationContext() {
- return applicationContext;
- }
+ public static ApplicationContext getApplicationContext() {
+ return applicationContext;
+ }
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/SwaggerConfiguration.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/SwaggerConfiguration.java
index b4bb0a3..435414a 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/SwaggerConfiguration.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/SwaggerConfiguration.java
@@ -40,29 +40,29 @@
@EnableSwagger2
public class SwaggerConfiguration {
- /**
- * @return new Docket
- */
- @Bean
- public Docket api() {
- return new Docket(DocumentationType.SWAGGER_2).select() //
- .apis(RequestHandlerSelectors.basePackage(DashboardApplication.class.getPackage().getName())) //
- .paths(PathSelectors.any()) //
- .build() //
- .apiInfo(apiInfo());
- }
+ /**
+ * @return new Docket
+ */
+ @Bean
+ public Docket api() {
+ return new Docket(DocumentationType.SWAGGER_2).select() //
+ .apis(RequestHandlerSelectors.basePackage(DashboardApplication.class.getPackage().getName())) //
+ .paths(PathSelectors.any()) //
+ .build() //
+ .apiInfo(apiInfo());
+ }
- private ApiInfo apiInfo() {
- final String version = DashboardApplication.class.getPackage().getImplementationVersion();
- return new ApiInfoBuilder() //
- .title("RIC Dashboard backend") //
- .description("Proxies access to RIC services.")//
- .termsOfServiceUrl("Terms of service") //
- .contact(new Contact("RIC Dashboard Dev Team", //
- "http://no-docs-yet.org/", //
- "noreply@O-RAN-SC.org")) //
- .license("Apache 2.0 License").licenseUrl("http://www.apache.org/licenses/LICENSE-2.0") //
- .version(version == null ? "version not available" : version) //
- .build();
- }
+ private ApiInfo apiInfo() {
+ final String version = DashboardApplication.class.getPackage().getImplementationVersion();
+ return new ApiInfoBuilder() //
+ .title("RIC Dashboard backend") //
+ .description("Proxies access to RIC services.")//
+ .termsOfServiceUrl("Terms of service") //
+ .contact(new Contact("RIC Dashboard Dev Team", //
+ "http://no-docs-yet.org/", //
+ "noreply@O-RAN-SC.org")) //
+ .license("Apache 2.0 License").licenseUrl("http://www.apache.org/licenses/LICENSE-2.0") //
+ .version(version == null ? "version not available" : version) //
+ .build();
+ }
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/WebSecurityConfiguration.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/WebSecurityConfiguration.java
index 85a96d0..b43f8a9 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/WebSecurityConfiguration.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/WebSecurityConfiguration.java
@@ -26,6 +26,7 @@
import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;
import org.oransc.ric.portal.dashboard.DashboardUserManager;
+import org.oransc.ric.portal.dashboard.controller.PolicyController;
import org.oransc.ric.portal.dashboard.controller.SimpleErrorController;
import org.oransc.ric.portal.dashboard.portalapi.PortalAuthManager;
import org.oransc.ric.portal.dashboard.portalapi.PortalAuthenticationFilter;
@@ -43,7 +44,6 @@
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
import org.springframework.security.web.csrf.CookieCsrfTokenRepository;
-import org.oransc.ric.portal.dashboard.controller.PolicyController;
@Configuration
@EnableWebSecurity
@@ -51,77 +51,77 @@
@Profile("!test")
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- // Although constructor arguments are recommended over field injection,
- // this results in fewer lines of code.
- @Value("${portalapi.security}")
- private Boolean portalapiSecurity;
- @Value("${portalapi.appname}")
- private String appName;
- @Value("${portalapi.username}")
- private String userName;
- @Value("${portalapi.password}")
- private String password;
- @Value("${portalapi.decryptor}")
- private String decryptor;
- @Value("${portalapi.usercookie}")
- private String userCookie;
+ // Although constructor arguments are recommended over field injection,
+ // this results in fewer lines of code.
+ @Value("${portalapi.security}")
+ private Boolean portalapiSecurity;
+ @Value("${portalapi.appname}")
+ private String appName;
+ @Value("${portalapi.username}")
+ private String userName;
+ @Value("${portalapi.password}")
+ private String password;
+ @Value("${portalapi.decryptor}")
+ private String decryptor;
+ @Value("${portalapi.usercookie}")
+ private String userCookie;
- @Autowired
- DashboardUserManager userManager;
+ @Autowired
+ DashboardUserManager userManager;
- @Override
- protected void configure(HttpSecurity http) throws Exception {
- logger.debug("configure: portalapi.username {}", userName);
- // A chain of ".and()" always baffles me
- http.authorizeRequests().anyRequest().authenticated();
- http.headers().frameOptions().disable();
- http.csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse());
- http.addFilterBefore(portalAuthenticationFilterBean(), BasicAuthenticationFilter.class);
- }
+ @Override
+ protected void configure(HttpSecurity http) throws Exception {
+ logger.debug("configure: portalapi.username {}", userName);
+ // A chain of ".and()" always baffles me
+ http.authorizeRequests().anyRequest().authenticated();
+ http.headers().frameOptions().disable();
+ http.csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse());
+ http.addFilterBefore(portalAuthenticationFilterBean(), BasicAuthenticationFilter.class);
+ }
- /**
- * Resource paths that do not require authentication, especially including
- * Swagger-generated documentation.
- */
- public static final String[] OPEN_PATHS = { //
- "/v2/api-docs", //
- "/swagger-resources/**", //
- "/swagger-ui.html", //
- "/webjars/**", //
- PortalApiConstants.API_PREFIX + "/**", //
- PolicyController.CONTROLLER_PATH + "/" + PolicyController.VERSION_METHOD, //
- SimpleErrorController.ERROR_PATH };
+ /**
+ * Resource paths that do not require authentication, especially including
+ * Swagger-generated documentation.
+ */
+ public static final String[] OPEN_PATHS = { //
+ "/v2/api-docs", //
+ "/swagger-resources/**", //
+ "/swagger-ui.html", //
+ "/webjars/**", //
+ PortalApiConstants.API_PREFIX + "/**", //
+ PolicyController.CONTROLLER_PATH + "/" + PolicyController.VERSION_METHOD, //
+ SimpleErrorController.ERROR_PATH};
- @Override
- public void configure(WebSecurity web) throws Exception {
- // This disables Spring security, but not the app's filter.
- web.ignoring().antMatchers(OPEN_PATHS);
- }
+ @Override
+ public void configure(WebSecurity web) throws Exception {
+ // This disables Spring security, but not the app's filter.
+ web.ignoring().antMatchers(OPEN_PATHS);
+ }
- @Bean
- public PortalAuthManager portalAuthManagerBean()
- throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException,
- IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
- return new PortalAuthManager(appName, userName, password, decryptor, userCookie);
- }
+ @Bean
+ public PortalAuthManager portalAuthManagerBean()
+ throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException,
+ IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
+ return new PortalAuthManager(appName, userName, password, decryptor, userCookie);
+ }
- /*
- * If this is annotated with @Bean, it is created automatically AND REGISTERED,
- * and Spring processes annotations in the source of the class. However, the
- * filter is added in the chain apparently in the wrong order. Alternately, with
- * no @Bean and added to the chain up in the configure() method in the desired
- * order, the ignoring() matcher pattern configured above causes Spring to
- * bypass this filter, which seems to me means the filter participates
- * correctly.
- */
- public PortalAuthenticationFilter portalAuthenticationFilterBean()
- throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException,
- IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
- PortalAuthenticationFilter portalAuthenticationFilter = new PortalAuthenticationFilter(portalapiSecurity,
- portalAuthManagerBean(), this.userManager);
- return portalAuthenticationFilter;
- }
+ /*
+ * If this is annotated with @Bean, it is created automatically AND REGISTERED,
+ * and Spring processes annotations in the source of the class. However, the
+ * filter is added in the chain apparently in the wrong order. Alternately, with
+ * no @Bean and added to the chain up in the configure() method in the desired
+ * order, the ignoring() matcher pattern configured above causes Spring to
+ * bypass this filter, which seems to me means the filter participates
+ * correctly.
+ */
+ public PortalAuthenticationFilter portalAuthenticationFilterBean()
+ throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException,
+ IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
+ PortalAuthenticationFilter portalAuthenticationFilter =
+ new PortalAuthenticationFilter(portalapiSecurity, portalAuthManagerBean(), this.userManager);
+ return portalAuthenticationFilter;
+ }
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/CustomResponseEntityExceptionHandler.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/CustomResponseEntityExceptionHandler.java
index f5ecd10..52a51fb 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/CustomResponseEntityExceptionHandler.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/CustomResponseEntityExceptionHandler.java
@@ -7,9 +7,9 @@
* 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.
@@ -36,7 +36,7 @@
/**
* Catches certain exceptions. This controller advice factors out try-catch
* blocks in many controller methods.
- *
+ *
* Also see:<br>
* https://www.baeldung.com/exception-handling-for-rest-with-spring
* https://www.springboottutorial.com/spring-boot-exception-handling-for-rest-services
@@ -44,39 +44,39 @@
@ControllerAdvice
public class CustomResponseEntityExceptionHandler extends ResponseEntityExceptionHandler {
- // Superclass has "logger" that is exposed here, so use a different name
- private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ // Superclass has "logger" that is exposed here, so use a different name
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- /**
- * Logs the error and generates a JSON response when a REST controller method
- * takes a RestClientResponseException. This is thrown by the Http client when a
- * remote method returns a non-2xx code. All the controller methods are proxies
- * in that they just forward the request along to a remote system, so if that
- * remote system fails, return 502 plus some details about the failure, rather
- * than the generic 500 that Spring-Boot will return on an uncaught exception.
- *
- * Why 502? I quote: <blockquote>HTTP server received an invalid response from a
- * server it consulted when acting as a proxy or gateway.</blockquote>
- *
- * @param ex
- * The exception
- *
- * @param request
- * The original request
- *
- * @return A response entity with status code 502 plus some details in the body.
- */
- @ExceptionHandler({ RestClientResponseException.class })
- public final ResponseEntity<ErrorTransport> handleProxyMethodException(Exception ex, WebRequest request) {
- // Capture the full stack trace in the log.
- log.error("handleProxyMethodException: request {}, exception {}", request.getDescription(false), ex);
- if (ex instanceof HttpStatusCodeException) {
- HttpStatusCodeException hsce = (HttpStatusCodeException) ex;
- return new ResponseEntity<>(new ErrorTransport(hsce.getRawStatusCode(), hsce.getResponseBodyAsString(),
- ex.toString(), request.getDescription(false)), HttpStatus.BAD_GATEWAY);
- } else {
- return new ResponseEntity<>(new ErrorTransport(500, ex), HttpStatus.BAD_GATEWAY);
- }
- }
+ /**
+ * Logs the error and generates a JSON response when a REST controller method
+ * takes a RestClientResponseException. This is thrown by the Http client when a
+ * remote method returns a non-2xx code. All the controller methods are proxies
+ * in that they just forward the request along to a remote system, so if that
+ * remote system fails, return 502 plus some details about the failure, rather
+ * than the generic 500 that Spring-Boot will return on an uncaught exception.
+ *
+ * Why 502? I quote: <blockquote>HTTP server received an invalid response from a
+ * server it consulted when acting as a proxy or gateway.</blockquote>
+ *
+ * @param ex
+ * The exception
+ *
+ * @param request
+ * The original request
+ *
+ * @return A response entity with status code 502 plus some details in the body.
+ */
+ @ExceptionHandler({RestClientResponseException.class})
+ public final ResponseEntity<ErrorTransport> handleProxyMethodException(Exception ex, WebRequest request) {
+ // Capture the full stack trace in the log.
+ log.error("handleProxyMethodException: request {}, exception {}", request.getDescription(false), ex);
+ if (ex instanceof HttpStatusCodeException) {
+ HttpStatusCodeException hsce = (HttpStatusCodeException) ex;
+ return new ResponseEntity<>(new ErrorTransport(hsce.getRawStatusCode(), hsce.getResponseBodyAsString(),
+ ex.toString(), request.getDescription(false)), HttpStatus.BAD_GATEWAY);
+ } else {
+ return new ResponseEntity<>(new ErrorTransport(500, ex), HttpStatus.BAD_GATEWAY);
+ }
+ }
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/Html5PathsController.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/Html5PathsController.java
index 7fb6e67..5d80538 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/Html5PathsController.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/Html5PathsController.java
@@ -8,9 +8,9 @@
* 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.
@@ -39,30 +39,31 @@
@Controller
public class Html5PathsController {
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- /**
- * Forwards the browser to the index (main) page upon request of a known route.
- * This unfortunately requires duplication of the Angular route strings in the
- * path mappings on this method. Could switch to a regex pattern instead someday
- * if the routes change too often.
- *
- * https://stackoverflow.com/questions/44692781/configure-spring-boot-to-redirect-404-to-a-single-page-app
- *
- * @param request
- * HttpServletRequest
- * @param response
- * HttpServletResponse
- * @throws IOException
- * On error
- */
- @RequestMapping(method = { RequestMethod.OPTIONS, RequestMethod.GET }, //
- path = { "/policy", "/user" })
- public void forwardAngularRoutes(HttpServletRequest request, HttpServletResponse response) throws IOException {
- URL url = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), "/index.html");
- if (logger.isDebugEnabled())
- logger.debug("forwardAngularRoutes: {} redirected to {}", request.getRequestURI(), url);
- response.sendRedirect(url.toString());
- }
+ /**
+ * Forwards the browser to the index (main) page upon request of a known route.
+ * This unfortunately requires duplication of the Angular route strings in the
+ * path mappings on this method. Could switch to a regex pattern instead someday
+ * if the routes change too often.
+ *
+ * https://stackoverflow.com/questions/44692781/configure-spring-boot-to-redirect-404-to-a-single-page-app
+ *
+ * @param request
+ * HttpServletRequest
+ * @param response
+ * HttpServletResponse
+ * @throws IOException
+ * On error
+ */
+ @RequestMapping(
+ method = {RequestMethod.OPTIONS, RequestMethod.GET}, //
+ path = {"/policy", "/user"})
+ public void forwardAngularRoutes(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ URL url = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), "/index.html");
+ if (logger.isDebugEnabled())
+ logger.debug("forwardAngularRoutes: {} redirected to {}", request.getRequestURI(), url);
+ response.sendRedirect(url.toString());
+ }
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/PolicyController.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/PolicyController.java
index 529cd2a..5b90931 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/PolicyController.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/PolicyController.java
@@ -19,14 +19,16 @@
*/
package org.oransc.ric.portal.dashboard.controller;
-import java.lang.invoke.MethodHandles;
-
-import javax.servlet.http.HttpServletResponse;
-
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-import org.oransc.ric.portal.dashboard.DashboardApplication;
+import io.swagger.annotations.ApiOperation;
+
+import java.lang.invoke.MethodHandles;
+import java.util.Collection;
+
+import javax.servlet.http.HttpServletResponse;
+
import org.oransc.ric.portal.dashboard.DashboardConstants;
import org.oransc.ric.portal.dashboard.exceptions.HttpBadRequestException;
import org.oransc.ric.portal.dashboard.exceptions.HttpInternalServerErrorException;
@@ -34,7 +36,6 @@
import org.oransc.ric.portal.dashboard.exceptions.HttpNotImplementedException;
import org.oransc.ric.portal.dashboard.model.PolicyInstances;
import org.oransc.ric.portal.dashboard.model.PolicyTypes;
-import org.oransc.ric.portal.dashboard.model.SuccessTransport;
import org.oransc.ric.portal.dashboard.policyagentapi.PolicyAgentApi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,8 +53,6 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
-import java.util.Collection;
-import io.swagger.annotations.ApiOperation;
/**
* Proxies calls from the front end to the Policy agent API.
@@ -67,117 +66,117 @@
@RequestMapping(value = PolicyController.CONTROLLER_PATH, produces = MediaType.APPLICATION_JSON_VALUE)
public class PolicyController {
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- private static Gson gson = new GsonBuilder() //
- .serializeNulls() //
- .create(); //
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static Gson gson = new GsonBuilder() //
+ .serializeNulls() //
+ .create(); //
- // Publish paths in constants so tests are easy to write
- public static final String CONTROLLER_PATH = DashboardConstants.ENDPOINT_PREFIX + "/policy";
- // Endpoints
- public static final String VERSION_METHOD = DashboardConstants.VERSION_METHOD;
- public static final String POLICY_TYPES_METHOD = "policytypes";
- public static final String POLICY_TYPE_ID_NAME = "policy_type_id";
- public static final String POLICIES_NAME = "policies";
- public static final String POLICY_INSTANCE_ID_NAME = "policy_instance_id";
+ // Publish paths in constants so tests are easy to write
+ public static final String CONTROLLER_PATH = DashboardConstants.ENDPOINT_PREFIX + "/policy";
+ // Endpoints
+ public static final String VERSION_METHOD = DashboardConstants.VERSION_METHOD;
+ public static final String POLICY_TYPES_METHOD = "policytypes";
+ public static final String POLICY_TYPE_ID_NAME = "policy_type_id";
+ public static final String POLICIES_NAME = "policies";
+ public static final String POLICY_INSTANCE_ID_NAME = "policy_instance_id";
- // Populated by the autowired constructor
- private final PolicyAgentApi policyAgentApi;
+ // Populated by the autowired constructor
+ private final PolicyAgentApi policyAgentApi;
- @Autowired
- public PolicyController(final PolicyAgentApi policyAgentApi) {
- Assert.notNull(policyAgentApi, "API must not be null");
- this.policyAgentApi = policyAgentApi;
- logger.debug("ctor: configured with client type {}", policyAgentApi.getClass().getName());
- }
+ @Autowired
+ public PolicyController(final PolicyAgentApi policyAgentApi) {
+ Assert.notNull(policyAgentApi, "API must not be null");
+ this.policyAgentApi = policyAgentApi;
+ logger.debug("ctor: configured with client type {}", policyAgentApi.getClass().getName());
+ }
- /*
- * The fields are defined in the Policy Control Typescript interface.
- */
- @ApiOperation(value = "Gets the policy types from Near Realtime-RIC")
- @GetMapping(POLICY_TYPES_METHOD)
- @Secured({ DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD })
- public ResponseEntity<PolicyTypes> getAllPolicyTypes(HttpServletResponse response) {
- logger.debug("getAllPolicyTypes");
- return this.policyAgentApi.getAllPolicyTypes();
- }
+ /*
+ * The fields are defined in the Policy Control Typescript interface.
+ */
+ @ApiOperation(value = "Gets the policy types from Near Realtime-RIC")
+ @GetMapping(POLICY_TYPES_METHOD)
+ @Secured({DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD})
+ public ResponseEntity<PolicyTypes> getAllPolicyTypes(HttpServletResponse response) {
+ logger.debug("getAllPolicyTypes");
+ return this.policyAgentApi.getAllPolicyTypes();
+ }
- @ApiOperation(value = "Returns the policy instances for the given policy type.")
- @GetMapping(POLICY_TYPES_METHOD + "/{" + POLICY_TYPE_ID_NAME + "}/" + POLICIES_NAME)
- @Secured({ DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD })
- public ResponseEntity<String> getPolicyInstances(@PathVariable(POLICY_TYPE_ID_NAME) String policyTypeIdString) {
- logger.debug("getPolicyInstances {}", policyTypeIdString);
+ @ApiOperation(value = "Returns the policy instances for the given policy type.")
+ @GetMapping(POLICY_TYPES_METHOD + "/{" + POLICY_TYPE_ID_NAME + "}/" + POLICIES_NAME)
+ @Secured({DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD})
+ public ResponseEntity<String> getPolicyInstances(@PathVariable(POLICY_TYPE_ID_NAME) String policyTypeIdString) {
+ logger.debug("getPolicyInstances {}", policyTypeIdString);
- ResponseEntity<PolicyInstances> response = this.policyAgentApi.getPolicyInstancesForType(policyTypeIdString);
- if (!response.getStatusCode().is2xxSuccessful()) {
- return new ResponseEntity<>(response.getStatusCode());
- }
- String json = gson.toJson(response.getBody());
- return new ResponseEntity<>(json, response.getStatusCode());
- }
+ ResponseEntity<PolicyInstances> response = this.policyAgentApi.getPolicyInstancesForType(policyTypeIdString);
+ if (!response.getStatusCode().is2xxSuccessful()) {
+ return new ResponseEntity<>(response.getStatusCode());
+ }
+ String json = gson.toJson(response.getBody());
+ return new ResponseEntity<>(json, response.getStatusCode());
+ }
- @ApiOperation(value = "Returns a policy instance of a type")
- @GetMapping(POLICY_TYPES_METHOD + "/{" + POLICY_TYPE_ID_NAME + "}/" + POLICIES_NAME + "/{" + POLICY_INSTANCE_ID_NAME
- + "}")
- @Secured({ DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD })
- public ResponseEntity<String> getPolicyInstance(@PathVariable(POLICY_TYPE_ID_NAME) String policyTypeIdString,
- @PathVariable(POLICY_INSTANCE_ID_NAME) String policyInstanceId) {
- logger.debug("getPolicyInstance {}:{}", policyTypeIdString, policyInstanceId);
- return this.policyAgentApi.getPolicyInstance(policyInstanceId);
- }
+ @ApiOperation(value = "Returns a policy instance of a type")
+ @GetMapping(POLICY_TYPES_METHOD + "/{" + POLICY_TYPE_ID_NAME + "}/" + POLICIES_NAME + "/{" + POLICY_INSTANCE_ID_NAME
+ + "}")
+ @Secured({DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD})
+ public ResponseEntity<String> getPolicyInstance(@PathVariable(POLICY_TYPE_ID_NAME) String policyTypeIdString,
+ @PathVariable(POLICY_INSTANCE_ID_NAME) String policyInstanceId) {
+ logger.debug("getPolicyInstance {}:{}", policyTypeIdString, policyInstanceId);
+ return this.policyAgentApi.getPolicyInstance(policyInstanceId);
+ }
- @ApiOperation(value = "Creates the policy instances for the given policy type.")
- @PutMapping(POLICY_TYPES_METHOD + "/{" + POLICY_TYPE_ID_NAME + "}/" + POLICIES_NAME + "/{" + POLICY_INSTANCE_ID_NAME
- + "}")
- @Secured({ DashboardConstants.ROLE_ADMIN })
- public ResponseEntity<String> putPolicyInstance(@PathVariable(POLICY_TYPE_ID_NAME) String policyTypeIdString,
- @RequestParam(name = "ric", required = true) String ric,
- @PathVariable(POLICY_INSTANCE_ID_NAME) String policyInstanceId, @RequestBody String instance) {
- logger.debug("putPolicyInstance typeId: {}, instanceId: {}, instance: {}", policyTypeIdString, policyInstanceId,
- instance);
- return this.policyAgentApi.putPolicy(policyTypeIdString, policyInstanceId, instance, ric);
- }
+ @ApiOperation(value = "Creates the policy instances for the given policy type.")
+ @PutMapping(POLICY_TYPES_METHOD + "/{" + POLICY_TYPE_ID_NAME + "}/" + POLICIES_NAME + "/{" + POLICY_INSTANCE_ID_NAME
+ + "}")
+ @Secured({DashboardConstants.ROLE_ADMIN})
+ public ResponseEntity<String> putPolicyInstance(@PathVariable(POLICY_TYPE_ID_NAME) String policyTypeIdString,
+ @RequestParam(name = "ric", required = true) String ric,
+ @PathVariable(POLICY_INSTANCE_ID_NAME) String policyInstanceId, @RequestBody String instance) {
+ logger.debug("putPolicyInstance typeId: {}, instanceId: {}, instance: {}", policyTypeIdString, policyInstanceId,
+ instance);
+ return this.policyAgentApi.putPolicy(policyTypeIdString, policyInstanceId, instance, ric);
+ }
- @ApiOperation(value = "Deletes the policy instances for the given policy type.")
- @DeleteMapping(POLICY_TYPES_METHOD + "/{" + POLICY_TYPE_ID_NAME + "}/" + POLICIES_NAME + "/{"
- + POLICY_INSTANCE_ID_NAME + "}")
- @Secured({ DashboardConstants.ROLE_ADMIN })
- public void deletePolicyInstance(@PathVariable(POLICY_TYPE_ID_NAME) String policyTypeIdString,
- @PathVariable(POLICY_INSTANCE_ID_NAME) String policyInstanceId) {
- logger.debug("deletePolicyInstance typeId: {}, instanceId: {}", policyTypeIdString, policyInstanceId);
- this.policyAgentApi.deletePolicy(policyInstanceId);
- }
+ @ApiOperation(value = "Deletes the policy instances for the given policy type.")
+ @DeleteMapping(POLICY_TYPES_METHOD + "/{" + POLICY_TYPE_ID_NAME + "}/" + POLICIES_NAME + "/{"
+ + POLICY_INSTANCE_ID_NAME + "}")
+ @Secured({DashboardConstants.ROLE_ADMIN})
+ public void deletePolicyInstance(@PathVariable(POLICY_TYPE_ID_NAME) String policyTypeIdString,
+ @PathVariable(POLICY_INSTANCE_ID_NAME) String policyInstanceId) {
+ logger.debug("deletePolicyInstance typeId: {}, instanceId: {}", policyTypeIdString, policyInstanceId);
+ this.policyAgentApi.deletePolicy(policyInstanceId);
+ }
- private void checkHttpError(String httpCode) {
- logger.debug("Http Response Code: {}", httpCode);
- if (httpCode.equals(String.valueOf(HttpStatus.NOT_FOUND.value()))) {
- logger.error("Caught HttpNotFoundException");
- throw new HttpNotFoundException("Not Found Exception");
- } else if (httpCode.equals(String.valueOf(HttpStatus.BAD_REQUEST.value()))) {
- logger.error("Caught HttpBadRequestException");
- throw new HttpBadRequestException("Bad Request Exception");
- } else if (httpCode.equals(String.valueOf(HttpStatus.INTERNAL_SERVER_ERROR.value()))) {
- logger.error("Caught HttpInternalServerErrorException");
- throw new HttpInternalServerErrorException("Internal Server Error Exception");
- } else if (httpCode.equals(String.valueOf(HttpStatus.NOT_IMPLEMENTED.value()))) {
- logger.error("Caught HttpNotImplementedException");
- throw new HttpNotImplementedException("Not Implemented Exception");
- }
- }
+ private void checkHttpError(String httpCode) {
+ logger.debug("Http Response Code: {}", httpCode);
+ if (httpCode.equals(String.valueOf(HttpStatus.NOT_FOUND.value()))) {
+ logger.error("Caught HttpNotFoundException");
+ throw new HttpNotFoundException("Not Found Exception");
+ } else if (httpCode.equals(String.valueOf(HttpStatus.BAD_REQUEST.value()))) {
+ logger.error("Caught HttpBadRequestException");
+ throw new HttpBadRequestException("Bad Request Exception");
+ } else if (httpCode.equals(String.valueOf(HttpStatus.INTERNAL_SERVER_ERROR.value()))) {
+ logger.error("Caught HttpInternalServerErrorException");
+ throw new HttpInternalServerErrorException("Internal Server Error Exception");
+ } else if (httpCode.equals(String.valueOf(HttpStatus.NOT_IMPLEMENTED.value()))) {
+ logger.error("Caught HttpNotImplementedException");
+ throw new HttpNotImplementedException("Not Implemented Exception");
+ }
+ }
- @ApiOperation(value = "Returns the rics supporting the given policy type.")
- @GetMapping("/rics")
- @Secured({ DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD })
- public ResponseEntity<String> getRicsSupportingType(
- @RequestParam(name = "policyType", required = true) String supportingPolicyType) {
- logger.debug("getRicsSupportingType {}", supportingPolicyType);
+ @ApiOperation(value = "Returns the rics supporting the given policy type.")
+ @GetMapping("/rics")
+ @Secured({DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD})
+ public ResponseEntity<String> getRicsSupportingType(
+ @RequestParam(name = "policyType", required = true) String supportingPolicyType) {
+ logger.debug("getRicsSupportingType {}", supportingPolicyType);
- ResponseEntity<Collection<String>> result = this.policyAgentApi.getRicsSupportingType(supportingPolicyType);
- if (!result.getStatusCode().is2xxSuccessful()) {
- return new ResponseEntity<>(result.getStatusCode());
- }
- String json = gson.toJson(result.getBody());
- return new ResponseEntity<>(json, result.getStatusCode());
- }
+ ResponseEntity<Collection<String>> result = this.policyAgentApi.getRicsSupportingType(supportingPolicyType);
+ if (!result.getStatusCode().is2xxSuccessful()) {
+ return new ResponseEntity<>(result.getStatusCode());
+ }
+ String json = gson.toJson(result.getBody());
+ return new ResponseEntity<>(json, result.getStatusCode());
+ }
};
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/SimpleErrorController.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/SimpleErrorController.java
index e2248e6..63b78ec 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/SimpleErrorController.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/SimpleErrorController.java
@@ -7,9 +7,9 @@
* 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.
@@ -35,7 +35,6 @@
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.context.request.ServletWebRequest;
-
import springfox.documentation.annotations.ApiIgnore;
/**
@@ -43,12 +42,12 @@
* context, including page not found, and redirects the caller to a custom error
* page. The caller is also redirected to this page if a REST controller takes
* an uncaught exception.
- *
+ *
* If trace is requested via request parameter ("?trace=true") and available,
* adds stack trace information to the standard JSON error response.
- *
+ *
* Excluded from Swagger API documentation.
- *
+ *
* https://stackoverflow.com/questions/25356781/spring-boot-remove-whitelabel-error-page
* https://www.baeldung.com/spring-boot-custom-error-page
*/
@@ -58,36 +57,36 @@
@RequestMapping(value = SimpleErrorController.ERROR_PATH, produces = MediaType.APPLICATION_JSON_VALUE)
public class SimpleErrorController implements ErrorController {
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- public static final String ERROR_PATH = "/error";
+ public static final String ERROR_PATH = "/error";
- private final ErrorAttributes errorAttributes;
+ private final ErrorAttributes errorAttributes;
- @Autowired
- public SimpleErrorController(ErrorAttributes errorAttributes) {
- this.errorAttributes = errorAttributes;
- }
+ @Autowired
+ public SimpleErrorController(ErrorAttributes errorAttributes) {
+ this.errorAttributes = errorAttributes;
+ }
- @Override
- public String getErrorPath() {
- logger.warn("getErrorPath");
- return ERROR_PATH;
- }
+ @Override
+ public String getErrorPath() {
+ logger.warn("getErrorPath");
+ return ERROR_PATH;
+ }
- @GetMapping
- public String handleError(HttpServletRequest request) {
- ServletWebRequest servletWebRequest = new ServletWebRequest(request);
- Throwable t = errorAttributes.getError(servletWebRequest);
- if (t != null)
- logger.warn("handleError", t);
- Map<String, Object> attributes = errorAttributes.getErrorAttributes(servletWebRequest, true);
- attributes.forEach((attribute, value) -> {
- logger.warn("handleError: {} -> {}", attribute, value);
- });
- // Return the name of the page INCLUDING suffix, which I guess is a "view" name.
- // Just "error" is not enough, but don't seem to need a ModelAndView object.
- return "error.html";
- }
+ @GetMapping
+ public String handleError(HttpServletRequest request) {
+ ServletWebRequest servletWebRequest = new ServletWebRequest(request);
+ Throwable t = errorAttributes.getError(servletWebRequest);
+ if (t != null)
+ logger.warn("handleError", t);
+ Map<String, Object> attributes = errorAttributes.getErrorAttributes(servletWebRequest, true);
+ attributes.forEach((attribute, value) -> {
+ logger.warn("handleError: {} -> {}", attribute, value);
+ });
+ // Return the name of the page INCLUDING suffix, which I guess is a "view" name.
+ // Just "error" is not enough, but don't seem to need a ModelAndView object.
+ return "error.html";
+ }
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/k8sapi/SimpleKubernetesClient.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/k8sapi/SimpleKubernetesClient.java
index bcfae62..d3add60 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/k8sapi/SimpleKubernetesClient.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/k8sapi/SimpleKubernetesClient.java
@@ -34,23 +34,22 @@
*/
public class SimpleKubernetesClient {
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- private final String k8sUrl;
+ private final String k8sUrl;
- public SimpleKubernetesClient(String baseUrl) {
- logger.debug("ctor: baseUrl {}", baseUrl);
- k8sUrl = baseUrl;
- }
+ public SimpleKubernetesClient(String baseUrl) {
+ logger.debug("ctor: baseUrl {}", baseUrl);
+ k8sUrl = baseUrl;
+ }
- public String listPods(String namespace) {
- logger.debug("listPods for namespace {}", namespace);
- String podsUrl = new DefaultUriBuilderFactory(k8sUrl.trim()).builder().pathSegment("v1")
- .pathSegment("namespaces").pathSegment(namespace.trim()).pathSegment("pods").build().normalize()
- .toString();
- RestTemplate rt = new RestTemplate();
- ResponseEntity<String> podsResponse = rt.getForEntity(podsUrl, String.class);
- return podsResponse.getBody();
- }
+ public String listPods(String namespace) {
+ logger.debug("listPods for namespace {}", namespace);
+ String podsUrl = new DefaultUriBuilderFactory(k8sUrl.trim()).builder().pathSegment("v1")
+ .pathSegment("namespaces").pathSegment(namespace.trim()).pathSegment("pods").build().normalize().toString();
+ RestTemplate rt = new RestTemplate();
+ ResponseEntity<String> podsResponse = rt.getForEntity(podsUrl, String.class);
+ return podsResponse.getBody();
+ }
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/EcompUserDetails.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/EcompUserDetails.java
index 7bc9f00..3a08206 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/EcompUserDetails.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/EcompUserDetails.java
@@ -32,54 +32,54 @@
public class EcompUserDetails implements UserDetails {
- private static final long serialVersionUID = 1L;
- private final EcompUser ecompUser;
+ private static final long serialVersionUID = 1L;
+ private final EcompUser ecompUser;
- // This is the default Spring role-name prefix.
- private static final String ROLEP = "ROLE_";
+ // This is the default Spring role-name prefix.
+ private static final String ROLEP = "ROLE_";
- public EcompUserDetails(EcompUser ecompUser) {
- this.ecompUser = ecompUser;
- }
+ public EcompUserDetails(EcompUser ecompUser) {
+ this.ecompUser = ecompUser;
+ }
- /*
- * Gets a list of authorities (roles) for this user. To keep Spring happy, every
- * item has prefix ROLE_.
- */
- public Collection<? extends GrantedAuthority> getAuthorities() {
- List<GrantedAuthority> roleList = new ArrayList<>();
- Iterator<EcompRole> roleIter = ecompUser.getRoles().iterator();
- while (roleIter.hasNext()) {
- EcompRole role = roleIter.next();
- // Add the prefix if the ONAP portal doesn't supply it.
- final String roleName = role.getName().startsWith(ROLEP) ? role.getName() : ROLEP + role.getName();
- roleList.add(new SimpleGrantedAuthority(roleName));
- }
- return roleList;
- }
+ /*
+ * Gets a list of authorities (roles) for this user. To keep Spring happy, every
+ * item has prefix ROLE_.
+ */
+ public Collection<? extends GrantedAuthority> getAuthorities() {
+ List<GrantedAuthority> roleList = new ArrayList<>();
+ Iterator<EcompRole> roleIter = ecompUser.getRoles().iterator();
+ while (roleIter.hasNext()) {
+ EcompRole role = roleIter.next();
+ // Add the prefix if the ONAP portal doesn't supply it.
+ final String roleName = role.getName().startsWith(ROLEP) ? role.getName() : ROLEP + role.getName();
+ roleList.add(new SimpleGrantedAuthority(roleName));
+ }
+ return roleList;
+ }
- public String getPassword() {
- return null;
- }
+ public String getPassword() {
+ return null;
+ }
- public String getUsername() {
- return ecompUser.getLoginId();
- }
+ public String getUsername() {
+ return ecompUser.getLoginId();
+ }
- public boolean isAccountNonExpired() {
- return true;
- }
+ public boolean isAccountNonExpired() {
+ return true;
+ }
- public boolean isAccountNonLocked() {
- return true;
- }
+ public boolean isAccountNonLocked() {
+ return true;
+ }
- public boolean isCredentialsNonExpired() {
- return true;
- }
+ public boolean isCredentialsNonExpired() {
+ return true;
+ }
- public boolean isEnabled() {
- return ecompUser.isActive();
- }
+ public boolean isEnabled() {
+ return ecompUser.isActive();
+ }
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/ErrorTransport.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/ErrorTransport.java
index 516e3c8..f1250c1 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/ErrorTransport.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/ErrorTransport.java
@@ -7,9 +7,9 @@
* 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.
@@ -28,106 +28,106 @@
*/
public class ErrorTransport implements IDashboardResponse {
- private Instant timestamp;
- private Integer status;
- private String error;
- private String message;
- private String path;
+ private Instant timestamp;
+ private Integer status;
+ private String error;
+ private String message;
+ private String path;
- /**
- * Builds an empty object.
- */
- public ErrorTransport() {
- // no-arg constructor
- }
+ /**
+ * Builds an empty object.
+ */
+ public ErrorTransport() {
+ // no-arg constructor
+ }
- /**
- * Convenience constructor for minimal value set.
- *
- * @param status
- * Integer value like 400
- * @param error
- * Error message
- */
- public ErrorTransport(int status, String error) {
- this(status, error, null, null);
- }
+ /**
+ * Convenience constructor for minimal value set.
+ *
+ * @param status
+ * Integer value like 400
+ * @param error
+ * Error message
+ */
+ public ErrorTransport(int status, String error) {
+ this(status, error, null, null);
+ }
- /**
- * Convenience constructor for populating an error from an exception
- *
- * @param status
- * Integer value like 400
- * @param throwable
- * The caught exception/throwable to convert to String with
- * an upper bound on characters
- */
- public ErrorTransport(int status, Throwable throwable) {
- this.timestamp = Instant.now();
- this.status = status;
- final int enough = 256;
- String exString = throwable.toString();
- this.error = exString.length() > enough ? exString.substring(0, enough) : exString;
- }
+ /**
+ * Convenience constructor for populating an error from an exception
+ *
+ * @param status
+ * Integer value like 400
+ * @param throwable
+ * The caught exception/throwable to convert to String with
+ * an upper bound on characters
+ */
+ public ErrorTransport(int status, Throwable throwable) {
+ this.timestamp = Instant.now();
+ this.status = status;
+ final int enough = 256;
+ String exString = throwable.toString();
+ this.error = exString.length() > enough ? exString.substring(0, enough) : exString;
+ }
- /**
- * Builds an object with all fields
- *
- * @param status
- * Integer value like 500
- * @param error
- * Explanation
- * @param message
- * Additional explanation
- * @param path
- * Requested path
- */
- public ErrorTransport(int status, String error, String message, String path) {
- this.timestamp = Instant.now();
- this.status = status;
- this.error = error;
- this.message = message;
- this.path = path;
- }
+ /**
+ * Builds an object with all fields
+ *
+ * @param status
+ * Integer value like 500
+ * @param error
+ * Explanation
+ * @param message
+ * Additional explanation
+ * @param path
+ * Requested path
+ */
+ public ErrorTransport(int status, String error, String message, String path) {
+ this.timestamp = Instant.now();
+ this.status = status;
+ this.error = error;
+ this.message = message;
+ this.path = path;
+ }
- public Integer getStatus() {
- return status;
- }
+ public Integer getStatus() {
+ return status;
+ }
- public void setStatus(Integer status) {
- this.status = status;
- }
+ public void setStatus(Integer status) {
+ this.status = status;
+ }
- public String getMessage() {
- return message;
- }
+ public String getMessage() {
+ return message;
+ }
- public void setMessage(String error) {
- this.message = error;
- }
+ public void setMessage(String error) {
+ this.message = error;
+ }
- public Instant getTimestamp() {
- return timestamp;
- }
+ public Instant getTimestamp() {
+ return timestamp;
+ }
- public void setTimestamp(Instant timestamp) {
- this.timestamp = timestamp;
- }
+ public void setTimestamp(Instant timestamp) {
+ this.timestamp = timestamp;
+ }
- public String getError() {
- return error;
- }
+ public String getError() {
+ return error;
+ }
- public void setError(String error) {
- this.error = error;
- }
+ public void setError(String error) {
+ this.error = error;
+ }
- public String getPath() {
- return path;
- }
+ public String getPath() {
+ return path;
+ }
- public void setPath(String path) {
- this.path = path;
- }
+ public void setPath(String path) {
+ this.path = path;
+ }
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyInfo.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyInfo.java
index ca1b79d..30cfd2a 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyInfo.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyInfo.java
@@ -26,16 +26,16 @@
@Gson.TypeAdapters
public interface PolicyInfo {
- public String id();
+ public String id();
- public String type();
+ public String type();
- public String ric();
+ public String ric();
- public String json();
+ public String json();
- public String service();
+ public String service();
- public String lastModified();
+ public String lastModified();
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyInstances.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyInstances.java
index eb6b455..c6faf9b 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyInstances.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyInstances.java
@@ -23,6 +23,6 @@
public class PolicyInstances extends ArrayList<PolicyInfo> {
- private static final long serialVersionUID = -928428052502491021L;
+ private static final long serialVersionUID = -928428052502491021L;
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyType.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyType.java
index ea51cc5..f0ca285 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyType.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyType.java
@@ -23,35 +23,35 @@
public class PolicyType {
- @JsonProperty("name")
- String name;
+ @JsonProperty("name")
+ String name;
- @JsonProperty("schema")
- String schema;
+ @JsonProperty("schema")
+ String schema;
- public PolicyType(String name, String schema) {
- this.name = name;
- this.schema = schema;
- }
+ public PolicyType(String name, String schema) {
+ this.name = name;
+ this.schema = schema;
+ }
- public String getName() {
- return name;
- }
+ public String getName() {
+ return name;
+ }
- public void setName(String name) {
- this.name = name;
- }
+ public void setName(String name) {
+ this.name = name;
+ }
- public String getSchema() {
- return schema;
- }
+ public String getSchema() {
+ return schema;
+ }
- public void setSchema(String schema) {
- this.schema = schema;
- }
+ public void setSchema(String schema) {
+ this.schema = schema;
+ }
- @Override
- public String toString() {
- return "[name:" + name + ", schema:" + schema + "]";
- }
+ @Override
+ public String toString() {
+ return "[name:" + name + ", schema:" + schema + "]";
+ }
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyTypes.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyTypes.java
index 3165d1b..43a6383 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyTypes.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/PolicyTypes.java
@@ -23,6 +23,6 @@
public class PolicyTypes extends ArrayList<PolicyType> {
- private static final long serialVersionUID = -928428052502491021L;
+ private static final long serialVersionUID = -928428052502491021L;
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/SuccessTransport.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/SuccessTransport.java
index 9e13789..65b39eb 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/SuccessTransport.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/SuccessTransport.java
@@ -7,9 +7,9 @@
* 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.
@@ -21,43 +21,43 @@
public class SuccessTransport implements IDashboardResponse {
- private int status;
- private Object data;
+ private int status;
+ private Object data;
- /**
- * Builds an empty object
- */
- public SuccessTransport() {
- // no-arg constructor
- }
+ /**
+ * Builds an empty object
+ */
+ public SuccessTransport() {
+ // no-arg constructor
+ }
- /**
- * Builds an object with the specified values.
- *
- * @param status
- * Status code
- * @param data
- * Data to transport
- */
- public SuccessTransport(int status, Object data) {
- this.status = status;
- this.data = data;
- }
+ /**
+ * Builds an object with the specified values.
+ *
+ * @param status
+ * Status code
+ * @param data
+ * Data to transport
+ */
+ public SuccessTransport(int status, Object data) {
+ this.status = status;
+ this.data = data;
+ }
- public int getStatus() {
- return status;
- }
+ public int getStatus() {
+ return status;
+ }
- public void setStatus(int status) {
- this.status = status;
- }
+ public void setStatus(int status) {
+ this.status = status;
+ }
- public Object getData() {
- return data;
- }
+ public Object getData() {
+ return data;
+ }
- public void setData(Object data) {
- this.data = data;
- }
+ public void setData(Object data) {
+ this.data = data;
+ }
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/policyagentapi/PolicyAgentApi.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/policyagentapi/PolicyAgentApi.java
index 47add76..4a26563 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/policyagentapi/PolicyAgentApi.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/policyagentapi/PolicyAgentApi.java
@@ -7,9 +7,9 @@
* 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.
@@ -35,7 +35,7 @@
public ResponseEntity<String> getPolicyInstance(String id) throws RestClientException;
public ResponseEntity<String> putPolicy(String policyTypeIdString, String policyInstanceId, String json, String ric)
- throws RestClientException;
+ throws RestClientException;
public void deletePolicy(String policyInstanceId) throws RestClientException;
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/policyagentapi/PolicyAgentApiImpl.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/policyagentapi/PolicyAgentApiImpl.java
index eb3f836..af814b9 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/policyagentapi/PolicyAgentApiImpl.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/policyagentapi/PolicyAgentApiImpl.java
@@ -7,9 +7,9 @@
* 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.
@@ -19,12 +19,29 @@
*/
package org.oransc.ric.portal.dashboard.policyagentapi;
-import org.oransc.ric.portal.dashboard.DashboardConstants;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import com.google.gson.reflect.TypeToken;
+
+import java.lang.invoke.MethodHandles;
+import java.lang.reflect.Type;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import org.immutables.gson.Gson;
+import org.immutables.value.Value;
import org.oransc.ric.portal.dashboard.model.ImmutablePolicyInfo;
import org.oransc.ric.portal.dashboard.model.PolicyInfo;
import org.oransc.ric.portal.dashboard.model.PolicyInstances;
import org.oransc.ric.portal.dashboard.model.PolicyType;
import org.oransc.ric.portal.dashboard.model.PolicyTypes;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -32,26 +49,6 @@
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-import java.lang.invoke.MethodHandles;
-import java.lang.reflect.Type;
-
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import com.google.gson.annotations.SerializedName;
-import com.google.gson.reflect.TypeToken;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.immutables.gson.Gson;
-import org.immutables.value.Value;
-
@Component("PolicyAgentApi")
public class PolicyAgentApiImpl implements PolicyAgentApi {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@@ -59,14 +56,14 @@
RestTemplate restTemplate = new RestTemplate();
private static com.google.gson.Gson gson = new GsonBuilder() //
- .serializeNulls() //
- .create(); //
+ .serializeNulls() //
+ .create(); //
private final String urlPrefix;
@Autowired
public PolicyAgentApiImpl(
- @org.springframework.beans.factory.annotation.Value("${policycontroller.url.prefix}") final String urlPrefix) {
+ @org.springframework.beans.factory.annotation.Value("${policycontroller.url.prefix}") final String urlPrefix) {
logger.debug("ctor prefix '{}'", urlPrefix);
this.urlPrefix = urlPrefix;
}
@@ -114,8 +111,7 @@
return new ResponseEntity<>(rsp.getStatusCode());
}
- Type listType = new TypeToken<List<ImmutablePolicyInfo>>() {
- }.getType();
+ Type listType = new TypeToken<List<ImmutablePolicyInfo>>() {}.getType();
List<PolicyInfo> rspParsed = gson.fromJson(rsp.getBody(), listType);
PolicyInstances result = new PolicyInstances();
@@ -135,13 +131,13 @@
@Override
public ResponseEntity<String> putPolicy(String policyTypeIdString, String policyInstanceId, String json, String ric)
- throws RestClientException {
+ throws RestClientException {
String url = baseUrl() + "/policy?type={type}&instance={instance}&ric={ric}&service={service}";
Map<String, ?> uriVariables = Map.of( //
- "type", policyTypeIdString, //
- "instance", policyInstanceId, //
- "ric", ric, //
- "service", "dashboard");
+ "type", policyTypeIdString, //
+ "instance", policyInstanceId, //
+ "ric", ric, //
+ "service", "dashboard");
try {
this.restTemplate.put(url, json, uriVariables);
@@ -174,8 +170,7 @@
Map<String, ?> uriVariables = Map.of("typeName", typeName);
String rsp = this.restTemplate.getForObject(url, String.class, uriVariables);
- Type listType = new TypeToken<List<ImmutableRicInfo>>() {
- }.getType();
+ Type listType = new TypeToken<List<ImmutableRicInfo>>() {}.getType();
List<RicInfo> rspParsed = gson.fromJson(rsp, listType);
Collection<String> result = new Vector<>(rspParsed.size());
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/IPortalSdkDecryptor.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/IPortalSdkDecryptor.java
index 34d80c9..552d783 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/IPortalSdkDecryptor.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/IPortalSdkDecryptor.java
@@ -7,9 +7,9 @@
* 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.
@@ -27,15 +27,15 @@
*/
public interface IPortalSdkDecryptor {
- /**
- * Decrypts the specified value using a known key.
- *
- * @param cipherText
- * Encrypted value
- * @return Clear text on success, null otherwise.
- * @throws CipherUtilException
- * if any decryption step fails
- */
- String decrypt(String cipherText) throws CipherUtilException;
+ /**
+ * Decrypts the specified value using a known key.
+ *
+ * @param cipherText
+ * Encrypted value
+ * @return Clear text on success, null otherwise.
+ * @throws CipherUtilException
+ * if any decryption step fails
+ */
+ String decrypt(String cipherText) throws CipherUtilException;
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalAuthManager.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalAuthManager.java
index dc70f7e..f4daa5c 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalAuthManager.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalAuthManager.java
@@ -7,9 +7,9 @@
* 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.
@@ -38,83 +38,83 @@
*/
public class PortalAuthManager {
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- final Map<String, String> credentialsMap;
- private final IPortalSdkDecryptor portalSdkDecryptor;
- private final String userIdCookieName;
+ final Map<String, String> credentialsMap;
+ private final IPortalSdkDecryptor portalSdkDecryptor;
+ private final String userIdCookieName;
- public PortalAuthManager(final String appName, final String username, final String password,
- final String decryptorClassName, final String userCookie)
- throws ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException,
- InvocationTargetException, NoSuchMethodException, SecurityException {
- credentialsMap = new HashMap<>();
- credentialsMap.put(IPortalRestCentralService.CREDENTIALS_APP, appName);
- credentialsMap.put(IPortalRestCentralService.CREDENTIALS_USER, username);
- credentialsMap.put(IPortalRestCentralService.CREDENTIALS_PASS, password);
- this.userIdCookieName = userCookie;
- // Instantiate here so configuration errors are detected at app-start time
- logger.debug("ctor: using decryptor class {}", decryptorClassName);
- Class<?> decryptorClass = Class.forName(decryptorClassName);
- portalSdkDecryptor = (IPortalSdkDecryptor) decryptorClass.getDeclaredConstructor().newInstance();
- }
+ public PortalAuthManager(final String appName, final String username, final String password,
+ final String decryptorClassName, final String userCookie)
+ throws ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException,
+ InvocationTargetException, NoSuchMethodException, SecurityException {
+ credentialsMap = new HashMap<>();
+ credentialsMap.put(IPortalRestCentralService.CREDENTIALS_APP, appName);
+ credentialsMap.put(IPortalRestCentralService.CREDENTIALS_USER, username);
+ credentialsMap.put(IPortalRestCentralService.CREDENTIALS_PASS, password);
+ this.userIdCookieName = userCookie;
+ // Instantiate here so configuration errors are detected at app-start time
+ logger.debug("ctor: using decryptor class {}", decryptorClassName);
+ Class<?> decryptorClass = Class.forName(decryptorClassName);
+ portalSdkDecryptor = (IPortalSdkDecryptor) decryptorClass.getDeclaredConstructor().newInstance();
+ }
- /**
- * @return A map of key-value pairs with application name, user name and
- * password.
- */
- public Map<String, String> getAppCredentials() {
- return credentialsMap;
- }
+ /**
+ * @return A map of key-value pairs with application name, user name and
+ * password.
+ */
+ public Map<String, String> getAppCredentials() {
+ return credentialsMap;
+ }
- /**
- * Searches the request for a cookie with the specified name.
- *
- * @param request
- * HttpServletRequest
- * @param cookieName
- * Cookie name
- * @return Cookie, or null if not found.
- */
- private Cookie getCookie(HttpServletRequest request, String cookieName) {
- Cookie[] cookies = request.getCookies();
- if (cookies != null)
- for (Cookie cookie : cookies)
- if (cookie.getName().equals(cookieName))
- return cookie;
- return null;
- }
+ /**
+ * Searches the request for a cookie with the specified name.
+ *
+ * @param request
+ * HttpServletRequest
+ * @param cookieName
+ * Cookie name
+ * @return Cookie, or null if not found.
+ */
+ private Cookie getCookie(HttpServletRequest request, String cookieName) {
+ Cookie[] cookies = request.getCookies();
+ if (cookies != null)
+ for (Cookie cookie : cookies)
+ if (cookie.getName().equals(cookieName))
+ return cookie;
+ return null;
+ }
- /**
- * Validates whether the ECOMP Portal sign-on process has completed. Checks for
- * the ECOMP cookie first, then the user cookie.
- *
- * @param request
- * HttpServletRequest
- * @return User ID if the ECOMP cookie is present and the sign-on process
- * established a user ID; else null.
- */
- public String validateEcompSso(HttpServletRequest request) {
- // Check ECOMP Portal cookie
- Cookie ep = getCookie(request, PortalApiConstants.EP_SERVICE);
- if (ep == null) {
- logger.debug("validateEcompSso: cookie not found: {}", PortalApiConstants.EP_SERVICE);
- return null;
- }
- logger.trace("validateEcompSso: found cookie {}", PortalApiConstants.EP_SERVICE);
- Cookie user = getCookie(request, userIdCookieName);
- if (user == null) {
- logger.debug("validateEcompSso: cookie not found: {}", userIdCookieName);
- return null;
- }
- logger.trace("validateEcompSso: user cookie {}", userIdCookieName);
- String userid = null;
- try {
- userid = portalSdkDecryptor.decrypt(user.getValue());
- } catch (CipherUtilException e) {
- throw new IllegalArgumentException("validateEcompSso failed", e);
- }
- return userid;
- }
+ /**
+ * Validates whether the ECOMP Portal sign-on process has completed. Checks for
+ * the ECOMP cookie first, then the user cookie.
+ *
+ * @param request
+ * HttpServletRequest
+ * @return User ID if the ECOMP cookie is present and the sign-on process
+ * established a user ID; else null.
+ */
+ public String validateEcompSso(HttpServletRequest request) {
+ // Check ECOMP Portal cookie
+ Cookie ep = getCookie(request, PortalApiConstants.EP_SERVICE);
+ if (ep == null) {
+ logger.debug("validateEcompSso: cookie not found: {}", PortalApiConstants.EP_SERVICE);
+ return null;
+ }
+ logger.trace("validateEcompSso: found cookie {}", PortalApiConstants.EP_SERVICE);
+ Cookie user = getCookie(request, userIdCookieName);
+ if (user == null) {
+ logger.debug("validateEcompSso: cookie not found: {}", userIdCookieName);
+ return null;
+ }
+ logger.trace("validateEcompSso: user cookie {}", userIdCookieName);
+ String userid = null;
+ try {
+ userid = portalSdkDecryptor.decrypt(user.getValue());
+ } catch (CipherUtilException e) {
+ throw new IllegalArgumentException("validateEcompSso failed", e);
+ }
+ return userid;
+ }
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalAuthenticationFilter.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalAuthenticationFilter.java
index 4b6de91..711761a 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalAuthenticationFilter.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalAuthenticationFilter.java
@@ -7,9 +7,9 @@
* 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.
@@ -71,211 +71,211 @@
* Portal knows where to forward the request to once the Portal Session is
* created and EPService cookie is set.
* </UL>
- *
+ *
* TODO: What about sessions? Will this be stateless?
- *
+ *
* This filter uses no annotations to avoid Spring's automatic registration,
* which add this filter in the chain in the wrong order.
*/
public class PortalAuthenticationFilter implements Filter {
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- // Unfortunately not all file names are defined as constants
- private static final String[] securityPropertyFiles = { KeyProperties.PROPERTY_FILE_NAME,
- PortalApiProperties.PROPERTY_FILE_NAME, DefaultSecurityConfiguration.DEFAULT_RESOURCE_FILE,
- "validation.properties" };
+ // Unfortunately not all file names are defined as constants
+ private static final String[] securityPropertyFiles =
+ {KeyProperties.PROPERTY_FILE_NAME, PortalApiProperties.PROPERTY_FILE_NAME,
+ DefaultSecurityConfiguration.DEFAULT_RESOURCE_FILE, "validation.properties"};
- public static final String REDIRECT_URL_KEY = "redirectUrl";
+ public static final String REDIRECT_URL_KEY = "redirectUrl";
- private final boolean enforcePortalSecurity;
- private final PortalAuthManager authManager;
+ private final boolean enforcePortalSecurity;
+ private final PortalAuthManager authManager;
- private final DashboardUserManager userManager;
+ private final DashboardUserManager userManager;
- public PortalAuthenticationFilter(boolean portalSecurity, PortalAuthManager authManager,
- DashboardUserManager userManager) {
- this.enforcePortalSecurity = portalSecurity;
- this.authManager = authManager;
- this.userManager = userManager;
- if (portalSecurity) {
- // Throw if security is requested and prerequisites are not met
- for (String pf : securityPropertyFiles) {
- InputStream in = MethodHandles.lookup().lookupClass().getClassLoader().getResourceAsStream(pf);
- if (in == null) {
- String msg = "Failed to find property file on classpath: " + pf;
- logger.error(msg);
- throw new RuntimeException(msg);
- } else {
- try {
- in.close();
- } catch (IOException ex) {
- logger.warn("Failed to close stream", ex);
- }
- }
- }
- }
- }
+ public PortalAuthenticationFilter(boolean portalSecurity, PortalAuthManager authManager,
+ DashboardUserManager userManager) {
+ this.enforcePortalSecurity = portalSecurity;
+ this.authManager = authManager;
+ this.userManager = userManager;
+ if (portalSecurity) {
+ // Throw if security is requested and prerequisites are not met
+ for (String pf : securityPropertyFiles) {
+ InputStream in = MethodHandles.lookup().lookupClass().getClassLoader().getResourceAsStream(pf);
+ if (in == null) {
+ String msg = "Failed to find property file on classpath: " + pf;
+ logger.error(msg);
+ throw new RuntimeException(msg);
+ } else {
+ try {
+ in.close();
+ } catch (IOException ex) {
+ logger.warn("Failed to close stream", ex);
+ }
+ }
+ }
+ }
+ }
- @Override
- public void init(FilterConfig filterConfig) throws ServletException {
- // complain loudly if this key property is missing
- String url = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL);
- logger.debug("init: Portal redirect URL {}", url);
- if (url == null)
- logger.error(
- "init: Failed to find property in portal.properties: " + PortalApiConstants.ECOMP_REDIRECT_URL);
- }
+ @Override
+ public void init(FilterConfig filterConfig) throws ServletException {
+ // complain loudly if this key property is missing
+ String url = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL);
+ logger.debug("init: Portal redirect URL {}", url);
+ if (url == null)
+ logger
+ .error("init: Failed to find property in portal.properties: " + PortalApiConstants.ECOMP_REDIRECT_URL);
+ }
- @Override
- public void destroy() {
- // No resources to release
- }
+ @Override
+ public void destroy() {
+ // No resources to release
+ }
- /**
- * Requests for pages ignored in the web security config do not hit this filter.
- */
- @Override
- public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
- throws IOException, ServletException {
- if (enforcePortalSecurity)
- doFilterEPSDKFW(req, res, chain);
- else
- doFilterMockUserAdminRole(req, res, chain);
- }
+ /**
+ * Requests for pages ignored in the web security config do not hit this filter.
+ */
+ @Override
+ public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
+ throws IOException, ServletException {
+ if (enforcePortalSecurity)
+ doFilterEPSDKFW(req, res, chain);
+ else
+ doFilterMockUserAdminRole(req, res, chain);
+ }
- /*
- * Populates security context with a mock user in the admin role.
- *
- */
- private void doFilterMockUserAdminRole(ServletRequest req, ServletResponse res, FilterChain chain)
- throws IOException, ServletException {
- Authentication auth = SecurityContextHolder.getContext().getAuthentication();
- if (auth == null || auth.getAuthorities().isEmpty()) {
- if (logger.isDebugEnabled()) {
- logger.debug("doFilter adding auth to request URI {}",
- (req instanceof HttpServletRequest) ? ((HttpServletRequest) req).getRequestURL() : req);
- }
- EcompRole admin = new EcompRole();
- admin.setId(1L);
- admin.setName(DashboardConstants.ROLE_ADMIN);
- HashSet<EcompRole> roles = new HashSet<>();
- roles.add(admin);
- EcompUser user = new EcompUser();
- user.setLoginId("fakeLoginId");
- user.setRoles(roles);
- user.setActive(true);
- EcompUserDetails userDetails = new EcompUserDetails(user);
- PreAuthenticatedAuthenticationToken authToken = new PreAuthenticatedAuthenticationToken(userDetails,
- "fakeCredentials", userDetails.getAuthorities());
- SecurityContextHolder.getContext().setAuthentication(authToken);
- } else {
- logger.debug("doFilter: authorities {}", auth.getAuthorities());
- }
- chain.doFilter(req, res);
- }
+ /*
+ * Populates security context with a mock user in the admin role.
+ *
+ */
+ private void doFilterMockUserAdminRole(ServletRequest req, ServletResponse res, FilterChain chain)
+ throws IOException, ServletException {
+ Authentication auth = SecurityContextHolder.getContext().getAuthentication();
+ if (auth == null || auth.getAuthorities().isEmpty()) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("doFilter adding auth to request URI {}",
+ (req instanceof HttpServletRequest) ? ((HttpServletRequest) req).getRequestURL() : req);
+ }
+ EcompRole admin = new EcompRole();
+ admin.setId(1L);
+ admin.setName(DashboardConstants.ROLE_ADMIN);
+ HashSet<EcompRole> roles = new HashSet<>();
+ roles.add(admin);
+ EcompUser user = new EcompUser();
+ user.setLoginId("fakeLoginId");
+ user.setRoles(roles);
+ user.setActive(true);
+ EcompUserDetails userDetails = new EcompUserDetails(user);
+ PreAuthenticatedAuthenticationToken authToken =
+ new PreAuthenticatedAuthenticationToken(userDetails, "fakeCredentials", userDetails.getAuthorities());
+ SecurityContextHolder.getContext().setAuthentication(authToken);
+ } else {
+ logger.debug("doFilter: authorities {}", auth.getAuthorities());
+ }
+ chain.doFilter(req, res);
+ }
- /*
- * Checks for valid cookies and allows request to be served if found; redirects
- * to Portal otherwise.
- */
- private void doFilterEPSDKFW(ServletRequest req, ServletResponse res, FilterChain chain)
- throws IOException, ServletException {
- HttpServletRequest request = (HttpServletRequest) req;
- HttpServletResponse response = (HttpServletResponse) res;
- if (logger.isTraceEnabled())
- logger.trace("doFilter: req {}", request.getRequestURI());
- // Need to authenticate the request
- final String userId = authManager.validateEcompSso(request);
- final EcompUser ecompUser = (userId == null ? null : userManager.getUser(userId));
- if (userId == null || ecompUser == null) {
- logger.debug("doFilter: unauthorized user requests URI {}, serving login page", request.getRequestURI());
- StringBuffer sb = request.getRequestURL();
- sb.append(request.getQueryString() == null ? "" : "?" + request.getQueryString());
- String body = generateLoginRedirectPage(sb.toString());
- response.setContentType(MediaType.TEXT_HTML_VALUE);
- response.getWriter().print(body);
- response.getWriter().flush();
- } else {
- EcompUserDetails userDetails = new EcompUserDetails(ecompUser);
- // Using portal session as credentials is a hack
- PreAuthenticatedAuthenticationToken authToken = new PreAuthenticatedAuthenticationToken(userDetails,
- getPortalSessionId(request), userDetails.getAuthorities());
- SecurityContextHolder.getContext().setAuthentication(authToken);
- // Pass request back down the filter chain
- chain.doFilter(request, response);
- }
- }
+ /*
+ * Checks for valid cookies and allows request to be served if found; redirects
+ * to Portal otherwise.
+ */
+ private void doFilterEPSDKFW(ServletRequest req, ServletResponse res, FilterChain chain)
+ throws IOException, ServletException {
+ HttpServletRequest request = (HttpServletRequest) req;
+ HttpServletResponse response = (HttpServletResponse) res;
+ if (logger.isTraceEnabled())
+ logger.trace("doFilter: req {}", request.getRequestURI());
+ // Need to authenticate the request
+ final String userId = authManager.validateEcompSso(request);
+ final EcompUser ecompUser = (userId == null ? null : userManager.getUser(userId));
+ if (userId == null || ecompUser == null) {
+ logger.debug("doFilter: unauthorized user requests URI {}, serving login page", request.getRequestURI());
+ StringBuffer sb = request.getRequestURL();
+ sb.append(request.getQueryString() == null ? "" : "?" + request.getQueryString());
+ String body = generateLoginRedirectPage(sb.toString());
+ response.setContentType(MediaType.TEXT_HTML_VALUE);
+ response.getWriter().print(body);
+ response.getWriter().flush();
+ } else {
+ EcompUserDetails userDetails = new EcompUserDetails(ecompUser);
+ // Using portal session as credentials is a hack
+ PreAuthenticatedAuthenticationToken authToken = new PreAuthenticatedAuthenticationToken(userDetails,
+ getPortalSessionId(request), userDetails.getAuthorities());
+ SecurityContextHolder.getContext().setAuthentication(authToken);
+ // Pass request back down the filter chain
+ chain.doFilter(request, response);
+ }
+ }
- /**
- * Generates a page with text only, absolutely no references to any webapp
- * resources, so this can be served to an unauthenticated user without
- * triggering a new authentication attempt. The page has a link to the Portal
- * URL from configuration, with a return URL that is the original request.
- *
- * @param appUrl
- * Original requested URL
- * @return HTML
- * @throws UnsupportedEncodingException
- * On error
- */
- private static String generateLoginRedirectPage(String appUrl) throws UnsupportedEncodingException {
- String encodedAppUrl = URLEncoder.encode(appUrl, "UTF-8");
- String portalBaseUrl = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL);
- String redirectUrl = portalBaseUrl + "?" + PortalAuthenticationFilter.REDIRECT_URL_KEY + "=" + encodedAppUrl;
- String aHref = "<a href=\"" + redirectUrl + "\">";
- // If only Java had "here" documents.
- String body = String.join(//
- System.getProperty("line.separator"), //
- "<html>", //
- "<head>", //
- "<title>RIC Dashboard</title>", //
- "<style>", //
- "html, body { ", //
- " font-family: Helvetica, Arial, sans-serif;", //
- "}", //
- "</style>", //
- "</head>", //
- "<body>", //
- "<h2>RIC Dashboard</h2>", //
- "<h4>Please log in.</h4>", //
- "<p>", //
- aHref, "Click here to authenticate at the ONAP Portal</a>", //
- "</p>", //
- "</body>", //
- "</html>");
- return body;
- }
+ /**
+ * Generates a page with text only, absolutely no references to any webapp
+ * resources, so this can be served to an unauthenticated user without
+ * triggering a new authentication attempt. The page has a link to the Portal
+ * URL from configuration, with a return URL that is the original request.
+ *
+ * @param appUrl
+ * Original requested URL
+ * @return HTML
+ * @throws UnsupportedEncodingException
+ * On error
+ */
+ private static String generateLoginRedirectPage(String appUrl) throws UnsupportedEncodingException {
+ String encodedAppUrl = URLEncoder.encode(appUrl, "UTF-8");
+ String portalBaseUrl = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL);
+ String redirectUrl = portalBaseUrl + "?" + PortalAuthenticationFilter.REDIRECT_URL_KEY + "=" + encodedAppUrl;
+ String aHref = "<a href=\"" + redirectUrl + "\">";
+ // If only Java had "here" documents.
+ String body = String.join(//
+ System.getProperty("line.separator"), //
+ "<html>", //
+ "<head>", //
+ "<title>RIC Dashboard</title>", //
+ "<style>", //
+ "html, body { ", //
+ " font-family: Helvetica, Arial, sans-serif;", //
+ "}", //
+ "</style>", //
+ "</head>", //
+ "<body>", //
+ "<h2>RIC Dashboard</h2>", //
+ "<h4>Please log in.</h4>", //
+ "<p>", //
+ aHref, "Click here to authenticate at the ONAP Portal</a>", //
+ "</p>", //
+ "</body>", //
+ "</html>");
+ return body;
+ }
- /**
- * Searches the request for a cookie with the specified name.
- *
- * @param request
- * HttpServletRequest
- * @param cookieName
- * Cookie name
- * @return Cookie, or null if not found.
- */
- private Cookie getCookie(HttpServletRequest request, String cookieName) {
- Cookie[] cookies = request.getCookies();
- if (cookies != null)
- for (Cookie cookie : cookies)
- if (cookie.getName().equals(cookieName))
- return cookie;
- return null;
- }
+ /**
+ * Searches the request for a cookie with the specified name.
+ *
+ * @param request
+ * HttpServletRequest
+ * @param cookieName
+ * Cookie name
+ * @return Cookie, or null if not found.
+ */
+ private Cookie getCookie(HttpServletRequest request, String cookieName) {
+ Cookie[] cookies = request.getCookies();
+ if (cookies != null)
+ for (Cookie cookie : cookies)
+ if (cookie.getName().equals(cookieName))
+ return cookie;
+ return null;
+ }
- /**
- * Gets the ECOMP Portal service cookie value.
- *
- * @param request
- * @return Cookie value, or null if not found.
- */
- private String getPortalSessionId(HttpServletRequest request) {
- Cookie ep = getCookie(request, PortalApiConstants.EP_SERVICE);
- if (ep == null)
- return null;
- return ep.getValue();
- }
+ /**
+ * Gets the ECOMP Portal service cookie value.
+ *
+ * @param request
+ * @return Cookie value, or null if not found.
+ */
+ private String getPortalSessionId(HttpServletRequest request) {
+ Cookie ep = getCookie(request, PortalApiConstants.EP_SERVICE);
+ if (ep == null)
+ return null;
+ return ep.getValue();
+ }
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalRestCentralServiceImpl.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalRestCentralServiceImpl.java
index 581ca25..a2fae9f 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalRestCentralServiceImpl.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalRestCentralServiceImpl.java
@@ -7,9 +7,9 @@
* 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.
@@ -38,52 +38,52 @@
* Implements the contract used by the Portal to transmit user details to this
* on-boarded application. The requests are intercepted first by a servlet in
* the EPSDK-FW library, which proxies the calls to these methods.
- *
+ *
* An instance of this class is created upon first request to the API. But this
* class is found and instantiated via Class.forName(), so cannot use Spring
* annotations.
*/
public class PortalRestCentralServiceImpl implements IPortalRestCentralService {
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- private final PortalAuthManager authManager;
- private final DashboardUserManager userManager;
+ private final PortalAuthManager authManager;
+ private final DashboardUserManager userManager;
- public PortalRestCentralServiceImpl() throws IOException, PortalAPIException {
- final ApplicationContext context = SpringContextCache.getApplicationContext();
- authManager = (PortalAuthManager) context.getBean(PortalAuthManager.class);
- userManager = (DashboardUserManager) context.getBean(DashboardUserManager.class);
- }
+ public PortalRestCentralServiceImpl() throws IOException, PortalAPIException {
+ final ApplicationContext context = SpringContextCache.getApplicationContext();
+ authManager = context.getBean(PortalAuthManager.class);
+ userManager = context.getBean(DashboardUserManager.class);
+ }
- /*
- * Answers the Portal API credentials.
- */
- @Override
- public Map<String, String> getAppCredentials() throws PortalAPIException {
- logger.debug("getAppCredentials");
- return authManager.getAppCredentials();
- }
+ /*
+ * Answers the Portal API credentials.
+ */
+ @Override
+ public Map<String, String> getAppCredentials() throws PortalAPIException {
+ logger.debug("getAppCredentials");
+ return authManager.getAppCredentials();
+ }
- /*
- * Extracts the user ID from a cookie in the header
- */
- @Override
- public String getUserId(HttpServletRequest request) throws PortalAPIException {
- logger.debug("getuserId");
- return authManager.validateEcompSso(request);
- }
+ /*
+ * Extracts the user ID from a cookie in the header
+ */
+ @Override
+ public String getUserId(HttpServletRequest request) throws PortalAPIException {
+ logger.debug("getuserId");
+ return authManager.validateEcompSso(request);
+ }
- @Override
- public void pushUser(EcompUser user) throws PortalAPIException {
- logger.debug("pushUser: {}", user);
- userManager.createUser(user);
- }
+ @Override
+ public void pushUser(EcompUser user) throws PortalAPIException {
+ logger.debug("pushUser: {}", user);
+ userManager.createUser(user);
+ }
- @Override
- public void editUser(String loginId, EcompUser user) throws PortalAPIException {
- logger.debug("editUser: {}", user);
- userManager.updateUser(loginId, user);
- }
+ @Override
+ public void editUser(String loginId, EcompUser user) throws PortalAPIException {
+ logger.debug("editUser: {}", user);
+ userManager.updateUser(loginId, user);
+ }
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalSdkDecryptorAes.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalSdkDecryptorAes.java
index 279f1dd..f62ea5f 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalSdkDecryptorAes.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalSdkDecryptorAes.java
@@ -24,9 +24,9 @@
public class PortalSdkDecryptorAes implements IPortalSdkDecryptor {
- @SuppressWarnings("deprecation")
- public String decrypt(String cipherText) throws CipherUtilException {
- return CipherUtil.decrypt(cipherText);
- }
+ @SuppressWarnings("deprecation")
+ public String decrypt(String cipherText) throws CipherUtilException {
+ return CipherUtil.decrypt(cipherText);
+ }
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalSdkDecryptorPkc.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalSdkDecryptorPkc.java
index 0127267..1020527 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalSdkDecryptorPkc.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalSdkDecryptorPkc.java
@@ -24,8 +24,8 @@
public class PortalSdkDecryptorPkc implements IPortalSdkDecryptor {
- public String decrypt(String cipherText) throws CipherUtilException {
- return CipherUtil.decryptPKC(cipherText);
- }
+ public String decrypt(String cipherText) throws CipherUtilException {
+ return CipherUtil.decryptPKC(cipherText);
+ }
}
diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/util/HttpsURLConnectionUtils.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/util/HttpsURLConnectionUtils.java
index a97ed7b..d5f2cbf 100644
--- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/util/HttpsURLConnectionUtils.java
+++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/util/HttpsURLConnectionUtils.java
@@ -7,9 +7,9 @@
* 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.
@@ -35,48 +35,52 @@
* Disables and enables certificate and host-name checking in
* HttpsURLConnection, the default JVM implementation of the HTTPS/TLS protocol.
* Has no effect on implementations such as Apache Http Client, Ok Http.
- *
+ *
* https://stackoverflow.com/questions/23504819/how-to-disable-ssl-certificate-checking-with-spring-resttemplate/58291331#58291331
*/
public final class HttpsURLConnectionUtils {
- private static final HostnameVerifier jvmHostnameVerifier = HttpsURLConnection.getDefaultHostnameVerifier();
+ private static final HostnameVerifier jvmHostnameVerifier = HttpsURLConnection.getDefaultHostnameVerifier();
- private static final HostnameVerifier trivialHostnameVerifier = new HostnameVerifier() {
- public boolean verify(String hostname, SSLSession sslSession) {
- return true;
- }
- };
+ private static final HostnameVerifier trivialHostnameVerifier = new HostnameVerifier() {
+ @Override
+ public boolean verify(String hostname, SSLSession sslSession) {
+ return true;
+ }
+ };
- private static final TrustManager[] UNQUESTIONING_TRUST_MANAGER = new TrustManager[] { new X509TrustManager() {
- public java.security.cert.X509Certificate[] getAcceptedIssuers() {
- return null;
- }
+ private static final TrustManager[] UNQUESTIONING_TRUST_MANAGER = new TrustManager[] {new X509TrustManager() {
+ @Override
+ public java.security.cert.X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
- public void checkClientTrusted(X509Certificate[] certs, String authType) {
- }
+ @Override
+ public void checkClientTrusted(X509Certificate[] certs, String authType) {
+ }
- public void checkServerTrusted(X509Certificate[] certs, String authType) {
- }
- } };
+ @Override
+ public void checkServerTrusted(X509Certificate[] certs, String authType) {
+ }
+ }};
- public static void turnOffSslChecking() throws NoSuchAlgorithmException, KeyManagementException {
- HttpsURLConnection.setDefaultHostnameVerifier(trivialHostnameVerifier);
- // Install the all-trusting trust manager
- SSLContext sc = SSLContext.getInstance("SSL");
- sc.init(null, UNQUESTIONING_TRUST_MANAGER, null);
- HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
- }
+ public static void turnOffSslChecking() throws NoSuchAlgorithmException, KeyManagementException {
+ HttpsURLConnection.setDefaultHostnameVerifier(trivialHostnameVerifier);
+ // Install the all-trusting trust manager
+ SSLContext sc = SSLContext.getInstance("SSL");
+ sc.init(null, UNQUESTIONING_TRUST_MANAGER, null);
+ HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
+ }
- public static void turnOnSslChecking() throws KeyManagementException, NoSuchAlgorithmException {
- HttpsURLConnection.setDefaultHostnameVerifier(jvmHostnameVerifier);
- // Return it to the initial state (discovered by reflection, now hardcoded)
- SSLContext sc = SSLContext.getInstance("SSL");
- sc.init(null, null, null);
- HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
- }
+ public static void turnOnSslChecking() throws KeyManagementException, NoSuchAlgorithmException {
+ HttpsURLConnection.setDefaultHostnameVerifier(jvmHostnameVerifier);
+ // Return it to the initial state (discovered by reflection, now hardcoded)
+ SSLContext sc = SSLContext.getInstance("SSL");
+ sc.init(null, null, null);
+ HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
+ }
- private HttpsURLConnectionUtils() {
- throw new UnsupportedOperationException("Do not instantiate libraries.");
- }
+ private HttpsURLConnectionUtils() {
+ throw new UnsupportedOperationException("Do not instantiate libraries.");
+ }
}
diff --git a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/DashboardTestServer.java b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/DashboardTestServer.java
index a6c0a1e..e19890b 100644
--- a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/DashboardTestServer.java
+++ b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/DashboardTestServer.java
@@ -22,6 +22,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.lang.invoke.MethodHandles;
+
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -29,7 +30,6 @@
import org.slf4j.LoggerFactory;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
-import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
/**
@@ -49,23 +49,23 @@
@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT)
public class DashboardTestServer {
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- /*
- * Keeps the test server alive forever. Use a guard so this test is never run by
- * Jenkins.
- */
- @EnabledIfSystemProperty(named = "org.oransc.ric.portal.dashboard", matches = "mock")
- @Test
- public void keepServerAlive() {
- logger.warn("Keeping server alive!");
- try {
- synchronized (this) {
- this.wait();
- }
- } catch (Exception ex) {
- logger.warn(ex.toString());
- }
- assertEquals(1, 2);
- }
+ /*
+ * Keeps the test server alive forever. Use a guard so this test is never run by
+ * Jenkins.
+ */
+ @EnabledIfSystemProperty(named = "org.oransc.ric.portal.dashboard", matches = "mock")
+ @Test
+ public void keepServerAlive() {
+ logger.warn("Keeping server alive!");
+ try {
+ synchronized (this) {
+ this.wait();
+ }
+ } catch (Exception ex) {
+ logger.warn(ex.toString());
+ }
+ assertEquals(1, 2);
+ }
}
diff --git a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/PolicyControllerMockConfiguration.java b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/PolicyControllerMockConfiguration.java
index e073ef6..41b9ee0 100644
--- a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/PolicyControllerMockConfiguration.java
+++ b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/PolicyControllerMockConfiguration.java
@@ -52,143 +52,143 @@
@TestConfiguration
public class PolicyControllerMockConfiguration {
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- @Bean
- public PolicyAgentApi policyAgentApi() {
- MockPolicyAgentApi apiClient = new MockPolicyAgentApi();
- return apiClient;
- }
+ @Bean
+ public PolicyAgentApi policyAgentApi() {
+ MockPolicyAgentApi apiClient = new MockPolicyAgentApi();
+ return apiClient;
+ }
- class MockPolicyAgentApi implements PolicyAgentApi {
- private final Database database = new Database();
+ class MockPolicyAgentApi implements PolicyAgentApi {
+ private final Database database = new Database();
- @Override
- public ResponseEntity<String> getPolicyInstance(String id) throws RestClientException {
- return new ResponseEntity<>(database.getInstance(id), HttpStatus.OK);
- }
+ @Override
+ public ResponseEntity<String> getPolicyInstance(String id) throws RestClientException {
+ return new ResponseEntity<>(database.getInstance(id), HttpStatus.OK);
+ }
- @Override
- public ResponseEntity<String> putPolicy(String policyTypeIdString, String policyInstanceId, String json,
- String ric) throws RestClientException {
- database.putInstance(policyTypeIdString, policyInstanceId, json, ric);
- return new ResponseEntity<>(HttpStatus.OK);
- }
+ @Override
+ public ResponseEntity<String> putPolicy(String policyTypeIdString, String policyInstanceId, String json,
+ String ric) throws RestClientException {
+ database.putInstance(policyTypeIdString, policyInstanceId, json, ric);
+ return new ResponseEntity<>(HttpStatus.OK);
+ }
- @Override
- public void deletePolicy(String policyInstanceId) throws RestClientException {
- database.deleteInstance(policyInstanceId);
- }
+ @Override
+ public void deletePolicy(String policyInstanceId) throws RestClientException {
+ database.deleteInstance(policyInstanceId);
+ }
- @Override
- public ResponseEntity<PolicyTypes> getAllPolicyTypes() throws RestClientException {
- PolicyTypes result = new PolicyTypes();
- result.addAll(database.getTypes());
- return new ResponseEntity<>(result, HttpStatus.OK);
- }
+ @Override
+ public ResponseEntity<PolicyTypes> getAllPolicyTypes() throws RestClientException {
+ PolicyTypes result = new PolicyTypes();
+ result.addAll(database.getTypes());
+ return new ResponseEntity<>(result, HttpStatus.OK);
+ }
- @Override
- public ResponseEntity<PolicyInstances> getPolicyInstancesForType(String type) {
- PolicyInstances result = new PolicyInstances();
- List<PolicyInfo> inst = database.getInstances(Optional.of(type));
- result.addAll(inst);
- return new ResponseEntity<>(result, HttpStatus.OK);
- }
+ @Override
+ public ResponseEntity<PolicyInstances> getPolicyInstancesForType(String type) {
+ PolicyInstances result = new PolicyInstances();
+ List<PolicyInfo> inst = database.getInstances(Optional.of(type));
+ result.addAll(inst);
+ return new ResponseEntity<>(result, HttpStatus.OK);
+ }
- @Override
- public ResponseEntity<Collection<String>> getRicsSupportingType(String typeName) {
- Vector<String> res = new Vector<>();
- res.add("ric_1");
- res.add("ric_2");
- res.add("ric_3");
- return new ResponseEntity<>(res, HttpStatus.OK);
- }
- }
+ @Override
+ public ResponseEntity<Collection<String>> getRicsSupportingType(String typeName) {
+ Vector<String> res = new Vector<>();
+ res.add("ric_1");
+ res.add("ric_2");
+ res.add("ric_3");
+ return new ResponseEntity<>(res, HttpStatus.OK);
+ }
+ }
- class Database {
+ class Database {
- Database() {
- String schema = getStringFromFile("anr-policy-schema.json");
- PolicyType policy = new PolicyType("ANR", schema);
- types.put("ANR", policy);
+ Database() {
+ String schema = getStringFromFile("anr-policy-schema.json");
+ PolicyType policy = new PolicyType("ANR", schema);
+ types.put("ANR", policy);
- schema = getStringFromFile("demo-policy-schema-1.json");
- policy = new PolicyType("type2", schema);
- types.put("type2", policy);
+ schema = getStringFromFile("demo-policy-schema-1.json");
+ policy = new PolicyType("type2", schema);
+ types.put("type2", policy);
- schema = getStringFromFile("demo-policy-schema-2.json");
- policy = new PolicyType("type3", schema);
- types.put("type3", policy);
+ schema = getStringFromFile("demo-policy-schema-2.json");
+ policy = new PolicyType("type3", schema);
+ types.put("type3", policy);
- schema = getStringFromFile("demo-policy-schema-3.json");
- policy = new PolicyType("type4", schema);
- types.put("type4", policy);
- try {
- putInstance("ANR", "ANR-1", getStringFromFile("anr-policy-instance.json"), "ric_1");
- } catch (Exception e) {
- // Nothing
- }
- }
+ schema = getStringFromFile("demo-policy-schema-3.json");
+ policy = new PolicyType("type4", schema);
+ types.put("type4", policy);
+ try {
+ putInstance("ANR", "ANR-1", getStringFromFile("anr-policy-instance.json"), "ric_1");
+ } catch (Exception e) {
+ // Nothing
+ }
+ }
- private String getStringFromFile(String path) {
- try {
- InputStream inputStream = MethodHandles.lookup().lookupClass().getClassLoader()
- .getResourceAsStream(path);
- return new BufferedReader(new InputStreamReader(inputStream)).lines().collect(Collectors.joining("\n"));
- } catch (Exception e) {
- logger.error("Cannot read file :" + path, e);
- return "";
- }
- }
+ private String getStringFromFile(String path) {
+ try {
+ InputStream inputStream =
+ MethodHandles.lookup().lookupClass().getClassLoader().getResourceAsStream(path);
+ return new BufferedReader(new InputStreamReader(inputStream)).lines().collect(Collectors.joining("\n"));
+ } catch (Exception e) {
+ logger.error("Cannot read file :" + path, e);
+ return "";
+ }
+ }
- String normalize(String str) {
- return str.replace('\n', ' ');
- }
+ String normalize(String str) {
+ return str.replace('\n', ' ');
+ }
- private String getTimeStampUTC() {
- return java.time.Instant.now().toString();
- }
+ private String getTimeStampUTC() {
+ return java.time.Instant.now().toString();
+ }
- void putInstance(String typeId, String instanceId, String instanceData, String ric) {
- PolicyInfo i = ImmutablePolicyInfo.builder().json(instanceData).lastModified(getTimeStampUTC())
- .id(instanceId).ric(ric).service("service").type(typeId).build();
- instances.put(instanceId, i);
- }
+ void putInstance(String typeId, String instanceId, String instanceData, String ric) {
+ PolicyInfo i = ImmutablePolicyInfo.builder().json(instanceData).lastModified(getTimeStampUTC())
+ .id(instanceId).ric(ric).service("service").type(typeId).build();
+ instances.put(instanceId, i);
+ }
- public void deleteInstance(String instanceId) {
- instances.remove(instanceId);
- }
+ public void deleteInstance(String instanceId) {
+ instances.remove(instanceId);
+ }
- String getInstance(String id) throws RestClientException {
- PolicyInfo i = instances.get(id);
- if (i == null) {
- throw new RestClientException("Type not found: " + id);
- }
- return i.json();
- }
+ String getInstance(String id) throws RestClientException {
+ PolicyInfo i = instances.get(id);
+ if (i == null) {
+ throw new RestClientException("Type not found: " + id);
+ }
+ return i.json();
+ }
- public Collection<PolicyType> getTypes() {
- return types.values();
- }
+ public Collection<PolicyType> getTypes() {
+ return types.values();
+ }
- public List<PolicyInfo> getInstances(Optional<String> typeId) {
- ArrayList<PolicyInfo> result = new ArrayList<>();
- for (PolicyInfo i : instances.values()) {
- if (typeId.isPresent()) {
- if (i.type().equals(typeId.get())) {
- result.add(i);
- }
+ public List<PolicyInfo> getInstances(Optional<String> typeId) {
+ ArrayList<PolicyInfo> result = new ArrayList<>();
+ for (PolicyInfo i : instances.values()) {
+ if (typeId.isPresent()) {
+ if (i.type().equals(typeId.get())) {
+ result.add(i);
+ }
- } else {
- result.add(i);
- }
- }
- return result;
- }
+ } else {
+ result.add(i);
+ }
+ }
+ return result;
+ }
- private Map<String, PolicyType> types = new HashMap<>();
- private Map<String, PolicyInfo> instances = new HashMap<>();
+ private Map<String, PolicyType> types = new HashMap<>();
+ private Map<String, PolicyInfo> instances = new HashMap<>();
- }
+ }
}
diff --git a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/PortalApIMockConfiguration.java b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/PortalApIMockConfiguration.java
index a3d05be..01265d9 100644
--- a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/PortalApIMockConfiguration.java
+++ b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/PortalApIMockConfiguration.java
@@ -43,41 +43,41 @@
@Profile("test")
public class PortalApIMockConfiguration {
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- // Unfortunately EPSDK-FW does not define these as constants
- public static final String PORTAL_USERNAME_HEADER_KEY = "username";
- public static final String PORTAL_PASSWORD_HEADER_KEY = "password";
+ // Unfortunately EPSDK-FW does not define these as constants
+ public static final String PORTAL_USERNAME_HEADER_KEY = "username";
+ public static final String PORTAL_PASSWORD_HEADER_KEY = "password";
- @Bean
- public ServletRegistrationBean<PortalRestAPIProxy> portalApiProxyServlet() {
- PortalRestAPIProxy servlet = new PortalRestAPIProxy();
- final ServletRegistrationBean<PortalRestAPIProxy> servletBean = new ServletRegistrationBean<>(servlet,
- PortalApiConstants.API_PREFIX + "/*");
- servletBean.setName("PortalRestApiProxyServlet");
- return servletBean;
- }
+ @Bean
+ public ServletRegistrationBean<PortalRestAPIProxy> portalApiProxyServlet() {
+ PortalRestAPIProxy servlet = new PortalRestAPIProxy();
+ final ServletRegistrationBean<PortalRestAPIProxy> servletBean =
+ new ServletRegistrationBean<>(servlet, PortalApiConstants.API_PREFIX + "/*");
+ servletBean.setName("PortalRestApiProxyServlet");
+ return servletBean;
+ }
- @Bean
- public PortalAuthManager portalAuthManager() throws Exception {
- PortalAuthManager mockManager = mock(PortalAuthManager.class);
- final Map<String, String> credentialsMap = new HashMap<>();
- credentialsMap.put("appName", "appName");
- credentialsMap.put(PORTAL_USERNAME_HEADER_KEY, PORTAL_USERNAME_HEADER_KEY);
- credentialsMap.put(PORTAL_PASSWORD_HEADER_KEY, PORTAL_PASSWORD_HEADER_KEY);
- doAnswer(inv -> {
- logger.debug("getAppCredentials");
- return credentialsMap;
- }).when(mockManager).getAppCredentials();
- doAnswer(inv -> {
- logger.debug("getUserId");
- return "userId";
- }).when(mockManager).validateEcompSso(any(HttpServletRequest.class));
- doAnswer(inv -> {
- logger.debug("getAppCredentials");
- return credentialsMap;
- }).when(mockManager).getAppCredentials();
- return mockManager;
- }
+ @Bean
+ public PortalAuthManager portalAuthManager() throws Exception {
+ PortalAuthManager mockManager = mock(PortalAuthManager.class);
+ final Map<String, String> credentialsMap = new HashMap<>();
+ credentialsMap.put("appName", "appName");
+ credentialsMap.put(PORTAL_USERNAME_HEADER_KEY, PORTAL_USERNAME_HEADER_KEY);
+ credentialsMap.put(PORTAL_PASSWORD_HEADER_KEY, PORTAL_PASSWORD_HEADER_KEY);
+ doAnswer(inv -> {
+ logger.debug("getAppCredentials");
+ return credentialsMap;
+ }).when(mockManager).getAppCredentials();
+ doAnswer(inv -> {
+ logger.debug("getUserId");
+ return "userId";
+ }).when(mockManager).validateEcompSso(any(HttpServletRequest.class));
+ doAnswer(inv -> {
+ logger.debug("getAppCredentials");
+ return credentialsMap;
+ }).when(mockManager).getAppCredentials();
+ return mockManager;
+ }
}
diff --git a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/WebSecurityMockConfiguration.java b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/WebSecurityMockConfiguration.java
index 80cde66..3e75606 100644
--- a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/WebSecurityMockConfiguration.java
+++ b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/WebSecurityMockConfiguration.java
@@ -42,43 +42,43 @@
@Profile("test")
public class WebSecurityMockConfiguration extends WebSecurityConfigurerAdapter {
- public static final String TEST_CRED_ADMIN = "admin";
- public static final String TEST_CRED_STANDARD = "standard";
+ public static final String TEST_CRED_ADMIN = "admin";
+ public static final String TEST_CRED_STANDARD = "standard";
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- public WebSecurityMockConfiguration(@Value("${userfile}") final String userFilePath) {
- logger.debug("ctor: user file path {}", userFilePath);
- }
+ public WebSecurityMockConfiguration(@Value("${userfile}") final String userFilePath) {
+ logger.debug("ctor: user file path {}", userFilePath);
+ }
- @Override
- protected void configure(AuthenticationManagerBuilder auth) throws Exception {
- PasswordEncoder encoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
- auth.inMemoryAuthentication() //
- .passwordEncoder(encoder) //
- // The admin user has the admin AND standard roles
- .withUser(TEST_CRED_ADMIN) //
- .password(encoder.encode(TEST_CRED_ADMIN))
- .roles(DashboardConstants.ROLE_NAME_ADMIN, DashboardConstants.ROLE_NAME_STANDARD)//
- .and()//
- // The standard user has only the standard role
- .withUser(TEST_CRED_STANDARD) //
- .password(encoder.encode(TEST_CRED_STANDARD)) //
- .roles(DashboardConstants.ROLE_NAME_STANDARD);
- }
+ @Override
+ protected void configure(AuthenticationManagerBuilder auth) throws Exception {
+ PasswordEncoder encoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
+ auth.inMemoryAuthentication() //
+ .passwordEncoder(encoder) //
+ // The admin user has the admin AND standard roles
+ .withUser(TEST_CRED_ADMIN) //
+ .password(encoder.encode(TEST_CRED_ADMIN))
+ .roles(DashboardConstants.ROLE_NAME_ADMIN, DashboardConstants.ROLE_NAME_STANDARD)//
+ .and()//
+ // The standard user has only the standard role
+ .withUser(TEST_CRED_STANDARD) //
+ .password(encoder.encode(TEST_CRED_STANDARD)) //
+ .roles(DashboardConstants.ROLE_NAME_STANDARD);
+ }
- @Override
- protected void configure(HttpSecurity http) throws Exception {
- http.authorizeRequests().anyRequest().authenticated()//
- .and().httpBasic() //
- .and().csrf().disable();
- }
+ @Override
+ protected void configure(HttpSecurity http) throws Exception {
+ http.authorizeRequests().anyRequest().authenticated()//
+ .and().httpBasic() //
+ .and().csrf().disable();
+ }
- @Override
- public void configure(WebSecurity web) throws Exception {
- // This disables Spring security, but not the app's filter.
- web.ignoring().antMatchers(WebSecurityConfiguration.OPEN_PATHS);
- web.ignoring().antMatchers("/", "/csrf"); // allow swagger-ui to load
- }
+ @Override
+ public void configure(WebSecurity web) throws Exception {
+ // This disables Spring security, but not the app's filter.
+ web.ignoring().antMatchers(WebSecurityConfiguration.OPEN_PATHS);
+ web.ignoring().antMatchers("/", "/csrf"); // allow swagger-ui to load
+ }
}
diff --git a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/AbstractControllerTest.java b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/AbstractControllerTest.java
index d4163f0..09d3a86 100644
--- a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/AbstractControllerTest.java
+++ b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/AbstractControllerTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -44,69 +44,69 @@
@ActiveProfiles("test")
public class AbstractControllerTest {
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- // Created by Spring black magic
- // https://spring.io/guides/gs/testing-web/
- @LocalServerPort
- private int localServerPort;
+ // Created by Spring black magic
+ // https://spring.io/guides/gs/testing-web/
+ @LocalServerPort
+ private int localServerPort;
- @Autowired
- protected TestRestTemplate restTemplate;
+ @Autowired
+ protected TestRestTemplate restTemplate;
- /**
- * Flexible URI builder.
- *
- * @param queryParams
- * Map of string-string query parameters
- * @param path
- * Array of path components. If a component has an
- * embedded slash, the string is split and each
- * subcomponent is added individually.
- * @return URI
- */
- protected URI buildUri(final Map<String, String> queryParams, final String... path) {
- UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:" + localServerPort + "/");
- for (int p = 0; p < path.length; ++p) {
- if (path[p] == null || path[p].isEmpty()) {
- throw new IllegalArgumentException("Unexpected null or empty at path index " + Integer.toString(p));
- } else if (path[p].contains("/")) {
- String[] subpaths = path[p].split("/");
- for (String s : subpaths)
- if (!s.isEmpty())
- builder.pathSegment(s);
- } else {
- builder.pathSegment(path[p]);
- }
- }
- if (queryParams != null && queryParams.size() > 0) {
- for (Map.Entry<String, String> entry : queryParams.entrySet()) {
- if (entry.getKey() == null || entry.getValue() == null)
- throw new IllegalArgumentException("Unexpected null key or value");
- else
- builder.queryParam(entry.getKey(), entry.getValue());
- }
- }
- return builder.build().encode().toUri();
- }
+ /**
+ * Flexible URI builder.
+ *
+ * @param queryParams
+ * Map of string-string query parameters
+ * @param path
+ * Array of path components. If a component has an
+ * embedded slash, the string is split and each
+ * subcomponent is added individually.
+ * @return URI
+ */
+ protected URI buildUri(final Map<String, String> queryParams, final String... path) {
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:" + localServerPort + "/");
+ for (int p = 0; p < path.length; ++p) {
+ if (path[p] == null || path[p].isEmpty()) {
+ throw new IllegalArgumentException("Unexpected null or empty at path index " + Integer.toString(p));
+ } else if (path[p].contains("/")) {
+ String[] subpaths = path[p].split("/");
+ for (String s : subpaths)
+ if (!s.isEmpty())
+ builder.pathSegment(s);
+ } else {
+ builder.pathSegment(path[p]);
+ }
+ }
+ if (queryParams != null && queryParams.size() > 0) {
+ for (Map.Entry<String, String> entry : queryParams.entrySet()) {
+ if (entry.getKey() == null || entry.getValue() == null)
+ throw new IllegalArgumentException("Unexpected null key or value");
+ else
+ builder.queryParam(entry.getKey(), entry.getValue());
+ }
+ }
+ return builder.build().encode().toUri();
+ }
- // Because I put the annotations on this parent class,
- // must define at least one test here.
- @Test
- public void contextLoads() {
- // Silence Sonar warning about missing assertion.
- Assertions.assertTrue(logger.isWarnEnabled());
- logger.info("Context loads on mock profile");
- }
+ // Because I put the annotations on this parent class,
+ // must define at least one test here.
+ @Test
+ public void contextLoads() {
+ // Silence Sonar warning about missing assertion.
+ Assertions.assertTrue(logger.isWarnEnabled());
+ logger.info("Context loads on mock profile");
+ }
- public TestRestTemplate testRestTemplateAdminRole() {
- return restTemplate.withBasicAuth(WebSecurityMockConfiguration.TEST_CRED_ADMIN,
- WebSecurityMockConfiguration.TEST_CRED_ADMIN);
- }
+ public TestRestTemplate testRestTemplateAdminRole() {
+ return restTemplate.withBasicAuth(WebSecurityMockConfiguration.TEST_CRED_ADMIN,
+ WebSecurityMockConfiguration.TEST_CRED_ADMIN);
+ }
- public TestRestTemplate testRestTemplateStandardRole() {
- return restTemplate.withBasicAuth(WebSecurityMockConfiguration.TEST_CRED_STANDARD,
- WebSecurityMockConfiguration.TEST_CRED_STANDARD);
- }
+ public TestRestTemplate testRestTemplateStandardRole() {
+ return restTemplate.withBasicAuth(WebSecurityMockConfiguration.TEST_CRED_STANDARD,
+ WebSecurityMockConfiguration.TEST_CRED_STANDARD);
+ }
}
diff --git a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/DefaultContextTest.java b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/DefaultContextTest.java
index 48c5931..643f15e 100644
--- a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/DefaultContextTest.java
+++ b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/DefaultContextTest.java
@@ -36,13 +36,13 @@
@SpringBootTest
public class DefaultContextTest {
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- @Test
- public void contextLoads() {
- // Silence Sonar warning about missing assertion.
- Assertions.assertTrue(logger.isWarnEnabled());
- logger.info("Context loads on default profile");
- }
+ @Test
+ public void contextLoads() {
+ // Silence Sonar warning about missing assertion.
+ Assertions.assertTrue(logger.isWarnEnabled());
+ logger.info("Context loads on default profile");
+ }
}
diff --git a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/PortalRestCentralServiceTest.java b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/PortalRestCentralServiceTest.java
index dc80968..1e8d3a3 100644
--- a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/PortalRestCentralServiceTest.java
+++ b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/PortalRestCentralServiceTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -41,77 +41,78 @@
public class PortalRestCentralServiceTest extends AbstractControllerTest {
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- @Test
- public void getAnalyticsTest() {
- // paths are hardcoded here exactly like the EPSDK-FW library :(
- URI uri = buildUri(null, PortalApiConstants.API_PREFIX, "/analytics");
- logger.info("Invoking {}", uri);
- ResponseEntity<String> response = restTemplate.exchange(uri, HttpMethod.GET, null, String.class);
- // No Portal is available so this always fails
- Assertions.assertTrue(response.getStatusCode().is4xxClientError());
- }
+ @Test
+ public void getAnalyticsTest() {
+ // paths are hardcoded here exactly like the EPSDK-FW library :(
+ URI uri = buildUri(null, PortalApiConstants.API_PREFIX, "/analytics");
+ logger.info("Invoking {}", uri);
+ ResponseEntity<String> response = restTemplate.exchange(uri, HttpMethod.GET, null, String.class);
+ // No Portal is available so this always fails
+ Assertions.assertTrue(response.getStatusCode().is4xxClientError());
+ }
- @Test
- public void getErrorPageTest() {
- // Send unauthorized request
- URI uri = buildUri(null, "/favicon.ico");
- logger.info("Invoking {}", uri);
- ResponseEntity<String> response = restTemplate.exchange(uri, HttpMethod.GET, null, String.class);
- Assertions.assertTrue(response.getStatusCode().is4xxClientError());
- Assertions.assertTrue(response.getBody().contains("Static error page"));
- }
+ @Test
+ public void getErrorPageTest() {
+ // Send unauthorized request
+ URI uri = buildUri(null, "/favicon.ico");
+ logger.info("Invoking {}", uri);
+ ResponseEntity<String> response = restTemplate.exchange(uri, HttpMethod.GET, null, String.class);
+ Assertions.assertTrue(response.getStatusCode().is4xxClientError());
+ Assertions.assertTrue(response.getBody().contains("Static error page"));
+ }
- private HttpEntity<Object> getEntityWithHeaders(Object body) {
- HttpHeaders headers = new HttpHeaders();
- headers.set(PortalApIMockConfiguration.PORTAL_USERNAME_HEADER_KEY,
- PortalApIMockConfiguration.PORTAL_USERNAME_HEADER_KEY);
- headers.set(PortalApIMockConfiguration.PORTAL_PASSWORD_HEADER_KEY,
- PortalApIMockConfiguration.PORTAL_PASSWORD_HEADER_KEY);
- HttpEntity<Object> entity = new HttpEntity<>(body, headers);
- return entity;
- }
+ private HttpEntity<Object> getEntityWithHeaders(Object body) {
+ HttpHeaders headers = new HttpHeaders();
+ headers.set(PortalApIMockConfiguration.PORTAL_USERNAME_HEADER_KEY,
+ PortalApIMockConfiguration.PORTAL_USERNAME_HEADER_KEY);
+ headers.set(PortalApIMockConfiguration.PORTAL_PASSWORD_HEADER_KEY,
+ PortalApIMockConfiguration.PORTAL_PASSWORD_HEADER_KEY);
+ HttpEntity<Object> entity = new HttpEntity<>(body, headers);
+ return entity;
+ }
- private EcompUser createEcompUser(String loginId) {
- EcompUser user = new EcompUser();
- user.setLoginId(loginId);
- EcompRole role = new EcompRole();
- role.setRoleFunctions(Collections.EMPTY_SET);
- role.setId(1L);
- role.setName(DashboardConstants.ROLE_NAME_ADMIN);
- Set<EcompRole> roles = new HashSet<>();
- roles.add(role);
- user.setRoles(roles);
- return user;
- }
+ private EcompUser createEcompUser(String loginId) {
+ EcompUser user = new EcompUser();
+ user.setLoginId(loginId);
+ EcompRole role = new EcompRole();
+ role.setRoleFunctions(Collections.EMPTY_SET);
+ role.setId(1L);
+ role.setName(DashboardConstants.ROLE_NAME_ADMIN);
+ Set<EcompRole> roles = new HashSet<>();
+ roles.add(role);
+ user.setRoles(roles);
+ return user;
+ }
-/* @Test
- public void createUserTest() {
- final String loginId = "login1";
- URI create = buildUri(null, PortalApiConstants.API_PREFIX, "user");
- logger.info("Invoking {}", create);
- HttpEntity<Object> requestEntity = getEntityWithHeaders(createEcompUser(loginId));
- ResponseEntity<String> response = restTemplate.exchange(create, HttpMethod.POST, requestEntity, String.class);
- Assertions.assertTrue(response.getStatusCode().is2xxSuccessful());
- }
-
- @Test
- public void updateUserTest() {
- final String loginId = "login2";
- URI create = buildUri(null, PortalApiConstants.API_PREFIX, "user");
- EcompUser user = createEcompUser(loginId);
- logger.info("Invoking {}", create);
- HttpEntity<Object> requestEntity = getEntityWithHeaders(user);
- // Create
- ResponseEntity<String> response = restTemplate.exchange(create, HttpMethod.POST, requestEntity, String.class);
- Assertions.assertTrue(response.getStatusCode().is2xxSuccessful());
- URI update = buildUri(null, PortalApiConstants.API_PREFIX, "user", loginId);
- user.setEmail("user@company.org");
- requestEntity = getEntityWithHeaders(user);
- response = restTemplate.exchange(update, HttpMethod.POST, requestEntity, String.class);
- Assertions.assertTrue(response.getStatusCode().is2xxSuccessful());
- }
-*/
+ /*
+ * @Test
+ * public void createUserTest() {
+ * final String loginId = "login1";
+ * URI create = buildUri(null, PortalApiConstants.API_PREFIX, "user");
+ * logger.info("Invoking {}", create);
+ * HttpEntity<Object> requestEntity = getEntityWithHeaders(createEcompUser(loginId));
+ * ResponseEntity<String> response = restTemplate.exchange(create, HttpMethod.POST, requestEntity, String.class);
+ * Assertions.assertTrue(response.getStatusCode().is2xxSuccessful());
+ * }
+ *
+ * @Test
+ * public void updateUserTest() {
+ * final String loginId = "login2";
+ * URI create = buildUri(null, PortalApiConstants.API_PREFIX, "user");
+ * EcompUser user = createEcompUser(loginId);
+ * logger.info("Invoking {}", create);
+ * HttpEntity<Object> requestEntity = getEntityWithHeaders(user);
+ * // Create
+ * ResponseEntity<String> response = restTemplate.exchange(create, HttpMethod.POST, requestEntity, String.class);
+ * Assertions.assertTrue(response.getStatusCode().is2xxSuccessful());
+ * URI update = buildUri(null, PortalApiConstants.API_PREFIX, "user", loginId);
+ * user.setEmail("user@company.org");
+ * requestEntity = getEntityWithHeaders(user);
+ * response = restTemplate.exchange(update, HttpMethod.POST, requestEntity, String.class);
+ * Assertions.assertTrue(response.getStatusCode().is2xxSuccessful());
+ * }
+ */
}