1 19 20 package com.sslexplorer.core.forms; 21 22 import java.io.BufferedReader ; 23 import java.io.FileInputStream ; 24 import java.io.InputStream ; 25 import java.io.InputStreamReader ; 26 import java.io.PrintWriter ; 27 import java.io.StringWriter ; 28 29 import org.apache.commons.logging.Log; 30 import org.apache.commons.logging.LogFactory; 31 32 import com.sslexplorer.core.LicenseAgreement; 33 34 37 public class LicenseAgreementForm extends CoreForm { 38 39 private LicenseAgreement agreement; 40 private final static Log log = LogFactory.getLog(LicenseAgreementForm.class); 41 42 43 public void setAgreement(LicenseAgreement agreement) { 44 this.agreement = agreement; 45 } 46 47 public void reset() { 48 agreement = null; 49 } 50 51 public LicenseAgreement getAgreement() { 52 return agreement; 53 } 54 55 public String getAgreementText() { 56 InputStream in = null; 57 StringWriter sw = new StringWriter (); 58 try { 59 in = new FileInputStream (getAgreement().getLicenseTextFile()); 60 BufferedReader r = new BufferedReader (new InputStreamReader (in)); 61 String l = null; 62 PrintWriter pw = new PrintWriter (sw, true); 63 while( ( l = r.readLine() ) != null) { 64 pw.println(l); 65 } 66 67 } 68 catch(Exception e) { 69 log.error("Failed to load license text.", e); 70 e.printStackTrace(new PrintWriter (sw)); 71 } 72 return sw.toString(); 73 } 74 } 75 | Popular Tags |