Search in sources :

Example 11 with RequestContext

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());
            }
        }
    }
}
Also used : ServletOutputStream(javax.servlet.ServletOutputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) DataInputStream(java.io.DataInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) HttpServletResponse(javax.servlet.http.HttpServletResponse) RequestContext(com.iplanet.jato.RequestContext) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream)

Example 12 with RequestContext

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);
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) STSHomeViewBeanModelImpl(com.sun.identity.console.sts.model.STSHomeViewBeanModelImpl) RequestContext(com.iplanet.jato.RequestContext) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 13 with RequestContext

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());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IDRepoModelImpl(com.sun.identity.console.realm.model.IDRepoModelImpl) RequestContext(com.iplanet.jato.RequestContext)

Example 14 with RequestContext

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
    }
}
Also used : CompleteRequestException(com.iplanet.jato.CompleteRequestException) RequestContext(com.iplanet.jato.RequestContext) IOException(java.io.IOException)

Example 15 with RequestContext

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());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) AMModelBase(com.sun.identity.console.base.model.AMModelBase) RequestContext(com.iplanet.jato.RequestContext)

Aggregations

RequestContext (com.iplanet.jato.RequestContext)32 HttpServletRequest (javax.servlet.http.HttpServletRequest)20 IOException (java.io.IOException)5 AuthConfigurationModelImpl (com.sun.identity.console.authentication.model.AuthConfigurationModelImpl)3 AuthPropertiesModelImpl (com.sun.identity.console.authentication.model.AuthPropertiesModelImpl)3 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)3 AMModelBase (com.sun.identity.console.base.model.AMModelBase)3 ISLocaleContext (com.sun.identity.common.ISLocaleContext)2 DelegationModelImpl (com.sun.identity.console.delegation.model.DelegationModelImpl)2 EntityModelImpl (com.sun.identity.console.federation.model.EntityModelImpl)2 RestSTSInstanceModel (com.sun.identity.console.sts.model.RestSTSInstanceModel)2 SoapSTSInstanceModel (com.sun.identity.console.sts.model.SoapSTSInstanceModel)2 PWResetUserValidationModel (com.sun.identity.password.ui.model.PWResetUserValidationModel)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 DataInputStream (java.io.DataInputStream)2 InputStream (java.io.InputStream)2 ServletOutputStream (javax.servlet.ServletOutputStream)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 CompleteRequestException (com.iplanet.jato.CompleteRequestException)1 HiddenField (com.iplanet.jato.view.html.HiddenField)1