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;
}
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;
}
Aggregations