-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/forgot-username' of github.com:Evolveum/midpoin…
…t into feature/forgot-username * 'feature/forgot-username' of github.com:Evolveum/midpoint: duplicate url usage fix added login recovery result page; some refactoring in auth channels
- Loading branch information
Showing
14 changed files
with
170 additions
and
62 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
...-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/login/PageLoginRecoveryFinish.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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright (c) 2010-2023 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 wicket:id="userLoginName" /> | ||
</wicket:extend> | ||
</body> | ||
</html> |
83 changes: 83 additions & 0 deletions
83
...-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/login/PageLoginRecoveryFinish.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,83 @@ | ||
/* | ||
* Copyright (c) 2023 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.gui.impl.page.login; | ||
|
||
import com.evolveum.midpoint.authentication.api.authorization.AuthorizationAction; | ||
import com.evolveum.midpoint.authentication.api.authorization.PageDescriptor; | ||
import com.evolveum.midpoint.authentication.api.authorization.Url; | ||
|
||
import com.evolveum.midpoint.authentication.api.config.MidpointAuthentication; | ||
import com.evolveum.midpoint.security.api.AuthorizationConstants; | ||
|
||
import com.evolveum.midpoint.web.component.util.VisibleBehaviour; | ||
|
||
import org.apache.wicket.markup.html.basic.Label; | ||
import org.apache.wicket.model.IModel; | ||
import org.apache.wicket.model.Model; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.security.core.context.SecurityContextHolder; | ||
|
||
import java.io.Serial; | ||
|
||
@PageDescriptor( | ||
urls = { | ||
@Url(mountUrl = "/loginRecovery", matchUrlForSecurity = "/loginRecovery") | ||
}, | ||
action = { | ||
@AuthorizationAction(actionUri = AuthorizationConstants.AUTZ_UI_LOGIN_RECOVERY_FINISH_URL, | ||
label = "PageLoginRecoveryFinish.auth.label", | ||
description = "PageLoginRecoveryFinish.auth.description") }) | ||
public class PageLoginRecoveryFinish extends AbstractPageLogin { | ||
|
||
@Serial private static final long serialVersionUID = 1L; | ||
|
||
private static final String ID_USER_LOGIN_PANEL = "userLoginName"; | ||
|
||
@Override | ||
protected boolean isBackButtonVisible() { | ||
return true; | ||
} | ||
|
||
@Override | ||
protected void initCustomLayout() { | ||
Label loginNamePanel = new Label(ID_USER_LOGIN_PANEL, Model.of(getAuthorizedUserName())); | ||
loginNamePanel.setOutputMarkupId(true); | ||
loginNamePanel.add(new VisibleBehaviour(this::isUserAuthorized)); | ||
add(loginNamePanel); | ||
} | ||
|
||
@Override | ||
protected IModel<String> getLoginPanelTitleModel() { | ||
return createStringResource(getTitleKey()); | ||
} | ||
|
||
private String getTitleKey() { | ||
return isUserAuthorized() ? "PageLoginRecoveryFinish.title.success" : "PageLoginRecoveryFinish.title.fail"; | ||
} | ||
|
||
@Override | ||
protected IModel<String> getLoginPanelDescriptionModel() { | ||
return createStringResource(getTitleDescriptionKey()); | ||
} | ||
|
||
private String getTitleDescriptionKey() { | ||
return isUserAuthorized() ? "PageLoginRecoveryFinish.title.success" : "PageLoginRecoveryFinish.title.fail"; | ||
} | ||
|
||
private boolean isUserAuthorized() { | ||
return getAuthorizedUserName() != null; | ||
} | ||
|
||
private String getAuthorizedUserName() { | ||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); | ||
if (authentication instanceof MidpointAuthentication) { | ||
return ((MidpointAuthentication) authentication).getUsername(); | ||
} | ||
return null; | ||
} | ||
|
||
} |
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
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
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