Skip to content

Commit

Permalink
Merge branch 'post-3.7-fixes' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
…into post-3.7-fixes
  • Loading branch information
KaterynaHonchar committed Feb 26, 2018
2 parents f84cdf5 + 9ec8abd commit b5f40b8
Show file tree
Hide file tree
Showing 86 changed files with 3,211 additions and 783 deletions.
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.evolveum.midpoint.gui.api.util;

import com.evolveum.midpoint.web.security.MidPointApplication;

/**
* Created by Viliam Repan (lazyman).
*/
public interface MidPointApplicationConfiguration {

void init(MidPointApplication application);
}
Expand Up @@ -26,11 +26,13 @@
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.task.api.TaskManager;
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.web.page.admin.PageAdminObjectDetails;
import com.evolveum.midpoint.web.page.login.PageLogin;
import com.evolveum.midpoint.web.security.MidPointApplication;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.prism.xml.ns._public.types_3.EvaluationTimeType;

import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang.LocaleUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
Expand Down Expand Up @@ -711,4 +713,29 @@ public static void addIncludeOptionsForExportOrView(Collection<SelectorOptions<G
GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE)));
}
}

public static boolean isEnableExperimentalFeature(PageBase pageBase) {
Task task = pageBase.createSimpleTask("Load admin gui config");
OperationResult result = task.getResult();

ModelInteractionService mInteractionService = pageBase.getModelInteractionService();

AdminGuiConfigurationType adminGuiConfig = null;
try {
adminGuiConfig = mInteractionService.getAdminGuiConfiguration(task, result);
result.recomputeStatus();
result.recordSuccessIfUnknown();
} catch (Exception e) {
LoggingUtils.logException(LOGGER, "Cannot load admin gui config", e);
result.recordPartialError("Cannot load admin gui config. Reason: " + e.getLocalizedMessage());

}

if (adminGuiConfig == null) {
return false;
}

return BooleanUtils.isTrue(adminGuiConfig.isEnableExperimentalFeatures());

}
}
Expand Up @@ -27,6 +27,7 @@
import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.util.logging.Trace;
Expand Down Expand Up @@ -90,7 +91,12 @@ private void initLayout() {
}

private List<ItemPath> getVisibleContainers() {
return Arrays.asList(ItemPath.EMPTY_PATH, new ItemPath(AbstractRoleType.F_DATA_PROTECTION), SchemaConstants.PATH_ACTIVATION, SchemaConstants.PATH_PASSWORD);
List<ItemPath> paths = new ArrayList<>();
paths.addAll(Arrays.asList(ItemPath.EMPTY_PATH, SchemaConstants.PATH_ACTIVATION, SchemaConstants.PATH_PASSWORD));
if (WebModelServiceUtils.isEnableExperimentalFeature(getPageBase())) {
paths.add(new ItemPath(AbstractRoleType.F_DATA_PROTECTION));
}
return paths;
}


Expand Down
Expand Up @@ -305,40 +305,44 @@ public String getCount() {
});

