Skip to content

Commit

Permalink
fix suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoshani committed Jul 5, 2023
1 parent 5c2c2a3 commit 157989c
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
* Copyright (c) 2022, WSO2 LLC. (http://www.wso2.org) All Rights Reserved.
/**
* Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com) All Rights Reserved.
*
* WSO2 LLC. licenses this file to you 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
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
Expand Down Expand Up @@ -82,6 +82,16 @@ public class MagicLinkAuthenticator extends AbstractApplicationAuthenticator imp
private static final Log log = LogFactory.getLog(MagicLinkAuthenticator.class);
private AuthenticationContext authenticationContext;

/**
* Processes the authentication or logout flow for the Authenticator.
*
* @param request The httpServletRequest.
* @param response The httpServletResponse.
* @param context The authentication context.
* @return The AuthenticatorFlowStatus indicating the status of the flow.
* @throws AuthenticationFailedException If the authentication process fails.
* @throws LogoutFailedException If the logout process fails.
*/
@Override
public AuthenticatorFlowStatus process(HttpServletRequest request, HttpServletResponse response,
AuthenticationContext context) throws AuthenticationFailedException,
Expand All @@ -94,7 +104,7 @@ public AuthenticatorFlowStatus process(HttpServletRequest request, HttpServletRe
if (context.isLogoutRequest()) {
return AuthenticatorFlowStatus.SUCCESS_COMPLETED;
}
if (getName().equals(context.getProperty(FrameworkConstants.LAST_FAILED_AUTHENTICATOR))) {
if (StringUtils.equals(getName(), (String) context.getProperty(FrameworkConstants.LAST_FAILED_AUTHENTICATOR))) {
context.setRetrying(true);
}
User user = resolveUser(request, authenticationContext);
Expand All @@ -116,7 +126,7 @@ public AuthenticatorFlowStatus process(HttpServletRequest request, HttpServletRe
*/
@Override
protected void initiateAuthenticationRequest(HttpServletRequest request, HttpServletResponse response,
AuthenticationContext context) throws AuthenticationFailedException {
AuthenticationContext context) throws AuthenticationFailedException {

if (context.getLastAuthenticatedUser() == null) {
context.setProperty(MagicLinkAuthenticatorConstants.IS_IDF_INITIATED_FROM_AUTHENTICATOR, true);
Expand Down Expand Up @@ -189,7 +199,7 @@ protected void initiateAuthenticationRequest(HttpServletRequest request, HttpSer
*/
@Override
protected void processAuthenticationResponse(HttpServletRequest request, HttpServletResponse response,
AuthenticationContext context) throws AuthenticationFailedException {
AuthenticationContext context) throws AuthenticationFailedException {

if (StringUtils.isEmpty(request.getParameter(MagicLinkAuthenticatorConstants.MAGIC_LINK_TOKEN))) {
throw new InvalidCredentialsException("MagicToken cannot be null.");
Expand All @@ -205,7 +215,7 @@ protected void processAuthenticationResponse(HttpServletRequest request, HttpSer
UserCoreUtil.setDomainInThreadLocal(magicLinkAuthContextData.getUser().getUserStoreDomain());
AuthenticatedUser authenticatedUser =
AuthenticatedUser.createLocalAuthenticatedUserFromSubjectIdentifier(
magicLinkAuthContextData.getUser().getFullQualifiedUsername());
magicLinkAuthContextData.getUser().getFullQualifiedUsername());
context.setSubject(authenticatedUser);
MagicLinkAuthContextCache.getInstance().clearCacheEntry(magicLinkAuthContextCacheKey);
} else {
Expand Down Expand Up @@ -285,7 +295,7 @@ public String getName() {
* @param expiryTime The expiry time.
*/
protected void triggerEvent(String username, String userStoreDomain, String tenantDomain, String magicToken,
String applicationName, String expiryTime) {
String applicationName, String expiryTime) {

String eventName = IdentityEventConstants.Event.TRIGGER_NOTIFICATION;
Map<String, Object> properties = new HashMap<>();
Expand Down Expand Up @@ -417,8 +427,9 @@ private String validateIdentifierFromRequest(HttpServletRequest request)
/**
* This method is used to resolve the user from authentication response from identifier handler.
*
* @param request The httpServletRequest.
* @param context The authentication context.
* @param request The httpServletRequest.
* @param context The authentication context.
* @return The resolved User object.
* @throws AuthenticationFailedException In occasions of failing.
*/
private User resolveUser(HttpServletRequest request, AuthenticationContext context)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
* Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
/**
* Copyright (c) 2021, WSO2 LLC. (https://www.wso2.com) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* WSO2 LLC. licenses this file to you 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
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
* Copyright (c) 2021, WSO2 LLC. (http://www.wso2.org) All Rights Reserved.
/**
* Copyright (c) 2021, WSO2 LLC. (https://www.wso2.com) All Rights Reserved.
*
* WSO2 LLC. licenses this file to you 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
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
* Copyright (c) 2021, WSO2 LLC. (http://www.wso2.org) All Rights Reserved.
/**
* Copyright (c) 2021, WSO2 LLC. (https://www.wso2.com) All Rights Reserved.
*
* WSO2 LLC. licenses this file to you 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
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
* Copyright (c) 2022, WSO2 LLC. (http://www.wso2.org) All Rights Reserved.
/**
* Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com) All Rights Reserved.
*
* WSO2 LLC. licenses this file to you 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
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
* Copyright (c) 2022, WSO2 LLC. (http://www.wso2.org) All Rights Reserved.
/**
* Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com) All Rights Reserved.
*
* WSO2 LLC. licenses this file to you 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
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
Expand Down

0 comments on commit 157989c

Please sign in to comment.