Search in sources :

Example 6 with ActiveObjectCreationException

use of org.objectweb.proactive.ActiveObjectCreationException in project scheduling by ow2-proactive.

the class SchedulerAuthentication method login.

/**
 * {@inheritDoc}
 */
public Scheduler login(Credentials cred) throws LoginException, AlreadyConnectedException {
    Subject subject = authenticate(cred);
    UserNamePrincipal unPrincipal = subject.getPrincipals(UserNamePrincipal.class).iterator().next();
    String user = unPrincipal.getName();
    logger.info("user : " + user);
    // add this user to the scheduler front-end
    UserIdentificationImpl ident = new UserIdentificationImpl(user, subject);
    ident.setHostName(getSenderHostName());
    this.frontend.connect(PAActiveObject.getContext().getCurrentRequest().getSourceBodyID(), ident, cred);
    try {
        // return the stub on Scheduler interface to keep avoid using server class on client side
        return PAActiveObject.lookupActive(Scheduler.class, PAActiveObject.getUrl(frontend));
    } catch (ActiveObjectCreationException e) {
        rethrowSchedulerStubException(e);
    } catch (IOException e) {
        rethrowSchedulerStubException(e);
    }
    return null;
}
Also used : UserNamePrincipal(org.ow2.proactive.authentication.principals.UserNamePrincipal) IOException(java.io.IOException) Subject(javax.security.auth.Subject) UserIdentificationImpl(org.ow2.proactive.scheduler.job.UserIdentificationImpl) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException)

Example 7 with ActiveObjectCreationException

use of org.objectweb.proactive.ActiveObjectCreationException in project scheduling by ow2-proactive.

the class SchedulerStateRest method publish.

/**
 * Accepts an {@link EventSubscription} instance which specifies the types
 * of SchedulerEvents which interest the client. When such Scheduler event
 * occurs, it will be communicated to the client in the form of
 * {@link EventNotification} utilizing the WebSocket channel initialized
 * previously.
 */
@POST
@Path("/events")
@Produces("application/json")
public EventNotification publish(@Context HttpServletRequest req, EventSubscription subscription) throws NotConnectedRestException, PermissionRestException {
    HttpSession session = req.getSession();
    String broadcasterId = (String) session.getAttribute(ATM_BROADCASTER_ID);
    final SchedulerProxyUserInterface scheduler = checkAccess(broadcasterId);
    SchedulerEventBroadcaster eventListener = new SchedulerEventBroadcaster(broadcasterId);
    try {
        final SchedulerEventBroadcaster activedEventListener = PAActiveObject.turnActive(eventListener);
        scheduler.addEventListener(activedEventListener, subscription.isMyEventsOnly(), EventUtil.toSchedulerEvents(subscription.getEvents()));
        AtmosphereResource atmResource = getAtmosphereResourceFactory().find((String) session.getAttribute(ATM_RESOURCE_ID));
        atmResource.addEventListener(new WebSocketEventListenerAdapter() {

            @Override
            public void onDisconnect(@SuppressWarnings("rawtypes") WebSocketEvent event) {
                try {
                    logger.info("#### websocket disconnected remove listener ####");
                    scheduler.removeEventListener();
                } catch (Exception e) {
                    logger.error(e);
                }
                PAActiveObject.terminateActiveObject(activedEventListener, true);
            }
        });
    } catch (NotConnectedException e) {
        throw new NotConnectedRestException(e);
    } catch (PermissionException e) {
        throw new PermissionRestException(e);
    } catch (ActiveObjectCreationException | NodeException e) {
        throw new RuntimeException(e);
    }
    return new EventNotification(EventNotification.Action.NONE, null, null);
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) EventNotification(org.ow2.proactive_grid_cloud_portal.scheduler.dto.eventing.EventNotification) WebSocketEventListenerAdapter(org.atmosphere.websocket.WebSocketEventListenerAdapter) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) AtmosphereResource(org.atmosphere.cpr.AtmosphereResource) HttpSession(javax.servlet.http.HttpSession) SchedulerProxyUserInterface(org.ow2.proactive.scheduler.common.util.SchedulerProxyUserInterface) NodeException(org.objectweb.proactive.core.node.NodeException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) KeyException(java.security.KeyException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) SchedulerRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.SchedulerRestException) InternalSchedulerException(org.ow2.proactive.scheduler.common.exception.InternalSchedulerException) LogForwardingRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.LogForwardingRestException) NodeException(org.objectweb.proactive.core.node.NodeException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) JobCreationRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.JobCreationRestException) ConnectionException(org.ow2.proactive.scheduler.common.exception.ConnectionException) IOException(java.io.IOException) SchedulerException(org.ow2.proactive.scheduler.common.exception.SchedulerException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) LoginException(javax.security.auth.login.LoginException) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) URISyntaxException(java.net.URISyntaxException) UnknownTaskRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownTaskRestException) LogForwardingException(org.ow2.proactive.scheduler.common.util.logforwarder.LogForwardingException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) UnknownJobRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException) JobAlreadyFinishedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.JobAlreadyFinishedRestException) SubmissionClosedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.SubmissionClosedRestException) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 8 with ActiveObjectCreationException

use of org.objectweb.proactive.ActiveObjectCreationException in project scheduling by ow2-proactive.

the class RMAuthenticationImpl method login.

/**
 * Performs user authentication
 */
public ResourceManager login(Credentials cred) throws LoginException {
    Client client = new Client(authenticate(cred), true);
    client.setCredentials(cred);
    if (RMCore.clients.containsKey(client.getId())) {
        logger.info(client + " reconnected.");
    }
    RMCore.clients.put(client.getId(), client);
    UserHistory history = new UserHistory(client);
    RMDBManager.getInstance().saveUserHistory(history);
    client.setHistory(history);
    logger.info(client + " connected from " + client.getId().shortString());
    try {
        // return the stub on ResourceManager interface to keep avoid using server class on client side
        return PAActiveObject.lookupActive(ResourceManager.class, PAActiveObject.getUrl(rmcore));
    } catch (ActiveObjectCreationException e) {
        rethrowStubException(e);
    } catch (IOException e) {
        rethrowStubException(e);
    }
    return null;
}
Also used : UserHistory(org.ow2.proactive.resourcemanager.core.history.UserHistory) IOException(java.io.IOException) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException)

Aggregations

ActiveObjectCreationException (org.objectweb.proactive.ActiveObjectCreationException)8 IOException (java.io.IOException)5 NodeException (org.objectweb.proactive.core.node.NodeException)5 LoginException (javax.security.auth.login.LoginException)3 HttpSession (javax.servlet.http.HttpSession)3 POST (javax.ws.rs.POST)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 InternalSchedulerException (org.ow2.proactive.scheduler.common.exception.InternalSchedulerException)3 SchedulerException (org.ow2.proactive.scheduler.common.exception.SchedulerException)3 SchedulerRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.SchedulerRestException)3 Consumes (javax.ws.rs.Consumes)2 CredData (org.ow2.proactive.authentication.crypto.CredData)2 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)2 Session (org.ow2.proactive_grid_cloud_portal.common.Session)2 InetAddress (java.net.InetAddress)1 URISyntaxException (java.net.URISyntaxException)1 KeyException (java.security.KeyException)1 LinkedList (java.util.LinkedList)1 Subject (javax.security.auth.Subject)1