Search in sources :

Example 1 with TerminateSessionEvent

use of com.evolveum.midpoint.TerminateSessionEvent in project midpoint by Evolveum.

the class InternalsLoggedInUsersPanel method terminateSessions.

private void terminateSessions(AjaxRequestTarget target, F selectedObject) {
    List<String> selected = getSelectedObjects(selectedObject);
    if (CollectionUtils.isEmpty(selected)) {
        getSession().warn(getString("InternalsLoggedInUsersPanel.expireSession.warn"));
        target.add(getPageBase().getFeedbackPanel());
        return;
    }
    Task task = getPageBase().createSimpleTask(OPERATION_TERMINATE_SESSIONS);
    TerminateSessionEvent details = new TerminateSessionEvent();
    details.setPrincipalOids(selected);
    getPageBase().getModelInteractionService().terminateSessions(details, task, task.getResult());
    getSession().success(getString("InternalsLoggedInUsersPanel.expireSession.success"));
    target.add(getPageBase().getFeedbackPanel());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) TerminateSessionEvent(com.evolveum.midpoint.TerminateSessionEvent)

Example 2 with TerminateSessionEvent

use of com.evolveum.midpoint.TerminateSessionEvent in project midpoint by Evolveum.

the class TestAbstractAuthenticationEvaluator method initSystem.

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
    super.initSystem(initTask, initResult);
    modelService.postInit(initResult);
    // System Configuration
    try {
        repoAddObjectFromFile(SYSTEM_CONFIGURATION_FILE, initResult);
    } catch (ObjectAlreadyExistsException e) {
        throw new ObjectAlreadyExistsException("System configuration already exists in repository;" + "looks like the previous test haven't cleaned it up", e);
    }
    repoAddObjectFromFile(SECURITY_POLICY_FILE, initResult);
    // Administrator
    repoAddObjectFromFile(ROLE_SUPERUSER_FILE, initResult);
    PrismObject<UserType> userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, initResult);
    login(userAdministrator);
    // Users
    repoAddObjectFromFile(USER_JACK_FILE, UserType.class, initResult).asObjectable();
    repoAddObjectFromFile(USER_GUYBRUSH_FILE, UserType.class, initResult).asObjectable();
    messages = new MessageSourceAccessor(messageSource);
    ((AuthenticationEvaluatorImpl) getAuthenticationEvaluator()).setPrincipalManager(new GuiProfiledPrincipalManager() {

        @Override
        public <F extends FocusType, O extends ObjectType> PrismObject<F> resolveOwner(PrismObject<O> object) throws CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
            return focusProfileService.resolveOwner(object);
        }

        @Override
        public void updateFocus(MidPointPrincipal principal, Collection<? extends ItemDelta<?, ?>> itemDeltas) {
            focusProfileService.updateFocus(principal, itemDeltas);
        }

        @Override
        public GuiProfiledPrincipal getPrincipal(PrismObject<? extends FocusType> user) throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
            return getPrincipal(user, null, null);
        }

        @Override
        public GuiProfiledPrincipal getPrincipal(PrismObject<? extends FocusType> user, AuthorizationTransformer authorizationLimiter, OperationResult result) throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
            GuiProfiledPrincipal principal = focusProfileService.getPrincipal(user);
            addFakeAuthorization(principal);
            return principal;
        }

        @Override
        public GuiProfiledPrincipal getPrincipal(String username, Class<? extends FocusType> clazz) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
            GuiProfiledPrincipal principal = focusProfileService.getPrincipal(username, clazz);
            addFakeAuthorization(principal);
            return principal;
        }

        @Override
        public GuiProfiledPrincipal getPrincipalByOid(String oid, Class<? extends FocusType> clazz) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
            GuiProfiledPrincipal principal = focusProfileService.getPrincipalByOid(oid, clazz);
            addFakeAuthorization(principal);
            return principal;
        }

        // TODO test maybe later?
        @Override
        public List<UserSessionManagementType> getLocalLoggedInPrincipals() {
            return null;
        }

        @Override
        public void terminateLocalSessions(TerminateSessionEvent terminateSessionEvent) {
        // TOTO test it
        }
    });
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismObject(com.evolveum.midpoint.prism.PrismObject) MessageSourceAccessor(org.springframework.context.support.MessageSourceAccessor) GuiProfiledPrincipal(com.evolveum.midpoint.model.api.authentication.GuiProfiledPrincipal) AuthenticationEvaluatorImpl(com.evolveum.midpoint.authentication.impl.evaluator.AuthenticationEvaluatorImpl) List(java.util.List) TerminateSessionEvent(com.evolveum.midpoint.TerminateSessionEvent) GuiProfiledPrincipalManager(com.evolveum.midpoint.model.api.authentication.GuiProfiledPrincipalManager)

Aggregations

TerminateSessionEvent (com.evolveum.midpoint.TerminateSessionEvent)2 AuthenticationEvaluatorImpl (com.evolveum.midpoint.authentication.impl.evaluator.AuthenticationEvaluatorImpl)1 GuiProfiledPrincipal (com.evolveum.midpoint.model.api.authentication.GuiProfiledPrincipal)1 GuiProfiledPrincipalManager (com.evolveum.midpoint.model.api.authentication.GuiProfiledPrincipalManager)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1 List (java.util.List)1 MessageSourceAccessor (org.springframework.context.support.MessageSourceAccessor)1