Search in sources :

Example 1 with MethodCallPermission

use of org.ow2.proactive.permissions.MethodCallPermission in project scheduling by ow2-proactive.

the class SchedulerFrontendState method checkPermissionReturningListeningUser.

synchronized ListeningUser checkPermissionReturningListeningUser(String methodName, String permissionMsg) throws NotConnectedException, PermissionException {
    UniqueID id = checkAccess();
    ListeningUser ident = identifications.get(id);
    // renew session for this user
    renewUserSession(id, ident.getUser());
    final String fullMethodName = SchedulerFrontend.class.getName() + "." + methodName;
    final MethodCallPermission methodCallPermission = new MethodCallPermission(fullMethodName);
    try {
        ident.getUser().checkPermission(methodCallPermission, permissionMsg);
    } catch (PermissionException ex) {
        logger.warn(permissionMsg);
        throw ex;
    }
    return ident;
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) UniqueID(org.objectweb.proactive.core.UniqueID) MethodCallPermission(org.ow2.proactive.permissions.MethodCallPermission)

Example 2 with MethodCallPermission

use of org.ow2.proactive.permissions.MethodCallPermission in project scheduling by ow2-proactive.

the class RMCore method checkMethodCallPermission.

/**
 * Checks if the caller thread has permissions to call particular method name
 *
 * @return client object corresponding to the caller thread
 */
private Client checkMethodCallPermission(final String methodName, UniqueID clientId) {
    Client client = RMCore.clients.get(clientId);
    if (client == null) {
        // Check if the client id is a local body or half body
        LocalBodyStore lbs = LocalBodyStore.getInstance();
        if (lbs.getLocalBody(clientId) != null || lbs.getLocalHalfBody(clientId) != null) {
            return RMCore.localClient;
        }
        throw new NotConnectedException("Client " + clientId.shortString() + " is not connected to the resource manager");
    }
    final String fullMethodName = RMCore.class.getName() + "." + methodName;
    final MethodCallPermission methodCallPermission = new MethodCallPermission(fullMethodName);
    client.checkPermission(methodCallPermission, client + " is not authorized to call " + fullMethodName);
    return client;
}
Also used : LocalBodyStore(org.objectweb.proactive.core.body.LocalBodyStore) MethodCallPermission(org.ow2.proactive.permissions.MethodCallPermission) NotConnectedException(org.ow2.proactive.resourcemanager.exception.NotConnectedException) Client(org.ow2.proactive.resourcemanager.authentication.Client)

Aggregations

MethodCallPermission (org.ow2.proactive.permissions.MethodCallPermission)2 UniqueID (org.objectweb.proactive.core.UniqueID)1 LocalBodyStore (org.objectweb.proactive.core.body.LocalBodyStore)1 Client (org.ow2.proactive.resourcemanager.authentication.Client)1 NotConnectedException (org.ow2.proactive.resourcemanager.exception.NotConnectedException)1 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)1