Permalink
Browse files

upgraded to new kotlin version

upgraded to new eps javascript version
  • Loading branch information...
1 parent fc885a2 commit f82a212afecf4484abf3780c0404e3d2a632175e @phifty phifty committed Mar 26, 2013
View
@@ -1,7 +1,7 @@
buildscript {
repositories { mavenRepo url: 'http://evgenyg.artifactoryonline.com/evgenyg/repo/' }
- dependencies { classpath 'com.github.goldin.plugins.gradle:kotlin:0.2-SNAPSHOT' }
+ dependencies { classpath 'com.github.goldin.plugins.gradle:kotlin:0.2.1' }
}
logging.captureStandardOutput LogLevel.INFO
@@ -25,10 +25,10 @@ repositories {
dependencies {
compile files( "${ System.getProperty( 'java.home' )}/lib/jce.jar" )
- compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: '0.4.297'
+ compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: '0.5.162'
compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
- runtime group: 'org.jetbrains.kotlin', name: 'kotlin-runtime', version: '0.4.297'
+ runtime group: 'org.jetbrains.kotlin', name: 'kotlin-runtime', version: '0.5.162'
testCompile group: 'junit', name: 'junit', version: '4.+'
}
View
Binary file not shown.
@@ -14,7 +14,7 @@ fun debug(message: String) {
fun debug(values: ByteArray) {
val message = StringBuilder()
- for (val value in values) {
+ for (value in values) {
message.append(value.toString())
message.append(", ")
}
@@ -23,7 +23,7 @@ fun debug(values: ByteArray) {
fun debug(values: LongArray) {
val message = StringBuilder()
- for (val value in values) {
+ for (value in values) {
message.append(value.toString())
message.append(", ")
}
@@ -25,27 +25,27 @@ class MutableObjectEntrySet<T : Mapable>(val entrySet: MutableSet<MutableMap.Mut
throw UnsupportedOperationException()
}
- public override fun containsAll(c: Collection<out Any?>): Boolean {
+ public override fun containsAll(c: Collection<Any?>): Boolean {
throw UnsupportedOperationException()
}
public override fun isEmpty(): Boolean {
throw UnsupportedOperationException()
}
- public override fun removeAll(c: Collection<out Any?>): Boolean {
+ public override fun removeAll(c: Collection<Any?>): Boolean {
throw UnsupportedOperationException()
}
public override fun remove(o: Any?): Boolean {
throw UnsupportedOperationException()
}
- public override fun addAll(c: Collection<out MutableMap.MutableEntry<String, T>>): Boolean {
+ public override fun addAll(c: Collection<MutableMap.MutableEntry<String, T>>): Boolean {
throw UnsupportedOperationException()
}
- public override fun retainAll(c: Collection<out Any?>): Boolean {
+ public override fun retainAll(c: Collection<Any?>): Boolean {
throw UnsupportedOperationException()
}
@@ -24,7 +24,7 @@ open class MutableObjectMap<T : Mapable>(val map: MutableMap<String, Any?>,
return if (id == null || value == null) null else builder(id, value)
}
- public override fun putAll(m: Map<out String, out T>) {
+ public override fun putAll(m: Map<out String, T>) {
throw UnsupportedOperationException()
}
@@ -1,7 +1,5 @@
package com.anyaku.map
-import java.util.Arrays
-
/**
* @author phifty <b.phifty@gmail.com>
*/
@@ -11,8 +9,8 @@ fun stringify(value: Any): String {
is String -> value
is Map<*, *> -> {
val result = StringBuilder()
- val keys = value.keySet().toArray()
- Arrays.sort(keys)
+ val keys = value.keySet().toArray() as Array<Any>
+ java.util.Arrays.sort(keys)
for (key in keys) {
result.append(key.toString())
val nestedValue = value.get(key)
@@ -19,15 +19,15 @@ fun asMap<K, V>(vararg arguments: Any?): MutableMap<K, V> {
fun asList<T>(vararg arguments: T): MutableList<T> {
val result = ArrayList<T>()
- for (val item in arguments) {
+ for (item in arguments) {
result.add(item)
}
return result
}
fun asByteArray(vararg arguments: Byte): ByteArray {
val result = ByteArray(arguments.size)
- for (val index in 0..arguments.size - 1) {
+ for (index in 0..arguments.size - 1) {
result.set(index, arguments[index])
}
return result
@@ -22,14 +22,14 @@ class SignerTest() {
}
test fun testFreshlyGeneratedProfile() {
- runInWorker("var profile = root.Profile.Generator.generate(512);" +
+ runInWorker("var profile = epdRoot.Generator.generate(512);" +
"profile.sections.open.modules['build_in:com.anyaku.Basic'].content = { name: 'Mr Test', gravata: undefined, country: 'NON' };" +
- "var lockedProfile = root.Profile.Locker.lock(profile, password);")
+ "var lockedProfile = epdRoot.Locker.lock(profile, password);")
val profileJson = runInWorker("JSON.stringify(lockedProfile);") as String
val profileMap = parseJson(profileJson) as MutableMap<String, Any?>
val profile = Document(HashMap(profileMap))
- val serializedProfile = runInWorker("delete(lockedProfile.signature); root.Object.stringify(lockedProfile);") as String
+ val serializedProfile = runInWorker("delete(lockedProfile.signature); epdRoot.Object.stringify(lockedProfile);") as String
profileMap.remove("signature")
assertEquals(serializedProfile, stringify(profileMap))
@@ -23,7 +23,7 @@ class BigIntegerTest() {
}
test fun testBigIntegerConvertToInteger() {
- for (val value in asList("1", "2", "abc", "5db7b170c06ca69d75ecbb881a937087")) {
+ for (value in asList("1", "2", "abc", "5db7b170c06ca69d75ecbb881a937087")) {
assertEquals(BigInteger(value, 16).intValue(),
runInWorker("(new BigInteger('$value', 16)).intValue();"))
}
@@ -31,21 +31,21 @@ class CodingTest {
val modulus = "abcd1234"
val exponent = "1234abcd"
- val encodedKey = runInWorker("root.Crypt.Coder.encode({ type: 'rsaKey', modulus: _toArray('$modulus'), exponent: _toArray('$exponent') });") as String
+ val encodedKey = runInWorker("epdRoot.Crypt.Coder.encode({ type: 'rsaKey', modulus: _toArray('$modulus'), exponent: _toArray('$exponent') });") as String
val decodedKey = decode(encodedKey) as RSAKey
assertEquals(modulus, decodedKey.modulus.toString(16), "should keep the key's modulus")
assertEquals(exponent, decodedKey.exponent.toString(16), "should keep the key's exponent")
}
test fun testRecodingOfAKeyPair() {
- runInWorker("var keyPair = root.Crypt.Asymmetric.generateKeyPair(512);")
+ runInWorker("var keyPair = epdRoot.Crypt.Asymmetric.generateKeyPair(512);")
val modulus = runInWorker("_toHex(keyPair.publicKey.modulus);") as String
val privateExponent = runInWorker("_toHex(keyPair.privateKey.exponent);") as String
- val encodedPublicKey = runInWorker("root.Crypt.Coder.encode(keyPair.publicKey);") as String
- val encodedPrivateKey = runInWorker("root.Crypt.Coder.encode(keyPair.privateKey);") as String
+ val encodedPublicKey = runInWorker("epdRoot.Crypt.Coder.encode(keyPair.publicKey);") as String
+ val encodedPrivateKey = runInWorker("epdRoot.Crypt.Coder.encode(keyPair.privateKey);") as String
val decodedPublicKey = decode(encodedPublicKey) as RSAKey
val decodedPrivateKey = decode(encodedPrivateKey) as RSAKey
@@ -19,7 +19,7 @@ class MapStringificationTest() {
val sampleProfileJson = writeJson(sampleProfile.map)
test fun testMapStringification() {
- val result = runInWorker("var profile = $sampleProfileJson; profile.floatTestOne = -12.3456789; root.Object.stringify(profile);") as String
+ val result = runInWorker("var profile = $sampleProfileJson; profile.floatTestOne = -12.3456789; epdRoot.Object.stringify(profile);") as String
sampleProfile.map["floatTestOne"] = -12.3456789
assertEquals(result, stringify(sampleProfile.map))
}
@@ -15,12 +15,12 @@ class PasswordHashTest {
val keySize = 160
{
- runInWorker("password = root.Crypt.Password.hash('test', { iterations: $iterations, keySize: ${keySize / 32} });")
+ runInWorker("password = epdRoot.Crypt.Password.hash('test', { iterations: $iterations, keySize: ${keySize / 32} });")
}
test fun testPasswordHashing() {
- val javascriptHash = runInWorker("root.Crypt.Coder.encode(password.hash);") as String
- val javascriptSalt = runInWorker("root.Crypt.Coder.encode(password.salt);") as String
+ val javascriptHash = runInWorker("epdRoot.Crypt.Coder.encode(password.hash);") as String
+ val javascriptSalt = runInWorker("epdRoot.Crypt.Coder.encode(password.salt);") as String
val javascriptIterations = runInWorker("password.iterations;")
val javascriptKeySize = runInWorker("password.keySize;")
@@ -20,11 +20,11 @@ class RSASignatureTest() {
val sampleContent = "test"
{
- runInWorker("var publicKey = root.Crypt.Coder.decode('$encodedPublicKey'), privateKey = root.Crypt.Coder.decode('$encodedPrivateKey');")
+ runInWorker("var publicKey = epdRoot.Crypt.Coder.decode('$encodedPublicKey'), privateKey = epdRoot.Crypt.Coder.decode('$encodedPrivateKey');")
}
test fun testSignatureVerification() {
- val encodedSignature = runInWorker("root.Crypt.Coder.encode(root.Crypt.Asymmetric.sign('$sampleContent', publicKey, privateKey));") as String
+ val encodedSignature = runInWorker("epdRoot.Crypt.Coder.encode(epdRoot.Crypt.Asymmetric.sign('$sampleContent', publicKey, privateKey));") as String
val signature = decode(encodedSignature) as RSASignature
val signer = Signer(sampleContent)
assertTrue(signer.verify(publicKey, signature))
@@ -22,9 +22,9 @@ private val scriptEngine = { (): ScriptEngine ->
val scriptEngineManager = ScriptEngineManager()
val scriptEngine = scriptEngineManager.getEngineByName("JavaScript") as ScriptEngine
try {
- scriptEngine.eval("var navigator = { }, root = { }, profile;")
+ scriptEngine.eval("var navigator = { }, profile;")
scriptEngine.eval(InputStreamReader(ClassLoader.getSystemResourceAsStream("epd.js") as InputStream))
- scriptEngine.eval("var password = root.Crypt.Password.hash('test');")
+ scriptEngine.eval("var password = epdRoot.Crypt.Password.hash('test');")
} catch (exception: Exception) {
debug(exception.toString())
}
Oops, something went wrong. Retry.

0 comments on commit f82a212

Please sign in to comment.