KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > security > CipherFactory


1 /*
2  * Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
3  * Initial Developer: H2 Group
4  */

5 package org.h2.security;
6
7 import java.sql.SQLException JavaDoc;
8
9 import org.h2.message.Message;
10
11 public class CipherFactory {
12     
13     public static BlockCipher getBlockCipher(String JavaDoc algorithm) throws SQLException JavaDoc {
14         if ("XTEA".equalsIgnoreCase(algorithm)) {
15             return new XTEA();
16         } else if ("AES".equalsIgnoreCase(algorithm)) {
17             return new AES();
18         } else {
19             throw Message.getSQLException(Message.UNSUPPORTED_CIPHER, algorithm);
20         }
21     }
22
23     public static SHA256 getHash(String JavaDoc algorithm) throws SQLException JavaDoc {
24         if("SHA256".equalsIgnoreCase(algorithm)) {
25             return new SHA256();
26         } else {
27             throw Message.getInvalidValueException(algorithm, "algorithm");
28         }
29     }
30     
31 }
32
Popular Tags