ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/tomcat/util/net/ocsp/TestOcspEnabled.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/tomcat/util/net/ocsp/TestOcspEnabled.java
Status
scanned
Type
file
Name
TestOcspEnabled.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
4610 (4.5 KB)
MD5
dd518d5fddd8587813a7ec406eea7eef
SHA1
be546ca6685e1e07eb23e9f07a74d21982caecd3
SHA256
e45bc3ab1f4596d52d94af9d39de0ed80d376bca9a25a098ab8020a074294cdd
SHA512

      
    
SHA1_git
45d459239df093c44b9b1fe82d7d664e3f9b30f8
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestOcspEnabled.java | 4.5 KB |

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.tomcat.util.net.ocsp; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.List; import javax.net.ssl.SSLHandshakeException; import org.junit.AfterClass; import org.junit.Assert; import org.junit.Assume; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; @RunWith(Parameterized.class) public class TestOcspEnabled extends OcspBaseTest { private static TesterOcspResponder ocspResponder; @BeforeClass public static void startOcspResponder() { ocspResponder = new TesterOcspResponder(); try { ocspResponder.start(); } catch (IOException ioe) { ocspResponder = null; } } @AfterClass public static void stopOcspResponder() { if (ocspResponder != null) { ocspResponder.stop(); ocspResponder = null; } } @Parameters(name = "{0} with OpenSSL trust {2}: clientOk {4}, serverOk {5}, verifyClient {6}, verifyServer {7}") public static Collection<Object[]> parameters() { List<Object[]> parameterSets = new ArrayList<>(); Collection<Object[]> baseData = OcspBaseTest.parameters(); for (Object[] base : baseData) { for (Boolean clientCertValid : booleans) { for (Boolean serverCertValid : booleans) { for (ClientCertificateVerification verifyClientCert : ClientCertificateVerification.values()) { boolean useOpenSSLTrust = ((Boolean) base[2]).booleanValue(); if (verifyClientCert == ClientCertificateVerification.OPTIONAL_NO_CA && !useOpenSSLTrust || verifyClientCert == ClientCertificateVerification.ENABLED && !clientCertValid.booleanValue()) { continue; } for (Boolean verifyServerCert : booleans) { Boolean handshakeFailureExpected; if (!serverCertValid.booleanValue() && verifyServerCert.booleanValue()) { handshakeFailureExpected = Boolean.TRUE; } else { handshakeFailureExpected = Boolean.FALSE; } parameterSets.add(new Object[] { base[0], base[1], base[2], base[3], clientCertValid, serverCertValid, verifyClientCert, verifyServerCert, handshakeFailureExpected}); } } } } } return parameterSets; } @Parameter(4) public boolean clientCertValid; @Parameter(5) public boolean serverCertValid; @Parameter(6) public ClientCertificateVerification verifyClientCert; @Parameter(7) public boolean verifyServerCert; @Parameter(8) public boolean handshakeFailureExpected; @Test public void test() throws Exception { Assume.assumeNotNull(ocspResponder); try { doTest(clientCertValid, serverCertValid, verifyClientCert, verifyServerCert); if (handshakeFailureExpected) { Assert.fail("Handshake did not fail when expected to do so."); } } catch (SSLHandshakeException e) { if (!handshakeFailureExpected) { Assert.fail("Handshake failed when not expected to do so."); } } } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
29.9
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9