1 13 package org.ejbca.core.model.approval; 14 15 import java.io.ByteArrayInputStream ; 16 import java.io.IOException ; 17 import java.io.ObjectInputStream ; 18 import java.util.ArrayList ; 19 import java.util.Collection ; 20 21 import javax.ejb.EJBException ; 22 23 import org.apache.log4j.Logger; 24 import org.ejbca.util.Base64; 25 26 27 28 29 37 38 public class ApprovalDataUtil { 39 40 private static final Logger log = Logger.getLogger(ApprovalDataUtil.class); 41 42 43 public static Collection getApprovals(String stringdata) { 44 ArrayList retval = new ArrayList (); 45 try{ 46 ObjectInputStream ois = new ObjectInputStream (new ByteArrayInputStream (Base64.decode(stringdata.getBytes()))); 47 48 int size = ois.readInt(); 49 for(int i=0;i<size;i++){ 50 Approval next = (Approval) ois.readObject(); 51 retval.add(next); 52 } 53 54 } catch (IOException e) { 55 log.error("Error building approvals.",e); 56 throw new EJBException (e); 57 } catch (ClassNotFoundException e) { 58 log.error("Error building approvals.",e); 59 throw new EJBException (e); 60 } 61 62 return retval; 63 } 64 65 public static ApprovalRequest getApprovalRequest(String stringdata) { 66 ApprovalRequest retval = null; 67 try { 68 69 ObjectInputStream ois = new ObjectInputStream (new ByteArrayInputStream (Base64.decode(stringdata.getBytes()))); 70 retval= (ApprovalRequest) ois.readObject(); 71 } catch (IOException e) { 72 log.error("Error building approval request.",e); 73 throw new EJBException (e); 74 } catch (ClassNotFoundException e) { 75 log.error("Error building approval request.",e); 76 throw new EJBException (e); 77 } 78 79 return retval; 80 } 81 82 83 } 84 | Popular Tags |