8250246: Address reliance on default constructors in security libs

Reviewed-by: mullan
This commit is contained in:
Joe Darcy 2020-07-24 13:49:38 -07:00
parent 9b73fb125d
commit 5db58348f8
29 changed files with 170 additions and 25 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -60,6 +60,11 @@ import java.security.spec.AlgorithmParameterSpec;
public abstract class AlgorithmParameterGeneratorSpi {
/**
* Constructor for subclasses to call.
*/
public AlgorithmParameterGeneratorSpi() {}
/**
* Initializes this parameter generator for a certain size
* and source of randomness.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -50,6 +50,11 @@ import java.security.spec.InvalidParameterSpecException;
public abstract class AlgorithmParametersSpi {
/**
* Constructor for subclasses to call.
*/
public AlgorithmParametersSpi() {}
/**
* Initializes this parameters object using the parameters
* specified in {@code paramSpec}.

View File

@ -69,6 +69,11 @@ import java.security.spec.InvalidKeySpecException;
public abstract class KeyFactorySpi {
/**
* Constructor for subclasses to call.
*/
public KeyFactorySpi() {}
/**
* Generates a public key object from the provided key
* specification (key material).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -58,6 +58,11 @@ import java.security.spec.AlgorithmParameterSpec;
public abstract class KeyPairGeneratorSpi {
/**
* Constructor for subclasses to call.
*/
public KeyPairGeneratorSpi() {}
/**
* Initializes the key pair generator for a certain keysize, using
* the default parameter set.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -53,6 +53,11 @@ import javax.security.auth.callback.*;
public abstract class KeyStoreSpi {
/**
* Constructor for subclasses to call.
*/
public KeyStoreSpi() {}
/**
* Returns the key associated with the given alias, using the given
* password to recover it. The key must have been associated with

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -54,6 +54,11 @@ public abstract class MessageDigestSpi {
// for re-use in engineUpdate(ByteBuffer input)
private byte[] tempArray;
/**
* Constructor for subclasses to call.
*/
public MessageDigestSpi() {}
/**
* Returns the digest length in bytes.
*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -102,6 +102,11 @@ public abstract class PermissionCollection implements java.io.Serializable {
// when set, add will throw an exception.
private volatile boolean readOnly;
/**
* Constructor for subclasses to call.
*/
public PermissionCollection() {}
/**
* Adds a permission object to the current collection of permission objects.
*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -87,6 +87,11 @@ import sun.security.util.SecurityConstants;
public abstract class Policy {
/**
* Constructor for subclasses to call.
*/
public Policy() {}
/**
* A read-only empty PermissionCollection instance.
* @since 1.6

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -44,6 +44,11 @@ package java.security;
public abstract class PolicySpi {
/**
* Constructor for subclasses to call.
*/
public PolicySpi() {}
/**
* Check whether the policy has granted a Permission to a ProtectionDomain.
*

View File

@ -52,6 +52,11 @@ import sun.security.jca.JCAUtil;
public abstract class SignatureSpi {
/**
* Constructor for subclasses to call.
*/
public SignatureSpi() {}
/**
* Application-specified source of randomness.
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -65,6 +65,11 @@ import java.security.NoSuchProviderException;
public abstract class CertificateFactorySpi {
/**
* Constructor for subclasses to call.
*/
public CertificateFactorySpi() {}
/**
* Generates a certificate object and initializes it with
* the data read from the input stream {@code inStream}.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -67,6 +67,11 @@ import sun.security.x509.X509CRLEntryImpl;
public abstract class X509CRLEntry implements X509Extension {
/**
* Constructor for subclasses to call.
*/
public X509CRLEntry() {}
/**
* Compares this CRL entry for equality with the given
* object. If the {@code other} object is an

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -229,6 +229,11 @@ import java.nio.ByteBuffer;
public abstract class CipherSpi {
/**
* Constructor for subclasses to call.
*/
public CipherSpi() {}
/**
* Sets the mode of this cipher.
*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -45,6 +45,11 @@ import java.security.spec.AlgorithmParameterSpec;
public abstract class ExemptionMechanismSpi {
/**
* Constructor for subclasses to call.
*/
public ExemptionMechanismSpi() {}
/**
* Returns the length in bytes that an output buffer would need to be in
* order to hold the result of the next

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -62,6 +62,11 @@ import java.security.spec.*;
public abstract class KeyAgreementSpi {
/**
* Constructor for subclasses to call.
*/
public KeyAgreementSpi() {}
/**
* Initializes this key agreement with the given key and source of
* randomness. The given key is required to contain all the algorithm

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -55,6 +55,11 @@ import java.security.spec.*;
public abstract class KeyGeneratorSpi {
/**
* Constructor for subclasses to call.
*/
public KeyGeneratorSpi() {}
/**
* Initializes the key generator.
*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -46,6 +46,11 @@ import java.nio.ByteBuffer;
public abstract class MacSpi {
/**
* Constructor for subclasses to call.
*/
public MacSpi() {}
/**
* Returns the length of the MAC in bytes.
*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -53,6 +53,11 @@ import java.security.spec.*;
public abstract class SecretKeyFactorySpi {
/**
* Constructor for subclasses to call.
*/
public SecretKeyFactorySpi() {}
/**
* Generates a <code>SecretKey</code> object from the
* provided key specification (key material).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -43,6 +43,11 @@ package javax.security.auth.login;
*/
public abstract class ConfigurationSpi {
/**
* Constructor for subclasses to call.
*/
public ConfigurationSpi() {}
/**
* Retrieve the AppConfigurationEntries for the specified {@code name}.
*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -65,6 +65,11 @@ import java.security.SignatureException;
@Deprecated(since="9", forRemoval=true)
public abstract class Certificate {
/**
* Constructor for subclasses to call.
*/
public Certificate() {}
/**
* Compares this certificate for equality with the specified
* object. If the {@code other} object is an

View File

@ -130,6 +130,11 @@ import java.util.Date;
@Deprecated(since="9", forRemoval=true)
public abstract class X509Certificate extends Certificate {
/**
* Constructor for subclasses to call.
*/
public X509Certificate() {}
/**
* Constant to lookup in the Security properties file.
* In the Security properties file the default implementation

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -138,6 +138,11 @@ import java.security.Provider;
*/
public abstract class GSSManager {
/**
* Constructor for subclasses to call.
*/
public GSSManager() {}
/**
* Returns the default GSSManager implementation.
*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -195,6 +195,11 @@ public class JndiLoginModule implements LoginModule {
private static final String NAME = "javax.security.auth.login.name";
private static final String PWD = "javax.security.auth.login.password";
/**
* Creates a {@code JndiLoginModule}.
*/
public JndiLoginModule() {}
/**
* Initialize this {@code LoginModule}.
*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -162,6 +162,11 @@ public class KeyStoreLoginModule implements LoginModule {
private boolean token = false;
private boolean protectedPath = false;
/**
* Creates a {@code KeyStoreLoginModule}.
*/
public KeyStoreLoginModule() {}
/* -- Methods -- */
/**

View File

@ -419,6 +419,11 @@ public class Krb5LoginModule implements LoginModule {
private static final String NAME = "javax.security.auth.login.name";
private static final String PWD = "javax.security.auth.login.password";
/**
* Creates a {@code Krb5LoginModule}.
*/
public Krb5LoginModule() {}
/**
* Initialize this {@code LoginModule}.
*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -355,6 +355,11 @@ public class LdapLoginModule implements LoginModule {
private Hashtable<String, Object> ldapEnvironment;
private SearchControls constraints = null;
/**
* Creates an {@code LdapLoginModule}.
*/
public LdapLoginModule() {}
/**
* Initialize this {@code LoginModule}.
*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -83,6 +83,11 @@ public class NTLoginModule implements LoginModule {
private NTSidGroupPrincipal[] groups; // supplementary groups
private NTNumericCredential iToken; // impersonation token
/**
* Creates an {@code NTLoginModule}.
*/
public NTLoginModule() {}
/**
* Initialize this {@code LoginModule}.
*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -72,6 +72,11 @@ public class UnixLoginModule implements LoginModule {
private LinkedList<UnixNumericGroupPrincipal> supplementaryGroups =
new LinkedList<>();
/**
* Creates a {@code UnixLoginModule}.
*/
public UnixLoginModule() {}
/**
* Initialize this {@code LoginModule}.
*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -34,6 +34,11 @@ import org.ietf.jgss.GSSCredential;
* implementation of Java GSS-API.
*/
public class GSSUtil {
/**
* Do not call.
*/
@Deprecated(since="16", forRemoval=true)
public GSSUtil() {}
/**
* Use this method to convert a GSSName and GSSCredential into a