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 2015/12/03 15:16:06 UTC
[2/2] cxf git commit: Adding a jws test for loading a publik key from
JKS
Adding a jws test for loading a publik key from JKS
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/5a018910
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/5a018910
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/5a018910
Branch: refs/heads/3.0.x-fixes
Commit: 5a0189104645bc25a65f11f5a25f07889d160bd4
Parents: b1ab9e9
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Thu Dec 3 10:27:59 2015 +0000
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Thu Dec 3 14:13:06 2015 +0000
----------------------------------------------------------------------
.../cxf/rs/security/jose/jws/JwsUtilsTest.java | 68 +++++++++++++++++++
.../apache/cxf/rs/security/jose/jws/alice.jks | Bin 0 -> 4125 bytes
2 files changed, 68 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/5a018910/rt/rs/security/jose-parent/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/JwsUtilsTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose-parent/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/JwsUtilsTest.java b/rt/rs/security/jose-parent/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/JwsUtilsTest.java
new file mode 100644
index 0000000..f82ce92
--- /dev/null
+++ b/rt/rs/security/jose-parent/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/JwsUtilsTest.java
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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.apache.cxf.rs.security.jose.jws;
+
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.ExchangeImpl;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.rs.security.jose.common.JoseConstants;
+import org.apache.cxf.rs.security.jose.jwk.JsonWebKey;
+import org.apache.cxf.rs.security.jose.jwk.JsonWebKeys;
+import org.apache.cxf.rs.security.jose.jwk.JwkUtils;
+import org.apache.cxf.rs.security.jose.jwk.KeyType;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class JwsUtilsTest extends Assert {
+ @Test
+ public void testLoadVerificationKeys() throws Exception {
+ Properties p = new Properties();
+ p.put(JoseConstants.RSSEC_KEY_STORE_FILE,
+ "org/apache/cxf/rs/security/jose/jws/alice.jks");
+ p.put(JoseConstants.RSSEC_KEY_STORE_PSWD, "password");
+ p.put(JoseConstants.RSSEC_KEY_STORE_ALIAS, "alice");
+ JsonWebKeys keySet = JwsUtils.loadPublicVerificationKeys(createMessage(), p);
+ assertEquals(1, keySet.asMap().size());
+ List<JsonWebKey> keys = keySet.getRsaKeys();
+ assertEquals(1, keys.size());
+ JsonWebKey key = keys.get(0);
+ System.out.println(JwkUtils.jwkKeyToJson(key));
+ assertEquals(KeyType.RSA, key.getKeyType());
+ assertEquals("alice", key.getKeyId());
+ assertNotNull(key.getKeyProperty(JsonWebKey.RSA_PUBLIC_EXP));
+ assertNotNull(key.getKeyProperty(JsonWebKey.RSA_MODULUS));
+ assertNull(key.getKeyProperty(JsonWebKey.RSA_PRIVATE_EXP));
+ }
+
+ private Message createMessage() {
+ Message m = new MessageImpl();
+ Exchange e = new ExchangeImpl();
+ e.put(Bus.class, BusFactory.getThreadDefaultBus());
+ m.setExchange(e);
+ e.setInMessage(m);
+ return m;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5a018910/rt/rs/security/jose-parent/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/alice.jks
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose-parent/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/alice.jks b/rt/rs/security/jose-parent/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/alice.jks
new file mode 100644
index 0000000..213b26c
Binary files /dev/null and b/rt/rs/security/jose-parent/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/alice.jks differ