List of usage examples for java.nio.charset StandardCharsets UTF_8
Charset UTF_8
To view the source code for java.nio.charset StandardCharsets UTF_8.
Click Source Link
From source file:org.springframework.cloud.dataflow.rest.util.ResourceBasedAuthorizationInterceptor.java
@Override public void process(HttpRequest httpRequest, HttpContext httpContext) throws HttpException, IOException { final String credentials = StreamUtils.copyToString(resource.getInputStream(), StandardCharsets.UTF_8) .trim();/*from w w w .j a v a 2s . c om*/ resource.check(); httpRequest.addHeader(HttpHeaders.AUTHORIZATION, credentials); }
From source file:com.haulmont.cuba.core.sys.dbupdate.ScriptResource.java
public String getContent() throws IOException { return IOUtils.toString(resource.getInputStream(), StandardCharsets.UTF_8); }
From source file:de.tud.inf.db.sparqlytics.bench.LDBCBenchmark.java
@BeforeClass public static void bindRepository() throws Exception { SPARQLyticsParser parser = new SPARQLyticsParser( new InputStreamReader(LDBCBenchmark.class.getResourceAsStream("ldbc-snb-bi-repository.sparqlytics"), StandardCharsets.UTF_8)); parser.Start();/*from w w w . j ava2 s. c o m*/ Repository repository = parser.getRepository(); Slf4jReporter.forRegistry(repository.getStatistics()).withLoggingLevel(Slf4jReporter.LoggingLevel.INFO) .prefixedWith("before:").build().report(); //Set system properties Context.INITIAL_CONTEXT_FACTORY and Context.PROVIDER_URL in pom.xml new InitialContext(new Hashtable<Object, Object>()).bind("ldbc", repository); }
From source file:CWLClientTest.java
/** * This test demonstrates how to take a CWL document and generate a corresponding json parameters file for it. * @throws Exception/* ww w .ja v a 2s .c o m*/ */ @Test public void serializeToJson() throws Exception { final URL resource = Resources.getResource("cwl.json"); final String cwlJson = Resources.toString(resource, StandardCharsets.UTF_8); final CWL cwl = new CWL(); final Gson gson = CWL.getTypeSafeCWLToolDocument(); final Map<String, Object> runJson = cwl.extractRunJson(cwlJson); // check that default values made it assertTrue(runJson.get("mem_gb").equals(4)); assertTrue( ((Map) runJson.get("bam_input")).get("path").equals("default_directory/default_bam_location.bam")); assertTrue(((Map) runJson.get("bam_input")).containsKey("format")); final String s = gson.toJson(runJson); assertTrue(s.length() > 10); }
From source file:aiai.ai.utils.checksum.TestChecksumWithSignature.java
@Test public void test() throws IOException, GeneralSecurityException { File file = new File("config", "private-key.txt"); String base64 = FileUtils.readFileToString(file, StandardCharsets.UTF_8); PrivateKey privateKey = SecUtils.getPrivateKey(base64); String checksum = "69c33a60e09f00fa3610fb8833bef54487f9c8b99db48b339cd6ed0f192ba5c9"; String signature = SecUtils.getSignature(checksum, privateKey); String forVerifying = checksum + SecUtils.SIGNATURE_DELIMITER + signature; ChecksumWithSignatureService.ChecksumWithSignature checksumWithSignature = ChecksumWithSignatureService .parse(forVerifying);// ww w . j a v a 2 s . c om assertTrue(ChecksumWithSignatureService.isValid(checksumWithSignature.checksum.getBytes(), checksumWithSignature.signature, globals.publicKey)); }
From source file:de.micromata.genome.util.types.Converter.java
/** * Encode url param.// w ww . j a va 2s . c om * * @param value the value * @return the string */ public static String encodeUrlParam(String value) { if (StringUtils.isEmpty(value) == true) { return ""; } try { return URLEncoder.encode(value, StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException ex) { throw new RuntimeException(ex); } }
From source file:co.rsk.net.discovery.message.NeighborsPeerMessage.java
public static NeighborsPeerMessage create(List<Node> nodes, String check, ECKey privKey) { byte[][] nodeRLPs = null; if (nodes != null) { nodeRLPs = new byte[nodes.size()][]; int i = 0; for (Node node : nodes) { nodeRLPs[i] = node.getRLP(); ++i;//w ww. j av a2s . c o m } } byte[] rlpListNodes = RLP.encodeList(nodeRLPs); byte[] rlpCheck = RLP.encodeElement(check.getBytes(StandardCharsets.UTF_8)); byte[] type = new byte[] { (byte) DiscoveryMessageType.NEIGHBORS.getTypeValue() }; byte[] data = RLP.encodeList(rlpListNodes, rlpCheck); NeighborsPeerMessage neighborsMessage = new NeighborsPeerMessage(); neighborsMessage.encode(type, data, privKey); neighborsMessage.nodes = nodes; neighborsMessage.messageId = check; return neighborsMessage; }
From source file:com.xavin.config.security.JWTLoginFilter.java
/** * @Override protected boolean requiresAuthentication(HttpServletRequest * request, HttpServletResponse response) { * * }// w w w . ja v a2 s.c o m */ @Override public Authentication attemptAuthentication(HttpServletRequest req, HttpServletResponse res) throws AuthenticationException, IOException, ServletException { String data = IOUtils.toString(req.getInputStream(), StandardCharsets.UTF_8); AccountCredentials creds = new ObjectMapper().readValue(data, AccountCredentials.class); return getAuthenticationManager().authenticate(new UsernamePasswordAuthenticationToken(creds.getUsername(), creds.getPassword(), Collections.emptyList())); }
From source file:jenkins.plugins.jclouds.credentials.JCloudsUserWithKey.java
private static String getJsonString(final String fileUploadEntry, final String fieldName) { if (null != fileUploadEntry) { try {/*from ww w. ja v a2 s.c om*/ final FileItem fi = Stapler.getCurrentRequest().getFileItem(fileUploadEntry); if (null != fi) { final String content = new String(fi.get(), StandardCharsets.UTF_8); if (null != content && !content.isEmpty()) { final JsonObject jo = new JsonParser().parse(content).getAsJsonObject(); final String value = jo.get(fieldName).getAsString(); return value; } } } catch (Exception x) { LOGGER.warning(x.getMessage()); } } return null; }
From source file:io.kamax.mxisd.util.GsonParser.java
public JsonObject parse(InputStream stream) throws IOException { JsonElement el = parser.parse(IOUtils.toString(stream, StandardCharsets.UTF_8)); if (!el.isJsonObject()) { throw new InvalidResponseJsonException("Response body is not a JSON object"); }// w w w .j a v a2s .co m return el.getAsJsonObject(); }