Search in sources :

Example 16 with WSFederationMetaException

use of com.sun.identity.wsfederation.meta.WSFederationMetaException in project OpenAM by OpenRock.

the class DefaultAttributeMapper method getConfigAttributeMap.

/**
     * Returns the attribute map by parsing the configured map in hosted
     * provider configuration
     * @param realm realm name.
     * @param hostEntityID <code>EntityID</code> of the hosted provider.
     * @return a map of local attributes configuration map.
     *        This map will have a key as the SAML attribute name and the value
     *        is the local attribute. 
     * @exception <code>WSFederationException</code> if any failured.
     */
public Map getConfigAttributeMap(String realm, String hostEntityID) throws WSFederationException {
    if (realm == null) {
        throw new WSFederationException(bundle.getString("nullRealm"));
    }
    if (hostEntityID == null) {
        throw new WSFederationException(bundle.getString("nullHostEntityID"));
    }
    try {
        BaseConfigType config = null;
        if (role.equals(SP)) {
            config = WSFederationUtils.getMetaManager().getSPSSOConfig(realm, hostEntityID);
        } else {
            config = WSFederationUtils.getMetaManager().getIDPSSOConfig(realm, hostEntityID);
        }
        if (config == null) {
            if (debug.warningEnabled()) {
                debug.warning("DefaultAttributeMapper.getConfigAttribute" + "Map: configuration is not defined.");
            }
            return Collections.EMPTY_MAP;
        }
        Map attribConfig = WSFederationMetaUtils.getAttributes(config);
        List mappedAttributes = (List) attribConfig.get(SAML2Constants.ATTRIBUTE_MAP);
        if (mappedAttributes == null || mappedAttributes.size() == 0) {
            if (debug.messageEnabled()) {
                debug.message("DefaultAttributeMapper.getConfigAttributeMap:" + "Attribute map is not defined for entity: " + hostEntityID);
            }
            return Collections.EMPTY_MAP;
        }
        Map map = new HashMap();
        for (Iterator iter = mappedAttributes.iterator(); iter.hasNext(); ) {
            String entry = (String) iter.next();
            if (entry.indexOf("=") == -1) {
                if (debug.messageEnabled()) {
                    debug.message("DefaultAttributeMapper.getConfig" + "AttributeMap: Invalid entry." + entry);
                }
                continue;
            }
            StringTokenizer st = new StringTokenizer(entry, "=");
            map.put(st.nextToken(), st.nextToken());
        }
        return map;
    } catch (WSFederationMetaException sme) {
        debug.error("DefaultAttributeMapper.getConfigAttributeMap: " + "Meta Exception", sme);
        throw new WSFederationException(sme);
    }
}
Also used : BaseConfigType(com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType) StringTokenizer(java.util.StringTokenizer) WSFederationException(com.sun.identity.wsfederation.common.WSFederationException) HashMap(java.util.HashMap) Iterator(java.util.Iterator) List(java.util.List) WSFederationMetaException(com.sun.identity.wsfederation.meta.WSFederationMetaException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 17 with WSFederationMetaException

use of com.sun.identity.wsfederation.meta.WSFederationMetaException in project OpenAM by OpenRock.

the class WSFedPropertiesModelImpl method setGenAttributeValues.

/**
     * Saves the attribute values from the General page.
     *
     * @param realm to which the entity belongs.
     * @param fedId is the entity id.
     * @param idpStdValues has the General standard attribute value pairs.
     * @param role of the entity ID.
     * @param location specifies if the entity is remote or local.
     * @throws AMConsoleException if saving of attribute value fails.
     */
public void setGenAttributeValues(String realm, String fedId, Map idpStdValues, String role, String location) throws AMConsoleException {
    String tknissEndPt = null;
    String tknissName = null;
    Iterator it = idpStdValues.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry entry = (Map.Entry) it.next();
        Object key = entry.getKey();
        Object value = entry.getValue();
        if (key.equals(TFTOKENISSUER_ENDPT)) {
            HashSet set = (HashSet) idpStdValues.get(key);
            Iterator i = set.iterator();
            while ((i != null) && (i.hasNext())) {
                tknissEndPt = (String) i.next();
            }
        } else if (key.equals(TFTOKENISSUER_NAME)) {
            HashSet set = (HashSet) idpStdValues.get(key);
            Iterator i = set.iterator();
            while ((i != null) && (i.hasNext())) {
                tknissName = (String) i.next();
            }
        } else if (key.equals(TF_DISPNAME)) {
            if (role.equals(EntityModel.SERVICE_PROVIDER)) {
                HashSet set = (HashSet) idpStdValues.get(key);
                // Get the current map of extended SP values
                Map tmpMap = getExtendedValues(role, realm, fedId);
                // Replace existing value
                tmpMap.put(TF_DISPNAME, set);
                setSPExtAttributeValues(realm, fedId, tmpMap, location);
            } else if (role.equals(EntityModel.IDENTITY_PROVIDER)) {
                HashSet set = (HashSet) idpStdValues.get(key);
                // Get the current map of extended IDP values
                Map tmpMap = getExtendedValues(role, realm, fedId);
                // Replace existing value
                tmpMap.put(TF_DISPNAME, set);
                setIDPExtAttributeValues(realm, fedId, tmpMap, location);
            } else if (role.equals(DUAL)) {
                HashSet set = (HashSet) idpStdValues.get(key);
                // Get the current map of extended SP values
                Map tmpMap = getExtendedValues(EntityModel.SERVICE_PROVIDER, realm, fedId);
                // Replace existing value
                tmpMap.put(TF_DISPNAME, set);
                setSPExtAttributeValues(realm, fedId, tmpMap, location);
                // Get the current map of extended IDP values
                tmpMap = getExtendedValues(EntityModel.IDENTITY_PROVIDER, realm, fedId);
                set = (HashSet) idpStdValues.get(TFIDPDISP_NAME);
                // Replace existing value
                tmpMap.put(TF_DISPNAME, set);
                setIDPExtAttributeValues(realm, fedId, tmpMap, location);
            }
        }
    }
    try {
        //fedElem is standard metadata federation element under the realm.
        WSFederationMetaManager metaManager = getWSFederationMetaManager();
        FederationElement fedElem = metaManager.getEntityDescriptor(realm, fedId);
        if (fedElem == null) {
            if (debug.warningEnabled()) {
                debug.warning("WSFedPropertiesModelImpl.setGenAttributeValues:" + " found invalid  federation element " + fedId);
            }
            throw new AMConsoleException("invalid.federation.element");
        } else {
            for (Iterator iter = fedElem.getAny().iterator(); iter.hasNext(); ) {
                Object o = iter.next();
                if (o instanceof TokenIssuerEndpointElement) {
                    ((TokenIssuerEndpointElement) o).getAddress().setValue(tknissEndPt);
                } else if (o instanceof TokenIssuerNameElement) {
                    ((TokenIssuerNameElement) o).setValue(tknissName);
                }
            }
            metaManager.setFederation(realm, fedElem);
        }
    } catch (WSFederationMetaException e) {
        debug.warning("WSFedPropertiesModelImpl.setGenAttributeValues", e);
        throw new AMConsoleException(e.getMessage());
    }
}
Also used : WSFederationMetaManager(com.sun.identity.wsfederation.meta.WSFederationMetaManager) TokenIssuerEndpointElement(com.sun.identity.wsfederation.jaxb.wsfederation.TokenIssuerEndpointElement) TokenIssuerNameElement(com.sun.identity.wsfederation.jaxb.wsfederation.TokenIssuerNameElement) Iterator(java.util.Iterator) WSFederationMetaException(com.sun.identity.wsfederation.meta.WSFederationMetaException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map) FederationElement(com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement) HashSet(java.util.HashSet)

