Search in sources :

Example 1 with AttributeResolverConfiguration

use of org.gluu.config.oxtrust.AttributeResolverConfiguration in project oxTrust by GluuFederation.

the class ConfigureNameIdAction method init.

public String init() {
    loadNameIds();
    this.attributes = attributeService.getAllAttributes();
    this.nameIdConfigs = new ArrayList<NameIdConfig>();
    AttributeResolverConfiguration attributeResolverConfiguration = configurationFactory.getAttributeResolverConfiguration();
    if ((attributeResolverConfiguration != null) && (attributeResolverConfiguration.getNameIdConfigs() != null)) {
        this.usedNamedIds.clear();
        for (NameIdConfig nameIdConfig : attributeResolverConfiguration.getNameIdConfigs()) {
            this.nameIdConfigs.add(nameIdConfig);
            this.usedNamedIds.put(nameIdConfig.getNameIdType(), nameIdConfig.getNameIdType());
        }
    }
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : AttributeResolverConfiguration(org.gluu.config.oxtrust.AttributeResolverConfiguration) NameIdConfig(org.gluu.config.oxtrust.NameIdConfig)

Example 2 with AttributeResolverConfiguration

use of org.gluu.config.oxtrust.AttributeResolverConfiguration in project oxTrust by GluuFederation.

the class ConfigureNameIdAction method saveImpl.

private String saveImpl() {
    AttributeResolverConfiguration attributeResolverConfiguration = new AttributeResolverConfiguration();
    attributeResolverConfiguration.setNameIdConfigs(this.nameIdConfigs);
    jsonConfigurationService.saveOxTrustAttributeResolverConfigurationConfiguration(attributeResolverConfiguration);
    boolean updateShib3Configuration = applicationConfiguration.isConfigGeneration();
    if (updateShib3Configuration) {
        List<GluuSAMLTrustRelationship> trustRelationships = trustService.getAllActiveTrustRelationships();
        if (!shibboleth3ConfService.generateConfigurationFiles(trustRelationships)) {
            log.error("Failed to update Shibboleth v3 configuration");
            facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to update Shibboleth v3 configuration");
        } else {
            try {
                SSLContext sslContext = SSLContextBuilder.create().loadTrustMaterial(new TrustSelfSignedStrategy()).build();
                HostnameVerifier allowAllHosts = new NoopHostnameVerifier();
                SSLConnectionSocketFactory connectionFactory = new SSLConnectionSocketFactory(sslContext, allowAllHosts);
                HttpClient client = HttpClients.custom().setDefaultRequestConfig(RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD).build()).setSSLSocketFactory(connectionFactory).build();
                HttpGet request = new HttpGet(CloudEditionUtil.getIdpHost().orElse("https://localhost") + "/idp/profile/admin/reload-service?id=shibboleth.NameIdentifierGenerationService");
                request.addHeader("User-Agent", "Mozilla/5.0");
                HttpResponse response = client.execute(request);
                log.info(EntityUtils.toString(response.getEntity(), "UTF-8"));
            } catch (Exception e) {
                log.error("error refreshing nameid setting (kindly restart services manually)", e);
                return OxTrustConstants.RESULT_RESTART_IDP;
            }
        }
    }
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : GluuSAMLTrustRelationship(org.gluu.oxtrust.model.GluuSAMLTrustRelationship) NoopHostnameVerifier(org.apache.http.conn.ssl.NoopHostnameVerifier) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) AttributeResolverConfiguration(org.gluu.config.oxtrust.AttributeResolverConfiguration) SSLContext(javax.net.ssl.SSLContext) SSLConnectionSocketFactory(org.apache.http.conn.ssl.SSLConnectionSocketFactory) NoopHostnameVerifier(org.apache.http.conn.ssl.NoopHostnameVerifier) HostnameVerifier(javax.net.ssl.HostnameVerifier) HttpClient(org.apache.http.client.HttpClient) TrustSelfSignedStrategy(org.apache.http.conn.ssl.TrustSelfSignedStrategy)

Example 3 with AttributeResolverConfiguration

use of org.gluu.config.oxtrust.AttributeResolverConfiguration in project oxTrust by GluuFederation.

the class Shibboleth3ConfService method initAttributeResolverParamMap.

public HashMap<String, Object> initAttributeResolverParamMap() {
    List<NameIdConfig> nameIdConfigs = new ArrayList<NameIdConfig>();
    Set<GluuAttribute> nameIdAttributes = new HashSet<GluuAttribute>();
    AttributeResolverConfiguration attributeResolverConfiguration = configurationFactory.getAttributeResolverConfiguration();
    if ((attributeResolverConfiguration != null) && (attributeResolverConfiguration.getNameIdConfigs() != null)) {
        for (NameIdConfig nameIdConfig : attributeResolverConfiguration.getNameIdConfigs()) {
            if (StringHelper.isNotEmpty(nameIdConfig.getSourceAttribute()) && nameIdConfig.isEnabled()) {
                String attributeName = nameIdConfig.getSourceAttribute();
                GluuAttribute attribute = attributeService.getAttributeByName(attributeName);
                nameIdConfigs.add(nameIdConfig);
                nameIdAttributes.add(attribute);
            }
        }
    }
    HashMap<String, Object> attributeResolverParams = createAttributeMap(nameIdAttributes);
    attributeResolverParams.put("configs", nameIdConfigs);
    attributeResolverParams.put("attributes", nameIdAttributes);
    String baseUserDn = personService.getDnForPerson(null);
    String persistenceType = persistenceEntryManager.getPersistenceType(baseUserDn);
    log.debug(">>>>>>>>>> Shibboleth3ConfService.initAttributeResolverParamMap() - Persistance type: '{}'", persistenceType);
    attributeResolverParams.put("persistenceType", persistenceType);
    return attributeResolverParams;
}
Also used : ArrayList(java.util.ArrayList) AttributeResolverConfiguration(org.gluu.config.oxtrust.AttributeResolverConfiguration) NameIdConfig(org.gluu.config.oxtrust.NameIdConfig) GluuAttribute(org.gluu.model.GluuAttribute) HashSet(java.util.HashSet)

Aggregations

AttributeResolverConfiguration (org.gluu.config.oxtrust.AttributeResolverConfiguration)3 NameIdConfig (org.gluu.config.oxtrust.NameIdConfig)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 HostnameVerifier (javax.net.ssl.HostnameVerifier)1 SSLContext (javax.net.ssl.SSLContext)1 HttpResponse (org.apache.http.HttpResponse)1 HttpClient (org.apache.http.client.HttpClient)1 HttpGet (org.apache.http.client.methods.HttpGet)1 NoopHostnameVerifier (org.apache.http.conn.ssl.NoopHostnameVerifier)1 SSLConnectionSocketFactory (org.apache.http.conn.ssl.SSLConnectionSocketFactory)1 TrustSelfSignedStrategy (org.apache.http.conn.ssl.TrustSelfSignedStrategy)1 GluuAttribute (org.gluu.model.GluuAttribute)1 GluuSAMLTrustRelationship (org.gluu.oxtrust.model.GluuSAMLTrustRelationship)1