Java Code Examples for javax.json.JsonArray#toString()
The following examples show how to use
javax.json.JsonArray#toString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AuthResource.java From eplmp with Eclipse Public License 1.0 | 6 votes |
private String getSigningKeys(String url) { OkHttpClient client = new OkHttpClient(); Request request = new Request.Builder().url(url).build(); JsonReader jsonReader = null; try { com.squareup.okhttp.Response response = client.newCall(request).execute(); jsonReader = Json.createReader(new StringReader(response.body().string())); JsonObject object = jsonReader.readObject(); JsonArray keys = object.getJsonArray("keys"); return keys.toString(); } catch (IOException | JsonParsingException e) { LOGGER.log(Level.SEVERE, null, e); return null; } finally { if (jsonReader != null) { jsonReader.close(); } } }
Example 2
Source File: MavenDependencySettingsService.java From sonarqube-licensecheck with Apache License 2.0 | 6 votes |
private void initMavenDependencies() { JsonArray jsonArray = Json .createArrayBuilder() .add(Json.createObjectBuilder().add("nameMatches", "org.apache..*").add("license", "Apache-2.0")) .add(Json.createObjectBuilder().add("nameMatches", "org.glassfish..*").add("license", "CDDL-1.0")) .build(); String initValueMavenDepependencies = jsonArray.toString(); String mavenDependencies = persistentSettings.getSettings().getString(ALLOWED_DEPENDENCIES_KEY); if ((mavenDependencies != null) && !mavenDependencies.isEmpty()) { return; } persistentSettings.getSettings().setProperty(ALLOWED_DEPENDENCIES_KEY, initValueMavenDepependencies); persistentSettings.saveProperty(ALLOWED_DEPENDENCIES_KEY, initValueMavenDepependencies); }
Example 3
Source File: ManagementHelper.java From activemq-artemis with Apache License 2.0 | 6 votes |
/** * Stores an operation invocation in a message to invoke the corresponding operation the value from the server resource. * * @param message message * @param resourceName the name of the server resource * @param operationName the name of the operation to invoke on the server resource * @param parameters the parameters to use to invoke the server resource * @see ResourceNames */ public static void putOperationInvocation(final ICoreMessage message, final String resourceName, final String operationName, final Object... parameters) throws Exception { // store the name of the operation in the headers message.putStringProperty(ManagementHelper.HDR_RESOURCE_NAME, new SimpleString(resourceName)); message.putStringProperty(ManagementHelper.HDR_OPERATION_NAME, new SimpleString(operationName)); // and the params go in the body, since might be too large for header String paramString; if (parameters != null) { JsonArray jsonArray = JsonUtil.toJSONArray(parameters); paramString = jsonArray.toString(); } else { paramString = null; } message.getBodyBuffer().writeNullableSimpleString(SimpleString.toSimpleString(paramString)); }
Example 4
Source File: ManagementHelper.java From activemq-artemis with Apache License 2.0 | 6 votes |
/** * Used by ActiveMQ Artemis management service. */ public static void storeResult(final CoreMessage message, final Object result) throws Exception { String resultString; if (result != null) { // Result is stored in body, also encoded as JSON array of length 1 JsonArray jsonArray = JsonUtil.toJSONArray(new Object[]{result}); resultString = jsonArray.toString(); } else { resultString = null; } message.getBodyBuffer().writeNullableSimpleString(SimpleString.toSimpleString(resultString)); }
Example 5
Source File: verifyFido2RegistrationPolicy.java From fido2 with GNU Lesser General Public License v2.1 | 4 votes |
private void verifyMDS(MdsPolicyOptions mdsOp, JsonObject clientJson, FIDO2AttestationObject attObject, MDSClient mds, Integer version) throws SKFEException, CertificateException, NoSuchProviderException{ //MDS not configured, skipping checks if(mdsOp == null || mds == null){ return; } boolean isPolicyQualifiersRejected = true; byte[] aaguidbytes = attObject.getAuthData().getAttCredData().getAaguid(); byte[] aaguidbytes1 = new byte[8]; byte[] aaguidbytes2 = new byte[8]; System.arraycopy(aaguidbytes, 0, aaguidbytes1, 0, 8); System.arraycopy(aaguidbytes, 8, aaguidbytes2, 0, 8); UUID uuid = new UUID(Longs.fromByteArray(aaguidbytes1), Longs.fromByteArray(aaguidbytes2)); JsonObject trustAnchors = mds.getTrustAnchors(uuid.toString(), mdsOp.getAllowedCertificationLevel()); FIDO2AttestationStatement attStmt = attObject.getAttStmt(); if(attStmt == null){ return; } if(attObject.getAttFormat().equals("fido-u2f")){ return; } if (attObject.getAttFormat().equals("tpm")) { isPolicyQualifiersRejected = false; } //TODO if no certificate chain returned, check/implement ECDAA ArrayList attBytesChain = attObject.getAttStmt().getX5c(); if(attBytesChain == null || attBytesChain.isEmpty()){ return; } List<Certificate> certchain = new ArrayList<>(); X509Certificate leafCert = cryptoCommon.generateX509FromBytes((byte[]) attBytesChain.get(0)); //check leaf if it is self signed certchain.add(leafCert); if(leafCert.getSubjectDN().equals(leafCert.getIssuerDN())){ //TODO verify certificate properly self-signs itself return; } //Create certificate path if (!attBytesChain.isEmpty()) { for (int attCertIndex = 1; attCertIndex < attBytesChain.size(); attCertIndex++) { X509Certificate attestationCert = cryptoCommon.generateX509FromBytes((byte[]) attBytesChain.get(attCertIndex)); skfsLogger.log(skfsConstants.SKFE_LOGGER, Level.FINE, "FIDO-MSG-2001", "CertPath " + attCertIndex + ": " + attestationCert); certchain.add(attestationCert); } } else { throw new SKIllegalArgumentException("Expected Certificate chain missing"); } CertPath certPath = CertificateFactory.getInstance("X.509", "BCFIPS").generateCertPath(certchain); //Create list of possible roots from MDS Set<TrustAnchor> rootAnchors = new HashSet<>(); JsonArray roots = trustAnchors.getJsonArray("attestationRootCertificates"); JsonArray errors = trustAnchors.getJsonArray("errors"); if(!errors.isEmpty()){ throw new SKIllegalArgumentException("MDS error(s): " + errors.toString()); } if(roots == null){ throw new SKIllegalArgumentException("Root certificates not found in MDS"); } for(int rootIndex = 0; rootIndex < roots.size(); rootIndex++) { byte[] certBytes = java.util.Base64.getDecoder().decode(roots.getString(rootIndex)); rootAnchors.add(new TrustAnchor(cryptoCommon.generateX509FromBytes(certBytes), null)); } //Verify chain chains up to one of the roots. if(!PKIXChainValidation.pkixvalidate(certPath, rootAnchors, false, isPolicyQualifiersRejected)){ //TODO check CRLs if they exist, otherwise don't throw new SKIllegalArgumentException("Failed to verify certificate path"); } }
Example 6
Source File: QueueControlImpl.java From activemq-artemis with Apache License 2.0 | 4 votes |
private static String toJSON(final Map<String, Object>[] messages) { JsonArray array = toJSONMsgArray(messages); return array.toString(); }