Example 18 with WSFederationMetaException

use of com.sun.identity.wsfederation.meta.WSFederationMetaException in project OpenAM by OpenRock.

the class WSFedPropertiesModelImpl method setIDPExtAttributeValues.

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

Example 19 with WSFederationMetaException

use of com.sun.identity.wsfederation.meta.WSFederationMetaException in project OpenAM by OpenRock.

the class ImportEntityModelImpl method createWSFedEntity.

private void createWSFedEntity() throws AMConsoleException {
    try {
        com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement configElt = null;
        if (extendedMetaData != null) {
            configElt = getWSFedEntityConfigElement();
            /*
                 * see note at the end of this class for how we decide
                 * the realm value
                 */
            if (configElt != null && configElt.isHosted()) {
                List config = configElt.getIDPSSOConfigOrSPSSOConfig();
                if (!config.isEmpty()) {
                    com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType bConfig = (com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType) config.iterator().next();
                    realm = WSFederationMetaUtils.getRealmByMetaAlias(bConfig.getMetaAlias());
                }
            }
        }
        if (standardMetaData != null) {
            importWSFedMetaData();
        }
        if (configElt != null) {
            (new WSFederationMetaManager()).createEntityConfig(realm, configElt);
        }
    } catch (WSFederationMetaException e) {
        debug.error("ImportEntityModel.createWSFedEntity", e);
        throw new AMConsoleException(e);
    }
}
Also used : WSFederationMetaManager(com.sun.identity.wsfederation.meta.WSFederationMetaManager) BaseConfigType(com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType) List(java.util.List) WSFederationMetaException(com.sun.identity.wsfederation.meta.WSFederationMetaException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 20 with WSFederationMetaException

use of com.sun.identity.wsfederation.meta.WSFederationMetaException in project OpenAM by OpenRock.

the class CircleOfTrustManager method updateWSFedEntityConfig.

/**
     * Updates the WSFederation Entity Configuration.
     *
     * @param realm the realm name.
     * @param cotName the circle of trust name.
     * @param trustedProviders set of trusted provider names.
     * @throws COTException if there is an error updating the configuration.
     */
void updateWSFedEntityConfig(String realm, String cotName, Set trustedProviders) throws COTException {
    String classMethod = "COTManager:updateWSFedEntityConfig";
    String entityId = null;
    WSFederationCOTUtils wsfedCotUtils = new WSFederationCOTUtils(callerSession);
    if (trustedProviders != null && !trustedProviders.isEmpty()) {
        for (Iterator iter = trustedProviders.iterator(); iter.hasNext(); ) {
            entityId = (String) iter.next();
            try {
                wsfedCotUtils.updateEntityConfig(realm, cotName, entityId);
            } catch (WSFederationMetaException sme) {
                throw new COTException(sme);
            } catch (JAXBException e) {
                debug.error(classMethod, e);
                String[] data = { e.getMessage(), cotName, entityId, realm };
                LogUtil.error(Level.INFO, LogUtil.CONFIG_ERROR_CREATE_COT_DESCRIPTOR, data);
                throw new COTException(e);
            }
        }
    }
}
Also used : WSFederationCOTUtils(com.sun.identity.wsfederation.meta.WSFederationCOTUtils) JAXBException(javax.xml.bind.JAXBException) Iterator(java.util.Iterator) WSFederationMetaException(com.sun.identity.wsfederation.meta.WSFederationMetaException)

Aggregations

WSFederationMetaException (com.sun.identity.wsfederation.meta.WSFederationMetaException)30 WSFederationMetaManager (com.sun.identity.wsfederation.meta.WSFederationMetaManager)20 List (java.util.List)13 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)11 FederationElement (com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement)10 Iterator (java.util.Iterator)10 Map (java.util.Map)9 HashMap (java.util.HashMap)8 JAXBException (javax.xml.bind.JAXBException)8 CLIException (com.sun.identity.cli.CLIException)7 HashSet (java.util.HashSet)7 BaseConfigType (com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType)6 IDPSSOConfigElement (com.sun.identity.wsfederation.jaxb.entityconfig.IDPSSOConfigElement)5 ArrayList (java.util.ArrayList)5 Set (java.util.Set)5 FederationConfigElement (com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement)4 UriNamedClaimTypesOfferedElement (com.sun.identity.wsfederation.jaxb.wsfederation.UriNamedClaimTypesOfferedElement)4 WSFederationException (com.sun.identity.wsfederation.common.WSFederationException)3 TokenIssuerEndpointElement (com.sun.identity.wsfederation.jaxb.wsfederation.TokenIssuerEndpointElement)3 IOException (java.io.IOException)3