2015-08-24 07:58:52 +00:00
/ *
* Copyright 2013 Brian Rosenberger ( Brutex Network )
*
* Licensed under the Apache License , Version 2 . 0 ( the " License " ) ;
* you may not use this file except in compliance with the License .
* You may obtain a copy of the License at
*
* http : //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing , software
* distributed under the License is distributed on an " AS IS " BASIS ,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
* See the License for the specific language governing permissions and
* limitations under the License .
* /
package net.brutex.xservices.security ;
2023-09-19 12:50:19 +00:00
import lombok.extern.slf4j.Slf4j ;
2015-08-24 07:58:52 +00:00
import org.apache.shiro.authz.Permission ;
/ * *
* @author Brian Rosenberger , bru ( at ) brutex . de
*
* /
2023-09-19 12:50:19 +00:00
@Slf4j
2015-08-24 07:58:52 +00:00
public class XmlServicePermission implements Permission {
private final String permissionString ;
public XmlServicePermission ( String permissionString ) {
2023-09-19 12:50:19 +00:00
log . debug ( String . format ( " Creating permission for '{}' " , permissionString ) ) ;
2015-08-24 07:58:52 +00:00
this . permissionString = permissionString ;
}
@Override
public boolean implies ( Permission p ) {
boolean result = false ;
/* is of same type */
if ( ! ( p instanceof XmlServicePermission ) ) {
2023-09-19 12:50:19 +00:00
log . debug ( String . format ( " Testing if permission of type '{}' implies permission of type '{}'. Result was '{}' " , this . getClass ( ) , p . getClass ( ) , result ) ) ;
2015-08-24 07:58:52 +00:00
return result ;
}
/* comparing to non null directory */
if ( ( ( XmlServicePermission ) p ) . getPermissionString ( ) = = null ) {
2023-09-19 12:50:19 +00:00
log . debug ( String . format ( " Testing if DirectoryPermission '{}' implies permission to 'null'. Result was '{}' " , permissionString , result ) ) ;
2015-08-24 07:58:52 +00:00
return result ;
}
/* directory pattern implies other */
//TODO
/ * if ( ( new AntPathMatcher ( ) ) . matches ( permissionString , ( ( XmlServicePermission ) p ) . getPermissionString ( ) ) ) ) {
result = true ;
}
logger . debug ( String . format ( " Testing if DirectoryPermission '%s' implies permission to '%s'. Result was '%s' " , permissionString , ( ( XmlServicePermission ) p ) . getPermissionString ( ) , result ) ) ;
* /
return result ;
}
public String getPermissionString ( ) {
return permissionString ;
}
}