jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXTimestampParameters.java
changeset 43910 cff79c8819dd
parent 43909 56f021844230
parent 43907 de9c439b9ab1
child 43913 ace20ac79fcf
equal deleted inserted replaced
43909:56f021844230 43910:cff79c8819dd
     1 /*
       
     2  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.  Oracle designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Oracle in the LICENSE file that accompanied this code.
       
    10  *
       
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14  * version 2 for more details (a copy is included in the LICENSE file that
       
    15  * accompanied this code).
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License version
       
    18  * 2 along with this work; if not, write to the Free Software Foundation,
       
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20  *
       
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    22  * or visit www.oracle.com if you need additional information or have any
       
    23  * questions.
       
    24  */
       
    25 
       
    26 
       
    27 package sun.security.provider.certpath;
       
    28 
       
    29 import java.security.InvalidAlgorithmParameterException;
       
    30 import java.security.Timestamp;
       
    31 import java.security.cert.CertSelector;
       
    32 import java.security.cert.CertStore;
       
    33 import java.security.cert.PKIXBuilderParameters;
       
    34 import java.security.cert.PKIXCertPathChecker;
       
    35 import java.security.cert.TrustAnchor;
       
    36 import java.util.Date;
       
    37 import java.util.List;
       
    38 import java.util.Set;
       
    39 
       
    40 /**
       
    41  * This class is a wrapper for PKIXBuilderParameters so that a Timestamp object
       
    42  * can be passed alone when PKIXCertPath is checking signed jar files.
       
    43  */
       
    44 
       
    45 public class PKIXTimestampParameters extends PKIXBuilderParameters {
       
    46 
       
    47     private final PKIXBuilderParameters p;
       
    48     private Timestamp jarTimestamp;
       
    49 
       
    50     public PKIXTimestampParameters(PKIXBuilderParameters params,
       
    51             Timestamp timestamp) throws InvalidAlgorithmParameterException {
       
    52         super(params.getTrustAnchors(), null);
       
    53         p = params;
       
    54         jarTimestamp = timestamp;
       
    55     }
       
    56 
       
    57     public Timestamp getTimestamp() {
       
    58         return jarTimestamp;
       
    59     }
       
    60     public void setTimestamp(Timestamp t) {
       
    61         jarTimestamp = t;
       
    62     }
       
    63 
       
    64     @Override
       
    65     public void setDate(Date d) {
       
    66         p.setDate(d);
       
    67     }
       
    68 
       
    69     @Override
       
    70     public void addCertPathChecker(PKIXCertPathChecker c) {
       
    71         p.addCertPathChecker(c);
       
    72     }
       
    73 
       
    74     @Override
       
    75     public void setMaxPathLength(int maxPathLength) {
       
    76         p.setMaxPathLength(maxPathLength);
       
    77     }
       
    78 
       
    79     @Override
       
    80     public int getMaxPathLength() {
       
    81         return p.getMaxPathLength();
       
    82     }
       
    83 
       
    84     @Override
       
    85     public String toString() {
       
    86         return p.toString();
       
    87     }
       
    88 
       
    89     @Override
       
    90     public Set<TrustAnchor> getTrustAnchors() {
       
    91         return p.getTrustAnchors();
       
    92     }
       
    93 
       
    94     @Override
       
    95     public void setTrustAnchors(Set<TrustAnchor> trustAnchors)
       
    96             throws InvalidAlgorithmParameterException {
       
    97         // To avoid problems with PKIXBuilderParameter's constructors
       
    98         if (p == null) {
       
    99             return;
       
   100         }
       
   101         p.setTrustAnchors(trustAnchors);
       
   102     }
       
   103 
       
   104     @Override
       
   105     public Set<String> getInitialPolicies() {
       
   106         return p.getInitialPolicies();
       
   107     }
       
   108 
       
   109     @Override
       
   110     public void setInitialPolicies(Set<String> initialPolicies) {
       
   111         p.setInitialPolicies(initialPolicies);
       
   112     }
       
   113 
       
   114     @Override
       
   115     public void setCertStores(List<CertStore> stores) {
       
   116         p.setCertStores(stores);
       
   117     }
       
   118 
       
   119     @Override
       
   120     public void addCertStore(CertStore store) {
       
   121         p.addCertStore(store);
       
   122     }
       
   123 
       
   124     @Override
       
   125     public List<CertStore> getCertStores() {
       
   126         return p.getCertStores();
       
   127     }
       
   128 
       
   129     @Override
       
   130     public void setRevocationEnabled(boolean val) {
       
   131         p.setRevocationEnabled(val);
       
   132     }
       
   133 
       
   134     @Override
       
   135     public boolean isRevocationEnabled() {
       
   136         return p.isRevocationEnabled();
       
   137     }
       
   138 
       
   139     @Override
       
   140     public void setExplicitPolicyRequired(boolean val) {
       
   141         p.setExplicitPolicyRequired(val);
       
   142     }
       
   143 
       
   144     @Override
       
   145     public boolean isExplicitPolicyRequired() {
       
   146         return p.isExplicitPolicyRequired();
       
   147     }
       
   148 
       
   149     @Override
       
   150     public void setPolicyMappingInhibited(boolean val) {
       
   151         p.setPolicyMappingInhibited(val);
       
   152     }
       
   153 
       
   154     @Override
       
   155     public boolean isPolicyMappingInhibited() {
       
   156         return p.isPolicyMappingInhibited();
       
   157     }
       
   158 
       
   159     @Override
       
   160     public void setAnyPolicyInhibited(boolean val) {
       
   161         p.setAnyPolicyInhibited(val);
       
   162     }
       
   163 
       
   164     @Override
       
   165     public boolean isAnyPolicyInhibited() {
       
   166         return p.isAnyPolicyInhibited();
       
   167     }
       
   168 
       
   169     @Override
       
   170     public void setPolicyQualifiersRejected(boolean qualifiersRejected) {
       
   171         p.setPolicyQualifiersRejected(qualifiersRejected);
       
   172     }
       
   173 
       
   174     @Override
       
   175     public boolean getPolicyQualifiersRejected() {
       
   176         return p.getPolicyQualifiersRejected();
       
   177     }
       
   178 
       
   179     @Override
       
   180     public Date getDate() {
       
   181         return p.getDate();
       
   182     }
       
   183 
       
   184     @Override
       
   185     public void setCertPathCheckers(List<PKIXCertPathChecker> checkers) {
       
   186         p.setCertPathCheckers(checkers);
       
   187     }
       
   188 
       
   189     @Override
       
   190     public List<PKIXCertPathChecker> getCertPathCheckers() {
       
   191         return p.getCertPathCheckers();
       
   192     }
       
   193 
       
   194     @Override
       
   195     public String getSigProvider() {
       
   196         return p.getSigProvider();
       
   197     }
       
   198 
       
   199     @Override
       
   200     public void setSigProvider(String sigProvider) {
       
   201         p.setSigProvider(sigProvider);
       
   202     }
       
   203 
       
   204     @Override
       
   205     public CertSelector getTargetCertConstraints() {
       
   206         return p.getTargetCertConstraints();
       
   207     }
       
   208 
       
   209     @Override
       
   210     public void setTargetCertConstraints(CertSelector selector) {
       
   211         // To avoid problems with PKIXBuilderParameter's constructors
       
   212         if (p == null) {
       
   213             return;
       
   214         }
       
   215         p.setTargetCertConstraints(selector);
       
   216     }
       
   217 
       
   218 }