Example usage for javax.xml.ws BindingProvider ENDPOINT_ADDRESS_PROPERTY

List of usage examples for javax.xml.ws BindingProvider ENDPOINT_ADDRESS_PROPERTY

Introduction

In this page you can find the example usage for javax.xml.ws BindingProvider ENDPOINT_ADDRESS_PROPERTY.

Prototype

String ENDPOINT_ADDRESS_PROPERTY

To view the source code for javax.xml.ws BindingProvider ENDPOINT_ADDRESS_PROPERTY.

Click Source Link

Document

Standard property: Target service endpoint address.

Usage

From source file:org.openehealth.ipf.platform.camel.lbs.cxf.process.LbsCxfHugeFileTest.java

@Before
public void setUp() throws Exception {
    File temp = new File("target/store");
    temp.delete();//from  ww w .  ja  va2  s .  com
    baseDir = new File(temp.getAbsolutePath());
    baseDir.mkdir();

    URL wsdlResource = getClass().getClassLoader().getResource("hello_world.wsdl");
    SOAPService service = new SOAPService(wsdlResource);
    greeter = service.getSoapOverHttp();
    provider = (BindingProvider) greeter;
    SOAPBinding binding = (SOAPBinding) provider.getBinding();
    binding.setMTOMEnabled(true);
    provider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, ENDPOINT);

    camelContext.addRoutes(createRouteBuilder());
}

From source file:org.openhie.openempi.nhinproxy.AbstractComponentMpi.java

@SuppressWarnings("unchecked")
protected void configurePort(AdapterComponentMpiPortType port, String endpointURL) {
    log.debug("Begin configurePort");
    if (port == null) {
        log.warn("configurePort - Port was null.");
    } else if (endpointURL == null) {
        log.warn("configurePort - Endpoint URL was null.");
    } else {/*  w w w. j  a  va  2 s .  c o m*/
        Map requestContext = ((BindingProvider) port).getRequestContext();
        requestContext.put(javax.xml.ws.BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL);
    }
    log.debug("End configurePort");
}

From source file:org.oscarehr.web.OcanReportUIBean.java

