Search in sources :

Example 1 with FileUploadWrapper

use of org.xdi.util.io.FileUploadWrapper in project oxTrust by GluuFederation.

the class RelyingPartyAction method updateProfileConfigurations.

public String updateProfileConfigurations() {
    for (ProfileConfiguration profileConfiguration : savedProfileConfigurations) {
        if (!profileConfigurationService.isProfileConfigurationPresent(trustRelationship, profileConfiguration)) {
            this.getFileWrappers().put(profileConfiguration.getName(), new FileUploadWrapper());
            profileConfigurationService.updateProfileConfiguration(trustRelationship, profileConfiguration);
        }
    }
    for (ProfileConfiguration profileConfiguration : profileConfigurationService.getProfileConfigurationsList(trustRelationship)) {
        if (!profileConfigurations.contains(profileConfiguration.getName())) {
            this.getFileWrappers().remove(profileConfiguration.getName());
            ProfileConfiguration removedProfileConfiguration = null;
            for (ProfileConfiguration savedProfileConfiguration : savedProfileConfigurations) {
                if (savedProfileConfiguration.getName().equals(profileConfiguration.getName())) {
                    removedProfileConfiguration = profileConfiguration;
                }
            }
            if (removedProfileConfiguration != null) {
                savedProfileConfigurations.remove(profileConfiguration);
            }
            profileConfigurationService.removeProfileConfiguration(trustRelationship, profileConfiguration);
        }
    }
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : ProfileConfiguration(org.gluu.oxtrust.model.ProfileConfiguration) FileUploadWrapper(org.xdi.util.io.FileUploadWrapper)

Example 2 with FileUploadWrapper

use of org.xdi.util.io.FileUploadWrapper in project oxTrust by GluuFederation.

the class UpdateTrustRelationshipAction method add.

public String add() {
    if (this.trustRelationship != null) {
        return OxTrustConstants.RESULT_SUCCESS;
    }
    this.update = false;
    this.trustRelationship = new GluuSAMLTrustRelationship();
    this.trustRelationship.setMaxRefreshDelay("PT8H");
    this.fileWrapper = new FileUploadWrapper();
    this.trustRelationship.setOwner(organizationService.getOrganization().getDn());
    boolean initActionsResult = initActions();
    if (!initActionsResult) {
        return OxTrustConstants.RESULT_FAILURE;
    }
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : GluuSAMLTrustRelationship(org.gluu.oxtrust.model.GluuSAMLTrustRelationship) FileUploadWrapper(org.xdi.util.io.FileUploadWrapper)

Example 3 with FileUploadWrapper

use of org.xdi.util.io.FileUploadWrapper in project oxTrust by GluuFederation.

the class UpdateTrustRelationshipAction method update.

public String update() {
    if (this.trustRelationship != null) {
        return OxTrustConstants.RESULT_SUCCESS;
    }
    this.update = true;
    try {
        this.trustRelationship = trustService.getRelationshipByInum(inum);
    } catch (LdapMappingException ex) {
        log.error("Failed to find trust relationship {}", ex, inum);
    }
    if (this.trustRelationship == null) {
        return OxTrustConstants.RESULT_FAILURE;
    }
    this.fileWrapper = new FileUploadWrapper();
    this.fileWrapper.setFileName(this.trustRelationship.getSpMetaDataFN());
    boolean initActionsResult = initActions();
    if (!initActionsResult) {
        return OxTrustConstants.RESULT_FAILURE;
    }
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException) FileUploadWrapper(org.xdi.util.io.FileUploadWrapper)

Example 4 with FileUploadWrapper

use of org.xdi.util.io.FileUploadWrapper 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) {
        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)

Example 5 with FileUploadWrapper

use of org.xdi.util.io.FileUploadWrapper in project oxTrust by GluuFederation.

the class Shibboleth3ConfService method saveMetadataFile.

public boolean saveMetadataFile(String spMetaDataURL, String metadataFileName) {
    if (StringHelper.isEmpty(spMetaDataURL)) {
        return false;
    }
    String metadataFileContent = HTTPFileDownloader.getResource(spMetaDataURL, "application/xml, text/xml", null, null);
    if (StringHelper.isEmpty(metadataFileContent)) {
        return false;
    }
    // Save new file
    ByteArrayInputStream is;
    try {
        byte[] metadataFileContentBytes = metadataFileContent.getBytes("UTF-8");
        is = new ByteArrayInputStream(metadataFileContentBytes);
    } catch (UnsupportedEncodingException ex) {
        ex.printStackTrace();
        return false;
    }
    FileUploadWrapper tmpfileWrapper = new FileUploadWrapper();
    tmpfileWrapper.setStream(is);
    return saveMetadataFile(metadataFileName, tmpfileWrapper.getStream());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) UnsupportedEncodingException(java.io.UnsupportedEncodingException) FileUploadWrapper(org.xdi.util.io.FileUploadWrapper)

Aggregations

FileUploadWrapper (org.xdi.util.io.FileUploadWrapper)7 ByteArrayInputStream (java.io.ByteArrayInputStream)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ProfileConfiguration (org.gluu.oxtrust.model.ProfileConfiguration)2 Protocol (org.apache.commons.httpclient.protocol.Protocol)1 GluuSAMLTrustRelationship (org.gluu.oxtrust.model.GluuSAMLTrustRelationship)1 EasyCASSLProtocolSocketFactory (org.gluu.oxtrust.util.EasyCASSLProtocolSocketFactory)1 LdapMappingException (org.gluu.site.ldap.persistence.exception.LdapMappingException)1