aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepak Bhole <[email protected]>2010-12-06 15:34:01 -0500
committerDeepak Bhole <[email protected]>2010-12-06 15:34:01 -0500
commit6ca1a9a369b10703da9af8f8a1ced0f3b02ae5c2 (patch)
tree568f8e454db94fa8abc896b46ce8cac7a9f3b74d
parent0d66adf24179c33bbdccaacc10d4c8a5f5e2cd54 (diff)
Fixed indentation and spacing for all .java files.
Added a new .settings directory which contains Eclipse preferences for code style.
-rw-r--r--.settings/org.eclipse.jdt.core.prefs270
-rw-r--r--.settings/org.eclipse.jdt.ui.prefs4
-rw-r--r--ChangeLog7
-rw-r--r--netx/javax/jnlp/BasicService.java13
-rw-r--r--netx/javax/jnlp/ClipboardService.java7
-rw-r--r--netx/javax/jnlp/DownloadService.java49
-rw-r--r--netx/javax/jnlp/DownloadServiceListener.java13
-rw-r--r--netx/javax/jnlp/ExtensionInstallerService.java40
-rw-r--r--netx/javax/jnlp/FileContents.java28
-rw-r--r--netx/javax/jnlp/FileOpenService.java7
-rw-r--r--netx/javax/jnlp/FileSaveService.java7
-rw-r--r--netx/javax/jnlp/JNLPRandomAccessFile.java112
-rw-r--r--netx/javax/jnlp/PersistenceService.java24
-rw-r--r--netx/javax/jnlp/PrintService.java13
-rw-r--r--netx/javax/jnlp/ServiceManager.java64
-rw-r--r--netx/javax/jnlp/ServiceManagerStub.java7
-rw-r--r--netx/javax/jnlp/UnavailableServiceException.java14
-rw-r--r--netx/net/sourceforge/jnlp/AppletDesc.java12
-rw-r--r--netx/net/sourceforge/jnlp/ApplicationDesc.java2
-rw-r--r--netx/net/sourceforge/jnlp/ComponentDesc.java1
-rw-r--r--netx/net/sourceforge/jnlp/DefaultLaunchHandler.java3
-rw-r--r--netx/net/sourceforge/jnlp/ExtensionDesc.java6
-rw-r--r--netx/net/sourceforge/jnlp/IconDesc.java4
-rw-r--r--netx/net/sourceforge/jnlp/InformationDesc.java30
-rw-r--r--netx/net/sourceforge/jnlp/InstallerDesc.java2
-rw-r--r--netx/net/sourceforge/jnlp/JARDesc.java1
-rw-r--r--netx/net/sourceforge/jnlp/JNLPFile.java38
-rw-r--r--netx/net/sourceforge/jnlp/JREDesc.java8
-rw-r--r--netx/net/sourceforge/jnlp/LaunchException.java5
-rw-r--r--netx/net/sourceforge/jnlp/LaunchHandler.java1
-rw-r--r--netx/net/sourceforge/jnlp/Launcher.java137
-rw-r--r--netx/net/sourceforge/jnlp/NetxPanel.java92
-rw-r--r--netx/net/sourceforge/jnlp/Node.java10
-rw-r--r--netx/net/sourceforge/jnlp/PackageDesc.java6
-rw-r--r--netx/net/sourceforge/jnlp/ParseException.java2
-rw-r--r--netx/net/sourceforge/jnlp/Parser.java238
-rw-r--r--netx/net/sourceforge/jnlp/PluginBridge.java64
-rw-r--r--netx/net/sourceforge/jnlp/PropertyDesc.java2
-rw-r--r--netx/net/sourceforge/jnlp/ResourcesDesc.java32
-rw-r--r--netx/net/sourceforge/jnlp/SecurityDesc.java121
-rw-r--r--netx/net/sourceforge/jnlp/Version.java35
-rw-r--r--netx/net/sourceforge/jnlp/cache/CacheEntry.java13
-rw-r--r--netx/net/sourceforge/jnlp/cache/CacheUtil.java67
-rw-r--r--netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java33
-rw-r--r--netx/net/sourceforge/jnlp/cache/DownloadIndicator.java1
-rw-r--r--netx/net/sourceforge/jnlp/cache/Resource.java48
-rw-r--r--netx/net/sourceforge/jnlp/cache/ResourceTracker.java104
-rw-r--r--netx/net/sourceforge/jnlp/cache/UpdatePolicy.java3
-rw-r--r--netx/net/sourceforge/jnlp/controlpanel/AdvancedProxySettingsDialog.java4
-rw-r--r--netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java2
-rw-r--r--netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java3
-rw-r--r--netx/net/sourceforge/jnlp/controlpanel/DesktopShortcutPanel.java3
-rw-r--r--netx/net/sourceforge/jnlp/controlpanel/MiddleClickListener.java3
-rw-r--r--netx/net/sourceforge/jnlp/controlpanel/NamedBorderPanel.java2
-rw-r--r--netx/net/sourceforge/jnlp/controlpanel/NetworkSettingsPanel.java3
-rw-r--r--netx/net/sourceforge/jnlp/controlpanel/SecuritySettingsPanel.java2
-rw-r--r--netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java3
-rw-r--r--netx/net/sourceforge/jnlp/event/ApplicationEvent.java1
-rw-r--r--netx/net/sourceforge/jnlp/event/ApplicationListener.java2
-rw-r--r--netx/net/sourceforge/jnlp/event/DownloadEvent.java1
-rw-r--r--netx/net/sourceforge/jnlp/event/DownloadListener.java2
-rw-r--r--netx/net/sourceforge/jnlp/runtime/AppThreadGroup.java3
-rw-r--r--netx/net/sourceforge/jnlp/runtime/AppletAudioClip.java7
-rw-r--r--netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java36
-rw-r--r--netx/net/sourceforge/jnlp/runtime/AppletInstance.java6
-rw-r--r--netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java47
-rw-r--r--netx/net/sourceforge/jnlp/runtime/Boot.java119
-rw-r--r--netx/net/sourceforge/jnlp/runtime/Boot13.java12
-rw-r--r--netx/net/sourceforge/jnlp/runtime/DeploymentConfiguration.java14
-rw-r--r--netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java393
-rw-r--r--netx/net/sourceforge/jnlp/runtime/JNLPPolicy.java30
-rw-r--r--netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java50
-rw-r--r--netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java264
-rw-r--r--netx/net/sourceforge/jnlp/security/AccessWarningPane.java253
-rw-r--r--netx/net/sourceforge/jnlp/security/AppletWarningPane.java101
-rw-r--r--netx/net/sourceforge/jnlp/security/CertWarningPane.java278
-rw-r--r--netx/net/sourceforge/jnlp/security/CertsInfoPane.java314
-rw-r--r--netx/net/sourceforge/jnlp/security/HttpsCertVerifier.java94
-rw-r--r--netx/net/sourceforge/jnlp/security/KeyStores.java1
-rw-r--r--netx/net/sourceforge/jnlp/security/MoreInfoPane.java62
-rw-r--r--netx/net/sourceforge/jnlp/security/NotAllSignedWarningPane.java107
-rw-r--r--netx/net/sourceforge/jnlp/security/PasswordAuthenticationDialog.java9
-rw-r--r--netx/net/sourceforge/jnlp/security/SecurityDialogPanel.java116
-rw-r--r--netx/net/sourceforge/jnlp/security/SecurityUtil.java294
-rw-r--r--netx/net/sourceforge/jnlp/security/SecurityWarning.java9
-rw-r--r--netx/net/sourceforge/jnlp/security/SecurityWarningDialog.java343
-rw-r--r--netx/net/sourceforge/jnlp/security/SingleCertInfoPane.java41
-rw-r--r--netx/net/sourceforge/jnlp/security/VariableX509TrustManager.java4
-rw-r--r--netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java503
-rw-r--r--netx/net/sourceforge/jnlp/security/viewer/CertificateViewer.java51
-rw-r--r--netx/net/sourceforge/jnlp/services/ServiceUtil.java72
-rw-r--r--netx/net/sourceforge/jnlp/services/XBasicService.java23
-rw-r--r--netx/net/sourceforge/jnlp/services/XClipboardService.java40
-rw-r--r--netx/net/sourceforge/jnlp/services/XDownloadService.java1
-rw-r--r--netx/net/sourceforge/jnlp/services/XExtendedService.java2
-rw-r--r--netx/net/sourceforge/jnlp/services/XExtensionInstallerService.java1
-rw-r--r--netx/net/sourceforge/jnlp/services/XFileContents.java2
-rw-r--r--netx/net/sourceforge/jnlp/services/XFileOpenService.java6
-rw-r--r--netx/net/sourceforge/jnlp/services/XFileSaveService.java8
-rw-r--r--netx/net/sourceforge/jnlp/services/XJNLPRandomAccessFile.java230
-rw-r--r--netx/net/sourceforge/jnlp/services/XPersistenceService.java12
-rw-r--r--netx/net/sourceforge/jnlp/services/XPrintService.java120
-rw-r--r--netx/net/sourceforge/jnlp/services/XServiceManagerStub.java50
-rw-r--r--netx/net/sourceforge/jnlp/tools/CharacterEncoder.java57
-rw-r--r--netx/net/sourceforge/jnlp/tools/HexDumpEncoder.java12
-rw-r--r--netx/net/sourceforge/jnlp/tools/JarRunner.java13
-rw-r--r--netx/net/sourceforge/jnlp/tools/JarSigner.java118
-rw-r--r--netx/net/sourceforge/jnlp/tools/JarSignerResources.java324
-rw-r--r--netx/net/sourceforge/jnlp/tools/KeyStoreUtil.java3
-rw-r--r--netx/net/sourceforge/jnlp/tools/KeyTool.java292
-rw-r--r--netx/net/sourceforge/jnlp/util/FileUtils.java2
-rw-r--r--netx/net/sourceforge/jnlp/util/PropertiesFile.java8
-rw-r--r--netx/net/sourceforge/jnlp/util/Reflect.java13
-rw-r--r--netx/net/sourceforge/jnlp/util/WeakList.java9
-rw-r--r--netx/net/sourceforge/jnlp/util/XDesktopEntry.java2
-rw-r--r--netx/net/sourceforge/nanoxml/XMLElement.java185
-rw-r--r--netx/net/sourceforge/nanoxml/XMLParseException.java28
-rw-r--r--plugin/icedteanp/java/netscape/javascript/JSException.java4
-rw-r--r--plugin/icedteanp/java/netscape/javascript/JSObject.java82
-rw-r--r--plugin/icedteanp/java/netscape/javascript/JSObjectCreatePermission.java3
-rw-r--r--plugin/icedteanp/java/netscape/javascript/JSProxy.java27
-rw-r--r--plugin/icedteanp/java/netscape/javascript/JSRunnable.java46
-rw-r--r--plugin/icedteanp/java/netscape/javascript/JSUtil.java17
-rw-r--r--plugin/icedteanp/java/netscape/security/ForbiddenTargetException.java2
-rw-r--r--plugin/icedteanp/java/sun/applet/AppletSecurityContextManager.java41
-rw-r--r--plugin/icedteanp/java/sun/applet/GetMemberPluginCallRequest.java10
-rw-r--r--plugin/icedteanp/java/sun/applet/GetWindowPluginCallRequest.java6
-rw-r--r--plugin/icedteanp/java/sun/applet/JavaConsole.java8
-rw-r--r--plugin/icedteanp/java/sun/applet/MethodOverloadResolver.java222
-rw-r--r--plugin/icedteanp/java/sun/applet/PluginAppletSecurityContext.java1958
-rw-r--r--plugin/icedteanp/java/sun/applet/PluginAppletViewer.java3622
-rw-r--r--plugin/icedteanp/java/sun/applet/PluginCallRequest.java22
-rw-r--r--plugin/icedteanp/java/sun/applet/PluginCallRequestFactory.java28
-rw-r--r--plugin/icedteanp/java/sun/applet/PluginClassLoader.java15
-rw-r--r--plugin/icedteanp/java/sun/applet/PluginCookieInfoRequest.java19
-rw-r--r--plugin/icedteanp/java/sun/applet/PluginCookieManager.java43
-rw-r--r--plugin/icedteanp/java/sun/applet/PluginDebug.java9
-rw-r--r--plugin/icedteanp/java/sun/applet/PluginException.java18
-rw-r--r--plugin/icedteanp/java/sun/applet/PluginMain.java155
-rw-r--r--plugin/icedteanp/java/sun/applet/PluginMessageConsumer.java361
-rw-r--r--plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java204
-rw-r--r--plugin/icedteanp/java/sun/applet/PluginObjectStore.java24
-rw-r--r--plugin/icedteanp/java/sun/applet/PluginProxyInfoRequest.java30
-rw-r--r--plugin/icedteanp/java/sun/applet/PluginProxySelector.java4
-rw-r--r--plugin/icedteanp/java/sun/applet/PluginStreamHandler.java585
-rw-r--r--plugin/icedteanp/java/sun/applet/RequestQueue.java12
-rw-r--r--plugin/icedteanp/java/sun/applet/TestEnv.java13
-rw-r--r--plugin/icedteanp/java/sun/applet/VoidPluginCallRequest.java9
148 files changed, 7316 insertions, 7308 deletions
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..a01a30f
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,270 @@
+#Fri Dec 03 15:33:31 EST 2010
+eclipse.preferences.version=1
+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_annotation=0
+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_method_declaration=0
+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=true
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
+org.eclipse.jdt.core.formatter.comment.line_length=80
+org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
+org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
+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.disabling_tag=@formatter\:off
+org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
+org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
+org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
+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_on_local_variable=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not 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=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=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=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=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not 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.join_lines_in_comments=true
+org.eclipse.jdt.core.formatter.join_wrapped_lines=false
+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=true
+org.eclipse.jdt.core.formatter.tabulation.char=space
+org.eclipse.jdt.core.formatter.tabulation.size=4
+org.eclipse.jdt.core.formatter.use_on_off_tags=false
+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.formatter.wrap_outer_expressions_when_nested=true
diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 0000000..2044d03
--- /dev/null
+++ b/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,4 @@
+#Fri Dec 03 14:29:50 EST 2010
+eclipse.preferences.version=1
+formatter_profile=_IcedTea Web
+formatter_settings_version=11
diff --git a/ChangeLog b/ChangeLog
index 0efa3a7..d9677d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-12-06 Deepak Bhole <[email protected]>
+
+ Fixed indentation and spacing for all .java files
+ * .settings/org.eclipse.jdt.core.prefs: New file. Contains code style
+ preference settings for Eclipse.
+ * .settings/org.eclipse.jdt.ui.prefs: Same.
+
2010-12-03 Andrew John Hughes <[email protected]>
* netx/net/sourceforge/jnlp/cache/CacheUtil.java,
diff --git a/netx/javax/jnlp/BasicService.java b/netx/javax/jnlp/BasicService.java
index cb9a445..b04691e 100644
--- a/netx/javax/jnlp/BasicService.java
+++ b/netx/javax/jnlp/BasicService.java
@@ -1,12 +1,13 @@
-
-
package javax.jnlp;
public interface BasicService {
- public java.net.URL getCodeBase();
- public boolean isOffline();
- public boolean showDocument(java.net.URL url);
- public boolean isWebBrowserSupported();
+ public java.net.URL getCodeBase();
+
+ public boolean isOffline();
+
+ public boolean showDocument(java.net.URL url);
+
+ public boolean isWebBrowserSupported();
}
diff --git a/netx/javax/jnlp/ClipboardService.java b/netx/javax/jnlp/ClipboardService.java
index cada884..3d3696f 100644
--- a/netx/javax/jnlp/ClipboardService.java
+++ b/netx/javax/jnlp/ClipboardService.java
@@ -1,10 +1,9 @@
-
-
package javax.jnlp;
public interface ClipboardService {
- public java.awt.datatransfer.Transferable getContents();
- public void setContents(java.awt.datatransfer.Transferable contents);
+ public java.awt.datatransfer.Transferable getContents();
+
+ public void setContents(java.awt.datatransfer.Transferable contents);
}
diff --git a/netx/javax/jnlp/DownloadService.java b/netx/javax/jnlp/DownloadService.java
index 6710fc6..558b9b4 100644
--- a/netx/javax/jnlp/DownloadService.java
+++ b/netx/javax/jnlp/DownloadService.java
@@ -1,24 +1,37 @@
-
-
package javax.jnlp;
public interface DownloadService {
- public boolean isResourceCached(java.net.URL ref, java.lang.String version);
- public boolean isPartCached(java.lang.String part);
- public boolean isPartCached(java.lang.String[] parts);
- public boolean isExtensionPartCached(java.net.URL ref, java.lang.String version, java.lang.String part);
- public boolean isExtensionPartCached(java.net.URL ref, java.lang.String version, java.lang.String[] parts);
- public void loadResource(java.net.URL ref, java.lang.String version, DownloadServiceListener progress) throws java.io.IOException;
- public void loadPart(java.lang.String part, DownloadServiceListener progress) throws java.io.IOException;
- public void loadPart(java.lang.String[] parts, DownloadServiceListener progress) throws java.io.IOException;
- public void loadExtensionPart(java.net.URL ref, java.lang.String version, java.lang.String part, DownloadServiceListener progress) throws java.io.IOException;
- public void loadExtensionPart(java.net.URL ref, java.lang.String version, java.lang.String[] parts, DownloadServiceListener progress) throws java.io.IOException;
- public void removeResource(java.net.URL ref, java.lang.String version) throws java.io.IOException;
- public void removePart(java.lang.String part) throws java.io.IOException;
- public void removePart(java.lang.String[] parts) throws java.io.IOException;
- public void removeExtensionPart(java.net.URL ref, java.lang.String version, java.lang.String part) throws java.io.IOException;
- public void removeExtensionPart(java.net.URL ref, java.lang.String version, java.lang.String[] parts) throws java.io.IOException;
- public DownloadServiceListener getDefaultProgressWindow();
+ public boolean isResourceCached(java.net.URL ref, java.lang.String version);
+
+ public boolean isPartCached(java.lang.String part);
+
+ public boolean isPartCached(java.lang.String[] parts);
+
+ public boolean isExtensionPartCached(java.net.URL ref, java.lang.String version, java.lang.String part);
+
+ public boolean isExtensionPartCached(java.net.URL ref, java.lang.String version, java.lang.String[] parts);
+
+ public void loadResource(java.net.URL ref, java.lang.String version, DownloadServiceListener progress) throws java.io.IOException;
+
+ public void loadPart(java.lang.String part, DownloadServiceListener progress) throws java.io.IOException;
+
+ public void loadPart(java.lang.String[] parts, DownloadServiceListener progress) throws java.io.IOException;
+
+ public void loadExtensionPart(java.net.URL ref, java.lang.String version, java.lang.String part, DownloadServiceListener progress) throws java.io.IOException;
+
+ public void loadExtensionPart(java.net.URL ref, java.lang.String version, java.lang.String[] parts, DownloadServiceListener progress) throws java.io.IOException;
+
+ public void removeResource(java.net.URL ref, java.lang.String version) throws java.io.IOException;
+
+ public void removePart(java.lang.String part) throws java.io.IOException;
+
+ public void removePart(java.lang.String[] parts) throws java.io.IOException;
+
+ public void removeExtensionPart(java.net.URL ref, java.lang.String version, java.lang.String part) throws java.io.IOException;
+
+ public void removeExtensionPart(java.net.URL ref, java.lang.String version, java.lang.String[] parts) throws java.io.IOException;
+
+ public DownloadServiceListener getDefaultProgressWindow();
}
diff --git a/netx/javax/jnlp/DownloadServiceListener.java b/netx/javax/jnlp/DownloadServiceListener.java
index 4d0fba3..519161f 100644
--- a/netx/javax/jnlp/DownloadServiceListener.java
+++ b/netx/javax/jnlp/DownloadServiceListener.java
@@ -1,12 +1,13 @@
-
-
package javax.jnlp;
public interface DownloadServiceListener {
- public void progress(java.net.URL url, java.lang.String version, long readSoFar, long total, int overallPercent);
- public void validating(java.net.URL url, java.lang.String version, long entry, long total, int overallPercent);
- public void upgradingArchive(java.net.URL url, java.lang.String version, int patchPercent, int overallPercent);
- public void downloadFailed(java.net.URL url, java.lang.String version);
+ public void progress(java.net.URL url, java.lang.String version, long readSoFar, long total, int overallPercent);
+
+ public void validating(java.net.URL url, java.lang.String version, long entry, long total, int overallPercent);
+
+ public void upgradingArchive(java.net.URL url, java.lang.String version, int patchPercent, int overallPercent);
+
+ public void downloadFailed(java.net.URL url, java.lang.String version);
}
diff --git a/netx/javax/jnlp/ExtensionInstallerService.java b/netx/javax/jnlp/ExtensionInstallerService.java
index a3b686c..d968167 100644
--- a/netx/javax/jnlp/ExtensionInstallerService.java
+++ b/netx/javax/jnlp/ExtensionInstallerService.java
@@ -1,21 +1,31 @@
-
-
package javax.jnlp;
public interface ExtensionInstallerService {
- public java.lang.String getInstallPath();
- public java.lang.String getExtensionVersion();
- public java.net.URL getExtensionLocation();
- public void hideProgressBar();
- public void hideStatusWindow();
- public void setHeading(java.lang.String heading);
- public void setStatus(java.lang.String status);
- public void updateProgress(int value);
- public void installSucceeded(boolean needsReboot);
- public void installFailed();
- public void setJREInfo(java.lang.String platformVersion, java.lang.String jrePath);
- public void setNativeLibraryInfo(java.lang.String path);
- public java.lang.String getInstalledJRE(java.net.URL url, java.lang.String version);
+ public java.lang.String getInstallPath();
+
+ public java.lang.String getExtensionVersion();
+
+ public java.net.URL getExtensionLocation();
+
+ public void hideProgressBar();
+
+ public void hideStatusWindow();
+
+ public void setHeading(java.lang.String heading);
+
+ public void setStatus(java.lang.String status);
+
+ public void updateProgress(int value);
+
+ public void installSucceeded(boolean needsReboot);
+
+ public void installFailed();
+
+ public void setJREInfo(java.lang.String platformVersion, java.lang.String jrePath);
+
+ public void setNativeLibraryInfo(java.lang.String path);
+
+ public java.lang.String getInstalledJRE(java.net.URL url, java.lang.String version);
}
diff --git a/netx/javax/jnlp/FileContents.java b/netx/javax/jnlp/FileContents.java
index a612202..4658dff 100644
--- a/netx/javax/jnlp/FileContents.java
+++ b/netx/javax/jnlp/FileContents.java
@@ -1,17 +1,23 @@
-
-
package javax.jnlp;
public interface FileContents {
- public java.lang.String getName() throws java.io.IOException;
- public java.io.InputStream getInputStream() throws java.io.IOException;
- public java.io.OutputStream getOutputStream(boolean overwrite) throws java.io.IOException;
- public long getLength() throws java.io.IOException;
- public boolean canRead() throws java.io.IOException;
- public boolean canWrite() throws java.io.IOException;
- public JNLPRandomAccessFile getRandomAccessFile(java.lang.String mode) throws java.io.IOException;
- public long getMaxLength() throws java.io.IOException;
- public long setMaxLength(long maxlength) throws java.io.IOException;
+ public java.lang.String getName() throws java.io.IOException;
+
+ public java.io.InputStream getInputStream() throws java.io.IOException;
+
+ public java.io.OutputStream getOutputStream(boolean overwrite) throws java.io.IOException;
+
+ public long getLength() throws java.io.IOException;
+
+ public boolean canRead() throws java.io.IOException;
+
+ public boolean canWrite() throws java.io.IOException;
+
+ public JNLPRandomAccessFile getRandomAccessFile(java.lang.String mode) throws java.io.IOException;
+
+ public long getMaxLength() throws java.io.IOException;
+
+ public long setMaxLength(long maxlength) throws java.io.IOException;
}
diff --git a/netx/javax/jnlp/FileOpenService.java b/netx/javax/jnlp/FileOpenService.java
index 1ca5ee9..d31fd35 100644
--- a/netx/javax/jnlp/FileOpenService.java
+++ b/netx/javax/jnlp/FileOpenService.java
@@ -1,10 +1,9 @@
-
-
package javax.jnlp;
public interface FileOpenService {
- public FileContents openFileDialog(java.lang.String pathHint, java.lang.String[] extensions) throws java.io.IOException;
- public FileContents[] openMultiFileDialog(java.lang.String pathHint, java.lang.String[] extensions) throws java.io.IOException;
+ public FileContents openFileDialog(java.lang.String pathHint, java.lang.String[] extensions) throws java.io.IOException;
+
+ public FileContents[] openMultiFileDialog(java.lang.String pathHint, java.lang.String[] extensions) throws java.io.IOException;
}
diff --git a/netx/javax/jnlp/FileSaveService.java b/netx/javax/jnlp/FileSaveService.java
index b06d761..d27201c 100644
--- a/netx/javax/jnlp/FileSaveService.java
+++ b/netx/javax/jnlp/FileSaveService.java
@@ -1,10 +1,9 @@
-
-
package javax.jnlp;
public interface FileSaveService {
- public FileContents saveFileDialog(java.lang.String pathHint, java.lang.String[] extensions, java.io.InputStream stream, java.lang.String name) throws java.io.IOException;
- public FileContents saveAsFileDialog(java.lang.String pathHint, java.lang.String[] extensions, FileContents contents) throws java.io.IOException;
+ public FileContents saveFileDialog(java.lang.String pathHint, java.lang.String[] extensions, java.io.InputStream stream, java.lang.String name) throws java.io.IOException;
+
+ public FileContents saveAsFileDialog(java.lang.String pathHint, java.lang.String[] extensions, FileContents contents) throws java.io.IOException;
}
diff --git a/netx/javax/jnlp/JNLPRandomAccessFile.java b/netx/javax/jnlp/JNLPRandomAccessFile.java
index 3d67fce..ad7d431 100644
--- a/netx/javax/jnlp/JNLPRandomAccessFile.java
+++ b/netx/javax/jnlp/JNLPRandomAccessFile.java
@@ -1,45 +1,79 @@
-
-
package javax.jnlp;
+
public interface JNLPRandomAccessFile extends java.io.DataInput, java.io.DataOutput {
+ public void close() throws java.io.IOException;
+
+ public long length() throws java.io.IOException;
+
+ public long getFilePointer() throws java.io.IOException;
+
+ public int read() throws java.io.IOException;
+
+ public int read(byte[] b, int off, int len) throws java.io.IOException;
+
+ public int read(byte[] b) throws java.io.IOException;
+
+ public void readFully(byte[] b) throws java.io.IOException;
+
+ public void readFully(byte[] b, int off, int len) throws java.io.IOException;
+
+ public int skipBytes(int n) throws java.io.IOException;
+
+ public boolean readBoolean() throws java.io.IOException;
+
+ public byte readByte() throws java.io.IOException;
+
+ public int readUnsignedByte() throws java.io.IOException;
+
+ public short readShort() throws java.io.IOException;
+
+ public int readUnsignedShort() throws java.io.IOException;
+
+ public char readChar() throws java.io.IOException;
+
+ public int readInt() throws java.io.IOException;
+
+ public long readLong() throws java.io.IOException;
+
+ public float readFloat() throws java.io.IOException;
+
+ public double readDouble() throws java.io.IOException;
+
+ public java.lang.String readLine() throws java.io.IOException;
+
+ public java.lang.String readUTF() throws java.io.IOException;
+
+ public void seek(long pos) throws java.io.IOException;
+
+ public void setLength(long newLength) throws java.io.IOException;
+
+ public void write(int b) throws java.io.IOException;
+
+ public void write(byte[] b) throws java.io.IOException;
+
+ public void write(byte[] b, int off, int len) throws java.io.IOException;
+
+ public void writeBoolean(boolean v) throws java.io.IOException;
+
+ public void writeByte(int v) throws java.io.IOException;
+
+ public void writeShort(int v) throws java.io.IOException;
+
+ public void writeChar(int v) throws java.io.IOException;
+
+ public void writeInt(int v) throws java.io.IOException;
+
+ public void writeLong(long v) throws java.io.IOException;
+
+ public void writeFloat(float v) throws java.io.IOException;
+
+ public void writeDouble(double v) throws java.io.IOException;
+
+ public void writeBytes(java.lang.String s) throws java.io.IOException;
+
+ public void writeChars(java.lang.String s) throws java.io.IOException;
- public void close() throws java.io.IOException;
- public long length() throws java.io.IOException;
- public long getFilePointer() throws java.io.IOException;
- public int read() throws java.io.IOException;
- public int read(byte[] b, int off, int len) throws java.io.IOException;
- public int read(byte[] b) throws java.io.IOException;
- public void readFully(byte[] b) throws java.io.IOException;
- public void readFully(byte[] b, int off, int len) throws java.io.IOException;
- public int skipBytes(int n) throws java.io.IOException;
- public boolean readBoolean() throws java.io.IOException;
- public byte readByte() throws java.io.IOException;
- public int readUnsignedByte() throws java.io.IOException;
- public short readShort() throws java.io.IOException;
- public int readUnsignedShort() throws java.io.IOException;
- public char readChar() throws java.io.IOException;
- public int readInt() throws java.io.IOException;
- public long readLong() throws java.io.IOException;
- public float readFloat() throws java.io.IOException;
- public double readDouble() throws java.io.IOException;
- public java.lang.String readLine() throws java.io.IOException;
- public java.lang.String readUTF() throws java.io.IOException;
- public void seek(long pos) throws java.io.IOException;
- public void setLength(long newLength) throws java.io.IOException;
- public void write(int b) throws java.io.IOException;
- public void write(byte[] b) throws java.io.IOException;
- public void write(byte[] b, int off, int len) throws java.io.IOException;
- public void writeBoolean(boolean v) throws java.io.IOException;
- public void writeByte(int v) throws java.io.IOException;
- public void writeShort(int v) throws java.io.IOException;
- public void writeChar(int v) throws java.io.IOException;
- public void writeInt(int v) throws java.io.IOException;
- public void writeLong(long v) throws java.io.IOException;
- public void writeFloat(float v) throws java.io.IOException;
- public void writeDouble(double v) throws java.io.IOException;
- public void writeBytes(java.lang.String s) throws java.io.IOException;
- public void writeChars(java.lang.String s) throws java.io.IOException;
- public void writeUTF(java.lang.String str) throws java.io.IOException;
+ public void writeUTF(java.lang.String str) throws java.io.IOException;
}
diff --git a/netx/javax/jnlp/PersistenceService.java b/netx/javax/jnlp/PersistenceService.java
index 008c670..10de8e6 100644
--- a/netx/javax/jnlp/PersistenceService.java
+++ b/netx/javax/jnlp/PersistenceService.java
@@ -1,17 +1,21 @@
-
package javax.jnlp;
public interface PersistenceService {
- public static final int CACHED = 0;
- public static final int TEMPORARY = 1;
- public static final int DIRTY = 2;
+ public static final int CACHED = 0;
+ public static final int TEMPORARY = 1;
+ public static final int DIRTY = 2;
+
+ public long create(java.net.URL url, long maxsize) throws java.net.MalformedURLException, java.io.IOException;
+
+ public FileContents get(java.net.URL url) throws java.net.MalformedURLException, java.io.IOException, java.io.FileNotFoundException;
+
+ public void delete(java.net.URL url) throws java.net.MalformedURLException, java.io.IOException;
+
+ public java.lang.String[] getNames(java.net.URL url) throws java.net.MalformedURLException, java.io.IOException;
+
+ public int getTag(java.net.URL url) throws java.net.MalformedURLException, java.io.IOException;
- public long create(java.net.URL url, long maxsize) throws java.net.MalformedURLException, java.io.IOException;
- public FileContents get(java.net.URL url) throws java.net.MalformedURLException, java.io.IOException, java.io.FileNotFoundException;
- public void delete(java.net.URL url) throws java.net.MalformedURLException, java.io.IOException;
- public java.lang.String[] getNames(java.net.URL url) throws java.net.MalformedURLException, java.io.IOException;
- public int getTag(java.net.URL url) throws java.net.MalformedURLException, java.io.IOException;
- public void setTag(java.net.URL url, int tag) throws java.net.MalformedURLException, java.io.IOException;
+ public void setTag(java.net.URL url, int tag) throws java.net.MalformedURLException, java.io.IOException;
}
diff --git a/netx/javax/jnlp/PrintService.java b/netx/javax/jnlp/PrintService.java
index 7573233..ffd7444 100644
--- a/netx/javax/jnlp/PrintService.java
+++ b/netx/javax/jnlp/PrintService.java
@@ -1,12 +1,13 @@
-
-
package javax.jnlp;
public interface PrintService {
- public java.awt.print.PageFormat getDefaultPage();
- public java.awt.print.PageFormat showPageFormatDialog(java.awt.print.PageFormat page);
- public boolean print(java.awt.print.Pageable document);
- public boolean print(java.awt.print.Printable painter);
+ public java.awt.print.PageFormat getDefaultPage();
+
+ public java.awt.print.PageFormat showPageFormatDialog(java.awt.print.PageFormat page);
+
+ public boolean print(java.awt.print.Pageable document);
+
+ public boolean print(java.awt.print.Printable painter);
}
diff --git a/netx/javax/jnlp/ServiceManager.java b/netx/javax/jnlp/ServiceManager.java
index 7e6fb36..2f35a6f 100644
--- a/netx/javax/jnlp/ServiceManager.java
+++ b/netx/javax/jnlp/ServiceManager.java
@@ -1,54 +1,48 @@
-
-
-
package javax.jnlp;
import java.util.*;
-
public final class ServiceManager {
- private static ServiceManagerStub stub = null;
+ private static ServiceManagerStub stub = null;
- private static Map<String,Object> lookupTable
- = new HashMap<String,Object>(); // ensure lookup is idempotent
-
- private ServiceManager() {
- // says it can't be instantiated
- }
+ private static Map<String, Object> lookupTable = new HashMap<String, Object>(); // ensure lookup is idempotent
+ private ServiceManager() {
+ // says it can't be instantiated
+ }
- public static java.lang.Object lookup(java.lang.String name) throws UnavailableServiceException {
- if (stub == null)
- throw new UnavailableServiceException("service stub not set.");
+ public static java.lang.Object lookup(java.lang.String name) throws UnavailableServiceException {
+ if (stub == null)
+ throw new UnavailableServiceException("service stub not set.");
- synchronized(lookupTable) {
- Object result = lookupTable.get(name);
+ synchronized (lookupTable) {
+ Object result = lookupTable.get(name);
- if (result == null) {
- result = stub.lookup(name);
- if (result != null)
- lookupTable.put(name, result);
- }
+ if (result == null) {
+ result = stub.lookup(name);
+ if (result != null)
+ lookupTable.put(name, result);
+ }
- if (result == null)
- throw new UnavailableServiceException("service not available (stub returned null).");
+ if (result == null)
+ throw new UnavailableServiceException("service not available (stub returned null).");
- return result;
+ return result;
+ }
}
- }
- public static java.lang.String[] getServiceNames() {
- // should this return the required ones even though no stub??
- if (stub == null)
- return new String[0];
+ public static java.lang.String[] getServiceNames() {
+ // should this return the required ones even though no stub??
+ if (stub == null)
+ return new String[0];
- return stub.getServiceNames();
- }
+ return stub.getServiceNames();
+ }
- public static void setServiceManagerStub(ServiceManagerStub stub) {
- if (ServiceManager.stub == null)
- ServiceManager.stub = stub;
- }
+ public static void setServiceManagerStub(ServiceManagerStub stub) {
+ if (ServiceManager.stub == null)
+ ServiceManager.stub = stub;
+ }
}
diff --git a/netx/javax/jnlp/ServiceManagerStub.java b/netx/javax/jnlp/ServiceManagerStub.java
index 04af1dd..5afe2e3 100644
--- a/netx/javax/jnlp/ServiceManagerStub.java
+++ b/netx/javax/jnlp/ServiceManagerStub.java
@@ -1,10 +1,9 @@
-
-
package javax.jnlp;
public interface ServiceManagerStub {
- public java.lang.Object lookup(java.lang.String name) throws UnavailableServiceException;
- public java.lang.String[] getServiceNames();
+ public java.lang.Object lookup(java.lang.String name) throws UnavailableServiceException;
+
+ public java.lang.String[] getServiceNames();
}
diff --git a/netx/javax/jnlp/UnavailableServiceException.java b/netx/javax/jnlp/UnavailableServiceException.java
index b5c342d..b1ef4e6 100644
--- a/netx/javax/jnlp/UnavailableServiceException.java
+++ b/netx/javax/jnlp/UnavailableServiceException.java
@@ -1,15 +1,13 @@
-
-
package javax.jnlp;
public class UnavailableServiceException extends Exception {
- public UnavailableServiceException() {
- super();
- }
+ public UnavailableServiceException() {
+ super();
+ }
- public UnavailableServiceException(java.lang.String message) {
- super(message);
- }
+ public UnavailableServiceException(java.lang.String message) {
+ super(message);
+ }
}
diff --git a/netx/net/sourceforge/jnlp/AppletDesc.java b/netx/net/sourceforge/jnlp/AppletDesc.java
index 39133ce..a3b7fe4 100644
--- a/netx/net/sourceforge/jnlp/AppletDesc.java
+++ b/netx/net/sourceforge/jnlp/AppletDesc.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp;
import java.io.*;
@@ -45,8 +44,7 @@ public class AppletDesc {
private int height;
/** the parameters */
- private Map<String,String> parameters;
-
+ private Map<String, String> parameters;
/**
* Create an Applet descriptor.
@@ -59,13 +57,13 @@ public class AppletDesc {
* @param parameters the parameters
*/
public AppletDesc(String name, String mainClass, URL documentBase, int width, int height,
- Map<String,String> parameters) {
+ Map<String, String> parameters) {
this.name = name;
this.mainClass = mainClass;
this.documentBase = documentBase;
this.width = width;
this.height = height;
- this.parameters = new HashMap<String,String>(parameters);
+ this.parameters = new HashMap<String, String>(parameters);
}
/**
@@ -106,8 +104,8 @@ public class AppletDesc {
/**
* Returns the applet parameters
*/
- public Map<String,String> getParameters() {
- return new HashMap<String,String>(parameters);
+ public Map<String, String> getParameters() {
+ return new HashMap<String, String>(parameters);
}
/**
diff --git a/netx/net/sourceforge/jnlp/ApplicationDesc.java b/netx/net/sourceforge/jnlp/ApplicationDesc.java
index 221eaac..87fc75a 100644
--- a/netx/net/sourceforge/jnlp/ApplicationDesc.java
+++ b/netx/net/sourceforge/jnlp/ApplicationDesc.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp;
import java.io.*;
@@ -35,7 +34,6 @@ public class ApplicationDesc {
/** the arguments */
private String arguments[];
-
/**
* Create an Application descriptor.
*
diff --git a/netx/net/sourceforge/jnlp/ComponentDesc.java b/netx/net/sourceforge/jnlp/ComponentDesc.java
index 7d0b2a3..2bf4967 100644
--- a/netx/net/sourceforge/jnlp/ComponentDesc.java
+++ b/netx/net/sourceforge/jnlp/ComponentDesc.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp;
import java.io.*;
diff --git a/netx/net/sourceforge/jnlp/DefaultLaunchHandler.java b/netx/net/sourceforge/jnlp/DefaultLaunchHandler.java
index 357ad1a..7240684 100644
--- a/netx/net/sourceforge/jnlp/DefaultLaunchHandler.java
+++ b/netx/net/sourceforge/jnlp/DefaultLaunchHandler.java
@@ -23,7 +23,6 @@ import java.awt.*;
import java.util.*;
import javax.swing.*;
-
/**
* This default implementation shows prints the exception to
* stdout and if not in headless mode displays the exception in a
@@ -100,7 +99,7 @@ public class DefaultLaunchHandler implements LaunchHandler {
Throwable causes[] = ex.getCauses();
- for (int i=0; i < causes.length; i++) {
+ for (int i = 0; i < causes.length; i++) {
result.append(" (");
result.append(causes[i].getClass().getName());
result.append(" ");
diff --git a/netx/net/sourceforge/jnlp/ExtensionDesc.java b/netx/net/sourceforge/jnlp/ExtensionDesc.java
index 09a2ddb..4e4283f 100644
--- a/netx/net/sourceforge/jnlp/ExtensionDesc.java
+++ b/netx/net/sourceforge/jnlp/ExtensionDesc.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp;
import static net.sourceforge.jnlp.runtime.Translator.R;
@@ -46,12 +45,11 @@ public class ExtensionDesc {
private JNLPFile file;
/** map from ext-part to local part */
- private Map<String,String> extToPart = new HashMap<String,String>();
+ private Map<String, String> extToPart = new HashMap<String, String>();
/** eager ext parts */
private List<String> eagerExtParts = new ArrayList<String>();
-
/**
* Create an extention descriptor.
*
@@ -125,7 +123,7 @@ public class ExtensionDesc {
file = new JNLPFile(location);
if (JNLPRuntime.isDebug())
- System.out.println("Resolve: "+file.getInformation().getTitle());
+ System.out.println("Resolve: " + file.getInformation().getTitle());
// check for it being an extension descriptor
if (!file.isComponent() && !file.isInstaller())
diff --git a/netx/net/sourceforge/jnlp/IconDesc.java b/netx/net/sourceforge/jnlp/IconDesc.java
index c115b42..448bcf5 100644
--- a/netx/net/sourceforge/jnlp/IconDesc.java
+++ b/netx/net/sourceforge/jnlp/IconDesc.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp;
import java.io.*;
@@ -47,7 +46,6 @@ public class IconDesc {
/** destop shortcut icon */
public static final Object SHORTCUT = "shortcut";
-
/** the location of the icon */
private URL location;
@@ -66,7 +64,6 @@ public class IconDesc {
/** the size, or -1 if unknown*/
private int size;
-
/**
* Creates an icon descriptor with the specified information.
*
@@ -131,5 +128,4 @@ public class IconDesc {
return depth;
}
-
}
diff --git a/netx/net/sourceforge/jnlp/InformationDesc.java b/netx/net/sourceforge/jnlp/InformationDesc.java
index 076b6b3..faee3c2 100644
--- a/netx/net/sourceforge/jnlp/InformationDesc.java
+++ b/netx/net/sourceforge/jnlp/InformationDesc.java
@@ -15,7 +15,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp;
import java.io.*;
@@ -37,13 +36,13 @@ public class InformationDesc {
// specification name.
/** one-line description */
- public static final Object ONE_LINE= "oneline";
+ public static final Object ONE_LINE = "oneline";
/** short description */
- public static final Object SHORT= "short";
+ public static final Object SHORT = "short";
/** tooltip description */
- public static final Object TOOLTIP= "tooltip";
+ public static final Object TOOLTIP = "tooltip";
/** default description */
public static final Object DEFAULT = "default";
@@ -57,7 +56,6 @@ public class InformationDesc {
/** the JNLPFile this information is for */
private JNLPFile jnlpFile;
-
/**
* Create an information element object.
*
@@ -87,7 +85,7 @@ public class InformationDesc {
* Returns the application's homepage.
*/
public URL getHomepage() {
- return (URL)getItem("homepage");
+ return (URL) getItem("homepage");
}
/**
@@ -114,9 +112,9 @@ public class InformationDesc {
* Information.TOOLTIP, Information.DEFAULT
*/
public String getDescription(Object kind) {
- String result = (String) getItem("description-"+kind);
+ String result = (String) getItem("description-" + kind);
if (result == null)
- return (String) getItem("description-"+DEFAULT);
+ return (String) getItem("description-" + DEFAULT);
else
return result;
}
@@ -129,7 +127,7 @@ public class InformationDesc {
* @return an array of zero of more IconDescs of the specified icon type
*/
public IconDesc[] getIcons(Object kind) {
- List<Object> icons = getItems("icon-"+kind);
+ List<Object> icons = getItems("icon-" + kind);
return icons.toArray(new IconDesc[icons.size()]);
};
@@ -151,14 +149,14 @@ public class InformationDesc {
return null;
IconDesc best = null;
- for (int i=0; i < icons.length; i++) {
+ for (int i = 0; i < icons.length; i++) {
if (icons[i].getWidth() >= width &&
- icons[i].getHeight() >= height) {
+ icons[i].getHeight() >= height) {
if (best == null)
best = icons[i];
if (icons[i].getWidth() <= best.getWidth() && // Use <= so last specified of
- icons[i].getHeight() <= best.getHeight()) // equivalent icons is chosen.
+ icons[i].getHeight() <= best.getHeight()) // equivalent icons is chosen.
best = icons[i];
}
}
@@ -233,7 +231,7 @@ public class InformationDesc {
if (items.size() == 0)
return null;
else
- return items.get( items.size()-1 );
+ return items.get(items.size() - 1);
}
/**
@@ -244,9 +242,9 @@ public class InformationDesc {
return Collections.emptyList();
List<Object> result = new ArrayList<Object>();
- for (int i=0; i < info.size(); i+=2)
+ for (int i = 0; i < info.size(); i += 2)
if (info.get(i).equals(key))
- result.add( info.get(i+1) );
+ result.add(info.get(i + 1));
return result;
}
@@ -257,7 +255,7 @@ public class InformationDesc {
*/
protected void addItem(String key, Object value) {
if (info == null)
- info = new ArrayList<Object>();
+ info = new ArrayList<Object>();
info.add(key);
info.add(value);
diff --git a/netx/net/sourceforge/jnlp/InstallerDesc.java b/netx/net/sourceforge/jnlp/InstallerDesc.java
index 17b8f87..797f5ac 100644
--- a/netx/net/sourceforge/jnlp/InstallerDesc.java
+++ b/netx/net/sourceforge/jnlp/InstallerDesc.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp;
import java.io.*;
@@ -32,7 +31,6 @@ public class InstallerDesc {
/** the main class name and package. */
private String mainClass;
-
/**
* Creates a installer descriptor.
*
diff --git a/netx/net/sourceforge/jnlp/JARDesc.java b/netx/net/sourceforge/jnlp/JARDesc.java
index d3941ca..78bc311 100644
--- a/netx/net/sourceforge/jnlp/JARDesc.java
+++ b/netx/net/sourceforge/jnlp/JARDesc.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp;
import java.io.*;
diff --git a/netx/net/sourceforge/jnlp/JNLPFile.java b/netx/net/sourceforge/jnlp/JNLPFile.java
index 6ba186f..24a6566 100644
--- a/netx/net/sourceforge/jnlp/JNLPFile.java
+++ b/netx/net/sourceforge/jnlp/JNLPFile.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp;
import static net.sourceforge.jnlp.runtime.Translator.R;
@@ -34,7 +33,6 @@ import net.sourceforge.jnlp.cache.ResourceTracker;
import net.sourceforge.jnlp.cache.UpdatePolicy;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
-
/**
* Provides methods to access the information in a Java Network
* Launching Protocol (JNLP) file. The Java Network Launching
@@ -115,8 +113,7 @@ public class JNLPFile {
defaultLocale = Locale.getDefault();
defaultOS = System.getProperty("os.name");
defaultArch = System.getProperty("os.arch");
- }
- catch (SecurityException ex) {
+ } catch (SecurityException ex) {
// null values will still work, and app can set defaults later
}
}
@@ -241,7 +238,6 @@ public class JNLPFile {
//parse(Parser.getRootNode(input), strict, null);
}
-
/**
* Open the jnlp file URL from the cache if there, otherwise
* download to the cache. Called from constructor.
@@ -252,11 +248,10 @@ public class JNLPFile {
try {
ResourceTracker tracker = new ResourceTracker(false); // no prefetch
- tracker.addResource(location, version , policy);
+ tracker.addResource(location, version, policy);
return tracker.getInputStream(location);
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
throw new IOException(ex.getMessage());
}
}
@@ -333,16 +328,16 @@ public class JNLPFile {
* through the specified locale.
*/
public InformationDesc getInformation(final Locale locale) {
- return new InformationDesc(this, new Locale[] {locale}) {
+ return new InformationDesc(this, new Locale[] { locale }) {
protected List<Object> getItems(Object key) {
List<Object> result = new ArrayList<Object>();
- for (int i=0; i < info.size(); i++) {
+ for (int i = 0; i < info.size(); i++) {
InformationDesc infoDesc = (InformationDesc) info.get(i);
if (localMatches(locale, infoDesc.getLocales()))
if (localMatches(locale, infoDesc.getLocales()))
- result.addAll(infoDesc.getItems(key) );
+ result.addAll(infoDesc.getItems(key));
}
return result;
@@ -378,17 +373,17 @@ public class JNLPFile {
* specified locale, os, and arch.
*/
public ResourcesDesc getResources(final Locale locale, final String os, final String arch) {
- return new ResourcesDesc(this, new Locale[] {locale}, new String[] {os}, new String[] {arch}) {
+ return new ResourcesDesc(this, new Locale[] { locale }, new String[] { os }, new String[] { arch }) {
public <T> List<T> getResources(Class<T> launchType) {
List<T> result = new ArrayList<T>();
- for (int i=0; i < resources.size(); i++) {
+ for (int i = 0; i < resources.size(); i++) {
ResourcesDesc rescDesc = resources.get(i);
if (localMatches(locale, rescDesc.getLocales())
- && stringMatches(os, rescDesc.getOS())
- && stringMatches(arch, rescDesc.getArch()))
- result.addAll(rescDesc.getResources(launchType) );
+ && stringMatches(os, rescDesc.getOS())
+ && stringMatches(arch, rescDesc.getArch()))
+ result.addAll(rescDesc.getResources(launchType));
}
result.addAll(sharedResources.getResources(launchType));
@@ -499,7 +494,6 @@ public class JNLPFile {
defaultLocale = locale;
}
-
/**
* Returns whether a locale is matched by one of more other
* locales. Only the non-empty language, country, and variant
@@ -515,7 +509,7 @@ public class JNLPFile {
if (available == null || available.length == 0)
return true;
- for (int i=0; i < available.length; i++) {
+ for (int i = 0; i < available.length; i++) {
String language = requested.getLanguage(); // "" but never null
String country = requested.getCountry();
String variant = requested.getVariant();
@@ -546,7 +540,7 @@ public class JNLPFile {
if (available == null || available.length == 0)
return true;
- for (int i=0; i < available.length; i++)
+ for (int i = 0; i < available.length; i++)
if (available[i] != null && available[i].startsWith(prefixStr))
return true;
@@ -579,11 +573,9 @@ public class JNLPFile {
launchType = parser.getLauncher(root);
component = parser.getComponent(root);
security = parser.getSecurity(root);
- }
- catch (ParseException ex) {
+ } catch (ParseException ex) {
throw ex;
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
if (JNLPRuntime.isDebug())
ex.printStackTrace();
diff --git a/netx/net/sourceforge/jnlp/JREDesc.java b/netx/net/sourceforge/jnlp/JREDesc.java
index 54538f4..5f7e8c2 100644
--- a/netx/net/sourceforge/jnlp/JREDesc.java
+++ b/netx/net/sourceforge/jnlp/JREDesc.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp;
import static net.sourceforge.jnlp.runtime.Translator.R;
@@ -49,7 +48,6 @@ public class JREDesc {
/** list of ResourceDesc objects */
private List resources;
-
/**
* Create a JRE descriptor.
*
@@ -139,10 +137,10 @@ public class JREDesc {
boolean lastCharacterIsDigit = true;
// the last character must be 0-9 or k/K/m/M
- char lastChar = Character.toLowerCase(heapSize.charAt(heapSize.length()-1));
+ char lastChar = Character.toLowerCase(heapSize.charAt(heapSize.length() - 1));
if ((lastChar < '0' || lastChar > '9')) {
lastCharacterIsDigit = false;
- if (lastChar != 'k' && lastChar!= 'm' ) {
+ if (lastChar != 'k' && lastChar != 'm') {
throw new ParseException(R("PBadHeapSize", heapSize));
}
}
@@ -152,7 +150,7 @@ public class JREDesc {
indexOfLastDigit = indexOfLastDigit - 1;
}
- String size = heapSize.substring(0,indexOfLastDigit);
+ String size = heapSize.substring(0, indexOfLastDigit);
try {
// check that the number is a number!
Integer.valueOf(size);
diff --git a/netx/net/sourceforge/jnlp/LaunchException.java b/netx/net/sourceforge/jnlp/LaunchException.java
index 2666387..9e682df 100644
--- a/netx/net/sourceforge/jnlp/LaunchException.java
+++ b/netx/net/sourceforge/jnlp/LaunchException.java
@@ -48,12 +48,11 @@ public class LaunchException extends Exception {
/** severity of the warning/error */
private String severity;
-
/**
* Creates a LaunchException without detail message.
*/
public LaunchException(JNLPFile file, Exception cause, String severity, String category, String summary, String description) {
- super(severity + ": " + category + ": "+ summary);
+ super(severity + ": " + category + ": " + summary);
this.file = file;
this.category = category;
@@ -79,7 +78,7 @@ public class LaunchException extends Exception {
* Creates a LaunchException with a cause and detail message
*/
public LaunchException(String message, Throwable cause) {
- this(message+": "+cause.getMessage());
+ this(message + ": " + cause.getMessage());
// replace with setCause when no longer 1.3 compatible
this.cause = cause;
diff --git a/netx/net/sourceforge/jnlp/LaunchHandler.java b/netx/net/sourceforge/jnlp/LaunchHandler.java
index 5176fb0..a0b106b 100644
--- a/netx/net/sourceforge/jnlp/LaunchHandler.java
+++ b/netx/net/sourceforge/jnlp/LaunchHandler.java
@@ -51,6 +51,7 @@ public interface LaunchHandler {
* @return true to allow the application to continue, false to stop it.
*/
public boolean validationError(LaunchException security);
+
// this method will probably be replaced when real security
// controller is in place.
diff --git a/netx/net/sourceforge/jnlp/Launcher.java b/netx/net/sourceforge/jnlp/Launcher.java
index 13e0f52..8fa7c1d 100644
--- a/netx/net/sourceforge/jnlp/Launcher.java
+++ b/netx/net/sourceforge/jnlp/Launcher.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp;
import static net.sourceforge.jnlp.runtime.Translator.R;
@@ -56,7 +55,6 @@ import javax.swing.text.html.parser.ParserDelegator;
import sun.awt.SunToolkit;
-
/**
* Launches JNLPFiles either in the foreground or background.<p>
*
@@ -74,7 +72,7 @@ public class Launcher {
// defines class Launcher.BgRunner, Launcher.TgThread
/** shared thread group */
- /*package*/ static final ThreadGroup mainGroup = new ThreadGroup(R("LAllThreadGroup"));
+ /*package*/static final ThreadGroup mainGroup = new ThreadGroup(R("LAllThreadGroup"));
/** the handler */
private LaunchHandler handler = null;
@@ -220,19 +218,18 @@ public class Launcher {
}
if (file instanceof PluginBridge && cont != null)
- tg = new TgThread(file, cont, true);
+ tg = new TgThread(file, cont, true);
else if (cont == null)
- tg = new TgThread(file);
+ tg = new TgThread(file);
else
- tg = new TgThread(file, cont);
+ tg = new TgThread(file, cont);
tg.start();
try {
tg.join();
- }
- catch (InterruptedException ex) {
- //By default, null is thrown here, and the message dialog is shown.
+ } catch (InterruptedException ex) {
+ //By default, null is thrown here, and the message dialog is shown.
throw launchWarning(new LaunchException(file, ex, R("LSMinor"), R("LCSystem"), R("LThreadInterrupted"), R("LThreadInterruptedInfo")));
}
@@ -339,7 +336,7 @@ public class Launcher {
"javaws";
commands.add(pathToWebstartBinary);
// use -Jargument format to pass arguments to the JVM through the launcher
- for (String arg: vmArgs) {
+ for (String arg : vmArgs) {
commands.add("-J" + arg);
}
commands.addAll(javawsArgs);
@@ -351,11 +348,9 @@ public class Launcher {
new StreamEater(p.getInputStream()).start();
p.getOutputStream().close();
- }
- catch (NullPointerException ex) {
+ } catch (NullPointerException ex) {
throw launchError(new LaunchException(null, null, R("LSFatal"), R("LCExternalLaunch"), R("LNetxJarMissing"), R("LNetxJarMissingInfo")));
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
throw launchError(new LaunchException(null, ex, R("LSFatal"), R("LCExternalLaunch"), R("LCouldNotLaunch"), R("LCouldNotLaunchInfo")));
}
}
@@ -369,24 +364,23 @@ public class Launcher {
try {
file = new JNLPFile(location, (Version) null, true, updatePolicy); // strict
- }
- catch (ParseException ex) {
+ } catch (ParseException ex) {
file = new JNLPFile(location, (Version) null, false, updatePolicy);
// only here if strict failed but lax did not fail
LaunchException lex =
- launchWarning(new LaunchException(file, ex, R("LSMinor"), R("LCFileFormat"), R("LNotToSpec"), R("LNotToSpecInfo")));
+ launchWarning(new LaunchException(file, ex, R("LSMinor"), R("LCFileFormat"), R("LNotToSpec"), R("LNotToSpecInfo")));
if (lex != null)
throw lex;
}
return file;
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
if (ex instanceof LaunchException)
throw (LaunchException) ex; // already sent to handler when first thrown
- else // IO and Parse
+ else
+ // IO and Parse
throw launchError(new LaunchException(null, ex, R("LSFatal"), R("LCReadError"), R("LCantRead"), R("LCantReadInfo")));
}
}
@@ -401,8 +395,10 @@ public class Launcher {
markNetxRunning();
Runtime.getRuntime().addShutdownHook(new Thread() {
- public void run() { markNetxStopped(); }
- });
+ public void run() {
+ markNetxStopped();
+ }
+ });
try {
@@ -435,7 +431,6 @@ public class Launcher {
}
}
-
ApplicationInstance app = createApplication(file);
app.initialize();
@@ -447,25 +442,26 @@ public class Launcher {
JARDesc mainJarDesc = file.getResources().getMainJAR();
File f = CacheUtil.getCacheFile(mainJarDesc.getLocation(), null);
if (f != null) {
- JarFile mainJar = new JarFile(f);
- mainName = mainJar.getManifest().
+ JarFile mainJar = new JarFile(f);
+ mainName = mainJar.getManifest().
getMainAttributes().getValue("Main-Class");
}
}
if (mainName == null)
throw launchError(new LaunchException(file, null,
- R("LSFatal"), R("LCClient"), R("LCantDetermineMainClass") ,
+ R("LSFatal"), R("LCClient"), R("LCantDetermineMainClass"),
R("LCantDetermineMainClassInfo")));
Class<?> mainClass = app.getClassLoader().loadClass(mainName);
- Method main = mainClass.getMethod("main", new Class<?>[] {String[].class} );
+ Method main = mainClass.getMethod("main", new Class<?>[] { String[].class });
String args[] = file.getApplication().getArguments();
SwingUtilities.invokeAndWait(new Runnable() {
// dummy method to force Event Dispatch Thread creation
- public void run(){}
+ public void run() {
+ }
});
setContextClassLoaderForAllThreads(app.getThreadGroup(), app.getClassLoader());
@@ -478,14 +474,12 @@ public class Launcher {
}
main.setAccessible(true);
- main.invoke(null, new Object[] { args } );
+ main.invoke(null, new Object[] { args });
return app;
- }
- catch (LaunchException lex) {
+ } catch (LaunchException lex) {
throw launchError(lex);
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
throw launchError(new LaunchException(file, ex, R("LSFatal"), R("LCLaunching"), R("LCouldNotLaunch"), R("LCouldNotLaunchInfo")));
}
}
@@ -509,10 +503,9 @@ public class Launcher {
threadCountGuess = threadCountGuess * 2;
threads = new Thread[threadCountGuess];
tg.enumerate(threads, true);
- } while (threads[threadCountGuess-1] != null);
-
+ } while (threads[threadCountGuess - 1] != null);
- for (Thread thread: threads) {
+ for (Thread thread : threads) {
if (thread != null) {
if (JNLPRuntime.isDebug()) {
System.err.println("Setting " + classLoader + " as the classloader for thread " + thread.getName());
@@ -548,11 +541,9 @@ public class Launcher {
applet.getAppletEnvironment().startApplet(); // this should be a direct call to applet instance
return applet;
- }
- catch (LaunchException lex) {
+ } catch (LaunchException lex) {
throw launchError(lex);
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
throw launchError(new LaunchException(file, ex, R("LSFatal"), R("LCLaunching"), R("LCouldNotLaunch"), R("LCouldNotLaunchInfo")));
}
}
@@ -568,11 +559,9 @@ public class Launcher {
AppletInstance applet = createApplet(file, enableCodeBase, cont);
applet.initialize();
return applet;
- }
- catch (LaunchException lex) {
+ } catch (LaunchException lex) {
throw launchError(lex);
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
throw launchError(new LaunchException(file, ex, R("LSFatal"), R("LCLaunching"), R("LCouldNotLaunch"), R("LCouldNotLaunchInfo")));
}
}
@@ -601,17 +590,17 @@ public class Launcher {
String appletName = file.getApplet().getMainClass();
- //Classloader chokes if there's '/' in the path to the main class.
- //Must replace with '.' instead.
- appletName = appletName.replace('/', '.');
+ //Classloader chokes if there's '/' in the path to the main class.
+ //Must replace with '.' instead.
+ appletName = appletName.replace('/', '.');
Class appletClass = loader.loadClass(appletName);
Applet applet = (Applet) appletClass.newInstance();
AppletInstance appletInstance;
if (cont == null)
- appletInstance = new AppletInstance(file, group, loader, applet);
+ appletInstance = new AppletInstance(file, group, loader, applet);
else
- appletInstance = new AppletInstance(file, group, loader, applet, cont);
+ appletInstance = new AppletInstance(file, group, loader, applet, cont);
group.setApplication(appletInstance);
loader.setApplication(appletInstance);
@@ -619,8 +608,7 @@ public class Launcher {
setContextClassLoaderForAllThreads(appletInstance.getThreadGroup(), appletInstance.getClassLoader());
return appletInstance;
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
throw launchError(new LaunchException(file, ex, R("LSFatal"), R("LCInit"), R("LInitApplet"), R("LInitAppletInfo")));
}
}
@@ -640,15 +628,14 @@ public class Launcher {
String appletName = file.getApplet().getMainClass();
- //Classloader chokes if there's '/' in the path to the main class.
- //Must replace with '.' instead.
- appletName = appletName.replace('/', '.');
+ //Classloader chokes if there's '/' in the path to the main class.
+ //Must replace with '.' instead.
+ appletName = appletName.replace('/', '.');
Class appletClass = loader.loadClass(appletName);
Applet applet = (Applet) appletClass.newInstance();
return applet;
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
throw launchError(new LaunchException(file, ex, R("LSFatal"), R("LCInit"), R("LInitApplet"), R("LInitAppletInfo")));
}
}
@@ -666,8 +653,7 @@ public class Launcher {
loader.setApplication(app);
return app;
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
throw new LaunchException(file, ex, R("LSFatal"), R("LCInit"), R("LInitApplication"), R("LInitApplicationInfo"));
}
}
@@ -770,7 +756,7 @@ public class Launcher {
fileLock = null;
if (JNLPRuntime.isDebug()) {
String file = JNLPRuntime.getConfiguration()
- .getProperty(DeploymentConfiguration.KEY_USER_NETX_RUNNING_FILE);
+ .getProperty(DeploymentConfiguration.KEY_USER_NETX_RUNNING_FILE);
System.out.println("Release shared lock on " + file);
}
} catch (IOException e) {
@@ -829,33 +815,32 @@ public class Launcher {
// Do not create new AppContext if we're using NetX and icedteaplugin.
// The plugin needs an AppContext too, but it has to be created earlier.
if (context && !isPlugin)
- SunToolkit.createNewAppContext();
+ SunToolkit.createNewAppContext();
doPerApplicationAppContextHacks();
if (isPlugin) {
- // Do not display download indicators if we're using gcjwebplugin.
- JNLPRuntime.setDefaultDownloadIndicator(null);
- application = getApplet(file, true, cont);
+ // Do not display download indicators if we're using gcjwebplugin.
+ JNLPRuntime.setDefaultDownloadIndicator(null);
+ application = getApplet(file, true, cont);
} else {
- if (file.isApplication())
- application = launchApplication(file);
- else if (file.isApplet())
- application = launchApplet(file, true, cont); // enable applet code base
- else if (file.isInstaller())
- application = launchInstaller(file);
- else
- throw launchError(new LaunchException(file, null,
+ if (file.isApplication())
+ application = launchApplication(file);
+ else if (file.isApplet())
+ application = launchApplet(file, true, cont); // enable applet code base
+ else if (file.isInstaller())
+ application = launchInstaller(file);
+ else
+ throw launchError(new LaunchException(file, null,
R("LSFatal"), R("LCClient"), R("LNotLaunchable"),
R("LNotLaunchableInfo")));
}
- }
- catch (LaunchException ex) {
+ } catch (LaunchException ex) {
ex.printStackTrace();
exception = ex;
// Exit if we can't launch the application.
if (exitOnFailure)
- System.exit(0);
+ System.exit(0);
}
}
@@ -869,7 +854,6 @@ public class Launcher {
};
-
/**
* This runnable is used by the <code>launchBackground</code>
* methods to launch a JNLP file from a separate thread.
@@ -889,8 +873,7 @@ public class Launcher {
launch(file);
if (location != null)
launch(location);
- }
- catch (LaunchException ex) {
+ } catch (LaunchException ex) {
// launch method communicates error conditions to the
// handler if it exists, otherwise we don't care because
// there's nothing that can be done about the exception.
diff --git a/netx/net/sourceforge/jnlp/NetxPanel.java b/netx/net/sourceforge/jnlp/NetxPanel.java
index 1cd4d1b..e049b10 100644
--- a/netx/net/sourceforge/jnlp/NetxPanel.java
+++ b/netx/net/sourceforge/jnlp/NetxPanel.java
@@ -38,22 +38,19 @@ import sun.awt.SunToolkit;
*
* @author Francis Kung <[email protected]>
*/
-public class NetxPanel extends AppletViewerPanel
-{
+public class NetxPanel extends AppletViewerPanel {
private PluginBridge bridge = null;
private boolean exitOnFailure = true;
private AppletInstance appInst = null;
private boolean appletAlive;
- public NetxPanel(URL documentURL, Hashtable<String,String> atts)
- {
+ public NetxPanel(URL documentURL, Hashtable<String, String> atts) {
super(documentURL, atts);
}
// overloaded constructor, called when initialized via plugin
- public NetxPanel(URL documentURL, Hashtable<String,String> atts,
- boolean exitOnFailure)
- {
+ public NetxPanel(URL documentURL, Hashtable<String, String> atts,
+ boolean exitOnFailure) {
this(documentURL, atts);
this.exitOnFailure = exitOnFailure;
this.appletAlive = true;
@@ -76,7 +73,7 @@ public class NetxPanel extends AppletViewerPanel
protected void runLoader() {
try {
- bridge = new PluginBridge(baseURL,
+ bridge = new PluginBridge(baseURL,
getDocumentBase(),
getJarFiles(),
getCode(),
@@ -84,46 +81,45 @@ public class NetxPanel extends AppletViewerPanel
getHeight(),
atts);
- doInit = true;
- dispatchAppletEvent(APPLET_LOADING, null);
- status = APPLET_LOAD;
-
- Launcher l = new Launcher(exitOnFailure);
-
- try {
- appInst = (AppletInstance) l.launch(bridge, this);
- } catch (LaunchException e) {
- // Assume user has indicated he does not trust the
- // applet.
- if (exitOnFailure)
- System.exit(0);
- }
- applet = appInst.getApplet();
-
- //On the other hand, if you create an applet this way, it'll work
- //fine. Note that you might to open visibility in sun.applet.AppletPanel
- //for this to work (the loader field, and getClassLoader).
- //loader = getClassLoader(getCodeBase(), getClassLoaderCacheKey());
- //applet = createApplet(loader);
-
- // This shows that when using NetX's JNLPClassLoader, keyboard input
- // won't make it to the applet, whereas using sun.applet.AppletClassLoader
- // works just fine.
-
- dispatchAppletEvent(APPLET_LOADING_COMPLETED, null);
-
- if (applet != null)
- {
- // Stick it in the frame
- applet.setStub(this);
- applet.setVisible(false);
- add("Center", applet);
- showAppletStatus("loaded");
- validate();
- }
+ doInit = true;
+ dispatchAppletEvent(APPLET_LOADING, null);
+ status = APPLET_LOAD;
+
+ Launcher l = new Launcher(exitOnFailure);
+
+ try {
+ appInst = (AppletInstance) l.launch(bridge, this);
+ } catch (LaunchException e) {
+ // Assume user has indicated he does not trust the
+ // applet.
+ if (exitOnFailure)
+ System.exit(0);
+ }
+ applet = appInst.getApplet();
+
+ //On the other hand, if you create an applet this way, it'll work
+ //fine. Note that you might to open visibility in sun.applet.AppletPanel
+ //for this to work (the loader field, and getClassLoader).
+ //loader = getClassLoader(getCodeBase(), getClassLoaderCacheKey());
+ //applet = createApplet(loader);
+
+ // This shows that when using NetX's JNLPClassLoader, keyboard input
+ // won't make it to the applet, whereas using sun.applet.AppletClassLoader
+ // works just fine.
+
+ dispatchAppletEvent(APPLET_LOADING_COMPLETED, null);
+
+ if (applet != null) {
+ // Stick it in the frame
+ applet.setStub(this);
+ applet.setVisible(false);
+ add("Center", applet);
+ showAppletStatus("loaded");
+ validate();
+ }
} catch (Exception e) {
this.appletAlive = false;
- e.printStackTrace();
+ e.printStackTrace();
}
}
@@ -134,13 +130,13 @@ public class NetxPanel extends AppletViewerPanel
// Reminder: Relax visibility in sun.applet.AppletPanel
protected synchronized void createAppletThread() {
// initialize JNLPRuntime in the main threadgroup
- synchronized(JNLPRuntime.initMutex) {
+ synchronized (JNLPRuntime.initMutex) {
//The custom NetX Policy and SecurityManager are set here.
if (!JNLPRuntime.isInitialized()) {
if (JNLPRuntime.isDebug())
System.out.println("initializing JNLPRuntime...");
- JNLPRuntime.initialize(false);
+ JNLPRuntime.initialize(false);
} else {
if (JNLPRuntime.isDebug())
System.out.println("JNLPRuntime already initialized");
diff --git a/netx/net/sourceforge/jnlp/Node.java b/netx/net/sourceforge/jnlp/Node.java
index a3f0aa2..3ab00ca 100644
--- a/netx/net/sourceforge/jnlp/Node.java
+++ b/netx/net/sourceforge/jnlp/Node.java
@@ -50,19 +50,19 @@ class Node {
List<Node> list = new ArrayList<Node>();
for (Enumeration e = xml.enumerateChildren(); e.hasMoreElements();)
- list.add( new Node((XMLElement)e.nextElement()) );
+ list.add(new Node((XMLElement) e.nextElement()));
- children = list.toArray( new Node[list.size()] );
+ children = list.toArray(new Node[list.size()]);
- for (int i=0; i < children.length-1; i++)
- children[i].next = children[i+1];
+ for (int i = 0; i < children.length - 1; i++)
+ children[i].next = children[i + 1];
}
return children;
}
String getAttribute(String name) {
- return (String)xml.getAttribute(name);
+ return (String) xml.getAttribute(name);
}
String getNodeName() {
diff --git a/netx/net/sourceforge/jnlp/PackageDesc.java b/netx/net/sourceforge/jnlp/PackageDesc.java
index 22822fb..88fcc17 100644
--- a/netx/net/sourceforge/jnlp/PackageDesc.java
+++ b/netx/net/sourceforge/jnlp/PackageDesc.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp;
import java.io.*;
@@ -38,7 +37,6 @@ public class PackageDesc {
/** whether the package includes subpackages */
private boolean recursive;
-
/**
* Create a package descriptor.
*
@@ -64,10 +62,10 @@ public class PackageDesc {
// form 2: package.*
if (name.endsWith(".*")) {
- String pkName = name.substring(0, name.length()-1);
+ String pkName = name.substring(0, name.length() - 1);
if (className.startsWith(pkName)) {
- String postfix = className.substring(pkName.length()+1);
+ String postfix = className.substring(pkName.length() + 1);
if (recursive || -1 == postfix.indexOf("."))
return true;
diff --git a/netx/net/sourceforge/jnlp/ParseException.java b/netx/net/sourceforge/jnlp/ParseException.java
index 9ed86e1..0fcb9bc 100644
--- a/netx/net/sourceforge/jnlp/ParseException.java
+++ b/netx/net/sourceforge/jnlp/ParseException.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp;
import java.io.*;
@@ -36,7 +35,6 @@ public class ParseException extends Exception {
/** the original exception */
private Throwable cause = null;
-
/**
* Create a parse exception with the specified message.
*/
diff --git a/netx/net/sourceforge/jnlp/Parser.java b/netx/net/sourceforge/jnlp/Parser.java
index c5b7a34..5c9ad01 100644
--- a/netx/net/sourceforge/jnlp/Parser.java
+++ b/netx/net/sourceforge/jnlp/Parser.java
@@ -15,7 +15,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp;
import static net.sourceforge.jnlp.runtime.Translator.R;
@@ -66,7 +65,6 @@ class Parser {
};
*/
-
/** the supported JNLP file versions */
private static Version supportedVersions = new Version("1.0 1.1 1.2 1.3 1.4 1.5 1.6 6.0");
@@ -98,7 +96,6 @@ class Parser {
/** whether to allow extensions to the JNLP specification */
private boolean allowExtensions; // true if extensions to JNLP spec are ok
-
/**
* Create a parser for the JNLP file. If the location
* parameters is not null it is used as the default codebase
@@ -128,7 +125,7 @@ class Parser {
// JNLP tag information
this.spec = getVersion(root, "spec", "1.0+");
this.codebase = addSlash(getURL(root, "codebase", base));
- this.base = (codebase!=null) ? codebase : base; // if codebase not specified use default codebase
+ this.base = (codebase != null) ? codebase : base; // if codebase not specified use default codebase
fileLocation = getURL(root, "href", this.base);
// ensure version is supported
@@ -188,7 +185,7 @@ class Parser {
Check check;
String checkValue = getAttribute(node, "check", "timeout");
if (checkValue.equals("always")) {
- check = Check.ALWAYS;
+ check = Check.ALWAYS;
} else if (checkValue.equals("timeout")) {
check = Check.TIMEOUT;
} else if (checkValue.equals("background")) {
@@ -234,8 +231,7 @@ class Parser {
* @throws ParseException if the JNLP file is invalid
*/
public List<ResourcesDesc> getResources(Node parent, boolean j2se)
- throws ParseException
- {
+ throws ParseException {
List<ResourcesDesc> result = new ArrayList<ResourcesDesc>();
Node resources[] = getChildNodes(parent, "resources");
@@ -244,7 +240,7 @@ class Parser {
throw new ParseException(R("PNoResources"));
// create objects from the resources sections
- for (int i=0; i < resources.length; i++)
+ for (int i = 0; i < resources.length; i++)
result.add(getResourcesDesc(resources[i], j2se));
return result;
@@ -262,7 +258,7 @@ class Parser {
// create resources
ResourcesDesc resources =
- new ResourcesDesc(file,
+ new ResourcesDesc(file,
getLocales(node),
splitString(getAttribute(node, "os", null)),
splitString(getAttribute(node, "arch", null)));
@@ -282,7 +278,7 @@ class Parser {
if (strict)
throw new ParseException(R("PExtensionHasJ2SE"));
if (!j2se)
- resources.addResource( getJRE(child) );
+ resources.addResource(getJRE(child));
else
throw new ParseException(R("PInnerJ2SE"));
}
@@ -302,13 +298,13 @@ class Parser {
}
if ("extension".equals(name))
- resources.addResource( getExtension(child) );
+ resources.addResource(getExtension(child));
if ("property".equals(name))
- resources.addResource( getProperty(child) );
+ resources.addResource(getProperty(child));
if ("package".equals(name))
- resources.addResource( getPackage(child) );
+ resources.addResource(getPackage(child));
child = child.getNextSibling();
}
@@ -325,7 +321,7 @@ class Parser {
public JREDesc getJRE(Node node) throws ParseException {
Version version = getVersion(node, "version", null);
URL location = getURL(node, "href", base);
- String vmArgs = getAttribute(node, "java-vm-args",null);
+ String vmArgs = getAttribute(node, "java-vm-args", null);
try {
checkVMArgs(vmArgs);
} catch (IllegalArgumentException argumentException) {
@@ -341,8 +337,6 @@ class Parser {
return new JREDesc(version, location, vmArgs, initialHeap, maxHeap, resources);
}
-
-
/**
* Returns the JAR element at the specified node.
*
@@ -380,7 +374,7 @@ class Parser {
ExtensionDesc ext = new ExtensionDesc(name, version, location);
Node dload[] = getChildNodes(node, "ext-download");
- for (int i=0; i < dload.length; i++) {
+ for (int i = 0; i < dload.length; i++) {
boolean lazy = "lazy".equals(getAttribute(dload[i], "download", "eager"));
ext.addPart(getRequiredAttribute(dload[i], "ext-part", null),
@@ -430,8 +424,7 @@ class Parser {
* @throws ParseException if the JNLP file is invalid
*/
public List<InformationDesc> getInfo(Node parent)
- throws ParseException
- {
+ throws ParseException {
List<InformationDesc> result = new ArrayList<InformationDesc>();
Node info[] = getChildNodes(parent, "information");
@@ -440,7 +433,7 @@ class Parser {
throw new ParseException(R("PNoInfoElement"));
// create objects from the info sections
- for (int i=0; i < info.length; i++)
+ for (int i = 0; i < info.length; i++)
result.add(getInformationDesc(info[i]));
return result;
@@ -515,12 +508,12 @@ class Parser {
* @param value the info object to add (icon or string)
*/
protected void addInfo(InformationDesc info, Node node, String mod, Object value) {
- String modStr = (mod == null) ? "" : "-"+mod;
+ String modStr = (mod == null) ? "" : "-" + mod;
if (node == null)
return;
- info.addItem(node.getNodeName()+modStr, value);
+ info.addItem(node.getNodeName() + modStr, value);
}
/**
@@ -586,7 +579,7 @@ class Parser {
if (security != null)
if (getChildNode(security, "all-permissions") != null
- || getChildNode(security, "j2ee-application-client-permissions") != null)
+ || getChildNode(security, "j2ee-application-client-permissions") != null)
return true;
return false;
@@ -606,8 +599,8 @@ class Parser {
public Object getLauncher(Node parent) throws ParseException {
// check for other than one application type
if (1 < getChildNodes(parent, "applet-desc").length
- + getChildNodes(parent, "application-desc").length
- + getChildNodes(parent, "installer-desc").length)
+ + getChildNodes(parent, "application-desc").length
+ + getChildNodes(parent, "installer-desc").length)
throw new ParseException(R("PTwoDescriptors"));
Node child = parent.getFirstChild();
@@ -637,15 +630,14 @@ class Parser {
String name = getRequiredAttribute(node, "name", R("PUnknownApplet"));
String main = getRequiredAttribute(node, "main-class", null);
URL docbase = getURL(node, "documentbase", base);
- Map<String,String> paramMap = new HashMap<String,String>();
+ Map<String, String> paramMap = new HashMap<String, String>();
int width = 0;
int height = 0;
try {
width = Integer.parseInt(getRequiredAttribute(node, "width", "100"));
height = Integer.parseInt(getRequiredAttribute(node, "height", "100"));
- }
- catch (NumberFormatException nfe) {
+ } catch (NumberFormatException nfe) {
if (width <= 0)
throw new ParseException(R("PBadWidth"));
throw new ParseException(R("PBadWidth"));
@@ -653,7 +645,7 @@ class Parser {
// read params
Node params[] = getChildNodes(node, "param");
- for (int i=0; i < params.length; i++) {
+ for (int i = 0; i < params.length; i++) {
paramMap.put(getRequiredAttribute(params[i], "name", null),
getRequiredAttribute(params[i], "value", ""));
}
@@ -675,14 +667,14 @@ class Parser {
// read parameters
Node args[] = getChildNodes(node, "argument");
- for (int i=0; i < args.length; i++) {
+ for (int i = 0; i < args.length; i++) {
//argsList.add( args[i].getNodeValue() );
//This approach was not finding the argument text
- argsList.add( getSpanText(args[i]) );
+ argsList.add(getSpanText(args[i]));
}
- String argStrings[] = argsList.toArray( new String[argsList.size()] );
+ String argStrings[] = argsList.toArray(new String[argsList.size()]);
return new ApplicationDesc(main, argStrings);
}
@@ -749,7 +741,7 @@ class Parser {
throw new ParseException(R("PTwoDesktops"));
}
showOnDesktop = true;
- } else if ("menu".equals(name)){
+ } else if ("menu".equals(name)) {
if (menu != null && strict) {
throw new ParseException(R("PTwoMenus"));
}
@@ -775,7 +767,6 @@ class Parser {
return new MenuDesc(subMenu);
}
-
/**
* Returns the related-content descriptor.
*/
@@ -844,21 +835,22 @@ class Parser {
while (true) {
part.append(st.nextToken());
- if (st.hasMoreTokens() && part.charAt(part.length()-1) == '\\')
- part.setCharAt(part.length()-1, ' '); // join with the space
+ if (st.hasMoreTokens() && part.charAt(part.length() - 1) == '\\')
+ part.setCharAt(part.length() - 1, ' '); // join with the space
else
break; // bizarre while format gets \ at end of string right (no extra space added at end)
}
// delete \ quote chars
- for (int i = part.length(); i-- > 0;) // sweet syntax for reverse loop
+ for (int i = part.length(); i-- > 0;)
+ // sweet syntax for reverse loop
if (part.charAt(i) == '\\')
part.deleteCharAt(i--); // and skip previous char so \\ becomes \
- result.add( part.toString() );
+ result.add(part.toString());
}
- return result.toArray(new String[result.size()] );
+ return result.toArray(new String[result.size()]);
}
/**
@@ -869,15 +861,15 @@ class Parser {
public Locale[] getLocales(Node node) {
List<Locale> locales = new ArrayList<Locale>();
String localeParts[] =
- splitString(getAttribute(node, "locale", ""));
+ splitString(getAttribute(node, "locale", ""));
- for (int i=0; i < localeParts.length; i++) {
- Locale l = getLocale( localeParts[i] );
+ for (int i = 0; i < localeParts.length; i++) {
+ Locale l = getLocale(localeParts[i]);
if (l != null)
locales.add(l);
}
- return locales.toArray(new Locale[locales.size()] );
+ return locales.toArray(new Locale[locales.size()]);
}
/**
@@ -890,15 +882,13 @@ class Parser {
return null;
String language = localeStr.substring(0, 2);
- String country = (localeStr.length()<5) ? "" : localeStr.substring(3, 5);
- String variant = (localeStr.length()<7) ? "" : localeStr.substring(6, 8);
+ String country = (localeStr.length() < 5) ? "" : localeStr.substring(3, 5);
+ String variant = (localeStr.length() < 7) ? "" : localeStr.substring(6, 8);
// null is not allowed n locale but "" is
return new Locale(language, country, variant);
}
-
-
// XML junk
/**
@@ -954,10 +944,9 @@ class Parser {
child = child.getNextSibling();
}
- return result.toArray( new Node[result.size()] );
+ return result.toArray(new Node[result.size()]);
}
-
/**
* Returns a URL with a trailing / appended to it if there is no
* trailing slash on the specifed URL.
@@ -968,16 +957,14 @@ class Parser {
if (!source.toString().endsWith("/")) {
try {
- source = new URL(source.toString()+"/");
- }
- catch (MalformedURLException ex) {
+ source = new URL(source.toString() + "/");
+ } catch (MalformedURLException ex) {
}
}
return source;
}
-
/**
* Returns the same result as getURL except that a
* ParseException is thrown if the attribute is null or empty.
@@ -995,7 +982,6 @@ class Parser {
return getURL(node, name, base);
}
-
/**
* Returns a URL object from a href string relative to the
* code base. If the href denotes a relative URL, it must
@@ -1018,23 +1004,21 @@ class Parser {
else {
try {
return new URL(href);
- }
- catch (MalformedURLException ex) {
+ } catch (MalformedURLException ex) {
// is relative
}
URL result = new URL(base, href);
// check for going above the codebase
- if (! result.toString().startsWith( base.toString()) )
+ if (!result.toString().startsWith(base.toString()))
if (strict)
throw new ParseException(R("PUrlNotInCodebase", node.getNodeName(), href, base));
return result;
}
- }
- catch (MalformedURLException ex) {
+ } catch (MalformedURLException ex) {
if (base == null)
throw new ParseException(R("PBadNonrelativeUrl", node.getNodeName(), href));
else
@@ -1074,13 +1058,13 @@ class Parser {
String[] arguments = vmArgs.split(" ");
boolean argumentIsValid = false;
- for (String argument: arguments) {
+ for (String argument : arguments) {
argumentIsValid = false;
if (validArguments.contains(argument)) {
argumentIsValid = true;
} else {
- for (String validStartingArgument: validStartingArguments) {
+ for (String validStartingArgument : validStartingArguments) {
if (argument.startsWith(validStartingArgument)) {
argumentIsValid = true;
break;
@@ -1102,33 +1086,33 @@ class Parser {
*/
private String[] getValidVMArguments() {
return new String[] {
- "-d32", /* use a 32-bit data model if available */
- "-client", /* to select the client VM */
- "-server", /* to select the server VM */
- "-verbose", /* enable verbose output */
- "-version", /* print product version and exit */
- "-showversion", /* print product version and continue */
- "-help", /* print this help message */
- "-X", /* print help on non-standard options */
- "-ea", /* enable assertions */
- "-enableassertions", /* enable assertions */
- "-da", /* disable assertions */
- "-disableassertions", /* disable assertions */
- "-esa", /* enable system assertions */
- "-enablesystemassertions", /* enable system assertions */
- "-dsa", /* disable system assertione */
- "-disablesystemassertions", /* disable system assertione */
- "-Xmixed", /* mixed mode execution (default) */
- "-Xint", /* interpreted mode execution only */
- "-Xnoclassgc", /* disable class garbage collection */
- "-Xincgc", /* enable incremental garbage collection */
- "-Xbatch", /* disable background compilation */
- "-Xprof", /* output cpu profiling data */
- "-Xdebug", /* enable remote debugging */
- "-Xfuture", /* enable strictest checks, anticipating future default */
- "-Xrs", /* reduce use of OS signals by Java/VM (see documentation) */
- "-XX:+ForceTimeHighResolution", /* use high resolution timer */
- "-XX:-ForceTimeHighResolution", /* use low resolution (default) */
+ "-d32", /* use a 32-bit data model if available */
+ "-client", /* to select the client VM */
+ "-server", /* to select the server VM */
+ "-verbose", /* enable verbose output */
+ "-version", /* print product version and exit */
+ "-showversion", /* print product version and continue */
+ "-help", /* print this help message */
+ "-X", /* print help on non-standard options */
+ "-ea", /* enable assertions */
+ "-enableassertions", /* enable assertions */
+ "-da", /* disable assertions */
+ "-disableassertions", /* disable assertions */
+ "-esa", /* enable system assertions */
+ "-enablesystemassertions", /* enable system assertions */
+ "-dsa", /* disable system assertione */
+ "-disablesystemassertions", /* disable system assertione */
+ "-Xmixed", /* mixed mode execution (default) */
+ "-Xint", /* interpreted mode execution only */
+ "-Xnoclassgc", /* disable class garbage collection */
+ "-Xincgc", /* enable incremental garbage collection */
+ "-Xbatch", /* disable background compilation */
+ "-Xprof", /* output cpu profiling data */
+ "-Xdebug", /* enable remote debugging */
+ "-Xfuture", /* enable strictest checks, anticipating future default */
+ "-Xrs", /* reduce use of OS signals by Java/VM (see documentation) */
+ "-XX:+ForceTimeHighResolution", /* use high resolution timer */
+ "-XX:-ForceTimeHighResolution", /* use low resolution (default) */
};
}
@@ -1140,26 +1124,26 @@ class Parser {
*/
private String[] getValidStartingVMArguments() {
return new String[] {
- "-ea", /* enable assertions for classes */
- "-enableassertions", /* enable assertions for classes */
- "-da", /* disable assertions for classes */
- "-disableassertions", /* disable assertions for classes */
- "-verbose", /* enable verbose output */
- "-Xms", /* set initial Java heap size */
- "-Xmx", /* set maximum Java heap size */
- "-Xss", /* set java thread stack size */
- "-XX:NewRatio", /* set Ratio of new/old gen sizes */
- "-XX:NewSize", /* set initial size of new generation */
- "-XX:MaxNewSize", /* set max size of new generation */
- "-XX:PermSize", /* set initial size of permanent gen */
- "-XX:MaxPermSize", /* set max size of permanent gen */
- "-XX:MaxHeapFreeRatio", /* heap free percentage (default 70) */
- "-XX:MinHeapFreeRatio", /* heap free percentage (default 40) */
- "-XX:UseSerialGC", /* use serial garbage collection */
- "-XX:ThreadStackSize", /* thread stack size (in KB) */
- "-XX:MaxInlineSize", /* set max num of bytecodes to inline */
- "-XX:ReservedCodeCacheSize", /* Reserved code cache size (bytes) */
- "-XX:MaxDirectMemorySize",
+ "-ea", /* enable assertions for classes */
+ "-enableassertions", /* enable assertions for classes */
+ "-da", /* disable assertions for classes */
+ "-disableassertions", /* disable assertions for classes */
+ "-verbose", /* enable verbose output */
+ "-Xms", /* set initial Java heap size */
+ "-Xmx", /* set maximum Java heap size */
+ "-Xss", /* set java thread stack size */
+ "-XX:NewRatio", /* set Ratio of new/old gen sizes */
+ "-XX:NewSize", /* set initial size of new generation */
+ "-XX:MaxNewSize", /* set max size of new generation */
+ "-XX:PermSize", /* set initial size of permanent gen */
+ "-XX:MaxPermSize", /* set max size of permanent gen */
+ "-XX:MaxHeapFreeRatio", /* heap free percentage (default 70) */
+ "-XX:MinHeapFreeRatio", /* heap free percentage (default 40) */
+ "-XX:UseSerialGC", /* use serial garbage collection */
+ "-XX:ThreadStackSize", /* thread stack size (in KB) */
+ "-XX:MaxInlineSize", /* set max num of bytecodes to inline */
+ "-XX:ReservedCodeCacheSize", /* Reserved code cache size (bytes) */
+ "-XX:MaxDirectMemorySize",
};
}
@@ -1200,7 +1184,7 @@ class Parser {
// String result = ((Element) node).getAttribute(name);
String result = node.getAttribute(name);
- if (result == null || result.length()==0)
+ if (result == null || result.length() == 0)
return defaultValue;
return result;
@@ -1242,22 +1226,20 @@ class Parser {
// Clean the jnlp xml file of all comments before passing
// it to the parser.
new Thread(
- new Runnable(){
- public void run(){
- (new XMLElement()).sanitizeInput(isr, pout);
- try {
- pout.close();
- } catch (IOException ioe) {
- ioe.printStackTrace();
+ new Runnable() {
+ public void run() {
+ (new XMLElement()).sanitizeInput(isr, pout);
+ try {
+ pout.close();
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ }
}
- }
- }
- ).start();
+ }).start();
xml.parseFromReader(new InputStreamReader(pin));
Node jnlpNode = new Node(xml);
return jnlpNode;
- }
- catch(Exception ex) {
+ } catch (Exception ex) {
throw new ParseException(R("PBadXML"), ex);
}
}
@@ -1268,7 +1250,7 @@ class Parser {
* @param input the InputStream
* @return a String representation of encoding
*/
- private static String getEncoding(InputStream input) throws IOException{
+ private static String getEncoding(InputStream input) throws IOException {
//Fixme: This only recognizes UTF-8, UTF-16, and
//UTF-32, which is enough to parse the prolog portion of xml to
//find out the exact encoding (if it exists). The reason being
@@ -1300,26 +1282,26 @@ class Parser {
}
}
} else if (s[0] == 254 && s[1] == 255 && (s[2] != 0 ||
- s[3] != 0)) {
+ s[3] != 0)) {
encoding = "UTF-16";
} else if (s[0] == 0 && s[1] == 0 && s[2] == 254 &&
- s[3] == 255) {
+ s[3] == 255) {
encoding = "X-UTF-32BE-BOM";
} else if (s[0] == 0 && s[1] == 0 && s[2] == 0 &&
- s[3] == 60) {
+ s[3] == 60) {
encoding = "UTF-32BE";
} else if (s[0] == 60 && s[1] == 0 && s[2] == 0 &&
- s[3] == 0) {
+ s[3] == 0) {
encoding = "UTF-32LE";
} else if (s[0] == 0 && s[1] == 60 && s[2] == 0 &&
- s[3] == 63) {
+ s[3] == 63) {
encoding = "UTF-16BE";
} else if (s[0] == 60 && s[1] == 0 && s[2] == 63 &&
- s[3] == 0) {
+ s[3] == 0) {
encoding = "UTF-16LE";
}
diff --git a/netx/net/sourceforge/jnlp/PluginBridge.java b/netx/net/sourceforge/jnlp/PluginBridge.java
index 56538e7..75e96e5 100644
--- a/netx/net/sourceforge/jnlp/PluginBridge.java
+++ b/netx/net/sourceforge/jnlp/PluginBridge.java
@@ -34,33 +34,30 @@ import java.util.Map;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
-
-public class PluginBridge extends JNLPFile
-{
+public class PluginBridge extends JNLPFile {
String name;
String[] jars = new String[0];
String[] cacheJars = new String[0];
String[] cacheExJars = new String[0];
- Hashtable<String,String> atts;
+ Hashtable<String, String> atts;
public PluginBridge(URL codebase, URL documentBase, String jar, String main,
- int width, int height, Hashtable<String,String> atts)
- throws Exception
- {
+ int width, int height, Hashtable<String, String> atts)
+ throws Exception {
specVersion = new Version("1.0");
fileVersion = new Version("1.1");
this.codeBase = codebase;
this.sourceLocation = documentBase;
- if (atts.containsKey("jnlp_href")){
+ if (atts.containsKey("jnlp_href")) {
try {
URL jnlp = new URL(codeBase.toExternalForm() + atts.get("jnlp_href"));
JNLPFile jnlpFile = new JNLPFile(jnlp);
- Map<String,String> jnlpParams = jnlpFile.getApplet().getParameters();
+ Map<String, String> jnlpParams = jnlpFile.getApplet().getParameters();
// Change the parameter name to lowercase to follow conventions.
- for (Map.Entry<String,String> entry : jnlpParams.entrySet()){
+ for (Map.Entry<String, String> entry : jnlpParams.entrySet()) {
atts.put(entry.getKey().toLowerCase(), entry.getValue());
}
} catch (MalformedURLException e) {
@@ -86,7 +83,7 @@ public class PluginBridge extends JNLPFile
String[] jars = cacheArchive.split(",");
cacheJars = new String[jars.length];
- for (int i=0; i < jars.length; i++) {
+ for (int i = 0; i < jars.length; i++) {
cacheJars[i] = jars[i].trim();
@@ -103,10 +100,10 @@ public class PluginBridge extends JNLPFile
if (jar != null && jar.length() > 0) {
this.jars = jar.split(",");
-
+
// trim white spaces
- for (int i =0; i < this.jars.length; i++) {
- this.jars[i] = this.jars[i].trim();
+ for (int i = 0; i < this.jars.length; i++) {
+ this.jars[i] = this.jars[i].trim();
}
if (JNLPRuntime.isDebug()) {
@@ -139,16 +136,13 @@ public class PluginBridge extends JNLPFile
documentBase;
}
- public String getTitle()
- {
+ public String getTitle() {
return name;
}
- public InformationDesc getInformation(final Locale locale)
- {
- return new InformationDesc(this, new Locale[] {locale}) {
- protected List<Object> getItems(Object key)
- {
+ public InformationDesc getInformation(final Locale locale) {
+ return new InformationDesc(this, new Locale[] { locale }) {
+ protected List<Object> getItems(Object key) {
// Should we populate this list with applet attribute tags?
return new ArrayList<Object>();
}
@@ -156,19 +150,15 @@ public class PluginBridge extends JNLPFile
}
public ResourcesDesc getResources(final Locale locale, final String os,
- final String arch)
- {
- return new ResourcesDesc(this, new Locale[] {locale}, new String[] {os},
- new String[] {arch}) {
+ final String arch) {
+ return new ResourcesDesc(this, new Locale[] { locale }, new String[] { os },
+ new String[] { arch }) {
@Override
- public <T> List<T> getResources(Class<T> launchType)
- {
+ public <T> List<T> getResources(Class<T> launchType) {
// Need to add the JAR manually...
//should this be done to sharedResources on init?
- if (launchType.equals(JARDesc.class))
- {
- try
- {
+ if (launchType.equals(JARDesc.class)) {
+ try {
List<JARDesc> jarDescs = new ArrayList<JARDesc>();
jarDescs.addAll(sharedResources.getResources(JARDesc.class));
@@ -233,13 +223,13 @@ public class PluginBridge extends JNLPFile
}
// We know this is a safe list of JarDesc objects
@SuppressWarnings("unchecked")
- List<T> result = (List<T>) jarDescs;
+ List<T> result = (List<T>) jarDescs;
return result;
+ } catch (MalformedURLException ex) { /* Ignored */
}
- catch (MalformedURLException ex) { /* Ignored */ }
}
return sharedResources.getResources(launchType);
- }
+ }
@Override
public JARDesc[] getJARs() {
@@ -247,8 +237,7 @@ public class PluginBridge extends JNLPFile
return jarDescs.toArray(new JARDesc[jarDescs.size()]);
}
- public void addResource(Object resource)
- {
+ public void addResource(Object resource) {
// todo: honor the current locale, os, arch values
sharedResources.addResource(resource);
}
@@ -259,12 +248,15 @@ public class PluginBridge extends JNLPFile
public boolean isApplet() {
return true;
}
+
public boolean isApplication() {
return false;
}
+
public boolean isComponent() {
return false;
}
+
public boolean isInstaller() {
return false;
}
diff --git a/netx/net/sourceforge/jnlp/PropertyDesc.java b/netx/net/sourceforge/jnlp/PropertyDesc.java
index c96b748..14248a8 100644
--- a/netx/net/sourceforge/jnlp/PropertyDesc.java
+++ b/netx/net/sourceforge/jnlp/PropertyDesc.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp;
import java.io.*;
@@ -35,7 +34,6 @@ public class PropertyDesc {
/** the value */
private String value;
-
/**
* Creates a property descriptor.
*
diff --git a/netx/net/sourceforge/jnlp/ResourcesDesc.java b/netx/net/sourceforge/jnlp/ResourcesDesc.java
index ca6f1dd..abd3e35 100644
--- a/netx/net/sourceforge/jnlp/ResourcesDesc.java
+++ b/netx/net/sourceforge/jnlp/ResourcesDesc.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp;
import java.io.*;
@@ -44,6 +43,7 @@ public class ResourcesDesc {
/** list of jars, packages, properties, and extensions */
private List<Object> resources = new ArrayList<Object>();
+
// mixed list makes easier for lookup code
/**
@@ -67,7 +67,7 @@ public class ResourcesDesc {
*/
public JREDesc[] getJREs() {
List<JREDesc> resources = getResources(JREDesc.class);
- return resources.toArray( new JREDesc[resources.size()] );
+ return resources.toArray(new JREDesc[resources.size()]);
}
/**
@@ -78,7 +78,7 @@ public class ResourcesDesc {
public JARDesc getMainJAR() {
JARDesc jars[] = getJARs();
- for (int i=0; i < jars.length; i++)
+ for (int i = 0; i < jars.length; i++)
if (jars[i].isMain())
return jars[i];
@@ -93,7 +93,7 @@ public class ResourcesDesc {
*/
public JARDesc[] getJARs() {
List<JARDesc> resources = getResources(JARDesc.class);
- return resources.toArray( new JARDesc[resources.size()] );
+ return resources.toArray(new JARDesc[resources.size()]);
}
/**
@@ -107,11 +107,11 @@ public class ResourcesDesc {
for (int i = resources.size(); i-- > 0;) {
JARDesc jar = resources.get(i);
- if (!(""+jar.getPart()).equals(""+partName))
+ if (!("" + jar.getPart()).equals("" + partName))
resources.remove(i);
}
- return resources.toArray( new JARDesc[resources.size()] );
+ return resources.toArray(new JARDesc[resources.size()]);
}
/**
@@ -119,7 +119,7 @@ public class ResourcesDesc {
*/
public ExtensionDesc[] getExtensions() {
List<ExtensionDesc> resources = getResources(ExtensionDesc.class);
- return resources.toArray( new ExtensionDesc[resources.size()] );
+ return resources.toArray(new ExtensionDesc[resources.size()]);
}
/**
@@ -127,7 +127,7 @@ public class ResourcesDesc {
*/
public PackageDesc[] getPackages() {
List<PackageDesc> resources = getResources(PackageDesc.class);
- return resources.toArray( new PackageDesc[resources.size()] );
+ return resources.toArray(new PackageDesc[resources.size()]);
}
/**
@@ -146,7 +146,7 @@ public class ResourcesDesc {
resources.remove(i);
}
- return resources.toArray( new PackageDesc[resources.size()] );
+ return resources.toArray(new PackageDesc[resources.size()]);
}
/**
@@ -154,18 +154,18 @@ public class ResourcesDesc {
*/
public PropertyDesc[] getProperties() {
List<PropertyDesc> resources = getResources(PropertyDesc.class);
- return resources.toArray( new PropertyDesc[resources.size()] );
+ return resources.toArray(new PropertyDesc[resources.size()]);
}
/**
* Returns the properties as a map.
*/
- public Map<String,String> getPropertiesMap() {
- Map<String,String> properties = new HashMap<String,String>();
+ public Map<String, String> getPropertiesMap() {
+ Map<String, String> properties = new HashMap<String, String>();
List<PropertyDesc> resources = getResources(PropertyDesc.class);
- for (int i=0; i < resources.size(); i++) {
+ for (int i = 0; i < resources.size(); i++) {
PropertyDesc prop = resources.get(i);
- properties.put( prop.getKey(), prop.getValue() );
+ properties.put(prop.getKey(), prop.getValue());
}
return properties;
@@ -208,8 +208,8 @@ public class ResourcesDesc {
public <T> List<T> getResources(Class<T> type) {
List<T> result = new ArrayList<T>();
- for (int i=0; i < resources.size(); i++)
- if ( type.isAssignableFrom(resources.get(i).getClass()) )
+ for (int i = 0; i < resources.size(); i++)
+ if (type.isAssignableFrom(resources.get(i).getClass()))
result.add(type.cast(resources.get(i)));
return result;
diff --git a/netx/net/sourceforge/jnlp/SecurityDesc.java b/netx/net/sourceforge/jnlp/SecurityDesc.java
index c5ddec4..c695bec 100644
--- a/netx/net/sourceforge/jnlp/SecurityDesc.java
+++ b/netx/net/sourceforge/jnlp/SecurityDesc.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp;
import java.io.*;
@@ -67,75 +66,75 @@ public class SecurityDesc {
/** basic permissions for restricted mode */
private static Permission j2eePermissions[] = {
- new AWTPermission("accessClipboard"),
- // disabled because we can't at this time prevent an
- // application from accessing other applications' event
- // queues, or even prevent access to security dialog queues.
- //
- // new AWTPermission("accessEventQueue"),
- new RuntimePermission("exitVM"),
- new RuntimePermission("loadLibrary"),
- new RuntimePermission("queuePrintJob"),
- new SocketPermission("*", "connect"),
- new SocketPermission("localhost:1024-", "accept, listen"),
- new FilePermission("*", "read, write"),
- new PropertyPermission("*", "read"),
+ new AWTPermission("accessClipboard"),
+ // disabled because we can't at this time prevent an
+ // application from accessing other applications' event
+ // queues, or even prevent access to security dialog queues.
+ //
+ // new AWTPermission("accessEventQueue"),
+ new RuntimePermission("exitVM"),
+ new RuntimePermission("loadLibrary"),
+ new RuntimePermission("queuePrintJob"),
+ new SocketPermission("*", "connect"),
+ new SocketPermission("localhost:1024-", "accept, listen"),
+ new FilePermission("*", "read, write"),
+ new PropertyPermission("*", "read"),
};
/** basic permissions for restricted mode */
private static Permission sandboxPermissions[] = {
- new SocketPermission("localhost:1024-", "listen"),
- // new SocketPermission("<DownloadHost>", "connect, accept"), // added by code
- new PropertyPermission("java.version", "read"),
- new PropertyPermission("java.vendor", "read"),
- new PropertyPermission("java.vendor.url", "read"),
- new PropertyPermission("java.class.version", "read"),
- new PropertyPermission("os.name", "read"),
- new PropertyPermission("os.version", "read"),
- new PropertyPermission("os.arch", "read"),
- new PropertyPermission("file.separator", "read"),
- new PropertyPermission("path.separator", "read"),
- new PropertyPermission("line.separator", "read"),
- new PropertyPermission("java.specification.version", "read"),
- new PropertyPermission("java.specification.vendor", "read"),
- new PropertyPermission("java.specification.name", "read"),
- new PropertyPermission("java.vm.specification.vendor", "read"),
- new PropertyPermission("java.vm.specification.name", "read"),
- new PropertyPermission("java.vm.version", "read"),
- new PropertyPermission("java.vm.vendor", "read"),
- new PropertyPermission("java.vm.name", "read"),
- new PropertyPermission("javawebstart.version", "read"),
- new PropertyPermission("javaplugin.*", "read"),
- new PropertyPermission("jnlp.*", "read,write"),
- new PropertyPermission("javaws.*", "read,write"),
- new RuntimePermission("exitVM"),
- new RuntimePermission("stopThread"),
+ new SocketPermission("localhost:1024-", "listen"),
+ // new SocketPermission("<DownloadHost>", "connect, accept"), // added by code
+ new PropertyPermission("java.version", "read"),
+ new PropertyPermission("java.vendor", "read"),
+ new PropertyPermission("java.vendor.url", "read"),
+ new PropertyPermission("java.class.version", "read"),
+ new PropertyPermission("os.name", "read"),
+ new PropertyPermission("os.version", "read"),
+ new PropertyPermission("os.arch", "read"),
+ new PropertyPermission("file.separator", "read"),
+ new PropertyPermission("path.separator", "read"),
+ new PropertyPermission("line.separator", "read"),
+ new PropertyPermission("java.specification.version", "read"),
+ new PropertyPermission("java.specification.vendor", "read"),
+ new PropertyPermission("java.specification.name", "read"),
+ new PropertyPermission("java.vm.specification.vendor", "read"),
+ new PropertyPermission("java.vm.specification.name", "read"),
+ new PropertyPermission("java.vm.version", "read"),
+ new PropertyPermission("java.vm.vendor", "read"),
+ new PropertyPermission("java.vm.name", "read"),
+ new PropertyPermission("javawebstart.version", "read"),
+ new PropertyPermission("javaplugin.*", "read"),
+ new PropertyPermission("jnlp.*", "read,write"),
+ new PropertyPermission("javaws.*", "read,write"),
+ new RuntimePermission("exitVM"),
+ new RuntimePermission("stopThread"),
// disabled because we can't at this time prevent an
// application from accessing other applications' event
// queues, or even prevent access to security dialog queues.
//
// new AWTPermission("accessEventQueue"),
- };
+ };
/** basic permissions for restricted mode */
private static Permission jnlpRIAPermissions[] = {
- new PropertyPermission("awt.useSystemAAFontSettings", "read,write"),
- new PropertyPermission("http.agent", "read,write"),
- new PropertyPermission("http.keepAlive", "read,write"),
- new PropertyPermission("java.awt.syncLWRequests", "read,write"),
- new PropertyPermission("java.awt.Window.locationByPlatform", "read,write"),
- new PropertyPermission("javaws.cfg.jauthenticator", "read,write"),
- new PropertyPermission("javax.swing.defaultlf", "read,write"),
- new PropertyPermission("sun.awt.noerasebackground", "read,write"),
- new PropertyPermission("sun.awt.erasebackgroundonresize", "read,write"),
- new PropertyPermission("sun.java2d.d3d", "read,write"),
- new PropertyPermission("sun.java2d.dpiaware", "read,write"),
- new PropertyPermission("sun.java2d.noddraw", "read,write"),
- new PropertyPermission("sun.java2d.opengl", "read,write"),
- new PropertyPermission("swing.boldMetal", "read,write"),
- new PropertyPermission("swing.metalTheme", "read,write"),
- new PropertyPermission("swing.noxp", "read,write"),
- new PropertyPermission("swing.useSystemFontSettings", "read,write"),
+ new PropertyPermission("awt.useSystemAAFontSettings", "read,write"),
+ new PropertyPermission("http.agent", "read,write"),
+ new PropertyPermission("http.keepAlive", "read,write"),
+ new PropertyPermission("java.awt.syncLWRequests", "read,write"),
+ new PropertyPermission("java.awt.Window.locationByPlatform", "read,write"),
+ new PropertyPermission("javaws.cfg.jauthenticator", "read,write"),
+ new PropertyPermission("javax.swing.defaultlf", "read,write"),
+ new PropertyPermission("sun.awt.noerasebackground", "read,write"),
+ new PropertyPermission("sun.awt.erasebackgroundonresize", "read,write"),
+ new PropertyPermission("sun.java2d.d3d", "read,write"),
+ new PropertyPermission("sun.java2d.dpiaware", "read,write"),
+ new PropertyPermission("sun.java2d.noddraw", "read,write"),
+ new PropertyPermission("sun.java2d.opengl", "read,write"),
+ new PropertyPermission("swing.boldMetal", "read,write"),
+ new PropertyPermission("swing.metalTheme", "read,write"),
+ new PropertyPermission("swing.noxp", "read,write"),
+ new PropertyPermission("swing.useSystemFontSettings", "read,write"),
};
/**
@@ -178,7 +177,7 @@ public class SecurityDesc {
// add j2ee to sandbox if needed
if (type == J2EE_PERMISSIONS)
- for (int i=0; i < j2eePermissions.length; i++)
+ for (int i = 0; i < j2eePermissions.length; i++)
permissions.add(j2eePermissions[i]);
return permissions;
@@ -191,7 +190,7 @@ public class SecurityDesc {
Permissions permissions = new Permissions();
- for (int i=0; i < sandboxPermissions.length; i++)
+ for (int i = 0; i < sandboxPermissions.length; i++)
permissions.add(sandboxPermissions[i]);
if (grantAwtPermissions) {
@@ -199,7 +198,7 @@ public class SecurityDesc {
}
if (file.isApplication())
- for (int i=0; i < jnlpRIAPermissions.length; i++)
+ for (int i = 0; i < jnlpRIAPermissions.length; i++)
permissions.add(jnlpRIAPermissions[i]);
if (downloadHost != null)
diff --git a/netx/net/sourceforge/jnlp/Version.java b/netx/net/sourceforge/jnlp/Version.java
index 1a48a86..f4ccc1a 100644
--- a/netx/net/sourceforge/jnlp/Version.java
+++ b/netx/net/sourceforge/jnlp/Version.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp;
import java.io.*;
@@ -57,7 +56,6 @@ public class Version {
/** contains all the versions matched */
private String versionString;
-
/**
* Create a Version object based on a version string (ie,
* "1.2.3+ 4.56*").
@@ -96,8 +94,8 @@ public class Version {
public boolean matches(Version version) {
List<String> versionStrings = version.getVersionStrings();
- for (int i=0; i < versionStrings.size(); i++) {
- if (!this.matchesSingle(versionStrings.get(i) ))
+ for (int i = 0; i < versionStrings.size(); i++) {
+ if (!this.matchesSingle(versionStrings.get(i)))
return false;
}
@@ -114,7 +112,6 @@ public class Version {
return matches(new Version(version));
}
-
/**
* Returns true if any of this version's version-ids match one
* or more of the specifed version's version-id.
@@ -124,8 +121,8 @@ public class Version {
public boolean matchesAny(Version version) {
List<String> versionStrings = version.getVersionStrings();
- for (int i=0; i < versionStrings.size(); i++) {
- if (this.matchesSingle( versionStrings.get(i) ))
+ for (int i = 0; i < versionStrings.size(); i++) {
+ if (this.matchesSingle(versionStrings.get(i)))
return true;
}
@@ -140,14 +137,13 @@ public class Version {
*/
private boolean matchesSingle(String version) {
List<String> versionStrings = this.getVersionStrings();
- for (int i=0; i < versionStrings.size(); i++) {
- if ( matches(version, versionStrings.get(i)) )
+ for (int i = 0; i < versionStrings.size(); i++) {
+ if (matches(version, versionStrings.get(i)))
return true;
}
return false;
}
-
/**
* Returns whether a single version string is supported by
* another single version string.
@@ -185,8 +181,8 @@ public class Version {
* @param parts2 normalized version parts
*/
protected boolean equal(List<String> parts1, List<String> parts2) {
- for (int i=0; i < parts1.size(); i++) {
- if ( 0 != compare(parts1.get(i), parts2.get(i)) )
+ for (int i = 0; i < parts1.size(); i++) {
+ if (0 != compare(parts1.get(i), parts2.get(i)))
return false;
}
@@ -203,7 +199,7 @@ public class Version {
protected boolean greater(List<String> parts1, List<String> parts2) {
//if (true) return false;
- for (int i=0; i < parts1.size(); i++) {
+ for (int i = 0; i < parts1.size(); i++) {
// if part1 > part2 then it's a later version, so return true
if (compare(parts1.get(i), parts2.get(i)) > 0)
return true;
@@ -244,8 +240,7 @@ public class Version {
number2 = Integer.valueOf(part2);
return number1.compareTo(number2);
- }
- catch (NumberFormatException ex) {
+ } catch (NumberFormatException ex) {
// means to compare as strings
}
@@ -275,11 +270,11 @@ public class Version {
for (List<String> vers : versions) {
// remove excess elements
while (vers.size() > length)
- vers.remove( vers.size()-1 );
+ vers.remove(vers.size() - 1);
// add in empty pad elements
while (vers.size() < length)
- vers.add( emptyString );
+ vers.add(emptyString);
}
}
@@ -291,7 +286,7 @@ public class Version {
StringTokenizer st = new StringTokenizer(versionString, " ");
while (st.hasMoreTokens())
- strings.add( st.nextToken() );
+ strings.add(st.nextToken());
return strings;
}
@@ -304,9 +299,9 @@ public class Version {
protected List<String> getParts(String oneVersion) {
ArrayList<String> strings = new ArrayList<String>();
- StringTokenizer st = new StringTokenizer(oneVersion, seperators+"+*");
+ StringTokenizer st = new StringTokenizer(oneVersion, seperators + "+*");
while (st.hasMoreTokens()) {
- strings.add( st.nextToken() );
+ strings.add(st.nextToken());
}
return strings;
diff --git a/netx/net/sourceforge/jnlp/cache/CacheEntry.java b/netx/net/sourceforge/jnlp/cache/CacheEntry.java
index d442a90..9299962 100644
--- a/netx/net/sourceforge/jnlp/cache/CacheEntry.java
+++ b/netx/net/sourceforge/jnlp/cache/CacheEntry.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.cache;
import static net.sourceforge.jnlp.runtime.Translator.R;
@@ -47,7 +46,6 @@ public class CacheEntry {
/** info about the cached file */
private PropertiesFile properties;
-
/**
* Create a CacheEntry for the resources specified as a remote
* URL.
@@ -60,7 +58,7 @@ public class CacheEntry {
this.version = version;
File infoFile = CacheUtil.getCacheFile(location, version);
- infoFile = new File(infoFile.getPath()+".info"); // replace with something that can't be clobbered
+ infoFile = new File(infoFile.getPath() + ".info"); // replace with something that can't be clobbered
properties = new PropertiesFile(infoFile, R("CAutoGen"));
}
@@ -91,8 +89,7 @@ public class CacheEntry {
public long getLastUpdated() {
try {
return Long.parseLong(properties.getProperty("last-updated"));
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
return 0;
}
}
@@ -127,8 +124,7 @@ public class CacheEntry {
return true;
else
return false;
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
if (JNLPRuntime.isDebug())
ex.printStackTrace();
@@ -155,8 +151,7 @@ public class CacheEntry {
return false;
else
return true;
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
if (JNLPRuntime.isDebug())
ex.printStackTrace();
diff --git a/netx/net/sourceforge/jnlp/cache/CacheUtil.java b/netx/net/sourceforge/jnlp/cache/CacheUtil.java
index 04b5adc..e316282 100644
--- a/netx/net/sourceforge/jnlp/cache/CacheUtil.java
+++ b/netx/net/sourceforge/jnlp/cache/CacheUtil.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.cache;
import static net.sourceforge.jnlp.runtime.Translator.R;
@@ -49,17 +48,17 @@ public class CacheUtil {
* ie sourceforge.net and www.sourceforge.net).
*/
public static boolean urlEquals(URL u1, URL u2) {
- if (u1==u2)
+ if (u1 == u2)
return true;
- if (u1==null || u2==null)
+ if (u1 == null || u2 == null)
return false;
if (!compare(u1.getProtocol(), u2.getProtocol(), true) ||
- !compare(u1.getHost(), u2.getHost(), true) ||
- //u1.getDefaultPort() != u2.getDefaultPort() || // only in 1.4
- !compare(u1.getPath(), u2.getPath(), false) ||
- !compare(u1.getQuery(), u2.getQuery(), false) ||
- !compare(u1.getRef(), u2.getRef(), false))
+ !compare(u1.getHost(), u2.getHost(), true) ||
+ //u1.getDefaultPort() != u2.getDefaultPort() || // only in 1.4
+ !compare(u1.getPath(), u2.getPath(), false) ||
+ !compare(u1.getQuery(), u2.getQuery(), false) ||
+ !compare(u1.getRef(), u2.getRef(), false))
return false;
else
return true;
@@ -82,8 +81,7 @@ public class CacheUtil {
File f = rt.getCacheFile(location);
// TODO: Should be toURI().toURL()
return f.toURL();
- }
- catch (MalformedURLException ex) {
+ } catch (MalformedURLException ex) {
return location;
}
}
@@ -92,9 +90,9 @@ public class CacheUtil {
* Compare strings that can be null.
*/
private static boolean compare(String s1, String s2, boolean ignore) {
- if (s1==s2)
+ if (s1 == s2)
return true;
- if (s1==null || s2==null)
+ if (s1 == null || s2 == null)
return false;
if (ignore)
@@ -112,16 +110,14 @@ public class CacheUtil {
File file = CacheUtil.getCacheFile(location, version);
return new FilePermission(file.getPath(), "read");
- }
- else {
+ } else {
try {
// this is what URLClassLoader does
return location.openConnection().getPermission();
- }
- catch (java.io.IOException ioe) {
+ } catch (java.io.IOException ioe) {
// should try to figure out the permission
if (JNLPRuntime.isDebug())
- ioe.printStackTrace();
+ ioe.printStackTrace();
}
}
@@ -223,11 +219,10 @@ public class CacheUtil {
boolean result = entry.isCurrent(connection);
if (JNLPRuntime.isDebug())
- System.out.println("isCurrent: "+source+" = "+result);
+ System.out.println("isCurrent: " + source + " = " + result);
return result;
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
if (JNLPRuntime.isDebug())
ex.printStackTrace();
@@ -252,7 +247,7 @@ public class CacheUtil {
boolean result = entry.isCached();
if (JNLPRuntime.isDebug())
- System.out.println("isCached: "+source+" = "+result);
+ System.out.println("isCached: " + source + " = " + result);
return result;
}
@@ -294,13 +289,12 @@ public class CacheUtil {
try {
String cacheDir = JNLPRuntime.getConfiguration()
- .getProperty(DeploymentConfiguration.KEY_USER_CACHE_DIR);
+ .getProperty(DeploymentConfiguration.KEY_USER_CACHE_DIR);
File localFile = urlToPath(source, cacheDir);
localFile.getParentFile().mkdirs();
return localFile;
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
if (JNLPRuntime.isDebug())
ex.printStackTrace();
@@ -343,8 +337,7 @@ public class CacheUtil {
os.write(b, 0, c);
}
- }
- finally {
+ } finally {
is.close();
os.close();
}
@@ -378,7 +371,6 @@ public class CacheUtil {
return new File(FileUtils.sanitizePath(path.toString()));
}
-
/**
* Waits until the resources are downloaded, while showing a
* progress indicator.
@@ -404,11 +396,11 @@ public class CacheUtil {
// only resources not starting out downloaded are displayed
List<URL> urlList = new ArrayList<URL>();
- for (int i=0; i < resources.length; i++) {
+ for (int i = 0; i < resources.length; i++) {
if (!tracker.checkResource(resources[i]))
urlList.add(resources[i]);
}
- URL undownloaded[] = urlList.toArray( new URL[urlList.size()] );
+ URL undownloaded[] = urlList.toArray(new URL[urlList.size()]);
listener = indicator.getListener(app, title, undownloaded);
@@ -416,35 +408,32 @@ public class CacheUtil {
long read = 0;
long total = 0;
- for (int i=0; i < undownloaded.length; i++) {
+ for (int i = 0; i < undownloaded.length; i++) {
// add in any -1's; they're insignificant
total += tracker.getTotalSize(undownloaded[i]);
read += tracker.getAmountRead(undownloaded[i]);
}
- int percent = (int)( (100*read)/Math.max(1,total) );
+ int percent = (int) ((100 * read) / Math.max(1, total));
- for (int i=0; i < undownloaded.length; i++)
+ for (int i = 0; i < undownloaded.length; i++)
listener.progress(undownloaded[i], "version",
tracker.getAmountRead(undownloaded[i]),
tracker.getTotalSize(undownloaded[i]),
percent);
- }
- while (!tracker.waitForResources(resources, indicator.getUpdateRate()));
+ } while (!tracker.waitForResources(resources, indicator.getUpdateRate()));
// make sure they read 100% until indicator closes
- for (int i=0; i < undownloaded.length; i++)
+ for (int i = 0; i < undownloaded.length; i++)
listener.progress(undownloaded[i], "version",
tracker.getTotalSize(undownloaded[i]),
tracker.getTotalSize(undownloaded[i]),
100);
- }
- catch (InterruptedException ex) {
+ } catch (InterruptedException ex) {
if (JNLPRuntime.isDebug())
ex.printStackTrace();
- }
- finally {
+ } finally {
if (listener != null)
indicator.disposeListener(listener);
}
diff --git a/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java b/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java
index f7c382e..7472307 100644
--- a/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java
+++ b/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.cache;
import static net.sourceforge.jnlp.runtime.Translator.R;
@@ -100,12 +99,12 @@ public class DefaultDownloadIndicator implements DownloadIndicator {
DownloadPanel result = new DownloadPanel(downloadName);
if (frame == null) {
- frame = new JFrame(downloading+"...");
+ frame = new JFrame(downloading + "...");
frame.getContentPane().setLayout(new GridBagLayout());
}
if (resources != null)
- for (int i=0; i < resources.length; i++)
+ for (int i = 0; i < resources.length; i++)
result.addProgressPanel(resources[i], null);
frame.getContentPane().add(result, vertical);
@@ -114,10 +113,10 @@ public class DefaultDownloadIndicator implements DownloadIndicator {
if (!frame.isVisible()) {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(frame.getGraphicsConfiguration());
- Dimension screen = new Dimension(screenSize.width - insets.left ,
+ Dimension screen = new Dimension(screenSize.width - insets.left,
screenSize.height - insets.top);
- frame.setLocation(screen.width-frame.getWidth(),
- screen.height-frame.getHeight());
+ frame.setLocation(screen.width - frame.getWidth(),
+ screen.height - frame.getHeight());
}
frame.setVisible(true);
@@ -149,8 +148,6 @@ public class DefaultDownloadIndicator implements DownloadIndicator {
timer.start();
}
-
-
/**
* Groups the url progress in a panel.
*/
@@ -168,7 +165,6 @@ public class DefaultDownloadIndicator implements DownloadIndicator {
/** list of ProgressPanels */
private List<ProgressPanel> panels = new ArrayList<ProgressPanel>();
-
/**
* Create a new download panel for with the specified download
* name.
@@ -226,7 +222,7 @@ public class DefaultDownloadIndicator implements DownloadIndicator {
// don't get whole string from resource and sub in
// values because it'll be doing a MessageFormat for
// each update.
- header.setText(downloading+" "+downloadName+": "+percent+"% "+complete+".");
+ header.setText(downloading + " " + downloadName + ": " + percent + "% " + complete + ".");
}
/**
@@ -259,8 +255,6 @@ public class DefaultDownloadIndicator implements DownloadIndicator {
};
-
-
/**
* A progress bar with the URL next to it.
*/
@@ -271,10 +265,10 @@ public class DefaultDownloadIndicator implements DownloadIndicator {
private long readSoFar;
ProgressPanel(URL url, String version) {
- JLabel location = new JLabel(" "+url.getHost()+"/"+url.getFile());
+ JLabel location = new JLabel(" " + url.getHost() + "/" + url.getFile());
- bar.setMinimumSize(new Dimension(80,15));
- bar.setPreferredSize(new Dimension(80,15));
+ bar.setMinimumSize(new Dimension(80, 15));
+ bar.setPreferredSize(new Dimension(80, 15));
bar.setOpaque(false);
setLayout(new GridBagLayout());
@@ -308,15 +302,14 @@ public class DefaultDownloadIndicator implements DownloadIndicator {
if (readSoFar <= 0 || total <= 0) {
// make barber pole
- }
- else {
- double progress = (double)readSoFar / (double)total;
- int divide = (int)(w * progress);
+ } else {
+ double progress = (double) readSoFar / (double) total;
+ int divide = (int) (w * progress);
g.setColor(Color.white);
g.fillRect(x, y, w, h);
g.setColor(Color.blue);
- g.fillRect(x+1, y+1, divide-1, h-1);
+ g.fillRect(x + 1, y + 1, divide - 1, h - 1);
}
}
};
diff --git a/netx/net/sourceforge/jnlp/cache/DownloadIndicator.java b/netx/net/sourceforge/jnlp/cache/DownloadIndicator.java
index a6eecb8..7506392 100644
--- a/netx/net/sourceforge/jnlp/cache/DownloadIndicator.java
+++ b/netx/net/sourceforge/jnlp/cache/DownloadIndicator.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.cache;
import java.awt.*;
diff --git a/netx/net/sourceforge/jnlp/cache/Resource.java b/netx/net/sourceforge/jnlp/cache/Resource.java
index 08a31fb..9818b64 100644
--- a/netx/net/sourceforge/jnlp/cache/Resource.java
+++ b/netx/net/sourceforge/jnlp/cache/Resource.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.cache;
import java.io.*;
@@ -169,17 +168,26 @@ public class Resource {
private String getStatusString(int flag) {
StringBuffer result = new StringBuffer();
- if (flag == 0) result.append("<> ");
- if ((flag & CONNECT) != 0) result.append("CONNECT ");
- if ((flag & CONNECTING) != 0) result.append("CONNECTING ");
- if ((flag & CONNECTED) != 0) result.append("CONNECTED ");
- if ((flag & DOWNLOAD) != 0) result.append("DOWNLOAD ");
- if ((flag & DOWNLOADING) != 0) result.append("DOWNLOADING ");
- if ((flag & DOWNLOADED) != 0) result.append("DOWNLOADED ");
- if ((flag & ERROR) != 0) result.append("ERROR ");
- if ((flag & STARTED) != 0) result.append("STARTED ");
-
- return result.deleteCharAt(result.length()-1).toString();
+ if (flag == 0)
+ result.append("<> ");
+ if ((flag & CONNECT) != 0)
+ result.append("CONNECT ");
+ if ((flag & CONNECTING) != 0)
+ result.append("CONNECTING ");
+ if ((flag & CONNECTED) != 0)
+ result.append("CONNECTED ");
+ if ((flag & DOWNLOAD) != 0)
+ result.append("DOWNLOAD ");
+ if ((flag & DOWNLOADING) != 0)
+ result.append("DOWNLOADING ");
+ if ((flag & DOWNLOADED) != 0)
+ result.append("DOWNLOADED ");
+ if ((flag & ERROR) != 0)
+ result.append("ERROR ");
+ if ((flag & STARTED) != 0)
+ result.append("STARTED ");
+
+ return result.deleteCharAt(result.length() - 1).toString();
}
/**
@@ -190,7 +198,7 @@ public class Resource {
public void changeStatus(int clear, int add) {
int orig = 0;
- synchronized(this) {
+ synchronized (this) {
orig = status;
this.status &= ~clear;
@@ -199,12 +207,12 @@ public class Resource {
if (JNLPRuntime.isDebug())
if (status != orig) {
- System.out.print("Status: "+getStatusString(status));
+ System.out.print("Status: " + getStatusString(status));
if ((status & ~orig) != 0)
- System.out.print(" +("+getStatusString(status & ~orig)+")");
+ System.out.print(" +(" + getStatusString(status & ~orig) + ")");
if ((~status & orig) != 0)
- System.out.print(" -("+getStatusString(~status & orig)+")");
- System.out.println(" @ "+location.getPath());
+ System.out.print(" -(" + getStatusString(~status & orig) + ")");
+ System.out.println(" @ " + location.getPath());
}
}
@@ -245,7 +253,7 @@ public class Resource {
send = trackers.hardList();
}
- for (int i=0; i < send.size(); i++) {
+ for (int i = 0; i < send.size(); i++) {
ResourceTracker rt = send.get(i);
rt.fireDownloadEvent(this);
}
@@ -258,13 +266,13 @@ public class Resource {
// time spent in synchronized addResource determining if
// Resource is already in a tracker, and better for offline
// mode on some OS.
- return CacheUtil.urlEquals(location, ((Resource)other).location);
+ return CacheUtil.urlEquals(location, ((Resource) other).location);
}
return false;
}
public String toString() {
- return "location="+location.toString() + " state="+getStatusString(status);
+ return "location=" + location.toString() + " state=" + getStatusString(status);
}
}
diff --git a/netx/net/sourceforge/jnlp/cache/ResourceTracker.java b/netx/net/sourceforge/jnlp/cache/ResourceTracker.java
index e4d85b0..c21be39 100644
--- a/netx/net/sourceforge/jnlp/cache/ResourceTracker.java
+++ b/netx/net/sourceforge/jnlp/cache/ResourceTracker.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.cache;
import java.io.BufferedInputStream;
@@ -85,7 +84,6 @@ public class ResourceTracker {
// todo: might make a tracker be able to download more than one
// version of a resource, but probably not very useful.
-
// defines
// ResourceTracker.Downloader (download threads)
@@ -114,14 +112,14 @@ public class ResourceTracker {
/** weak list of resource trackers with resources to prefetch */
private static WeakList<ResourceTracker> prefetchTrackers =
- new WeakList<ResourceTracker>();
+ new WeakList<ResourceTracker>();
/** resources requested to be downloaded */
private static ArrayList<Resource> queue = new ArrayList<Resource>();
/** resource trackers threads are working for (used for load balancing across multi-tracker downloads) */
private static ArrayList<ResourceTracker> active =
- new ArrayList<ResourceTracker>(); //
+ new ArrayList<ResourceTracker>(); //
/** the resources known about by this resource tracker */
private List<Resource> resources = new ArrayList<Resource>();
@@ -132,7 +130,6 @@ public class ResourceTracker {
/** whether to download parts before requested */
private boolean prefetch;
-
/**
* Creates a resource tracker that does not prefetch resources.
*/
@@ -227,7 +224,7 @@ public class ResourceTracker {
// they will just 'pass through' the tracker as if they were
// never added (for example, not affecting the total download size).
synchronized (resource) {
- resource.changeStatus(0, DOWNLOADED|CONNECTED|STARTED);
+ resource.changeStatus(0, DOWNLOADED | CONNECTED | STARTED);
}
fireDownloadEvent(resource);
return true;
@@ -238,13 +235,13 @@ public class ResourceTracker {
if (entry.isCached() && !updatePolicy.shouldUpdate(entry)) {
if (JNLPRuntime.isDebug())
- System.out.println("not updating: "+resource.location);
+ System.out.println("not updating: " + resource.location);
synchronized (resource) {
resource.localFile = CacheUtil.getCacheFile(resource.location, resource.downloadVersion);
resource.size = resource.localFile.length();
resource.transferred = resource.localFile.length();
- resource.changeStatus(0, DOWNLOADED|CONNECTED|STARTED);
+ resource.changeStatus(0, DOWNLOADED | CONNECTED | STARTED);
}
fireDownloadEvent(resource);
return true;
@@ -304,8 +301,8 @@ public class ResourceTracker {
}
DownloadEvent event = new DownloadEvent(this, resource);
- for (int i=0; i < l.length; i++) {
- if (0 != ((ERROR|DOWNLOADED) & status))
+ for (int i = 0; i < l.length; i++) {
+ if (0 != ((ERROR | DOWNLOADED) & status))
l[i].downloadCompleted(event);
else if (0 != (DOWNLOADING & status))
l[i].downloadStarted(event);
@@ -333,8 +330,7 @@ public class ResourceTracker {
if (f != null)
// TODO: Should be toURI().toURL()
return f.toURL();
- }
- catch (MalformedURLException ex) {
+ } catch (MalformedURLException ex) {
if (JNLPRuntime.isDebug())
ex.printStackTrace();
}
@@ -358,7 +354,7 @@ public class ResourceTracker {
public File getCacheFile(URL location) {
try {
Resource resource = getResource(location);
- if (!resource.isSet(DOWNLOADED|ERROR))
+ if (!resource.isSet(DOWNLOADED | ERROR))
waitForResource(location, 0);
if (resource.isSet(ERROR))
@@ -374,8 +370,7 @@ public class ResourceTracker {
}
return null;
- }
- catch (InterruptedException ex) {
+ } catch (InterruptedException ex) {
if (JNLPRuntime.isDebug())
ex.printStackTrace();
@@ -398,15 +393,14 @@ public class ResourceTracker {
public InputStream getInputStream(URL location) throws IOException {
try {
Resource resource = getResource(location);
- if (!resource.isSet(DOWNLOADED|ERROR))
+ if (!resource.isSet(DOWNLOADED | ERROR))
waitForResource(location, 0);
if (resource.localFile != null)
return new FileInputStream(resource.localFile);
return resource.location.openStream();
- }
- catch (InterruptedException ex) {
+ } catch (InterruptedException ex) {
throw new IOException("wait was interrupted");
}
}
@@ -421,11 +415,11 @@ public class ResourceTracker {
* @throws IllegalArgumentException if the resource is not being tracked
*/
public boolean waitForResources(URL urls[], long timeout) throws InterruptedException {
- Resource resources[] = new Resource[ urls.length ];
+ Resource resources[] = new Resource[urls.length];
- synchronized(resources) {
+ synchronized (resources) {
// keep the lock so getResource doesn't have to aquire it each time
- for (int i=0; i < urls.length; i++)
+ for (int i = 0; i < urls.length; i++)
resources[i] = getResource(urls[i]);
}
@@ -469,7 +463,7 @@ public class ResourceTracker {
* @throws IllegalArgumentException if the resource is not being tracked
*/
public boolean checkResource(URL location) {
- return getResource(location).isSet(DOWNLOADED|ERROR); // isSet atomic
+ return getResource(location).isSet(DOWNLOADED | ERROR); // isSet atomic
}
/**
@@ -505,11 +499,11 @@ public class ResourceTracker {
enqueue = !resource.isSet(STARTED);
if (!resource.isSet(CONNECTED | CONNECTING))
- resource.changeStatus(0, CONNECT|STARTED);
+ resource.changeStatus(0, CONNECT | STARTED);
if (!resource.isSet(DOWNLOADED | DOWNLOADING))
- resource.changeStatus(0, DOWNLOAD|STARTED);
+ resource.changeStatus(0, DOWNLOAD | STARTED);
- if (!resource.isSet(DOWNLOAD|CONNECT))
+ if (!resource.isSet(DOWNLOAD | CONNECT))
enqueue = false;
}
@@ -580,8 +574,8 @@ public class ResourceTracker {
*/
private void queueResource(Resource resource) {
synchronized (lock) {
- if (!resource.isSet(CONNECT|DOWNLOAD))
- throw new IllegalArgumentException("Invalid resource state (resource: "+resource+")");
+ if (!resource.isSet(CONNECT | DOWNLOAD))
+ throw new IllegalArgumentException("Invalid resource state (resource: " + resource + ")");
queue.add(resource);
startThread();
@@ -668,7 +662,7 @@ public class ResourceTracker {
// explicitly close the URLConnection.
if (con instanceof HttpURLConnection)
- ((HttpURLConnection)con).disconnect();
+ ((HttpURLConnection) con).disconnect();
/*
* If the file was compressed, uncompress it.
@@ -709,17 +703,16 @@ public class ResourceTracker {
}
resource.changeStatus(DOWNLOADING, DOWNLOADED);
- synchronized(lock) {
+ synchronized (lock) {
lock.notifyAll(); // wake up wait's to check for completion
}
resource.fireDownloadEvent(); // fire DOWNLOADED
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
if (JNLPRuntime.isDebug())
ex.printStackTrace();
resource.changeStatus(0, ERROR);
- synchronized(lock) {
+ synchronized (lock) {
lock.notifyAll(); // wake up wait's to check for completion
}
resource.fireDownloadEvent(); // fire ERROR
@@ -743,15 +736,15 @@ public class ResourceTracker {
int size = connection.getContentLength();
boolean current = CacheUtil.isCurrent(resource.location, resource.requestVersion, connection) && resource.getUpdatePolicy() != UpdatePolicy.FORCE;
- synchronized(resource) {
+ synchronized (resource) {
resource.localFile = localFile;
// resource.connection = connection;
resource.size = size;
- resource.changeStatus(CONNECT|CONNECTING, CONNECTED);
+ resource.changeStatus(CONNECT | CONNECTING, CONNECTED);
// check if up-to-date; if so set as downloaded
if (current)
- resource.changeStatus(DOWNLOAD|DOWNLOADING, DOWNLOADED);
+ resource.changeStatus(DOWNLOAD | DOWNLOADING, DOWNLOADED);
}
// update cache entry
@@ -762,21 +755,20 @@ public class ResourceTracker {
entry.setLastUpdated(System.currentTimeMillis());
entry.store();
- synchronized(lock) {
+ synchronized (lock) {
lock.notifyAll(); // wake up wait's to check for completion
}
resource.fireDownloadEvent(); // fire CONNECTED
// explicitly close the URLConnection.
- if (connection instanceof HttpURLConnection)
- ((HttpURLConnection)connection).disconnect();
- }
- catch (Exception ex) {
+ if (connection instanceof HttpURLConnection)
+ ((HttpURLConnection) connection).disconnect();
+ } catch (Exception ex) {
if (JNLPRuntime.isDebug())
ex.printStackTrace();
resource.changeStatus(0, ERROR);
- synchronized(lock) {
+ synchronized (lock) {
lock.notifyAll(); // wake up wait's to check for completion
}
resource.fireDownloadEvent(); // fire ERROR
@@ -807,7 +799,6 @@ public class ResourceTracker {
return versionedURL;
}
-
/**
* Pick the next resource to download or initialize. If there
* are no more resources requested then one is taken from a
@@ -826,7 +817,7 @@ public class ResourceTracker {
// pick from queue
result = selectByFlag(queue, CONNECT, ERROR); // connect but not error
if (result == null)
- result = selectByFlag(queue, DOWNLOAD, ERROR|CONNECT|CONNECTING);
+ result = selectByFlag(queue, DOWNLOAD, ERROR | CONNECT | CONNECTING);
// remove from queue if found
if (result != null)
@@ -842,8 +833,7 @@ public class ResourceTracker {
synchronized (result) {
if (result.isSet(CONNECT)) {
result.changeStatus(CONNECT, CONNECTING);
- }
- else if (result.isSet(DOWNLOAD)) {
+ } else if (result.isSet(DOWNLOAD)) {
// only download if *not* connecting, when done connecting
// select next will pick up the download part. This makes
// all requested connects happen before any downloads, so
@@ -867,7 +857,7 @@ public class ResourceTracker {
// first find one to initialize
synchronized (prefetchTrackers) {
- for (int i=0; i < prefetchTrackers.size() && result == null; i++) {
+ for (int i = 0; i < prefetchTrackers.size() && result == null; i++) {
ResourceTracker tracker = prefetchTrackers.get(i);
if (tracker == null)
continue;
@@ -876,7 +866,7 @@ public class ResourceTracker {
result = selectByFlag(tracker.resources, UNINITIALIZED, ERROR);
if (result == null && alternate == null)
- alternate = selectByFlag(tracker.resources, CONNECTED, ERROR|DOWNLOADED|DOWNLOADING|DOWNLOAD);
+ alternate = selectByFlag(tracker.resources, CONNECTED, ERROR | DOWNLOADED | DOWNLOADING | DOWNLOAD);
}
}
}
@@ -915,7 +905,7 @@ public class ResourceTracker {
Resource result = null;
int score = Integer.MAX_VALUE;
- for (int i=0; i < source.size(); i++) {
+ for (int i = 0; i < source.size(); i++) {
Resource resource = source.get(i);
boolean selectable = false;
@@ -927,7 +917,7 @@ public class ResourceTracker {
if (selectable) {
int activeCount = 0;
- for (int j=0; j < active.size(); j++)
+ for (int j = 0; j < active.size(); j++)
if (active.get(j) == resource.getTracker())
activeCount++;
@@ -950,7 +940,7 @@ public class ResourceTracker {
*/
private Resource getResource(URL location) {
synchronized (resources) {
- for (int i=0; i < resources.size(); i++) {
+ for (int i = 0; i < resources.size(); i++) {
Resource resource = resources.get(i);
if (CacheUtil.urlEquals(resource.location, location))
@@ -974,7 +964,7 @@ public class ResourceTracker {
long startTime = System.currentTimeMillis();
// start them downloading / connecting in background
- for (int i=0; i < resources.length; i++)
+ for (int i = 0; i < resources.length; i++)
startResource(resources[i]);
// wait for completion
@@ -983,9 +973,9 @@ public class ResourceTracker {
synchronized (lock) {
// check for completion
- for (int i=0; i < resources.length; i++) {
- //NetX Deadlocking may be solved by removing this
- //synch block.
+ for (int i = 0; i < resources.length; i++) {
+ //NetX Deadlocking may be solved by removing this
+ //synch block.
synchronized (resources[i]) {
if (!resources[i].isSet(DOWNLOADED | ERROR)) {
finished = false;
@@ -1000,7 +990,7 @@ public class ResourceTracker {
long waitTime = 0;
if (timeout > 0) {
- waitTime = timeout - (System.currentTimeMillis()-startTime);
+ waitTime = timeout - (System.currentTimeMillis() - startTime);
if (waitTime <= 0)
return false;
}
@@ -1010,7 +1000,6 @@ public class ResourceTracker {
}
}
-
// inner classes
/**
@@ -1039,8 +1028,7 @@ public class ResourceTracker {
try {
processResource(resource);
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
if (JNLPRuntime.isDebug())
ex.printStackTrace();
}
diff --git a/netx/net/sourceforge/jnlp/cache/UpdatePolicy.java b/netx/net/sourceforge/jnlp/cache/UpdatePolicy.java
index 157e38c..8c069f6 100644
--- a/netx/net/sourceforge/jnlp/cache/UpdatePolicy.java
+++ b/netx/net/sourceforge/jnlp/cache/UpdatePolicy.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.cache;
import java.io.*;
@@ -27,6 +26,7 @@ import javax.jnlp.*;
import net.sourceforge.jnlp.*;
import net.sourceforge.jnlp.runtime.*;
import net.sourceforge.jnlp.util.*;
+
/**
* A policy that determines when a resource should be checked for
* an updated version.<p>
@@ -52,7 +52,6 @@ public class UpdatePolicy {
private long timeDiff = -1;
-
/**
* Create a new update policy; this policy always updates the
* entry unless the shouldUpdate method is overridden.
diff --git a/netx/net/sourceforge/jnlp/controlpanel/AdvancedProxySettingsDialog.java b/netx/net/sourceforge/jnlp/controlpanel/AdvancedProxySettingsDialog.java
index 2334947..241f04c 100644
--- a/netx/net/sourceforge/jnlp/controlpanel/AdvancedProxySettingsDialog.java
+++ b/netx/net/sourceforge/jnlp/controlpanel/AdvancedProxySettingsDialog.java
@@ -130,9 +130,7 @@ public class AdvancedProxySettingsDialog extends JDialog {
psd.dispose();
}
});
-
-
-
+
}
/**
diff --git a/netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java b/netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java
index 27812a9..3273940 100644
--- a/netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java
+++ b/netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java
@@ -182,7 +182,7 @@ public class ControlPanel extends JFrame {
SettingsPanel[] panels = new SettingsPanel[] { new SettingsPanel(Translator.R("CPTabAbout"), createAboutPanel()),
new SettingsPanel(Translator.R("CPTabCache"), createCacheSettingsPanel()),
new SettingsPanel(Translator.R("CPTabCertificate"), createCertificatesSettingsPanel()),
-// new SettingsPanel(Translator.R("CPTabClassLoader"), createClassLoaderSettingsPanel()),
+ // new SettingsPanel(Translator.R("CPTabClassLoader"), createClassLoaderSettingsPanel()),
new SettingsPanel(Translator.R("CPTabDebugging"), createDebugSettingsPanel()),
new SettingsPanel(Translator.R("CPTabDesktopIntegration"), createDesktopSettingsPanel()),
new SettingsPanel(Translator.R("CPTabNetwork"), createNetworkSettingsPanel()),
diff --git a/netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java b/netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java
index 0693357..1cdbb46 100644
--- a/netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java
+++ b/netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java
@@ -116,7 +116,8 @@ public class DebuggingPanel extends NamedBorderPanel implements ItemListener {
case 3:
for (int j = 0; j < javaConsoleItems.length; j++) {
consoleComboBox.addItem(javaConsoleItems[j]);
- if (config.getProperty("deployment.console.startup.mode").equals(javaConsoleItems[j].getValue())) consoleComboBox.setSelectedIndex(j);
+ if (config.getProperty("deployment.console.startup.mode").equals(javaConsoleItems[j].getValue()))
+ consoleComboBox.setSelectedIndex(j);
}
consoleComboBox.addItemListener(this);
add(consolePanel, c);
diff --git a/netx/net/sourceforge/jnlp/controlpanel/DesktopShortcutPanel.java b/netx/net/sourceforge/jnlp/controlpanel/DesktopShortcutPanel.java
index 3d13c62..8563b82 100644
--- a/netx/net/sourceforge/jnlp/controlpanel/DesktopShortcutPanel.java
+++ b/netx/net/sourceforge/jnlp/controlpanel/DesktopShortcutPanel.java
@@ -72,7 +72,8 @@ public class DesktopShortcutPanel extends NamedBorderPanel implements ItemListen
shortcutComboOptions.setActionCommand("deployment.javaws.shortcut"); // The configuration property this combobox affects.
for (int j = 0; j < items.length; j++) {
shortcutComboOptions.addItem(items[j]);
- if (config.getProperty("deployment.javaws.shortcut").equals(items[j].getValue())) shortcutComboOptions.setSelectedIndex(j);
+ if (config.getProperty("deployment.javaws.shortcut").equals(items[j].getValue()))
+ shortcutComboOptions.setSelectedIndex(j);
}
shortcutComboOptions.addItemListener(this);
diff --git a/netx/net/sourceforge/jnlp/controlpanel/MiddleClickListener.java b/netx/net/sourceforge/jnlp/controlpanel/MiddleClickListener.java
index 0062684..633bfdf 100644
--- a/netx/net/sourceforge/jnlp/controlpanel/MiddleClickListener.java
+++ b/netx/net/sourceforge/jnlp/controlpanel/MiddleClickListener.java
@@ -39,7 +39,8 @@ class MiddleClickListener extends MouseAdapter {
String result = null;
if (obj instanceof JTextField)
result = ((JTextField) obj).getText();
- else if (obj instanceof JTextArea) result = ((JTextArea) obj).getText();
+ else if (obj instanceof JTextArea)
+ result = ((JTextArea) obj).getText();
config.setProperty(property, result);
}
diff --git a/netx/net/sourceforge/jnlp/controlpanel/NamedBorderPanel.java b/netx/net/sourceforge/jnlp/controlpanel/NamedBorderPanel.java
index c7b2506..9ec1398 100644
--- a/netx/net/sourceforge/jnlp/controlpanel/NamedBorderPanel.java
+++ b/netx/net/sourceforge/jnlp/controlpanel/NamedBorderPanel.java
@@ -54,7 +54,7 @@ public class NamedBorderPanel extends JPanel {
public NamedBorderPanel(String title) {
super();
setBorder(BorderFactory.createCompoundBorder(
- BorderFactory.createTitledBorder(title),
+ BorderFactory.createTitledBorder(title),
BorderFactory.createEmptyBorder(5, 5, 5, 5)));
}
}
diff --git a/netx/net/sourceforge/jnlp/controlpanel/NetworkSettingsPanel.java b/netx/net/sourceforge/jnlp/controlpanel/NetworkSettingsPanel.java
index 4b6ee04..ae21521 100644
--- a/netx/net/sourceforge/jnlp/controlpanel/NetworkSettingsPanel.java
+++ b/netx/net/sourceforge/jnlp/controlpanel/NetworkSettingsPanel.java
@@ -190,7 +190,8 @@ public class NetworkSettingsPanel extends JPanel implements ActionListener {
locationField.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) {
String value = locationField.getText();
- if (value.trim().equals("")) value = null;
+ if (value.trim().equals(""))
+ value = null;
config.setProperty(properties[4], value);
}
});
diff --git a/netx/net/sourceforge/jnlp/controlpanel/SecuritySettingsPanel.java b/netx/net/sourceforge/jnlp/controlpanel/SecuritySettingsPanel.java
index 18d574a..d148b8a 100644
--- a/netx/net/sourceforge/jnlp/controlpanel/SecuritySettingsPanel.java
+++ b/netx/net/sourceforge/jnlp/controlpanel/SecuritySettingsPanel.java
@@ -64,7 +64,7 @@ public class SecuritySettingsPanel extends NamedBorderPanel implements ActionLis
"deployment.security.SSLv2Hello", // Default FALSE
"deployment.security.SSLv3", // Default TRUE
"deployment.security.TLSv1", // Default TRUE
-// "deployment.security.mixcode", // Default TRUE
+ // "deployment.security.mixcode", // Default TRUE
};
/**
diff --git a/netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java b/netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java
index ef56a18..413b585 100644
--- a/netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java
+++ b/netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java
@@ -226,7 +226,8 @@ public class TemporaryInternetFilesPanel extends NamedBorderPanel implements Cha
Object o = e.getSource();
if (o instanceof JSlider)
spCacheSize.setValue(((JSlider) o).getValue());
- else if (o instanceof JSpinner) slCacheSize.setValue((Integer) ((JSpinner) o).getValue());
+ else if (o instanceof JSpinner)
+ slCacheSize.setValue((Integer) ((JSpinner) o).getValue());
config.setProperty(properties[2], spCacheSize.getValue().toString());
}
diff --git a/netx/net/sourceforge/jnlp/event/ApplicationEvent.java b/netx/net/sourceforge/jnlp/event/ApplicationEvent.java
index 10d6844..12e0d83 100644
--- a/netx/net/sourceforge/jnlp/event/ApplicationEvent.java
+++ b/netx/net/sourceforge/jnlp/event/ApplicationEvent.java
@@ -32,7 +32,6 @@ public class ApplicationEvent extends EventObject {
/** the application instance */
private ApplicationInstance application;
-
/**
* Creates a launch event for the specified application
* instance.
diff --git a/netx/net/sourceforge/jnlp/event/ApplicationListener.java b/netx/net/sourceforge/jnlp/event/ApplicationListener.java
index b000b2c..8df4b68 100644
--- a/netx/net/sourceforge/jnlp/event/ApplicationListener.java
+++ b/netx/net/sourceforge/jnlp/event/ApplicationListener.java
@@ -14,12 +14,10 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.event;
import java.util.*;
-
/**
* The listener that is notified when an application instance is
* terminated.
diff --git a/netx/net/sourceforge/jnlp/event/DownloadEvent.java b/netx/net/sourceforge/jnlp/event/DownloadEvent.java
index a5697d1..9d07c2f 100644
--- a/netx/net/sourceforge/jnlp/event/DownloadEvent.java
+++ b/netx/net/sourceforge/jnlp/event/DownloadEvent.java
@@ -38,7 +38,6 @@ public class DownloadEvent extends EventObject {
/** the resource */
private Resource resource;
-
/**
* Creates a launch event for the specified application
* instance.
diff --git a/netx/net/sourceforge/jnlp/event/DownloadListener.java b/netx/net/sourceforge/jnlp/event/DownloadListener.java
index b9816b9..dfdd42d 100644
--- a/netx/net/sourceforge/jnlp/event/DownloadListener.java
+++ b/netx/net/sourceforge/jnlp/event/DownloadListener.java
@@ -14,12 +14,10 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.event;
import java.util.*;
-
/**
* The listener that is notified of the state of resources being
* downloaded by a ResourceTracker. Events may be delivered on a
diff --git a/netx/net/sourceforge/jnlp/runtime/AppThreadGroup.java b/netx/net/sourceforge/jnlp/runtime/AppThreadGroup.java
index 84ee28f..5287975 100644
--- a/netx/net/sourceforge/jnlp/runtime/AppThreadGroup.java
+++ b/netx/net/sourceforge/jnlp/runtime/AppThreadGroup.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.runtime;
import java.awt.*;
@@ -30,7 +29,6 @@ public class AppThreadGroup extends ThreadGroup {
/** the app */
private ApplicationInstance app = null;
-
/**
* Creates new JavaAppThreadGroup
*
@@ -64,5 +62,4 @@ public class AppThreadGroup extends ThreadGroup {
super.uncaughtException(t, e);
}
-
}
diff --git a/netx/net/sourceforge/jnlp/runtime/AppletAudioClip.java b/netx/net/sourceforge/jnlp/runtime/AppletAudioClip.java
index 3b62e0d..ea6bbc2 100644
--- a/netx/net/sourceforge/jnlp/runtime/AppletAudioClip.java
+++ b/netx/net/sourceforge/jnlp/runtime/AppletAudioClip.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.runtime;
import java.net.*;
@@ -35,7 +34,6 @@ public class AppletAudioClip implements AudioClip {
/** the clip */
private Clip clip;
-
/**
* Creates new AudioClip. If the clip cannot be opened no
* exception is thrown, instead the methods of the AudioClip
@@ -49,9 +47,8 @@ public class AppletAudioClip implements AudioClip {
clip = (Clip) AudioSystem.getLine(new Line.Info(Clip.class));
clip.open(stream);
- }
- catch (Exception ex) {
- System.err.println("Error loading sound:"+location.toString());
+ } catch (Exception ex) {
+ System.err.println("Error loading sound:" + location.toString());
clip = null;
}
}
diff --git a/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java b/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java
index 65032fe..f55c95d 100644
--- a/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java
+++ b/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.runtime;
import java.applet.*;
@@ -65,7 +64,6 @@ public class AppletEnvironment implements AppletContext, AppletStub {
/** whether the applet has been destroyed */
private boolean destroyed = false;
-
/**
* Create a new applet environment for the applet specified by
* the JNLP file.
@@ -151,7 +149,7 @@ public class AppletEnvironment implements AppletContext, AppletStub {
AppletDesc appletDesc = file.getApplet();
if (cont instanceof AppletStub)
- applet.setStub((AppletStub)cont);
+ applet.setStub((AppletStub) cont);
else
applet.setStub(this);
@@ -171,26 +169,25 @@ public class AppletEnvironment implements AppletContext, AppletStub {
try {
SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
- // do first because some applets need to be displayed before
- // starting (they use Component.getImage or something)
- cont.setVisible(true);
-
- applet.init();
- applet.start();
-
- cont.invalidate(); // this should force the applet to
- cont.validate(); // the correct size and to repaint
- cont.repaint();
- }
+ public void run() {
+ // do first because some applets need to be displayed before
+ // starting (they use Component.getImage or something)
+ cont.setVisible(true);
+
+ applet.init();
+ applet.start();
+
+ cont.invalidate(); // this should force the applet to
+ cont.validate(); // the correct size and to repaint
+ cont.repaint();
+ }
});
} catch (InterruptedException ie) {
} catch (InvocationTargetException ite) {
}
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
if (JNLPRuntime.isDebug())
ex.printStackTrace();
@@ -220,7 +217,7 @@ public class AppletEnvironment implements AppletContext, AppletStub {
public Enumeration<Applet> getApplets() {
checkDestroyed();
- return Collections.enumeration( Arrays.asList(new Applet[] { applet }) );
+ return Collections.enumeration(Arrays.asList(new Applet[] { applet }));
}
/**
@@ -293,7 +290,7 @@ public class AppletEnvironment implements AppletContext, AppletStub {
/**
* Required for JRE1.4, but not implemented yet.
*/
- public Iterator<String> getStreamKeys() {
+ public Iterator<String> getStreamKeys() {
checkDestroyed();
return null;
@@ -350,5 +347,4 @@ public class AppletEnvironment implements AppletContext, AppletStub {
return true;
}
-
}
diff --git a/netx/net/sourceforge/jnlp/runtime/AppletInstance.java b/netx/net/sourceforge/jnlp/runtime/AppletInstance.java
index 51bc801..a7fbce1 100644
--- a/netx/net/sourceforge/jnlp/runtime/AppletInstance.java
+++ b/netx/net/sourceforge/jnlp/runtime/AppletInstance.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.runtime;
import java.applet.*;
@@ -29,7 +28,6 @@ import java.lang.ref.*;
import net.sourceforge.jnlp.*;
-
/**
* Represents a launched application instance created from a JNLP
* file. This class does not control the operation of the applet,
@@ -49,7 +47,6 @@ public class AppletInstance extends ApplicationInstance {
/** the applet environment */
private AppletEnvironment environment;
-
/**
* Create a New Task based on the Specified URL
*/
@@ -124,8 +121,7 @@ public class AppletInstance extends ApplicationInstance {
try {
applet.stop();
applet.destroy();
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
if (JNLPRuntime.isDebug())
ex.printStackTrace();
}
diff --git a/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java b/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java
index 99b576d..f86eb39 100644
--- a/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java
+++ b/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.runtime;
import java.awt.Window;
@@ -54,7 +53,6 @@ public class ApplicationInstance {
// todo: should attempt to unload the environment variables
// installed by the application.
-
/** the file */
private JNLPFile file;
@@ -83,8 +81,8 @@ public class ApplicationInstance {
/** list of application listeners */
private EventListenerList listeners = new EventListenerList();
- /** whether or not this application is signed */
- private boolean isSigned = false;
+ /** whether or not this application is signed */
+ private boolean isSigned = false;
/**
* Create an application instance for the file. This should be done in the
@@ -119,11 +117,11 @@ public class ApplicationInstance {
Object list[] = listeners.getListenerList();
ApplicationEvent event = null;
- for (int i=list.length-1; i>0; i-=2) { // last to first required
+ for (int i = list.length - 1; i > 0; i -= 2) { // last to first required
if (event == null)
event = new ApplicationEvent(this);
- ((ApplicationListener)list[i]).applicationDestroyed(event);
+ ((ApplicationListener) list[i]).applicationDestroyed(event);
}
}
@@ -174,7 +172,7 @@ public class ApplicationInstance {
*/
private boolean shouldCreateShortcut(ShortcutDesc sd) {
String currentSetting = JNLPRuntime.getConfiguration()
- .getProperty(DeploymentConfiguration.KEY_CREATE_DESKTOP_SHORTCUT);
+ .getProperty(DeploymentConfiguration.KEY_CREATE_DESKTOP_SHORTCUT);
boolean createShortcut = false;
/*
@@ -221,7 +219,7 @@ public class ApplicationInstance {
void installEnvironment() {
final PropertyDesc props[] = file.getResources().getProperties();
- CodeSource cs = new CodeSource((URL) null, (java.security.cert.Certificate [])null);
+ CodeSource cs = new CodeSource((URL) null, (java.security.cert.Certificate[]) null);
JNLPClassLoader loader = (JNLPClassLoader) this.loader;
SecurityDesc s = loader.getSecurity();
@@ -229,11 +227,11 @@ public class ApplicationInstance {
ProtectionDomain pd = new ProtectionDomain(cs, s.getPermissions(), null, null);
// Add to hashmap
- AccessControlContext acc = new AccessControlContext(new ProtectionDomain[] {pd});
+ AccessControlContext acc = new AccessControlContext(new ProtectionDomain[] { pd });
PrivilegedAction<Object> installProps = new PrivilegedAction<Object>() {
public Object run() {
- for (int i=0; i < props.length; i++) {
+ for (int i = 0; i < props.length; i++) {
System.setProperty(props[i].getKey(), props[i].getValue());
}
@@ -274,7 +272,7 @@ public class ApplicationInstance {
try {
// destroy resources
- for (int i=0; i < weakWindows.size(); i++) {
+ for (int i = 0; i < weakWindows.size(); i++) {
Window w = weakWindows.get(i);
if (w != null)
w.dispose();
@@ -282,12 +280,12 @@ public class ApplicationInstance {
weakWindows.clear();
- // interrupt threads
- Thread threads[] = new Thread[ group.activeCount() * 2 ];
+ // interrupt threads
+ Thread threads[] = new Thread[group.activeCount() * 2];
int nthreads = group.enumerate(threads);
- for (int i=0; i < nthreads; i++) {
+ for (int i = 0; i < nthreads; i++) {
if (JNLPRuntime.isDebug())
- System.out.println("Interrupt thread: "+threads[i]);
+ System.out.println("Interrupt thread: " + threads[i]);
threads[i].interrupt();
}
@@ -295,17 +293,16 @@ public class ApplicationInstance {
// then stop
Thread.currentThread().yield();
nthreads = group.enumerate(threads);
- for (int i=0; i < nthreads; i++) {
+ for (int i = 0; i < nthreads; i++) {
if (JNLPRuntime.isDebug())
- System.out.println("Stop thread: "+threads[i]);
+ System.out.println("Stop thread: " + threads[i]);
threads[i].stop();
}
// then destroy - except Thread.destroy() not implemented in jdk
- }
- finally {
+ } finally {
stopped = true;
fireDestroyed();
}
@@ -344,12 +341,12 @@ public class ApplicationInstance {
weakWindows.trimToSize();
}
- /**
- * Returns whether or not this jar is signed.
- */
- public boolean isSigned() {
- return isSigned;
- }
+ /**
+ * Returns whether or not this jar is signed.
+ */
+ public boolean isSigned() {
+ return isSigned;
+ }
public AppContext getAppContext() {
return appContext;
diff --git a/netx/net/sourceforge/jnlp/runtime/Boot.java b/netx/net/sourceforge/jnlp/runtime/Boot.java
index c4939b7..b075e65 100644
--- a/netx/net/sourceforge/jnlp/runtime/Boot.java
+++ b/netx/net/sourceforge/jnlp/runtime/Boot.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.runtime;
import static net.sourceforge.jnlp.runtime.Translator.R;
@@ -63,62 +62,60 @@ public final class Boot implements PrivilegedAction<Void> {
/** the text to display before launching the about link */
private static final String aboutMessage = ""
- + "netx v"+version+" - (C)2001-2003 Jon A. Maxwell ([email protected])\n"
- + "\n"
- + R("BLaunchAbout");
+ + "netx v" + version + " - (C)2001-2003 Jon A. Maxwell ([email protected])\n"
+ + "\n"
+ + R("BLaunchAbout");
private static final String miniLicense = "\n"
- + " netx - an open-source JNLP client.\n"
- + " Copyright (C) 2001-2003 Jon A. Maxwell (JAM)\n"
- + "\n"
- + " // This library is free software; you can redistribute it and/or\n"
- + " modify it under the terms of the GNU Lesser General Public\n"
- + " License as published by the Free Software Foundation; either\n"
- + " version 2.1 of the License, or (at your option) any later version.\n"
- + "\n"
- + " This library is distributed in the hope that it will be useful,\n"
- + " but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
- + " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
- + " Lesser General Public License for more details.\n"
- + "\n"
- + " You should have received a copy of the GNU Lesser General Public\n"
- + " License along with this library; if not, write to the Free Software\n"
- + " Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n"
- + "\n";
+ + " netx - an open-source JNLP client.\n"
+ + " Copyright (C) 2001-2003 Jon A. Maxwell (JAM)\n"
+ + "\n"
+ + " // This library is free software; you can redistribute it and/or\n"
+ + " modify it under the terms of the GNU Lesser General Public\n"
+ + " License as published by the Free Software Foundation; either\n"
+ + " version 2.1 of the License, or (at your option) any later version.\n"
+ + "\n"
+ + " This library is distributed in the hope that it will be useful,\n"
+ + " but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
+ + " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
+ + " Lesser General Public License for more details.\n"
+ + "\n"
+ + " You should have received a copy of the GNU Lesser General Public\n"
+ + " License along with this library; if not, write to the Free Software\n"
+ + " Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n"
+ + "\n";
private static final String helpMessage = "\n"
- + "Usage: " + R("BOUsage")+"\n"
- + " " + R("BOUsage2")+"\n"
- + "\n"
- + "control-options:"+"\n"
- + " -about "+R("BOAbout")+"\n"
- + " -viewer "+R("BOViewer")+"\n"
- + "\n"
- + "run-options:"+"\n"
- + " -arg arg "+R("BOArg")+"\n"
- + " -param name=value "+R("BOParam")+"\n"
- + " -property name=value "+R("BOProperty")+"\n"
- + " -update seconds "+R("BOUpdate")+"\n"
- + " -license "+R("BOLicense")+"\n"
- + " -verbose "+R("BOVerbose")+"\n"
- + " -nosecurity "+R("BONosecurity")+"\n"
- + " -noupdate "+R("BONoupdate")+"\n"
- + " -headless "+R("BOHeadless")+"\n"
- + " -strict "+R("BOStrict")+"\n"
- + " -Xnofork "+R("BXnofork")+"\n"
- + " -Xclearcache "+R("BXclearcache")+"\n"
- + " -help "+R("BOHelp")+"\n";
+ + "Usage: " + R("BOUsage") + "\n"
+ + " " + R("BOUsage2") + "\n"
+ + "\n"
+ + "control-options:" + "\n"
+ + " -about " + R("BOAbout") + "\n"
+ + " -viewer " + R("BOViewer") + "\n"
+ + "\n"
+ + "run-options:" + "\n"
+ + " -arg arg " + R("BOArg") + "\n"
+ + " -param name=value " + R("BOParam") + "\n"
+ + " -property name=value " + R("BOProperty") + "\n"
+ + " -update seconds " + R("BOUpdate") + "\n"
+ + " -license " + R("BOLicense") + "\n"
+ + " -verbose " + R("BOVerbose") + "\n"
+ + " -nosecurity " + R("BONosecurity") + "\n"
+ + " -noupdate " + R("BONoupdate") + "\n"
+ + " -headless " + R("BOHeadless") + "\n"
+ + " -strict " + R("BOStrict") + "\n"
+ + " -Xnofork " + R("BXnofork") + "\n"
+ + " -Xclearcache " + R("BXclearcache") + "\n"
+ + " -help " + R("BOHelp") + "\n";
/** the JNLP file to open to display the network-based about window */
private static final String NETX_ABOUT_FILE = System.getProperty("java.home") + File.separator + "lib"
+ File.separator + "about.jnlp";
-
private static final String doubleArgs = "-basedir -jnlp -arg -param -property -update";
private static String args[]; // avoid the hot potato
-
/**
* Launch the JNLP file specified by the command-line arguments.
*/
@@ -155,13 +152,12 @@ public final class Boot implements PrivilegedAction<Void> {
if (null != getOption("-update")) {
int value = Integer.parseInt(getOption("-update"));
- JNLPRuntime.setDefaultUpdatePolicy(new UpdatePolicy(value*1000l));
+ JNLPRuntime.setDefaultUpdatePolicy(new UpdatePolicy(value * 1000l));
}
if (null != getOption("-headless"))
JNLPRuntime.setHeadless(true);
-
if (null != getOption("-noupdate"))
JNLPRuntime.setDefaultUpdatePolicy(UpdatePolicy.NEVER);
@@ -198,11 +194,9 @@ public final class Boot implements PrivilegedAction<Void> {
try {
new Launcher().launch(getFile());
- }
- catch (LaunchException ex) {
+ } catch (LaunchException ex) {
// default handler prints this
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
if (JNLPRuntime.isDebug())
ex.printStackTrace();
@@ -213,7 +207,7 @@ public final class Boot implements PrivilegedAction<Void> {
}
private static void fatalError(String message) {
- System.err.println("netx: "+message);
+ System.err.println("netx: " + message);
System.exit(1);
}
@@ -252,7 +246,7 @@ public final class Boot implements PrivilegedAction<Void> {
}
if (JNLPRuntime.isDebug())
- System.out.println(R("BFileLoc")+": "+location);
+ System.out.println(R("BFileLoc") + ": " + location);
URL url = null;
@@ -306,14 +300,14 @@ public final class Boot implements PrivilegedAction<Void> {
String props[] = getOptions("-property");
ResourcesDesc resources = file.getResources();
- for (int i=0; i < props.length; i++) {
+ for (int i = 0; i < props.length; i++) {
// allows empty property, not sure about validity of that.
int equals = props[i].indexOf("=");
if (equals == -1)
fatalError(R("BBadProp", props[i]));
String key = props[i].substring(0, equals);
- String value = props[i].substring(equals+1, props[i].length());
+ String value = props[i].substring(equals + 1, props[i].length());
resources.addResource(new PropertyDesc(key, value));
}
@@ -327,14 +321,14 @@ public final class Boot implements PrivilegedAction<Void> {
String params[] = getOptions("-param");
AppletDesc applet = file.getApplet();
- for (int i=0; i < params.length; i++) {
+ for (int i = 0; i < params.length; i++) {
// allows empty param, not sure about validity of that.
int equals = params[i].indexOf("=");
if (equals == -1)
fatalError(R("BBadParam", params[i]));
String name = params[i].substring(0, equals);
- String value = params[i].substring(equals+1, params[i].length());
+ String value = params[i].substring(equals + 1, params[i].length());
applet.addParameter(name, value);
}
@@ -345,10 +339,10 @@ public final class Boot implements PrivilegedAction<Void> {
* actually an application (not installer).
*/
private static void addArguments(JNLPFile file) {
- String args[] = getOptions("-arg"); // FYI args also global variable
+ String args[] = getOptions("-arg"); // FYI args also global variable
ApplicationDesc app = file.getApplication();
- for (int i=0; i < args.length; i++) {
+ for (int i = 0; i < args.length; i++) {
app.addArgument(args[i]);
}
}
@@ -401,20 +395,19 @@ public final class Boot implements PrivilegedAction<Void> {
private static String[] getOptions(String option) {
List<String> result = new ArrayList<String>();
- for (int i=0; i < args.length; i++) {
+ for (int i = 0; i < args.length; i++) {
if (option.equals(args[i])) {
if (-1 == doubleArgs.indexOf(option))
result.add(option);
- else
- if (i+1 < args.length)
- result.add(args[i+1]);
+ else if (i + 1 < args.length)
+ result.add(args[i + 1]);
}
if (args[i].startsWith("-") && -1 != doubleArgs.indexOf(args[i]))
i++;
}
- return result.toArray( new String[result.size()] );
+ return result.toArray(new String[result.size()]);
}
}
diff --git a/netx/net/sourceforge/jnlp/runtime/Boot13.java b/netx/net/sourceforge/jnlp/runtime/Boot13.java
index 1b5aaa3..a573a1b 100644
--- a/netx/net/sourceforge/jnlp/runtime/Boot13.java
+++ b/netx/net/sourceforge/jnlp/runtime/Boot13.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.runtime;
import java.lang.reflect.*;
@@ -50,7 +49,7 @@ public class Boot13 extends URLClassLoader {
protected PermissionCollection getPermissions(CodeSource source) {
Permissions result = new Permissions();
- result.add( new AllPermission() );
+ result.add(new AllPermission());
return result;
}
@@ -66,8 +65,7 @@ public class Boot13 extends URLClassLoader {
// but the wrong permissions.
try {
return findClass(name);
- }
- catch (ClassNotFoundException ex) {
+ } catch (ClassNotFoundException ex) {
}
return getParent().loadClass(name);
@@ -89,14 +87,14 @@ public class Boot13 extends URLClassLoader {
System.exit(1);
}
- Boot13 b = new Boot13(new URL[] {cs});
+ Boot13 b = new Boot13(new URL[] { cs });
Thread.currentThread().setContextClassLoader(b); // try to prevent getting the non-policy version of classes
Class<?> c = b.loadClass("net.sourceforge.jnlp.runtime.Boot");
- Method main = c.getDeclaredMethod("main", new Class<?>[] {String[].class} );
+ Method main = c.getDeclaredMethod("main", new Class<?>[] { String[].class });
- main.invoke(null, new Object[] { args } );
+ main.invoke(null, new Object[] { args });
}
}
diff --git a/netx/net/sourceforge/jnlp/runtime/DeploymentConfiguration.java b/netx/net/sourceforge/jnlp/runtime/DeploymentConfiguration.java
index 2a4c963..662730f 100644
--- a/netx/net/sourceforge/jnlp/runtime/DeploymentConfiguration.java
+++ b/netx/net/sourceforge/jnlp/runtime/DeploymentConfiguration.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.runtime;
import java.awt.AWTPermission;
@@ -215,7 +214,7 @@ public final class DeploymentConfiguration {
private Map<String, ConfigValue> unchangeableConfiguration;
public DeploymentConfiguration() {
- currentConfiguration = new HashMap<String,ConfigValue>();
+ currentConfiguration = new HashMap<String, ConfigValue>();
unchangeableConfiguration = new HashMap<String, ConfigValue>();
}
@@ -372,10 +371,10 @@ public final class DeploymentConfiguration {
{ KEY_USER_TRUSTED_CA_CERTS, USER_SECURITY + File.separator + "trusted.cacerts" },
{ KEY_USER_TRUSTED_JSSE_CA_CERTS, USER_SECURITY + File.separator + "trusted.jssecacerts" },
{ KEY_USER_TRUSTED_CERTS, USER_SECURITY + File.separator + "trusted.certs" },
- { KEY_USER_TRUSTED_JSSE_CERTS, USER_SECURITY + File.separator + "trusted.jssecerts"},
+ { KEY_USER_TRUSTED_JSSE_CERTS, USER_SECURITY + File.separator + "trusted.jssecerts" },
{ KEY_USER_TRUSTED_CLIENT_CERTS, USER_SECURITY + File.separator + "trusted.clientcerts" },
{ "deployment.system.security.policy", null },
- { KEY_SYSTEM_TRUSTED_CA_CERTS , SYSTEM_SECURITY + File.separator + "cacerts" },
+ { KEY_SYSTEM_TRUSTED_CA_CERTS, SYSTEM_SECURITY + File.separator + "cacerts" },
{ KEY_SYSTEM_TRUSTED_JSSE_CA_CERTS, SYSTEM_SECURITY + File.separator + "jssecacerts" },
{ KEY_SYSTEM_TRUSTED_CERTS, SYSTEM_SECURITY + File.separator + "trusted.certs" },
{ KEY_SYSTEM_TRUSTED_JSSE_CERTS, SYSTEM_SECURITY + File.separator + "trusted.jssecerts" },
@@ -417,7 +416,7 @@ public final class DeploymentConfiguration {
/* JNLP association */
{ "deployment.javaws.associations", String.valueOf(JNLP_ASSOCIATION_ASK_USER) },
/* desktop integration */
- { KEY_CREATE_DESKTOP_SHORTCUT, ShortcutDesc.CREATE_ASK_USER_IF_HINTED},
+ { KEY_CREATE_DESKTOP_SHORTCUT, ShortcutDesc.CREATE_ASK_USER_IF_HINTED },
/* jre selection */
{ "deployment.javaws.installURL", null },
/* jre management */
@@ -500,7 +499,7 @@ public final class DeploymentConfiguration {
+ systemPropertiesFile);
}
ConfigValue mandatory = systemConfiguration.get("deployment.system.config.mandatory");
- systemPropertiesMandatory = Boolean.valueOf(mandatory == null? null: mandatory.get());
+ systemPropertiesMandatory = Boolean.valueOf(mandatory == null ? null : mandatory.get());
return true;
} else {
if (JNLPRuntime.isDebug()) {
@@ -548,7 +547,6 @@ public final class DeploymentConfiguration {
}
}
-
/**
* Saves all properties that are not part of default or system properties
*
@@ -659,7 +657,7 @@ public final class DeploymentConfiguration {
* @param srcMap the source for reading key value pairs
*/
private void mergeMaps(Map<String, ConfigValue> finalMap, Map<String, ConfigValue> srcMap) {
- for (String key: srcMap.keySet()) {
+ for (String key : srcMap.keySet()) {
ConfigValue configValue = finalMap.get(key);
if (configValue == null) {
configValue = srcMap.get(key);
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
index aac70d0..3ac5014 100644
--- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
@@ -1,4 +1,3 @@
-
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -14,7 +13,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.runtime;
import static net.sourceforge.jnlp.runtime.Translator.R;
@@ -81,8 +79,8 @@ public class JNLPClassLoader extends URLClassLoader {
// resources in an extension.
/** map from JNLPFile url to shared classloader */
- private static Map<String,JNLPClassLoader> urlToLoader =
- new HashMap<String,JNLPClassLoader>(); // never garbage collected!
+ private static Map<String, JNLPClassLoader> urlToLoader =
+ new HashMap<String, JNLPClassLoader>(); // never garbage collected!
/** the directory for native code */
private File nativeDir = null; // if set, some native code exists
@@ -145,7 +143,7 @@ public class JNLPClassLoader extends URLClassLoader {
/** Map of specific codesources to securitydesc */
private HashMap<URL, SecurityDesc> jarLocationSecurityMap =
- new HashMap<URL, SecurityDesc>();
+ new HashMap<URL, SecurityDesc>();
/**
* Create a new JNLPClassLoader from the specified file.
@@ -156,7 +154,7 @@ public class JNLPClassLoader extends URLClassLoader {
super(new URL[0], JNLPClassLoader.class.getClassLoader());
if (JNLPRuntime.isDebug())
- System.out.println("New classloader: "+file.getFileLocation());
+ System.out.println("New classloader: " + file.getFileLocation());
this.file = file;
this.updatePolicy = policy;
@@ -229,12 +227,12 @@ public class JNLPClassLoader extends URLClassLoader {
if (file instanceof PluginBridge) {
if (signing == true) {
this.security = new SecurityDesc(file,
- SecurityDesc.ALL_PERMISSIONS,
- codebase.getHost());
+ SecurityDesc.ALL_PERMISSIONS,
+ codebase.getHost());
} else {
this.security = new SecurityDesc(file,
- SecurityDesc.SANDBOX_PERMISSIONS,
- codebase.getHost());
+ SecurityDesc.SANDBOX_PERMISSIONS,
+ codebase.getHost());
}
} else { //regular jnlp file
@@ -252,8 +250,7 @@ public class JNLPClassLoader extends URLClassLoader {
*/
if (!file.getSecurity().getSecurityType().equals(SecurityDesc.SANDBOX_PERMISSIONS) && !signing) {
throw new LaunchException(file, null, R("LSFatal"), R("LCClient"), R("LUnsignedJarWithSecurity"), R("LUnsignedJarWithSecurityInfo"));
- }
- else if (signing == true) {
+ } else if (signing == true) {
this.security = file.getSecurity();
} else {
this.security = new SecurityDesc(file,
@@ -277,41 +274,41 @@ public class JNLPClassLoader extends URLClassLoader {
if (uniqueKey != null)
baseLoader = urlToLoader.get(uniqueKey);
- try {
+ try {
- // If base loader is null, or the baseloader's file and this
- // file is different, initialize a new loader
- if (baseLoader == null ||
+ // If base loader is null, or the baseloader's file and this
+ // file is different, initialize a new loader
+ if (baseLoader == null ||
!baseLoader.getJNLPFile().getFileLocation().equals(file.getFileLocation())) {
- loader = new JNLPClassLoader(file, policy);
+ loader = new JNLPClassLoader(file, policy);
- // New loader init may have caused extentions to create a
- // loader for this unique key. Check.
- JNLPClassLoader extLoader = urlToLoader.get(uniqueKey);
+ // New loader init may have caused extentions to create a
+ // loader for this unique key. Check.
+ JNLPClassLoader extLoader = urlToLoader.get(uniqueKey);
- if (extLoader != null && extLoader != loader) {
- if (loader.signing && !extLoader.signing)
- if (!SecurityWarning.showNotAllSignedWarningDialog(file))
- throw new LaunchException(file, null, R("LSFatal"), R("LCClient"), R("LSignedAppJarUsingUnsignedJar"), R("LSignedAppJarUsingUnsignedJarInfo"));
+ if (extLoader != null && extLoader != loader) {
+ if (loader.signing && !extLoader.signing)
+ if (!SecurityWarning.showNotAllSignedWarningDialog(file))
+ throw new LaunchException(file, null, R("LSFatal"), R("LCClient"), R("LSignedAppJarUsingUnsignedJar"), R("LSignedAppJarUsingUnsignedJarInfo"));
- loader.merge(extLoader);
- }
+ loader.merge(extLoader);
+ }
// loader is now current + ext. But we also need to think of
// the baseLoader
- if (baseLoader != null && baseLoader != loader) {
- loader.merge(baseLoader);
+ if (baseLoader != null && baseLoader != loader) {
+ loader.merge(baseLoader);
}
- } else {
- // if key is same and locations match, this is the loader we want
- loader = baseLoader;
- }
+ } else {
+ // if key is same and locations match, this is the loader we want
+ loader = baseLoader;
+ }
- } catch (LaunchException e) {
- throw e;
- }
+ } catch (LaunchException e) {
+ throw e;
+ }
// loaders are mapped to a unique key. Only extensions and parent
// share a key, so it is safe to always share based on it
@@ -348,18 +345,17 @@ public class JNLPClassLoader extends URLClassLoader {
loaderList.add(this);
- //if (ext != null) {
- for (int i=0; i < ext.length; i++) {
- try {
- String uniqueKey = this.getJNLPFile().getUniqueKey();
- JNLPClassLoader loader = getInstance(ext[i].getLocation(), uniqueKey, ext[i].getVersion(), updatePolicy);
- loaderList.add(loader);
- }
- catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- //}
+ //if (ext != null) {
+ for (int i = 0; i < ext.length; i++) {
+ try {
+ String uniqueKey = this.getJNLPFile().getUniqueKey();
+ JNLPClassLoader loader = getInstance(ext[i].getLocation(), uniqueKey, ext[i].getVersion(), updatePolicy);
+ loaderList.add(loader);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ //}
loaders = loaderList.toArray(new JNLPClassLoader[loaderList.size()]);
}
@@ -371,15 +367,15 @@ public class JNLPClassLoader extends URLClassLoader {
resourcePermissions = new ArrayList<Permission>();
JARDesc jars[] = resources.getJARs();
- for (int i=0; i < jars.length; i++) {
+ for (int i = 0; i < jars.length; i++) {
Permission p = CacheUtil.getReadPermission(jars[i].getLocation(),
jars[i].getVersion());
if (JNLPRuntime.isDebug()) {
if (p == null)
- System.out.println("Unable to add permission for " + jars[i].getLocation());
+ System.out.println("Unable to add permission for " + jars[i].getLocation());
else
- System.out.println("Permission added: " + p.toString());
+ System.out.println("Permission added: " + p.toString());
}
if (p != null)
resourcePermissions.add(p);
@@ -392,17 +388,17 @@ public class JNLPClassLoader extends URLClassLoader {
*/
void initializeResources() throws LaunchException {
JARDesc jars[] = resources.getJARs();
- if (jars == null || jars.length == 0)
- return;
- /*
- if (jars == null || jars.length == 0) {
- throw new LaunchException(null, null, R("LSFatal"),
- R("LCInit"), R("LFatalVerification"), "No jars!");
- }
- */
+ if (jars == null || jars.length == 0)
+ return;
+ /*
+ if (jars == null || jars.length == 0) {
+ throw new LaunchException(null, null, R("LSFatal"),
+ R("LCInit"), R("LFatalVerification"), "No jars!");
+ }
+ */
List<JARDesc> initialJars = new ArrayList<JARDesc>();
- for (int i=0; i < jars.length; i++) {
+ for (int i = 0; i < jars.length; i++) {
available.add(jars[i]);
@@ -418,94 +414,93 @@ public class JNLPClassLoader extends URLClassLoader {
if (strict)
fillInPartJars(initialJars); // add in each initial part's lazy jars
- if (JNLPRuntime.isVerifying()) {
+ if (JNLPRuntime.isVerifying()) {
- JarSigner js;
- waitForJars(initialJars); //download the jars first.
+ JarSigner js;
+ waitForJars(initialJars); //download the jars first.
- try {
- js = verifyJars(initialJars);
- } catch (Exception e) {
- //we caught an Exception from the JarSigner class.
- //Note: one of these exceptions could be from not being able
- //to read the cacerts or trusted.certs files.
- e.printStackTrace();
- throw new LaunchException(null, null, R("LSFatal"),
+ try {
+ js = verifyJars(initialJars);
+ } catch (Exception e) {
+ //we caught an Exception from the JarSigner class.
+ //Note: one of these exceptions could be from not being able
+ //to read the cacerts or trusted.certs files.
+ e.printStackTrace();
+ throw new LaunchException(null, null, R("LSFatal"),
R("LCInit"), R("LFatalVerification"), R("LFatalVerificationInfo"));
- }
+ }
- //Case when at least one jar has some signing
- if (js.anyJarsSigned()){
- signing = true;
+ //Case when at least one jar has some signing
+ if (js.anyJarsSigned()) {
+ signing = true;
- if (!js.allJarsSigned() &&
+ if (!js.allJarsSigned() &&
!SecurityWarning.showNotAllSignedWarningDialog(file))
- throw new LaunchException(file, null, R("LSFatal"), R("LCClient"), R("LSignedAppJarUsingUnsignedJar"), R("LSignedAppJarUsingUnsignedJarInfo"));
+ throw new LaunchException(file, null, R("LSFatal"), R("LCClient"), R("LSignedAppJarUsingUnsignedJar"), R("LSignedAppJarUsingUnsignedJarInfo"));
+
+ //user does not trust this publisher
+ if (!js.getAlreadyTrustPublisher()) {
+ checkTrustWithUser(js);
+ } else {
+ /**
+ * If the user trusts this publisher (i.e. the publisher's certificate
+ * is in the user's trusted.certs file), we do not show any dialogs.
+ */
+ }
+ } else {
+ signing = false;
+ //otherwise this jar is simply unsigned -- make sure to ask
+ //for permission on certain actions
+ }
+ }
- //user does not trust this publisher
- if (!js.getAlreadyTrustPublisher()) {
- checkTrustWithUser(js);
- } else {
- /**
- * If the user trusts this publisher (i.e. the publisher's certificate
- * is in the user's trusted.certs file), we do not show any dialogs.
- */
- }
- } else {
+ for (JARDesc jarDesc : file.getResources().getJARs()) {
+ try {
+ File cachedFile = tracker.getCacheFile(jarDesc.getLocation());
- signing = false;
- //otherwise this jar is simply unsigned -- make sure to ask
- //for permission on certain actions
- }
+ if (cachedFile == null) {
+ System.err.println("JAR " + jarDesc.getLocation() + " not found. Continuing.");
+ continue; // JAR not found. Keep going.
}
- for (JARDesc jarDesc: file.getResources().getJARs()) {
- try {
- File cachedFile = tracker.getCacheFile(jarDesc.getLocation());
-
- if (cachedFile == null) {
- System.err.println("JAR " + jarDesc.getLocation() + " not found. Continuing.");
- continue; // JAR not found. Keep going.
- }
-
- // TODO: Should be toURI().toURL()
- URL location = cachedFile.toURL();
- SecurityDesc jarSecurity = file.getSecurity();
+ // TODO: Should be toURI().toURL()
+ URL location = cachedFile.toURL();
+ SecurityDesc jarSecurity = file.getSecurity();
- if (file instanceof PluginBridge) {
+ if (file instanceof PluginBridge) {
- URL codebase = null;
+ URL codebase = null;
- if (file.getCodeBase() != null) {
- codebase = file.getCodeBase();
- } else {
- //Fixme: codebase should be the codebase of the Main Jar not
- //the location. Although, it still works in the current state.
- codebase = file.getResources().getMainJAR().getLocation();
- }
+ if (file.getCodeBase() != null) {
+ codebase = file.getCodeBase();
+ } else {
+ //Fixme: codebase should be the codebase of the Main Jar not
+ //the location. Although, it still works in the current state.
+ codebase = file.getResources().getMainJAR().getLocation();
+ }
- jarSecurity = new SecurityDesc(file,
+ jarSecurity = new SecurityDesc(file,
SecurityDesc.ALL_PERMISSIONS,
codebase.getHost());
- }
-
- jarLocationSecurityMap.put(location, jarSecurity);
- } catch (MalformedURLException mfe) {
- System.err.println(mfe.getMessage());
- }
}
+ jarLocationSecurityMap.put(location, jarSecurity);
+ } catch (MalformedURLException mfe) {
+ System.err.println(mfe.getMessage());
+ }
+ }
+
activateJars(initialJars);
}
private void checkTrustWithUser(JarSigner js) throws LaunchException {
if (!js.getRootInCacerts()) { //root cert is not in cacerts
boolean b = SecurityWarning.showCertWarningDialog(
- AccessType.UNVERIFIED, file, js);
+ AccessType.UNVERIFIED, file, js);
if (!b)
throw new LaunchException(null, null, R("LSFatal"),
- R("LCLaunching"), R("LNotVerified"), "");
+ R("LCLaunching"), R("LNotVerified"), "");
} else if (js.getRootInCacerts()) { //root cert is in cacerts
boolean b = false;
if (js.noSigningIssues())
@@ -516,7 +511,7 @@ public class JNLPClassLoader extends URLClassLoader {
AccessType.SIGNING_ERROR, file, js);
if (!b)
throw new LaunchException(null, null, R("LSFatal"),
- R("LCLaunching"), R("LCancelOnUserRequest"), "");
+ R("LCLaunching"), R("LCancelOnUserRequest"), "");
}
}
@@ -527,7 +522,7 @@ public class JNLPClassLoader extends URLClassLoader {
* loaded from the codebase are not cached.
*/
public void enableCodeBase() {
- addURL( file.getCodeBase() ); // nothing happens if called more that once?
+ addURL(file.getCodeBase()); // nothing happens if called more that once?
}
/**
@@ -569,7 +564,7 @@ public class JNLPClassLoader extends URLClassLoader {
// access w/o security dialog once we actually check certificates.
// copy security permissions from SecurityDesc element
- if (security != null) {
+ if (security != null) {
// Security desc. is used only to track security settings for the
// application. However, an application may comprise of multiple
// jars, and as such, security must be evaluated on a per jar basis.
@@ -582,8 +577,7 @@ public class JNLPClassLoader extends URLClassLoader {
// 2. ALL or J2EE permissions must be requested (note: plugin requests ALL automatically)
if (cs.getCodeSigners() != null &&
(getCodeSourceSecurity(cs.getLocation()).getSecurityType().equals(SecurityDesc.ALL_PERMISSIONS) ||
- getCodeSourceSecurity(cs.getLocation()).getSecurityType().equals(SecurityDesc.J2EE_PERMISSIONS))
- ) {
+ getCodeSourceSecurity(cs.getLocation()).getSecurityType().equals(SecurityDesc.J2EE_PERMISSIONS))) {
permissions = getCodeSourceSecurity(cs.getLocation()).getPermissions();
}
@@ -594,12 +588,12 @@ public class JNLPClassLoader extends URLClassLoader {
}
// add in permission to read the cached JAR files
- for (int i=0; i < resourcePermissions.size(); i++)
+ for (int i = 0; i < resourcePermissions.size(); i++)
result.add(resourcePermissions.get(i));
// add in the permissions that the user granted.
- for (int i=0; i < runtimePermissions.size(); i++)
- result.add(runtimePermissions.get(i));
+ for (int i = 0; i < runtimePermissions.size(); i++)
+ result.add(runtimePermissions.get(i));
return result;
}
@@ -614,10 +608,10 @@ public class JNLPClassLoader extends URLClassLoader {
* in the same part).
*/
protected void fillInPartJars(List<JARDesc> jars) {
- for (int i=0; i < jars.size(); i++) {
+ for (int i = 0; i < jars.size(); i++) {
String part = jars.get(i).getPart();
- for (int a=0; a < available.size(); a++) {
+ for (int a = 0; a < available.size(); a++) {
JARDesc jar = available.get(a);
if (part != null && part.equals(jar.getPart()))
@@ -642,7 +636,7 @@ public class JNLPClassLoader extends URLClassLoader {
// transfer the Jars
waitForJars(jars);
- for (int i=0; i < jars.size(); i++) {
+ for (int i = 0; i < jars.size(); i++) {
JARDesc jar = jars.get(i);
available.remove(jar);
@@ -725,13 +719,13 @@ public class JNLPClassLoader extends URLClassLoader {
}
jarSecurity = new SecurityDesc(file,
- SecurityDesc.ALL_PERMISSIONS,
- codebase.getHost());
+ SecurityDesc.ALL_PERMISSIONS,
+ codebase.getHost());
}
jarLocationSecurityMap.put(fileURL, jarSecurity);
- } catch (MalformedURLException mfue) {
+ } catch (MalformedURLException mfue) {
if (JNLPRuntime.isDebug())
System.err.println("Unable to add extracted nested jar to classpath");
@@ -756,7 +750,7 @@ public class JNLPClassLoader extends URLClassLoader {
}
if (JNLPRuntime.isDebug())
- System.err.println("Activate jar: "+location);
+ System.err.println("Activate jar: " + location);
}
catch (Exception ex) {
if (JNLPRuntime.isDebug())
@@ -781,7 +775,7 @@ public class JNLPClassLoader extends URLClassLoader {
*/
protected void activateNative(JARDesc jar) {
if (JNLPRuntime.isDebug())
- System.out.println("Activate native: "+jar.getLocation());
+ System.out.println("Activate native: " + jar.getLocation());
File localFile = tracker.getCacheFile(jar.getLocation());
if (localFile == null)
@@ -803,10 +797,10 @@ public class JNLPClassLoader extends URLClassLoader {
String name = new File(e.getName()).getName();
boolean isLibrary = false;
- for (String suffix: librarySuffixes) {
+ for (String suffix : librarySuffixes) {
if (name.endsWith(suffix)) {
- isLibrary = true;
- break;
+ isLibrary = true;
+ break;
}
}
if (!isLibrary) {
@@ -824,8 +818,7 @@ public class JNLPClassLoader extends URLClassLoader {
new FileOutputStream(outFile));
}
- }
- catch (IOException ex) {
+ } catch (IOException ex) {
if (JNLPRuntime.isDebug())
ex.printStackTrace();
}
@@ -879,7 +872,7 @@ public class JNLPClassLoader extends URLClassLoader {
protected String findLibrary(String lib) {
String syslib = System.mapLibraryName(lib);
- for (File dir: getNativeDirectories()) {
+ for (File dir : getNativeDirectories()) {
File target = new File(dir, syslib);
if (target.exists())
return target.toString();
@@ -896,7 +889,7 @@ public class JNLPClassLoader extends URLClassLoader {
* Try to find the library path from another peer classloader.
*/
protected String findLibraryExt(String lib) {
- for (int i=0; i < loaders.length; i++) {
+ for (int i = 0; i < loaders.length; i++) {
String result = null;
if (loaders[i] != this)
@@ -918,7 +911,7 @@ public class JNLPClassLoader extends URLClassLoader {
private void waitForJars(List jars) {
URL urls[] = new URL[jars.size()];
- for (int i=0; i < jars.size(); i++) {
+ for (int i = 0; i < jars.size(); i++) {
JARDesc jar = (JARDesc) jars.get(i);
urls[i] = jar.getLocation();
@@ -932,18 +925,18 @@ public class JNLPClassLoader extends URLClassLoader {
*
* @param jars the jars to be verified.
*/
- private JarSigner verifyJars(List<JARDesc> jars) throws Exception {
+ private JarSigner verifyJars(List<JARDesc> jars) throws Exception {
- js = new JarSigner();
- js.verifyJars(jars, tracker);
- return js;
- }
+ js = new JarSigner();
+ js.verifyJars(jars, tracker);
+ return js;
+ }
/**
* Find the loaded class in this loader or any of its extension loaders.
*/
protected Class findLoadedClassAll(String name) {
- for (int i=0; i < loaders.length; i++) {
+ for (int i = 0; i < loaders.length; i++) {
Class result = null;
if (loaders[i] == this)
@@ -975,8 +968,8 @@ public class JNLPClassLoader extends URLClassLoader {
parent = ClassLoader.getSystemClassLoader();
return parent.loadClass(name);
+ } catch (ClassNotFoundException ex) {
}
- catch (ClassNotFoundException ex) { }
}
// filter out 'bad' package names like java, javax
@@ -992,13 +985,13 @@ public class JNLPClassLoader extends URLClassLoader {
// Currently this loads jars directly from the site. We cannot cache it because this
// call is initiated from within the applet, which does not have disk read/write permissions
- for (JarIndex index: jarIndexes) {
+ for (JarIndex index : jarIndexes) {
// Non-generic code in sun.misc.JarIndex
@SuppressWarnings("unchecked")
- LinkedList<String> jarList = index.get(name.replace('.', '/'));
+ LinkedList<String> jarList = index.get(name.replace('.', '/'));
if (jarList != null) {
- for (String jarName: jarList) {
+ for (String jarName : jarList) {
JARDesc desc;
try {
desc = new JARDesc(new URL(file.getCodeBase(), jarName),
@@ -1012,7 +1005,7 @@ public class JNLPClassLoader extends URLClassLoader {
tracker.addResource(desc.getLocation(),
desc.getVersion(),
JNLPRuntime.getDefaultUpdatePolicy()
- );
+ );
URL remoteURL;
try {
@@ -1047,15 +1040,15 @@ public class JNLPClassLoader extends URLClassLoader {
* Find the class in this loader or any of its extension loaders.
*/
protected Class findClass(String name) throws ClassNotFoundException {
- for (int i=0; i < loaders.length; i++) {
+ for (int i = 0; i < loaders.length; i++) {
try {
if (loaders[i] == this)
return super.findClass(name);
else
return loaders[i].findClass(name);
+ } catch (ClassNotFoundException ex) {
+ } catch (ClassFormatError cfe) {
}
- catch(ClassNotFoundException ex) { }
- catch(ClassFormatError cfe) {}
}
throw new ClassNotFoundException(name);
@@ -1073,8 +1066,7 @@ public class JNLPClassLoader extends URLClassLoader {
// find it
try {
return findClass(name);
- }
- catch(ClassNotFoundException ex) {
+ } catch (ClassNotFoundException ex) {
}
// add resources until found
@@ -1086,8 +1078,7 @@ public class JNLPClassLoader extends URLClassLoader {
try {
return addedTo.findClass(name);
- }
- catch(ClassNotFoundException ex) {
+ } catch (ClassNotFoundException ex) {
}
}
}
@@ -1099,7 +1090,7 @@ public class JNLPClassLoader extends URLClassLoader {
public URL getResource(String name) {
URL result = super.getResource(name);
- for (int i=1; i < loaders.length; i++)
+ for (int i = 1; i < loaders.length; i++)
if (result == null)
result = loaders[i].getResource(name);
@@ -1114,7 +1105,7 @@ public class JNLPClassLoader extends URLClassLoader {
public Enumeration<URL> findResources(String name) throws IOException {
Vector<URL> resources = new Vector<URL>();
- for (int i=0; i < loaders.length; i++) {
+ for (int i = 0; i < loaders.length; i++) {
Enumeration<URL> e;
if (loaders[i] == this)
@@ -1147,7 +1138,7 @@ public class JNLPClassLoader extends URLClassLoader {
// go through available, check tracker for it and all of its
// part brothers being available immediately, add them.
- for (int i=1; i < loaders.length; i++) {
+ for (int i = 1; i < loaders.length; i++) {
loaders[i].addAvailable();
}
}
@@ -1162,7 +1153,7 @@ public class JNLPClassLoader extends URLClassLoader {
*/
protected JNLPClassLoader addNextResource() {
if (available.size() == 0) {
- for (int i=1; i < loaders.length; i++) {
+ for (int i = 1; i < loaders.length; i++) {
JNLPClassLoader result = loaders[i].addNextResource();
if (result != null)
@@ -1207,50 +1198,50 @@ public class JNLPClassLoader extends URLClassLoader {
return file.getFileLocation().toString();
}
- public boolean getSigning() {
- return signing;
- }
+ public boolean getSigning() {
+ return signing;
+ }
- protected SecurityDesc getSecurity() {
- return security;
- }
+ protected SecurityDesc getSecurity() {
+ return security;
+ }
- /**
- * Returns the security descriptor for given code source URL
- *
- * @param source The code source
- * @return The SecurityDescriptor for that source
- */
+ /**
+ * Returns the security descriptor for given code source URL
+ *
+ * @param source The code source
+ * @return The SecurityDescriptor for that source
+ */
- protected SecurityDesc getCodeSourceSecurity(URL source) {
- return jarLocationSecurityMap.get(source);
- }
+ protected SecurityDesc getCodeSourceSecurity(URL source) {
+ return jarLocationSecurityMap.get(source);
+ }
- /**
- * Merges the code source/security descriptor mapping from another loader
- *
- * @param extLoader The loader form which to merge
- * @throws SecurityException if the code is called from an untrusted source
- */
- private void merge(JNLPClassLoader extLoader) {
+ /**
+ * Merges the code source/security descriptor mapping from another loader
+ *
+ * @param extLoader The loader form which to merge
+ * @throws SecurityException if the code is called from an untrusted source
+ */
+ private void merge(JNLPClassLoader extLoader) {
- try {
- System.getSecurityManager().checkPermission(new AllPermission());
- } catch (SecurityException se) {
- throw new SecurityException("JNLPClassLoader() may only be called from trusted sources!");
- }
+ try {
+ System.getSecurityManager().checkPermission(new AllPermission());
+ } catch (SecurityException se) {
+ throw new SecurityException("JNLPClassLoader() may only be called from trusted sources!");
+ }
- // jars
- for (URL u : extLoader.getURLs())
- addURL(u);
+ // jars
+ for (URL u : extLoader.getURLs())
+ addURL(u);
- // native search paths
- for (File nativeDirectory: extLoader.getNativeDirectories())
+ // native search paths
+ for (File nativeDirectory : extLoader.getNativeDirectories())
addNativeDirectory(nativeDirectory);
// security descriptors
- for (URL key: extLoader.jarLocationSecurityMap.keySet()) {
- jarLocationSecurityMap.put(key, extLoader.jarLocationSecurityMap.get(key));
- }
+ for (URL key : extLoader.jarLocationSecurityMap.keySet()) {
+ jarLocationSecurityMap.put(key, extLoader.jarLocationSecurityMap.get(key));
}
+ }
}
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPPolicy.java b/netx/net/sourceforge/jnlp/runtime/JNLPPolicy.java
index d839fbd..62b6967 100644
--- a/netx/net/sourceforge/jnlp/runtime/JNLPPolicy.java
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPPolicy.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.runtime;
import java.security.*;
@@ -41,7 +40,6 @@ public class JNLPPolicy extends Policy {
/** the previous policy */
private static Policy systemPolicy;
-
protected JNLPPolicy() {
shellSource = JNLPPolicy.class.getProtectionDomain().getCodeSource();
systemSource = Policy.class.getProtectionDomain().getCodeSource();
@@ -59,19 +57,19 @@ public class JNLPPolicy extends Policy {
// if we check the SecurityDesc here then keep in mind that
// code can add properties at runtime to the ResourcesDesc!
if (JNLPRuntime.getApplication() != null) {
- if (JNLPRuntime.getApplication().getClassLoader() instanceof JNLPClassLoader) {
- JNLPClassLoader cl = (JNLPClassLoader) JNLPRuntime.getApplication().getClassLoader();
+ if (JNLPRuntime.getApplication().getClassLoader() instanceof JNLPClassLoader) {
+ JNLPClassLoader cl = (JNLPClassLoader) JNLPRuntime.getApplication().getClassLoader();
- PermissionCollection clPermissions = cl.getPermissions(source);
+ PermissionCollection clPermissions = cl.getPermissions(source);
- // systempolicy permissions need to be accounted for as well
- CodeSource appletCS = new CodeSource(JNLPRuntime.getApplication().getJNLPFile().getSourceLocation(), (java.security.cert.Certificate[]) null);
- Enumeration e = systemPolicy.getPermissions(appletCS).elements();
+ // systempolicy permissions need to be accounted for as well
+ CodeSource appletCS = new CodeSource(JNLPRuntime.getApplication().getJNLPFile().getSourceLocation(), (java.security.cert.Certificate[]) null);
+ Enumeration e = systemPolicy.getPermissions(appletCS).elements();
while (e.hasMoreElements())
clPermissions.add((Permission) e.nextElement());
- return clPermissions;
- }
+ return clPermissions;
+ }
}
// delegate to original Policy object; required to run under WebStart
@@ -91,13 +89,13 @@ public class JNLPPolicy extends Policy {
private Permissions getAllPermissions() {
Permissions result = new Permissions();
- result.add( new AllPermission() );
+ result.add(new AllPermission());
return result;
}
- public boolean implies(ProtectionDomain domain, Permission permission) {
- //Include the permissions that may be added during runtime.
- PermissionCollection pc = getPermissions(domain.getCodeSource());
- return super.implies(domain, permission) || pc.implies(permission);
- }
+ public boolean implies(ProtectionDomain domain, Permission permission) {
+ //Include the permissions that may be added during runtime.
+ PermissionCollection pc = getPermissions(domain.getCodeSource());
+ return super.implies(domain, permission) || pc.implies(permission);
+ }
}
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
index 848a198..1e3a91c 100644
--- a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.runtime;
import java.io.*;
@@ -43,7 +42,6 @@ import net.sourceforge.jnlp.security.VariableX509TrustManager;
import net.sourceforge.jnlp.services.*;
import net.sourceforge.jnlp.util.*;
-
/**
* Configure and access the runtime environment. This class
* stores global jnlp properties such as default download
@@ -98,8 +96,8 @@ public class JNLPRuntime {
/** whether netx is in command-line mode (headless) */
private static boolean headless = false;
- /** whether we'll be checking for jar signing */
- private static boolean verify = true;
+ /** whether we'll be checking for jar signing */
+ private static boolean verify = true;
/** whether the runtime uses security */
private static boolean securityEnabled = true;
@@ -169,7 +167,7 @@ public class JNLPRuntime {
//Setting the system property for javawebstart's version.
//The version stored will be the same as java's version.
System.setProperty("javawebstart.version", "javaws-" +
- System.getProperty("java.version"));
+ System.getProperty("java.version"));
if (headless == false)
checkHeadless();
@@ -333,12 +331,13 @@ public class JNLPRuntime {
return headless;
}
- /**
- * Returns whether we are verifying code signing.
- */
- public static boolean isVerifying() {
- return verify;
- }
+ /**
+ * Returns whether we are verifying code signing.
+ */
+ public static boolean isVerifying() {
+ return verify;
+ }
+
/**
* Sets whether the JNLP client will use any AWT/Swing
* components. In headless mode, client features that use the
@@ -352,13 +351,13 @@ public class JNLPRuntime {
headless = enabled;
}
- /**
- * Sets whether we will verify code signing.
- * @throws IllegalStateException if the runtime was previously initialized
- */
+ /**
+ * Sets whether we will verify code signing.
+ * @throws IllegalStateException if the runtime was previously initialized
+ */
public static void setVerify(boolean enabled) {
- checkInitialized();
- verify = enabled;
+ checkInitialized();
+ verify = enabled;
}
/**
@@ -518,12 +517,11 @@ public class JNLPRuntime {
return null;
else
return result;
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
if (!key.equals("RNoResource"))
- return getMessage("RNoResource", new Object[] {key});
+ return getMessage("RNoResource", new Object[] { key });
else
- return "Missing resource: "+key;
+ return "Missing resource: " + key;
}
}
@@ -578,8 +576,7 @@ public class JNLPRuntime {
try {
if ("true".equalsIgnoreCase(System.getProperty("java.awt.headless")))
headless = true;
- }
- catch (SecurityException ex) {
+ } catch (SecurityException ex) {
}
}
@@ -589,8 +586,7 @@ public class JNLPRuntime {
private static void loadResources() {
try {
resources = ResourceBundle.getBundle("net.sourceforge.jnlp.resources.Messages");
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
throw new IllegalStateException("Missing resource bundle in netx.jar:net/sourceforge/jnlp/resource/Messages.properties");
}
}
@@ -605,14 +601,12 @@ public class JNLPRuntime {
try {
windowIcon = new javax.swing.ImageIcon((new sun.misc.Launcher())
.getClassLoader().getResource("net/sourceforge/jnlp/resources/netx-icon.png")).getImage();
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
if (JNLPRuntime.isDebug())
ex.printStackTrace();
}
}
-
public static void setInitialArgments(List<String> args) {
checkInitialized();
SecurityManager securityManager = System.getSecurityManager();
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java b/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java
index 32a54f8..38a0545 100644
--- a/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.runtime;
import static net.sourceforge.jnlp.runtime.Translator.R;
@@ -95,14 +94,14 @@ class JNLPSecurityManager extends AWTSecurityManager {
/** this exception prevents exiting the JVM */
private SecurityException closeAppEx = // making here prevents huge stack traces
- new SecurityException(R("RShutdown"));
+ new SecurityException(R("RShutdown"));
/** weak list of windows created */
private WeakList<Window> weakWindows = new WeakList<Window>();
/** weak list of applications corresponding to window list */
private WeakList<ApplicationInstance> weakApplications =
- new WeakList<ApplicationInstance>();
+ new WeakList<ApplicationInstance>();
/** weak reference to most app who's windows was most recently activated */
private WeakReference activeApplication = null;
@@ -148,7 +147,7 @@ class JNLPSecurityManager extends AWTSecurityManager {
if (exitClass == null)
return true;
- for (int i=0; i < stack.length; i++)
+ for (int i = 0; i < stack.length; i++)
if (stack[i] == exitClass)
return true;
@@ -182,7 +181,7 @@ class JNLPSecurityManager extends AWTSecurityManager {
* call from event dispatch thread).
*/
protected ApplicationInstance getApplication(Window window) {
- for (int i = weakWindows.size(); i-->0;) {
+ for (int i = weakWindows.size(); i-- > 0;) {
Window w = weakWindows.get(i);
if (w == null) {
weakWindows.remove(i);
@@ -201,17 +200,17 @@ class JNLPSecurityManager extends AWTSecurityManager {
*/
protected ApplicationInstance getApplication(Class stack[], int maxDepth) {
if (maxDepth <= 0)
- maxDepth = stack.length;
+ maxDepth = stack.length;
// this needs to be tightened up
- for (int i=0; i < stack.length && i < maxDepth; i++) {
- if (stack[i].getClassLoader() instanceof JNLPClassLoader) {
- JNLPClassLoader loader = (JNLPClassLoader) stack[i].getClassLoader();
+ for (int i = 0; i < stack.length && i < maxDepth; i++) {
+ if (stack[i].getClassLoader() instanceof JNLPClassLoader) {
+ JNLPClassLoader loader = (JNLPClassLoader) stack[i].getClassLoader();
- if (loader != null && loader.getApplication() != null) {
- return loader.getApplication();
- }
+ if (loader != null && loader.getApplication() != null) {
+ return loader.getApplication();
}
+ }
}
return null;
@@ -243,113 +242,112 @@ class JNLPSecurityManager extends AWTSecurityManager {
// System.out.println("Checking permission: " + perm.toString());
if (!JNLPRuntime.isWebstartApplication() &&
- ("setPolicy".equals(name) || "setSecurityManager".equals(name)))
+ ("setPolicy".equals(name) || "setSecurityManager".equals(name)))
throw new SecurityException(R("RCantReplaceSM"));
try {
// deny all permissions to stopped applications
- // The call to getApplication() below might not work if an
- // application hasn't been fully initialized yet.
-// if (JNLPRuntime.isDebug()) {
-// if (!"getClassLoader".equals(name)) {
-// ApplicationInstance app = getApplication();
-// if (app != null && !app.isRunning())
-// throw new SecurityException(R("RDenyStopped"));
-// }
-// }
+ // The call to getApplication() below might not work if an
+ // application hasn't been fully initialized yet.
+ // if (JNLPRuntime.isDebug()) {
+ // if (!"getClassLoader".equals(name)) {
+ // ApplicationInstance app = getApplication();
+ // if (app != null && !app.isRunning())
+ // throw new SecurityException(R("RDenyStopped"));
+ // }
+ // }
+
+ try {
+ super.checkPermission(perm);
+ } catch (SecurityException se) {
+
+ //This section is a special case for dealing with SocketPermissions.
+ if (JNLPRuntime.isDebug())
+ System.err.println("Requesting permission: " + perm.toString());
+
+ //Change this SocketPermission's action to connect and accept
+ //(and resolve). This is to avoid asking for connect permission
+ //on every address resolve.
+ Permission tmpPerm = null;
+ if (perm instanceof SocketPermission) {
+ tmpPerm = new SocketPermission(perm.getName(),
+ SecurityConstants.SOCKET_CONNECT_ACCEPT_ACTION);
+
+ // before proceeding, check if we are trying to connect to same origin
+ ApplicationInstance app = getApplication();
+ JNLPFile file = app.getJNLPFile();
+
+ String srcHost = file.getSourceLocation().getAuthority();
+ String destHost = name;
+
+ // host = abc.xyz.com or abc.xyz.com:<port>
+ if (destHost.indexOf(':') >= 0)
+ destHost = destHost.substring(0, destHost.indexOf(':'));
+
+ // host = abc.xyz.com
+ String[] hostComponents = destHost.split("\\.");
+ int length = hostComponents.length;
+ if (length >= 2) {
+
+ // address is in xxx.xxx.xxx format
+ destHost = hostComponents[length - 2] + "." + hostComponents[length - 1];
+
+ // host = xyz.com i.e. origin
+ boolean isDestHostName = false;
+
+ // make sure that it is not an ip address
try {
- super.checkPermission(perm);
- } catch (SecurityException se) {
-
- //This section is a special case for dealing with SocketPermissions.
- if (JNLPRuntime.isDebug())
- System.err.println("Requesting permission: " + perm.toString());
-
- //Change this SocketPermission's action to connect and accept
- //(and resolve). This is to avoid asking for connect permission
- //on every address resolve.
- Permission tmpPerm = null;
- if (perm instanceof SocketPermission) {
- tmpPerm = new SocketPermission(perm.getName(),
- SecurityConstants.SOCKET_CONNECT_ACCEPT_ACTION);
+ Integer.parseInt(hostComponents[length - 1]);
+ } catch (NumberFormatException e) {
+ isDestHostName = true;
+ }
- // before proceeding, check if we are trying to connect to same origin
- ApplicationInstance app = getApplication();
- JNLPFile file = app.getJNLPFile();
-
- String srcHost = file.getSourceLocation().getAuthority();
- String destHost = name;
-
- // host = abc.xyz.com or abc.xyz.com:<port>
- if (destHost.indexOf(':') >= 0)
- destHost = destHost.substring(0, destHost.indexOf(':'));
-
- // host = abc.xyz.com
- String[] hostComponents = destHost.split("\\.");
-
- int length = hostComponents.length;
- if (length >= 2) {
-
- // address is in xxx.xxx.xxx format
- destHost = hostComponents[length -2] + "." + hostComponents[length -1];
-
- // host = xyz.com i.e. origin
- boolean isDestHostName = false;
-
- // make sure that it is not an ip address
- try {
- Integer.parseInt(hostComponents[length -1]);
- } catch (NumberFormatException e) {
- isDestHostName = true;
- }
-
- if (isDestHostName) {
- // okay, destination is hostname. Now figure out if it is a subset of origin
- if (srcHost.endsWith(destHost)) {
- addPermission(tmpPerm);
- return;
- }
- }
- }
-
- } else if (perm instanceof SecurityPermission) {
-
- // JCE's initialization requires putProviderProperty permission
- if (perm.equals(new SecurityPermission("putProviderProperty.SunJCE"))) {
- if (inTrustedCallChain("com.sun.crypto.provider.SunJCE", "run")) {
- return;
- }
- }
-
- } else if (perm instanceof RuntimePermission) {
-
- // KeyGenerator's init method requires internal spec access
- if (perm.equals(new SecurityPermission("accessClassInPackage.sun.security.internal.spec"))) {
- if (inTrustedCallChain("javax.crypto.KeyGenerator", "init")) {
- return;
- }
- }
-
- } else {
- tmpPerm = perm;
- }
-
- if (tmpPerm != null) {
- //askPermission will only prompt the user on SocketPermission
- //meaning we're denying all other SecurityExceptions that may arise.
- if (askPermission(tmpPerm)) {
- addPermission(tmpPerm);
- //return quietly.
- } else {
- throw se;
- }
- }
+ if (isDestHostName) {
+ // okay, destination is hostname. Now figure out if it is a subset of origin
+ if (srcHost.endsWith(destHost)) {
+ addPermission(tmpPerm);
+ return;
+ }
}
- }
- catch (SecurityException ex) {
+ }
+
+ } else if (perm instanceof SecurityPermission) {
+
+ // JCE's initialization requires putProviderProperty permission
+ if (perm.equals(new SecurityPermission("putProviderProperty.SunJCE"))) {
+ if (inTrustedCallChain("com.sun.crypto.provider.SunJCE", "run")) {
+ return;
+ }
+ }
+
+ } else if (perm instanceof RuntimePermission) {
+
+ // KeyGenerator's init method requires internal spec access
+ if (perm.equals(new SecurityPermission("accessClassInPackage.sun.security.internal.spec"))) {
+ if (inTrustedCallChain("javax.crypto.KeyGenerator", "init")) {
+ return;
+ }
+ }
+
+ } else {
+ tmpPerm = perm;
+ }
+
+ if (tmpPerm != null) {
+ //askPermission will only prompt the user on SocketPermission
+ //meaning we're denying all other SecurityExceptions that may arise.
+ if (askPermission(tmpPerm)) {
+ addPermission(tmpPerm);
+ //return quietly.
+ } else {
+ throw se;
+ }
+ }
+ }
+ } catch (SecurityException ex) {
if (JNLPRuntime.isDebug()) {
- System.out.println("Denying permission: "+perm);
+ System.out.println("Denying permission: " + perm);
}
throw ex;
}
@@ -365,9 +363,9 @@ class JNLPSecurityManager extends AWTSecurityManager {
*/
private boolean inTrustedCallChain(String className, String methodName) {
- StackTraceElement[] stack = Thread.currentThread().getStackTrace();
+ StackTraceElement[] stack = Thread.currentThread().getStackTrace();
- for (int i=0; i < stack.length; i++) {
+ for (int i = 0; i < stack.length; i++) {
// Everything up to the desired class/method must be trusted
if (!stack[i].getClass().getProtectionDomain().implies(new AllPermission())) {
@@ -375,7 +373,7 @@ class JNLPSecurityManager extends AWTSecurityManager {
}
if (stack[i].getClassName().equals(className) &&
- stack[i].getMethodName().equals(methodName)) {
+ stack[i].getMethodName().equals(methodName)) {
return true;
}
}
@@ -388,14 +386,14 @@ class JNLPSecurityManager extends AWTSecurityManager {
* @param perm the permission to be granted
* @return true if the permission was granted, false otherwise.
*/
- private boolean askPermission(Permission perm) {
+ private boolean askPermission(Permission perm) {
ApplicationInstance app = getApplication();
if (app != null && !app.isSigned()) {
- if (perm instanceof SocketPermission
+ if (perm instanceof SocketPermission
&& ServiceUtil.checkAccess(AccessType.NETWORK, perm.getName())) {
- return true;
- }
+ return true;
+ }
}
return false;
@@ -408,17 +406,17 @@ class JNLPSecurityManager extends AWTSecurityManager {
private void addPermission(Permission perm) {
if (JNLPRuntime.getApplication().getClassLoader() instanceof JNLPClassLoader) {
- JNLPClassLoader cl = (JNLPClassLoader) JNLPRuntime.getApplication().getClassLoader();
- cl.addPermission(perm);
- if (JNLPRuntime.isDebug()) {
- if (cl.getPermissions(null).implies(perm))
- System.err.println("Added permission: " + perm.toString());
- else
- System.err.println("Unable to add permission: " + perm.toString());
- }
+ JNLPClassLoader cl = (JNLPClassLoader) JNLPRuntime.getApplication().getClassLoader();
+ cl.addPermission(perm);
+ if (JNLPRuntime.isDebug()) {
+ if (cl.getPermissions(null).implies(perm))
+ System.err.println("Added permission: " + perm.toString());
+ else
+ System.err.println("Unable to add permission: " + perm.toString());
+ }
} else {
- if (JNLPRuntime.isDebug())
- System.err.println("Unable to add permission: " + perm + ", classloader not JNLP.");
+ if (JNLPRuntime.isDebug())
+ System.err.println("Unable to add permission: " + perm + ", classloader not JNLP.");
}
}
@@ -435,7 +433,7 @@ class JNLPSecurityManager extends AWTSecurityManager {
Window w = (Window) window;
if (JNLPRuntime.isDebug())
- System.err.println("SM: app: "+app.getTitle()+" is adding a window: "+window+" with appContext "+AppContext.getAppContext());
+ System.err.println("SM: app: " + app.getTitle() + " is adding a window: " + window + " with appContext " + AppContext.getAppContext());
weakWindows.add(w); // for mapping window -> app
weakApplications.add(app);
@@ -445,9 +443,9 @@ class JNLPSecurityManager extends AWTSecurityManager {
// change coffee cup to netx for default icon
if (window instanceof Window)
- for (Window w = (Window)window; w != null; w = w.getOwner())
+ for (Window w = (Window) window; w != null; w = w.getOwner())
if (window instanceof Frame)
- ((Frame)window).setIconImage(JNLPRuntime.getWindowIcon());
+ ((Frame) window).setIconImage(JNLPRuntime.getWindowIcon());
// todo: set awt.appletWarning to custom message
// todo: logo on with glass pane on JFrame/JWindow?
@@ -473,9 +471,9 @@ class JNLPSecurityManager extends AWTSecurityManager {
// applets are not allowed to exit, but the plugin main class (primordial loader) is
Class stack[] = getClassContext();
if (!exitAllowed) {
- for (int i=0; i < stack.length; i++)
- if (stack[i].getClassLoader() != null)
- throw new AccessControlException("Applets may not call System.exit()");
+ for (int i = 0; i < stack.length; i++)
+ if (stack[i].getClassLoader() != null)
+ throw new AccessControlException("Applets may not call System.exit()");
}
super.checkExit(status);
diff --git a/netx/net/sourceforge/jnlp/security/AccessWarningPane.java b/netx/net/sourceforge/jnlp/security/AccessWarningPane.java
index 68b1ef4..d83e45c 100644
--- a/netx/net/sourceforge/jnlp/security/AccessWarningPane.java
+++ b/netx/net/sourceforge/jnlp/security/AccessWarningPane.java
@@ -71,142 +71,141 @@ import net.sourceforge.jnlp.util.FileUtils;
*/
public class AccessWarningPane extends SecurityDialogPanel {
- JCheckBox alwaysAllow;
- Object[] extras;
-
- public AccessWarningPane(SecurityWarningDialog x, CertVerifier certVerifier) {
- super(x, certVerifier);
- addComponents();
+ JCheckBox alwaysAllow;
+ Object[] extras;
+
+ public AccessWarningPane(SecurityWarningDialog x, CertVerifier certVerifier) {
+ super(x, certVerifier);
+ addComponents();
+ }
+
+ public AccessWarningPane(SecurityWarningDialog x, Object[] extras, CertVerifier certVerifier) {
+ super(x, certVerifier);
+ this.extras = extras;
+ addComponents();
+ }
+
+ /**
+ * Creates the actual GUI components, and adds it to this panel
+ */
+ private void addComponents() {
+ AccessType type = parent.getAccessType();
+ JNLPFile file = parent.getFile();
+
+ String name = "";
+ String publisher = "";
+ String from = "";
+
+ //We don't worry about exceptions when trying to fill in
+ //these strings -- we just want to fill in as many as possible.
+ try {
+ name = file.getInformation().getTitle() != null ? file.getInformation().getTitle() : R("SNoAssociatedCertificate");
+ } catch (Exception e) {
}
- public AccessWarningPane(SecurityWarningDialog x, Object[] extras, CertVerifier certVerifier) {
- super(x, certVerifier);
- this.extras = extras;
- addComponents();
+ try {
+ publisher = file.getInformation().getVendor() != null ? file.getInformation().getVendor() : R("SNoAssociatedCertificate");
+ } catch (Exception e) {
}
- /**
- * Creates the actual GUI components, and adds it to this panel
- */
- private void addComponents() {
- AccessType type = parent.getAccessType();
- JNLPFile file = parent.getFile();
-
- String name = "";
- String publisher = "";
- String from = "";
-
- //We don't worry about exceptions when trying to fill in
- //these strings -- we just want to fill in as many as possible.
- try {
- name = file.getInformation().getTitle() != null ? file.getInformation().getTitle() : R("SNoAssociatedCertificate");
- } catch (Exception e) {
- }
-
- try {
- publisher = file.getInformation().getVendor() != null ? file.getInformation().getVendor() : R("SNoAssociatedCertificate");
- } catch (Exception e) {
- }
+ try {
+ from = !file.getInformation().getHomepage().toString().equals("") ? file.getInformation().getHomepage().toString() : file.getSourceLocation().getAuthority();
+ } catch (Exception e) {
+ from = file.getSourceLocation().getAuthority();
+ }
- try {
- from = !file.getInformation().getHomepage().toString().equals("") ? file.getInformation().getHomepage().toString() : file.getSourceLocation().getAuthority();
- } catch (Exception e) {
- from = file.getSourceLocation().getAuthority();
+ //Top label
+ String topLabelText = "";
+ switch (type) {
+ case READ_FILE:
+ if (extras != null && extras.length > 0 && extras[0] instanceof String) {
+ topLabelText = R("SFileReadAccess", FileUtils.displayablePath((String) extras[0]));
+ } else {
+ topLabelText = R("SFileReadAccess", R("AFileOnTheMachine"));
}
-
- //Top label
- String topLabelText = "";
- switch (type) {
- case READ_FILE:
- if (extras != null && extras.length > 0 && extras[0] instanceof String) {
- topLabelText = R("SFileReadAccess", FileUtils.displayablePath((String)extras[0]));
- } else {
- topLabelText = R("SFileReadAccess", R("AFileOnTheMachine"));
- }
- break;
- case WRITE_FILE:
- if (extras != null && extras.length > 0 && extras[0] instanceof String) {
- topLabelText = R("SFileWriteAccess", FileUtils.displayablePath((String)extras[0]));
- } else {
- topLabelText = R("SFileWriteAccess", R("AFileOnTheMachine"));
- }
- break;
- case CREATE_DESTKOP_SHORTCUT:
- topLabelText = R("SDesktopShortcut");
- break;
- case CLIPBOARD_READ:
- topLabelText = R("SClipboardReadAccess");
- break;
- case CLIPBOARD_WRITE:
- topLabelText = R("SClipboardWriteAccess");
- break;
- case PRINTER:
- topLabelText = R("SPrinterAccess");
- break;
- case NETWORK:
- if (extras != null && extras.length >= 0)
- topLabelText = R("SNetworkAccess", extras[0]);
- else
- topLabelText = R("SNetworkAccess", "(address here)");
+ break;
+ case WRITE_FILE:
+ if (extras != null && extras.length > 0 && extras[0] instanceof String) {
+ topLabelText = R("SFileWriteAccess", FileUtils.displayablePath((String) extras[0]));
+ } else {
+ topLabelText = R("SFileWriteAccess", R("AFileOnTheMachine"));
}
-
- ImageIcon icon = new ImageIcon((new sun.misc.Launcher()).getClassLoader().getResource("net/sourceforge/jnlp/resources/warning.png"));
- JLabel topLabel = new JLabel(htmlWrap(topLabelText), icon, SwingConstants.LEFT);
- topLabel.setFont(new Font(topLabel.getFont().toString(),
- Font.BOLD, 12));
- JPanel topPanel = new JPanel(new BorderLayout());
- topPanel.setBackground(Color.WHITE);
- topPanel.add(topLabel, BorderLayout.CENTER);
- topPanel.setPreferredSize(new Dimension(450,100));
- topPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
-
- //application info
- JLabel nameLabel = new JLabel(R("Name") + ": " + name);
- nameLabel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
- JLabel publisherLabel = new JLabel(R("Publisher") + ": " + publisher);
- publisherLabel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
- JLabel fromLabel = new JLabel(R("From") + ": " + from);
- fromLabel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
-
- alwaysAllow = new JCheckBox(R("AlwaysAllowAction"));
- alwaysAllow.setEnabled(false);
-
- JPanel infoPanel = new JPanel(new GridLayout(4,1));
- infoPanel.add(nameLabel);
- infoPanel.add(publisherLabel);
- infoPanel.add(fromLabel);
- infoPanel.add(alwaysAllow);
- infoPanel.setBorder(BorderFactory.createEmptyBorder(25,25,25,25));
-
- //run and cancel buttons
- JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
-
- JButton run = new JButton(R("ButAllow"));
- JButton cancel = new JButton(R("ButCancel"));
- run.addActionListener(createSetValueListener(parent,0));
- run.addActionListener(new CheckBoxListener());
- cancel.addActionListener(createSetValueListener(parent, 1));
- initialFocusComponent = cancel;
- buttonPanel.add(run);
- buttonPanel.add(cancel);
- buttonPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
-
- //all of the above
- setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
- add(topPanel);
- add(infoPanel);
- add(buttonPanel);
-
+ break;
+ case CREATE_DESTKOP_SHORTCUT:
+ topLabelText = R("SDesktopShortcut");
+ break;
+ case CLIPBOARD_READ:
+ topLabelText = R("SClipboardReadAccess");
+ break;
+ case CLIPBOARD_WRITE:
+ topLabelText = R("SClipboardWriteAccess");
+ break;
+ case PRINTER:
+ topLabelText = R("SPrinterAccess");
+ break;
+ case NETWORK:
+ if (extras != null && extras.length >= 0)
+ topLabelText = R("SNetworkAccess", extras[0]);
+ else
+ topLabelText = R("SNetworkAccess", "(address here)");
}
-
- private class CheckBoxListener implements ActionListener {
- public void actionPerformed(ActionEvent e) {
- if (alwaysAllow != null && alwaysAllow.isSelected()) {
- // TODO: somehow tell the ApplicationInstance
- // to stop asking for permission
- }
- }
+ ImageIcon icon = new ImageIcon((new sun.misc.Launcher()).getClassLoader().getResource("net/sourceforge/jnlp/resources/warning.png"));
+ JLabel topLabel = new JLabel(htmlWrap(topLabelText), icon, SwingConstants.LEFT);
+ topLabel.setFont(new Font(topLabel.getFont().toString(),
+ Font.BOLD, 12));
+ JPanel topPanel = new JPanel(new BorderLayout());
+ topPanel.setBackground(Color.WHITE);
+ topPanel.add(topLabel, BorderLayout.CENTER);
+ topPanel.setPreferredSize(new Dimension(450, 100));
+ topPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+
+ //application info
+ JLabel nameLabel = new JLabel(R("Name") + ": " + name);
+ nameLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+ JLabel publisherLabel = new JLabel(R("Publisher") + ": " + publisher);
+ publisherLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+ JLabel fromLabel = new JLabel(R("From") + ": " + from);
+ fromLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+
+ alwaysAllow = new JCheckBox(R("AlwaysAllowAction"));
+ alwaysAllow.setEnabled(false);
+
+ JPanel infoPanel = new JPanel(new GridLayout(4, 1));
+ infoPanel.add(nameLabel);
+ infoPanel.add(publisherLabel);
+ infoPanel.add(fromLabel);
+ infoPanel.add(alwaysAllow);
+ infoPanel.setBorder(BorderFactory.createEmptyBorder(25, 25, 25, 25));
+
+ //run and cancel buttons
+ JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
+
+ JButton run = new JButton(R("ButAllow"));
+ JButton cancel = new JButton(R("ButCancel"));
+ run.addActionListener(createSetValueListener(parent, 0));
+ run.addActionListener(new CheckBoxListener());
+ cancel.addActionListener(createSetValueListener(parent, 1));
+ initialFocusComponent = cancel;
+ buttonPanel.add(run);
+ buttonPanel.add(cancel);
+ buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+
+ //all of the above
+ setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+ add(topPanel);
+ add(infoPanel);
+ add(buttonPanel);
+
+ }
+
+ private class CheckBoxListener implements ActionListener {
+ public void actionPerformed(ActionEvent e) {
+ if (alwaysAllow != null && alwaysAllow.isSelected()) {
+ // TODO: somehow tell the ApplicationInstance
+ // to stop asking for permission
+ }
}
+ }
}
diff --git a/netx/net/sourceforge/jnlp/security/AppletWarningPane.java b/netx/net/sourceforge/jnlp/security/AppletWarningPane.java
index 8bd14ef..5a959bc 100644
--- a/netx/net/sourceforge/jnlp/security/AppletWarningPane.java
+++ b/netx/net/sourceforge/jnlp/security/AppletWarningPane.java
@@ -49,67 +49,66 @@ import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
-
public class AppletWarningPane extends SecurityDialogPanel {
- public AppletWarningPane(SecurityWarningDialog x, CertVerifier certVerifier) {
- super(x, certVerifier);
- addComponents();
- }
+ public AppletWarningPane(SecurityWarningDialog x, CertVerifier certVerifier) {
+ super(x, certVerifier);
+ addComponents();
+ }
- protected void addComponents() {
+ protected void addComponents() {
- //Top label
- String topLabelText = "While support for verifying signed code" +
+ //Top label
+ String topLabelText = "While support for verifying signed code" +
" has not been implemented yet, some applets will not run " +
"properly under the default restricted security level.";
- String bottomLabelText = "Do you want to run this applet under the " +
+ String bottomLabelText = "Do you want to run this applet under the " +
"restricted security level? (clicking No will run this applet " +
"without any security checking, and should only be done if you " +
"trust the applet!)";
- JLabel topLabel = new JLabel(htmlWrap(topLabelText));
- topLabel.setFont(new Font(topLabel.getFont().toString(),
+ JLabel topLabel = new JLabel(htmlWrap(topLabelText));
+ topLabel.setFont(new Font(topLabel.getFont().toString(),
Font.BOLD, 12));
- JPanel topPanel = new JPanel(new BorderLayout());
- topPanel.setBackground(Color.WHITE);
- topPanel.add(topLabel, BorderLayout.CENTER);
- topPanel.setPreferredSize(new Dimension(400,80));
- topPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
-
- JLabel bottomLabel = new JLabel(htmlWrap(bottomLabelText));
- JPanel infoPanel = new JPanel(new BorderLayout());
- infoPanel.add(bottomLabel, BorderLayout.CENTER);
- infoPanel.setPreferredSize(new Dimension(400,80));
- infoPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
-
- //run and cancel buttons
- JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
-
- JButton yes = new JButton("Yes");
- JButton no = new JButton("No");
- JButton cancel = new JButton("Cancel");
- int buttonWidth = cancel.getMinimumSize().width;
- int buttonHeight = cancel.getMinimumSize().height;
- Dimension d = new Dimension(buttonWidth, buttonHeight);
- yes.setPreferredSize(d);
- no.setPreferredSize(d);
- cancel.setPreferredSize(d);
- yes.addActionListener(createSetValueListener(parent, 0));
- no.addActionListener(createSetValueListener(parent, 1));
- cancel.addActionListener(createSetValueListener(parent, 2));
- initialFocusComponent = cancel;
- buttonPanel.add(yes);
- buttonPanel.add(no);
- buttonPanel.add(cancel);
- buttonPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
-
- //all of the above
- setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
- add(topPanel);
- add(infoPanel);
- add(buttonPanel);
-
- }
+ JPanel topPanel = new JPanel(new BorderLayout());
+ topPanel.setBackground(Color.WHITE);
+ topPanel.add(topLabel, BorderLayout.CENTER);
+ topPanel.setPreferredSize(new Dimension(400, 80));
+ topPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+
+ JLabel bottomLabel = new JLabel(htmlWrap(bottomLabelText));
+ JPanel infoPanel = new JPanel(new BorderLayout());
+ infoPanel.add(bottomLabel, BorderLayout.CENTER);
+ infoPanel.setPreferredSize(new Dimension(400, 80));
+ infoPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+
+ //run and cancel buttons
+ JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
+
+ JButton yes = new JButton("Yes");
+ JButton no = new JButton("No");
+ JButton cancel = new JButton("Cancel");
+ int buttonWidth = cancel.getMinimumSize().width;
+ int buttonHeight = cancel.getMinimumSize().height;
+ Dimension d = new Dimension(buttonWidth, buttonHeight);
+ yes.setPreferredSize(d);
+ no.setPreferredSize(d);
+ cancel.setPreferredSize(d);
+ yes.addActionListener(createSetValueListener(parent, 0));
+ no.addActionListener(createSetValueListener(parent, 1));
+ cancel.addActionListener(createSetValueListener(parent, 2));
+ initialFocusComponent = cancel;
+ buttonPanel.add(yes);
+ buttonPanel.add(no);
+ buttonPanel.add(cancel);
+ buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+
+ //all of the above
+ setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+ add(topPanel);
+ add(infoPanel);
+ add(buttonPanel);
+
+ }
}
diff --git a/netx/net/sourceforge/jnlp/security/CertWarningPane.java b/netx/net/sourceforge/jnlp/security/CertWarningPane.java
index 56105e9..215b365 100644
--- a/netx/net/sourceforge/jnlp/security/CertWarningPane.java
+++ b/netx/net/sourceforge/jnlp/security/CertWarningPane.java
@@ -81,162 +81,160 @@ import net.sourceforge.jnlp.util.FileUtils;
*/
public class CertWarningPane extends SecurityDialogPanel {
- JCheckBox alwaysTrust;
- CertVerifier certVerifier;
+ JCheckBox alwaysTrust;
+ CertVerifier certVerifier;
- public CertWarningPane(SecurityWarningDialog x, CertVerifier certVerifier) {
- super(x, certVerifier);
- this.certVerifier = certVerifier;
- addComponents();
- }
-
- /**
- * Creates the actual GUI components, and adds it to this panel
- */
- private void addComponents() {
- AccessType type = parent.getAccessType();
- JNLPFile file = parent.getFile();
- Certificate c = parent.getJarSigner().getPublisher();
-
- String name = "";
- String publisher = "";
- String from = "";
+ public CertWarningPane(SecurityWarningDialog x, CertVerifier certVerifier) {
+ super(x, certVerifier);
+ this.certVerifier = certVerifier;
+ addComponents();
+ }
- //We don't worry about exceptions when trying to fill in
- //these strings -- we just want to fill in as many as possible.
- try {
- if ((certVerifier instanceof HttpsCertVerifier) &&
+ /**
+ * Creates the actual GUI components, and adds it to this panel
+ */
+ private void addComponents() {
+ AccessType type = parent.getAccessType();
+ JNLPFile file = parent.getFile();
+ Certificate c = parent.getJarSigner().getPublisher();
+
+ String name = "";
+ String publisher = "";
+ String from = "";
+
+ //We don't worry about exceptions when trying to fill in
+ //these strings -- we just want to fill in as many as possible.
+ try {
+ if ((certVerifier instanceof HttpsCertVerifier) &&
(c instanceof X509Certificate))
- name = SecurityUtil.getCN(((X509Certificate)c)
+ name = SecurityUtil.getCN(((X509Certificate) c)
.getSubjectX500Principal().getName());
- else if (file instanceof PluginBridge)
- name = file.getTitle();
- else
- name = file.getInformation().getTitle();
- } catch (Exception e) {
- }
+ else if (file instanceof PluginBridge)
+ name = file.getTitle();
+ else
+ name = file.getInformation().getTitle();
+ } catch (Exception e) {
+ }
- try {
- if (c instanceof X509Certificate) {
- publisher = SecurityUtil.getCN(((X509Certificate)c)
+ try {
+ if (c instanceof X509Certificate) {
+ publisher = SecurityUtil.getCN(((X509Certificate) c)
.getSubjectX500Principal().getName());
- }
- } catch (Exception e) {
- }
+ }
+ } catch (Exception e) {
+ }
- try {
- if (file instanceof PluginBridge)
- from = file.getCodeBase().getHost();
- else
- from = file.getInformation().getHomepage().toString();
- } catch (Exception e) {
- }
+ try {
+ if (file instanceof PluginBridge)
+ from = file.getCodeBase().getHost();
+ else
+ from = file.getInformation().getHomepage().toString();
+ } catch (Exception e) {
+ }
- //Top label
- String topLabelText = "";
- String propertyName = "";
- if (certVerifier instanceof HttpsCertVerifier)
- {
- topLabelText = R("SHttpsUnverified") + " " +
+ //Top label
+ String topLabelText = "";
+ String propertyName = "";
+ if (certVerifier instanceof HttpsCertVerifier) {
+ topLabelText = R("SHttpsUnverified") + " " +
R("Continue");
- propertyName = "OptionPane.warningIcon";
- }
- else
- switch (type) {
- case VERIFIED:
- topLabelText = R("SSigVerified");
- propertyName = "OptionPane.informationIcon";
- break;
- case UNVERIFIED:
- topLabelText = R("SSigUnverified");
- propertyName = "OptionPane.warningIcon";
- break;
- case SIGNING_ERROR:
- topLabelText = R("SSignatureError");
- propertyName = "OptionPane.warningIcon";
- break;
- }
- ImageIcon icon = new ImageIcon((new sun.misc.Launcher())
+ propertyName = "OptionPane.warningIcon";
+ } else
+ switch (type) {
+ case VERIFIED:
+ topLabelText = R("SSigVerified");
+ propertyName = "OptionPane.informationIcon";
+ break;
+ case UNVERIFIED:
+ topLabelText = R("SSigUnverified");
+ propertyName = "OptionPane.warningIcon";
+ break;
+ case SIGNING_ERROR:
+ topLabelText = R("SSignatureError");
+ propertyName = "OptionPane.warningIcon";
+ break;
+ }
+ ImageIcon icon = new ImageIcon((new sun.misc.Launcher())
.getClassLoader().getResource("net/sourceforge/jnlp/resources/warning.png"));
- JLabel topLabel = new JLabel(htmlWrap(topLabelText), icon, SwingConstants.LEFT);
- topLabel.setFont(new Font(topLabel.getFont().toString(),
+ JLabel topLabel = new JLabel(htmlWrap(topLabelText), icon, SwingConstants.LEFT);
+ topLabel.setFont(new Font(topLabel.getFont().toString(),
Font.BOLD, 12));
- JPanel topPanel = new JPanel(new BorderLayout());
- topPanel.setBackground(Color.WHITE);
- topPanel.add(topLabel, BorderLayout.CENTER);
- topPanel.setPreferredSize(new Dimension(400,60));
- topPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
-
- //application info
- JLabel nameLabel = new JLabel(R("Name") + ": " + name);
- nameLabel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
- JLabel publisherLabel = new JLabel(R("Publisher") + ": " + publisher);
- publisherLabel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
- JLabel fromLabel = new JLabel(R("From") + ": " + from);
- fromLabel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
-
- alwaysTrust = new JCheckBox(R("SAlwaysTrustPublisher"));
- alwaysTrust.setEnabled(true);
-
- JPanel infoPanel = new JPanel(new GridLayout(4,1));
- infoPanel.add(nameLabel);
- infoPanel.add(publisherLabel);
-
- if (!(certVerifier instanceof HttpsCertVerifier))
- infoPanel.add(fromLabel);
-
- infoPanel.add(alwaysTrust);
- infoPanel.setBorder(BorderFactory.createEmptyBorder(25,25,25,25));
-
- //run and cancel buttons
- JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
- JButton run = new JButton(R("ButRun"));
- JButton cancel = new JButton(R("ButCancel"));
- int buttonWidth = Math.max(run.getMinimumSize().width,
+ JPanel topPanel = new JPanel(new BorderLayout());
+ topPanel.setBackground(Color.WHITE);
+ topPanel.add(topLabel, BorderLayout.CENTER);
+ topPanel.setPreferredSize(new Dimension(400, 60));
+ topPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+
+ //application info
+ JLabel nameLabel = new JLabel(R("Name") + ": " + name);
+ nameLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+ JLabel publisherLabel = new JLabel(R("Publisher") + ": " + publisher);
+ publisherLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+ JLabel fromLabel = new JLabel(R("From") + ": " + from);
+ fromLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+
+ alwaysTrust = new JCheckBox(R("SAlwaysTrustPublisher"));
+ alwaysTrust.setEnabled(true);
+
+ JPanel infoPanel = new JPanel(new GridLayout(4, 1));
+ infoPanel.add(nameLabel);
+ infoPanel.add(publisherLabel);
+
+ if (!(certVerifier instanceof HttpsCertVerifier))
+ infoPanel.add(fromLabel);
+
+ infoPanel.add(alwaysTrust);
+ infoPanel.setBorder(BorderFactory.createEmptyBorder(25, 25, 25, 25));
+
+ //run and cancel buttons
+ JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
+ JButton run = new JButton(R("ButRun"));
+ JButton cancel = new JButton(R("ButCancel"));
+ int buttonWidth = Math.max(run.getMinimumSize().width,
cancel.getMinimumSize().width);
- int buttonHeight = run.getMinimumSize().height;
- Dimension d = new Dimension(buttonWidth, buttonHeight);
- run.setPreferredSize(d);
- cancel.setPreferredSize(d);
- run.addActionListener(createSetValueListener(parent, 0));
- run.addActionListener(new CheckBoxListener());
- cancel.addActionListener(createSetValueListener(parent, 1));
- initialFocusComponent = cancel;
- buttonPanel.add(run);
- buttonPanel.add(cancel);
- buttonPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
-
- //all of the above
- setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
- add(topPanel);
- add(infoPanel);
- add(buttonPanel);
-
- JLabel bottomLabel;
- JButton moreInfo = new JButton(R("ButMoreInformation"));
- moreInfo.addActionListener(new MoreInfoButtonListener());
-
- if (parent.getJarSigner().getRootInCacerts())
- bottomLabel = new JLabel(htmlWrap(R("STrustedSource")));
- else
- bottomLabel = new JLabel(htmlWrap(R("SUntrustedSource")));
-
- JPanel bottomPanel = new JPanel();
- bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.X_AXIS));
- bottomPanel.add(bottomLabel);
- bottomPanel.add(moreInfo);
- bottomPanel.setPreferredSize(new Dimension(500,100));
- bottomPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
- add(bottomPanel);
+ int buttonHeight = run.getMinimumSize().height;
+ Dimension d = new Dimension(buttonWidth, buttonHeight);
+ run.setPreferredSize(d);
+ cancel.setPreferredSize(d);
+ run.addActionListener(createSetValueListener(parent, 0));
+ run.addActionListener(new CheckBoxListener());
+ cancel.addActionListener(createSetValueListener(parent, 1));
+ initialFocusComponent = cancel;
+ buttonPanel.add(run);
+ buttonPanel.add(cancel);
+ buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+
+ //all of the above
+ setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+ add(topPanel);
+ add(infoPanel);
+ add(buttonPanel);
+
+ JLabel bottomLabel;
+ JButton moreInfo = new JButton(R("ButMoreInformation"));
+ moreInfo.addActionListener(new MoreInfoButtonListener());
+
+ if (parent.getJarSigner().getRootInCacerts())
+ bottomLabel = new JLabel(htmlWrap(R("STrustedSource")));
+ else
+ bottomLabel = new JLabel(htmlWrap(R("SUntrustedSource")));
+
+ JPanel bottomPanel = new JPanel();
+ bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.X_AXIS));
+ bottomPanel.add(bottomLabel);
+ bottomPanel.add(moreInfo);
+ bottomPanel.setPreferredSize(new Dimension(500, 100));
+ bottomPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+ add(bottomPanel);
- }
+ }
- private class MoreInfoButtonListener implements ActionListener {
- public void actionPerformed(ActionEvent e) {
- SecurityWarningDialog.showMoreInfoDialog(parent.getJarSigner(),
+ private class MoreInfoButtonListener implements ActionListener {
+ public void actionPerformed(ActionEvent e) {
+ SecurityWarningDialog.showMoreInfoDialog(parent.getJarSigner(),
parent);
- }
}
+ }
/**
* Updates the user's KeyStore of trusted Certificates.
diff --git a/netx/net/sourceforge/jnlp/security/CertsInfoPane.java b/netx/net/sourceforge/jnlp/security/CertsInfoPane.java
index 616dbfe..2c9a826 100644
--- a/netx/net/sourceforge/jnlp/security/CertsInfoPane.java
+++ b/netx/net/sourceforge/jnlp/security/CertsInfoPane.java
@@ -67,66 +67,66 @@ import net.sourceforge.jnlp.tools.*;
*/
public class CertsInfoPane extends SecurityDialogPanel {
- private ArrayList<CertPath> certs;
+ private ArrayList<CertPath> certs;
private JList list;
- protected JTree tree;
+ protected JTree tree;
private JTable table;
private JTextArea output;
private ListSelectionModel listSelectionModel;
private ListSelectionModel tableSelectionModel;
protected String[] certNames;
private String[] columnNames = { R("Field"), R("Value") };
- protected ArrayList<String[][]> certsData;
+ protected ArrayList<String[][]> certsData;
- public CertsInfoPane(SecurityWarningDialog x, CertVerifier certVerifier) {
- super(x, certVerifier);
- addComponents();
- }
+ public CertsInfoPane(SecurityWarningDialog x, CertVerifier certVerifier) {
+ super(x, certVerifier);
+ addComponents();
+ }
- /**
- * Builds the JTree out of CertPaths.
- */
- void buildTree() {
- certs = parent.getJarSigner().getCerts();
- //for now, we're only going to display the first signer, even though
- //jars can be signed by multiple people.
- CertPath firstPath = certs.get(0);
- X509Certificate firstCert =
- ((X509Certificate)firstPath.getCertificates().get(0));
- String subjectString =
+ /**
+ * Builds the JTree out of CertPaths.
+ */
+ void buildTree() {
+ certs = parent.getJarSigner().getCerts();
+ //for now, we're only going to display the first signer, even though
+ //jars can be signed by multiple people.
+ CertPath firstPath = certs.get(0);
+ X509Certificate firstCert =
+ ((X509Certificate) firstPath.getCertificates().get(0));
+ String subjectString =
SecurityUtil.getCN(firstCert.getSubjectX500Principal().getName());
- String issuerString =
+ String issuerString =
SecurityUtil.getCN(firstCert.getIssuerX500Principal().getName());
- DefaultMutableTreeNode top =
+ DefaultMutableTreeNode top =
new DefaultMutableTreeNode(subjectString
+ " (" + issuerString + ")");
- //not self signed
- if (!firstCert.getSubjectDN().equals(firstCert.getIssuerDN())
+ //not self signed
+ if (!firstCert.getSubjectDN().equals(firstCert.getIssuerDN())
&& (firstPath.getCertificates().size() > 1)) {
- X509Certificate secondCert =
- ((X509Certificate)firstPath.getCertificates().get(1));
- subjectString =
+ X509Certificate secondCert =
+ ((X509Certificate) firstPath.getCertificates().get(1));
+ subjectString =
SecurityUtil.getCN(secondCert.getSubjectX500Principal().getName());
- issuerString =
+ issuerString =
SecurityUtil.getCN(secondCert.getIssuerX500Principal().getName());
- top.add(new DefaultMutableTreeNode(subjectString
+ top.add(new DefaultMutableTreeNode(subjectString
+ " (" + issuerString + ")"));
- }
+ }
- tree = new JTree(top);
- tree.getSelectionModel().setSelectionMode
+ tree = new JTree(top);
+ tree.getSelectionModel().setSelectionMode
(TreeSelectionModel.SINGLE_TREE_SELECTION);
- tree.addTreeSelectionListener(new TreeSelectionHandler());
- }
+ tree.addTreeSelectionListener(new TreeSelectionHandler());
+ }
- /**
- * Fills in certsNames, certsData with data from the certificates.
- */
- protected void populateTable() {
- certNames = new String[certs.get(0).getCertificates().size()];
- certsData = new ArrayList<String[][]>();
+ /**
+ * Fills in certsNames, certsData with data from the certificates.
+ */
+ protected void populateTable() {
+ certNames = new String[certs.get(0).getCertificates().size()];
+ certsData = new ArrayList<String[][]>();
for (int i = 0; i < certs.get(0).getCertificates().size(); i++) {
@@ -135,11 +135,11 @@ public class CertsInfoPane extends SecurityDialogPanel {
certNames[i] = SecurityUtil.getCN(c.getSubjectX500Principal().getName())
+ " (" + SecurityUtil.getCN(c.getIssuerX500Principal().getName()) + ")";
}
- }
+ }
- protected String[][] parseCert(X509Certificate c) {
+ protected String[][] parseCert(X509Certificate c) {
- String version = ""+c.getVersion();
+ String version = "" + c.getVersion();
String serialNumber = c.getSerialNumber().toString();
String signatureAlg = c.getSigAlgName();
String issuer = c.getIssuerX500Principal().toString();
@@ -151,146 +151,148 @@ public class CertsInfoPane extends SecurityDialogPanel {
HexDumpEncoder encoder = new HexDumpEncoder();
String signature = encoder.encodeBuffer(c.getSignature());
- String md5Hash = "";
- String sha1Hash = "";
- try {
- MessageDigest digest = MessageDigest.getInstance("MD5");
- digest.update(c.getEncoded());
- md5Hash = makeFingerprint(digest.digest());
-
- digest = MessageDigest.getInstance("SHA-1");
- digest.update(c.getEncoded());
- sha1Hash = makeFingerprint(digest.digest());
- } catch (Exception e) {
- //fail quietly
- }
+ String md5Hash = "";
+ String sha1Hash = "";
+ try {
+ MessageDigest digest = MessageDigest.getInstance("MD5");
+ digest.update(c.getEncoded());
+ md5Hash = makeFingerprint(digest.digest());
+
+ digest = MessageDigest.getInstance("SHA-1");
+ digest.update(c.getEncoded());
+ sha1Hash = makeFingerprint(digest.digest());
+ } catch (Exception e) {
+ //fail quietly
+ }
- String[][] cert = { {R("Version"), version},
- {R("SSerial"), serialNumber},
- {R("SSignatureAlgorithm"), signatureAlg},
- {R("SIssuer"), issuer},
- {R("SValidity"), validity},
- {R("SSubject"), subject},
- {R("SSignature"), signature},
- {R("SMD5Fingerprint"), md5Hash},
- {R("SSHA1Fingerprint"), sha1Hash}
+ String[][] cert = { { R("Version"), version },
+ { R("SSerial"), serialNumber },
+ { R("SSignatureAlgorithm"), signatureAlg },
+ { R("SIssuer"), issuer },
+ { R("SValidity"), validity },
+ { R("SSubject"), subject },
+ { R("SSignature"), signature },
+ { R("SMD5Fingerprint"), md5Hash },
+ { R("SSHA1Fingerprint"), sha1Hash }
};
return cert;
- }
+ }
+ /**
+ * Constructs the GUI components of this panel
+ */
+ protected void addComponents() {
+ buildTree();
+ populateTable();
/**
- * Constructs the GUI components of this panel
- */
- protected void addComponents() {
- buildTree();
- populateTable();
- /**
- //List of Certs
+ //List of Certs
list = new JList(certNames);
- list.setSelectedIndex(0); //assuming there's at least 1 cert
+ list.setSelectedIndex(0); //assuming there's at least 1 cert
listSelectionModel = list.getSelectionModel();
listSelectionModel.addListSelectionListener(new ListSelectionHandler());
JScrollPane listPane = new JScrollPane(list);
- */
- JScrollPane listPane = new JScrollPane(tree);
+ */
+ JScrollPane listPane = new JScrollPane(tree);
//Table of field-value pairs
DefaultTableModel tableModel = new DefaultTableModel(certsData.get(0),
columnNames);
table = new JTable(tableModel);
- table.getTableHeader().setReorderingAllowed(false);
+ table.getTableHeader().setReorderingAllowed(false);
tableSelectionModel = table.getSelectionModel();
tableSelectionModel.addListSelectionListener(new TableSelectionHandler());
table.setFillsViewportHeight(true);
JScrollPane tablePane = new JScrollPane(table);
- tablePane.setPreferredSize(new Dimension(500,200));
+ tablePane.setPreferredSize(new Dimension(500, 200));
//Text area to display the larger values
output = new JTextArea();
output.setEditable(false);
JScrollPane outputPane = new JScrollPane(output,
- ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
- ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
- outputPane.setPreferredSize(new Dimension(500,200));
+ ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
+ ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+ outputPane.setPreferredSize(new Dimension(500, 200));
- //split pane of the field-value pairs and textbox
- JSplitPane rightSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
+ //split pane of the field-value pairs and textbox
+ JSplitPane rightSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
tablePane, outputPane);
- rightSplitPane.setDividerLocation(0.50);
- rightSplitPane.setResizeWeight(0.50);
+ rightSplitPane.setDividerLocation(0.50);
+ rightSplitPane.setResizeWeight(0.50);
- JSplitPane mainPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
+ JSplitPane mainPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
listPane, rightSplitPane);
- mainPane.setDividerLocation(0.30);
- mainPane.setResizeWeight(0.30);
-
- JPanel buttonPane = new JPanel(new BorderLayout());
- JButton close = new JButton(R("ButClose"));
- JButton copyToClipboard = new JButton(R("ButCopy"));
- close.addActionListener(createSetValueListener(parent, 0));
- copyToClipboard.addActionListener(new CopyToClipboardHandler());
- buttonPane.add(close, BorderLayout.EAST);
- buttonPane.add(copyToClipboard, BorderLayout.WEST);
- buttonPane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
-
- add(mainPane, BorderLayout.CENTER);
- add(buttonPane, BorderLayout.SOUTH);
- }
+ mainPane.setDividerLocation(0.30);
+ mainPane.setResizeWeight(0.30);
+
+ JPanel buttonPane = new JPanel(new BorderLayout());
+ JButton close = new JButton(R("ButClose"));
+ JButton copyToClipboard = new JButton(R("ButCopy"));
+ close.addActionListener(createSetValueListener(parent, 0));
+ copyToClipboard.addActionListener(new CopyToClipboardHandler());
+ buttonPane.add(close, BorderLayout.EAST);
+ buttonPane.add(copyToClipboard, BorderLayout.WEST);
+ buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+
+ add(mainPane, BorderLayout.CENTER);
+ add(buttonPane, BorderLayout.SOUTH);
+ }
- /**
- * Copies the currently selected certificate to the system Clipboard.
- */
- private class CopyToClipboardHandler implements ActionListener {
- public void actionPerformed(ActionEvent e) {
- Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
- int certIndex = 0;
- DefaultMutableTreeNode node = (DefaultMutableTreeNode)
- tree.getLastSelectedPathComponent();
- if (node == null) return;
+ /**
+ * Copies the currently selected certificate to the system Clipboard.
+ */
+ private class CopyToClipboardHandler implements ActionListener {
+ public void actionPerformed(ActionEvent e) {
+ Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
+ int certIndex = 0;
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode)
+ tree.getLastSelectedPathComponent();
+ if (node == null)
+ return;
if (node.isRoot())
- certIndex = 0;
+ certIndex = 0;
else if (node.isLeaf())
- certIndex = 1;
-
- String[][] cert = certsData.get(certIndex);
- int rows = cert.length;
- int cols = cert[0].length;
-
- String certString = "";
- for (int i = 0; i < rows; i++) {
- for (int j = 0; j < cols; j++) {
- certString += cert[i][j];
- certString += " ";
- }
- certString += "\n";
- }
-
- clipboard.setContents(new StringSelection(certString), null);
+ certIndex = 1;
+
+ String[][] cert = certsData.get(certIndex);
+ int rows = cert.length;
+ int cols = cert[0].length;
+
+ String certString = "";
+ for (int i = 0; i < rows; i++) {
+ for (int j = 0; j < cols; j++) {
+ certString += cert[i][j];
+ certString += " ";
}
+ certString += "\n";
+ }
+
+ clipboard.setContents(new StringSelection(certString), null);
}
+ }
- /**
- * Updates the JTable when the JTree selection has changed.
- */
- protected class TreeSelectionHandler implements TreeSelectionListener {
- public void valueChanged(TreeSelectionEvent e) {
- DefaultMutableTreeNode node = (DefaultMutableTreeNode)
+ /**
+ * Updates the JTable when the JTree selection has changed.
+ */
+ protected class TreeSelectionHandler implements TreeSelectionListener {
+ public void valueChanged(TreeSelectionEvent e) {
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode)
tree.getLastSelectedPathComponent();
- if (node == null) return;
- if (node.isRoot()) {
- table.setModel(new DefaultTableModel(certsData.get(0),
+ if (node == null)
+ return;
+ if (node.isRoot()) {
+ table.setModel(new DefaultTableModel(certsData.get(0),
columnNames));
- } else if (node.isLeaf()) {
- table.setModel(new DefaultTableModel(certsData.get(1),
+ } else if (node.isLeaf()) {
+ table.setModel(new DefaultTableModel(certsData.get(1),
columnNames));
- }
- }
+ }
}
+ }
- /**
- * Updates the JTable when the selection on the list has changed.
- */
+ /**
+ * Updates the JTable when the selection on the list has changed.
+ */
private class ListSelectionHandler implements ListSelectionListener {
public void valueChanged(ListSelectionEvent e) {
ListSelectionModel lsm = (ListSelectionModel) e.getSource();
@@ -320,24 +322,24 @@ public class CertsInfoPane extends SecurityDialogPanel {
for (int i = minIndex; i <= maxIndex; i++) {
if (lsm.isSelectedIndex(i)) {
- output.setText((String) table.getValueAt(i,1));
+ output.setText((String) table.getValueAt(i, 1));
}
}
}
}
- /**
- * Makes a human readable hash fingerprint.
- * For example: 11:22:33:44:AA:BB:CC:DD:EE:FF.
- */
- private String makeFingerprint(byte[] hash) {
- String fingerprint = "";
- for (int i = 0; i < hash.length; i++) {
- if (!fingerprint.equals(""))
- fingerprint += ":";
- fingerprint += Integer.toHexString(
- ((hash[i] & 0xFF)|0x100)).substring(1,3);
- }
- return fingerprint.toUpperCase();
+ /**
+ * Makes a human readable hash fingerprint.
+ * For example: 11:22:33:44:AA:BB:CC:DD:EE:FF.
+ */
+ private String makeFingerprint(byte[] hash) {
+ String fingerprint = "";
+ for (int i = 0; i < hash.length; i++) {
+ if (!fingerprint.equals(""))
+ fingerprint += ":";
+ fingerprint += Integer.toHexString(
+ ((hash[i] & 0xFF) | 0x100)).substring(1, 3);
}
+ return fingerprint.toUpperCase();
+ }
}
diff --git a/netx/net/sourceforge/jnlp/security/HttpsCertVerifier.java b/netx/net/sourceforge/jnlp/security/HttpsCertVerifier.java
index 966023b..3593291 100644
--- a/netx/net/sourceforge/jnlp/security/HttpsCertVerifier.java
+++ b/netx/net/sourceforge/jnlp/security/HttpsCertVerifier.java
@@ -86,7 +86,7 @@ public class HttpsCertVerifier implements CertVerifier {
public ArrayList<CertPath> getCerts() {
ArrayList<X509Certificate> list = new ArrayList<X509Certificate>();
- for (int i=0; i < chain.length; i++)
+ for (int i = 0; i < chain.length; i++)
list.add(chain[i]);
ArrayList<CertPath> certPaths = new ArrayList<CertPath>();
@@ -104,53 +104,51 @@ public class HttpsCertVerifier implements CertVerifier {
public ArrayList<String> getDetails() {
- boolean hasExpiredCert=false;
- boolean hasExpiringCert=false;
- boolean notYetValidCert=false;
- boolean isUntrusted=false;
+ boolean hasExpiredCert = false;
+ boolean hasExpiringCert = false;
+ boolean notYetValidCert = false;
+ boolean isUntrusted = false;
boolean CNMisMatch = !hostMatched;
- if (! getAlreadyTrustPublisher())
- isUntrusted = true;
-
- for (int i=0; i < chain.length; i++)
- {
- X509Certificate cert = chain[i];
-
- long now = System.currentTimeMillis();
- long SIX_MONTHS = 180*24*60*60*1000L;
- long notAfter = cert.getNotAfter().getTime();
- if (notAfter < now) {
- hasExpiredCert = true;
- } else if (notAfter < now + SIX_MONTHS) {
- hasExpiringCert = true;
- }
-
- try {
- cert.checkValidity();
- } catch (CertificateNotYetValidException cnyve) {
- notYetValidCert = true;
- } catch (CertificateExpiredException cee) {
- hasExpiredCert = true;
- }
+ if (!getAlreadyTrustPublisher())
+ isUntrusted = true;
+
+ for (int i = 0; i < chain.length; i++) {
+ X509Certificate cert = chain[i];
+
+ long now = System.currentTimeMillis();
+ long SIX_MONTHS = 180 * 24 * 60 * 60 * 1000L;
+ long notAfter = cert.getNotAfter().getTime();
+ if (notAfter < now) {
+ hasExpiredCert = true;
+ } else if (notAfter < now + SIX_MONTHS) {
+ hasExpiringCert = true;
+ }
+
+ try {
+ cert.checkValidity();
+ } catch (CertificateNotYetValidException cnyve) {
+ notYetValidCert = true;
+ } catch (CertificateExpiredException cee) {
+ hasExpiredCert = true;
+ }
}
String altNames = getNamesForCert(chain[0]);
if (isUntrusted || hasExpiredCert || hasExpiringCert || notYetValidCert || CNMisMatch) {
- if (isUntrusted)
+ if (isUntrusted)
addToDetails(R("SUntrustedCertificate"));
- if (hasExpiredCert)
+ if (hasExpiredCert)
addToDetails(R("SHasExpiredCert"));
- if (hasExpiringCert)
+ if (hasExpiringCert)
addToDetails(R("SHasExpiringCert"));
- if (notYetValidCert)
+ if (notYetValidCert)
addToDetails(R("SNotYetValidCert"));
- if (CNMisMatch)
- addToDetails(R("SCNMisMatch", altNames, this.hostName));
+ if (CNMisMatch)
+ addToDetails(R("SCNMisMatch", altNames, this.hostName));
}
-
return details;
}
@@ -158,7 +156,6 @@ public class HttpsCertVerifier implements CertVerifier {
String names = "";
-
// We use the specification from
// http://java.sun.com/j2se/1.5.0/docs/api/java/security/cert/X509Certificate.html#getSubjectAlternativeNames()
// to determine the type of address
@@ -174,10 +171,9 @@ public class HttpsCertVerifier implements CertVerifier {
if (subjAltNames != null) {
for (List<?> next : subjAltNames) {
- if ( ((Integer)next.get(0)).intValue() == ALTNAME_IP ||
- ((Integer)next.get(0)).intValue() == ALTNAME_DNS
- ) {
- names += ", " + (String)next.get(1);
+ if (((Integer) next.get(0)).intValue() == ALTNAME_IP ||
+ ((Integer) next.get(0)).intValue() == ALTNAME_DNS) {
+ names += ", " + (String) next.get(1);
}
}
}
@@ -195,26 +191,26 @@ public class HttpsCertVerifier implements CertVerifier {
}
private void addToDetails(String detail) {
- if (!details.contains(detail))
- details.add(detail);
+ if (!details.contains(detail))
+ details.add(detail);
}
public Certificate getPublisher() {
- if (chain.length > 0)
- return (Certificate)chain[0];
- return null;
+ if (chain.length > 0)
+ return (Certificate) chain[0];
+ return null;
}
public Certificate getRoot() {
- if (chain.length > 0)
- return (Certificate)chain[chain.length - 1];
- return null;
+ if (chain.length > 0)
+ return (Certificate) chain[chain.length - 1];
+ return null;
}
public boolean getRootInCacerts() {
try {
KeyStore[] caCertsKeyStores = KeyStores.getCAKeyStores();
- return CertificateUtils.inKeyStores((X509Certificate)getRoot(), caCertsKeyStores);
+ return CertificateUtils.inKeyStores((X509Certificate) getRoot(), caCertsKeyStores);
} catch (Exception e) {
}
return false;
diff --git a/netx/net/sourceforge/jnlp/security/KeyStores.java b/netx/net/sourceforge/jnlp/security/KeyStores.java
index de4aff3..cfabb20 100644
--- a/netx/net/sourceforge/jnlp/security/KeyStores.java
+++ b/netx/net/sourceforge/jnlp/security/KeyStores.java
@@ -368,5 +368,4 @@ public final class KeyStores {
return ks;
}
-
}
diff --git a/netx/net/sourceforge/jnlp/security/MoreInfoPane.java b/netx/net/sourceforge/jnlp/security/MoreInfoPane.java
index 28c9f71..c76002b 100644
--- a/netx/net/sourceforge/jnlp/security/MoreInfoPane.java
+++ b/netx/net/sourceforge/jnlp/security/MoreInfoPane.java
@@ -61,49 +61,49 @@ import javax.swing.SwingConstants;
*/
public class MoreInfoPane extends SecurityDialogPanel {
- public MoreInfoPane(SecurityWarningDialog x, CertVerifier certVerifier) {
- super(x, certVerifier);
- addComponents();
- }
+ public MoreInfoPane(SecurityWarningDialog x, CertVerifier certVerifier) {
+ super(x, certVerifier);
+ addComponents();
+ }
- /**
- * Constructs the GUI components of this panel
- */
- private void addComponents() {
- ArrayList<String> details = certVerifier.getDetails();
-
- int numLabels = details.size();
- JPanel errorPanel = new JPanel(new GridLayout(numLabels,1));
- errorPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
- errorPanel.setPreferredSize(new Dimension(400, 70*(numLabels)));
-
- for (int i = 0; i < numLabels; i++) {
- ImageIcon icon = null;
- if (details.get(i).equals(R("STrustedCertificate")))
- icon = new ImageIcon((new sun.misc.Launcher())
+ /**
+ * Constructs the GUI components of this panel
+ */
+ private void addComponents() {
+ ArrayList<String> details = certVerifier.getDetails();
+
+ int numLabels = details.size();
+ JPanel errorPanel = new JPanel(new GridLayout(numLabels, 1));
+ errorPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+ errorPanel.setPreferredSize(new Dimension(400, 70 * (numLabels)));
+
+ for (int i = 0; i < numLabels; i++) {
+ ImageIcon icon = null;
+ if (details.get(i).equals(R("STrustedCertificate")))
+ icon = new ImageIcon((new sun.misc.Launcher())
.getClassLoader().getResource("net/sourceforge/jnlp/resources/info-small.png"));
- else
- icon = new ImageIcon((new sun.misc.Launcher())
+ else
+ icon = new ImageIcon((new sun.misc.Launcher())
.getClassLoader().getResource("net/sourceforge/jnlp/resources/warning-small.png"));
- errorPanel.add(new JLabel(htmlWrap(details.get(i)), icon, SwingConstants.LEFT));
- }
+ errorPanel.add(new JLabel(htmlWrap(details.get(i)), icon, SwingConstants.LEFT));
+ }
- JPanel buttonsPanel = new JPanel(new BorderLayout());
- JButton certDetails = new JButton(R("SCertificateDetails"));
- certDetails.addActionListener(new CertInfoButtonListener());
- JButton close = new JButton(R("ButClose"));
- close.addActionListener(createSetValueListener(parent, 0));
+ JPanel buttonsPanel = new JPanel(new BorderLayout());
+ JButton certDetails = new JButton(R("SCertificateDetails"));
+ certDetails.addActionListener(new CertInfoButtonListener());
+ JButton close = new JButton(R("ButClose"));
+ close.addActionListener(createSetValueListener(parent, 0));
buttonsPanel.add(certDetails, BorderLayout.WEST);
buttonsPanel.add(close, BorderLayout.EAST);
- buttonsPanel.setBorder(BorderFactory.createEmptyBorder(15,15,15,15));
+ buttonsPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));
add(errorPanel, BorderLayout.NORTH);
add(buttonsPanel, BorderLayout.SOUTH);
- }
+ }
- private class CertInfoButtonListener implements ActionListener {
+ private class CertInfoButtonListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
SecurityWarningDialog.showCertInfoDialog(parent.getJarSigner(),
parent);
diff --git a/netx/net/sourceforge/jnlp/security/NotAllSignedWarningPane.java b/netx/net/sourceforge/jnlp/security/NotAllSignedWarningPane.java
index 6e5b56f..8d2919c 100644
--- a/netx/net/sourceforge/jnlp/security/NotAllSignedWarningPane.java
+++ b/netx/net/sourceforge/jnlp/security/NotAllSignedWarningPane.java
@@ -55,64 +55,63 @@ import javax.swing.SwingConstants;
import net.sourceforge.jnlp.JNLPFile;
-
public class NotAllSignedWarningPane extends SecurityDialogPanel {
- public NotAllSignedWarningPane(SecurityWarningDialog x) {
- super(x);
- addComponents();
- }
+ public NotAllSignedWarningPane(SecurityWarningDialog x) {
+ super(x);
+ addComponents();
+ }
- /**
- * Creates the actual GUI components, and adds it to this panel
- */
- private void addComponents() {
- JNLPFile file = parent.getFile();
+ /**
+ * Creates the actual GUI components, and adds it to this panel
+ */
+ private void addComponents() {
+ JNLPFile file = parent.getFile();
- String topLabelText = R("SNotAllSignedSummary");
- String infoLabelText = R("SNotAllSignedDetail");
- String questionLabelText = R("SNotAllSignedQuestion");
+ String topLabelText = R("SNotAllSignedSummary");
+ String infoLabelText = R("SNotAllSignedDetail");
+ String questionLabelText = R("SNotAllSignedQuestion");
- ImageIcon icon = new ImageIcon((new sun.misc.Launcher()).getClassLoader().getResource("net/sourceforge/jnlp/resources/warning.png"));
- JLabel topLabel = new JLabel(htmlWrap(topLabelText), icon, SwingConstants.LEFT);
- topLabel.setFont(new Font(topLabel.getFont().toString(),
+ ImageIcon icon = new ImageIcon((new sun.misc.Launcher()).getClassLoader().getResource("net/sourceforge/jnlp/resources/warning.png"));
+ JLabel topLabel = new JLabel(htmlWrap(topLabelText), icon, SwingConstants.LEFT);
+ topLabel.setFont(new Font(topLabel.getFont().toString(),
Font.BOLD, 12));
- JPanel topPanel = new JPanel(new BorderLayout());
- topPanel.setBackground(Color.WHITE);
- topPanel.add(topLabel, BorderLayout.CENTER);
- topPanel.setPreferredSize(new Dimension(500,80));
- topPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
-
- JLabel infoLabel = new JLabel(htmlWrap(infoLabelText));
- JPanel infoPanel = new JPanel(new BorderLayout());
- infoPanel.add(infoLabel, BorderLayout.CENTER);
- infoPanel.setPreferredSize(new Dimension(500,100));
- infoPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
-
- JLabel questionLabel = new JLabel(htmlWrap(questionLabelText));
- JPanel questionPanel = new JPanel(new BorderLayout());
- questionPanel.add(questionLabel, BorderLayout.CENTER);
- questionPanel.setPreferredSize(new Dimension(500,100));
- questionPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
-
- //run and cancel buttons
- JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
-
- JButton run = new JButton(R("ButProceed"));
- JButton cancel = new JButton(R("ButCancel"));
- run.addActionListener(createSetValueListener(parent,0));
- cancel.addActionListener(createSetValueListener(parent, 1));
- initialFocusComponent = cancel;
- buttonPanel.add(run);
- buttonPanel.add(cancel);
- buttonPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
-
- //all of the above
- setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
- add(topPanel);
- add(infoPanel);
- add(questionPanel);
- add(buttonPanel);
-
- }
+ JPanel topPanel = new JPanel(new BorderLayout());
+ topPanel.setBackground(Color.WHITE);
+ topPanel.add(topLabel, BorderLayout.CENTER);
+ topPanel.setPreferredSize(new Dimension(500, 80));
+ topPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+
+ JLabel infoLabel = new JLabel(htmlWrap(infoLabelText));
+ JPanel infoPanel = new JPanel(new BorderLayout());
+ infoPanel.add(infoLabel, BorderLayout.CENTER);
+ infoPanel.setPreferredSize(new Dimension(500, 100));
+ infoPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+
+ JLabel questionLabel = new JLabel(htmlWrap(questionLabelText));
+ JPanel questionPanel = new JPanel(new BorderLayout());
+ questionPanel.add(questionLabel, BorderLayout.CENTER);
+ questionPanel.setPreferredSize(new Dimension(500, 100));
+ questionPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+
+ //run and cancel buttons
+ JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
+
+ JButton run = new JButton(R("ButProceed"));
+ JButton cancel = new JButton(R("ButCancel"));
+ run.addActionListener(createSetValueListener(parent, 0));
+ cancel.addActionListener(createSetValueListener(parent, 1));
+ initialFocusComponent = cancel;
+ buttonPanel.add(run);
+ buttonPanel.add(cancel);
+ buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+
+ //all of the above
+ setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+ add(topPanel);
+ add(infoPanel);
+ add(questionPanel);
+ add(buttonPanel);
+
+ }
}
diff --git a/netx/net/sourceforge/jnlp/security/PasswordAuthenticationDialog.java b/netx/net/sourceforge/jnlp/security/PasswordAuthenticationDialog.java
index 0014f94..b05debe 100644
--- a/netx/net/sourceforge/jnlp/security/PasswordAuthenticationDialog.java
+++ b/netx/net/sourceforge/jnlp/security/PasswordAuthenticationDialog.java
@@ -111,7 +111,6 @@ public class PasswordAuthenticationDialog extends JDialog {
c.weightx = 1.0;
add(jtfUserName, c);
-
c = new GridBagConstraints();
c.gridx = 0;
c.gridy = 2;
@@ -142,11 +141,11 @@ public class PasswordAuthenticationDialog extends JDialog {
c.weightx = 0.0;
add(jbOK, c);
- setMinimumSize(new Dimension(400,150));
- setMaximumSize(new Dimension(1024,150));
+ setMinimumSize(new Dimension(400, 150));
+ setMaximumSize(new Dimension(1024, 150));
setAlwaysOnTop(true);
- setSize(400,150);
+ setSize(400, 150);
setLocationRelativeTo(null);
// OK => read supplied info and pass it on
@@ -202,7 +201,7 @@ public class PasswordAuthenticationDialog extends JDialog {
" is requesting authentication. It says \"" + prompt + "\"</html>");
try {
- SwingUtilities.invokeAndWait( new Runnable() {
+ SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
// show dialog to user
setVisible(true);
diff --git a/netx/net/sourceforge/jnlp/security/SecurityDialogPanel.java b/netx/net/sourceforge/jnlp/security/SecurityDialogPanel.java
index ed7921a..23109a8 100644
--- a/netx/net/sourceforge/jnlp/security/SecurityDialogPanel.java
+++ b/netx/net/sourceforge/jnlp/security/SecurityDialogPanel.java
@@ -1,5 +1,5 @@
- /* SecurityDialogPanel.java
- Copyright (C) 2008-2010 Red Hat, Inc.
+/* SecurityDialogPanel.java
+Copyright (C) 2008-2010 Red Hat, Inc.
This file is part of IcedTea.
@@ -49,71 +49,71 @@ import javax.swing.JPanel;
*/
public abstract class SecurityDialogPanel extends JPanel {
- protected SecurityWarningDialog parent;
-
- JComponent initialFocusComponent = null;
-
- CertVerifier certVerifier = null;
-
- public SecurityDialogPanel(SecurityWarningDialog dialog, CertVerifier certVerifier){
- this.parent = dialog;
- this.certVerifier = certVerifier;
- this.setLayout(new BorderLayout());
- }
-
- public SecurityDialogPanel(SecurityWarningDialog dialog) {
- this.parent = dialog;
- this.setLayout(new BorderLayout());
- }
-
- /**
- * Needed to get word wrap working in JLabels.
- */
- protected String htmlWrap (String s) {
- return "<html>"+s+"</html>";
+ protected SecurityWarningDialog parent;
+
+ JComponent initialFocusComponent = null;
+
+ CertVerifier certVerifier = null;
+
+ public SecurityDialogPanel(SecurityWarningDialog dialog, CertVerifier certVerifier) {
+ this.parent = dialog;
+ this.certVerifier = certVerifier;
+ this.setLayout(new BorderLayout());
+ }
+
+ public SecurityDialogPanel(SecurityWarningDialog dialog) {
+ this.parent = dialog;
+ this.setLayout(new BorderLayout());
+ }
+
+ /**
+ * Needed to get word wrap working in JLabels.
+ */
+ protected String htmlWrap(String s) {
+ return "<html>" + s + "</html>";
+ }
+
+ /**
+ * Create an ActionListener suitable for use with buttons. When this {@link ActionListener}
+ * is invoked, it will set the value of the {@link SecurityWarningDialog} and then dispossed.
+ *
+ * @param buttonIndex the index of the button. By convention 0 = Yes. 1 = No, 2 = Cancel
+ * @return
+ */
+ protected ActionListener createSetValueListener(SecurityWarningDialog dialog, int buttonIndex) {
+ return new SetValueHandler(dialog, buttonIndex);
+ }
+
+ @Override
+ public void setVisible(boolean aFlag) {
+ super.setVisible(aFlag);
+ requestFocusOnDefaultButton();
+ }
+
+ public void requestFocusOnDefaultButton() {
+ if (initialFocusComponent != null) {
+ initialFocusComponent.requestFocusInWindow();
}
+ }
- /**
- * Create an ActionListener suitable for use with buttons. When this {@link ActionListener}
- * is invoked, it will set the value of the {@link SecurityWarningDialog} and then dispossed.
- *
- * @param buttonIndex the index of the button. By convention 0 = Yes. 1 = No, 2 = Cancel
- * @return
- */
- protected ActionListener createSetValueListener(SecurityWarningDialog dialog, int buttonIndex) {
- return new SetValueHandler(dialog, buttonIndex);
- }
+ /**
+ * Creates a handler that sets a dialog's value and then disposes it when activated
+ *
+ */
+ private class SetValueHandler implements ActionListener {
- @Override
- public void setVisible(boolean aFlag) {
- super.setVisible(aFlag);
- requestFocusOnDefaultButton();
- }
+ Integer buttonIndex;
+ SecurityWarningDialog dialog;
- public void requestFocusOnDefaultButton() {
- if (initialFocusComponent != null) {
- initialFocusComponent.requestFocusInWindow();
- }
+ public SetValueHandler(SecurityWarningDialog dialog, int buttonIndex) {
+ this.dialog = dialog;
+ this.buttonIndex = buttonIndex;
}
- /**
- * Creates a handler that sets a dialog's value and then disposes it when activated
- *
- */
- private class SetValueHandler implements ActionListener {
-
- Integer buttonIndex;
- SecurityWarningDialog dialog;
-
- public SetValueHandler(SecurityWarningDialog dialog, int buttonIndex) {
- this.dialog = dialog;
- this.buttonIndex = buttonIndex;
- }
-
@Override
public void actionPerformed(ActionEvent e) {
dialog.setValue(buttonIndex);
dialog.dispose();
}
- }
+ }
}
diff --git a/netx/net/sourceforge/jnlp/security/SecurityUtil.java b/netx/net/sourceforge/jnlp/security/SecurityUtil.java
index ebdab60..feb149d 100644
--- a/netx/net/sourceforge/jnlp/security/SecurityUtil.java
+++ b/netx/net/sourceforge/jnlp/security/SecurityUtil.java
@@ -48,15 +48,15 @@ import net.sourceforge.jnlp.security.KeyStores.Type;
public class SecurityUtil {
- private static final char[] password = "changeit".toCharArray();
+ private static final char[] password = "changeit".toCharArray();
- public static String getTrustedCertsFilename() throws Exception{
- return KeyStores.getKeyStoreLocation(Level.USER, Type.CERTS);
- }
+ public static String getTrustedCertsFilename() throws Exception {
+ return KeyStores.getKeyStoreLocation(Level.USER, Type.CERTS);
+ }
- public static char[] getTrustedCertsPassword() {
- return password;
- }
+ public static char[] getTrustedCertsPassword() {
+ return password;
+ }
/**
* Extracts the CN field from a Certificate principal string. Or, if it
@@ -98,55 +98,55 @@ public class SecurityUtil {
for (int i = start + 3; i < principal.length(); i++) {
char ch = principal.charAt(i);
switch (ch) {
- case '"':
- if (escaped) {
- commonName.append(ch);
- escaped = false;
- } else {
- inQuotes = !inQuotes;
- }
- break;
+ case '"':
+ if (escaped) {
+ commonName.append(ch);
+ escaped = false;
+ } else {
+ inQuotes = !inQuotes;
+ }
+ break;
- case '\\':
- if (escaped) {
- commonName.append(ch);
- escaped = false;
- } else {
- escaped = true;
- }
- break;
-
- case ',':
- /* fall through */
- case ';':
- /* fall through */
- case '+':
- if (escaped || inQuotes) {
- commonName.append(ch);
+ case '\\':
if (escaped) {
+ commonName.append(ch);
escaped = false;
+ } else {
+ escaped = true;
}
- } else {
- return commonName.toString();
- }
- break;
-
- default:
- if (escaped && isHexDigit(ch)) {
- hexBits = new char[2];
- hexBits[0] = ch;
- } else if (hexBits != null) {
- if (!isHexDigit(ch)) {
- /* error parsing */
- return "";
+ break;
+
+ case ',':
+ /* fall through */
+ case ';':
+ /* fall through */
+ case '+':
+ if (escaped || inQuotes) {
+ commonName.append(ch);
+ if (escaped) {
+ escaped = false;
+ }
+ } else {
+ return commonName.toString();
}
- hexBits[1] = ch;
- commonName.append((char) Integer.parseInt(new String(hexBits), 16));
- hexBits = null;
- } else {
- commonName.append(ch);
- }
- escaped = false;
+ break;
+
+ default:
+ if (escaped && isHexDigit(ch)) {
+ hexBits = new char[2];
+ hexBits[0] = ch;
+ } else if (hexBits != null) {
+ if (!isHexDigit(ch)) {
+ /* error parsing */
+ return "";
+ }
+ hexBits[1] = ch;
+ commonName.append((char) Integer.parseInt(new String(hexBits), 16));
+ hexBits = null;
+ } else {
+ commonName.append(ch);
+ }
+ escaped = false;
}
}
@@ -158,68 +158,68 @@ public class SecurityUtil {
return ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f'));
}
- /**
- * Checks the user's home directory to see if the trusted.certs file exists.
- * If it does not exist, it tries to create an empty keystore.
- * @return true if the trusted.certs file exists or a new trusted.certs
- * was created successfully, otherwise false.
- */
- public static boolean checkTrustedCertsFile() throws Exception {
+ /**
+ * Checks the user's home directory to see if the trusted.certs file exists.
+ * If it does not exist, it tries to create an empty keystore.
+ * @return true if the trusted.certs file exists or a new trusted.certs
+ * was created successfully, otherwise false.
+ */
+ public static boolean checkTrustedCertsFile() throws Exception {
- File certFile = new File(getTrustedCertsFilename());
+ File certFile = new File(getTrustedCertsFilename());
- //file does not exist
- if (!certFile.isFile()) {
- File dir = certFile.getAbsoluteFile().getParentFile();
- boolean madeDir = false;
- if (!dir.isDirectory()) {
- madeDir = dir.mkdirs();
- }
+ //file does not exist
+ if (!certFile.isFile()) {
+ File dir = certFile.getAbsoluteFile().getParentFile();
+ boolean madeDir = false;
+ if (!dir.isDirectory()) {
+ madeDir = dir.mkdirs();
+ }
- //made directory, or directory exists
- if (madeDir || dir.isDirectory()) {
- KeyStore ks = KeyStore.getInstance("JKS");
- ks.load(null, password);
- FileOutputStream fos = new FileOutputStream(certFile);
- ks.store(fos, password);
- fos.close();
- return true;
- } else {
- return false;
- }
- } else {
- return true;
- }
+ //made directory, or directory exists
+ if (madeDir || dir.isDirectory()) {
+ KeyStore ks = KeyStore.getInstance("JKS");
+ ks.load(null, password);
+ FileOutputStream fos = new FileOutputStream(certFile);
+ ks.store(fos, password);
+ fos.close();
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return true;
}
+ }
- /**
- * Returns the keystore associated with the user's trusted.certs file,
- * or null otherwise.
- */
- public static KeyStore getUserKeyStore() throws Exception {
-
- KeyStore ks = null;
- FileInputStream fis = null;
-
- if (checkTrustedCertsFile()) {
-
- try {
- File file = new File(getTrustedCertsFilename());
- if (file.exists()) {
- fis = new FileInputStream(file);
- ks = KeyStore.getInstance("JKS");
- ks.load(fis, password);
- }
- } catch (Exception e) {
- e.printStackTrace();
- throw e;
- } finally {
- if (fis != null)
- fis.close();
- }
+ /**
+ * Returns the keystore associated with the user's trusted.certs file,
+ * or null otherwise.
+ */
+ public static KeyStore getUserKeyStore() throws Exception {
+
+ KeyStore ks = null;
+ FileInputStream fis = null;
+
+ if (checkTrustedCertsFile()) {
+
+ try {
+ File file = new File(getTrustedCertsFilename());
+ if (file.exists()) {
+ fis = new FileInputStream(file);
+ ks = KeyStore.getInstance("JKS");
+ ks.load(fis, password);
}
- return ks;
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ } finally {
+ if (fis != null)
+ fis.close();
+ }
}
+ return ks;
+ }
/**
* Returns the keystore associated with the JDK cacerts file,
@@ -227,54 +227,54 @@ public class SecurityUtil {
*/
public static KeyStore getCacertsKeyStore() throws Exception {
- KeyStore caks = null;
- FileInputStream fis = null;
+ KeyStore caks = null;
+ FileInputStream fis = null;
- try {
- File file = new File(System.getProperty("java.home")
+ try {
+ File file = new File(System.getProperty("java.home")
+ "/lib/security/cacerts");
- if (file.exists()) {
- fis = new FileInputStream(file);
- caks = KeyStore.getInstance("JKS");
- caks.load(fis, null);
- }
- } catch (Exception e) {
- caks = null;
- } finally {
- if (fis != null)
- fis.close();
- }
+ if (file.exists()) {
+ fis = new FileInputStream(file);
+ caks = KeyStore.getInstance("JKS");
+ caks.load(fis, null);
+ }
+ } catch (Exception e) {
+ caks = null;
+ } finally {
+ if (fis != null)
+ fis.close();
+ }
- return caks;
+ return caks;
}
- /**
- * Returns the keystore associated with the system certs file,
- * or null otherwise.
- */
- public static KeyStore getSystemCertStore() throws Exception {
+ /**
+ * Returns the keystore associated with the system certs file,
+ * or null otherwise.
+ */
+ public static KeyStore getSystemCertStore() throws Exception {
- KeyStore caks = null;
- FileInputStream fis = null;
+ KeyStore caks = null;
+ FileInputStream fis = null;
- try {
- File file = new File(System.getProperty("javax.net.ssl.trustStore"));
- String type = System.getProperty("javax.net.ssl.trustStoreType");
- //String provider = "SUN";
- char[] password = System.getProperty(
+ try {
+ File file = new File(System.getProperty("javax.net.ssl.trustStore"));
+ String type = System.getProperty("javax.net.ssl.trustStoreType");
+ //String provider = "SUN";
+ char[] password = System.getProperty(
"javax.net.ssl.trustStorePassword").toCharArray();
- if (file.exists()) {
- fis = new FileInputStream(file);
- caks = KeyStore.getInstance(type);
- caks.load(fis, password);
- }
- } catch (Exception e) {
- caks = null;
- } finally {
- if (fis != null)
- fis.close();
- }
-
- return caks;
+ if (file.exists()) {
+ fis = new FileInputStream(file);
+ caks = KeyStore.getInstance(type);
+ caks.load(fis, password);
+ }
+ } catch (Exception e) {
+ caks = null;
+ } finally {
+ if (fis != null)
+ fis.close();
}
+
+ return caks;
+ }
}
diff --git a/netx/net/sourceforge/jnlp/security/SecurityWarning.java b/netx/net/sourceforge/jnlp/security/SecurityWarning.java
index c0eda43..863cb2a 100644
--- a/netx/net/sourceforge/jnlp/security/SecurityWarning.java
+++ b/netx/net/sourceforge/jnlp/security/SecurityWarning.java
@@ -35,7 +35,6 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version.
*/
-
package net.sourceforge.jnlp.security;
import java.awt.Dialog.ModalityType;
@@ -97,7 +96,7 @@ public class SecurityWarning {
* @return true if permission was granted by the user, false otherwise.
*/
public static boolean showAccessWarningDialog(AccessType accessType, JNLPFile file) {
- return showAccessWarningDialog(accessType, file, null);
+ return showAccessWarningDialog(accessType, file, null);
}
/**
@@ -111,7 +110,7 @@ public class SecurityWarning {
* @return true if permission was granted by the user, false otherwise.
*/
public static boolean showAccessWarningDialog(final AccessType accessType,
- final JNLPFile file, final Object[] extras) {
+ final JNLPFile file, final Object[] extras) {
if (!shouldPromptUser()) {
return false;
@@ -161,7 +160,7 @@ public class SecurityWarning {
if (selectedValue == null) {
return false;
} else if (selectedValue instanceof Integer) {
- if (((Integer)selectedValue).intValue() == 0) {
+ if (((Integer) selectedValue).intValue() == 0) {
return true;
} else {
return false;
@@ -188,7 +187,7 @@ public class SecurityWarning {
return false;
}
- final SecurityDialogMessage message = new SecurityDialogMessage();
+ final SecurityDialogMessage message = new SecurityDialogMessage();
message.dialogType = DialogType.CERT_WARNING;
message.accessType = accessType;
message.file = file;
diff --git a/netx/net/sourceforge/jnlp/security/SecurityWarningDialog.java b/netx/net/sourceforge/jnlp/security/SecurityWarningDialog.java
index dc17174..60b13f0 100644
--- a/netx/net/sourceforge/jnlp/security/SecurityWarningDialog.java
+++ b/netx/net/sourceforge/jnlp/security/SecurityWarningDialog.java
@@ -62,175 +62,173 @@ import java.util.List;
*/
public class SecurityWarningDialog extends JDialog {
- /** The type of dialog we want to show */
- private DialogType dialogType;
+ /** The type of dialog we want to show */
+ private DialogType dialogType;
- /** The type of access that this dialog is for */
- private AccessType accessType;
+ /** The type of access that this dialog is for */
+ private AccessType accessType;
- private SecurityDialogPanel panel;
+ private SecurityDialogPanel panel;
- /** The application file associated with this security warning */
- private JNLPFile file;
+ /** The application file associated with this security warning */
+ private JNLPFile file;
- private CertVerifier certVerifier;
+ private CertVerifier certVerifier;
- private X509Certificate cert;
+ private X509Certificate cert;
- /** An optional String array that's only necessary when a dialog
- * label requires some parameters (e.g. showing which address an application
- * is trying to connect to).
- */
- private Object[] extras;
+ /** An optional String array that's only necessary when a dialog
+ * label requires some parameters (e.g. showing which address an application
+ * is trying to connect to).
+ */
+ private Object[] extras;
- /** Whether or not this object has been fully initialized */
- private boolean initialized = false;
+ /** Whether or not this object has been fully initialized */
+ private boolean initialized = false;
/**
* the return value of this dialog. result: 0 = Yes, 1 = No, 2 = Cancel,
* null = Window closed.
*/
- private Object value;
+ private Object value;
- SecurityWarningDialog(DialogType dialogType, AccessType accessType,
+ SecurityWarningDialog(DialogType dialogType, AccessType accessType,
JNLPFile file, CertVerifier jarSigner, X509Certificate cert, Object[] extras) {
- super();
- this.dialogType = dialogType;
- this.accessType = accessType;
- this.file = file;
- this.certVerifier = jarSigner;
- this.cert = cert;
- this.extras = extras;
- initialized = true;
-
- initDialog();
- }
+ super();
+ this.dialogType = dialogType;
+ this.accessType = accessType;
+ this.file = file;
+ this.certVerifier = jarSigner;
+ this.cert = cert;
+ this.extras = extras;
+ initialized = true;
+
+ initDialog();
+ }
- /**
- * Construct a SecurityWarningDialog to display some sort of access warning
- */
- SecurityWarningDialog(DialogType dialogType, AccessType accessType,
+ /**
+ * Construct a SecurityWarningDialog to display some sort of access warning
+ */
+ SecurityWarningDialog(DialogType dialogType, AccessType accessType,
JNLPFile file) {
- this(dialogType, accessType, file, null, null, null);
- }
+ this(dialogType, accessType, file, null, null, null);
+ }
- /**
- * Create a SecurityWarningDialog to display a certificate-related warning
- */
- SecurityWarningDialog(DialogType dialogType, AccessType accessType,
+ /**
+ * Create a SecurityWarningDialog to display a certificate-related warning
+ */
+ SecurityWarningDialog(DialogType dialogType, AccessType accessType,
JNLPFile file, CertVerifier jarSigner) {
- this(dialogType, accessType, file, jarSigner, null, null);
- }
+ this(dialogType, accessType, file, jarSigner, null, null);
+ }
- /**
- * Create a SecurityWarningDialog to display a certificate-related warning
- */
- SecurityWarningDialog(DialogType dialogType, AccessType accessType,
+ /**
+ * Create a SecurityWarningDialog to display a certificate-related warning
+ */
+ SecurityWarningDialog(DialogType dialogType, AccessType accessType,
CertVerifier certVerifier) {
- this(dialogType, accessType, null, certVerifier, null, null);
- }
+ this(dialogType, accessType, null, certVerifier, null, null);
+ }
- /**
- * Create a SecurityWarningDialog to display some sort of access warning
- * with more information
- */
- SecurityWarningDialog(DialogType dialogType, AccessType accessType,
+ /**
+ * Create a SecurityWarningDialog to display some sort of access warning
+ * with more information
+ */
+ SecurityWarningDialog(DialogType dialogType, AccessType accessType,
JNLPFile file, Object[] extras) {
- this(dialogType, accessType, file, null, null, extras);
- }
+ this(dialogType, accessType, file, null, null, extras);
+ }
- /**
- * Create a SecurityWarningDailog to display information about a single
- * certificate
- */
- SecurityWarningDialog(DialogType dialogType, X509Certificate c) {
- this(dialogType, null, null, null, c, null);
- }
+ /**
+ * Create a SecurityWarningDailog to display information about a single
+ * certificate
+ */
+ SecurityWarningDialog(DialogType dialogType, X509Certificate c) {
+ this(dialogType, null, null, null, c, null);
+ }
- /**
- * Returns if this dialog has been fully initialized yet.
- * @return true if this dialog has been initialized, and false otherwise.
- */
- public boolean isInitialized(){
- return initialized;
- }
+ /**
+ * Returns if this dialog has been fully initialized yet.
+ * @return true if this dialog has been initialized, and false otherwise.
+ */
+ public boolean isInitialized() {
+ return initialized;
+ }
- /**
- * Shows more information regarding jar code signing
- *
- * @param jarSigner the JarSigner used to verify this application
- * @param parent the parent option pane
- */
- public static void showMoreInfoDialog(
+ /**
+ * Shows more information regarding jar code signing
+ *
+ * @param jarSigner the JarSigner used to verify this application
+ * @param parent the parent option pane
+ */
+ public static void showMoreInfoDialog(
CertVerifier jarSigner, SecurityWarningDialog parent) {
- SecurityWarningDialog dialog =
+ SecurityWarningDialog dialog =
new SecurityWarningDialog(DialogType.MORE_INFO, null, null,
- jarSigner);
- dialog.setModalityType(ModalityType.APPLICATION_MODAL);
- dialog.setVisible(true);
- dialog.dispose();
- }
+ jarSigner);
+ dialog.setModalityType(ModalityType.APPLICATION_MODAL);
+ dialog.setVisible(true);
+ dialog.dispose();
+ }
- /**
- * Displays CertPath information in a readable table format.
- *
- * @param certs the certificates used in signing.
- */
- public static void showCertInfoDialog(CertVerifier jarSigner,
+ /**
+ * Displays CertPath information in a readable table format.
+ *
+ * @param certs the certificates used in signing.
+ */
+ public static void showCertInfoDialog(CertVerifier jarSigner,
SecurityWarningDialog parent) {
- SecurityWarningDialog dialog = new SecurityWarningDialog(DialogType.CERT_INFO,
+ SecurityWarningDialog dialog = new SecurityWarningDialog(DialogType.CERT_INFO,
null, null, jarSigner);
- dialog.setLocationRelativeTo(parent);
- dialog.setModalityType(ModalityType.APPLICATION_MODAL);
- dialog.setVisible(true);
- dialog.dispose();
- }
+ dialog.setLocationRelativeTo(parent);
+ dialog.setModalityType(ModalityType.APPLICATION_MODAL);
+ dialog.setVisible(true);
+ dialog.dispose();
+ }
- /**
- * Displays a single certificate's information.
- *
- * @param c
- * @param optionPane
- */
- public static void showSingleCertInfoDialog(X509Certificate c,
+ /**
+ * Displays a single certificate's information.
+ *
+ * @param c
+ * @param optionPane
+ */
+ public static void showSingleCertInfoDialog(X509Certificate c,
JDialog parent) {
- SecurityWarningDialog dialog = new SecurityWarningDialog(DialogType.SINGLE_CERT_INFO, c);
- dialog.setLocationRelativeTo(parent);
- dialog.setModalityType(ModalityType.APPLICATION_MODAL);
- dialog.setVisible(true);
- dialog.dispose();
- }
-
-
+ SecurityWarningDialog dialog = new SecurityWarningDialog(DialogType.SINGLE_CERT_INFO, c);
+ dialog.setLocationRelativeTo(parent);
+ dialog.setModalityType(ModalityType.APPLICATION_MODAL);
+ dialog.setVisible(true);
+ dialog.dispose();
+ }
- private void initDialog() {
- setSystemLookAndFeel();
+ private void initDialog() {
+ setSystemLookAndFeel();
- String dialogTitle = "";
- if (dialogType == DialogType.CERT_WARNING)
- dialogTitle = "Warning - Security";
- else if (dialogType == DialogType.MORE_INFO)
- dialogTitle = "More Information";
- else if (dialogType == DialogType.CERT_INFO)
- dialogTitle = "Details - Certificate";
- else if (dialogType == DialogType.ACCESS_WARNING)
- dialogTitle = "Security Warning";
- else if (dialogType == DialogType.APPLET_WARNING)
- dialogTitle = "Applet Warning";
- else if (dialogType == DialogType.NOTALLSIGNED_WARNING)
- dialogTitle = "Security Warning";
+ String dialogTitle = "";
+ if (dialogType == DialogType.CERT_WARNING)
+ dialogTitle = "Warning - Security";
+ else if (dialogType == DialogType.MORE_INFO)
+ dialogTitle = "More Information";
+ else if (dialogType == DialogType.CERT_INFO)
+ dialogTitle = "Details - Certificate";
+ else if (dialogType == DialogType.ACCESS_WARNING)
+ dialogTitle = "Security Warning";
+ else if (dialogType == DialogType.APPLET_WARNING)
+ dialogTitle = "Applet Warning";
+ else if (dialogType == DialogType.NOTALLSIGNED_WARNING)
+ dialogTitle = "Security Warning";
- setTitle(dialogTitle);
- setModalityType(ModalityType.MODELESS);
+ setTitle(dialogTitle);
+ setModalityType(ModalityType.MODELESS);
- setDefaultCloseOperation(DISPOSE_ON_CLOSE);
+ setDefaultCloseOperation(DISPOSE_ON_CLOSE);
- installPanel();
+ installPanel();
- pack();
+ pack();
- WindowAdapter adapter = new WindowAdapter() {
+ WindowAdapter adapter = new WindowAdapter() {
private boolean gotFocus = false;
@Override
@@ -241,6 +239,7 @@ public class SecurityWarningDialog extends JDialog {
gotFocus = true;
}
}
+
@Override
public void windowOpened(WindowEvent e) {
if (e.getSource() instanceof SecurityWarningDialog) {
@@ -251,57 +250,57 @@ public class SecurityWarningDialog extends JDialog {
}
}
};
- addWindowListener(adapter);
- addWindowFocusListener(adapter);
+ addWindowListener(adapter);
+ addWindowFocusListener(adapter);
- }
+ }
- public AccessType getAccessType() {
- return accessType;
- }
+ public AccessType getAccessType() {
+ return accessType;
+ }
- public JNLPFile getFile() {
- return file;
- }
+ public JNLPFile getFile() {
+ return file;
+ }
- public CertVerifier getJarSigner() {
- return certVerifier;
- }
+ public CertVerifier getJarSigner() {
+ return certVerifier;
+ }
- public X509Certificate getCert() {
- return cert;
- }
+ public X509Certificate getCert() {
+ return cert;
+ }
- /**
- * Adds the appropriate JPanel to this Dialog, based on {@link DialogType}.
- */
- private void installPanel() {
-
- if (dialogType == DialogType.CERT_WARNING)
- panel = new CertWarningPane(this, this.certVerifier);
- else if (dialogType == DialogType.MORE_INFO)
- panel = new MoreInfoPane(this, this.certVerifier);
- else if (dialogType == DialogType.CERT_INFO)
- panel = new CertsInfoPane(this, this.certVerifier);
- else if (dialogType == DialogType.SINGLE_CERT_INFO)
- panel = new SingleCertInfoPane(this, this.certVerifier);
- else if (dialogType == DialogType.ACCESS_WARNING)
- panel = new AccessWarningPane(this, extras, this.certVerifier);
- else if (dialogType == DialogType.APPLET_WARNING)
- panel = new AppletWarningPane(this, this.certVerifier);
- else if (dialogType == DialogType.NOTALLSIGNED_WARNING)
- panel = new NotAllSignedWarningPane(this);
-
- add(panel, BorderLayout.CENTER);
- }
+ /**
+ * Adds the appropriate JPanel to this Dialog, based on {@link DialogType}.
+ */
+ private void installPanel() {
+
+ if (dialogType == DialogType.CERT_WARNING)
+ panel = new CertWarningPane(this, this.certVerifier);
+ else if (dialogType == DialogType.MORE_INFO)
+ panel = new MoreInfoPane(this, this.certVerifier);
+ else if (dialogType == DialogType.CERT_INFO)
+ panel = new CertsInfoPane(this, this.certVerifier);
+ else if (dialogType == DialogType.SINGLE_CERT_INFO)
+ panel = new SingleCertInfoPane(this, this.certVerifier);
+ else if (dialogType == DialogType.ACCESS_WARNING)
+ panel = new AccessWarningPane(this, extras, this.certVerifier);
+ else if (dialogType == DialogType.APPLET_WARNING)
+ panel = new AppletWarningPane(this, this.certVerifier);
+ else if (dialogType == DialogType.NOTALLSIGNED_WARNING)
+ panel = new NotAllSignedWarningPane(this);
+
+ add(panel, BorderLayout.CENTER);
+ }
- private static void centerDialog(JDialog dialog) {
- Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
- Dimension dialogSize = dialog.getSize();
+ private static void centerDialog(JDialog dialog) {
+ Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
+ Dimension dialogSize = dialog.getSize();
- dialog.setLocation((screen.width - dialogSize.width)/2,
- (screen.height - dialogSize.height)/2);
- }
+ dialog.setLocation((screen.width - dialogSize.width) / 2,
+ (screen.height - dialogSize.height) / 2);
+ }
private void selectDefaultButton() {
if (panel == null) {
diff --git a/netx/net/sourceforge/jnlp/security/SingleCertInfoPane.java b/netx/net/sourceforge/jnlp/security/SingleCertInfoPane.java
index 59b8ab8..c60a084 100644
--- a/netx/net/sourceforge/jnlp/security/SingleCertInfoPane.java
+++ b/netx/net/sourceforge/jnlp/security/SingleCertInfoPane.java
@@ -44,34 +44,33 @@ import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeSelectionModel;
-
public class SingleCertInfoPane extends CertsInfoPane {
- public SingleCertInfoPane(SecurityWarningDialog x, CertVerifier certVerifier) {
- super(x, certVerifier);
- }
+ public SingleCertInfoPane(SecurityWarningDialog x, CertVerifier certVerifier) {
+ super(x, certVerifier);
+ }
- protected void buildTree() {
- X509Certificate cert = parent.getCert();
- String subjectString =
+ protected void buildTree() {
+ X509Certificate cert = parent.getCert();
+ String subjectString =
SecurityUtil.getCN(cert.getSubjectX500Principal().getName());
- String issuerString =
+ String issuerString =
SecurityUtil.getCN(cert.getIssuerX500Principal().getName());
- DefaultMutableTreeNode top = new DefaultMutableTreeNode(subjectString
+ DefaultMutableTreeNode top = new DefaultMutableTreeNode(subjectString
+ " (" + issuerString + ")");
- tree = new JTree(top);
- tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
- tree.addTreeSelectionListener(new TreeSelectionHandler());
- }
-
- protected void populateTable() {
- X509Certificate c = parent.getCert();
- certNames = new String[1];
- certsData = new ArrayList<String[][]>();
- certsData.add(parseCert(c));
- certNames[0] = SecurityUtil.getCN(c.getSubjectX500Principal().getName())
+ tree = new JTree(top);
+ tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
+ tree.addTreeSelectionListener(new TreeSelectionHandler());
+ }
+
+ protected void populateTable() {
+ X509Certificate c = parent.getCert();
+ certNames = new String[1];
+ certsData = new ArrayList<String[][]>();
+ certsData.add(parseCert(c));
+ certNames[0] = SecurityUtil.getCN(c.getSubjectX500Principal().getName())
+ " (" + SecurityUtil.getCN(c.getIssuerX500Principal().getName()) + ")";
- }
+ }
}
diff --git a/netx/net/sourceforge/jnlp/security/VariableX509TrustManager.java b/netx/net/sourceforge/jnlp/security/VariableX509TrustManager.java
index d40513e..01689ba 100644
--- a/netx/net/sourceforge/jnlp/security/VariableX509TrustManager.java
+++ b/netx/net/sourceforge/jnlp/security/VariableX509TrustManager.java
@@ -123,7 +123,7 @@ final public class VariableX509TrustManager extends X509ExtendedTrustManager {
// tm factory initialized, now get the managers so we can extract the X509 one
TrustManager[] trustManagers = tmFactory.getTrustManagers();
- for (int i=0; i < trustManagers.length; i++) {
+ for (int i = 0; i < trustManagers.length; i++) {
if (trustManagers[i] instanceof X509TrustManager) {
caTrustManagers[j] = (X509TrustManager) trustManagers[i];
}
@@ -147,7 +147,7 @@ final public class VariableX509TrustManager extends X509ExtendedTrustManager {
// tm factory initialized, now get the managers so we can extract the X509 one
TrustManager[] trustManagers = tmFactory.getTrustManagers();
- for (int i=0; i < trustManagers.length; i++) {
+ for (int i = 0; i < trustManagers.length; i++) {
if (trustManagers[i] instanceof X509TrustManager) {
clientTrustManagers[j] = (X509TrustManager) trustManagers[i];
}
diff --git a/netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java b/netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java
index c85c856..21666d7 100644
--- a/netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java
+++ b/netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java
@@ -81,224 +81,222 @@ import net.sourceforge.jnlp.util.FileUtils;
public class CertificatePane extends JPanel {
- /**
- * The certificates stored in the certificates file.
- */
- private ArrayList<X509Certificate> certs = null;
+ /**
+ * The certificates stored in the certificates file.
+ */
+ private ArrayList<X509Certificate> certs = null;
- private static final Dimension TABLE_DIMENSION = new Dimension(500,200);
+ private static final Dimension TABLE_DIMENSION = new Dimension(500, 200);
- /**
- * "Issued To" and "Issued By" string pairs for certs.
- */
- private String[][] issuedToAndBy = null;
- private final String[] columnNames = { R("CVIssuedTo"), R("CVIssuedBy") };
+ /**
+ * "Issued To" and "Issued By" string pairs for certs.
+ */
+ private String[][] issuedToAndBy = null;
+ private final String[] columnNames = { R("CVIssuedTo"), R("CVIssuedBy") };
- private final CertificateType[] certificateTypes = new CertificateType[] {
+ private final CertificateType[] certificateTypes = new CertificateType[] {
new CertificateType(KeyStores.Type.CA_CERTS),
new CertificateType(KeyStores.Type.JSSE_CA_CERTS),
new CertificateType(KeyStores.Type.CERTS),
new CertificateType(KeyStores.Type.JSSE_CERTS),
};
- JTabbedPane tabbedPane;
- private final JTable userTable;
- private final JTable systemTable;
- private JComboBox certificateTypeCombo;
- private KeyStores.Type currentKeyStoreType;
- private KeyStores.Level currentKeyStoreLevel;
-
- /** JComponents that should be disbled for system store */
- private final List<JComponent> disableForSystem;
+ JTabbedPane tabbedPane;
+ private final JTable userTable;
+ private final JTable systemTable;
+ private JComboBox certificateTypeCombo;
+ private KeyStores.Type currentKeyStoreType;
+ private KeyStores.Level currentKeyStoreLevel;
- private JDialog parent;
- private JComponent defaultFocusComponent = null;
+ /** JComponents that should be disbled for system store */
+ private final List<JComponent> disableForSystem;
- /**
- * The Current KeyStore. Only one table/tab is visible for interaction to
- * the user. This KeyStore corresponds to that.
- */
- private KeyStore keyStore = null;
+ private JDialog parent;
+ private JComponent defaultFocusComponent = null;
- public CertificatePane(JDialog parent) {
- super();
- this.parent = parent;
+ /**
+ * The Current KeyStore. Only one table/tab is visible for interaction to
+ * the user. This KeyStore corresponds to that.
+ */
+ private KeyStore keyStore = null;
- userTable = new JTable(null);
- systemTable = new JTable(null);
- disableForSystem = new ArrayList<JComponent>();
+ public CertificatePane(JDialog parent) {
+ super();
+ this.parent = parent;
- addComponents();
+ userTable = new JTable(null);
+ systemTable = new JTable(null);
+ disableForSystem = new ArrayList<JComponent>();
- currentKeyStoreType = ((CertificateType)(certificateTypeCombo.getSelectedItem())).getType();
- if (tabbedPane.getSelectedIndex() == 0) {
- currentKeyStoreLevel = Level.USER;
- } else {
- currentKeyStoreLevel = Level.SYSTEM;
- }
+ addComponents();
- repopulateTables();
+ currentKeyStoreType = ((CertificateType) (certificateTypeCombo.getSelectedItem())).getType();
+ if (tabbedPane.getSelectedIndex() == 0) {
+ currentKeyStoreLevel = Level.USER;
+ } else {
+ currentKeyStoreLevel = Level.SYSTEM;
}
- /**
- * Reads the user's trusted.cacerts keystore.
- */
- private void initializeKeyStore() {
- try {
- keyStore = KeyStores.getKeyStore(currentKeyStoreLevel, currentKeyStoreType);
- } catch (Exception e) {
- e.printStackTrace();
- }
+ repopulateTables();
+ }
+
+ /**
+ * Reads the user's trusted.cacerts keystore.
+ */
+ private void initializeKeyStore() {
+ try {
+ keyStore = KeyStores.getKeyStore(currentKeyStoreLevel, currentKeyStoreType);
+ } catch (Exception e) {
+ e.printStackTrace();
}
+ }
- //create the GUI here.
- protected void addComponents() {
+ //create the GUI here.
+ protected void addComponents() {
- JPanel main = new JPanel(new BorderLayout());
+ JPanel main = new JPanel(new BorderLayout());
- JPanel certificateTypePanel = new JPanel(new BorderLayout());
- certificateTypePanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
+ JPanel certificateTypePanel = new JPanel(new BorderLayout());
+ certificateTypePanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
- JLabel certificateTypeLabel = new JLabel(R("CVCertificateType"));
+ JLabel certificateTypeLabel = new JLabel(R("CVCertificateType"));
- certificateTypeCombo = new JComboBox(certificateTypes);
- certificateTypeCombo.addActionListener(new CertificateTypeListener());
+ certificateTypeCombo = new JComboBox(certificateTypes);
+ certificateTypeCombo.addActionListener(new CertificateTypeListener());
- certificateTypePanel.add(certificateTypeLabel, BorderLayout.LINE_START);
- certificateTypePanel.add(certificateTypeCombo, BorderLayout.CENTER);
+ certificateTypePanel.add(certificateTypeLabel, BorderLayout.LINE_START);
+ certificateTypePanel.add(certificateTypeCombo, BorderLayout.CENTER);
- JPanel tablePanel = new JPanel(new BorderLayout());
+ JPanel tablePanel = new JPanel(new BorderLayout());
- // User Table
- DefaultTableModel userTableModel
- = new DefaultTableModel(issuedToAndBy, columnNames);
- userTable.setModel(userTableModel);
- userTable.getTableHeader().setReorderingAllowed(false);
- userTable.setFillsViewportHeight(true);
- JScrollPane userTablePane = new JScrollPane(userTable);
- userTablePane.setPreferredSize(TABLE_DIMENSION);
- userTablePane.setSize(TABLE_DIMENSION);
- userTablePane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
+ // User Table
+ DefaultTableModel userTableModel = new DefaultTableModel(issuedToAndBy, columnNames);
+ userTable.setModel(userTableModel);
+ userTable.getTableHeader().setReorderingAllowed(false);
+ userTable.setFillsViewportHeight(true);
+ JScrollPane userTablePane = new JScrollPane(userTable);
+ userTablePane.setPreferredSize(TABLE_DIMENSION);
+ userTablePane.setSize(TABLE_DIMENSION);
+ userTablePane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
- // System Table
- DefaultTableModel systemTableModel = new DefaultTableModel(issuedToAndBy, columnNames);
- systemTable.setModel(systemTableModel);
- systemTable.getTableHeader().setReorderingAllowed(false);
- systemTable.setFillsViewportHeight(true);
- JScrollPane systemTablePane = new JScrollPane(systemTable);
- systemTablePane.setPreferredSize(TABLE_DIMENSION);
- systemTablePane.setSize(TABLE_DIMENSION);
- systemTablePane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
+ // System Table
+ DefaultTableModel systemTableModel = new DefaultTableModel(issuedToAndBy, columnNames);
+ systemTable.setModel(systemTableModel);
+ systemTable.getTableHeader().setReorderingAllowed(false);
+ systemTable.setFillsViewportHeight(true);
+ JScrollPane systemTablePane = new JScrollPane(systemTable);
+ systemTablePane.setPreferredSize(TABLE_DIMENSION);
+ systemTablePane.setSize(TABLE_DIMENSION);
+ systemTablePane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
- tabbedPane = new JTabbedPane();
- tabbedPane.addTab(R("CVUser"), userTablePane);
- tabbedPane.addTab(R("CVSystem"), systemTablePane);
- tabbedPane.addChangeListener(new TabChangeListener());
+ tabbedPane = new JTabbedPane();
+ tabbedPane.addTab(R("CVUser"), userTablePane);
+ tabbedPane.addTab(R("CVSystem"), systemTablePane);
+ tabbedPane.addChangeListener(new TabChangeListener());
- JPanel buttonPanel = new JPanel(new FlowLayout());
+ JPanel buttonPanel = new JPanel(new FlowLayout());
- String[] buttonNames = {R("CVImport"), R("CVExport"), R("CVRemove"), R("CVDetails")};
- char[] buttonMnemonics = { KeyEvent.VK_I,
+ String[] buttonNames = { R("CVImport"), R("CVExport"), R("CVRemove"), R("CVDetails") };
+ char[] buttonMnemonics = { KeyEvent.VK_I,
KeyEvent.VK_E,
KeyEvent.VK_M,
- KeyEvent.VK_D};
- ActionListener[] listeners = { new ImportButtonListener(),
+ KeyEvent.VK_D };
+ ActionListener[] listeners = { new ImportButtonListener(),
new ExportButtonListener(),
new RemoveButtonListener(),
new DetailsButtonListener() };
- JButton button;
+ JButton button;
- //get the max width
- int maxWidth = 0;
- for (int i = 0; i < buttonNames.length; i++) {
- button = new JButton(buttonNames[i]);
- maxWidth = Math.max(maxWidth, button.getMinimumSize().width);
- }
+ //get the max width
+ int maxWidth = 0;
+ for (int i = 0; i < buttonNames.length; i++) {
+ button = new JButton(buttonNames[i]);
+ maxWidth = Math.max(maxWidth, button.getMinimumSize().width);
+ }
- for (int i = 0; i < buttonNames.length; i++) {
- button = new JButton(buttonNames[i]);
- button.setMnemonic(buttonMnemonics[i]);
- button.addActionListener(listeners[i]);
- button.setSize(maxWidth, button.getSize().height);
- // import and remove buttons
- if (i == 0 || i == 2) {
- disableForSystem.add(button);
- }
- buttonPanel.add(button);
- }
+ for (int i = 0; i < buttonNames.length; i++) {
+ button = new JButton(buttonNames[i]);
+ button.setMnemonic(buttonMnemonics[i]);
+ button.addActionListener(listeners[i]);
+ button.setSize(maxWidth, button.getSize().height);
+ // import and remove buttons
+ if (i == 0 || i == 2) {
+ disableForSystem.add(button);
+ }
+ buttonPanel.add(button);
+ }
- tablePanel.add(tabbedPane, BorderLayout.CENTER);
- tablePanel.add(buttonPanel, BorderLayout.SOUTH);
-
- main.add(certificateTypePanel, BorderLayout.NORTH);
- main.add(tablePanel, BorderLayout.CENTER);
-
- if (parent != null){
- JPanel closePanel = new JPanel(new BorderLayout());
- closePanel.setBorder(BorderFactory.createEmptyBorder(7,7,7,7));
- JButton closeButton = new JButton(R("ButClose"));
- closeButton.addActionListener(new CloseButtonListener());
- defaultFocusComponent = closeButton;
- closePanel.add(closeButton, BorderLayout.EAST);
- main.add(closePanel, BorderLayout.SOUTH);
- }
- add(main);
+ tablePanel.add(tabbedPane, BorderLayout.CENTER);
+ tablePanel.add(buttonPanel, BorderLayout.SOUTH);
- }
+ main.add(certificateTypePanel, BorderLayout.NORTH);
+ main.add(tablePanel, BorderLayout.CENTER);
- /**
- * Read in the optionPane's keystore to issuedToAndBy.
- */
- private void readKeyStore() {
+ if (parent != null) {
+ JPanel closePanel = new JPanel(new BorderLayout());
+ closePanel.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7));
+ JButton closeButton = new JButton(R("ButClose"));
+ closeButton.addActionListener(new CloseButtonListener());
+ defaultFocusComponent = closeButton;
+ closePanel.add(closeButton, BorderLayout.EAST);
+ main.add(closePanel, BorderLayout.SOUTH);
+ }
+ add(main);
- Enumeration<String> aliases = null;
- certs = new ArrayList<X509Certificate>();
- try {
+ }
- //Get all of the X509Certificates and put them into an ArrayList
- aliases = keyStore.aliases();
- while (aliases.hasMoreElements()) {
- Certificate c = keyStore.getCertificate(aliases.nextElement());
- if (c instanceof X509Certificate)
- certs.add((X509Certificate)c);
- }
+ /**
+ * Read in the optionPane's keystore to issuedToAndBy.
+ */
+ private void readKeyStore() {
+
+ Enumeration<String> aliases = null;
+ certs = new ArrayList<X509Certificate>();
+ try {
+
+ //Get all of the X509Certificates and put them into an ArrayList
+ aliases = keyStore.aliases();
+ while (aliases.hasMoreElements()) {
+ Certificate c = keyStore.getCertificate(aliases.nextElement());
+ if (c instanceof X509Certificate)
+ certs.add((X509Certificate) c);
+ }
- //get the publisher and root information
- issuedToAndBy = new String[certs.size()][2];
- for (int i = 0; i < certs.size(); i++) {
- X509Certificate c = certs.get(i);
- issuedToAndBy[i][0] =
+ //get the publisher and root information
+ issuedToAndBy = new String[certs.size()][2];
+ for (int i = 0; i < certs.size(); i++) {
+ X509Certificate c = certs.get(i);
+ issuedToAndBy[i][0] =
SecurityUtil.getCN(c.getSubjectX500Principal().getName());
- issuedToAndBy[i][1] =
+ issuedToAndBy[i][1] =
SecurityUtil.getCN(c.getIssuerX500Principal().getName());
- }
- } catch (Exception e) {
- //TODO
- e.printStackTrace();
- }
+ }
+ } catch (Exception e) {
+ //TODO
+ e.printStackTrace();
}
+ }
- /**
- * Re-reads the certs file and repopulates the JTable. This is typically
- * called after a certificate was deleted from the keystore.
- */
- private void repopulateTables() {
- initializeKeyStore();
- readKeyStore();
- DefaultTableModel tableModel
- = new DefaultTableModel(issuedToAndBy, columnNames);
+ /**
+ * Re-reads the certs file and repopulates the JTable. This is typically
+ * called after a certificate was deleted from the keystore.
+ */
+ private void repopulateTables() {
+ initializeKeyStore();
+ readKeyStore();
+ DefaultTableModel tableModel = new DefaultTableModel(issuedToAndBy, columnNames);
- userTable.setModel(tableModel);
+ userTable.setModel(tableModel);
- tableModel = new DefaultTableModel(issuedToAndBy, columnNames);
- systemTable.setModel(tableModel);
- }
+ tableModel = new DefaultTableModel(issuedToAndBy, columnNames);
+ systemTable.setModel(tableModel);
+ }
- public void focusOnDefaultButton() {
- if (defaultFocusComponent != null) {
- defaultFocusComponent.requestFocusInWindow();
- }
+ public void focusOnDefaultButton() {
+ if (defaultFocusComponent != null) {
+ defaultFocusComponent.requestFocusInWindow();
}
+ }
/** Allows storing KeyStores.Types in a JComponent */
private class CertificateType {
@@ -355,74 +353,73 @@ public class CertificatePane extends JPanel {
}
}
- private class ImportButtonListener implements ActionListener {
+ private class ImportButtonListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
- JFileChooser chooser = new JFileChooser();
- int returnVal = chooser.showOpenDialog(parent);
- if(returnVal == JFileChooser.APPROVE_OPTION) {
- try {
- KeyStore ks = keyStore;
- CertificateUtils.addToKeyStore(chooser.getSelectedFile(), ks);
- File keyStoreFile = new File(KeyStores
+ JFileChooser chooser = new JFileChooser();
+ int returnVal = chooser.showOpenDialog(parent);
+ if (returnVal == JFileChooser.APPROVE_OPTION) {
+ try {
+ KeyStore ks = keyStore;
+ CertificateUtils.addToKeyStore(chooser.getSelectedFile(), ks);
+ File keyStoreFile = new File(KeyStores
.getKeyStoreLocation(currentKeyStoreLevel, currentKeyStoreType));
- if (!keyStoreFile.isFile()) {
- FileUtils.createRestrictedFile(keyStoreFile, true);
- }
-
- OutputStream os = new FileOutputStream(keyStoreFile);
- ks.store(os, KeyStores.getPassword());
- repopulateTables();
- } catch (Exception ex) {
- // TODO: handle exception
- ex.printStackTrace();
- }
+ if (!keyStoreFile.isFile()) {
+ FileUtils.createRestrictedFile(keyStoreFile, true);
+ }
+
+ OutputStream os = new FileOutputStream(keyStoreFile);
+ ks.store(os, KeyStores.getPassword());
+ repopulateTables();
+ } catch (Exception ex) {
+ // TODO: handle exception
+ ex.printStackTrace();
}
+ }
}
}
- private class ExportButtonListener implements ActionListener {
- public void actionPerformed(ActionEvent e) {
-
- JTable table = null;
- if (currentKeyStoreLevel == Level.USER) {
- table = userTable;
- } else {
- table = systemTable;
- }
+ private class ExportButtonListener implements ActionListener {
+ public void actionPerformed(ActionEvent e) {
- //For now, let's just export in -rfc mode as keytool does.
- //we'll write to a file the exported certificate.
+ JTable table = null;
+ if (currentKeyStoreLevel == Level.USER) {
+ table = userTable;
+ } else {
+ table = systemTable;
+ }
+ //For now, let's just export in -rfc mode as keytool does.
+ //we'll write to a file the exported certificate.
- try {
- int selectedRow = table.getSelectedRow();
- if (selectedRow != -1) {
- JFileChooser chooser = new JFileChooser();
- int returnVal = chooser.showOpenDialog(parent);
- if(returnVal == JFileChooser.APPROVE_OPTION) {
- String alias = keyStore.getCertificateAlias(certs
+ try {
+ int selectedRow = table.getSelectedRow();
+ if (selectedRow != -1) {
+ JFileChooser chooser = new JFileChooser();
+ int returnVal = chooser.showOpenDialog(parent);
+ if (returnVal == JFileChooser.APPROVE_OPTION) {
+ String alias = keyStore.getCertificateAlias(certs
.get(selectedRow));
- if (alias != null) {
- Certificate c = keyStore.getCertificate(alias);
- PrintStream ps = new PrintStream(chooser.getSelectedFile().getAbsolutePath());
- CertificateUtils.dump(c, ps);
- repopulateTables();
- }
- }
- }
- } catch (Exception ex) {
- // TODO
- ex.printStackTrace();
+ if (alias != null) {
+ Certificate c = keyStore.getCertificate(alias);
+ PrintStream ps = new PrintStream(chooser.getSelectedFile().getAbsolutePath());
+ CertificateUtils.dump(c, ps);
+ repopulateTables();
}
+ }
}
+ } catch (Exception ex) {
+ // TODO
+ ex.printStackTrace();
+ }
}
+ }
- private class RemoveButtonListener implements ActionListener {
+ private class RemoveButtonListener implements ActionListener {
- /**
- * Removes a certificate from the keyStore and writes changes to disk.
- */
+ /**
+ * Removes a certificate from the keyStore and writes changes to disk.
+ */
public void actionPerformed(ActionEvent e) {
JTable table = null;
@@ -431,44 +428,44 @@ public class CertificatePane extends JPanel {
} else {
table = systemTable;
}
- try {
- int selectedRow = table.getSelectedRow();
+ try {
+ int selectedRow = table.getSelectedRow();
- if (selectedRow != -1){
- String alias = keyStore.getCertificateAlias(certs.get(selectedRow));
- if (alias != null) {
+ if (selectedRow != -1) {
+ String alias = keyStore.getCertificateAlias(certs.get(selectedRow));
+ if (alias != null) {
- int i = JOptionPane.showConfirmDialog(parent,
+ int i = JOptionPane.showConfirmDialog(parent,
R("CVRemoveConfirmMessage"),
R("CVRemoveConfirmTitle"),
JOptionPane.YES_NO_OPTION);
- if (i == 0) {
- keyStore.deleteEntry(alias);
- File keyStoreFile = new File(KeyStores
+ if (i == 0) {
+ keyStore.deleteEntry(alias);
+ File keyStoreFile = new File(KeyStores
.getKeyStoreLocation(currentKeyStoreLevel, currentKeyStoreType));
- if (!keyStoreFile.isFile()) {
- FileUtils.createRestrictedFile(keyStoreFile, true);
- }
- FileOutputStream fos = new FileOutputStream(keyStoreFile);
- keyStore.store(fos, KeyStores.getPassword());
- fos.close();
- }
- }
- repopulateTables();
+ if (!keyStoreFile.isFile()) {
+ FileUtils.createRestrictedFile(keyStoreFile, true);
+ }
+ FileOutputStream fos = new FileOutputStream(keyStoreFile);
+ keyStore.store(fos, KeyStores.getPassword());
+ fos.close();
}
- } catch (Exception ex) {
- // TODO
- ex.printStackTrace();
+ }
+ repopulateTables();
}
+ } catch (Exception ex) {
+ // TODO
+ ex.printStackTrace();
+ }
}
}
- private class DetailsButtonListener implements ActionListener {
+ private class DetailsButtonListener implements ActionListener {
- /**
- * Shows the details of a trusted certificate.
- */
+ /**
+ * Shows the details of a trusted certificate.
+ */
public void actionPerformed(ActionEvent e) {
JTable table = null;
@@ -478,19 +475,19 @@ public class CertificatePane extends JPanel {
table = systemTable;
}
- int selectedRow = table.getSelectedRow();
- if (selectedRow != -1 && selectedRow >= 0) {
- X509Certificate c = certs.get(selectedRow);
- SecurityWarningDialog.showSingleCertInfoDialog(c, parent);
- }
+ int selectedRow = table.getSelectedRow();
+ if (selectedRow != -1 && selectedRow >= 0) {
+ X509Certificate c = certs.get(selectedRow);
+ SecurityWarningDialog.showSingleCertInfoDialog(c, parent);
+ }
}
}
- private class CloseButtonListener implements ActionListener {
- @Override
- public void actionPerformed(ActionEvent e) {
- parent.dispose();
- }
+ private class CloseButtonListener implements ActionListener {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ parent.dispose();
}
+ }
}
diff --git a/netx/net/sourceforge/jnlp/security/viewer/CertificateViewer.java b/netx/net/sourceforge/jnlp/security/viewer/CertificateViewer.java
index 57bafd3..c497308 100644
--- a/netx/net/sourceforge/jnlp/security/viewer/CertificateViewer.java
+++ b/netx/net/sourceforge/jnlp/security/viewer/CertificateViewer.java
@@ -59,8 +59,8 @@ public class CertificateViewer extends JDialog {
CertificatePane panel;
- public CertificateViewer() {
- super((Frame)null, dialogTitle, true);
+ public CertificateViewer() {
+ super((Frame) null, dialogTitle, true);
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
@@ -84,32 +84,31 @@ public class CertificateViewer extends JDialog {
};
addWindowFocusListener(adapter);
- initialized = true;
- }
-
- public boolean isInitialized(){
- return initialized;
- }
+ initialized = true;
+ }
- private void centerDialog() {
- Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
- Dimension dialogSize = getSize();
+ public boolean isInitialized() {
+ return initialized;
+ }
- setLocation((screen.width - dialogSize.width)/2,
- (screen.height - dialogSize.height)/2);
- }
+ private void centerDialog() {
+ Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
+ Dimension dialogSize = getSize();
+ setLocation((screen.width - dialogSize.width) / 2,
+ (screen.height - dialogSize.height) / 2);
+ }
- public static void showCertificateViewer() throws Exception {
- JNLPRuntime.initialize(true);
- setSystemLookAndFeel();
+ public static void showCertificateViewer() throws Exception {
+ JNLPRuntime.initialize(true);
+ setSystemLookAndFeel();
- CertificateViewer cv = new CertificateViewer();
- cv.setResizable(true);
- cv.centerDialog();
- cv.setVisible(true);
- cv.dispose();
- }
+ CertificateViewer cv = new CertificateViewer();
+ cv.setResizable(true);
+ cv.centerDialog();
+ cv.setVisible(true);
+ cv.dispose();
+ }
private static void setSystemLookAndFeel() {
try {
@@ -119,7 +118,7 @@ public class CertificateViewer extends JDialog {
}
}
- public static void main(String[] args) throws Exception {
- CertificateViewer.showCertificateViewer();
- }
+ public static void main(String[] args) throws Exception {
+ CertificateViewer.showCertificateViewer();
+ }
}
diff --git a/netx/net/sourceforge/jnlp/services/ServiceUtil.java b/netx/net/sourceforge/jnlp/services/ServiceUtil.java
index 62ce28f..96d040a 100644
--- a/netx/net/sourceforge/jnlp/services/ServiceUtil.java
+++ b/netx/net/sourceforge/jnlp/services/ServiceUtil.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.services;
import java.lang.reflect.InvocationHandler;
@@ -143,8 +142,7 @@ public class ServiceUtil {
private static Object getService(String name) {
try {
return ServiceManager.lookup(name);
- }
- catch (UnavailableServiceException ex) {
+ } catch (UnavailableServiceException ex) {
return null;
}
}
@@ -174,10 +172,10 @@ public class ServiceUtil {
public Object invoke(Object proxy, final Method method, final Object[] args) throws Throwable {
if (JNLPRuntime.isDebug()) {
- System.err.println("call privileged method: "+method.getName());
+ System.err.println("call privileged method: " + method.getName());
if (args != null)
- for (int i=0; i < args.length; i++)
- System.err.println(" arg: "+args[i]);
+ for (int i = 0; i < args.length; i++)
+ System.err.println(" arg: " + args[i]);
}
PrivilegedExceptionAction<Object> invoker = new PrivilegedExceptionAction<Object>() {
@@ -190,7 +188,7 @@ public class ServiceUtil {
Object result = AccessController.doPrivileged(invoker);
if (JNLPRuntime.isDebug())
- System.err.println(" result: "+result);
+ System.err.println(" result: " + result);
return result;
} catch (PrivilegedActionException e) {
@@ -238,57 +236,57 @@ public class ServiceUtil {
Object... extras) {
if (app == null)
- app = JNLPRuntime.getApplication();
+ app = JNLPRuntime.getApplication();
boolean codeTrusted = true;
- StackTraceElement[] stack = Thread.currentThread().getStackTrace();
+ StackTraceElement[] stack = Thread.currentThread().getStackTrace();
- for (int i=0; i < stack.length; i++) {
+ for (int i = 0; i < stack.length; i++) {
- Class c = null;
+ Class c = null;
+ try {
+ c = Class.forName(stack[i].getClassName());
+ } catch (Exception e1) {
try {
- c = Class.forName(stack[i].getClassName());
- } catch (Exception e1) {
- try {
- c = Class.forName(stack[i].getClassName(), false, app.getClassLoader());
- } catch (Exception e2) {
- System.err.println(e2.getMessage());
- }
+ c = Class.forName(stack[i].getClassName(), false, app.getClassLoader());
+ } catch (Exception e2) {
+ System.err.println(e2.getMessage());
}
+ }
// Everything up to the desired class/method must be trusted
if (c == null || // class not found
- ( c.getProtectionDomain().getCodeSource() != null && // class is not in bootclasspath
- c.getProtectionDomain().getCodeSource().getCodeSigners() == null) // class is trusted
- ) {
+ (c.getProtectionDomain().getCodeSource() != null && // class is not in bootclasspath
+ c.getProtectionDomain().getCodeSource().getCodeSigners() == null) // class is trusted
+ ) {
codeTrusted = false;
}
}
if (!codeTrusted) {
- if (!shouldPromptUser()) {
- return false;
- }
+ if (!shouldPromptUser()) {
+ return false;
+ }
- final AccessType tmpType = type;
- final Object[] tmpExtras = extras;
- final ApplicationInstance tmpApp = app;
+ final AccessType tmpType = type;
+ final Object[] tmpExtras = extras;
+ final ApplicationInstance tmpApp = app;
- //We need to do this to allow proper icon loading for unsigned
- //applets, otherwise permissions won't be granted to load icons
- //from resources.jar.
- Boolean b = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
- public Boolean run() {
- boolean b = SecurityWarning.showAccessWarningDialog(tmpType,
+ //We need to do this to allow proper icon loading for unsigned
+ //applets, otherwise permissions won't be granted to load icons
+ //from resources.jar.
+ Boolean b = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+ public Boolean run() {
+ boolean b = SecurityWarning.showAccessWarningDialog(tmpType,
tmpApp.getJNLPFile(), tmpExtras);
- return new Boolean(b);
- }
- });
+ return new Boolean(b);
+ }
+ });
- return b.booleanValue();
+ return b.booleanValue();
}
return true; //allow
diff --git a/netx/net/sourceforge/jnlp/services/XBasicService.java b/netx/net/sourceforge/jnlp/services/XBasicService.java
index a46a309..124025c 100644
--- a/netx/net/sourceforge/jnlp/services/XBasicService.java
+++ b/netx/net/sourceforge/jnlp/services/XBasicService.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.services;
import java.io.IOException;
@@ -48,7 +47,6 @@ class XBasicService implements BasicService {
/** whether the command was loaded / prompted for */
private boolean initialized = false;
-
protected XBasicService() {
}
@@ -128,7 +126,7 @@ class XBasicService implements BasicService {
}
JARDesc[] jarDescs = jnlpFile.getResources().getJARs();
- for (JARDesc jarDesc: jarDescs) {
+ for (JARDesc jarDesc : jarDescs) {
return jarDesc.getLocation();
}
}
@@ -159,15 +157,14 @@ class XBasicService implements BasicService {
*
* @return whether the document was opened
*/
- public boolean showDocument(URL url) {
+ public boolean showDocument(URL url) {
initialize();
if (url.toString().endsWith(".jnlp")) {
try {
new Launcher().launchExternal(url);
return true;
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
return false;
}
}
@@ -181,8 +178,7 @@ class XBasicService implements BasicService {
//Runtime.getRuntime().exec(new String[]{command,url.toString()});
return true;
- }
- catch(IOException ex){
+ } catch (IOException ex) {
if (JNLPRuntime.isDebug())
ex.printStackTrace();
}
@@ -196,17 +192,16 @@ class XBasicService implements BasicService {
return;
initialized = true;
- if(isWindows()) {
+ if (isWindows()) {
command = "rundll32 url.dll,FileProtocolHandler ";
- }
- else {
+ } else {
DeploymentConfiguration config = JNLPRuntime.getConfiguration();
command = config.getProperty(DeploymentConfiguration.KEY_BROWSER_PATH);
- if(command == null) { // prompt & store
+ if (command == null) { // prompt & store
command = promptForCommand(null);
- if(command != null) {
+ if (command != null) {
config.setProperty(DeploymentConfiguration.KEY_BROWSER_PATH, command);
try {
config.save();
@@ -220,7 +215,7 @@ class XBasicService implements BasicService {
private boolean isWindows() {
String os = System.getProperty("os.name");
- if(os != null && os.startsWith("Windows"))
+ if (os != null && os.startsWith("Windows"))
return true;
else
return false;
diff --git a/netx/net/sourceforge/jnlp/services/XClipboardService.java b/netx/net/sourceforge/jnlp/services/XClipboardService.java
index b00e6da..6f462e5 100644
--- a/netx/net/sourceforge/jnlp/services/XClipboardService.java
+++ b/netx/net/sourceforge/jnlp/services/XClipboardService.java
@@ -51,31 +51,31 @@ import java.awt.Toolkit;
*/
class XClipboardService implements ClipboardService {
- protected XClipboardService() {
- }
+ protected XClipboardService() {
+ }
- /**
- * Returns the contents of the system clipboard.
- */
- public java.awt.datatransfer.Transferable getContents(){
+ /**
+ * Returns the contents of the system clipboard.
+ */
+ public java.awt.datatransfer.Transferable getContents() {
- if (ServiceUtil.checkAccess(AccessType.CLIPBOARD_READ)) {
- Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
- return (Transferable) ServiceUtil.createPrivilegedProxy(
+ if (ServiceUtil.checkAccess(AccessType.CLIPBOARD_READ)) {
+ Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
+ return (Transferable) ServiceUtil.createPrivilegedProxy(
Transferable.class, t);
- } else {
- return null;
- }
+ } else {
+ return null;
}
-
- /**
- * Sets the contents of the system clipboard.
- */
- public void setContents(java.awt.datatransfer.Transferable contents) {
- if (ServiceUtil.checkAccess(AccessType.CLIPBOARD_WRITE)) {
- Toolkit.getDefaultToolkit().getSystemClipboard().setContents(
+ }
+
+ /**
+ * Sets the contents of the system clipboard.
+ */
+ public void setContents(java.awt.datatransfer.Transferable contents) {
+ if (ServiceUtil.checkAccess(AccessType.CLIPBOARD_WRITE)) {
+ Toolkit.getDefaultToolkit().getSystemClipboard().setContents(
contents, null);
- }
}
+ }
}
diff --git a/netx/net/sourceforge/jnlp/services/XDownloadService.java b/netx/net/sourceforge/jnlp/services/XDownloadService.java
index 174071a..8d2f6d3 100644
--- a/netx/net/sourceforge/jnlp/services/XDownloadService.java
+++ b/netx/net/sourceforge/jnlp/services/XDownloadService.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.services;
import java.io.*;
diff --git a/netx/net/sourceforge/jnlp/services/XExtendedService.java b/netx/net/sourceforge/jnlp/services/XExtendedService.java
index 296740d..88da724 100644
--- a/netx/net/sourceforge/jnlp/services/XExtendedService.java
+++ b/netx/net/sourceforge/jnlp/services/XExtendedService.java
@@ -35,7 +35,7 @@ public class XExtendedService implements ExtendedService {
public FileContents openFile(File file) throws IOException {
/* FIXME: this opens a file with read/write mode, not just read or write */
- if (ServiceUtil.checkAccess(AccessType.READ_FILE, new Object[]{ file.getAbsolutePath() })) {
+ if (ServiceUtil.checkAccess(AccessType.READ_FILE, new Object[] { file.getAbsolutePath() })) {
return (FileContents) ServiceUtil.createPrivilegedProxy(FileContents.class,
new XFileContents(file));
} else {
diff --git a/netx/net/sourceforge/jnlp/services/XExtensionInstallerService.java b/netx/net/sourceforge/jnlp/services/XExtensionInstallerService.java
index 7fea6bb..b60218b 100644
--- a/netx/net/sourceforge/jnlp/services/XExtensionInstallerService.java
+++ b/netx/net/sourceforge/jnlp/services/XExtensionInstallerService.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.services;
import java.io.*;
diff --git a/netx/net/sourceforge/jnlp/services/XFileContents.java b/netx/net/sourceforge/jnlp/services/XFileContents.java
index c7b331a..48904c5 100644
--- a/netx/net/sourceforge/jnlp/services/XFileContents.java
+++ b/netx/net/sourceforge/jnlp/services/XFileContents.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.services;
import java.io.*;
@@ -117,5 +116,4 @@ class XFileContents implements FileContents {
return maxlength;
}
-
}
diff --git a/netx/net/sourceforge/jnlp/services/XFileOpenService.java b/netx/net/sourceforge/jnlp/services/XFileOpenService.java
index 61d2bdb..e238b16 100644
--- a/netx/net/sourceforge/jnlp/services/XFileOpenService.java
+++ b/netx/net/sourceforge/jnlp/services/XFileOpenService.java
@@ -64,8 +64,8 @@ class XFileOpenService implements FileOpenService {
/**
* Prompts the user to select a single file.
*/
- public FileContents openFileDialog (java.lang.String pathHint,
- java.lang.String[] extensions) throws java.io.IOException {
+ public FileContents openFileDialog(java.lang.String pathHint,
+ java.lang.String[] extensions) throws java.io.IOException {
if (ServiceUtil.checkAccess(AccessType.READ_FILE)) {
@@ -87,7 +87,7 @@ class XFileOpenService implements FileOpenService {
/**
* Prompts the user to select one or more files.
*/
- public FileContents[] openMultiFileDialog (java.lang.String pathHint,
+ public FileContents[] openMultiFileDialog(java.lang.String pathHint,
java.lang.String[] extensions) throws java.io.IOException {
if (ServiceUtil.checkAccess(AccessType.WRITE_FILE)) {
diff --git a/netx/net/sourceforge/jnlp/services/XFileSaveService.java b/netx/net/sourceforge/jnlp/services/XFileSaveService.java
index c4e856b..1477b8c 100644
--- a/netx/net/sourceforge/jnlp/services/XFileSaveService.java
+++ b/netx/net/sourceforge/jnlp/services/XFileSaveService.java
@@ -64,8 +64,8 @@ class XFileSaveService implements FileSaveService {
* Prompts the user to save a file.
*/
public FileContents saveFileDialog(java.lang.String pathHint,
- java.lang.String[] extensions, java.io.InputStream stream,
- java.lang.String name) throws java.io.IOException {
+ java.lang.String[] extensions, java.io.InputStream stream,
+ java.lang.String name) throws java.io.IOException {
if (ServiceUtil.checkAccess(AccessType.WRITE_FILE)) {
JFileChooser chooser = new JFileChooser();
@@ -88,7 +88,7 @@ class XFileSaveService implements FileSaveService {
* Prompts the user to save a file, with an optional pre-set filename.
*/
public FileContents saveAsFileDialog(java.lang.String pathHint,
- java.lang.String[] extensions, FileContents contents) throws java.io.IOException {
+ java.lang.String[] extensions, FileContents contents) throws java.io.IOException {
if (ServiceUtil.checkAccess(AccessType.WRITE_FILE)) {
JFileChooser chooser = new JFileChooser();
@@ -117,7 +117,7 @@ class XFileSaveService implements FileSaveService {
if (!file.createNewFile()) { //file exists
boolean replace = (JOptionPane.showConfirmDialog(null,
file.getAbsolutePath() + " already exists.\n"
- +"Do you want to replace it?",
+ + "Do you want to replace it?",
"Warning - File Exists", JOptionPane.YES_NO_OPTION) == 0);
if (!replace)
return;
diff --git a/netx/net/sourceforge/jnlp/services/XJNLPRandomAccessFile.java b/netx/net/sourceforge/jnlp/services/XJNLPRandomAccessFile.java
index 8e97743..b8eca83 100644
--- a/netx/net/sourceforge/jnlp/services/XJNLPRandomAccessFile.java
+++ b/netx/net/sourceforge/jnlp/services/XJNLPRandomAccessFile.java
@@ -44,160 +44,160 @@ import javax.jnlp.JNLPRandomAccessFile;
public class XJNLPRandomAccessFile implements JNLPRandomAccessFile {
- private RandomAccessFile raf;
+ private RandomAccessFile raf;
- public XJNLPRandomAccessFile(File file, String mode) throws IOException {
- raf = new RandomAccessFile(file, mode);
+ public XJNLPRandomAccessFile(File file, String mode) throws IOException {
+ raf = new RandomAccessFile(file, mode);
- }
+ }
- public void close() throws IOException {
- raf.close();
- }
+ public void close() throws IOException {
+ raf.close();
+ }
- public long getFilePointer() throws IOException {
- return raf.getFilePointer();
- }
+ public long getFilePointer() throws IOException {
+ return raf.getFilePointer();
+ }
- public long length() throws IOException {
- return raf.length();
- }
+ public long length() throws IOException {
+ return raf.length();
+ }
- public int read() throws IOException {
- return raf.read();
- }
+ public int read() throws IOException {
+ return raf.read();
+ }
- public int read(byte[] b, int off, int len) throws IOException {
- return raf.read(b, off, len);
- }
+ public int read(byte[] b, int off, int len) throws IOException {
+ return raf.read(b, off, len);
+ }
- public int read(byte[] b) throws IOException {
- return raf.read(b);
- }
+ public int read(byte[] b) throws IOException {
+ return raf.read(b);
+ }
- public boolean readBoolean() throws IOException {
- return raf.readBoolean();
- }
+ public boolean readBoolean() throws IOException {
+ return raf.readBoolean();
+ }
- public byte readByte() throws IOException {
- return raf.readByte();
- }
+ public byte readByte() throws IOException {
+ return raf.readByte();
+ }
- public char readChar() throws IOException {
- return raf.readChar();
- }
+ public char readChar() throws IOException {
+ return raf.readChar();
+ }
- public double readDouble() throws IOException {
- return raf.readDouble();
- }
+ public double readDouble() throws IOException {
+ return raf.readDouble();
+ }
- public float readFloat() throws IOException {
- return raf.readFloat();
- }
+ public float readFloat() throws IOException {
+ return raf.readFloat();
+ }
- public void readFully(byte[] b) throws IOException {
- raf.readFully(b);
- }
+ public void readFully(byte[] b) throws IOException {
+ raf.readFully(b);
+ }
- public void readFully(byte[] b, int off, int len) throws IOException {
- raf.readFully(b, off, len);
- }
+ public void readFully(byte[] b, int off, int len) throws IOException {
+ raf.readFully(b, off, len);
+ }
- public int readInt() throws IOException {
- return raf.readInt();
- }
+ public int readInt() throws IOException {
+ return raf.readInt();
+ }
- public String readLine() throws IOException {
- return raf.readLine();
- }
+ public String readLine() throws IOException {
+ return raf.readLine();
+ }
- public long readLong() throws IOException {
- return raf.readLong();
- }
+ public long readLong() throws IOException {
+ return raf.readLong();
+ }
- public short readShort() throws IOException {
- return raf.readShort();
- }
+ public short readShort() throws IOException {
+ return raf.readShort();
+ }
- public String readUTF() throws IOException {
- return raf.readUTF();
- }
+ public String readUTF() throws IOException {
+ return raf.readUTF();
+ }
- public int readUnsignedByte() throws IOException {
- return raf.readUnsignedByte();
- }
+ public int readUnsignedByte() throws IOException {
+ return raf.readUnsignedByte();
+ }
- public int readUnsignedShort() throws IOException {
- return raf.readUnsignedShort();
- }
+ public int readUnsignedShort() throws IOException {
+ return raf.readUnsignedShort();
+ }
- public void seek(long pos) throws IOException {
- raf.seek(pos);
- }
+ public void seek(long pos) throws IOException {
+ raf.seek(pos);
+ }
- public void setLength(long newLength) throws IOException {
- raf.setLength(newLength);
- }
+ public void setLength(long newLength) throws IOException {
+ raf.setLength(newLength);
+ }
- public int skipBytes(int n) throws IOException {
- return raf.skipBytes(n);
- }
+ public int skipBytes(int n) throws IOException {
+ return raf.skipBytes(n);
+ }
- public void write(int b) throws IOException {
- raf.write(b);
+ public void write(int b) throws IOException {
+ raf.write(b);
- }
+ }
- public void write(byte[] b) throws IOException {
- raf.write(b);
- }
+ public void write(byte[] b) throws IOException {
+ raf.write(b);
+ }
- public void write(byte[] b, int off, int len) throws IOException {
- raf.write(b, off, len);
- }
+ public void write(byte[] b, int off, int len) throws IOException {
+ raf.write(b, off, len);
+ }
- public void writeBoolean(boolean v) throws IOException {
- raf.writeBoolean(v);
- }
+ public void writeBoolean(boolean v) throws IOException {
+ raf.writeBoolean(v);
+ }
- public void writeByte(int v) throws IOException {
- raf.writeByte(v);
- }
+ public void writeByte(int v) throws IOException {
+ raf.writeByte(v);
+ }
- public void writeBytes(String s) throws IOException {
- raf.writeBytes(s);
- }
+ public void writeBytes(String s) throws IOException {
+ raf.writeBytes(s);
+ }
- public void writeChar(int v) throws IOException {
- raf.writeChar(v);
- }
+ public void writeChar(int v) throws IOException {
+ raf.writeChar(v);
+ }
- public void writeChars(String s) throws IOException {
- raf.writeChars(s);
- }
+ public void writeChars(String s) throws IOException {
+ raf.writeChars(s);
+ }
- public void writeDouble(double v) throws IOException {
- raf.writeDouble(v);
- }
+ public void writeDouble(double v) throws IOException {
+ raf.writeDouble(v);
+ }
- public void writeFloat(float v) throws IOException {
- raf.writeFloat(v);
- }
+ public void writeFloat(float v) throws IOException {
+ raf.writeFloat(v);
+ }
- public void writeInt(int v) throws IOException {
- raf.writeInt(v);
- }
+ public void writeInt(int v) throws IOException {
+ raf.writeInt(v);
+ }
- public void writeLong(long v) throws IOException {
- raf.writeLong(v);
- }
+ public void writeLong(long v) throws IOException {
+ raf.writeLong(v);
+ }
- public void writeShort(int v) throws IOException {
- raf.writeShort(v);
- }
+ public void writeShort(int v) throws IOException {
+ raf.writeShort(v);
+ }
- public void writeUTF(String str) throws IOException {
- raf.writeUTF(str);
- }
+ public void writeUTF(String str) throws IOException {
+ raf.writeUTF(str);
+ }
}
diff --git a/netx/net/sourceforge/jnlp/services/XPersistenceService.java b/netx/net/sourceforge/jnlp/services/XPersistenceService.java
index b409f82..5388438 100644
--- a/netx/net/sourceforge/jnlp/services/XPersistenceService.java
+++ b/netx/net/sourceforge/jnlp/services/XPersistenceService.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.services;
import java.io.*;
@@ -67,8 +66,8 @@ class XPersistenceService implements PersistenceService {
requestPath = "";
if (JNLPRuntime.isDebug()) {
- System.out.println("codebase path: "+source.getFile());
- System.out.println("request path: "+requestPath);
+ System.out.println("codebase path: " + source.getFile());
+ System.out.println("request path: " + requestPath);
}
if (!source.getFile().startsWith(requestPath))
@@ -82,7 +81,7 @@ class XPersistenceService implements PersistenceService {
*/
protected File toCacheFile(URL location) throws MalformedURLException {
String pcache = JNLPRuntime.getConfiguration()
- .getProperty(DeploymentConfiguration.KEY_USER_PERSISTENCE_CACHE_DIR);
+ .getProperty(DeploymentConfiguration.KEY_USER_PERSISTENCE_CACHE_DIR);
return CacheUtil.urlToPath(location, pcache);
}
@@ -125,7 +124,7 @@ class XPersistenceService implements PersistenceService {
File file = toCacheFile(location);
if (!file.exists())
throw new FileNotFoundException("Persistence store for "
- + location.toString() + " is not found.");
+ + location.toString() + " is not found.");
file.getParentFile().mkdirs();
return (FileContents) ServiceUtil.createPrivilegedProxy(FileContents.class, new XFileContents(file));
@@ -138,7 +137,6 @@ class XPersistenceService implements PersistenceService {
public String[] getNames(URL location) throws MalformedURLException, IOException {
checkLocation(location);
-
File file = toCacheFile(location);
if (!file.isDirectory())
return new String[0];
@@ -147,7 +145,7 @@ class XPersistenceService implements PersistenceService {
// check whether this is right: only add files and not directories.
File entries[] = file.listFiles();
- for (int i=0; i < entries.length; i++)
+ for (int i = 0; i < entries.length; i++)
if (entries[i].isFile())
result.add(entries[i].getName());
diff --git a/netx/net/sourceforge/jnlp/services/XPrintService.java b/netx/net/sourceforge/jnlp/services/XPrintService.java
index f2f75dd..ddbeb98 100644
--- a/netx/net/sourceforge/jnlp/services/XPrintService.java
+++ b/netx/net/sourceforge/jnlp/services/XPrintService.java
@@ -50,74 +50,74 @@ import net.sourceforge.jnlp.runtime.JNLPRuntime;
public class XPrintService implements PrintService {
- // If pj is null, then we do not have a printer to use.
- private PrinterJob pj;
-
- public XPrintService() {
- pj = PrinterJob.getPrinterJob();
+ // If pj is null, then we do not have a printer to use.
+ private PrinterJob pj;
+
+ public XPrintService() {
+ pj = PrinterJob.getPrinterJob();
+ }
+
+ public PageFormat getDefaultPage() {
+ if (pj != null)
+ return pj.defaultPage();
+ else {
+ showWarning();
+ return new PageFormat(); // might not have default settings.
}
-
- public PageFormat getDefaultPage() {
- if (pj != null)
- return pj.defaultPage();
- else {
- showWarning();
- return new PageFormat(); // might not have default settings.
- }
+ }
+
+ public PageFormat showPageFormatDialog(PageFormat page) {
+ if (pj != null)
+ return pj.pageDialog(page);
+ else {
+ showWarning();
+ return page;
}
- public PageFormat showPageFormatDialog(PageFormat page) {
- if (pj != null)
- return pj.pageDialog(page);
- else {
- showWarning();
- return page;
+ }
+
+ public boolean print(Pageable document) {
+ if (pj != null) {
+ pj.setPageable(document);
+ if (pj.printDialog()) {
+ try {
+ pj.print();
+ return true;
+ } catch (PrinterException pe) {
+ System.err.println("Could not print: " + pe);
+ return false;
+ }
+ }
+ } else
+ showWarning();
+
+ return false;
+ }
+
+ public boolean print(Printable painter) {
+ if (pj != null) {
+ pj.setPrintable(painter);
+ if (pj.printDialog()) {
+ try {
+ pj.print();
+ return true;
+ } catch (PrinterException pe) {
+ System.err.println("Could not print: " + pe);
+ return false;
}
- }
-
- public boolean print(Pageable document) {
- if (pj != null) {
- pj.setPageable(document);
- if (pj.printDialog()) {
- try {
- pj.print();
- return true;
- } catch(PrinterException pe) {
- System.err.println("Could not print: " + pe);
- return false;
- }
- }
- } else
- showWarning();
-
- return false;
- }
+ }
+ } else
+ showWarning();
- public boolean print(Printable painter) {
- if (pj != null) {
- pj.setPrintable(painter);
- if (pj.printDialog()) {
- try {
- pj.print();
- return true;
- } catch(PrinterException pe) {
- System.err.println("Could not print: " + pe);
- return false;
- }
-
- }
- } else
- showWarning();
-
- return false;
- }
+ return false;
+ }
- private void showWarning() {
- JOptionPane.showMessageDialog(null,
+ private void showWarning() {
+ JOptionPane.showMessageDialog(null,
"Unable to find a default printer.",
"Warning",
JOptionPane.WARNING_MESSAGE);
- System.err.println("Unable to print: Unable to find default printer.");
- }
+ System.err.println("Unable to print: Unable to find default printer.");
+ }
}
diff --git a/netx/net/sourceforge/jnlp/services/XServiceManagerStub.java b/netx/net/sourceforge/jnlp/services/XServiceManagerStub.java
index 756b412..325ec73 100644
--- a/netx/net/sourceforge/jnlp/services/XServiceManagerStub.java
+++ b/netx/net/sourceforge/jnlp/services/XServiceManagerStub.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.services;
import java.io.*;
@@ -42,33 +41,32 @@ public class XServiceManagerStub implements ServiceManagerStub {
// run less code in the secure environment (or avoid privileged
// actions by giving permission to the code source).
- private static String serviceNames[] = {
- "javax.jnlp.BasicService", // required
- "javax.jnlp.DownloadService", // required
- "javax.jnlp.ExtendedService",
- "javax.jnlp.ExtensionInstallerService", // required
- "javax.jnlp.PersistenceService",
- "javax.jnlp.FileOpenService",
- "javax.jnlp.FileSaveService",
- "javax.jnlp.ClipboardService",
- "javax.jnlp.PrintService",
- "javax.jnlp.SingleInstanceService"
+ private static String serviceNames[] = {
+ "javax.jnlp.BasicService", // required
+ "javax.jnlp.DownloadService", // required
+ "javax.jnlp.ExtendedService",
+ "javax.jnlp.ExtensionInstallerService", // required
+ "javax.jnlp.PersistenceService",
+ "javax.jnlp.FileOpenService",
+ "javax.jnlp.FileSaveService",
+ "javax.jnlp.ClipboardService",
+ "javax.jnlp.PrintService",
+ "javax.jnlp.SingleInstanceService"
};
private static Object services[] = {
- ServiceUtil.createPrivilegedProxy(BasicService.class, new XBasicService()),
- ServiceUtil.createPrivilegedProxy(DownloadService.class, new XDownloadService()),
- ServiceUtil.createPrivilegedProxy(ExtendedService.class, new XExtendedService()),
- ServiceUtil.createPrivilegedProxy(ExtensionInstallerService.class, new XExtensionInstallerService()),
- ServiceUtil.createPrivilegedProxy(PersistenceService.class, new XPersistenceService()),
- ServiceUtil.createPrivilegedProxy(FileOpenService.class, new XFileOpenService()),
- ServiceUtil.createPrivilegedProxy(FileSaveService.class, new XFileSaveService()),
- ServiceUtil.createPrivilegedProxy(ClipboardService.class, new XClipboardService()),
- ServiceUtil.createPrivilegedProxy(PrintService.class, new XPrintService()),
- ServiceUtil.createPrivilegedProxy(ExtendedSingleInstanceService.class, new XSingleInstanceService())
+ ServiceUtil.createPrivilegedProxy(BasicService.class, new XBasicService()),
+ ServiceUtil.createPrivilegedProxy(DownloadService.class, new XDownloadService()),
+ ServiceUtil.createPrivilegedProxy(ExtendedService.class, new XExtendedService()),
+ ServiceUtil.createPrivilegedProxy(ExtensionInstallerService.class, new XExtensionInstallerService()),
+ ServiceUtil.createPrivilegedProxy(PersistenceService.class, new XPersistenceService()),
+ ServiceUtil.createPrivilegedProxy(FileOpenService.class, new XFileOpenService()),
+ ServiceUtil.createPrivilegedProxy(FileSaveService.class, new XFileSaveService()),
+ ServiceUtil.createPrivilegedProxy(ClipboardService.class, new XClipboardService()),
+ ServiceUtil.createPrivilegedProxy(PrintService.class, new XPrintService()),
+ ServiceUtil.createPrivilegedProxy(ExtendedSingleInstanceService.class, new XSingleInstanceService())
};
-
public XServiceManagerStub() {
}
@@ -91,16 +89,16 @@ public class XServiceManagerStub implements ServiceManagerStub {
*/
public Object lookup(String name) throws UnavailableServiceException {
// exact match
- for (int i=0; i < serviceNames.length; i++)
+ for (int i = 0; i < serviceNames.length; i++)
if (serviceNames[i].equals(name))
return services[i];
// substring match
- for (int i=0; i < serviceNames.length; i++)
+ for (int i = 0; i < serviceNames.length; i++)
if (-1 != serviceNames[i].indexOf(name))
return services[i];
- throw new UnavailableServiceException(""+name);
+ throw new UnavailableServiceException("" + name);
}
}
diff --git a/netx/net/sourceforge/jnlp/tools/CharacterEncoder.java b/netx/net/sourceforge/jnlp/tools/CharacterEncoder.java
index 2d8af4f..7913114 100644
--- a/netx/net/sourceforge/jnlp/tools/CharacterEncoder.java
+++ b/netx/net/sourceforge/jnlp/tools/CharacterEncoder.java
@@ -33,7 +33,6 @@ import java.io.PrintStream;
import java.io.IOException;
import java.nio.ByteBuffer;
-
/**
* This class defines the encoding half of character encoders.
* A character encoder is an algorithim for transforming 8 bit binary
@@ -102,7 +101,7 @@ public abstract class CharacterEncoder {
* Encode the prefix that starts every output line.
*/
protected void encodeLinePrefix(OutputStream aStream, int aLength)
- throws IOException {
+ throws IOException {
}
/**
@@ -122,12 +121,12 @@ public abstract class CharacterEncoder {
* read method.
*/
protected int readFully(InputStream in, byte buffer[])
- throws java.io.IOException {
+ throws java.io.IOException {
for (int i = 0; i < buffer.length; i++) {
int q = in.read();
if (q == -1)
return i;
- buffer[i] = (byte)q;
+ buffer[i] = (byte) q;
}
return buffer.length;
}
@@ -139,10 +138,10 @@ public abstract class CharacterEncoder {
* line that is shorter than bytesPerLine().
*/
public void encode(InputStream inStream, OutputStream outStream)
- throws IOException {
- int j;
- int numBytes;
- byte tmpbuffer[] = new byte[bytesPerLine()];
+ throws IOException {
+ int j;
+ int numBytes;
+ byte tmpbuffer[] = new byte[bytesPerLine()];
encodeBufferPrefix(outStream);
@@ -157,7 +156,7 @@ public abstract class CharacterEncoder {
if ((j + bytesPerAtom()) <= numBytes) {
encodeAtom(outStream, tmpbuffer, j, bytesPerAtom());
} else {
- encodeAtom(outStream, tmpbuffer, j, (numBytes)- j);
+ encodeAtom(outStream, tmpbuffer, j, (numBytes) - j);
}
}
if (numBytes < bytesPerLine()) {
@@ -174,7 +173,7 @@ public abstract class CharacterEncoder {
* result to the OutputStream <i>aStream</i>.
*/
public void encode(byte aBuffer[], OutputStream aStream)
- throws IOException {
+ throws IOException {
ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer);
encode(inStream, aStream);
}
@@ -184,8 +183,8 @@ public abstract class CharacterEncoder {
* bytes and returns a string containing the encoded buffer.
*/
public String encode(byte aBuffer[]) {
- ByteArrayOutputStream outStream = new ByteArrayOutputStream();
- ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer);
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer);
String retVal = null;
try {
encode(inStream, outStream);
@@ -207,19 +206,19 @@ public abstract class CharacterEncoder {
* byte array backing the ByteBuffer. If this is not possible, a
* new byte array will be created.
*/
- private byte [] getBytes(ByteBuffer bb) {
+ private byte[] getBytes(ByteBuffer bb) {
/*
* This should never return a BufferOverflowException, as we're
* careful to allocate just the right amount.
*/
- byte [] buf = null;
+ byte[] buf = null;
/*
* If it has a usable backing byte buffer, use it. Use only
* if the array exactly represents the current ByteBuffer.
*/
if (bb.hasArray()) {
- byte [] tmp = bb.array();
+ byte[] tmp = bb.array();
if ((tmp.length == bb.capacity()) &&
(tmp.length == bb.remaining())) {
buf = tmp;
@@ -251,8 +250,8 @@ public abstract class CharacterEncoder {
* The ByteBuffer's position will be advanced to ByteBuffer's limit.
*/
public void encode(ByteBuffer aBuffer, OutputStream aStream)
- throws IOException {
- byte [] buf = getBytes(aBuffer);
+ throws IOException {
+ byte[] buf = getBytes(aBuffer);
encode(buf, aStream);
}
@@ -263,7 +262,7 @@ public abstract class CharacterEncoder {
* The ByteBuffer's position will be advanced to ByteBuffer's limit.
*/
public String encode(ByteBuffer aBuffer) {
- byte [] buf = getBytes(aBuffer);
+ byte[] buf = getBytes(aBuffer);
return encode(buf);
}
@@ -274,10 +273,10 @@ public abstract class CharacterEncoder {
* line at the end of a final line that is shorter than bytesPerLine().
*/
public void encodeBuffer(InputStream inStream, OutputStream outStream)
- throws IOException {
- int j;
- int numBytes;
- byte tmpbuffer[] = new byte[bytesPerLine()];
+ throws IOException {
+ int j;
+ int numBytes;
+ byte tmpbuffer[] = new byte[bytesPerLine()];
encodeBufferPrefix(outStream);
@@ -291,7 +290,7 @@ public abstract class CharacterEncoder {
if ((j + bytesPerAtom()) <= numBytes) {
encodeAtom(outStream, tmpbuffer, j, bytesPerAtom());
} else {
- encodeAtom(outStream, tmpbuffer, j, (numBytes)- j);
+ encodeAtom(outStream, tmpbuffer, j, (numBytes) - j);
}
}
encodeLineSuffix(outStream);
@@ -307,7 +306,7 @@ public abstract class CharacterEncoder {
* result to the OutputStream <i>aStream</i>.
*/
public void encodeBuffer(byte aBuffer[], OutputStream aStream)
- throws IOException {
+ throws IOException {
ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer);
encodeBuffer(inStream, aStream);
}
@@ -317,8 +316,8 @@ public abstract class CharacterEncoder {
* bytes and returns a string containing the encoded buffer.
*/
public String encodeBuffer(byte aBuffer[]) {
- ByteArrayOutputStream outStream = new ByteArrayOutputStream();
- ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer);
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer);
try {
encodeBuffer(inStream, outStream);
} catch (Exception IOException) {
@@ -335,8 +334,8 @@ public abstract class CharacterEncoder {
* The ByteBuffer's position will be advanced to ByteBuffer's limit.
*/
public void encodeBuffer(ByteBuffer aBuffer, OutputStream aStream)
- throws IOException {
- byte [] buf = getBytes(aBuffer);
+ throws IOException {
+ byte[] buf = getBytes(aBuffer);
encodeBuffer(buf, aStream);
}
@@ -347,7 +346,7 @@ public abstract class CharacterEncoder {
* The ByteBuffer's position will be advanced to ByteBuffer's limit.
*/
public String encodeBuffer(ByteBuffer aBuffer) {
- byte [] buf = getBytes(aBuffer);
+ byte[] buf = getBytes(aBuffer);
return encodeBuffer(buf);
}
diff --git a/netx/net/sourceforge/jnlp/tools/HexDumpEncoder.java b/netx/net/sourceforge/jnlp/tools/HexDumpEncoder.java
index 4f7c27f..7b6b242 100644
--- a/netx/net/sourceforge/jnlp/tools/HexDumpEncoder.java
+++ b/netx/net/sourceforge/jnlp/tools/HexDumpEncoder.java
@@ -55,15 +55,15 @@ public class HexDumpEncoder extends CharacterEncoder {
c = (char) ((x >> 4) & 0xf);
if (c > 9)
- c = (char) ((c-10) + 'A');
+ c = (char) ((c - 10) + 'A');
else
- c = (char)(c + '0');
+ c = (char) (c + '0');
p.write(c);
c = (char) (x & 0xf);
if (c > 9)
- c = (char)((c-10) + 'A');
+ c = (char) ((c - 10) + 'A');
else
- c = (char)(c + '0');
+ c = (char) (c + '0');
p.write(c);
}
@@ -81,8 +81,8 @@ public class HexDumpEncoder extends CharacterEncoder {
}
protected void encodeLinePrefix(OutputStream o, int len) throws IOException {
- hexDigit(pStream, (byte)((offset >>> 8) & 0xff));
- hexDigit(pStream, (byte)(offset & 0xff));
+ hexDigit(pStream, (byte) ((offset >>> 8) & 0xff));
+ hexDigit(pStream, (byte) (offset & 0xff));
pStream.print(": ");
currentByte = 0;
thisLineLength = len;
diff --git a/netx/net/sourceforge/jnlp/tools/JarRunner.java b/netx/net/sourceforge/jnlp/tools/JarRunner.java
index 52e86da..33c056f 100644
--- a/netx/net/sourceforge/jnlp/tools/JarRunner.java
+++ b/netx/net/sourceforge/jnlp/tools/JarRunner.java
@@ -1,15 +1,14 @@
package net.sourceforge.jnlp.tools;
import net.sourceforge.jnlp.tools.JarSigner;
-public class JarRunner {
-
- public static void main(String[] args) throws Exception{
+public class JarRunner {
+ public static void main(String[] args) throws Exception {
- //JarSigner.main(args);
- JarSigner js = new JarSigner();
- js.verifyJar(args[0]);
- }
+ //JarSigner.main(args);
+ JarSigner js = new JarSigner();
+ js.verifyJar(args[0]);
+ }
}
diff --git a/netx/net/sourceforge/jnlp/tools/JarSigner.java b/netx/net/sourceforge/jnlp/tools/JarSigner.java
index da7cf13..0630702 100644
--- a/netx/net/sourceforge/jnlp/tools/JarSigner.java
+++ b/netx/net/sourceforge/jnlp/tools/JarSigner.java
@@ -64,15 +64,16 @@ public class JarSigner implements CertVerifier {
// prefix for new signature-related files in META-INF directory
private static final String SIG_PREFIX = META_INF + "SIG-";
-
- private static final long SIX_MONTHS = 180*24*60*60*1000L; //milliseconds
+ private static final long SIX_MONTHS = 180 * 24 * 60 * 60 * 1000L; //milliseconds
static final String VERSION = "1.0";
static final int IN_KEYSTORE = 0x01;
static final int IN_SCOPE = 0x02;
- static enum verifyResult {UNSIGNED, SIGNED_OK, SIGNED_NOT_OK}
+ static enum verifyResult {
+ UNSIGNED, SIGNED_OK, SIGNED_NOT_OK
+ }
// signer's certificate chain (when composing)
X509Certificate[] certChain;
@@ -86,14 +87,14 @@ public class JarSigner implements CertVerifier {
String keystore; // key store file
boolean nullStream = false; // null keystore input stream (NONE)
boolean token = false; // token-based keystore
- String jarfile; // jar file to sign
- String alias; // alias to sign jar with
+ String jarfile; // jar file to sign
+ String alias; // alias to sign jar with
char[] storepass; // keystore password
boolean protectedPath; // protected authentication path
String storetype; // keystore type
String providerName; // provider name
Vector<String> providers = null; // list of providers
- HashMap<String,String> providerArgs = new HashMap<String, String>(); // arguments for provider constructors
+ HashMap<String, String> providerArgs = new HashMap<String, String>(); // arguments for provider constructors
char[] keypass; // private key password
String sigfile; // name of .SF file
String sigalg; // name of signature algorithm
@@ -165,7 +166,7 @@ public class JarSigner implements CertVerifier {
*/
public boolean hasSigningIssues() {
return hasExpiredCert || notYetValidCert || badKeyUsage
- || badExtendedKeyUsage || badNetscapeCertType;
+ || badExtendedKeyUsage || badNetscapeCertType;
}
/* (non-Javadoc)
@@ -194,7 +195,7 @@ public class JarSigner implements CertVerifier {
}
public void verifyJars(List<JARDesc> jars, ResourceTracker tracker)
- throws Exception {
+ throws Exception {
certs = new ArrayList<CertPath>();
for (int i = 0; i < jars.size(); i++) {
@@ -224,7 +225,7 @@ public class JarSigner implements CertVerifier {
} else if (result == verifyResult.SIGNED_OK) {
verifiedJars.add(localFile);
}
- } catch (Exception e){
+ } catch (Exception e) {
// We may catch exceptions from using verifyJar()
// or from checkTrustedCerts
throw e;
@@ -267,7 +268,8 @@ public class JarSigner implements CertVerifier {
}
if (jarFile.getManifest() != null) {
- if (verbose) System.out.println();
+ if (verbose)
+ System.out.println();
Enumeration<JarEntry> e = entriesVec.elements();
long now = System.currentTimeMillis();
@@ -290,16 +292,16 @@ public class JarSigner implements CertVerifier {
certs.add(certPath);
//we really only want the first certPath
- if (!certPath.equals(this.certPath)){
+ if (!certPath.equals(this.certPath)) {
this.certPath = certPath;
}
Certificate cert = signers[i].getSignerCertPath()
- .getCertificates().get(0);
+ .getCertificates().get(0);
if (cert instanceof X509Certificate) {
- checkCertUsage((X509Certificate)cert, null);
+ checkCertUsage((X509Certificate) cert, null);
if (!showcerts) {
- long notAfter = ((X509Certificate)cert)
+ long notAfter = ((X509Certificate) cert)
.getNotAfter().getTime();
if (notAfter < now) {
@@ -358,8 +360,7 @@ public class JarSigner implements CertVerifier {
//anySigned does not guarantee that all files were signed.
return (anySigned && !(hasUnsignedEntry || hasExpiredCert
- || badKeyUsage || badExtendedKeyUsage || badNetscapeCertType
- || notYetValidCert)) ? verifyResult.SIGNED_OK : verifyResult.SIGNED_NOT_OK;
+ || badKeyUsage || badExtendedKeyUsage || badNetscapeCertType || notYetValidCert)) ? verifyResult.SIGNED_OK : verifyResult.SIGNED_NOT_OK;
}
/**
@@ -368,24 +369,24 @@ public class JarSigner implements CertVerifier {
*/
private void checkTrustedCerts() throws Exception {
if (certPath != null) {
- try {
- X509Certificate publisher = (X509Certificate) getPublisher();
- KeyStore[] certKeyStores = KeyStores.getCertKeyStores();
- alreadyTrustPublisher = CertificateUtils.inKeyStores(publisher, certKeyStores);
- X509Certificate root = (X509Certificate) getRoot();
- KeyStore[] caKeyStores = KeyStores.getCAKeyStores();
- rootInCacerts = CertificateUtils.inKeyStores(root, caKeyStores);
- } catch (Exception e) {
- // TODO: Warn user about not being able to
- // look through their cacerts/trusted.certs
- // file depending on exception.
- throw e;
- }
+ try {
+ X509Certificate publisher = (X509Certificate) getPublisher();
+ KeyStore[] certKeyStores = KeyStores.getCertKeyStores();
+ alreadyTrustPublisher = CertificateUtils.inKeyStores(publisher, certKeyStores);
+ X509Certificate root = (X509Certificate) getRoot();
+ KeyStore[] caKeyStores = KeyStores.getCAKeyStores();
+ rootInCacerts = CertificateUtils.inKeyStores(root, caKeyStores);
+ } catch (Exception e) {
+ // TODO: Warn user about not being able to
+ // look through their cacerts/trusted.certs
+ // file depending on exception.
+ throw e;
+ }
- if (!rootInCacerts)
- addToDetails(R("SUntrustedCertificate"));
- else
- addToDetails(R("STrustedCertificate"));
+ if (!rootInCacerts)
+ addToDetails(R("SUntrustedCertificate"));
+ else
+ addToDetails(R("STrustedCertificate"));
}
}
@@ -394,15 +395,14 @@ public class JarSigner implements CertVerifier {
*/
public Certificate getPublisher() {
if (certPath != null) {
- List<? extends Certificate> certList
- = certPath.getCertificates();
- if (certList.size() > 0) {
- return (Certificate)certList.get(0);
- } else {
- return null;
- }
- } else {
+ List<? extends Certificate> certList = certPath.getCertificates();
+ if (certList.size() > 0) {
+ return (Certificate) certList.get(0);
+ } else {
return null;
+ }
+ } else {
+ return null;
}
}
@@ -411,26 +411,25 @@ public class JarSigner implements CertVerifier {
*/
public Certificate getRoot() {
if (certPath != null) {
- List<? extends Certificate> certList
- = certPath.getCertificates();
- if (certList.size() > 0) {
- return (Certificate)certList.get(
+ List<? extends Certificate> certList = certPath.getCertificates();
+ if (certList.size() > 0) {
+ return (Certificate) certList.get(
certList.size() - 1);
- } else {
- return null;
- }
- } else {
+ } else {
return null;
+ }
+ } else {
+ return null;
}
}
- private void addToDetails(String detail) {
- if (!details.contains(detail))
- details.add(detail);
- }
+ private void addToDetails(String detail) {
+ if (!details.contains(detail))
+ details.add(detail);
+ }
Hashtable<Certificate, String> storeHash =
- new Hashtable<Certificate, String>();
+ new Hashtable<Certificate, String>();
/**
* signature-related files include:
@@ -498,7 +497,7 @@ public class JarSigner implements CertVerifier {
List<String> xKeyUsage = userCert.getExtendedKeyUsage();
if (xKeyUsage != null) {
if (!xKeyUsage.contains("2.5.29.37.0") // anyExtendedKeyUsage
- && !xKeyUsage.contains("1.3.6.1.5.5.7.3.3")) { // codeSigning
+ && !xKeyUsage.contains("1.3.6.1.5.5.7.3.3")) { // codeSigning
if (bad != null) {
bad[1] = true;
} else {
@@ -518,12 +517,12 @@ public class JarSigner implements CertVerifier {
DerInputStream in = new DerInputStream(netscapeEx);
byte[] encoded = in.getOctetString();
encoded = new DerValue(encoded).getUnalignedBitString()
- .toByteArray();
+ .toByteArray();
NetscapeCertTypeExtension extn =
- new NetscapeCertTypeExtension(encoded);
+ new NetscapeCertTypeExtension(encoded);
- Boolean val = (Boolean)extn.get(
+ Boolean val = (Boolean) extn.get(
NetscapeCertTypeExtension.OBJECT_SIGNING);
if (!val) {
if (bad != null) {
@@ -538,14 +537,13 @@ public class JarSigner implements CertVerifier {
}
}
-
/**
* Returns if all jars are signed.
*
* @return True if all jars are signed, false if there are one or more unsigned jars
*/
public boolean allJarsSigned() {
- return this.unverifiedJars.size() == 0;
+ return this.unverifiedJars.size() == 0;
}
}
diff --git a/netx/net/sourceforge/jnlp/tools/JarSignerResources.java b/netx/net/sourceforge/jnlp/tools/JarSignerResources.java
index 50655ab..7d02b66 100644
--- a/netx/net/sourceforge/jnlp/tools/JarSignerResources.java
+++ b/netx/net/sourceforge/jnlp/tools/JarSignerResources.java
@@ -34,169 +34,169 @@ public class JarSignerResources extends java.util.ListResourceBundle {
private static final Object[][] contents = {
- // shared (from jarsigner)
- {" ", " "},
- {" ", " "},
- {" ", " "},
- {", ", ", "},
+ // shared (from jarsigner)
+ { " ", " " },
+ { " ", " " },
+ { " ", " " },
+ { ", ", ", " },
- {"provName not a provider", "{0} not a provider"},
- {"signerClass is not a signing mechanism", "{0} is not a signing mechanism"},
- {"jarsigner error: ", "jarsigner error: "},
- {"Illegal option: ", "Illegal option: "},
- {"-keystore must be NONE if -storetype is {0}",
- "-keystore must be NONE if -storetype is {0}"},
- {"-keypass can not be specified if -storetype is {0}",
- "-keypass can not be specified if -storetype is {0}"},
- {"If -protected is specified, then -storepass and -keypass must not be specified",
- "If -protected is specified, then -storepass and -keypass must not be specified"},
- {"If keystore is not password protected, then -storepass and -keypass must not be specified",
- "If keystore is not password protected, then -storepass and -keypass must not be specified"},
- {"Usage: jarsigner [options] jar-file alias",
- "Usage: jarsigner [options] jar-file alias"},
- {" jarsigner -verify [options] jar-file",
- " jarsigner -verify [options] jar-file"},
- {"[-keystore <url>] keystore location",
- "[-keystore <url>] keystore location"},
- {"[-storepass <password>] password for keystore integrity",
- "[-storepass <password>] password for keystore integrity"},
- {"[-storetype <type>] keystore type",
- "[-storetype <type>] keystore type"},
- {"[-keypass <password>] password for private key (if different)",
- "[-keypass <password>] password for private key (if different)"},
- {"[-sigfile <file>] name of .SF/.DSA file",
- "[-sigfile <file>] name of .SF/.DSA file"},
- {"[-signedjar <file>] name of signed JAR file",
- "[-signedjar <file>] name of signed JAR file"},
- {"[-digestalg <algorithm>] name of digest algorithm",
- "[-digestalg <algorithm>] name of digest algorithm"},
- {"[-sigalg <algorithm>] name of signature algorithm",
- "[-sigalg <algorithm>] name of signature algorithm"},
- {"[-verify] verify a signed JAR file",
- "[-verify] verify a signed JAR file"},
- {"[-verbose] verbose output when signing/verifying",
- "[-verbose] verbose output when signing/verifying"},
- {"[-certs] display certificates when verbose and verifying",
- "[-certs] display certificates when verbose and verifying"},
- {"[-tsa <url>] location of the Timestamping Authority",
- "[-tsa <url>] location of the Timestamping Authority"},
- {"[-tsacert <alias>] public key certificate for Timestamping Authority",
- "[-tsacert <alias>] public key certificate for Timestamping Authority"},
- {"[-altsigner <class>] class name of an alternative signing mechanism",
- "[-altsigner <class>] class name of an alternative signing mechanism"},
- {"[-altsignerpath <pathlist>] location of an alternative signing mechanism",
- "[-altsignerpath <pathlist>] location of an alternative signing mechanism"},
- {"[-internalsf] include the .SF file inside the signature block",
- "[-internalsf] include the .SF file inside the signature block"},
- {"[-sectionsonly] don't compute hash of entire manifest",
- "[-sectionsonly] don't compute hash of entire manifest"},
- {"[-protected] keystore has protected authentication path",
- "[-protected] keystore has protected authentication path"},
- {"[-providerName <name>] provider name",
- "[-providerName <name>] provider name"},
- {"[-providerClass <class> name of cryptographic service provider's",
- "[-providerClass <class> name of cryptographic service provider's"},
- {" [-providerArg <arg>]] ... master class file and constructor argument",
- " [-providerArg <arg>]] ... master class file and constructor argument"},
- {"s", "s"},
- {"m", "m"},
- {"k", "k"},
- {"i", "i"},
- {" s = signature was verified ",
- " s = signature was verified "},
- {" m = entry is listed in manifest",
- " m = entry is listed in manifest"},
- {" k = at least one certificate was found in keystore",
- " k = at least one certificate was found in keystore"},
- {" i = at least one certificate was found in identity scope",
- " i = at least one certificate was found in identity scope"},
- {"no manifest.", "no manifest."},
- {"jar is unsigned. (signatures missing or not parsable)",
- "jar is unsigned. (signatures missing or not parsable)"},
- {"jar verified.", "jar verified."},
- {"jarsigner: ", "jarsigner: "},
- {"signature filename must consist of the following characters: A-Z, 0-9, _ or -",
- "signature filename must consist of the following characters: A-Z, 0-9, _ or -"},
- {"unable to open jar file: ", "unable to open jar file: "},
- {"unable to create: ", "unable to create: "},
- {" adding: ", " adding: "},
- {" updating: ", " updating: "},
- {" signing: ", " signing: "},
- {"attempt to rename signedJarFile to jarFile failed",
- "attempt to rename {0} to {1} failed"},
- {"attempt to rename jarFile to origJar failed",
- "attempt to rename {0} to {1} failed"},
- {"unable to sign jar: ", "unable to sign jar: "},
- {"Enter Passphrase for keystore: ", "Enter Passphrase for keystore: "},
- {"keystore load: ", "keystore load: "},
- {"certificate exception: ", "certificate exception: "},
- {"unable to instantiate keystore class: ",
- "unable to instantiate keystore class: "},
- {"Certificate chain not found for: alias. alias must reference a valid KeyStore key entry containing a private key and corresponding public key certificate chain.",
- "Certificate chain not found for: {0}. {1} must reference a valid KeyStore key entry containing a private key and corresponding public key certificate chain."},
- {"found non-X.509 certificate in signer's chain",
- "found non-X.509 certificate in signer's chain"},
- {"incomplete certificate chain", "incomplete certificate chain"},
- {"Enter key password for alias: ", "Enter key password for {0}: "},
- {"unable to recover key from keystore",
- "unable to recover key from keystore"},
- {"key associated with alias not a private key",
- "key associated with {0} not a private key"},
- {"you must enter key password", "you must enter key password"},
- {"unable to read password: ", "unable to read password: "},
- {"certificate is valid from", "certificate is valid from {0} to {1}"},
- {"certificate expired on", "certificate expired on {0}"},
- {"certificate is not valid until",
- "certificate is not valid until {0}"},
- {"certificate will expire on", "certificate will expire on {0}"},
- {"requesting a signature timestamp",
- "requesting a signature timestamp"},
- {"TSA location: ", "TSA location: "},
- {"TSA certificate: ", "TSA certificate: "},
- {"no response from the Timestamping Authority. ",
- "no response from the Timestamping Authority. "},
- {"When connecting from behind a firewall then an HTTP proxy may need to be specified. ",
- "When connecting from behind a firewall then an HTTP proxy may need to be specified. "},
- {"Supply the following options to jarsigner: ",
- "Supply the following options to jarsigner: "},
- {"Certificate not found for: alias. alias must reference a valid KeyStore entry containing an X.509 public key certificate for the Timestamping Authority.",
- "Certificate not found for: {0}. {1} must reference a valid KeyStore entry containing an X.509 public key certificate for the Timestamping Authority."},
- {"using an alternative signing mechanism",
- "using an alternative signing mechanism"},
- {"entry was signed on", "entry was signed on {0}"},
- {"Warning: ", "Warning: "},
- {"This jar contains unsigned entries which have not been integrity-checked. ",
- "This jar contains unsigned entries which have not been integrity-checked. "},
- {"This jar contains entries whose signer certificate has expired. ",
- "This jar contains entries whose signer certificate has expired. "},
- {"This jar contains entries whose signer certificate will expire within six months. ",
- "This jar contains entries whose signer certificate will expire within six months. "},
- {"This jar contains entries whose signer certificate is not yet valid. ",
- "This jar contains entries whose signer certificate is not yet valid. "},
- {"Re-run with the -verbose option for more details.",
- "Re-run with the -verbose option for more details."},
- {"Re-run with the -verbose and -certs options for more details.",
- "Re-run with the -verbose and -certs options for more details."},
- {"The signer certificate has expired.",
- "The signer certificate has expired."},
- {"The signer certificate will expire within six months.",
- "The signer certificate will expire within six months."},
- {"The signer certificate is not yet valid.",
- "The signer certificate is not yet valid."},
- {"The signer certificate's KeyUsage extension doesn't allow code signing.",
- "The signer certificate's KeyUsage extension doesn't allow code signing."},
- {"The signer certificate's ExtendedKeyUsage extension doesn't allow code signing.",
- "The signer certificate's ExtendedKeyUsage extension doesn't allow code signing."},
- {"The signer certificate's NetscapeCertType extension doesn't allow code signing.",
- "The signer certificate's NetscapeCertType extension doesn't allow code signing."},
- {"This jar contains entries whose signer certificate's KeyUsage extension doesn't allow code signing.",
- "This jar contains entries whose signer certificate's KeyUsage extension doesn't allow code signing."},
- {"This jar contains entries whose signer certificate's ExtendedKeyUsage extension doesn't allow code signing.",
- "This jar contains entries whose signer certificate's ExtendedKeyUsage extension doesn't allow code signing."},
- {"This jar contains entries whose signer certificate's NetscapeCertType extension doesn't allow code signing.",
- "This jar contains entries whose signer certificate's NetscapeCertType extension doesn't allow code signing."},
- {"[{0} extension does not support code signing]",
- "[{0} extension does not support code signing]"},
+ { "provName not a provider", "{0} not a provider" },
+ { "signerClass is not a signing mechanism", "{0} is not a signing mechanism" },
+ { "jarsigner error: ", "jarsigner error: " },
+ { "Illegal option: ", "Illegal option: " },
+ { "-keystore must be NONE if -storetype is {0}",
+ "-keystore must be NONE if -storetype is {0}" },
+ { "-keypass can not be specified if -storetype is {0}",
+ "-keypass can not be specified if -storetype is {0}" },
+ { "If -protected is specified, then -storepass and -keypass must not be specified",
+ "If -protected is specified, then -storepass and -keypass must not be specified" },
+ { "If keystore is not password protected, then -storepass and -keypass must not be specified",
+ "If keystore is not password protected, then -storepass and -keypass must not be specified" },
+ { "Usage: jarsigner [options] jar-file alias",
+ "Usage: jarsigner [options] jar-file alias" },
+ { " jarsigner -verify [options] jar-file",
+ " jarsigner -verify [options] jar-file" },
+ { "[-keystore <url>] keystore location",
+ "[-keystore <url>] keystore location" },
+ { "[-storepass <password>] password for keystore integrity",
+ "[-storepass <password>] password for keystore integrity" },
+ { "[-storetype <type>] keystore type",
+ "[-storetype <type>] keystore type" },
+ { "[-keypass <password>] password for private key (if different)",
+ "[-keypass <password>] password for private key (if different)" },
+ { "[-sigfile <file>] name of .SF/.DSA file",
+ "[-sigfile <file>] name of .SF/.DSA file" },
+ { "[-signedjar <file>] name of signed JAR file",
+ "[-signedjar <file>] name of signed JAR file" },
+ { "[-digestalg <algorithm>] name of digest algorithm",
+ "[-digestalg <algorithm>] name of digest algorithm" },
+ { "[-sigalg <algorithm>] name of signature algorithm",
+ "[-sigalg <algorithm>] name of signature algorithm" },
+ { "[-verify] verify a signed JAR file",
+ "[-verify] verify a signed JAR file" },
+ { "[-verbose] verbose output when signing/verifying",
+ "[-verbose] verbose output when signing/verifying" },
+ { "[-certs] display certificates when verbose and verifying",
+ "[-certs] display certificates when verbose and verifying" },
+ { "[-tsa <url>] location of the Timestamping Authority",
+ "[-tsa <url>] location of the Timestamping Authority" },
+ { "[-tsacert <alias>] public key certificate for Timestamping Authority",
+ "[-tsacert <alias>] public key certificate for Timestamping Authority" },
+ { "[-altsigner <class>] class name of an alternative signing mechanism",
+ "[-altsigner <class>] class name of an alternative signing mechanism" },
+ { "[-altsignerpath <pathlist>] location of an alternative signing mechanism",
+ "[-altsignerpath <pathlist>] location of an alternative signing mechanism" },
+ { "[-internalsf] include the .SF file inside the signature block",
+ "[-internalsf] include the .SF file inside the signature block" },
+ { "[-sectionsonly] don't compute hash of entire manifest",
+ "[-sectionsonly] don't compute hash of entire manifest" },
+ { "[-protected] keystore has protected authentication path",
+ "[-protected] keystore has protected authentication path" },
+ { "[-providerName <name>] provider name",
+ "[-providerName <name>] provider name" },
+ { "[-providerClass <class> name of cryptographic service provider's",
+ "[-providerClass <class> name of cryptographic service provider's" },
+ { " [-providerArg <arg>]] ... master class file and constructor argument",
+ " [-providerArg <arg>]] ... master class file and constructor argument" },
+ { "s", "s" },
+ { "m", "m" },
+ { "k", "k" },
+ { "i", "i" },
+ { " s = signature was verified ",
+ " s = signature was verified " },
+ { " m = entry is listed in manifest",
+ " m = entry is listed in manifest" },
+ { " k = at least one certificate was found in keystore",
+ " k = at least one certificate was found in keystore" },
+ { " i = at least one certificate was found in identity scope",
+ " i = at least one certificate was found in identity scope" },
+ { "no manifest.", "no manifest." },
+ { "jar is unsigned. (signatures missing or not parsable)",
+ "jar is unsigned. (signatures missing or not parsable)" },
+ { "jar verified.", "jar verified." },
+ { "jarsigner: ", "jarsigner: " },
+ { "signature filename must consist of the following characters: A-Z, 0-9, _ or -",
+ "signature filename must consist of the following characters: A-Z, 0-9, _ or -" },
+ { "unable to open jar file: ", "unable to open jar file: " },
+ { "unable to create: ", "unable to create: " },
+ { " adding: ", " adding: " },
+ { " updating: ", " updating: " },
+ { " signing: ", " signing: " },
+ { "attempt to rename signedJarFile to jarFile failed",
+ "attempt to rename {0} to {1} failed" },
+ { "attempt to rename jarFile to origJar failed",
+ "attempt to rename {0} to {1} failed" },
+ { "unable to sign jar: ", "unable to sign jar: " },
+ { "Enter Passphrase for keystore: ", "Enter Passphrase for keystore: " },
+ { "keystore load: ", "keystore load: " },
+ { "certificate exception: ", "certificate exception: " },
+ { "unable to instantiate keystore class: ",
+ "unable to instantiate keystore class: " },
+ { "Certificate chain not found for: alias. alias must reference a valid KeyStore key entry containing a private key and corresponding public key certificate chain.",
+ "Certificate chain not found for: {0}. {1} must reference a valid KeyStore key entry containing a private key and corresponding public key certificate chain." },
+ { "found non-X.509 certificate in signer's chain",
+ "found non-X.509 certificate in signer's chain" },
+ { "incomplete certificate chain", "incomplete certificate chain" },
+ { "Enter key password for alias: ", "Enter key password for {0}: " },
+ { "unable to recover key from keystore",
+ "unable to recover key from keystore" },
+ { "key associated with alias not a private key",
+ "key associated with {0} not a private key" },
+ { "you must enter key password", "you must enter key password" },
+ { "unable to read password: ", "unable to read password: " },
+ { "certificate is valid from", "certificate is valid from {0} to {1}" },
+ { "certificate expired on", "certificate expired on {0}" },
+ { "certificate is not valid until",
+ "certificate is not valid until {0}" },
+ { "certificate will expire on", "certificate will expire on {0}" },
+ { "requesting a signature timestamp",
+ "requesting a signature timestamp" },
+ { "TSA location: ", "TSA location: " },
+ { "TSA certificate: ", "TSA certificate: " },
+ { "no response from the Timestamping Authority. ",
+ "no response from the Timestamping Authority. " },
+ { "When connecting from behind a firewall then an HTTP proxy may need to be specified. ",
+ "When connecting from behind a firewall then an HTTP proxy may need to be specified. " },
+ { "Supply the following options to jarsigner: ",
+ "Supply the following options to jarsigner: " },
+ { "Certificate not found for: alias. alias must reference a valid KeyStore entry containing an X.509 public key certificate for the Timestamping Authority.",
+ "Certificate not found for: {0}. {1} must reference a valid KeyStore entry containing an X.509 public key certificate for the Timestamping Authority." },
+ { "using an alternative signing mechanism",
+ "using an alternative signing mechanism" },
+ { "entry was signed on", "entry was signed on {0}" },
+ { "Warning: ", "Warning: " },
+ { "This jar contains unsigned entries which have not been integrity-checked. ",
+ "This jar contains unsigned entries which have not been integrity-checked. " },
+ { "This jar contains entries whose signer certificate has expired. ",
+ "This jar contains entries whose signer certificate has expired. " },
+ { "This jar contains entries whose signer certificate will expire within six months. ",
+ "This jar contains entries whose signer certificate will expire within six months. " },
+ { "This jar contains entries whose signer certificate is not yet valid. ",
+ "This jar contains entries whose signer certificate is not yet valid. " },
+ { "Re-run with the -verbose option for more details.",
+ "Re-run with the -verbose option for more details." },
+ { "Re-run with the -verbose and -certs options for more details.",
+ "Re-run with the -verbose and -certs options for more details." },
+ { "The signer certificate has expired.",
+ "The signer certificate has expired." },
+ { "The signer certificate will expire within six months.",
+ "The signer certificate will expire within six months." },
+ { "The signer certificate is not yet valid.",
+ "The signer certificate is not yet valid." },
+ { "The signer certificate's KeyUsage extension doesn't allow code signing.",
+ "The signer certificate's KeyUsage extension doesn't allow code signing." },
+ { "The signer certificate's ExtendedKeyUsage extension doesn't allow code signing.",
+ "The signer certificate's ExtendedKeyUsage extension doesn't allow code signing." },
+ { "The signer certificate's NetscapeCertType extension doesn't allow code signing.",
+ "The signer certificate's NetscapeCertType extension doesn't allow code signing." },
+ { "This jar contains entries whose signer certificate's KeyUsage extension doesn't allow code signing.",
+ "This jar contains entries whose signer certificate's KeyUsage extension doesn't allow code signing." },
+ { "This jar contains entries whose signer certificate's ExtendedKeyUsage extension doesn't allow code signing.",
+ "This jar contains entries whose signer certificate's ExtendedKeyUsage extension doesn't allow code signing." },
+ { "This jar contains entries whose signer certificate's NetscapeCertType extension doesn't allow code signing.",
+ "This jar contains entries whose signer certificate's NetscapeCertType extension doesn't allow code signing." },
+ { "[{0} extension does not support code signing]",
+ "[{0} extension does not support code signing]" },
};
/**
diff --git a/netx/net/sourceforge/jnlp/tools/KeyStoreUtil.java b/netx/net/sourceforge/jnlp/tools/KeyStoreUtil.java
index 5f497ef..017bbea 100644
--- a/netx/net/sourceforge/jnlp/tools/KeyStoreUtil.java
+++ b/netx/net/sourceforge/jnlp/tools/KeyStoreUtil.java
@@ -44,7 +44,6 @@ public class KeyStoreUtil {
// this class is not meant to be instantiated
}
-
/**
* Returns true if KeyStore has a password. This is true except for
* MSCAPI KeyStores
@@ -60,7 +59,7 @@ public class KeyStoreUtil {
public static String niceStoreTypeName(String storetype) {
if (storetype.equalsIgnoreCase("Windows-MY")) {
return "Windows-MY";
- } else if(storetype.equalsIgnoreCase("Windows-ROOT")) {
+ } else if (storetype.equalsIgnoreCase("Windows-ROOT")) {
return "Windows-ROOT";
} else {
return storetype.toUpperCase();
diff --git a/netx/net/sourceforge/jnlp/tools/KeyTool.java b/netx/net/sourceforge/jnlp/tools/KeyTool.java
index 7e7d4e7..eeda0aa 100644
--- a/netx/net/sourceforge/jnlp/tools/KeyTool.java
+++ b/netx/net/sourceforge/jnlp/tools/KeyTool.java
@@ -53,137 +53,137 @@ import net.sourceforge.jnlp.security.SecurityUtil;
*/
public class KeyTool {
- // The user's keystore.
- private KeyStore usercerts = null;
- // JDK cacerts
- private KeyStore cacerts = null;
- // System ca-bundle.crt
- private KeyStore systemcerts = null;
+ // The user's keystore.
+ private KeyStore usercerts = null;
+ // JDK cacerts
+ private KeyStore cacerts = null;
+ // System ca-bundle.crt
+ private KeyStore systemcerts = null;
- private String fullCertPath = SecurityUtil.getTrustedCertsFilename();
+ private String fullCertPath = SecurityUtil.getTrustedCertsFilename();
- private FileOutputStream fos = null;
+ private FileOutputStream fos = null;
- /**
- * Whether we trust the system cacerts file.
- */
- private boolean trustcacerts = true;
+ /**
+ * Whether we trust the system cacerts file.
+ */
+ private boolean trustcacerts = true;
- private final char[] password = "changeit".toCharArray();
+ private final char[] password = "changeit".toCharArray();
- /**
- * Whether we prompt for user input.
- */
- private boolean noprompt = true;
+ /**
+ * Whether we prompt for user input.
+ */
+ private boolean noprompt = true;
- public KeyTool() throws Exception {
+ public KeyTool() throws Exception {
- // Initialize all the keystores.
- usercerts = SecurityUtil.getUserKeyStore();
- cacerts = SecurityUtil.getCacertsKeyStore();
- systemcerts = SecurityUtil.getSystemCertStore();
- }
+ // Initialize all the keystores.
+ usercerts = SecurityUtil.getUserKeyStore();
+ cacerts = SecurityUtil.getCacertsKeyStore();
+ systemcerts = SecurityUtil.getSystemCertStore();
+ }
- /**
- * Adds a trusted certificate to the user's keystore.
- * @return true if the add was successful, false otherwise.
- */
- public boolean importCert(File file) throws Exception {
-
- BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
- CertificateFactory cf = CertificateFactory.getInstance("X509");
- X509Certificate cert = null;
-
- if (bis.available() >= 1) {
- try {
- cert = (X509Certificate)cf.generateCertificate(bis);
- } catch (ClassCastException cce) {
- throw new Exception("Input file is not an X509 Certificate");
- } catch (CertificateException ce) {
- throw new Exception("Input file is not an X509 Certificate");
- }
- }
+ /**
+ * Adds a trusted certificate to the user's keystore.
+ * @return true if the add was successful, false otherwise.
+ */
+ public boolean importCert(File file) throws Exception {
- return importCert((Certificate)cert);
+ BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
+ CertificateFactory cf = CertificateFactory.getInstance("X509");
+ X509Certificate cert = null;
+
+ if (bis.available() >= 1) {
+ try {
+ cert = (X509Certificate) cf.generateCertificate(bis);
+ } catch (ClassCastException cce) {
+ throw new Exception("Input file is not an X509 Certificate");
+ } catch (CertificateException ce) {
+ throw new Exception("Input file is not an X509 Certificate");
+ }
}
- /**
- * Adds a trusted certificate to the user's keystore.
- * @return true if the add was successful, false otherwise.
- */
- public boolean importCert(Certificate cert) throws Exception {
+ return importCert((Certificate) cert);
+ }
- String alias = usercerts.getCertificateAlias(cert);
+ /**
+ * Adds a trusted certificate to the user's keystore.
+ * @return true if the add was successful, false otherwise.
+ */
+ public boolean importCert(Certificate cert) throws Exception {
- if (alias != null) { //cert already exists
- return true;
- } else {
- String newAlias = getRandomAlias();
- //check to make sure this alias doesn't exist
- while (usercerts.getCertificate(newAlias) != null)
- newAlias = getRandomAlias();
- return addTrustedCert(newAlias, cert);
- }
- }
+ String alias = usercerts.getCertificateAlias(cert);
- /**
- * Generates a random alias for storing a trusted Certificate.
- */
- private String getRandomAlias() {
- Random r = new Random();
- String token = Long.toString(Math.abs(r.nextLong()), 36);
- return "trustedCert-" + token;
+ if (alias != null) { //cert already exists
+ return true;
+ } else {
+ String newAlias = getRandomAlias();
+ //check to make sure this alias doesn't exist
+ while (usercerts.getCertificate(newAlias) != null)
+ newAlias = getRandomAlias();
+ return addTrustedCert(newAlias, cert);
}
+ }
- /**
- * Prints all keystore entries.
+ /**
+ * Generates a random alias for storing a trusted Certificate.
*/
- private void doPrintEntries(PrintStream out) throws Exception {
+ private String getRandomAlias() {
+ Random r = new Random();
+ String token = Long.toString(Math.abs(r.nextLong()), 36);
+ return "trustedCert-" + token;
+ }
+
+ /**
+ * Prints all keystore entries.
+ */
+ private void doPrintEntries(PrintStream out) throws Exception {
- out.println("KeyStore type: " + usercerts.getType());
- out.println("KeyStore provider: " + usercerts.getProvider().toString());
- out.println();
+ out.println("KeyStore type: " + usercerts.getType());
+ out.println("KeyStore provider: " + usercerts.getProvider().toString());
+ out.println();
- for (Enumeration<String> e = usercerts.aliases(); e.hasMoreElements();) {
- String alias = e.nextElement();
- doPrintEntry(alias, out, false);
- }
+ for (Enumeration<String> e = usercerts.aliases(); e.hasMoreElements();) {
+ String alias = e.nextElement();
+ doPrintEntry(alias, out, false);
}
+ }
/**
* Prints a single keystore entry.
*/
- private void doPrintEntry(String alias, PrintStream out,
+ private void doPrintEntry(String alias, PrintStream out,
boolean printWarning) throws Exception {
- if (usercerts.containsAlias(alias) == false) {
- throw new Exception("Alias does not exist");
- }
+ if (usercerts.containsAlias(alias) == false) {
+ throw new Exception("Alias does not exist");
+ }
- if (usercerts.entryInstanceOf(alias,
+ if (usercerts.entryInstanceOf(alias,
KeyStore.TrustedCertificateEntry.class)) {
- Certificate cert = usercerts.getCertificate(alias);
+ Certificate cert = usercerts.getCertificate(alias);
- out.println("Alias: " + alias);
- out.println("Date Created: " + usercerts.getCreationDate(alias));
- out.println("Subject: " + SecurityUtil.getCN(((X509Certificate)usercerts
+ out.println("Alias: " + alias);
+ out.println("Date Created: " + usercerts.getCreationDate(alias));
+ out.println("Subject: " + SecurityUtil.getCN(((X509Certificate) usercerts
.getCertificate(alias)).getSubjectX500Principal().getName()));
- out.println("Certificate fingerprint (MD5): "
+ out.println("Certificate fingerprint (MD5): "
+ getCertFingerPrint("MD5", cert));
- out.println();
- }
+ out.println();
}
+ }
/**
* Gets the requested finger print of the certificate.
*/
- private String getCertFingerPrint(String mdAlg, Certificate cert)
+ private String getCertFingerPrint(String mdAlg, Certificate cert)
throws Exception {
- byte[] encCertInfo = cert.getEncoded();
- MessageDigest md = MessageDigest.getInstance(mdAlg);
- byte[] digest = md.digest(encCertInfo);
- return toHexString(digest);
- }
+ byte[] encCertInfo = cert.getEncoded();
+ MessageDigest md = MessageDigest.getInstance(mdAlg);
+ byte[] digest = md.digest(encCertInfo);
+ return toHexString(digest);
+ }
/**
* Converts a byte to hex digit and writes to the supplied buffer
@@ -204,31 +204,31 @@ public class KeyTool {
StringBuffer buf = new StringBuffer();
int len = block.length;
for (int i = 0; i < len; i++) {
- byte2hex(block[i], buf);
- if (i < len-1) {
- buf.append(":");
- }
+ byte2hex(block[i], buf);
+ if (i < len - 1) {
+ buf.append(":");
+ }
}
return buf.toString();
}
- /**
- * Adds a certificate to the keystore, and writes new keystore to disk.
- */
+ /**
+ * Adds a certificate to the keystore, and writes new keystore to disk.
+ */
private boolean addTrustedCert(String alias, Certificate cert)
- throws Exception {
+ throws Exception {
- if (isSelfSigned((X509Certificate)cert)) {
- //will throw exception if this fails
- cert.verify(cert.getPublicKey());
- }
+ if (isSelfSigned((X509Certificate) cert)) {
+ //will throw exception if this fails
+ cert.verify(cert.getPublicKey());
+ }
if (noprompt) {
- usercerts.setCertificateEntry(alias, cert);
- fos = new FileOutputStream(fullCertPath);
- usercerts.store(fos, password);
- fos.close();
- return true;
+ usercerts.setCertificateEntry(alias, cert);
+ fos = new FileOutputStream(fullCertPath);
+ usercerts.store(fos, password);
+ fos.close();
+ return true;
}
return false;
@@ -239,12 +239,12 @@ public class KeyTool {
*/
public boolean isTrusted(Certificate cert) throws Exception {
if (cert != null) {
- if (usercerts.getCertificateAlias(cert) != null) {
- return true; // found in own keystore
- }
- return false;
+ if (usercerts.getCertificateAlias(cert) != null) {
+ return true; // found in own keystore
+ }
+ return false;
} else {
- return false;
+ return false;
}
}
@@ -265,23 +265,23 @@ public class KeyTool {
public boolean checkCacertsForCertificate(Certificate c) throws Exception {
if (c != null) {
- String alias = null;
+ String alias = null;
- //first try jdk cacerts.
- if (cacerts != null) {
- alias = cacerts.getCertificateAlias(c);
+ //first try jdk cacerts.
+ if (cacerts != null) {
+ alias = cacerts.getCertificateAlias(c);
- //if we can't find it here, try the system certs.
- if (alias == null && systemcerts != null)
- alias = systemcerts.getCertificateAlias(c);
- }
- //otherwise try the system certs if you can't use the jdk certs.
- else if (systemcerts != null)
- alias = systemcerts.getCertificateAlias(c);
+ //if we can't find it here, try the system certs.
+ if (alias == null && systemcerts != null)
+ alias = systemcerts.getCertificateAlias(c);
+ }
+ //otherwise try the system certs if you can't use the jdk certs.
+ else if (systemcerts != null)
+ alias = systemcerts.getCertificateAlias(c);
- return (alias != null);
+ return (alias != null);
} else
- return false;
+ return false;
}
/**
@@ -294,8 +294,7 @@ public class KeyTool {
*/
public boolean establishCertChain(Certificate userCert,
Certificate certToVerify)
- throws Exception
- {
+ throws Exception {
if (userCert != null) {
// Make sure that the public key of the certificate reply matches
// the original public key in the keystore
@@ -325,8 +324,8 @@ public class KeyTool {
keystorecerts2Hashtable(usercerts, certs);
}
if (trustcacerts) { //if we're trusting the cacerts
- KeyStore caks = SecurityUtil.getCacertsKeyStore();
- if (caks!=null && caks.size()>0) {
+ KeyStore caks = SecurityUtil.getCacertsKeyStore();
+ if (caks != null && caks.size() > 0) {
if (certs == null) {
certs = new Hashtable<Principal, Vector<Certificate>>(11);
}
@@ -336,13 +335,13 @@ public class KeyTool {
// start building chain
Vector<Certificate> chain = new Vector<Certificate>(2);
- if (buildChain((X509Certificate)certToVerify, chain, certs)) {
+ if (buildChain((X509Certificate) certToVerify, chain, certs)) {
Certificate[] newChain = new Certificate[chain.size()];
// buildChain() returns chain with self-signed root-cert first and
// user-cert last, so we need to invert the chain before we store
// it
- int j=0;
- for (int i=chain.size()-1; i>=0; i--) {
+ int j = 0;
+ for (int i = chain.size() - 1; i >= 0; i--) {
newChain[j] = chain.elementAt(i);
j++;
}
@@ -360,14 +359,13 @@ public class KeyTool {
*/
private void keystorecerts2Hashtable(KeyStore ks,
Hashtable<Principal, Vector<Certificate>> hash)
- throws Exception {
+ throws Exception {
- for (Enumeration<String> aliases = ks.aliases();
- aliases.hasMoreElements(); ) {
+ for (Enumeration<String> aliases = ks.aliases(); aliases.hasMoreElements();) {
String alias = aliases.nextElement();
Certificate cert = ks.getCertificate(alias);
if (cert != null) {
- Principal subjectDN = ((X509Certificate)cert).getSubjectDN();
+ Principal subjectDN = ((X509Certificate) cert).getSubjectDN();
Vector<Certificate> vec = hash.get(subjectDN);
if (vec == null) {
vec = new Vector<Certificate>();
@@ -412,10 +410,8 @@ public class KeyTool {
// Try out each certificate in the vector, until we find one
// whose public key verifies the signature of the certificate
// in question.
- for (Enumeration<Certificate> issuerCerts = vec.elements();
- issuerCerts.hasMoreElements(); ) {
- X509Certificate issuerCert
- = (X509Certificate)issuerCerts.nextElement();
+ for (Enumeration<Certificate> issuerCerts = vec.elements(); issuerCerts.hasMoreElements();) {
+ X509Certificate issuerCert = (X509Certificate) issuerCerts.nextElement();
PublicKey issuerPubKey = issuerCert.getPublicKey();
try {
certToVerify.verify(issuerPubKey);
@@ -430,8 +426,8 @@ public class KeyTool {
return false;
}
- public static void main(String[] args) throws Exception {
- KeyTool kt = new KeyTool();
- kt.doPrintEntries(System.out);
- }
+ public static void main(String[] args) throws Exception {
+ KeyTool kt = new KeyTool();
+ kt.doPrintEntries(System.out);
+ }
}
diff --git a/netx/net/sourceforge/jnlp/util/FileUtils.java b/netx/net/sourceforge/jnlp/util/FileUtils.java
index b006424..51081ed 100644
--- a/netx/net/sourceforge/jnlp/util/FileUtils.java
+++ b/netx/net/sourceforge/jnlp/util/FileUtils.java
@@ -192,7 +192,7 @@ public final class FileUtils {
return path.substring(path.length() - visibleChars);
}
- int affixLength = (visibleChars - OMITTED_LENGTH)/2;
+ int affixLength = (visibleChars - OMITTED_LENGTH) / 2;
String prefix = path.substring(0, affixLength);
String suffix = path.substring(path.length() - affixLength);
diff --git a/netx/net/sourceforge/jnlp/util/PropertiesFile.java b/netx/net/sourceforge/jnlp/util/PropertiesFile.java
index 80a7ec2..6cdfd59 100644
--- a/netx/net/sourceforge/jnlp/util/PropertiesFile.java
+++ b/netx/net/sourceforge/jnlp/util/PropertiesFile.java
@@ -14,7 +14,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.util;
import java.io.*;
@@ -45,7 +44,6 @@ public class PropertiesFile extends Properties {
/** lazy loaded on getProperty */
boolean loaded = false;
-
/**
* Create a properties object backed by the specified file.
*
@@ -121,8 +119,7 @@ public class PropertiesFile extends Properties {
InputStream s = new FileInputStream(file);
load(s);
- }
- catch (IOException ex) {
+ } catch (IOException ex) {
// eat
}
}
@@ -137,8 +134,7 @@ public class PropertiesFile extends Properties {
try {
OutputStream s = new FileOutputStream(file);
store(s, header);
- }
- catch (IOException ex) {
+ } catch (IOException ex) {
// eat
}
}
diff --git a/netx/net/sourceforge/jnlp/util/Reflect.java b/netx/net/sourceforge/jnlp/util/Reflect.java
index 2b1301c..5f40629 100644
--- a/netx/net/sourceforge/jnlp/util/Reflect.java
+++ b/netx/net/sourceforge/jnlp/util/Reflect.java
@@ -19,7 +19,6 @@ package net.sourceforge.jnlp.util;
import java.util.*;
import java.lang.reflect.*;
-
/**
* Provides simply, convenient methods to invoke methods by
* name. This class is used to consolidate reflection needed to
@@ -48,7 +47,6 @@ public class Reflect {
private static Object zero[] = new Object[0];
-
/**
* Create a new Reflect instance.
*/
@@ -84,8 +82,7 @@ public class Reflect {
m.setAccessible(accessible);
return m.invoke(null, args);
- }
- catch (Exception ex) { // eat
+ } catch (Exception ex) { // eat
return null;
}
}
@@ -110,8 +107,7 @@ public class Reflect {
m.setAccessible(accessible);
return m.invoke(object, args);
- }
- catch (Exception ex) { // eat
+ } catch (Exception ex) { // eat
ex.printStackTrace();
return null;
}
@@ -126,7 +122,7 @@ public class Reflect {
for (Class c = type; c != null; c = c.getSuperclass()) {
Method methods[] = c.getMethods();
- for (int i=0; i < methods.length; i++) {
+ for (int i = 0; i < methods.length; i++) {
if (methods[i].getName().equals(method)) {
Class parameters[] = methods[i].getParameterTypes();
@@ -135,8 +131,7 @@ public class Reflect {
}
}
}
- }
- catch (Exception ex) { // eat
+ } catch (Exception ex) { // eat
ex.printStackTrace();
}
diff --git a/netx/net/sourceforge/jnlp/util/WeakList.java b/netx/net/sourceforge/jnlp/util/WeakList.java
index 85204b1..66dab40 100644
--- a/netx/net/sourceforge/jnlp/util/WeakList.java
+++ b/netx/net/sourceforge/jnlp/util/WeakList.java
@@ -14,13 +14,11 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
package net.sourceforge.jnlp.util;
import java.lang.ref.*;
import java.util.*;
-
/**
* This list stores objects automatically using weak references.
* Objects are added and removed from the list as normal, but may
@@ -37,7 +35,6 @@ public class WeakList<E> extends AbstractList<E> {
/* list of weak references */
private ArrayList<WeakReference<E>> refs = new ArrayList<WeakReference<E>>();
-
/**
* Create a weak random-access list.
*/
@@ -103,7 +100,7 @@ public class WeakList<E> extends AbstractList<E> {
public List<E> hardList() {
List<E> result = new ArrayList<E>();
- for (int i=0; i < size(); i++) {
+ for (int i = 0; i < size(); i++) {
E tmp = get(i);
if (tmp != null)
@@ -118,8 +115,8 @@ public class WeakList<E> extends AbstractList<E> {
* objects.
*/
public void trimToSize() {
- for (int i=size(); i-->0;)
- if (get(i)==null)
+ for (int i = size(); i-- > 0;)
+ if (get(i) == null)
remove(i);
}
diff --git a/netx/net/sourceforge/jnlp/util/XDesktopEntry.java b/netx/net/sourceforge/jnlp/util/XDesktopEntry.java
index eae4146..06dff37 100644
--- a/netx/net/sourceforge/jnlp/util/XDesktopEntry.java
+++ b/netx/net/sourceforge/jnlp/util/XDesktopEntry.java
@@ -75,7 +75,7 @@ public class XDesktopEntry {
String pathToJavaws = System.getProperty("java.home") + File.separator + "bin"
+ File.separator + "javaws";
String cacheDir = JNLPRuntime.getConfiguration()
- .getProperty(DeploymentConfiguration.KEY_USER_CACHE_DIR);
+ .getProperty(DeploymentConfiguration.KEY_USER_CACHE_DIR);
File cacheFile = CacheUtil.urlToPath(file.getSourceLocation(), cacheDir);
String fileContents = "[Desktop Entry]\n";
diff --git a/netx/net/sourceforge/nanoxml/XMLElement.java b/netx/net/sourceforge/nanoxml/XMLElement.java
index f8fd369..2284895 100644
--- a/netx/net/sourceforge/nanoxml/XMLElement.java
+++ b/netx/net/sourceforge/nanoxml/XMLElement.java
@@ -35,7 +35,6 @@ import java.util.*;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
-
/**
* XMLElement is a representation of an XML object. The object is able to parse
* XML code.
@@ -94,8 +93,7 @@ import net.sourceforge.jnlp.runtime.JNLPRuntime;
* &lt;<A href="mailto:[email protected]">[email protected]</A>&gt;
* @version $Name: $, $Revision: 1.2 $
*/
-public class XMLElement
-{
+public class XMLElement {
/**
* The attributes given to the element.
@@ -106,8 +104,7 @@ public class XMLElement
* <li>The keys and the values are strings.
* </ul></dd></dl>
*/
- private Hashtable<String,Object> attributes;
-
+ private Hashtable<String, Object> attributes;
/**
* Child elements of the element.
@@ -121,7 +118,6 @@ public class XMLElement
*/
private Vector<XMLElement> children;
-
/**
* The name of the element.
*
@@ -135,7 +131,6 @@ public class XMLElement
*/
private String name;
-
/**
* The #PCDATA content of the object.
*
@@ -147,7 +142,6 @@ public class XMLElement
*/
private String contents;
-
/**
* Conversion table for &amp;...; entities. The keys are the entity names
* without the &amp; and ; delimiters.
@@ -162,8 +156,7 @@ public class XMLElement
* <li>The values are char arrays
* </ul></dd></dl>
*/
- private Hashtable<String,char[]> entities;
-
+ private Hashtable<String, char[]> entities;
/**
* The line number where the element starts.
@@ -174,21 +167,18 @@ public class XMLElement
*/
private int lineNr;
-
/**
* <code>true</code> if the case of the element and attribute names
* are case insensitive.
*/
private boolean ignoreCase;
-
/**
* <code>true</code> if the leading and trailing whitespace of #PCDATA
* sections have to be ignored.
*/
private boolean ignoreWhitespace;
-
/**
* Character read too much.
* This character provides push-back functionality to the input reader
@@ -212,7 +202,6 @@ public class XMLElement
*/
private Reader reader;
-
/**
* The current line number in the source content.
*
@@ -222,7 +211,6 @@ public class XMLElement
*/
private int parserLineNr;
-
/**
* Creates and initializes a new XML element.
* Calling the construction is equivalent to:
@@ -240,12 +228,10 @@ public class XMLElement
* </ul></dd></dl>
*
*/
- public XMLElement()
- {
- this(new Hashtable<String,char[]>(), false, true, true);
+ public XMLElement() {
+ this(new Hashtable<String, char[]>(), false, true, true);
}
-
/**
* Creates and initializes a new XML element.
* <P>
@@ -284,16 +270,15 @@ public class XMLElement
* </ul></dd></dl><dl>
*
*/
- protected XMLElement(Hashtable<String,char[]> entities,
- boolean skipLeadingWhitespace,
- boolean fillBasicConversionTable,
- boolean ignoreCase)
- {
+ protected XMLElement(Hashtable<String, char[]> entities,
+ boolean skipLeadingWhitespace,
+ boolean fillBasicConversionTable,
+ boolean ignoreCase) {
this.ignoreWhitespace = skipLeadingWhitespace;
this.ignoreCase = ignoreCase;
this.name = null;
this.contents = "";
- this.attributes = new Hashtable<String,Object>();
+ this.attributes = new Hashtable<String, Object>();
this.children = new Vector<XMLElement>();
this.entities = entities;
this.lineNr = 0;
@@ -314,7 +299,6 @@ public class XMLElement
}
}
-
/**
* Adds a child element.
*
@@ -334,12 +318,10 @@ public class XMLElement
* </ul></dd></dl><dl>
*
*/
- public void addChild(XMLElement child)
- {
+ public void addChild(XMLElement child) {
this.children.addElement(child);
}
-
/**
* Adds or modifies an attribute.
*
@@ -362,15 +344,13 @@ public class XMLElement
*
*/
public void setAttribute(String name,
- Object value)
- {
+ Object value) {
if (this.ignoreCase) {
name = name.toUpperCase();
}
this.attributes.put(name, value.toString());
}
-
/**
* Returns the number of child elements of the element.
*
@@ -379,12 +359,10 @@ public class XMLElement
* </ul></dd></dl>
*
*/
- public int countChildren()
- {
+ public int countChildren() {
return this.children.size();
}
-
/**
* Enumerates the attribute names.
*
@@ -393,12 +371,10 @@ public class XMLElement
* </ul></dd></dl>
*
*/
- public Enumeration enumerateAttributeNames()
- {
+ public Enumeration enumerateAttributeNames() {
return this.attributes.keys();
}
-
/**
* Enumerates the child elements.
*
@@ -407,23 +383,19 @@ public class XMLElement
* </ul></dd></dl>
*
*/
- public Enumeration enumerateChildren()
- {
+ public Enumeration enumerateChildren() {
return this.children.elements();
}
-
/**
* Returns the PCDATA content of the object. If there is no such content,
* <CODE>null</CODE> is returned.
*
*/
- public String getContent()
- {
+ public String getContent() {
return this.contents;
}
-
/**
* Returns the line nr in the source data on which the element is found.
* This method returns <code>0</code> there is no associated source data.
@@ -432,12 +404,10 @@ public class XMLElement
* <ul><li><code>result >= 0</code>
* </ul></dd></dl>
*/
- public int getLineNr()
- {
+ public int getLineNr() {
return this.lineNr;
}
-
/**
* Returns an attribute of the element.
* If the attribute doesn't exist, <code>null</code> is returned.
@@ -450,8 +420,7 @@ public class XMLElement
* </ul></dd></dl><dl>
*
*/
- public Object getAttribute(String name)
- {
+ public Object getAttribute(String name) {
if (this.ignoreCase) {
name = name.toUpperCase();
}
@@ -459,17 +428,14 @@ public class XMLElement
return value;
}
-
/**
* Returns the name of the element.
*
*/
- public String getName()
- {
+ public String getName() {
return this.name;
}
-
/**
* Reads one XML element from a java.io.Reader and parses it.
*
@@ -494,12 +460,10 @@ public class XMLElement
* If an error occured while parsing the read data.
*/
public void parseFromReader(Reader reader)
- throws IOException, XMLParseException
- {
- this.parseFromReader(reader, /*startingLineNr*/ 1);
+ throws IOException, XMLParseException {
+ this.parseFromReader(reader, /*startingLineNr*/1);
}
-
/**
* Reads one XML element from a java.io.Reader and parses it.
*
@@ -526,9 +490,8 @@ public class XMLElement
* If an error occured while parsing the read data.
*/
public void parseFromReader(Reader reader,
- int startingLineNr)
- throws IOException, XMLParseException
- {
+ int startingLineNr)
+ throws IOException, XMLParseException {
this.charReadTooMuch = '\0';
this.reader = reader;
this.parserLineNr = startingLineNr;
@@ -552,33 +515,28 @@ public class XMLElement
}
}
-
/**
* Creates a new similar XML element.
* <P>
* You should override this method when subclassing XMLElement.
*/
- protected XMLElement createAnotherElement()
- {
+ protected XMLElement createAnotherElement() {
return new XMLElement(this.entities,
this.ignoreWhitespace,
false,
this.ignoreCase);
}
-
/**
* Changes the content string.
*
* @param content
* The new content string.
*/
- public void setContent(String content)
- {
+ public void setContent(String content) {
this.contents = content;
}
-
/**
* Changes the name of the element.
*
@@ -591,12 +549,10 @@ public class XMLElement
* </ul></dd></dl>
*
*/
- public void setName(String name)
- {
+ public void setName(String name) {
this.name = name;
}
-
/**
* Scans an identifier from the current reader.
* The scanned identifier is appended to <code>result</code>.
@@ -616,13 +572,12 @@ public class XMLElement
* </ul></dd></dl><dl>
*/
protected void scanIdentifier(StringBuffer result)
- throws IOException
- {
+ throws IOException {
for (;;) {
char ch = this.readChar();
if (((ch < 'A') || (ch > 'Z')) && ((ch < 'a') || (ch > 'z'))
- && ((ch < '0') || (ch > '9')) && (ch != '_') && (ch != '.')
- && (ch != ':') && (ch != '-') && (ch <= '\u007E')) {
+ && ((ch < '0') || (ch > '9')) && (ch != '_') && (ch != '.')
+ && (ch != ':') && (ch != '-') && (ch <= '\u007E')) {
this.unreadChar(ch);
return;
}
@@ -630,15 +585,13 @@ public class XMLElement
}
}
-
/**
* This method scans an identifier from the current reader.
*
* @return the next character following the whitespace.
*/
protected char scanWhitespace()
- throws IOException
- {
+ throws IOException {
for (;;) {
char ch = this.readChar();
switch (ch) {
@@ -653,7 +606,6 @@ public class XMLElement
}
}
-
/**
* This method scans an identifier from the current reader.
* The scanned whitespace is appended to <code>result</code>.
@@ -665,8 +617,7 @@ public class XMLElement
* </ul></dd></dl>
*/
protected char scanWhitespace(StringBuffer result)
- throws IOException
- {
+ throws IOException {
for (;;) {
char ch = this.readChar();
switch (ch) {
@@ -683,7 +634,6 @@ public class XMLElement
}
}
-
/**
* This method scans a delimited string from the current reader.
* The scanned string without delimiters is appended to
@@ -695,8 +645,7 @@ public class XMLElement
* </ul></dd></dl>
*/
protected void scanString(StringBuffer string)
- throws IOException
- {
+ throws IOException {
char delimiter = this.readChar();
if ((delimiter != '\'') && (delimiter != '"')) {
throw this.expectedInput("' or \"");
@@ -713,7 +662,6 @@ public class XMLElement
}
}
-
/**
* Scans a #PCDATA element. CDATA sections and entities are resolved.
* The next &lt; char is skipped.
@@ -724,8 +672,7 @@ public class XMLElement
* </ul></dd></dl>
*/
protected void scanPCData(StringBuffer data)
- throws IOException
- {
+ throws IOException {
for (;;) {
char ch = this.readChar();
if (ch == '<') {
@@ -744,7 +691,6 @@ public class XMLElement
}
}
-
/**
* Scans a special tag and if the tag is a CDATA section, append its
* content to <code>buf</code>.
@@ -755,14 +701,13 @@ public class XMLElement
* </ul></dd></dl>
*/
protected boolean checkCDATA(StringBuffer buf)
- throws IOException
- {
+ throws IOException {
char ch = this.readChar();
if (ch != '[') {
this.unreadChar(ch);
this.skipSpecialTag(0);
return false;
- } else if (! this.checkLiteral("CDATA[")) {
+ } else if (!this.checkLiteral("CDATA[")) {
this.skipSpecialTag(1); // one [ has already been read
return false;
} else {
@@ -802,7 +747,6 @@ public class XMLElement
}
}
-
/**
* Skips a comment.
*
@@ -811,8 +755,7 @@ public class XMLElement
* </ul></dd></dl>
*/
protected void skipComment()
- throws IOException
- {
+ throws IOException {
int dashesToRead = 2;
while (dashesToRead > 0) {
char ch = this.readChar();
@@ -841,7 +784,6 @@ public class XMLElement
*/
}
-
/**
* Skips a special tag or comment.
*
@@ -854,8 +796,7 @@ public class XMLElement
* </ul></dd></dl>
*/
protected void skipSpecialTag(int bracketLevel)
- throws IOException
- {
+ throws IOException {
int tagLevel = 1; // <
char stringDelimiter = '\0';
if (bracketLevel == 0) {
@@ -899,7 +840,6 @@ public class XMLElement
}
}
-
/**
* Scans the data for literal text.
* Scanning stops when a character does not match or after the complete
@@ -912,8 +852,7 @@ public class XMLElement
* </ul></dd></dl>
*/
protected boolean checkLiteral(String literal)
- throws IOException
- {
+ throws IOException {
int length = literal.length();
for (int i = 0; i < length; i += 1) {
if (this.readChar() != literal.charAt(i)) {
@@ -923,13 +862,11 @@ public class XMLElement
return true;
}
-
/**
* Reads a character from a reader.
*/
protected char readChar()
- throws IOException
- {
+ throws IOException {
if (this.charReadTooMuch != '\0') {
char ch = this.charReadTooMuch;
this.charReadTooMuch = '\0';
@@ -947,7 +884,6 @@ public class XMLElement
}
}
-
/**
* Scans an XML element.
*
@@ -959,8 +895,7 @@ public class XMLElement
* </ul></dd></dl>
*/
protected void scanElement(XMLElement elt)
- throws IOException
- {
+ throws IOException {
StringBuffer buf = new StringBuffer();
this.scanIdentifier(buf);
String name = buf.toString();
@@ -1051,7 +986,7 @@ public class XMLElement
throw this.expectedInput("/");
}
this.unreadChar(this.scanWhitespace());
- if (! this.checkLiteral(name)) {
+ if (!this.checkLiteral(name)) {
throw this.expectedInput(name);
}
if (this.scanWhitespace() != '>') {
@@ -1059,7 +994,6 @@ public class XMLElement
}
}
-
/**
* Resolves an entity. The name of the entity is read from the reader.
* The value of the entity is appended to <code>buf</code>.
@@ -1072,8 +1006,7 @@ public class XMLElement
* </ul></dd></dl>
*/
protected void resolveEntity(StringBuffer buf)
- throws IOException
- {
+ throws IOException {
char ch = '\0';
StringBuffer keyBuf = new StringBuffer();
for (;;) {
@@ -1104,7 +1037,6 @@ public class XMLElement
}
}
-
/**
* Pushes a character back to the read-back buffer.
*
@@ -1115,12 +1047,10 @@ public class XMLElement
* <li><code>ch != '\0'</code>
* </ul></dd></dl>
*/
- protected void unreadChar(char ch)
- {
+ protected void unreadChar(char ch) {
this.charReadTooMuch = ch;
}
-
/**
* Creates a parse exception for when an invalid valueset is given to
* a method.
@@ -1131,13 +1061,11 @@ public class XMLElement
* <ul><li><code>name != null</code>
* </ul></dd></dl>
*/
- protected XMLParseException invalidValueSet(String name)
- {
+ protected XMLParseException invalidValueSet(String name) {
String msg = "Invalid value set (entity name = \"" + name + "\")";
return new XMLParseException(this.getName(), this.parserLineNr, msg);
}
-
/**
* Creates a parse exception for when an invalid value is given to a
* method.
@@ -1151,25 +1079,21 @@ public class XMLElement
* </ul></dd></dl>
*/
protected XMLParseException invalidValue(String name,
- String value)
- {
+ String value) {
String msg = "Attribute \"" + name + "\" does not contain a valid "
+ "value (\"" + value + "\")";
return new XMLParseException(this.getName(), this.parserLineNr, msg);
}
-
/**
* Creates a parse exception for when the end of the data input has been
* reached.
*/
- protected XMLParseException unexpectedEndOfData()
- {
+ protected XMLParseException unexpectedEndOfData() {
String msg = "Unexpected end of data reached";
return new XMLParseException(this.getName(), this.parserLineNr, msg);
}
-
/**
* Creates a parse exception for when a syntax error occured.
*
@@ -1180,13 +1104,11 @@ public class XMLElement
* <li><code>context.length() &gt; 0</code>
* </ul></dd></dl>
*/
- protected XMLParseException syntaxError(String context)
- {
+ protected XMLParseException syntaxError(String context) {
String msg = "Syntax error while parsing " + context;
return new XMLParseException(this.getName(), this.parserLineNr, msg);
}
-
/**
* Creates a parse exception for when the next character read is not
* the character that was expected.
@@ -1199,8 +1121,7 @@ public class XMLElement
* <li><code>charSet.length() &gt; 0</code>
* </ul></dd></dl>
*/
- protected XMLParseException expectedInput(String charSet)
- {
+ protected XMLParseException expectedInput(String charSet) {
String msg = "Expected: " + charSet;
return new XMLParseException(this.getName(), this.parserLineNr, msg);
}
@@ -1217,9 +1138,8 @@ public class XMLElement
* <li><code>charSet.length() &gt; 0</code>
* </ul></dd></dl>
*/
- protected XMLParseException expectedInput(String charSet, char ch)
- {
- String msg = "Expected: '" + charSet +"'" + " but got: '" + ch + "'";
+ protected XMLParseException expectedInput(String charSet, char ch) {
+ String msg = "Expected: '" + charSet + "'" + " but got: '" + ch + "'";
return new XMLParseException(this.getName(), this.parserLineNr, msg);
}
@@ -1233,8 +1153,7 @@ public class XMLElement
* <li><code>name.length() &gt; 0</code>
* </ul></dd></dl>
*/
- protected XMLParseException unknownEntity(String name)
- {
+ protected XMLParseException unknownEntity(String name) {
String msg = "Unknown or invalid entity: &" + name + ";";
return new XMLParseException(this.getName(), this.parserLineNr, msg);
}
@@ -1257,7 +1176,7 @@ public class XMLElement
int newline = 2;
char prev = ' ';
- while(true) {
+ while (true) {
char ch;
if (this.sanitizeCharReadTooMuch != '\0') {
ch = this.sanitizeCharReadTooMuch;
diff --git a/netx/net/sourceforge/nanoxml/XMLParseException.java b/netx/net/sourceforge/nanoxml/XMLParseException.java
index dfbb637..329dea4 100644
--- a/netx/net/sourceforge/nanoxml/XMLParseException.java
+++ b/netx/net/sourceforge/nanoxml/XMLParseException.java
@@ -26,10 +26,8 @@
* 3. This notice may not be removed or altered from any source distribution.
*****************************************************************************/
-
package net.sourceforge.nanoxml;
-
/**
* An XMLParseException is thrown when an error occures while parsing an XML
* string.
@@ -43,15 +41,13 @@ package net.sourceforge.nanoxml;
* @version $Name: $, $Revision: 1.1 $
*/
public class XMLParseException
- extends RuntimeException
-{
+ extends RuntimeException {
/**
* Indicates that no line number has been associated with this exception.
*/
public static final int NO_LINE = -1;
-
/**
* The line number in the source code where the error occurred, or
* <code>NO_LINE</code> if the line number is unknown.
@@ -62,7 +58,6 @@ public class XMLParseException
*/
private int lineNr;
-
/**
* Creates an exception.
*
@@ -78,16 +73,14 @@ public class XMLParseException
* </ul></dd></dl><dl>
*/
public XMLParseException(String name,
- String message)
- {
+ String message) {
super("XML Parse Exception during parsing of "
- + ((name == null) ? "the XML definition"
+ + ((name == null) ? "the XML definition"
: ("a " + name + " element"))
- + ": " + message);
+ + ": " + message);
this.lineNr = XMLParseException.NO_LINE;
}
-
/**
* Creates an exception.
*
@@ -105,25 +98,22 @@ public class XMLParseException
* </ul></dd></dl><dl>
*/
public XMLParseException(String name,
- int lineNr,
- String message)
- {
+ int lineNr,
+ String message) {
super("XML Parse Exception during parsing of "
- + ((name == null) ? "the XML definition"
+ + ((name == null) ? "the XML definition"
: ("a " + name + " element"))
- + " at line " + lineNr + ": " + message);
+ + " at line " + lineNr + ": " + message);
this.lineNr = lineNr;
}
-
/**
* Where the error occurred, or <code>NO_LINE</code> if the line number is
* unknown.
*
* @see net.sourceforge.nanoxml.XMLParseException#NO_LINE
*/
- public int getLineNr()
- {
+ public int getLineNr() {
return this.lineNr;
}
diff --git a/plugin/icedteanp/java/netscape/javascript/JSException.java b/plugin/icedteanp/java/netscape/javascript/JSException.java
index 5fbb750..35d72a7 100644
--- a/plugin/icedteanp/java/netscape/javascript/JSException.java
+++ b/plugin/icedteanp/java/netscape/javascript/JSException.java
@@ -44,8 +44,7 @@ package netscape.javascript;
* returns an error.
*/
-public
-class JSException extends RuntimeException {
+public class JSException extends RuntimeException {
public static final int EXCEPTION_TYPE_EMPTY = -1;
public static final int EXCEPTION_TYPE_VOID = 0;
public static final int EXCEPTION_TYPE_OBJECT = 1;
@@ -140,4 +139,3 @@ class JSException extends RuntimeException {
}
}
-
diff --git a/plugin/icedteanp/java/netscape/javascript/JSObject.java b/plugin/icedteanp/java/netscape/javascript/JSObject.java
index 31cd973..293f2be 100644
--- a/plugin/icedteanp/java/netscape/javascript/JSObject.java
+++ b/plugin/icedteanp/java/netscape/javascript/JSObject.java
@@ -55,8 +55,6 @@ import java.security.BasicPermission;
import sun.applet.PluginAppletViewer;
import sun.applet.PluginDebug;
-
-
/**
* JSObject allows Java to manipulate objects that are
* defined in JavaScript.
@@ -90,17 +88,17 @@ import sun.applet.PluginDebug;
*/
public final class JSObject {
/* the internal object data */
- private long internal;
+ private long internal;
/**
* initialize
*/
private static void initClass() {
- PluginDebug.debug ("JSObject.initClass");
+ PluginDebug.debug("JSObject.initClass");
}
static {
- PluginDebug.debug ("JSObject INITIALIZER");
+ PluginDebug.debug("JSObject INITIALIZER");
}
/**
@@ -131,20 +129,21 @@ public final class JSObject {
// Although this check is inefficient, it should happen only once
// during applet init, so we look the other way
- StackTraceElement[] stack = Thread.currentThread().getStackTrace();
+ StackTraceElement[] stack = Thread.currentThread().getStackTrace();
boolean mayProceed = false;
- for (int i=0; i < stack.length; i++) {
+ for (int i = 0; i < stack.length; i++) {
if (stack[i].getClassName().equals("netscape.javascript.JSObject") &&
- stack[i].getMethodName().equals("getWindow")) {
+ stack[i].getMethodName().equals("getWindow")) {
mayProceed = true;
}
}
- if (!mayProceed) throw ace;
+ if (!mayProceed)
+ throw ace;
}
- PluginDebug.debug ("JSObject long CONSTRUCTOR");
+ PluginDebug.debug("JSObject long CONSTRUCTOR");
internal = jsobj_addr;
}
@@ -152,36 +151,31 @@ public final class JSObject {
* Retrieves a named member of a JavaScript object.
* Equivalent to "this.<i>name</i>" in JavaScript.
*/
- public Object getMember(String name)
- {
- PluginDebug.debug ("JSObject.getMember " + name);
+ public Object getMember(String name) {
+ PluginDebug.debug("JSObject.getMember " + name);
Object o = PluginAppletViewer.getMember(internal, name);
- PluginDebug.debug ("JSObject.getMember GOT " + o);
+ PluginDebug.debug("JSObject.getMember GOT " + o);
return o;
}
-
/**
* Retrieves an indexed member of a JavaScript object.
* Equivalent to "this[<i>index</i>]" in JavaScript.
*/
// public Object getMember(int index) { return getSlot(index); }
- public Object getSlot(int index)
- {
- PluginDebug.debug ("JSObject.getSlot " + index);
+ public Object getSlot(int index) {
+ PluginDebug.debug("JSObject.getSlot " + index);
return PluginAppletViewer.getSlot(internal, index);
}
-
/**
* Sets a named member of a JavaScript object.
* Equivalent to "this.<i>name</i> = <i>value</i>" in JavaScript.
*/
- public void setMember(String name, Object value)
- {
- PluginDebug.debug ("JSObject.setMember " + name + " " + value);
+ public void setMember(String name, Object value) {
+ PluginDebug.debug("JSObject.setMember " + name + " " + value);
PluginAppletViewer.setMember(internal, name, value);
}
@@ -193,103 +187,87 @@ public final class JSObject {
// public void setMember(int index, Object value) {
// setSlot(index, value);
// }
- public void setSlot(int index, Object value)
- {
- PluginDebug.debug ("JSObject.setSlot " + index + " " + value);
+ public void setSlot(int index, Object value) {
+ PluginDebug.debug("JSObject.setSlot " + index + " " + value);
PluginAppletViewer.setSlot(internal, index, value);
}
-
// TODO: toString, finalize.
/**
* Removes a named member of a JavaScript object.
*/
- public void removeMember(String name)
- {
- PluginDebug.debug ("JSObject.removeMember " + name);
+ public void removeMember(String name) {
+ PluginDebug.debug("JSObject.removeMember " + name);
PluginAppletViewer.removeMember(internal, name);
}
-
/**
* Calls a JavaScript method.
* Equivalent to "this.<i>methodName</i>(<i>args</i>[0], <i>args</i>[1], ...)" in JavaScript.
*/
- public Object call(String methodName, Object args[])
- {
+ public Object call(String methodName, Object args[]) {
if (args == null)
- args = new Object[0];
+ args = new Object[0];
- PluginDebug.debug ("JSObject.call " + methodName);
+ PluginDebug.debug("JSObject.call " + methodName);
for (int i = 0; i < args.length; i++)
- PluginDebug.debug (" " + args[i]);
+ PluginDebug.debug(" " + args[i]);
PluginDebug.debug("");
return PluginAppletViewer.call(internal, methodName, args);
}
-
/**
* Evaluates a JavaScript expression. The expression is a string
* of JavaScript source code which will be evaluated in the context
* given by "this".
*/
- public Object eval(String s)
- {
+ public Object eval(String s) {
PluginDebug.debug("JSObject.eval " + s);
return PluginAppletViewer.eval(internal, s);
}
-
/**
* Converts a JSObject to a String.
*/
- public String toString()
- {
+ public String toString() {
PluginDebug.debug("JSObject.toString");
return PluginAppletViewer.javascriptToString(internal);
}
-
// should use some sort of identifier rather than String
// is "property" the right word?
// native String[] listProperties();
-
/**
* get a JSObject for the window containing the given applet
*/
- public static JSObject getWindow(Applet applet)
- {
+ public static JSObject getWindow(Applet applet) {
PluginDebug.debug("JSObject.getWindow");
// FIXME: handle long case as well.
long internal = 0;
internal = ((PluginAppletViewer)
applet.getAppletContext()).getWindow();
- PluginDebug.debug ("GOT IT: " + internal);
+ PluginDebug.debug("GOT IT: " + internal);
return new JSObject(internal);
}
-
/**
* Finalization decrements the reference count on the corresponding
* JavaScript object.
*/
- protected void finalize()
- {
+ protected void finalize() {
PluginDebug.debug("JSObject.finalize ");
PluginAppletViewer.JavaScriptFinalize(internal);
}
-
/**
* Override java.lang.Object.equals() because identity is not preserved
* with instances of JSObject.
*/
- public boolean equals(Object obj)
- {
+ public boolean equals(Object obj) {
PluginDebug.debug("JSObject.equals " + obj);
return false;
diff --git a/plugin/icedteanp/java/netscape/javascript/JSObjectCreatePermission.java b/plugin/icedteanp/java/netscape/javascript/JSObjectCreatePermission.java
index f8e510f..b955b6c 100644
--- a/plugin/icedteanp/java/netscape/javascript/JSObjectCreatePermission.java
+++ b/plugin/icedteanp/java/netscape/javascript/JSObjectCreatePermission.java
@@ -34,12 +34,11 @@ or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
+
package netscape.javascript;
import java.security.BasicPermission;
-
public class JSObjectCreatePermission extends BasicPermission {
public JSObjectCreatePermission() {
super("JSObjectCreate");
diff --git a/plugin/icedteanp/java/netscape/javascript/JSProxy.java b/plugin/icedteanp/java/netscape/javascript/JSProxy.java
index e4f1f6e..c9ac50e 100644
--- a/plugin/icedteanp/java/netscape/javascript/JSProxy.java
+++ b/plugin/icedteanp/java/netscape/javascript/JSProxy.java
@@ -43,16 +43,25 @@
*/
package netscape.javascript;
+
import java.applet.Applet;
public interface JSProxy {
- Object getMember(JSObject jso, String name);
- Object getSlot(JSObject jso, int index);
- void setMember(JSObject jso, String name, Object value);
- void setSlot(JSObject jso, int index, Object value);
- void removeMember(JSObject jso, String name);
- Object call(JSObject jso, String methodName, Object args[]);
- Object eval(JSObject jso, String s);
- String toString(JSObject jso);
- JSObject getWindow(Applet applet);
+ Object getMember(JSObject jso, String name);
+
+ Object getSlot(JSObject jso, int index);
+
+ void setMember(JSObject jso, String name, Object value);
+
+ void setSlot(JSObject jso, int index, Object value);
+
+ void removeMember(JSObject jso, String name);
+
+ Object call(JSObject jso, String methodName, Object args[]);
+
+ Object eval(JSObject jso, String s);
+
+ String toString(JSObject jso);
+
+ JSObject getWindow(Applet applet);
}
diff --git a/plugin/icedteanp/java/netscape/javascript/JSRunnable.java b/plugin/icedteanp/java/netscape/javascript/JSRunnable.java
index 8f1cf72..df245a7 100644
--- a/plugin/icedteanp/java/netscape/javascript/JSRunnable.java
+++ b/plugin/icedteanp/java/netscape/javascript/JSRunnable.java
@@ -45,28 +45,28 @@ import sun.applet.PluginDebug;
* Runs a JavaScript object with a run() method in a separate thread.
*/
public class JSRunnable implements Runnable {
- private JSObject runnable;
+ private JSObject runnable;
- public JSRunnable(JSObject runnable) {
- this.runnable = runnable;
- synchronized(this) {
- new Thread(this).start();
- try {
- this.wait();
- } catch (InterruptedException ie) {
- }
- }
- }
-
- public void run() {
- try {
- runnable.call("run", null);
- synchronized(this) {
- notifyAll();
- }
- } catch (Throwable t) {
- PluginDebug.debug(t.toString());
- t.printStackTrace(System.err);
- }
- }
+ public JSRunnable(JSObject runnable) {
+ this.runnable = runnable;
+ synchronized (this) {
+ new Thread(this).start();
+ try {
+ this.wait();
+ } catch (InterruptedException ie) {
+ }
+ }
+ }
+
+ public void run() {
+ try {
+ runnable.call("run", null);
+ synchronized (this) {
+ notifyAll();
+ }
+ } catch (Throwable t) {
+ PluginDebug.debug(t.toString());
+ t.printStackTrace(System.err);
+ }
+ }
}
diff --git a/plugin/icedteanp/java/netscape/javascript/JSUtil.java b/plugin/icedteanp/java/netscape/javascript/JSUtil.java
index 47bc6e6..14dfda0 100644
--- a/plugin/icedteanp/java/netscape/javascript/JSUtil.java
+++ b/plugin/icedteanp/java/netscape/javascript/JSUtil.java
@@ -39,21 +39,22 @@
/* ** */
package netscape.javascript;
+
import java.io.*;
public class JSUtil {
/* Return the stack trace of an exception or error as a String */
public static String getStackTrace(Throwable t) {
- ByteArrayOutputStream captureStream;
- PrintWriter p;
-
- captureStream = new ByteArrayOutputStream();
- p = new PrintWriter(captureStream);
+ ByteArrayOutputStream captureStream;
+ PrintWriter p;
+
+ captureStream = new ByteArrayOutputStream();
+ p = new PrintWriter(captureStream);
- t.printStackTrace(p);
- p.flush();
+ t.printStackTrace(p);
+ p.flush();
- return captureStream.toString();
+ return captureStream.toString();
}
}
diff --git a/plugin/icedteanp/java/netscape/security/ForbiddenTargetException.java b/plugin/icedteanp/java/netscape/security/ForbiddenTargetException.java
index c7ce827..abaeb55 100644
--- a/plugin/icedteanp/java/netscape/security/ForbiddenTargetException.java
+++ b/plugin/icedteanp/java/netscape/security/ForbiddenTargetException.java
@@ -37,7 +37,7 @@ exception statement from your version. */
package netscape.security;
-public class ForbiddenTargetException extends RuntimeException{
+public class ForbiddenTargetException extends RuntimeException {
private static final long serialVersionUID = 1271219852541058396L;
diff --git a/plugin/icedteanp/java/sun/applet/AppletSecurityContextManager.java b/plugin/icedteanp/java/sun/applet/AppletSecurityContextManager.java
index 6e0defd..c758bac 100644
--- a/plugin/icedteanp/java/sun/applet/AppletSecurityContextManager.java
+++ b/plugin/icedteanp/java/sun/applet/AppletSecurityContextManager.java
@@ -35,7 +35,6 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package sun.applet;
import java.security.AccessControlContext;
@@ -43,30 +42,30 @@ import java.util.HashMap;
public class AppletSecurityContextManager {
- // Context identifier -> PluginAppletSecurityContext object.
- // FIXME: make private
- private static HashMap<Integer, PluginAppletSecurityContext> contexts =
- new HashMap<Integer, PluginAppletSecurityContext>();
+ // Context identifier -> PluginAppletSecurityContext object.
+ // FIXME: make private
+ private static HashMap<Integer, PluginAppletSecurityContext> contexts =
+ new HashMap<Integer, PluginAppletSecurityContext>();
- public static void addContext(int identifier, PluginAppletSecurityContext context) {
- contexts.put(identifier, context);
- }
+ public static void addContext(int identifier, PluginAppletSecurityContext context) {
+ contexts.put(identifier, context);
+ }
- public static PluginAppletSecurityContext getSecurityContext(int identifier) {
- return contexts.get(identifier);
- }
+ public static PluginAppletSecurityContext getSecurityContext(int identifier) {
+ return contexts.get(identifier);
+ }
- public static void dumpStore(int identifier) {
- contexts.get(identifier).dumpStore();
- }
+ public static void dumpStore(int identifier) {
+ contexts.get(identifier).dumpStore();
+ }
- public static void handleMessage(int identifier, int reference, String src, String[] privileges, String message) {
- PluginDebug.debug(identifier + " -- " + src + " -- " + reference + " -- " + message + " CONTEXT= " + contexts.get(identifier));
- AccessControlContext callContext = null;
+ public static void handleMessage(int identifier, int reference, String src, String[] privileges, String message) {
+ PluginDebug.debug(identifier + " -- " + src + " -- " + reference + " -- " + message + " CONTEXT= " + contexts.get(identifier));
+ AccessControlContext callContext = null;
- privileges = privileges != null ? privileges : new String[0];
- callContext = contexts.get(identifier).getAccessControlContext(privileges, src);
+ privileges = privileges != null ? privileges : new String[0];
+ callContext = contexts.get(identifier).getAccessControlContext(privileges, src);
- contexts.get(identifier).handleMessage(reference, src, callContext, message);
- }
+ contexts.get(identifier).handleMessage(reference, src, callContext, message);
+ }
}
diff --git a/plugin/icedteanp/java/sun/applet/GetMemberPluginCallRequest.java b/plugin/icedteanp/java/sun/applet/GetMemberPluginCallRequest.java
index 7a0a623..5d143a6 100644
--- a/plugin/icedteanp/java/sun/applet/GetMemberPluginCallRequest.java
+++ b/plugin/icedteanp/java/sun/applet/GetMemberPluginCallRequest.java
@@ -37,27 +37,25 @@ exception statement from your version. */
package sun.applet;
-
public class GetMemberPluginCallRequest extends PluginCallRequest {
Object object = null;
public GetMemberPluginCallRequest(String message, Long reference) {
super(message, reference);
- PluginDebug.debug ("GetMemberPluginCall " + message);
+ PluginDebug.debug("GetMemberPluginCall " + message);
}
public void parseReturn(String message) {
- PluginDebug.debug ("GetMemberParseReturn GOT: " + message);
+ PluginDebug.debug("GetMemberParseReturn GOT: " + message);
String[] args = message.split(" ");
// FIXME: Is it even possible to distinguish between null and void
// here?
if (args[3] != "null" && args[3] != "void")
- object = AppletSecurityContextManager.getSecurityContext(0).getObject(Integer.parseInt(args[3]));
+ object = AppletSecurityContextManager.getSecurityContext(0).getObject(Integer.parseInt(args[3]));
setDone(true);
}
public Object getObject() {
- return this.object;
+ return this.object;
}
}
-
diff --git a/plugin/icedteanp/java/sun/applet/GetWindowPluginCallRequest.java b/plugin/icedteanp/java/sun/applet/GetWindowPluginCallRequest.java
index 9c13726..aa46a86 100644
--- a/plugin/icedteanp/java/sun/applet/GetWindowPluginCallRequest.java
+++ b/plugin/icedteanp/java/sun/applet/GetWindowPluginCallRequest.java
@@ -40,8 +40,6 @@ package sun.applet;
import java.security.AccessControlContext;
import java.security.ProtectionDomain;
-
-
public class GetWindowPluginCallRequest extends PluginCallRequest {
// FIXME: look into int vs long JavaScript internal values.
long internal;
@@ -51,7 +49,7 @@ public class GetWindowPluginCallRequest extends PluginCallRequest {
}
public void parseReturn(String message) {
- PluginDebug.debug ("GetWindowParseReturn GOT: " + message);
+ PluginDebug.debug("GetWindowParseReturn GOT: " + message);
String[] args = message.split(" ");
// FIXME: add thread ID to messages to support multiple
// threads using the netscape.javascript package.
@@ -60,6 +58,6 @@ public class GetWindowPluginCallRequest extends PluginCallRequest {
}
public Long getObject() {
- return this.internal;
+ return this.internal;
}
}
diff --git a/plugin/icedteanp/java/sun/applet/JavaConsole.java b/plugin/icedteanp/java/sun/applet/JavaConsole.java
index ad255bd..ae33343 100644
--- a/plugin/icedteanp/java/sun/applet/JavaConsole.java
+++ b/plugin/icedteanp/java/sun/applet/JavaConsole.java
@@ -267,9 +267,9 @@ public class JavaConsole {
System.out.println(" ----");
System.out.println("Available Classloaders: ");
Set<String> loaders = PluginAppletSecurityContext.getLoaderInfo().keySet();
- for (String loader: loaders) {
+ for (String loader : loaders) {
System.out.println(loader + "\n"
- + " codebase = "
+ + " codebase = "
+ PluginAppletSecurityContext.getLoaderInfo().get(loader));
}
System.out.println(" ----");
@@ -278,7 +278,7 @@ public class JavaConsole {
private void printMemoryInfo() {
System.out.println(" ----- ");
System.out.println(" Memory Info:");
- System.out.println(" Max Memory: "
+ System.out.println(" Max Memory: "
+ String.format("%1$10d", Runtime.getRuntime().maxMemory()));
System.out.println(" Total Memory: "
+ String.format("%1$10d", Runtime.getRuntime().totalMemory()));
@@ -304,7 +304,7 @@ public class JavaConsole {
final JavaConsole console = new JavaConsole();
- boolean toShowConsole = false;
+ boolean toShowConsole = false;
for (int i = 0; i < args.length; i++) {
if (args[i] == "--show-console") {
diff --git a/plugin/icedteanp/java/sun/applet/MethodOverloadResolver.java b/plugin/icedteanp/java/sun/applet/MethodOverloadResolver.java
index a1b3147..cd1801a 100644
--- a/plugin/icedteanp/java/sun/applet/MethodOverloadResolver.java
+++ b/plugin/icedteanp/java/sun/applet/MethodOverloadResolver.java
@@ -197,7 +197,8 @@ public class MethodOverloadResolver {
suppliedParam, paramTypeClass);
methodCost += (Integer) costAndCastedObj[0];
- if ((Integer) costAndCastedObj[0] < 0) break;
+ if ((Integer) costAndCastedObj[0] < 0)
+ break;
Object castedObj = paramTypeClass.isPrimitive() ? costAndCastedObj[1]
: paramTypeClass.cast(costAndCastedObj[1]);
@@ -218,7 +219,7 @@ public class MethodOverloadResolver {
}
if ((methodCost > 0 && methodCost < lowestCost) ||
- paramTypes.length == 0) {
+ paramTypes.length == 0) {
ret = methodAndArgs;
lowestCost = methodCost;
}
@@ -261,7 +262,8 @@ public class MethodOverloadResolver {
suppliedParam, paramTypeClass);
constructorCost += (Integer) costAndCastedObj[0];
- if ((Integer) costAndCastedObj[0] < 0) break;
+ if ((Integer) costAndCastedObj[0] < 0)
+ break;
Object castedObj = paramTypeClass.isPrimitive() ? costAndCastedObj[1]
: paramTypeClass.cast(costAndCastedObj[1]);
@@ -282,7 +284,7 @@ public class MethodOverloadResolver {
}
if ((constructorCost > 0 && constructorCost < lowestCost) ||
- paramTypes.length == 0) {
+ paramTypes.length == 0) {
ret = constructorAndArgs;
lowestCost = constructorCost;
}
@@ -297,14 +299,14 @@ public class MethodOverloadResolver {
Integer cost = new Integer(0);
Object castedObj;
- Class<?> suppliedParamClass = suppliedParam != null ? suppliedParam.getClass() : null ;
+ Class<?> suppliedParamClass = suppliedParam != null ? suppliedParam.getClass() : null;
// Either both are an array, or neither are
boolean suppliedParamIsArray = suppliedParamClass != null && suppliedParamClass.isArray();
if (paramTypeClass.isArray() != suppliedParamIsArray &&
- !paramTypeClass.equals(Object.class) &&
+ !paramTypeClass.equals(Object.class) &&
!paramTypeClass.equals(String.class)) {
- ret[0] = Integer.MIN_VALUE; // Not allowed
+ ret[0] = Integer.MIN_VALUE; // Not allowed
ret[1] = suppliedParam;
return ret;
}
@@ -317,7 +319,7 @@ public class MethodOverloadResolver {
if (paramTypeClass.isArray()) {
Object newArray = Array.newInstance(paramTypeClass.getComponentType(), Array.getLength(suppliedParam));
- for (int i=0; i < Array.getLength(suppliedParam); i++) {
+ for (int i = 0; i < Array.getLength(suppliedParam); i++) {
Object original = Array.get(suppliedParam, i);
// When dealing with arrays, we represent empty slots with
@@ -331,7 +333,7 @@ public class MethodOverloadResolver {
Object[] costAndCastedObject = getCostAndCastedObject(original, paramTypeClass.getComponentType());
if ((Integer) costAndCastedObject[0] < 0) {
- ret[0] = Integer.MIN_VALUE; // Not allowed
+ ret[0] = Integer.MIN_VALUE; // Not allowed
ret[1] = suppliedParam;
return ret;
}
@@ -364,15 +366,14 @@ public class MethodOverloadResolver {
cost += 1; // Numeric type to the analogous Java primitive type
castedObj = suppliedParam; // Let auto-boxing handle it
} else if (suppliedParamClass.equals(paramTypeClass)) {
- cost += 3; // Class type to Class type where the types are equal
- castedObj = suppliedParam;
+ cost += 3; // Class type to Class type where the types are equal
+ castedObj = suppliedParam;
} else if (isNum(suppliedParam) &&
(paramTypeClass.isPrimitive() ||
- java.lang.Number.class.isAssignableFrom(paramTypeClass) ||
- java.lang.Character.class.isAssignableFrom(paramTypeClass) ||
+ java.lang.Number.class.isAssignableFrom(paramTypeClass) ||
+ java.lang.Character.class.isAssignableFrom(paramTypeClass) ||
java.lang.Byte.class.isAssignableFrom(paramTypeClass)
- )
- ) {
+ )) {
cost += 4; // Numeric type to a different primitive type
if (suppliedParam.toString().equals("true"))
@@ -389,10 +390,9 @@ public class MethodOverloadResolver {
} else if (suppliedParam instanceof java.lang.String &&
isNum(suppliedParam) &&
(paramTypeClass.isInstance(java.lang.Number.class) ||
- paramTypeClass.isInstance(java.lang.Character.class) ||
- paramTypeClass.isInstance(java.lang.Byte.class) ||
- paramTypeClass.isPrimitive())
- ) {
+ paramTypeClass.isInstance(java.lang.Character.class) ||
+ paramTypeClass.isInstance(java.lang.Byte.class) ||
+ paramTypeClass.isPrimitive())) {
cost += 5; // String to numeric type
if (suppliedParam.toString().equals("true"))
@@ -404,10 +404,9 @@ public class MethodOverloadResolver {
castedObj = (char) Short.decode(suppliedParam.toString()).shortValue();
else
castedObj = getNum(suppliedParam.toString(), paramTypeClass);
- } else if (suppliedParam instanceof java.lang.String &&
+ } else if (suppliedParam instanceof java.lang.String &&
(paramTypeClass.equals(java.lang.Boolean.class) ||
- paramTypeClass.equals(java.lang.Boolean.TYPE))
- ){
+ paramTypeClass.equals(java.lang.Boolean.TYPE))) {
cost += 5; // Same cost as above
castedObj = new Boolean(suppliedParam.toString().length() > 0);
@@ -437,7 +436,7 @@ public class MethodOverloadResolver {
Method[] allMethods = c.getMethods();
ArrayList<Method> matchingMethods = new ArrayList<Method>(5);
- for (Method m: allMethods) {
+ for (Method m : allMethods) {
if (m.getName().equals(name) && m.getParameterTypes().length == paramCount)
matchingMethods.add(m);
}
@@ -449,7 +448,7 @@ public class MethodOverloadResolver {
Constructor[] allConstructors = c.getConstructors();
ArrayList<Constructor> matchingConstructors = new ArrayList<Constructor>(5);
- for (Constructor cs: allConstructors) {
+ for (Constructor cs : allConstructors) {
if (cs.getParameterTypes().length == paramCount)
matchingConstructors.add(cs);
}
@@ -480,7 +479,7 @@ public class MethodOverloadResolver {
return o.getClass();
}
- private static boolean isNum (Object o) {
+ private static boolean isNum(Object o) {
if (o instanceof java.lang.Number)
return true;
@@ -497,18 +496,19 @@ public class MethodOverloadResolver {
try {
Long.parseLong((String) o); // whole number test
return true;
- } catch (NumberFormatException nfe) {}
+ } catch (NumberFormatException nfe) {
+ }
try {
Float.parseFloat((String) o); // decimal
return true;
- } catch (NumberFormatException nfe) {}
-
+ } catch (NumberFormatException nfe) {
+ }
return false;
}
- private static Number getNum (String s, Class<?> c) throws NumberFormatException {
+ private static Number getNum(String s, Class<?> c) throws NumberFormatException {
Number n;
if (s.contains("."))
@@ -518,39 +518,39 @@ public class MethodOverloadResolver {
// See if we need to collapse first
if (c.equals(java.lang.Integer.class) ||
- c.equals(java.lang.Integer.TYPE)) {
+ c.equals(java.lang.Integer.TYPE)) {
return n.intValue();
}
if (c.equals(java.lang.Long.class) ||
- c.equals(java.lang.Long.TYPE)) {
+ c.equals(java.lang.Long.TYPE)) {
return n.longValue();
}
if (c.equals(java.lang.Short.class) ||
- c.equals(java.lang.Short.TYPE)) {
+ c.equals(java.lang.Short.TYPE)) {
return n.shortValue();
}
if (c.equals(java.lang.Float.class) ||
- c.equals(java.lang.Float.TYPE)) {
+ c.equals(java.lang.Float.TYPE)) {
return n.floatValue();
}
if (c.equals(java.lang.Double.class) ||
- c.equals(java.lang.Double.TYPE)) {
+ c.equals(java.lang.Double.TYPE)) {
return n.doubleValue();
}
if (c.equals(java.lang.Byte.class) ||
- c.equals(java.lang.Byte.TYPE)) {
+ c.equals(java.lang.Byte.TYPE)) {
return n.byteValue();
}
return n;
}
- private static String printList (Object[] oList) {
+ private static String printList(Object[] oList) {
String ret = "";
@@ -562,7 +562,7 @@ public class MethodOverloadResolver {
ret += oStr;
ret += ", ";
}
- ret = ret.substring(0, ret.length()-2); // remove last ", "
+ ret = ret.substring(0, ret.length() - 2); // remove last ", "
ret += " }";
return ret;
@@ -573,7 +573,7 @@ public class MethodOverloadResolver {
String ret = new String();
- for (int i=0; i < Array.getLength(array); i++) {
+ for (int i = 0; i < Array.getLength(array); i++) {
Object element = Array.get(array, i);
if (element != null) {
@@ -600,97 +600,147 @@ public class MethodOverloadResolver {
class FooClass {
- public FooClass() {}
+ public FooClass() {
+ }
- public FooClass(Boolean b, int i) {}
+ public FooClass(Boolean b, int i) {
+ }
- public FooClass(Boolean b, Integer i) {}
+ public FooClass(Boolean b, Integer i) {
+ }
- public FooClass(Boolean b, short s) {}
+ public FooClass(Boolean b, short s) {
+ }
- public FooClass(String s, int i) {}
+ public FooClass(String s, int i) {
+ }
- public FooClass(String s, Integer i) {}
+ public FooClass(String s, Integer i) {
+ }
- public FooClass(java.lang.Number num) {}
+ public FooClass(java.lang.Number num) {
+ }
- public FooClass(java.lang.Integer integer) {}
+ public FooClass(java.lang.Integer integer) {
+ }
- public FooClass(long l) {}
+ public FooClass(long l) {
+ }
- public FooClass(double d) {}
+ public FooClass(double d) {
+ }
- public FooClass(float f) {}
+ public FooClass(float f) {
+ }
- public FooClass(JSObject j) {}
+ public FooClass(JSObject j) {
+ }
- public FooClass(BarClass1 b) {}
+ public FooClass(BarClass1 b) {
+ }
- public FooClass(BarClass2 b) {}
+ public FooClass(BarClass2 b) {
+ }
- public FooClass(String s) {}
+ public FooClass(String s) {
+ }
- public FooClass(byte b) {}
+ public FooClass(byte b) {
+ }
- public FooClass(String s, Float f) {}
+ public FooClass(String s, Float f) {
+ }
- public FooClass (int i) {}
+ public FooClass(int i) {
+ }
- public void FooClass() {}
+ public void FooClass() {
+ }
- public void FooClass(boolean b) {}
+ public void FooClass(boolean b) {
+ }
+ public void foo(Boolean b, int i) {
+ }
- public void foo(Boolean b, int i) {}
+ public void foo(Boolean b, Integer i) {
+ }
- public void foo(Boolean b, Integer i) {}
+ public void foo(Boolean b, short s) {
+ }
- public void foo(Boolean b, short s) {}
+ public void foo_string_int(String s, int i) {
+ }
- public void foo_string_int(String s, int i) {}
+ public void foo_string_int(String s, Integer i) {
+ }
- public void foo_string_int(String s, Integer i) {}
+ public void foo_jsobj(JSObject j) {
+ }
- public void foo_jsobj(JSObject j) {}
+ public void foo_jsobj(String s) {
+ }
- public void foo_jsobj(String s) {}
+ public void foo_classtype(java.lang.Number num) {
+ }
- public void foo_classtype(java.lang.Number num) {}
+ public void foo_classtype(java.lang.Integer integer) {
+ }
- public void foo_classtype(java.lang.Integer integer) {}
+ public void foo_multiprim(int i) {
+ }
- public void foo_multiprim(int i) {}
+ public void foo_multiprim(long l) {
+ }
- public void foo_multiprim(long l) {}
+ public void foo_multiprim(float f) {
+ }
- public void foo_multiprim(float f) {}
+ public void foo_multiprim(double d) {
+ }
- public void foo_multiprim(double d) {}
+ public void foo_float(float f) {
+ }
- public void foo_float(float f) {}
+ public void foo_float(String s) {
+ }
- public void foo_float(String s) {}
+ public void foo_float(JSObject j) {
+ }
- public void foo_float(JSObject j) {}
+ public void foo_class(BarClass1 b) {
+ }
- public void foo_class(BarClass1 b) {}
+ public void foo_class(BarClass2 b) {
+ }
- public void foo_class(BarClass2 b) {}
+ public void foo_strandbyteonly(String s) {
+ }
- public void foo_strandbyteonly(String s) {}
+ public void foo_strandbyteonly(byte b) {
+ }
- public void foo_strandbyteonly(byte b) {}
+ public void foo_str_and_float(String s, Float f) {
+ }
- public void foo_str_and_float(String s, Float f) {}
+ public void foo_int_only(int i) {
+ }
- public void foo_int_only (int i) {}
+ public void foo_noargs() {
+ }
- public void foo_noargs() {}
+ public void foo_boolonly(boolean b) {
+ }
+}
+
+class BarClass1 {
+}
- public void foo_boolonly(boolean b) {}
+class BarClass2 extends BarClass1 {
}
-class BarClass1 {}
-class BarClass2 extends BarClass1 {}
-class BarClass3 extends BarClass2 {}
-class JSObject {}
+class BarClass3 extends BarClass2 {
+}
+
+class JSObject {
+}
diff --git a/plugin/icedteanp/java/sun/applet/PluginAppletSecurityContext.java b/plugin/icedteanp/java/sun/applet/PluginAppletSecurityContext.java
index e2db130..ead88c3 100644
--- a/plugin/icedteanp/java/sun/applet/PluginAppletSecurityContext.java
+++ b/plugin/icedteanp/java/sun/applet/PluginAppletSecurityContext.java
@@ -64,380 +64,377 @@ import javax.swing.text.html.HTMLDocument.HTMLReader.IsindexAction;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
import netscape.javascript.JSObjectCreatePermission;
-
-
class Signature {
- private String signature;
- private int currentIndex;
- private List<Class> typeList;
- private static final char ARRAY = '[';
- private static final char OBJECT = 'L';
- private static final char SIGNATURE_ENDCLASS = ';';
- private static final char SIGNATURE_FUNC = '(';
- private static final char SIGNATURE_ENDFUNC = ')';
- private static final char VOID = 'V';
- private static final char BOOLEAN = 'Z';
- private static final char BYTE = 'B';
- private static final char CHARACTER = 'C';
- private static final char SHORT = 'S';
- private static final char INTEGER = 'I';
- private static final char LONG = 'J';
- private static final char FLOAT = 'F';
- private static final char DOUBLE = 'D';
-
- private String nextTypeName() {
- char key = signature.charAt(currentIndex++);
-
- switch (key) {
- case ARRAY:
- return nextTypeName() + "[]";
-
- case OBJECT:
- int endClass = signature.indexOf(SIGNATURE_ENDCLASS, currentIndex);
- String retVal = signature.substring(currentIndex, endClass);
- retVal = retVal.replace('/', '.');
- currentIndex = endClass + 1;
- return retVal;
-
- // FIXME: generated bytecode with classes named after
- // primitives will not work in this scheme -- those
- // classes will be incorrectly treated as primitive
- // types.
- case VOID:
- return "void";
- case BOOLEAN:
- return "boolean";
- case BYTE:
- return "byte";
- case CHARACTER:
- return "char";
- case SHORT:
- return "short";
- case INTEGER:
- return "int";
- case LONG:
- return "long";
- case FLOAT:
- return "float";
- case DOUBLE:
- return "double";
-
- case SIGNATURE_ENDFUNC:
- return null;
-
- case SIGNATURE_FUNC:
- return nextTypeName();
-
- default:
- throw new IllegalArgumentException(
+ private String signature;
+ private int currentIndex;
+ private List<Class> typeList;
+ private static final char ARRAY = '[';
+ private static final char OBJECT = 'L';
+ private static final char SIGNATURE_ENDCLASS = ';';
+ private static final char SIGNATURE_FUNC = '(';
+ private static final char SIGNATURE_ENDFUNC = ')';
+ private static final char VOID = 'V';
+ private static final char BOOLEAN = 'Z';
+ private static final char BYTE = 'B';
+ private static final char CHARACTER = 'C';
+ private static final char SHORT = 'S';
+ private static final char INTEGER = 'I';
+ private static final char LONG = 'J';
+ private static final char FLOAT = 'F';
+ private static final char DOUBLE = 'D';
+
+ private String nextTypeName() {
+ char key = signature.charAt(currentIndex++);
+
+ switch (key) {
+ case ARRAY:
+ return nextTypeName() + "[]";
+
+ case OBJECT:
+ int endClass = signature.indexOf(SIGNATURE_ENDCLASS, currentIndex);
+ String retVal = signature.substring(currentIndex, endClass);
+ retVal = retVal.replace('/', '.');
+ currentIndex = endClass + 1;
+ return retVal;
+
+ // FIXME: generated bytecode with classes named after
+ // primitives will not work in this scheme -- those
+ // classes will be incorrectly treated as primitive
+ // types.
+ case VOID:
+ return "void";
+ case BOOLEAN:
+ return "boolean";
+ case BYTE:
+ return "byte";
+ case CHARACTER:
+ return "char";
+ case SHORT:
+ return "short";
+ case INTEGER:
+ return "int";
+ case LONG:
+ return "long";
+ case FLOAT:
+ return "float";
+ case DOUBLE:
+ return "double";
+
+ case SIGNATURE_ENDFUNC:
+ return null;
+
+ case SIGNATURE_FUNC:
+ return nextTypeName();
+
+ default:
+ throw new IllegalArgumentException(
"Invalid JNI signature character '" + key + "'");
- }
}
+ }
- public Signature(String signature, ClassLoader cl) {
- this.signature = signature;
- currentIndex = 0;
- typeList = new ArrayList<Class>(10);
-
- String elem;
- while (currentIndex < signature.length()) {
- elem = nextTypeName();
-
- if (elem == null) // end of signature
- continue;
-
- // System.out.println ("NEXT TYPE: " + elem);
- Class primitive = primitiveNameToType(elem);
- if (primitive != null)
- typeList.add(primitive);
- else {
- // System.out.println ("HERE1");
- int dimsize = 0;
- int n = elem.indexOf('[');
- if (n != -1) {
- // System.out.println ("HERE2");
- String arrayType = elem.substring(0, n);
- dimsize++;
- n = elem.indexOf('[', n + 1);
- // System.out.println ("HERE2.5");
- while (n != -1) {
- dimsize++;
- n = elem.indexOf('[', n + 1);
- // System.out.println ("HERE2.8");
- }
- int[] dims = new int[dimsize];
- primitive = primitiveNameToType(arrayType);
- // System.out.println ("HERE3");
- if (primitive != null) {
- typeList.add(Array.newInstance(primitive, dims)
+ public Signature(String signature, ClassLoader cl) {
+ this.signature = signature;
+ currentIndex = 0;
+ typeList = new ArrayList<Class>(10);
+
+ String elem;
+ while (currentIndex < signature.length()) {
+ elem = nextTypeName();
+
+ if (elem == null) // end of signature
+ continue;
+
+ // System.out.println ("NEXT TYPE: " + elem);
+ Class primitive = primitiveNameToType(elem);
+ if (primitive != null)
+ typeList.add(primitive);
+ else {
+ // System.out.println ("HERE1");
+ int dimsize = 0;
+ int n = elem.indexOf('[');
+ if (n != -1) {
+ // System.out.println ("HERE2");
+ String arrayType = elem.substring(0, n);
+ dimsize++;
+ n = elem.indexOf('[', n + 1);
+ // System.out.println ("HERE2.5");
+ while (n != -1) {
+ dimsize++;
+ n = elem.indexOf('[', n + 1);
+ // System.out.println ("HERE2.8");
+ }
+ int[] dims = new int[dimsize];
+ primitive = primitiveNameToType(arrayType);
+ // System.out.println ("HERE3");
+ if (primitive != null) {
+ typeList.add(Array.newInstance(primitive, dims)
.getClass());
- // System.out.println ("HERE4");
- } else
- typeList.add(Array.newInstance(
+ // System.out.println ("HERE4");
+ } else
+ typeList.add(Array.newInstance(
getClass(arrayType, cl), dims).getClass());
- } else {
- typeList.add(getClass(elem, cl));
- }
- }
+ } else {
+ typeList.add(getClass(elem, cl));
}
- if (signature.length() < 2) {
- throw new IllegalArgumentException("Invalid JNI signature '"
+ }
+ }
+ if (signature.length() < 2) {
+ throw new IllegalArgumentException("Invalid JNI signature '"
+ signature + "'");
- }
}
+ }
- public static Class getClass(String name, ClassLoader cl) {
-
- Class c = null;
+ public static Class getClass(String name, ClassLoader cl) {
- try {
- c = Class.forName(name);
- } catch (ClassNotFoundException cnfe) {
+ Class c = null;
- PluginDebug.debug("Class " + name + " not found in primordial loader. Looking in " + cl);
- try {
- c = cl.loadClass(name);
- } catch (ClassNotFoundException e) {
- throw (new RuntimeException(new ClassNotFoundException("Unable to find class " + name)));
- }
- }
-
- return c;
+ try {
+ c = Class.forName(name);
+ } catch (ClassNotFoundException cnfe) {
+
+ PluginDebug.debug("Class " + name + " not found in primordial loader. Looking in " + cl);
+ try {
+ c = cl.loadClass(name);
+ } catch (ClassNotFoundException e) {
+ throw (new RuntimeException(new ClassNotFoundException("Unable to find class " + name)));
+ }
}
- public static Class primitiveNameToType(String name) {
- if (name.equals("void"))
- return Void.TYPE;
- else if (name.equals("boolean"))
- return Boolean.TYPE;
- else if (name.equals("byte"))
- return Byte.TYPE;
- else if (name.equals("char"))
- return Character.TYPE;
- else if (name.equals("short"))
- return Short.TYPE;
- else if (name.equals("int"))
- return Integer.TYPE;
- else if (name.equals("long"))
- return Long.TYPE;
- else if (name.equals("float"))
- return Float.TYPE;
- else if (name.equals("double"))
- return Double.TYPE;
- else
- return null;
- }
+ return c;
+ }
- public Class[] getClassArray() {
- return typeList.subList(0, typeList.size()).toArray(new Class[] {});
- }
+ public static Class primitiveNameToType(String name) {
+ if (name.equals("void"))
+ return Void.TYPE;
+ else if (name.equals("boolean"))
+ return Boolean.TYPE;
+ else if (name.equals("byte"))
+ return Byte.TYPE;
+ else if (name.equals("char"))
+ return Character.TYPE;
+ else if (name.equals("short"))
+ return Short.TYPE;
+ else if (name.equals("int"))
+ return Integer.TYPE;
+ else if (name.equals("long"))
+ return Long.TYPE;
+ else if (name.equals("float"))
+ return Float.TYPE;
+ else if (name.equals("double"))
+ return Double.TYPE;
+ else
+ return null;
+ }
+
+ public Class[] getClassArray() {
+ return typeList.subList(0, typeList.size()).toArray(new Class[] {});
+ }
}
public class PluginAppletSecurityContext {
- private static Hashtable<ClassLoader, URL> classLoaders = new Hashtable<ClassLoader, URL>();
- private static Hashtable<Integer, ClassLoader> instanceClassLoaders = new Hashtable<Integer, ClassLoader>();
+ private static Hashtable<ClassLoader, URL> classLoaders = new Hashtable<ClassLoader, URL>();
+ private static Hashtable<Integer, ClassLoader> instanceClassLoaders = new Hashtable<Integer, ClassLoader>();
- // FIXME: make private
- public PluginObjectStore store = new PluginObjectStore();
- private Throwable throwable = null;
- private ClassLoader liveconnectLoader = ClassLoader.getSystemClassLoader();
- int identifier = 0;
+ // FIXME: make private
+ public PluginObjectStore store = new PluginObjectStore();
+ private Throwable throwable = null;
+ private ClassLoader liveconnectLoader = ClassLoader.getSystemClassLoader();
+ int identifier = 0;
- public static PluginStreamHandler streamhandler;
+ public static PluginStreamHandler streamhandler;
- long startTime = 0;
+ long startTime = 0;
- public PluginAppletSecurityContext(int identifier) {
- this.identifier = identifier;
-
- // We need a security manager.. and since there is a good chance that
- // an applet will be loaded at some point, we should make it the SM
- // that JNLPRuntime will try to install
- if (System.getSecurityManager() == null) {
- JNLPRuntime.initialize(/* isApplication */ false);
- }
+ public PluginAppletSecurityContext(int identifier) {
+ this.identifier = identifier;
- JNLPRuntime.disableExit();
-
- URL u = null;
- try {
- u = new URL("file://");
- } catch (Exception e) {
- e.printStackTrace();
- }
+ // We need a security manager.. and since there is a good chance that
+ // an applet will be loaded at some point, we should make it the SM
+ // that JNLPRuntime will try to install
+ if (System.getSecurityManager() == null) {
+ JNLPRuntime.initialize(/* isApplication */false);
+ }
+ JNLPRuntime.disableExit();
- this.classLoaders.put(liveconnectLoader, u);
+ URL u = null;
+ try {
+ u = new URL("file://");
+ } catch (Exception e) {
+ e.printStackTrace();
}
- private static <V> V parseCall(String s, ClassLoader cl, Class<V> c) {
- if (c == Integer.class)
- return c.cast(new Integer(s));
- else if (c == String.class)
- return c.cast(new String(s));
- else if (c == Signature.class)
- return c.cast(new Signature(s, cl));
- else
- throw new RuntimeException("Unexpected call value.");
- }
+ this.classLoaders.put(liveconnectLoader, u);
+ }
- private Object parseArgs(String s, Class c) {
- if (c == Boolean.TYPE || c == Boolean.class)
- return new Boolean(s);
- else if (c == Byte.TYPE || c == Byte.class)
- return new Byte(s);
- else if (c == Character.TYPE || c == Character.class) {
- String[] bytes = s.split("_");
- int low = Integer.parseInt(bytes[0]);
- int high = Integer.parseInt(bytes[1]);
- int full = ((high << 8) & 0x0ff00) | (low & 0x0ff);
- return new Character((char) full);
- } else if (c == Short.TYPE || c == Short.class)
- return new Short(s);
- else if (c == Integer.TYPE || c == Integer.class)
- return new Integer(s);
- else if (c == Long.TYPE || c == Long.class)
- return new Long(s);
- else if (c == Float.TYPE || c == Float.class)
- return new Float(s);
- else if (c == Double.TYPE || c == Double.class)
- return new Double(s);
- else
- return store.getObject(new Integer(s));
- }
+ private static <V> V parseCall(String s, ClassLoader cl, Class<V> c) {
+ if (c == Integer.class)
+ return c.cast(new Integer(s));
+ else if (c == String.class)
+ return c.cast(new String(s));
+ else if (c == Signature.class)
+ return c.cast(new Signature(s, cl));
+ else
+ throw new RuntimeException("Unexpected call value.");
+ }
- public void associateSrc(ClassLoader cl, URL src) {
- PluginDebug.debug("Associating " + cl + " with " + src);
- this.classLoaders.put(cl, src);
- }
+ private Object parseArgs(String s, Class c) {
+ if (c == Boolean.TYPE || c == Boolean.class)
+ return new Boolean(s);
+ else if (c == Byte.TYPE || c == Byte.class)
+ return new Byte(s);
+ else if (c == Character.TYPE || c == Character.class) {
+ String[] bytes = s.split("_");
+ int low = Integer.parseInt(bytes[0]);
+ int high = Integer.parseInt(bytes[1]);
+ int full = ((high << 8) & 0x0ff00) | (low & 0x0ff);
+ return new Character((char) full);
+ } else if (c == Short.TYPE || c == Short.class)
+ return new Short(s);
+ else if (c == Integer.TYPE || c == Integer.class)
+ return new Integer(s);
+ else if (c == Long.TYPE || c == Long.class)
+ return new Long(s);
+ else if (c == Float.TYPE || c == Float.class)
+ return new Float(s);
+ else if (c == Double.TYPE || c == Double.class)
+ return new Double(s);
+ else
+ return store.getObject(new Integer(s));
+ }
+
+ public void associateSrc(ClassLoader cl, URL src) {
+ PluginDebug.debug("Associating " + cl + " with " + src);
+ this.classLoaders.put(cl, src);
+ }
public void associateInstance(Integer i, ClassLoader cl) {
PluginDebug.debug("Associating " + cl + " with instance " + i);
this.instanceClassLoaders.put(i, cl);
}
- public static void setStreamhandler(PluginStreamHandler sh) {
- streamhandler = sh;
- }
-
- public static Map<String, String> getLoaderInfo() {
- Hashtable<String, String> map = new Hashtable<String, String>();
+ public static void setStreamhandler(PluginStreamHandler sh) {
+ streamhandler = sh;
+ }
- for (ClassLoader loader : PluginAppletSecurityContext.classLoaders.keySet()) {
- map.put(loader.getClass().getName(), classLoaders.get(loader).toString());
- }
+ public static Map<String, String> getLoaderInfo() {
+ Hashtable<String, String> map = new Hashtable<String, String>();
- return map;
+ for (ClassLoader loader : PluginAppletSecurityContext.classLoaders.keySet()) {
+ map.put(loader.getClass().getName(), classLoaders.get(loader).toString());
}
- public void handleMessage(int reference, String src, AccessControlContext callContext, String message) {
+ return map;
+ }
+
+ public void handleMessage(int reference, String src, AccessControlContext callContext, String message) {
- startTime = new java.util.Date().getTime();
+ startTime = new java.util.Date().getTime();
+
+ try {
+ if (message.startsWith("FindClass")) {
+ ClassLoader cl = null;
+ Class c = null;
+ cl = liveconnectLoader;
+ String[] args = message.split(" ");
+ Integer instance = new Integer(args[1]);
+ String className = args[2].replace('/', '.');
+ PluginDebug.debug("Searching for class " + className + " in " + cl);
try {
- if (message.startsWith("FindClass")) {
- ClassLoader cl = null;
- Class c = null;
- cl = liveconnectLoader;
- String[] args = message.split(" ");
- Integer instance = new Integer(args[1]);
- String className = args[2].replace('/', '.');
- PluginDebug.debug("Searching for class " + className + " in " + cl);
-
- try {
- c = cl.loadClass(className);
- store.reference(c);
- write(reference, "FindClass " + store.getIdentifier(c));
- } catch (ClassNotFoundException cnfe) {
-
- cl = this.instanceClassLoaders.get(instance);
- PluginDebug.debug("Not found. Looking in " + cl);
+ c = cl.loadClass(className);
+ store.reference(c);
+ write(reference, "FindClass " + store.getIdentifier(c));
+ } catch (ClassNotFoundException cnfe) {
+
+ cl = this.instanceClassLoaders.get(instance);
+ PluginDebug.debug("Not found. Looking in " + cl);
if (instance != 0 && cl != null) {
- try {
- c = cl.loadClass(className);
- store.reference(c);
- write(reference, "FindClass " + store.getIdentifier(c));
- } catch (ClassNotFoundException cnfe2) {
- write(reference, "FindClass 0");
- }
- } else {
- write(reference, "FindClass 0");
- }
- }
+ try {
+ c = cl.loadClass(className);
+ store.reference(c);
+ write(reference, "FindClass " + store.getIdentifier(c));
+ } catch (ClassNotFoundException cnfe2) {
+ write(reference, "FindClass 0");
+ }
+ } else {
+ write(reference, "FindClass 0");
+ }
+ }
- } else if (message.startsWith("GetStaticMethodID")
+ } else if (message.startsWith("GetStaticMethodID")
|| message.startsWith("GetMethodID")) {
- String[] args = message.split(" ");
- Integer classID = parseCall(args[1], null, Integer.class);
- String methodName = parseCall(args[2], null, String.class);
- Signature signature = parseCall(args[3], ((Class) store.getObject(classID)).getClassLoader(), Signature.class);
- Object[] a = signature.getClassArray();
+ String[] args = message.split(" ");
+ Integer classID = parseCall(args[1], null, Integer.class);
+ String methodName = parseCall(args[2], null, String.class);
+ Signature signature = parseCall(args[3], ((Class) store.getObject(classID)).getClassLoader(), Signature.class);
+ Object[] a = signature.getClassArray();
- Class<?> c;
+ Class<?> c;
- if (message.startsWith("GetStaticMethodID") ||
+ if (message.startsWith("GetStaticMethodID") ||
methodName.equals("<init>") ||
methodName.equals("<clinit>"))
- c = (Class<?>) store.getObject(classID);
- else
- c = store.getObject(classID).getClass();
-
- Method m = null;
- Constructor cs = null;
- Object o = null;
- if (methodName.equals("<init>")
+ c = (Class<?>) store.getObject(classID);
+ else
+ c = store.getObject(classID).getClass();
+
+ Method m = null;
+ Constructor cs = null;
+ Object o = null;
+ if (methodName.equals("<init>")
|| methodName.equals("<clinit>")) {
- o = cs = c.getConstructor(signature.getClassArray());
- store.reference(cs);
- } else {
- o = m = c.getMethod(methodName, signature.getClassArray());
- store.reference(m);
- }
- PluginDebug.debug(o + " has id " + store.getIdentifier(o));
- write(reference, args[0] + " " + store.getIdentifier(o));
- } else if (message.startsWith("GetStaticFieldID")
+ o = cs = c.getConstructor(signature.getClassArray());
+ store.reference(cs);
+ } else {
+ o = m = c.getMethod(methodName, signature.getClassArray());
+ store.reference(m);
+ }
+ PluginDebug.debug(o + " has id " + store.getIdentifier(o));
+ write(reference, args[0] + " " + store.getIdentifier(o));
+ } else if (message.startsWith("GetStaticFieldID")
|| message.startsWith("GetFieldID")) {
- String[] args = message.split(" ");
- Integer classID = parseCall(args[1], null, Integer.class);
- Integer fieldID = parseCall(args[2], null, Integer.class);
- String fieldName = (String) store.getObject(fieldID);
+ String[] args = message.split(" ");
+ Integer classID = parseCall(args[1], null, Integer.class);
+ Integer fieldID = parseCall(args[2], null, Integer.class);
+ String fieldName = (String) store.getObject(fieldID);
- Class<?> c = (Class<?>) store.getObject(classID);
+ Class<?> c = (Class<?>) store.getObject(classID);
- PluginDebug.debug("GetStaticFieldID/GetFieldID got class=" + c.getName());
+ PluginDebug.debug("GetStaticFieldID/GetFieldID got class=" + c.getName());
- Field f = null;
- f = c.getField(fieldName);
+ Field f = null;
+ f = c.getField(fieldName);
- store.reference(f);
+ store.reference(f);
- write(reference, "GetStaticFieldID " + store.getIdentifier(f));
- } else if (message.startsWith("GetStaticField")) {
- String[] args = message.split(" ");
- String type = parseCall(args[1], null, String.class);
- Integer classID = parseCall(args[1], null, Integer.class);
- Integer fieldID = parseCall(args[2], null, Integer.class);
+ write(reference, "GetStaticFieldID " + store.getIdentifier(f));
+ } else if (message.startsWith("GetStaticField")) {
+ String[] args = message.split(" ");
+ String type = parseCall(args[1], null, String.class);
+ Integer classID = parseCall(args[1], null, Integer.class);
+ Integer fieldID = parseCall(args[2], null, Integer.class);
- final Class<?> c = (Class<?>) store.getObject(classID);
- final Field f = (Field) store.getObject(fieldID);
+ final Class<?> c = (Class<?>) store.getObject(classID);
+ final Field f = (Field) store.getObject(fieldID);
- AccessControlContext acc = callContext != null ? callContext : getClosedAccessControlContext();
- checkPermission(src, c, acc);
+ AccessControlContext acc = callContext != null ? callContext : getClosedAccessControlContext();
+ checkPermission(src, c, acc);
- Object ret = AccessController.doPrivileged(new PrivilegedAction<Object> () {
- public Object run() {
- try {
- return f.get(c);
- } catch (Throwable t) {
- return t;
- }
- }
- }, acc);
+ Object ret = AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ try {
+ return f.get(c);
+ } catch (Throwable t) {
+ return t;
+ }
+ }
+ }, acc);
- if (ret instanceof Throwable)
- throw (Throwable) ret;
+ if (ret instanceof Throwable)
+ throw (Throwable) ret;
if (ret == null) {
write(reference, "GetStaticField literalreturn null");
@@ -449,7 +446,7 @@ public class PluginAppletSecurityContext {
write(reference, "GetStaticField literalreturn " + ret);
} else if (f.getType() == Float.TYPE
|| f.getType() == Double.TYPE) {
- write(reference, "GetStaticField literalreturn " + String.format("%308.308e", ret));
+ write(reference, "GetStaticField literalreturn " + String.format("%308.308e", ret));
} else if (f.getType() == Character.TYPE) {
write(reference, "GetStaticField literalreturn " + (int) (Character) ret);
} else {
@@ -457,7 +454,7 @@ public class PluginAppletSecurityContext {
store.reference(ret);
write(reference, "GetStaticField " + store.getIdentifier(ret));
}
- } else if (message.startsWith("GetValue")) {
+ } else if (message.startsWith("GetValue")) {
String[] args = message.split(" ");
Integer index = parseCall(args[1], null, Integer.class);
@@ -491,56 +488,56 @@ public class PluginAppletSecurityContext {
}
} else if (message.startsWith("SetStaticField") ||
message.startsWith("SetField")) {
- String[] args = message.split(" ");
- Integer classOrObjectID = parseCall(args[1], null, Integer.class);
- Integer fieldID = parseCall(args[2], null, Integer.class);
- Object value = store.getObject(parseCall(args[3], null, Integer.class));
+ String[] args = message.split(" ");
+ Integer classOrObjectID = parseCall(args[1], null, Integer.class);
+ Integer fieldID = parseCall(args[2], null, Integer.class);
+ Object value = store.getObject(parseCall(args[3], null, Integer.class));
- final Object o = store.getObject(classOrObjectID);
- final Field f = (Field) store.getObject(fieldID);
+ final Object o = store.getObject(classOrObjectID);
+ final Field f = (Field) store.getObject(fieldID);
- final Object fValue = MethodOverloadResolver.getCostAndCastedObject(value, f.getType())[1];
+ final Object fValue = MethodOverloadResolver.getCostAndCastedObject(value, f.getType())[1];
- AccessControlContext acc = callContext != null ? callContext : getClosedAccessControlContext();
- checkPermission(src,
+ AccessControlContext acc = callContext != null ? callContext : getClosedAccessControlContext();
+ checkPermission(src,
message.startsWith("SetStaticField") ? (Class) o : o.getClass(),
acc);
- Object ret = AccessController.doPrivileged(new PrivilegedAction<Object> () {
- public Object run() {
- try {
- f.set(o, fValue);
- } catch (Throwable t) {
- return t;
- }
+ Object ret = AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ try {
+ f.set(o, fValue);
+ } catch (Throwable t) {
+ return t;
+ }
- return null;
- }
- }, acc);
+ return null;
+ }
+ }, acc);
- if (ret instanceof Throwable)
- throw (Throwable) ret;
+ if (ret instanceof Throwable)
+ throw (Throwable) ret;
- write(reference, "SetField");
- } else if (message.startsWith("GetObjectArrayElement")) {
- String[] args = message.split(" ");
- Integer arrayID = parseCall(args[1], null, Integer.class);
- Integer index = parseCall(args[2], null, Integer.class);
+ write(reference, "SetField");
+ } else if (message.startsWith("GetObjectArrayElement")) {
+ String[] args = message.split(" ");
+ Integer arrayID = parseCall(args[1], null, Integer.class);
+ Integer index = parseCall(args[2], null, Integer.class);
- Object ret = Array.get(store.getObject(arrayID), index);
- Class retClass = store.getObject(arrayID).getClass().getComponentType(); // prevent auto-boxing influence
+ Object ret = Array.get(store.getObject(arrayID), index);
+ Class retClass = store.getObject(arrayID).getClass().getComponentType(); // prevent auto-boxing influence
if (ret == null) {
write(reference, "GetObjectArrayElement literalreturn null");
} else if (retClass == Boolean.TYPE
|| retClass == Byte.TYPE
|| retClass == Short.TYPE
- || retClass== Integer.TYPE
- || retClass== Long.TYPE) {
+ || retClass == Integer.TYPE
+ || retClass == Long.TYPE) {
write(reference, "GetObjectArrayElement literalreturn " + ret);
} else if (retClass == Float.TYPE
|| retClass == Double.TYPE) {
- write(reference, "GetObjectArrayElement literalreturn " + String.format("%308.308e", ret));
+ write(reference, "GetObjectArrayElement literalreturn " + String.format("%308.308e", ret));
} else if (retClass == Character.TYPE) {
write(reference, "GetObjectArrayElement literalreturn " + (int) (Character) ret);
} else {
@@ -549,61 +546,61 @@ public class PluginAppletSecurityContext {
write(reference, "GetObjectArrayElement " + store.getIdentifier(ret));
}
- } else if (message.startsWith("SetObjectArrayElement")) {
- String[] args = message.split(" ");
- Integer arrayID = parseCall(args[1], null, Integer.class);
- Integer index = parseCall(args[2], null, Integer.class);
- Integer objectID = parseCall(args[3], null, Integer.class);
-
- Object value = store.getObject(objectID);
-
- // Cast the object to appropriate type before insertion
- value = MethodOverloadResolver.getCostAndCastedObject(value, store.getObject(arrayID).getClass().getComponentType())[1];
-
- //if (value == null &&
- // store.getObject(arrayID).getClass().getComponentType().isPrimitive()) {
- // value = 0;
- //}
-
- Array.set(store.getObject(arrayID), index, value);
-
- write(reference, "SetObjectArrayElement");
- } else if (message.startsWith("GetArrayLength")) {
- String[] args = message.split(" ");
- Integer arrayID = parseCall(args[1], null, Integer.class);
-
- //System.out.println("ARRAYID: " + arrayID);
- Object o = store.getObject(arrayID);
- int len = 0;
- len = Array.getLength(o);
- // System.out.println ("Returning array length: " + len);
-
- // System.out.println ("array length: " + o + " " + len);
- write(reference, "GetArrayLength " + Array.getLength(o));
- } else if (message.startsWith("GetField")) {
- String[] args = message.split(" ");
- String type = parseCall(args[1], null, String.class);
- Integer objectID = parseCall(args[1], null, Integer.class);
- Integer fieldID = parseCall(args[2], null, Integer.class);
-
- final Object o = store.getObject(objectID);
- final Field f = (Field) store.getObject(fieldID);
-
- AccessControlContext acc = callContext != null ? callContext : getClosedAccessControlContext();
- checkPermission(src, o.getClass(), acc);
-
- Object ret = AccessController.doPrivileged(new PrivilegedAction<Object> () {
- public Object run() {
- try {
- return f.get(o);
- } catch (Throwable t) {
- return t;
- }
- }
- }, acc);
-
- if (ret instanceof Throwable)
- throw (Throwable) ret;
+ } else if (message.startsWith("SetObjectArrayElement")) {
+ String[] args = message.split(" ");
+ Integer arrayID = parseCall(args[1], null, Integer.class);
+ Integer index = parseCall(args[2], null, Integer.class);
+ Integer objectID = parseCall(args[3], null, Integer.class);
+
+ Object value = store.getObject(objectID);
+
+ // Cast the object to appropriate type before insertion
+ value = MethodOverloadResolver.getCostAndCastedObject(value, store.getObject(arrayID).getClass().getComponentType())[1];
+
+ //if (value == null &&
+ // store.getObject(arrayID).getClass().getComponentType().isPrimitive()) {
+ // value = 0;
+ //}
+
+ Array.set(store.getObject(arrayID), index, value);
+
+ write(reference, "SetObjectArrayElement");
+ } else if (message.startsWith("GetArrayLength")) {
+ String[] args = message.split(" ");
+ Integer arrayID = parseCall(args[1], null, Integer.class);
+
+ //System.out.println("ARRAYID: " + arrayID);
+ Object o = store.getObject(arrayID);
+ int len = 0;
+ len = Array.getLength(o);
+ // System.out.println ("Returning array length: " + len);
+
+ // System.out.println ("array length: " + o + " " + len);
+ write(reference, "GetArrayLength " + Array.getLength(o));
+ } else if (message.startsWith("GetField")) {
+ String[] args = message.split(" ");
+ String type = parseCall(args[1], null, String.class);
+ Integer objectID = parseCall(args[1], null, Integer.class);
+ Integer fieldID = parseCall(args[2], null, Integer.class);
+
+ final Object o = store.getObject(objectID);
+ final Field f = (Field) store.getObject(fieldID);
+
+ AccessControlContext acc = callContext != null ? callContext : getClosedAccessControlContext();
+ checkPermission(src, o.getClass(), acc);
+
+ Object ret = AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ try {
+ return f.get(o);
+ } catch (Throwable t) {
+ return t;
+ }
+ }
+ }, acc);
+
+ if (ret instanceof Throwable)
+ throw (Throwable) ret;
if (ret == null) {
write(reference, "GetField literalreturn null");
@@ -615,7 +612,7 @@ public class PluginAppletSecurityContext {
write(reference, "GetField literalreturn " + ret);
} else if (f.getType() == Float.TYPE
|| f.getType() == Double.TYPE) {
- write(reference, "GetField literalreturn " + String.format("%308.308e", ret));
+ write(reference, "GetField literalreturn " + String.format("%308.308e", ret));
} else if (f.getType() == Character.TYPE) {
write(reference, "GetField literalreturn " + (int) (Character) ret);
} else {
@@ -624,39 +621,39 @@ public class PluginAppletSecurityContext {
write(reference, "GetField " + store.getIdentifier(ret));
}
- } else if (message.startsWith("GetObjectClass")) {
- int oid = Integer.parseInt(message.substring("GetObjectClass"
+ } else if (message.startsWith("GetObjectClass")) {
+ int oid = Integer.parseInt(message.substring("GetObjectClass"
.length() + 1));
- // System.out.println ("GETTING CLASS FOR: " + oid);
- Class<?> c = store.getObject(oid).getClass();
- // System.out.println (" OBJ: " + store.getObject(oid));
- // System.out.println (" CLS: " + c);
- store.reference(c);
-
- write(reference, "GetObjectClass " + store.getIdentifier(c));
- } else if (message.startsWith("CallMethod") ||
+ // System.out.println ("GETTING CLASS FOR: " + oid);
+ Class<?> c = store.getObject(oid).getClass();
+ // System.out.println (" OBJ: " + store.getObject(oid));
+ // System.out.println (" CLS: " + c);
+ store.reference(c);
+
+ write(reference, "GetObjectClass " + store.getIdentifier(c));
+ } else if (message.startsWith("CallMethod") ||
message.startsWith("CallStaticMethod")) {
- String[] args = message.split(" ");
- Integer objectID = parseCall(args[1], null, Integer.class);
- String methodName = parseCall(args[2], null, String.class);
- Object o = null;
- Class<?> c;
-
- if (message.startsWith("CallMethod")) {
- o = store.getObject(objectID);
- c = o.getClass();
- } else {
- c = (Class<?>) store.getObject(objectID);
- }
+ String[] args = message.split(" ");
+ Integer objectID = parseCall(args[1], null, Integer.class);
+ String methodName = parseCall(args[2], null, String.class);
+ Object o = null;
+ Class<?> c;
+
+ if (message.startsWith("CallMethod")) {
+ o = store.getObject(objectID);
+ c = o.getClass();
+ } else {
+ c = (Class<?>) store.getObject(objectID);
+ }
- // length -3 to discard first 3, + 2 for holding object
- // and method name
- Object[] arguments = new Object[args.length - 1];
- arguments[0] = c;
- arguments[1] = methodName;
+ // length -3 to discard first 3, + 2 for holding object
+ // and method name
+ Object[] arguments = new Object[args.length - 1];
+ arguments[0] = c;
+ arguments[1] = methodName;
for (int i = 0; i < args.length - 3; i++) {
- arguments[i+2] = store.getObject(parseCall(args[3 + i], null, Integer.class));
- PluginDebug.debug("GOT ARG: " + arguments[i+2]);
+ arguments[i + 2] = store.getObject(parseCall(args[3 + i], null, Integer.class));
+ PluginDebug.debug("GOT ARG: " + arguments[i + 2]);
}
Object[] matchingMethodAndArgs = MethodOverloadResolver.getMatchingMethod(arguments);
@@ -666,175 +663,175 @@ public class PluginAppletSecurityContext {
return;
}
- final Method m = (Method) matchingMethodAndArgs[0];
- Object[] castedArgs = new Object[matchingMethodAndArgs.length - 1];
- for (int i=0; i < castedArgs.length; i++) {
- castedArgs[i] = matchingMethodAndArgs[i+1];
- }
+ final Method m = (Method) matchingMethodAndArgs[0];
+ Object[] castedArgs = new Object[matchingMethodAndArgs.length - 1];
+ for (int i = 0; i < castedArgs.length; i++) {
+ castedArgs[i] = matchingMethodAndArgs[i + 1];
+ }
- String collapsedArgs = "";
- for (Object arg : castedArgs) {
- collapsedArgs += " " + arg;
- }
+ String collapsedArgs = "";
+ for (Object arg : castedArgs) {
+ collapsedArgs += " " + arg;
+ }
- PluginDebug.debug("Calling method " + m + " on object " + o
+ PluginDebug.debug("Calling method " + m + " on object " + o
+ " (" + c + ") with " + collapsedArgs);
- AccessControlContext acc = callContext != null ? callContext : getClosedAccessControlContext();
- checkPermission(src, c, acc);
-
- final Object[] fArguments = castedArgs;
- final Object callableObject = o;
- // Set the method accessible prior to calling. See:
- // http://forums.sun.com/thread.jspa?threadID=332001&start=15&tstart=0
- m.setAccessible(true);
- Object ret = AccessController.doPrivileged(new PrivilegedAction<Object> () {
- public Object run() {
- try {
- return m.invoke(callableObject, fArguments);
- } catch (Throwable t) {
- return t;
- }
- }
- }, acc);
-
- if (ret instanceof Throwable)
- throw (Throwable) ret;
-
- String retO;
- if (ret == null) {
- retO = "null";
- } else {
- retO = m.getReturnType().toString();
- }
+ AccessControlContext acc = callContext != null ? callContext : getClosedAccessControlContext();
+ checkPermission(src, c, acc);
- PluginDebug.debug("Calling " + m + " on " + o + " with "
+ final Object[] fArguments = castedArgs;
+ final Object callableObject = o;
+ // Set the method accessible prior to calling. See:
+ // http://forums.sun.com/thread.jspa?threadID=332001&start=15&tstart=0
+ m.setAccessible(true);
+ Object ret = AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ try {
+ return m.invoke(callableObject, fArguments);
+ } catch (Throwable t) {
+ return t;
+ }
+ }
+ }, acc);
+
+ if (ret instanceof Throwable)
+ throw (Throwable) ret;
+
+ String retO;
+ if (ret == null) {
+ retO = "null";
+ } else {
+ retO = m.getReturnType().toString();
+ }
+
+ PluginDebug.debug("Calling " + m + " on " + o + " with "
+ collapsedArgs + " and that returned: " + ret
+ " of type " + retO);
- if (m.getReturnType().equals(java.lang.Void.class) ||
+ if (m.getReturnType().equals(java.lang.Void.class) ||
m.getReturnType().equals(java.lang.Void.TYPE)) {
write(reference, "CallMethod literalreturn void");
} else if (ret == null) {
- write(reference, "CallMethod literalreturn null");
- } else if (m.getReturnType() == Boolean.TYPE
+ write(reference, "CallMethod literalreturn null");
+ } else if (m.getReturnType() == Boolean.TYPE
|| m.getReturnType() == Byte.TYPE
|| m.getReturnType() == Short.TYPE
|| m.getReturnType() == Integer.TYPE
|| m.getReturnType() == Long.TYPE) {
- write(reference, "CallMethod literalreturn " + ret);
+ write(reference, "CallMethod literalreturn " + ret);
} else if (m.getReturnType() == Float.TYPE
|| m.getReturnType() == Double.TYPE) {
- write(reference, "CallMethod literalreturn " + String.format("%308.308e", ret));
- } else if (m.getReturnType() == Character.TYPE) {
- write(reference, "CallMethod literalreturn " + (int) (Character) ret);
- } else {
- // Track returned object.
- store.reference(ret);
- write(reference, "CallMethod " + store.getIdentifier(ret));
- }
- } else if (message.startsWith("GetSuperclass")) {
- String[] args = message.split(" ");
- Integer classID = parseCall(args[1], null, Integer.class);
- Class<?> c = null;
- Class<?> ret = null;
-
- c = (Class) store.getObject(classID);
- ret = c.getSuperclass();
- store.reference(ret);
-
- write(reference, "GetSuperclass " + store.getIdentifier(ret));
- } else if (message.startsWith("IsAssignableFrom")) {
- String[] args = message.split(" ");
- Integer classID = parseCall(args[1], null, Integer.class);
- Integer superclassID = parseCall(args[2], null, Integer.class);
-
- boolean result = false;
- Class<?> clz = (Class<?>) store.getObject(classID);
- Class<?> sup = (Class<?>) store.getObject(superclassID);
-
- result = sup.isAssignableFrom(clz);
-
- write(reference, "IsAssignableFrom " + (result ? "1" : "0"));
- } else if (message.startsWith("IsInstanceOf")) {
- String[] args = message.split(" ");
- Integer objectID = parseCall(args[1], null, Integer.class);
- Integer classID = parseCall(args[2], null, Integer.class);
-
- boolean result = false;
- Object o = store.getObject(objectID);
- Class<?> c = (Class<?>) store.getObject(classID);
-
- result = c.isInstance(o);
-
- write(reference, "IsInstanceOf " + (result ? "1" : "0"));
- } else if (message.startsWith("GetStringUTFLength")) {
- String[] args = message.split(" ");
- Integer stringID = parseCall(args[1], null, Integer.class);
-
- String o = null;
- byte[] b = null;
- o = (String) store.getObject(stringID);
- b = o.getBytes("UTF-8");
- // System.out.println ("STRING UTF-8 LENGTH: " + o + " " +
- // b.length);
-
- write(reference, "GetStringUTFLength " + o.length());
- } else if (message.startsWith("GetStringLength")) {
- String[] args = message.split(" ");
- Integer stringID = parseCall(args[1], null, Integer.class);
-
- String o = null;
- byte[] b = null;
- o = (String) store.getObject(stringID);
- b = o.getBytes("UTF-16LE");
- // System.out.println ("STRING UTF-16 LENGTH: " + o + " " +
- // b.length);
-
- // System.out.println ("Java: GetStringLength " + b.length);
- write(reference, "GetStringLength " + o.length());
- } else if (message.startsWith("GetStringUTFChars")) {
- String[] args = message.split(" ");
- Integer stringID = parseCall(args[1], null, Integer.class);
-
- String o = null;
- byte[] b = null;
- StringBuffer buf = null;
- o = (String) store.getObject(stringID);
- b = o.getBytes("UTF-8");
- buf = new StringBuffer(b.length * 2);
- buf.append(b.length);
- for (int i = 0; i < b.length; i++)
- buf
+ write(reference, "CallMethod literalreturn " + String.format("%308.308e", ret));
+ } else if (m.getReturnType() == Character.TYPE) {
+ write(reference, "CallMethod literalreturn " + (int) (Character) ret);
+ } else {
+ // Track returned object.
+ store.reference(ret);
+ write(reference, "CallMethod " + store.getIdentifier(ret));
+ }
+ } else if (message.startsWith("GetSuperclass")) {
+ String[] args = message.split(" ");
+ Integer classID = parseCall(args[1], null, Integer.class);
+ Class<?> c = null;
+ Class<?> ret = null;
+
+ c = (Class) store.getObject(classID);
+ ret = c.getSuperclass();
+ store.reference(ret);
+
+ write(reference, "GetSuperclass " + store.getIdentifier(ret));
+ } else if (message.startsWith("IsAssignableFrom")) {
+ String[] args = message.split(" ");
+ Integer classID = parseCall(args[1], null, Integer.class);
+ Integer superclassID = parseCall(args[2], null, Integer.class);
+
+ boolean result = false;
+ Class<?> clz = (Class<?>) store.getObject(classID);
+ Class<?> sup = (Class<?>) store.getObject(superclassID);
+
+ result = sup.isAssignableFrom(clz);
+
+ write(reference, "IsAssignableFrom " + (result ? "1" : "0"));
+ } else if (message.startsWith("IsInstanceOf")) {
+ String[] args = message.split(" ");
+ Integer objectID = parseCall(args[1], null, Integer.class);
+ Integer classID = parseCall(args[2], null, Integer.class);
+
+ boolean result = false;
+ Object o = store.getObject(objectID);
+ Class<?> c = (Class<?>) store.getObject(classID);
+
+ result = c.isInstance(o);
+
+ write(reference, "IsInstanceOf " + (result ? "1" : "0"));
+ } else if (message.startsWith("GetStringUTFLength")) {
+ String[] args = message.split(" ");
+ Integer stringID = parseCall(args[1], null, Integer.class);
+
+ String o = null;
+ byte[] b = null;
+ o = (String) store.getObject(stringID);
+ b = o.getBytes("UTF-8");
+ // System.out.println ("STRING UTF-8 LENGTH: " + o + " " +
+ // b.length);
+
+ write(reference, "GetStringUTFLength " + o.length());
+ } else if (message.startsWith("GetStringLength")) {
+ String[] args = message.split(" ");
+ Integer stringID = parseCall(args[1], null, Integer.class);
+
+ String o = null;
+ byte[] b = null;
+ o = (String) store.getObject(stringID);
+ b = o.getBytes("UTF-16LE");
+ // System.out.println ("STRING UTF-16 LENGTH: " + o + " " +
+ // b.length);
+
+ // System.out.println ("Java: GetStringLength " + b.length);
+ write(reference, "GetStringLength " + o.length());
+ } else if (message.startsWith("GetStringUTFChars")) {
+ String[] args = message.split(" ");
+ Integer stringID = parseCall(args[1], null, Integer.class);
+
+ String o = null;
+ byte[] b = null;
+ StringBuffer buf = null;
+ o = (String) store.getObject(stringID);
+ b = o.getBytes("UTF-8");
+ buf = new StringBuffer(b.length * 2);
+ buf.append(b.length);
+ for (int i = 0; i < b.length; i++)
+ buf
.append(" "
+ Integer
.toString(((int) b[i]) & 0x0ff, 16));
- // System.out.println ("Java: GetStringUTFChars: " + o);
- // //System.out.println ("String UTF BYTES: " + buf);
- write(reference, "GetStringUTFChars " + buf);
- } else if (message.startsWith("GetStringChars")) {
- String[] args = message.split(" ");
- Integer stringID = parseCall(args[1], null, Integer.class);
-
- String o = null;
- byte[] b = null;
- StringBuffer buf = null;
- o = (String) store.getObject(stringID);
- // FIXME: LiveConnect uses UCS-2.
- b = o.getBytes("UTF-16LE");
- buf = new StringBuffer(b.length * 2);
- buf.append(b.length);
- for (int i = 0; i < b.length; i++)
- buf
+ // System.out.println ("Java: GetStringUTFChars: " + o);
+ // //System.out.println ("String UTF BYTES: " + buf);
+ write(reference, "GetStringUTFChars " + buf);
+ } else if (message.startsWith("GetStringChars")) {
+ String[] args = message.split(" ");
+ Integer stringID = parseCall(args[1], null, Integer.class);
+
+ String o = null;
+ byte[] b = null;
+ StringBuffer buf = null;
+ o = (String) store.getObject(stringID);
+ // FIXME: LiveConnect uses UCS-2.
+ b = o.getBytes("UTF-16LE");
+ buf = new StringBuffer(b.length * 2);
+ buf.append(b.length);
+ for (int i = 0; i < b.length; i++)
+ buf
.append(" "
+ Integer
.toString(((int) b[i]) & 0x0ff, 16));
- PluginDebug.debug("Java: GetStringChars: " + o);
- PluginDebug.debug(" String BYTES: " + buf);
- write(reference, "GetStringChars " + buf);
- } else if (message.startsWith("GetToStringValue")) {
+ PluginDebug.debug("Java: GetStringChars: " + o);
+ PluginDebug.debug(" String BYTES: " + buf);
+ write(reference, "GetStringChars " + buf);
+ } else if (message.startsWith("GetToStringValue")) {
String[] args = message.split(" ");
Integer objectID = parseCall(args[1], null, Integer.class);
@@ -853,23 +850,23 @@ public class PluginAppletSecurityContext {
write(reference, "GetToStringValue " + buf);
} else if (message.startsWith("NewArray")) {
- String[] args = message.split(" ");
- String type = parseCall(args[1], null, String.class);
- Integer length = parseCall(args[2], null, Integer.class);
-
- // System.out.println ("CALLING: NewArray: " + type + " " +
- // length + " "
- // + Signature.primitiveNameToType(type));
-
- Object newArray = null;
-
- Class c;
- if (type.equals("bool")) {
- c = Boolean.class;
- } else if (type.equals("double")) {
- c = Double.class;
- } else if (type.equals("int")) {
- c = Integer.class;
+ String[] args = message.split(" ");
+ String type = parseCall(args[1], null, String.class);
+ Integer length = parseCall(args[2], null, Integer.class);
+
+ // System.out.println ("CALLING: NewArray: " + type + " " +
+ // length + " "
+ // + Signature.primitiveNameToType(type));
+
+ Object newArray = null;
+
+ Class c;
+ if (type.equals("bool")) {
+ c = Boolean.class;
+ } else if (type.equals("double")) {
+ c = Double.class;
+ } else if (type.equals("int")) {
+ c = Integer.class;
} else if (type.equals("string")) {
c = String.class;
} else if (isInt(type)) {
@@ -878,14 +875,14 @@ public class PluginAppletSecurityContext {
c = JSObject.class;
}
- if (args.length > 3)
- newArray = Array.newInstance(c, new int[] { length, parseCall(args[3], null, Integer.class)});
- else
- newArray = Array.newInstance(c, length);
+ if (args.length > 3)
+ newArray = Array.newInstance(c, new int[] { length, parseCall(args[3], null, Integer.class) });
+ else
+ newArray = Array.newInstance(c, length);
- store.reference(newArray);
- write(reference, "NewArray " + store.getIdentifier(newArray));
- } else if (message.startsWith("HasMethod")) {
+ store.reference(newArray);
+ write(reference, "NewArray " + store.getIdentifier(newArray));
+ } else if (message.startsWith("HasMethod")) {
String[] args = message.split(" ");
Integer classNameID = parseCall(args[1], null, Integer.class);
Integer methodNameID = parseCall(args[2], null, Integer.class);
@@ -895,11 +892,11 @@ public class PluginAppletSecurityContext {
Method method = null;
Method[] classMethods = c.getMethods();
- for (Method m: classMethods) {
- if (m.getName().equals(methodName)) {
- method = m;
- break;
- }
+ for (Method m : classMethods) {
+ if (m.getName().equals(methodName)) {
+ method = m;
+ break;
+ }
}
int hasMethod = (method != null) ? 1 : 0;
@@ -926,37 +923,37 @@ public class PluginAppletSecurityContext {
Field field = null;
Field[] classFields = c.getFields();
- for (Field f: classFields) {
- if (f.getName().equals(fieldName)) {
- field = f;
- break;
- }
+ for (Field f : classFields) {
+ if (f.getName().equals(fieldName)) {
+ field = f;
+ break;
+ }
}
int hasField = (field != null) ? 1 : 0;
write(reference, "HasField " + hasField);
} else if (message.startsWith("NewObjectArray")) {
- String[] args = message.split(" ");
- Integer length = parseCall(args[1], null, Integer.class);
- Integer classID = parseCall(args[2], null, Integer.class);
- Integer objectID = parseCall(args[3], null, Integer.class);
+ String[] args = message.split(" ");
+ Integer length = parseCall(args[1], null, Integer.class);
+ Integer classID = parseCall(args[2], null, Integer.class);
+ Integer objectID = parseCall(args[3], null, Integer.class);
- // System.out.println ("CALLING: NewObjectArray: " +
- // classID + " " + length + " "
- // + objectID);
+ // System.out.println ("CALLING: NewObjectArray: " +
+ // classID + " " + length + " "
+ // + objectID);
- Object newArray = null;
- newArray = Array.newInstance((Class) store.getObject(classID),
+ Object newArray = null;
+ newArray = Array.newInstance((Class) store.getObject(classID),
length);
- Object[] array = (Object[]) newArray;
- for (int i = 0; i < array.length; i++)
- array[i] = store.getObject(objectID);
- store.reference(newArray);
- write(reference, "NewObjectArray "
+ Object[] array = (Object[]) newArray;
+ for (int i = 0; i < array.length; i++)
+ array[i] = store.getObject(objectID);
+ store.reference(newArray);
+ write(reference, "NewObjectArray "
+ store.getIdentifier(newArray));
- } else if (message.startsWith("NewObjectWithConstructor")) {
+ } else if (message.startsWith("NewObjectWithConstructor")) {
String[] args = message.split(" ");
Integer classID = parseCall(args[1], null, Integer.class);
@@ -979,7 +976,7 @@ public class PluginAppletSecurityContext {
Class c = (Class) store.getObject(classID);
checkPermission(src, c, acc);
- Object ret = AccessController.doPrivileged(new PrivilegedAction<Object> () {
+ Object ret = AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
try {
return m.newInstance(fArguments);
@@ -997,9 +994,9 @@ public class PluginAppletSecurityContext {
write(reference, "NewObject " + store.getIdentifier(ret));
} else if (message.startsWith("NewObject")) {
- String[] args = message.split(" ");
- Integer classID = parseCall(args[1], null, Integer.class);
- Class c = (Class) store.getObject(classID);
+ String[] args = message.split(" ");
+ Integer classID = parseCall(args[1], null, Integer.class);
+ Class c = (Class) store.getObject(classID);
final Constructor cons;
final Object[] fArguments;
@@ -1037,26 +1034,26 @@ public class PluginAppletSecurityContext {
" with " + collapsedArgs);
AccessControlContext acc = callContext != null ? callContext : getClosedAccessControlContext();
- checkPermission(src, c, acc);
+ checkPermission(src, c, acc);
- Object ret = AccessController.doPrivileged(new PrivilegedAction<Object> () {
- public Object run() {
- try {
- return cons.newInstance(fArguments);
- } catch (Throwable t) {
- return t;
- }
- }
- }, acc);
+ Object ret = AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ try {
+ return cons.newInstance(fArguments);
+ } catch (Throwable t) {
+ return t;
+ }
+ }
+ }, acc);
- if (ret instanceof Throwable)
- throw (Throwable) ret;
+ if (ret instanceof Throwable)
+ throw (Throwable) ret;
- store.reference(ret);
+ store.reference(ret);
- write(reference, "NewObject " + store.getIdentifier(ret));
+ write(reference, "NewObject " + store.getIdentifier(ret));
- } else if (message.startsWith("NewStringUTF")) {
+ } else if (message.startsWith("NewStringUTF")) {
PluginDebug.debug("MESSAGE: " + message);
String[] args = message.split(" ");
int length = new Integer(args[1]);
@@ -1075,7 +1072,7 @@ public class PluginAppletSecurityContext {
store.reference(ret);
write(reference, "NewStringUTF " + store.getIdentifier(ret));
- } else if (message.startsWith("NewString")) {
+ } else if (message.startsWith("NewString")) {
PluginDebug.debug("MESSAGE: " + message);
String[] args = message.split(" ");
Integer strlength = parseCall(args[1], null, Integer.class);
@@ -1099,383 +1096,382 @@ public class PluginAppletSecurityContext {
store.reference(ret);
write(reference, "NewString " + store.getIdentifier(ret));
- } else if (message.startsWith("ExceptionOccurred")) {
- PluginDebug.debug("EXCEPTION: " + throwable);
- if (throwable != null)
- store.reference(throwable);
- write(reference, "ExceptionOccurred "
+ } else if (message.startsWith("ExceptionOccurred")) {
+ PluginDebug.debug("EXCEPTION: " + throwable);
+ if (throwable != null)
+ store.reference(throwable);
+ write(reference, "ExceptionOccurred "
+ store.getIdentifier(throwable));
- } else if (message.startsWith("ExceptionClear")) {
- if (throwable != null && store.contains(throwable))
- store.unreference(store.getIdentifier(throwable));
- throwable = null;
- write(reference, "ExceptionClear");
- } else if (message.startsWith("DeleteGlobalRef")) {
- String[] args = message.split(" ");
- Integer id = parseCall(args[1], null, Integer.class);
- store.unreference(id);
- write(reference, "DeleteGlobalRef");
- } else if (message.startsWith("DeleteLocalRef")) {
- String[] args = message.split(" ");
- Integer id = parseCall(args[1], null, Integer.class);
- store.unreference(id);
- write(reference, "DeleteLocalRef");
- } else if (message.startsWith("NewGlobalRef")) {
- String[] args = message.split(" ");
- Integer id = parseCall(args[1], null, Integer.class);
- store.reference(store.getObject(id));
- write(reference, "NewGlobalRef " + id);
- } else if (message.startsWith("GetClassName")) {
- String[] args = message.split(" ");
- Integer objectID = parseCall(args[1], null, Integer.class);
- Object o = store.getObject(objectID);
- write(reference, "GetClassName " + o.getClass().getName());
- } else if (message.startsWith("GetClassID")) {
+ } else if (message.startsWith("ExceptionClear")) {
+ if (throwable != null && store.contains(throwable))
+ store.unreference(store.getIdentifier(throwable));
+ throwable = null;
+ write(reference, "ExceptionClear");
+ } else if (message.startsWith("DeleteGlobalRef")) {
+ String[] args = message.split(" ");
+ Integer id = parseCall(args[1], null, Integer.class);
+ store.unreference(id);
+ write(reference, "DeleteGlobalRef");
+ } else if (message.startsWith("DeleteLocalRef")) {
+ String[] args = message.split(" ");
+ Integer id = parseCall(args[1], null, Integer.class);
+ store.unreference(id);
+ write(reference, "DeleteLocalRef");
+ } else if (message.startsWith("NewGlobalRef")) {
+ String[] args = message.split(" ");
+ Integer id = parseCall(args[1], null, Integer.class);
+ store.reference(store.getObject(id));
+ write(reference, "NewGlobalRef " + id);
+ } else if (message.startsWith("GetClassName")) {
+ String[] args = message.split(" ");
+ Integer objectID = parseCall(args[1], null, Integer.class);
+ Object o = store.getObject(objectID);
+ write(reference, "GetClassName " + o.getClass().getName());
+ } else if (message.startsWith("GetClassID")) {
String[] args = message.split(" ");
Integer objectID = parseCall(args[1], null, Integer.class);
store.reference(store.getObject(objectID).getClass());
write(reference, "GetClassID " + store.getIdentifier(store.getObject(objectID).getClass()));
}
- } catch (Throwable t) {
- t.printStackTrace();
- String msg = t.getCause() != null ? t.getCause().getMessage() : t.getMessage();
-
- // add an identifier string to let javaside know of the type of error
- // check for cause as well, since the top level exception will be InvocationTargetException in most cases
- if (t instanceof AccessControlException || t.getCause() instanceof AccessControlException) {
- msg = "LiveConnectPermissionNeeded " + msg;
- }
-
- write(reference, " Error " + msg);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ String msg = t.getCause() != null ? t.getCause().getMessage() : t.getMessage();
+
+ // add an identifier string to let javaside know of the type of error
+ // check for cause as well, since the top level exception will be InvocationTargetException in most cases
+ if (t instanceof AccessControlException || t.getCause() instanceof AccessControlException) {
+ msg = "LiveConnectPermissionNeeded " + msg;
+ }
- // ExceptionOccured is only called after Callmethod() by mozilla. So
- // for exceptions that are not related to CallMethod, we need a way
- // to log them. This is how we do it.. send an error message to the
- // c++ side to let it know that something went wrong, and it will do
- // the right thing to let mozilla know
+ write(reference, " Error " + msg);
- // Store the cause as the actual exception. This is needed because
- // the exception we get here will always be an
- // "InvocationTargetException" due to the use of reflection above
- if (message.startsWith("CallMethod") || message.startsWith("CallStaticMethod"))
- throwable = t.getCause();
- }
+ // ExceptionOccured is only called after Callmethod() by mozilla. So
+ // for exceptions that are not related to CallMethod, we need a way
+ // to log them. This is how we do it.. send an error message to the
+ // c++ side to let it know that something went wrong, and it will do
+ // the right thing to let mozilla know
+ // Store the cause as the actual exception. This is needed because
+ // the exception we get here will always be an
+ // "InvocationTargetException" due to the use of reflection above
+ if (message.startsWith("CallMethod") || message.startsWith("CallStaticMethod"))
+ throwable = t.getCause();
}
- /**
- * Checks if the calling script is allowed to access the specified class
- *
- * @param jsSrc The source of the script
- * @param target The target class that the script is trying to access
- * @param acc AccessControlContext for this execution
- * @throws AccessControlException If the script has insufficient permissions
- */
- public void checkPermission(String jsSrc, Class target, AccessControlContext acc) throws AccessControlException {
- // NPRuntime does not allow cross-site calling. We therefore always
- // allow this, for the time being
- return;
- }
+ }
- private void write(int reference, String message) {
- PluginDebug.debug("appletviewer writing " + message);
- streamhandler.write("context " + identifier + " reference " + reference
- + " " + message);
- }
+ /**
+ * Checks if the calling script is allowed to access the specified class
+ *
+ * @param jsSrc The source of the script
+ * @param target The target class that the script is trying to access
+ * @param acc AccessControlContext for this execution
+ * @throws AccessControlException If the script has insufficient permissions
+ */
+ public void checkPermission(String jsSrc, Class target, AccessControlContext acc) throws AccessControlException {
+ // NPRuntime does not allow cross-site calling. We therefore always
+ // allow this, for the time being
+ return;
+ }
- public void prePopulateLCClasses() {
-
- int classID;
-
- prepopulateClass("netscape/javascript/JSObject");
- classID = prepopulateClass("netscape/javascript/JSException");
- prepopulateMethod(classID, "<init>", "(Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;I)");
- prepopulateMethod(classID, "<init>", "(ILjava/lang/Object;)");
- prepopulateField(classID, "lineno");
- prepopulateField(classID, "tokenIndex");
- prepopulateField(classID, "source");
- prepopulateField(classID, "filename");
- prepopulateField(classID, "wrappedExceptionType");
- prepopulateField(classID, "wrappedException");
-
- classID = prepopulateClass("netscape/javascript/JSUtil");
- prepopulateMethod(classID, "getStackTrace", "(Ljava/lang/Throwable;)");
-
- prepopulateClass("java/lang/Object");
- classID = prepopulateClass("java/lang/Class");
- prepopulateMethod(classID, "getMethods", "()");
- prepopulateMethod(classID, "getConstructors", "()");
- prepopulateMethod(classID, "getFields", "()");
- prepopulateMethod(classID, "getName", "()");
- prepopulateMethod(classID, "isArray", "()");
- prepopulateMethod(classID, "getComponentType", "()");
- prepopulateMethod(classID, "getModifiers", "()");
-
-
- classID = prepopulateClass("java/lang/reflect/Method");
- prepopulateMethod(classID, "getName", "()");
- prepopulateMethod(classID, "getParameterTypes", "()");
- prepopulateMethod(classID, "getReturnType", "()");
- prepopulateMethod(classID, "getModifiers", "()");
-
- classID = prepopulateClass("java/lang/reflect/Constructor");
- prepopulateMethod(classID, "getParameterTypes", "()");
- prepopulateMethod(classID, "getModifiers", "()");
-
- classID = prepopulateClass("java/lang/reflect/Field");
- prepopulateMethod(classID, "getName", "()");
- prepopulateMethod(classID, "getType", "()");
- prepopulateMethod(classID, "getModifiers", "()");
-
- classID = prepopulateClass("java/lang/reflect/Array");
- prepopulateMethod(classID, "newInstance", "(Ljava/lang/Class;I)");
-
- classID = prepopulateClass("java/lang/Throwable");
- prepopulateMethod(classID, "toString", "()");
- prepopulateMethod(classID, "getMessage", "()");
-
- classID = prepopulateClass("java/lang/System");
- prepopulateMethod(classID, "identityHashCode", "(Ljava/lang/Object;)");
-
- classID = prepopulateClass("java/lang/Boolean");
- prepopulateMethod(classID, "booleanValue", "()");
- prepopulateMethod(classID, "<init>", "(Z)");
-
- classID = prepopulateClass("java/lang/Double");
- prepopulateMethod(classID, "doubleValue", "()");
- prepopulateMethod(classID, "<init>", "(D)");
-
- classID = prepopulateClass("java/lang/Void");
- prepopulateField(classID, "TYPE");
-
- prepopulateClass("java/lang/String");
- prepopulateClass("java/applet/Applet");
- }
+ private void write(int reference, String message) {
+ PluginDebug.debug("appletviewer writing " + message);
+ streamhandler.write("context " + identifier + " reference " + reference
+ + " " + message);
+ }
- private int prepopulateClass(String name) {
- name = name.replace('/', '.');
- ClassLoader cl = liveconnectLoader;
- Class c = null;
+ public void prePopulateLCClasses() {
+
+ int classID;
+
+ prepopulateClass("netscape/javascript/JSObject");
+ classID = prepopulateClass("netscape/javascript/JSException");
+ prepopulateMethod(classID, "<init>", "(Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;I)");
+ prepopulateMethod(classID, "<init>", "(ILjava/lang/Object;)");
+ prepopulateField(classID, "lineno");
+ prepopulateField(classID, "tokenIndex");
+ prepopulateField(classID, "source");
+ prepopulateField(classID, "filename");
+ prepopulateField(classID, "wrappedExceptionType");
+ prepopulateField(classID, "wrappedException");
+
+ classID = prepopulateClass("netscape/javascript/JSUtil");
+ prepopulateMethod(classID, "getStackTrace", "(Ljava/lang/Throwable;)");
+
+ prepopulateClass("java/lang/Object");
+ classID = prepopulateClass("java/lang/Class");
+ prepopulateMethod(classID, "getMethods", "()");
+ prepopulateMethod(classID, "getConstructors", "()");
+ prepopulateMethod(classID, "getFields", "()");
+ prepopulateMethod(classID, "getName", "()");
+ prepopulateMethod(classID, "isArray", "()");
+ prepopulateMethod(classID, "getComponentType", "()");
+ prepopulateMethod(classID, "getModifiers", "()");
+
+ classID = prepopulateClass("java/lang/reflect/Method");
+ prepopulateMethod(classID, "getName", "()");
+ prepopulateMethod(classID, "getParameterTypes", "()");
+ prepopulateMethod(classID, "getReturnType", "()");
+ prepopulateMethod(classID, "getModifiers", "()");
+
+ classID = prepopulateClass("java/lang/reflect/Constructor");
+ prepopulateMethod(classID, "getParameterTypes", "()");
+ prepopulateMethod(classID, "getModifiers", "()");
+
+ classID = prepopulateClass("java/lang/reflect/Field");
+ prepopulateMethod(classID, "getName", "()");
+ prepopulateMethod(classID, "getType", "()");
+ prepopulateMethod(classID, "getModifiers", "()");
+
+ classID = prepopulateClass("java/lang/reflect/Array");
+ prepopulateMethod(classID, "newInstance", "(Ljava/lang/Class;I)");
+
+ classID = prepopulateClass("java/lang/Throwable");
+ prepopulateMethod(classID, "toString", "()");
+ prepopulateMethod(classID, "getMessage", "()");
+
+ classID = prepopulateClass("java/lang/System");
+ prepopulateMethod(classID, "identityHashCode", "(Ljava/lang/Object;)");
+
+ classID = prepopulateClass("java/lang/Boolean");
+ prepopulateMethod(classID, "booleanValue", "()");
+ prepopulateMethod(classID, "<init>", "(Z)");
+
+ classID = prepopulateClass("java/lang/Double");
+ prepopulateMethod(classID, "doubleValue", "()");
+ prepopulateMethod(classID, "<init>", "(D)");
+
+ classID = prepopulateClass("java/lang/Void");
+ prepopulateField(classID, "TYPE");
+
+ prepopulateClass("java/lang/String");
+ prepopulateClass("java/applet/Applet");
+ }
- try {
- c = cl.loadClass(name);
- store.reference(c);
- } catch (ClassNotFoundException cnfe) {
- // do nothing ... this should never happen
- cnfe.printStackTrace();
- }
+ private int prepopulateClass(String name) {
+ name = name.replace('/', '.');
+ ClassLoader cl = liveconnectLoader;
+ Class c = null;
- return store.getIdentifier(c);
+ try {
+ c = cl.loadClass(name);
+ store.reference(c);
+ } catch (ClassNotFoundException cnfe) {
+ // do nothing ... this should never happen
+ cnfe.printStackTrace();
}
- private int prepopulateMethod(int classID, String methodName, String signatureStr) {
- Signature signature = parseCall(signatureStr, ((Class) store.getObject(classID)).getClassLoader(), Signature.class);
- Object[] a = signature.getClassArray();
+ return store.getIdentifier(c);
+ }
- Class<?> c = (Class<?>) store.getObject(classID);
- Method m = null;
- Constructor cs = null;
- Object o = null;
+ private int prepopulateMethod(int classID, String methodName, String signatureStr) {
+ Signature signature = parseCall(signatureStr, ((Class) store.getObject(classID)).getClassLoader(), Signature.class);
+ Object[] a = signature.getClassArray();
- try {
- if (methodName.equals("<init>")
- || methodName.equals("<clinit>")) {
- o = cs = c.getConstructor(signature.getClassArray());
- store.reference(cs);
- } else {
- o = m = c.getMethod(methodName, signature.getClassArray());
- store.reference(m);
- }
- } catch (NoSuchMethodException e) {
- // should never happen
- e.printStackTrace();
- }
+ Class<?> c = (Class<?>) store.getObject(classID);
+ Method m = null;
+ Constructor cs = null;
+ Object o = null;
- return store.getIdentifier(m);
+ try {
+ if (methodName.equals("<init>")
+ || methodName.equals("<clinit>")) {
+ o = cs = c.getConstructor(signature.getClassArray());
+ store.reference(cs);
+ } else {
+ o = m = c.getMethod(methodName, signature.getClassArray());
+ store.reference(m);
+ }
+ } catch (NoSuchMethodException e) {
+ // should never happen
+ e.printStackTrace();
}
- private int prepopulateField(int classID, String fieldName) {
+ return store.getIdentifier(m);
+ }
- Class<?> c = (Class<?>) store.getObject(classID);
- Field f = null;
- try {
- f = c.getField(fieldName);
- } catch (SecurityException e) {
- // should never happen
- e.printStackTrace();
- } catch (NoSuchFieldException e) {
- // should never happen
- e.printStackTrace();
- }
+ private int prepopulateField(int classID, String fieldName) {
- store.reference(f);
- return store.getIdentifier(f);
+ Class<?> c = (Class<?>) store.getObject(classID);
+ Field f = null;
+ try {
+ f = c.getField(fieldName);
+ } catch (SecurityException e) {
+ // should never happen
+ e.printStackTrace();
+ } catch (NoSuchFieldException e) {
+ // should never happen
+ e.printStackTrace();
}
- public void dumpStore() {
- store.dump();
- }
+ store.reference(f);
+ return store.getIdentifier(f);
+ }
- public Object getObject(int identifier) {
- return store.getObject(identifier);
- }
+ public void dumpStore() {
+ store.dump();
+ }
- public int getIdentifier(Object o) {
- return store.getIdentifier(o);
- }
+ public Object getObject(int identifier) {
+ return store.getObject(identifier);
+ }
- public void store(Object o) {
- store.reference(o);
- }
+ public int getIdentifier(Object o) {
+ return store.getIdentifier(o);
+ }
- /**
- * Returns a "closed" AccessControlContext i.e. no permissions to get out of sandbox.
- */
- public AccessControlContext getClosedAccessControlContext() {
- // Deny everything
- Permissions p = new Permissions();
- ProtectionDomain pd = new ProtectionDomain(null, p);
- return new AccessControlContext(new ProtectionDomain[] {pd});
- }
+ public void store(Object o) {
+ store.reference(o);
+ }
+
+ /**
+ * Returns a "closed" AccessControlContext i.e. no permissions to get out of sandbox.
+ */
+ public AccessControlContext getClosedAccessControlContext() {
+ // Deny everything
+ Permissions p = new Permissions();
+ ProtectionDomain pd = new ProtectionDomain(null, p);
+ return new AccessControlContext(new ProtectionDomain[] { pd });
+ }
- public AccessControlContext getAccessControlContext(String[] nsPrivilegeList, String src) {
-
-/*
- for (int i=0; i < nsPrivilegeList.length; i++) {
- String privilege = nsPrivilegeList[i];
-
- if (privilege.equals("UniversalAccept")) {
- SocketPermission sp = new SocketPermission("*", "accept,resolve");
- grantedPermissions.add(sp);
- } else if (privilege.equals("UniversalAwtEventQueueAccess")) {
- AWTPermission awtp = new AWTPermission("accessEventQueue");
- grantedPermissions.add(awtp);
- } else if (privilege.equals("UniversalConnect")) {
- SocketPermission sp = new SocketPermission("*", "connect,resolve");
- grantedPermissions.add(sp);
- } else if (privilege.equals("UniversalListen")) {
- SocketPermission sp = new SocketPermission("*", "listen,resolve");
- grantedPermissions.add(sp);
- } else if (privilege.equals("UniversalExecAccess")) {
- FilePermission fp = new FilePermission("<<ALL FILES>>", "execute");
- RuntimePermission rtp = new RuntimePermission("setIO");
- grantedPermissions.add(fp);
- grantedPermissions.add(rtp);
- } else if (privilege.equals("UniversalExitAccess")) {
- // Doesn't matter what the permissions are. Do not allow VM to exit.. we
- // use a single VM for the entire browser lifecycle once invoked, we
- // cannot let it exit
-
- //RuntimePermission rtp = new RuntimePermission("exitVM.*");
- //grantedPermissions.add(rtp);
- } else if (privilege.equals("UniversalFileDelete")) {
- FilePermission fp = new FilePermission("<<ALL FILES>>", "delete");
- grantedPermissions.add(fp);
- } else if (privilege.equals("UniversalFileRead")) {
- FilePermission fp = new FilePermission("<<ALL FILES>>", "read");
- grantedPermissions.add(fp);
- } else if (privilege.equals("UniversalFileWrite")) {
- FilePermission fp = new FilePermission("<<ALL FILES>>", "write");
- grantedPermissions.add(fp);
- } else if (privilege.equals("UniversalFdRead")) {
- RuntimePermission rtp = new RuntimePermission("readFileDescriptor");
- grantedPermissions.add(rtp);
- } else if (privilege.equals("UniversalFdWrite")) {
- RuntimePermission rtp = new RuntimePermission("writeFileDescriptor");
- grantedPermissions.add(rtp);
- } else if (privilege.equals("UniversalLinkAccess")) {
- RuntimePermission rtp = new RuntimePermission("loadLibrary.*");
- grantedPermissions.add(rtp);
- } else if (privilege.equals("UniversalListen")) {
- SocketPermission sp = new SocketPermission("*", "listen");
- grantedPermissions.add(sp);
- } else if (privilege.equals("UniversalMulticast")) {
- SocketPermission sp = new SocketPermission("*", "accept,connect,resolve");
- grantedPermissions.add(sp);
- } else if (privilege.equals("UniversalPackageAccess")) {
- RuntimePermission rtp = new RuntimePermission("defineClassInPackage.*");
- grantedPermissions.add(rtp);
- } else if (privilege.equals("UniversalPackageDefinition")) {
- RuntimePermission rtp = new RuntimePermission("accessClassInPackage.*");
- grantedPermissions.add(rtp);
- } else if (privilege.equals("UniversalPrintJobAccess")) {
- RuntimePermission rtp = new RuntimePermission("queuePrintJob");
- grantedPermissions.add(rtp);
- } else if (privilege.equals("UniversalPropertyRead")) {
- PropertyPermission pp = new PropertyPermission("*", "read");
- grantedPermissions.add(pp);
- } else if (privilege.equals("UniversalPropertyWrite")) {
- PropertyPermission pp = new PropertyPermission("*", "write");
- grantedPermissions.add(pp);
- } else if (privilege.equals("UniversalSetFactory")) {
- RuntimePermission rtp = new RuntimePermission("setFactory");
- grantedPermissions.add(rtp);
- } else if (privilege.equals("UniversalSystemClipboardAccess")) {
- AWTPermission awtp = new AWTPermission("accessClipboard");
- grantedPermissions.add(awtp);
- } else if (privilege.equals("UniversalThreadAccess")) {
- RuntimePermission rtp1 = new RuntimePermission("modifyThread");
- RuntimePermission rtp2 = new RuntimePermission("stopThread");
- grantedPermissions.add(rtp1);
- grantedPermissions.add(rtp2);
- } else if (privilege.equals("UniversalThreadGroupAccess")) {
- RuntimePermission rtp1 = new RuntimePermission("modifyThreadGroup");
- RuntimePermission rtp2 = new RuntimePermission("modifyThread");
- RuntimePermission rtp3 = new RuntimePermission("stopThread");
- grantedPermissions.add(rtp1);
- grantedPermissions.add(rtp2);
- grantedPermissions.add(rtp3);
- } else if (privilege.equals("UniversalTopLevelWindow")) {
- AWTPermission awtp = new AWTPermission("topLevelWindow");
- grantedPermissions.add(awtp);
- } else if (privilege.equals("UniversalBrowserRead")) {
- BrowserReadPermission bp = new BrowserReadPermission();
- grantedPermissions.add(bp);
- } else if (privilege.equals("UniversalJavaPermissions")) {
- AllPermission ap = new AllPermission();
- grantedPermissions.add(ap);
+ public AccessControlContext getAccessControlContext(String[] nsPrivilegeList, String src) {
+
+ /*
+ for (int i=0; i < nsPrivilegeList.length; i++) {
+ String privilege = nsPrivilegeList[i];
+
+ if (privilege.equals("UniversalAccept")) {
+ SocketPermission sp = new SocketPermission("*", "accept,resolve");
+ grantedPermissions.add(sp);
+ } else if (privilege.equals("UniversalAwtEventQueueAccess")) {
+ AWTPermission awtp = new AWTPermission("accessEventQueue");
+ grantedPermissions.add(awtp);
+ } else if (privilege.equals("UniversalConnect")) {
+ SocketPermission sp = new SocketPermission("*", "connect,resolve");
+ grantedPermissions.add(sp);
+ } else if (privilege.equals("UniversalListen")) {
+ SocketPermission sp = new SocketPermission("*", "listen,resolve");
+ grantedPermissions.add(sp);
+ } else if (privilege.equals("UniversalExecAccess")) {
+ FilePermission fp = new FilePermission("<<ALL FILES>>", "execute");
+ RuntimePermission rtp = new RuntimePermission("setIO");
+ grantedPermissions.add(fp);
+ grantedPermissions.add(rtp);
+ } else if (privilege.equals("UniversalExitAccess")) {
+ // Doesn't matter what the permissions are. Do not allow VM to exit.. we
+ // use a single VM for the entire browser lifecycle once invoked, we
+ // cannot let it exit
+
+ //RuntimePermission rtp = new RuntimePermission("exitVM.*");
+ //grantedPermissions.add(rtp);
+ } else if (privilege.equals("UniversalFileDelete")) {
+ FilePermission fp = new FilePermission("<<ALL FILES>>", "delete");
+ grantedPermissions.add(fp);
+ } else if (privilege.equals("UniversalFileRead")) {
+ FilePermission fp = new FilePermission("<<ALL FILES>>", "read");
+ grantedPermissions.add(fp);
+ } else if (privilege.equals("UniversalFileWrite")) {
+ FilePermission fp = new FilePermission("<<ALL FILES>>", "write");
+ grantedPermissions.add(fp);
+ } else if (privilege.equals("UniversalFdRead")) {
+ RuntimePermission rtp = new RuntimePermission("readFileDescriptor");
+ grantedPermissions.add(rtp);
+ } else if (privilege.equals("UniversalFdWrite")) {
+ RuntimePermission rtp = new RuntimePermission("writeFileDescriptor");
+ grantedPermissions.add(rtp);
+ } else if (privilege.equals("UniversalLinkAccess")) {
+ RuntimePermission rtp = new RuntimePermission("loadLibrary.*");
+ grantedPermissions.add(rtp);
+ } else if (privilege.equals("UniversalListen")) {
+ SocketPermission sp = new SocketPermission("*", "listen");
+ grantedPermissions.add(sp);
+ } else if (privilege.equals("UniversalMulticast")) {
+ SocketPermission sp = new SocketPermission("*", "accept,connect,resolve");
+ grantedPermissions.add(sp);
+ } else if (privilege.equals("UniversalPackageAccess")) {
+ RuntimePermission rtp = new RuntimePermission("defineClassInPackage.*");
+ grantedPermissions.add(rtp);
+ } else if (privilege.equals("UniversalPackageDefinition")) {
+ RuntimePermission rtp = new RuntimePermission("accessClassInPackage.*");
+ grantedPermissions.add(rtp);
+ } else if (privilege.equals("UniversalPrintJobAccess")) {
+ RuntimePermission rtp = new RuntimePermission("queuePrintJob");
+ grantedPermissions.add(rtp);
+ } else if (privilege.equals("UniversalPropertyRead")) {
+ PropertyPermission pp = new PropertyPermission("*", "read");
+ grantedPermissions.add(pp);
+ } else if (privilege.equals("UniversalPropertyWrite")) {
+ PropertyPermission pp = new PropertyPermission("*", "write");
+ grantedPermissions.add(pp);
+ } else if (privilege.equals("UniversalSetFactory")) {
+ RuntimePermission rtp = new RuntimePermission("setFactory");
+ grantedPermissions.add(rtp);
+ } else if (privilege.equals("UniversalSystemClipboardAccess")) {
+ AWTPermission awtp = new AWTPermission("accessClipboard");
+ grantedPermissions.add(awtp);
+ } else if (privilege.equals("UniversalThreadAccess")) {
+ RuntimePermission rtp1 = new RuntimePermission("modifyThread");
+ RuntimePermission rtp2 = new RuntimePermission("stopThread");
+ grantedPermissions.add(rtp1);
+ grantedPermissions.add(rtp2);
+ } else if (privilege.equals("UniversalThreadGroupAccess")) {
+ RuntimePermission rtp1 = new RuntimePermission("modifyThreadGroup");
+ RuntimePermission rtp2 = new RuntimePermission("modifyThread");
+ RuntimePermission rtp3 = new RuntimePermission("stopThread");
+ grantedPermissions.add(rtp1);
+ grantedPermissions.add(rtp2);
+ grantedPermissions.add(rtp3);
+ } else if (privilege.equals("UniversalTopLevelWindow")) {
+ AWTPermission awtp = new AWTPermission("topLevelWindow");
+ grantedPermissions.add(awtp);
+ } else if (privilege.equals("UniversalBrowserRead")) {
+ BrowserReadPermission bp = new BrowserReadPermission();
+ grantedPermissions.add(bp);
+ } else if (privilege.equals("UniversalJavaPermissions")) {
+ AllPermission ap = new AllPermission();
+ grantedPermissions.add(ap);
+ }
}
- }
- // what to do with these is unknown: UniversalConnectWithRedirect, UniversalDialogModality, UniversalSendMail, LimitedInstall, FullInstall, SilentInstall
-*/
+ // what to do with these is unknown: UniversalConnectWithRedirect, UniversalDialogModality, UniversalSendMail, LimitedInstall, FullInstall, SilentInstall
+ */
- Permissions grantedPermissions = new Permissions();
+ Permissions grantedPermissions = new Permissions();
- for (int i=0; i < nsPrivilegeList.length; i++) {
- String privilege = nsPrivilegeList[i];
+ for (int i = 0; i < nsPrivilegeList.length; i++) {
+ String privilege = nsPrivilegeList[i];
- if (privilege.equals("UniversalBrowserRead")) {
- BrowserReadPermission bp = new BrowserReadPermission();
- grantedPermissions.add(bp);
- } else if (privilege.equals("UniversalJavaPermission")) {
- AllPermission ap = new AllPermission();
- grantedPermissions.add(ap);
- }
- }
+ if (privilege.equals("UniversalBrowserRead")) {
+ BrowserReadPermission bp = new BrowserReadPermission();
+ grantedPermissions.add(bp);
+ } else if (privilege.equals("UniversalJavaPermission")) {
+ AllPermission ap = new AllPermission();
+ grantedPermissions.add(ap);
+ }
+ }
- CodeSource cs = new CodeSource((URL) null, (java.security.cert.Certificate [])null);
+ CodeSource cs = new CodeSource((URL) null, (java.security.cert.Certificate[]) null);
- if (src != null && src.length() > 0) {
- try {
- cs = new CodeSource(new URL(src + "/"), (java.security.cert.Certificate[]) null);
- } catch (MalformedURLException mfue) {
- // do nothing
- }
+ if (src != null && src.length() > 0) {
+ try {
+ cs = new CodeSource(new URL(src + "/"), (java.security.cert.Certificate[]) null);
+ } catch (MalformedURLException mfue) {
+ // do nothing
+ }
- if (src.equals("[System]"))
- grantedPermissions.add(new JSObjectCreatePermission());
+ if (src.equals("[System]"))
+ grantedPermissions.add(new JSObjectCreatePermission());
- } else {
- JSObjectCreatePermission perm = new JSObjectCreatePermission();
- grantedPermissions.add(perm);
- }
+ } else {
+ JSObjectCreatePermission perm = new JSObjectCreatePermission();
+ grantedPermissions.add(perm);
+ }
- ProtectionDomain pd = new ProtectionDomain(cs, grantedPermissions, null, null);
+ ProtectionDomain pd = new ProtectionDomain(cs, grantedPermissions, null, null);
- // Add to hashmap
- return new AccessControlContext(new ProtectionDomain[] {pd});
- }
+ // Add to hashmap
+ return new AccessControlContext(new ProtectionDomain[] { pd });
+ }
// private static final == inline
private static final boolean isInt(Object o) {
@@ -1491,10 +1487,10 @@ public class PluginAppletSecurityContext {
return isInt;
}
- class BrowserReadPermission extends BasicPermission {
- public BrowserReadPermission() {
- super("browserRead");
- }
+ class BrowserReadPermission extends BasicPermission {
+ public BrowserReadPermission() {
+ super("browserRead");
}
+ }
}
diff --git a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
index 29a3103..ca90b70 100644
--- a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
+++ b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
@@ -60,9 +60,9 @@ exception statement from your version. */
* have any questions.
*/
- package sun.applet;
+package sun.applet;
- import java.applet.Applet;
+import java.applet.Applet;
import java.applet.AppletContext;
import java.applet.AudioClip;
import java.awt.Dimension;
@@ -115,368 +115,362 @@ import sun.misc.Ref;
import com.sun.jndi.toolkit.url.UrlUtil;
- /**
- * Lets us construct one using unix-style one shot behaviors
- */
+/**
+ * Lets us construct one using unix-style one shot behaviors
+ */
- class PluginAppletPanelFactory
- {
+class PluginAppletPanelFactory {
- public AppletPanel createPanel(PluginStreamHandler streamhandler,
+ public AppletPanel createPanel(PluginStreamHandler streamhandler,
int identifier,
long handle, int x, int y,
final URL doc,
- final Hashtable<String,String> atts) {
- AppletViewerPanel panel = AccessController.doPrivileged(new PrivilegedAction<AppletViewerPanel>() {
- public AppletViewerPanel run() {
- try {
- AppletViewerPanel panel = new NetxPanel(doc, atts, false);
- AppletViewerPanel.debug("Using NetX panel");
- PluginDebug.debug(atts.toString());
- return panel;
- } catch (Exception ex) {
- AppletViewerPanel.debug("Unable to start NetX applet - defaulting to Sun applet", ex);
- return new AppletViewerPanel(doc, atts);
- }
- }
- });
+ final Hashtable<String, String> atts) {
+ AppletViewerPanel panel = AccessController.doPrivileged(new PrivilegedAction<AppletViewerPanel>() {
+ public AppletViewerPanel run() {
+ try {
+ AppletViewerPanel panel = new NetxPanel(doc, atts, false);
+ AppletViewerPanel.debug("Using NetX panel");
+ PluginDebug.debug(atts.toString());
+ return panel;
+ } catch (Exception ex) {
+ AppletViewerPanel.debug("Unable to start NetX applet - defaulting to Sun applet", ex);
+ return new AppletViewerPanel(doc, atts);
+ }
+ }
+ });
- // create the frame.
- PluginAppletViewer.framePanel(identifier, System.out, handle, panel);
+ // create the frame.
+ PluginAppletViewer.framePanel(identifier, System.out, handle, panel);
- panel.init();
+ panel.init();
- // Start the applet
- initEventQueue(panel);
+ // Start the applet
+ initEventQueue(panel);
- // Applet initialized. Find out it's classloader and add it to the list
- String portComponent = doc.getPort() != -1 ? ":" + doc.getPort() : "";
- String codeBase = doc.getProtocol() + "://" + doc.getHost() + portComponent;
+ // Applet initialized. Find out it's classloader and add it to the list
+ String portComponent = doc.getPort() != -1 ? ":" + doc.getPort() : "";
+ String codeBase = doc.getProtocol() + "://" + doc.getHost() + portComponent;
- if (atts.get("codebase") != null) {
- try {
- URL appletSrcURL = new URL(codeBase + atts.get("codebase"));
- codeBase = appletSrcURL.getProtocol() + "://" + appletSrcURL.getHost();
- } catch (MalformedURLException mfue) {
- // do nothing
- }
- }
-
-
- // Wait for the panel to initialize
- // (happens in a separate thread)
- Applet a;
-
- // Wait for panel to come alive
- int maxWait = PluginAppletViewer.APPLET_TIMEOUT; // wait for panel to come alive
- int wait = 0;
- while ((panel == null) || (!((NetxPanel) panel).isAlive() && wait < maxWait)) {
- try {
- Thread.sleep(50);
- wait += 50;
- } catch (InterruptedException ie) {
- // just wait
- }
- }
-
- // Wait for the panel to initialize
- // (happens in a separate thread)
- PluginAppletViewer.waitForAppletInit((NetxPanel) panel);
-
- a = panel.getApplet();
-
- // Still null?
- if (panel.getApplet() == null) {
- streamhandler.write("instance " + identifier + " reference " + -1 + " fatalError " + "Initialization failed");
- return null;
- }
-
- PluginDebug.debug("Applet " + a.getClass() + " initialized");
- streamhandler.write("instance " + identifier + " reference 0 initialized");
-
- AppletSecurityContextManager.getSecurityContext(0).associateSrc(((NetxPanel) panel).getAppletClassLoader(), doc);
- AppletSecurityContextManager.getSecurityContext(0).associateInstance(identifier, ((NetxPanel) panel).getAppletClassLoader());
-
- return panel;
- }
-
- public boolean isStandalone()
- {
- return false;
- }
-
- /**
- * Send the initial set of events to the appletviewer event queue.
- * On start-up the current behaviour is to load the applet and call
- * Applet.init() and Applet.start().
- */
- private void initEventQueue(AppletPanel panel) {
- // appletviewer.send.event is an undocumented and unsupported system
- // property which is used exclusively for testing purposes.
- PrivilegedAction<String> pa = new PrivilegedAction<String>() {
- public String run() {
- return System.getProperty("appletviewer.send.event");
- }
- };
- String eventList = AccessController.doPrivileged(pa);
-
- if (eventList == null) {
- // Add the standard events onto the event queue.
- panel.sendEvent(AppletPanel.APPLET_LOAD);
- panel.sendEvent(AppletPanel.APPLET_INIT);
- panel.sendEvent(AppletPanel.APPLET_START);
- } else {
- // We're testing AppletViewer. Force the specified set of events
- // onto the event queue, wait for the events to be processed, and
- // exit.
-
- // The list of events that will be executed is provided as a
- // ","-separated list. No error-checking will be done on the list.
- String [] events = splitSeparator(",", eventList);
-
- for (int i = 0; i < events.length; i++) {
- PluginDebug.debug("Adding event to queue: " + events[i]);
- if (events[i].equals("dispose"))
- panel.sendEvent(AppletPanel.APPLET_DISPOSE);
- else if (events[i].equals("load"))
- panel.sendEvent(AppletPanel.APPLET_LOAD);
- else if (events[i].equals("init"))
- panel.sendEvent(AppletPanel.APPLET_INIT);
- else if (events[i].equals("start"))
- panel.sendEvent(AppletPanel.APPLET_START);
- else if (events[i].equals("stop"))
- panel.sendEvent(AppletPanel.APPLET_STOP);
- else if (events[i].equals("destroy"))
- panel.sendEvent(AppletPanel.APPLET_DESTROY);
- else if (events[i].equals("quit"))
- panel.sendEvent(AppletPanel.APPLET_QUIT);
- else if (events[i].equals("error"))
- panel.sendEvent(AppletPanel.APPLET_ERROR);
- else
- // non-fatal error if we get an unrecognized event
- PluginDebug.debug("Unrecognized event name: " + events[i]);
- }
+ if (atts.get("codebase") != null) {
+ try {
+ URL appletSrcURL = new URL(codeBase + atts.get("codebase"));
+ codeBase = appletSrcURL.getProtocol() + "://" + appletSrcURL.getHost();
+ } catch (MalformedURLException mfue) {
+ // do nothing
+ }
+ }
- while (!panel.emptyEventQueue()) ;
- }
- }
-
-
- /**
- * Split a string based on the presence of a specified separator. Returns
- * an array of arbitrary length. The end of each element in the array is
- * indicated by the separator of the end of the string. If there is a
- * separator immediately before the end of the string, the final element
- * will be empty. None of the strings will contain the separator. Useful
- * when separating strings such as "foo/bar/bas" using separator "/".
- *
- * @param sep The separator.
- * @param s The string to split.
- * @return An array of strings. Each string in the array is determined
- * by the location of the provided sep in the original string,
- * s. Whitespace not stripped.
- */
- private String [] splitSeparator(String sep, String s) {
- List<String> l = new ArrayList<String>();
- int tokenStart = 0;
- int tokenEnd = 0;
-
- while ((tokenEnd = s.indexOf(sep, tokenStart)) != -1) {
- l.add(s.substring(tokenStart, tokenEnd));
- tokenStart = tokenEnd+1;
- }
- // Add the final element.
- l.add(s.substring(tokenStart));
-
- return l.toArray(new String[l.size()]);
- }
- }
-
- class PluginParseRequest
- {
- long handle;
- String tag;
- String documentbase;
- }
-
- /*
- */
- // FIXME: declare JSProxy implementation
- public class PluginAppletViewer extends XEmbeddedFrame
- implements AppletContext, Printable {
- /**
- * Some constants...
- */
- private static String defaultSaveFile = "Applet.ser";
+ // Wait for the panel to initialize
+ // (happens in a separate thread)
+ Applet a;
+
+ // Wait for panel to come alive
+ int maxWait = PluginAppletViewer.APPLET_TIMEOUT; // wait for panel to come alive
+ int wait = 0;
+ while ((panel == null) || (!((NetxPanel) panel).isAlive() && wait < maxWait)) {
+ try {
+ Thread.sleep(50);
+ wait += 50;
+ } catch (InterruptedException ie) {
+ // just wait
+ }
+ }
+
+ // Wait for the panel to initialize
+ // (happens in a separate thread)
+ PluginAppletViewer.waitForAppletInit((NetxPanel) panel);
+
+ a = panel.getApplet();
+
+ // Still null?
+ if (panel.getApplet() == null) {
+ streamhandler.write("instance " + identifier + " reference " + -1 + " fatalError " + "Initialization failed");
+ return null;
+ }
+
+ PluginDebug.debug("Applet " + a.getClass() + " initialized");
+ streamhandler.write("instance " + identifier + " reference 0 initialized");
+
+ AppletSecurityContextManager.getSecurityContext(0).associateSrc(((NetxPanel) panel).getAppletClassLoader(), doc);
+ AppletSecurityContextManager.getSecurityContext(0).associateInstance(identifier, ((NetxPanel) panel).getAppletClassLoader());
+
+ return panel;
+ }
+
+ public boolean isStandalone() {
+ return false;
+ }
+
+ /**
+ * Send the initial set of events to the appletviewer event queue.
+ * On start-up the current behaviour is to load the applet and call
+ * Applet.init() and Applet.start().
+ */
+ private void initEventQueue(AppletPanel panel) {
+ // appletviewer.send.event is an undocumented and unsupported system
+ // property which is used exclusively for testing purposes.
+ PrivilegedAction<String> pa = new PrivilegedAction<String>() {
+ public String run() {
+ return System.getProperty("appletviewer.send.event");
+ }
+ };
+ String eventList = AccessController.doPrivileged(pa);
+
+ if (eventList == null) {
+ // Add the standard events onto the event queue.
+ panel.sendEvent(AppletPanel.APPLET_LOAD);
+ panel.sendEvent(AppletPanel.APPLET_INIT);
+ panel.sendEvent(AppletPanel.APPLET_START);
+ } else {
+ // We're testing AppletViewer. Force the specified set of events
+ // onto the event queue, wait for the events to be processed, and
+ // exit.
+
+ // The list of events that will be executed is provided as a
+ // ","-separated list. No error-checking will be done on the list.
+ String[] events = splitSeparator(",", eventList);
+
+ for (int i = 0; i < events.length; i++) {
+ PluginDebug.debug("Adding event to queue: " + events[i]);
+ if (events[i].equals("dispose"))
+ panel.sendEvent(AppletPanel.APPLET_DISPOSE);
+ else if (events[i].equals("load"))
+ panel.sendEvent(AppletPanel.APPLET_LOAD);
+ else if (events[i].equals("init"))
+ panel.sendEvent(AppletPanel.APPLET_INIT);
+ else if (events[i].equals("start"))
+ panel.sendEvent(AppletPanel.APPLET_START);
+ else if (events[i].equals("stop"))
+ panel.sendEvent(AppletPanel.APPLET_STOP);
+ else if (events[i].equals("destroy"))
+ panel.sendEvent(AppletPanel.APPLET_DESTROY);
+ else if (events[i].equals("quit"))
+ panel.sendEvent(AppletPanel.APPLET_QUIT);
+ else if (events[i].equals("error"))
+ panel.sendEvent(AppletPanel.APPLET_ERROR);
+ else
+ // non-fatal error if we get an unrecognized event
+ PluginDebug.debug("Unrecognized event name: " + events[i]);
+ }
+
+ while (!panel.emptyEventQueue())
+ ;
+ }
+ }
+ /**
+ * Split a string based on the presence of a specified separator. Returns
+ * an array of arbitrary length. The end of each element in the array is
+ * indicated by the separator of the end of the string. If there is a
+ * separator immediately before the end of the string, the final element
+ * will be empty. None of the strings will contain the separator. Useful
+ * when separating strings such as "foo/bar/bas" using separator "/".
+ *
+ * @param sep The separator.
+ * @param s The string to split.
+ * @return An array of strings. Each string in the array is determined
+ * by the location of the provided sep in the original string,
+ * s. Whitespace not stripped.
+ */
+ private String[] splitSeparator(String sep, String s) {
+ List<String> l = new ArrayList<String>();
+ int tokenStart = 0;
+ int tokenEnd = 0;
+
+ while ((tokenEnd = s.indexOf(sep, tokenStart)) != -1) {
+ l.add(s.substring(tokenStart, tokenEnd));
+ tokenStart = tokenEnd + 1;
+ }
+ // Add the final element.
+ l.add(s.substring(tokenStart));
+
+ return l.toArray(new String[l.size()]);
+ }
+}
+
+class PluginParseRequest {
+ long handle;
+ String tag;
+ String documentbase;
+}
+
+/*
+ */
+// FIXME: declare JSProxy implementation
+public class PluginAppletViewer extends XEmbeddedFrame
+ implements AppletContext, Printable {
+ /**
+ * Some constants...
+ */
+ private static String defaultSaveFile = "Applet.ser";
- /**
- * Enumerates the current status of an applet
- *
- * PRE_INIT -> Parsing and initialization phase
- * INIT_COMPLETE -> Initialization complete, reframe pending
- * REFRAME_COMPLETE -> Reframe complete, applet is initialized and usable by the user
- * INACTIVE -> Browser has directed that the applet be destroyed (this state is non-overridable except by DESTROYED)
- * DESTROYED -> Applet has been destroyed
- */
- private static enum PAV_INIT_STATUS {PRE_INIT, INIT_COMPLETE, REFRAME_COMPLETE, INACTIVE, DESTROYED};
+ /**
+ * Enumerates the current status of an applet
+ *
+ * PRE_INIT -> Parsing and initialization phase
+ * INIT_COMPLETE -> Initialization complete, reframe pending
+ * REFRAME_COMPLETE -> Reframe complete, applet is initialized and usable by the user
+ * INACTIVE -> Browser has directed that the applet be destroyed (this state is non-overridable except by DESTROYED)
+ * DESTROYED -> Applet has been destroyed
+ */
+ private static enum PAV_INIT_STATUS {
+ PRE_INIT, INIT_COMPLETE, REFRAME_COMPLETE, INACTIVE, DESTROYED
+ };
- /**
- * The panel in which the applet is being displayed.
- */
- AppletViewerPanel panel;
+ /**
+ * The panel in which the applet is being displayed.
+ */
+ AppletViewerPanel panel;
- /**
- * The status line.
- */
- Label label;
+ /**
+ * The status line.
+ */
+ Label label;
- /**
- * output status messages to this stream
- */
+ /**
+ * output status messages to this stream
+ */
- PrintStream statusMsgStream;
+ PrintStream statusMsgStream;
- int identifier;
+ int identifier;
- private static HashMap<Integer, PluginParseRequest> requests =
- new HashMap<Integer,PluginParseRequest>();
+ private static HashMap<Integer, PluginParseRequest> requests =
+ new HashMap<Integer, PluginParseRequest>();
- // Instance identifier -> PluginAppletViewer object.
- private static HashMap<Integer, PluginAppletViewer> applets =
- new HashMap<Integer,PluginAppletViewer>();
+ // Instance identifier -> PluginAppletViewer object.
+ private static HashMap<Integer, PluginAppletViewer> applets =
+ new HashMap<Integer, PluginAppletViewer>();
- private static PluginStreamHandler streamhandler;
+ private static PluginStreamHandler streamhandler;
- private static PluginCallRequestFactory requestFactory;
+ private static PluginCallRequestFactory requestFactory;
- private static HashMap<Integer, PAV_INIT_STATUS> status =
- new HashMap<Integer,PAV_INIT_STATUS>();
+ private static HashMap<Integer, PAV_INIT_STATUS> status =
+ new HashMap<Integer, PAV_INIT_STATUS>();
- private long handle = 0;
- private WindowListener windowEventListener = null;
- private AppletEventListener appletEventListener = null;
+ private long handle = 0;
+ private WindowListener windowEventListener = null;
+ private AppletEventListener appletEventListener = null;
- public static final int APPLET_TIMEOUT = 180000;
+ public static final int APPLET_TIMEOUT = 180000;
- private static Long requestIdentityCounter = 0L;
+ private static Long requestIdentityCounter = 0L;
- private Image bufFrameImg;
- private Graphics bufFrameImgGraphics;
+ private Image bufFrameImg;
+ private Graphics bufFrameImgGraphics;
- /**
- * Null constructor to allow instantiation via newInstance()
- */
- public PluginAppletViewer() {
- }
+ /**
+ * Null constructor to allow instantiation via newInstance()
+ */
+ public PluginAppletViewer() {
+ }
- public static void framePanel(int identifier, PrintStream statusMsgStream,
+ public static void framePanel(int identifier, PrintStream statusMsgStream,
long handle, AppletViewerPanel panel) {
- PluginDebug.debug("Framing " + panel);
+ PluginDebug.debug("Framing " + panel);
- // SecurityManager MUST be set, and only privileged code may call reFrame()
- System.getSecurityManager().checkPermission(new AllPermission());
+ // SecurityManager MUST be set, and only privileged code may call reFrame()
+ System.getSecurityManager().checkPermission(new AllPermission());
- PluginAppletViewer appletFrame = new PluginAppletViewer(handle, identifier, statusMsgStream, panel);
+ PluginAppletViewer appletFrame = new PluginAppletViewer(handle, identifier, statusMsgStream, panel);
- appletFrame.add("Center", panel);
- appletFrame.pack();
+ appletFrame.add("Center", panel);
+ appletFrame.pack();
- appletFrame.appletEventListener = new AppletEventListener(appletFrame, appletFrame);
- panel.addAppletListener(appletFrame.appletEventListener);
+ appletFrame.appletEventListener = new AppletEventListener(appletFrame, appletFrame);
+ panel.addAppletListener(appletFrame.appletEventListener);
- applets.put(identifier, appletFrame);
+ applets.put(identifier, appletFrame);
- PluginDebug.debug(panel + " framed");
- }
+ PluginDebug.debug(panel + " framed");
+ }
- /**
- * Create new plugin appletviewer frame
- */
- private PluginAppletViewer(long handle, final int identifier,
+ /**
+ * Create new plugin appletviewer frame
+ */
+ private PluginAppletViewer(long handle, final int identifier,
PrintStream statusMsgStream,
AppletViewerPanel appletPanel) {
- super(handle, true);
- this.statusMsgStream = statusMsgStream;
- this.identifier = identifier;
- this.panel = appletPanel;
+ super(handle, true);
+ this.statusMsgStream = statusMsgStream;
+ this.identifier = identifier;
+ this.panel = appletPanel;
- if (!appletPanels.contains(panel))
- appletPanels.addElement(panel);
+ if (!appletPanels.contains(panel))
+ appletPanels.addElement(panel);
- windowEventListener = new WindowAdapter() {
+ windowEventListener = new WindowAdapter() {
- public void windowClosing(WindowEvent evt) {
- appletClose();
- }
+ public void windowClosing(WindowEvent evt) {
+ appletClose();
+ }
- public void windowIconified(WindowEvent evt) {
- appletStop();
- }
+ public void windowIconified(WindowEvent evt) {
+ appletStop();
+ }
- public void windowDeiconified(WindowEvent evt) {
- appletStart();
- }
- };
+ public void windowDeiconified(WindowEvent evt) {
+ appletStart();
+ }
+ };
- addWindowListener(windowEventListener);
+ addWindowListener(windowEventListener);
- }
+ }
- private static class AppletEventListener implements AppletListener
- {
- final Frame frame;
- final PluginAppletViewer appletViewer;
+ private static class AppletEventListener implements AppletListener {
+ final Frame frame;
+ final PluginAppletViewer appletViewer;
- public AppletEventListener(Frame frame, PluginAppletViewer appletViewer)
- {
- this.frame = frame;
- this.appletViewer = appletViewer;
- }
+ public AppletEventListener(Frame frame, PluginAppletViewer appletViewer) {
+ this.frame = frame;
+ this.appletViewer = appletViewer;
+ }
- public void appletStateChanged(AppletEvent evt)
- {
- AppletPanel src = (AppletPanel)evt.getSource();
+ public void appletStateChanged(AppletEvent evt) {
+ AppletPanel src = (AppletPanel) evt.getSource();
- switch (evt.getID()) {
- case AppletPanel.APPLET_RESIZE: {
- if(src != null) {
- appletViewer.setSize(appletViewer.getPreferredSize());
- appletViewer.validate();
- }
- break;
- }
- case AppletPanel.APPLET_LOADING_COMPLETED: {
- Applet a = src.getApplet(); // sun.applet.AppletPanel
-
- // Fixed #4754451: Applet can have methods running on main
- // thread event queue.
- //
- // The cause of this bug is that the frame of the applet
- // is created in main thread group. Thus, when certain
- // AWT/Swing events are generated, the events will be
- // dispatched through the wrong event dispatch thread.
- //
- // To fix this, we rearrange the AppContext with the frame,
- // so the proper event queue will be looked up.
- //
- // Swing also maintains a Frame list for the AppContext,
- // so we will have to rearrange it as well.
- //
- if (a != null)
- AppletPanel.changeFrameAppContext(frame, SunToolkit.targetToAppContext(a));
- else
- AppletPanel.changeFrameAppContext(frame, AppContext.getAppContext());
-
- updateStatus(appletViewer.identifier, PAV_INIT_STATUS.INIT_COMPLETE);
-
- break;
- }
- }
- }
- }
+ switch (evt.getID()) {
+ case AppletPanel.APPLET_RESIZE: {
+ if (src != null) {
+ appletViewer.setSize(appletViewer.getPreferredSize());
+ appletViewer.validate();
+ }
+ break;
+ }
+ case AppletPanel.APPLET_LOADING_COMPLETED: {
+ Applet a = src.getApplet(); // sun.applet.AppletPanel
+
+ // Fixed #4754451: Applet can have methods running on main
+ // thread event queue.
+ //
+ // The cause of this bug is that the frame of the applet
+ // is created in main thread group. Thus, when certain
+ // AWT/Swing events are generated, the events will be
+ // dispatched through the wrong event dispatch thread.
+ //
+ // To fix this, we rearrange the AppContext with the frame,
+ // so the proper event queue will be looked up.
+ //
+ // Swing also maintains a Frame list for the AppContext,
+ // so we will have to rearrange it as well.
+ //
+ if (a != null)
+ AppletPanel.changeFrameAppContext(frame, SunToolkit.targetToAppContext(a));
+ else
+ AppletPanel.changeFrameAppContext(frame, AppContext.getAppContext());
+
+ updateStatus(appletViewer.identifier, PAV_INIT_STATUS.INIT_COMPLETE);
+
+ break;
+ }
+ }
+ }
+ }
public static void setStreamhandler(PluginStreamHandler sh) {
streamhandler = sh;
@@ -486,288 +480,286 @@ import com.sun.jndi.toolkit.url.UrlUtil;
requestFactory = rf;
}
- /**
- * Handle an incoming message from the plugin.
- */
- public static void handleMessage(int identifier, int reference, String message)
- {
-
- PluginDebug.debug("PAV handling: " + message);
-
- try {
- if (message.startsWith("handle")) {
-
- // If there is a key for this status, it means it
- // was either initialized before, or destroy has been
- // processed. Stop moving further.
- if (updateStatus(identifier, PAV_INIT_STATUS.PRE_INIT) != null)
- return;
-
- // Extract the information from the message
- String[] msgParts = new String[4];
- for (int i=0; i < 3; i++) {
- int spaceLocation = message.indexOf(' ');
- int nextSpaceLocation = message.indexOf(' ', spaceLocation+1);
- msgParts[i] = message.substring(spaceLocation + 1, nextSpaceLocation);
- message = message.substring(nextSpaceLocation + 1);
- }
-
- long handle = Long.parseLong(msgParts[0]);
- String width = msgParts[1];
- String height = msgParts[2];
-
- int spaceLocation = message.indexOf(' ', "tag".length()+1);
- String documentBase =
- UrlUtil.decode(message.substring("tag".length() + 1, spaceLocation));
- String tag = message.substring(spaceLocation+1);
+ /**
+ * Handle an incoming message from the plugin.
+ */
+ public static void handleMessage(int identifier, int reference, String message) {
- // Decode the tag
- tag = tag.replace("&gt;", ">");
- tag = tag.replace("&lt;", "<");
- tag = tag.replace("&amp;", "&");
- tag = tag.replace("&#10;", "\n");
- tag = tag.replace("&#13;", "\r");
- tag = tag.replace("&quot;", "\"");
+ PluginDebug.debug("PAV handling: " + message);
- PluginDebug.debug ("Handle = " + handle + "\n" +
+ try {
+ if (message.startsWith("handle")) {
+
+ // If there is a key for this status, it means it
+ // was either initialized before, or destroy has been
+ // processed. Stop moving further.
+ if (updateStatus(identifier, PAV_INIT_STATUS.PRE_INIT) != null)
+ return;
+
+ // Extract the information from the message
+ String[] msgParts = new String[4];
+ for (int i = 0; i < 3; i++) {
+ int spaceLocation = message.indexOf(' ');
+ int nextSpaceLocation = message.indexOf(' ', spaceLocation + 1);
+ msgParts[i] = message.substring(spaceLocation + 1, nextSpaceLocation);
+ message = message.substring(nextSpaceLocation + 1);
+ }
+
+ long handle = Long.parseLong(msgParts[0]);
+ String width = msgParts[1];
+ String height = msgParts[2];
+
+ int spaceLocation = message.indexOf(' ', "tag".length() + 1);
+ String documentBase =
+ UrlUtil.decode(message.substring("tag".length() + 1, spaceLocation));
+ String tag = message.substring(spaceLocation + 1);
+
+ // Decode the tag
+ tag = tag.replace("&gt;", ">");
+ tag = tag.replace("&lt;", "<");
+ tag = tag.replace("&amp;", "&");
+ tag = tag.replace("&#10;", "\n");
+ tag = tag.replace("&#13;", "\r");
+ tag = tag.replace("&quot;", "\"");
+
+ PluginDebug.debug("Handle = " + handle + "\n" +
"Width = " + width + "\n" +
"Height = " + height + "\n" +
"DocumentBase = " + documentBase + "\n" +
"Tag = " + tag);
- PluginAppletViewer.parse
+ PluginAppletViewer.parse
(identifier, handle, width, height,
new StringReader(tag),
new URL(documentBase));
- int maxWait = APPLET_TIMEOUT; // wait for applet to fully load
- int wait = 0;
- while ( !applets.containsKey(identifier) && // Map is populated only by reFrame
- (wait < maxWait)) {
-
- try {
- Thread.sleep(50);
- wait += 50;
- } catch (InterruptedException ie) {
- // just wait
- }
- }
+ int maxWait = APPLET_TIMEOUT; // wait for applet to fully load
+ int wait = 0;
+ while (!applets.containsKey(identifier) && // Map is populated only by reFrame
+ (wait < maxWait)) {
- // If wait exceeded maxWait, we timed out. Throw an exception
- if (wait >= maxWait)
- throw new Exception("Applet initialization timeout");
+ try {
+ Thread.sleep(50);
+ wait += 50;
+ } catch (InterruptedException ie) {
+ // just wait
+ }
+ }
- PluginAppletViewer oldFrame = applets.get(identifier);
+ // If wait exceeded maxWait, we timed out. Throw an exception
+ if (wait >= maxWait)
+ throw new Exception("Applet initialization timeout");
- // We should not try to destroy an applet during
- // initialization. It may cause an inconsistent state,
- // which would bad if it's a trusted applet that
- // read/writes to files
- waitForAppletInit((NetxPanel) applets.get(identifier).panel);
+ PluginAppletViewer oldFrame = applets.get(identifier);
- // Should we proceed with reframing?
- if (updateStatus(identifier, PAV_INIT_STATUS.REFRAME_COMPLETE).equals(PAV_INIT_STATUS.INACTIVE)) {
- destroyApplet(identifier);
- return;
- }
+ // We should not try to destroy an applet during
+ // initialization. It may cause an inconsistent state,
+ // which would bad if it's a trusted applet that
+ // read/writes to files
+ waitForAppletInit((NetxPanel) applets.get(identifier).panel);
+
+ // Should we proceed with reframing?
+ if (updateStatus(identifier, PAV_INIT_STATUS.REFRAME_COMPLETE).equals(PAV_INIT_STATUS.INACTIVE)) {
+ destroyApplet(identifier);
+ return;
+ }
- } else if (message.startsWith("destroy")) {
+ } else if (message.startsWith("destroy")) {
- // Set it inactive, and try to do cleanup is applicable
- PAV_INIT_STATUS previousStatus = updateStatus(identifier, PAV_INIT_STATUS.INACTIVE);
- PluginDebug.debug("Destroy status set for " + identifier);
+ // Set it inactive, and try to do cleanup is applicable
+ PAV_INIT_STATUS previousStatus = updateStatus(identifier, PAV_INIT_STATUS.INACTIVE);
+ PluginDebug.debug("Destroy status set for " + identifier);
- if (previousStatus != null &&
+ if (previousStatus != null &&
previousStatus.equals(PAV_INIT_STATUS.REFRAME_COMPLETE)) {
- destroyApplet(identifier);
- }
+ destroyApplet(identifier);
+ }
- } else {
- PluginDebug.debug ("Handling message: " + message + " instance " + identifier + " " + Thread.currentThread());
+ } else {
+ PluginDebug.debug("Handling message: " + message + " instance " + identifier + " " + Thread.currentThread());
- // Wait till initialization finishes
- while (!applets.containsKey(identifier) &&
+ // Wait till initialization finishes
+ while (!applets.containsKey(identifier) &&
(
!status.containsKey(identifier) ||
status.get(identifier).equals(PAV_INIT_STATUS.PRE_INIT)
- )
- );
+ ))
+ ;
- // don't bother processing further for inactive applets
- if (status.get(identifier).equals(PAV_INIT_STATUS.INACTIVE))
- return;
+ // don't bother processing further for inactive applets
+ if (status.get(identifier).equals(PAV_INIT_STATUS.INACTIVE))
+ return;
- applets.get(identifier).handleMessage(reference, message);
- }
- } catch (Exception e) {
+ applets.get(identifier).handleMessage(reference, message);
+ }
+ } catch (Exception e) {
- e.printStackTrace();
+ e.printStackTrace();
- // If an exception happened during pre-init, we need to update status
- updateStatus(identifier, PAV_INIT_STATUS.INACTIVE);
+ // If an exception happened during pre-init, we need to update status
+ updateStatus(identifier, PAV_INIT_STATUS.INACTIVE);
- throw new RuntimeException("Failed to handle message: " +
+ throw new RuntimeException("Failed to handle message: " +
message + " for instance " + identifier, e);
- }
- }
-
- /**
- * Sets the status unless an overriding status is set (e.g. if
- * status is DESTROYED, it may not be overridden).
- *
- * @param identifier The identifier for which the status is to be set
- * @param status The status to switch to
- * @return The previous status
- */
- private static synchronized PAV_INIT_STATUS updateStatus(int identifier, PAV_INIT_STATUS newStatus) {
-
- PAV_INIT_STATUS prev = status.get(identifier);
-
- // If the status is set
- if (status.containsKey(identifier)) {
-
- // Nothing may override destroyed status
- if (status.get(identifier).equals(PAV_INIT_STATUS.DESTROYED)) {
- return prev;
- }
+ }
+ }
- // If status is inactive, only DESTROYED may override it
- if (status.get(identifier).equals(PAV_INIT_STATUS.INACTIVE)) {
- if (!newStatus.equals(PAV_INIT_STATUS.DESTROYED)) {
- return prev;
- }
- }
- }
+ /**
+ * Sets the status unless an overriding status is set (e.g. if
+ * status is DESTROYED, it may not be overridden).
+ *
+ * @param identifier The identifier for which the status is to be set
+ * @param status The status to switch to
+ * @return The previous status
+ */
+ private static synchronized PAV_INIT_STATUS updateStatus(int identifier, PAV_INIT_STATUS newStatus) {
+
+ PAV_INIT_STATUS prev = status.get(identifier);
+
+ // If the status is set
+ if (status.containsKey(identifier)) {
+
+ // Nothing may override destroyed status
+ if (status.get(identifier).equals(PAV_INIT_STATUS.DESTROYED)) {
+ return prev;
+ }
+
+ // If status is inactive, only DESTROYED may override it
+ if (status.get(identifier).equals(PAV_INIT_STATUS.INACTIVE)) {
+ if (!newStatus.equals(PAV_INIT_STATUS.DESTROYED)) {
+ return prev;
+ }
+ }
+ }
// Else set to given status
status.put(identifier, newStatus);
return prev;
- }
+ }
- /**
- * Destroys the given applet instance.
- *
- * This function may be called multiple times without problems.
- * It does a synchronized check on the status and will only
- * attempt to destroy the applet if not previously destroyed.
- *
- * @param identifier The instance which is to be destroyed
- */
+ /**
+ * Destroys the given applet instance.
+ *
+ * This function may be called multiple times without problems.
+ * It does a synchronized check on the status and will only
+ * attempt to destroy the applet if not previously destroyed.
+ *
+ * @param identifier The instance which is to be destroyed
+ */
- private static synchronized void destroyApplet(int identifier) {
+ private static synchronized void destroyApplet(int identifier) {
- PluginDebug.debug("DestroyApplet called for " + identifier);
+ PluginDebug.debug("DestroyApplet called for " + identifier);
- PAV_INIT_STATUS prev = updateStatus(identifier, PAV_INIT_STATUS.DESTROYED);
+ PAV_INIT_STATUS prev = updateStatus(identifier, PAV_INIT_STATUS.DESTROYED);
- // If already destroyed, return
- if (prev.equals(PAV_INIT_STATUS.DESTROYED)) {
- PluginDebug.debug(identifier + " already destroyed. Returning.");
- return;
- }
+ // If already destroyed, return
+ if (prev.equals(PAV_INIT_STATUS.DESTROYED)) {
+ PluginDebug.debug(identifier + " already destroyed. Returning.");
+ return;
+ }
- PluginDebug.debug("Attempting to destroy frame " + identifier);
+ PluginDebug.debug("Attempting to destroy frame " + identifier);
- // Try to dispose the panel right away
- if (applets.containsKey(identifier))
- applets.get(identifier).dispose();
+ // Try to dispose the panel right away
+ if (applets.containsKey(identifier))
+ applets.get(identifier).dispose();
- // If panel is already disposed, return
- if (applets.get(identifier).panel.applet == null) {
- PluginDebug.debug(identifier + " panel inactive. Returning.");
- return;
- }
+ // If panel is already disposed, return
+ if (applets.get(identifier).panel.applet == null) {
+ PluginDebug.debug(identifier + " panel inactive. Returning.");
+ return;
+ }
- PluginDebug.debug("Attempting to destroy panel " + identifier);
+ PluginDebug.debug("Attempting to destroy panel " + identifier);
- final int fIdentifier = identifier;
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- applets.get(fIdentifier).appletClose();
- }
- });
+ final int fIdentifier = identifier;
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ applets.get(fIdentifier).appletClose();
+ }
+ });
- PluginDebug.debug(identifier + " destroyed");
- }
+ PluginDebug.debug(identifier + " destroyed");
+ }
- /**
- * Function to block until applet initialization is complete
- *
- * @param identifier The instance to wait for
- */
- public static void waitForAppletInit(NetxPanel panel) {
+ /**
+ * Function to block until applet initialization is complete
+ *
+ * @param identifier The instance to wait for
+ */
+ public static void waitForAppletInit(NetxPanel panel) {
- int waitTime = 0;
+ int waitTime = 0;
- // Wait till initialization finishes
- while (panel.getApplet() == null &&
+ // Wait till initialization finishes
+ while (panel.getApplet() == null &&
panel.isAlive() &&
waitTime < APPLET_TIMEOUT) {
- try {
- if (waitTime%500 == 0)
- PluginDebug.debug("Waiting for applet panel " + panel + " to initialize...");
+ try {
+ if (waitTime % 500 == 0)
+ PluginDebug.debug("Waiting for applet panel " + panel + " to initialize...");
- Thread.sleep(waitTime += 50);
- } catch (InterruptedException ie) {
- // just wait
- }
- }
-
- PluginDebug.debug("Applet panel " + panel + " initialized");
- }
-
- public void handleMessage(int reference, String message)
- {
- if (message.startsWith("width")) {
-
- // Wait for panel to come alive
- int maxWait = APPLET_TIMEOUT; // wait for panel to come alive
- int wait = 0;
- while (!status.get(identifier).equals(PAV_INIT_STATUS.INIT_COMPLETE) && wait < maxWait) {
- try {
- Thread.sleep(50);
- wait += 50;
- } catch (InterruptedException ie) {
- // just wait
- }
- }
+ Thread.sleep(waitTime += 50);
+ } catch (InterruptedException ie) {
+ // just wait
+ }
+ }
- // 0 => width, 1=> width_value, 2 => height, 3=> height_value
- String[] dimMsg = message.split(" ");
+ PluginDebug.debug("Applet panel " + panel + " initialized");
+ }
- final int height = Integer.parseInt(dimMsg[3]);
- final int width = Integer.parseInt(dimMsg[1]);
+ public void handleMessage(int reference, String message) {
+ if (message.startsWith("width")) {
+
+ // Wait for panel to come alive
+ int maxWait = APPLET_TIMEOUT; // wait for panel to come alive
+ int wait = 0;
+ while (!status.get(identifier).equals(PAV_INIT_STATUS.INIT_COMPLETE) && wait < maxWait) {
+ try {
+ Thread.sleep(50);
+ wait += 50;
+ } catch (InterruptedException ie) {
+ // just wait
+ }
+ }
+
+ // 0 => width, 1=> width_value, 2 => height, 3=> height_value
+ String[] dimMsg = message.split(" ");
- if (panel instanceof NetxPanel)
- ((NetxPanel) panel).updateSizeInAtts(height, width);
+ final int height = Integer.parseInt(dimMsg[3]);
+ final int width = Integer.parseInt(dimMsg[1]);
- try {
+ if (panel instanceof NetxPanel)
+ ((NetxPanel) panel).updateSizeInAtts(height, width);
+
+ try {
SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
-
- setSize(width, height);
-
- // There is a rather odd drawing bug whereby resizing
- // the panel makes no difference on initial call
- // because the panel thinks that it is already the
- // right size. Validation has no effect there either.
- // So we work around by setting size to 1, validating,
- // and then setting to the right size and validating
- // again. This is not very efficient, and there is
- // probably a better way -- but resizing happens
- // quite infrequently, so for now this is how we do it
-
- panel.setSize(1,1);
- panel.validate();
-
- panel.setSize(width, height);
- panel.validate();
-
- panel.applet.resize(width, height);
- panel.applet.validate();
- }
- });
+ public void run() {
+
+ setSize(width, height);
+
+ // There is a rather odd drawing bug whereby resizing
+ // the panel makes no difference on initial call
+ // because the panel thinks that it is already the
+ // right size. Validation has no effect there either.
+ // So we work around by setting size to 1, validating,
+ // and then setting to the right size and validating
+ // again. This is not very efficient, and there is
+ // probably a better way -- but resizing happens
+ // quite infrequently, so for now this is how we do it
+
+ panel.setSize(1, 1);
+ panel.validate();
+
+ panel.setSize(width, height);
+ panel.validate();
+
+ panel.applet.resize(width, height);
+ panel.applet.validate();
+ }
+ });
} catch (InterruptedException e) {
// do nothing
e.printStackTrace();
@@ -776,780 +768,771 @@ import com.sun.jndi.toolkit.url.UrlUtil;
e.printStackTrace();
}
- } else if (message.startsWith("GetJavaObject")) {
-
- // FIXME: how do we determine what security context this
- // object should belong to?
- Object o;
-
- // Wait for panel to come alive
- int maxWait = APPLET_TIMEOUT; // wait for panel to come alive
- int wait = 0;
- while ((panel == null) || (!((NetxPanel) panel).isAlive() && wait < maxWait)) {
- try {
- Thread.sleep(50);
- wait += 50;
- } catch (InterruptedException ie) {
- // just wait
- }
- }
+ } else if (message.startsWith("GetJavaObject")) {
+
+ // FIXME: how do we determine what security context this
+ // object should belong to?
+ Object o;
+
+ // Wait for panel to come alive
+ int maxWait = APPLET_TIMEOUT; // wait for panel to come alive
+ int wait = 0;
+ while ((panel == null) || (!((NetxPanel) panel).isAlive() && wait < maxWait)) {
+ try {
+ Thread.sleep(50);
+ wait += 50;
+ } catch (InterruptedException ie) {
+ // just wait
+ }
+ }
- // Wait for the panel to initialize
- // (happens in a separate thread)
- waitForAppletInit((NetxPanel) panel);
+ // Wait for the panel to initialize
+ // (happens in a separate thread)
+ waitForAppletInit((NetxPanel) panel);
- PluginDebug.debug(panel + " -- " + panel.getApplet() + " -- " + ((NetxPanel) panel).isAlive());
+ PluginDebug.debug(panel + " -- " + panel.getApplet() + " -- " + ((NetxPanel) panel).isAlive());
- // Still null?
- if (panel.getApplet() == null) {
- this.streamhandler.write("instance " + identifier + " reference " + -1 + " fatalError " + "Initialization failed");
- return;
- }
+ // Still null?
+ if (panel.getApplet() == null) {
+ this.streamhandler.write("instance " + identifier + " reference " + -1 + " fatalError " + "Initialization failed");
+ return;
+ }
- o = panel.getApplet();
- PluginDebug.debug ("Looking for object " + o + " panel is " + panel);
- AppletSecurityContextManager.getSecurityContext(0).store(o);
- PluginDebug.debug ("WRITING 1: " + "context 0 reference " + reference + " GetJavaObject "
+ o = panel.getApplet();
+ PluginDebug.debug("Looking for object " + o + " panel is " + panel);
+ AppletSecurityContextManager.getSecurityContext(0).store(o);
+ PluginDebug.debug("WRITING 1: " + "context 0 reference " + reference + " GetJavaObject "
+ AppletSecurityContextManager.getSecurityContext(0).getIdentifier(o));
- streamhandler.write("context 0 reference " + reference + " GetJavaObject "
+ streamhandler.write("context 0 reference " + reference + " GetJavaObject "
+ AppletSecurityContextManager.getSecurityContext(0).getIdentifier(o));
- PluginDebug.debug ("WRITING 1 DONE");
- }
- }
-
- // FIXME: Kind of hackish way to ensure synchronized re-drawing
- private synchronized void forceredraw() {
- doLayout();
- }
-
- /*
- * Methods for java.applet.AppletContext
- */
-
- private static Map<URL,AudioClip> audioClips = new HashMap<URL,AudioClip>();
-
- /**
- * Get an audio clip.
- */
- public AudioClip getAudioClip(URL url) {
- checkConnect(url);
- synchronized (audioClips) {
- AudioClip clip = audioClips.get(url);
- if (clip == null) {
- audioClips.put(url, clip = new AppletAudioClip(url));
- }
- return clip;
- }
- }
+ PluginDebug.debug("WRITING 1 DONE");
+ }
+ }
+
+ // FIXME: Kind of hackish way to ensure synchronized re-drawing
+ private synchronized void forceredraw() {
+ doLayout();
+ }
+
+ /*
+ * Methods for java.applet.AppletContext
+ */
+
+ private static Map<URL, AudioClip> audioClips = new HashMap<URL, AudioClip>();
+
+ /**
+ * Get an audio clip.
+ */
+ public AudioClip getAudioClip(URL url) {
+ checkConnect(url);
+ synchronized (audioClips) {
+ AudioClip clip = audioClips.get(url);
+ if (clip == null) {
+ audioClips.put(url, clip = new AppletAudioClip(url));
+ }
+ return clip;
+ }
+ }
- private static Map<URL,AppletImageRef> imageRefs = new HashMap<URL,AppletImageRef>();
+ private static Map<URL, AppletImageRef> imageRefs = new HashMap<URL, AppletImageRef>();
- /**
- * Get an image.
- */
- public Image getImage(URL url) {
- return getCachedImage(url);
- }
+ /**
+ * Get an image.
+ */
+ public Image getImage(URL url) {
+ return getCachedImage(url);
+ }
- private Image getCachedImage(URL url) {
- // System.getSecurityManager().checkConnection(url.getHost(), url.getPort());
- return (Image)getCachedImageRef(url).get();
- }
+ private Image getCachedImage(URL url) {
+ // System.getSecurityManager().checkConnection(url.getHost(), url.getPort());
+ return (Image) getCachedImageRef(url).get();
+ }
- /**
- * Get an image ref.
- */
- private synchronized Ref getCachedImageRef(URL url) {
- PluginDebug.debug("getCachedImageRef() searching for " + url);
+ /**
+ * Get an image ref.
+ */
+ private synchronized Ref getCachedImageRef(URL url) {
+ PluginDebug.debug("getCachedImageRef() searching for " + url);
- try {
+ try {
- String originalURL = url.toString();
- String codeBase = panel.getCodeBase().toString();
+ String originalURL = url.toString();
+ String codeBase = panel.getCodeBase().toString();
- if (originalURL.startsWith(codeBase)) {
+ if (originalURL.startsWith(codeBase)) {
- PluginDebug.debug("getCachedImageRef() got URL = " + url);
- PluginDebug.debug("getCachedImageRef() plugin codebase = " + codeBase);
+ PluginDebug.debug("getCachedImageRef() got URL = " + url);
+ PluginDebug.debug("getCachedImageRef() plugin codebase = " + codeBase);
- // try to fetch it locally
- if (panel instanceof NetxPanel) {
+ // try to fetch it locally
+ if (panel instanceof NetxPanel) {
- URL localURL = null;
+ URL localURL = null;
- String resourceName = originalURL.substring(codeBase.length());
- JNLPClassLoader loader = (JNLPClassLoader) ((NetxPanel) panel).getAppletClassLoader();
+ String resourceName = originalURL.substring(codeBase.length());
+ JNLPClassLoader loader = (JNLPClassLoader) ((NetxPanel) panel).getAppletClassLoader();
- if (loader.resourceAvailableLocally(resourceName))
- localURL = loader.getResource(resourceName);
+ if (loader.resourceAvailableLocally(resourceName))
+ localURL = loader.getResource(resourceName);
- url = localURL != null ? localURL : url;
- }
- }
+ url = localURL != null ? localURL : url;
+ }
+ }
- PluginDebug.debug("getCachedImageRef() getting img from URL = " + url);
+ PluginDebug.debug("getCachedImageRef() getting img from URL = " + url);
- synchronized (imageRefs) {
- AppletImageRef ref = imageRefs.get(url);
- if (ref == null) {
- ref = new AppletImageRef(url);
- imageRefs.put(url, ref);
- }
- return ref;
- }
- } catch (Exception e) {
- System.err.println("Error occurred when trying to fetch image:");
- e.printStackTrace();
- return null;
- }
- }
-
- /**
- * Flush the image cache.
- */
- static void flushImageCache() {
+ synchronized (imageRefs) {
+ AppletImageRef ref = imageRefs.get(url);
+ if (ref == null) {
+ ref = new AppletImageRef(url);
+ imageRefs.put(url, ref);
+ }
+ return ref;
+ }
+ } catch (Exception e) {
+ System.err.println("Error occurred when trying to fetch image:");
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ /**
+ * Flush the image cache.
+ */
+ static void flushImageCache() {
imageRefs.clear();
- }
-
- static Vector<AppletPanel> appletPanels = new Vector<AppletPanel>();
-
- /**
- * Get an applet by name.
- */
- public Applet getApplet(String name) {
- name = name.toLowerCase();
- SocketPermission panelSp =
- new SocketPermission(panel.getCodeBase().getHost(), "connect");
- for (Enumeration e = appletPanels.elements() ; e.hasMoreElements() ;) {
- AppletPanel p = (AppletPanel)e.nextElement();
- String param = p.getParameter("name");
- if (param != null) {
- param = param.toLowerCase();
+ }
+
+ static Vector<AppletPanel> appletPanels = new Vector<AppletPanel>();
+
+ /**
+ * Get an applet by name.
+ */
+ public Applet getApplet(String name) {
+ name = name.toLowerCase();
+ SocketPermission panelSp =
+ new SocketPermission(panel.getCodeBase().getHost(), "connect");
+ for (Enumeration e = appletPanels.elements(); e.hasMoreElements();) {
+ AppletPanel p = (AppletPanel) e.nextElement();
+ String param = p.getParameter("name");
+ if (param != null) {
+ param = param.toLowerCase();
+ }
+ if (name.equals(param) &&
+ p.getDocumentBase().equals(panel.getDocumentBase())) {
+
+ SocketPermission sp =
+ new SocketPermission(p.getCodeBase().getHost(), "connect");
+
+ if (panelSp.implies(sp)) {
+ return p.applet;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Return an enumeration of all the accessible
+ * applets on this page.
+ */
+ public Enumeration<Applet> getApplets() {
+ Vector<Applet> v = new Vector<Applet>();
+ SocketPermission panelSp =
+ new SocketPermission(panel.getCodeBase().getHost(), "connect");
+
+ for (Enumeration<AppletPanel> e = appletPanels.elements(); e.hasMoreElements();) {
+ AppletPanel p = e.nextElement();
+ if (p.getDocumentBase().equals(panel.getDocumentBase())) {
+
+ SocketPermission sp =
+ new SocketPermission(p.getCodeBase().getHost(), "connect");
+ if (panelSp.implies(sp)) {
+ v.addElement(p.applet);
+ }
+ }
}
- if (name.equals(param) &&
- p.getDocumentBase().equals(panel.getDocumentBase())) {
+ return v.elements();
+ }
- SocketPermission sp =
- new SocketPermission(p.getCodeBase().getHost(), "connect");
+ /**
+ * Ignore.
+ */
+ public void showDocument(URL url) {
+ PluginDebug.debug("Showing document...");
+ showDocument(url, "_self");
+ }
- if (panelSp.implies(sp)) {
- return p.applet;
+ /**
+ * Ignore.
+ */
+ public void showDocument(URL url, String target) {
+ try {
+ // FIXME: change to postCallRequest
+ write("url " + UrlUtil.encode(url.toString(), "UTF-8") + " " + target);
+ } catch (IOException exception) {
+ // Deliberately ignore IOException. showDocument may be
+ // called from threads other than the main thread after
+ // streamhandler.pluginOutputStream has been closed.
}
+ }
+
+ /**
+ * Show status.
+ */
+ public void showStatus(String status) {
+ try {
+ // FIXME: change to postCallRequest
+ // For statuses, we cannot have a newline
+ status = status.replace("\n", " ");
+ write("status " + status);
+ } catch (IOException exception) {
+ // Deliberately ignore IOException. showStatus may be
+ // called from threads other than the main thread after
+ // streamhandler.pluginOutputStream has been closed.
}
}
- return null;
- }
-
- /**
- * Return an enumeration of all the accessible
- * applets on this page.
- */
- public Enumeration<Applet> getApplets() {
- Vector<Applet> v = new Vector<Applet>();
- SocketPermission panelSp =
- new SocketPermission(panel.getCodeBase().getHost(), "connect");
-
- for (Enumeration<AppletPanel> e = appletPanels.elements() ; e.hasMoreElements() ;) {
- AppletPanel p = e.nextElement();
- if (p.getDocumentBase().equals(panel.getDocumentBase())) {
-
- SocketPermission sp =
- new SocketPermission(p.getCodeBase().getHost(), "connect");
- if (panelSp.implies(sp)) {
- v.addElement(p.applet);
- }
- }
- }
- return v.elements();
- }
-
- /**
- * Ignore.
- */
- public void showDocument(URL url) {
- PluginDebug.debug("Showing document...");
- showDocument(url, "_self");
- }
-
- /**
- * Ignore.
- */
- public void showDocument(URL url, String target) {
- try {
- // FIXME: change to postCallRequest
- write("url " + UrlUtil.encode(url.toString(), "UTF-8") + " " + target);
- } catch (IOException exception) {
- // Deliberately ignore IOException. showDocument may be
- // called from threads other than the main thread after
- // streamhandler.pluginOutputStream has been closed.
- }
- }
-
- /**
- * Show status.
- */
- public void showStatus(String status) {
- try {
- // FIXME: change to postCallRequest
- // For statuses, we cannot have a newline
- status = status.replace("\n", " ");
- write("status " + status);
- } catch (IOException exception) {
- // Deliberately ignore IOException. showStatus may be
- // called from threads other than the main thread after
- // streamhandler.pluginOutputStream has been closed.
- }
- }
-
- /**
- * Returns an incremental number (unique identifier) for a message.
- * If identifier hits Long.MAX_VALUE it loops back starting at 0.
- *
- * @return A unique Long identifier for the request
- */
- private static Long getRequestIdentifier() {
- synchronized (requestIdentityCounter) {
-
- if (requestIdentityCounter == Long.MAX_VALUE)
- requestIdentityCounter = 0L;
-
- return requestIdentityCounter++;
+
+ /**
+ * Returns an incremental number (unique identifier) for a message.
+ * If identifier hits Long.MAX_VALUE it loops back starting at 0.
+ *
+ * @return A unique Long identifier for the request
+ */
+ private static Long getRequestIdentifier() {
+ synchronized (requestIdentityCounter) {
+
+ if (requestIdentityCounter == Long.MAX_VALUE)
+ requestIdentityCounter = 0L;
+
+ return requestIdentityCounter++;
}
- }
-
- public long getWindow() {
- PluginDebug.debug ("STARTING getWindow");
- Long reference = getRequestIdentifier();
-
- PluginCallRequest request = requestFactory.getPluginCallRequest("window",
- "instance " + identifier + " reference " +
- + reference + " " + "GetWindow", reference);
-
- PluginDebug.debug ("STARTING postCallRequest");
- streamhandler.postCallRequest(request);
- PluginDebug.debug ("STARTING postCallRequest done");
- streamhandler.write(request.getMessage());
- try {
- PluginDebug.debug ("wait request 1");
- synchronized(request) {
- PluginDebug.debug ("wait request 2");
- while ((Long) request.getObject() == 0)
- request.wait();
- PluginDebug.debug ("wait request 3");
- }
- } catch (InterruptedException e) {
- throw new RuntimeException("Interrupted waiting for call request.",
+ }
+
+ public long getWindow() {
+ PluginDebug.debug("STARTING getWindow");
+ Long reference = getRequestIdentifier();
+
+ PluginCallRequest request = requestFactory.getPluginCallRequest("window",
+ "instance " + identifier + " reference " +
+ +reference + " " + "GetWindow", reference);
+
+ PluginDebug.debug("STARTING postCallRequest");
+ streamhandler.postCallRequest(request);
+ PluginDebug.debug("STARTING postCallRequest done");
+ streamhandler.write(request.getMessage());
+ try {
+ PluginDebug.debug("wait request 1");
+ synchronized (request) {
+ PluginDebug.debug("wait request 2");
+ while ((Long) request.getObject() == 0)
+ request.wait();
+ PluginDebug.debug("wait request 3");
+ }
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Interrupted waiting for call request.",
e);
- }
-
- PluginDebug.debug ("STARTING getWindow DONE");
- return (Long) request.getObject();
- }
-
- // FIXME: make private, access via reflection.
- public static Object getMember(long internal, String name)
- {
- AppletSecurityContextManager.getSecurityContext(0).store(name);
- int nameID = AppletSecurityContextManager.getSecurityContext(0).getIdentifier(name);
- Long reference = getRequestIdentifier();
-
- // Prefix with dummy instance for convenience.
- PluginCallRequest request = requestFactory.getPluginCallRequest("member",
- "instance " + 0 + " reference " + reference + " GetMember " +
- internal + " " + nameID, reference);
-
- streamhandler.postCallRequest(request);
- streamhandler.write(request.getMessage());
- try {
- PluginDebug.debug ("wait getMEM request 1");
- synchronized(request) {
- PluginDebug.debug ("wait getMEM request 2");
- while (request.isDone() == false)
- request.wait();
- PluginDebug.debug ("wait getMEM request 3 GOT: " + request.getObject().getClass());
- }
- } catch (InterruptedException e) {
- throw new RuntimeException("Interrupted waiting for call request.",
+ }
+
+ PluginDebug.debug("STARTING getWindow DONE");
+ return (Long) request.getObject();
+ }
+
+ // FIXME: make private, access via reflection.
+ public static Object getMember(long internal, String name) {
+ AppletSecurityContextManager.getSecurityContext(0).store(name);
+ int nameID = AppletSecurityContextManager.getSecurityContext(0).getIdentifier(name);
+ Long reference = getRequestIdentifier();
+
+ // Prefix with dummy instance for convenience.
+ PluginCallRequest request = requestFactory.getPluginCallRequest("member",
+ "instance " + 0 + " reference " + reference + " GetMember " +
+ internal + " " + nameID, reference);
+
+ streamhandler.postCallRequest(request);
+ streamhandler.write(request.getMessage());
+ try {
+ PluginDebug.debug("wait getMEM request 1");
+ synchronized (request) {
+ PluginDebug.debug("wait getMEM request 2");
+ while (request.isDone() == false)
+ request.wait();
+ PluginDebug.debug("wait getMEM request 3 GOT: " + request.getObject().getClass());
+ }
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Interrupted waiting for call request.",
e);
- }
- PluginDebug.debug (" getMember DONE");
- return request.getObject();
- }
-
- public static void setMember(long internal, String name, Object value) {
- System.err.println("Setting to class " + value.getClass() + ":" + value.getClass().isPrimitive());
- AppletSecurityContextManager.getSecurityContext(0).store(name);
- int nameID = AppletSecurityContextManager.getSecurityContext(0).getIdentifier(name);
- Long reference = getRequestIdentifier();
-
- // work on a copy of value, as we don't want to be manipulating
- // complex objects
- String valueToSetTo;
- if (value instanceof java.lang.Byte ||
- value instanceof java.lang.Character ||
- value instanceof java.lang.Short ||
- value instanceof java.lang.Integer ||
- value instanceof java.lang.Long ||
- value instanceof java.lang.Float ||
- value instanceof java.lang.Double ||
- value instanceof java.lang.Boolean) {
-
- valueToSetTo = "literalreturn " + value.toString();
-
- // Character -> Str results in str value.. we need int value as
- // per specs.
- if (value instanceof java.lang.Character) {
- valueToSetTo = "literalreturn " + (int) ((java.lang.Character) value).charValue();
- } else if (value instanceof Float ||
+ }
+ PluginDebug.debug(" getMember DONE");
+ return request.getObject();
+ }
+
+ public static void setMember(long internal, String name, Object value) {
+ System.err.println("Setting to class " + value.getClass() + ":" + value.getClass().isPrimitive());
+ AppletSecurityContextManager.getSecurityContext(0).store(name);
+ int nameID = AppletSecurityContextManager.getSecurityContext(0).getIdentifier(name);
+ Long reference = getRequestIdentifier();
+
+ // work on a copy of value, as we don't want to be manipulating
+ // complex objects
+ String valueToSetTo;
+ if (value instanceof java.lang.Byte ||
+ value instanceof java.lang.Character ||
+ value instanceof java.lang.Short ||
+ value instanceof java.lang.Integer ||
+ value instanceof java.lang.Long ||
+ value instanceof java.lang.Float ||
+ value instanceof java.lang.Double ||
+ value instanceof java.lang.Boolean) {
+
+ valueToSetTo = "literalreturn " + value.toString();
+
+ // Character -> Str results in str value.. we need int value as
+ // per specs.
+ if (value instanceof java.lang.Character) {
+ valueToSetTo = "literalreturn " + (int) ((java.lang.Character) value).charValue();
+ } else if (value instanceof Float ||
value instanceof Double) {
- valueToSetTo = "literalreturn " + String.format("%308.308e", value);
- }
+ valueToSetTo = "literalreturn " + String.format("%308.308e", value);
+ }
- } else {
- AppletSecurityContextManager.getSecurityContext(0).store(value);
- valueToSetTo = Integer.toString(AppletSecurityContextManager.getSecurityContext(0).getIdentifier(value));
- }
-
- // Prefix with dummy instance for convenience.
- PluginCallRequest request = requestFactory.getPluginCallRequest("void",
- "instance " + 0 + " reference " + reference + " SetMember " +
- internal + " " + nameID + " " + valueToSetTo, reference);
-
- streamhandler.postCallRequest(request);
- streamhandler.write(request.getMessage());
- try {
- PluginDebug.debug ("wait setMem request: " + request.getMessage());
- PluginDebug.debug ("wait setMem request 1");
- synchronized(request) {
- PluginDebug.debug ("wait setMem request 2");
- while (request.isDone() == false)
- request.wait();
- PluginDebug.debug ("wait setMem request 3");
- }
- } catch (InterruptedException e) {
- throw new RuntimeException("Interrupted waiting for call request.",
+ } else {
+ AppletSecurityContextManager.getSecurityContext(0).store(value);
+ valueToSetTo = Integer.toString(AppletSecurityContextManager.getSecurityContext(0).getIdentifier(value));
+ }
+
+ // Prefix with dummy instance for convenience.
+ PluginCallRequest request = requestFactory.getPluginCallRequest("void",
+ "instance " + 0 + " reference " + reference + " SetMember " +
+ internal + " " + nameID + " " + valueToSetTo, reference);
+
+ streamhandler.postCallRequest(request);
+ streamhandler.write(request.getMessage());
+ try {
+ PluginDebug.debug("wait setMem request: " + request.getMessage());
+ PluginDebug.debug("wait setMem request 1");
+ synchronized (request) {
+ PluginDebug.debug("wait setMem request 2");
+ while (request.isDone() == false)
+ request.wait();
+ PluginDebug.debug("wait setMem request 3");
+ }
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Interrupted waiting for call request.",
e);
- }
- PluginDebug.debug (" setMember DONE");
- }
-
- // FIXME: handle long index as well.
- public static void setSlot(long internal, int index, Object value) {
- AppletSecurityContextManager.getSecurityContext(0).store(value);
- Long reference = getRequestIdentifier();
-
- // work on a copy of value, as we don't want to be manipulating
- // complex objects
- String valueToSetTo;
- if (value instanceof java.lang.Byte ||
- value instanceof java.lang.Character ||
- value instanceof java.lang.Short ||
- value instanceof java.lang.Integer ||
- value instanceof java.lang.Long ||
- value instanceof java.lang.Float ||
- value instanceof java.lang.Double ||
- value instanceof java.lang.Boolean) {
-
- valueToSetTo = "literalreturn " + value.toString();
-
- // Character -> Str results in str value.. we need int value as
- // per specs.
- if (value instanceof java.lang.Character) {
- valueToSetTo = "literalreturn " + (int) ((java.lang.Character) value).charValue();
- } else if (value instanceof Float ||
+ }
+ PluginDebug.debug(" setMember DONE");
+ }
+
+ // FIXME: handle long index as well.
+ public static void setSlot(long internal, int index, Object value) {
+ AppletSecurityContextManager.getSecurityContext(0).store(value);
+ Long reference = getRequestIdentifier();
+
+ // work on a copy of value, as we don't want to be manipulating
+ // complex objects
+ String valueToSetTo;
+ if (value instanceof java.lang.Byte ||
+ value instanceof java.lang.Character ||
+ value instanceof java.lang.Short ||
+ value instanceof java.lang.Integer ||
+ value instanceof java.lang.Long ||
+ value instanceof java.lang.Float ||
+ value instanceof java.lang.Double ||
+ value instanceof java.lang.Boolean) {
+
+ valueToSetTo = "literalreturn " + value.toString();
+
+ // Character -> Str results in str value.. we need int value as
+ // per specs.
+ if (value instanceof java.lang.Character) {
+ valueToSetTo = "literalreturn " + (int) ((java.lang.Character) value).charValue();
+ } else if (value instanceof Float ||
value instanceof Double) {
- valueToSetTo = "literalreturn " + String.format("%308.308e", value);
- }
+ valueToSetTo = "literalreturn " + String.format("%308.308e", value);
+ }
- } else {
- AppletSecurityContextManager.getSecurityContext(0).store(value);
- valueToSetTo = Integer.toString(AppletSecurityContextManager.getSecurityContext(0).getIdentifier(value));
- }
-
- // Prefix with dummy instance for convenience.
- PluginCallRequest request = requestFactory.getPluginCallRequest("void",
- "instance " + 0 + " reference " + reference + " SetSlot " +
- internal + " " + index + " " + valueToSetTo, reference);
-
- streamhandler.postCallRequest(request);
- streamhandler.write(request.getMessage());
- try {
- PluginDebug.debug ("wait setSlot request 1");
- synchronized(request) {
- PluginDebug.debug ("wait setSlot request 2");
- while (request.isDone() == false)
- request.wait();
- PluginDebug.debug ("wait setSlot request 3");
- }
- } catch (InterruptedException e) {
- throw new RuntimeException("Interrupted waiting for call request.",
+ } else {
+ AppletSecurityContextManager.getSecurityContext(0).store(value);
+ valueToSetTo = Integer.toString(AppletSecurityContextManager.getSecurityContext(0).getIdentifier(value));
+ }
+
+ // Prefix with dummy instance for convenience.
+ PluginCallRequest request = requestFactory.getPluginCallRequest("void",
+ "instance " + 0 + " reference " + reference + " SetSlot " +
+ internal + " " + index + " " + valueToSetTo, reference);
+
+ streamhandler.postCallRequest(request);
+ streamhandler.write(request.getMessage());
+ try {
+ PluginDebug.debug("wait setSlot request 1");
+ synchronized (request) {
+ PluginDebug.debug("wait setSlot request 2");
+ while (request.isDone() == false)
+ request.wait();
+ PluginDebug.debug("wait setSlot request 3");
+ }
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Interrupted waiting for call request.",
e);
- }
- PluginDebug.debug (" setSlot DONE");
- }
-
- public static Object getSlot(long internal, int index)
- {
- Long reference = getRequestIdentifier();
-
- // Prefix with dummy instance for convenience.
- PluginCallRequest request = requestFactory.getPluginCallRequest("member",
- "instance " + 0 + " reference " + reference + " GetSlot " +
- internal + " " + index, reference);
- streamhandler.postCallRequest(request);
- streamhandler.write(request.getMessage());
- try {
- PluginDebug.debug ("wait getSlot request 1");
- synchronized(request) {
- PluginDebug.debug ("wait getSlot request 2");
- while (request.isDone() == false)
- request.wait();
- PluginDebug.debug ("wait getSlot request 3");
- }
- } catch (InterruptedException e) {
- throw new RuntimeException("Interrupted waiting for call request.",
+ }
+ PluginDebug.debug(" setSlot DONE");
+ }
+
+ public static Object getSlot(long internal, int index) {
+ Long reference = getRequestIdentifier();
+
+ // Prefix with dummy instance for convenience.
+ PluginCallRequest request = requestFactory.getPluginCallRequest("member",
+ "instance " + 0 + " reference " + reference + " GetSlot " +
+ internal + " " + index, reference);
+ streamhandler.postCallRequest(request);
+ streamhandler.write(request.getMessage());
+ try {
+ PluginDebug.debug("wait getSlot request 1");
+ synchronized (request) {
+ PluginDebug.debug("wait getSlot request 2");
+ while (request.isDone() == false)
+ request.wait();
+ PluginDebug.debug("wait getSlot request 3");
+ }
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Interrupted waiting for call request.",
e);
- }
- PluginDebug.debug (" getSlot DONE");
- return request.getObject();
- }
-
- public static Object eval(long internal, String s)
- {
- AppletSecurityContextManager.getSecurityContext(0).store(s);
- int stringID = AppletSecurityContextManager.getSecurityContext(0).getIdentifier(s);
- Long reference = getRequestIdentifier();
-
- // Prefix with dummy instance for convenience.
- // FIXME: rename GetMemberPluginCallRequest ObjectPluginCallRequest.
- PluginCallRequest request = requestFactory.getPluginCallRequest("member",
- "instance " + 0 + " reference " + reference + " Eval " +
- internal + " " + stringID, reference);
- streamhandler.postCallRequest(request);
- streamhandler.write(request.getMessage());
- try {
- PluginDebug.debug ("wait eval request 1");
- synchronized(request) {
- PluginDebug.debug ("wait eval request 2");
- while (request.isDone() == false)
- request.wait();
- PluginDebug.debug ("wait eval request 3");
- }
- } catch (InterruptedException e) {
- throw new RuntimeException("Interrupted waiting for call request.",
+ }
+ PluginDebug.debug(" getSlot DONE");
+ return request.getObject();
+ }
+
+ public static Object eval(long internal, String s) {
+ AppletSecurityContextManager.getSecurityContext(0).store(s);
+ int stringID = AppletSecurityContextManager.getSecurityContext(0).getIdentifier(s);
+ Long reference = getRequestIdentifier();
+
+ // Prefix with dummy instance for convenience.
+ // FIXME: rename GetMemberPluginCallRequest ObjectPluginCallRequest.
+ PluginCallRequest request = requestFactory.getPluginCallRequest("member",
+ "instance " + 0 + " reference " + reference + " Eval " +
+ internal + " " + stringID, reference);
+ streamhandler.postCallRequest(request);
+ streamhandler.write(request.getMessage());
+ try {
+ PluginDebug.debug("wait eval request 1");
+ synchronized (request) {
+ PluginDebug.debug("wait eval request 2");
+ while (request.isDone() == false)
+ request.wait();
+ PluginDebug.debug("wait eval request 3");
+ }
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Interrupted waiting for call request.",
e);
- }
- PluginDebug.debug (" getSlot DONE");
- return request.getObject();
- }
-
- public static void removeMember (long internal, String name) {
- AppletSecurityContextManager.getSecurityContext(0).store(name);
- int nameID = AppletSecurityContextManager.getSecurityContext(0).getIdentifier(name);
- Long reference = getRequestIdentifier();
-
- // Prefix with dummy instance for convenience.
- PluginCallRequest request = requestFactory.getPluginCallRequest("void",
- "instance " + 0 + " reference " + reference + " RemoveMember " +
- internal + " " + nameID, reference);
-
- streamhandler.postCallRequest(request);
- streamhandler.write(request.getMessage());
- try {
- PluginDebug.debug ("wait removeMember request 1");
- synchronized(request) {
- PluginDebug.debug ("wait removeMember request 2");
- while (request.isDone() == false)
- request.wait();
- PluginDebug.debug ("wait removeMember request 3");
- }
- } catch (InterruptedException e) {
- throw new RuntimeException("Interrupted waiting for call request.",
+ }
+ PluginDebug.debug(" getSlot DONE");
+ return request.getObject();
+ }
+
+ public static void removeMember(long internal, String name) {
+ AppletSecurityContextManager.getSecurityContext(0).store(name);
+ int nameID = AppletSecurityContextManager.getSecurityContext(0).getIdentifier(name);
+ Long reference = getRequestIdentifier();
+
+ // Prefix with dummy instance for convenience.
+ PluginCallRequest request = requestFactory.getPluginCallRequest("void",
+ "instance " + 0 + " reference " + reference + " RemoveMember " +
+ internal + " " + nameID, reference);
+
+ streamhandler.postCallRequest(request);
+ streamhandler.write(request.getMessage());
+ try {
+ PluginDebug.debug("wait removeMember request 1");
+ synchronized (request) {
+ PluginDebug.debug("wait removeMember request 2");
+ while (request.isDone() == false)
+ request.wait();
+ PluginDebug.debug("wait removeMember request 3");
+ }
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Interrupted waiting for call request.",
e);
- }
- PluginDebug.debug (" RemoveMember DONE");
- }
-
- public static Object call(long internal, String name, Object args[])
- {
- // FIXME: when is this removed from the object store?
- // FIXME: reference should return the ID.
- // FIXME: convenience method for this long line.
- AppletSecurityContextManager.getSecurityContext(0).store(name);
- int nameID = AppletSecurityContextManager.getSecurityContext(0).getIdentifier(name);
- Long reference = getRequestIdentifier();
-
- String argIDs = "";
- for (Object arg : args)
- {
- AppletSecurityContextManager.getSecurityContext(0).store(arg);
- argIDs += AppletSecurityContextManager.getSecurityContext(0).getIdentifier(arg) + " ";
- }
- argIDs = argIDs.trim();
-
- // Prefix with dummy instance for convenience.
- PluginCallRequest request = requestFactory.getPluginCallRequest("member",
- "instance " + 0 + " reference " + reference + " Call " +
- internal + " " + nameID + " " + argIDs, reference);
-
- streamhandler.postCallRequest(request);
- streamhandler.write(request.getMessage());
- try {
- PluginDebug.debug ("wait call request 1");
- synchronized(request) {
- PluginDebug.debug ("wait call request 2");
- while (request.isDone() == false)
- request.wait();
- PluginDebug.debug ("wait call request 3");
- }
- } catch (InterruptedException e) {
- throw new RuntimeException("Interrupted waiting for call request.",
+ }
+ PluginDebug.debug(" RemoveMember DONE");
+ }
+
+ public static Object call(long internal, String name, Object args[]) {
+ // FIXME: when is this removed from the object store?
+ // FIXME: reference should return the ID.
+ // FIXME: convenience method for this long line.
+ AppletSecurityContextManager.getSecurityContext(0).store(name);
+ int nameID = AppletSecurityContextManager.getSecurityContext(0).getIdentifier(name);
+ Long reference = getRequestIdentifier();
+
+ String argIDs = "";
+ for (Object arg : args) {
+ AppletSecurityContextManager.getSecurityContext(0).store(arg);
+ argIDs += AppletSecurityContextManager.getSecurityContext(0).getIdentifier(arg) + " ";
+ }
+ argIDs = argIDs.trim();
+
+ // Prefix with dummy instance for convenience.
+ PluginCallRequest request = requestFactory.getPluginCallRequest("member",
+ "instance " + 0 + " reference " + reference + " Call " +
+ internal + " " + nameID + " " + argIDs, reference);
+
+ streamhandler.postCallRequest(request);
+ streamhandler.write(request.getMessage());
+ try {
+ PluginDebug.debug("wait call request 1");
+ synchronized (request) {
+ PluginDebug.debug("wait call request 2");
+ while (request.isDone() == false)
+ request.wait();
+ PluginDebug.debug("wait call request 3");
+ }
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Interrupted waiting for call request.",
e);
- }
- PluginDebug.debug (" Call DONE");
- return request.getObject();
- }
+ }
+ PluginDebug.debug(" Call DONE");
+ return request.getObject();
+ }
- public static Object requestPluginCookieInfo(URI uri) {
+ public static Object requestPluginCookieInfo(URI uri) {
- PluginCallRequest request;
- Long reference = getRequestIdentifier();
+ PluginCallRequest request;
+ Long reference = getRequestIdentifier();
- try
- {
- String encodedURI = UrlUtil.encode(uri.toString(), "UTF-8");
- request = requestFactory.getPluginCallRequest("cookieinfo",
- "plugin PluginCookieInfo " + "reference " + reference +
- " " + encodedURI, reference);
+ try {
+ String encodedURI = UrlUtil.encode(uri.toString(), "UTF-8");
+ request = requestFactory.getPluginCallRequest("cookieinfo",
+ "plugin PluginCookieInfo " + "reference " + reference +
+ " " + encodedURI, reference);
+
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ return null;
+ }
- } catch (UnsupportedEncodingException e)
- {
- e.printStackTrace();
- return null;
- }
-
- PluginMessageConsumer.registerPriorityWait(reference);
- streamhandler.postCallRequest(request);
- streamhandler.write(request.getMessage());
- try {
- PluginDebug.debug ("wait cookieinfo request 1");
- synchronized(request) {
- PluginDebug.debug ("wait cookieinfo request 2");
- while (request.isDone() == false)
- request.wait();
- PluginDebug.debug ("wait cookieinfo request 3");
- }
- } catch (InterruptedException e) {
- throw new RuntimeException("Interrupted waiting for cookieinfo request.",
- e);
- }
- PluginDebug.debug (" Cookieinfo DONE");
- return request.getObject();
- }
-
- public static Object requestPluginProxyInfo(URI uri) {
-
- String requestURI = null;
- Long reference = getRequestIdentifier();
-
- try {
-
- // there is no easy way to get SOCKS proxy info. So, we tell mozilla that we want proxy for
- // an HTTP uri in case of non http/ftp protocols. If we get back a SOCKS proxy, we can
- // use that, if we get back an http proxy, we fallback to DIRECT connect
-
- String scheme = uri.getScheme();
- String port = uri.getPort() != -1 ? ":" + uri.getPort() : "";
- if (!uri.getScheme().startsWith("http") && !uri.getScheme().equals("ftp"))
- scheme = "http";
-
- requestURI = UrlUtil.encode(scheme + "://" + uri.getHost() + port + "/" + uri.getPath(), "UTF-8");
- } catch (Exception e) {
- PluginDebug.debug("Cannot construct URL from " + uri.toString() + " ... falling back to DIRECT proxy");
- e.printStackTrace();
- return null;
- }
-
- PluginCallRequest request = requestFactory.getPluginCallRequest("proxyinfo",
- "plugin PluginProxyInfo reference " + reference + " " +
- requestURI, reference);
-
- PluginMessageConsumer.registerPriorityWait(reference);
- streamhandler.postCallRequest(request);
- streamhandler.write(request.getMessage());
- try {
- PluginDebug.debug ("wait call request 1");
- synchronized(request) {
- PluginDebug.debug ("wait call request 2");
- while (request.isDone() == false)
- request.wait();
- PluginDebug.debug ("wait call request 3");
- }
- } catch (InterruptedException e) {
- throw new RuntimeException("Interrupted waiting for call request.",
+ PluginMessageConsumer.registerPriorityWait(reference);
+ streamhandler.postCallRequest(request);
+ streamhandler.write(request.getMessage());
+ try {
+ PluginDebug.debug("wait cookieinfo request 1");
+ synchronized (request) {
+ PluginDebug.debug("wait cookieinfo request 2");
+ while (request.isDone() == false)
+ request.wait();
+ PluginDebug.debug("wait cookieinfo request 3");
+ }
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Interrupted waiting for cookieinfo request.",
e);
- }
- PluginDebug.debug (" Call DONE");
- return request.getObject();
- }
-
- public static void JavaScriptFinalize(long internal)
- {
- Long reference = getRequestIdentifier();
-
- // Prefix with dummy instance for convenience.
- PluginCallRequest request = requestFactory.getPluginCallRequest("void",
- "instance " + 0 + " reference " + reference + " Finalize " +
- internal, reference);
-
- streamhandler.postCallRequest(request);
- streamhandler.write(request.getMessage());
- try {
- PluginDebug.debug ("wait finalize request 1");
- synchronized(request) {
- PluginDebug.debug ("wait finalize request 2");
- while (request.isDone() == false)
- request.wait();
- PluginDebug.debug ("wait finalize request 3");
- }
- } catch (InterruptedException e) {
- throw new RuntimeException("Interrupted waiting for call request.",
+ }
+ PluginDebug.debug(" Cookieinfo DONE");
+ return request.getObject();
+ }
+
+ public static Object requestPluginProxyInfo(URI uri) {
+
+ String requestURI = null;
+ Long reference = getRequestIdentifier();
+
+ try {
+
+ // there is no easy way to get SOCKS proxy info. So, we tell mozilla that we want proxy for
+ // an HTTP uri in case of non http/ftp protocols. If we get back a SOCKS proxy, we can
+ // use that, if we get back an http proxy, we fallback to DIRECT connect
+
+ String scheme = uri.getScheme();
+ String port = uri.getPort() != -1 ? ":" + uri.getPort() : "";
+ if (!uri.getScheme().startsWith("http") && !uri.getScheme().equals("ftp"))
+ scheme = "http";
+
+ requestURI = UrlUtil.encode(scheme + "://" + uri.getHost() + port + "/" + uri.getPath(), "UTF-8");
+ } catch (Exception e) {
+ PluginDebug.debug("Cannot construct URL from " + uri.toString() + " ... falling back to DIRECT proxy");
+ e.printStackTrace();
+ return null;
+ }
+
+ PluginCallRequest request = requestFactory.getPluginCallRequest("proxyinfo",
+ "plugin PluginProxyInfo reference " + reference + " " +
+ requestURI, reference);
+
+ PluginMessageConsumer.registerPriorityWait(reference);
+ streamhandler.postCallRequest(request);
+ streamhandler.write(request.getMessage());
+ try {
+ PluginDebug.debug("wait call request 1");
+ synchronized (request) {
+ PluginDebug.debug("wait call request 2");
+ while (request.isDone() == false)
+ request.wait();
+ PluginDebug.debug("wait call request 3");
+ }
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Interrupted waiting for call request.",
e);
- }
- PluginDebug.debug (" finalize DONE");
- }
-
- public static String javascriptToString(long internal)
- {
- Long reference = getRequestIdentifier();
-
- // Prefix with dummy instance for convenience.
- PluginCallRequest request = requestFactory.getPluginCallRequest("member",
- "instance " + 0 + " reference " + reference + " ToString " +
- internal, reference);
-
- streamhandler.postCallRequest(request);
- streamhandler.write(request.getMessage());
- try {
- PluginDebug.debug ("wait ToString request 1");
- synchronized(request) {
- PluginDebug.debug ("wait ToString request 2");
- while (request.isDone() == false)
- request.wait();
- PluginDebug.debug ("wait ToString request 3");
- }
- } catch (InterruptedException e) {
- throw new RuntimeException("Interrupted waiting for call request.",
+ }
+ PluginDebug.debug(" Call DONE");
+ return request.getObject();
+ }
+
+ public static void JavaScriptFinalize(long internal) {
+ Long reference = getRequestIdentifier();
+
+ // Prefix with dummy instance for convenience.
+ PluginCallRequest request = requestFactory.getPluginCallRequest("void",
+ "instance " + 0 + " reference " + reference + " Finalize " +
+ internal, reference);
+
+ streamhandler.postCallRequest(request);
+ streamhandler.write(request.getMessage());
+ try {
+ PluginDebug.debug("wait finalize request 1");
+ synchronized (request) {
+ PluginDebug.debug("wait finalize request 2");
+ while (request.isDone() == false)
+ request.wait();
+ PluginDebug.debug("wait finalize request 3");
+ }
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Interrupted waiting for call request.",
e);
- }
- PluginDebug.debug (" ToString DONE");
- return (String) request.getObject();
- }
-
- // FIXME: make this private and access it from JSObject using
- // reflection.
- private void write(String message) throws IOException {
- PluginDebug.debug ("WRITING 2: " + "instance " + identifier + " " + message);
- streamhandler.write("instance " + identifier + " " + message);
- PluginDebug.debug ("WRITING 2 DONE");
- }
-
- public void setStream(String key, InputStream stream)throws IOException{
- // We do nothing.
- }
-
- @Override
- public InputStream getStream(String key){
- // We do nothing.
- return null;
- }
-
- @Override
- public Iterator<String> getStreamKeys(){
- // We do nothing.
- return null;
- }
-
- /**
- * System parameters.
- */
- static Hashtable<String,String> systemParam = new Hashtable<String,String>();
-
- static {
- systemParam.put("codebase", "codebase");
- systemParam.put("code", "code");
- systemParam.put("alt", "alt");
- systemParam.put("width", "width");
- systemParam.put("height", "height");
- systemParam.put("align", "align");
- systemParam.put("vspace", "vspace");
- systemParam.put("hspace", "hspace");
- }
-
- /**
- * Print the HTML tag.
- */
- public static void printTag(PrintStream out, Hashtable<String,String> atts) {
- out.print("<applet");
-
- String v = atts.get("codebase");
- if (v != null) {
- out.print(" codebase=\"" + v + "\"");
- }
-
- v = atts.get("code");
- if (v == null) {
- v = "applet.class";
- }
- out.print(" code=\"" + v + "\"");
- v = atts.get("width");
- if (v == null) {
- v = "150";
- }
- out.print(" width=" + v);
-
- v = atts.get("height");
- if (v == null) {
- v = "100";
- }
- out.print(" height=" + v);
-
- v = atts.get("name");
- if (v != null) {
- out.print(" name=\"" + v + "\"");
- }
- out.println(">");
-
- // A very slow sorting algorithm
- int len = atts.size();
- String params[] = new String[len];
- len = 0;
- for (Enumeration<String> e = atts.keys() ; e.hasMoreElements() ;) {
- String param = e.nextElement();
- int i = 0;
- for (; i < len ; i++) {
- if (params[i].compareTo(param) >= 0) {
- break;
+ }
+ PluginDebug.debug(" finalize DONE");
+ }
+
+ public static String javascriptToString(long internal) {
+ Long reference = getRequestIdentifier();
+
+ // Prefix with dummy instance for convenience.
+ PluginCallRequest request = requestFactory.getPluginCallRequest("member",
+ "instance " + 0 + " reference " + reference + " ToString " +
+ internal, reference);
+
+ streamhandler.postCallRequest(request);
+ streamhandler.write(request.getMessage());
+ try {
+ PluginDebug.debug("wait ToString request 1");
+ synchronized (request) {
+ PluginDebug.debug("wait ToString request 2");
+ while (request.isDone() == false)
+ request.wait();
+ PluginDebug.debug("wait ToString request 3");
}
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Interrupted waiting for call request.",
+ e);
}
- System.arraycopy(params, i, params, i + 1, len - i);
- params[i] = param;
- len++;
+ PluginDebug.debug(" ToString DONE");
+ return (String) request.getObject();
+ }
+
+ // FIXME: make this private and access it from JSObject using
+ // reflection.
+ private void write(String message) throws IOException {
+ PluginDebug.debug("WRITING 2: " + "instance " + identifier + " " + message);
+ streamhandler.write("instance " + identifier + " " + message);
+ PluginDebug.debug("WRITING 2 DONE");
+ }
+
+ public void setStream(String key, InputStream stream) throws IOException {
+ // We do nothing.
+ }
+
+ @Override
+ public InputStream getStream(String key) {
+ // We do nothing.
+ return null;
+ }
+
+ @Override
+ public Iterator<String> getStreamKeys() {
+ // We do nothing.
+ return null;
}
- for (int i = 0 ; i < len ; i++) {
- String param = params[i];
- if (systemParam.get(param) == null) {
- out.println("<param name=" + param +
- " value=\"" + atts.get(param) + "\">");
+ /**
+ * System parameters.
+ */
+ static Hashtable<String, String> systemParam = new Hashtable<String, String>();
+
+ static {
+ systemParam.put("codebase", "codebase");
+ systemParam.put("code", "code");
+ systemParam.put("alt", "alt");
+ systemParam.put("width", "width");
+ systemParam.put("height", "height");
+ systemParam.put("align", "align");
+ systemParam.put("vspace", "vspace");
+ systemParam.put("hspace", "hspace");
+ }
+
+ /**
+ * Print the HTML tag.
+ */
+ public static void printTag(PrintStream out, Hashtable<String, String> atts) {
+ out.print("<applet");
+
+ String v = atts.get("codebase");
+ if (v != null) {
+ out.print(" codebase=\"" + v + "\"");
+ }
+
+ v = atts.get("code");
+ if (v == null) {
+ v = "applet.class";
+ }
+ out.print(" code=\"" + v + "\"");
+ v = atts.get("width");
+ if (v == null) {
+ v = "150";
+ }
+ out.print(" width=" + v);
+
+ v = atts.get("height");
+ if (v == null) {
+ v = "100";
+ }
+ out.print(" height=" + v);
+
+ v = atts.get("name");
+ if (v != null) {
+ out.print(" name=\"" + v + "\"");
+ }
+ out.println(">");
+
+ // A very slow sorting algorithm
+ int len = atts.size();
+ String params[] = new String[len];
+ len = 0;
+ for (Enumeration<String> e = atts.keys(); e.hasMoreElements();) {
+ String param = e.nextElement();
+ int i = 0;
+ for (; i < len; i++) {
+ if (params[i].compareTo(param) >= 0) {
+ break;
+ }
+ }
+ System.arraycopy(params, i, params, i + 1, len - i);
+ params[i] = param;
+ len++;
}
+
+ for (int i = 0; i < len; i++) {
+ String param = params[i];
+ if (systemParam.get(param) == null) {
+ out.println("<param name=" + param +
+ " value=\"" + atts.get(param) + "\">");
+ }
+ }
+ out.println("</applet>");
}
- out.println("</applet>");
- }
- /**
- * Make sure the atrributes are uptodate.
- */
+ /**
+ * Make sure the atrributes are uptodate.
+ */
public void updateAtts() {
Dimension d = panel.getSize();
Insets in = panel.getInsets();
@@ -1557,100 +1540,100 @@ import com.sun.jndi.toolkit.url.UrlUtil;
Integer.valueOf(d.width - (in.left + in.right)).toString());
panel.atts.put("height",
Integer.valueOf(d.height - (in.top + in.bottom)).toString());
- }
-
- /**
- * Restart the applet.
- */
- void appletRestart() {
- panel.sendEvent(AppletPanel.APPLET_STOP);
- panel.sendEvent(AppletPanel.APPLET_DESTROY);
- panel.sendEvent(AppletPanel.APPLET_INIT);
- panel.sendEvent(AppletPanel.APPLET_START);
- }
-
- /**
- * Reload the applet.
- */
- void appletReload() {
- panel.sendEvent(AppletPanel.APPLET_STOP);
- panel.sendEvent(AppletPanel.APPLET_DESTROY);
- panel.sendEvent(AppletPanel.APPLET_DISPOSE);
+ }
/**
- * Fixed #4501142: Classlaoder sharing policy doesn't
- * take "archive" into account. This will be overridden
- * by Java Plug-in. [stanleyh]
+ * Restart the applet.
*/
- AppletPanel.flushClassLoader(panel.getClassLoaderCacheKey());
-
- /*
- * Make sure we don't have two threads running through the event queue
- * at the same time.
- */
- try {
- panel.joinAppletThread();
- panel.release();
- } catch (InterruptedException e) {
- return; // abort the reload
- }
-
- AccessController.doPrivileged(new PrivilegedAction<Void>() {
- public Void run() {
- panel.createAppletThread();
- return null;
- }
- });
-
- panel.sendEvent(AppletPanel.APPLET_LOAD);
- panel.sendEvent(AppletPanel.APPLET_INIT);
- panel.sendEvent(AppletPanel.APPLET_START);
- }
-
- public int print(Graphics graphics, PageFormat pf, int pageIndex) {
- return Printable.NO_SUCH_PAGE;
- }
-
- /**
- * Start the applet.
- */
- void appletStart() {
- panel.sendEvent(AppletPanel.APPLET_START);
- }
-
- /**
- * Stop the applet.
- */
- void appletStop() {
- panel.sendEvent(AppletPanel.APPLET_STOP);
- }
-
- /**
- * Shutdown a viewer.
- * Stop, Destroy, Dispose and Quit a viewer
- */
- private void appletShutdown(AppletPanel p) {
- p.sendEvent(AppletPanel.APPLET_STOP);
- p.sendEvent(AppletPanel.APPLET_DESTROY);
- p.sendEvent(AppletPanel.APPLET_DISPOSE);
- p.sendEvent(AppletPanel.APPLET_QUIT);
- }
-
- /**
- * Close this viewer.
- * Stop, Destroy, Dispose and Quit an AppletView, then
- * reclaim resources and exit the program if this is
- * the last applet.
- */
- void appletClose() {
-
- // The caller thread is event dispatch thread, so
- // spawn a new thread to avoid blocking the event queue
- // when calling appletShutdown.
- //
- final AppletPanel p = panel;
-
- new Thread(new Runnable()
+ void appletRestart() {
+ panel.sendEvent(AppletPanel.APPLET_STOP);
+ panel.sendEvent(AppletPanel.APPLET_DESTROY);
+ panel.sendEvent(AppletPanel.APPLET_INIT);
+ panel.sendEvent(AppletPanel.APPLET_START);
+ }
+
+ /**
+ * Reload the applet.
+ */
+ void appletReload() {
+ panel.sendEvent(AppletPanel.APPLET_STOP);
+ panel.sendEvent(AppletPanel.APPLET_DESTROY);
+ panel.sendEvent(AppletPanel.APPLET_DISPOSE);
+
+ /**
+ * Fixed #4501142: Classlaoder sharing policy doesn't
+ * take "archive" into account. This will be overridden
+ * by Java Plug-in. [stanleyh]
+ */
+ AppletPanel.flushClassLoader(panel.getClassLoaderCacheKey());
+
+ /*
+ * Make sure we don't have two threads running through the event queue
+ * at the same time.
+ */
+ try {
+ panel.joinAppletThread();
+ panel.release();
+ } catch (InterruptedException e) {
+ return; // abort the reload
+ }
+
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ public Void run() {
+ panel.createAppletThread();
+ return null;
+ }
+ });
+
+ panel.sendEvent(AppletPanel.APPLET_LOAD);
+ panel.sendEvent(AppletPanel.APPLET_INIT);
+ panel.sendEvent(AppletPanel.APPLET_START);
+ }
+
+ public int print(Graphics graphics, PageFormat pf, int pageIndex) {
+ return Printable.NO_SUCH_PAGE;
+ }
+
+ /**
+ * Start the applet.
+ */
+ void appletStart() {
+ panel.sendEvent(AppletPanel.APPLET_START);
+ }
+
+ /**
+ * Stop the applet.
+ */
+ void appletStop() {
+ panel.sendEvent(AppletPanel.APPLET_STOP);
+ }
+
+ /**
+ * Shutdown a viewer.
+ * Stop, Destroy, Dispose and Quit a viewer
+ */
+ private void appletShutdown(AppletPanel p) {
+ p.sendEvent(AppletPanel.APPLET_STOP);
+ p.sendEvent(AppletPanel.APPLET_DESTROY);
+ p.sendEvent(AppletPanel.APPLET_DISPOSE);
+ p.sendEvent(AppletPanel.APPLET_QUIT);
+ }
+
+ /**
+ * Close this viewer.
+ * Stop, Destroy, Dispose and Quit an AppletView, then
+ * reclaim resources and exit the program if this is
+ * the last applet.
+ */
+ void appletClose() {
+
+ // The caller thread is event dispatch thread, so
+ // spawn a new thread to avoid blocking the event queue
+ // when calling appletShutdown.
+ //
+ final AppletPanel p = panel;
+
+ new Thread(new Runnable()
{
public void run()
{
@@ -1661,7 +1644,7 @@ import com.sun.jndi.toolkit.url.UrlUtil;
dispose();
if (tg.activeCount() > 0)
- tg.stop();
+ tg.stop();
if (countApplets() == 0) {
appletSystemExit();
@@ -1671,497 +1654,490 @@ import com.sun.jndi.toolkit.url.UrlUtil;
}
}).start();
- }
-
- /**
- * Exit the program.
- * Exit from the program (if not stand alone) - do no clean-up
- */
- private void appletSystemExit() {
- // Do nothing. Exit is handled by another
- // block of code, called when _all_ applets are gone
- }
-
- /**
- * How many applets are running?
- */
-
- public static int countApplets() {
- return appletPanels.size();
- }
-
-
- /**
- * Scan spaces.
- */
- public static void skipSpace(int[] c, Reader in) throws IOException {
- while ((c[0] >= 0) &&
- ((c[0] == ' ') || (c[0] == '\t') || (c[0] == '\n') || (c[0] == '\r'))) {
- c[0] = in.read();
- }
- }
-
- /**
- * Scan identifier
- */
- public static String scanIdentifier(int[] c, Reader in) throws IOException {
- StringBuilder buf = new StringBuilder();
-
- if (c[0] == '!') {
- // Technically, we should be scanning for '!--' but we are reading
- // from a stream, and there is no way to peek ahead. That said,
- // a ! at this point can only mean comment here afaik, so we
- // should be okay
- skipComment(c, in);
- return "";
- }
-
- while (true) {
- if (((c[0] >= 'a') && (c[0] <= 'z')) ||
- ((c[0] >= 'A') && (c[0] <= 'Z')) ||
- ((c[0] >= '0') && (c[0] <= '9')) || (c[0] == '_')) {
- buf.append((char)c[0]);
- c[0] = in.read();
- } else {
- return buf.toString();
- }
- }
- }
-
- public static void skipComment(int[] c, Reader in) throws IOException {
- StringBuilder buf = new StringBuilder();
- boolean commentHeaderPassed = false;
- c[0] = in.read();
- buf.append((char)c[0]);
-
- while (true) {
- if (c[0] == '-' && (c[0] = in.read()) == '-') {
- buf.append((char)c[0]);
- if (commentHeaderPassed) {
- // -- encountered ... is > next?
- if ((c[0] = in.read()) == '>') {
- buf.append((char)c[0]);
-
- PluginDebug.debug("Comment skipped: " + buf.toString());
-
- // comment skipped.
- return;
- }
- } else {
- // first -- is part of <!-- ... , just mark that we have passed it
- commentHeaderPassed = true;
- }
+ }
- } else if (commentHeaderPassed == false) {
- buf.append((char)c[0]);
- PluginDebug.debug("Warning: Attempted to skip comment, but this tag does not appear to be a comment: " + buf.toString());
- return;
- }
+ /**
+ * Exit the program.
+ * Exit from the program (if not stand alone) - do no clean-up
+ */
+ private void appletSystemExit() {
+ // Do nothing. Exit is handled by another
+ // block of code, called when _all_ applets are gone
+ }
- c[0] = in.read();
- buf.append((char)c[0]);
- }
- }
-
- /**
- * Scan tag
- */
- public static Hashtable<String,String> scanTag(int[] c, Reader in) throws IOException {
- Hashtable<String,String> atts = new Hashtable<String,String>();
- skipSpace(c, in);
- while (c[0] >= 0 && c[0] != '>') {
- String att = scanIdentifier(c, in);
- String val = "";
- skipSpace(c, in);
- if (c[0] == '=') {
- int quote = -1;
- c[0] = in.read();
- skipSpace(c, in);
- if ((c[0] == '\'') || (c[0] == '\"')) {
- quote = c[0];
- c[0] = in.read();
- }
- StringBuilder buf = new StringBuilder();
- while ((c[0] > 0) &&
+ /**
+ * How many applets are running?
+ */
+
+ public static int countApplets() {
+ return appletPanels.size();
+ }
+
+ /**
+ * Scan spaces.
+ */
+ public static void skipSpace(int[] c, Reader in) throws IOException {
+ while ((c[0] >= 0) &&
+ ((c[0] == ' ') || (c[0] == '\t') || (c[0] == '\n') || (c[0] == '\r'))) {
+ c[0] = in.read();
+ }
+ }
+
+ /**
+ * Scan identifier
+ */
+ public static String scanIdentifier(int[] c, Reader in) throws IOException {
+ StringBuilder buf = new StringBuilder();
+
+ if (c[0] == '!') {
+ // Technically, we should be scanning for '!--' but we are reading
+ // from a stream, and there is no way to peek ahead. That said,
+ // a ! at this point can only mean comment here afaik, so we
+ // should be okay
+ skipComment(c, in);
+ return "";
+ }
+
+ while (true) {
+ if (((c[0] >= 'a') && (c[0] <= 'z')) ||
+ ((c[0] >= 'A') && (c[0] <= 'Z')) ||
+ ((c[0] >= '0') && (c[0] <= '9')) || (c[0] == '_')) {
+ buf.append((char) c[0]);
+ c[0] = in.read();
+ } else {
+ return buf.toString();
+ }
+ }
+ }
+
+ public static void skipComment(int[] c, Reader in) throws IOException {
+ StringBuilder buf = new StringBuilder();
+ boolean commentHeaderPassed = false;
+ c[0] = in.read();
+ buf.append((char) c[0]);
+
+ while (true) {
+ if (c[0] == '-' && (c[0] = in.read()) == '-') {
+ buf.append((char) c[0]);
+ if (commentHeaderPassed) {
+ // -- encountered ... is > next?
+ if ((c[0] = in.read()) == '>') {
+ buf.append((char) c[0]);
+
+ PluginDebug.debug("Comment skipped: " + buf.toString());
+
+ // comment skipped.
+ return;
+ }
+ } else {
+ // first -- is part of <!-- ... , just mark that we have passed it
+ commentHeaderPassed = true;
+ }
+
+ } else if (commentHeaderPassed == false) {
+ buf.append((char) c[0]);
+ PluginDebug.debug("Warning: Attempted to skip comment, but this tag does not appear to be a comment: " + buf.toString());
+ return;
+ }
+
+ c[0] = in.read();
+ buf.append((char) c[0]);
+ }
+ }
+
+ /**
+ * Scan tag
+ */
+ public static Hashtable<String, String> scanTag(int[] c, Reader in) throws IOException {
+ Hashtable<String, String> atts = new Hashtable<String, String>();
+ skipSpace(c, in);
+ while (c[0] >= 0 && c[0] != '>') {
+ String att = scanIdentifier(c, in);
+ String val = "";
+ skipSpace(c, in);
+ if (c[0] == '=') {
+ int quote = -1;
+ c[0] = in.read();
+ skipSpace(c, in);
+ if ((c[0] == '\'') || (c[0] == '\"')) {
+ quote = c[0];
+ c[0] = in.read();
+ }
+ StringBuilder buf = new StringBuilder();
+ while ((c[0] > 0) &&
(((quote < 0) && (c[0] != ' ') && (c[0] != '\t') &&
- (c[0] != '\n') && (c[0] != '\r') && (c[0] != '>'))
+ (c[0] != '\n') && (c[0] != '\r') && (c[0] != '>'))
|| ((quote >= 0) && (c[0] != quote)))) {
- buf.append((char)c[0]);
- c[0] = in.read();
- }
- if (c[0] == quote) {
- c[0] = in.read();
- }
- skipSpace(c, in);
- val = buf.toString();
- }
+ buf.append((char) c[0]);
+ c[0] = in.read();
+ }
+ if (c[0] == quote) {
+ c[0] = in.read();
+ }
+ skipSpace(c, in);
+ val = buf.toString();
+ }
- PluginDebug.debug("PUT " + att + " = '" + val + "'");
- atts.put(att.toLowerCase(java.util.Locale.ENGLISH), val);
+ PluginDebug.debug("PUT " + att + " = '" + val + "'");
+ atts.put(att.toLowerCase(java.util.Locale.ENGLISH), val);
- while (true) {
- if ((c[0] == '>') || (c[0] < 0) ||
- ((c[0] >= 'a') && (c[0] <= 'z')) ||
- ((c[0] >= 'A') && (c[0] <= 'Z')) ||
- ((c[0] >= '0') && (c[0] <= '9')) || (c[0] == '_'))
- break;
- c[0] = in.read();
- }
- //skipSpace(in);
- }
- return atts;
- }
-
- // private static final == inline
- private static final boolean isInt(Object o) {
- boolean isInt = false;
- try {
- Integer.parseInt((String) o);
- isInt = true;
- } catch (Exception e) {
- // don't care
- }
-
- return isInt;
- }
-
- /* values used for placement of AppletViewer's frames */
- private static int x = 0;
- private static int y = 0;
- private static final int XDELTA = 30;
- private static final int YDELTA = XDELTA;
-
- static String encoding = null;
-
- static private Reader makeReader(InputStream is) {
- if (encoding != null) {
+ while (true) {
+ if ((c[0] == '>') || (c[0] < 0) ||
+ ((c[0] >= 'a') && (c[0] <= 'z')) ||
+ ((c[0] >= 'A') && (c[0] <= 'Z')) ||
+ ((c[0] >= '0') && (c[0] <= '9')) || (c[0] == '_'))
+ break;
+ c[0] = in.read();
+ }
+ //skipSpace(in);
+ }
+ return atts;
+ }
+
+ // private static final == inline
+ private static final boolean isInt(Object o) {
+ boolean isInt = false;
try {
- return new BufferedReader(new InputStreamReader(is, encoding));
- } catch (IOException x) { }
- }
- InputStreamReader r = new InputStreamReader(is);
- encoding = r.getEncoding();
- return new BufferedReader(r);
- }
-
- /**
- * Scan an html file for <applet> tags
- */
- public static void parse(int identifier, long handle, String width, String height, Reader in, URL url, String enc)
- throws IOException {
- encoding = enc;
- parse(identifier, handle, width, height, in, url, System.out, new PluginAppletPanelFactory());
- }
-
- public static void parse(int identifier, long handle, String width, String height, Reader in, URL url)
- throws PrivilegedActionException {
-
- final int fIdentifier = identifier;
- final long fHandle = handle;
- final String fWidth = width;
- final String fHeight = height;
- final Reader fIn = in;
- final URL fUrl = url;
- AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
- public Void run() throws IOException {
- parse(fIdentifier, fHandle, fWidth, fHeight, fIn, fUrl,
- System.out, new PluginAppletPanelFactory());
- return null;
- }
- });
- }
+ Integer.parseInt((String) o);
+ isInt = true;
+ } catch (Exception e) {
+ // don't care
+ }
+
+ return isInt;
+ }
+
+ /* values used for placement of AppletViewer's frames */
+ private static int x = 0;
+ private static int y = 0;
+ private static final int XDELTA = 30;
+ private static final int YDELTA = XDELTA;
- public static void parse(int identifier, long handle, String width,
+ static String encoding = null;
+
+ static private Reader makeReader(InputStream is) {
+ if (encoding != null) {
+ try {
+ return new BufferedReader(new InputStreamReader(is, encoding));
+ } catch (IOException x) {
+ }
+ }
+ InputStreamReader r = new InputStreamReader(is);
+ encoding = r.getEncoding();
+ return new BufferedReader(r);
+ }
+
+ /**
+ * Scan an html file for <applet> tags
+ */
+ public static void parse(int identifier, long handle, String width, String height, Reader in, URL url, String enc)
+ throws IOException {
+ encoding = enc;
+ parse(identifier, handle, width, height, in, url, System.out, new PluginAppletPanelFactory());
+ }
+
+ public static void parse(int identifier, long handle, String width, String height, Reader in, URL url)
+ throws PrivilegedActionException {
+
+ final int fIdentifier = identifier;
+ final long fHandle = handle;
+ final String fWidth = width;
+ final String fHeight = height;
+ final Reader fIn = in;
+ final URL fUrl = url;
+ AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
+ public Void run() throws IOException {
+ parse(fIdentifier, fHandle, fWidth, fHeight, fIn, fUrl,
+ System.out, new PluginAppletPanelFactory());
+ return null;
+ }
+ });
+ }
+
+ public static void parse(int identifier, long handle, String width,
String height, Reader in, URL url,
PrintStream statusMsgStream,
PluginAppletPanelFactory factory)
- throws IOException
- {
- // <OBJECT> <EMBED> tag flags
- boolean isAppletTag = false;
- boolean isObjectTag = false;
- boolean isEmbedTag = false;
- boolean objectTagAlreadyParsed = false;
-
- // The current character
- // FIXME: This is an evil hack to force pass-by-reference.. the
- // parsing code needs to be rewritten from scratch to prevent such
- //a need
- int[] c = new int[1];
-
- // warning messages
- String requiresNameWarning = amh.getMessage("parse.warning.requiresname");
- String paramOutsideWarning = amh.getMessage("parse.warning.paramoutside");
- String appletRequiresCodeWarning = amh.getMessage("parse.warning.applet.requirescode");
- String appletRequiresHeightWarning = amh.getMessage("parse.warning.applet.requiresheight");
- String appletRequiresWidthWarning = amh.getMessage("parse.warning.applet.requireswidth");
- String objectRequiresCodeWarning = amh.getMessage("parse.warning.object.requirescode");
- String objectRequiresHeightWarning = amh.getMessage("parse.warning.object.requiresheight");
- String objectRequiresWidthWarning = amh.getMessage("parse.warning.object.requireswidth");
- String embedRequiresCodeWarning = amh.getMessage("parse.warning.embed.requirescode");
- String embedRequiresHeightWarning = amh.getMessage("parse.warning.embed.requiresheight");
- String embedRequiresWidthWarning = amh.getMessage("parse.warning.embed.requireswidth");
- String appNotLongerSupportedWarning = amh.getMessage("parse.warning.appnotLongersupported");
-
- java.net.URLConnection conn = url.openConnection();
- /* The original URL may have been redirected - this
- * sets it to whatever URL/codebase we ended up getting
- */
- url = conn.getURL();
-
- int ydisp = 1;
- Hashtable<String,String> atts = null;
-
- while(true) {
- c[0] = in.read();
- if (c[0] == -1)
- break;
-
- if (c[0] == '<') {
- c[0] = in.read();
- if (c[0] == '/') {
- c[0] = in.read();
- String nm = scanIdentifier(c, in);
- if (nm.equalsIgnoreCase("applet") ||
+ throws IOException {
+ // <OBJECT> <EMBED> tag flags
+ boolean isAppletTag = false;
+ boolean isObjectTag = false;
+ boolean isEmbedTag = false;
+ boolean objectTagAlreadyParsed = false;
+
+ // The current character
+ // FIXME: This is an evil hack to force pass-by-reference.. the
+ // parsing code needs to be rewritten from scratch to prevent such
+ //a need
+ int[] c = new int[1];
+
+ // warning messages
+ String requiresNameWarning = amh.getMessage("parse.warning.requiresname");
+ String paramOutsideWarning = amh.getMessage("parse.warning.paramoutside");
+ String appletRequiresCodeWarning = amh.getMessage("parse.warning.applet.requirescode");
+ String appletRequiresHeightWarning = amh.getMessage("parse.warning.applet.requiresheight");
+ String appletRequiresWidthWarning = amh.getMessage("parse.warning.applet.requireswidth");
+ String objectRequiresCodeWarning = amh.getMessage("parse.warning.object.requirescode");
+ String objectRequiresHeightWarning = amh.getMessage("parse.warning.object.requiresheight");
+ String objectRequiresWidthWarning = amh.getMessage("parse.warning.object.requireswidth");
+ String embedRequiresCodeWarning = amh.getMessage("parse.warning.embed.requirescode");
+ String embedRequiresHeightWarning = amh.getMessage("parse.warning.embed.requiresheight");
+ String embedRequiresWidthWarning = amh.getMessage("parse.warning.embed.requireswidth");
+ String appNotLongerSupportedWarning = amh.getMessage("parse.warning.appnotLongersupported");
+
+ java.net.URLConnection conn = url.openConnection();
+ /* The original URL may have been redirected - this
+ * sets it to whatever URL/codebase we ended up getting
+ */
+ url = conn.getURL();
+
+ int ydisp = 1;
+ Hashtable<String, String> atts = null;
+
+ while (true) {
+ c[0] = in.read();
+ if (c[0] == -1)
+ break;
+
+ if (c[0] == '<') {
+ c[0] = in.read();
+ if (c[0] == '/') {
+ c[0] = in.read();
+ String nm = scanIdentifier(c, in);
+ if (nm.equalsIgnoreCase("applet") ||
nm.equalsIgnoreCase("object") ||
nm.equalsIgnoreCase("embed")) {
- // We can't test for a code tag until </OBJECT>
- // because it is a parameter, not an attribute.
- if(isObjectTag) {
- if (atts.get("code") == null && atts.get("object") == null) {
- statusMsgStream.println(objectRequiresCodeWarning);
- atts = null;
- }
- }
-
- if (atts != null) {
- // XXX 5/18 In general this code just simply
- // shouldn't be part of parsing. It's presence
- // causes things to be a little too much of a
- // hack.
-
- // Let user know we are starting up
- streamhandler.write("instance " + identifier + " status " + amh.getMessage("status.start"));
- factory.createPanel(streamhandler, identifier, handle, x, y, url, atts);
-
- x += XDELTA;
- y += YDELTA;
- // make sure we don't go too far!
- Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
- if ((x > d.width - 300) || (y > d.height - 300)) {
- x = 0;
- y = 2 * ydisp * YDELTA;
- ydisp++;
- }
- }
- atts = null;
- isAppletTag = false;
- isObjectTag = false;
- isEmbedTag = false;
- }
- }
- else {
- String nm = scanIdentifier(c, in);
- if (nm.equalsIgnoreCase("param")) {
- Hashtable<String,String> t = scanTag(c, in);
- String att = t.get("name");
-
- if (atts.containsKey(att))
- continue;
-
- if (att == null) {
- statusMsgStream.println(requiresNameWarning);
- } else {
- String val = t.get("value");
- if (val == null) {
- statusMsgStream.println(requiresNameWarning);
- } else if (atts != null) {
- PluginDebug.debug("PUT " + att + " = " + val);
- atts.put(att.toLowerCase(), val);
- } else {
- statusMsgStream.println(paramOutsideWarning);
- }
- }
- }
- else if (nm.equalsIgnoreCase("applet")) {
- isAppletTag = true;
- atts = scanTag(c, in);
-
- // If there is a classid and no code tag present, transform it to code tag
- if (atts.get("code") == null && atts.get("classid") != null
- && !(atts.get("classid")).startsWith("clsid:")) {
- atts.put("code", atts.get("classid"));
- }
-
- // remove java: from code tag
- if (atts.get("code") != null && (atts.get("code")).startsWith("java:")) {
- atts.put("code", (atts.get("code")).substring(5));
- }
-
- if (atts.get("code") == null && atts.get("object") == null) {
- statusMsgStream.println(appletRequiresCodeWarning);
- atts = null;
- }
-
- if (atts.get("width") == null || !isInt(atts.get("width"))) {
- atts.put("width", width);
- }
-
- if (atts.get("height") == null || !isInt(atts.get("height"))) {
- atts.put("height", height);
- }
- }
- else if (nm.equalsIgnoreCase("object")) {
- isObjectTag = true;
-
- // Once code is set, additional nested objects are ignored
- if (!objectTagAlreadyParsed) {
- objectTagAlreadyParsed = true;
- atts = scanTag(c, in);
- }
-
- // If there is a classid and no code tag present, transform it to code tag
- if (atts.get("code") == null && atts.get("classid") != null
- && !(atts.get("classid")).startsWith("clsid:")) {
- atts.put("code", atts.get("classid"));
- }
-
- // remove java: from code tag
- if (atts.get("code") != null && (atts.get("code")).startsWith("java:")) {
- atts.put("code", (atts.get("code")).substring(5));
- }
-
- // java_* aliases override older names:
- // http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/using_tags.html#in-ie
- if (atts.get("java_code") != null) {
- atts.put("code", (atts.get("java_code")));
- }
-
- if (atts.containsKey("code")) {
- objectTagAlreadyParsed = true;
- }
-
- if (atts.get("java_codebase") != null) {
- atts.put("codebase", (atts.get("java_codebase")));
- }
-
- if (atts.get("java_archive") != null) {
- atts.put("archive", (atts.get("java_archive")));
- }
-
- if (atts.get("java_object") != null) {
- atts.put("object", (atts.get("java_object")));
- }
-
- if (atts.get("java_type") != null) {
- atts.put("type", (atts.get("java_type")));
- }
-
- if (atts.get("width") == null || !isInt(atts.get("width"))) {
- atts.put("width", width);
- }
-
- if (atts.get("height") == null || !isInt(atts.get("height"))) {
- atts.put("height", height);
- }
- }
- else if (nm.equalsIgnoreCase("embed")) {
- isEmbedTag = true;
- atts = scanTag(c, in);
-
- // If there is a classid and no code tag present, transform it to code tag
- if (atts.get("code") == null && atts.get("classid") != null
- && !(atts.get("classid")).startsWith("clsid:")) {
- atts.put("code", atts.get("classid"));
- }
-
- // remove java: from code tag
- if (atts.get("code") != null && (atts.get("code")).startsWith("java:")) {
- atts.put("code", (atts.get("code")).substring(5));
- }
-
- // java_* aliases override older names:
- // http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/using_tags.html#in-nav
- if (atts.get("java_code") != null) {
- atts.put("code", (atts.get("java_code")));
- }
-
- if (atts.get("java_codebase") != null) {
- atts.put("codebase", (atts.get("java_codebase")));
- }
-
- if (atts.get("java_archive") != null) {
- atts.put("archive", (atts.get("java_archive")));
- }
-
- if (atts.get("java_object") != null) {
- atts.put("object", (atts.get("java_object")));
- }
-
- if (atts.get("java_type") != null) {
- atts.put("type", (atts.get("java_type")));
- }
-
- if (atts.get("code") == null && atts.get("object") == null) {
- statusMsgStream.println(embedRequiresCodeWarning);
- atts = null;
- }
-
- if (atts.get("width") == null || !isInt(atts.get("width"))) {
- atts.put("width", width);
- }
-
- if (atts.get("height") == null || !isInt(atts.get("height"))) {
- atts.put("height", height);
- }
-
- }
- }
- }
- }
- in.close();
- }
-
+ // We can't test for a code tag until </OBJECT>
+ // because it is a parameter, not an attribute.
+ if (isObjectTag) {
+ if (atts.get("code") == null && atts.get("object") == null) {
+ statusMsgStream.println(objectRequiresCodeWarning);
+ atts = null;
+ }
+ }
- private static AppletMessageHandler amh = new AppletMessageHandler("appletviewer");
+ if (atts != null) {
+ // XXX 5/18 In general this code just simply
+ // shouldn't be part of parsing. It's presence
+ // causes things to be a little too much of a
+ // hack.
+
+ // Let user know we are starting up
+ streamhandler.write("instance " + identifier + " status " + amh.getMessage("status.start"));
+ factory.createPanel(streamhandler, identifier, handle, x, y, url, atts);
+
+ x += XDELTA;
+ y += YDELTA;
+ // make sure we don't go too far!
+ Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
+ if ((x > d.width - 300) || (y > d.height - 300)) {
+ x = 0;
+ y = 2 * ydisp * YDELTA;
+ ydisp++;
+ }
+ }
+ atts = null;
+ isAppletTag = false;
+ isObjectTag = false;
+ isEmbedTag = false;
+ }
+ } else {
+ String nm = scanIdentifier(c, in);
+ if (nm.equalsIgnoreCase("param")) {
+ Hashtable<String, String> t = scanTag(c, in);
+ String att = t.get("name");
+
+ if (atts.containsKey(att))
+ continue;
+
+ if (att == null) {
+ statusMsgStream.println(requiresNameWarning);
+ } else {
+ String val = t.get("value");
+ if (val == null) {
+ statusMsgStream.println(requiresNameWarning);
+ } else if (atts != null) {
+ PluginDebug.debug("PUT " + att + " = " + val);
+ atts.put(att.toLowerCase(), val);
+ } else {
+ statusMsgStream.println(paramOutsideWarning);
+ }
+ }
+ } else if (nm.equalsIgnoreCase("applet")) {
+ isAppletTag = true;
+ atts = scanTag(c, in);
+
+ // If there is a classid and no code tag present, transform it to code tag
+ if (atts.get("code") == null && atts.get("classid") != null
+ && !(atts.get("classid")).startsWith("clsid:")) {
+ atts.put("code", atts.get("classid"));
+ }
- private static void checkConnect(URL url)
- {
- SecurityManager security = System.getSecurityManager();
- if (security != null) {
- try {
- java.security.Permission perm =
- url.openConnection().getPermission();
- if (perm != null)
- security.checkPermission(perm);
- else
- security.checkConnect(url.getHost(), url.getPort());
- } catch (java.io.IOException ioe) {
- security.checkConnect(url.getHost(), url.getPort());
+ // remove java: from code tag
+ if (atts.get("code") != null && (atts.get("code")).startsWith("java:")) {
+ atts.put("code", (atts.get("code")).substring(5));
+ }
+
+ if (atts.get("code") == null && atts.get("object") == null) {
+ statusMsgStream.println(appletRequiresCodeWarning);
+ atts = null;
+ }
+
+ if (atts.get("width") == null || !isInt(atts.get("width"))) {
+ atts.put("width", width);
+ }
+
+ if (atts.get("height") == null || !isInt(atts.get("height"))) {
+ atts.put("height", height);
+ }
+ } else if (nm.equalsIgnoreCase("object")) {
+ isObjectTag = true;
+
+ // Once code is set, additional nested objects are ignored
+ if (!objectTagAlreadyParsed) {
+ objectTagAlreadyParsed = true;
+ atts = scanTag(c, in);
+ }
+
+ // If there is a classid and no code tag present, transform it to code tag
+ if (atts.get("code") == null && atts.get("classid") != null
+ && !(atts.get("classid")).startsWith("clsid:")) {
+ atts.put("code", atts.get("classid"));
+ }
+
+ // remove java: from code tag
+ if (atts.get("code") != null && (atts.get("code")).startsWith("java:")) {
+ atts.put("code", (atts.get("code")).substring(5));
+ }
+
+ // java_* aliases override older names:
+ // http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/using_tags.html#in-ie
+ if (atts.get("java_code") != null) {
+ atts.put("code", (atts.get("java_code")));
+ }
+
+ if (atts.containsKey("code")) {
+ objectTagAlreadyParsed = true;
+ }
+
+ if (atts.get("java_codebase") != null) {
+ atts.put("codebase", (atts.get("java_codebase")));
+ }
+
+ if (atts.get("java_archive") != null) {
+ atts.put("archive", (atts.get("java_archive")));
+ }
+
+ if (atts.get("java_object") != null) {
+ atts.put("object", (atts.get("java_object")));
+ }
+
+ if (atts.get("java_type") != null) {
+ atts.put("type", (atts.get("java_type")));
+ }
+
+ if (atts.get("width") == null || !isInt(atts.get("width"))) {
+ atts.put("width", width);
+ }
+
+ if (atts.get("height") == null || !isInt(atts.get("height"))) {
+ atts.put("height", height);
+ }
+ } else if (nm.equalsIgnoreCase("embed")) {
+ isEmbedTag = true;
+ atts = scanTag(c, in);
+
+ // If there is a classid and no code tag present, transform it to code tag
+ if (atts.get("code") == null && atts.get("classid") != null
+ && !(atts.get("classid")).startsWith("clsid:")) {
+ atts.put("code", atts.get("classid"));
+ }
+
+ // remove java: from code tag
+ if (atts.get("code") != null && (atts.get("code")).startsWith("java:")) {
+ atts.put("code", (atts.get("code")).substring(5));
+ }
+
+ // java_* aliases override older names:
+ // http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/using_tags.html#in-nav
+ if (atts.get("java_code") != null) {
+ atts.put("code", (atts.get("java_code")));
+ }
+
+ if (atts.get("java_codebase") != null) {
+ atts.put("codebase", (atts.get("java_codebase")));
+ }
+
+ if (atts.get("java_archive") != null) {
+ atts.put("archive", (atts.get("java_archive")));
+ }
+
+ if (atts.get("java_object") != null) {
+ atts.put("object", (atts.get("java_object")));
+ }
+
+ if (atts.get("java_type") != null) {
+ atts.put("type", (atts.get("java_type")));
+ }
+
+ if (atts.get("code") == null && atts.get("object") == null) {
+ statusMsgStream.println(embedRequiresCodeWarning);
+ atts = null;
+ }
+
+ if (atts.get("width") == null || !isInt(atts.get("width"))) {
+ atts.put("width", width);
+ }
+
+ if (atts.get("height") == null || !isInt(atts.get("height"))) {
+ atts.put("height", height);
+ }
+
+ }
+ }
+ }
+ }
+ in.close();
+ }
+
+ private static AppletMessageHandler amh = new AppletMessageHandler("appletviewer");
+
+ private static void checkConnect(URL url) {
+ SecurityManager security = System.getSecurityManager();
+ if (security != null) {
+ try {
+ java.security.Permission perm =
+ url.openConnection().getPermission();
+ if (perm != null)
+ security.checkPermission(perm);
+ else
+ security.checkConnect(url.getHost(), url.getPort());
+ } catch (java.io.IOException ioe) {
+ security.checkConnect(url.getHost(), url.getPort());
+ }
}
}
- }
-
- /**
- * {@inheritDoc}
- *
- * This method calls paint directly, rather than via super.update() since
- * the parent class's update() just does a couple of checks (both of
- * which are accounted for) and then calls paint anyway.
- */
- public void update(Graphics g) {
-
- // If the image or the graphics don't exist, create new ones
- if (bufFrameImg == null || bufFrameImgGraphics == null) {
- bufFrameImg = createImage(getWidth(), getHeight());
- bufFrameImgGraphics = bufFrameImg.getGraphics ();
- }
-
- // Paint off-screen
- paint(bufFrameImgGraphics);
-
- // Draw the painted image
- g.drawImage(bufFrameImg, 0, 0, this);
- }
- }
+
+ /**
+ * {@inheritDoc}
+ *
+ * This method calls paint directly, rather than via super.update() since
+ * the parent class's update() just does a couple of checks (both of
+ * which are accounted for) and then calls paint anyway.
+ */
+ public void update(Graphics g) {
+
+ // If the image or the graphics don't exist, create new ones
+ if (bufFrameImg == null || bufFrameImgGraphics == null) {
+ bufFrameImg = createImage(getWidth(), getHeight());
+ bufFrameImgGraphics = bufFrameImg.getGraphics();
+ }
+
+ // Paint off-screen
+ paint(bufFrameImgGraphics);
+
+ // Draw the painted image
+ g.drawImage(bufFrameImg, 0, 0, this);
+ }
+}
diff --git a/plugin/icedteanp/java/sun/applet/PluginCallRequest.java b/plugin/icedteanp/java/sun/applet/PluginCallRequest.java
index a4f01a7..b32ff8b 100644
--- a/plugin/icedteanp/java/sun/applet/PluginCallRequest.java
+++ b/plugin/icedteanp/java/sun/applet/PluginCallRequest.java
@@ -54,23 +54,23 @@ public abstract class PluginCallRequest {
}
public String getMessage() {
- return this.message;
+ return this.message;
}
-
+
public boolean isDone() {
- return this.done;
+ return this.done;
}
-
+
public boolean setDone(boolean done) {
- return this.done = done;
+ return this.done = done;
}
-
+
public void setNext(PluginCallRequest next) {
- this.next = next;
+ this.next = next;
}
-
+
public PluginCallRequest getNext() {
- return this.next;
+ return this.next;
}
/**
@@ -82,8 +82,8 @@ public abstract class PluginCallRequest {
public boolean serviceable(String message) {
return message.contains("reference " + reference);
}
-
+
public abstract void parseReturn(String message);
-
+
public abstract Object getObject();
}
diff --git a/plugin/icedteanp/java/sun/applet/PluginCallRequestFactory.java b/plugin/icedteanp/java/sun/applet/PluginCallRequestFactory.java
index 69cec35..d5edc6f 100644
--- a/plugin/icedteanp/java/sun/applet/PluginCallRequestFactory.java
+++ b/plugin/icedteanp/java/sun/applet/PluginCallRequestFactory.java
@@ -35,27 +35,25 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package sun.applet;
-
public class PluginCallRequestFactory {
-
- public PluginCallRequest getPluginCallRequest(String id, String message, Long reference) {
-
- if (id == "member") {
- return new GetMemberPluginCallRequest(message, reference);
- } else if (id == "void") {
- return new VoidPluginCallRequest(message, reference);
- } else if (id == "window") {
- return new GetWindowPluginCallRequest(message, reference);
- } else if (id == "proxyinfo") {
+
+ public PluginCallRequest getPluginCallRequest(String id, String message, Long reference) {
+
+ if (id == "member") {
+ return new GetMemberPluginCallRequest(message, reference);
+ } else if (id == "void") {
+ return new VoidPluginCallRequest(message, reference);
+ } else if (id == "window") {
+ return new GetWindowPluginCallRequest(message, reference);
+ } else if (id == "proxyinfo") {
return new PluginProxyInfoRequest(message, reference);
} else if (id == "cookieinfo") {
return new PluginCookieInfoRequest(message, reference);
} else {
- throw new RuntimeException ("Unknown plugin call request type requested from factory");
- }
- }
+ throw new RuntimeException("Unknown plugin call request type requested from factory");
+ }
+ }
}
diff --git a/plugin/icedteanp/java/sun/applet/PluginClassLoader.java b/plugin/icedteanp/java/sun/applet/PluginClassLoader.java
index 5965d0d..0af80c2 100644
--- a/plugin/icedteanp/java/sun/applet/PluginClassLoader.java
+++ b/plugin/icedteanp/java/sun/applet/PluginClassLoader.java
@@ -35,17 +35,16 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package sun.applet;
public class PluginClassLoader extends ClassLoader {
- public PluginClassLoader() {
- super();
- }
+ public PluginClassLoader() {
+ super();
+ }
+
+ public Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
+ return super.loadClass(name, resolve);
+ }
- public Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
- return super.loadClass(name, resolve);
- }
-
}
diff --git a/plugin/icedteanp/java/sun/applet/PluginCookieInfoRequest.java b/plugin/icedteanp/java/sun/applet/PluginCookieInfoRequest.java
index c08d9f5..89ef98d 100644
--- a/plugin/icedteanp/java/sun/applet/PluginCookieInfoRequest.java
+++ b/plugin/icedteanp/java/sun/applet/PluginCookieInfoRequest.java
@@ -37,7 +37,6 @@ exception statement from your version. */
package sun.applet;
-
/**
* This class represents a request object for cookie information for a given URI
*/
@@ -55,20 +54,20 @@ public class PluginCookieInfoRequest extends PluginCallRequest {
// try to parse the proxy information. If things go wrong, do nothing ..
// this will keep internal = null which forces a direct connection
- PluginDebug.debug ("PluginCookieInfoRequest GOT: " + cookieInfo);
+ PluginDebug.debug("PluginCookieInfoRequest GOT: " + cookieInfo);
- // Skip the first 5 components. We are guaranteed 5 components,
- // so no index -1 to worry about
- cookieInfo = cookieInfo.substring(cookieInfo.indexOf(' ')+1);
- cookieInfo = cookieInfo.substring(cookieInfo.indexOf(' ')+1);
- cookieInfo = cookieInfo.substring(cookieInfo.indexOf(' ')+1);
- cookieInfo = cookieInfo.substring(cookieInfo.indexOf(' ')+1);
- cookieString = cookieInfo.substring(cookieInfo.indexOf(' ')+1);
+ // Skip the first 5 components. We are guaranteed 5 components,
+ // so no index -1 to worry about
+ cookieInfo = cookieInfo.substring(cookieInfo.indexOf(' ') + 1);
+ cookieInfo = cookieInfo.substring(cookieInfo.indexOf(' ') + 1);
+ cookieInfo = cookieInfo.substring(cookieInfo.indexOf(' ') + 1);
+ cookieInfo = cookieInfo.substring(cookieInfo.indexOf(' ') + 1);
+ cookieString = cookieInfo.substring(cookieInfo.indexOf(' ') + 1);
setDone(true);
}
public String getObject() {
- return this.cookieString;
+ return this.cookieString;
}
}
diff --git a/plugin/icedteanp/java/sun/applet/PluginCookieManager.java b/plugin/icedteanp/java/sun/applet/PluginCookieManager.java
index 233cfa9..72a94dc 100644
--- a/plugin/icedteanp/java/sun/applet/PluginCookieManager.java
+++ b/plugin/icedteanp/java/sun/applet/PluginCookieManager.java
@@ -45,35 +45,34 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
-public class PluginCookieManager extends CookieManager
-{
+public class PluginCookieManager extends CookieManager {
public Map<String, List<String>> get(URI uri,
- Map<String, List<String>> requestHeaders) throws IOException {
- // pre-condition check
- if (uri == null || requestHeaders == null) {
- throw new IllegalArgumentException("Argument is null");
- }
-
- Map<String, List<String>> cookieMap = new java.util.HashMap<String, List<String>>();
-
- String cookies = (String) PluginAppletViewer
- .requestPluginCookieInfo(uri);
- List<String> cookieHeader = new java.util.ArrayList<String>();
-
- if (cookies != null && cookies.length() > 0)
- cookieHeader.add(cookies);
-
- // Add anything else that mozilla didn't add
+ Map<String, List<String>> requestHeaders) throws IOException {
+ // pre-condition check
+ if (uri == null || requestHeaders == null) {
+ throw new IllegalArgumentException("Argument is null");
+ }
+
+ Map<String, List<String>> cookieMap = new java.util.HashMap<String, List<String>>();
+
+ String cookies = (String) PluginAppletViewer
+ .requestPluginCookieInfo(uri);
+ List<String> cookieHeader = new java.util.ArrayList<String>();
+
+ if (cookies != null && cookies.length() > 0)
+ cookieHeader.add(cookies);
+
+ // Add anything else that mozilla didn't add
for (HttpCookie cookie : getCookieStore().get(uri)) {
// apply path-matches rule (RFC 2965 sec. 3.3.4)
if (pathMatches(uri.getPath(), cookie.getPath())) {
- cookieHeader.add(cookie.toString());
+ cookieHeader.add(cookie.toString());
}
}
- cookieMap.put("Cookie", cookieHeader);
- return Collections.unmodifiableMap(cookieMap);
- }
+ cookieMap.put("Cookie", cookieHeader);
+ return Collections.unmodifiableMap(cookieMap);
+ }
private boolean pathMatches(String path, String pathToMatchWith) {
if (path == pathToMatchWith)
diff --git a/plugin/icedteanp/java/sun/applet/PluginDebug.java b/plugin/icedteanp/java/sun/applet/PluginDebug.java
index 60e2bd0..d96314c 100644
--- a/plugin/icedteanp/java/sun/applet/PluginDebug.java
+++ b/plugin/icedteanp/java/sun/applet/PluginDebug.java
@@ -35,17 +35,16 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package sun.applet;
import java.io.*;
public class PluginDebug {
- static final boolean DEBUG = System.getenv().containsKey("ICEDTEAPLUGIN_DEBUG");
+ static final boolean DEBUG = System.getenv().containsKey("ICEDTEAPLUGIN_DEBUG");
public static void debug(String message) {
- if (DEBUG)
- System.err.println(message);
- }
+ if (DEBUG)
+ System.err.println(message);
+ }
}
diff --git a/plugin/icedteanp/java/sun/applet/PluginException.java b/plugin/icedteanp/java/sun/applet/PluginException.java
index 0f6e660..4d42eff 100644
--- a/plugin/icedteanp/java/sun/applet/PluginException.java
+++ b/plugin/icedteanp/java/sun/applet/PluginException.java
@@ -35,19 +35,17 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package sun.applet;
-
public class PluginException extends Exception {
- public PluginException (PluginStreamHandler sh, int instance, int reference, Throwable t) {
- t.printStackTrace();
- this.setStackTrace(t.getStackTrace());
-
- AppletSecurityContextManager.dumpStore(0);
+ public PluginException(PluginStreamHandler sh, int instance, int reference, Throwable t) {
+ t.printStackTrace();
+ this.setStackTrace(t.getStackTrace());
+
+ AppletSecurityContextManager.dumpStore(0);
- String message = "instance " + instance + " reference " + reference + " Error " + t.getMessage();
- sh.write(message);
- }
+ String message = "instance " + instance + " reference " + reference + " Error " + t.getMessage();
+ sh.write(message);
+ }
}
diff --git a/plugin/icedteanp/java/sun/applet/PluginMain.java b/plugin/icedteanp/java/sun/applet/PluginMain.java
index 6c4b1f4..283a452 100644
--- a/plugin/icedteanp/java/sun/applet/PluginMain.java
+++ b/plugin/icedteanp/java/sun/applet/PluginMain.java
@@ -82,14 +82,13 @@ import net.sourceforge.jnlp.security.JNLPAuthenticator;
/**
* The main entry point into PluginAppletViewer.
*/
-public class PluginMain
-{
+public class PluginMain {
// the files where stdout/stderr are sent to
public static final String PLUGIN_STDERR_FILE = "java.stderr";
public static final String PLUGIN_STDOUT_FILE = "java.stdout";
- final boolean redirectStreams = System.getenv().containsKey("ICEDTEAPLUGIN_DEBUG");
- static PluginStreamHandler streamHandler;
+ final boolean redirectStreams = System.getenv().containsKey("ICEDTEAPLUGIN_DEBUG");
+ static PluginStreamHandler streamHandler;
// This is used in init(). Getting rid of this is desirable but depends
// on whether the property that uses it is necessary/standard.
@@ -101,25 +100,23 @@ public class PluginMain
* The main entry point into AppletViewer.
*/
public static void main(String args[])
- throws IOException
- {
+ throws IOException {
if (args.length != 2 || !(new File(args[0]).exists()) || !(new File(args[1]).exists())) {
System.err.println("Invalid pipe names provided. Refusing to proceed.");
System.exit(1);
}
try {
- PluginMain pm = new PluginMain(args[0], args[1]);
+ PluginMain pm = new PluginMain(args[0], args[1]);
} catch (Exception e) {
- e.printStackTrace();
- System.err.println("Something very bad happened. I don't know what to do, so I am going to exit :(");
- System.exit(1);
+ e.printStackTrace();
+ System.err.println("Something very bad happened. I don't know what to do, so I am going to exit :(");
+ System.exit(1);
}
}
public PluginMain(String inPipe, String outPipe) {
-
connect(inPipe, outPipe);
// must be called before JNLPRuntime.initialize()
@@ -130,87 +127,87 @@ public class PluginMain
securityContext.setStreamhandler(streamHandler);
AppletSecurityContextManager.addContext(0, securityContext);
- PluginAppletViewer.setStreamhandler(streamHandler);
- PluginAppletViewer.setPluginCallRequestFactory(new PluginCallRequestFactory());
+ PluginAppletViewer.setStreamhandler(streamHandler);
+ PluginAppletViewer.setPluginCallRequestFactory(new PluginCallRequestFactory());
init();
- // Streams set. Start processing.
- streamHandler.startProcessing();
+ // Streams set. Start processing.
+ streamHandler.startProcessing();
+ }
+
+ public void connect(String inPipe, String outPipe) {
+ try {
+ streamHandler = new PluginStreamHandler(new FileInputStream(inPipe), new FileOutputStream(outPipe));
+ PluginDebug.debug("Streams initialized");
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ }
}
- public void connect(String inPipe, String outPipe) {
- try {
- streamHandler = new PluginStreamHandler(new FileInputStream(inPipe), new FileOutputStream(outPipe));
- PluginDebug.debug("Streams initialized");
- } catch (IOException ioe) {
- ioe.printStackTrace();
- }
+ private static void init() {
+ Properties avProps = new Properties();
+
+ // ADD OTHER RANDOM PROPERTIES
+ // XXX 5/18 need to revisit why these are here, is there some
+ // standard for what is available?
+
+ // Standard browser properties
+ avProps.put("browser", "sun.applet.AppletViewer");
+ avProps.put("browser.version", "1.06");
+ avProps.put("browser.vendor", "Sun Microsystems Inc.");
+ avProps.put("http.agent", "Java(tm) 2 SDK, Standard Edition v" + theVersion);
+
+ // Define which packages can be extended by applets
+ // XXX 5/19 probably not needed, not checked in AppletSecurity
+ avProps.put("package.restrict.definition.java", "true");
+ avProps.put("package.restrict.definition.sun", "true");
+
+ // Define which properties can be read by applets.
+ // A property named by "key" can be read only when its twin
+ // property "key.applet" is true. The following ten properties
+ // are open by default. Any other property can be explicitly
+ // opened up by the browser user by calling appletviewer with
+ // -J-Dkey.applet=true
+ avProps.put("java.version.applet", "true");
+ avProps.put("java.vendor.applet", "true");
+ avProps.put("java.vendor.url.applet", "true");
+ avProps.put("java.class.version.applet", "true");
+ avProps.put("os.name.applet", "true");
+ avProps.put("os.version.applet", "true");
+ avProps.put("os.arch.applet", "true");
+ avProps.put("file.separator.applet", "true");
+ avProps.put("path.separator.applet", "true");
+ avProps.put("line.separator.applet", "true");
+
+ avProps.put("javaplugin.nodotversion", "160_17");
+ avProps.put("javaplugin.version", "1.6.0_17");
+ avProps.put("javaplugin.vm.options", "");
+
+ // Read in the System properties. If something is going to be
+ // over-written, warn about it.
+ Properties sysProps = System.getProperties();
+ for (Enumeration<?> e = sysProps.propertyNames(); e.hasMoreElements();) {
+ String key = (String) e.nextElement();
+ String val = sysProps.getProperty(key);
+ avProps.setProperty(key, val);
}
- private static void init() {
- Properties avProps = new Properties();
-
- // ADD OTHER RANDOM PROPERTIES
- // XXX 5/18 need to revisit why these are here, is there some
- // standard for what is available?
-
- // Standard browser properties
- avProps.put("browser", "sun.applet.AppletViewer");
- avProps.put("browser.version", "1.06");
- avProps.put("browser.vendor", "Sun Microsystems Inc.");
- avProps.put("http.agent", "Java(tm) 2 SDK, Standard Edition v" + theVersion);
-
- // Define which packages can be extended by applets
- // XXX 5/19 probably not needed, not checked in AppletSecurity
- avProps.put("package.restrict.definition.java", "true");
- avProps.put("package.restrict.definition.sun", "true");
-
- // Define which properties can be read by applets.
- // A property named by "key" can be read only when its twin
- // property "key.applet" is true. The following ten properties
- // are open by default. Any other property can be explicitly
- // opened up by the browser user by calling appletviewer with
- // -J-Dkey.applet=true
- avProps.put("java.version.applet", "true");
- avProps.put("java.vendor.applet", "true");
- avProps.put("java.vendor.url.applet", "true");
- avProps.put("java.class.version.applet", "true");
- avProps.put("os.name.applet", "true");
- avProps.put("os.version.applet", "true");
- avProps.put("os.arch.applet", "true");
- avProps.put("file.separator.applet", "true");
- avProps.put("path.separator.applet", "true");
- avProps.put("line.separator.applet", "true");
-
- avProps.put("javaplugin.nodotversion", "160_17");
- avProps.put("javaplugin.version", "1.6.0_17");
- avProps.put("javaplugin.vm.options", "");
-
- // Read in the System properties. If something is going to be
- // over-written, warn about it.
- Properties sysProps = System.getProperties();
- for (Enumeration<?> e = sysProps.propertyNames(); e.hasMoreElements(); ) {
- String key = (String) e.nextElement();
- String val = sysProps.getProperty(key);
- avProps.setProperty(key, val);
- }
-
- // INSTALL THE PROPERTY LIST
- System.setProperties(avProps);
-
- // plug in a custom authenticator and proxy selector
- boolean installAuthenticator = Boolean.valueOf(JNLPRuntime.getConfiguration()
+ // INSTALL THE PROPERTY LIST
+ System.setProperties(avProps);
+
+ // plug in a custom authenticator and proxy selector
+ boolean installAuthenticator = Boolean.valueOf(JNLPRuntime.getConfiguration()
.getProperty(DeploymentConfiguration.KEY_SECURITY_INSTALL_AUTHENTICATOR));
- if (installAuthenticator) {
- Authenticator.setDefault(new JNLPAuthenticator());
- }
+ if (installAuthenticator) {
+ Authenticator.setDefault(new JNLPAuthenticator());
+ }
// override the proxy selector set by JNLPRuntime
ProxySelector.setDefault(new PluginProxySelector());
CookieManager ckManager = new PluginCookieManager();
CookieHandler.setDefault(ckManager);
- }
+ }
static boolean messageAvailable() {
return streamHandler.messageAvailable();
diff --git a/plugin/icedteanp/java/sun/applet/PluginMessageConsumer.java b/plugin/icedteanp/java/sun/applet/PluginMessageConsumer.java
index 188155b..c30cdcb 100644
--- a/plugin/icedteanp/java/sun/applet/PluginMessageConsumer.java
+++ b/plugin/icedteanp/java/sun/applet/PluginMessageConsumer.java
@@ -45,36 +45,36 @@ import java.util.Set;
class PluginMessageConsumer {
- private static int MAX_PARALLEL_INITS = 1;
-
- // Each initialization requires 5 responses (tag, handle, width, proxy, cookie)
- // before the message stack unlocks/collapses. This works out well because we
- // want to allow upto 5 parallel tasks anyway
- private static int MAX_WORKERS = MAX_PARALLEL_INITS*4;
- private static int PRIORITY_WORKERS = MAX_PARALLEL_INITS*2;
-
- private static Hashtable<Integer, PluginMessageHandlerWorker> initWorkers = new Hashtable<Integer, PluginMessageHandlerWorker>(2);
-
- LinkedList<String> readQueue = new LinkedList<String>();
- private static LinkedList<String> priorityWaitQueue = new LinkedList<String>();
- ArrayList<PluginMessageHandlerWorker> workers = new ArrayList<PluginMessageHandlerWorker>();
- PluginStreamHandler streamHandler = null;
- AppletSecurity as;
- ConsumerThread consumerThread = new ConsumerThread();
- private static ArrayList<Integer> processedIds = new ArrayList<Integer>();
-
- /**
- * Registers a reference to wait for. Responses to registered priority
- * references get handled by priority worker if normal workers are busy.
- *
- * @param reference The reference to give priority to
- */
- public static void registerPriorityWait(Long reference) {
- PluginDebug.debug("Registering priority for reference " + reference);
- registerPriorityWait("reference " + reference.toString());
- }
-
- /**
+ private static int MAX_PARALLEL_INITS = 1;
+
+ // Each initialization requires 5 responses (tag, handle, width, proxy, cookie)
+ // before the message stack unlocks/collapses. This works out well because we
+ // want to allow upto 5 parallel tasks anyway
+ private static int MAX_WORKERS = MAX_PARALLEL_INITS * 4;
+ private static int PRIORITY_WORKERS = MAX_PARALLEL_INITS * 2;
+
+ private static Hashtable<Integer, PluginMessageHandlerWorker> initWorkers = new Hashtable<Integer, PluginMessageHandlerWorker>(2);
+
+ LinkedList<String> readQueue = new LinkedList<String>();
+ private static LinkedList<String> priorityWaitQueue = new LinkedList<String>();
+ ArrayList<PluginMessageHandlerWorker> workers = new ArrayList<PluginMessageHandlerWorker>();
+ PluginStreamHandler streamHandler = null;
+ AppletSecurity as;
+ ConsumerThread consumerThread = new ConsumerThread();
+ private static ArrayList<Integer> processedIds = new ArrayList<Integer>();
+
+ /**
+ * Registers a reference to wait for. Responses to registered priority
+ * references get handled by priority worker if normal workers are busy.
+ *
+ * @param reference The reference to give priority to
+ */
+ public static void registerPriorityWait(Long reference) {
+ PluginDebug.debug("Registering priority for reference " + reference);
+ registerPriorityWait("reference " + reference.toString());
+ }
+
+ /**
* Registers a string to wait for.
*
* @param searchString the string to look for in a response
@@ -87,7 +87,7 @@ class PluginMessageConsumer {
}
}
- /**
+ /**
* Unregisters a priority reference to wait for.
*
* @param reference The reference to remove
@@ -117,46 +117,46 @@ class PluginMessageConsumer {
private Long getReference(String[] msgParts) {
return Long.parseLong(msgParts[3]);
}
-
- public PluginMessageConsumer(PluginStreamHandler streamHandler) {
-
- as = new AppletSecurity();
- this.streamHandler = streamHandler;
- this.consumerThread.start();
- }
-
- private String getPriorityStrIfPriority(String message) {
-
- // Destroy messages are permanently high priority
- if (message.endsWith("destroy"))
+
+ public PluginMessageConsumer(PluginStreamHandler streamHandler) {
+
+ as = new AppletSecurity();
+ this.streamHandler = streamHandler;
+ this.consumerThread.start();
+ }
+
+ private String getPriorityStrIfPriority(String message) {
+
+ // Destroy messages are permanently high priority
+ if (message.endsWith("destroy"))
return "destroy";
- synchronized (priorityWaitQueue) {
- Iterator<String> it = priorityWaitQueue.iterator();
+ synchronized (priorityWaitQueue) {
+ Iterator<String> it = priorityWaitQueue.iterator();
- while (it.hasNext()) {
- String priorityStr = it.next();
- if (message.indexOf(priorityStr) > 0)
- return priorityStr;
- }
- }
+ while (it.hasNext()) {
+ String priorityStr = it.next();
+ if (message.indexOf(priorityStr) > 0)
+ return priorityStr;
+ }
+ }
- return null;
- }
+ return null;
+ }
- private boolean isInInit(Integer instanceNum) {
- return initWorkers.containsKey(instanceNum);
- }
+ private boolean isInInit(Integer instanceNum) {
+ return initWorkers.containsKey(instanceNum);
+ }
- private void addToInitWorkers(Integer instanceNum, PluginMessageHandlerWorker worker) {
- synchronized(initWorkers) {
+ private void addToInitWorkers(Integer instanceNum, PluginMessageHandlerWorker worker) {
+ synchronized (initWorkers) {
initWorkers.put(instanceNum, worker);
}
- }
+ }
- public void notifyWorkerIsFree(PluginMessageHandlerWorker worker) {
- synchronized (initWorkers) {
- Iterator<Integer> i = initWorkers.keySet().iterator();
+ public void notifyWorkerIsFree(PluginMessageHandlerWorker worker) {
+ synchronized (initWorkers) {
+ Iterator<Integer> i = initWorkers.keySet().iterator();
while (i.hasNext()) {
Integer key = i.next();
if (initWorkers.get(key).equals(worker)) {
@@ -164,136 +164,137 @@ class PluginMessageConsumer {
initWorkers.remove(key);
}
}
- }
-
- consumerThread.interrupt();
- }
-
- public void queue(String message) {
- synchronized(readQueue) {
- readQueue.addLast(message);
- }
-
- // Wake that lazy consumer thread
- consumerThread.interrupt();
- }
-
- protected class ConsumerThread extends Thread {
-
- /**
- * Scans the readQueue for priority messages and brings them to the front
- */
- private void bringPriorityMessagesToFront() {
- synchronized (readQueue) {
-
- // iterate through the list
- for (int i=0; i < readQueue.size(); i++) {
-
- // remove element at i to inspect it
- String message = readQueue.remove(i);
-
- // if element at i is a priority msg, bring it forward
- if (getPriorityStrIfPriority(message) != null) {
- readQueue.addFirst(message);
- } else { // else keep it where it was
- readQueue.add(i, message);
- }
-
- // by the end the queue size is the same, so the
- // position indicator (i) is still valid
- }
- }
- }
-
- public void run() {
-
- while (true) {
+ }
+
+ consumerThread.interrupt();
+ }
+
+ public void queue(String message) {
+ synchronized (readQueue) {
+ readQueue.addLast(message);
+ }
+
+ // Wake that lazy consumer thread
+ consumerThread.interrupt();
+ }
+
+ protected class ConsumerThread extends Thread {
+
+ /**
+ * Scans the readQueue for priority messages and brings them to the front
+ */
+ private void bringPriorityMessagesToFront() {
+ synchronized (readQueue) {
+
+ // iterate through the list
+ for (int i = 0; i < readQueue.size(); i++) {
+
+ // remove element at i to inspect it
+ String message = readQueue.remove(i);
+
+ // if element at i is a priority msg, bring it forward
+ if (getPriorityStrIfPriority(message) != null) {
+ readQueue.addFirst(message);
+ } else { // else keep it where it was
+ readQueue.add(i, message);
+ }
+
+ // by the end the queue size is the same, so the
+ // position indicator (i) is still valid
+ }
+ }
+ }
+
+ public void run() {
+
+ while (true) {
String message = null;
- synchronized(readQueue) {
- message = readQueue.poll();
- }
+ synchronized (readQueue) {
+ message = readQueue.poll();
+ }
+
+ if (message != null) {
- if (message != null) {
+ String[] msgParts = message.split(" ");
- String[] msgParts = message.split(" ");
+ String priorityStr = getPriorityStrIfPriority(message);
+ boolean isPriorityResponse = (priorityStr != null);
- String priorityStr = getPriorityStrIfPriority(message);
- boolean isPriorityResponse = (priorityStr != null);
-
- //PluginDebug.debug("Message " + message + " (priority=" + isPriorityResponse + ") ready to be processed. Looking for free worker...");
- final PluginMessageHandlerWorker worker = getFreeWorker(isPriorityResponse);
-
- if (worker == null) {
- synchronized(readQueue) {
+ //PluginDebug.debug("Message " + message + " (priority=" + isPriorityResponse + ") ready to be processed. Looking for free worker...");
+ final PluginMessageHandlerWorker worker = getFreeWorker(isPriorityResponse);
+
+ if (worker == null) {
+ synchronized (readQueue) {
readQueue.addFirst(message);
}
- // re-scan to see if any priority message came in
+ // re-scan to see if any priority message came in
bringPriorityMessagesToFront();
-
- continue; // re-loop to try next msg
- }
- if (msgParts[2].equals("tag"))
- addToInitWorkers((new Integer(msgParts[1])), worker);
+ continue; // re-loop to try next msg
+ }
+
+ if (msgParts[2].equals("tag"))
+ addToInitWorkers((new Integer(msgParts[1])), worker);
- if (isPriorityResponse) {
- unRegisterPriorityWait(priorityStr);
- }
+ if (isPriorityResponse) {
+ unRegisterPriorityWait(priorityStr);
+ }
worker.setmessage(message);
- worker.interrupt();
-
- } else {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException ie) {}
- }
- }
- }
- }
-
- private PluginMessageHandlerWorker getFreeWorker(boolean prioritized) {
-
- for (PluginMessageHandlerWorker worker: workers) {
- if (worker.isFree(prioritized)) {
- PluginDebug.debug("Found free worker (" + worker.isPriority() + ") with id " + worker.getWorkerId());
- // mark it busy before returning
- worker.busy();
- return worker;
- }
- }
-
- // If we have less than MAX_WORKERS, create a new worker
- if (workers.size() <= MAX_WORKERS) {
- PluginMessageHandlerWorker worker = null;
-
- if (workers.size() < (MAX_WORKERS - PRIORITY_WORKERS)) {
- PluginDebug.debug("Cannot find free worker, creating worker " + workers.size());
- worker = new PluginMessageHandlerWorker(this, streamHandler, workers.size(), as, false);
- } else if (prioritized) {
- PluginDebug.debug("Cannot find free worker, creating priority worker " + workers.size());
- worker = new PluginMessageHandlerWorker(this, streamHandler, workers.size(), as, true);
- } else {
- return null;
- }
-
- worker.start();
- worker.busy();
- workers.add(worker);
- return worker;
-
- }
-
- // No workers available. Better luck next time!
- return null;
- }
-
- private void dumpWorkerStatus() {
- for (PluginMessageHandlerWorker worker: workers) {
- PluginDebug.debug(worker.toString());
- }
- }
+ worker.interrupt();
+
+ } else {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ie) {
+ }
+ }
+ }
+ }
+ }
+
+ private PluginMessageHandlerWorker getFreeWorker(boolean prioritized) {
+
+ for (PluginMessageHandlerWorker worker : workers) {
+ if (worker.isFree(prioritized)) {
+ PluginDebug.debug("Found free worker (" + worker.isPriority() + ") with id " + worker.getWorkerId());
+ // mark it busy before returning
+ worker.busy();
+ return worker;
+ }
+ }
+
+ // If we have less than MAX_WORKERS, create a new worker
+ if (workers.size() <= MAX_WORKERS) {
+ PluginMessageHandlerWorker worker = null;
+
+ if (workers.size() < (MAX_WORKERS - PRIORITY_WORKERS)) {
+ PluginDebug.debug("Cannot find free worker, creating worker " + workers.size());
+ worker = new PluginMessageHandlerWorker(this, streamHandler, workers.size(), as, false);
+ } else if (prioritized) {
+ PluginDebug.debug("Cannot find free worker, creating priority worker " + workers.size());
+ worker = new PluginMessageHandlerWorker(this, streamHandler, workers.size(), as, true);
+ } else {
+ return null;
+ }
+
+ worker.start();
+ worker.busy();
+ workers.add(worker);
+ return worker;
+
+ }
+
+ // No workers available. Better luck next time!
+ return null;
+ }
+
+ private void dumpWorkerStatus() {
+ for (PluginMessageHandlerWorker worker : workers) {
+ PluginDebug.debug(worker.toString());
+ }
+ }
}
diff --git a/plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java b/plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java
index 30714c4..91e3746 100644
--- a/plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java
+++ b/plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java
@@ -35,113 +35,109 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package sun.applet;
-
class PluginMessageHandlerWorker extends Thread {
- private boolean free = true;
- private boolean isPriorityWorker = false;
- private int id;
- private String message = null;
- private SecurityManager sm;
- PluginStreamHandler streamHandler = null;
- PluginMessageConsumer consumer = null;
-
- public PluginMessageHandlerWorker(
- PluginMessageConsumer consumer,
- PluginStreamHandler streamHandler, int id,
- SecurityManager sm, boolean isPriorityWorker) {
-
- this.id = id;
- this.streamHandler = streamHandler;
- this.sm = sm;
- this.isPriorityWorker = isPriorityWorker;
- this.consumer = consumer;
-
- PluginDebug.debug("Worker " + this.id + " (priority=" + isPriorityWorker + ") created.");
- }
-
- public void setmessage(String message) {
- this.message = message;
- }
-
- public void run() {
- while (true) {
-
- if (message != null) {
-
- PluginDebug.debug("Consumer (priority=" + isPriorityWorker + ") thread " + id + " consuming " + message);
-
- // ideally, whoever returns things object should mark it
- // busy first, but just in case..
- busy();
-
- try {
- streamHandler.handleMessage(message);
- } catch (PluginException pe) {
- /*
- catch the exception and DO NOTHING. The plugin should take over after
- this error and let the user know. We don't quit because otherwise the
- exception will spread to the rest of the applets which is a no-no
- */
- }
-
- this.message = null;
-
- PluginDebug.debug("Consumption (priority=" + isPriorityWorker + ") completed by consumer thread " + id);
-
- // mark ourselves free again
- free();
-
- } else {
-
- // Sleep when there is nothing to do
- try {
- Thread.sleep(Integer.MAX_VALUE);
- PluginDebug.debug("Consumer thread " + id + " sleeping...");
- } catch (InterruptedException ie) {
- PluginDebug.debug("Consumer thread " + id + " woken...");
- // nothing.. someone woke us up, see if there
- // is work to do
- }
- }
- }
- }
-
-
-
- public int getWorkerId() {
- return id;
- }
-
- public void busy() {
- synchronized (this) {
- this.free = false;
+ private boolean free = true;
+ private boolean isPriorityWorker = false;
+ private int id;
+ private String message = null;
+ private SecurityManager sm;
+ PluginStreamHandler streamHandler = null;
+ PluginMessageConsumer consumer = null;
+
+ public PluginMessageHandlerWorker(
+ PluginMessageConsumer consumer,
+ PluginStreamHandler streamHandler, int id,
+ SecurityManager sm, boolean isPriorityWorker) {
+
+ this.id = id;
+ this.streamHandler = streamHandler;
+ this.sm = sm;
+ this.isPriorityWorker = isPriorityWorker;
+ this.consumer = consumer;
+
+ PluginDebug.debug("Worker " + this.id + " (priority=" + isPriorityWorker + ") created.");
+ }
+
+ public void setmessage(String message) {
+ this.message = message;
+ }
+
+ public void run() {
+ while (true) {
+
+ if (message != null) {
+
+ PluginDebug.debug("Consumer (priority=" + isPriorityWorker + ") thread " + id + " consuming " + message);
+
+ // ideally, whoever returns things object should mark it
+ // busy first, but just in case..
+ busy();
+
+ try {
+ streamHandler.handleMessage(message);
+ } catch (PluginException pe) {
+ /*
+ catch the exception and DO NOTHING. The plugin should take over after
+ this error and let the user know. We don't quit because otherwise the
+ exception will spread to the rest of the applets which is a no-no
+ */
+ }
+
+ this.message = null;
+
+ PluginDebug.debug("Consumption (priority=" + isPriorityWorker + ") completed by consumer thread " + id);
+
+ // mark ourselves free again
+ free();
+
+ } else {
+
+ // Sleep when there is nothing to do
+ try {
+ Thread.sleep(Integer.MAX_VALUE);
+ PluginDebug.debug("Consumer thread " + id + " sleeping...");
+ } catch (InterruptedException ie) {
+ PluginDebug.debug("Consumer thread " + id + " woken...");
+ // nothing.. someone woke us up, see if there
+ // is work to do
+ }
+ }
+ }
+ }
+
+ public int getWorkerId() {
+ return id;
+ }
+
+ public void busy() {
+ synchronized (this) {
+ this.free = false;
+ }
+ }
+
+ public void free() {
+ synchronized (this) {
+ this.free = true;
+
+ // Signal the consumer that we are done in case it was waiting
+ consumer.notifyWorkerIsFree(this);
+ }
+ }
+
+ public boolean isPriority() {
+ return isPriorityWorker;
+ }
+
+ public boolean isFree(boolean prioritized) {
+ synchronized (this) {
+ return free && (prioritized == isPriorityWorker);
}
- }
-
- public void free() {
- synchronized (this) {
- this.free = true;
-
- // Signal the consumer that we are done in case it was waiting
- consumer.notifyWorkerIsFree(this);
- }
- }
-
- public boolean isPriority() {
- return isPriorityWorker;
- }
-
- public boolean isFree(boolean prioritized) {
- synchronized (this) {
- return free && (prioritized == isPriorityWorker);
- }
- }
-
- public String toString() {
- return "Worker #" + this.id + "/IsPriority=" + this.isPriorityWorker + "/IsFree=" + this.free + "/Message=" + message;
- }
+ }
+
+ public String toString() {
+ return "Worker #" + this.id + "/IsPriority=" + this.isPriorityWorker + "/IsFree=" + this.free + "/Message=" + message;
+ }
}
diff --git a/plugin/icedteanp/java/sun/applet/PluginObjectStore.java b/plugin/icedteanp/java/sun/applet/PluginObjectStore.java
index 9960211..a0c6f6e 100644
--- a/plugin/icedteanp/java/sun/applet/PluginObjectStore.java
+++ b/plugin/icedteanp/java/sun/applet/PluginObjectStore.java
@@ -41,11 +41,10 @@ import java.util.*;
import java.lang.reflect.*;
import java.io.*;
-public class PluginObjectStore
-{
- private static HashMap<Integer, Object> objects = new HashMap<Integer,Object>();
- private static HashMap<Integer, Integer> counts = new HashMap<Integer,Integer>();
- private static HashMap<Object, Integer> identifiers = new HashMap<Object,Integer>();
+public class PluginObjectStore {
+ private static HashMap<Integer, Object> objects = new HashMap<Integer, Object>();
+ private static HashMap<Integer, Integer> counts = new HashMap<Integer, Integer>();
+ private static HashMap<Object, Integer> identifiers = new HashMap<Object, Integer>();
// FIXME:
//
// IF uniqueID == MAX_LONG, uniqueID =
@@ -73,13 +72,13 @@ public class PluginObjectStore
public boolean contains(Object object) {
if (object == null)
- return identifiers.containsKey(object);
+ return identifiers.containsKey(object);
return false;
}
public boolean contains(int identifier) {
- return objects.containsKey(identifier);
+ return objects.containsKey(identifier);
}
public void reference(Object object) {
@@ -122,11 +121,10 @@ public class PluginObjectStore
}
public void dump() {
- Iterator i = objects.keySet().iterator();
- while (i.hasNext()) {
- Object key = i.next();
- PluginDebug.debug(key + "::" + objects.get(key));
- }
+ Iterator i = objects.keySet().iterator();
+ while (i.hasNext()) {
+ Object key = i.next();
+ PluginDebug.debug(key + "::" + objects.get(key));
+ }
}
}
-
diff --git a/plugin/icedteanp/java/sun/applet/PluginProxyInfoRequest.java b/plugin/icedteanp/java/sun/applet/PluginProxyInfoRequest.java
index 674f11d..b6e12d4 100644
--- a/plugin/icedteanp/java/sun/applet/PluginProxyInfoRequest.java
+++ b/plugin/icedteanp/java/sun/applet/PluginProxyInfoRequest.java
@@ -45,37 +45,37 @@ import java.net.URI;
*/
public class PluginProxyInfoRequest extends PluginCallRequest {
-
+
URI internal = null;
public PluginProxyInfoRequest(String message, Long reference) {
super(message, reference);
}
-
+
public void parseReturn(String proxyInfo) {
// try to parse the proxy information. If things go wrong, do nothing ..
// this will keep internal = null which forces a direct connection
- PluginDebug.debug ("PluginProxyInfoRequest GOT: " + proxyInfo);
- String[] messageComponents = proxyInfo.split(" ");
+ PluginDebug.debug("PluginProxyInfoRequest GOT: " + proxyInfo);
+ String[] messageComponents = proxyInfo.split(" ");
- try {
- String protocol = messageComponents[4].equals("PROXY") ? "http" : "socks";
- String host = messageComponents[5].split(":")[0];
- int port = Integer.parseInt(messageComponents[5].split(":")[1]);
+ try {
+ String protocol = messageComponents[4].equals("PROXY") ? "http" : "socks";
+ String host = messageComponents[5].split(":")[0];
+ int port = Integer.parseInt(messageComponents[5].split(":")[1]);
- internal = new URI(protocol, null, host, port, null, null, null);
- } catch (ArrayIndexOutOfBoundsException aioobe) {
- // Nothing.. this is expected if there is no proxy
- } catch (Exception e) {
- e.printStackTrace();
- }
+ internal = new URI(protocol, null, host, port, null, null, null);
+ } catch (ArrayIndexOutOfBoundsException aioobe) {
+ // Nothing.. this is expected if there is no proxy
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
setDone(true);
}
public URI getObject() {
- return this.internal;
+ return this.internal;
}
}
diff --git a/plugin/icedteanp/java/sun/applet/PluginProxySelector.java b/plugin/icedteanp/java/sun/applet/PluginProxySelector.java
index 36236ba..dc716f7 100644
--- a/plugin/icedteanp/java/sun/applet/PluginProxySelector.java
+++ b/plugin/icedteanp/java/sun/applet/PluginProxySelector.java
@@ -138,7 +138,7 @@ public class PluginProxySelector extends JNLPProxySelector {
* @param <V> The Object type
*/
- private class TimedHashMap<K,V> extends HashMap<K,V> {
+ private class TimedHashMap<K, V> extends HashMap<K, V> {
HashMap<K, Long> timeStamps = new HashMap<K, Long>();
Long expiry = 10000L;
@@ -176,7 +176,7 @@ public class PluginProxySelector extends JNLPProxySelector {
timeStamps.put((K) key, (new Date()).getTime());
return super.get(key);
} else {
- PluginDebug.debug("Proxy cache for " + key + " has expired (age=" + age/1000.0 + " seconds)");
+ PluginDebug.debug("Proxy cache for " + key + " has expired (age=" + age / 1000.0 + " seconds)");
}
}
diff --git a/plugin/icedteanp/java/sun/applet/PluginStreamHandler.java b/plugin/icedteanp/java/sun/applet/PluginStreamHandler.java
index eb5b11a..bd95493 100644
--- a/plugin/icedteanp/java/sun/applet/PluginStreamHandler.java
+++ b/plugin/icedteanp/java/sun/applet/PluginStreamHandler.java
@@ -35,7 +35,6 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package sun.applet;
import java.io.BufferedReader;
@@ -54,234 +53,232 @@ import java.util.LinkedList;
import javax.swing.SwingUtilities;
-
public class PluginStreamHandler {
private BufferedReader pluginInputReader;
private StreamTokenizer pluginInputTokenizer;
private BufferedWriter pluginOutputWriter;
-
+
private RequestQueue queue = new RequestQueue();
-
+
private JavaConsole console = new JavaConsole();
- LinkedList<String> writeQueue = new LinkedList<String>();
-
- PluginMessageConsumer consumer;
- Boolean shuttingDown = false;
-
- PluginAppletViewer pav;
-
- static Date d = new Date();
- static long startTime = d.getTime();
- static long totalWait = 0;
-
+ LinkedList<String> writeQueue = new LinkedList<String>();
+
+ PluginMessageConsumer consumer;
+ Boolean shuttingDown = false;
+
+ PluginAppletViewer pav;
+
+ static Date d = new Date();
+ static long startTime = d.getTime();
+ static long totalWait = 0;
+
public PluginStreamHandler(InputStream inputstream, OutputStream outputstream)
- throws MalformedURLException, IOException
- {
-
- PluginDebug.debug("Current context CL=" + Thread.currentThread().getContextClassLoader());
- try {
- pav = (PluginAppletViewer) ClassLoader.getSystemClassLoader().loadClass("sun.applet.PluginAppletViewer").newInstance();
- PluginDebug.debug("Loaded: " + pav + " CL=" + pav.getClass().getClassLoader());
- } catch (InstantiationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- PluginDebug.debug("Creating consumer...");
- consumer = new PluginMessageConsumer(this);
-
- // Set up input and output pipes. Use UTF-8 encoding.
- pluginInputReader =
- new BufferedReader(new InputStreamReader(inputstream,
- Charset.forName("UTF-8")));
- /*pluginInputTokenizer = new StreamTokenizer(pluginInputReader);
- pluginInputTokenizer.resetSyntax();
- pluginInputTokenizer.whitespaceChars('\u0000', '\u0000');
- pluginInputTokenizer.wordChars('\u0001', '\u00FF');*/
- pluginOutputWriter =
- new BufferedWriter(new OutputStreamWriter
- (outputstream, Charset.forName("UTF-8")));
-
- /*
- while(true) {
+ throws MalformedURLException, IOException {
+
+ PluginDebug.debug("Current context CL=" + Thread.currentThread().getContextClassLoader());
+ try {
+ pav = (PluginAppletViewer) ClassLoader.getSystemClassLoader().loadClass("sun.applet.PluginAppletViewer").newInstance();
+ PluginDebug.debug("Loaded: " + pav + " CL=" + pav.getClass().getClassLoader());
+ } catch (InstantiationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ClassNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ PluginDebug.debug("Creating consumer...");
+ consumer = new PluginMessageConsumer(this);
+
+ // Set up input and output pipes. Use UTF-8 encoding.
+ pluginInputReader =
+ new BufferedReader(new InputStreamReader(inputstream,
+ Charset.forName("UTF-8")));
+ /*pluginInputTokenizer = new StreamTokenizer(pluginInputReader);
+ pluginInputTokenizer.resetSyntax();
+ pluginInputTokenizer.whitespaceChars('\u0000', '\u0000');
+ pluginInputTokenizer.wordChars('\u0001', '\u00FF');*/
+ pluginOutputWriter =
+ new BufferedWriter(new OutputStreamWriter
+ (outputstream, Charset.forName("UTF-8")));
+
+ /*
+ while(true) {
String message = read();
PluginDebug.debug(message);
handleMessage(message);
// TODO:
// write(queue.peek());
- }
- */
+ }
+ */
}
public void startProcessing() {
- Thread listenerThread = new Thread() {
-
- public void run() {
-
- while (true) {
-
- PluginDebug.debug("Waiting for data...");
-
- long b4 = new Date().getTime();
-
- String s = read();
-
- long after = new Date().getTime();
-
- totalWait += (after - b4);
- //System.err.println("Total wait time: " + totalWait);
-
- if (s != null) {
- consumer.queue(s);
- } else {
- try {
- // Close input/output channels to plugin.
- pluginInputReader.close();
- pluginOutputWriter.close();
- } catch (IOException exception) {
- // Deliberately ignore IOException caused by broken
- // pipe since plugin may have already detached.
- }
- AppletSecurityContextManager.dumpStore(0);
- PluginDebug.debug("APPLETVIEWER: exiting appletviewer");
- System.exit(0);
- }
-
-/*
- int readChar = -1;
- // blocking read, discard first character
- try {
- readChar = pluginInputReader.read();
- } catch (IOException ioe) {
- // plugin may have detached
- }
-
- // if not disconnected
- if (readChar != -1) {
- String s = read();
- PluginDebug.debug("Got data, consuming " + s);
- consumer.consume(s);
- } else {
- try {
- // Close input/output channels to plugin.
- pluginInputReader.close();
- pluginOutputWriter.close();
- } catch (IOException exception) {
- // Deliberately ignore IOException caused by broken
- // pipe since plugin may have already detached.
- }
- AppletSecurityContextManager.dumpStore(0);
- PluginDebug.debug("APPLETVIEWER: exiting appletviewer");
- System.exit(0);
- }
-*/
- }
- }
- };
-
- listenerThread.start();
+ Thread listenerThread = new Thread() {
+
+ public void run() {
+
+ while (true) {
+
+ PluginDebug.debug("Waiting for data...");
+
+ long b4 = new Date().getTime();
+
+ String s = read();
+
+ long after = new Date().getTime();
+
+ totalWait += (after - b4);
+ //System.err.println("Total wait time: " + totalWait);
+
+ if (s != null) {
+ consumer.queue(s);
+ } else {
+ try {
+ // Close input/output channels to plugin.
+ pluginInputReader.close();
+ pluginOutputWriter.close();
+ } catch (IOException exception) {
+ // Deliberately ignore IOException caused by broken
+ // pipe since plugin may have already detached.
+ }
+ AppletSecurityContextManager.dumpStore(0);
+ PluginDebug.debug("APPLETVIEWER: exiting appletviewer");
+ System.exit(0);
+ }
+
+ /*
+ int readChar = -1;
+ // blocking read, discard first character
+ try {
+ readChar = pluginInputReader.read();
+ } catch (IOException ioe) {
+ // plugin may have detached
+ }
+
+ // if not disconnected
+ if (readChar != -1) {
+ String s = read();
+ PluginDebug.debug("Got data, consuming " + s);
+ consumer.consume(s);
+ } else {
+ try {
+ // Close input/output channels to plugin.
+ pluginInputReader.close();
+ pluginOutputWriter.close();
+ } catch (IOException exception) {
+ // Deliberately ignore IOException caused by broken
+ // pipe since plugin may have already detached.
+ }
+ AppletSecurityContextManager.dumpStore(0);
+ PluginDebug.debug("APPLETVIEWER: exiting appletviewer");
+ System.exit(0);
+ }
+ */
+ }
+ }
+ };
+
+ listenerThread.start();
}
-
+
public void handleMessage(String message) throws PluginException {
- int nextIndex = 0;
- int reference = -1;
- String src = null;
- String[] privileges = null;
- String rest = "";
+ int nextIndex = 0;
+ int reference = -1;
+ String src = null;
+ String[] privileges = null;
+ String rest = "";
+
+ String[] msgComponents = message.split(" ");
- String[] msgComponents = message.split(" ");
-
- if (msgComponents.length < 2)
- return;
+ if (msgComponents.length < 2)
+ return;
if (msgComponents[0].startsWith("plugin")) {
handlePluginMessage(message);
return;
}
- // type and identifier are guaranteed to be there
- String type = msgComponents[0];
- final int identifier = Integer.parseInt(msgComponents[1]);
- nextIndex = 2;
-
- // reference, src and privileges are optional components,
- // and are guaranteed to be in that order, if they occur
-
- // is there a reference ?
- if (msgComponents[nextIndex].equals("reference")) {
- reference = Integer.parseInt(msgComponents[nextIndex+1]);
- nextIndex += 2;
- }
-
- // is there a src?
- if (msgComponents[nextIndex].equals("src")) {
- src = msgComponents[nextIndex+1];
- nextIndex += 2;
- }
-
- // is there a privileges?
- if (msgComponents[nextIndex].equals("privileges")) {
- String privs = msgComponents[nextIndex+1];
- privileges = privs.split(",");
- nextIndex += 2;
- }
-
- // rest
- for (int i=nextIndex; i < msgComponents.length; i++) {
- rest += msgComponents[i];
- rest += " ";
- }
-
- rest = rest.trim();
-
- try {
-
- PluginDebug.debug("Breakdown -- type: " + type + " identifier: " + identifier + " reference: " + reference + " src: " + src + " privileges: " + privileges + " rest: \"" + rest + "\"");
-
- if (rest.contains("JavaScriptGetWindow")
- || rest.contains("JavaScriptGetMember")
- || rest.contains("JavaScriptSetMember")
- || rest.contains("JavaScriptGetSlot")
- || rest.contains("JavaScriptSetSlot")
- || rest.contains("JavaScriptEval")
- || rest.contains("JavaScriptRemoveMember")
- || rest.contains("JavaScriptCall")
- || rest.contains("JavaScriptFinalize")
- || rest.contains("JavaScriptToString")) {
-
- finishCallRequest("reference " + reference + " " + rest);
- return;
- }
-
- final int freference = reference;
- final String frest = rest;
-
- if (type.equals("instance")) {
- PluginAppletViewer.handleMessage(identifier, freference,frest);
- } else if (type.equals("context")) {
- PluginDebug.debug("Sending to PASC: " + identifier + "/" + reference + " and " + rest);
- AppletSecurityContextManager.handleMessage(identifier, reference, src, privileges, rest);
- }
- } catch (Exception e) {
- throw new PluginException(this, identifier, reference, e);
- }
+ // type and identifier are guaranteed to be there
+ String type = msgComponents[0];
+ final int identifier = Integer.parseInt(msgComponents[1]);
+ nextIndex = 2;
+
+ // reference, src and privileges are optional components,
+ // and are guaranteed to be in that order, if they occur
+
+ // is there a reference ?
+ if (msgComponents[nextIndex].equals("reference")) {
+ reference = Integer.parseInt(msgComponents[nextIndex + 1]);
+ nextIndex += 2;
+ }
+
+ // is there a src?
+ if (msgComponents[nextIndex].equals("src")) {
+ src = msgComponents[nextIndex + 1];
+ nextIndex += 2;
+ }
+
+ // is there a privileges?
+ if (msgComponents[nextIndex].equals("privileges")) {
+ String privs = msgComponents[nextIndex + 1];
+ privileges = privs.split(",");
+ nextIndex += 2;
+ }
+
+ // rest
+ for (int i = nextIndex; i < msgComponents.length; i++) {
+ rest += msgComponents[i];
+ rest += " ";
+ }
+
+ rest = rest.trim();
+
+ try {
+
+ PluginDebug.debug("Breakdown -- type: " + type + " identifier: " + identifier + " reference: " + reference + " src: " + src + " privileges: " + privileges + " rest: \"" + rest + "\"");
+
+ if (rest.contains("JavaScriptGetWindow")
+ || rest.contains("JavaScriptGetMember")
+ || rest.contains("JavaScriptSetMember")
+ || rest.contains("JavaScriptGetSlot")
+ || rest.contains("JavaScriptSetSlot")
+ || rest.contains("JavaScriptEval")
+ || rest.contains("JavaScriptRemoveMember")
+ || rest.contains("JavaScriptCall")
+ || rest.contains("JavaScriptFinalize")
+ || rest.contains("JavaScriptToString")) {
+
+ finishCallRequest("reference " + reference + " " + rest);
+ return;
+ }
+
+ final int freference = reference;
+ final String frest = rest;
+
+ if (type.equals("instance")) {
+ PluginAppletViewer.handleMessage(identifier, freference, frest);
+ } else if (type.equals("context")) {
+ PluginDebug.debug("Sending to PASC: " + identifier + "/" + reference + " and " + rest);
+ AppletSecurityContextManager.handleMessage(identifier, reference, src, privileges, rest);
+ }
+ } catch (Exception e) {
+ throw new PluginException(this, identifier, reference, e);
+ }
}
private void handlePluginMessage(String message) {
if (message.equals("plugin showconsole")) {
showConsole();
} else if (message.equals("plugin hideconsole")) {
- hideConsole();
+ hideConsole();
} else {
// else this is something that was specifically requested
finishCallRequest(message);
@@ -289,60 +286,60 @@ public class PluginStreamHandler {
}
public void postCallRequest(PluginCallRequest request) {
- synchronized(queue) {
- queue.post(request);
+ synchronized (queue) {
+ queue.post(request);
}
}
private void finishCallRequest(String message) {
- PluginDebug.debug ("DISPATCHCALLREQUESTS 1");
- synchronized(queue) {
- PluginDebug.debug ("DISPATCHCALLREQUESTS 2");
- PluginCallRequest request = queue.pop();
-
- // make sure we give the message to the right request
- // in the queue.. for the love of God, MAKE SURE!
-
- // first let's be efficient.. if there was only one
- // request in queue, we're already set
- if (queue.size() != 0) {
-
- int size = queue.size();
- int count = 0;
-
- while (!request.serviceable(message)) {
-
- PluginDebug.debug(request + " cannot service " + message);
-
- // something is very wrong.. we have a message to
- // process, but no one to service it
- if (count >= size) {
- throw new RuntimeException("Unable to find processor for message " + message);
- }
-
- // post request at the end of the queue
- queue.post(request);
-
- // Look at the next request
- request = queue.pop();
-
- count++;
- }
-
- }
-
- PluginDebug.debug ("DISPATCHCALLREQUESTS 3");
- if (request != null) {
- PluginDebug.debug ("DISPATCHCALLREQUESTS 5");
- synchronized(request) {
- request.parseReturn(message);
- request.notifyAll();
- }
- PluginDebug.debug ("DISPATCHCALLREQUESTS 6");
- PluginDebug.debug ("DISPATCHCALLREQUESTS 7");
- }
- }
- PluginDebug.debug ("DISPATCHCALLREQUESTS 8");
+ PluginDebug.debug("DISPATCHCALLREQUESTS 1");
+ synchronized (queue) {
+ PluginDebug.debug("DISPATCHCALLREQUESTS 2");
+ PluginCallRequest request = queue.pop();
+
+ // make sure we give the message to the right request
+ // in the queue.. for the love of God, MAKE SURE!
+
+ // first let's be efficient.. if there was only one
+ // request in queue, we're already set
+ if (queue.size() != 0) {
+
+ int size = queue.size();
+ int count = 0;
+
+ while (!request.serviceable(message)) {
+
+ PluginDebug.debug(request + " cannot service " + message);
+
+ // something is very wrong.. we have a message to
+ // process, but no one to service it
+ if (count >= size) {
+ throw new RuntimeException("Unable to find processor for message " + message);
+ }
+
+ // post request at the end of the queue
+ queue.post(request);
+
+ // Look at the next request
+ request = queue.pop();
+
+ count++;
+ }
+
+ }
+
+ PluginDebug.debug("DISPATCHCALLREQUESTS 3");
+ if (request != null) {
+ PluginDebug.debug("DISPATCHCALLREQUESTS 5");
+ synchronized (request) {
+ request.parseReturn(message);
+ request.notifyAll();
+ }
+ PluginDebug.debug("DISPATCHCALLREQUESTS 6");
+ PluginDebug.debug("DISPATCHCALLREQUESTS 7");
+ }
+ }
+ PluginDebug.debug("DISPATCHCALLREQUESTS 8");
}
/**
@@ -352,16 +349,15 @@ public class PluginStreamHandler {
*
* @exception IOException if an error occurs
*/
- private String read()
- {
- String message = null;
+ private String read() {
+ String message = null;
- try {
- message = pluginInputReader.readLine();
- PluginDebug.debug(" PIPE: appletviewer read: " + message);
+ try {
+ message = pluginInputReader.readLine();
+ PluginDebug.debug(" PIPE: appletviewer read: " + message);
if (message == null || message.equals("shutdown")) {
- synchronized(shuttingDown) {
+ synchronized (shuttingDown) {
shuttingDown = true;
}
try {
@@ -376,13 +372,13 @@ public class PluginStreamHandler {
PluginDebug.debug("APPLETVIEWER: exiting appletviewer");
System.exit(0);
}
- } catch (IOException e) {
- e.printStackTrace();
- }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
- return message;
+ return message;
}
-
+
/**
* Write string to plugin.
*
@@ -390,52 +386,51 @@ public class PluginStreamHandler {
*
* @exception IOException if an error occurs
*/
- public void write(String message)
- {
-
- PluginDebug.debug(" PIPE: appletviewer wrote: " + message);
- synchronized(pluginOutputWriter) {
- try {
- pluginOutputWriter.write(message + "\n", 0, message.length());
- pluginOutputWriter.write(0);
- pluginOutputWriter.flush();
- } catch (IOException e) {
- // if we are shutting down, ignore write failures as
- // pipe may have closed
- synchronized(shuttingDown) {
- if (!shuttingDown) {
- e.printStackTrace();
- }
- }
-
- // either ways, if the pipe is broken, there is nothing
- // we can do anymore. Don't hang around.
- PluginDebug.debug("Unable to write to PIPE. APPLETVIEWER exiting");
- System.exit(1);
- }
- }
+ public void write(String message) {
+
+ PluginDebug.debug(" PIPE: appletviewer wrote: " + message);
+ synchronized (pluginOutputWriter) {
+ try {
+ pluginOutputWriter.write(message + "\n", 0, message.length());
+ pluginOutputWriter.write(0);
+ pluginOutputWriter.flush();
+ } catch (IOException e) {
+ // if we are shutting down, ignore write failures as
+ // pipe may have closed
+ synchronized (shuttingDown) {
+ if (!shuttingDown) {
+ e.printStackTrace();
+ }
+ }
+
+ // either ways, if the pipe is broken, there is nothing
+ // we can do anymore. Don't hang around.
+ PluginDebug.debug("Unable to write to PIPE. APPLETVIEWER exiting");
+ System.exit(1);
+ }
+ }
- return;
- /*
- synchronized(writeQueue) {
- writeQueue.add(message);
- PluginDebug.debug(" PIPE: appletviewer wrote: " + message);
- }
- */
+ return;
+ /*
+ synchronized(writeQueue) {
+ writeQueue.add(message);
+ PluginDebug.debug(" PIPE: appletviewer wrote: " + message);
+ }
+ */
}
public boolean messageAvailable() {
- return writeQueue.size() != 0;
+ return writeQueue.size() != 0;
}
public String getMessage() {
- synchronized(writeQueue) {
- String ret = writeQueue.size() > 0 ? writeQueue.poll() : "";
- return ret;
- }
+ synchronized (writeQueue) {
+ String ret = writeQueue.size() > 0 ? writeQueue.poll() : "";
+ return ret;
+ }
}
-
+
private void showConsole() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
@@ -443,7 +438,7 @@ public class PluginStreamHandler {
}
});
}
-
+
private void hideConsole() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
diff --git a/plugin/icedteanp/java/sun/applet/RequestQueue.java b/plugin/icedteanp/java/sun/applet/RequestQueue.java
index 87dc54f..17df673 100644
--- a/plugin/icedteanp/java/sun/applet/RequestQueue.java
+++ b/plugin/icedteanp/java/sun/applet/RequestQueue.java
@@ -35,17 +35,15 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package sun.applet;
-
public class RequestQueue {
PluginCallRequest head = null;
PluginCallRequest tail = null;
private int size = 0;
public void post(PluginCallRequest request) {
- PluginDebug.debug("Securitymanager=" + System.getSecurityManager());
+ PluginDebug.debug("Securitymanager=" + System.getSecurityManager());
if (head == null) {
head = tail = request;
tail.setNext(null);
@@ -54,7 +52,7 @@ public class RequestQueue {
tail = request;
tail.setNext(null);
}
-
+
size++;
}
@@ -67,11 +65,11 @@ public class RequestQueue {
ret.setNext(null);
size--;
-
+
return ret;
}
-
+
public int size() {
- return size;
+ return size;
}
}
diff --git a/plugin/icedteanp/java/sun/applet/TestEnv.java b/plugin/icedteanp/java/sun/applet/TestEnv.java
index 08b74ce..0e4ac3d 100644
--- a/plugin/icedteanp/java/sun/applet/TestEnv.java
+++ b/plugin/icedteanp/java/sun/applet/TestEnv.java
@@ -37,8 +37,7 @@ exception statement from your version. */
package sun.applet;
-public class TestEnv
-{
+public class TestEnv {
public static int intField = 103;
public int intInstanceField = 7822;
public String stringField = "hello";
@@ -92,20 +91,20 @@ public class TestEnv
public static void TestItIntArray(int[] arg) {
PluginDebug.debug("TestItIntArray: " + arg);
for (int i = 0; i < arg.length; i++)
- PluginDebug.debug ("ELEMENT: " + i + " " + arg[i]);
+ PluginDebug.debug("ELEMENT: " + i + " " + arg[i]);
}
public static void TestItObjectArray(String[] arg) {
PluginDebug.debug("TestItObjectArray: " + arg);
for (int i = 0; i < arg.length; i++)
- PluginDebug.debug ("ELEMENT: " + i + " " + arg[i]);
+ PluginDebug.debug("ELEMENT: " + i + " " + arg[i]);
}
public static void TestItObjectArrayMulti(String[][] arg) {
PluginDebug.debug("TestItObjectArrayMulti: " + arg);
for (int i = 0; i < arg.length; i++)
for (int j = 0; j < arg[i].length; j++)
- PluginDebug.debug ("ELEMENT: " + i + " " + j + " " + arg[i][j]);
+ PluginDebug.debug("ELEMENT: " + i + " " + j + " " + arg[i][j]);
}
public static boolean TestItBoolReturnTrue() {
@@ -161,8 +160,8 @@ public class TestEnv
}
public static String[][] TestItObjectArrayMultiReturn() {
- return new String[][] { {"Thomas", "Brigitte"},
- {"Lindsay", "Michael"} };
+ return new String[][] { { "Thomas", "Brigitte" },
+ { "Lindsay", "Michael" } };
}
public int TestItIntInstance(int arg) {
diff --git a/plugin/icedteanp/java/sun/applet/VoidPluginCallRequest.java b/plugin/icedteanp/java/sun/applet/VoidPluginCallRequest.java
index 0bacc6c..71687d2 100644
--- a/plugin/icedteanp/java/sun/applet/VoidPluginCallRequest.java
+++ b/plugin/icedteanp/java/sun/applet/VoidPluginCallRequest.java
@@ -37,18 +37,17 @@ exception statement from your version. */
package sun.applet;
-
public class VoidPluginCallRequest extends PluginCallRequest {
public VoidPluginCallRequest(String message, Long reference) {
super(message, reference);
- PluginDebug.debug ("VoidPluginCall " + message);
+ PluginDebug.debug("VoidPluginCall " + message);
}
public void parseReturn(String message) {
- setDone(true);
+ setDone(true);
}
-
+
public Object getObject() {
- return null;
+ return null;
}
}