Path: blob/master/src/java.base/share/classes/sun/security/provider/certpath/PKIXExtendedParameters.java
41161 views
/*1* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/242526package sun.security.provider.certpath;2728import java.security.InvalidAlgorithmParameterException;29import java.security.Timestamp;30import java.security.cert.CertSelector;31import java.security.cert.CertStore;32import java.security.cert.PKIXBuilderParameters;33import java.security.cert.PKIXCertPathChecker;34import java.security.cert.TrustAnchor;35import java.util.Date;36import java.util.List;37import java.util.Set;3839/**40* This class is a wrapper for PKIXBuilderParameters so that a Timestamp object41* and a string for the variant type, can be passed when doing certpath42* checking.43*/4445public class PKIXExtendedParameters extends PKIXBuilderParameters {4647private final PKIXBuilderParameters p;48private Timestamp jarTimestamp;49private final String variant;5051public PKIXExtendedParameters(PKIXBuilderParameters params,52Timestamp timestamp, String variant)53throws InvalidAlgorithmParameterException {54super(params.getTrustAnchors(), null);55p = params;56jarTimestamp = timestamp;57this.variant = variant;58}5960public Timestamp getTimestamp() {61return jarTimestamp;62}63public void setTimestamp(Timestamp t) {64jarTimestamp = t;65}6667public String getVariant() {68return variant;69}7071@Override72public void setDate(Date d) {73p.setDate(d);74}7576@Override77public void addCertPathChecker(PKIXCertPathChecker c) {78p.addCertPathChecker(c);79}8081@Override82public void setMaxPathLength(int maxPathLength) {83p.setMaxPathLength(maxPathLength);84}8586@Override87public int getMaxPathLength() {88return p.getMaxPathLength();89}9091@Override92public String toString() {93return p.toString();94}9596@Override97public Set<TrustAnchor> getTrustAnchors() {98return p.getTrustAnchors();99}100101@Override102public void setTrustAnchors(Set<TrustAnchor> trustAnchors)103throws InvalidAlgorithmParameterException {104// To avoid problems with PKIXBuilderParameter's constructors105if (p == null) {106return;107}108p.setTrustAnchors(trustAnchors);109}110111@Override112public Set<String> getInitialPolicies() {113return p.getInitialPolicies();114}115116@Override117public void setInitialPolicies(Set<String> initialPolicies) {118p.setInitialPolicies(initialPolicies);119}120121@Override122public void setCertStores(List<CertStore> stores) {123p.setCertStores(stores);124}125126@Override127public void addCertStore(CertStore store) {128p.addCertStore(store);129}130131@Override132public List<CertStore> getCertStores() {133return p.getCertStores();134}135136@Override137public void setRevocationEnabled(boolean val) {138p.setRevocationEnabled(val);139}140141@Override142public boolean isRevocationEnabled() {143return p.isRevocationEnabled();144}145146@Override147public void setExplicitPolicyRequired(boolean val) {148p.setExplicitPolicyRequired(val);149}150151@Override152public boolean isExplicitPolicyRequired() {153return p.isExplicitPolicyRequired();154}155156@Override157public void setPolicyMappingInhibited(boolean val) {158p.setPolicyMappingInhibited(val);159}160161@Override162public boolean isPolicyMappingInhibited() {163return p.isPolicyMappingInhibited();164}165166@Override167public void setAnyPolicyInhibited(boolean val) {168p.setAnyPolicyInhibited(val);169}170171@Override172public boolean isAnyPolicyInhibited() {173return p.isAnyPolicyInhibited();174}175176@Override177public void setPolicyQualifiersRejected(boolean qualifiersRejected) {178p.setPolicyQualifiersRejected(qualifiersRejected);179}180181@Override182public boolean getPolicyQualifiersRejected() {183return p.getPolicyQualifiersRejected();184}185186@Override187public Date getDate() {188return p.getDate();189}190191@Override192public void setCertPathCheckers(List<PKIXCertPathChecker> checkers) {193p.setCertPathCheckers(checkers);194}195196@Override197public List<PKIXCertPathChecker> getCertPathCheckers() {198return p.getCertPathCheckers();199}200201@Override202public String getSigProvider() {203return p.getSigProvider();204}205206@Override207public void setSigProvider(String sigProvider) {208p.setSigProvider(sigProvider);209}210211@Override212public CertSelector getTargetCertConstraints() {213return p.getTargetCertConstraints();214}215216@Override217public void setTargetCertConstraints(CertSelector selector) {218// To avoid problems with PKIXBuilderParameter's constructors219if (p == null) {220return;221}222p.setTargetCertConstraints(selector);223}224225}226227228