Search in sources :

Example 11 with InvalidConfigurationException

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();
}
Also used : SubversionFile(org.gluu.oxtrust.model.SubversionFile) File(java.io.File) InvalidConfigurationException(org.xdi.util.exception.InvalidConfigurationException)

Example 12 with InvalidConfigurationException

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;
}
Also used : FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) SubversionFile(org.gluu.oxtrust.model.SubversionFile) File(java.io.File) InvalidConfigurationException(org.xdi.util.exception.InvalidConfigurationException)

Example 13 with InvalidConfigurationException

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;
}
Also used : FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) SubversionFile(org.gluu.oxtrust.model.SubversionFile) File(java.io.File) InvalidConfigurationException(org.xdi.util.exception.InvalidConfigurationException)

Aggregations

InvalidConfigurationException (org.xdi.util.exception.InvalidConfigurationException)13 File (java.io.File)10 SubversionFile (org.gluu.oxtrust.model.SubversionFile)9 IOException (java.io.IOException)5 FileOutputStream (java.io.FileOutputStream)4 VelocityContext (org.apache.velocity.VelocityContext)3 ArrayList (java.util.ArrayList)1 GluuSAMLTrustRelationship (org.gluu.oxtrust.model.GluuSAMLTrustRelationship)1 EncryptionException (org.xdi.util.security.StringEncrypter.EncryptionException)1