- Timestamp:
- 02/02/09 15:51:55 (14 months ago)
- Location:
- tools/routingservice/trunk/src/jp/co/orkney/restlet
- Files:
-
- 2 modified
-
WebRouting.java (modified) (1 diff)
-
security/SecurityHelper.java (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tools/routingservice/trunk/src/jp/co/orkney/restlet/WebRouting.java
r199 r257 210 210 try 211 211 { 212 if (!SecurityHelper.checkAPIKey((String) keys.get(clientId.toUpperCase()), encKey, signature, clientId ))212 if (!SecurityHelper.checkAPIKey((String) keys.get(clientId.toUpperCase()), encKey, signature, clientId, log)) 213 213 { 214 214 response.setStatus(Status.CLIENT_ERROR_FORBIDDEN); -
tools/routingservice/trunk/src/jp/co/orkney/restlet/security/SecurityHelper.java
r253 r257 41 41 42 42 public static boolean checkAPIKey(String apiKey, String encKey, 43 String signature, String clientId ) throws IOException,43 String signature, String clientId, Log log) throws IOException, 44 44 KeyStoreException, CertificateException, NoSuchAlgorithmException, 45 45 NoSuchPaddingException, NoSuchProviderException, … … 92 92 verifies = sig.verify(sigToVerify); 93 93 94 System.out.println("signature verifies: " + verifies); 94 //System.out.println("signature verifies: " + verifies); 95 log.write("signature verifies: " + verifies, 2); 95 96 96 97 // byte[] text = encKey.substring(0,176).getBytes(); 97 98 byte[] text = b64.decodeBuffer(encKey); 98 99 99 System.out.println("Encrypting message..."); 100 //System.out.println("Encrypting message..."); 101 log.write("Encrypting message...", 2); 100 102 101 103 // text = crypt(c, priKey, text, Cipher.DECRYPT_MODE); 102 text = encryptDecrypt("DECRYPT", text, priKey );104 text = encryptDecrypt("DECRYPT", text, priKey, log); 103 105 104 106 String decKey = new String(text); 105 System.out.println("text = " + decKey); 107 //System.out.println("text = " + decKey); 108 log.write("text = " + decKey, 2); 106 109 107 110 isValid = apiKey.equals(decKey); … … 247 250 } 248 251 249 public static byte[] encryptDecrypt(String type, byte[] data, Key secretKey )252 public static byte[] encryptDecrypt(String type, byte[] data, Key secretKey, Log log) 250 253 throws ShortBufferException, NoSuchAlgorithmException, 251 254 NoSuchPaddingException, InvalidKeyException, … … 255 258 256 259 Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); 257 System.out.println("Provider is-->" + cipher.getProvider().getInfo()); 260 //System.out.println("Provider is-->" + cipher.getProvider().getInfo()); 261 log.write("Provider is-->" + cipher.getProvider().getInfo(), 2); 258 262 int j = 0; 259 263 int k = 0; … … 279 283 280 284 int cipherlength = cipher.getOutputSize(data.length); 281 System.out.println("data size-->" + data.length); 282 System.out.println("cipher size-->" + cipherlength); 285 //System.out.println("data size-->" + data.length); 286 log.write("data size-->" + data.length, 2); 287 //System.out.println("cipher size-->" + cipherlength); 288 log.write("cipher size-->" + cipherlength, 2); 283 289 cryptedCipherText = new byte[cipherlength]; 284 290 … … 291 297 { 292 298 System.arraycopy(data, i, bufferedEncryption, 0, j); 293 System.out.println("sizeof bufferedencryption-->" 294 + bufferedEncryption.length); 299 //System.out.println("sizeof bufferedencryption-->" 300 // + bufferedEncryption.length); 301 log.write("sizeof bufferedencryption-->" 302 + bufferedEncryption.length, 2); 295 303 cryptedCipherText = cipher.doFinal(bufferedEncryption); 296 304 count += cryptedCipherText.length; 297 System.out.println("Length-->" + count); 305 //System.out.println("Length-->" + count); 306 log.write("Length-->" + count, 2); 298 307 cryptedTextBuffer.write(cryptedCipherText); 299 System.out.println("i-->" + i); 308 //System.out.println("i-->" + i); 309 log.write("i-->" + i, 2); 300 310 301 311 i += k;
