From 5b93f41335f57c452090d3aa3a8be93f89ec9e4c Mon Sep 17 00:00:00 2001 From: "Andrei Solntsev, Marek Kusmin" Date: Mon, 13 Feb 2017 11:50:49 +0200 Subject: [PATCH] play-cms 2.2: use play-secure 0.5 instead of Play! built-in module "secure" --- CHANGELOG | 3 +++ app/controllers/cms/Profiler.java | 37 +++++++++---------------------- conf/dependencies.yml | 8 ++++--- 3 files changed, 19 insertions(+), 29 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4fd448e..13ab31b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ == Changelog +=== 2.2 (13.02.2017) +* use play-secure 0.5 instead of Play! built-in module "secure" + === 2.1 (21.01.2017) * use play-rebel 0.6, extend RebelController diff --git a/app/controllers/cms/Profiler.java b/app/controllers/cms/Profiler.java index 961e1be..ed6de9c 100644 --- a/app/controllers/cms/Profiler.java +++ b/app/controllers/cms/Profiler.java @@ -1,43 +1,28 @@ package controllers.cms; -import controllers.Secure.Security; -import play.Logger; import play.Play; +import play.classloading.enhancers.ControllersEnhancer.ControllerSupport; import play.mvc.Scope.Session; -import play.utils.Java; +import play.security.AuthorizationService; + +import javax.inject.Inject; + +public class Profiler implements ControllerSupport { + @Inject static AuthorizationService authorizationService; -public class Profiler { public static boolean canEdit(String pageName) { if (Session.current().get("username") == null) return false; + String profile = Play.configuration.getProperty("cms.profile", "admin"); - boolean result; - try { - result = (Boolean) invoke(Security.class, "check", profile); - return result; - } - catch (Throwable e) { - Logger.error(e, "While checking cms profile"); - return false; - } + return authorizationService.check(profile); } public static boolean canEnter() { if (Session.current().get("username") == null) return false; - String profile = Play.configuration.getProperty("cms.profile", "admin"); - boolean result; - try { - result = (Boolean) invoke(Security.class, "check", profile); - return result; - } - catch (Throwable e) { - Logger.error(e, "While checking cms profile"); - return false; - } - } - private static Object invoke(Class original, String m, Object... args) throws Throwable { - return Java.invokeChildOrStatic(original, m, args); + String profile = Play.configuration.getProperty("cms.profile", "admin"); + return authorizationService.check(profile); } } diff --git a/conf/dependencies.yml b/conf/dependencies.yml index 7f2d64d..c48ecf5 100644 --- a/conf/dependencies.yml +++ b/conf/dependencies.yml @@ -1,9 +1,10 @@ -self: play -> cms 2.1 +self: play -> cms 2.2 require: - play [1.2,1.4] - - play -> secure - - play-codeborne -> rebel 0.6 + + - play-codeborne -> secure 0.5 + - play-codeborne -> rebel 0.6.5 repositories: @@ -11,4 +12,5 @@ repositories: type: http artifact: https://repo.codeborne.com/play-[module]/[module]-[revision].jar contains: + - play-codeborne -> secure - play-codeborne -> rebel