diff options
author | Matthew Flaherty | 2008-02-28 18:02:41 +0000 |
---|---|---|
committer | Matthew Flaherty | 2008-02-28 18:02:41 +0000 |
commit | 29b554fbb50f5344fbdbb5d5933b78de2481165f (patch) | |
tree | be3212742436707af5bee9871b5a3b111368f9b8 /bundles/org.eclipse.equinox.security.tests | |
parent | 214985f7d58476d614c658ad4193f0d366a5edc9 (diff) | |
download | rt.equinox.bundles-29b554fbb50f5344fbdbb5d5933b78de2481165f.tar.gz rt.equinox.bundles-29b554fbb50f5344fbdbb5d5933b78de2481165f.tar.xz rt.equinox.bundles-29b554fbb50f5344fbdbb5d5933b78de2481165f.zip |
*** empty log message ***
Diffstat (limited to 'bundles/org.eclipse.equinox.security.tests')
27 files changed, 2208 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.security.tests/.classpath b/bundles/org.eclipse.equinox.security.tests/.classpath new file mode 100644 index 000000000..065ac06e1 --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/bundles/org.eclipse.equinox.security.tests/.project b/bundles/org.eclipse.equinox.security.tests/.project new file mode 100644 index 000000000..2dadceb0c --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.equinox.security.tests</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/bundles/org.eclipse.equinox.security.tests/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.security.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..bc54588f1 --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,343 @@ +#Tue Jan 22 17:24:37 EST 2008 +eclipse.preferences.version=1 +instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true +org.eclipse.jdt.core.builder.cleanOutputFolder=clean +org.eclipse.jdt.core.builder.duplicateResourceTask=warning +org.eclipse.jdt.core.builder.invalidClasspath=abort +org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch +org.eclipse.jdt.core.circularClasspath=error +org.eclipse.jdt.core.classpath.exclusionPatterns=enabled +org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.4 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.doc.comment.support=enabled +org.eclipse.jdt.core.compiler.maxProblemPerUnit=1000 +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=warning +org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=ignore +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadoc=error +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private +org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled +org.eclipse.jdt.core.compiler.problem.unusedImport=error +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=enabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.3 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.format_block_comments=false +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=false +org.eclipse.jdt.core.formatter.comment.format_line_comments=false +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false +org.eclipse.jdt.core.formatter.comment.indent_root_tags=false +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert +org.eclipse.jdt.core.formatter.comment.line_length=80 +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=800 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false +org.eclipse.jdt.core.formatter.tabulation.char=tab +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.incompatibleJDKLevel=ignore +org.eclipse.jdt.core.incompleteClasspath=error diff --git a/bundles/org.eclipse.equinox.security.tests/.settings/org.eclipse.jdt.ui.prefs b/bundles/org.eclipse.equinox.security.tests/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000..416d09055 --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,59 @@ +#Tue Sep 18 13:56:07 EDT 2007 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +formatter_profile=_core +formatter_settings_version=11 +instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=; +org.eclipse.jdt.ui.ondemandthreshold=3 +org.eclipse.jdt.ui.staticondemandthreshold=99 +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=false +sp_cleanup.format_source_code=true +sp_cleanup.make_local_variable_final=false +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=false +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=false +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=false +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/bundles/org.eclipse.equinox.security.tests/.settings/org.eclipse.pde.core.prefs b/bundles/org.eclipse.equinox.security.tests/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 000000000..bc8d37e87 --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,3 @@ +#Thu Sep 13 15:23:29 EDT 2007 +eclipse.preferences.version=1 +resolve.requirebundle=false diff --git a/bundles/org.eclipse.equinox.security.tests/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.security.tests/META-INF/MANIFEST.MF new file mode 100644 index 000000000..05364a003 --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/META-INF/MANIFEST.MF @@ -0,0 +1,19 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Equinox security tests +Bundle-SymbolicName: org.eclipse.equinox.security.tests;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: org.eclipse.equinox.internal.security.tests.SecurityTestsActivator +Bundle-RequiredExecutionEnvironment: J2SE-1.4 +Bundle-Vendor: Eclipse.org +Require-Bundle: org.eclipse.core.tests.harness;bundle-version="3.4.0", + org.junit, + org.eclipse.osgi;bundle-version="3.4.0", + org.eclipse.equinox.security;bundle-version="0.0.1", + org.eclipse.equinox.registry;bundle-version="3.4.0", + org.eclipse.equinox.preferences;bundle-version="3.2.200" +Eclipse-LazyStart: true +Export-Package: org.eclipse.equinox.internal.security.tests;x-internal:=true, + org.eclipse.equinox.internal.security.tests.storage;x-internal:=true, + org.eclipse.equinox.security.tests +Bundle-ActivationPolicy: lazy diff --git a/bundles/org.eclipse.equinox.security.tests/Plugin_Testing/priority/high/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.security.tests/Plugin_Testing/priority/high/META-INF/MANIFEST.MF new file mode 100644 index 000000000..4014291bf --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/Plugin_Testing/priority/high/META-INF/MANIFEST.MF @@ -0,0 +1,7 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: TestHighPriority +Bundle-SymbolicName: org.eclipse.equinox.security.TestHighPriority;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Vendor: Eclipse.org +Require-Bundle: org.eclipse.equinox.security.tests diff --git a/bundles/org.eclipse.equinox.security.tests/Plugin_Testing/priority/high/plugin.xml b/bundles/org.eclipse.equinox.security.tests/Plugin_Testing/priority/high/plugin.xml new file mode 100644 index 000000000..c7f68f117 --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/Plugin_Testing/priority/high/plugin.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.2"?> +<plugin> + <extension + id="HighPriority" + name="High priority dynamic test for secure preferences" + point="org.eclipse.equinox.security.secureStorage"> + <provider + class="org.eclipse.equinox.internal.security.tests.storage.HighPriorityModule" + priority="10"> + </provider> + </extension> + +</plugin> diff --git a/bundles/org.eclipse.equinox.security.tests/Plugin_Testing/priority/low/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.security.tests/Plugin_Testing/priority/low/META-INF/MANIFEST.MF new file mode 100644 index 000000000..ac69d5d15 --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/Plugin_Testing/priority/low/META-INF/MANIFEST.MF @@ -0,0 +1,7 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: TestLowPriority +Bundle-SymbolicName: org.eclipse.equinox.security.TestLowPriority;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Vendor: Eclipse.org +Require-Bundle: org.eclipse.equinox.security.tests diff --git a/bundles/org.eclipse.equinox.security.tests/Plugin_Testing/priority/low/plugin.xml b/bundles/org.eclipse.equinox.security.tests/Plugin_Testing/priority/low/plugin.xml new file mode 100644 index 000000000..0ea673fed --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/Plugin_Testing/priority/low/plugin.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.2"?> +<plugin> + <extension + id="LowPriority" + name="Low priority dynamic test for secure preferences" + point="org.eclipse.equinox.security.secureStorage"> + <provider + class="org.eclipse.equinox.internal.security.tests.storage.LowPriorityModule" + priority="9"> + </provider> + </extension> + +</plugin> diff --git a/bundles/org.eclipse.equinox.security.tests/SecurePrefsSample/1/secure_storage.equinox b/bundles/org.eclipse.equinox.security.tests/SecurePrefsSample/1/secure_storage.equinox new file mode 100644 index 000000000..8cbf107c6 --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/SecurePrefsSample/1/secure_storage.equinox @@ -0,0 +1,9 @@ +#Equinox secure storage version 1.0 +#Fri Feb 01 11:33:36 EST 2008 +equinox.security.preferences.version=1 +password==org.eclipse.equinox.security.noModule\tXNIUPgccoIw\=,0o1QFi/xKg1OR/HP4ZCWhA\=\= +/abc/password1=org.eclipse.equinox.security.noModule\tDvRvjht7osQ\=,46ajUw62cSomethingIsWrong6rDR9gX+9WL3w\=\= +/abc/password2=org.eclipse.equinox.security.noModule\tDvRvjht7osQ\=,46abUw62c6rDR9gX+9WL3w\=\= +/cvs/eclipse.org/account1/password1=org.eclipse.equinox.security.oops\tOMBrKCofwqM\=,v8GEHFR5HvCe94arAo1RvA\=\= +/cvs/eclipse.org/account1/password2=OMBrKCofwqM\=,v8GEHFR5HvCe94arAo1RvA\=\= +/cvs/eclipse.org/password=org.eclipse.equinox.security.noModule\tG4/jZ1j21uI\=,C5c3ftrYWKEZo7Zuv7Ygxg\=\= diff --git a/bundles/org.eclipse.equinox.security.tests/about.html b/bundles/org.eclipse.equinox.security.tests/about.html new file mode 100644 index 000000000..460233046 --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/about.html @@ -0,0 +1,28 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> +<title>About</title> +</head> +<body lang="EN-US"> +<h2>About This Content</h2> + +<p>June 2, 2006</p> +<h3>License</h3> + +<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. +For purposes of the EPL, "Program" will mean the Content.</p> + +<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p> + +</body> +</html>
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.security.tests/build.properties b/bundles/org.eclipse.equinox.security.tests/build.properties new file mode 100644 index 000000000..dc993f980 --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/build.properties @@ -0,0 +1,9 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + about.html,\ + plugin.xml,\ + Plugin_Testing/ +src.includes = about.html,\ + src/ diff --git a/bundles/org.eclipse.equinox.security.tests/plugin.xml b/bundles/org.eclipse.equinox.security.tests/plugin.xml new file mode 100644 index 000000000..50c2e3161 --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/plugin.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.2"?> +<plugin> + +</plugin> diff --git a/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/SecurityTestsActivator.java b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/SecurityTestsActivator.java new file mode 100644 index 000000000..c9294b90e --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/SecurityTestsActivator.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.internal.security.tests; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class SecurityTestsActivator implements BundleActivator { + + /** + * ID of this bundle + */ + public static final String PLUGIN_ID = "org.eclipse.equinox.security.tests"; + + private static SecurityTestsActivator singleton; + + private BundleContext bundleContext; + + /* + * Returns the singleton for this Activator. Callers should be aware that + * this will return nulCooll if the bundle is not active. + */ + public static SecurityTestsActivator getDefault() { + return singleton; + } + + public SecurityTestsActivator() { + super(); + } + + public void start(BundleContext context) throws Exception { + bundleContext = context; + singleton = this; + } + + public void stop(BundleContext context) throws Exception { + bundleContext = null; + singleton = null; + } + + public BundleContext getBundleContext() { + return bundleContext; + } + +} diff --git a/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/Base64Test.java b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/Base64Test.java new file mode 100644 index 000000000..05ec66746 --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/Base64Test.java @@ -0,0 +1,113 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.internal.security.tests.storage; + +import java.util.Random; +import junit.framework.*; +import org.eclipse.equinox.security.storage.EncodingUtils; + +public class Base64Test extends TestCase { + + /** + * Number of random-generated round trip tests to run + */ + final private static int RANDOM_ITERATIONS = 1000; + + final private static String decoded1 = "sample^^*"; + final private static String encoded1 = "c2FtcGxlXl4q"; + + final private static String decoded2 = "lazy frog jumped over sleeping dog"; + final private static String encoded2 = "bGF6eSBmcm9nIGp1bXBlZCBvdmVyIHNsZWVwaW5nIGRvZw=="; + + final private static byte[] decoded3 = {5, 0, 0, 12, 32, 1, 127, (byte) 0xFF}; + final private static String encoded3 = "BQAADCABf/8="; + + final private static byte[] decoded4 = new byte[0]; + final private static String encoded4 = ""; + + final private static String decoded5 = "1.234"; + final private static String encoded5 = "M\05S4y\tM\n\rzQ=\r\n"; // tests invalid characters + + public Base64Test() { + super(); + } + + public Base64Test(String name) { + super(name); + } + + /** + * Tests encoding using hand-calculated examples. + */ + public void testHandCoded() { + String encoded = EncodingUtils.encodeBase64(decoded1.getBytes()); + assertEquals(encoded1, encoded); + + byte[] bytes = EncodingUtils.decodeBase64(encoded2); + String decoded = new String(bytes); + assertEquals(decoded2, decoded); + + String testZeroes = EncodingUtils.encodeBase64(decoded3); + assertEquals(encoded3, testZeroes); + byte[] roundtripBytes = EncodingUtils.decodeBase64(testZeroes); + compareArrays(decoded3, roundtripBytes); + + byte[] bytesInvalidChars = EncodingUtils.decodeBase64(encoded5); + String decodedInvalidChars = new String(bytesInvalidChars); + assertEquals(decoded5, decodedInvalidChars); + } + + /** + * Tests edge conditions: null or empty arguments + */ + public void testEdge() { + assertNull(EncodingUtils.encodeBase64(null)); + assertNull(EncodingUtils.decodeBase64(null)); + + String encoded = EncodingUtils.encodeBase64(decoded4); + assertNotNull(encoded); + assertEquals(encoded4, encoded); + + byte[] decoded = EncodingUtils.decodeBase64(encoded); + compareArrays(decoded4, decoded); + } + + /** + * Tests round trip using large random sequences + */ + public void testRandom() { + Random generator = new Random(System.currentTimeMillis()); + + for (int i = 0; i < RANDOM_ITERATIONS; i++) { + // length of array is random in [100, 1000) + int length = 100 + generator.nextInt(900); + byte[] bytes = new byte[length]; + generator.nextBytes(bytes); + + // round trip + String encoded = EncodingUtils.encodeBase64(bytes); + byte[] decoded = EncodingUtils.decodeBase64(encoded); + compareArrays(bytes, decoded); + } + } + + private void compareArrays(byte[] array1, byte[] array2) { + assertNotNull(array1); + assertNotNull(array2); + assertEquals(array1.length, array2.length); + for (int i = 0; i < array1.length; i++) + assertEquals(array1[i], array2[i]); + } + + public static Test suite() { + return new TestSuite(Base64Test.class); + } +} diff --git a/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/DefaultPreferencesTest.java b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/DefaultPreferencesTest.java new file mode 100644 index 000000000..edc591a42 --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/DefaultPreferencesTest.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.internal.security.tests.storage; + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * Uses whatever default module is provided for the current installation. + */ +public class DefaultPreferencesTest extends SecurePreferencesTest { + + protected String getModuleID() { + return null; + } + + public static Test suite() { + return new TestSuite(DefaultPreferencesTest.class); + } +} diff --git a/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/DynamicPreferencesTest.java b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/DynamicPreferencesTest.java new file mode 100644 index 000000000..53013b347 --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/DynamicPreferencesTest.java @@ -0,0 +1,232 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.internal.security.tests.storage; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Map; +import junit.framework.Test; +import junit.framework.TestSuite; +import org.eclipse.core.tests.harness.BundleTestingHelper; +import org.eclipse.equinox.internal.security.storage.StorageUtils; +import org.eclipse.equinox.internal.security.tests.SecurityTestsActivator; +import org.eclipse.equinox.security.storage.ISecurePreferences; +import org.eclipse.equinox.security.storage.StorageException; +import org.osgi.framework.*; + +/** + * In those tests listener is used to synchronize with the asynchronous registry processing + * when bundle is added / removed. + */ +public class DynamicPreferencesTest extends StorageAbstractTest { + + final private static int MAX_TIME_PER_BUNDLE = 10000; // maximum time to wait for bundle event in milliseconds + public static final String TEST_FILES_ROOT = "Plugin_Testing/"; + + final private static String key = "password"; + final private static String unassignedKey = "unknown"; + final private static String value = "p[[pkknb#"; + final private static String defaultValue = "default"; + + final private static String key2 = "password2"; + final private static String value2 = "34534534535"; + + final private static String clearTextKey = "data"; + final private static String clearTextValue = "-> this should not be encrypted <-"; + + public DynamicPreferencesTest() { + super(); + } + + public DynamicPreferencesTest(String name) { + super(name); + } + + private void check(ISecurePreferences prefs) throws StorageException { + ISecurePreferences node1 = prefs.node("/abc"); + assertEquals(value, node1.get(key, defaultValue)); + assertEquals(defaultValue, node1.get(unassignedKey, defaultValue)); + } + + /** + * Test dynamic behavior while secure preferences remain in memory + */ + public void testDynamicMemory() throws Exception { + + Bundle bundle01 = null; + Bundle bundle02 = null; + try { + // add low priority module + bundle01 = installBundle("priority/low"); + // fill - this should use the "low" priority bundle + ISecurePreferences preferences = newPreferences(getStorageLocation(), getOptions()); + ISecurePreferences node1 = preferences.node("/abc"); + node1.put(key, value, true); + // add high priority module + bundle02 = installBundle("priority/high"); + // all should work well + check(preferences); + + // new elements added should go through the high priority module + // -> add entries on the same node as the first fill + node1.put(key2, value2, true); + node1.put(clearTextKey, clearTextValue, false); + // -> add entries on a different node + ISecurePreferences node2 = preferences.node("/abc/high"); + node2.put(key, value, true); + node2.put(clearTextKey, clearTextValue, false); + + // uninstall high priority module + if (uninstallBundle(bundle02)) + bundle02 = null; + + // check newly filled elements - should cause an exception + checkUnreadable(node1, key2); + checkUnreadable(node2, key); + + // the entry created with no encryption should read fine + assertEquals(clearTextValue, node1.get(clearTextKey, defaultValue)); + assertEquals(clearTextValue, node2.get(clearTextKey, defaultValue)); + // check original elements - should be able to read fine + check(preferences); + } finally { + // in case of exception in the process + if (bundle02 != null) + bundle02.uninstall(); + if (bundle01 != null) + bundle01.uninstall(); + } + } + + /** + * Test dynamic behavior with persisted secure preferences + */ + public void testDynamicPersisted() throws Exception { + URL location = getStorageLocation(); + assertNotNull(location); + + Bundle bundle01 = null; + Bundle bundle02 = null; + try { + { // block1: create and save using low priority module + bundle01 = installBundle("priority/low"); + // fill - this should use the "low" priority bundle + ISecurePreferences preferences = newPreferences(location, getOptions()); + ISecurePreferences node1 = preferences.node("/abc"); + node1.put(key, value, true); + preferences.flush(); + closePreferences(preferences); + } + + { // block2: add high priority module and reload + bundle02 = installBundle("priority/high"); + ISecurePreferences preferences = newPreferences(location, getOptions()); + // all should work well + check(preferences); + // new elements added should go through the high priority module + // -> add entries on the same node as the first fill + ISecurePreferences node1 = preferences.node("/abc"); + node1.put(key2, value2, true); + // -> add entries on a different node + ISecurePreferences node2 = preferences.node("/abc/high"); + node2.put(key, value, true); + preferences.flush(); + closePreferences(preferences); + } + + { // block3: uninstall high priority module and reload + if (uninstallBundle(bundle02)) + bundle02 = null; + ISecurePreferences preferences = newPreferences(location, getOptions()); + ISecurePreferences node1 = preferences.node("/abc"); + ISecurePreferences node2 = preferences.node("/abc/high"); + // check newly filled elements - should cause an exception + checkUnreadable(node1, key2); + checkUnreadable(node2, key); + // check original elements - should be able to read fine + check(preferences); + } + } finally { + // in case of exception in the process + if (bundle02 != null) + bundle02.uninstall(); + if (bundle01 != null) + bundle01.uninstall(); + StorageUtils.delete(location); + } + } + + protected void checkUnreadable(ISecurePreferences node, String keyToCheck) { + // check newly filled elements - should cause an exception + boolean exception = false; + try { + node.get(keyToCheck, defaultValue); + } catch (StorageException e) { + exception = true; + } + assertTrue(exception); + } + + protected Map getOptions() { + // Don't specify default password for those tests; they need to have + // password providers + return getOptions(null); + } + + /** + * Synchronizes to ensure bundle XML contribution has been processed + * before method returns. + */ + protected Bundle installBundle(String bundlePath) throws MalformedURLException, BundleException, IOException { + BundleContext bundleContext = SecurityTestsActivator.getDefault().getBundleContext(); + Bundle bundle = null; + WaitingRegistryListener listener = new WaitingRegistryListener(); + listener.register("org.eclipse.equinox.security.secureStorage"); + + try { + bundle = BundleTestingHelper.installBundle("0.1", bundleContext, TEST_FILES_ROOT + bundlePath); + BundleTestingHelper.refreshPackages(bundleContext, new Bundle[] {bundle}); + // synchronization: listener should receive 1 group of events + assertTrue(listener.waitFor(1, MAX_TIME_PER_BUNDLE) == 1); + } finally { + listener.unregister(); + } + return bundle; + } + + /** + * Synchronizes to ensure bundle XML contribution has been processed + * before method returns. + */ + protected boolean uninstallBundle(Bundle bundle) throws BundleException { + WaitingRegistryListener listener = new WaitingRegistryListener(); + listener.register("org.eclipse.equinox.security.secureStorage"); + try { + bundle.uninstall(); + bundle = null; + // synchronization: listener should receive 1 group of events + // There might be lots of active listeners by the time this test is run + // so give it some time - hence multiplication by 10 + assertTrue(listener.waitFor(1, 10 * MAX_TIME_PER_BUNDLE) == 1); + return true; + } finally { + listener.unregister(); + // in case of exception in the process + if (bundle != null) + bundle.uninstall(); + } + } + + public static Test suite() { + return new TestSuite(DynamicPreferencesTest.class); + } +} diff --git a/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/HighPriorityModule.java b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/HighPriorityModule.java new file mode 100644 index 000000000..bee36a25b --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/HighPriorityModule.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.internal.security.tests.storage; + +import javax.crypto.spec.PBEKeySpec; +import org.eclipse.equinox.security.storage.provider.IPreferencesContainer; +import org.eclipse.equinox.security.storage.provider.PasswordProvider; + +/** + * Password provider which is to be added at a with relatively high priority. + */ +public class HighPriorityModule extends PasswordProvider { + + public final static PBEKeySpec PASSWORD = new PBEKeySpec("HighPriorityPassword".toCharArray()); + + public PBEKeySpec login(IPreferencesContainer controller) { + return PASSWORD; + } + + public boolean changePassword(Exception e, IPreferencesContainer container) { + return false; + } + + public void logout(IPreferencesContainer container) { + // noting to do + } + +} diff --git a/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/LowPriorityModule.java b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/LowPriorityModule.java new file mode 100644 index 000000000..157391746 --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/LowPriorityModule.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.internal.security.tests.storage; + +import javax.crypto.spec.PBEKeySpec; +import org.eclipse.equinox.security.storage.provider.IPreferencesContainer; +import org.eclipse.equinox.security.storage.provider.PasswordProvider; + +/** + * Password provider which is to be added at a with relatively low priority. + */ +public class LowPriorityModule extends PasswordProvider { + + public final static PBEKeySpec PASSWORD = new PBEKeySpec("LowPriorityPassword".toCharArray()); + + public PBEKeySpec login(IPreferencesContainer controller) { + return PASSWORD; + } + + public boolean changePassword(Exception e, IPreferencesContainer container) { + return false; + } + + public void logout(IPreferencesContainer container) { + // noting to do + } +} diff --git a/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/ManualTest.java b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/ManualTest.java new file mode 100644 index 000000000..c53e40fbe --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/ManualTest.java @@ -0,0 +1,119 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.internal.security.tests.storage; + +import java.io.IOException; +import java.security.Provider; +import java.security.Security; +import java.util.*; +import junit.framework.*; +import org.eclipse.equinox.security.storage.*; +import org.eclipse.equinox.security.storage.provider.IProviderHints; + +/** + * This is a semi-manual test; expected to be run with modules requiring + * UI interactions. Set configuration before executing this so that desired + * storage module is selected. + */ +public class ManualTest extends TestCase { + + static private final String JAVA_MODULE_ID = "org.eclipse.equinox.security.javaCrypt"; //$NON-NLS-1$ + + public ManualTest() { + super(); + } + + public ManualTest(String name) { + super(name); + } + + final private String passwordSample = "uYTIU689_~@@/"; + final private String loginSample = "cheburashka"; + + public void testBasic() { + + // Note that this skips Alg.Alias.Cipher.ABC + // few aliases are useful and it will be harder to separate human-redable + // aliases from internal ones + Provider[] providers = Security.getProviders(); + for (int i = 0; i < providers.length; i++) { + for (Iterator j = providers[i].entrySet().iterator(); j.hasNext();) { + Map.Entry entry = (Map.Entry) j.next(); + String key = (String) entry.getKey(); + if (key == null) + continue; + if (key.indexOf(' ') != -1) // skips "[Cipher.ABC SupportedPaddings]", etc. + continue; + if (key.startsWith("Cipher.")) { + String cipher = key.substring(7); // length("Cipher.") + System.out.println("[cypher] " + cipher); + } + if (key.startsWith("SecretKeyFactory.")) { + String keyFactory = key.substring(17); // length("SecretKeyFactory.") + System.out.println("[keyFactory] " + keyFactory); + } + } + + /* + * In theory, all those ciphers support "Raw" key factory format - the SecretKeyFactory + * algorithm should be really irrelevant. That said, Blowfish would not work with JavaCrypt + * - so need to manually test all and exclude those that we know not supported + * (or provide a roundtrip test - if it fails, exclude the value) + [keyFactory] PBKDF2WithHmacSHA1 + [keyFactory] DES + [keyFactory] DESede + [keyFactory] PBE + [keyFactory] PBEWithSHA1AndRC2_40 + [keyFactory] PBEWithSHA1AndDESede + [keyFactory] PBEWithMD5AndTripleDES + [keyFactory] PBEWithMD5AndDES + + + [cypher] DES + [cypher] Blowfish + [cypher] RC2 + [cypher] AES + [cypher] DESede + [cypher] PBEWithMD5AndDES + [cypher] PBEWithMD5AndTripleDES + [cypher] ARCFOUR + [cypher] RSA + [cypher] AESWrap + [cypher] PBEWithSHA1AndRC2_40 + [cypher] PBEWithSHA1AndDESede + [cypher] DESedeWrap + + http://java.sun.com/javase/6/docs/technotes/guides/security/StandardNames.html#SecretKeyFactory + http://java.sun.com/j2se/1.4.2/docs/guide/security/jce/JCERefGuide.html#AppA + */ + } + } + + /** + * Manual test for Java module to see password prompt functionality + */ + public void testJavaModule() throws IOException, StorageException { + // manual test for the Java module + Map options = new HashMap(1); + options.put(IProviderHints.REQUIRED_MODULE_ID, JAVA_MODULE_ID); + ISecurePreferences storage = SecurePreferencesFactory.open(null, options); + ISecurePreferences node = storage.node("/cvs/account1"); + node.put("login", loginSample, true); + node.put("password", passwordSample, true); + assertEquals(loginSample, node.get("login", null)); + assertEquals(passwordSample, node.get("password", null)); + } + + public static Test suite() { + return new TestSuite(ManualTest.class); + } + +} diff --git a/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/SecurePreferencesTest.java b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/SecurePreferencesTest.java new file mode 100644 index 000000000..0581ad67c --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/SecurePreferencesTest.java @@ -0,0 +1,506 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.internal.security.tests.storage; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Map; +import junit.framework.Test; +import junit.framework.TestSuite; +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.equinox.internal.security.storage.SecurePreferencesRoot; +import org.eclipse.equinox.internal.security.storage.SecurePreferencesWrapper; +import org.eclipse.equinox.internal.security.tests.SecurityTestsActivator; +import org.eclipse.equinox.security.storage.ISecurePreferences; +import org.eclipse.equinox.security.storage.StorageException; +import org.osgi.framework.BundleContext; + +abstract public class SecurePreferencesTest extends StorageAbstractTest { + + final private static String sampleLocation = "/SecurePrefsSample/1/secure_storage.equinox"; + + final private static String path1 = "/test/abc"; + final private static String path2 = "/test/cvs/eclipse.org"; + final private static String path3 = "/test/cvs/eclipse.org/account1"; + + final private static String key = "password"; + final private static String unassignedKey = "unknown"; + final private static String value = "p[[pkknb#"; + final private static String defaultValue = "default"; + + final private static String secondKey = "/ sdfdsf / sf"; + final private static String secondValue = "one"; + + final private static String clearTextKey = "data"; + final private static String clearTextValue = "-> this should not be encrypted <-"; + + public SecurePreferencesTest() { + super(); + } + + public SecurePreferencesTest(String name) { + super(name); + } + + protected Map getOptions() { + // Note that if the default password value below is modified, + // the sample storage file needs to be regenerated. + return getOptions("password1"); + } + + private void fill(ISecurePreferences preferences) throws StorageException { + preferences.put(key, value, true); // puts entry at the root node + + ISecurePreferences node1 = preferences.node(path1); // puts entry at the root node + 1 + node1.put(key, value, true); + node1.put(clearTextKey, clearTextValue, false); + + ISecurePreferences node2 = preferences.node(path2); // puts entry at the root node + 2 + node2.put(key, value, true); + node2.put(secondKey, secondValue, true); + + ISecurePreferences node3 = preferences.node(path3); // puts entry at the root node + 3 + node3.put(key, value, true); + node3.put(secondKey, secondValue, true); + node3.put(clearTextKey, clearTextValue, false); + + node2.remove(secondKey); + + assertTrue(isModified(node2)); + assertTrue(isModified(preferences)); + } + + /** + * The method reaches into internal classes to check if modified flag is set on secure + * preference data. + */ + private boolean isModified(ISecurePreferences node) { + SecurePreferencesRoot rootData = ((SecurePreferencesWrapper) node).getContainer().getRootData(); + return rootData.isModified(); + } + + private void check(ISecurePreferences preferences) throws StorageException { + assertFalse(isModified(preferences)); + assertEquals(value, preferences.get(key, defaultValue)); // checks entry at the root node + assertEquals(defaultValue, preferences.get(unassignedKey, defaultValue)); + + ISecurePreferences node1 = preferences.node(path1); // checks entry at the root node + 1 + assertFalse(isModified(node1)); + assertEquals(value, node1.get(key, defaultValue)); + assertEquals(defaultValue, node1.get(unassignedKey, defaultValue)); + assertEquals(clearTextValue, node1.get(clearTextKey, defaultValue)); + + ISecurePreferences node2 = preferences.node(path2); // checks entry at the root node + 2 + assertFalse(isModified(node2)); + assertEquals(value, node2.get(key, defaultValue)); + assertNull(node2.get(secondKey, null)); + assertEquals(defaultValue, node2.get(unassignedKey, defaultValue)); + + ISecurePreferences node3 = preferences.node(path3); // checks entry at the root node + 3 + assertFalse(isModified(node3)); + assertEquals(value, node3.get(key, defaultValue)); + assertEquals(secondValue, node3.get(secondKey, defaultValue)); + assertEquals(defaultValue, node3.get(unassignedKey, defaultValue)); + assertEquals(clearTextValue, node3.get(clearTextKey, defaultValue)); + + String[] leafKeys = node3.keys(); + assertNotNull(leafKeys); + assertEquals(leafKeys.length, 3); + boolean order1 = secondKey.equals(leafKeys[0]) && key.equals(leafKeys[1]); + boolean order2 = secondKey.equals(leafKeys[1]) && key.equals(leafKeys[0]); + assertTrue(order1 || order2); + } + + /** + * Basic test to fill / read Preferences implementation. Also tests removal of a value + * and Preferences#keys(). + */ + public void testPreferences() throws IOException, StorageException { + URL location = getStorageLocation(); + assertNotNull(location); + { // block1: fill and save + ISecurePreferences preferences = newPreferences(getStorageLocation(), getOptions()); + fill(preferences); + preferences.flush(); + closePreferences(preferences); + } + { // block2: re-load and check + ISecurePreferences preferences = newPreferences(getStorageLocation(), getOptions()); + check(preferences); + } + } + + /** + * Test relative names, absolute names, and children names + * @throws StorageException + */ + public void testNames() throws IOException, StorageException { + ISecurePreferences preferences = newPreferences(getStorageLocation(), getOptions()); + fill(preferences); + + // check names for the root node + assertNull(preferences.name()); + assertEquals("/", preferences.absolutePath()); + + String[] childrenNames = preferences.node("test").childrenNames(); + assertNotNull(childrenNames); + + boolean order1 = "abc".equals(childrenNames[0]) && "cvs".equals(childrenNames[1]); + boolean order2 = "abc".equals(childrenNames[1]) && "cvs".equals(childrenNames[0]); + assertTrue(order1 || order2); + assertEquals(childrenNames.length, 2); + + // check names for the root node + 1 + ISecurePreferences node1 = preferences.node("test/cvs"); + assertEquals("cvs", node1.name()); + assertEquals("/test/cvs", node1.absolutePath()); + + String[] childrenNames1 = node1.childrenNames(); + assertNotNull(childrenNames1); + assertEquals(childrenNames1.length, 1); + assertEquals("eclipse.org", childrenNames1[0]); + + // check names for the root node + 2 + ISecurePreferences node2 = node1.node("eclipse.org"); + assertEquals("eclipse.org", node2.name()); + assertEquals("/test/cvs/eclipse.org", node2.absolutePath()); + + String[] childrenNames2 = node2.childrenNames(); + assertNotNull(childrenNames2); + assertEquals(childrenNames2.length, 1); + assertEquals("account1", childrenNames2[0]); + + // check names for the leaf node + ISecurePreferences node3 = node2.node("account1"); + assertEquals("account1", node3.name()); + assertEquals("/test/cvs/eclipse.org/account1", node3.absolutePath()); + + String[] childrenNames3 = node3.childrenNames(); + assertNotNull(childrenNames3); + assertEquals(childrenNames3.length, 0); + } + + /** + * Test node existence, resolution: parent -> child; child -> parent, + * compare absolute and relative paths. + */ + public void testNodeResolution() throws IOException, StorageException { + ISecurePreferences preferences = newPreferences(getStorageLocation(), getOptions()); + fill(preferences); + + // absolute paths and node existence: + assertTrue(preferences.nodeExists(null)); + ISecurePreferences nodeRoot = preferences.node(null); + assertNotNull(nodeRoot); + + assertTrue(preferences.nodeExists("/test/cvs")); + assertFalse(preferences.nodeExists("/test/nonExistent")); + ISecurePreferences node1 = preferences.node("/test/cvs"); + assertNotNull(node1); + + assertTrue(preferences.nodeExists("/test/cvs/eclipse.org")); + assertFalse(preferences.nodeExists("/test/nonExistent/cvs")); + assertFalse(preferences.nodeExists("/test/cvs/nonExistent")); + ISecurePreferences node2 = preferences.node("/test/cvs/eclipse.org"); + assertNotNull(node2); + + assertTrue(preferences.nodeExists("/test/cvs/eclipse.org/account1")); + assertFalse(preferences.nodeExists("/test/cvs/nonExistent/cvs")); + ISecurePreferences node3 = preferences.node("/test/cvs/eclipse.org/account1"); + assertNotNull(node3); + + // relative paths, parents and compare to results from absolute paths: + assertNull(preferences.parent()); + assertEquals(nodeRoot, preferences); + + assertTrue(nodeRoot.nodeExists("test/cvs")); + assertFalse(nodeRoot.nodeExists("test/nonExistent")); + ISecurePreferences relativeNode1 = nodeRoot.node("test/cvs"); + assertNotNull(relativeNode1); + assertEquals(node1, relativeNode1); + assertEquals(nodeRoot, relativeNode1.parent().parent()); + + assertTrue(relativeNode1.nodeExists("eclipse.org")); + assertFalse(relativeNode1.nodeExists("nonExistent")); + ISecurePreferences relativeNode2 = relativeNode1.node("eclipse.org"); + assertNotNull(relativeNode2); + assertEquals(node2, relativeNode2); + assertEquals(node1, relativeNode2.parent()); + + assertTrue(relativeNode2.nodeExists("account1")); + assertFalse(relativeNode2.nodeExists("nonExistent")); + ISecurePreferences relativeNode3 = relativeNode2.node("account1"); + assertNotNull(relativeNode3); + assertEquals(node3, relativeNode3); + assertEquals(relativeNode2, relativeNode3.parent()); + + //check contents to make sure that traversing did not add and new children + preferences.flush(); + check(preferences); + } + + /** + * Tests node removal. + * @throws StorageException + */ + public void testNodeRemoval() throws IOException, StorageException { + URL location = getStorageLocation(); + assertNotNull(location); + + { // block1: initial fill and check + ISecurePreferences preferences = newPreferences(location, getOptions()); + fill(preferences); + + ISecurePreferences nodeToRemove = preferences.node("/test/cvs/eclipse.org"); + assertNotNull(nodeToRemove); + nodeToRemove.removeNode(); + + assertFalse(preferences.nodeExists("/test/cvs/eclipse.org/account1")); + assertFalse(preferences.nodeExists("/test/cvs/eclipse.org")); + + preferences.flush(); + closePreferences(preferences); + } + + { // block2: reload + ISecurePreferences preferences = newPreferences(location, getOptions()); + assertTrue(preferences.nodeExists(null)); + assertFalse(preferences.nodeExists("/test/cvs/eclipse.org/account1")); + assertFalse(preferences.nodeExists("/test/cvs/eclipse.org")); + + ISecurePreferences node = preferences.node("/test/cvs"); + String[] children = node.childrenNames(); + assertNotNull(children); + assertEquals(children.length, 0); + + // test in-memory removal + ISecurePreferences node2 = preferences.node(null).node("test"); + String[] children2 = node2.childrenNames(); + assertNotNull(children2); + assertEquals(children2.length, 2); + + ISecurePreferences nodeToRemove2 = node2.node("/test/cvs"); + assertNotNull(nodeToRemove2); + nodeToRemove2.removeNode(); + String[] children3 = node2.childrenNames(); + assertNotNull(children3); + assertEquals(children3.length, 1); + assertEquals("abc", children3[0]); + + preferences.removeNode(); // check the special case - removal of the root node + boolean exception = false; + try { + preferences.nodeExists(null); + } catch (IllegalStateException e) { + exception = true; + } + assertTrue(exception); + } + } + + /** + * Tests validation of node paths. + * @throws Throwable + */ + public void testPathValidation() throws Throwable { + ISecurePreferences preferences = newPreferences(getStorageLocation(), getOptions()); + boolean exception = false; + try { + preferences.node("/test/cvs/eclipse.org//account1"); + } catch (IllegalArgumentException e) { + exception = true; + } + assertTrue(exception); + + exception = false; + try { + preferences.node("/test/cvs/eclipse.org/"); + } catch (IllegalArgumentException e) { + exception = true; + } + assertTrue(exception); + + exception = false; + try { + preferences.node("/test/cvs/eclipse.org//"); + } catch (IllegalArgumentException e) { + exception = true; + } + assertTrue(exception); + } + + /** + * Tests URL validation. + */ + public void testLocation() throws MalformedURLException { + URL invalidURL = new URL("http", "eclipse.org", "testEquinoxFile"); + boolean exception = false; + try { + newPreferences(invalidURL, getOptions()); + } catch (IOException e) { + exception = true; + } + assertTrue(exception); + } + + /** + * Tests data types + * @throws StorageException + * @throws IOException + * @throws MalformedURLException + */ + public void testDataTypes() throws StorageException, MalformedURLException, IOException { + ISecurePreferences preferences = newPreferences(getStorageLocation(), getOptions()); + + ISecurePreferences node = preferences.node("/test"); + byte[] testArray = new byte[] {0, 4, 12, 75, 84, 12, 1, (byte) 0xFF}; + + boolean encrypt = true; + + node.putBoolean("trueBoolean", true, encrypt); + node.putBoolean("falseBoolean", false, encrypt); + + node.putInt("oneInteger", 1, encrypt); + node.putLong("twoLong", 2l, encrypt); + node.putFloat("threeFloat", 3.12f, encrypt); + node.putDouble("fourDouble", 4.1d, encrypt); + + assertTrue(node.getBoolean("trueBoolean", false)); + assertFalse(node.getBoolean("falseBoolean", true)); + assertTrue(node.getBoolean("unknownBoolean", true)); + assertFalse(node.getBoolean("unknownBoolean", false)); + + assertEquals(node.getInt("oneInteger", 0), 1); + assertEquals(node.getInt("unknownInteger", 5), 5); + + assertEquals(node.getLong("twoLong", 0), 2l); + assertEquals(node.getLong("unknownLong", 5), 5l); + + assertEquals(node.getFloat("threeFloat", 0f), 3.12f, 0); + assertEquals(node.getFloat("unknownFloat", 1.23f), 1.23f, 0); + + assertEquals(node.getDouble("fourDouble", 0), 4.1d, 0); + assertEquals(node.getDouble("unknownDouble", 1.23d), 1.23d, 0); + + node.putByteArray("fiveArray", testArray, encrypt); + byte[] array = node.getByteArray("fiveArray", null); + compareArrays(testArray, array); + } + + /** + * Tests corrupted encrypted data. + */ + public void testIncorrectData() throws IOException { + URL location = getFilePath(sampleLocation); + // Same default password as in the SecurePreferencesTest.getOptions() - same note + // on regenerating data file. + ISecurePreferences preferences = newPreferences(location, getOptions("password1")); + try { + ISecurePreferences node = preferences.node("/abc"); + boolean exception = false; + try { + node.get("password1", "default"); + } catch (StorageException e) { + assertEquals(StorageException.DECRYPTION_ERROR, e.getErrorCode()); + exception = true; + } + assertTrue(exception); + + exception = false; + try { + node.get("password2", "default"); + } catch (StorageException e) { + assertEquals(StorageException.DECRYPTION_ERROR, e.getErrorCode()); + exception = true; + } + assertTrue(exception); + } finally { + // make sure we won't try to delete it + closePreferences(preferences); + } + } + + /** + * Tests incorrect passwords + */ + public void testIncorrectPassword() throws IOException { + URL location = getFilePath(sampleLocation); + Map options = getOptions("wrong"); + ISecurePreferences preferences = newPreferences(location, options); + try { + ISecurePreferences node = preferences.node("/cvs/eclipse.org"); + boolean exception = false; + try { + node.get("password", "default"); + } catch (StorageException e) { + assertEquals(StorageException.DECRYPTION_ERROR, e.getErrorCode()); + exception = true; + } + assertTrue(exception); + } finally { + // make sure we won't try to delete it + closePreferences(preferences); + } + } + + /** + * Tests incorrect or unexpected module specifications + */ + public void testModules() throws IOException { + URL location = getFilePath(sampleLocation); + ISecurePreferences preferences = newPreferences(location, getOptions(null)); + try { + ISecurePreferences node = preferences.node("/cvs/eclipse.org/account1"); + + // non-existent module + boolean exception = false; + try { + node.get("password1", "default"); + } catch (StorageException e) { + assertEquals(StorageException.NO_SECURE_MODULE, e.getErrorCode()); + exception = true; + } + assertTrue(exception); + + // empty module and no default password + exception = false; + try { + node.get("password2", "default"); + } catch (StorageException e) { + assertEquals(StorageException.DECRYPTION_ERROR, e.getErrorCode()); + exception = true; + } + assertTrue(exception); + } finally { + // make sure we won't try to delete it + closePreferences(preferences); + } + } + + private void compareArrays(byte[] array1, byte[] array2) { + assertNotNull(array1); + assertNotNull(array2); + assertEquals(array1.length, array2.length); + for (int i = 0; i < array1.length; i++) + assertEquals(array1[i], array2[i]); + } + + private URL getFilePath(String path) throws IOException { + BundleContext bundleContext = SecurityTestsActivator.getDefault().getBundleContext(); + URL url = bundleContext.getBundle().getEntry(path); + return FileLocator.toFileURL(url); + } + + public static Test suite() { + return new TestSuite(SecurePreferencesTest.class); + } +} diff --git a/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/SlashEncodeTest.java b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/SlashEncodeTest.java new file mode 100644 index 000000000..f33d6c82a --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/SlashEncodeTest.java @@ -0,0 +1,132 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.internal.security.tests.storage; + +import java.io.IOException; +import java.net.URL; +import java.util.Map; +import junit.framework.Test; +import junit.framework.TestSuite; +import org.eclipse.equinox.internal.security.storage.StorageUtils; +import org.eclipse.equinox.security.storage.*; +import org.osgi.service.prefs.BackingStoreException; + +public class SlashEncodeTest extends StorageAbstractTest { + + public SlashEncodeTest() { + super(); + } + + public SlashEncodeTest(String name) { + super(name); + } + + final private static String[] decodedSlash = {"root", "ro/ot", "/root", "root/", "ro/ot/me", "ro//ot"}; + final private static String[] encodedSlash = {"root", "ro\\2fot", "\\2froot", "root\\2f", "ro\\2fot\\2fme", "ro\\2f\\2fot"}; + + final private static String[] decodedBackSlash = {"ro\\ot", "\\root", "root\\", "ro\\ot\\me", "ro\\\\ot"}; + final private static String[] encodedBackSlash = {"ro\\5cot", "\\5croot", "root\\5c", "ro\\5cot\\5cme", "ro\\5c\\5cot"}; + + final private static String[] decodedMixSlash = {"r/o\\ot", "r\\o/ot", "/\\root", "root\\/", "\\5cro\\2f ot"}; + final private static String[] encodedMixSlash = {"r\\2fo\\5cot", "r\\5co\\2fot", "\\2f\\5croot", "root\\5c\\2f", "\\5c5cro\\5c2f ot"}; + + /** + * Tests forward slash + */ + public void testForwardSlash() { + for (int i = 0; i < decodedSlash.length; i++) { + String tmp = EncodingUtils.encodeSlashes(decodedSlash[i]); + assertEquals(encodedSlash[i], tmp); + assertEquals(decodedSlash[i], EncodingUtils.decodeSlashes(tmp)); + } + } + + /** + * Tests backward slash + */ + public void testBackwardSlash() { + for (int i = 0; i < decodedBackSlash.length; i++) { + String tmp = EncodingUtils.encodeSlashes(decodedBackSlash[i]); + assertEquals(encodedBackSlash[i], tmp); + assertEquals(decodedBackSlash[i], EncodingUtils.decodeSlashes(tmp)); + } + } + + /** + * Tests mixed slashes + */ + public void testMixSlash() { + for (int i = 0; i < decodedMixSlash.length; i++) { + String tmp = EncodingUtils.encodeSlashes(decodedMixSlash[i]); + assertEquals(encodedMixSlash[i], tmp); + assertEquals(decodedMixSlash[i], EncodingUtils.decodeSlashes(tmp)); + } + } + + /** + * Tests edge conditions: null or empty arguments + */ + public void testEdge() { + assertNull(EncodingUtils.encodeSlashes(null)); + assertNull(EncodingUtils.decodeSlashes(null)); + + String encoded = EncodingUtils.encodeSlashes(""); + assertNotNull(encoded); + assertEquals("", encoded); + } + + protected Map getOptions() { + // Password value really doesn't matter here; we specify it to avoid + // triggering UI elements in case default password provider has the + // highest priority in the tested configuration + return getOptions("password1"); + } + + /** + * Tests preferences node name using slash encoding + * @throws IOException + * @throws BackingStoreException + * @throws + */ + public void testPreferencesWithSlashes() throws IOException, StorageException { + URL location = getStorageLocation(); + assertNotNull(location); + { // block1: fill and test in memory + ISecurePreferences preferences = newPreferences(location, getOptions()); + String safePath = EncodingUtils.encodeSlashes("ro/ot"); + ISecurePreferences node = preferences.node(safePath); + node.put("password", "test", true); + + assertFalse(preferences.nodeExists("ro")); + assertFalse(preferences.nodeExists("ro/ot")); + assertTrue(preferences.nodeExists(safePath)); + + preferences.flush(); + closePreferences(preferences); + } + + { // block2: reload and check + ISecurePreferences preferences = newPreferences(location, getOptions()); + String children[] = preferences.childrenNames(); + assertNotNull(children); + assertEquals(children.length, 1); + ISecurePreferences nodeRet = preferences.node(children[0]); + String absolutePath = EncodingUtils.decodeSlashes(nodeRet.absolutePath()); + assertEquals("/ro/ot", absolutePath); + assertEquals("test", nodeRet.get("password", null)); + } + StorageUtils.delete(location); + } + + public static Test suite() { + return new TestSuite(SlashEncodeTest.class); + } +} diff --git a/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/StorageAbstractTest.java b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/StorageAbstractTest.java new file mode 100644 index 000000000..424ed8532 --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/StorageAbstractTest.java @@ -0,0 +1,104 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.internal.security.tests.storage; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.*; +import javax.crypto.spec.PBEKeySpec; +import junit.framework.TestCase; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.tests.harness.FileSystemHelper; +import org.eclipse.equinox.internal.security.storage.*; +import org.eclipse.equinox.security.storage.ISecurePreferences; +import org.eclipse.equinox.security.storage.SecurePreferencesFactory; +import org.eclipse.equinox.security.storage.provider.IProviderHints; + +/** + * Temp directory is used for storage. + */ +public class StorageAbstractTest extends TestCase { + + final protected String defaultFileName = "secure_storage_test.equinox"; + + private List openPreferences = new ArrayList(5); // <ISecurePreferences> + + public StorageAbstractTest() { + super(); + } + + public StorageAbstractTest(String name) { + super(name); + } + + protected String getModuleID() { + return null; + } + + protected void tearDown() throws Exception { + synchronized (openPreferences) { + for (Iterator i = openPreferences.iterator(); i.hasNext();) { + ISecurePreferences root = (ISecurePreferences) i.next(); + SecurePreferencesMapper.close((((SecurePreferencesWrapper) root).getContainer().getRootData())); + URL location = ((SecurePreferencesWrapper) root).getContainer().getLocation(); + StorageUtils.delete(location); + } + } + super.tearDown(); + } + + protected ISecurePreferences newPreferences(URL location, Map options) throws IOException { + synchronized (openPreferences) { + ISecurePreferences result = SecurePreferencesFactory.open(location, options); + openPreferences.add(result); + return result; + } + } + + protected void closePreferences(ISecurePreferences root) { + synchronized (openPreferences) { + for (Iterator i = openPreferences.iterator(); i.hasNext();) { + ISecurePreferences element = (ISecurePreferences) i.next(); + if (element.equals(root)) { + SecurePreferencesMapper.close((((SecurePreferencesWrapper) root).getContainer().getRootData())); + i.remove(); + } + } + } + } + + protected Map getOptions(String defaultPassword) { + Map options = new HashMap(); + + if (defaultPassword != null) { + PBEKeySpec password = new PBEKeySpec(defaultPassword.toCharArray()); + options.put(IProviderHints.DEFAULT_PASSWORD, password); + } + + String requiredID = getModuleID(); + if (requiredID != null) + options.put(IProviderHints.REQUIRED_MODULE_ID, requiredID); + + options.put(IProviderHints.PROMPT_USER, new Boolean(false)); + return options; + } + + /** + * Might consider switching to configuration location. + * @throws MalformedURLException + */ + protected URL getStorageLocation() throws MalformedURLException { + IPath tempDir = FileSystemHelper.getTempDir(); + tempDir = tempDir.append(defaultFileName); + return tempDir.toFile().toURL(); + } +} diff --git a/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/WaitingRegistryListener.java b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/WaitingRegistryListener.java new file mode 100644 index 000000000..0c6480140 --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/WaitingRegistryListener.java @@ -0,0 +1,189 @@ +/******************************************************************************* + * Copyright (c) 2007, 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.internal.security.tests.storage; + +import java.util.ArrayList; +import java.util.List; +import junit.framework.Assert; +import org.eclipse.core.runtime.*; + +/** + * Allows test cases to wait for the extension registry notifications. + * This listener checks navigability to related elements from extensions. + * @since 3.4 + * Copied from runtime tests + */ +public class WaitingRegistryListener extends Assert implements IRegistryEventListener { + + final static long MIN_WAIT_TIME = 100; // minimum wait time in milliseconds + + private List extensionIDs; // String[] + private List extPointIDs; // String[] + + private volatile boolean added; + private volatile boolean removed; + private volatile int callbacks; + + private String extPointId; + + public WaitingRegistryListener() { + reset(); + } + + public void register(String id) { + extPointId = id; // used for verification in callbacks + if (extPointId != null) + RegistryFactory.getRegistry().addListener(this, extPointId); + else + RegistryFactory.getRegistry().addListener(this); + } + + public void unregister() { + RegistryFactory.getRegistry().removeListener(this); + } + + public void reset() { + extensionIDs = null; + extPointIDs = null; + added = false; + removed = false; + callbacks = 0; + } + + public boolean isAdded() { + return added; + } + + public boolean isRemoved() { + return removed; + } + + public synchronized String[] extensionsReceived(long timeout) { + if (extensionIDs != null) + return (String[]) extensionIDs.toArray(new String[extensionIDs.size()]); + try { + wait(timeout); + } catch (InterruptedException e) { + // who cares? + } + if (extensionIDs == null) + return null; + return (String[]) extensionIDs.toArray(new String[extensionIDs.size()]); + } + + public synchronized String[] extPointsReceived(long timeout) { + if (extPointIDs != null) + return (String[]) extPointIDs.toArray(new String[extPointIDs.size()]); + try { + wait(timeout); + } catch (InterruptedException e) { + // who cares? + } + if (extPointIDs == null) + return null; + return (String[]) extPointIDs.toArray(new String[extPointIDs.size()]); + } + + public synchronized int waitFor(int events, long maxTimeout) { + long startTime = System.currentTimeMillis(); + try { + while (callbacks < events) { + long currentTime = System.currentTimeMillis(); + long alreadyWaited = currentTime - startTime; + if (alreadyWaited < 0) + alreadyWaited = 0; // just in case if system timer is not very precise + long timeToWait = maxTimeout - alreadyWaited; + if (timeToWait <= 0) { + wait(MIN_WAIT_TIME); // give it a last chance + break; // timed out + } + wait(timeToWait); + } + } catch (InterruptedException e) { + // breaks the cycle + } + return callbacks; + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IRegistryEventListener#added(org.eclipse.core.runtime.IExtension[]) + */ + synchronized public void added(IExtension[] extensions) { + extensionsToString(extensions); + added = true; + callbacks++; + notify(); + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IRegistryEventListener#removed(org.eclipse.core.runtime.IExtension[]) + */ + synchronized public void removed(IExtension[] extensions) { + extensionsToString(extensions); + removed = true; + callbacks++; + notify(); + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IRegistryEventListener#added(org.eclipse.core.runtime.IExtensionPoint[]) + */ + synchronized public void added(IExtensionPoint[] extensionPoints) { + extPointsToString(extensionPoints); + added = true; + callbacks++; + notify(); + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IRegistryEventListener#removed(org.eclipse.core.runtime.IExtensionPoint[]) + */ + synchronized public void removed(IExtensionPoint[] extensionPoints) { + extPointsToString(extensionPoints); + removed = true; + callbacks++; + notify(); + } + + private void extensionsToString(IExtension[] extensions) { + extensionIDs = new ArrayList(extensions.length); + for (int i = 0; i < extensions.length; i++) { + IExtension extension = extensions[i]; + extensionIDs.add(extension.getUniqueIdentifier()); + + // test navigation: to extension point + String ownerId = extension.getExtensionPointUniqueIdentifier(); + if (extPointId != null) + assertTrue(extPointId.equals(ownerId)); + // test navigation: all children + assertTrue(validContents(extension.getConfigurationElements())); + } + } + + private boolean validContents(IConfigurationElement[] children) { + if (children == null) + return true; + for (int i = 0; i < children.length; i++) { + if (!children[i].isValid()) + return false; + if (!validContents(children[i].getChildren())) + return false; + } + return true; + } + + private void extPointsToString(IExtensionPoint[] extensionPoints) { + extPointIDs = new ArrayList(extensionPoints.length); + for (int i = 0; i < extensionPoints.length; i++) + extPointIDs.add(extensionPoints[i].getUniqueIdentifier()); + } + +} diff --git a/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/WinPreferencesTest.java b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/WinPreferencesTest.java new file mode 100644 index 000000000..d98fb092a --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/WinPreferencesTest.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.internal.security.tests.storage; + +import java.util.Map; +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * Tests Windows module, if available. + * + */ +public class WinPreferencesTest extends SecurePreferencesTest { + + /** + * Unique ID of the Windows module. + */ + static private final String WIN_MODULE_ID = "org.eclipse.equinox.security.WindowsPasswordProvider"; //$NON-NLS-1$ + + protected String getModuleID() { + return WIN_MODULE_ID; + } + + public static Test suite() { + return new TestSuite(WinPreferencesTest.class); + } + + protected Map getOptions() { + // Don't specify default password when testing specific password provider + return getOptions(null); + } +} diff --git a/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/security/tests/AllSecurityTests.java b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/security/tests/AllSecurityTests.java new file mode 100644 index 000000000..72deaaaad --- /dev/null +++ b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/security/tests/AllSecurityTests.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.security.tests; + +import junit.framework.*; +import org.eclipse.equinox.internal.security.tests.SecurityTestsActivator; +import org.eclipse.equinox.internal.security.tests.storage.*; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; + +/** + * As tests use registry listeners, UI listeners might cause tests to time out and fail. + * As such this tests should be run in a headless mode. + */ +public class AllSecurityTests extends TestCase { + + final private static String WIN_BUNDLE = "org.eclipse.equinox.security.win32.x86"; + + public AllSecurityTests() { + super(null); + } + + public AllSecurityTests(String name) { + super(name); + } + + public static Test suite() { + TestSuite suite = new TestSuite(AllSecurityTests.class.getName()); + + // stand-alone test for Base64 + suite.addTest(Base64Test.suite()); + // test node names encoding ("slash eliminator") + suite.addTest(SlashEncodeTest.suite()); + // tests secure Preferences functionality using default provider + suite.addTest(DefaultPreferencesTest.suite()); + // check dynamic additions / removals + suite.addTest(DynamicPreferencesTest.suite()); + + // testing Windows-specific path should only be attempted if bundle is resolved + if (hasBundle(WIN_BUNDLE)) + suite.addTest(WinPreferencesTest.suite()); + + return suite; + } + + static private boolean hasBundle(String symbolicID) { + BundleContext context = SecurityTestsActivator.getDefault().getBundleContext(); + Bundle[] bundles = context.getBundles(); + for (int i = 0; i < bundles.length; i++) { + String bundleName = bundles[i].getSymbolicName(); + if (!symbolicID.equals(bundleName)) + continue; + int bundleState = bundles[i].getState(); + return (bundleState != Bundle.INSTALLED) && (bundleState != Bundle.UNINSTALLED); + } + return false; + } +} |