public static int sendSubmissionToIAR(OCANv2SubmissionFileDocument submissionDoc) {
    if (submissionDoc.getOCANv2SubmissionFile().getOCANv2SubmissionRecordArray().length == 0) {
        logger.info("No records to send");
        return 0;
    }/*from w  w w .  j a v  a2s  .com*/
    if (submissionDoc.getOCANv2SubmissionFile().getOCANv2SubmissionRecordArray().length > 500) {
        logger.warn("over 500 to send..will probably fail");
    }

    //serialize the data
    ByteArrayOutputStream sos = new ByteArrayOutputStream();
    try {
        XmlOptions options = new XmlOptions();
        options.setUseDefaultNamespace();
        //options.setSavePrettyPrint();
        options.setCharacterEncoding("UTF-8");
        Map<String, String> implicitNamespaces = new HashMap<String, String>();
        implicitNamespaces.put("", "http://oscarehr.org/ocan");
        options.setSaveImplicitNamespaces(implicitNamespaces);
        submissionDoc.save(sos, options);
    } catch (IOException e) {
        logger.error("Error:", e);
        return 0;
    }

    //generate the envelope
    IARSubmission is = new IARSubmission();
    is.setVersion("2.0");

    Application application = new Application();
    application.setId("1");
    application.setName("OSCAR");
    application.setVendor("CAISI");
    application.setVersion("10.06");

    Organization org = new Organization();
    //String orgId = OscarProperties.getInstance().getProperty("ocan.iar.org.id");
    String orgId = LoggedInInfo.loggedInInfo.get().currentFacility.getOcanServiceOrgNumber();
    org.setId(orgId);
    org.setName(LoggedInInfo.loggedInInfo.get().currentFacility.getName());

    XMLGregorianCalendar cal = null;

    try {
        GregorianCalendar gc = new GregorianCalendar();
        DatatypeFactory dtf = DatatypeFactory.newInstance();
        cal = dtf.newXMLGregorianCalendar(gc);
    } catch (Exception e) {
        logger.error("Error:", e);
    }

    TransmissionHeaderType th = new TransmissionHeaderType();
    th.setApplication(application);
    th.setAssessmentType("OCAN");
    th.setExportTimestamp(cal);
    th.setOrganization(org);
    th.setSubmissionId("1");

    is.setTransmissionHeader(th);

    Text t = new Text();
    t.setValue(sos.toString());

    Record r = new Record();
    r.setRecordType("Assessment");
    r.setMimeType("text/xml");
    r.setText(t);
    r.setVersion("2.0.6");

    Record consent = new Record();
    consent.setVersion("1.0");
    consent.setMimeType("text/xml");
    consent.setRecordType("Consent");
    ConsentSubmission cs = ConsentSubmission.Factory.newInstance();
    //cs.getDomNode().getAttributes().
    OCANv2SubmissionRecord[] submissionRecords = submissionDoc.getOCANv2SubmissionFile()
            .getOCANv2SubmissionRecordArray();
    for (OCANv2SubmissionRecord submissionRecord : submissionRecords) {

        String assessmentId = submissionRecord.getAssessmentID();

        String assessmentId_noPrefix = assessmentId;
        String idPrefix = OscarProperties.getInstance().getProperty("ocan.iar.idPrefix");
        if (!StringUtils.isBlank(idPrefix)) {
            assessmentId_noPrefix = assessmentId.replace(idPrefix, "");
        }

        OcanStaffForm staffForm = ocanStaffFormDao.findLatestByAssessmentId(
                LoggedInInfo.loggedInInfo.get().currentFacility.getId(),
                Integer.parseInt(assessmentId_noPrefix));

        ConsentDirective cd = cs.addNewConsentDirective();
        cd.setId(assessmentId);
        cd.setType(CdConsentDirectiveType.ASSESSMENT);

        PersonIdentification pi = PersonIdentification.Factory.newInstance();
        SourceSystem ss = pi.addNewSourceSystem();
        ss.setId(application.getId());
        ss.setType(SourceSystem.Type.APPLICATION_ID);
        PersonIdentificationDocument.PersonIdentification.Organization o = pi.addNewOrganization();
        o.setId(orgId);
        o.setName(LoggedInInfo.loggedInInfo.get().currentFacility.getName());
        pi.setPersonId(submissionRecord.getClientRecord().getClientID().getOrgClientID());
        cd.setPersonIdentification(pi);

        ApplyTo at = ApplyTo.Factory.newInstance();
        ApplyToDocument.ApplyTo.Assessment a = at.addNewAssessment();
        a.setAssessmentId(assessmentId);
        a.setAssessmentType(AssessmentType.OCAN);
        at.setAssessment(a);
        cd.setApplyTo(at);

        CdConsentActionType actionType = CdConsentActionType.Factory.newInstance();
        String c = staffForm.getConsent();
        if (c.equals("GRANT")) {
            actionType.setAccessLevel(CdConsentActionType.AccessLevel.GRANT);
        } else if (c.equals("DENY")) {
            actionType.setAccessLevel(CdConsentActionType.AccessLevel.DENY);
        } else if (c.equals("NOT_SPECIFIED")) {
            actionType.setAccessLevel(CdConsentActionType.AccessLevel.UNSUPPORTED);
        } else {
            actionType.setAccessLevel(CdConsentActionType.AccessLevel.GRANT);
        }
        cd.setDirective(actionType);

        RecordedByInfo rbi = RecordedByInfo.Factory.newInstance();
        rbi.setNameOrUserID(staffForm.getProviderName());
        Calendar cal2 = Calendar.getInstance();
        cal2.setTime(staffForm.getCreated());
        rbi.setTimeRecorded(cal2);
        cd.setRecordedByInfo(rbi);

    }

    Text t2 = new Text();
    String cs1 = cs.toString().replace("<xml-fragment xmlns:ccim=\"http://www.ehealthontario.ca/CCIM\">", "");
    String cs2 = cs1.replace("</xml-fragment>", "");
    String cs3 = cs2.replaceAll("ccim:", "");
    t2.setValue(
            "<ConsentSubmission xsi:schemaLocation=\"http://www.ehealthontario.ca/CCIMConsentSubmission-1.0.xsd\" xmlns=\"http://www.ehealthontario.ca/CCIM\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
                    + cs3 + "</ConsentSubmission>");
    consent.setText(t2);

    SubmissionContent sc = new SubmissionContent();
    sc.getRecord().add(r);
    sc.getRecord().add(consent);

    is.setSubmissionContent(sc);

    //create the log entry and get the submission id
    OcanSubmissionLog log = new OcanSubmissionLog();
    log.setSubmitDateTime(new Date());
    logDao.persist(log);

    if (log.getId() == null) {
        logger.info("log has no id!");
        return 0;
    }

    is.getTransmissionHeader().setSubmissionId(String.valueOf(log.getId()));
    logger.info("the submissionId is " + log.getId());

    try {
        String user = OscarProperties.getInstance().getProperty("ocan.iar.user");
        String url = OscarProperties.getInstance().getProperty("ocan.iar.url");
        if (url == null || url.length() == 0) {
            //validation environment
            url = "https://iarvt.ccim.on.ca/iarws-2.0/services/SubmissionService";
        }
        SubmissionService service = new SubmissionService();
        SubmissionPortType port = service.getSubmissionPort();
        ((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
        CxfClientUtils.configureClientConnection(port);
        CxfClientUtils.configureWSSecurity(port, user, new OcanReportUIBean());
        CxfClientUtils.configureLogging(port);

        SubmissionResultType result = port.submitAssessment(is);
        Result res = result.getResult();
        logger.info("result message:" + result.getDetailMessage());
        logger.info("error code:" + result.getErrorCode());
        logger.info("result:" + res.isValue());
        logger.info("transactionId=" + res.getTransactionId());

        log.setResult(String.valueOf(res.isValue()));
        log.setTransactionId(res.getTransactionId());
        log.setResultMessage(result.getDetailMessage());
    } catch (Exception e) {
        logger.error("Error:", e);
        return 0;
    }

    logDao.merge(log);

    if (log.getResult() != null && log.getResult().equals("true")) {
        for (int x = 0; x < submissionDoc.getOCANv2SubmissionFile()
                .getOCANv2SubmissionRecordArray().length; x++) {
            OCANv2SubmissionRecord subRec = submissionDoc.getOCANv2SubmissionFile()
                    .getOCANv2SubmissionRecordArray()[x];
            String id = subRec.getAssessmentID();
            //OcanStaffForm staffForm = ocanStaffFormDao.find(Integer.parseInt(id));
            // assessment ID is not form ID.
            String assessmentId_noPrefix = id;
            String idPrefix = OscarProperties.getInstance().getProperty("ocan.iar.idPrefix");
            if (!StringUtils.isBlank(idPrefix)) {
                assessmentId_noPrefix = id.replace(idPrefix, "");
            }

            OcanStaffForm staffForm = ocanStaffFormDao.findLatestByAssessmentId(
                    LoggedInInfo.loggedInInfo.get().currentFacility.getId(),
                    Integer.valueOf(assessmentId_noPrefix));

            staffForm.setSubmissionId(log.getId());
            ocanStaffFormDao.merge(staffForm);
        }
    }

    return log.getId();
}

From source file:org.socraticgrid.presentationservices.resources.messages.SetMessagesResource.java

/**
 * ONLY call DDA.setMessage for// ww  w.j a  va 2  s  . c om
 * @param userId
 * @param messageIds
 * @param messageTypes
 * @param labels
 * @return
 */
//Exception DisallowedSetAction = new Exception();
private SetMessageDataResponseType setMessages(String userId, List<String> messageIds,
        List<String> messageTypes, List<String> labels) {
    DisplayDataAggregator service = new org.socraticgrid.aggregator.DisplayDataAggregator();
    DisplayDataAggregatorPortType port = service.getDisplayDataAggregatorPortSoap11();

    ((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
            getProperty("DisplayDataAggregatorService"));

    SetMessageDataRequestType setMessageRequest = new SetMessageDataRequestType();
    SetMessageDataResponseType setMessageResponse = new SetMessageDataResponseType();

    try {
        int j = 0; //indicates how many msgs needs to be process.
        Map messageIdWithType = new HashMap();

        //------------------------------------------------
        // WHEN msg already exists
        //------------------------------------------------
        if (!CommonUtil.listNullorEmpty(messageIds)) {

            //-----------------------------------------------
            // On preexisting msgs, when coming from EMR
            // where (patientId <> null) AND (user logged in is a provider),
            // disallow the following SET actions:
            // Update, Read, Archive, Unarchive, Delete, Undelete, DeleteForever
            //
            //  !! This logic still not working correctly yet!!
            //-----------------------------------------------
            //                ContactDAO contactDAO = LdapService.getContactDAO();
            //                ContactDTO contact = null;
            //                contact = contactDAO.findContact("uid=" + this.userId).get(0);

            //                if (   !CommonUtil.strNullorEmpty(this.patientId)
            //                    && !CommonUtil.strNullorEmpty(contact.getEmployeeNumber())
            //                   )
            //                {
            //
            //                    String errmsg = "Doing a Set action when logged in as userId="+ this.userId
            //                            +" and message has context of patientId="+ this.patientId
            //                            +" "+ this.action + " action disallowed on this request.  ";
            //
            //                    System.out.println(errmsg);
            //
            //                    setMessageResponse.setSuccessStatus(false);
            //                    setMessageResponse.setMessage(errmsg);
            //
            //                    getResponse().setStatus(Status.SUCCESS_OK);
            //                    getResponse().setEntity(JSONHelper.getResponse(setMessageResponse).toString(),
            //                    MediaType.APPLICATION_JSON);
            //
            //                } else {

            //-----------------------------------------------
            // Create a Map of msgId:<Email|Alert|Document>
            // so that DDA can correct redirect the msg to be processed later
            //-----------------------------------------------
            for (int i = 0; i < messageIds.size(); i++) {
                messageIdWithType.put(messageIds.get(i), messageTypes.get(i));
            }

            //-----------------------------------------------
            // CHANGE:
            // Instead of sending separate DDA ws call for each messageId,
            // prep a list and do one call.  Let DDA take care of iterating
            // through the list as it makes its library processing call.
            //-----------------------------------------------
            for (String messageId : messageIds) {
                MessageDataRequestType aMsgReq = new MessageDataRequestType();
                aMsgReq = createMsgRequest(messageId, userId, messageIdWithType, j, labels);
                ++j;
                setMessageRequest.getRequestMessage().add(aMsgReq);
            }
            //                }
        }
        //------------------------------------------------
        // WHEN msg is new and user wants to do a SAVE
        //------------------------------------------------
        else if (action.equalsIgnoreCase("Save")) {
            createSaveRequest(setMessageRequest, userId, labels);
        }
        //------------------------------------------------
        // WHEN msg is new and user wants to do a SEND
        //------------------------------------------------
        else if (action.equalsIgnoreCase("Send")) {
            MessageDataRequestType aMsgReq = new MessageDataRequestType();
            aMsgReq = createMsgRequest(null, userId, null, 0, labels);
            setMessageRequest.getRequestMessage().add(aMsgReq);
        }

        //Send to DDA to process.
        setMessageResponse = port.setMessage(setMessageRequest);

    } catch (Exception e) {
        logger.error(e.getMessage());
        setMessageResponse.setSuccessStatus(false);
        setMessageResponse.setMessage(e.toString());

        getResponse().setStatus(Status.SUCCESS_OK);
        getResponse().setEntity(JSONHelper.getResponse(setMessageResponse).toString(),
                MediaType.APPLICATION_JSON);
        e.printStackTrace();
    }

    return setMessageResponse;
}

From source file:org.talend.components.netsuite.v2014_2.client.NetSuiteClientServiceImpl.java

protected NetSuitePortType getNetSuitePort(String defaultEndpointUrl, String account) throws NetSuiteException {
    try {/*from w  w w  .j a  v  a2s  . c om*/
        URL wsdlLocationUrl = this.getClass().getResource("/wsdl/2014.2/netsuite.wsdl");

        NetSuiteService service = new NetSuiteService(wsdlLocationUrl, NetSuiteService.SERVICE);

        List<WebServiceFeature> features = new ArrayList<>(2);
        if (isMessageLoggingEnabled()) {
            features.add(new LoggingFeature());
        }
        NetSuitePortType port = service
                .getNetSuitePort(features.toArray(new WebServiceFeature[features.size()]));

        BindingProvider provider = (BindingProvider) port;
        Map<String, Object> requestContext = provider.getRequestContext();
        requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, defaultEndpointUrl);

        GetDataCenterUrlsRequest dataCenterRequest = new GetDataCenterUrlsRequest();
        dataCenterRequest.setAccount(account);
        DataCenterUrls urls = null;
        GetDataCenterUrlsResponse response = port.getDataCenterUrls(dataCenterRequest);
        if (response != null && response.getGetDataCenterUrlsResult() != null) {
            urls = response.getGetDataCenterUrlsResult().getDataCenterUrls();
        }
        if (urls == null) {
            throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.CLIENT_ERROR),
                    NetSuiteRuntimeI18n.MESSAGES.getMessage("error.couldNotGetWebServiceDomain",
                            defaultEndpointUrl));
        }

        String wsDomain = urls.getWebservicesDomain();
        String endpointUrl = wsDomain.concat(new URL(defaultEndpointUrl).getPath());

        requestContext.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
        requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointUrl);

        return port;
    } catch (WebServiceException | MalformedURLException | UnexpectedErrorFault | ExceededRequestSizeFault e) {
        throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.CLIENT_ERROR),
                NetSuiteRuntimeI18n.MESSAGES.getMessage("error.failedToInitClient", e.getLocalizedMessage()),
                e);
    }
}

