|
From: <pe...@us...> - 2003-12-10 23:58:55
|
Update of /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/tools/commandline
In directory sc8-pr-cvs1:/tmp/cvs-serv1921/src/java/org/neuclear/id/tools/commandline
Modified Files:
BuildHttpIdentity.java CommandLineSigner.java
IdentityCreator.java
Log Message:
Did some cleaning up in the builders
Fixed some stuff in IdentityCreator
New maven goal to create executable jarapp
We are close to 0.8 final of ID, 0.11 final of XMLSIG and 0.5 of commons.
Will release shortly.
Index: BuildHttpIdentity.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/tools/commandline/BuildHttpIdentity.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** BuildHttpIdentity.java 9 Dec 2003 23:41:44 -0000 1.1
--- BuildHttpIdentity.java 10 Dec 2003 23:58:51 -0000 1.2
***************
*** 4,14 ****
import org.neuclear.commons.Utility;
import org.neuclear.commons.crypto.passphraseagents.GuiDialogAgent;
! import org.neuclear.commons.crypto.passphraseagents.CommandLineAgent;
! import org.neuclear.commons.crypto.signers.*;
! import org.neuclear.id.SignedNamedObject;
import org.neuclear.id.NSTools;
import org.neuclear.id.builders.IdentityBuilder;
- import org.neuclear.store.FileStore;
- import org.neuclear.store.Store;
import org.neuclear.xml.XMLException;
--- 4,11 ----
import org.neuclear.commons.Utility;
import org.neuclear.commons.crypto.passphraseagents.GuiDialogAgent;
! import org.neuclear.commons.crypto.signers.DefaultSigner;
! import org.neuclear.commons.crypto.signers.JCESigner;
import org.neuclear.id.NSTools;
import org.neuclear.id.builders.IdentityBuilder;
import org.neuclear.xml.XMLException;
***************
*** 36,39 ****
--- 33,43 ----
$Id$
$Log$
+ Revision 1.2 2003/12/10 23:58:51 pelle
+ Did some cleaning up in the builders
+ Fixed some stuff in IdentityCreator
+ New maven goal to create executable jarapp
+ We are close to 0.8 final of ID, 0.11 final of XMLSIG and 0.5 of commons.
+ Will release shortly.
+
Revision 1.1 2003/12/09 23:41:44 pelle
IdentityCreator is now the default class of the uber jar.
***************
*** 78,82 ****
public static void main(final String[] args) {
try {
! if (args.length<2){
System.err.println("Usage: java org.neuclear.id.tools.commandline.BuildHttpIdentity name receiver");
System.err.println("eg. java org.neuclear.id.tools.commandline.BuildHttpIdentity neu://neuclear.org mailto:bo...@ne...");
--- 82,86 ----
public static void main(final String[] args) {
try {
! if (args.length < 2) {
System.err.println("Usage: java org.neuclear.id.tools.commandline.BuildHttpIdentity name receiver");
System.err.println("eg. java org.neuclear.id.tools.commandline.BuildHttpIdentity neu://neuclear.org mailto:bo...@ne...");
***************
*** 85,89 ****
final JCESigner rootsig = new DefaultSigner(new GuiDialogAgent());
! createIdentity(args[0], rootsig,args[1]);
} catch (NeuClearException e) {
e.printStackTrace();
--- 89,93 ----
final JCESigner rootsig = new DefaultSigner(new GuiDialogAgent());
! createIdentity(args[0], rootsig, args[1]);
} catch (NeuClearException e) {
e.printStackTrace();
***************
*** 100,110 ****
}
! private static void createIdentity(final String name, final JCESigner rootsig,String receiver) throws NeuClearException, XMLException, IOException {
! System.out.println("Creating "+name);
String store = NSTools.isHttpScheme(name);
! boolean isTopLevel=!Utility.isEmpty(store);
if (!isTopLevel) {
// If this isn't a top level we will derive the repository from its parent.
! store=NSTools.isHttpScheme(NSTools.getParentNSURI(name));
}
final IdentityBuilder id = new IdentityBuilder(
--- 104,114 ----
}
! private static void createIdentity(final String name, final JCESigner rootsig, final String receiver) throws NeuClearException, XMLException, IOException {
! System.out.println("Creating " + name);
String store = NSTools.isHttpScheme(name);
! boolean isTopLevel = !Utility.isEmpty(store);
if (!isTopLevel) {
// If this isn't a top level we will derive the repository from its parent.
! store = NSTools.isHttpScheme(NSTools.getSignatoryURI(name));
}
final IdentityBuilder id = new IdentityBuilder(
***************
*** 114,126 ****
"http://localhost:11870/Signer",
"http://logger.neuclear.org",
! receiver);
System.out.println("Signing: " + name);
! id.sign((isTopLevel)?name:NSTools.getParentNSURI(name),rootsig);
! String filename = "_NEUID"+NSTools.name2path(name)+"/root.id";
! System.out.println("Saving to: "+filename);
! File fout=new File(filename);
fout.getParentFile().mkdirs();
! OutputStream os=new FileOutputStream(fout);
os.write(id.canonicalize());
os.close();
--- 118,130 ----
"http://localhost:11870/Signer",
"http://logger.neuclear.org",
! receiver);
System.out.println("Signing: " + name);
! id.sign((isTopLevel) ? name : NSTools.getSignatoryURI(name), rootsig);
! String filename = "_NEUID" + NSTools.name2path(name) + "/root.id";
! System.out.println("Saving to: " + filename);
! File fout = new File(filename);
fout.getParentFile().mkdirs();
! OutputStream os = new FileOutputStream(fout);
os.write(id.canonicalize());
os.close();
Index: CommandLineSigner.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/tools/commandline/CommandLineSigner.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** CommandLineSigner.java 9 Dec 2003 23:41:44 -0000 1.1
--- CommandLineSigner.java 10 Dec 2003 23:58:51 -0000 1.2
***************
*** 1,4 ****
--- 1,11 ----
/* $Id$
* $Log$
+ * Revision 1.2 2003/12/10 23:58:51 pelle
+ * Did some cleaning up in the builders
+ * Fixed some stuff in IdentityCreator
+ * New maven goal to create executable jarapp
+ * We are close to 0.8 final of ID, 0.11 final of XMLSIG and 0.5 of commons.
+ * Will release shortly.
+ *
* Revision 1.1 2003/12/09 23:41:44 pelle
* IdentityCreator is now the default class of the uber jar.
***************
*** 103,107 ****
* The email sender works. The LogSender and the SoapSender should work but havent been tested yet.
* The SignedNamedObject has a new log() method that logs it's contents at it's parent Identity's logger.
! * The Identity object also has a new method send() which allows one to send a named object to the Identity's
* default receiver.
*
--- 110,114 ----
* The email sender works. The LogSender and the SoapSender should work but havent been tested yet.
* The SignedNamedObject has a new log() method that logs it's contents at it's parent Identity's logger.
! * The Identity object also has a new method receive() which allows one to receive a named object to the Identity's
* default receiver.
*
***************
*** 179,196 ****
import org.apache.commons.cli.*;
import org.dom4j.Document;
- import org.neuclear.commons.Utility;
import org.neuclear.commons.NeuClearException;
! import org.neuclear.commons.time.TimeTools;
! import org.neuclear.commons.configuration.Configuration;
! import org.neuclear.commons.configuration.ConfigurationException;
import org.neuclear.commons.crypto.CryptoTools;
import org.neuclear.commons.crypto.passphraseagents.CommandLineAgent;
- import org.neuclear.commons.crypto.signers.Signer;
import org.neuclear.commons.crypto.signers.DefaultSigner;
! import org.neuclear.id.SignedNamedObject;
! import org.neuclear.id.NSTools;
import org.neuclear.id.Identity;
! import org.neuclear.id.resolver.NSResolver;
import org.neuclear.id.builders.NamedObjectBuilder;
import org.neuclear.xml.XMLException;
import org.neuclear.xml.XMLTools;
--- 186,200 ----
import org.apache.commons.cli.*;
import org.dom4j.Document;
import org.neuclear.commons.NeuClearException;
! import org.neuclear.commons.Utility;
import org.neuclear.commons.crypto.CryptoTools;
import org.neuclear.commons.crypto.passphraseagents.CommandLineAgent;
import org.neuclear.commons.crypto.signers.DefaultSigner;
! import org.neuclear.commons.crypto.signers.Signer;
! import org.neuclear.commons.time.TimeTools;
import org.neuclear.id.Identity;
! import org.neuclear.id.NSTools;
import org.neuclear.id.builders.NamedObjectBuilder;
+ import org.neuclear.id.resolver.NSResolver;
import org.neuclear.xml.XMLException;
import org.neuclear.xml.XMLTools;
***************
*** 212,226 ****
cmd = clparser.parse(options, args);
checkArguments();
! if (cmd.hasOption('v')){
! String name=cmd.getOptionValue('v');
! System.out.println("Resolving and Verifying: "+name);
try {
! Identity id=NSResolver.resolveIdentity(name);
! if (id!=null){
! System.out.println("Signed Object: "+id.getName()+ " is verified");
! System.out.println("was signed at: "+TimeTools.formatTimeStamp(id.getTimeStamp()));
! System.out.println("Is of type: "+id.getClass().getName());
! System.out.println("repository: "+id.getRepository());
! System.out.println("signer: "+id.getSigner());
} else {
System.out.println("Couldnt Resolve or Verify the object.");
--- 216,230 ----
cmd = clparser.parse(options, args);
checkArguments();
! if (cmd.hasOption('v')) {
! String name = cmd.getOptionValue('v');
! System.out.println("Resolving and Verifying: " + name);
try {
! Identity id = NSResolver.resolveIdentity(name);
! if (id != null) {
! System.out.println("Signed Object: " + id.getName() + " is verified");
! System.out.println("was signed at: " + TimeTools.formatTimeStamp(id.getTimeStamp()));
! System.out.println("Is of type: " + id.getClass().getName());
! System.out.println("repository: " + id.getRepository());
! System.out.println("signer: " + id.getSigner());
} else {
System.out.println("Couldnt Resolve or Verify the object.");
***************
*** 236,241 ****
alias = cmd.getOptionValue("a");
of = cmd.getOptionValue("o");
! if (Utility.isEmpty(of)&&cmd.hasOption('i')){
! of=cmd.getOptionValue('i')+".id";
}
}
--- 240,245 ----
alias = cmd.getOptionValue("a");
of = cmd.getOptionValue("o");
! if (Utility.isEmpty(of) && cmd.hasOption('i')) {
! of = cmd.getOptionValue('i') + ".id";
}
}
***************
*** 255,259 ****
help.printHelp("java " +
this.getClass().getName() +
! getExtraHelp()+" [--outputfile signed/test.id] " , options);
System.exit(1);
}
--- 259,263 ----
help.printHelp("java " +
this.getClass().getName() +
! getExtraHelp() + " [--outputfile signed/test.id] ", options);
System.exit(1);
}
***************
*** 265,269 ****
protected boolean hasArguments() {
! return cmd.hasOption("i")||cmd.hasOption('v');
}
--- 269,273 ----
protected boolean hasArguments() {
! return cmd.hasOption("i") || cmd.hasOption('v');
}
***************
*** 275,280 ****
if (!sig.canSignFor(alias)) {
if (!Utility.isEmpty(of))
! of=subject.getLocalName()+".xml";
! System.err.println("Key with alias: " + alias + " doesnt exist in our keystore. \nSaving unsigned Identity as: "+of);
} else {
System.err.println("Signing by " + alias + " ...");
--- 279,284 ----
if (!sig.canSignFor(alias)) {
if (!Utility.isEmpty(of))
! of = subject.getLocalName() + ".xml";
! System.err.println("Key with alias: " + alias + " doesnt exist in our keystore. \nSaving unsigned Identity as: " + of);
} else {
System.err.println("Signing by " + alias + " ...");
***************
*** 305,308 ****
--- 309,316 ----
if (!Utility.isEmpty(sf)) {
source = new FileInputStream(sf);
+ if (Utility.isEmpty(of)) {
+ int loc = sf.lastIndexOf(".");
+ of = sf.substring(0, loc) + ".id";
+ }
}
final Document doc = XMLTools.loadDocument(source);
***************
*** 310,328 ****
if (Utility.isEmpty(alias)) {
! alias = Utility.denullString(NSTools.isHttpScheme(subject.getName()),NSTools.getParentNSURI(subject.getName()));
}
if (!sig.canSignFor(alias)) {
! System.err.println("You can not sign as " +alias+ " with your current keystore.");
System.exit(1);
}
System.out.println("You are about to sign the following Contract. Please make sure that is what you want.");
! System.out.println("Type: "+subject.getTagName());
! System.out.println("Proposed Name: "+subject.getName());
System.out.println("Raw XML:\n===================");
System.out.println(subject.asXML());
System.out.print("===================\nAre you shure you wish to sign this? (y/N) ");
! String answer=new jline.ConsoleReader().readLine();
if (!answer.toLowerCase().equals("y")) {
System.out.println("Aborted Signing Process");
--- 318,336 ----
if (Utility.isEmpty(alias)) {
! alias = Utility.denullString(NSTools.isHttpScheme(subject.getName()), NSTools.getSignatoryURI(subject.getName()));
}
if (!sig.canSignFor(alias)) {
! System.err.println("You can not sign as " + alias + " with your current keystore.");
System.exit(1);
}
System.out.println("You are about to sign the following Contract. Please make sure that is what you want.");
! System.out.println("Type: " + subject.getTagName());
! System.out.println("Proposed Name: " + subject.getName());
System.out.println("Raw XML:\n===================");
System.out.println(subject.asXML());
System.out.print("===================\nAre you shure you wish to sign this? (y/N) ");
! String answer = new jline.ConsoleReader().readLine();
if (!answer.toLowerCase().equals("y")) {
System.out.println("Aborted Signing Process");
Index: IdentityCreator.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/tools/commandline/IdentityCreator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** IdentityCreator.java 9 Dec 2003 23:41:44 -0000 1.1
--- IdentityCreator.java 10 Dec 2003 23:58:51 -0000 1.2
***************
*** 1,4 ****
--- 1,11 ----
/* $Id$
* $Log$
+ * Revision 1.2 2003/12/10 23:58:51 pelle
+ * Did some cleaning up in the builders
+ * Fixed some stuff in IdentityCreator
+ * New maven goal to create executable jarapp
+ * We are close to 0.8 final of ID, 0.11 final of XMLSIG and 0.5 of commons.
+ * Will release shortly.
+ *
* Revision 1.1 2003/12/09 23:41:44 pelle
* IdentityCreator is now the default class of the uber jar.
***************
*** 107,111 ****
* The email sender works. The LogSender and the SoapSender should work but havent been tested yet.
* The SignedNamedObject has a new log() method that logs it's contents at it's parent Identity's logger.
! * The Identity object also has a new method send() which allows one to send a named object to the Identity's
* default receiver.
*
--- 114,118 ----
* The email sender works. The LogSender and the SoapSender should work but havent been tested yet.
* The SignedNamedObject has a new log() method that logs it's contents at it's parent Identity's logger.
! * The Identity object also has a new method receive() which allows one to receive a named object to the Identity's
* default receiver.
*
***************
*** 189,196 ****
import org.neuclear.id.builders.IdentityBuilder;
import org.neuclear.id.builders.NamedObjectBuilder;
- import org.neuclear.id.resolver.NSResolver;
import org.neuclear.senders.LogSender;
- import java.io.File;
import java.security.PublicKey;
--- 196,201 ----
***************
*** 210,216 ****
// if (!cachedir.exists())
// cachedir.mkdirs();
! if (!Utility.isEmpty(identity)){
of = Utility.denullString(of, "_NEUID" + NSTools.name2path(identity) + "/root.id");
! alias = Utility.denullString(alias, NSTools.getParentNSURI(identity));
}
--- 215,221 ----
// if (!cachedir.exists())
// cachedir.mkdirs();
! if (!Utility.isEmpty(identity)) {
of = Utility.denullString(of, "_NEUID" + NSTools.name2path(identity) + "/root.id");
! alias = Utility.denullString(alias, NSTools.getSignatoryURI(identity));
}
***************
*** 219,234 ****
public final NamedObjectBuilder build() throws Exception {
! NamedObjectBuilder subject=null;
if (cmd.hasOption('i')) {//If we have an input file we load that instead of creating a new one
! subject= super.build();
! identity=subject.getName();
}
String store = NSTools.isHttpScheme(identity);
! boolean isTopLevel=!Utility.isEmpty(store);
if (!isTopLevel) {
// If this isn't a top level we will derive the repository from its parent.
! store=NSTools.isHttpScheme(NSTools.getParentNSURI(identity));
}
! alias=(isTopLevel)?identity:NSTools.getParentNSURI(identity);
final String allow = Utility.denullString(cmd.getOptionValue("w"), identity);
final String defaultstore = Utility.denullString(cmd.getOptionValue("r"), store);
--- 224,239 ----
public final NamedObjectBuilder build() throws Exception {
! NamedObjectBuilder subject = null;
if (cmd.hasOption('i')) {//If we have an input file we load that instead of creating a new one
! subject = super.build();
! identity = subject.getName();
}
String store = NSTools.isHttpScheme(identity);
! boolean isTopLevel = !Utility.isEmpty(store);
if (!isTopLevel) {
// If this isn't a top level we will derive the repository from its parent.
! store = NSTools.isHttpScheme(NSTools.getSignatoryURI(identity));
}
! alias = (isTopLevel) ? identity : NSTools.getSignatoryURI(identity);
final String allow = Utility.denullString(cmd.getOptionValue("w"), identity);
final String defaultstore = Utility.denullString(cmd.getOptionValue("r"), store);
***************
*** 258,262 ****
protected final boolean hasArguments() {
! return (cmd.hasOption("i")||cmd.hasOption('v')||(cmd.hasOption("n") && cmd.hasOption("b")));
}
--- 263,267 ----
protected final boolean hasArguments() {
! return (cmd.hasOption("i") || cmd.hasOption('v') || (cmd.hasOption("n") && cmd.hasOption("b")));
}
|