1 13 14 19 20 package org.ejbca.core.model.log; 21 22 import java.io.Serializable ; 23 import java.io.UnsupportedEncodingException ; 24 import java.security.MessageDigest ; 25 import java.security.NoSuchAlgorithmException ; 26 import java.security.NoSuchProviderException ; 27 import java.util.Date ; 28 29 import org.bouncycastle.util.encoders.Hex; 30 import org.ejbca.core.model.protect.Protectable; 31 import org.ejbca.core.model.protect.TableVerifyResult; 32 33 39 public class LogEntry implements Serializable , Protectable { 40 41 50 private static final long serialVersionUID = -1L; 51 52 54 55 public static final int EVENT_INFO_UNKNOWN = 0; 57 public static final int EVENT_INFO_ADDEDENDENTITY = 1; 58 public static final int EVENT_INFO_CHANGEDENDENTITY = 2; 59 public static final int EVENT_INFO_REVOKEDENDENTITY = 3; 60 public static final int EVENT_INFO_REVOKEDCERT = 4; 61 public static final int EVENT_INFO_DELETEDENDENTITY = 5; 62 public static final int EVENT_INFO_EDITSYSTEMCONFIGURATION = 6; 63 public static final int EVENT_INFO_EDITEDADMINISTRATORPRIVILEGES = 7; 64 public static final int EVENT_INFO_EDITLOGCONFIGURATION = 8; 65 public static final int EVENT_INFO_ADMINISTRATORPREFERENCECHANGED = 9; 66 public static final int EVENT_INFO_ENDENTITYPROFILE = 10; 67 public static final int EVENT_INFO_USERAUTHENTICATION = 11; 68 public static final int EVENT_INFO_STORECERTIFICATE = 12; 69 public static final int EVENT_INFO_STORECRL = 13; 70 public static final int EVENT_INFO_GETLASTCRL = 14; 71 public static final int EVENT_INFO_CERTPROFILE = 15; 72 public static final int EVENT_INFO_DATABASE = 16; 73 public static final int EVENT_INFO_CREATECERTIFICATE = 17; 74 public static final int EVENT_INFO_CREATECRL = 18; 75 public static final int EVENT_INFO_ADMINISTRATORLOGGEDIN = 19; 76 public static final int EVENT_INFO_AUTHORIZEDTORESOURCE = 20; 77 public static final int EVENT_INFO_PUBLICWEBUSERCONNECTED = 21; 78 public static final int EVENT_INFO_HARDTOKEN_USERDATASENT = 22; 79 public static final int EVENT_INFO_HARDTOKENGENERATED = 23; 80 public static final int EVENT_INFO_HARDTOKENDATA = 24; 81 public static final int EVENT_INFO_HARDTOKENISSUERDATA = 25; 82 public static final int EVENT_INFO_HARDTOKENCERTIFICATEMAP = 26; 83 public static final int EVENT_INFO_KEYRECOVERY = 27; 84 public static final int EVENT_INFO_NOTIFICATION = 28; 85 public static final int EVENT_INFO_HARDTOKENVIEWED = 29; 86 public static final int EVENT_INFO_CACREATED = 30; 87 public static final int EVENT_INFO_CAEDITED = 31; 88 public static final int EVENT_INFO_CAREVOKED = 32; 89 public static final int EVENT_INFO_HARDTOKENPROFILEDATA = 33; 90 public static final int EVENT_INFO_PUBLISHERDATA = 34; 91 public static final int EVENT_INFO_USERDATASOURCEDATA = 35; 92 public static final int EVENT_INFO_USERDATAFETCHED = 36; 93 public static final int EVENT_INFO_UNREVOKEDCERT = 37; 94 public static final int EVENT_INFO_APPROVALREQUESTED = 38; 95 public static final int EVENT_INFO_APPROVALAPPROVED = 39; 96 public static final int EVENT_INFO_APPROVALREJECTED = 40; 97 public static final int EVENT_INFO_SERVICESEDITED = 41; 98 public static final int EVENT_INFO_SERVICEEXECUTED = 42; 99 public static final int EVENT_INFO_REQUESTCERTIFICATE = 43; 100 public static final int EVENT_INFO_CARENEWED = 44; 101 public static final int EVENT_INFO_CAEXPORTED = 45; 102 103 public static final int EVENT_ERROR_UNKNOWN = 1000; 105 public static final int EVENT_ERROR_ADDEDENDENTITY = 1001; 106 public static final int EVENT_ERROR_CHANGEDENDENTITY = 1002; 107 public static final int EVENT_ERROR_REVOKEDENDENTITY = 1003; 108 public static final int EVENT_ERROR_REVOKEDCERT = 1004; 109 public static final int EVENT_ERROR_DELETEENDENTITY = 1005; 110 public static final int EVENT_ERROR_EDITSYSTEMCONFIGURATION = 1006; 111 public static final int EVENT_ERROR_EDITEDADMINISTRATORPRIVILEGES = 1007; 112 public static final int EVENT_ERROR_EDITLOGCONFIGURATION = 1008; 113 public static final int EVENT_ERROR_ADMINISTRATORPREFERENCECHANGED = 1009; 114 public static final int EVENT_ERROR_ENDENTITYPROFILE = 1010; 115 public static final int EVENT_ERROR_USERAUTHENTICATION = 1011; 116 public static final int EVENT_ERROR_STORECERTIFICATE = 1012; 117 public static final int EVENT_ERROR_STORECRL = 1013; 118 public static final int EVENT_ERROR_GETLASTCRL = 1014; 119 public static final int EVENT_ERROR_CERTPROFILE = 1015; 120 public static final int EVENT_ERROR_DATABASE = 1016; 121 public static final int EVENT_ERROR_CREATECERTIFICATE = 1017; 122 public static final int EVENT_ERROR_CREATECRL = 1018; 123 public static final int EVENT_ERROR_ADMINISTRATORLOGGEDIN = 1019; 124 public static final int EVENT_ERROR_NOTAUTHORIZEDTORESOURCE = 1020; 125 public static final int EVENT_ERROR_PUBLICWEBUSERCONNECTED = 1021; 126 public static final int EVENT_ERROR_HARDTOKEN_USERDATASENT = 1022; 127 public static final int EVENT_ERROR_HARDTOKENGENERATED = 1023; 128 public static final int EVENT_ERROR_HARDTOKENDATA = 1024; 129 public static final int EVENT_ERROR_HARDTOKENISSUERDATA = 1025; 130 public static final int EVENT_ERROR_HARDTOKENCERTIFICATEMAP = 1026; 131 public static final int EVENT_ERROR_KEYRECOVERY = 1027; 132 public static final int EVENT_ERROR_NOTIFICATION = 1028; 133 public static final int EVENT_ERROR_HARDTOKENVIEWED = 1029; 134 public static final int EVENT_ERROR_CACREATED = 1030; 135 public static final int EVENT_ERROR_CAEDITED = 1031; 136 public static final int EVENT_ERROR_CAREVOKED = 1032; 137 public static final int EVENT_ERROR_HARDTOKENPROFILEDATA = 1033; 138 public static final int EVENT_ERROR_PUBLISHERDATA = 1034; 139 public static final int EVENT_ERROR_USERDATASOURCEDATA = 1035; 140 public static final int EVENT_ERROR_USERDATAFETCHED = 1036; 141 public static final int EVENT_ERROR_UNREVOKEDCERT = 1037; 142 public static final int EVENT_ERROR_APPROVALREQUESTED = 1038; 143 public static final int EVENT_ERROR_APPROVALAPPROVED = 1039; 144 public static final int EVENT_ERROR_APPROVALREJECTED = 1040; 145 public static final int EVENT_ERROR_SERVICESEDITED = 1041; 146 public static final int EVENT_ERROR_SERVICEEXECUTED = 1042; 147 public static final int EVENT_ERROR_REQUESTCERTIFICATE = 1043; 148 public static final int EVENT_ERROR_CARENEWED = 1044; 149 public static final int EVENT_ERROR_CAEXPORTED = 1045; 150 151 public static final int MODULE_CA = 0; 153 public static final int MODULE_RA = 1; 154 public static final int MODULE_LOG = 2; 155 public static final int MODULE_PUBLICWEB = 3; 156 public static final int MODULE_ADMINWEB = 4; 157 public static final int MODULE_HARDTOKEN = 5; 158 public static final int MODULE_KEYRECOVERY = 6; 159 public static final int MODULE_AUTHORIZATION = 7; 160 public static final int MODULE_APPROVAL = 8; 161 public static final int MODULE_SERVICES = 9; 162 163 public static final int EVENT_ERROR_BOUNDRARY = 1000; 164 165 public static final String [] EVENTNAMES_INFO = {"EVENT_INFO_UNKNOWN", "EVENT_INFO_ADDEDENDENTITY", "EVENT_INFO_CHANGEDENDENTITY", "EVENT_INFO_REVOKEDENDENTITY", "EVENT_INFO_REVOKEDCERT", 167 "EVENT_INFO_DELETEDENDENTITY", "EVENT_INFO_EDITSYSTEMCONFIGURATION", "EVENT_INFO_EDITEDADMINISTRATORPRIVILEGES", 168 "EVENT_INFO_EDITLOGCONFIGURATION", "EVENT_INFO_ADMINISTRATORPREFERENCECHANGED", "EVENT_INFO_ENDENTITYPROFILE", "EVENT_INFO_USERAUTHENTICATION", 169 "EVENT_INFO_STORECERTIFICATE", "EVENT_INFO_STORECRL", "EVENT_INFO_GETLASTCRL", "EVENT_INFO_CERTPROFILE", "EVENT_INFO_DATABASE", 170 "EVENT_INFO_CREATECERTIFICATE", "EVENT_INFO_CREATECRL", "EVENT_INFO_ADMINISTRATORLOGGEDIN", "EVENT_INFO_AUTHORIZEDTORESOURCE", 171 "EVENT_INFO_PUBLICWEBUSERCONNECTED", "EVENT_INFO_HARDTOKEN_USERDATASENT", "EVENT_INFO_HARDTOKENGENERATED", "EVENT_INFO_HARDTOKENDATA", 172 "EVENT_INFO_HARDTOKENISSUERDATA", "EVENT_INFO_HARDTOKENCERTIFICATEMAP", "EVENT_INFO_KEYRECOVERY", "EVENT_INFO_NOTIFICATION", 173 "EVENT_INFO_HARDTOKENVIEWED", "EVENT_INFO_CACREATED", "EVENT_INFO_CAEDITED", "EVENT_INFO_CAREVOKED", "EVENT_INFO_HARDTOKENPROFILEDATA", 174 "EVENT_INFO_PUBLISHERDATA", "EVENT_INFO_USERDATASOURCEDATA", "EVENT_INFO_USERDATAFETCHED", "EVENT_INFO_UNREVOKEDCERT", 175 "EVENT_INFO_APPROVALREQUESTED","EVENT_INFO_APPROVALAPPROVED","EVENT_INFO_APPROVALREJECTED","EVENT_INFO_SERVICESEDITED","EVENT_INFO_SERVICEEXECUTED", 176 "EVENT_INFO_REQUESTCERTIFICATE", "EVENT_INFO_CARENEWED", "EVENT_INFO_CAEXPORTED"}; 177 178 179 public static final String [] EVENTNAMES_ERROR = {"EVENT_ERROR_UNKNOWN", "EVENT_ERROR_ADDEDENDENTITY", "EVENT_ERROR_CHANGEDENDENTITY", "EVENT_ERROR_REVOKEDENDENTITY", "EVENT_ERROR_REVOKEDCERT", 180 "EVENT_ERROR_DELETEENDENTITY", "EVENT_ERROR_EDITSYSTEMCONFIGURATION", "EVENT_ERROR_EDITEDADMINISTRATORPRIVILEGES", 181 "EVENT_ERROR_EDITLOGCONFIGURATION", "EVENT_ERROR_ADMINISTRATORPREFERENCECHANGED", "EVENT_ERROR_ENDENTITYPROFILE", "EVENT_ERROR_USERAUTHENTICATION", 182 "EVENT_ERROR_STORECERTIFICATE", "EVENT_ERROR_STORECRL", "EVENT_ERROR_GETLASTCRL", "EVENT_ERROR_CERTPROFILE", "EVENT_ERROR_DATABASE", 183 "EVENT_ERROR_CREATECERTIFICATE", "EVENT_ERROR_CREATECRL", "EVENT_ERROR_ADMINISTRATORLOGGEDIN", "EVENT_ERROR_NOTAUTHORIZEDTORESOURCE", 184 "EVENT_ERROR_PUBLICWEBUSERCONNECTED", "EVENT_ERROR_HARDTOKEN_USERDATASENT", "EVENT_ERROR_HARDTOKENGENERATED", "EVENT_ERROR_HARDTOKENDATA", 185 "EVENT_ERROR_HARDTOKENISSUERDATA", "EVENT_ERROR_HARDTOKENCERTIFICATEMAP", "EVENT_ERROR_KEYRECOVERY", "EVENT_ERROR_NOTIFICATION", 186 "EVENT_ERROR_HARDTOKENVIEWED", "EVENT_ERROR_CACREATED", "EVENT_ERROR_CAEDITED", "EVENT_ERROR_CAREVOKED", "EVENT_ERROR_HARDTOKENPROFILEDATA", 187 "EVENT_ERROR_PUBLISHERDATA", "EVENT_ERROR_USERDATASOURCEDATA", "EVENT_ERROR_USERDATAFETCHED", "EVENT_ERROR_UNREVOKEDCERT", 188 "EVENT_ERROR_APPROVALREQUESTED","EVENT_ERROR_APPROVALAPPROVED","EVENT_ERROR_APPROVALREJECTED","EVENT_ERROR_SERVICESEDITED", 189 "EVENT_ERROR_SERVICEEXECUTED", "EVENT_ERROR_REQUESTCERTIFICATE", "EVENT_ERROR_CARENEWED", "EVENT_ERROR_CAEXPORTED"}; 190 191 public static final String [] MODULETEXTS = {"CA", "RA", "LOG", "PUBLICWEB", "ADMINWEB", "HARDTOKEN", "KEYRECOVERY", "AUTHORIZATION","APPROVAL","SERVICE"}; 192 193 194 206 207 public LogEntry(int id, int admintype, String admindata, int caid, int module, Date time, String username, String certificatesnr, int event, String comment) { 208 this.id = id; 209 this.admintype = admintype; 210 this.admindata = admindata; 211 this.caid = caid; 212 this.module = module; 213 this.time = time; 214 this.username = username; 215 this.certificatesnr = certificatesnr; 216 this.event = event; 217 this.comment = comment; 218 } 219 220 222 227 public String getEventName() { 228 if (this.event >= EVENT_ERROR_BOUNDRARY) 229 return EVENTNAMES_ERROR[this.event - EVENT_ERROR_BOUNDRARY]; 230 return EVENTNAMES_INFO[this.event]; 231 } 232 233 234 public int getId() { 235 return this.id; 236 } 237 238 public int getAdminType() { 239 return this.admintype; 240 } 241 242 public String getAdminData() { 243 return this.admindata; 244 } 245 246 public int getCAId() { 247 return this.caid; 248 } 249 250 public int getModule() { 251 return this.module; 252 } 253 254 public Date getTime() { 255 return this.time; 256 } 257 258 public String getUsername() { 259 return this.username; 260 } 261 262 public String getCertificateSNR() { 263 return this.certificatesnr; 264 } 265 266 public int getEvent() { 267 return this.event; 268 } 269 270 public String getComment() { 271 return this.comment; 272 } 273 274 public String getVerifyResult() { 275 return this.verifyResult; 276 } 277 278 public void setVerifyResult(String result) { 279 this.verifyResult=result; 280 } 281 282 public int getHashVersion() { 286 return 1; 287 } 288 public String getDbKeyString() { 289 return Integer.toString(id); 290 } 291 public String getEntryType() { 292 return "LOGENTRY"; 293 } 294 public String getHash() throws NoSuchAlgorithmException , NoSuchProviderException , UnsupportedEncodingException { 295 StringBuffer buf = new StringBuffer (); 296 buf.append(id).append(admintype).append(admindata).append(caid).append(module).append(time.getTime()). 297 append(username).append(certificatesnr).append(event).append(comment); 298 MessageDigest digest = MessageDigest.getInstance("SHA-256", "BC"); 299 byte[] result = digest.digest(buf.toString().getBytes("UTF-8")); 300 return new String (Hex.encode(result)); 301 } 302 public String getHash(int version) throws NoSuchAlgorithmException , NoSuchProviderException , UnsupportedEncodingException { 303 return getHash(); 304 } 305 306 308 private int id; 310 private int admintype; 311 private String admindata; 312 private int caid; 313 private int module; 314 private Date time; 315 private String username; 316 private String certificatesnr; 317 private int event; 318 private String comment; 319 private String verifyResult = TableVerifyResult.VERIFY_DISABLED_MSG; 320 321 } 322 | Popular Tags |