[utilities COMMIT] /ant-extensions/trunk/src/main/java/edu/internet2/middleware/ant/pki/SelfSignedCertificate.java

noreply at shibboleth.net noreply at shibboleth.net
Wed Aug 6 22:08:40 EDT 2014


Author: scantor
Date: Wed Aug  6 22:08:39 2014
New Revision: 656

URL: http://svn.shibboleth.net/view/utilities?rev=656&view=rev
Log:
Cleanup error handling.

Modified:
    ant-extensions/trunk/src/main/java/edu/internet2/middleware/ant/pki/SelfSignedCertificate.java

Modified: ant-extensions/trunk/src/main/java/edu/internet2/middleware/ant/pki/SelfSignedCertificate.java
URL: http://svn.shibboleth.net/view/utilities/ant-extensions/trunk/src/main/java/edu/internet2/middleware/ant/pki/SelfSignedCertificate.java?rev=656&r1=655&r2=656&view=diff
==============================================================================
--- ant-extensions/trunk/src/main/java/edu/internet2/middleware/ant/pki/SelfSignedCertificate.java (original)
+++ ant-extensions/trunk/src/main/java/edu/internet2/middleware/ant/pki/SelfSignedCertificate.java Wed Aug  6 22:08:39 2014
@@ -102,7 +102,8 @@
     private String keystorePassword;
 
     /** {@inheritDoc} */
-    public void execute() throws BuildException {
+    @Override
+    public void execute() {
         validate();
         KeyPair keypair = generateKeyPair();
         X509Certificate certificate = generateCertificate(keypair);
@@ -115,6 +116,7 @@
                 keyOut.flush();
                 keyOut.close();
             } catch (Exception e) {
+                log(e.toString(), Project.MSG_ERR);
                 throw new BuildException("Unable to create private key file.", e);
             }
         }
@@ -127,7 +129,8 @@
                 certOut.flush();
                 certOut.close();
             } catch (Exception e) {
-                throw new BuildException("Unable to create private key file.", e);
+                log(e.toString(), Project.MSG_ERR);
+                throw new BuildException("Unable to create certificate file.", e);
             }
         }
 
@@ -143,7 +146,8 @@
                 keystoreOut.flush();
                 keystoreOut.close();
             } catch (Exception e) {
-                throw new BuildException(e);
+                log(e.toString(), Project.MSG_WARN);
+                throw new BuildException("Unable to create keystore file.", e);
             }
         }
     }
@@ -239,7 +243,7 @@
     }
 
     /** Validates the provided task input. */
-    protected void validate() throws BuildException {
+    protected void validate() {
         if (keysize > 2048) {
             log("Key size is greater than 2048, this may cause problems with some JVMs", Project.MSG_WARN);
         }
@@ -257,10 +261,8 @@
      * Generates the key pair for the certificate.
      * 
      * @return key pair for the certificate
-     * 
-     * @throws BuildException thrown if there is a problem generating the keys.
-     */
-    protected KeyPair generateKeyPair() throws BuildException {
+     */
+    protected KeyPair generateKeyPair() {
         try {
             KeyPairGenerator generator = KeyPairGenerator.getInstance(keyType);
             generator.initialize(keysize);
@@ -276,10 +278,8 @@
      * @param keypair keypair associated with the certificate
      * 
      * @return self-signed certificate
-     * 
-     * @throws BuildException thrown if the certificate can not be generated
-     */
-    protected X509Certificate generateCertificate(KeyPair keypair) throws BuildException {
+     */
+    protected X509Certificate generateCertificate(KeyPair keypair) {
         try {
             final X500Name dn = new X500Name("CN=" + hostname);
             final GregorianCalendar notBefore = new GregorianCalendar();
@@ -346,6 +346,8 @@
     /** Key type enumeration. */
     public static class KeyType extends EnumeratedAttribute {
 
+        /** {@inheritDoc} */
+        @Override
         public String[] getValues() {
             return new String[] {"DSA", "RSA"};
         }



More information about the commits mailing list