Changeset 257 for tools

Show
Ignore:
Timestamp:
02/02/09 15:51:55 (19 months ago)
Author:
anton
Message:

Logging fixed

Location:
tools/routingservice/trunk/src/jp/co/orkney/restlet
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • tools/routingservice/trunk/src/jp/co/orkney/restlet/WebRouting.java

    r199 r257  
    210210                                                                try 
    211211                                                                { 
    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)) 
    213213                                                                        { 
    214214                                                                                response.setStatus(Status.CLIENT_ERROR_FORBIDDEN); 
  • tools/routingservice/trunk/src/jp/co/orkney/restlet/security/SecurityHelper.java

    r253 r257  
    4141 
    4242    public static boolean checkAPIKey(String apiKey, String encKey, 
    43             String signature, String clientId) throws IOException, 
     43            String signature, String clientId, Log log) throws IOException, 
    4444            KeyStoreException, CertificateException, NoSuchAlgorithmException, 
    4545            NoSuchPaddingException, NoSuchProviderException, 
     
    9292        verifies = sig.verify(sigToVerify); 
    9393 
    94         System.out.println("signature verifies: " + verifies); 
     94        //System.out.println("signature verifies: " + verifies); 
     95        log.write("signature verifies: " + verifies, 2); 
    9596 
    9697        // byte[] text = encKey.substring(0,176).getBytes(); 
    9798        byte[] text = b64.decodeBuffer(encKey); 
    9899 
    99         System.out.println("Encrypting message..."); 
     100        //System.out.println("Encrypting message..."); 
     101        log.write("Encrypting message...", 2); 
    100102 
    101103        // text = crypt(c, priKey, text, Cipher.DECRYPT_MODE); 
    102         text = encryptDecrypt("DECRYPT", text, priKey); 
     104        text = encryptDecrypt("DECRYPT", text, priKey, log); 
    103105 
    104106        String decKey = new String(text); 
    105         System.out.println("text = " + decKey); 
     107        //System.out.println("text = " + decKey); 
     108        log.write("text = " + decKey, 2); 
    106109 
    107110        isValid = apiKey.equals(decKey); 
     
    247250    } 
    248251 
    249     public static byte[] encryptDecrypt(String type, byte[] data, Key secretKey) 
     252    public static byte[] encryptDecrypt(String type, byte[] data, Key secretKey, Log log) 
    250253            throws ShortBufferException, NoSuchAlgorithmException, 
    251254            NoSuchPaddingException, InvalidKeyException, 
     
    255258 
    256259        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); 
    258262        int j = 0; 
    259263        int k = 0; 
     
    279283 
    280284        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); 
    283289        cryptedCipherText = new byte[cipherlength]; 
    284290 
     
    291297        { 
    292298            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); 
    295303            cryptedCipherText = cipher.doFinal(bufferedEncryption); 
    296304            count += cryptedCipherText.length; 
    297             System.out.println("Length-->" + count); 
     305            //System.out.println("Length-->" + count); 
     306            log.write("Length-->" + count, 2); 
    298307            cryptedTextBuffer.write(cryptedCipherText); 
    299             System.out.println("i-->" + i); 
     308            //System.out.println("i-->" + i); 
     309            log.write("i-->" + i, 2); 
    300310 
    301311            i += k;