Home | History | Annotate | Download | only in utils
      1 /*
      2  * Copyright (C) 2014 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 
     17 package org.apache.harmony.security.utils;
     18 
     19 import java.math.BigInteger;
     20 import java.security.InvalidKeyException;
     21 import java.security.NoSuchAlgorithmException;
     22 import java.security.NoSuchProviderException;
     23 import java.security.Principal;
     24 import java.security.PublicKey;
     25 import java.security.SignatureException;
     26 import java.security.cert.CertificateEncodingException;
     27 import java.security.cert.CertificateException;
     28 import java.security.cert.CertificateExpiredException;
     29 import java.security.cert.CertificateNotYetValidException;
     30 import java.security.cert.X509Certificate;
     31 import java.util.Date;
     32 import java.util.Set;
     33 
     34 public class WrappedX509Certificate extends X509Certificate {
     35     private final X509Certificate wrapped;
     36 
     37     public WrappedX509Certificate(X509Certificate wrapped) {
     38         this.wrapped = wrapped;
     39     }
     40 
     41     @Override
     42     public Set<String> getCriticalExtensionOIDs() {
     43         return wrapped.getCriticalExtensionOIDs();
     44     }
     45 
     46     @Override
     47     public byte[] getExtensionValue(String oid) {
     48         return wrapped.getExtensionValue(oid);
     49     }
     50 
     51     @Override
     52     public Set<String> getNonCriticalExtensionOIDs() {
     53         return wrapped.getNonCriticalExtensionOIDs();
     54     }
     55 
     56     @Override
     57     public boolean hasUnsupportedCriticalExtension() {
     58         return wrapped.hasUnsupportedCriticalExtension();
     59     }
     60 
     61     @Override
     62     public void checkValidity() throws CertificateExpiredException,
     63             CertificateNotYetValidException {
     64         wrapped.checkValidity();
     65     }
     66 
     67     @Override
     68     public void checkValidity(Date date) throws CertificateExpiredException,
     69             CertificateNotYetValidException {
     70         wrapped.checkValidity(date);
     71     }
     72 
     73     @Override
     74     public int getVersion() {
     75         return wrapped.getVersion();
     76     }
     77 
     78     @Override
     79     public BigInteger getSerialNumber() {
     80         return wrapped.getSerialNumber();
     81     }
     82 
     83     @Override
     84     public Principal getIssuerDN() {
     85         return wrapped.getIssuerDN();
     86     }
     87 
     88     @Override
     89     public Principal getSubjectDN() {
     90         return wrapped.getSubjectDN();
     91     }
     92 
     93     @Override
     94     public Date getNotBefore() {
     95         return wrapped.getNotBefore();
     96     }
     97 
     98     @Override
     99     public Date getNotAfter() {
    100         return wrapped.getNotAfter();
    101     }
    102 
    103     @Override
    104     public byte[] getTBSCertificate() throws CertificateEncodingException {
    105         return wrapped.getTBSCertificate();
    106     }
    107 
    108     @Override
    109     public byte[] getSignature() {
    110         return wrapped.getSignature();
    111     }
    112 
    113     @Override
    114     public String getSigAlgName() {
    115         return wrapped.getSigAlgName();
    116     }
    117 
    118     @Override
    119     public String getSigAlgOID() {
    120         return wrapped.getSigAlgOID();
    121     }
    122 
    123     @Override
    124     public byte[] getSigAlgParams() {
    125         return wrapped.getSigAlgParams();
    126     }
    127 
    128     @Override
    129     public boolean[] getIssuerUniqueID() {
    130         return wrapped.getIssuerUniqueID();
    131     }
    132 
    133     @Override
    134     public boolean[] getSubjectUniqueID() {
    135         return wrapped.getSubjectUniqueID();
    136     }
    137 
    138     @Override
    139     public boolean[] getKeyUsage() {
    140         return wrapped.getKeyUsage();
    141     }
    142 
    143     @Override
    144     public int getBasicConstraints() {
    145         return wrapped.getBasicConstraints();
    146     }
    147 
    148     @Override
    149     public byte[] getEncoded() throws CertificateEncodingException {
    150         return wrapped.getEncoded();
    151     }
    152 
    153     @Override
    154     public void verify(PublicKey key) throws CertificateException, NoSuchAlgorithmException,
    155             InvalidKeyException, NoSuchProviderException, SignatureException {
    156         wrapped.verify(key);
    157     }
    158 
    159     @Override
    160     public void verify(PublicKey key, String sigProvider) throws CertificateException,
    161             NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException,
    162             SignatureException {
    163         wrapped.verify(key, sigProvider);
    164     }
    165 
    166     @Override
    167     public String toString() {
    168         return wrapped.toString();
    169     }
    170 
    171     @Override
    172     public PublicKey getPublicKey() {
    173         return wrapped.getPublicKey();
    174     }
    175 }
    176