Home | History | Annotate | Download | only in security
      1 /*
      2  * Copyright (C) 2009 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *     http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 package tests.security;
     17 
     18 import java.security.cert.CertPath;
     19 import java.security.cert.CertPathParameters;
     20 import java.security.cert.CertPathValidator;
     21 import java.security.cert.CertPathValidatorResult;
     22 import junit.framework.TestCase;
     23 
     24 public abstract class CertPathValidatorTest extends TestCase {
     25 
     26     private final String algorithmName;
     27 
     28 
     29     public CertPathValidatorTest(String algorithmName) {
     30         this.algorithmName = algorithmName;
     31     }
     32 
     33     public abstract CertPathParameters getParams();
     34     public abstract CertPath getCertPath();
     35     public abstract void validateResult(CertPathValidatorResult validatorResult);
     36 
     37     public void testCertPathValidator() throws Exception {
     38         CertPathValidator certPathValidator = CertPathValidator.getInstance(
     39                 algorithmName);
     40 
     41         CertPathValidatorResult validatorResult = certPathValidator.validate(
     42                 getCertPath(), getParams());
     43 
     44         validateResult(validatorResult);
     45     }
     46 
     47 
     48 }
     49