Example usage for javax.xml.ws BindingProvider USERNAME_PROPERTY

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

Introduction

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

Prototype

String USERNAME_PROPERTY

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

Click Source Link

Document

Standard property: User name for authentication.

Usage

From source file:org.apache.axis2.jaxws.client.PropertyValidator.java

/**
 * Checks to see if the property value is valid given the name of the property and the type that
 * is expected by JAX-WS.//ww  w .j  a v  a 2s  .  c om
 *
 * @param propName
 * @param value
 * @return
 */
public static boolean validate(String propName, Object value) {
    if (log.isDebugEnabled()) {
        String valueText;
        if (BindingProvider.USERNAME_PROPERTY.equals(propName)
                || BindingProvider.PASSWORD_PROPERTY.equals(propName)) {
            valueText = "xxxxxx";
        } else if (value == null) {
            valueText = "null";
        } else if (value instanceof String || value instanceof Boolean || value instanceof Integer) {
            valueText = value.toString();
        } else {
            valueText = JavaUtils.getObjectIdentity(value);
        }
        log.debug("validate property=(" + propName + ") with value=(" + valueText + ")");
    }
    Class expectedType = map.get(propName);
    if (expectedType != null) {
        if (expectedType.equals(value.getClass())) {
            return true;
        } else {
            if (log.isDebugEnabled()) {
                log.debug("  not a valid property.  Expected a value of type " + expectedType);
            }
            return false;
        }
    }

    return true;
}

From source file:org.apache.juddi.adminconsole.hub.UddiAdminHub.java

private String GetToken() {
    EnsureConfig();//w ww  .j  a  v a 2s  .  c  o  m
    if (style != AuthStyle.UDDI_AUTH) {
        BindingProvider bp = null;
        if (WS_Transport) {
            Map<String, Object> context = null;
            bp = (BindingProvider) juddi;
            context = bp.getRequestContext();
            context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
            context.put(BindingProvider.USERNAME_PROPERTY,
                    session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));
        }
        return null;
    } else {
        if (token != null) {
            return token;
        }
        GetAuthToken req = new GetAuthToken();
        if (session.getAttribute("username") != null && session.getAttribute("password") != null) {
            req.setUserID((String) session.getAttribute("username"));
            req.setCred(AES.Decrypt((String) session.getAttribute("password"), (String) properties.get("key")));
            try {
                AuthToken authToken = security.getAuthToken(req);
                token = authToken.getAuthInfo();
            } catch (Exception ex) {
                return HandleException(ex);
            }
        }
    }
    return token;
}

From source file:org.apache.juddi.adminconsole.hub.UddiAdminHub.java

public String verifyLogin() {
    EnsureConfig();//from w w  w. j  av  a2  s. c o  m
    if (style != AuthStyle.UDDI_AUTH) {
        if (WS_Transport) {
            BindingProvider bp = null;
            Map<String, Object> context = null;

            bp = (BindingProvider) juddi;
            context = bp.getRequestContext();
            context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
            context.put(BindingProvider.USERNAME_PROPERTY,
                    session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));
        }
        FindBusiness fb = new FindBusiness();
        fb.setListHead(0);
        fb.setMaxRows(1);
        fb.setFindQualifiers(new FindQualifiers());
        fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
        fb.getName().add(new Name(UDDIConstants.WILDCARD, null));
        try {
            GetPublisherDetail publisherDetail = new GetPublisherDetail();
            publisherDetail.getPublisherId().add((String) session.getAttribute("username"));
            juddi.getPublisherDetail(publisherDetail);

        } catch (Exception ex) {
            return HandleException(ex);
        }
        /*
         bp = (BindingProvider) juddi;
         context = bp.getRequestContext();
         context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
         context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));*/
        return null;
    } else {
        if (token != null) {
            return token;
        }
        if (WS_Transport) {
            BindingProvider bp = null;
            Map<String, Object> context = null;

            bp = (BindingProvider) juddi;
            context = bp.getRequestContext();
            context.remove(BindingProvider.USERNAME_PROPERTY);
            context.remove(BindingProvider.PASSWORD_PROPERTY);
        }
        GetAuthToken req = new GetAuthToken();
        try {
            if (security == null) {
                security = transport.getUDDISecurityService();
            }
        } catch (Exception ex) {
            return HandleException(ex);
        }
        if (session.getAttribute("username") != null && session.getAttribute("password") != null) {
            req.setUserID((String) session.getAttribute("username"));
            req.setCred(AES.Decrypt((String) session.getAttribute("password"), (String) properties.get("key")));
            log.info("AUDIT: fetching auth token for " + req.getUserID() + " Auth Mode is "
                    + ((security == null) ? "HTTP" : "AUTH_TOKEN"));
            try {
                AuthToken authToken = security.getAuthToken(req);
                token = authToken.getAuthInfo();
                return null;
            } catch (Exception ex) {
                return HandleException(ex);
            }
        }
    }
    return "Unexpected error";
}