From source file:org.talend.components.netsuite.v2016_2.client.NetSuiteClientServiceImpl.java

protected NetSuitePortType getNetSuitePort(String defaultEndpointUrl, String account) throws NetSuiteException {
    try {/*w  w  w  . j  a va  2s . c  o m*/
        URL wsdlLocationUrl = this.getClass().getResource("/wsdl/2016.2/netsuite.wsdl");

        NetSuiteService service = new NetSuiteService(wsdlLocationUrl, NetSuiteService.SERVICE);

        List<WebServiceFeature> features = new ArrayList<>(2);
        if (isMessageLoggingEnabled()) {
            features.add(new LoggingFeature());
        }
        NetSuitePortType port = service
                .getNetSuitePort(features.toArray(new WebServiceFeature[features.size()]));

        BindingProvider provider = (BindingProvider) port;
        Map<String, Object> requestContext = provider.getRequestContext();
        requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, defaultEndpointUrl);

        GetDataCenterUrlsRequest dataCenterRequest = new GetDataCenterUrlsRequest();
        dataCenterRequest.setAccount(account);
        DataCenterUrls urls = null;
        GetDataCenterUrlsResponse response = port.getDataCenterUrls(dataCenterRequest);
        if (response != null && response.getGetDataCenterUrlsResult() != null) {
            urls = response.getGetDataCenterUrlsResult().getDataCenterUrls();
        }
        if (urls == null) {
            throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.CLIENT_ERROR),
                    NetSuiteRuntimeI18n.MESSAGES.getMessage("error.couldNotGetWebServiceDomain",
                            defaultEndpointUrl));
        }

        String wsDomain = urls.getWebservicesDomain();
        String endpointUrl = wsDomain.concat(new URL(defaultEndpointUrl).getPath());

        requestContext.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
        requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointUrl);

        return port;
    } catch (WebServiceException | MalformedURLException | InsufficientPermissionFault | InvalidCredentialsFault
            | InvalidSessionFault | UnexpectedErrorFault | ExceededRequestSizeFault e) {
        throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.CLIENT_ERROR),
                NetSuiteRuntimeI18n.MESSAGES.getMessage("error.failedToInitClient", e.getLocalizedMessage()),
                e);
    }
}

