as3corelib 0.1.0 → 0.85.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. data/Gemfile +1 -4
  2. data/Gemfile.lock +7 -4
  3. data/README.textile +20 -10
  4. data/Rakefile +32 -2
  5. data/as3corelib.gemspec +13 -11
  6. data/lib/as3corelib.rb +10 -4
  7. data/lib/as3corelib/version.rb +4 -0
  8. metadata +31 -121
  9. data/build/build.properties +0 -48
  10. data/build/build.xml +0 -104
  11. data/examples/JSONExample/JSONExample.mxml +0 -73
  12. data/src/com/adobe/air/crypto/EncryptionKeyGenerator.as +0 -313
  13. data/src/com/adobe/air/filesystem/FileMonitor.as +0 -245
  14. data/src/com/adobe/air/filesystem/FileUtil.as +0 -63
  15. data/src/com/adobe/air/filesystem/VolumeMonitor.as +0 -184
  16. data/src/com/adobe/air/filesystem/events/FileMonitorEvent.as +0 -61
  17. data/src/com/adobe/air/logging/FileTarget.as +0 -95
  18. data/src/com/adobe/air/net/ResourceCache.as +0 -165
  19. data/src/com/adobe/air/net/events/ResourceCacheEvent.as +0 -70
  20. data/src/com/adobe/crypto/HMAC.as +0 -127
  21. data/src/com/adobe/crypto/MD5.as +0 -281
  22. data/src/com/adobe/crypto/MD5Stream.as +0 -402
  23. data/src/com/adobe/crypto/SHA1.as +0 -289
  24. data/src/com/adobe/crypto/SHA224.as +0 -257
  25. data/src/com/adobe/crypto/SHA256.as +0 -261
  26. data/src/com/adobe/crypto/WSSEUsernameToken.as +0 -114
  27. data/src/com/adobe/errors/IllegalStateError.as +0 -63
  28. data/src/com/adobe/fileformats/vcard/Address.as +0 -47
  29. data/src/com/adobe/fileformats/vcard/Email.as +0 -39
  30. data/src/com/adobe/fileformats/vcard/Phone.as +0 -39
  31. data/src/com/adobe/fileformats/vcard/VCard.as +0 -54
  32. data/src/com/adobe/fileformats/vcard/VCardParser.as +0 -246
  33. data/src/com/adobe/images/BitString.as +0 -39
  34. data/src/com/adobe/images/JPGEncoder.as +0 -648
  35. data/src/com/adobe/images/PNGEncoder.as +0 -141
  36. data/src/com/adobe/net/DynamicURLLoader.as +0 -55
  37. data/src/com/adobe/net/IURIResolver.as +0 -76
  38. data/src/com/adobe/net/MimeTypeMap.as +0 -200
  39. data/src/com/adobe/net/URI.as +0 -2466
  40. data/src/com/adobe/net/URIEncodingBitmap.as +0 -139
  41. data/src/com/adobe/net/proxies/RFC2817Socket.as +0 -198
  42. data/src/com/adobe/protocols/dict/Database.as +0 -66
  43. data/src/com/adobe/protocols/dict/Definition.as +0 -71
  44. data/src/com/adobe/protocols/dict/Dict.as +0 -360
  45. data/src/com/adobe/protocols/dict/DictionaryServer.as +0 -60
  46. data/src/com/adobe/protocols/dict/MatchStrategy.as +0 -66
  47. data/src/com/adobe/protocols/dict/Response.as +0 -71
  48. data/src/com/adobe/protocols/dict/events/ConnectedEvent.as +0 -53
  49. data/src/com/adobe/protocols/dict/events/DatabaseEvent.as +0 -67
  50. data/src/com/adobe/protocols/dict/events/DefinitionEvent.as +0 -70
  51. data/src/com/adobe/protocols/dict/events/DefinitionHeaderEvent.as +0 -69
  52. data/src/com/adobe/protocols/dict/events/DictionaryServerEvent.as +0 -69
  53. data/src/com/adobe/protocols/dict/events/DisconnectedEvent.as +0 -55
  54. data/src/com/adobe/protocols/dict/events/ErrorEvent.as +0 -80
  55. data/src/com/adobe/protocols/dict/events/MatchEvent.as +0 -67
  56. data/src/com/adobe/protocols/dict/events/MatchStrategiesEvent.as +0 -70
  57. data/src/com/adobe/protocols/dict/events/NoMatchEvent.as +0 -54
  58. data/src/com/adobe/protocols/dict/util/CompleteResponseEvent.as +0 -68
  59. data/src/com/adobe/protocols/dict/util/SocketHelper.as +0 -81
  60. data/src/com/adobe/serialization/json/JSON.as +0 -86
  61. data/src/com/adobe/serialization/json/JSONDecoder.as +0 -327
  62. data/src/com/adobe/serialization/json/JSONEncoder.as +0 -312
  63. data/src/com/adobe/serialization/json/JSONParseError.as +0 -87
  64. data/src/com/adobe/serialization/json/JSONToken.as +0 -104
  65. data/src/com/adobe/serialization/json/JSONTokenType.as +0 -69
  66. data/src/com/adobe/serialization/json/JSONTokenizer.as +0 -702
  67. data/src/com/adobe/utils/ArrayUtil.as +0 -187
  68. data/src/com/adobe/utils/DateUtil.as +0 -701
  69. data/src/com/adobe/utils/DictionaryUtil.as +0 -87
  70. data/src/com/adobe/utils/IntUtil.as +0 -99
  71. data/src/com/adobe/utils/NumberFormatter.as +0 -74
  72. data/src/com/adobe/utils/StringUtil.as +0 -239
  73. data/src/com/adobe/utils/XMLUtil.as +0 -168
  74. data/src/com/adobe/webapis/ServiceBase.as +0 -48
  75. data/src/com/adobe/webapis/URLLoaderBase.as +0 -108
  76. data/src/com/adobe/webapis/events/ServiceEvent.as +0 -82
  77. data/tests/src/CoreLibTestRunner-app.xml +0 -135
  78. data/tests/src/CoreLibTestRunner.as +0 -138
  79. data/tests/src/CoreLibTestRunner.mxml +0 -46
  80. data/tests/src/com/adobe/air/crypto/EncryptionKeyGeneratorTest.as +0 -176
  81. data/tests/src/com/adobe/air/filesystem/FileMonitorTest.as +0 -63
  82. data/tests/src/com/adobe/air/filesystem/VolumeMonitorTest.as +0 -57
  83. data/tests/src/com/adobe/air/filesystem/events/FileMonitorEventTest.as +0 -59
  84. data/tests/src/com/adobe/air/net/events/ResourceCacheEventTest.as +0 -72
  85. data/tests/src/com/adobe/crypto/HMACMD5Test.as +0 -134
  86. data/tests/src/com/adobe/crypto/HMACSHA1Test.as +0 -138
  87. data/tests/src/com/adobe/crypto/MD5Test.as +0 -82
  88. data/tests/src/com/adobe/crypto/SHA1Test.as +0 -151
  89. data/tests/src/com/adobe/crypto/SHA224Test.as +0 -104
  90. data/tests/src/com/adobe/crypto/SHA256Test.as +0 -116
  91. data/tests/src/com/adobe/crypto/WSSEUsernameTokenTest.as +0 -87
  92. data/tests/src/com/adobe/images/JPGEncoderTest.as +0 -54
  93. data/tests/src/com/adobe/images/PNGEncoderTest.as +0 -54
  94. data/tests/src/com/adobe/net/URITest.as +0 -589
  95. data/tests/src/com/adobe/protocols/events/ConnectedEventTest.as +0 -59
  96. data/tests/src/com/adobe/protocols/events/DatabaseEventTest.as +0 -62
  97. data/tests/src/com/adobe/protocols/events/DefinitionEventTest.as +0 -61
  98. data/tests/src/com/adobe/protocols/events/DefinitionHeaderEventTest.as +0 -61
  99. data/tests/src/com/adobe/protocols/events/DictionaryServerEventTest.as +0 -61
  100. data/tests/src/com/adobe/protocols/events/DisconnectedEventTest.as +0 -59
  101. data/tests/src/com/adobe/protocols/events/ErrorEventTest.as +0 -63
  102. data/tests/src/com/adobe/protocols/events/MatchEventTest.as +0 -61
  103. data/tests/src/com/adobe/protocols/events/MatchStrategiesEventTest.as +0 -61
  104. data/tests/src/com/adobe/protocols/events/NoMatchEventTest.as +0 -58
  105. data/tests/src/com/adobe/protocols/util/CompletedResponseEventTest.as +0 -60
  106. data/tests/src/com/adobe/serialization/json/JSONTest.as +0 -522
  107. data/tests/src/com/adobe/serialization/json/SimpleClass.as +0 -85
  108. data/tests/src/com/adobe/utils/ArrayUtilTest.as +0 -173
  109. data/tests/src/com/adobe/utils/DateUtilTest.as +0 -436
  110. data/tests/src/com/adobe/utils/DictionaryUtilTest.as +0 -93
  111. data/tests/src/com/adobe/utils/IntUtilTest.as +0 -73
  112. data/tests/src/com/adobe/utils/NumberFormatterTest.as +0 -70
  113. data/tests/src/com/adobe/utils/StringUtilTest.as +0 -304
  114. data/tests/src/com/adobe/utils/XMLUtilTest.as +0 -101
  115. data/tests/src/com/adobe/webapis/events/ServiceEventTest.as +0 -66
