adding license
This commit is contained in:
@@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014 David Horscroft
|
||||||
|
*
|
||||||
|
* Licensed 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.
|
||||||
|
*
|
||||||
|
* The NoCore class is the interface between which the wrapper application (wrapplication?) accesses
|
||||||
|
* no- functionality.
|
||||||
|
*/
|
||||||
|
|
||||||
package nodash.core;
|
package nodash.core;
|
||||||
|
|
||||||
import java.security.PublicKey;
|
import java.security.PublicKey;
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014 David Horscroft
|
||||||
|
*
|
||||||
|
* Licensed 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.
|
||||||
|
*
|
||||||
|
* The NoCore class is the interface between which the wrapper application (wrapplication?) accesses
|
||||||
|
* no- functionality.
|
||||||
|
*/
|
||||||
|
|
||||||
package nodash.core;
|
package nodash.core;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014 David Horscroft
|
||||||
|
*
|
||||||
|
* Licensed 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.
|
||||||
|
*
|
||||||
|
* The NoCore class is the interface between which the wrapper application (wrapplication?) accesses
|
||||||
|
* no- functionality.
|
||||||
|
*/
|
||||||
|
|
||||||
package nodash.test;
|
package nodash.test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014 David Horscroft
|
||||||
|
*
|
||||||
|
* Licensed 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.
|
||||||
|
*
|
||||||
|
* The NoCore class is the interface between which the wrapper application (wrapplication?) accesses
|
||||||
|
* no- functionality.
|
||||||
|
*/
|
||||||
|
|
||||||
package nodash.test;
|
package nodash.test;
|
||||||
|
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014 David Horscroft
|
||||||
|
*
|
||||||
|
* Licensed 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.
|
||||||
|
*
|
||||||
|
* The NoCore class is the interface between which the wrapper application (wrapplication?) accesses
|
||||||
|
* no- functionality.
|
||||||
|
*/
|
||||||
|
|
||||||
package nodash.test;
|
package nodash.test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014 David Horscroft
|
||||||
|
*
|
||||||
|
* Licensed 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.
|
||||||
|
*
|
||||||
|
* The NoCore class is the interface between which the wrapper application (wrapplication?) accesses
|
||||||
|
* no- functionality.
|
||||||
|
*/
|
||||||
|
|
||||||
package nodash.test;
|
package nodash.test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
@@ -14,11 +31,11 @@ import org.apache.commons.codec.binary.Base64;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class NoUserTest {
|
public class NoUserTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoUser() {
|
public void testNoUser() {
|
||||||
NoUser user = new NoUser();
|
NoUser user = new NoUser();
|
||||||
|
|
||||||
assertNotNull(user.getNoActions());
|
assertNotNull(user.getNoActions());
|
||||||
assertEquals(user.getNoActions().size(), 0);
|
assertEquals(user.getNoActions().size(), 0);
|
||||||
assertNotNull(user.getRsaPublicKey());
|
assertNotNull(user.getRsaPublicKey());
|
||||||
@@ -31,12 +48,12 @@ public class NoUserTest {
|
|||||||
public void testCreateFile() {
|
public void testCreateFile() {
|
||||||
NoUser user = new NoUser();
|
NoUser user = new NoUser();
|
||||||
byte[] file = user.createFile("password".toCharArray());
|
byte[] file = user.createFile("password".toCharArray());
|
||||||
|
|
||||||
assertNotNull(file);
|
assertNotNull(file);
|
||||||
assertTrue(file.length > 0);
|
assertTrue(file.length > 0);
|
||||||
|
|
||||||
byte[] secondFile = user.createFile("password".toCharArray());
|
byte[] secondFile = user.createFile("password".toCharArray());
|
||||||
|
|
||||||
assertFalse(Arrays.equals(file, secondFile));
|
assertFalse(Arrays.equals(file, secondFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,45 +61,46 @@ public class NoUserTest {
|
|||||||
public void testCreateHash() {
|
public void testCreateHash() {
|
||||||
NoUser user = new NoUser();
|
NoUser user = new NoUser();
|
||||||
byte[] hash = user.createHash();
|
byte[] hash = user.createHash();
|
||||||
|
|
||||||
assertNotNull(hash);
|
assertNotNull(hash);
|
||||||
assertEquals(hash.length, 64);
|
assertEquals(hash.length, 64);
|
||||||
|
|
||||||
byte[] secondHash = user.createHash();
|
byte[] secondHash = user.createHash();
|
||||||
|
|
||||||
assertTrue(Arrays.equals(hash, secondHash));
|
assertTrue(Arrays.equals(hash, secondHash));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateHashString() {
|
public void testCreateHashString() {
|
||||||
NoUser user = new NoUser();
|
NoUser user = new NoUser();
|
||||||
byte[] hash = user.createHash();
|
byte[] hash = user.createHash();
|
||||||
String hashString = user.createHashString();
|
String hashString = user.createHashString();
|
||||||
|
|
||||||
assertEquals(Base64.encodeBase64URLSafeString(hash), hashString);
|
assertEquals(Base64.encodeBase64URLSafeString(hash), hashString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateUserFromFile() throws IllegalBlockSizeException, BadPaddingException, ClassNotFoundException, IOException {
|
public void testCreateUserFromFile() throws IllegalBlockSizeException, BadPaddingException,
|
||||||
|
ClassNotFoundException, IOException {
|
||||||
NoUser user = new NoUser();
|
NoUser user = new NoUser();
|
||||||
final byte[] originalFile = user.createFile("password".toCharArray());
|
final byte[] originalFile = user.createFile("password".toCharArray());
|
||||||
byte[] file = Arrays.copyOf(originalFile, originalFile.length);
|
byte[] file = Arrays.copyOf(originalFile, originalFile.length);
|
||||||
byte[] hash = user.createHash();
|
byte[] hash = user.createHash();
|
||||||
String hashString = user.createHashString();
|
String hashString = user.createHashString();
|
||||||
user = null;
|
user = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
user = NoUser.createUserFromFile(file, "wrongpassword".toCharArray());
|
user = NoUser.createUserFromFile(file, "wrongpassword".toCharArray());
|
||||||
fail("Should have thrown an error when given wrong password.");
|
fail("Should have thrown an error when given wrong password.");
|
||||||
} catch (BadPaddingException e) {
|
} catch (BadPaddingException e) {
|
||||||
// Do nothing, correct
|
// Do nothing, correct
|
||||||
}
|
}
|
||||||
|
|
||||||
file = Arrays.copyOf(originalFile, originalFile.length);
|
file = Arrays.copyOf(originalFile, originalFile.length);
|
||||||
user = NoUser.createUserFromFile(file, "password".toCharArray());
|
user = NoUser.createUserFromFile(file, "password".toCharArray());
|
||||||
assertTrue(Arrays.equals(hash, user.createHash()));
|
assertTrue(Arrays.equals(hash, user.createHash()));
|
||||||
assertEquals(hashString, user.createHashString());
|
assertEquals(hashString, user.createHashString());
|
||||||
|
|
||||||
file = Arrays.copyOf(originalFile, originalFile.length);
|
file = Arrays.copyOf(originalFile, originalFile.length);
|
||||||
try {
|
try {
|
||||||
NoUser.createUserFromFile(file, null);
|
NoUser.createUserFromFile(file, null);
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014 David Horscroft
|
||||||
|
*
|
||||||
|
* Licensed 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.
|
||||||
|
*
|
||||||
|
* The NoCore class is the interface between which the wrapper application (wrapplication?) accesses
|
||||||
|
* no- functionality.
|
||||||
|
*/
|
||||||
|
|
||||||
package nodash.test;
|
package nodash.test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|||||||
Reference in New Issue
Block a user