/* * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
/** * Returns the cacerts keystore with the configured CA certificates.
*/ publicstatic KeyStore getCacertsKeyStore() throws Exception {
File file = new File(getCacerts()); if (!file.exists()) { returnnull;
} return KeyStore.getInstance(file, (char[])null);
}
/** * Removes the specified protocols from the jdk.tls.disabledAlgorithms * security property.
*/ publicstaticvoid removeFromDisabledTlsAlgs(String... protocols) {
removeFromDisabledAlgs("jdk.tls.disabledAlgorithms",
List.<String>of(protocols));
}
/** * Removes constraints that contain the specified constraint from the * specified security property. For example, List.of("SHA1") will remove * any constraint containing "SHA1".
*/ publicstaticvoid removeFromDisabledAlgs(String prop,
List<String> constraints) {
String value = Security.getProperty(prop);
value = Arrays.stream(value.split(","))
.map(s -> s.trim())
.filter(s -> constraints.stream()
.allMatch(constraint -> !s.contains(constraint)))
.collect(Collectors.joining(","));
Security.setProperty(prop, value);
}
/** * Removes the specified algorithms from the * jdk.xml.dsig.secureValidationPolicy security property. Matches any * part of the algorithm URI.
*/ publicstaticvoid removeAlgsFromDSigPolicy(String... algs) {
removeFromDSigPolicy("disallowAlg", List.<String>of(algs));
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.