< prev index next >
src/java.base/share/classes/java/security/cert/PKIXParameters.java
Print this page
*** 118,129 ****
throws InvalidAlgorithmParameterException
{
setTrustAnchors(trustAnchors);
this.unmodInitialPolicies = Collections.<String>emptySet();
! this.certPathCheckers = new ArrayList<PKIXCertPathChecker>();
! this.certStores = new ArrayList<CertStore>();
}
/**
* Creates an instance of {@code PKIXParameters} that
* populates the set of most-trusted CAs from the trusted
--- 118,129 ----
throws InvalidAlgorithmParameterException
{
setTrustAnchors(trustAnchors);
this.unmodInitialPolicies = Collections.<String>emptySet();
! this.certPathCheckers = new ArrayList<>();
! this.certStores = new ArrayList<>();
}
/**
* Creates an instance of {@code PKIXParameters} that
* populates the set of most-trusted CAs from the trusted
*** 142,152 ****
throws KeyStoreException, InvalidAlgorithmParameterException
{
if (keystore == null)
throw new NullPointerException("the keystore parameter must be " +
"non-null");
! Set<TrustAnchor> hashSet = new HashSet<TrustAnchor>();
Enumeration<String> aliases = keystore.aliases();
while (aliases.hasMoreElements()) {
String alias = aliases.nextElement();
if (keystore.isCertificateEntry(alias)) {
Certificate cert = keystore.getCertificate(alias);
--- 142,152 ----
throws KeyStoreException, InvalidAlgorithmParameterException
{
if (keystore == null)
throw new NullPointerException("the keystore parameter must be " +
"non-null");
! Set<TrustAnchor> hashSet = new HashSet<>();
Enumeration<String> aliases = keystore.aliases();
while (aliases.hasMoreElements()) {
String alias = aliases.nextElement();
if (keystore.isCertificateEntry(alias)) {
Certificate cert = keystore.getCertificate(alias);
*** 154,165 ****
hashSet.add(new TrustAnchor((X509Certificate)cert, null));
}
}
setTrustAnchors(hashSet);
this.unmodInitialPolicies = Collections.<String>emptySet();
! this.certPathCheckers = new ArrayList<PKIXCertPathChecker>();
! this.certStores = new ArrayList<CertStore>();
}
/**
* Returns an immutable {@code Set} of the most-trusted
* CAs.
--- 154,165 ----
hashSet.add(new TrustAnchor((X509Certificate)cert, null));
}
}
setTrustAnchors(hashSet);
this.unmodInitialPolicies = Collections.<String>emptySet();
! this.certPathCheckers = new ArrayList<>();
! this.certStores = new ArrayList<>();
}
/**
* Returns an immutable {@code Set} of the most-trusted
* CAs.
*** 205,215 ****
throw new ClassCastException("all elements of set must be "
+ "of type java.security.cert.TrustAnchor");
}
}
this.unmodTrustAnchors = Collections.unmodifiableSet
! (new HashSet<TrustAnchor>(trustAnchors));
}
/**
* Returns an immutable {@code Set} of initial
* policy identifiers (OID strings), indicating that any one of these
--- 205,215 ----
throw new ClassCastException("all elements of set must be "
+ "of type java.security.cert.TrustAnchor");
}
}
this.unmodTrustAnchors = Collections.unmodifiableSet
! (new HashSet<>(trustAnchors));
}
/**
* Returns an immutable {@code Set} of initial
* policy identifiers (OID strings), indicating that any one of these
*** 254,264 ****
if (!(i.next() instanceof String))
throw new ClassCastException("all elements of set must be "
+ "of type java.lang.String");
}
this.unmodInitialPolicies =
! Collections.unmodifiableSet(new HashSet<String>(initialPolicies));
} else
this.unmodInitialPolicies = Collections.<String>emptySet();
}
/**
--- 254,264 ----
if (!(i.next() instanceof String))
throw new ClassCastException("all elements of set must be "
+ "of type java.lang.String");
}
this.unmodInitialPolicies =
! Collections.unmodifiableSet(new HashSet<>(initialPolicies));
} else
this.unmodInitialPolicies = Collections.<String>emptySet();
}
/**
*** 278,296 ****
*
* @see #getCertStores
*/
public void setCertStores(List<CertStore> stores) {
if (stores == null) {
! this.certStores = new ArrayList<CertStore>();
} else {
for (Iterator<CertStore> i = stores.iterator(); i.hasNext();) {
if (!(i.next() instanceof CertStore)) {
throw new ClassCastException("all elements of list must be "
+ "of type java.security.cert.CertStore");
}
}
! this.certStores = new ArrayList<CertStore>(stores);
}
}
/**
* Adds a {@code CertStore} to the end of the list of
--- 278,296 ----
*
* @see #getCertStores
*/
public void setCertStores(List<CertStore> stores) {
if (stores == null) {
! this.certStores = new ArrayList<>();
} else {
for (Iterator<CertStore> i = stores.iterator(); i.hasNext();) {
if (!(i.next() instanceof CertStore)) {
throw new ClassCastException("all elements of list must be "
+ "of type java.security.cert.CertStore");
}
}
! this.certStores = new ArrayList<>(stores);
}
}
/**
* Adds a {@code CertStore} to the end of the list of
*** 314,324 ****
*
* @see #setCertStores
*/
public List<CertStore> getCertStores() {
return Collections.unmodifiableList
! (new ArrayList<CertStore>(this.certStores));
}
/**
* Sets the RevocationEnabled flag. If this flag is true, the default
* revocation checking mechanism of the underlying PKIX service provider
--- 314,324 ----
*
* @see #setCertStores
*/
public List<CertStore> getCertStores() {
return Collections.unmodifiableList
! (new ArrayList<>(this.certStores));
}
/**
* Sets the RevocationEnabled flag. If this flag is true, the default
* revocation checking mechanism of the underlying PKIX service provider
*** 542,559 ****
* are not of type {@code java.security.cert.PKIXCertPathChecker}
* @see #getCertPathCheckers
*/
public void setCertPathCheckers(List<PKIXCertPathChecker> checkers) {
if (checkers != null) {
! List<PKIXCertPathChecker> tmpList =
! new ArrayList<PKIXCertPathChecker>();
for (PKIXCertPathChecker checker : checkers) {
tmpList.add((PKIXCertPathChecker)checker.clone());
}
this.certPathCheckers = tmpList;
} else {
! this.certPathCheckers = new ArrayList<PKIXCertPathChecker>();
}
}
/**
* Returns the {@code List} of certification path checkers.
--- 542,558 ----
* are not of type {@code java.security.cert.PKIXCertPathChecker}
* @see #getCertPathCheckers
*/
public void setCertPathCheckers(List<PKIXCertPathChecker> checkers) {
if (checkers != null) {
! List<PKIXCertPathChecker> tmpList = new ArrayList<>();
for (PKIXCertPathChecker checker : checkers) {
tmpList.add((PKIXCertPathChecker)checker.clone());
}
this.certPathCheckers = tmpList;
} else {
! this.certPathCheckers = new ArrayList<>();
}
}
/**
* Returns the {@code List} of certification path checkers.
*** 565,575 ****
* {@code PKIXCertPathChecker}s (may be empty, but not
* {@code null})
* @see #setCertPathCheckers
*/
public List<PKIXCertPathChecker> getCertPathCheckers() {
! List<PKIXCertPathChecker> tmpList = new ArrayList<PKIXCertPathChecker>();
for (PKIXCertPathChecker ck : certPathCheckers) {
tmpList.add((PKIXCertPathChecker)ck.clone());
}
return Collections.unmodifiableList(tmpList);
}
--- 564,574 ----
* {@code PKIXCertPathChecker}s (may be empty, but not
* {@code null})
* @see #setCertPathCheckers
*/
public List<PKIXCertPathChecker> getCertPathCheckers() {
! List<PKIXCertPathChecker> tmpList = new ArrayList<>();
for (PKIXCertPathChecker ck : certPathCheckers) {
tmpList.add((PKIXCertPathChecker)ck.clone());
}
return Collections.unmodifiableList(tmpList);
}
*** 665,679 ****
try {
PKIXParameters copy = (PKIXParameters)super.clone();
// must clone these because addCertStore, et al. modify them
if (certStores != null) {
! copy.certStores = new ArrayList<CertStore>(certStores);
}
if (certPathCheckers != null) {
copy.certPathCheckers =
! new ArrayList<PKIXCertPathChecker>(certPathCheckers.size());
for (PKIXCertPathChecker checker : certPathCheckers) {
copy.certPathCheckers.add(
(PKIXCertPathChecker)checker.clone());
}
}
--- 664,678 ----
try {
PKIXParameters copy = (PKIXParameters)super.clone();
// must clone these because addCertStore, et al. modify them
if (certStores != null) {
! copy.certStores = new ArrayList<>(certStores);
}
if (certPathCheckers != null) {
copy.certPathCheckers =
! new ArrayList<>(certPathCheckers.size());
for (PKIXCertPathChecker checker : certPathCheckers) {
copy.certPathCheckers.add(
(PKIXCertPathChecker)checker.clone());
}
}
< prev index next >