Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
15 changed files
with
309 additions
and
345 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/login/AbstractPageLogin.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright (c) 2010-2013 Evolveum | ||
~ | ||
~ This work is dual-licensed under the Apache License 2.0 | ||
~ and European Union Public License. See LICENSE file for details. | ||
--> | ||
|
||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | ||
"http://www.w3.org/TR/html4/loose.dtd"> | ||
<html xmlns:wicket="http://wicket.apache.org"> | ||
<body> | ||
<wicket:extend> | ||
|
||
<div class="row"> | ||
<div class="col-md-12" style="float: left; font-weight: 600;"> | ||
<span wicket:id="sequence"/> | ||
</div> | ||
<div class="col-md-offset-2 col-md-8 col-lg-offset-4 col-lg-4"> | ||
<div class="panel panel-default" style="margin-top: 120px;"> | ||
<div class="panel-body"> | ||
<wicket:child/> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
|
||
<script type="text/javascript"> | ||
$(".focus-username").focus(); | ||
</script> | ||
|
||
<wicket:remove>This css is used to hide sidebar menu</wicket:remove> | ||
<style type="text/css"> | ||
.content-wrapper, .right-side, .main-footer { | ||
margin-left: 0px; | ||
|
||
-moz-transition: none; | ||
-webkit-transition: none; | ||
-o-transition: color 0 ease-in; | ||
transition: none; | ||
} | ||
</style> | ||
</wicket:extend> | ||
|
||
</body> | ||
</html> |
145 changes: 145 additions & 0 deletions
145
gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/login/AbstractPageLogin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
/* | ||
* Copyright (c) 2010-2018 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
|
||
package com.evolveum.midpoint.web.page.login; | ||
|
||
import com.evolveum.midpoint.gui.api.page.PageBase; | ||
import com.evolveum.midpoint.model.api.authentication.MidpointAuthentication; | ||
import com.evolveum.midpoint.model.api.authentication.ModuleAuthentication; | ||
import com.evolveum.midpoint.model.api.authentication.ModuleWebSecurityConfiguration; | ||
import com.evolveum.midpoint.schema.result.OperationResult; | ||
import com.evolveum.midpoint.task.api.Task; | ||
import com.evolveum.midpoint.util.exception.CommonException; | ||
import com.evolveum.midpoint.util.logging.Trace; | ||
import com.evolveum.midpoint.util.logging.TraceManager; | ||
import com.evolveum.midpoint.web.application.PageDescriptor; | ||
import com.evolveum.midpoint.web.application.Url; | ||
import com.evolveum.midpoint.web.component.form.Form; | ||
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour; | ||
import com.evolveum.midpoint.web.page.forgetpassword.PageForgotPassword; | ||
import com.evolveum.midpoint.web.security.MidPointApplication; | ||
import com.evolveum.midpoint.web.security.module.authentication.LdapModuleAuthentication; | ||
import com.evolveum.midpoint.web.security.module.authentication.LoginFormModuleAuthentication; | ||
import com.evolveum.midpoint.web.security.util.SecurityUtils; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.AuthenticationSequenceType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsPolicyType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.RegistrationsPolicyType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.apache.wicket.AttributeModifier; | ||
import org.apache.wicket.RestartResponseException; | ||
import org.apache.wicket.markup.html.WebMarkupContainer; | ||
import org.apache.wicket.markup.html.basic.Label; | ||
import org.apache.wicket.markup.html.link.BookmarkablePageLink; | ||
import org.apache.wicket.model.IModel; | ||
import org.apache.wicket.protocol.http.servlet.ServletWebRequest; | ||
import org.apache.wicket.request.cycle.RequestCycle; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.security.core.context.SecurityContextHolder; | ||
import org.springframework.security.web.WebAttributes; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpSession; | ||
|
||
import static org.springframework.security.saml.util.StringUtils.stripSlashes; | ||
|
||
/** | ||
* @author lskublik | ||
*/ | ||
public abstract class AbstractPageLogin extends PageBase { | ||
private static final long serialVersionUID = 1L; | ||
|
||
private static final Trace LOGGER = TraceManager.getTrace(AbstractPageLogin.class); | ||
|
||
private static final String ID_SEQUENCE = "sequence"; | ||
|
||
public AbstractPageLogin() { | ||
} | ||
|
||
@Override | ||
protected void onInitialize() { | ||
super.onInitialize(); | ||
initLayer(); | ||
} | ||
|
||
private void initLayer() { | ||
Label sequence = new Label(ID_SEQUENCE, createStringResource("AbstractPageLogin.authenticationSequence", getSequenceName())); | ||
sequence.add(new VisibleEnableBehaviour() { | ||
@Override | ||
public boolean isVisible() { | ||
return !StringUtils.isEmpty(getSequenceName()); | ||
} | ||
}); | ||
add(sequence); | ||
initCustomLayer(); | ||
} | ||
|
||
private String getSequenceName() { | ||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); | ||
if (authentication instanceof MidpointAuthentication) { | ||
MidpointAuthentication mpAuthentication = (MidpointAuthentication) authentication; | ||
AuthenticationSequenceType sequence = mpAuthentication.getSequence(); | ||
if (sequence != null) { | ||
return sequence.getDisplayName() != null ? sequence.getDisplayName() : sequence.getName(); | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
protected abstract void initCustomLayer(); | ||
|
||
@Override | ||
protected void onConfigure() { | ||
super.onConfigure(); | ||
|
||
ServletWebRequest req = (ServletWebRequest) RequestCycle.get().getRequest(); | ||
HttpServletRequest httpReq = req.getContainerRequest(); | ||
HttpSession httpSession = httpReq.getSession(); | ||
|
||
Exception ex = (Exception) httpSession.getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION); | ||
if (ex == null) { | ||
return; | ||
} | ||
|
||
String msg = ex.getMessage(); | ||
if (StringUtils.isEmpty(msg)) { | ||
msg = "web.security.provider.unavailable"; | ||
} | ||
|
||
String[] msgs = msg.split(";"); | ||
for (String message : msgs) { | ||
message = getLocalizationService().translate(message, null, getLocale(), message); | ||
error(message); | ||
} | ||
|
||
httpSession.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION); | ||
|
||
clearBreadcrumbs(); | ||
} | ||
|
||
@Override | ||
protected void createBreadcrumb() { | ||
//don't create breadcrumb for login page | ||
} | ||
|
||
@Override | ||
protected void onBeforeRender() { | ||
super.onBeforeRender(); | ||
|
||
if (SecurityUtils.getPrincipalUser() != null) { | ||
MidPointApplication app = getMidpointApplication(); | ||
throw new RestartResponseException(app.getHomePage()); | ||
} | ||
} | ||
|
||
@Override | ||
protected boolean isSideMenuVisible(boolean visibleIfLoggedIn) { | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.