Search in sources :

Example 1 with InsertEntryType

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

the class DiscoEntryHandlerImplUtils method handleInserts.

/*
     * Adds discovery entries.
     * Used by implementations of SPI <code>DiscoEntryHandler</code>:
     * <code>UserDiscoEntryHandler</code> and
     * <code>UserDynamicEntryHandler</code>.
     *
     * @param discoEntriesMap Discovery Entries Map.
     * @param removes List of entries to be added.
     * @return true if the operation is successful; false otherwise.
     */
public static Map handleInserts(Set discoEntries, List inserts) {
    /*
         * if support proxy:
         * look through discoEntries and find all the serviceTypes that have
         *  proxy proxyServiceTypes
         */
    Map insertResults = new HashMap();
    insertResults.put(DiscoEntryHandler.STATUS_CODE, DiscoConstants.STATUS_FAILED);
    Set supportedDirectives = DiscoServiceManager.getSupportedDirectives();
    if (debug.messageEnabled()) {
        debug.message("DiscoEntryHandlerImplUtils.handleInserts: " + "size of supportedDirective is " + supportedDirectives.size());
    }
    Iterator i = inserts.iterator();
    InsertEntryType insertEntry = null;
    DiscoEntryElement de = null;
    ResourceOfferingType resOff = null;
    List newEntryIDs = new LinkedList();
    while (i.hasNext()) {
        insertEntry = (InsertEntryType) i.next();
        try {
            de = DiscoUtils.getDiscoEntryFactory().createDiscoEntryElement();
        } catch (JAXBException je) {
            debug.error("DiscoEntryHandlerImplUtils.handleInserts: couldn't " + "create DiscoEntry: ", je);
            return insertResults;
        }
        resOff = insertEntry.getResourceOffering();
        String newEntryID = SAMLUtils.generateID();
        if (debug.messageEnabled()) {
            debug.message("DiscoEntryHandlerImplUtils: newEntryID=" + newEntryID);
        }
        resOff.setEntryID(newEntryID);
        newEntryIDs.add(newEntryID);
        de.setResourceOffering(resOff);
        List dirs = insertEntry.getAny();
        if ((dirs != null) && !dirs.isEmpty()) {
            Iterator j = dirs.iterator();
            while (j.hasNext()) {
                Object dir = j.next();
                if (dir instanceof AuthenticateRequesterElement) {
                    if (!supportedDirectives.contains(DiscoConstants.AUTHN_DIRECTIVE)) {
                        debug.error("Directive AuthenticateRequester is " + "not supported.");
                        return insertResults;
                    }
                } else if (dir instanceof AuthorizeRequesterElement) {
                    if (!supportedDirectives.contains(DiscoConstants.AUTHZ_DIRECTIVE)) {
                        debug.error("Directive AuthorizeRequester is " + "not supported.");
                        return insertResults;
                    }
                } else if (dir instanceof AuthenticateSessionContextElement) {
                    if (!supportedDirectives.contains(DiscoConstants.SESSION_DIRECTIVE)) {
                        debug.error("Directive AuthenticateSessionContext " + "is not supported.");
                        return insertResults;
                    }
                } else if (dir instanceof EncryptResourceIDElement) {
                    if (!supportedDirectives.contains(DiscoConstants.ENCRYPT_DIRECTIVE)) {
                        debug.error("Directive EncryptResourceID " + "is not supported.");
                        return insertResults;
                    }
                } else if (dir instanceof GenerateBearerTokenElement) {
                    if (!supportedDirectives.contains(DiscoConstants.BEARER_DIRECTIVE)) {
                        debug.error("Directive GenerateBearerToken " + "is not supported.");
                        return insertResults;
                    }
                } else {
                    debug.error("Directive " + dir + " is not supported.");
                    return insertResults;
                }
            }
            de.getAny().addAll(dirs);
        }
        if (!discoEntries.add(de)) {
            debug.error("DiscoEntryHandlerImplUtils.handleInserts: couldn't " + "add DiscoEntry to Set.");
            return insertResults;
        }
    }
    insertResults.put(DiscoEntryHandler.STATUS_CODE, DiscoConstants.STATUS_OK);
    insertResults.put(DiscoEntryHandler.NEW_ENTRY_IDS, newEntryIDs);
    return insertResults;
}
Also used : GenerateBearerTokenElement(com.sun.identity.liberty.ws.disco.jaxb11.GenerateBearerTokenElement) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) JAXBException(javax.xml.bind.JAXBException) ResourceOfferingType(com.sun.identity.liberty.ws.disco.jaxb.ResourceOfferingType) AuthenticateSessionContextElement(com.sun.identity.liberty.ws.disco.jaxb.AuthenticateSessionContextElement) DiscoEntryElement(com.sun.identity.liberty.ws.disco.plugins.jaxb.DiscoEntryElement) AuthorizeRequesterElement(com.sun.identity.liberty.ws.disco.jaxb.AuthorizeRequesterElement) LinkedList(java.util.LinkedList) EncryptResourceIDElement(com.sun.identity.liberty.ws.disco.jaxb.EncryptResourceIDElement) Iterator(java.util.Iterator) AuthenticateRequesterElement(com.sun.identity.liberty.ws.disco.jaxb.AuthenticateRequesterElement) LinkedList(java.util.LinkedList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) InsertEntryType(com.sun.identity.liberty.ws.disco.jaxb.InsertEntryType)

Aggregations

AuthenticateRequesterElement (com.sun.identity.liberty.ws.disco.jaxb.AuthenticateRequesterElement)1 AuthenticateSessionContextElement (com.sun.identity.liberty.ws.disco.jaxb.AuthenticateSessionContextElement)1 AuthorizeRequesterElement (com.sun.identity.liberty.ws.disco.jaxb.AuthorizeRequesterElement)1 EncryptResourceIDElement (com.sun.identity.liberty.ws.disco.jaxb.EncryptResourceIDElement)1 InsertEntryType (com.sun.identity.liberty.ws.disco.jaxb.InsertEntryType)1 ResourceOfferingType (com.sun.identity.liberty.ws.disco.jaxb.ResourceOfferingType)1 GenerateBearerTokenElement (com.sun.identity.liberty.ws.disco.jaxb11.GenerateBearerTokenElement)1 DiscoEntryElement (com.sun.identity.liberty.ws.disco.plugins.jaxb.DiscoEntryElement)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 JAXBException (javax.xml.bind.JAXBException)1