harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r413797 - in /incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/keytool: ArgumentsParser.java Command.java KeytoolParameters.java
Date Tue, 13 Jun 2006 03:39:38 GMT
Author: mloenko
Date: Mon Jun 12 20:39:37 2006
New Revision: 413797

URL: http://svn.apache.org/viewvc?rev=413797&view=rev
Log:
applied patch from HARMONY-586
Keytool - added parameter and options declarations and commands enum

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/keytool/Command.java
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/keytool/ArgumentsParser.java
    incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/keytool/KeytoolParameters.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/keytool/ArgumentsParser.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/keytool/ArgumentsParser.java?rev=413797&r1=413796&r2=413797&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/keytool/ArgumentsParser.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/keytool/ArgumentsParser.java
Mon Jun 12 20:39:37 2006
@@ -23,20 +23,109 @@
  */
 
 class ArgumentsParser {
+    // / options names to compare to ///
+    // commands
+    final static String sGenkey = "-genkey";
+
+    final static String sSelfcert = "-selfcert";
+
+    final static String sImport = "-import";
+
+    final static String sExport = "-export";
+
+    final static String sStorepasswd = "-storepasswd";
+
+    final static String sKeypasswd = "-keypasswd";
+
+    final static String sCertreq = "-certreq";
+
+    final static String sSign = "-sign";
+
+    final static String sCheck = "-checkcrl";
+
+    final static String sAdd = "-addtocrl";
+
+    final static String sVerify = "-verify";
+
+    final static String sPrintcert = "-printcert";
+
+    final static String sKeyclone = "-keyclone";
+
+    final static String sDelete = "-delete";
+
+    final static String sList = "-list";
+
+    final static String sHelp = "-help";
+
+    // addititanal options
+    final static String sKeystore = "-keystore";
+
+    final static String sStoretype = "-storetype";
+
+    final static String sProvider = "-provider";
+
+    final static String sStorepass = "-storepass";
+
+    final static String sAlias = "-alias";
+
+    final static String sKeyalg = "-keyalg";
+
+    final static String sKeysize = "-keysize";
+
+    final static String sSigalg = "-sigalg";
+
+    final static String sDname = "-dname";
+
+    final static String sKeypass = "-keypass";
+
+    final static String sValidity = "-validity";
+
+    final static String sV = "-v";
+
+    final static String sJ = "-J";
+
+    final static String sFile = "-file";
+
+    final static String sNoprompt = "-noprompt";
+
+    final static String sTrustcacerts = "-trustcacerts";
+
+    final static String sRfc = "-rfc";
+
+    final static String sNew = "-new";
+
+    final static String sCertalias = "-certalias";
+
+    final static String sCertstore = "-certstore";
+
+    final static String sSecretkey = "-secretkey";
+
+    final static String sX509Version = "-x509version";
+
+    final static String sCertSerial = "-certserial";
+
+    final static String sDestAlias = "-dest";
+
+    final static String sCRLstore = "-crlstore";
+
     /**
      * The method finds known options in args which is usually taken from
      * command line and sets the corresponding fields of the returned
      * KeytoolParameters object to given values.
      */
-    static KeytoolParameters parseArgs(String[] args){
-        // TODO
-        throw new RuntimeException("The method is not implemented yet.");
+    static KeytoolParameters parseArgs(String[] args) {
+        // TODO: look for known options and get their values
+        if (args == null || args.length == 0) {
+            return null;
+        }
+        KeytoolParameters param = new KeytoolParameters();
+        return param;
     }
 
     /**
      * Checks if the needed values are set and, if not, prompts for them.
      */
-    static void getAdditionalParameters(KeytoolParameters param){
+    static void getAdditionalParameters(KeytoolParameters param) {
         // TODO
         throw new RuntimeException("The method is not implemented yet.");
     }

Added: incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/keytool/Command.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/keytool/Command.java?rev=413797&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/keytool/Command.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/keytool/Command.java
Mon Jun 12 20:39:37 2006
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package org.apache.harmony.tools.keytool;
+
+/** enumeration of commands available for execution */
+public enum Command {
+    // show help message
+    HELP,
+    // generate a key pair or a secret key
+    GENKEY,
+    // generate a self-signed certificate using
+    // an existing key pair
+    SELFCERT,
+    // import a trusted certificate or a CSR reply
+    IMPORT,
+    // export a certificate
+    EXPORT,
+    // change store password
+    STOREPASSWD,
+    // change key password
+    KEYPASSWD,
+    // generate a certificate signing request (CSR)
+    CERTREQ,
+    // check a CRL
+    CHECK,
+    // add a certificate to a CRL
+    ADD,
+    // verify a certificate chain
+    VERIFY,
+    // copy a key entry into a newly created one
+    KEYCLONE,
+    // print out the store contents
+    LIST,
+    // print out a certificate which is not in keystore yet
+    PRINTCERT,
+    // remove an entry from the store
+    DELETE
+}
+

Modified: incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/keytool/KeytoolParameters.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/keytool/KeytoolParameters.java?rev=413797&r1=413796&r2=413797&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/keytool/KeytoolParameters.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/keytool/KeytoolParameters.java
Mon Jun 12 20:39:37 2006
@@ -16,10 +16,112 @@
 
 package org.apache.harmony.tools.keytool;
 
+import java.io.File;
+import java.security.KeyStore;
+
 /**
- * The class encapsulates paramaters for Keytool most of which are ususally given
- * in command line.
+ * The class encapsulates paramaters for Keytool most of which are ususally
+ * given in command line.
  */
 public class KeytoolParameters {
     // TODO
+    /**
+     * Default location of the keystore. Used when the value is not supplied by
+     * the user.
+     */
+    public static final String defaultKeystorePath = System
+            .getProperty("user.home")
+            + File.separator + ".keystore";
+
+    /**
+     * Location of cacerts file, containing the certificates from root
+     * certificate authorities (usually self-signed).
+     */
+    public static final String cacertsPath = System.getProperty("java.home")
+            + File.separator + "lib" + File.separator + "security"
+            + File.separator + "cacerts";
+
+    // the keystore to work with
+    private KeyStore keyStore;
+
+    // shows should the keystore be saved or not;
+    private boolean needSaveKS;
+
+    // path to the keystore or certstore depending on a command.
+    private String storePath;
+
+    // type of the store. Default type is set in java.security file.
+    private String storeType = KeyStore.getDefaultType();
+
+    // the name of the provider to use
+    private String provider;
+
+    // alias to access an entry in keystore
+    private String alias;
+
+    // algorithm name to get instance of KeyPairGenerator, KeyFactory, etc.
+    private String keyAlg = "DSA";
+
+    // digital signature algorithm
+    private String sigAlg;
+
+    // X.500 Distinguished Name to generate a certificate
+    private String dName;
+
+    // name of the file to import/export certificates
+    private String fileName;
+
+    // alias to access an entry in certstore
+    private String certAlias;
+
+    // certstore to keep a CRL in
+    private String crlStore;
+
+    // used in keyclone. Shows the destination alias to copy key pair to
+    private String destAlias;
+
+    // password to access the store
+    private char[] storePass;
+
+    // password to access the key entry
+    private char[] keyPass;
+
+    // new password to change the old one to
+    private char[] newPasswd;
+
+    // size of the key to generate
+    private int keySize = 1024;
+
+    // validity period of the generated certificate in days from the current
+    // moment
+    private int validity = 90;
+
+    // X.509 protocol version to use when generating a certificate
+    private int X509version = 3;
+
+    // certificate serial number
+    private int certSerialNr;
+
+    // should the unspecified parameters be prompted for or not
+    private boolean noPrompt;
+
+    // used in import. Should the certificates from cacerts file be considered
+    // for the chain of trust or not
+    private boolean trustCACerts;
+
+    // should the certificate be printed or exported in printable or binary
+    // format
+    private boolean rfc;
+
+    // should the keytool print the detailed information on the operation or not
+    private boolean verbose;
+
+    // should a secret key or a key pair be generated
+    private boolean isSecretKey;
+
+    // true if the store worked with is a keystore, false - if a certstore
+    private boolean isKeyStore = true;
+
+    // command to perform
+    private Command command = Command.HELP;
 }



Mime
View raw message