Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkarlsen committed Apr 2, 2019
1 parent 260cfe3 commit 2157f30
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Expand Up @@ -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
Expand All @@ -51,4 +52,9 @@ public static PrivateKey loadPrivateKey() {
return null;
}
}

@Override
public PrivateKey getKey(String keyId) {
return loadPrivateKey();
}
}
Expand Up @@ -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>
Expand Down

0 comments on commit 2157f30

Please sign in to comment.