Search in sources :

Example 6 with EntityConfigElement

use of com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement in project OpenAM by OpenRock.

the class SAMLv2ModelImpl method setExtAttributeAuthorityValues.

/**
     * Saves the extended attribute values for Attribute Authority.
     *
     * @param realm to which the entity belongs.
     * @param entityName is the entity id.
     * @param attrAuthExtValues Map which contains the extended values.
     * @param location has the information whether remote or hosted.
     * @throws AMConsoleException if saving of attribute value fails.
     */
public void setExtAttributeAuthorityValues(String realm, String entityName, Map attrAuthExtValues, String location) throws AMConsoleException {
    String[] params = { realm, entityName, "SAMLv2", "AttribAuthority-Ext" };
    logEvent("ATTEMPT_MODIFY_ATTR_AUTH_ATTR_VALUES", params);
    String role = EntityModel.SAML_ATTRAUTHORITY;
    try {
        SAML2MetaManager samlManager = getSAML2MetaManager();
        EntityConfigElement entityConfig = samlManager.getEntityConfig(realm, entityName);
        //for remote cases
        if (entityConfig == null) {
            createExtendedObject(realm, entityName, location, role);
            entityConfig = samlManager.getEntityConfig(realm, entityName);
        }
        AttributeAuthorityConfigElement attributeAuthorityConfig = samlManager.getAttributeAuthorityConfig(realm, entityName);
        if (attributeAuthorityConfig != null) {
            updateBaseConfig(attributeAuthorityConfig, attrAuthExtValues, role);
        }
        //saves the attributes by passing the new entityConfig object
        samlManager.setEntityConfig(realm, entityConfig);
        logEvent("SUCCEED_MODIFY_ATTR_AUTH_ATTR_VALUES", params);
    } catch (SAML2MetaException e) {
        debug.error("SAMLv2ModelImpl.setExtAttributeAuthorityValues:", e);
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "AttribAuthority-Ext", strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_ATTR_AUTH_ATTR_VALUES", paramsEx);
    } catch (JAXBException e) {
        debug.error("SAMLv2ModelImpl.setExtAttributeAuthorityValues:", e);
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "AttribAuthority-Extended", strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_ATTR_AUTH_ATTR_VALUES", paramsEx);
    } catch (AMConsoleException e) {
        debug.error("SAMLv2ModelImpl.setExtAttributeAuthorityValues:", e);
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "AttribAuthority-Ext", strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_ATTR_AUTH_ATTR_VALUES", paramsEx);
    }
}
Also used : JAXBException(javax.xml.bind.JAXBException) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) AttributeAuthorityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.AttributeAuthorityConfigElement) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Example 7 with EntityConfigElement

use of com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement in project OpenAM by OpenRock.

the class ExportMetaData method runExportExtended.

private void runExportExtended() throws CLIException {
    OutputStream os = null;
    String out = (isWebBase) ? "web" : extendedData;
    Object[] objs = { out };
    Object[] objs2 = { entityID, realm };
    try {
        SAML2MetaManager metaManager = new SAML2MetaManager(ssoToken);
        EntityConfigElement config = metaManager.getEntityConfig(realm, entityID);
        if (config == null) {
            throw new CLIException(MessageFormat.format(getResourceString("export-entity-exception-entity-config-not-exist"), objs2), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
        }
        if (isWebBase) {
            os = new ByteArrayOutputStream();
        } else {
            os = new FileOutputStream(extendedData);
        }
        SAML2MetaUtils.convertJAXBToOutputStream(config, os);
        if (isWebBase) {
            getOutputWriter().printlnMessage(os.toString());
        }
        getOutputWriter().printlnMessage(MessageFormat.format(getResourceString("export-entity-export-config-succeeded"), objs));
    } catch (SAML2MetaException e) {
        debugError("ExportMetaData.runExportExtended", e);
        throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (FileNotFoundException e) {
        debugWarning("ExportMetaData.runExportExtended", e);
        throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (JAXBException e) {
        debugWarning("ExportMetaData.runExportExtended", e);
        throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (IllegalArgumentException e) {
        debugWarning("ExportMetaData.runExportExtended", e);
        throw new CLIException(MessageFormat.format(getResourceString("export-entity-exception-invalid-config"), objs2), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } finally {
        if (os != null) {
            try {
                os.close();
            } catch (IOException e) {
            // ignore
            }
        }
    }
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) JAXBException(javax.xml.bind.JAXBException) FileNotFoundException(java.io.FileNotFoundException) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) FileOutputStream(java.io.FileOutputStream) CLIException(com.sun.identity.cli.CLIException) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Example 8 with EntityConfigElement

use of com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement in project OpenAM by OpenRock.

the class TaskModelImpl method getEntities.

private Set getEntities(String realm, String cotName, boolean bIDP, boolean hosted) throws AMConsoleException {
    try {
        SAML2MetaManager mgr = new SAML2MetaManager();
        Set entities = getEntities(realm, cotName);
        Set results = new HashSet();
        for (Iterator i = entities.iterator(); i.hasNext(); ) {
            String entityId = (String) i.next();
            EntityConfigElement elm = mgr.getEntityConfig(realm, entityId);
            // elm could be null due to OPENAM-269
            if (elm != null && elm.isHosted() == hosted) {
                EntityDescriptorElement desc = mgr.getEntityDescriptor(realm, entityId);
                if (bIDP) {
                    if (SAML2MetaUtils.getIDPSSODescriptor(desc) != null) {
                        results.add(entityId);
                    }
                } else {
                    if (SAML2MetaUtils.getSPSSODescriptor(desc) != null) {
                        results.add(entityId);
                    }
                }
            }
        }
        return results;
    } catch (SAML2MetaException ex) {
        throw new AMConsoleException(ex.getMessage());
    }
}
Also used : TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) Iterator(java.util.Iterator) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) EntityDescriptorElement(com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) HashSet(java.util.HashSet) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Example 9 with EntityConfigElement

use of com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement in project OpenAM by OpenRock.

the class ExportSAML2MetaData method exportExtendedMeta.

public static String exportExtendedMeta(String realm, String entityID) throws WorkflowException {
    try {
        String result = null;
        SAML2MetaManager metaManager = new SAML2MetaManager();
        EntityConfigElement config = metaManager.getEntityConfig(realm, entityID);
        if (config != null) {
            OutputStream os = new ByteArrayOutputStream();
            SAML2MetaUtils.convertJAXBToOutputStream(config, os);
            result = os.toString();
        }
        return result;
    } catch (JAXBException e) {
        throw new WorkflowException(e.getMessage());
    } catch (SAML2MetaException e) {
        throw new WorkflowException(e.getMessage());
    }
}
Also used : OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) JAXBException(javax.xml.bind.JAXBException) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Example 10 with EntityConfigElement

use of com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement in project OpenAM by OpenRock.

the class GetCircleOfTrusts method getRealmFromExtData.

private String getRealmFromExtData(String xml) throws WorkflowException {
    String realm = null;
    try {
        Object obj = SAML2MetaUtils.convertStringToJAXB(xml);
        EntityConfigElement configElt = (obj instanceof EntityConfigElement) ? (EntityConfigElement) obj : null;
        if (configElt != null && configElt.isHosted()) {
            List config = configElt.getIDPSSOConfigOrSPSSOConfigOrAuthnAuthorityConfig();
            if (!config.isEmpty()) {
                BaseConfigType bConfig = (BaseConfigType) config.iterator().next();
                realm = SAML2MetaUtils.getRealmByMetaAlias(bConfig.getMetaAlias());
            }
        }
    } catch (JAXBException e) {
        throw new WorkflowException("invalid-extended-data-cot", null);
    }
    return realm;
}
Also used : BaseConfigType(com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType) JAXBException(javax.xml.bind.JAXBException) List(java.util.List) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Aggregations

EntityConfigElement (com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)44 List (java.util.List)26 SAML2MetaManager (com.sun.identity.saml2.meta.SAML2MetaManager)23 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)22 ArrayList (java.util.ArrayList)21 Iterator (java.util.Iterator)19 JAXBException (javax.xml.bind.JAXBException)18 BaseConfigType (com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType)12 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)11 EntityDescriptorElement (com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement)10 COTException (com.sun.identity.cot.COTException)8 ConfigurationException (com.sun.identity.plugin.configuration.ConfigurationException)8 Set (java.util.Set)8 Map (java.util.Map)7 SPSSOConfigElement (com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement)6 HashSet (java.util.HashSet)6 IDPSSOConfigElement (com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement)5 AttributeType (com.sun.identity.saml2.jaxb.entityconfig.AttributeType)4 ObjectFactory (com.sun.identity.saml2.jaxb.entityconfig.ObjectFactory)4 CLIException (com.sun.identity.cli.CLIException)3