From source file:org.apache.juddi.example.partition.SimpleCreateTmodelPartition.java

/**
 * Gets a UDDI style auth token, otherwise, appends credentials to the
 * ws proxies (not yet implemented)/* www  . j  a  va2  s  .  co  m*/
 *
 * @param username
 * @param password
 * @param style
 * @return
 */
private String GetAuthKey(String username, String password, AuthStyle style) {
    switch (style) {
    case HTTP:
        ((BindingProvider) publish).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
        ((BindingProvider) publish).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
        return null;
    case UDDI_AUTH:
        try {

            GetAuthToken getAuthTokenRoot = new GetAuthToken();
            getAuthTokenRoot.setUserID(username);
            getAuthTokenRoot.setCred(password);

            // Making API call that retrieves the authentication token for the 'root' user.
            AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot);
            System.out.println(username + " AUTHTOKEN = (don't log auth tokens!)");
            return rootAuthToken.getAuthInfo();
        } catch (Exception ex) {
            System.out.println("Could not authenticate with the provided credentials " + ex.getMessage());
        }
    }

    return null;
}

From source file:org.apache.juddi.v3.client.transport.JAXWSTransport.java

/**
 * Sets the credentials on the RequestContext if the services are
 * protected by Basic Authentication. The username and password are
 * obtained from the uddi.xml.// w  ww.ja va2s  .c o  m
 *
 * @param requestContext
 * @throws ConfigurationException
 */
private void setCredentials(Map<String, Object> requestContext) throws ConfigurationException {
    UDDIClient client = UDDIClientContainer.getUDDIClient(clientName);
    Properties properties = client.getClientConfig().getUDDINode(nodeName).getProperties();
    if (properties != null) {
        String username = null;
        String password = null;
        if (properties.containsKey(Property.BASIC_AUTH_USERNAME)) {
            username = properties.getProperty(Property.BASIC_AUTH_USERNAME);
        }
        if (properties.containsKey(Property.BASIC_AUTH_PASSWORD)) {
            password = properties.getProperty(Property.BASIC_AUTH_PASSWORD);
        }
        String cipher = null;
        boolean isEncrypted = false;
        if (properties.containsKey(Property.BASIC_AUTH_PASSWORD_CP)) {
            cipher = properties.getProperty(Property.BASIC_AUTH_PASSWORD_CP);
        }
        if (properties.containsKey(Property.BASIC_AUTH_PASSWORD_IS_ENC)) {
            isEncrypted = Boolean.parseBoolean(properties.getProperty(Property.BASIC_AUTH_PASSWORD_IS_ENC));
        }
        if (username != null && password != null) {
            requestContext.put(BindingProvider.USERNAME_PROPERTY, username);
            if (isEncrypted) {
                try {
                    requestContext.put(BindingProvider.PASSWORD_PROPERTY,
                            CryptorFactory.getCryptor(cipher).decrypt(password));
                } catch (Exception ex) {
                    logger.error("Unable to decrypt password!", ex);
                }
            } else {
                requestContext.put(BindingProvider.PASSWORD_PROPERTY, password);
            }
        }
    }
}

From source file:org.apache.juddi.v3.client.transport.SAPRegistryJAXWSTransport.java

/**
 * Sets the credentials on the RequestContext if the services are protected
 * by Basic Authentication. The username and password are obtained from the 
 * uddi.xml./* w w  w.j a va  2  s  . c  o  m*/
 * 
 * @param requestContext
 * @throws ConfigurationException
 */
private void setCredentials(Map<String, Object> requestContext) throws ConfigurationException {
    UDDIClerkManager manager = UDDIClientContainer.getUDDIClerkManager(managerName);
    Properties properties = manager.getClientConfig().getUDDINode(nodeName).getProperties();
    String username = null;
    String password = null;
    if (properties.containsKey(Property.BASIC_AUTH_USERNAME)) {
        username = properties.getProperty(Property.BASIC_AUTH_USERNAME);
    }
    if (properties.containsKey(Property.BASIC_AUTH_PASSWORD)) {
        password = properties.getProperty(Property.BASIC_AUTH_PASSWORD);
    }
    if (username != null && password != null) {
        requestContext.put(BindingProvider.USERNAME_PROPERTY, username);
        requestContext.put(BindingProvider.PASSWORD_PROPERTY, password);
    }
}

