You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by al...@apache.org on 2014/01/09 00:34:33 UTC
svn commit: r1556671 [2/4] - in /juddi/trunk:
juddi-client.net/juddi-client.net/org.apache.juddi.v3.client.config/
juddi-client/src/main/java/org/apache/juddi/v3/client/config/
juddi-client/src/main/java/org/apache/juddi/v3/client/ext/wsdm/
juddi-clien...
Modified: juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiCreatebulk.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiCreatebulk.java?rev=1556671&r1=1556670&r2=1556671&view=diff
==============================================================================
--- juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiCreatebulk.java (original)
+++ juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiCreatebulk.java Wed Jan 8 23:34:32 2014
@@ -38,157 +38,155 @@ import org.uddi.v3_service.UDDISecurityP
*/
public class UddiCreatebulk {
- private static UDDISecurityPortType security = null;
- private static UDDIPublicationPortType publish = null;
+ private static UDDISecurityPortType security = null;
+ private static UDDIPublicationPortType publish = null;
- public UddiCreatebulk() {
- try {
- // create a manager and read the config in the archive;
- // you can use your config file name
- UDDIClient clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml");
- Transport transport = clerkManager.getTransport();
- // Now you create a reference to the UDDI API
- security = transport.getUDDISecurityService();
- publish = transport.getUDDIPublishService();
- } catch (Exception e) {
- e.printStackTrace();
+ public UddiCreatebulk() {
+ try {
+ // create a manager and read the config in the archive;
+ // you can use your config file name
+ UDDIClient clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml");
+ Transport transport = clerkManager.getTransport();
+ // Now you create a reference to the UDDI API
+ security = transport.getUDDISecurityService();
+ publish = transport.getUDDIPublishService();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
- }
- public void publish() {
- try {
- // Setting up the values to get an authentication token for the 'root' user ('root' user has admin privileges
- // and can save other publishers).
- GetAuthToken getAuthTokenRoot = new GetAuthToken();
- getAuthTokenRoot.setUserID("root");
- getAuthTokenRoot.setCred("root");
-
- // Making API call that retrieves the authentication token for the 'root' user.
- AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot);
- System.out.println("root AUTHTOKEN = " + rootAuthToken.getAuthInfo());
-
- int servicesPerBusiness = 5;
- int businesses = 15;
-
- DatatypeFactory df = DatatypeFactory.newInstance();
- GregorianCalendar gcal = new GregorianCalendar();
- gcal.setTimeInMillis(System.currentTimeMillis());
- XMLGregorianCalendar xcal = df.newXMLGregorianCalendar(gcal);
- for (int i = 0; i < businesses; i++) {
- // Creating the parent business entity that will contain our service.
- BusinessEntity myBusEntity = new BusinessEntity();
- Name myBusName = new Name();
- myBusName.setLang("en");
- myBusName.setValue("My Business " + i + " " + xcal.toString());
- myBusEntity.getName().add(myBusName);
-
- // Adding the business entity to the "save" structure, using our publisher's authentication info and saving away.
- SaveBusiness sb = new SaveBusiness();
- sb.getBusinessEntity().add(myBusEntity);
- sb.setAuthInfo(rootAuthToken.getAuthInfo());
- BusinessDetail bd = publish.saveBusiness(sb);
- String myBusKey = bd.getBusinessEntity().get(0).getBusinessKey();
- System.out.println("myBusiness key: " + myBusKey);
- for (int k = 0; k < servicesPerBusiness; k++) {
- // Creating a service to save. Only adding the minimum data: the parent business key retrieved from saving the business
- // above and a single name.
- BusinessService myService = new BusinessService();
- myService.setBusinessKey(myBusKey);
- Name myServName = new Name();
- myServName.setLang("en");
- myServName.setValue("My Service " + i + " " + k + " " + xcal.toString());
- myService.getName().add(myServName);
- Description d2 = new Description();
- d2.setValue("my service description");
- d2.setLang("en");
- myService.getDescription().add(d2);
- // Add binding templates, etc...
- BindingTemplate myBindingTemplate = new BindingTemplate();
- myBindingTemplate.setCategoryBag(new CategoryBag());
- KeyedReference kr = new KeyedReference();
- kr.setTModelKey(UDDIConstants.TRANSPORT_HTTP);
- kr.setKeyName("keyname1");
- kr.setKeyValue("myvalue1");
-
- myBindingTemplate.getCategoryBag().getKeyedReference().add(kr);
-
- KeyedReferenceGroup krg = new KeyedReferenceGroup();
- krg.setTModelKey(UDDIConstants.TRANSPORT_HTTP);
- kr = new KeyedReference();
- kr.setTModelKey(UDDIConstants.PROTOCOL_SSLv3);
- kr.setKeyName("keyname1grp");
- kr.setKeyValue("myvalue1grp");
-
- krg.getKeyedReference().add(kr);
- myBindingTemplate.getCategoryBag().getKeyedReferenceGroup().add(krg);
-
-
- myService.setCategoryBag(new CategoryBag());
-
- kr = new KeyedReference();
- kr.setTModelKey(UDDIConstants.TRANSPORT_HTTP);
- kr.setKeyName("Servicekeyname2grp");
- kr.setKeyValue("Servicemyvalue2grp");
- myService.getCategoryBag().getKeyedReference().add(kr);
-
- krg = new KeyedReferenceGroup();
- krg.setTModelKey(UDDIConstants.TRANSPORT_HTTP);
- kr = new KeyedReference();
- kr.setTModelKey(UDDIConstants.TRANSPORT_HTTP);
- kr.setKeyName("keyname1grp");
- kr.setKeyValue("myvalue1grp");
-
- krg.getKeyedReference().add(kr);
- myService.getCategoryBag().getKeyedReferenceGroup().add(krg);
-
- AccessPoint accessPoint = new AccessPoint();
- accessPoint.setUseType(AccessPointType.WSDL_DEPLOYMENT.toString());
- accessPoint.setValue("http://example.org/services/myservice" + i + k + "?wsdl");
- myBindingTemplate.setAccessPoint(accessPoint);
- myBindingTemplate.setTModelInstanceDetails(new TModelInstanceDetails());
- TModelInstanceInfo tii = new TModelInstanceInfo();
- Description d = new Description();
- d.setValue("Tmodel instance description");
- tii.getDescription().add(d);
- tii.setTModelKey(UDDIConstants.TRANSPORT_HTTP);
- tii.setInstanceDetails(new InstanceDetails());
- tii.getInstanceDetails().setInstanceParms("heres some useful stuff describing this endpoint, up to 4KB of data");
- tii.getInstanceDetails().getDescription().add(d);
- OverviewDoc od = new OverviewDoc();
- d = new Description();
- d.setValue("ovweview doc description");
- od.getDescription().add(d);
- od.setOverviewURL(new OverviewURL());
- od.getOverviewURL().setUseType("www");
- od.getOverviewURL().setValue("www.apache.org");
- tii.getInstanceDetails().getOverviewDoc().add(od);
- myBindingTemplate.getTModelInstanceDetails().getTModelInstanceInfo().add(tii);
-
-
- BindingTemplates myBindingTemplates = new BindingTemplates();
- myBindingTemplate = UDDIClient.addSOAPtModels(myBindingTemplate);
- myBindingTemplates.getBindingTemplate().add(myBindingTemplate);
- myService.setBindingTemplates(myBindingTemplates);
- try {
- // Adding the service to the "save" structure, using our publisher's authentication info and saving away.
- SaveService ss = new SaveService();
- ss.getBusinessService().add(myService);
- ss.setAuthInfo(rootAuthToken.getAuthInfo());
- ServiceDetail sd = publish.saveService(ss);
- String myServKey = sd.getBusinessService().get(0).getServiceKey();
- System.out.println("myService key: " + myServKey);
- } catch (Exception x) {
- x.printStackTrace();
- }
+ public void publishBusiness(String token, int businesses, int servicesPerBusiness) {
+ try {
+ // Setting up the values to get an authentication token for the 'root' user ('root' user has admin privileges
+ // and can save other publishers).
+ if (token == null) {
+ GetAuthToken getAuthTokenRoot = new GetAuthToken();
+ getAuthTokenRoot.setUserID("root");
+ getAuthTokenRoot.setCred("root");
+
+ // Making API call that retrieves the authentication token for the 'root' user.
+ AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot);
+ System.out.println("root AUTHTOKEN = " + "don't log auth tokens!");
+ token = rootAuthToken.getAuthInfo();
+ }
+
+ DatatypeFactory df = DatatypeFactory.newInstance();
+ GregorianCalendar gcal = new GregorianCalendar();
+ gcal.setTimeInMillis(System.currentTimeMillis());
+ XMLGregorianCalendar xcal = df.newXMLGregorianCalendar(gcal);
+ for (int i = 0; i < businesses; i++) {
+ // Creating the parent business entity that will contain our service.
+ BusinessEntity myBusEntity = new BusinessEntity();
+ Name myBusName = new Name();
+ myBusName.setLang("en");
+ myBusName.setValue("My Business " + i + " " + xcal.toString());
+ myBusEntity.getName().add(myBusName);
+
+ // Adding the business entity to the "save" structure, using our publisher's authentication info and saving away.
+ SaveBusiness sb = new SaveBusiness();
+ sb.getBusinessEntity().add(myBusEntity);
+ sb.setAuthInfo(token);
+ BusinessDetail bd = publish.saveBusiness(sb);
+ String myBusKey = bd.getBusinessEntity().get(0).getBusinessKey();
+ System.out.println("saved: Business key: " + myBusKey);
+ for (int k = 0; k < servicesPerBusiness; k++) {
+ // Creating a service to save. Only adding the minimum data: the parent business key retrieved from saving the business
+ // above and a single name.
+ BusinessService myService = new BusinessService();
+ myService.setBusinessKey(myBusKey);
+ Name myServName = new Name();
+ myServName.setLang("en");
+ myServName.setValue("My Service " + i + " " + k + " " + xcal.toString());
+ myService.getName().add(myServName);
+ Description d2 = new Description();
+ d2.setValue("my service description");
+ d2.setLang("en");
+ myService.getDescription().add(d2);
+ // Add binding templates, etc...
+ BindingTemplate myBindingTemplate = new BindingTemplate();
+ myBindingTemplate.setCategoryBag(new CategoryBag());
+ KeyedReference kr = new KeyedReference();
+ kr.setTModelKey(UDDIConstants.TRANSPORT_HTTP);
+ kr.setKeyName("keyname1");
+ kr.setKeyValue("myvalue1");
+
+ myBindingTemplate.getCategoryBag().getKeyedReference().add(kr);
+
+ KeyedReferenceGroup krg = new KeyedReferenceGroup();
+ krg.setTModelKey(UDDIConstants.TRANSPORT_HTTP);
+ kr = new KeyedReference();
+ kr.setTModelKey(UDDIConstants.PROTOCOL_SSLv3);
+ kr.setKeyName("keyname1grp");
+ kr.setKeyValue("myvalue1grp");
+
+ krg.getKeyedReference().add(kr);
+ myBindingTemplate.getCategoryBag().getKeyedReferenceGroup().add(krg);
+
+ myService.setCategoryBag(new CategoryBag());
+
+ kr = new KeyedReference();
+ kr.setTModelKey(UDDIConstants.TRANSPORT_HTTP);
+ kr.setKeyName("Servicekeyname2grp");
+ kr.setKeyValue("Servicemyvalue2grp");
+ myService.getCategoryBag().getKeyedReference().add(kr);
+
+ krg = new KeyedReferenceGroup();
+ krg.setTModelKey(UDDIConstants.TRANSPORT_HTTP);
+ kr = new KeyedReference();
+ kr.setTModelKey(UDDIConstants.TRANSPORT_HTTP);
+ kr.setKeyName("keyname1grp");
+ kr.setKeyValue("myvalue1grp");
+
+ krg.getKeyedReference().add(kr);
+ myService.getCategoryBag().getKeyedReferenceGroup().add(krg);
+
+ AccessPoint accessPoint = new AccessPoint();
+ accessPoint.setUseType(AccessPointType.WSDL_DEPLOYMENT.toString());
+ accessPoint.setValue("http://example.org/services/myservice" + i + k + "?wsdl");
+ myBindingTemplate.setAccessPoint(accessPoint);
+ myBindingTemplate.setTModelInstanceDetails(new TModelInstanceDetails());
+ TModelInstanceInfo tii = new TModelInstanceInfo();
+ Description d = new Description();
+ d.setValue("Tmodel instance description");
+ tii.getDescription().add(d);
+ tii.setTModelKey(UDDIConstants.TRANSPORT_HTTP);
+ tii.setInstanceDetails(new InstanceDetails());
+ tii.getInstanceDetails().setInstanceParms("heres some useful stuff describing this endpoint, up to 4KB of data");
+ tii.getInstanceDetails().getDescription().add(d);
+ OverviewDoc od = new OverviewDoc();
+ d = new Description();
+ d.setValue("ovweview doc description");
+ od.getDescription().add(d);
+ od.setOverviewURL(new OverviewURL());
+ od.getOverviewURL().setUseType("www");
+ od.getOverviewURL().setValue("www.apache.org");
+ tii.getInstanceDetails().getOverviewDoc().add(od);
+ myBindingTemplate.getTModelInstanceDetails().getTModelInstanceInfo().add(tii);
+
+ BindingTemplates myBindingTemplates = new BindingTemplates();
+ myBindingTemplate = UDDIClient.addSOAPtModels(myBindingTemplate);
+ myBindingTemplates.getBindingTemplate().add(myBindingTemplate);
+ myService.setBindingTemplates(myBindingTemplates);
+ try {
+ // Adding the service to the "save" structure, using our publisher's authentication info and saving away.
+ SaveService ss = new SaveService();
+ ss.getBusinessService().add(myService);
+ ss.setAuthInfo(token);
+ ServiceDetail sd = publish.saveService(ss);
+ String myServKey = sd.getBusinessService().get(0).getServiceKey();
+ System.out.println("saved: service key: " + myServKey);
+ } catch (Exception x) {
+ x.printStackTrace();
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
}
- }
- } catch (Exception e) {
- e.printStackTrace();
}
- }
- public static void main(String args[]) {
- UddiCreatebulk sp = new UddiCreatebulk();
- sp.publish();
- }
+ public static void main(String args[]) {
+ UddiCreatebulk sp = new UddiCreatebulk();
+ sp.publishBusiness(null, 15, 20);
+ }
}
Modified: juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiCustodyTransfer.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiCustodyTransfer.java?rev=1556671&r1=1556670&r2=1556671&view=diff
==============================================================================
--- juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiCustodyTransfer.java (original)
+++ juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiCustodyTransfer.java Wed Jan 8 23:34:32 2014
@@ -21,7 +21,6 @@ import javax.xml.datatype.DatatypeFactor
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.ws.Holder;
import org.apache.juddi.v3.client.config.UDDIClient;
-import org.apache.juddi.v3.client.config.UDDIClientContainer;
import org.apache.juddi.v3.client.transport.Transport;
import org.uddi.api_v3.*;
import org.uddi.custody_v3.KeyBag;
@@ -31,7 +30,6 @@ import org.uddi.v3_service.UDDICustodyTr
import org.uddi.v3_service.UDDIInquiryPortType;
import org.uddi.v3_service.UDDIPublicationPortType;
import org.uddi.v3_service.UDDISecurityPortType;
-import org.uddi.v3_service.UDDISubscriptionPortType;
/**
* This provides an example of how to transfer custody of a business from one
@@ -41,149 +39,121 @@ import org.uddi.v3_service.UDDISubscript
*/
public class UddiCustodyTransfer {
- private static UDDISecurityPortType security = null;
- private static UDDIPublicationPortType publish = null;
- private static UDDIInquiryPortType uddiInquiryService = null;
- private static UDDISubscriptionPortType uddiSubscriptionService = null;
- private static UDDICustodyTransferPortType custodyTransferPortType = null;
- boolean callbackRecieved = false;
-
- public UddiCustodyTransfer() {
- try {
- // create a manager and read the config in the archive;
- // you can use your config file name
- UDDIClient clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml");
- Transport transport = clerkManager.getTransport();
- // Now you create a reference to the UDDI API
- security = transport.getUDDISecurityService();
-
- publish = transport.getUDDIPublishService();
- uddiInquiryService = transport.getUDDIInquiryService();
- uddiSubscriptionService = transport.getUDDISubscriptionService();
- custodyTransferPortType = transport.getUDDICustodyTransferService();
- } catch (Exception e) {
- e.printStackTrace();
+ private static UDDISecurityPortType security = null;
+ private static UDDIPublicationPortType publish = null;
+ private static UDDIInquiryPortType uddiInquiryService = null;
+ private static UDDICustodyTransferPortType custodyTransferPortType = null;
+
+ public UddiCustodyTransfer() {
+ try {
+ // create a manager and read the config in the archive;
+ // you can use your config file name
+ UDDIClient clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml");
+ Transport transport = clerkManager.getTransport();
+ // Now you create a reference to the UDDI API
+ security = transport.getUDDISecurityService();
+
+ publish = transport.getUDDIPublishService();
+ uddiInquiryService = transport.getUDDIInquiryService();
+ custodyTransferPortType = transport.getUDDICustodyTransferService();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
- }
- public static void main(String args[]) throws Exception {
- UddiCustodyTransfer sp = new UddiCustodyTransfer();
- sp.Transfer();
- }
-
- private void Transfer() throws Exception {
-
- DatatypeFactory df = DatatypeFactory.newInstance();
- GregorianCalendar gcal = new GregorianCalendar();
- gcal.setTimeInMillis(System.currentTimeMillis());
- XMLGregorianCalendar xcal = df.newXMLGregorianCalendar(gcal);
-
- GetAuthToken getAuthTokenRoot = new GetAuthToken();
- getAuthTokenRoot.setUserID("root");
- getAuthTokenRoot.setCred("root");
-
- // Making API call that retrieves the authentication token for the 'root' user.
- AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot);
- System.out.println("root AUTHTOKEN = " + rootAuthToken.getAuthInfo());
-
-
- getAuthTokenRoot = new GetAuthToken();
- getAuthTokenRoot.setUserID("uddi");
- getAuthTokenRoot.setCred("uddi");
-
- // Making API call that retrieves the authentication token for the 'root' user.
- AuthToken uddiAuthToken = security.getAuthToken(getAuthTokenRoot);
- System.out.println("uddi AUTHTOKEN = " + rootAuthToken.getAuthInfo());
-
- //first publish a business user the user uddi
- BusinessEntity myBusEntity = new BusinessEntity();
- Name myBusName = new Name();
- myBusName.setLang("en");
- myBusName.setValue("UDDI's Business" + " " + xcal.toString());
- myBusEntity.getName().add(myBusName);
- myBusEntity.setBusinessServices(new BusinessServices());
- myBusEntity.getBusinessServices().getBusinessService().add(CreateBusinessService("UDDI"));
- SaveBusiness sb = new SaveBusiness();
- sb.getBusinessEntity().add(myBusEntity);
- sb.setAuthInfo(uddiAuthToken.getAuthInfo());
- BusinessDetail bd = publish.saveBusiness(sb);
-
- String keyUddiBiz = bd.getBusinessEntity().get(0).getBusinessKey();
-
- //create a business for the ROOT user
- myBusEntity = new BusinessEntity();
- myBusName = new Name();
- myBusName.setLang("en");
- myBusName.setValue("Root's Business" + " " + xcal.toString());
- myBusEntity.getName().add(myBusName);
- myBusEntity.setBusinessServices(new BusinessServices());
- myBusEntity.getBusinessServices().getBusinessService().add(CreateBusinessService("root"));
- sb = new SaveBusiness();
- sb.getBusinessEntity().add(myBusEntity);
- sb.setAuthInfo(rootAuthToken.getAuthInfo());
- bd = publish.saveBusiness(sb);
-
- String keyRootBiz = bd.getBusinessEntity().get(0).getBusinessKey();
-
-
- //Create a transfer token from ROOT to UDDI
- KeyBag kb = new KeyBag();
- kb.getKey().add(keyRootBiz);
- Holder<String> nodeidOUT = new Holder<String>();
- Holder<XMLGregorianCalendar> expiresOUT = new Holder<XMLGregorianCalendar>();
- Holder<byte[]> tokenOUT = new Holder<byte[]>();
- custodyTransferPortType.getTransferToken(rootAuthToken.getAuthInfo(), kb, nodeidOUT, expiresOUT, tokenOUT);
-
- //The magic part happens here, the user ROOT needs to give the user UDDI the token information out of band
- //in practice, all values must match exactly
-
- //UDDI now accepts the transfer
- TransferEntities te = new TransferEntities();
- te.setAuthInfo(uddiAuthToken.getAuthInfo());
- te.setKeyBag(kb);
- TransferToken tt = new TransferToken();
- tt.setExpirationTime(expiresOUT.value);
- tt.setNodeID(nodeidOUT.value);
- tt.setOpaqueToken(tokenOUT.value);
- te.setTransferToken(tt);
- custodyTransferPortType.transferEntities(te);
-
- //confirm the transfer
- GetOperationalInfo go = new GetOperationalInfo();
- go.setAuthInfo(rootAuthToken.getAuthInfo());
- go.getEntityKey().add(keyRootBiz);
- go.getEntityKey().add(keyUddiBiz);
- OperationalInfos operationalInfo = uddiInquiryService.getOperationalInfo(go);
- boolean ok = false;
- for (int i = 0; i < operationalInfo.getOperationalInfo().size(); i++) {
- if (operationalInfo.getOperationalInfo().get(i).getEntityKey().equalsIgnoreCase(keyRootBiz)) {
- if (operationalInfo.getOperationalInfo().get(i).getAuthorizedName().equalsIgnoreCase("root")) {
- //no suprise here
- }
- } else if (operationalInfo.getOperationalInfo().get(i).getEntityKey().equalsIgnoreCase(keyUddiBiz)) {
- if (operationalInfo.getOperationalInfo().get(i).getAuthorizedName().equalsIgnoreCase("uddi")) {
- //success
- ok = true;
+ public static void main(String args[]) throws Exception {
+ UddiCustodyTransfer sp = new UddiCustodyTransfer();
+
+ GetAuthToken getAuthTokenRoot = new GetAuthToken();
+ getAuthTokenRoot.setUserID("root");
+ getAuthTokenRoot.setCred("root");
+
+ // Making API call that retrieves the authentication token for the 'root' user.
+ AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot);
+ System.out.println("root AUTHTOKEN = " + "don't log auth tokens!");
+
+ getAuthTokenRoot = new GetAuthToken();
+ getAuthTokenRoot.setUserID("uddi");
+ getAuthTokenRoot.setCred("uddi");
+
+ // Making API call that retrieves the authentication token for the 'root' user.
+ AuthToken uddiAuthToken = security.getAuthToken(getAuthTokenRoot);
+ System.out.println("uddi AUTHTOKEN = " + "don't log auth tokens!");
+ BusinessEntity biz = sp.CreateBusiness("uddi");
+
+
+
+ //save user uddi's business
+ SaveBusiness sb = new SaveBusiness();
+ sb.setAuthInfo(uddiAuthToken.getAuthInfo());
+ sb.getBusinessEntity().add(biz);
+ BusinessDetail saveBusiness = publish.saveBusiness(sb);
+
+
+ sp.TransferBusiness(uddiAuthToken.getAuthInfo(), "uddi", rootAuthToken.getAuthInfo(), "root", saveBusiness.getBusinessEntity().get(0).getBusinessKey());
+ }
+
+ public void TransferBusiness(String fromUser, String fromUserAuthToken, String toUser, String toUserAuthToken,
+ String BusinessKey) throws Exception {
+
+ System.out.println("Transfering business key " + BusinessKey);
+ DatatypeFactory df = DatatypeFactory.newInstance();
+ GregorianCalendar gcal = new GregorianCalendar();
+ gcal.setTimeInMillis(System.currentTimeMillis());
+ XMLGregorianCalendar xcal = df.newXMLGregorianCalendar(gcal);
+
+
+
+ //Create a transfer token from fromUser to toUser
+ KeyBag kb = new KeyBag();
+ kb.getKey().add(BusinessKey);
+ Holder<String> nodeidOUT = new Holder<String>();
+ Holder<XMLGregorianCalendar> expiresOUT = new Holder<XMLGregorianCalendar>();
+ Holder<byte[]> tokenOUT = new Holder<byte[]>();
+ custodyTransferPortType.getTransferToken(fromUser, kb, nodeidOUT, expiresOUT, tokenOUT);
+
+ //The magic part happens here, the user ROOT needs to give the user UDDI the token information out of band
+ //in practice, all values must match exactly
+ //UDDI now accepts the transfer
+ TransferEntities te = new TransferEntities();
+ te.setAuthInfo(toUser);
+ te.setKeyBag(kb);
+ TransferToken tt = new TransferToken();
+ tt.setExpirationTime(expiresOUT.value);
+ tt.setNodeID(nodeidOUT.value);
+ tt.setOpaqueToken(tokenOUT.value);
+ te.setTransferToken(tt);
+ custodyTransferPortType.transferEntities(te);
+
+ //confirm the transfer
+ GetOperationalInfo go = new GetOperationalInfo();
+ go.setAuthInfo(fromUser);
+ go.getEntityKey().add(BusinessKey);
+ OperationalInfos operationalInfo = uddiInquiryService.getOperationalInfo(go);
+ boolean ok = false;
+ for (int i = 0; i < operationalInfo.getOperationalInfo().size(); i++) {
+ if (operationalInfo.getOperationalInfo().get(i).getEntityKey().equalsIgnoreCase(BusinessKey)) {
+ if (operationalInfo.getOperationalInfo().get(i).getAuthorizedName().equalsIgnoreCase(fromUser)) {
+ System.out.println("Transfer unexpected failed");
+ }
+ } else if (operationalInfo.getOperationalInfo().get(i).getEntityKey().equalsIgnoreCase(BusinessKey)) {
+ if (operationalInfo.getOperationalInfo().get(i).getAuthorizedName().equalsIgnoreCase(toUser)) {
+ //success
+ ok = true;
+ }
+ } else {
+ System.out.println("the key wasn't found!");
+ }
}
- } else {
- System.out.println("unexpected key");
- }
+
+ System.out.println("Transfer " + (ok ? "success" : " failed"));
}
- System.out.println("Transfer " + (ok ? "success" : " failed"));
- }
+ private BusinessEntity CreateBusiness(String user) {
+ BusinessEntity be = new BusinessEntity();
+ be.getName().add(new Name(user + "'s business", null));
+ return be;
+ }
- private BusinessService CreateBusinessService(String user) {
- BusinessService bs = new BusinessService();
- bs.getName().add(new Name());
- bs.getName().get(0).setValue(user + "'s callback endpoint");
- bs.setBindingTemplates(new BindingTemplates());
- BindingTemplate bt = new BindingTemplate();
- bt.setAccessPoint(new AccessPoint());
- bt.getAccessPoint().setValue("http://localhost:9999/" + user);
- bt.getAccessPoint().setUseType("endPoint");
- bt = UDDIClient.addSOAPtModels(bt);
- bs.getBindingTemplates().getBindingTemplate().add(bt);
- return bs;
- }
+
}
Modified: juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiDigitalSignatureBusiness.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiDigitalSignatureBusiness.java?rev=1556671&r1=1556670&r2=1556671&view=diff
==============================================================================
--- juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiDigitalSignatureBusiness.java (original)
+++ juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiDigitalSignatureBusiness.java Wed Jan 8 23:34:32 2014
@@ -34,145 +34,151 @@ import org.uddi.v3_service.UDDISecurityP
*/
public class UddiDigitalSignatureBusiness {
- private static UDDISecurityPortType security = null;
- private static UDDIInquiryPortType inquiry = null;
- private static UDDIPublicationPortType publish = null;
- private static UDDIClient clerkManager = null;
-
- /**
- * This sets up the ws proxies using uddi.xml in META-INF
- */
- public UddiDigitalSignatureBusiness() {
- try {
- // create a manager and read the config in the archive;
- // you can use your config file name
- clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml");
- Transport transport = clerkManager.getTransport();
- // Now you create a reference to the UDDI API
- security = transport.getUDDISecurityService();
- inquiry = transport.getUDDIInquiryService();
- publish = transport.getUDDIPublishService();
- } catch (Exception e) {
- e.printStackTrace();
+ private static UDDISecurityPortType security = null;
+ private static UDDIInquiryPortType inquiry = null;
+ private static UDDIPublicationPortType publish = null;
+ private static UDDIClient clerkManager = null;
+
+ /**
+ * This sets up the ws proxies using uddi.xml in META-INF
+ */
+ public UddiDigitalSignatureBusiness() {
+ try {
+ // create a manager and read the config in the archive;
+ // you can use your config file name
+ clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml");
+ Transport transport = clerkManager.getTransport();
+ // Now you create a reference to the UDDI API
+ security = transport.getUDDISecurityService();
+ inquiry = transport.getUDDIInquiryService();
+ publish = transport.getUDDIPublishService();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
- }
- /**
- * Main entry point
- *
- * @param args
- */
- public static void main(String args[]) {
-
- UddiDigitalSignatureBusiness sp = new UddiDigitalSignatureBusiness();
- sp.Fire(args);
- }
-
- public void Fire(String[] args) {
- 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");
- //this flag will cause juddi to crash until JUDDI-716 is fixed
- //TODO JUDDI-716
- //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
- String token = null;
- //option, load from juddi config
- token = GetAuthKey(clerkManager.getClerk("default").getPublisher(),
- clerkManager.getClerk("default").getPassword());
-
- //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);
- //sign the copy returned from the UDDI node (it may have made changes)
- DigSigUtil.JAXB_ToStdOut(be);
-
- //if it's already signed, remove all existing signatures
-
- be.getSignature().clear();
- System.out.println("signing");
- BusinessEntity signUDDI_JAXBObject = ds.signUddiEntity(be);
- DigSigUtil.JAXB_ToStdOut(signUDDI_JAXBObject);
- System.out.println("signed, saving");
-
- 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)");
- }
- System.out.println(msg.get());
+ /**
+ * Main entry point
+ *
+ * @param args
+ */
+ public static void main(String args[]) {
- } catch (Exception e) {
- e.printStackTrace();
+ UddiDigitalSignatureBusiness sp = new UddiDigitalSignatureBusiness();
+ sp.Fire(null, null);
}
- }
- /**
- * Gets a UDDI style auth token, otherwise, appends credentials to the ws
- * proxies (not yet implemented)
- *
- * @param username
- * @param password
- * @param style
- * @return
- */
- private String GetAuthKey(String username, String password) {
- try {
-
- GetAuthToken getAuthTokenRoot = new GetAuthToken();
- getAuthTokenRoot.setUserID(username);
- getAuthTokenRoot.setCred(password);
-
- // Making API call that retrieves the authentication token for the 'root' user.
- AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot);
- System.out.println("root AUTHTOKEN = " + rootAuthToken.getAuthInfo());
- return rootAuthToken.getAuthInfo();
- } catch (Exception ex) {
- System.out.println("Could not authenticate with the provided credentials " + ex.getMessage());
+ 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)");
+ }
+ System.out.println(msg.get());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Gets a UDDI style auth token, otherwise, appends credentials to the
+ * ws proxies (not yet implemented)
+ *
+ * @param username
+ * @param password
+ * @param style
+ * @return
+ */
+ private String GetAuthKey(String username, String password) {
+ try {
+
+ GetAuthToken getAuthTokenRoot = new GetAuthToken();
+ getAuthTokenRoot.setUserID(username);
+ getAuthTokenRoot.setCred(password);
+
+ // Making API call that retrieves the authentication token for the 'root' user.
+ AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot);
+ System.out.println("root AUTHTOKEN = " + "don't log auth tokens!");
+ return rootAuthToken.getAuthInfo();
+ } catch (Exception ex) {
+ System.out.println("Could not authenticate with the provided credentials " + ex.getMessage());
+ }
+ return null;
}
- return null;
- }
}
Modified: juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiDigitalSignatureSearch.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiDigitalSignatureSearch.java?rev=1556671&r1=1556670&r2=1556671&view=diff
==============================================================================
--- juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiDigitalSignatureSearch.java (original)
+++ juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiDigitalSignatureSearch.java Wed Jan 8 23:34:32 2014
@@ -63,18 +63,21 @@ public class UddiDigitalSignatureSearch
public static void main(String args[]) {
UddiDigitalSignatureSearch sp = new UddiDigitalSignatureSearch();
- sp.Fire(args);
+ sp.Fire(null);
}
- public void Fire(String[] args) {
+ public void Fire(String token) {
try {
FindService fs = new FindService();
//optional, usually
- fs.setAuthInfo(GetAuthKey("root", "root"));
+ if (token==null)
+ token=GetAuthKey("root", "root");
+ fs.setAuthInfo(token);
fs.setFindQualifiers(new FindQualifiers());
fs.getFindQualifiers().getFindQualifier().add(UDDIConstants.SORT_BY_DATE_ASC);
- fs.getFindQualifiers().getFindQualifier().add(UDDIConstants.SORT_BY_DATE_DESC);
+ fs.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
+ fs.getFindQualifiers().getFindQualifier().add(UDDIConstants.SIGNATURE_PRESENT);
Name n = new Name();
n.setValue("%");
fs.getName().add(n);
@@ -105,7 +108,7 @@ public class UddiDigitalSignatureSearch
// Making API call that retrieves the authentication token for the 'root' user.
AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot);
- System.out.println("root AUTHTOKEN = " + rootAuthToken.getAuthInfo());
+ System.out.println("root AUTHTOKEN = " + "dont log auth tokens!");
return rootAuthToken.getAuthInfo();
} catch (Exception ex) {
System.out.println("Could not authenticate with the provided credentials " + ex.getMessage());
Modified: juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiDigitalSignatureService.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiDigitalSignatureService.java?rev=1556671&r1=1556670&r2=1556671&view=diff
==============================================================================
--- juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiDigitalSignatureService.java (original)
+++ juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiDigitalSignatureService.java Wed Jan 8 23:34:32 2014
@@ -33,128 +33,157 @@ import org.uddi.v3_service.UDDISecurityP
*/
public class UddiDigitalSignatureService {
- private static UDDISecurityPortType security = null;
- private static UDDIInquiryPortType inquiry = null;
- private static UDDIPublicationPortType publish = null;
- private static UDDIClient clerkManager = null;
-
- /**
- * This sets up the ws proxies using uddi.xml in META-INF
- */
- public UddiDigitalSignatureService() {
- try {
+ private static UDDISecurityPortType security = null;
+ private static UDDIInquiryPortType inquiry = null;
+ private static UDDIPublicationPortType publish = null;
+ private static UDDIClient clerkManager = null;
+
+ /**
+ * This sets up the ws proxies using uddi.xml in META-INF
+ */
+ public UddiDigitalSignatureService() {
+ try {
// create a manager and read the config in the archive;
- // you can use your config file name
- clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml");
- Transport transport = clerkManager.getTransport();
- // Now you create a reference to the UDDI API
- security = transport.getUDDISecurityService();
- inquiry = transport.getUDDIInquiryService();
- publish = transport.getUDDIPublishService();
- } catch (Exception e) {
- e.printStackTrace();
+ // you can use your config file name
+ clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml");
+ Transport transport = clerkManager.getTransport();
+ // Now you create a reference to the UDDI API
+ security = transport.getUDDISecurityService();
+ inquiry = transport.getUDDIInquiryService();
+ publish = transport.getUDDIPublishService();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
- }
- /**
- * Main entry point
- *
- * @param args
- */
- public static void main(String args[]) {
-
- UddiDigitalSignatureService sp = new UddiDigitalSignatureService();
- sp.Fire(args);
- }
-
- public void Fire(String[] args) {
- 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, "password");
- ds.put(DigSigUtil.SIGNATURE_KEYSTORE_KEY_ALIAS, "selfsigned");
- ds.put(DigSigUtil.SIGNATURE_OPTION_CERT_INCLUSION_BASE64, "true");
+ /**
+ * Main entry point
+ *
+ * @param args
+ */
+ public static void main(String args[]) {
- //option 2), load it from the juddi config file
- //ds = new DigSigUtil(clerkManager.getClientConfig().getDigitalSignatureConfiguration());
+ UddiDigitalSignatureService sp = new UddiDigitalSignatureService();
+ sp.Fire(null, null);
+ }
+
+ public void Fire(String token, String key) {
+ try {
+
+ DigSigUtil ds = null;
- //login
- String token = null;
- //option, load from juddi config
- token = GetAuthKey(clerkManager.getClerk("default").getPublisher(),
- clerkManager.getClerk("default").getPassword());
-
- //TODO replace this with something more useful
- String key = "uddi:juddi.apache.org:da314f49-b84f-4ede-a434-0b0178632f10";
- BusinessService be = null;
- be = GetServiceDetails(key);
- be.getSignature().clear();
- //DigSigUtil.JAXB_ToStdOut(be);
- System.out.println("signing");
- BusinessService signUDDI_JAXBObject = ds.signUddiEntity(be);
- DigSigUtil.JAXB_ToStdOut(signUDDI_JAXBObject);
- System.out.println("signed, saving");
-
- SaveService sb = new SaveService();
- sb.setAuthInfo(token);
- sb.getBusinessService().add(signUDDI_JAXBObject);
- publish.saveService(sb);
- System.out.println("saved, fetching");
-
-
- be = GetServiceDetails(key);
- 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)");
- }
- System.out.println(msg.get());
+ ds = new DigSigUtil();
+ //option 1), set everything manually
+ 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) {
+ SaveBusiness sb = new SaveBusiness();
+ sb.setAuthInfo(token);
+ BusinessEntity ob = new BusinessEntity();
+ Name name = new Name();
+ name.setValue("My Signed Business");
+ ob.getName().add(name);
+ ob.setBusinessServices(new BusinessServices());
+ BusinessService bs = new BusinessService();
+ bs.getName().add(new Name("My signed service", null));
+ ob.getBusinessServices().getBusinessService().add(bs);
+ sb.getBusinessEntity().add(ob);
+ //save it
+ BusinessDetail saveBusiness = publish.saveBusiness(sb);
+
+ System.out.println("business created with key " + saveBusiness.getBusinessEntity().get(0).getBusinessKey());
+
+ key = saveBusiness.getBusinessEntity().get(0).getBusinessServices().getBusinessService().get(0).getServiceKey();
+ }
+
+ BusinessService be = null;
+ be = GetServiceDetails(key);
+ if (!be.getSignature().isEmpty())
+ {
+ System.out.println("WARN, the entity with the key " + key + " is already signed! aborting");
+ return;
+ }
+
+ //DigSigUtil.JAXB_ToStdOut(be);
+ System.out.println("signing");
+ BusinessService signUDDI_JAXBObject = ds.signUddiEntity(be);
+ DigSigUtil.JAXB_ToStdOut(signUDDI_JAXBObject);
+ System.out.println("signed, saving");
+
+ SaveService sb = new SaveService();
+ sb.setAuthInfo(token);
+ sb.getBusinessService().add(signUDDI_JAXBObject);
+ publish.saveService(sb);
+ System.out.println("saved, fetching");
+
+ be = GetServiceDetails(key);
+ 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)");
+ }
+ System.out.println(msg.get());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
- } catch (Exception e) {
- e.printStackTrace();
+ private BusinessService GetServiceDetails(String key) throws Exception {
+ // BusinessInfo get
+ GetServiceDetail r = new GetServiceDetail();
+ //GetBusinessDetail r = new GetBusinessDetail();
+ r.getServiceKey().add(key);
+ return inquiry.getServiceDetail(r).getBusinessService().get(0);
}
- }
- private BusinessService GetServiceDetails(String key) throws Exception {
- // BusinessInfo get
- GetServiceDetail r = new GetServiceDetail();
- //GetBusinessDetail r = new GetBusinessDetail();
- r.getServiceKey().add(key);
- return inquiry.getServiceDetail(r).getBusinessService().get(0);
- }
-
- /**
- * Gets a UDDI style auth token, otherwise, appends credentials to the ws
- * proxies (not yet implemented)
- *
- * @param username
- * @param password
- * @param style
- * @return
- */
- private String GetAuthKey(String username, String password) {
- try {
-
- GetAuthToken getAuthTokenRoot = new GetAuthToken();
- getAuthTokenRoot.setUserID(username);
- getAuthTokenRoot.setCred(password);
-
- // Making API call that retrieves the authentication token for the 'root' user.
- AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot);
- System.out.println("root AUTHTOKEN = " + rootAuthToken.getAuthInfo());
- return rootAuthToken.getAuthInfo();
- } catch (Exception ex) {
- System.out.println("Could not authenticate with the provided credentials " + ex.getMessage());
+ /**
+ * Gets a UDDI style auth token, otherwise, appends credentials to the
+ * ws proxies (not yet implemented)
+ *
+ * @param username
+ * @param password
+ * @param style
+ * @return
+ */
+ private String GetAuthKey(String username, String password) {
+ try {
+
+ GetAuthToken getAuthTokenRoot = new GetAuthToken();
+ getAuthTokenRoot.setUserID(username);
+ getAuthTokenRoot.setCred(password);
+
+ // Making API call that retrieves the authentication token for the 'root' user.
+ AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot);
+ System.out.println("root AUTHTOKEN = " + "don't log auth tokens!");
+ return rootAuthToken.getAuthInfo();
+ } catch (Exception ex) {
+ System.out.println("Could not authenticate with the provided credentials " + ex.getMessage());
+ }
+ return null;
}
- return null;
- }
}
Modified: juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiDigitalSignatureTmodel.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiDigitalSignatureTmodel.java?rev=1556671&r1=1556670&r2=1556671&view=diff
==============================================================================
--- juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiDigitalSignatureTmodel.java (original)
+++ juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiDigitalSignatureTmodel.java Wed Jan 8 23:34:32 2014
@@ -33,126 +33,141 @@ import org.uddi.v3_service.UDDISecurityP
*/
public class UddiDigitalSignatureTmodel {
- private static UDDISecurityPortType security = null;
- private static UDDIInquiryPortType inquiry = null;
- private static UDDIPublicationPortType publish = null;
- private static UDDIClient clerkManager = null;
-
- /**
- * This sets up the ws proxies using uddi.xml in META-INF
- */
- public UddiDigitalSignatureTmodel() {
- try {
- // create a manager and read the config in the archive;
- // you can use your config file name
- clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml");
- Transport transport = clerkManager.getTransport();
- // Now you create a reference to the UDDI API
- security = transport.getUDDISecurityService();
- inquiry = transport.getUDDIInquiryService();
- publish = transport.getUDDIPublishService();
- } catch (Exception e) {
- e.printStackTrace();
+ private static UDDISecurityPortType security = null;
+ private static UDDIInquiryPortType inquiry = null;
+ private static UDDIPublicationPortType publish = null;
+ private static UDDIClient clerkManager = null;
+
+ /**
+ * This sets up the ws proxies using uddi.xml in META-INF
+ */
+ public UddiDigitalSignatureTmodel() {
+ try {
+ // create a manager and read the config in the archive;
+ // you can use your config file name
+ clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml");
+ Transport transport = clerkManager.getTransport();
+ // Now you create a reference to the UDDI API
+ security = transport.getUDDISecurityService();
+ inquiry = transport.getUDDIInquiryService();
+ publish = transport.getUDDIPublishService();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
- }
- /**
- * Main entry point
- *
- * @param args
- */
- public static void main(String args[]) {
- UddiDigitalSignatureTmodel sp = new UddiDigitalSignatureTmodel();
- sp.Fire(args);
- }
-
- public void Fire(String[] args) {
- 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, "password");
- ds.put(DigSigUtil.SIGNATURE_KEYSTORE_KEY_ALIAS, "selfsigned");
- ds.put(DigSigUtil.SIGNATURE_OPTION_CERT_INCLUSION_BASE64, "true");
-
- //option 2), load it from the juddi config file
- //ds = new DigSigUtil(clerkManager.getClientConfig().getDigitalSignatureConfiguration());
-
- //login
- String token = null;
- //option, load from juddi config
- token = GetAuthKey(clerkManager.getClerk("default").getPublisher(),
- clerkManager.getClerk("default").getPassword());
-
-
- String key = "uddi:juddi.apache.org:23748881-bb2f-4896-8283-4a15be1d0bc1";
-
-
- TModel be = GetTmodelDetails(key);
- be.getSignature().clear();
- //DigSigUtil.JAXB_ToStdOut(be);
- System.out.println("signing");
- TModel signUDDI_JAXBObject = ds.signUddiEntity(be);
- DigSigUtil.JAXB_ToStdOut(signUDDI_JAXBObject);
- System.out.println("signed, saving");
-
- SaveTModel sb = new SaveTModel();
- sb.setAuthInfo(token);
- sb.getTModel().add(signUDDI_JAXBObject);
- publish.saveTModel(sb);
- System.out.println("saved, fetching");
-
-
- be = GetTmodelDetails(key);
- 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)");
- }
- System.out.println(msg.get());
+ /**
+ * Main entry point
+ *
+ * @param args
+ */
+ public static void main(String args[]) {
+ UddiDigitalSignatureTmodel sp = new UddiDigitalSignatureTmodel();
+ sp.Fire(null, null);
+ }
+
+ 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){
+ SaveTModel stm = new SaveTModel();
+ stm.setAuthInfo(token);
+ TModel tm = new TModel();
+ tm.setName(new Name("my cool signed tmodel", null));
+ stm.getTModel().add(tm);
+ TModelDetail saveTModel = publish.saveTModel(stm);
+ key = saveTModel.getTModel().get(0).getTModelKey();
+ }
+
+ TModel be = GetTmodelDetails(key);
+ if (!be.getSignature().isEmpty())
+ {
+ System.out.println("WARN, the entity with the key " + key + " is already signed! aborting");
+ return;
+ }
+
+ //DigSigUtil.JAXB_ToStdOut(be);
+ System.out.println("signing");
+ TModel signUDDI_JAXBObject = ds.signUddiEntity(be);
+ DigSigUtil.JAXB_ToStdOut(signUDDI_JAXBObject);
+ System.out.println("signed, saving");
+
+ SaveTModel sb = new SaveTModel();
+ sb.setAuthInfo(token);
+ sb.getTModel().add(signUDDI_JAXBObject);
+ publish.saveTModel(sb);
+ System.out.println("saved, fetching");
+
+ be = GetTmodelDetails(key);
+ 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)");
+ }
+ System.out.println(msg.get());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
- } catch (Exception e) {
- e.printStackTrace();
+ private TModel GetTmodelDetails(String key) throws Exception {
+ // BusinessInfo get
+ GetTModelDetail r = new GetTModelDetail();
+ r.getTModelKey().add(key);
+ return inquiry.getTModelDetail(r).getTModel().get(0);
}
- }
- private TModel GetTmodelDetails(String key) throws Exception {
- // BusinessInfo get
- GetTModelDetail r = new GetTModelDetail();
- r.getTModelKey().add(key);
- return inquiry.getTModelDetail(r).getTModel().get(0);
- }
-
- /**
- * Gets a UDDI style auth token, otherwise, appends credentials to the ws
- * proxies (not yet implemented)
- *
- * @param username
- * @param password
- * @param style
- * @return
- */
- private String GetAuthKey(String username, String password) {
- try {
-
- GetAuthToken getAuthTokenRoot = new GetAuthToken();
- getAuthTokenRoot.setUserID(username);
- getAuthTokenRoot.setCred(password);
-
- // Making API call that retrieves the authentication token for the 'root' user.
- AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot);
- System.out.println("root AUTHTOKEN = " + rootAuthToken.getAuthInfo());
- return rootAuthToken.getAuthInfo();
- } catch (Exception ex) {
- System.out.println("Could not authenticate with the provided credentials " + ex.getMessage());
+ /**
+ * Gets a UDDI style auth token, otherwise, appends credentials to the
+ * ws proxies (not yet implemented)
+ *
+ * @param username
+ * @param password
+ * @param style
+ * @return
+ */
+ private String GetAuthKey(String username, String password) {
+ try {
+
+ GetAuthToken getAuthTokenRoot = new GetAuthToken();
+ getAuthTokenRoot.setUserID(username);
+ getAuthTokenRoot.setCred(password);
+
+ // Making API call that retrieves the authentication token for the 'root' user.
+ AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot);
+ System.out.println("root AUTHTOKEN = " + "don't log auth tokens!");
+ return rootAuthToken.getAuthInfo();
+ } catch (Exception ex) {
+ System.out.println("Could not authenticate with the provided credentials " + ex.getMessage());
+ }
+ return null;
}
- return null;
- }
}
Modified: juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiFindBinding.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiFindBinding.java?rev=1556671&r1=1556670&r2=1556671&view=diff
==============================================================================
--- juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiFindBinding.java (original)
+++ juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiFindBinding.java Wed Jan 8 23:34:32 2014
@@ -34,66 +34,69 @@ import org.uddi.v3_service.UDDISecurityP
*/
public class UddiFindBinding {
- private static UDDISecurityPortType security = null;
- private static JUDDIApiPortType juddiApi = null;
- private static UDDIPublicationPortType publish = null;
- private static UDDIInquiryPortType inquiry = null;
+ private static UDDISecurityPortType security = null;
+ private static JUDDIApiPortType juddiApi = null;
+ private static UDDIPublicationPortType publish = null;
+ private static UDDIInquiryPortType inquiry = null;
- public UddiFindBinding() {
- try {
+ public UddiFindBinding() {
+ try {
// create a manager and read the config in the archive;
- // you can use your config file name
- UDDIClient clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml");
- Transport transport = clerkManager.getTransport();
- // Now you create a reference to the UDDI API
- security = transport.getUDDISecurityService();
- juddiApi = transport.getJUDDIApiService();
- publish = transport.getUDDIPublishService();
- inquiry = transport.getUDDIInquiryService();
- } catch (Exception e) {
- e.printStackTrace();
+ // you can use your config file name
+ UDDIClient clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml");
+ Transport transport = clerkManager.getTransport();
+ // Now you create a reference to the UDDI API
+ security = transport.getUDDISecurityService();
+ juddiApi = transport.getJUDDIApiService();
+ publish = transport.getUDDIPublishService();
+ inquiry = transport.getUDDIInquiryService();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
- }
- public void publish() {
- try {
+ public void Fire(String token) {
+ try {
// Setting up the values to get an authentication token for the 'root' user ('root' user has admin privileges
- // and can save other publishers).
- GetAuthToken getAuthTokenRoot = new GetAuthToken();
- getAuthTokenRoot.setUserID("root");
- getAuthTokenRoot.setCred("root");
-
- // Making API call that retrieves the authentication token for the 'root' user.
- AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot);
- System.out.println("root AUTHTOKEN = " + rootAuthToken.getAuthInfo());
-
- FindService fs = new FindService();
- fs.getName().add(new Name());
- fs.getName().get(0).setValue("%");
- fs.setFindQualifiers(new FindQualifiers());
- fs.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
-
- ServiceList findService = inquiry.findService(fs);
- System.out.println(findService.getServiceInfos().getServiceInfo().size());
- GetServiceDetail gs = new GetServiceDetail();
- for (int i = 0; i < findService.getServiceInfos().getServiceInfo().size(); i++) {
- gs.getServiceKey().add(findService.getServiceInfos().getServiceInfo().get(i).getServiceKey());
- }
-
- ServiceDetail serviceDetail = inquiry.getServiceDetail(gs);
- for (int i = 0; i < serviceDetail.getBusinessService().size(); i++) {
- System.out.println(serviceDetail.getBusinessService().get(i).getBindingTemplates().getBindingTemplate().size());
- for (int k = 0; k < serviceDetail.getBusinessService().get(i).getBindingTemplates().getBindingTemplate().size(); k++) {
- System.out.println(serviceDetail.getBusinessService().get(i).getBindingTemplates().getBindingTemplate().get(k).getAccessPoint().getValue());
+ // and can save other publishers).
+ GetAuthToken getAuthTokenRoot = new GetAuthToken();
+ getAuthTokenRoot.setUserID("root");
+ getAuthTokenRoot.setCred("root");
+
+ if (token == null) {
+ // Making API call that retrieves the authentication token for the 'root' user.
+ AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot);
+ System.out.println("root AUTHTOKEN = " + "don't log auth tokens!");
+ token = rootAuthToken.getAuthInfo();
+ }
+ FindService fs = new FindService();
+ fs.setAuthInfo(token);
+ fs.getName().add(new Name());
+ fs.getName().get(0).setValue("%");
+ fs.setFindQualifiers(new FindQualifiers());
+ fs.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
+
+ ServiceList findService = inquiry.findService(fs);
+ System.out.println(findService.getServiceInfos().getServiceInfo().size());
+ GetServiceDetail gs = new GetServiceDetail();
+ for (int i = 0; i < findService.getServiceInfos().getServiceInfo().size(); i++) {
+ gs.getServiceKey().add(findService.getServiceInfos().getServiceInfo().get(i).getServiceKey());
+ }
+
+ ServiceDetail serviceDetail = inquiry.getServiceDetail(gs);
+ for (int i = 0; i < serviceDetail.getBusinessService().size(); i++) {
+ //System.out.println(serviceDetail.getBusinessService().get(i).getBindingTemplates().getBindingTemplate().size());
+ for (int k = 0; k < serviceDetail.getBusinessService().get(i).getBindingTemplates().getBindingTemplate().size(); k++) {
+ System.out.println(serviceDetail.getBusinessService().get(i).getBindingTemplates().getBindingTemplate().get(k).getAccessPoint().getValue());
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
}
- }
- } catch (Exception e) {
- e.printStackTrace();
}
- }
- public static void main(String args[]) {
- UddiFindBinding sp = new UddiFindBinding();
- sp.publish();
- }
+ public static void main(String args[]) {
+ UddiFindBinding sp = new UddiFindBinding();
+ sp.Fire(null);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org
For additional commands, e-mail: commits-help@juddi.apache.org