Skip to content

Commit

Permalink
remove the framework dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Manchiz committed Jun 26, 2024
1 parent bc76ebb commit 32a19ff
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public class IdentityRecoveryConstants {
"http://wso2.org/claims/identity/failedLoginLockoutCount";
public static final String ACCOUNT_CONFIRMED_TIME_CLAIM = "http://wso2.org/claims/identity/accountConfirmedTime";


public static final String FUNCTION_LOCKOUT_COUNT_PROPERTY = "LockoutCount";
public static final String FUNCTION_FAILED_ATTEMPTS_PROPERTY = "FailedAttempts";
public static final String FUNCTION_MAX_ATTEMPTS_PROPERTY = "MaxAttempts";
Expand Down Expand Up @@ -826,6 +827,10 @@ public static class Consent {
public static final String PURPOSE_ID = "purposeId";
public static final String INFINITE_TERMINATION = "DATE_UNTIL:INDEFINITE";
public static final String RESIDENT_IDP = "Resident IDP";

//This is used for retrieve SP-UUID from the event.
//To-DO: onc ethe framework version bump to 7.3.14.x or above use the constant from framework insted of this.
public static final String SERVICE_PROVIDER_UUID = "serviceProviderUUID";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,12 @@ private void validateRequestAttributes(User recoveredUser, RecoveryScenarios sce
private void triggerNotification(User user, String notificationChannel, String templateName, String code,
String eventName, Property[] metaProperties) throws IdentityRecoveryException {

String serviceProviderUUID = (String) IdentityUtil.threadLocalProperties.get().get(IdentityEventConstants.EventProperty.SERVICE_PROVIDER_UUID);
String serviceProviderUUID = (String) IdentityUtil.threadLocalProperties.get().get(IdentityRecoveryConstants.Consent.SERVICE_PROVIDER_UUID);

HashMap<String, Object> properties = new HashMap<>();
if (!serviceProviderUUID.isBlank()) {
properties.put(IdentityEventConstants.EventProperty.SERVICE_PROVIDER_UUID, serviceProviderUUID);
properties.put(IdentityRecoveryConstants.Consent.SERVICE_PROVIDER_UUID
, serviceProviderUUID);
}
properties.put(IdentityEventConstants.EventProperty.USER_NAME, user.getUserName());
properties.put(IdentityEventConstants.EventProperty.TENANT_DOMAIN, user.getTenantDomain());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,12 @@ private void triggerNotification(User user, String type, String code, Property[]

String eventName = IdentityEventConstants.Event.TRIGGER_NOTIFICATION;

String serviceProviderUUID = (String) IdentityUtil.threadLocalProperties.get().get(IdentityEventConstants.EventProperty.SERVICE_PROVIDER_UUID);
String serviceProviderUUID = (String) IdentityUtil.threadLocalProperties.get().get(IdentityRecoveryConstants.Consent.SERVICE_PROVIDER_UUID);

HashMap<String, Object> properties = new HashMap<>();
if (!serviceProviderUUID.isBlank()) {
properties.put(IdentityEventConstants.EventProperty.SERVICE_PROVIDER_UUID, serviceProviderUUID);
properties.put(IdentityRecoveryConstants.Consent.SERVICE_PROVIDER_UUID
, serviceProviderUUID);
}
properties.put(IdentityEventConstants.EventProperty.USER_NAME, user.getUserName());
properties.put(IdentityEventConstants.EventProperty.TENANT_DOMAIN, user.getTenantDomain());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,12 @@ private void triggerNotification(User user, String notificationChannel, String c
log.debug("Sending self user registration notification user: " + user.getUserName());
}

String serviceProviderUUID = (String) IdentityUtil.threadLocalProperties.get().get(IdentityEventConstants.EventProperty.SERVICE_PROVIDER_UUID);
String serviceProviderUUID = (String) IdentityUtil.threadLocalProperties.get().get(IdentityRecoveryConstants.Consent.SERVICE_PROVIDER_UUID);

HashMap<String, Object> properties = new HashMap<>();
if (!serviceProviderUUID.isBlank()) {
properties.put(IdentityEventConstants.EventProperty.SERVICE_PROVIDER_UUID, serviceProviderUUID);
properties.put(IdentityRecoveryConstants.Consent.SERVICE_PROVIDER_UUID
, serviceProviderUUID);
}
properties.put(IdentityEventConstants.EventProperty.USER_NAME, user.getUserName());
properties.put(IdentityEventConstants.EventProperty.TENANT_DOMAIN, user.getTenantDomain());
Expand Down Expand Up @@ -461,11 +462,12 @@ private void triggerNotification(User user, String notificationChannel, String c
private void triggerAccountCreationNotification(User user) throws IdentityRecoveryServerException {
String eventName = IdentityEventConstants.Event.TRIGGER_NOTIFICATION;

String serviceProviderUUID = (String) IdentityUtil.threadLocalProperties.get().get(IdentityEventConstants.EventProperty.SERVICE_PROVIDER_UUID);
String serviceProviderUUID = (String) IdentityUtil.threadLocalProperties.get().get(IdentityRecoveryConstants.Consent.SERVICE_PROVIDER_UUID);

HashMap<String, Object> properties = new HashMap<>();
if (!serviceProviderUUID.isBlank()) {
properties.put(IdentityEventConstants.EventProperty.SERVICE_PROVIDER_UUID, serviceProviderUUID);
properties.put(IdentityRecoveryConstants.Consent.SERVICE_PROVIDER_UUID
, serviceProviderUUID);
}
properties.put(IdentityEventConstants.EventProperty.USER_NAME, user.getUserName());
properties.put(IdentityEventConstants.EventProperty.TENANT_DOMAIN, user.getTenantDomain());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.wso2.carbon.identity.base.IdentityConstants;
import org.wso2.carbon.identity.core.util.IdentityTenantUtil;
import org.wso2.carbon.identity.core.util.IdentityUtil;
import org.wso2.carbon.identity.event.IdentityEventConstants;
import org.wso2.carbon.identity.event.IdentityEventException;
import org.wso2.carbon.identity.governance.service.notification.NotificationChannels;
import org.wso2.carbon.identity.recovery.IdentityRecoveryClientException;
Expand Down Expand Up @@ -441,9 +440,10 @@ private NotificationResponseBean notifyUser(User user, String notificationChanne
boolean manageNotificationInternally, Map<String, String> properties)
throws IdentityRecoveryException {

String serviceProviderUUID = (String) IdentityUtil.threadLocalProperties.get().get(IdentityEventConstants.EventProperty.SERVICE_PROVIDER_UUID);
String serviceProviderUUID = (String) IdentityUtil.threadLocalProperties.get().get(IdentityRecoveryConstants.Consent.SERVICE_PROVIDER_UUID);
if (!serviceProviderUUID.isBlank()) {
properties.put(IdentityEventConstants.EventProperty.SERVICE_PROVIDER_UUID, serviceProviderUUID);
properties.put(IdentityRecoveryConstants.Consent.SERVICE_PROVIDER_UUID
, serviceProviderUUID);
}

Property[] metaProperties = buildPropertyList(notificationChannel, properties);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@
<carbon.kernel.registry.imp.pkg.version.range>[1.0.1, 2.0.0)</carbon.kernel.registry.imp.pkg.version.range>

<!--Carbon Identity Framework Version-->
<carbon.identity.framework.version>5.25.707</carbon.identity.framework.version>
<carbon.identity.framework.version>5.25.623</carbon.identity.framework.version>
<carbon.identity.framework.imp.pkg.version.range>[5.20.211, 8.0.0)
</carbon.identity.framework.imp.pkg.version.range>

Expand Down

0 comments on commit 32a19ff

Please sign in to comment.