01: /*
02:
03: Derby - Class org.apache.derbyTesting.functionTests.tests.store.EncryptionTest
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to You under the Apache License, Version 2.0
09: (the "License"); you may not use this file except in compliance with
10: the License. You may obtain a copy of the License at
11:
12: http://www.apache.org/licenses/LICENSE-2.0
13:
14: Unless required by applicable law or agreed to in writing, software
15: distributed under the License is distributed on an "AS IS" BASIS,
16: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: See the License for the specific language governing permissions and
18: limitations under the License.
19:
20: */
21:
22: package org.apache.derbyTesting.functionTests.tests.store;
23:
24: import java.sql.Connection;
25: import java.sql.Statement;
26: import java.sql.PreparedStatement;
27: import java.sql.DriverManager;
28: import java.util.Properties;
29: import java.io.*;
30:
31: /**
32: * check if bootpassword is not written out in plain text into service.properties
33: * for an encrypted database run within the test harness.
34: * In future encryption related testcases can be added to this test
35: */
36: public class EncryptionTest {
37: public static void main(String[] args) {
38: Connection conn = null;
39: try {
40: // use the ij utility to read the property file and
41: // make the initial connection.
42: org.apache.derby.tools.ij.getPropertyArg(args);
43: conn = org.apache.derby.tools.ij.startJBMS();
44:
45: // Test 1
46: // Derby 236 - boot password should not be written out
47: // into service.properties
48: String derbyHome = System.getProperty("derby.system.home");
49:
50: // read in the properties in the service.properties file of the db
51: Properties serviceProperties = new Properties();
52: File f = new File(derbyHome + "/wombat/service.properties");
53: serviceProperties.load(new FileInputStream(f
54: .getAbsolutePath()));
55: if (serviceProperties.getProperty("bootPassword") == null)
56: report("TEST PASSED");
57: else
58: report("FAIL -- bootPassword should not be written out into service.properties");
59:
60: conn.close();
61: } catch (Throwable e) {
62: report("FAIL -- unexpected exception: " + e);
63: e.printStackTrace();
64: }
65:
66: }
67:
68: /**
69: * print message
70: * @param msg to print out
71: */
72: public static void report(String msg) {
73: System.out.println(msg);
74: }
75:
76: }
|