|
|
@ -28,6 +28,7 @@ import org.wso2.carbon.apimgt.impl.utils.APIUtil;
|
|
|
|
import org.wso2.carbon.apimgt.webapp.publisher.config.APIResource;
|
|
|
|
import org.wso2.carbon.apimgt.webapp.publisher.config.APIResource;
|
|
|
|
import org.wso2.carbon.apimgt.webapp.publisher.config.APIResourceConfiguration;
|
|
|
|
import org.wso2.carbon.apimgt.webapp.publisher.config.APIResourceConfiguration;
|
|
|
|
import org.wso2.carbon.apimgt.webapp.publisher.config.WebappPublisherConfig;
|
|
|
|
import org.wso2.carbon.apimgt.webapp.publisher.config.WebappPublisherConfig;
|
|
|
|
|
|
|
|
import org.wso2.carbon.apimgt.webapp.publisher.lifecycle.util.AnnotationProcessor;
|
|
|
|
import org.wso2.carbon.base.MultitenantConstants;
|
|
|
|
import org.wso2.carbon.base.MultitenantConstants;
|
|
|
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
|
|
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
|
|
|
import org.wso2.carbon.core.util.Utils;
|
|
|
|
import org.wso2.carbon.core.util.Utils;
|
|
|
@ -51,6 +52,9 @@ public class APIPublisherUtil {
|
|
|
|
private static final String PARAM_SHARED_WITH_ALL_TENANTS = "isSharedWithAllTenants";
|
|
|
|
private static final String PARAM_SHARED_WITH_ALL_TENANTS = "isSharedWithAllTenants";
|
|
|
|
private static final String PARAM_PROVIDER_TENANT_DOMAIN = "providerTenantDomain";
|
|
|
|
private static final String PARAM_PROVIDER_TENANT_DOMAIN = "providerTenantDomain";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final String NON_SECURED_RESOURCES = "nonSecuredEndPoints";
|
|
|
|
|
|
|
|
private static final String AUTH_TYPE_NON_SECURED = "None";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static API getAPI(APIConfig config) throws APIManagementException {
|
|
|
|
public static API getAPI(APIConfig config) throws APIManagementException {
|
|
|
|
|
|
|
|
|
|
|
@ -313,4 +317,29 @@ public class APIPublisherUtil {
|
|
|
|
return apiConfig;
|
|
|
|
return apiConfig;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void setResourceAuthTypes(ServletContext servletContext, APIConfig apiConfig) {
|
|
|
|
|
|
|
|
List<String> resourcesList = null;
|
|
|
|
|
|
|
|
String nonSecuredResources = servletContext.getInitParameter(NON_SECURED_RESOURCES);
|
|
|
|
|
|
|
|
if(null != nonSecuredResources){
|
|
|
|
|
|
|
|
resourcesList = Arrays.asList(nonSecuredResources.split(","));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Set<URITemplate> templates = apiConfig.getUriTemplates();
|
|
|
|
|
|
|
|
if(null != resourcesList) {
|
|
|
|
|
|
|
|
for (URITemplate template : templates) {
|
|
|
|
|
|
|
|
String fullPaath = "";
|
|
|
|
|
|
|
|
if( template.getUriTemplate() != AnnotationProcessor.WILD_CARD ) {
|
|
|
|
|
|
|
|
fullPaath = apiConfig.getContext() + template.getUriTemplate();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
fullPaath = apiConfig.getContext();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for(String context : resourcesList) {
|
|
|
|
|
|
|
|
if (context.trim().equals(fullPaath)) {
|
|
|
|
|
|
|
|
template.setAuthType(AUTH_TYPE_NON_SECURED);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|