use of org.xdi.util.exception.InvalidConfigurationException in project oxTrust by GluuFederation.
the class Shibboleth3ConfService method generateIdpConfigurationFiles.
public boolean generateIdpConfigurationFiles() {
if (appConfiguration.getShibboleth3IdpRootDir() == null) {
throw new InvalidConfigurationException("Failed to update configuration due to undefined IDP root folder");
}
String idpConfFolder = getIdpConfDir();
// Prepare data for files
VelocityContext context = new VelocityContext();
// white spaces or comma
String regx = "\\s*(=>|,|\\s)\\s*";
String[] ldapUrls = appConfiguration.getIdpLdapServer().split(regx);
String ldapUrl = "";
if (ldapUrls != null) {
for (String ldapServer : ldapUrls) {
if (ldapUrl.length() > 1) {
ldapUrl = ldapUrl + " ";
}
ldapUrl = ldapUrl + appConfiguration.getIdpLdapProtocol() + "://" + ldapServer;
}
} else {
ldapUrl = appConfiguration.getIdpLdapProtocol() + "://" + appConfiguration.getIdpLdapServer();
}
String host = ldapUrl;
String base = appConfiguration.getBaseDN();
String serviceUser = appConfiguration.getIdpBindDn();
String serviceCredential = "";
try {
serviceCredential = encryptionService.decrypt(appConfiguration.getIdpBindPassword());
} catch (EncryptionException e) {
log.error("Failed to decrypt bindPassword", e);
e.printStackTrace();
}
String userField = appConfiguration.getIdpUserFields();
context.put("host", host);
context.put("base", base);
context.put("serviceUser", serviceUser);
context.put("serviceCredential", serviceCredential);
context.put("userField", userField);
// Generate login.config
String loginConfig = templateService.generateConfFile(SHIB3_IDP_LOGIN_CONFIG_FILE, context);
boolean result = (loginConfig != null);
// Write login.config
result &= templateService.writeConfFile(idpConfFolder + SHIB3_IDP_LOGIN_CONFIG_FILE, loginConfig);
return result;
}
use of org.xdi.util.exception.InvalidConfigurationException in project oxTrust by GluuFederation.
the class Shibboleth3ConfService method getConfigurationFilesForSubversion.
public List<SubversionFile> getConfigurationFilesForSubversion(List<GluuSAMLTrustRelationship> trustRelationships) {
if (appConfiguration.getShibboleth3IdpRootDir() == null) {
throw new InvalidConfigurationException("Failed to create SubversionFile file due to undefined IDP root folder");
}
String idpConfFolder = getIdpConfDir();
String idpMetadataFolder = getIdpMetadataDir();
String idpMetadataCredentialsFolder = appConfiguration.getShibboleth3IdpRootDir() + File.separator + SHIB3_IDP_METADATA_CREDENTIALS_FOLDER + File.separator;
String spConfFolder = appConfiguration.getShibboleth3SpConfDir() + File.separator;
List<SubversionFile> subversionFiles = new ArrayList<SubversionFile>();
subversionFiles.add(new SubversionFile(SHIB3_IDP, idpConfFolder + SHIB3_IDP_ATTRIBUTE_RESOLVER_FILE));
subversionFiles.add(new SubversionFile(SHIB3_IDP, idpConfFolder + SHIB3_IDP_ATTRIBUTE_FILTER_FILE));
subversionFiles.add(new SubversionFile(SHIB3_IDP, idpConfFolder + SHIB3_IDP_RELYING_PARTY_FILE));
subversionFiles.add(new SubversionFile(SHIB3_SP, spConfFolder + SHIB3_SP_ATTRIBUTE_MAP_FILE));
subversionFiles.add(new SubversionFile(SHIB3_SP, spConfFolder + SHIB3_SP_SHIBBOLETH2_FILE));
for (GluuSAMLTrustRelationship trustRelationship : trustRelationships) {
if (trustService.getTrustContainerFederation(trustRelationship) == null) {
subversionFiles.add(new SubversionFile(SHIB3_IDP + File.separator + SHIB3_IDP_METADATA_FOLDER, idpMetadataFolder + trustRelationship.getSpMetaDataFN()));
}
if (trustRelationship.getMetadataFilters().containsKey("signatureValidation")) {
subversionFiles.add(new SubversionFile(SHIB3_IDP + File.separator + SHIB3_IDP_METADATA_CREDENTIALS_FOLDER, idpMetadataCredentialsFolder + StringHelper.removePunctuation(trustRelationship.getInum())));
}
}
return subversionFiles;
}
use of org.xdi.util.exception.InvalidConfigurationException in project oxTrust by GluuFederation.
the class Shibboleth3ConfService method getMetadataFilePath.
public String getMetadataFilePath(String metadataFileName) {
if (appConfiguration.getShibboleth3FederationRootDir() == null) {
throw new InvalidConfigurationException("Failed to return meta-data file due to undefined federation root folder");
}
String metadataFolderName = getIdpMetadataDir();
File metadataFolder = new File(metadataFolderName);
if (!metadataFolder.exists()) {
metadataFolder.mkdirs();
}
return metadataFolderName + metadataFileName;
}
use of org.xdi.util.exception.InvalidConfigurationException in project oxTrust by GluuFederation.
the class Shibboleth3ConfService method removeMetadataFile.
public void removeMetadataFile(String spMetaDataFN) {
if (appConfiguration.getShibboleth3FederationRootDir() == null) {
throw new InvalidConfigurationException("Failed to remove meta-data file due to undefined federation root folder");
}
String metadataFolder = getIdpMetadataDir();
File spMetadataFile = new File(metadataFolder + spMetaDataFN);
if (spMetadataFile.exists()) {
spMetadataFile.delete();
}
}
use of org.xdi.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();
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 = templateService.generateConfFile(SHIB3_IDP_METADATA_PROVIDERS_FILE, context);
// Generate attribute-resolver.xml
String attributeResolver = templateService.generateConfFile(SHIB3_IDP_ATTRIBUTE_RESOLVER_FILE, context);
// Generate attribute-filter.xml
String attributeFilter = templateService.generateConfFile(SHIB3_IDP_ATTRIBUTE_FILTER_FILE, context);
// Generate relying-party.xml
String relyingParty = templateService.generateConfFile(SHIB3_IDP_RELYING_PARTY_FILE, context);
// Generate cas-protocol.xml
String casProtocol = templateService.generateConfFile(SHIB3_IDP_CAS_PROTOCOL_FILE, context);
// Generate shibboleth2.xml
String shibConfig = templateService.generateConfFile(SHIB3_SP_SHIBBOLETH2_FILE, context);
// Generate saml-nameid.xml
String samlnamedConfig = templateService.generateConfFile(SHIB3_SAML_NAMEID_FILE, context);
// Generate handler.xml
// String profileHandler = templateService.generateConfFile(SHIB3_IDP_PROFILE_HADLER, context);
// Generate attribute-map.xml
// String attributeMap =
// templateService.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 &= templateService.writeConfFile(idpConfFolder + SHIB3_IDP_METADATA_PROVIDERS_FILE, metadataProviders);
// Write attribute-resolver.xml
result &= templateService.writeConfFile(idpConfFolder + SHIB3_IDP_ATTRIBUTE_RESOLVER_FILE, attributeResolver);
// Write attribute-filter.xml
result &= templateService.writeConfFile(idpConfFolder + SHIB3_IDP_ATTRIBUTE_FILTER_FILE, attributeFilter);
// Write relying-party.xml
result &= templateService.writeConfFile(idpConfFolder + SHIB3_IDP_RELYING_PARTY_FILE, relyingParty);
// Write cas-protocol.xml
result &= templateService.writeConfFile(idpConfFolder + SHIB3_IDP_CAS_PROTOCOL_FILE, casProtocol);
// Write shibboleth2.xml
result &= templateService.writeConfFile(getSpShibboleth3FilePath(), shibConfig);
// Write saml-nameid.xml
result &= templateService.writeConfFile(idpConfFolder + SHIB3_SAML_NAMEID_FILE, samlnamedConfig);
// Write handler.xml
// result &= templateService.writeConfFile(idpConfFolder + SHIB3_IDP_PROFILE_HADLER, profileHandler);
// Write attribute-map.xml
// result &= templateService.writeConfFile(spConfFolder +
// SHIB2_SP_ATTRIBUTE_MAP, attributeMap);
log.info(">>>>>>>>>> LEAVING Shibboleth3ConfService.generateConfigurationFiles()...");
return result;
}
Aggregations