[DEV] update back with archidata and upgrade
This commit is contained in:
parent
b4819532d8
commit
645fcfb3d2
401
Formatter.xml
Normal file
401
Formatter.xml
Normal file
@ -0,0 +1,401 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<profiles version="23">
|
||||||
|
<profile kind="CodeFormatterProfile" name="EWOL" version="23">
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" 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_before_comma_in_allocation_expression" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment" value="common_lines"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" 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.insert_new_line_after_annotation_on_package" value="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_before_closing_paren_in_while" 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.comment.format_javadoc_comments" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration" value="preserve_positions"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.align_with_spaces" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
|
||||||
|
<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.comment.indent_root_tags" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_record_components" value="49"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
|
||||||
|
<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.wrap_before_multiplicative_operator" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
|
||||||
|
<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_prefix_operator" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="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_new_line_after_annotation_on_method" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_logical_operator" value="16"/>
|
||||||
|
<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.keep_annotation_declaration_on_one_line" value="one_line_if_empty"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_record_declaration" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator" 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_between_empty_parens_in_method_invocation" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" 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_after_opening_paren_in_for" value="do not insert"/>
|
||||||
|
<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.insert_new_line_after_annotation_on_local_variable" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method" value="1"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line" value="one_line_never"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns" value="false"/>
|
||||||
|
<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.alignment_for_union_type_in_multicatch" value="16"/>
|
||||||
|
<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.keep_else_statement_on_same_line" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause" value="common_lines"/>
|
||||||
|
<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_before_comma_in_array_initializer" 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.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line" value="one_line_if_empty"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_before_shift_operator" 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.brace_position_for_block" value="end_of_line"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_parameters" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_loops" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_before_switch_case_arrow_operator" value="false"/>
|
||||||
|
<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_before_unary_operator" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation" value="common_lines"/>
|
||||||
|
<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_semicolon_in_try_resources" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enum_constant" value="0"/>
|
||||||
|
<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_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.text_block_indentation" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_module_statements" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
|
||||||
|
<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.comment.align_tags_names_descriptions" value="false"/>
|
||||||
|
<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.keep_if_then_body_block_on_one_line" value="one_line_if_empty"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
|
||||||
|
<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_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_permitted_types" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
|
||||||
|
<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.alignment_for_conditional_expression_chain" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_annotations" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_before_assertion_message_operator" value="true"/>
|
||||||
|
<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.alignment_for_method_declaration" value="1"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines" value="2147483647"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
|
||||||
|
<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.never_indent_block_comments_on_first_column" value="false"/>
|
||||||
|
<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_comma_in_allocation_expression" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
|
||||||
|
<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_after_not_operator" 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_space_after_opening_brace_in_array_initializer" value="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.comment.format_html" value="true"/>
|
||||||
|
<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.parentheses_positions_in_method_delcaration" value="common_lines"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_arguments" value="0"/>
|
||||||
|
<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_opening_paren_in_enum_constant" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="0"/>
|
||||||
|
<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.alignment_for_annotations_on_package" value="49"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
|
||||||
|
<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_space_before_assignment_operator" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
|
||||||
|
<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_comma_in_method_declaration_parameters" 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_after_arrow_in_switch_case" value="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_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_permitted_types_in_type_declaration" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_record_header" value="true"/>
|
||||||
|
<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_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
|
||||||
|
<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.wrap_before_bitwise_operator" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.javadoc_do_not_separate_block_tags" value="false"/>
|
||||||
|
<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_before_lambda_arrow" value="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.comment.indent_tag_description" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_record_constructor" value="end_of_line"/>
|
||||||
|
<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_between_brackets_in_array_type_reference" 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.alignment_for_string_concatenation" value="16"/>
|
||||||
|
<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_opening_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
|
||||||
|
<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_before_prefix_operator" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_shift_operator" 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_after_comma_in_type_parameters" value="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_after_shift_operator" value="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_before_comma_in_multiple_local_declarations" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line" value="false"/>
|
||||||
|
<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_comma_in_record_components" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/>
|
||||||
|
<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_before_opening_paren_in_synchronized" value="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.alignment_for_expressions_in_for_loop_header" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_before_additive_operator" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line" value="false"/>
|
||||||
|
<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_opening_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_record_declaration" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_relational_operator" value="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.blank_lines_between_import_groups" value="1"/>
|
||||||
|
<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_after_logical_operator" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation" value="common_lines"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_record_declaration" value="common_lines"/>
|
||||||
|
<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.parentheses_positions_in_switch_statement" value="common_lines"/>
|
||||||
|
<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_comma_in_for_increments" 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_arrow_in_switch_default" value="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.disabling_tag" value="@formatter:off"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement" value="common_lines"/>
|
||||||
|
<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_before_parenthesized_expression_in_return" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_switch_body_block_on_one_line" value="one_line_never"/>
|
||||||
|
<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_after_opening_paren_in_catch" 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_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
|
||||||
|
<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_opening_paren_in_annotation" 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.alignment_for_expressions_in_switch_case_with_arrow" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="200"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_method_body_on_one_line" value="one_line_if_empty"/>
|
||||||
|
<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.keep_loop_body_block_on_one_line" value="one_line_if_empty"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line" value="one_line_if_empty"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_additive_operator" value="16"/>
|
||||||
|
<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_before_opening_brace_in_record_constructor" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_relational_operator" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line" value="one_line_if_empty"/>
|
||||||
|
<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_after_question_in_conditional" value="insert"/>
|
||||||
|
<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_lambda_body" value="end_of_line"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
|
||||||
|
<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_opening_paren_in_catch" value="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_after_comma_in_method_invocation_arguments" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" 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.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_relational_operator" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
|
||||||
|
<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_additive_operator" value="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_comma_in_type_arguments" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.align_selector_in_method_invocation_on_expression_first_line" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_record_declaration" value="end_of_line"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_switch_case_with_arrow_on_one_line" value="one_line_never"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_colon" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type" value="49"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable" value="49"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_additive_operator" value="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_before_opening_paren_in_while" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
|
||||||
|
<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.alignment_for_annotations_on_field" value="49"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_before_conditional_operator" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
|
||||||
|
<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_paren_in_synchronized" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_shift_operator" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause" value="common_lines"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_code_block_on_one_line" value="one_line_if_empty"/>
|
||||||
|
<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_record_components" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator" value="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_colon_in_conditional" value="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_after_semicolon_in_try_resources" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
|
||||||
|
<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_opening_paren_in_record_declaration" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_before_assignment_operator" value="false"/>
|
||||||
|
<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.brace_position_for_switch" value="end_of_line"/>
|
||||||
|
<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_after_comma_in_method_declaration_parameters" value="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.alignment_for_switch_case_with_arrow" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line" value="one_line_if_empty"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method" value="49"/>
|
||||||
|
<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.keep_record_constructor_on_one_line" value="one_line_never"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_declaration" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assertion_message" value="0"/>
|
||||||
|
<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.blank_lines_before_new_chunk" value="1"/>
|
||||||
|
<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_paren_in_constructor_declaration" value="do not 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_closing_angle_bracket_in_type_arguments" 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.blank_lines_before_member_type" value="1"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_logical_operator" value="insert"/>
|
||||||
|
<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_superinterfaces_in_record_declaration" value="33"/>
|
||||||
|
<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_before_semicolon" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_before_relational_operator" value="true"/>
|
||||||
|
<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_opening_angle_bracket_in_type_arguments" 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.comment.format_block_comments" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="48"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_before_logical_operator" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch" value="0"/>
|
||||||
|
<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_after_comma_in_annotation" value="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.parentheses_positions_in_lambda_declaration" value="common_lines"/>
|
||||||
|
<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_after_comma_in_permitted_types" value="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.keep_enum_declaration_on_one_line" value="one_line_never"/>
|
||||||
|
<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.brace_position_for_enum_constant" 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.insert_space_before_multiplicative_operator" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
|
||||||
|
<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_comma_in_for_increments" 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_comma_in_explicitconstructorcall_arguments" 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.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
|
||||||
|
<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_comma_in_constructor_declaration_throws" 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_question_in_conditional" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block" value="0"/>
|
||||||
|
<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.tabulation.char" value="tab"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_before_string_concatenation" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
|
||||||
|
<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_before_opening_paren_in_switch" value="insert"/>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
@ -20,7 +20,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>kangaroo-and-rabbit</groupId>
|
<groupId>kangaroo-and-rabbit</groupId>
|
||||||
<artifactId>archidata</artifactId>
|
<artifactId>archidata</artifactId>
|
||||||
<version>0.6.2</version>
|
<version>0.8.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
|
181
back/src/org/kar/karso/WebLauncher.java
Executable file
181
back/src/org/kar/karso/WebLauncher.java
Executable file
@ -0,0 +1,181 @@
|
|||||||
|
package org.kar.karso;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import org.glassfish.grizzly.http.server.HttpServer;
|
||||||
|
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
|
||||||
|
import org.glassfish.jersey.jackson.JacksonFeature;
|
||||||
|
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
||||||
|
import org.glassfish.jersey.server.ResourceConfig;
|
||||||
|
import org.kar.archidata.GlobalConfiguration;
|
||||||
|
import org.kar.archidata.UpdateJwtPublicKey;
|
||||||
|
import org.kar.archidata.api.DataResource;
|
||||||
|
import org.kar.archidata.backup.BackupEngine;
|
||||||
|
import org.kar.archidata.backup.BackupEngine.StoreMode;
|
||||||
|
import org.kar.archidata.catcher.ExceptionCatcher;
|
||||||
|
import org.kar.archidata.catcher.FailException404API;
|
||||||
|
import org.kar.archidata.catcher.FailExceptionCatcher;
|
||||||
|
import org.kar.archidata.catcher.InputExceptionCatcher;
|
||||||
|
import org.kar.archidata.catcher.SystemExceptionCatcher;
|
||||||
|
import org.kar.archidata.db.DBConfig;
|
||||||
|
import org.kar.archidata.filter.CORSFilter;
|
||||||
|
import org.kar.archidata.filter.OptionFilter;
|
||||||
|
import org.kar.archidata.migration.MigrationEngine;
|
||||||
|
import org.kar.archidata.migration.model.Migration;
|
||||||
|
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||||
|
import org.kar.archidata.tools.JWTWrapper;
|
||||||
|
import org.kar.karso.api.ApplicationResource;
|
||||||
|
import org.kar.karso.api.ApplicationTokenResource;
|
||||||
|
import org.kar.karso.api.Front;
|
||||||
|
import org.kar.karso.api.HealthCheck;
|
||||||
|
import org.kar.karso.api.PublicKeyResource;
|
||||||
|
import org.kar.karso.api.RightResource;
|
||||||
|
import org.kar.karso.api.SystemConfigResource;
|
||||||
|
import org.kar.karso.api.UserResource;
|
||||||
|
import org.kar.karso.filter.KarsoAuthenticationFilter;
|
||||||
|
import org.kar.karso.migration.Initialization;
|
||||||
|
import org.kar.karso.migration.Migration20231015;
|
||||||
|
import org.kar.karso.migration.Migration20231126;
|
||||||
|
import org.kar.karso.model.Application;
|
||||||
|
import org.kar.karso.model.ApplicationToken;
|
||||||
|
import org.kar.karso.model.Right;
|
||||||
|
import org.kar.karso.model.RightDescription;
|
||||||
|
import org.kar.karso.model.Settings;
|
||||||
|
import org.kar.karso.model.UserAuth;
|
||||||
|
import org.kar.karso.util.ConfigVariable;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import jakarta.ws.rs.core.UriBuilder;
|
||||||
|
|
||||||
|
public class WebLauncher {
|
||||||
|
final static Logger LOGGER = LoggerFactory.getLogger(WebLauncher.class);
|
||||||
|
public static DBConfig dbConfig;
|
||||||
|
protected UpdateJwtPublicKey keyUpdater = null;
|
||||||
|
protected HttpServer server = null;
|
||||||
|
protected BackupEngine backupEngine = new BackupEngine("./backup", StoreMode.JSON);
|
||||||
|
|
||||||
|
public WebLauncher() {
|
||||||
|
ConfigBaseVariable.bdDatabase = "karso";
|
||||||
|
|
||||||
|
this.backupEngine.addClass(Migration.class);
|
||||||
|
this.backupEngine.addClass(Settings.class);
|
||||||
|
this.backupEngine.addClass(UserAuth.class);
|
||||||
|
this.backupEngine.addClass(Application.class);
|
||||||
|
this.backupEngine.addClass(ApplicationToken.class);
|
||||||
|
this.backupEngine.addClass(RightDescription.class);
|
||||||
|
this.backupEngine.addClass(Right.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static URI getBaseURI() {
|
||||||
|
return UriBuilder.fromUri(ConfigBaseVariable.getlocalAddress()).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void migrateDB() throws Exception {
|
||||||
|
WebLauncher.LOGGER.info("Create migration engine");
|
||||||
|
final MigrationEngine migrationEngine = new MigrationEngine();
|
||||||
|
WebLauncher.LOGGER.info("Add initialization");
|
||||||
|
migrationEngine.setInit(new Initialization());
|
||||||
|
WebLauncher.LOGGER.info("Add migration since last version");
|
||||||
|
migrationEngine.add(new Migration20231015());
|
||||||
|
migrationEngine.add(new Migration20231126());
|
||||||
|
WebLauncher.LOGGER.info("Migrate the DB [START]");
|
||||||
|
migrationEngine.migrateWaitAdmin(GlobalConfiguration.dbConfig);
|
||||||
|
WebLauncher.LOGGER.info("Migrate the DB [STOP]");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(final String[] args) throws Exception {
|
||||||
|
WebLauncher.LOGGER.info("[START] application wake UP");
|
||||||
|
final WebLauncher launcher = new WebLauncher();
|
||||||
|
launcher.migrateDB();
|
||||||
|
launcher.process();
|
||||||
|
WebLauncher.LOGGER.info("end-configure the server & wait finish process:");
|
||||||
|
Thread.currentThread().join();
|
||||||
|
WebLauncher.LOGGER.info("STOP the REST server");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void process() throws InterruptedException {
|
||||||
|
try {
|
||||||
|
JWTWrapper.initLocalToken(ConfigVariable.getUUIDKeyRoot());
|
||||||
|
} catch (final Exception e1) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e1.printStackTrace();
|
||||||
|
LOGGER.info("Wait 10 seconds ....");
|
||||||
|
Thread.sleep(10000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===================================================================
|
||||||
|
// Configure resources
|
||||||
|
// ===================================================================
|
||||||
|
final ResourceConfig rc = new ResourceConfig();
|
||||||
|
|
||||||
|
// add multi-part models ..
|
||||||
|
rc.register(MultiPartFeature.class);
|
||||||
|
// global authentication system
|
||||||
|
rc.register(OptionFilter.class);
|
||||||
|
// remove cors ==> all time called by an other system...
|
||||||
|
rc.register(CORSFilter.class);
|
||||||
|
// global authentication system
|
||||||
|
rc.register(KarsoAuthenticationFilter.class);
|
||||||
|
// register exception catcher
|
||||||
|
rc.register(InputExceptionCatcher.class);
|
||||||
|
rc.register(SystemExceptionCatcher.class);
|
||||||
|
rc.register(FailExceptionCatcher.class);
|
||||||
|
rc.register(FailException404API.class);
|
||||||
|
rc.register(ExceptionCatcher.class);
|
||||||
|
// add default resource:
|
||||||
|
rc.register(DataResource.class);
|
||||||
|
rc.register(ApplicationResource.class);
|
||||||
|
rc.register(ApplicationTokenResource.class);
|
||||||
|
rc.register(PublicKeyResource.class);
|
||||||
|
rc.register(RightResource.class);
|
||||||
|
rc.register(SystemConfigResource.class);
|
||||||
|
rc.register(UserResource.class);
|
||||||
|
|
||||||
|
rc.register(HealthCheck.class);
|
||||||
|
rc.register(Front.class);
|
||||||
|
|
||||||
|
// add jackson to be discover when we are ins stand-alone server
|
||||||
|
rc.register(JacksonFeature.class);
|
||||||
|
// enable this to show low level request
|
||||||
|
//rc.property(LoggingFeature.LOGGING_FEATURE_LOGGER_LEVEL_SERVER, Level.WARNING.getName());
|
||||||
|
|
||||||
|
this.server = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc);
|
||||||
|
final HttpServer serverLink = this.server;
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
System.out.println("Stopping server..");
|
||||||
|
serverLink.shutdownNow();
|
||||||
|
}
|
||||||
|
}, "shutdownHook"));
|
||||||
|
|
||||||
|
// ===================================================================
|
||||||
|
// run JERSEY
|
||||||
|
// ===================================================================
|
||||||
|
try {
|
||||||
|
this.server.start();
|
||||||
|
LOGGER.info("Jersey app started at {}", getBaseURI());
|
||||||
|
} catch (final Exception e) {
|
||||||
|
LOGGER.error("There was an error while starting Grizzly HTTP server.");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stop() {
|
||||||
|
if (this.server != null) {
|
||||||
|
this.server.shutdownNow();
|
||||||
|
while (this.server.isStarted()) {
|
||||||
|
LOGGER.info("wait stop");
|
||||||
|
try {
|
||||||
|
Thread.sleep(200);
|
||||||
|
} catch (final InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.server = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,35 +1,47 @@
|
|||||||
|
|
||||||
package org.kar.karso;
|
package org.kar.karso;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.kar.archidata.api.DataResource;
|
||||||
|
import org.kar.archidata.dataAccess.DataFactoryTsApi;
|
||||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||||
|
import org.kar.karso.api.ApplicationResource;
|
||||||
|
import org.kar.karso.api.ApplicationTokenResource;
|
||||||
|
import org.kar.karso.api.Front;
|
||||||
|
import org.kar.karso.api.PublicKeyResource;
|
||||||
|
import org.kar.karso.api.RightResource;
|
||||||
|
import org.kar.karso.api.SystemConfigResource;
|
||||||
|
import org.kar.karso.api.UserResource;
|
||||||
|
import org.kar.karso.migration.Initialization;
|
||||||
import org.kar.karso.util.ConfigVariable;
|
import org.kar.karso.util.ConfigVariable;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class WebLauncherLocal extends WebLauncher {
|
public class WebLauncherLocal extends WebLauncher {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(WebLauncherLocal.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(WebLauncherLocal.class);
|
||||||
|
|
||||||
private WebLauncherLocal() {}
|
private WebLauncherLocal() {}
|
||||||
|
|
||||||
public static void main(final String[] args) throws InterruptedException {
|
public static void main(final String[] args) throws Exception {
|
||||||
|
DataFactoryTsApi.generatePackage(
|
||||||
|
List.of(Front.class, DataResource.class, ApplicationResource.class, ApplicationTokenResource.class,
|
||||||
|
PublicKeyResource.class, RightResource.class, UserResource.class, SystemConfigResource.class),
|
||||||
|
Initialization.CLASSES_BASE, "../front/src/back-api/");
|
||||||
final WebLauncherLocal launcher = new WebLauncherLocal();
|
final WebLauncherLocal launcher = new WebLauncherLocal();
|
||||||
launcher.process();
|
launcher.process();
|
||||||
LOGGER.info("end-configure the server & wait finish process:");
|
LOGGER.info("end-configure the server & wait finish process:");
|
||||||
Thread.currentThread().join();
|
Thread.currentThread().join();
|
||||||
LOGGER.info("STOP the REST server:");
|
LOGGER.info("STOP the REST server:");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process() throws InterruptedException {
|
public void process() throws InterruptedException {
|
||||||
if (true) {
|
if (true) {
|
||||||
// for local test:
|
|
||||||
ConfigBaseVariable.apiAdress = "http://0.0.0.0:15080/karso/api/";
|
ConfigBaseVariable.apiAdress = "http://0.0.0.0:15080/karso/api/";
|
||||||
ConfigBaseVariable.dbPort = "3906";
|
ConfigBaseVariable.dbPort = "3906";
|
||||||
// create a unique key for test ==> not retrieve the token every load...
|
// create a unique key for test ==> not retrieve the token every load...
|
||||||
ConfigVariable.uuid_for_key_generation = "lkjlkjlkjlmkjqmwlsdkjqfsdlkf88QJSDMLQKSndmLQKZNERMAL";
|
ConfigVariable.uuid_for_key_generation = "lkjlkjlkjlmkjqmwlsdkjqfsdlkf88QJSDMLQKSndmLQKZNERMAL";
|
||||||
//ConfigBaseVariable.dbType = "sqlite";
|
|
||||||
//ConfigBaseVariable.dbHost = "./bdd_base.sqlite";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
super.migrateDB();
|
super.migrateDB();
|
||||||
|
@ -5,12 +5,14 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.kar.archidata.annotation.AsyncType;
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DataAccess;
|
||||||
import org.kar.archidata.dataAccess.QueryAnd;
|
import org.kar.archidata.dataAccess.QueryAnd;
|
||||||
import org.kar.archidata.dataAccess.QueryCondition;
|
import org.kar.archidata.dataAccess.QueryCondition;
|
||||||
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
||||||
import org.kar.archidata.dataAccess.options.Condition;
|
import org.kar.archidata.dataAccess.options.Condition;
|
||||||
import org.kar.archidata.exception.InputException;
|
import org.kar.archidata.exception.InputException;
|
||||||
|
import org.kar.archidata.exception.SystemException;
|
||||||
import org.kar.archidata.filter.GenericContext;
|
import org.kar.archidata.filter.GenericContext;
|
||||||
import org.kar.archidata.tools.JWTWrapper;
|
import org.kar.archidata.tools.JWTWrapper;
|
||||||
import org.kar.karso.model.Application;
|
import org.kar.karso.model.Application;
|
||||||
@ -33,21 +35,21 @@ import jakarta.ws.rs.Produces;
|
|||||||
import jakarta.ws.rs.QueryParam;
|
import jakarta.ws.rs.QueryParam;
|
||||||
import jakarta.ws.rs.core.Context;
|
import jakarta.ws.rs.core.Context;
|
||||||
import jakarta.ws.rs.core.MediaType;
|
import jakarta.ws.rs.core.MediaType;
|
||||||
import jakarta.ws.rs.core.Response;
|
|
||||||
import jakarta.ws.rs.core.SecurityContext;
|
import jakarta.ws.rs.core.SecurityContext;
|
||||||
|
|
||||||
@Path("/application")
|
@Path("/application")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public class ApplicationResource {
|
public class ApplicationResource {
|
||||||
final Logger logger = LoggerFactory.getLogger(ApplicationResource.class);
|
final Logger logger = LoggerFactory.getLogger(ApplicationResource.class);
|
||||||
|
|
||||||
public ApplicationResource() {}
|
public ApplicationResource() {}
|
||||||
|
|
||||||
public List<Long> getUserListOfApplication(final Long userId) {
|
public List<Long> getUserListOfApplication(final Long userId) {
|
||||||
final List<Long> out = new ArrayList<>();
|
final List<Long> out = new ArrayList<>();
|
||||||
List<UserLinkApplication> links = null;
|
List<UserLinkApplication> links = null;
|
||||||
try {
|
try {
|
||||||
links = DataAccess.getsWhere(UserLinkApplication.class, new Condition(new QueryCondition("object1id", "=", userId)));
|
links = DataAccess.getsWhere(UserLinkApplication.class,
|
||||||
|
new Condition(new QueryCondition("object1id", "=", userId)));
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -60,12 +62,13 @@ public class ApplicationResource {
|
|||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Long> getListOfUsers(final Long applicationId) {
|
public List<Long> getListOfUsers(final Long applicationId) {
|
||||||
final List<Long> out = new ArrayList<>();
|
final List<Long> out = new ArrayList<>();
|
||||||
List<UserLinkApplication> links = null;
|
List<UserLinkApplication> links = null;
|
||||||
try {
|
try {
|
||||||
links = DataAccess.getsWhere(UserLinkApplication.class, new Condition(new QueryCondition("object2id", "=", applicationId)));
|
links = DataAccess.getsWhere(UserLinkApplication.class,
|
||||||
|
new Condition(new QueryCondition("object2id", "=", applicationId)));
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
final String result = "SERVER Internal error";
|
final String result = "SERVER Internal error";
|
||||||
@ -83,10 +86,10 @@ public class ApplicationResource {
|
|||||||
// Generic /application/
|
// Generic /application/
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed(value = { "USER", "ADMIN" })
|
@RolesAllowed(value = { "USER", "ADMIN" })
|
||||||
public List<Application> getApplications(@Context final SecurityContext sc) throws Exception {
|
public List<Application> gets(@Context final SecurityContext sc) throws Exception {
|
||||||
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
||||||
this.logger.debug("getApplications");
|
this.logger.debug("getApplications");
|
||||||
// TODO filter with the list of element available in his authorizations ...
|
// TODO filter with the list of element available in his authorizations ...
|
||||||
@ -103,7 +106,7 @@ public class ApplicationResource {
|
|||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Application create(final Application application) throws Exception {
|
public Application create(final Application application) throws Exception {
|
||||||
@ -113,7 +116,8 @@ public class ApplicationResource {
|
|||||||
throw new InputException("name", "create application (name too small: '" + application.name + "')");
|
throw new InputException("name", "create application (name too small: '" + application.name + "')");
|
||||||
}
|
}
|
||||||
if (application.redirect == null || application.redirect.length() < 6) {
|
if (application.redirect == null || application.redirect.length() < 6) {
|
||||||
throw new InputException("redirect", "create application (redirect too small: '" + application.redirect + "')");
|
throw new InputException("redirect",
|
||||||
|
"create application (redirect too small: '" + application.redirect + "')");
|
||||||
}
|
}
|
||||||
application.id = null;
|
application.id = null;
|
||||||
application.createdAt = null;
|
application.createdAt = null;
|
||||||
@ -121,29 +125,30 @@ public class ApplicationResource {
|
|||||||
application.updatedAt = null;
|
application.updatedAt = null;
|
||||||
return DataAccess.insert(application);
|
return DataAccess.insert(application);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Generic /application/{id}
|
// Generic /application/{id}
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Application get(@PathParam("id") final Long id) throws Exception {
|
public Application get(@PathParam("id") final Long id) throws Exception {
|
||||||
return DataAccess.get(Application.class, id);
|
return DataAccess.get(Application.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PATCH
|
@PATCH
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Application put(@PathParam("id") final Long id, final String jsonRequest) throws Exception {
|
public Application patch(@PathParam("id") final Long id, @AsyncType(Application.class) final String jsonRequest)
|
||||||
|
throws Exception {
|
||||||
DataAccess.updateWithJson(Application.class, id, jsonRequest);
|
DataAccess.updateWithJson(Application.class, id, jsonRequest);
|
||||||
return DataAccess.get(Application.class, id);
|
return DataAccess.get(Application.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@ -151,29 +156,29 @@ public class ApplicationResource {
|
|||||||
public void remove(@Context final SecurityContext sc, @PathParam("id") final long applicationId) throws Exception {
|
public void remove(@Context final SecurityContext sc, @PathParam("id") final long applicationId) throws Exception {
|
||||||
DataAccess.delete(Application.class, applicationId);
|
DataAccess.delete(Application.class, applicationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Generic /{id}/*
|
// Generic /{id}/*
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}/users")
|
@Path("{id}/users")
|
||||||
@RolesAllowed(value = { "ADMIN" })
|
@RolesAllowed(value = { "ADMIN" })
|
||||||
public List<Long> getApplicationUsers(@PathParam("id") final Long applicationId) throws Exception {
|
public List<Long> getApplicationUsers(@PathParam("id") final Long applicationId) throws Exception {
|
||||||
// special case for SSO: (all user have access on the SSO...).
|
// special case for SSO: (all user have access on the SSO...).
|
||||||
|
|
||||||
this.logger.debug("Request list of user for an applciation: {}", applicationId);
|
this.logger.debug("Request list of user for an applciation: {}", applicationId);
|
||||||
return getListOfUsers(applicationId);
|
return getListOfUsers(applicationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Generic /application/*
|
// Generic /application/*
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("small")
|
@Path("small")
|
||||||
@RolesAllowed(value = { "USER", "ADMIN" })
|
@RolesAllowed(value = { "USER", "ADMIN" })
|
||||||
@ -190,51 +195,65 @@ public class ApplicationResource {
|
|||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class AddUserData {
|
||||||
|
public long userId;
|
||||||
|
|
||||||
public record AddUserData(
|
public AddUserData(final long userId) {
|
||||||
long userId) {}
|
this.userId = userId;
|
||||||
|
}
|
||||||
// TODO : review the function to correct admin only access...
|
|
||||||
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/users")
|
@Path("{id}/users")
|
||||||
@RolesAllowed(value = { "ADMIN" })
|
@RolesAllowed(value = { "ADMIN" })
|
||||||
public boolean addUser(@PathParam("id") final Long applicationId, final AddUserData data) throws Exception {
|
public void addUser(@PathParam("id") final Long applicationId, final AddUserData data) throws Exception {
|
||||||
this.logger.debug("getApplications");
|
this.logger.debug("getApplications");
|
||||||
AddOnManyToMany.addLink(UserAuth.class, data.userId, "application", applicationId);
|
AddOnManyToMany.addLink(UserAuth.class, data.userId, "application", applicationId);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO : review the function to correct admin only access...
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}/users")
|
@Path("{id}/users/${userId}")
|
||||||
@RolesAllowed(value = { "ADMIN" })
|
@RolesAllowed(value = { "ADMIN" })
|
||||||
public boolean rmUser(@PathParam("id") final Long applicationId, final AddUserData data) throws Exception {
|
public void removeUser(@PathParam("id") final Long applicationId, @PathParam("userId") final Long userId)
|
||||||
|
throws Exception {
|
||||||
this.logger.debug("getApplications");
|
this.logger.debug("getApplications");
|
||||||
AddOnManyToMany.removeLink(UserAuth.class, data.userId, "application", applicationId);
|
AddOnManyToMany.removeLink(UserAuth.class, userId, "application", applicationId);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO : review the function to correct admin only access...
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}/rights")
|
@Path("{id}/rights")
|
||||||
@RolesAllowed(value = { "ADMIN" })
|
@RolesAllowed(value = { "ADMIN" })
|
||||||
public List<RightDescription> getRightsDescription(@PathParam("id") final Long applicationId) throws Exception {
|
public List<RightDescription> getRightsDescription(@PathParam("id") final Long applicationId) throws Exception {
|
||||||
this.logger.debug("getApplications rights");
|
this.logger.debug("getApplications rights");
|
||||||
return DataAccess.getsWhere(RightDescription.class, new Condition(new QueryCondition("applicationId", "=", applicationId)));
|
return DataAccess.getsWhere(RightDescription.class,
|
||||||
|
new Condition(new QueryCondition("applicationId", "=", applicationId)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class ClientToken {
|
||||||
|
public String url;
|
||||||
|
public String jwt;
|
||||||
|
|
||||||
|
public ClientToken(final String url, final String jwt) {
|
||||||
|
this.url = url;
|
||||||
|
this.jwt = jwt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("get_token")
|
@Path("get_token")
|
||||||
@RolesAllowed(value = { "USER", "ADMIN" })
|
@RolesAllowed(value = { "USER", "ADMIN" })
|
||||||
public Response getClientToken(@Context final SecurityContext sc, @QueryParam("application") final String application) throws Exception {
|
public ClientToken getClientToken(
|
||||||
|
@Context final SecurityContext sc,
|
||||||
|
@QueryParam("application") final String application) throws Exception {
|
||||||
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
||||||
this.logger.info("get application TOKEN application name='{}'", application);
|
this.logger.info("get application TOKEN application name='{}'", application);
|
||||||
this.logger.debug("== USER ? {}", gc.userByToken.name);
|
this.logger.debug("== USER ? {}", gc.userByToken.name);
|
||||||
|
|
||||||
if (application == null) {
|
if (application == null) {
|
||||||
final String result = "Input error missing parameter: 'application'";
|
throw new InputException("application", "Input error missing parameter");
|
||||||
this.logger.debug(" result: {}", result);
|
|
||||||
return Response.status(406).entity(result).build();
|
|
||||||
}
|
}
|
||||||
String applicationName = application;
|
String applicationName = application;
|
||||||
boolean isDev = false;
|
boolean isDev = false;
|
||||||
@ -243,38 +262,36 @@ public class ApplicationResource {
|
|||||||
isDev = true;
|
isDev = true;
|
||||||
}
|
}
|
||||||
this.logger.debug("Search for '{}' base of '{}'", applicationName, application);
|
this.logger.debug("Search for '{}' base of '{}'", applicationName, application);
|
||||||
|
|
||||||
Application appl = null;
|
Application appl = null;
|
||||||
try {
|
try {
|
||||||
appl = DataAccess.getWhere(Application.class, new Condition(new QueryCondition("name", "=", applicationName)));
|
appl = DataAccess.getWhere(Application.class,
|
||||||
|
new Condition(new QueryCondition("name", "=", applicationName)));
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
final String result = "SERVER Internal error";
|
final String result = "SERVER Internal error";
|
||||||
this.logger.debug(" result: {}", result);
|
this.logger.debug(" result: {}", result);
|
||||||
return Response.status(500).entity(result).build();
|
throw new SystemException("Internal fail request");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appl == null) {
|
if (appl == null) {
|
||||||
final String result = "Authentiocate-wrong email/login '" + applicationName + "')";
|
final String result = "Authentiocate-wrong email/login '" + applicationName + "')";
|
||||||
this.logger.error(" result: {}", result);
|
this.logger.error(" result: {}", result);
|
||||||
return Response.status(401).entity(result).build();
|
throw new InputException("email/login", "Authentiocate-wrong email/login '" + applicationName + "'");
|
||||||
}
|
}
|
||||||
UserLinkApplication links = null;
|
UserLinkApplication links = null;
|
||||||
try {
|
try {
|
||||||
links = DataAccess.getWhere(UserLinkApplication.class,
|
links = DataAccess.getWhere(UserLinkApplication.class,
|
||||||
new Condition(new QueryAnd(new QueryCondition("object1id", "=", gc.userByToken.id), new QueryCondition("deleted", "=", 0), new QueryCondition("object2id", "=", appl.id))));
|
new Condition(new QueryAnd(new QueryCondition("object1id", "=", gc.userByToken.id),
|
||||||
|
new QueryCondition("deleted", "=", 0), new QueryCondition("object2id", "=", appl.id))));
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
final String result = "SERVER Internal error";
|
throw new SystemException("Fail to insert Link");
|
||||||
this.logger.error(" result: {}", result);
|
|
||||||
return Response.status(500).entity(result).build();
|
|
||||||
}
|
}
|
||||||
if (links == null) {
|
if (links == null) {
|
||||||
final String result = "Authenticate impossible ==> application not accessible '" + applicationName + "'";
|
throw new SystemException(
|
||||||
this.logger.error(" result: {}", result);
|
"Authenticate impossible ==> application not accessible '" + applicationName + "'");
|
||||||
return Response.status(401).entity(result).build();
|
|
||||||
}
|
}
|
||||||
// Get the USER Right
|
// Get the USER Right
|
||||||
final Map<String, Object> applicationRight = RightResource.getUserRight(gc.userByToken.id, appl.id);
|
final Map<String, Object> applicationRight = RightResource.getUserRight(gc.userByToken.id, appl.id);
|
||||||
@ -287,29 +304,29 @@ public class ApplicationResource {
|
|||||||
// and in some application user can see other user or all user of the
|
// and in some application user can see other user or all user of the
|
||||||
// application
|
// application
|
||||||
outRight.put(applicationName, applicationRight);
|
outRight.put(applicationName, applicationRight);
|
||||||
final String ret = JWTWrapper.generateJWToken(gc.userByToken.id, gc.userByToken.name, "KarAuth", applicationName, outRight, -appl.ttl);
|
final String ret = JWTWrapper.generateJWToken(gc.userByToken.id, gc.userByToken.name, "KarAuth",
|
||||||
|
applicationName, outRight, -appl.ttl);
|
||||||
// logger.debug(" ==> generate token: {}", ret);
|
// logger.debug(" ==> generate token: {}", ret);
|
||||||
String returnAdress = appl.redirect;
|
String returnAdress = appl.redirect;
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
returnAdress = appl.redirectDev;
|
returnAdress = appl.redirectDev;
|
||||||
}
|
}
|
||||||
return Response.status(201).entity("{ \"url\":\"" + returnAdress + "\", \"jwt\":\"" + ret + "\"}").build();
|
return new ClientToken(returnAdress, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("return")
|
@Path("return")
|
||||||
@RolesAllowed(value = { "USER", "ADMIN" })
|
@RolesAllowed(value = { "USER", "ADMIN" })
|
||||||
public Response logOut(@Context final SecurityContext sc, @QueryParam("application") final String application) {
|
public String logOut(@Context final SecurityContext sc, @QueryParam("application") final String application)
|
||||||
|
throws SystemException, InputException {
|
||||||
this.logger.debug("=====================================");
|
this.logger.debug("=====================================");
|
||||||
this.logger.debug("Get log_out()");
|
this.logger.debug("Get log_out()");
|
||||||
this.logger.debug("=====================================");
|
this.logger.debug("=====================================");
|
||||||
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
||||||
this.logger.debug("== USER ? {}", gc.userByToken);
|
this.logger.debug("== USER ? {}", gc.userByToken);
|
||||||
|
|
||||||
if (application == null) {
|
if (application == null) {
|
||||||
final String result = "Input error missing parameter: 'application'";
|
throw new InputException("application", "Input error missing parameter");
|
||||||
this.logger.error(" result: {}", result);
|
|
||||||
return Response.status(406).entity(result).build();
|
|
||||||
}
|
}
|
||||||
String applicationName = application;
|
String applicationName = application;
|
||||||
boolean isDev = false;
|
boolean isDev = false;
|
||||||
@ -318,28 +335,23 @@ public class ApplicationResource {
|
|||||||
isDev = true;
|
isDev = true;
|
||||||
}
|
}
|
||||||
this.logger.debug("Search for '{}' base of '{}'", applicationName, application);
|
this.logger.debug("Search for '{}' base of '{}'", applicationName, application);
|
||||||
|
|
||||||
Application appl = null;
|
Application appl = null;
|
||||||
try {
|
try {
|
||||||
appl = DataAccess.getWhere(Application.class, new Condition(new QueryCondition("name", "=", applicationName)));
|
appl = DataAccess.getWhere(Application.class,
|
||||||
|
new Condition(new QueryCondition("name", "=", applicationName)));
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
final String result = "SERVER Internal error";
|
throw new SystemException("Fail to log-Out...");
|
||||||
this.logger.error(" result: {}", result);
|
|
||||||
return Response.status(500).entity(result).build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appl == null) {
|
if (appl == null) {
|
||||||
final String result = "Authentiocate-wrong email/login '" + applicationName + "')";
|
throw new SystemException("Authentiocate-wrong email/login '" + applicationName + "'");
|
||||||
this.logger.error(" result: {}", result);
|
|
||||||
return Response.status(404).entity(result).build();
|
|
||||||
}
|
}
|
||||||
String returnAdress = appl.redirect;
|
String returnAdress = appl.redirect;
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
returnAdress = appl.redirectDev;
|
returnAdress = appl.redirectDev;
|
||||||
}
|
}
|
||||||
return Response.status(201).entity("{ \"url\":\"" + returnAdress + "\"}").build();
|
return returnAdress;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import org.kar.archidata.dataAccess.DataAccess;
|
|||||||
import org.kar.archidata.dataAccess.QueryAnd;
|
import org.kar.archidata.dataAccess.QueryAnd;
|
||||||
import org.kar.archidata.dataAccess.QueryCondition;
|
import org.kar.archidata.dataAccess.QueryCondition;
|
||||||
import org.kar.archidata.dataAccess.options.Condition;
|
import org.kar.archidata.dataAccess.options.Condition;
|
||||||
|
import org.kar.archidata.exception.DataAccessException;
|
||||||
import org.kar.archidata.exception.InputException;
|
import org.kar.archidata.exception.InputException;
|
||||||
import org.kar.karso.model.ApplicationToken;
|
import org.kar.karso.model.ApplicationToken;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -23,46 +24,49 @@ import jakarta.ws.rs.PathParam;
|
|||||||
import jakarta.ws.rs.Produces;
|
import jakarta.ws.rs.Produces;
|
||||||
import jakarta.ws.rs.core.Context;
|
import jakarta.ws.rs.core.Context;
|
||||||
import jakarta.ws.rs.core.MediaType;
|
import jakarta.ws.rs.core.MediaType;
|
||||||
import jakarta.ws.rs.core.Response;
|
|
||||||
import jakarta.ws.rs.core.SecurityContext;
|
import jakarta.ws.rs.core.SecurityContext;
|
||||||
|
|
||||||
@Path("/application_token")
|
@Path("/application_token")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public class ApplicationTokenResource {
|
public class ApplicationTokenResource {
|
||||||
final Logger logger = LoggerFactory.getLogger(ApplicationTokenResource.class);
|
final Logger logger = LoggerFactory.getLogger(ApplicationTokenResource.class);
|
||||||
|
|
||||||
public ApplicationTokenResource() {}
|
public ApplicationTokenResource() {}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Generic /application_token/{applicationId}
|
// Generic /application_token/{applicationId}
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{applicationId}")
|
@Path("{applicationId}")
|
||||||
@RolesAllowed(value = { "ADMIN" })
|
@RolesAllowed(value = { "ADMIN" })
|
||||||
public List<ApplicationToken> gets(@Context final SecurityContext sc, @PathParam("applicationId") final Long applicationId) throws Exception {
|
public List<ApplicationToken> gets(
|
||||||
final List<ApplicationToken> values = DataAccess.getsWhere(ApplicationToken.class, new Condition(new QueryCondition("parentId", "=", applicationId)));
|
@Context final SecurityContext sc,
|
||||||
|
@PathParam("applicationId") final Long applicationId) throws Exception {
|
||||||
|
final List<ApplicationToken> values = DataAccess.getsWhere(ApplicationToken.class,
|
||||||
|
new Condition(new QueryCondition("parentId", "=", applicationId)));
|
||||||
// clean all tokens this is a secret:
|
// clean all tokens this is a secret:
|
||||||
for (final ApplicationToken elem : values) {
|
for (final ApplicationToken elem : values) {
|
||||||
elem.token = null;
|
elem.token = null;
|
||||||
}
|
}
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{applicationId}/{tokenId}")
|
@Path("{applicationId}/{tokenId}")
|
||||||
@RolesAllowed(value = { "ADMIN" })
|
@RolesAllowed(value = { "ADMIN" })
|
||||||
public Response delete(@Context final SecurityContext sc, @PathParam("applicationId") final Long applicationId, @PathParam("tokenId") final Integer tokenId) throws Exception {
|
public void remove(
|
||||||
final int nbRemoved = DataAccess.deleteWhere(ApplicationToken.class, new Condition(new QueryAnd(new QueryCondition("parentId", "=", applicationId), new QueryCondition("id", "=", tokenId))));
|
@Context final SecurityContext sc,
|
||||||
|
@PathParam("applicationId") final Long applicationId,
|
||||||
|
@PathParam("tokenId") final Integer tokenId) throws Exception {
|
||||||
|
final int nbRemoved = DataAccess.deleteWhere(ApplicationToken.class,
|
||||||
|
new Condition(new QueryAnd(new QueryCondition("parentId", "=", applicationId),
|
||||||
|
new QueryCondition("id", "=", tokenId))));
|
||||||
if (nbRemoved == 0) {
|
if (nbRemoved == 0) {
|
||||||
return Response.notModified("{}").build();
|
throw new DataAccessException("Fail to remove token");
|
||||||
}
|
}
|
||||||
if (nbRemoved == 0) {
|
|
||||||
return Response.serverError().build();
|
|
||||||
}
|
|
||||||
return Response.ok("{}").build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String multipartCorrection(final String data) {
|
private String multipartCorrection(final String data) {
|
||||||
@ -77,7 +81,7 @@ public class ApplicationTokenResource {
|
|||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static String randomToken() {
|
static String randomToken() {
|
||||||
final int len = 48;
|
final int len = 48;
|
||||||
final String valid_element = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvxyz0123456789#_@-~*!?";
|
final String valid_element = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvxyz0123456789#_@-~*!?";
|
||||||
@ -92,25 +96,34 @@ public class ApplicationTokenResource {
|
|||||||
}
|
}
|
||||||
return out.toString();
|
return out.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public record CreateRequest(
|
public class CreateRequest {
|
||||||
String name,
|
public CreateRequest(final String name, final Integer validity) {
|
||||||
Integer validity) {};
|
this.name = name;
|
||||||
|
this.validity = validity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String name;
|
||||||
|
public Integer validity;
|
||||||
|
};
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("/{applicationId}/create")
|
@Path("/{applicationId}/create")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public ApplicationToken createToken(@Context final SecurityContext sc, @PathParam("applicationId") final Long applicationId, final CreateRequest request) throws Exception {
|
public ApplicationToken create(
|
||||||
|
@Context final SecurityContext sc,
|
||||||
|
@PathParam("applicationId") final Long applicationId,
|
||||||
|
final CreateRequest request) throws Exception {
|
||||||
this.logger.info("get user application TOKEN: app='{}' user='???'", applicationId);
|
this.logger.info("get user application TOKEN: app='{}' user='???'", applicationId);
|
||||||
// correct input string stream :
|
// correct input string stream :
|
||||||
final String name = multipartCorrection(request.name());
|
final String name = multipartCorrection(request.name);
|
||||||
//validity = multipartCorrection(validity);
|
//validity = multipartCorrection(validity);
|
||||||
this.logger.debug("create a new token...");
|
this.logger.debug("create a new token...");
|
||||||
if (applicationId == null) {
|
if (applicationId == null) {
|
||||||
throw new InputException("applicationId", "can not be null");
|
throw new InputException("applicationId", "can not be null");
|
||||||
}
|
}
|
||||||
final int maximum = 365 * 5;
|
final int maximum = 365 * 5;
|
||||||
Integer validity = request.validity();
|
Integer validity = request.validity;
|
||||||
if (validity == null || validity < 0 || validity > maximum) {
|
if (validity == null || validity < 0 || validity > maximum) {
|
||||||
validity = maximum;
|
validity = maximum;
|
||||||
}
|
}
|
||||||
@ -125,7 +138,7 @@ public class ApplicationTokenResource {
|
|||||||
this.logger.warn("Check Timestamp now = {}", now);
|
this.logger.warn("Check Timestamp now = {}", now);
|
||||||
token.endValidityTime = Timestamp.from(now.plusDays(validity).toInstant());
|
token.endValidityTime = Timestamp.from(now.plusDays(validity).toInstant());
|
||||||
this.logger.warn("token.endValidityTime = {}", token.endValidityTime);
|
this.logger.warn("token.endValidityTime = {}", token.endValidityTime);
|
||||||
|
|
||||||
// insert in the BDD
|
// insert in the BDD
|
||||||
token = DataAccess.insert(token);
|
token = DataAccess.insert(token);
|
||||||
// here we return the token to permit to the user to see it to set it in the application.
|
// here we return the token to permit to the user to see it to set it in the application.
|
||||||
@ -134,5 +147,5 @@ public class ApplicationTokenResource {
|
|||||||
/*
|
/*
|
||||||
Cannot find a deserializer for non-concrete Map type [map type; class jakarta.ws.rs.core.MultivaluedMap, [simple type, class java.lang.String] -> [collection type; class java.util.List, contains [simple type, class java.lang.String]]]
|
Cannot find a deserializer for non-concrete Map type [map type; class jakarta.ws.rs.core.MultivaluedMap, [simple type, class java.lang.String] -> [collection type; class java.util.List, contains [simple type, class java.lang.String]]]
|
||||||
at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 1]
|
at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 1]
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.kar.archidata.annotation.AsyncType;
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DataAccess;
|
||||||
import org.kar.archidata.dataAccess.QueryAnd;
|
import org.kar.archidata.dataAccess.QueryAnd;
|
||||||
import org.kar.archidata.dataAccess.QueryCondition;
|
import org.kar.archidata.dataAccess.QueryCondition;
|
||||||
@ -24,51 +25,52 @@ import jakarta.ws.rs.Path;
|
|||||||
import jakarta.ws.rs.PathParam;
|
import jakarta.ws.rs.PathParam;
|
||||||
import jakarta.ws.rs.Produces;
|
import jakarta.ws.rs.Produces;
|
||||||
import jakarta.ws.rs.core.MediaType;
|
import jakarta.ws.rs.core.MediaType;
|
||||||
import jakarta.ws.rs.core.Response;
|
|
||||||
|
|
||||||
@Path("/right")
|
@Path("/right")
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public class RightResource {
|
public class RightResource {
|
||||||
final static Logger logger = LoggerFactory.getLogger(RightResource.class);
|
final static Logger logger = LoggerFactory.getLogger(RightResource.class);
|
||||||
|
|
||||||
public static List<RightDescription> getApplicationRightDecription(final long applicationId) throws Exception {
|
public static List<RightDescription> getApplicationRightDecription(final long applicationId) throws Exception {
|
||||||
return DataAccess.getsWhere(RightDescription.class, new Condition(new QueryCondition("applicationId", "=", applicationId)));
|
return DataAccess.getsWhere(RightDescription.class,
|
||||||
|
new Condition(new QueryCondition("applicationId", "=", applicationId)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Right> getRawUserRight(final long userId, final long applicationId) throws Exception {
|
public static List<Right> getRawUserRight(final long userId, final long applicationId) throws Exception {
|
||||||
// Formatter:off
|
// Formatter:off
|
||||||
return DataAccess.getsWhere(Right.class,
|
return DataAccess.getsWhere(Right.class,
|
||||||
new Condition(
|
new Condition(new QueryAnd(new QueryCondition("applicationId", "=", applicationId),
|
||||||
new QueryAnd(
|
new QueryCondition("userId", "=", userId))));
|
||||||
new QueryCondition("applicationId", "=", applicationId),
|
|
||||||
new QueryCondition("userId", "=", userId)
|
|
||||||
)));
|
|
||||||
// Formatter:on
|
// Formatter:on
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Object> getUserRight(final long userId, final long applicationId) throws Exception {
|
public static Map<String, Object> getUserRight(final long userId, final long applicationId) throws Exception {
|
||||||
final Map<String, Object> out = new HashMap<>();
|
final Map<String, Object> out = new HashMap<>();
|
||||||
final List<RightDescription> rightsDescriptions = getApplicationRightDecription(applicationId);
|
final List<RightDescription> rightsDescriptions = getApplicationRightDecription(applicationId);
|
||||||
logger.trace("Get some descriptions: {} applicationId={}", rightsDescriptions.size(), applicationId);
|
logger.trace("Get some descriptions: {} applicationId={}", rightsDescriptions.size(), applicationId);
|
||||||
if (rightsDescriptions != null && rightsDescriptions.size() != 0) {
|
if (rightsDescriptions != null && rightsDescriptions.size() != 0) {
|
||||||
final List<Right> rights = getRawUserRight(userId, applicationId);
|
final List<Right> rights = getRawUserRight(userId, applicationId);
|
||||||
logger.trace("Get some user right: count={} userID={} applicationId={}", rights.size(), userId, applicationId);
|
logger.trace("Get some user right: count={} userID={} applicationId={}", rights.size(), userId,
|
||||||
|
applicationId);
|
||||||
logger.trace("Rights:");
|
logger.trace("Rights:");
|
||||||
for (final Right elem : rights) {
|
for (final Right elem : rights) {
|
||||||
logger.trace(" - applId={} rightDescriptionId={} value={}", elem.applicationId, elem.rightDescriptionId, elem.value);
|
logger.trace(" - applId={} rightDescriptionId={} value={}", elem.applicationId,
|
||||||
|
elem.rightDescriptionId, elem.value);
|
||||||
}
|
}
|
||||||
logger.trace("RightDescription:");
|
logger.trace("RightDescription:");
|
||||||
for (final RightDescription description : rightsDescriptions) {
|
for (final RightDescription description : rightsDescriptions) {
|
||||||
if (description == null) {
|
if (description == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
logger.trace(" - id={} key={} type={} default={}", description.id, description.key, description.type, description.defaultValue);
|
logger.trace(" - id={} key={} type={} default={}", description.id, description.key, description.type,
|
||||||
|
description.defaultValue);
|
||||||
}
|
}
|
||||||
for (final RightDescription description : rightsDescriptions) {
|
for (final RightDescription description : rightsDescriptions) {
|
||||||
if (description == null) {
|
if (description == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final Right right = rights.stream().filter(elem -> elem.rightDescriptionId.equals(description.id)).findAny().orElse(null);
|
final Right right = rights.stream().filter(elem -> elem.rightDescriptionId.equals(description.id))
|
||||||
|
.findAny().orElse(null);
|
||||||
if (right != null) {
|
if (right != null) {
|
||||||
out.put(description.key, Transform.convertToType(description.type, right.value));
|
out.put(description.key, Transform.convertToType(description.type, right.value));
|
||||||
} else if (description.defaultValue != null) {
|
} else if (description.defaultValue != null) {
|
||||||
@ -83,8 +85,9 @@ public class RightResource {
|
|||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateUserRight(final long userId, final long applicationId, final Map<String, Object> delta) throws Exception {
|
public static void updateUserRight(final long userId, final long applicationId, final Map<String, Object> delta)
|
||||||
|
throws Exception {
|
||||||
final List<RightDescription> rightsDescriptions = getApplicationRightDecription(applicationId);
|
final List<RightDescription> rightsDescriptions = getApplicationRightDecription(applicationId);
|
||||||
logger.debug("Get some descriptions: {} applicationId={}", rightsDescriptions.size(), applicationId);
|
logger.debug("Get some descriptions: {} applicationId={}", rightsDescriptions.size(), applicationId);
|
||||||
if (rightsDescriptions == null || rightsDescriptions.size() == 0) {
|
if (rightsDescriptions == null || rightsDescriptions.size() == 0) {
|
||||||
@ -106,16 +109,17 @@ public class RightResource {
|
|||||||
if (convertedValue == null) {
|
if (convertedValue == null) {
|
||||||
throw new IllegalArgumentException("Uncompatible value:'" + description.type + "'");
|
throw new IllegalArgumentException("Uncompatible value:'" + description.type + "'");
|
||||||
}
|
}
|
||||||
List<Right> allRights = rights.stream().filter(elem -> elem.rightDescriptionId.equals(description.id)).toList();
|
final List<Right> allRights = rights.stream().filter(elem -> elem.rightDescriptionId.equals(description.id))
|
||||||
|
.toList();
|
||||||
if (allRights.size() > 1) {
|
if (allRights.size() > 1) {
|
||||||
// special case of error somewhere else ... ==> remove all elements (except the first)
|
// special case of error somewhere else ... ==> remove all elements (except the first)
|
||||||
for (int iii=1; iii<allRights.size(); iii++) {
|
for (int iii = 1; iii < allRights.size(); iii++) {
|
||||||
logger.error("Remove starnge element in Right id={} ", allRights.get(iii).id);
|
logger.error("Remove starnge element in Right id={} ", allRights.get(iii).id);
|
||||||
DataAccess.delete(Right.class, allRights.get(iii).id);
|
DataAccess.delete(Right.class, allRights.get(iii).id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (allRights.size() == 1 ) {
|
if (allRights.size() == 1) {
|
||||||
Right right = allRights.get(0);
|
final Right right = allRights.get(0);
|
||||||
// The value exist, we need to update it
|
// The value exist, we need to update it
|
||||||
logger.debug("Request update a knonwn parameter: {} with {}", description.key, newValue);
|
logger.debug("Request update a knonwn parameter: {} with {}", description.key, newValue);
|
||||||
right.value = convertedValue;
|
right.value = convertedValue;
|
||||||
@ -123,7 +127,7 @@ public class RightResource {
|
|||||||
} else {
|
} else {
|
||||||
// we need to create it
|
// we need to create it
|
||||||
logger.debug("Request create parameter: {} with {}", description.key, newValue);
|
logger.debug("Request create parameter: {} with {}", description.key, newValue);
|
||||||
Right right = new Right();
|
final Right right = new Right();
|
||||||
right.applicationId = applicationId;
|
right.applicationId = applicationId;
|
||||||
right.userId = userId;
|
right.userId = userId;
|
||||||
right.rightDescriptionId = description.id;
|
right.rightDescriptionId = description.id;
|
||||||
@ -132,42 +136,42 @@ public class RightResource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public List<Right> get() throws Exception {
|
public List<Right> gets() throws Exception {
|
||||||
return DataAccess.gets(Right.class);
|
return DataAccess.gets(Right.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Right post(final String jsonRequest) throws Exception {
|
public Right post(final Right request) throws Exception {
|
||||||
return DataAccess.insertWithJson(Right.class, jsonRequest);
|
return DataAccess.insert(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public static Right getWithId(@PathParam("id") final Long id) throws Exception {
|
public static Right get(@PathParam("id") final Long id) throws Exception {
|
||||||
return DataAccess.get(Right.class, id);
|
return DataAccess.get(Right.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PATCH
|
@PATCH
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Right put(@PathParam("id") final Long id, final String jsonRequest) throws Exception {
|
public Right patch(@PathParam("id") final Long id, @AsyncType(Right.class) final String jsonRequest)
|
||||||
|
throws Exception {
|
||||||
DataAccess.updateWithJson(Right.class, id, jsonRequest);
|
DataAccess.updateWithJson(Right.class, id, jsonRequest);
|
||||||
return DataAccess.get(Right.class, id);
|
return DataAccess.get(Right.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response delete(@PathParam("id") final Long id) throws Exception {
|
public void remove(@PathParam("id") final Long id) throws Exception {
|
||||||
DataAccess.delete(Right.class, id);
|
DataAccess.delete(Right.class, id);
|
||||||
return Response.ok().build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package org.kar.karso.api;
|
package org.kar.karso.api;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DataAccess;
|
||||||
import org.kar.archidata.dataAccess.QueryCondition;
|
import org.kar.archidata.dataAccess.QueryCondition;
|
||||||
@ -23,84 +25,87 @@ import jakarta.ws.rs.PathParam;
|
|||||||
import jakarta.ws.rs.Produces;
|
import jakarta.ws.rs.Produces;
|
||||||
import jakarta.ws.rs.core.Context;
|
import jakarta.ws.rs.core.Context;
|
||||||
import jakarta.ws.rs.core.MediaType;
|
import jakarta.ws.rs.core.MediaType;
|
||||||
import jakarta.ws.rs.core.Response;
|
|
||||||
import jakarta.ws.rs.core.SecurityContext;
|
import jakarta.ws.rs.core.SecurityContext;
|
||||||
|
|
||||||
@Path("/system_config")
|
@Path("/system_config")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public class SystemConfigResource {
|
public class SystemConfigResource {
|
||||||
final Logger logger = LoggerFactory.getLogger(SystemConfigResource.class);
|
final Logger logger = LoggerFactory.getLogger(SystemConfigResource.class);
|
||||||
|
|
||||||
public static class GetSignUpAvaillable {
|
public static class GetSignUpAvailable {
|
||||||
public boolean signup;
|
public boolean signup;
|
||||||
|
|
||||||
public GetSignUpAvaillable(final boolean availlable) {
|
public GetSignUpAvailable(final boolean availlable) {
|
||||||
this.signup = availlable;
|
this.signup = availlable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GetSignUpAvaillable() {
|
public GetSignUpAvailable() {
|
||||||
this.signup = false;
|
this.signup = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SystemConfigResource() {}
|
public SystemConfigResource() {}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("is_sign_up_availlable")
|
@Path("is_sign_up_availlable")
|
||||||
@PermitAll
|
@PermitAll
|
||||||
public GetSignUpAvaillable isSignUpAvaillable() throws Exception {
|
public GetSignUpAvailable isSignUpAvailable() throws Exception {
|
||||||
final Settings set = DataAccess.getWhere(Settings.class, new Condition(new QueryCondition("key", "=", "SIGN_UP_ENABLE")));
|
final Settings set = DataAccess.getWhere(Settings.class,
|
||||||
|
new Condition(new QueryCondition("key", "=", "SIGN_UP_ENABLE")));
|
||||||
if (set == null) {
|
if (set == null) {
|
||||||
throw new NotFoundException("Value does not exist");
|
throw new NotFoundException("Value does not exist");
|
||||||
}
|
}
|
||||||
final boolean availlable = "true".equalsIgnoreCase(set.value);
|
final boolean availlable = "true".equalsIgnoreCase(set.value);
|
||||||
final GetSignUpAvaillable tmp = new GetSignUpAvaillable(availlable);
|
final GetSignUpAvailable tmp = new GetSignUpAvailable(availlable);
|
||||||
this.logger.debug("mlkmlk {}", tmp.signup);
|
this.logger.debug("mlkmlk {}", tmp.signup);
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("key/{key}")
|
@Path("key/{key}")
|
||||||
@RolesAllowed(value = { "USER", "ADMIN" })
|
@RolesAllowed(value = { "USER", "ADMIN" })
|
||||||
public Response getKey(@Context final SecurityContext sc, @PathParam("key") final String key) throws Exception {
|
public Map<String, Object> getKey(@Context final SecurityContext sc, @PathParam("key") final String key)
|
||||||
|
throws Exception {
|
||||||
final Settings set = DataAccess.getWhere(Settings.class, new Condition(new QueryCondition("key", "=", key)));
|
final Settings set = DataAccess.getWhere(Settings.class, new Condition(new QueryCondition("key", "=", key)));
|
||||||
if (set == null) {
|
if (set == null) {
|
||||||
throw new NotFoundException("Value does not exist");
|
throw new NotFoundException("Value does not exist");
|
||||||
}
|
}
|
||||||
|
final Map<String, Object> out = new HashMap<>();
|
||||||
if ("BOOLEAN".equals(set.type)) {
|
if ("BOOLEAN".equals(set.type)) {
|
||||||
final boolean availlable = "true".equalsIgnoreCase(set.value);
|
final boolean available = "true".equalsIgnoreCase(set.value);
|
||||||
return Response.status(200).entity("{ \"value\":" + availlable + "}").build();
|
out.put("value", available);
|
||||||
}
|
} else if ("NUMBER".equals(set.type)) {
|
||||||
if ("NUMBER".equals(set.type)) {
|
|
||||||
final double value = Double.parseDouble(set.value);
|
final double value = Double.parseDouble(set.value);
|
||||||
return Response.status(200).entity("{ \"value\":" + value + "}").build();
|
out.put("value", value);
|
||||||
|
} else {
|
||||||
|
out.put("value", set.value);
|
||||||
}
|
}
|
||||||
return Response.status(200).entity("{ \"value\":\"" + set.value + "\"}").build();
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PATCH
|
@PATCH
|
||||||
@Path("key/{key}")
|
@Path("key/{key}")
|
||||||
@RolesAllowed(value = { "ADMIN" })
|
@RolesAllowed(value = { "ADMIN" })
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Response setKey(@Context final SecurityContext sc, @PathParam("key") final String key, final String jsonRequest) throws Exception {
|
public void setKey(@Context final SecurityContext sc, @PathParam("key") final String key, final String jsonRequest)
|
||||||
|
throws Exception {
|
||||||
Settings res = null;
|
Settings res = null;
|
||||||
try {
|
try {
|
||||||
res = DataAccess.getWhere(Settings.class, new Condition(new QueryCondition("key", "=", key)));
|
res = DataAccess.getWhere(Settings.class, new Condition(new QueryCondition("key", "=", key)));
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
final String result = "Can not find the Key";
|
final String result = "Can not find the Key: '" + key + "'";
|
||||||
return Response.status(404).entity(result).build();
|
throw new NotFoundException(result);
|
||||||
}
|
}
|
||||||
final ObjectMapper mapper = new ObjectMapper();
|
final ObjectMapper mapper = new ObjectMapper();
|
||||||
// Read the tree to filter injection of data:
|
// Read the tree to filter injection of data:
|
||||||
final JsonNode root = mapper.readTree(jsonRequest);
|
final JsonNode root = mapper.readTree(jsonRequest);
|
||||||
final JsonNode value = root.findPath("value");
|
final JsonNode value = root.findPath("value");
|
||||||
|
|
||||||
res.value = value.asText();
|
res.value = value.asText();
|
||||||
this.logger.debug("Update value : {}", res.value);
|
this.logger.debug("Update value : {}", res.value);
|
||||||
DataAccess.update(res, res.id, List.of("value"));
|
DataAccess.update(res, res.id, List.of("value"));
|
||||||
return Response.status(201).entity("{ \"value\":\"" + res.value + "\"}").build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,6 @@ import jakarta.annotation.security.PermitAll;
|
|||||||
import jakarta.annotation.security.RolesAllowed;
|
import jakarta.annotation.security.RolesAllowed;
|
||||||
import jakarta.ws.rs.Consumes;
|
import jakarta.ws.rs.Consumes;
|
||||||
import jakarta.ws.rs.GET;
|
import jakarta.ws.rs.GET;
|
||||||
import jakarta.ws.rs.NotFoundException;
|
|
||||||
import jakarta.ws.rs.PATCH;
|
import jakarta.ws.rs.PATCH;
|
||||||
import jakarta.ws.rs.POST;
|
import jakarta.ws.rs.POST;
|
||||||
import jakarta.ws.rs.Path;
|
import jakarta.ws.rs.Path;
|
||||||
@ -51,26 +50,26 @@ import jakarta.ws.rs.core.SecurityContext;
|
|||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public class UserResource {
|
public class UserResource {
|
||||||
final Logger logger = LoggerFactory.getLogger(UserResource.class);
|
final Logger logger = LoggerFactory.getLogger(UserResource.class);
|
||||||
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class UserOut {
|
public class UserOut {
|
||||||
public long id;
|
public long id;
|
||||||
public String login;
|
public String login;
|
||||||
|
|
||||||
public UserOut(final long id, final String login) {
|
public UserOut(final long id, final String login) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.login = login;
|
this.login = login;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserResource() {}
|
public UserResource() {}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public List<UserAuthGet> getUsers() throws Exception {
|
public List<UserAuthGet> getUsers() throws Exception {
|
||||||
return DataAccess.gets(UserAuthGet.class);
|
return DataAccess.gets(UserAuthGet.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@ -78,12 +77,15 @@ public class UserResource {
|
|||||||
//GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
//GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
||||||
return DataAccess.get(UserAuthGet.class, userId);
|
return DataAccess.get(UserAuthGet.class, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{userId}/application/{applicationId}/link")
|
@Path("{userId}/application/{applicationId}/link")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public UserAuth linkApplication(@Context final SecurityContext sc, @PathParam("userId") final long userId, @PathParam("applicationId") final long applicationId, final boolean data)
|
public UserAuth linkApplication(
|
||||||
throws Exception {
|
@Context final SecurityContext sc,
|
||||||
|
@PathParam("userId") final long userId,
|
||||||
|
@PathParam("applicationId") final long applicationId,
|
||||||
|
final boolean data) throws Exception {
|
||||||
this.logger.debug("Find typeNode");
|
this.logger.debug("Find typeNode");
|
||||||
if (data) {
|
if (data) {
|
||||||
AddOnManyToMany.addLink(UserAuth.class, userId, "application", applicationId);
|
AddOnManyToMany.addLink(UserAuth.class, userId, "application", applicationId);
|
||||||
@ -92,74 +94,84 @@ public class UserResource {
|
|||||||
}
|
}
|
||||||
return DataAccess.get(UserAuth.class, userId);
|
return DataAccess.get(UserAuth.class, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{userId}/application/{applicationId}/rights")
|
@Path("{userId}/application/{applicationId}/rights")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Map<String, Object> getApplicationRight(@Context final SecurityContext sc, @PathParam("userId") final long userId, @PathParam("applicationId") final long applicationId) throws Exception {
|
public Map<String, Object> getApplicationRight(
|
||||||
|
@Context final SecurityContext sc,
|
||||||
|
@PathParam("userId") final long userId,
|
||||||
|
@PathParam("applicationId") final long applicationId) throws Exception {
|
||||||
return RightResource.getUserRight(userId, applicationId);
|
return RightResource.getUserRight(userId, applicationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PATCH
|
@PATCH
|
||||||
@Path("{userId}/application/{applicationId}/rights")
|
@Path("{userId}/application/{applicationId}/rights")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Map<String, Object> patchApplicationRight(@Context final SecurityContext sc, @PathParam("userId") final long userId, @PathParam("applicationId") final long applicationId,
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
public Map<String, Object> patchApplicationRight(
|
||||||
|
@Context final SecurityContext sc,
|
||||||
|
@PathParam("userId") final long userId,
|
||||||
|
@PathParam("applicationId") final long applicationId,
|
||||||
final Map<String, Object> data) throws Exception {
|
final Map<String, Object> data) throws Exception {
|
||||||
this.logger.info("Patch data from FRONT: {}", data);
|
this.logger.info("Patch data from FRONT: {}", data);
|
||||||
RightResource.updateUserRight(userId, applicationId, data);
|
RightResource.updateUserRight(userId, applicationId, data);
|
||||||
return RightResource.getUserRight(userId, applicationId);
|
return RightResource.getUserRight(userId, applicationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: check this it might be deprecated ...
|
// TODO: check this it might be deprecated ...
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/set_admin")
|
@Path("{id}/set_admin")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response setAdmin(@Context final SecurityContext sc, @PathParam("id") final long userId, final boolean data) throws Exception {
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
public void setAdmin(@Context final SecurityContext sc, @PathParam("id") final long userId, final boolean data)
|
||||||
|
throws Exception {
|
||||||
final UserAuth user = new UserAuth();
|
final UserAuth user = new UserAuth();
|
||||||
user.admin = data;
|
user.admin = data;
|
||||||
final int ret = DataAccess.update(user, userId, List.of("admin"));
|
final int ret = DataAccess.update(user, userId, List.of("admin"));
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
return Response.notModified("{}").build();
|
throw new FailException(Response.Status.NOT_MODIFIED, "Fail to modify user as an admin.");
|
||||||
}
|
}
|
||||||
return Response.ok("{}").build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/set_blocked")
|
@Path("{id}/set_blocked")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response setBlocked(@Context final SecurityContext sc, @PathParam("id") final long userId, final boolean data) throws Exception {
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
public void setBlocked(@Context final SecurityContext sc, @PathParam("id") final long userId, final boolean data)
|
||||||
|
throws Exception {
|
||||||
final UserAuth user = new UserAuth();
|
final UserAuth user = new UserAuth();
|
||||||
user.blocked = data;
|
user.blocked = data;
|
||||||
final int ret = DataAccess.update(user, userId, List.of("blocked"));
|
final int ret = DataAccess.update(user, userId, List.of("blocked"));
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
return Response.notModified("{}").build();
|
throw new FailException(Response.Status.NOT_MODIFIED, "Fail to block the User.");
|
||||||
}
|
}
|
||||||
return Response.ok("{}").build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("create_new_user")
|
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public UserAuthGet createUser(final UserCreate user) throws Exception {
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
public UserAuthGet create(final UserCreate user) throws Exception {
|
||||||
this.logger.debug("create new User email={} login={}", user.email, user.login);
|
this.logger.debug("create new User email={} login={}", user.email, user.login);
|
||||||
// verify login or email is correct:
|
// verify login or email is correct:
|
||||||
if (user.login == null || user.login.length() < 6) {
|
if (user.login == null || user.login.length() < 6) {
|
||||||
throw new InputException("login", "Authentiocate-method-error (login too small: '" + user.login + "')");
|
throw new InputException("login", "Authentiocate-method-error (login too small: '" + user.login + "')");
|
||||||
}
|
}
|
||||||
// TODO: check login format
|
// TODO: check login format
|
||||||
|
|
||||||
if (user.email == null || user.email.length() < 6) {
|
if (user.email == null || user.email.length() < 6) {
|
||||||
throw new InputException("email", "Authentiocate-method-error (email too small: '" + user.email + "')");
|
throw new InputException("email", "Authentiocate-method-error (email too small: '" + user.email + "')");
|
||||||
}
|
}
|
||||||
// TODO: check email format
|
// TODO: check email format
|
||||||
|
|
||||||
if (user.password == null || user.password.length() != 128) {
|
if (user.password == null || user.password.length() != 128) {
|
||||||
throw new InputException("password", "null password, or wrong hash size");
|
throw new InputException("password", "null password, or wrong hash size");
|
||||||
}
|
}
|
||||||
// TODO: verify if the data are a hash ...
|
// TODO: verify if the data are a hash ...
|
||||||
|
|
||||||
// Check login does not exist
|
// Check login does not exist
|
||||||
List<UserAuth> out = DataAccess.getsWhere(UserAuth.class, new Condition(new QueryCondition("login", "=", user.login)));
|
List<UserAuth> out = DataAccess.getsWhere(UserAuth.class,
|
||||||
|
new Condition(new QueryCondition("login", "=", user.login)));
|
||||||
if (out.size() >= 1) {
|
if (out.size() >= 1) {
|
||||||
throw new FailException(Response.Status.BAD_REQUEST, "Login already used !!!");
|
throw new FailException(Response.Status.BAD_REQUEST, "Login already used !!!");
|
||||||
}
|
}
|
||||||
@ -168,8 +180,8 @@ public class UserResource {
|
|||||||
if (out.size() >= 1) {
|
if (out.size() >= 1) {
|
||||||
throw new FailException(Response.Status.BAD_REQUEST, "e-mail already used !!!");
|
throw new FailException(Response.Status.BAD_REQUEST, "e-mail already used !!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add new user and return formated dat.
|
// Add new user and return formated data.
|
||||||
final UserAuth newUser = new UserAuth();
|
final UserAuth newUser = new UserAuth();
|
||||||
newUser.admin = false;
|
newUser.admin = false;
|
||||||
newUser.removed = false;
|
newUser.removed = false;
|
||||||
@ -183,7 +195,7 @@ public class UserResource {
|
|||||||
this.logger.debug("create new user done with id=={}", tmp.id);
|
this.logger.debug("create new user done with id=={}", tmp.id);
|
||||||
return DataAccess.get(UserAuthGet.class, tmp.id);
|
return DataAccess.get(UserAuthGet.class, tmp.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("me")
|
@Path("me")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
@ -193,15 +205,16 @@ public class UserResource {
|
|||||||
this.logger.debug("== USER ? {}", gc.userByToken);
|
this.logger.debug("== USER ? {}", gc.userByToken);
|
||||||
return new UserOut(gc.userByToken.id, gc.userByToken.name);
|
return new UserOut(gc.userByToken.id, gc.userByToken.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("password")
|
@Path("password")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public Response changePassword(@Context final SecurityContext sc, final ChangePassword data) throws Exception {
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
public void changePassword(@Context final SecurityContext sc, final ChangePassword data) throws Exception {
|
||||||
this.logger.debug("ChangePassword()");
|
this.logger.debug("ChangePassword()");
|
||||||
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
||||||
this.logger.debug("== USER ? {}", gc.userByToken);
|
this.logger.debug("== USER ? {}", gc.userByToken);
|
||||||
|
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
throw new InputException("data", "No data set...");
|
throw new InputException("data", "No data set...");
|
||||||
}
|
}
|
||||||
@ -215,52 +228,31 @@ public class UserResource {
|
|||||||
// Process the update:
|
// Process the update:
|
||||||
user.password = data.newPassword;
|
user.password = data.newPassword;
|
||||||
DataAccess.update(user, user.id, List.of("password"));
|
DataAccess.update(user, user.id, List.of("password"));
|
||||||
return Response.status(Response.Status.OK).build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
@GET
|
@GET
|
||||||
@Path("validipass")
|
@Path("is_login_exist")
|
||||||
@PermitAll
|
@PermitAll
|
||||||
public Response validatePasswordFromEMail(@QueryParam("uuid") String uuid, @QueryParam("securityId") String securityId) {
|
public Boolean isLoginExist(@QueryParam("login") final String login) throws Exception {
|
||||||
|
|
||||||
// Validate new password if OK
|
|
||||||
|
|
||||||
// clear the passwordChange, passwordValidation fields
|
|
||||||
|
|
||||||
// send an e-mail to confirm the new password has been set.
|
|
||||||
|
|
||||||
|
|
||||||
return Response.status(500).build();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("/check_login")
|
|
||||||
@PermitAll
|
|
||||||
public Response checkLogin(@QueryParam("login") final String login) throws Exception {
|
|
||||||
this.logger.debug("checkLogin: '{}'", login);
|
this.logger.debug("checkLogin: '{}'", login);
|
||||||
final List<UserAuth> out = DataAccess.getsWhere(UserAuth.class, new Condition(new QueryCondition("login", "=", login)));
|
final List<UserAuth> out = DataAccess.getsWhere(UserAuth.class,
|
||||||
if (out.size() >= 1) {
|
new Condition(new QueryCondition("login", "=", login)));
|
||||||
return Response.ok().build();
|
return out.size() >= 1;
|
||||||
}
|
|
||||||
throw new NotFoundException("User does not exist: '" + login + "'");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add an application TOKEN and permit only 50 requested (maybe add an option to disable it).
|
// TODO: add an application TOKEN and permit only 50 requested (maybe add an option to disable it).
|
||||||
@GET
|
@GET
|
||||||
@Path("/check_email")
|
@Path("is_email_exist")
|
||||||
@PermitAll
|
@PermitAll
|
||||||
public Response checkEmail(@QueryParam("email") final String email) throws Exception {
|
public Boolean isEmailExist(@QueryParam("email") final String email) throws Exception {
|
||||||
this.logger.debug("checkEmail: {}", email);
|
this.logger.debug("checkEmail: {}", email);
|
||||||
final List<UserAuth> out = DataAccess.getsWhere(UserAuth.class, new Condition(new QueryCondition("email", "=", email)));
|
final List<UserAuth> out = DataAccess.getsWhere(UserAuth.class,
|
||||||
if (out.size() >= 1) {
|
new Condition(new QueryCondition("email", "=", email)));
|
||||||
return Response.ok().build();
|
return out.size() >= 1;
|
||||||
}
|
|
||||||
throw new NotFoundException("emain does not exist: '" + email + "'");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private UserAuth checkAuthUser(final String method, final String login, final String time, final String password) throws Exception {
|
private UserAuth checkAuthUser(final String method, final String login, final String time, final String password)
|
||||||
|
throws Exception {
|
||||||
// check good version:
|
// check good version:
|
||||||
if (!"v1".contentEquals(method)) {
|
if (!"v1".contentEquals(method)) {
|
||||||
throw new InputException("method", "Authentiocate-method-error (wrong version: '" + method + "')");
|
throw new InputException("method", "Authentiocate-method-error (wrong version: '" + method + "')");
|
||||||
@ -278,24 +270,26 @@ public class UserResource {
|
|||||||
query = "email";
|
query = "email";
|
||||||
}
|
}
|
||||||
final UserAuth user = DataAccess.getWhere(UserAuth.class, new Condition(new QueryCondition(query, "=", login)));
|
final UserAuth user = DataAccess.getWhere(UserAuth.class, new Condition(new QueryCondition(query, "=", login)));
|
||||||
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new FailException(Response.Status.PRECONDITION_FAILED, "FAIL Authentiocate-wrong email/login '" + login + "')");
|
throw new FailException(Response.Status.PRECONDITION_FAILED,
|
||||||
|
"FAIL Authentiocate-wrong email/login '" + login + "')");
|
||||||
}
|
}
|
||||||
// Check the password:
|
// Check the password:
|
||||||
final String passwodCheck = getSHA512("login='" + login + "';pass='" + user.password + "';date='" + time + "'");
|
final String passwodCheck = getSHA512("login='" + login + "';pass='" + user.password + "';date='" + time + "'");
|
||||||
if (!passwodCheck.contentEquals(password)) {
|
if (!passwodCheck.contentEquals(password)) {
|
||||||
throw new FailException(Response.Status.PRECONDITION_FAILED, "Password error ...");
|
throw new FailException(Response.Status.PRECONDITION_FAILED, "Password error ...");
|
||||||
}
|
}
|
||||||
this.logger.debug(" ==> pass nearly all test : admin={} blocked={} removed={}", user.admin, user.blocked, user.removed);
|
this.logger.debug(" ==> pass nearly all test : admin={} blocked={} removed={}", user.admin, user.blocked,
|
||||||
|
user.removed);
|
||||||
if (user.blocked || user.removed) {
|
if (user.blocked || user.removed) {
|
||||||
throw new FailException(Response.Status.UNAUTHORIZED, "FAIL Authentiocate");
|
throw new FailException(Response.Status.UNAUTHORIZED, "FAIL Authentiocate");
|
||||||
}
|
}
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("/get_token")
|
@Path("get_token")
|
||||||
@PermitAll
|
@PermitAll
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public GetToken getToken(final DataGetToken data) throws Exception {
|
public GetToken getToken(final DataGetToken data) throws Exception {
|
||||||
@ -304,9 +298,10 @@ public class UserResource {
|
|||||||
// at the point the user has been not deleted and not blocked.
|
// at the point the user has been not deleted and not blocked.
|
||||||
// this authentication is valid only for Karso ==> not for the application
|
// this authentication is valid only for Karso ==> not for the application
|
||||||
final int expirationTimeInMinutes = ConfigVariable.getAuthExpirationTime();
|
final int expirationTimeInMinutes = ConfigVariable.getAuthExpirationTime();
|
||||||
|
|
||||||
// Get the USER Right (Note: by construction KARSO have application ID = KARSO_INITIALISATION_ID
|
// Get the USER Right (Note: by construction KARSO have application ID = KARSO_INITIALISATION_ID
|
||||||
final Map<String, Object> ssoRight = RightResource.getUserRight(user.id, Initialization.KARSO_INITIALISATION_ID);
|
final Map<String, Object> ssoRight = RightResource.getUserRight(user.id,
|
||||||
|
Initialization.KARSO_INITIALISATION_ID);
|
||||||
if (!ssoRight.containsKey("USER")) {
|
if (!ssoRight.containsKey("USER")) {
|
||||||
// If the USER is not override, the system add by default USER
|
// If the USER is not override, the system add by default USER
|
||||||
ssoRight.put("USER", true);
|
ssoRight.put("USER", true);
|
||||||
@ -317,17 +312,20 @@ public class UserResource {
|
|||||||
// we set the right in the under map to manage multiple application group right. and in some application user can see other user or all user of the application
|
// we set the right in the under map to manage multiple application group right. and in some application user can see other user or all user of the application
|
||||||
outRight.put(applicationName, ssoRight);
|
outRight.put(applicationName, ssoRight);
|
||||||
// TODO: maybe correct this get of TTL...
|
// TODO: maybe correct this get of TTL...
|
||||||
final String ret = JWTWrapper.generateJWToken(user.id, user.login, "KarAuth", applicationName, outRight, expirationTimeInMinutes);
|
final String ret = JWTWrapper.generateJWToken(user.id, user.login, "KarAuth", applicationName, outRight,
|
||||||
|
expirationTimeInMinutes);
|
||||||
|
if (ret == null) {
|
||||||
|
throw new SystemException("Missing internal JWT system ==> can not sign anything ...");
|
||||||
|
}
|
||||||
// Update last connection:
|
// Update last connection:
|
||||||
final UserAuth newUser = new UserAuth();
|
final UserAuth newUser = new UserAuth();
|
||||||
newUser.lastConnection = Timestamp.valueOf(LocalDateTime.now());
|
newUser.lastConnection = Timestamp.valueOf(LocalDateTime.now());
|
||||||
DataAccess.update(newUser, user.id, List.of("lastConnection"));
|
DataAccess.update(newUser, user.id, List.of("lastConnection"));
|
||||||
|
|
||||||
//logger.debug(" ==> generate token: {}", ret);
|
//logger.debug(" ==> generate token: {}", ret);
|
||||||
return new GetToken(ret);
|
return new GetToken(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String bytesToHex(final byte[] bytes) {
|
public static String bytesToHex(final byte[] bytes) {
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
for (final byte b : bytes) {
|
for (final byte b : bytes) {
|
||||||
@ -335,7 +333,7 @@ public class UserResource {
|
|||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSHA512(final String passwordToHash) {
|
public String getSHA512(final String passwordToHash) {
|
||||||
try {
|
try {
|
||||||
final MessageDigest md = MessageDigest.getInstance("SHA-512");
|
final MessageDigest md = MessageDigest.getInstance("SHA-512");
|
||||||
@ -346,5 +344,5 @@ public class UserResource {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package org.kar.karso.migration;
|
package org.kar.karso.migration;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.kar.archidata.migration.MigrationSqlStep;
|
import org.kar.archidata.migration.MigrationSqlStep;
|
||||||
import org.kar.karso.model.Application;
|
import org.kar.karso.model.Application;
|
||||||
import org.kar.karso.model.ApplicationToken;
|
import org.kar.karso.model.ApplicationToken;
|
||||||
@ -9,27 +11,26 @@ import org.kar.karso.model.Settings;
|
|||||||
import org.kar.karso.model.UserAuth;
|
import org.kar.karso.model.UserAuth;
|
||||||
|
|
||||||
public class Initialization extends MigrationSqlStep {
|
public class Initialization extends MigrationSqlStep {
|
||||||
|
|
||||||
public static final int KARSO_INITIALISATION_ID = 1;
|
public static final int KARSO_INITIALISATION_ID = 1;
|
||||||
|
|
||||||
|
public static final List<Class<?>> CLASSES_BASE = List.of(Settings.class, UserAuth.class,Application.class,ApplicationToken.class,RightDescription.class,Right.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Initialization";
|
return "Initialization";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Initialization() {
|
public Initialization() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateStep() throws Exception {
|
public void generateStep() throws Exception {
|
||||||
addClass(Settings.class);
|
for(final Class<?> clazz : CLASSES_BASE) {
|
||||||
addClass(UserAuth.class);
|
addClass(clazz);
|
||||||
addClass(Application.class);
|
}
|
||||||
addClass(ApplicationToken.class);
|
|
||||||
addClass(RightDescription.class);
|
|
||||||
addClass(Right.class);
|
|
||||||
|
|
||||||
addAction("""
|
addAction("""
|
||||||
INSERT INTO `application` (`id`, `name`, `description`, `redirect`, `redirectDev`, `notification`, `ttl`) VALUES
|
INSERT INTO `application` (`id`, `name`, `description`, `redirect`, `redirectDev`, `notification`, `ttl`) VALUES
|
||||||
(1, 'karso', 'Root SSO interface', 'http://atria-soft/karso', '', '', 666);
|
(1, 'karso', 'Root SSO interface', 'http://atria-soft/karso', '', '', 666);
|
||||||
@ -77,5 +78,5 @@ public class Initialization extends MigrationSqlStep {
|
|||||||
""", "mysql");
|
""", "mysql");
|
||||||
display();
|
display();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,9 @@ CREATE TABLE `application` (
|
|||||||
`token` varchar(128) COLLATE 'latin1_bin' NOT NULL COMMENT 'Token (can be not unique)'
|
`token` varchar(128) COLLATE 'latin1_bin' NOT NULL COMMENT 'Token (can be not unique)'
|
||||||
) AUTO_INCREMENT=10;
|
) AUTO_INCREMENT=10;
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.kar.archidata.annotation.DataComment;
|
import org.kar.archidata.annotation.DataComment;
|
||||||
import org.kar.archidata.annotation.DataDefault;
|
|
||||||
import org.kar.archidata.annotation.DataIfNotExists;
|
import org.kar.archidata.annotation.DataIfNotExists;
|
||||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||||
|
|
||||||
@ -19,6 +18,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
|||||||
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
import jakarta.ws.rs.DefaultValue;
|
||||||
|
|
||||||
@Table(name = "application")
|
@Table(name = "application")
|
||||||
@DataIfNotExists
|
@DataIfNotExists
|
||||||
@ -31,18 +31,18 @@ public class Application extends GenericDataSoftDelete {
|
|||||||
@Column(length = 2048, nullable = false)
|
@Column(length = 2048, nullable = false)
|
||||||
public String redirect;
|
public String redirect;
|
||||||
@Column(length = 2048)
|
@Column(length = 2048)
|
||||||
@DataDefault("'http://localhost:4200/sso/'")
|
@DefaultValue("'http://localhost:4200/sso/'")
|
||||||
public String redirectDev;
|
public String redirectDev;
|
||||||
@Column(length = 2048)
|
@Column(length = 2048)
|
||||||
@DataDefault("'http://localhost:4200/sso/notification'")
|
@DefaultValue("'http://localhost:4200/sso/notification'")
|
||||||
public String notification;
|
public String notification;
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
@DataComment("Expiration time ")
|
@DataComment("Expiration time ")
|
||||||
@DataDefault("666")
|
@DefaultValue("666")
|
||||||
public Integer ttl;
|
public Integer ttl;
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
@DataComment("Right is manage with Karso")
|
@DataComment("Right is manage with Karso")
|
||||||
@DataDefault("0")
|
@DefaultValue("0")
|
||||||
public Boolean manageRight;
|
public Boolean manageRight;
|
||||||
|
|
||||||
public Application() {}
|
public Application() {}
|
||||||
|
@ -1,9 +1,16 @@
|
|||||||
package org.kar.karso.model;
|
package org.kar.karso.model;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
|
||||||
public class ChangePassword {
|
public class ChangePassword {
|
||||||
|
@Column(length = 32)
|
||||||
public String method;
|
public String method;
|
||||||
|
@Column(length = 512)
|
||||||
public String login;
|
public String login;
|
||||||
|
@Column(length = 64)
|
||||||
public String time;
|
public String time;
|
||||||
public String password;
|
@Column(length = 128)
|
||||||
public String newPassword;
|
public String password;
|
||||||
|
@Column(length = 128)
|
||||||
|
public String newPassword;
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package org.kar.karso.model;
|
package org.kar.karso.model;
|
||||||
|
|
||||||
import org.kar.archidata.annotation.DataComment;
|
|
||||||
import org.kar.archidata.annotation.DataIfNotExists;
|
import org.kar.archidata.annotation.DataIfNotExists;
|
||||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.FetchType;
|
import jakarta.persistence.FetchType;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
@ -15,20 +15,20 @@ import jakarta.persistence.Table;
|
|||||||
@DataIfNotExists
|
@DataIfNotExists
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class Right extends GenericDataSoftDelete {
|
public class Right extends GenericDataSoftDelete {
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
@DataComment("application-ID that have the reference of the right")
|
@Schema(description ="application-ID that have the reference of the right")
|
||||||
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Application.class)
|
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Application.class)
|
||||||
public Long applicationId;
|
public Long applicationId;
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
@DataComment("user-ID ")
|
@Schema(description ="user-ID ")
|
||||||
@ManyToOne(fetch = FetchType.LAZY, targetEntity = UserAuth.class)
|
@ManyToOne(fetch = FetchType.LAZY, targetEntity = UserAuth.class)
|
||||||
public Long userId;
|
public Long userId;
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
@DataComment("rightDescription-ID of the right description")
|
@Schema(description ="rightDescription-ID of the right description")
|
||||||
@ManyToOne(fetch = FetchType.LAZY, targetEntity = RightDescription.class)
|
@ManyToOne(fetch = FetchType.LAZY, targetEntity = RightDescription.class)
|
||||||
public Long rightDescriptionId;
|
public Long rightDescriptionId;
|
||||||
@Column(length = 1024, nullable = false)
|
@Column(length = 1024, nullable = false)
|
||||||
@DataComment("Value of the right")
|
@Schema(description ="Value of the right")
|
||||||
public String value;
|
public String value;
|
||||||
}
|
}
|
||||||
|
@ -1,39 +1,39 @@
|
|||||||
package org.kar.karso.model;
|
package org.kar.karso.model;
|
||||||
|
|
||||||
import org.kar.archidata.annotation.DataComment;
|
|
||||||
import org.kar.archidata.annotation.DataDefault;
|
|
||||||
import org.kar.archidata.annotation.DataIfNotExists;
|
import org.kar.archidata.annotation.DataIfNotExists;
|
||||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.FetchType;
|
import jakarta.persistence.FetchType;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
import jakarta.ws.rs.DefaultValue;
|
||||||
|
|
||||||
@Table(name = "rightDescription")
|
@Table(name = "rightDescription")
|
||||||
@DataIfNotExists
|
@DataIfNotExists
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class RightDescription extends GenericDataSoftDelete {
|
public class RightDescription extends GenericDataSoftDelete {
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
@DataComment("Application id that have the reference of the right")
|
@Schema(description ="Application id that have the reference of the right")
|
||||||
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Application.class)
|
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Application.class)
|
||||||
public Long applicationId;
|
public Long applicationId;
|
||||||
@Column(length = 64, nullable = false)
|
@Column(length = 64, nullable = false)
|
||||||
@DataComment("Key of the property")
|
@Schema(description ="Key of the property")
|
||||||
public String key;
|
public String key;
|
||||||
@Column(length = 1024, nullable = false)
|
@Column(length = 1024, nullable = false)
|
||||||
@DataComment("Title of the right")
|
@Schema(description ="Title of the right")
|
||||||
public String title;
|
public String title;
|
||||||
@Column(length = 1024, nullable = false)
|
@Column(length = 1024, nullable = false)
|
||||||
@DataComment("Description of the right")
|
@Schema(description ="Description of the right")
|
||||||
public String description;
|
public String description;
|
||||||
@Column(length = 1024)
|
@Column(length = 1024)
|
||||||
@DataComment("default value if Never set")
|
@Schema(description ="default value if Never set")
|
||||||
public String defaultValue;
|
public String defaultValue;
|
||||||
@Column(length = 16, nullable = false)
|
@Column(length = 16, nullable = false)
|
||||||
@DataComment("Type of the property")
|
@Schema(description ="Type of the property")
|
||||||
@DataDefault("\"BOOLEAN\"")
|
@DefaultValue("\"BOOLEAN\"")
|
||||||
public String type = "BOOLEAN"; // this is a place-holder (current type supported BOOLEAN)
|
public String type = "BOOLEAN"; // this is a place-holder (current type supported BOOLEAN)
|
||||||
}
|
}
|
@ -1,24 +1,14 @@
|
|||||||
package org.kar.karso.model;
|
package org.kar.karso.model;
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
CREATE TABLE `application` (
|
|
||||||
`id` bigint NOT NULL COMMENT 'Unique ID of the application' AUTO_INCREMENT PRIMARY KEY,
|
|
||||||
`description` text COMMENT 'description of the application',
|
|
||||||
`token` varchar(128) COLLATE 'latin1_bin' NOT NULL COMMENT 'Token (can be not unique)'
|
|
||||||
) AUTO_INCREMENT=10;
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
import org.kar.archidata.annotation.DataComment;
|
|
||||||
import org.kar.archidata.annotation.DataDefault;
|
|
||||||
import org.kar.archidata.annotation.DataIfNotExists;
|
import org.kar.archidata.annotation.DataIfNotExists;
|
||||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
import jakarta.ws.rs.DefaultValue;
|
||||||
|
|
||||||
enum PropertyType {
|
enum PropertyType {
|
||||||
STRING, NUMBER, BOOLEAN,
|
STRING, NUMBER, BOOLEAN,
|
||||||
@ -30,14 +20,14 @@ enum PropertyType {
|
|||||||
public class Settings extends GenericDataSoftDelete {
|
public class Settings extends GenericDataSoftDelete {
|
||||||
@Column(length = 512, nullable = false)
|
@Column(length = 512, nullable = false)
|
||||||
public String key;
|
public String key;
|
||||||
@DataComment("Right for the specific element(ADMIN [rw] USER [rw] other [rw])")
|
@Schema(description ="Right for the specific element(ADMIN [rw] USER [rw] other [rw])")
|
||||||
@Column(length = 6, nullable = false)
|
@Column(length = 6, nullable = false)
|
||||||
@DataDefault("\"rw----\"")
|
@DefaultValue("\"rw----\"")
|
||||||
public String right;
|
public String right;
|
||||||
@DataComment("Type Of the data")
|
@Schema(description ="Type Of the data")
|
||||||
@Column(length = 10, nullable = false)
|
@Column(length = 10, nullable = false)
|
||||||
public String type;
|
public String type;
|
||||||
@DataComment("Value of the configuration")
|
@Schema(description ="Value of the configuration")
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
public String value;
|
public String value;
|
||||||
|
|
||||||
|
@ -3,16 +3,16 @@ package org.kar.karso.model;
|
|||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.kar.archidata.annotation.DataComment;
|
|
||||||
import org.kar.archidata.annotation.DataDefault;
|
|
||||||
import org.kar.archidata.annotation.DataIfNotExists;
|
import org.kar.archidata.annotation.DataIfNotExists;
|
||||||
import org.kar.archidata.model.User;
|
import org.kar.archidata.model.User;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.ManyToMany;
|
import jakarta.persistence.ManyToMany;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
import jakarta.ws.rs.DefaultValue;
|
||||||
|
|
||||||
@Table(name = "user")
|
@Table(name = "user")
|
||||||
@DataIfNotExists
|
@DataIfNotExists
|
||||||
@ -25,16 +25,16 @@ public class UserAuth extends User {
|
|||||||
public String passwordChange; //!< When change a password, the new password is set in temporary area and wait the email validation
|
public String passwordChange; //!< When change a password, the new password is set in temporary area and wait the email validation
|
||||||
@Column(length = 128)
|
@Column(length = 128)
|
||||||
public String passwordValidation; //!< UniqueId to validate the new password
|
public String passwordValidation; //!< UniqueId to validate the new password
|
||||||
*/
|
*/
|
||||||
@Column(length = 512, nullable = false)
|
@Column(length = 512, nullable = false)
|
||||||
public String email;
|
public String email;
|
||||||
public Timestamp emailValidate; // time of validation
|
public Timestamp emailValidate; // time of validation
|
||||||
@Column(length = 512)
|
@Column(length = 512)
|
||||||
public String newEmail;
|
public String newEmail;
|
||||||
@DataDefault("'0'")
|
@DefaultValue("'0'")
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
public Boolean avatar = false;
|
public Boolean avatar = false;
|
||||||
@DataComment("List of accessible application (if not set the application is not available)")
|
@Schema(description ="List of accessible application (if not set the application is not available)")
|
||||||
@ManyToMany(targetEntity = Application.class)
|
@ManyToMany(targetEntity = Application.class)
|
||||||
public List<Long> applications = null;
|
public List<Long> applications = null;
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.kar.karso.model;
|
package org.kar.karso.model;
|
||||||
|
|
||||||
import org.kar.archidata.annotation.DataDefault;
|
|
||||||
import org.kar.archidata.annotation.DataIfNotExists;
|
import org.kar.archidata.annotation.DataIfNotExists;
|
||||||
import org.kar.archidata.model.User;
|
import org.kar.archidata.model.User;
|
||||||
|
|
||||||
@ -8,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
|||||||
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
import jakarta.ws.rs.DefaultValue;
|
||||||
|
|
||||||
@Table(name = "user")
|
@Table(name = "user")
|
||||||
@DataIfNotExists
|
@DataIfNotExists
|
||||||
@ -15,7 +15,7 @@ import jakarta.persistence.Table;
|
|||||||
public class UserAuthGet extends User {
|
public class UserAuthGet extends User {
|
||||||
@Column(length = 512, nullable = false)
|
@Column(length = 512, nullable = false)
|
||||||
public String email;
|
public String email;
|
||||||
@DataDefault("'0'")
|
@DefaultValue("'0'")
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
public Boolean avatar = false;
|
public Boolean avatar = false;
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
"index": "src/index.html",
|
"index": "src/index.html",
|
||||||
"main": "src/app-root/main.ts",
|
"main": "src/app-root/main.ts",
|
||||||
"tsConfig": "src/tsconfig.app-root.json",
|
"tsConfig": "src/tsconfig.app-root.json",
|
||||||
|
"preserveSymlinks": true,
|
||||||
"polyfills": [
|
"polyfills": [
|
||||||
"zone.js"
|
"zone.js"
|
||||||
],
|
],
|
||||||
@ -51,33 +52,38 @@
|
|||||||
"develop": {
|
"develop": {
|
||||||
"optimization": false,
|
"optimization": false,
|
||||||
"outputHashing": "none",
|
"outputHashing": "none",
|
||||||
"sourceMap": true,
|
|
||||||
"namedChunks": true,
|
"namedChunks": true,
|
||||||
"aot": true,
|
"aot": false,
|
||||||
"extractLicenses": true,
|
"extractLicenses": true,
|
||||||
"vendorChunk": true,
|
"vendorChunk": true,
|
||||||
"buildOptimizer": false
|
"buildOptimizer": false,
|
||||||
|
"sourceMap": {
|
||||||
|
"scripts": true,
|
||||||
|
"styles": true,
|
||||||
|
"hidden": false,
|
||||||
|
"vendor": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"serve": {
|
"serve": {
|
||||||
"builder": "@angular-devkit/build-angular:dev-server",
|
"builder": "@angular-devkit/build-angular:dev-server",
|
||||||
"options": {
|
"options": {
|
||||||
"browserTarget": "karso:build"
|
"buildTarget": "karso:build"
|
||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"production": {
|
"production": {
|
||||||
"browserTarget": "karso:build:production"
|
"buildTarget": "karso:build:production"
|
||||||
},
|
},
|
||||||
"develop": {
|
"develop": {
|
||||||
"browserTarget": "karso:build:develop"
|
"buildTarget": "karso:build:develop"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"extract-i18n": {
|
"extract-i18n": {
|
||||||
"builder": "@angular-devkit/build-angular:extract-i18n",
|
"builder": "@angular-devkit/build-angular:extract-i18n",
|
||||||
"options": {
|
"options": {
|
||||||
"browserTarget": "karso:build"
|
"buildTarget": "karso:build"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"test": {
|
"test": {
|
||||||
@ -165,6 +171,7 @@
|
|||||||
"index": "src/index.html",
|
"index": "src/index.html",
|
||||||
"main": "src/app-edge/main.ts",
|
"main": "src/app-edge/main.ts",
|
||||||
"tsConfig": "src/tsconfig.app-edge.json",
|
"tsConfig": "src/tsconfig.app-edge.json",
|
||||||
|
"preserveSymlinks": true,
|
||||||
"polyfills": [
|
"polyfills": [
|
||||||
"zone.js"
|
"zone.js"
|
||||||
],
|
],
|
||||||
@ -201,12 +208,17 @@
|
|||||||
"develop": {
|
"develop": {
|
||||||
"optimization": false,
|
"optimization": false,
|
||||||
"outputHashing": "none",
|
"outputHashing": "none",
|
||||||
"sourceMap": true,
|
|
||||||
"namedChunks": true,
|
"namedChunks": true,
|
||||||
"aot": true,
|
"aot": false,
|
||||||
"extractLicenses": true,
|
"extractLicenses": true,
|
||||||
"vendorChunk": true,
|
"vendorChunk": true,
|
||||||
"buildOptimizer": false,
|
"buildOptimizer": false,
|
||||||
|
"sourceMap": {
|
||||||
|
"scripts": true,
|
||||||
|
"styles": true,
|
||||||
|
"hidden": false,
|
||||||
|
"vendor": true
|
||||||
|
},
|
||||||
"fileReplacements": [
|
"fileReplacements": [
|
||||||
{
|
{
|
||||||
"replace": "src/environments/environment.ts",
|
"replace": "src/environments/environment.ts",
|
||||||
@ -219,14 +231,14 @@
|
|||||||
"serve": {
|
"serve": {
|
||||||
"builder": "@angular-devkit/build-angular:dev-server",
|
"builder": "@angular-devkit/build-angular:dev-server",
|
||||||
"options": {
|
"options": {
|
||||||
"browserTarget": "karso:build"
|
"buildTarget": "karso:build"
|
||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"production": {
|
"production": {
|
||||||
"browserTarget": "karso-edge:build:production"
|
"buildTarget": "karso-edge:build:production"
|
||||||
},
|
},
|
||||||
"develop": {
|
"develop": {
|
||||||
"browserTarget": "karso-edge:build:develop"
|
"buildTarget": "karso-edge:build:develop"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
18611
front/package-lock.json
generated
18611
front/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -14,46 +14,50 @@
|
|||||||
"style": "prettier --write .",
|
"style": "prettier --write .",
|
||||||
"e2e": "ng e2e",
|
"e2e": "ng e2e",
|
||||||
"update_packages": "ncu --upgrade",
|
"update_packages": "ncu --upgrade",
|
||||||
"install_dependency": "npm install"
|
"install_dependency": "pnpm install --force",
|
||||||
|
"link_kar_cw": "pnpm link ../../kar-cw/dist/kar-cw/",
|
||||||
|
"unlink_kar_cw": "pnpm unlink ../../kar-cw/dist/kar-cw/"
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/animations": "^17.2.2",
|
"@angular/animations": "^17.3.6",
|
||||||
"@angular/cdk": "^17.2.1",
|
"@angular/cdk": "^17.3.6",
|
||||||
"@angular/common": "^17.2.2",
|
"@angular/common": "^17.3.6",
|
||||||
"@angular/compiler": "^17.2.2",
|
"@angular/compiler": "^17.3.6",
|
||||||
"@angular/core": "^17.2.2",
|
"@angular/core": "^17.3.6",
|
||||||
"@angular/forms": "^17.2.2",
|
"@angular/forms": "^17.3.6",
|
||||||
"@angular/material": "^17.2.1",
|
"@angular/material": "^17.3.6",
|
||||||
"@angular/platform-browser": "^17.2.2",
|
"@angular/platform-browser": "^17.3.6",
|
||||||
"@angular/platform-browser-dynamic": "^17.2.2",
|
"@angular/platform-browser-dynamic": "^17.3.6",
|
||||||
"@angular/router": "^17.2.2",
|
"@angular/router": "^17.3.6",
|
||||||
"rxjs": "^7.8.1",
|
"rxjs": "^7.8.1",
|
||||||
"zone.js": "^0.14.4",
|
"zone.js": "^0.14.5",
|
||||||
"zod": "3.22.4"
|
"zod": "3.23.5",
|
||||||
|
"@kangaroo-and-rabbit/kar-cw": "^0.2.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular-devkit/build-angular": "^17.2.1",
|
"@angular-devkit/build-angular": "^17.3.6",
|
||||||
"@angular-eslint/builder": "17.2.1",
|
"@angular-eslint/builder": "17.3.0",
|
||||||
"@angular-eslint/eslint-plugin": "17.2.1",
|
"@angular-eslint/eslint-plugin": "17.3.0",
|
||||||
"@angular-eslint/eslint-plugin-template": "17.2.1",
|
"@angular-eslint/eslint-plugin-template": "17.3.0",
|
||||||
"@angular-eslint/schematics": "17.2.1",
|
"@angular-eslint/schematics": "17.3.0",
|
||||||
"@angular-eslint/template-parser": "17.2.1",
|
"@angular-eslint/template-parser": "17.3.0",
|
||||||
"@angular/cli": "^17.2.1",
|
"@angular/cli": "^17.3.6",
|
||||||
"@angular/compiler-cli": "^17.2.2",
|
"@angular/compiler-cli": "^17.3.6",
|
||||||
"@angular/language-service": "^17.2.2",
|
"@angular/language-service": "^17.3.6",
|
||||||
"@playwright/test": "^1.41.2",
|
"@playwright/test": "^1.43.1",
|
||||||
"@types/jest": "^29.5.12",
|
"@types/jest": "^29.5.12",
|
||||||
"jasmine": "^5.1.0",
|
"jasmine": "^5.1.0",
|
||||||
"jasmine-core": "^5.1.2",
|
"jasmine-core": "^5.1.2",
|
||||||
"karma": "^6.4.2",
|
"karma": "^6.4.3",
|
||||||
"karma-coverage": "^2.2.1",
|
"karma-coverage": "^2.2.1",
|
||||||
"karma-coverage-istanbul-reporter": "^3.0.3",
|
"karma-coverage-istanbul-reporter": "^3.0.3",
|
||||||
"karma-firefox-launcher": "^2.1.2",
|
"karma-firefox-launcher": "^2.1.3",
|
||||||
"karma-jasmine": "^5.1.0",
|
"karma-jasmine": "^5.1.0",
|
||||||
"karma-jasmine-html-reporter": "^2.1.0",
|
"karma-jasmine-html-reporter": "^2.1.0",
|
||||||
"karma-spec-reporter": "^0.0.36",
|
"karma-spec-reporter": "^0.0.36",
|
||||||
"prettier": "^3.2.5",
|
"prettier": "^3.2.5",
|
||||||
"npm-check-updates": "^16.14.15"
|
"npm-check-updates": "^16.14.20",
|
||||||
|
"tslib": "^2.6.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
10417
front/pnpm-lock.yaml
Normal file
10417
front/pnpm-lock.yaml
Normal file
File diff suppressed because it is too large
Load Diff
@ -20,8 +20,7 @@ import {
|
|||||||
ApplicationsScene,
|
ApplicationsScene,
|
||||||
ApplicationEditScene,
|
ApplicationEditScene,
|
||||||
} from '../base/scene';
|
} from '../base/scene';
|
||||||
import { OnlyAdminGuard, OnlyUnregisteredGuardHome, OnlyUsersGuard, OnlyUsersGuardHome } from 'common/service/session';
|
import { ForbiddenScene, NotFound404Scene, OnlyAdminGuard, OnlyUnregisteredGuardHome, OnlyUsersGuard, OnlyUsersGuardHome } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import { ForbiddenScene, NotFound404Scene } from 'common/scene';
|
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: '', redirectTo: '/home', pathMatch: 'full' },
|
{ path: '', redirectTo: '/home', pathMatch: 'full' },
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!-- Generig global menu -->
|
<!-- Generig global menu -->
|
||||||
<app-top-menu [menu]="currentMenu" (callback)="eventOnMenu($event)"></app-top-menu>
|
<karcw-top-menu [menu]="currentMenu" (callback)="eventOnMenu($event)"/>
|
||||||
<!-- all interfaced pages -->
|
<!-- all interfaced pages -->
|
||||||
<div class="main-content">
|
<div class="main-content">
|
||||||
@if(autoConnectedDone) {
|
@if(autoConnectedDone) {
|
||||||
|
@ -5,11 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { EventOnMenu } from 'common/component/top-menu/top-menu';
|
import { MenuItem, UserService, SessionService, SSOService, MenuPosition, EventOnMenu } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import { UserService } from 'common/service/user';
|
|
||||||
import { SessionService } from 'common/service/session';
|
|
||||||
import { MenuItem, MenuPosition } from 'common/model/menu-item';
|
|
||||||
import { SSOService } from 'common/service';
|
|
||||||
import { environment } from 'environments/environment';
|
import { environment } from 'environments/environment';
|
||||||
|
|
||||||
enum MenuEventType {
|
enum MenuEventType {
|
||||||
|
@ -26,49 +26,14 @@ import {
|
|||||||
ApplicationsScene,
|
ApplicationsScene,
|
||||||
ApplicationEditScene,
|
ApplicationEditScene,
|
||||||
} from 'base/scene';
|
} from 'base/scene';
|
||||||
import {
|
|
||||||
BddService,
|
|
||||||
CookiesService,
|
|
||||||
HttpWrapperService,
|
|
||||||
NotificationService,
|
|
||||||
OnlyAdminGuard,
|
|
||||||
OnlyUnregisteredGuardHome,
|
|
||||||
OnlyUsersGuard,
|
|
||||||
OnlyUsersGuardHome,
|
|
||||||
PopInService,
|
|
||||||
SessionService,
|
|
||||||
SSOService,
|
|
||||||
StorageService,
|
|
||||||
UserService,
|
|
||||||
} from 'common/service';
|
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { ErrorComponent, PopInComponent, SpinerComponent, TopMenuComponent, UploadFileComponent, PasswordEntryComponent, EntryComponent, AsyncActionStatusComponent, ErrorMessageStateComponent, CheckboxComponent, BurgerPropertyComponent, EntryValidatorComponent, RenderSettingsComponent, RenderFormComponent, EntryNumberComponent } from 'common/component';
|
import { AdminUserService, ApplicationService, ApplicationTokenService } from 'base/service';
|
||||||
import { ForbiddenScene } from 'common/scene';
|
import { KarCWModule } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import { AdminUserService, ApplicationService, ApplicationTokenService, SettingsService } from 'base/service';
|
import { environment } from 'environments/environment';
|
||||||
import { PopInUploadProgress, PopInDeleteConfirm } from 'common/popin';
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
AppComponent,
|
AppComponent,
|
||||||
TopMenuComponent,
|
|
||||||
UploadFileComponent,
|
|
||||||
ErrorComponent,
|
|
||||||
PasswordEntryComponent,
|
|
||||||
EntryComponent,
|
|
||||||
EntryValidatorComponent,
|
|
||||||
SpinerComponent,
|
|
||||||
AsyncActionStatusComponent,
|
|
||||||
ErrorMessageStateComponent,
|
|
||||||
CheckboxComponent,
|
|
||||||
BurgerPropertyComponent,
|
|
||||||
RenderSettingsComponent,
|
|
||||||
RenderFormComponent,
|
|
||||||
EntryNumberComponent,
|
|
||||||
|
|
||||||
PopInComponent,
|
|
||||||
PopInUploadProgress,
|
|
||||||
PopInDeleteConfirm,
|
|
||||||
|
|
||||||
SignInScene,
|
SignInScene,
|
||||||
SignUpScene,
|
SignUpScene,
|
||||||
SignOutScene,
|
SignOutScene,
|
||||||
@ -78,7 +43,6 @@ import { PopInUploadProgress, PopInDeleteConfirm } from 'common/popin';
|
|||||||
HelpScene,
|
HelpScene,
|
||||||
ForgotPasswordScene,
|
ForgotPasswordScene,
|
||||||
SettingsScene,
|
SettingsScene,
|
||||||
ForbiddenScene,
|
|
||||||
ChangePasswordScene,
|
ChangePasswordScene,
|
||||||
HomeUnregisteredScene,
|
HomeUnregisteredScene,
|
||||||
ManageAccountsScene,
|
ManageAccountsScene,
|
||||||
@ -93,42 +57,19 @@ import { PopInUploadProgress, PopInDeleteConfirm } from 'common/popin';
|
|||||||
FormsModule,
|
FormsModule,
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
CommonModule,
|
CommonModule,
|
||||||
|
KarCWModule,
|
||||||
],
|
],
|
||||||
// injectable element
|
// injectable element
|
||||||
providers: [
|
providers: [
|
||||||
|
{ provide: 'ENVIRONMENT', useValue: environment },
|
||||||
// application
|
// application
|
||||||
AdminUserService,
|
AdminUserService,
|
||||||
ApplicationService,
|
ApplicationService,
|
||||||
ApplicationTokenService,
|
ApplicationTokenService,
|
||||||
|
|
||||||
// common
|
|
||||||
BddService,
|
|
||||||
CookiesService,
|
|
||||||
HttpWrapperService,
|
|
||||||
StorageService,
|
|
||||||
PopInService,
|
|
||||||
SessionService,
|
|
||||||
UserService,
|
|
||||||
SSOService,
|
|
||||||
NotificationService,
|
|
||||||
SettingsService,
|
|
||||||
OnlyUsersGuard,
|
|
||||||
OnlyAdminGuard,
|
|
||||||
OnlyUsersGuardHome,
|
|
||||||
OnlyUnregisteredGuardHome,
|
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
AppComponent,
|
AppComponent,
|
||||||
TopMenuComponent,
|
|
||||||
PasswordEntryComponent,
|
|
||||||
UploadFileComponent,
|
|
||||||
ErrorComponent,
|
|
||||||
BurgerPropertyComponent,
|
|
||||||
|
|
||||||
BurgerPropertyComponent,
|
|
||||||
PopInComponent,
|
|
||||||
PopInUploadProgress,
|
|
||||||
PopInDeleteConfirm,
|
|
||||||
],
|
],
|
||||||
bootstrap: [AppComponent],
|
bootstrap: [AppComponent],
|
||||||
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
|
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
|
||||||
|
@ -22,8 +22,7 @@ import {
|
|||||||
ApplicationUserEditScene,
|
ApplicationUserEditScene,
|
||||||
applicationUserRightEditScene,
|
applicationUserRightEditScene,
|
||||||
} from '../base/scene';
|
} from '../base/scene';
|
||||||
import { OnlyAdminGuard, OnlyUnregisteredGuardHome, OnlyUsersGuard, OnlyUsersGuardHome } from 'common/service/session';
|
import { ForbiddenScene, NotFound404Scene, OnlyAdminGuard, OnlyUnregisteredGuardHome, OnlyUsersGuard, OnlyUsersGuardHome } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import { ForbiddenScene, NotFound404Scene } from 'common/scene';
|
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: '', redirectTo: '/home', pathMatch: 'full' },
|
{ path: '', redirectTo: '/home', pathMatch: 'full' },
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!-- Generig global menu -->
|
<!-- Generig global menu -->
|
||||||
<app-top-menu [menu]="currentMenu" (callback)="eventOnMenu($event)"></app-top-menu>
|
<karcw-top-menu [menu]="currentMenu" (callback)="eventOnMenu($event)"/>
|
||||||
<!-- all interfaced pages -->
|
<!-- all interfaced pages -->
|
||||||
<div class="main-content">
|
<div class="main-content">
|
||||||
@if(autoConnectedDone) {
|
@if(autoConnectedDone) {
|
||||||
|
@ -5,12 +5,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { EventOnMenu } from 'common/component/top-menu/top-menu';
|
import { EventOnMenu, MenuItem, MenuPosition, SSOService, SessionService, UserRoles222, UserService } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import { UserService } from 'common/service/user';
|
import { environmentKarso } from 'environments/environment';
|
||||||
import { SessionService, UserRoles222 } from 'common/service/session';
|
|
||||||
import { MenuItem, MenuPosition } from 'common/model/menu-item';
|
|
||||||
import { SSOService } from 'common/service';
|
|
||||||
import { environment } from 'environments/environment';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
@ -18,7 +14,7 @@ import { environment } from 'environments/environment';
|
|||||||
styleUrls: ['./app.component.less'],
|
styleUrls: ['./app.component.less'],
|
||||||
})
|
})
|
||||||
export class AppComponent implements OnInit {
|
export class AppComponent implements OnInit {
|
||||||
title: string = environment.edgeMode ? 'Karso-edge' : 'Karso';
|
title: string = environmentKarso.edgeMode ? 'Karso-edge' : 'Karso';
|
||||||
autoConnectedDone: boolean = false;
|
autoConnectedDone: boolean = false;
|
||||||
isConnected: boolean = false;
|
isConnected: boolean = false;
|
||||||
signUpEnable: boolean = true;
|
signUpEnable: boolean = true;
|
||||||
|
@ -28,65 +28,15 @@ import {
|
|||||||
ApplicationUserEditScene,
|
ApplicationUserEditScene,
|
||||||
applicationUserRightEditScene,
|
applicationUserRightEditScene,
|
||||||
} from 'base/scene';
|
} from 'base/scene';
|
||||||
import {
|
|
||||||
BddService,
|
|
||||||
CookiesService,
|
|
||||||
HttpWrapperService,
|
|
||||||
NotificationService,
|
|
||||||
OnlyAdminGuard,
|
|
||||||
OnlyUnregisteredGuardHome,
|
|
||||||
OnlyUsersGuard,
|
|
||||||
OnlyUsersGuardHome,
|
|
||||||
PopInService,
|
|
||||||
SessionService,
|
|
||||||
SSOService,
|
|
||||||
StorageService,
|
|
||||||
UserService,
|
|
||||||
} from 'common/service';
|
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import {
|
|
||||||
ErrorComponent,
|
import { AdminUserService, ApplicationService, ApplicationTokenService } from 'base/service';
|
||||||
PopInComponent,
|
|
||||||
SpinerComponent,
|
|
||||||
TopMenuComponent,
|
|
||||||
UploadFileComponent,
|
|
||||||
PasswordEntryComponent,
|
|
||||||
EntryComponent,
|
|
||||||
AsyncActionStatusComponent,
|
|
||||||
ErrorMessageStateComponent,
|
|
||||||
CheckboxComponent,
|
|
||||||
BurgerPropertyComponent,
|
|
||||||
EntryValidatorComponent,
|
|
||||||
RenderSettingsComponent,
|
|
||||||
RenderFormComponent,
|
|
||||||
EntryNumberComponent,
|
|
||||||
} from 'common/component';
|
|
||||||
import { ForbiddenScene } from 'common/scene';
|
|
||||||
import { AdminUserService, ApplicationService, ApplicationTokenService, SettingsService } from 'base/service';
|
|
||||||
import { PopInUploadProgress, PopInDeleteConfirm } from 'common/popin';
|
|
||||||
import { environment } from 'environments/environment';
|
import { environment } from 'environments/environment';
|
||||||
|
import { KarCWModule } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
AppComponent,
|
AppComponent,
|
||||||
TopMenuComponent,
|
|
||||||
UploadFileComponent,
|
|
||||||
ErrorComponent,
|
|
||||||
PasswordEntryComponent,
|
|
||||||
EntryComponent,
|
|
||||||
EntryValidatorComponent,
|
|
||||||
SpinerComponent,
|
|
||||||
AsyncActionStatusComponent,
|
|
||||||
ErrorMessageStateComponent,
|
|
||||||
CheckboxComponent,
|
|
||||||
BurgerPropertyComponent,
|
|
||||||
RenderSettingsComponent,
|
|
||||||
RenderFormComponent,
|
|
||||||
EntryNumberComponent,
|
|
||||||
|
|
||||||
PopInComponent,
|
|
||||||
PopInUploadProgress,
|
|
||||||
PopInDeleteConfirm,
|
|
||||||
|
|
||||||
SignInScene,
|
SignInScene,
|
||||||
SignUpScene,
|
SignUpScene,
|
||||||
@ -97,7 +47,6 @@ import { environment } from 'environments/environment';
|
|||||||
HelpScene,
|
HelpScene,
|
||||||
ForgotPasswordScene,
|
ForgotPasswordScene,
|
||||||
SettingsScene,
|
SettingsScene,
|
||||||
ForbiddenScene,
|
|
||||||
ChangePasswordScene,
|
ChangePasswordScene,
|
||||||
HomeUnregisteredScene,
|
HomeUnregisteredScene,
|
||||||
ManageAccountsScene,
|
ManageAccountsScene,
|
||||||
@ -114,42 +63,19 @@ import { environment } from 'environments/environment';
|
|||||||
FormsModule,
|
FormsModule,
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
CommonModule,
|
CommonModule,
|
||||||
|
KarCWModule,
|
||||||
],
|
],
|
||||||
// injectable element
|
// injectable element
|
||||||
providers: [
|
providers: [
|
||||||
|
{ provide: 'ENVIRONMENT', useValue: environment },
|
||||||
// application
|
// application
|
||||||
AdminUserService,
|
AdminUserService,
|
||||||
ApplicationService,
|
ApplicationService,
|
||||||
ApplicationTokenService,
|
ApplicationTokenService,
|
||||||
|
|
||||||
// common
|
|
||||||
BddService,
|
|
||||||
CookiesService,
|
|
||||||
HttpWrapperService,
|
|
||||||
StorageService,
|
|
||||||
PopInService,
|
|
||||||
SessionService,
|
|
||||||
UserService,
|
|
||||||
SSOService,
|
|
||||||
NotificationService,
|
|
||||||
SettingsService,
|
|
||||||
OnlyUsersGuard,
|
|
||||||
OnlyAdminGuard,
|
|
||||||
OnlyUsersGuardHome,
|
|
||||||
OnlyUnregisteredGuardHome,
|
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
AppComponent,
|
AppComponent,
|
||||||
TopMenuComponent,
|
|
||||||
PasswordEntryComponent,
|
|
||||||
UploadFileComponent,
|
|
||||||
ErrorComponent,
|
|
||||||
BurgerPropertyComponent,
|
|
||||||
|
|
||||||
BurgerPropertyComponent,
|
|
||||||
PopInComponent,
|
|
||||||
PopInUploadProgress,
|
|
||||||
PopInDeleteConfirm,
|
|
||||||
],
|
],
|
||||||
bootstrap: [AppComponent],
|
bootstrap: [AppComponent],
|
||||||
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
|
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
|
||||||
|
252
front/src/back-api/application-resource.ts
Normal file
252
front/src/back-api/application-resource.ts
Normal file
@ -0,0 +1,252 @@
|
|||||||
|
/**
|
||||||
|
* API of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import {
|
||||||
|
HTTPMimeType,
|
||||||
|
HTTPRequestModel,
|
||||||
|
ModelResponseHttp,
|
||||||
|
RESTCallbacks,
|
||||||
|
RESTConfig,
|
||||||
|
RESTRequestJson,
|
||||||
|
RESTRequestJsonArray,
|
||||||
|
RESTRequestVoid
|
||||||
|
} from "./rest-tools"
|
||||||
|
import {
|
||||||
|
Application,
|
||||||
|
RightDescription,
|
||||||
|
Long,
|
||||||
|
ClientToken,
|
||||||
|
ApplicationSmall,
|
||||||
|
AddUserData,
|
||||||
|
isApplication,
|
||||||
|
isRightDescription,
|
||||||
|
isLong,
|
||||||
|
isClientToken,
|
||||||
|
isApplicationSmall,
|
||||||
|
} from "./model"
|
||||||
|
export namespace ApplicationResource {
|
||||||
|
|
||||||
|
export function remove({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/application/{id}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export function get({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Application> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/application/{id}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isApplication);
|
||||||
|
};
|
||||||
|
export function create({
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
data: Application,
|
||||||
|
}): Promise<Application> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/application",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}, isApplication);
|
||||||
|
};
|
||||||
|
export function patch({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: Application,
|
||||||
|
}): Promise<Application> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/application/{id}",
|
||||||
|
requestType: HTTPRequestModel.PATCH,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, isApplication);
|
||||||
|
};
|
||||||
|
export function gets({
|
||||||
|
restConfig,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<Application[]> {
|
||||||
|
return RESTRequestJsonArray({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/application",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isApplication);
|
||||||
|
};
|
||||||
|
export function getApplicationUsers({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Long[]> {
|
||||||
|
return RESTRequestJsonArray({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/application/{id}/users",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isLong);
|
||||||
|
};
|
||||||
|
export function getApplicationsSmall({
|
||||||
|
restConfig,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<ApplicationSmall[]> {
|
||||||
|
return RESTRequestJsonArray({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/application/small",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isApplicationSmall);
|
||||||
|
};
|
||||||
|
export function addUser({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: AddUserData,
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/application/{id}/users",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export function removeUser({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
userId: Long,
|
||||||
|
},
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/application/{id}/users/${userId}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export function getRightsDescription({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<RightDescription[]> {
|
||||||
|
return RESTRequestJsonArray({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/application/{id}/rights",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isRightDescription);
|
||||||
|
};
|
||||||
|
export function getClientToken({
|
||||||
|
restConfig,
|
||||||
|
queries,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
queries: {
|
||||||
|
application?: string,
|
||||||
|
},
|
||||||
|
}): Promise<ClientToken> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/application/get_token",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
queries,
|
||||||
|
}, isClientToken);
|
||||||
|
};
|
||||||
|
export function logOut({
|
||||||
|
restConfig,
|
||||||
|
queries,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
queries: {
|
||||||
|
application?: string,
|
||||||
|
},
|
||||||
|
}): Promise<string> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/application/return",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
queries,
|
||||||
|
}, null);
|
||||||
|
};
|
||||||
|
}
|
84
front/src/back-api/application-token-resource.ts
Normal file
84
front/src/back-api/application-token-resource.ts
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
/**
|
||||||
|
* API of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import {
|
||||||
|
HTTPMimeType,
|
||||||
|
HTTPRequestModel,
|
||||||
|
ModelResponseHttp,
|
||||||
|
RESTCallbacks,
|
||||||
|
RESTConfig,
|
||||||
|
RESTRequestJson,
|
||||||
|
RESTRequestJsonArray,
|
||||||
|
RESTRequestVoid
|
||||||
|
} from "./rest-tools"
|
||||||
|
import {
|
||||||
|
ApplicationToken,
|
||||||
|
Integer,
|
||||||
|
Long,
|
||||||
|
CreateRequest,
|
||||||
|
isApplicationToken,
|
||||||
|
} from "./model"
|
||||||
|
export namespace ApplicationTokenResource {
|
||||||
|
|
||||||
|
export function remove({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
tokenId: Integer,
|
||||||
|
applicationId: Long,
|
||||||
|
},
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/application_token/{applicationId}/{tokenId}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export function create({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
applicationId: Long,
|
||||||
|
},
|
||||||
|
data: CreateRequest,
|
||||||
|
}): Promise<ApplicationToken> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/application_token//{applicationId}/create",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, isApplicationToken);
|
||||||
|
};
|
||||||
|
export function gets({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
applicationId: Long,
|
||||||
|
},
|
||||||
|
}): Promise<ApplicationToken[]> {
|
||||||
|
return RESTRequestJsonArray({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/application_token/{applicationId}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isApplicationToken);
|
||||||
|
};
|
||||||
|
}
|
132
front/src/back-api/data-resource.ts
Normal file
132
front/src/back-api/data-resource.ts
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
/**
|
||||||
|
* API of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import {
|
||||||
|
HTTPMimeType,
|
||||||
|
HTTPRequestModel,
|
||||||
|
ModelResponseHttp,
|
||||||
|
RESTCallbacks,
|
||||||
|
RESTConfig,
|
||||||
|
RESTRequestJson,
|
||||||
|
RESTRequestJsonArray,
|
||||||
|
RESTRequestVoid
|
||||||
|
} from "./rest-tools"
|
||||||
|
import {
|
||||||
|
UUID,
|
||||||
|
} from "./model"
|
||||||
|
export namespace DataResource {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a thumbnail of from the data environment (if resize is possible)
|
||||||
|
*/
|
||||||
|
// TODO: unmanaged "Response" type: please specify @AsyncType or considered as 'void'.
|
||||||
|
export function retrieveDataThumbnailId({
|
||||||
|
restConfig,
|
||||||
|
queries,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
queries: {
|
||||||
|
Authorization?: string,
|
||||||
|
},
|
||||||
|
params: {
|
||||||
|
uuid: UUID,
|
||||||
|
},
|
||||||
|
data: string,
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/data/thumbnail/{uuid}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
queries,
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Get back some data from the data environment (with a beautiful name (permit download with basic name)
|
||||||
|
*/
|
||||||
|
// TODO: unmanaged "Response" type: please specify @AsyncType or considered as 'void'.
|
||||||
|
export function retrieveDataFull({
|
||||||
|
restConfig,
|
||||||
|
queries,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
queries: {
|
||||||
|
Authorization?: string,
|
||||||
|
},
|
||||||
|
params: {
|
||||||
|
name: string,
|
||||||
|
uuid: UUID,
|
||||||
|
},
|
||||||
|
data: string,
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/data/{uuid}/{name}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
queries,
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Insert a new data in the data environment
|
||||||
|
*/
|
||||||
|
export function uploadFile({
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
data: {
|
||||||
|
file: File,
|
||||||
|
},
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/data//upload/",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Get back some data from the data environment
|
||||||
|
*/
|
||||||
|
// TODO: unmanaged "Response" type: please specify @AsyncType or considered as 'void'.
|
||||||
|
export function retrieveDataId({
|
||||||
|
restConfig,
|
||||||
|
queries,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
queries: {
|
||||||
|
Authorization?: string,
|
||||||
|
},
|
||||||
|
params: {
|
||||||
|
uuid: UUID,
|
||||||
|
},
|
||||||
|
data: string,
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/data/{uuid}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
queries,
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
18
front/src/back-api/front.ts
Normal file
18
front/src/back-api/front.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/**
|
||||||
|
* API of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import {
|
||||||
|
HTTPMimeType,
|
||||||
|
HTTPRequestModel,
|
||||||
|
ModelResponseHttp,
|
||||||
|
RESTCallbacks,
|
||||||
|
RESTConfig,
|
||||||
|
RESTRequestJson,
|
||||||
|
RESTRequestJsonArray,
|
||||||
|
RESTRequestVoid
|
||||||
|
} from "./rest-tools"
|
||||||
|
import {
|
||||||
|
} from "./model"
|
||||||
|
export namespace Front {
|
||||||
|
|
||||||
|
}
|
12
front/src/back-api/index.ts
Normal file
12
front/src/back-api/index.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Global import of the package
|
||||||
|
*/
|
||||||
|
export * from "./model";
|
||||||
|
export * from "./front";
|
||||||
|
export * from "./data-resource";
|
||||||
|
export * from "./application-resource";
|
||||||
|
export * from "./application-token-resource";
|
||||||
|
export * from "./public-key-resource";
|
||||||
|
export * from "./right-resource";
|
||||||
|
export * from "./user-resource";
|
||||||
|
export * from "./system-config-resource";
|
549
front/src/back-api/model.ts
Normal file
549
front/src/back-api/model.ts
Normal file
@ -0,0 +1,549 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
export const ZodUUID = zod.string().uuid();
|
||||||
|
export type UUID = zod.infer<typeof ZodUUID>;
|
||||||
|
export function isUUID(data: any): data is UUID {
|
||||||
|
try {
|
||||||
|
ZodUUID.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodLong = zod.number();
|
||||||
|
export type Long = zod.infer<typeof ZodLong>;
|
||||||
|
export function isLong(data: any): data is Long {
|
||||||
|
try {
|
||||||
|
ZodLong.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodInteger = zod.number().safe();
|
||||||
|
export type Integer = zod.infer<typeof ZodInteger>;
|
||||||
|
export function isInteger(data: any): data is Integer {
|
||||||
|
try {
|
||||||
|
ZodInteger.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodFloat = zod.number();
|
||||||
|
export type Float = zod.infer<typeof ZodFloat>;
|
||||||
|
export function isFloat(data: any): data is Float {
|
||||||
|
try {
|
||||||
|
ZodFloat.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodInstant = zod.string();
|
||||||
|
export type Instant = zod.infer<typeof ZodInstant>;
|
||||||
|
export function isInstant(data: any): data is Instant {
|
||||||
|
try {
|
||||||
|
ZodInstant.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodDate = zod.date();
|
||||||
|
export type Date = zod.infer<typeof ZodDate>;
|
||||||
|
export function isDate(data: any): data is Date {
|
||||||
|
try {
|
||||||
|
ZodDate.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodTimestamp = zod.date();
|
||||||
|
export type Timestamp = zod.infer<typeof ZodTimestamp>;
|
||||||
|
export function isTimestamp(data: any): data is Timestamp {
|
||||||
|
try {
|
||||||
|
ZodTimestamp.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodLocalDate = zod.date();
|
||||||
|
export type LocalDate = zod.infer<typeof ZodLocalDate>;
|
||||||
|
export function isLocalDate(data: any): data is LocalDate {
|
||||||
|
try {
|
||||||
|
ZodLocalDate.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodLocalTime = zod.date();
|
||||||
|
export type LocalTime = zod.infer<typeof ZodLocalTime>;
|
||||||
|
export function isLocalTime(data: any): data is LocalTime {
|
||||||
|
try {
|
||||||
|
ZodLocalTime.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodRestErrorResponse = zod.object({
|
||||||
|
uuid: ZodUUID.optional(),
|
||||||
|
name: zod.string().max(255).optional(),
|
||||||
|
message: zod.string().max(255).optional(),
|
||||||
|
time: zod.string().max(255).optional(),
|
||||||
|
status: ZodInteger,
|
||||||
|
statusMessage: zod.string().max(255).optional()
|
||||||
|
});
|
||||||
|
export type RestErrorResponse = zod.infer<typeof ZodRestErrorResponse>;
|
||||||
|
export function isRestErrorResponse(data: any): data is RestErrorResponse {
|
||||||
|
try {
|
||||||
|
ZodRestErrorResponse.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodGenericTiming = zod.object({
|
||||||
|
// Create time of the object
|
||||||
|
createdAt: ZodDate.readonly().optional(),
|
||||||
|
// When update the object
|
||||||
|
updatedAt: ZodDate.readonly().optional()
|
||||||
|
});
|
||||||
|
export type GenericTiming = zod.infer<typeof ZodGenericTiming>;
|
||||||
|
export function isGenericTiming(data: any): data is GenericTiming {
|
||||||
|
try {
|
||||||
|
ZodGenericTiming.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodGenericData = ZodGenericTiming.extend({
|
||||||
|
// Unique Id of the object
|
||||||
|
id: ZodLong.readonly().optional()
|
||||||
|
});
|
||||||
|
export type GenericData = zod.infer<typeof ZodGenericData>;
|
||||||
|
export function isGenericData(data: any): data is GenericData {
|
||||||
|
try {
|
||||||
|
ZodGenericData.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodGenericDataSoftDelete = ZodGenericData.extend({
|
||||||
|
// Deleted state
|
||||||
|
deleted: zod.boolean().readonly().optional()
|
||||||
|
});
|
||||||
|
export type GenericDataSoftDelete = zod.infer<typeof ZodGenericDataSoftDelete>;
|
||||||
|
export function isGenericDataSoftDelete(data: any): data is GenericDataSoftDelete {
|
||||||
|
try {
|
||||||
|
ZodGenericDataSoftDelete.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodApplication = ZodGenericDataSoftDelete.extend({
|
||||||
|
name: zod.string().max(256).optional(),
|
||||||
|
description: zod.string().max(2048).optional(),
|
||||||
|
redirect: zod.string().max(2048).optional(),
|
||||||
|
redirectDev: zod.string().max(2048).optional(),
|
||||||
|
notification: zod.string().max(2048).optional(),
|
||||||
|
// Expiration time
|
||||||
|
ttl: ZodInteger.optional(),
|
||||||
|
// Right is manage with Karso
|
||||||
|
manageRight: zod.boolean().optional()
|
||||||
|
});
|
||||||
|
export type Application = zod.infer<typeof ZodApplication>;
|
||||||
|
export function isApplication(data: any): data is Application {
|
||||||
|
try {
|
||||||
|
ZodApplication.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodApplicationSmall = zod.object({
|
||||||
|
id: ZodLong.optional(),
|
||||||
|
name: zod.string().max(255).optional(),
|
||||||
|
description: zod.string().max(255).optional(),
|
||||||
|
redirect: zod.string().max(255).optional()
|
||||||
|
});
|
||||||
|
export type ApplicationSmall = zod.infer<typeof ZodApplicationSmall>;
|
||||||
|
export function isApplicationSmall(data: any): data is ApplicationSmall {
|
||||||
|
try {
|
||||||
|
ZodApplicationSmall.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodAddUserData = zod.object({
|
||||||
|
userId: ZodLong
|
||||||
|
});
|
||||||
|
export type AddUserData = zod.infer<typeof ZodAddUserData>;
|
||||||
|
export function isAddUserData(data: any): data is AddUserData {
|
||||||
|
try {
|
||||||
|
ZodAddUserData.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodRightDescription = ZodGenericDataSoftDelete.extend({
|
||||||
|
// Application id that have the reference of the right
|
||||||
|
applicationId: ZodLong.optional(),
|
||||||
|
// Key of the property
|
||||||
|
key: zod.string().max(64).optional(),
|
||||||
|
// Title of the right
|
||||||
|
title: zod.string().max(1024).optional(),
|
||||||
|
// Description of the right
|
||||||
|
description: zod.string().max(1024).optional(),
|
||||||
|
// default value if Never set
|
||||||
|
defaultValue: zod.string().max(1024).optional(),
|
||||||
|
// Type of the property
|
||||||
|
type: zod.string().max(16).optional()
|
||||||
|
});
|
||||||
|
export type RightDescription = zod.infer<typeof ZodRightDescription>;
|
||||||
|
export function isRightDescription(data: any): data is RightDescription {
|
||||||
|
try {
|
||||||
|
ZodRightDescription.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodClientToken = zod.object({
|
||||||
|
url: zod.string().max(255).optional(),
|
||||||
|
jwt: zod.string().max(255).optional()
|
||||||
|
});
|
||||||
|
export type ClientToken = zod.infer<typeof ZodClientToken>;
|
||||||
|
export function isClientToken(data: any): data is ClientToken {
|
||||||
|
try {
|
||||||
|
ZodClientToken.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodGenericToken = ZodGenericDataSoftDelete.extend({
|
||||||
|
parentId: ZodLong.optional(),
|
||||||
|
name: zod.string().optional(),
|
||||||
|
endValidityTime: ZodTimestamp.optional(),
|
||||||
|
token: zod.string().optional()
|
||||||
|
});
|
||||||
|
export type GenericToken = zod.infer<typeof ZodGenericToken>;
|
||||||
|
export function isGenericToken(data: any): data is GenericToken {
|
||||||
|
try {
|
||||||
|
ZodGenericToken.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodApplicationToken = ZodGenericToken.extend({
|
||||||
|
});
|
||||||
|
export type ApplicationToken = zod.infer<typeof ZodApplicationToken>;
|
||||||
|
export function isApplicationToken(data: any): data is ApplicationToken {
|
||||||
|
try {
|
||||||
|
ZodApplicationToken.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodCreateRequest = zod.object({
|
||||||
|
name: zod.string().max(255).optional(),
|
||||||
|
validity: ZodInteger.optional()
|
||||||
|
});
|
||||||
|
export type CreateRequest = zod.infer<typeof ZodCreateRequest>;
|
||||||
|
export function isCreateRequest(data: any): data is CreateRequest {
|
||||||
|
try {
|
||||||
|
ZodCreateRequest.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodPublicKey = zod.object({
|
||||||
|
key: zod.string().max(255).optional()
|
||||||
|
});
|
||||||
|
export type PublicKey = zod.infer<typeof ZodPublicKey>;
|
||||||
|
export function isPublicKey(data: any): data is PublicKey {
|
||||||
|
try {
|
||||||
|
ZodPublicKey.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodRight = ZodGenericDataSoftDelete.extend({
|
||||||
|
// application-ID that have the reference of the right
|
||||||
|
applicationId: ZodLong.optional(),
|
||||||
|
// user-ID
|
||||||
|
userId: ZodLong.optional(),
|
||||||
|
// rightDescription-ID of the right description
|
||||||
|
rightDescriptionId: ZodLong.optional(),
|
||||||
|
// Value of the right
|
||||||
|
value: zod.string().max(1024).optional()
|
||||||
|
});
|
||||||
|
export type Right = zod.infer<typeof ZodRight>;
|
||||||
|
export function isRight(data: any): data is Right {
|
||||||
|
try {
|
||||||
|
ZodRight.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodUser = ZodGenericDataSoftDelete.extend({
|
||||||
|
login: zod.string().max(128).optional(),
|
||||||
|
lastConnection: ZodTimestamp.optional(),
|
||||||
|
admin: zod.boolean(),
|
||||||
|
blocked: zod.boolean(),
|
||||||
|
removed: zod.boolean(),
|
||||||
|
covers: zod.array(ZodLong).optional()
|
||||||
|
});
|
||||||
|
export type User = zod.infer<typeof ZodUser>;
|
||||||
|
export function isUser(data: any): data is User {
|
||||||
|
try {
|
||||||
|
ZodUser.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodUserAuthGet = ZodUser.extend({
|
||||||
|
email: zod.string().max(512).optional(),
|
||||||
|
avatar: zod.boolean().optional()
|
||||||
|
});
|
||||||
|
export type UserAuthGet = zod.infer<typeof ZodUserAuthGet>;
|
||||||
|
export function isUserAuthGet(data: any): data is UserAuthGet {
|
||||||
|
try {
|
||||||
|
ZodUserAuthGet.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodUserCreate = zod.object({
|
||||||
|
login: zod.string().max(255).optional(),
|
||||||
|
email: zod.string().max(255).optional(),
|
||||||
|
password: zod.string().max(255).optional()
|
||||||
|
});
|
||||||
|
export type UserCreate = zod.infer<typeof ZodUserCreate>;
|
||||||
|
export function isUserCreate(data: any): data is UserCreate {
|
||||||
|
try {
|
||||||
|
ZodUserCreate.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodUserAuth = ZodUser.extend({
|
||||||
|
password: zod.string().max(128).optional(),
|
||||||
|
email: zod.string().max(512).optional(),
|
||||||
|
emailValidate: ZodTimestamp.optional(),
|
||||||
|
newEmail: zod.string().max(512).optional(),
|
||||||
|
avatar: zod.boolean().optional(),
|
||||||
|
// List of accessible application (if not set the application is not available)
|
||||||
|
applications: zod.array(ZodLong).optional()
|
||||||
|
});
|
||||||
|
export type UserAuth = zod.infer<typeof ZodUserAuth>;
|
||||||
|
export function isUserAuth(data: any): data is UserAuth {
|
||||||
|
try {
|
||||||
|
ZodUserAuth.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodUserOut = zod.object({
|
||||||
|
id: ZodLong,
|
||||||
|
login: zod.string().max(255).optional()
|
||||||
|
});
|
||||||
|
export type UserOut = zod.infer<typeof ZodUserOut>;
|
||||||
|
export function isUserOut(data: any): data is UserOut {
|
||||||
|
try {
|
||||||
|
ZodUserOut.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodChangePassword = zod.object({
|
||||||
|
method: zod.string().max(32).optional(),
|
||||||
|
login: zod.string().max(512).optional(),
|
||||||
|
time: zod.string().max(64).optional(),
|
||||||
|
password: zod.string().max(128).optional(),
|
||||||
|
newPassword: zod.string().max(128).optional()
|
||||||
|
});
|
||||||
|
export type ChangePassword = zod.infer<typeof ZodChangePassword>;
|
||||||
|
export function isChangePassword(data: any): data is ChangePassword {
|
||||||
|
try {
|
||||||
|
ZodChangePassword.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodGetToken = zod.object({
|
||||||
|
jwt: zod.string().optional()
|
||||||
|
});
|
||||||
|
export type GetToken = zod.infer<typeof ZodGetToken>;
|
||||||
|
export function isGetToken(data: any): data is GetToken {
|
||||||
|
try {
|
||||||
|
ZodGetToken.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodDataGetToken = zod.object({
|
||||||
|
});
|
||||||
|
export type DataGetToken = zod.infer<typeof ZodDataGetToken>;
|
||||||
|
export function isDataGetToken(data: any): data is DataGetToken {
|
||||||
|
try {
|
||||||
|
ZodDataGetToken.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodGetSignUpAvailable = zod.object({
|
||||||
|
signup: zod.boolean()
|
||||||
|
});
|
||||||
|
export type GetSignUpAvailable = zod.infer<typeof ZodGetSignUpAvailable>;
|
||||||
|
export function isGetSignUpAvailable(data: any): data is GetSignUpAvailable {
|
||||||
|
try {
|
||||||
|
ZodGetSignUpAvailable.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodSettings = ZodGenericDataSoftDelete.extend({
|
||||||
|
key: zod.string().max(512).optional(),
|
||||||
|
// Right for the specific element(ADMIN [rw] USER [rw] other [rw])
|
||||||
|
right: zod.string().max(6).optional(),
|
||||||
|
// Type Of the data
|
||||||
|
type: zod.string().max(10).optional(),
|
||||||
|
// Value of the configuration
|
||||||
|
value: zod.string().max(255).optional()
|
||||||
|
});
|
||||||
|
export type Settings = zod.infer<typeof ZodSettings>;
|
||||||
|
export function isSettings(data: any): data is Settings {
|
||||||
|
try {
|
||||||
|
ZodSettings.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
48
front/src/back-api/public-key-resource.ts
Normal file
48
front/src/back-api/public-key-resource.ts
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/**
|
||||||
|
* API of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import {
|
||||||
|
HTTPMimeType,
|
||||||
|
HTTPRequestModel,
|
||||||
|
ModelResponseHttp,
|
||||||
|
RESTCallbacks,
|
||||||
|
RESTConfig,
|
||||||
|
RESTRequestJson,
|
||||||
|
RESTRequestJsonArray,
|
||||||
|
RESTRequestVoid
|
||||||
|
} from "./rest-tools"
|
||||||
|
import {
|
||||||
|
PublicKey,
|
||||||
|
isPublicKey,
|
||||||
|
} from "./model"
|
||||||
|
export namespace PublicKeyResource {
|
||||||
|
|
||||||
|
export function getKey({
|
||||||
|
restConfig,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<PublicKey> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/public_key",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isPublicKey);
|
||||||
|
};
|
||||||
|
export function getKeyPem({
|
||||||
|
restConfig,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<string> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/public_key//pem",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, null);
|
||||||
|
};
|
||||||
|
}
|
373
front/src/back-api/rest-tools.ts
Normal file
373
front/src/back-api/rest-tools.ts
Normal file
@ -0,0 +1,373 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2024, Edouard DUPIN, all right reserved
|
||||||
|
* @license MPL-2
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { RestErrorResponse } from "./model"
|
||||||
|
|
||||||
|
export enum HTTPRequestModel {
|
||||||
|
DELETE = 'DELETE',
|
||||||
|
GET = 'GET',
|
||||||
|
PATCH = 'PATCH',
|
||||||
|
POST = 'POST',
|
||||||
|
PUT = 'PUT',
|
||||||
|
}
|
||||||
|
export enum HTTPMimeType {
|
||||||
|
ALL = '*/*',
|
||||||
|
CSV = 'text/csv',
|
||||||
|
IMAGE = 'image/*',
|
||||||
|
IMAGE_JPEG = 'image/jpeg',
|
||||||
|
IMAGE_PNG = 'image/png',
|
||||||
|
JSON = 'application/json',
|
||||||
|
MULTIPART = 'multipart/form-data',
|
||||||
|
OCTET_STREAM = 'application/octet-stream',
|
||||||
|
TEXT_PLAIN = 'text/plain',
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RESTConfig {
|
||||||
|
// base of the server: http(s)://my.server.org/plop/api/
|
||||||
|
server: string;
|
||||||
|
// Token to access of the data.
|
||||||
|
token?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RESTModel {
|
||||||
|
// base of the local API request: "sheep/{id}".
|
||||||
|
endPoint: string;
|
||||||
|
// Type of the request.
|
||||||
|
requestType?: HTTPRequestModel;
|
||||||
|
// Input type requested.
|
||||||
|
accept?: HTTPMimeType;
|
||||||
|
// Content of the local data.
|
||||||
|
contentType?: HTTPMimeType;
|
||||||
|
// Mode of the TOKEN in URL or Header (?token:${tokenInUrl})
|
||||||
|
tokenInUrl?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ModelResponseHttp {
|
||||||
|
status: number;
|
||||||
|
data: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isArrayOf<TYPE>(
|
||||||
|
data: any,
|
||||||
|
typeChecker: (subData: any) => subData is TYPE,
|
||||||
|
length?: number
|
||||||
|
): data is TYPE[] {
|
||||||
|
if (!Array.isArray(data)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!data.every(typeChecker)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (length !== undefined && data.length != length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isNullOrUndefined(data: any): data is undefined | null {
|
||||||
|
return data === undefined || data === null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// generic progression callback
|
||||||
|
export type ProgressCallback = (count: number, total: number) => void;
|
||||||
|
|
||||||
|
export interface RESTAbort {
|
||||||
|
abort?: () => boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Rest generic callback have a basic model to upload and download advancement.
|
||||||
|
export interface RESTCallbacks {
|
||||||
|
progressUpload?: ProgressCallback,
|
||||||
|
progressDownload?: ProgressCallback,
|
||||||
|
abortHandle?: RESTAbort,
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface RESTRequestType {
|
||||||
|
restModel: RESTModel,
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
data?: any,
|
||||||
|
params?: object,
|
||||||
|
queries?: object,
|
||||||
|
callback?: RESTCallbacks,
|
||||||
|
};
|
||||||
|
|
||||||
|
function removeTrailingSlashes(input: string): string {
|
||||||
|
if (isNullOrUndefined(input)) {
|
||||||
|
return "undefined";
|
||||||
|
}
|
||||||
|
return input.replace(/\/+$/, '');
|
||||||
|
}
|
||||||
|
function removeLeadingSlashes(input: string): string {
|
||||||
|
if (isNullOrUndefined(input)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return input.replace(/^\/+/, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function RESTUrl({ restModel, restConfig, params, queries }: RESTRequestType): string {
|
||||||
|
// Create the URL PATH:
|
||||||
|
let generateUrl = `${removeTrailingSlashes(restConfig.server)}/${removeLeadingSlashes(restModel.endPoint)}`;
|
||||||
|
if (params !== undefined) {
|
||||||
|
for (let key of Object.keys(params)) {
|
||||||
|
generateUrl = generateUrl.replaceAll(`{${key}}`, `${params[key]}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (queries === undefined && (restConfig.token === undefined || restModel.tokenInUrl !== true)) {
|
||||||
|
return generateUrl;
|
||||||
|
}
|
||||||
|
const searchParams = new URLSearchParams();
|
||||||
|
if (queries !== undefined) {
|
||||||
|
for (let key of Object.keys(queries)) {
|
||||||
|
const value = queries[key];
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
for (let iii = 0; iii < value.length; iii++) {
|
||||||
|
searchParams.append(`${key}`, `${value[iii]}`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
searchParams.append(`${key}`, `${value}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (restConfig.token !== undefined && restModel.tokenInUrl === true) {
|
||||||
|
searchParams.append('Authorization', `Bearer ${restConfig.token}`);
|
||||||
|
}
|
||||||
|
return generateUrl + "?" + searchParams.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function fetchProgress(generateUrl: string, { method, headers, body }: {
|
||||||
|
method: HTTPRequestModel,
|
||||||
|
headers: any,
|
||||||
|
body: any,
|
||||||
|
}, { progressUpload, progressDownload, abortHandle }: RESTCallbacks): Promise<Response> {
|
||||||
|
const xhr = {
|
||||||
|
io: new XMLHttpRequest()
|
||||||
|
}
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
// Stream the upload progress
|
||||||
|
if (progressUpload) {
|
||||||
|
xhr.io.upload.addEventListener("progress", (dataEvent) => {
|
||||||
|
if (dataEvent.lengthComputable) {
|
||||||
|
//console.log(` ==> has a progress event: ${dataEvent.loaded} / ${dataEvent.total}`);
|
||||||
|
progressUpload(dataEvent.loaded, dataEvent.total);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// Stream the download progress
|
||||||
|
if (progressDownload) {
|
||||||
|
xhr.io.addEventListener("progress", (dataEvent) => {
|
||||||
|
if (dataEvent.lengthComputable) {
|
||||||
|
//console.log(` ==> download progress:: ${dataEvent.loaded} / ${dataEvent.total}`);
|
||||||
|
progressUpload(dataEvent.loaded, dataEvent.total);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (abortHandle) {
|
||||||
|
abortHandle.abort = () => {
|
||||||
|
if (xhr.io) {
|
||||||
|
console.log(`Request abort on the XMLHttpRequest: ${generateUrl}`);
|
||||||
|
xhr.io.abort();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
console.log(`Request abort (FAIL) on the XMLHttpRequest: ${generateUrl}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Check if we have an internal Fail:
|
||||||
|
xhr.io.addEventListener('error', () => {
|
||||||
|
xhr.io = undefined;
|
||||||
|
reject(new TypeError('Failed to fetch'))
|
||||||
|
});
|
||||||
|
|
||||||
|
// Capture the end of the stream
|
||||||
|
xhr.io.addEventListener("loadend", () => {
|
||||||
|
if (xhr.io.readyState !== XMLHttpRequest.DONE) {
|
||||||
|
//console.log(` ==> READY state`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (xhr.io.status === 0) {
|
||||||
|
//the stream has been aborted
|
||||||
|
reject(new TypeError('Fetch has been aborted'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Stream is ended, transform in a generic response:
|
||||||
|
const response = new Response(xhr.io.response, {
|
||||||
|
status: xhr.io.status,
|
||||||
|
statusText: xhr.io.statusText
|
||||||
|
});
|
||||||
|
const headersArray = xhr.io.getAllResponseHeaders().trim().replaceAll("\r\n", "\n").split('\n');
|
||||||
|
headersArray.forEach(function (header) {
|
||||||
|
const firstColonIndex = header.indexOf(':');
|
||||||
|
if (firstColonIndex !== -1) {
|
||||||
|
var key = header.substring(0, firstColonIndex).trim();
|
||||||
|
var value = header.substring(firstColonIndex + 1).trim();
|
||||||
|
response.headers.set(key, value);
|
||||||
|
} else {
|
||||||
|
response.headers.set(header, "");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
xhr.io = undefined;
|
||||||
|
resolve(response);
|
||||||
|
});
|
||||||
|
xhr.io.open(method, generateUrl, true);
|
||||||
|
if (!isNullOrUndefined(headers)) {
|
||||||
|
for (const [key, value] of Object.entries(headers)) {
|
||||||
|
xhr.io.setRequestHeader(key, value as string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xhr.io.send(body);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function RESTRequest({ restModel, restConfig, data, params, queries, callback }: RESTRequestType): Promise<ModelResponseHttp> {
|
||||||
|
// Create the URL PATH:
|
||||||
|
let generateUrl = RESTUrl({ restModel, restConfig, data, params, queries });
|
||||||
|
let headers: any = {};
|
||||||
|
if (restConfig.token !== undefined && restModel.tokenInUrl !== true) {
|
||||||
|
headers['Authorization'] = `Bearer ${restConfig.token}`;
|
||||||
|
}
|
||||||
|
if (restModel.accept !== undefined) {
|
||||||
|
headers['Accept'] = restModel.accept;
|
||||||
|
}
|
||||||
|
if (restModel.requestType !== HTTPRequestModel.GET) {
|
||||||
|
// if Get we have not a content type, the body is empty
|
||||||
|
if (restModel.contentType !== HTTPMimeType.MULTIPART) {
|
||||||
|
// special case of multi-part ==> no content type otherwise the browser does not set the ";bundary=--****"
|
||||||
|
headers['Content-Type'] = restModel.contentType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let body = data;
|
||||||
|
if (restModel.contentType === HTTPMimeType.JSON) {
|
||||||
|
body = JSON.stringify(data);
|
||||||
|
} else if (restModel.contentType === HTTPMimeType.MULTIPART) {
|
||||||
|
const formData = new FormData();
|
||||||
|
for (const name in data) {
|
||||||
|
formData.append(name, data[name]);
|
||||||
|
}
|
||||||
|
body = formData
|
||||||
|
}
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
let action: undefined | Promise<Response> = undefined;
|
||||||
|
if (isNullOrUndefined(callback)
|
||||||
|
|| (isNullOrUndefined(callback.progressDownload)
|
||||||
|
&& isNullOrUndefined(callback.progressUpload)
|
||||||
|
&& isNullOrUndefined(callback.abortHandle))) {
|
||||||
|
// No information needed: call the generic fetch interface
|
||||||
|
action = fetch(generateUrl, {
|
||||||
|
method: restModel.requestType,
|
||||||
|
headers,
|
||||||
|
body,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// need progression information: call old fetch model (XMLHttpRequest) that permit to keep % upload and % download for HTTP1.x
|
||||||
|
action = fetchProgress(generateUrl, {
|
||||||
|
method: restModel.requestType ?? HTTPRequestModel.GET,
|
||||||
|
headers,
|
||||||
|
body,
|
||||||
|
}, callback);
|
||||||
|
}
|
||||||
|
action.then((response: Response) => {
|
||||||
|
if (response.status >= 200 && response.status <= 299) {
|
||||||
|
const contentType = response.headers.get('Content-Type');
|
||||||
|
if (restModel.accept !== contentType) {
|
||||||
|
reject({
|
||||||
|
time: Date().toString(),
|
||||||
|
status: 901,
|
||||||
|
error: `REST check wrong type: ${restModel.accept} != ${contentType}`,
|
||||||
|
statusMessage: "Fetch error",
|
||||||
|
message: "rest-tools.ts Wrong type in the message return type"
|
||||||
|
} as RestErrorResponse);
|
||||||
|
} else if (contentType === HTTPMimeType.JSON) {
|
||||||
|
response
|
||||||
|
.json()
|
||||||
|
.then((value: any) => {
|
||||||
|
//console.log(`RECEIVE ==> ${response.status}=${ JSON.stringify(value, null, 2)}`);
|
||||||
|
resolve({ status: response.status, data: value });
|
||||||
|
})
|
||||||
|
.catch((reason: any) => {
|
||||||
|
reject({
|
||||||
|
time: Date().toString(),
|
||||||
|
status: 902,
|
||||||
|
error: `REST parse json fail: ${reason}`,
|
||||||
|
statusMessage: "Fetch parse error",
|
||||||
|
message: "rest-tools.ts Wrong message model to parse"
|
||||||
|
} as RestErrorResponse);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
resolve({ status: response.status, data: response.body });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
reject({
|
||||||
|
time: Date().toString(),
|
||||||
|
status: response.status,
|
||||||
|
error: `${response.body}`,
|
||||||
|
statusMessage: "Fetch code error",
|
||||||
|
message: "rest-tools.ts Wrong return code"
|
||||||
|
} as RestErrorResponse);
|
||||||
|
}
|
||||||
|
}).catch((error: any) => {
|
||||||
|
reject({
|
||||||
|
time: Date(),
|
||||||
|
status: 999,
|
||||||
|
error: error,
|
||||||
|
statusMessage: "Fetch catch error",
|
||||||
|
message: "rest-tools.ts detect an error in the fetch request"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export function RESTRequestJson<TYPE>(request: RESTRequestType, checker: (data: any) => data is TYPE): Promise<TYPE> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
RESTRequest(request).then((value: ModelResponseHttp) => {
|
||||||
|
if (checker(value.data)) {
|
||||||
|
resolve(value.data);
|
||||||
|
} else {
|
||||||
|
reject({
|
||||||
|
time: Date().toString(),
|
||||||
|
status: 950,
|
||||||
|
error: "REST Fail to verify the data",
|
||||||
|
statusMessage: "API cast ERROR",
|
||||||
|
message: "api.ts Check type as fail"
|
||||||
|
} as RestErrorResponse);
|
||||||
|
}
|
||||||
|
}).catch((reason: RestErrorResponse) => {
|
||||||
|
reject(reason);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
export function RESTRequestJsonArray<TYPE>(request: RESTRequestType, checker: (data: any) => data is TYPE): Promise<TYPE[]> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
RESTRequest(request).then((value: ModelResponseHttp) => {
|
||||||
|
if (isArrayOf(value.data, checker)) {
|
||||||
|
resolve(value.data);
|
||||||
|
} else {
|
||||||
|
reject({
|
||||||
|
time: Date().toString(),
|
||||||
|
status: 950,
|
||||||
|
error: "REST Fail to verify the data",
|
||||||
|
statusMessage: "API cast ERROR",
|
||||||
|
message: "api.ts Check type as fail"
|
||||||
|
} as RestErrorResponse);
|
||||||
|
}
|
||||||
|
}).catch((reason: RestErrorResponse) => {
|
||||||
|
reject(reason);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function RESTRequestVoid(request: RESTRequestType): Promise<void> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
RESTRequest(request).then((value: ModelResponseHttp) => {
|
||||||
|
resolve();
|
||||||
|
}).catch((reason: RestErrorResponse) => {
|
||||||
|
reject(reason);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
114
front/src/back-api/right-resource.ts
Normal file
114
front/src/back-api/right-resource.ts
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
/**
|
||||||
|
* API of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import {
|
||||||
|
HTTPMimeType,
|
||||||
|
HTTPRequestModel,
|
||||||
|
ModelResponseHttp,
|
||||||
|
RESTCallbacks,
|
||||||
|
RESTConfig,
|
||||||
|
RESTRequestJson,
|
||||||
|
RESTRequestJsonArray,
|
||||||
|
RESTRequestVoid
|
||||||
|
} from "./rest-tools"
|
||||||
|
import {
|
||||||
|
Right,
|
||||||
|
Long,
|
||||||
|
isRight,
|
||||||
|
} from "./model"
|
||||||
|
export namespace RightResource {
|
||||||
|
|
||||||
|
export function remove({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/right/{id}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export function get({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Right> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/right/{id}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isRight);
|
||||||
|
};
|
||||||
|
export function patch({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: Right,
|
||||||
|
}): Promise<Right> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/right/{id}",
|
||||||
|
requestType: HTTPRequestModel.PATCH,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, isRight);
|
||||||
|
};
|
||||||
|
export function post({
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
data: Right,
|
||||||
|
}): Promise<Right> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/right",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}, isRight);
|
||||||
|
};
|
||||||
|
export function gets({
|
||||||
|
restConfig,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<Right[]> {
|
||||||
|
return RESTRequestJsonArray({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/right",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isRight);
|
||||||
|
};
|
||||||
|
}
|
75
front/src/back-api/system-config-resource.ts
Normal file
75
front/src/back-api/system-config-resource.ts
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
/**
|
||||||
|
* API of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import {
|
||||||
|
HTTPMimeType,
|
||||||
|
HTTPRequestModel,
|
||||||
|
ModelResponseHttp,
|
||||||
|
RESTCallbacks,
|
||||||
|
RESTConfig,
|
||||||
|
RESTRequestJson,
|
||||||
|
RESTRequestJsonArray,
|
||||||
|
RESTRequestVoid
|
||||||
|
} from "./rest-tools"
|
||||||
|
import {
|
||||||
|
GetSignUpAvailable,
|
||||||
|
isGetSignUpAvailable,
|
||||||
|
} from "./model"
|
||||||
|
export namespace SystemConfigResource {
|
||||||
|
|
||||||
|
export function getKey({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
key: string,
|
||||||
|
},
|
||||||
|
}): Promise<any> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/system_config/key/{key}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, null);
|
||||||
|
};
|
||||||
|
export function isSignUpAvailable({
|
||||||
|
restConfig,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<GetSignUpAvailable> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/system_config/is_sign_up_availlable",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isGetSignUpAvailable);
|
||||||
|
};
|
||||||
|
export function setKey({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
key: string,
|
||||||
|
},
|
||||||
|
data: string,
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/system_config/key/{key}",
|
||||||
|
requestType: HTTPRequestModel.PATCH,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
279
front/src/back-api/user-resource.ts
Normal file
279
front/src/back-api/user-resource.ts
Normal file
@ -0,0 +1,279 @@
|
|||||||
|
/**
|
||||||
|
* API of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import {
|
||||||
|
HTTPMimeType,
|
||||||
|
HTTPRequestModel,
|
||||||
|
ModelResponseHttp,
|
||||||
|
RESTCallbacks,
|
||||||
|
RESTConfig,
|
||||||
|
RESTRequestJson,
|
||||||
|
RESTRequestJsonArray,
|
||||||
|
RESTRequestVoid
|
||||||
|
} from "./rest-tools"
|
||||||
|
import {
|
||||||
|
GetToken,
|
||||||
|
Long,
|
||||||
|
UserOut,
|
||||||
|
UserAuthGet,
|
||||||
|
DataGetToken,
|
||||||
|
UserCreate,
|
||||||
|
ChangePassword,
|
||||||
|
UserAuth,
|
||||||
|
isGetToken,
|
||||||
|
isUserOut,
|
||||||
|
isUserAuthGet,
|
||||||
|
isUserAuth,
|
||||||
|
} from "./model"
|
||||||
|
export namespace UserResource {
|
||||||
|
|
||||||
|
export function create({
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
data: UserCreate,
|
||||||
|
}): Promise<UserAuthGet> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}, isUserAuthGet);
|
||||||
|
};
|
||||||
|
export function getUsers({
|
||||||
|
restConfig,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<UserAuthGet[]> {
|
||||||
|
return RESTRequestJsonArray({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isUserAuthGet);
|
||||||
|
};
|
||||||
|
export function getUser({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<UserAuthGet> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users/{id}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isUserAuthGet);
|
||||||
|
};
|
||||||
|
export function linkApplication({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
applicationId: Long,
|
||||||
|
userId: Long,
|
||||||
|
},
|
||||||
|
data: boolean,
|
||||||
|
}): Promise<UserAuth> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users/{userId}/application/{applicationId}/link",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, isUserAuth);
|
||||||
|
};
|
||||||
|
export function getApplicationRight({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
applicationId: Long,
|
||||||
|
userId: Long,
|
||||||
|
},
|
||||||
|
}): Promise<any> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users/{userId}/application/{applicationId}/rights",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, null);
|
||||||
|
};
|
||||||
|
export function patchApplicationRight({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
applicationId: Long,
|
||||||
|
userId: Long,
|
||||||
|
},
|
||||||
|
data: any,
|
||||||
|
}): Promise<any> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users/{userId}/application/{applicationId}/rights",
|
||||||
|
requestType: HTTPRequestModel.PATCH,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, null);
|
||||||
|
};
|
||||||
|
export function setAdmin({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: boolean,
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users/{id}/set_admin",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export function setBlocked({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: boolean,
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users/{id}/set_blocked",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export function getMe({
|
||||||
|
restConfig,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<UserOut> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users/me",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isUserOut);
|
||||||
|
};
|
||||||
|
export function changePassword({
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
data: ChangePassword,
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users/password",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export function isLoginExist({
|
||||||
|
restConfig,
|
||||||
|
queries,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
queries: {
|
||||||
|
login?: string,
|
||||||
|
},
|
||||||
|
}): Promise<boolean> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users/is_login_exist",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
queries,
|
||||||
|
}, null);
|
||||||
|
};
|
||||||
|
export function isEmailExist({
|
||||||
|
restConfig,
|
||||||
|
queries,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
queries: {
|
||||||
|
email?: string,
|
||||||
|
},
|
||||||
|
}): Promise<boolean> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users/is_email_exist",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
queries,
|
||||||
|
}, null);
|
||||||
|
};
|
||||||
|
export function getToken({
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
data: DataGetToken,
|
||||||
|
}): Promise<GetToken> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users/get_token",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}, isGetToken);
|
||||||
|
};
|
||||||
|
}
|
@ -4,14 +4,11 @@
|
|||||||
* @license PROPRIETARY (see license file)
|
* @license PROPRIETARY (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit } from '@angular/core';
|
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { ApplicationService, ApplicationModel, ApplicationTokenService } from 'base/service';
|
import { PopInService, NotificationService, isString, AsyncActionState, isNumber, SettingsItem, CheckerParameterType, SettingType } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import { ApplicationTokenModel } from 'base/service/application-token';
|
import { Application, ApplicationToken } from 'back-api';
|
||||||
import { AsyncActionState } from 'common/component';
|
import { ApplicationService, ApplicationTokenService } from 'base/service';
|
||||||
import { CheckerParameterType, SettingsItem, SettingType } from 'common/component/render-settings/render-settings';
|
|
||||||
import { NotificationService, PopInService } from 'common/service';
|
|
||||||
import { isNumber, isNumeric, isString } from 'common/utils';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'application-setting-edit',
|
selector: 'application-setting-edit',
|
||||||
@ -21,9 +18,9 @@ import { isNumber, isNumeric, isString } from 'common/utils';
|
|||||||
})
|
})
|
||||||
export class ApplicationEditScene implements OnInit {
|
export class ApplicationEditScene implements OnInit {
|
||||||
id: number = undefined
|
id: number = undefined
|
||||||
application: ApplicationModel = undefined;
|
application: Application = undefined;
|
||||||
applicationRef: ApplicationModel = undefined;
|
applicationRef: Application = undefined;
|
||||||
tokens: ApplicationTokenModel[] = [];
|
tokens: ApplicationToken[] = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private applicationService: ApplicationService,
|
private applicationService: ApplicationService,
|
||||||
@ -39,7 +36,7 @@ export class ApplicationEditScene implements OnInit {
|
|||||||
let self = this;
|
let self = this;
|
||||||
this.applicationService
|
this.applicationService
|
||||||
.get(this.id)
|
.get(this.id)
|
||||||
.then((response: ApplicationModel) => {
|
.then((response: Application) => {
|
||||||
console.log(`??? get full response: ${JSON.stringify(response, null, 4)}`);
|
console.log(`??? get full response: ${JSON.stringify(response, null, 4)}`);
|
||||||
self.application = response;
|
self.application = response;
|
||||||
self.checkName(self.application.name);
|
self.checkName(self.application.name);
|
||||||
@ -51,7 +48,7 @@ export class ApplicationEditScene implements OnInit {
|
|||||||
});
|
});
|
||||||
this.applicationTokenService
|
this.applicationTokenService
|
||||||
.gets(this.id)
|
.gets(this.id)
|
||||||
.then((response: ApplicationTokenModel[]) => {
|
.then((response: ApplicationToken[]) => {
|
||||||
console.log(`??? get full response: ${JSON.stringify(response, null, 4)}`);
|
console.log(`??? get full response: ${JSON.stringify(response, null, 4)}`);
|
||||||
self.tokens = response;
|
self.tokens = response;
|
||||||
})
|
})
|
||||||
@ -170,7 +167,7 @@ export class ApplicationEditScene implements OnInit {
|
|||||||
let self = this;
|
let self = this;
|
||||||
this.applicationService.update(this.id, this.dataUpdate)
|
this.applicationService.update(this.id, this.dataUpdate)
|
||||||
.then(
|
.then(
|
||||||
(data: ApplicationModel) => {
|
(data: Application) => {
|
||||||
self.updateState = AsyncActionState.DONE;
|
self.updateState = AsyncActionState.DONE;
|
||||||
console.log(`Get new application data: ${JSON.stringify(data, null, 2)}`);
|
console.log(`Get new application data: ${JSON.stringify(data, null, 2)}`);
|
||||||
self.application = data;
|
self.application = data;
|
||||||
@ -193,7 +190,7 @@ export class ApplicationEditScene implements OnInit {
|
|||||||
let self = this;
|
let self = this;
|
||||||
this.applicationTokenService
|
this.applicationTokenService
|
||||||
.create(this.id, this.dataCreateApplication["name"], this.dataCreateApplication["ttl"])
|
.create(this.id, this.dataCreateApplication["name"], this.dataCreateApplication["ttl"])
|
||||||
.then((response: ApplicationTokenModel) => {
|
.then((response: ApplicationToken) => {
|
||||||
//console.log(`??? get fullllllll response: ${JSON.stringify(response, null, 4)}`);
|
//console.log(`??? get fullllllll response: ${JSON.stringify(response, null, 4)}`);
|
||||||
self.tokens.push(response);
|
self.tokens.push(response);
|
||||||
response.token = `"${response.id}:${response.token}"`
|
response.token = `"${response.id}:${response.token}"`
|
||||||
@ -204,13 +201,13 @@ export class ApplicationEditScene implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onRemoveApplicationToken(_event: any, token: ApplicationTokenModel) {
|
onRemoveApplicationToken(_event: any, token: ApplicationToken) {
|
||||||
this.confirmDeleteComment = `Delete the application token ID: [${this.application.id}/${token.id}] ${token.name}`;
|
this.confirmDeleteComment = `Delete the application token ID: [${this.application.id}/${token.id}] ${token.name}`;
|
||||||
this.confirmDeleteApplicationToken = token;
|
this.confirmDeleteApplicationToken = token;
|
||||||
this.popInService.open('popin-delete-confirm');
|
this.popInService.open('popin-delete-confirm');
|
||||||
}
|
}
|
||||||
|
|
||||||
removeApplicationConfirm(token: ApplicationTokenModel) {
|
removeApplicationConfirm(token: ApplicationToken) {
|
||||||
let self = this;
|
let self = this;
|
||||||
this.applicationTokenService.remove(self.application.id, token.id)
|
this.applicationTokenService.remove(self.application.id, token.id)
|
||||||
.then(
|
.then(
|
||||||
@ -227,8 +224,8 @@ export class ApplicationEditScene implements OnInit {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
confirmDeleteComment: string = undefined;
|
confirmDeleteComment?: string;
|
||||||
confirmDeleteApplicationToken: ApplicationTokenModel = undefined;
|
confirmDeleteApplicationToken?: ApplicationToken;
|
||||||
|
|
||||||
deleteConfirmed() {
|
deleteConfirmed() {
|
||||||
if (this.confirmDeleteApplicationToken !== undefined) {
|
if (this.confirmDeleteApplicationToken !== undefined) {
|
||||||
|
@ -6,12 +6,9 @@
|
|||||||
|
|
||||||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit } from '@angular/core';
|
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { ApplicationService, ApplicationModel, ApplicationTokenService, AdminUserService } from 'base/service';
|
import { PopInService, NotificationService, isString, isNumber, CheckerParameterType, SettingType, SettingsItem } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import { ApplicationTokenModel } from 'base/service/application-token';
|
import { Application, ApplicationToken } from 'back-api';
|
||||||
import { AsyncActionState } from 'common/component';
|
import { ApplicationService, ApplicationTokenService, AdminUserService } from 'base/service';
|
||||||
import { CheckerParameterType, SettingsItem, SettingType } from 'common/component/render-settings/render-settings';
|
|
||||||
import { ModelResponseHttp, NotificationService, PopInService } from 'common/service';
|
|
||||||
import { isNumber, isNumeric, isString } from 'common/utils';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'application-setting-user-edit',
|
selector: 'application-setting-user-edit',
|
||||||
@ -24,8 +21,8 @@ export class ApplicationUserEditScene implements OnInit {
|
|||||||
users: any[] = undefined;
|
users: any[] = undefined;
|
||||||
notUsers: any[] = undefined;
|
notUsers: any[] = undefined;
|
||||||
applicationName: string = undefined;
|
applicationName: string = undefined;
|
||||||
applicationRef: ApplicationModel = undefined;
|
applicationRef: Application = undefined;
|
||||||
tokens: ApplicationTokenModel[] = [];
|
tokens: ApplicationToken[] = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private adminUserService: AdminUserService,
|
private adminUserService: AdminUserService,
|
||||||
@ -44,7 +41,7 @@ export class ApplicationUserEditScene implements OnInit {
|
|||||||
// get local information of the application
|
// get local information of the application
|
||||||
this.applicationService
|
this.applicationService
|
||||||
.get(this.id)
|
.get(this.id)
|
||||||
.then((response: ApplicationModel) => {
|
.then((response: Application) => {
|
||||||
console.log(`??? get full response: ${JSON.stringify(response, null, 4)}`);
|
console.log(`??? get full response: ${JSON.stringify(response, null, 4)}`);
|
||||||
self.applicationName = response.name;
|
self.applicationName = response.name;
|
||||||
self.applicationRef = response;
|
self.applicationRef = response;
|
||||||
@ -86,16 +83,12 @@ export class ApplicationUserEditScene implements OnInit {
|
|||||||
onRemoveApplicationUser(value: boolean, user: any) {
|
onRemoveApplicationUser(value: boolean, user: any) {
|
||||||
console.log(`changeState : ${JSON.stringify(value, null, 2)}`);
|
console.log(`changeState : ${JSON.stringify(value, null, 2)}`);
|
||||||
const self = this;
|
const self = this;
|
||||||
this.applicationService.rmUser(this.id, user.id)
|
this.applicationService.removeUser(this.id, user.id)
|
||||||
.then((response: boolean) => {
|
.then(() => {
|
||||||
if (response === true) {
|
self.notUsers.push(user);
|
||||||
self.notUsers.push(user);
|
const index = self.users.indexOf(user, 0);
|
||||||
const index = self.users.indexOf(user, 0);
|
if (index > -1) {
|
||||||
if (index > -1) {
|
self.users.splice(index, 1);
|
||||||
self.users.splice(index, 1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// TODO: manage error
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
@ -106,15 +99,11 @@ export class ApplicationUserEditScene implements OnInit {
|
|||||||
console.log(`changeState : ${JSON.stringify(value, null, 2)}`);
|
console.log(`changeState : ${JSON.stringify(value, null, 2)}`);
|
||||||
const self = this;
|
const self = this;
|
||||||
this.applicationService.addUser(this.id, user.id)
|
this.applicationService.addUser(this.id, user.id)
|
||||||
.then((response: boolean) => {
|
.then(() => {
|
||||||
if (response === true) {
|
self.users.push(user);
|
||||||
self.users.push(user);
|
const index = self.notUsers.indexOf(user, 0);
|
||||||
const index = self.notUsers.indexOf(user, 0);
|
if (index > -1) {
|
||||||
if (index > -1) {
|
self.notUsers.splice(index, 1);
|
||||||
self.notUsers.splice(index, 1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// TODO: manage error
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
@ -128,7 +117,7 @@ export class ApplicationUserEditScene implements OnInit {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
removeApplicationConfirm(token: ApplicationTokenModel) {
|
removeApplicationConfirm(token: ApplicationToken) {
|
||||||
let self = this;
|
let self = this;
|
||||||
/*
|
/*
|
||||||
this.applicationTokenService.remove(self.application.id, token.id)
|
this.applicationTokenService.remove(self.application.id, token.id)
|
||||||
@ -148,7 +137,7 @@ export class ApplicationUserEditScene implements OnInit {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
confirmDeleteComment: string = undefined;
|
confirmDeleteComment: string = undefined;
|
||||||
confirmDeleteApplicationToken: ApplicationTokenModel = undefined;
|
confirmDeleteApplicationToken: ApplicationToken = undefined;
|
||||||
|
|
||||||
deleteConfirmed() {
|
deleteConfirmed() {
|
||||||
if (this.confirmDeleteApplicationToken !== undefined) {
|
if (this.confirmDeleteApplicationToken !== undefined) {
|
||||||
|
@ -6,14 +6,9 @@
|
|||||||
|
|
||||||
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { AdminUserService, ApplicationModel, ApplicationService, ApplicationUserRight, SettingsService } from 'base/service';
|
import { AdminUserService, ApplicationService } from 'base/service';
|
||||||
import { ApplicationRightModel } from 'base/service/application';
|
import { isNullOrUndefined, AsyncActionState, SettingsItem, SettingType } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import { SettingType, SettingsItem } from '../manage-accounts/manage-accounts';
|
import { Application, RightDescription } from 'back-api';
|
||||||
import { UserService } from 'common/service';
|
|
||||||
import { isNullOrUndefined, isUndefined } from 'common/utils';
|
|
||||||
import { AsyncActionState } from 'common/component';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -25,17 +20,15 @@ export class applicationUserRightEditScene implements OnInit {
|
|||||||
page = '';
|
page = '';
|
||||||
applicationId: number = undefined;
|
applicationId: number = undefined;
|
||||||
userId: number = undefined;
|
userId: number = undefined;
|
||||||
application: ApplicationModel;
|
application: Application;
|
||||||
rowRight: ApplicationRightModel[] = [];
|
rowRight: RightDescription[] = [];
|
||||||
applicationName: string;
|
applicationName: string;
|
||||||
userName: string;
|
userName: string;
|
||||||
userRights: ApplicationUserRight = {};
|
userRights: any = {};
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private settingService: SettingsService,
|
|
||||||
private applicationService: ApplicationService,
|
private applicationService: ApplicationService,
|
||||||
private userService: UserService,
|
private adminUserService: AdminUserService,
|
||||||
private userAdminService: AdminUserService,
|
|
||||||
private activatedRoute: ActivatedRoute,
|
private activatedRoute: ActivatedRoute,
|
||||||
private cdr: ChangeDetectorRef,
|
private cdr: ChangeDetectorRef,
|
||||||
) { }
|
) { }
|
||||||
@ -47,7 +40,7 @@ export class applicationUserRightEditScene implements OnInit {
|
|||||||
let self = this;
|
let self = this;
|
||||||
this.applicationService
|
this.applicationService
|
||||||
.get(this.applicationId)
|
.get(this.applicationId)
|
||||||
.then((response: ApplicationModel) => {
|
.then((response: Application) => {
|
||||||
console.log(`??? get full response: ${JSON.stringify(response, null, 4)}`);
|
console.log(`??? get full response: ${JSON.stringify(response, null, 4)}`);
|
||||||
self.applicationName = response.name;
|
self.applicationName = response.name;
|
||||||
self.application = response;
|
self.application = response;
|
||||||
@ -70,7 +63,7 @@ export class applicationUserRightEditScene implements OnInit {
|
|||||||
*/
|
*/
|
||||||
this.applicationService
|
this.applicationService
|
||||||
.getRights(this.applicationId)
|
.getRights(this.applicationId)
|
||||||
.then((response: ApplicationRightModel[]) => {
|
.then((response: RightDescription[]) => {
|
||||||
console.log(`getRights OK response: ${JSON.stringify(response, null, 4)}`);
|
console.log(`getRights OK response: ${JSON.stringify(response, null, 4)}`);
|
||||||
self.rowRight = response;
|
self.rowRight = response;
|
||||||
self.configureEditInput();
|
self.configureEditInput();
|
||||||
@ -79,9 +72,9 @@ export class applicationUserRightEditScene implements OnInit {
|
|||||||
console.log(`getRights ERROR response: ${JSON.stringify(error, null, 4)}`);
|
console.log(`getRights ERROR response: ${JSON.stringify(error, null, 4)}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.userAdminService
|
this.adminUserService
|
||||||
.getApplicationRights(this.userId, this.applicationId)
|
.getApplicationRights(this.userId, this.applicationId)
|
||||||
.then((userRights: ApplicationUserRight) => {
|
.then((userRights: any) => {
|
||||||
console.log(`getApplicationRights OK response: ${JSON.stringify(userRights, null, 4)}`);
|
console.log(`getApplicationRights OK response: ${JSON.stringify(userRights, null, 4)}`);
|
||||||
self.userRights = userRights;
|
self.userRights = userRights;
|
||||||
self.configureEditInput();
|
self.configureEditInput();
|
||||||
@ -168,9 +161,9 @@ export class applicationUserRightEditScene implements OnInit {
|
|||||||
this.updateState = AsyncActionState.LOADING;
|
this.updateState = AsyncActionState.LOADING;
|
||||||
let self = this;
|
let self = this;
|
||||||
console.log(`update requested: : ${JSON.stringify(this.dataUpdate, null, 2)}`);
|
console.log(`update requested: : ${JSON.stringify(this.dataUpdate, null, 2)}`);
|
||||||
this.userAdminService
|
this.adminUserService
|
||||||
.updateApplicationRights(this.userId, this.applicationId, this.dataUpdate)
|
.updateApplicationRights(this.userId, this.applicationId, this.dataUpdate)
|
||||||
.then((userRights: ApplicationUserRight[]) => {
|
.then((userRights: any[]) => {
|
||||||
console.log(`getApplicationRights OK response: ${JSON.stringify(userRights, null, 4)}`);
|
console.log(`getApplicationRights OK response: ${JSON.stringify(userRights, null, 4)}`);
|
||||||
self.userRights = userRights;
|
self.userRights = userRights;
|
||||||
self.updateState = AsyncActionState.DONE;
|
self.updateState = AsyncActionState.DONE;
|
||||||
|
@ -6,11 +6,9 @@
|
|||||||
|
|
||||||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { ApplicationService, ApplicationModel } from 'base/service';
|
import { AsyncActionState, CheckerParameterType, NotificationService, PopInService, SettingType, SettingsItem, isString } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import { AsyncActionState } from 'common/component';
|
import { Application } from 'back-api';
|
||||||
import { CheckerParameterType, SettingsItem, SettingType } from 'common/component/render-settings/render-settings';
|
import { ApplicationService } from 'base/service';
|
||||||
import { NotificationService, PopInService } from 'common/service';
|
|
||||||
import { isString } from 'common/utils';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'application-setting',
|
selector: 'application-setting',
|
||||||
@ -19,7 +17,7 @@ import { isString } from 'common/utils';
|
|||||||
changeDetection: ChangeDetectionStrategy.Default,
|
changeDetection: ChangeDetectionStrategy.Default,
|
||||||
})
|
})
|
||||||
export class ApplicationsScene implements OnInit {
|
export class ApplicationsScene implements OnInit {
|
||||||
applications: ApplicationModel[] = [];
|
applications: Application[] = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private applicationService: ApplicationService,
|
private applicationService: ApplicationService,
|
||||||
@ -34,7 +32,7 @@ export class ApplicationsScene implements OnInit {
|
|||||||
this.configureInput();
|
this.configureInput();
|
||||||
this.applicationService
|
this.applicationService
|
||||||
.gets()
|
.gets()
|
||||||
.then((response: ApplicationModel[]) => {
|
.then((response: Application[]) => {
|
||||||
console.log(`??? get full response: ${JSON.stringify(response, null, 4)}`);
|
console.log(`??? get full response: ${JSON.stringify(response, null, 4)}`);
|
||||||
self.applications = response;
|
self.applications = response;
|
||||||
})
|
})
|
||||||
@ -43,13 +41,13 @@ export class ApplicationsScene implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onRemoveApplication(_event: any, application: ApplicationModel) {
|
onRemoveApplication(_event: any, application: Application) {
|
||||||
this.confirmDeleteComment = `Delete the application ID: [${application.id}] ${application.name}`;
|
this.confirmDeleteComment = `Delete the application ID: [${application.id}] ${application.name}`;
|
||||||
this.confirmDeleteApplication = application;
|
this.confirmDeleteApplication = application;
|
||||||
this.popInService.open('popin-delete-confirm');
|
this.popInService.open('popin-delete-confirm');
|
||||||
}
|
}
|
||||||
|
|
||||||
removeApplicationConfirm(application: ApplicationModel) {
|
removeApplicationConfirm(application: Application) {
|
||||||
const self = this;
|
const self = this;
|
||||||
this.applicationService.remove(application.id)
|
this.applicationService.remove(application.id)
|
||||||
.then(
|
.then(
|
||||||
@ -67,7 +65,7 @@ export class ApplicationsScene implements OnInit {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
confirmDeleteComment: string = undefined;
|
confirmDeleteComment: string = undefined;
|
||||||
confirmDeleteApplication: ApplicationModel = undefined;
|
confirmDeleteApplication: Application = undefined;
|
||||||
|
|
||||||
deleteConfirmed() {
|
deleteConfirmed() {
|
||||||
if (this.confirmDeleteApplication !== undefined) {
|
if (this.confirmDeleteApplication !== undefined) {
|
||||||
@ -77,10 +75,10 @@ export class ApplicationsScene implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onEditApplication(_event: any, application: ApplicationModel) {
|
onEditApplication(_event: any, application: Application) {
|
||||||
this.router.navigate(['application-edit', application.id]);
|
this.router.navigate(['application-edit', application.id]);
|
||||||
}
|
}
|
||||||
onEditRightApplication(_event: any, application: ApplicationModel) {
|
onEditRightApplication(_event: any, application: Application) {
|
||||||
this.router.navigate(['application-user-edit', application.id]);
|
this.router.navigate(['application-user-edit', application.id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +155,7 @@ export class ApplicationsScene implements OnInit {
|
|||||||
const self = this;
|
const self = this;
|
||||||
this.applicationService.create(this.dataCreateApplication['name'], this.dataCreateApplication['redirect'])
|
this.applicationService.create(this.dataCreateApplication['name'], this.dataCreateApplication['redirect'])
|
||||||
.then(
|
.then(
|
||||||
(data: ApplicationModel) => {
|
(data: Application) => {
|
||||||
self.createState = AsyncActionState.DONE;
|
self.createState = AsyncActionState.DONE;
|
||||||
console.log(`Get new user: ${JSON.stringify(data, null, 2)}`);
|
console.log(`Get new user: ${JSON.stringify(data, null, 2)}`);
|
||||||
self.applications.push(data);
|
self.applications.push(data);
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { Location } from '@angular/common';
|
import { Location } from '@angular/common';
|
||||||
import { createPasswordState } from 'common/utils';
|
|
||||||
import { AdminUserService } from 'base/service';
|
import { AdminUserService } from 'base/service';
|
||||||
|
import { createPasswordState } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
|
||||||
export enum PasswordState {
|
export enum PasswordState {
|
||||||
FILLING = "filling",
|
FILLING = "filling",
|
||||||
@ -104,6 +104,7 @@ export class ChangePasswordScene {
|
|||||||
this.updateState = PasswordState.DONE;
|
this.updateState = PasswordState.DONE;
|
||||||
})
|
})
|
||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
|
console.log(`Catch error: ${JSON.stringify(error, null, 2)}`);
|
||||||
this.updateState = PasswordState.ERROR;
|
this.updateState = PasswordState.ERROR;
|
||||||
this.error = error;
|
this.error = error;
|
||||||
});
|
});
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { Location } from '@angular/common';
|
import { Location } from '@angular/common';
|
||||||
import { UserService } from 'common/service';
|
|
||||||
import { AdminUserService } from 'base/service';
|
import { AdminUserService } from 'base/service';
|
||||||
|
import { UserService } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
|
||||||
export function checkLoginValidity(value: string): boolean {
|
export function checkLoginValidity(value: string): boolean {
|
||||||
let regexCheck = new RegExp('^[a-zA-Z0-9_\\.-]+$');
|
let regexCheck = new RegExp('^[a-zA-Z0-9_\\.-]+$');
|
||||||
@ -108,7 +108,7 @@ export class ForgotPasswordScene implements OnInit {
|
|||||||
onRetreive(): void {
|
onRetreive(): void {
|
||||||
let self = this;
|
let self = this;
|
||||||
this.adminUserService
|
this.adminUserService
|
||||||
.retreivePassword(this.login)
|
.retrievePassword(this.login)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// go to the retreive page
|
// go to the retreive page
|
||||||
self.router.navigate(['retreive']);
|
self.router.navigate(['retreive']);
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { UserService } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
import { ApplicationSmall, ClientToken } from 'back-api';
|
||||||
import { ApplicationService } from 'base/service';
|
import { ApplicationService } from 'base/service';
|
||||||
import { GetApplicationSmallResponse, SpecificTokenResponse } from 'base/service/application';
|
|
||||||
import { UserService } from 'common/service';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-home',
|
selector: 'app-home',
|
||||||
@ -16,26 +16,27 @@ import { UserService } from 'common/service';
|
|||||||
})
|
})
|
||||||
export class HomeScene implements OnInit {
|
export class HomeScene implements OnInit {
|
||||||
error = '';
|
error = '';
|
||||||
dataList: GetApplicationSmallResponse[];
|
dataList: ApplicationSmall[];
|
||||||
constructor(private applicationService: ApplicationService, private userService: UserService) { }
|
constructor(private applicationService: ApplicationService,
|
||||||
|
private userService: UserService) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
let self = this;
|
let self = this;
|
||||||
this.applicationService
|
this.applicationService
|
||||||
.getApplicationsSmall()
|
.getApplicationsSmall()
|
||||||
.then((data: GetApplicationSmallResponse[]) => {
|
.then((data: ApplicationSmall[]) => {
|
||||||
self.dataList = data;
|
self.dataList = data;
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.log(`fail to keep data : ${error}`);
|
console.log(`fail to keep data : ${error}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
onClick(_event: any, data: GetApplicationSmallResponse): void {
|
onClick(_event: any, data: ApplicationSmall): void {
|
||||||
//window.location.href = data.redirect;
|
//window.location.href = data.redirect;
|
||||||
let self = this;
|
let self = this;
|
||||||
this.applicationService
|
this.applicationService
|
||||||
.getApplicationSpecificToken(data.name)
|
.getApplicationSpecificToken(data.name)
|
||||||
.then((result: SpecificTokenResponse) => {
|
.then((result: ClientToken) => {
|
||||||
self.transferToApplicationThatRequiredTheSSO2(result.url, result.jwt);
|
self.transferToApplicationThatRequiredTheSSO2(result.url, result.jwt);
|
||||||
})
|
})
|
||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
|
@ -5,97 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
||||||
|
import { SessionService, AsyncActionState, createPasswordState, createLoginState, checkEmailValidity } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import { AdminUserService } from 'base/service';
|
import { AdminUserService } from 'base/service';
|
||||||
import { AsyncActionState } from 'common/component';
|
|
||||||
import { SessionService } from 'common/service';
|
|
||||||
import {
|
|
||||||
checkEmailValidity,
|
|
||||||
checkLoginValidity,
|
|
||||||
createLoginState,
|
|
||||||
createPasswordState,
|
|
||||||
isBoolean,
|
|
||||||
isInArray,
|
|
||||||
isNullOrUndefined,
|
|
||||||
isNumber,
|
|
||||||
isObject,
|
|
||||||
isOptionalArrayOf,
|
|
||||||
isOptionalOf,
|
|
||||||
isString,
|
|
||||||
} from 'common/utils';
|
|
||||||
|
|
||||||
export enum SettingType {
|
|
||||||
TITLE = 'TITLE',
|
|
||||||
GROUP = 'GROUP',
|
|
||||||
LINE = 'LINE',
|
|
||||||
BOOLEAN = 'BOOLEAN',
|
|
||||||
STRING = 'STRING',
|
|
||||||
PASSWORD = 'PASSWORD',
|
|
||||||
}
|
|
||||||
export function isSettingType(data: any): data is SettingType {
|
|
||||||
return isInArray(data, ['TITLE', 'GROUP', 'LINE', 'BOOLEAN', 'STRING', 'PASSWORD']);
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SettingsItem {
|
|
||||||
// Type of the menu Node
|
|
||||||
type: SettingType;
|
|
||||||
// Displayed Title
|
|
||||||
title?: string;
|
|
||||||
// Description of the parameter
|
|
||||||
description?: string;
|
|
||||||
// Image to dsplay that describe the parameter
|
|
||||||
image?: string;
|
|
||||||
// If true the parameter is applied directly to the backend
|
|
||||||
directApply?: boolean;
|
|
||||||
// Parameter key to SET/GET
|
|
||||||
key?: string;
|
|
||||||
// Parameter key to SET/GET or the sub-menu
|
|
||||||
value?: SettingsItem[] | boolean | string | Number;
|
|
||||||
// whendata is change the value is set here:
|
|
||||||
newValue?: boolean | string | Number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isSettingsItem(data: any): data is SettingsItem {
|
|
||||||
if (isNullOrUndefined(data)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isObject(data)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isSettingType(data.type)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isOptionalOf(data.title, isString)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isOptionalOf(data.description, isString)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isOptionalOf(data.image, isString)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isOptionalOf(data.directApply, isBoolean)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isOptionalOf(data.key, isString)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
!isOptionalOf(data.value, isBoolean) &&
|
|
||||||
!isOptionalOf(data.value, isString) &&
|
|
||||||
!isOptionalOf(data.value, isNumber) &&
|
|
||||||
!isOptionalArrayOf(data.value, isSettingsItem)
|
|
||||||
) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
!isOptionalOf(data.newValue, isBoolean) &&
|
|
||||||
!isOptionalOf(data.newValue, isString) &&
|
|
||||||
!isOptionalOf(data.newValue, isNumber)
|
|
||||||
) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-settings',
|
selector: 'app-settings',
|
||||||
@ -226,7 +138,7 @@ export class ManageAccountsScene implements OnInit {
|
|||||||
console.log(`create user:`);
|
console.log(`create user:`);
|
||||||
this.createState = AsyncActionState.LOADING;
|
this.createState = AsyncActionState.LOADING;
|
||||||
const self = this;
|
const self = this;
|
||||||
this.adminUserService.createUsers(this.email, this.login, this.password)
|
this.adminUserService.createUser(this.email, this.login, this.password)
|
||||||
.then(
|
.then(
|
||||||
(user_data: any) => {
|
(user_data: any) => {
|
||||||
self.createState = AsyncActionState.DONE;
|
self.createState = AsyncActionState.DONE;
|
||||||
|
@ -5,16 +5,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { SettingType, SettingsItem, isNullOrUndefined, isObject, isOptionalArrayOf, isOptionalOf, isSettingsItem, isString } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import { SettingsService } from 'base/service';
|
import { SettingsService } from 'base/service';
|
||||||
import { isSettingsItem, SettingsItem, SettingType } from 'common/component/render-settings/render-settings';
|
|
||||||
import {
|
|
||||||
isNullOrUndefined,
|
|
||||||
isObject,
|
|
||||||
isOptionalArrayOf,
|
|
||||||
isOptionalOf,
|
|
||||||
isString,
|
|
||||||
} from 'common/utils';
|
|
||||||
|
|
||||||
|
|
||||||
export interface SettingsItem222 {
|
export interface SettingsItem222 {
|
||||||
|
@ -7,10 +7,9 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { Location } from '@angular/common';
|
import { Location } from '@angular/common';
|
||||||
import { SessionService } from 'common/service';
|
|
||||||
import { createLoginState, createPasswordState, getLoginType, isNullOrUndefined } from 'common/utils';
|
|
||||||
import { AdminUserService, ApplicationService } from 'base/service';
|
import { AdminUserService, ApplicationService } from 'base/service';
|
||||||
import { SpecificTokenResponse } from 'base/service/application';
|
import { SessionService, isNullOrUndefined, createLoginState, getLoginType, createPasswordState } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
import { ClientToken } from 'back-api';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -62,7 +61,7 @@ export class SignInScene implements OnInit {
|
|||||||
}
|
}
|
||||||
// TODO: check auto-reconnection !!!
|
// TODO: check auto-reconnection !!!
|
||||||
let self = this;
|
let self = this;
|
||||||
if (this.sessionService.islogged() == true && self.loginButtonIsClicked === false) {
|
if (this.sessionService.isLogged() == true && self.loginButtonIsClicked === false) {
|
||||||
// in theory it is the inly one case possible, the system loading page after retreiving session ....
|
// in theory it is the inly one case possible, the system loading page after retreiving session ....
|
||||||
if (!isNullOrUndefined(self.ssoApplicationId)) {
|
if (!isNullOrUndefined(self.ssoApplicationId)) {
|
||||||
// detect an auto-relog...
|
// detect an auto-relog...
|
||||||
@ -137,7 +136,7 @@ export class SignInScene implements OnInit {
|
|||||||
let self = this;
|
let self = this;
|
||||||
this.applicationService
|
this.applicationService
|
||||||
.getApplicationSpecificToken(this.ssoApplicationId)
|
.getApplicationSpecificToken(this.ssoApplicationId)
|
||||||
.then((result: SpecificTokenResponse) => {
|
.then((result: ClientToken) => {
|
||||||
self.transferToApplicationThatRequiredTheSSO2(result.url, result.jwt);
|
self.transferToApplicationThatRequiredTheSSO2(result.url, result.jwt);
|
||||||
})
|
})
|
||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
|
@ -7,10 +7,8 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { Location } from '@angular/common';
|
import { Location } from '@angular/common';
|
||||||
import { UserService } from 'common/service/user';
|
|
||||||
import { isNullOrUndefined } from 'common/utils';
|
|
||||||
import { AdminUserService, ApplicationService } from 'base/service';
|
import { AdminUserService, ApplicationService } from 'base/service';
|
||||||
import { SpecificReturnResponse } from 'base/service/application';
|
import { UserService, isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
|
||||||
export function checkLoginValidity(value: string): boolean {
|
export function checkLoginValidity(value: string): boolean {
|
||||||
let regexCheck = new RegExp('^[a-zA-Z0-9_\\.-]+$');
|
let regexCheck = new RegExp('^[a-zA-Z0-9_\\.-]+$');
|
||||||
@ -85,8 +83,8 @@ export class SignOutScene implements OnInit {
|
|||||||
} else {
|
} else {
|
||||||
this.applicationService
|
this.applicationService
|
||||||
.getApplicationReturn(this.ssoApplicationId)
|
.getApplicationReturn(this.ssoApplicationId)
|
||||||
.then((result: SpecificReturnResponse) => {
|
.then((url: string) => {
|
||||||
self.transferToApplicationThatRequiredTheSSO2(result.url);
|
self.transferToApplicationThatRequiredTheSSO2(url);
|
||||||
})
|
})
|
||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
// TODO: self.error = `Can not retreive the application interface`;
|
// TODO: self.error = `Can not retreive the application interface`;
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { SSOService, UserService } from 'common/service';
|
|
||||||
import { AdminUserService } from 'base/service';
|
import { AdminUserService } from 'base/service';
|
||||||
import { checkLoginValidity, checkEmailValidity, checkPasswordValidity } from '../forgot-password/forgot-password';
|
import { checkLoginValidity, checkEmailValidity, checkPasswordValidity } from '../forgot-password/forgot-password';
|
||||||
|
import { UserService, SSOService } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-sign-up',
|
selector: 'app-sign-up',
|
||||||
|
@ -5,49 +5,30 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
import { UserService, SessionService, sha512 } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import {
|
import { DataGetToken, GetToken, Long, UserAuthGet, UserResource } from 'back-api';
|
||||||
SessionService,
|
import { RESTConfig } from 'back-api/rest-tools';
|
||||||
StorageService,
|
import { environment } from 'environments/environment';
|
||||||
HTTPMimeType,
|
|
||||||
HTTPRequestModel,
|
|
||||||
HttpWrapperService,
|
|
||||||
ModelResponseHttp,
|
|
||||||
UserService,
|
|
||||||
} from 'common/service';
|
|
||||||
import { sha512 } from 'common/utils';
|
|
||||||
|
|
||||||
interface MessageLogIn {
|
|
||||||
login: string;
|
|
||||||
method: string;
|
|
||||||
time: string;
|
|
||||||
password: string;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
interface MessageAnswer_USER_CONNECT {
|
|
||||||
sessionId: string;
|
|
||||||
login: string;
|
|
||||||
eMail: string;
|
|
||||||
role: string;
|
|
||||||
avatar: string;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
export type ApplicationUserRight = Object;
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AdminUserService {
|
export class AdminUserService {
|
||||||
|
getRestConfig(): RESTConfig {
|
||||||
|
return {
|
||||||
|
server: environment.server.karso,
|
||||||
|
token: this.session.getToken()
|
||||||
|
}
|
||||||
|
}
|
||||||
// 0: Not hide password; 1 hide password;
|
// 0: Not hide password; 1 hide password;
|
||||||
private identificationVersion: number = 1;
|
private identificationVersion: number = 1;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private userService: UserService,
|
private userService: UserService,
|
||||||
private sessionService: SessionService,
|
private session: SessionService) {
|
||||||
private http: HttpWrapperService) {
|
|
||||||
console.log('Start AdminUserService');
|
console.log('Start AdminUserService');
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Log-in with a clear password
|
* Log-in with a clear password
|
||||||
* @param _login Loggin of the user (or e-mail)
|
* @param _login Login of the user (or e-mail)
|
||||||
* @param _password clear password to send at the Oauth server
|
* @param _password clear password to send at the Oauth server
|
||||||
* @returns promise on connection
|
* @returns promise on connection
|
||||||
*/
|
*/
|
||||||
@ -59,7 +40,7 @@ export class AdminUserService {
|
|||||||
this.userService.removeSession();
|
this.userService.removeSession();
|
||||||
const self = this;
|
const self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.getTocken(login, password)
|
self.getToken(login, password)
|
||||||
.then((value: any) => {
|
.then((value: any) => {
|
||||||
console.log(' =====> We connect on the system...');
|
console.log(' =====> We connect on the system...');
|
||||||
self.userService
|
self.userService
|
||||||
@ -78,14 +59,14 @@ export class AdminUserService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getTocken(login: string, password: string): Promise<any> {
|
getToken(login: string, password: string): Promise<GetToken> {
|
||||||
console.log(`AuthService.getToken ... '${login}':'${password}'`);
|
console.log(`AuthService.getToken ... '${login}':'${password}'`);
|
||||||
|
|
||||||
// TODO: skip this part if the token is valid !!!
|
// TODO: skip this part if the token is valid !!!
|
||||||
// this is here we need to route to the SSO on external system.
|
// this is here we need to route to the SSO on external system.
|
||||||
|
|
||||||
const currentDate: string = new Date().toISOString();
|
const currentDate: string = new Date().toISOString();
|
||||||
let data: MessageLogIn;
|
let data: DataGetToken;
|
||||||
// create request:
|
// create request:
|
||||||
if (this.identificationVersion === 1) {
|
if (this.identificationVersion === 1) {
|
||||||
data = {
|
data = {
|
||||||
@ -101,215 +82,111 @@ export class AdminUserService {
|
|||||||
|
|
||||||
console.log(`call users/connect data=${JSON.stringify(data, null, 2)}`);
|
console.log(`call users/connect data=${JSON.stringify(data, null, 2)}`);
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return UserResource.getToken({
|
||||||
this.http
|
restConfig: this.getRestConfig(),
|
||||||
.requestJson({
|
data
|
||||||
server: 'karso',
|
|
||||||
endPoint: 'users/get_token',
|
|
||||||
requestType: HTTPRequestModel.POST,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
body: data,
|
|
||||||
disableTocken: true,
|
|
||||||
})
|
|
||||||
.then((response: ModelResponseHttp) => {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getUsers(): Promise<any> {
|
getUsers(): Promise<UserAuthGet[]> {
|
||||||
return new Promise((resolve, reject) => {
|
return UserResource.getUsers({
|
||||||
this.http
|
restConfig: this.getRestConfig(),
|
||||||
.requestJson({
|
|
||||||
server: 'karso',
|
|
||||||
endPoint: 'users',
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
contentType: HTTPMimeType.JSON
|
|
||||||
})
|
|
||||||
.then((response: ModelResponseHttp) => {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setAdmin(userId: number, state: boolean): Promise<void> {
|
setAdmin(userId: number, state: boolean): Promise<void> {
|
||||||
const body = state;
|
return UserResource.setAdmin({
|
||||||
return new Promise((resolve, reject) => {
|
restConfig: this.getRestConfig(),
|
||||||
this.http
|
params: {
|
||||||
.requestJson({
|
id: userId
|
||||||
server: 'karso',
|
},
|
||||||
endPoint: `users/${userId}/set_admin`,
|
data: state,
|
||||||
requestType: HTTPRequestModel.POST,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
body,
|
|
||||||
})
|
|
||||||
.then((response: ModelResponseHttp) => {
|
|
||||||
resolve();
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setBlocked(userId: number, state: boolean): Promise<void> {
|
setBlocked(userId: number, state: boolean): Promise<void> {
|
||||||
const body = state;
|
return UserResource.setBlocked({
|
||||||
return new Promise((resolve, reject) => {
|
restConfig: this.getRestConfig(),
|
||||||
this.http
|
params: {
|
||||||
.requestJson({
|
id: userId
|
||||||
server: 'karso',
|
},
|
||||||
endPoint: `users/${userId}/set_blocked`,
|
data: state,
|
||||||
requestType: HTTPRequestModel.POST,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
body,
|
|
||||||
})
|
|
||||||
.then((response: ModelResponseHttp) => {
|
|
||||||
resolve();
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
createUsers(email: string, login: string, password: string): Promise<any> {
|
createUser(email: string, login: string, password: string): Promise<UserAuthGet> {
|
||||||
const body = {
|
return UserResource.create({
|
||||||
email,
|
restConfig: this.getRestConfig(),
|
||||||
login,
|
data: {
|
||||||
password: sha512(password)
|
login,
|
||||||
};
|
email,
|
||||||
return new Promise((resolve, reject) => {
|
password: sha512(password)
|
||||||
this.http
|
},
|
||||||
.requestJson({
|
|
||||||
server: 'karso',
|
|
||||||
endPoint: 'users/create_new_user',
|
|
||||||
requestType: HTTPRequestModel.POST,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
body,
|
|
||||||
})
|
|
||||||
.then((response: ModelResponseHttp) => {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
create(login: string, email: string, password: string) {
|
create(login: string, email: string, password: string) {
|
||||||
return this.createSha(login, email, sha512(password));
|
return this.createSha(login, email, sha512(password));
|
||||||
}
|
|
||||||
createSha(login: string, email: string, password: string) {
|
|
||||||
const data = {
|
|
||||||
method: 'v?',
|
|
||||||
login: login,
|
|
||||||
email: email,
|
|
||||||
password: password,
|
|
||||||
};
|
|
||||||
console.log(`call users data=${JSON.stringify(data, null, 2)}`);
|
|
||||||
|
|
||||||
if (this.identificationVersion === 1) {
|
|
||||||
data.method = 'v1';
|
|
||||||
}
|
}
|
||||||
|
createSha(login: string, email: string, password: string) {
|
||||||
return new Promise((resolve, reject) => {
|
const data = {
|
||||||
this.http
|
method: 'v?',
|
||||||
.requestJson({
|
login: login,
|
||||||
server: 'karso',
|
email: email,
|
||||||
endPoint: 'users',
|
password: password,
|
||||||
requestType: HTTPRequestModel.POST,
|
};
|
||||||
accept: HTTPMimeType.JSON,
|
console.log(`call users data=${JSON.stringify(data, null, 2)}`);
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
body: data,
|
if (this.identificationVersion === 1) {
|
||||||
})
|
data.method = 'v1';
|
||||||
.then((response: ModelResponseHttp) => {
|
}
|
||||||
// TODO: check type ...
|
|
||||||
console.log(`createSha : get some data to check: ${JSON.stringify(response.data)}`);
|
return new Promise((resolve, reject) => {
|
||||||
resolve(response.data);
|
this.http
|
||||||
})
|
.requestJson({
|
||||||
.catch((error: any) => {
|
server: 'karso',
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
endPoint: 'users',
|
||||||
});
|
requestType: HTTPRequestModel.POST,
|
||||||
});
|
accept: HTTPMimeType.JSON,
|
||||||
}
|
contentType: HTTPMimeType.JSON,
|
||||||
|
body: data,
|
||||||
|
})
|
||||||
|
.then((response: ModelResponseHttp) => {
|
||||||
|
// TODO: check type ...
|
||||||
|
console.log(`createSha : get some data to check: ${JSON.stringify(response.data)}`);
|
||||||
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch((error: any) => {
|
||||||
|
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
checkLogin(login: string): Promise<boolean> {
|
checkLogin(login: string): Promise<boolean> {
|
||||||
const params = {
|
return UserResource.isLoginExist({
|
||||||
login: login,
|
restConfig: this.getRestConfig(),
|
||||||
};
|
queries: {
|
||||||
return new Promise((resolve, reject) => {
|
login
|
||||||
this.http
|
},
|
||||||
.request({
|
|
||||||
server: 'karso',
|
|
||||||
endPoint: 'users/check_login',
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
params,
|
|
||||||
})
|
|
||||||
.then((response: Response) => {
|
|
||||||
if (response.status >= 200 && response.status <= 299) {
|
|
||||||
console.log(`checkLogin : The login already exist`);
|
|
||||||
resolve(false);
|
|
||||||
} else if (response.status >= 404) {
|
|
||||||
resolve(true);
|
|
||||||
} else {
|
|
||||||
reject(`return ERROR fail in verifiing the login`);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
checkEMail(email: string): Promise<boolean> {
|
checkEMail(email: string): Promise<boolean> {
|
||||||
const params = {
|
return UserResource.isEmailExist({
|
||||||
email: email,
|
restConfig: this.getRestConfig(),
|
||||||
};
|
queries: {
|
||||||
return new Promise((resolve, reject) => {
|
email
|
||||||
this.http
|
},
|
||||||
.request({
|
|
||||||
server: 'karso',
|
|
||||||
endPoint: 'users/check_email',
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
params,
|
|
||||||
})
|
|
||||||
.then((response: Response) => {
|
|
||||||
if (response.status >= 200 && response.status <= 299) {
|
|
||||||
console.log(`check_email : The login already exist`);
|
|
||||||
resolve(false);
|
|
||||||
} else if (response.status >= 404) {
|
|
||||||
resolve(true);
|
|
||||||
} else {
|
|
||||||
reject(`return ERROR fail in verifiing the email`);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
retreivePassword(login: string): Promise<void> {
|
retrievePassword(login: string): Promise<void> {
|
||||||
throw new Error('retreivePassword: Method not implemented.');
|
throw new Error('retrievePassword: Method not implemented.');
|
||||||
}
|
}
|
||||||
|
|
||||||
changePassword(oldPassword: string, newPassword: string): Promise<void> {
|
changePassword(oldPassword: string, newPassword: string): Promise<void> {
|
||||||
const time: string = new Date().toISOString();
|
const time: string = new Date().toISOString();
|
||||||
const login: string = this.sessionService.getLogin();
|
const login: string = this.session.getLogin();
|
||||||
let method = null;
|
let method = null;
|
||||||
let password = null;
|
let password = null;
|
||||||
if (this.identificationVersion === 1) {
|
if (this.identificationVersion === 1) {
|
||||||
@ -320,82 +197,36 @@ export class AdminUserService {
|
|||||||
reject(`Internal Fail (contact administrator).`);
|
reject(`Internal Fail (contact administrator).`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const body = {
|
return UserResource.changePassword({
|
||||||
method,
|
restConfig: this.getRestConfig(),
|
||||||
time,
|
data: {
|
||||||
login,
|
method,
|
||||||
password,
|
time,
|
||||||
newPassword: sha512(newPassword),
|
login,
|
||||||
};
|
password,
|
||||||
const self = this;
|
newPassword: sha512(newPassword),
|
||||||
return new Promise((resolve, reject) => {
|
},
|
||||||
self.http
|
|
||||||
.request({
|
|
||||||
server: 'karso',
|
|
||||||
endPoint: 'users/password',
|
|
||||||
requestType: HTTPRequestModel.POST,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
body,
|
|
||||||
})
|
|
||||||
.then((response: Response) => {
|
|
||||||
if (response.status >= 200 && response.status <= 299) {
|
|
||||||
console.log(`Update password done with sucess`);
|
|
||||||
resolve();
|
|
||||||
} else {
|
|
||||||
reject(`return ERROR to change password: ${response.status}`);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getApplicationRights(userId: number, applicationId: number): Promise<ApplicationUserRight> {
|
getApplicationRights(userId: Long, applicationId: Long): Promise<any> {
|
||||||
const self = this;
|
return UserResource.getApplicationRight({
|
||||||
return new Promise((resolve, reject) => {
|
restConfig: this.getRestConfig(),
|
||||||
this.http
|
params: {
|
||||||
.requestJson({
|
applicationId,
|
||||||
server: 'karso',
|
userId,
|
||||||
endPoint: `users/${userId}/application/${applicationId}/rights`,
|
}
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
})
|
|
||||||
.then((response: ModelResponseHttp) => {
|
|
||||||
console.log(
|
|
||||||
`Get user Rights: ${JSON.stringify(response.data)}`
|
|
||||||
);
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
updateApplicationRights(userId: number, applicationId: number, dataUpdate: object): Promise<ApplicationUserRight> {
|
updateApplicationRights(userId: number, applicationId: number, dataUpdate: object): Promise<any> {
|
||||||
const self = this;
|
return UserResource.patchApplicationRight({
|
||||||
return new Promise((resolve, reject) => {
|
restConfig: this.getRestConfig(),
|
||||||
this.http
|
params: {
|
||||||
.requestJson({
|
applicationId,
|
||||||
server: 'karso',
|
userId,
|
||||||
endPoint: `users/${userId}/application/${applicationId}/rights`,
|
},
|
||||||
requestType: HTTPRequestModel.PATCH,
|
data: dataUpdate
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
body: dataUpdate
|
|
||||||
})
|
|
||||||
.then((response: ModelResponseHttp) => {
|
|
||||||
console.log(
|
|
||||||
`Get user Rights: ${JSON.stringify(response.data)}`
|
|
||||||
);
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,92 +5,53 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
import { SessionService } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import {
|
import { ApplicationToken, ApplicationTokenResource, Long } from 'back-api';
|
||||||
SessionService,
|
import { RESTConfig } from 'back-api/rest-tools';
|
||||||
HTTPMimeType,
|
import { environment } from 'environments/environment';
|
||||||
HTTPRequestModel,
|
|
||||||
HttpWrapperService,
|
|
||||||
ModelResponseHttp,
|
|
||||||
} from 'common/service';
|
|
||||||
|
|
||||||
export interface ApplicationTokenModel {
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
endValidityTime: string;
|
|
||||||
token?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ApplicationTokenService {
|
export class ApplicationTokenService {
|
||||||
constructor(private http: HttpWrapperService) {
|
getRestConfig(): RESTConfig {
|
||||||
|
return {
|
||||||
|
server: environment.server.karso,
|
||||||
|
token: this.session.getToken()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private session: SessionService) {
|
||||||
console.log('Start ApplicationTokenService');
|
console.log('Start ApplicationTokenService');
|
||||||
}
|
}
|
||||||
|
|
||||||
gets(applicationId: number): Promise<ApplicationTokenModel[]> {
|
gets(applicationId: Long): Promise<ApplicationToken[]> {
|
||||||
const self = this;
|
return ApplicationTokenResource.gets({
|
||||||
return new Promise((resolve, reject) => {
|
restConfig: this.getRestConfig(),
|
||||||
this.http
|
params: {
|
||||||
.requestJson({
|
applicationId
|
||||||
server: 'karso',
|
}
|
||||||
endPoint: `application_token/${applicationId}`,
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
})
|
|
||||||
.then((response: ModelResponseHttp) => {
|
|
||||||
// TODO: check type ...
|
|
||||||
console.log(
|
|
||||||
`retreive Token for application : get some data to check: ${JSON.stringify(response.data)}`
|
|
||||||
);
|
|
||||||
// tODO: check the format...
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
create(applicationId: number, name: string, validity: number): Promise<ApplicationTokenModel> {
|
create(applicationId: number, name: string, validity: number): Promise<ApplicationToken> {
|
||||||
let body = {
|
return ApplicationTokenResource.create({
|
||||||
name,
|
restConfig: this.getRestConfig(),
|
||||||
validity,
|
params: {
|
||||||
};
|
applicationId
|
||||||
return new Promise((resolve, reject) => {
|
},
|
||||||
this.http
|
data: {
|
||||||
.requestJson({
|
name,
|
||||||
server: 'karso',
|
validity
|
||||||
endPoint: `application_token/${applicationId}/create`,
|
}
|
||||||
requestType: HTTPRequestModel.POST,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
body,
|
|
||||||
})
|
|
||||||
.then((response: ModelResponseHttp) => {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
remove(applicationId: number, tokenId: number): Promise<void> {
|
remove(applicationId: number, tokenId: number): Promise<void> {
|
||||||
return new Promise((resolve, reject) => {
|
return ApplicationTokenResource.remove({
|
||||||
this.http
|
restConfig: this.getRestConfig(),
|
||||||
.request({
|
params: {
|
||||||
server: 'karso',
|
applicationId,
|
||||||
endPoint: `application_token/${applicationId}/${tokenId}`,
|
tokenId
|
||||||
requestType: HTTPRequestModel.DELETE,
|
}
|
||||||
accept: HTTPMimeType.ALL,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
resolve();
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,342 +5,123 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
import { SessionService } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import {
|
import { RightDescription, ApplicationSmall, Application, ApplicationResource, ClientToken, Long } from 'back-api';
|
||||||
SessionService,
|
import { RESTConfig } from 'back-api/rest-tools';
|
||||||
StorageService,
|
import { environment } from 'environments/environment';
|
||||||
HTTPMimeType,
|
|
||||||
HTTPRequestModel,
|
|
||||||
HttpWrapperService,
|
|
||||||
ModelResponseHttp,
|
|
||||||
} from 'common/service';
|
|
||||||
|
|
||||||
interface MessageLogIn {
|
|
||||||
login: string;
|
|
||||||
method: string;
|
|
||||||
time: number;
|
|
||||||
password: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SpecificTokenResponse {
|
|
||||||
jwt: string;
|
|
||||||
url: string;
|
|
||||||
}
|
|
||||||
export interface SpecificReturnResponse {
|
|
||||||
url: string;
|
|
||||||
}
|
|
||||||
export interface GetApplicationSmallResponse {
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
description: string;
|
|
||||||
redirect: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ApplicationModel {
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
description: string;
|
|
||||||
redirect: string;
|
|
||||||
redirectDev: string;
|
|
||||||
notification: string;
|
|
||||||
ttl: number;
|
|
||||||
}
|
|
||||||
export interface ApplicationRightModel {
|
|
||||||
id: number;
|
|
||||||
applicationId: number;
|
|
||||||
title: string;
|
|
||||||
description: string;
|
|
||||||
key: string;
|
|
||||||
type: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ApplicationService {
|
export class ApplicationService {
|
||||||
constructor(private http: HttpWrapperService, private sessionService: SessionService) {
|
getRestConfig(): RESTConfig {
|
||||||
|
return {
|
||||||
|
server: environment.server.karso,
|
||||||
|
token: this.session.getToken()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(private session: SessionService) {
|
||||||
console.log('Start ApplicationService');
|
console.log('Start ApplicationService');
|
||||||
}
|
}
|
||||||
|
|
||||||
getRights(applicationId: number): Promise<ApplicationRightModel[]> {
|
getRights(id: Long): Promise<RightDescription[]> {
|
||||||
const self = this;
|
return ApplicationResource.getRightsDescription({
|
||||||
return new Promise((resolve, reject) => {
|
restConfig: this.getRestConfig(),
|
||||||
this.http
|
params: {
|
||||||
.requestJson({
|
id
|
||||||
server: 'karso',
|
}
|
||||||
endPoint: `application/${applicationId}/rights`,
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
})
|
|
||||||
.then((response: ModelResponseHttp) => {
|
|
||||||
// TODO: check type ...
|
|
||||||
console.log(
|
|
||||||
`retrieve Token for application : get some data to check: ${JSON.stringify(response.data)}`
|
|
||||||
);
|
|
||||||
// tODO: check the format...
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getApplicationSpecificToken(applicationId: string): Promise<SpecificTokenResponse> {
|
getApplicationSpecificToken(application: string): Promise<ClientToken> {
|
||||||
const self = this;
|
return ApplicationResource.getClientToken({
|
||||||
return new Promise((resolve, reject) => {
|
restConfig: this.getRestConfig(),
|
||||||
this.http
|
queries: {
|
||||||
.requestJson({
|
application
|
||||||
server: 'karso',
|
}
|
||||||
endPoint: 'application/get_token',
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
params: {
|
|
||||||
application: applicationId,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.then((response: ModelResponseHttp) => {
|
|
||||||
// TODO: check type ...
|
|
||||||
console.log(
|
|
||||||
`retrieve Token for application : get some data to check: ${JSON.stringify(response.data)}`
|
|
||||||
);
|
|
||||||
// tODO: check the format...
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
addUser(applicationId: number, userId: number): Promise<boolean> {
|
addUser(id: Long, userId: Long): Promise<void> {
|
||||||
const self = this;
|
return ApplicationResource.addUser({
|
||||||
return new Promise((resolve, reject) => {
|
restConfig: this.getRestConfig(),
|
||||||
this.http
|
params: {
|
||||||
.requestJson({
|
id
|
||||||
server: 'karso',
|
},
|
||||||
endPoint: `application/${applicationId}/users`,
|
data: {
|
||||||
requestType: HTTPRequestModel.POST,
|
userId
|
||||||
accept: HTTPMimeType.JSON,
|
}
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
body: {
|
|
||||||
userId,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.then((response: ModelResponseHttp) => {
|
|
||||||
console.log(
|
|
||||||
`User has been added: ${JSON.stringify(response.data)}`
|
|
||||||
);
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
rmUser(applicationId: number, userId: number): Promise<boolean> {
|
removeUser(id: Long, userId: Long): Promise<void> {
|
||||||
const self = this;
|
return ApplicationResource.removeUser({
|
||||||
return new Promise((resolve, reject) => {
|
restConfig: this.getRestConfig(),
|
||||||
this.http
|
params: {
|
||||||
.requestJson({
|
id,
|
||||||
server: 'karso',
|
userId
|
||||||
endPoint: `application/${applicationId}/users`,
|
},
|
||||||
requestType: HTTPRequestModel.DELETE,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
body: {
|
|
||||||
userId,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.then((response: ModelResponseHttp) => {
|
|
||||||
console.log(
|
|
||||||
`User has been added: ${JSON.stringify(response.data)}`
|
|
||||||
);
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getApplicationReturn(applicationId: string): Promise<SpecificReturnResponse> {
|
getApplicationReturn(application: string): Promise<string> {
|
||||||
const self = this;
|
return ApplicationResource.logOut({
|
||||||
return new Promise((resolve, reject) => {
|
restConfig: this.getRestConfig(),
|
||||||
this.http
|
queries: {
|
||||||
.requestJson({
|
application
|
||||||
server: 'karso',
|
},
|
||||||
endPoint: 'application/return',
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
params: {
|
|
||||||
application: applicationId,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.then((response: ModelResponseHttp) => {
|
|
||||||
// TODO: check type ...
|
|
||||||
console.log(
|
|
||||||
`retreive return for application : get some data to check: ${JSON.stringify(response.data)}`
|
|
||||||
);
|
|
||||||
// tODO: check the format...
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getApplicationsSmall(): Promise<GetApplicationSmallResponse[]> {
|
getApplicationsSmall(): Promise<ApplicationSmall[]> {
|
||||||
const self = this;
|
return ApplicationResource.getApplicationsSmall({
|
||||||
return new Promise((resolve, reject) => {
|
restConfig: this.getRestConfig(),
|
||||||
this.http
|
|
||||||
.requestJson({
|
|
||||||
server: 'karso',
|
|
||||||
endPoint: 'application/small',
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
})
|
|
||||||
.then((response: ModelResponseHttp) => {
|
|
||||||
// TODO: check type ...
|
|
||||||
console.log(
|
|
||||||
`retrieve return for application : get some data to check: ${JSON.stringify(response.data)}`
|
|
||||||
);
|
|
||||||
// tODO: check the format...
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getUsers(id: number): Promise<number[]> {
|
getUsers(id: number): Promise<Long[]> {
|
||||||
return new Promise((resolve, reject) => {
|
return ApplicationResource.getApplicationUsers({
|
||||||
this.http
|
restConfig: this.getRestConfig(),
|
||||||
.requestJson({
|
params: {
|
||||||
server: 'karso',
|
id,
|
||||||
endPoint: `application/${id}/users`,
|
}
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
})
|
|
||||||
.then((response: ModelResponseHttp) => {
|
|
||||||
// TODO: check type ...
|
|
||||||
console.log(
|
|
||||||
`retrieve return for application : get some data to check: ${JSON.stringify(response.data)}`
|
|
||||||
);
|
|
||||||
// TODO: check the format...
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
gets(): Promise<ApplicationModel[]> {
|
gets(): Promise<Application[]> {
|
||||||
return new Promise((resolve, reject) => {
|
return ApplicationResource.gets({
|
||||||
this.http
|
restConfig: this.getRestConfig(),
|
||||||
.requestJson({
|
|
||||||
server: 'karso',
|
|
||||||
endPoint: 'application',
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
})
|
|
||||||
.then((response: ModelResponseHttp) => {
|
|
||||||
// TODO: check type ...
|
|
||||||
console.log(
|
|
||||||
`retreive return for application : get some data to check: ${JSON.stringify(response.data)}`
|
|
||||||
);
|
|
||||||
// tODO: check the format...
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
get(id: number): Promise<ApplicationModel> {
|
get(id: number): Promise<Application> {
|
||||||
return new Promise((resolve, reject) => {
|
return ApplicationResource.get({
|
||||||
this.http
|
restConfig: this.getRestConfig(),
|
||||||
.requestJson({
|
params: {
|
||||||
server: 'karso',
|
id,
|
||||||
endPoint: `application/${id}`,
|
}
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
})
|
|
||||||
.then((response: ModelResponseHttp) => {
|
|
||||||
// TODO: check type ...
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
update(id: number, updateState: object): Promise<ApplicationModel> {
|
update(id: number, updateState: Application): Promise<Application> {
|
||||||
return new Promise((resolve, reject) => {
|
return ApplicationResource.patch({
|
||||||
this.http
|
restConfig: this.getRestConfig(),
|
||||||
.requestJson({
|
params: {
|
||||||
server: 'karso',
|
id,
|
||||||
endPoint: `application/${id}`,
|
},
|
||||||
requestType: HTTPRequestModel.PATCH,
|
data: updateState
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
body: updateState,
|
|
||||||
})
|
|
||||||
.then((response: ModelResponseHttp) => {
|
|
||||||
// TODO: check type ...
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
create(name: string, redirect: string): Promise<ApplicationModel> {
|
create(name: string, redirect: string): Promise<Application> {
|
||||||
let body = {
|
return ApplicationResource.create({
|
||||||
name,
|
restConfig: this.getRestConfig(),
|
||||||
redirect,
|
data: {
|
||||||
};
|
name,
|
||||||
return new Promise((resolve, reject) => {
|
redirect,
|
||||||
this.http
|
}
|
||||||
.requestJson({
|
|
||||||
server: 'karso',
|
|
||||||
endPoint: 'application',
|
|
||||||
requestType: HTTPRequestModel.POST,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
body,
|
|
||||||
})
|
|
||||||
.then((response: ModelResponseHttp) => {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
remove(id: number): Promise<void> {
|
remove(id: number): Promise<void> {
|
||||||
return new Promise((resolve, reject) => {
|
return ApplicationResource.remove({
|
||||||
this.http
|
restConfig: this.getRestConfig(),
|
||||||
.request({
|
params: {
|
||||||
server: 'karso',
|
id,
|
||||||
endPoint: `application/${id}`,
|
},
|
||||||
requestType: HTTPRequestModel.DELETE,
|
|
||||||
accept: HTTPMimeType.ALL,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
resolve();
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { AdminUserService, ApplicationUserRight } from './admin-user';
|
export { AdminUserService } from './admin-user';
|
||||||
import { ApplicationModel, ApplicationService } from './application';
|
export { ApplicationService } from './application';
|
||||||
import { ApplicationTokenService } from './application-token';
|
export { ApplicationTokenService } from './application-token';
|
||||||
import { SettingsService } from './settings';
|
export { SettingsService } from './settings';
|
||||||
|
|
||||||
export { AdminUserService, ApplicationService, SettingsService, ApplicationModel, ApplicationTokenService, ApplicationUserRight };
|
|
||||||
|
@ -5,8 +5,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HTTPMimeType, HTTPRequestModel, HttpWrapperService, ModelResponseHttp } from 'common/service';
|
import { isUndefined, SessionService } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import { isUndefined } from 'common/utils';
|
import { SystemConfigResource } from 'back-api';
|
||||||
|
import { RESTConfig } from 'back-api/rest-tools';
|
||||||
|
import { environment } from 'environments/environment';
|
||||||
|
|
||||||
|
|
||||||
class MultipleRequest {
|
class MultipleRequest {
|
||||||
requestDone: number = 0;
|
requestDone: number = 0;
|
||||||
@ -44,52 +47,45 @@ class MultipleRequest {
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SettingsService {
|
export class SettingsService {
|
||||||
constructor(private http: HttpWrapperService) { }
|
getRestConfig(): RESTConfig {
|
||||||
|
return {
|
||||||
|
server: environment.server.karso,
|
||||||
|
token: this.session.getToken()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
constructor(private session: SessionService) { }
|
||||||
/**
|
/**
|
||||||
* Get a generic setting (Key value)
|
* Get a generic setting (Key value)
|
||||||
* @returns a promise of the data value
|
* @returns a promise of the data value
|
||||||
*/
|
*/
|
||||||
get(key: string): Promise<string | Number | boolean> {
|
get(key: string): Promise<string | Number | boolean> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.http
|
SystemConfigResource.getKey(
|
||||||
.requestJson({
|
{
|
||||||
endPoint: `system_config/key/${key}`,
|
restConfig: this.getRestConfig(),
|
||||||
requestType: HTTPRequestModel.GET,
|
params: {
|
||||||
accept: HTTPMimeType.JSON,
|
key
|
||||||
contentType: HTTPMimeType.JSON,
|
}
|
||||||
})
|
})
|
||||||
.then((response: ModelResponseHttp) => {
|
.then((response: any) => {
|
||||||
resolve(response.data.value);
|
resolve(response.value);
|
||||||
})
|
})
|
||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||||
});
|
});
|
||||||
return;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Set a generic setting (Key value)
|
* Set a generic setting (Key value)
|
||||||
* @returns a promise when set is done
|
* @returns a promise when set is done
|
||||||
*/
|
*/
|
||||||
set(key: string, value: string | Number | boolean): Promise<boolean> {
|
set(key: string, value: string | Number | boolean): Promise<void> {
|
||||||
return new Promise((resolve, reject) => {
|
return SystemConfigResource.setKey({
|
||||||
this.http
|
restConfig: this.getRestConfig(),
|
||||||
.requestJson({
|
params: {
|
||||||
endPoint: `system_config/key/${key}`,
|
key
|
||||||
requestType: HTTPRequestModel.PATCH,
|
},
|
||||||
accept: HTTPMimeType.JSON,
|
data: `${value}`
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
body: {
|
|
||||||
value,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.then((response: ModelResponseHttp) => {
|
|
||||||
resolve(true);
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -121,8 +117,8 @@ export class SettingsService {
|
|||||||
let multipleResponse = new MultipleRequest(resolve, reject, keys.length);
|
let multipleResponse = new MultipleRequest(resolve, reject, keys.length);
|
||||||
for (let key of keys) {
|
for (let key of keys) {
|
||||||
this.set(key, data[key])
|
this.set(key, data[key])
|
||||||
.then((result: boolean) => {
|
.then(() => {
|
||||||
multipleResponse.add(key, result);
|
multipleResponse.add(key, true);
|
||||||
})
|
})
|
||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
multipleResponse.fail(key, error);
|
multipleResponse.fail(key, error);
|
||||||
|
@ -1 +0,0 @@
|
|||||||
Subproject commit 147a955b195eb7c90e445d404f043d9a363087ca
|
|
@ -3,7 +3,9 @@
|
|||||||
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
|
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
|
||||||
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
||||||
|
|
||||||
export const environment = {
|
import { Environment } from "@kangaroo-and-rabbit/kar-cw";
|
||||||
|
|
||||||
|
export const environment: Environment = {
|
||||||
production: true,
|
production: true,
|
||||||
// URL of development API
|
// URL of development API
|
||||||
applName: 'karso',
|
applName: 'karso',
|
||||||
@ -11,7 +13,6 @@ export const environment = {
|
|||||||
server: {
|
server: {
|
||||||
karso: `${location.origin}/karso/api`,
|
karso: `${location.origin}/karso/api`,
|
||||||
},
|
},
|
||||||
edgeMode: true,
|
|
||||||
// set to undefined sso* in case of internal authentication model
|
// set to undefined sso* in case of internal authentication model
|
||||||
ssoSite: `${location.origin}/karso-edge`,
|
ssoSite: `${location.origin}/karso-edge`,
|
||||||
ssoSignIn: undefined,
|
ssoSignIn: undefined,
|
||||||
@ -19,3 +20,7 @@ export const environment = {
|
|||||||
ssoSignUp: undefined,
|
ssoSignUp: undefined,
|
||||||
tokenStoredInPermanentStorage: true,
|
tokenStoredInPermanentStorage: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const environmentKarso = {
|
||||||
|
edgeMode: true,
|
||||||
|
};
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
|
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
|
||||||
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
||||||
|
|
||||||
export const environment = {
|
import { Environment } from "@kangaroo-and-rabbit/kar-cw";
|
||||||
|
|
||||||
|
export const environment: Environment = {
|
||||||
production: false,
|
production: false,
|
||||||
// URL of development API
|
// URL of development API
|
||||||
applName: 'karso-edge',
|
applName: 'karso-edge',
|
||||||
@ -11,7 +13,6 @@ export const environment = {
|
|||||||
server: {
|
server: {
|
||||||
karso: 'http://localhost:15080/karso-edge/api',
|
karso: 'http://localhost:15080/karso-edge/api',
|
||||||
},
|
},
|
||||||
edgeMode: true,
|
|
||||||
// set to undefined sso* in case of internal authentication model
|
// set to undefined sso* in case of internal authentication model
|
||||||
ssoSite: 'http://localhost:15080/karso',
|
ssoSite: 'http://localhost:15080/karso',
|
||||||
ssoSignIn: undefined,
|
ssoSignIn: undefined,
|
||||||
@ -19,3 +20,7 @@ export const environment = {
|
|||||||
ssoSignUp: undefined,
|
ssoSignUp: undefined,
|
||||||
tokenStoredInPermanentStorage: true,
|
tokenStoredInPermanentStorage: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const environmentKarso = {
|
||||||
|
edgeMode: true,
|
||||||
|
};
|
@ -3,7 +3,9 @@
|
|||||||
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
|
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
|
||||||
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
||||||
|
|
||||||
export const environment = {
|
import { Environment } from "@kangaroo-and-rabbit/kar-cw";
|
||||||
|
|
||||||
|
export const environment: Environment = {
|
||||||
production: true,
|
production: true,
|
||||||
// URL of development API
|
// URL of development API
|
||||||
applName: 'karso',
|
applName: 'karso',
|
||||||
@ -11,7 +13,6 @@ export const environment = {
|
|||||||
server: {
|
server: {
|
||||||
karso: `${location.origin}/karso/api`,
|
karso: `${location.origin}/karso/api`,
|
||||||
},
|
},
|
||||||
edgeMode: false,
|
|
||||||
// set to undefined sso* in case of internal authentication model
|
// set to undefined sso* in case of internal authentication model
|
||||||
ssoSite: undefined,
|
ssoSite: undefined,
|
||||||
ssoSignIn: undefined,
|
ssoSignIn: undefined,
|
||||||
@ -19,3 +20,7 @@ export const environment = {
|
|||||||
ssoSignUp: undefined,
|
ssoSignUp: undefined,
|
||||||
tokenStoredInPermanentStorage: true,
|
tokenStoredInPermanentStorage: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const environmentKarso = {
|
||||||
|
edgeMode: false,
|
||||||
|
};
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
|
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
|
||||||
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
||||||
|
|
||||||
export const environment = {
|
import { Environment } from "@kangaroo-and-rabbit/kar-cw";
|
||||||
|
|
||||||
|
export const environment: Environment = {
|
||||||
production: false,
|
production: false,
|
||||||
// URL of development API
|
// URL of development API
|
||||||
applName: 'karso',
|
applName: 'karso',
|
||||||
@ -11,7 +13,6 @@ export const environment = {
|
|||||||
server: {
|
server: {
|
||||||
karso: 'http://localhost:15080/karso/api',
|
karso: 'http://localhost:15080/karso/api',
|
||||||
},
|
},
|
||||||
edgeMode: false,
|
|
||||||
// set to undefined sso* in case of internal authentication model
|
// set to undefined sso* in case of internal authentication model
|
||||||
ssoSite: undefined,
|
ssoSite: undefined,
|
||||||
ssoSignIn: undefined,
|
ssoSignIn: undefined,
|
||||||
@ -19,3 +20,7 @@ export const environment = {
|
|||||||
ssoSignUp: undefined,
|
ssoSignUp: undefined,
|
||||||
tokenStoredInPermanentStorage: true,
|
tokenStoredInPermanentStorage: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const environmentKarso = {
|
||||||
|
edgeMode: false,
|
||||||
|
};
|
||||||
|
@ -9,12 +9,12 @@
|
|||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"target": "es2018",
|
"target": "ES2022",
|
||||||
"typeRoots": [
|
"typeRoots": [
|
||||||
"node_modules/@types"
|
"node_modules/@types"
|
||||||
],
|
],
|
||||||
"lib": [
|
"lib": [
|
||||||
"es2018",
|
"ES2022",
|
||||||
"dom"
|
"dom"
|
||||||
],
|
],
|
||||||
"module": "es2020",
|
"module": "es2020",
|
||||||
@ -33,5 +33,13 @@
|
|||||||
"./src/common/"
|
"./src/common/"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"angularCompilerOptions": {
|
||||||
|
"_enabledBlockTypes": [
|
||||||
|
"if",
|
||||||
|
"switch",
|
||||||
|
"for",
|
||||||
|
"defer"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user