Search in sources :

Example 6 with ResourceOfferingType

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

the class SMDiscoveryServiceData method setDiscoEntryData.

private static void setDiscoEntryData(DiscoEntryElement entry, SMDiscoEntryData smDisco) {
    ResourceOfferingType resOff = entry.getResourceOffering();
    ResourceIDType resourceIdType = resOff.getResourceID();
    ServiceInstanceType serviceInstance = resOff.getServiceInstance();
    String providerID = serviceInstance.getProviderID();
    String serviceType = serviceInstance.getServiceType();
    smDisco.entryId = resOff.getEntryID();
    smDisco.resourceIdAttribute = resourceIdType.getId();
    smDisco.resourceIdValue = resourceIdType.getValue();
    smDisco.serviceType = serviceType;
    smDisco.providerId = providerID;
    smDisco.abstractValue = resOff.getAbstract();
    OptionsType optType = resOff.getOptions();
    if (optType != null) {
        smDisco.options = optType.getOption();
        smDisco.noOption = false;
    } else {
        smDisco.noOption = true;
    }
    List list = serviceInstance.getDescription();
    if (list != null && !list.isEmpty()) {
        for (Iterator iter = list.iterator(); iter.hasNext(); ) {
            SMDescriptionData smDesc = new SMDescriptionData();
            DescriptionType desc = (DescriptionType) iter.next();
            smDesc.setDescriptionEntry(desc);
            smDisco.descData.add(smDesc);
        }
    } else {
        debug.error("SMDiscoveryServiceData.setDiscoEntryData: " + "No description exists in the disco entry");
    }
    smDisco.directives = getDirectiveEntry(entry);
}
Also used : ServiceInstanceType(com.sun.identity.liberty.ws.disco.jaxb.ServiceInstanceType) DescriptionType(com.sun.identity.liberty.ws.disco.jaxb.DescriptionType) ResourceOfferingType(com.sun.identity.liberty.ws.disco.jaxb.ResourceOfferingType) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) ResourceIDType(com.sun.identity.liberty.ws.disco.jaxb.ResourceIDType) OptionsType(com.sun.identity.liberty.ws.disco.jaxb.OptionsType)

Example 7 with ResourceOfferingType

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

the class AuthnSvcUtils method setResourceOfferingAndCredentials.

/**
     * Sets resource offering and credentials to the SASL response based on
     * provided sso token.
     * @param saslResp a SASL response
     * @param message a SOAP message containing a SASL request
     * @param userDN Distinguished Name of the User.
     * @return <code>true</code> if it sets correctly
     */
