Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update URL placeholders #206

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.event</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.application.authentication.framework</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static org.wso2.carbon.identity.core.util.IdentityTenantUtil.isSuperTenantRequiredInUrl;
import static org.wso2.carbon.identity.event.handler.notification.NotificationConstants.EmailNotification.ACCOUNT_RECOVERY_ENDPOINT_PLACEHOLDER;
import static org.wso2.carbon.identity.event.handler.notification.NotificationConstants.EmailNotification.AUTHENTICATION_ENDPOINT_PLACEHOLDER;
import static org.wso2.carbon.identity.event.handler.notification.NotificationConstants.EmailNotification.BRANDING_PREFERENCES_COPYRIGHT_TEXT_PATH;
Expand All @@ -94,6 +95,7 @@
import static org.wso2.carbon.identity.event.handler.notification.NotificationConstants.EmailNotification.ORGANIZATION_NAME_PLACEHOLDER;
import static org.wso2.carbon.identity.event.handler.notification.NotificationConstants.TENANT_DOMAIN;
import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_ORGANIZATION_NOT_FOUND_FOR_TENANT;
import static org.wso2.carbon.utils.multitenancy.MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;

public class NotificationUtil {

Expand Down Expand Up @@ -274,12 +276,17 @@ public static Map<String, String> getPlaceholderValues(EmailTemplate emailTempla
// Building the server url.
String serverURL;
String carbonUrlWithUserTenant;
String accountRecoveryEndpointURL = ConfigurationFacade.getInstance().getAccountRecoveryEndpointPath();
String authenticationEndpointURL = ConfigurationFacade.getInstance().getAuthenticationEndpointURL();
String accountRecoveryEndpointURL = ConfigurationFacade.getInstance().getAccountRecoveryEndpointAbsolutePath();
String authenticationEndpointURL = ConfigurationFacade.getInstance().getAuthenticationEndpointAbsoluteURL();
try {
serverURL = ServiceURLBuilder.create().build().getAbsolutePublicURL();
carbonUrlWithUserTenant = ServiceURLBuilder.create().build().getAbsolutePublicUrlWithoutPath();
if (IdentityTenantUtil.isTenantQualifiedUrlsEnabled()) {

if (IdentityTenantUtil.isTenantQualifiedUrlsEnabled() &&
(isSuperTenantRequiredInUrl()
|| !SUPER_TENANT_DOMAIN_NAME.equalsIgnoreCase(placeHolderData.get(TENANT_DOMAIN)))) {
// If tenant domain is carbon.super, and super tenant is not required in the URL,
// then the tenant domain should not be appended.
carbonUrlWithUserTenant = ServiceURLBuilder.create().build().getAbsolutePublicUrlWithoutPath() + "/t" +
"/" + placeHolderData.get(TENANT_DOMAIN);
}
Expand Down Expand Up @@ -660,7 +667,7 @@ private static String resolveHumanReadableOrganizationName(String tenantDomain)

String organizationName = tenantDomain;
try {
if (MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
if (SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
return organizationName;
}
RealmService realmService = NotificationHandlerDataHolder.getInstance().getRealmService();
Expand Down
Loading
Loading