Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
halo
rockchip_libcore
Commits
8ae047f5
Commit
8ae047f5
authored
14 years ago
by
Brian Carlstrom
Committed by
Android (Google) Code Review
14 years ago
Browse files
Options
Download
Plain Diff
Merge "Change Engine.getInstance interfaces to make usage less error prone"
parents
490a5fc2
6cdb6b7e
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
129 additions
and
237 deletions
+129
-237
luni/src/main/java/java/security/AlgorithmParameterGenerator.java
.../main/java/java/security/AlgorithmParameterGenerator.java
+6
-11
luni/src/main/java/java/security/AlgorithmParameters.java
luni/src/main/java/java/security/AlgorithmParameters.java
+4
-10
luni/src/main/java/java/security/KeyFactory.java
luni/src/main/java/java/security/KeyFactory.java
+4
-8
luni/src/main/java/java/security/KeyPairGenerator.java
luni/src/main/java/java/security/KeyPairGenerator.java
+4
-12
luni/src/main/java/java/security/KeyStore.java
luni/src/main/java/java/security/KeyStore.java
+9
-13
luni/src/main/java/java/security/MessageDigest.java
luni/src/main/java/java/security/MessageDigest.java
+5
-13
luni/src/main/java/java/security/Policy.java
luni/src/main/java/java/security/Policy.java
+4
-11
luni/src/main/java/java/security/SecureRandom.java
luni/src/main/java/java/security/SecureRandom.java
+5
-9
luni/src/main/java/java/security/Signature.java
luni/src/main/java/java/security/Signature.java
+4
-12
luni/src/main/java/java/security/cert/CertPathBuilder.java
luni/src/main/java/java/security/cert/CertPathBuilder.java
+4
-9
luni/src/main/java/java/security/cert/CertPathValidator.java
luni/src/main/java/java/security/cert/CertPathValidator.java
+4
-10
luni/src/main/java/java/security/cert/CertStore.java
luni/src/main/java/java/security/cert/CertStore.java
+4
-10
luni/src/main/java/java/security/cert/CertificateFactory.java
.../src/main/java/java/security/cert/CertificateFactory.java
+4
-10
luni/src/main/java/javax/crypto/Cipher.java
luni/src/main/java/javax/crypto/Cipher.java
+44
-41
luni/src/main/java/javax/crypto/ExemptionMechanism.java
luni/src/main/java/javax/crypto/ExemptionMechanism.java
+4
-10
luni/src/main/java/javax/crypto/KeyAgreement.java
luni/src/main/java/javax/crypto/KeyAgreement.java
+4
-10
luni/src/main/java/javax/crypto/KeyGenerator.java
luni/src/main/java/javax/crypto/KeyGenerator.java
+4
-10
luni/src/main/java/javax/crypto/Mac.java
luni/src/main/java/javax/crypto/Mac.java
+4
-8
luni/src/main/java/javax/crypto/SecretKeyFactory.java
luni/src/main/java/javax/crypto/SecretKeyFactory.java
+4
-10
luni/src/main/java/javax/net/ssl/KeyManagerFactory.java
luni/src/main/java/javax/net/ssl/KeyManagerFactory.java
+4
-10
No files found.
luni/src/main/java/java/security/AlgorithmParameterGenerator.java
View file @
8ae047f5
...
@@ -90,12 +90,9 @@ public class AlgorithmParameterGenerator {
...
@@ -90,12 +90,9 @@ public class AlgorithmParameterGenerator {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
synchronized
(
ENGINE
)
{
Engine
.
SpiAndProvider
sap
=
ENGINE
.
getInstance
(
algorithm
,
null
);
ENGINE
.
getInstance
(
algorithm
,
null
);
return
new
AlgorithmParameterGenerator
((
AlgorithmParameterGeneratorSpi
)
sap
.
spi
,
return
new
AlgorithmParameterGenerator
(
sap
.
provider
,
algorithm
);
(
AlgorithmParameterGeneratorSpi
)
ENGINE
.
getSpi
(),
ENGINE
.
getProvider
(),
algorithm
);
}
}
}
/**
/**
...
@@ -154,11 +151,9 @@ public class AlgorithmParameterGenerator {
...
@@ -154,11 +151,9 @@ public class AlgorithmParameterGenerator {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
synchronized
(
ENGINE
)
{
Object
spi
=
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
return
new
AlgorithmParameterGenerator
((
AlgorithmParameterGeneratorSpi
)
spi
,
provider
,
return
new
AlgorithmParameterGenerator
(
algorithm
);
(
AlgorithmParameterGeneratorSpi
)
ENGINE
.
getSpi
(),
provider
,
algorithm
);
}
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
luni/src/main/java/java/security/AlgorithmParameters.java
View file @
8ae047f5
...
@@ -94,11 +94,8 @@ public class AlgorithmParameters {
...
@@ -94,11 +94,8 @@ public class AlgorithmParameters {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
synchronized
(
ENGINE
)
{
Engine
.
SpiAndProvider
sap
=
ENGINE
.
getInstance
(
algorithm
,
null
);
ENGINE
.
getInstance
(
algorithm
,
null
);
return
new
AlgorithmParameters
((
AlgorithmParametersSpi
)
sap
.
spi
,
sap
.
provider
,
algorithm
);
return
new
AlgorithmParameters
((
AlgorithmParametersSpi
)
ENGINE
.
getSpi
(),
ENGINE
.
getProvider
(),
algorithm
);
}
}
}
/**
/**
...
@@ -156,11 +153,8 @@ public class AlgorithmParameters {
...
@@ -156,11 +153,8 @@ public class AlgorithmParameters {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
synchronized
(
ENGINE
)
{
Object
spi
=
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
return
new
AlgorithmParameters
((
AlgorithmParametersSpi
)
spi
,
provider
,
algorithm
);
return
new
AlgorithmParameters
((
AlgorithmParametersSpi
)
ENGINE
.
getSpi
(),
provider
,
algorithm
);
}
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
luni/src/main/java/java/security/KeyFactory.java
View file @
8ae047f5
...
@@ -78,10 +78,8 @@ public class KeyFactory {
...
@@ -78,10 +78,8 @@ public class KeyFactory {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
synchronized
(
ENGINE
)
{
Engine
.
SpiAndProvider
sap
=
ENGINE
.
getInstance
(
algorithm
,
null
);
ENGINE
.
getInstance
(
algorithm
,
null
);
return
new
KeyFactory
((
KeyFactorySpi
)
sap
.
spi
,
sap
.
provider
,
algorithm
);
return
new
KeyFactory
((
KeyFactorySpi
)
ENGINE
.
getSpi
(),
ENGINE
.
getProvider
(),
algorithm
);
}
}
}
/**
/**
...
@@ -135,10 +133,8 @@ public class KeyFactory {
...
@@ -135,10 +133,8 @@ public class KeyFactory {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
synchronized
(
ENGINE
)
{
Object
spi
=
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
return
new
KeyFactory
((
KeyFactorySpi
)
spi
,
provider
,
algorithm
);
return
new
KeyFactory
((
KeyFactorySpi
)
ENGINE
.
getSpi
(),
provider
,
algorithm
);
}
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
luni/src/main/java/java/security/KeyPairGenerator.java
View file @
8ae047f5
...
@@ -82,13 +82,9 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
...
@@ -82,13 +82,9 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
Object
spi
;
Engine
.
SpiAndProvider
sap
=
ENGINE
.
getInstance
(
algorithm
,
null
);
Provider
provider
;
Object
spi
=
sap
.
spi
;
synchronized
(
ENGINE
)
{
Provider
provider
=
sap
.
provider
;
ENGINE
.
getInstance
(
algorithm
,
null
);
spi
=
ENGINE
.
getSpi
();
provider
=
ENGINE
.
getProvider
();
}
if
(
spi
instanceof
KeyPairGenerator
)
{
if
(
spi
instanceof
KeyPairGenerator
)
{
KeyPairGenerator
result
=
(
KeyPairGenerator
)
spi
;
KeyPairGenerator
result
=
(
KeyPairGenerator
)
spi
;
result
.
algorithm
=
algorithm
;
result
.
algorithm
=
algorithm
;
...
@@ -149,11 +145,7 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
...
@@ -149,11 +145,7 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
Object
spi
;
Object
spi
=
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
synchronized
(
ENGINE
)
{
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
spi
=
ENGINE
.
getSpi
();
}
if
(
spi
instanceof
KeyPairGenerator
)
{
if
(
spi
instanceof
KeyPairGenerator
)
{
KeyPairGenerator
result
=
(
KeyPairGenerator
)
spi
;
KeyPairGenerator
result
=
(
KeyPairGenerator
)
spi
;
result
.
algorithm
=
algorithm
;
result
.
algorithm
=
algorithm
;
...
...
This diff is collapsed.
Click to expand it.
luni/src/main/java/java/security/KeyStore.java
View file @
8ae047f5
...
@@ -111,13 +111,11 @@ public class KeyStore {
...
@@ -111,13 +111,11 @@ public class KeyStore {
if
(
type
==
null
)
{
if
(
type
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
synchronized
(
ENGINE
)
{
try
{
try
{
Engine
.
SpiAndProvider
sap
=
ENGINE
.
getInstance
(
type
,
null
);
ENGINE
.
getInstance
(
type
,
null
);
return
new
KeyStore
((
KeyStoreSpi
)
sap
.
spi
,
sap
.
provider
,
type
);
return
new
KeyStore
((
KeyStoreSpi
)
ENGINE
.
getSpi
(),
ENGINE
.
getProvider
(),
type
);
}
catch
(
NoSuchAlgorithmException
e
)
{
}
catch
(
NoSuchAlgorithmException
e
)
{
throw
new
KeyStoreException
(
e
.
getMessage
());
throw
new
KeyStoreException
(
e
.
getMessage
());
}
}
}
}
}
...
@@ -187,14 +185,12 @@ public class KeyStore {
...
@@ -187,14 +185,12 @@ public class KeyStore {
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
// return KeyStore instance
// return KeyStore instance
synchronized
(
ENGINE
)
{
try
{
try
{
Object
spi
=
ENGINE
.
getInstance
(
type
,
provider
,
null
);
ENGINE
.
getInstance
(
type
,
provider
,
null
);
return
new
KeyStore
((
KeyStoreSpi
)
spi
,
provider
,
type
);
return
new
KeyStore
((
KeyStoreSpi
)
ENGINE
.
getSpi
(),
provider
,
type
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
// override exception
// override exception
throw
new
KeyStoreException
(
e
.
getMessage
());
throw
new
KeyStoreException
(
e
.
getMessage
());
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
luni/src/main/java/java/security/MessageDigest.java
View file @
8ae047f5
...
@@ -88,20 +88,16 @@ public abstract class MessageDigest extends MessageDigestSpi {
...
@@ -88,20 +88,16 @@ public abstract class MessageDigest extends MessageDigestSpi {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
Object
spi
;
Engine
.
SpiAndProvider
sap
=
ENGINE
.
getInstance
(
algorithm
,
null
);
Provider
provider
;
Object
spi
=
sap
.
spi
;
synchronized
(
ENGINE
)
{
Provider
provider
=
sap
.
provider
;
ENGINE
.
getInstance
(
algorithm
,
null
);
spi
=
ENGINE
.
getSpi
();
provider
=
ENGINE
.
getProvider
();
}
if
(
spi
instanceof
MessageDigest
)
{
if
(
spi
instanceof
MessageDigest
)
{
MessageDigest
result
=
(
MessageDigest
)
spi
;
MessageDigest
result
=
(
MessageDigest
)
spi
;
result
.
algorithm
=
algorithm
;
result
.
algorithm
=
algorithm
;
result
.
provider
=
provider
;
result
.
provider
=
provider
;
return
result
;
return
result
;
}
}
return
new
MessageDigestImpl
((
MessageDigestSpi
)
s
pi
,
provider
,
algorithm
);
return
new
MessageDigestImpl
((
MessageDigestSpi
)
s
ap
.
spi
,
sap
.
provider
,
algorithm
);
}
}
/**
/**
...
@@ -158,11 +154,7 @@ public abstract class MessageDigest extends MessageDigestSpi {
...
@@ -158,11 +154,7 @@ public abstract class MessageDigest extends MessageDigestSpi {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
Object
spi
;
Object
spi
=
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
synchronized
(
ENGINE
)
{
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
spi
=
ENGINE
.
getSpi
();
}
if
(
spi
instanceof
MessageDigest
)
{
if
(
spi
instanceof
MessageDigest
)
{
MessageDigest
result
=
(
MessageDigest
)
spi
;
MessageDigest
result
=
(
MessageDigest
)
spi
;
result
.
algorithm
=
algorithm
;
result
.
algorithm
=
algorithm
;
...
...
This diff is collapsed.
Click to expand it.
luni/src/main/java/java/security/Policy.java
View file @
8ae047f5
...
@@ -126,12 +126,8 @@ public abstract class Policy {
...
@@ -126,12 +126,8 @@ public abstract class Policy {
}
}
try
{
try
{
synchronized
(
ENGINE
)
{
Engine
.
SpiAndProvider
sap
=
ENGINE
.
getInstance
(
type
,
params
);
ENGINE
.
getInstance
(
type
,
params
);
return
new
PolicyDelegate
((
PolicySpi
)
sap
.
spi
,
sap
.
provider
,
type
,
params
);
return
new
PolicyDelegate
((
PolicySpi
)
ENGINE
.
getSpi
(),
ENGINE
.
getProvider
(),
type
,
params
);
}
}
catch
(
NoSuchAlgorithmException
e
)
{
}
catch
(
NoSuchAlgorithmException
e
)
{
if
(
e
.
getCause
()
==
null
)
{
if
(
e
.
getCause
()
==
null
)
{
throw
e
;
throw
e
;
...
@@ -242,11 +238,8 @@ public abstract class Policy {
...
@@ -242,11 +238,8 @@ public abstract class Policy {
}
}
try
{
try
{
synchronized
(
ENGINE
)
{
Object
spi
=
ENGINE
.
getInstance
(
type
,
provider
,
params
);
ENGINE
.
getInstance
(
type
,
provider
,
params
);
return
new
PolicyDelegate
((
PolicySpi
)
spi
,
provider
,
type
,
params
);
return
new
PolicyDelegate
((
PolicySpi
)
ENGINE
.
getSpi
(),
provider
,
type
,
params
);
}
}
catch
(
NoSuchAlgorithmException
e
)
{
}
catch
(
NoSuchAlgorithmException
e
)
{
if
(
e
.
getCause
()
==
null
)
{
if
(
e
.
getCause
()
==
null
)
{
throw
e
;
throw
e
;
...
...
This diff is collapsed.
Click to expand it.
luni/src/main/java/java/security/SecureRandom.java
View file @
8ae047f5
...
@@ -124,11 +124,9 @@ public class SecureRandom extends Random {
...
@@ -124,11 +124,9 @@ public class SecureRandom extends Random {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
synchronized
(
ENGINE
)
{
Engine
.
SpiAndProvider
sap
=
ENGINE
.
getInstance
(
algorithm
,
null
);
ENGINE
.
getInstance
(
algorithm
,
null
);
return
new
SecureRandom
((
SecureRandomSpi
)
sap
.
spi
,
sap
.
provider
,
return
new
SecureRandom
((
SecureRandomSpi
)
ENGINE
.
getSpi
(),
ENGINE
.
getProvider
(),
algorithm
);
algorithm
);
}
}
}
/**
/**
...
@@ -185,10 +183,8 @@ public class SecureRandom extends Random {
...
@@ -185,10 +183,8 @@ public class SecureRandom extends Random {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
synchronized
(
ENGINE
)
{
Object
spi
=
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
return
new
SecureRandom
((
SecureRandomSpi
)
spi
,
provider
,
algorithm
);
return
new
SecureRandom
((
SecureRandomSpi
)
ENGINE
.
getSpi
(),
provider
,
algorithm
);
}
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
luni/src/main/java/java/security/Signature.java
View file @
8ae047f5
...
@@ -101,13 +101,9 @@ public abstract class Signature extends SignatureSpi {
...
@@ -101,13 +101,9 @@ public abstract class Signature extends SignatureSpi {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
Object
spi
;
Engine
.
SpiAndProvider
sap
=
ENGINE
.
getInstance
(
algorithm
,
null
);
Provider
provider
;
Object
spi
=
sap
.
spi
;
synchronized
(
ENGINE
)
{
Provider
provider
=
sap
.
provider
;
ENGINE
.
getInstance
(
algorithm
,
null
);
spi
=
ENGINE
.
getSpi
();
provider
=
ENGINE
.
getProvider
();
}
if
(
spi
instanceof
Signature
)
{
if
(
spi
instanceof
Signature
)
{
Signature
result
=
(
Signature
)
spi
;
Signature
result
=
(
Signature
)
spi
;
result
.
algorithm
=
algorithm
;
result
.
algorithm
=
algorithm
;
...
@@ -179,11 +175,7 @@ public abstract class Signature extends SignatureSpi {
...
@@ -179,11 +175,7 @@ public abstract class Signature extends SignatureSpi {
private
static
Signature
getSignatureInstance
(
String
algorithm
,
private
static
Signature
getSignatureInstance
(
String
algorithm
,
Provider
provider
)
throws
NoSuchAlgorithmException
{
Provider
provider
)
throws
NoSuchAlgorithmException
{
Object
spi
;
Object
spi
=
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
synchronized
(
ENGINE
)
{
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
spi
=
ENGINE
.
getSpi
();
}
if
(
spi
instanceof
Signature
)
{
if
(
spi
instanceof
Signature
)
{
Signature
result
=
(
Signature
)
spi
;
Signature
result
=
(
Signature
)
spi
;
result
.
algorithm
=
algorithm
;
result
.
algorithm
=
algorithm
;
...
...
This diff is collapsed.
Click to expand it.
luni/src/main/java/java/security/cert/CertPathBuilder.java
View file @
8ae047f5
...
@@ -105,11 +105,8 @@ public class CertPathBuilder {
...
@@ -105,11 +105,8 @@ public class CertPathBuilder {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
synchronized
(
ENGINE
)
{
Engine
.
SpiAndProvider
sap
=
ENGINE
.
getInstance
(
algorithm
,
null
);
ENGINE
.
getInstance
(
algorithm
,
null
);
return
new
CertPathBuilder
((
CertPathBuilderSpi
)
sap
.
spi
,
sap
.
provider
,
algorithm
);
return
new
CertPathBuilder
((
CertPathBuilderSpi
)
ENGINE
.
getSpi
(),
ENGINE
.
getProvider
(),
algorithm
);
}
}
}
/**
/**
...
@@ -165,10 +162,8 @@ public class CertPathBuilder {
...
@@ -165,10 +162,8 @@ public class CertPathBuilder {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
synchronized
(
ENGINE
)
{
Object
spi
=
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
return
new
CertPathBuilder
((
CertPathBuilderSpi
)
spi
,
provider
,
algorithm
);
return
new
CertPathBuilder
((
CertPathBuilderSpi
)
ENGINE
.
getSpi
(),
provider
,
algorithm
);
}
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
luni/src/main/java/java/security/cert/CertPathValidator.java
View file @
8ae047f5
...
@@ -104,11 +104,8 @@ public class CertPathValidator {
...
@@ -104,11 +104,8 @@ public class CertPathValidator {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
synchronized
(
ENGINE
)
{
Engine
.
SpiAndProvider
sap
=
ENGINE
.
getInstance
(
algorithm
,
null
);
ENGINE
.
getInstance
(
algorithm
,
null
);
return
new
CertPathValidator
((
CertPathValidatorSpi
)
sap
.
spi
,
sap
.
provider
,
algorithm
);
return
new
CertPathValidator
((
CertPathValidatorSpi
)
ENGINE
.
getSpi
(),
ENGINE
.
getProvider
(),
algorithm
);
}
}
}
/**
/**
...
@@ -166,11 +163,8 @@ public class CertPathValidator {
...
@@ -166,11 +163,8 @@ public class CertPathValidator {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
synchronized
(
ENGINE
)
{
Object
spi
=
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
return
new
CertPathValidator
((
CertPathValidatorSpi
)
spi
,
provider
,
algorithm
);
return
new
CertPathValidator
((
CertPathValidatorSpi
)
ENGINE
.
getSpi
(),
provider
,
algorithm
);
}
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
luni/src/main/java/java/security/cert/CertStore.java
View file @
8ae047f5
...
@@ -101,11 +101,8 @@ public class CertStore {
...
@@ -101,11 +101,8 @@ public class CertStore {
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
try
{
try
{
synchronized
(
ENGINE
)
{
Engine
.
SpiAndProvider
sap
=
ENGINE
.
getInstance
(
type
,
params
);
ENGINE
.
getInstance
(
type
,
params
);
return
new
CertStore
((
CertStoreSpi
)
sap
.
spi
,
sap
.
provider
,
type
,
params
);
return
new
CertStore
((
CertStoreSpi
)
ENGINE
.
getSpi
(),
ENGINE
.
getProvider
(),
type
,
params
);
}
}
catch
(
NoSuchAlgorithmException
e
)
{
}
catch
(
NoSuchAlgorithmException
e
)
{
Throwable
th
=
e
.
getCause
();
Throwable
th
=
e
.
getCause
();
if
(
th
==
null
)
{
if
(
th
==
null
)
{
...
@@ -182,11 +179,8 @@ public class CertStore {
...
@@ -182,11 +179,8 @@ public class CertStore {
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
try
{
try
{
synchronized
(
ENGINE
)
{
Object
spi
=
ENGINE
.
getInstance
(
type
,
provider
,
params
);
ENGINE
.
getInstance
(
type
,
provider
,
params
);
return
new
CertStore
((
CertStoreSpi
)
spi
,
provider
,
type
,
params
);
return
new
CertStore
((
CertStoreSpi
)
ENGINE
.
getSpi
(),
provider
,
type
,
params
);
}
}
catch
(
NoSuchAlgorithmException
e
)
{
}
catch
(
NoSuchAlgorithmException
e
)
{
Throwable
th
=
e
.
getCause
();
Throwable
th
=
e
.
getCause
();
if
(
th
==
null
)
{
if
(
th
==
null
)
{
...
...
This diff is collapsed.
Click to expand it.
luni/src/main/java/java/security/cert/CertificateFactory.java
View file @
8ae047f5
...
@@ -87,11 +87,8 @@ public class CertificateFactory {
...
@@ -87,11 +87,8 @@ public class CertificateFactory {
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
try
{
try
{
synchronized
(
ENGINE
)
{
Engine
.
SpiAndProvider
sap
=
ENGINE
.
getInstance
(
type
,
null
);
ENGINE
.
getInstance
(
type
,
null
);
return
new
CertificateFactory
((
CertificateFactorySpi
)
sap
.
spi
,
sap
.
provider
,
type
);
return
new
CertificateFactory
((
CertificateFactorySpi
)
ENGINE
.
getSpi
(),
ENGINE
.
getProvider
(),
type
);
}
}
catch
(
NoSuchAlgorithmException
e
)
{
}
catch
(
NoSuchAlgorithmException
e
)
{
throw
new
CertificateException
(
e
);
throw
new
CertificateException
(
e
);
}
}
...
@@ -156,11 +153,8 @@ public class CertificateFactory {
...
@@ -156,11 +153,8 @@ public class CertificateFactory {
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
try
{
try
{
synchronized
(
ENGINE
)
{
Object
spi
=
ENGINE
.
getInstance
(
type
,
provider
,
null
);
ENGINE
.
getInstance
(
type
,
provider
,
null
);
return
new
CertificateFactory
((
CertificateFactorySpi
)
spi
,
provider
,
type
);
return
new
CertificateFactory
((
CertificateFactorySpi
)
ENGINE
.
getSpi
(),
provider
,
type
);
}
}
catch
(
NoSuchAlgorithmException
e
)
{
}
catch
(
NoSuchAlgorithmException
e
)
{
throw
new
CertificateException
(
e
.
getMessage
());
throw
new
CertificateException
(
e
.
getMessage
());
}
}
...
...
This diff is collapsed.
Click to expand it.
luni/src/main/java/javax/crypto/Cipher.java
View file @
8ae047f5
...
@@ -264,51 +264,54 @@ public class Cipher {
...
@@ -264,51 +264,54 @@ public class Cipher {
boolean
needSetPadding
=
false
;
boolean
needSetPadding
=
false
;
boolean
needSetMode
=
false
;
boolean
needSetMode
=
false
;
Object
engineSpi
;
Object
engineSpi
=
null
;
Provider
engineProvider
;
Provider
engineProvider
=
provider
;
synchronized
(
ENGINE
)
{
if
(
transf
[
1
]
==
null
&&
transf
[
2
]
==
null
)
{
// "algorithm"
if
(
transf
[
1
]
==
null
&&
transf
[
2
]
==
null
)
{
// "algorithm"
if
(
provider
==
null
)
{
if
(
provider
==
null
)
{
Engine
.
SpiAndProvider
sap
=
ENGINE
.
getInstance
(
transf
[
0
],
null
);
ENGINE
.
getInstance
(
transf
[
0
],
null
);
engineSpi
=
sap
.
spi
;
}
else
{
engineProvider
=
sap
.
provider
;
ENGINE
.
getInstance
(
transf
[
0
],
provider
,
null
);
}
}
else
{
}
else
{
String
[]
searhOrder
=
{
engineSpi
=
ENGINE
.
getInstance
(
transf
[
0
],
provider
,
null
);
transf
[
0
]
+
"/"
+
transf
[
1
]
+
"/"
+
transf
[
2
],
// "algorithm/mode/padding"
}
transf
[
0
]
+
"/"
+
transf
[
1
],
// "algorithm/mode"
}
else
{
transf
[
0
]
+
"//"
+
transf
[
2
],
// "algorithm//padding"
String
[]
searchOrder
=
{
transf
[
0
]
// "algorithm"
transf
[
0
]
+
"/"
+
transf
[
1
]
+
"/"
+
transf
[
2
],
// "algorithm/mode/padding"
};
transf
[
0
]
+
"/"
+
transf
[
1
],
// "algorithm/mode"
int
i
;
transf
[
0
]
+
"//"
+
transf
[
2
],
// "algorithm//padding"
for
(
i
=
0
;
i
<
searhOrder
.
length
;
i
++)
{
transf
[
0
]
// "algorithm"
try
{
};
if
(
provider
==
null
)
{
int
i
;
ENGINE
.
getInstance
(
searhOrder
[
i
],
null
);
for
(
i
=
0
;
i
<
searchOrder
.
length
;
i
++)
{
}
else
{
try
{
ENGINE
.
getInstance
(
searhOrder
[
i
],
provider
,
null
);
if
(
provider
==
null
)
{
}
Engine
.
SpiAndProvider
sap
=
ENGINE
.
getInstance
(
searchOrder
[
i
],
null
);
break
;
engineSpi
=
sap
.
spi
;
}
catch
(
NoSuchAlgorithmException
e
)
{
engineProvider
=
sap
.
provider
;
if
(
i
==
searhOrder
.
length
-
1
)
{
}
else
{
throw
new
NoSuchAlgorithmException
(
transformation
);
engineSpi
=
ENGINE
.
getInstance
(
searchOrder
[
i
],
provider
,
null
);
}
}
break
;
}
catch
(
NoSuchAlgorithmException
e
)
{
if
(
i
==
searchOrder
.
length
-
1
)
{
throw
new
NoSuchAlgorithmException
(
transformation
);
}
}
}
switch
(
i
)
{
case
1
:
// "algorithm/mode"
needSetPadding
=
true
;
break
;
case
2
:
// "algorithm//padding"
needSetMode
=
true
;
break
;
case
3
:
// "algorithm"
needSetPadding
=
true
;
needSetMode
=
true
;
}
}
}
}
engineSpi
=
ENGINE
.
getSpi
();
switch
(
i
)
{
engineProvider
=
ENGINE
.
getProvider
();
case
1
:
// "algorithm/mode"
needSetPadding
=
true
;
break
;
case
2
:
// "algorithm//padding"
needSetMode
=
true
;
break
;
case
3
:
// "algorithm"
needSetPadding
=
true
;
needSetMode
=
true
;
}
}
if
(
engineSpi
==
null
||
engineProvider
==
null
)
{
throw
new
NoSuchAlgorithmException
(
transformation
);
}
}
if
(!(
engineSpi
instanceof
CipherSpi
))
{
if
(!(
engineSpi
instanceof
CipherSpi
))
{
throw
new
NoSuchAlgorithmException
(
engineSpi
.
getClass
().
getName
());
throw
new
NoSuchAlgorithmException
(
engineSpi
.
getClass
().
getName
());
...
...
This diff is collapsed.
Click to expand it.
luni/src/main/java/javax/crypto/ExemptionMechanism.java
View file @
8ae047f5
...
@@ -100,11 +100,8 @@ public class ExemptionMechanism {
...
@@ -100,11 +100,8 @@ public class ExemptionMechanism {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
synchronized
(
ENGINE
)
{
Engine
.
SpiAndProvider
sap
=
ENGINE
.
getInstance
(
algorithm
,
null
);
ENGINE
.
getInstance
(
algorithm
,
null
);
return
new
ExemptionMechanism
((
ExemptionMechanismSpi
)
sap
.
spi
,
sap
.
provider
,
algorithm
);
return
new
ExemptionMechanism
((
ExemptionMechanismSpi
)
ENGINE
.
getSpi
(),
ENGINE
.
getProvider
(),
algorithm
);
}
}
}
/**
/**
...
@@ -167,11 +164,8 @@ public class ExemptionMechanism {
...
@@ -167,11 +164,8 @@ public class ExemptionMechanism {
if
(
provider
==
null
)
{
if
(
provider
==
null
)
{
throw
new
IllegalArgumentException
(
"provider == null"
);
throw
new
IllegalArgumentException
(
"provider == null"
);
}
}
synchronized
(
ENGINE
)
{
Object
spi
=
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
return
new
ExemptionMechanism
((
ExemptionMechanismSpi
)
spi
,
provider
,
algorithm
);
return
new
ExemptionMechanism
((
ExemptionMechanismSpi
)
ENGINE
.
getSpi
(),
provider
,
algorithm
);
}
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
luni/src/main/java/javax/crypto/KeyAgreement.java
View file @
8ae047f5
...
@@ -101,11 +101,8 @@ public class KeyAgreement {
...
@@ -101,11 +101,8 @@ public class KeyAgreement {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
synchronized
(
ENGINE
)
{
Engine
.
SpiAndProvider
sap
=
ENGINE
.
getInstance
(
algorithm
,
null
);
ENGINE
.
getInstance
(
algorithm
,
null
);
return
new
KeyAgreement
((
KeyAgreementSpi
)
sap
.
spi
,
sap
.
provider
,
algorithm
);
return
new
KeyAgreement
((
KeyAgreementSpi
)
ENGINE
.
getSpi
(),
ENGINE
.
getProvider
(),
algorithm
);
}
}
}
/**
/**
...
@@ -166,11 +163,8 @@ public class KeyAgreement {
...
@@ -166,11 +163,8 @@ public class KeyAgreement {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
synchronized
(
ENGINE
)
{
Object
spi
=
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
return
new
KeyAgreement
((
KeyAgreementSpi
)
spi
,
provider
,
algorithm
);
return
new
KeyAgreement
((
KeyAgreementSpi
)
ENGINE
.
getSpi
(),
provider
,
algorithm
);
}
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
luni/src/main/java/javax/crypto/KeyGenerator.java
View file @
8ae047f5
...
@@ -100,11 +100,8 @@ public class KeyGenerator {
...
@@ -100,11 +100,8 @@ public class KeyGenerator {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
synchronized
(
ENGINE
)
{
Engine
.
SpiAndProvider
sap
=
ENGINE
.
getInstance
(
algorithm
,
null
);
ENGINE
.
getInstance
(
algorithm
,
null
);
return
new
KeyGenerator
((
KeyGeneratorSpi
)
sap
.
spi
,
sap
.
provider
,
algorithm
);
return
new
KeyGenerator
((
KeyGeneratorSpi
)
ENGINE
.
getSpi
(),
ENGINE
.
getProvider
(),
algorithm
);
}
}
}
/**
/**
...
@@ -163,11 +160,8 @@ public class KeyGenerator {
...
@@ -163,11 +160,8 @@ public class KeyGenerator {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
synchronized
(
ENGINE
)
{
Object
spi
=
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
return
new
KeyGenerator
((
KeyGeneratorSpi
)
spi
,
provider
,
algorithm
);
return
new
KeyGenerator
((
KeyGeneratorSpi
)
ENGINE
.
getSpi
(),
provider
,
algorithm
);
}
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
luni/src/main/java/javax/crypto/Mac.java
View file @
8ae047f5
...
@@ -103,10 +103,8 @@ public class Mac implements Cloneable {
...
@@ -103,10 +103,8 @@ public class Mac implements Cloneable {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
synchronized
(
ENGINE
)
{
Engine
.
SpiAndProvider
sap
=
ENGINE
.
getInstance
(
algorithm
,
null
);
ENGINE
.
getInstance
(
algorithm
,
null
);
return
new
Mac
((
MacSpi
)
sap
.
spi
,
sap
.
provider
,
algorithm
);
return
new
Mac
((
MacSpi
)
ENGINE
.
getSpi
(),
ENGINE
.
getProvider
(),
algorithm
);
}
}
}
/**
/**
...
@@ -167,10 +165,8 @@ public class Mac implements Cloneable {
...
@@ -167,10 +165,8 @@ public class Mac implements Cloneable {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
synchronized
(
ENGINE
)
{
Object
spi
=
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
return
new
Mac
((
MacSpi
)
spi
,
provider
,
algorithm
);
return
new
Mac
((
MacSpi
)
ENGINE
.
getSpi
(),
provider
,
algorithm
);
}
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
luni/src/main/java/javax/crypto/SecretKeyFactory.java
View file @
8ae047f5
...
@@ -105,11 +105,8 @@ public class SecretKeyFactory {
...
@@ -105,11 +105,8 @@ public class SecretKeyFactory {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
synchronized
(
ENGINE
)
{
Engine
.
SpiAndProvider
sap
=
ENGINE
.
getInstance
(
algorithm
,
null
);
ENGINE
.
getInstance
(
algorithm
,
null
);
return
new
SecretKeyFactory
((
SecretKeyFactorySpi
)
sap
.
spi
,
sap
.
provider
,
algorithm
);
return
new
SecretKeyFactory
((
SecretKeyFactorySpi
)
ENGINE
.
getSpi
(),
ENGINE
.
getProvider
(),
algorithm
);
}
}
}
/**
/**
...
@@ -170,11 +167,8 @@ public class SecretKeyFactory {
...
@@ -170,11 +167,8 @@ public class SecretKeyFactory {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
synchronized
(
ENGINE
)
{
Object
spi
=
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
return
new
SecretKeyFactory
((
SecretKeyFactorySpi
)
spi
,
provider
,
algorithm
);
return
new
SecretKeyFactory
((
SecretKeyFactorySpi
)
ENGINE
.
getSpi
(),
provider
,
algorithm
);
}
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
luni/src/main/java/javax/net/ssl/KeyManagerFactory.java
View file @
8ae047f5
...
@@ -76,11 +76,8 @@ public class KeyManagerFactory {
...
@@ -76,11 +76,8 @@ public class KeyManagerFactory {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
(
"algorithm is null"
);
throw
new
NullPointerException
(
"algorithm is null"
);
}
}
synchronized
(
ENGINE
)
{
Engine
.
SpiAndProvider
sap
=
ENGINE
.
getInstance
(
algorithm
,
null
);
ENGINE
.
getInstance
(
algorithm
,
null
);
return
new
KeyManagerFactory
((
KeyManagerFactorySpi
)
sap
.
spi
,
sap
.
provider
,
algorithm
);
return
new
KeyManagerFactory
((
KeyManagerFactorySpi
)
ENGINE
.
getSpi
(),
ENGINE
.
getProvider
(),
algorithm
);
}
}
}
/**
/**
...
@@ -138,11 +135,8 @@ public class KeyManagerFactory {
...
@@ -138,11 +135,8 @@ public class KeyManagerFactory {
if
(
algorithm
==
null
)
{
if
(
algorithm
==
null
)
{
throw
new
NullPointerException
(
"algorithm is null"
);
throw
new
NullPointerException
(
"algorithm is null"
);
}
}
synchronized
(
ENGINE
)
{
Object
spi
=
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
ENGINE
.
getInstance
(
algorithm
,
provider
,
null
);
return
new
KeyManagerFactory
((
KeyManagerFactorySpi
)
spi
,
provider
,
algorithm
);
return
new
KeyManagerFactory
((
KeyManagerFactorySpi
)
ENGINE
.
getSpi
(),
provider
,
algorithm
);
}
}
}
// Store used provider
// Store used provider
...
...
This diff is collapsed.
Click to expand it.
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment