Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.dell.dfs.beam.order.repository.impl;
- import javax.inject.Inject;
- import javax.xml.namespace.QName;
- import org.apache.axiom.om.OMAbstractFactory;
- import org.apache.axiom.om.OMElement;
- import org.apache.axiom.om.OMFactory;
- import org.apache.axiom.om.OMNamespace;
- import com.dell.dfs.beam.order.model.canonical.DSCanonical;
- import com.dell.dfs.beam.order.repository.AuthorizeOrderRepositoryIntf;
- import com.dell.dfs.beam.order.resource.ConfigurationProperty;
- import com.dell.dfs.beam.order.resource.ResourceOrder;
- import com.dell.dfs.beam.order.service.order.OrderServiceSoapQSServiceStub;
- import com.dell.www.dfs.dcal.order._2_0.types.BusinessSegment;
- import com.dell.www.dfs.dcal.order._2_0.types.FunctionalArea;
- import com.dell.www.dfs.dcal.order._2_0.types.GetOrderInformationRequestDocument;
- import com.dell.www.dfs.dcal.order._2_0.types.GetOrderInformationResponseDocument;
- import com.dell.www.dfs.dcal.order._2_0.types.GetOrderInformationResponseDocument.GetOrderInformationResponse;
- import com.dell.www.dfs.dcal.order._2_0.types.OrderNumbers;
- import com.dell.www.dfs.gil.headerdataxmls.HeaderDataDocument;
- import com.dell.www.dfs.gil.headerdataxmls.HeaderDataDocument.HeaderData;
- public class AuthorizeOrderRepository implements AuthorizeOrderRepositoryIntf {
- @Inject
- private ResourceOrder resourceOrder;
- @Override
- public GetOrderInformationResponse getOrderInformationRequest(DSCanonical canonical) {
- GetOrderInformationResponse response = null;
- try {
- OrderServiceSoapQSServiceStub stub = new OrderServiceSoapQSServiceStub(
- resourceOrder.getProperty(ConfigurationProperty.PR2_GOSS_ENDPOINT_KEY));
- 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\">"
- + "<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\">"
- + "<saml:Conditions NotBefore=\"2015-10-17T15:04:35Z\" NotOnOrAfter=\"2015-10-17T15:09:35Z\"/>"
- + "<saml:AuthenticationStatement AuthenticationInstant=\"2015-10-17T15:04:35Z\" AuthenticationMethod=\"urn:oasis:names:tc:SAML:1.0:am:password\">"
- + "<saml:Subject>"
- + "<saml:NameIdentifier Format=\"urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified\">owsm_anonymous_fe24daa0-bc21-4434-9d8e-148833612e92</saml:NameIdentifier>"
- + "<saml:SubjectConfirmation>"
- + "<saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:sender-vouches</saml:ConfirmationMethod>"
- + "</saml:SubjectConfirmation>" + "</saml:Subject>" + "</saml:AuthenticationStatement>"
- + "</saml:Assertion>" + "</wsse:Security>";
- OMFactory omFactory = OMAbstractFactory.getOMFactory();
- OMElement omSecurityElement = omFactory.createOMElement(
- new QName("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
- "Security", "wsse"),
- null);
- omSecurityElement.addAttribute("soapenv:mustUnderstand", "1", null);
- OMElement assertionToken = omFactory.createOMElement(
- new QName("urn:oasis:names:tc:SAML:1.0:assertion", "saml:Assertion", "saml"), null);
- assertionToken.addAttribute("MajorVersion", "1", null);
- assertionToken.addAttribute("MinorVersion", "1", null);
- assertionToken.addAttribute("AssertionID", "SAML-LD0NGZq6qREOIP8EUacvVQ22", null);
- assertionToken.addAttribute("IssueInstant", "2015-10-17T15:04:35Z", null);
- assertionToken.addAttribute("Issuer", "www.oracle.com", null);
- OMElement conditionsToken = omFactory.createOMElement(new QName(null, "saml:Conditions", "saml"), null);
- conditionsToken.addAttribute("NotBefore", "2015-10-17T15:04:35Z", null);
- conditionsToken.addAttribute("NotOnOrAfter", "2015-10-17T15:09:35Z", null);
- OMElement omuserName = omFactory
- .createOMElement(new QName("http://docs.oasis-open.org/wss/2004", "Username", "wsse"), null);
- omuserName.setText("myusername");
- OMElement omPassword = omFactory
- .createOMElement(new QName("http://docs.oasis-open.org/wss/2004", "Password", "wsse"), null);
- omPassword.addAttribute("Type",
- "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText",
- null);
- omPassword.setText("mypassword");
- assertionToken.addChild(conditionsToken);
- stub._getServiceClient().addHeader(omSecurityElement);
- HeaderDataDocument header = HeaderDataDocument.Factory.newInstance();
- HeaderData headerData = header.addNewHeaderData();
- GetOrderInformationRequestDocument req = GetOrderInformationRequestDocument.Factory.newInstance();
- GetOrderInformationRequestDocument.GetOrderInformationRequest data = req.addNewGetOrderInformationRequest();
- headerData.setCLIENTID("CrazyTest");
- headerData.setCLIENTVERSION("2_0");
- headerData.setDOENCRYPT(false);
- headerData.setMESSAGEID("New_Order_Service_MLA_PR2");
- OrderNumbers orderNumbers = data.addNewOrderNumbers();
- orderNumbers.addOrderNumber("408609675");
- data.setBusinessUnitID("UnitedStates");
- data.setFunctionalArea(FunctionalArea.RISK_APS);
- data.setBusinessSegment(BusinessSegment.CONSUMER);
- GetOrderInformationResponseDocument resp = stub.getOrderInformation(req, header);
- response = resp.getGetOrderInformationResponse();
- } catch (Exception all) {
- all.printStackTrace();
- }
- return response;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement