Search in sources :

Example 41 with IDFFMetaException

use of com.sun.identity.federation.meta.IDFFMetaException in project OpenAM by OpenRock.

the class ImportMetaData method handleIDFFRequest.

private void handleIDFFRequest(RequestContext rc) throws CLIException {
    try {
        IDFFMetaManager metaManager = new IDFFMetaManager(ssoToken);
        String entityID = null;
        com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement configElt = null;
        if (extendedData != null) {
            configElt = getIDFFEntityConfigElement();
            /*
                 * see note at the end of this class for how we decide
                 * the realm value
                 */
            if ((configElt != null) && configElt.isHosted()) {
                IDPDescriptorConfigElement idpConfig = IDFFMetaUtils.getIDPDescriptorConfig(configElt);
                if (idpConfig != null) {
                    realm = SAML2MetaUtils.getRealmByMetaAlias(idpConfig.getMetaAlias());
                } else {
                    SPDescriptorConfigElement spConfig = IDFFMetaUtils.getSPDescriptorConfig(configElt);
                    if (spConfig != null) {
                        realm = SAML2MetaUtils.getRealmByMetaAlias(spConfig.getMetaAlias());
                    }
                }
            }
        }
        if (metadata != null) {
            entityID = importIDFFMetaData(realm, metaManager);
        }
        if (configElt != null) {
            String out = (webAccess) ? "web" : extendedData;
            Object[] objs = { out };
            metaManager.createEntityConfig(realm, configElt);
            getOutputWriter().printlnMessage(MessageFormat.format(getResourceString("import-entity-succeeded"), objs));
        }
        if ((cot != null) && (cot.length() > 0) && (entityID != null) && (entityID.length() > 0)) {
            CircleOfTrustManager cotManager = new CircleOfTrustManager(ssoToken);
            if (!cotManager.isInCircleOfTrust(realm, cot, spec, entityID)) {
                cotManager.addCircleOfTrustMember(realm, cot, spec, entityID);
            }
        }
    } catch (IDFFMetaException e) {
        throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (COTException e) {
        throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) SPDescriptorConfigElement(com.sun.identity.federation.jaxb.entityconfig.SPDescriptorConfigElement) COTException(com.sun.identity.cot.COTException) IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) CLIException(com.sun.identity.cli.CLIException) IDPDescriptorConfigElement(com.sun.identity.federation.jaxb.entityconfig.IDPDescriptorConfigElement)

Example 42 with IDFFMetaException

use of com.sun.identity.federation.meta.IDFFMetaException in project OpenAM by OpenRock.

the class IDFFModelImpl method getEntityIDPDescriptor.

/**
     * Returns a map of IDP key/value pairs.
     *
     * @param realm where the entity exists.
     * @param entityName of entity descriptor.
     * @return map of IDP key/value pairs
     */
public Map getEntityIDPDescriptor(String realm, String entityName) throws AMConsoleException {
    String[] params = { realm, entityName, "IDFF", "IDP-Standard Metadata" };
    logEvent("ATTEMPT_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", params);
    Map map = new HashMap();
    try {
        IDFFMetaManager manager = getIDFFMetaManager();
        IDPDescriptorType pDesc = manager.getIDPDescriptor(realm, entityName);
        // common attributes
        map.put(ATTR_PROTOCOL_SUPPORT_ENUMERATION, convertListToSet(pDesc.getProtocolSupportEnumeration()));
        //communication URLs
        map.put(ATTR_SOAP_END_POINT, returnEmptySetIfValueIsNull(pDesc.getSoapEndpoint()));
        map.put(ATTR_SINGLE_SIGN_ON_SERVICE_URL, returnEmptySetIfValueIsNull(pDesc.getSingleSignOnServiceURL()));
        map.put(ATTR_SINGLE_LOGOUT_SERVICE_URL, returnEmptySetIfValueIsNull(pDesc.getSingleLogoutServiceURL()));
        map.put(ATTR_SINGLE_LOGOUT_SERVICE_RETURN_URL, returnEmptySetIfValueIsNull(pDesc.getSingleLogoutServiceReturnURL()));
        map.put(ATTR_FEDERATION_TERMINATION_SERVICES_URL, returnEmptySetIfValueIsNull(pDesc.getFederationTerminationServiceURL()));
        map.put(ATTR_FEDERATION_TERMINATION_SERVICE_RETURN_URL, returnEmptySetIfValueIsNull(pDesc.getFederationTerminationServiceReturnURL()));
        map.put(ATTR_REGISTRATION_NAME_IDENTIFIER_SERVICE_URL, returnEmptySetIfValueIsNull(pDesc.getRegisterNameIdentifierServiceURL()));
        map.put(ATTR_REGISTRATION_NAME_IDENTIFIER_SERVICE_RETURN_URL, returnEmptySetIfValueIsNull(pDesc.getRegisterNameIdentifierServiceReturnURL()));
        // communication profiles
        map.put(ATTR_FEDERATION_TERMINATION_NOTIFICATION_PROTOCOL_PROFILE, returnEmptySetIfValueIsNull((String) pDesc.getFederationTerminationNotificationProtocolProfile().get(0)));
        map.put(ATTR_SINGLE_LOGOUT_PROTOCOL_PROFILE, returnEmptySetIfValueIsNull((String) pDesc.getSingleLogoutProtocolProfile().get(0)));
        map.put(ATTR_REGISTRATION_NAME_IDENTIFIER_PROFILE_PROFILE, returnEmptySetIfValueIsNull((String) pDesc.getRegisterNameIdentifierProtocolProfile().get(0)));
        map.put(ATTR_SINGLE_SIGN_ON_PROTOCOL_PROFILE, returnEmptySetIfValueIsNull((String) pDesc.getSingleSignOnProtocolProfile().get(0)));
        // get signing key size and algorithm               
        EncInfo encinfo = KeyUtil.getEncInfo((ProviderDescriptorType) pDesc, entityName, //isIDP
        true);
        if (encinfo == null) {
            map.put(ATTR_ENCRYPTION_KEY_SIZE, Collections.EMPTY_SET);
            map.put(ATTR_ENCRYPTION_ALGORITHM, Collections.EMPTY_SET);
        } else {
            int size = encinfo.getDataEncStrength();
            String alg = encinfo.getDataEncAlgorithm();
            map.put(ATTR_ENCRYPTION_KEY_SIZE, returnEmptySetIfValueIsNull(Integer.toString(size)));
            map.put(ATTR_ENCRYPTION_ALGORITHM, returnEmptySetIfValueIsNull(alg));
        }
        logEvent("SUCCEED_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", params);
    } catch (IDFFMetaException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "IDFF", "IDP-Standard Metadata", strError };
        logEvent("FEDERATION_EXCEPTION_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", paramsEx);
        throw new AMConsoleException(strError);
    }
    return map;
}
Also used : IDPDescriptorType(com.sun.identity.liberty.ws.meta.jaxb.IDPDescriptorType) EncInfo(com.sun.identity.federation.key.EncInfo) HashMap(java.util.HashMap) IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 43 with IDFFMetaException

