1 13 14 package org.ejbca.ui.web.admin.cainterface; 15 16 import java.security.cert.X509Certificate ; 17 import java.util.Collection ; 18 import java.util.HashMap ; 19 import java.util.Iterator ; 20 21 import org.ejbca.core.model.SecConst; 22 import org.ejbca.core.model.ca.caadmin.CAInfo; 23 import org.ejbca.core.model.ca.caadmin.X509CAInfo; 24 import org.ejbca.core.model.ca.caadmin.extendedcaservices.ExtendedCAServiceInfo; 25 import org.ejbca.core.model.ca.caadmin.extendedcaservices.OCSPCAServiceInfo; 26 import org.ejbca.core.model.ca.catoken.HardCATokenInfo; 27 import org.ejbca.core.model.ca.catoken.IHardCAToken; 28 import org.ejbca.ui.web.admin.configuration.EjbcaWebBean; 29 import org.ejbca.ui.web.admin.rainterface.RevokedInfoView; 30 31 32 37 public class CAInfoView implements java.io.Serializable , Cloneable { 38 40 public static final int NAME = 0; 41 public static final int SUBJECTDN = 1; 42 public static final int SUBJECTALTNAME = 2; 43 public static final int CATYPE = 3; 44 45 private static final int CASPACER = 4; 46 47 public static final int EXPIRETIME = 5; 48 public static final int STATUS = 6; 49 public static final int CATOKEN_STATUS = 7; 50 public static final int DESCRIPTION = 8; 51 52 private static final int CRLSPACER = 9; 53 54 public static final int CRLPERIOD = 10; 55 public static final int CRLISSUEINTERVAL = 11; 56 public static final int CRLOVERLAPTIME = 12; 57 public static final int CRLPUBLISHERS = 13; 58 59 private static final int OCSPSPACER = 14; 60 61 public static final int OCSP = 15; 62 63 64 public static String [] X509CA_CAINFODATATEXTS = {"NAME","SUBJECTDN","SUBJECTALTNAME","CATYPE","", 65 "EXPIRES","STATUS","CATOKENSTATUS","DESCRIPTION","", "CRLPERIOD", 66 "CRLISSUEINTERVAL", "CRLOVERLAPTIME", "CRLPUBLISHERS", "", "OCSPSERVICE"}; 67 68 private String [] cainfodata = null; 69 private String [] cainfodatatexts = null; 70 71 private CAInfo cainfo = null; 72 private X509Certificate ocspcert = null; 73 74 public CAInfoView(CAInfo cainfo, EjbcaWebBean ejbcawebbean, HashMap publishersidtonamemap){ 75 this.cainfo = cainfo; 76 77 if(cainfo instanceof X509CAInfo){ 78 cainfodatatexts = new String [X509CA_CAINFODATATEXTS.length]; 79 cainfodata = new String [X509CA_CAINFODATATEXTS.length]; 80 81 for(int i=0; i < X509CA_CAINFODATATEXTS.length; i++){ 82 if(X509CA_CAINFODATATEXTS[i].equals("")) 83 cainfodatatexts[i]=" "; 84 else 85 cainfodatatexts[i] = ejbcawebbean.getText(X509CA_CAINFODATATEXTS[i]); 86 } 87 88 cainfodata[SUBJECTDN] = cainfo.getSubjectDN(); 89 cainfodata[SUBJECTALTNAME] = ((X509CAInfo) cainfo).getSubjectAltName(); 90 cainfodata[NAME] = cainfo.getName(); 91 cainfodata[CATYPE] = ejbcawebbean.getText("X509"); 92 cainfodata[CASPACER] = " "; if(cainfo.getExpireTime() == null) 94 cainfodata[EXPIRETIME] = ""; 95 else 96 cainfodata[EXPIRETIME] = ejbcawebbean.printDateTime(cainfo.getExpireTime()); 97 98 switch(cainfo.getStatus()){ 99 case SecConst.CA_ACTIVE : 100 cainfodata[STATUS] = ejbcawebbean.getText("ACTIVE"); 101 break; 102 case SecConst.CA_EXPIRED : 103 cainfodata[STATUS] = ejbcawebbean.getText("EXPIRED"); 104 break; 105 case SecConst.CA_OFFLINE : 106 cainfodata[STATUS] = ejbcawebbean.getText("OFFLINE"); 107 break; 108 case SecConst.CA_REVOKED : 109 cainfodata[STATUS] = ejbcawebbean.getText("CAREVOKED") + "<br> " + 110 ejbcawebbean.getText("REASON") + " : <br> " + 111 ejbcawebbean.getText(RevokedInfoView.reasontexts[cainfo.getRevokationReason()]) + "<br> " + 112 ejbcawebbean.getText("REVOKATIONDATE") + "<br> " + 113 ejbcawebbean.printDateTime(cainfo.getRevokationDate()); 114 break; 115 case SecConst.CA_WAITING_CERTIFICATE_RESPONSE : 116 cainfodata[STATUS] = ejbcawebbean.getText("WAITINGFORCERTRESPONSE"); 117 break; 118 } 119 120 if(cainfo.getCATokenInfo() instanceof HardCATokenInfo){ 121 switch(((HardCATokenInfo) cainfo.getCATokenInfo()).getCATokenStatus()){ 122 case IHardCAToken.STATUS_ACTIVE : 123 cainfodata[CATOKEN_STATUS] = ejbcawebbean.getText("HARDTOKEN") + ", " + ejbcawebbean.getText("ACTIVE"); 124 break; 125 case IHardCAToken.STATUS_OFFLINE : 126 cainfodata[CATOKEN_STATUS] = ejbcawebbean.getText("HARDTOKEN") +", " + ejbcawebbean.getText("OFFLINE"); 127 break; 128 } 129 }else{ 130 cainfodata[CATOKEN_STATUS] = ejbcawebbean.getText("SOFT") + ", " + ejbcawebbean.getText("ACTIVE"); 131 } 132 133 134 cainfodata[DESCRIPTION] = cainfo.getDescription(); 135 136 cainfodata[CRLSPACER] = " "; 138 cainfodata[CRLPERIOD] = Integer.toString(((X509CAInfo) cainfo).getCRLPeriod()); 139 cainfodata[CRLISSUEINTERVAL] = Integer.toString(((X509CAInfo) cainfo).getCRLIssueInterval()); 140 cainfodata[CRLOVERLAPTIME] = Integer.toString(((X509CAInfo) cainfo).getCRLOverlapTime()); 141 142 cainfodata[CRLPUBLISHERS] = ""; 143 Iterator iter = ((X509CAInfo) cainfo).getCRLPublishers().iterator(); 144 if(iter.hasNext()) 145 cainfodata[CRLPUBLISHERS] = (String ) publishersidtonamemap.get(iter.next()); 146 else 147 cainfodata[CRLPUBLISHERS] = ejbcawebbean.getText("NONE"); 148 149 while(iter.hasNext()) 150 cainfodata[CRLPUBLISHERS] = cainfodata[CRLPUBLISHERS] + ", " + 151 (String ) publishersidtonamemap.get(iter.next()); 152 153 cainfodata[OCSPSPACER] = " "; 155 boolean active = false; 156 iter = ((X509CAInfo) cainfo).getExtendedCAServiceInfos().iterator(); 157 while(iter.hasNext()){ 158 ExtendedCAServiceInfo next = (ExtendedCAServiceInfo) iter.next(); 159 if(next instanceof OCSPCAServiceInfo){ 160 active = next.getStatus() == ExtendedCAServiceInfo.STATUS_ACTIVE; 161 if(((OCSPCAServiceInfo) next).getOCSPSignerCertificatePath() != null) 162 ocspcert = (X509Certificate ) ((OCSPCAServiceInfo) next).getOCSPSignerCertificatePath().get(0); 163 } 164 } 165 166 if(active){ 167 cainfodata[OCSP] = ejbcawebbean.getText("ACTIVE") + 168 "<br>" + " <a style='cursor:hand;' onClick='viewocspcert()'><u>" + 169 ejbcawebbean.getText("VIEWOCSPCERTIFICATE") + 170 "</u></a>"; 171 }else{ 172 cainfodata[OCSP] = ejbcawebbean.getText("INACTIVE"); 173 } 174 175 176 } 177 } 178 179 public String [] getCAInfoData(){ return cainfodata;} 180 public String [] getCAInfoDataText(){ return cainfodatatexts;} 181 182 public CAInfo getCAInfo() { return cainfo;} 183 public Collection getCertificateChain() { return cainfo.getCertificateChain(); } 184 185 public X509Certificate getOCSPSignerCertificate() { return ocspcert;} 186 187 188 } 189 | Popular Tags |