Search in sources :

Example 6 with InvalidConfigurationException

use of org.gluu.util.exception.InvalidConfigurationException in project oxTrust by GluuFederation.

the class Shibboleth3ConfService method saveSpMetadataFile.

public String saveSpMetadataFile(String spMetaDataURL, String spMetadataFileName) {
    if (StringHelper.isEmpty(spMetaDataURL)) {
        return null;
    }
    if (appConfiguration.getShibboleth3IdpRootDir() == null) {
        throw new InvalidConfigurationException("Failed to save SP meta-data file due to undefined IDP root folder");
    }
    HTTPFileDownloader.setEasyhttps(new Protocol("https", new EasyCASSLProtocolSocketFactory(), 443));
    String spMetadataFileContent = HTTPFileDownloader.getResource(spMetaDataURL, "application/xml, text/xml", null, null);
    if (StringHelper.isEmpty(spMetadataFileContent)) {
        return null;
    }
    String idpMetadataTempFolder = getIdpMetadataTempDir();
    String tempFileName = getTempMetadataFilename(idpMetadataTempFolder, spMetadataFileName);
    String spMetadataFile = idpMetadataTempFolder + tempFileName;
    try {
        boolean result = documentStoreService.saveDocument(spMetadataFile, spMetadataFileContent, UTF_8);
        if (result) {
            return tempFileName;
        }
    } catch (Exception ex) {
        log.error("Failed to write SP meta-data file '{}'", spMetadataFile, ex);
    }
    return null;
}
Also used : EasyCASSLProtocolSocketFactory(org.gluu.oxtrust.util.EasyCASSLProtocolSocketFactory) Protocol(org.apache.commons.httpclient.protocol.Protocol) XPathExpressionException(javax.xml.xpath.XPathExpressionException) EncryptionException(org.gluu.util.security.StringEncrypter.EncryptionException) SAXException(org.xml.sax.SAXException) IOException(java.io.IOException) XMLParserException(org.opensaml.xml.parse.XMLParserException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) InvalidConfigurationException(org.gluu.util.exception.InvalidConfigurationException) InvalidConfigurationException(org.gluu.util.exception.InvalidConfigurationException)

Example 7 with InvalidConfigurationException

use of org.gluu.util.exception.InvalidConfigurationException in project oxTrust by GluuFederation.

the class Shibboleth3ConfService method generateConfigurationFiles.

/*
     * Generate relying-party.xml, attribute-filter.xml, attribute-resolver.xml
     */
