Search in sources :

Example 86 with JAXBException

use of javax.xml.bind.JAXBException in project OpenAM by OpenRock.

the class SAMLv2ModelImpl method setIDPExtAttributeValues.

/**
     * Saves the extended attribute values for the Identiy Provider.
     *
     * @param realm to which the entity belongs.
     * @param entityName is the entity id.
     * @param idpExtValues Map which contains the standard attribute values.
     * @param location has the information whether remote or hosted.
     * @throws AMConsoleException if saving of attribute value fails.
     */
public void setIDPExtAttributeValues(String realm, String entityName, Map idpExtValues, String location) throws AMConsoleException {
    String[] params = { realm, entityName, "SAMLv2", "IDP-Extended" };
    logEvent("ATTEMPT_MODIFY_ENTITY_DESCRIPTOR", params);
    String role = EntityModel.IDENTITY_PROVIDER;
    try {
        SAML2MetaManager samlManager = getSAML2MetaManager();
        //entityConfig is the extended entity configuration object
        EntityConfigElement entityConfig = samlManager.getEntityConfig(realm, entityName);
        //for remote cases
        if (entityConfig == null) {
            createExtendedObject(realm, entityName, location, role);
            entityConfig = samlManager.getEntityConfig(realm, entityName);
        }
        IDPSSOConfigElement idpssoConfig = samlManager.getIDPSSOConfig(realm, entityName);
        if (idpssoConfig != null) {
            updateBaseConfig(idpssoConfig, idpExtValues, role);
        }
        //saves the attributes by passing the new entityConfig object
        samlManager.setEntityConfig(realm, entityConfig);
        logEvent("SUCCEED_MODIFY_ENTITY_DESCRIPTOR", params);
    } catch (SAML2MetaException e) {
        debug.error("SAMLv2ModelImpl.setIDPExtAttributeValues:", e);
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "IDP-Extended", strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_ENTITY_DESCRIPTOR", paramsEx);
    } catch (JAXBException e) {
        debug.error("SAMLv2ModelImpl.setIDPExtAttributeValues:", e);
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "IDP-Extended", strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_ENTITY_DESCRIPTOR", paramsEx);
    } catch (AMConsoleException e) {
        debug.error("SAMLv2ModelImpl.setIDPExtAttributeValues:", e);
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "IDP-Extended", strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_ENTITY_DESCRIPTOR", paramsEx);
    }
}
Also used : JAXBException(javax.xml.bind.JAXBException) IDPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Example 87 with JAXBException

use of javax.xml.bind.JAXBException in project OpenAM by OpenRock.

the class SAMLv2ModelImpl method getPDPConfig.

/**
     * Returns a Map of PDP Config data. (Extended Metadata)
     *
     * @param realm realm of Entity
     * @param entityName entity name of Entity Descriptor
     * @param location location of entity(hosted or remote)
     * @return key-value pair Map of PPP config data.
     * @throws AMConsoleException if unable to retrieve the PDP
     *         extended metadata attribute
     */
public Map getPDPConfig(String realm, String entityName, String location) throws AMConsoleException {
    String[] params = { realm, entityName, "SAMLv2", "XACML PDP" };
    logEvent("ATTEMPT_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", params);
    String role = EntityModel.POLICY_DECISION_POINT_DESCRIPTOR;
    Map data = null;
    List configList = null;
    String metaAlias = null;
    try {
        SAML2MetaManager saml2Manager = getSAML2MetaManager();
        XACMLPDPConfigElement xacmlPDPConfigElement = saml2Manager.getPolicyDecisionPointConfig(realm, entityName);
        if (xacmlPDPConfigElement != null) {
            data = new HashMap();
            configList = xacmlPDPConfigElement.getAttribute();
            metaAlias = xacmlPDPConfigElement.getMetaAlias();
            int size = configList.size();
            for (int i = 0; i < size; i++) {
                AttributeType atype = (AttributeType) configList.get(i);
                String name = atype.getName();
                java.util.List value = atype.getValue();
                data.put(atype.getName(), returnEmptySetIfValueIsNull(atype.getValue()));
            }
            data.put("metaAlias", metaAlias);
        } else {
            createExtendedObject(realm, entityName, location, role);
        }
        logEvent("SUCCEED_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", params);
    } catch (JAXBException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "XACML PDP", strError };
        logEvent("FEDERATION_EXCEPTION_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", paramsEx);
        throw new AMConsoleException(strError);
    } catch (SAML2MetaException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "XACML PDP", strError };
        logEvent("FEDERATION_EXCEPTION_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", paramsEx);
        throw new AMConsoleException(strError);
    }
    return (data != null) ? data : Collections.EMPTY_MAP;
}
Also used : HashMap(java.util.HashMap) JAXBException(javax.xml.bind.JAXBException) XACMLPDPConfigElement(com.sun.identity.saml2.jaxb.entityconfig.XACMLPDPConfigElement) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) List(java.util.List) AttributeType(com.sun.identity.saml2.jaxb.entityconfig.AttributeType) List(java.util.List) ArrayList(java.util.ArrayList) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map) HashMap(java.util.HashMap) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException)

