From 22b7a70ebeba2734e1b5c0f48e2e023885053544 Mon Sep 17 00:00:00 2001 From: James Ding Date: Sun, 29 Jun 2014 17:20:12 +0200 Subject: [PATCH] Resolve Issues SONARPLUGINS-2931 (Update pom.xml) and SONARPLUGINS-3028 (Use the sonar.security.realm property) --- pom.xml | 2 +- .../org/sonar/plugins/crowd/CrowdPlugin.java | 15 +++--- .../org/sonar/plugins/crowd/CrowdRealm.java | 47 +++++++++++++++++++ 3 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 src/main/java/org/sonar/plugins/crowd/CrowdRealm.java diff --git a/pom.xml b/pom.xml index 14b709f..b38cedf 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ sonar-plugin Sonar Crowd Plugin - Enables the delegation of Sonar authentication to Atlassian Crowd. + Delegates authentication to Atlassian Crowd. http://docs.codehaus.org/display/SONAR/Crowd+Plugin 2009 diff --git a/src/main/java/org/sonar/plugins/crowd/CrowdPlugin.java b/src/main/java/org/sonar/plugins/crowd/CrowdPlugin.java index 4813398..234fc8b 100644 --- a/src/main/java/org/sonar/plugins/crowd/CrowdPlugin.java +++ b/src/main/java/org/sonar/plugins/crowd/CrowdPlugin.java @@ -29,11 +29,12 @@ /** * @author Evgeny Mandrikov */ + public class CrowdPlugin extends SonarPlugin { - public List> getExtensions() { - ArrayList> extensions = new ArrayList>(); - extensions.add(CrowdAuthenticator.class); - extensions.add(CrowdConfiguration.class); - return extensions; - } -} + public List> getExtensions() { + ArrayList> extensions = new ArrayList>(); + extensions.add(CrowdRealm.class); + extensions.add(CrowdConfiguration.class); + return extensions; + } + } \ No newline at end of file diff --git a/src/main/java/org/sonar/plugins/crowd/CrowdRealm.java b/src/main/java/org/sonar/plugins/crowd/CrowdRealm.java new file mode 100644 index 0000000..84cfc98 --- /dev/null +++ b/src/main/java/org/sonar/plugins/crowd/CrowdRealm.java @@ -0,0 +1,47 @@ +/* + * Sonar Crowd Plugin + * Copyright (C) 2009 SonarSource + * dev@sonar.codehaus.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.plugins.crowd; + +import org.sonar.api.security.LoginPasswordAuthenticator; +import org.sonar.api.security.SecurityRealm; + +public class CrowdRealm extends SecurityRealm { + + private CrowdAuthenticator authenticator; + private final CrowdConfiguration configuration; + + public CrowdRealm(CrowdConfiguration configuration) { + this.configuration = configuration; + } + + public String getName() { + return "Crowd"; + } + + @Override + public void init() { + authenticator = new CrowdAuthenticator(configuration); + } + + @Override + public LoginPasswordAuthenticator getLoginPasswordAuthenticator() { + return authenticator; + } +} \ No newline at end of file