Advertisement
Guest User

Untitled

a guest
Feb 17th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.08 KB | None | 0 0
  1. package com.dell.dfs.beam.order.repository.impl;
  2.  
  3. import javax.inject.Inject;
  4. import javax.xml.namespace.QName;
  5.  
  6. import org.apache.axiom.om.OMAbstractFactory;
  7. import org.apache.axiom.om.OMElement;
  8. import org.apache.axiom.om.OMFactory;
  9. import org.apache.axiom.om.OMNamespace;
  10.  
  11. import com.dell.dfs.beam.order.model.canonical.DSCanonical;
  12. import com.dell.dfs.beam.order.repository.AuthorizeOrderRepositoryIntf;
  13. import com.dell.dfs.beam.order.resource.ConfigurationProperty;
  14. import com.dell.dfs.beam.order.resource.ResourceOrder;
  15. import com.dell.dfs.beam.order.service.order.OrderServiceSoapQSServiceStub;
  16. import com.dell.www.dfs.dcal.order._2_0.types.BusinessSegment;
  17. import com.dell.www.dfs.dcal.order._2_0.types.FunctionalArea;
  18. import com.dell.www.dfs.dcal.order._2_0.types.GetOrderInformationRequestDocument;
  19. import com.dell.www.dfs.dcal.order._2_0.types.GetOrderInformationResponseDocument;
  20. import com.dell.www.dfs.dcal.order._2_0.types.GetOrderInformationResponseDocument.GetOrderInformationResponse;
  21. import com.dell.www.dfs.dcal.order._2_0.types.OrderNumbers;
  22. import com.dell.www.dfs.gil.headerdataxmls.HeaderDataDocument;
  23. import com.dell.www.dfs.gil.headerdataxmls.HeaderDataDocument.HeaderData;
  24.  
  25. public class AuthorizeOrderRepository implements AuthorizeOrderRepositoryIntf {
  26.  
  27. @Inject
  28. private ResourceOrder resourceOrder;
  29.  
  30. @Override
  31. public GetOrderInformationResponse getOrderInformationRequest(DSCanonical canonical) {
  32. GetOrderInformationResponse response = null;
  33.  
  34. try {
  35. OrderServiceSoapQSServiceStub stub = new OrderServiceSoapQSServiceStub(
  36. resourceOrder.getProperty(ConfigurationProperty.PR2_GOSS_ENDPOINT_KEY));
  37.  
  38. String token = "<wsse:Security soapenv:mustUnderstand=\"1\" xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:soap=\"soapenv\">"
  39. + "<saml:Assertion MajorVersion=\"1\" MinorVersion=\"1\" AssertionID=\"SAML-LD0NGZq6qREOIP8EUacvVQ22\" IssueInstant=\"2015-10-17T15:04:35Z\" Issuer=\"www.oracle.com\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\">"
  40. + "<saml:Conditions NotBefore=\"2015-10-17T15:04:35Z\" NotOnOrAfter=\"2015-10-17T15:09:35Z\"/>"
  41. + "<saml:AuthenticationStatement AuthenticationInstant=\"2015-10-17T15:04:35Z\" AuthenticationMethod=\"urn:oasis:names:tc:SAML:1.0:am:password\">"
  42. + "<saml:Subject>"
  43. + "<saml:NameIdentifier Format=\"urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified\">owsm_anonymous_fe24daa0-bc21-4434-9d8e-148833612e92</saml:NameIdentifier>"
  44. + "<saml:SubjectConfirmation>"
  45. + "<saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:sender-vouches</saml:ConfirmationMethod>"
  46. + "</saml:SubjectConfirmation>" + "</saml:Subject>" + "</saml:AuthenticationStatement>"
  47. + "</saml:Assertion>" + "</wsse:Security>";
  48.  
  49. OMFactory omFactory = OMAbstractFactory.getOMFactory();
  50. OMElement omSecurityElement = omFactory.createOMElement(
  51. new QName("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
  52. "Security", "wsse"),
  53. null);
  54. omSecurityElement.addAttribute("soapenv:mustUnderstand", "1", null);
  55.  
  56. OMElement assertionToken = omFactory.createOMElement(
  57. new QName("urn:oasis:names:tc:SAML:1.0:assertion", "saml:Assertion", "saml"), null);
  58. assertionToken.addAttribute("MajorVersion", "1", null);
  59. assertionToken.addAttribute("MinorVersion", "1", null);
  60. assertionToken.addAttribute("AssertionID", "SAML-LD0NGZq6qREOIP8EUacvVQ22", null);
  61. assertionToken.addAttribute("IssueInstant", "2015-10-17T15:04:35Z", null);
  62. assertionToken.addAttribute("Issuer", "www.oracle.com", null);
  63.  
  64. OMElement conditionsToken = omFactory.createOMElement(new QName(null, "saml:Conditions", "saml"), null);
  65. conditionsToken.addAttribute("NotBefore", "2015-10-17T15:04:35Z", null);
  66. conditionsToken.addAttribute("NotOnOrAfter", "2015-10-17T15:09:35Z", null);
  67.  
  68. OMElement omuserName = omFactory
  69. .createOMElement(new QName("http://docs.oasis-open.org/wss/2004", "Username", "wsse"), null);
  70. omuserName.setText("myusername");
  71.  
  72. OMElement omPassword = omFactory
  73. .createOMElement(new QName("http://docs.oasis-open.org/wss/2004", "Password", "wsse"), null);
  74. omPassword.addAttribute("Type",
  75. "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText",
  76. null);
  77. omPassword.setText("mypassword");
  78.  
  79. assertionToken.addChild(conditionsToken);
  80. stub._getServiceClient().addHeader(omSecurityElement);
  81.  
  82. HeaderDataDocument header = HeaderDataDocument.Factory.newInstance();
  83. HeaderData headerData = header.addNewHeaderData();
  84.  
  85. GetOrderInformationRequestDocument req = GetOrderInformationRequestDocument.Factory.newInstance();
  86. GetOrderInformationRequestDocument.GetOrderInformationRequest data = req.addNewGetOrderInformationRequest();
  87.  
  88. headerData.setCLIENTID("CrazyTest");
  89. headerData.setCLIENTVERSION("2_0");
  90. headerData.setDOENCRYPT(false);
  91. headerData.setMESSAGEID("New_Order_Service_MLA_PR2");
  92.  
  93. OrderNumbers orderNumbers = data.addNewOrderNumbers();
  94. orderNumbers.addOrderNumber("408609675");
  95. data.setBusinessUnitID("UnitedStates");
  96. data.setFunctionalArea(FunctionalArea.RISK_APS);
  97. data.setBusinessSegment(BusinessSegment.CONSUMER);
  98.  
  99. GetOrderInformationResponseDocument resp = stub.getOrderInformation(req, header);
  100.  
  101. response = resp.getGetOrderInformationResponse();
  102.  
  103. } catch (Exception all) {
  104. all.printStackTrace();
  105. }
  106.  
  107. return response;
  108. }
  109.  
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement