Merge lp:~nik90/cliffhanger/fix-authentication-error into lp:~flashback-dev/cliffhanger/trunk

Proposed by Nekhelesh Ramananthan
Status: Merged
Merged at revision: 49
Proposed branch: lp:~nik90/cliffhanger/fix-authentication-error
Merge into: lp:~flashback-dev/cliffhanger/trunk
Diff against target: 405 lines (+214/-146)
4 files modified
Flashback.json (+1/-1)
backend/sha1.js (+201/-144)
manifest.json (+1/-1)
ui/TraktLogin.qml (+11/-0)
To merge this branch: bzr merge lp:~nik90/cliffhanger/fix-authentication-error
Reviewer Review Type Date Requested Status
Flashback Dev Pending
Review via email: mp+213267@code.launchpad.net

Commit message

1298989

Description of the change

Fixed the authentication error and provided a way to show/hide the password in clear text.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Flashback.json'
--- Flashback.json 2013-12-12 12:30:07 +0000
+++ Flashback.json 2014-03-28 13:53:23 +0000
@@ -3,4 +3,4 @@
3 "networking"3 "networking"
4 ],4 ],
5 "policy_version": 15 "policy_version": 1
6}6}
7\ No newline at end of file7\ No newline at end of file
88
=== modified file 'backend/sha1.js'
--- backend/sha1.js 2013-11-21 22:11:26 +0000
+++ backend/sha1.js 2014-03-28 13:53:23 +0000
@@ -1,145 +1,202 @@
1function sha1 (str) {1/*
2 // http://kevin.vanzonneveld.net2 * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
3 // + original by: Webtoolkit.info (http://www.webtoolkit.info/)3 * in FIPS PUB 180-1
4 // + namespaced by: Michael White (http://getsprink.com)4 * Version 2.1a Copyright Paul Johnston 2000 - 2002.
5 // + input by: Brett Zamir (http://brett-zamir.me)5 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
6 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)6 * Distributed under the BSD License
7 // - depends on: utf8_encode7 * See http://pajhome.org.uk/crypt/md5 for details.
8 // * example 1: sha1('Kevin van Zonneveld');8 */
9 // * returns 1: '54916d2e62f65b3afa6e192e6a601cdbe5cb5897'9
10 var rotate_left = function (n, s) {10/*
11 var t4 = (n << s) | (n >>> (32 - s));11 * Configurable variables. You may need to tweak these to be compatible with
12 return t4;12 * the server-side, but the defaults work in most cases.
13 };13 */
1414var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
15/*var lsb_hex = function (val) { // Not in use; needed?15var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
16 var str="";16var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
17 var i;17
18 var vh;18/*
19 var vl;19 * These are the functions you'll usually want to call
2020 * They take string arguments and return either hex or base-64 encoded strings
21 for ( i=0; i<=6; i+=2 ) {21 */
22 vh = (val>>>(i*4+4))&0x0f;22function sha1(s){return binb2hex(core_sha1(str2binb(s),s.length * chrsz));}
23 vl = (val>>>(i*4))&0x0f;23function b64_sha1(s){return binb2b64(core_sha1(str2binb(s),s.length * chrsz));}
24 str += vh.toString(16) + vl.toString(16);24function str_sha1(s){return binb2str(core_sha1(str2binb(s),s.length * chrsz));}
25 }25function hex_hmac_sha1(key, data){ return binb2hex(core_hmac_sha1(key, data));}
26 return str;26function b64_hmac_sha1(key, data){ return binb2b64(core_hmac_sha1(key, data));}
27 };*/27function str_hmac_sha1(key, data){ return binb2str(core_hmac_sha1(key, data));}
2828
29 var cvt_hex = function (val) {29/*
30 var str = "";30 * Perform a simple self-test to see if the VM is working
31 var i;31 */
32 var v;32function sha1_vm_test()
3333{
34 for (i = 7; i >= 0; i--) {34 return sha1("abc") == "a9993e364706816aba3e25717850c26c9cd0d89d";
35 v = (val >>> (i * 4)) & 0x0f;35}
36 str += v.toString(16);36
37 }37/*
38 return str;38 * Calculate the SHA-1 of an array of big-endian words, and a bit length
39 };39 */
4040function core_sha1(x, len)
41 var blockstart;41{
42 var i, j;42 /* append padding */
43 var W = new Array(80);43 x[len >> 5] |= 0x80 << (24 - len % 32);
44 var H0 = 0x67452301;44 x[((len + 64 >> 9) << 4) + 15] = len;
45 var H1 = 0xEFCDAB89;45
46 var H2 = 0x98BADCFE;46 var w = Array(80);
47 var H3 = 0x10325476;47 var a = 1732584193;
48 var H4 = 0xC3D2E1F0;48 var b = -271733879;
49 var A, B, C, D, E;49 var c = -1732584194;
50 var temp;50 var d = 271733878;
5151 var e = -1009589776;
52 str = encodeURIComponent(str);52
53 var str_len = str.length;53 for(var i = 0; i < x.length; i += 16)
5454 {
55 var word_array = [];55 var olda = a;
56 for (i = 0; i < str_len - 3; i += 4) {56 var oldb = b;
57 j = str.charCodeAt(i) << 24 | str.charCodeAt(i + 1) << 16 | str.charCodeAt(i + 2) << 8 | str.charCodeAt(i + 3);57 var oldc = c;
58 word_array.push(j);58 var oldd = d;
59 }59 var olde = e;
6060
61 switch (str_len % 4) {61 for(var j = 0; j < 80; j++)
62 case 0:62 {
63 i = 0x080000000;63 if(j < 16) w[j] = x[i + j];
64 break;64 else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);
65 case 1:65 var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)),
66 i = str.charCodeAt(str_len - 1) << 24 | 0x0800000;66 safe_add(safe_add(e, w[j]), sha1_kt(j)));
67 break;67 e = d;
68 case 2:68 d = c;
69 i = str.charCodeAt(str_len - 2) << 24 | str.charCodeAt(str_len - 1) << 16 | 0x08000;69 c = rol(b, 30);
70 break;70 b = a;
71 case 3:71 a = t;
72 i = str.charCodeAt(str_len - 3) << 24 | str.charCodeAt(str_len - 2) << 16 | str.charCodeAt(str_len - 1) << 8 | 0x80;72 }
73 break;73
74 }74 a = safe_add(a, olda);
7575 b = safe_add(b, oldb);
76 word_array.push(i);76 c = safe_add(c, oldc);
7777 d = safe_add(d, oldd);
78 while ((word_array.length % 16) != 14) {78 e = safe_add(e, olde);
79 word_array.push(0);79 }
80 }80 return Array(a, b, c, d, e);
8181
82 word_array.push(str_len >>> 29);82}
83 word_array.push((str_len << 3) & 0x0ffffffff);83
8484/*
85 for (blockstart = 0; blockstart < word_array.length; blockstart += 16) {85 * Perform the appropriate triplet combination function for the current
86 for (i = 0; i < 16; i++) {86 * iteration
87 W[i] = word_array[blockstart + i];87 */
88 }88function sha1_ft(t, b, c, d)
89 for (i = 16; i <= 79; i++) {89{
90 W[i] = rotate_left(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);90 if(t < 20) return (b & c) | ((~b) & d);
91 }91 if(t < 40) return b ^ c ^ d;
9292 if(t < 60) return (b & c) | (b & d) | (c & d);
9393 return b ^ c ^ d;
94 A = H0;94}
95 B = H1;95
96 C = H2;96/*
97 D = H3;97 * Determine the appropriate additive constant for the current iteration
98 E = H4;98 */
9999function sha1_kt(t)
100 for (i = 0; i <= 19; i++) {100{
101 temp = (rotate_left(A, 5) + ((B & C) | (~B & D)) + E + W[i] + 0x5A827999) & 0x0ffffffff;101 return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 :
102 E = D;102 (t < 60) ? -1894007588 : -899497514;
103 D = C;103}
104 C = rotate_left(B, 30);104
105 B = A;105/*
106 A = temp;106 * Calculate the HMAC-SHA1 of a key and some data
107 }107 */
108108function core_hmac_sha1(key, data)
109 for (i = 20; i <= 39; i++) {109{
110 temp = (rotate_left(A, 5) + (B ^ C ^ D) + E + W[i] + 0x6ED9EBA1) & 0x0ffffffff;110 var bkey = str2binb(key);
111 E = D;111 if(bkey.length > 16) bkey = core_sha1(bkey, key.length * chrsz);
112 D = C;112
113 C = rotate_left(B, 30);113 var ipad = Array(16), opad = Array(16);
114 B = A;114 for(var i = 0; i < 16; i++)
115 A = temp;115 {
116 }116 ipad[i] = bkey[i] ^ 0x36363636;
117117 opad[i] = bkey[i] ^ 0x5C5C5C5C;
118 for (i = 40; i <= 59; i++) {118 }
119 temp = (rotate_left(A, 5) + ((B & C) | (B & D) | (C & D)) + E + W[i] + 0x8F1BBCDC) & 0x0ffffffff;119
120 E = D;120 var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz);
121 D = C;121 return core_sha1(opad.concat(hash), 512 + 160);
122 C = rotate_left(B, 30);122}
123 B = A;123
124 A = temp;124/*
125 }125 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
126126 * to work around bugs in some JS interpreters.
127 for (i = 60; i <= 79; i++) {127 */
128 temp = (rotate_left(A, 5) + (B ^ C ^ D) + E + W[i] + 0xCA62C1D6) & 0x0ffffffff;128function safe_add(x, y)
129 E = D;129{
130 D = C;130 var lsw = (x & 0xFFFF) + (y & 0xFFFF);
131 C = rotate_left(B, 30);131 var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
132 B = A;132 return (msw << 16) | (lsw & 0xFFFF);
133 A = temp;133}
134 }134
135135/*
136 H0 = (H0 + A) & 0x0ffffffff;136 * Bitwise rotate a 32-bit number to the left.
137 H1 = (H1 + B) & 0x0ffffffff;137 */
138 H2 = (H2 + C) & 0x0ffffffff;138function rol(num, cnt)
139 H3 = (H3 + D) & 0x0ffffffff;139{
140 H4 = (H4 + E) & 0x0ffffffff;140 return (num << cnt) | (num >>> (32 - cnt));
141 }141}
142142
143 temp = cvt_hex(H0) + cvt_hex(H1) + cvt_hex(H2) + cvt_hex(H3) + cvt_hex(H4);143/*
144 return temp.toLowerCase();144 * Convert an 8-bit or 16-bit string to an array of big-endian words
145 * In 8-bit function, characters >255 have their hi-byte silently ignored.
146 */
147function str2binb(str)
148{
149 var bin = Array();
150 var mask = (1 << chrsz) - 1;
151 for(var i = 0; i < str.length * chrsz; i += chrsz)
152 bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (32 - chrsz - i%32);
153 return bin;
154}
155
156/*
157 * Convert an array of big-endian words to a string
158 */
159function binb2str(bin)
160{
161 var str = "";
162 var mask = (1 << chrsz) - 1;
163 for(var i = 0; i < bin.length * 32; i += chrsz)
164 str += String.fromCharCode((bin[i>>5] >>> (32 - chrsz - i%32)) & mask);
165 return str;
166}
167
168/*
169 * Convert an array of big-endian words to a hex string.
170 */
171function binb2hex(binarray)
172{
173 var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
174 var str = "";
175 for(var i = 0; i < binarray.length * 4; i++)
176 {
177 str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) +
178 hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF);
179 }
180 return str;
181}
182
183/*
184 * Convert an array of big-endian words to a base-64 string
185 */
186function binb2b64(binarray)
187{
188 var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
189 var str = "";
190 for(var i = 0; i < binarray.length * 4; i += 3)
191 {
192 var triplet = (((binarray[i >> 2] >> 8 * (3 - i %4)) & 0xFF) << 16)
193 | (((binarray[i+1 >> 2] >> 8 * (3 - (i+1)%4)) & 0xFF) << 8 )
194 | ((binarray[i+2 >> 2] >> 8 * (3 - (i+2)%4)) & 0xFF);
195 for(var j = 0; j < 4; j++)
196 {
197 if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
198 else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
199 }
200 }
201 return str;
145}202}
146203
=== added file 'graphics/unwatched_gray.png'
147Binary files graphics/unwatched_gray.png 1970-01-01 00:00:00 +0000 and graphics/unwatched_gray.png 2014-03-28 13:53:23 +0000 differ204Binary files graphics/unwatched_gray.png 1970-01-01 00:00:00 +0000 and graphics/unwatched_gray.png 2014-03-28 13:53:23 +0000 differ
=== added file 'graphics/watched_gray.png'
148Binary files graphics/watched_gray.png 1970-01-01 00:00:00 +0000 and graphics/watched_gray.png 2014-03-28 13:53:23 +0000 differ205Binary files graphics/watched_gray.png 1970-01-01 00:00:00 +0000 and graphics/watched_gray.png 2014-03-28 13:53:23 +0000 differ
=== modified file 'manifest.json'
--- manifest.json 2014-03-14 09:51:08 +0000
+++ manifest.json 2014-03-28 13:53:23 +0000
@@ -12,4 +12,4 @@
12 "name": "com.ubuntu.developer.nik90.flashback",12 "name": "com.ubuntu.developer.nik90.flashback",
13 "title": "Flashback",13 "title": "Flashback",
14 "version": "0.3.2"14 "version": "0.3.2"
15}15}
16\ No newline at end of file16\ No newline at end of file
1717
=== modified file 'ui/TraktLogin.qml'
--- ui/TraktLogin.qml 2014-03-08 14:09:52 +0000
+++ ui/TraktLogin.qml 2014-03-28 13:53:23 +0000
@@ -154,6 +154,7 @@
154154
155 TextField {155 TextField {
156 id: password156 id: password
157 hasClearButton: false
157 placeholderText: i18n.tr("Password")158 placeholderText: i18n.tr("Password")
158 echoMode: TextInput.Password159 echoMode: TextInput.Password
159 onTextChanged: !isLogin ? password_timer.restart() : undefined160 onTextChanged: !isLogin ? password_timer.restart() : undefined
@@ -162,6 +163,16 @@
162 fillMode: Image.PreserveAspectFit163 fillMode: Image.PreserveAspectFit
163 source: Qt.resolvedUrl("../graphics/password.png")164 source: Qt.resolvedUrl("../graphics/password.png")
164 }165 }
166 secondaryItem: Image {
167 visible: password.text !== ""
168 height: parent.height/1.5;
169 fillMode: Image.PreserveAspectFit
170 source: password.echoMode === TextInput.Password ? Qt.resolvedUrl("../graphics/watched_gray.png") : Qt.resolvedUrl("../graphics/unwatched_gray.png")
171 MouseArea {
172 anchors.fill: parent
173 onClicked: password.echoMode = password.echoMode === TextInput.Password ? TextInput.Normal : TextInput.Password
174 }
175 }
165 }176 }
166177
167 TextField {178 TextField {

Subscribers

People subscribed via source and target branches