private Object prepareActionData(IEvent event) throws Exception { ViewCertificateEvent certEvent = (ViewCertificateEvent) event; Vector certList = null; try { String password = certEvent.getPassword(); Boolean isFile = certEvent.isFile(); if (isFile != null && isFile.booleanValue()) { File certFile = FileUtil.getFile(IPathConfig.PATH_TEMP, _userID + "/in/", certEvent.getName()); certList = getManager().getX500NamesAndCertDetail(certFile.getAbsolutePath(), password); certFile.delete(); } else { certList = getManager().getX500NamesAndCertDetail(certEvent.getUId()); } // TWX 26072006 Convert the serial number into hex format byte[] serialNumInByte = (byte[]) certList.get(2); certList.set(2, convertByteToHex(serialNumInByte)); } catch (Exception aex) { throw aex; } return certList; }
public static <T> ArrayList<T> deserialize(String filename, String pathKey, Class<T> castType) throws Exception { FileInputStream input = null; ObjectInputStream inputObj = null; try { File fileToDeserialize = FileUtil.getFile(pathKey, filename); input = new FileInputStream(fileToDeserialize); inputObj = new ObjectInputStream(input); ArrayList<T> deserializeObj = new ArrayList<T>(2000); while (true) { try { T obj = castType.cast(inputObj.readObject()); deserializeObj.add(obj); } catch (EOFException ex) { Logger.log( "[ObjSerializeHelper.deserialize] file " + fileToDeserialize.getAbsolutePath() + " has reached end of file."); break; } } return deserializeObj; } catch (Exception ex) { throw new ApplicationException( "[ObjSerializeHelper.deserialize] Unable to deserialize obj from a file " + filename, ex); } finally { if (input != null) { input.close(); } if (inputObj != null) { inputObj.close(); } } }
private synchronized void readConfig(String configName) { _props = new Properties(); try { _props.load(new FileInputStream(FileUtil.getFile(CONFIG_PATH, configName))); } catch (Exception ex) { Logger.err("[NotificationConfig.readConfig] Unable to load " + configName); } }
/** * Retrieve the encryption Certificate used by a particular channel in a File. * * @param channel The Channel. * @return The certificate file. */ static File getCertFile(ChannelInfo channel) throws Throwable { ICertificateManagerObj certMgr = ServiceLookupHelper.getCertificateManager(); Certificate cert = certMgr.findCertificateByUID(channel.getSecurityProfile().getEncryptionCertificateID()); String filename = FileUtil.getFile(IPathConfig.PATH_TEMP, "").getAbsolutePath() + "/myCert.cert"; GridCertUtilities.writeX509Certificate( filename, GridCertUtilities.loadX509Certificate(GridCertUtilities.decode(cert.getCertificate()))); return new File(filename); }