Search in sources :

Example 1 with GenerateBearerTokenElement

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

Example 2 with GenerateBearerTokenElement

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

the class SMDiscoveryServiceData method getDirectiveEntry.

/**
     * Returns map of directive entries.
     *
     * @return map of directive entries.
     */
public static Map getDirectiveEntry(DiscoEntryElement entry) {
    Map map = Collections.EMPTY_MAP;
    List directiveList = entry.getAny();
    if ((directiveList != null) && !directiveList.isEmpty()) {
        map = new HashMap(directiveList.size() * 2);
        for (Iterator iter = directiveList.iterator(); iter.hasNext(); ) {
            Object obj = iter.next();
            ;
            if (obj instanceof AuthenticateRequesterElement) {
                AuthenticateRequesterElement dType = (AuthenticateRequesterElement) obj;
                setDirectiveData(dType, map, DiscoConstants.AUTHN_DIRECTIVE);
            } else if (obj instanceof EncryptResourceIDElement) {
                EncryptResourceIDElement dType = (EncryptResourceIDElement) obj;
                setDirectiveData(dType, map, DiscoConstants.ENCRYPT_DIRECTIVE);
            } else if (obj instanceof AuthenticateSessionContextElement) {
                AuthenticateSessionContextElement dType = (AuthenticateSessionContextElement) obj;
                setDirectiveData(dType, map, DiscoConstants.SESSION_DIRECTIVE);
            } else if (obj instanceof AuthorizeRequesterElement) {
                AuthorizeRequesterElement dType = (AuthorizeRequesterElement) obj;
                setDirectiveData(dType, map, DiscoConstants.AUTHZ_DIRECTIVE);
            } else if (obj instanceof GenerateBearerTokenElement) {
                GenerateBearerTokenElement dType = (GenerateBearerTokenElement) obj;
                setDirectiveData(dType, map, DiscoConstants.BEARER_DIRECTIVE);
            } else if (obj instanceof SendSingleLogOutElement) {
                SendSingleLogOutElement dType = (SendSingleLogOutElement) obj;
                setDirectiveData(dType, map, DiscoConstants.LOGOUT_DIRECTIVE);
            } else {
                debug.error("unsupported directive type");
            }
        }
    }
    return map;
}
Also used : GenerateBearerTokenElement(com.sun.identity.liberty.ws.disco.jaxb11.GenerateBearerTokenElement) SendSingleLogOutElement(com.sun.identity.liberty.ws.disco.jaxb11.SendSingleLogOutElement) HashMap(java.util.HashMap) EncryptResourceIDElement(com.sun.identity.liberty.ws.disco.jaxb.EncryptResourceIDElement) Iterator(java.util.Iterator) AuthenticateRequesterElement(com.sun.identity.liberty.ws.disco.jaxb.AuthenticateRequesterElement) ArrayList(java.util.ArrayList) List(java.util.List) AuthenticateSessionContextElement(com.sun.identity.liberty.ws.disco.jaxb.AuthenticateSessionContextElement) HashMap(java.util.HashMap) Map(java.util.Map) AuthorizeRequesterElement(com.sun.identity.liberty.ws.disco.jaxb.AuthorizeRequesterElement)

Example 3 with GenerateBearerTokenElement

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

the class SMDiscoEntryData method createDirectivesEntry.

private void createDirectivesEntry(DiscoEntryElement de, List descriptionTypeList) throws JAXBException, AMConsoleException {
    if ((directives != null) && !directives.isEmpty()) {
        Set set = directives.keySet();
        for (Iterator iter = set.iterator(); iter.hasNext(); ) {
            String dName = (String) iter.next();
            List idRefs = (List) directives.get(dName);
            if (dName.equals(DiscoConstants.AUTHN_DIRECTIVE)) {
                AuthenticateRequesterElement authenticateRequester = discoFac.createAuthenticateRequesterElement();
                createDirectiveEntry(de, authenticateRequester, idRefs, descriptionTypeList);
            } else if (dName.equals(DiscoConstants.ENCRYPT_DIRECTIVE)) {
                EncryptResourceIDElement encryptResourceId = discoFac.createEncryptResourceIDElement();
                createDirectiveEntry(de, encryptResourceId, idRefs, descriptionTypeList);
            } else if (dName.equals(DiscoConstants.SESSION_DIRECTIVE)) {
                AuthenticateSessionContextElement authSessionCntx = discoFac.createAuthenticateSessionContextElement();
                createDirectiveEntry(de, authSessionCntx, idRefs, descriptionTypeList);
            } else if (dName.equals(DiscoConstants.AUTHZ_DIRECTIVE)) {
                AuthorizeRequesterElement authorizeRequester = discoFac.createAuthorizeRequesterElement();
                createDirectiveEntry(de, authorizeRequester, idRefs, descriptionTypeList);
            } else if (dName.equals(DiscoConstants.BEARER_DIRECTIVE)) {
                GenerateBearerTokenElement bearer = disco11Fac.createGenerateBearerTokenElement();
                createDirectiveEntry(de, bearer, idRefs, descriptionTypeList);
            } else if (dName.equals(DiscoConstants.LOGOUT_DIRECTIVE)) {
                SendSingleLogOutElement logout = disco11Fac.createSendSingleLogOutElement();
                createDirectiveEntry(de, logout, idRefs, descriptionTypeList);
            }
        }
    }
}
Also used : GenerateBearerTokenElement(com.sun.identity.liberty.ws.disco.jaxb11.GenerateBearerTokenElement) SendSingleLogOutElement(com.sun.identity.liberty.ws.disco.jaxb11.SendSingleLogOutElement) HashSet(java.util.HashSet) Set(java.util.Set) EncryptResourceIDElement(com.sun.identity.liberty.ws.disco.jaxb.EncryptResourceIDElement) Iterator(java.util.Iterator) AuthenticateRequesterElement(com.sun.identity.liberty.ws.disco.jaxb.AuthenticateRequesterElement) ArrayList(java.util.ArrayList) List(java.util.List) AuthenticateSessionContextElement(com.sun.identity.liberty.ws.disco.jaxb.AuthenticateSessionContextElement) AuthorizeRequesterElement(com.sun.identity.liberty.ws.disco.jaxb.AuthorizeRequesterElement)

Aggregations

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