1 46 47 package org.mr.kernel.security.authorization.permissions; 48 49 import org.mr.MantaAgent; 50 import org.mr.kernel.security.SecurityConfigurationPaths; 51 52 import java.security.Permission ; 53 54 import org.mr.kernel.security.MantaSecurityException; 55 import org.apache.commons.logging.Log; 56 import org.apache.commons.logging.LogFactory; 57 58 66 public abstract class MantaPermission extends Permission implements SecurityConfigurationPaths { 67 private Log _logger; 68 69 public MantaPermission(String name) { 70 super(name); 71 } 72 73 80 public Object getPermissionPathForUser() throws MantaSecurityException { 81 String currentACLConfigurationInUse = MantaAgent.getInstance().getSingletonRepository().getConfigManager().getStringProperty(ACL + "." + ACL_CONFIGURATION_IN_USE); 82 if (currentACLConfigurationInUse == null){ 83 if (getLogger().isErrorEnabled()) 84 getLogger().error("[getPermissionPathForUser] Unable to find configuration parameter: " + ACL + "." + ACL_CONFIGURATION_IN_USE); 85 throw new MantaSecurityException("Unable to find configuration parameter: " + ACL + "." + ACL_CONFIGURATION_IN_USE); 86 } 87 88 String path = MantaAgent.getInstance().getSingletonRepository().getConfigManager().getStringProperty(ACL_CONFIGURATIONS + "." + currentACLConfigurationInUse + "." + PERMISSION_PATHS + "." + getName() + "." + USER); 89 if (path == null){ 90 if (getLogger().isWarnEnabled()) 91 getLogger().warn("[getPermissionPathForUser] Unable to find configuration parameter: " + ACL_CONFIGURATIONS + "." + currentACLConfigurationInUse + "." + PERMISSION_PATHS + "." + getName() + "." + USER); 92 throw new MantaSecurityException("Unable to find configuration parameter: " + ACL_CONFIGURATIONS + "." + currentACLConfigurationInUse + "." + PERMISSION_PATHS + "." + getName() + "." + USER); 93 } 94 return path; 95 } 96 97 104 public Object getPermissionPathForGroup() throws MantaSecurityException { 105 String currentACLConfigurationInUse = MantaAgent.getInstance().getSingletonRepository().getConfigManager().getStringProperty(ACL + "." + ACL_CONFIGURATION_IN_USE); 106 if (currentACLConfigurationInUse == null){ 107 if (getLogger().isErrorEnabled()) 108 getLogger().error("[getPermissionPathForGroup] Unable to find configuration parameter: " + ACL + "." + ACL_CONFIGURATION_IN_USE); 109 throw new MantaSecurityException("Unable to find configuration parameter: " + ACL + "." + ACL_CONFIGURATION_IN_USE); 110 } 111 112 String path = MantaAgent.getInstance().getSingletonRepository().getConfigManager().getStringProperty(ACL_CONFIGURATIONS + "." + currentACLConfigurationInUse + "." + PERMISSION_PATHS + "." + getName() + "." + GROUP); 113 if (path == null){ 114 if (getLogger().isWarnEnabled()) 115 getLogger().warn("[getPermissionPathForGroup] Unable to find configuration parameter: " + ACL_CONFIGURATIONS + "." + currentACLConfigurationInUse + "." + PERMISSION_PATHS + "." + getName() + "." + GROUP); 116 throw new MantaSecurityException("Unable to find configuration parameter: " + ACL_CONFIGURATIONS + "." + currentACLConfigurationInUse + "." + PERMISSION_PATHS + "." + getName() + "." + GROUP); 117 } 118 return path; 119 } 120 121 public boolean implies(Permission permission){ 122 return equals(permission); 123 } 124 125 public boolean equals(Object obj){ 126 if (!(obj instanceof MantaPermission)) 127 return false; 128 MantaPermission other = (MantaPermission) obj; 129 return (getName().equals(other.getName())); 130 } 131 132 public int hashCode(){ 133 return getName().hashCode(); 134 } 135 136 public String toString(){ 137 return getName(); 138 } 139 140 public String getActions(){ 141 return null; 142 } 143 144 public Log getLogger(){ 145 if (_logger == null){ 146 _logger = LogFactory.getLog(getClass().getName()); 147 } 148 return _logger; 149 } 150 } 151 | Popular Tags |