-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This class helps to make some AccessPermissions into Frameworks. To make D2W more powerful.
- Loading branch information
Showing
2 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
Frameworks/Core/ERExtensions/Sources/er/extensions/security/ERXAccessPermission.java
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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package er.extensions.security; | ||
|
||
import org.apache.log4j.Logger; | ||
|
||
/** | ||
* AccessPermission | ||
* | ||
* This class makes it easy to create AccessPermission into Frameworks. | ||
* | ||
* The User can implement IERXAccessPermissionInterface and Delegate | ||
* and then do what he like. | ||
* | ||
* @author ishimoto | ||
* | ||
*/ | ||
public class ERXAccessPermission implements IERXAccessPermissionInterface { | ||
|
||
private static final Logger log = Logger.getLogger(ERXAccessPermission.class); | ||
|
||
//******************************************************************** | ||
// Singleton | ||
//******************************************************************** | ||
|
||
public static ERXAccessPermission instance() { | ||
return instance; | ||
} | ||
private static final ERXAccessPermission instance = new ERXAccessPermission(); | ||
|
||
private ERXAccessPermission() {} | ||
|
||
//******************************************************************** | ||
// Delegate | ||
//******************************************************************** | ||
|
||
public void setDelegate(IERXAccessPermissionInterface delegate) { | ||
this.delegate = delegate; | ||
} | ||
public IERXAccessPermissionInterface delegate() { | ||
return delegate; | ||
} | ||
private IERXAccessPermissionInterface delegate = null; | ||
|
||
//******************************************************************** | ||
// AccessPermission | ||
//******************************************************************** | ||
|
||
public boolean can(String key) { | ||
return canWithDefault(key, false); | ||
} | ||
|
||
|
||
public boolean canWithDefault(String key, boolean defaultValue) { | ||
if(delegate() != null) { | ||
return delegate().canWithDefault(key, defaultValue); | ||
} | ||
|
||
log.warn("No Delegate is set. Result for '" + key + "' is false."); | ||
return false; | ||
} | ||
|
||
public boolean isDeveloper() { | ||
if(delegate() != null) { | ||
return delegate().isDeveloper(); | ||
} | ||
|
||
log.warn("No Delegate is set. Result for 'isDeveloper' is false."); | ||
return false; | ||
} | ||
|
||
public boolean isAdministrator() { | ||
if(delegate() != null) { | ||
return delegate().isAdministrator(); | ||
} | ||
|
||
log.warn("No Delegate is set. Result for 'isAdministrator' is false."); | ||
return false; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...works/Core/ERExtensions/Sources/er/extensions/security/IERXAccessPermissionInterface.java
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package er.extensions.security; | ||
|
||
/** | ||
* <span class="ja"> | ||
* このクラスはアクセス権限に使用します | ||
* </span> | ||
* | ||
* @author ishimoto | ||
* | ||
*/ | ||
public interface IERXAccessPermissionInterface { | ||
|
||
public boolean can(String key); | ||
|
||
public boolean canWithDefault(String key, boolean defaultValue); | ||
|
||
public boolean isDeveloper(); | ||
|
||
public boolean isAdministrator(); | ||
|
||
} |