[java-support] branch master updated: Bad Scott, don't use Eclipse.
Scott Cantor
cantor.2 at osu.edu
Mon Feb 15 13:12:32 EST 2016
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch master
in repository java-support.
The following commit(s) were added to refs/heads/master by this push:
new 693dc6e Bad Scott, don't use Eclipse.
693dc6e is described below
commit 693dc6e81cc4c4bf45a6d0939ca4d7fa710e71d3
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Feb 15 13:13:57 2016 -0500
Bad Scott, don't use Eclipse.
---
.../java/support/security/DataSealerTest.java | 382 ++++++++++-----------
1 file changed, 191 insertions(+), 191 deletions(-)
diff --git a/src/test/java/net/shibboleth/utilities/java/support/security/DataSealerTest.java b/src/test/java/net/shibboleth/utilities/java/support/security/DataSealerTest.java
index d803821..a7d9215 100644
--- a/src/test/java/net/shibboleth/utilities/java/support/security/DataSealerTest.java
+++ b/src/test/java/net/shibboleth/utilities/java/support/security/DataSealerTest.java
@@ -1,192 +1,192 @@
-/*
- * Licensed to the University Corporation for Advanced Internet Development,
- * Inc. (UCAID) under one or more contributor license agreements. See the
- * NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The UCAID 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 net.shibboleth.utilities.java.support.security;
-
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.resource.Resource;
-import net.shibboleth.utilities.java.support.resource.TestResourceConverter;
-
-import org.bouncycastle.util.Arrays;
-import org.springframework.core.io.ClassPathResource;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * Test for {@link DataSealer}.
- */
-public class DataSealerTest {
-
- private Resource keystoreResource;
- private Resource versionResource;
- private Resource version2Resource;
-
- final private String THE_DATA = "THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA"
- + "THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA"
- + "THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA"
- + "THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA";
- final private long THE_DELAY = 500;
-
- @BeforeClass public void initializeKeystoreResource() {
- ClassPathResource resource =
- new ClassPathResource("/data/net/shibboleth/utilities/java/support/security/SealerKeyStore.jks");
- Assert.assertTrue(resource.exists());
- keystoreResource = TestResourceConverter.of(resource);
-
- resource =
- new ClassPathResource("/data/net/shibboleth/utilities/java/support/security/SealerKeyStore.kver");
- Assert.assertTrue(resource.exists());
- versionResource = TestResourceConverter.of(resource);
-
- resource =
- new ClassPathResource("/data/net/shibboleth/utilities/java/support/security/SealerKeyStore.kver2");
- Assert.assertTrue(resource.exists());
- version2Resource = TestResourceConverter.of(resource);
- }
-
- private DataSealer createDataSealer() throws DataSealerException, ComponentInitializationException {
- final BasicKeystoreKeyStrategy strategy = new BasicKeystoreKeyStrategy();
-
- strategy.setKeyAlias("secret");
- strategy.setKeyPassword("kpassword");
-
- strategy.setKeystorePassword("password");
- strategy.setKeystoreResource(keystoreResource);
-
- strategy.setKeyVersionResource(versionResource);
-
- strategy.initialize();
-
- final DataSealer sealer = new DataSealer();
- sealer.setKeyStrategy(strategy);
- sealer.initialize();
- return sealer;
- }
-
- private DataSealer createDataSealer2() throws DataSealerException, ComponentInitializationException {
- final BasicKeystoreKeyStrategy strategy = new BasicKeystoreKeyStrategy();
-
- strategy.setKeyAlias("secret");
- strategy.setKeyPassword("kpassword");
-
- strategy.setKeystorePassword("password");
- strategy.setKeystoreResource(keystoreResource);
-
- strategy.setKeyVersionResource(version2Resource);
-
- strategy.initialize();
-
- final DataSealer sealer = new DataSealer();
- sealer.setKeyStrategy(strategy);
- sealer.initialize();
- return sealer;
- }
-
- @Test public void encodeDecode() throws DataSealerException, ComponentInitializationException {
- final DataSealer sealer = createDataSealer();
-
- final String encoded = sealer.wrap(THE_DATA, System.currentTimeMillis() + 50000);
- final StringBuffer alias = new StringBuffer();
- Assert.assertEquals(sealer.unwrap(encoded, alias), THE_DATA);
- Assert.assertEquals(alias.toString(), "secret1");
- }
-
- @Test public void encodeDecodeSecondKey() throws DataSealerException, ComponentInitializationException {
- final DataSealer sealer = createDataSealer();
- final DataSealer sealer2 = createDataSealer2();
-
- final StringBuffer alias = new StringBuffer();
- final String encoded = sealer.wrap(THE_DATA, System.currentTimeMillis() + 50000);
- Assert.assertEquals(sealer.unwrap(encoded, alias), THE_DATA);
- Assert.assertEquals(alias.toString(), "secret1");
- alias.setLength(0);
- Assert.assertEquals(sealer2.unwrap(encoded, alias), THE_DATA);
- Assert.assertEquals(alias.toString(), "secret1");
- }
-
- @Test public void timeOut() throws DataSealerException, InterruptedException, ComponentInitializationException {
- final DataSealer sealer = createDataSealer();
-
- String encoded = sealer.wrap(THE_DATA, System.currentTimeMillis() + THE_DELAY);
- Thread.sleep(THE_DELAY + 1);
- try {
- sealer.unwrap(encoded);
- Assert.fail("Should have timed out");
- } catch (DataExpiredException ex) {
- // OK
- }
- }
-
- public void encodeDecodeLong() throws DataSealerException, ComponentInitializationException {
- final DataSealer sealer = createDataSealer();
-
- char[] buffer = new char[1000000];
- Arrays.fill(buffer, 'x');
- final String longData = new String(buffer);
- final String encoded = sealer.wrap(longData, System.currentTimeMillis() + 50000);
- final StringBuffer alias = new StringBuffer();
- Assert.assertEquals(sealer.unwrap(encoded, alias), longData);
- Assert.assertEquals(alias.toString(), "secret1");
- }
-
- @Test public void badValues() throws DataSealerException, ComponentInitializationException {
- DataSealer sealer = new DataSealer();
-
- try {
- sealer.initialize();
- Assert.fail("no strategy");
- } catch (ComponentInitializationException e) {
-
- }
-
- sealer = createDataSealer();
-
- try {
- sealer.unwrap("");
- Assert.fail("no data");
- } catch (DataSealerException e) {
- // OK
- }
-
- try {
- sealer.unwrap("RandomGarbage");
- Assert.fail("random data");
- } catch (DataSealerException e) {
- // OK
- }
-
- final String wrapped = sealer.wrap(THE_DATA, 3600 * 1000);
-
- final String corrupted = wrapped.substring(0, 25) + "A" + wrapped.substring(27);
-
- try {
- sealer.unwrap(corrupted);
- Assert.fail("corrupted data");
- } catch (DataSealerException e) {
- // OK
- }
-
- try {
- sealer.wrap(null, 10);
- Assert.fail("no data");
- } catch (IllegalArgumentException e) {
- // OK
- }
- }
-
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID 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 net.shibboleth.utilities.java.support.security;
+
+import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
+import net.shibboleth.utilities.java.support.resource.Resource;
+import net.shibboleth.utilities.java.support.resource.TestResourceConverter;
+
+import org.bouncycastle.util.Arrays;
+import org.springframework.core.io.ClassPathResource;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * Test for {@link DataSealer}.
+ */
+public class DataSealerTest {
+
+ private Resource keystoreResource;
+ private Resource versionResource;
+ private Resource version2Resource;
+
+ final private String THE_DATA = "THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA"
+ + "THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA"
+ + "THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA"
+ + "THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA THIS IS SOME TEST DATA";
+ final private long THE_DELAY = 500;
+
+ @BeforeClass public void initializeKeystoreResource() {
+ ClassPathResource resource =
+ new ClassPathResource("/data/net/shibboleth/utilities/java/support/security/SealerKeyStore.jks");
+ Assert.assertTrue(resource.exists());
+ keystoreResource = TestResourceConverter.of(resource);
+
+ resource =
+ new ClassPathResource("/data/net/shibboleth/utilities/java/support/security/SealerKeyStore.kver");
+ Assert.assertTrue(resource.exists());
+ versionResource = TestResourceConverter.of(resource);
+
+ resource =
+ new ClassPathResource("/data/net/shibboleth/utilities/java/support/security/SealerKeyStore.kver2");
+ Assert.assertTrue(resource.exists());
+ version2Resource = TestResourceConverter.of(resource);
+ }
+
+ private DataSealer createDataSealer() throws DataSealerException, ComponentInitializationException {
+ final BasicKeystoreKeyStrategy strategy = new BasicKeystoreKeyStrategy();
+
+ strategy.setKeyAlias("secret");
+ strategy.setKeyPassword("kpassword");
+
+ strategy.setKeystorePassword("password");
+ strategy.setKeystoreResource(keystoreResource);
+
+ strategy.setKeyVersionResource(versionResource);
+
+ strategy.initialize();
+
+ final DataSealer sealer = new DataSealer();
+ sealer.setKeyStrategy(strategy);
+ sealer.initialize();
+ return sealer;
+ }
+
+ private DataSealer createDataSealer2() throws DataSealerException, ComponentInitializationException {
+ final BasicKeystoreKeyStrategy strategy = new BasicKeystoreKeyStrategy();
+
+ strategy.setKeyAlias("secret");
+ strategy.setKeyPassword("kpassword");
+
+ strategy.setKeystorePassword("password");
+ strategy.setKeystoreResource(keystoreResource);
+
+ strategy.setKeyVersionResource(version2Resource);
+
+ strategy.initialize();
+
+ final DataSealer sealer = new DataSealer();
+ sealer.setKeyStrategy(strategy);
+ sealer.initialize();
+ return sealer;
+ }
+
+ @Test public void encodeDecode() throws DataSealerException, ComponentInitializationException {
+ final DataSealer sealer = createDataSealer();
+
+ final String encoded = sealer.wrap(THE_DATA, System.currentTimeMillis() + 50000);
+ final StringBuffer alias = new StringBuffer();
+ Assert.assertEquals(sealer.unwrap(encoded, alias), THE_DATA);
+ Assert.assertEquals(alias.toString(), "secret1");
+ }
+
+ @Test public void encodeDecodeSecondKey() throws DataSealerException, ComponentInitializationException {
+ final DataSealer sealer = createDataSealer();
+ final DataSealer sealer2 = createDataSealer2();
+
+ final StringBuffer alias = new StringBuffer();
+ final String encoded = sealer.wrap(THE_DATA, System.currentTimeMillis() + 50000);
+ Assert.assertEquals(sealer.unwrap(encoded, alias), THE_DATA);
+ Assert.assertEquals(alias.toString(), "secret1");
+ alias.setLength(0);
+ Assert.assertEquals(sealer2.unwrap(encoded, alias), THE_DATA);
+ Assert.assertEquals(alias.toString(), "secret1");
+ }
+
+ @Test public void timeOut() throws DataSealerException, InterruptedException, ComponentInitializationException {
+ final DataSealer sealer = createDataSealer();
+
+ String encoded = sealer.wrap(THE_DATA, System.currentTimeMillis() + THE_DELAY);
+ Thread.sleep(THE_DELAY + 1);
+ try {
+ sealer.unwrap(encoded);
+ Assert.fail("Should have timed out");
+ } catch (DataExpiredException ex) {
+ // OK
+ }
+ }
+
+ public void encodeDecodeLong() throws DataSealerException, ComponentInitializationException {
+ final DataSealer sealer = createDataSealer();
+
+ char[] buffer = new char[1000000];
+ Arrays.fill(buffer, 'x');
+ final String longData = new String(buffer);
+ final String encoded = sealer.wrap(longData, System.currentTimeMillis() + 50000);
+ final StringBuffer alias = new StringBuffer();
+ Assert.assertEquals(sealer.unwrap(encoded, alias), longData);
+ Assert.assertEquals(alias.toString(), "secret1");
+ }
+
+ @Test public void badValues() throws DataSealerException, ComponentInitializationException {
+ DataSealer sealer = new DataSealer();
+
+ try {
+ sealer.initialize();
+ Assert.fail("no strategy");
+ } catch (ComponentInitializationException e) {
+
+ }
+
+ sealer = createDataSealer();
+
+ try {
+ sealer.unwrap("");
+ Assert.fail("no data");
+ } catch (DataSealerException e) {
+ // OK
+ }
+
+ try {
+ sealer.unwrap("RandomGarbage");
+ Assert.fail("random data");
+ } catch (DataSealerException e) {
+ // OK
+ }
+
+ final String wrapped = sealer.wrap(THE_DATA, 3600 * 1000);
+
+ final String corrupted = wrapped.substring(0, 25) + "A" + wrapped.substring(27);
+
+ try {
+ sealer.unwrap(corrupted);
+ Assert.fail("corrupted data");
+ } catch (DataSealerException e) {
+ // OK
+ }
+
+ try {
+ sealer.wrap(null, 10);
+ Assert.fail("no data");
+ } catch (IllegalArgumentException e) {
+ // OK
+ }
+ }
+
}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list