From source file:test.integ.be.agiv.security.Axis2Test.java

@Test
public void testSecurityFramework() {
    Service service = ClaimsAwareServiceFactory.getInstance();
    // WS-Addressing via JAX-WS
    IService iservice = service.getWS2007FederationHttpBindingIService(new AddressingFeature());

    BindingProvider bindingProvider = (BindingProvider) iservice;
    bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
            "https://auth.beta.agiv.be/ClaimsAwareService/Service.svc");

    AGIVSecurity agivSecurity = new AGIVSecurity(
            "https://auth.beta.agiv.be/ipsts/Services/DaliSecurityTokenServiceConfiguration.svc/IWSTrust13",
            "https://auth.beta.agiv.be/sts/Services/SalvadorSecurityTokenServiceConfiguration.svc/IWSTrust13",
            AGIVSecurity.BETA_REALM, this.config.getUsername(), this.config.getPassword());
    agivSecurity.enable(bindingProvider, false);
    agivSecurity.enable(bindingProvider, false);

    agivSecurity.prefetchTokens("https://auth.beta.agiv.be/ClaimsAwareService/Service.svc", false);

    LOG.debug("calling getData");
    iservice.getData(0);/*from w w  w  .j  av  a 2s . co  m*/
    LOG.debug("calling getData");
    iservice.getData(0);
    LOG.debug("calling getData");
    iservice.getData(0);

    SecurityToken secureConversationToken = agivSecurity.getSecureConversationTokens().values().iterator()
            .next();

    agivSecurity.cancelSecureConversationTokens();

    iservice.getData(0);
    SecurityToken secureConversationToken2 = agivSecurity.getSecureConversationTokens().values().iterator()
            .next();
    assertFalse(secureConversationToken.getAttachedReference()
            .equals(secureConversationToken2.getAttachedReference()));
}