public static boolean setResourceOfferingAndCredentials(SASLResponse saslResp, Message message, String userDN) {
    try {
        DiscoEntryElement discoEntry = (DiscoEntryElement) DiscoServiceManager.getBootstrappingDiscoEntry();
        ResourceOfferingType offering = discoEntry.getResourceOffering();
        if (!DiscoServiceManager.useImpliedResource()) {
            ServiceInstanceType serviceInstance = offering.getServiceInstance();
            String providerID = serviceInstance.getProviderID();
            ResourceIDMapper idMapper = DiscoServiceManager.getResourceIDMapper(providerID);
            if (idMapper == null) {
                idMapper = DiscoServiceManager.getDefaultResourceIDMapper();
            }
            ObjectFactory fac = new com.sun.identity.liberty.ws.disco.jaxb.ObjectFactory();
            ResourceIDType resourceID = fac.createResourceIDType();
            String resourceIDValue = idMapper.getResourceID(providerID, userDN);
            if (AuthnSvcUtils.debug.messageEnabled()) {
                AuthnSvcUtils.debug.message("AuthnSvcUtils.setResourceOfferingAndCredentials" + "Offering: ResourceID Value:" + resourceIDValue);
            }
            resourceID.setValue(resourceIDValue);
            offering.setResourceID(resourceID);
        } else {
            ObjectFactory fac = new com.sun.identity.liberty.ws.disco.jaxb.ObjectFactory();
            ResourceIDType resourceID = fac.createResourceIDType();
            resourceID.setValue(DiscoConstants.IMPLIED_RESOURCE);
            offering.setResourceID(resourceID);
        }
        List discoEntryList = new ArrayList();
        discoEntryList.add(discoEntry);
        Map map = DiscoUtils.checkPolicyAndHandleDirectives(userDN, message, discoEntryList, null, null, null, message.getToken());
        List offerings = (List) map.get(DiscoUtils.OFFERINGS);
        if (offerings.isEmpty()) {
            if (AuthnSvcUtils.debug.messageEnabled()) {
                AuthnSvcUtils.debug.message("AuthnSvcUtils.setResourceOfferingAndCredentials" + "no ResourceOffering");
            }
            return false;
        }
        ResourceOffering ro = (ResourceOffering) offerings.get(0);
        saslResp.setResourceOffering(ro);
        List assertions = (List) map.get(DiscoUtils.CREDENTIALS);
        if ((assertions != null) && (!assertions.isEmpty())) {
            Iterator iter = assertions.iterator();
            List credentials = new ArrayList();
            while (iter.hasNext()) {
                SecurityAssertion assertion = (SecurityAssertion) iter.next();
                Document doc = XMLUtils.toDOMDocument(assertion.toString(true, true), AuthnSvcUtils.debug);
                credentials.add(doc.getDocumentElement());
            }
            saslResp.setCredentials(credentials);
        }
        return true;
    } catch (Exception ex) {
        debug.error("AuthnSvcUtils.setResourceOfferingAndCredentials:", ex);
        return false;
    }
}
Also used : ResourceOffering(com.sun.identity.liberty.ws.disco.ResourceOffering) ResourceOfferingType(com.sun.identity.liberty.ws.disco.jaxb.ResourceOfferingType) ArrayList(java.util.ArrayList) SecurityAssertion(com.sun.identity.liberty.ws.security.SecurityAssertion) Document(org.w3c.dom.Document) DiscoEntryElement(com.sun.identity.liberty.ws.disco.plugins.jaxb.DiscoEntryElement) ServiceInstanceType(com.sun.identity.liberty.ws.disco.jaxb.ServiceInstanceType) ResourceIDMapper(com.sun.identity.liberty.ws.interfaces.ResourceIDMapper) ObjectFactory(com.sun.identity.liberty.ws.disco.jaxb.ObjectFactory) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) ResourceIDType(com.sun.identity.liberty.ws.disco.jaxb.ResourceIDType) Map(java.util.Map)

Aggregations

ResourceOfferingType (com.sun.identity.liberty.ws.disco.jaxb.ResourceOfferingType)7 DiscoEntryElement (com.sun.identity.liberty.ws.disco.plugins.jaxb.DiscoEntryElement)6 List (java.util.List)6 ResourceIDType (com.sun.identity.liberty.ws.disco.jaxb.ResourceIDType)5 Iterator (java.util.Iterator)5 Map (java.util.Map)5 ServiceInstanceType (com.sun.identity.liberty.ws.disco.jaxb.ServiceInstanceType)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)3 JAXBException (javax.xml.bind.JAXBException)3 ResourceOffering (com.sun.identity.liberty.ws.disco.ResourceOffering)2 ObjectFactory (com.sun.identity.liberty.ws.disco.jaxb.ObjectFactory)2 ResourceIDMapper (com.sun.identity.liberty.ws.interfaces.ResourceIDMapper)2 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 Set (java.util.Set)2 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)1 AuthnContext (com.sun.identity.federation.message.common.AuthnContext)1 EncryptedNameIdentifier (com.sun.identity.federation.message.common.EncryptedNameIdentifier)1 IDPProvidedNameIdentifier (com.sun.identity.federation.message.common.IDPProvidedNameIdentifier)1