Skip to content

Commit

Permalink
Merge pull request #12344 from tharindu1st/wss4j-removal
Browse files Browse the repository at this point in the history
Wss4j removal
  • Loading branch information
tharindu1st authored Mar 24, 2024
2 parents 9b6b651 + 1538e72 commit c52e6a0
Show file tree
Hide file tree
Showing 13 changed files with 173 additions and 113 deletions.
2 changes: 1 addition & 1 deletion components/apimgt/org.wso2.carbon.apimgt.gateway/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@
--add-exports java.base/sun.nio.cs=ALL-UNNAMED
</argLine>
<classpathDependencyExcludes>
<classpathDependencyExclude>org.wso2.org.ops4j.pax.logging:pax-logging-api</classpathDependencyExclude>
<classpathDependencyExclude>org.wso2.org.ops4j.pax.logging</classpathDependencyExclude>
<classpathDependencyExclude>org.wso2.orbit.com.fasterxml.jackson.core:jackson-core</classpathDependencyExclude>
</classpathDependencyExcludes>
<systemProperties>
Expand Down
16 changes: 2 additions & 14 deletions components/apimgt/org.wso2.carbon.apimgt.impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -223,24 +223,12 @@
<artifactId>hamcrest-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.governance</groupId>
<artifactId>org.wso2.carbon.governance.custom.lifecycles.checklist</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.poi.wso2</groupId>
<artifactId>poi-ooxml</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.governance</groupId>
<artifactId>org.wso2.carbon.governance.lcm</artifactId>
</dependency>

