本文整理汇总了Java中org.wso2.carbon.registry.core.utils.AccessControlConstants类的典型用法代码示例。如果您正苦于以下问题:Java AccessControlConstants类的具体用法?Java AccessControlConstants怎么用?Java AccessControlConstants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AccessControlConstants类属于org.wso2.carbon.registry.core.utils包,在下文中一共展示了AccessControlConstants类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isAuthorizeAllowed
import org.wso2.carbon.registry.core.utils.AccessControlConstants; //导入依赖的package包/类
public static boolean isAuthorizeAllowed(
String userName, String resourcePath, UserRegistry userRegistry)
throws RegistryException {
boolean putAllowed = false;
UserRealm userRealm = userRegistry.getUserRealm();
try {
if (userRealm.getAuthorizationManager().isUserAuthorized(
userName, resourcePath, AccessControlConstants.AUTHORIZE)) {
putAllowed = true;
}
} catch (UserStoreException e) {
String msg = "Could not the permission details for the user: " + userName +
" for the resource: " + resourcePath + ". Caused by: " + e.getMessage();
throw new RegistryException(msg);
}
return putAllowed;
}
示例2: setAnonAuthorization
import org.wso2.carbon.registry.core.utils.AccessControlConstants; //导入依赖的package包/类
public static void setAnonAuthorization(String path, UserRealm userRealm)
throws RegistryException {
if (userRealm == null) {
return;
}
try {
AuthorizationManager accessControlAdmin = userRealm.getAuthorizationManager();
String everyoneRole = CarbonConstants.REGISTRY_ANONNYMOUS_ROLE_NAME;
accessControlAdmin.authorizeRole(everyoneRole, path, ActionConstants.GET);
accessControlAdmin.denyRole(everyoneRole, path, ActionConstants.PUT);
accessControlAdmin.denyRole(everyoneRole, path, ActionConstants.DELETE);
accessControlAdmin.denyRole(everyoneRole, path, AccessControlConstants.AUTHORIZE);
} catch (UserStoreException e) {
String msg = "Could not set authorizations for the " + path + ".";
log.error(msg, e);
throw new RegistryException(msg);
}
}
示例3: testIsAuthorizeAllowed
import org.wso2.carbon.registry.core.utils.AccessControlConstants; //导入依赖的package包/类
public void testIsAuthorizeAllowed() throws Exception {
String resourcePath = "/_system/governance/trunk";
String userName = "admin";
UserRegistry userRegistry = mock(UserRegistry.class);
UserRealm userRealm = mock(UserRealm.class);
AuthorizationManager authorizationManager = mock(AuthorizationManager.class);
when(userRegistry.getUserRealm()).thenReturn(userRealm);
when(userRealm.getAuthorizationManager()).thenReturn(authorizationManager);
when(userRealm.getAuthorizationManager()
.isUserAuthorized(userName, resourcePath, AccessControlConstants.AUTHORIZE))
.thenReturn(true);
assertTrue(UserUtil.isAuthorizeAllowed(userName, resourcePath, userRegistry));
}