Example 88 with JAXBException

use of javax.xml.bind.JAXBException 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 89 with JAXBException

use of javax.xml.bind.JAXBException in project OpenAM by OpenRock.

the class SAMLv2ModelImpl method setExtAttributeQueryValues.

/**
     * Saves the extended attribute values for Attribute Query.
     *
     * @param realm to which the entity belongs.
     * @param entityName is the entity id.
     * @param attrQueryExtValues 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 setExtAttributeQueryValues(String realm, String entityName, Map attrQueryExtValues, String location) throws AMConsoleException {
    String[] params = { realm, entityName, "SAMLv2", "AttribQuery-Ext" };
    logEvent("ATTEMPT_MODIFY_ATTR_QUERY_ATTR_VALUES", params);
    String role = EntityModel.SAML_ATTRQUERY;
    try {
        SAML2MetaManager samlManager = getSAML2MetaManager();
        //entityConfig is the extended entity configuration object
        EntityConfigElement entityConfig = samlManager.getEntityConfig(realm, entityName);
        //for remote cases
        if (entityConfig == null) {
            createExtendedObject(realm, entityName, location, role);
            entityConfig = samlManager.getEntityConfig(realm, entityName);
        }
        AttributeQueryConfigElement attrQueryConfig = samlManager.getAttributeQueryConfig(realm, entityName);
        if (attrQueryConfig != null) {
            updateBaseConfig(attrQueryConfig, attrQueryExtValues, role);
        }
        //saves the attributes by passing the new entityConfig object
        samlManager.setEntityConfig(realm, entityConfig);
        logEvent("SUCCEED_MODIFY_ATTR_QUERY_ATTR_VALUES", params);
    } catch (SAML2MetaException e) {
        debug.error("SAMLv2ModelImpl.setExtAttributeQueryValues:", e);
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "AttribQuery-Ext", strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_ATTR_QUERY_ATTR_VALUES", paramsEx);
    } catch (JAXBException e) {
        debug.error("SAMLv2ModelImpl.setExtAttributeQueryValues:", e);
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "AttribQuery-Extended", strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_ATTR_QUERY_ATTR_VALUES", paramsEx);
    } catch (AMConsoleException e) {
        debug.error("SAMLv2ModelImpl.setExtAttributeQueryValues:", e);
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "AttribQuery-Ext", strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_ATTR_QUERY_ATTR_VALUES", paramsEx);
    }
}
Also used : JAXBException(javax.xml.bind.JAXBException) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) AttributeQueryConfigElement(com.sun.identity.saml2.jaxb.entityconfig.AttributeQueryConfigElement) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Example 90 with JAXBException

use of javax.xml.bind.JAXBException in project OpenAM by OpenRock.

the class SAMLv2ModelImpl method setSPStdAttributeValues.

/**
     * Saves the standard attribute values for the Service Provider.
     *
     * @param realm to which the entity belongs.
     * @param entityName is the entity id.
     * @param spStdValues Map which contains the standard attribute values.
     * @param assertionConsumer List with assertion consumer service values.
     * @throws AMConsoleException if saving of attribute value fails.
     */
