From 5db9f4bdb20945cf14d5ab7fab7c91adf6ccc649 Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Fri, 20 Jan 2006 08:22:33 +0000 Subject: [PATCH] [MRM-63] - 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 --- .../src/keystore/keystore | Bin 1279 -> 1381 bytes .../repository/applet/ChecksumApplet.java | 58 ++++++++++++------ .../src/main/webapp/WEB-INF/jsp/form.jspf | 53 ++++++++++++++-- 3 files changed, 88 insertions(+), 23 deletions(-) diff --git a/maven-repository-artifact-applet/src/keystore/keystore b/maven-repository-artifact-applet/src/keystore/keystore index 52cea0c2881a4973f602e78d542432c8e47ee087..dda84744a781d0ce9e2566dbaf83be9f821618b8 100644 GIT binary patch delta 1135 zcmV-#1d#jx3FQiq8-M1CeNzAc0=Y1P0<|y>1_~<%0R#am0uccL1pows0-=<#+oAY^ z9l^k>pK$2#%!qNeG`co(iHpRS=y8nx2Zo^I4Y)vVucB*8EriF(#wT|CafFqU<}ZlC zuKfCLZXj|5#c%_ZRF!jB+_jX2${0OZmbSlDDhuOBUlKa_e}Cm!ChErQ{~Q2I)GZAh zAF16lGiSSSR3n>|i#FsSrkS9e!np|n8OAF)GoEDKSXxQvtXJZ9i;e_uazcYX@0{^; zW7B7tr4Excsb`cA@u_BwlcSaJCpZAfnOR)W+!35u)M(wJoPB?gz?~|!U2rXg{O3}4 zE1u|+Jq|15-CgDR0c&cTU9D3#BGV6Bt? zd5f{(wdUrQ@QPa zg}v?!zFBaHO`>c@)iM?S2CazEm3ld{cc1{y0Wq5^Rio#&hD+N~t>3iSqaH4b$W%i@ zwpCS)M}NZ|z1V@=?hU;n6}5n017x7^V*!SWUQ=1umgWA4_M0kC4>u$uz0ObS(t2fv z>cHu<gb}fK0>b&bv)a&K-tzk!bXe8%lMR=!5e>*|YQhL6x zl&$!Mveo{*>=bOr_ibxKXd&LNQU(Nno`hdHwWmuB-vR>x00A%!1_>&LNQUJ(PI|~Ec-ZYGt2FY{3+&P#^@W5t1tBT$cg)%1ioWZ(SZXlz# B6=(ne delta 1016 zcmV4I;?C zX~*a0&lYSD=V~421~& zNILKG>waa2&O|YS6A(`$<#145WN|?Pp_vL| zNp%^t6LBl=S%0!rB4GAd$@eaH2m*-#*M4&e2v`Z5MCK@%8u2xegnM7!eiZ&uaFQ<& z+rc*CH!AcQ{mpeI0#BaB$63t(BG=>5{gh$i3TG2E~5#Rwi+eaXUQ?B2oKUJ&joUzs2>sF!sxvRczOR zJAfTDZ}Mhfw`-YDrKF#q=mdKZBEnC*sn`Cu#vAxMSLep4rWFqa`-Aq=#U8@~e>GGS zS{9Kq_I2~FD`D3v@A4u88J*Ec0mlLr0GD7;j};>e%(9ZXf}-n$3-DMR^#Xx`0Qcdb zh1Q!r-pjnJTsF8@xp|bYyZSong85fW3q1#dXHi*Kj=I!YPv&t45P^WSNfvP<=u9XU z6SvO^GK|Qk;XD?4i&T7#DBz>6e;zBdrgf2SqkjwfAvI$0`(k>jLw&r; z9nl&%ciEQD+_u=2G~~q7UkxfVug?;7PGeVAK`Uv{Lpbl+x#%8esS#?Ff1@P*UBQKO z@{zlSro)tPCu}2X^Eu>I>&ctt{Z6ZiGrNJynh!Z$l?w{5;V9jS9L+qO;nqa&4B*=p zx-DEV3kC-&hDgph1Oo*C126zEEdms8oTTTUQ6@~`Yr}-d%h!uD0Ox=L6#$M$((>zj mwddrili$$nYK~y5sCh+c5_HqvQinp*32jGoYLFr!)+MQjy3|ns diff --git a/maven-repository-artifact-applet/src/main/java/org/apache/maven/repository/applet/ChecksumApplet.java b/maven-repository-artifact-applet/src/main/java/org/apache/maven/repository/applet/ChecksumApplet.java index b102d70d3..0de9d6599 100644 --- a/maven-repository-artifact-applet/src/main/java/org/apache/maven/repository/applet/ChecksumApplet.java +++ b/maven-repository-artifact-applet/src/main/java/org/apache/maven/repository/applet/ChecksumApplet.java @@ -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 { - digest.update( buffer, 0, numRead ); + 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 ) + { + 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 ) diff --git a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/form.jspf b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/form.jspf index ebff97902..033ff98c0 100644 --- a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/form.jspf +++ b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/form.jspf @@ -30,10 +30,55 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + +

Search by Java Package: