List of usage examples for org.apache.commons.lang CharEncoding UTF_8
String UTF_8
To view the source code for org.apache.commons.lang CharEncoding UTF_8.
Click Source Link
Eight-bit Unicode Transformation Format.
From source file:com.jaspersoft.jasperserver.api.security.externalAuth.sso.AbstractSsoAuthenticationProcessingFilter.java
/** * Attempt validation of SSO token./*from w ww . j a v a 2 s .c o m*/ * @param request sso server request * @return {@link Authentication} with some of the principal information * @throws AuthenticationException if authentication fails */ @Override public final Authentication attemptAuthentication(final HttpServletRequest request) throws AuthenticationException { try { logger.debug("Attempt authentication with SSO token ..."); Object ticket = obtainTicket(request); logger.debug("SSO Token: " + ticket); String userName = obtainUsername(request); userName = userName != null ? URLDecoder.decode(userName, CharEncoding.UTF_8) : null; String password = obtainPassword(request); final SsoAuthenticationToken authToken = new SsoAuthenticationToken(ticket, userName, password); setDetails(request, authToken); return this.getAuthenticationManager().authenticate(authToken); } catch (UnsupportedEncodingException e) { logger.error("could not decode user name " + obtainUsername(request)); throw new IllegalStateException(e); } }
From source file:net.bulletin.pdi.xero.step.support.XMLChunkerImpl.java
private String pullNextXmlChunkFromTopElementOnStack(XMLChunkerState data) throws KettleException { Stack<String> elementStack = data.getElementStack(); XMLStreamReader xmlStreamReader = data.getXmlStreamReader(); int elementStackDepthOnEntry = elementStack.size(); StringWriter stringWriter = new StringWriter(); try {/*from ww w .j av a2 s .c o m*/ XMLStreamWriter xmlStreamWriter = data.getXmlOutputFactory().createXMLStreamWriter(stringWriter); xmlStreamWriter.writeStartDocument(CharEncoding.UTF_8, "1.0"); // put the current element on because presumably it's the open element for the one // that is being looked for. XmlReaderToWriter.write(xmlStreamReader, xmlStreamWriter); while (xmlStreamReader.hasNext() & elementStack.size() >= elementStackDepthOnEntry) { switch (xmlStreamReader.next()) { case XMLStreamConstants.END_DOCUMENT: break; // handled below explicitly. case XMLStreamConstants.END_ELEMENT: elementStack.pop(); XmlReaderToWriter.write(xmlStreamReader, xmlStreamWriter); break; case XMLStreamConstants.START_ELEMENT: elementStack.push(xmlStreamReader.getLocalName()); XmlReaderToWriter.write(xmlStreamReader, xmlStreamWriter); break; default: XmlReaderToWriter.write(xmlStreamReader, xmlStreamWriter); break; } } xmlStreamWriter.writeEndDocument(); xmlStreamWriter.close(); } catch (Exception e) { throw new KettleException("unable to process a chunk of the xero xml stream", e); } return stringWriter.toString(); }
From source file:de.tsystems.mms.apm.performancesignature.util.PerfSigUIUtils.java
public static String encodeString(final String value) { if (StringUtils.isBlank(value)) { return ""; }//from w ww .ja va 2 s .com try { return URLEncoder.encode(value, CharEncoding.UTF_8).replaceAll("\\+", "%20"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(Messages.PerfSigUIUtils_EncodingFailure(), e); } }
From source file:com.aurora.mail.config.ThymeleafConfiguration.java
/** * THYMELEAF: Template Resolver for email templates * * @return//from w ww . j ava2 s. c om */ @Bean @Description("Thymeleaf template resolver serving HTML 5 emails") public ClassLoaderTemplateResolver emailTemplateResolver() { ClassLoaderTemplateResolver emailTemplateResolver = new ClassLoaderTemplateResolver(); emailTemplateResolver.setPrefix("mails/"); emailTemplateResolver.setSuffix(".html"); emailTemplateResolver.setTemplateMode("HTML5"); emailTemplateResolver.setCharacterEncoding(CharEncoding.UTF_8); emailTemplateResolver.setOrder(1); return emailTemplateResolver; }
From source file:io.personium.core.model.file.DataCryptorTest.java
/** * Test encode()./* www. j a v a2 s . co m*/ * normal. * @throws Exception Unexpected error. */ @Test public void encode_Normal() throws Exception { // -------------------- // Test method args // -------------------- String str = "0123456789"; InputStream input = new ByteArrayInputStream(str.getBytes(CharEncoding.UTF_8)); // -------------------- // Mock settings // -------------------- // Nothing. // -------------------- // Expected result // -------------------- // Nothing. // -------------------- // Run method // -------------------- DataCryptor cryptor = new DataCryptor("zyxwvutsrqponmlk"); CipherInputStream encodedInputStream = null; encodedInputStream = (CipherInputStream) cryptor.encode(input, true); // -------------------- // Confirm result // -------------------- Field field = FilterInputStream.class.getDeclaredField("in"); field.setAccessible(true); InputStream actualInput = (InputStream) field.get(encodedInputStream); assertThat(actualInput, is(input)); field = CipherInputStream.class.getDeclaredField("cipher"); field.setAccessible(true); Cipher actualCipher = (Cipher) field.get(encodedInputStream); byte[] expectedIV = "klmnopqrstuvwxyz".getBytes(CharEncoding.UTF_8); String expectedAlgorithm = "AES/CBC/PKCS5Padding"; assertThat(actualCipher.getIV(), is(expectedIV)); assertThat(actualCipher.getAlgorithm(), is(expectedAlgorithm)); }
From source file:com.revitasinc.sonar.dp.batch.parser.GitLogParser.java
public Map<String, List<RevisionInfo>> parse(InputStream inputStream) { Map<String, List<RevisionInfo>> result = new HashMap<String, List<RevisionInfo>>(); // ISO standard format (--date=iso) 2013-07-03 10:26:25 -0700 DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); try {// www . j a v a2 s.c o m RevisionInfo revInfo = null; String author = null; Date date = null; for (LineIterator iterator = IOUtils.lineIterator(inputStream, CharEncoding.UTF_8); iterator .hasNext();) { String line = iterator.nextLine(); if (line.startsWith(AUTHOR)) { author = line.split(EMAIL_START)[0].substring(AUTHOR.length()); revInfo = null; } else if (line.startsWith(DATE)) { date = df.parse(line.substring(DATE.length()).trim()); } else if (!StringUtils.isBlank(line) && !line.startsWith(COMMIT)) { if (revInfo == null) { revInfo = new RevisionInfo(author, date, line.trim(), 0); author = null; date = null; } else { processFileLine(line, revInfo, result); } } } } catch (NumberFormatException e) { logger.error(EMPTY_STRING, e); } catch (IOException e) { logger.error(EMPTY_STRING, e); } catch (ParseException e) { logger.error(EMPTY_STRING, e); } return result; }
From source file:mitm.common.dlp.impl.FileWordSkipper.java
private void loadFile() throws IOException { if (!file.exists()) { throw new IOException("File " + file.getAbsolutePath() + " does not exist."); }//from w w w . ja v a 2 s . c o m /* * Read the file using a Unicode aware reader */ UnicodeReader unicodeReader = new UnicodeReader(new FileInputStream(file), CharEncoding.UTF_8); LineIterator lineIterator = new LineIterator(unicodeReader); while (lineIterator.hasNext()) { String line = StringUtils.trimToNull(lineIterator.nextLine()); if (line == null || line.startsWith("#")) { continue; } words.add(line.toLowerCase()); } }
From source file:eu.eexcess.opensearch.querygenerator.OpensearchQuerygeneratorTest.java
@Test public void toQuery_withSecureUserProfileKeywordsAndLimit_expectsPass() { SecureUserProfile userProfile = new SecureUserProfile(); String keywordText = "some Text with special characters {[]}\\"; userProfile.numResults = 123;/*from ww w . j av a2 s . c om*/ userProfile.contextKeywords = newDummyContextKeywords(7, keywordText); OpensearchQueryGenerator generator = new OpensearchQueryGenerator(); String query = generator.toQuery(userProfile); try { assertTrue(query.contains(URLEncoder.encode(keywordText, CharEncoding.UTF_8))); assertTrue(query.contains(URLEncoder.encode(keywordText + "[1]", CharEncoding.UTF_8))); assertTrue(query.contains(URLEncoder.encode(keywordText + "[6]", CharEncoding.UTF_8))); assertFalse(query.contains(URLEncoder.encode(keywordText + "[7]", CharEncoding.UTF_8))); assertTrue(query.contains("&limit=" + userProfile.numResults)); } catch (UnsupportedEncodingException e) { assertTrue(false); } }
From source file:com.revitasinc.sonar.dp.batch.parser.CvsLogParser.java
public Map<String, List<RevisionInfo>> parse(InputStream inputStream) { Map<String, List<RevisionInfo>> result = new HashMap<String, List<RevisionInfo>>(); DateFormat df = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss"); try {//from ww w .j ava2 s . c o m String currentFile = null; boolean isRevision = false; List<RevisionInfo> revList = null; RevisionInfo revInfo = null; for (LineIterator iterator = IOUtils.lineIterator(inputStream, CharEncoding.UTF_8); iterator .hasNext();) { String line = iterator.nextLine(); if (line.startsWith(WORKING_FILE)) { currentFile = line.substring(WORKING_FILE.length()); revList = new ArrayList<RevisionInfo>(); } else if (line.equals(REV_SEPARATOR)) { isRevision = true; revInfo = null; } else if (line.equals(FILE_SEPARATOR)) { isRevision = false; putResult(result, currentFile, revList); } else if (isRevision) { if (isDataLine(line)) { revInfo = infoFromLine(line, df); } else if (isCommentLine(line, revInfo)) { revList.add(new RevisionInfo(revInfo.getAuthor(), revInfo.getDate(), line, revInfo.getAddedLineCount())); revInfo = null; } } } } catch (IOException e) { logger.error(EMPTY_STRING, e); } return result; }
From source file:co.cask.cdap.metrics.query.MetricQueryParser.java
private static String urlDecode(String str) { try {/* ww w. j a v a 2s. c o m*/ return URLDecoder.decode(str, CharEncoding.UTF_8); } catch (UnsupportedEncodingException e) { throw new IllegalArgumentException("unsupported encoding in path element", e); } }