<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/4.6.6">
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#ffffff">
Some comments for the patch.<BR>
<BR>
pki man page -<BR>
<BR>
I feel this line is not required - <BR>
Finally, to use the \fBpki\fP command-line tool with basic authentication interactively, user passwords may be prompted for:<BR>
<BR>
A few lines, i feel, that need a change:<BR>
<S><FONT COLOR="#ff0000">(First of all, a)</FONT></S><FONT COLOR="#ff0000"> A</FONT> client certificate associated with the desired PKI server must be used for client authentication. This can be done by importing the client certificate into an NSS security database and passing the values to<U><B> </B></U><U><B><FONT COLOR="#ff0000">the </FONT></B></U>relevant options provided by the \fBpki\fP CLI framework.<BR>
<BR>
When issuing the first <B><U><FONT COLOR="#ff0000">pki</FONT></U></B> command using the authentication parameters (after completion of the setup of the client<BR>
<BR>
Question: Do we need to provide the -y option? Can we not prompt for a user password as we do with the client security database password(or may be throw an error message)?<BR>
<BR>
MainCLI.java:<BR>
<BR>
1. The method names must be camel cased:<BR>
promptForPassword, readPlaintextPasswordFromFile and so on.<BR>
<BR>
2. In the method read_plaintext_password_from_file:<BR>
The streams must be closed in a finally block. It is a good practice to ensure that there are no open streams in case of an exception.<BR>
The try block can be written as follows:<BR>
BufferedReader br = null;<BR>
try {<BR>
            br = new BufferedReader(new FileReader(pwfile));<BR>
            password = br.readLine();<BR>
            if (password == null) {<BR>
                System.err.println("\nWarning:  File '" + pwfile + "' is empty!\n");<BR>
<BR>
                // Attempt to prompt for the password<BR>
                password = prompt_for_password();<BR>
            }<BR>
        } catch (Exception e) {<BR>
            errMsgs.add("Error: " + e.getMessage());<BR>
            printHelp(errMsgs);<BR>
            System.exit(-1);<BR>
        } finally{<BR>
            if(br != null)<BR>
                br.close();<BR>
       }<BR>
<BR>
In Java7 it can be further simplified as:<BR>
<BR>
try(BufferedReader br = new BufferedReader(new FileReader(pwfile))){<BR>
            password = br.readLine();<BR>
           if (password == null || <FONT COLOR="#ff0000">password.trim().length() !=0</FONT>) { <FONT COLOR="#ff0000">// Additional check for an empty file. Assuming that the password must be present on the first line.</FONT><BR>
                System.err.println("\nWarning:  File '" + pwfile + "' is empty!\n");<BR>
<BR>
                // Attempt to prompt for the password<BR>
                password = prompt_for_password();<BR>
            }<BR>
 }catch (Exception e) {<BR>
            errMsgs.add("Error: " + e.getMessage());<BR>
            printHelp(errMsgs);<BR>
            System.exit(-1);<BR>
 }<BR>
The BufferedReader resource used will be auto closed.<BR>
<BR>
3. Similar file read optimization can be applied in read_client_security_database_password_from_file method.<BR>
<BR>
4.  We have been traditionally using "kra" in the URI, i think it is not required to provide an option to enter DRM in the URI and try to <BR>
convert it it internally. May be we can specify that in the man page itself.<BR>
<BR>
5. You have explained thoroughly, the mutually exclusive nature of the various options. I think it would be better to throw an error message when an invalid case<BR>
is encountered rather than storing the error messages and printing them together.<BR>
<BR>
I haven't tested the patch yet. But it looks good logical wise.<BR>
<BR>
-- Abhishek<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
On Thu, 2014-07-31 at 20:28 -0700, Matthew Harmsen wrote:<BR>
<BLOCKQUOTE TYPE=CITE>
    <TT>Please review the attached patch which implements alternative CLI password methods to address the following PKI TRAC ticket:</TT>
    <UL>
        <LI><TT><A HREF="https://fedorahosted.org/pki/ticket/555">PKI TRAC Ticket #555 - Other ways to specify CLI password</A></TT>
    </UL>
    <BR>
    <TT>This patch contains two additional password implementations for Basic Authentication ('-W <user password file>' and '-y' which allows prompting for the user password), and one additional password implementation for Client Authentication ('-C <client security database password file>').</TT><BR>
    <BR>
    <BR>
    <TT>As a part of this patch, the </TT><TT><B>pki </B></TT><TT>man page was updated significantly.</TT><BR>
    <BR>
    <BR>
    <TT>Additionally, the <A HREF="http://pki.fedoraproject.org/wiki/CLI">Dogtag CLI Design Wiki</A> was updated to reflect these Dogtag 10.2 changes.</TT><BR>
    <BR>
    <BR>
<PRE>
_______________________________________________
Pki-devel mailing list
<A HREF="mailto:Pki-devel@redhat.com">Pki-devel@redhat.com</A>
<A HREF="https://www.redhat.com/mailman/listinfo/pki-devel">https://www.redhat.com/mailman/listinfo/pki-devel</A>
</PRE>
</BLOCKQUOTE>
<BR>
</BODY>
</HTML>