[spring-extensions] 01/02: Some error handling / checkstyle nits.
Ian Young
ian at iay.org.uk
Thu Sep 13 14:03:24 EDT 2018
This is an automated email from the git hooks/post-receive script.
iay pushed a commit to branch master
in repository spring-extensions.
View the commit online:
http://git.shibboleth.net/view/?p=spring-extensions.git;a=commit;h=ff30da10a02d03dbe9492b39173fd597a29f3c3b
commit ff30da10a02d03dbe9492b39173fd597a29f3c3b
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Aug 29 11:47:12 2018 -0400
Some error handling / checkstyle nits.
---
.../ext/spring/factory/KeyStoreFactoryBean.java | 22 +++++++++++++---------
.../factory/PKCS11PrivateKeyFactoryBean.java | 1 -
2 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/src/main/java/net/shibboleth/ext/spring/factory/KeyStoreFactoryBean.java b/src/main/java/net/shibboleth/ext/spring/factory/KeyStoreFactoryBean.java
index 38f5f92..53f563d 100644
--- a/src/main/java/net/shibboleth/ext/spring/factory/KeyStoreFactoryBean.java
+++ b/src/main/java/net/shibboleth/ext/spring/factory/KeyStoreFactoryBean.java
@@ -27,6 +27,7 @@ import net.shibboleth.utilities.java.support.logic.Constraint;
import net.shibboleth.utilities.java.support.primitive.StringSupport;
import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.FactoryBeanNotInitializedException;
import org.springframework.core.io.Resource;
/**
@@ -37,19 +38,19 @@ import org.springframework.core.io.Resource;
public class KeyStoreFactoryBean implements FactoryBean<KeyStore> {
/** KeyStore resource. */
- private Resource resource;
+ @Nullable private Resource resource;
/** Password for the keystore. */
- private String keyPass;
+ @Nullable private String keyPass;
/** KeyStore type. */
- private String type;
+ @Nullable private String type;
/** KeyStore provider. */
- private String provider;
+ @Nullable private String provider;
/** The singleton instance of the private key produced by this factory. */
- private KeyStore keyStore;
+ @Nullable private KeyStore keyStore;
/**
* Set the resource containing the keystore.
@@ -89,14 +90,17 @@ public class KeyStoreFactoryBean implements FactoryBean<KeyStore> {
/** {@inheritDoc} */
@Override public KeyStore getObject() throws Exception {
+
if (keyStore == null) {
+ if (resource == null) {
+ throw new FactoryBeanNotInitializedException("Resource property cannot be null");
+ }
+
if (provider != null && type != null) {
keyStore = KeyStore.getInstance(type, provider);
- }
- else if (type != null) {
+ } else if (type != null) {
keyStore = KeyStore.getInstance(type);
- }
- else {
+ } else {
keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
}
try (final InputStream is = resource.getInputStream()) {
diff --git a/src/main/java/net/shibboleth/ext/spring/factory/PKCS11PrivateKeyFactoryBean.java b/src/main/java/net/shibboleth/ext/spring/factory/PKCS11PrivateKeyFactoryBean.java
index 3625319..4de8139 100644
--- a/src/main/java/net/shibboleth/ext/spring/factory/PKCS11PrivateKeyFactoryBean.java
+++ b/src/main/java/net/shibboleth/ext/spring/factory/PKCS11PrivateKeyFactoryBean.java
@@ -122,7 +122,6 @@ public class PKCS11PrivateKeyFactoryBean implements FactoryBean<PrivateKey> {
* @return the singleton {@link Provider}
* @throws Exception if something goes wrong building the {@link Provider}
*/
- @SuppressWarnings("unchecked")
private Provider getProvider() throws Exception {
if (provider == null) {
final ClassLoader loader = PKCS11PrivateKeyFactoryBean.class.getClassLoader();
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list