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,261 +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
- import com.adobe.utils.IntUtil;
36
- import flash.utils.ByteArray;
37
- import mx.utils.Base64Encoder;
38
-
39
- /**
40
- * The SHA-256 algorithm
41
- *
42
- * @see http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf
43
- */
44
- public class SHA256
45
- {
46
- public static var digest:ByteArray;
47
- /**
48
- * Performs the SHA256 hash algorithm on a string.
49
- *
50
- * @param s The string to hash
51
- * @return A string containing the hash value of s
52
- * @langversion ActionScript 3.0
53
- * @playerversion 9.0
54
- * @tiptext
55
- */
56
- public static function hash( s:String ):String {
57
- var blocks:Array = createBlocksFromString( s );
58
- var byteArray:ByteArray = hashBlocks( blocks );
59
-
60
- return IntUtil.toHex( byteArray.readInt(), true )
61
- + IntUtil.toHex( byteArray.readInt(), true )
62
- + IntUtil.toHex( byteArray.readInt(), true )
63
- + IntUtil.toHex( byteArray.readInt(), true )
64
- + IntUtil.toHex( byteArray.readInt(), true )
65
- + IntUtil.toHex( byteArray.readInt(), true )
66
- + IntUtil.toHex( byteArray.readInt(), true )
67
- + IntUtil.toHex( byteArray.readInt(), true );
68
- }
69
-
70
- /**
71
- * Performs the SHA256 hash algorithm on a ByteArray.
72
- *
73
- * @param data The ByteArray data to hash
74
- * @return A string containing the hash value of data
75
- * @langversion ActionScript 3.0
76
- * @playerversion 9.0
77
- */
78
- public static function hashBytes( data:ByteArray ):String
79
- {
80
- var blocks:Array = createBlocksFromByteArray( data );
81
- var byteArray:ByteArray = hashBlocks(blocks);
82
-
83
- return IntUtil.toHex( byteArray.readInt(), true )
84
- + IntUtil.toHex( byteArray.readInt(), true )
85
- + IntUtil.toHex( byteArray.readInt(), true )
86
- + IntUtil.toHex( byteArray.readInt(), true )
87
- + IntUtil.toHex( byteArray.readInt(), true )
88
- + IntUtil.toHex( byteArray.readInt(), true )
89
- + IntUtil.toHex( byteArray.readInt(), true )
90
- + IntUtil.toHex( byteArray.readInt(), true );
91
- }
92
-
93
- /**
94
- * Performs the SHA256 hash algorithm on a string, then does
95
- * Base64 encoding on the result.
96
- *
97
- * @param s The string to hash
98
- * @return The base64 encoded hash value of s
99
- * @langversion ActionScript 3.0
100
- * @playerversion 9.0
101
- * @tiptext
102
- */
103
- public static function hashToBase64( s:String ):String
104
- {
105
- var blocks:Array = createBlocksFromString( s );
106
- var byteArray:ByteArray = hashBlocks(blocks);
107
-
108
- // ByteArray.toString() returns the contents as a UTF-8 string,
109
- // which we can't use because certain byte sequences might trigger
110
- // a UTF-8 conversion. Instead, we convert the bytes to characters
111
- // one by one.
112
- var charsInByteArray:String = "";
113
- byteArray.position = 0;
114
- for (var j:int = 0; j < byteArray.length; j++)
115
- {
116
- var byte:uint = byteArray.readUnsignedByte();
117
- charsInByteArray += String.fromCharCode(byte);
118
- }
119
-
120
- var encoder:Base64Encoder = new Base64Encoder();
121
- encoder.encode(charsInByteArray);
122
- return encoder.flush();
123
- }
124
-
125
- private static function hashBlocks( blocks:Array ):ByteArray {
126
- var h0:int = 0x6a09e667;
127
- var h1:int = 0xbb67ae85;
128
- var h2:int = 0x3c6ef372;
129
- var h3:int = 0xa54ff53a;
130
- var h4:int = 0x510e527f;
131
- var h5:int = 0x9b05688c;
132
- var h6:int = 0x1f83d9ab;
133
- var h7:int = 0x5be0cd19;
134
-
135
- var k:Array = new Array(0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2);
136
-
137
- var len:int = blocks.length;
138
- var w:Array = new Array( 64 );
139
-
140
- // loop over all of the blocks
141
- for ( var i:int = 0; i < len; i += 16 ) {
142
-
143
- var a:int = h0;
144
- var b:int = h1;
145
- var c:int = h2;
146
- var d:int = h3;
147
- var e:int = h4;
148
- var f:int = h5;
149
- var g:int = h6;
150
- var h:int = h7;
151
-
152
- for(var t:int = 0; t < 64; t++) {
153
-
154
- if ( t < 16 ) {
155
- w[t] = blocks[ i + t ];
156
- if(isNaN(w[t])) { w[t] = 0; }
157
- } else {
158
- var ws0:int = IntUtil.ror(w[t-15], 7) ^ IntUtil.ror(w[t-15], 18) ^ (w[t-15] >>> 3);
159
- var ws1:int = IntUtil.ror(w[t-2], 17) ^ IntUtil.ror(w[t-2], 19) ^ (w[t-2] >>> 10);
160
- w[t] = w[t-16] + ws0 + w[t-7] + ws1;
161
- }
162
-
163
- var s0:int = IntUtil.ror(a, 2) ^ IntUtil.ror(a, 13) ^ IntUtil.ror(a, 22);
164
- var maj:int = (a & b) ^ (a & c) ^ (b & c);
165
- var t2:int = s0 + maj;
166
- var s1:int = IntUtil.ror(e, 6) ^ IntUtil.ror(e, 11) ^ IntUtil.ror(e, 25);
167
- var ch:int = (e & f) ^ ((~e) & g);
168
- var t1:int = h + s1 + ch + k[t] + w[t];
169
-
170
- h = g;
171
- g = f;
172
- f = e;
173
- e = d + t1;
174
- d = c;
175
- c = b;
176
- b = a;
177
- a = t1 + t2;
178
- }
179
-
180
- //Add this chunk's hash to result so far:
181
- h0 += a;
182
- h1 += b;
183
- h2 += c;
184
- h3 += d;
185
- h4 += e;
186
- h5 += f;
187
- h6 += g;
188
- h7 += h;
189
- }
190
-
191
- var byteArray:ByteArray = new ByteArray();
192
- byteArray.writeInt(h0);
193
- byteArray.writeInt(h1);
194
- byteArray.writeInt(h2);
195
- byteArray.writeInt(h3);
196
- byteArray.writeInt(h4);
197
- byteArray.writeInt(h5);
198
- byteArray.writeInt(h6);
199
- byteArray.writeInt(h7);
200
- byteArray.position = 0;
201
-
202
- digest = new ByteArray();
203
- digest.writeBytes(byteArray);
204
- digest.position = 0;
205
- return byteArray;
206
- }
207
-
208
- /**
209
- * Converts a ByteArray to a sequence of 16-word blocks
210
- * that we'll do the processing on. Appends padding
211
- * and length in the process.
212
- *
213
- * @param data The data to split into blocks
214
- * @return An array containing the blocks into which data was split
215
- */
216
- private static function createBlocksFromByteArray( data:ByteArray ):Array
217
- {
218
- var oldPosition:int = data.position;
219
- data.position = 0;
220
-
221
- var blocks:Array = new Array();
222
- var len:int = data.length * 8;
223
- var mask:int = 0xFF; // ignore hi byte of characters > 0xFF
224
- for( var i:int = 0; i < len; i += 8 )
225
- {
226
- blocks[ i >> 5 ] |= ( data.readByte() & mask ) << ( 24 - i % 32 );
227
- }
228
-
229
- // append padding and length
230
- blocks[ len >> 5 ] |= 0x80 << ( 24 - len % 32 );
231
- blocks[ ( ( ( len + 64 ) >> 9 ) << 4 ) + 15 ] = len;
232
-
233
- data.position = oldPosition;
234
-
235
- return blocks;
236
- }
237
-
238
- /**
239
- * Converts a string to a sequence of 16-word blocks
240
- * that we'll do the processing on. Appends padding
241
- * and length in the process.
242
- *
243
- * @param s The string to split into blocks
244
- * @return An array containing the blocks that s was split into.
245
- */
246
- private static function createBlocksFromString( s:String ):Array
247
- {
248
- var blocks:Array = new Array();
249
- var len:int = s.length * 8;
250
- var mask:int = 0xFF; // ignore hi byte of characters > 0xFF
251
- for( var i:int = 0; i < len; i += 8 ) {
252
- blocks[ i >> 5 ] |= ( s.charCodeAt( i / 8 ) & mask ) << ( 24 - i % 32 );
253
- }
254
-
255
- // append padding and length
256
- blocks[ len >> 5 ] |= 0x80 << ( 24 - len % 32 );
257
- blocks[ ( ( ( len + 64 ) >> 9 ) << 4 ) + 15 ] = len;
258
- return blocks;
259
- }
260
- }
261
- }
@@ -1,114 +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
- import mx.formatters.DateFormatter;
36
- import mx.utils.Base64Encoder;
37
-
38
- /**
39
- * Web Services Security Username Token
40
- *
41
- * Implementation based on algorithm description at
42
- * http://www.oasis-open.org/committees/wss/documents/WSS-Username-02-0223-merged.pdf
43
- */
44
- public class WSSEUsernameToken
45
- {
46
- /**
47
- * Generates a WSSE Username Token.
48
- *
49
- * @param username The username
50
- * @param password The password
51
- * @param nonce A cryptographically random nonce (if null, the nonce
52
- * will be generated)
53
- * @param timestamp The time at which the token is generated (if null,
54
- * the time will be set to the moment of execution)
55
- * @return The generated token
56
- * @langversion ActionScript 3.0
57
- * @playerversion Flash 9.0
58
- * @tiptext
59
- */
60
- public static function getUsernameToken(username:String, password:String, nonce:String=null, timestamp:Date=null):String
61
- {
62
- if (nonce == null)
63
- {
64
- nonce = generateNonce();
65
- }
66
- nonce = base64Encode(nonce);
67
-
68
- var created:String = generateTimestamp(timestamp);
69
-
70
- var password64:String = getBase64Digest(nonce,
71
- created,
72
- password);
73
-
74
- var token:String = new String("UsernameToken Username=\"");
75
- token += username + "\", " +
76
- "PasswordDigest=\"" + password64 + "\", " +
77
- "Nonce=\"" + nonce + "\", " +
78
- "Created=\"" + created + "\"";
79
- return token;
80
- }
81
-
82
- private static function generateNonce():String
83
- {
84
- // Math.random returns a Number between 0 and 1. We don't want our
85
- // nonce to contain invalid characters (e.g. the period) so we
86
- // strip them out before returning the result.
87
- var s:String = Math.random().toString();
88
- return s.replace(".", "");
89
- }
90
-
91
- internal static function base64Encode(s:String):String
92
- {
93
- var encoder:Base64Encoder = new Base64Encoder();
94
- encoder.encode(s);
95
- return encoder.flush();
96
- }
97
-
98
- internal static function generateTimestamp(timestamp:Date):String
99
- {
100
- if (timestamp == null)
101
- {
102
- timestamp = new Date();
103
- }
104
- var dateFormatter:DateFormatter = new DateFormatter();
105
- dateFormatter.formatString = "YYYY-MM-DDTJJ:NN:SS"
106
- return dateFormatter.format(timestamp) + "Z";
107
- }
108
-
109
- internal static function getBase64Digest(nonce:String, created:String, password:String):String
110
- {
111
- return SHA1.hashToBase64(nonce + created + password);
112
- }
113
- }
114
- }
@@ -1,63 +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.errors
34
- {
35
- /**
36
- * This class represents an Error that is thrown when a method is called when
37
- * the receiving instance is in an invalid state.
38
- *
39
- * For example, this may occur if a method has been called, and other properties
40
- * in the instance have not been initialized properly.
41
- *
42
- * @langversion ActionScript 3.0
43
- * @playerversion Flash 9.0
44
- * @tiptext
45
- *
46
- */
47
- public class IllegalStateError extends Error
48
- {
49
- /**
50
- * Constructor
51
- *
52
- * @param message A message describing the error in detail.
53
- *
54
- * @langversion ActionScript 3.0
55
- * @playerversion Flash 9.0
56
- * @tiptext
57
- */
58
- public function IllegalStateError(message:String)
59
- {
60
- super(message);
61
- }
62
- }
63
- }
@@ -1,47 +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
- package com.adobe.fileformats.vcard
33
- {
34
- public class Address
35
- {
36
- public var type:String;
37
- public var street:String;
38
- public var city:String;
39
- public var state:String;
40
- public var postalCode:String;
41
-
42
- public function toString():String
43
- {
44
- return (street + " " + city + ", " + state + " " + postalCode);
45
- }
46
- }
47
- }