Search in sources :

Example 71 with UnsupportedEncodingException

use of java.io.UnsupportedEncodingException in project OpenAM by OpenRock.

the class ConsoleServletBase method validateSSOToken.

private void validateSSOToken(RequestContext requestContext) throws ServletException {
    try {
        /*
             * Since all supported web containers now support
             * servlet 2.3 and above, we use setCharacterEncoding
             * to set request charset.
             */
        HttpServletRequest req = requestContext.getRequest();
        SSOToken token = checkAuthentication(req);
        String enc = token.getProperty("CharSet");
        try {
            String jCharset = BrowserEncoding.mapHttp2JavaCharset(enc);
            req.setCharacterEncoding(jCharset);
        } catch (UnsupportedEncodingException ex) {
            getDebug().error("ConsoleServletBase.validateSSOToken " + "Unsupported encoding", ex);
        }
    } catch (SSOException soe) {
        browserRedirect(requestContext, formGotoUrl(requestContext.getRequest()));
        throw new CompleteRequestException();
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) SSOToken(com.iplanet.sso.SSOToken) CompleteRequestException(com.iplanet.jato.CompleteRequestException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) SSOException(com.iplanet.sso.SSOException)

Example 72 with UnsupportedEncodingException

use of java.io.UnsupportedEncodingException in project OpenAM by OpenRock.

the class EntityServicesViewBean method handleTblDataActionHrefRequest.

public void handleTblDataActionHrefRequest(String serviceName) throws ModelControlException {
    EntitiesModel model = (EntitiesModel) getModel();
    SCUtils utils = new SCUtils(serviceName, model);
    String propertiesViewBeanURL = utils.getServiceDisplayURL();
    String universalId = (String) getPageSessionAttribute(EntityEditViewBean.UNIVERSAL_ID);
    // This is not needed in 7.0, but is still used by old 6.3 console.
    if (serviceName.equals(AMAdminConstants.AUTH_CONFIG_SERVICE)) {
        propertiesViewBeanURL = null;
    }
    if ((propertiesViewBeanURL != null) && (propertiesViewBeanURL.trim().length() > 0)) {
        try {
            String realm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
            String pageTrailID = (String) getPageSessionAttribute(PG_SESSION_PAGE_TRAIL_ID);
            setPageSessionAttribute(getTrackingTabIDName(), Integer.toString(TAB_SERVICES));
            propertiesViewBeanURL += "?ServiceName=" + serviceName + "&User=" + Locale.URLEncodeField(stringToHex(universalId), getCharset(model)) + "&Op=" + AMAdminConstants.OPERATION_EDIT + "&realm=" + Locale.URLEncodeField(realm, getCharset(model)) + "&" + PG_SESSION_PAGE_TRAIL_ID + "=" + pageTrailID;
            HttpServletResponse response = getRequestContext().getResponse();
            response.sendRedirect(propertiesViewBeanURL);
        } catch (UnsupportedEncodingException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
            forwardTo();
        } catch (IOException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
            forwardTo();
        }
    } else {
        ServicesEditViewBean vb = (ServicesEditViewBean) getViewBean(ServicesEditViewBean.class);
        setPageSessionAttribute(ServicesEditViewBean.SERVICE_NAME, serviceName);
        unlockPageTrail();
        passPgSessionMap(vb);
        vb.forwardTo(getRequestContext());
    }
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException) EntitiesModel(com.sun.identity.console.idm.model.EntitiesModel) SCUtils(com.sun.identity.console.service.model.SCUtils)

Example 73 with UnsupportedEncodingException

use of java.io.UnsupportedEncodingException in project OpenAM by OpenRock.

the class AMViewConfig method parseDocument.

private Document parseDocument(String fileName) {
    Document document = null;
    InputStream is = getClass().getClassLoader().getResourceAsStream(fileName);
    try {
        DocumentBuilder documentBuilder = XMLUtils.getSafeDocumentBuilder(false);
        document = documentBuilder.parse(is);
    } catch (UnsupportedEncodingException e) {
        AMModelBase.debug.error("AMViewConfig.parseDocument", e);
    } catch (ParserConfigurationException e) {
        AMModelBase.debug.error("AMViewConfig.parseDocument", e);
    } catch (SAXException e) {
        AMModelBase.debug.error("AMViewConfig.parseDocument", e);
    } catch (IOException e) {
        AMModelBase.debug.error("AMViewConfig.parseDocument", e);
    }
    return document;
}
Also used : DocumentBuilder(javax.xml.parsers.DocumentBuilder) InputStream(java.io.InputStream) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IOException(java.io.IOException) Document(org.w3c.dom.Document) SAXException(org.xml.sax.SAXException)

Example 74 with UnsupportedEncodingException

use of java.io.UnsupportedEncodingException in project tdi-studio-se by Talend.

the class HeapDumpHandler method getHeapHistogram.

/**
     * Gets the heap histogram from target JVM.
     * <p>
     * e.g.
     * 
     * <pre>
     *  num     #instances         #bytes  class name
     * ----------------------------------------------
     *    1:         18329        2104376  &lt;constMethodKlass&gt;
     *    2:         18329        1479904  &lt;methodKlass&gt;
     *    3:          2518        1051520  [B
     *    4:         11664         989856  [C
     *    5:         11547         277128  java.lang.String
     * </pre>
     * 
     * @param virtualMachine The virtual machine
     * @param isLive True to dump only live objects
     * @return The heap histogram
     * @throws JvmCoreException
     */
private static String getHeapHistogram(Object virtualMachine, boolean isLive) throws JvmCoreException {
    InputStream in = Tools.getInstance().invokeHeapHisto(virtualMachine, isLive);
    byte[] bytes = new byte[BUFFER_SIZE];
    int length;
    StringBuilder builder = new StringBuilder();
    try {
        while ((length = in.read(bytes)) != -1) {
            String string = new String(bytes, 0, length, IConstants.UTF8);
            builder.append(string);
        }
    } catch (UnsupportedEncodingException e) {
        throw new JvmCoreException(IStatus.ERROR, Messages.charsetNotSupportedMsg, e);
    } catch (IOException e) {
        throw new JvmCoreException(IStatus.ERROR, Messages.readInputStreamFailedMsg, e);
    } finally {
        try {
            in.close();
        } catch (IOException e) {
        // ignore
        }
    }
    return builder.toString();
}
Also used : InputStream(java.io.InputStream) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 75 with UnsupportedEncodingException

use of java.io.UnsupportedEncodingException in project voltdb by VoltDB.

the class ClientStats method latencyHistoReport.

/**
     * Generate a human-readable report of latencies in the form of a histogram. Latency is
     * in milliseconds
     *
     * @return String containing human-readable report.
     */
public String latencyHistoReport() {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream pw = null;
    try {
        pw = new PrintStream(baos, false, Charsets.UTF_8.name());
    } catch (UnsupportedEncodingException e) {
        Throwables.propagate(e);
    }
    //Get a latency report in milliseconds
    m_latencyHistogram.outputPercentileDistributionVolt(pw, 1, 1000.0);
    return new String(baos.toByteArray(), Charsets.UTF_8);
}
Also used : PrintStream(java.io.PrintStream) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Aggregations

UnsupportedEncodingException (java.io.UnsupportedEncodingException)3108 IOException (java.io.IOException)878 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)284 InputStream (java.io.InputStream)275 ArrayList (java.util.ArrayList)268 InputStreamReader (java.io.InputStreamReader)243 File (java.io.File)234 ByteArrayInputStream (java.io.ByteArrayInputStream)209 ByteArrayOutputStream (java.io.ByteArrayOutputStream)201 FileNotFoundException (java.io.FileNotFoundException)198 HashMap (java.util.HashMap)182 MessageDigest (java.security.MessageDigest)180 BufferedReader (java.io.BufferedReader)150 URL (java.net.URL)150 Map (java.util.Map)148 OutputStreamWriter (java.io.OutputStreamWriter)145 FileOutputStream (java.io.FileOutputStream)120 MalformedURLException (java.net.MalformedURLException)110 FileInputStream (java.io.FileInputStream)107 List (java.util.List)105