Subversion Repositories XServices

Rev

Rev 94 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

/*     */ package net.brutex.xservices.util;
/*     */ 
/*     */ import java.io.PrintStream;
/*     */ 
/*     */ public class CvsPassword
/*     */ {
/*  46 */   private static final char[] LOOKUP_TABLE = { 
/*  47 */     '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', 'r', 'x', '5', 
/*  48 */     'O', '\000', 'm', 'H', 'l', 'F', '@', 'L', 'C', 't', 'J', 'D', 'W', 'o', '4', 'K', 
/*  49 */     'w', '1', '"', 'R', 'Q', '_', 'A', 'p', 'V', 'v', 'n', 'z', 'i', ')', '9', 
/*  50 */     'S', '+', '.', 'f', '(', 'Y', '&', 'g', '-', '2', '*', '{', '[', '#', '}', '7', 
/*  51 */     '6', 'B', '|', '~', ';', '/', '\\', 'G', 's', 'N', 'X', 'k', 'j', '8', 
/*  52 */     '\000', 'y', 'u', 'h', 'e', 'd', 'E', 'I', 'c', '?', '^', ']', '\'', '%', '=', '0', 
/*  53 */     ':', 'q', ' ', 'Z', ',', 'b', '<', '3', '!', 'a', '>', 'M', 'T', 'P', 'U' };
/*     */ 
/*     */   public static String encode(String clearText)
/*     */   {
/*  68 */     char[] encoded = new char[clearText.length() + 1];
/*  69 */     encoded[0] = 'A';
/*     */ 
/*  72 */     int counter = 1;
/*  73 */     for (char c : clearText.toCharArray())
/*     */     {
/*  75 */       if ((c == '`') || (c == '$') || (c < ' '))
/*     */       {
/*  77 */         throw new IllegalArgumentException(
/*  78 */           "Illegal character was found in clear password.");
/*     */       }
/*     */ 
/*  81 */       encoded[(counter++)] = LOOKUP_TABLE[c];
/*     */     }
/*     */ 
/*  84 */     return String.valueOf(encoded);
/*     */   }
/*     */ 
/*     */   public static String decode(String encodedPassword)
/*     */   {
/*  98 */     String rtn = null;
/*     */ 
/* 100 */     if ((encodedPassword != null) && (encodedPassword.length() > 0))
/*     */     {
/* 102 */       if (encodedPassword.startsWith("A"))
/*     */       {
/* 104 */         rtn = encode(encodedPassword.substring(1)).substring(1);
/*     */       }
/*     */       else
/*     */       {
/* 108 */         rtn = encode(encodedPassword).substring(1);
/*     */       }
/*     */     }
/*     */ 
/* 112 */     return rtn;
/*     */   }
/*     */ 
/*     */   public static void main(String[] sArgs)
/*     */   {
/* 117 */     String TEST_WORD = "i07w91";
/* 118 */     String encoded = encode("i07w91");
/* 119 */     System.out.println("Encoded: <" + encoded + ">");
/* 120 */     String decoded = decode(encoded);
/* 121 */     System.out.println("Decoded: <" + decoded + ">");
/* 122 */     System.out.println(decoded.equals("i07w91") ? "Test Passed" : "Test Failed");
/*     */   }
/*     */ }

/* Location:           C:\Users\brosenberger\Documents\My Box Files\XBridgeNG-download\XServices-20130131 - Kopie\WEB-INF\classes\net.zip
 * Qualified Name:     net.brutex.xservices.util.CvsPassword
 * JD-Core Version:    0.6.2
 */

Generated by GNU Enscript 1.6.5.90.