Search in sources :

Example 51 with StringValue

use of org.apache.wicket.util.string.StringValue in project midpoint by Evolveum.

the class ObjectPolicyConfigurationTabPanel method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    PageParameters params = getPage().getPageParameters();
    StringValue val = params.get(PageSystemConfiguration.SELECTED_TAB_INDEX);
    if (val != null && !val.isNull()) {
        params.remove(params.getPosition(PageSystemConfiguration.SELECTED_TAB_INDEX));
    }
    params.set(PageSystemConfiguration.SELECTED_TAB_INDEX, PageSystemConfiguration.CONFIGURATION_TAB_OBJECT_POLICY);
    initLayout();
}
Also used : PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) StringValue(org.apache.wicket.util.string.StringValue)

Example 52 with StringValue

use of org.apache.wicket.util.string.StringValue in project midpoint by Evolveum.

the class ObjectListPanel method getSearchByNameParameterValue.

protected String getSearchByNameParameterValue() {
    PageParameters parameters = getPageBase().getPageParameters();
    if (parameters == null) {
        return null;
    }
    StringValue value = parameters.get(PageBase.PARAMETER_SEARCH_BY_NAME);
    if (value == null) {
        return null;
    }
    return value.toString();
}
Also used : PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) StringValue(org.apache.wicket.util.string.StringValue)

Example 53 with StringValue

use of org.apache.wicket.util.string.StringValue in project midpoint by Evolveum.

the class PageResetPasswordConfirmation method init.

private void init(final PageParameters pageParameters) {
    PageParameters params = pageParameters;
    if (params == null) {
        params = getPageParameters();
    }
    OperationResult result = new OperationResult(OPERATION_FINISH_REGISTRATION);
    if (params == null) {
        LOGGER.error("Confirmation link is not valid. No credentials provided in it");
        String msg = createStringResource("PageSelfRegistration.invalid.registration.link").getString();
        getSession().error(createStringResource(msg));
        result.recordFatalError(msg);
        initLayout(result);
        return;
    }
    StringValue userNameValue = params.get(SchemaConstants.USER_ID);
    Validate.notEmpty(userNameValue.toString());
    StringValue tokenValue = params.get(SchemaConstants.TOKEN);
    Validate.notEmpty(tokenValue.toString());
    UsernamePasswordAuthenticationToken token = authenticateUser(userNameValue.toString(), tokenValue.toString(), result);
    if (token == null) {
        initLayout(result);
        return;
    } else {
        // SecurityContextHolder.getContext().setAuthentication(token);
        MidPointPrincipal principal = (MidPointPrincipal) token.getPrincipal();
        Collection<Authorization> authz = principal.getAuthorities();
        if (authz != null) {
            for (Authorization authzI : authz) {
                authzI.getAction().removeIf(action -> action.contains(AuthorizationConstants.NS_AUTHORIZATION_UI));
            }
        }
        AuthorizationType authorizationType = new AuthorizationType();
        authorizationType.getAction().add(AuthorizationConstants.AUTZ_UI_SELF_CREDENTIALS_URL);
        Authorization selfServiceCredentialsAuthz = new Authorization(authorizationType);
        authz.add(selfServiceCredentialsAuthz);
        AuthenticationSequenceType sequence = SecurityPolicyUtil.createPasswordResetSequence();
        Map<Class<?>, Object> sharedObjects = new HashMap<>();
        AuthenticationModulesType modules = new AuthenticationModulesType();
        LoginFormAuthenticationModuleType loginForm = new LoginFormAuthenticationModuleType();
        loginForm.name(SecurityPolicyUtil.DEFAULT_MODULE_NAME);
        modules.loginForm(loginForm);
        AuthModule authModule = null;
        AuthenticationChannel channel = null;
        try {
            channel = channelFactory.createAuthChannel(sequence.getChannel());
            authModule = moduleFactory.createModuleFilter(loginForm, sequence.getChannel().getUrlSuffix(), null, sharedObjects, modules, null, channel);
        } catch (Exception e) {
            LOGGER.error("Couldn't build filter for module moduleFactory", e);
        }
        MidpointAuthentication mpAuthentication = new MidpointAuthentication(sequence);
        List<AuthModule> authModules = new ArrayList<>();
        authModules.add(authModule);
        mpAuthentication.setAuthModules(authModules);
        mpAuthentication.setSessionId(Session.get().getId());
        ModuleAuthentication moduleAuthentication = authModule.getBaseModuleAuthentication();
        moduleAuthentication.setAuthentication(token);
        moduleAuthentication.setState(AuthenticationModuleState.SUCCESSFULLY);
        mpAuthentication.addAuthentications(moduleAuthentication);
        mpAuthentication.setPrincipal(principal);
        mpAuthentication.setAuthorities(token.getAuthorities());
        mpAuthentication.setAuthenticationChannel(channel);
        SecurityContextHolder.getContext().setAuthentication(mpAuthentication);
        setResponsePage(PageResetPassword.class);
    }
    initLayout(result);
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication) AuthenticationException(org.springframework.security.core.AuthenticationException) ModuleAuthentication(com.evolveum.midpoint.authentication.api.config.ModuleAuthentication) StringValue(org.apache.wicket.util.string.StringValue)

Example 54 with StringValue

use of org.apache.wicket.util.string.StringValue in project midpoint by Evolveum.

the class LeftMenuPanel method createDashboardMenuItem.

private MenuItem createDashboardMenuItem(CompiledDashboardType dashboard) {
    Validate.notNull(dashboard, "Dashboard object is null");
    if (!WebComponentUtil.getElementVisibility(dashboard.getVisibility())) {
        return null;
    }
    String label = getDashboardLabel(dashboard);
    StringValue dashboardOidParam = getPageBase().getPageParameters().get(OnePageParameterEncoder.PARAMETER);
    boolean active = false;
    if (dashboardOidParam != null) {
        active = dashboard.getOid().equals(dashboardOidParam.toString());
    }
    return new MenuItem(label, PageDashboardConfigurable.class, createDashboardPageParameters(dashboard), active);
}
Also used : StringValue(org.apache.wicket.util.string.StringValue)

Example 55 with StringValue

use of org.apache.wicket.util.string.StringValue in project midpoint by Evolveum.

the class LeftMenuPanel method getSelectedTabForConfiguration.

private int getSelectedTabForConfiguration(WebPage page) {
    PageParameters params = page.getPageParameters();
    StringValue val = params.get(PageSystemConfiguration.SELECTED_TAB_INDEX);
    String value = null;
    if (val != null && !val.isNull()) {
        value = val.toString();
    }
    return StringUtils.isNumeric(value) ? Integer.parseInt(value) : PageSystemConfiguration.CONFIGURATION_TAB_BASIC;
}
Also used : PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) StringValue(org.apache.wicket.util.string.StringValue)

Aggregations

StringValue (org.apache.wicket.util.string.StringValue)57 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)22 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 IOException (java.io.IOException)7 Test (org.junit.Test)7 Task (com.evolveum.midpoint.task.api.Task)6 Url (org.apache.wicket.request.Url)5 AnnotationFeature (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)4 AnnotationLayer (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer)4 WebSession (org.apache.openmeetings.web.app.WebSession)4 RestartResponseException (org.apache.wicket.RestartResponseException)4 IRequestParameters (org.apache.wicket.request.IRequestParameters)4 AnnotationException (de.tudarmstadt.ukp.clarin.webanno.api.annotation.exception.AnnotationException)3 AnnotatorState (de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 AnnotationFS (org.apache.uima.cas.text.AnnotationFS)3 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)3