From source file:org.apache.juddi.webconsole.hub.UddiHub.java

public String verifyLogin() {
    EnsureConfig();/*from  w  w  w . j a va2  s .  c om*/
    token = null;
    if (style != AuthStyle.UDDI_AUTH) {
        if (WS_Transport) {
            BindingProvider bp = null;
            Map<String, Object> context = null;
            bp = (BindingProvider) inquiry;
            context = bp.getRequestContext();
            context.remove(BindingProvider.USERNAME_PROPERTY);
            context.remove(BindingProvider.PASSWORD_PROPERTY);

            context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
            context.put(BindingProvider.PASSWORD_PROPERTY,
                    session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));

            bp = (BindingProvider) publish;
            context = bp.getRequestContext();
            context.remove(BindingProvider.USERNAME_PROPERTY);
            context.remove(BindingProvider.PASSWORD_PROPERTY);

            context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
            context.put(BindingProvider.PASSWORD_PROPERTY,
                    session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));

            bp = (BindingProvider) custody;
            context = bp.getRequestContext();
            context.remove(BindingProvider.USERNAME_PROPERTY);
            context.remove(BindingProvider.PASSWORD_PROPERTY);

            context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
            context.put(BindingProvider.PASSWORD_PROPERTY,
                    session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));

            bp = (BindingProvider) subscription;
            context = bp.getRequestContext();
            context.remove(BindingProvider.USERNAME_PROPERTY);
            context.remove(BindingProvider.PASSWORD_PROPERTY);

            context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
            context.put(BindingProvider.PASSWORD_PROPERTY,
                    session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));
        }
        FindBusiness fb = new FindBusiness();
        fb.setListHead(0);
        fb.setMaxRows(1);
        fb.setFindQualifiers(new FindQualifiers());
        fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
        fb.getName().add(new Name(UDDIConstants.WILDCARD, null));
        try {
            inquiry.findBusiness(fb);
        } catch (Exception ex) {
            return HandleException(ex);
        }
        /*
         bp = (BindingProvider) juddi;
         context = bp.getRequestContext();
         context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
         context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));*/
        return null;
    } else {

        if (WS_Transport) {
            BindingProvider bp = null;
            Map<String, Object> context = null;

            bp = (BindingProvider) inquiry;
            context = bp.getRequestContext();
            context.remove(BindingProvider.USERNAME_PROPERTY);
            context.remove(BindingProvider.PASSWORD_PROPERTY);

            bp = (BindingProvider) publish;
            context = bp.getRequestContext();
            context.remove(BindingProvider.USERNAME_PROPERTY);
            context.remove(BindingProvider.PASSWORD_PROPERTY);

            bp = (BindingProvider) custody;
            context = bp.getRequestContext();
            context.remove(BindingProvider.USERNAME_PROPERTY);
            context.remove(BindingProvider.PASSWORD_PROPERTY);

            bp = (BindingProvider) subscription;
            context = bp.getRequestContext();
            context.remove(BindingProvider.USERNAME_PROPERTY);
            context.remove(BindingProvider.PASSWORD_PROPERTY);
        }
        GetAuthToken req = new GetAuthToken();
        try {
            if (security == null) {
                security = transport.getUDDISecurityService();
            }
        } catch (Exception ex) {
            return HandleException(ex);
        }
        if (session.getAttribute("username") != null && session.getAttribute("password") != null) {
            req.setUserID((String) session.getAttribute("username"));
            req.setCred(AES.Decrypt((String) session.getAttribute("password"), (String) properties.get("key")));
            log.info("AUDIT: fetching auth token for " + req.getUserID() + " Auth Mode is "
                    + ((security == null) ? "HTTP" : "AUTH_TOKEN"));
            try {
                AuthToken authToken = security.getAuthToken(req);
                token = authToken.getAuthInfo();
                return null;
            } catch (Exception ex) {
                return HandleException(ex);
            }
        }
    }
    return "Unexpected error";
}

From source file:org.apache.juddi.webconsole.hub.UddiHub.java

