Skip to content

Commit

Permalink
Merge branch 'wso2:master' into add-cutsom-fed-auth-mgt-support
Browse files Browse the repository at this point in the history
  • Loading branch information
Thisara-Welmilla committed Dec 3, 2024
2 parents 3d069a9 + 56b7c3b commit 7a1ad73
Show file tree
Hide file tree
Showing 845 changed files with 4,812 additions and 94,403 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>action-mgt</artifactId>
<version>7.6.20-SNAPSHOT</version>
<version>7.7.16-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,10 @@ public ActionExecutionStatus<?> execute(ActionType actionType, Map<String, Objec
validateActions(actions, actionType);
// As of now only one action is allowed.
Action action = actions.get(0);
DIAGNOSTIC_LOGGER.logActionInitiation(action);
return execute(action, eventContext);
} catch (ActionExecutionRuntimeException e) {
DIAGNOSTIC_LOGGER.logSkippedActionExecution(actionType);
LOG.debug("Skip executing actions for action type: " + actionType.name(), e);
// Skip executing actions when no action available or due to a failure in retrieving actions,
// is considered as action execution being successful.
// Skip executing actions when no action available is considered as action execution being successful.
return new SuccessStatus.Builder().setResponseContext(eventContext).build();
}
}
Expand All @@ -140,14 +137,11 @@ public ActionExecutionStatus<?> execute(ActionType actionType, String[] actionId

validateActionIdList(actionType, actionIdList);
Action action = getActionByActionId(actionType, actionIdList[0], tenantDomain);
DIAGNOSTIC_LOGGER.logActionInitiation(action);
try {
return execute(action, eventContext);
} catch (ActionExecutionRuntimeException e) {
DIAGNOSTIC_LOGGER.logSkippedActionExecution(actionType);
LOG.debug("Skip executing actions for action type: " + actionType.name(), e);
// Skip executing actions when no action available or due to a failure in retrieving actions,
// is considered as action execution being successful.
// Skip executing actions when no action available is considered as action execution being successful.
return new SuccessStatus.Builder().setResponseContext(eventContext).build();
}
}
Expand All @@ -172,6 +166,7 @@ private ActionExecutionStatus<?> execute(Action action, Map<String, Object> even
ActionExecutionResponseProcessor actionExecutionResponseProcessor = getResponseProcessor(actionType);

if (action.getStatus() == Action.Status.ACTIVE) {
DIAGNOSTIC_LOGGER.logActionInitiation(action);
return executeAction(action, actionRequest, eventContext, actionExecutionResponseProcessor);
} else {
// If no active actions are detected, it is regarded as the action execution being successful.
Expand All @@ -191,13 +186,13 @@ private Action getActionByActionId(ActionType actionType, String actionId, Strin
}

private List<Action> getActionsByActionType(ActionType actionType, String tenantDomain) throws
ActionExecutionRuntimeException {
ActionExecutionException {

try {
return ActionExecutionServiceComponentHolder.getInstance().getActionManagementService()
.getActionsByActionType(Action.ActionTypes.valueOf(actionType.name()).getPathParam(), tenantDomain);
} catch (ActionMgtException e) {
throw new ActionExecutionRuntimeException("Error occurred while retrieving actions.", e);
throw new ActionExecutionException("Error occurred while retrieving actions.", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.apache.http.client.methods.HttpPost;
import org.wso2.carbon.identity.action.execution.ActionExecutionLogConstants;
import org.wso2.carbon.identity.action.execution.model.ActionInvocationResponse;
import org.wso2.carbon.identity.action.execution.model.ActionType;
import org.wso2.carbon.identity.action.management.model.Action;
import org.wso2.carbon.identity.central.log.mgt.utils.LoggerUtils;
import org.wso2.carbon.utils.DiagnosticLog;
Expand All @@ -47,19 +46,6 @@ public void logActionInitiation(Action action) {
DiagnosticLog.ResultStatus.SUCCESS));
}

public void logSkippedActionExecution(ActionType actionType) {

if (!LoggerUtils.isDiagnosticLogsEnabled()) {
return;
}

triggerLogEvent(
initializeDiagnosticLogBuilder(
ActionExecutionLogConstants.ActionIDs.EXECUTE_ACTION,
"Skip executing action for " + actionType + " type.",
DiagnosticLog.ResultStatus.FAILED));
}

public void logActionRequest(Action action) {

if (!LoggerUtils.isDiagnosticLogsEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,16 @@ public void testActionExecuteWithActionIdFailureWhenInvalidActionIdGiven() throw
actionExecutorService.execute(ActionType.PRE_ISSUE_ACCESS_TOKEN, new String[]{any()}, any(), any());
}

@Test(expectedExceptions = ActionExecutionException.class,
expectedExceptionsMessageRegExp = "Error occurred while retrieving actions.")
public void testActionExecuteWithActionFailureWhenInvalidActionGiven() throws Exception {

when(actionManagementService.getActionsByActionType(any(), any())).thenThrow(
new ActionMgtException("Error occurred while retrieving actions."));

actionExecutorService.execute(ActionType.PRE_ISSUE_ACCESS_TOKEN, any(), any());
}

@Test(expectedExceptions = ActionExecutionException.class,
expectedExceptionsMessageRegExp = "Failed to build the request payload for action type: " +
"PRE_ISSUE_ACCESS_TOKEN")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>action-mgt</artifactId>
<version>7.6.20-SNAPSHOT</version>
<version>7.7.16-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion components/action-mgt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>identity-framework</artifactId>
<version>7.6.20-SNAPSHOT</version>
<version>7.7.16-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>api-resource-mgt</artifactId>
<version>7.6.20-SNAPSHOT</version>
<version>7.7.16-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>api-resource-mgt</artifactId>
<version>7.6.20-SNAPSHOT</version>
<version>7.7.16-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>org.wso2.carbon.identity.api.resource.mgt</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion components/api-resource-mgt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>identity-framework</artifactId>
<version>7.6.20-SNAPSHOT</version>
<version>7.7.16-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<parent>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>application-mgt</artifactId>
<version>7.6.20-SNAPSHOT</version>
<version>7.7.16-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>application-mgt</artifactId>
<version>7.6.20-SNAPSHOT</version>
<version>7.7.16-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>application-mgt</artifactId>
<version>7.6.20-SNAPSHOT</version>
<version>7.7.16-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>org.wso2.carbon.identity.application.mgt</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@
<!-- Scope validators list. The validators registered here wil be executed during token validation. -->
<ScopeValidators>
<ScopeValidator class="org.wso2.carbon.identity.oauth2.validators.JDBCScopeValidator" />
<ScopeValidator class="org.wso2.carbon.identity.oauth2.validators.xacml.XACMLScopeValidator"/>
</ScopeValidators>

<!-- Scope handlers list. The handlers registered here will be executed at the scope validation phase while
Expand Down
2 changes: 1 addition & 1 deletion components/application-mgt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>identity-framework</artifactId>
<version>7.6.20-SNAPSHOT</version>
<version>7.7.16-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>authentication-framework</artifactId>
<version>7.6.20-SNAPSHOT</version>
<version>7.7.16-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>authentication-framework</artifactId>
<version>7.6.20-SNAPSHOT</version>
<version>7.7.16-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import org.wso2.carbon.identity.application.authentication.framework.handler.request.RequestCoordinator;
import org.wso2.carbon.identity.application.authentication.framework.internal.FrameworkServiceComponent;
import org.wso2.carbon.identity.application.authentication.framework.internal.FrameworkServiceDataHolder;
import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedIdPData;
import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser;
import org.wso2.carbon.identity.application.authentication.framework.model.CommonAuthResponseWrapper;
import org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants;
Expand Down Expand Up @@ -979,34 +978,21 @@ protected void findPreviousAuthenticatedSession(HttpServletRequest request, Auth
AuthenticatedUser authenticatedUser = previousAuthenticatedSeq.getAuthenticatedUser();

if (authenticatedUser != null) {
String authenticatedUserTenantDomain = authenticatedUser.getTenantDomain();
// Set the user for the current authentication/logout flow.
context.setSubject(authenticatedUser);

if (isUserAllowedToLogin(authenticatedUser)) {
String authenticatedUserTenantDomain = authenticatedUser.getTenantDomain();
// set the user for the current authentication/logout flow
context.setSubject(authenticatedUser);

if (log.isDebugEnabled()) {
log.debug("Already authenticated by username: " + authenticatedUser
.getAuthenticatedSubjectIdentifier());
}

if (authenticatedUserTenantDomain != null) {
// set the user tenant domain for the current authentication/logout flow
context.setProperty(USER_TENANT_DOMAIN, authenticatedUserTenantDomain);
if (log.isDebugEnabled()) {
log.debug("Already authenticated by username: " +
authenticatedUser.getAuthenticatedSubjectIdentifier());
}

if (log.isDebugEnabled()) {
log.debug("Authenticated user tenant domain: " + authenticatedUserTenantDomain);
}
}
} else {
if (authenticatedUserTenantDomain != null) {
// Set the user tenant domain for the current authentication/logout flow.
context.setProperty(USER_TENANT_DOMAIN, authenticatedUserTenantDomain);
if (log.isDebugEnabled()) {
log.debug(String.format("User %s is not allowed to authenticate from previous session.",
authenticatedUser.toString()));
log.debug("Authenticated user tenant domain: " + authenticatedUserTenantDomain);
}
context.setPreviousSessionFound(false);
FrameworkUtils.removeSessionContextFromCache(sessionContextKey,
context.getLoginTenantDomain());
sessionContext.setAuthenticatedIdPs(new HashMap<String, AuthenticatedIdPData>());
}
}
// This is done to reflect the changes done in SP to the sequence config. So, the requested claim
Expand Down
Loading

0 comments on commit 7a1ad73

Please sign in to comment.