PKUWY2META-INF/MANIFEST.MFMLK-. K-*ϳR03PKPK WY2X``5name/prados/philippe/securikit/SecureHashString.class0Q/name/prados/philippe/securikit/SecureHashStringjava/lang/Objectrnd_Istr_Ljava/lang/String; cacheHash_()VCodejava/security/SecureRandom getSeed(I)[B  ([B)V  nextInt()I    LineNumberTableLocalVariableTable(Ljava/lang/String;)V    "  $this1Lname/prados/philippe/securikit/SecureHashString;strequals(Ljava/lang/Object;)Zjava/lang/String+ )* ,-java/lang/ClassCastException/objLjava/lang/Object;xLjava/lang/ClassCastException;hashCodeSHA6java/security/MessageDigest8 getInstance1(Ljava/lang/String;)Ljava/security/MessageDigest; :; 9<getBytes()[B >? ,@digest([B)[B BC 9D&java/security/NoSuchAlgorithmExceptionF[Bhashie(Ljava/security/NoSuchAlgorithmException;toString()Ljava/lang/String; SourceFileSecureHashString.java1   ?Y  Q*!*#*+%& ()&'()* `*%+%.M0246 &'12345 k*#*#7=*%AEL=>'+3+`3x+`3x+`3x=+* `Z#LffGFACBDCBE#F(H)H5I=H>IIFRKfMgO4k&'GBH#CI%-JgKLMN /*%Y &'OPPK WY2A4name/prados/philippe/securikit/SecureHashString.javapackage name.prados.philippe.securikit; /* * Securikit V.1.0 */ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; /** * This is a String with a secure hashCode() method, for using in key with a * critical Map. Replace the classic String key to a SecureHashString key. * * @version 1.0 * @since 1.0 * @author Philippe PRADOS */ public final class SecureHashString { /** * A secure random initial value. */ private static final int rnd_ = new SecureRandom(SecureRandom.getSeed(20)) .nextInt(); /** * The string to represent. */ private final String str_; private int cacheHash_=rnd_; /** * Create a String with a security hashCode() method. * * @param str The string to use. */ public SecureHashString(String str) { str_ = str; } /** * {@inheritDoc} */ public boolean equals(Object obj) { try { return str_.equals(((SecureHashString) obj).str_); } catch (ClassCastException x) { return false; } } /** * {@inheritDoc} */ public int hashCode() { try { if (cacheHash_!=rnd_) return cacheHash_; byte[] digest = MessageDigest.getInstance( "SHA").digest( str_.getBytes()); int hash = rnd_; for (int i = 0; i < digest.length; i += 4) { hash ^= digest[i] | (digest[i + 1] << 8) | (digest[i + 2] << 16) | (digest[i + 3] << 24); } return cacheHash_=(hash == rnd_) ? hash + 1 : hash; } catch (NoSuchAlgorithmException e) { return rnd_; } } /** * {@inheritDoc} */ public String toString() { return str_; } }PK yX2{{1name/prados/philippe/securikit/LimitedMap$1.class0+name/prados/philippe/securikit/LimitedMap$1java/lang/Object2name/prados/philippe/securikit/LimitedMap$Overflow()VCode   LineNumberTableLocalVariableTablethis-Lname/prados/philippe/securikit/LimitedMap$1;overflow@(Lname/prados/philippe/securikit/LimitedMap;I)Ljava/lang/Object;map+Lname/prados/philippe/securikit/LimitedMap;numberI SourceFileLimitedMap.java InnerClasses0 3*  )  @ -  PK yX2zeȩ1name/prados/philippe/securikit/LimitedMap$2.class0+name/prados/philippe/securikit/LimitedMap$2java/lang/Object2name/prados/philippe/securikit/LimitedMap$Overflow()VCode   LineNumberTableLocalVariableTablethis-Lname/prados/philippe/securikit/LimitedMap$2;overflow@(Lname/prados/philippe/securikit/LimitedMap;I)Ljava/lang/Object;java/lang/ArrayStoreException  map+Lname/prados/philippe/securikit/LimitedMap;numberI SourceFileLimitedMap.java InnerClasses0 3*  5  FY 9  PK yX2=`1name/prados/philippe/securikit/LimitedMap$3.class04+name/prados/philippe/securikit/LimitedMap$3java/lang/Object2name/prados/philippe/securikit/LimitedMap$Overflow()VCode   LineNumberTableLocalVariableTablethis-Lname/prados/philippe/securikit/LimitedMap$3;overflow@(Lname/prados/philippe/securikit/LimitedMap;I)Ljava/lang/Object;)name/prados/philippe/securikit/LimitedMapentrySet()Ljava/util/Set;   java/util/Setiterator()Ljava/util/Iterator;  java/util/Iteratornext()Ljava/lang/Object; ! "remove $ %hasNext()Z '( )map+Lname/prados/philippe/securikit/LimitedMap;numberIiLjava/util/Iterator; SourceFileLimitedMap.java InnerClasses0 3*  A  ,+N-#W-&-* E F HIF*K *,,+,,-. /0123 PK yX2S<<8name/prados/philippe/securikit/LimitedMap$Overflow.class0 2name/prados/philippe/securikit/LimitedMap$Overflowjava/lang/Objectoverflow@(Lname/prados/philippe/securikit/LimitedMap;I)Ljava/lang/Object; SourceFileLimitedMap.java InnerClasses)name/prados/philippe/securikit/LimitedMap Overflow  PK yX2 /name/prados/philippe/securikit/LimitedMap.class0o)name/prados/philippe/securikit/LimitedMapjava/lang/Object java/util/MapNothing4Lname/prados/philippe/securikit/LimitedMap$Overflow; Exception RemoveRandomnext_Ljava/util/Map;maxsize_I overflow_()VCode+name/prados/philippe/securikit/LimitedMap$1    +name/prados/philippe/securikit/LimitedMap$2   +name/prados/philippe/securikit/LimitedMap$3   "LineNumberTableLocalVariableTable(Ljava/util/Map;I)VG(Ljava/util/Map;ILname/prados/philippe/securikit/LimitedMap$Overflow;)V ' (this+Lname/prados/philippe/securikit/LimitedMap;nextmaxsize  /  1  3overflowsize()I 67 8isEmpty()Z :; < containsKey(Ljava/lang/Object;)Z >? @keyLjava/lang/Object; containsValue D? Evalueget&(Ljava/lang/Object;)Ljava/lang/Object; HI Jput8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;2name/prados/philippe/securikit/LimitedMap$OverflowN@(Lname/prados/philippe/securikit/LimitedMap;I)Ljava/lang/Object; 5P OQ LM Sremove UI VputAll(Ljava/util/Map;)V XY Ztclear ] ^keySet()Ljava/util/Set; `a bvalues()Ljava/util/Collection; de fentrySet ha i SourceFileLimitedMap.java InnerClassesOverflow!    KYY Y!#$) 5A%&L *+)$ h i%  *+ ,  -'l*.*+0*2*-4$rt uvw%**+, -5674 *09$~%  *+:;4 *0=$%  *+>?? *0+A$% *+ BCD?? *0+F$% *+ GCHI? *0+K$% *+ BCLM~(*09*2*4*R*0+,T$ "% (*+(BC(GCUI? *0+W$% *+ BCXY{3*09+9`*2*4*+9RW*0+[$"(2%3*+3\ ]8 *0_$  %  *+`a4 *0c$%  *+de4 *0g$%  *+ha4 *0j$%  *+klm"On PK yX2^.name/prados/philippe/securikit/LimitedMap.javapackage name.prados.philippe.securikit; /* * Securikit V.1.0 */ import java.util.Collection; import java.util.Iterator; import java.util.Map; import java.util.Set; /** * A wrapper for limite the size of a map. When an overflow, you can choose * differents algorithm. * * {@code Map map=new LimitedMap(new HashMap(),100,LimitedMap.RemoveRandom);} * * @version 1.0 * @since 1.0 * @author Philippe PRADOS */ public class LimitedMap implements Map { /** * Interface for update the overflow algorithm. * * @version 1.0 * @since 1.0 * @author Ph. Prados */ public interface Overflow { public Object overflow(LimitedMap map, int number); } /** * Overflow algorithm to do nothing. * The new data is not added in the map. */ public static final Overflow Nothing = new Overflow() { public Object overflow(LimitedMap map, int number) { return null; } }; /** * Overflow algorithm to genetate an ArrayStoreException * if the map is overflow. */ public static final Overflow Exception = new Overflow() { public Object overflow(LimitedMap map, int number) { throw new ArrayStoreException(); } }; /** * Overflow algorithm to remove a random values in the map, * before inserting the new one. */ public static final Overflow RemoveRandom = new Overflow() { public Object overflow(LimitedMap map, int number) { for (Iterator i = map.entrySet().iterator(); i.hasNext() && number > 0; --number) { i.next(); i.remove(); } return null; } }; /** * The map to manage. */ private final Map next_; /** * The maximum number of items accepted in the map */ private final int maxsize_; /** * The overflow strategy. */ private final Overflow overflow_; /** * Create a map with a limited size. If the map overflowed, an exception is * generated. * * @param next The map to use with a size limitation. * @param maxsize The maximum number of item in the map. */ public LimitedMap(Map next, int maxsize) { this(next, maxsize, Exception); } /** * Create a map with a limited size. * * @param next The map to use with a size limitation. * @param maxsize The maximum number of item in the map. * @param overflow The overflow algorithm. */ public LimitedMap(Map next, int maxsize, Overflow overflow) { next_ = next; maxsize_ = maxsize; overflow_ = overflow; } /** * {@inheritDoc} */ public int size() { return next_.size(); } /** * {@inheritDoc} */ public boolean isEmpty() { return next_.isEmpty(); } /** * {@inheritDoc} */ public boolean containsKey(Object key) { return next_.containsKey(key); } /** * {@inheritDoc} */ public boolean containsValue(Object value) { return next_.containsValue(value); } /** * {@inheritDoc} */ public Object get(Object key) { return next_.get(key); } /** * {@inheritDoc} */ public Object put(Object key, Object value) { if (next_.size() >= maxsize_) return overflow_.overflow( this, 1); return next_.put( key, value); } /** * {@inheritDoc} */ public Object remove(Object key) { return next_.remove(key); } /** * {@inheritDoc} */ public void putAll(Map t) { if (next_.size() + t.size() >= maxsize_) overflow_.overflow( this, t.size()); next_.putAll(t); } /** * {@inheritDoc} */ public void clear() { next_.clear(); } /** * {@inheritDoc} */ public Set keySet() { return next_.keySet(); } /** * {@inheritDoc} */ public Collection values() { return next_.values(); } /** * {@inheritDoc} */ public Set entrySet() { return next_.entrySet(); } /* public static void main(String[] args) { Map map = new LimitedMap(new java.util.Hashtable(), 3, LimitedMap.RemoveRandom); map.put("abc", "abc"); map.put("def", "def"); map.put("ghi", "ghi"); map.put("klm", "klm"); Map map2 = new java.util.Hashtable(); map2.put("ggg", "ggg"); map2.put("hhh", "hhh"); map.putAll(map2); } */ }PK SY2Bdd4name/prados/philippe/securikit/SecureMatcher$1.class0(.name/prados/philippe/securikit/SecureMatcher$19name/prados/philippe/securikit/SecureMatcher$BooleanAsyncthis$0.Lname/prados/philippe/securikit/SecureMatcher; Synthetic1(Lname/prados/philippe/securikit/SecureMatcher;)VCode     LineNumberTableLocalVariableTablethis0Lname/prados/philippe/securikit/SecureMatcher$1;run()V,name/prados/philippe/securikit/SecureMatcheraccess$0I(Lname/prados/philippe/securikit/SecureMatcher;)Ljava/util/regex/Matcher;  java/util/regex/Matchermatches()Z  resultZ !" # SourceFileSecureMatcher.java InnerClasses0  = *+ *+    =**  $  %&' PK SY2gaa4name/prados/philippe/securikit/SecureMatcher$2.class0(.name/prados/philippe/securikit/SecureMatcher$29name/prados/philippe/securikit/SecureMatcher$BooleanAsyncthis$0.Lname/prados/philippe/securikit/SecureMatcher; Synthetic1(Lname/prados/philippe/securikit/SecureMatcher;)VCode     LineNumberTableLocalVariableTablethis0Lname/prados/philippe/securikit/SecureMatcher$2;run()V,name/prados/philippe/securikit/SecureMatcheraccess$0I(Lname/prados/philippe/securikit/SecureMatcher;)Ljava/util/regex/Matcher;  java/util/regex/Matcherfind()Z  resultZ !" # SourceFileSecureMatcher.java InnerClasses0  = *+ *+    =**  $    %&' PK SY2Ͽp4name/prados/philippe/securikit/SecureMatcher$3.class0-.name/prados/philippe/securikit/SecureMatcher$39name/prados/philippe/securikit/SecureMatcher$BooleanAsyncthis$0.Lname/prados/philippe/securikit/SecureMatcher; Synthetic val$startI2(Lname/prados/philippe/securikit/SecureMatcher;I)VCode    1(Lname/prados/philippe/securikit/SecureMatcher;)V  LineNumberTableLocalVariableTablethis0Lname/prados/philippe/securikit/SecureMatcher$3;run()V,name/prados/philippe/securikit/SecureMatcheraccess$0I(Lname/prados/philippe/securikit/SecureMatcher;)Ljava/util/regex/Matcher;  java/util/regex/Matcher find(I)Z "# !$resultZ &' ( SourceFileSecureMatcher.java InnerClasses0   B*+**+ +  A***%) /0 *+, PK SY2t/ff4name/prados/philippe/securikit/SecureMatcher$4.class0(.name/prados/philippe/securikit/SecureMatcher$49name/prados/philippe/securikit/SecureMatcher$BooleanAsyncthis$0.Lname/prados/philippe/securikit/SecureMatcher; Synthetic1(Lname/prados/philippe/securikit/SecureMatcher;)VCode     LineNumberTableLocalVariableTablethis0Lname/prados/philippe/securikit/SecureMatcher$4;run()V,name/prados/philippe/securikit/SecureMatcheraccess$0I(Lname/prados/philippe/securikit/SecureMatcher;)Ljava/util/regex/Matcher;  java/util/regex/Matcher lookingAt()Z  resultZ !" # SourceFileSecureMatcher.java InnerClasses0  = *+ *+M    =**  $ QR %&' PK SY24name/prados/philippe/securikit/SecureMatcher$5.class01.name/prados/philippe/securikit/SecureMatcher$58name/prados/philippe/securikit/SecureMatcher$ObjectAsyncthis$0.Lname/prados/philippe/securikit/SecureMatcher; Syntheticval$sbLjava/lang/StringBuffer;val$replacementLjava/lang/String;[(Lname/prados/philippe/securikit/SecureMatcher;Ljava/lang/StringBuffer;Ljava/lang/String;)VCode     1(Lname/prados/philippe/securikit/SecureMatcher;)V  LineNumberTableLocalVariableTablethis0Lname/prados/philippe/securikit/SecureMatcher$5;run()V,name/prados/philippe/securikit/SecureMatcheraccess$0I(Lname/prados/philippe/securikit/SecureMatcher;)Ljava/util/regex/Matcher; ! "java/util/regex/Matcher$appendReplacementE(Ljava/lang/StringBuffer;Ljava/lang/String;)Ljava/util/regex/Matcher; &' %(resultLjava/lang/Object; *+ , SourceFileSecureMatcher.java InnerClasses0   G*+*,*-*+v M**#**)-zz{| ./0 PK SY2774name/prados/philippe/securikit/SecureMatcher$6.class0-.name/prados/philippe/securikit/SecureMatcher$68name/prados/philippe/securikit/SecureMatcher$ObjectAsyncthis$0.Lname/prados/philippe/securikit/SecureMatcher; Syntheticval$sbLjava/lang/StringBuffer;I(Lname/prados/philippe/securikit/SecureMatcher;Ljava/lang/StringBuffer;)VCode    1(Lname/prados/philippe/securikit/SecureMatcher;)V  LineNumberTableLocalVariableTablethis0Lname/prados/philippe/securikit/SecureMatcher$6;run()V,name/prados/philippe/securikit/SecureMatcheraccess$0I(Lname/prados/philippe/securikit/SecureMatcher;)Ljava/util/regex/Matcher;  java/util/regex/Matcher  appendTail2(Ljava/lang/StringBuffer;)Ljava/lang/StringBuffer; "# !$resultLjava/lang/Object; &' ( SourceFileSecureMatcher.java InnerClasses0   B*+*,*+   A***%)  *+, PK SY20((4name/prados/philippe/securikit/SecureMatcher$7.class0-.name/prados/philippe/securikit/SecureMatcher$78name/prados/philippe/securikit/SecureMatcher$ObjectAsyncthis$0.Lname/prados/philippe/securikit/SecureMatcher; Syntheticval$replacementLjava/lang/String;C(Lname/prados/philippe/securikit/SecureMatcher;Ljava/lang/String;)VCode    1(Lname/prados/philippe/securikit/SecureMatcher;)V  LineNumberTableLocalVariableTablethis0Lname/prados/philippe/securikit/SecureMatcher$7;run()V,name/prados/philippe/securikit/SecureMatcheraccess$0I(Lname/prados/philippe/securikit/SecureMatcher;)Ljava/util/regex/Matcher;  java/util/regex/Matcher  replaceAll&(Ljava/lang/String;)Ljava/lang/String; "# !$resultLjava/lang/Object; &' ( SourceFileSecureMatcher.java InnerClasses0   B*+*,*+   A***%)  *+, PK SY2X**4name/prados/philippe/securikit/SecureMatcher$8.class0-.name/prados/philippe/securikit/SecureMatcher$88name/prados/philippe/securikit/SecureMatcher$ObjectAsyncthis$0.Lname/prados/philippe/securikit/SecureMatcher; Syntheticval$replacementLjava/lang/String;C(Lname/prados/philippe/securikit/SecureMatcher;Ljava/lang/String;)VCode    1(Lname/prados/philippe/securikit/SecureMatcher;)V  LineNumberTableLocalVariableTablethis0Lname/prados/philippe/securikit/SecureMatcher$8;run()V,name/prados/philippe/securikit/SecureMatcheraccess$0I(Lname/prados/philippe/securikit/SecureMatcher;)Ljava/util/regex/Matcher;  java/util/regex/Matcher  replaceFirst&(Ljava/lang/String;)Ljava/lang/String; "# !$resultLjava/lang/Object; &' ( SourceFileSecureMatcher.java InnerClasses0   B*+*,*+   A***%)  *+, PK SY2ݪEP?name/prados/philippe/securikit/SecureMatcher$BooleanAsync.class09name/prados/philippe/securikit/SecureMatcher$BooleanAsyncjava/lang/Objectjava/lang/RunnableresultZthis$0.Lname/prados/philippe/securikit/SecureMatcher; Synthetic1(Lname/prados/philippe/securikit/SecureMatcher;)VCode ()V  LineNumberTableLocalVariableTablethis;Lname/prados/philippe/securikit/SecureMatcher$BooleanAsync; SourceFileSecureMatcher.java InnerClasses,name/prados/philippe/securikit/SecureMatcher BooleanAsync    4 *+*   PK SY2Z>name/prados/philippe/securikit/SecureMatcher$ObjectAsync.class08name/prados/philippe/securikit/SecureMatcher$ObjectAsyncjava/lang/Objectjava/lang/RunnableresultLjava/lang/Object;this$0.Lname/prados/philippe/securikit/SecureMatcher; Synthetic1(Lname/prados/philippe/securikit/SecureMatcher;)VCode ()V  LineNumberTableLocalVariableTablethis:Lname/prados/philippe/securikit/SecureMatcher$ObjectAsync; SourceFileSecureMatcher.java InnerClasses,name/prados/philippe/securikit/SecureMatcher ObjectAsync    4 *+*!   PK SY2E©2name/prados/philippe/securikit/SecureMatcher.class0,name/prados/philippe/securikit/SecureMatcherjava/lang/Objectmatcher_Ljava/util/regex/Matcher;defaultTimeout_JstartBooleanAsync?(Lname/prados/philippe/securikit/SecureMatcher$BooleanAsync;J)Z Exceptionsjava/lang/InterruptedException Codejava/lang/Thread(Ljava/lang/Runnable;)V   setDaemon(Z)V   setPriority(I)V  start()V  join(J)V !" #isAlive()Z %& ' interrupt ) *  ,9name/prados/philippe/securikit/SecureMatcher$BooleanAsync.resultZ 01 /2LineNumberTableLocalVariableTablethis.Lname/prados/philippe/securikit/SecureMatcher;async;Lname/prados/philippe/securikit/SecureMatcher$BooleanAsync;timeoutthreadLjava/lang/Thread; startAsyncO(Lname/prados/philippe/securikit/SecureMatcher$ObjectAsync;J)Ljava/lang/Object;8name/prados/philippe/securikit/SecureMatcher$ObjectAsync?Ljava/lang/Object; 0A @B:Lname/prados/philippe/securikit/SecureMatcher$ObjectAsync;(Ljava/util/regex/Matcher;)V(Ljava/util/regex/Matcher;J)V H Imatcher ,  M  OdefaultTimeout getMatcher()Ljava/util/regex/Matcher;pattern()Ljava/util/regex/Pattern;java/util/regex/MatcherV TU WXreset0()Lname/prados/philippe/securikit/SecureMatcher; ZS W\H(Ljava/lang/CharSequence;)Lname/prados/philippe/securikit/SecureMatcher;3(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher; Z_ W`inputLjava/lang/CharSequence;()I d We(I)I g WhgroupIend ld Wm lg Wo()Ljava/lang/String; jq Wr(I)Ljava/lang/String; jt Wu groupCount wd Wxmatches(J)Z z{ |.name/prados/philippe/securikit/SecureMatcher$1~1(Lname/prados/philippe/securikit/SecureMatcher;)V   find { .name/prados/philippe/securikit/SecureMatcher$2 (I)Z(IJ)Z .name/prados/philippe/securikit/SecureMatcher$32(Lname/prados/philippe/securikit/SecureMatcher;I)V   lookingAt { .name/prados/philippe/securikit/SecureMatcher$4 appendReplacementZ(Ljava/lang/StringBuffer;Ljava/lang/String;)Lname/prados/philippe/securikit/SecureMatcher;F(Ljava/lang/StringBuffer;Ljava/lang/String;J)Ljava/util/regex/Matcher; sbLjava/lang/StringBuffer; replacementLjava/lang/String;.name/prados/philippe/securikit/SecureMatcher$5[(Lname/prados/philippe/securikit/SecureMatcher;Ljava/lang/StringBuffer;Ljava/lang/String;)V  =>  appendTail2(Ljava/lang/StringBuffer;)Ljava/lang/StringBuffer;3(Ljava/lang/StringBuffer;J)Ljava/lang/StringBuffer; .name/prados/philippe/securikit/SecureMatcher$6I(Lname/prados/philippe/securikit/SecureMatcher;Ljava/lang/StringBuffer;)V  java/lang/StringBuffer replaceAll&(Ljava/lang/String;)Ljava/lang/String;'(Ljava/lang/String;J)Ljava/lang/String; .name/prados/philippe/securikit/SecureMatcher$7C(Lname/prados/philippe/securikit/SecureMatcher;Ljava/lang/String;)V  java/lang/String replaceFirst .name/prados/philippe/securikit/SecureMatcher$8 access$0I(Lname/prados/philippe/securikit/SecureMatcher;)Ljava/util/regex/Matcher; Synthetic SourceFileSecureMatcher.java InnerClasses BooleanAsync ObjectAsync!    MY+:  $$::(+ Y-+3$$EH$42 ) *+,/$2.365;6C8E2H95*M67M89M: C;<=>  MY+:  $$::(+ Y-+C$$EH$42 @ ABCF$I.J6L;MCOEIHP5*M67M8DM: C;<EA *+FJ4 \]5 67 KHY*L*+N* P4fh ij5 67KQRS/*N4t5 67TU2*NY4}5 67Z[8 *N]W*4 5  67Z^C *N+aW*4  5 67 bcd2*Nf45 67g= *Ni45 67 jkld2*Nn45 67lg= *Np45 67 jkjq2*Ns45 67jt= *Nv45 67 jkwd2*Ny45 67z&  3 **P}45  67z{  N*Y*4 567:&  3 **P45  67{  N*Y*4  567:  F **P45 67 k  Y*Y* 4*+ 1 *5 67k:&  3 **P4>5  67{  N*Y*4LM S L567:  hY*+,*P*PJ4ccd cdc5 67  g*Y*+,!W4uv } u5*67:  F *+*P45 67   \*Y*+ 4  5 67:  F *+*P45 67   \*Y*+ 4  5 67:  F *+*Pİ45 67   \*Y*+ 4  5 67:%*N45R /@PK SY2(Af((1name/prados/philippe/securikit/SecureMatcher.javapackage name.prados.philippe.securikit; /* * Securikit V.1.0 */ import java.util.regex.Matcher; import java.util.regex.Pattern; /** * Add a timeout for each Matcher methods. * {@code * SecureMatcher sm = new SecureMatcher(p * .matcher("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaC")); * System.out.println(sm.matches(100) ? "match" : "not match"); * } * * @version 1.0 * @since 1.0 * @author Philippe PRADOS */ public class SecureMatcher { private final Matcher matcher_; private final long defaultTimeout_; private abstract class BooleanAsync implements Runnable { boolean result; } private abstract class ObjectAsync implements Runnable { Object result; } private boolean startBooleanAsync(BooleanAsync async, long timeout) throws InterruptedException { Thread thread = new Thread(async); thread.setDaemon(true); thread.setPriority(Thread.NORM_PRIORITY / 2); thread.start(); try { thread.join(timeout); } finally { if (thread.isAlive()) { thread.interrupt(); throw new InterruptedException(); } } return async.result; } private Object startAsync(ObjectAsync async, long timeout) throws InterruptedException { Thread thread = new Thread(async); thread.setDaemon(true); thread.setPriority(Thread.NORM_PRIORITY / 2); thread.start(); try { thread.join(timeout); } finally { if (thread.isAlive()) { thread.interrupt(); throw new InterruptedException(); } } return async.result; } /** * Create an secure matcher with timeout for each complex methods. * * @param matcher The matcher to controle. * @since 1.0 */ public SecureMatcher(Matcher matcher) { this(matcher, 1000); } /** * Create an secure matcher with timeout for each complex methods. * * @param matcher The matcher to controle. * @param defaultTimeout The default timeout for this matcher. * @since 1.0 */ public SecureMatcher(Matcher matcher, long defaultTimeout) { matcher_ = matcher; defaultTimeout_ = defaultTimeout; } /** * Return the matcher to control. * * @return Return the matcher to control. * @since 1.0 */ public Matcher getMatcher() { return matcher_; } /** * @see Matcher#pattern() * @since 1.0 */ public Pattern pattern() { return matcher_.pattern(); } /** * @see Matcher#reset() * @since 1.0 */ public SecureMatcher reset() { matcher_.reset(); return this; } /** * @see Matcher#reset(java.lang.CharSequence) * @since 1.0 */ public SecureMatcher reset(CharSequence input) { matcher_.reset(input); return this; } /** * @see Matcher#start() * @since 1.0 */ public int start() { return matcher_.start(); } /** * @see Matcher#start(int) * @since 1.0 */ public int start(int group) { return matcher_.start(group); } /** * @see Matcher#end() * @since 1.0 */ public int end() { return matcher_.end(); } /** * @see Matcher#end(int) * @since 1.0 */ public int end(int group) { return matcher_.end(group); } /** * @see Matcher#group() * @since 1.0 */ public String group() { return matcher_.group(); } /** * @see Matcher#group(int) * @since 1.0 */ public String group(int group) { return matcher_.group(group); } /** * @see Matcher#groupCount() * @since 1.0 */ public int groupCount() { return matcher_.groupCount(); } /** * @see Matcher#matches() * @since 1.0 */ public boolean matches() throws InterruptedException { return matches(defaultTimeout_); } /** * @see Matcher#matches() * @since 1.0 */ public boolean matches(long timeout) throws InterruptedException { return startBooleanAsync( new BooleanAsync() { public void run() { result = matcher_.matches(); } }, timeout); } /** * Find the pattern. * * @return true if find it. * @exception InterruptedException If timeout. * @see Matcher#find() * @since 1.0 */ public boolean find() throws InterruptedException { return find(defaultTimeout_); } /** * Find the pattern. * * @param timeout The timeout. * @return true if find it. * @exception InterruptedException If timeout. * @see Matcher#find() * @since 1.0 */ public boolean find(long timeout) throws InterruptedException { return startBooleanAsync( new BooleanAsync() { public void run() { result = matcher_.find(); } }, timeout); } /** * Find the pattern. * * @param start The start position. * @return true if find it. * @exception InterruptedException If timeout. * @see Matcher#find(int) * @since 1.0 */ public boolean find(int start) throws InterruptedException { return find( start, defaultTimeout_); } /** * Find the pattern. * * @param start The start position. * @param timeout The timeout. * @return true if find it. * @exception InterruptedException If timeout. * @see Matcher#find(int) * @since 1.0 */ public boolean find(final int start, long timeout) throws InterruptedException { return startBooleanAsync( new BooleanAsync() { public void run() { result = matcher_.find(start); } }, timeout); } /** * Looking at. * * @return true if find. * @exception InterruptedException If timeout. * @see Matcher#lookingAt() * @since 1.0 */ public boolean lookingAt() throws InterruptedException { return lookingAt(defaultTimeout_); } /** * Looking at. * * @param timeout The timeout. * @return true if find. * @exception InterruptedException If timeout. * @see Matcher#lookingAt() * @since 1.0 */ public boolean lookingAt(long timeout) throws InterruptedException { return startBooleanAsync( new BooleanAsync() { public void run() { result = matcher_.lookingAt(); } }, timeout); } /** * Append the replacement. * * @param sb The stringbuffer. * @param replacement The replacement string. * @return The secure matcher. * @exception InterruptedException If timeout. * @see Matcher#appendReplacement(java.lang.StringBuffer, java.lang.String) * @since 1.0 */ public SecureMatcher appendReplacement(StringBuffer sb, String replacement) throws InterruptedException { return new SecureMatcher(appendReplacement( sb, replacement, defaultTimeout_), defaultTimeout_); } /** * Append the replacement. * * @param sb The stringbuffer. * @param replacement The replacement string. * @param timeout The timeout. * @return The secure matcher. * @exception InterruptedException If timeout. * @see Matcher#appendReplacement(java.lang.StringBuffer, java.lang.String) * @since 1.0 */ public Matcher appendReplacement(final StringBuffer sb, final String replacement, long timeout) throws InterruptedException { return (Matcher) startAsync( new ObjectAsync() { public void run() { result = matcher_.appendReplacement( sb, replacement); } }, timeout); } /** * Append tail. * * @param sb The string buffer. * @return The string buffer. * @exception InterruptedException If timeout. * @see Matcher#appendTail(java.lang.StringBuffer) * @since 1.0 */ public StringBuffer appendTail(StringBuffer sb) throws InterruptedException { return appendTail( sb, defaultTimeout_); } /** * Append tail. * * @param sb The string buffer. * @param timeout The timeout. * @return The string buffer. * @exception InterruptedException If timeout. * @see Matcher#appendTail(java.lang.StringBuffer) * @since 1.0 */ public StringBuffer appendTail(final StringBuffer sb, long timeout) throws InterruptedException { return (StringBuffer) startAsync( new ObjectAsync() { public void run() { result = matcher_.appendTail(sb); } }, timeout); } /** * Replace all. * * @param replacement The replacement string. * @return The string buffer. * @exception InterruptedException If timeout. * @see Matcher#replaceAll(java.lang.String) * @since 1.0 */ public String replaceAll(String replacement) throws InterruptedException { return replaceAll( replacement, defaultTimeout_); } /** * Replace all. * * @param replacement The replacement string. * @param timeout The timeout. * @return The string buffer. * @exception InterruptedException If timeout. * @see Matcher#replaceAll(java.lang.String) * @since 1.0 */ public String replaceAll(final String replacement, long timeout) throws InterruptedException { return (String) startAsync( new ObjectAsync() { public void run() { result = matcher_.replaceAll(replacement); } }, timeout); } /** * Replace first. * * @param replacement The replacement string. * @return The string. * @exception InterruptedException If timeout. * @see Matcher#replaceFirst(java.lang.String) * @since 1.0 */ public String replaceFirst(String replacement) throws InterruptedException { return replaceFirst( replacement, defaultTimeout_); } /** * Replace first. * * @param replacement The replacement string. * @param timeout The timeout. * @return The string. * @exception InterruptedException If timeout. * @see Matcher#replaceFirst(java.lang.String) * @since 1.0 */ public String replaceFirst(final String replacement, long timeout) throws InterruptedException { return (String) startAsync( new ObjectAsync() { public void run() { result = matcher_.replaceFirst(replacement); } }, timeout); } /* public static void main(String[] args) { Pattern p = Pattern.compile("(a|aa)*B"); try { SecureMatcher sm = new SecureMatcher(p .matcher("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaC")); System.out.println(sm.matches(100) ? "match" : "not match"); } catch (InterruptedException e) { System.err.println("TIMEOUT"); } } */ }PKUWY2META-INF/MANIFEST.MFPK WY2X``5aname/prados/philippe/securikit/SecureHashString.classPK WY2A4name/prados/philippe/securikit/SecureHashString.javaPK yX2{{1>name/prados/philippe/securikit/LimitedMap$1.classPK yX2zeȩ1name/prados/philippe/securikit/LimitedMap$2.classPK yX2=`1name/prados/philippe/securikit/LimitedMap$3.classPK yX2S<<83name/prados/philippe/securikit/LimitedMap$Overflow.classPK yX2 /name/prados/philippe/securikit/LimitedMap.classPK yX2^.%name/prados/philippe/securikit/LimitedMap.javaPK SY2Bdd4_6name/prados/philippe/securikit/SecureMatcher$1.classPK SY2gaa4:name/prados/philippe/securikit/SecureMatcher$2.classPK SY2Ͽp4=name/prados/philippe/securikit/SecureMatcher$3.classPK SY2t/ff4Aname/prados/philippe/securikit/SecureMatcher$4.classPK SY24Ename/prados/philippe/securikit/SecureMatcher$5.classPK SY2774Jname/prados/philippe/securikit/SecureMatcher$6.classPK SY20((4(Oname/prados/philippe/securikit/SecureMatcher$7.classPK SY2X**4Sname/prados/philippe/securikit/SecureMatcher$8.classPK SY2ݪEP?Xname/prados/philippe/securikit/SecureMatcher$BooleanAsync.classPK SY2Z>[name/prados/philippe/securikit/SecureMatcher$ObjectAsync.classPK SY2E©2]name/prados/philippe/securikit/SecureMatcher.classPK SY2(Af((1xname/prados/philippe/securikit/SecureMatcher.javaPK^