-
Bug
-
Resolution: Fixed
-
P3
-
None
-
None
-
b10
The general contract with Provider.Service.newInstance() is that the Provider.Service implementation must provide a public no-arg constructor. In some cases, like CertStore/Policy/Configuration/TerminalFactory, there needs to be a public one-arg constructor. This is controlled by the Provider.EngineDescription class.
The following Services:
GssApiMechanism.1.2.840.113554.1.2.2
GssApiMechanism.1.3.6.1.5.5.2
don't work because the EngineDescription that controls the GssApiMechanisms don't allow parameters:
Provider.java:
1331: addEngine("GssApiMechanism", false, null);
and thus there must be a public no-arg constructor. Looking at the jgss/SunProvider.java:
put("GssApiMechanism.1.2.840.113554.1.2.2",
"sun.security.jgss.krb5.Krb5MechFactory");
put("GssApiMechanism.1.3.6.1.5.5.2",
"sun.security.jgss.spnego.SpNegoMechFactory");
I see:
public final class Krb5MechFactory implements MechanismFactory {
public Krb5MechFactory(GSSCaller caller) {
}
public final class SpNegoMechFactory implements MechanismFactory {
public SpNegoMechFactory(GSSCaller caller) {
}
I realize that the GSSManager.getInstance() is probably what you would use to get these, but this does not follow the expected behavior of Provider.Service class.
public class NewInstance {
public static void main(String[] args) throws Exception {
Set<Provider.Service> p =
Security.getProvider("SunJGSS").getServices();
for (Provider.Service s : p) {
try {
s.newInstance(null);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: 1.2.840.113554.1.2.2, provider: SunJGSS, class: sun.security.jgss.krb5.Krb5MechFactory)
at java.security.Provider$Service.newInstance(Provider.java:1621)
at NewInstance.main(NewInstance.java:100)
Caused by: java.lang.NoSuchMethodException: sun.security.jgss.krb5.Krb5MechFactory.<init>()
at java.lang.Class.getConstructor0(Class.java:2967)
at java.lang.Class.getConstructor(Class.java:1811)
at java.security.Provider$Service.newInstance(Provider.java:1594)
... 1 more
java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: 1.3.6.1.5.5.2, provider: SunJGSS, class: sun.security.jgss.spnego.SpNegoMechFactory)
at java.security.Provider$Service.newInstance(Provider.java:1621)
at NewInstance.main(NewInstance.java:100)
Caused by: java.lang.NoSuchMethodException: sun.security.jgss.spnego.SpNegoMechFactory.<init>()
at java.lang.Class.getConstructor0(Class.java:2967)
at java.lang.Class.getConstructor(Class.java:1811)
at java.security.Provider$Service.newInstance(Provider.java:1594)
... 1 more
The following Services:
GssApiMechanism.1.2.840.113554.1.2.2
GssApiMechanism.1.3.6.1.5.5.2
don't work because the EngineDescription that controls the GssApiMechanisms don't allow parameters:
Provider.java:
1331: addEngine("GssApiMechanism", false, null);
and thus there must be a public no-arg constructor. Looking at the jgss/SunProvider.java:
put("GssApiMechanism.1.2.840.113554.1.2.2",
"sun.security.jgss.krb5.Krb5MechFactory");
put("GssApiMechanism.1.3.6.1.5.5.2",
"sun.security.jgss.spnego.SpNegoMechFactory");
I see:
public final class Krb5MechFactory implements MechanismFactory {
public Krb5MechFactory(GSSCaller caller) {
}
public final class SpNegoMechFactory implements MechanismFactory {
public SpNegoMechFactory(GSSCaller caller) {
}
I realize that the GSSManager.getInstance() is probably what you would use to get these, but this does not follow the expected behavior of Provider.Service class.
public class NewInstance {
public static void main(String[] args) throws Exception {
Set<Provider.Service> p =
Security.getProvider("SunJGSS").getServices();
for (Provider.Service s : p) {
try {
s.newInstance(null);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: 1.2.840.113554.1.2.2, provider: SunJGSS, class: sun.security.jgss.krb5.Krb5MechFactory)
at java.security.Provider$Service.newInstance(Provider.java:1621)
at NewInstance.main(NewInstance.java:100)
Caused by: java.lang.NoSuchMethodException: sun.security.jgss.krb5.Krb5MechFactory.<init>()
at java.lang.Class.getConstructor0(Class.java:2967)
at java.lang.Class.getConstructor(Class.java:1811)
at java.security.Provider$Service.newInstance(Provider.java:1594)
... 1 more
java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: 1.3.6.1.5.5.2, provider: SunJGSS, class: sun.security.jgss.spnego.SpNegoMechFactory)
at java.security.Provider$Service.newInstance(Provider.java:1621)
at NewInstance.main(NewInstance.java:100)
Caused by: java.lang.NoSuchMethodException: sun.security.jgss.spnego.SpNegoMechFactory.<init>()
at java.lang.Class.getConstructor0(Class.java:2967)
at java.lang.Class.getConstructor(Class.java:1811)
at java.security.Provider$Service.newInstance(Provider.java:1594)
... 1 more
- relates to
-
JDK-8039575 liberate two manual kerberos tests
-
- Closed
-
1.
|
add a comment to the NewInstance test |
|
Resolved | Weijun Wang |