You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2014/06/06 18:00:08 UTC
git commit: [CXF-5311] Fixing the typo, updating the test
Repository: cxf
Updated Branches:
refs/heads/master bfd50e974 -> 2b51837e4
[CXF-5311] Fixing the typo, updating the test
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/2b51837e
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/2b51837e
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/2b51837e
Branch: refs/heads/master
Commit: 2b51837e4e51cc33e9cc537423930bb4bb246655
Parents: bfd50e9
Author: Sergey Beryozkin <sb...@talend.com>
Authored: Fri Jun 6 16:59:51 2014 +0100
Committer: Sergey Beryozkin <sb...@talend.com>
Committed: Fri Jun 6 16:59:51 2014 +0100
----------------------------------------------------------------------
.../rs/security/oauth2/utils/crypto/CryptoUtils.java | 13 ++++++++++---
.../jaxrs/security/oauth2/OAuthDataProviderImpl.java | 11 ++++-------
2 files changed, 14 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/2b51837e/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/crypto/CryptoUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/crypto/CryptoUtils.java b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/crypto/CryptoUtils.java
index f661b50..1527f79 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/crypto/CryptoUtils.java
+++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/crypto/CryptoUtils.java
@@ -120,11 +120,18 @@ public final class CryptoUtils {
}
}
- public static PublicKey loadPrivateKey(InputStream storeLocation, char[] storePassword, String alias) {
+ public static Certificate loadCertificate(InputStream storeLocation, char[] storePassword, String alias) {
try {
KeyStore keyStore = loadKeyStore(storeLocation, storePassword);
- Certificate cert = keyStore.getCertificate(alias);
- return cert.getPublicKey();
+ return keyStore.getCertificate(alias);
+ } catch (Exception ex) {
+ throw new SecurityException(ex);
+ }
+ }
+
+ public static PublicKey loadPublicKey(InputStream storeLocation, char[] storePassword, String alias) {
+ try {
+ return loadCertificate(storeLocation, storePassword, alias).getPublicKey();
} catch (Exception ex) {
throw new SecurityException(ex);
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/2b51837e/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/OAuthDataProviderImpl.java
----------------------------------------------------------------------
diff --git a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/OAuthDataProviderImpl.java b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/OAuthDataProviderImpl.java
index 8647414..8652dd7 100644
--- a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/OAuthDataProviderImpl.java
+++ b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/OAuthDataProviderImpl.java
@@ -19,7 +19,6 @@
package org.apache.cxf.systest.jaxrs.security.oauth2;
import java.io.InputStream;
-import java.security.KeyStore;
import java.security.cert.Certificate;
import java.util.HashMap;
import java.util.List;
@@ -35,6 +34,7 @@ import org.apache.cxf.rs.security.oauth2.provider.OAuthDataProvider;
import org.apache.cxf.rs.security.oauth2.provider.OAuthServiceException;
import org.apache.cxf.rs.security.oauth2.saml.Constants;
import org.apache.cxf.rs.security.oauth2.tokens.bearer.BearerAccessToken;
+import org.apache.cxf.rs.security.oauth2.utils.crypto.CryptoUtils;
public class OAuthDataProviderImpl implements OAuthDataProvider {
@@ -48,8 +48,7 @@ public class OAuthDataProviderImpl implements OAuthDataProvider {
clients.put(client.getClientId(), client);
- KeyStore keyStore = loadKeyStore();
- Certificate cert = keyStore.getCertificate("morpit");
+ Certificate cert = loadCert();
String encodedCert = Base64Utility.encode(cert.getEncoded());
Client client2 = new Client("CN=whateverhost.com,OU=Morpit,O=ApacheTest,L=Syracuse,C=US",
@@ -62,11 +61,9 @@ public class OAuthDataProviderImpl implements OAuthDataProvider {
clients.put(client2.getClientId(), client2);
}
- private KeyStore loadKeyStore() throws Exception {
- KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
+ private Certificate loadCert() throws Exception {
InputStream is = this.getClass().getResourceAsStream("/org/apache/cxf/systest/http/resources/Truststore.jks");
- ks.load(is, new char[]{'p', 'a', 's', 's', 'w', 'o', 'r', 'd'});
- return ks;
+ return CryptoUtils.loadCertificate(is, new char[]{'p', 'a', 's', 's', 'w', 'o', 'r', 'd'}, "morpit");
}