KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > security > util > TrustNode


1 /*
2  * JacORB - a free Java ORB
3  *
4  * Copyright (C) 1997-2004 Gerald Brose.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the Free
18  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */

20
21 package org.jacorb.security.util;
22
23 /**
24  * This class represents key store entries
25  *
26  * @author Gerald Brose, FU Berlin
27  * @version $Id: TrustNode.java,v 1.7 2004/05/06 12:40:01 nicolas Exp $
28  */

29
30 import java.security.*;
31 import java.security.cert.*;
32 import java.util.*;
33 import javax.swing.tree.*;
34 import iaik.asn1.*;
35 import iaik.asn1.structures.*;
36 import iaik.x509.*;
37 import iaik.x509.extensions.*;
38
39 public class TrustNode
40     implements KSNode
41 {
42     private String JavaDoc alias;
43     private String JavaDoc label;
44     private TreeNode root;
45     private KeyStore ks;
46     private iaik.x509.X509Certificate cert;
47
48     /**
49      * constructor
50      */

51
52     public TrustNode(String JavaDoc alias, iaik.x509.X509Certificate cert, KeyStore ks)
53     {
54     this.alias = alias;
55     this.cert = cert;
56     this.ks = ks;
57     label = "trusted: " + alias;
58     }
59
60     /* TreeNode interface: */
61
62     public Enumeration children()
63     {
64     return null;
65     }
66
67     public boolean getAllowsChildren()
68     {
69     return false;
70     }
71
72     public TreeNode getChildAt(int index)
73     {
74     return null;
75     }
76
77     public int getChildCount()
78     {
79     return 0;
80     }
81
82     public int getIndex(TreeNode node)
83     {
84     return -1;
85     }
86
87     public TreeNode getParent()
88     {
89     return root;
90     }
91
92     public boolean isLeaf()
93     {
94     return true;
95     }
96
97     /* MutableTreeNode interface: */
98
99     public void insert(MutableTreeNode child, int index)
100     {
101     }
102
103     public void remove(int index)
104     {
105     }
106
107     public void remove(MutableTreeNode child)
108     {
109     }
110
111     public void setParent(MutableTreeNode root)
112     {
113     this.root = root;
114     }
115
116     public void setUserObject(Object JavaDoc o)
117     {}
118
119     public void removeFromParent()
120     {
121     try
122     {
123         ks.deleteEntry( alias );
124     }
125     catch( java.security.KeyStoreException JavaDoc kse )
126     {
127         kse.printStackTrace();
128     }
129     }
130
131     public iaik.x509.X509Certificate getCert()
132     {
133     return cert;
134     }
135
136     public String JavaDoc getAlias()
137     {
138     return alias;
139     }
140
141     public String JavaDoc toString()
142     {
143     return label;
144     }
145
146
147     public void store()
148     {
149     try
150     {
151         ks.setCertificateEntry ( alias, cert );
152     }
153     catch( java.security.KeyStoreException JavaDoc kse )
154     {
155         kse.printStackTrace();
156     }
157     }
158
159 }
160
161
162
163
164
165
166
167
168
169
170
171
172
173
Popular Tags