public void setSPStdAttributeValues(String realm, String entityName, Map spStdValues, List assertionConsumer) throws AMConsoleException {
    String[] params = { realm, entityName, "SAMLv2", "SP-Standard" };
    logEvent("ATTEMPT_MODIFY_ENTITY_DESCRIPTOR", params);
    SPSSODescriptorElement spssoDescriptor = null;
    com.sun.identity.saml2.jaxb.metadata.ObjectFactory objFact = new com.sun.identity.saml2.jaxb.metadata.ObjectFactory();
    try {
        SAML2MetaManager samlManager = getSAML2MetaManager();
        EntityDescriptorElement entityDescriptor = samlManager.getEntityDescriptor(realm, entityName);
        spssoDescriptor = samlManager.getSPSSODescriptor(realm, entityName);
        if (spssoDescriptor != null) {
            // save for Single Logout Service - Http-Redirect
            if (spStdValues.keySet().contains(SP_SINGLE_LOGOUT_HTTP_LOCATION)) {
                String lohttpLocation = getResult(spStdValues, SP_SINGLE_LOGOUT_HTTP_LOCATION);
                String lohttpRespLocation = getResult(spStdValues, SP_SINGLE_LOGOUT_HTTP_RESP_LOCATION);
                String lopostLocation = getResult(spStdValues, SP_SLO_POST_LOC);
                String lopostRespLocation = getResult(spStdValues, SP_SLO_POST_RESPLOC);
                String losoapLocation = getResult(spStdValues, SP_SINGLE_LOGOUT_SOAP_LOCATION);
                String priority = getResult(spStdValues, SP_LOGOUT_DEFAULT);
                if (priority.contains("none")) {
                    if (lohttpLocation != null) {
                        priority = httpRedirectBinding;
                    } else if (lopostLocation != null) {
                        priority = httpPostBinding;
                    } else if (losoapLocation != null) {
                        priority = soapBinding;
                    }
                }
                List logList = spssoDescriptor.getSingleLogoutService();
                if (!logList.isEmpty()) {
                    logList.clear();
                }
                if (priority != null && priority.contains("HTTP-Redirect")) {
                    savehttpRedLogout(lohttpLocation, lohttpRespLocation, logList, objFact);
                    savepostLogout(lopostLocation, lopostRespLocation, logList, objFact);
                    savesoapLogout(losoapLocation, logList, objFact);
                } else if (priority != null && priority.contains("HTTP-POST")) {
                    savepostLogout(lopostLocation, lopostRespLocation, logList, objFact);
                    savehttpRedLogout(lohttpLocation, lohttpRespLocation, logList, objFact);
                    savesoapLogout(losoapLocation, logList, objFact);
                } else if (priority != null && priority.contains("SOAP")) {
                    savesoapLogout(losoapLocation, logList, objFact);
                    savehttpRedLogout(lohttpLocation, lohttpRespLocation, logList, objFact);
                    savepostLogout(lopostLocation, lopostRespLocation, logList, objFact);
                }
            }
            // save for Manage Name ID Service
            if (spStdValues.keySet().contains(SP_MANAGE_NAMEID_HTTP_LOCATION)) {
                String mnihttpLocation = getResult(spStdValues, SP_MANAGE_NAMEID_HTTP_LOCATION);
                String mnihttpRespLocation = getResult(spStdValues, SP_MANAGE_NAMEID_HTTP_RESP_LOCATION);
                String mnipostLocation = getResult(spStdValues, SP_MNI_POST_LOC);
                String mnipostRespLocation = getResult(spStdValues, SP_MNI_POST_RESPLOC);
                String mnisoapLocation = getResult(spStdValues, SP_MANAGE_NAMEID_SOAP_LOCATION);
                String mnisoapResLocation = getResult(spStdValues, SP_MANAGE_NAMEID_SOAP_RESP_LOCATION);
                String priority = getResult(spStdValues, SP_MNI_DEFAULT);
                if (priority.contains("none")) {
                    if (mnihttpLocation != null) {
                        priority = httpRedirectBinding;
                    } else if (mnipostLocation != null) {
                        priority = httpPostBinding;
                    } else if (mnisoapLocation != null) {
                        priority = soapBinding;
                    }
                }
                List manageNameIdList = spssoDescriptor.getManageNameIDService();
                if (!manageNameIdList.isEmpty()) {
                    manageNameIdList.clear();
                }
                if (priority != null && priority.contains("HTTP-Redirect")) {
                    savehttpRedMni(mnihttpLocation, mnihttpRespLocation, manageNameIdList, objFact);
                    savepostMni(mnipostLocation, mnipostRespLocation, manageNameIdList, objFact);
                    saveSPsoapMni(mnisoapLocation, mnisoapResLocation, manageNameIdList, objFact);
                } else if (priority != null && priority.contains("HTTP-POST")) {
                    savepostMni(mnipostLocation, mnipostRespLocation, manageNameIdList, objFact);
                    savehttpRedMni(mnihttpLocation, mnihttpRespLocation, manageNameIdList, objFact);
                    saveSPsoapMni(mnisoapLocation, mnisoapResLocation, manageNameIdList, objFact);
                } else if (priority != null && priority.contains("SOAP")) {
                    saveSPsoapMni(mnisoapLocation, mnisoapResLocation, manageNameIdList, objFact);
                    savehttpRedMni(mnihttpLocation, mnihttpRespLocation, manageNameIdList, objFact);
                    savepostMni(mnipostLocation, mnipostRespLocation, manageNameIdList, objFact);
                }
            }
            //save for artifact, post and paos Assertion Consumer Service
            if (!assertionConsumer.isEmpty() && assertionConsumer.size() > 0) {
                List asconsServiceList = spssoDescriptor.getAssertionConsumerService();
                if (!asconsServiceList.isEmpty()) {
                    asconsServiceList.clear();
                }
                asconsServiceList.addAll(assertionConsumer);
            }
            //save nameid format
            if (spStdValues.keySet().contains(NAMEID_FORMAT)) {
                saveNameIdFormat(spssoDescriptor, spStdValues);
            }
            //save AuthnRequestsSigned
            if (spStdValues.keySet().contains(IS_AUTHN_REQ_SIGNED)) {
                boolean authnValue = setToBoolean(spStdValues, IS_AUTHN_REQ_SIGNED);
                spssoDescriptor.setAuthnRequestsSigned(authnValue);
            }
            //save WantAssertionsSigned
            if (spStdValues.keySet().contains(WANT_ASSERTIONS_SIGNED)) {
                boolean assertValue = setToBoolean(spStdValues, WANT_ASSERTIONS_SIGNED);
                spssoDescriptor.setWantAssertionsSigned(assertValue);
            }
            samlManager.setEntityDescriptor(realm, entityDescriptor);
        }
        logEvent("SUCCEED_MODIFY_ENTITY_DESCRIPTOR", params);
    } catch (SAML2MetaException e) {
        debug.warning("SAMLv2ModelImpl.setSPStdAttributeValues:", e);
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "SP-Standard", strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_ENTITY_DESCRIPTOR", paramsEx);
        throw new AMConsoleException(strError);
    } catch (JAXBException e) {
        debug.error("SAMLv2ModelImpl.setSPStdAttributeValues:", e);
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "SP-Standard", strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_ENTITY_DESCRIPTOR", paramsEx);
    }
}
Also used : SPSSODescriptorElement(com.sun.identity.saml2.jaxb.metadata.SPSSODescriptorElement) JAXBException(javax.xml.bind.JAXBException) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) EntityDescriptorElement(com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement) ObjectFactory(com.sun.identity.saml2.jaxb.entityconfig.ObjectFactory) List(java.util.List) ArrayList(java.util.ArrayList) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException)

Aggregations

JAXBException (javax.xml.bind.JAXBException)402 JAXBContext (javax.xml.bind.JAXBContext)126 IOException (java.io.IOException)93 Unmarshaller (javax.xml.bind.Unmarshaller)91 Marshaller (javax.xml.bind.Marshaller)69 ArrayList (java.util.ArrayList)38 StringWriter (java.io.StringWriter)35 List (java.util.List)35 Map (java.util.Map)33 SAXException (org.xml.sax.SAXException)32 File (java.io.File)29 InputStream (java.io.InputStream)29 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)28 HashSet (java.util.HashSet)28 JAXBElement (javax.xml.bind.JAXBElement)24 XMLStreamException (javax.xml.stream.XMLStreamException)23 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)22 StringReader (java.io.StringReader)21 HashMap (java.util.HashMap)21 SAML2MetaManager (com.sun.identity.saml2.meta.SAML2MetaManager)20