01: /*
02: * Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
03: * (http://h2database.com/html/license.html).
04: * Initial Developer: H2 Group
05: */
06: package org.h2.security;
07:
08: import java.sql.SQLException;
09:
10: import org.h2.constant.ErrorCode;
11: import org.h2.message.Message;
12:
13: /**
14: * A factory to create new block cipher objects.
15: */
16: public class CipherFactory {
17:
18: public static BlockCipher getBlockCipher(String algorithm)
19: throws SQLException {
20: if ("XTEA".equalsIgnoreCase(algorithm)) {
21: return new XTEA();
22: } else if ("AES".equalsIgnoreCase(algorithm)) {
23: return new AES();
24: } else {
25: throw Message.getSQLException(ErrorCode.UNSUPPORTED_CIPHER,
26: algorithm);
27: }
28: }
29:
30: public static SHA256 getHash(String algorithm) throws SQLException {
31: if ("SHA256".equalsIgnoreCase(algorithm)) {
32: return new SHA256();
33: } else {
34: throw Message.getInvalidValueException(algorithm,
35: "algorithm");
36: }
37: }
38:
39: }
|