Search in sources :

Example 6 with FederationConfigElement

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

the class WSFederationMetaManager method getSPSSOConfig.

/**
     * Returns first service provider's SSO configuration in an entity under
     * the realm.
     * 
     * @param realm The realm under which the entity resides.
     * @param federationId ID of the entity to be retrieved.
     * @return <code>SPSSOConfigElement</code> for the entity or null if not
     *         found.
     * @throws WSFederationMetaException if unable to retrieve the first service
     *                            provider's SSO configuration.
     */
public SPSSOConfigElement getSPSSOConfig(String realm, String federationId) throws WSFederationMetaException {
    FederationConfigElement eConfig = getEntityConfig(realm, federationId);
    if (eConfig == null) {
        return null;
    }
    List list = eConfig.getIDPSSOConfigOrSPSSOConfig();
    for (Iterator iter = list.iterator(); iter.hasNext(); ) {
        Object obj = iter.next();
        if (obj instanceof SPSSOConfigElement) {
            return (SPSSOConfigElement) obj;
        }
    }
    return null;
}
Also used : Iterator(java.util.Iterator) SPSSOConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.SPSSOConfigElement) FederationConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement) ArrayList(java.util.ArrayList) List(java.util.List)

Example 7 with FederationConfigElement

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

the class WSFederationMetaManager method getIDPSSOConfig.

/**
     * Returns first identity provider's SSO configuration in an entity under
     * the realm.
     * 
     * @param realm The realm under which the entity resides.
     * @param federationId ID of the entity to be retrieved.
     * @return <code>IDPSSOConfigElement</code> for the entity or null if not
     *         found.
     * @throws WSFederationMetaException if unable to retrieve the first 
     * identity provider's SSO configuration.
     */
public IDPSSOConfigElement getIDPSSOConfig(String realm, String federationId) throws WSFederationMetaException {
    FederationConfigElement eConfig = getEntityConfig(realm, federationId);
    if (eConfig == null) {
        return null;
    }
    List list = eConfig.getIDPSSOConfigOrSPSSOConfig();
    for (Iterator iter = list.iterator(); iter.hasNext(); ) {
        Object obj = iter.next();
        if (obj instanceof IDPSSOConfigElement) {
            return (IDPSSOConfigElement) obj;
        }
    }
    return null;
}
Also used : Iterator(java.util.Iterator) FederationConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement) ArrayList(java.util.ArrayList) List(java.util.List) IDPSSOConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.IDPSSOConfigElement)

Example 8 with FederationConfigElement

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

the class CreateMetaDataModelImpl method createWSFedProvider.

/**
     * Creates a WS Federation provider.
     *
     * @param realm Realm Name.
     * @param entityId Entity Id.
     * @param values   Map of property name to values.
     * 
     * @throws AMConsoleException if duplicate metaAliases provided or unable to create or import metadata.
     * */
public void createWSFedProvider(String realm, String entityId, Map values) throws AMConsoleException {
    try {
        List<String> metaAliases = getFederationAlias(values, MetaTemplateParameters.P_WS_FED_ALIASES);
        Set<String> duplicateCheck = new HashSet<String>(metaAliases);
        if (duplicateCheck.size() < metaAliases.size()) {
            throw new AMConsoleException(getLocalizedString("federation.create.provider.duplicate.metaAlias"));
        }
        WSFederationMetaManager metaManager = new WSFederationMetaManager();
        metaManager.validateMetaAliasForNewEntity(realm, metaAliases);
        String metadata = CreateWSFedMetaDataTemplate.createStandardMetaTemplate(entityId, values, requestURL);
        String extendedData = CreateWSFedMetaDataTemplate.createExtendedMetaTemplate(entityId, values);
        FederationElement elt = (FederationElement) WSFederationMetaUtils.convertStringToJAXB(metadata);
        String federationID = elt.getFederationID();
        if (federationID == null) {
            federationID = WSFederationConstants.DEFAULT_FEDERATION_ID;
        }
        metaManager.createFederation(realm, elt);
        FederationConfigElement cfg = (FederationConfigElement) WSFederationMetaUtils.convertStringToJAXB(extendedData);
        metaManager.createEntityConfig(realm, cfg);
    } catch (WSFederationMetaException ex) {
        throw new AMConsoleException(ex.getMessage());
    } catch (JAXBException ex) {
        throw new AMConsoleException(ex.getMessage());
    } catch (CertificateEncodingException ex) {
        throw new AMConsoleException(ex.getMessage());
    }
}
Also used : WSFederationMetaManager(com.sun.identity.wsfederation.meta.WSFederationMetaManager) JAXBException(javax.xml.bind.JAXBException) FederationConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement) CertificateEncodingException(java.security.cert.CertificateEncodingException) WSFederationMetaException(com.sun.identity.wsfederation.meta.WSFederationMetaException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) FederationElement(com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement) HashSet(java.util.HashSet)

Example 9 with FederationConfigElement

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

the class WSFedPropertiesModelImpl method setSPExtAttributeValues.

/**
     * Saves the extended metadata attribute values for the SP.
     *
     * @param realm to which the entity belongs.
     * @param fedId is the entity id.
     * @param spExtvalues has the extended attribute value pairs of SP.
     * @param location has the information whether remote or hosted.
     * @throws AMConsoleException if saving of attribute value fails.
     */
