ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/catalina/realm/TestMessageDigestCredentialHandler.java

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

      
    
Rootfs path

      
    
Size
2360 (2.3 KB)
MD5
4dab0ec5bc93c00ee43ba4a4571edfde
SHA1
732c956f69b828de457a9f74354a070b48dd26e0
SHA256
98a9480b9452a454ac874e74750735887e4b54ea6a489fc32fa830b00392ac7b
SHA512

      
    
SHA1_git
1bcbe1f2f603aed59e0a1061ee0dae6b1928c609
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestMessageDigestCredentialHandler.java | 2.3 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.catalina.realm; import java.security.NoSuchAlgorithmException; import org.junit.Assert; import org.junit.Test; import org.apache.tomcat.util.security.ConcurrentMessageDigest; public class TestMessageDigestCredentialHandler { private static final String[] DIGESTS = new String[] {"MD5", "SHA-1", "SHA-512"}; private static final String PWD = "password"; static { try { ConcurrentMessageDigest.init("SHA-512"); } catch (NoSuchAlgorithmException e) { throw new IllegalArgumentException(e); } } @Test public void testGeneral() throws Exception { for (String digest : DIGESTS) { for (int saltLength = 0; saltLength < 20; saltLength++) { for (int iterations = 1; iterations < 100; iterations += 10) { doTest(digest, saltLength, iterations); } } } } private void doTest(String digest, int saltLength, int iterations) throws NoSuchAlgorithmException { MessageDigestCredentialHandler mdch = new MessageDigestCredentialHandler(); MessageDigestCredentialHandler verifier = new MessageDigestCredentialHandler(); mdch.setAlgorithm(digest); mdch.setIterations(iterations); mdch.setSaltLength(saltLength); verifier.setAlgorithm(digest); String storedCredential = mdch.mutate(PWD); Assert.assertTrue(verifier.matches(PWD, storedCredential)); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
48.18
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