Search in sources :

Example 16 with FederationConfigElement

use of com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement in project OpenAM by OpenRock.

the class WSFedPropertiesModelImpl method createExtendedObject.

/**
     * Creates the extended config object when it does not exist.
     * @param realm to which the entity belongs.
     * @param fedId is the entity id.
     * @param location is either hosted or remote
     * @param role is SP, IDP or SP/IDP.
     * @param keys which contain all extended attribute keys.
     * @throws WSFederationMetaException, JAXBException,
     *     AMConsoleException if saving of attribute value fails.
     */
private void createExtendedObject(String realm, String fedId, String location, String role, Map keys) throws WSFederationMetaException, JAXBException, AMConsoleException {
    try {
        ObjectFactory objFactory = new ObjectFactory();
        WSFederationMetaManager metaManager = getWSFederationMetaManager();
        FederationElement edes = metaManager.getEntityDescriptor(realm, fedId);
        if (edes == null) {
            if (debug.warningEnabled()) {
                debug.warning("WSFedPropertiesModelImpl.createExtendedObject: " + "No such entity: " + fedId);
            }
            String[] data = { realm, fedId };
            throw new WSFederationMetaException("fedId_invalid", data);
        }
        FederationConfigElement eConfig = metaManager.getEntityConfig(realm, fedId);
        if (eConfig == null) {
            BaseConfigType bctype = null;
            FederationConfigElement ele = objFactory.createFederationConfigElement();
            ele.setFederationID(fedId);
            if (location.equals("remote")) {
                ele.setHosted(false);
            }
            List ll = ele.getIDPSSOConfigOrSPSSOConfig();
            // Right now, it is either an SP or an IdP or dual role
            if (isDualRole(edes)) {
                //for dual role create both idp and sp config objects
                BaseConfigType bctype_idp = null;
                BaseConfigType bctype_sp = null;
                bctype_idp = objFactory.createIDPSSOConfigElement();
                bctype_idp = createAttributeElement(keys, bctype_idp);
                bctype_sp = objFactory.createSPSSOConfigElement();
                bctype_sp = createAttributeElement(keys, bctype_sp);
                ll.add(bctype_idp);
                ll.add(bctype_sp);
            } else if (role.equals(IDENTITY_PROVIDER)) {
                bctype = objFactory.createIDPSSOConfigElement();
                //bctype.getAttribute().add(atype);
                bctype = createAttributeElement(keys, bctype);
                ll.add(bctype);
            } else if (role.equals(SERVICE_PROVIDER)) {
                bctype = objFactory.createSPSSOConfigElement();
                bctype = createAttributeElement(keys, bctype);
                ll.add(bctype);
            }
            metaManager.setEntityConfig(realm, ele);
        }
    } catch (JAXBException e) {
        debug.warning("WSFedPropertiesModelImpl.createExtendedObject", e);
        throw new AMConsoleException(getErrorString(e));
    } catch (WSFederationMetaException e) {
        debug.warning("WSFedPropertiesModelImpl.createExtendedObject", e);
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : BaseConfigType(com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType) WSFederationMetaManager(com.sun.identity.wsfederation.meta.WSFederationMetaManager) ObjectFactory(com.sun.identity.wsfederation.jaxb.entityconfig.ObjectFactory) JAXBException(javax.xml.bind.JAXBException) FederationConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement) List(java.util.List) WSFederationMetaException(com.sun.identity.wsfederation.meta.WSFederationMetaException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) FederationElement(com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement)

Aggregations

FederationConfigElement (com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement)16 BaseConfigType (com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType)7 Iterator (java.util.Iterator)7 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)6 List (java.util.List)6 ConfigurationException (com.sun.identity.plugin.configuration.ConfigurationException)5 FederationElement (com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement)5 Set (java.util.Set)5 JAXBException (javax.xml.bind.JAXBException)5 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)4 WSFederationMetaException (com.sun.identity.wsfederation.meta.WSFederationMetaException)4 WSFederationMetaManager (com.sun.identity.wsfederation.meta.WSFederationMetaManager)4 IDPSSOConfigElement (com.sun.identity.wsfederation.jaxb.entityconfig.IDPSSOConfigElement)3 SPSSOConfigElement (com.sun.identity.wsfederation.jaxb.entityconfig.SPSSOConfigElement)3 AttributeType (com.sun.identity.wsfederation.jaxb.entityconfig.AttributeType)2 ObjectFactory (com.sun.identity.wsfederation.jaxb.entityconfig.ObjectFactory)2 TokenSigningKeyInfoElement (com.sun.identity.wsfederation.jaxb.wsfederation.TokenSigningKeyInfoElement)1 StringWriter (java.io.StringWriter)1 CertificateEncodingException (java.security.cert.CertificateEncodingException)1