]> source.dussan.org Git - archiva.git/commitdiff
[MRM-63]
authorBrett Porter <brett@apache.org>
Fri, 20 Jan 2006 08:22:33 +0000 (08:22 +0000)
committerBrett Porter <brett@apache.org>
Fri, 20 Jan 2006 08:22:33 +0000 (08:22 +0000)
- run file reading code privileged
- do the applet tag convert thing

git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@370755 13f79535-47bb-0310-9956-ffa450edef68

maven-repository-artifact-applet/src/keystore/keystore
maven-repository-artifact-applet/src/main/java/org/apache/maven/repository/applet/ChecksumApplet.java
maven-repository-webapp/src/main/webapp/WEB-INF/jsp/form.jspf

index 52cea0c2881a4973f602e78d542432c8e47ee087..dda84744a781d0ce9e2566dbaf83be9f821618b8 100644 (file)
Binary files a/maven-repository-artifact-applet/src/keystore/keystore and b/maven-repository-artifact-applet/src/keystore/keystore differ
index b102d70d3cc59c3f724856cdaf507beb296f5860..0de9d6599142c779b15425c3a9e34bbc2ca1f9ad 100644 (file)
@@ -21,8 +21,11 @@ import java.applet.Applet;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.security.AccessController;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
+import java.security.PrivilegedAction;
+import java.util.Properties;
 
 /**
  * TODO: Description.
@@ -41,32 +44,49 @@ public class ChecksumApplet
         super.init();
     }
 
-    public String generateMd5( String file )
+    public String generateMd5( final String file )
         throws IOException, NoSuchAlgorithmException
     {
-        MessageDigest digest = MessageDigest.getInstance( "MD5" );
-
-        InputStream fis = new FileInputStream( file );
-        try
+        return (String) AccessController.doPrivileged( new PrivilegedAction()
         {
-            byte[] buffer = new byte[CHECKSUM_BUFFER_SIZE];
-            int numRead;
-            do
+            public Object run()
             {
-                numRead = fis.read( buffer );
-                if ( numRead > 0 )
+                try
+                {
+                    MessageDigest digest = MessageDigest.getInstance( "MD5" );
+
+                    InputStream fis = new FileInputStream( file );
+                    try
+                    {
+                        byte[] buffer = new byte[CHECKSUM_BUFFER_SIZE];
+                        int numRead;
+                        do
+                        {
+                            numRead = fis.read( buffer );
+                            if ( numRead > 0 )
+                            {
+                                digest.update( buffer, 0, numRead );
+                            }
+                        }
+                        while ( numRead != -1 );
+                    }
+                    finally
+                    {
+                        fis.close();
+                    }
+
+                    return byteArrayToHexStr( digest.digest() );
+                }
+                catch ( NoSuchAlgorithmException e )
                 {
-                    digest.update( buffer, 0, numRead );
+                    throw new RuntimeException( e );
+                }
+                catch ( IOException e )
+                {
+                    throw new RuntimeException( e );
                 }
             }
-            while ( numRead != -1 );
-        }
-        finally
-        {
-            fis.close();
-        }
-
-        return byteArrayToHexStr( digest.digest() );
+        } );
     }
 
     private static String byteArrayToHexStr( byte[] data )
index ebff979027859203a7402f38cd557cbb419cc80f..033ff98c0d882d4282240293873cc85a41e1da7d 100644 (file)
     <input type="submit" value="Search"/>
   </form>
 
-  <applet name="ChecksumApplet" archive="maven-repository-artifact-applet.jar"
-          width="1" height="1"
-          code="org/apache/maven/repository/applet/ChecksumApplet.class">
-  </applet>
+  <!--"CONVERTED_APPLET"-->
+<!-- HTML CONVERTER -->
+<script language="JavaScript" type="text/javascript"><!--
+    var _info = navigator.userAgent;
+    var _ns = false;
+    var _ns6 = false;
+    var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0);
+//--></script>
+
+    <comment>
+        <script language="JavaScript" type="text/javascript"><!--
+        var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0) || (_info.indexOf("AIX") > 0) || (_info.indexOf("OS/2") > 0) || (_info.indexOf("IRIX") > 0)));
+        var _ns6 = ((_ns == true) && (_info.indexOf("Mozilla/5") >= 0));
+//--></script>
+    </comment>
+
+<script language="JavaScript" type="text/javascript"><!--
+    if (_ie == true) document.writeln('<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = "1" HEIGHT = "1" NAME = "ChecksumApplet"  codebase="http://java.sun.com/update/1.5.0/jinstall-1_5-windows-i586.cab#Version=5,0,0,5"><noembed><xmp>');
+    else if (_ns == true && _ns6 == false) document.writeln('<embed ' +
+           'type="application/x-java-applet;version=1.5" \
+            CODE = "org/apache/maven/repository/applet/ChecksumApplet.class" \
+            ARCHIVE = "maven-repository-artifact-applet.jar" \
+            NAME = "ChecksumApplet" \
+            WIDTH = "1" \
+            HEIGHT = "1" ' +
+           'scriptable=false ' +
+           'pluginspage="http://java.sun.com/products/plugin/index.html#download"><noembed><xmp>');
+//--></script>
+<applet  CODE = "org/apache/maven/repository/applet/ChecksumApplet.class" ARCHIVE = "maven-repository-artifact-applet.jar" WIDTH = "1" HEIGHT = "1" NAME = "ChecksumApplet"></xmp>
+    <PARAM NAME = CODE VALUE = "org/apache/maven/repository/applet/ChecksumApplet.class" >
+    <PARAM NAME = ARCHIVE VALUE = "maven-repository-artifact-applet.jar" >
+    <PARAM NAME = NAME VALUE = "ChecksumApplet" >
+
+    <param name="type" value="application/x-java-applet;version=1.5">
+    <param name="scriptable" value="false">
+
+
+</applet>
+</noembed>
+</embed>
+</object>
+
+<!--
+<APPLET CODE = "org/apache/maven/repository/applet/ChecksumApplet.class" ARCHIVE = "maven-repository-artifact-applet.jar" WIDTH = "1" HEIGHT = "1" NAME = "ChecksumApplet">
+
+
+</APPLET>
+-->
+<!--"END_CONVERTED_APPLET"-->
 </p>
 
 <p>Search by Java Package: