Search in sources :

Example 1 with ServiceInstance

use of com.sun.identity.liberty.ws.disco.ServiceInstance in project OpenAM by OpenRock.

the class DSTClient method parseResourceOffering.

/**
     * Parses the given discovery resource offering for the Data service.
     * @param offering ResourceOffering 
     * @exception DSTException.
     */
private void parseResourceOffering(ResourceOffering offering) throws DSTException {
    //Try for the encrypted resource offering first;
    encryptedResourceID = offering.getEncryptedResourceID();
    if (encryptedResourceID != null) {
        isEncryptedResourceID = true;
    } else {
        ResourceID resID = offering.getResourceID();
        if (resID == null) {
            DSTUtils.debug.error("DSTClient:parseResourceOffering: " + "No ResourceID");
            throw new DSTException(DSTUtils.bundle.getString("noResourceID"));
        }
        resourceID = resID.getResourceID();
    }
    ServiceInstance serviceInstance = offering.getServiceInstance();
    // providerID = serviceInstance.getProviderID();
    if (serviceInstance == null) {
        DSTUtils.debug.error("DSTClient:parseResourceOffering: " + "No service instance.");
        throw new DSTException(DSTUtils.bundle.getString("noServiceInstance"));
    }
    serviceType = serviceInstance.getServiceType();
    if (serviceType == null) {
        DSTUtils.debug.error("DSTClient:parseResourceOffering: " + "service type is null.");
        throw new DSTException(DSTUtils.bundle.getString("noServiceType"));
    }
    List descriptions = serviceInstance.getDescription();
    if (descriptions == null || descriptions.isEmpty()) {
        DSTUtils.debug.error("DSTClient:parseResourceOffering: " + "descriptions are null.");
        throw new DSTException(DSTUtils.bundle.getString("noDescriptions"));
    }
    // A service instance can have mutiple descriptions. In this case,
    // we will try to use a valid description. 
    Iterator iter = descriptions.iterator();
    while (iter.hasNext()) {
        Description description = (Description) iter.next();
        soapAction = description.getSoapAction();
        soapURI = description.getEndpoint();
        if (soapURI == null || soapURI.length() == 0) {
            continue;
        }
        List secMechIDs = description.getSecurityMechID();
        if (secMechIDs == null || secMechIDs.isEmpty()) {
            continue;
        }
        boolean foundProfile = false;
        int size = secMechIDs.size();
        for (int i = 0; i < size; i++) {
            String secProfile = (String) secMechIDs.get(i);
            secProfile = secProfile.trim();
            if (secProfile.equals(Message.NULL_NULL) || secProfile.equals(Message.TLS_NULL) || secProfile.equals(Message.CLIENT_TLS_NULL)) {
                securityProfile = Message.ANONYMOUS;
                if (secProfile.equals(Message.CLIENT_TLS_NULL)) {
                    clientAuthEnabled = true;
                }
                foundProfile = true;
                break;
            } else if (secProfile.equals(Message.NULL_X509) || secProfile.equals(Message.TLS_X509) || secProfile.equals(Message.CLIENT_TLS_X509) || secProfile.equals(Message.NULL_X509_WSF11) || secProfile.equals(Message.TLS_X509_WSF11) || secProfile.equals(Message.CLIENT_TLS_X509_WSF11)) {
                securityProfile = Message.X509_TOKEN;
                if (secProfile.equals(Message.NULL_X509) || secProfile.equals(Message.TLS_X509) || secProfile.equals(Message.CLIENT_TLS_X509)) {
                    wsfVersion = SOAPBindingConstants.WSF_10_VERSION;
                } else {
                    wsfVersion = SOAPBindingConstants.WSF_11_VERSION;
                }
                securityProfile = Message.X509_TOKEN;
                if (secProfile.equals(Message.CLIENT_TLS_X509) || secProfile.equals(Message.CLIENT_TLS_X509_WSF11)) {
                    clientAuthEnabled = true;
                }
                foundProfile = true;
                break;
            } else if (secProfile.equals(Message.NULL_SAML) || secProfile.equals(Message.TLS_SAML) || secProfile.equals(Message.CLIENT_TLS_SAML) || secProfile.equals(Message.NULL_SAML_WSF11) || secProfile.equals(Message.TLS_SAML_WSF11) || secProfile.equals(Message.CLIENT_TLS_SAML_WSF11)) {
                securityProfile = Message.SAML_TOKEN;
                if (secProfile.equals(Message.NULL_SAML) || secProfile.equals(Message.TLS_SAML) || secProfile.equals(Message.CLIENT_TLS_SAML)) {
                    wsfVersion = SOAPBindingConstants.WSF_10_VERSION;
                } else {
                    wsfVersion = SOAPBindingConstants.WSF_11_VERSION;
                }
                if (secProfile.equals(Message.CLIENT_TLS_SAML) || secProfile.equals(Message.CLIENT_TLS_SAML_WSF11)) {
                    clientAuthEnabled = true;
                }
                foundProfile = true;
                break;
            } else if (secProfile.equals(Message.NULL_BEARER) || secProfile.equals(Message.TLS_BEARER) || secProfile.equals(Message.CLIENT_TLS_BEARER) || secProfile.equals(Message.NULL_BEARER_WSF11) || secProfile.equals(Message.TLS_BEARER_WSF11) || secProfile.equals(Message.CLIENT_TLS_BEARER_WSF11)) {
                securityProfile = Message.BEARER_TOKEN;
                if (secProfile.equals(Message.NULL_BEARER) || secProfile.equals(Message.TLS_BEARER) || secProfile.equals(Message.CLIENT_TLS_BEARER)) {
                    wsfVersion = SOAPBindingConstants.WSF_10_VERSION;
                } else {
                    wsfVersion = SOAPBindingConstants.WSF_11_VERSION;
                }
                if (secProfile.equals(Message.CLIENT_TLS_BEARER) || secProfile.equals(Message.CLIENT_TLS_BEARER_WSF11)) {
                    clientAuthEnabled = true;
                }
                foundProfile = true;
                break;
            }
        }
        if (foundProfile) {
            break;
        }
    }
    if (soapURI == null) {
        DSTUtils.debug.error("DSTClient:parseResourceOffering: " + "SOAP Endpoint or security profile is null");
        throw new DSTException(DSTUtils.bundle.getString("invalidResourceOffering"));
    }
    if (DSTUtils.debug.messageEnabled()) {
        DSTUtils.debug.message("DSTClient.parseResourceOffering:" + "soapURI = " + soapURI + "soapAction = " + soapAction + "securityProfile = " + securityProfile);
    }
}
Also used : Description(com.sun.identity.liberty.ws.disco.Description) EncryptedResourceID(com.sun.identity.liberty.ws.disco.EncryptedResourceID) ResourceID(com.sun.identity.liberty.ws.disco.ResourceID) Iterator(java.util.Iterator) ServiceInstance(com.sun.identity.liberty.ws.disco.ServiceInstance) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with ServiceInstance

