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();
}
}
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());
}
}
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;
}
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 <constMethodKlass>
* 2: 18329 1479904 <methodKlass>
* 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();
}
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);
}
Aggregations