Search in sources :

Example 91 with JAXBException

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

the class SAMLv2ModelImpl method setExtauthnAuthValues.

/**
     * Saves the extended attribute values for Authn Authority.
     *
     * @param realm to which the entity belongs.
     * @param entityName is the entity id.
     * @param authnAuthExtValues 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 setExtauthnAuthValues(String realm, String entityName, Map authnAuthExtValues, String location) throws AMConsoleException {
    String[] params = { realm, entityName, "SAMLv2", "AuthnAuthority-Ext" };
    logEvent("ATTEMPT_MODIFY_AUTHN_AUTH_ATTR_VALUES", params);
    String role = EntityModel.SAML_AUTHNAUTHORITY;
    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);
        }
        AuthnAuthorityConfigElement authnAuthorityConfig = samlManager.getAuthnAuthorityConfig(realm, entityName);
        if (authnAuthorityConfig != null) {
            updateBaseConfig(authnAuthorityConfig, authnAuthExtValues, role);
        }
        //saves the attributes by passing the new entityConfig object
        samlManager.setEntityConfig(realm, entityConfig);
        logEvent("SUCCEED_MODIFY_AUTHN_AUTH_ATTR_VALUES", params);
    } catch (SAML2MetaException e) {
        debug.error("SAMLv2ModelImpl.setExtauthnAuthValues:", e);
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "AuthnAuthority-Ext", strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_AUTHN_AUTH_ATTR_VALUES", paramsEx);
    } catch (JAXBException e) {
        debug.error("SAMLv2ModelImpl.setExtauthnAuthValues:", e);
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "AuthnAuthority-Extended", strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_AUTHN_AUTH_ATTR_VALUES", paramsEx);
    } catch (AMConsoleException e) {
        debug.error("SAMLv2ModelImpl.setExtauthnAuthValues:", e);
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "AuthnAuthority-Ext", strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_AUTHN_AUTH_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) AuthnAuthorityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.AuthnAuthorityConfigElement) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Example 92 with JAXBException

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

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

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

the class WSFedPropertiesModelImpl method createAttributeElement.

/**
     * Returns BaseConfig object after updating with Attribute Elements.
     * @param values contain the keys for extended metadata attributes.
     * @param bconfig is the BaseConfigType object passed.
     *
     * @return BaseConfig object after updating with Attribute Elements.
     */
private BaseConfigType createAttributeElement(Map values, BaseConfigType bconfig) throws AMConsoleException {
    try {
        ObjectFactory objFactory = new ObjectFactory();
        for (Iterator iter = values.keySet().iterator(); iter.hasNext(); ) {
            AttributeElement avp = objFactory.createAttributeElement();
            String key = (String) iter.next();
            avp.setName(key);
            bconfig.getAttribute().add(avp);
        }
    } catch (JAXBException e) {
        debug.warning("WSFedPropertiesModelImpl.createAttributeElement", e);
        throw new AMConsoleException(e.getMessage());
    }
    return bconfig;
}
Also used : ObjectFactory(com.sun.identity.wsfederation.jaxb.entityconfig.ObjectFactory) JAXBException(javax.xml.bind.JAXBException) Iterator(java.util.Iterator) AttributeElement(com.sun.identity.wsfederation.jaxb.entityconfig.AttributeElement) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 95 with JAXBException

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

the class CreateMetaDataTemplate method buildWSFedDescriptorTemplate.

private void buildWSFedDescriptorTemplate() throws CLIException {
    Writer pw = null;
    try {
        boolean writeToFile = !isWebBased && (metadata != null) && (metadata.length() > 0);
        if (writeToFile) {
            pw = new PrintWriter(new FileWriter(metadata));
        } else {
            pw = new StringWriter();
        }
        String xml = CreateWSFedMetaDataTemplate.createStandardMetaTemplate(entityID, getWorkflowParamMap(), protocol + "://" + host + ":" + port + deploymentURI);
        pw.write(xml);
        if (writeToFile) {
            Object[] objs = { metadata };
            getOutputWriter().printlnMessage(MessageFormat.format(getResourceString("create-meta-template-created-descriptor-template"), objs));
        }
    } catch (IOException e) {
        Object[] objs = { metadata };
        throw new CLIException(MessageFormat.format(getResourceString("cannot-write-to-file"), objs), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (JAXBException e) {
        throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (CertificateEncodingException e) {
        throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } finally {
        if ((pw != null) && (pw instanceof PrintWriter)) {
            ((PrintWriter) pw).close();
        } else {
            this.getOutputWriter().printlnMessage(((StringWriter) pw).toString());
        }
    }
}
Also used : StringWriter(java.io.StringWriter) FileWriter(java.io.FileWriter) JAXBException(javax.xml.bind.JAXBException) CLIException(com.sun.identity.cli.CLIException) CertificateEncodingException(java.security.cert.CertificateEncodingException) IOException(java.io.IOException) LogWriter(com.sun.identity.cli.LogWriter) PrintWriter(java.io.PrintWriter) StringWriter(java.io.StringWriter) FileWriter(java.io.FileWriter) Writer(java.io.Writer) PrintWriter(java.io.PrintWriter)

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