use of com.sun.identity.liberty.ws.disco.ServiceInstance in project OpenAM by OpenRock.

the class MessageProcessor method processResourceOffering.

/**
     * Returns security profile after parsing the resource offering.
     */
private String processResourceOffering(ResourceOffering offering) throws SOAPBindingException {
    try {
        ServiceInstance si = offering.getServiceInstance();
        List descriptions = si.getDescription();
        if (descriptions == null || descriptions.isEmpty()) {
            Utils.debug.error("MessageProcessor:processResourceOffering: " + "descriptions are null.");
            throw new SOAPBindingException(Utils.bundle.getString("noDescriptions"));
        }
        Iterator iter = descriptions.iterator();
        while (iter.hasNext()) {
            Description desc = (Description) iter.next();
            List secMechIDs = desc.getSecurityMechID();
            if (secMechIDs == null || secMechIDs.isEmpty()) {
                Utils.debug.error("MessageProcessor.processResourceOffering:" + " security Mechs are empty");
                throw new SOAPBindingException(Utils.bundle.getString("noSecurityMechs"));
            }
            return (String) secMechIDs.iterator().next();
        }
        //It should not come over here.
        throw new SOAPBindingException(Utils.bundle.getString("noSecurityMechs"));
    } catch (Exception ex) {
        Utils.debug.error("MessageProcessor.processResourceOffering: " + "Failed in processing the resource offering.", ex);
        throw new SOAPBindingException(Utils.bundle.getString("processOfferingFailed"));
    }
}
Also used : Description(com.sun.identity.liberty.ws.disco.Description) Iterator(java.util.Iterator) ServiceInstance(com.sun.identity.liberty.ws.disco.ServiceInstance) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) List(java.util.List) SOAPException(javax.xml.soap.SOAPException)

Aggregations

Description (com.sun.identity.liberty.ws.disco.Description)2 ServiceInstance (com.sun.identity.liberty.ws.disco.ServiceInstance)2 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 List (java.util.List)2 EncryptedResourceID (com.sun.identity.liberty.ws.disco.EncryptedResourceID)1 ResourceID (com.sun.identity.liberty.ws.disco.ResourceID)1 SOAPException (javax.xml.soap.SOAPException)1 NodeList (org.w3c.dom.NodeList)1