KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ca > directory > jxplorer > editor > cacertificateeditor


1 /**
2  * All pluggable editors must be in this package
3  */

4
5 package com.ca.directory.jxplorer.editor;
6
7 import com.ca.commons.security.cert.*;
8 import com.ca.commons.security.cert.CertViewer;
9 import com.ca.commons.cbutil.*;
10
11 import java.awt.Frame JavaDoc;
12 import java.security.cert.X509Certificate JavaDoc;
13 import java.util.Arrays JavaDoc;
14
15 /**
16  * Cerrtificate Editor.
17  * Allows user to enter a masked binary password.
18  */

19
20 public class cacertificateeditor implements abstractbinaryeditor
21 {
22     Frame JavaDoc owner;
23
24     public cacertificateeditor(Frame JavaDoc owner)
25     {
26         this.owner = owner;
27     }
28
29     /**
30      * Uses the static editCertificate method in CertViewer to
31      * display (and potentially edit) the certificate.
32      */

33
34     public void setValue(editablebinary editMe)
35     {
36         byte[] data = editMe.getValue();
37
38         CertViewer.CertAndFileName returnVal = null;
39
40         try
41         {
42              returnVal = CertViewer.editCertificate(owner, data);
43         }
44         catch (Exception JavaDoc e)
45         {
46              CBUtility.error(CBIntText.get("Error reading certificate."), e);
47         }
48
49         X509Certificate JavaDoc cert = null;
50
51         if(returnVal != null) //TE: throws an exception if this is null....bug 3176.
52
cert = returnVal.cert;
53
54         if (cert != null)
55         {
56             try
57             {
58                 byte[] newData = cert.getEncoded();
59                 if (Arrays.equals(newData, data) == false)
60                     editMe.setValue(newData);
61             }
62             catch(Exception JavaDoc e)
63             {
64                 CBUtility.error(CBIntText.get("Error: unable to modify certificate."), e);
65             }
66         }
67     }
68 }
Popular Tags