You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by sebb <se...@gmail.com> on 2013/09/08 22:34:02 UTC

Re: svn commit: r1520912 - /jmeter/trunk/src/jorphan/org/apache/jorphan/exec/KeyToolUtils.java

On 8 September 2013 21:09,  <pm...@apache.org> wrote:
> Author: pmouawad
> Date: Sun Sep  8 20:09:45 2013
> New Revision: 1520912
>
> URL: http://svn.apache.org/r1520912
> Log:
> Test value of File#delete
>
> Modified:
>     jmeter/trunk/src/jorphan/org/apache/jorphan/exec/KeyToolUtils.java
>
> Modified: jmeter/trunk/src/jorphan/org/apache/jorphan/exec/KeyToolUtils.java
> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/jorphan/org/apache/jorphan/exec/KeyToolUtils.java?rev=1520912&r1=1520911&r2=1520912&view=diff
> ==============================================================================
> --- jmeter/trunk/src/jorphan/org/apache/jorphan/exec/KeyToolUtils.java (original)
> +++ jmeter/trunk/src/jorphan/org/apache/jorphan/exec/KeyToolUtils.java Sun Sep  8 20:09:45 2013
> @@ -29,11 +29,14 @@ import java.util.List;
>
>  import org.apache.commons.lang3.JavaVersion;
>  import org.apache.commons.lang3.SystemUtils;
> +import org.apache.jorphan.logging.LoggingManager;
> +import org.apache.log.Logger;
>
>  /**
>   * Utilities for working with Java keytool
>   */
>  public class KeyToolUtils {
> +    private static final Logger log = LoggingManager.getLoggerForClass();
>
>      // The DNAME which is used if none is provided
>      private static final String DEFAULT_DNAME = "cn=JMeter Proxy (DO NOT TRUST)";  // $NON-NLS-1$
> @@ -114,8 +117,11 @@ public class KeyToolUtils {
>       */
>      public static void generateProxyCA(File keystore, String password,  int validity) throws IOException {
>          keystore.delete(); // any existing entries will be invalidated anyway
> -        new File(CACERT).delete(); // not strictly needed
> -
> +        // not strictly needed
> +        if(!new File(CACERT).delete()) {
> +            // Noop as we accept not to be able to delete it
> +            log.warn("Could not delete file:"+new File(CACERT).getAbsolutePath()+", will continue ignoring this");
> +        }

What if the file does not exist?
Won't that cause delete() to return false?

I think it's better to ignore the return code; the gencert command
will detect any problems (e.g. read-only .crt file)

>          // Create the self-signed keypairs (requires Java 7 for -ext flag)
>          KeyToolUtils.genkeypair(keystore, ROOT_ALIAS, password, validity, DNAME_ROOT_KEY, "bc:c");
>          KeyToolUtils.genkeypair(keystore, CA_ALIAS, password, validity, DNAME_CA_KEY, "bc:c");
>
>