* @return
*/
private boolean checkPermission( String permission )
{
WikiSession session = m_wikiContext.getWikiSession();
WikiPage page = m_wikiContext.getPage();
AuthorizationManager mgr = m_wikiContext.getEngine().getAuthorizationManager();
boolean gotPermission = false;
if ( CREATE_GROUPS.equals( permission ) || CREATE_PAGES.equals( permission )
|| EDIT_PREFERENCES.equals( permission ) || EDIT_PROFILE.equals( permission )
|| LOGIN.equals( permission ) )
{
gotPermission = mgr.checkPermission( session, new WikiPermission( page.getWiki(), permission ) );
}
else if ( VIEW_GROUP.equals( permission )
|| EDIT_GROUP.equals( permission )
|| DELETE_GROUP.equals( permission ) )
{
Command command = m_wikiContext.getCommand();
gotPermission = false;
if ( command instanceof GroupCommand && command.getTarget() != null )
{
GroupPrincipal group = (GroupPrincipal)command.getTarget();
String groupName = group.getName();
String action = "view";
if( EDIT_GROUP.equals( permission ) )
{
action = "edit";
}
else if ( DELETE_GROUP.equals( permission ) )
{
action = "delete";
}
gotPermission = mgr.checkPermission( session, new GroupPermission( groupName, action ) );
}
}
else if ( ALL_PERMISSION.equals( permission ) )
{
gotPermission = mgr.checkPermission( session, new AllPermission( m_wikiContext.getEngine().getApplicationName() ) );
}
else if ( page != null )
{
//
// Edit tag also checks that we're not trying to edit an
// old version: they cannot be edited.
//
if( EDIT.equals(permission) )
{
WikiPage latest = m_wikiContext.getEngine().getPage( page.getName() );
if( page.getVersion() != WikiProvider.LATEST_VERSION &&
latest.getVersion() != page.getVersion() )
{
return false;
}
}