changeset 1929:f04f94067be0

2009-06-17 Omair Majid <omajid@redhat.com> * netx/javax/jnlp/ExtendedService.java: New file. * netx/net/sourceforge/jnlp/services/XExtendedService.java: New file. * netx/net/sourceforge/jnlp/services/XServiceManagerStub.java: Add ExtendedService to serviceNames. Create a proxy for XExtendedService to provide ExtendedService.
author Omair Majid <omajid@redhat.com>
date Wed, 17 Jun 2009 15:13:34 -0400
parents ee421053683d
children 2bf6d173f425
files ChangeLog netx/javax/jnlp/ExtendedService.java netx/net/sourceforge/jnlp/services/XExtendedService.java netx/net/sourceforge/jnlp/services/XServiceManagerStub.java
diffstat 4 files changed, 117 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Jun 17 14:47:36 2009 -0400
+++ b/ChangeLog	Wed Jun 17 15:13:34 2009 -0400
@@ -1,3 +1,11 @@
+2009-06-17  Omair Majid  <omajid@redhat.com>
+
+	*  * netx/javax/jnlp/ExtendedService.java: New file.
+	* netx/net/sourceforge/jnlp/services/XExtendedService.java: New file.
+	* netx/net/sourceforge/jnlp/services/XServiceManagerStub.java: Add 
+	ExtendedService to serviceNames. Create a proxy for XExtendedService to 
+	provide ExtendedService.
+
 2009-06-17  Deepak Bhole  <dbhole@redhat.com>
 
 	* IcedTeaPlugin.cc: Fix race condition that led to segfault.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/netx/javax/jnlp/ExtendedService.java	Wed Jun 17 15:13:34 2009 -0400
@@ -0,0 +1,51 @@
+// Copyright (C) 2009 Red Hat, Inc.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// 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 javax.jnlp;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * This interface provides a way for the JNLP application to open specific files
+ * in the client's system. It asks permission from the user before opening any
+ * files.
+ * 
+ * @author <a href="mailto:omajid@redhat.com">Omair Majid</a>
+ * 
+ */
+public interface ExtendedService {
+
+    /**
+     * Open a file on the client' system and return its contents. The user must
+     * grant permission to the application for this to work.
+     * 
+     * @param file the file to open
+     * @return the opened file as a {@link FileContents} object
+     * @throws IOException on any io problems
+     */
+    FileContents openFile(File file) throws IOException;
+
+    /**
+     * Opens multiple files on the user's sytem and returns their contents as a
+     * {@link FileContents} array
+     * 
+     * @param files the files to open
+     * @return an array of FileContents objects
+     * @throws IOException on any io problems
+     */
+    FileContents[] openFiles(File[] files) throws IOException;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/netx/net/sourceforge/jnlp/services/XExtendedService.java	Wed Jun 17 15:13:34 2009 -0400
@@ -0,0 +1,56 @@
+// Copyright (C) 2009 Red Hat, Inc.
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// 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.File;
+import java.io.IOException;
+
+import javax.jnlp.ExtendedService;
+import javax.jnlp.FileContents;
+
+import net.sourceforge.jnlp.security.SecurityWarningDialog;
+
+/**
+ * Implementation of ExtendedService
+ * 
+ * @author <a href="mailto:omajid@redhat.com">Omair Majid</a>
+ * 
+ */
+public class XExtendedService implements ExtendedService {
+
+    @Override
+    public FileContents openFile(File file) throws IOException {
+
+        if (ServiceUtil.checkAccess(SecurityWarningDialog.AccessType.READ_FILE)) {
+            return (FileContents) ServiceUtil.createPrivilegedProxy(FileContents.class,
+                    new XFileContents(file));
+        } else {
+            return null;
+        }
+
+    }
+
+    @Override
+    public FileContents[] openFiles(File[] files) throws IOException {
+        FileContents[] contents = new FileContents[files.length];
+        for (int i = 0; i < files.length; i++) {
+            contents[i] = openFile(files[i]);
+        }
+        return contents;
+    }
+
+}
--- a/netx/net/sourceforge/jnlp/services/XServiceManagerStub.java	Wed Jun 17 14:47:36 2009 -0400
+++ b/netx/net/sourceforge/jnlp/services/XServiceManagerStub.java	Wed Jun 17 15:13:34 2009 -0400
@@ -45,6 +45,7 @@
 	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",
@@ -56,6 +57,7 @@
     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()),