Search in sources :

Example 1 with EasyCASSLProtocolSocketFactory

use of org.gluu.oxtrust.util.EasyCASSLProtocolSocketFactory in project oxTrust by GluuFederation.

the class Shibboleth3ConfService method saveSpMetadataFile.

public String saveSpMetadataFile(String uri, String spMetadataFileName) {
    if (StringHelper.isEmpty(uri)) {
        return null;
    }
    HTTPFileDownloader.setEasyhttps(new Protocol("https", new EasyCASSLProtocolSocketFactory(), 443));
    String spMetadataFileContent = HTTPFileDownloader.getResource(uri, "application/xml, text/xml", null, null);
    if (StringHelper.isEmpty(spMetadataFileContent)) {
        return null;
    }
    // Save new file
    ByteArrayInputStream is;
    try {
        byte[] spMetadataFileContentBytes = spMetadataFileContent.getBytes("UTF-8");
        is = new ByteArrayInputStream(spMetadataFileContentBytes);
    } catch (UnsupportedEncodingException ex) {
        log.error("saveSpMetadataFile exception", ex);
        ex.printStackTrace();
        return null;
    }
    FileUploadWrapper tmpfileWrapper = new FileUploadWrapper();
    tmpfileWrapper.setStream(is);
    return saveSpMetadataFile(spMetadataFileName, tmpfileWrapper.getStream());
}
Also used : EasyCASSLProtocolSocketFactory(org.gluu.oxtrust.util.EasyCASSLProtocolSocketFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Protocol(org.apache.commons.httpclient.protocol.Protocol) FileUploadWrapper(org.xdi.util.io.FileUploadWrapper)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Protocol (org.apache.commons.httpclient.protocol.Protocol)1 EasyCASSLProtocolSocketFactory (org.gluu.oxtrust.util.EasyCASSLProtocolSocketFactory)1 FileUploadWrapper (org.xdi.util.io.FileUploadWrapper)1