public void setSPExtAttributeValues(String realm, String fedId, Map spExtvalues, String location) throws AMConsoleException {
    try {
        String role = EntityModel.SERVICE_PROVIDER;
        //fed is the extended entity configuration object under the realm
        WSFederationMetaManager metaManager = getWSFederationMetaManager();
        FederationConfigElement fed = metaManager.getEntityConfig(realm, fedId);
        if (fed == null) {
            SPEX_DATA_MAP.put(TF_DISPNAME, Collections.EMPTY_SET);
            createExtendedObject(realm, fedId, location, SERVICE_PROVIDER, SPEX_DATA_MAP);
            fed = metaManager.getEntityConfig(realm, fedId);
        }
        SPSSOConfigElement spsso = getspsso(fed);
        if (spsso != null) {
            BaseConfigType baseConfig = (BaseConfigType) spsso;
            updateBaseConfig(baseConfig, spExtvalues, role);
        }
        //saves the attributes by passing the new fed object
        metaManager.setEntityConfig(realm, fed);
    } catch (JAXBException e) {
        debug.warning("WSFedPropertiesModelImpl.setSPExtAttributeValues", e);
        throw new AMConsoleException(e.getMessage());
    } catch (WSFederationMetaException e) {
        debug.warning("WSFedPropertiesModelImpl.setSPExtAttributeValues", e);
        throw new AMConsoleException(e.getMessage());
    }
}
Also used : BaseConfigType(com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType) WSFederationMetaManager(com.sun.identity.wsfederation.meta.WSFederationMetaManager) JAXBException(javax.xml.bind.JAXBException) SPSSOConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.SPSSOConfigElement) FederationConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement) WSFederationMetaException(com.sun.identity.wsfederation.meta.WSFederationMetaException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 10 with FederationConfigElement

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

the class WSFederationCOTUtils method updateEntityConfig.

/**
     * Updates the entity config to add the circle of trust name to the
     * <code>cotlist</code> attribute. The Service Provider and Identity
     * Provider Configuration are updated.
     *
     * @param realm the realm name where the entity configuration is.
     * @param name the circle of trust name.
     * @param entityId the name of the Entity identifier.
     * @throws WSFederationMetaException if there is a configuration error when
     *         updating the configuration.
     * @throws JAXBException is there is an error updating the entity
     *          configuration.
     */
public void updateEntityConfig(String realm, String name, String entityId) throws WSFederationMetaException, JAXBException {
    String classMethod = "WSFederationCOTUtils.updateEntityConfig: ";
    WSFederationMetaManager metaManager = null;
    if (callerSession != null) {
        metaManager = new WSFederationMetaManager(callerSession);
    } else {
        metaManager = new WSFederationMetaManager();
    }
    ObjectFactory objFactory = new ObjectFactory();
    // Check whether the entity id existed in the DS
    FederationElement edes = metaManager.getEntityDescriptor(realm, entityId);
    if (edes == null) {
        debug.error(classMethod + "No such entity: " + entityId);
        String[] data = { realm, entityId };
        throw new WSFederationMetaException("entityid_invalid", data);
    }
    FederationConfigElement eConfig = metaManager.getEntityConfig(realm, entityId);
    if (eConfig == null) {
        BaseConfigType bctype = null;
        AttributeType atype = objFactory.createAttributeType();
        atype.setName(SAML2Constants.COT_LIST);
        atype.getValue().add(name);
        // add to eConfig
        FederationConfigElement ele = objFactory.createFederationConfigElement();
        ele.setFederationID(entityId);
        ele.setHosted(false);
        List ll = ele.getIDPSSOConfigOrSPSSOConfig();
        // IdP will have UriNamedClaimTypesOffered
        if (metaManager.getUriNamedClaimTypesOffered(edes) != null) {
            bctype = objFactory.createIDPSSOConfigElement();
            bctype.getAttribute().add(atype);
            ll.add(bctype);
        } else {
            bctype = objFactory.createSPSSOConfigElement();
            bctype.getAttribute().add(atype);
            ll.add(bctype);
        }
        metaManager.setEntityConfig(realm, ele);
    } else {
        List elist = eConfig.getIDPSSOConfigOrSPSSOConfig();
        for (Iterator iter = elist.iterator(); iter.hasNext(); ) {
            BaseConfigType bConfig = (BaseConfigType) iter.next();
            List list = bConfig.getAttribute();
            boolean foundCOT = false;
            for (Iterator iter2 = list.iterator(); iter2.hasNext(); ) {
                AttributeType avp = (AttributeType) iter2.next();
                if (avp.getName().trim().equalsIgnoreCase(SAML2Constants.COT_LIST)) {
                    foundCOT = true;
                    List avpl = avp.getValue();
                    if (avpl.isEmpty() || !containsValue(avpl, name)) {
                        avpl.add(name);
                        metaManager.setEntityConfig(realm, eConfig);
                        break;
                    }
                }
            }
            // no cot_list in the original entity config
            if (!foundCOT) {
                AttributeType atype = objFactory.createAttributeType();
                atype.setName(SAML2Constants.COT_LIST);
                atype.getValue().add(name);
                list.add(atype);
                metaManager.setEntityConfig(realm, eConfig);
            }
        }
    }
}
Also used : BaseConfigType(com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType) ObjectFactory(com.sun.identity.wsfederation.jaxb.entityconfig.ObjectFactory) AttributeType(com.sun.identity.wsfederation.jaxb.entityconfig.AttributeType) Iterator(java.util.Iterator) FederationConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement) List(java.util.List) 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