This is an automated email from the git hooks/post-receive script. New commit to branch feature/7463-2 in repository observe. See http://git.codelutin.com/observe.git commit 5d9167940e446094be9c2a557f237209651b2674 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Sep 6 23:02:53 2015 +0200 Ajout de nouvelles méthodes d'administration pour voir (et supprimer) les jetons d'authenfication --- .../web/controller/v1/ConfigurationController.java | 39 ++++++++++++++++++++++ .../controller/v1/DataSourceServiceController.java | 4 +-- .../ObserveWebSecurityApplicationContext.java | 4 +++ ...ObserveWebSecurityAuthenticationTokenCache.java | 4 +++ 4 files changed, 49 insertions(+), 2 deletions(-) diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/ConfigurationController.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/ConfigurationController.java index 7803048..ca4815e 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/ConfigurationController.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/ConfigurationController.java @@ -1,10 +1,13 @@ package fr.ird.observe.application.web.controller.v1; +import com.google.common.collect.ImmutableMap; import fr.ird.observe.application.web.configuration.db.ObserveWebDatabases; import fr.ird.observe.application.web.configuration.db.ObserveWebDatabasesHelper; import fr.ird.observe.application.web.configuration.user.ObserveWebUsers; import fr.ird.observe.application.web.configuration.user.ObserveWebUsersHelper; import fr.ird.observe.application.web.controller.ObserveWebMotionController; +import fr.ird.observe.application.web.security.ObserveWebSecurityApplicationContext; +import fr.ird.observe.services.configuration.ObserveDataSourceConfiguration; import org.apache.commons.io.IOUtils; import org.debux.webmotion.server.WebMotionContextable; import org.debux.webmotion.server.render.Render; @@ -12,6 +15,7 @@ import org.debux.webmotion.server.render.Render; import java.io.IOException; import java.io.InputStream; import java.io.StringWriter; +import java.util.Map; /** * Created on 8/30/15. @@ -84,5 +88,40 @@ public class ConfigurationController extends ObserveWebMotionController { } + public Render showAuthenticationTokens() { + + ObserveWebSecurityApplicationContext securityApplicationContext = getSecurityApplicationContext(); + + StringBuilder builder = new StringBuilder(); + ImmutableMap<String, ObserveDataSourceConfiguration> cache = securityApplicationContext.getAuthenticationTokensCache(); + + builder.append("Number of authentication tokens: ").append(cache.size()); + for (Map.Entry<String, ObserveDataSourceConfiguration> entry : cache.entrySet()) { + builder.append("\n").append(entry.getKey()).append(" - ").append(entry.getValue()); + } + return renderContent(builder.toString(), "text/plain"); + + } + + public Render resetAuthenticationTokens() { + + ObserveWebSecurityApplicationContext securityApplicationContext = getSecurityApplicationContext(); + + StringBuilder builder = new StringBuilder(); + ImmutableMap<String, ObserveDataSourceConfiguration> authenticationTokensCache = securityApplicationContext.getAuthenticationTokensCache(); + + builder.append("Number of authentication tokens to reset: ").append(authenticationTokensCache.size()); + for (Map.Entry<String, ObserveDataSourceConfiguration> entry : authenticationTokensCache.entrySet()) { + builder.append("\n").append(entry.getKey()).append(" - ").append(entry.getValue()); + } + + for (String authenticationToken : authenticationTokensCache.keySet()) { + securityApplicationContext.invalidateAuthenticationToken(authenticationToken); + } + + return renderContent(builder.toString(), "text/plain"); + + } + } diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/DataSourceServiceController.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/DataSourceServiceController.java index b8eb0c5..047c840 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/DataSourceServiceController.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/DataSourceServiceController.java @@ -28,8 +28,8 @@ public class DataSourceServiceController extends ObserveServiceControllerSupport } @Override - public void canConnect(ObserveDataSourceConfiguration dataSourceConfiguration) throws DatabaseConnexionNotAuthorizedException, DatabaseNotFoundException { - service.canConnect(dataSourceConfiguration); + public void checkCanConnect(ObserveDataSourceConfiguration dataSourceConfiguration) throws DatabaseConnexionNotAuthorizedException, DatabaseNotFoundException { + service.checkCanConnect(dataSourceConfiguration); } @Override diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/security/ObserveWebSecurityApplicationContext.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/security/ObserveWebSecurityApplicationContext.java index 5210310..f07d941 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/security/ObserveWebSecurityApplicationContext.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/security/ObserveWebSecurityApplicationContext.java @@ -203,6 +203,10 @@ public class ObserveWebSecurityApplicationContext implements Closeable { authenticateCache.removeAuthenticationToken(authenticationToken); } + public ImmutableMap<String, ObserveDataSourceConfiguration> getAuthenticationTokensCache() { + return ImmutableMap.copyOf(authenticateCache.getAuthenticationTokenCache().asMap()); + } + @Override public void close() { authenticateCache.close(); diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/security/ObserveWebSecurityAuthenticationTokenCache.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/security/ObserveWebSecurityAuthenticationTokenCache.java index c2edd9f..23c237e 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/security/ObserveWebSecurityAuthenticationTokenCache.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/security/ObserveWebSecurityAuthenticationTokenCache.java @@ -74,6 +74,10 @@ public class ObserveWebSecurityAuthenticationTokenCache implements Closeable { authenticationTokenCache.invalidateAll(); } + public Cache<String, ObserveDataSourceConfiguration> getAuthenticationTokenCache() { + return authenticationTokenCache; + } + @Override public void close() { removeAllAuthenticationTokens(); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.