public void handleButtonDownloadCertRequest(RequestInvocationEvent event) throws ModelControlException {
  RequestContext reqContext=event.getRequestContext();
  HttpServletResponse resp=reqContext.getResponse();
  String cert=(String)psModel.getValue("PubKey");
  ServletOutputStream op=null;
  try {
    int length=0;
    op=resp.getOutputStream();
    resp.setContentType("application/octet-stream");
    resp.setContentLength(cert.length());
    resp.setHeader("Content-Disposition","attachment; filename=\"" + "OpenSSOCert.txt" + "\"");
    int BUFSIZE=cert.length();
    byte[] bbuf=new byte[BUFSIZE];
    InputStream is=new ByteArrayInputStream(cert.getBytes());
    DataInputStream in=new DataInputStream(is);
    while ((in != null) && ((length=in.read(bbuf)) != -1)) {
      op.write(bbuf,0,length);
    }
    in.close();
    op.flush();
  }
 catch (  IOException ex) {
    debug.error("ConfigureGoogleAppsCompleteViewBean.uploadCert",ex);
    setInlineAlertMessage(CCAlert.TYPE_ERROR,"configure.google.apps.complete.certificate.download.error",ex.getMessage());
  }
 finally {
    if (op != null) {
      try {
        op.close();
      }
 catch (      IOException ex) {
        debug.error("ConfigureGoogleAppsCompleteViewBean.uploadCert",ex);
        setInlineAlertMessage(CCAlert.TYPE_ERROR,"configure.google.apps.complete.certificate.download.error",ex.getMessage());
      }
    }
  }
}

public void handleButtonDownloadCertRequest ( RequestInvocationEvent event ) throws ModelControlException { RequestContext reqContext = event . getRequestContext ( ) ; HttpServletResponse resp = reqContext . getResponse ( ) ; String cert = ( String ) psModel . getValue ( "PubKey" ) ; ServletOutputStream op = null ; try { int length = 0 ; op = resp . getOutputStream ( ) ; resp . setContentType ( "application/octet-stream" ) ; resp . setContentLength ( cert . length ( ) ) ; resp . setHeader ( "Content-Disposition" , "attachment; filename=\"" + "OpenSSOCert.txt" + "\"" ) ; int BUFSIZE = cert . length ( ) ; byte [ ] bbuf = new byte [ BUFSIZE ] ; InputStream is = new ByteArrayInputStream ( cert . getBytes ( ) ) ; DataInputStream in = new DataInputStream ( is ) ; while ( ( in != null ) && ( ( length = in . read ( bbuf ) ) != - 1 ) ) { op . write ( bbuf , 0 , length ) ; } in . close ( ) ; op . flush ( ) ; } catch ( IOException ex ) { debug . error ( "ConfigureGoogleAppsCompleteViewBean.uploadCert" , ex ) ; setInlineAlertMessage ( CCAlert . TYPE_ERROR , "configure.google.apps.complete.certificate.download.error" , ex . getMessage ( ) ) ; } finally { if ( op != null ) { try { op . close ( ) ; } catch ( IOException ex ) { debug . error ( "ConfigureGoogleAppsCompleteViewBean.uploadCert" , ex ) ; setInlineAlertMessage ( CCAlert . TYPE_ERROR , "configure.google.apps.complete.certificate.download.error" , ex . getMessage ( ) ) ; } } } }
handles verification certificate download button request . sends verification certificate to the servletresponse output stream .
