KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > core > forms > LicenseAgreementForm


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.core.forms;
21
22 import java.io.BufferedReader JavaDoc;
23 import java.io.FileInputStream JavaDoc;
24 import java.io.InputStream JavaDoc;
25 import java.io.InputStreamReader JavaDoc;
26 import java.io.PrintWriter JavaDoc;
27 import java.io.StringWriter JavaDoc;
28
29 import org.apache.commons.logging.Log;
30 import org.apache.commons.logging.LogFactory;
31
32 import com.sslexplorer.core.LicenseAgreement;
33
34 /**
35  * @author Brett Smith <brett@3sp.com>
36  */

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 JavaDoc getAgreementText() {
56         InputStream JavaDoc in = null;
57         StringWriter JavaDoc sw = new StringWriter JavaDoc();
58         try {
59             in = new FileInputStream JavaDoc(getAgreement().getLicenseTextFile());
60             BufferedReader JavaDoc r = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(in));
61             String JavaDoc l = null;
62             PrintWriter JavaDoc pw = new PrintWriter JavaDoc(sw, true);
63             while( ( l = r.readLine() ) != null) {
64                 pw.println(l);
65             }
66             
67         }
68         catch(Exception JavaDoc e) {
69             log.error("Failed to load license text.", e);
70             e.printStackTrace(new PrintWriter JavaDoc(sw));
71         }
72         return sw.toString();
73     }
74 }
75
Popular Tags