From source file:test.integ.be.agiv.security.ClaimsAwareServiceTest.java

@Test
public void testWithoutSecurity() {
    Service service = new Service();
    IService iservice = service.getBasicHttpBindingIService();

    BindingProvider bindingProvider = (BindingProvider) iservice;
    bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
            "https://auth.beta.agiv.be/ClaimsAwareService/Service.svc/basic");

    try {/*ww  w.java  2 s  .  c  o m*/
        iservice.getData(0);
        fail();
    } catch (SOAPFaultException e) {
        LOG.debug("expected exception: " + e.getMessage());
        assertTrue(e.getMessage().contains("security"));
    }
}

From source file:test.integ.be.agiv.security.ClaimsAwareServiceTest.java

@Test
public void testSecurity() {
    Service service = new Service();
    IService iservice = service.getWS2007FederationHttpBindingIService();

    BindingProvider bindingProvider = (BindingProvider) iservice;
    bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
            ClaimsAwareServiceFactory.SERVICE_LOCATION);

    IPSTSClient ipStsClient = new IPSTSClient(
            "https://auth.beta.agiv.be/ipsts/Services/DaliSecurityTokenServiceConfiguration.svc/IWSTrust13",
            AGIVSecurity.BETA_REALM);//  ww  w .  j  a  v a  2 s  .  c o  m
    SecurityToken ipStsSecurityToken = ipStsClient.getSecurityToken(this.config.getUsername(),
            this.config.getPassword());

    RSTSClient rStsClient = new RSTSClient(
            "https://auth.beta.agiv.be/sts/Services/SalvadorSecurityTokenServiceConfiguration.svc/IWSTrust13");
    SecurityToken rStsSecurityToken = rStsClient.getSecurityToken(ipStsSecurityToken,
            ClaimsAwareServiceFactory.SERVICE_REALM);

    Binding binding = bindingProvider.getBinding();
    List<Handler> handlerChain = binding.getHandlerChain();
    WSAddressingHandler wsAddressingHandler = new WSAddressingHandler();
    handlerChain.add(wsAddressingHandler);
    WSSecurityHandler wsSecurityHandler = new WSSecurityHandler();
    handlerChain.add(wsSecurityHandler);
    handlerChain.add(new LoggingHandler());
    binding.setHandlerChain(handlerChain);

    wsAddressingHandler.setAddressing("http://www.agiv.be/IService/GetData",
            ClaimsAwareServiceFactory.SERVICE_LOCATION);
    wsSecurityHandler.setKey(rStsSecurityToken.getKey(), rStsSecurityToken.getAttachedReference(),
            rStsSecurityToken.getToken(), true);

    ArrayOfClaimInfo result = iservice.getData(0);

    List<ClaimInfo> claims = result.getClaimInfo();
    boolean myName = false;
    for (ClaimInfo claim : claims) {
        LOG.debug(claim.getName() + " = " + claim.getValue());
        if (this.config.getUsername().equals(claim.getValue())) {
            myName = true;
        }
    }
    assertTrue(myName);
}

