Search in sources :

Example 1 with ProfileConfiguration

use of org.gluu.oxtrust.model.ProfileConfiguration 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 ProfileConfiguration

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

the class ProfileConfigurationService method parseProfileConfigurations.

public void parseProfileConfigurations(GluuSAMLTrustRelationship trustRelationship) throws SAXException, IOException, ParserConfigurationException, FactoryConfigurationError, XPathExpressionException {
    if (trustRelationship.getGluuProfileConfiguration() != null) {
        for (String profileConfigurationXML : trustRelationship.getGluuProfileConfiguration()) {
            Document xmlDocument = xmlService.getXmlDocument(profileConfigurationXML.getBytes(), true);
            if (xmlDocument.getFirstChild().getAttributes().getNamedItem("xsi:type").getNodeValue().contains(SHIBBOLETH_SSO)) {
                ProfileConfiguration profileConfiguration = createProfileConfiguration(SHIBBOLETH_SSO);
                profileConfiguration.setIncludeAttributeStatement(Boolean.parseBoolean(xmlDocument.getFirstChild().getAttributes().getNamedItem("includeAttributeStatement").getNodeValue()));
                profileConfiguration.setAssertionLifetime(Integer.parseInt(xmlDocument.getFirstChild().getAttributes().getNamedItem("assertionLifetime").getNodeValue()));
                profileConfiguration.setSignResponses(xmlDocument.getFirstChild().getAttributes().getNamedItem("signResponses").getNodeValue());
                profileConfiguration.setSignAssertions(xmlDocument.getFirstChild().getAttributes().getNamedItem("signAssertions").getNodeValue());
                profileConfiguration.setSignRequests(xmlDocument.getFirstChild().getAttributes().getNamedItem("signRequests").getNodeValue());
                Node attribute = xmlDocument.getFirstChild().getAttributes().getNamedItem("signingCredentialRef");
                if (attribute != null) {
                    profileConfiguration.setProfileConfigurationCertFileName(attribute.getNodeValue());
                }
                trustRelationship.getProfileConfigurations().put(SHIBBOLETH_SSO, profileConfiguration);
                continue;
            }
            if (xmlDocument.getFirstChild().getAttributes().getNamedItem("xsi:type").getNodeValue().contains(SAML1_ARTIFACT_RESOLUTION)) {
                ProfileConfiguration profileConfiguration = createProfileConfiguration(SAML1_ARTIFACT_RESOLUTION);
                profileConfiguration.setSignResponses(xmlDocument.getFirstChild().getAttributes().getNamedItem("signResponses").getNodeValue());
                profileConfiguration.setSignAssertions(xmlDocument.getFirstChild().getAttributes().getNamedItem("signAssertions").getNodeValue());
                profileConfiguration.setSignRequests(xmlDocument.getFirstChild().getAttributes().getNamedItem("signRequests").getNodeValue());
                Node attribute = xmlDocument.getFirstChild().getAttributes().getNamedItem("signingCredentialRef");
                if (attribute != null) {
                    profileConfiguration.setProfileConfigurationCertFileName(attribute.getNodeValue());
                }
                trustRelationship.getProfileConfigurations().put(SAML1_ARTIFACT_RESOLUTION, profileConfiguration);
                continue;
            }
            if (xmlDocument.getFirstChild().getAttributes().getNamedItem("xsi:type").getNodeValue().contains(SAML1_ATTRIBUTE_QUERY)) {
                ProfileConfiguration profileConfiguration = createProfileConfiguration(SAML1_ATTRIBUTE_QUERY);
                profileConfiguration.setAssertionLifetime(Integer.parseInt(xmlDocument.getFirstChild().getAttributes().getNamedItem("assertionLifetime").getNodeValue()));
                profileConfiguration.setSignResponses(xmlDocument.getFirstChild().getAttributes().getNamedItem("signResponses").getNodeValue());
                profileConfiguration.setSignAssertions(xmlDocument.getFirstChild().getAttributes().getNamedItem("signAssertions").getNodeValue());
                profileConfiguration.setSignRequests(xmlDocument.getFirstChild().getAttributes().getNamedItem("signRequests").getNodeValue());
                Node attribute = xmlDocument.getFirstChild().getAttributes().getNamedItem("signingCredentialRef");
                if (attribute != null) {
                    profileConfiguration.setProfileConfigurationCertFileName(attribute.getNodeValue());
                }
                trustRelationship.getProfileConfigurations().put(SAML1_ATTRIBUTE_QUERY, profileConfiguration);
                continue;
            }
            if (xmlDocument.getFirstChild().getAttributes().getNamedItem("xsi:type").getNodeValue().contains(SAML2_SSO)) {
                ProfileConfiguration profileConfiguration = createProfileConfiguration(SAML2_SSO);
                profileConfiguration.setIncludeAttributeStatement(Boolean.parseBoolean(xmlDocument.getFirstChild().getAttributes().getNamedItem("includeAttributeStatement").getNodeValue()));
                profileConfiguration.setAssertionLifetime(Integer.parseInt(xmlDocument.getFirstChild().getAttributes().getNamedItem("assertionLifetime").getNodeValue()));
                profileConfiguration.setAssertionProxyCount(Integer.parseInt(xmlDocument.getFirstChild().getAttributes().getNamedItem("assertionProxyCount").getNodeValue()));
                profileConfiguration.setSignResponses(xmlDocument.getFirstChild().getAttributes().getNamedItem("signResponses").getNodeValue());
                profileConfiguration.setSignAssertions(xmlDocument.getFirstChild().getAttributes().getNamedItem("signAssertions").getNodeValue());
                profileConfiguration.setSignRequests(xmlDocument.getFirstChild().getAttributes().getNamedItem("signRequests").getNodeValue());
                profileConfiguration.setEncryptAssertions(xmlDocument.getFirstChild().getAttributes().getNamedItem("encryptAssertions").getNodeValue());
                profileConfiguration.setEncryptNameIds(xmlDocument.getFirstChild().getAttributes().getNamedItem("encryptNameIds").getNodeValue());
                Node attribute = xmlDocument.getFirstChild().getAttributes().getNamedItem("signingCredentialRef");
                if (attribute != null) {
                    profileConfiguration.setProfileConfigurationCertFileName(attribute.getNodeValue());
                }
                trustRelationship.getProfileConfigurations().put(SAML2_SSO, profileConfiguration);
                continue;
            }
            if (xmlDocument.getFirstChild().getAttributes().getNamedItem("xsi:type").getNodeValue().contains(SAML2_ARTIFACT_RESOLUTION)) {
                ProfileConfiguration profileConfiguration = createProfileConfiguration(SAML2_ARTIFACT_RESOLUTION);
                profileConfiguration.setSignResponses(xmlDocument.getFirstChild().getAttributes().getNamedItem("signResponses").getNodeValue());
                profileConfiguration.setSignAssertions(xmlDocument.getFirstChild().getAttributes().getNamedItem("signAssertions").getNodeValue());
                profileConfiguration.setSignRequests(xmlDocument.getFirstChild().getAttributes().getNamedItem("signRequests").getNodeValue());
                profileConfiguration.setEncryptAssertions(xmlDocument.getFirstChild().getAttributes().getNamedItem("encryptNameIds").getNodeValue());
                profileConfiguration.setEncryptNameIds(xmlDocument.getFirstChild().getAttributes().getNamedItem("encryptNameIds").getNodeValue());
                Node attribute = xmlDocument.getFirstChild().getAttributes().getNamedItem("signingCredentialRef");
                if (attribute != null) {
                    profileConfiguration.setProfileConfigurationCertFileName(attribute.getNodeValue());
                }
                trustRelationship.getProfileConfigurations().put(SAML2_ARTIFACT_RESOLUTION, profileConfiguration);
                continue;
            }
            if (xmlDocument.getFirstChild().getAttributes().getNamedItem("xsi:type").getNodeValue().contains(SAML2_ATTRIBUTE_QUERY)) {
                ProfileConfiguration profileConfiguration = createProfileConfiguration(SAML2_ATTRIBUTE_QUERY);
                profileConfiguration.setAssertionLifetime(Integer.parseInt(xmlDocument.getFirstChild().getAttributes().getNamedItem("assertionLifetime").getNodeValue()));
                profileConfiguration.setAssertionProxyCount(Integer.parseInt(xmlDocument.getFirstChild().getAttributes().getNamedItem("assertionProxyCount").getNodeValue()));
                profileConfiguration.setSignResponses(xmlDocument.getFirstChild().getAttributes().getNamedItem("signResponses").getNodeValue());
                profileConfiguration.setSignAssertions(xmlDocument.getFirstChild().getAttributes().getNamedItem("signAssertions").getNodeValue());
                profileConfiguration.setSignRequests(xmlDocument.getFirstChild().getAttributes().getNamedItem("signRequests").getNodeValue());
                profileConfiguration.setEncryptAssertions(xmlDocument.getFirstChild().getAttributes().getNamedItem("encryptNameIds").getNodeValue());
                profileConfiguration.setEncryptNameIds(xmlDocument.getFirstChild().getAttributes().getNamedItem("encryptNameIds").getNodeValue());
                Node attribute = xmlDocument.getFirstChild().getAttributes().getNamedItem("signingCredentialRef");
                if (attribute != null) {
                    profileConfiguration.setProfileConfigurationCertFileName(attribute.getNodeValue());
                }
                trustRelationship.getProfileConfigurations().put(SAML2_ATTRIBUTE_QUERY, profileConfiguration);
                continue;
            }
        }
    }
}
Also used : ProfileConfiguration(org.gluu.oxtrust.model.ProfileConfiguration) Node(org.w3c.dom.Node) Document(org.w3c.dom.Document)