@@ -1,151 +0,0 @@
1
- /*
2
- Copyright (c) 2008, Adobe Systems Incorporated
3
- All rights reserved.
4
-
5
- Redistribution and use in source and binary forms, with or without
6
- modification, are permitted provided that the following conditions are
7
- met:
8
-
9
- * Redistributions of source code must retain the above copyright notice,
10
- this list of conditions and the following disclaimer.
11
-
12
- * Redistributions in binary form must reproduce the above copyright
13
- notice, this list of conditions and the following disclaimer in the
14
- documentation and/or other materials provided with the distribution.
15
-
16
- * Neither the name of Adobe Systems Incorporated nor the names of its
17
- contributors may be used to endorse or promote products derived from
18
- this software without specific prior written permission.
19
-
20
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
- */
32
-
33
- package com.adobe.crypto
34
- {
35
-
36
- import flash.utils.ByteArray;
37
- import flexunit.framework.TestCase;
38
- import flexunit.framework.TestSuite;
39
-
40
- import com.adobe.crypto.SHA1;
41
- import com.adobe.utils.IntUtil;
42
-
43
- public class SHA1Test extends TestCase {
44
-
45
- public function SHA1Test( methodName:String = null ) {
46
- super( methodName );
47
- }
48
-
49
- public function testSHA1():void {
50
-
51
- assertSHA1( "abc", "a9993e364706816aba3e25717850c26c9cd0d89d" );
52
-
53
- assertSHA1( "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
54
- "84983e441c3bd26ebaae4aa1f95129e5e54670f1" );
55
-
56
- assertSHA1( "The quick brown fox jumps over the lazy dog",
57
- "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12" );
58
-
59
- assertSHA1( "The quick brown fox jumps over the lazy cog",
60
- "de9f2c7fd25e1b3afad3e85a0bd17d9b100db4b3" );
61
-
62
- assertSHA1( "",
63
- "da39a3ee5e6b4b0d3255bfef95601890afd80709" );
64
-
65
- assertSHA1( "d36e316282959a9ed4c89851497a717f2003-12-15T14:43:07Ztaadtaadpstcsm",
66
- "aae47f1162c0578c4b7fd66acb0e290e67d5f4e6" );
67
-
68
- var millionAs:String = new String("");
69
- for ( var i:int = 0; i < 1000000; i++ ) {
70
- millionAs += "a";
71
- }
72
- assertSHA1( millionAs, "34aa973cd4c4daa4f61eeb2bdbad27316534016f" );
73
- }
74
-
75
- public function testSHA1Binary():void {
76
-
77
- assertSHA1Binary( "abc", "a9993e364706816aba3e25717850c26c9cd0d89d" );
78
-
79
- assertSHA1Binary( "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
80
- "84983e441c3bd26ebaae4aa1f95129e5e54670f1" );
81
-
82
- assertSHA1Binary( "The quick brown fox jumps over the lazy dog",
83
- "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12" );
84
-
85
- assertSHA1Binary( "The quick brown fox jumps over the lazy cog",
86
- "de9f2c7fd25e1b3afad3e85a0bd17d9b100db4b3" );
87
-
88
- assertSHA1Binary( "",
89
- "da39a3ee5e6b4b0d3255bfef95601890afd80709" );
90
-
91
- assertSHA1Binary( "d36e316282959a9ed4c89851497a717f2003-12-15T14:43:07Ztaadtaadpstcsm",
92
- "aae47f1162c0578c4b7fd66acb0e290e67d5f4e6" );
93
-
94
- var millionAs:String = new String("");
95
- for ( var i:int = 0; i < 1000000; i++ ) {
96
- millionAs += "a";
97
- }
98
- assertSHA1Binary( millionAs, "34aa973cd4c4daa4f61eeb2bdbad27316534016f" );
99
- }
100
-
101
- public function testSHA1Base64():void {
102
- assertSHA1Base64( "abc", "qZk+NkcGgWq6PiVxeFDCbJzQ2J0=" );
103
-
104
- assertSHA1Base64( "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
105
- "hJg+RBw70m66rkqh+VEp5eVGcPE=");
106
-
107
- assertSHA1Base64( "The quick brown fox jumps over the lazy dog",
108
- "L9ThxnotKPzthJ7hu3bnORuT6xI=" );
109
-
110
- assertSHA1Base64( "The quick brown fox jumps over the lazy cog",
111
- "3p8sf9JeGzr60+haC9F9mxANtLM=" );
112
-
113
- assertSHA1Base64( "",
114
- "2jmj7l5rSw0yVb/vlWAYkK/YBwk=" );
115
-
116
- assertSHA1Base64( "d36e316282959a9ed4c89851497a717f2003-12-15T14:43:07Ztaadtaadpstcsm",
117
- "quR/EWLAV4xLf9Zqyw4pDmfV9OY=" );
118
-
119
- var millionAs:String = new String("");
120
- for ( var i:int = 0; i < 1000000; i++ ) {
121
- millionAs += "a";
122
- }
123
- assertSHA1Base64( millionAs, "NKqXPNTE2qT2Husr260nMWU0AW8=" );
124
- }
125
-
126
- private function assertSHA1( value:String, expected:String ):void {
127
- var result:String = SHA1.hash( value );
128
-
129
- assertTrue( "Hash of '" + value + "' returned wrong value ('" + result + "')",
130
- result == expected );
131
- }
132
-
133
- private function assertSHA1Binary(value:String, expected:String):void {
134
-
135
- var byteArray:ByteArray = new ByteArray();
136
- byteArray.writeUTFBytes(value);
137
-
138
- var result:String = SHA1.hashBytes( byteArray );
139
- assertTrue( "Hash of '" + value + "' returned wrong value ('" + result + "')",
140
- result == expected );
141
- }
142
-
143
- private function assertSHA1Base64( value:String, expected:String ):void {
144
- var result:String = SHA1.hashToBase64( value );
145
-
146
- assertTrue( "Hash of '" + value + "' returned wrong value ('" + result + "')",
147
- result == expected );
148
- }
149
-
150
- }
151
- }
@@ -1,104 +0,0 @@
1
- /*
2
- Copyright (c) 2008, Adobe Systems Incorporated
3
- All rights reserved.
4
-
5
- Redistribution and use in source and binary forms, with or without
6
- modification, are permitted provided that the following conditions are
7
- met:
8
-
9
- * Redistributions of source code must retain the above copyright notice,
10
- this list of conditions and the following disclaimer.
11
-
12
- * Redistributions in binary form must reproduce the above copyright
13
- notice, this list of conditions and the following disclaimer in the
14
- documentation and/or other materials provided with the distribution.
15
-
16
- * Neither the name of Adobe Systems Incorporated nor the names of its
17
- contributors may be used to endorse or promote products derived from
18
- this software without specific prior written permission.
19
-
20
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
- */
32
-
33
- package com.adobe.crypto
34
- {
35
-
36
- import flash.utils.ByteArray;
37
- import flexunit.framework.TestCase;
38
- import flexunit.framework.TestSuite;
39
-
40
- import com.adobe.crypto.SHA256;
41
-
42
- public class SHA224Test extends TestCase {
43
-
44
- public function SHA224Test( methodName:String = null ) {
45
- super( methodName );
46
- }
47
-
48
- public function testSHA224():void {
49
-
50
- // from the spec ( http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf )
51
- assertSHA224( "abc", "23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7" );
52
- assertSHA224( "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525" );
53
-
54
- var millionAs:String = new String("");
55
- for ( var i:int = 0; i < 1000000; i++ ) {
56
- millionAs += "a";
57
- }
58
- assertSHA224( millionAs, "20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67" );
59
-
60
- }
61
-
62
- public function testSHA224Binary():void {
63
-
64
- // from the spec ( http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf )
65
- assertSHA224Binary( "abc", "23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7" );
66
- assertSHA224Binary( "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525" );
67
-
68
- var millionAs:String = new String("");
69
- for ( var i:int = 0; i < 1000000; i++ ) {
70
- millionAs += "a";
71
- }
72
- assertSHA224Binary( millionAs, "20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67" );
73
- }
74
-
75
- public function testSHA224Base64():void {
76
-
77
- }
78
-
79
- private function assertSHA224( value:String, expected:String ):void {
80
- var result:String = SHA224.hash( value );
81
-
82
- assertTrue( "Hash of '" + value + "' returned wrong value ('" + result + "')",
83
- result == expected );
84
- }
85
-
86
- private function assertSHA224Binary(value:String, expected:String):void {
87
-
88
- var byteArray:ByteArray = new ByteArray();
89
- byteArray.writeUTFBytes(value);
90
-
91
- var result:String = SHA224.hashBytes( byteArray );
92
- assertTrue( "Hash of '" + value + "' returned wrong value ('" + result + "')",
93
- result == expected );
94
- }
95
-
96
- private function assertSHA224Base64( value:String, expected:String ):void {
97
- var result:String = SHA224.hashToBase64( value );
98
-
99
- assertTrue( "Hash of '" + value + "' returned wrong value ('" + result + "')",
100
- result == expected );
101
- }
102
-
103
- }
104
- }
@@ -1,116 +0,0 @@
1
- /*
2
- Copyright (c) 2008, Adobe Systems Incorporated
3
- All rights reserved.
4
-
5
- Redistribution and use in source and binary forms, with or without
6
- modification, are permitted provided that the following conditions are
7
- met:
8
-
9
- * Redistributions of source code must retain the above copyright notice,
10
- this list of conditions and the following disclaimer.
11
-
12
- * Redistributions in binary form must reproduce the above copyright
13
- notice, this list of conditions and the following disclaimer in the
14
- documentation and/or other materials provided with the distribution.
15
-
16
- * Neither the name of Adobe Systems Incorporated nor the names of its
17
- contributors may be used to endorse or promote products derived from
18
- this software without specific prior written permission.
19
-
20
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
- */
32
-
33
- package com.adobe.crypto
34
- {
35
-
36
- import flash.utils.ByteArray;
37
- import flexunit.framework.TestCase;
38
- import flexunit.framework.TestSuite;
39
-
40
- import com.adobe.crypto.SHA256;
41
-
42
- public class SHA256Test extends TestCase {
43
-
44
- public function SHA256Test( methodName:String = null ) {
45
- super( methodName );
46
- }
47
-
48
- public function testSHA256():void {
49
-
50
-
51
- // from the spec ( http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf )
52
- assertSHA256( "abc", "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" );
53
- assertSHA256( "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1");
54
-
55
- var millionAs:String = new String("");
56
- for ( var i:int = 0; i < 1000000; i++ ) {
57
- millionAs += "a";
58
- }
59
- assertSHA256( millionAs, "cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0" );
60
-
61
- // from wikipedia
62
- assertSHA256( "The quick brown fox jumps over the lazy dog", "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592" );
63
- assertSHA256( "The quick brown fox jumps over the lazy cog", "e4c4d8f3bf76b692de791a173e05321150f7a345b46484fe427f6acc7ecc81be" );
64
- assertSHA256( "", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" );
65
-
66
- }
67
-
68
- public function testSHA256Binary():void {
69
-
70
- // from the spec ( http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf )
71
- assertSHA256Binary( "abc", "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" );
72
- assertSHA256Binary( "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1");
73
-
74
- var millionAs:String = new String("");
75
- for ( var i:int = 0; i < 1000000; i++ ) {
76
- millionAs += "a";
77
- }
78
- assertSHA256Binary( millionAs, "cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0" );
79
-
80
- // from wikipedia
81
- assertSHA256Binary( "The quick brown fox jumps over the lazy dog", "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592" );
82
- assertSHA256Binary( "The quick brown fox jumps over the lazy cog", "e4c4d8f3bf76b692de791a173e05321150f7a345b46484fe427f6acc7ecc81be" );
83
- assertSHA256Binary( "", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" );
84
-
85
- }
86
-
87
- public function testSHA256Base64():void {
88
-
89
- }
90
-
91
- private function assertSHA256( value:String, expected:String ):void {
92
- var result:String = SHA256.hash( value );
93
-
94
- assertTrue( "Hash of '" + value + "' returned wrong value ('" + result + "')",
95
- result == expected );
96
- }
97
-
98
- private function assertSHA256Binary(value:String, expected:String):void {
99
-
100
- var byteArray:ByteArray = new ByteArray();
101
- byteArray.writeUTFBytes(value);
102
-
103
- var result:String = SHA256.hashBytes( byteArray );
104
- assertTrue( "Hash of '" + value + "' returned wrong value ('" + result + "')",
105
- result == expected );
106
- }
107
-
108
- private function assertSHA256Base64( value:String, expected:String ):void {
109
- var result:String = SHA256.hashToBase64( value );
110
-
111
- assertTrue( "Hash of '" + value + "' returned wrong value ('" + result + "')",
112
- result == expected );
113
- }
114
-
115
- }
116
- }
@@ -1,87 +0,0 @@
1
- /*
2
- Copyright (c) 2008, Adobe Systems Incorporated
3
- All rights reserved.
4
-
5
- Redistribution and use in source and binary forms, with or without
6
- modification, are permitted provided that the following conditions are
7
- met:
8
-
9
- * Redistributions of source code must retain the above copyright notice,
10
- this list of conditions and the following disclaimer.
11
-
12
- * Redistributions in binary form must reproduce the above copyright
13
- notice, this list of conditions and the following disclaimer in the
14
- documentation and/or other materials provided with the distribution.
15
-
16
- * Neither the name of Adobe Systems Incorporated nor the names of its
17
- contributors may be used to endorse or promote products derived from
18
- this software without specific prior written permission.
19
-
20
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
- */
32
-
33
- package com.adobe.crypto
34
- {
35
-
36
- import com.adobe.crypto.WSSEUsernameToken;
37
-
38
- import flexunit.framework.TestCase;
39
- import flexunit.framework.TestSuite;
40
-
41
- public class WSSEUsernameTokenTest extends TestCase {
42
-
43
- public function WSSEUsernameTokenTest( methodName:String = null ) {
44
- super( methodName );
45
- }
46
-
47
- public function testWSSEUsernameToken():void {
48
-
49
- // Results generated from stripped-down version of Claude
50
- // Montpetit's WSSE-enabled Atom API client (see
51
- // http://www.montpetit.net/en/2004/06/06/11h32/index.html).
52
- //
53
-
54
- var date:Date = new Date(Date.parse("05/09/2006 13:43:21 GMT-0700"));
55
- assertWSSEUsernameToken( "abc", "abc", "0123456789", date,
56
- "UsernameToken Username=\"abc\", PasswordDigest=\""
57
- + WSSEUsernameToken.getBase64Digest( WSSEUsernameToken.base64Encode( "0123456789" ),
58
- WSSEUsernameToken.generateTimestamp( date ),
59
- "abc" )
60
- + "\", Nonce=\"MDEyMzQ1Njc4OQ==\", Created=\"2006-05-09T" + ( date.hours < 10 ? "0" + date.hours : date.hours ) + ":43:21Z\"" );
61
-
62
- date = new Date(Date.parse("05/09/2006 16:11:46 GMT-0700"));
63
- assertWSSEUsernameToken( "fe31_449", "168fqo4659", "1147216300992", date,
64
- "UsernameToken Username=\"fe31_449\", PasswordDigest=\""
65
- + WSSEUsernameToken.getBase64Digest( WSSEUsernameToken.base64Encode( "1147216300992" ),
66
- WSSEUsernameToken.generateTimestamp( date ),
67
- "168fqo4659" )
68
- + "\", Nonce=\"MTE0NzIxNjMwMDk5Mg==\", Created=\"2006-05-09T" + ( date.hours < 10 ? "0" + date.hours : date.hours ) + ":11:46Z\"" );
69
-
70
- date = new Date(Date.parse("08/16/2006 01:48:28 GMT-0700"));
71
- assertWSSEUsernameToken( "candy", "dandy", "2018558572", date,
72
- "UsernameToken Username=\"candy\", PasswordDigest=\""
73
- + WSSEUsernameToken.getBase64Digest( WSSEUsernameToken.base64Encode( "2018558572" ),
74
- WSSEUsernameToken.generateTimestamp( date ),
75
- "dandy" )
76
- + "\", Nonce=\"MjAxODU1ODU3Mg==\", Created=\"2006-08-16T" + ( date.hours < 10 ? "0" + date.hours : date.hours ) + ":48:28Z\"" );
77
- }
78
-
79
- private function assertWSSEUsernameToken( username:String, password:String, nonce:String,
80
- timestamp:Date, expected:String ):void {
81
- var result:String = WSSEUsernameToken.getUsernameToken( username, password, nonce, timestamp );
82
-
83
- assertTrue( "WSSEUsernameToken returned wrong value ('" + result + "')" + expected,
84
- result == expected );
85
- }
86
- }
87
- }