KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derbyTesting > functionTests > tests > store > EncryptionTest


1 /*
2  
3  Derby - Class org.apache.derbyTesting.functionTests.tests.store.EncryptionTest
4  
5  Licensed to the Apache Software Foundation (ASF) under one or more
6  contributor license agreements. See the NOTICE file distributed with
7  this work for additional information regarding copyright ownership.
8  The ASF licenses this file to You under the Apache License, Version 2.0
9  (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 JavaDoc;
25 import java.sql.Statement JavaDoc;
26 import java.sql.PreparedStatement JavaDoc;
27 import java.sql.DriverManager JavaDoc;
28 import java.util.Properties JavaDoc;
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 JavaDoc[] args) {
38         Connection JavaDoc 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 JavaDoc derbyHome = System.getProperty("derby.system.home");
49
50             // read in the properties in the service.properties file of the db
51
Properties JavaDoc serviceProperties = new Properties JavaDoc();
52             File f = new File(derbyHome + "/wombat/service.properties");
53             serviceProperties.load(new FileInputStream(f.getAbsolutePath()));
54             if (serviceProperties.getProperty("bootPassword") == null)
55                 report("TEST PASSED");
56             else
57                 report("FAIL -- bootPassword should not be written out into service.properties");
58             
59             conn.close();
60         } catch (Throwable JavaDoc e) {
61             report("FAIL -- unexpected exception: " + e);
62             e.printStackTrace();
63         }
64
65     }
66
67     /**
68      * print message
69      * @param msg to print out
70      */

71     public static void report(String JavaDoc msg) {
72         System.out.println(msg);
73     }
74
75 }
76
Popular Tags