Search in sources :

Example 1 with ResourceID

use of com.sun.identity.liberty.ws.disco.ResourceID 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 ResourceID

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

the class DiscoUtils method doEncryption.

private static ResourceOffering doEncryption(ResourceOffering current) {
    ResourceID ri = current.getResourceID();
    if (ri == null) {
        return current;
    }
    try {
        EncryptedResourceID eri = EncryptedResourceID.getEncryptedResourceID(ri, current.getServiceInstance().getProviderID());
        current.setResourceID(null);
        current.setEncryptedResourceID(eri);
    } catch (Exception e) {
        debug.error("DiscoUtils.doEncryption: exception:", e);
    }
    return current;
}
Also used : EncryptedResourceID(com.sun.identity.liberty.ws.disco.EncryptedResourceID) ResourceID(com.sun.identity.liberty.ws.disco.ResourceID) EncryptedResourceID(com.sun.identity.liberty.ws.disco.EncryptedResourceID) DiscoveryException(com.sun.identity.liberty.ws.disco.DiscoveryException)

Aggregations

EncryptedResourceID (com.sun.identity.liberty.ws.disco.EncryptedResourceID)2 ResourceID (com.sun.identity.liberty.ws.disco.ResourceID)2 Description (com.sun.identity.liberty.ws.disco.Description)1 DiscoveryException (com.sun.identity.liberty.ws.disco.DiscoveryException)1 ServiceInstance (com.sun.identity.liberty.ws.disco.ServiceInstance)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1