authorization = new FocusTabVisibleBehavior(unwrapModel(), ComponentConstants.UI_FOCUS_TAB_ASSIGNMENTS_URL);
tabs.add(
new CountablePanelTab(parentPage.createStringResource("pageAdminFocus.dataProtection"), authorization) {

if (WebModelServiceUtils.isEnableExperimentalFeature(parentPage)) {
tabs.add(new CountablePanelTab(parentPage.createStringResource("pageAdminFocus.dataProtection"), authorization) {

private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;

@Override
public WebMarkupContainer createPanel(String panelId) {
return createFocusDataProtectionTabPanel(panelId, parentPage);
}
@Override
public WebMarkupContainer createPanel(String panelId) {
return createFocusDataProtectionTabPanel(panelId, parentPage);
}

@Override
public String getCount() {
PrismObject<F> focus = getObjectModel().getObject().getObject();
List<AssignmentType> assignments = focus.asObjectable().getAssignment();
int count = 0;
for (AssignmentType assignment : assignments) {
if (assignment.getTargetRef() == null) {
continue;
}
if (QNameUtil.match(assignment.getTargetRef().getType(), OrgType.COMPLEX_TYPE)) {
Task task = parentPage.createSimpleTask("load data protection obejcts");
PrismObject<OrgType> org = WebModelServiceUtils.loadObject(assignment.getTargetRef(), parentPage, task, task.getResult());

if (org != null) {
if (org.asObjectable().getOrgType().contains("access")) {
count++;
}
@Override
public String getCount() {
PrismObject<F> focus = getObjectModel().getObject().getObject();
List<AssignmentType> assignments = focus.asObjectable().getAssignment();
int count = 0;
for (AssignmentType assignment : assignments) {
if (assignment.getTargetRef() == null) {
continue;
}
if (QNameUtil.match(assignment.getTargetRef().getType(), OrgType.COMPLEX_TYPE)) {
Task task = parentPage.createSimpleTask("load data protection obejcts");
PrismObject<OrgType> org = WebModelServiceUtils.loadObject(assignment.getTargetRef(), parentPage,
task, task.getResult());

if (org != null) {
if (org.asObjectable().getOrgType().contains("access")) {
count++;
}
}
}

return String.valueOf(count);
}
});

return String.valueOf(count);
}
});
}


authorization = new FocusTabVisibleBehavior(unwrapModel(), ComponentConstants.UI_FOCUS_TAB_TASKS_URL);
tabs.add(
Expand Down
Expand Up @@ -58,7 +58,7 @@ private boolean isContainerMultivalue(){
}

@Override
protected String getLabel() {
public String getLabel() {
return getModelObject() != null ? getModelObject().getDisplayName() : "";
}

Expand Down
Expand Up @@ -274,7 +274,7 @@ private WebMarkupContainer getChildContainersSelectorPanel(){
}

@Override
protected String getLabel() {
public String getLabel() {
return getModel().getObject().getDisplayName();
}

Expand Down
Expand Up @@ -72,7 +72,7 @@ protected void onButtonClick(AjaxRequestTarget target) {

}

protected abstract String getLabel();
public abstract String getLabel();

public boolean isButtonsVisible() {
return true;
Expand Down
Expand Up @@ -19,6 +19,7 @@
import com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition;
import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.path.ItemPath;
Expand Down Expand Up @@ -60,13 +61,16 @@ public class PrismPropertyPanel<IW extends ItemWrapper> extends Panel {
private static final String ID_LABEL = "label";
private static final String ID_LABEL_CONTAINER = "labelContainer";

private IModel<IW> model;

private PageBase pageBase;

private boolean labelContainerVisible = true;

public PrismPropertyPanel(String id, final IModel<IW> model, Form form, ItemVisibilityHandler visibilityHandler, PageBase pageBase) {
super(id, model);
Validate.notNull(model, "no model");
this.model = model;
this.pageBase = pageBase;

LOGGER.trace("Creating property panel for {}", model.getObject());
Expand Down Expand Up @@ -96,6 +100,10 @@ public boolean isEnabled() {
initLayout(model, form);
}

public IModel<IW> getModel() {
return model;
}

private void initLayout(final IModel<IW> model, final Form form) {
WebMarkupContainer labelContainer = new WebMarkupContainer(ID_LABEL_CONTAINER);
labelContainer.setOutputMarkupId(true);
Expand Down
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2018 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:panel>
<div class="row">
<div class="col-md-6">
<h3><wicket:message key="PageInternals.title.cache"/></h3>

<div class="main-button-bar">
<a class="btn btn-primary" wicket:id="clearCaches"/>
</div>

</div>
</div>
</wicket:panel>
</body>
</html>
@@ -0,0 +1,36 @@
package com.evolveum.midpoint.web.page.admin.configuration;

import org.apache.wicket.ajax.AjaxRequestTarget;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.web.component.AjaxButton;

public class InternalsCachePanel extends BasePanel<Void>{

private static final long serialVersionUID = 1L;

private static final String ID_CLEAR_CACHES_BUTTON = "clearCaches";

public InternalsCachePanel(String id) {
super(id);
}

@Override
protected void onInitialize() {
super.onInitialize();

AjaxButton clearCustomFunctionCache = new AjaxButton(ID_CLEAR_CACHES_BUTTON, createStringResource("InternalsCachePanel.button.clearCaches")) {

private static final long serialVersionUID = 1L;

@Override
public void onClick(AjaxRequestTarget target) {
getPageBase().getModelInteractionService().clearCaches();
}
};

add(clearCustomFunctionCache);
}


}
Expand Up @@ -156,6 +156,16 @@ public WebMarkupContainer getPanel(String panelId) {
}
});

tabs.add(new AbstractTab(createStringResource("PageInternals.tab.cache")) {

private static final long serialVersionUID = 1L;

@Override
public WebMarkupContainer getPanel(String panelId) {
return initCachePanel(panelId);
}
});

TabbedPanel<ITab> tabPannel = new TabbedPanel<>(ID_TAB_PANEL, tabs);
add(tabPannel);

Expand All @@ -178,7 +188,11 @@ private WebMarkupContainer initTraces(String panelId) {
}

private WebMarkupContainer initCounters(String panelId) {
return new InternalsCountersPanel(panelId);
return new InternalsCountersPanel(panelId);
}

private WebMarkupContainer initCachePanel(String panelId) {
return new InternalsCachePanel(panelId);
}


Expand Down
Expand Up @@ -16,13 +16,13 @@

package com.evolveum.midpoint.web.security;

import org.apache.commons.lang.StringUtils;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.security.web.access.AccessDeniedHandlerImpl;
import org.springframework.security.web.csrf.CsrfException;
import org.springframework.security.web.csrf.InvalidCsrfTokenException;
import org.springframework.security.web.csrf.MissingCsrfTokenException;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Expand Down Expand Up @@ -57,6 +57,20 @@ private boolean isLoginLogoutRequest(HttpServletRequest req) {
}

String uri = req.getRequestURI();
return "/j_spring_security_logout".equals(uri) || "/spring_security_login".equals(uri);
return createUri(req, "/j_spring_security_logout").equals(uri)
|| createUri(req, "/spring_security_login").equals(uri);
}

private String createUri(HttpServletRequest req, String uri) {
StringBuilder sb = new StringBuilder();

ServletContext ctx = req.getServletContext();
String ctxPath = ctx.getContextPath();
if (StringUtils.isNotEmpty(ctxPath)) {
sb.append(ctxPath);
}
sb.append(uri);

return sb.toString();
}
}

0 comments on commit b5f40b8

Please sign in to comment.