1 20 21 package org.jacorb.security.util; 22 23 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 alias; 43 private String label; 44 private TreeNode root; 45 private KeyStore ks; 46 private iaik.x509.X509Certificate cert; 47 48 51 52 public TrustNode(String 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 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 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 o) 117 {} 118 119 public void removeFromParent() 120 { 121 try 122 { 123 ks.deleteEntry( alias ); 124 } 125 catch( java.security.KeyStoreException kse ) 126 { 127 kse.printStackTrace(); 128 } 129 } 130 131 public iaik.x509.X509Certificate getCert() 132 { 133 return cert; 134 } 135 136 public String getAlias() 137 { 138 return alias; 139 } 140 141 public String 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 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 |