}
public void Fire(String token, String key) {
try {
DigSigUtil ds = null;
//option 1), set everything manually
ds = new DigSigUtil();
ds.put(DigSigUtil.SIGNATURE_KEYSTORE_FILE, "keystore.jks");
ds.put(DigSigUtil.SIGNATURE_KEYSTORE_FILETYPE, "JKS");
ds.put(DigSigUtil.SIGNATURE_KEYSTORE_FILE_PASSWORD, "Test");
ds.put(DigSigUtil.SIGNATURE_KEYSTORE_KEY_ALIAS, "Test");
ds.put(DigSigUtil.SIGNATURE_OPTION_CERT_INCLUSION_BASE64, "true");
ds.put(DigSigUtil.SIGNATURE_OPTION_CERT_INCLUSION_SERIAL, "true");
ds.put(DigSigUtil.SIGNATURE_OPTION_CERT_INCLUSION_SUBJECTDN, "true");
ds.put(DigSigUtil.TRUSTSTORE_FILE, "truststore.jks");
ds.put(DigSigUtil.TRUSTSTORE_FILETYPE, "JKS");
ds.put(DigSigUtil.TRUSTSTORE_FILE_PASSWORD, "Test");
//option 2), load it from the juddi config file
//ds = new DigSigUtil(clerkManager.getClientConfig().getDigitalSignatureConfiguration());
//login
if (token == null) //option, load from juddi config
{
token = GetAuthKey(clerkManager.getClerk("default").getPublisher(),
clerkManager.getClerk("default").getPassword());
}
if (key == null) {
//make a new business
SaveBusiness sb = new SaveBusiness();
sb.setAuthInfo(token);
BusinessEntity ob = new BusinessEntity();
Name name = new Name();
name.setValue("My Signed Business");
ob.getName().add(name);
sb.getBusinessEntity().add(ob);
//save it
BusinessDetail saveBusiness = publish.saveBusiness(sb);
System.out.println("business created with key " + saveBusiness.getBusinessEntity().get(0).getBusinessKey());
BusinessEntity be = saveBusiness.getBusinessEntity().get(0);
key = be.getBusinessKey();
}
BusinessEntity be = clerkManager.getClerk("default").getBusinessDetail(key);
//sign the copy returned from the UDDI node (it may have made changes)
DigSigUtil.JAXB_ToStdOut(be);
if (!be.getSignature().isEmpty())
{
System.out.println("WARN, the entity with the key " + key + " is already signed! aborting");
return;
}
//if it's already signed, remove all existing signatures
System.out.println("signing");
BusinessEntity signUDDI_JAXBObject = ds.signUddiEntity(be);
DigSigUtil.JAXB_ToStdOut(signUDDI_JAXBObject);
System.out.println("signed, saving");
SaveBusiness sb = new SaveBusiness();
sb.setAuthInfo(token);
sb.getBusinessEntity().add(signUDDI_JAXBObject);
publish.saveBusiness(sb);
System.out.println("saved, fetching");
//validate it again from the server, confirming that it was transformed correctly
GetBusinessDetail gb = new GetBusinessDetail();
gb.setAuthInfo(token);
gb.getBusinessKey().add(be.getBusinessKey());
be = inquiry.getBusinessDetail(gb).getBusinessEntity().get(0);
DigSigUtil.JAXB_ToStdOut(be);
System.out.println("verifing");
AtomicReference<String> msg = new AtomicReference<String>();
boolean verifySigned_UDDI_JAXB_Object = ds.verifySignedUddiEntity(be, msg);
if (verifySigned_UDDI_JAXB_Object) {
System.out.println("signature validation passed (expected)");
} else {
System.out.println("signature validation failed (not expected)");
}