Java Code Examples for javax.xml.ws.BindingProvider#USERNAME_PROPERTY

The following examples show how to use javax.xml.ws.BindingProvider#USERNAME_PROPERTY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BesDAO.java    From development with Apache License 2.0 5 votes vote down vote up
String getUsernameConstant(Map<String, Setting> settings) {
    if (isSsoMode(settings)) {
        return XWSSConstants.USERNAME_PROPERTY;
    } else {
        return BindingProvider.USERNAME_PROPERTY;
    }
}
 
Example 2
Source File: BSSWebServiceFactory.java    From development with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a OSCM Web service with the given parameters.
 * 
 * @param serviceClass
 *            the class of the Web service to be created
 * @param authentication
 *            a <code>PasswordAuthentication</code> object specifying the
 *            credentials to be used for authentication
 * @return the service class
 * @throws ConfigurationException
 *             if the configuration of the platform is incorrect
 * @throws MalformedURLException
 *             if the base URL of the OSCM configuration is malformed
 */
public static <T> T getBSSWebService(Class<T> serviceClass,
        PasswordAuthentication authentication)
        throws ConfigurationException, MalformedURLException {

    String targetNamespace = serviceClass.getAnnotation(WebService.class)
            .targetNamespace();
    QName serviceQName = new QName(targetNamespace,
            serviceClass.getSimpleName());

    String wsdlUrl = APPlatformServiceFactory.getInstance()
            .getBSSWebServiceWSDLUrl();
    wsdlUrl = wsdlUrl.replace("{SERVICE}", serviceClass.getSimpleName());
    String serviceUrl = APPlatformServiceFactory.getInstance()
    .getBSSWebServiceUrl();
    serviceUrl=serviceUrl.replace("{SERVICE}", serviceClass.getSimpleName());
    Service service = Service.create(new URL(wsdlUrl), serviceQName);

    boolean isSsoMode = wsdlUrl != null
            && wsdlUrl.toLowerCase().endsWith("/sts?wsdl");
    String portSuffix = isSsoMode ? "PortSTS" : "PortBASIC";

    T client = service.getPort(
            new QName(targetNamespace, serviceClass.getSimpleName()
                    + portSuffix), serviceClass);

    String usernameConstant = isSsoMode ? XWSSConstants.USERNAME_PROPERTY
            : BindingProvider.USERNAME_PROPERTY;
    String passwordConstant = isSsoMode ? XWSSConstants.PASSWORD_PROPERTY
            : BindingProvider.PASSWORD_PROPERTY;

    Map<String, Object> clientRequestContext = ((BindingProvider) client)
            .getRequestContext();
    clientRequestContext
            .put(usernameConstant, authentication.getUserName());
    clientRequestContext
            .put(passwordConstant, authentication.getPassword());
    clientRequestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
            serviceUrl );
    return client;
}
 
Example 3
Source File: BSSWebServiceFactory.java    From development with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a OSCM Web service with the given parameters.
 * 
 * @param serviceClass
 *            the class of the Web service to be created
 * @param authentication
 *            a <code>PasswordAuthentication</code> object specifying the
 *            credentials to be used for authentication
 * @return the service class
 * @throws ConfigurationException
 *             if the configuration of the platform is incorrect
 * @throws MalformedURLException
 *             if the base URL of the OSCM configuration is malformed
 */
public static <T> T getBSSWebService(Class<T> serviceClass,
        PasswordAuthentication authentication)
        throws ConfigurationException, MalformedURLException {

    String targetNamespace = serviceClass.getAnnotation(WebService.class)
            .targetNamespace();
    QName serviceQName = new QName(targetNamespace,
            serviceClass.getSimpleName());

    String wsdlUrl = APPlatformServiceFactory.getInstance()
            .getBSSWebServiceWSDLUrl();
    wsdlUrl = wsdlUrl.replace("{SERVICE}", serviceClass.getSimpleName());
    String serviceUrl = APPlatformServiceFactory.getInstance()
    .getBSSWebServiceUrl();
    serviceUrl=serviceUrl.replace("{SERVICE}", serviceClass.getSimpleName());
    Service service = Service.create(new URL(wsdlUrl), serviceQName);

    boolean isSsoMode = wsdlUrl != null
            && wsdlUrl.toLowerCase().endsWith("/sts?wsdl");
    String portSuffix = isSsoMode ? "PortSTS" : "PortBASIC";

    T client = service.getPort(
            new QName(targetNamespace, serviceClass.getSimpleName()
                    + portSuffix), serviceClass);

    String usernameConstant = isSsoMode ? XWSSConstants.USERNAME_PROPERTY
            : BindingProvider.USERNAME_PROPERTY;
    String passwordConstant = isSsoMode ? XWSSConstants.PASSWORD_PROPERTY
            : BindingProvider.PASSWORD_PROPERTY;

    Map<String, Object> clientRequestContext = ((BindingProvider) client)
            .getRequestContext();
    clientRequestContext
            .put(usernameConstant, authentication.getUserName());
    clientRequestContext
            .put(passwordConstant, authentication.getPassword());
    clientRequestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
            serviceUrl );
    return client;
}