public boolean generateConfigurationFiles(List<GluuSAMLTrustRelationship> trustRelationships) {
    log.info(">>>>>>>>>> IN Shibboleth3ConfService.generateConfigurationFiles()...");
    if (appConfiguration.getShibboleth3IdpRootDir() == null) {
        throw new InvalidConfigurationException("Failed to update configuration due to undefined IDP root folder");
    }
    String idpConfFolder = getIdpConfDir();
    String idpMetadataFolder = getIdpMetadataDir();
    // Prepare data for files
    initAttributes(trustRelationships);
    HashMap<String, Object> trustParams = initTrustParamMap(trustRelationships);
    HashMap<String, Object> attrParams = initAttributeParamMap(trustRelationships);
    HashMap<String, Object> casParams = initCASParamMap();
    HashMap<String, Object> attrResolverParams = initAttributeResolverParamMap();
    for (String key : attrParams.keySet()) attrResolverParams.remove(key);
    boolean result = (trustParams != null) && (attrParams != null) && (casParams != null) && (attrResolverParams != null);
    if (!result) {
        log.error(">>>>>>>>>> Shibboleth3ConfService.generateConfigurationFiles() - params preparation failed, break files generation");
        return result;
    }
    VelocityContext context = prepareVelocityContext(trustParams, attrParams, casParams, attrResolverParams, idpMetadataFolder);
    // Generate metadata-providers.xml
    String metadataProviders = generateConfFile(SHIB3_IDP_METADATA_PROVIDERS_FILE, context);
    // Generate attribute-resolver.xml
    String attributeResolver = generateConfFile(SHIB3_IDP_ATTRIBUTE_RESOLVER_FILE, context);
    // Generate attribute-filter.xml
    String attributeFilter = generateConfFile(SHIB3_IDP_ATTRIBUTE_FILTER_FILE, context);
    // Generate relying-party.xml
    String relyingParty = generateConfFile(SHIB3_IDP_RELYING_PARTY_FILE, context);
    // Generate cas-protocol.xml
    String casProtocol = generateConfFile(SHIB3_IDP_CAS_PROTOCOL_FILE, context);
    // Generate shibboleth2.xml
    String shibConfig = generateConfFile(SHIB3_SP_SHIBBOLETH2_FILE, context);
    // Generate saml-nameid.xml
    String samlnamedConfig = generateConfFile(SHIB3_SAML_NAMEID_FILE, context);
    // Generate saml-nameid.properties
    String samlnamedPropsConfig = generateConfFile(SHIB3_SAML_NAMEID_PROPS_FILE, context);
    // Generate handler.xml
    // String profileHandler =
    // generateConfFile(SHIB3_IDP_PROFILE_HADLER, context);
    // Generate attribute-map.xml
    // String attributeMap =
    // generateConfFile(SHIB2_SP_ATTRIBUTE_MAP, context);
    // result = (metadataProviders != null) && (attributeFilter != null) &&
    // (attributeResolver != null) && (relyingParty != null) && (shibConfig != null)
    // && (profileHandler != null);
    result = (metadataProviders != null) && (attributeFilter != null) && (attributeResolver != null) && (relyingParty != null) && (casProtocol != null) && (shibConfig != null);
    // Write metadata-providers.xml
    result &= writeConfFile(idpConfFolder + SHIB3_IDP_METADATA_PROVIDERS_FILE, metadataProviders);
    // Write attribute-resolver.xml
    result &= writeConfFile(idpConfFolder + SHIB3_IDP_ATTRIBUTE_RESOLVER_FILE, attributeResolver);
    // Write attribute-filter.xml
    result &= writeConfFile(idpConfFolder + SHIB3_IDP_ATTRIBUTE_FILTER_FILE, attributeFilter);
    // Write relying-party.xml
    result &= writeConfFile(idpConfFolder + SHIB3_IDP_RELYING_PARTY_FILE, relyingParty);
    // Write cas-protocol.xml
    result &= writeConfFile(idpConfFolder + SHIB3_IDP_CAS_PROTOCOL_FILE, casProtocol);
    // Write shibboleth2.xml
    result &= writeConfFile(getSpShibboleth3FilePath(), shibConfig);
    // Write saml-nameid.xml
    result &= writeConfFile(idpConfFolder + SHIB3_SAML_NAMEID_FILE, samlnamedConfig);
    // Write saml-nameid.properties
    result &= writeConfFile(idpConfFolder + SHIB3_SAML_NAMEID_PROPS_FILE, samlnamedPropsConfig);
    // Write handler.xml
    // result &= writeIdpConfFile(idpConfFolder +
    // SHIB3_IDP_PROFILE_HADLER, profileHandler);
    // Write attribute-map.xml
    // result &= writeIdpConfFile(spConfFolder +
    // SHIB2_SP_ATTRIBUTE_MAP, attributeMap);
    log.info(">>>>>>>>>> LEAVING Shibboleth3ConfService.generateConfigurationFiles()...");
    return result;
}
Also used : VelocityContext(org.apache.velocity.VelocityContext) InvalidConfigurationException(org.gluu.util.exception.InvalidConfigurationException)

Aggregations

InvalidConfigurationException (org.gluu.util.exception.InvalidConfigurationException)7 VelocityContext (org.apache.velocity.VelocityContext)5 EncryptionException (org.gluu.util.security.StringEncrypter.EncryptionException)4 IOException (java.io.IOException)3 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)3 XPathExpressionException (javax.xml.xpath.XPathExpressionException)3 XMLParserException (org.opensaml.xml.parse.XMLParserException)3 SAXException (org.xml.sax.SAXException)3 ArrayList (java.util.ArrayList)2 Protocol (org.apache.commons.httpclient.protocol.Protocol)2 EasyCASSLProtocolSocketFactory (org.gluu.oxtrust.util.EasyCASSLProtocolSocketFactory)2 AttributeTypeDefinition (com.unboundid.ldap.sdk.schema.AttributeTypeDefinition)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 HashMap (java.util.HashMap)1 GluuAttribute (org.gluu.model.GluuAttribute)1 SchemaEntry (org.gluu.model.SchemaEntry)1 SamlAcr (org.gluu.oxtrust.model.SamlAcr)1