-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
play-cms 2.2: use play-secure 0.5 instead of Play! built-in module "s…
…ecure"
- Loading branch information
Andrei Solntsev, Marek Kusmin
committed
Feb 13, 2017
1 parent
0df6baf
commit 5b93f41
Showing
3 changed files
with
19 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
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: | ||
|
||
- codeborne-modules-jars: | ||
type: http | ||
artifact: https://repo.codeborne.com/play-[module]/[module]-[revision].jar | ||
contains: | ||
- play-codeborne -> secure | ||
- play-codeborne -> rebel |