From 0015b9f6e383c02805ec8f54b4deecf91c565cdc Mon Sep 17 00:00:00 2001 From: ane Date: Fri, 1 Apr 2016 15:24:37 +0200 Subject: [PATCH] Added new key for the sonar.properties file: crowd.groups.sync (true/false) If false, the groups are not synced from the crowd server. Defaults to true. --- .../java/org/sonar/plugins/crowd/CrowdConfiguration.java | 9 +++++++++ src/main/java/org/sonar/plugins/crowd/CrowdRealm.java | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/sonar/plugins/crowd/CrowdConfiguration.java b/src/main/java/org/sonar/plugins/crowd/CrowdConfiguration.java index ac0b082..fbc7277 100644 --- a/src/main/java/org/sonar/plugins/crowd/CrowdConfiguration.java +++ b/src/main/java/org/sonar/plugins/crowd/CrowdConfiguration.java @@ -32,6 +32,7 @@ public class CrowdConfiguration implements ServerExtension { static final String KEY_CROWD_APP_NAME = "crowd.application"; static final String KEY_CROWD_APP_PASSWORD = "crowd.password"; static final String FALLBACK_NAME = "sonar"; + static final String KEY_CROWD_GRP_SYNC = "crowd.groups.sync"; private final Settings settings; /** @@ -82,4 +83,12 @@ public String getCrowdApplicationPassword() { public String getCrowdUrl() { return getAndValidate(KEY_CROWD_URL, settings); } + + /** + * Define if the Groups have to be synced from the Crowd server. + * Defaults to true if not provided. + */ + public String getCrowdGrpSync() { + return get(KEY_CROWD_GRP_SYNC, settings, "true"); + } } diff --git a/src/main/java/org/sonar/plugins/crowd/CrowdRealm.java b/src/main/java/org/sonar/plugins/crowd/CrowdRealm.java index 62b94a6..e4954af 100644 --- a/src/main/java/org/sonar/plugins/crowd/CrowdRealm.java +++ b/src/main/java/org/sonar/plugins/crowd/CrowdRealm.java @@ -113,7 +113,12 @@ public LoginPasswordAuthenticator getLoginPasswordAuthenticator() { @Override public ExternalGroupsProvider getGroupsProvider() { - return groupsProvider; + if(this.crowdConfiguration.getCrowdGrpSync() == "true") { + LOG.debug("Sync group from Crowd enabled."); + return groupsProvider; + } + LOG.debug("Sync groups from Crowd disabled."); + return null; } @Override