diff --git a/.github/badges/jacoco.svg b/.github/badges/jacoco.svg index e3af9ca..c357eba 100644 --- a/.github/badges/jacoco.svg +++ b/.github/badges/jacoco.svg @@ -1 +1 @@ -coverage67.8% \ No newline at end of file +coverage69.3% \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 94f3f34..a6dee6d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,11 +7,11 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up JDK 8 - uses: actions/setup-java@v2 + - uses: actions/checkout@v4 + - name: Set up JDK 11 + uses: actions/setup-java@v4 with: - java-version: '8' + java-version: '11' distribution: 'zulu' - name: Build with Maven run: mvn verify diff --git a/lib/axway/apigw-common/7.7.0.20240530-1/apigw-common-7.7.0.20240530-1.jar b/lib/axway/apigw-common/7.7.0.20240530-1/apigw-common-7.7.0.20240530-1.jar new file mode 100644 index 0000000..908b658 Binary files /dev/null and b/lib/axway/apigw-common/7.7.0.20240530-1/apigw-common-7.7.0.20240530-1.jar differ diff --git a/lib/axway/es-core/7.7.0.20240530-1/es-core-7.7.0.20240530-1.jar b/lib/axway/es-core/7.7.0.20240530-1/es-core-7.7.0.20240530-1.jar new file mode 100644 index 0000000..6362cb5 Binary files /dev/null and b/lib/axway/es-core/7.7.0.20240530-1/es-core-7.7.0.20240530-1.jar differ diff --git a/lib/axway/resource-repo/7.7.0.20240530-1/resource-repo-7.7.0.20240530-1.jar b/lib/axway/resource-repo/7.7.0.20240530-1/resource-repo-7.7.0.20240530-1.jar new file mode 100644 index 0000000..48fdf8a Binary files /dev/null and b/lib/axway/resource-repo/7.7.0.20240530-1/resource-repo-7.7.0.20240530-1.jar differ diff --git a/lib/axway/vordel-apigateway/7.7.0.20240530-1/vordel-apigateway-7.7.0.20240530-1.jar b/lib/axway/vordel-apigateway/7.7.0.20240530-1/vordel-apigateway-7.7.0.20240530-1.jar new file mode 100644 index 0000000..f6a9564 Binary files /dev/null and b/lib/axway/vordel-apigateway/7.7.0.20240530-1/vordel-apigateway-7.7.0.20240530-1.jar differ diff --git a/lib/axway/vordel-common/7.7.0.20240530-1/vordel-common-7.7.0.20240530-1.jar b/lib/axway/vordel-common/7.7.0.20240530-1/vordel-common-7.7.0.20240530-1.jar new file mode 100644 index 0000000..11aabb0 Binary files /dev/null and b/lib/axway/vordel-common/7.7.0.20240530-1/vordel-common-7.7.0.20240530-1.jar differ diff --git a/lib/axway/vordel-config/7.7.0.20240530-1/vordel-config-7.7.0.20240530-1.jar b/lib/axway/vordel-config/7.7.0.20240530-1/vordel-config-7.7.0.20240530-1.jar new file mode 100644 index 0000000..2f39a79 Binary files /dev/null and b/lib/axway/vordel-config/7.7.0.20240530-1/vordel-config-7.7.0.20240530-1.jar differ diff --git a/lib/axway/vordel-core-runtime/7.7.0.20240530-1/vordel-core-runtime-7.7.0.20240530-1.jar b/lib/axway/vordel-core-runtime/7.7.0.20240530-1/vordel-core-runtime-7.7.0.20240530-1.jar new file mode 100644 index 0000000..e64f1e3 Binary files /dev/null and b/lib/axway/vordel-core-runtime/7.7.0.20240530-1/vordel-core-runtime-7.7.0.20240530-1.jar differ diff --git a/lib/axway/vordel-system/7.7.0.20240530-1/vordel-system-7.7.0.20240530-1.jar b/lib/axway/vordel-system/7.7.0.20240530-1/vordel-system-7.7.0.20240530-1.jar new file mode 100644 index 0000000..fc3bf2e Binary files /dev/null and b/lib/axway/vordel-system/7.7.0.20240530-1/vordel-system-7.7.0.20240530-1.jar differ diff --git a/lib/axway/vordel-trace/7.7.0.20240530-1/vordel-trace-7.7.0.20240530-1.jar b/lib/axway/vordel-trace/7.7.0.20240530-1/vordel-trace-7.7.0.20240530-1.jar new file mode 100644 index 0000000..e31cc00 Binary files /dev/null and b/lib/axway/vordel-trace/7.7.0.20240530-1/vordel-trace-7.7.0.20240530-1.jar differ diff --git a/pom.xml b/pom.xml index 351fcef..e18c94e 100644 --- a/pom.xml +++ b/pom.xml @@ -6,16 +6,16 @@ com.axway apim-env-module - 1.1.12 + 1.3.0 apim-env-module https://axway.com UTF-8 - 1.8 - 1.8 - 7.7.0.20220530-2 + 11 + 11 + 7.7.0.20240530-1 @@ -79,6 +79,12 @@ xercesImpl 2.12.2 test + + + xml-apis + xml-apis + + org.apache.commons @@ -89,18 +95,18 @@ commons-io commons-io - 2.8.0 + 2.11.0 test org.bouncycastle - bcprov-jdk15on - 1.69 + bcprov-jdk18on + 1.78 org.bouncycastle - bcpkix-jdk15on - 1.69 + bcpkix-jdk18on + 1.78 axway diff --git a/src/main/java/com/axway/ExternalConfigLoader.java b/src/main/java/com/axway/ExternalConfigLoader.java index 4150a95..434d588 100644 --- a/src/main/java/com/axway/ExternalConfigLoader.java +++ b/src/main/java/com/axway/ExternalConfigLoader.java @@ -11,9 +11,8 @@ import java.io.File; import java.io.FileNotFoundException; -import java.security.GeneralSecurityException; -import java.security.Principal; -import java.security.PrivateKey; +import java.io.IOException; +import java.security.*; import java.security.cert.Certificate; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; @@ -21,6 +20,17 @@ public class ExternalConfigLoader implements LoadableModule { + public static final String SMTP = "smtp_"; + public static final String PASSWORD = "password"; + public static final String USERNAME = "username"; + public static final String DNAME = "dname"; + public static final String CONTENT = "content"; + public static final String CASSANDRA_SETTINGS_NAME_CASSANDRA_SETTINGS = "/[CassandraSettings]name=Cassandra Settings"; + public static final String USE_SSL = "useSSL"; + public static final String CERTIFICATE = "Certificate"; + public static final String CERTIFICATES = "Certificates"; + public static final String READ_CONSISTENCY_LEVEL = "readConsistencyLevel"; + public static final String WRITE_CONSISTENCY_LEVEL = "writeConsistencyLevel"; private final CertHelper certHelper = new CertHelper(); private final ExternalInstanceDomainCert externalInstanceDomainCert = new ExternalInstanceDomainCert(); private final List mailConnectionTypes = Arrays.asList("NONE", "SSL", "TLS"); @@ -59,7 +69,7 @@ public void updatePassword(EntityStore entityStore) { Iterator keysIterator = keys.iterator(); Map ldap = Util.groupEnvVariables(envValues, "ldap_"); Map jms = Util.groupEnvVariables(envValues, "jms_"); - Map smtp = Util.groupEnvVariables(envValues, "smtp_"); + Map smtp = Util.groupEnvVariables(envValues, SMTP); Map httpBasic = Util.groupEnvVariables(envValues, "httpbasic_"); Map cassandraConsistency = Util.groupEnvVariables(envValues, "cassandraconsistency_"); @@ -67,7 +77,7 @@ public void updatePassword(EntityStore entityStore) { String key = keysIterator.next(); if (!key.contains("_")) continue; - if(key.startsWith("ldap_") || key.startsWith("jms_") || key.startsWith("smtp_") || key.startsWith("httpbasic_") || key.startsWith("cassandraconsistency_")) + if(key.startsWith("ldap_") || key.startsWith("jms_") || key.startsWith(SMTP) || key.startsWith("httpbasic_") || key.startsWith("cassandraconsistency_")) continue; String filterName = key.split("_")[1]; String passwordValue = envValues.get(key); @@ -172,9 +182,11 @@ public void updatePassword(EntityStore entityStore) { Trace.info("Updating JWT verify certificate"); X509Certificate certificate = certHelper.parseX509(passwordValue).get(0); String alias = importPublicCertificate(certificate, entityStore); - jwtVerifyConfigureCertificate(entityStore, filterName, alias); + if(!jwtVerifyConfigureCertificate(entityStore, filterName, alias)){ + Trace.error("Unable to update certificate to JWT verify Filter"); + } } catch (Exception e) { - Trace.error("Unable to add the certificate from Environment variable", e); + Trace.error("Unable to update certificate to JWT verify Filter"); } } else if (key.startsWith("gatewaytoplogycertandkey_")) { try { @@ -243,7 +255,7 @@ public void updateHttpBasic(Map> httpBasicObjs, Enti for (Map.Entry> entry : httpBasicObjs.entrySet()) { String filterName = entry.getKey(); Map attributes = entry.getValue(); - String password = attributes.get("password"); + String password = attributes.get(PASSWORD); String shorthandKey = "/[AuthProfilesGroup]name=Auth Profiles/[BasicAuthGroup]name=HTTP Basic/[BasicProfile]name=" + filterName; Entity entity = getEntity(entityStore, shorthandKey); @@ -277,13 +289,13 @@ public Entity getEntity(EntityStore entityStore, String shorthandKey) { } private void setUsernameAndPassword(Map attributes, Entity entity, String usernameFieldName) throws GeneralSecurityException { - String password = attributes.get("password"); + String password = attributes.get(PASSWORD); if (password != null) { byte[] encryptedPassword = passwordCipher.encrypt(password.getBytes()); password = Base64.getEncoder().encodeToString(encryptedPassword); - entity.setStringField("password", password); + entity.setStringField(PASSWORD, password); } - String username = attributes.get("username"); + String username = attributes.get(USERNAME); if (username != null) { entity.setStringField(usernameFieldName, username); } @@ -345,7 +357,7 @@ public void updateSMTP(EntityStore entityStore, Map attributes, return; } try { - setUsernameAndPassword(attributes, entity, "username"); + setUsernameAndPassword(attributes, entity, USERNAME); String host = attributes.get("url"); if (host != null) { entity.setStringField("smtpServer", host); @@ -366,7 +378,7 @@ public void updateAlertSMTP(EntityStore entityStore, Map attribu return; } try { - setUsernameAndPassword(attributes, entity, "username"); + setUsernameAndPassword(attributes, entity, USERNAME); String host = attributes.get("url"); if (host != null) { entity.setStringField("smtp", host); @@ -380,7 +392,7 @@ public void updateAlertSMTP(EntityStore entityStore, Map attribu } public void updateMailConnectionTypeAndPort(Entity entity, String filterName, String portFieldName) { - String connectionType = System.getenv("smtp_" + filterName + "_connectionType"); + String connectionType = System.getenv(SMTP + filterName + "_connectionType"); if (connectionType != null) { // Possible Values NONE, SSL TLS if (mailConnectionTypes.contains(connectionType)) { @@ -389,7 +401,7 @@ public void updateMailConnectionTypeAndPort(Entity entity, String filterName, St Trace.error("Invalid connection type : " + connectionType); } } - String port = System.getenv("smtp_" + filterName + "_port"); + String port = System.getenv(SMTP + filterName + "_port"); if (port != null) { try { entity.setStringField(portFieldName, port); @@ -400,17 +412,16 @@ public void updateMailConnectionTypeAndPort(Entity entity, String filterName, St } public void updateCassandraPassword(EntityStore entityStore, char[] password) throws GeneralSecurityException { - String shorthandKey = "/[CassandraSettings]name=Cassandra Settings"; - Entity entity = getEntity(entityStore, shorthandKey); + Entity entity = getEntity(entityStore, CASSANDRA_SETTINGS_NAME_CASSANDRA_SETTINGS); byte[] encryptedPassword = passwordCipher.encrypt(String.valueOf(password).getBytes()); String encodedPassword = Base64.getEncoder().encodeToString(encryptedPassword); - entity.setStringField("password", encodedPassword); + entity.setStringField(PASSWORD, encodedPassword); entityStore.updateEntity(entity); } public void updateCassandraCertAndKey(EntityStore entityStore, String clientAuthAlias, Certificate[] certificates) { - Entity entity = getEntity(entityStore, "/[CassandraSettings]name=Cassandra Settings"); - boolean useSSL = entity.getBooleanValue("useSSL"); + Entity entity = getEntity(entityStore, CASSANDRA_SETTINGS_NAME_CASSANDRA_SETTINGS); + boolean useSSL = entity.getBooleanValue(USE_SSL); if (useSSL) { String clientAuth = "sslCertificate"; updateCertEntity(entityStore, entity, clientAuthAlias, clientAuth, false); @@ -428,8 +439,8 @@ public void updateCassandraCertAndKey(EntityStore entityStore, String clientAuth } public void updateCassandraCert(EntityStore entityStore, String alias, boolean append) { - Entity entity = getEntity(entityStore, "/[CassandraSettings]name=Cassandra Settings"); - boolean useSSL = entity.getBooleanValue("useSSL"); + Entity entity = getEntity(entityStore, CASSANDRA_SETTINGS_NAME_CASSANDRA_SETTINGS); + boolean useSSL = entity.getBooleanValue(USE_SSL); if (useSSL) { String filedName = "sslTrustedCerts"; updateCertEntity(entityStore, entity, alias, filedName, append); @@ -437,10 +448,9 @@ public void updateCassandraCert(EntityStore entityStore, String alias, boolean a } public void disableCassandraSSL(EntityStore entityStore, String value) { - String shorthandKey = "/[CassandraSettings]name=Cassandra Settings"; - Entity entity = getEntity(entityStore, shorthandKey); + Entity entity = getEntity(entityStore, CASSANDRA_SETTINGS_NAME_CASSANDRA_SETTINGS); boolean boolValue = Boolean.parseBoolean(value); - entity.setBooleanField("useSSL", !boolValue); + entity.setBooleanField(USE_SSL, !boolValue); entityStore.updateEntity(entity); if(!boolValue) Trace.info("Disabled Cassandra SSL"); @@ -472,16 +482,16 @@ private String importPublicCertificate(X509Certificate certificate, EntityStore Trace.info("Alias :" + alias + "Escaped alias :" + escapedAlias); if (certEntity == null) { Trace.info("Adding cert"); - certEntity = EntityStoreDelegate.createDefaultedEntity(entityStore, "Certificate"); + certEntity = EntityStoreDelegate.createDefaultedEntity(entityStore, CERTIFICATE); ESPK rootPK = entityStore.getRootPK(); - EntityType group = entityStore.getTypeForName("Certificates"); + EntityType group = entityStore.getTypeForName(CERTIFICATES); Collection groups = entityStore.listChildren(rootPK, group); - certEntity.setStringField("dname", alias); - certEntity.setBinaryValue("content", certificate.getEncoded()); + certEntity.setStringField(DNAME, alias); + certEntity.setBinaryValue(CONTENT, certificate.getEncoded()); entityStore.addEntity(groups.iterator().next(), certEntity); } else { Trace.info("Updating cert with alias " + escapedAlias); - certEntity.setBinaryValue("content", certificate.getEncoded()); + certEntity.setBinaryValue(CONTENT, certificate.getEncoded()); entityStore.updateEntity(certEntity); } return alias; @@ -540,16 +550,14 @@ private void updateCertEntity(EntityStore entityStore, Entity entity, String ali String escapedAlias = ShorthandKeyFinder.escapeFieldValue(alias); Entity certEntity = getCertEntity(entityStore, escapedAlias); - // Trace.info("Certificate entity set to listener interface "+ certEntity); PortableESPK portableESPK = PortableESPK.toPortableKey(entityStore, certEntity.getPK()); - //Trace.info("Portable : " + portableESPK); if (append) { Field field = entity.getField(fieldName); List values = field.getValueList(); List cloneVales = new ArrayList<>(values); for (Value value : cloneVales) { PortableESPK valueRef = (PortableESPK) value.getRef(); - String certStoreDistinguishedName = valueRef.getFieldValueOfReferencedEntity("dname"); + String certStoreDistinguishedName = valueRef.getFieldValueOfReferencedEntity(DNAME); Trace.info(" alias name from Gateway Cert store :" + certStoreDistinguishedName); if (certStoreDistinguishedName.equals(alias)) { Trace.info("Removing existing cert as it matches the current cert" + alias); @@ -627,7 +635,7 @@ public Entity getCertEntity(EntityStore entityStore, String alias) { } - public PKCS12 importP12(EntityStore entityStore, String cert, char[] password) throws Exception { + public PKCS12 importP12(EntityStore entityStore, String cert, char[] password) throws GeneralSecurityException, IOException { PKCS12 pkcs12; File file = new File(cert); @@ -642,7 +650,6 @@ public PKCS12 importP12(EntityStore entityStore, String cert, char[] password) t Certificate[] certificates = pkcs12.getCertificates(); Entity certEntity = getCertEntity(entityStore, escapedAlias); Trace.info("Escaped Certificate alias name : " + escapedAlias); - // Trace.info("Certificate Entity received from entity store : "+ certEntity); if (certEntity != null) { //Updates the existing certificate in the certStore Trace.info("Updating existing certificate"); @@ -658,13 +665,13 @@ public PKCS12 importP12(EntityStore entityStore, String cert, char[] password) t } } else { ESPK rootPK = entityStore.getRootPK(); - EntityType group = entityStore.getTypeForName("Certificates"); + EntityType group = entityStore.getTypeForName(CERTIFICATES); Collection groups = entityStore.listChildren(rootPK, group); - certEntity = EntityStoreDelegate.createDefaultedEntity(entityStore, "Certificate"); + certEntity = EntityStoreDelegate.createDefaultedEntity(entityStore, CERTIFICATE); for (int i = 0; i < certificates.length; i++) { if (i == 0) { Trace.info("Importing Leaf certificate"); - certEntity.setStringField("dname", alias); + certEntity.setStringField(DNAME, alias); updateCertificateEntityWithKey(certEntity, certificates[i].getEncoded(), pkcs12.getPrivateKey().getEncoded()); entityStore.addEntity(groups.iterator().next(), certEntity); Trace.info("Leaf certificate imported"); @@ -682,37 +689,37 @@ public PKCS12 importP12(EntityStore entityStore, String cert, char[] password) t public void updateCertificateEntityWithKey(Entity certEntity, byte[] publicKey, byte[] privateKey) throws GeneralSecurityException { Trace.info("Updating existing certificate"); - certEntity.setBinaryValue("content", publicKey); + certEntity.setBinaryValue(CONTENT, publicKey); byte[] keyBytes = passwordCipher.encrypt(privateKey); String keyStr = Base64.getEncoder().encodeToString(keyBytes); certEntity.setStringField("key", keyStr); + certEntity.setStringField("issuer", "-1"); } - public PKCS12 importCertAndKeyAndCA(EntityStore entityStore, String cert, String ca, String key, String alias) throws Exception { + public PKCS12 importCertAndKeyAndCA(EntityStore entityStore, String cert, String ca, String key, String alias) throws GeneralSecurityException, IOException { PKCS12 pkcs12 = new PKCS12(); List caCerts = new ArrayList<>(); - Trace.info("ca cert "+ca); + Trace.info("ca cert " + ca); if (ca != null) { caCerts = certHelper.parseX509(ca); } X509Certificate certObj = certHelper.parseX509(cert).get(0); if (alias == null) { alias = certObj.getSubjectDN().getName(); - if (alias.equals("")) { + if (alias.isEmpty()) { alias = certObj.getSerialNumber().toString(); } } PrivateKey privateKey = certHelper.parsePrivateKey(key); if (privateKey == null) { - throw new Exception("Unable to parse a private key"); + throw new IOException("Unable to parse a private key"); } Trace.info("Certificate alias name : " + alias); String escapedAlias = ShorthandKeyFinder.escapeFieldValue(alias); Entity certEntity = getCertEntity(entityStore, escapedAlias); Trace.info("Escaped Certificate alias name : " + escapedAlias); - // Trace.info("Certificate Entity received from entity store : "+ certEntity); if (certEntity != null) { //Updates the existing certificate in the certStore Trace.info("Updating existing certificate"); @@ -725,11 +732,11 @@ public PKCS12 importCertAndKeyAndCA(EntityStore entityStore, String cert, String } } else { ESPK rootPK = entityStore.getRootPK(); - EntityType group = entityStore.getTypeForName("Certificates"); + EntityType group = entityStore.getTypeForName(CERTIFICATES); Collection groups = entityStore.listChildren(rootPK, group); - certEntity = EntityStoreDelegate.createDefaultedEntity(entityStore, "Certificate"); + certEntity = EntityStoreDelegate.createDefaultedEntity(entityStore, CERTIFICATE); Trace.info("Importing Leaf certificate"); - certEntity.setStringField("dname", alias); + certEntity.setStringField(DNAME, alias); updateCertificateEntityWithKey(certEntity, certObj.getEncoded(), privateKey.getEncoded()); entityStore.addEntity(groups.iterator().next(), certEntity); Trace.info("Leaf certificate imported"); @@ -755,21 +762,21 @@ public void updateCassandraConsistencyLevel(EntityStore entityStore, String read ShorthandKeyFinder shorthandKeyFinder = new ShorthandKeyFinder(entityStore); // Update KPS table consistency level updateCassandraConsistencyLevel(shorthandKeyFinder, "/[KPSRoot]name=Key Property Stores/[KPSPackage]**/[KPSDataSourceGroup]**/[KPSCassandraDataSource]name=Cassandra Storage", - "readConsistencyLevel", readConsistencyLevel, "writeConsistencyLevel", writeConsistencyLevel); + READ_CONSISTENCY_LEVEL, readConsistencyLevel, WRITE_CONSISTENCY_LEVEL, writeConsistencyLevel); updateCassandraConsistencyLevel(shorthandKeyFinder, "/[PortalConfiguration]name=Portal Config", "quotaReadConsistency", readConsistencyLevel, "quotaWriteConsistency", writeConsistencyLevel); //Update throttling consistency level - updateCassandraConsistencyLevel(shorthandKeyFinder, "/[CassandraSettings]name=Cassandra Settings", + updateCassandraConsistencyLevel(shorthandKeyFinder, CASSANDRA_SETTINGS_NAME_CASSANDRA_SETTINGS, "throttlingReadConsistencyLevel", readConsistencyLevel, "throttlingWriteConsistencyLevel", writeConsistencyLevel); //Update access token consistency level updateCassandraConsistencyLevel(shorthandKeyFinder, "/[OAuth2StoresGroup]name=OAuth2 Stores/[AccessTokenStoreGroup]name=Access Token Stores/[AccessTokenPersist]**", - "readConsistencyLevel", readConsistencyLevel, "writeConsistencyLevel", writeConsistencyLevel); + READ_CONSISTENCY_LEVEL, readConsistencyLevel, WRITE_CONSISTENCY_LEVEL, writeConsistencyLevel); //Update auth code consistency level updateCassandraConsistencyLevel(shorthandKeyFinder, "/[OAuth2StoresGroup]name=OAuth2 Stores/[AuthzCodeStoreGroup]name=Authorization Code Stores/[AuthzCodePersist]**", - "readConsistencyLevel", readConsistencyLevel, "writeConsistencyLevel", writeConsistencyLevel); + READ_CONSISTENCY_LEVEL, readConsistencyLevel, WRITE_CONSISTENCY_LEVEL, writeConsistencyLevel); //update client access token consistency level updateCassandraConsistencyLevel(shorthandKeyFinder, "/[OAuth2StoresGroup]name=OAuth2 Stores/[ClientAccessTokenStoreGroup]name=Client Access Token Stores/[ClientAccessTokenPersist]**", - "readConsistencyLevel", readConsistencyLevel, "writeConsistencyLevel", writeConsistencyLevel); + READ_CONSISTENCY_LEVEL, readConsistencyLevel, WRITE_CONSISTENCY_LEVEL, writeConsistencyLevel); } diff --git a/src/test/java/com/axway/ExternalConfigLoaderTest.java b/src/test/java/com/axway/ExternalConfigLoaderTest.java index 208e6c9..f687350 100644 --- a/src/test/java/com/axway/ExternalConfigLoaderTest.java +++ b/src/test/java/com/axway/ExternalConfigLoaderTest.java @@ -36,7 +36,7 @@ @RunWith(PowerMockRunner.class) @PrepareForTest({ Trace.class }) @SuppressStaticInitializationFor({ "com.vordel.trace.Trace" , "com.vordel.common.crypto.PasswordCipher"}) -@PowerMockIgnore("javax.management.*") +@PowerMockIgnore({"javax.management.*", "com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "org.w3c.*", "com.sun.org.apache.xalan.*"}) public class ExternalConfigLoaderTest { final private static Logger logger = LoggerFactory.getLogger(ExternalConfigLoaderTest.class); @@ -493,11 +493,13 @@ public void setup() throws GeneralSecurityException { mockStatic(Trace.class); PasswordCipher passwordCipher = mock(PasswordCipher.class); when(passwordCipher.encrypt(any())).thenAnswer(i -> i.getArguments()[0]); + String path = this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath() + "test-env/configs.xml"; externalConfigLoader = new ExternalConfigLoader(passwordCipher); - File file = new File("src/test/resources/test-env/configs.xml"); - String url = "federated:file:"+file.getAbsolutePath(); + // File file = new File("src/test/resources/test-env/configs.xml"); + String url = "federated:file:"+path; entityStore = EntityStoreFactory.createESForURL(url); entityStore.connect(url, new Properties()); } + } diff --git a/src/test/java/com/axway/ExternalInstanceDomainCertTest.java b/src/test/java/com/axway/ExternalInstanceDomainCertTest.java index fef39b5..c3cb0c2 100644 --- a/src/test/java/com/axway/ExternalInstanceDomainCertTest.java +++ b/src/test/java/com/axway/ExternalInstanceDomainCertTest.java @@ -6,6 +6,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +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; @@ -23,6 +24,8 @@ @RunWith(PowerMockRunner.class) @PrepareForTest({ Trace.class }) @SuppressStaticInitializationFor({ "com.vordel.trace.Trace", "com.vordel.common.crypto.PasswordCipher" }) +@PowerMockIgnore({"javax.management.*", "com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "org.w3c.*", "com.sun.org.apache.xalan.*"}) + public class ExternalInstanceDomainCertTest { CertHelper certHelper = new CertHelper();