-
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.
changes to get to the PageAttributeVerification
- Loading branch information
1 parent
d8a8307
commit 8e4e3d9
Showing
6 changed files
with
82 additions
and
21 deletions.
There are no files selected for viewing
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
54 changes: 54 additions & 0 deletions
54
...olveum/midpoint/authentication/impl/filter/AttributeVerificationAuthenticationFilter.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,54 @@ | ||
/* | ||
* Copyright (c) 2022 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.authentication.impl.filter; | ||
|
||
import com.evolveum.midpoint.authentication.api.util.AuthConstants; | ||
import com.evolveum.midpoint.authentication.impl.module.authentication.token.AttributeVerificationToken; | ||
import com.evolveum.midpoint.authentication.impl.util.AuthSequenceUtil; | ||
|
||
import org.springframework.security.authentication.AuthenticationServiceException; | ||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.security.core.AuthenticationException; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class AttributeVerificationAuthenticationFilter extends MidpointUsernamePasswordAuthenticationFilter { | ||
|
||
private static final String SPRING_SECURITY_FORM_ANSWER_KEY = "answer"; | ||
private static final String SPRING_SECURITY_FORM_USER_KEY = "user"; | ||
|
||
public Authentication attemptAuthentication( | ||
HttpServletRequest request, HttpServletResponse response) throws AuthenticationException { | ||
if (isPostOnly() && !request.getMethod().equals("POST")) { | ||
throw new AuthenticationServiceException( | ||
"Authentication method not supported: " + request.getMethod()); | ||
} | ||
|
||
setUsernameParameter(SPRING_SECURITY_FORM_USER_KEY); | ||
String username = obtainUsername(request); | ||
if (username == null) { | ||
username = ""; | ||
} | ||
|
||
username = username.trim(); | ||
|
||
UsernamePasswordAuthenticationToken authRequest = | ||
new AttributeVerificationToken(username, null); | ||
|
||
return this.getAuthenticationManager().authenticate(authRequest); | ||
} | ||
|
||
protected Map<String, String> obtainAnswers(HttpServletRequest request) { | ||
String answers = request.getParameter(SPRING_SECURITY_FORM_ANSWER_KEY); | ||
|
||
return AuthSequenceUtil.obtainAnswers(answers, AuthConstants.SEC_QUESTION_J_QID, AuthConstants.SEC_QUESTION_J_QANS); | ||
} | ||
} |
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