use of com.iplanet.jato.RequestContext in project OpenAM by OpenRock.
the class RealmPropertiesViewBean method getModelInternal.
protected AMModel getModelInternal() {
RequestContext rc = RequestManager.getRequestContext();
HttpServletRequest req = rc.getRequest();
return new RMRealmModelImpl(req, getPageSessionAttributes());
}
use of com.iplanet.jato.RequestContext in project OpenAM by OpenRock.
the class ConfigureSalesForceAppsCompleteViewBean method handleButtonDownloadCertRequest.
/**
* Handles Verification Certificate download button request.
* Sends Verification Certificate to the ServletResponse output stream.
* @param event Request invocation event
*/
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();
// Set the response
resp.setContentType("application/octet-stream");
resp.setContentLength(cert.length());
resp.setHeader("Content-Disposition", "attachment; filename=\"" + "OpenSSOCert.txt" + "\"");
// Stream to the requester.
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("ConfigureSalesForceAppsCompleteViewBean.uploadCert", ex);
setInlineAlertMessage(CCAlert.TYPE_ERROR, "configure.salesforce.apps.complete.certificate.download.error", ex.getMessage());
} finally {
if (op != null) {
try {
op.close();
} catch (IOException ex) {
debug.error("ConfigureSalesForceAppsCompleteViewBean.uploadCert", ex);
setInlineAlertMessage(CCAlert.TYPE_ERROR, "configure.SalesForce.apps.complete.certificate.download.error", ex.getMessage());
}
}
}
}
Aggregations