Skip to content

Commit

Permalink
Merge branch 'wso2:master' into add-cutsom-auth-configs-service-support
Browse files Browse the repository at this point in the history
  • Loading branch information
Thisara-Welmilla authored Dec 1, 2024
2 parents 7cbfc23 + 366a820 commit 35f1e25
Show file tree
Hide file tree
Showing 236 changed files with 540 additions and 251 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.7.8-SNAPSHOT</version>
<version>7.7.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ 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) {
LOG.debug("Skip executing actions for action type: " + actionType.name(), e);
Expand All @@ -138,7 +137,6 @@ 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) {
Expand Down Expand Up @@ -168,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 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.7.8-SNAPSHOT</version>
<version>7.7.12-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.7.8-SNAPSHOT</version>
<version>7.7.12-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.7.8-SNAPSHOT</version>
<version>7.7.12-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.7.8-SNAPSHOT</version>
<version>7.7.12-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.7.8-SNAPSHOT</version>
<version>7.7.12-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.7.8-SNAPSHOT</version>
<version>7.7.12-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.7.8-SNAPSHOT</version>
<version>7.7.12-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.7.8-SNAPSHOT</version>
<version>7.7.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>org.wso2.carbon.identity.application.mgt</artifactId>
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.7.8-SNAPSHOT</version>
<version>7.7.12-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.7.8-SNAPSHOT</version>
<version>7.7.12-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.7.8-SNAPSHOT</version>
<version>7.7.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion components/authentication-framework/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.7.8-SNAPSHOT</version>
<version>7.7.12-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion components/captcha-mgt/org.wso2.carbon.captcha.mgt/pom.xml
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>captcha-mgt</artifactId>
<version>7.7.8-SNAPSHOT</version>
<version>7.7.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion components/captcha-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.7.8-SNAPSHOT</version>
<version>7.7.12-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion components/carbon-authenticators/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<parent>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>identity-framework</artifactId>
<version>7.7.8-SNAPSHOT</version>
<version>7.7.12-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>thrift-authenticator</artifactId>
<version>7.7.8-SNAPSHOT</version>
<version>7.7.12-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>carbon-authenticators</artifactId>
<version>7.7.8-SNAPSHOT</version>
<version>7.7.12-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>
<artifactId>central-logger</artifactId>
<groupId>org.wso2.carbon.identity.framework</groupId>
<version>7.7.8-SNAPSHOT</version>
<version>7.7.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion components/central-logger/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<artifactId>identity-framework</artifactId>
<groupId>org.wso2.carbon.identity.framework</groupId>
<version>7.7.8-SNAPSHOT</version>
<version>7.7.12-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>certificate-mgt</artifactId>
<version>7.7.8-SNAPSHOT</version>
<version>7.7.12-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion components/certificate-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.7.8-SNAPSHOT</version>
<version>7.7.12-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion components/claim-mgt/org.wso2.carbon.claim.mgt.ui/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>claim-mgt</artifactId>
<version>7.7.8-SNAPSHOT</version>
<version>7.7.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion components/claim-mgt/org.wso2.carbon.claim.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>claim-mgt</artifactId>
<version>7.7.8-SNAPSHOT</version>
<version>7.7.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
import org.wso2.carbon.identity.claim.metadata.mgt.util.ClaimConstants;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;

import static org.wso2.carbon.identity.claim.metadata.mgt.util.ClaimConstants.ErrorMessage.ERROR_CODE_NON_EXISTING_LOCAL_CLAIM_URI;
Expand Down Expand Up @@ -163,9 +165,9 @@ public List<LocalClaim> getLocalClaims(int tenantId) throws ClaimMetadataExcepti
.findFirst();

if (matchingClaimInDB.isPresent()) {
matchingClaimInDB.get().setClaimProperty(ClaimConstants.IS_SYSTEM_CLAIM, Boolean.TRUE.toString());
markAsSystemClaim(matchingClaimInDB.get());
} else {
systemClaim.setClaimProperty(ClaimConstants.IS_SYSTEM_CLAIM, Boolean.TRUE.toString());
markAsSystemClaim(systemClaim);
allLocalClaims.add(systemClaim);
}
});
Expand All @@ -186,13 +188,13 @@ public Optional<LocalClaim> getLocalClaim(String localClaimURI, int tenantId) th
Optional<LocalClaim> localClaimInDB = this.dbBasedClaimMetadataManager.getLocalClaim(localClaimURI, tenantId);
if (localClaimInDB.isPresent()) {
if (isSystemDefaultLocalClaim(localClaimURI, tenantId)) {
localClaimInDB.get().setClaimProperty(ClaimConstants.IS_SYSTEM_CLAIM, Boolean.TRUE.toString());
markAsSystemClaim(localClaimInDB.get());
}
return localClaimInDB;
}
Optional<LocalClaim> localClaimInSystem = this.systemDefaultClaimMetadataManager.getLocalClaim(localClaimURI, tenantId);
if (localClaimInSystem.isPresent()) {
localClaimInSystem.get().setClaimProperty(ClaimConstants.IS_SYSTEM_CLAIM, Boolean.TRUE.toString());
markAsSystemClaim(localClaimInSystem.get());
return localClaimInSystem;
}
return Optional.empty();
Expand Down Expand Up @@ -300,17 +302,26 @@ public List<ExternalClaim> getExternalClaims(String externalClaimDialectURI, int
List<ExternalClaim> externalClaimsInDB = this.dbBasedClaimMetadataManager.getExternalClaims(
externalClaimDialectURI, tenantId);

Map<String, ExternalClaim> externalClaimsInDBMap = externalClaimsInDB.stream()
.collect(Collectors.toMap(ExternalClaim::getClaimURI, claim -> claim));

Map<String, ExternalClaim> externalClaimsInDBMap = new HashMap<>();
Map<String, ExternalClaim> mappedLocalClaimInDBMap = new HashMap<>();
externalClaimsInDB.forEach(claim -> {
externalClaimsInDBMap.put(claim.getClaimURI(), claim);
mappedLocalClaimInDBMap.put(claim.getMappedLocalClaim(), claim);
});
/*
* If a system claim is also in the DB, then the claim retrieved from the DB gets the priority.
* Also, if there is a system claim that is mapped to the same local claim as another external claim in the same
* dialect, then we do not enforce the system claim on the tenant because that would violate the constraint of
* having a unique claim mapping within the dialect. This is to preserve backward-compatibility.
*/
List<ExternalClaim> allExternalClaims = new ArrayList<>();
for (ExternalClaim externalClaimInSystem : externalClaimsInSystem) {
ExternalClaim matchingClaimInDB = externalClaimsInDBMap.get(externalClaimInSystem.getClaimURI());
if (matchingClaimInDB != null) {
matchingClaimInDB.setClaimProperty(ClaimConstants.IS_SYSTEM_CLAIM, Boolean.TRUE.toString());
markAsSystemClaim(matchingClaimInDB);
allExternalClaims.add(matchingClaimInDB);
externalClaimsInDBMap.remove(externalClaimInSystem.getClaimURI());
} else {
} else if (!mappedLocalClaimInDBMap.containsKey(externalClaimInSystem.getMappedLocalClaim())) {
externalClaimInSystem.setClaimProperty(ClaimConstants.IS_SYSTEM_CLAIM, Boolean.TRUE.toString());
allExternalClaims.add(externalClaimInSystem);
}
Expand All @@ -331,18 +342,29 @@ public List<ExternalClaim> getExternalClaims(String externalClaimDialectURI, int
public Optional<ExternalClaim> getExternalClaim(String externalClaimDialectURI, String claimURI, int tenantId)
throws ClaimMetadataException {

Optional<ExternalClaim> externalClaim = this.dbBasedClaimMetadataManager.getExternalClaim(
externalClaimDialectURI, claimURI, tenantId);
List<ExternalClaim> externalClaimsInDB = this.dbBasedClaimMetadataManager.getExternalClaims(
externalClaimDialectURI, tenantId);
Optional<ExternalClaim> externalClaim = Optional.empty();
Map<String, ExternalClaim> mappedLocalClaimInDBMap = new HashMap<>();

for (ExternalClaim claim : externalClaimsInDB) {
if (claim.getClaimURI().equals(claimURI)) {
externalClaim = Optional.of(claim);
}
mappedLocalClaimInDBMap.put(claim.getMappedLocalClaim(), claim);
}
if (externalClaim.isPresent()) {
if (isSystemDefaultExternalClaim(externalClaimDialectURI, claimURI, tenantId)) {
externalClaim.get().setClaimProperty(ClaimConstants.IS_SYSTEM_CLAIM, Boolean.TRUE.toString());
markAsSystemClaim(externalClaim.get());
}
return externalClaim;
}

Optional<ExternalClaim> externalClaimInSystem = this.systemDefaultClaimMetadataManager.getExternalClaim(
externalClaimDialectURI, claimURI, tenantId);
if (externalClaimInSystem.isPresent()) {
externalClaimInSystem.get().setClaimProperty(ClaimConstants.IS_SYSTEM_CLAIM, Boolean.TRUE.toString());
if (externalClaimInSystem.isPresent()
&& !mappedLocalClaimInDBMap.containsKey(externalClaimInSystem.get().getMappedLocalClaim())) {
markAsSystemClaim(externalClaimInSystem.get());
return externalClaimInSystem;
}
return Optional.empty();
Expand Down Expand Up @@ -573,4 +595,9 @@ private void addSystemDefaultLocalClaimToDB(String claimURI, int tenantId)
this.dbBasedClaimMetadataManager.addLocalClaim(claimInSystem.get(), tenantId);
}
}

private void markAsSystemClaim(Claim claim) {

claim.setClaimProperty(ClaimConstants.IS_SYSTEM_CLAIM, Boolean.TRUE.toString());
}
}
Loading

0 comments on commit 35f1e25

Please sign in to comment.