Skip to content
Permalink
Browse files
fix test
  • Loading branch information
davidkarlsen committed Apr 2, 2019
1 parent 260cfe3 commit 2157f30f50a0626e725c6398e534d10d845219e0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
@@ -28,21 +28,22 @@
import java.security.cert.CertificateException;

import org.apache.cxf.common.classloader.ClassLoaderUtils;
import org.apache.cxf.rs.security.httpsignature.provider.PrivateKeyProvider;

/**
* Just a test-class to provide a static method to easily load a PrivateKey in spring config.
*/
public final class PrivateKeyProvider {
public final class PrivateKeyProviderTestHelper implements PrivateKeyProvider {

private PrivateKeyProvider() {
private PrivateKeyProviderTestHelper() {
// complete
}

public static PrivateKey loadPrivateKey() {
KeyStore keyStore;
try {
keyStore = KeyStore.getInstance("JKS");
keyStore.load(ClassLoaderUtils.getResourceAsStream("keys/bob.jks", PrivateKeyProvider.class),
keyStore.load(ClassLoaderUtils.getResourceAsStream("keys/bob.jks", PrivateKeyProviderTestHelper.class),
"password".toCharArray());
return (PrivateKey)keyStore.getKey("bob", "password".toCharArray());
} catch (KeyStoreException | NoSuchAlgorithmException | CertificateException
@@ -51,4 +52,9 @@ public static PrivateKey loadPrivateKey() {
return null;
}
}

@Override
public PrivateKey getKey(String keyId) {
return loadPrivateKey();
}
}
@@ -114,7 +114,7 @@ under the License.

<bean id="messageSigner" class="org.apache.cxf.rs.security.httpsignature.MessageSigner">
<constructor-arg>
<bean class="org.apache.cxf.systest.jaxrs.security.httpsignature.PrivateKeyProvider" factory-method="loadPrivateKey" />
<bean class="org.apache.cxf.systest.jaxrs.security.httpsignature.PrivateKeyProviderTestHelper" />
</constructor-arg>
<constructor-arg value="bob-key-id" />
</bean>

0 comments on commit 2157f30

Please sign in to comment.