Example 3 with ProfileConfiguration

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

the class RelyingPartyAction method initProfileConfigurations.

public String initProfileConfigurations() {
    if (profileConfigurations != null) {
        return OxTrustConstants.RESULT_SUCCESS;
    }
    trustRelationship = updateTrustRelationshipAction.getTrustRelationship();
    try {
        profileConfigurationService.parseProfileConfigurations(trustRelationship);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    availableProfileConfigurations = new ArrayList<String>();
    for (ProfileConfiguration profileConfiguration : profileConfigurationService.getAvailableProfileConfigurations()) {
        availableProfileConfigurations.add(profileConfiguration.getName());
        this.getFileWrappers().put(profileConfiguration.getName(), new FileUploadWrapper());
    }
    profileConfigurations = new ArrayList<String>();
    savedProfileConfigurations = new ArrayList<ProfileConfiguration>();
    for (ProfileConfiguration profileConfiguration : profileConfigurationService.getProfileConfigurationsList(trustRelationship)) {
        savedProfileConfigurations.add(profileConfiguration);
        profileConfigurations.add(profileConfiguration.getName());
    }
    // availableProfileConfigurations.removeAll(profileConfigurations);
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : ProfileConfiguration(org.gluu.oxtrust.model.ProfileConfiguration) FileUploadWrapper(org.xdi.util.io.FileUploadWrapper)

Example 4 with ProfileConfiguration

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

the class ProfileConfigurationService method getAvailableProfileConfigurations.

public List<ProfileConfiguration> getAvailableProfileConfigurations() {
    String idpTemplatesLocation = configurationFactory.getIDPTemplatesLocation();
    // File profileConfigurationFolder = new File(configurationFactory.DIR + "shibboleth3" + File.separator + "idp" + File.separator + "ProfileConfiguration");
    File profileConfigurationFolder = new File(idpTemplatesLocation + "shibboleth3" + File.separator + "idp" + File.separator + "ProfileConfiguration");
    File[] profileConfigurationTemplates = null;
    List<ProfileConfiguration> profileConfigurations = new ArrayList<ProfileConfiguration>();
    if (profileConfigurationFolder.exists() && profileConfigurationFolder.isDirectory()) {
        profileConfigurationTemplates = profileConfigurationFolder.listFiles(new FilenameFilter() {

            public boolean accept(File dir, String name) {
                return name.endsWith("ProfileConfiguration.xml.vm");
            }
        });
        for (File profileConfigurationTemplate : profileConfigurationTemplates) {
            profileConfigurations.add(createProfileConfiguration(profileConfigurationTemplate.getName().split("ProfileConfiguration")[0]));
        }
    }
    return profileConfigurations;
}
Also used : FilenameFilter(java.io.FilenameFilter) ProfileConfiguration(org.gluu.oxtrust.model.ProfileConfiguration) ArrayList(java.util.ArrayList) File(java.io.File)

Example 5 with ProfileConfiguration

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

the class ProfileConfigurationService method createProfileConfiguration.

private ProfileConfiguration createProfileConfiguration(String profileConfigurationName) {
    ProfileConfiguration profileConfiguration = new ProfileConfiguration();
    profileConfiguration.setName(profileConfigurationName);
    if (SHIBBOLETH_SSO.equals(profileConfigurationName)) {
        profileConfiguration.setIncludeAttributeStatement(false);
        profileConfiguration.setAssertionLifetime(300000);
        profileConfiguration.setSignResponses("conditional");
        profileConfiguration.setSignAssertions("never");
        profileConfiguration.setSignRequests("conditional");
    }
    if (SAML1_ARTIFACT_RESOLUTION.equals(profileConfigurationName)) {
        profileConfiguration.setSignResponses("conditional");
        profileConfiguration.setSignAssertions("never");
        profileConfiguration.setSignRequests("conditional");
    }
    if (SAML1_ATTRIBUTE_QUERY.equals(profileConfigurationName)) {
        profileConfiguration.setAssertionLifetime(300000);
        profileConfiguration.setSignResponses("conditional");
        profileConfiguration.setSignAssertions("never");
        profileConfiguration.setSignRequests("conditional");
    }
    if (SAML2_SSO.equals(profileConfigurationName)) {
        profileConfiguration.setIncludeAttributeStatement(true);
        profileConfiguration.setAssertionLifetime(300000);
        profileConfiguration.setAssertionProxyCount(0);
        profileConfiguration.setSignResponses("conditional");
        profileConfiguration.setSignAssertions("never");
        profileConfiguration.setSignRequests("conditional");
        profileConfiguration.setEncryptAssertions("conditional");
        profileConfiguration.setEncryptNameIds("never");
    }
    if (SAML2_ARTIFACT_RESOLUTION.equals(profileConfigurationName)) {
        profileConfiguration.setSignResponses("conditional");
        profileConfiguration.setSignAssertions("never");
        profileConfiguration.setSignRequests("conditional");
        profileConfiguration.setEncryptAssertions("conditional");
        profileConfiguration.setEncryptNameIds("never");
    }
    if (SAML2_ATTRIBUTE_QUERY.equals(profileConfigurationName)) {
        profileConfiguration.setAssertionLifetime(300000);
        profileConfiguration.setAssertionProxyCount(0);
        profileConfiguration.setSignResponses("conditional");
        profileConfiguration.setSignAssertions("never");
        profileConfiguration.setSignRequests("conditional");
        profileConfiguration.setEncryptAssertions("conditional");
        profileConfiguration.setEncryptNameIds("never");
    }
    return profileConfiguration;
}
Also used : 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