Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed May 29, 2020
2 parents 2918d74 + b17aea7 commit 164c3c2
Show file tree
Hide file tree
Showing 15 changed files with 309 additions and 345 deletions.
@@ -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>
@@ -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;
}
}
Expand Up @@ -40,7 +40,7 @@
import java.util.ArrayList;
import java.util.List;

public abstract class PageAuthenticationBase extends PageBase {
public abstract class PageAuthenticationBase extends AbstractPageLogin {

private static final long serialVersionUID = 1L;
private static final String DOT_CLASS = PageAuthenticationBase.class.getName() + ".";
Expand Down
Expand Up @@ -11,57 +11,30 @@
<html xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:extend>

<div class="row">
<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">

<form class="form-horizontal" action="ignore" wicket:id="mainForm">
<div class="form-group" wicket:id="staticLayout">
<label class="col-md-4 col-lg-4 control-label">
<wicket:message key="PageForgetPassword.email"/>
</label>

<div class="col-md-8 col-lg-8">
<input name="email" type="text" class="form-control input-sm focus-username"
wicket:message="placeholder:PageForgetPassword.email" wicket:id="email">
</div>
</div>

<div wicket:id="dynamicLayout">
<div wicket:id="dynamicForm"/>
</div>

<div class="pull-right">
<a class="btn btn-default" wicket:id="back"><wicket:message key="PageBase.button.back"/></a>
<a class="btn btn-primary" wicket:id="submit"/>
</div>
</form>
<div style="text-align: center">
<h2 wicket:id="resetPasswordInfo"></h2>
</div>
</div>
<form class="form-horizontal" action="ignore" wicket:id="mainForm">
<div class="form-group" wicket:id="staticLayout">
<label class="col-md-4 col-lg-4 control-label">
<wicket:message key="PageForgetPassword.email"/>
</label>

<div class="col-md-8 col-lg-8">
<input name="email" type="text" class="form-control input-sm focus-username"
wicket:message="placeholder:PageForgetPassword.email" wicket:id="email">
</div>
</div>
</div>

<div wicket:id="dynamicLayout">
<div wicket:id="dynamicForm"/>
</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>
<div class="pull-right">
<a class="btn btn-default" wicket:id="back"><wicket:message key="PageBase.button.back"/></a>
<a class="btn btn-primary" wicket:id="submit"/>
</div>
</form>
<div style="text-align: center">
<h2 wicket:id="resetPasswordInfo"></h2>
</div>
</wicket:extend>

</body>
Expand Down
Expand Up @@ -77,10 +77,9 @@ public class PageEmailNonse extends PageAuthenticationBase {
private boolean submited;

public PageEmailNonse() {
initLayout();
}

private void initLayout() {
protected void initCustomLayer() {
Form form = new Form(ID_MAIN_FORM);
form.add(new VisibleEnableBehaviour() {

Expand Down
Expand Up @@ -11,71 +11,44 @@
<html xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:extend>

<div class="row">
<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">
<!-- <form method="post" class="form-horizontal" action="spring_security_login">-->
<form method="post" class="form-horizontal" wicket:id="form">
<div class="form-group">
<label class="col-md-4 col-lg-4 control-label">
<wicket:message key="PageLogin.username"/>
</label>

<div class="col-md-8 col-lg-8">
<input name="username" type="text" class="form-control input-sm focus-username"
wicket:message="placeholder:PageLogin.username" >
</div>
</div>
<div class="form-group">
<label class="col-md-4 col-lg-4 control-label">
<wicket:message key="PageLogin.password"/>
</label>

<div class="col-md-8 col-lg-8">
<input name="password" type="password" class="form-control input-sm"
wicket:message="placeholder:PageLogin.password" >
</div>
</div>

<div wicket:id="csrfField"/>

<wicket:link>
<a class="btn" role="button" href="forgetpassword" wicket:id="forgetpassword">
<wicket:message key="PageLogin.forgetPassword"/>
</a>
</wicket:link>

<div class="pull-right">
<a class="btn btn-default" role="button" wicket:id="selfRegistration">
<wicket:message key="PageLogin.selfRegistration"/>
</a>

<input type="submit" class="btn btn-primary" wicket:message="value:PageLogin.signIn"/>
</div>
</form>
</div>
<form method="post" class="form-horizontal" wicket:id="form">
<div class="form-group">
<label class="col-md-4 col-lg-4 control-label">
<wicket:message key="PageLogin.username"/>
</label>

<div class="col-md-8 col-lg-8">
<input name="username" type="text" class="form-control input-sm focus-username"
wicket:message="placeholder:PageLogin.username" >
</div>
</div>
<div class="form-group">
<label class="col-md-4 col-lg-4 control-label">
<wicket:message key="PageLogin.password"/>
</label>

<div class="col-md-8 col-lg-8">
<input name="password" type="password" class="form-control input-sm"
wicket:message="placeholder:PageLogin.password" >
</div>
</div>
</div>

<div wicket:id="csrfField"/>

<script type="text/javascript">
$(".focus-username").focus();
</script>
<wicket:link>
<a class="btn" role="button" href="forgetpassword" wicket:id="forgetpassword">
<wicket:message key="PageLogin.forgetPassword"/>
</a>
</wicket:link>

<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;
<div class="pull-right">
<a class="btn btn-default" role="button" wicket:id="selfRegistration">
<wicket:message key="PageLogin.selfRegistration"/>
</a>

-moz-transition: none;
-webkit-transition: none;
-o-transition: color 0 ease-in;
transition: none;
}
</style>
<input type="submit" class="btn btn-primary" wicket:message="value:PageLogin.signIn"/>
</div>
</form>
</wicket:extend>

</body>
Expand Down

0 comments on commit 164c3c2

Please sign in to comment.