use of org.xdi.util.exception.InvalidConfigurationException in project oxTrust by GluuFederation.
the class Shibboleth3ConfService method isCorrectMetadataFile.
public boolean isCorrectMetadataFile(String spMetaDataFN) {
if (appConfiguration.getShibboleth3FederationRootDir() == null) {
throw new InvalidConfigurationException("Failed to check meta-data file due to undefined federation root folder");
}
String metadataFolder = getIdpMetadataDir();
File metadataFile = new File(metadataFolder + spMetaDataFN);
List<String> entityId = SAMLMetadataParser.getEntityIdFromMetadataFile(metadataFile);
return (entityId != null) && !entityId.isEmpty();
}
use of org.xdi.util.exception.InvalidConfigurationException in project oxTrust by GluuFederation.
the class Shibboleth3ConfService method saveMetadataFile.
public boolean saveMetadataFile(String metadataFileName, InputStream stream) {
if (appConfiguration.getShibboleth3FederationRootDir() == null) {
IOUtils.closeQuietly(stream);
throw new InvalidConfigurationException("Failed to save meta-data file due to undefined federation root folder");
}
String idpMetadataFolderName = getIdpMetadataDir();
File idpMetadataFolder = new File(idpMetadataFolderName);
if (!idpMetadataFolder.exists()) {
idpMetadataFolder.mkdirs();
}
File spMetadataFile = new File(idpMetadataFolderName + metadataFileName);
FileOutputStream os = null;
try {
os = FileUtils.openOutputStream(spMetadataFile);
IOUtils.copy(stream, os);
os.flush();
} catch (IOException ex) {
log.error("Failed to write meta-data file '{}'", spMetadataFile, ex);
ex.printStackTrace();
return false;
} finally {
IOUtils.closeQuietly(os);
IOUtils.closeQuietly(stream);
}
return true;
}
use of org.xdi.util.exception.InvalidConfigurationException in project oxTrust by GluuFederation.
the class Shibboleth3ConfService method saveSpMetadataFile.
public String saveSpMetadataFile(String spMetadataFileName, InputStream input) {
if (appConfiguration.getShibboleth3IdpRootDir() == null) {
IOUtils.closeQuietly(input);
String errorMessage = "Failed to save SP meta-data file due to undefined IDP root folder";
log.error(errorMessage);
throw new InvalidConfigurationException(errorMessage);
}
// String idpMetadataFolder = getIdpMetadataDir();
String idpMetadataTempFolder = getIdpMetadataTempDir();
String tempFileName = getTempMetadataFilename(idpMetadataTempFolder, spMetadataFileName);
// temp file location for metadatavalidator thread process .
File spMetadataFile = new File(idpMetadataTempFolder + tempFileName);
FileOutputStream os = null;
try {
os = FileUtils.openOutputStream(spMetadataFile);
IOUtils.copy(input, os);
os.flush();
} catch (IOException ex) {
log.error("Failed to write SP meta-data file '{}'", spMetadataFile, ex);
ex.printStackTrace();
return null;
} finally {
IOUtils.closeQuietly(os);
IOUtils.closeQuietly(input);
}
return tempFileName;
}
Aggregations