From source file:test.integ.be.agiv.security.ClaimsAwareServiceTest.java

@Test
public void testSecuritySecondaryParameters() throws Exception {
    Service service = new Service();
    IService iservice = service.getWS2007FederationHttpBindingIService();

    BindingProvider bindingProvider = (BindingProvider) iservice;
    bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
            ClaimsAwareServiceFactory.SERVICE_LOCATION);

    InputStream wsdlInputStream = CrabReadTest.class.getResourceAsStream("/ClaimsAwareService.wsdl");
    assertNotNull(wsdlInputStream);/*ww w . j ava  2  s.  co  m*/

    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    documentBuilderFactory.setNamespaceAware(true);
    DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
    Document wsdlDocument = documentBuilder.parse(wsdlInputStream);

    NodeList requestSecurityTokenTemplateNodeList = wsdlDocument
            .getElementsByTagNameNS(WSConstants.WS_SECURITY_POLICY_NAMESPACE, "RequestSecurityTokenTemplate");
    assertEquals(1, requestSecurityTokenTemplateNodeList.getLength());
    Element requestSecurityTokenTemplateElement = (Element) requestSecurityTokenTemplateNodeList.item(0);
    NodeList secondaryParametersNodeList = requestSecurityTokenTemplateElement.getChildNodes();

    IPSTSClient ipStsClient = new IPSTSClient(
            "https://auth.beta.agiv.be/ipsts/Services/DaliSecurityTokenServiceConfiguration.svc/IWSTrust13",
            AGIVSecurity.BETA_REALM, secondaryParametersNodeList);
    SecurityToken ipStsSecurityToken = ipStsClient.getSecurityToken(this.config.getUsername(),
            this.config.getPassword());

    RSTSClient rStsClient = new RSTSClient(
            "https://auth.beta.agiv.be/sts/Services/SalvadorSecurityTokenServiceConfiguration.svc/IWSTrust13");
    SecurityToken rStsSecurityToken = rStsClient.getSecurityToken(ipStsSecurityToken,
            ClaimsAwareServiceFactory.SERVICE_REALM);

    Binding binding = bindingProvider.getBinding();
    List<Handler> handlerChain = binding.getHandlerChain();
    WSAddressingHandler wsAddressingHandler = new WSAddressingHandler();
    handlerChain.add(wsAddressingHandler);
    WSSecurityHandler wsSecurityHandler = new WSSecurityHandler();
    handlerChain.add(wsSecurityHandler);
    handlerChain.add(new LoggingHandler());
    binding.setHandlerChain(handlerChain);

    wsAddressingHandler.setAddressing("http://www.agiv.be/IService/GetData",
            ClaimsAwareServiceFactory.SERVICE_LOCATION);
    wsSecurityHandler.setKey(rStsSecurityToken.getKey(), rStsSecurityToken.getAttachedReference(),
            rStsSecurityToken.getToken(), true);

    ArrayOfClaimInfo result = iservice.getData(0);

    List<ClaimInfo> claims = result.getClaimInfo();
    boolean myName = false;
    for (ClaimInfo claim : claims) {
        LOG.debug(claim.getName() + " = " + claim.getValue());
        if (this.config.getUsername().equals(claim.getValue())) {
            myName = true;
        }
    }
    assertTrue(myName);
}