Search in sources :

Example 6 with ProfileConfiguration

use of org.gluu.oxtrust.model.ProfileConfiguration in project oxTrust by GluuFederation.

the class ProfileConfigurationService method saveProfileConfigurations.

public void saveProfileConfigurations(GluuSAMLTrustRelationship trustRelationship, Map<String, FileUploadWrapper> fileWrappers) {
    VelocityContext context = new VelocityContext();
    if (trustRelationship.getProfileConfigurations().get(SHIBBOLETH_SSO) != null) {
        ProfileConfiguration profileConfiguration = trustRelationship.getProfileConfigurations().get(SHIBBOLETH_SSO);
        context.put(SHIBBOLETH_SSO + "IncludeAttributeStatement", profileConfiguration.isIncludeAttributeStatement());
        context.put(SHIBBOLETH_SSO + "AssertionLifetime", profileConfiguration.getAssertionLifetime());
        context.put(SHIBBOLETH_SSO + "SignResponses", profileConfiguration.getSignResponses());
        context.put(SHIBBOLETH_SSO + "SignAssertions", profileConfiguration.getSignAssertions());
        context.put(SHIBBOLETH_SSO + "SignRequests", profileConfiguration.getSignRequests());
        saveCertificate(trustRelationship, fileWrappers, SHIBBOLETH_SSO);
        String certName = trustRelationship.getProfileConfigurations().get(SHIBBOLETH_SSO).getProfileConfigurationCertFileName();
        if (StringHelper.isNotEmpty(certName)) {
            context.put(SHIBBOLETH_SSO + "SigningCredentialRef", certName);
        }
    }
    if (trustRelationship.getProfileConfigurations().get(SAML1_ARTIFACT_RESOLUTION) != null) {
        ProfileConfiguration profileConfiguration = trustRelationship.getProfileConfigurations().get(SAML1_ARTIFACT_RESOLUTION);
        context.put(SAML1_ARTIFACT_RESOLUTION + "SignResponses", profileConfiguration.getSignResponses());
        context.put(SAML1_ARTIFACT_RESOLUTION + "SignAssertions", profileConfiguration.getSignAssertions());
        context.put(SAML1_ARTIFACT_RESOLUTION + "SignRequests", profileConfiguration.getSignRequests());
        saveCertificate(trustRelationship, fileWrappers, SAML1_ARTIFACT_RESOLUTION);
        String certName = trustRelationship.getProfileConfigurations().get(SAML1_ARTIFACT_RESOLUTION).getProfileConfigurationCertFileName();
        if (StringHelper.isNotEmpty(certName)) {
            context.put(SAML1_ARTIFACT_RESOLUTION + "SigningCredentialRef", certName);
        }
    }
    if (trustRelationship.getProfileConfigurations().get(SAML1_ATTRIBUTE_QUERY) != null) {
        ProfileConfiguration profileConfiguration = trustRelationship.getProfileConfigurations().get(SAML1_ATTRIBUTE_QUERY);
        context.put(SAML1_ATTRIBUTE_QUERY + "AssertionLifetime", profileConfiguration.getAssertionLifetime());
        context.put(SAML1_ATTRIBUTE_QUERY + "SignResponses", profileConfiguration.getSignResponses());
        context.put(SAML1_ATTRIBUTE_QUERY + "SignAssertions", profileConfiguration.getSignAssertions());
        context.put(SAML1_ATTRIBUTE_QUERY + "SignRequests", profileConfiguration.getSignRequests());
        saveCertificate(trustRelationship, fileWrappers, SAML1_ATTRIBUTE_QUERY);
        String certName = trustRelationship.getProfileConfigurations().get(SAML1_ATTRIBUTE_QUERY).getProfileConfigurationCertFileName();
        if (StringHelper.isNotEmpty(certName)) {
            context.put(SAML1_ATTRIBUTE_QUERY + "SigningCredentialRef", certName);
        }
    }
    if (trustRelationship.getProfileConfigurations().get(SAML2_SSO) != null) {
        ProfileConfiguration profileConfiguration = trustRelationship.getProfileConfigurations().get(SAML2_SSO);
        context.put(SAML2_SSO + "IncludeAttributeStatement", profileConfiguration.isIncludeAttributeStatement());
        context.put(SAML2_SSO + "AssertionLifetime", profileConfiguration.getAssertionLifetime());
        context.put(SAML2_SSO + "AssertionProxyCount", profileConfiguration.getAssertionProxyCount());
        context.put(SAML2_SSO + "SignResponses", profileConfiguration.getSignResponses());
        context.put(SAML2_SSO + "SignAssertions", profileConfiguration.getSignAssertions());
        context.put(SAML2_SSO + "SignRequests", profileConfiguration.getSignRequests());
        context.put(SAML2_SSO + "EncryptNameIds", profileConfiguration.getEncryptNameIds());
        context.put(SAML2_SSO + "EncryptAssertions", profileConfiguration.getEncryptAssertions());
        saveCertificate(trustRelationship, fileWrappers, SAML2_SSO);
        String certName = trustRelationship.getProfileConfigurations().get(SAML2_SSO).getProfileConfigurationCertFileName();
        if (StringHelper.isNotEmpty(certName)) {
            context.put(SAML2_SSO + "SigningCredentialRef", certName);
        }
    }
    if (trustRelationship.getProfileConfigurations().get(SAML2_ARTIFACT_RESOLUTION) != null) {
        ProfileConfiguration profileConfiguration = trustRelationship.getProfileConfigurations().get(SAML2_ARTIFACT_RESOLUTION);
        context.put(SAML2_ARTIFACT_RESOLUTION + "SignResponses", profileConfiguration.getSignResponses());
        context.put(SAML2_ARTIFACT_RESOLUTION + "SignAssertions", profileConfiguration.getSignAssertions());
        context.put(SAML2_ARTIFACT_RESOLUTION + "SignRequests", profileConfiguration.getSignRequests());
        context.put(SAML2_ARTIFACT_RESOLUTION + "EncryptAssertions", profileConfiguration.getEncryptAssertions());
        context.put(SAML2_ARTIFACT_RESOLUTION + "EncryptNameIds", profileConfiguration.getEncryptNameIds());
        saveCertificate(trustRelationship, fileWrappers, SAML2_ARTIFACT_RESOLUTION);
        String certName = trustRelationship.getProfileConfigurations().get(SAML2_ARTIFACT_RESOLUTION).getProfileConfigurationCertFileName();
        if (StringHelper.isNotEmpty(certName)) {
            context.put(SAML2_ARTIFACT_RESOLUTION + "SigningCredentialRef", certName);
        }
    }
    if (trustRelationship.getProfileConfigurations().get(SAML2_ATTRIBUTE_QUERY) != null) {
        ProfileConfiguration profileConfiguration = trustRelationship.getProfileConfigurations().get(SAML2_ATTRIBUTE_QUERY);
        context.put(SAML2_ATTRIBUTE_QUERY + "AssertionLifetime", profileConfiguration.getAssertionLifetime());
        context.put(SAML2_ATTRIBUTE_QUERY + "AssertionProxyCount", profileConfiguration.getAssertionProxyCount());
        context.put(SAML2_ATTRIBUTE_QUERY + "SignResponses", profileConfiguration.getSignResponses());
        context.put(SAML2_ATTRIBUTE_QUERY + "SignAssertions", profileConfiguration.getSignAssertions());
        context.put(SAML2_ATTRIBUTE_QUERY + "SignRequests", profileConfiguration.getSignRequests());
        context.put(SAML2_ATTRIBUTE_QUERY + "EncryptAssertions", profileConfiguration.getEncryptAssertions());
        context.put(SAML2_ATTRIBUTE_QUERY + "EncryptNameIds", profileConfiguration.getEncryptNameIds());
        saveCertificate(trustRelationship, fileWrappers, SAML2_ATTRIBUTE_QUERY);
        String certName = trustRelationship.getProfileConfigurations().get(SAML2_ATTRIBUTE_QUERY).getProfileConfigurationCertFileName();
        if (StringHelper.isNotEmpty(certName)) {
            context.put(SAML2_ATTRIBUTE_QUERY + "SigningCredentialRef", certName);
        }
    }
    if (!trustRelationship.getProfileConfigurations().isEmpty()) {
        trustRelationship.setGluuProfileConfiguration(new ArrayList<String>());
        for (String profileConfigurationName : trustRelationship.getProfileConfigurations().keySet()) {
            trustRelationship.getGluuProfileConfiguration().add(templateService.generateConfFile(profileConfigurationName + "ProfileConfiguration.xml", context));
        }
    } else {
        trustRelationship.setGluuProfileConfiguration(null);
    }
}
Also used : VelocityContext(org.apache.velocity.VelocityContext) ProfileConfiguration(org.gluu.oxtrust.model.ProfileConfiguration)

Aggregations

ProfileConfiguration (org.gluu.oxtrust.model.ProfileConfiguration)6 FileUploadWrapper (org.xdi.util.io.FileUploadWrapper)2 File (java.io.File)1 FilenameFilter (java.io.FilenameFilter)1 ArrayList (java.util.ArrayList)1 VelocityContext (org.apache.velocity.VelocityContext)1 Document (org.w3c.dom.Document)1 Node (org.w3c.dom.Node)1