本文整理汇总了Java中org.wso2.carbon.user.core.UserRealm.getAuthorizationManager方法的典型用法代码示例。如果您正苦于以下问题:Java UserRealm.getAuthorizationManager方法的具体用法?Java UserRealm.getAuthorizationManager怎么用?Java UserRealm.getAuthorizationManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.wso2.carbon.user.core.UserRealm
的用法示例。
在下文中一共展示了UserRealm.getAuthorizationManager方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isUserAuthorizedToConfigureProfile
import org.wso2.carbon.user.core.UserRealm; //导入方法依赖的package包/类
private static boolean isUserAuthorizedToConfigureProfile(UserRealm realm, String currentUserName,
String targetUser, String permission)
throws UserStoreException {
boolean isAuthrized = false;
if (currentUserName == null) {
//do nothing
} else if (currentUserName.equals(targetUser)) {
isAuthrized = true;
} else {
AuthorizationManager authorizer = realm.getAuthorizationManager();
isAuthrized = authorizer.isUserAuthorized(currentUserName,
CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION + permission,
"ui.execute");
}
return isAuthrized;
}
示例2: setAnonAuthorization
import org.wso2.carbon.user.core.UserRealm; //导入方法依赖的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: removeAuthorization
import org.wso2.carbon.user.core.UserRealm; //导入方法依赖的package包/类
private void removeAuthorization (UserRealm userRealm, String serviceGroupId,
String serviceName) throws UserStoreException {
AuthorizationManager manager = userRealm.getAuthorizationManager();
String resourceName = serviceGroupId + "/" + serviceName;
String[] roles = manager.
getAllowedRolesForResource(resourceName,
UserCoreConstants.INVOKE_SERVICE_PERMISSION);
if (roles != null) {
for (String role : roles) {
manager.clearRoleAuthorization(role, resourceName,
UserCoreConstants.INVOKE_SERVICE_PERMISSION);
}
}
}
示例4: isUserAuthorizedToConfigureProfile
import org.wso2.carbon.user.core.UserRealm; //导入方法依赖的package包/类
public static boolean isUserAuthorizedToConfigureProfile(UserRealm realm, String currentUserName, String targetUser)
throws UserStoreException {
boolean isAuthrized = false;
if (currentUserName == null) {
//do nothing
} else if (currentUserName.equals(targetUser)) {
isAuthrized = true;
} else {
AuthorizationManager authorizer = realm.getAuthorizationManager();
isAuthrized = authorizer.isUserAuthorized(currentUserName,
CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION + "/manage/identity/usermgt/profiles",
"ui.execute");
}
return isAuthrized;
}
示例5: getAuthorizationManager
import org.wso2.carbon.user.core.UserRealm; //导入方法依赖的package包/类
private AuthorizationManager getAuthorizationManager() throws UserStoreException {
try {
UserRealm realm = super.getUserRealm();
if (realm == null) {
throw new UserStoreException(NULL_REALM_MESSAGE);
}
return realm.getAuthorizationManager();
} catch (Exception e) {
throw new UserStoreException(e);
}
}
示例6: isUserAuthorizedToConfigureProfile
import org.wso2.carbon.user.core.UserRealm; //导入方法依赖的package包/类
public static boolean isUserAuthorizedToConfigureProfile(UserRealm realm, String currentUserName, String targetUser)
throws UserStoreException {
boolean isAuthrized = false;
if (currentUserName == null) {
//do nothing
} else if (currentUserName.equals(targetUser)) {
isAuthrized = true;
} else {
AuthorizationManager authorizer = realm.getAuthorizationManager();
isAuthrized = authorizer.isUserAuthorized(currentUserName,
CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION + "/configure/security/usermgt/profiles",
"ui.execute");
}
return isAuthrized;
}
示例7: isAuthorized
import org.wso2.carbon.user.core.UserRealm; //导入方法依赖的package包/类
public static boolean isAuthorized(UserRegistry userRegistry, String path, String action) {
try {
UserRealm realm = userRegistry.getUserRealm();
if (realm.getAuthorizationManager() != null) {
return realm.getAuthorizationManager().isUserAuthorized(userRegistry.getUserName(), path, action);
}
return false;
} catch (UserStoreException e) {
return false;
}
}
示例8: applySecurityParameters
import org.wso2.carbon.user.core.UserRealm; //导入方法依赖的package包/类
private void applySecurityParameters(AxisService service, SecurityScenario secScenario,
Policy policy) {
try {
UserRealm userRealm = (UserRealm) PrivilegedCarbonContext.getThreadLocalCarbonContext()
.getUserRealm();
UserRegistry govRegistry = (UserRegistry) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getRegistry(RegistryType.SYSTEM_GOVERNANCE);
String serviceGroupId = service.getAxisServiceGroup().getServiceGroupName();
String serviceName = service.getName();
SecurityConfigParams configParams =
SecurityConfigParamBuilder.getSecurityParams(getSecurityConfig(policy));
// Set Trust (Rahas) Parameters
if (secScenario.getModules().contains(SecurityConstants.TRUST_MODULE)) {
AxisModule trustModule = service.getAxisConfiguration()
.getModule(SecurityConstants.TRUST_MODULE);
if (log.isDebugEnabled()) {
log.debug("Enabling trust module : " + SecurityConstants.TRUST_MODULE);
}
service.disengageModule(trustModule);
service.engageModule(trustModule);
Properties cryptoProps = new Properties();
cryptoProps.setProperty(ServerCrypto.PROP_ID_PRIVATE_STORE,
configParams.getPrivateStore());
cryptoProps.setProperty(ServerCrypto.PROP_ID_DEFAULT_ALIAS,
configParams.getKeyAlias());
if (configParams.getTrustStores() != null) {
cryptoProps.setProperty(ServerCrypto.PROP_ID_TRUST_STORES,
configParams.getTrustStores());
}
service.addParameter(RahasUtil.getSCTIssuerConfigParameter(
ServerCrypto.class.getName(), cryptoProps, -1, null, true, true));
service.addParameter(RahasUtil.getTokenCancelerConfigParameter());
}
// Authorization
AuthorizationManager manager = userRealm.getAuthorizationManager();
String resourceName = serviceGroupId + "/" + serviceName;
removeAuthorization(userRealm, serviceGroupId, serviceName);
String allowRolesParameter = configParams.getAllowedRoles();
if (allowRolesParameter != null) {
if (log.isDebugEnabled()) {
log.debug("Authorizing roles " + allowRolesParameter);
}
String[] allowRoles = allowRolesParameter.split(",");
if (allowRoles != null) {
for (String role : allowRoles) {
manager.authorizeRole(role, resourceName,
UserCoreConstants.INVOKE_SERVICE_PERMISSION);
}
}
}
// Password Callback Handler
ServicePasswordCallbackHandler handler =
new ServicePasswordCallbackHandler(configParams, serviceGroupId, serviceName,
govRegistry, userRealm);
Parameter param = new Parameter();
param.setName(WSHandlerConstants.PW_CALLBACK_REF);
param.setValue(handler);
service.addParameter(param);
} catch (Throwable e) {
//TODO: Copied from 4.2.2.
//TODO: Not sure why we are catching throwable. Need to check error handling is correct
String msg = "Cannot apply security parameters";
log.error(msg, e);
}
}
示例9: applySecurityParameters
import org.wso2.carbon.user.core.UserRealm; //导入方法依赖的package包/类
private void applySecurityParameters(AxisService service, SecurityScenario secScenario,
Policy policy) {
try {
UserRealm userRealm = (UserRealm) PrivilegedCarbonContext.getThreadLocalCarbonContext()
.getUserRealm();
UserRegistry govRegistry = (UserRegistry) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getRegistry(RegistryType.SYSTEM_GOVERNANCE);
String serviceGroupId = service.getAxisServiceGroup().getServiceGroupName();
String serviceName = service.getName();
SecurityConfigParams configParams =
SecurityConfigParamBuilder.getSecurityParams(getSecurityConfig(policy));
// Set Trust (Rahas) Parameters
if (secScenario.getModules().contains(SecurityConstants.TRUST_MODULE)) {
AxisModule trustModule = service.getAxisConfiguration()
.getModule(SecurityConstants.TRUST_MODULE);
if (log.isDebugEnabled()) {
log.debug("Enabling trust module : " + SecurityConstants.TRUST_MODULE);
}
service.disengageModule(trustModule);
service.engageModule(trustModule);
Properties cryptoProps = new Properties();
cryptoProps.setProperty(ServerCrypto.PROP_ID_PRIVATE_STORE,
configParams.getPrivateStore());
cryptoProps.setProperty(ServerCrypto.PROP_ID_DEFAULT_ALIAS,
configParams.getKeyAlias());
if (configParams.getTrustStores() != null) {
cryptoProps.setProperty(ServerCrypto.PROP_ID_TRUST_STORES,
configParams.getTrustStores());
}
service.addParameter(RahasUtil.getSCTIssuerConfigParameter(
ServerCrypto.class.getName(), cryptoProps, -1, null, true, true));
service.addParameter(RahasUtil.getTokenCancelerConfigParameter());
}
// Authorization
AuthorizationManager manager = userRealm.getAuthorizationManager();
String resourceName = serviceGroupId + "/" + serviceName;
removeAuthorization(userRealm,serviceGroupId,serviceName);
String allowRolesParameter = configParams.getAllowedRoles();
if (allowRolesParameter != null) {
if (log.isDebugEnabled()) {
log.debug("Authorizing roles " + allowRolesParameter);
}
String[] allowRoles = allowRolesParameter.split(",");
if (allowRoles != null) {
for (String role : allowRoles) {
manager.authorizeRole(role, resourceName,
UserCoreConstants.INVOKE_SERVICE_PERMISSION);
}
}
}
// Password Callback Handler
ServicePasswordCallbackHandler handler =
new ServicePasswordCallbackHandler(configParams, serviceGroupId, serviceName,
govRegistry, userRealm);
Parameter param = new Parameter();
param.setName(WSHandlerConstants.PW_CALLBACK_REF);
param.setValue(handler);
service.addParameter(param);
} catch (Throwable e) {
//TODO: Copied from 4.2.2.
//TODO: Not sure why we are catching throwable. Need to check error handling is correct
String msg = "Cannot apply security parameters";
log.error(msg, e);
}
}