Search in sources :

Example 1 with SoapBody

use of org.springframework.ws.soap.SoapBody in project OpenClinica by OpenClinica.

the class UserPermissionInterceptor method handleRequest.

public boolean handleRequest(MessageContext messageContext, Object endpoint) throws Exception {
    ResourceBundleProvider.updateLocale(new Locale("en_US"));
    Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    String username = null;
    if (principal instanceof UserDetails) {
        username = ((UserDetails) principal).getUsername();
    } else {
        username = principal.toString();
    }
    UserAccountDAO userAccountDao = new UserAccountDAO(dataSource);
    UserAccountBean userAccountBean = ((UserAccountBean) userAccountDao.findByUserName(username));
    Boolean result = userAccountBean.getRunWebservices();
    if (!result) {
        SoapBody response = ((SoapMessage) messageContext.getResponse()).getSoapBody();
        response.addClientOrSenderFault("Authorization is required to execute SOAP web services with this account.Please contact your administrator.", Locale.ENGLISH);
        return false;
    } else {
        return result;
    }
}
Also used : Locale(java.util.Locale) UserDetails(org.springframework.security.core.userdetails.UserDetails) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) SoapBody(org.springframework.ws.soap.SoapBody) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) SoapMessage(org.springframework.ws.soap.SoapMessage)

Example 2 with SoapBody

use of org.springframework.ws.soap.SoapBody in project webservices-axiom by apache.

the class TestCreateWebServiceMessage method runTest.

@Override
protected void runTest(SoapMessageFactory messageFactory) {
    SoapMessage message = messageFactory.createWebServiceMessage();
    SoapEnvelope env = message.getEnvelope();
    assertNotNull(env);
    assertEquals(spec.getEnvelopeQName(), env.getName());
    SoapHeader header = env.getHeader();
    assertNotNull(header);
    assertEquals(spec.getHeaderQName(), header.getName());
    SoapBody body = env.getBody();
    assertNotNull(body);
    assertEquals(spec.getHeaderQName(), header.getName());
}
Also used : SoapEnvelope(org.springframework.ws.soap.SoapEnvelope) SoapBody(org.springframework.ws.soap.SoapBody) SoapHeader(org.springframework.ws.soap.SoapHeader) SoapMessage(org.springframework.ws.soap.SoapMessage)

Aggregations

SoapBody (org.springframework.ws.soap.SoapBody)2 SoapMessage (org.springframework.ws.soap.SoapMessage)2 Locale (java.util.Locale)1 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)1 UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)1 UserDetails (org.springframework.security.core.userdetails.UserDetails)1 SoapEnvelope (org.springframework.ws.soap.SoapEnvelope)1 SoapHeader (org.springframework.ws.soap.SoapHeader)1