use of com.sun.identity.federation.meta.IDFFMetaException in project OpenAM by OpenRock.

the class IDFFModelImpl method updateIDPEntityConfig.

/**
     * Modifies a identity provider's extended metadata.
     *
     * @param entityName name of Entity Descriptor.
     * @param realm where entity exists.
     * @param attrValues Map of attribute name to set of values.
     * @throws AMConsoleException if provider cannot be modified.
     * @throws JAXBException if provider cannot be retrieved.
     */
public void updateIDPEntityConfig(String realm, String entityName, Map attrValues) throws AMConsoleException {
    String[] params = { realm, entityName, "IDFF", "IDP-Extended Metadata" };
    logEvent("ATTEMPT_MODIFY_ENTITY_DESCRIPTOR", params);
    try {
        IDFFMetaManager idffMetaMgr = getIDFFMetaManager();
        EntityConfigElement entityConfig = idffMetaMgr.getEntityConfig(realm, entityName);
        if (entityConfig == null) {
            throw new AMConsoleException("invalid.entity.name");
        }
        IDPDescriptorConfigElement idpDecConfigElement = idffMetaMgr.getIDPDescriptorConfig(realm, entityName);
        if (idpDecConfigElement == null) {
            throw new AMConsoleException("invalid.config.element");
        } else {
            updateAttrInConfig(idpDecConfigElement, attrValues, EntityModel.IDENTITY_PROVIDER);
        }
        //saves the attributes by passing the new entityConfig object
        idffMetaMgr.setEntityConfig(realm, entityConfig);
        logEvent("SUCCEED_MODIFY_ENTITY_DESCRIPTOR", params);
    } catch (IDFFMetaException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "IDFF", "IDP-Extended Metadata", strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_ENTITY_DESCRIPTOR", paramsEx);
        throw new AMConsoleException(strError);
    } catch (JAXBException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "IDFF", "IDP-Extended Metadata", strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_ENTITY_DESCRIPTOR", paramsEx);
        throw new AMConsoleException(strError);
    }
}
Also used : IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) JAXBException(javax.xml.bind.JAXBException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) IDPDescriptorConfigElement(com.sun.identity.federation.jaxb.entityconfig.IDPDescriptorConfigElement) EntityConfigElement(com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement)

Example 44 with IDFFMetaException

use of com.sun.identity.federation.meta.IDFFMetaException in project OpenAM by OpenRock.

the class IDFFModelImpl method updateSPEntityConfig.

/**
     * Modifies a service provider's extended metadata.
     *
     * @param realm where entity exists.
     * @param entityName name of Entity Descriptor.
     * @param attrValues Map of attribute name to set of values.
     * @throws AMConsoleException if provider cannot be modified.
     * @throws JAXBException if provider cannot be retrieved.
     */