private String GetToken() {
    EnsureConfig();//w  ww. jav a2  s  .c om
    if (style != AuthStyle.UDDI_AUTH) {
        if (WS_Transport) {
            BindingProvider bp = null;
            Map<String, Object> context = null;
            bp = (BindingProvider) inquiry;
            context = bp.getRequestContext();
            context.remove(BindingProvider.USERNAME_PROPERTY);
            context.remove(BindingProvider.PASSWORD_PROPERTY);

            context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
            context.put(BindingProvider.PASSWORD_PROPERTY,
                    session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));

            bp = (BindingProvider) publish;
            context = bp.getRequestContext();
            context.remove(BindingProvider.USERNAME_PROPERTY);
            context.remove(BindingProvider.PASSWORD_PROPERTY);

            context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
            context.put(BindingProvider.PASSWORD_PROPERTY,
                    session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));

            bp = (BindingProvider) custody;
            context = bp.getRequestContext();
            context.remove(BindingProvider.USERNAME_PROPERTY);
            context.remove(BindingProvider.PASSWORD_PROPERTY);

            context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
            context.put(BindingProvider.PASSWORD_PROPERTY,
                    session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));

            bp = (BindingProvider) subscription;
            context = bp.getRequestContext();
            context.remove(BindingProvider.USERNAME_PROPERTY);
            context.remove(BindingProvider.PASSWORD_PROPERTY);

            context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
            context.put(BindingProvider.PASSWORD_PROPERTY,
                    session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));
        }
        /*
         bp = (BindingProvider) juddi;
         context = bp.getRequestContext();
         context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
         context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));*/
        return null;
    } else {
        if (token != null) {
            return token;
        }
        if (WS_Transport) {
            BindingProvider bp = null;
            Map<String, Object> context = null;

            bp = (BindingProvider) inquiry;
            context = bp.getRequestContext();
            context.remove(BindingProvider.USERNAME_PROPERTY);
            context.remove(BindingProvider.PASSWORD_PROPERTY);

            bp = (BindingProvider) publish;
            context = bp.getRequestContext();
            context.remove(BindingProvider.USERNAME_PROPERTY);
            context.remove(BindingProvider.PASSWORD_PROPERTY);

            bp = (BindingProvider) custody;
            context = bp.getRequestContext();
            context.remove(BindingProvider.USERNAME_PROPERTY);
            context.remove(BindingProvider.PASSWORD_PROPERTY);

            bp = (BindingProvider) subscription;
            context = bp.getRequestContext();
            context.remove(BindingProvider.USERNAME_PROPERTY);
            context.remove(BindingProvider.PASSWORD_PROPERTY);
        }
        GetAuthToken req = new GetAuthToken();
        try {
            if (security == null) {
                security = transport.getUDDISecurityService();
            }
        } catch (Exception ex) {
            log.error(ex);
        }
        if (session != null && session.getAttribute("username") != null
                && session.getAttribute("password") != null) {
            req.setUserID((String) session.getAttribute("username"));
            req.setCred(AES.Decrypt((String) session.getAttribute("password"), (String) properties.get("key")));
            log.info("AUDIT: fetching auth token for " + req.getUserID() + " Auth Mode is "
                    + ((security == null) ? "HTTP" : "AUTH_TOKEN"));
            try {
                AuthToken authToken = security.getAuthToken(req);
                token = authToken.getAuthInfo();
            } catch (Exception ex) {
                return HandleException(ex);
            }
        }
    }
    return token;
}

From source file:org.miloss.fgsms.tests.ManualLoadTests.java

public void init(String url, String username, String password, boolean moreOutput) {
    this.moreOutput = moreOutput;
    if (url != null) {
        bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
    } else {/*from  w ww  . j  av a  2  s . c  o  m*/
        bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, cfg.getPCS_URLS().get(0));
    }

    if (username != null) {
        bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
    } else {
        bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, cfg.getUsername());
    }

    if (password != null) {
        bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
    } else {
        bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, Utility.DE(cfg.getPassword()));
    }

}

From source file:org.nuxeo.adullact.service.AdullactServiceImpl.java

private InterfaceParapheur serviceSOAPFactory() throws ClientException {
    // in wsdl definitions target name space
    QName qname = new QName("http://www.adullact.org/spring-ws/iparapheur/1.0", "InterfaceParapheurService");
    URL wsdlUrl = AdullactServiceImpl.class.getResource("/wsdl/iparapheur.xml.wsdl");
    Service service = Service.create(wsdlUrl, qname);

    InterfaceParapheurService ifParapheurService = new InterfaceParapheurService(wsdlUrl, qname);

    InterfaceParapheur ifParapheur = ifParapheurService.getInterfaceParapheurSoap11();

    Map<String, Object> requestContext = ((BindingProvider) ifParapheur).getRequestContext();

    requestContext.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE);
    requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, webServiceBaseURL.toString());
    requestContext.put(BindingProvider.USERNAME_PROPERTY, login);
    requestContext.put(BindingProvider.PASSWORD_PROPERTY, password);
    return ifParapheur;
}