KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > upgrade > miscconfig > PolicyParser


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * PolicyParser.java
26  *
27  * Created on May 27, 2004, 7:36 AM
28  */

29
30 package com.sun.enterprise.tools.upgrade.miscconfig;
31
32 import java.io.*;
33 import java.util.Enumeration JavaDoc;
34
35 /**
36  *
37  * @author Hans Hrasna
38  */

39
40 public class PolicyParser extends sun.security.provider.PolicyParser {
41     
42     /** Creates a new instance of PolicyParser */
43     public PolicyParser() {
44     }
45     
46     /**
47      * @param args the command line arguments
48      */

49     public static void main(String JavaDoc[] args) {
50     }
51     
52     public void write(java.io.Writer JavaDoc policy) {
53         PrintWriter out = new PrintWriter(new BufferedWriter(policy));
54         
55         Enumeration JavaDoc ee = grantElements();
56         
57         out.println("/* Generated by asupgrade on "+
58         (new java.util.Date JavaDoc()) + " */");
59         out.println("/* Copyright 2004 Sun Microsystems, Inc. All rights reserved. */");
60         out.println("/* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */");
61         out.println();
62         
63         // write the (unexpanded) keystore entry as the first entry of the
64
// policy file
65
if (getKeyStoreUrl() != null) {
66             writeKeyStoreEntry(out);
67         }
68         
69         // write "grant" entries
70
while (ee.hasMoreElements()) {
71             GrantEntry ge = (GrantEntry) ee.nextElement();
72             ge.write(out);
73             out.println();
74         }
75         out.flush();
76         out.close();
77     }
78     
79     /**
80      * writes the (unexpanded) keystore entry
81      */

82     private void writeKeyStoreEntry(PrintWriter out) {
83         out.print("keystore \"");
84         out.print(getKeyStoreUrl());
85         out.print('"');
86         String JavaDoc keyStoreType = getKeyStoreType();
87         if (keyStoreType != null && keyStoreType.length() > 0)
88             out.print(", \"" + keyStoreType + "\"");
89         out.println(";");
90         out.println();
91     }
92 }
93
Popular Tags