<dependency>
<groupId>org.wso2.carbon.event-processing</groupId>
<artifactId>org.wso2.carbon.event.processor.stub</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import org.wso2.carbon.apimgt.impl.importexport.ExportFormat;
import org.wso2.carbon.apimgt.impl.importexport.ImportExportAPI;
import org.wso2.carbon.apimgt.impl.internal.ServiceReferenceHolder;
import org.wso2.carbon.apimgt.impl.lifecycle.CheckListItem;
import org.wso2.carbon.apimgt.impl.monetization.DefaultMonetizationImpl;
import org.wso2.carbon.apimgt.impl.notification.NotificationDTO;
import org.wso2.carbon.apimgt.impl.notification.NotificationExecutor;
Expand Down Expand Up @@ -96,7 +97,6 @@
import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.databridge.commons.Event;
import org.wso2.carbon.governance.custom.lifecycles.checklist.util.CheckListItem;
import org.wso2.carbon.identity.application.common.model.IdentityProvider;
import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.user.api.UserStoreManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/*
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.apimgt.impl.lifecycle;
public class CheckListItem implements Comparable {
private String lifeCycleStatus;
private String name;
private String value;
private String order;
private String propertyName;
private String isVisible;
private static final Object HASH_CODE_OBJECT = new Object();

public String getVisible() {
return this.isVisible;
}

public void setVisible(String visible) {
this.isVisible = visible;
}

public String getPropertyName() {
return this.propertyName;
}

public void setPropertyName(String propertyName) {
this.propertyName = propertyName;
}

public String getLifeCycleStatus() {
return this.lifeCycleStatus;
}

public void setLifeCycleStatus(String lifeCycleStatus) {
this.lifeCycleStatus = lifeCycleStatus;
}

public String getName() {
return this.name;
}

public void setName(String name) {
this.name = name;
}

public String getValue() {
return this.value;
}

public void setValue(String value) {
this.value = value;
}

public String getOrder() {
return this.order;
}

public void setOrder(String order) {
this.order = order;
}

public CheckListItem(String lifeCycleStatus, String name, String value, String order) {
this.lifeCycleStatus = lifeCycleStatus;
this.name = name;
this.value = value;
this.order = order;
}

public CheckListItem() {
}

public boolean matchLifeCycleStatus(String status, boolean ignoreCase) {
if (this.lifeCycleStatus != null && status != null) {
return ignoreCase ? this.lifeCycleStatus.equalsIgnoreCase(status) : this.lifeCycleStatus.equals(status);
} else {
return false;
}
}

public boolean matchLifeCycleStatus(String status) {
return this.matchLifeCycleStatus(status, true);
}

public int hashCode() {
int hashCode = HASH_CODE_OBJECT.hashCode();
if (this.order != null) {
hashCode &= this.order.hashCode();
}

if (this.name != null) {
hashCode &= this.name.hashCode();
}

if (this.value != null) {
hashCode &= this.value.hashCode();
}

if (this.lifeCycleStatus != null) {
hashCode &= this.lifeCycleStatus.hashCode();
}

if (this.propertyName != null) {
hashCode &= this.propertyName.hashCode();
}

return hashCode;
}

public boolean equals(Object obj) {
if (!(obj instanceof CheckListItem)) {
return false;
} else {
CheckListItem item = (CheckListItem)obj;
return (this.order != null && this.order.equals(item.order) || this.order == null && item.order == null) && (this.lifeCycleStatus != null && this.lifeCycleStatus.equals(item.lifeCycleStatus) || this.lifeCycleStatus == null && item.lifeCycleStatus == null) && (this.name != null && this.name.equals(item.name) || this.name == null && item.name == null) && (this.value != null && this.value.equals(item.value) || this.value == null && item.value == null) && (this.propertyName != null && this.propertyName.equals(item.propertyName) || this.propertyName == null && item.propertyName == null);
}
}

public int compareTo(Object anotherItem) {
if (this.equals(anotherItem)) {
return 0;
} else {
CheckListItem item = (CheckListItem)anotherItem;
int otherItemOrder = Integer.parseInt(item.getOrder());
int itemOrder = Integer.parseInt(this.order);
return itemOrder - otherItemOrder;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,10 @@
import org.wso2.carbon.apimgt.impl.dto.ThrottleProperties;
import org.wso2.carbon.apimgt.impl.internal.ServiceReferenceHolder;
import org.wso2.carbon.apimgt.impl.loader.KeyManagerConfigurationDataRetriever;
import org.wso2.carbon.apimgt.impl.service.KeyMgtRegistrationService;
import org.wso2.carbon.apimgt.impl.utils.APIUtil;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.governance.lcm.util.CommonUtil;
import org.wso2.carbon.registry.core.exceptions.RegistryException;
import org.wso2.carbon.utils.AbstractAxis2ConfigurationContextObserver;

import java.io.FileNotFoundException;

import javax.xml.stream.XMLStreamException;

/**
* This task provisions mandatory configs & Artifacts needed by any tenant. The reason for introducing this task is
* to prevent {@link org.wso2.carbon.apimgt.impl.observers.TenantServiceCreator} class being run on None-synapse
Expand Down Expand Up @@ -124,17 +117,6 @@ public void run() {
} catch (Exception e) { // The generic Exception is handled explicitly so execution does not stop during config deployment
log.error("Exception when creating default roles for tenant " + tenantDomain, e);
}
try {
CommonUtil.addDefaultLifecyclesIfNotAvailable(ServiceReferenceHolder.getInstance().getRegistryService()
.getConfigSystemRegistry(tenantId), CommonUtil
.getRootSystemRegistry(tenantId));
} catch (RegistryException e) {
log.error("Error while accessing registry", e);
} catch (FileNotFoundException e) {
log.error("Error while find lifecycle.xml", e);
} catch (XMLStreamException e) {
log.error("Error while parsing Lifecycle.xml", e);
}
KeyManagerConfigurationDataRetriever keyManagerConfigurationDataRetriever =
new KeyManagerConfigurationDataRetriever(tenantDomain);
keyManagerConfigurationDataRetriever.startLoadKeyManagerConfigurations();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.mockito.Mockito;
import org.mockito.stubbing.Answer;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.junit4.PowerMockRunner;
Expand Down Expand Up @@ -105,7 +104,6 @@
import org.wso2.carbon.governance.api.generic.GenericArtifactManager;
import org.wso2.carbon.governance.api.generic.dataobjects.GenericArtifact;
import org.wso2.carbon.governance.api.util.GovernanceUtils;
import org.wso2.carbon.governance.custom.lifecycles.checklist.util.LifecycleBeanPopulator;
import org.wso2.carbon.registry.core.Collection;
import org.wso2.carbon.registry.core.Registry;
import org.wso2.carbon.registry.core.Resource;
Expand Down Expand Up @@ -152,7 +150,7 @@
@SuppressStaticInitializationFor("org.wso2.carbon.context.PrivilegedCarbonContext")
@PrepareForTest({ ServiceReferenceHolder.class, ApiMgtDAO.class, APIUtil.class, APIGatewayManager.class,
GovernanceUtils.class, PrivilegedCarbonContext.class, WorkflowExecutorFactory.class, JavaUtils.class,
APIProviderImpl.class, APIManagerFactory.class, RegistryUtils.class, LifecycleBeanPopulator.class,
APIProviderImpl.class, APIManagerFactory.class, RegistryUtils.class,
Caching.class, PaginationContext.class, MultitenantUtils.class, AbstractAPIManager.class, OASParserUtil.class,
KeyManagerHolder.class, CertificateManagerImpl.class , PublisherAPI.class, Organization.class,
APIPersistence.class, GatewayArtifactsMgtDAO.class, RegistryPersistenceUtil.class})
Expand Down Expand Up @@ -183,7 +181,6 @@ public void init() throws Exception {
PowerMockito.mockStatic(RegistryUtils.class);
PowerMockito.mockStatic(GovernanceUtils.class);
PowerMockito.mockStatic(WorkflowExecutorFactory.class);
PowerMockito.mockStatic(LifecycleBeanPopulator.class);
PowerMockito.mockStatic(KeyManagerHolder.class);
PowerMockito.mockStatic(Caching.class);
PowerMockito.mockStatic(PaginationContext.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,20 @@
import org.wso2.carbon.apimgt.impl.internal.ServiceReferenceHolder;
import org.wso2.carbon.apimgt.impl.utils.APIUtil;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.governance.lcm.util.CommonUtil;
import org.wso2.carbon.registry.core.service.RegistryService;

import static org.wso2.carbon.base.CarbonBaseConstants.CARBON_HOME;


@RunWith(PowerMockRunner.class)
@PrepareForTest({APIUtil.class, PrivilegedCarbonContext.class, ServiceReferenceHolder.class, CommonUtil.class})
@PrepareForTest({APIUtil.class, PrivilegedCarbonContext.class, ServiceReferenceHolder.class})
public class CommonConfigDeployerTestCase {

private final int TENANT_ID = 1234;
private final String TENANT_DOMAIN = "foo.com";

@Test
public void testCreatedConfigurationContext() throws APIManagementException {
PowerMockito.mockStatic(CommonUtil.class);
System.setProperty(CARBON_HOME, "");
PrivilegedCarbonContext privilegedCarbonContext = Mockito.mock(PrivilegedCarbonContext.class);
PowerMockito.mockStatic(PrivilegedCarbonContext.class);
Expand Down Expand Up @@ -84,16 +82,12 @@ public void testCreatedConfigurationContext() throws APIManagementException {

PowerMockito.verifyStatic(APIUtil.class);
APIUtil.loadAndSyncTenantConf(TENANT_DOMAIN);

//PowerMockito.verifyStatic(APIUtil.class);
//APIUtil.addDefaultTenantAdvancedThrottlePolicies(TENANT_DOMAIN, TENANT_ID);
}


@Test
public void testExceptions() throws Exception {
PowerMockito.mockStatic(APIUtil.class);
PowerMockito.mockStatic(CommonUtil.class);
System.setProperty(CARBON_HOME, "");
PrivilegedCarbonContext privilegedCarbonContext = Mockito.mock(PrivilegedCarbonContext.class);
PowerMockito.mockStatic(PrivilegedCarbonContext.class);
Expand Down Expand Up @@ -144,7 +138,6 @@ public void testExceptions() throws Exception {
@Test
public void testCreatedConfigurationContextRuntimeException() throws APIManagementException {
System.setProperty(CARBON_HOME, "");
PowerMockito.mockStatic(CommonUtil.class);
PrivilegedCarbonContext privilegedCarbonContext = Mockito.mock(PrivilegedCarbonContext.class);
PowerMockito.mockStatic(PrivilegedCarbonContext.class);
PowerMockito.when(PrivilegedCarbonContext.getThreadLocalCarbonContext()).thenReturn(privilegedCarbonContext);
Expand Down
28 changes: 16 additions & 12 deletions components/apimgt/org.wso2.carbon.apimgt.persistence/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
<Import-Package>
org.apache.commons.logging.*; version="${import.package.version.commons.logging}",
org.wso2.carbon.registry.core.*; version="${carbon.registry.imp.pkg.version}",
org.wso2.carbon.governance.lcm.* version="${carbon.governance.version}",
org.apache.cxf.jaxrs.ext.multipart.* version="${cxf.version}"
</Import-Package>
<DynamicImport-Package>*</DynamicImport-Package>
Expand Down Expand Up @@ -100,17 +99,22 @@
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.registry.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.governance</groupId>
<artifactId>org.wso2.carbon.governance.lcm</artifactId>
<exclusions>
<exclusion>
<groupId>jboss</groupId>
<artifactId>javassist</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.wso2.carbon.governance</groupId>
<artifactId>org.wso2.carbon.governance.api</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.registry</groupId>
<artifactId>org.wso2.carbon.registry.indexing</artifactId>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>org.wso2.carbon.apimgt.api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3080,7 +3080,6 @@ protected RegistryHolder getRegistry(String requestedTenantDomain) throws APIPer
loadTenantRegistry(tenantId);
registry = getRegistryService().getGovernanceSystemRegistry(tenantId);
RegistryPersistenceUtil.loadloadTenantAPIRXT(null, tenantId);
RegistryPersistenceUtil.addLifecycleIfNotExists(tenantId);
RegistryPersistenceUtil.registerCustomQueries(registry, null, userTenantDomain);
holder.setTenantId(tenantId);
}
Expand All @@ -3089,7 +3088,6 @@ protected RegistryHolder getRegistry(String requestedTenantDomain) throws APIPer
loadTenantRegistry(tenantId);
registry = getRegistryService().getGovernanceSystemRegistry(tenantId);
RegistryPersistenceUtil.loadloadTenantAPIRXT(null, tenantId);
RegistryPersistenceUtil.addLifecycleIfNotExists(tenantId);
RegistryPersistenceUtil.registerCustomQueries(registry, null, userTenantDomain);
holder.setTenantId(tenantId);
}
Expand Down Expand Up @@ -3151,7 +3149,6 @@ protected RegistryHolder getRegistry(String username, String requestedTenantDoma
holder.setTenantId(tenantId);
}
RegistryPersistenceUtil.registerCustomQueries(configRegistry, username, userTenantDomain);
RegistryPersistenceUtil.addLifecycleIfNotExists(tenantId);
} catch (RegistryException | UserStoreException | PersistenceException e) {
String msg = "Failed to get API";
throw new APIPersistenceException(msg, e);
Expand Down
Loading

0 comments on commit c52e6a0

Please sign in to comment.