1 13 14 package org.ejbca.core.model.ra; 15 16 import java.util.HashMap ; 17 import java.util.Iterator ; 18 19 import org.apache.log4j.Logger; 20 import org.ejbca.core.model.InternalResources; 21 import org.ejbca.core.model.UpgradeableDataHashMap; 22 23 24 31 public class ExtendedInformation extends UpgradeableDataHashMap implements java.io.Serializable , Cloneable { 32 private static final Logger log = Logger.getLogger(ExtendedInformation.class); 33 34 private static final InternalResources intres = InternalResources.getInstance(); 35 36 45 private static final long serialVersionUID = 3981761824188420319L; 46 47 public static final float LATEST_VERSION = 1; 48 49 public static final int TYPE_BASIC = 0; 50 public static final int TYPE_SCEPRA = 1; 51 52 public static final String TYPE = "type"; 53 54 protected static final String SUBJECTDIRATTRIBUTES = "subjectdirattributes"; 56 57 protected static final String XKMSREVOCATIONCODEIDENTIFIER = "revocationcodeidentifier"; 58 protected static final String CUSTOMDATA = "customdata_"; 59 60 61 63 65 67 public ExtendedInformation() { 68 setType(TYPE_BASIC); 69 data.put(SUBJECTDIRATTRIBUTES, ""); 70 } 71 72 public String getSubjectDirectoryAttributes(){ 73 String ret = (String ) data.get(SUBJECTDIRATTRIBUTES); 74 if (ret == null) { 75 ret = ""; 76 } 77 return ret; 78 } 79 public void setSubjectDirectoryAttributes(String subjdirattr) { 80 if(subjdirattr==null) 81 data.put(SUBJECTDIRATTRIBUTES,""); 82 else 83 data.put(SUBJECTDIRATTRIBUTES,subjdirattr); 84 } 85 86 95 public String getRevocationCodeIdentifier(){ 96 String retval = (String ) data.get(XKMSREVOCATIONCODEIDENTIFIER); 97 98 99 100 return retval; 101 } 102 103 104 109 public void setRevocationCodeIdentifier(String revocationCodeIdentifier) { 110 String value = revocationCodeIdentifier; 111 112 data.put(XKMSREVOCATIONCODEIDENTIFIER,value); 113 114 } 115 116 121 public String getCustomData(String key){ 122 String retval = (String ) data.get(CUSTOMDATA + key); 123 124 125 126 return retval; 127 } 128 129 130 135 public void setCustomData(String key, String value) { 136 data.put(CUSTOMDATA + key,value); 137 } 138 139 public Object clone() throws CloneNotSupportedException { 140 ExtendedInformation clone = new ExtendedInformation(); 141 HashMap clonedata = (HashMap ) clone.saveData(); 142 143 Iterator i = (data.keySet()).iterator(); 144 while(i.hasNext()){ 145 Object key = i.next(); 146 clonedata.put(key, data.get(key)); 147 } 148 149 clone.loadData(clonedata); 150 return clone; 151 } 152 153 154 public float getLatestVersion(){ 155 return LATEST_VERSION; 156 } 157 158 159 160 public void upgrade(){ 161 if(Float.compare(LATEST_VERSION, getVersion()) != 0) { 162 String msg = intres.getLocalizedMessage("ra.extendedinfoupgrade", new Float (getVersion())); 164 log.info(msg); 165 166 if(data.get(SUBJECTDIRATTRIBUTES) == null){ 167 data.put(SUBJECTDIRATTRIBUTES, ""); 168 } 169 170 data.put(VERSION, new Float (LATEST_VERSION)); 171 } 172 } 173 174 178 public int getType(){ 179 return ((Integer ) data.get(TYPE)).intValue(); 180 } 181 182 190 protected void setType(int type){ 191 data.put(TYPE,new Integer (type)); 192 } 193 194 } 195 | Popular Tags |