use of com.iplanet.jato.RequestContext in project OpenAM by OpenRock.
the class ConfigureGoogleAppsCompleteViewBean 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("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());
}
}
}
}
use of com.iplanet.jato.RequestContext in project OpenAM by OpenRock.
the class STSHomeViewBean method getModelInternal.
protected AMModel getModelInternal() {
RequestContext rc = RequestManager.getRequestContext();
HttpServletRequest req = rc.getRequest();
try {
return new STSHomeViewBeanModelImpl(req, getPageSessionAttributes());
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
throw new IllegalStateException("Exception getting model in STSHomeViewBean: " + e.getMessage(), e);
}
}
use of com.iplanet.jato.RequestContext in project OpenAM by OpenRock.
the class IDRepoViewBean method getModelInternal.
protected AMModel getModelInternal() {
RequestContext rc = RequestManager.getRequestContext();
HttpServletRequest req = rc.getRequest();
return new IDRepoModelImpl(req, getPageSessionAttributes());
}
use of com.iplanet.jato.RequestContext in project OpenAM by OpenRock.
the class XuiRedirectHelper method redirectToXui.
/**
* Redirects to the XUI to the specified realm and hash.
*
* @param request Used to determine the OpenAM deployment URI.
* @param redirectRealm The realm.
* @param xuiHash The XUI location hash.
*/
public static void redirectToXui(HttpServletRequest request, String redirectRealm, String xuiHash) {
String deploymentUri = InjectorHolder.getInstance(BaseURLProviderFactory.class).get(redirectRealm).getRootURL(request);
String redirect = MessageFormat.format(XUI_CONSOLE_BASE_PAGE, deploymentUri, xuiHash);
RequestContext rc = RequestManager.getRequestContext();
try {
rc.getResponse().sendRedirect(redirect);
throw new CompleteRequestException();
} catch (IOException e) {
//never thrown, empty catch
}
}
use of com.iplanet.jato.RequestContext in project OpenAM by OpenRock.
the class ScriptUploaderViewBean method getModelInternal.
/**
* {@inheritDoc}
*/
@Override
protected AMModel getModelInternal() {
RequestContext rc = RequestManager.getRequestContext();
HttpServletRequest req = rc.getRequest();
return new AMModelBase(req, getPageSessionAttributes());
}
Aggregations