Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Nov 19, 2018
2 parents 499afd8 + 8da0443 commit f92cf19
Show file tree
Hide file tree
Showing 55 changed files with 846 additions and 1,210 deletions.
Expand Up @@ -62,6 +62,7 @@
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.task.api.TaskCategory;
import com.evolveum.midpoint.task.api.TaskManager;
import com.evolveum.midpoint.util.CheckedProducer;
import com.evolveum.midpoint.util.Holder;
import com.evolveum.midpoint.util.Producer;
import com.evolveum.midpoint.util.QNameUtil;
Expand Down Expand Up @@ -2305,6 +2306,26 @@ public <T> T runPrivileged(Producer<T> producer) {
return securityContextManager.runPrivileged(producer);
}

public <T> T runAsChecked(CheckedProducer<T> producer, PrismObject<UserType> user) throws CommonException {
return securityContextManager.runAsChecked(producer, user);
}

@NotNull public PrismObject<UserType> getAdministratorPrivileged(OperationResult parentResult) throws CommonException {
OperationResult result = parentResult.createSubresult(OPERATION_LOAD_USER);
try {
return securityContextManager.runPrivilegedChecked(() -> {
Task task = createAnonymousTask(OPERATION_LOAD_USER);
return getModelService()
.getObject(UserType.class, SystemObjectsType.USER_ADMINISTRATOR.value(), null, task, result);
});
} catch (Throwable t) {
result.recordFatalError("Couldn't get administrator user: " + t.getMessage(), t);
throw t;
} finally {
result.computeStatusIfUnknown();
}
}

public void setBreadcrumbs(List<Breadcrumb> breadcrumbs) {
getBreadcrumbs().clear();

Expand Down
Expand Up @@ -185,7 +185,7 @@ private static SpringApplicationBuilder configureApplication(SpringApplicationBu
System.setProperty(MIDPOINT_HOME_PROPERTY, mpHome);
}

System.setProperty("spring.config.location", MidPointSpringApplication.class.getResource("/") + ",${midpoint.home}/");
System.setProperty("spring.config.additional-location", "${midpoint.home}/");

application.bannerMode(Banner.Mode.LOG);

Expand Down Expand Up @@ -267,6 +267,8 @@ public class ServerCustomization implements WebServerFactoryCustomizer<Configura

@Value("${server.servlet.session.timeout}")
private int sessionTimeout;
@Value("${server.servlet.context-path}")
private String servletPath;

@Autowired
ServerProperties serverProperties;
Expand Down Expand Up @@ -300,7 +302,7 @@ public void customize(ConfigurableServletWebServerFactory server) {
private void customizeTomcat(TomcatServletWebServerFactory tomcatFactory) {
// Tomcat valve used to redirect root URL (/) to real application URL (/midpoint/).
// See comments in TomcatRootValve
Valve rootValve = new TomcatRootValve();
Valve rootValve = new TomcatRootValve(servletPath);
tomcatFactory.addEngineValves(rootValve);
}

Expand Down
Expand Up @@ -15,52 +15,57 @@
*/
package com.evolveum.midpoint.web.boot;

import java.io.IOException;

import javax.servlet.ServletException;

import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import org.apache.catalina.Context;
import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;
import org.apache.catalina.valves.ValveBase;

import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import javax.servlet.ServletException;
import java.io.IOException;

/**
* Tomcat valve used to redirect root (/) URL to real application (/midpoint/).
* This is needed in Spring boot deployment. Entire midPoint app is deployed
* under http://.../midpoint/ URL root. But we want users to use http://.../
* as well to access the application.
*
* <p>
* This could not be done with midPoint servlets or servlet filters. The entire
* midPoint application is under /midpoint/, so the application won't even receive
* requests to root URL. We need to use dirty Tomcat-specific tricks for this.
*
* @author semancik
*
* @author semancik
*/
public class TomcatRootValve extends ValveBase {

private static final Trace LOGGER = TraceManager.getTrace(TomcatRootValve.class);


private String servletPath;

public TomcatRootValve(String serlvetPath) {
super();

this.servletPath = serlvetPath == null ? "" : serlvetPath;
}

@Override
public void invoke(Request request, Response response) throws IOException, ServletException {

Context context = request.getContext();
if (context instanceof RootRootContext) {
String uri = request.getDecodedRequestURI();
if (uri.endsWith("favicon.ico")) {
LOGGER.trace("Redirecting favicon request to real application (URI={})", request.getDecodedRequestURI());
response.sendRedirect("/midpoint/favicon.ico");
response.sendRedirect(servletPath + "/favicon.ico");
return;
} else {
LOGGER.trace("Redirecting request to real application root (URI={})", request.getDecodedRequestURI());
response.sendRedirect("/midpoint/");
response.sendRedirect(servletPath + "/");
return;
}
}

getNext().invoke(request, response);
}

Expand Down
Expand Up @@ -230,6 +230,11 @@ static String getDisplayNameFromItem(Item item) {
QName name = item.getElementName();
if (name != null) {
displayName = name.getLocalPart();

PrismValue val = item.getParent();
if (val != null && val.getTypeName() != null) {
displayName = val.getTypeName().getLocalPart() + "." + displayName;
}
} else {
displayName = item.getDefinition().getTypeName().getLocalPart();
}
Expand Down
Expand Up @@ -24,7 +24,7 @@
<!-- <div> -->
<!-- <div wicket:id="testConnectionResults" /> -->
<!-- </div> -->
<div>
<div class="col-xs-12" style="padding: 0;">
<div wicket:id="summary" />
</div>

Expand Down
@@ -0,0 +1,26 @@
<!--
~ Copyright (c) 2016 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.
-->

<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<div class="row">
<div class="col-md-12">
<div wicket:id="account"/>
</div>
</div>
</wicket:panel>
</html>
@@ -0,0 +1,66 @@
/*
* 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.
*/

package com.evolveum.midpoint.web.page.admin.resources;

import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.web.component.form.Form;
import com.evolveum.midpoint.web.component.objectdetails.AbstractObjectTabPanel;
import com.evolveum.midpoint.web.component.prism.ObjectWrapper;
import com.evolveum.midpoint.web.component.prism.PrismPanel;
import com.evolveum.midpoint.web.model.ContainerWrapperListFromObjectWrapperModel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
* Created by Viliam Repan (lazyman).
*/
public class ShadowDetailsTabPanel extends AbstractObjectTabPanel<ShadowType> {

private static final long serialVersionUID = 1L;

private static final String ID_ACCOUNT = "account";

public ShadowDetailsTabPanel(String id, Form<ObjectWrapper<ShadowType>> mainForm,
LoadableModel<ObjectWrapper<ShadowType>> objectWrapperModel, PageBase pageBase) {
super(id, mainForm, objectWrapperModel, pageBase);
}

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

PrismPanel<ShadowType> panel = new PrismPanel<>(ID_ACCOUNT,
new ContainerWrapperListFromObjectWrapperModel(getObjectWrapperModel(), getVisibleContainers()),
null, getMainForm(), null, getPageBase());
add(panel);
}

private List<ItemPath> getVisibleContainers() {
// todo maybe everything should be visible, but for now this should be fine
return Arrays.asList(
new ItemPath(ShadowType.F_ATTRIBUTES),
new ItemPath(ShadowType.F_CREDENTIALS, CredentialsType.F_PASSWORD),
new ItemPath(ShadowType.F_ACTIVATION)
);
}
}
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:extend>
<wicket:child/>
</wicket:extend>
</body>
</html>
@@ -0,0 +1,61 @@
/*
* 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.
*/

package com.evolveum.midpoint.web.page.admin.resources;

import com.evolveum.midpoint.gui.api.GuiStyleConstants;
import com.evolveum.midpoint.gui.api.util.ModelServiceLocator;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.web.component.ObjectSummaryPanel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;
import org.apache.wicket.model.IModel;

/**
* Created by Viliam Repan (lazyman).
*/
public class ShadowSummaryPanel extends ObjectSummaryPanel<ShadowType> {

private static final long serialVersionUID = 1L;

public ShadowSummaryPanel(String id, IModel<PrismObject<ShadowType>> model, ModelServiceLocator locator) {
super(id, ShadowType.class, model, locator);

initLayoutCommon(locator);
}

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


// todo implement custom layout
}

@Override
protected String getIconCssClass() {
return GuiStyleConstants.CLASS_OBJECT_RESOURCE_ICON; //todo fix
}

@Override
protected String getIconBoxAdditionalCssClass() {
return "summary-panel-resource"; //todo fix
}

@Override
protected String getBoxAdditionalCssClass() {
return "summary-panel-resource"; //todo fix
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Expand Up @@ -18,15 +18,14 @@
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:extend>
<form wicket:id="mainForm" autocomplete="off">
<div class="alert alert-warning" wicket:id="protectedMessage">
<wicket:message key="pageAccount.message.cantEditProtectedAccount"/></div>
<div class="alert alert-warning" wicket:id="protectedMessage">
<wicket:message key="pageAccount.message.cantEditProtectedAccount"/></div>

<div class="row">
<div class="col-md-12">
<div wicket:id="account"/>
</div>
</div>
<div wicket:id="summary" />

<form wicket:id="mainForm" autocomplete="off" class="col-xs-12 form-horizontal" style="padding:0px;">

<div wicket:id="tabPanel" class="nav-tabs-custom" />

<div class="main-button-bar">
<span class="button-group">
Expand Down

0 comments on commit f92cf19

Please sign in to comment.