Fix SSO related issues

remotes/1731000850486189418/master
tcdlpds 1 year ago
parent a17c5c27ab
commit f117e40fc9

@ -65,6 +65,7 @@ import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
import java.util.*;
import java.util.stream.Collectors;
/**
* This class represents an implementation of APIManagementProviderService.
@ -143,31 +144,29 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices();
try {
List<APIInfo> uniqueApiList = new ArrayList<>();
Map<String, String> headerParams = new HashMap<>();
if (!"carbon.super".equals(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true))) {
headerParams.put("X-WSO2-Tenant", "carbon.super");
}
Map <String, APIInfo> uniqueApiSet = new HashMap<>();
for (String tag : tags) {
Map<String, String> queryParams = new HashMap<>();
queryParams.put("tag", tag);
APIInfo[] apiInfos = consumerRESTAPIServices.getAllApis(tokenInfo, queryParams, headerParams);
uniqueApiList.addAll(List.of(apiInfos));
Set<APIInfo> taggedAPISet = new HashSet<>(uniqueApiList);
uniqueApiList.clear();
uniqueApiList.addAll(taggedAPISet);
Arrays.stream(apiInfos).forEach(apiInfo -> uniqueApiSet.putIfAbsent(apiInfo.getName(), apiInfo));
}
List<APIInfo> uniqueApiList = new ArrayList<>(uniqueApiSet.values());
io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications =
consumerRESTAPIServices.getAllApplications(tokenInfo, applicationName);
io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application;
MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService();
if (applications.length == 0) {
return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, validityTime);
return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType,
validityTime);
} else {
if (applications.length == 1) {
Optional<io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application> applicationOpt =

@ -222,7 +222,7 @@ public class SsoLoginHandler extends HttpServlet {
}
// Update the grant types of the application
String url = apiMgtUrl + HandlerConstants.APIM_APPLICATIONS_ENDPOINT + applicationId + "/keys/" +
String url = apiMgtUrl + HandlerConstants.APIM_APPLICATIONS_ENDPOINT + "/" + applicationId + "/keys/" +
HandlerConstants.PRODUCTION_KEY;
HttpPut updateApplicationGrantTypesEndpoint = new HttpPut(url);
updateApplicationGrantTypesEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER +

@ -26,7 +26,7 @@ public class HandlerConstants {
public static final String INTERNAL_TOKEN_ENDPOINT = "/token";
public static final String INTROSPECT_ENDPOINT = "/oauth2/introspect";
public static final String AUTHORIZATION_ENDPOINT = "/oauth2/authorize";
public static final String APIM_APPLICATIONS_ENDPOINT = "/api/am/devportal/v2/applications/";
public static final String APIM_APPLICATIONS_ENDPOINT = "/api/am/devportal/v3/applications";
public static final String IDENTITY_APP_MGT_ENDPOINT = "/services/IdentityApplicationManagementService.IdentityApplicationManagementServiceHttpsSoap11Endpoint";
public static final String LOGIN_PAGE = "/login";
public static final String SSO_LOGIN_CALLBACK = "/ssoLoginCallback";
@ -77,7 +77,7 @@ public class HandlerConstants {
public static final String OTP_HEADER = "one-time-token";
public static final String AX_PREFIX = "ax2251:";
public static final String AX_PREFIX = "ax2245:";
public static final String PAYLOADS_DIR = "repository/resources/payloads";
public static final String SOAP_ACTION_HEADER = "SOAPAction";
public static final String REFERER_HEADER = "Referer";

Loading…
Cancel
Save