public void updateSPEntityConfig(String realm, String entityName, Map attrValues) throws AMConsoleException {
    String[] params = { realm, entityName, "IDFF", "SP-Extended Metadata" };
    logEvent("ATTEMPT_MODIFY_ENTITY_DESCRIPTOR", params);
    try {
        IDFFMetaManager idffMetaMgr = getIDFFMetaManager();
        EntityConfigElement entityConfig = idffMetaMgr.getEntityConfig(realm, entityName);
        if (entityConfig == null) {
            throw new AMConsoleException("invalid.entity.name");
        }
        SPDescriptorConfigElement spDecConfigElement = idffMetaMgr.getSPDescriptorConfig(realm, entityName);
        if (spDecConfigElement == null) {
            throw new AMConsoleException("invalid.config.element");
        } else {
            // update sp entity config
            updateAttrInConfig(spDecConfigElement, attrValues, EntityModel.SERVICE_PROVIDER);
            //handle supported sso profile
            List supportedSSOProfileList = new ArrayList();
            supportedSSOProfileList.add((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_SUPPORTED_SSO_PROFILE)));
            int size = supportedSSOProfileList.size();
            for (int i = 0; i < size; i++) {
                if (!supportedSSOProfileList.get(i).equals((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_SUPPORTED_SSO_PROFILE)))) {
                    supportedSSOProfileList.add(supportedSSOProfileList.get(i));
                }
            }
            updateAttrInConfig(spDecConfigElement, ATTR_SUPPORTED_SSO_PROFILE, supportedSSOProfileList);
        }
        //saves the attributes by passing the new entityConfig object
        idffMetaMgr.setEntityConfig(realm, entityConfig);
        logEvent("SUCCEED_MODIFY_ENTITY_DESCRIPTOR", params);
    } catch (IDFFMetaException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "IDFF", "SP-Extended Metadata", strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_ENTITY_DESCRIPTOR", paramsEx);
        throw new AMConsoleException(strError);
    } catch (JAXBException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "IDFF", "IDP-Extended Metadata", strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_ENTITY_DESCRIPTOR", paramsEx);
        throw new AMConsoleException(strError);
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) JAXBException(javax.xml.bind.JAXBException) SPDescriptorConfigElement(com.sun.identity.federation.jaxb.entityconfig.SPDescriptorConfigElement) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) EntityConfigElement(com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement)

Example 45 with IDFFMetaException

use of com.sun.identity.federation.meta.IDFFMetaException in project OpenAM by OpenRock.

the class IDFFModelImpl method isAffiliate.

/**
     * Returns true if entity descriptor is an affiliate.
     *
     * @param entityName of entity descriptor.
     * @return true if entity descriptor is an affiliate.
     * @throws AMConsoleException if entity cannot be retrieved.
     */
public boolean isAffiliate(String realm, String entityName) throws AMConsoleException {
    boolean isAffiliate = false;
    try {
        IDFFMetaManager idffManager = getIDFFMetaManager();
        AffiliationDescriptorType ad = (AffiliationDescriptorType) idffManager.getAffiliationDescriptor(realm, entityName);
        if (ad != null) {
            isAffiliate = true;
        }
    } catch (IDFFMetaException e) {
        debug.warning("IDFFModel.isAffiliate", e);
        throw new AMConsoleException(getErrorString(e));
    }
    return isAffiliate;
}
Also used : IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) AffiliationDescriptorType(com.sun.identity.liberty.ws.meta.jaxb.AffiliationDescriptorType) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Aggregations

IDFFMetaException (com.sun.identity.federation.meta.IDFFMetaException)89 IDFFMetaManager (com.sun.identity.federation.meta.IDFFMetaManager)55 BaseConfigType (com.sun.identity.federation.jaxb.entityconfig.BaseConfigType)30 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)27 Iterator (java.util.Iterator)25 Map (java.util.Map)25 HashMap (java.util.HashMap)24 List (java.util.List)24 ProviderDescriptorType (com.sun.identity.liberty.ws.meta.jaxb.ProviderDescriptorType)22 Set (java.util.Set)21 SAMLException (com.sun.identity.saml.common.SAMLException)17 HashSet (java.util.HashSet)17 ArrayList (java.util.ArrayList)14 FSException (com.sun.identity.federation.common.FSException)13 FSMsgException (com.sun.identity.federation.message.common.FSMsgException)12 CLIException (com.sun.identity.cli.CLIException)10 SessionException (com.sun.identity.plugin.session.SessionException)9 IOException (java.io.IOException)9 IDPDescriptorConfigElement (com.sun.identity.federation.jaxb.entityconfig.IDPDescriptorConfigElement)8 SPDescriptorConfigElement (com.sun.identity.federation.jaxb.entityconfig.SPDescriptorConfigElement)8