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0xNTQsNyArMTU2LDggQEAKICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgSVNtcyBpY2NJU21zID0gSVNtcy5TdHViLmFzSW50ZXJmYWNlKFNlcnZpY2VNYW5hZ2VyLmdldFNlcnZpY2UoImlzbXMiKSk7CiAgICAgICAgICAgICAgICAgaWYgKGljY0lTbXMgIT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICBpY2NJU21zLnNlbmRNdWx0aXBhcnRUZXh0KGRlc3RpbmF0aW9uQWRkcmVzcywgc2NBZGRyZXNzLCBwYXJ0cywKKyAgICAgICAgICAgICAgICAgICAgaWNjSVNtcy5zZW5kTXVsdGlwYXJ0VGV4dChBY3Rpdml0eVRocmVhZC5jdXJyZW50UGFja2FnZU5hbWUoKSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0aW5hdGlvbkFkZHJlc3MsIHNjQWRkcmVzcywgcGFydHMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VudEludGVudHMsIGRlbGl2ZXJ5SW50ZW50cyk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfSBjYXRjaCAoUmVtb3RlRXhjZXB0aW9uIGV4KSB7CkBAIC0yMTUsNyArMjE4LDggQEAKICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgIElTbXMgaWNjSVNtcyA9IElTbXMuU3R1Yi5hc0ludGVyZmFjZShTZXJ2aWNlTWFuYWdlci5nZXRTZXJ2aWNlKCJpc21zIikpOwogICAgICAgICAgICAgaWYgKGljY0lTbXMgIT0gbnVsbCkgewotICAgICAgICAgICAgICAgIGljY0lTbXMuc2VuZERhdGEoZGVzdGluYXRpb25BZGRyZXNzLCBzY0FkZHJlc3MsIGRlc3RpbmF0aW9uUG9ydCAmIDB4RkZGRiwKKyAgICAgICAgICAgICAgICBpY2NJU21zLnNlbmREYXRhKEFjdGl2aXR5VGhyZWFkLmN1cnJlbnRQYWNrYWdlTmFtZSgpLAorICAgICAgICAgICAgICAgICAgICAgICAgZGVzdGluYXRpb25BZGRyZXNzLCBzY0FkZHJlc3MsIGRlc3RpbmF0aW9uUG9ydCAmIDB4RkZGRiwKICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEsIHNlbnRJbnRlbnQsIGRlbGl2ZXJ5SW50ZW50KTsKICAgICAgICAgICAgIH0KICAgICAgICAgfSBjYXRjaCAoUmVtb3RlRXhjZXB0aW9uIGV4KSB7CkBAIC0yNTksNyArMjYzLDggQEAKICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgIElTbXMgaWNjSVNtcyA9IElTbXMuU3R1Yi5hc0ludGVyZmFjZShTZXJ2aWNlTWFuYWdlci5nZXRTZXJ2aWNlKCJpc21zIikpOwogICAgICAgICAgICAgaWYgKGljY0lTbXMgIT0gbnVsbCkgewotICAgICAgICAgICAgICAgIHN1Y2Nlc3MgPSBpY2NJU21zLmNvcHlNZXNzYWdlVG9JY2NFZihzdGF0dXMsIHBkdSwgc21zYyk7CisgICAgICAgICAgICAgICAgc3VjY2VzcyA9IGljY0lTbXMuY29weU1lc3NhZ2VUb0ljY0VmKEFjdGl2aXR5VGhyZWFkLmN1cnJlbnRQYWNrYWdlTmFtZSgpLAorICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzLCBwZHUsIHNtc2MpOwogICAgICAgICAgICAgfQogICAgICAgICB9IGNhdGNoIChSZW1vdGVFeGNlcHRpb24gZXgpIHsKICAgICAgICAgICAgIC8vIGlnbm9yZSBpdApAQCAtMjg3LDcgKzI5Miw4IEBACiAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICBJU21zIGljY0lTbXMgPSBJU21zLlN0dWIuYXNJbnRlcmZhY2UoU2VydmljZU1hbmFnZXIuZ2V0U2VydmljZSgiaXNtcyIpKTsKICAgICAgICAgICAgIGlmIChpY2NJU21zICE9IG51bGwpIHsKLSAgICAgICAgICAgICAgICBzdWNjZXNzID0gaWNjSVNtcy51cGRhdGVNZXNzYWdlT25JY2NFZihtZXNzYWdlSW5kZXgsIFNUQVRVU19PTl9JQ0NfRlJFRSwgcGR1KTsKKyAgICAgICAgICAgICAgICBzdWNjZXNzID0gaWNjSVNtcy51cGRhdGVNZXNzYWdlT25JY2NFZihBY3Rpdml0eVRocmVhZC5jdXJyZW50UGFja2FnZU5hbWUoKSwKKyAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VJbmRleCwgU1RBVFVTX09OX0lDQ19GUkVFLCBwZHUpOwogICAgICAgICAgICAgfQogICAgICAgICB9IGNhdGNoIChSZW1vdGVFeGNlcHRpb24gZXgpIHsKICAgICAgICAgICAgIC8vIGlnbm9yZSBpdApAQCAtMzE2LDcgKzMyMiw4IEBACiAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICBJU21zIGljY0lTbXMgPSBJU21zLlN0dWIuYXNJbnRlcmZhY2UoU2VydmljZU1hbmFnZXIuZ2V0U2VydmljZSgiaXNtcyIpKTsKICAgICAgICAgICAgIGlmIChpY2NJU21zICE9IG51bGwpIHsKLSAgICAgICAgICAgICAgICBzdWNjZXNzID0gaWNjSVNtcy51cGRhdGVNZXNzYWdlT25JY2NFZihtZXNzYWdlSW5kZXgsIG5ld1N0YXR1cywgcGR1KTsKKyAgICAgICAgICAgICAgICBzdWNjZXNzID0gaWNjSVNtcy51cGRhdGVNZXNzYWdlT25JY2NFZihBY3Rpdml0eVRocmVhZC5jdXJyZW50UGFja2FnZU5hbWUoKSwKKyAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VJbmRleCwgbmV3U3RhdHVzLCBwZHUpOwogICAgICAgICAgICAgfQogICAgICAgICB9IGNhdGNoIChSZW1vdGVFeGNlcHRpb24gZXgpIHsKICAgICAgICAgICAgIC8vIGlnbm9yZSBpdApAQCAtMzQwLDcgKzM0Nyw3IEBACiAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICBJU21zIGljY0lTbXMgPSBJU21zLlN0dWIuYXNJbnRlcmZhY2UoU2VydmljZU1hbmFnZXIuZ2V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GVsZXBob255TWFuYWdlci5nZXREZWZhdWx0KCkuZ2V0Q3VycmVudFBob25lVHlwZSgpOwogICAgICAgICBpZiAoUEhPTkVfVFlQRV9DRE1BID09IGFjdGl2ZVBob25lKSB7CmRpZmYgLS1naXQgYS9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvQVRSZXNwb25zZVBhcnNlci5qYXZhIGIvc3JjL2phdmEvY29tL2FuZHJvaWQvaW50ZXJuYWwvdGVsZXBob255L0FUUmVzcG9uc2VQYXJzZXIuamF2YQppbmRleCBmZGIwNTI2Li4xZDRkN2M3IDEwMDY0NAotLS0gYS9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvQVRSZXNwb25zZVBhcnNlci5qYXZhCisrKyBiL3NyYy9qYXZhL2NvbS9hbmRyb2lkL2ludGVybmFsL3RlbGVwaG9ueS9BVFJlc3BvbnNlUGFyc2VyLmphdmEKQEAgLTIzLDE2ICsyMywxNiBAQAogewogICAgIC8qKioqKioqKioqKioqKioqKioqKioqKioqKiogSW5zdGFuY2UgVmFyaWFibGVzICoqKioqKioqKioqKioqKioqKioqKioqKioqLwogCi0gICAgcHJpdmF0ZSBTdHJpbmcgbGluZTsKLSAgICBwcml2YXRlIGludCBuZXh0ID0gMDsKLSAgICBwcml2YXRlIGludCB0b2tTdGFydCwgdG9rRW5kOworICAgIHByaXZhdGUgU3RyaW5nIG1MaW5lOworICAgIHByaXZhdGUgaW50IG1OZXh0ID0gMDsKKyAgICBwcml2YXRlIGludCBtVG9rU3RhcnQsIG1Ub2tFbmQ7CiAKICAgICAvKioqKioqKioqKioqKioqKioqKioqKioqKioqKiogQ2xhc3MgTWV0aG9kcyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KIAogICAgIHB1YmxpYwogICAgIEFUUmVzcG9uc2VQYXJzZXIgKFN0cmluZyBsaW5lKQogICAgIHsKLSAgICAgICAgdGhpcy5saW5lID0gbGluZTsKKyAgICAgICAgbUxpbmUgPSBsaW5lOwogICAgIH0KIAogICAgIHB1YmxpYyBib29sZWFuCkBAIC00MywxMCArNDMsMTAgQEAKIAogICAgICAgICBuZXh0VG9rKCk7CiAKLSAgICAgICAgaWYgKHRva0VuZCAtIHRva1N0YXJ0ID4gMSkgeworICAgICAgICBpZiAobVRva0VuZCAtIG1Ub2tTdGFydCA+IDEpIHsKICAgICAgICAgICAgIHRocm93IG5ldyBBVFBhcnNlRXgoKTsKICAgICAgICAgfQotICAgICAgICBjaGFyIGMgPSBsaW5lLmNoYXJBdCh0b2tTdGFydCk7CisgICAgICAgIGNoYXIgYyA9IG1MaW5lLmNoYXJBdChtVG9rU3RhcnQpOwogCiAgICAgICAgIGlmIChjID09ICcwJykgcmV0dXJuIGZhbHNlOwogICAgICAgICBpZiAoYyA9PSAgJzEnKSByZXR1cm4gdHJ1ZTsKQEAgLTYzLDggKzYzLDggQEAKIAogICAgICAgICBuZXh0VG9rKCk7CiAKLSAgICAgICAgZm9yIChpbnQgaSA9IHRva1N0YXJ0IDsgaSA8IHRva0VuZCA7IGkrKykgewotICAgICAgICAgICAgY2hhciBjID0gbGluZS5jaGFyQXQoaSk7CisgICAgICAgIGZvciAoaW50IGkgPSBtVG9rU3RhcnQgOyBpIDwgbVRva0VuZCA7IGkrKykgeworICAgICAgICAgICAgY2hhciBjID0gbUxpbmUuY2hhckF0KGkpOwogCiAgICAgICAgICAgICAvLyBZZXMsIEFTQ0lJIGRlY2ltYWwgZGlnaXRzIG9ubHkKICAgICAgICAgICAgIGlmIChjIDwgJzAnIHx8IGMgPiAnOScpIHsKQEAgLTgzLDYzICs4Myw2MyBAQAogICAgIHsKICAgICAgICAgbmV4dFRvaygpOwogCi0gICAgICAgIHJldHVybiBsaW5lLnN1YnN0cmluZyh0b2tTdGFydCwgdG9rRW5kKTsKKyAgICAgICAgcmV0dXJuIG1MaW5lLnN1YnN0cmluZyhtVG9rU3RhcnQsIG1Ub2tFbmQpOwogICAgIH0KIAogICAgIHB1YmxpYyBib29sZWFuCiAgICAgaGFzTW9yZSgpCiAgICAgewotICAgICAgICByZXR1cm4gbmV4dCA8IGxpbmUubGVuZ3RoKCk7CisgICAgICAgIHJldHVybiBtTmV4dCA8IG1MaW5lLmxlbmd0aCgpOwogICAgIH0KIAogICAgIHByaXZhdGUgdm9pZAogICAgIG5leHRUb2soKQogICAgIHsKLSAgICAgICAgaW50IGxlbiA9IGxpbmUubGVuZ3RoKCk7CisgICAgICAgIGludCBsZW4gPSBtTGluZS5sZW5ndGgoKTsKIAotICAgICAgICBpZiAobmV4dCA9PSAwKSB7CisgICAgICAgIGlmIChtTmV4dCA9PSAwKSB7CiAgICAgICAgICAgICBza2lwUHJlZml4KCk7CiAgICAgICAgIH0KIAotICAgICAgICBpZiAobmV4dCA+PSBsZW4pIHsKKyAgICAgICAgaWYgKG1OZXh0ID49IGxlbikgewogICAgICAgICAgICAgdGhyb3cgbmV3IEFUUGFyc2VFeCgpOwogICAgICAgICB9CiAKICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgIC8vIFxzKigiKFteIl0qKSJ8KC4qKVxzKikoLHwkKQogCi0gICAgICAgICAgICBjaGFyIGMgPSBsaW5lLmNoYXJBdChuZXh0KyspOworICAgICAgICAgICAgY2hhciBjID0gbUxpbmUuY2hhckF0KG1OZXh0KyspOwogICAgICAgICAgICAgYm9vbGVhbiBoYXNRdW90ZSA9IGZhbHNlOwogCiAgICAgICAgICAgICBjID0gc2tpcFdoaXRlU3BhY2UoYyk7CiAKICAgICAgICAgICAgIGlmIChjID09ICciJykgewotICAgICAgICAgICAgICAgIGlmIChuZXh0ID49IGxlbikgeworICAgICAgICAgICAgICAgIGlmIChtTmV4dCA+PSBsZW4pIHsKICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEFUUGFyc2VFeCgpOwogICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBjID0gbGluZS5jaGFyQXQobmV4dCsrKTsKLSAgICAgICAgICAgICAgICB0b2tTdGFydCA9IG5leHQgLSAxOwotICAgICAgICAgICAgICAgIHdoaWxlIChjICE9ICciJyAmJiBuZXh0IDwgbGVuKSB7Ci0gICAgICAgICAgICAgICAgICAgIGMgPSBsaW5lLmNoYXJBdChuZXh0KyspOworICAgICAgICAgICAgICAgIGMgPSBtTGluZS5jaGFyQXQobU5leHQrKyk7CisgICAgICAgICAgICAgICAgbVRva1N0YXJ0ID0gbU5leHQgLSAxOworICAgICAgICAgICAgICAgIHdoaWxlIChjICE9ICciJyAmJiBtTmV4dCA8IGxlbikgeworICAgICAgICAgICAgICAgICAgICBjID0gbUxpbmUuY2hhckF0KG1OZXh0KyspOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBpZiAoYyAhPSAnIicpIHsKICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEFUUGFyc2VFeCgpOwogICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICB0b2tFbmQgPSBuZXh0IC0gMTsKLSAgICAgICAgICAgICAgICBpZiAobmV4dCA8IGxlbiAmJiBsaW5lLmNoYXJBdChuZXh0KyspICE9ICcsJykgeworICAgICAgICAgICAgICAgIG1Ub2tFbmQgPSBtTmV4dCAtIDE7CisgICAgICAgICAgICAgICAgaWYgKG1OZXh0IDwgbGVuICYmIG1MaW5lLmNoYXJBdChtTmV4dCsrKSAhPSAnLCcpIHsKICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEFUUGFyc2VFeCgpOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgdG9rU3RhcnQgPSBuZXh0IC0gMTsKLSAgICAgICAgICAgICAgICB0b2tFbmQgPSB0b2tTdGFydDsKKyAgICAgICAgICAgICAgICBtVG9rU3RhcnQgPSBtTmV4dCAtIDE7CisgICAgICAgICAgICAgICAgbVRva0VuZCA9IG1Ub2tTdGFydDsKICAgICAgICAgICAgICAgICB3aGlsZSAoYyAhPSAnLCcpIHsKICAgICAgICAgICAgICAgICAgICAgaWYgKCFDaGFyYWN0ZXIuaXNXaGl0ZXNwYWNlKGMpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICB0b2tFbmQgPSBuZXh0OworICAgICAgICAgICAgICAgICAgICAgICAgbVRva0VuZCA9IG1OZXh0OwogICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgIGlmIChuZXh0ID09IGxlbikgeworICAgICAgICAgICAgICAgICAgICBpZiAobU5leHQgPT0gbGVuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBjID0gbGluZS5jaGFyQXQobmV4dCsrKTsKKyAgICAgICAgICAgICAgICAgICAgYyA9IG1MaW5lLmNoYXJBdChtTmV4dCsrKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CiAgICAgICAgIH0gY2F0Y2ggKFN0cmluZ0luZGV4T3V0T2ZCb3VuZHNFeGNlcHRpb24gZXgpIHsKQEAgLTE1Myw5ICsxNTMsOSBAQAogICAgIHNraXBXaGl0ZVNwYWNlIChjaGFyIGMpCiAgICAgewogICAgICAgICBpbnQgbGVuOwotICAgICAgICBsZW4gPSBsaW5lLmxlbmd0aCgpOwotICAgICAgICB3aGlsZSAobmV4dCA8IGxlbiAmJiBDaGFyYWN0ZXIuaXNXaGl0ZXNwYWNlKGMpKSB7Ci0gICAgICAgICAgICBjID0gbGluZS5jaGFyQXQobmV4dCsrKTsKKyAgICAgICAgbGVuID0gbUxpbmUubGVuZ3RoKCk7CisgICAgICAgIHdoaWxlIChtTmV4dCA8IGxlbiAmJiBDaGFyYWN0ZXIuaXNXaGl0ZXNwYWNlKGMpKSB7CisgICAgICAgICAgICBjID0gbUxpbmUuY2hhckF0KG1OZXh0KyspOwogICAgICAgICB9CiAKICAgICAgICAgaWYgKENoYXJhY3Rlci5pc1doaXRlc3BhY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zEyMCw3IEBACiAgICAgICovCiAgICAgcHVibGljIENvbm5lY3Rpb24KICAgICBnZXRFYXJsaWVzdENvbm5lY3Rpb24oKSB7Ci0gICAgICAgIExpc3QgbDsKKyAgICAgICAgTGlzdDxDb25uZWN0aW9uPiBsOwogICAgICAgICBsb25nIHRpbWUgPSBMb25nLk1BWF9WQUxVRTsKICAgICAgICAgQ29ubmVjdGlvbiBjOwogICAgICAgICBDb25uZWN0aW9uIGVhcmxpZXN0ID0gbnVsbDsKQEAgLTEzMCw3ICsxMzIsNyBAQAogICAgICAgICB9CiAKICAgICAgICAgZm9yIChpbnQgaSA9IDAsIHMgPSBsLnNpemUoKSA7IGkgPCBzIDsgaSsrKSB7Ci0gICAgICAgICAgICBjID0gKENvbm5lY3Rpb24pIGwuZ2V0KGkpOworICAgICAgICAgICAgYyA9IGwuZ2V0KGkpOwogICAgICAgICAgICAgbG9uZyB0OwogCiAgICAgICAgICAgICB0ID0gYy5nZXRDcmVhdGVUaW1lKCk7CkBAIC0xNDYsNyArMTQ4LDcgQEAKIAogICAgIHB1YmxpYyBsb25nCiAgICAgZ2V0RWFybGllc3RDcmVhdGVUaW1lKCkgewotICAgICAgICBMaXN0IGw7CisgICAgICAgIExpc3Q8Q29ubmVjdGlvbj4gbDsKICAgICAgICAgbG9uZyB0aW1lID0gTG9uZy5NQVhfVkFMVUU7CiAKICAgICAgICAgbCA9IGdldENvbm5lY3Rpb25zKCk7CkBAIC0xNTYsNyArMTU4LDcgQEAKICAgICAgICAgfQogCiAgICAgICAgIGZvciAoaW50IGkgPSAwLCBzID0gbC5zaXplKCkgOyBpIDwgcyA7IGkrKykgewotICAgICAgICAgICAgQ29ubmVjdGlvbiBjID0gKENvbm5lY3Rpb24pIGwuZ2V0KGkpOworICAgICAgICAgICAgQ29ubmVjdGlvbiBjID0gbC5nZXQoaSk7CiAgICAgICAgICAgICBsb25nIHQ7CiAKICAgICAgICAgICAgIHQgPSBjLmdldENyZWF0ZVRpbWUoKTsKQEAgLTE3MCwxNCArMTcyLDE0IEBACiAgICAgcHVibGljIGxvbmcKICAgICBnZXRFYXJsaWVzdENvbm5lY3RUaW1lKCkgewogICAgICAgICBsb25nIHRpbWUgPSBMb25nLk1BWF9WQUxVRTsKLSAgICAgICAgTGlzdCBsID0gZ2V0Q29ubmVjdGlvbnMoKTsKKyAgICAgICAgTGlzdDxDb25uZWN0aW9uPiBsID0gZ2V0Q29ubmVjdGlvbnMoKTsKIAogICAgICAgICBpZiAobC5zaXplKCkgPT0gMCkgewogICAgICAgICAgICAgcmV0dXJuIDA7CiAgICAgICAgIH0KIAogICAgICAgICBmb3IgKGludCBpID0gMCwgcyA9IGwuc2l6ZSgpIDsgaSA8IHMgOyBpKyspIHsKLSAgICAgICAgICAgIENvbm5lY3Rpb24gYyA9IChDb25uZWN0aW9uKSBsLmdldChpKTsKKyAgICAgICAgICAgIENvbm5lY3Rpb24gYyA9IGwuZ2V0KGkpOwogICAgICAgICAgICAgbG9uZyB0OwogCiAgICAgICAgICAgICB0ID0gYy5nZXRDb25uZWN0VGltZSgpOwpAQCAtMjA1LDcgKzIwNyw3IEBACiAgICAgICovCiAgICAgcHVibGljIENvbm5lY3Rpb24KICAgICBnZXRMYXRlc3RDb25uZWN0aW9uKCkgewotICAgICAgICBMaXN0IGwgPSBnZXRDb25uZWN0aW9ucygpOworICAgICAgICBMaXN0PENvbm5lY3Rpb24+IGwgPSBnZXRDb25uZWN0aW9ucygpOwogICAgICAgICBpZiAobC5zaXplKCkgPT0gMCkgewogICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgIH0KQEAgLTIxMyw3ICsyMTUsNyBAQAogICAgICAgICBsb25nIHRpbWUgPSAwOwogICAgICAgICBDb25uZWN0aW9uIGxhdGVzdCA9IG51bGw7CiAgICAgICAgIGZvciAoaW50IGkgPSAwLCBzID0gbC5zaXplKCkgOyBpIDwgcyA7IGkrKykgewotICAgICAgICAgICAgQ29ubmVjdGlvbiBjID0gKENvbm5lY3Rpb24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mxvZy5kKExPR19UQUcsIHRoaXMudG9TdHJpbmcoKSk7CisgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgdG9TdHJpbmcoKSk7CiAgICAgICAgIH0KIAogICAgICAgICBQaG9uZSByaW5naW5nUGhvbmUgPSByaW5naW5nQ2FsbC5nZXRQaG9uZSgpOwpAQCAtNTg2LDcgKzU4Niw3IEBACiAKICAgICAgICAgaWYgKFZEQkcpIHsKICAgICAgICAgICAgIFJsb2cuZChMT0dfVEFHLCAiRW5kIHJlamVjdENhbGwoIiArcmluZ2luZ0NhbGwgKyAiKSIpOwotICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsIHRoaXMudG9TdHJpbmcoKSk7CisgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgdG9TdHJpbmcoKSk7CiAgICAgICAgIH0KICAgICB9CiAKQEAgLTYxNCw3ICs2MTQsNyBAQAogCiAgICAgICAgIGlmIChWREJHKSB7CiAgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgInN3aXRjaEhvbGRpbmdBbmRBY3RpdmUoIiAraGVsZENhbGwgKyAiKSIpOwotICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsIHRoaXMudG9TdHJpbmcoKSk7CisgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgdG9TdHJpbmcoKSk7CiAgICAgICAgIH0KIAogICAgICAgICBpZiAoaGFzQWN0aXZlRmdDYWxsKCkpIHsKQEAgLTYzNSw3ICs2MzUsNyBAQAogCiAgICAgICAgIGlmIChWREJHKSB7CiAgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgIkVuZCBzd2l0Y2hIb2xkaW5nQW5kQWN0aXZlKCIgK2hlbGRDYWxsICsgIikiKTsKLSAgICAgICAgICAgIFJsb2cuZChMT0dfVEFHLCB0aGlzLnRvU3RyaW5nKCkpOworICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsIHRvU3RyaW5nKCkpOwogICAgICAgICB9CiAgICAgfQogCkBAIC02NTMsNyArNjUzLDcgQEAKIAogICAgICAgICBpZiAoVkRCRykgewogICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsICJoYW5ndXBGb3JlZ3JvdW5kUmVzdW1lQmFja2dyb3VuZCgiICtoZWxkQ2FsbCArICIpIik7Ci0gICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgdGhpcy50b1N0cmluZygpKTsKKyAgICAgICAgICAgIFJsb2cuZChMT0dfVEFHLCB0b1N0cmluZygpKTsKICAgICAgICAgfQogCiAgICAgICAgIGlmIChoYXNBY3RpdmVGZ0NhbGwoKSkgewpAQCAtNjcyLDcgKzY3Miw3IEBACiAKICAgICAgICAgaWYgKFZEQkcpIHsKICAgICAgICAgICAgIFJsb2cuZChMT0dfVEFHLCAiRW5kIGhhbmd1cEZvcmVncm91bmRSZXN1bWVCYWNrZ3JvdW5kKCIgK2hlbGRDYWxsICsgIikiKTsKLSAgICAgICAgICAgIFJsb2cuZChMT0dfVEFHLCB0aGlzLnRvU3RyaW5nKCkpOworICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsIHRvU3RyaW5nKCkpOwogICAgICAgICB9CiAgICAgfQogCkBAIC03MDksNyArNzA5LDcgQEAKIAogICAgICAgICBpZiAoVkRCRykgewogICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsICJjb25mZXJlbmNlKCIgK2hlbGRDYWxsICsgIikiKTsKLSAgICAgICAgICAgIFJsb2cuZChMT0dfVEFHLCB0aGlzLnRvU3RyaW5nKCkpOworICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsIHRvU3RyaW5nKCkpOwogICAgICAgICB9CiAKIApAQCAtNzI0LDcgKzcyNCw3IEBACiAKICAgICAgICAgaWYgKFZEQkcpIHsKICAgICAgICAgICAgIFJsb2cuZChMT0dfVEFHLCAiRW5kIGNvbmZlcmVuY2UoIiAraGVsZENhbGwgKyAiKSIpOwotICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsIHRoaXMudG9TdHJpbmcoKSk7CisgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgdG9TdHJpbmcoKSk7CiAgICAgICAgIH0KIAogICAgIH0KQEAgLTc0NSw3ICs3NDUsNyBAQAogCiAgICAgICAgIGlmIChWREJHKSB7CiAgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgIiBkaWFsKCIgKyBiYXNlUGhvbmUgKyAiLCAiKyBkaWFsU3RyaW5nICsgIikiKTsKLSAgICAgICAgICAgIFJsb2cuZChMT0dfVEFHLCB0aGlzLnRvU3RyaW5nKCkpOworICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsIHRvU3RyaW5nKCkpOwogICAgICAgICB9CiAKICAgICAgICAgaWYgKCFjYW5EaWFsKHBob25lKSkgewpAQCAtNzc1LDcgKzc3NSw3IEBACiAKICAgICAgICAgaWYgKFZEQkcpIHsKICAgICAgICAgICAgIFJsb2cuZChMT0dfVEFHLCAiRW5kIGRpYWwoIiArIGJhc2VQaG9uZSArICIsICIrIGRpYWxTdHJpbmcgKyAiKSIpOwotICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsIHRoaXMudG9TdHJpbmcoKSk7CisgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgdG9TdHJpbmcoKSk7CiAgICAgICAgIH0KIAogICAgICAgICByZXR1cm4gcmVzdWx0OwpAQCAtODc1LDcgKzg3NSw3IEBACiAgICAgcHVibGljIHZvaWQgZXhwbGljaXRDYWxsVHJhbnNmZXIoQ2FsbCBoZWxkQ2FsbCkgdGhyb3dzIENhbGxTdGF0ZUV4Y2VwdGlvbiB7CiAgICAgICAgIGlmIChWREJHKSB7CiAgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgIiBleHBsaWNpdENhbGxUcmFuc2ZlcigiICsgaGVsZENhbGwgKyAiKSIpOwotICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsIHRoaXMudG9TdHJpbmcoKSk7CisgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgdG9TdHJpbmcoKSk7CiAgICAgICAgIH0KIAogICAgICAgICBpZiAoY2FuVHJhbnNmZXIoaGVsZENhbGwpKSB7CkBAIC04ODQsNyArODg0LDcgQEAKIAogICAgICAgICBpZiAoVkRCRykgewogICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsICJFbmQgZXhwbGljaXRDYWxsVHJhbnNmZXIoIiArIGhlbGRDYWxsICsgIikiKTsKLSAgICAgICAgICAgIFJsb2cuZChMT0dfVEFHLCB0aGlzLnRvU3RyaW5nKCkpOworICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsIHRvU3RyaW5nKCkpOwogICAgICAgICB9CiAKICAgICB9CkBAIC05MjgsNyArOTI4LDcgQEAKICAgICBwdWJsaWMgdm9pZCBzZXRNdXRlKGJvb2xlYW4gbXV0ZWQpIHsKICAgICAgICAgaWYgKFZEQkcpIHsKICAgICAgICAgICAgIFJsb2cuZChMT0dfVEFHLCAiIHNldE11dGUoIiArIG11dGVkICsgIikiKTsKLSAgICAgICAgICAgIFJsb2cuZChMT0dfVEFHLCB0aGlzLnRvU3RyaW5nKCkpOworICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsIHRvU3RyaW5nKCkpOwogICAgICAgICB9CiAKICAgICAgICAgaWYgKGhhc0FjdGl2ZUZnQ2FsbCgpKSB7CkBAIC05MzcsNyArOTM3LDcgQEAKIAogICAgICAgICBpZiAoVkRCRykgewogICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsICJFbmQgc2V0TXV0ZSgiICsgbXV0ZWQgKyAiKSIpOwotICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsIHRoaXMudG9TdHJpbmcoKSk7CisgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgdG9TdHJpbmcoKSk7CiAgICAgICAgIH0KICAgICB9CiAKQEAgLTk2NSw3ICs5NjUsNyBAQAogICAgIHB1YmxpYyB2b2lkIHNldEVjaG9TdXBwcmVzc2lvbkVuYWJsZWQoYm9vbGVhbiBlbmFibGVkKSB7CiAgICAgICAgIGlmIChWREJHKSB7CiAgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgIiBzZXRFY2hvU3VwcHJlc3Npb24oIiArIGVuYWJsZWQgKyAiKSIpOwotICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsIHRoaXMudG9TdHJpbmcoKSk7CisgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgdG9TdHJpbmcoKSk7CiAgICAgICAgIH0KIAogICAgICAgICBpZiAoaGFzQWN0aXZlRmdDYWxsKCkpIHsKQEAgLTk3NCw3ICs5NzQsNyBAQAogCiAgICAgICAgIGlmIChWREJHKSB7CiAgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgIkVuZCBzZXRFY2hvU3VwcHJlc3Npb24oIiArIGVuYWJsZWQgKyAiKSIpOwotICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsIHRoaXMudG9TdHJpbmcoKSk7CisgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgdG9TdHJpbmcoKSk7CiAgICAgICAgIH0KICAgICB9CiAKQEAgLTk5MSw3ICs5OTEsNyBAQAogCiAgICAgICAgIGlmIChWREJHKSB7CiAgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgIiBzZW5kRHRtZigiICsgYyArICIpIik7Ci0gICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgdGhpcy50b1N0cmluZygpKTsKKyAgICAgICAgICAgIFJsb2cuZChMT0dfVEFHLCB0b1N0cmluZygpKTsKICAgICAgICAgfQogCiAgICAgICAgIGlmIChoYXNBY3RpdmVGZ0NhbGwoKSkgewpAQCAtMTAwMSw3ICsxMDAxLDcgQEAKIAogICAgICAgICBpZiAoVkRCRykgewogICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsICJFbmQgc2VuZER0bWYoIiArIGMgKyAiKSIpOwotICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsIHRoaXMudG9TdHJpbmcoKSk7CisgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgdG9TdHJpbmcoKSk7CiAgICAgICAgIH0KICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICB9CkBAIC0xMDIwLDcgKzEwMjAsNyBAQAogCiAgICAgICAgIGlmIChWREJHKSB7CiAgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgIiBzdGFydER0bWYoIiArIGMgKyAiKSIpOwotICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsIHRoaXMudG9TdHJpbmcoKSk7CisgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgdG9TdHJpbmcoKSk7CiAgICAgICAgIH0KIAogICAgICAgICBpZiAoaGFzQWN0aXZlRmdDYWxsKCkpIHsKQEAgLTEwMzAsNyArMTAzMCw3IEBACiAKICAgICAgICAgaWYgKFZEQkcpIHsKICAgICAgICAgICAgIFJsb2cuZChMT0dfVEFHLCAiRW5kIHN0YXJ0RHRtZigiICsgYyArICIpIik7Ci0gICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgdGhpcy50b1N0cmluZygpKTsKKyAgICAgICAgICAgIFJsb2cuZChMT0dfVEFHLCB0b1N0cmluZygpKTsKICAgICAgICAgfQogCiAgICAgICAgIHJldHVybiByZXN1bHQ7CkBAIC0xMDQzLDE0ICsxMDQzLDE0IEBACiAgICAgcHVibGljIHZvaWQgc3RvcER0bWYoKSB7CiAgICAgICAgIGlmIChWREJHKSB7CiAgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgIiBzdG9wRHRtZigpIiApOwotICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsIHRoaXMudG9TdHJpbmcoKSk7CisgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgdG9TdHJpbmcoKSk7CiAgICAgICAgIH0KIAogICAgICAgICBpZiAoaGFzQWN0aXZlRmdDYWxsKCkpIGdldEZnUGhvbmUoKS5zdG9wRHRtZigpOwogCiAgICAgICAgIGlmIChWREJHKSB7CiAgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgIkVuZCBzdG9wRHRtZigpIik7Ci0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gICAgbUNpLmdldEN1cnJlbnRDYWxscyhtTGFzdFJlbGV2YW50UG9sbCk7CiAgICAgICAgIH0KICAgICB9CiAKQEAgLTEwNSw4ICsxMDMsOCBAQAogICAgICAqLwogICAgIHByb3RlY3RlZCBNZXNzYWdlCiAgICAgb2J0YWluTm9Qb2xsQ29tcGxldGVNZXNzYWdlKGludCB3aGF0KSB7Ci0gICAgICAgIHBlbmRpbmdPcGVyYXRpb25zKys7Ci0gICAgICAgIGxhc3RSZWxldmFudFBvbGwgPSBudWxsOworICAgICAgICBtUGVuZGluZ09wZXJhdGlvbnMrKzsKKyAgICAgICAgbUxhc3RSZWxldmFudFBvbGwgPSBudWxsOwogICAgICAgICByZXR1cm4gb2J0YWluTWVzc2FnZSh3aGF0KTsKICAgICB9CiAKQEAgLTExNyw4ICsxMTUsOCBAQAogICAgIHByaXZhdGUgYm9vbGVhbgogICAgIGNoZWNrTm9PcGVyYXRpb25zUGVuZGluZygpIHsKICAgICAgICAgaWYgKERCR19QT0xMKSBsb2coImNoZWNrTm9PcGVyYXRpb25zUGVuZGluZzogcGVuZGluZ09wZXJhdGlvbnM9IiArCi0gICAgICAgICAgICAgICAgcGVuZGluZ09wZXJhdGlvbnMpOwotICAgICAgICByZXR1cm4gcGVuZGluZ09wZXJhdGlvbnMgPT0gMDsKKyAgICAgICAgICAgICAgICBtUGVuZGluZ09wZXJhdGlvbnMpOworICAgICAgICByZXR1cm4gbVBlbmRpbmdPcGVyYXRpb25zID09IDA7CiAgICAgfQogCiAgICAgLyoqCkBAIC0xMzksNyArMTM3LDcgQEAKICAgICAgKiBUbyB0ZXN0IERpYWwgMTEyIHRha2UgY2FsbCB0aGVuIGhhbmcgdXAgb24gTU8gZGV2aWNlIHRvIGVudGVyIEVDTQogICAgICAqIHNlZSBSSUwjcHJvY2Vzc1NvbGljaXRlZCBSSUxfUkVRVUVTVF9IQU5HVVBfRk9SRUdST1VORF9SRVNVTUVfQkFDS0dST1VORAogICAgICAqCi0gICAgICogQH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VELCAgICAgICAgICAgICAgIC8qIGhhcyBub3QgeWV0IGRpc2Nvbm5lY3RlZCAqLwpAQCAtNzAsNyArNzAsNyBAQAogICAgICAgICBFUlJPUl9VTlNQRUNJRklFRAogICAgIH0KIAotICAgIE9iamVjdCB1c2VyRGF0YTsKKyAgICBPYmplY3QgbVVzZXJEYXRhOwogCiAgICAgLyogSW5zdGFuY2UgTWV0aG9kcyAqLwogCkBAIC04OCw3ICs4OCw3IEBACiAgICAgICogQHJldHVybiBjbmFwIG5hbWUgb3IgbnVsbCBpZiB1bmF2YWlsYWJsZQogICAgICAqLwogICAgIHB1YmxpYyBTdHJpbmcgZ2V0Q25hcE5hbWUoKSB7Ci0gICAgICAgIHJldHVybiBjbmFwTmFtZTsKKyAgICAgICAgcmV0dXJuIG1DbmFwTmFtZTsKICAgICB9CiAKICAgICAvKioKQEAgLTEwNSw4ICsxMDUsOCBAQAogICAgICAqLwogCiAgICAgcHVibGljIGludCBnZXRDbmFwTmFtZVByZXNlbnRhdGlvbigpIHsKLSAgICAgICByZXR1cm4gY25hcE5hbWVQcmVzZW50YXRpb247Ci0gICAgfTsKKyAgICAgICByZXR1cm4gbUNuYXBOYW1lUHJlc2VudGF0aW9uOworICAgIH0KIAogICAgIC8qKgogICAgICAqIEByZXR1cm4gQ2FsbCB0aGF0IG93bnMgdGhpcyBDb25uZWN0aW9uLCBvciBudWxsIGlmIG5vbmUKQEAgLTIwNyw3ICsyMDcsNyBAQAogICAgICAqIEByZXR1cm4gdGhlIHVzZXJkYXRhIHNldCBpbiBzZXRVc2VyRGF0YSgpCiAgICAgICovCiAgICAgcHVibGljIE9iamVjdCBnZXRVc2VyRGF0YSgpIHsKLSAgICAgICAgcmV0dXJuIHVzZXJEYXRhOworICAgICAgICByZXR1cm4gbVVzZXJEYXRhOwogICAgIH0KIAogICAgIC8qKgpAQCAtMjE1LDcgKzIxNSw3IEBACiAgICAgICogQHBhcmFtIHVzZXJkYXRhIHVzZXIgY2FuIHN0b3JlIGF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ICAgICAgICB9CiAgICAgfQogCi0gICAgcHJpdmF0ZSB2b2lkIGxvZyhTdHJpbmcgcykgewotICAgICAgICBSbG9nLmQoTE9HX1RBRywgIltQaG9uZU5vdGlmaWVyXSAiICsgcyk7Ci0gICAgfQotCiAgICAgLyoqCi0gICAgICogQ29udmVydCB0aGUge0BsaW5rIFN0YXRlfSBlbnVtIGludG8gdGhlIFRlbGVwaG9ueU1hbmFnZXIuQ0FMTF9TVEFURV8qIGNvbnN0YW50cwotICAgICAqIGZvciB0aGUgcHVibGljIEFQSS4KKyAgICAgKiBDb252ZXJ0IHRoZSB7QGxpbmsgUGhvbmVDb25zdGFudHMuU3RhdGV9IGVudW0gaW50byB0aGUgVGVsZXBob255TWFuYWdlci5DQUxMX1NUQVRFXyoKKyAgICAgKiBjb25zdGFudHMgZm9yIHRoZSBwdWJsaWMgQVBJLgogICAgICAqLwogICAgIHB1YmxpYyBzdGF0aWMgaW50IGNvbnZlcnRDYWxsU3RhdGUoUGhvbmVDb25zdGFudHMuU3RhdGUgc3RhdGUpIHsKICAgICAgICAgc3dpdGNoIChzdGF0ZSkgewpAQCAtMTk1LDggKzE5OSw4IEBACiAgICAgfQogCiAgICAgLyoqCi0gICAgICogQ29udmVydCB0aGUgVGVsZXBob255TWFuYWdlci5DQUxMX1NUQVRFXyogY29uc3RhbnRzIGludG8gdGhlIHtAbGluayBTdGF0ZX0gZW51bQotICAgICAqIGZvciB0aGUgcHVibGljIEFQSS4KKyAgICAgKiBDb252ZXJ0IHRoZSBUZWxlcGhvbnlNYW5hZ2VyLkNBTExfU1RBVEVfKiBjb25zdGFudHMgaW50byB0aGUKKyAgICAgKiB7QGxpbmsgUGhvbmVDb25zdGFudHMuU3RhdGV9IGVudW0gZm9yIHRoZSBwdWJsaWMgQVBJLgogICAgICAqLwogICAgIHB1YmxpYyBzdGF0aWMgUGhvbmVDb25zdGFudHMuU3RhdGUgY29udmVydENhbGxTdGF0ZShpbnQgc3RhdGUpIHsKICAgICAgICAgc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JvdGVjdGVkIHN0YXRpYyBmaW5hbCBib29sZWFuIERCRyA9IHRydWU7CiAKLSAgICBwcm90ZWN0ZWQgUGhvbmVCYXNlIHBob25lOwotICAgIHByb3RlY3RlZCBBZG5SZWNvcmRDYWNoZSBhZG5DYWNoZTsKKyAgICBwcm90ZWN0ZWQgUGhvbmVCYXNlIG1QaG9uZTsKKyAgICBwcm90ZWN0ZWQgQWRuUmVjb3JkQ2FjaGUgbUFkbkNhY2hlOwogICAgIHByb3RlY3RlZCBmaW5hbCBPYmplY3QgbUxvY2sgPSBuZXcgT2JqZWN0KCk7Ci0gICAgcHJvdGVjdGVkIGludCByZWNvcmRTaXplW107Ci0gICAgcHJvdGVjdGVkIGJvb2xlYW4gc3VjY2VzczsKLSAgICBwcm90ZWN0ZWQgTGlzdDxBZG5SZWNvcmQ+IHJlY29yZHM7CisgICAgcHJvdGVjdGVkIGludCBtUmVjb3JkU2l6ZVtdOworICAgIHByb3RlY3RlZCBib29sZWFuIG1TdWNjZXNzOworICAgIHByb3RlY3RlZCBMaXN0PEFkblJlY29yZD4gbVJlY29yZHM7CiAKICAgICBwcm90ZWN0ZWQgc3RhdGljIGZpbmFsIGJvb2xlYW4gQUxMT1dfU0lNX09QX0lOX1VJX1RIUkVBRCA9IGZhbHNlOwogCkBAIC02MywxMyArNjIsMTMgQEAKICAgICAgICAgICAgICAgICAgICAgYXIgPSAoQXN5bmNSZXN1bHQpIG1zZy5vYmo7CiAgICAgICAgICAgICAgICAgICAgIHN5bmNocm9uaXplZCAobUxvY2spIHsKICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhci5leGNlcHRpb24gPT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY29yZFNpemUgPSAoaW50W10pYXIucmVzdWx0OworICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1SZWNvcmRTaXplID0gKGludFtdKWFyLnJlc3VsdDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyByZWNvcmRTaXplWzBdICBpcyB0aGUgcmVjb3JkIGxlbmd0aAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHJlY29yZFNpemVbMV0gIGlzIHRoZSB0b3RhbCBsZW5ndGggb2YgdGhlIEVGIGZpbGUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyByZWNvcmRTaXplWzJdICBpcyB0aGUgbnVtYmVyIG9mIHJlY29yZHMgaW4gdGhlIEVGIGZpbGUKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2dkKCJHRVRfUkVDT1JEX1NJWkUgU2l6ZSAiICsgcmVjb3JkU2l6ZVswXSArCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiIHRvdGFsICIgKyByZWNvcmRTaXplWzFdICsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICIgI3JlY29yZCAiICsgcmVjb3JkU2l6ZVsyXSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9nZCgiR0VUX1JFQ09SRF9TSVpFIFNpemUgIiArIG1SZWNvcmRTaXplWzBdICsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICIgdG90YWwgIiArIG1SZWNvcmRTaXplWzFdICsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICIgI3JlY29yZCAiICsgbVJlY29yZFNpemVbMl0pOwogICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgbm90aWZ5UGVuZGluZyhhcik7CiAgICAgICAgICAgICAgICAgICAgIH0KQEAgLTc3LDcgKzc2LDcgQEAKICAgICAgICAgICAgICAgICBjYXNlIEVWRU5UX1VQREFURV9ET05FOgogICAgICAgICAgICAgICAgICAgICBhciA9IChBc3luY1Jlc3VsdCkgbXNnLm9iajsKICAgICAgICAgICAgICAgICAgICAgc3luY2hyb25pemVkIChtTG9jaykgewotICAgICAgICAgICAgICAgICAgICAgICAgc3VjY2VzcyA9IChhci5leGNlcHRpb24gPT0gbnVsbCk7CisgICAgICAgICAgICAgICAgICAgICAgICBtU3VjY2VzcyA9IChhci5leGNlcHRpb24gPT0gbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgICBub3RpZnlQZW5kaW5nKGFyKTsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICBicmVhazsKQEAgLTg1LDExICs4NCwxMSBAQAogICAgICAgICAgICAgICAgICAgICBhciA9IChBc3luY1Jlc3VsdCltc2cub2JqOwogICAgICAgICAgICAgICAgICAgICBzeW5jaHJvbml6ZWQgKG1Mb2NrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYXIuZXhjZXB0aW9uID09IG51bGwpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWNvcmRzID0gKExpc3Q8QWRuUmVjb3JkPikgYXIucmVzdWx0OworICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1SZWNvcmRzID0gKExpc3Q8QWRuUmVjb3JkPikgYXIucmVzdWx0OwogICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZihEQkcpIGxvZ2QoIkNhbm5vdCBsb2FkIEFETiByZWNvcmRzIik7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlY29yZHMgIT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWNvcmRzLmNsZWFyKCk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1SZWNvcmRzICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbVJlY29yZHMuY2xlYXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICBub3RpZnlQZW5kaW5nKGFyKTsKQEAgLTEwOSwxMCArMTA4LDEwIEBACiAgICAgfTsKI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gICAgICAgICBhZG5DYWNoZS51cGRhdGVBZG5CeVNlYXJjaChlZmlkLCBvbGRBZG4sIG5ld0FkbiwgcGluMiwgcmVzcG9uc2UpOworICAgICAgICAgICAgbUFkbkNhY2hlLnVwZGF0ZUFkbkJ5U2VhcmNoKGVmaWQsIG9sZEFkbiwgbmV3QWRuLCBwaW4yLCByZXNwb25zZSk7CiAgICAgICAgICAgICB3YWl0Rm9yUmVzdWx0KHN0YXR1cyk7CiAgICAgICAgIH0KLSAgICAgICAgcmV0dXJuIHN1Y2Nlc3M7CisgICAgICAgIHJldHVybiBtU3VjY2VzczsKICAgICB9CiAKICAgICAvKioKQEAgLTIwNiwxMSArMjA2LDEyIEBACiAgICAgICogQHBhcmFtIHBpbjIgcmVxdWlyZWQgdG8gdXBkYXRlIEVGX0ZETiwgb3RoZXJ3aXNlIG11c3QgYmUgbnVsbAogICAgICAqIEByZXR1cm4gdHJ1ZSBmb3Igc3VjY2VzcwogICAgICAqLworICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBib29sZWFuCiAgICAgdXBkYXRlQWRuUmVjb3Jkc0luRWZCeUluZGV4KGludCBlZmlkLCBTdHJpbmcgbmV3VGFnLAogICAgICAgICAgICAgU3RyaW5nIG5ld1Bob25lTnVtYmVyLCBpbnQgaW5kZXgsIFN0cmluZyBwaW4yKSB7CiAKLSAgICAgICAgaWYgKHBob25lLmdldENvbnRleHQoKS5jaGVja0NhbGxpbmdPclNlbGZQZXJtaXNzaW9uKAorICAgICAgICBpZiAobVBob25lLmdldENvbnRleHQoKS5jaGVja0NhbGxpbmdPclNlbGZQZXJtaXNzaW9uKAogICAgICAgICAgICAgICAgIGFuZHJvaWQuTWFuaWZlc3QucGVybWlzc2lvbi5XUklURV9DT05UQUNUUykKICAgICAgICAgICAgICAgICAhPSBQYWNrYWdlTWFuYWdlci5QRVJNSVNTSU9OX0dSQU5URUQpIHsKICAgICAgICAgICAgIHRocm93IG5ldyBTZWN1cml0eUV4Y2VwdGlvbigKQEAgLTIyMiwxNCArMjIzLDE0IEBACiAgICAgICAgICAgICAgICAgIigiKyBuZXdUYWcgKyAiLCIgKyBuZXdQaG9uZU51bWJlciArICIpIisgIiBwaW4yPSIgKyBwaW4yKTsKICAgICAgICAgc3luY2hyb25pemVkKG1Mb2NrKSB7CiAgICAgICAgICAgICBjaGVja1RocmVhZCgpOwotICAgICAgICAgICAgc3VjY2VzcyA9IGZhbHNlOworICAgICAgICAgICAgbVN1Y2Nlc3MgPSBmYWxzZTsKICAgICAgICAgICAgIEF0b21pY0Jvb2xlYW4gc3RhdHVzID0gbmV3IEF0b21pY0Jvb2xlYW4oZmFsc2UpOwogICAgICAgICAgICAgTWVzc2FnZSByZXNwb25zZSA9IG1CYXNlSGFuZGxlci5vYnRhaW5NZXNzYWdlKEVWRU5UX1VQREFURV9ET05FLCBzdGF0dXMpOwogICAgICAgICAgICAgQWRuUmVjb3JkIG5ld0FkbiA9IG5ldyBBZG5SZWNvcmQobmV3VGFnLCBuZXdQaG9uZU51bWJlcik7Ci0gICAgICAgICAgICBhZG5DYWNoZS51cGRhdGVBZG5CeUluZGV4KGVmaWQsIG5ld0FkbiwgaW5kZXgsIHBpbjIsIHJlc3BvbnNlKTsKKyAgICAgICAgICAgIG1BZG5DYWNoZS51cGRhdGVBZG5CeUluZGV4KGVmaWQsIG5ld0FkbiwgaW5kZXgsIHBpbjIsIHJlc3BvbnNlKTsKICAgICAgICAgICAgIHdhaXRGb3JSZXN1bHQoc3RhdHVzKTsKICAgICAgICAgfQotICAgICAgICByZXR1cm4gc3VjY2VzczsKKyAgICAgICAgcmV0dXJuIG1TdWNjZXNzOwogICAgIH0KIAogICAgIC8qKgpAQCAtMjQxLDYgKzI0Miw3IEBACiAgICAgICogICAgICAgICAgICByZWNvcmRTaXplc1sxXSAgaXMgdGhlIHRvdGFsIGxlbmd0aCBvZiB0aGUgRUYgZmlsZQogICAgICAqICAgICAgICAgICAgcmVjb3JkU2l6ZXNbMl0gIGlzIHRoZSBudW1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lKSB7CiAgICAgICAgIG1Db250ZXh0LmVuZm9yY2VDYWxsaW5nUGVybWlzc2lvbigKLSAgICAgICAgICAgICAgICAiYW5kcm9pZC5wZXJtaXNzaW9uLlJFQ0VJVkVfU01TIiwgbWVzc2FnZSk7CisgICAgICAgICAgICAgICAgTWFuaWZlc3QucGVybWlzc2lvbi5SRUNFSVZFX1NNUywgbWVzc2FnZSk7CiAgICAgICAgIG1Db250ZXh0LmVuZm9yY2VDYWxsaW5nUGVybWlzc2lvbigKLSAgICAgICAgICAgICAgICAiYW5kcm9pZC5wZXJtaXNzaW9uLlNFTkRfU01TIiwgbWVzc2FnZSk7CisgICAgICAgICAgICAgICAgTWFuaWZlc3QucGVybWlzc2lvbi5TRU5EX1NNUywgbWVzc2FnZSk7CiAgICAgfQogCiAgICAgLyoqCkBAIC0xNTMsMTIgKzE1OCwxNyBAQAogICAgICAqIEByZXR1cm4gc3VjY2VzcyBvciBub3QKICAgICAgKgogICAgICAqLworICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBib29sZWFuCi0gICAgdXBkYXRlTWVzc2FnZU9uSWNjRWYoaW50IGluZGV4LCBpbnQgc3RhdHVzLCBieXRlW10gcGR1KSB7CisgICAgdXBkYXRlTWVzc2FnZU9uSWNjRWYoU3RyaW5nIGNhbGxpbmdQYWNrYWdlLCBpbnQgaW5kZXgsIGludCBzdGF0dXMsIGJ5dGVbXSBwZHUpIHsKICAgICAgICAgaWYgKERCRykgbG9nKCJ1cGRhdGVNZXNzYWdlT25JY2NFZjogaW5kZXg9IiArIGluZGV4ICsKICAgICAgICAgICAgICAgICAiIHN0YXR1cz0iICsgc3RhdHVzICsgIiA9PT4gIiArCiAgICAgICAgICAgICAgICAgIigiKyBBcnJheXMudG9TdHJpbmcocGR1KSArICIpIik7CiAgICAgICAgIGVuZm9yY2VSZWNlaXZlQW5kU2VuZCgiVXBkYXRpbmcgbWVzc2FnZSBvbiBJY2MiKTsKKyAgICAgICAgaWYgKG1BcHBPcHMubm90ZU9wKEFwcE9wc01hbmFnZXIuT1BfV1JJVEVfSUNDX1NNUywgQmluZGVyLmdldENhbGxpbmdVaWQoKSwKKyAgICAgICAgICAgICAgICBjYWxsaW5nUGFja2FnZSkgIT0gQXBwT3BzTWFuYWdlci5NT0RFX0FMTE9XRUQpIHsKKyAgICAgICAgICAgIHJldHVybiBmYWxzZTsKKyAgICAgICAgfQogICAgICAgICBzeW5jaHJvbml6ZWQobUxvY2spIHsKICAgICAgICAgICAgIG1TdWNjZXNzID0gZmFsc2U7CiAgICAgICAgICAgICBNZXNzYWdlIHJlc3BvbnNlID0gbUhhbmRsZXIub2J0YWluTWVzc2FnZShFVkVOVF9VUERBVEVfRE9ORSk7CkBAIC0xOTksMTIgKzIwOSwxNyBAQAogICAgICAqIEByZXR1cm4gc3VjY2VzcyBvciBub3QKICAgICAgKgogICAgICAqLwotICAgIHB1YmxpYyBib29sZWFuIGNvcHlNZXNzYWdlVG9JY2NFZihpbnQgc3RhdHVzLCBieXRlW10gcGR1LCBieXRlW10gc21zYykgeworICAgIEBPdmVycmlkZQorICAgIHB1YmxpYyBib29sZWFuIGNvcHlNZXNzYWdlVG9JY2NFZihTdHJpbmcgY2FsbGluZ1BhY2thZ2UsIGludCBzdGF0dXMsIGJ5dGVbXSBwZHUsIGJ5dGVbXSBzbXNjKSB7CiAgICAgICAgIC8vTk9URSBzbXNjIG5vdCB1c2VkIGluIFJVSU0KICAgICAgICAgaWYgKERCRykgbG9nKCJjb3B5TWVzc2FnZVRvSWNjRWY6IHN0YXR1cz0iICsgc3RhdHVzICsgIiA9PT4gIiArCiAgICAgICAgICAgICAgICAgInBkdT0oIisgQXJyYXlzLnRvU3RyaW5nKHBkdSkgKwogICAgICAgICAgICAgICAgICIpLCBzbXNjPSgiICsgQXJyYXlzLnRvU3RyaW5nKHNtc2MpICsiKSIpOwogICAgICAgICBlbmZvcmNlUmVjZWl2ZUFuZFNlbmQoIkNvcHlpbmcgbWVzc2FnZSB0byBJY2MiKTsKK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YyB2b2lkIHNlbmRUZXh0KFN0cmluZyBkZXN0QWRkciwgU3RyaW5nIHNjQWRkciwKKyAgICBAT3ZlcnJpZGUKKyAgICBwdWJsaWMgdm9pZCBzZW5kVGV4dChTdHJpbmcgY2FsbGluZ1BhY2thZ2UsIFN0cmluZyBkZXN0QWRkciwgU3RyaW5nIHNjQWRkciwKICAgICAgICAgICAgIFN0cmluZyB0ZXh0LCBQZW5kaW5nSW50ZW50IHNlbnRJbnRlbnQsIFBlbmRpbmdJbnRlbnQgZGVsaXZlcnlJbnRlbnQpIHsKICAgICAgICAgbVBob25lLmdldENvbnRleHQoKS5lbmZvcmNlQ2FsbGluZ1Blcm1pc3Npb24oCi0gICAgICAgICAgICAgICAgImFuZHJvaWQucGVybWlzc2lvbi5TRU5EX1NNUyIsCisgICAgICAgICAgICAgICAgTWFuaWZlc3QucGVybWlzc2lvbi5TRU5EX1NNUywKICAgICAgICAgICAgICAgICAiU2VuZGluZyBTTVMgbWVzc2FnZSIpOwogICAgICAgICBpZiAoUmxvZy5pc0xvZ2dhYmxlKCJTTVMiLCBMb2cuVkVSQk9TRSkpIHsKICAgICAgICAgICAgIGxvZygic2VuZFRleHQ6IGRlc3RBZGRyPSIgKyBkZXN0QWRkciArICIgc2NBZGRyPSIgKyBzY0FkZHIgKwogICAgICAgICAgICAgICAgICIgdGV4dD0nIisgdGV4dCArICInIHNlbnRJbnRlbnQ9IiArCiAgICAgICAgICAgICAgICAgc2VudEludGVudCArICIgZGVsaXZlcnlJbnRlbnQ9IiArIGRlbGl2ZXJ5SW50ZW50KTsKICAgICAgICAgfQorICAgICAgICBpZiAobUFwcE9wcy5ub3RlT3AoQXBwT3BzTWFuYWdlci5PUF9TRU5EX1NNUywgQmluZGVyLmdldENhbGxpbmdVaWQoKSwKKyAgICAgICAgICAgICAgICBjYWxsaW5nUGFja2FnZSkgIT0gQXBwT3BzTWFuYWdlci5NT0RFX0FMTE9XRUQpIHsKKyAgICAgICAgICAgIHJldHVybjsKKyA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FJsb2cuaXNMb2dnYWJsZSgiU01TIiwgTG9nLlZFUkJPU0UpKSB7CiAgICAgICAgICAgICBpbnQgaSA9IDA7CkBAIC0zNjcsMTQgKzM5OSwyMCBAQAogICAgICAgICAgICAgICAgICAgICAgICAgIiwgcGFydFsiICsgKGkrKykgKyAiXT0iICsgcGFydCk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KKyAgICAgICAgaWYgKG1BcHBPcHMubm90ZU9wKEFwcE9wc01hbmFnZXIuT1BfU0VORF9TTVMsIEJpbmRlci5nZXRDYWxsaW5nVWlkKCksCisgICAgICAgICAgICAgICAgY2FsbGluZ1BhY2thZ2UpICE9IEFwcE9wc01hbmFnZXIuTU9ERV9BTExPV0VEKSB7CisgICAgICAgICAgICByZXR1cm47CisgICAgICAgIH0KICAgICAgICAgbURpc3BhdGNoZXIuc2VuZE11bHRpcGFydFRleHQoZGVzdEFkZHIsIHNjQWRkciwgKEFycmF5TGlzdDxTdHJpbmc+KSBwYXJ0cywKICAgICAgICAgICAgICAgICAoQXJyYXlMaXN0PFBlbmRpbmdJbnRlbnQ+KSBzZW50SW50ZW50cywgKEFycmF5TGlzdDxQZW5kaW5nSW50ZW50PikgZGVsaXZlcnlJbnRlbnRzKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgaW50IGdldFByZW1pdW1TbXNQZXJtaXNzaW9uKFN0cmluZyBwYWNrYWdlTmFtZSkgewogICAgICAgICByZXR1cm4gbURpc3BhdGNoZXIuZ2V0UHJlbWl1bVNtc1Blcm1pc3Npb24ocGFja2FnZU5hbWUpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHNldFByZW1pdW1TbXNQZXJtaXNzaW9uKFN0cmluZyBwYWNrYWdlTmFtZSwgaW50IHBlcm1pc3Npb24pIHsKICAgICAgICAgbURpc3BhdGNoZXIuc2V0UHJlbWl1bVNtc1Blcm1pc3Npb24ocGFja2FnZU5hbWUsIH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gICAgICAgIGludCBtU3RhcnRJZDsKKyAgICAgICAgaW50IG1FbmRJZDsKICAgICAgICAgLy8gc29ydGVkIGJ5IGVhcmxpZXN0IHN0YXJ0IGlkCi0gICAgICAgIGZpbmFsIEFycmF5TGlzdDxDbGllbnRSYW5nZT4gY2xpZW50czsKKyAgICAgICAgZmluYWwgQXJyYXlMaXN0PENsaWVudFJhbmdlPiBtQ2xpZW50czsKIAogICAgICAgICAvKioKICAgICAgICAgICogQ3JlYXRlIGEgbmV3IEludFJhbmdlIHdpdGggYSBzaW5nbGUgY2xpZW50LgpAQCAtNjQsMTAgKzY0LDEwIEBACiAgICAgICAgICAqIEBwYXJhbSBjbGllbnQgdGhlIGNsaWVudCByZXF1ZXN0aW5nIHRoZSBlbmFibGVkIHJhbmdlCiAgICAgICAgICAqLwogICAgICAgICBJbnRSYW5nZShpbnQgc3RhcnRJZCwgaW50IGVuZElkLCBTdHJpbmcgY2xpZW50KSB7Ci0gICAgICAgICAgICB0aGlzLnN0YXJ0SWQgPSBzdGFydElkOwotICAgICAgICAgICAgdGhpcy5lbmRJZCA9IGVuZElkOwotICAgICAgICAgICAgY2xpZW50cyA9IG5ldyBBcnJheUxpc3Q8Q2xpZW50UmFuZ2U+KElOSVRJQUxfQ0xJRU5UU19BUlJBWV9TSVpFKTsKLSAgICAgICAgICAgIGNsaWVudHMuYWRkKG5ldyBDbGllbnRSYW5nZShzdGFydElkLCBlbmRJZCwgY2xpZW50KSk7CisgICAgICAgICAgICBtU3RhcnRJZCA9IHN0YXJ0SWQ7CisgICAgICAgICAgICBtRW5kSWQgPSBlbmRJZDsKKyAgICAgICAgICAgIG1DbGllbnRzID0gbmV3IEFycmF5TGlzdDxDbGllbnRSYW5nZT4oSU5JVElBTF9DTElFTlRTX0FSUkFZX1NJWkUpOworICAgICAgICAgICAgbUNsaWVudHMuYWRkKG5ldyBDbGllbnRSYW5nZShzdGFydElkLCBlbmRJZCwgY2xpZW50KSk7CiAgICAgICAgIH0KIAogICAgIC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ICAgICAgICAgdGhpcy5jbGllbnRzID0gbmV3IEFycmF5TGlzdDxDbGllbnRSYW5nZT4oaW50UmFuZ2UuY2xpZW50cy5zaXplKCkpOworICAgICAgICAgICAgbVN0YXJ0SWQgPSBpbnRSYW5nZS5tU3RhcnRJZDsKKyAgICAgICAgICAgIG1FbmRJZCA9IGludFJhbmdlLm1FbmRJZDsKKyAgICAgICAgICAgIG1DbGllbnRzID0gbmV3IEFycmF5TGlzdDxDbGllbnRSYW5nZT4oaW50UmFuZ2UubUNsaWVudHMuc2l6ZSgpKTsKICAgICAgICAgICAgIGZvciAoaW50IGk9MDsgaSA8IG51bUVsZW1lbnRzOyBpKyspIHsKLSAgICAgICAgICAgICAgICB0aGlzLmNsaWVudHMuYWRkKGludFJhbmdlLmNsaWVudHMuZ2V0KGkpKTsKKyAgICAgICAgICAgICAgICBtQ2xpZW50cy5hZGQoaW50UmFuZ2UubUNsaWVudHMuZ2V0KGkpKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfQogCkBAIC0xMTAsMTggKzExMCwxOCBAQAogICAgICAgICAgKiBAcGFyYW0gcmFuZ2UgdGhlIG5ldyBDbGllbnRSYW5nZSB0byBpbnNlcnQKICAgICAgICAgICovCiAgICAgICAgIHZvaWQgaW5zZXJ0KENsaWVudFJhbmdlIHJhbmdlKSB7Ci0gICAgICAgICAgICBpbnQgbGVuID0gY2xpZW50cy5zaXplKCk7CisgICAgICAgICAgICBpbnQgbGVuID0gbUNsaWVudHMuc2l6ZSgpOwogICAgICAgICAgICAgZm9yIChpbnQgaT0wOyBpIDwgbGVuOyBpKyspIHsKLSAgICAgICAgICAgICAgICBDbGllbnRSYW5nZSBuZXh0UmFuZ2UgPSBjbGllbnRzLmdldChpKTsKLSAgICAgICAgICAgICAgICBpZiAocmFuZ2Uuc3RhcnRJZCA8PSBuZXh0UmFuZ2Uuc3RhcnRJZCkgeworICAgICAgICAgICAgICAgIENsaWVudFJhbmdlIG5leHRSYW5nZSA9IG1DbGllbnRzLmdldChpKTsKKyAgICAgICAgICAgICAgICBpZiAocmFuZ2UubVN0YXJ0SWQgPD0gbmV4dFJhbmdlLm1TdGFydElkKSB7CiAgICAgICAgICAgICAgICAgICAgIC8vIGlnbm9yZSBkdXBsaWNhdGUgcmFuZ2VzIGZyb20gdGhlIHNhbWUgY2xpZW50CiAgICAgICAgICAgICAgICAgICAgIGlmICghcmFuZ2UuZXF1YWxzKG5leHRSYW5nZSkpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGNsaWVudHMuYWRkKGksIHJhbmdlKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1DbGllbnRzLmFkZChpLCByYW5nZSk7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGNsaWVudHMuYWRkKHJhbmdlKTsgICAgLy8gYXBwZW5kIHRvIGVuZCBvZiBsaXN0CisgICAgICAgICAgICBtQ2xpZW50cy5hZGQocmFuZ2UpOyAgICAvLyBhcHBlbmQgdG8gZW5kIG9mIGxpc3QKICAgICAgICAgfQogICAgIH0KIApAQCAtMTI5LDIzICsxMjksMjMgQEAKICAgICAgKiBUaGUgbWVzc2FnZSBpZCByYW5nZSBmb3IgYSBzaW5nbGUgY2xpZW50LgogICAgICAqLwogICAgIHByaXZhdGUgY2xhc3MgQ2xpZW50UmFuZ2UgewotICAgICAgICBmaW5hbCBpbnQgc3RhcnRJZDsKLSAgICAgICAgZmluYWwgaW50IGVuZElkOwotICAgICAgICBmaW5hbCBTdHJpbmcgY2xpZW50OworICAgICAgICBmaW5hbCBpbnQgbVN0YXJ0SWQ7CisgICAgICAgIGZpbmFsIGludCBtRW5kSWQ7CisgICAgICAgIGZpbmFsIFN0cmluZyBtQ2xpZW50OwogCiAgICAgICAgIENsaWVudFJhbmdlKGludCBzdGFydElkLCBpbnQgZW5kSWQsIFN0cmluZyBjbGllbnQpIHsKLSAgICAgICAgICAgIHRoaXMuc3RhcnRJZCA9IHN0YXJ0SWQ7Ci0gICAgICAgICAgICB0aGlzLmVuZElkID0gZW5kSWQ7Ci0gICAgICAgICAgICB0aGlzLmNsaWVudCA9IGNsaWVudDsKKyAgICAgICAgICAgIG1TdGFydElkID0gc3RhcnRJZDsKKyAgICAgICAgICAgIG1FbmRJZCA9IGVuZElkOworICAgICAgICAgICAgbUNsaWVudCA9IGNsaWVudDsKICAgICAgICAgfQogCiAgICAgICAgIEBPdmVycmlkZQogICAgICAgICBwdWJsaWMgYm9vbGVhbiBlcXVhbHMoT2JqZWN0IG8pIHsKICAgICAgICAgICAgIGlmIChvICE9IG51bGwgJiYgbyBpbnN0YW5jZW9mIENsaWVudFJhbmdlKSB7CiAgICAgICAgICAgICAgICAgQ2xpZW50UmFuZ2Ugb3RoZXIgPSAoQ2xpZW50UmFuZ2UpIG87Ci0gICAgICAgICAgICAgICAgcmV0dXJuIHN0YXJ0SWQgPT0gb3RoZXIuc3RhcnRJZCAmJgotICAgICAgICAgICAgICAgICAgICAgICAgZW5kSWQgPT0gb3RoZXIuZW5kSWQgJiYKLSAgICAgICAgICAgICAgICAgICAgICAgIGNsaWVudC5lcXVhbHMob3RoZXIuY2xpZW50KTsKKyAgICAgICAgICAgICAgICByZXR1cm4gbVN0YXJ0SWQgPT0gb3RoZXIubVN0YXJ0SWQgJiYKKyAgICAgICAgICAgICAgICAgICAgICAgIG1FbmRJZCA9PSBvdGhlci5tRW5kSWQgJiYKKyAgICAgICAgICAgICAgICAgICAgICAgIG1DbGllbnQuZXF1YWxzKG90aGVyLm1DbGllbnQpOwogICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICB9CkBAIC0xNTMsNyArMTUzLDcgQEAKIAogICAgICAgICBAT3ZlcnJpZGUKICAgICAgICAgcHVibGljIGludCBoYXNoQ29kZSgpIHsKLSAgICAgICAgICAgIHJldHVybiAoc3RhcnRJZCAqIDMxICsgZW5kSWQpICogMzEgKyBjbGllbnQuaGFzaENvZGUoKTsKKyAgICAgICAgICAgIHJldHVybiAobVN0YXJ0SWQgKiAzMSArIG1FbmRJZCkgKiAzMSArIG1DbGllbnQuaGFzaENvZGUoKTsKICAgICAgICAgfQogICAgIH0KIApAQCAtMTg5LDEwICsxODksMTAgQEAKIAogICAgICAgICBmb3IgKGludCBzdGFydEluZGV4ID0gMDsgc3RhcnRJbmRleCA8IGxlbjsgc3RhcnRJbmRleCsrKSB7CiAgICAgICAgICAgICBJbnRSYW5nZSByYW5nZSA9IG1SYW5nZXMuZ2V0KHN0YXJ0SW5kZXgpOwotICAgICAgICAgICAgaWYgKHN0YXJ0SWQgPCByYW5nZS5zdGFydElkKSB7CisgICAgICAgICAgICBpZiAoc3RhcnRJZCA8IHJhbmdlLm1TdGFydElkKSB7CiAgICAgICAgICAgICAgICAgLy8gdGVzdCBpZiBuZXcgcmFuZ2UgY29tcGxldGVseSBwcmVjZWRlcyB0aGlzIHJhbmdlCiAgICAgICAgICAgICAgICAgLy8gbm90ZSB0aGF0IFsxLCA0XSBhbmQgWzUsIDZdIGNvYWxlc2NlIHRvIFsxLCA2XQotICAgICAgICAgICAgICAgIGlmICgoZW5kSWQgKyAxKSA8IHJhbmdlLnN0YXJ0SWQpIHsKKyAgICAgICAgICAgICAgICBpZiAoKGVuZElkICsgMSkgPCByYW5nZS5tU3RhcnRJZCkgewogICAgICAgICAgICAgICAgICAgICAvLyBpbnNlcnQgbmV3IGludCByYW5nZSBiZWZvcmUgcHJldmlvdXMgZmlyc3QgcmFuZ2UKICAgICAgICAgICAgICAgICAgICAgaWYgKHRyeUFkZFNpbmdsZVJhbmdlKHN0YXJ0SWQsIGVuZElkLCB0cnVlKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgbVJhbmdlcy5hZGQoc3RhcnRJbmRleCwgbmV3IEludFJhbmdlKHN0YXJ0SWQsIGVuZElkLCBjbGllbnQpKTsKQEAgLTIwMCwxMSArMjAwLDExIEBACiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7ICAgLy8gZmFpbGVkIHRvIHVwZGF0ZSByYWRpbwogICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChlbmRJZCA8PSByYW5nZS5lbmRJZCkgeworICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZW5kSWQgPD0gcmFuZ2UubUVuZElkKSB7CiAgICAgICAgICAgICAgICAgICAgIC8vIGV4dGVuZCB0aGUgc3RhcnQgb2YgdGhpcyByYW5nZQotICAgICAgICAgICAgICAgICAgICBpZiAodHJ5QWRkU2luZ2xlUmFuZ2Uoc3RhcnRJZCwgcmFuZ2Uuc3RhcnRJZCAtIDEsIHRydWUpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICByYW5nZS5zdGFydElkID0gc3RhcnRJZDsKLSAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlLmNsaWVudHMuYWRkKDAsIG5ldyBDbGllbnRSYW5nZShzdGFydElkLCBlbmRJZCwgY2xpZW50KSk7CisgICAgICAgICAgICAgICAgICAgIGlmICh0cnlBZGRTaW5nbGVSYW5nZShzdGFydElkLCByYW5nZS5tU3RhcnRJZCAtIDEsIHRydWUpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICByYW5nZS5tU3RhcnRJZCA9IHN0YXJ0SWQ7CisgICAgICAgICAgICAgICAgICAgICAgICByYW5nZS5tQ2xpZW50cy5hZGQoMCwgbmV3IENsaWVudFJhbmdlKHN0YXJ0SWQsIGVuZElkLCBjbGllbnQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOyAgIC8vIGZhaWxlZCB0byB1cGRhdGUgcmFkaW8KQEAgLTIxMywxMyArMjEzLDEzIEBACiAgICAgICAgICAgICAgICAgICAgIC8vIGZpbmQgbGFzdCByYW5nZSB0aGF0IGNhbiBjb2FsZXNjZSBpbnRvIHRoZSBuZXcgY29tYmluZWQgcmFuZ2UKICAgICAgICAgICAgICAgICAgICAgZm9yIChpbnQgZW5kSW5kZXggPSBzdGFydEluZGV4KzE7IGVuZEluZGV4IDwgbGVuOyBlbmRJbmRleCsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBJbnRSYW5nZSBlbmRSYW5nZSA9IG1SYW5nZXMuZ2V0KGVuZEluZGV4KTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGlmICgoZW5kSWQgKyAxKSA8IGVuZFJhbmdlLnN0YXJ0SWQpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmICgoZW5kSWQgKyAxKSA8IGVuZFJhbmdlLm1TdGFydElkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gdHJ5IHRvIGFkZCBlbnRpcmUgbmV3IHJhbmdlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRyeUFkZFNpbmdsZVJhbmdlKHN0YXJ0SWQsIGVuZElkLCB0cnVlKSkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByYW5nZS5zdGFydElkID0gc3RhcnRJZDsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmFuZ2UuZW5kSWQgPSBlbmRJZDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmFuZ2UubVN0YXJ0SWQgPSBzdGFydElkOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByYW5nZS5tRW5kSWQgPSBlbmRJZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gaW5zZXJ0IG5ldyBDbGllbnRSYW5nZSBiZWZvcmUgZXhpc3RpbmcgcmFuZ2VzCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlLmNsaWVudHMuYWRkKDAsIG5ldyBDbGllbnRSYW5nZShzdGFydElkLCBlbmRJZCwgY2xpZW50KSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlLm1DbGllbnRzLmFkZCgwLCBuZXcgQ2xpZW50UmFuZ2Uoc3RhcnRJZCwgZW5kSWQsIGNsaWVudCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBjb2FsZXNjZSByYW5nZSB3aXRoIGZvbGxvd2luZyByYW5nZXMgdXAgdG8gZW5kSW5kZXgtMQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyByZW1vdmUgZWFjaCByYW5nZSBhZnRlciBhZGRpbmcgaXRzIGVsZW1lbnRzLCBzbyB0aGUgaW5kZXgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gb2YgdGhlIG5leHQgcmFuZ2UgdG8gam9pbiBpcyBhbHdheXMgc3RhcnRJbmRleCsxLgpAQCAtMjI4LDIxICsyMjgsMjEgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50IGpvaW5JbmRleCA9IHN0YXJ0SW5kZXggKyAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGludCBpID0gam9pbkluZGV4OyBpIDwgZW5kSW5kZXg7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSW50UmFuZ2Ugam9pblJhbmdlID0gbVJhbmdlcy5nZXQoam9pbkluZGV4KTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlLmNsaWVudHMuYWRkQWxsKGpvaW5SYW5nZS5jbGllbnRzKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlLm1DbGllbnRzLmFkZEFsbChqb2luUmFuZ2UubUNsaWVudHMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbVJhbmdlcy5yZW1vdmUoam9pblJhbmdlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7ICAgLy8gZmFpbGVkIHRvIHVwZGF0ZSByYWRpbwogICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZW5kSWQgPD0gZW5kUmFuZ2UuZW5kSWQpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZW5kSWQgPD0gZW5kUmFuZ2UubUVuZElkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gYWRkIHJhbmdlIGZyb20gc3RhcnQgaWQgdG8gc3RhcnQgb2YgbGFzdCBvdmVybGFwcGluZyByYW5nZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyB2YWx1ZXMgZnJvbSBlbmRSYW5nZS5zdGFydElkIHRvIGVuZElkIGFyZSBhbHJlYWR5IGVuYWJsZWQKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHJ5QWRkU2luZ2xlUmFuZ2Uoc3RhcnRJZCwgZW5kUmFuZ2Uuc3RhcnRJZCAtIDEsIHRydWUpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlLnN0YXJ0SWQgPSBzdGFydElkOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByYW5nZS5lbmRJZCA9IGVuZFJhbmdlLmVuZElkOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0cnlBZGRTaW5nbGVSYW5nZShzdGFydElkLCBlbmRSYW5nZS5tU3RhcnRJZCAtIDEsIHRydWUpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlLm1TdGFydElkID0gc3RhcnRJZDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmFuZ2UubUVuZElkID0gZW5kUmFuZ2UubUVuZElkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBpbnNlcnQgbmV3IENsaWVudFJhbmdlIGJlZm9yZSBleGlzdGluZyByYW5nZXMKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmFuZ2UuY2xpZW50cy5hZGQoMCwgbmV3IENsaWVudFJhbmdlKHN0YXJ0SWQsIGVuZElkLCBjbGllbnQpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmFuZ2UubUNsaWVudHMuYWRkKDAsIG5ldyBDbGllbnRSYW5nZShzdGFydElkLCBlbmRJZCwgY2xpZW50KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGNvYWxlc2NlIHJhbmdlIHdpdGggZm9sbG93aW5nIHJhbmdlcyB1cCB0byBlbmRJbmRleAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyByZW1vdmUgZWFjaCByYW5nZSBhZnRlciBhZGRpbmcgaXRzIGVsZW1lbnRzLCBzbyB0aGUgaW5kZXgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gb2YgdGhlIG5leHQgcmFuZ2UgdG8gam9pbiBpcyBhbHdheXMgc3RhcnRJbmRleCsxLgpAQCAtMjUxLDcgKzI1MSw3IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludCBqb2luSW5kZXggPSBzdGFydEluZGV4ICsgMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpbnQgaSA9IGpvaW5JbmRleDsgaSA8PSBlbmRJbmRleDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbnRSYW5nZSBqb2luUmFuZ2UgPSBtUmFuZ2VzLmdldChqb2luSW5kZXgpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmFuZ2UuY2xpZW50cy5hZGRBbGwoam9pblJhbmdlLmNsaWVudHMpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmFuZ2UubUNsaWVudHMuYWRkQWxsKGpvaW5SYW5nZS5tQ2xpZW50cyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtUmFuZ2VzLnJlbW92ZShqb2luUmFuZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwpAQCAtMjYzLDEwICsyNjMsMTAgQEAKIAogICAgICAgICAgICAgICAgICAgICAvLyBlbmRJZCBleHRlbmRzIHBhc3QgYWxsIGV4aXN0aW5nIEludFJhbmdlczogY29tYmluZSB0aGVtIGFsbCB0b2dldGhlcgogICAgICAgICAgICAgICAgICAgICBpZiAodHJ5QWRkU2luZ2xlUmFuZ2Uoc3RhcnRJZCwgZW5kSWQsIHRydWUpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICByYW5nZS5zdGFydElkID0gc3RhcnRJZDsKLSAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlLmVuZElkID0gZW5kSWQ7CisgICAgICAgICAgICAgICAgICAgICAgICByYW5nZS5tU3RhcnRJZCA9IHN0YXJ0SWQ7CisgICAgICAgICAgICAgICAgICAgICAgICByYW5nZS5tRW5kSWQgPSBlbmRJZDsKICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGluc2VydCBuZXcgQ2xpZW50UmFuZ2UgYmVmb3JlIGV4aXN0aW5nIHJhbmdlcwotICAgICAgICAgICAgICAgICAgICAgICAgcmFuZ2UuY2xpZW50cy5hZGQoMCwgbmV3IENsaWVudFJhbmdlKHN0YXJ0SWQsIGVuZElkLCBjbGllbnQpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlLm1DbGllbnRzLmFkZCgwLCBuZXcgQ2xpZW50UmFuZ2Uoc3RhcnRJZCwgZW5kSWQsIGNsaWVudCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgLy8gY29hbGVzY2UgcmFuZ2Ugd2l0aCBmb2xsb3dpbmcgcmFuZ2VzIHVwIHRvIGxlbi0xCiAgICAgICAgICAgICAgICAgICAgICAgICAvLyByZW1vdmUgZWFjaCByYW5nZSBhZnRlciBhZGRpbmcgaXRzIGVsZW1lbnRzLCBzbyB0aGUgaW5kZXgKICAgICAgICAgICAgICAgICAgICAgICAgIC8vIG9mIHRoZSBuZXh0IHJhbmdlIHRvIGpvaW4gaXMgYWx3YXlzIHN0YXJ0SW5kZXgrMS4KQEAgLTI3NSw3ICsyNzUsNyBAQAogICAgICAgICAgICAgICAgICAgICAgICAgaW50IGpvaW5JbmRleCA9IHN0YXJ0SW5kZXggKyAxOwogICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpbnQgaSA9IGpvaW5JbmRleDsgaSA8IGxlbjsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSW50UmFuZ2Ugam9pblJhbmdlID0gbVJhbmdlcy5nZXQoam9pbkluZGV4KTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICByYW5nZS5jbGllbnRzLmFkZEFsbChqb2luUmFuZ2UuY2xpZW50cyk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmFuZ2UubUNsaWVudHMuYWRkQWxsKGpvaW5SYW5nZS5tQ2xpZW50cyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbVJhbmdlcy5yZW1vdmUoam9pblJhbmdlKTsKICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwpAQCAtMjgzLDggKzI4Myw4IEBACiAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7ICAgLy8gZmFpbGVkIHRvIHVwZGF0ZSByYWRpbwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgfSBlbHNlIGlmICgoc3RhcnRJZCArIDEpIDw9IHJhbmdlLmVuZElkKSB7Ci0gICAgICAgICAgICAgICAgaWYgKGVuZElkIDw9IHJhbmdlLmVuZElkKSB7CisgICAgICAgICAgICB9IGVsc2UgaWYgKChzdGFydElkICsgMSkgPD0gcmFuZ2UubUVuZElkKSB7CisgICAgICAgICAgICAgICAgaWYgKGVuZElkIDw9IHJhbmdlLm1FbmRJZCkgewogICAgICAgICAgICAgICAgICAgICAvLyBjb21wbGV0ZWx5IGNvbnRhaW5lZCBpbiBleGlzdGluZyByYW5nZTsgbm8gcmFkaW8gY2hhbmdlcwogICAgICAgICAgICAgICAgICAgICByYW5nZS5pbnNlcnQobmV3IENsaWVudFJhbmdlKHN0YXJ0SWQsIGVuZElkLCBjbGllbnQpKTsKICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CkBAIC0yOTMsNyArMjkzLDcgQEAKICAgICAgICAgICAgICAgICAgICAgaW50IGVuZEluZGV4ID0gc3RhcnRJbmRleDsKICAgICAgICAgICAgICAgICAgICAgZm9yIChpbnQgdGVzdEluZGV4ID0gc3RhcnRJbmRleCsxOyB0ZXN0SW5kZXggPCBsZW47IHRlc3RJbmRleCsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBJbnRSYW5nZSB0ZXN0UmFuZ2UgPSBtUmFuZ2VzLmdldCh0ZXN0SW5kZXgpOwotICAgICAgICAgICAgICAgICAgICAgICAgaWYgKChlbmRJZCArIDEpIDwgdGVzdFJhbmdlLnN0YXJ0SWQpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmICgoZW5kSWQgKyAxKSA8IHRlc3RSYW5nZS5tU3RhcnRJZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmRJbmRleCA9IHRlc3RJbmRleDsKQEAgLTMwMyw4ICszMDMsOCBAQAogICAgICAgICAgICAgICAgICAgICBpZiAoZW5kSW5kZXggPT0gc3RhcnRJbmRleCkgewogICAgICAgICAgICAgICAgICAgICAgICAgLy8gYWRkIHJhbmdlIGZyb20gcmFuZ2UuZW5kSWQrMSB0byBlbmRJZCwKICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHZhbHVlcyBmcm9tIHN0YXJ0SWQgdG8gcmFuZ2UuZW5kSWQgYXJlIGFscmVhZHkgZW5hYmxlZAotICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRyeUFkZFNpbmdsZVJhbmdlKHJhbmdlLmVuZElkICsgMSwgZW5kSWQsIHRydWUpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmFuZ2UuZW5kSWQgPSBlbmRJZDsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0cnlBZGRTaW5nbGVSYW5nZShyYW5nZS5tRW5kSWQgKyAxLCBlbmRJZCwgdHJ1ZSkpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICByYW5nZS5tRW5kSWQgPSBlbmRJZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICByYW5nZS5pbnNlcnQobmV3IENsaWVudFJhbmdlKHN0YXJ0SWQsIGVuZElkLCBjbGllbnQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CkBAIC0zMTcsOSArMzE3LDkgQEAKICAgICAgICAgICAgICAgICAgICAgLy8gaWYgZW5kSWQgPiBlbmRSYW5nZS5lbmRJZCwgdGhlbiBlbmFibGUgcmFuZ2UgZnJvbSByYW5nZS5lbmRJZCsxIHRvIGVuZElkLAogICAgICAgICAgICAgICAgICAgICAvLyBlbHNlIGVuYWJsZSByYW5nZSBmcm9tIHJhbmdlLmVuZElkKzEgdG8gZW5kUmFuZ2Uuc3RhcnRJZC0xLCBiZWNhdXNlCiAgICAgICAgICAgICAgICAgICAgIC8vIHZhbHVlcyBmcm9tIGVuZFJhbmdlLnN0YXJ0SWQgdG8gZW5kSWQgaGF2ZSBhbHJlYWR5IGJlZW4gYWRkZWQuCi0gICAgICAgICAgICAgICAgICAgIGludCBuZXdSYW5nZUVuZElkID0gKGVuZElkIDw9IGVuZFJhbmdlLmVuZElkKSA/IGVuZFJhbmdlLnN0YXJ0SWQgLSAxIDogZW5kSWQ7Ci0gICAgICAgICAgICAgICAgICAgIGlmICh0cnlBZGRTaW5nbGVSYW5nZShyYW5nZS5lbmRJZCArIDEsIG5ld1JhbmdlRW5kSWQsIHRydWUpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICByYW5nZS5lbmRJZCA9IGVuZElkOworICAgICAgICAgICAgICAgICAgICBpbnQgbmV3UmFuZ2VFbmRJZCA9IChlbmRJZCA8PSBlbmRSYW5nZS5tRW5kSWQpID8gZW5kUmFuZ2UubVN0YXJ0SWQgLSAxIDogZW5kSWQ7CisgICAgICAgICAgICAgICAgICAgIGlmICh0cnlBZGRTaW5nbGVSYW5nZShyYW5nZS5tRW5kSWQgKyAxLCBuZXdSYW5nZUVuZElkLCB0cnVlKSkgeworICAgICAgICAgICAgICAgICAgICAgICAgcmFuZ2UubUVuZElkID0gZW5kSWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBpbnNlcnQgbmV3IENsaWVudFJhbmdlIGluIHBsYWNlCiAgICAgICAgICAgICAgICAgICAgICAgICByYW5nZS5pbnNlcnQobmV3IENsaWVudFJhbmdlKHN0YXJ0SWQsIGVuZElkLCBjbGllbnQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGNvYWxlc2NlIHJhbmdlIHdpdGggZm9sbG93aW5nIHJhbmdlcyB1cCB0byBlbmRJbmRleC0xCkBAIC0zMzAsNyArMzMwLDcgQEAKICAgICAgICAgICAgICAgICAgICAgICAgIGludCBqb2luSW5kZXggPSBzdGFydEluZGV4ICsgMTsKICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaW50IGkgPSBqb2luSW5kZXg7IGkgPCBlbmRJbmRleDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSW50UmFuZ2Ugam9pblJhbmdlID0gbVJhbmdlcy5nZXQoam9pbkluZGV4KTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICByYW5nZS5jbGllbnRzLmFkZEFsbChqb2luUmFuZ2UuY2xpZW50cyk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmFuZ2UubUNsaWVudHMuYWRkQWxsKGpvaW5SYW5nZS5tQ2xpZW50cyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbVJhbmdlcy5yZW1vdmUoam9pblJhbmdlKTsKICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwpAQCAtMzY1LDE4ICszNjUsMTggQEAKIAogICAgICAgICBmb3IgKGludCBpPTA7IGkgPCBsZW47IGkrKykgewogICAgICAgICAgICAgSW50UmFuZ2UgcmFuZ2UgPSBtUmFuZ2VzLmdldChpKTsKLSAgICAgICAgICAgIGlmIChzdGFydElkIDwgcmFuZ2Uuc3RhcnRJZCkgeworICAgICAgICAgICAgaWYgKHN0YXJ0SWQgPCByYW5nZS5tU3RhcnRJZCkgewogICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsgICAvLyBub3QgZm91bmQKLSAgICAgICAgICAgIH0gZWxzZSBpZiAoZW5kSWQgPD0gcmFuZ2UuZW5kSWQpIHsKKyAgICAgICAgICAgIH0gZWxzZSBpZiAoZW5kSWQgPD0gcmFuZ2UubUVuZElkKSB7CiAgICAgICAgICAgICAgICAgLy8gZm91bmQgdGhlIEludFJhbmdlIHRoYXQgZW5jbG9zZXMgdGhlIGNsaWVudCByYW5nZSwgaWYgYW55CiAgICAgICAgICAgICAgICAgLy8gc2VhcmNoIGZvciBpdCBpbiB0aGUgY2xpZW50cyBsaXN0Ci0gICAgICAgICAgICAgICAgQXJyYXlMaXN0PENsaWVudFJhbmdlPiBjbGllbnRzID0gcmFuZ2UuY2xpZW50czsKKyAgICAgICAgICAgICAgICBBcnJheUxpc3Q8Q2xpZW50UmFuZ2U+IGNsaWVudHMgPSByYW5nZS5tQ2xpZW50czsKIAogICAgICAgICAgICAgICAgIC8vIGhhbmRsZSBjb21tb24gY2FzZSBvZiBJbnRSYW5nZSBjb250YWluaW5nIG9uZSBDbGllbnRSYW5nZQogICAgICAgICAgICAgICAgIGludCBjckxlbmd0aCA9IGNsaWVudHMuc2l6ZSgpOwogICAgICAgICAgICAgICAgIGlmIChjckxlbmd0aCA9PSAxKSB7CiAgICAgICAgICAgICAgICAgICAgIENsaWVudFJhbmdlIGNyID0gY2xpZW50cy5nZXQoMCk7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChjci5zdGFydElkID09IHN0YXJ0SWQgJiYgY3IuZW5kSWQgPT0gZW5kSWQgJiYgY3IuY2xpZW50LmVxdWFscyhjbGllbnQpKSB7CisgICAgICAgICAgICAgICAgICAgIGlmIChjci5tU3RhcnRJZCA9PSBzdGFydElkICYmIGNyLm1FbmRJZCA9PSBlbmRJZCAmJiBjci5tQ2xpZW50LmVxdWFscyhjbGllbnQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBkaXNhYmxlIHJhbmdlIGluIHJhZGlvIHRoZW4gcmVtb3ZlIHRoZSBlbnRpcmUgSW50UmFuZ2UKICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0cnlBZGRTaW5nbGVSYW5nZShzdGFydElkLCBlbmRJZCwgZmFsc2UpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbVJhbmdlcy5yZW1vdmUoaSk7CkBAIC0zOTgsMTggKzM5OCwxOCBAQAogCiAgICAgICAgICAgICAgICAgZm9yIChpbnQgY3JJbmRleD0wOyBjckluZGV4IDwgY3JMZW5ndGg7IGNySW5kZXgrKykgewogICAgICAgICAgICAgICAgICAgICBDbGllbnRSYW5nZSBjciA9IGNsaWVudHMuZ2V0KGNySW5kZXgpOwotICAgICAgICAgICAgICAgICAgICBpZiAoY3Iuc3RhcnRJZCA9PSBzdGFydElkICYmIGNyLmVuZElkID09IGVuZElkICYmIGNyLmNsaWVudC5lcXVhbHMoY2xpZW50KSkgeworICAgICAgICAgICAgICAgICAgICBpZiAoY3IubVN0YXJ0SWQgPT0gc3RhcnRJZCAmJiBjci5tRW5kSWQgPT0gZW5kSWQgJiYgY3IubUNsaWVudC5lcXVhbHMoY2xpZW50KSkgewogICAgICAgICAgICAgICAgICAgICAgICAgLy8gZm91bmQgdGhlIENsaWVudFJhbmdlIHRvIHJlbW92ZSwgY2hlY2sgaWYgaXQncyB0aGUgbGFzdCBpbiB0aGUgbGlzdAogICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNySW5kZXggPT0gY3JMZW5ndGggLSAxKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJhbmdlLmVuZElkID09IGxhcmdlc3RFbmRJZCkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyYW5nZS5tRW5kSWQgPT0gbGFyZ2VzdEVuZElkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIG5vIGNoYW5uZWxzIHRvIHJlbW92ZSBmcm9tIHJhZGlvOyByZXR1cm4gc3VjY2VzcwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGllbnRzLnJlbW92ZShjckluZGV4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gZGlzYWJsZSB0aGUgY2hhbm5lbHMgYXQgdGhlIGVuZCBhbmQgbG93ZXIgdGhlIGVuZCBpZAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHJ5QWRkU2luZ2xlUmFuZ2UobGFyZ2VzdEVuZElkICsgMSwgcmFuZ2UuZW5kSWQsIGZhbHNlKSkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHJ5QWRkU2luZ2xlUmFuZ2UobGFyZ2VzdEVuZElkICsgMSwgcmFuZ2UubUVuZElkLCBmYWxzZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsaWVudHMucmVtb3ZlKGNySW5kZXgpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmFuZ2UuZW5kSWQgPSBsYXJnZXN0RW5kSWQ7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByYW5nZS5tRW5kSWQgPSBsYXJnZXN0RW5kSWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKQEAgLTQyNywxNSArNDI3LDE1IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gdGhlIHN0YXJ0IGlkIG9mIHRoZSBJbnRSYW5nZS4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBXZSBrbm93IHRoZXJlIGFyZSBhdCBsZWFzdCB0d28gQ2xpZW50UmFuZ2VzIGluIHRoZSBsaXN0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHNvIGNsaWVudHMuZ2V0KDEpIHNob3VsZCBhbHdheXMgc3VjY2VlZC4KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgbmV4dFN0YXJ0SWQgPSBjbGllbnRzLmdldCgxKS5zdGFydElkOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZXh0U3RhcnRJZCAhPSByYW5nZS5zdGFydElkKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50IG5leHRTdGFydElkID0gY2xpZW50cy5nZXQoMSkubVN0YXJ0SWQ7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5leHRTdGFydElkICE9IHJhbmdlLm1TdGFydElkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0VXBkYXRlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVwZGF0ZVN0YXJ0ZWQgPSB0cnVlOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhZGRSYW5nZShyYW5nZS5zdGFydElkLCBuZXh0U3RhcnRJZCAtIDEsIGZhbHNlKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmFuZ2VDb3B5LnN0YXJ0SWQgPSBuZXh0U3RhcnRJZDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWRkUmFuZ2UocmFuZ2UubVN0YXJ0SWQsIG5leHRTdGFydElkIC0gMSwgZmFsc2UpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByYW5nZUNvcHkubVN0YXJ0SWQgPSBuZXh0U3RhcnRJZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gaW5pdCBsYXJnZXN0RW5kSWQKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXJnZXN0RW5kSWQgPSBjbGllbnRzLmdldCgxKS5lbmRJZDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXJnZXN0RW5kSWQgPSBjbGllbnRzLmdldCgxKS5tRW5kSWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGdvIHRocm91Z2ggcmVtYWluaW5nIENsaWVudFJhbmdlcywgY3JlYXRpbmcgbmV3IEludFJhbmdlcyB3aGVuCkBAIC00NDcsMjAgKzQ0NywyMCBAQAogICAgICAgICAgICAgICAgICAgICAgICAgSW50UmFuZ2UgY3VycmVudFJhbmdlID0gcmFuZ2VDb3B5OwogICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpbnQgbmV4dEluZGV4ID0gY3JJbmRleCArIDE7IG5leHRJbmRleCA8IGNyTGVuZ3RoOyBuZXh0SW5kZXgrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgIENsaWVudFJhbmdlIG5leHRDciA9IGNsaWVudHMuZ2V0KG5leHRJbmRleCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5leHRDci5zdGFydElkID4gbGFyZ2VzdEVuZElkICsgMSkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZXh0Q3IubVN0YXJ0SWQgPiBsYXJnZXN0RW5kSWQgKyAxKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdXBkYXRlU3RhcnRlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRVcGRhdGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVwZGF0ZVN0YXJ0ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFkZFJhbmdlKGxhcmdlc3RFbmRJZCArIDEsIG5leHRDci5zdGFydElkIC0gMSwgZmFsc2UpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50UmFuZ2UuZW5kSWQgPSBsYXJnZXN0RW5kSWQ7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFkZFJhbmdlKGxhcmdlc3RFbmRJZCArIDEsIG5leHRDci5tU3RhcnRJZCAtIDEsIGZhbHNlKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudFJhbmdlLm1FbmRJZCA9IGxhcmdlc3RFbmRJZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3UmFuZ2VzLmFkZChjdXJyZW50UmFuZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50UmFuZ2UgPSBuZXcgSW50UmFuZ2UobmV4dENyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50UmFuZ2UuY2xpZW50cy5hZGQobmV4dENyKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudFJhbmdlLm1DbGllbnRzLmFkZChuZXh0Q3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobmV4dENyLmVuZElkID4gbGFyZ2VzdEVuZElkKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxhcmdlc3RFbmRJZCA9IG5leHRDci5lbmRJZDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobmV4dENyLm1FbmRJZCA+IGxhcmdlc3RFbmRJZCkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXJnZXN0RW5kSWQgPSBuZXh0Q3IubUVuZElkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgIH0KIApAQCAtNDcxLDcgKzQ3MSw3IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVwZGF0ZVN0YXJ0ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhZGRSYW5nZShsYXJnZXN0RW5kSWQgKyAxLCBlbmRJZCwgZmFsc2UpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRSYW5nZS5lbmRJZCA9IGxhcmdlc3RFbmRJZDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50UmFuZ2UubUVuZElkID0gbGFyZ2VzdEVuZElkOwogICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgbmV3UmFuZ2VzLmFkZChjdXJyZW50UmFuZ2UpOwogCkBAIC00ODUsOCArNDg1LDggQEAKICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgLy8gbm90IHRoZSBDbGllbnRSYW5nZSB0byByZW1vdmU7IHNhdmUgaGlnaGVzdCBlbmQgSUQgc2VlbiBzbyBmYXIKLSAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjci5lbmRJZCA+IGxhcmdlc3RFbmRJZCkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxhcmdlc3RFbmRJZCA9IGNyLmVuZElkOworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNyLm1FbmRJZCA+IGxhcmdlc3RFbmRJZCkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxhcmdlc3RFbmRJZCA9IGNyLm1FbmRJZDsKICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0KQEAgLTUwNywyMCArNTA3LDIwIEBACiAgICAgICAgIEl0ZXJhdG9yPEludFJhbmdlPiBpdGVyYXRvciA9IG1SYW5nZXMuaXRlcmF0b3IoKTsKICAgICAgICAgaWYgKGl0ZXJhdG9yLmhhc05leHQoKSkgewogICAgICAgICAgICAgSW50UmFuZ2UgcmFuZ2UgPSBpdGVyYXRvci5uZXh0KCk7Ci0gICAgICAgICAgICBpbnQgc3RhcnQgPSByYW5nZS5zdGFydElkOwotICAgICAgICAgICAgaW50IGVuZCA9IHJhbmdlLmVuZElkOworICAgICAgICAgICAgaW50IHN0YXJ0ID0gcmFuZ2UubVN0YXJ0SWQ7CisgICAgICAgICAgICBpbnQgZW5kID0gcmFuZ2UubUVuZElkOwogICAgICAgICAgICAgLy8gYWNjdW11bGF0ZSByYW5nZXMgb2YgW3N0YXJ0SWQsIGVuZElkXQogICAgICAgICAgICAgd2hpbGUgKGl0ZXJhdG9yLmhhc05leHQoKSkgewogICAgICAgICAgICAgICAgIEludFJhbmdlIG5leHROb2RlID0gaXRlcmF0b3IubmV4dCgpOwogICAgICAgICAgICAgICAgIC8vIFtzdGFydElkQSwgZW5kSWRBXSwgW2VuZElkQSArIDEsIGVuZElkQl0gLT4gW3N0YXJ0SWRBLCBlbmRJZEJdCi0gICAgICAgICAgICAgICAgaWYgKG5leHROb2RlLnN0YXJ0SWQgPD0gKGVuZCArIDEpKSB7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChuZXh0Tm9kZS5lbmRJZCA+IGVuZCkgewotICAgICAgICAgICAgICAgICAgICAgICAgZW5kID0gbmV4dE5vZGUuZW5kSWQ7CisgICAgICAgICAgICAgICAgaWYgKG5leHROb2RlLm1TdGFydElkIDw9IChlbmQgKyAxKSkgeworICAgICAgICAgICAgICAgICAgICBpZiAobmV4dE5vZGUubUVuZElkID4gZW5kKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBlbmQgPSBuZXh0Tm9kZS5tRW5kSWQ7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICBhZGRSYW5nZShzdGFydCwgZW5kLCB0cnVlKTsKLSAgICAgICAgICAgICAgICAgICAgc3RhcnQgPSBuZXh0Tm9kZS5zdGFydElkOwotICAgICAgICAgICAgICAgICAgICBlbmQgPSBuZXh0Tm9kZS5lbmRJZDsKKyAgICAgICAgICAgICAgICAgICAgc3RhcnQgPSBuZXh0Tm9kZS5tU3RhcnRJZDsKKyAgICAgICAgICAgICAgICAgICAgZW5kID0gbmV4dE5vZGUubUVuZElkOwogICAgICAgICAgICAgICAgIH0KICAgICAg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G51bGwpOwogICAgICAgICB9CiAKICAgICAgICAgTWNjRW50cnkoaW50IG1uYywgU3RyaW5nIGlzbywgaW50IHNtYWxsZXN0RGlnaXRzTUNDLCBTdHJpbmcgbGFuZ3VhZ2UpIHsKLSAgICAgICAgICAgIHRoaXMubWNjID0gbW5jOwotICAgICAgICAgICAgdGhpcy5pc28gPSBpc287Ci0gICAgICAgICAgICB0aGlzLnNtYWxsZXN0RGlnaXRzTW5jID0gc21hbGxlc3REaWdpdHNNQ0M7Ci0gICAgICAgICAgICB0aGlzLmxhbmd1YWdlID0gbGFuZ3VhZ2U7CisgICAgICAgICAgICBtTWNjID0gbW5jOworICAgICAgICAgICAgbUlzbyA9IGlzbzsKKyAgICAgICAgICAgIG1TbWFsbGVzdERpZ2l0c01uYyA9IHNtYWxsZXN0RGlnaXRzTUNDOworICAgICAgICAgICAgbUxhbmd1YWdlID0gbGFuZ3VhZ2U7CiAgICAgICAgIH0KIAogCisgICAgICAgIEBPdmVycmlkZQogICAgICAgICBwdWJsaWMgaW50IGNvbXBhcmVUbyhNY2NFbnRyeSBvKQogICAgICAgICB7Ci0gICAgICAgICAgICByZXR1cm4gbWNjIC0gby5tY2M7CisgICAgICAgICAgICByZXR1cm4gbU1jYyAtIG8ubU1jYzsKICAgICAgICAgfQogICAgIH0KIApAQCAtNzgsMTIgKzc5LDEyIEBACiAKICAgICAgICAgbSA9IG5ldyBNY2NFbnRyeShtY2MsIG51bGwsIDApOwogCi0gICAgICAgIGluZGV4ID0gQ29sbGVjdGlvbnMuYmluYXJ5U2VhcmNoKHRhYmxlLCBtKTsKKyAgICAgICAgaW5kZXggPSBDb2xsZWN0aW9ucy5iaW5hcnlTZWFyY2goc1RhYmxlLCBtKTsKIAogICAgICAgICBpZiAoaW5kZXggPCAwKSB7CiAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgIHJldHVybiB0YWJsZS5nZXQoaW5kZXgpOworICAgICAgICAgICAgcmV0dXJuIHNUYWJsZS5nZXQoaW5kZXgpOwogICAgICAgICB9CiAgICAgfQogCkBAIC05NiwxNCArOTcsMTQgQEAKICAgICAgICAgTWNjRW50cnkgZW50cnk7CiAKICAgICAgICAgZW50cnkgPSBlbnRyeUZvck1jYyhtY2MpOwotICAgICAgICBpZiAoZW50cnkgPT0gbnVsbCB8fCBlbnRyeS5pc28gPT0gbnVsbCkgeworICAgICAgICBpZiAoZW50cnkgPT0gbnVsbCB8fCBlbnRyeS5tSXNvID09IG51bGwpIHsKICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgTG9jYWxlIGxvY2FsZTsKLSAgICAgICAgICAgIGlmIChlbnRyeS5sYW5ndWFnZSA9PSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgbG9jYWxlID0gbmV3IExvY2FsZShlbnRyeS5pc28pOworICAgICAgICAgICAgaWYgKGVudHJ5Lm1MYW5ndWFnZSA9PSBudWxsKSB7CisgICAgICAgICAgICAgICAgbG9jYWxlID0gbmV3IExvY2FsZShlbnRyeS5tSXNvKTsKICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgbG9jYWxlID0gbmV3IExvY2FsZShlbnRyeS5sYW5ndWFnZSwgZW50cnkuaXNvKTsKKyAgICAgICAgICAgICAgICBsb2NhbGUgPSBuZXcgTG9jYWxlKGVudHJ5Lm1MYW5ndWFnZSwgZW50cnkubUlzbyk7CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBTdHJpbmdbXSB0eiA9IFRpbWVab25lTmFtZXMuZm9yTG9jYWxlKGxvY2FsZSk7CiAgICAgICAgICAgICBpZiAodHoubGVuZ3RoID09IDApIHJldHVybiBudWxsOwpAQCAtMTI2LDcgKzEyNyw3IEBACiAgICAgICAgIGlmIChlbnRyeSA9PSBudWxsKSB7CiAgICAgICAgICAgICByZXR1cm4gIiI7CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICByZXR1cm4gZW50cnkuaXNvOworICAgICAgICAgICAgcmV0dXJuIGVudHJ5Lm1Jc287CiAgICAgICAgIH0KICAgICB9CiAKQEAgLTE0Myw3ICsxNDQsNyBAQAogICAgICAgICBpZiAoZW50cnkgPT0gbnVsbCkgewogICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICByZXR1cm4gZW50cnkubGFuZ3VhZ2U7CisgICAgICAgICAgICByZXR1cm4gZW50cnkubUxhbmd1YWdlOwogICAgICAgICB9CiAgICAgfQogCkBAIC0xNjIsNyArMTYzLDcgQEAKICAgICAgICAgaWYgKGVudHJ5ID09IG51bGwpIHsKICAgICAgICAgICAgIHJldHVybiAyOwogICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgcmV0dXJuIGVudHJ5LnNtYWxsZXN0RGlnaXRzTW5jOworICAgICAgICAgICAgcmV0dXJuIGVudHJ5Lm1TbWFsbGVzdERpZ2l0c01uYzsKICAgICAgICAgfQogICAgIH0KIApAQCAtMzEzLDcgKzMxNCw3IEBACiAgICAgfQogCiAgICAgc3RhdGljIHsKLSAgICAgICAgdGFibGUgPSBuZXcgQXJyYXlMaXN0PE1jY0VudHJ5PigyNDApOworICAgICAgICBzVGFibGUgPSBuZXcgQXJyYXlMaXN0PE1jY0VudHJ5PigyNDApOwogCiAKICAgICAgICAgLyoKQEAgLTMzMSwyNDIgKzMzMiwyNDIgQEAKICAgICAgICAgICoKICAgICAgICAgICovCiAKLQkJdGFibGUuYWRkKG5ldyBNY2NFbnRyeSgyMDIsImdyIiwyKSk7CS8vR3JlZWNlCi0JCXRhYmxlLmFkZChuZXcgTWNjRW50cnkoMjA0LCJubCIsMiwibmwiKSk7CS8vTmV0aGVybGFuZHMgKEtpbmdkb20gb2YgdGhlKQotCQl0YWJsZS5hZGQobmV3IE1jY0VudHJ5KDIwNiwiYmUiLDIpKTsJLy9CZWxnaXVtCi0JCXRhYmxlLmFkZChuZ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AgICAgU3RyaW5nIG9wZXJhdG9yTnVtZXJpYywKICAgICAgICAgICAgICAgICBTdGF0ZSBzdGF0ZSkgewogCi0gICAgICAgIHRoaXMub3BlcmF0b3JBbHBoYUxvbmcgPSBvcGVyYXRvckFscGhhTG9uZzsKLSAgICAgICAgdGhpcy5vcGVyYXRvckFscGhhU2hvcnQgPSBvcGVyYXRvckFscGhhU2hvcnQ7Ci0gICAgICAgIHRoaXMub3BlcmF0b3JOdW1lcmljID0gb3BlcmF0b3JOdW1lcmljOworICAgICAgICBtT3BlcmF0b3JBbHBoYUxvbmcgPSBvcGVyYXRvckFscGhhTG9uZzsKKyAgICAgICAgbU9wZXJhdG9yQWxwaGFTaG9ydCA9IG9wZXJhdG9yQWxwaGFTaG9ydDsKKyAgICAgICAgbU9wZXJhdG9yTnVtZXJpYyA9IG9wZXJhdG9yTnVtZXJpYzsKIAotICAgICAgICB0aGlzLnN0YXRlID0gc3RhdGU7CisgICAgICAgIG1TdGF0ZSA9IHN0YXRlOwogICAgIH0KIAogCkBAIC05NywxMSArOTcsMTIgQEAKICAgICB9CiAKIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdHJpbmcgdG9TdHJpbmcoKSB7Ci0gICAgICAgIHJldHVybiAiT3BlcmF0b3JJbmZvICIgKyBvcGVyYXRvckFscGhhTG9uZwotICAgICAgICAgICAgICAgICsgIi8iICsgb3BlcmF0b3JBbHBoYVNob3J0Ci0gICAgICAgICAgICAgICAgKyAiLyIgKyBvcGVyYXRvck51bWVyaWMKLSAgICAgICAgICAgICAgICArICIvIiArIHN0YXRlOworICAgICAgICByZXR1cm4gIk9wZXJhdG9ySW5mbyAiICsgbU9wZXJhdG9yQWxwaGFMb25nCisgICAgICAgICAgICAgICAgKyAiLyIgKyBtT3BlcmF0b3JBbHBoYVNob3J0CisgICAgICAgICAgICAgICAgKyAiLyIgKyBtT3BlcmF0b3JOdW1lcmljCisgICAgICAgICAgICAgICAgKyAiLyIgKyBtU3RhdGU7C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ICAgICAgICBtU21zU3RvcmFnZU1vbml0b3IgPSBudWxsOwogICAgICAgICBtU21zVXNhZ2VNb25pdG9yID0gbnVsbDsKQEAgLTMzNyw2ICszMzEsNyBAQAogICAgIH0KIAogICAgIC8vIEluaGVyaXRlZCBkb2N1bWVudGF0aW9uIHN1ZmZpY2VzLgorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBDb250ZXh0IGdldENvbnRleHQoKSB7CiAgICAgICAgIHJldHVybiBtQ29udGV4dDsKICAgICB9CkBAIC0zNDksNiArMzQ0LDcgQEAKICAgICAgKiBVc2VmdWwgZm9yIGxhYiB0ZXN0aW5nIGVudmlyb25tZW50LgogICAgICAqIEBwYXJhbSBiIHRydWUgZGlzYWJsZXMgdGhlIGNoZWNrLCBmYWxzZSBlbmFibGVzLgogICAgICAqLworICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIGRpc2FibGVEbnNDaGVjayhib29sZWFuIGIpIHsKICAgICAgICAgbURuc0NoZWNrRGlzYWJsZWQgPSBiOwogICAgICAgICBTaGFyZWRQcmVmZXJlbmNlcyBzcCA9IFByZWZlcmVuY2VNYW5hZ2VyLmdldERlZmF1bHRTaGFyZWRQcmVmZXJlbmNlcyhnZXRDb250ZXh0KCkpOwpAQCAtMzYwLDExICszNTYsMTMgQEAKICAgICAvKioKICAgICAgKiBSZXR1cm5zIHRydWUgaWYgdGhlIEROUyBjaGVjayBpcyBjdXJyZW50bHkgZGlzYWJsZWQuCiAgICAgICovCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGJvb2xlYW4gaXNEbnNDaGVja0Rpc2FibGVkKCkgewogICAgICAgICByZXR1cm4gbURuc0NoZWNrRGlzYWJsZWQ7CiAgICAgfQogCiAgICAgLy8gSW5oZXJpdGVkIGRvY3VtZW50YXRpb24gc3VmZmljZXMuCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgcmVnaXN0ZXJGb3JQcmVjaXNlQ2FsbFN0YXRlQ2h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ElORwogICAgICAqLworICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBpbnQgZ2V0Q2RtYUVyaUljb25Nb2RlKCkgewogICAgICAgICBsb2dVbmV4cGVjdGVkQ2RtYU1ldGhvZENhbGwoImdldENkbWFFcmlJY29uTW9kZSIpOwogICAgICAgICByZXR1cm4gLTE7CkBAIC05MDUsNTQgKzk1NCw2NCBAQAogICAgIC8qKgogICAgICAqIFJldHVybnMgdGhlIENETUEgRVJJIHRleHQsCiAgICAgICovCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFN0cmluZyBnZXRDZG1hRXJpVGV4dCgpIHsKICAgICAgICAgbG9nVW5leHBlY3RlZENkbWFNZXRob2RDYWxsKCJnZXRDZG1hRXJpVGV4dCIpOwogICAgICAgICByZXR1cm4gIkdTTSBudywgbm8gRVJJIjsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgU3RyaW5nIGdldENkbWFNaW4oKSB7CiAgICAgICAgIC8vIFRoaXMgZnVuY3Rpb24gc2hvdWxkIGJlIG92ZXJyaWRkZW4gYnkgdGhlIGNsYXNzIENETUFQaG9uZS4gTm90IGltcGxlbWVudGVkIGluIEdTTVBob25lLgogICAgICAgICBsb2dVbmV4cGVjdGVkQ2RtYU1ldGhvZENhbGwoImdldENkbWFNaW4iKTsKICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGJvb2xlYW4gaXNNaW5JbmZvUmVhZHkoKSB7CiAgICAgICAgIC8vIFRoaXMgZnVuY3Rpb24gc2hvdWxkIGJlIG92ZXJyaWRkZW4gYnkgdGhlIGNsYXNzIENETUFQaG9uZS4gTm90IGltcGxlbWVudGVkIGluIEdTTVBob25lLgogICAgICAgICBsb2dVbmV4cGVjdGVkQ2RtYU1ldGhvZENhbGwoImlzTWluSW5mb1JlYWR5Iik7CiAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICB9CiAKKyAgICB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QCAtMTMwLDcgKzEyOCw3IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAvL0dldCBjZG1hU3Vic2NyaXB0aW9uIG1vZGUgZnJvbSBTZXR0aW5ncy5TeXN0ZW0KICAgICAgICAgICAgICAgICAgICAgICAgIGNkbWFTdWJzY3JpcHRpb24gPSBTZXR0aW5ncy5HbG9iYWwuZ2V0SW50KGNvbnRleHQuZ2V0Q29udGVudFJlc29sdmVyKCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFNldHRpbmdzLkdsb2JhbC5QUkVGRVJSRURfQ0RNQV9TVUJTQ1JJUFRJT04sCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZWZlcnJlZENkbWFTdWJzY3JpcHRpb24pOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzUHJlZmVycmVkQ2RtYVN1YnNjcmlwdGlvbik7CiAgICAgICAgICAgICAgICAgICAgICAgICBSbG9nLmkoTE9HX1RBRywgImx0ZU9uQ2RtYSBub3Qgc2V0LCB1c2luZyBQUkVGRVJSRURfQ0RNQV9TVUJTQ1JJUFRJT04iKTsKICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgIH0KZGlmZiAtLWdpdCBhL3NyYy9qYXZhL2NvbS9hbmRyb2lkL2ludGVybmFsL3RlbGVwaG9ueS9QaG9uZVByb3h5LmphdmEgYi9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvUGhvbmVQcm94eS5qYXZhCmluZGV4IDMwMDUyOWIuLmJkMzIyYjMgMTAwNjQ0Ci0tLSBhL3NyYy9qYXZhL2NvbS9hbmRyb2lkL2ludGVybmFsL3RlbGVwaG9ueS9QaG9uZVByb3h5LmphdmEKKysrIGIvc3JjL2phdmEvY29tL2FuZHJvaWQvaW50ZXJuYWwvdGVsZXBob255L1Bob25lUHJveHkuamF2YQpAQCAtMzMsOCArMzMsNiBAQAogaW1wb3J0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ogUGhvbmVTdWJJbmZvLmdldFZvaWNlTWFpbE5VbWJlcjogIik7IC8vICsgbnVtYmVyKTsKKyAgICAgICAgaWYgKFZEQkcpIGxvZygiVk06IFBob25lU3ViSW5mby5nZXRWb2ljZU1haWxOVW1iZXI6ICIgKyBudW1iZXIpOwogICAgICAgICByZXR1cm4gbnVtYmVyOwogICAgIH0KIApAQCAtMTI3LDI2ICsxMzksMjkgQEAKICAgICAgKgogICAgICAqIEBoaWRlCiAgICAgICovCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFN0cmluZyBnZXRDb21wbGV0ZVZvaWNlTWFpbE51bWJlcigpIHsKICAgICAgICAgbUNvbnRleHQuZW5mb3JjZUNhbGxpbmdPclNlbGZQZXJtaXNzaW9uKENBTExfUFJJVklMRUdFRCwKICAgICAgICAgICAgICAgICAiUmVxdWlyZXMgQ0FMTF9QUklWSUxFR0VEIik7CiAgICAgICAgIFN0cmluZyBudW1iZXIgPSBtUGhvbmUuZ2V0Vm9pY2VNYWlsTnVtYmVyKCk7Ci0gICAgICAgIFJsb2cuZChMT0dfVEFHLCAiVk06IFBob25lU3ViSW5mby5nZXRDb21wbGV0ZVZvaWNlTWFpbE5VbWJlcjogIik7IC8vICsgbnVtYmVyKTsKKyAgICAgICAgaWYgKFZEQkcpIGxvZygiVk06IFBob25lU3ViSW5mby5nZXRDb21wbGV0ZVZvaWNlTWFpbE5VbWJlcjogIiArIG51bWJlcik7CiAgICAgICAgIHJldHVybiBudW1iZXI7CiAgICAgfQogCiAgICAgLyoqCiAgICAgICogUmV0cmlldmVzIHRoZSBhbHBoYSBpZGVudGlmaWVyIGFzc29jaWF0ZWQgd2l0aCB0aGUgdm9pY2UgbWFpbCBudW1iZXIuCiAgICAgICovCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFN0cmluZyBnZXRWb2ljZU1haWxBbHBoYVRhZygpIHsKICAgICAgICAgbUNvbnRleHQuZW5mb3JjZUNhbGxpbmdPclNlbGZQZXJtaXNz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AorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdHJpbmcgZ2V0RGV2aWNlSWQoKSB7CiAgICAgICAgIHJldHVybiBtUGhvbmVTdWJJbmZvLmdldERldmljZUlkKCk7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFN0cmluZyBnZXREZXZpY2VTdm4oKSB7CiAgICAgICAgIHJldHVybiBtUGhvbmVTdWJJbmZvLmdldERldmljZVN2bigpOwogICAgIH0KQEAgLTQ5LDYgKzQ5LDcgQEAKICAgICAvKioKICAgICAgKiBSZXRyaWV2ZXMgdGhlIHVuaXF1ZSBzdWJzY3JpYmVyIElELCBlLmcuLCBJTVNJIGZvciBHU00gcGhvbmVzLgogICAgICAqLworICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdHJpbmcgZ2V0U3Vic2NyaWJlcklkKCkgewogICAgICAgICByZXR1cm4gbVBob25lU3ViSW5mby5nZXRTdWJzY3JpYmVySWQoKTsKICAgICB9CkBAIC01Niw2ICs1Nyw3IEBACiAgICAgLyoqCiAgICAgICogUmV0cmlldmVzIHRoZSBzZXJpYWwgbnVtYmVyIG9mIHRoZSBJQ0MsIGlmIGFwcGxpY2FibGUuCiAgICAgICovCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFN0cmluZyBnZXRJY2NTZXJpYWxOdW1iZXIoKSB7CiAgICAgICAgIHJldHVybiBtUGhvbmVTdWJJbmZvLmdldEljY1NlcmlhbE51bWJlcigpOwogICAgIH0KQEAgLTYzLDYgKzY1LDcgQEAKICAgICAvKioKICAgICAgKiBSZXRyaWV2ZXMgdGhlIHBob25lIG51bWJlciBzdHJpbmcgZm9yIGxpbmUgMS4KICAgICAgKi8KKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgU3RyaW5nIGdldExpbmUxTnVtYmVyKCkgewogICAgICAgICByZXR1cm4gbVBob25lU3ViSW5mby5nZXRMaW5lMU51bWJlcigpOwogICAgIH0KQEAgLTcwLDYgKzcz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CBtU2VyaWFsOwogICAgIGludCBtUmVxdWVzdDsKICAgICBNZXNzYWdlIG1SZXN1bHQ7Ci0gICAgUGFyY2VsIG1wOworICAgIFBhcmNlbCBtUGFyY2VsOwogICAgIFJJTFJlcXVlc3QgbU5leHQ7CiAKICAgICAvKioKQEAgLTExOSwxNSArMTIwLDE1IEBACiAgICAgICAgIH0KICAgICAgICAgcnIubVJlcXVlc3QgPSByZXF1ZXN0OwogICAgICAgICByci5tUmVzdWx0ID0gcmVzdWx0OwotICAgICAgICByci5tcCA9IFBhcmNlbC5vYnRhaW4oKTsKKyAgICAgICAgcnIubVBhcmNlbCA9IFBhcmNlbC5vYnRhaW4oKTsKIAogICAgICAgICBpZiAocmVzdWx0ICE9IG51bGwgJiYgcmVzdWx0LmdldFRhcmdldCgpID09IG51bGwpIHsKICAgICAgICAgICAgIHRocm93IG5ldyBOdWxsUG9pbnRlckV4Y2VwdGlvbigiTWVzc2FnZSB0YXJnZXQgbXVzdCBub3QgYmUgbnVsbCIpOwogICAgICAgICB9CiAKICAgICAgICAgLy8gZmlyc3QgZWxlbWVudHMgaW4gYW55IFJJTCBQYXJjZWwKLSAgICAgICAgcnIubXAud3JpdGVJbnQocmVxdWVzdCk7Ci0gICAgICAgIHJyLm1wLndyaXRlSW50KHJyLm1TZXJpYWwpOworICAgICAgICByci5tUGFyY2VsLndyaXRlSW50KHJlcXVlc3QpOworICAgICAgICByci5tUGFyY2VsLndyaXRlSW50KHJyLm1TZXJpYWwpOwogCiAgICAgICAgIHJldHVybiBycjsKICAgICB9CkBAIC0xNDAsNyArMTQxLDcgQEAKICAgICB2b2lkIHJlbGVhc2UoKSB7CiAgICAgICAgIHN5bmNocm9uaXplZCAoc1Bvb2xTeW5jKSB7CiAgICAgICAgICAgICBpZiAoc1Bvb2xTaXplIDwgTUFYX1BPT0xfU0laRSkgewotICAgICAgICAgICAgICAgIHRoaXMubU5leHQgPSBzUG9vbDsKKyAgICAgICAgICAgICAgICBtTmV4dCA9IHNQb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ogICAgICAgICAgICAgfSBlbHNlIGlmIChpbnRlbnQuZ2V0QWN0aW9uKCkuZXF1YWxzKEludGVudC5BQ1RJT05fU0NSRUVOX09GRikpIHsKICAgICAgICAgICAgICAgICBzZW5kU2NyZWVuU3RhdGUoZmFsc2UpOwogICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICBSbG9nLncoTE9HX1RBRywgIlJJTCByZWNlaXZlZCB1bmV4cGVjdGVkIEludGVudDogIiArIGludGVudC5nZXRBY3Rpb24oKSk7CisgICAgICAgICAgICAgICAgUmxvZy53KFJJTEpfTE9HX1RBRywgIlJJTCByZWNlaXZlZCB1bmV4cGVjdGVkIEludGVudDogIiArIGludGVudC5nZXRBY3Rpb24oKSk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICB9OwpAQCAtMjg3LDYgKzI4OCw3IEBACiAgICAgICAgIGJ5dGVbXSBkYXRhTGVuZ3RoID0gbmV3IGJ5dGVbNF07CiAKICAgICAgICAgLy8qKioqKiBSdW5uYWJsZSBpbXBsZW1lbnRhdGlvbgorICAgICAgICBAT3ZlcnJpZGUKICAgICAgICAgcHVibGljIHZvaWQKICAgICAgICAgcnVuKCkgewogICAgICAgICAgICAgLy9zZXR1cCBpZiBuZWVkZWQKQEAgLTMzMiw5ICszMzQsOSBAQAogCiAgICAgICAgICAgICAgICAgICAgICAgICBieXRlW10gZGF0YTsKIAotICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSA9IHJyLm1wLm1hcnNoYWxsKCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICByci5tcC5yZWN5Y2xlKCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICByci5tcCA9IG51bGw7CisgICAgICAgICAgICAgICAgICAgICAgICBkYXRhID0gcnIubVBhcmNlbC5tYXJzaGFsbCgpOworICAgICAgICAgICAgICAgICAgICAgICAgcnIubVBhcmNlbC5yZWN5Y2xlKCk7CisgICAgICAgICAgICAgICAgICAgICAgICByci5tUGFyY2VsID0gbnVsbDsKIAogICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEubGVuZ3RoID4gUklMX01BWF9DT01NQU5EX0JZVEVTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IFJ1bnRpbWVFeGNlcHRpb24oCkBAIC0zNDcsMTIgKzM0OSwxMiBAQAogICAgICAgICAgICAgICAgICAgICAgICAgZGF0YUxlbmd0aFsyXSA9IChieXRlKSgoZGF0YS5sZW5ndGggPj4gOCkgJiAweGZmKTsKICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFMZW5ndGhbM10gPSAoYnl0ZSkoKGRhdGEubGVuZ3RoKSAmIDB4ZmYpOwogCi0gICAgICAgICAgICAgICAgICAgICAgICAvL1Jsb2cudihMT0dfVEFHLCAid3JpdGluZyBwYWNrZXQ6ICIgKyBkYXRhLmxlbmd0aCArICIgYnl0ZXMiKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIC8vUmxvZy52KFJJTEpfTE9HX1RBRywgIndyaXRpbmcgcGFja2V0OiAiICsgZGF0YS5sZW5ndGggKyAiIGJ5dGVzIik7CiAKICAgICAgICAgICAgICAgICAgICAgICAgIHMuZ2V0T3V0cHV0U3RyZWFtKCkud3JpdGUoZGF0YUxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgICBzLmdldE91dHB1dFN0cmVhbSgpLndyaXRlKGRhdGEpOwogICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChJT0V4Y2VwdGlvbiBleCkgewotICAgICAgICAgICAgICAgICAgICAgICAgUmxvZy5lKExPR19UQUcsICJJT0V4Y2VwdGlvbiIsIGV4KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIFJsb2cuZShSSUxKX0xPR19UQUcsICJJT0V4Y2VwdGlvbiIsIGV4KTsKICAgICAgICAgICAgICAgICAgICAgICAgIHJlcSA9IGZpbmRBbmRSZW1vdmVSZXF1ZXN0RnJvbUxpc3QocnIubVNlcmlhbCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBtYWtlIHN1cmUgdGhpcyByZXF1ZXN0IGhhcyBub3QgYWxyZWFkeSBiZWVuIGhhbmRsZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBlZywgaWYgUklMUmVjZWl2ZXIgY2xlYXJlZCB0aGUgbGlzdC4KQEAgLTM2MSw3ICszNjMsNyBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJyLnJlbGVhc2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoUnVudGltZUV4Y2VwdGlvbiBleGMpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIFJsb2cuZShMT0dfVEFHLCAiVW5jYXVnaHQgZXhjZXB0aW9uICIsIGV4Yyk7CisgICAgICAgICAgICAgICAgICAgICAgICBSbG9nLmUoUklMSl9MT0dfVEFHLCAiVW5jYXVnaHQgZXhjZXB0aW9uICIsIGV4Yyk7CiAgICAgICAgICAgICAgICAgICAgICAgICByZXEgPSBmaW5kQW5kUmVtb3ZlUmVxdWVzdEZyb21MaXN0KHJyLm1TZXJpYWwpOwogICAgICAgICAgICAgICAgICAgICAgICAgLy8gbWFrZSBzdXJlIHRoaXMgcmVxdWVzdCBoYXMgbm90IGFscmVhZHkgYmVlbiBoYW5kbGVkLAogICAgICAgICAgICAgICAgICAgICAgICAgLy8gZWcsIGlmIFJJTFJlY2VpdmVyIGNsZWFyZWQgdGhlIGxpc3QuCkBAIC0zOTcsNyArMzk5LDcgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBOb3RlOiBLZWVwIG1SZXF1ZXN0TGlzdCBzbyB0aGF0IGRlbGF5ZWQgcmVzcG9uc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBjYW4gc3RpbGwgYmUgaGFuZGxlZCB3aGVuIHJlc3BvbnNlIGZpbmFsbHkgY29tZXMuCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1SZXF1ZXN0TWVzc2FnZXNXYWl0aW5nICE9IDApIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsICJOT1RFOiBtUmVxV2FpdGluZyBpcyBOT1QgMCBidXQiCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFJsb2cuZChSSUxKX0xPR19UQUcsICJOT1RFOiBtUmVxV2FpdGluZyBpcyBOT1QgMCBidXQiCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyBtUmVxdWVzdE1lc3NhZ2VzV2FpdGluZyArICIgYXQgVElNRU9VVCwgcmVzZXQhIgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgIiBUaGVyZSBzdGlsbCBtc2cgd2FpdG5nIGZvciByZXNwb25zZSIpOwogCkBAIC00MDYsMTIgKzQwOCwxMiBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoUklMSl9MT0dEKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzeW5jaHJvbml6ZWQgKG1SZXF1ZXN0TGlzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludCBjb3VudCA9IG1SZXF1ZXN0TGlzdC5zaXplKCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsICJXQUtFX0xPQ0tfVElNRU9VVCAiICsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBSbG9nLmQoUklMSl9MT0dfVEFHLCAiV0FLRV9MT0NLX1RJTUVPVVQgIiArCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiIG1SZXF1ZXN0TGlzdD0iICsgY291bnQpOwogCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBjb3VudDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJyID0gbVJlcXVlc3RMaXN0LmdldChpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsIGkgKyAiOiBbIiArIHJyLm1TZXJpYWwgKyAiXSAiCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFJsb2cuZChSSUxKX0xPR19UQUcsIGkgKyAiOiBbIiArIHJyLm1TZXJpYWwgKyAiXSAiCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyByZXF1ZXN0VG9TdHJpbmcocnIubVJlcXVlc3QpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CkBAIC00MjUsNyArNDI3LDcgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBzaG91bGQgYWxyZWFkeSBzZW50IG91dCAoaS5lLgogICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIG1SZXF1ZXN0TWVzc2FnZXNQZW5kaW5nIGlzIDAgKXdoaWxlIFRJTUVPVVQgb2NjdXJzLgogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtUmVxdWVzdE1lc3NhZ2VzUGVuZGluZyAhPSAwKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFJsb2cuZShMT0dfVEFHLCAiRVJST1I6IG1SZXFQZW5kaW5nIGlzIE5PVCAwIGJ1dCIKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUmxvZy5lKFJJTEpfTE9HX1RBRywgIkVSUk9SOiBtUmVxUGVuZGluZyBpcyBOT1QgMCBidXQiCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyBtUmVxdWVzdE1lc3NhZ2VzUGVuZGluZyArICIgYXQgVElNRU9VVCwgcmVzZXQhIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1SZXF1ZXN0TWVzc2FnZXNQZW5kaW5nID0gMDsKIApAQCAtNDY1LDcgKzQ2Nyw3IEBACiAgICAgICAgICAgICBjb3VudFJlYWQgPSBpcy5yZWFkKGJ1ZmZlciwgb2Zmc2V0LCByZW1haW5pbmcpOwogCiAgICAgICAgICAgICBpZiAoY291bnRSZWFkIDwgMCApIHsKLSAgICAgICAgICAgICAgICBSbG9nLmUoTE9HX1RBRywgIkhpdCBFT1MgcmVhZGluZyBtZXNzYWdlIGxlbmd0aCIpOworICAgICAgICAgICAgICAgIFJsb2cuZShSSUxKX0xPR19UQUcsICJIaXQgRU9TIHJlYWRpbmcgbWVzc2FnZSBsZW5ndGgiKTsKICAgICAgICAgICAgICAgICByZXR1cm4gLTE7CiAgICAgICAgICAgICB9CiAKQEAgLTQ4NSw3ICs0ODcsNyBAQAogICAgICAgICAgICAgY291bnRSZWFkID0gaXMucmVhZChidWZmZXIsIG9mZnNldCwgcmVtYWluaW5nKTsKIAogICAgICAgICAgICAgaWYgKGNvdW50UmVhZCA8IDAgKSB7Ci0gICAgICAgICAgICAgICAgUmxvZy5lKExPR19UQUcsICJIaXQgRU9TIHJlYWRpbmcgbWVzc2FnZS4gIG1lc3NhZ2VMZW5ndGg9IiArIG1lc3NhZ2VMZW5ndGgKKyAgICAgICAgICAgICAgICBSbG9nLmUoUklMSl9MT0dfVEFHLCAiSGl0IEVPUyByZWFkaW5nIG1lc3NhZ2UuICBtZXNzYWdlTGVuZ3RoPSIgKyBtZXNzYWdlTGVuZ3RoCiAgICAgICAgICAgICAgICAgICAgICAgICArICIgcmVtYWluaW5nPSIgKyByZW1haW5pbmcpOwogICAgICAgICAgICAgICAgIHJldHVybiAtMTsKICAgICAgICAgICAgIH0KQEAgLTUwNCw2ICs1MDYsNyBAQAogICAgICAgICAgICAgYnVmZmVyID0gbmV3IGJ5dGVbUklMX01BWF9DT01NQU5EX0JZVEVTXTsKICAgICAgICAgfQogCisgICAgICAgIEBPdmVycmlkZQogICAgICAgICBwdWJsaWMgdm9pZAogICAgICAgICBydW4oKSB7CiAgICAgICAgICAgICBpbnQgcmV0cnlDb3VudCA9IDA7CkBAIC01MzAsMTIgKzUzMywxMiBAQAogICAgICAgICAgICAgICAgICAgICAvLyBvciBhZnRlciB0aGUgOHRoIHRpbWUKIAogICAgICAgICAgICAgICAgICAgICBpZiAocmV0cnlDb3VudCA9PSA4KSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBSbG9nLmUgKExPR19UQUcsCisgICAgICAgICAgICAgICAgICAgICAgICBSbG9nLmUgKFJJTEpfTE9HX1RBRywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiQ291bGRuJ3QgZmluZCAnIiArIFNPQ0tFVF9OQU1FX1JJTAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgIicgc29ja2V0IGFmdGVyICIgKyByZXRyeUNvdW50CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyAiIHRpbWVzLCBjb250aW51aW5nIHRvIHJldHJ5IHNpbGVudGx5Iik7CiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAocmV0cnlDb3VudCA+IDAgJiYgcmV0cnlDb3VudCA8IDgpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIFJsb2cuaSAoTE9HX1RBRywKKyAgICAgICAgICAgICAgICAgICAgICAgIFJsb2cuaSAoUklMSl9MT0dfVEFHLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICJDb3VsZG4ndCBmaW5kICciICsgU09DS0VUX05BTUVfUklMCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyAiJyBzb2NrZXQ7IHJldHJ5aW5nIGFmdGVyIHRpbWVvdXQiKTsKICAgICAgICAgICAgICAgICAgICAgfQpAQCAtNTUyLDcgKzU1NSw3IEBACiAgICAgICAgICAgICAgICAgcmV0cnlDb3VudCA9IDA7CiAKICAgICAgICAgICAgICAgICBtU29ja2V0ID0gczsKLSAgICAgICAgICAgICAgICBSbG9nLmkoTE9HX1RBRywgIkNvbm5lY3RlZCB0byAnIiArIFNPQ0tFVF9OQU1FX1JJTCArICInIHNvY2tldCIpOworICAgICAgICAgICAgICAgIFJsb2cuaShSSUxKX0xPR19UQUcsICJDb25uZWN0ZWQgdG8gJyIgKyBTT0NLRVRfTkFNRV9SSUwgKyAiJyBzb2NrZXQiKTsKIAogICAgICAgICAgICAgICAgIGludCBsZW5ndGggPSAwOwogICAgICAgICAgICAgICAgIHRyeSB7CkBAIC01NzIsMjAgKzU3NSwyMCBAQAogICAgICAgICAgICAgICAgICAgICAgICAgcC51bm1hcnNoYWxsKGJ1ZmZlciwgMCwgbGVuZ3RoKTsKICAgICAgICAgICAgICAgICAgICAgICAgIHAuc2V0RGF0YVBvc2l0aW9uKDApOwogCi0gICAgICAgICAgICAgICAgICAgICAgICAvL1Jsb2cudihMT0dfVEFHLCAiUmVhZCBwYWNrZXQ6ICIgKyBsZW5ndGggKyAiIGJ5dGVzIik7CisgICAgICAgICAgICAgICAgICAgICAgICAvL1Jsb2cudihSSUxKX0xPR19UQUcsICJSZWFkIHBhY2tldDogIiArIGxlbmd0aCArICIgYnl0ZXMiKTsKIAogICAgICAgICAgICAgICAgICAgICAgICAgcHJvY2Vzc1Jlc3BvbnNlKHApOwogICAgICAgICAgICAgICAgICAgICAgICAgcC5yZWN5Y2xlKCk7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9IGNhdGNoIChqYXZhLmlvLklPRXhjZXB0aW9uIGV4KSB7Ci0gICAgICAgICAgICAgICAgICAgIFJsb2cuaShMT0dfVEFHLCAiJyIgKyBTT0NLRVRfTkFNRV9SSUwgKyAiJyBzb2NrZXQgY2xvc2VkIiwKKyAgICAgICAgICAgICAgICAgICAgUmxvZy5pKFJJTEpfTE9HX1RBRywgIiciICsgU09DS0VUX05BTUVfUklMICsgIicgc29ja2V0IGNsb3NlZCIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4KTsKICAgICAgICAgICAgICAgICB9IGNhdGNoIChUaHJvd2FibGUgdHIpIHsKLSAgICAgICAgICAgICAgICAgICAgUmxvZy5lKExPR19UQUcsICJVbmNhdWdodCBleGNlcHRpb24gcmVhZCBsZW5ndGg9IiArIGxlbmd0aCArCisgICAgICAgICAgICAgICAgICAgIFJsb2cuZShSSUxKX0xPR19UQUcsICJVbmNhdWdodCBleGNlcHRpb24gcmVhZCBsZW5ndGg9IiArIGxlbmd0aCArCiAgICAgICAgICAgICAgICAgICAgICAgICAiRXhjZXB0aW9uOiIgKyB0ci50b1N0cmluZygpKTsKICAgICAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgICAgICBSbG9nLmkoTE9HX1RBRywgIkRpc2Nvbm5lY3RlZCBmcm9tICciICsgU09DS0VUX05BTUVfUklMCisgICAgICAgICAgICAgICAgUmxvZy5pKFJJTEpfTE9HX1RBRywgIkRpc2Nvbm5lY3RlZCBmcm9tICciICsgU09DS0VUX05BTUVfUklMCiAgICAgICAgICAgICAgICAgICAgICAgKyAiJyBzb2NrZXQiKTsKIAogICAgICAgICAgICAgICAgIHNldFJhZGlvU3RhdGUgKFJhZGlvU3RhdGUuUkFESU9fVU5BVkFJTEFCTEUpOwpAQCAtNjAxLDcgKzYwNCw3IEBACiAgICAgICAgICAgICAgICAgLy8gQ2xlYXIgcmVxdWVzdCBsaXN0IG9uIGNsb3NlCiAgICAgICAgICAgICAgICAgY2xlYXJSZXF1ZXN0TGlzdChSQURJT19OT1RfQVZBSUxBQkxFLCBmYWxzZSk7CiAgICAgICAgICAgICB9fSBjYXRjaCAoVGhyb3dhYmxlIHRyKSB7Ci0gICAgICAgICAgICAgICAgUmxvZy5lKExPR19UQUcsIlVuY2F1Z2h0IGV4Y2VwdGlvbiIsIHRyKTsKKyAgICAgICAgICAgICAgICBSbG9nLmUoUklMSl9MT0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AgcnIubVBhcmNlbC53cml0ZVN0cmluZyhwdWspOworICAgICAgICByci5tUGFyY2VsLndyaXRlU3RyaW5nKG5ld1Bpbik7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVTdHJpbmcoYWlkKTsKIAogICAgICAgICBzZW5kKHJyKTsKICAgICB9CkBAIC03NDUsOSArNzUwLDkgQEAKIAogICAgICAgICBpZiAoUklMSl9MT0dEKSByaWxqTG9nKHJyLnNlcmlhbFN0cmluZygpICsgIj4gIiArIHJlcXVlc3RUb1N0cmluZyhyci5tUmVxdWVzdCkpOwogCi0gICAgICAgIHJyLm1wLndyaXRlSW50KDIpOwotICAgICAgICByci5tcC53cml0ZVN0cmluZyhwaW4pOwotICAgICAgICByci5tcC53cml0ZVN0cmluZyhhaWQpOworICAgICAgICByci5tUGFyY2VsLndyaXRlSW50KDIpOworICAgICAgICByci5tUGFyY2VsLndyaXRlU3RyaW5nKHBpbik7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVTdHJpbmcoYWlkKTsKIAogICAgICAgICBzZW5kKHJyKTsKICAgICB9CkBAIC03NjUsMTAgKzc3MCwxMCBAQAogCiAgICAgICAgIGlmIChSSUxKX0xPR0QpIHJpbGpMb2cocnIuc2VyaWFsU3RyaW5nKCkgKyAiPiAiICsgcmVxdWVzdFRvU3RyaW5nKHJyLm1SZXF1ZXN0KSk7CiAKLSAgICAgICAgcnIubXAud3JpdGVJbnQoMyk7Ci0gICAgICAgIHJyLm1wLndyaXRlU3RyaW5nKHB1ayk7Ci0gICAgICAgIHJyLm1wLndyaXRlU3RyaW5nKG5ld1BpbjIpOwotICAgICAgICByci5tcC53cml0ZVN0cmluZyhhaWQpOworICAgICAgICByci5tUGFyY2VsLndyaXRlSW50KDMpOworICAgICAgICByci5tUGFyY2VsLndyaXRlU3RyaW5nKHB1ayk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVTdHJpbmcobmV3UGluMik7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVTdHJpbmcoYWlkKTsKIAogICAgICAgICBzZW5kKHJyKTsKICAgICB9CkBAIC03ODYsMTAgKzc5MSwxMCBAQAogCiAgICAgICAgIGlmIChSSUxKX0xPR0QpIHJpbGpMb2cocnIuc2VyaWFsU3RyaW5nKCkgKyAiPiAiICsgcmVxdWVzdFRvU3RyaW5nKHJyLm1SZXF1ZXN0KSk7CiAKLSAgICAgICAgcnIubXAud3JpdGVJbnQoMyk7Ci0gICAgICAgIHJyLm1wLndyaXRlU3RyaW5nKG9sZFBpbik7Ci0gICAgICAgIHJyLm1wLndyaXRlU3RyaW5nKG5ld1Bpbik7Ci0gICAgICAgIHJyLm1wLndyaXRlU3RyaW5nKGFpZCk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQoMyk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVTdHJpbmcob2xkUGluKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZVN0cmluZyhuZXdQaW4pOworICAgICAgICByci5tUGFyY2VsLndyaXRlU3RyaW5nKGFpZCk7CiAKICAgICAgICAgc2VuZChycik7CiAgICAgfQpAQCAtODA3LDQwICs4MTIsNDMgQEAKIAogICAgICAgICBpZiAoUklMSl9MT0dEKSByaWxqTG9nKHJyLnNlcmlhbFN0cmluZygpICsgIj4gIiArIHJlcXVlc3RUb1N0cmluZyhyci5tUmVxdWVzdCkpOwogCi0gICAgICAgIHJyLm1wLndyaXRlSW50KDMpOwotICAgICAgICByci5tcC53cml0ZVN0cmluZyhvbGRQaW4yKTsKLSAgICAgICAgcnIubXAud3JpdGVTdHJpbmcobmV3UGluMik7Ci0gICAgICAgIHJyLm1wLndyaXRlU3RyaW5nKGFpZCk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQoMyk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVTdHJpbmcob2xkUGluMik7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVTdHJpbmcobmV3UGluMik7CisgICAgICAgIHJyLm1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MX1JFUVVFU1RfRU5URVJfTkVUV09SS19ERVBFUlNPTkFMSVpBVElPTiwgcmVzdWx0KTsKIAogICAgICAgICBpZiAoUklMSl9MT0dEKSByaWxqTG9nKHJyLnNlcmlhbFN0cmluZygpICsgIj4gIiArIHJlcXVlc3RUb1N0cmluZyhyci5tUmVxdWVzdCkpOwogCi0gICAgICAgIHJyLm1wLndyaXRlSW50KDEpOwotICAgICAgICByci5tcC53cml0ZVN0cmluZyhuZXRwaW4pOworICAgICAgICByci5tUGFyY2VsLndyaXRlSW50KDEpOworICAgICAgICByci5tUGFyY2VsLndyaXRlU3RyaW5nKG5ldHBpbik7CiAKICAgICAgICAgc2VuZChycik7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQKICAgICBnZXRDdXJyZW50Q2FsbHMgKE1lc3NhZ2UgcmVzdWx0KSB7CiAgICAgICAgIFJJTFJlcXVlc3QgcnIgPSBSSUxSZXF1ZXN0Lm9idGFpbihSSUxfUkVRVUVTVF9HRVRfQ1VSUkVOVF9DQUxMUywgcmVzdWx0KTsKQEAgLTg1MCwxMSArODU4LDEzIEBACiAgICAgICAgIHNlbmQocnIpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIEBEZXByZWNhdGVkIHB1YmxpYyB2b2lkCiAgICAgZ2V0UERQQ29udGV4dExpc3QoTWVzc2FnZSByZXN1bHQpIHsKICAgICAgICAgZ2V0RGF0YUNhbGxMaXN0KHJlc3VsdCk7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQKICAgICBnZXREYXRhQ2FsbExpc3QoTWVzc2FnZSByZXN1bHQpIHsKICAgICAgICAgUklMUmVxdWVzdCByciA9IFJJTFJlcXVlc3Qub2J0YWluKFJJTF9SRVFVRVNUX0RBVEFfQ0FMTF9MSVNULCByZXN1bHQpOwpAQCAtODY0LDI2ICs4NzQsMjggQEAKICAgICAgICAgc2VuZChycik7CiAgICAgfQogCisgICAgQ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ICAgICAgcnIubXAud3JpdGVJbnQodXVzSW5mby5nZXRUeXBlKCkpOwotICAgICAgICAgICAgcnIubXAud3JpdGVJbnQodXVzSW5mby5nZXREY3MoKSk7Ci0gICAgICAgICAgICByci5tcC53cml0ZUJ5dGVBcnJheSh1dXNJbmZvLmdldFVzZXJEYXRhKCkpOworICAgICAgICAgICAgcnIubVBhcmNlbC53cml0ZUludCgxKTsgLy8gVVVTIGluZm9ybWF0aW9uIGlzIHByZXNlbnQKKyAgICAgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQodXVzSW5mby5nZXRUeXBlKCkpOworICAgICAgICAgICAgcnIubVBhcmNlbC53cml0ZUludCh1dXNJbmZvLmdldERjcygpKTsKKyAgICAgICAgICAgIHJyLm1QYXJjZWwud3JpdGVCeXRlQXJyYXkodXVzSW5mby5nZXRVc2VyRGF0YSgpKTsKICAgICAgICAgfQogCiAgICAgICAgIGlmIChSSUxKX0xPR0QpIHJpbGpMb2cocnIuc2VyaWFsU3RyaW5nKCkgKyAiPiAiICsgcmVxdWVzdFRvU3RyaW5nKHJyLm1SZXF1ZXN0KSk7CkBAIC04OTEsMTcgKzkwMywxOSBAQAogICAgICAgICBzZW5kKHJyKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZAogICAgIGdldElNU0koTWVzc2FnZSByZXN1bHQpIHsKICAgICAgICAgZ2V0SU1TSUZvckFwcChudWxsLCByZXN1bHQpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkCiAgICAgZ2V0SU1TSUZvckFwcChTdHJpbmcgYWlkLCBNZXNzYWdlIHJlc3VsdCkgewogICAgICAgICBSSUxSZXF1ZXN0IHJyID0gUklMUmVxdWVzdC5vYnRhaW4oUklMX1JFUVVFU1RfR0VUX0lNU0ksIHJlc3VsdCk7CiAKLSAgICAgICAgcnIubXAud3JpdGVJbnQoMSk7Ci0gICAgICAgIHJyLm1wLndyaXRlU3Ry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gcmVzdWx0KSB7CiAgICAgICAgIFJJTFJlcXVlc3QgcnIKQEAgLTk4NywyMiArMTAwOCwyNSBAQAogICAgIH0KIAogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgc2V0UHJlZmVycmVkVm9pY2VQcml2YWN5KGJvb2xlYW4gZW5hYmxlLCBNZXNzYWdlIHJlc3VsdCkgewogICAgICAgICBSSUxSZXF1ZXN0IHJyID0gUklMUmVxdWVzdC5vYnRhaW4oUklMX1JFUVVFU1RfQ0RNQV9TRVRfUFJFRkVSUkVEX1ZPSUNFX1BSSVZBQ1lfTU9ERSwKICAgICAgICAgICAgICAgICByZXN1bHQpOwogCi0gICAgICAgIHJyLm1wLndyaXRlSW50KDEpOwotICAgICAgICByci5tcC53cml0ZUludChlbmFibGUgPyAxOjApOworICAgICAgICByci5tUGFyY2VsLndyaXRlSW50KDEpOworICAgICAgICByci5tUGFyY2VsLndyaXRlSW50KGVuYWJsZSA/IDE6MCk7CiAKICAgICAgICAgc2VuZChycik7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgZ2V0UHJlZmVycmVkVm9pY2VQcml2YWN5KE1lc3NhZ2UgcmVzdWx0KSB7CiAgICAgICAgIFJJTFJlcXVlc3QgcnIgPSBSSUxSZXF1ZXN0Lm9idGFpbihSSUxfUkVRVUVTVF9DRE1BX1FVRVJZX1BSRUZFUlJFRF9WT0lDRV9QUklWQUNZX01PREUsCiAgICAgICAgICAgICAgICAgcmVzdWx0KTsKICAgICAgICAgc2VuZChycik7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQKICAgICBzZXBhcmF0ZUNvbm5lY3Rpb24gKGludCBnc21JbmRleCwgTWVzc2FnZSByZXN1bHQpIHsKICAgICAgICAgUklMUmVxdWVzdCBycgpAQCAtMTAxMSwxMiArMTAzNSwxMyBAQAogICAgICAgICBpZiAoUklMSl9MT0dEKSByaWxqTG9nKHJyLnNlcmlhbFN0cmluZygpICsgIj4gIiArIHJlcXVlc3RUb1N0cmluZyhyci5tUmVxdWVzdCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICArICIgIiArIGdzbUluZGV4KTsKIAotICAgICAgICByci5tcC53cml0ZUludCgxKTsKLSAgICAgICAgcnIubXAud3JpdGVJbnQoZ3NtSW5kZXgpOworICAgICAgICByci5tUGFyY2VsLndyaXRlSW50KDEpOworICAgICAgICByci5tUGFyY2VsLndyaXRlSW50KGdzbUluZGV4KTsKIAogICAgICAgICBzZW5kKHJyKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZAogICAgIGFjY2VwdENhbGwgKE1lc3NhZ2UgcmVzdWx0KSB7CiAgICAgICAgIFJJTFJlcXVlc3QgcnIKQEAgLTEwMjcsNiArMTA1Miw3IEBACiAgICAgICAgIHNlbmQocnIpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkCiAgICAgcmVqZWN0Q2FsbCAoTWVzc2FnZSByZXN1bHQpIHsKICAgICAgICAgUklMUmVxdWVzdCBycgpAQCAtMTAzNyw2ICsxMDYzLDcgQEAKICAgICAgICAgc2VuZChycik7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQKICAgICBleHBsaWNpdENhbGxUcmFuc2ZlciAoTWVzc2FnZSByZXN1bHQpIHsKICAgICAgICAgUklMUmVxdWVzdCBycgpAQCAtMTA0Nyw2ICsxMDc0LDcgQEAKICAgICAgICAgc2VuZChycik7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQKICAgICBnZXRMYXN0Q2FsbEZhaWxDYXVzZSAoTWVzc2FnZSByZXN1bHQpIHsKICAgICAgICAgUklMUmVxdWVzdCBycgpAQCAtMTA2MCw2ICsxMDg4LDggQEAKICAgICAvKioKICAgICAgKiBAZGVwcmVjYXRlZAogICAgICAqLworICAgIEBEZXByZWNhdGVkCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQKICAgICBnZXRMYXN0UGRwRmFpbENhdXNlIChNZXNzYWdlIHJlc3VsdCkgewogICAgICAgICBnZXRMYXN0RGF0YUNhbGxGYWlsQ2F1c2UgKHJlc3VsdCk7CkBAIC0xMDY4LDYgKzEwOTgsNyBAQAogICAgIC8qKgogICAgICAqIFRoZSBwcmVmZXJyZWQgbmV3IGFsdGVybmF0aXZlIHRvIGdldExhc3RQZHBGYWlsQ2F1c2UKICAgICAgKi8KKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZAogICAgIGdldExhc3REYXRhQ2FsbEZhaWxDYXVzZSAoTWVzc2FnZSByZXN1bHQpIHsKICAgICAgICAgUklMUmVxdWVzdCBycgpAQCAtMTA3OCw2ICsxMTA5LDcgQEAKICAgICAgICAgc2VuZChycik7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQKICAgICBzZXRNdXRlIChib29sZWFuIGVuYWJsZU11dGUsIE1lc3NhZ2UgcmVzcG9uc2UpIHsKICAgICAgICAgUklMUmVxdWVzdCBycgpAQCAtMTA4NiwxMiArMTExOCwxMyBAQAogICAgICAgICBpZiAoUklMSl9MT0dEKSByaWxqTG9nKHJyLnNlcmlhbFN0cmluZygpICsgIj4gIiArIHJlcXVlc3RUb1N0cmluZyhyci5tUmVxdWVzdCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICArICIgIiArIGVuYWJsZU11dGUpOwogCi0gICAgICAgIHJyLm1wLndyaXRlSW50KDEpOwotICAgICAgICByci5tcC53cml0ZUludChlbmFibGVNdXRlID8gMSA6IDApOworICAgICAgICByci5tUGFyY2VsLndyaXRlSW50KDEpOworICAgICAgICByci5tUGFyY2VsLndyaXRlSW50KGVuYWJsZU11dGUgPyAxIDogMCk7CiAKICAgICAgICAgc2VuZChycik7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQKIC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VSk7Ci0gICAgICAgIHJyLm1wLndyaXRlU3RyaW5nKHBkdSk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQoMik7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVTdHJpbmcoc21zY1BEVSk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVTdHJpbmcocGR1KTsKIAogICAgICAgICBpZiAoUklMSl9MT0dEKSByaWxqTG9nKHJyLnNlcmlhbFN0cmluZygpICsgIj4gIiArIHJlcXVlc3RUb1N0cmluZyhyci5tUmVxdWVzdCkpOwogCiAgICAgICAgIHNlbmQocnIpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkCiAgICAgc2VuZENkbWFTbXMoYnl0ZVtdIHBkdSwgTWVzc2FnZSByZXN1bHQpIHsKICAgICAgICAgaW50IGFkZHJlc3NfbmJyX29mX2RpZ2l0czsKQEAgLTEyMTcsMzAgKzEyNjAsMzAgQEAKICAgICAgICAgICAgICAgICA9IFJJTFJlcXVlc3Qub2J0YWluKFJJTF9SRVFVRVNUX0NETUFfU0VORF9TTVMsIHJlc3VsdCk7CiAKICAgICAgICAgdHJ5IHsKLSAgICAgICAgICAgIHJyLm1wLndyaXRlSW50KGRpcy5yZWFkSW50KCkpOyAvL3RlbGVTZXJ2aWNlSWQKLSAgICAgICAgICAgIHJyLm1wLndyaXRlQnl0ZSgoYnl0ZSkgZGlzLnJlYWRJbnQoKSk7IC8vc2VydmljZVByZXNlbnQKLSAgICAgICAgICAgIHJyLm1wLndyaXRlSW50KGRpcy5yZWFkSW50KCkpOyAvL3NlcnZpY2VDYXRlZ29yeQotICAgICAgICAgICAgcnIubXAud3JpdGVJbnQoZGlzLnJlYWQoKSk7IC8vYWRkcmVzc19kaWdpdF9tb2RlCi0gICAgICAgICAgICByci5tcC53cml0ZUludChkaXMucmVhZCgpKTsgLy9hZGRyZXNzX25icl9tb2RlCi0gICAgICAgICAgICByci5tcC53cml0ZUludChkaXMucmVhZCgpKTsgLy9hZGRyZXNzX3RvbgotICAgICAgICAgICAgcnIubXAud3JpdGVJbnQoZGlzLnJlYWQoKSk7IC8vYWRkcmVzc19uYnJfcGxhbgorICAgICAgICAgICAgcnIubVBhcmNlbC53cml0ZUludChkaXMucmVhZEludCgpKTsgLy90ZWxlU2VydmljZUlkCisgICAgICAgICAgICByci5tUGFyY2VsLndyaXRlQnl0ZSgoYnl0ZSkgZGlzLnJlYWRJbnQoKSk7IC8vc2VydmljZVByZXNlbnQKKyAgICAgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQoZGlzLnJlYWRJbnQoKSk7IC8vc2VydmljZUNhdGVnb3J5CisgICAgICAgICAgICByci5tUGFyY2VsLndyaXRlSW50KGRpcy5yZWFkKCkpOyAvL2FkZHJlc3NfZGlnaXRfbW9kZQorICAgICAgICAgICAgcnIubVBhcmNlbC53cml0ZUludChkaXMucmVhZCgpKTsgLy9hZGRyZXNzX25icl9tb2RlCisgICAgICAgICAgICByci5tUGFyY2VsLndyaXRlSW50KGRpcy5yZWFkKCkpOyAvL2FkZHJlc3NfdG9uCisgICAgICAgICAgICByci5tUGFyY2VsLndyaXRlSW50KGRpcy5yZWFkKCkpOyAvL2FkZHJlc3NfbmJyX3BsYW4KICAgICAgICAgICAgIGFkZHJlc3NfbmJyX29mX2RpZ2l0cyA9IChieXRlKSBkaXMucmVhZCgpOwotICAgICAgICAgICAgcnIubXAud3JpdGVCeXRlKChieXRlKSBhZGRyZXNzX25icl9vZl9kaWdpdHMpOworICAgICAgICAgICAgcnIubVBhcmNlbC53cml0ZUJ5dGUoKGJ5dGUpIGFkZHJlc3NfbmJyX29mX2RpZ2l0cyk7CiAgICAgICAgICAgICBmb3IoaW50IGk9MDsgaSA8IGFkZHJlc3NfbmJyX29mX2RpZ2l0czsgaSsrKXsKLSAgICAgICAgICAgICAgICByci5tcC53cml0ZUJ5dGUoZGlzLnJlYWRCeXRlKCkpOyAvLyBhZGRyZXNzX29yaWdfYnl0Z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XRlSW50KGJlYXJlckRhdGFMZW5ndGgpOworICAgICAgICAgICAgcnIubVBhcmNlbC53cml0ZUludChiZWFyZXJEYXRhTGVuZ3RoKTsKICAgICAgICAgICAgIGZvcihpbnQgaT0wOyBpIDwgYmVhcmVyRGF0YUxlbmd0aDsgaSsrKXsKLSAgICAgICAgICAgICAgICByci5tcC53cml0ZUJ5dGUoZGlzLnJlYWRCeXRlKCkpOyAvL2JlYXJlckRhdGFbaV0KKyAgICAgICAgICAgICAgICByci5tUGFyY2VsLndyaXRlQnl0ZShkaXMucmVhZEJ5dGUoKSk7IC8vYmVhcmVyRGF0YVtpXQogICAgICAgICAgICAgfQogICAgICAgICB9Y2F0Y2ggKElPRXhjZXB0aW9uIGV4KXsKICAgICAgICAgICAgIGlmIChSSUxKX0xPR0QpIHJpbGpMb2coInNlbmRTbXNDZG1hOiBjb252ZXJzaW9uIGZyb20gaW5wdXQgc3RyZWFtIHRvIG9iamVjdCBmYWlsZWQ6ICIKQEAgLTEyNTIsNzEgKzEyOTUsNjcgQEAKICAgICAgICAgc2VuZChycik7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgZGVsZXRlU21zT25TaW0oaW50IGluZGV4LCBNZXNzYWdlIHJlc3BvbnNlKSB7CiAgICAgICAgIFJJTFJlcXVlc3QgcnIgPSBSSUxSZXF1ZXN0Lm9idGFpbihSSUxfUkVRVUVTVF9ERUxFVEVfU01TX09OX1NJTSwKICAgICAgICAgICAgICAgICByZXNwb25zZSk7CiAKLSAgICAgICAgcnIubXAud3JpdGVJbnQoMSk7Ci0gICAgICAgIHJyLm1wLndyaXRlSW50KGluZGV4KTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZUludCgxKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZUludChpbmRleCk7CiAKLSAgICAgICAgaWYgKGZhbHNlKSB7Ci0gICAgICAgICAgICBpZiAoUklMSl9MT0dEKSByaWxqTG9nKHJyLnNlcmlhbFN0cmluZygpICsgIj4gIgotICAgICAgICAgICAgICAgICAgICArIHJlcXVlc3RUb1N0cmluZyhyci5tUmVxdWVzdCkKLSAgICAgICAgICAgICAgICAgICAgKyAiICIgKyBpbmRleCk7Ci0gICAgICAgIH0KKyAgICAgICAgaWYgKFJJTEpfTE9HVikgcmlsakxvZyhyci5zZXJpYWxTdHJpbmcoKSArICI+ICIKKyAgICAgICAgICAgICAgICArIHJlcXVlc3RUb1N0cmluZyhyci5tUmVxdWVzdCkKKyAgICAgICAgICAgICAgICArICIgIiArIGluZGV4KTsKIAogICAgICAgICBzZW5kKHJyKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBkZWxldGVTbXNPblJ1aW0oaW50IGluZGV4LCBNZXNzYWdlIHJlc3BvbnNlKSB7CiAgICAgICAgIFJJTFJlcXVlc3QgcnIgPSBSSUxSZXF1ZXN0Lm9idGFpbihSSUxfUkVRVUVTVF9DRE1BX0RFTEVURV9TTVNfT05fUlVJTSwKICAgICAgICAgICAgICAgICByZXNwb25zZSk7CiAKLSAgICAgICAgcnIubXAud3JpdGVJbnQoMSk7Ci0gICAgICAgIHJyLm1wLndyaXRlSW50KGluZGV4KTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZUludCgxKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZUludChpbmRleCk7CiAKLSAgICAgICAgaWYgKGZhbHNlKSB7Ci0gICAgICAgICAgICBpZiAoUklMSl9MT0dEKSByaWxqTG9nKHJyLnNlcmlhbFN0cmluZygpICsgIj4gIgotICAgICAgICAgICAgICAgICAgICArIHJlcXVlc3RUb1N0cmluZyhyci5tUmVxdWVzdCkKLSAgICAgICAgICAgICAgICAgICAgKyAiICIgKyBpbmRleCk7Ci0gICAgICAgIH0KKyAgICAgICAgaWYgKFJJTEpfTE9HVikgcmlsakxvZyhyci5zZXJpYWxTdHJpbmcoKSArICI+ICIKKyAgICAgICAgICAgICAgICArIHJlcXVlc3RUb1N0cmluZyhyci5tUmVxdWVzdCkKKyAgICAgICAgICAgICAgICArICIgIiArIGluZGV4KTsKIAogICAgICAgICBzZW5kKHJyKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCB3cml0ZVNtc1RvU2ltKGludCBzdGF0dXMsIFN0cmluZyBzbXNjLCBTdHJpbmcgcGR1LCBNZXNzYWdlIHJlc3BvbnNlKSB7CiAgICAgICAgIHN0YXR1cyA9IHRyYW5zbGF0ZVN0YXR1cyhzdGF0dXMpOwogCiAgICAgICAgIFJJTFJlcXVlc3QgcnIgPSBSSUxSZXF1ZXN0Lm9idGFpbihSSUxfUkVRVUVTVF9XUklURV9TTVNfVE9fU0lNLAogICAgICAgICAgICAgICAgIHJlc3BvbnNlKTsKIAotICAgICAgICByci5tcC53cml0ZUludChzdGF0dXMpOwotICAgICAgICByci5tcC53cml0ZVN0cmluZyhwZHUpOwotICAgICAgICByci5tcC53cml0ZVN0cmluZyhzbXNjKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZUludChzdGF0dXMpOworICAgICAgICByci5tUGFyY2VsLndyaXRlU3RyaW5nKHBkdSk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVTdHJpbmcoc21zYyk7CiAKLSAgICAgICAgaWYgKGZhbHNlKSB7Ci0gICAgICAgICAgICBpZiAoUklMSl9MT0dEKSByaWxqTG9nKHJyLnNlcmlhbFN0cmluZygpICsgIj4gIgotICAgICAgICAgICAgICAgICAgICArIHJlcXVlc3RUb1N0cmluZyhyci5tUmVxdWVzdCkKLSAgICAgICAgICAgICAgICAgICAgKyAiICIgKyBzdGF0dXMpOwotICAgICAgICB9CisgICAgICAgIGlmIChSSUxKX0xPR1YpIHJpbGpMb2cocnIuc2VyaWFsU3RyaW5nKCkgKyAiPiAiCisgICAgICAgICAgICAgICAgKyByZXF1ZXN0VG9TdHJpbmcocnIubVJlcXVlc3QpCisgICAgICAgICAgICAgICAgKyAiICIgKyBzdGF0dXMpOwogCiAgICAgICAgIHNlbmQocnIpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHdyaXRlU21zVG9SdWltKGludCBzdGF0dXMsIFN0cmluZyBwZHUsIE1lc3NhZ2UgcmVzcG9uc2UpIHsKICAgICAgICAgc3RhdHVzID0gdHJhbnNsYXRlU3RhdHVzKHN0YXR1cyk7CiAKICAgICAgICAgUklMUmVxdWVzdCByciA9IFJJTFJlcXVlc3Qub2J0YWluKFJJTF9SRVFVRVNUX0NETUFfV1JJVEVfU01TX1RPX1JVSU0sCiAgICAgICAgICAgICAgICAgcmVzcG9uc2UpOwogCi0gICAgICAgIHJyLm1wLndyaXRlSW50KHN0YXR1cyk7Ci0gICAgICAgIHJyLm1wLndyaXRlU3RyaW5nKHBkdSk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQoc3RhdHVzKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZVN0cmluZyhwZHUpOwogCi0gICAgICAgIGlmIChmYWxzZSkgewotICAgICAgICAgICAgaWYgKFJJTEpfTE9HRCkgcmlsakxvZyhyci5zZXJpYWxTdHJpbmcoKSArICI+ICIKLSAgICAgICAgICAgICAgICAgICAgKyByZXF1ZXN0VG9TdHJpbmcocnIubVJlcXVlc3QpCi0gICAgICAgICAgICAgICAgICAgICsgIiAiICsgc3RhdHVzKTsKLSAgICAgICAgfQorICAgICAgICBpZiAoUklMSl9MT0dWKSByaWxqTG9nKHJyLnNlcmlhbFN0cmluZygpICsgIj4gIgorICAgICAgICAgICAgICAgICsgcmVxdWVzdFRvU3RyaW5nKHJyLm1SZXF1ZXN0KQorICAgICAgICAgICAgICAgICsgIiAiICsgc3RhdHVzKTsKIAogICAgICAgICBzZW5kKHJyKTsKICAgICB9CkBAIC0xMzQxLDYgKzEzODAsNyBAQAogICAgICAgICByZXR1cm4gMTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZAogICAgIHNldHVwRGF0YUNhbGwoU3RyaW5nIHJhZGlvVGVjaG5vbG9neSwgU3RyaW5nIHByb2ZpbGUsIFN0cmluZyBhcG4sCiAgICAgICAgICAgICBTdHJpbmcgdXNlciwgU3RyaW5nIHBhc3N3b3JkLCBTdHJpbmcgYXV0aFR5cGUsIFN0cmluZyBwcm90b2NvbCwKQEAgLTEzNDgsMTUgKzEzODgsMTUgQEAKICAgICAgICAgUklMUmVxdWVzdCBycgogICAgICAgICAgICAgICAgID0gUklMUmVxdWVzdC5vYnRhaW4oUklMX1JFUVVFU1RfU0VUVVBfREFUQV9DQUxMLCByZXN1bHQpOwogCi0gICAgICAgIHJyLm1wLndyaXRlSW50KDcpOworICAgICAgICByci5tUGFyY2VsLndyaXRlSW50KDcpOwogCi0gICAgICAgIHJyLm1wLndyaXRlU3RyaW5nKHJhZGlvVGVjaG5vbG9neSk7Ci0gICAgICAgIHJyLm1wLndyaXRlU3RyaW5nKHByb2ZpbGUpOwotICAgICAgICByci5tcC53cml0ZVN0cmluZyhhcG4pOwotICAgICAgICByci5tcC53cml0ZVN0cmluZyh1c2VyKTsKLSAgICAgICAgcnIubXAud3JpdGVTdHJpbmcocGFzc3dvcmQpOwotICAgICAgICByci5tcC53cml0ZVN0cmluZyhhdXRoVHlwZSk7Ci0gICAgICAgIHJyLm1wLndyaXRlU3RyaW5nKHByb3RvY29sKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZVN0cmluZyhyYWRpb1RlY2hub2xvZ3kpOworICAgICAgICByci5tUGFyY2VsLndyaXRlU3RyaW5nKHByb2ZpbGUpOworICAgICAgICByci5tUGFyY2VsLndyaXRlU3RyaW5nKGFwbik7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVTdHJpbmcodXNlcik7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVTdHJpbmcocGFzc3dvcmQpOworICAgICAgICByci5tUGFyY2VsLndyaXRlU3RyaW5nKGF1dGhUeXBlKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZVN0cmluZyhwcm90b2NvbCk7CiAKICAgICAgICAgaWYgKFJJTEpfTE9HRCkgcmlsakxvZyhyci5zZXJpYWxTdHJpbmcoKSArICI+ICIKICAgICAgICAgICAgICAgICArIHJlcXVlc3RUb1N0cmluZyhyci5tUmVxdWVzdCkgKyAiICIgKyByYWRpb1RlY2hub2xvZ3kgKyAiICIKQEAgLTEzNjYsMTQgKzE0MDYsMTUgQEAKICAgICAgICAgc2VuZChycik7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQKICAgICBkZWFjdGl2YXRlRGF0YUNhbGwoaW50IGNpZCwgaW50IHJlYXNvbiwgTWVzc2FnZSByZXN1bHQpIHsKICAgICAgICAgUklMUmVxdWVzdCBycgogICAgICAgICAgICAgICAgID0gUklMUmVxdWVzdC5vYnRhaW4oUklMX1JFUVVFU1RfREVBQ1RJVkFURV9EQVRBX0NBTEwsIHJlc3VsdCk7CiAKLSAgICAgICAgcnIubXAud3JpdGVJbnQoMik7Ci0gICAgICAgIHJyLm1wLndyaXRlU3RyaW5nKEludGVnZXIudG9TdHJpbmcoY2lkKSk7Ci0gICAgICAgIHJyLm1wLndyaXRlU3RyaW5nKEludGVnZXIudG9TdHJpbmcocmVhc29uKSk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQoMik7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVTdHJpbmcoSW50ZWdlci50b1N0cmluZyhjaWQpKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZVN0cmluZyhJbnRlZ2VyLnRvU3RyaW5nKHJlYXNvbikpOwogCiAgICAgICAgIGlmIChSSUxKX0xPR0QpIHJpbGpMb2cocnIuc2VyaWFsU3RyaW5nKCkgKyAiPiAiICsKICAgICAgICAgICAgICAgICByZXF1ZXN0VG9TdHJpbmcocnIubVJlcXVlc3QpICsgIiAiICsgY2lkICsgIiAiICsgcmVhc29uKTsKQEAgLTEzODEsMTIgKzE0MjIsMTMgQEAKICAgICAgICAgc2VuZChycik7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQKICAgICBzZXRSYWRpb1Bvd2VyKGJvb2xlYW4gb24sIE1lc3NhZ2UgcmVzdWx0KSB7CiAgICAgICAgIFJJTFJlcXVlc3QgcnIgPSBSSUxSZXF1ZXN0Lm9idGFpbihSSUxfUkVRVUVTVF9SQURJT19QT1dFUiwgcmVzdWx0KTsKIAotICAgICAgICByci5tcC53cml0ZUludCgxKTsKLSAgICAgICAgcnIubXAud3JpdGVJbnQob24gPyAxIDogMCk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQoMSk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQob24gPyAxIDogMCk7CiAKICAgICAgICAgaWYgKFJJTEpfTE9HRCkgewogICAgICAgICAgICAgcmlsakxvZyhyci5zZXJpYWxTdHJpbmcoKSArICI+ICIgKyByZXF1ZXN0VG9TdHJpbmcocnIubVJlcXVlc3QpCkBAIC0xMzk2LDEzICsxNDM4LDE0IEBACiAgICAgICAgIHNlbmQocnIpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkCiAgICAgc2V0U3VwcFNlcnZpY2VOb3RpZmljYXRpb25zKGJvb2xlYW4gZW5hYmxlLCBNZXNzYWdlIHJlc3VsdCkgewogICAgICAgICBSSUxSZXF1ZXN0IHJyCiAgICAgICAgICAgICAgICAgPSBSSUxSZXF1ZXN0Lm9idGFpbihSSUxfUkVRVUVTVF9TRVRfU1VQUF9TVkNfTk9USUZJQ0FUSU9OLCByZXN1bHQpOwogCi0gICAgICAgIHJyLm1wLndyaXRlSW50KDEpOwotICAgICAgICByci5tcC53cml0ZUludChlbmFibGUgPyAxIDogMCk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQoMSk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQoZW5hYmxlID8gMSA6IDApOwogCiAgICAgICAgIGlmIChSSUxKX0xPR0QpIHJpbGpMb2cocnIuc2VyaWFsU3RyaW5nKCkgKyAiPiAiCiAgICAgICAgICAgICAgICAgKyByZXF1ZXN0VG9TdHJpbmcocnIubVJlcXVlc3QpKTsKQEAgLTE0MTAsMTQgKzE0NTMsMTUgQEAKICAgICAgICAgc2VuZChycik7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQKICAgICBhY2tub3dsZWRnZUxhc3RJbmNvbWluZ0dzbVNtcyhib29sZWFuIHN1Y2Nlc3MsIGludCBjYXVzZSwgTWVzc2FnZSByZXN1bHQpIHsKICAgICAgICAgUklMUmVxdWVzdCBycgogICAgICAgICAgICAgICAgID0gUklMUmVxdWVzdC5vYnRhaW4oUklMX1JFUVVFU1RfU01TX0FDS05PV0xFREdFLCByZXN1bHQpOwogCi0gICAgICAgIHJyLm1wLndyaXRlSW50KDIpOwotICAgICAgICByci5tcC53cml0ZUludChzdWNjZXNzID8gMSA6IDApOwotICAgICAgICByci5tcC53cml0ZUludChjYXVzZSk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQoMik7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQoc3VjY2VzcyA/IDEgOiAwKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZUludChjYXVzZSk7CiAKICAgICAgICAgaWYgKFJJTEpfTE9HRCkgcmlsakxvZyhyci5zZXJpYWxTdHJpbmcoKSArICI+ICIgKyByZXF1ZXN0VG9TdHJpbmcocnIubVJlcXVlc3QpCiAgICAgICAgICAgICAgICAgKyAiICIgKyBzdWNjZXNzICsgIiAiICsgY2F1c2UpOwpAQCAtMTQyNSwxNCArMTQ2OSwxNSBAQAogICAgICAgICBzZW5kKHJyKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZAogICAgIGFja25vd2xlZGdlTGFzdEluY29taW5nQ2RtYVNtcyh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aW4yLCBTdHJpbmcgYWlkLCBNZXNzYWdlIHJlc3VsdCkgewpAQCAtMTQ2OCwxNSArMTUxNiwxNSBAQAogICAgICAgICBSSUxSZXF1ZXN0IHJyCiAgICAgICAgICAgICAgICAgPSBSSUxSZXF1ZXN0Lm9idGFpbihSSUxfUkVRVUVTVF9TSU1fSU8sIHJlc3VsdCk7CiAKLSAgICAgICAgcnIubXAud3JpdGVJbnQoY29tbWFuZCk7Ci0gICAgICAgIHJyLm1wLndyaXRlSW50KGZpbGVpZCk7Ci0gICAgICAgIHJyLm1wLndyaXRlU3RyaW5nKHBhdGgpOwotICAgICAgICByci5tcC53cml0ZUludChwMSk7Ci0gICAgICAgIHJyLm1wLndyaXRlSW50KHAyKTsKLSAgICAgICAgcnIubXAud3JpdGVJbnQocDMpOwotICAgICAgICByci5tcC53cml0ZVN0cmluZyhkYXRhKTsKLSAgICAgICAgcnIubXAud3JpdGVTdHJpbmcocGluMik7Ci0gICAgICAgIHJyLm1wLndyaXRlU3RyaW5nKGFpZCk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQoY29tbWFuZCk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQoZmlsZWlkKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZVN0cmluZyhwYXRoKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZUludChwMSk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQocDIpOworICAgICAgICByci5tUGFyY2VsLndyaXRlSW50KHAzKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZVN0cmluZyhkYXRhKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZVN0cmluZyhwaW4yKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZVN0cmluZyhhaWQpOwogCiAgICAgICAgIGlmIChSSUxKX0xPR0QpIHJpbGpMb2cocnIuc2VyaWFsU3RyaW5nKCkgKyAiPiBpY2NJTzogIgogICAgICAgICAgICAgICAgICsgcmVxdWVzdFRvU3RyaW5nKHJyLm1SZXF1ZXN0KQpAQCAtMTQ4OSw2ICsxNTM3LDcgQEAKICAgICAgICAgc2VuZChycik7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQKICAgICBnZXRDTElSKE1lc3NhZ2UgcmVzdWx0KSB7CiAgICAgICAgIFJJTFJlcXVlc3QgcnIKQEAgLTE0OTksMTUgKzE1NDgsMTYgQEAKICAgICAgICAgc2VuZChycik7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQKICAgICBzZXRDTElSKGludCBjbGlyTW9kZSwgTWVzc2FnZSByZXN1bHQpIHsKICAgICAgICAgUklMUmVxdWVzdCBycgogICAgICAgICAgICAgICAgID0gUklMUmVxdWVzdC5vYnRhaW4oUklMX1JFUVVFU1RfU0VUX0NMSVIsIHJlc3VsdCk7CiAKICAgICAgICAgLy8gY291bnQgaW50cwotICAgICAgICByci5tcC53cml0ZUludCgxKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZUludCgxKTsKIAotICAgICAgICByci5tcC53cml0ZUludChjbGlyTW9kZSk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQoY2xpck1vZGUpOwogCiAgICAgICAgIGlmIChSSUxKX0xPR0QpIHJpbGpMb2cocnIuc2VyaWFsU3RyaW5nKCkgKyAiPiAiICsgcmVxdWVzdFRvU3RyaW5nKHJyLm1SZXF1ZXN0KQogICAgICAgICAgICAgICAgICAgICArICIgIiArIGNsaXJNb2RlKTsKQEAgLTE1MTUsMTMgKzE1NjUsMTQgQEAKICAgICAgICAgc2VuZChycik7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQKICAgICBxdWVyeUNhbGxXYWl0aW5nKGludCBzZXJ2aWNlQ2xhc3MsIE1lc3NhZ2UgcmVzcG9uc2UpIHsKICAgICAgICAgUklMUmVxdWVzdCBycgogICAgICAgICAgICAgICAgID0gUklMUmVxdWVzdC5vYnRhaW4oUklMX1JFUVVFU1RfUVVFUllfQ0FMTF9XQUlUSU5HLCByZXNwb25zZSk7CiAKLSAgICAgICAgcnIubXAud3JpdGVJbnQoMSk7Ci0gICAgICAgIHJyLm1wLndyaXRlSW50KHNlcnZpY2VDbGFzcyk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQoMSk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQoc2VydmljZUNsYXNzKTsKIAogICAgICAgICBpZiAoUklMSl9MT0dEKSByaWxqTG9nKHJyLnNlcmlhbFN0cmluZygpICsgIj4gIiArIHJlcXVlc3RUb1N0cmluZyhyci5tUmVxdWVzdCkKICAgICAgICAgICAgICAgICAgICAgKyAiICIgKyBzZXJ2aWNlQ2xhc3MpOwpAQCAtMTUyOSwxNCArMTU4MCwxNSBAQAogICAgICAgICBzZW5kKHJyKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZAogICAgIHNldENhbGxXYWl0aW5nKGJvb2xlYW4gZW5hYmxlLCBpbnQgc2VydmljZUNsYXNzLCBNZXNzYWdlIHJlc3BvbnNlKSB7CiAgICAgICAgIFJJTFJlcXVlc3QgcnIKICAgICAgICAgICAgICAgICA9IFJJTFJlcXVlc3Qub2J0YWluKFJJTF9SRVFVRVNUX1NFVF9DQUxMX1dBSVRJTkcsIHJlc3BvbnNlKTsKIAotICAgICAgICByci5tcC53cml0ZUludCgyKTsKLSAgICAgICAgcnIubXAud3JpdGVJbnQoZW5hYmxlID8gMSA6IDApOwotICAgICAgICByci5tcC53cml0ZUludChzZXJ2aWNlQ2xhc3MpOworICAgICAgICByci5tUGFyY2VsLndyaXRlSW50KDIpOworICAgICAgICByci5tUGFyY2VsLndyaXRlSW50KGVuYWJsZSA/IDEgOiAwKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZUludChzZXJ2aWNlQ2xhc3MpOwogCiAgICAgICAgIGlmIChSS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CiAgICAgICAgIFJJTFJlcXVlc3QgcnIKQEAgLTE1ODAsNiArMTYzNSw3IEBACiAgICAgICAgIHNlbmQocnIpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkCiAgICAgZ2V0QXZhaWxhYmxlTmV0d29ya3MoTWVzc2FnZSByZXNwb25zZSkgewogICAgICAgICBSSUxSZXF1ZXN0IHJyCkBAIC0xNTkxLDE4ICsxNjQ3LDE5IEBACiAgICAgICAgIHNlbmQocnIpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkCiAgICAgc2V0Q2FsbEZvcndhcmQoaW50IGFjdGlvbiwgaW50IGNmUmVhc29uLCBpbnQgc2VydmljZUNsYXNzLAogICAgICAgICAgICAgICAgIFN0cmluZyBudW1iZXIsIGludCB0aW1lU2Vjb25kcywgTWVzc2FnZSByZXNwb25zZSkgewogICAgICAgICBSSUxSZXF1ZXN0IHJyCiAgICAgICAgICAgICAgICAgPSBSSUxSZXF1ZXN0Lm9idGFpbihSSUxfUkVRVUVTVF9TRVRfQ0FMTF9GT1JXQVJELCByZXNwb25zZSk7CiAKLSAgICAgICAgcnIubXAud3JpdGVJbnQoYWN0aW9uKTsKLSAgICAgICAgcnIubXAud3JpdGVJbnQoY2ZSZWFzb24pOwotICAgICAgICByci5tcC53cml0ZUludChzZXJ2aWNlQ2xhc3MpOwotICAgICAgICByci5tcC53cml0ZUludChQaG9uZU51bWJlclV0aWxzLnRvYUZyb21TdHJpbmcobnVtYmVyKSk7Ci0gICAgICAgIHJyLm1wLndyaXRlU3RyaW5nKG51bWJlcik7Ci0gICAgICAgIHJyLm1wLndyaXRlSW50ICh0aW1lU2Vjb25kcyk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQoYWN0aW9uKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZUludChjZlJlYXNvbik7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQoc2VydmljZUNsYXNzKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZUludChQaG9uZU51bWJlclV0aWxzLnRvYUZyb21TdHJpbmcobnVtYmVyKSk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVTdHJpbmcobnVtYmVyKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZUludCAodGltZVNlY29uZHMpOwogCiAgICAgICAgIGlmIChSSUxKX0xPR0QpIHJpbGpMb2cocnIuc2VyaWFsU3RyaW5nKCkgKyAiPiAiICsgcmVxdWVzdFRvU3RyaW5nKHJyLm1SZXF1ZXN0KQogICAgICAgICAgICAgICAgICAgICArICIgIiArIGFjdGlvbiArICIgIiArIGNmUmVhc29uICsgIiAiICsgc2VydmljZUNsYXNzCkBAIC0xNjExLDE4ICsxNjY4LDE5IEBACiAgICAgICAgIHNlbmQocnIpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkCiAgICAgcXVlcnlDYWxsRm9yd2FyZFN0YXR1cyhpbnQgY2ZSZWFzb24sIGludCBzZXJ2aWNlQ2xhc3MsCiAgICAgICAgICAgICAgICAgU3RyaW5nIG51bWJlciwgTWVzc2FnZSByZXNwb25zZSkgewogICAgICAgICBSSUxSZXF1ZXN0IHJyCiAgICAgICAgICAgICA9IFJJTFJlcXVlc3Qub2J0YWluKFJJTF9SRVFVRVNUX1FVRVJZX0NBTExfRk9SV0FSRF9TVEFUVVMsIHJlc3BvbnNlKTsKIAotICAgICAgICByci5tcC53cml0ZUludCgyKTsgLy8gMiBpcyBmb3IgcXVlcnkgYWN0aW9uLCBub3QgaW4gdXNlZCBhbnl3YXkKLSAgICAgICAgcnIubXAud3JpdGVJbnQoY2ZSZWFzb24pOwotICAgICAgICByci5tcC53cml0ZUludChzZXJ2aWNlQ2xhc3MpOwotICAgICAgICByci5tcC53cml0ZUludChQaG9uZU51bWJlclV0aWxzLnRvYUZyb21TdHJpbmcobnVtYmVyKSk7Ci0gICAgICAgIHJyLm1wLndyaXRlU3RyaW5nKG51bWJlcik7Ci0gICAgICAgIHJyLm1wLndyaXRlSW50ICgwKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZUludCgyKTsgLy8gMiBpcyBmb3IgcXVlcnkgYWN0aW9uLCBub3QgaW4gdXNlZCBhbnl3YXkKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZUludChjZlJlYXNvbik7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQoc2VydmljZUNsYXNzKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZUludChQaG9uZU51bWJlclV0aWxzLnRvYUZyb21TdHJpbmcobnVtYmVyKSk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVTdHJpbmcobnVtYmVyKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZUludCAoMCk7CiAKICAgICAgICAgaWYgKFJJTEpfTE9HRCkgcmlsakxvZyhyci5zZXJpYWxTdHJpbmcoKSArICI+ICIgKyByZXF1ZXN0VG9TdHJpbmcocnIubVJlcXVlc3QpCiAgICAgICAgICAgICAgICAgKyAiICIgKyBjZlJlYXNvbiArICIgIiArIHNlcnZpY2VDbGFzcyk7CkBAIC0xNjMwLDYgKzE2ODgsNyBAQAogICAgICAgICBzZW5kKHJyKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZAogICAgIHF1ZXJ5Q0xJUChNZXNzYWdlIHJlc3BvbnNlKSB7CiAgICAgICAgIFJJTFJlcXVlc3QgcnIKQEAgLTE2NDEsNiArMTcwMCw3IEBACiAgICAgfQogCiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZAogICAgIGdldEJhc2ViYW5kVmVyc2lvbiAoTWVzc2FnZSByZXNwb25zZSkgewogICAgICAgICBSSUxSZXF1ZXN0IHJyCkBAIC0xNjY5LDEzICsxNzI5LDEzIEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyAiICIgKyBhcHBJZCArICJdIik7CiAKICAgICAgICAgLy8gY291bnQgc3RyaW5ncwotICAgICAgICByci5tcC53cml0ZUludCg0KTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZUludCg0KTsKIAotICAgICAgICByci5tcC53cml0ZVN0cmluZyhmYWNpbGl0eSk7Ci0gICAgICAgIHJyLm1wLndyaXRlU3RyaW5nKHBhc3N3b3JkKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZVN0cmluZyhmYWNpbGl0eSk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVTdHJpbmcocGFzc3dvcmQpOwogCi0gICAgICAgIHJyLm1wLndyaXRlU3RyaW5nKEludGVnZXIudG9TdHJpbmcoc2VydmljZUNsYXNzKSk7Ci0gICAgICAgIHJyLm1wLndyaXRlU3RyaW5nKGFwcElkKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZVN0cmluZyhJbnRlZ2VyLnRvU3RyaW5nKHNlcnZpY2VDbGFzcykpOworICAgICAgICByci5tUGFyY2VsLndyaXRlU3RyaW5nKGFwcElkKTsKIAogICAgICAgICBzZW5kKHJyKTsKICAgICB9CkBAIC0xNzAwLDE5ICsxNzYwLDIwIEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgIiAiICsgc2VydmljZUNsYXNzICsgIiAiICsgYXBwSWQgKyAiXSIpOwogCiAgICAgICAgIC8vIGNvdW50IHN0cmluZ3MKLSAgICAgICAgcnIubXAud3JpdGVJbnQoNSk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQoNSk7CiAKLSAgICAgICAgcnIubXAud3JpdGVTdHJpbmcoZmFjaWxpdHkpOworICAgICAgICByci5tUGFyY2VsLndyaXRlU3RyaW5nKGZhY2lsaXR5KTsKICAgICAgICAgbG9ja1N0cmluZyA9IChsb2NrU3RhdGUpPyIxIjoiMCI7Ci0gICAgICAgIHJyLm1wLndyaXRlU3RyaW5nKGxvY2tTdHJpbmcpOwotICAgICAgICByci5tcC53cml0ZVN0cmluZyhwYXNzd29yZCk7Ci0gICAgICAgIHJyLm1wLndyaXRlU3RyaW5nKEludGVnZXIudG9TdHJpbmcoc2VydmljZUNsYXNzKSk7Ci0gICAgICAgIHJyLm1wLndyaXRlU3RyaW5nKGFwcElkKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZVN0cmluZyhsb2NrU3RyaW5nKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZVN0cmluZyhwYXNzd29yZCk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVTdHJpbmcoSW50ZWdlci50b1N0cmluZyhzZXJ2aWNlQ2xhc3MpKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZVN0cmluZyhhcHBJZCk7CiAKICAgICAgICAgc2VuZChycik7CiAKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZAogICAgIHNlbmRVU1NEIChTdHJpbmcgdXNzZFN0cmluZywgTWVzc2FnZSByZXNwb25zZSkgewogICAgICAgICBSSUxSZXF1ZXN0IHJyCkBAIC0xNzI1LDEyICsxNzg2LDEzIEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgIiAiICsgbG9nVXNzZFN0cmluZyk7CiAgICAgICAgIH0KIAotICAgICAgICByci5tcC53cml0ZVN0cmluZyh1c3NkU3RyaW5nKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZVN0cmluZyh1c3NkU3RyaW5nKTsKIAogICAgICAgICBzZW5kKHJyKTsKICAgICB9CiAKICAgICAvLyBpbmhlcml0ZWQgamF2YWRvYyBzdWZmaWNlcworICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIGNhbmNlbFBlbmRpbmdVc3NkIChNZXNzYWdlIHJlc3BvbnNlKSB7CiAgICAgICAgIFJJTFJlcXVlc3QgcnIKICAgICAgICAgICAgICAgICA9IFJJTFJlcXVl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cocnIubVJlcXVlc3QpCiAgICAgICAgICAgICAgICAgKyAnWycgKyBjb250ZW50cyArICddJyk7CiAKLSAgICAgICAgcnIubXAud3JpdGVTdHJpbmcoY29udGVudHMpOworICAgICAgICByci5tUGFyY2VsLndyaXRlU3RyaW5nKGNvbnRlbnRzKTsKICAgICAgICAgc2VuZChycik7CiAgICAgfQogCiAgICAgLyoqCiAgICAgICoge0Bpbmhlcml0RG9jfQogICAgICAqLworICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIGhhbmRsZUNhbGxTZXR1cFJlcXVlc3RGcm9tU2ltKAogICAgICAgICAgICAgYm9vbGVhbiBhY2NlcHQsIE1lc3NhZ2UgcmVzcG9uc2UpIHsKIApAQCAtMTg2NSw3ICsxOTM2LDcgQEAKIAogICAgICAgICBpbnRbXSBwYXJhbSA9IG5ldyBpbnRbMV07CiAgICAgICAgIHBhcmFtWzBdID0gYWNjZXB0ID8gMSA6IDA7Ci0gICAgICAgIHJyLm1wLndyaXRlSW50QXJyYXkocGFyYW0pOworICAgICAgICByci5tUGFyY2VsLndyaXRlSW50QXJyYXkocGFyYW0pOwogICAgICAgICBzZW5kKHJyKTsKICAgICB9CiAKQEAgLTE4ODIsMTIgKzE5NTMsMTMgQEAKICAgICAvKioKICAgICAgKiB7QGluaGVyaXREb2N9CiAgICAgICovCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgc2V0UHJlZmVycmVkTmV0d29ya1R5cGUoaW50IG5ldHdvcmtUeXBlICwgTWVzc2FnZSByZXNwb25zZSkgewogICAgICAgICBSSUxSZXF1ZXN0IHJyID0gUklMUmVxdWVzdC5vYnRhaW4oCiAgICAgICAgICAgICAgICAgUklMQ29uc3RhbnRzLlJJTF9SRVFVRVNUX1NFVF9QUkVGRVJSRURfTkVUV09SS19UWVBFLCByZXNwb25zZSk7CiAKLSAgICAgICAgcnIubXAud3JpdGVJbnQoMSk7Ci0gICAgICAgIHJyLm1wLndyaXRlSW50KG5ld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AgICAgICAgIHJyLm1wLndyaXRlSW50KGNvbmZpZ1tpXS5nZXRUb1NlcnZpY2VJZCgpKTsKLSAgICAgICAgICAgIHJyLm1wLndyaXRlSW50KGNvbmZpZ1tpXS5nZXRGcm9tQ29kZVNjaGVtZSgpKTsKLSAgICAgICAgICAgIHJyLm1wLndyaXRlSW50KGNvbmZpZ1tpXS5nZXRUb0NvZGVTY2hlbWUoKSk7Ci0gICAgICAgICAgICByci5tcC53cml0ZUludChjb25maWdbaV0uaXNTZWxlY3RlZCgpID8gMSA6IDApOworICAgICAgICAgICAgcnIubVBhcmNlbC53cml0ZUludChjb25maWdbaV0uZ2V0RnJvbVNlcnZpY2VJZCgpKTsKKyAgICAgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQoY29uZmlnW2ldLmdldFRvU2VydmljZUlkKCkpOworICAgICAgICAgICAgcnIubVBhcmNlbC53cml0ZUludChjb25maWdbaV0uZ2V0RnJvbUNvZGVTY2hlbWUoKSk7CisgICAgICAgICAgICByci5tUGFyY2VsLndyaXRlSW50KGNvbmZpZ1tpXS5nZXRUb0NvZGVTY2hlbWUoKSk7CisgICAgICAgICAgICByci5tUGFyY2VsLndyaXRlSW50KGNvbmZpZ1tpXS5pc1NlbGVjdGVkKCkgPyAxIDogMCk7CiAgICAgICAgIH0KIAogICAgICAgICBpZiAoUklMSl9MT0dEKSB7CkBAIC0yMDI4LDExICsyMTA5LDEyIEBACiAgICAgLyoqCiAgICAgICoge0Bpbmhlcml0RG9jfQogICAgICAqLworICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHNldEdzbUJyb2FkY2FzdEFjdGl2YXRpb24oYm9vbGVhbiBhY3RpdmF0ZSwgTWVzc2FnZSByZXNwb25zZSkgewogICAgICAgICBSSUxSZXF1ZXN0IHJyID0gUklMUmVxdWVzdC5vYnRhaW4oUklMX1JFUVVFU1RfR1NNX0JST0FEQ0FTVF9BQ1RJVkFUSU9OLCByZXNwb25zZSk7CiAKLSAgICAgICAgcnIubXAud3JpdGVJbnQoMSk7Ci0gICAgICAgIHJyLm1wLndyaXRlSW50KGFjdGl2YXRlID8gMCA6IDEpOworICAgICAgICByci5tUGFyY2VsLndyaXRlSW50KDEpOworICAgICAgICByci5tUGFyY2VsLndyaXRlSW50KGFjdGl2YXRlID8gMCA6IDEpOwogCiAgICAgICAgIGlmIChSSUxKX0xPR0QpIHJpbGpMb2cocnIuc2VyaWFsU3RyaW5nKCkgKyAiPiAiICsgcmVxdWVzdFRvU3RyaW5nKHJyLm1SZXF1ZXN0KSk7CiAKQEAgLTIwNDMsOCArMjEyNSw4IEBACiAKICAgICBwcml2YXRlIHZvaWQgc2VuZFNjcmVlblN0YXRlKGJvb2xlYW4gb24pIHsKICAgICAgICAgUklMUmVxdWVzdCByciA9IFJJTFJlcXVlc3Qub2J0YWluKFJJTF9SRVFVRVNUX1NDUkVFTl9TVEFURSwgbnVsbCk7Ci0gICAgICAgIHJyLm1wLndyaXRlSW50KDEpOwotICAgICAgICByci5tcC53cml0ZUludChvbiA/IDEgOiAwKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZUludCgxKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZUludChvbiA/IDEgOiAwKTsKIAogICAgICAgICBpZiAoUklMSl9MT0dEKSByaWxqTG9nKHJyLnNlcmlhbFN0cmluZygpCiAgICAgICAgICAgICAgICAgKyAiPiAiICsgcmVxdWVzdFRvU3RyaW5nKHJyLm1SZXF1ZXN0KSArICI6ICIgKyBvbik7CkBAIC0yMDUyLDYgKzIxMzQsNyBAQAogICAgICAgICBzZW5kKHJyKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwcm90ZWN0ZWQgdm9pZAogICAgIG9uUmFkaW9BdmFpbGFibGUoKSB7CiAgICAgICAgIC8vIEluIGNhc2Ugc2NyZWVuIHN0YXRlIHdhcyBsb3N0IChkdWUgdG8gcHJvY2VzcyBjcmFzaCksCkBAIC0yMTU2LDcgKzIyMzksNyBAQAogICAgICAgICBzeW5jaHJvbml6ZWQgKG1SZXF1ZXN0TGlzdCkgewogICAgICAgICAgICAgaW50IGNvdW50ID0gbVJlcXVlc3RMaXN0LnNpemUoKTsKICAgICAgICAgICAgIGlmIChSSUxKX0xPR0QgJiYgbG9nZ2FibGUpIHsKLSAgICAgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgIldBS0VfTE9DS19USU1FT1VUICIgKworICAgICAgICAgICAgICAgIFJsb2cuZChSSUxKX0xPR19UQUcsICJXQUtFX0xPQ0tfVElNRU9VVCAiICsKICAgICAgICAgICAgICAgICAgICAgICAgICIgbVJlcVBlbmRpbmc9IiArIG1SZXF1ZXN0TWVzc2FnZXNQZW5kaW5nICsKICAgICAgICAgICAgICAgICAgICAgICAgICIgbVJlcXVlc3RMaXN0PSIgKyBjb3VudCk7CiAgICAgICAgICAgICB9CkBAIC0yMTY0LDcgKzIyNDcsNyBAQAogICAgICAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBjb3VudCA7IGkrKykgewogICAgICAgICAgICAgICAgIHJyID0gbVJlcXVlc3RMaXN0LmdldChpKTsKICAgICAgICAgICAgICAgICBpZiAoUklMSl9MT0dEICYmIGxvZ2dhYmxlKSB7Ci0gICAgICAgICAgICAgICAgICAgIFJsb2cuZChMT0dfVEFHLCBpICsgIjogWyIgKyByci5tU2VyaWFsICsgIl0gIiArCisgICAgICAgICAgICAgICAgICAgIFJsb2cuZChSSUxKX0xPR19UQUcsIGkgKyAiOiBbIiArIHJyLm1TZXJpYWwgKyAiXSAiICsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0VG9TdHJpbmcocnIubVJlcXVlc3QpKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgcnIub25FcnJvcihlcnJvciwgbnVsbCk7CkBAIC0yMjA1LDcgKzIyODgsNyBAQAogICAgICAgICByciA9IGZpbmRBbmRSZW1vdmVSZXF1ZXN0RnJvbUxpc3Qoc2VyaWFsKTsKIAogICAgICAgICBpZiAocnIgPT0gbnVsbCkgewotICAgICAgICAgICAgUmxvZy53KExPR19UQUcsICJVbmV4cGVjdGVkIHNvbGljaXRlZCByZXNwb25zZSEgc246ICIKKyAgICAgICAgICAgIFJsb2cudyhSSUxKX0xPR19UQUcsICJVbmV4cGVjdGVkIHNvbGljaXRlZCByZXNwb25zZSEgc246ICIKICAgICAgICAgICAgICAgICAgICAgICAgICAgICArIHNlcmlhbCArICIgZXJyb3I6ICIgKyBlcnJvcik7CiAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgIH0KQEAgLTIzNDMsNyArMjQyNiw3IEBACiAgICAgICAgICAgICB9fSBjYXRjaCAoVGhyb3dhYmxlIHRyKSB7CiAgICAgICAgICAgICAgICAgLy8gRXhjZXB0aW9ucyBoZXJlIHVzdWFsbHkgbWVhbiBpbnZhbGlkIFJJTCByZXNwb25zZXMKIAotICAgICAgICAgICAgICAgIFJsb2cudyhMT0dfVEFHLCByci5zZXJpYWxTdHJpbmcoKSArICI8ICIKKyAgICAgICAgICAgICAgICBSbG9nLncoUklMSl9MT0dfVEFHLCByci5zZXJpYWxTdHJpbmcoKSArICI8ICIKICAgICAgICAgICAgICAgICAgICAgICAgICsgcmVxdWVzdFRvU3RyaW5nKHJyLm1SZXF1ZXN0KQogICAgICAgICAgICAgICAgICAgICAgICAgKyAiIGV4Y2VwdGlvbiwgcG9zc2libGUgaW52YWxpZCBSSUwgcmVzcG9uc2UiLCB0cik7CiAKQEAgLTI1MjMsNyArMjYwNiw3IEBACiAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IFJ1bnRpbWVFeGNlcHRpb24oIlVucmVjb2duaXplZCB1bnNvbCByZXNwb25zZTogIiArIHJlc3BvbnNlKTsKICAgICAgICAgICAgIC8vYnJlYWs7IChpbXBsaWVkKQogICAgICAgICB9fSBjYXRjaCAoVGhyb3dhYmxlIHRyKSB7Ci0gICAgICAgICAgICBSbG9nLmUoTE9HX1RBRywgIkV4Y2VwdGlvbiBwcm9jZXNzaW5nIHVuc29sIHJlc3BvbnNlOiAiICsgcmVzcG9uc2UgKworICAgICAgICAgICAgUmxvZy5lKFJJTEpfTE9HX1RBRywgIkV4Y2VwdGlvbiBwcm9jZXNzaW5nIHVuc29sIHJlc3BvbnNlOiAiICsgcmVzcG9uc2UgKwogICAgICAgICAgICAgICAgICJFeGNlcHRpb246IiArIHRyLnRvU3RyaW5nKCkpOwogICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICB9CkBAIC0yNzk0LDcgKzI4NzcsNyBAQAogICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgIGxpc3RJbmZvUmVjcyA9IChBcnJheUxpc3Q8Q2RtYUluZm9ybWF0aW9uUmVjb3Jkcz4pcmV0OwogICAgICAgICAgICAgICAgIH0gY2F0Y2ggKENsYXNzQ2FzdEV4Y2VwdGlvbiBlKSB7Ci0gICAgICAgICAgICAgICAgICAgIFJsb2cuZShMT0dfVEFHLCAiVW5leHBlY3RlZCBleGNlcHRpb24gY2FzdGluZyB0byBsaXN0SW5mb1JlY3MiLCBlKTsKKyAgICAgICAgICAgICAgICAgICAgUmxvZy5lKFJJTEpfTE9HX1RBRywgIlVuZXhwZWN0ZWQgZXhjZXB0aW9uIGNhc3RpbmcgdG8gbGlzdEluZm9SZWNzIiwgZSk7CiAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgIH0KIApAQCAtMjk3Myw3ICszMDU2LDcgQEAKIAogICAgICAgICByZXNwb25zZSA9IHAucmVhZFN0cmluZ0FycmF5KCk7CiAKLSAgICAgICAgaWYgKGZhbHNlKSB7CisgICAgICAgIGlmIChSSUxKX0xPR1YpIHsKICAgICAgICAgICAgIG51bSA9IHAucmVhZEludCgpOwogCiAgICAgICAgICAgICByZXNwb25zZSA9IG5ldyBTdHJpbmdbbnVtXTsKQEAgLTMxNjcsNyArMzI1MCw3IEBACiAgICAgICAgICAgICBkYXRhQ2Fs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A9IHAucmVhZFN0cmluZygpOwogICAgICAgICBub3RpZmljYXRpb24ubmFtZVByZXNlbnRhdGlvbiA9IG5vdGlmaWNhdGlvbi5udW1iZXJQcmVzZW50YXRpb247CiAgICAgICAgIG5vdGlmaWNhdGlvbi5pc1ByZXNlbnQgPSBwLnJlYWRJbnQoKTsKQEAgLTM2NjQsMTEgKzM3NDgsMTEgQEAKICAgICB9CiAKICAgICBwcml2YXRlIHZvaWQgcmlsakxvZyhTdHJpbmcgbXNnKSB7Ci0gICAgICAgIFJsb2cuZChMT0dfVEFHLCBtc2cpOworICAgICAgICBSbG9nLmQoUklMSl9MT0dfVEFHLCBtc2cpOwogICAgIH0KIAogICAgIHByaXZhdGUgdm9pZCByaWxqTG9ndihTdHJpbmcgbXNnKSB7Ci0gICAgICAgIFJsb2cudihMT0dfVEFHLCBtc2cpOworICAgICAgICBSbG9nLnYoUklMSl9MT0dfVEFHLCBtc2cpOwogICAgIH0KIAogICAgIHByaXZhdGUgdm9pZCB1bnNsakxvZyhpbnQgcmVzcG9uc2UpIHsKQEAgLTM2ODksNiArMzc3Myw3IEBACiAKIAogICAgIC8vICoqKioqIE1ldGhvZHMgZm9yIENETUEgc3VwcG9ydAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkCiAgICAgZ2V0RGV2aWNlSWRlbnRpdHkoTWVzc2FnZSByZXNwb25zZSkgewogICAgICAgICBSSUxSZXF1ZXN0IHJyID0gUklMUmVxdWVzdC5vYnRhaW4oUklMX1JFUVVFU1RfREVWSUNFX0lERU5USVRZLCByZXNwb25zZSk7CkBAIC0zNjk4LDYgKzM3ODMsNyBAQAogICAgICAgICBzZW5kKHJyKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZAogICAgIGdldENETUFTdWJzY3JpcHRpb24oTWVzc2FnZSByZXNwb25zZSkgewogICAgICAgICBSSUxSZXF1ZXN0IHJyID0gUklMUmVxdWVzdC5vYnRhaW4oUklMX1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AgICAgICAgICAgICAgKyAiIDogIiArIGNkbWFSb2FtaW5nVHlwZSk7CkBAIC0zNzQ0LDEyICszODMyLDEzIEBACiAgICAgLyoqCiAgICAgICoge0Bpbmhlcml0RG9jfQogICAgICAqLworICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHNldENkbWFTdWJzY3JpcHRpb25Tb3VyY2UoaW50IGNkbWFTdWJzY3JpcHRpb24gLCBNZXNzYWdlIHJlc3BvbnNlKSB7CiAgICAgICAgIFJJTFJlcXVlc3QgcnIgPSBSSUxSZXF1ZXN0Lm9idGFpbigKICAgICAgICAgICAgICAgICBSSUxDb25zdGFudHMuUklMX1JFUVVFU1RfQ0RNQV9TRVRfU1VCU0NSSVBUSU9OX1NPVVJDRSwgcmVzcG9uc2UpOwogCi0gICAgICAgIHJyLm1wLndyaXRlSW50KDEpOwotICAgICAgICByci5tcC53cml0ZUludChjZG1hU3Vic2NyaXB0aW9uKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZUludCgxKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZUludChjZG1hU3Vic2NyaXB0aW9uKTsKIAogICAgICAgICBpZiAoUklMSl9MT0dEKSByaWxqTG9nKHJyLnNlcmlhbFN0cmluZygpICsgIj4gIiArIHJlcXVlc3RUb1N0cmluZyhyci5tUmVxdWVzdCkKICAgICAgICAgICAgICAgICArICIgOiAiICsgY2RtYVN1YnNjcmlwdGlvbik7CkBAIC0zNzczLDYgKzM4NjIsNyBAQAogICAgIC8qKgogICAgICAqIHtAaW5oZXJpdERvY30KICAgICAgKi8KKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBxdWVyeVRUWU1vZGUoTWVzc2FnZSByZXNwb25zZSkgewogICAgICAgICBSSUxSZXF1ZXN0IHJyID0gUklMUmVxdWVzdC5vYnRhaW4oCiAgICAgICAgICAgICAgICAgUklMQ29uc3RhbnRzLlJJTF9SRVFVRVNUX1FVRVJZX1RUWV9NT0RFLCByZXNwb25zZSk7CkBAIC0zNzg1LDEyICszODc1LDEzIEBACiAgICAgLyoqCiAgICAgICoge0Bpbmhlcml0RG9jfQogICAgICAqLworICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHNldFRUWU1vZGUoaW50IHR0eU1vZGUsIE1lc3NhZ2UgcmVzcG9uc2UpIHsKICAgICAgICAgUklMUmVxdWVzdCByciA9IFJJTFJlcXVlc3Qub2J0YWluKAogICAgICAgICAgICAgICAgIFJJTENvbnN0YW50cy5SSUxfUkVRVUVTVF9TRVRfVFRZX01PREUsIHJlc3BvbnNlKTsKIAotICAgICAgICByci5tcC53cml0ZUludCgxKTsKLSAgICAgICAgcnIubXAud3JpdGVJbnQodHR5TW9kZSk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQoMSk7CisgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQodHR5TW9kZSk7CiAKICAgICAgICAgaWYgKFJJTEpfTE9HRCkgcmlsakxvZyhyci5zZXJpYWxTdHJpbmcoKSArICI+ICIgKyByZXF1ZXN0VG9TdHJpbmcocnIubVJlcXVlc3QpCiAgICAgICAgICAgICAgICAgKyAiIDogIiArIHR0eU1vZGUpOwpAQCAtMzgwMSwxMSArMzg5MiwxMiBAQAogICAgIC8qKgogICAgICAqIHtAaW5oZXJpdERvY30KICAgICAgKi8KKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZAogICAgIHNlbmRDRE1BRmVhdHVyZUNvZGUoU3RyaW5nIEZlYXR1cmVDb2RlLCBNZXNzYWdlIHJlc3BvbnNlKSB7CiAgICAgICAgIFJJTFJlcXVlc3QgcnIgPSBSSUxSZXF1ZXN0Lm9idGFpbihSSUxfUkVRVUVTVF9DRE1BX0ZMQVNILCByZXNwb25zZSk7CiAKLSAgICAgICAgcnIubXAud3JpdGVTdHJpbmcoRmVhdHVyZUNvZGUpOworICAgICAgICByci5tUGFyY2VsLndyaXRlU3RyaW5nKEZlYXR1cmVD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xDb25maWdzLmxlbmd0aDsgaSsrKSB7Ci0gICAgICAgICAgICByci5tcC53cml0ZUludChyaWxDb25maWdzW2ldLmdldEZyb21TZXJ2aWNlQ2F0ZWdvcnkoKSk7Ci0gICAgICAgICAgICByci5tcC53cml0ZUludChyaWxDb25maWdzW2ldLmdldExhbmd1YWdlKCkpOwotICAgICAgICAgICAgcnIubXAud3JpdGVJbnQocmlsQ29uZmlnc1tpXS5pc1NlbGVjdGVkKCkgPyAxIDogMCk7CisgICAgICAgICAgICByci5tUGFyY2VsLndyaXRlSW50KHJpbENvbmZpZ3NbaV0uZ2V0RnJvbVNlcnZpY2VDYXRlZ29yeSgpKTsKKyAgICAgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQocmlsQ29uZmlnc1tpXS5nZXRMYW5ndWFnZSgpKTsKKyAgICAgICAgICAgIHJyLm1QYXJjZWwud3JpdGVJbnQocmlsQ29uZmlnc1tpXS5pc1NlbGVjdGVkKCkgPyAxIDogMCk7CiAgICAgICAgIH0KIAogICAgICAgICBpZiAoUklMSl9MT0dEKSB7CkBAIC0zODUzLDExICszOTQ3LDEyIEBACiAgICAgICAgIHNlbmQocnIpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHNldENkbWFCcm9hZGNhc3RBY3RpdmF0aW9uKGJvb2xlYW4gYWN0aXZhdGUsIE1lc3NhZ2UgcmVzcG9uc2UpIHsKICAgICAgICAgUklMUmVxdWVzdCByciA9IFJJTFJlcXVlc3Qub2J0YWluKFJJTF9SRVFVRVNUX0NETUFfQlJPQURDQVNUX0FDVElWQVRJT04sIHJlc3BvbnNlKTsKIAotICAgICAgICByci5tcC53cml0ZUludCgxKTsKLSAgICAgICAgcnIubXAud3JpdGVJbnQoYWN0aXZhdGUgPyAwIDoxKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZUludCgxKTsKKyAgICAgICAgcnIubVBhcmNlbC53cml0ZUludChhY3RpdmF0ZSA/IDAgO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5TWFuYWdlciI7CiAgICAgc3RhdGljIHB1YmxpYyBmaW5hbCBib29sZWFuIERCRyA9IHRydWU7CiAgICAgc3RhdGljIHB1YmxpYyBmaW5hbCBib29sZWFuIFZEQkcgPSBmYWxzZTsKIApAQCAtMTA2LDcgKzEwNiw3IEBACiAgICAgcHJpdmF0ZSBpbnQgbVJldHJ5Q291bnQ7CiAKICAgICAvKiogUmFuZG9tIG51bWJlciBnZW5lcmF0b3IgKi8KLSAgICBwcml2YXRlIFJhbmRvbSBybmcgPSBuZXcgUmFuZG9tKCk7CisgICAgcHJpdmF0ZSBSYW5kb20gbVJuZyA9IG5ldyBSYW5kb20oKTsKIAogICAgIHByaXZhdGUgU3RyaW5nIG1Db25maWc7CiAKQEAgLTExNSw2ICsxMTUsNyBAQAogICAgICAgICBpZiAoVkRCRykgbG9nKCJjb25zdHJ1Y3RvciIpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdHJpbmcgdG9TdHJpbmcoKSB7CiAgICAgICAgIFN0cmluZyByZXQgPSAiUmV0cnlNYW5hZ2VyOiBmb3JldmVyPSIgKyBtUmV0cnlGb3JldmVyICsgIiwgbWF4UmV0cnk9IiArIG1NYXhSZXRyeUNvdW50ICsKICAgICAgICAgICAgICAgICAiLCByZXRyeT0iICsgbVJldHJ5Q291bnQgKyAiLFxuICAgICIgKyBtQ29uZmlnOwpAQCAtNDAwLDcgKzQwMSw3IEBACiAgICAgICAgIGlmIChyYW5kb21UaW1lID09IDApIHsKICAgICAgICAgICAgIHJldHVybiAwOwogICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgcmV0dXJuIHJuZy5uZXh0SW50KHJhbmRvbVRpbWUpOworICAgICAgICAgICAgcmV0dXJuIG1SbmcubmV4dEludChyYW5kb21UaW1lKTsKICAgICAgICAgfQogICAgIH0KIApkaWZmIC0tZ2l0IGEvc3JjL2phdmEvY29tL2FuZHJvaWQvaW50ZXJuYWwvdGVsZXBob255L1NNU0Rp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B7Ci0gICAgICAgICAgICAgICAgUmxvZy5kKFRBRywgIlNNUyBzZW5kIGNvbXBsZXRlLiBCcm9hZGNhc3RpbmcgIgotICAgICAgICAgICAgICAgICAgICAgICAgKyAiaW50ZW50OiAiICsgc2VudEludGVudCk7Ci0gICAgICAgICAgICB9CisgICAgICAgICAgICBpZiAoREJHKSBSbG9nLmQoVEFHLCAiU01TIHNlbmQgY29tcGxldGUuIEJyb2FkY2FzdGluZyBpbnRlbnQ6ICIgKyBzZW50SW50ZW50KTsKIAogICAgICAgICAgICAgaWYgKHRyYWNrZXIubURlbGl2ZXJ5SW50ZW50ICE9IG51bGwpIHsKICAgICAgICAgICAgICAgICAvLyBFeHBlY3RpbmcgYSBzdGF0dXMgcmVwb3J0LiAgQWRkIGl0IHRvIHRoZSBsaXN0LgotICAgICAgICAgICAgICAgIGludCBtZXNzYWdlUmVmID0gKChTbXNSZXNwb25zZSlhci5yZXN1bHQpLm1lc3NhZ2VSZWY7CisgICAgICAgICAgICAgICAgaW50IG1lc3NhZ2VSZWYgPSAoKFNtc1Jlc3BvbnNlKWFyLnJlc3VsdCkubU1lc3NhZ2VSZWY7CiAgICAgICAgICAgICAgICAgdHJhY2tlci5tTWVzc2FnZVJlZiA9IG1lc3NhZ2VSZWY7CiAgICAgICAgICAgICAgICAgZGVsaXZlcnlQZW5kaW5nTGlzdC5hZGQodHJhY2tlcik7CiAgICAgICAgICAgICB9CkBAIC00NTMsOSArNDU0LDcgQEAKICAgICAgICAgICAgICAgICB9IGNhdGNoIChDYW5jZWxlZEV4Y2VwdGlvbiBleCkge30KICAgICAgICAgICAgIH0KICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgIGlmIChmYWxzZSkgewotICAgICAgICAgICAgICAgIFJsb2cuZChUQUcsICJTTVMgc2VuZCBmYWlsZWQiKTsKLSAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGlmIChEQkcpIFJsb2cuZChUQUcsICJTTVMgc2VuZCBmYWlsZWQiKTsKIAogICAgICAgICAgICAgaW50IHNzID0gbVBob25lLmdldFNlcnZpY2VTdGF0ZSgpLmdldFN0YXRlKCk7CiAKQEAgLTQ4Niw3ICs0ODUsNyBAQAogICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgIEludGVudCBmaWxsSW4gPSBuZXcgSW50ZW50KCk7CiAgICAgICAgICAgICAgICAgICAgIGlmIChhci5yZXN1bHQgIT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICAgICAgZmlsbEluLnB1dEV4dHJhKCJlcnJvckNvZGUiLCAoKFNtc1Jlc3BvbnNlKWFyLnJlc3VsdCkuZXJyb3JDb2RlKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGZpbGxJbi5wdXRFeHRyYSgiZXJyb3JDb2RlIiwgKChTbXNSZXNwb25zZSlhci5yZXN1bHQpLm1FcnJvckNvZGUpOwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIGlmIChtUmVtYWluaW5nTWVzc2FnZXMgPiAtMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgbVJlbWFpbmluZ01lc3NhZ2VzLS07CkBAIC01MjcsNyArNTI2LDcgQEAKICAgICAgKiBEaXNwYXRjaGVzIGFuIGluY29taW5nIFNNUyBtZXNzYWdlcy4KICAgICAgKgogICAgICAqIEBwYXJhbSBzbXMgdGhlIGluY29taW5nIG1lc3NhZ2UgZnJvbSB0aGUgcGhvbmUKLSAgICAgKiBAcmV0dXJuIGEgcmVzdWx0IGNvZGUgZnJvbSB7QGxpbmsgVGVsZXBob255LlNtcy5JbnRlbnRzfSwgb3IKKyAgICAgKiBAcmV0dXJuIGEgcmVzdWx0IGNvZGUgZnJvbSB7QGxpbmsgYW5kcm9pZC5wcm92aWRlci5UZWxlcGhvbnkuU21zLkludGVudHN9LCBvcgogICAgICAqICAgICAgICAge0BsaW5rIEFjdGl2aXR5I1JFU1VMVF9PS30gaWYgdGhlIG1lc3NhZ2UgaGFzIGJ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0dXJuIG51bGw7CiAgICAgICAgIH0KIAotICAgICAgICByZXR1cm4gb3JpZ2luYXRpbmdBZGRyZXNzLmdldEFkZHJlc3NTdHJpbmcoKTsKKyAgICAgICAgcmV0dXJuIG1PcmlnaW5hdGluZ0FkZHJlc3MuZ2V0QWRkcmVzc1N0cmluZygpOwogICAgIH0KIAogICAgIC8qKgpAQCAtMTI1LDggKzEyNCw4IEBACiAgICAgICogdW5hdmFpbGFibGUuCiAgICAgICovCiAgICAgcHVibGljIFN0cmluZyBnZXREaXNwbGF5T3JpZ2luYXRpbmdBZGRyZXNzKCkgewotICAgICAgICBpZiAoaXNFbWFpbCkgewotICAgICAgICAgICAgcmV0dXJuIGVtYWlsRnJvbTsKKyAgICAgICAgaWYgKG1Jc0VtYWlsKSB7CisgICAgICAgICAgICByZXR1cm4gbUVtYWlsRnJvbTsKICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIHJldHVybiBnZXRPcmlnaW5hdGluZ0FkZHJlc3MoKTsKICAgICAgICAgfQpAQCAtMTM3LDcgKzEzNiw3IEBACiAgICAgICogQHJldHVybiBtZXNzYWdlIGJvZHkgaXMgdGhlcmUgaXMgb25lLCBvdGhlcndpc2UgbnVsbAogICAgICAqLwogICAgIHB1YmxpYyBTdHJpbmcgZ2V0TWVzc2FnZUJvZHkoKSB7Ci0gICAgICAgIHJldHVybiBtZXNzYWdlQm9keTsKKyAgICAgICAgcmV0dXJuIG1NZXNzYWdlQm9keTsKICAgICB9CiAKICAgICAvKioKQEAgLTE1MCw4ICsxNDksOCBAQAogICAgICAqIGFuIGVtYWlsIGdhdGV3YXkuIFJldHVybnMgbnVsbCBpZiBtZXNzYWdlIGJvZHkgdW5hdmFpbGFibGUuCiAgICAgICovCiAgICAgcHVibGljIFN0cmluZyBnZXREaXNwbGF5TWVzc2FnZUJvZHkoKSB7Ci0gICAgICAgIGlmIChpc0VtYWlsKSB7Ci0gICAgICAgICAgICByZXR1cm4gZW1haWxCb2R5OworICAgICAgICBpZiAobUlzRW1haWwpIHsKKyAgICAgICAgICAgIHJldHVybiBtRW1haWxCb2R5OwogICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgcmV0dXJuIGdldE1lc3NhZ2VCb2R5KCk7CiAgICAgICAgIH0KQEAgLTE2MiwxNCArMTYxLDE0IEBACiAgICAgICogaWYgbm90IHByZXNlbnQKICAgICAgKi8KICAgICBwdWJsaWMgU3RyaW5nIGdldFBzZXVkb1N1YmplY3QoKSB7Ci0gICAgICAgIHJldHVybiBwc2V1ZG9TdWJqZWN0ID09IG51bGwgPyAiIiA6IHBzZXVkb1N1YmplY3Q7CisgICAgICAgIHJldHVybiBtUHNldWRvU3ViamVjdCA9PSBudWxsID8gIiIgOiBtUHNldWRvU3ViamVjdDsKICAgICB9CiAKICAgICAvKioKICAgICAgKiBSZXR1cm5zIHRoZSBzZXJ2aWNlIGNlbnRyZSB0aW1lc3RhbXAgaW4gY3VycmVudFRpbWVNaWxsaXMoKSBmb3JtYXQKICAgICAgKi8KICAgICBwdWJsaWMgbG9uZyBnZXRUaW1lc3RhbXBNaWxsaXMoKSB7Ci0gICAgICAgIHJldHVybiBzY1RpbWVNaWxsaXM7CisgICAgICAgIHJldHVybiBtU2NUaW1lTWlsbGlzOwogICAgIH0KIAogICAgIC8qKgpAQCAtMTc5LDcgKzE3OCw3IEBACiAgICAgICogICAgICAgICBzZW5kZXIgLyBzdWJqZWN0IC8gcGFyc2VkIGJvZHkgYXJlIGF2YWlsYWJsZQogICAgICAqLwogICAgIHB1YmxpYyBib29sZWFuIGlzRW1haWwoKSB7Ci0gICAgICAgIHJldHVybiBpc0VtYWlsOworICAgICAgICByZXR1cm4gbUlzRW1haWw7CiAgICAgfQogCiAgICAgLyoqCkBAIC0xODcsNyArMTg2LDcgQEAKICAgICAgKiAgICAgICAgIG51bGwgb3RoZXJ3aXNlCiAgICAgICovCiAgICAgcHVibGljIFN0cmluZyBnZXRFbWFpbEJvZHkoKSB7Ci0gICAgICAgIHJldHVybiBlbWFpbEJvZHk7CisgICAgICAgIHJldHVybiBtRW1haWxCb2R5OwogICAgIH0KIAogICAgIC8qKgpAQCAtMTk1LDcgKzE5NCw3IEBACiAgICAgICogICAgICAgICB0aGUgZ2F0ZXdheS4gbnVsbCBvdGhlcndpc2UKICAgICAgKi8KICAgICBwdWJsaWMgU3RyaW5nIGdldEVtYWlsRnJvbSgpIHsKLSAgICAgICAgcmV0dXJuIGVtYWlsRnJvbTsKKyAgICAgICAgcmV0dXJuIG1FbWFpbEZyb207CiAgICAgfQogCiAgICAgLyoqCkBAIC0yNDAsNyArMjM5LDcgQEAKICAgICAgKiBwcmVzZW50LgogICAgICAqLwogICAgIHB1YmxpYyBieXRlW10gZ2V0VXNlckRhdGEoKSB7Ci0gICAgICAgIHJldHVybiB1c2VyRGF0YTsKKyAgICAgICAgcmV0dXJuIG1Vc2VyRGF0YTsKICAgICB9CiAKICAgICAvKioKQEAgLTI0OSw3ICsyNDgsNyBAQAogICAgICAqIHtAaGlkZX0KICAgICAgKi8KICAgICBwdWJsaWMgU21zSGVhZGVyIGdldFVzZXJEYXRhSGVhZGVyKCkgewotICAgICAgICByZXR1cm4gdXNlckRhdGFIZWFkZXI7CisgICAgICAgIHJldHVybiBtVXNlckRhdGFIZWFkZXI7CiAgICAgfQogCiAgICAgLyoqCkBAIC0zMDAsNyArMjk5LDcgQEAKICAgICAgKiAgICAgICAgIFNtc01hbmFnZXIuU1RBVFVTX09OX0lDQ19VTlNFTlQKICAgICAgKi8KICAgICBwdWJsaWMgaW50IGdldFN0YXR1c09uSWNjKCkgewotICAgICAgICByZXR1cm4gc3RhdHVzT25JY2M7CisgICAgICAgIHJldHVybiBtU3RhdHVzT25JY2M7CiAgICAgfQogCiAgICAgLyoqCkBAIC0zMDksMTMgKzMwOCwxMyBAQAogICAgICAqICAgICAgICAgU21zTWVzc2FnZSB3YXMgbm90IGNyZWF0ZWQgZnJvbSBhIElDQyBTTVMgRUYgcmVjb3JkLgogICAgICAqLwogICAgIH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worICAgICAgICBtQ2kudW5TZXRPbkljY1Ntc0Z1bGwodGhpcyk7CisgICAgICAgIG1DaS51bnJlZ2lzdGVyRm9yT24odGhpcyk7CiAgICAgICAgIG1Db250ZXh0LnVucmVnaXN0ZXJSZWNlaXZlcihtUmVzdWx0UmVjZWl2ZXIpOwogICAgIH0KIApAQCAtMTE4LDcgKzExOCw3IEBACiAgICAgICAgICAgICAgICAgaWYgKG1SZXBvcnRNZW1vcnlTdGF0dXNQZW5kaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgIFJsb2cudihUQUcsICJTZW5kaW5nIHBlbmRpbmcgbWVtb3J5IHN0YXR1cyByZXBvcnQgOiBtU3RvcmFnZUF2YWlsYWJsZSA9ICIKICAgICAgICAgICAgICAgICAgICAgICAgICAgICArIG1TdG9yYWdlQXZhaWxhYmxlKTsKLSAgICAgICAgICAgICAgICAgICAgbUNtLnJlcG9ydFNtc01lbW9yeVN0YXR1cyhtU3RvcmFnZUF2YWlsYWJsZSwKKyAgICAgICAgICAgICAgICAgICAgbUNpLnJlcG9ydFNtc01lbW9yeVN0YXR1cyhtU3RvcmFnZUF2YWlsYWJsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX1JFUE9SVF9NRU1PUllfU1RBVFVTX0RPTkUpKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgYnJlYWs7CkBAIC0xNTIsMTAgKzE1MiwxMCBAQAogICAgICAgICBwdWJsaWMgdm9pZCBvblJlY2VpdmUoQ29udGV4dCBjb250ZXh0LCBJbnRlbnQgaW50ZW50KSB7CiAgICAgICAgICAgICBpZiAoaW50ZW50LmdldEFjdGlvbigpLmVxdWFscyhJbnRlbnQuQUNUSU9OX0RFVklDRV9TVE9SQUdFX0ZVTEwpKSB7CiAgICAgICAgICAgICAgICAgbVN0b3JhZ2VBdmFpbGFibGUgPSBmYWxzZTsKLSAgICAgICAgICAgICAgICBtQ20ucmVwb3J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AgdGhpcy51dXNUeXBlID0gVVVTX1RZUEUxX0lNUExJQ0lUOwotICAgICAgICB0aGlzLnV1c0RjcyA9IFVVU19EQ1NfSUE1YzsKLSAgICAgICAgdGhpcy51dXNEYXRhID0gbnVsbDsKKyAgICAgICAgbVV1c1R5cGUgPSBVVVNfVFlQRTFfSU1QTElDSVQ7CisgICAgICAgIG1VdXNEY3MgPSBVVVNfRENTX0lBNWM7CisgICAgICAgIG1VdXNEYXRhID0gbnVsbDsKICAgICB9CiAKICAgICBwdWJsaWMgVVVTSW5mbyhpbnQgdXVzVHlwZSwgaW50IHV1c0RjcywgYnl0ZVtdIHV1c0RhdGEpIHsKLSAgICAgICAgdGhpcy51dXNUeXBlID0gdXVzVHlwZTsKLSAgICAgICAgdGhpcy51dXNEY3MgPSB1dXNEY3M7Ci0gICAgICAgIHRoaXMudXVzRGF0YSA9IHV1c0RhdGE7CisgICAgICAgIG1VdXNUeXBlID0gdXVzVHlwZTsKKyAgICAgICAgbVV1c0RjcyA9IHV1c0RjczsKKyAgICAgICAgbVV1c0RhdGEgPSB1dXNEYXRhOwogICAgIH0KIAogICAgIHB1YmxpYyBpbnQgZ2V0RGNzKCkgewotICAgICAgICByZXR1cm4gdXVzRGNzOworICAgICAgICByZXR1cm4gbVV1c0RjczsKICAgICB9CiAKICAgICBwdWJsaWMgdm9pZCBzZXREY3MoaW50IHV1c0RjcykgewotICAgICAgICB0aGlzLnV1c0RjcyA9IHV1c0RjczsKKyAgICAgICAgbVV1c0RjcyA9IHV1c0RjczsKICAgICB9CiAKICAgICBwdWJsaWMgaW50IGdldFR5cGUoKSB7Ci0gICAgICAgIHJldHVybiB1dXNUeXBlOworICAgICAgICByZXR1cm4gbVV1c1R5cGU7CiAgICAgfQogCiAgICAgcHVibGljIHZvaWQgc2V0VHlwZShpbnQgdXVzVHlwZSkgewotICAgICAgICB0aGlzLnV1c1R5cGUgPSB1dXNUeXBlOworICAgICAgICBtVXVzVHlwZSA9IHV1c1R5cGU7CiAg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nROYW1lIG5hbWUsIElCaW5kZXIgc2VydmljZSkgewogICAgICAgICAgICAgbVdhcFB1c2hNYW4gPSBJV2FwUHVzaE1hbmFnZXIuU3R1Yi5hc0ludGVyZmFjZShzZXJ2aWNlKTsKLSAgICAgICAgICAgIGlmIChmYWxzZSkgUmxvZy52KExPR19UQUcsICJ3YXBwdXNoIG1hbmFnZXIgY29ubmVjdGVkIHRvICIgKworICAgICAgICAgICAgaWYgKERCRykgUmxvZy52KExPR19UQUcsICJ3YXBwdXNoIG1hbmFnZXIgY29ubmVjdGVkIHRvICIgKwogICAgICAgICAgICAgICAgICAgICBtT3duZXIuaGFzaENvZGUoKSk7CiAgICAgICAgIH0KIAorICAgICAgICBAT3ZlcnJpZGUKICAgICAgICAgcHVibGljIHZvaWQgb25TZXJ2aWNlRGlzY29ubmVjdGVkKENvbXBvbmVudE5hbWUgbmFtZSkgewogICAgICAgICAgICAgbVdhcFB1c2hNYW4gPSBudWxsOwotICAgICAgICAgICAgaWYgKGZhbHNlKSBSbG9nLnYoTE9HX1RBRywgIndhcHB1c2ggbWFuYWdlciBkaXNjb25uZWN0ZWQuIik7CisgICAgICAgICAgICBpZiAoREJHKSBSbG9nLnYoTE9HX1RBRywgIndhcHB1c2ggbWFuYWdlciBkaXNjb25uZWN0ZWQuIik7CiAgICAgICAgICAgICAvLyBEZXRhY2ggdGhlIHByZXZpb3VzIGJpbmRlcgogICAgICAgICAgICAgbU93bmVyLnVuYmluZFNlcnZpY2UobVdhcENvbm4pOwogICAgICAgICAgICAgLy8gV2FwUHVzaE1hbmFnZXIgbXVzdCBiZSBhbHdheXMgYXR0YWNoZWQuCkBAIC05Nyw2ICs5NCw3IEBACiAKICAgICAgICAgICAgIGZpbmFsIFNlcnZpY2VDb25uZWN0aW9uIHdhcFB1c2hDb25uZWN0aW9uID0gdGhpczsKICAgICAgICAgICAgIG5ldyBUaHJlYWQoKSB7CisgICAgICAgICAgICAgICAgQE92ZXJyaWRlCiAgICAgICAgICAgICAgICAgcHVibGljIHZvaWQgcnVuKCkgewogICAgICAgICAgICAgICAgICAgICB3aGlsZSAobVdhcFB1c2hNYW4gPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgbU93bmVyLmJpbmRTZXJ2aWNlKG5ldyBJbnRlbnQoSVdhcFB1c2hNYW5hZ2VyLmNsYXNzLmdldE5hbWUoKSksCkBAIC0xMDQsNyArMTAyLDcgQEAKICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVGhyZWFkLnNsZWVwKEJJTkRfUkVUUllfSU5URVJWQUwpOwogICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoSW50ZXJydXB0ZWRFeGNlcHRpb24gZSkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmYWxzZSkgUmxvZy52KExPR19UQUcsICJzbGVlcCBpbnRlcnJ1cHRlZC4iKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBSbG9nLnYoTE9HX1RBRywgInNsZWVwIGludGVycnVwdGVkLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgfQpAQCAtMTMyLDEzICsxMzAsMTMgQEAKICAgICAgKiB3YXAtMjMwLXdzcC0yMDAxMDcwNS1hIHNlY3Rpb24gOCBmb3IgZGV0YWlscyBvbiB0aGUgV0FQIFBEVSBmb3JtYXQuCiAgICAgICoKICAgICAgKiBAcGFyYW0gcGR1IFRoZSBXQVAgUERVLCBtYWRlIHVwIG9mIG9uZSBvciBtb3JlIFNNUyBQRFVzCi0gICAgICogQHJldHVybiBhIHJlc3VsdCBjb2RlIGZyb20ge0BsaW5rIFRlbGVwaG9ueS5TbXMuSW50ZW50c30sIG9yCisgICAgICogQHJldHVybiBhIHJlc3VsdCBjb2RlIGZyb20ge0BsaW5rIGFuZHJvaWQucHJvdmlkZXIuVGVsZXBob255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gaXQgd2lsbCBiZSBlbmNvZGVkIGluIG5vIG1vcmUgdGhhbiA1IG9jdGV0cy4KICAgICAgICAgICovCiAgICAgICAgIGlmIChwZHVEZWNvZGVyLmRlY29kZVVpbnR2YXJJbnRlZ2VyKGluZGV4KSA9PSBmYWxzZSkgewotICAgICAgICAgICAgaWYgKGZhbHNlKSBSbG9nLncoTE9HX1RBRywgIlJlY2VpdmVkIFBEVS4gSGVhZGVyIExlbmd0aCBlcnJvci4iKTsKKyAgICAgICAgICAgIGlmIChEQkcpIFJsb2cudyhMT0dfVEFHLCAiUmVjZWl2ZWQgUERVLiBIZWFkZXIgTGVuZ3RoIGVycm9yLiIpOwogICAgICAgICAgICAgcmV0dXJuIEludGVudHMuUkVTVUxUX1NNU19HRU5FUklDX0VSUk9SOwogICAgICAgICB9CiAgICAgICAgIGhlYWRlckxlbmd0aCA9IChpbnQpcGR1RGVjb2Rlci5nZXRWYWx1ZTMyKCk7CkBAIC0xODEsNyArMTc5LDcgQEAKICAgICAgICAgICogTGVuZ3RoID0gVWludHZhci1pbnRlZ2VyCiAgICAgICAgICAqLwogICAgICAgICBpZiAocGR1RGVjb2Rlci5kZWNvZGVDb250ZW50VHlwZShpbmRleCkgPT0gZmFsc2UpIHsKLSAgICAgICAgICAgIGlmIChmYWxzZSkgUmxvZy53KExPR19UQUcsICJSZWNlaXZlZCBQRFUuIEhlYWRlciBDb250ZW50LVR5cGUgZXJyb3IuIik7CisgICAgICAgICAgICBpZiAoREJHKSBSbG9nLncoTE9HX1RBRywgIlJlY2VpdmVkIFBEVS4gSGVhZGVyIENvbnRlbnQtVHlwZSBlcnJvci4iKTsKICAgICAgICAgICAgIHJldHVybiBJbnRlbnRzLlJFU1VMVF9TTVNfR0VORVJJQ19FUlJPUjsKICAgICAgICAgfQogCkBAIC0yMTgsMTQgKzIxNiwxNCBAQAogCiAgICAgICAgICAgICBTdHJpbmcgY29udGVudFR5cGUgPSAoKG1pbWVUeXBlID09IG51bGwpID8KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBMb25nLnRvU3RyaW5nKGJpbmFyeUNvbnRlbnRUeXBlKSA6IG1pbWVUeXBlKTsKLSAgICAgICAgICAgIGlmIChmYWxzZSkgUmxvZy52KExPR19UQUcsICJhcHBpZCBmb3VuZDogIiArIHdhcEFwcElkICsgIjoiICsgY29udGVudFR5cGUpOworICAgICAgICAgICAgaWYgKERCRykgUmxvZy52KExPR19UQUcsICJhcHBpZCBmb3VuZDogIiArIHdhcEFwcElkICsgIjoiICsgY29udGVudFR5cGUpOwogCiAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgIGJvb2xlYW4gcHJvY2Vzc0Z1cnRoZXIgPSB0cnVlOwogICAgICAgICAgICAgICAgIElXYXBQdXNoTWFuYWdlciB3YXBQdXNoTWFuID0gbVdhcENvbm4uZ2V0V2FwUHVzaE1hbmFnZXIoKTsKIAogICAgICAgICAgICAgICAgIGlmICh3YXBQdXNoTWFuID09IG51bGwpIHsKLSAgICAgICAgICAgICAgICAgICAgaWYgKGZhbHNlKSBSbG9nLncoTE9HX1RBRywgIndhcCBwdXNoIG1hbmFnZXIgbm90IGZvdW5kISIpOworICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBSbG9nLncoTE9HX1RBRywgIndhcCBwdXNoIG1hbmFnZXIgbm90IGZvdW5kISIpOwogICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgIEludGVudCBpbnRlbnQgPSBuZXcgSW50ZW50KCk7CiAgICAgICAgICAgICAgICAgICAgIGludGVudC5wdXRFeHRyYSgidHJhbnNhY3Rpb25JZCIsIHRyYW5zYWN0aW9uSWQpOwpAQCAtMjM2LDcgKzIzNCw3IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGR1RGVjb2Rlci5nZXRDb250ZW50UGFyYW1ldGVycygpKTsKIAogICAgICAgICAgICAgICAgICAgICBpbnQgcHJvY1JldCA9IHdhcFB1c2hNYW4ucHJvY2Vzc01lc3NhZ2Uod2FwQXBwSWQsIGNvbnRlbnRUeXBlLCBpbnRlbnQpOwotICAgICAgICAgICAgICAgICAgICBpZiAoZmFsc2UpIFJsb2cudihMT0dfVEFHLCAicHJvY1JldDoiICsgcHJvY1JldCk7CisgICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIFJsb2cudihMT0dfVEFHLCAicHJvY1JldDoiICsgcHJvY1JldCk7CiAgICAgICAgICAgICAgICAgICAgIGlmICgocHJvY1JldCAmIFdhcFB1c2hNYW5hZ2VyUGFyYW1zLk1FU1NBR0VfSEFORExFRCkgPiAwCiAgICAgICAgICAgICAgICAgICAgICAgICAmJiAocHJvY1JldCAmIFdhcFB1c2hNYW5hZ2VyUGFyYW1zLkZVUlRIRVJfUFJPQ0VTU0lORykgPT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgcHJvY2Vzc0Z1cnRoZXIgPSBmYWxzZTsKQEAgLTI0NiwyMiArMjQ0LDI1IEBACiAgICAgICAgICAgICAgICAgICAgIHJldHVybiBJbnRlbnRzLlJFU1VMVF9TTVNfSEFORExFRDsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9IGNhdGNoIChSZW1vdGVFeGNlcHRpb24gZSkgewotICAgICAgICAgICAgICAgIGlmIChmYWxzZSkgUmxvZy53KExPR19UQUcsICJyZW1vdGUgZnVuYyBmYWlsZWQuLi4iKTsKKyAgICAgICAgICAgICAgICBpZiAoREJHKSBSbG9nLncoTE9HX1RBRywgInJlbW90ZSBmdW5jIGZhaWxlZC4uLiIpOwogICAgICAgICAgICAgfQogICAgICAgICB9Ci0gICAgICAgIGlmIChmYWxzZSkgUmxvZy52KExPR19UQUcsICJmYWxsIGJhY2sgdG8gZXhpc3RpbmcgaGFuZGxlciIpOworICAgICAgICBpZiAoREJHKSBSbG9nLnYoTE9HX1RBRywgImZhbGwgYmFjayB0byBleGlzdGluZyBoYW5kbGVyIik7CiAKICAgICAgICAgaWYgKG1pbWVUeXBlID09IG51bGwpIHsKLSAgICAgICAgICAgIGlmIChmYWxzZSkgUmxvZy53KExPR19UQUcsICJIZWFkZXIgQ29udGVudC1UeXBlIGVycm9yLiIpOworICAgICAgICAgICAgaWYgKERCRykgUmxvZy53KExPR19UQUcsICJIZWFkZXIgQ29udGVudC1UeXBlIGVycm9yLiIpOwogICAgICAgICAgICAgcmV0dXJuIEludGVudHMuUkVTVUxUX1NNU19HRU5FUklDX0VSUk9SOwogICAgICAgICB9CiAKICAgICAgICAgU3RyaW5nIHBlcm1pc3Npb247CisgICAgICAgIGludCBhcHBPcDsKIAogICAgICAgICBpZiAobWltZVR5cGUuZXF1YWxzKFdzcFR5cGVEZWNvZGVyLkNPTlRFTlRfVFlQRV9CX01NUykpIHsKLSAgICAgICAgICAgIHBlcm1pc3Npb24gPSAiYW5kcm9pZC5wZXJtaXNzaW9uLlJFQ0VJVkVfTU1TIjsKKyAgICAgICAgICAgIHBlcm1pc3Npb24gPSBhbmRyb2lkLk1hbmlmZXN0LnBlcm1pc3Npb24uUkVDRUlWRV9NTVM7CisgICAgICAgICAgICBhcHBPcCA9IEFwcE9wc01hbmFnZXIuT1BfUkVDRUlWRV9NTVM7CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICBwZXJtaXNzaW9uID0gImFuZHJvaWQucGVybWlzc2lvbi5SRUNFSVZFX1dBUF9QVVNIIjsKKyAgICAgICAgICAgIHBlcm1pc3Npb24gPSBhbmRyb2lkLk1hbmlmZXN0LnBlcm1pc3Npb24uUkVDRUlWRV9XQVBfUFVTSDsKKyAgICAgICAgICAgIGFwcE9wID0gQXBwT3BzTWFuYWdlci5PUF9SRUNFSVZFX1dBUF9QVVNIOwogICAgICAgICB9CiAKICAgICAgICAgSW50ZW50IGludGVudCA9IG5ldyBJbnRlbnQoSW50ZW50cy5XQVBfUFVTSF9SRUNFSVZFRF9BQ1RJT04pOwpAQCAtMjcyLDcgKzI3Myw3IEBACiAgICAgICAgIGludGVudC5wdXRFeHRyYSg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gfQpAQCAtMjYwLDExICsyNjAsMTEgQEAKICAgICAgKiAgICAgICAgIGxlbmd0aCBvZiBkYXRhIGluIHBkdSBjYW4gYmUgcmV0cmlldmVkIGJ5IGdldERlY29kZWREYXRhTGVuZ3RoKCkgbWV0aG9kCiAgICAgICovCiAgICAgcHVibGljIGJvb2xlYW4gZGVjb2RlU2hvcnRJbnRlZ2VyKGludCBzdGFydEluZGV4KSB7Ci0gICAgICAgIGlmICgod3NwRGF0YVtzdGFydEluZGV4XSAmIDB4ODApID09IDApIHsKKyAgICAgICAgaWYgKChtV3NwRGF0YVtzdGFydEluZGV4XSAmIDB4ODApID09IDApIHsKICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgfQotICAgICAgICB1bnNpZ25lZDMyYml0ID0gd3NwRGF0YVtzdGFydEluZGV4XSAmIDB4N2Y7Ci0gICAgICAgIGRhdGFMZW5ndGggPSAxOworICAgICAgICBtVW5zaWduZWQzMmJpdCA9IG1Xc3BEYXRhW3N0YXJ0SW5kZXhdICYgMHg3ZjsKKyAgICAgICAgbURhdGFMZW5ndGggPSAxOwogICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICB9CiAKQEAgLTI3OCwxNiArMjc4LDE2IEBACiAgICAgICogICAgICAgICBsZW5ndGggb2YgZGF0YSBpbiBwZHUgY2FuIGJlIHJldHJpZXZlZCBieSBnZXREZWNvZGVkRGF0YUxlbmd0aCgpIG1ldGhvZAogICAgICAqLwogICAgIHB1YmxpYyBib29sZWFuIGRlY29kZUxvbmdJbnRlZ2VyKGludCBzdGFydEluZGV4KSB7Ci0gICAgICAgIGludCBsZW5ndGhNdWx0aU9jdGV0ID0gd3NwRGF0YVtzdGFydEluZGV4XSAmIDB4ZmY7CisgICAgICAgIGludCBsZW5ndGhNdWx0aU9jdGV0ID0gbVdzcERhdGFbc3RhcnRJbmRleF0gJiAweGZmOwogCiAgICAgICAgIGlmIChsZW5ndGhNdWx0aU9jdGV0ID4gV0FQX1BEVV9TS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RleF0gPCBXQVBfUERVX0xFTkdUSF9RVU9URSkgewotICAgICAgICAgICAgdW5zaWduZWQzMmJpdCA9IHdzcERhdGFbc3RhcnRJbmRleF07Ci0gICAgICAgICAgICBkYXRhTGVuZ3RoID0gMTsKKyAgICAgICAgaWYgKG1Xc3BEYXRhW3N0YXJ0SW5kZXhdIDwgV0FQX1BEVV9MRU5HVEhfUVVPVEUpIHsKKyAgICAgICAgICAgIG1VbnNpZ25lZDMyYml0ID0gbVdzcERhdGFbc3RhcnRJbmRleF07CisgICAgICAgICAgICBtRGF0YUxlbmd0aCA9IDE7CiAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICBkZWNvZGVVaW50dmFySW50ZWdlcihzdGFydEluZGV4ICsgMSk7Ci0gICAgICAgICAgICBkYXRhTGVuZ3RoKys7CisgICAgICAgICAgICBtRGF0YUxlbmd0aCsrOwogICAgICAgICB9CiAgICAgICAgIHJldHVybiB0cnVlOwogICAgIH0KQEAgLTM2NywxNyArMzY3LDE3IEBACiAgICAgICovCiAgICAgcHVibGljIGJvb2xlYW4gZGVjb2RlRXh0ZW5zaW9uTWVkaWEoaW50IHN0YXJ0SW5kZXgpIHsKICAgICAgICAgaW50IGluZGV4ID0gc3RhcnRJbmRleDsKLSAgICAgICAgZGF0YUxlbmd0aCA9IDA7Ci0gICAgICAgIHN0cmluZ1ZhbHVlID0gbnVsbDsKLSAgICAgICAgaW50IGxlbmd0aCA9IHdzcERhdGEubGVuZ3RoOworICAgICAgICBtRGF0YUxlbmd0aCA9IDA7CisgICAgICAgIG1TdHJpbmdWYWx1ZSA9IG51bGw7CisgICAgICAgIGludCBsZW5ndGggPSBtV3NwRGF0YS5sZW5ndGg7CiAgICAgICAgIGJvb2xlYW4gcnRybiA9IGluZGV4IDwgbGVuZ3RoOwogCi0gICAgICAgIHdoaWxlIChpbmRleCA8IGxlbmd0aCAmJiB3c3BEYXRhW2luZGV4XSAhPSAwKSB7CisgICAgICAgIHdoaWxlIChpbmRleCA8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ZW50UGFyYW1ldGVycyA9IG5ldyBIYXNoTWFwPFN0cmluZywgU3RyaW5nPigpOwogCiAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICBpZiAoZGVjb2RlVmFsdWVMZW5ndGgoc3RhcnRJbmRleCkgPT0gZmFsc2UpIHsKQEAgLTQyNCwzNSArNDI0LDM1IEBACiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIHJldHVybiBmb3VuZDsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGludCBoZWFkZXJzTGVuZ3RoID0gKGludCkgdW5zaWduZWQzMmJpdDsKKyAgICAgICAgICAgIGludCBoZWFkZXJzTGVuZ3RoID0gKGludCkgbVVuc2lnbmVkMzJiaXQ7CiAgICAgICAgICAgICBtZWRpYVByZWZpeExlbmd0aCA9IGdldERlY29kZWREYXRhTGVuZ3RoKCk7CiAgICAgICAgICAgICBpZiAoZGVjb2RlSW50ZWdlclZhbHVlKHN0YXJ0SW5kZXggKyBtZWRpYVByZWZpeExlbmd0aCkgPT0gdHJ1ZSkgewotICAgICAgICAgICAgICAgIGRhdGFMZW5ndGggKz0gbWVkaWFQcmVmaXhMZW5ndGg7Ci0gICAgICAgICAgICAgICAgaW50IHJlYWRMZW5ndGggPSBkYXRhTGVuZ3RoOwotICAgICAgICAgICAgICAgIHN0cmluZ1ZhbHVlID0gbnVsbDsKKyAgICAgICAgICAgICAgICBtRGF0YUxlbmd0aCArPSBtZWRpYVByZWZpeExlbmd0aDsKKyAgICAgICAgICAgICAgICBpbnQgcmVhZExlbmd0aCA9IG1EYXRhTGVuZ3RoOworICAgICAgICAgICAgICAgIG1TdHJpbmdWYWx1ZSA9IG51bGw7CiAgICAgICAgICAgICAgICAgZXhwYW5kV2VsbEtub3duTWltZVR5cGUoKTsKLSAgICAgICAgICAgICAgICBsb25nIHdlbGxLbm93blZhbHVlID0gdW5zaWduZWQzMmJpdDsKLSAgICAgICAgICAgICAgICBTdHJpbmcgbWltZVR5cGUgPSBzdHJpbmdWYWx1ZTsKLSAgICAgICAgICAgICAgICBpZiAocmVhZENvbnRlbnRQYXJhbWV0ZXJzKHN0YXJ0SW5kZXggKyBkYXRhTGVuZ3RoLAotICAgICAgICAgICAgICAgICAgICAgICAgKGhlYWRlcnNMZW5ndGggLSAoZGF0YUxlbmd0aCAtIG1lZGlhUHJlZml4TGVuZ3RoKSksIDApKSB7Ci0gICAgICAgICAgICAgICAgICAgIGRhdGFMZW5ndGggKz0gcmVhZExlbmd0aDsKLSAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQzMmJpdCA9IHdlbGxLbm93blZhbHVlOwotICAgICAgICAgICAgICAgICAgICBzdHJpbmdWYWx1ZSA9IG1pbWVUeXBlOworICAgICAgICAgICAgICAgIGxvbmcgd2VsbEtub3duVmFsdWUgPSBtVW5zaWduZWQzMmJpdDsKKyAgICAgICAgICAgICAgICBTdHJpbmcgbWltZVR5cGUgPSBtU3RyaW5nVmFsdWU7CisgICAgICAgICAgICAgICAgaWYgKHJlYWRDb250ZW50UGFyYW1ldGVycyhzdGFydEluZGV4ICsgbURhdGFMZW5ndGgsCisgICAgICAgICAgICAgICAgICAgICAgICAoaGVhZGVyc0xlbmd0aCAtIChtRGF0YUxlbmd0aCAtIG1lZGlhUHJlZml4TGVuZ3RoKSksIDApKSB7CisgICAgICAgICAgICAgICAgICAgIG1EYXRhTGVuZ3RoICs9IHJlYWRMZW5ndGg7CisgICAgICAgICAgICAgICAgICAgIG1VbnNpZ25lZDMyYml0ID0gd2VsbEtub3duVmFsdWU7CisgICAgICAgICAgICAgICAgICAgIG1TdHJpbmdWYWx1ZSA9IG1pbWVUeXBlOwogICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgfQogICAgICAgICAgICAgaWYgKGRlY29kZUV4dGVuc2lvbk1lZGlhKHN0YXJ0SW5kZXggKyBtZWRpYVByZWZpeExlbmd0aCkgPT0gdHJ1ZSkgewotICAgICAgICAgICAgICAgIGRhdGFMZW5ndGggKz0gbWVkaWFQcmVmaXhMZW5ndGg7Ci0gICAgICAgICAgICAgICAgaW50IHJlYWRMZW5ndGggPSBkYXRhTGVuZ3RoOworICAgICAgICAgICAgICAgIG1EYXRhTGVuZ3RoICs9IG1lZGlhUHJlZml4TGVuZ3RoOworICAgICAgICAgICAgICAgIGludCByZWFkTGVuZ3RoID0gbURhdGFMZW5ndGg7CiAgICAgICAgICAgICAgICAgZXhwYW5kV2VsbEtub3duTWltZVR5cGUoKTsKLSAgICAgICAgICAgICAgICBsb25nIHdlbGxLbm93blZhbHVlID0gdW5zaWduZWQzMmJpdDsKLSAgICAgICAgICAgICAgICBTdHJpbmcgbWltZVR5cGUgPSBzdHJpbmdWYWx1ZTsKLSAgICAgICAgICAgICAgICBpZiAocmVhZENvbnRlbnRQYXJhbWV0ZXJzKHN0YXJ0SW5kZXggKyBkYXRhTGVuZ3RoLAotICAgICAgICAgICAgICAgICAgICAgICAgKGhlYWRlcnNMZW5ndGggLSAoZGF0YUxlbmd0aCAtIG1lZGlhUHJlZml4TGVuZ3RoKSksIDApKSB7Ci0gICAgICAgICAgICAgICAgICAgIGRhdGFMZW5ndGggKz0gcmVhZExlbmd0aDsKLSAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQzMmJpdCA9IHdlbGxLbm93blZhbHVlOwotICAgICAgICAgICAgICAgICAgICBzdHJpbmdWYWx1ZSA9IG1pbWVUeXBlOworICAgICAgICAgICAgICAgIGxvbmcgd2VsbEtub3duVmFsdWUgPSBtVW5zaWduZWQzMmJpdDsKKyAgICAgICAgICAgICAgICBTdHJpbmcgbWltZVR5cGUgPSBtU3RyaW5nVmFsdWU7CisgICAgICAgICAgICAgICAgaWYgKHJlYWRDb250ZW50UGFyYW1ldGVycyhzdGFydEluZGV4ICsgbURhdGFMZW5ndGgsCisgICAgICAgICAgICAgICAgICAgICAgICAoaGVhZGVyc0xlbmd0aCAtIChtRGF0YUxlbmd0aCAtIG1lZGlhUHJlZml4TGVuZ3RoKSksIDApKSB7CisgICAgICAgICAgICAgICAgICAgIG1EYXRhTGVuZ3RoICs9IHJlYWRMZW5ndGg7CisgICAgICAgICAgICAgICAgICAgIG1VbnNpZ25lZDMyYml0ID0gd2VsbEtub3duVmFsdWU7CisgICAgICAgICAgICAgICAgICAgIG1TdHJpbmdWYWx1ZSA9IG1pbWVUeXBlOwogICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CkBAIC00NjgsMTcgKzQ2OCwxNyBAQAogICAgICAgICBpbnQgdG90YWxSZWFkID0gMDsKIAogICAgICAgICBpZiAobGVmdFRvUmVhZCA+IDApIHsKLSAgICAgICAgICAgIGJ5dGUgbmV4dEJ5dGUgPSB3c3BEYXRhW3N0YXJ0SW5kZXhdOworICAgICAgICAgICAgYnl0ZSBuZXh0Qnl0ZSA9IG1Xc3BEYXRhW3N0YXJ0SW5kZXhdOwogICAgICAgICAgICAgU3RyaW5nIHZhbHVlID0gbnVsbDsKICAgICAgICAgICAgIFN0cmluZyBwYXJhbSA9IG51bGw7CiAgICAgICAgICAgICBpZiAoKG5leHRCeXRlICYgMHg4MCkgPT0gMHgwMCAmJiBuZXh0Qnl0ZSA+IDMxKSB7IC8vIHVudHlwZWQKICAgICAgICAgICAgICAgICBkZWNvZGVUb2tlblRleHQoc3RhcnRJbmRleCk7Ci0gICAgICAgICAgICAgICAgcGFyYW0gPSBzdHJpbmdWYWx1ZTsKLSAgICAgICAgICAgICAgICB0b3RhbFJlYWQgKz0gZGF0YUxlbmd0aDsKKyAgICAgICAgICAgICAgICBwYXJhbSA9IG1TdHJpbmdWYWx1ZTsKKyAgICAgICAgICAgICAgICB0b3RhbFJlYWQgKz0gbURhdGFMZW5ndGg7CiAgICAgICAgICAgICB9IGVsc2UgeyAvLyB0eXBlZAogICAgICAgICAgICAgICAgIGlmIChkZWNvZGVJbnRlZ2VyVmFsdWUoc3RhcnRJbmRleCkpIHsKLSAgICAgICAgICAgICAgICAgICAgdG90YWxSZWFkICs9IGRhdGFMZW5ndGg7Ci0gICAgICAgICAgICAgICAgICAgIGludCB3ZWxsS25vd25QYXJhbWV0ZXJWYWx1ZSA9IChpbnQpIHVuc2lnbmVkMzJiaXQ7CisgICAgICAgICAgICAgICAgICAgIHRvdGFsUmVhZCArPSBtRGF0YUxlbmd0aDsKKyAgICAgICAgICAgICAgICAgICAgaW50IHdlbGxLbm93blBhcmFtZXRlclZhbHVlID0gKGludCkgbVVuc2lnbmVkMzJiaXQ7CiAgICAgICAgICAgICAgICAgICAgIHBhcmFtID0gV0VMTF9LTk9XTl9QQVJBTUVURVJTLmdldCh3ZWxsS25vd25QYXJhbWV0ZXJWYWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgIGlmIChwYXJhbSA9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBwYXJhbSA9ICJ1bmFzc2lnbmVkLzB4IiArIExvbmcudG9IZXhTdHJpbmcod2VsbEtub3duUGFyYW1ldGVyVmFsdWUpOwpAQCAtNDg2LDkgKzQ4Niw5IEBACiAgICAgICAgICAgICAgICAgICAgIC8vIHNwZWNpYWwgY2FzZSBmb3IgdGhlICJRIiBwYXJhbWV0ZXIsIHZhbHVlIGlzIGEgdWludHZhcgogICAgICAgICAgICAgICAgICAgICBpZiAod2VsbEtub3duUGFyYW1ldGVyVmFsdWUgPT0gUV9WQUxVRSkgewogICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRlY29kZVVpbnR2YXJJbnRlZ2VyKHN0YXJ0SW5kZXggKyB0b3RhbFJlYWQpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgdG90YWxSZWFkICs9IGRhdGFMZW5ndGg7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUgPSBTdHJpbmcudmFsdWVPZih1bnNpZ25lZDMyYml0KTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50UGFyYW1ldGVycy5wdXQocGFyYW0sIHZhbHVlKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB0b3RhbFJlYWQgKz0gbURhdGFMZW5ndGg7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUgPSBTdHJpbmcudmFsdWVPZihtVW5zaWduZWQzMmJpdCk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUNvbnRlbnRQYXJhbWV0ZXJzLnB1dChwYXJhbSwgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZWFkQ29udGVudFBhcmFtZXRlcnMoc3RhcnRJbmRleCArIHRvdGFsUmVhZCwgbGVmdFRvUmVhZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLSB0b3RhbFJlYWQsIGFjY3VtdWxhdG9yICsgdG90YWxSZWFkKTsKICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CkBAIC01MDEsMjcgKzUwMSwyNyBAQAogICAgICAgICAgICAgfQogCiAgICAgICAgICAgICBpZiAoZGVjb2RlTm9WYWx1ZShzdGFydEluZGV4ICsgdG90YWxSZWFkKSkgewotICAgICAgICAgICAgICAgIHRvdGFsUmVhZCArPSBkYXRhTGVuZ3RoOworICAgICAgICAgICAgICAgIHRvdGFsUmVhZCArPSBtRGF0YUxlbmd0aDsKICAgICAgICAgICAgICAgICB2YWx1ZSA9IG51bGw7CiAgICAgICAgICAgICB9IGVsc2UgaWYgKGRlY29kZUludGVnZXJWYWx1ZShzdGFydEluZGV4ICsgdG90YWxSZWFkKSkgewotICAgICAgICAgICAgICAgIHRvdGFsUmVhZCArPSBkYXRhTGVuZ3RoOwotICAgICAgICAgICAgICAgIGludCBpbnRWYWx1ZSA9IChpbnQpIHVuc2lnbmVkMzJiaXQ7CisgICAgICAgICAgICAgICAgdG90YWxSZWFkICs9IG1EYXRhTGVuZ3RoOworICAgICAgICAgICAgICAgIGludCBpbnRWYWx1ZSA9IChpbnQpIG1VbnNpZ25lZDMyYml0OwogICAgICAgICAgICAgICAgIHZhbHVlID0gU3RyaW5nLnZhbHVlT2YoaW50VmFsdWUpOwogICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICBkZWNvZGVUb2tlblRleHQoc3RhcnRJbmRleCArIHRvdGFsUmVhZCk7Ci0gICAgICAgICAgICAgICAgdG90YWxSZWFkICs9IGRhdGFMZW5ndGg7Ci0gICAgICAgICAgICAgICAgdmFsdWUgPSBzdHJpbmdWYWx1ZTsKKyAgICAgICAgICAgICAgICB0b3RhbFJlYWQgKz0gbURhdGFMZW5ndGg7CisgICAgICAgICAgICAgICAgdmFsdWUgPSBtU3RyaW5nVmFsdWU7CiAgICAgICAgICAgICAgICAgaWYgKHZhbHVlLnN0YXJ0c1dpdGgoIlwiIikpIHsKICAgICAgICAgICAgICAgICAgICAgLy8gcXVvdGVkIHN0cmluZywgc28gcmVtb3ZlIHRoZSBxdW90ZQogICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IHZhbHVlLnN1YnN0cmluZygxKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9Ci0gICAgICAgICAgICBjb250ZW50UGFyYW1ldGVycy5wdXQocGFyYW0sIHZhbHVlKTsKKyAgICAgICAgICAgIG1Db250ZW50UGFyYW1ldGVycy5wdXQocGFyYW0sIHZhbHVlKTsKICAgICAgICAgICAgIHJldHVybiByZWFkQ29udGVudFBhcmFtZXRlcnMoc3RhcnRJbmRleCArIHRvdGFsUmVhZCwgbGVmdFRvUmVhZCAtIHRvdGFsUmVhZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWNjdW11bGF0b3IgKyB0b3RhbFJlYWQpOwogCiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICBkYXRhTGVuZ3RoID0gYWNjdW11bGF0b3I7CisgICAgICAgICAgICBtRGF0YUxlbmd0aCA9IGFjY3VtdWxhdG9yOwogICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgIH0KICAgICB9CkBAIC01MzQsOCArNTM0LDggQEAKICAgICAgKiBAcmV0dXJuIHRydWUgaWYgYW5kIG9ubHkgaWYgdGhlIG5leHQgYnl0ZSBpcyAweDAwCiAgICAgICovCiAgICAgcHJpdmF0ZSBib29sZWFuIGRlY29kZU5vVmFsdWUoaW50IHN0YXJ0SW5kZXgpIHsKLSAgICAgICAgaWYgKHdzcERhdGFbc3RhcnRJbmRleF0gPT0gMCkgewotICAgICAgICAgICAgZGF0YUxlbmd0aCA9IDE7CisgICAgICAgIGlmIChtV3NwRGF0YVtzdGFydEluZGV4XSA9PSAwKSB7CisgICAgICAgICAgICBtRGF0YUxlbmd0aCA9IDE7CiAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKQEAgLTU0OCwxMSArNTQ4LDExIEBACiAgICAgICogU2V0cyB1bnNpZ25lZDMyYml0IHRvIC0xIGlmIHN0cmluZ1ZhbHVlIGlzIGFscmVhZHkgcG9wdWxhdGVkCiAgICAgICovCiAgICAgcHJpdmF0ZSB2b2lkIGV4cGFuZFdlbGxLbm93bk1pbWVUeXBlKCkgewotICAgICAgICBpZiAoc3RyaW5nVmFsdWUgPT0gbnVsbCkgewotICAgICAgICAgICAgaW50IGJpbmFyeUNvbnRlbnRUeXBlID0gKGludCkgdW5zaWduZWQzMmJpdDsKLSAgICAgICAgICAgIHN0cmluZ1ZhbHVlID0gV0VMTF9LTk9XTl9NSU1FX1RZUEVTLmdldChiaW5hcnlDb250ZW50VHlwZSk7CisgICAgICAgIGlmIChtU3RyaW5nVmFsdWUgPT0gbnVsbCkgeworICAgICAgICAgICAgaW50IGJpbmFyeUNvbnRlbnRUeXBlID0gKGludCkgbVVuc2lnbmVkMzJiaXQ7CisgICAgICAgICAgICBtU3RyaW5nVmFsdWUgPSBXRUxMX0tOT1dOX01JTUVfVFlQRVMuZ2V0KGJpbmFyeUNvbnRlbnRUeXBlKTsKICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgIHVuc2lnbmVkMzJiaXQgPSAtMTsKKyAgICAgICAgICAgIG1VbnNpZ25lZDMyYml0ID0gLTE7CiAgICAgICAgIH0KICAgICB9CiAKQEAgLTU5NCw3ICs1OTQsNyBAQAogICAgICAqLwogICAgIHB1YmxpYyBib29sZWFuIGRlY29kZVhXYXBBcHBsaWNhdGlvbklkKGludCBzdGFydEluZGV4KSB7CiAgICAgICAgIGlmIChkZWNvZGVJbnRlZ2VyVmFsdWUoc3RhcnRJbmRleCkgPT0gdHJ1ZSkgewotICAgICAgICAgICAgc3RyaW5nVmFsdWUgPSBudWxsOworICAgICAgICAgICAgbVN0cmluZ1ZhbHVlID0gbnVsbDsKICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICB9CiAgICAgICAgIHJldHVybiBkZWNvZGVUZXh0U3RyaW5nKHN0YXJ0SW5kZXgpOwpAQCAtNjIyLDcgKzYyMiw3IEBACiAgICAgICAgICAgICAgICAgICAgIGludCBmaWVsZFZhbHVlID0gKGludCkgZ2V0VmFsdWUzMigpOwogCiAgICAgICAgICAgICAgICAgICAgIGlmIChmaWVsZFZhbHVlID09IFBBUkFNRVRFUl9JRF9YX1dBUF9BUFBMSUNBVElPTl9JRCkgewotICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQzMmJpdCA9IGluZGV4ICsgMTsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1VbnNpZ25lZDMyYml0ID0gaW5kZXggKyAxOwogICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9IGVsc2UgewpAQCAtNjQyLDkgKzY0Miw5IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAoTlVMIGNoYXJhY3RlcikKICAgICAgICAgICAgICAgICAgKiAxMjggLSAyNTUgSXQgaXMgYW4gZW5jb2RlZCA3LWJpdCB2YWx1ZTsgdGhpcyBoZWFkZXIgaGFzIG5vIG1vcmUgZGF0YQogICAgICAgICAgICAgICAgICAqLwotICAgICAgICAgICAgICAgIGJ5dGUgdmFsID0gd3NwRGF0YVtpbmRleF07CisgICAgICAgICAgICAgICAgYnl0ZSB2YWwgPSBtV3NwRGF0YVtpbmRleF07CiAgICAgICAgICAgICAgICAgaWYgKDAgPD0gdmFsICYmIHZhbCA8PSBXQVBfUERVX1NIT1JUX0xFTkdUSF9NQVgpIHsKLSAgICAgICAgICAgICAgICAgICAgaW5kZXggKz0gd3NwRGF0YVtpbmRleF0gKyAxOworICAgICAgICAgICAgICAgICAgICBpbmRleCArPSBtV3NwRGF0YVtpbmRleF0gKyAxOwogICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodmFsID09IFdBUF9QRFVfTEVOR1RIX1FVT1RFKSB7CiAgICAgICAgICAgICAgICAgICAgIGlmIChpbmRleCArIDEgPj0gZW5kSW5kZXgpIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgaW5kZXgrKzsKQEAgLTY5NCwyMSArNjk0LDIxIEBACiAgICAgICogVGhlIGRhdGEgbGVuZ3RoIG9mIGxhdGVzdCBvcGVyYXRpb24uCiAgICAgICovCiAgICAgcHVibGljIGludCBnZXREZWNvZGVkRGF0YUxlbmd0aCgpIHsKLSAgICAgICAgcmV0dXJuIGRhdGFMZW5ndGg7CisgICAgICAgIHJldHVybiBtRGF0YUxlbmd0aDsKICAgICB9CiAKICAgICAvKioKICAgICAgKiBUaGUgMzItYml0cyByZXN1bHQgb2YgbGF0ZXN0IG9wZXJhdGlvbi4KICAgICAgKi8KICAgICBwdWJsaWMgbG9uZyBnZXRWYWx1ZTMyKCkgewotICAgICAgICByZXR1cm4gdW5zaWduZWQzMmJpdDsKKyAgICAgICAgcmV0dX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0ID0gY21kUGFyYW1zLm1DbWREZXQ7CiAgICAgICAgIHN3aXRjaChnZXRDbWRUeXBlKCkpIHsKICAgICAgICAgY2FzZSBTRVRfVVBfTUVOVToKICAgICAgICAgY2FzZSBTRUxFQ1RfSVRFTToKLSAgICAgICAgICAgIG1NZW51ID0gKChTZWxlY3RJdGVtUGFyYW1zKSBjbWRQYXJhbXMpLm1lbnU7CisgICAgICAgICAgICBtTWVudSA9ICgoU2VsZWN0SXRlbVBhcmFtcykgY21kUGFyYW1zKS5tTWVudTsKICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICBjYXNlIERJU1BMQVlfVEVYVDoKICAgICAgICAgY2FzZSBTRVRfVVBfSURMRV9NT0RFX1RFWFQ6CkBAIC02MywzNyArNjMsNDIgQEAKICAgICAgICAgY2FzZSBTRU5EX1NNUzoKICAgICAgICAgY2FzZSBTRU5EX1NTOgogICAgICAgICBjYXNlIFNFTkRfVVNTRDoKLSAgICAgICAgICAgIG1UZXh0TXNnID0gKChEaXNwbGF5VGV4dFBhcmFtcykgY21kUGFyYW1zKS50ZXh0TXNnOworICAgICAgICAgICAgbVRleHRNc2cgPSAoKERpc3BsYXlUZXh0UGFyYW1zKSBjbWRQYXJhbXMpLm1UZXh0TXNnOwogICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIGNhc2UgR0VUX0lOUFVUOgogICAgICAgICBjYXNlIEdFVF9JTktFWToKLSAgICAgICAgICAgIG1JbnB1dCA9ICgoR2V0SW5wdXRQYXJhbXMpIGNtZFBhcmFtcykuaW5wdXQ7CisgICAgICAgICAgICBtSW5wdXQgPSAoKEdldElucHV0UGFyYW1zKSBjbWRQYXJhbXMpLm1JbnB1dDsKICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICBjYXNlIExBVU5DSF9CUk9XU0VSOgotICAgICAgICAgICAgbVRleHRNc2cgPSAoKExhdW5jaEJyb3dzZXJQYXJhbXMpIGNtZFBhcmFtcykuY29uZmlybU1zZzsKKyAgICAgICAgICAgIG1UZXh0TXNnID0gKChMYXVuY2hCcm93c2VyUGFyYW1zKSBjbWRQYXJhbXMpLm1Db25maXJtTXNnOwogICAgICAgICAgICAgbUJyb3dzZXJTZXR0aW5ncyA9IG5ldyBCcm93c2VyU2V0dGluZ3MoKTsKLSAgICAgICAgICAgIG1Ccm93c2VyU2V0dGluZ3MudXJsID0gKChMYXVuY2hCcm93c2VyUGFyYW1zKSBjbWRQYXJhbXMpLnVybDsKLSAgICAgICAgICAgIG1Ccm93c2VyU2V0dGluZ3MubW9kZSA9ICgoTGF1bmNoQnJvd3NlclBhcmFtcykgY21kUGFyYW1zKS5tb2RlOworICAgICAgICAgICAgbUJyb3dzZXJTZXR0aW5ncy51cmwgPSAoKExhdW5jaEJyb3dzZXJQYXJhbXMpIGNtZFBhcmFtcykubVVybDsKKyAgICAgICAgICAgIG1Ccm93c2VyU2V0dGluZ3MubW9kZSA9ICgoTGF1bmNoQnJvd3NlclBhcmFtcykgY21kUGFyYW1zKS5tTW9kZTsKICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICBjYXNlIFBMQVlfVE9ORToKICAgICAgICAgICAgIFBsYXlUb25lUGFyYW1zIHBhcmFtcyA9IChQbGF5VG9uZVBhcmFtcykgY21kUGFyYW1zOwotICAgICAgICAgICAgbVRvbmVTZXR0aW5ncyA9IHBhcmFtcy5zZXR0aW5nczsKLSAgICAgICAgICAgIG1UZXh0TXNnID0gcGFyYW1zLnRleHRNc2c7CisgICAgICAgICAgICBtVG9uZVNldHRpbmdzID0gcGFyYW1zLm1TZXR0aW5nczsKKyAgICAgICAgICAgIG1UZXh0TXNnID0gcGFyYW1zLm1UZXh0TXNnOwogICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIGNhc2UgR0VUX0NIQU5ORUxfU1RBVFVTOgotICAgICAgICAgICAgbVRleHRNc2cgPSAoKENhbGxTZXR1cFBhcmFtcykgY21kUGFyYW1zKS5jb25maXJtTXNnOworICAgICAgICAgICAgbVRleHRNc2cgPSA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OVF9MSVNUOgorICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIH0KICAgICB9CkBAIC0xMTcsOSArMTIyLDEyIEBACiAgICAgICAgICAgICBtQ2FsbFNldHRpbmdzLmNvbmZpcm1Nc2cgPSBpbi5yZWFkUGFyY2VsYWJsZShudWxsKTsKICAgICAgICAgICAgIG1DYWxsU2V0dGluZ3MuY2FsbE1zZyA9IGluLnJlYWRQYXJjZWxhYmxlKG51bGwpOwogICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHdyaXRlVG9QYXJjZWwoUGFyY2VsIGRlc3QsIGludCBmbGFncykgewogICAgICAgICBkZXN0LndyaXRlUGFyY2VsYWJsZShtQ21kRGV0LCAwKTsKICAgICAgICAgZGVzdC53cml0ZVBhcmNlbGFibGUobVRleHRNc2csIDApOwpAQCAtMTM3LDE5ICsxNDUsMjQgQEAKICAgICAgICAgICAgIGRlc3Qud3JpdGVQYXJjZWxhYmxlKG1DYWxsU2V0dGluZ3MuY29uZmlybU1zZywgMCk7CiAgICAgICAgICAgICBkZXN0LndyaXRlUGFyY2VsYWJsZShtQ2FsbFNldHRpbmdzLmNhbGxNc2csIDApOwogICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogICAgIH0KIAogICAgIHB1YmxpYyBzdGF0aWMgZmluYWwgUGFyY2VsYWJsZS5DcmVhdG9yPENhdENtZE1lc3NhZ2U+IENSRUFUT1IgPSBuZXcgUGFyY2VsYWJsZS5DcmVhdG9yPENhdENtZE1lc3NhZ2U+KCkgeworICAgICAgICBAT3ZlcnJpZGUKICAgICAgICAgcHVibGljIENhdENtZE1lc3NhZ2UgY3JlYXRlRnJvbVBhcmNlbChQYXJjZWwg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SAgICAgICAgU3RyaW5nIHVzZXJzSW5wdXQgID0gbnVsbDsKLSAgICAgICAgYm9vbGVhbiB1c2Vyc1llc05vU2VsZWN0aW9uID0gZmFsc2U7Ci0gICAgICAgIGJvb2xlYW4gdXNlcnNDb25maXJtID0gZmFsc2U7Ci0gICAgICAgIGJvb2xlYW4gaW5jbHVkZUFkZGl0aW9uYWxJbmZvID0gZmFsc2U7Ci0gICAgICAgIGludCBhZGRpdGlvbmFsSW5mbyA9IDA7CisgICAgICAgIENvbW1hbmREZXRhaWxzIG1DbWREZXQgPSBudWxsOworICAgICAgICBSZXN1bHRDb2RlIG1SZXNDb2RlICA9IFJlc3VsdENvZGUuT0s7CisgICAgICAgIGludCBtVXNlcnNNZW51U2VsZWN0aW9uID0gMDsKKyAgICAgICAgU3RyaW5nIG1Vc2Vyc0lucHV0ICA9IG51bGw7CisgICAgICAgIGJvb2xlYW4gbVVzZXJzWWVzTm9TZWxlY3Rpb24gPSBmYWxzZTsKKyAgICAgICAgYm9vbGVhbiBtVXNlcnNDb25maXJtID0gZmFsc2U7CisgICAgICAgIGJvb2xlYW4gbUluY2x1ZGVBZGRpdGlvbmFsSW5mbyA9IGZhbHNlOworICAgICAgICBpbnQgbUFkZGl0aW9uYWxJbmZvID0gMDsKICAgICAgICAgcHVibGljIENhdFJlc3BvbnNlTWVzc2FnZShDYXRDbWRNZXNzYWdlIGNtZE1zZykgewotICAgICAgICAgICAgdGhpcy5jbWREZXQgPSBjbWRNc2cubUNtZERldDsKKyAgICAgICAgICAgIG1DbWREZXQgPSBjbWRNc2cubUNtZERldDsKICAgICAgICAgfQogCiAgICAgICAgIHB1YmxpYyB2b2lkIHNldFJlc3VsdENvZGUoUmVzdWx0Q29kZSByZXNDb2RlKSB7Ci0gICAgICAgICAgICB0aGlzLnJlc0NvZGUgPSByZXNDb2RlOworICAgICAgICAgICAgbVJlc0NvZGUgPSByZXNDb2RlOwogICAgICAgICB9CiAKICAgICAgICAgcHVibGljIHZvaWQgc2V0TWVudVNlbGVjdGlvbihpbnQgc2VsZWN0aW9uKSB7Ci0gICAgICAgICAgICB0aGlzLnVzZXJzTWVudVNlbGVjdGlvbiA9IHNlbGVjdGlvbjsKKyAgICAgICAgICAgIG1Vc2Vyc01lbnVTZWxlY3Rpb24gPSBzZWxlY3Rpb247CiAgICAgICAgIH0KIAogICAgICAgICBwdWJsaWMgdm9pZCBzZXRJbnB1dChTdHJpbmcgaW5wdXQpIHsKLSAgICAgICAgICAgIHRoaXMudXNlcnNJbnB1dCA9IGlucHV0OworICAgICAgICAgICAgbVVzZXJzSW5wdXQgPSBpbnB1dDsKICAgICAgICAgfQogCiAgICAgICAgIHB1YmxpYyB2b2lkIHNldFllc05vKGJvb2xlYW4geWVzTm8pIHsKLSAgICAgICAgICAgIHVzZXJzWWVzTm9TZWxlY3Rpb24gPSB5ZXNObzsKKyAgICAgICAgICAgIG1Vc2Vyc1llc05vU2VsZWN0aW9uID0geWVzTm87CiAgICAgICAgIH0KIAogICAgICAgICBwdWJsaWMgdm9pZCBzZXRDb25maXJtYXRpb24oYm9vbGVhbiBjb25maXJtKSB7Ci0gICAgICAgICAgICB1c2Vyc0NvbmZpcm0gPSBjb25maXJtOworICAgICAgICAgICAgbVVzZXJzQ29uZmlybSA9IGNvbmZpcm07CiAgICAgICAgIH0KIAogICAgICAgICBwdWJsaWMgdm9pZCBzZXRBZGRpdGlvbmFsSW5mbyhpbnQgaW5mbykgewotICAgICAgICAgICAgdGhpcy5pbmNsdWRlQWRkaXRpb25hbEluZm8gPSB0cnVlOwotICAgICAgICAgICAgdGhpcy5hZGRpdGlvbmFsSW5mbyA9IGluZm87CisgICAgICAgICAgICBtSW5jbHVkZUFkZGl0aW9uYWxJbmZvID0gdHJ1ZTsKKyAgICAgICAgICAgIG1BZGRpdGlvbmFsSW5mbyA9IGluZm87CiAgICAgICAgIH0KIAogICAgICAgICBDb21tYW5kRGV0YWlscyBnZXRDbWREZXRhaWxzKCkgewotICAgICAgICAgICAgcmV0dX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ZSBmaW5hbGl6ZWQiKTsKICAgICB9CkBAIC0xODYsNyArMTg0LDcgQEAKICAgICAgICAgICAgICAgICAgICAgLy8gZm9yIHByb2FjdGl2ZSBjb21tYW5kcyB0aGF0IGNvdWxkbid0IGJlIGRlY29kZWQKICAgICAgICAgICAgICAgICAgICAgLy8gc3VjY2Vzc2Z1bGx5IHJlc3BvbmQgd2l0aCB0aGUgY29kZSBnZW5lcmF0ZWQgYnkgdGhlCiAgICAgICAgICAgICAgICAgICAgIC8vIG1lc3NhZ2UgZGVjb2Rlci4KLSAgICAgICAgICAgICAgICAgICAgc2VuZFRlcm1pbmFsUmVzcG9uc2UoY21kUGFyYW1zLmNtZERldCwgcmlsTXNnLm1SZXNDb2RlLAorICAgICAgICAgICAgICAgICAgICBzZW5kVGVybWluYWxSZXNwb25zZShjbWRQYXJhbXMubUNtZERldCwgcmlsTXNnLm1SZXNDb2RlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZhbHNlLCAwLCBudWxsKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CkBAIC0yMjYsNDMgKzIyNCw0MyBAQAogICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgIG1NZW51Q21kID0gY21kTXNnOwogICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBzZW5kVGVybWluYWxSZXNwb25zZShjbWRQYXJhbXMuY21kRGV0LCBSZXN1bHRDb2RlLk9LLCBmYWxzZSwgMCwgbnVsbCk7CisgICAgICAgICAgICAgICAgc2VuZFRlcm1pbmFsUmVzcG9uc2UoY21kUGFyYW1zLm1DbWREZXQsIFJlc3VsdENvZGUuT0ssIGZhbHNlLCAwLCBudWxsKTsKICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIGNhc2UgRElTUExBWV9URVhUOgogICAgICAgICAgICAgICAgIC8vIHdoZW4gYXBwbGljYXRpb24gaXMgbm90IHJlcXVpcmVkIHRvIHJlc3BvbmQsIHNlbmQgYW4gaW1tZWRpYXRlIHJlc3BvbnNlLgogICAgICAgICAgICAgICAgIGlmICghY21kTXNnLmdlVGV4dE1lc3NhZ2UoKS5yZXNwb25zZU5lZWRlZCkgewotICAgICAgICAgICAgICAgICAgICBzZW5kVGVybWluYWxSZXNwb25zZShjbWRQYXJhbXMuY21kRGV0LCBSZXN1bHRDb2RlLk9LLCBmYWxzZSwgMCwgbnVsbCk7CisgICAgICAgICAgICAgICAgICAgIHNlbmRUZXJtaW5hbFJlc3BvbnNlKGNtZFBhcmFtcy5tQ21kRGV0LCBSZXN1bHRDb2RlLk9LLCBmYWxzZSwgMCwgbnVsbCk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgY2FzZSBSRUZSRVNIOgogICAgICAgICAgICAgICAgIC8vIE1FIHNpZGUgb25seSBoYW5kbGVzIHJlZnJlc2ggY29tbWFuZHMgd2hpY2ggbWVhbnQgdG8gcmVtb3ZlIElETEUKICAgICAgICAgICAgICAgICAvLyBNT0RFIFRFWFQuCi0gICAgICAgICAgICAgICAgY21kUGFyYW1zLmNtZERldC50eXBlT2ZDb21tYW5kID0gQ29tbWFuZFR5cGUuU0VUX1VQX0lETEVfTU9ERV9URVhULnZhbHVlKCk7CisgICAgICAgICAgICAgICAgY21kUGFyYW1zLm1DbWREZXQudHlwZU9mQ29tbWFuZCA9IENvbW1hbmRUeXBlLlNFVF9VUF9JRExFX01PREVfVEVYVC52YWx1ZSgpOwogICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgY2FzZSBTRVRfVVBfSURMRV9NT0RFX1RFWFQ6Ci0gICAgICAgICAgICAgICAgc2VuZFRlcm1pbmFsUmVzcG9uc2UoY21kUGFyYW1zLmNtZERldCwgUmVzdWx0Q29kZS5PSywgZmFsc2UsIDAsIG51bGwpOworICAgICAgICAgICAgICAgIHNlbmRUZXJtaW5hbFJlc3BvbnNlKGNtZFBhcmFtcy5tQ21kRGV0LCBSZXN1bHRDb2RlLk9LLCBmYWxzZSwgMCwgbnVsbCk7CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICBjYXNlIFBST1ZJREVfTE9DQUxfSU5GT1JNQVRJT046CiAgICAgICAgICAgICAgICAgUmVzcG9uc2VEYXRhIHJlc3A7Ci0gICAgICAgICAgICAgICAgc3dpdGNoIChjbWRQYXJhbXMuY21kRGV0LmNvbW1hbmRRdWFsaWZpZXIpIHsKKyAgICAgICAgICAgICAgICBzd2l0Y2ggKGNtZFBhcmFtcy5tQ21kRGV0LmNvbW1hbmRRdWFsaWZpZXIpIHsKICAgICAgICAgICAgICAgICAgICAgY2FzZSBDb21tYW5kUGFyYW1zRmFjdG9yeS5EVFRaX1NFVFRJTkc6CiAgICAgICAgICAgICAgICAgICAgICAgICByZXNwID0gbmV3IERUVFpSZXNwb25zZURhdGEobnVsbCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBzZW5kVGVybWluYWxSZXNwb25zZShjbWRQYXJhbXMuY21kRGV0LCBSZXN1bHRDb2RlLk9LLCBmYWxzZSwgMCwgcmVzcCk7CisgICAgICAgICAgICAgICAgICAgICAgICBzZW5kVGVybWluYWxSZXNwb25zZShjbWRQYXJhbXMubUNtZERldCwgUmVzdWx0Q29kZS5PSywgZmFsc2UsIDAsIHJlc3ApOwogICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgIGNhc2UgQ29tbWFuZFBhcmFtc0ZhY3RvcnkuTEFOR1VBR0VfU0VUVElORzoKICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3AgPSBuZXcgTGFuZ3VhZ2VSZXNwb25zZURhdGEoTG9jYWxlLmdldERlZmF1bHQoKS5nZXRMYW5ndWFnZSgpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIHNlbmRUZXJtaW5hbFJlc3BvbnNlKGNtZFBhcmFtcy5jbWREZXQsIFJlc3VsdENvZGUuT0ssIGZhbHNlLCAwLCByZXNwKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHNlbmRUZXJtaW5hbFJlc3BvbnNlKGNtZFBhcmFtcy5tQ21kRGV0LCBSZXN1bHRDb2RlLk9LLCBmYWxzZSwgMCwgcmVzcCk7CiAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKLSAgICAgICAgICAgICAgICAgICAgICAgIHNlbmRUZXJtaW5hbFJlc3BvbnNlKGNtZFBhcmFtcy5jbWREZXQsIFJlc3VsdENvZGUuT0ssIGZhbHNlLCAwLCBudWxsKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHNlbmRUZXJtaW5hbFJlc3BvbnNlKGNtZFBhcmFtcy5tQ21kRGV0LCBSZXN1bHRDb2RlLk9LLCBmYWxzZSwgMCwgbnVsbCk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIC8vIE5vIG5lZWQgdG8gc3RhcnQgU1RLIGFwcCBoZXJlLgogICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgIGNhc2UgTEFVTkNIX0JST1dTRVI6Ci0gICAgICAgICAgICAgICAgaWYgKCgoKExhdW5jaEJyb3dzZXJQYXJhbXMpIGNtZFBhcmFtcykuY29uZmlybU1zZy50ZXh0ICE9IG51bGwpCi0gICAgICAgICAgICAgICAgICAgICAgICAmJiAoKChMYXVuY2hCcm93c2VyUGFyYW1zKSBjbWRQYXJhbXMpLmNvbmZpcm1Nc2cudGV4dC5lcXVhbHMoU1RLX0RFRkFVTFQpKSkgeworICAgICAgICAgICAgICAgIGlmICgoKChMYXVuY2hCcm93c2VyUGFyYW1zKSBjbWRQYXJhbXMpLm1Db25maXJtTXNnLnRleHQgIT0gbnVsbCkKKyAgICAgICAgICAgICAgICAgICAgICAgICYmICgoKExhdW5jaEJyb3dzZXJQYXJhbXMpIGNtZFBhcmFtcykubUNvbmZpcm1Nc2cudGV4dC5lcXVhbHMoU1RLX0RFRkFVTFQpKSkgewogICAgICAgICAgICAgICAgICAgICBtZXNzYWdlID0gbUNvbnRleHQuZ2V0VGV4dChjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5sYXVuY2hCcm93c2VyRGVmYXVsdCk7Ci0gICAgICAgICAgICAgICAgICAgICgoTGF1bmNoQnJvd3NlclBhcmFtcykgY21kUGFyYW1zKS5jb25maXJtTXNnLnRleHQgPSBtZXNzYWdlLnRvU3RyaW5nKCk7CisgICAgICAgICAgICAgICAgICAgICgoTGF1bmNoQnJvd3NlclBhcmFtcykgY21kUGFyYW1zKS5tQ29uZmlybU1zZy50ZXh0ID0gbWVzc2FnZS50b1N0cmluZygpOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIGNhc2UgU0VMRUNUX0lURU06CkBAIC0yNzMsMTkgKzI3MSwxOSBAQAogICAgICAgICAgICAgY2FzZSBTRU5EX1NNUzoKICAgICAgICAgICAgIGNhc2UgU0VORF9TUzoKICAgICAgICAgICAgIGNhc2UgU0VORF9VU1NEOgotICAgICAgICAgICAgICAgIGlmICgoKChEaXNwbGF5VGV4dFBhcmFtcyljbWRQYXJhbXMpLnRleHRNc2cudGV4dCAhPSBudWxsKQotICAgICAgICAgICAgICAgICAgICAgICAgJiYgKCgoRGlzcGxheVRleHRQYXJhbXMpY21kUGFyYW1zKS50ZXh0TXNnLnRleHQuZXF1YWxzKFNUS19ERUZBVUxUKSkpIHsKKyAgICAgICAgICAgICAgICBpZiAoKCgoRGlzcGxheVRleHRQYXJhbXMpY21kUGFyYW1zKS5tVGV4dE1zZy50ZXh0ICE9IG51bGwpCisgICAgICAgICAgICAgICAgICAgICAgICAmJiAoKChEaXNwbGF5VGV4dFBhcmFtcyljbWRQYXJhbXMpLm1UZXh0TXNnLnRleHQuZXF1YWxzKFNUS19ERUZBVUxUKSkpIHsKICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZSA9IG1Db250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuc2VuZGluZyk7Ci0gICAgICAgICAgICAgICAgICAgICgoRGlzcGxheVRleHRQYXJhbXMpY21kUGFyYW1zKS50ZXh0TXNnLnRleHQgPSBtZXNzYWdlLnRvU3RyaW5nKCk7CisgICAgICAgICAgICAgICAgICAgICgoRGlzcGxheVRleHRQYXJhbXMpY21kUGFyYW1zKS5tVGV4dE1zZy50ZXh0ID0gbWVzc2FnZS50b1N0cmluZygpOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIGNhc2UgUExBWV9UT05FOgogICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgY2FzZSBTRVRfVVBfQ0FMTDoKLSAgICAgICAgICAgICAgICBpZiAoKCgoQ2FsbFNldHVwUGFyYW1zKSBjbWRQYXJhbXMpLmNvbmZpcm1Nc2cudGV4dCAhPSBudWxsKQotICAgICAgICAgICAgICAgICAgICAgICAgJiYgKCgoQ2FsbFNldHVwUGFyYW1zKSBjbWRQYXJhbXMpLmNvbmZpcm1Nc2cudGV4dC5lcXVhbHMoU1RLX0RFRkFVTFQpKSkgeworICAgICAgICAgICAgICAgIGlmICgoKChDYWxsU2V0dXBQYXJhbXMpIGNtZFBhcmFtcykubUNvbmZpcm1Nc2cudGV4dCAhPSBudWxsKQorICAgICAgICAgICAgICAgICAgICAgICAgJiYgKCgoQ2FsbFNldHVwUGFyYW1zKSBjbWRQYXJhbXMpLm1Db25maXJtTXNnLnRleHQuZXF1YWxzKFNUS19ERUZBVUxUKSkpIHsKICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZSA9IG1Db250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuU2V0dXBDYWxsRGVmYXVsdCk7Ci0gICAgICAgICAgICAgICAgICAgICgoQ2FsbFNldHVwUGFyYW1zKSBjbWRQYXJhbXMpLmNvbmZpcm1Nc2cudGV4dCA9IG1lc3NhZ2UudG9TdHJpbmcoKTsKKyAgICAgICAgICAgICAgICAgICAgKChDYWxsU2V0dXBQYXJhbXMpIGNtZFBhcmFtcykubUNvbmZpcm1Nc2cudGV4dCA9IG1lc3NhZ2UudG9TdHJpbmcoKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICBjYXNlIE9QRU5fQ0hBTk5FTDoKQEAgLTI5MywxMSArMjkxLDExIEBACiAgICAgICAgICAgICBjYXNlIFJFQ0VJVkVfREFUQToKICAgICAgICAgICAgIGNhc2UgU0VORF9EQVRBOgogICAgICAgICAgICAgICAgIEJJUENsaWVudFBhcmFtcyBjbWQgPSAoQklQQ2xpZW50UGFyYW1zKSBjbWRQYXJhbXM7Ci0gICAgICAgICAgICAgICAgaWYgKGNtZC5iSGFzQWxwaGFJZCAmJiAoY21kLnRleHRNc2cudGV4dCA9PSBudWxsKSkgeworICAgICAgICAgICAgICAgIGlmIChjbWQubUhhc0FscGhhSWQgJiYgKGNtZC5tVGV4dE1zZy50ZXh0ID09IG51bGwpKSB7CiAgICAgICAgICAgICAgICAgICAgIENhdExvZy5kKHRoaXMsICJjbWQgIiArIGNtZFBhcmFtcy5nZXRDb21tYW5kVHlwZSgpICsgIiB3aXRoIG51bGwgYWxwaGEgaWQiKTsKICAgICAgICAgICAgICAgICAgICAgLy8gSWYgYWxwaGEgbGVuZ3RoIGlzIHplcm8sIHdlIGp1c3QgcmVzcG9uZCB3aXRoIE9LLgogICAgICAgICAgICAgICAgICAgICBpZiAoaXNQcm9hY3RpdmVDbWQpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIHNlbmRUZXJtaW5hbFJlc3BvbnNlKGNtZFBhcmFtcy5jbWREZXQsIFJlc3VsdENvZGUuT0ssIGZhbHNlLCAwLCBudWxsKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHNlbmRUZXJtaW5hbFJlc3BvbnNlKGNtZFBhcmFtcy5tQ21kRGV0LCBSZXN1bHRDb2RlLk9LLCBmYWxzZSwgMCwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgIH0KQEAgLTMwNSw3ICszMDMsNyBAQAogICAgICAgICAgICAgICAgIGlmICghbVN0a0FwcEluc3RhbGxlZCkgewogICAgICAgICAgICAgICAgICAgICBDYXRMb2cuZCh0aGlzLCAiTm8gU1RLIGFwcGxpY2F0aW9uIGZvdW5kLiIpOwogICAgICAgICAgICAgICAgICAgICBpZiAoaXNQcm9hY3RpdmVDbWQpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIHNlbmRUZXJtaW5hbFJlc3BvbnNlKGNtZFBhcmFtcy5jbWREZXQsCisgICAgICAgICAgICAgICAgICAgICAgICBzZW5kVGVybWluYWxSZXNwb25zZShjbWRQYXJhbXMubUNtZERldCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFJlc3VsdENvZGUuQkVZT05EX1RFUk1JTkFMX0NBUEFCSUxJVFksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmYWxzZSwgMCwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CkBAIC0zMjEsNyArMzE5LDcgQEAKICAgICAgICAgICAgICAgICAgICAgKChjbWRQYXJhbXMuZ2V0Q29tbWFuZFR5cGUoKSA9PSBDb21tYW5kVHlwZS5DTE9TRV9DSEFOTkVMKSB8fAogICAgICAgICAgICAgICAgICAgICAgKGNtZFBhcmFtcy5nZXRDb21tYW5kVHlwZSgpID09IENvbW1hbmRUeXBlLlJFQ0VJVkVfREFUQSkgfHwKICAgICAgICAgICAgICAgICAgICAgIChjbWRQYXJhbXMuZ2V0Q29tbWFuZFR5cGUoKSA9PSBDb21tYW5kVHlwZS5TRU5EX0RBVEEpKSkgewotICAgICA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ICAgICBpbnQgbGVuID0gcmF3RGF0YS5sZW5ndGggLSAyOyAvLyBtaW51cyAodGFnICsgbGVuZ3RoKQotICAgICAgICByYXdEYXRhWzFdID0gKGJ5dGUpIGxlbjsKLQotICAgICAgICBTdHJpbmcgaGV4U3RyaW5nID0gSWNjVXRpbHMuYnl0ZXNUb0hleFN0cmluZyhyYXdEYXRhKTsKLQotICAgICAgICBtQ21kSWYuc2VuZEVudmVsb3BlKGhleFN0cmluZywgbnVsbCk7Ci0gICAgfQotCiAgICAgLyoqCiAgICAgICogVXNlZCBmb3IgaW5zdGFudGlhdGluZy91cGRhdGluZyB0aGUgU2VydmljZSBmcm9tIHRoZSBHc21QaG9uZSBvciBDZG1hUGhvbmUgY29uc3RydWN0b3IuCiAgICAgICoKICAgICAgKiBAcGFyYW0gY2kgQ29tbWFuZHNJbnRlcmZhY2Ugb2JqZWN0Ci0gICAgICogQHBhcmFtIGlyIEljY1JlY29yZHMgb2JqZWN0CiAgICAgICogQHBhcmFtIGNvbnRleHQgcGhvbmUgYXBwIGNvbnRleHQKLSAgICAgKiBAcGFyYW0gZmggSWNjIGZpbGUgaGFuZGxlcgogICAgICAqIEBwYXJhbSBpYyBJY2MgY2FyZAogICAgICAqIEByZXR1cm4gVGhlIG9ubHkgU2VydmljZSBvYmplY3QgaW4gdGhlIHN5c3RlbQogICAgICAqLwpAQCAtNjU5LDE4ICs2MTIsMTkgQEAKICAgICAgICAgfQogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBzeW5jaHJvbml6ZWQgdm9pZCBvbkNtZFJlc3BvbnNlKENhdFJlc3BvbnNlTWVzc2FnZSByZXNNc2cpIHsKICAgICAgICAgaWYgKHJlc01zZyA9PSBudWxsKSB7CiAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgIH0KICAgICAgICAgLy8gcXVldWUgYSByZXNwb25zZSBtZXNzYWdlLgotICAgICAgICBNZXNzYWdlIG1zZyA9IHRoaXMub2J0YWluTWVzc2Fn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odHlwZSkgewogICAgICAgICAgICAgY2FzZSBTRVRfVVBfTUVOVToKLSAgICAgICAgICAgICAgICBoZWxwUmVxdWlyZWQgPSByZXNNc2cucmVzQ29kZSA9PSBSZXN1bHRDb2RlLkhFTFBfSU5GT19SRVFVSVJFRDsKLSAgICAgICAgICAgICAgICBzZW5kTWVudVNlbGVjdGlvbihyZXNNc2cudXNlcnNNZW51U2VsZWN0aW9uLCBoZWxwUmVxdWlyZWQpOworICAgICAgICAgICAgICAgIGhlbHBSZXF1aXJlZCA9IHJlc01zZy5tUmVzQ29kZSA9PSBSZXN1bHRDb2RlLkhFTFBfSU5GT19SRVFVSVJFRDsKKyAgICAgICAgICAgICAgICBzZW5kTWVudVNlbGVjdGlvbihyZXNNc2cubVVzZXJzTWVudVNlbGVjdGlvbiwgaGVscFJlcXVpcmVkKTsKICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICBjYXNlIFNFTEVDVF9JVEVNOgotICAgICAgICAgICAgICAgIHJlc3AgPSBuZXcgU2VsZWN0SXRlbVJlc3BvbnNlRGF0YShyZXNNc2cudXNlcnNNZW51U2VsZWN0aW9uKTsKKyAgICAgICAgICAgICAgICByZXNwID0gbmV3IFNlbGVjdEl0ZW1SZXNwb25zZURhdGEocmVzTXNnLm1Vc2Vyc01lbnVTZWxlY3Rpb24pOwogICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgY2FzZSBHRVRfSU5QVVQ6CiAgICAgICAgICAgICBjYXNlIEdFVF9JTktFWToKQEAgLTczNiwyNCArNjkwLDI2IEBACiAgICAgICAgICAgICAgICAgICAgIC8vIHdoZW4gaGVscCBpcyByZXF1ZXN0ZWQgdGhlcmUgaXMgbm8gbmVlZCB0byBzZW5kIHRoZSB0ZXh0CiAgICAgICAgICAgICAgICAgICAgIC8vIHN0cmluZyBvYmplY3QuCiAgICAgICAgICAgICAgICAgICAgIGlmICghaGVscFJlcXVpcmVkKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICByZXNwID0gbmV3IEdldElua2V5SW5wdXRSZXNwb25zZURhdGEocmVzTXNnLnVzZXJzSW5wdXQsCisgICAgICAgICAgICAgICAgICAgICAgICByZXNwID0gbmV3IEdldElua2V5SW5wdXRSZXNwb25zZURhdGEocmVzTXNnLm1Vc2Vyc0lucHV0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnB1dC51Y3MyLCBpbnB1dC5wYWNrZWQpOwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgcmVzcCA9IG5ldyBHZXRJbmtleUlucHV0UmVzcG9uc2VEYXRhKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc01zZy51c2Vyc1llc05vU2VsZWN0aW9uKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNNc2cubVVzZXJzWWVzTm9TZWxlY3Rpb24pOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIGNhc2UgRElTUExBWV9URVhUOgogICAgICAgICAgICAgY2FzZSBMQVVOQ0hfQlJPV1NFUjoKICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIGNhc2UgU0VUX1VQX0NBTEw6Ci0gICAgICAgICAgICAgICAgbUNtZElmLmhhbmRsZUNhbGxTZXR1cFJlcXVlc3RGcm9tU2ltKHJlc01zZy51c2Vyc0NvbmZpcm0sIG51bGwpOworICAgICAgICAgICAgICAgIG1DbWRJZi5oYW5kbGVDYWxsU2V0dXBSZXF1ZXN0RnJvbVNpbShyZXNNc2cubVVzZXJzQ29uZmlybSwgbnVsbCk7CiAgICAgICAgICAgICAgICAgLy8gTm8gbmVlZCB0byBzZW5kIHRlcm1pbmFsIHJlc3BvbnNlIGZvciBTRVQgVVAgQ0FMTC4gVGhlIHVzZXIncwogICAgICAgICAgICAgICAgIC8vIGNvbmZpcm1hdGlvbiByZXN1bHQgaXMgc2VuZCBiYWNrIHVzaW5nIGEgZGVkaWNhdGVkIHJpbCBtZXNzYWdlCiAgICAgICAgICAgICAgICAgLy8gaW52b2tlZCBieSB0aGUgQ29tbWFuZEludGVyZmFjZSBjYWxsIGFib3ZlLgogICAgICAgICAgICAgICAgIG1DdXJybnRDbWQgPSBudWxsOwogICAgICAgICAgICAgICAgIHJldHVybjsKKyAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBicmVhazsKICAgICAgICAgY2FzZSBCQUNLV0FSRF9NT1ZFX0JZX1VTRVI6CkBAIC03NzcsOCArNzMzLDggQEAKICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgfQotICAgICAgICBzZW5kVGVybWluYWxSZXNwb25zZShjbWREZXQsIHJlc01zZy5yZXNDb2RlLCByZXNNc2cuaW5jbHVkZUFkZGl0aW9uYWxJbmZvLAotICAgICAgICAgICAgICAgIHJlc01zZy5hZGRpdGlvbmFsSW5mbywgcmVzcCk7CisgICAgICAgIHNlbmRUZXJtaW5hbFJlc3BvbnNlKGNtZERldCwgcmVzTXNnLm1SZXNDb2RlLCByZXNNc2cubUluY2x1ZGVBZGRpdGlvbmFsSW5mbywKKyAgICAgICAgICAgICAgICByZXNNc2cubUFkZGl0aW9uYWxJbmZvLCByZXNwKTsKICAgICAgICAgbUN1cnJudENtZCA9IG51bGw7CiAgICAgfQogCmRpZmYgLS1naXQgYS9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvY2F0L0NvbW1hbmREZXRhaWxzLmphdmEgYi9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvY2F0L0NvbW1hbmREZXRhaWxzLmphdmEKaW5kZXggM2U3ZjcyMi4uYWFhOWQ2OCAxMDA2NDQKLS0tIGEvc3JjL2phdmEvY29tL2FuZHJ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aW5hbCBQYXJjZWxhYmxlLkNyZWF0b3I8Q29tbWFuZERldGFpbHM+IENSRUFUT1IgPQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXcgUGFyY2VsYWJsZS5DcmVhdG9yPENvbW1hbmREZXRhaWxzPigpIHsKKyAgICAgICAgQE92ZXJyaWRlCiAgICAgICAgIHB1YmxpYyBDb21tYW5kRGV0YWlscyBjcmVhdGVGcm9tUGFyY2VsKFBhcmNlbCBpbikgewogICAgICAgICAgICAgcmV0dXJuIG5ldyBDb21tYW5kRGV0YWlscyhpbik7CiAgICAgICAgIH0KIAorICAgICAgICBAT3ZlcnJpZGUKICAgICAgICAgcHVibGljIENvbW1hbmREZXRhaWxzW10gbmV3QXJyYXkoaW50IHNpemUpIHsKICAgICAgICAgICAgIHJldHVybiBuZXcgQ29tbWFuZERldGFpbHNbc2l6ZV07CiAgICAgICAgIH0KICAgICB9OwogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGludCBkZXNjcmliZUNvbnRlbnRzKCkgewogICAgICAgICByZXR1cm4gMDsKICAgICB9CkBAIC04OSw2ICs5NCw3IEBACiAgICAgcHVibGljIGludCBzb3VyY2VJZDsKICAgICBwdWJsaWMgaW50IGRlc3RpbmF0aW9uSWQ7CiAKKyAgICBAT3ZlcnJpZGUKICAgICBDb21wcmVoZW5zaW9uVGx2VGFnIGdldFRhZygpIHsKICAgICAgICAgcmV0dXJuIENvbXByZWhlbnNpb25UbHZUYWcuREVWSUNFX0lERU5USVRJRVM7CiAgICAgfQpAQCAtOTksNiArMTA1LDcgQEAKICAgICBpbnQgcmVjb3JkTnVtYmVyOwogICAgIGJvb2xlYW4gc2VsZkV4cGxhbmF0b3J5OwogCisgICAgQE92ZXJyaWRlCiAgICAgQ29tcHJlaGVuc2lvblRsdlRhZyBnZXRUYWcoKSB7CiAgICAgICAgIHJldHVybiBDb21wcmVoZW5zaW9uVGx2VGFnLklDT05fSUQ7CiAgICAgfQpAQCAtMTA5LDYg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KTsKKyAgICAgICAgcmV0dXJuIEFwcEludGVyZmFjZS5Db21tYW5kVHlwZS5mcm9tSW50KG1DbWREZXQudHlwZU9mQ29tbWFuZCk7CiAgICAgfQogCiAgICAgYm9vbGVhbiBzZXRJY29uKEJpdG1hcCBpY29uKSB7IHJldHVybiB0cnVlOyB9CiAKICAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgU3RyaW5nIHRvU3RyaW5nKCkgewotICAgICAgICByZXR1cm4gY21kRGV0LnRvU3RyaW5nKCk7CisgICAgICAgIHJldHVybiBtQ21kRGV0LnRvU3RyaW5nKCk7CiAgICAgfQogfQogCiBjbGFzcyBEaXNwbGF5VGV4dFBhcmFtcyBleHRlbmRzIENvbW1hbmRQYXJhbXMgewotICAgIFRleHRNZXNzYWdlIHRleHRNc2c7CisgICAgVGV4dE1lc3NhZ2UgbVRleHRNc2c7CiAKICAgICBEaXNwbGF5VGV4dFBhcmFtcyhDb21tYW5kRGV0YWlscyBjbWREZXQsIFRleHRNZXNzYWdlIHRleHRNc2cpIHsKICAgICAgICAgc3VwZXIoY21kRGV0KTsKLSAgICAgICAgdGhpcy50ZXh0TXNnID0gdGV4dE1zZzsKKyAgICAgICAgbVRleHRNc2cgPSB0ZXh0TXNnOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIGJvb2xlYW4gc2V0SWNvbihCaXRtYXAgaWNvbikgewotICAgICAgICBpZiAoaWNvbiAhPSBudWxsICYmIHRleHRNc2cgIT0gbnVsbCkgewotICAgICAgICAgICAgdGV4dE1zZy5pY29uID0gaWNvbjsKKyAgICAgICAgaWYgKGljb24gIT0gbnVsbCAmJiBtVGV4dE1zZyAhPSBudWxsKSB7CisgICAgICAgICAgICBtVGV4dE1zZy5pY29uID0gaWNvbjsKICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICB9CiAgICAgICAgIHJldHVybiBmYWxzZTsKQEAgLTU5LDIxICs2MCwyMiBAQAogfQogCiBjbGFzcyBMYXVuY2hCcm93c2VyUGFyYW1zIGV4dGVuZHMgQ29tbWFuZFBhcmFtcyB7Ci0gICAgVGV4dE1lc3NhZ2UgY29uZmlybU1zZzsKLSAgICBMYXVuY2hCcm93c2VyTW9kZSBtb2RlOwotICAgIFN0cmluZyB1cmw7CisgICAgVGV4dE1lc3NhZ2UgbUNvbmZpcm1Nc2c7CisgICAgTGF1bmNoQnJvd3Nlck1vZGUgbU1vZGU7CisgICAgU3RyaW5nIG1Vcmw7CiAKICAgICBMYXVuY2hCcm93c2VyUGFyYW1zKENvbW1hbmREZXRhaWxzIGNtZERldCwgVGV4dE1lc3NhZ2UgY29uZmlybU1zZywKICAgICAgICAgICAgIFN0cmluZyB1cmwsIExhdW5jaEJyb3dzZXJNb2RlIG1vZGUpIHsKICAgICAgICAgc3VwZXIoY21kRGV0KTsKLSAgICAgICAgdGhpcy5jb25maXJtTXNnID0gY29uZmlybU1zZzsKLSAgICAgICAgdGhpcy5tb2RlID0gbW9kZTsKLSAgICAgICAgdGhpcy51cmwgPSB1cmw7CisgICAgICAgIG1Db25maXJtTXNnID0gY29uZmlybU1zZzsKKyAgICAgICAgbU1vZGUgPSBtb2RlOworICAgICAgICBtVXJsID0gdXJsOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIGJvb2xlYW4gc2V0SWNvbihCaXRtYXAgaWNvbikgewotICAgICAgICBpZiAoaWNvbiAhPSBudWxsICYmIGNvbmZpcm1Nc2cgIT0gbnVsbCkgewotICAgICAgICAgICAgY29uZmlybU1zZy5pY29uID0gaWNvbjsKKyAgICAgICAgaWYgKGljb24gIT0gbnVsbCAmJiBtQ29uZmlybU1zZyAhPSBudWxsKSB7CisgICAgICAgICAgICBtQ29uZmlybU1zZy5pY29uID0gaWNvbjsKICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICB9CiAgICAgICAgIHJldHVybiBmYWxzZTsKQEAgLTgxLDE5ICs4MywyMCBAQAogfQogCiBjbGFzcyBQbGF5VG9uZVBhcmFtcyBleHRlbmRzIENvbW1hbmRQYXJhbXMgewotICAgIFRleHRNZXNzYWdlIHRleHRNc2c7Ci0gICAgVG9uZVNldHRpbmdzIHNldHRpbmdzOworICAgIFRleHRNZXNzYWdlIG1UZXh0TXNnOworICAgIFRvbmVTZXR0aW5ncyBtU2V0dGluZ3M7CiAKICAgICBQbGF5VG9uZVBhcmFtcyhDb21tYW5kRGV0YWlscyBjbWREZXQsIFRleHRNZXNzYWdlIHRleHRNc2csCiAgICAgICAgICAgICBUb25lIHRvbmUsIER1cmF0aW9uIGR1cmF0aW9uLCBib29sZWFuIHZpYnJhdGUpIHsKICAgICAgICAgc3VwZXIoY21kRGV0KTsKLSAgICAgICAgdGhpcy50ZXh0TXNnID0gdGV4dE1zZzsKLSAgICAgICAgdGhpcy5zZXR0aW5ncyA9IG5ldyBUb25lU2V0dGluZ3MoZHVyYXRpb24sIHRvbmUsIHZpYnJhdGUpOworICAgICAgICBtVGV4dE1zZyA9IHRleHRNc2c7CisgICAgICAgIG1TZXR0aW5ncyA9IG5ldyBUb25lU2V0dGluZ3MoZHVyYXRpb24sIHRvbmUsIHZpYnJhdGUpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIGJvb2xlYW4gc2V0SWNvbihCaXRtYXAgaWNvbikgewotICAgICAgICBpZiAoaWNvbiAhPSBudWxsICYmIHRleHRNc2cgIT0gbnVsbCkgewotICAgICAgICAgICAgdGV4dE1zZy5pY29uID0gaWNvbjsKKyAgICAgICAgaWYgKGljb24gIT0gbnVsbCAmJiBtVGV4dE1zZyAhPSBudWxsKSB7CisgICAgICAgICAgICBtVGV4dE1zZy5pY29uID0gaWNvbjsKICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICB9CiAgICAgICAgIHJldHVybiBmYWxzZTsKQEAgLTEwMSwyNSArMTA0LDI2IEBACiB9CiAKIGNsYXNzIENhbGxTZXR1cFBhcmFtcyBleHRlbmRzIENvbW1hbmRQYXJhbXMgewotICAgIFRleHRNZXNz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yAhPSBudWxsICYmIG1DYWxsTXNnLmljb24gPT0gbnVsbCkgeworICAgICAgICAgICAgbUNhbGxNc2cuaWNvbiA9IGljb247CiAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgfQogICAgICAgICByZXR1cm4gZmFsc2U7CkBAIC0xMjcsMjEgKzEzMSwyMiBAQAogfQogCiBjbGFzcyBTZWxlY3RJdGVtUGFyYW1zIGV4dGVuZHMgQ29tbWFuZFBhcmFtcyB7Ci0gICAgTWVudSBtZW51ID0gbnVsbDsKLSAgICBib29sZWFuIGxvYWRUaXRsZUljb24gPSBmYWxzZTsKKyAgICBNZW51IG1NZW51ID0gbnVsbDsKKyAgICBib29sZWFuIG1Mb2FkVGl0bGVJY29uID0gZmFsc2U7CiAKICAgICBTZWxlY3RJdGVtUGFyYW1zKENvbW1hbmREZXRhaWxzIGNtZERldCwgTWVudSBtZW51LCBib29sZWFuIGxvYWRUaXRsZUljb24pIHsKICAgICAgICAgc3VwZXIoY21kRGV0KTsKLSAgICAgICAgdGhpcy5tZW51ID0gbWVudTsKLSAgICAgICAgdGhpcy5sb2FkVGl0bGVJY29uID0gbG9hZFRpdGxlSWNvbjsKKyAgICAgICAgbU1lbnUgPSBtZW51OworICAgICAgICBtTG9hZFRpdGxlSWNvbiA9IGxvYWRUaXRsZUljb247CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgYm9vbGVhbiBzZXRJY29uKEJpdG1hcCBpY29uKSB7Ci0gICAgICAgIGlmIChpY29uICE9IG51bGwgJiYgbWVudSAhPSBudWxsKSB7Ci0gICAgICAgICAgICBpZiAobG9hZFRpdGxlSWNvbiAmJiBtZW51LnRpdGxlSWNvbiA9PSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgbWVudS50aXRsZUljb24gPSBpY29uOworICAgICAgICBpZiAoaWNvbiAhPSBudWxsICYmIG1NZW51ICE9IG51bGwpIHsKKyAgICAgICAgICAgIGlmIChtTG9hZFRpdGxlSWNvbiAmJiBtTWVudS50aXRsZUljb24gPT0gbnVsbCkgeworICAgICAgICAgICAgICAgIG1NZW51LnRpdGxlSWNvbiA9IGljb247CiAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgIGZvciAoSXRlbSBpdGVtIDogbWVudS5pdGVtcykgeworICAgICAgICAgICAgICAgIGZvciAoSXRlbSBpdGVtIDogbU1lbnUuaXRlbXMpIHsKICAgICAgICAgICAgICAgICAgICAgaWYgKGl0ZW0uaWNvbiAhPSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgfQpAQCAtMTU2LDE2ICsxNjEsMTcgQEAKIH0KIAogY2xhc3MgR2V0SW5wdXRQYXJhbXMgZXh0ZW5kcyBDb21tYW5kUGFyYW1zIHsKLSAgICBJbnB1dCBpbnB1dCA9IG51bGw7CisgICAgSW5wdXQgbUlucHV0ID0gbnVsbDsKIAogICAgIEdldElucHV0UGFyYW1zKENvbW1hbmREZXRhaWxzIGNtZERldCwgSW5wdXQgaW5wdXQpIHsKICAgICAgICAgc3VwZXIoY21kRGV0KTsKLSAgICAgICAgdGhpcy5pbnB1dCA9IGlucHV0OworICAgICAgICBtSW5wdXQgPSBpbnB1dDsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBib29sZWFuIHNldEljb24oQml0bWFwIGljb24pIHsKLSAgICAgICAgaWYgKGljb24gIT0gbnVsbCAmJiBpbnB1dCAhPSBudWxsKSB7Ci0gICAgICAgICAgICBpbnB1dC5pY29uID0gaWNvbjsKKyAgICAgICAgaWYgKGljb24gIT0gbnVsbCAmJiBtSW5wdXQgIT0gbnVsbCkgeworICAgICAgICAgICAgbUlucHV0Lmljb24gPSBpY29uOwogICAgICAgICB9CiAgICAgICAgIHJldHVybiB0cnVlOwogICAgIH0KQEAgLTE4MCwxOCArMTg2LDE5IEBACiAgKiB0aGUgZGV0YWlscyBvZiBwcm9hY3RpdmUgY29tbWFuZHMgcHJvY2VkdXJlcyBhbmQgdGhlaXIgc3RydWN0dXJlcy4KICAqLwogY2xhc3MgQklQQ2xpZW50UGFyYW1zIGV4dGVuZHMgQ29tbWFuZFBhcmFtcyB7Ci0gICAgVGV4dE1lc3NhZ2UgdGV4dE1zZzsKLSAgICBib29sZWFuIGJIYXNBbHBoYUlkOworICAgIFRleHRNZXNzYWdlIG1UZXh0TXNnOworICAgIGJvb2xlYW4gbUhhc0FscGhhSWQ7CiAKICAgICBCSVBDbGllbnRQYXJhbXMoQ29tbWFuZERldGFpbHMgY21kRGV0LCBUZXh0TWVzc2FnZSB0ZXh0TXNnLCBib29sZWFuIGhhc19hbHBoYV9pZCkgewogICAgICAgICBzdXBlcihjbWREZXQpOwotICAgICAgICB0aGlzLnRleHRNc2cgPSB0ZXh0TXNnOwotICAgICAgICB0aGlzLmJIYXNBbHBoYUlkID0gaGFzX2FscGhhX2lkOworICAgICAgICBtVGV4dE1zZyA9IHRleHRNc2c7CisgICAgICAgIG1IYXNBbHBoYUlkID0gaGFzX2FscGhhX2lkOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIGJvb2xlYW4gc2V0SWNvbihCaXRtYXAgaWNvbikgewotICAgICAgICBpZiAoaWNvbiAhPSBudWxsICYmIHRleHRNc2cgIT0gbnVsbCkgewotICAgICAgICAgICAgdGV4dE1zZy5pY29uID0gaWNvbjsKKyAgICAgICAgaWYgKGljb24gIT0gbnVsbCAmJiBtVGV4dE1zZyAhPSBudWxsKSB7CisgICAgICAgICAgICBtVGV4dE1zZy5pY29uID0gaWNvbjsKICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICB9CiAgICAgICAgIHJldHVybiBmYWxzZTsKZGlmZiAtLWdpdCBhL3NyYy9qYXZhL2NvbS9hbmRyb2lkL2ludGVybmFsL3RlbGVwaG9ueS9jYXQvQ29tbWFuZFBhcmFtc0ZhY3RvcnkuamF2YSBiL3NyYy9qYXZhL2NvbS9hbmRyb2lkL2ludGVybmFsL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IGlkOworICAgIHByaXZhdGUgaW50IG1JZDsKIAogICAgIHB1YmxpYyBTZWxlY3RJdGVtUmVzcG9uc2VEYXRhKGludCBpZCkgewogICAgICAgICBzdXBlcigpOwotICAgICAgICB0aGlzLmlkID0gaWQ7CisgICAgICAgIG1JZCA9IGlkOwogICAgIH0KIAogICAgIEBPdmVycmlkZQpAQCAtNjEsNyArNjEsNyBAQAogICAgICAgICBpbnQgdGFnID0gMHg4MCB8IENvbXByZWhlbnNpb25UbHZUYWcuSVRFTV9JRC52YWx1ZSgpOwogICAgICAgICBidWYud3JpdGUodGFnKTsgLy8gdGFnCiAgICAgICAgIGJ1Zi53cml0ZSgxKTsgLy8gbGVuZ3RoCi0gICAgICAgIGJ1Zi53cml0ZShpZCk7IC8vIGlkZW50aWZpZXIgb2YgaXRlbSBjaG9zZW4KKyAgICAgICAgYnVmLndyaXRlKG1JZCk7IC8vIGlkZW50aWZpZXIgb2YgaXRlbSBjaG9zZW4KICAgICB9CiB9CiAKQEAgLTc5LDE5ICs3OSwxOSBAQAogCiAgICAgcHVibGljIEdldElua2V5SW5wdXRSZXNwb25zZURhdGEoU3RyaW5nIGluRGF0YSwgYm9vbGVhbiB1Y3MyLCBib29sZWFuIHBhY2tlZCkgewogICAgICAgICBzdXBlcigpOwotICAgICAgICB0aGlzLm1Jc1VjczIgPSB1Y3MyOwotICAgICAgICB0aGlzLm1Jc1BhY2tlZCA9IHBhY2tlZDsKLSAgICAgICAgdGhpcy5tSW5EYXRhID0gaW5EYXRhOwotICAgICAgICB0aGlzLm1Jc1llc05vID0gZmFsc2U7CisgICAgICAgIG1Jc1VjczIgPSB1Y3MyOworICAgICAgICBtSXNQYWNrZWQgPSBwYWNrZWQ7CisgICAgICAgIG1JbkRhdGEgPSBpbkRhdGE7CisgICAgICAgIG1Jc1llc05vID0gZmFsc2U7CiAgICAgfQogCiAgICAgcHVibGljIEdldElua2V5SW5wdXRSZXNwb25zZURhdGEoYm9vbGVhbiB5ZXNOb1Jlc3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25zdGFudHMuU3RhdGUuSURMRSAmJgorICAgICAgICAgICAgICAgICAgICBpZiAobUNULm1TdGF0ZSAhPSBQaG9uZUNvbnN0YW50cy5TdGF0ZS5JRExFICYmCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIW1TU1QuaXNDb25jdXJyZW50Vm9pY2VBbmREYXRhQWxsb3dlZCgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICByZXQgPSBQaG9uZUNvbnN0YW50cy5EYXRhU3RhdGUuU1VTUEVOREVEOwogICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewpAQCAtMTQxLDcgKzEzOSw2IEBACiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAKLSAgICAgICAgICAgICAgICBjYXNlIElOSVRJTkc6CiAgICAgICAgICAgICAgICAgY2FzZSBDT05ORUNUSU5HOgogICAgICAgICAgICAgICAgIGNhc2UgU0NBTk5JTkc6CiAgICAgICAgICAgICAgICAgICAgIHJldCA9IFBob25lQ29uc3RhbnRzLkRhdGFTdGF0ZS5DT05ORUNUSU5HOwpAQCAtMTY3LDcgKzE2NCw3IEBACiAgICAgICAgIC8vIGdldCB0aGUgbWVzc2FnZQogICAgICAgICBNZXNzYWdlIG1zZyA9IG9idGFpbk1lc3NhZ2UoRVZFTlRfU0VUX05FVFdPUktfTUFOVUFMX0NPTVBMRVRFLCBuc20pOwogCi0gICAgICAgIG1DTS5zZXROZXR3b3JrU2VsZWN0aW9uTW9kZU1hbnVhbChuZXR3b3JrLmdldE9wZXJhdG9yTnVtZXJpYygpLCBtc2cpOworICAgICAgICBtQ2kuc2V0TmV0d29ya1NlbGVjdGlvbk1vZGVNYW51YWwobmV0d29yay5nZXRPcGVyYXRvck51bWVyaWMoKSwgbXNnKTsKICAgICB9CiAKICAgICAvKioKQEAgLTE3Nyw3ICsxNzQsNyBAQAogICAgICAgICAvLyBsb29rIGZvciBvdXIgd3JhcHBlciB3aXRoaW4gdGhlIGFzeW5jcmVzdWx0LCBza2lwIHRoZSByZXN0IGlmIGl0CiAgICAgICAgIC8vIGlzIG51bGwuCiAgICAgICAgIGlmICghKGFyLnVzZXJPYmogaW5zdGFuY2VvZiBOZXR3b3JrU2VsZWN0TWVzc2FnZSkpIHsKLSAgICAgICAgICAgIFJsb2cuZShMT0dfVEFHLCAidW5leHBlY3RlZCByZXN1bHQgZnJvbSB1c2VyIG9iamVjdC4iKTsKKyAgICAgICAgICAgIGxvZ2UoInVuZXhwZWN0ZWQgcmVzdWx0IGZyb20gdXNlciBvYmplY3QuIik7CiAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgIH0KIApAQCAtMjAwLDcgKzE5Nyw3IEBACiAKICAgICAgICAgLy8gY29tbWl0IGFuZCBsb2cgdGhlIHJlc3VsdC4KICAgICAgICAgaWYgKCEgZWRpdG9yLmNvbW1pdCgpKSB7Ci0gICAgICAgICAgICBSbG9nLmUoTE9HX1RBRywgImZhaWxlZCB0byBjb21taXQgbmV0d29yayBzZWxlY3Rpb24gcHJlZmVyZW5jZSIpOworICAgICAgICAgICAgbG9nZSgiZmFpbGVkIHRvIGNvbW1pdCBuZXR3b3JrIHNlbGVjdGlvbiBwcmVmZXJlbmNlIik7CiAgICAgICAgIH0KIAogICAgIH0KQEAgLTIxOCw3ICsyMTUsNyBAQAogICAgICAgICAgICAgICAgIG1Db250ZXh0LmdldENvbnRlbnRSZXNvbHZlcigpLmluc2VydCh1cmksIG1hcCk7CiAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICB9IGNhdGNoIChTUUxFeGNlcHRpb24gZSkgewotICAgICAgICAgICAgICAgIFJsb2cuZShMT0dfVEFHLCAiW0NETUFMVEVQaG9uZV0gQ2FuJ3Qgc3RvcmUgY3VycmVudCBvcGVyYXRvciByZXQgZmFsc2UiLCBlKTsKKyAgICAgICAgICAgICAgICBsb2dlKCJDYW4ndCBzdG9yZSBjdXJyZW50IG9wZXJhdG9yIHJldCBmYW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mhhbmNlZFZvaWNlUHJpdmFjeShib29sZWFuIGVuYWJsZSwgTWVzc2FnZSBvbkNvbXBsZXRlKSB7Ci0gICAgICAgIHRoaXMubUNNLnNldFByZWZlcnJlZFZvaWNlUHJpdmFjeShlbmFibGUsIG9uQ29tcGxldGUpOworICAgICAgICBtQ2kuc2V0UHJlZmVycmVkVm9pY2VQcml2YWN5KGVuYWJsZSwgb25Db21wbGV0ZSk7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgZ2V0RW5oYW5jZWRWb2ljZVByaXZhY3koTWVzc2FnZSBvbkNvbXBsZXRlKSB7Ci0gICAgICAgIHRoaXMubUNNLmdldFByZWZlcnJlZFZvaWNlUHJpdmFjeShvbkNvbXBsZXRlKTsKKyAgICAgICAgbUNpLmdldFByZWZlcnJlZFZvaWNlUHJpdmFjeShvbkNvbXBsZXRlKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBjbGVhckRpc2Nvbm5lY3RlZCgpIHsKICAgICAgICAgbUNULmNsZWFyRGlzY29ubmVjdGVkKCk7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIERhdGFBY3Rpdml0eVN0YXRlIGdldERhdGFBY3Rpdml0eVN0YXRlKCkgewogICAgICAgICBEYXRhQWN0aXZpdHlTdGF0ZSByZXQgPSBEYXRhQWN0aXZpdHlTdGF0ZS5OT05FOwogCkBAIC0zNTIsMTEgKzM1OSwxNiBAQAogICAgICAgICAgICAgICAgIGNhc2UgRE9STUFOVDoKICAgICAgICAgICAgICAgICAgICAgcmV0ID0gRGF0YUFjdGl2aXR5U3RhdGUuRE9STUFOVDsKICAgICAgICAgICAgICAgICBicmVhazsKKworICAgICAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgICAgIHJldCA9IERhdGFBY3Rpdml0eVN0YXRlLk5PTkU7CisgICAgICAgICAgICAgICAgYnJlYWs7CiAgIC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cmV0dXJuICIwIjsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgU3RyaW5nIGdldFN1YnNjcmliZXJJZCgpIHsKICAgICAgICAgcmV0dXJuIG1TU1QuZ2V0SW1zaSgpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdHJpbmcgZ2V0SW1laSgpIHsKICAgICAgICAgUmxvZy5lKExPR19UQUcsICJJTUVJIGlzIG5vdCBhdmFpbGFibGUgaW4gQ0RNQSIpOwogICAgICAgICByZXR1cm4gbnVsbDsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgYm9vbGVhbiBjYW5Db25mZXJlbmNlKCkgewogICAgICAgICBSbG9nLmUoTE9HX1RBRywgImNhbkNvbmZlcmVuY2U6IG5vdCBwb3NzaWJsZSBpbiBDRE1BIik7CiAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgQ2VsbExvY2F0aW9uIGdldENlbGxMb2NhdGlvbigpIHsKLSAgICAgICAgcmV0dXJuIG1TU1QuY2VsbExvYzsKKyAgICAgICAgcmV0dXJuIG1TU1QubUNlbGxMb2M7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIENkbWFDYWxsIGdldEZvcmVncm91bmRDYWxsKCkgewotICAgICAgICByZXR1cm4gbUNULmZvcmVncm91bmRDYWxsOworICAgICAgICByZXR1cm4gbUNULm1Gb3JlZ3JvdW5kQ2FsbDsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZAogICAgIHNlbGVjdE5ldHdvcmtNYW51YWxseShPcGVyYXRvckluZm8gbmV0d29yaywKICAgICAgICAgICAgIE1lc3NhZ2UgcmVzcG9uc2UpIHsKICAgICAgICAgUmxvZy5lKExPR19UQUcsICJzZWxlY3ROZXR3b3JrTWFudWFsbHk6IG5vdCBwb3NzaWJs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cy5EYXRhU3RhdGUgcmV0ID0gUGhvbmVDb25zdGFudHMuRGF0YVN0YXRlLkRJU0NPTk5FQ1RFRDsKIApAQCAtNjI3LDcgKzY4Miw3IEBACiAKICAgICAgICAgICAgICAgICBjYXNlIENPTk5FQ1RFRDoKICAgICAgICAgICAgICAgICBjYXNlIERJU0NPTk5FQ1RJTkc6Ci0gICAgICAgICAgICAgICAgICAgIGlmICggbUNULnN0YXRlICE9IFBob25lQ29uc3RhbnRzLlN0YXRlLklETEUKKyAgICAgICAgICAgICAgICAgICAgaWYgKCBtQ1QubVN0YXRlICE9IFBob25lQ29uc3RhbnRzLlN0YXRlLklETEUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAmJiAhbVNTVC5pc0NvbmN1cnJlbnRWb2ljZUFuZERhdGFBbGxvd2VkKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIHJldCA9IFBob25lQ29uc3RhbnRzLkRhdGFTdGF0ZS5TVVNQRU5ERUQ7CiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CkBAIC02MzUsNyArNjkwLDYgQEAKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIGJyZWFrOwogCi0gICAgICAgICAgICAgICAgY2FzZSBJTklUSU5HOgogICAgICAgICAgICAgICAgIGNhc2UgQ09OTkVDVElORzoKICAgICAgICAgICAgICAgICBjYXNlIFNDQU5OSU5HOgogICAgICAgICAgICAgICAgICAgICByZXQgPSBQaG9uZUNvbnN0YW50cy5EYXRhU3RhdGUuQ09OTkVDVElORzsKQEAgLTY0NywzNCArNzAxLDM5IEBACiAgICAgICAgIHJldHVybiByZXQ7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgc2VuZFVzc2RSZXNwb25zZShTdHJpbmcgdXNzZE1lc3NnZSkgewogICAgICAgICBSbG9nLmUoTE9HX1RBRywgInNlbmRVc3NkUmVzcG9uc2U6IG5vdCBwb3NzaWJsZSBpbiBDRE1BIik7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgc2VuZER0bWYoY2hhciBjKSB7CiAgICAgICAgIGlmICghUGhvbmVOdW1iZXJVdGlscy5pczEyS2V5KGMpKSB7CiAgICAgICAgICAgICBSbG9nLmUoTE9HX1RBRywKICAgICAgICAgICAgICAgICAgICAgInNlbmREdG1mIGNhbGxlZCB3aXRoIGludmFsaWQgY2hhcmFjdGVyICciICsgYyArICInIik7CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICBpZiAobUNULnN0YXRlID09ICBQaG9uZUNvbnN0YW50cy5TdGF0ZS5PRkZIT09LKSB7Ci0gICAgICAgICAgICAgICAgbUNNLnNlbmREdG1mKGMsIG51bGwpOworICAgICAgICAgICAgaWYgKG1DVC5tU3RhdGUgPT0gIFBob25lQ29uc3RhbnRzLlN0YXRlLk9GRkhPT0spIHsKKyAgICAgICAgICAgICAgICBtQ2kuc2VuZER0bWYoYywgbnVsbCk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBzdGFydER0bWYoY2hhciBjKSB7CiAgICAgICAgIGlmICghUGhvbmVOdW1iZXJVdGlscy5pczEyS2V5KGMpKSB7CiAgICAgICAgICAgICBSbG9nLmUoTE9HX1RBRywKICAgICAgICAgICAgICAgICAgICAgInN0YXJ0RHRtZiBjYWxsZWQgd2l0aCBpbnZhbGlkIGNoYXJhY3RlciAnIiArIGMgKyAiJyIpOwogICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgbUNNLnN0YXJ0RHRtZihjLCBudWxsKTsKKyAgICAgICAgICAgIG1DaS5zdGFydER0bWYoYywgbnVsbCk7CiAgICAgICAgIH0KICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBzdG9wRHRtZigpIHsKLSAgICAgICAgbUNNLnN0b3BEdG1mKG51bGwpOworICAgIC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c3NhZ2Ugb25Db21wbGV0ZSkgewogICAgICAgICBSbG9nLmUoTE9HX1RBRywgInNldE91dGdvaW5nQ2FsbGVySWREaXNwbGF5OiBub3QgcG9zc2libGUgaW4gQ0RNQSIpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIGVuYWJsZUxvY2F0aW9uVXBkYXRlcygpIHsKICAgICAgICAgbVNTVC5lbmFibGVMb2NhdGlvblVwZGF0ZXMoKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBkaXNhYmxlTG9jYXRpb25VcGRhdGVzKCkgewogICAgICAgICBtU1NULmRpc2FibGVMb2NhdGlvblVwZGF0ZXMoKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBnZXREYXRhQ2FsbExpc3QoTWVzc2FnZSByZXNwb25zZSkgewotICAgICAgICBtQ00uZ2V0RGF0YUNhbGxMaXN0KHJlc3BvbnNlKTsKKyAgICAgICAgbUNpLmdldERhdGFDYWxsTGlzdChyZXNwb25zZSk7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGJvb2xlYW4gZ2V0RGF0YVJvYW1pbmdFbmFibGVkKCkgewogICAgICAgICByZXR1cm4gbURhdGFDb25uZWN0aW9uVHJhY2tlci5nZXREYXRhT25Sb2FtaW5nRW5hYmxlZCgpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHNldFZvaWNlTWFpbE51bWJlcihTdHJpbmcgYWxwaGFUYWcsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZyB2b2ljZU1haWxOdW1iZXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1lc3NhZ2Ugb25Db21wbGV0ZSkgewpAQCAtNzI2LDYgKzc5Miw3IEBACiAgICAgICAgIH0KICAgICB9CiAKKyAgICBAT3Zl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wogCi0gICAgICAgICAgICAgICAgbUNNLmdldERldmljZUlkZW50aXR5KG9idGFpbk1lc3NhZ2UoRVZFTlRfR0VUX0RFVklDRV9JREVOVElUWV9ET05FKSk7CisgICAgICAgICAgICAgICAgbUNpLmdldERldmljZUlkZW50aXR5KG9idGFpbk1lc3NhZ2UoRVZFTlRfR0VUX0RFVklDRV9JREVOVElUWV9ET05FKSk7CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBicmVhazsKIApAQCAtMTEyMSw2ICsxMjAyLDcgQEAKICAgICAvKioKICAgICAgKiBSZXRyaWV2ZXMgdGhlIFBob25lU3ViSW5mbyBvZiB0aGUgQ0RNQVBob25lCiAgICAgICovCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFBob25lU3ViSW5mbyBnZXRQaG9uZVN1YkluZm8oKSB7CiAgICAgICAgIHJldHVybiBtU3ViSW5mbzsKICAgICB9CkBAIC0xMTI4LDYgKzEyMTAsNyBAQAogICAgIC8qKgogICAgICAqIFJldHJpZXZlcyB0aGUgSWNjU21zSW50ZXJmYWNlTWFuYWdlciBvZiB0aGUgQ0RNQVBob25lCiAgICAgICovCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIEljY1Ntc0ludGVyZmFjZU1hbmFnZXIgZ2V0SWNjU21zSW50ZXJmYWNlTWFuYWdlcigpIHsKICAgICAgICAgcmV0dXJuIG1SdWltU21zSW50ZXJmYWNlTWFuYWdlcjsKICAgICB9CkBAIC0xMTM1LDYgKzEyMTgsNyBAQAogICAgIC8qKgogICAgICAqIFJldHJpZXZlcyB0aGUgSWNjUGhvbmVCb29rSW50ZXJmYWNlTWFuYWdlciBvZiB0aGUgQ0RNQVBob25lCiAgICAgICovCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIEljY1Bob25lQm9va0ludGVyZmFjZU1hbmFnZXIgZ2V0SWNjUGhvbmVCb29rSW50ZXJmYWNlTWFuYWdlcigpIHsKICAgICAgICAgcmV0dXJuIG1SdWltUGhvbm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AgaW50IHNlbE1pbiA9IEludGVnZXIucGFyc2VJbnQoKFN0cmluZylzY2hbaSsyXSk7Ci0gICAgICAgICAgICAgICAgICAgIGludCBzZWxNYXggPSBJbnRlZ2VyLnBhcnNlSW50KChTdHJpbmcpc2NoW2krM10pOworICAgICAgICAgICAgICAgICAgICBpbnQgc2VsTWluID0gSW50ZWdlci5wYXJzZUludChzY2hbaSsyXSk7CisgICAgICAgICAgICAgICAgICAgIGludCBzZWxNYXggPSBJbnRlZ2VyLnBhcnNlSW50KHNjaFtpKzNdKTsKICAgICAgICAgICAgICAgICAgICAgLy8gQ2hlY2sgaWYgdGhlIHNlbGVjdGlvbiBjb2RlIGV4dHJhY3RlZCBmcm9tIHRoZSBkaWFsIHN0cmluZyBmYWxscwogICAgICAgICAgICAgICAgICAgICAvLyB3aXRoaW4gYW55IG9mIHRoZSByYW5nZSBwYWlycyBzcGVjaWZpZWQgaW4gdGhlIHNjaGVtYS4KICAgICAgICAgICAgICAgICAgICAgaWYgKChzeXNTZWxDb2RlSW50ID49IHNlbE1pbikgJiYgKHN5c1NlbENvZGVJbnQgPD0gc2VsTWF4KSkgewpAQCAtMTMzNyw4ICsxNDI1LDggQEAKICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIVRleHRVdGlscy5pc0VtcHR5KHNjaFswXSkgJiYgc2NoWzBdLmVxdWFscygiRkMiKSkgewotICAgICAgICAgICAgICAgICAgICBpbnQgZmNMZW4gPSAgSW50ZWdlci5wYXJzZUludCgoU3RyaW5nKXNjaFsxXSk7Ci0gICAgICAgICAgICAgICAgICAgIFN0cmluZyBmYyA9IChTdHJpbmcpc2NoWzJdOworICAgICAgICAgICAgICAgICAgICBpbnQgZmNMZW4gPSAgSW50ZWdlci5wYXJzZUludChzY2hbMV0pOworICAgICAgICAgICAgICAgICAgICBTdHJpbmcgZmMgPSBzY2hbMl07CiAgICAgICAgICAg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GVwaG9ueS5Db25uZWN0aW9uOwogaW1wb3J0IGNvbS5hbmRyb2lkLmludGVybmFsLnRlbGVwaG9ueS5Ecml2ZXJDYWxsOwogaW1wb3J0IGNvbS5hbmRyb2lkLmludGVybmFsLnRlbGVwaG9ueS5QaG9uZTsKLWltcG9ydCBjb20uYW5kcm9pZC5pbnRlcm5hbC50ZWxlcGhvbnkuQ2FsbC5TdGF0ZTsKIAogLyoqCiAgKiB7QGhpZGV9CkBAIC0zMiw5ICszMCw3IEBACiBwdWJsaWMgZmluYWwgY2xhc3MgQ2RtYUNhbGwgZXh0ZW5kcyBDYWxsIHsKICAgICAvKioqKioqKioqKioqKioqKioqKioqKioqKioqIEluc3RhbmNlIFZhcmlhYmxlcyAqKioqKioqKioqKioqKioqKioqKioqKioqKi8KIAotICAgIC8qcGFja2FnZSovIEFycmF5TGlzdDxDb25uZWN0aW9uPiBjb25uZWN0aW9ucyA9IG5ldyBBcnJheUxpc3Q8Q29ubmVjdGlvbj4oKTsKLSAgICAvKnBhY2thZ2UqLyBTdGF0ZSBzdGF0ZSA9IFN0YXRlLklETEU7Ci0gICAgLypwYWNrYWdlKi8gQ2RtYUNhbGxUcmFja2VyIG93bmVyOworICAgIC8qcGFja2FnZSovIENkbWFDYWxsVHJhY2tlciBtT3duZXI7CiAKICAgICAvKioqKioqKioqKioqKioqKioqKioqKioqKioqKiogQ2xhc3MgTWV0aG9kcyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KIApAQCAtNTUsNjEgKzUxLDYxIEBACiAgICAgLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiBDb25zdHJ1Y3RvcnMgKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCiAgICAgLypwYWNrYWdlKi8KICAgICBDZG1hQ2FsbCAoQ2RtYUNhbGxUcmFja2VyIG93bmVyKSB7Ci0gICAgICAgIHRoaXMub3duZXIgPSBvd25lcjsKKyAgICAgICAgbU93bmVyID0gb3duZXI7CiAgICAgfQogCiAgICAgcHVibGljIHZvaWQgZGlzcG9zZSgpIHsKICAgICB9CiAKICAgICAvKioqKioqKioqKioqKioqKioqKioqKioqKiogT3ZlcnJpZGRlbiBmcm9tIENhbGwgKioqKioqKioqKioqKioqKioqKioqKioqKi8KKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgTGlzdDxDb25uZWN0aW9uPgogICAgIGdldENvbm5lY3Rpb25zKCkgewogICAgICAgICAvLyBGSVhNRSBzaG91bGQgcmV0dXJuIENvbGxlY3Rpb25zLnVubW9kaWZpYWJsZUxpc3QoKTsKLSAgICAgICAgcmV0dXJuIGNvbm5lY3Rpb25zOworICAgICAgICByZXR1cm4gbUNvbm5lY3Rpb25zOwogICAgIH0KIAotICAgIHB1YmxpYyBTdGF0ZQotICAgIGdldFN0YXRlKCkgewotICAgICAgICByZXR1cm4gc3RhdGU7Ci0gICAgfQotCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFBob25lCiAgICAgZ2V0UGhvbmUoKSB7Ci0gICAgICAgIHJldHVybiBvd25lci5waG9uZTsKKyAgICAgICAgcmV0dXJuIG1Pd25lci5tUGhvbmU7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGJvb2xlYW4gaXNNdWx0aXBhcnR5KCkgewotICAgICAgICByZXR1cm4gY29ubmVjdGlvbnMuc2l6ZSgpID4gMTsKKyAgICAgICAgcmV0dXJuIG1Db25uZWN0aW9ucy5zaXplKCkgPiAxOwogICAgIH0KIAogICAgIC8qKiBQbGVhc2Ugbm90ZTogaWYgdGhpcyBpcyB0aGUgZm9yZWdyb3VuZCBjYWxsIGFuZCBhCiAgICAgICogIGJhY2tncm91bmQgY2FsbCBleGlzdHMsIHRoZSBiYWNrZ3JvdW5kIGNhbGwgd2lsbCBiZSByZXN1bWVkCiAgICAgICogIGJlY2F1c2UgYW4gQVQrQ0hMRD0xIHdpbGwgYmUgc2VudAogICAgICAqLworICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b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dGUgIT0gU3RhdGUuRElTQ09OTkVDVEVEKSB7CisgICAgICAgIGlmIChtU3RhdGUgIT0gU3RhdGUuRElTQ09OTkVDVEVEKSB7CiAgICAgICAgICAgICAvKiBJZiBvbmx5IGRpc2Nvbm5lY3RlZCBjb25uZWN0aW9ucyByZW1haW4sIHdlIGFyZSBkaXNjb25uZWN0ZWQqLwogCiAgICAgICAgICAgICBib29sZWFuIGhhc09ubHlEaXNjb25uZWN0ZWRDb25uZWN0aW9ucyA9IHRydWU7CiAKLSAgICAgICAgICAgIGZvciAoaW50IGkgPSAwLCBzID0gY29ubmVjdGlvbnMuc2l6ZSgpICA7IGkgPCBzOyBpICsrKSB7Ci0gICAgICAgICAgICAgICAgaWYgKGNvbm5lY3Rpb25zLmdldChpKS5nZXRTdGF0ZSgpCisgICAgICAgICAgICBmb3IgKGludCBpID0gMCwgcyA9IG1Db25uZWN0aW9ucy5zaXplKCkgIDsgaSA8IHM7IGkgKyspIHsKKyAgICAgICAgICAgICAgICBpZiAobUNvbm5lY3Rpb25zLmdldChpKS5nZXRTdGF0ZSgpCiAgICAgICAgICAgICAgICAgICAgICE9IFN0YXRlLkRJU0NPTk5FQ1RFRAogICAgICAgICAgICAgICAgICkgewogICAgICAgICAgICAgICAgICAgICBoYXNPbmx5RGlzY29ubmVjdGVkQ29ubmVjdGlvbnMgPSBmYWxzZTsKQEAgLTEzMiw3ICsxMjgsNyBAQAogICAgICAgICAgICAgfQogCiAgICAgICAgICAgICBpZiAoaGFzT25seURpc2Nvbm5lY3RlZENvbm5lY3Rpb25zKSB7Ci0gICAgICAgICAgICAgICAgc3RhdGUgPSBTdGF0ZS5ESVNDT05ORUNURUQ7CisgICAgICAgICAgICAgICAgbVN0YXRlID0gU3RhdGUuRElTQ09OTkVDVEVEOwogICAgICAgICAgICAgfQogICAgICAgICB9CiAgICAgfQpAQCAtMTQwLDEwICsxMzYsMTAgQEAKIAogICAgIC8qcGFja2FnZSovIHZvaWQKICAgICBkZXRhY2goQ2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NJZGxlKCkpIHsKKyAgICAgICAgaWYgKCFtRm9yZWdyb3VuZENhbGwuaXNJZGxlKCkpIHsKICAgICAgICAgICAgIC8vIENoZWNrIGRhdGEgY2FsbAogICAgICAgICAgICAgZGlzYWJsZURhdGFDYWxsSW5FbWVyZ2VuY3lDYWxsKGRpYWxTdHJpbmcpOwogCiAgICAgICAgICAgICAvLyBBdHRhY2ggdGhlIG5ldyBjb25uZWN0aW9uIHRvIGZvcmVncm91bmRDYWxsCi0gICAgICAgICAgICBwZW5kaW5nTU8gPSBuZXcgQ2RtYUNvbm5lY3Rpb24ocGhvbmUuZ2V0Q29udGV4dCgpLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGVja0ZvclRlc3RFbWVyZ2VuY3lOdW1iZXIoZGlhbFN0cmluZyksIHRoaXMsIGZvcmVncm91bmRDYWxsKTsKLSAgICAgICAgICAgIGNtLnNlbmRDRE1BRmVhdHVyZUNvZGUocGVuZGluZ01PLmFkZHJlc3MsCisgICAgICAgICAgICBtUGVuZGluZ01PID0gbmV3IENkbWFDb25uZWN0aW9uKG1QaG9uZS5nZXRDb250ZXh0KCksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoZWNrRm9yVGVzdEVtZXJnZW5jeU51bWJlcihkaWFsU3RyaW5nKSwgdGhpcywgbUZvcmVncm91bmRDYWxsKTsKKyAgICAgICAgICAgIG1DaS5zZW5kQ0RNQUZlYXR1cmVDb2RlKG1QZW5kaW5nTU8ubUFkZHJlc3MsCiAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZShFVkVOVF9USFJFRV9XQVlfRElBTF9MMl9SRVNVTFRfQ0RNQSkpOwotICAgICAgICAgICAgcmV0dXJuIHBlbmRpbmdNTzsKKyAgICAgICAgICAgIHJldHVybiBtUGVuZGluZ01POwogICAgICAgICB9CiAgICAgICAgIHJldHVybiBudWxsOwogICAgIH0KIAogICAgIHZvaWQKICAgICBhY2NlcHRDYWxsKCkgdGhyb3d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WxlcGhvbnlQcm9wZXJ0aWVzLlBST1BFUlRZX0RJU0FCTEVfQ0FMTCwgImZhbHNlIik7CiAKICAgICAgICAgcmV0ID0gKHNlcnZpY2VTdGF0ZSAhPSBTZXJ2aWNlU3RhdGUuU1RBVEVfUE9XRVJfT0ZGKQotICAgICAgICAgICAgICAgICYmIHBlbmRpbmdNTyA9PSBudWxsCi0gICAgICAgICAgICAgICAgJiYgIXJpbmdpbmdDYWxsLmlzUmluZ2luZygpCisgICAgICAgICAgICAgICAgJiYgbVBlbmRpbmdNTyA9PSBudWxsCisgICAgICAgICAgICAgICAgJiYgIW1SaW5naW5nQ2FsbC5pc1JpbmdpbmcoKQogICAgICAgICAgICAgICAgICYmICFkaXNhYmxlQ2FsbC5lcXVhbHMoInRydWUiKQotICAgICAgICAgICAgICAgICYmICghZm9yZWdyb3VuZENhbGwuZ2V0U3RhdGUoKS5pc0FsaXZlKCkKLSAgICAgICAgICAgICAgICAgICAgfHwgKGZvcmVncm91bmRDYWxsLmdldFN0YXRlKCkgPT0gQ2RtYUNhbGwuU3RhdGUuQUNUSVZFKQotICAgICAgICAgICAgICAgICAgICB8fCAhYmFja2dyb3VuZENhbGwuZ2V0U3RhdGUoKS5pc0FsaXZlKCkpOworICAgICAgICAgICAgICAgICYmICghbUZvcmVncm91bmRDYWxsLmdldFN0YXRlKCkuaXNBbGl2ZSgpCisgICAgICAgICAgICAgICAgICAgIHx8IChtRm9yZWdyb3VuZENhbGwuZ2V0U3RhdGUoKSA9PSBDZG1hQ2FsbC5TdGF0ZS5BQ1RJVkUpCisgICAgICAgICAgICAgICAgICAgIHx8ICFtQmFja2dyb3VuZENhbGwuZ2V0U3RhdGUoKS5pc0FsaXZlKCkpOwogCiAgICAgICAgIGlmICghcmV0KSB7CiAgICAgICAgICAgICBsb2coU3RyaW5nLmZvcm1hdCgiY2FuRGlhbCBpcyBmYWxzZVxuIiArCkBAIC0zNzQsMTIgKzM2MywxMiBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIiAgIHx8IWJhY2tncm91bmRDYWxsLmdldFN0YXRlKCkuaXNBbGl2ZSgpKTo6PSVzKSIsCiAgICAgICAgICAgICAgICAgICAgIHNlcnZpY2VTdGF0ZSwKICAgICAgICAgICAgICAgICAgICAgc2VydmljZVN0YXRlICE9IFNlcnZpY2VTdGF0ZS5TVEFURV9QT1dFUl9PRkYsCi0gICAgICAgICAgICAgICAgICAgIHBlbmRpbmdNTyA9PSBudWxsLAotICAgICAgICAgICAgICAgICAgICAhcmluZ2luZ0NhbGwuaXNSaW5naW5nKCksCisgICAgICAgICAgICAgICAgICAgIG1QZW5kaW5nTU8gPT0gbnVsbCwKKyAgICAgICAgICAgICAgICAgICAgIW1SaW5naW5nQ2FsbC5pc1JpbmdpbmcoKSwKICAgICAgICAgICAgICAgICAgICAgIWRpc2FibGVDYWxsLmVxdWFscygidHJ1ZSIpLAotICAgICAgICAgICAgICAgICAgICAhZm9yZWdyb3VuZENhbGwuZ2V0U3RhdGUoKS5pc0FsaXZlKCksCi0gICAgICAgICAgICAgICAgICAgIGZvcmVncm91bmRDYWxsLmdldFN0YXRlKCkgPT0gQ2RtYUNhbGwuU3RhdGUuQUNUSVZFLAotICAgICAgICAgICAgICAgICAgICAhYmFja2dyb3VuZENhbGwuZ2V0U3RhdGUoKS5pc0FsaXZlKCkpKTsKKyAgICAgICAgICAgICAgICAgICAgIW1Gb3JlZ3JvdW5kQ2FsbC5nZXRTdGF0ZSgpLmlzQWxpdmUoKSwKKyAgICAgICAgICAgICAgICAgICAgbUZvcmVncm91bmRDYWxsLmdldFN0YXRlKCkgPT0gQ2RtYUNhbGwuU3RhdGUuQUNUSVZFLAorICAgICAgICAgICAgICAgICAgICAhbUJhY2tncm91bmRDYWxsLmdldFN0YXRlKCkuaXNBbGl2ZSgpKSk7CiAgICAgICAgIH0KICAgICAgICAgcmV0dXJuIHJldDsKICAgICB9CkBAIC0zOTQsOSArMzgzLDkgQEAKIAogICAgIHByaXZhdGUgdm9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aGF0KTsKICAgICB9CiAKICAgICBwcml2YXRlIHZvaWQKICAgICBvcGVyYXRpb25Db21wbGV0ZSgpIHsKLSAgICAgICAgcGVuZGluZ09wZXJhdGlvbnMtLTsKKyAgICAgICAgbVBlbmRpbmdPcGVyYXRpb25zLS07CiAKICAgICAgICAgaWYgKERCR19QT0xMKSBsb2coIm9wZXJhdGlvbkNvbXBsZXRlOiBwZW5kaW5nT3BlcmF0aW9ucz0iICsKLSAgICAgICAgICAgICAgICBwZW5kaW5nT3BlcmF0aW9ucyArICIsIG5lZWRzUG9sbD0iICsgbmVlZHNQb2xsKTsKKyAgICAgICAgICAgICAgICBtUGVuZGluZ09wZXJhdGlvbnMgKyAiLCBuZWVkc1BvbGw9IiArIG1OZWVkc1BvbGwpOwogCi0gICAgICAgIGlmIChwZW5kaW5nT3BlcmF0aW9ucyA9PSAwICYmIG5lZWRzUG9sbCkgewotICAgICAgICAgICAgbGFzdFJlbGV2YW50UG9sbCA9IG9idGFpbk1lc3NhZ2UoRVZFTlRfUE9MTF9DQUxMU19SRVNVTFQpOwotICAgICAgICAgICAgY20uZ2V0Q3VycmVudENhbGxzKGxhc3RSZWxldmFudFBvbGwpOwotICAgICAgICB9IGVsc2UgaWYgKHBlbmRpbmdPcGVyYXRpb25zIDwgMCkgeworICAgICAgICBpZiAobVBlbmRpbmdPcGVyYXRpb25zID09IDAgJiYgbU5lZWRzUG9sbCkgeworICAgICAgICAgICAgbUxhc3RSZWxldmFudFBvbGwgPSBvYnRhaW5NZXNzYWdlKEVWRU5UX1BPTExfQ0FMTFNfUkVTVUxUKTsKKyAgICAgICAgICAgIG1DaS5nZXRDdXJyZW50Q2FsbHMobUxhc3RSZWxldmFudFBvbGwpOworICAgICAgICB9IGVsc2UgaWYgKG1QZW5kaW5nT3BlcmF0aW9ucyA8IDApIHsKICAgICAgICAgICAgIC8vIHRoaXMgc2hvdWxkIG5ldmVyIGhhcHBlbgogICAgICAgICAgICAgUmxvZy5lKExPR19UQUcsIkNk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IG51bGw7CiAKICAgICAgICAgICAgIC8vIHBvbGxlZENhbGwgbGlzdCBpcyBzcGFyc2UKQEAgLTUxNywyOCArNTA3LDI4IEBACiAKICAgICAgICAgICAgIGlmIChjb25uID09IG51bGwgJiYgZGMgIT0gbnVsbCkgewogICAgICAgICAgICAgICAgIC8vIENvbm5lY3Rpb24gYXBwZWFyZWQgaW4gQ0xDQyByZXNwb25zZSB0aGF0IHdlIGRvbid0IGtub3cgYWJvdXQKLSAgICAgICAgICAgICAgICBpZiAocGVuZGluZ01PICE9IG51bGwgJiYgcGVuZGluZ01PLmNvbXBhcmVUbyhkYykpIHsKKyAgICAgICAgICAgICAgICBpZiAobVBlbmRpbmdNTyAhPSBudWxsICYmIG1QZW5kaW5nTU8uY29tcGFyZVRvKGRjKSkgewogCi0gICAgICAgICAgICAgICAgICAgIGlmIChEQkdfUE9MTCkgbG9nKCJwb2xsOiBwZW5kaW5nTU89IiArIHBlbmRpbmdNTyk7CisgICAgICAgICAgICAgICAgICAgIGlmIChEQkdfUE9MTCkgbG9nKCJwb2xsOiBwZW5kaW5nTU89IiArIG1QZW5kaW5nTU8pOwogCiAgICAgICAgICAgICAgICAgICAgIC8vIEl0J3Mgb3VyIHBlbmRpbmcgbW9iaWxlIG9yaWdpbmF0aW5nIGNhbGwKLSAgICAgICAgICAgICAgICAgICAgY29ubmVjdGlvbnNbaV0gPSBwZW5kaW5nTU87Ci0gICAgICAgICAgICAgICAgICAgIHBlbmRpbmdNTy5pbmRleCA9IGk7Ci0gICAgICAgICAgICAgICAgICAgIHBlbmRpbmdNTy51cGRhdGUoZGMpOwotICAgICAgICAgICAgICAgICAgICBwZW5kaW5nTU8gPSBudWxsOworICAgICAgICAgICAgICAgICAgICBtQ29ubmVjdGlvbnNbaV0gPSBtUGVuZGluZ01POworICAgICAgICAgICAgICAgICAgICBtUGVuZGluZ01PLm1JbmRleCA9IGk7CisgICAgICAgICAgICAgICAgICAgIG1QZW5kaW5nTU8udXBkYXRlKGRjKTsKKyAgICAgICAgICAgICAgICAgICAgbVBlbmRpbmdNTyA9IG51bGw7CiAKICAgICAgICAgICAgICAgICAgICAgLy8gU29tZW9uZSBoYXMgYWxyZWFkeSBhc2tlZCB0byBoYW5ndXAgdGhpcyBjYWxsCi0gICAgICAgICAgICAgICAgICAgIGlmIChoYW5ndXBQZW5kaW5nTU8pIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGhhbmd1cFBlbmRpbmdNTyA9IGZhbHNlOworICAgICAgICAgICAgICAgICAgICBpZiAobUhhbmd1cFBlbmRpbmdNTykgeworICAgICAgICAgICAgICAgICAgICAgICAgbUhhbmd1cFBlbmRpbmdNTyA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgLy8gUmUtc3RhcnQgRWNtIHRpbWVyIHdoZW4gYW4gdW5jb21wbGV0ZWQgZW1lcmdlbmN5IGNhbGwgZW5kcwogICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1Jc0VjbVRpbWVyQ2FuY2VsZWQpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYW5kbGVFY21UaW1lcihwaG9uZS5SRVNUQVJUX0VDTV9USU1FUik7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFuZGxlRWNtVGltZXIoQ0RNQVBob25lLlJFU1RBUlRfRUNNX1RJTUVSKTsKICAgICAgICAgICAgICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoUGhvbmUuREVCVUdfUEhPTkUpIGxvZygKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJwb2xsOiBoYW5ndXBQZW5kaW5nTU8sIGhhbmd1cCBjb25uICIgKyBpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYW5ndXAoY29ubmVjdGlvbnNbaV0pOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhbmd1cChtQ29ubmVjdGlvbnNbaV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoQ2FsbFN0YXRlRXhjZXB0aW9uIGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUmxvZy5lKExPR19UQUcsICJ1bmV4cGVjdGVkIGVycm9yIG9uIGhhbmd1cCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgfQpAQCAtNTQ5LDcgKzUzOSw3IEBACiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICBpZiAoUGhvbmUuREVCVUdfUEhPTkUpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGxvZygicGVuZGluZ01vPSIgKyBwZW5kaW5nTU8gKyAiLCBkYz0iICsgZGMpOworICAgICAgICAgICAgICAgICAgICAgICAgbG9nKCJwZW5kaW5nTW89IiArIG1QZW5kaW5nTU8gKyAiLCBkYz0iICsgZGMpOwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIC8vIGZpbmQgaWYgdGhlIE1UIGNhbGwgaXMgYSBuZXcgcmluZyBvciB1bmtub3duIGNvbm5lY3Rpb24KICAgICAgICAgICAgICAgICAgICAgbmV3UmluZ2luZyA9IGNoZWNrTXRGaW5kTmV3UmluZ2luZyhkYyxpKTsKQEAgLTU2NCwzOSArNTU0LDM5IEBACiAgICAgICAgICAgICAgICAgLy8gd2UgbmVlZCB0byBjbGVhbiB1cCB0aGUgZm9yZWdyb3VuZENhbGwgYW5kIHJpbmdpbmdDYWxsLgogICAgICAgICAgICAgICAgIC8vIExvb3AgdGhyb3VnaCBmb3JlZ3JvdW5kIGNhbGwgY29ubmVjdGlvbnMgYXMKICAgICAgICAgICAgICAgICAvLyBpdCBjb250YWlucyB0aGUga25vd24gbG9naWNhbCBjb25uZWN0aW9ucy4KLSAgICAgICAgICAgICAgICBpbnQgY291bnQgPSBmb3JlZ3JvdW5kQ2FsbC5jb25uZWN0aW9ucy5zaXplKCk7CisgICAgICAgICAgICAgICAgaW50IGNvdW50ID0gbUZvcmVncm91bmRDYWxsLm1Db25uZWN0aW9ucy5zaXplKCk7CiAgICAgICAgICAgICAgICAgZm9yIChpbnQgbiA9IDA7IG4gPCBjb3VudDsgbisrKSB7CiAgICAgICAgICAgICAgICAgICAgIGlmIChQaG9uZS5ERUJVR19QSE9ORSkgbG9nKCJhZGRpbmcgZmdDYWxsIGNuICIgKyBuICsgIiB0byBkcm9wcGVkRHVyaW5nUG9sbCIpOwotICAgICAgICAgICAgICAgICAgICBDZG1hQ29ubmVjdGlvbiBjbiA9IChDZG1hQ29ubmVjdGlvbilmb3JlZ3JvdW5kQ2FsbC5jb25uZWN0aW9ucy5nZXQobik7Ci0gICAgICAgICAgICAgICAgICAgIGRyb3BwZWREdXJpbmdQb2xsLmFkZChjbik7CisgICAgICAgICAgICAgICAgICAgIENkbWFDb25uZWN0aW9uIGNuID0gKENkbWFDb25uZWN0aW9uKW1Gb3JlZ3JvdW5kQ2FsbC5tQ29ubmVjdGlvbnMuZ2V0KG4pOworICAgICAgICAgICAgICAgICAgICBtRHJvcHBlZER1cmluZ1BvbGwuYWRkKGNuKTsKICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgY291bnQgPSByaW5naW5nQ2FsbC5jb25uZWN0aW9ucy5zaXplKCk7CisgICAgICAgICAgICAgICAgY291bnQgPSBtUmluZ2luZ0NhbGwubUNvbm5lY3Rpb25zLnNpemUoKTsKICAgICAgICAgICAgICAgICAvLyBMb29wIHRocm91Z2ggcmluZ2luZyBjYWxsIGNvbm5lY3Rpb25zIGFzCiAgICAgICAgICAgICAgICAgLy8gaXQgbWF5IGNvbnRhaW4gdGhlIGtub3duIGxvZ2ljYWwgY29ubmVjdGlvbnMuCiAgICAgICAgICAgICAgICAgZm9yIChpbnQgbiA9IDA7IG4gPCBjb3VudDsgbisrKSB7CiAgICAgICAgICAgICAgICAgICAgIGlmIChQaG9uZS5ERUJVR19QSE9ORSkgbG9nKCJhZGRpbmcgcmdDYWxsIGNuICIgKyBuICsgIiB0byBkcm9wcGVkRHVyaW5nUG9sbCIpOwotICAgICAgICAgICAgICAgICAgICBDZG1hQ29ubmVjdGlvbiBjbiA9IChDZG1hQ29ubmVjdGlvbilyaW5naW5nQ2FsbC5jb25uZWN0aW9ucy5nZXQobik7Ci0gICAgICAgICAgICAgICAgICAgIGRyb3BwZWREdXJpbmdQb2xsLmFkZChjbik7CisgICAgICAgICAgICAgICAgICAgIENkbWFDb25uZWN0aW9uIGNuID0gKENkbWFDb25uZWN0aW9uKW1SaW5naW5nQ2FsbC5tQ29ubmVjdGlvbnMuZ2V0KG4pOworICAgICAgICAgICAgICAgICAgICBtRHJvcHBlZER1cmluZ1BvbGwuYWRkKGNuKTsKICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgZm9yZWdyb3VuZENhbGwuc2V0R2VuZXJpYyhmYWxzZSk7Ci0gICAgICAgICAgICAgICAgcmluZ2luZ0NhbGwuc2V0R2VuZXJpYyhmYWxzZSk7CisgICAgICAgICAgICAgICAgbUZvcmVncm91bmRDYWxsLnNldEdlbmVyaWMoZmFsc2UpOworICAgICAgICAgICAgICAgIG1SaW5naW5nQ2FsbC5zZXRHZW5lcmljKGZhbHNlKTsKIAogICAgICAgICAgICAgICAgIC8vIFJlLXN0YXJ0IEVjbSB0aW1lciB3aGVuIHRoZSBjb25uZWN0ZWQgZW1lcmdlbmN5IGNhbGwgZW5kcwogICAgICAgICAgICAgICAgIGlmIChtSXNFY21UaW1lckNhbmNlbGVkKSB7Ci0gICAgICAgICAgICAgICAgICAgIGhhbmRsZUVjbVRpbWVyKHBob25lLlJFU1RBUlRfRUNNX1RJTUVSKTsKKyAgICAgICAgICAgICAgICAgICAgaGFuZGxlRWNtVGltZXIoQ0RNQVBob25lLlJFU1RBUlRfRUNNX1RJTUVSKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgLy8gSWYgZW1lcmdlbmN5IGNhbGwgaXMgbm90IGdvaW5nIHRocm91Z2ggd2hpbGUgZGlhbGluZwogICAgICAgICAgICAgICAgIGNoZWNrQW5kRW5hYmxlRGF0YUNhbGxBZnRlckVtZXJnZW5jeUNhbGxEcm9wcGVkKCk7CiAKICAgICAgICAgICAgICAgICAvLyBEcm9wcGVkIGNvbm5lY3Rpb25zIGFyZSByZW1vdmVkIGZyb20gdGhlIENhbGxUcmFja2VyCiAgICAgICAgICAgICAgICAgLy8gbGlzdCBidXQga2VwdCBpbiB0aGUgQ2FsbCBsaXN0Ci0gICAgICAgICAgICAgICAgY29ubmVjdGlvbnNbaV0gPSBudWxsOworICAgICAgICAgICAgICAgIG1Db25uZWN0aW9uc1tpXSA9IG51bGw7CiAgICAgICAgICAgICB9IGVsc2UgaWYgKGNvbm4gIT0gbnVsbCAmJiBkYyAhPSBudWxsKSB7IC8qIGltcGxpY2l0IGNvbm4uY29tcGFyZVRvKGRjKSAqLwogICAgICAgICAgICAgICAgIC8vIENhbGwgY29sbGlzaW9uIGNhc2UKLSAgICAgICAgICAgICAgICBpZiAoY29ubi5pc0luY29taW5nICE9IGRjLmlzTVQpIHsKKyAgICAgICAgICAgICAgICBpZiAoY29ubi5tSXNJbmNvbWluZyAhPSBkYy5pc01UKSB7CiAgICAgICAgICAgICAgICAgICAgIGlmIChkYy5pc01UID09IHRydWUpewogICAgICAgICAgICAgICAgICAgICAgICAgLy8gTXQgY2FsbCB0YWtlcyBwcmVjZWRlbmNlIHRoYW4gTW8sZHJvcHMgTW8KLSAgICAgICAgICAgICAgICAgICAgICAgIGRyb3BwZWREdXJpbmdQb2xsLmFkZChjb25uKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1Ecm9wcGVkRHVyaW5nUG9sbC5hZGQoY29ubik7CiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBmaW5kIGlmIHRoZSBNVCBjYWxsIGlzIGEgbmV3IHJpbmcgb3IgdW5rbm93biBjb25uZWN0aW9uCiAgICAgICAgICAgICAgICAgICAgICAgICBuZXdSaW5naW5nID0gY2hlY2tNdEZpbmROZXdSaW5naW5nKGRjLGkpOwogICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5ld1JpbmdpbmcgPT0gbnVsbCkgewpAQCAtNjQwLDU2ICs2MzAsNTYgQEAKICAgICAgICAgLy8gVGhpcyBpcyB0aGUgZmlyc3QgcG9sbCBhZnRlciBhbiBBVEQuCiAgICAgICAgIC8vIFdlIGV4cGVjdCB0aGUgcGVuZGluZyBjYWxsIHRvIGFwcGVhciBpbiB0aGUgbGlzdAogICAgICAgICAvLyBJZiBpdCBkb2VzIG5vdCwgd2UgbGFuZCBoZXJlCi0gICAgICAgIGlmIChwZW5kaW5nTU8gIT0gbnVsbCkgeworICAgICAgICBpZiAobVBlbmRpbmdNTyAhPSBudWxsKSB7CiAgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywiUGVuZGluZyBNTyBkcm9wcGVkIGJlZm9yZSBwb2xsIGZnIHN0YXRlOiIKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICArIGZvcmVncm91bmRDYWxsLmdldFN0YXRlKCkpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgbUZvcmVncm91bmRDYWxsLmdldFN0YXRlKCkpOwogCi0gICAgICAgICAgICBkcm9wcGVkRHVyaW5nUG9sbC5hZGQocGVuZGluZ01PKTsKLSAgICAgICAgICAgIHBlbmRpbmdNTyA9IG51bGw7Ci0gICAgICAgICAgICBoYW5ndXBQZW5kaW5nTU8gPSBmYWxzZTsKLSAgICAgICAgICAgIGlmKCBwZW5kaW5nQ2FsbEluRWNtKSB7Ci0gICAgICAgICAgICAgICAgcGVuZGluZ0NhbGxJbkVjbSA9IGZhbHNlOworICAgICAgICAgICAgbURyb3BwZWREdXJpbmdQb2xsLmFkZChtUGVuZGluZ01PKTsKKyAgICAgICAgICAgIG1QZW5kaW5nTU8gPSBudWxsOworICAgICAgICAgICAgbUhhbmd1cFBlbmRpbmdNTyA9IGZhbHNlOworICAgICAgICAgICAgaWYoIG1QZW5kaW5nQ2FsbEluRWNtKSB7CisgICAgICAgICAgICAgICAgbVBlbmRpbmdDYWxsSW5FY20gPSBmYWxzZTsKICAgICAgICAgICAgIH0KICAgICAgICAgfQogCiAgICAgICAgIGlmIChuZXdSaW5naW5nICE9IG51bGwpIHsKLSAgICAgICAgICAgIHBob25lLm5vdGlmeU5ld1JpbmdpbmdDb25uZWN0aW9uKG5ld1JpbmdpbmcpOworICAgICAgICAgICAgbVBob25lLm5vdGlmeU5ld1JpbmdpbmdDb25uZWN0aW9uKG5ld1JpbmdpbmcpOwogICAgICAgICB9CiAKICAgICAgICAgLy8gY2xlYXIgdGhlICJsb2NhbCBoYW5ndXAiIGFuZCAibWlzc2VkL3JlamVjdGVkIGNhbGwiCiAgICAgICAgIC8vIGNhc2VzIGZyb20gdGhlICJkcm9wcGVkIGR1cmluZyBwb2xsIiBsaXN0CiAgICAgICAgIC8vIFRoZXNlIGNhc2VzIG5lZWQgbm8gImxhc3QgY2FsbCBmYWlsIiByZWFzb24KLSAgICAgICAgZm9yIChpbnQgaSA9IGRyb3BwZWREdXJpbmdQb2xsLnNpemUoKSAtIDE7IGkgPj0gMCA7IGktLSkgewotICAgICAgICAgICAgQ2RtYUNvbm5lY3Rpb24gY29ubiA9IGRyb3BwZWREdXJpbmdQb2xsLmdldChpKTsKKyAgICAgICAgZm9yIChpbnQgaSA9IG1Ecm9wcGVkRHVyaW5nUG9sbC5zaXplKCkgLSAxOyBpID49IDAgOyBpLS0pIHsKKyAgICAgICAgICAgIENkbWFDb25uZWN0aW9uIGNvbm4gPSBtRHJvcHBlZER1cmluZ1BvbGwuZ2V0KGkpOwogCiAgICAgICAgICAgICBpZiAoY29ubi5pc0luY29taW5nKCkgJiYgY29ubi5nZXRDb25uZWN0VGltZSgpID09IDApIHsKICAgICAgICAgICAgICAgICAvLyBNaXNzZWQgb3IgcmVqZWN0ZWQgY2FsbAogICAgICAgICAgICAgICAgIENvbm5lY3Rpb24uRGlzY29ubmVjdENhdXNlIGNhdXNlOwotICAgICAgICAgICAgICAgIGlmIChjb25uLmNhdXNlID09IENvbm5lY3Rpb24uRGlzY29ubmVjdENhdXNlLkxPQ0FMKSB7CisgICAgICAgICAgICAgICAgaWYgKGNvbm4ubUNhdXNlID09IENvbm5lY3Rpb24uRGlzY29ubmVjdENhdXNlLkxPQ0FMKSB7CiAgICAgICAgICAgICAgICAgICAgIGNhdXNlID0gQ29ubmVjdGlvbi5EaXNjb25uZWN0Q2F1c2UuSU5DT01JTkdfUkVKRUNURUQ7CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgY2F1c2UgPSBDb25uZWN0aW9uLkRpc2Nvbm5lY3RDYXVzZS5JTkNPTUlOR19NSVNTRUQ7CiAgICAgICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAgICAgaWYgKFBob25lLkRFQlVHX1BIT05FKSB7Ci0gICAgICAgICAgICAgICAgICAgIGxvZygibWlzc2VkL3JlamVjdGVkIGNhbGwsIGNvbm4uY2F1c2U9IiArIGNvbm4uY2F1c2UpOworICAgICAgICAgICAgICAgICAgICBsb2coIm1pc3NlZC9yZWplY3RlZCBjYWxsLCBjb25uLmNhdXNlPSIgKyBjb25uLm1DYXVzZSk7CiAgICAgICAgICAgICAgICAgICAgIGxvZygic2V0dGluZyBjYXVzZSB0byAiICsgY2F1c2UpOwogICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBkcm9wcGVkRHVyaW5nUG9sbC5yZW1vdmUoaSk7CisgICAgICAgICAgICAgICAgbURyb3BwZWREdXJpbmdQb2xsLnJlbW92ZShpKTsKICAgICAgICAgICAgICAgICBjb25uLm9uRGlzY29ubmVjdChjYXVzZSk7Ci0gICAgICAgICAgICB9IGVsc2UgaWYgKGNvbm4uY2F1c2UgPT0gQ29ubmVjdGlvbi5EaXNjb25uZWN0Q2F1c2UuTE9DQUwpIHsKKyAgICAgICAgICAgIH0gZWxzZ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IGlmIChjYWxsID09IHJpbmdpbmdDYWxsKSB7CisgICAgICAgIGlmIChjYWxsID09IG1SaW5naW5nQ2FsbCkgewogICAgICAgICAgICAgaWYgKFBob25lLkRFQlVHX1BIT05FKSBsb2coIihyaW5naW5nKSBoYW5ndXAgd2FpdGluZyBvciBiYWNrZ3JvdW5kIik7Ci0gICAgICAgICAgICBjbS5oYW5ndXBXYWl0aW5nT3JCYWNrZ3JvdW5kKG9idGFpbkNvbXBsZXRlTWVzc2FnZSgpKTsKLSAgICAgICAgfSBlbHNlIGlmIChjYWxsID09IGZvcmVncm91bmRDYWxsKSB7CisgICAgICAgICAgICBtQ2kuaGFuZ3VwV2FpdGluZ09yQmFja2dyb3VuZChvYnRhaW5Db21wbGV0ZU1lc3NhZ2UoKSk7CisgICAgICAgIH0gZWxzZSBpZiAoY2FsbCA9PSBtRm9yZWdyb3VuZENhbGwpIHsKICAgICAgICAgICAgIGlmIChjYWxsLmlzRGlhbGluZ09yQWxlcnRpbmcoKSkgewogICAgICAgICAgICAgICAgIGlmIChQaG9uZS5ERUJVR19QSE9ORSkgewogICAgICAgICAgICAgICAgICAgICBsb2coIihmb3JlZ25kKSBoYW5ndXAgZGlhbGluZyBvciBhbGVydGluZy4uLiIpOwpAQCAtODE1LDggKzgwNSw4IEBACiAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgIGhhbmd1cEZvcmVncm91bmRSZXN1bWVCYWNrZ3JvdW5kKCk7CiAgICAgICAgICAgICB9Ci0gICAgICAgIH0gZWxzZSBpZiAoY2FsbCA9PSBiYWNrZ3JvdW5kQ2FsbCkgewotICAgICAgICAgICAgaWYgKHJpbmdpbmdDYWxsLmlzUmluZ2luZygpKSB7CisgICAgICAgIH0gZWxzZSBpZiAoY2FsbCA9PSBtQmFja2dyb3VuZENhbGwpIHsKKyAgICAgICAgICAgIGlmIChtUmluZ2luZ0NhbGwuaXNSaW5naW5nKCkpIHsKICAgICAgICAgICAgICAgICBpZiAoUGhvbm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2b2lkIGhhbmd1cENvbm5lY3Rpb25CeUluZGV4KENkbWFDYWxsIGNhbGwsIGludCBpbmRleCkKICAgICAgICAgICAgIHRocm93cyBDYWxsU3RhdGVFeGNlcHRpb24gewotICAgICAgICBpbnQgY291bnQgPSBjYWxsLmNvbm5lY3Rpb25zLnNpemUoKTsKKyAgICAgICAgaW50IGNvdW50ID0gY2FsbC5tQ29ubmVjdGlvbnMuc2l6ZSgpOwogICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IGNvdW50OyBpKyspIHsKLSAgICAgICAgICAgIENkbWFDb25uZWN0aW9uIGNuID0gKENkbWFDb25uZWN0aW9uKWNhbGwuY29ubmVjdGlvbnMuZ2V0KGkpOworICAgICAgICAgICAgQ2RtYUNvbm5lY3Rpb24gY24gPSAoQ2RtYUNvbm5lY3Rpb24pY2FsbC5tQ29ubmVjdGlvbnMuZ2V0KGkpOwogICAgICAgICAgICAgaWYgKGNuLmdldENETUFJbmRleCgpID09IGluZGV4KSB7Ci0gICAgICAgICAgICAgICAgY20uaGFuZ3VwQ29ubmVjdGlvbihpbmRleCwgb2J0YWluQ29tcGxldGVNZXNzYWdlKCkpOworICAgICAgICAgICAgICAgIG1DaS5oYW5ndXBDb25uZWN0aW9uKGluZGV4LCBvYnRhaW5Db21wbGV0ZU1lc3NhZ2UoKSk7CiAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgfQogICAgICAgICB9CkBAIC04NTksMTIgKzg0OSwxMiBAQAogICAgICAgICB0aHJvdyBuZXcgQ2FsbFN0YXRlRXhjZXB0aW9uKCJubyBnc20gaW5kZXggZm91bmQiKTsKICAgICB9CiAKLSAgICB2b2lkIGhhbmd1cEFsbENvbm5lY3Rpb25zKENkbWFDYWxsIGNhbGwpIHRocm93cyBDYWxsU3RhdGVFeGNlcHRpb257CisgICAgdm9pZCBoYW5ndXBBbGxDb25uZWN0aW9ucyhDZG1hQ2FsbCBjYWxsKSB7CiAgICAgICAgIHRyeSB7Ci0gICAgICAgICAgICBpbnQgY291bnQgPSBjYWxsLmNvbm5lY3Rpb25zLnNpemUoKTsKKyAgICAgICAgICAgIGludCBjb3VudCA9IGNhbGwubUNvbm5lY3Rpb25zLnNpemUoKTsKICAgICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgY291bnQ7IGkrKykgewotICAgICAgICAgICAgICAgIENkbWFDb25uZWN0aW9uIGNuID0gKENkbWFDb25uZWN0aW9uKWNhbGwuY29ubmVjdGlvbnMuZ2V0KGkpOwotICAgICAgICAgICAgICAgIGNtLmhhbmd1cENvbm5lY3Rpb24oY24uZ2V0Q0RNQUluZGV4KCksIG9idGFpbkNvbXBsZXRlTWVzc2FnZSgpKTsKKyAgICAgICAgICAgICAgICBDZG1hQ29ubmVjdGlvbiBjbiA9IChDZG1hQ29ubmVjdGlvbiljYWxsLm1Db25uZWN0aW9ucy5nZXQoaSk7CisgICAgICAgICAgICAgICAgbUNpLmhhbmd1cENvbm5lY3Rpb24oY24uZ2V0Q0RNQUluZGV4KCksIG9idGFpbkNvbXBsZXRlTWVzc2FnZSgpKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfSBjYXRjaCAoQ2FsbFN0YXRlRXhjZXB0aW9uIGV4KSB7CiAgICAgICAgICAgICBSbG9nLmUoTE9HX1RBRywgImhhbmd1cENvbm5lY3Rpb25CeUluZGV4IGNhdWdodCAiICsgZXgpOwpAQCAtODc0LDkgKzg2NCw5IEBACiAgICAgLyogcGFja2FnZSAqLwogICAgIENkbWFDb25uZWN0aW9uIGdldENvbm5lY3Rpb25CeUluZGV4KENkbWFDYWxsIGNhbGwsIGludCBpbmRleCkKICAgICAgICAgICAgIHRocm93cyBDYWxsU3RhdGVFeGNlcHRpb24gewotICAgICAgICBpbnQgY291bnQgPSBjYWxsLmNvbm5lY3Rpb25zLnNpemUoKTsKKyAgICAgICAgaW50IGNvdW50ID0gY2FsbC5tQ29ubmVjdGlvbnMuc2l6ZSgpOwogICAgICAgICBmb3IgKGludCBp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ZXh0KCksIGN3LCB0aGlzLCByaW5naW5nQ2FsbCk7CisgICAgICAgIG1SaW5naW5nQ2FsbC5zZXRHZW5lcmljKGZhbHNlKTsKKyAgICAgICAgbmV3IENkbWFDb25uZWN0aW9uKG1QaG9uZS5nZXRDb250ZXh0KCksIGN3LCB0aGlzLCBtUmluZ2luZ0NhbGwpOwogICAgICAgICB1cGRhdGVQaG9uZVN0YXRlKCk7CiAKICAgICAgICAgLy8gRmluYWxseSBub3RpZnkgYXBwbGljYXRpb24KQEAgLTk0Myw2ICs5MTksNyBAQAogICAgIH0KICAgICAvLyoqKioqKiBPdmVycmlkZGVuIGZyb20gSGFuZGxlcgogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQKICAgICBoYW5kbGVNZXNzYWdlIChNZXNzYWdlIG1zZykgewogICAgICAgICBBc3luY1Jlc3VsdCBhcjsKQEAgLTk1MiwxMSArOTI5LDExIEBACiAgICAgICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsICJFdmVudCBFVkVOVF9QT0xMX0NBTExTX1JFU1VMVCBSZWNlaXZlZCIpOwogICAgICAgICAgICAgICAgIGFyID0gKEFzeW5jUmVzdWx0KW1zZy5vYmo7CiAKLSAgICAgICAgICAgICAgICBpZihtc2cgPT0gbGFzdFJlbGV2YW50UG9sbCkgeworICAgICAgICAgICAgICAgIGlmKG1zZyA9PSBtTGFzdFJlbGV2YW50UG9sbCkgewogICAgICAgICAgICAgICAgICAgICBpZihEQkdfUE9MTCkgbG9nKAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICJoYW5kbGUgRVZFTlRfUE9MTF9DQUxMX1JFU1VMVDogc2V0IG5lZWRzUG9sbD1GIik7Ci0gICAgICAgICAgICAgICAgICAgIG5lZWRzUG9sbCA9IGZhbHNlOwotICAgICAgICAgICAgICAgICAgICBsYXN0UmVsZXZhbnRQb2xsID0gbnVsbDsKKyAgICAgICAgICAgICAgICAgICAgbU5lZWRzUG9sbCA9IGZhbHNlOworICAgICAgICAgICAgICAgICAgICBtTGFzdFJlbGV2YW50UG9sbCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgIGhhbmRsZVBvbGxDYWxscygoQXN5bmNSZXN1bHQpbXNnLm9iaik7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQpAQCAtOTg4LDE4ICs5NjUsMTggQEAKICAgICAgICAgICAgICAgICAgICAgY2F1c2VDb2RlID0gKChpbnRbXSlhci5yZXN1bHQpWzBdOwogICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgICAgIGZvciAoaW50IGkgPSAwLCBzID0gIGRyb3BwZWREdXJpbmdQb2xsLnNpemUoKQorICAgICAgICAgICAgICAgIGZvciAoaW50IGkgPSAwLCBzID0gIG1Ecm9wcGVkRHVyaW5nUG9sbC5zaXplKCkKICAgICAgICAgICAgICAgICAgICAgICAgIDsgaSA8IHMgOyBpKysKICAgICAgICAgICAgICAgICApIHsKLSAgICAgICAgICAgICAgICAgICAgQ2RtYUNvbm5lY3Rpb24gY29ubiA9IGRyb3BwZWREdXJpbmdQb2xsLmdldChpKTsKKyAgICAgICAgICAgICAgICAgICAgQ2RtYUNvbm5lY3Rpb24gY29ubiA9IG1Ecm9wcGVkRHVyaW5nUG9sbC5nZXQoaSk7CiAKICAgICAgICAgICAgICAgICAgICAgY29ubi5vblJlbW90ZURpc2Nvbm5lY3QoY2F1c2VDb2RlKTsKICAgICAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgICAgICB1cGRhdGVQaG9uZVN0YXRlKCk7CiAKLSAgICAgICAgICAgICAgICBwaG9uZS5ub3RpZnlQcmVjaXNlQ2FsbFN0YXRlQ2hhbmdlZCgpOwotICAgICAgICAgICAgICAgIGRyb3BwZWREdXJpbmdQb2xsLmNsZWFyKCk7CisgICAgICAgICAgICAgICAgbVBob25lLm5vdGlmeVByZWNpc2VDYWxsU3RhdGVDaGFuZ2VkKCk7CisgICAgICAgICAgICAgICAgbURyb3BwZWREdXJpbmdQb2xsLmNsZWFyKCk7CiAgICAgICAgICAgICBicmVhazsKIAogICAgICAgICAgICAgY2FzZSBFVkVOVF9SRVBPTExfQUZURVJfREVMQVk6CkBAIC0xMDE3LDExICs5OTQsMTEgQEAKIAogICAgICAgICAgICAgY2FzZSBFVkVOVF9FWElUX0VDTV9SRVNQT05TRV9DRE1BOgogICAgICAgICAgICAgICAgLy9ubyBtYXR0ZXIgdGhlIHJlc3VsdCwgd2Ugc3RpbGwgZG8gdGhlIHNhbWUgaGVyZQotICAgICAgICAgICAgICAgaWYgKHBlbmRpbmdDYWxsSW5FY20pIHsKLSAgICAgICAgICAgICAgICAgICBjbS5kaWFsKHBlbmRpbmdNTy5hZGRyZXNzLCBwZW5kaW5nQ2FsbENsaXJNb2RlLCBvYnRhaW5Db21wbGV0ZU1lc3NhZ2UoKSk7Ci0gICAgICAgICAgICAgICAgICAgcGVuZGluZ0NhbGxJbkVjbSA9IGZhbHNlOworICAgICAgICAgICAgICAgaWYgKG1QZW5kaW5nQ2FsbEluRWNtKSB7CisgICAgICAgICAgICAgICAgICAgbUNpLmRpYWwobVBlbmRpbmdNTy5tQWRkcmVzcywgbVBlbmRpbmdDYWxsQ2xpck1vZGUsIG9idGFpbkNvbXBsZXRlTWVzc2FnZSgpKTsKKyAgICAgICAgICAgICAgICAgICBtUGVuZGluZ0NhbGxJbkVjbSA9IGZhbHNlOwogICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgcGhvbmUudW5zZXRPbkVjYk1vZGVFeGl0UmVzcG9uc2UodGhpcyk7CisgICAgICAgICAgICAgICBtUGhvbmUudW5zZXRPbkVjYk1vZGVFeGl0UmVzcG9uc2UodGhpcyk7CiAgICAgICAgICAgICBicmVhazsKIAogICAgICAgICAgICAgY2FzZSBFVkVOVF9DQUxMX1dBSVRJTkdfSU5GT19DRE1BOgpAQCAtMTAzNiw4ICsxMDEzLDggQEAKICAgICAgICAgICAgICAgICBhciA9IChBc3luY1Jlc3VsdCltc2cub2JqOwogICAgICAgICAgICAgICAgIGlmIChhci5leGNlcHRpb24gPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAvLyBBc3N1bWUgMyB3YXkgY2FsbCBpcyBjb25uZWN0ZWQKLSAgICAgICAgICAgICAgICAgICAgcGVuZGluZ01PLm9uQ29ubmVjdGVkSW5Pck91dCgpOwotICAgICAgICAgICAgICAgICAgICBwZW5kaW5nTU8gPSBudWxsOworICAgICAgICAgICAgICAgICAgICBtUGVuZGluZ01PLm9uQ29ubmVjdGVkSW5Pck91dCgpOworICAgICAgICAgICAgICAgICAgICBtUGVuZGluZ01PID0gbnVsbDsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICBicmVhazsKIApAQCAtMTA1MSw3ICsxMDI4LDcgQEAKICAgICAgKiBIYW5kbGUgRWNtIHRpbWVyIHRvIGJlIGNhbmNlbGVkIG9yIHJlLXN0YXJ0ZWQKICAgICAgKi8KICAgICBwcml2YXRlIHZvaWQgaGFuZGxlRWNtVGltZXIoaW50IGFjdGlvbikgewotICAgICAgICBwaG9uZS5oYW5kbGVUaW1lckluRW1lcmdlbmN5Q2FsbGJhY2tNb2RlKGFjdGlvbik7CisgICAgICAgIG1QaG9uZS5oYW5kbGVUaW1lckluRW1lcmdlbmN5Q2FsbGJhY2tNb2RlKGFjdGlvbik7CiAgICAgICAgIHN3aXRjaChhY3Rpb24pIHsKICAgICAgICAgY2FzZSBDRE1BUGhvbmUuQ0FOQ0VMX0VDTV9USU1FUjogbUlzRWNtVGltZXJDYW5jZWxlZCA9IHRydWU7IGJyZWFrOwogICAgICAgICBjYXNlIENETUFQaG9uZS5SRVNUQVJUX0VDTV9USU1FUjogbUlzRWNtVGltZXJDYW5jZWxlZCA9IGZhbHNlOyBicmVhazsKQEAgLTEwNjQsMTAgKzEwNDEsMTAgQEAKICAgICAgKiBEaXNhYmxlIGRhdGEgY2FsbCB3aGVuIGVtZXJnZW5jeSBjYWxsIGlzIGNvbm5lY3RlZAogICAgICAqLwogICAgIHByaX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WN0ZWRJbk9yT3V0KCk7CisgICAgICAgICAgICAgICAgbUNvbm5lY3Rpb25zW2ldLm9uQ29ubmVjdGVkSW5Pck91dCgpOwogICAgICAgICAgICAgICAgIGlmIChkYy5zdGF0ZSA9PSBEcml2ZXJDYWxsLlN0YXRlLkhPTERJTkcpIHsKICAgICAgICAgICAgICAgICAgICAgLy8gV2UndmUgdHJhbnNpdGlvbmVkIGludG8gSE9MRElORwotICAgICAgICAgICAgICAgICAgICBjb25uZWN0aW9uc1tpXS5vblN0YXJ0ZWRIb2xkaW5nKCk7CisgICAgICAgICAgICAgICAgICAgIG1Db25uZWN0aW9uc1tpXS5vblN0YXJ0ZWRIb2xkaW5nKCk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogICAgICAgICB9CkBAIC0xMTMyLDYgKzExMDksNyBAQAogICAgICAgICByZXR1cm4gbUlzSW5FbWVyZ2VuY3lDYWxsOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHByb3RlY3RlZCB2b2lkIGxvZyhTdHJpbmcgbXNnKSB7CiAgICAgICAgIFJsb2cuZChMT0dfVEFHLCAiW0NkbWFDYWxsVHJhY2tlcl0gIiArIG1zZyk7CiAgICAgfQpAQCAtMTE0MCwyOCArMTExOCwyOCBAQAogICAgIHB1YmxpYyB2b2lkIGR1bXAoRmlsZURlc2NyaXB0b3IgZmQsIFByaW50V3JpdGVyIHB3LCBTdHJpbmdbXSBhcmdzKSB7CiAgICAgICAgIHB3LnByaW50bG4oIkdzbUNhbGxUcmFja2VyIGV4dGVuZHM6Iik7CiAgICAgICAgIHN1cGVyLmR1bXAoZmQsIHB3LCBhcmdzKTsKLSAgICAgICAgcHcucHJpbnRsbigiZHJvcHBlZER1cmluZ1BvbGw6IGxlbmd0aD0iICsgY29ubmVjdGlvbnMubGVuZ3RoKTsKLSAgICAgICAgZm9yKGludCBpPTA7IGkgPCBjb25uZWN0aW9ucy5sZW5ndGg7IGkrKykgewotICAgICAgICAgICAgcHc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AotICAgICAgICBhZGRyZXNzID0gZGMubnVtYmVyOworICAgICAgICBtQWRkcmVzcyA9IGRjLm51bWJlcjsKIAotICAgICAgICBpc0luY29taW5nID0gZGMuaXNNVDsKLSAgICAgICAgY3JlYXRlVGltZSA9IFN5c3RlbS5jdXJyZW50VGltZU1pbGxpcygpOwotICAgICAgICBjbmFwTmFtZSA9IGRjLm5hbWU7Ci0gICAgICAgIGNuYXBOYW1lUHJlc2VudGF0aW9uID0gZGMubmFtZVByZXNlbnRhdGlvbjsKLSAgICAgICAgbnVtYmVyUHJlc2VudGF0aW9uID0gZGMubnVtYmVyUHJlc2VudGF0aW9uOworICAgICAgICBtSXNJbmNvbWluZyA9IGRjLmlzTVQ7CisgICAgICAgIG1DcmVhdGVUaW1lID0gU3lzdGVtLmN1cnJlbnRUaW1lTWlsbGlzKCk7CisgICAgICAgIG1DbmFwTmFtZSA9IGRjLm5hbWU7CisgICAgICAgIG1DbmFwTmFtZVByZXNlbnRhdGlvbiA9IGRjLm5hbWVQcmVzZW50YXRpb247CisgICAgICAgIG1OdW1iZXJQcmVzZW50YXRpb24gPSBkYy5udW1iZXJQcmVzZW50YXRpb247CiAKLSAgICAgICAgdGhpcy5pbmRleCA9IGluZGV4OworICAgICAgICBtSW5kZXggPSBpbmRleDsKIAotICAgICAgICBwYXJlbnQgPSBwYXJlbnRGcm9tRENTdGF0ZSAoZGMuc3RhdGUpOwotICAgICAgICBwYXJlbnQuYXR0YWNoKHRoaXMsIGRjKTsKKyAgICAgICAgbVBhcmVudCA9IHBhcmVudEZyb21EQ1N0YXRlIChkYy5zdGF0ZSk7CisgICAgICAgIG1QYXJlbnQuYXR0YWNoKHRoaXMsIGRjKTsKICAgICB9CiAKICAgICAvKiogVGhpcyBpcyBhbiBNTyBjYWxsL3RocmVlIHdheSBjYWxsLCBjcmVhdGVkIHdoZW4gZGlhbGluZyAqLwpAQCAtMTQ1LDMwICsxNDcsMzAgQEAKICAgICAgICAgY3JlYXRlV2FrZUxvY2so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gICAgIG1JbmRleCA9IC0xOwogCi0gICAgICAgIGlzSW5jb21pbmcgPSBmYWxzZTsKLSAgICAgICAgY25hcE5hbWUgPSBudWxsOwotICAgICAgICBjbmFwTmFtZVByZXNlbnRhdGlvbiA9IFBob25lQ29uc3RhbnRzLlBSRVNFTlRBVElPTl9BTExPV0VEOwotICAgICAgICBudW1iZXJQcmVzZW50YXRpb24gPSBQaG9uZUNvbnN0YW50cy5QUkVTRU5UQVRJT05fQUxMT1dFRDsKLSAgICAgICAgY3JlYXRlVGltZSA9IFN5c3RlbS5jdXJyZW50VGltZU1pbGxpcygpOworICAgICAgICBtSXNJbmNvbWluZyA9IGZhbHNlOworICAgICAgICBtQ25hcE5hbWUgPSBudWxsOworICAgICAgICBtQ25hcE5hbWVQcmVzZW50YXRpb24gPSBQaG9uZUNvbnN0YW50cy5QUkVTRU5UQVRJT05fQUxMT1dFRDsKKyAgICAgICAgbU51bWJlclByZXNlbnRhdGlvbiA9IFBob25lQ29uc3RhbnRzLlBSRVNFTlRBVElPTl9BTExPV0VEOworICAgICAgICBtQ3JlYXRlVGltZSA9IFN5c3RlbS5jdXJyZW50VGltZU1pbGxpcygpOwogCiAgICAgICAgIGlmIChwYXJlbnQgIT0gbnVsbCkgewotICAgICAgICAgICAgdGhpcy5wYXJlbnQgPSBwYXJlbnQ7CisgICAgICAgICAgICBtUGFyZW50ID0gcGFyZW50OwogCiAgICAgICAgICAgICAvL2ZvciB0aGUgdGhyZWUgd2F5IGNhbGwgY2FzZSwgbm90IGNoYW5nZSBwYXJlbnQgc3RhdGUKLSAgICAgICAgICAgIGlmIChwYXJlbnQuc3RhdGUgPT0gQ2RtYUNhbGwuU3RhdGUuQUNUSVZFKSB7CisgICAgICAgICAgICBpZiAocGFyZW50Lm1TdGF0ZSA9PSBDZG1hQ2FsbC5TdGF0ZS5BQ1RJVkUpIHsKICAgICAgICAgICAgICAgICBwYXJlbnQuYXR0YWNoRmFrZSh0aGlzLCBDZG1hQ2FsbC5TdGF0ZS5BQ1RJVkUpOwogICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICBwYXJlbnQuYXR0YWNoRmFrZSh0aGlzLCBDZG1hQ2FsbC5TdGF0ZS5ESUFMSU5HKTsKQEAgLTE4MiwxNyArMTg0LDE3IEBACiAgICAgICAgIGNyZWF0ZVdha2VMb2NrKGNvbnRleHQpOwogICAgICAgICBhY3F1aXJlV2FrZUxvY2soKTsKIAotICAgICAgICBvd25lciA9IGN0OwotICAgICAgICBoID0gbmV3IE15SGFuZGxlcihvd25lci5nZXRMb29wZXIoKSk7Ci0gICAgICAgIGFkZHJlc3MgPSBjdy5udW1iZXI7Ci0gICAgICAgIG51bWJlclByZXNlbnRhdGlvbiA9IGN3Lm51bWJlclByZXNlbnRhdGlvbjsKLSAgICAgICAgY25hcE5hbWUgPSBjdy5uYW1lOwotICAgICAgICBjbmFwTmFtZVByZXNlbnRhdGlvbiA9IGN3Lm5hbWVQcmVzZW50YXRpb247Ci0gICAgICAgIGluZGV4ID0gLTE7Ci0gICAgICAgIGlzSW5jb21pbmcgPSB0cnVlOwotICAgICAgICBjcmVhdGVUaW1lID0gU3lzdGVtLmN1cnJlbnRUaW1lTWlsbGlzKCk7Ci0gICAgICAgIGNvbm5lY3RUaW1lID0gMDsKLSAgICAgICAgdGhpcy5wYXJlbnQgPSBwYXJlbnQ7CisgICAgICAgIG1Pd25lciA9IGN0OworICAgICAgICBtSGFuZGxlciA9IG5ldyBNeUhhbmRsZXIobU93bmVyLmdldExvb3BlcigpKTsKKyAgICAgICAgbUFkZHJlc3MgPSBjdy5udW1iZXI7CisgICAgICAgIG1OdW1iZXJQcmVzZW50YXRpb24gPSBjdy5udW1iZXJQcmVzZW50YXRpb247CisgICAgICAgIG1DbmFwTmFtZSA9IGN3Lm5hbWU7CisgICAgICAgIG1DbmFwTmFtZVByZXNlbnRhdGlvbiA9IGN3Lm5hbWVQcmVzZW50YXRpb247CisgICAgICAgIG1JbmRleCA9IC0xOworICAg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01UICYmIGVxdWFsc0hhbmRsZXNOdWxscyhtQWRkcmVzcywgY0FkZHJlc3MpOwogICAgIH0KIAogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFN0cmluZyBnZXRPcmlnRGlhbFN0cmluZygpewotICAgICAgICByZXR1cm4gZGlhbFN0cmluZzsKKyAgICAgICAgcmV0dXJuIG1EaWFsU3RyaW5nOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdHJpbmcgZ2V0QWRkcmVzcygpIHsKLSAgICAgICAgcmV0dXJuIGFkZHJlc3M7CisgICAgICAgIHJldHVybiBtQWRkcmVzczsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgQ2RtYUNhbGwgZ2V0Q2FsbCgpIHsKLSAgICAgICAgcmV0dXJuIHBhcmVudDsKKyAgICAgICAgcmV0dXJuIG1QYXJlbnQ7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGxvbmcgZ2V0Q3JlYXRlVGltZSgpIHsKLSAgICAgICAgcmV0dXJuIGNyZWF0ZVRpbWU7CisgICAgICAgIHJldHVybiBtQ3JlYXRlVGltZTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgbG9uZyBnZXRDb25uZWN0VGltZSgpIHsKLSAgICAgICAgcmV0dXJuIGNvbm5lY3RUaW1lOworICAgICAgICByZXR1cm4gbUNvbm5lY3RUaW1lOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBsb25nIGdldERpc2Nvbm5lY3RUaW1lKCkgewotICAgICAgICByZXR1cm4gZGlzY29ubmVjdFRpbWU7CisgICAgICAgIHJldHVybiBtRGlzY29ubmVjdFRpbWU7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGxvbmcgZ2V0RHVyYXRpb25NaWxsaXMoKSB7Ci0gICAgICAgIGlmIChjb25uZWN0VGltZVJlYWwgPT0gMCkgeworICAgICAgICBpZiAobUNvbm5lY3RUaW1lUmVhbCA9PSAwKSB7CiAgICAgICAgICAgICByZXR1cm4gMDsKLSAgICAgICAgfSBlbHNlIGlmIChkdXJhdGlvbiA9PSAwKSB7Ci0gICAgICAgICAgICByZXR1cm4gU3lzdGVtQ2xvY2suZWxhcHNlZFJlYWx0aW1lKCkgLSBjb25uZWN0VGltZVJlYWw7CisgICAgICAgIH0gZWxzZSBpZiAobUR1cmF0aW9uID09IDApIHsKKyAgICAgICAgICAgIHJldHVybiBTeXN0ZW1DbG9jay5lbGFwc2VkUmVhbHRpbWUoKSAtIG1Db25uZWN0VGltZVJlYWw7CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICByZXR1cm4gZHVyYXRpb247CisgICAgICAgICAgICByZXR1cm4gbUR1cmF0aW9uOwogICAgICAgICB9CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGxvbmcgZ2V0SG9sZER1cmF0aW9uTWlsbGlzKCkgewogICAgICAgICBpZiAoZ2V0U3RhdGUoKSAhPSBDZG1hQ2FsbC5TdGF0ZS5IT0xESU5HKSB7CiAgICAgICAgICAgICAvLyBJZiBub3QgaG9sZGluZywgcmV0dXJuIDAKICAgICAgICAgICAgIHJldHVybiAwOwogICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgcmV0dXJuIFN5c3RlbUNsb2NrLmVsYXBzZWRSZWFsdGltZSgpIC0gaG9sZGluZ1N0YXJ0VGltZTsKKyAgICAgICAgICAgIHJldHVybiBTeXN0ZW1DbG9jay5lbGFwc2VkUmVhbHRpbWUoKSAtIG1Ib2xkaW5nU3RhcnRUaW1lOwogICAgICAgICB9CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIERpc2Nvbm5lY3RDYXVzZSBnZXREaXNjb25uZWN0Q2F1c2UoKSB7Ci0gICAgICAgIHJldHVybiBjYXVzZTsKKyAgICAgICAgcmV0dXJuIG1DYXVzZTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgYm9vbGVhbiBpc0luY29taW5nKCkgewotICAgICAgICByZXR1cm4gaXNJbmNvbWluZzsKKyAgICAgICAgcmV0dXJuIG1Jc0luY29taW5nOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBDZG1hQ2FsbC5TdGF0ZSBnZXRTdGF0ZSgpIHsKLSAgICAgICAgaWYgKGRpc2Nvbm5lY3RlZCkgeworICAgICAgICBpZiAobURpc2Nvbm5lY3RlZCkgewogICAgICAgICAgICAgcmV0dXJuIENkbWFDYWxsLlN0YXRlLkRJU0NPTk5FQ1RFRDsKICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIHJldHVybiBzdXBlci5nZXRTdGF0ZSgpOwogICAgICAgICB9CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgaGFuZ3VwKCkgdGhyb3dzIENhbGxTdGF0ZUV4Y2VwdGlvbiB7Ci0gICAgICAgIGlmICghZGlzY29ubmVjdGVkKSB7Ci0gICAgICAgICAgICBvd25lci5oYW5ndXAodGhpcyk7CisgICAgICAgIGlmICghbURpc2Nvbm5lY3RlZCkgeworICAgICAgICAgICAgbU93bmVyLmhhbmd1cCh0aGlzKTsKICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIHRocm93IG5ldyBDYWxsU3RhdGVFeGNlcHRpb24gKCJkaXNjb25uZWN0ZWQiKTsKICAgICAgICAgfQogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHNlcGFyYXRlKCkgdGhyb3dzIENhbGxTdGF0ZUV4Y2VwdGlvbiB7Ci0gICAgICAgIGlmICghZGlzY29ubmVjdGVkKSB7Ci0gICAgICAgICAgICBvd25lci5zZXBhcmF0ZSh0aGlzKTsKKyAgICAgICAgaWYgKCFtRGlzY29ubmVjdGVkKSB7CisgICAgICAgICAgICBtT3duZXIuc2VwYXJhdGUodGh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Btc2cgPSBoLm9idGFpbk1lc3NhZ2UoRVZFTlRfRFRNRl9ET05FKTsKLSAgICAgICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgICAgICBpZiAoUGhvbmVOdW1iZXJVdGlscy5pczEyS2V5KGMpKSB7Ci0gICAgICAgICAgICAgICAgICAgIG93bmVyLmNtLnNlbmREdG1mKGMsIG1zZyk7Ci0gICAgICAgICAgICAgICAgICAgIHBsYXllZFRvbmUgPSB0cnVlOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIH0KLQotICAgICAgICAgICAgaWYgKCFwbGF5ZWRUb25lKSB7Ci0gICAgICAgICAgICAgICAgcHJvY2Vzc05leHRQb3N0RGlhbENoYXIoKTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgIC8vIG1ha2UgYSBuZXcgcG9zdERpYWxTdHJpbmcsIHdpdGggdGhlIHdpbGQgY2hhciByZXBsYWNlbWVudCBzdHJpbmcKLSAgICAgICAgICAgIC8vIGF0IHRoZSBiZWdpbm5pbmcsIGZvbGxvd2VkIGJ5IHRoZSByZW1haW5pbmcgcG9zdERpYWxTdHJpbmcuCi0KLSAgICAgICAgICAgIFN0cmluZ0J1aWxkZXIgYnVmID0gbmV3IFN0cmluZ0J1aWxkZXIoc3RyKTsKLSAgICAgICAgICAgIGJ1Zi5hcHBlbmQocG9zdERpYWxTdHJpbmcuc3Vic3RyaW5nKG5leHRQb3N0RGlhbENoYXIpKTsKLSAgICAgICAgICAgIHBvc3REaWFsU3RyaW5nID0gYnVmLnRvU3RyaW5nKCk7Ci0gICAgICAgICAgICBuZXh0UG9zdERpYWxDaGFyID0gMDsKLSAgICAgICAgICAgIGlmIChQaG9uZS5ERUJVR19QSE9ORSkgewotICAgICAgICAgICAgICAgIGxvZygicHJvY2VlZEFmdGVyV2lsZENoYXI6IG5ldyBwb3N0RGlhbFN0cmluZyBpcyAiICsKLSAgICAgICAgICAgICAgICAgICAgICAgIHBvc3REaWFsU3RyaW5nKTsKLSAgICAgICAgICAgIH0KLQotICAgICAgICAgICAgcHJvY2Vzc05leHRQb3N0RGlhbENoYXIoKTsKKyAgICAgICAgU3RyaW5nQnVpbGRlciBidWYgPSBuZXcgU3RyaW5nQnVpbGRlcihzdHIpOworICAgICAgICBidWYuYXBwZW5kKG1Qb3N0RGlhbFN0cmluZy5zdWJzdHJpbmcobU5leHRQb3N0RGlhbENoYXIpKTsKKyAgICAgICAgbVBvc3REaWFsU3RyaW5nID0gYnVmLnRvU3RyaW5nKCk7CisgICAgICAgIG1OZXh0UG9zdERpYWxDaGFyID0gMDsKKyAgICAgICAgaWYgKFBob25lLkRFQlVHX1BIT05FKSB7CisgICAgICAgICAgICBsb2coInByb2NlZWRBZnRlcldpbGRDaGFyOiBuZXcgcG9zdERpYWxTdHJpbmcgaXMgIiArCisgICAgICAgICAgICAgICAgICAgIG1Qb3N0RGlhbFN0cmluZyk7CiAgICAgICAgIH0KKworICAgICAgICBwcm9jZXNzTmV4dFBvc3REaWFsQ2hhcigpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIGNhbmNlbFBvc3REaWFsKCkgewogICAgICAgICBzZXRQb3N0RGlhbFN0YXRlKFBvc3REaWFsU3RhdGUuQ0FOQ0VMTEVEKTsKICAgICB9CkBAIC0zNzAsNyArMzY2LDcgQEAKICAgICAgKi8KICAgICB2b2lkCiAgICAgb25IYW5ndXBMb2NhbCgpIHsKLSAgICAgICAgY2F1c2UgPSBEaXNjb25uZWN0Q2F1c2UuTE9DQUw7CisgICAgICAgIG1DYXVzZSA9IERpc2Nvbm5lY3RDYXVzZS5MT0NBTDsKICAgICB9CiAKICAgICBEaXNjb25uZWN0Q2F1c2UKQEAgLTQxNCw3ICs0MTAsNyBAQAogICAgICAgICAgICAgY2FzZSBDYWxsRmFpbENhdXNlLkVSUk9SX1VOU1BFQ0lGSUVEOgogICAgICAgICAgICAgY2FzZSBDYWxsRmFpbENhdXNlLk5PUk1BTF9DTEVBUklORzoKICAgICAgICAgICAgIGRlZmF1bHQ6Ci0gICAgICAgICAgICAgICAgQ0RNQVBob25lIHBob25lID0gb3duZXIucGhvbmU7CisgICAgICAgICAgICAgICAgQ0RNQVBob25lIHBob25lID0gbU93bmVyLm1QaG9uZTsKICAgICAgICAgICAgICAgICBpbnQgc2VydmljZVN0YXRlID0gcGhvbmUuZ2V0U2VydmljZVN0YXRlKCkuZ2V0U3RhdGUoKTsKICAgICAgICAgICAgICAgICBVaWNjQ2FyZEFwcGxpY2F0aW9uIGFwcCA9IFVpY2NDb250cm9sbGVyCiAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0SW5zdGFuY2UoKQpAQCAtNDQ1LDE3ICs0NDEsMTYgQEAKICAgICAvKiogQ2FsbGVkIHdoZW4gdGhlIHJhZGlvIGluZGljYXRlcyB0aGUgY29ubmVjdGlvbiBoYXMgYmVlbiBkaXNjb25uZWN0ZWQgKi8KICAgICAvKnBhY2thZ2UqLyB2b2lkCiAgICAgb25EaXNjb25uZWN0KERpc2Nvbm5lY3RDYXVzZSBjYXVzZSkgewotICAgICAgICB0aGlzLmNhdXNlID0gY2F1c2U7CisgICAgICAgIG1DYXVzZSA9IGNhdXNlOwogCi0gICAgICAgIGlmICghZGlzY29ubmVjdGVkKSB7CisgICAgICAgIGlmICghbURpc2Nvbm5lY3RlZCkgewogICAgICAgICAgICAgZG9EaXNjb25uZWN0KCk7Ci0gICAgICAgICAgICBpZiAoZmFsc2UpIFJsb2cuZChMT0dfVEFHLAotICAgICAgICAgICAgICAgICAgICAiW0NETUFDb25uXSBvbkRpc2Nvbm5lY3Q6IGNhdXNlPSIgKyBjYXVzZSk7CisgICAgICAgICAgICBpZiAoVkRCRykgUmxvZy5kKExPR19UQUcsICJvbkRpc2Nvbm5lY3Q6IGNhdXNlPSIgKyBjYXVzZSk7CiAKLSAgICAgICAgICAgIG93bmVyLnBob25lLm5vdGlmeURpc2Nvbm5lY3QodGhpcyk7CisgICAgICAgICAgICBtT3duZXIubVBob25lLm5vdGlmeURpc2Nvbm5lY3QodGhpcyk7CiAKLSAgICAgICAgICAgIGlmIChwYXJlbnQgIT0gbnVsbCkgewotICAgICAgICAgICAgICAgIHBhcmVudC5jb25uZWN0aW9uRGlzY29ubmVjdGVkKHRoaXMpOworICAgICAgICAgICAgaWYgKG1QYXJlbnQgIT0gbnVsbCkgeworICAgICAgICAgICAgICAgIG1QYXJlbnQuY29ubmVjdGlvbkRpc2Nvbm5lY3RlZCh0aGlzKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfQogICAgICAgICByZWxlYXNlV2FrZUxvY2soKTsKQEAgLTQ2NCwxMyArNDU5LDEyIEBACiAgICAgLyoqIENhbGxlZCB3aGVuIHRoZSBjYWxsIHdhaXRpbmcgY29ubmVjdGlvbiBoYXMgYmVlbiBodW5nIHVwICovCiAgICAgLypwYWNrYWdlKi8gdm9pZAogICAgIG9uTG9jYWxEaXNjb25uZWN0KCkgewotICAgICAgICBpZiAoIWRpc2Nvbm5lY3RlZCkgeworICAgICAgICBpZiAoIW1EaXNjb25uZWN0ZWQpIHsKICAgICAgICAgICAgIGRvRGlzY29ubmVjdCgpOwotICAgICAgICAgICAgaWYgKGZhbHNlKSBSbG9nLmQoTE9HX1RBRywKLSAgICAgICAgICAgICAgICAgICAgIltDRE1BQ29ubl0gb25Mb2FsRGlzY29ubmVjdCIgKTsKKyAgICAgICAgICAgIGlmIChWREJHKSBSbG9nLmQoTE9HX1RBRywgIm9uTG9hbERpc2Nvbm5lY3QiICk7CiAKLSAgICAgICAgICAgIGlmIChwYXJlbnQgIT0gbnVsbCkgewotICAgICAgICAgICAgICAgIHBhcmVudC5kZXRhY2godGhpcyk7CisgICAgICAgICAgICBpZiAobVBhcmVudCAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgbVBhcmVudC5kZXRhY2godGhpcyk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICAgICAgcmVsZWFzZVdha2VMb2NrKCk7CkBAIC00ODYsMzkgKzQ4MCwzOSBAQAogCiAgICAgICAgIG5ld1BhcmVudCA9IHBhcmVudEZyb21EQ1N0YXRlKGRjLnN0YXRlKTsKIAotICAgICAgICBpZiAoUGhvbmUuREVCVUdfUEhPTkUpIGxvZygicGFyZW50PSAiICtwYXJlbnQgKyIsIG5ld1BhcmVudD0gIiArIG5ld1BhcmVudCk7CisgICAgICAgIGlmIChQaG9uZS5ERUJVR19QSE9ORSkgbG9nKCJwYXJlbnQ9ICIgK21QYXJlbnQgKyIsIG5ld1BhcmVudD0gIiArIG5ld1BhcmVudCk7CiAKLSAgICAgICAgaWYgKCFlcXVhbHNIYW5kbGVzTnVsbHMoYWRkcmVzcywgZGMubnVtYmVyKSkgeworICAgICAgICBpZiAoIWVxdWFsc0hhbmRsZXNOdWxscyhtQWRkcmVzcywgZGMubnVtYmVyKSkgewogICAgICAgICAgICAgaWYgKFBob25lLkRFQlVHX1BIT05FKSBsb2coInVwZGF0ZTogcGhvbmUgIyBjaGFuZ2VkISIpOwotICAgICAgICAgICAgYWRkcmVzcyA9IGRjLm51bWJlcjsKKyAgICAgICAgICAgIG1BZGRyZXNzID0gZGMubnVtYmVyOwogICAgICAgICAgICAgY2hhbmdlZCA9IHRydWU7CiAgICAgICAgIH0KIAogICAgICAgICAvLyBBIG51bGwgY25hcE5hbWUgc2hvdWxkIGJlIHRoZSBzYW1lIGFzICIiCiAgICAgICAgIGlmIChUZXh0VXRpbHMuaXNFbXB0eShkYy5uYW1lKSkgewotICAgICAgICAgICAgaWYgKCFUZXh0VXRpbHMuaXNFbXB0eShjbmFwTmFtZSkpIHsKKyAgICAgICAgICAgIGlmICghVGV4dFV0aWxzLmlzRW1wdHkobUNuYXBOYW1lKSkgewogICAgICAgICAgICAgICAgIGNoYW5nZWQgPSB0cnVlOwotICAgICAgICAgICAgICAgIGNuYXBOYW1lID0gIiI7CisgICAgICAgICAgICAgICAgbUNuYXBOYW1lID0gIiI7CiAgICAgICAgICAgICB9Ci0gICAgICAgIH0gZWxzZSBpZiAoIWRjLm5hbWUuZXF1YWxzKGNuYXBOYW1lKSkgeworICAgICAgICB9IGVsc2UgaWYgKCFkYy5uYW1lLmVxdWFscyhtQ25hcE5hbWUpKSB7CiAgICAgICAgICAgICBjaGFuZ2VkID0gdHJ1ZTsKLSAgICAgICAgICAgIGNuYXBOYW1lID0gZGMubmFtZTsKKyAgICAgICAgICAgIG1DbmFwTmFtZSA9IGRjLm5hbWU7CiAgICAgICAgIH0KIAotICAgICAgICBpZiAoUGhvbmUuREVCVUdfUEhPTkUpIGxvZygiLS1kc3Nkcy0tLS0iK2NuYXBOYW1lKTsKLSAgICAgICAgY25hcE5hbWVQcmVzZW50YXRpb24gPSBkYy5uYW1lUHJlc2VudGF0aW9uOwotICAgICAgICBudW1iZXJQcmVzZW50YXRpb24gPSBkYy5udW1iZXJQcmVzZW50YXRpb247CisgICAgICAgIGlmIChQaG9uZS5ERUJVR19QSE9ORSkgbG9nKCItLWRzc2RzLS0tLSIrbUNuYXBOYW1lKTsKKyAgICAgICAgbUNuYXBOYW1lUHJlc2VudGF0aW9uID0gZGMubmFtZVByZXNlbnRhdGlvbjsKKyAgICAgICAgbU51bWJlclByZXNlbnRhdGlvbiA9IGRjLm51bWJlclByZXNlbnRhdGlvbjsKIAotICAgICAgICBpZiAobmV3UGFyZW50ICE9IHBhcmVudCkgewotICAgICAgICAgICAgaWYgKHBhcmVudCAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgcGFyZW50LmRldGFjaCh0aGlzKTsKKyAgICAgICAgaWYgKG5ld1BhcmVudCAhPSBtUGFyZW50KSB7CisgICAgICAgICAgICBpZiAobVBhcmVudCAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgbVBhcmVudC5kZXRhY2godGhpcyk7CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBuZXdQYXJlbnQuYXR0YWNoKHRoaXMsIGRjKTsKLSAgICAgICAgICAgIHBhcmVudCA9IG5ld1Bhcm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ci0gICAgICAgIGlmIChpbmRleCA+PSAwKSB7Ci0gICAgICAgICAgICByZXR1cm4gaW5kZXggKyAxOworICAgICAgICBpZiAobUluZGV4ID49IDApIHsKKyAgICAgICAgICAgIHJldHVybiBtSW5kZXggKyAxOwogICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgdGhyb3cgbmV3IENhbGxTdGF0ZUV4Y2VwdGlvbiAoIkNETUEgY29ubmVjdGlvbiBpbmRleCBub3QgYXNzaWduZWQiKTsKICAgICAgICAgfQpAQCAtNTc1LDE3ICs1NjksMTcgQEAKICAgICAgKi8KICAgICB2b2lkCiAgICAgb25Db25uZWN0ZWRJbk9yT3V0KCkgewotICAgICAgICBjb25uZWN0VGltZSA9IFN5c3RlbS5jdXJyZW50VGltZU1pbGxpcygpOwotICAgICAgICBjb25uZWN0VGltZVJlYWwgPSBTeXN0ZW1DbG9jay5lbGFwc2VkUmVhbHRpbWUoKTsKLSAgICAgICAgZHVyYXRpb24gPSAwOworICAgICAgICBtQ29ubmVjdFRpbWUgPSBTeXN0ZW0uY3VycmVudFRpbWVNaWxsaXMoKTsKKyAgICAgICAgbUNvbm5lY3RUaW1lUmVhbCA9IFN5c3RlbUNsb2NrLmVsYXBzZWRSZWFsdGltZSgpOworICAgICAgICBtRHVyYXRpb24gPSAwOwogCiAgICAgICAgIC8vIGJ1ZyAjNjc4NDc0OiBpbmNvbWluZyBjYWxsIGludGVycHJldGVkIGFzIG1pc3NlZCBjYWxsLCBldmVuIHRob3VnaAogICAgICAgICAvLyBpdCBzb3VuZHMgbGlrZSB0aGUgdXNlciBoYXMgcGlja2VkIHVwIHRoZSBjYWxsLgogICAgICAgICBpZiAoUGhvbmUuREVCVUdfUEhPTkUpIHsKLSAgICAgICAgICAgIGxvZygib25Db25uZWN0ZWRJbk9yT3V0OiBjb25uZWN0VGltZT0iICsgY29ubmVjdFRpbWUpOworICAgICAgICAgICAgbG9nKCJvbkNvbm5lY3RlZEluT3JPdXQ6IGNvbm5lY3RUa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EgcG9zdC1kaWFsIGNoYXIsIGJ1dCBkb2VzIG5vdApAQCAtNjE1LDE0ICs2MDksMTQgQEAKICAgICBwcml2YXRlIGJvb2xlYW4KICAgICBwcm9jZXNzUG9zdERpYWxDaGFyKGNoYXIgYykgewogICAgICAgICBpZiAoUGhvbmVOdW1iZXJVdGlscy5pczEyS2V5KGMpKSB7Ci0gICAgICAgICAgICBvd25lci5jbS5zZW5kRHRtZihjLCBoLm9idGFpbk1lc3NhZ2UoRVZFTlRfRFRNRl9ET05FKSk7CisgICAgICAgICAgICBtT3duZXIubUNpLnNlbmREdG1mKGMsIG1IYW5kbGVyLm9idGFpbk1lc3NhZ2UoRVZFTlRfRFRNRl9ET05FKSk7CiAgICAgICAgIH0gZWxzZSBpZiAoYyA9PSBQaG9uZU51bWJlclV0aWxzLlBBVVNFKSB7CiAgICAgICAgICAgICBzZXRQb3N0RGlhbFN0YXRlKFBvc3REaWFsU3RhdGUuUEFVU0UpOwogCiAgICAgICAgICAgICAvLyBVcG9uIG9jY3VycmVuY2VzIG9mIHRoZSBzZXBhcmF0b3IsIHRoZSBVRSBzaGFsbAogICAgICAgICAgICAgLy8gcGF1c2UgYWdhaW4gZm9yIDIgc2Vjb25kcyBiZWZvcmUgc2VuZGluZyBhbnkKICAgICAgICAgICAgIC8vIGZ1cnRoZXIgRFRNRiBkaWdpdHMuCi0gICAgICAgICAgICBoLnNlbmRNZXNzYWdlRGVsYXllZChoLm9idGFpbk1lc3NhZ2UoRVZFTlRfUEFVU0VfRE9ORSksCisgICAgICAgICAgICBtSGFuZGxlci5zZW5kTWVzc2FnZURlbGF5ZWQobUhhbmRsZXIub2J0YWluTWVzc2FnZShFVkVOVF9QQVVTRV9ET05FKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUEFVU0VfREVMQVlfTUlMTElTKTsKICAgICAgICAgfSBlbHNlIGlmIChjID09IFBob25lTnVtYmVyVXRpbHMuV0FJVCkgewogICAgICAgICAgICAgc2V0UG9zdERpYWxTdGF0ZShQb3N0RGlhbFN0YXRlLldBSVQpOwpAQCAtNjM1LDE1ICs2MjksMTYgQEAKICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFN0cmluZyBnZXRSZW1haW5pbmdQb3N0RGlhbFN0cmluZygpIHsKLSAgICAgICAgaWYgKHBvc3REaWFsU3RhdGUgPT0gUG9zdERpYWxTdGF0ZS5DQU5DRUxMRUQKLSAgICAgICAgICAgICAgICB8fCBwb3N0RGlhbFN0YXRlID09IFBvc3REaWFsU3RhdGUuQ09NUExFVEUKLSAgICAgICAgICAgICAgICB8fCBwb3N0RGlhbFN0cmluZyA9PSBudWxsCi0gICAgICAgICAgICAgICAgfHwgcG9zdERpYWxTdHJpbmcubGVuZ3RoKCkgPD0gbmV4dFBvc3REaWFsQ2hhcikgeworICAgICAgICBpZiAobVBvc3REaWFsU3RhdGUgPT0gUG9zdERpYWxTdGF0ZS5DQU5DRUxMRUQKKyAgICAgICAgICAgICAgICB8fCBtUG9zdERpYWxTdGF0ZSA9PSBQb3N0RGlhbFN0YXRlLkNPTVBMRVRFCisgICAgICAgICAgICAgICAgfHwgbVBvc3REaWFsU3RyaW5nID09IG51bGwKKyAgICAgICAgICAgICAgICB8fCBtUG9zdERpYWxTdHJpbmcubGVuZ3RoKCkgPD0gbU5leHRQb3N0RGlhbENoYXIpIHsKICAgICAgICAgICAgIHJldHVybiAiIjsKICAgICAgICAgfQogCi0gICAgICAgIFN0cmluZyBzdWJTdHIgPSBwb3N0RGlhbFN0cmluZy5zdWJzdHJpbmcobmV4dFBvc3REaWFsQ2hhcik7CisgICAgICAgIFN0cmluZyBzdWJTdHIgPSBtUG9zdERpYWxTdHJpbmcuc3Vic3RyaW5nKG1OZXh0UG9zdERpYWxDaGFyKTsKICAgICAgICAgaWYgKHN1YlN0ciAhPSBudWxsKSB7CiAgICAgICAgICAgICBpbnQgd0luZGV4ID0gc3ViU3RyLmluZGV4T2YoUGhvbmVOdW1iZXJVdGlscy5XQUlUKTsKICAgICAgICAgICAgIGludCBwSW5kZXggPSBzdWJTdHIuaW5kZXhPZihQaG9uZU51bWJlclV0aWxzLlBBVVNFKTsKQEAgLTY2Myw3ICs2NTgsNyBAQAogICAgICAgICAgICAgICAgIG9sZFBhcmVudC5kZXRhY2godGhpcyk7CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBuZXdQYXJlbnQuYXR0YWNoRmFrZSh0aGlzLCBDZG1hQ2FsbC5TdGF0ZS5BQ1RJVkUpOwotICAgICAgICAgICAgcGFyZW50ID0gbmV3UGFyZW50OworICAgICAgICAgICAgbVBhcmVudCA9IG5ld1BhcmVudDsKICAgICAgICAgfQogICAgIH0KIApAQCAtNjg2LDE0ICs2ODEsMTQgQEAKICAgICAgICAgY2hhciBjID0gMDsKICAgICAgICAgUmVnaXN0cmFudCBwb3N0RGlhbEhhbmRsZXI7CiAKLSAgICAgICAgaWYgKHBvc3REaWFsU3RhdGUgPT0gUG9zdERpYWxTdGF0ZS5DQU5DRUxMRUQpIHsKKyAgICAgICAgaWYgKG1Qb3N0RGlhbFN0YXRlID09IFBvc3REaWFsU3RhdGUuQ0FOQ0VMTEVEKSB7CiAgICAgICAgICAgICByZWxlYXNlV2FrZUxvY2soKTsKICAgICAgICAgICAgIC8vUmxvZy52KCJDRE1BIiwgIiMjIyMjIHByb2Nlc3NOZXh0UG9zdERpYWxDaGFyOiBwb3N0RGlhbFN0YXRlID09IENBTkNFTExFRCwgYmFpbCIpOwogICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICB9CiAKLSAgICAgICAgaWYgKHBvc3REaWFsU3RyaW5nID09IG51bGwgfHwKLSAgICAgICAgICAgICAgICBwb3N0RGlhbFN0cmluZy5sZW5ndGgoKSA8PSBuZXh0UG9zdERpYWxDaGFyKSB7CisgICAgICAgIGlmIChtUG9zdERpYWxTdHJpbmcgPT0gbnVsbCB8fAorICAgICAgICAgICAgICAgI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AgICAgICAgICAgICB9CiAgICAgICAgIH0KIAotICAgICAgICBwb3N0RGlhbEhhbmRsZXIgPSBvd25lci5waG9uZS5tUG9zdERpYWxIYW5kbGVyOworICAgICAgICBwb3N0RGlhbEhhbmRsZXIgPSBtT3duZXIubVBob25lLm1Qb3N0RGlhbEhhbmRsZXI7CiAKICAgICAgICAgTWVzc2FnZSBub3RpZnlNZXNzYWdlOwogCiAgICAgICAgIGlmIChwb3N0RGlhbEhhbmRsZXIgIT0gbnVsbCAmJgogICAgICAgICAgICAgICAgIChub3RpZnlNZXNzYWdlID0gcG9zdERpYWxIYW5kbGVyLm1lc3NhZ2VGb3JSZWdpc3RyYW50KCkpICE9IG51bGwpIHsKICAgICAgICAgICAgIC8vIFRoZSBBc3luY1Jlc3VsdC5yZXN1bHQgaXMgdGhlIENvbm5lY3Rpb24gb2JqZWN0Ci0gICAgICAgICAgICBQb3N0RGlhbFN0YXRlIHN0YXRlID0gcG9zdERpYWxTdGF0ZTsKKyAgICAgICAgICAgIFBvc3REaWFsU3RhdGUgc3RhdGUgPSBtUG9zdERpYWxTdGF0ZTsKICAgICAgICAgICAgIEFzeW5jUmVzdWx0IGFyID0gQXN5bmNSZXN1bHQuZm9yTWVzc2FnZShub3RpZnlNZXNzYWdlKTsKICAgICAgICAgICAgIGFyLnJlc3VsdCA9IHRoaXM7CiAgICAgICAgICAgICBhci51c2VyT2JqID0gc3RhdGU7CkBAIC03NDQsOSArNzM5LDkgQEAKICAgICAgKi8KICAgICBwcml2YXRlIGJvb2xlYW4KICAgICBpc0Nvbm5lY3RpbmdJbk9yT3V0KCkgewotICAgICAgICByZXR1cm4gcGFyZW50ID09IG51bGwgfHwgcGFyZW50ID09IG93bmVyLnJpbmdpbmdDYWxsCi0gICAgICAgICAgICB8fCBwYXJlbnQuc3RhdGUgPT0gQ2RtYUNhbGwuU3RhdGUuRElBTElORwotICAgICAgICAgICAgfHwgcGFyZW50LnN0YXRlID09IENkbWFDYWxsLlN0YXRlLkFMRVJUSU5HOworICAgICAgICByZXR1cm4gbVBhcmVudCA9PSBudWxsIHx8IG1QYXJlbnQgPT0gbU93bmVyLm1SaW5naW5nQ2FsbAorICAgICAgICAgICAgfHwgbVBhcmVudC5tU3RhdGUgPT0gQ2RtYUNhbGwuU3RhdGUuRElBTElORworICAgICAgICAgICAgfHwgbVBhcmVudC5tU3RhdGUgPT0gQ2RtYUNhbGwuU3RhdGUuQUxFUlRJTkc7CiAgICAgfQogCiAgICAgcHJpdmF0ZSBDZG1hQ2FsbApAQCAtNzU1LDE2ICs3NTAsMTYgQEAKICAgICAgICAgICAgIGNhc2UgQUNUSVZFOgogICAgICAgICAgICAgY2FzZSBESUFMSU5HOgogICAgICAgICAgICAgY2FzZSBBTEVSVElORzoKLSAgICAgICAgICAgICAgICByZXR1cm4gb3duZXIuZm9yZWdyb3VuZENhbGw7CisgICAgICAgICAgICAgICAgcmV0dXJuIG1Pd25lci5tRm9yZWdyb3VuZENhbGw7CiAgICAgICAgICAgICAvL2JyZWFrOwogCiAgICAgICAgICAgICBjYXNlIEhPTERJTkc6Ci0gICAgICAgICAgICAgICAgcmV0dXJuIG93bmVyLmJhY2tncm91bmRDYWxsOworICAgICAgICAgICAgICAgIHJldHVybiBtT3duZXIubUJhY2tncm91bmRDYWxsOwogICAgICAgICAgICAgLy9icmVhazsKIAogICAgICAgICAgICAgY2FzZSBJTkNPTUlORzoKICAgICAgICAgICAgIGNhc2UgV0FJVElORzoKLSAgICAgICAgICAgICAgICByZXR1cm4gb3duZXIucmluZ2luZ0NhbGw7CisgICAgICAgICAgICAgICAgcmV0dXJuIG1Pd25lci5tUmluZ2luZ0NhbGw7CiAgICAgICAgICAgICAvL2JyZWFrOwogCiAgICAgICAgICAgICBkZWZhdWx0OgpAQCAtNzgzLDE4ICs3NzgsMTggQEAKICAgICAgICAgICAgICAgICBzID09IFBvc3REaWFsU3RhdGUuUEFVU0UpIHsKICAgICAgICAgICAgIHN5bmNocm9uaXplZCAobVBhcnRpYWxXYWtlTG9jaykgewogICAgICAgICAgICAgICAgIGlmIChtUGFydGlhbFdha2VMb2NrLmlzSGVsZCgpKSB7Ci0gICAgICAgICAgICAgICAgICAgIGgucmVtb3ZlTWVzc2FnZXMoRVZFTlRfV0FLRV9MT0NLX1RJTUVPVVQpOworICAgICAgICAgICAgICAgICAgICBtSGFuZGxlci5yZW1vdmVNZXNzYWdlcyhFVkVOVF9XQUtFX0xPQ0tfVElNRU9VVCk7CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgYWNxdWlyZVdha2VMb2NrKCk7CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIE1lc3NhZ2UgbXNnID0gaC5vYnRhaW5NZXNzYWdlKEVWRU5UX1dBS0VfTE9DS19USU1FT1VUKTsKLSAgICAgICAgICAgICAgICBoLnNlbmRNZXNzYWdlRGVsYXllZChtc2csIFdBS0VfTE9DS19USU1FT1VUX01JTExJUyk7CisgICAgICAgICAgICAgICAgTWVzc2FnZSBtc2cgPSBtSGFuZGxlci5vYnRhaW5NZXNzYWdlKEVWRU5UX1dBS0VfTE9DS19USU1FT1VUKTsKKyAgICAgICAgICAgICAgICBtSGFuZGxlci5zZW5kTWVzc2FnZURlbGF5ZWQobXNnLCBXQUtFX0xPQ0tfVElNRU9VVF9NSUxMSVMpOwogICAgICAgICAgICAgfQogICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgaC5yZW1vdmVNZXNzYWdlcyhFVkVOVF9XQUtFX0xPQ0tfVElNRU9VVCk7CisgICAgICAgICAgICBtSGFuZGxlci5yZW1vdmVNZXNzYWdlcyhFVkVOVF9XQUtFX0xPQ0tfVElNRU9VVCk7CiAgICAgICAgICAgICByZWxlYXNlV2FrZUxvY2soKTsKICAgICAgICAgfQotICAgICAgICBwb3N0RGlhbFN0YXRlID0gczsKKyAgICAgICAgbVBvc3REaWFsU3RhdGUgPSBzOwogICAgIH0KIAogICAgIHByaXZhdGUgdm9pZCBjcm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ZDsKLSAgICAgICAgfQotCi0gICAgICAgIGludCBwc1N0YXRlID0gbUNkbWFQaG9uZS5tU1NULmdldEN1cnJlbnREYXRhQ29ubmVjdGlvblN0YXRlKCk7Ci0gICAgICAgIGJvb2xlYW4gcm9hbWluZyA9IChtUGhvbmUuZ2V0U2VydmljZVN0YXRlKCkuZ2V0Um9hbWluZygpICYmICFnZXREYXRhT25Sb2FtaW5nRW5hYmxlZCgpKTsKLSAgICAgICAgYm9vbGVhbiBkZXNpcmVkUG93ZXJTdGF0ZSA9IG1DZG1hUGhvbmUubVNTVC5nZXREZXNpcmVkUG93ZXJTdGF0ZSgpOwotICAgICAgICBib29sZWFuIHN1YnNjcmlwdGlvbkZyb21OdiA9IChtQ2RtYVNTTS5nZXRDZG1hU3Vic2NyaXB0aW9uU291cmNlKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID09IENkbWFTdWJzY3JpcHRpb25Tb3VyY2VNYW5hZ2VyLlNVQlNDUklQVElPTl9GUk9NX05WKTsKLQotICAgICAgICBJY2NSZWNvcmRzIHIgPSBtSWNjUmVjb3Jkcy5nZXQoKTsKLSAgICAgICAgYm9vbGVhbiBhbGxvd2VkID0KLSAgICAgICAgICAgICAgICAgICAgKHBzU3RhdGUgPT0gU2VydmljZVN0YXRlLlNUQVRFX0lOX1NFUlZJQ0UgfHwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBtQXV0b0F0dGFjaE9uQ3JlYXRpb24pICYmCi0gICAgICAgICAgICAgICAgICAgIChzdWJzY3JpcHRpb25Gcm9tTnYgfHwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAociAhPSBudWxsICYmIHIuZ2V0UmVjb3Jkc0xvYWRlZCgpKSkgJiYKLSAgICAgICAgICAgICAgICAgICAgKG1DZG1hUGhvbmUubVNTVC5pc0NvbmN1cnJlbnRWb2ljZUFuZERhdGFBbGxvd2VkKCkgfHwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBtUGhvbmUuZ2V0U3RhdGUoKSA9PVBob25lQ29uc3RhbnRzLlN0YXRlLklETEUpICYmCi0gICAgICAgICAgICAgICAgICAgICFyb2FtaW5nICYmCi0gICAgICAgICAgICAgICAgICAgIGludGVybmFsRGF0YUVuYWJsZWQgJiYKLSAgICAgICAgICAgICAgICAgICAgZGVzaXJlZFBvd2VyU3RhdGUgJiYKLSAgICAgICAgICAgICAgICAgICAgIW1QZW5kaW5nUmVzdGFydFJhZGlvICYmCi0gICAgICAgICAgICAgICAgICAgICgobVBob25lLmdldEx0ZU9uQ2RtYU1vZGUoKSA9PVBob25lQ29uc3RhbnRzLkxURV9PTl9DRE1BX1RSVUUpIHx8Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgIW1DZG1hUGhvbmUubmVlZHNPdGFTZXJ2aWNlUHJvdmlzaW9uaW5nKCkpOwotICAgICAgICBpZiAoIWFsbG93ZWQgJiYgREJHKSB7Ci0gICAgICAgICAgICBTdHJpbmcgcmVhc29uID0gIiI7Ci0gICAgICAgICAgICBpZiAoISgocHNTdGF0ZSA9PSBTZXJ2aWNlU3RhdGUuU1RBVEVfSU5fU0VSVklDRSkgfHwgbUF1dG9BdHRhY2hPbkNyZWF0aW9uKSkgewotICAgICAgICAgICAgICAgIHJlYXNvbiArPSAiIC0gcHNTdGF0ZT0gIiArIHBzU3RhdGU7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBpZiAoIXN1YnNjcmlwdGlvbkZyb21OdiAmJgotICAgICAgICAgICAgICAgICAgICAhKHIgIT0gbnVsbCAmJiByLmdldFJlY29yZHNMb2FkZWQoKSkpIHsKLSAgICAgICAgICAgICAgICByZWFzb24gKz0gIiAtIFJVSU0gbm90IGxvYWRlZCI7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBpZiAoIShtQ2RtYVBob25lLm1TU1QuaXNDb25jdXJyZW50Vm9pY2VBbmREYXRhQWxsb3dlZCgpIHx8Ci0gICAgICAgICAgICAgICAgICAgIG1Q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gaWYKLSAgICAgKiAgICAgICAgICAgICAgbXVsdGlwbGUgQVBOIHR5cGVzIGFyZSBhc3NvY2lhdGVkIHdpdGggaXQuCi0gICAgICovCi0gICAgcHJpdmF0ZSB2b2lkIGNsZWFuVXBDb25uZWN0aW9uKGJvb2xlYW4gdGVhckRvd24sIFN0cmluZyByZWFzb24sIGJvb2xlYW4gZG9BbGwpIHsKLSAgICAgICAgaWYgKERCRykgbG9nKCJjbGVhblVwQ29ubmVjdGlvbjogcmVhc29uOiAiICsgcmVhc29uKTsKLQotICAgICAgICAvLyBDbGVhciB0aGUgcmVjb25uZWN0IGFsYXJtLCBpZiBzZXQuCi0gICAgICAgIGlmIChtUmVjb25uZWN0SW50ZW50ICE9IG51bGwpIHsKLSAgICAgICAgICAgIEFsYXJtTWFuYWdlciBhbSA9Ci0gICAgICAgICAgICAgICAgKEFsYXJtTWFuYWdlcikgbVBob25lLmdldENvbnRleHQoKS5nZXRTeXN0ZW1TZXJ2aWNlKENvbnRleHQuQUxBUk1fU0VSVklDRSk7Ci0gICAgICAgICAgICBhbS5jYW5jZWwobVJlY29ubmVjdEludGVudCk7Ci0gICAgICAgICAgICBtUmVjb25uZWN0SW50ZW50ID0gbnVsbDsKLSAgICAgICAgfQotCi0gICAgICAgIHNldFN0YXRlKERjdENvbnN0YW50cy5TdGF0ZS5ESVNDT05ORUNUSU5HKTsKLSAgICAgICAgbm90aWZ5T2ZmQXBuc09mQXZhaWxhYmlsaXR5KHJlYXNvbik7Ci0KLSAgICAgICAgYm9vbGVhbiBub3RpZmljYXRpb25EZWZlcnJlZCA9IGZhbHNlOwotICAgICAgICBmb3IgKERhdGFDb25uZWN0aW9uIGNvbm4gOiBtRGF0YUNvbm5lY3Rpb25zLnZhbHVlcygpKSB7Ci0gICAgICAgICAgICBpZihjb25uICE9IG51bGwpIHsKLSAgICAgICAgICAgICAgICBEYXRhQ29ubmVjdGlvbkFjIGRjYWMgPQotICAgICAgICAgICAgICAgICAgICBtRGF0YUNvbm5lY3Rpb25Bc3luY0NoYW5uZWxzLmdldChjb25uLmdldERhdGFDb25uZWN0aW9uSWQoKSk7Ci0gICAgICAgICAgICAgICAgaWYgKHRlYXJEb3duKSB7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChkb0FsbCkgewotICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJjbGVhblVwQ29ubmVjdGlvbjogdGVhcmRvd24sIGNvbm4udGVhckRvd25BbGwiKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGNvbm4udGVhckRvd25BbGwocmVhc29uLCBvYnRhaW5NZXNzYWdlKERjdENvbnN0YW50cy5FVkVOVF9ESVNDT05ORUNUX0RPTkUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbm4uZ2V0RGF0YUNvbm5lY3Rpb25JZCgpLCAwLCByZWFzb24pKTsKLSAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygiY2xlYW5VcENvbm5lY3Rpb246IHRlYXJkb3duLCBjb25uLnRlYXJEb3duIik7Ci0gICAgICAgICAgICAgICAgICAgICAgICBjb25uLnRlYXJEb3duKHJlYXNvbiwgb2J0YWluTWVzc2FnZShEY3RDb25zdGFudHMuRVZFTlRfRElTQ09OTkVDVF9ET05FLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25uLmdldERhdGFDb25uZWN0aW9uSWQoKSwgMCwgcmVhc29uKSk7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgbm90aWZpY2F0aW9uRGVmZXJyZWQgPSB0cnVlOwotICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygiY2xlYW5VcENvbm5lY3Rpb246ICF0ZWFyRG93biwgY2FsbCBjb25uLnJlc2V0U3luY2hyb25vdXNseSIpOwotICAgICAgICAgICAgICAgICAgICBpZiAoZGNhYyAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBkY2FjLnJlc2V0U3luYygpOwotICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgIG5vdGlmaWNhdGlvbkRlZmVycmVkID0gZmFsc2U7Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgfQotICAgICAgICB9Ci0KLSAgICAgICAgc3RvcE5ldFN0YXRQb2xsKCk7Ci0gICAgICAgIHN0b3BEYXRhU3RhbGxBbGFybSgpOwotCi0gICAgICAgIGlmICghbm90aWZpY2F0aW9uRGVmZXJyZWQpIHsKLSAgICAgICAgICAgIGlmIChEQkcpIGxvZygiY2xlYW51cENvbm5lY3Rpb246ICFub3RpZmljYXRpb25EZWZlcnJlZCIpOwotICAgICAgICAgICAgZ290b0lkbGVBbmROb3RpZnlEYXRhQ29ubmVjdGlvbihyZWFzb24pOwotICAgICAgICB9Ci0gICAgfQotCi0gICAgcHJpdmF0ZSBDZG1hRGF0YUNvbm5lY3Rpb24gZmluZEZyZWVEYXRhQ29ubmVjdGlvbigpIHsKLSAgICAgICAgZm9yIChEYXRhQ29ubmVjdGlvbkFjIGRjYWMgOiBtRGF0YUNvbm5lY3Rpb25Bc3luY0NoYW5uZWxzLnZhbHVlcygpKSB7Ci0gICAgICAgICAgICBpZiAoZGNhYy5pc0luYWN0aXZlU3luYygpKSB7Ci0gICAgICAgICAgICAgICAgbG9nKCJmb3VuZCBmcmVlIEdzbURhdGFDb25uZWN0aW9uIik7Ci0gICAgICAgICAgICAgICAgcmV0dXJuIChDZG1hRGF0YUNvbm5lY3Rpb24pIGRjYWMuZGF0YUNvbm5lY3Rpb247Ci0gICAgICAgICAgICB9Ci0gICAgICAgIH0KLSAgICAgICAgbG9nKCJOTyBmcmVlIENkbWFEYXRhQ29ubmVjdGlvbiIpOwotICAgICAgICByZXR1cm4gbnVsbDsKLSAgICB9Ci0KLSAgICBwcml2YXRlIGJvb2xlYW4g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GlmICggUGhvbmUuUkVBU09OX1JBRElPX1RVUk5FRF9PRkYuZXF1YWxzKHJlYXNvbikgKSB7Ci0gICAgICAgICAgICByZXRyeSA9IGZhbHNlOwotICAgICAgICB9Ci0gICAgICAgIHJldHVybiByZXRyeTsKLSAgICB9Ci0KLSAgICBwcml2YXRlIHZvaWQgcmVjb25uZWN0QWZ0ZXJGYWlsKEZhaWxDYXVzZSBsYXN0RmFpbENhdXNlQ29kZSwgU3RyaW5nIHJlYXNvbiwgaW50IHJldHJ5T3ZlcnJpZGUpIHsKLSAgICAgICAgaWYgKG1TdGF0ZSA9PSBEY3RDb25zdGFudHMuU3RhdGUuRkFJTEVEKSB7Ci0gICAgICAgICAgICAvKioKLSAgICAgICAgICAgICAqIEZvciBub3cgV2l0aCBDRE1BIHdlIG5ldmVyIHRyeSB0byByZWNvbm5lY3Qgb24KLSAgICAgICAgICAgICAqIGVycm9yIGFuZCBpbnN0ZWFkIGp1c3QgY29udGludWUgdG8gcmV0cnkKLSAgICAgICAgICAgICAqIGF0IHRoZSBsYXN0IHRpbWUgdW50aWwgdGhlIHN0YXRlIGlzIGNoYW5nZWQuCi0gICAgICAgICAgICAgKiBUT0RPOiBNYWtlIHRoaXMgY29uZmlndXJhYmxlPwotICAgICAgICAgICAgICovCi0gICAgICAgICAgICBpbnQgbmV4dFJlY29ubmVjdERlbGF5ID0gcmV0cnlPdmVycmlkZTsKLSAgICAgICAgICAgIGlmIChuZXh0UmVjb25uZWN0RGVsYXkgPCAwKSB7Ci0gICAgICAgICAgICAgICAgbmV4dFJlY29ubmVjdERlbGF5ID0gbURhdGFDb25uZWN0aW9ucy5nZXQoMCkuZ2V0UmV0cnlUaW1lcigpOwotICAgICAgICAgICAgICAgIG1EYXRhQ29ubmVjdGlvbnMuZ2V0KDApLmluY3JlYXNlUmV0cnlDb3VudCgpOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgc3RhcnRBbGFybUZvclJlY29ubmVjdChuZXh0UmVjb25uZWN0RGVsYXksIHJlYXNvbik7Ci0KLSAgICAgICAgICAgIGlmICghc2hvdWxkUG9zdE5vdGlmaWNhdGlvbihsYXN0RmFpbENhdXNlQ29kZSkpIHsKLSAgICAgICAgICAgICAgICBsb2coIk5PVCBQb3N0aW5nIERhdGEgQ29ubmVjdGlvbiBVbmF2YWlsYWJsZSBub3RpZmljYXRpb24gIgotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArICItLSBsaWtlbHkgdHJhbnNpZW50IGVycm9yIik7Ci0gICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgIG5vdGlmeU5vRGF0YShsYXN0RmFpbENhdXNlQ29kZSk7Ci0gICAgICAgICAgICB9Ci0gICAgICAgIH0KLSAgICB9Ci0KLSAgICBwcml2YXRlIHZvaWQgc3RhcnRBbGFybUZvclJlY29ubmVjdChpbnQgZGVsYXksIFN0cmluZyByZWFzb24pIHsKLQotICAgICAgICBsb2coIkRhdGEgQ29ubmVjdGlvbiBhY3RpdmF0ZSBmYWlsZWQuIFNjaGVkdWxpbmcgbmV4dCBhdHRlbXB0IGZvciAiCi0gICAgICAgICAgICAgICAgKyAoZGVsYXkgLyAxMDAwKSArICJzIik7Ci0KLSAgICAgICAgQWxhcm1NYW5hZ2VyIGFtID0KLSAgICAgICAgICAgIChBbGFybU1hbmFnZXIpIG1QaG9uZS5nZXRDb250ZXh0KCkuZ2V0U3lzdGVtU2VydmljZShDb250ZXh0LkFMQVJNX1NFUlZJQ0UpOwotICAgICAgICBJbnRlbnQgaW50ZW50ID0gbmV3IEludGVudChJTlRFTlRfUkVDT05ORUNUX0FMQVJNKTsKLSAgICAgICAgaW50ZW50LnB1dEV4dHJhKElOVEVOVF9SRUNPTk5FQ1RfQUxBUk1fRVhUUkFfUkVBU09OLCByZWFzb24pOwotICAgICAgICBtUmVjb25uZWN0SW50ZW50ID0gUGVuZGluZ0ludGVudC5nZXRCcm9hZGNhc3QoCi0gICAgICAgICAgICAgICAgbVBob25lLmdldENvbnRleH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cgaXMgc2V0dXAKLSAgICAgICAgICAgIG5vdGlmeURlZmF1bHREYXRhKHJlYXNvbik7Ci0gICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICBGYWlsQ2F1c2UgY2F1c2UgPSAoRmFpbENhdXNlKSAoYXIucmVzdWx0KTsKLSAgICAgICAgICAgIGlmKERCRykgbG9nKCJEYXRhIENvbm5lY3Rpb24gc2V0dXAgZmFpbGVkICIgKyBjYXVzZSk7Ci0KLSAgICAgICAgICAgIC8vIE5vIHRyeSBmb3IgcGVybWFuZW50IGZhaWx1cmUKLSAgICAgICAgICAgIGlmIChjYXVzZS5pc1Blcm1hbmVudEZhaWwoKSkgewotICAgICAgICAgICAgICAgIG5vdGlmeU5vRGF0YShjYXVzZSk7Ci0gICAgICAgICAgICAgICAgcmV0dXJuOwotICAgICAgICAgICAgfQotCi0gICAgICAgICAgICBpbnQgcmV0cnlPdmVycmlkZSA9IC0xOwotICAgICAgICAgICAgaWYgKGFyLmV4Y2VwdGlvbiBpbnN0YW5jZW9mIERhdGFDb25uZWN0aW9uLkNhbGxTZXR1cEV4Y2VwdGlvbikgewotICAgICAgICAgICAgICAgIHJldHJ5T3ZlcnJpZGUgPQotICAgICAgICAgICAgICAgICAgICAoKERhdGFDb25uZWN0aW9uLkNhbGxTZXR1cEV4Y2VwdGlvbilhci5leGNlcHRpb24pLmdldFJldHJ5T3ZlcnJpZGUoKTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGlmIChyZXRyeU92ZXJyaWRlID09IFJJTENvbnN0YW50cy5NQVhfSU5UKSB7Ci0gICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJObyByZXRyeSBpcyBzdWdnZXN0ZWQuIik7Ci0gICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgIHN0YXJ0RGVsYXllZFJldHJ5KGNhdXNlLCByZWFzb24sIHJldHJ5T3ZlcnJpZGUpOwotICAgICAgICAgICAgfQotICAgICAgICB9Ci0gICAgfQotC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PSAoaW50IFtdKWFyLnJlc3VsdDsKLSAgICAgICAgICAgIGlmICgob3RhUHJpdmlzaW9uICE9IG51bGwpICYmIChvdGFQcml2aXNpb24ubGVuZ3RoID4gMSkpIHsKLSAgICAgICAgICAgICAgICBzd2l0Y2ggKG90YVByaXZpc2lvblswXSkgewotICAgICAgICAgICAgICAgIGNhc2UgUGhvbmUuQ0RNQV9PVEFfUFJPVklTSU9OX1NUQVRVU19DT01NSVRURUQ6Ci0gICAgICAgICAgICAgICAgY2FzZSBQaG9uZS5DRE1BX09UQV9QUk9WSVNJT05fU1RBVFVTX09UQVBBX1NUT1BQRUQ6Ci0gICAgICAgICAgICAgICAgICAgIG1EYXRhQ29ubmVjdGlvbnMuZ2V0KDApLnJlc2V0UmV0cnlDb3VudCgpOwotICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICBkZWZhdWx0OgotICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICB9Ci0gICAgICAgIH0KLSAgICB9Ci0KLSAgICBwcml2YXRlIHZvaWQgb25SZXN0YXJ0UmFkaW8oKSB7Ci0gICAgICAgIGlmIChtUGVuZGluZ1Jlc3RhcnRSYWRpbykgewotICAgICAgICAgICAgbG9nKCIqKioqKioqKioqKipUVVJOIE9GRiBSQURJTyoqKioqKioqKioqKioqIik7Ci0gICAgICAgICAgICBtUGhvbmUubUNNLnNldFJhZGlvUG93ZXIoZmFsc2UsIG51bGwpOwotICAgICAgICAgICAgLyogTm90ZTogbm8gbmVlZCB0byBjYWxsIHNldFJhZGlvUG93ZXIodHJ1ZSkuICBBc3N1bWluZyB0aGUgZGVzaXJlZAotICAgICAgICAgICAgICogcmFkaW8gcG93ZXIgc3RhdGUgaXMgc3RpbGwgT04gKGFzIHRyYWNrZWQgYnkgU2VydmljZVN0YXRlVHJhY2tlciksCi0gICAgICAgICAgICAgKiBTZXJ2aWNlU3RhdGVUcmFja2VyIHdpbGw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AoYXIuZXhjZXB0aW9uICE9IG51bGwpIHsKLSAgICAgICAgICAgIC8vIFRoaXMgaXMgcHJvYmFibHkgInJhZGlvIG5vdCBhdmFpbGFibGUiIG9yIHNvbWV0aGluZwotICAgICAgICAgICAgLy8gb2YgdGhhdCBzb3J0LiBJZiBzbywgdGhlIHdob2xlIGNvbm5lY3Rpb24gaXMgZ29pbmcKLSAgICAgICAgICAgIC8vIHRvIGNvbWUgZG93biBzb29uIGFueXdheQotICAgICAgICAgICAgcmV0dXJuOwotICAgICAgICB9Ci0KLSAgICAgICAgaWYgKG1TdGF0ZSA9PSBEY3RDb25zdGFudHMuU3RhdGUuQ09OTkVDVEVEKSB7Ci0gICAgICAgICAgICBib29sZWFuIGlzQWN0aXZlT3JEb3JtYW50Q29ubmVjdGlvblByZXNlbnQgPSBmYWxzZTsKLSAgICAgICAgICAgIGludCBjb25uZWN0aW9uU3RhdGUgPSBEQVRBX0NPTk5FQ1RJT05fQUNUSVZFX1BIX0xJTktfSU5BQ1RJVkU7Ci0KLSAgICAgICAgICAgIC8vIENoZWNrIGZvciBhbiBhY3RpdmUgb3IgZG9ybWFudCBjb25uZWN0aW9uIGVsZW1lbnQgaW4KLSAgICAgICAgICAgIC8vIHRoZSBEQVRBX0NBTExfTElTVCBhcnJheQotICAgICAgICAgICAgZm9yIChpbnQgaW5kZXggPSAwOyBpbmRleCA8IGRhdGFDYWxsU3RhdGVzLnNpemUoKTsgaW5kZXgrKykgewotICAgICAgICAgICAgICAgIGNvbm5lY3Rpb25TdGF0ZSA9IGRhdGFDYWxsU3RhdGVzLmdldChpbmRleCkuYWN0aXZlOwotICAgICAgICAgICAgICAgIGlmIChjb25uZWN0aW9uU3RhdGUgIT0gREFUQV9DT05ORUNUSU9OX0FDVElWRV9QSF9MSU5LX0lOQUNUSVZFKSB7Ci0gICAgICAgICAgICAgICAgICAgIGlzQWN0aXZlT3JEb3JtYW50Q29ubmVjdGlvblByZXNlbnQgPSB0cnVlOwotICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgIGlmICghaXNBY3RpdmVPckRvcm1hbnRDb25uZWN0aW9uUHJlc2VudCkgewotICAgICAgICAgICAgICAgIC8vIE5vIGFjdGl2ZSBvciBkb3JtYW50IGNvbm5lY3Rpb24KLSAgICAgICAgICAgICAgICBsb2coIm9uRGF0YVN0YXRlQ2hhbmdlZDogTm8gYWN0aXZlIGNvbm5lY3Rpb24iCi0gICAgICAgICAgICAgICAgICAgICAgICArICJzdGF0ZSBpcyBDT05ORUNURUQsIGRpc2Nvbm5lY3RpbmcvY2xlYW51cCIpOwotICAgICAgICAgICAgICAgIHdyaXRlRXZlbnRMb2dDZG1hRGF0YURyb3AoKTsKLSAgICAgICAgICAgICAgICBjbGVhblVwQ29ubmVjdGlvbih0cnVlLCBudWxsLCBmYWxzZSk7Ci0gICAgICAgICAgICAgICAgcmV0dXJuOwotICAgICAgICAgICAgfQotCi0gICAgICAgICAgICBzd2l0Y2ggKGNvbm5lY3Rpb25TdGF0ZSkgewotICAgICAgICAgICAgICAgIGNhc2UgREFUQV9DT05ORUNUSU9OX0FDVElWRV9QSF9MSU5LX1VQOgotICAgICAgICAgICAgICAgICAgICBsb2coIm9uRGF0YVN0YXRlQ2hhbmdlZDogYWN0aXZlPUxJTktfQUNUSVZFICYmIENPTk5FQ1RFRCwgaWdub3JlIik7Ci0gICAgICAgICAgICAgICAgICAgIG1BY3Rpdml0eSA9IERjdENvbnN0YW50cy5BY3Rpdml0eS5OT05FOwotICAgICAgICAgICAgICAgICAgICBtUGhvbmUubm90aWZ5RGF0YUFjdGl2aXR5KCk7Ci0gICAgICAgICAgICAgICAgICAgIHN0YXJ0TmV0U3RhdFBvbGwoKTsKLSAgICAgICAgICAgICAgICAgICAgc3RhcnREYXRhU3RhbGxBbGFybShEQVRBX1NUQUxMX05PVF9TVVNQRUNURUQpOwotICAgICAgICAgICAgICAgICAgICBicmVhazsKLQotICAgICAgICAgICAgICAgIGNhc2UgREFUQV9DT05ORUNUSU9OX0FDVElWRV9QSF9MSU5LX0RPV046Ci0gICAgICAgICAgICAgICAgICAgIGxvZygib25EYXRhU3RhdGVDaGFuZ2VkIGFjdGl2ZT1MSU5LX0RPV04gJiYgQ09OTkVDVEVELCBkb3JtYW50Iik7Ci0gICAgICAgICAgICAgICAgICAgIG1BY3Rpdml0eSA9IERjdENvbnN0YW50cy5BY3Rpdml0eS5ET1JNQU5UOwotICAgICAgICAgICAgICAgICAgICBtUGhvbmUubm90aWZ5RGF0YUFjdGl2aXR5KCk7Ci0gICAgICAgICAgICAgICAgICAgIHN0b3BOZXRTdGF0UG9sbCgpOwotICAgICAgICAgICAgICAgICAgICBzdG9wRGF0YVN0YWxsQWxhcm0oKTsKLSAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0KLSAgICAgICAgICAgICAgICBkZWZhdWx0OgotICAgICAgICAgICAgICAgICAgICBsb2coIm9uRGF0YVN0YXRlQ2hhbmdlZDogSUdOT1JFIHVuZXhwZWN0ZWQgRGF0YUNhbGxTdGF0ZS5hY3RpdmU9IgotICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgY29ubmVjdGlvblN0YXRlKTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgIC8vIFRPRE86IERvIHdlIG5lZWQgdG8gZG8gYW55dGhpbmc/Ci0gICAgICAgICAgICBsb2coIm9uRGF0YVN0YXRlQ2hhbmdlZDogbm90IGNvbm5lY3RlZCwgc3RhdGU9IiArIG1TdGF0ZSArICIgaWdub3JpbmciKTsKLSAgICAgICAgfQotICAgIH0KLQotICAgIHByaXZhdGUgdm9pZCBzdGFydERlbGF5ZWRSZXRyeShGYWlsQ2F1c2UgY2F1c2UsIFN0cmluZyByZWFzb24sIGludCByZXRyeU92ZXJyaWRlKSB7Ci0gICAgICAgIG5vdGlmeU5vRGF0YShjYXVzZSk7Ci0gICAgICAgI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SAgICAgICAgICAgICAgICBvbkNkbWFEYXRhRGV0YWNoZWQoKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLQotICAgICAgICAgICAgY2FzZSBEY3RDb25zdGFudHMuRVZFTlRfREFUQV9TVEFURV9DSEFOR0VEOgotICAgICAgICAgICAgICAgIG9uRGF0YVN0YXRlQ2hhbmdlZCgoQXN5bmNSZXN1bHQpIG1zZy5vYmopOwotICAgICAgICAgICAgICAgIGJyZWFrOwotCi0gICAgICAgICAgICBjYXNlIERjdENvbnN0YW50cy5FVkVOVF9DRE1BX09UQV9QUk9WSVNJT046Ci0gICAgICAgICAgICAgICAgb25DZG1hT3RhUHJvdmlzaW9uKChBc3luY1Jlc3VsdCkgbXNnLm9iaik7Ci0gICAgICAgICAgICAgICAgYnJlYWs7Ci0KLSAgICAgICAgICAgIGNhc2UgRGN0Q29uc3RhbnRzLkVWRU5UX1JFU1RBUlRfUkFESU86Ci0gICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJFVkVOVF9SRVNUQVJUX1JBRElPIik7Ci0gICAgICAgICAgICAgICAgb25SZXN0YXJ0UmFkaW8oKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLQotICAgICAgICAgICAgZGVmYXVsdDoKLSAgICAgICAgICAgICAgICAvLyBoYW5kbGUgdGhlIG1lc3NhZ2UgaW4gdGhlIHN1cGVyIGNsYXNzIERhdGFDb25uZWN0aW9uVHJhY2tlcgotICAgICAgICAgICAgICAgIHN1cGVyLmhhbmRsZU1lc3NhZ2UobXNnKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgfQotICAgIH0KLQotICAgIEBPdmVycmlkZQotICAgIHByb3RlY3RlZCB2b2lkIG9uVXBkYXRlSWNjKCkgewotICAgICAgICBpZiAobVVpY2NDb250cm9sbGVyID09IG51bGwgKSB7Ci0gICAgICAgICAgICByZXR1cm47Ci0gICAgICAgIH0KLQotICAgICAgICBJY2NSZWNvcmRzIG5ld0ljY1JlY29yZHMgPSB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UyBmb3IgRVZFTlRfUE9MTF9TVEFURV9SRUdJU1RSQVRJT05fQ0RNQQotICAgICAqLwotICAgIEBPdmVycmlkZQotICAgIHByb3RlY3RlZCB2b2lkIHNldENkbWFUZWNobm9sb2d5KGludCByYWRpb1RlY2hub2xvZ3kpIHsKLSAgICAgICAgLy8gQ2FsbGVkIG9uIHZvaWNlIHJlZ2lzdHJhdGlvbiBzdGF0ZSByZXNwb25zZS4KLSAgICAgICAgLy8gSnVzdCByZWNvcmQgbmV3IENETUEgcmFkaW8gdGVjaG5vbG9neQotICAgICAgICBuZXdTUy5zZXRSYWRpb1RlY2hub2xvZ3kocmFkaW9UZWNobm9sb2d5KTsKLSAgICB9Ci0KLSAgICAvKioKICAgICAgKiBIYW5kbGUgdGhlIHJlc3VsdCBvZiBvbmUgb2YgdGhlIHBvbGxTdGF0ZSgpLXJlbGF0ZWQgcmVxdWVzdHMKICAgICAgKi8KICAgICBAT3ZlcnJpZGUKQEAgLTE0OCwxMSArMTI4LDExIEBACiAgICAgICAgICAgICAgICAgICAgIFN0cmluZyBvcGVyYXRvck51bWVyaWMgPSBudWxsOwogCiAgICAgICAgICAgICAgICAgICAgIHRyeSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBvcGVyYXRvck51bWVyaWMgPSBtTHRlU1MuZ2V0T3BlcmF0b3JOdW1lcmljKCk7CisgICAgICAgICAgICAgICAgICAgICAgICBvcGVyYXRvck51bWVyaWMgPSBtTmV3U1MuZ2V0T3BlcmF0b3JOdW1lcmljKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICBtY2MgPSBJbnRlZ2VyLnBhcnNlSW50KG9wZXJhdG9yTnVtZXJpYy5zdWJzdHJpbmcoMCwzKSk7CiAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKEV4Y2VwdGlvbiBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTnVtZXJpYyA9IHNzLmdldE9wZXJhdG9yTnVtZXJpYygpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTnVtZXJpYyA9IG1TUy5nZXRPcGVyYXRvck51bWVyaWMoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtY2MgPSBJbnRlZ2VyLnBhcnNlSW50KG9wZXJhdG9yTnVtZXJpYy5zdWJzdHJpbmcoMCwzKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2dlKCJoYW5kbGVQb2xsU3RhdGVSZXN1bHRNZXNzYWdlOiBiYWQgbWNjIG9wZXJhdG9yTnVtZXJpYz0iICsKQEAgLTIwOCw4ICsxODgsMTQgQEAKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgIG1MdGVTUy5zZXRSYWRpb1RlY2hub2xvZ3kodHlwZSk7Ci0gICAgICAgICAgICBtTHRlU1Muc2V0U3RhdGUocmVnQ29kZVRvU2VydmljZVN0YXRlKHJlZ1N0YXRlKSk7CisgICAgICAgICAgICBtTmV3U1Muc2V0UmlsRGF0YVJhZGlvVGVjaG5vbG9neSh0eXBlKTsKKyAgICAgICAgICAgIGludCBkYXRhUmVnU3RhdGUgPSByZWdDb2RlVG9TZXJ2aWNlU3RhdGUocmVnU3RhdGUpOworICAgICAgICAgICAgbU5ld1NTLnNldERhdGFSZWdTdGF0ZShkYXRhUmVnU3RhdGUpOworICAgICAgICAgICAgaWYgKERCRykgeworICAgICAgICAgICAgICAgIGxvZygiaGFuZGxQb2xsU3RhdGVSZXN1bHRNZXNzYWdlOiBDZG1hTHRlU1NUIHNldERhdGFSZWdTdGF0ZT0iICsgZGF0YVJlZ1N0YXRlCisgICAgICAgICAgICAgICAgICAgICAgICArICIgcmVnU3RhdGU9IiArIHJlZ1N0YXRlCisgICAgICAgICAgICAgICAgICAgICAgICArICIgZG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YWs7CiAKICAgICAgICAgICAgIGNhc2UgUkFESU9fT0ZGOgotICAgICAgICAgICAgICAgIG5ld1NTLnNldFN0YXRlT2ZmKCk7Ci0gICAgICAgICAgICAgICAgbUx0ZVNTLnNldFN0YXRlT2ZmKCk7Ci0gICAgICAgICAgICAgICAgbmV3Q2VsbExvYy5zZXRTdGF0ZUludmFsaWQoKTsKKyAgICAgICAgICAgICAgICBtTmV3U1Muc2V0U3RhdGVPZmYoKTsKKyAgICAgICAgICAgICAgICBtTmV3Q2VsbExvYy5zZXRTdGF0ZUludmFsaWQoKTsKICAgICAgICAgICAgICAgICBzZXRTaWduYWxTdHJlbmd0aERlZmF1bHRWYWx1ZXMoKTsKICAgICAgICAgICAgICAgICBtR290Q291bnRyeUNvZGUgPSBmYWxzZTsKIApAQCAtMjQ2LDEwNyArMjMwLDc0IEBACiAgICAgICAgICAgICAgICAgLy8gZG93biB0aGUgcmVzcG9uc2VzIHdoaWNoIGFyZSBhbGxvd2VkIHRvIGFycml2ZQogICAgICAgICAgICAgICAgIC8vIG91dC1vZi1vcmRlci4KIAotICAgICAgICAgICAgICAgIHBvbGxpbmdDb250ZXh0WzBdKys7CisgICAgICAgICAgICAgICAgbVBvbGxpbmdDb250ZXh0WzBdKys7CiAgICAgICAgICAgICAgICAgLy8gUklMX1JFUVVFU1RfT1BFUkFUT1IgaXMgbmVjZXNzYXJ5IGZvciBDRE1BCi0gICAgICAgICAgICAgICAgY20uZ2V0T3BlcmF0b3Iob2J0YWluTWVzc2FnZShFVkVOVF9QT0xMX1NUQVRFX09QRVJBVE9SX0NETUEsIHBvbGxpbmdDb250ZXh0KSk7CisgICAgICAgICAgICAgICAgbUNpLmdldE9wZXJhdG9yKG9idGFpbk1lc3NhZ2UoRVZFTlRfUE9MTF9TVEFURV9PUEVSQVRPUl9DRE1BLCBtUG9sbGluZ0NvbnRleHQpKTsKIAotICAgICAgICAgICAgICAgIHBvbGxpbmdDb250ZXh0WzBdKys7CisgICAgICAgICAgICAgICAgbVBvbGxpbmdDb250ZXh0WzBdKys7CiAgICAgICAgICAgICAgICAgLy8gUklMX1JFUVVFU1RfVk9JQ0VfUkVHSVNUUkFUSU9OX1NUQVRFIGlzIG5lY2Vzc2FyeSBmb3IgQ0RNQQotICAgICAgICAgICAgICAgIGNtLmdldFZvaWNlUmVnaXN0cmF0aW9uU3RhdGUob2J0YWluTWVzc2FnZShFVkVOVF9QT0xMX1NUQVRFX1JFR0lTVFJBVElPTl9DRE1BLAotICAgICAgICAgICAgICAgICAgICAgICAgcG9sbGluZ0NvbnRleHQpKTsKKyAgICAgICAgICAgICAgICBtQ2kuZ2V0Vm9pY2VSZWdpc3RyYXRpb25TdGF0ZShvYnRhaW5NZXNzYWdlKEVWRU5UX1BPTExfU1RBVEVfUkVHSVNUUkFUSU9OX0NETUEsCisgICAgICAgICAgICAgICAgICAgICAgICBtUG9sbGluZ0NvbnRleHQpKTsKIAotICAgICAgICAgICAgICAgIHBvbGxpbmdDb250ZXh0WzBdKys7CisgICAgICAgICAgICAgICAgbVBvbGxpbmdDb250ZXh0WzBdKys7CiAgICAgICAgICAgICAgICAgLy8gUklMX1JFUVVFU1RfREFUQV9SRUdJU1RSQVRJT05fU1RBVEUKLSAgICAgICAgICAgICAgICBjbS5nZXREYXRhUmVnaXN0cmF0aW9uU3RhdGUob2J0YWluTWVzc2FnZShFVkVOVF9QT0xMX1NUQVRFX0dQUlMsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvbGxpbmdDb250ZXh0KSk7CisgICAgICAgICAgICAgICAgbUNpLmdldERhdGFSZWdpc3RyYXRpb25TdGF0ZShvYnRhaW5NZXNzYWdlKEVWRU5UX1BPTExfU1RBVEVfR1BSUywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbVBvbGxpbmdDb250ZXh0KSk7CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIH0KICAgICB9CiAKICAgICBAT3Z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iICJ1cGRhdGUgc2VjdXJlIHNldCB2YWx1ZT0nMTEnIHdoZXJlIG5hbWU9J3ByZWZlcnJlZF9uZXR3b3JrX21vZGUnIgotICAgICAgICBpZiAobmV3U1MuZ2V0U3RhdGUoKSA9PSBTZXJ2aWNlU3RhdGUuU1RBVEVfT1VUX09GX1NFUlZJQ0UpIHsKLSAgICAgICAgICAgIGludCBuZXR3b3JrTW9kZSA9IGFuZHJvaWQucHJvdmlkZXIuU2V0dGluZ3MuR2xvYmFsLmdldEludChwaG9uZS5nZXRDb250ZXh0KCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0Q29udGVudFJlc29sdmVyKCksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5kcm9pZC5wcm92aWRlci5TZXR0aW5ncy5HbG9iYWwuUFJFRkVSUkVEX05FVFdPUktfTU9ERSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBSSUxDb25zdGFudHMuUFJFRkVSUkVEX05FVFdPUktfTU9ERSk7Ci0gICAgICAgICAgICBpZiAobmV0d29ya01vZGUgPT0gUklMQ29uc3RhbnRzLk5FVFdPUktfTU9ERV9MVEVfT05MWSkgewotICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygicG9sbFN0YXRlOiBMVEUgT25seSBtb2RlIik7Ci0gICAgICAgICAgICAgICAgbmV3U1Muc2V0U3RhdGUobUx0ZVNTLmdldFN0YXRlKCkpOwotICAgICAgICAgICAgfQotICAgICAgICB9CisgICAgICAgIGJvb2xlYW4gaGFzUmVnaXN0ZXJlZCA9IG1TUy5nZXRWb2ljZVJlZ1N0YXRlKCkgIT0gU2VydmljZVN0YXRlLlNUQVRFX0lOX1NFUlZJQ0UKKyAgICAgICAgICAgICAgICAmJiBtTmV3U1MuZ2V0Vm9pY2VSZWdTdGF0ZSgpID09IFNlcnZpY2VTdGF0ZS5TVEFURV9JTl9TRVJWSUNFOwogCi0gICAgICAgIGlmIChEQkcp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AgICAgICAgaWYgKHNzLmdldFN0YXRlKCkgPT0gU2VydmljZVN0YXRlLlNUQVRFX0lOX1NFUlZJQ0UpIHsKLSAgICAgICAgICAgICAgICAgICAgZXJpVGV4dCA9IHBob25lLmdldENkbWFFcmlUZXh0KCk7Ci0gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzcy5nZXRTdGF0ZSgpID09IFNlcnZpY2VTdGF0ZS5TVEFURV9QT1dFUl9PRkYpIHsKKyAgICAgICAgICAgICAgICBpZiAobVNTLmdldFZvaWNlUmVnU3RhdGUoKSA9PSBTZXJ2aWNlU3RhdGUuU1RBVEVfSU5fU0VSVklDRSkgeworICAgICAgICAgICAgICAgICAgICBlcmlUZXh0ID0gbVBob25lLmdldENkbWFFcmlUZXh0KCk7CisgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChtU1MuZ2V0Vm9pY2VSZWdTdGF0ZSgpID09IFNlcnZpY2VTdGF0ZS5TVEFURV9QT1dFUl9PRkYpIHsKICAgICAgICAgICAgICAgICAgICAgZXJpVGV4dCA9IChtSWNjUmVjb3JkcyAhPSBudWxsKSA/IG1JY2NSZWNvcmRzLmdldFNlcnZpY2VQcm92aWRlck5hbWUoKSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgIGlmIChUZXh0VXRpbHMuaXNFbXB0eShlcmlUZXh0KSkgewogICAgICAgICAgICAgICAgICAgICAgICAgLy8gU2V0cyBvcGVyYXRvciBhbHBoYSBwcm9wZXJ0eSBieSByZXRyaWV2aW5nIGZyb20KQEAgLTQyOSw0MCArMzYyLDQwIEBACiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgLy8gTm90ZSB0aGF0IFNlcnZpY2VTdGF0ZS5TVEFURV9PVVRfT0ZfU0VSVklDRSBpcyB2YWxpZCB1c2VkCiAgICAgICAgICAgICAgICAgICAgIC8vIGZvciBtUmVnaXN0cmF0aW9uU3RhdGUgMCwyLDMgYW5kIDQKLSAgICAgICAgICAgICAgICAgICAgZXJpVGV4dCA9IHBob25lLmdldENvbnRleHQoKQorICAgICAgICAgICAgICAgICAgICBlcmlUZXh0ID0gbVBob25lLmdldENvbnRleHQoKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLnJvYW1pbmdUZXh0U2VhcmNoaW5nKS50b1N0cmluZygpOwogICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBzcy5zZXRPcGVyYXRvckFscGhhTG9uZyhlcmlUZXh0KTsKKyAgICAgICAgICAgICAgICBtU1Muc2V0T3BlcmF0b3JBbHBoYUxvbmcoZXJpVGV4dCk7CiAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgIGlmIChtVWljY0FwcGxjYXRpb24gIT0gbnVsbCAmJiBtVWljY0FwcGxjYXRpb24uZ2V0U3RhdGUoKSA9PSBBcHBTdGF0ZS5BUFBTVEFURV9SRUFEWSAmJgogICAgICAgICAgICAgICAgICAgICBtSWNjUmVjb3JkcyAhPSBudWxsKSB7CiAgICAgICAgICAgICAgICAgLy8gU0lNIGlzIGZvdW5kIG9uIHRoZSBkZXZpY2UuIElmIEVSSSByb2FtaW5nIGlzIE9GRiwgYW5kIFNJRC9OSUQgbWF0Y2hlcwotICAgICAgICAgICAgICAgIC8vIG9uZSBjb25maWdmdXJlZCBpbiBTSU0sIHVzZSBvcGVyYXRvciBuYW1lICBmcm9tIENTSU0gcmVjb3JkLgorICAgICAgICAgICAgICAgIC8vIG9uZSBjb25maWd1cmVkIGluIFNJTSwgdXNlIG9wZXJhdG9yIG5hbWUgIGZyb20gQ1NJTSByZWNvcmQuCiAgICAgICAgICAgICAgICAgYm9vbGVhbiBzaG93U3BuID0KICAgICAgICAgICAgICAgICAgICAgKChSdWltUmVjb3JkcyltSWNjUmVjb3JkcykuZ2V0Q3NpbVNwbkRpc3BsYXlDb25kaXRpb24oKTsKLSAgICAgICAgICAgICAgICBpbnQgaWNvbkluZGV4ID0gc3MuZ2V0Q2RtYUVyaUljb25JbmRleCgpOworICAgICAgICAgICAgICAgIGludCBpY29uSW5kZXggPSBtU1MuZ2V0Q2RtYUVyaUljb25JbmRleCgpOwogCiAgICAgICAgICAgICAgICAgaWYgKHNob3dTcG4gJiYgKGljb25JbmRleCA9PSBFcmlJbmZvLlJPQU1JTkdfSU5ESUNBVE9SX09GRikgJiYKLSAgICAgICAgICAgICAgICAgICAgaXNJbkhvbWVTaWROaWQoc3MuZ2V0U3lzdGVtSWQoKSwgc3MuZ2V0TmV0d29ya0lkKCkpICYmCisgICAgICAgICAgICAgICAgICAgIGlzSW5Ib21lU2lkTmlkKG1TUy5nZXRTeXN0ZW1JZCgpLCBtU1MuZ2V0TmV0d29ya0lkKCkpICYmCiAgICAgICAgICAgICAgICAgICAgIG1JY2NSZWNvcmRzICE9IG51bGwpIHsKLSAgICAgICAgICAgICAgICAgICAgc3Muc2V0T3BlcmF0b3JBbHBoYUxvbmcobUljY1JlY29yZHMuZ2V0U2VydmljZVByb3ZpZGVyTmFtZSgpKTsKKyAgICAgICAgICAgICAgICAgICAgbVNTLnNldE9wZXJhdG9yQWxwaGFMb25nKG1JY2NSZWNvcmRzLmdldFNlcnZpY2VQcm92aWRlck5hbWUoKSk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogCiAgICAgICAgICAgICBTdHJpbmcgb3BlcmF0b3JOdW1lcmljOwogCi0gICAgICAgICAgICBwaG9uZS5zZXRTeXN0ZW1Qcm9wZXJ0eShUZWxlcGhvbnlQcm9wZXJ0aWVzLlBST1BFUlRZX09QRVJBVE9SX0FMUEhBLAotICAgICAgICAgICAgICAgICAgICBzcy5nZXRPcGVyYXRvckFscGhhTG9uZygpKTsKKyAgICAgICAgICAgIG1QaG9uZS5zZXRTeXN0ZW1Qcm9wZXJ0eShUZWxlcGhvbnlQcm9wZXJ0aWVzLlBST1BFUlRZX09QRVJBVE9SX0FMUEhBLAorICAgICAgICAgICA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gICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgU3RyaW5nIGlzb0NvdW50cnlDb2RlID0gIiI7CkBAIC00NzYsMjEgKzQwOSwyMSBAQAogICAgICAgICAgICAgICAgICAgICBsb2dlKCJjb3VudHJ5Q29kZUZvck1jYyBlcnJvciIgKyBleCk7CiAgICAgICAgICAgICAgICAgfQogCi0gICAgICAgICAgICAgICAgcGhvbmUuc2V0U3lzdGVtUHJvcGVydHkoVGVsZXBob255UHJvcGVydGllcy5QUk9QRVJUWV9PUEVSQVRPUl9JU09fQ09VTlRSWSwKKyAgICAgICAgICAgICAgICBtUGhvbmUuc2V0U3lzdGVtUHJvcGVydHkoVGVsZXBob255UHJvcGVydGllcy5QUk9QRVJUWV9PUEVSQVRPUl9JU09fQ09VTlRSWSwKICAgICAgICAgICAgICAgICAgICAgICAgIGlzb0NvdW50cnlDb2RlKTsKICAgICAgICAgICAgICAgICBtR290Q291bnRyeUNvZGUgPSB0cnVlOwogCi0gICAgICAgICAgICAgICAgaWYgKHNob3VsZEZpeFRpbWVab25lTm93KHBob25lLCBvcGVyYXRvck51bWVyaWMsIHByZXZPcGVyYXRvck51bWVyaWMsCisgICAgICAgICAgICAgICAgaWYgKHNob3VsZEZpeFRpbWVab25lTm93KG1QaG9uZSwgb3BlcmF0b3JOdW1lcmljLCBwcmV2T3BlcmF0b3JOdW1lcmljLAogICAgICAgICAgICAgICAgICAgICAgICAgbU5lZWRGaXhab25lKSkgewogICAgICAgICAgICAgICAgICAgICBmaXhUaW1lWm9uZShpc29Db3VudHJ5Q29kZSk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogCi0gICAgICAgICAgICBwaG9uZS5zZXRTeXN0ZW1Qcm9wZXJ0eShUZWxlcGhvbnlQcm9wZXJ0aWVzLlBST1BFUlRZX09QRVJBVE9SX0lTUk9BTUlORywKLSAgICAgICAgICAgICAgICAgICAgc3MuZ2V0Um9hbWluZygpID8gInRydWUiIDogImZhbHNlIik7Cisg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Sk7CisgICAgICAgICAgICByZXQubVB3ZCA9IG1ha2VFbXB0eU51bGwobS5ncm91cChNQVRDSF9HUk9VUF9QV0RfQ09ORklSTSkpOworICAgICAgICAgICAgcmV0Lm1EaWFsaW5nTnVtYmVyID0gbWFrZUVtcHR5TnVsbChtLmdyb3VwKE1BVENIX0dST1VQX0RJQUxJTkdfTlVNQkVSKSk7CiAKICAgICAgICAgfQogCkBAIC0xMzcsMzQgKzEzNywzOCBAQAogCiAgICAgQ2RtYU1taUNvZGUgKENETUFQaG9uZSBwaG9uZSkgewogICAgICAgICBzdXBlcihwaG9uZS5nZXRIYW5kbGVyKCkuZ2V0TG9vcGVyKCkpOwotICAgICAgICB0aGlzLnBob25lID0gcGhvbmU7Ci0gICAgICAgIHRoaXMuY29udGV4dCA9IHBob25lLmdldENvbnRleHQoKTsKKyAgICAgICAgbVBob25lID0gcGhvbmU7CisgICAgICAgIG1Db250ZXh0ID0gcGhvbmUuZ2V0Q29udGV4dCgpOwogICAgIH0KIAogICAgIC8vIE1taUNvZGUgaW1wbGVtZW50YXRpb24KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdGF0ZQogICAgIGdldFN0YXRlKCkgewotICAgICAgICByZXR1cm4gc3RhdGU7CisgICAgICAgIHJldHVybiBtU3RhdGU7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIENoYXJTZXF1ZW5jZQogICAgIGdldE1lc3NhZ2UoKSB7Ci0gICAgICAgIHJldHVybiBtZXNzYWdlOworICAgICAgICByZXR1cm4gbU1lc3NhZ2U7CiAgICAgfQogCiAgICAgLy8gaW5oZXJpdGVkIGphdmFkb2Mgc3VmZmljZXMKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZAogICAgIGNhbmNlbCgpIHsKICAgICAgICAgLy8gQ29tcGxldGUgb3IgZmFpbGVkIGNhbm5vdCBiZSBjYW5jZWxsZWQKLSAgICAgICAgaWYgKHN0YXRlID09IFN0YXRlLkNPTVBMRVRFIHx8IHN0YXRlID09IFN0YXRlLkZBSUxFRCkgeworICAgICAgICBpZiAobVN0YXRlID09IFN0YXRlLkNPTVBMRVRFIHx8IG1TdGF0ZSA9PSBTdGF0ZS5GQUlMRUQpIHsKICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgfQogCi0gICAgICAgIHN0YXRlID0gU3RhdGUuQ0FOQ0VMTEVEOwotICAgICAgICBwaG9uZS5vbk1NSURvbmUgKHRoaXMpOworICAgICAgICBtU3RhdGUgPSBTdGF0ZS5DQU5DRUxMRUQ7CisgICAgICAgIG1QaG9uZS5vbk1NSURvbmUgKHRoaXMpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBib29sZWFuIGlzQ2FuY2VsYWJsZSgpIHsKICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgIH0KQEAgLTE3NSwxMyArMTc5LDE0IEBACiAgICAgICogQHJldHVybiB0cnVlIGlmIHRoZSBTZXJ2aWNlIENvZGUgaXMgUElOL1BJTjIvUFVLL1BVSzItcmVsYXRlZAogICAgICAqLwogICAgIGJvb2xlYW4gaXNQdWtDb21tYW5kKCkgewotICAgICAgICByZXR1cm4gc2MgIT0gbnVsbCAmJiBzYy5lcXVhbHMoU0NfUFVLKTsKKyAgICAgICAgcmV0dXJuIG1TYyAhPSBudWxsICYmIG1TYy5lcXVhbHMoU0NfUFVLKTsKICAgICAgfQogCiAgICAgYm9vbGVhbiBpc1JlZ2lzdGVyKCkgewotICAgICAgICByZXR1cm4gYWN0aW9uICE9IG51bGwgJiYgYWN0aW9uLmVxdWFscyhBQ1RJT05fUkVHSVNURVIpOworICAgICAgICByZXR1cm4gbUFjdGlvbiAhPSBudWxsICYmIG1BY3Rpb24uZXF1YWxzKEFDVElPTl9SRUdJU1RFUik7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGJvb2xlYW4gaXNVc3NkUmVxdWVzdCgpIHsKICAgICAgICAgUmxvZy53KExPR19UQUcsICJpc1Vzc2RSZXF1ZXN0IGlzIG5vdCBpbXBsZW1lbnRlZCBpbiBDZG1hTW1pQ29kZSIpOwogICAgICAgICByZXR1cm4gZmFsc2U7CkBAIC0xOTUsMTggKzIwMCwxOCBAQAogICAgICAgICAgICAgICAgIC8vIHNpYSA9IG9sZCBQVUsKICAgICAgICAgICAgICAgICAvLyBzaWIgPSBuZXcgUElOCiAgICAgICAgICAgICAgICAgLy8gc2ljID0gbmV3IFBJTgotICAgICAgICAgICAgICAgIFN0cmluZyBvbGRQaW5PclB1ayA9IHNpYTsKLSAgICAgICAgICAgICAgICBTdHJpbmcgbmV3UGluID0gc2liOworICAgICAgICAgICAgICAgIFN0cmluZyBvbGRQaW5PclB1ayA9IG1TaWE7CisgICAgICAgICAgICAgICAgU3RyaW5nIG5ld1BpbiA9IG1TaWI7CiAgICAgICAgICAgICAgICAgaW50IHBpbkxlbiA9IG5ld1Bpbi5sZW5ndGgoKTsKICAgICAgICAgICAgICAgICBpZiAoaXNSZWdpc3RlcigpKSB7Ci0gICAgICAgICAgICAgICAgICAgIGlmICghbmV3UGluLmVxdWFscyhzaWMpKSB7CisgICAgICAgICAgICAgICAgICAgIGlmICghbmV3UGluLmVxdWFscyhtU2ljKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgLy8gcGFzc3dvcmQgbWlzbWF0Y2g7IHJldHVybiBlcnJvcgogICAgICAgICAgICAgICAgICAgICAgICAgaGFuZGxlUGFzc3dvcmRFcnJvcihjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5taXNtYXRjaFBpbik7CiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAocGluTGVuIDwgNCB8fCBwaW5MZW4gPiA4ICkgewogICAgICAgICAgICAgICAgICAgICAgICAgLy8gaW52YWxpZCBsZW5ndGgKICAgICAgICAgICAgICAgICAgICAgICAgIGhhbmRsZVBhc3N3b3JkRXJyb3IoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuaW52YWxpZFBpbik7CiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBwaG9uZS5tQ00uc3VwcGx5SWNjUHVrKG9sZFBpbk9yUHVrLCBuZXdQaW4sCisgICAgICAgICAgICAgICAgICAgICAgICBtUGhvbmUubUNpLnN1cHBseUljY1B1ayhvbGRQaW5PclB1aywgbmV3UGluLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX1NFVF9DT01QTEVURSwgdGhpcykpOwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKQEAgLTIxNiwyMSArMjIxLDIyIEBACiAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IFJ1bnRpbWVFeGNlcHRpb24gKCJJbnZhbGlkIG9yIFVuc3VwcG9ydGVkIE1NSSBDb2RlIik7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0gY2F0Y2ggKFJ1bnRpbWVFeGNlcHRpb24gZXhjKSB7Ci0gICAgICAgICAgICBzdGF0ZSA9IFN0YXRlLkZBSUxFRDsKLSAgICAgICAgICAgIG1lc3NhZ2UgPSBjb250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcubW1pRXJyb3IpOwotICAgICAgICAgICAgcGhvbmUub25NTUlEb25lKHRoaXMpOworICAgICAgICAgICAgbVN0YXRlID0gU3RhdGUuRkFJTEVEOworICAgICAgICAgICAgbU1lc3NhZ2UgPSBtQ29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLm1taUVycm9yKTsKKyAgICAgICAgICAgIG1QaG9uZS5vbk1NSURvbmUodGhpcyk7CiAgICAgICAgIH0KICAgICB9CiAKICAgICBwcml2YXRlIHZvaWQgaGFuZGxlUGFzc3dvcmRFcnJvcihpbnQgcmVzKSB7Ci0gICAgICAgIHN0YXRlID0gU3RhdGUuRkFJTEVEOworICAgICAgICBtU3RhdGUgPSBTdGF0ZS5GQUlMRUQ7CiAgICAgICAgIFN0cmluZ0J1aWxkZXIgc2IgPSBuZXcgU3RyaW5nQnVpbGRlcihnZXRTY1N0cmluZygpKTsKICAgICAgICAgc2IuYXBwZW5kKCJcbiIpOwotICAgICAgICBzYi5hcHBlbmQoY29udGV4dC5nZXRUZXh0KHJlcykpOwotICAgICAgICBtZXNzYWdlID0gc2I7Ci0gICAgICAgIHBob25lLm9uTU1JRG9uZSh0aGlzKTsKKyAgICAgICAgc2IuYXBwZW5kKG1Db250ZXh0LmdldFRleHQocmVzKSk7CisgICAgICAgIG1NZXNzYWdlID0gc2I7CisgICAgICAgIG1QaG9uZS5vbk1NSURvbmUodGhpcyk7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQKICAgICBoYW5kbGVNZXNzYWdlIChNZXNzYWdlIG1zZykgewogICAgICAgICBBc3luY1Jlc3VsdCBhcjsKQEAgLTI0NSw5ICsyNTEsOSBAQAogICAgIC8vIFByaXZhdGUgaW5zdGFuY2UgbWV0aG9kcwogCiAgICAgcHJpdmF0ZSBDaGFyU2VxdWVuY2UgZ2V0U2NTdHJpbmcoKSB7Ci0gICAgICAgIGlmIChzYyAhPSBudWxsKSB7CisgICAgICAgIGlmIChtU2MgIT0gbnVsbCkgewogICAgICAgICAgICAgaWYgKGlzUHVrQ29tbWFuZCgpKSB7Ci0gICAgICAgICAgICAgICAgcmV0dXJuIGNvbnRleHQuZ2V0VGV4dChjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5QaW5NbWkpOworICAgICAgICAgICAgICAgIHJldHVybiBtQ29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLlBpbk1taSk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KIApAQCAtMjYwLDM3ICsyNjYsMzcgQEAKICAgICAgICAgc2IuYXBwZW5kKCJcbiIpOwogCiAgICAgICAgIGlmIChhci5leGNlcHRpb24gIT0gbnVsbCkgewotICAgICAgICAgICAgc3RhdGUgPSBTdGF0ZS5GQUlMRUQ7CisgICAgICAgICAgICBtU3RhdGUgPSBTdGF0ZS5GQUlMRUQ7CiAgICAgICAgICAgICBpZiAoYXIuZXhjZXB0aW9uIGluc3RhbmNlb2YgQ29tbWFuZEV4Y2VwdGlvbikgewogICAgICAgICAgICAgICAgIENvbW1hbmRFeGNlcHRpb24uRXJyb3IgZXJyID0gKChDb21tYW5kRXhjZXB0aW9uKShhci5leGNlcHRpb24pKS5nZXRDb21tYW5kRXJyb3IoKTsKICAgICAgICAgICAgICAgICBpZiAoZXJyID09IENvbW1hbmRFeGNlcHRpb24uRXJyb3IuUEFTU1dPUkRfSU5DT1JSRUNUKSB7CiAgICAgICAgICAgICAgICAgICAgIGlmIChpc1B1a0NvbW1hbmQoKSkgewotICAgICAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKGNvbnRleHQuZ2V0VGV4dCgKKyAgICAgICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChtQ29udGV4dC5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5iYWRQdWspKTsKICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQobUNvbnRleHQuZ2V0VGV4dCgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcucGFzc3dvcmRJbmNvcnJlY3QpKTsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChtQ29udGV4dC5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLm1taUVycm9yKSk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICBzYi5hcHBlbmQoY29udGV4dC5nZXRUZXh0KAorICAgICAgICAgICAgICAgIHNiLmFwcGVuZChtQ29udGV4dC5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcubW1pRXJyb3IpKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfSBlbHNlIGlmIChpc1JlZ2lzdGVyKCkpIHsKLSAgICAgICAgICAgIHN0YXRlID0gU3RhdGUuQ09NUExFVEU7Ci0gICAgICAgICAgICBzYi5hcHBlbmQoY29udGV4dC5nZXRUZXh0KAorICAgICAgICAgICAgbVN0YXRlID0gU3RhdGUuQ09NUExFVEU7CisgICAgICAgICAgICBzYi5hcHBlbmQobUNvbnRleHQuZ2V0VGV4dCgKICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuc2VydmljZVJlZ2lzdGVyZWQpKTsKICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgIHN0YXRlID0gU3RhdGUuRkFJTEVEOwotICAgICAgICAgICAgc2IuYXBwZW5kKGNvbnRleHQuZ2V0VGV4dCgKKyAgICAgICAgICAgIG1TdGF0ZSA9IFN0YXRlLkZBSUxFRDsKKyAgICAgICAgICAgIHNiLmFwcGVuZChtQ29udGV4dC5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICBjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5tbWlFcnJvcikpOwogICAgICAgICB9CiAKLSAgICAgICAgbWVz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dEludChtUGhvbmUuZ2V0Q29udGV4dCgpLmdldENvbnRlbnRSZXNvbHZlcigpLAogICAgICAgICAgICAgICAgIFNldHRpbmdzLkdsb2JhbC5DRE1BX1NVQlNDUklQVElPTl9NT0RFLAogICAgICAgICAgICAgICAgIHNvdXJjZSApOwogICAgIH0KIAogICAgIHByaXZhdGUgdm9pZCBnZXRTdWJzY3JpcHRpb25JbmZvQW5kU3RhcnRQb2xsaW5nVGhyZWFkcygpIHsKLSAgICAgICAgY20uZ2V0Q0RNQVN1YnNjcmlwdGlvbihvYnRhaW5NZXNzYWdlKEVWRU5UX1BPTExfU1RBVEVfQ0RNQV9TVUJTQ1JJUFRJT04pKTsKKyAgICAgICAgbUNpLmdldENETUFTdWJzY3JpcHRpb24ob2J0YWluTWVzc2FnZShFVkVOVF9QT0xMX1NUQVRFX0NETUFfU1VCU0NSSVBUSU9OKSk7CiAKICAgICAgICAgLy8gR2V0IFJlZ2lzdHJhdGlvbiBJbmZvcm1hdGlvbgogICAgICAgICBwb2xsU3RhdGUoKTsKQEAgLTI3MSw3ICsyNjUsNyBAQAogICAgICAgICBpbnRbXSBpbnRzOwogICAgICAgICBTdHJpbmdbXSBzdHJpbmdzOwogCi0gICAgICAgIGlmICghcGhvbmUubUlzVGhlQ3VycmVudEFjdGl2ZVBob25lKSB7CisgICAgICAgIGlmICghbVBob25lLm1Jc1RoZUN1cnJlbnRBY3RpdmVQaG9uZSkgewogICAgICAgICAgICAgbG9nZSgiUmVjZWl2ZWQgbWVzc2FnZSAiICsgbXNnICsgIlsiICsgbXNnLndoYXQgKyAiXSIgKwogICAgICAgICAgICAgICAgICAgICAiIHdoaWxlIGJlaW5nIGRlc3Ryb3llZC4gSWdub3JpbmcuIik7CiAgICAgICAgICAgICByZXR1cm47CkBAIC0yODYsNyArMjgwLDcgQEAKICAgICAgICAgICAgIC8vIFRPRE86IENvbnNpZGVyIGNhbGxpbmcgc2V0Q3VycmVudFByZWZlcnJlZE5ldHdvcmtUeXBlIGFzIHdlIGRvIGluIEdzbVNTVC4KICAgICAgICAgICAgIC8vIGNtLnNldEN1cnJlbnRQcmVmZXJyZWROZXR3b3JrVHlwZSgpOwogCi0gICAgICAgICAgICBpZiAocGhvbmUuZ2V0THRlT25DZG1hTW9kZSgpID09IFBob25lQ29uc3RhbnRzLkxURV9PTl9DRE1BX1RSVUUpIHsKKyAgICAgICAgICAgIGlmIChtUGhvbmUuZ2V0THRlT25DZG1hTW9kZSgpID09IFBob25lQ29uc3RhbnRzLkxURV9PTl9DRE1BX1RSVUUpIHsKICAgICAgICAgICAgICAgICAvLyBTdWJzY3JpcHRpb24gd2lsbCBiZSByZWFkIGZyb20gU0lNIEkvTwogICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygiUmVjZWl2ZSBFVkVOVF9SVUlNX1JFQURZIik7CiAgICAgICAgICAgICAgICAgcG9sbFN0YXRlKCk7CkBAIC0yOTQsNyArMjg4LDcgQEAKICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coIlJlY2VpdmUgRVZFTlRfUlVJTV9SRUFEWSBhbmQgU2VuZCBSZXF1ZXN0IGdldENETUFTdWJzY3JpcHRpb24uIik7CiAgICAgICAgICAgICAgICAgZ2V0U3Vic2NyaXB0aW9uSW5mb0FuZFN0YXJ0UG9sbGluZ1RocmVhZHMoKTsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIHBob25lLnByZXBhcmVFcmkoKTsKKyAgICAgICAgICAgIG1QaG9uZS5wcmVwYXJlRXJpKCk7CiAgICAgICAgICAgICBicmVhazsKIAogICAgICAgICBjYXNlIEVWRU5UX05WX1JFQURZOgpAQCAtMzA1LDcgKzI5OSw3IEBACiAgICAgICAgICAgICBicmVhazsKIAogICAgICAgICBjYXNlIEVWRU5UX1JBRElPX1NUQVRFX0NIQU5HRUQ6Ci0gICAgICAgICAgICBpZihjbS5nZXRSYWRpb1N0YXRlKCkgPT0gUmFkaW9TdGF0ZS5SQURJT19PTikgeworICAgICAgICAgICAgaWYob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ICAgICAgICAgcGhvbmUubm90aWZ5TG9jYXRpb25DaGFuZ2VkKCk7CisgICAgICAgICAgICAgICAgbVBob25lLm5vdGlmeUxvY2F0aW9uQ2hhbmdlZCgpOwogICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAvLyBSZWxlYXNlIGFueSB0ZW1wb3JhcnkgY2VsbCBsb2NrLCB3aGljaCBjb3VsZCBoYXZlIGJlZW4KQEAgLTM4NCw2ICszNzgsNyBAQAogCiAgICAgICAgIGNhc2UgRVZFTlRfUE9MTF9TVEFURV9SRUdJU1RSQVRJT05fQ0RNQToKICAgICAgICAgY2FzZSBFVkVOVF9QT0xMX1NUQVRFX09QRVJBVE9SX0NETUE6CisgICAgICAgIGNhc2UgRVZFTlRfUE9MTF9TVEFURV9HUFJTOgogICAgICAgICAgICAgYXIgPSAoQXN5bmNSZXN1bHQpIG1zZy5vYmo7CiAgICAgICAgICAgICBoYW5kbGVQb2xsU3RhdGVSZXN1bHQobXNnLndoYXQsIGFyKTsKICAgICAgICAgICAgIGJyZWFrOwpAQCAtNDA0LDcgKzM5OSw3IEBACiAgICAgICAgICAgICAgICAgICAgIG1Jc01pbkluZm9SZWFkeSA9IHRydWU7CiAKICAgICAgICAgICAgICAgICAgICAgdXBkYXRlT3Rhc3BTdGF0ZSgpOwotICAgICAgICAgICAgICAgICAgICBpZiAoIWlzU3Vic2NyaXB0aW9uRnJvbVJ1aW0gJiYgbUljY1JlY29yZHMgIT0gbnVsbCkgeworICAgICAgICAgICAgICAgICAgICBpZiAoIW1Jc1N1YnNjcmlwdGlvbkZyb21SdWltICYmIG1JY2NSZWNvcmRzICE9IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2coIkdFVF9DRE1BX1NVQlNDUklQVElPTiBzZXQgaW1zaSBpbiBtSWNjUmVjb3JkcyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgfQpAQCAtNDI3LDc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DA7ICAgICAgICAgICAgICAvL1s4XSBzeXN0ZW1JZAotICAgICAgICAgICAgaW50IG5ldHdvcmtJZCA9IDA7ICAgICAgICAgICAgIC8vWzldIG5ldHdvcmtJZAotICAgICAgICAgICAgaW50IHJvYW1pbmdJbmRpY2F0b3IgPSAtMTsgICAgIC8vWzEwXSBSb2FtaW5nIGluZGljYXRvcgotICAgICAgICAgICAgaW50IHN5c3RlbUlzSW5QcmwgPSAwOyAgICAgICAgIC8vWzExXSBJbmRpY2F0ZXMgaWYgY3VycmVudCBzeXN0ZW0gaXMgaW4gUFJMCi0gICAgICAgICAgICBpbnQgZGVmYXVsdFJvYW1pbmdJbmRpY2F0b3IgPSAwOyAgLy9bMTJdIElzIGRlZmF1bHQgcm9hbWluZyBpbmRpY2F0b3IgZnJvbSBQUkwKLSAgICAgICAgICAgIGludCByZWFzb25Gb3JEZW5pYWwgPSAwOyAgICAgICAvL1sxM10gRGVuaWFsIHJlYXNvbiBpZiByZWdpc3RyYXRpb25TdGF0ZSA9IDMKLQotICAgICAgICAgICAgaWYgKHN0YXRlcy5sZW5ndGggPj0gMTQpIHsKLSAgICAgICAgICAgICAgICB0cnkgewotICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzWzBdICE9IG51bGwpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIHJlZ2lzdHJhdGlvblN0YXRlID0gSW50ZWdlci5wYXJzZUludChzdGF0ZXNbMF0pOwotICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZXNbM10gIT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICAgICAgcmFkaW9UZWNobm9sb2d5ID0gSW50ZWdlci5wYXJzZUludChzdGF0ZXNbM10pOwotICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZXNbNF0gIT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICAgICAgYmFzZVN0YXRpb25JZCA9IEludGVnZXIucGFyc2VJbnQoc3RhdGVzWzRdKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzWzVdICE9IG51bGwpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VTdGF0aW9uTGF0aXR1ZGUgPSBJbnRlZ2VyLnBhcnNlSW50KHN0YXRlc1s1XSk7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlc1s2XSAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBiYXNlU3RhdGlvbkxvbmdpdHVkZSA9IEludGVnZXIucGFyc2VJbnQoc3RhdGVzWzZdKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICAvLyBTb21lIGNhcnJpZXJzIG9ubHkgcmV0dXJuIGxhdC1sbmdzIG9mIDAsMAotICAgICAgICAgICAgICAgICAgICBpZiAoYmFzZVN0YXRpb25MYXRpdHVkZSA9PSAwICYmIGJhc2VTdGF0aW9uTG9uZ2l0dWRlID09IDApIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VTdGF0aW9uTGF0aXR1ZGUgID0gQ2RtYUNlbGxMb2NhdGlvbi5JTlZBTElEX0xBVF9MT05HOwotICAgICAgICAgICAgICAgICAgICAgICAgYmFzZVN0YXRpb25Mb25naXR1ZGUgPSBDZG1hQ2VsbExvY2F0aW9uLklOVkFMSURfTEFUX0xPTkc7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlc1s3XSAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBjc3NJbmRpY2F0b3IgPSBJbnRlZ2VyLnBhcnNlSW50KHN0YXRlc1s3XSk7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlc1s4XSAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBzeXN0ZW1JZCA9IEludGVnZXIucGFyc2VJbnQoc3RhdGVzWzhdKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzWzldICE9IG51bGwpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIG5ldHdvcmtJZCA9IEludGVnZXIucGFyc2VJbnQoc3RhdGVzWzldKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzWzEwXSAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICByb2FtaW5nSW5kaWNhdG9yID0gSW50ZWdlci5wYXJzZUludChzdGF0ZXNbMTBdKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzWzExXSAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBzeXN0ZW1Jc0luUHJsID0gSW50ZWdlci5wYXJzZUludChzdGF0ZXNbMTFdKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzWzEyXSAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0Um9hbWluZ0luZGljYXRvciA9IEludGVnZXIucGFyc2VJbnQoc3RhdGVzWzEyXSk7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlc1sxM10gIT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uRm9yRGVuaWFsID0gSW50ZWdlci5wYXJzZUludChzdGF0ZXNbMTNdKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIH0gY2F0Y2ggKE51bWJlckZvcm1hdEV4Y2VwdGlvbiBleCkgewotICAgICAgICAgICAgICAgICAgICBsb2dlKCJFVkVOVF9QT0xMX1NUQVRFX1JFR0lTVFJBVElPTl9DRE1BOiBlcnJvciBwYXJzaW5nOiAiICsgZXgpOworICAgICAgICAgICAgY2FzZSBFVkVOVF9QT0xMX1NUQVRFX0dQUlM6IHsKKyAgICAgICAgICAgICAgICBzdGF0ZXMgPSAoU3RyaW5nW10pYXIucmVzdWx0OworICAgICAgICAgICAgICAgIGlmIChEQkcpIHsKKyAgICAgICAgICAgICAgICAgICAgbG9nKCJoYW5kbGVQb2xsU3RhdGVSZXN1bHRNZXNzYWdlOiBFVkVOVF9QT0xMX1NUQVRFX0dQUlMgc3RhdGVzLmxlbmd0aD0iICsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZXMubGVuZ3RoICsgIiBzdGF0ZXM9IiArIHN0YXRlcyk7CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICB0aHJvdyBuZXcgUnVudGltZUV4Y2VwdGlvbigiV2FybmluZyEgV3JvbmcgbnVtYmVyIG9mIHBhcmFtZXRlcnMgcmV0dXJuZWQgZnJvbSAiCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyAiUklMX1JFUVVFU1RfUkVHSVNUUkFUSU9OX1NUQVRFOiBleHBlY3RlZCAxNCBvciBtb3JlICIKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArICJzdHJpbmdzIGFuZCBnb3QgIiArIHN0YXRlcy5sZW5ndGggKyAiIHN0cmluZ3MiKTsKLSAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgbVJlZ2lzdHJhdGlvblN0YXRlID0gcmVnaXN0cmF0aW9uU3RhdGU7Ci0gICAgICAgICAgICAvLyBXaGVuIHJlZ2lzdHJhdGlvbiBzdGF0ZSBpcyByb2FtaW5nIGFuZCBUU0I1OAotICAgICAgICAgICAgLy8gcm9hbWluZyBpbmRpY2F0b3IgaXMgbm90IGluIHRoZSBjYXJyaWVyLXNwZWNpZmll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ZWxkIGlzbid0IHZhbGlkIHVzZSBQUk9QRVJUWV9DRE1BX0hPTUVfT1BFUkFUT1JfTlVNRVJJQwotICAgICAgICAgICAgICAgIGlmICgob3BOYW1lc1syXSA9PSBudWxsKSB8fCAob3BOYW1lc1syXS5sZW5ndGgoKSA8IDUpCi0gICAgICAgICAgICAgICAgICAgICAgICB8fCAoIjAwMDAwIi5lcXVhbHMob3BOYW1lc1syXSkpKSB7Ci0gICAgICAgICAgICAgICAgICAgIG9wTmFtZXNbMl0gPSBTeXN0ZW1Qcm9wZXJ0aWVzLmdldCgKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBDRE1BUGhvbmUuUFJPUEVSVFlfQ0RNQV9IT01FX09QRVJBVE9SX05VTUVSSUMsICIwMDAwMCIpOwotICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBsb2coIlJJTF9SRVFVRVNUX09QRVJBVE9SLnJlc3BvbnNlWzJdLCB0aGUgbnVtZXJpYywgIiArCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICIgaXMgYmFkLiBVc2luZyBTeXN0ZW1Qcm9wZXJ0aWVzICciICsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDRE1BUGhvbmUuUFJPUEVSVFlfQ0RNQV9IT01FX09QRVJBVE9SX05VTUVSSUMgKwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiJz0gIiArIG9wTmFtZXNbMl0pOworICAgICAgICAgICAgICAgIGlmIChzdGF0ZXMubGVuZ3RoID4gMCkgeworICAgICAgICAgICAgICAgICAgICB0cnkgeworICAgICAgICAgICAgICAgICAgICAgICAgcmVnU3RhdGUgPSBJbnRlZ2VyLnBhcnNlSW50KHN0YXRlc1swXSk7CisgICAgCisgICAgICAgICAgICAgICAgICAgICAgICAvLyBzdGF0ZXNbM10gKGlmIHByZXNlbnQpIGlzIHRoZSBjdXJyZW50IHJhZGlvIHRlY2hub2xvZ3kKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZXMubGVuZ3RoID49IDQgJiYgc3RhdGVzWzNdICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhUmFkaW9UZWNobm9sb2d5ID0gSW50ZWdlci5wYXJzZUludChzdGF0ZXNbM10pOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChOdW1iZXJGb3JtYXRFeGNlcHRpb24gZXgpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGxvZ2UoImhhbmRsZVBvbGxTdGF0ZVJlc3VsdE1lc3NhZ2U6IGVycm9yIHBhcnNpbmcgR3Byc1JlZ2lzdHJhdGlvblN0YXRlOiAiCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyBleCk7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgICAgICBpZiAoIWlzU3Vic2NyaXB0aW9uRnJvbVJ1aW0pIHsKLSAgICAgICAgICAgICAgICAgICAgLy8gSW4gQ0RNQSBpbiBjYXNlIG9uIE5WLCB0aGUgc3MubU9wZXJhdG9yQWxwaGFMb25nIGlzIHNldCBsYXRlciB3aXRoIHRoZQotICAgICAgICAgICAgICAgICAgICAvLyBFUkkgdGV4dCwgc28gaGVyZSBpdCBpcyBpZ25vcmVkIHdoYXQgaXMgY29taW5nIGZyb20gdGhlIG1vZGVtLgotICAgICAgICAgICAgICAgICAgICBuZXdTUy5zZXRPcGVyYXRvck5hbWUobnVsbCwgb3BOYW1lc1sxXSwgb3BOYW1lc1syXSk7CisgICAgICAgICAgICAgICAgaW50IGRhdGFSZWdTdGF0ZSA9IHJlZ0NvZGVUb1NlcnZpY2VTdGF0ZShyZWdTdGF0ZSk7CisgICAgICAgICAgICAgICAgbU5ld1NTLnNldERhdGFSZWdTdGF0ZShkYXRhUmVnU3RhdGUpOworICAgICAgICAgICAgICAgIG1OZXdTUy5zZXRSaWxEYXRhUmFkaW9UZWNobm9sb2d5KGRhdGFSYWRpb1RlY2hub2xvZ3kpOworICAgICAgICAgICAgICAgIGlmIChEQkcpIHsKKyAgICAgICAgICAgICAgICAgICAgbG9nKCJoYW5kbFBvbGxTdGF0ZVJlc3VsdE1lc3NhZ2U6IGNkbWEgc2V0RGF0YVJlZ1N0YXRlPSIgKyBkYXRhUmVnU3RhdGUKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICArICIgcmVnU3RhdGU9IiArIHJlZ1N0YXRlCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyAiIGRhdGFSYWRpb1RlY2hub2xvZ3k9IiArIGRhdGFSYWRpb1RlY2hub2xvZ3kpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIH0KKworICAgICAgICAgICAgY2FzZSBFVkVOVF9QT0xMX1NUQVRFX1JFR0lTVFJBVElPTl9DRE1BOiAvLyBIYW5kbGUgUklMX1JFUVVFU1RfUkVHSVNUUkFUSU9OX1NUQVRFLgorICAgICAgICAgICAgICAgIHN0YXRlcyA9IChTdHJpbmdbXSlhci5yZXN1bHQ7CisKKyAgICAgICAgICAgICAgICBpbnQgcmVnaXN0cmF0aW9uU3RhdGUgPSA0OyAgICAgLy9bMF0gcmVnaXN0cmF0aW9uU3RhdGUKKyAgICAgICAgICAgICAgICBpbnQgcmFkaW9UZWNobm9sb2d5ID0gLTE7ICAgICAgLy9bM10gcmFkaW9UZWNobm9sb2d5CisgICAgICAgICAgICAgICAgaW50IGJhc2VTdGF0aW9uSWQgPSAtMTsgICAgICAgIC8vWzRdIGJhc2VTdGF0aW9uSWQKKyAgICAgICAgICAgICAgICAvL1s1XSBiYXNlU3RhdGlvbkxhdGl0dWRlCisgICAgICAgICAgICAgICAgaW50IGJhc2VTdGF0aW9uTGF0aXR1ZGUgPSBDZG1hQ2VsbExvY2F0aW9uLklOVkFMSURfTEFUX0xPTkc7CisgICAgICAgICAgICAgICAgLy9bNl0gYmFzZVN0YXRpb25Mb25naXR1ZGUKKyAgICAgICAgICAgICAgICBpbnQgYmFzZVN0YXRpb25Mb25naXR1ZGUgPSBDZG1hQ2VsbExvY2F0aW9uLklOVkFMSURfTEFUX0xPTkc7CisgICAgICAgICAgICAgICAgaW50IGNzc0luZGljYXRvciA9IDA7ICAgICAgICAgIC8vWzddIGluaXQgd2l0aCAwLCBiZWNhdXNlIGl0IGlzIHRyZWF0ZWQgYXMgYSBib29sZWFuCisgICAgICAgICAgICAgICAgaW50IHN5c3RlbUlkID0gMDsgICAgICAgICAgICAgIC8vWzhdIHN5c3RlbUlkCisgICAgICAgICAgICAgICAgaW50IG5ldHdvcmtJZCA9IDA7ICAgICAgICAgICAgIC8vWzldIG5ldHdvcmtJZAorICAgICAgICAgICAgICAgIGludCByb2FtaW5nSW5kaWNhdG9yID0gLTE7ICAgICAvL1sxMF0gUm9hbWluZyBpbmRpY2F0b3IKKyAgICAgICAgICAgICAgICBpbnQgc3lzdGVtSXNJblBybCA9IDA7ICAgICAgICAgLy9bMTFdIEluZGljYXRlcyBpZiBjdXJyZW50IHN5c3RlbSBpcyBpbiBQUkwKKyAgICAgICAgICAgICAgICBpbnQgZGVmYXVsdFJvYW1pbmdJbmRpY2F0b3IgPSAwOyAgLy9bMTJdIElzIGRlZmF1bHQgcm9hbWluZyBpbmRpY2F0b3IgZnJvbSBQUkwKKyAgICAgICAgICAgICAgICBpbnQgcmVhc29uRm9yRGVuaWFsID0gMDsgICAgICAgLy9bMTNdIERlbmlhbCByZWFzb24gaWYgcmVnaXN0cmF0aW9uU3RhdGUgPSAzCisKKyAgICAgICAgICAgICAgICBpZiAoc3RhdGVzLmxlbmd0aCA+PSAxNCkgeworICAgICAgICAgICAgICAgICAgICB0cnkgeworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlc1swXSAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVnaXN0cmF0aW9uU3RhdGUgPSBJbnRlZ2VyLnBhcnNlSW50KHN0YXRlc1swXSk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzWzNdICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICByYWRpb1RlY2hub2xvZ3kgPSBJbnRlZ2VyLnBhcnNlSW50KHN0YXRlc1szXSk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzWzRdICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYXNlU3RhdGlvbklkID0gSW50ZWdlci5wYXJzZUludChzdGF0ZXNbNF0pOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlc1s1XSAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFzZVN0YXRpb25MYXRpdHVkZSA9IEludGVnZXIucGFyc2VJbnQoc3RhdGVzWzVdKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZXNbNl0gIT0gbnVsbCkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VTdGF0aW9uTG9uZ2l0dWRlID0gSW50ZWdlci5wYXJzZUludChzdGF0ZXNbNl0pOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgLy8gU29tZSBjYXJyaWVycyBvbmx5IHJldHVybiBsYXQtbG5ncyBvZiAwLDAKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChiYXNlU3RhdGlvbkxhdGl0dWRlID09IDAgJiYgYmFzZVN0YXRpb25Mb25naXR1ZGUgPT0gMCkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VTdGF0aW9uTGF0aXR1ZGUgID0gQ2RtYUNlbGxMb2NhdGlvbi5JTlZBTElEX0xBVF9MT05HOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VTdGF0aW9uTG9uZ2l0dWRlID0gQ2RtYUNlbGxMb2NhdGlvbi5JTlZBTElEX0xBVF9MT05HOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlc1s3XSAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3NzSW5kaWNhdG9yID0gSW50ZWdlci5wYXJzZUludChzdGF0ZXNbN10pOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlc1s4XSAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3lzdGVtSWQgPSBJbnRlZ2VyLnBhcnNlSW50KHN0YXRlc1s4XSk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzWzldICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXR3b3JrSWQgPSBJbnRlZ2VyLnBhcnNlSW50KHN0YXRlc1s5XSk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzWzEwXSAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm9hbWluZ0luZGljYXRvciA9IEludGVnZXIucGFyc2VJbnQoc3RhdGVzWzEwXSk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzWzExXSAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3lzdGVtSXNJblBybCA9IEludGVnZXIucGFyc2VJbnQoc3RhdGVzWzExXSk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzWzEyXSAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdFJvYW1pbmdJbmRpY2F0b3IgPSBJbnRlZ2VyLnBhcnNlSW50KHN0YXRlc1sxMl0pOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlc1sxM10gIT0gbnVsbCkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbkZvckRlbmlhbCA9IEludGVnZXIucGFyc2VJbnQoc3RhdGVzWzEzXSk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKE51bWJlckZvcm1hdEV4Y2VwdGlvbiBleCkgeworICAgICAgICAgICAgICAgICAgICAgICAgbG9nZSgiRVZFTlRfUE9MTF9TVEFURV9SRUdJU1RSQVRJT05fQ0RNQTogZXJyb3IgcGFyc2luZzogIiArIGV4KTsKKyAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgIG5ld1NTLnNldE9wZXJhdG9yTmFtZShvcE5hbWVzWzBdLCBvcE5hbWVzWzFdLCBvcE5hbWVzWzJdKTsKKyAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IFJ1bnRpbWVFeGNlcHRpb24oIldhcm5pbmchIFdyb25nIG51bWJlciBvZiBwYXJhbWV0ZXJzIHJldHVybmVkIGZyb20gIgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArICJSSUxfUkVRVUVTVF9SRUdJU1RSQVRJT05fU1RBVEU6IGV4cGVjdGVkIDE0IG9yIG1vcmUgIgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArICJzdHJpbmdzIGFuZCBnb3QgIiArIHN0YXRlcy5sZW5ndGggKyAiIHN0cm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kpOworCisgICAgICAgICAgICAgICAgbU5ld1NTLnNldFJpbFZvaWNlUmFkaW9UZWNobm9sb2d5KHJhZGlvVGVjaG5vbG9neSk7CisKKyAgICAgICAgICAgICAgICBtTmV3U1Muc2V0Q3NzSW5kaWNhdG9yKGNzc0luZGljYXRvcik7CisgICAgICAgICAgICAgICAgbU5ld1NTLnNldFN5c3RlbUFuZE5ldHdvcmtJZChzeXN0ZW1JZCwgbmV0d29ya0lkKTsKKyAgICAgICAgICAgICAgICBtUm9hbWluZ0luZGljYXRvciA9IHJvYW1pbmdJbmRpY2F0b3I7CisgICAgICAgICAgICAgICAgbUlzSW5QcmwgPSAoc3lzdGVtSXNJblBybCA9PSAwKSA/IGZhbHNlIDogdHJ1ZTsKKyAgICAgICAgICAgICAgICBtRGVmYXVsdFJvYW1pbmdJbmRpY2F0b3IgPSBkZWZhdWx0Um9hbWluZ0luZGljYXRvcjsKKworCisgICAgICAgICAgICAgICAgLy8gVmFsdWVzIGFyZSAtMSBpZiBub3QgYXZhaWxhYmxlLgorICAgICAgICAgICAgICAgIG1OZXdDZWxsTG9jLnNldENlbGxMb2NhdGlvbkRhdGEoYmFzZVN0YXRpb25JZCwgYmFzZVN0YXRpb25MYXRpdHVkZSwKKyAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VTdGF0aW9uTG9uZ2l0dWRlLCBzeXN0ZW1JZCwgbmV0d29ya0lkKTsKKworICAgICAgICAgICAgICAgIGlmIChyZWFzb25Gb3JEZW5pYWwgPT0gMCkgeworICAgICAgICAgICAgICAgICAgICBtUmVnaXN0cmF0aW9uRGVuaWVkUmVhc29uID0gU2VydmljZVN0YXRlVHJhY2tlci5SRUdJU1RSQVRJT05fREVOSUVEX0dFTjsKKyAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHJlYXNvbkZvckRlbmlhbCA9PSAxKSB7CisgICAgICAgICAgICAgICAgICAgIG1SZWdpc3RyYXRpb25EZW5pZWRSZWFzb24gPSBTZXJ2aWNlU3RhdGVUcmFja2VyLlJFR0lTVFJBVElPTl9ERU5JRURfQVVUSDsKKyAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICBtUmVnaXN0cmF0aW9uRGVuaWVkUmVhc29uID0gIiI7CisgICAgICAgICAgICAgICAgfQorICAgIAorICAgICAgICAgICAgICAgIGlmIChtUmVnaXN0cmF0aW9uU3RhdGUgPT0gMykgeworICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coIlJlZ2lzdHJhdGlvbiBkZW5pZWQsICIgKyBtUmVnaXN0cmF0aW9uRGVuaWVkUmVhc29uKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgYnJlYWs7CisKKyAgICAgICAgICAgIGNhc2UgRVZFTlRfUE9MTF9TVEFURV9PUEVSQVRPUl9DRE1BOiAvLyBIYW5kbGUgUklMX1JFUVVFU1RfT1BFUkFUT1IKKyAgICAgICAgICAgICAgICBTdHJpbmcgb3BOYW1lc1tdID0gKFN0cmluZ1tdKWFyLnJlc3VsdDsKKyAgICAKKyAgICAgICAgICAgICAgICBpZiAob3BOYW1lcyAhPSBudWxsICYmIG9wTmFtZXMubGVuZ3RoID49IDMpIHsKKyAgICAgICAgICAgICAgICAgICAgLy8gSWYgdGhlIE5VTUVSSUMgZmllbGQgaXNuJ3QgdmFsaWQgdXNlIFBST1BFUlRZX0NETUFfSE9NRV9PUEVSQVRPUl9OVU1FUklDCisgICAgICAgICAgICAgICAgICAgIGlmICgob3BOYW1lc1syXSA9PSBudWxsKSB8fCAob3BOYW1lc1syXS5sZW5ndGgoKSA8IDUpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgfHwgKCIwMDAwMCIuZXF1YWxzKG9wTmFtZXNbMl0pKSkgeworICAgICAgICAgICAgICAgICAgICAgICAgb3BOYW1lc1syXSA9IFN5c3RlbVByb3BlcnRpZXMuZ2V0KAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDRE1BUGhvbmUuUFJPUEVSVFlfQ0RNQV9IT01FX09QRVJBVE9SX05VTUVSSUMsICIwMDAwMCIpOworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvZygiUklMX1JFUVVFU1RfT1BFUkFUT1IucmVzcG9uc2VbMl0sIHRoZSBudW1lcmljLCAiICsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICIgaXMgYmFkLiBVc2luZyBTeXN0ZW1Qcm9wZXJ0aWVzICciICsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ0RNQVBob25lLlBST1BFUlRZX0NETUFfSE9NRV9PUEVSQVRPUl9OVU1FUklDICsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICInPSAiICsgb3BOYW1lc1syXSk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIH0KKworICAgICAgICAgICAgICAgICAgICBpZiAoIW1Jc1N1YnNjcmlwdGlvbkZyb21SdWltKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAvLyBJbiBDRE1BIGluIGNhc2Ugb24gTlYsIHRoZSBzcy5tT3BlcmF0b3JBbHBoYUxvbmcgaXMgc2V0IGxhdGVyIHdpdGggdGhlCisgICAgICAgICAgICAgICAgICAgICAgICAvLyBFUkkgdGV4dCwgc28gaGVyZSBpdCBpcyBpZ25vcmVkIHdoYXQgaXMgY29taW5nIGZyb20gdGhlIG1vZGVtLgorICAgICAgICAgICAgICAgICAgICAgICAgbU5ld1NTLnNldE9wZXJhdG9yTmFtZShudWxsLCBvcE5hbWVzWzFdLCBvcE5hbWVzWzJdKTsKKyAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1OZXdTUy5zZXRPcGVyYXRvck5hbWUob3BOYW1lc1swXSwgb3BOYW1lc1sxXSwgb3BOYW1lc1syXSk7CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coIkVWRU5UX1BPTExfU1RBVEVfT1BFUkFUT1JfQ0RNQTogZXJyb3IgcGFyc2luZyBvcE5hbWVzIik7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGJyZWFrOworCisgICAgICAgICAgICAKKyAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgCisgICAgICAgICAgICAgICAgCisgICAgICAgICAgICAgICAgbG9nZSgiaGFuZGxlUG9sbFN0YXRlUmVzdWx0TWVzc2FnZTogUklMIHJlc3BvbnNlIGhhbmRsZSBpbiB3cm9uZyBwaG9uZSEiCisgICAgICAgICAgICAgICAgICAgICAgICArICIgRXhwZWN0ZWQgQ0RNQSBSSUwgcmVxdWVzdCBhbmQgZ2V0IEdTTSBSSUwgcmVxdWVzdC4iKTsKKyAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogICAgIH0KIApAQCAtNzE1LDcgKzc0MCw3IEBACiAgICAgQE92ZXJyaWRlCiAgICAgcHJvdGVjdGVkIHZvaWQgaGFuZGxlUG9sbFN0YXRlUmVzdWx0KGludCB3aGF0LCBBc3luY1Jlc3VsdCBhcikgewogICAgICAgICAvLyBJZ25vcmUgc3RhbGUgcmVxdWVzdHMgZnJvbSBsYXN0IHBvbGwuCi0gICAgICAgIGlmIChhci51c2VyT2JqICE9IHBvbGxpbmdDb250ZXh0KSByZXR1cm47CisgICAgICAgIGlmIChhci51c2VyT2JqICE9IG1Qb2xsaW5nQ29udGV4dCkgcmV0dXJuOwogCiAgICAgICAgIGlmIChhci5leGNlcHRpb24gIT0gbnVsbCkgewogICAgICAgICAgICAgQ29tbWFuZEV4Y2VwdGlvbi5FcnJvciBlcnI9bnVsbDsKQEAgLTczMCw3ICs3NTUsNyBAQAogICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgaWYgKCFjbS5nZXRSYWRpb1N0YXRlKCkuaXNPbigpKSB7CisgICAgICAgICAgICBpZiAoIW1DaS5nZXRSYWRpb1N0YXRlKCkuaXNPbigpKSB7CiAgICAgICAgICAgICAgICAgLy8gUmFkaW8gaGFzIGNyYXNoZWQgb3IgdHVybmVkIG9mZi4KICAgICAgICAgICAgICAgICBjYW5jZWxQb2xsU3RhdGUoKTsKICAgICAgICAgICAgICAgICByZXR1cm47CkBAIC03NDcsNjEgKzc3Miw2MSBAQAogICAgICAgICAgICAgICAgICAgICArICJQcm9iYWJseSBtYWxmb3JtZWQgUklMIHJlc3BvbnNlLiIgKyBleCk7CiAgICAgICAgIH0KIAotICAgICAgICBwb2xsaW5nQ29udGV4dFswXS0tOworICAgICAgICBtUG9sbGluZ0NvbnRleHRbMF0tLTsKIAotICAgICAgICBpZiAocG9sbGluZ0NvbnRleHRbMF0gPT0gMCkgeworICAgICAgICBpZiAobVBvbGxpbmdDb250ZXh0WzBdID09IDApIHsKICAgICAgICAgICAgIGJvb2xlYW4gbmFtTWF0Y2ggPSBmYWxzZTsKLSAgICAgICAgICAgIGlmICghaXNTaWRzQWxsWmVyb3MoKSAmJiBpc0hvbWVTaWQobmV3U1MuZ2V0U3lzdGVtSWQoKSkpIHsKKyAgICAgICAgICAgIGlmICghaXNTaWRzQWxsWmVyb3MoKSAmJiBpc0hvbWVTaWQobU5ld1NTLmdldFN5c3RlbUlkKCkpKSB7CiAgICAgICAgICAgICAgICAgbmFtTWF0Y2ggPSB0cnVlOwogICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAvLyBTZXR0aW5nIFNTIFJvYW1pbmcgKGdlbmVyYWwpCi0gICAgICAgICAgICBpZiAoaXNTdWJzY3JpcHRpb25Gcm9tUnVpbSkgewotICAgICAgICAgICAgICAgIG5ld1NTLnNldFJvYW1pbmcoaXNSb2FtaW5nQmV0d2Vlbk9wZXJhdG9ycyhtQ2RtYVJvYW1pbmcsIG5ld1NTKSk7CisgICAgICAgICAg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IoRXJpSW5mby5ST0FNSU5HX0lORElDQVRPUl9PRkYpOworICAgICAgICAgICAgICAgIG1OZXdTUy5zZXRDZG1hUm9hbWluZ0luZGljYXRvcihFcmlJbmZvLlJPQU1JTkdfSU5ESUNBVE9SX09GRik7CiAgICAgICAgICAgICB9IGVsc2UgaWYgKCFpc1NpZHNBbGxaZXJvcygpKSB7CiAgICAgICAgICAgICAgICAgaWYgKCFuYW1NYXRjaCAmJiAhbUlzSW5QcmwpIHsKICAgICAgICAgICAgICAgICAgICAgLy8gVXNlIGRlZmF1bHQKLSAgICAgICAgICAgICAgICAgICAgbmV3U1Muc2V0Q2RtYVJvYW1pbmdJbmRpY2F0b3IobURlZmF1bHRSb2FtaW5nSW5kaWNhdG9yKTsKKyAgICAgICAgICAgICAgICAgICAgbU5ld1NTLnNldENkbWFSb2FtaW5nSW5kaWNhdG9yKG1EZWZhdWx0Um9hbWluZ0luZGljYXRvcik7CiAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChuYW1NYXRjaCAmJiAhbUlzSW5QcmwpIHsKLSAgICAgICAgICAgICAgICAgICAgbmV3U1Muc2V0Q2RtYVJvYW1pbmdJbmRpY2F0b3IoRXJpSW5mby5ST0FNSU5HX0lORElDQVRPUl9GTEFTSCk7CisgICAgICAgICAgICAgICAgICAgIG1OZXdTUy5zZXRDZG1hUm9hbWluZ0luZGljYXRvcihFcmlJbmZvLlJPQU1JTkdfSU5ESUNBVE9SX0ZMQVNIKTsKICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKCFuYW1NYXRjaCAmJiBtSXNJblBybCkgewogICAgICAgICAgICAgICAgICAgICAvLyBVc2UgdGhlIG9uZSBmcm9tIFBSTC9FUkkKLSAgICAgICAgICAgICAgICAgICAgbmV3U1Muc2V0Q2RtYVJvYW1pbmdJbmRpY2F0b3IobVJvYW1pbmdJbmRpY2F0b3IpOworICAgICAgICAgICAgICAgICAgICBtTmV3U1Muc2V0Q2RtYVJvYW1pbmdJbmRpY2F0b3IobVJvYW1pbmdJbmRpY2F0b3IpOwogICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgIC8vIEl0IG1lYW5zIG5hbU1hdGNoICYmIG1Jc0luUHJsCiAgICAgICAgICAgICAgICAgICAgIGlmICgobVJvYW1pbmdJbmRpY2F0b3IgPD0gMikpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIG5ld1NTLnNldENkbWFSb2FtaW5nSW5kaWNhdG9yKEVyaUluZm8uUk9BTUlOR19JTkRJQ0FUT1JfT0ZGKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1OZXdTUy5zZXRDZG1hUm9hbWluZ0luZGljYXRvcihFcmlJbmZvLlJPQU1JTkdfSU5ESUNBVE9SX09GRik7CiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBVc2UgdGhlIG9uZSBmcm9tIFBSTC9FUkkKLSAgICAgICAgICAgICAgICAgICAgICAgIG5ld1NTLnNldENkbWFSb2FtaW5nSW5kaWNhdG9yKG1Sb2FtaW5nSW5kaWNhdG9yKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1OZXdTUy5zZXRDZG1hUm9hbWluZ0luZGljYXRvcihtUm9hbWluZ0luZGljYXRvcik7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgIGludCByb2FtaW5nSW5kaWNhdG9yID0gbmV3U1MuZ2V0Q2RtYVJvYW1pbmdJbmRpY2F0b3IoKTsKLSAgICAgICAgICAgIG5ld1NTLnNldENkbWFFcmlJY29uSW5kZXgocGhvbmUubUVyaU1hbmFnZXIuZ2V0Q2RtYUVyaUljb25JbmRleChyb2FtaW5nSW5kaWNhdG9yLAorICAgICAgICAgICAgaW50IHJvYW1pbmdJbmRpY2F0b3IgPSBtTmV3U1MuZ2V0Q2RtYVJvYW1pbmdJbmRpY2F0b3Io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AgICAgICAgICAgICArICIuIG5hbU1hdGNoID0gIiArIG5hbU1hdGNoICsgIiAsIG1Jc0luUHJsID0gIiArIG1Jc0luUHJsCiAgICAgICAgICAgICAgICAgICAgICsgIiwgbVJvYW1pbmdJbmRpY2F0b3IgPSAiICsgbVJvYW1pbmdJbmRpY2F0b3IKQEAgLTgyNiwxNCArODUxLDEzIEBACiAgICAgICovCiAgICAgcHJvdGVjdGVkIHZvaWQKICAgICBwb2xsU3RhdGUoKSB7Ci0gICAgICAgIHBvbGxpbmdDb250ZXh0ID0gbmV3IGludFsxXTsKLSAgICAgICAgcG9sbGluZ0NvbnRleHRbMF0gPSAwOworICAgICAgICBtUG9sbGluZ0NvbnRleHQgPSBuZXcgaW50WzFdOworICAgICAgICBtUG9sbGluZ0NvbnRleHRbMF0gPSAwOwogCi0gICAgICAgIHN3aXRjaCAoY20uZ2V0UmFkaW9TdGF0ZSgpKSB7CisgICAgICAgIHN3aXRjaCAobUNpLmdldFJhZGlvU3RhdGUoKSkgewogICAgICAgICBjYXNlIFJBRElPX1VOQVZBSUxBQkxFOgotICAgICAgICAgICAgbmV3U1Muc2V0U3RhdGVPdXRPZlNlcnZpY2UoKTsKLSAgICAgICAgICAgIG1OZXdEYXRhQ29ubmVjdGlvblN0YXRlID0gU2VydmljZVN0YXRlLlNUQVRFX09VVF9PRl9TRVJWSUNFOwotICAgICAgICAgICAgbmV3Q2VsbExvYy5zZXRTdGF0ZUludmFsaWQoKTsKKyAgICAgICAgICAgIG1OZXdTUy5zZXRTdGF0ZU91dE9mU2VydmljZSgpOworICAgICAgICAgICAgbU5ld0NlbGxMb2Muc2V0U3RhdGVJbnZhbGlkKCk7CiAgICAgICAgICAgICBzZXRTaWduYWxTdHJlbmd0aERlZmF1bHRWYWx1ZXMoKTsKICAgICAgICAgICAgIG1Hb3RDb3VudHJ5Q29kZSA9IGZhbHNlOwogCkBAIC04NDEsOSArODY1LDggQEAKICAgICAgICAgICAgIGJyZWFrOwogCiAgICAgICAgIGNhc2UgUkFESU9fT0ZGOgotICAgICAgICAgICAgbmV3U1Muc2V0U3RhdGVPZmYoKTsKLSAgICAgICAgICAgIG1OZXdEYXRhQ29ubmVjdGlvblN0YXRlID0gU2VydmljZVN0YXRlLlNUQVRFX1BPV0VSX09GRjsKLSAgICAgICAgICAgIG5ld0NlbGxMb2Muc2V0U3RhdGVJbnZhbGlkKCk7CisgICAgICAgICAgICBtTmV3U1Muc2V0U3RhdGVPZmYoKTsKKyAgICAgICAgICAgIG1OZXdDZWxsTG9jLnNldFN0YXRlSW52YWxpZCgpOwogICAgICAgICAgICAgc2V0U2lnbmFsU3RyZW5ndGhEZWZhdWx0VmFsdWVzKCk7CiAgICAgICAgICAgICBtR290Q291bnRyeUNvZGUgPSBmYWxzZTsKIApAQCAtODU1LDE2ICs4NzgsMjAgQEAKICAgICAgICAgICAgIC8vIGRvd24gdGhlIHJlc3BvbnNlcyB3aGljaCBhcmUgYWxsb3dlZCB0byBhcnJpdmUKICAgICAgICAgICAgIC8vIG91dC1vZi1vcmRlci4KIAotICAgICAgICAgICAgcG9sbGluZ0NvbnRleHRbMF0rKzsKKyAgICAgICAgICAgIG1Qb2xsaW5nQ29udGV4dFswXSsrOwogICAgICAgICAgICAgLy8gUklMX1JFUVVFU1RfT1BFUkFUT1IgaXMgbmVjZXNzYXJ5IGZvciBDRE1BCi0gICAgICAgICAgICBjbS5nZXRPcGVyYXRvcigKLSAgICAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZShFVkVOVF9QT0xMX1NUQVRFX09QRVJBVE9SX0NETUEsIHBvbGxpbmdDb250ZXh0KSk7CisgICAgICAgICAgICBtQ2kuZ2V0T3BlcmF0b3IoCisgICAgICAgICAgICAgICAgICAgIG9idGFpbk1lc3NhZ2UoRVZFTlRfUE9MTF9TVEFURV9PUEVSQVRPUl9DRE1BLCBtUG9sbGluZ0NvbnRleHQpKTsKIAotICAgICAgICAgICAgcG9sbGluZ0NvbnRleHRbMF0rKzsKKyAgICAgICAgICAgIG1Qb2xsaW5nQ29udGV4dFswXSsrOwogICAgICAgICAgICAgLy8gUklMX1JFUVVFU1RfVk9JQ0VfUkVHSVNUUkFUSU9OX1NUQVRFIGlzIG5lY2Vzc2FyeSBmb3IgQ0RNQQotICAgICAgICAgICAgY20uZ2V0Vm9pY2VSZWdpc3RyYXRpb25TdGF0ZSgKLSAgICAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZShFVkVOVF9QT0xMX1NUQVRFX1JFR0lTVFJBVElPTl9DRE1BLCBwb2xsaW5nQ29udGV4dCkpOworICAgICAgICAgICAgbUNpLmdldFZvaWNlUmVnaXN0cmF0aW9uU3RhdGUoCisgICAgICAgICAgICAgICAgICAgIG9idGFpbk1lc3NhZ2UoRVZFTlRfUE9MTF9TVEFURV9SRUdJU1RSQVRJT05fQ0RNQSwgbVBvbGxpbmdDb250ZXh0KSk7CiAKKyAgICAgICAgICAgIG1Qb2xsaW5nQ29udGV4dFswXSsrOworICAgICAgICAgICAgLy8gUklMX1JFUVVFU1RfREFUQV9SRUdJU1RSQVRJT05fU1RBVEUKKyAgICAgICAgICAgIG1DaS5nZXREYXRhUmVnaXN0cmF0aW9uU3RhdGUob2J0YWluTWVzc2FnZShFVkVOVF9QT0xMX1NUQVRFX0dQUlMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbVBvbGxpbmdDb250ZXh0KSk7CiAgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogICAgIH0KQEAgLTkzMCw2NiArOTU3LDYyIEBACiAgICAgfQogCiAgICAgcHJvdGVjdGVkIHZvaWQgcG9sbFN0YXRlRG9uZSgpIHsKLSAgICAgICAgaWYgKERCRykgbG9nKCJwb2xsU3RhdGVEb25lOiBvbGRTUz1bIiArIHNzICsgIl0gbmV3U1M9WyIgKyBuZXdTUyArICJdIik7CisgICAgICAgIGlmIChEQkcpIGxvZygicG9sbFN0YXRlRG9uZTogY2RtYSBvbGRTUz1bIiArIG1TUyArICJd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VSVklDRSBpcyB2YWxpZCB1c2VkIGZvcgogICAgICAgICAgICAgICAgICAgICAvLyBtUmVnaXN0cmF0aW9uU3RhdGUgMCwyLDMgYW5kIDQKLSAgICAgICAgICAgICAgICAgICAgZXJpVGV4dCA9IHBob25lLmdldENvbnRleHQoKS5nZXRUZXh0KAorICAgICAgICAgICAgICAgICAgICBlcmlUZXh0ID0gbVBob25lLmdldENvbnRleHQoKS5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLnJvYW1pbmdUZXh0U2VhcmNoaW5nKS50b1N0cmluZygpOwogICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBzcy5zZXRPcGVyYXRvckFscGhhTG9uZyhlcmlUZXh0KTsKKyAgICAgICAgICAgICAgICBtU1Muc2V0T3BlcmF0b3JBbHBoYUxvbmcoZXJpVGV4dCk7CiAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgIFN0cmluZyBvcGVyYXRvck51bWVyaWM7CiAKLSAgICAgICAgICAgIHBob25lLnNldFN5c3RlbVByb3BlcnR5KFRlbGVwaG9ueVByb3BlcnRpZXMuUFJPUEVSVFlfT1BFUkFUT1JfQUxQSEEsCi0gICAgICAgICAgICAgICAgICAgIHNzLmdldE9wZXJhdG9yQWxwaGFMb25nKCkpOworICAgICAgICAgICAgbVBob25lLnNldFN5c3RlbVByb3BlcnR5KFRlbGVwaG9ueVByb3BlcnRpZXMuUFJPUEVSVFlfT1BFUkFUT1JfQUxQSEEsCisgICAgICAgICAgICAgICAgICAgIG1TUy5nZXRPcGVyYXRvckFscGhhTG9uZygpKTsKIAogICAgICAgICAgICAgU3RyaW5nIHByZXZPcGVyYXRvck51bWVyaWMgPQogICAgICAgICAgICAgICAgICAgICBTeXN0ZW1Qcm9wZXJ0aWVzLmdldChUZWxlcGhvbnlQcm9wZXJ0aWVzLlBST1BFUlRZX09QRVJBVE9SX05VTUVSSUMsICIiKTsKLSAgICAgICAgICAgIG9wZXJhdG9yTnVtZXJpYyA9IHNzLmdldE9wZXJhdG9yTnVtZXJpYygpOwotICAgICAgICAgICAgcGhvbmUuc2V0U3lzdGVtUHJvcGVydHkoVGVsZXBob255UHJvcGVydGllcy5QUk9QRVJUWV9PUEVSQVRPUl9OVU1FUklDLCBvcGVyYXRvck51bWVyaWMpOworICAgICAgICAgICAgb3BlcmF0b3JOdW1lcmljID0gbVNTLmdldE9wZXJhdG9yTnVtZXJpYygpOworICAgICAgICAgICAgbVBob25lLnNldFN5c3RlbVByb3BlcnR5KFRlbGVwaG9ueVByb3BlcnRpZXMuUFJPUEVSVFlfT1BFUkFUT1JfTlVNRVJJQywgb3BlcmF0b3JOdW1lcmljKTsKIAogICAgICAgICAgICAgaWYgKG9wZXJhdG9yTnVtZXJpYyA9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJvcGVyYXRvck51bWVyaWMgaXMgbnVsbCIpOwotICAgICAgICAgICAgICAgIHBob25lLnNldFN5c3RlbVByb3BlcnR5KFRlbGVwaG9ueVByb3BlcnRpZXMuUFJPUEVSVFlfT1BFUkFUT1JfSVNPX0NPVU5UUlksICIiKTsKKyAgICAgICAgICAgICAgICBtUGhvbmUuc2V0U3lzdGVtUHJvcGVydHkoVGVsZXBob255UHJvcGVydGllcy5QUk9QRVJUWV9PUEVSQVRPUl9JU09fQ09VTlRSWSwgIiIpOwogICAgICAgICAgICAgICAgIG1Hb3RDb3VudHJ5Q29kZSA9IGZhbHNlOwogICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICBTdHJpbmcgaXNvQ291bnRyeUNvZGUgPSAiIjsKQEAgLTEwMzcsMjEgKzEwNjAsMjEgQEAKICAgICAgICAgICAgICAgICAgICAgbG9nZSgicG9sbFN0YXRlRG9uZTogY291bnRyeUNvZGVGb3JNY2MgZXJyb3IiICsgZXgpOwogICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgICAgIHBob25lLnNldFN5c3RlbVByb3BlcnR5KFRlbGVwaG9ueVByb3BlcnRpZXMuUFJPUEVSVFlfT1BFUkFUT1JfSVNPX0NPVU5UUlksCisgICAgICAgICAgICAgICAgbVBob25lLnNldFN5c3RlbVByb3BlcnR5KFRlbGVwaG9ueVByb3BlcnRpZXMuUFJPUEVSVFlfT1BFUkFUT1JfSVNPX0NPVU5UUlksCiAgICAgICAgICAgICAgICAgICAgICAgICBpc29Db3VudHJ5Q29kZSk7CiAgICAgICAgICAgICAgICAgbUdvdENvdW50cnlDb2RlID0gdHJ1ZTsKIAotICAgICAgICAgICAgICAgIGlmIChzaG91bGRGaXhUaW1lWm9uZU5vdyhwaG9uZSwgb3BlcmF0b3JOdW1lcmljLCBwcmV2T3BlcmF0b3JOdW1lcmljLAorICAgICAgICAgICAgICAgIGlmIChzaG91bGRGaXhUaW1lWm9uZU5vdyhtUGhvbmUsIG9wZXJhdG9yTnVtZXJpYywgcHJldk9wZXJhdG9yTnVtZXJpYywKICAgICAgICAgICAgICAgICAgICAgICAgIG1OZWVkRml4Wm9uZSkpIHsKICAgICAgICAgICAgICAgICAgICAgZml4VGltZVpvbmUoaXNvQ291bnRyeUNvZGUpOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgcGhvbmUuc2V0U3lzdGVtUHJvcGVydHkoVGVsZXBob255UHJvcGVydGllcy5QUk9QRVJUWV9PUEVSQVRPUl9JU1JPQU1JTkcsCi0gICAgICAgICAgICAgICAgICAgIHNzLmdldFJvYW1pbmcoKSA/ICJ0cnVlIiA6ICJmYWxzZSIpOworICAgICAgICAgICAgbVBob25lLnNldFN5c3RlbVByb3BlcnR5KFRlbGVwaG9ueVByb3BlcnRpZXMuUFJPUEVSVFlfT1BFUkFUT1JfSVNST0FNSU5HLAorICAgICAgICAgICAgICAgICAgICBtU1MuZ2V0Um9hbWluZygpID8gInRydWUiIDogImZhbHNlIik7CiAKICAgICAgICAgICAg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cmVuZ3RoKSB7CiAgICAgICAgICAgICAvLyBUaGUgcmFkaW8gaXMgdGVsbGluZyB1cyBhYm91dCBzaWduYWwgc3RyZW5ndGggY2hhbmdlcwogICAgICAgICAgICAgLy8gd2UgZG9uJ3QgaGF2ZSB0byBhc2sgaXQKICAgICAgICAgICAgIHJldHVybjsKQEAgLTExODEsOCArMTIwNCw5IEBACiAgICAgICAgIH0KICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgaW50IGdldEN1cnJlbnREYXRhQ29ubmVjdGlvblN0YXRlKCkgewotICAgICAgICByZXR1cm4gbURhdGFDb25uZWN0aW9uU3RhdGU7CisgICAgICAgIHJldHVybiBtU1MuZ2V0RGF0YVJlZ1N0YXRlKCk7CiAgICAgfQogCiAgICAgLyoqCkBAIC0xNDAyLDkgKzE0MjYsOSBAQAogICAgICAgICAgICAgICAgICAgICAgKi8KICAgICAgICAgICAgICAgICAgICAgbG9uZyBnYWluZWQgPSBjLmdldFRpbWVJbk1pbGxpcygpIC0gU3lzdGVtLmN1cnJlbnRUaW1lTWlsbGlzKCk7CiAgICAgICAgICAgICAgICAgICAgIGxvbmcgdGltZVNpbmNlTGFzdFVwZGF0ZSA9IFN5c3RlbUNsb2NrLmVsYXBzZWRSZWFsdGltZSgpIC0gbVNhdmVkQXRUaW1lOwotICAgICAgICAgICAgICAgICAgICBpbnQgbml0elVwZGF0ZVNwYWNpbmcgPSBTZXR0aW5ncy5HbG9iYWwuZ2V0SW50KGNyLAorICAgICAgICAgICAgICAgICAgICBpbnQgbml0elVwZGF0ZVNwYWNpbmcgPSBTZXR0aW5ncy5HbG9iYWwuZ2V0SW50KG1DciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTZXR0aW5ncy5HbG9iYWwuTklUWl9VUERBVEVfU1BBQ0lORywgbU5pdHpVcGRhdGVTcGFjaW5nKTsKLSAgICAgICAgICAgICAgICAgICAgaW50IG5pdHpVcGRhdGVEaWZmID0gU2V0dGluZ3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AgICB9IGNhdGNoIChTZXR0aW5nTm90Rm91bmRFeGNlcHRpb24gc25mZSkgewogICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgIH0KQEAgLTE0NzEsMTIgKzE0OTUsMTIgQEAKICAgICBwcml2YXRlIHZvaWQgc2V0QW5kQnJvYWRjYXN0TmV0d29ya1NldFRpbWVab25lKFN0cmluZyB6b25lSWQpIHsKICAgICAgICAgaWYgKERCRykgbG9nKCJzZXRBbmRCcm9hZGNhc3ROZXR3b3JrU2V0VGltZVpvbmU6IHNldFRpbWVab25lPSIgKyB6b25lSWQpOwogICAgICAgICBBbGFybU1hbmFnZXIgYWxhcm0gPQotICAgICAgICAgICAgKEFsYXJtTWFuYWdlcikgcGhvbmUuZ2V0Q29udGV4dCgpLmdldFN5c3RlbVNlcnZpY2UoQ29udGV4dC5BTEFSTV9TRVJWSUNFKTsKKyAgICAgICAgICAgIChBbGFybU1hbmFnZXIpIG1QaG9uZS5nZXRDb250ZXh0KCkuZ2V0U3lzdGVtU2VydmljZShDb250ZXh0LkFMQVJNX1NFUlZJQ0UpOwogICAgICAgICBhbGFybS5zZXRUaW1lWm9uZSh6b25lSWQpOwogICAgICAgICBJbnRlbnQgaW50ZW50ID0gbmV3IEludGVudChUZWxlcGhvbnlJbnRlbnRzLkFDVElPTl9ORVRXT1JLX1NFVF9USU1FWk9ORSk7CiAgICAgICAgIGludGVudC5hZGRGbGFncyhJbnRlbnQuRkxBR19SRUNFSVZFUl9SRVBMQUNFX1BFTkRJTkcpOwogICAgICAgICBpbnRlbnQucHV0RXh0cmEoInRpbWUtem9uZSIsIHpvbmVJZCk7Ci0gICAgICAgIHBob25lLmdldENvbnRleHQoKS5zZW5kU3RpY2t5QnJvYWRjYXN0QXNVc2VyKGludGVudCwgVXNlckhhbmRsZS5BTEwpOworICAgICAgICBtUGhvbmUuZ2V0Q29udGV4dCgpLnNlbmRTdGlja3lCcm9hZGNhc3RBc1VzZXIoaW50ZW50LCBVc2VySGFuZ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5vdGlmeVJlZ2lzdHJhbnRzKCk7CiAgICAgICAgIH0KICAgICAgICAgaWYgKG9sZE90YXNwTW9kZSAhPSBtQ3VycmVudE90YXNwTW9kZSkgewogICAgICAgICAgICAgaWYgKERCRykgewogICAgICAgICAgICAgICAgIGxvZygiQ0RNQV9TVUJTQ1JJUFRJT046IGNhbGwgbm90aWZ5T3Rhc3BDaGFuZ2VkIG9sZCBvdGFzcE1vZGU9IiArCiAgICAgICAgICAgICAgICAgICAgIG9sZE90YXNwTW9kZSArICIgbmV3IG90YXNwTW9kZT0iICsgbUN1cnJlbnRPdGFzcE1vZGUpOwogICAgICAgICAgICAgfQotICAgICAgICAgICAgcGhvbmUubm90aWZ5T3Rhc3BDaGFuZ2VkKG1DdXJyZW50T3Rhc3BNb2RlKTsKKyAgICAgICAgICAgIG1QaG9uZS5ub3RpZnlPdGFzcENoYW5nZWQobUN1cnJlbnRPdGFzcE1vZGUpOwogICAgICAgICB9CiAgICAgfQogCkBAIC0xNjkxLDcgKzE3MTYsNyBAQAogICAgICAgICAgICAgICAgIGxvZygiTmV3IGNhcmQgZm91bmQiKTsKICAgICAgICAgICAgICAgICBtVWljY0FwcGxjYXRpb24gPSBuZXdVaWNjQXBwbGljYXRpb247CiAgICAgICAgICAgICAgICAgbUljY1JlY29yZHMgPSBtVWljY0FwcGxjYXRpb24uZ2V0SWNjUmVjb3JkcygpOwotICAgICAgICAgICAgICAgIGlmIChpc1N1YnNjcmlwdGlvbkZyb21SdWltKSB7CisgICAgICAgICAgICAgICAgaWYgKG1Jc1N1YnNjcmlwdGlvbkZyb21SdWltKSB7CiAgICAgICAgICAgICAgICAgICAgIG1VaWNjQXBwbGNhdGlvbi5yZWdpc3RlckZvclJlYWR5KHRoaXMsIEVWRU5UX1JVSU1fUkVBRFksIG51bGwpOwogICAgICAgICAgICAgICAgICAgICBpZiAobUljY1JlY29yZHMgIT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgbUljY1JlY29yZHMucmVna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AgICAgICAgICAgIH0KLSAgICAgICAgICAgIHNJbnN0YW5jZS5zUmVmZXJlbmNlQ291bnQrKzsKKyAgICAgICAgICAgIENkbWFTdWJzY3JpcHRpb25Tb3VyY2VNYW5hZ2VyLnNSZWZlcmVuY2VDb3VudCsrOwogICAgICAgICB9CiAgICAgICAgIHNJbnN0YW5jZS5yZWdpc3RlckZvckNkbWFTdWJzY3JpcHRpb25Tb3VyY2VDaGFuZ2VkKGgsIHdoYXQsIG9iaik7CiAgICAgICAgIHJldHVybiBzSW5zdGFuY2U7CkBAIC05MSw4ICs4OSw4IEBACiAgICAgICAgIHN5bmNocm9uaXplZCAoc1JlZmVyZW5jZUNvdW50TW9uaXRvcikgewogICAgICAgICAgICAgc1JlZmVyZW5jZUNvdW50LS07CiAgICAgICAgICAgICBpZiAoc1JlZmVyZW5jZUNvdW50IDw9IDApIHsKLSAgICAgICAgICAgICAgICBtQ00udW5yZWdpc3RlckZvckNkbWFTdWJzY3JpcHRpb25DaGFuZ2VkKHRoaXMpOwotICAgICAgICAgICAgICAgIG1DTS51bnJlZ2lzdGVyRm9yT24odGhpcyk7CisgICAgICAgICAgICAgICAgbUNpLnVucmVnaXN0ZXJGb3JDZG1hU3Vic2NyaXB0aW9uQ2hhbmdlZCh0aGlzKTsKKyAgICAgICAgICAgICAgICBtQ2kudW5yZWdpc3RlckZvck9uKHRoaXMpOwogICAgICAgICAgICAgICAgIHNJbnN0YW5jZSA9IG51bGw7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KQEAgLTExNSw3ICsxMTMsNyBAQAogICAgICAgICAgICAgfQogICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICBjYXNlIEVWRU5UX1JBRElPX09OOiB7Ci0gICAgICAgICAgICAgICAgbUNNLmdldENkbWFTdWJzY3JpcHRpb25Tb3VyY2Uob2J0YWluTWVzc2FnZShFVkVOVF9HRVRfQ0RNQV9TVUJTQ1JJUFRJT05fU09VUkNFKSk7CisgICAgICAgICAgICAgICA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IFJPQU1JTkdfSUNPTl9NT0RFX05PUk1BTCAgICA9IDA7CiAgICAgcHVibGljIHN0YXRpYyBmaW5hbCBpbnQgUk9BTUlOR19JQ09OX01PREVfRkxBU0ggICAgID0gMTsKIAotICAgIHB1YmxpYyBpbnQgbVJvYW1pbmdJbmRpY2F0b3I7Ci0gICAgcHVibGljIGludCBtSWNvbkluZGV4OwotICAgIHB1YmxpYyBpbnQgbUljb25Nb2RlOwotICAgIHB1YmxpYyBTdHJpbmcgbUVyaVRleHQ7Ci0gICAgcHVibGljIGludCBtQ2FsbFByb21wdElkOwotICAgIHB1YmxpYyBpbnQgbUFsZXJ0SWQ7CisgICAgcHVibGljIGludCByb2FtaW5nSW5kaWNhdG9yOworICAgIHB1YmxpYyBpbnQgaWNvbkluZGV4OworICAgIHB1YmxpYyBpbnQgaWNvbk1vZGU7CisgICAgcHVibGljIFN0cmluZyBlcmlUZXh0OworICAgIHB1YmxpYyBpbnQgY2FsbFByb21wdElkOworICAgIHB1YmxpYyBpbnQgYWxlcnRJZDsKIAogICAgIHB1YmxpYyBFcmlJbmZvIChpbnQgcm9hbWluZ0luZGljYXRvciwgaW50IGljb25JbmRleCwgaW50IGljb25Nb2RlLCBTdHJpbmcgZXJpVGV4dCwKICAgICAgICAgICAgIGludCBjYWxsUHJvbXB0SWQsIGludCBhbGVydElkKSB7CiAKLSAgICAgICAgdGhpcy5tUm9hbWluZ0luZGljYXRvciA9IHJvYW1pbmdJbmRpY2F0b3I7Ci0gICAgICAgIHRoaXMubUljb25JbmRleCA9IGljb25JbmRleDsKLSAgICAgICAgdGhpcy5tSWNvbk1vZGUgPSBpY29uTW9kZTsKLSAgICAgICAgdGhpcy5tRXJpVGV4dCA9IGVyaVRleHQ7Ci0gICAgICAgIHRoaXMubUNhbGxQcm9tcHRJZCA9IGNhbGxQcm9tcHRJZDsKLSAgICAgICAgdGhpcy5tQWxlcnRJZCA9IGFsZXJ0SWQ7CisgICAgICAgIHRoaXMucm9hbWluZ0luZGlj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kuUGhvbmVCYXNlOwogaW1wb3J0IGNvbS5hbmRyb2lkLmludGVybmFsLnV0aWwuWG1sVXRpbHM7CiAKQEAgLTQ0LDM4ICs0MiwzOCBAQAogCiAgICAgY2xhc3MgRXJpRmlsZSB7CiAKLSAgICAgICAgcHVibGljIGludCBtVmVyc2lvbk51bWJlcjsgICAgICAgICAgICAgICAgICAgICAgLy8gRmlsZSB2ZXJzaW9uIG51bWJlcgotICAgICAgICBwdWJsaWMgaW50IG1OdW1iZXJPZkVyaUVudHJpZXM7ICAgICAgICAgICAgICAgICAvLyBOdW1iZXIgb2YgZW50cmllcwotICAgICAgICBwdWJsaWMgaW50IG1FcmlGaWxlVHlwZTsgICAgICAgICAgICAgICAgICAgICAgICAvLyBFcmkgUGhhc2UgMC8xCi0gICAgICAgIC8vcHVibGljIGludCBtTnVtYmVyT2ZJY29uSW1hZ2VzOyAgICAgICAgICAgICAgIC8vIHJlc2VydmVkIGZvciBmdXR1cmUgdXNlCi0gICAgICAgIC8vcHVibGljIGludCBtSWNvbkltYWdlVHlwZTsgICAgICAgICAgICAgICAgICAgIC8vIHJlc2VydmVkIGZvciBmdXR1cmUgdXNlCi0gICAgICAgIHB1YmxpYyBTdHJpbmdbXSBtQ2FsbFByb21wdElkOyAgICAgICAgICAgICAgICAgIC8vIHJlc2VydmVkIGZvciBmdXR1cmUgdXNlCi0gICAgICAgIHB1YmxpYyBIYXNoTWFwPEludGVnZXIsIEVyaUluZm8+IG1Sb2FtSW5kVGFibGU7IC8vIFJvYW1pbmcgSW5kaWNhdG9yIFRhYmxlCisgICAgICAgIGludCBtVmVyc2lvbk51bWJlcjsgICAgICAgICAgICAgICAgICAgICAgLy8gRmlsZSB2ZXJzaW9uIG51bWJlcgorICAgICAgICBpbnQgbU51bWJlck9mRXJpRW50cmllczsgICAgICAgICAgICAgICAgIC8vIE51bWJlciBvZiBlbnRyaWVzCisgICAgICAgIGludCBtRXJpRmlsZVR5cGU7ICAgICAgICAgICAgICAgICAgICAgIC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bz4oKTsKICAgICAgICAgfQogICAgIH0KIAogICAgIGNsYXNzIEVyaURpc3BsYXlJbmZvcm1hdGlvbiB7Ci0gICAgICAgIHB1YmxpYyBpbnQgbUVyaUljb25JbmRleDsKLSAgICAgICAgcHVibGljIGludCBtRXJpSWNvbk1vZGU7Ci0gICAgICAgIHB1YmxpYyBTdHJpbmcgbUVyaUljb25UZXh0OworICAgICAgICBpbnQgbUVyaUljb25JbmRleDsKKyAgICAgICAgaW50IG1FcmlJY29uTW9kZTsKKyAgICAgICAgU3RyaW5nIG1FcmlJY29uVGV4dDsKIAotICAgICAgICBwdWJsaWMgRXJpRGlzcGxheUluZm9ybWF0aW9uKGludCBlcmlJY29uSW5kZXgsIGludCBlcmlJY29uTW9kZSwgU3RyaW5nIGVyaUljb25UZXh0KSB7CisgICAgICAgIEVyaURpc3BsYXlJbmZvcm1hdGlvbihpbnQgZXJpSWNvbkluZGV4LCBpbnQgZXJpSWNvbk1vZGUsIFN0cmluZyBlcmlJY29uVGV4dCkgewogICAgICAgICAgICAgbUVyaUljb25JbmRleCA9IGVyaUljb25JbmRleDsKICAgICAgICAgICAgIG1FcmlJY29uTW9kZSA9IGVyaUljb25Nb2RlOwogICAgICAgICAgICAgbUVyaUljb25UZXh0ID0gZXJpSWNvblRleHQ7CiAgICAgICAgIH0KIAogLy8gICAgICAgIHB1YmxpYyB2b2lkIHNldFBhcmFtZXRlcnMoaW50IGVyaUljb25JbmRleCwgaW50IGVyaUljb25Nb2RlLCBTdHJpbmcgZXJpSWNvblRleHQpewotLy8gICAgICAgICAgICB0aGlzLm1FcmlJY29uSW5kZXggPSBlcmlJY29uSW5kZXg7Ci0vLyAgICAgICAgICAgIHRoaXMubUVyaUljb25Nb2RlID0gZXJpSWNvbk1vZGU7Ci0vLyAgICAgICAgICAgIHRoaXMubUVyaUljb25UZXh0ID0gZXJpSWNvblRleHQ7CisvLyAgICAgICAgICAgIG1FcmlJY29uSW5kZXggPSBlcmlJY29uSW5kZXg7CisvLy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sZUxvYWRlZDsKKyAgICAgICAgcmV0dXJuIG1Jc0VyaUZpbGVMb2FkZWQ7CiAgICAgfQogCiAgICAgLyoqCkBAIC0yODcsMTQgKzI4MywxNCBAQAogICAgICAgICBFcmlEaXNwbGF5SW5mb3JtYXRpb24gcmV0OwogCiAgICAgICAgIC8vIENhcnJpZXIgY2FuIHVzZSBlcmkueG1sIHRvIGN1c3RvbWl6ZSBhbnkgYnVpbHQtaW4gcm9hbWluZyBkaXNwbGF5IGluZGljYXRpb25zCi0gICAgICAgIGlmIChpc0VyaUZpbGVMb2FkZWQpIHsKKyAgICAgICAgaWYgKG1Jc0VyaUZpbGVMb2FkZWQpIHsKICAgICAgICAgICAgIEVyaUluZm8gZXJpSW5mbyA9IGdldEVyaUluZm8ocm9hbUluZCk7CiAgICAgICAgICAgICBpZiAoZXJpSW5mbyAhPSBudWxsKSB7CiAgICAgICAgICAgICAgICAgaWYgKFZEQkcpIFJsb2cudihMT0dfVEFHLCAiRVJJIHJvYW1JbmQgIiArIHJvYW1JbmQgKyAiIGZvdW5kIGluIEVSSSBmaWxlIik7CiAgICAgICAgICAgICAgICAgcmV0ID0gbmV3IEVyaURpc3BsYXlJbmZvcm1hdGlvbigKLSAgICAgICAgICAgICAgICAgICAgICAgIGVyaUluZm8ubUljb25JbmRleCwKLSAgICAgICAgICAgICAgICAgICAgICAgIGVyaUluZm8ubUljb25Nb2RlLAotICAgICAgICAgICAgICAgICAgICAgICAgZXJpSW5mby5tRXJpVGV4dCk7CisgICAgICAgICAgICAgICAgICAgICAgICBlcmlJbmZvLmljb25JbmRleCwKKyAgICAgICAgICAgICAgICAgICAgICAgIGVyaUluZm8uaWNvbk1vZGUsCisgICAgICAgICAgICAgICAgICAgICAgICBlcmlJbmZvLmVyaVRleHQpOwogICAgICAgICAgICAgICAgIHJldHVybiByZXQ7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KQEAgLTM5Niw3ICszOTIsNyBAQAogCiAgICAgICAgIC8vIEhhbmRsaW5nIHRoZSBub24gc3RhbmRhcmQgRW5oYW5jZWQgUm9hbWluZyBJbmRpY2F0b3IgKHJvYW1JbmQgPiA2MykKICAgICAgICAgZGVmYXVsdDoKLSAgICAgICAgICAgIGlmICghaXNFcmlGaWxlTG9hZGVkKSB7CisgICAgICAgICAgICBpZiAoIW1Jc0VyaUZpbGVMb2FkZWQpIHsKICAgICAgICAgICAgICAgICAvLyBFUkkgZmlsZSBOT1QgbG9hZGVkCiAgICAgICAgICAgICAgICAgaWYgKERCRykgUmxvZy5kKExPR19UQUcsICJFUkkgRmlsZSBub3QgbG9hZGVkIik7CiAgICAgICAgICAgICAgICAgaWYoZGVmUm9hbUluZCA+IDIpIHsKQEAgLTQ2MCwxNiArNDU2LDE2IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUmxvZy52KExPR19UQUcsICJFUkkgZGVmUm9hbUluZCAiICsgZGVmUm9hbUluZCArICIgZm91bmQgaW4gRVJJIGZpbGUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgIHJldCA9IG5ldyBFcmlEaXNwbGF5SW5mb3JtYXRpb24oCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZkVyaUluZm8ubUljb25JbmRleCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmRXJpSW5mby5tSWNvbk1vZGUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZkVyaUluZm8ubUVyaVRleHQpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZFcmlJbmZvLmljb25JbmRleCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmRXJpSW5mby5pY29uTW9kZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmRXJpSW5mby5lcmlUZXh0KTsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgIGlmIChWREJHKSBSbG9nLnYoTE9HX1RBRywgIkVSSSByb2FtSW5kICIgKyByb2FtSW5kICsgIiBmb3VuZCBpbiBFUkkgZmlsZSIpOwogICAgICAgICAgICAgICAgICAgICByZXQgPSBuZXcgRXJpRGlzcGxheUluZm9ybWF0aW9uKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVyaUluZm8ubUljb25JbmRleCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcmlJbmZvLm1JY29uTW9kZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcmlJbmZvLm1FcmlUZXh0KTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcmlJbmZvLmljb25JbmRleCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcmlJbmZvLmljb25Nb2RlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVyaUluZm8uZXJpVGV4dCk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogICAgICAgICAgICAgYnJlYWs7CmRpZmYgLS1naXQgYS9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvY2RtYS9SdWltUGhvbmVCb29rSW50ZXJmYWNlTWFuYWdlci5qYXZhIGIvc3JjL2phdmEvY29tL2FuZHJvaWQvaW50ZXJuYWwvdGVsZXBob255L2NkbWEvUnVpbVBob25lQm9va0ludGVyZmFjZU1hbmFnZXIuamF2YQppbmRleCA3NWIyZjU5Li5hZjE4MzI0IDEwMDY0NAotLS0gYS9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvY2RtYS9SdWltUGhvbmVCb29rSW50ZXJmYWNlTWFuYWdlci5qYXZhCisrKyBiL3NyYy9qYXZhL2NvbS9hbmRyb2lkL2ludGVybmFsL3RlbGVwaG9ueS9jZG1hL1J1aW1QaG9uZUJvb2tJbnRlcmZhY2VNYW5hZ2VyLmphdmEKQEAgLTMx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EAKICAgICAgICAgLy8gbGluayB0aGUgdGhlIGZpbGxlZCBvYmplY3RzIHRvIHRoZSBTTVMKICAgICAgICAgZW52Lm9yaWdBZGRyZXNzID0gYWRkcjsKICAgICAgICAgZW52Lm9yaWdTdWJhZGRyZXNzID0gc3ViYWRkcjsKLSAgICAgICAgbXNnLm9yaWdpbmF0aW5nQWRkcmVzcyA9IGFkZHI7CisgICAgICAgIG1zZy5tT3JpZ2luYXRpbmdBZGRyZXNzID0gYWRkcjsKICAgICAgICAgbXNnLm1FbnZlbG9wZSA9IGVudjsKIAogICAgICAgICAvLyBjcmVhdGUgYnl0ZSBzdHJlYW0gcmVwcmVzZW50YXRpb24gZm9yIHRyYW5zcG9ydGF0aW9uIHRocm91Z2ggdGhlIGxheWVycy4KQEAgLTIzMiw3ICsyMzIsNyBAQAogICAgICAgICB0cnkgewogICAgICAgICAgICAgU21zTWVzc2FnZSBtc2cgPSBuZXcgU21zTWVzc2FnZSgpOwogCi0gICAgICAgICAgICBtc2cuaW5kZXhPbkljYyA9IGluZGV4OworICAgICAgICAgICAgbXNnLm1JbmRleE9uSWNjID0gaW5kZXg7CiAKICAgICAgICAgICAgIC8vIEZpcnN0IGJ5dGUgaXMgc3RhdHVzOiBSRUNFSVZFRF9SRUFELCBSRUNFSVZFRF9VTlJFQUQsIFNUT1JFRF9TRU5ULAogICAgICAgICAgICAgLy8gb3IgU1RPUkVEX1VOU0VOVApAQCAtMjQxLDcgKzI0MSw3IEBACiAgICAgICAgICAgICAgICAgUmxvZy53KExPR19UQUcsICJTTVMgcGFyc2luZyBmYWlsZWQ6IFRyeWluZyB0byBwYXJzZSBhIGZyZWUgcmVjb3JkIik7CiAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgIG1zZy5zdGF0dXNPbkljYyA9IGRhdGFbMF0gJiAweDA3OworICAgICAgICAgICAgICAgIG1zZy5tU3RhdHVzT25JY2MgPSBkYX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aGljaCBpcyBub3Qgc3VwcG9ydGVkIGluIENETUEgbW9kZS4KICAgICAgKi8KKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgYm9vbGVhbiBpc0NwaHNNd2lNZXNzYWdlKCkgewogICAgICAgICBSbG9nLncoTE9HX1RBRywgImlzQ3Boc013aU1lc3NhZ2U6IGlzIG5vdCBzdXBwb3J0ZWQgaW4gQ0RNQSBtb2RlLiIpOwogICAgICAgICByZXR1cm4gZmFsc2U7CkBAIC0zOTUsNiArMzk4LDcgQEAKICAgICAvKioKICAgICAgKiB7QGluaGVyaXREb2N9CiAgICAgICovCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGJvb2xlYW4gaXNNV0lDbGVhck1lc3NhZ2UoKSB7CiAgICAgICAgIHJldHVybiAoKG1CZWFyZXJEYXRhICE9IG51bGwpICYmIChtQmVhcmVyRGF0YS5udW1iZXJPZk1lc3NhZ2VzID09IDApKTsKICAgICB9CkBAIC00MDIsNiArNDA2LDcgQEAKICAgICAvKioKICAgICAgKiB7QGluaGVyaXREb2N9CiAgICAgICovCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGJvb2xlYW4gaXNNV0lTZXRNZXNzYWdlKCkgewogICAgICAgICByZXR1cm4gKChtQmVhcmVyRGF0YSAhPSBudWxsKSAmJiAobUJlYXJlckRhdGEubnVtYmVyT2ZNZXNzYWdlcyA+IDApKTsKICAgICB9CkBAIC00MDksNiArNDE0LDcgQEAKICAgICAvKioKICAgICAgKiB7QGluaGVyaXREb2N9CiAgICAgICovCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGJvb2xlYW4gaXNNd2lEb250U3RvcmUoKSB7CiAgICAgICAgIHJldHVybiAoKG1CZWFyZXJEYXRhICE9IG51bGwpICYmCiAgICAgICAgICAgICAgICAgKG1CZWFyZXJEYXRhLm51bWJlck9mTWVzc2FnZXMgPiAwKSAmJgpAQCAtNDIwLDExICs0MjYsMTMgQEAKICAgICAgKiBGb3Igbm90I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I7CisgICAgICAgIG1PcmlnaW5hdGluZ0FkZHJlc3MgPSBhZGRyOwogICAgICAgICBlbnYub3JpZ0FkZHJlc3MgPSBhZGRyOwogICAgICAgICBtRW52ZWxvcGUgPSBlbnY7CiAgICAgICAgIG1QZHUgPSBwZHU7CkBAIC02NjAsNyArNjY5LDcgQEAKICAgICAgICAgfQogCiAgICAgICAgIC8vIGxpbmsgdGhlIGZpbGxlZCBvYmplY3RzIHRvIHRoaXMgU01TCi0gICAgICAgIG9yaWdpbmF0aW5nQWRkcmVzcyA9IGFkZHI7CisgICAgICAgIG1PcmlnaW5hdGluZ0FkZHJlc3MgPSBhZGRyOwogICAgICAgICBlbnYub3JpZ0FkZHJlc3MgPSBhZGRyOwogICAgICAgICBlbnYub3JpZ1N1YmFkZHJlc3MgPSBzdWJBZGRyOwogICAgICAgICBtRW52ZWxvcGUgPSBlbnY7CkBAIC02ODAsNyArNjg5LDcgQEAKICAgICAgICAgICAgIGlmIChtRW52ZWxvcGUuYmVhcmVyRGF0YSAhPSBudWxsKSB7CiAgICAgICAgICAgICAgICAgbUJlYXJlckRhdGEubnVtYmVyT2ZNZXNzYWdlcyA9IDB4MDAwMDAwRkYgJiBtRW52ZWxvcGUuYmVhcmVyRGF0YVswXTsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGlmIChmYWxzZSkgeworICAgICAgICAgICAgaWYgKFZEQkcpIHsKICAgICAgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgInBhcnNlU21zOiBnZXQgTVdJICIgKwogICAgICAgICAgICAgICAgICAgICAgIEludGVnZXIudG9TdHJpbmcobUJlYXJlckRhdGEubnVtYmVyT2ZNZXNzYWdlcykpOwogICAgICAgICAgICAgfQpAQCAtNjkyLDI0ICs3MDEsMjQgQEAKICAgICAgICAgICAgICAgICAgICAgICBIZXhEdW1wLnRvSGV4U3RyaW5nKG1FbnZlbG9wZS5iZWFyZXJEYXRhKSArICInIik7CiAgICAgICAgICAgICBSbG9nLmQoTE9H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HVzID09IDApLgogICAgICAgICAgICAgaWYgKCEgbUJlYXJlckRhdGEubWVzc2FnZVN0YXR1c1NldCkgewogICAgICAgICAgICAgICAgIFJsb2cuZChMT0dfVEFHLCAiREVMSVZFUllfQUNLIG1lc3NhZ2Ugd2l0aG91dCBtc2dTdGF0dXMgKCIgKwotICAgICAgICAgICAgICAgICAgICAgICAgKHVzZXJEYXRhID09IG51bGwgPyAiYWxzbyBtaXNzaW5nIiA6ICJkb2VzIGhhdmUiKSArCisgICAgICAgICAgICAgICAgICAgICAgICAobVVzZXJEYXRhID09IG51bGwgPyAiYWxzbyBtaXNzaW5nIiA6ICJkb2VzIGhhdmUiKSArCiAgICAgICAgICAgICAgICAgICAgICAgICAiIHVzZXJEYXRhKS4iKTsKICAgICAgICAgICAgICAgICBzdGF0dXMgPSAwOwogICAgICAgICAgICAgfSBlbHNlIHsKQEAgLTczMywxMSArNzQyLDExIEBACiAgICAgICAgICAgICB0aHJvdyBuZXcgUnVudGltZUV4Y2VwdGlvbigiVW5zdXBwb3J0ZWQgbWVzc2FnZSB0eXBlOiAiICsgbUJlYXJlckRhdGEubWVzc2FnZVR5cGUpOwogICAgICAgICB9CiAKLSAgICAgICAgaWYgKG1lc3NhZ2VCb2R5ICE9IG51bGwpIHsKLSAgICAgICAgICAgIGlmIChmYWxzZSkgUmxvZy52KExPR19UQUcsICJTTVMgbWVzc2FnZSBib2R5OiAnIiArIG1lc3NhZ2VCb2R5ICsgIiciKTsKKyAgICAgICAgaWYgKG1NZXNzYWdlQm9keSAhPSBudWxsKSB7CisgICAgICAgICAgICBpZiAoVkRCRykgUmxvZy52KExPR19UQUcsICJTTVMgbWVzc2FnZSBib2R5OiAnIiArIG1NZXNzYWdlQm9keSArICInIik7CiAgICAgICAgICAgICBwYXJzZU1lc3NhZ2VCb2R5KCk7Ci0gICAgICAgIH0gZWxzZSBpZiAoKHVzZXJEYXRhICE9IG51bGwpICYmIChmYWxzZSkpIHsKLSAgICAgICAgICAgIFJsb2cud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iBtRGF0YUNvbm5lY3Rpb247CiAgICAgfQogCi0gICAgcHVibGljIHN5bmNocm9uaXplZCB2b2lkIHNldERhdGFDb25uZWN0aW9uKERhdGFDb25uZWN0aW9uIGRjKSB7CisgICAgcHVibGljIHN5bmNocm9uaXplZCB2b2lkIHNldERhdGFDb25uZWN0aW9uKERhdGFDb25uZWN0aW9uQmFzZSBkYykgewogICAgICAgICBpZiAoREJHKSB7CiAgICAgICAgICAgICBsb2coInNldERhdGFDb25uZWN0aW9uOiBvbGQgZGM9IiArIG1EYXRhQ29ubmVjdGlvbiArICIgbmV3IGRjPSIgKyBkYyArICIgdGhpcz0iICsgdGhpcyk7CiAgICAgICAgIH0KQEAgLTk1LDE0ICs5OCwxNCBAQAogCiAgICAgcHVibGljIHN5bmNocm9uaXplZCB2b2lkIHNldERhdGFDb25uZWN0aW9uQWMoRGF0YUNvbm5lY3Rpb25BYyBkY2FjKSB7CiAgICAgICAgIGlmIChEQkcpIHsKLSAgICAgICAgICAgIGxvZygic2V0RGF0YUNvbm5lY3Rpb25BYzogb2xkIGRjYWM9IiArIG1EYXRhQ29ubmVjdGlvbkFjICsgIiBuZXcgZGNhYz0iICsgZGNhYyk7CisgICAgICAgICAgICBsb2coInNldERhdGFDb25uZWN0aW9uQWM6IG9sZCBkY2FjPSIgKyBtRGF0YUNvbm5lY3Rpb25BYyArICIgbmV3IGRjYWM9IiArIGRjYWMKKyAgICAgICAgICAgICAgICAgICAgKyAiIHRoaXM9IiArIHRoaXMpOwogICAgICAgICB9Ci0gICAgICAgIGlmIChkY2FjICE9IG51bGwpIHsKLSAgICAgICAgICAgIGRjYWMuYWRkQXBuQ29udGV4dFN5bmModGhpcyk7Ci0gICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICBpZiAobURhdGFDb25uZWN0aW9uQWMgIT0gbnVsbCkgewotICAgICAgICAgICAgICAgIG1EYXRhQ29ubmVjdGlvbkFjLnJlbW92ZUFwbkNvbnRleHRTeW5jKHRoaXMpOwotICAgICAgICAgICAgfQorICAgICAgICBpZiAoKGRjYWMgPT0gbnVsbCkgJiYgKG1EYXRhQ29ubmVjdGlvbkFjICE9IG51bGwpICYmCisgICAgICAgICAgICAgICAgKG1EYXRhQ29ubmVjdGlvbkFjLmRhdGFDb25uZWN0aW9uICE9IG51bGwpKSB7CisgICAgICAgICAgICAvLyBUT0RPOiBUaGlzIHRlYXJEb3duIHNob3VsZCBiZSBkb25lIGJ5IGNhbGxlciwgYnV0IGZvciBub3cgd2UnbGwgZG8gaXQKKyAgICAgICAgICAgIGlmIChEQkcpIGxvZygic2V0RGF0YUNvbm5lY3Rpb246IGNhbGwgdGVhckRvd24iKTsKKyAgICAgICAgICAgIG1EYXRhQ29ubmVjdGlvbkFjLmRhdGFDb25uZWN0aW9uLnRlYXJEb3duKHRoaXMsICIiLCBudWxsKTsKICAgICAgICAgfQogICAgICAgICBtRGF0YUNvbm5lY3Rpb25BYyA9IGRjYWM7CiAgICAgfQpAQCAtMTkwLDcgKzE5Myw3IEBACiAgICAgICAgICAgICBsb2coInNldFJldHJ5Q291bnQ6ICIgKyByZXRyeUNvdW50KTsKICAgICAgICAgfQogICAgICAgICBtUmV0cnlDb3VudCA9IHJldHJ5Q291bnQ7Ci0gICAgICAgIERhdGFDb25uZWN0aW9uIGRjID0gbURhdGFDb25uZWN0aW9uOworICAgICAgICBEYXRhQ29ubmVjdGlvbkJhc2UgZGMgPSBtRGF0YUNvbm5lY3Rpb247CiAgICAgICAgIGlmIChkYyAhPSBudWxsKSB7CiAgICAgICAgICAgICBkYy5zZXRSZXRyeUNvdW50KHJldHJ5Q291bnQpOwogICAgICAgICB9CkBAIC0yMzEsNyArMjM0LDkgQEAKICAgICAgICAgLy8gV2UgZG9uJ3QgcHJpbnQgbURhdGFDb25uZWN0aW9uIGJlY2F1c2UgaXRzIHJlY3Vyc2l2ZS4KICAgICAgICAgcmV0dXJuICJ7bUFwblR5cGU9IiArIG1BcG5UeXBlICsgIiBtU3RhdGU9IiArIGdldFN0YXRlKCkgKyAiIG1XYWl0aW5nQXBucz0iICsgbVdhaXRpbmdBcG5zICsKICAgICAgICAgICAgICAgICAiIG1XYWl0aW5nQXBuc1Blcm1hbmVudEZhaWx1cmVDb3VudERvd249IiArIG1XYWl0aW5nQXBuc1Blcm1hbmVudEZhaWx1cmVDb3VudERvd24gKwotICAgICAgICAgICAgICAgICIgbUFwblNldHRpbmc9IiArIG1BcG5TZXR0aW5nICsgIiBtRGF0YUNvbm5lY3Rpb25BYz0iICsgbURhdGFDb25uZWN0aW9uQWMgKworICAgICAgICAgICAgICAgICIgbUFwblNldHRpbmc9IiArIG1BcG5TZXR0aW5nICsKKyAgICAgICAgICAgICAgICAiIG1EYXRhQ29ubmVjdGlvbj0iICsgKChtRGF0YUNvbm5lY3Rpb24gIT0gbnVsbCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPyBtRGF0YUNvbm5lY3Rpb24udG9TdHJpbmdTaW1wbGUoKSA6ICJudWxsIikgKwogICAgICAgICAgICAgICAgICIgbVJlYXNvbj0iICsgbVJlYXNvbiArICIgbVJldHJ5Q291bnQ9IiArIG1SZXRyeUNvdW50ICsKICAgICAgICAgICAgICAgICAiIG1EYXRhRW5hYmxlZD0iICsgbURhdGFFbmFibGVkICsgIiBtRGVwZW5kZW5jeU1ldD0iICsgbURlcGVuZGVuY3lNZXQgKyAifSI7CiAgICAgfQpkaWZmIC0tZ2l0IGEvc3JjL2phdmEvY29tL2FuZHJvaWQvaW50ZXJuYWwvdGVsZXBob255L0FwblNldHRpbmcuamF2YSBiL3NyYy9qYXZhL2NvbS9hbmRyb2lkL2ludGVybmFsL3RlbGVwaG9ueS9kYXRhY29ubmVjdGlvbi9BcG5TZXR0aW5nLmphdmEKc2ltaWxhcml0eSBpbmRleCA5NiUKcmVuYW1lIGZyb20gc3JjL2phdmEvY29tL2FuZHJvaWQvaW50ZXJuYWwvdGVsZXBob255L0FwblNldHRpbmcuamF2YQpyZW5hbW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hbWUoKSk7CiAgICAgICAgIHJldHVybiBnc21EYzsKQEAgLTczLDE1ICs2OSwxNSBAQAogICAgIEBPdmVycmlkZQogICAgIHByb3RlY3RlZAogICAgIHZvaWQgb25Db25uZWN0KENvbm5lY3Rpb25QYXJhbXMgY3ApIHsKLSAgICAgICAgbUFwbiA9IGNwLmFwbjsKKyAgICAgICAgbUFwbiA9IGNwLm1BcG5Db250ZXh0LmdldEFwblNldHRpbmcoKTsKIAotICAgICAgICBpZiAoREJHKSBsb2coIkNvbm5lY3RpbmcgdG8gY2FycmllcjogJyIgKyBtQXBuLmNhcnJpZXIKLSAgICAgICAgICAgICAgICArICInIEFQTjogJyIgKyBtQXBuLmFwbgotICAgICAgICAgICAgICAgICsgIicgcHJveHk6ICciICsgbUFwbi5wcm94eSArICInIHBvcnQ6ICciICsgbUFwbi5wb3J0KTsKKyAgICAgICAgaWYgKERCRykgbG9nKCJvbkNvbm5lY3Q6IGNhcnJpZXI9JyIgKyBtQXBuLmNhcnJpZXIKKyAgICAgICAgICAgICAgICArICInIEFQTj0nIiArIG1BcG4uYXBuCisgICAgICAgICAgICAgICAgKyAiJyBwcm94eT0nIiArIG1BcG4ucHJveHkgKyAiJyBwb3J0PSciICsgbUFwbi5wb3J0ICsgIiciKTsKIAotICAgICAgICBjcmVhdGVUaW1lID0gLTE7Ci0gICAgICAgIGxhc3RGYWlsVGltZSA9IC0xOwotICAgICAgICBsYXN0RmFpbENhdXNlID0gRmFpbENhdXNlLk5PTkU7CisgICAgICAgIG1DcmVhdGVUaW1lID0gLTE7CisgICAgICAgIG1MYXN0RmFpbFRpbWUgPSAtMTsKKyAgICAgICAgbUxhc3RGYWlsQ2F1c2UgPSBGYWlsQ2F1c2UuTk9ORTsKIAogICAgICAgICAvLyBtc2cub2JqIHdpbGwgYmUgcmV0dXJuZWQgaW4gQXN5bmNSZXN1bHQudXNlck9iajsKICAgICAgICAgTWVzc2FnZSBtc2cgPSBvYnRhaW5NZXNzYWdlKEVWRU5UX1NFVFVQX0RBVEFfQ09OTkVDVElPTl9ET05FLCBjcCk7CkBAIC05NCwxNCArOTAsMTQgQEAKICAgICAgICAgfQogCiAgICAgICAgIFN0cmluZyBwcm90b2NvbDsKLSAgICAgICAgaWYgKHBob25lLmdldFNlcnZpY2VTdGF0ZSgpLmdldFJvYW1pbmcoKSkgeworICAgICAgICBpZiAobVBob25lLmdldFNlcnZpY2VTdGF0ZSgpLmdldFJvYW1pbmcoKSkgewogICAgICAgICAgICAgcHJvdG9jb2wgPSBtQXBuLnJvYW1pbmdQcm90b2NvbDsKICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIHByb3RvY29sID0gbUFwbi5wcm90b2NvbDsKICAgICAgICAgfQogCi0gICAgICAgIHBob25lLm1DTS5zZXR1cERhdGFDYWxsKAotICAgICAgICAgICAgICAgIEludGVnZXIudG9TdHJpbmcoZ2V0UmlsUmFkaW9UZWNobm9sb2d5KFJJTENvbnN0YW50cy5TRVRVUF9EQVRBX1RFQ0hfR1NNKSksCisgICAgICAgIG1QaG9uZS5tQ2kuc2V0dXBEYXRhQ2FsbCgKKyAgICAgICAgICAgICAgICBJbnRlZ2VyLnRvU3RyaW5nKGdldFJpbFJhZGlvVGVjaG5vbG9neSgpKSwKICAgICAgICAgICAgICAgICBJbnRlZ2VyLnRvU3RyaW5nKG1Qcm9maWxlSWQpLAogICAgICAgICAgICAgICAgIG1BcG4uYXBuLCBtQXBuLnVzZXIsIG1BcG4ucGFzc3dvcmQsCiAgICAgICAgICAgICAgICAgSW50ZWdlci50b1N0cmluZyhhdXRoVHlwZSksCkBAIC0xMTYsMTggKzExMiwyNCBAQAogICAgICAgICByZXR1cm4gbVByb2ZpbGVJZDsKICAgICB9CiAKKyAgICAvKiogRG9lc24ndCBwcmludCBtQXBuTGlzdCBvZiBBcG5Db250ZXh0J3Mgd2hpY2ggd291bGQgYmUgcmVjdXJzaXZlICovCisgICAgQE92ZXJyaWRlCisgICAgcHVibGljIFN0cmluZyB0b1N0cm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KyAgICAgICAgTWVzc2FnZSBtT25Db21wbGV0ZWRNc2c7CiAgICAgfQogCiAgICAgLyoqCiAgICAgICogVXNlZCBpbnRlcm5hbGx5IGZvciBzYXZpbmcgZGlzY29ubmVjdGluZyBwYXJhbWV0ZXJzLgogICAgICAqLwogICAgIHByb3RlY3RlZCBzdGF0aWMgY2xhc3MgRGlzY29ubmVjdFBhcmFtcyB7Ci0gICAgICAgIHB1YmxpYyBEaXNjb25uZWN0UGFyYW1zKFN0cmluZyByZWFzb24sIE1lc3NhZ2Ugb25Db21wbGV0ZWRNc2cpIHsKLSAgICAgICAgICAgIHRoaXMucmVhc29uID0gcmVhc29uOwotICAgICAgICAgICAgdGhpcy5vbkNvbXBsZXRlZE1zZyA9IG9uQ29tcGxldGVkTXNnOworICAgICAgICBEaXNjb25uZWN0UGFyYW1zKEFwbkNvbnRleHQgYXBuQ29udGV4dCwgU3RyaW5nIHJlYXNvbiwgTWVzc2FnZSBvbkNvbXBsZXRlZE1zZykgeworICAgICAgICAgICAgbUFwbkNvbnRleHQgPSBhcG5Db250ZXh0OworICAgICAgICAgICAgbVJlYXNvbiA9IHJlYXNvbjsKKyAgICAgICAgICAgIG1PbkNvbXBsZXRlZE1zZyA9IG9uQ29tcGxldGVkTXNnOwogICAgICAgICB9Ci0gICAgICAgIHB1YmxpYyBpbnQgdGFnOwotICAgICAgICBwdWJsaWMgU3RyaW5nIHJlYXNvbjsKLSAgICAgICAgcHVibGljIE1lc3NhZ2Ugb25Db21wbGV0ZWRNc2c7CisKKyAgICAgICAgaW50IG1UaGVUYWc7CisgICAgICAgIEFwbkNvbnRleHQgbUFwbkNvbnRleHQ7CisgICAgICAgIFN0cmluZyBtUmVhc29uOworICAgICAgICBNZXNzYWdlIG1PbkNvbXBsZXRlZE1zZzsKICAgICB9CiAKICAgICAvKioKQEAgLTE1Niw3ICsxNzAsNyBAQAogICAgICAgICAgICAgbUVycm9yQ29kZSA9IGVycm9yQ29kZTsKICAgICAgICAgfQogCi0g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WMgdm9pZCBnZXRFaVBhcmFtZXRlcnMoSW50ZW50IGludGVudCwgU3RyaW5nIHMpIHsKKyAgICAgICAgICAgIGlmIChEQkcpIHNEY0xvZyhzICsgIi5nZXRFaVBhcmFtZXRlcnM6IGFjdGlvbj0iICsgaW50ZW50LmdldEFjdGlvbigpKTsKKyAgICAgICAgICAgIGNvdW50ZXIgPSBpbnRlbnQuZ2V0SW50RXh0cmEoRmFpbEJyaW5nVXAuQ09VTlRFUiwKKyAgICAgICAgICAgICAgICAgICAgRmFpbEJyaW5nVXAuREVGQVVMVF9DT1VOVEVSKTsKKyAgICAgICAgICAgIGZhaWxDYXVzZSA9IEZhaWxDYXVzZS5mcm9tSW50KAorICAgICAgICAgICAgICAgICAgICBpbnRlbnQuZ2V0SW50RXh0cmEoRmFpbEJyaW5nVXAuRkFJTF9DQVVTRSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBGYWlsQnJpbmdVcC5ERUZBVUxUX0ZBSUxfQ0FVU0UuZ2V0RXJyb3JDb2RlKCkpKTsKKyAgICAgICAgICAgIHN1Z2dlc3RlZFJldHJ5VGltZSA9CisgICAgICAgICAgICAgICAgICAgIGludGVudC5nZXRJbnRFeHRyYShGYWlsQnJpbmdVcC5TVUdHRVNURURfUkVUUllfVElNRSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBGYWlsQnJpbmdVcC5ERUZBVUxUX1NVR0dFU1RFRF9SRVRSWV9USU1FKTsKKyAgICAgICAgICAgIGlmIChEQkcpIHsKKyAgICAgICAgICAgICAgICBzRGNMb2cocyArICIuZ2V0RWlQYXJhbWV0ZXJzOiAiICsgdGhpcyk7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKworICAgICAgICBAT3ZlcnJpZGUKKyAgICAgICAgcHVibGljIFN0cmluZyB0b1N0cmluZygpIHsKKyAgICAgICAgICAgIHJldHVybiAie2NvdW50ZXI9IiArIGNvdW50ZXIgKworICAgICAgICAgICAgICAgICAgICAiIGZhaWxDYXVz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gNTAwMAorICAgIHByb3RlY3RlZCBGYWlsQnJpbmdVcCBtRmFpbEJyaW5nVXAgPSBuZXcgRmFpbEJyaW5nVXAoKTsKKworICAgIHByb3RlY3RlZCBCcm9hZGNhc3RSZWNlaXZlciBtSW50ZW50UmVjZWl2ZXIgPSBuZXcgQnJvYWRjYXN0UmVjZWl2ZXIgKCkKKyAgICB7CisgICAgICAgIEBPdmVycmlkZQorICAgICAgICBwdWJsaWMgdm9pZCBvblJlY2VpdmUoQ29udGV4dCBjb250ZXh0LCBJbnRlbnQgaW50ZW50KQorICAgICAgICB7CisgICAgICAgICAgICBTdHJpbmcgYWN0aW9uID0gaW50ZW50LmdldEFjdGlvbigpOworICAgICAgICAgICAgaWYgKERCRykgbG9nKCJtSW50ZW50UmVjZWl2ZXIub25SZWNlaXZlOiBhY3Rpb249IiArIGFjdGlvbik7CisgICAgICAgICAgICBpZiAoREJHX0ZBSUxVUkUgJiYgYWN0aW9uLmVxdWFscyhtQWN0aW9uRmFpbEJyaW5nVXApKSB7CisgICAgICAgICAgICAgICAgbUZhaWxCcmluZ1VwLmdldEVpUGFyYW1ldGVycyhpbnRlbnQsICJtRmFpbEJyaW5nVXAiKTsKKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJvblJlY2VpdmU6IHVua25vd24gYWN0aW9uPSIgKyBhY3Rpb24pOworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgfTsKKworICAgIC8qKgorICAgICAqIERvIHRoZSBvbiBjb25uZWN0IG9yIGZha2UgaXQgaWYgYW4gZXJyb3IKKyAgICAgKi8KKyAgICBwcm90ZWN0ZWQgdm9pZCBkb09uQ29ubmVjdChDb25uZWN0aW9uUGFyYW1zIGNwKSB7CisgICAgICAgIC8vIENoZWNrIGlmIHdlIHNob3VsZCBmYWtlIGFuIGVycm9yLgorICAgICAgICBpZiAoc0ZhaWxCcmluZ1VwLmNvdW50ZXIgID4gMCkgeworICAgICAgICAgICAgRGF0YUNhbGxTdGF0ZSByZXNwb25zZSA9IG5ldyBEYXRhQ2FsbFN0YXRlKCk7CisgICAgICAgICAgICByZXNwb25zZS52ZXJzaW9uID0gbVBob25lLm1DaS5nZXRSaWxWZXJzaW9uKCk7CisgICAgICAgICAgICByZXNwb25zZS5zdGF0dXMgPSBzRmFpbEJyaW5nVXAuZmFpbENhdXNlLmdldEVycm9yQ29kZSgpOworICAgICAgICAgICAgcmVzcG9uc2UuY2lkID0gMDsKKyAgICAgICAgICAgIHJlc3BvbnNlLmFjdGl2ZSA9IDA7CisgICAgICAgICAgICByZXNwb25zZS50eXBlID0gIiI7CisgICAgICAgICAgICByZXNwb25zZS5pZm5hbWUgPSAiIjsKKyAgICAgICAgICAgIHJlc3BvbnNlLmFkZHJlc3NlcyA9IG5ldyBTdHJpbmdbMF07CisgICAgICAgICAgICByZXNwb25zZS5kbnNlcyA9IG5ldyBTdHJpbmdbMF07CisgICAgICAgICAgICByZXNwb25zZS5nYXRld2F5cyA9IG5ldyBTdHJpbmdbMF07CisgICAgICAgICAgICByZXNwb25zZS5zdWdnZXN0ZWRSZXRyeVRpbWUgPSBzRmFpbEJyaW5nVXAuc3VnZ2VzdGVkUmV0cnlUaW1lOworCisgICAgICAgICAgICBNZXNzYWdlIG1zZyA9IG9idGFpbk1lc3NhZ2UoRVZFTlRfU0VUVVBfREFUQV9DT05ORUNUSU9OX0RPTkUsIGNwKTsKKyAgICAgICAgICAgIEFzeW5jUmVzdWx0LmZvck1lc3NhZ2UobXNnLCByZXNwb25zZSwgbnVsbCk7CisgICAgICAgICAgICBzZW5kTWVzc2FnZShtc2cpOworICAgICAgICAgICAgaWYgKERCRykgeworICAgICAgICAgICAgICAgIGxvZygiZG9PbkNvbm5lY3Q6IHNGYWlsQnJpbmdVcC5jb3VudGVyPSIgKyBzRmFpbEJyaW5nVXAuY291bnRlciArCisgICAgICAgICAgICAgICAgICAgICAgICAiIHNlbmQgZXJyb3IgcmVzcG9uc2U9IiArIHJlc3BvbnNlKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIHNGYWlsQnJpbmdVcC5jb3VudGVyIC09IDE7CisgICAgICAgICAgICByZXR1cm47CisgICAgICAgIH0KKyAgICAgICAgaWYgKG1GYWlsQnJpbmdVcC5jb3VudGVyID4gMCkgeworICAgICAgICAgICAgRGF0YUNhbGxTdGF0ZSByZXNwb25zZSA9IG5ldyBEYXRhQ2FsbFN0YXRlKCk7CisgICAgICAgICAgICByZXNwb25zZS52ZXJzaW9uID0gbVBob25lLm1DaS5nZXRSaWxWZXJzaW9uKCk7CisgICAgICAgICAgICByZXNwb25zZS5zdGF0dXMgPSBtRmFpbEJyaW5nVXAuZmFpbENhdXNlLmdldEVycm9yQ29kZSgpOworICAgICAgICAgICAgcmVzcG9uc2UuY2lkID0gMDsKKyAgICAgICAgICAgIHJlc3BvbnNlLmFjdGl2ZSA9IDA7CisgICAgICAgICAgICByZXNwb25zZS50eXBlID0gIiI7CisgICAgICAgICAgICByZXNwb25zZS5pZm5hbWUgPSAiIjsKKyAgICAgICAgICAgIHJlc3BvbnNlLmFkZHJlc3NlcyA9IG5ldyBTdHJpbmdbMF07CisgICAgICAgICAgICByZXNwb25zZS5kbnNlcyA9IG5ldyBTdHJpbmdbMF07CisgICAgICAgICAgICByZXNwb25zZS5nYXRld2F5cyA9IG5ldyBTdHJpbmdbMF07CisgICAgICAgICAgICByZXNwb25zZS5zdWdnZXN0ZWRSZXRyeVRpbWUgPSBtRmFpbEJyaW5nVXAuc3VnZ2VzdGVkUmV0cnlUaW1lOworCisgICAgICAgICAgICBNZXNzYWdlIG1zZyA9IG9idGFpbk1lc3NhZ2UoRVZFTlRfU0VUVVBfREFUQV9DT05ORUNUSU9OX0RPTkUsIGNwKTsKKyAgICAgICAgICAgIEFzeW5jUmVzdWx0LmZvck1lc3NhZ2UobXNnLCByZXNwb25zZSwgbnVsbCk7CisgICAgICAgICAgICBzZW5kTWVzc2FnZShtc2cpOworICAgICAgICAgICAgaWYgKERCRykgeworICAgICAgICAgICAgICAgIGxvZygiZG9PbkNvbm5lY3Q6IG1GYWlsQnJpbmdVcC5jb3VudGVyPSIgKyBtRmFpbEJyaW5nVXAuY291bnRlciArCisgICAgICAgICAgICAgICAgICAgICAgICAiIHNlbmQgZXJyb3IgcmVzcG9uc2U9IiArIHJlc3BvbnNlKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIG1GYWlsQnJpbmdVcC5jb3VudGVyIC09IDE7CisgICAgICAgICAgICByZXR1cm47CisgICAgICAgIH0KKworICAgICAgICAvLyBFbHNlIGRvIHRoZSBub3JtYWwgb25Db25uZWN0aW9uCisgICAgICAgIG9uQ29ubmVjdChjcCk7CisgICAgfQorCiAgICAgcHVibGljIHN0YXRpYyBjbGFzcyBDYWxsU2V0dXBFeGNlcHRpb24gZXh0ZW5kcyBFeGNlcHRpb24gewogICAgICAgICBwcml2YXRlIGludCBtUmV0cnlPdmVycmlkZSA9IC0xOwogCkBAIC0yNDEsNDIgKzQyMiw2OSBAQAogICAgIC8vKioqKiogTWVtYmVyIFZhcmlhYmxlcwogICAgIHByb3RlY3RlZCBBcG5TZXR0aW5nIG1BcG47CiAgICAgcHJvdGVjdGVkIGludCBtVGFnOwotICAgIHByb3RlY3RlZCBQaG9uZUJhc2UgcGhvbmU7CisgICAgcHJvdGVjdGVkIFBob25lQmFzZSBtUGhvbmU7CiAgICAgcHJvdGVjdGVkIGludCBtUmlsVmVyc2lvbiA9IC0xOwotICAgIHByb3RlY3RlZCBpbnQgY2lkOworICAgIHByb3RlY3RlZCBpbnQgbUNpZDsKICAgICBwcm90ZWN0ZWQgTGlua1Byb3BlcnRpZXMgbUxpbmtQcm9wZXJ0aWVzID0gbmV3IExpbmtQcm9wZXJ0aWVzKCk7CiAgICAgcHJvdGVjdGVkIExpbmtDYXBhYmlsaXRpZXMgbUNhcGFiaWxpdGllcyA9IG5ldyBMaW5rQ2FwYWJpbGl0aWVzKCk7Ci0gICAgcHJvdGVjdGVk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N0cmluZyBuYW1lLCBpbnQgaWQsIFJldHJ5TWFuYWdlciBybSwKLSAgICAgICAgICAgIERhdGFDb25uZWN0aW9uVHJhY2tlciBkY3QpIHsKKyAgICBwcm90ZWN0ZWQgRGF0YUNvbm5lY3Rpb25CYXNlKFBob25lQmFzZSBwaG9uZSwgU3RyaW5nIG5hbWUsIGludCBpZCwgUmV0cnlNYW5hZ2VyIHJtLAorICAgICAgICAgICAgRGF0YUNvbm5lY3Rpb25UcmFja2VyQmFzZSBkY3QpIHsKICAgICAgICAgc3VwZXIobmFtZSk7Ci0gICAgICAgIHNldExvZ1JlY1NpemUoMTAwKTsKLSAgICAgICAgaWYgKERCRykgbG9nKCJEYXRhQ29ubmVjdGlvbiBjb25zdHJ1Y3RvciBFIik7Ci0gICAgICAgIHRoaXMucGhvbmUgPSBwaG9uZTsKLSAgICAgICAgdGhpcy5tRGF0YUNvbm5lY3Rpb25UcmFja2VyID0gZGN0OworICAgICAgICBzZXRMb2dSZWNTaXplKDMwMCk7CisgICAgICAgIHNldExvZ09ubHlUcmFuc2l0aW9ucyh0cnVlKTsKKyAgICAgICAgaWYgKERCRykgbG9nKCJEYXRhQ29ubmVjdGlvbkJhc2UgY29uc3RydWN0b3IgRSIpOworICAgICAgICBtUGhvbmUgPSBwaG9uZTsKKyAgICAgICAgbURhdGFDb25uZWN0aW9uVHJhY2tlciA9IGRjdDsKICAgICAgICAgbUlkID0gaWQ7CiAgICAgICAgIG1SZXRyeU1nciA9IHJtOwotICAgICAgICB0aGlzLmNpZCA9IC0xOworICAgICAgICBtQ2lkID0gLTE7CiAKLSAgICAgICAgc2V0RGJnKGZhbHNlKTsKKyAgICAgICAgaWYgKERCR19GQUlMVVJFKSB7CisgICAgICAgICAgICBJbnRlbnRGaWx0ZXIgZmlsdGVyOworCisgICAgICAgICAgICBzeW5jaHJvbml6ZWQgKERhdGFDb25uZWN0aW9uQmFzZS5jbGFzcykgeworICAgICAgICAgICAgICAgIC8vIFJlZ2lzdGVyIHRoZSBzdGF0aWMgSW50ZW50IHJlY2VpdmVyIG9uY2UKKyAgICAgICAgICAgICAgICBpZiAoc0FjdGlvbkZhaWxCcmluZ1VwID09IG51bGwpIHsKKyAgICAgICAgICAgICAgICAgICAgc0FjdGlvbkZhaWxCcmluZ1VwID0gSU5URU5UX0JBU0UgKyAiLkRDLiIgKworICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZhaWxCcmluZ1VwLkFDVElPTl9GQUlMX0JSSU5HVVA7CisKKyAgICAgICAgICAgICAgICAgICAgZmlsdGVyID0gbmV3IEludGVudEZpbHRlcigpOworICAgICAgICAgICAgICAgICAgICBmaWx0ZXIuYWRkQWN0aW9uKHNBY3Rpb25GYWlsQnJpbmdVcCk7CisgICAgICAgICAgICAgICAgICAgIHBob25lLmdldENvbnRleHQoKS5yZWdpc3RlclJlY2VpdmVyKHNJbnRlbnRSZWNlaXZlciwgZmlsdGVyLCBudWxsLCBwaG9uZSk7CisgICAgICAgICAgICAgICAgICAgIGxvZygiRGF0YUNvbm5lY3Rpb25CYXNlOiByZWdpc3RlciBzQWN0aW9uRmFpbEJyaW5nVXA9IiArIHNBY3Rpb25GYWlsQnJpbmdVcCk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfQorCisgICAgICAgICAgICAvLyBSZWdpc3RlciB0aGUgcGVyIGluc3RhbmNlIEludGVudCByZWNlaXZlcgorICAgICAgICAgICAgbUFjdGlvbkZhaWxCcmluZ1VwID0gSU5URU5UX0JBU0UgKyAiLiIgKyBnZXROYW1lKCkgKyAiLiIgKworICAgICAgICAgICAgICAgICAgICBGYWlsQnJpbmdVcC5BQ1RJT05fRkFJTF9CUklOR1VQOworICAgICAgICAgICAgZmlsdGVyID0gbmV3IEludGVudEZpbHRlcigpOworICAgICAgICAgICAgZmlsdGVyLmFkZEFjdGlvbihtQWN0aW9uRmFpbEJyaW5nVXApOworICAgICAgICAgICAgcGhvbmUuZ2V0Q29udGV4dCgpLnJlZ2lzdGVyUmVjZW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DYXVzZSA9IG51bGw7CisgICAgICAgIG1Vc2VyRGF0YSA9IG51bGw7CiAgICAgfQogCiAgICAgLyoqCkBAIC0zMjAsMTYgKzUyOCwxNiBAQAogICAgICAgICBpbnQgZGlzY1JlYXNvbiA9IFJJTENvbnN0YW50cy5ERUFDVElWQVRFX1JFQVNPTl9OT05FOwogICAgICAgICBpZiAoKG8gIT0gbnVsbCkgJiYgKG8gaW5zdGFuY2VvZiBEaXNjb25uZWN0UGFyYW1zKSkgewogICAgICAgICAgICAgRGlzY29ubmVjdFBhcmFtcyBkcCA9IChEaXNjb25uZWN0UGFyYW1zKW87Ci0gICAgICAgICAgICBNZXNzYWdlIG0gPSBkcC5vbkNvbXBsZXRlZE1zZzsKLSAgICAgICAgICAgIGlmIChUZXh0VXRpbHMuZXF1YWxzKGRwLnJlYXNvbiwgUGhvbmUuUkVBU09OX1JBRElPX1RVUk5FRF9PRkYpKSB7CisgICAgICAgICAgICBNZXNzYWdlIG0gPSBkcC5tT25Db21wbGV0ZWRNc2c7CisgICAgICAgICAgICBpZiAoVGV4dFV0aWxzLmVxdWFscyhkcC5tUmVhc29uLCBQaG9uZS5SRUFTT05fUkFESU9fVFVSTkVEX09GRikpIHsKICAgICAgICAgICAgICAgICBkaXNjUmVhc29uID0gUklMQ29uc3RhbnRzLkRFQUNUSVZBVEVfUkVBU09OX1JBRElPX09GRjsKLSAgICAgICAgICAgIH0gZWxzZSBpZiAoVGV4dFV0aWxzLmVxdWFscyhkcC5yZWFzb24sIFBob25lLlJFQVNPTl9QRFBfUkVTRVQpKSB7CisgICAgICAgICAgICB9IGVsc2UgaWYgKFRleHRVdGlscy5lcXVhbHMoZHAubVJlYXNvbiwgUGhvbmUuUkVBU09OX1BEUF9SRVNFVCkpIHsKICAgICAgICAgICAgICAgICBkaXNjUmVhc29uID0gUklMQ29uc3RhbnRzLkRFQUNUSVZBVEVfUkVBU09OX1BEUF9SRVNFVDsKICAgICAgICAgICAgIH0KICAgICAgICAgfQotICAgICA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AgICAgICAgIGlmIChjb25uZWN0aW9uQ29tcGxldGVkTXNnID09IG51bGwpIHsKICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgfQogCiAgICAgICAgIGxvbmcgdGltZVN0YW1wID0gU3lzdGVtLmN1cnJlbnRUaW1lTWlsbGlzKCk7Ci0gICAgICAgIGNvbm5lY3Rpb25Db21wbGV0ZWRNc2cuYXJnMSA9IGNpZDsKKyAgICAgICAgY29ubmVjdGlvbkNvbXBsZXRlZE1zZy5hcmcxID0gbUNpZDsKIAogICAgICAgICBpZiAoY2F1c2UgPT0gRmFpbENhdXNlLk5PTkUpIHsKLSAgICAgICAgICAgIGNyZWF0ZVRpbWUgPSB0aW1lU3RhbXA7CisgICAgICAgICAgICBtQ3JlYXRlVGltZSA9IHRpbWVTdGFtcDsKICAgICAgICAgICAgIEFzeW5jUmVzdWx0LmZvck1lc3NhZ2UoY29ubmVjdGlvbkNvbXBsZXRlZE1zZyk7CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICBsYXN0RmFpbENhdXNlID0gY2F1c2U7Ci0gICAgICAgICAgICBsYXN0RmFpbFRpbWUgPSB0aW1lU3RhbXA7CisgICAgICAgICAgICBtTGFzdEZhaWxDYXVzZSA9IGNhdXNlOworICAgICAgICAgICAgbUxhc3RGYWlsVGltZSA9IHRpbWVTdGFtcDsKICAgICAgICAgICAgIEFzeW5jUmVzdWx0LmZvck1lc3NhZ2UoY29ubmVjdGlvbkNvbXBsZXRlZE1zZywgY2F1c2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBDYWxsU2V0dXBFeGNlcHRpb24obVJldHJ5T3ZlcnJpZGUpKTsKICAgICAgICAgfQpAQCAtMzc3LDEzICs1ODUsMTMgQEAKICAgICAgICAgQXBuQ29udGV4dCBhbHJlYWR5U2VudCA9IG51bGw7CiAgICAgICAgIFN0cmluZyByZWFzb24gPSBudWxsOwogCi0gICAgICAgIGlmIChkcC5vbkNvbXBsZXRlZE1zZyAhPSBudWxsKSB7CisgICAgICAgIGlmIChkcC5tT25Db21wbGV0ZWRNc2cgIT0gbnVsbCkgewogICAgICAgICAgICAgLy8gR2V0IEFwbkNvbnRleHQsIGJ1dCBvbmx5IHZhbGlkIG9uIEdTTSBkZXZpY2VzIHRoaXMgaXMgYSBzdHJpbmcgb24gQ0RNQSBkZXZpY2VzLgotICAgICAgICAgICAgTWVzc2FnZSBtc2cgPSBkcC5vbkNvbXBsZXRlZE1zZzsKKyAgICAgICAgICAgIE1lc3NhZ2UgbXNnID0gZHAubU9uQ29tcGxldGVkTXNnOwogICAgICAgICAgICAgaWYgKG1zZy5vYmogaW5zdGFuY2VvZiBBcG5Db250ZXh0KSB7CiAgICAgICAgICAgICAgICAgYWxyZWFkeVNlbnQgPSAoQXBuQ29udGV4dCltc2cub2JqOwogICAgICAgICAgICAgfQotICAgICAgICAgICAgcmVhc29uID0gZHAucmVhc29uOworICAgICAgICAgICAgcmVhc29uID0gZHAubVJlYXNvbjsKICAgICAgICAgICAgIGlmIChWREJHKSB7CiAgICAgICAgICAgICAgICAgbG9nKFN0cmluZy5mb3JtYXQoIm1zZz0lcyBtc2cub2JqPSVzIiwgbXNnLnRvU3RyaW5nKCksCiAgICAgICAgICAgICAgICAgICAgICgobXNnLm9iaiBpbnN0YW5jZW9mIFN0cmluZykgPyAoU3RyaW5nKSBtc2cub2JqIDogIjxuby1yZWFzb24+IikpKTsKQEAgLTQwNSwxMiArNjEzLDEyIEBACiAgICAgICAgIGlmIChEQkcpIGxvZygiTm90aWZ5RGlzY29ubmVjdENvbXBsZXRlZCBEaXNjb25uZWN0UGFyYW1zPSIgKyBkcCk7CiAgICAgfQogCi0gICAgcHJvdGVjdGVkIGludCBnZXRSaWxSYWRpb1RlY2hub2xvZ3koaW50IGRlZmF1bHRSaWxSYWRpb1RlY2hub2xvZ3kpIHsKKyAgICBwcm90ZWN0ZWQgaW50IGdldFJpbFJhZGlvVGVjaG5vbG9neSgpIHsKICAgICAgICAgaW50IHJpbFJhZGlvVGVjaG5vbG9neTsKLSAgICAgICAgaWYgKG1SaWxWZXJzaW9uIDwgNikgewotICAgICAgICAgICAgcmlsUmFkaW9UZWNobm9sb2d5ID0gZGVmYXVsdFJpbFJhZGlvVGVjaG5vbG9neTsKKyAgICAgICAgaWYgKG1BcG4uYmVhcmVyID4gMCkgeworICAgICAgICAgICAgcmlsUmFkaW9UZWNobm9sb2d5ID0gbUFwbi5iZWFyZXIgKyAyOwogICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgcmlsUmFkaW9UZWNobm9sb2d5ID0gcGhvbmUuZ2V0U2VydmljZVN0YXRlKCkuZ2V0UmlsUmFkaW9UZWNobm9sb2d5KCkgKyAyOworICAgICAgICAgICAgcmlsUmFkaW9UZWNobm9sb2d5ID0gbVBob25lLmdldFNlcnZpY2VTdGF0ZSgpLmdldFJpbERhdGFSYWRpb1RlY2hub2xvZ3koKSArIDI7CiAgICAgICAgIH0KICAgICAgICAgcmV0dXJuIHJpbFJhZGlvVGVjaG5vbG9neTsKICAgICB9CkBAIC00MTgsNyArNjI2LDcgQEAKICAgICAvKgogICAgICAqICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCiAgICAgICogQmVnaW4gTWVtYmVycyBhbmQgbWV0aG9kcyBvd25lZCBieSBEYXRhQ29ubmVjdGlvblRyYWNrZXIgYnV0IHN0b3JlZAotICAgICAqIGluIGEgRGF0YUNvbm5lY3Rpb24gYmVjYXVzZSB0aGVyZSBpcyBvbmUgcGVyIGNvbm5lY3Rpb24uCisgICAgICogaW4gYSBEYXRhQ29ubmVjdGlvbkJhc2UgYmVjYXVzZSB0aGVyZSBpcyBvbmUgcGVyIGNvbm5lY3Rpb24uCiAgICAgICogKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKICAgICAgKi8KIAp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lckZvclJpbENvbm5lY3RlZChnZXRIYW5kbGVyKCksIEVWRU5UX1JJTF9DT05ORUNURUQsIG51bGwpOwogICAgICAgICB9CiAgICAgICAgIEBPdmVycmlkZQogICAgICAgICBwdWJsaWMgdm9pZCBleGl0KCkgewotICAgICAgICAgICAgcGhvbmUubUNNLnVucmVnaXN0ZXJGb3JSaWxDb25uZWN0ZWQoZ2V0SGFuZGxlcigpKTsKKyAgICAgICAgICAgIG1QaG9uZS5tQ2kudW5yZWdpc3RlckZvclJpbENvbm5lY3RlZChnZXRIYW5kbGVyKCkpOwogICAgICAgICAgICAgc2h1dERvd24oKTsKICAgICAgICAgfQogICAgICAgICBAT3ZlcnJpZGUKQEAgLTY1OCw2ICs4NjYsMTAgQEAKICAgICAgICAgICAgIGJvb2xlYW4gcmV0VmFsID0gSEFORExFRDsKICAgICAgICAgICAgIEFzeW5jUmVzdWx0IGFyOwogCisgICAgICAgICAgICBpZiAoVkRCRykgeworICAgICAgICAgICAgICAgIGxvZygiRGNEZWZhdWx0IG1zZz0weCIgKyBJbnRlZ2VyLnRvSGV4U3RyaW5nKG1zZy53aGF0KQorICAgICAgICAgICAgICAgICAgICAgICAgKyAiIFJlZkNvdW50PSIgKyBtQXBuTGlzdC5zaXplKCkpOworICAgICAgICAgICAgfQogICAgICAgICAgICAgc3dpdGNoIChtc2cud2hhdCkgewogICAgICAgICAgICAgICAgIGNhc2UgQXN5bmNDaGFubmVsLkNNRF9DSEFOTkVMX0ZVTExfQ09OTkVDVElPTjogewogICAgICAgICAgICAgICAgICAgICBpZiAobUFjICE9IG51bGwpIHsKQEAgLTY4NSw4ICs4OTcsOCBAQAogICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgY2FzZSBEYXRhQ29ubmVjdGlvbkFjLlJFUV9HRVRfQ0lEOiB7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChWREJHKSBsb2coIlJFUV9HRVRfQ0lEICBjaWQ9IiArIGNpZCk7Ci0gICAgICAgICAgICAgICAgICAgIG1BYy5yZXBseVRvTWVzc2FnZShtc2csIERhdGFDb25uZWN0aW9uQWMuUlNQX0dFVF9DSUQsIGNpZCk7CisgICAgICAgICAgICAgICAgICAgIGlmIChWREJHKSBsb2coIlJFUV9HRVRfQ0lEICBjaWQ9IiArIG1DaWQpOworICAgICAgICAgICAgICAgICAgICBtQWMucmVwbHlUb01lc3NhZ2UobXNnLCBEYXRhQ29ubmVjdGlvbkFjLlJTUF9HRVRfQ0lELCBtQ2lkKTsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIGNhc2UgRGF0YUNvbm5lY3Rpb25BYy5SRVFfR0VUX0FQTlNFVFRJTkc6IHsKQEAgLTczMiwyNCArOTQ0LDggQEAKICAgICAgICAgICAgICAgICAgICAgdHJhbnNpdGlvblRvKG1JbmFjdGl2ZVN0YXRlKTsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgY2FzZSBEYXRhQ29ubmVjdGlvbkFjLlJFUV9HRVRfUkVGQ09VTlQ6IHsKLSAgICAgICAgICAgICAgICAgICAgaWYgKFZEQkcpIGxvZygiUkVRX0dFVF9SRUZDT1VOVCAgcmVmQ291bnQ9IiArIG1SZWZDb3VudCk7Ci0gICAgICAgICAgICAgICAgICAgIG1BYy5yZXBseVRvTWVzc2FnZShtc2csIERhdGFDb25uZWN0aW9uQWMuUlNQX0dFVF9SRUZDT1VOVCwgbVJlZkNvdW50KTsKLSAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIGNhc2UgRGF0YUNvbm5lY3Rpb25BYy5SRVFfQUREX0FQTkNPTlRFWFQ6IHsKLSAgICAgICAgICAgICAgICAgICAgQXBuQ29udGV4dCBhcG5Db250ZXh0ID0gKEFwbkNvbnRleHQpIG1zZy5vYmo7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChWREJHKSBsb2coIlJFUV9BRERfQVBOQ09OVEVYVCBhcG49IiArIGFwbkNvbnRleHQuZ2V0QXBuVHlwZSgpKTsKLSAgICAgICAgICAgICAgICAgICAgaWYgKCFtQXBuTGlzdC5jb250YWlucyhhcG5Db250ZXh0KSkgewotICAgICAgICAgICAgICAgICAgICAgICAgbUFwbkxpc3QuYWRkKGFwbkNvbnRleHQpOwotICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgIG1BYy5yZXBseVRvTWVzc2FnZShtc2csIERhdGFDb25uZWN0aW9uQWMuUlNQX0FERF9BUE5DT05URVhUKTsKLSAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIGNhc2UgRGF0YUNvbm5lY3Rpb25BYy5SRVFfUkVNT1ZFX0FQTkNPTlRFWFQ6IHsKLSAgICAgICAgICAgICAgICAgICAgQXBuQ29udGV4dCBhcG5Db250ZXh0ID0gKEFwbkNvbnRleHQpIG1zZy5vYmo7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChWREJHKSBsb2coIlJFUV9SRU1PVkVfQVBOQ09OVEVYVCBhcG49IiArIGFwbkNvbnRleHQuZ2V0QXBuVHlwZSgpKTsKLSAgICAgICAgICAgICAgICAgICAgbUFwbkxpc3QucmVtb3ZlKGFwbkNvbnRleHQpOwotICAgICAgICAgICAgICAgICAgICBtQWMucmVwbHlUb01lc3NhZ2UobXNnLCBEYXRhQ29ubmVjdGlvbkFjLlJTUF9SRU1PVkVfQVBOQ09OVEVYVCk7CisgICAgICAgICAgICAgICAgICAgIGlmIChWREJHKSBsb2coIlJFUV9HRVRfUkVGQ09VTlQgIFJlZkNvdW50PSIgKyBtQXBuTGlzdC5zaXplKCkpOworICAgICAgICAgICAgICAgICAgICBtQWMucmVwbHlUb01lc3NhZ2UobXNnLCBEYXRhQ29ubmVjdGlvbkFjLlJTUF9HRVRfUkVGQ09VTlQsIG1BcG5MaXN0LnNpemUoKSk7CiAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBjYXNlIERhdGFDb25uZWN0aW9uQWMuUkVRX0dFVF9BUE5DT05URVhUX0xJU1Q6IHsKQEAgLTc3OSwxNCArOTc1LDE2IEBACiAKICAgICAgICAgICAgICAgICBjYXNlIEVWRU5UX0RJU0NPTk5FQ1Q6CiAgICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGxvZygiRGNEZWZhdWx0U3RhdGUgZGVmZXJyaW5nIG1zZy53aGF0PUVWRU5UX0RJU0NPTk5FQ1QiICsgbVJlZkNvdW50KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGxvZygiRGNEZWZhdWx0U3RhdGUgZGVmZXJyaW5nIG1zZy53aGF0PUVWRU5UX0RJU0NPTk5FQ1QgUmVmQ291bnQ9IgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArIG1BcG5MaXN0LnNpemUoKSk7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgZGVmZXJNZXNzYWdlKG1zZyk7CiAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogCiAgICAgICAgICAgICAgICAgY2FzZSBFVkVOVF9ESVNDT05ORUNUX0FMTDoKICAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgewotICAgICAgICAgICAgICAgICAgICAgICAgbG9nKCJEY0RlZmF1bHRTdGF0ZSBkZWZlcnJpbmcgbXNnLndoYXQ9RVZFTlRfRElTQ09OTkVDVF9BTEwiICsgbVJlZkNvdW50KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGxvZygiRGNEZWZhdWx0U3RhdGUgZGVmZXJyaW5nIG1zZy53aGF0PUVWRU5UX0RJU0NPTk5FQ1RfQUxMIFJlZkNvdW50PSIKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyBtQXBuTGlzdC5zaXplKCkpOwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIGRlZmVyTWVzc2FnZShtc2cpOwogICAgICAgICAgICAgICAgICAgICBicmVhazsKQEAgLTg4NCwxMyArMTA4MiwxMyBAQAogCiAgICAgICAgICAgICAgICAgY2FzZSBFVkVOVF9DT05ORUNUOgogICAgICAgICAgICAgICAgICAgICBDb25uZWN0aW9uUGFyYW1zIGNwID0gKENvbm5lY3Rpb25QYXJhbXMpIG1zZy5vYmo7Ci0gICAgICAgICAgICAgICAgICAgIGNwLnRhZyA9IG1UYWc7CisgICAgICAgICAgICAgICAgICAgIG1BcG5MaXN0LmFkZChjcC5tQXBuQ29udGV4dCk7CisgICAgICAgICAgICAgICAgICAgIGNwLm1UaGVUYWcgPSBtVGFnOwogICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBsb2coIkRjSW5hY3RpdmVTdGF0ZSBtc2cud2hhdD1FVkVOVF9DT05ORUNULiIgKyAiUmVmQ291bnQgPSAiCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgbVJlZkNvdW50KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGxvZygiRGNJbmFjdGl2ZVN0YXRlIG1zZy53aGF0PUVWRU5UX0NPTk5FQ1QgIiArICJSZWZDb3VudD0iCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgbUFwbkxpc3Quc2l6ZSgpKTsKICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBtUmVmQ291bnQgPSAxOwotICAgICAgICAgICAgICAgICAgICBvbkNvbm5lY3QoY3ApOworICAgICAgICAgICAgICAgICAgICBkb09uQ29ubmVjdChjcCk7CiAgICAgICAgICAgICAgICAgICAgIHRyYW5zaXRpb25UbyhtQWN0aXZhdGluZ1N0YXRlKTsKICAgICAgICAgICAgICAgICAgICAgcmV0VmFsID0gSEFORExFRDsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CkBAIC05MzIsMTQgKzExMzAsMTkgQEAKIAogICAgICAgICAgICAgc3dpdGNoIChtc2cud2hhdCkgewogICAgICAgICAgICAgICAgIGNhc2UgRVZFTlRfQ09OTkVDVDoKLSAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJEY0FjdGl2YXRpbmdTdGF0ZSBkZWZlcnJpbmcgbXNnLndoYXQ9RVZFTlRfQ09OTkVDVCByZWZDb3VudCA9ICIKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICArIG1SZWZDb3VudCk7CisgICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGxvZygiRGNBY3RpdmF0aW5nU3RhdGUgZGVmZXJyaW5nIG1zZy53aGF0PUVWRU5UX0NPTk5FQ1QgUmVmQ291bnQ9IgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArIG1BcG5MaXN0LnNpemUoKSk7CisgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgZGVmZXJNZXNzYWdlKG1zZyk7CiAgICAgICAgICAgICAgICAgICAgIHJldFZhbCA9IEhBTkRMRUQ7CiAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogCiAgICAgICAgICAgICAgICAgY2FzZSBFVkVOVF9TRVRVUF9EQVRBX0NPTk5FQ1RJT05fRE9ORToKLSAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJEY0FjdGl2YXRpbmdTdGF0ZSBtc2cud2hhdD1FVkVOVF9TRVRVUF9EQVRBX0NPTk5FQ1RJT05fRE9ORSIpOworICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBsb2coIkRjQWN0aXZhdGluZ1N0YXRlIG1zZy53aGF0PUVWRU5UX1NFVFVQX0RBVEFfQ09OTkVDVElPTl9ET05FIgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArICIgUmVmQ291bnQ9IiArIG1BcG5MaXN0LnNpemUoKSk7CisgICAgICAgICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgICAgICAgICBhciA9IChBc3luY1Jlc3VsdCkgbXNnLm9iajsKICAgICAgICAgICAgICAgICAgICAgY3AgPSAoQ29ubmVjdGlvblBhcmFtcykgYXIudXNlck9iajsKQEAgLTk2Niw3ICsxMTY5LDcgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgRVJSX0dldExhc3RFcnJvckZyb21SaWw6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gUmVxdWVzdCBmYWlsZWQgYW5kIHRoaXMgaXMgYW4gb2xkIFJJTAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBob25lLm1DTS5nZXRMYXN0RGF0YUNhbGxGYWlsQ2F1c2UoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbVBob25lLm1DaS5nZXRMYXN0RGF0YUNhbGxGYWlsQ2F1c2UoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX0dFVF9MQVNUX0ZBSUxfRE9ORSwgY3ApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgRVJSX1JpbEVycm9yOgpAQCAtOTg5LDggKzExOTIsMTEgQEAKICAgICAgICAgICAgICAgICAgICAgY3AgPSAoQ29ubmVjdGlvblBhcmFtcykgYXIudXNlck9iajsKICAgICAgICAgICAgICAgICAgICAgRmFpbENhdXNlIGNhdXNlID0gRmFpbENhdXNlLlVOS05PV047CiAKLSAgICAgICAgICAgICAgICAgICAgaWYgKGNwLnRhZyA9PSBtVGFnKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coIkRjQWN0aXZhdGluZ1N0YXRlIG1zZy53aGF0PUVWRU5UX0dFVF9MQVNUX0ZBSUxfRE9ORSIpOworICAgICAgICAgICAgICAgICAgICBpZiAoY3AubVRoZVRhZyA9PSBtVGFnKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9nKCJEY0FjdGl2YXRpbmdTdGF0ZSBtc2cud2hhdD1FVkVOVF9HRVRfTEFTVF9GQUlMX0RPTkUiCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArICIgUmVmQ291bnQ9IiArIG1BcG5MaXN0LnNpemUoKSk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYXIuZXhjZXB0aW9uID09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgcmlsRmFpbENhdXNlID0gKChpbnRbXSkgKGFyLnJlc3VsdCkpWzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhdXNlID0gRmFpbENhdXNlLmZyb21JbnQocmlsRmFpbENhdXNlKTsKQEAgLTEwMDIsNyArMTIwOCw3IEBACiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9nKCJEY0FjdGl2YXRpbmdTdGF0ZSBFVkVOVF9HRVRfTEFTVF9GQUlMX0RPTkUgaXMgc3RhbGUgY3AudGFnPSIKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyBjcC50YWcgKyAiLCBtVGFnPSIgKyBtVGFnKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyBjcC5tVGhlVGFnICsgIiwgbVRhZz0iICsgbVRhZyArICIgUmVmQ291bnQ9IiArIG1BcG5MaXN0LnNpemUoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIH0KIApAQCAtMTAxMiw3ICsxMjE4LDcgQEAKICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICBpZiAoVkRCRykgewogICAgICAgICAgICAgICAgICAgICAgICAgbG9nKCJEY0FjdGl2YXRpbmdTdGF0ZSBub3QgaGFuZGxlZCBtc2cud2hhdD0weCIgKwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbnRlZ2VyLnRvSGV4U3RyaW5nKG1zZy53aGF0KSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEludGVnZXIudG9IZXhTdHJpbmcobXNnLndoYXQpICsgIiBSZWZDb3VudD0iICsgbUFwbkxpc3Quc2l6ZSgpKTsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICByZXRWYWwgPSBOT1RfSEFORExFRDsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CkBAIC0xMDYxLDQzICsxMjY3LDU5IEBACiAgICAgICAgICAgICBib29sZWFuIHJldFZhbDsKIAogICAgICAgICAgICAgc3dpdGNoIChtc2cud2hhdCkgewotICAgICAgICAgICAgICAgIGNhc2UgRVZFTlRfQ09OTkVDVDoKLSAgICAgICAgICAgICAgICAgICAgbVJlZkNvdW50Kys7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygiRGNBY3RpdmVTdGF0ZSBtc2cud2hhdD1FVkVOVF9DT05ORUNUIFJlZkNvdW50PSIgKyBtUmVmQ291bnQpOwotICAgICAgICAgICAgICAgICAgICBpZiAobXNnLm9iaiAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBub3RpZnlDb25uZWN0Q29tcGxldGVkKChDb25uZWN0aW9uUGFyYW1zKSBtc2cub2JqLCBGYWlsQ2F1c2UuTk9ORSk7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgcmV0VmFsID0gSEFORExFRDsKLSAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgY2FzZSBFVkVOVF9ESVNDT05ORUNUOgotICAgICAgICAgICAgICAgICAgICBtUmVmQ291bnQtLTsKLSAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJEY0FjdGl2ZVN0YXRlIG1zZy53aGF0PUVWRU5UX0RJU0NPTk5FQ1QgUmVmQ291bnQ9IiArIG1SZWZDb3VudCk7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChtUmVmQ291bnQgPT0gMCkKLSAgICAgICAgICAgICAgICAgICAgewotICAgICAgICAgICAgICAgICAgICAgICAgRGlzY29ubmVjdFBhcmFtcyBkcCA9IChEaXNjb25uZWN0UGFyYW1zKSBtc2cub2JqOwotICAgICAgICAgICAgICAgICAgICAgICAgZHAudGFnID0gbVRhZzsKLSAgICAgICAgICAgICAgICAgICAgICAgIHRlYXJEb3duRGF0YShkcCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2l0aW9uVG8obURpc2Nvbm5lY3RpbmdTdGF0ZSk7CisgICAgICAgICAgICAgICAgY2FzZSBFVkVOVF9DT05ORUNUOiB7CisgICAgICAgICAgICAgICAgICAgIENvbm5lY3Rpb25QYXJhbXMgY3AgPSAoQ29ubmVjdGlvblBhcmFtcykgbXNnLm9iajsKKyAgICAgICAgICAgICAgICAgICAgaWYgKG1BcG5MaXN0LmNvbnRhaW5zKGNwLm1BcG5Db250ZXh0KSkgeworICAgICAgICAgICAgICAgICAgICAgICAgbG9nKCJEY0FjdGl2ZVN0YXRlIEVSUk9SIGFscmVhZHkgYWRkZWQgYXBuQ29udGV4dD0iICsgY3AubUFwbkNvbnRleHQKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgIiB0byB0aGlzIERDPSIgKyB0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtc2cub2JqICE9IG51bGwpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBub3RpZnlEaXNjb25uZWN0Q29tcGxldGVkKChEaXNjb25uZWN0UGFyYW1zKSBtc2cub2JqLCBmYWxzZSk7CisgICAgICAgICAgICAgICAgICAgICAgICBtQXBuTGlzdC5hZGQoY3AubUFwbkNvbnRleHQpOworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvZygiRGNBY3RpdmVTdGF0ZSBtc2cud2hhdD1FVkVOVF9DT05ORUNUIFJlZkNvdW50PSIgKyBtQXBuTGlzdC5zaXplKCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIG5vdGlmeUNvbm5lY3RDb21wbGV0ZWQoY3AsIEZhaWxDYXVzZS5OT05FKTsKICAgICAgICAgICAgICAgICAgICAgcmV0VmFsID0gSEFORExFRDsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0KLSAgICAgICAgICAgICAgICBjYXNlIEVWRU5UX0RJU0NPTk5FQ1RfQUxMOgotICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBsb2coIkRjQWN0aXZlU3RhdGUgbXNnLndoYXQ9RVZFTlRfRElTQ09OTkVDVF9BTEwgUmVmQ291bnQ9IiArIG1SZWZDb3VudCk7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgbVJlZkNvdW50ID0gMDsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgY2FzZSBFVkVOVF9ESVNDT05ORUNUOiB7CiAgICAgICAgICAgICAgICAgICAgIERpc2Nvbm5lY3RQYXJhbXMgZHAgPSAoRGlzY29ubmVjdFBhcmFtcykgbXNnLm9iajsKLSAgICAgICAgICAgICAgICAgICAgZHAudGFnID0gbVRhZzsKKyAgICAgICAgICAgICAgICAgICAgaWYgKG1BcG5MaXN0LmNvbnRhaW5zKGRwLm1BcG5Db250ZXh0KSkgeworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvZygiRGNBY3RpdmVTdGF0ZSBtc2cud2hhdD1FVkVOVF9ESVNDT05ORUNUIFJlZkNvdW50PSIKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgbUFwbkxpc3Quc2l6ZSgpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1BcG5MaXN0LnNpemUoKSA9PSAxKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUFwbkxpc3QuY2xlYXIoKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBkcC5tVGhlVGFnID0gbVRhZzsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZWFyRG93bkRhdGEoZHApOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zaXRpb25UbyhtRGlzY29ubmVjdGluZ1N0YXRlKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUFwbkxpc3QucmVtb3ZlKGRwLm1BcG5Db250ZXh0KTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBub3RpZnlEaXNjb25uZWN0Q29tcGxldGVkKGRwLCBmYWxzZSk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgICAgICAgICBsb2coIkRjQWN0aXZlU3RhdGUgRVJST1Igbm8gc3VjaCBhcG5Db250ZXh0PSIgKyBkcC5tQXBuQ29udGV4dAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArICIgaW4gdGhpcyBEQz0iICsgdGhpcyk7CisgICAgICAgICAgICAgICAgICAgICAgICBub3RpZnlEaXNjb25uZWN0Q29tcGxldGVkKGRwLCBmYWxzZSk7CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgcmV0VmFsID0gSEFORExFRDsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGNhc2UgRVZFTlRfRElTQ09OTkVDVF9BTEw6IHsKKyAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgeworICAgICAgICAgICAgICAgICAgICAgICAgbG9nKCJEY0FjdGl2ZVN0YXRlIG1zZy53aGF0PUVWRU5UX0RJU0NPTk5FQ1RfQUxMIFJlZkNvdW50PSIKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyBtQXBuTGlzdC5zaXplKCkgKyAiIGNsZWFyaW5nIGFwbiBjb250ZXh0cyIpOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIG1BcG5MaXN0LmNsZWFyKCk7CisgICAgICAgICAgICAgICAgICAgIERpc2Nvbm5lY3RQYXJhbXMgZHAgPSAoRGlzY29ubmVjdFBhcmFtcykgbXNnLm9iajsKKyAgICAgICAgICAgICAgICAgICAgZHAubVRoZVRhZyA9IG1UYWc7CiAgICAgICAgICAgICAgICAgICAgIHRlYXJEb3duRGF0YShkcCk7CiAgICAgICAgICAgICAgICAgICAgIHRyYW5zaXRpb25UbyhtRGlzY29ubmVjdGluZ1N0YXRlKTsKICAgICAgICAgICAgICAgICAgICAgcmV0VmFsID0gSEFORExFRDsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0KKyAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgaWYgKFZEQkcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIGxvZygiRGNBY3RpdmVTdGF0ZSBub3QgaGFuZGxlZCBtc2cud2hhdD0weCIgKwpAQCAtMTEyMiwyMyArMTM0NCwyNCBAQAogICAgICAgICAgICAgc3dpdGNoIChtc2cud2hhdCkgewogICAgICAgICAgICAgICAgIGNhc2UgRVZFTlRfQ09OTkVDVDoKICAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJEY0Rpc2Nvbm5lY3RpbmdTdGF0ZSBtc2cud2hhdD1FVkVOVF9DT05ORUNULiBEZWZlci4gUmVmQ291bnQgPSAiCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgKyBtUmVmQ291bnQpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgbUFwbkxpc3Quc2l6ZSgpKTsKICAgICAgICAgICAgICAgICAgICAgZGVmZXJNZXNzYWdlKG1zZyk7CiAgICAgICAgICAgICAgICAgICAgIHJldFZhbCA9IEhBTkRMRUQ7CiAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogCiAgICAgICAgICAgICAgICAgY2FzZSBFVkVOVF9ERUFDVElWQVRFX0RPTkU6Ci0gICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygiRGNEaXNjb25uZWN0aW5nU3RhdGUgbXNnLndoYXQ9RVZFTlRfREVBQ1RJVkFURV9ET05FIik7CisgICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygiRGNEaXNjb25uZWN0aW5nU3RhdGUgbXNnLndoYXQ9RVZFTlRfREVBQ1RJVkFURV9ET05FIFJlZkNvdW50PSIKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICArIG1BcG5MaXN0LnNpemUoKSk7CiAgICAgICAgICAgICAgICAgICAgIEFzeW5jUmVzdWx0IGFyID0gKEFzeW5jUmVzdWx0KSBtc2cub2JqOwogICAgICAgICAgICAgICAgICAgICBEaXNjb25uZWN0UGFyYW1zIGRwID0gKERpc2Nvbm5lY3RQYXJhbXMpIGFyLnVzZXJPYmo7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChkcC50YWcgPT0gbVRhZykgeworICAgICAgICAgICAgICAgICAgICBpZiAoZHAubVRoZVRhZyA9PSBtVGFnKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBUcmFuc2l0aW9uIHRvIGluYWN0aXZlIGJ1dCBzZW5kIG5vdGlmaWNhdGlvbnMgYWZ0ZXIKICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHdlJ3ZlIGVudGVyZWQgdGhlIG1JbmFjdGl2ZSBzdGF0ZS4KICAgICAgICAgICAgICAgICAgICAgICAgIG1JbmFjdGl2ZVN0YXRlLnNldEVudGVyTm90aWZpY2F0aW9uUGFyYW1zKChEaXNjb25uZWN0UGFyYW1zKSBhci51c2VyT2JqKTsKICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zaXRpb25UbyhtSW5hY3RpdmVTdGF0ZSk7CiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coIkRjRGlzY29ubmVjdFN0YXRlIEVWRU5UX0RFQUNUSVZBVEVfRE9ORSBzdGFsZSBkcC50YWc9IgotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArIGRwLnRhZyArICIgbVRhZz0iICsgbVRhZyk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgZHAubVRoZVRhZyArICIgbVRhZz0iICsgbVRhZyk7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgcmV0VmFsID0gSEFORExFRDsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CkBAIC0xMTY4LDcgKzEzOTEsNyBAQAogICAgICAgICAgICAgICAgIGNhc2UgRVZFTlRfREVBQ1RJVkFURV9ET05FOgogICAgICAgICAgICAgICAgICAgICBBc3luY1Jlc3VsdCBhciA9IChBc3luY1Jlc3VsdCkgbXNnLm9iajsKICAgICAgICAgICAgICAgICAgICAgQ29ubmVjdGlvblBhcmFtcyBjcCA9IChDb25uZWN0aW9uUGFyYW1zKSBhci51c2VyT2JqOwotICAgICAgICAgICAgICAgICAgICBpZiAoY3AudGFnID09IG1UYWcpIHsKKyAgICAgICAgICAgICAgICAgICAgaWYgKGNwLm1UaGVUYWcgPT0gbVRhZykgewogICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvZygiRGNEaXNjb25uZWN0aW9uRXJyb3JDcmVhdGluZ0Nvbm5lY3Rpb24iICsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIiBtc2cud2hhdD1FVkVOVF9ERUFDVElWQVRFX0RPTkUiKTsKQEAgLTExODIsNyArMTQwNSw3IEBACiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9nKCJEY0Rpc2Nvbm5lY3Rpb25FcnJvckNyZWF0aW5nQ29ubmVjdGlvbiBFVkVOVF9ERUFDVElWQVRFX0RPTkUiICsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICIgc3RhbGUgZHAudGFnPSIgKyBjcC50YWcgKyAiLCBtVGFnPSIgKyBtVGFnKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICIgc3RhbGUgZHAudGFnPSIgKyBjcC5tVGhlVGFnICsgIiwgbVRhZz0iICsgbVRhZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgcmV0VmFsID0gSEFORExFRDsKQEAgLTEyMDksMTMgKzE0MzIsMTQgQEAKICAgICAgKiBVc2VkIGZvciBjZWxsdWxhciBuZXR3b3JrcyB0aGF0IHVzZSBBY2Vzc3MgUG9pbnQgTmFtZXMgKEFQTikgc3VjaAogICAgICAqIGFzIEdTTSBuZXR3b3Jrcy4KICAgICAgKgorICAgICAqIEBwYXJhbSBhcG5Db250ZXh0IGlzIHRoZSBBY2Nlc3MgUG9pbnQg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zZy5vYmouCiAgICAgICovCiAgICAgcHVibGljIHZvaWQgdGVhckRvd25BbGwoU3RyaW5nIHJlYXNvbiwgTWVzc2FnZSBvbkNvbXBsZXRlZE1zZykgeworICAgICAgICBpZiAoREJHKSBsb2coInRlYXJEb3duQWxsOiByZWFzb249IiArIHJlYXNvbiArICIgb25Db21wbGV0ZWRNc2c9IiArIG9uQ29tcGxldGVkTXNnKTsKICAgICAgICAgc2VuZE1lc3NhZ2Uob2J0YWluTWVzc2FnZShFVkVOVF9ESVNDT05ORUNUX0FMTCwKLSAgICAgICAgICAgICAgICBuZXcgRGlzY29ubmVjdFBhcmFtcyhyZWFzb24sIG9uQ29tcGxldGVkTXNnKSkpOworICAgICAgICAgICAgICAgIG5ldyBEaXNjb25uZWN0UGFyYW1zKG51bGwsIHJlYXNvbiwgb25Db21wbGV0ZWRNc2cpKSk7CiAgICAgfQogCiAgICAgLyoqCkBAIC0xMjYyLDI4ICsxNDkyLDI4IEBACiAgICAgICovCiAgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgZHVtcChGaWxlRGVzY3JpcHRvciBmZCwgUHJpbnRXcml0ZXIgcHcsIFN0cmluZ1tdIGFyZ3MpIHsKLSAgICAgICAgcHcucHJpbnQoIkRhdGFDb25uZWN0aW9uICIpOworICAgICAgICBwdy5wcmludCgiRGF0YUNvbm5lY3Rpb25CYXNlICIpOwogICAgICAgICBzdXBlci5kdW1wKGZkLCBwdywgYXJncyk7Ci0gICAgICAgIHB3LnByaW50bG4oIiBtQXBuTGlzdD0iICsgbUFwbkxpc3QpOworICAgICAgICBwdy5wcmludGxuKCIgbUFwbkNvbnRleHRzLnNpemU9IiArIG1BcG5MaXN0LnNpemUoKSk7CisgICAgICAgIHB3LnByaW50bG4oIiBtQXBuQ29udGV4dHM9IiArIG1BcG5MaXN0KTsKICAgICAgICAgcHcuZmx1c2goKTsKICAgICAgICAgcHcucHJpbnRsbigiIG1EYXRhQ29ubmVjdGlvblRyYWNrZXI9IiArIG1EYXRhQ29ubmVjdGlvblRyYWNrZXIpOwogICAgICAgICBwdy5wcmludGxuKCIgbUFwbj0iICsgbUFwbik7CiAgICAgICAgIHB3LnByaW50bG4oIiBtVGFnPSIgKyBtVGFnKTsKICAgICAgICAgcHcuZmx1c2goKTsKLSAgICAgICAgcHcucHJpbnRsbigiIHBob25lPSIgKyBwaG9uZSk7CisgICAgICAgIHB3LnByaW50bG4oIiBtUGhvbmU9IiArIG1QaG9uZSk7CiAgICAgICAgIHB3LnByaW50bG4oIiBtUmlsVmVyc2lvbj0iICsgbVJpbFZlcnNpb24pOwotICAgICAgICBwdy5wcmludGxuKCIgY2lkPSIgKyBjaWQpOworICAgICAgICBwdy5wcmludGxuKCIgbUNpZD0iICsgbUNpZCk7CiAgICAgICAgIHB3LmZsdXNoKCk7CiAgICAgICAgIHB3LnByaW50bG4oIiBtTGlua1Byb3BlcnRpZXM9IiArIG1MaW5rUHJvcGVydGllcyk7CiAgICAgICAgIHB3LmZsdXNoKCk7CiAgICAgICAgIHB3LnByaW50bG4oIiBtQ2FwYWJpbGl0aWVzPSIgKyBtQ2FwYWJpbGl0aWVzKTsKLSAgICAgICAgcHcucHJpbnRsbigiIGNyZWF0ZVRpbWU9IiArIFRpbWVVdGlscy5sb2dUaW1lT2ZEYXkoY3JlYXRlVGltZSkpOwotICAgICAgICBwdy5wcmludGxuKCIgbGFzdEZhaWxUaW1lPSIgKyBUaW1lVXRpbHMubG9nVGltZU9mRGF5KGxhc3RGYWlsVGltZSkpOwotICAgICAgICBwdy5wcmludGxuKCIgbGFzdEZhaWxDYXVzZT0iICsgbGFzdEZhaWxDYXVzZSk7CisgICAgICAgIHB3LnByaW50bG4oIiBtQ3JlYXRlVGltZT0iICsgVGltZVV0aWxzLmxvZ1RpbWVPZkRheShtQ3JlYXRlVGltZSkpOworICAgICAgICBwdy5wcmludGxuKCIgbUxhc3RGYWlsVGltZT0iICsgVGltZVV0aWxzLmxvZ1RpbWVPZkRheShtTGFzdEZhaW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lYXNvbj0iICsgcmVhc29uICsKLSAgICAgICAgICAgICAgICAgICAgIiBjb25uZWN0aW9uSWQ9IiArIGNvbm5lY3Rpb25JZCArICIgcmV0cnlDb3VudD0iICsgcmV0cnlDb3VudCArICIgZGNhYz0iICsgZGNhYwotICAgICAgICAgICAgICAgICAgICArICIgbURhdGFDb25uZWN0aW9uQXN5bmNDaGFubmVscz0iICsgbURhdGFDb25uZWN0aW9uQXN5bmNDaGFubmVscyk7CisgICAgICAgICAgICAgICAgICAgICIgcmV0cnlDb3VudD0iICsgcmV0cnlDb3VudCArCisgICAgICAgICAgICAgICAgICAgICIgYXBuVHlwZT0iICsgYXBuVHlwZSArICIgYXBuQ29udGV4dD0iICsgYXBuQ29udGV4dCArCisgICAgICAgICAgICAgICAgICAgICIgbURhdGFDb25uZWN0aW9uQXN5bmNDaGFubmVscz0iICsgbURhdGFDb25uZWN0aW9uQXN5bmNDaGFubmVscyk7CiAgICAgICAgIH0KIAotICAgICAgICBpZiAoZGNhYyAhPSBudWxsKSB7Ci0gICAgICAgICAgICBmb3IgKEFwbkNvbnRleHQgYXBuQ29udGV4dCA6IGRjYWMuZ2V0QXBuTGlzdFN5bmMoKSkgewotICAgICAgICAgICAgICAgIGFwbkNvbnRleHQuc2V0UmVhc29uKHJlYXNvbik7Ci0gICAgICAgICAgICAgICAgYXBuQ29udGV4dC5zZXRSZXRyeUNvdW50KHJldHJ5Q291bnQpOwotICAgICAgICAgICAgICAgIERjdENvbnN0YW50cy5TdGF0ZSBhcG5Db250ZXh0U3RhdGUgPSBhcG5Db250ZXh0LmdldFN0YXRlKCk7Ci0gICAgICAgICAgICAgICAgaWYgKERCRykgewotICAgICAgICAgICAgICAgICAgICBsb2coIm9uQWN0aW9uSW50ZW50UmVjb25uZWN0QWxhcm06IGFwbkNvbnRleHQgc3RhdGU9IiArIGFwbkNvbnRleHRTdGF0ZSk7Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIGlmICgoYXBuQ29udGV4dFN0YXRlID09IERjdENvbnN0YW50cy5TdGF0ZS5GQUlMRUQpCi0gICAgICAgICAgICAgICAgICAgICAgICB8fCAoYXBuQ29udGV4dFN0YXRlID09IERjdENvbnN0YW50cy5TdGF0ZS5JRExFKSkgewotICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBsb2coIm9uQWN0aW9uSW50ZW50UmVjb25uZWN0QWxhcm06IHN0YXRlIGlzIEZBSUxFRHxJRExFLCBkaXNhc3NvY2lhdGUiKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBhcG5Db250ZXh0LnNldERhdGFDb25uZWN0aW9uQWMobnVsbCk7Ci0gICAgICAgICAgICAgICAgICAgIGFwbkNvbnRleHQuc2V0RGF0YUNvbm5lY3Rpb24obnVsbCk7Ci0gICAgICAgICAgICAgICAgICAgIGFwbkNvbnRleHQuc2V0U3RhdGUoRGN0Q29uc3RhbnRzLlN0YXRlLklETEUpOwotICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGxvZygib25BY3Rpb25JbnRlbnRSZWNvbm5lY3RBbGFybToga2VlcCBhc3NvY2lhdGVkIik7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgc2VuZE1lc3NhZ2Uob2J0YWluTWVzc2FnZShEY3RDb25zdGFudHMuRVZFTlRfVFJZX1NFVFVQX0RBVEEsIGFwbkNvbnRleHQpKTsKKyAgICAgICAgaWYgKChhcG5Db250ZXh0ICE9IG51bGwpICYmIChhcG5Db250ZXh0LmlzRW5hYmxlZCgpKSkgeworICAgICAgICAgICAgYXBuQ29udGV4dC5zZXRSZWFzb24ocmVhc29uKTsKKyAgICAgICAgICAgIGFwbkNvbnRleHQuc2V0UmV0cnlDb3VudChyZXRyeUNvdW50KTsKKyAgICAgICAgICAgIERjdENvbnN0YW50cy5TdGF0ZSBhcG5Db250ZXh0U3RhdGUgPSBhcG5Db250ZXh0LmdldFN0YXRlKCk7CisgICAgICAgICAgICBpZiAoREJHKSB7CisgICAgICAgICAgICAgICAgbG9nKCJvbkFjdGlvbkludGVudFJlY29ubmVjdEFsYXJtOiBhcG5Db250ZXh0IHN0YXRlPSIgKyBhcG5Db250ZXh0U3RhdGUpOwogICAgICAgICAgICAgfQotICAgICAgICAgICAgLy8gQWxyYW0gaGFkIGV4cGlyZWQuIENsZWFyIHBlbmRpbmcgaW50ZW50IHJlY29yZGVkIG9uIHRoZSBEYXRhQ29ubmVjdGlvbi4KLSAgICAgICAgICAgIGRjYWMuc2V0UmVjb25uZWN0SW50ZW50U3luYyhudWxsKTsKKyAgICAgICAgICAgIGlmICgoYXBuQ29udGV4dFN0YXRlID09IERjdENvbnN0YW50cy5TdGF0ZS5GQUlMRUQpCisgICAgICAgICAgICAgICAgICAgIHx8IChhcG5Db250ZXh0U3RhdGUgPT0gRGN0Q29uc3RhbnRzLlN0YXRlLklETEUpKSB7CisgICAgICAgICAgICAgICAgaWYgKERCRykgeworICAgICAgICAgICAgICAgICAgICBsb2coIm9uQWN0aW9uSW50ZW50UmVjb25uZWN0QWxhcm06IHN0YXRlIGlzIEZBSUxFRHxJRExFLCBkaXNhc3NvY2lhdGUiKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgYXBuQ29udGV4dC5zZXREYXRhQ29ubmVjdGlvbkFjKG51bGwpOworICAgICAgICAgICAgICAgIGFwbkNvbnRleHQuc2V0RGF0YUNvbm5lY3Rpb24obnVsbCk7CisgICAgICAgICAgICAgICAgYXBuQ29udGV4dC5zZXRTdGF0ZShEY3RDb25zdGFudHMuU3RhdGUuSURMRSk7CisgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygib25BY3Rpb25JbnRlbnRSZWNvbm5lY3RBbGFybToga2VlcCBhc3NvY2lhdGVkIik7CisgICAgICAgICAgICB9CisgICAgICAgICAgICAvLyBUT0RPOiBJRiBhbHJlYWR5IGFzc29jaWF0ZWQgc2hvdWxkIHdlIHNlbmQgdGhlIEVWRU5UX1RSWV9TRVRVUF9EQVRBPz8/CisgICAgICAgICAgICBzZW5kTWVzc2FnZShvYnRhaW5NZXNzYWdlKERjdENvbnN0YW50cy5FVkVOVF9UUllfU0VUVVBfREFUQSwgYXBuQ29udGV4dCkpOworCisgICAgICAgICAgICBEYXRhQ29ubmVjdGlvbkFjIGRjYWMgPSBhcG5Db250ZXh0LmdldERhdGFDb25uZWN0aW9uQWMoKTsKKyAgICAgICAgICAgIGlmIChkY2FjICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICBDb2xsZWN0aW9uPEFwbkNvbnRleHQ+IGFwbkxpc3QgPSBkY2FjLmdldEFwbkxpc3RTeW5jKCk7CisgICAgICAgICAgICAgICAgbG9nKCJvbkFjdGlvbkludGVudFJlY29ubmVjdEFsYXJtOiBkY2FjLmdldEFwbkxpc3RTeW5jKCk9IiArIGFwbkxpc3QpOworICAgICAgICAgICAgICAgIC8vIEFsYXJtIGhhZCBleHBpcmVkLiBDbGVhciBwZW5kaW5nIGludGVudCByZWNvcmRlZCBvbiB0aGUgRGF0YUNvbm5lY3Rpb24uCisgICAgICAgICAgICAgICAgLy8gVE9ETzogTWF5YmUgc3RvcmUgaW4gYXBuQ29udGV4dD8/Pz8KKyAgICAgICAgICAgICAgICBkY2FjLnNldFJlY29ubmVjdEludGVudFN5bmMobnVsbCk7CisgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICB9CiAKQEAgLTE3MywxMyArMTcyLDEzIEBACiAKICAgICAvLyoqKioqIENvbnN0cnVjdG9yCiAKLSAgICBwdWJsaWMgR3NtRGF0YUNvbm5lY3Rpb25UcmFja2VyKFBob25lQmFzZSBwKSB7CisgICAgcHVibGljIERhdGFDb25uZWN0aW9uVHJhY2tlcihQaG9uZU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AgYm9vbGVhbiBpc0ZhaWxlZCA9IHRydWU7IC8vIEFsbCBlbmFibGVkIEFwbnMgc2hvdWxkIGJlIEZBSUxFRC4KQEAgLTQzNiw3ICs0MzYsNiBAQAogICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coIm92ZXJhbGwgc3RhdGUgaXMgQ09OTkVDVEVEIik7CiAgICAgICAgICAgICAgICAgICAgIHJldHVybiBEY3RDb25zdGFudHMuU3RhdGUuQ09OTkVDVEVEOwogICAgICAgICAgICAgICAgIGNhc2UgQ09OTkVDVElORzoKLSAgICAgICAgICAgICAgICBjYXNlIElOSVRJTkc6CiAgICAgICAgICAgICAgICAgICAgIGlzQ29ubmVjdGluZyA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgIGlzRmFpbGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwpAQCAtNDQ0LDYgKzQ0Myw5IEBACiAgICAgICAgICAgICAgICAgY2FzZSBTQ0FOTklORzoKICAgICAgICAgICAgICAgICAgICAgaXNGYWlsZWQgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICAgICAgaXNBbnlFbmFibGVkID0gdHJ1ZTsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogICAgICAgICB9CkBAIC00NjgsNyArNDcwLDcgQEAKICAgICAvKioKICAgICAgKiBFbnN1cmUgdGhhdCB3ZSBhcmUgY29ubmVjdGVkIHRvIGFuIEFQTiBvZiB0aGUgc3BlY2lmaWVkIHR5cGUuCiAgICAgICoKLSAgICAgKiBAcGFyYW0gdHlwZSB0aGUgQVBOIHR5cGUKKyAgICAgKiBAcGFyYW0gYXBuVHlwZSB0aGUgQVBOIHR5cGUKICAgICAgKiBAcmV0dXJuIFN1Y2Nlc3MgaXMgaW5kaWNhdGVkIGJ5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c6Ci0gICAgICAgICAgICAgICAgbVBob25lLm5vdGlmeURhdGFDb25uZWN0aW9uKHJlYXNvbiwgdHlwZSwgUGhvbmVDb25zdGFudHMuRGF0YVN0YXRlLkNPTk5FQ1RJTkcpOwotICAgICAgICAgICAgICAgIG1QaG9uZS5ub3RpZnlEYXRhQ29ubmVjdGlvbihyZWFzb24sIHR5cGUsIFBob25lQ29uc3RhbnRzLkRhdGFTdGF0ZS5DT05ORUNURUQpOwotICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICB9Ci0gICAgfQotCiAgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHN5bmNocm9uaXplZCBpbnQgZGlzYWJsZUFwblR5cGUoU3RyaW5nIHR5cGUpIHsKICAgICAgICAgaWYgKERCRykgbG9nKCJkaXNhYmxlQXBuVHlwZToiICsgdHlwZSk7CkBAIC01NjYsNyArNTQ5LDcgQEAKICAgICAgICAgc3luY2hyb25pemVkIChtRGF0YUVuYWJsZWRMb2NrKSB7CiAgICAgICAgICAgICBpZiAoIShtSW50ZXJuYWxEYXRhRW5hYmxlZCAmJiBtVXNlckRhdGFFbmFibGVkICYmIHNQb2xpY3lEYXRhRW5hYmxlZCkpIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgIGZvciAoQXBuQ29udGV4dCBhcG5Db250ZXh0IDogbUFwbkNvbnRleHRzLnZhbHVlcygpKSB7Ci0gICAgICAgICAgICAgICAgLy8gTWFrZSBzdXJlIHdlIGRvbnQgaGF2ZSBhIGNvbnRleHQgdGhhdCBnb2luZyBkb3duCisgICAgICAgICAgICAgICAgLy8gTWFrZSBzdXJlIHdlIGRvbid0IGhhdmUgYSBjb250ZXh0IHRoYXQgaXMgZ29pbmcgZG93bgogICAgICAgICAgICAgICAgIC8vIGFuZCBpcyBleHBsaWNpdGx5IGRpc2FibGVkLgogICAgICAgICAgICAgICAgIGlmIChpc0RhdGFBbGxvd2VkKGFwbkNvbnRleHQpKSB7CiAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwpAQCAtNzI2LDcgKzcwOSw3IEBACiAgICAgcHJpdmF0ZSBib29sZWFuIHRyeVNldHVwRGF0YShBcG5Db250ZXh0IGFwbkNvbnRleHQpIHsKICAgICAgICAgaWYgKERCRykgewogICAgICAgICAgICAgbG9nKCJ0cnlTZXR1cERhdGEgZm9yIHR5cGU6IiArIGFwbkNvbnRleHQuZ2V0QXBuVHlwZSgpICsKLSAgICAgICAgICAgICAgICAgICAgIiBkdWUgdG8gIiArIGFwbkNvbnRleHQuZ2V0UmVhc29uKCkpOworICAgICAgICAgICAgICAgICAgICAiIGR1ZSB0byAiICsgYXBuQ29udGV4dC5nZXRSZWFzb24oKSArICIgYXBuQ29udGV4dD0iICsgYXBuQ29udGV4dCk7CiAgICAgICAgICAgICBsb2coInRyeVNldHVwRGF0YSB3aXRoIG1Jc1BzUmVzdHJpY3RlZD0iICsgbUlzUHNSZXN0cmljdGVkKTsKICAgICAgICAgfQogCkBAIC03MzYsNyArNzE5LDcgQEAKICAgICAgICAgICAgIGFwbkNvbnRleHQuc2V0U3RhdGUoRGN0Q29uc3RhbnRzLlN0YXRlLkNPTk5FQ1RFRCk7CiAgICAgICAgICAgICBtUGhvbmUubm90aWZ5RGF0YUNvbm5lY3Rpb24oYXBuQ29udGV4dC5nZXRSZWFzb24oKSwgYXBuQ29udGV4dC5nZXRBcG5UeXBlKCkpOwogCi0gICAgICAgICAgICBsb2coInRyeVNldHVwRGF0YTogKGZpeD8pIFdlJ3JlIG9uIHRoZSBzaW11bGF0b3I7IGFzc3VtaW5nIGRhdGEgaXMgY29ubmVjdGVkIik7CisgICAgICAgICAgICBsb2coInRyeVNldHVwRGF0YTogWCBXZSdyZSBvbiB0aGUgc2ltdWxhdG9yOyBhc3N1bWluZyBjb25uZWN0ZWQgcmV0VmFsdWU9dHJ1ZSIpOwogICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgIH0KIApAQCAtNzQ5LDkgKzczMiw5IEBACiAgICAgICAgICAgICBpZiAoYXBuQ29udGV4dC5nZXRTdGF0ZSgpID09IERjdENvbnN0YW50cy5TdGF0ZS5JRExFKSB7CiAgICAgICAgICAgICAgICAgQXJyYXlMaXN0PEFwblNldHRpbmc+IHdhaXRpbmdBcG5zID0gYnVpbGRXYWl0aW5nQXBucyhhcG5Db250ZXh0LmdldEFwblR5cGUoKSk7CiAgICAgICAgICAgICAgICAgaWYgKHdhaXRpbmdBcG5zLmlzRW1wdHkoKSkgewotICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coInRyeVNldHVwRGF0YTogTm8gQVBOIGZvdW5kIik7Ci0gICAgICAgICAgICAgICAgICAgIG5vdGlmeU5vRGF0YShHc21EYXRhQ29ubmVjdGlvbi5GYWlsQ2F1c2UuTUlTU0lOR19VTktOT1dOX0FQTiwgYXBuQ29udGV4dCk7CisgICAgICAgICAgICAgICAgICAgIG5vdGlmeU5vRGF0YShEYXRhQ29ubmVjdGlvbkJhc2UuRmFpbENhdXNlLk1JU1NJTkdfVU5LTk9XTl9BUE4sIGFwbkNvbnRleHQpOwogICAgICAgICAgICAgICAgICAgICBub3RpZnlPZmZBcG5zT2ZBdmFpbGFiaWxpdHkoYXBuQ29udGV4dC5nZXRSZWFzb24oKSk7CisgICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygidHJ5U2V0dXBEYXRhOiBYIE5vIEFQTiBmb3VuZCByZXRWYWx1ZT1mYWxzZSIpOwogICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgYXBuQ29udGV4dC5zZXRXYWl0aW5nQXBucyh3YWl0aW5nQXBucyk7CkBAIC03NjIsMTEgKzc0NSwxNCBAQAogICAgICAgICAgICAgfQogCiAgICAgICAgICAgICBpZiAoREJHKSB7Ci0gICAgICAgICAgICAgICAgbG9nICgiU2V0dXAgd2F0aW5nQXBucyA6ICIgKyBhcG5MaXN0VG9TdHJpbmcoYXBuQ29udGV4dC5nZXRXYWl0aW5nQXBucygpKSk7CisgICAgICAgICAgICAgICAgbG9nKCJ0cnlTZXR1cERhdGE6IGNhbGwgc2V0dXBEYXRhLCB3YWl0aW5nQXBucyA6ICIKKyAgICAgICAgICAgICAgICAgICAgICAgICsgYXBuTGlzdFRvU3RyaW5nKGFwbkNvbnRleHQuZ2V0V2FpdGluZ0FwbnMoKSkpOwogICAgICAgICAgICAgfQogICAgICAgICAgICAgLy8gYXBuQ29udGV4dC5zZXRSZWFzb24oYXBuQ29udGV4dC5nZXRSZWFzb24oKSk7CiAgICAgICAgICAgICBib29sZWFuIHJldFZhbHVlID0gc2V0dXBEYXRhKGFwbkNvbnRleHQpOwogICAgICAgICAgICAgbm90aWZ5T2ZmQXBuc09mQXZhaWxhYmlsaXR5KGFwbkNvbnRleHQuZ2V0UmVhc29uKCkpOworCisgICAgICAgICAgICBpZiAoREJHKSBsb2coInRyeVNldHVwRGF0YTogWCByZXRWYWx1ZT0iICsgcmV0VmFsdWUpOwogICAgICAgICAgICAgcmV0dXJuIHJldFZhbHVlOwogICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgLy8gVE9ETzogY2hlY2sgdGhlIGNvbmRpdGlvbi4KQEAgLTc3NSw2ICs3NjEsNyBAQAogICAgICAgICAgICAgICAgICAgICB8fCBhcG5Db250ZXh0LmdldFN0YXRlKCkgPT0gRGN0Q29uc3RhbnRzLlN0YXRlLlNDQU5OSU5HKSkKICAgICAgICAgICAgICAgICBtUGhvbmUubm90aWZ5RGF0YUNvbm5lY3Rpb25GYWlsZWQoYXBuQ29udGV4dC5nZXRSZWFzb24oKSwgYXBuQ29udGV4dC5nZXRBcG5UeXBlKCkpOwogICAgICAgICAgICAgbm90aWZ5T2ZmQXBuc09mQXZhaWxhYmlsaXR5KGFwbkNvbnRleHQuZ2V0UmVhc29uKCkpOworICAgICAgICAgICAgaWYgKERCRykgbG9nICgidHJ5U2V0dXBEYXRhOiBYIGFwbkNvbnRleHQgbm90ICdyZWFkeScgcmV0VmFsdWU9ZmFsc2UiKTsKICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgfQogICAgIH0KQEAgLTc5MCw3ICs3NzcsNyBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBQaG9uZUNvbnN0YW50cy5EYXRhU3RhdGUuRElTQ09OTkVDVEVEKTsKICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgaWYgKERCRykgewotICAgICAgICAgICAgICAgICAgICBsb2coIm5vdGlmeU9mZkFwbnNPZkF2YWlsYWJpbGl0eSBza2lwcGVkIGFwbiBkdWUgdG8gaXNSZWFkeT09ZmFsc2U6ICIgKworICAgICAgICAgICAgICAgICAgICBsb2coIm5vdGlmeU9mZkFwbnNPZkF2YWlsYWJpbGl0eSBza2lwcGVkIGFwbiBkdWUgdG8gaXNSZWFkeT09dHJ1ZTogIiArCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBuQ29udGV4dC50b1N0cmluZygpKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CkBAIC03OTksMTAgKzc4NiwxMCBAQAogCiAgICAgLyoqCiAgICAgICogSWYgdGVhckRvd24gaXMgdHJ1ZSwgdGhpcyBvbmx5IHRlYXJzIGRvd24gYSBDT05ORUNURUQgc2Vzc2lvbi4gUHJlc2VudGx5LAotICAgICAqIHRoZXJlIGlzIG5vIG1lY2hhbmlzbSBmb3IgYWJhbmRvbmluZyBhbiBJTklUSU5HL0NPTk5FQ1RJTkcgc2Vzc2lvbiwKKyAgICAgKiB0aGVyZSBpcyBubyBtZWNoYW5pc20gZm9yIGFiYW5kb25pbmcgYW4gQ09OTkVDVElORyBzZXNzaW9uLAogICAgICAqIGJ1dCB3b3VsZCBsaWtlbHkgaW52b2x2ZSBjYW5jZWxsaW5nIHBlbmRpbmcgYXN5bmMgcmVxdWVzdHMgb3IKICAgICAgKiBzZX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lbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcG5Db250ZXh0LmdldERhdGFDb25uZWN0aW9uKCkudGVhckRvd24oYXBuQ29udGV4dC5nZXRSZWFzb24oKSwgbXNnKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcG5Db250ZXh0LmdldERhdGFDb25uZWN0aW9uKCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnRlYXJEb3duKGFwbkNvbnRleHQsIGFwbkNvbnRleHQuZ2V0UmVhc29uKCksIG1zZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICBhcG5Db250ZXh0LnNldFN0YXRlKERjdENvbnN0YW50cy5TdGF0ZS5ESVNDT05ORUNUSU5HKTsKICAgICAgICAgICAgICAgICAgICAgfQpAQCAtOTIwLDcgKzkwNyw3IEBACiAgICAgLyoqCiAgICAgICogQ2FuY2VscyB0aGUgYWxhcm0gYXNzb2NpYXRlZCB3aXRoIERDQUMuCiAgICAgICoKLSAgICAgKiBAcGFyYW0gRGF0YUNvbm5lY3Rpb25BYyBvbiB3aGljaCB0aGUgYWxhcm0gc2hvdWxkIGJlIHN0b3BwZWQuCisgICAgICogQHBhcmFtIGRjYWMgb24gd2hpY2ggdGhlIGFsYXJtIHNob3VsZCBiZSBzdG9wcGVkLgogICAgICAqLwogICAgIHByaXZhdGUgdm9pZCBjYW5jZWxSZWNvbm5lY3RBbGFybShEYXRhQ29ubmVjdGlvbkFjIGRjYWMpIHsKICAgICAgICAgaWYgKGRjYWMgPT0gbnVsbCkgcmV0dXJuOwpAQCAtMTAwMSw2MiArOTg4LDMxIEBACiAgICAgICAgIC8vIFRPRE86IEZpeCByZXRyeSBoYW5kbGluZyBzbyBmcmVlIERhdGFDb25uZWN0aW9ucyBoYXZlIGVtcHR5IGFwbmxpc3RzLgogICAgICAgICAvLyBQcm9iYWJseSBtb3ZlIHJldHJ5IGhhbmRsaW5nIGludG8gRG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jID0gZGNhYy5kYXRhQ29ubmVjdGlvbjsKKyAgICAgICAgICAgICAgICBEYXRhQ29ubmVjdGlvbkJhc2UgZGMgPSBkY2FjLmRhdGFDb25uZWN0aW9uOwogICAgICAgICAgICAgICAgIGlmIChEQkcpIHsKLSAgICAgICAgICAgICAgICAgICAgbG9nKCJmaW5kRnJlZURhdGFDb25uZWN0aW9uOiBmb3VuZCBmcmVlIEdzbURhdGFDb25uZWN0aW9uPSIgKworICAgICAgICAgICAgICAgICAgICBsb2coImZpbmRGcmVlRGF0YUNvbm5lY3Rpb246IGZvdW5kIGZyZWUgRGF0YUNvbm5lY3Rpb249IiArCiAgICAgICAgICAgICAgICAgICAgICAgICAiIGRjYWM9IiArIGRjYWMgKyAiIGRjPSIgKyBkYyk7CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIHJldHVybiAoR3NtRGF0YUNvbm5lY3Rpb24pIGRjOworICAgICAgICAgICAgICAgIHJldHVybiAoRGF0YUNvbm5lY3Rpb24pIGRjOwogICAgICAgICAgICAgfQogICAgICAgICB9Ci0gICAgICAgIGxvZygiZmluZEZyZWVEYXRhQ29ubmVjdGlvbjogTk8gZnJlZSBHc21EYXRhQ29ubmVjdGlvbiIpOworICAgICAgICBsb2coImZpbmRGcmVlRGF0YUNvbm5lY3Rpb246IE5PIGZyZWUgRGF0YUNvbm5lY3Rpb24iKTsKICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgfQogCi0gICAgcHJvdGVjdGVkIEdzbURhdGFDb25uZWN0aW9uIGZpbmRSZWFkeURhdGFDb25uZWN0aW9uKEFwblNldHRpbmcgYXBuKSB7Ci0gICAgICAgIGlmIChhcG4gPT0gbnVsbCkgewotICAgICAgICAgICAgcmV0dXJuIG51bGw7Ci0gICAgICAgIH0KLSAgICAgICAgaWYgKERCRykgewotICAgICAgICAgICAgbG9nKCJmaW5kUmVhZHlEYXRhQ29ubmVjdGlvbjogYXBuIHN0cmluZyA8IiArIGFwbiArICI+IiArCi0gICAgICAgICAgICAgICAgICAgICIgZGNhY3Muc2l6ZT0iICsgbURhdGFDb25uZWN0aW9uQXN5bmNDaGFubmVscy5zaXplKCkpOwotICAgICAgICB9Ci0gICAgICAgIGZvciAoRGF0YUNvbm5lY3Rpb25BYyBkY2FjIDogbURhdGFDb25uZWN0aW9uQXN5bmNDaGFubmVscy52YWx1ZXMoKSkgewotICAgICAgICAgICAgQXBuU2V0dGluZyBhcG5TZXR0aW5nID0gZGNhYy5nZXRBcG5TZXR0aW5nU3luYygpOwotICAgICAgICAgICAgaWYgKERCRykgewotICAgICAgICAgICAgICAgIGxvZygiZmluZFJlYWR5RGF0YUNvbm5lY3Rpb246IGRjIGFwbiBzdHJpbmcgPCIgKwotICAgICAgICAgICAgICAgICAgICAgICAgIChhcG5TZXR0aW5nICE9IG51bGwgPyAoYXBuU2V0dGluZy50b1N0cmluZygpKSA6ICJudWxsIikgKyAiPiIpOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgaWYgKChhcG5TZXR0aW5nICE9IG51bGwpICYmIFRleHRVdGlscy5lcXVhbHMoYXBuU2V0dGluZy50b1N0cmluZygpLCBhcG4udG9TdHJpbmcoKSkpIHsKLSAgICAgICAgICAgICAgICBEYXRhQ29ubmVjdGlvbiBkYyA9IGRjYWMuZGF0YUNvbm5lY3Rpb247Ci0gICAgICAgICAgICAgICAgaWYgKERCRykgewotICAgICAgICAgICAgICAgICAgICBsb2coImZpbmRSZWFkeURhdGFDb25uZWN0aW9uOiBmb3VuZCByZWFkeSBHc21EYXRhQ29ubmVjdGlvbj0iICsKLSAgICAgICAgICAgICAgICAgICAgICAgICIgZGNhYz0iICsgZGNhYyArICIgZGM9IiArIGRjKTsKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgcmV0dXJuIChHc21EYXRhQ29ubmVjdGlvbikgZGM7Ci0gICAgICAgICAgICB9Ci0gICAgICAgIH0KLSAgICAgICAgcmV0dXJuIG51bGw7Ci0gICAgfQotCi0KICA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rpb24gZ2V0IHRoZSB3cm9uZyBvbmU/PwotICAgICAgICAgICAgICAgIGRjID0gZmluZEZyZWVEYXRhQ29ubmVjdGlvbigpOwotICAgICAgICAgICAgfQorICAgICAgICAgICAgLy8gVE9ETzogV2hlbiBhbGxvY2F0aW5nIHlvdSBhcmUgbWFwcGluZyB0eXBlIHRvIGlkLiBJZiBtb3JlIHRoYW4gMSBmcmVlLAorICAgICAgICAgICAgLy8gdGhlbiBjb3VsZCBmaW5kRnJlZURhdGFDb25uZWN0aW9uIGdldCB0aGUgd3Jvbmcgb25lPz8KKyAgICAgICAgICAgIGRjID0gZmluZEZyZWVEYXRhQ29ubmVjdGlvbigpOwogCiAgICAgICAgICAgICBpZiAoZGMgPT0gbnVsbCkgewogICAgICAgICAgICAgICAgIGRjID0gY3JlYXRlRGF0YUNvbm5lY3Rpb24oKTsKICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgaWYgKGRjID09IG51bGwpIHsKLSAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coInNldHVwRGF0YTogTm8gZnJlZSBHc21EYXRhQ29ubmVjdGlvbiBmb3VuZCEiKTsKKyAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coInNldHVwRGF0YTogTm8gZnJlZSBEYXRhQ29ubmVjdGlvbiBmb3VuZCEiKTsKICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0gZWxzZSB7CkBAIC0xMDk0LDcgKzEwNDUsNyBAQAogICAgICAgICBkYy5zZXRQcm9maWxlSWQoIHByb2ZpbGVJZCApOyAgLy8gIGFzc3VtZWQgbm8gY29ubmVjdGlvbiBzaGFyaW5nIG9uIHByb2ZpbGVkIHR5cGVzCiAKICAgICAgICAgaW50IHJlZkNvdW50ID0gZGNhYy5nZXRSZWZDb3VudFN5bmMoKTsKLSAgICAgICAgaWYgKERCRykgbG9nKCJzZXR1cERhdGE6IGluaXQgZGMgYW5kIGFwbkNvbnRleHQg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dEludGVudFN5bmMoKSAhPSBudWxsKSB7CiAgICAgICAgICAgICBpZiAoREJHKSBsb2coInNldHVwRGF0YTogZGF0YSByZWNvbm5lY3Rpb24gcGVuZGluZyIpOwogICAgICAgICAgICAgYXBuQ29udGV4dC5zZXRTdGF0ZShEY3RDb25zdGFudHMuU3RhdGUuRkFJTEVEKTsKQEAgLTExMTksNyArMTA3MCw3IEBACiAgICAgICAgIE1lc3NhZ2UgbXNnID0gb2J0YWluTWVzc2FnZSgpOwogICAgICAgICBtc2cud2hhdCA9IERjdENvbnN0YW50cy5FVkVOVF9EQVRBX1NFVFVQX0NPTVBMRVRFOwogICAgICAgICBtc2cub2JqID0gYXBuQ29udGV4dDsKLSAgICAgICAgZGMuYnJpbmdVcChtc2csIGFwbik7CisgICAgICAgIGRjLmJyaW5nVXAoYXBuQ29udGV4dCwgbXNnKTsKIAogICAgICAgICBpZiAoREJHKSBsb2coInNldHVwRGF0YTogaW5pdGluZyEiKTsKICAgICAgICAgcmV0dXJuIHRydWU7CkBAIC0xMTg0LDggKzExMzUsNyBAQAogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBpZiAoIWZvdW5kKSB7CiAgICAgICAgICAgICAgICAgICAgIC8vIEFwbkNvbnRleHQgZG9lcyBub3QgaGF2ZSBkY2FjIHJlcG9ydGVkIGluIGRhdGEgY2FsbCBsaXN0LgotICAgICAgICAgICAgICAgICAgICAvLyBGZXRjaCBhbGwgdGhlIEFwbkNvbnRleHRzIHRoYXQgbWFwIHRvIHRoaXMgZGNhYyB3aGljaCBhcmUgaW4KLSAgICAgICAgICAgICAgICAgICAgLy8gSU5JVElORyBzdGF0ZSB0b28uCisgICAgICAgICAgICAgICAgICAgIC8vIEZldGNoIGFsbCB0aGUgQXBuQ29udGV4dHMgdGhhdCBtYXAgdG8gdGhpcyBkY2FjLgogICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coImZpbmRBcG5Db250ZXh0VG9DbGVhbihhcik6IENvbm5lY3RlZCBhcG4gbm90IGZvdW5kIGluIHRoZSBsaXN0ICgiICsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFwbkNvbnRleHQudG9TdHJpbmcoKSArICIpIik7CiAgICAgICAgICAgICAgICAgICAgIGlmIChhcG5Db250ZXh0LmdldERhdGFDb25uZWN0aW9uQWMoKSAhPSBudWxsKSB7CkBAIC0xMjUzLDggKzEyMDMsNyBAQAogICAgICAgICAgICAgQXJyYXlMaXN0PEFwbkNvbnRleHQ+IGNvbm5lY3RlZEFwbnMgPSBuZXcgQXJyYXlMaXN0PEFwbkNvbnRleHQ+KCk7CiAgICAgICAgICAgICBmb3IgKEFwbkNvbnRleHQgYXBuQ29udGV4dCA6IGFwbnMpIHsKICAgICAgICAgICAgICAgICBpZiAoYXBuQ29udGV4dC5nZXRTdGF0ZSgpID09IERjdENvbnN0YW50cy5TdGF0ZS5DT05ORUNURUQgfHwKLSAgICAgICAgICAgICAgICAgICAgICAgYXBuQ29udGV4dC5nZXRTdGF0ZSgpID09IERjdENvbnN0YW50cy5TdGF0ZS5DT05ORUNUSU5HIHx8Ci0gICAgICAgICAgICAgICAgICAgICAgIGFwbkNvbnRleHQuZ2V0U3RhdGUoKSA9PSBEY3RDb25zdGFudHMuU3RhdGUuSU5JVElORykgeworICAgICAgICAgICAgICAgICAgICAgICBhcG5Db250ZXh0LmdldFN0YXRlKCkgPT0gRGN0Q29uc3RhbnRzLlN0YXRlLkNPTk5FQ1RJTkcpIHsKICAgICAgICAgICAgICAgICAgICAgY29ubmVjdGVkQXBucy5hZGQoYXBuQ29udGV4dCk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQpAQCAtMTM4NCw2ICsxMzMzLDcgQEAKICAgICB9CiAKICAgICAvLyBUT0RPOiBGb3IgbXVsdGlwbGUgQWN0aXZlIEFQTnMgbm90IGV4YWN0bHkgc3VyZSBob3cgdG8gZG8gdGhpcy4KKyAgICBAT3ZlcnJpZGUKICAgICBwcm90Z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aW5nID0gZmV0Y2hEdW5BcG4oKTsKICAgICAgICAgfQogCi0gICAgICAgIERhdGFDb25uZWN0aW9uIHBvdGVudGlhbCA9IG51bGw7CisgICAgICAgIERhdGFDb25uZWN0aW9uQmFzZSBwb3RlbnRpYWwgPSBudWxsOwogICAgICAgICBmb3IgKEFwbkNvbnRleHQgYyA6IG1BcG5Db250ZXh0cy52YWx1ZXMoKSkgewotICAgICAgICAgICAgRGF0YUNvbm5lY3Rpb24gY29ubiA9IGMuZ2V0RGF0YUNvbm5lY3Rpb24oKTsKKyAgICAgICAgICAgIERhdGFDb25uZWN0aW9uQmFzZSBjb25uID0gYy5nZXREYXRhQ29ubmVjdGlvbigpOwogICAgICAgICAgICAgaWYgKGNvbm4gIT0gbnVsbCkgewogICAgICAgICAgICAgICAgIEFwblNldHRpbmcgYXBuU2V0dGluZyA9IGMuZ2V0QXBuU2V0dGluZygpOwogICAgICAgICAgICAgICAgIGlmIChkdW5TZXR0aW5nICE9IG51bGwpIHsKQEAgLTE2MzAsNiArMTU4MCw5IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjb25uOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgQ09OTkVDVElORzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcG90ZW50aWFsID0gY29ubjsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBOb3QgY29ubmVjdGVkLCBwb3RlbnRpYWwgdW5jaGFuZ2VkCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChhcG5TZXR0aW5nICE9IG51bGwgJiYgYXBuU2V0dGluZy5jYW5IYW5kbGVUeXBlKGFwblR5cGUpKSB7CkBAIC0xNjQyLDYgKzE1OTUsOSBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjb25uOwogICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBDT05ORUNUSU5HOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvdGVudGlhbCA9IGNvbm47CisgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIE5vdCBjb25uZWN0ZWQsIHBvdGVudGlhbCB1bmNoYW5nZWQKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KQEAgLTE3NTYsNyArMTcxMiw3IEBACiAgICAgQE92ZXJyaWRlCiAgICAgcHJvdGVjdGVkIHZvaWQgb25EYXRhU2V0dXBDb21wbGV0ZShBc3luY1Jlc3VsdCBhcikgewogCi0gICAgICAgIERhdGFDb25uZWN0aW9uLkZhaWxDYXVzZSBjYXVzZSA9IERhdGFDb25uZWN0aW9uLkZhaWxDYXVzZS5VTktOT1dOOworICAgICAgICBEYXRhQ29ubmVjdGlvbkJhc2UuRmFpbENhdXNlIGNhdXNlID0gRGF0YUNvbm5lY3Rpb25CYXNlLkZhaWxDYXVzZS5VTktOT1dOOwogICAgICAgICBib29sZWFuIGhhbmRsZUVycm9yID0gZmFsc2U7CiAgICAgICAgIEFwbkNvbnRleHQgYXBuQ29udGV4dCA9IG51bGw7CiAKQEAgLTE3NjYsNyArMTcyMiw3IEBACiAgICAgICAgICAgICB0aHJvdyBuZXcgUnVudGltZUV4Y2VwdGlvbigib25EYXRhU2V0dXBDb21wbGV0ZTogTm8gYXBuQ29udGV4dCIpOwogICAgICAgICB9CiAKLSAgICAgICAgaWYgKGlzRGF0YVNldHVwQ29tcGxldGVPayhhcikpIHsKKyAgICAgICAgaWYgKGFyLmV4Y2VwdGlvbiA9PSBudWxsKSB7CiAgICAgICAgICAgICBEYXRhQ29ubmVjdGlvbkFjIGRjYWMgPSBhcG5Db250ZXh0LmdldERhdGFDb25uZWN0aW9uQWMoKTsKIAogICAgICAgICAgICAgaWYgKFJBRElPX1RFU1RTKSB7CkBAIC0xNzg5LDEwICsxNzQ1LDEwIEBACiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBpZiAoZGNhYyA9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgbG9nKCJvbkRhdGFTZXR1cENvbXBsZXRlOiBubyBjb25uZWN0aW9uIHRvIERDLCBoYW5kbGUgYXMgZXJyb3IiKTsKLSAgICAgICAgICAgICAgICBjYXVzZSA9IERhdGFDb25uZWN0aW9uLkZhaWxDYXVzZS5DT05ORUNUSU9OX1RPX0RBVEFDT05ORUNUSU9OQUNfQlJPS0VOOworICAgICAgICAgICAgICAgIGNhdXNlID0gRGF0YUNvbm5lY3Rpb25CYXNlLkZhaWxDYXVzZS5DT05ORUNUSU9OX1RPX0RBVEFDT05ORUNUSU9OQUNfQlJPS0VOOwogICAgICAgICAgICAgICAgIGhhbmRsZUVycm9yID0gdHJ1ZTsKICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgRGF0YUNvbm5lY3Rpb24gZGMgPSBhcG5Db250ZXh0LmdldERhdGFDb25uZWN0aW9uKCk7CisgICAgICAgICAgICAgICAgRGF0YUNvbm5lY3Rpb25CYXNlIGRjID0gYXBuQ29udGV4dC5nZXREYXRhQ29ubmVjdGlvbigpOwogICAgICAgICAgICAgICAgIEFwblNldHRpbmcgYXBuID0gYXBuQ29udGV4dC5nZXRBcG5TZXR0aW5nKCk7CiAgICAgICAgICAgICAgICAgaWYgKERCRykgewogICAgICAgICAgICAgICAgICAgICBsb2coIm9uRGF0YVNldHVwQ29tcGxldGU6IHN1Y2Nlc3MgYXBuPSIgKyAoYXBuID09IG51bGwgPyAidW5rbm93biIgOiBhcG4uYXBuKSk7CkBAIC0xODEzLDcgKzE3NjksNyBAQAogICAgICAgICAgICAgICAgIC8vIGV2ZXJ5dGhpbmcgaXMgc2V0dXAKICAgICAgICAgICAgICAgICBpZihUZXh0VXRpbHMuZXF1YWxzKGFwbkNvbnRleHQuZ2V0QXBuVHlwZSgpLFBob25lQ29uc3RhbnRzLkFQTl9UWVBFX0RFRkFVTFQpKSB7CiAgICAgICAgICAgICAgICAgICAgIFN5c3RlbVByb3BlcnRpZXMuc2V0KCJnc20uZGVmYXVsdHBkcGNvbnRleHQuYWN0aXZlIiwgInRydWUiKTsKLSAgICAgICAgICAgICAgICAgICAgaWYgKGNhblNldFByZWZlckFwbiAmJiBtUHJlZmVycmVkQXBuID09IG51bGwpIHsKKyAgICAgICAgICAgICAgICAgICAgaWYgKG1DYW5TZXRQcmVmZXJBcG4gJiYgbVByZWZlcnJlZEFwbiA9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coIm9uRGF0YVNldHVwQ29tcGxldGU6IFBSRUZFUkVEIEFQTiBpcyBudWxsIik7CiAgICAgICAgICAgICAgICAgICAgICAgICBtUHJlZmVycmVkQXBuID0gYXBuOwogICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1QcmVmZXJyZWRBcG4gIT0gbnVsbCkgewpAQCAtMTgyNiw3ICsxNzgyLDcgQEAKICAgICAgICAgICAgICAgICBub3RpZnlEZWZhdWx0RGF0YShhcG5Db250ZXh0KTsKICAgICAgICAgICAgIH0KICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgIGNhdXNlID0gKERhdGFDb25uZWN0aW9uLkZhaWxDYXVzZSkgKGFyLnJlc3VsdCk7CisgICAgICAgICAgICBjYXVzZSA9IChEYXRhQ29ubmVjdGlvbkJhc2UuRmFpbENhdXNlKSAoYXIucmVzdWx0KTsKICAgICAgICAgICAgIGlmIChEQkcpIHsKICAgICAgICAgICAgICAgICBBcG5TZXR0aW5nIGFwbiA9IGFwbkNvbnRleHQuZ2V0QXBuU2V0dGluZygpOwogICAgICAgICAgICAgICAgIGxvZyhTdHJpbmcuZm9ybWF0KCJvbkRhdGFTZXR1cENvbXBsZXRlOiBlcnJvciBhcG49JXMgY2F1c2U9JXMiLApAQCAtMTg2OCw5ICsxODI0LDkgQEAKICAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJvbkRhdGFTZXR1cENvbXBsZXRlOiBOb3QgYWxsIHBlcm1hbmVudCBmYWlsdXJlcywgcmV0cnkiKTsKICAgICAgICAgICAgICAgICAgICAgLy8gY2hlY2sgdG8gc2VlIGlmIHJldHJ5IHNob3VsZCBiZSBvdmVycmlkZGVuIGZvciB0aGlzIGZhaWx1cmUuCiAgICAgICAgICAgICAgICAgICAgIGludCByZXRyeU92ZXJyaWRlID0gLTE7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChhci5leGNlcHRpb24gaW5zdGFuY2VvZiBEYXRhQ29ubmVjdGlvbi5DYWxsU2V0dXBFeGNlcHRpb24pIHsKKyAgICAgICAgICAgICAgICAgICAgaWYgKGFyLmV4Y2VwdGlvbiBpbnN0YW5jZW9mIERhdGFDb25uZWN0aW9uQmFzZS5DYWxsU2V0dXBFeGNlcHRpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgIHJldHJ5T3ZlcnJpZGUgPQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICgoRGF0YUNvbm5lY3Rpb24uQ2FsbFNldHVwRXhjZXB0aW9uKWFyLmV4Y2VwdGlvbikuZ2V0UmV0cnlPdmVycmlkZSgpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICgoRGF0YUNvbm5lY3Rpb25CYXNlLkNhbGxTZXR1cEV4Y2VwdGlvbilhci5leGNlcHRpb24pLmdldFJldHJ5T3ZlcnJpZGUoKTsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICBpZiAocmV0cnlPdmVycmlkZSA9PSBSSUxDb25zdGFudHMuTUFYX0lOVCkgewogICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgb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9vbGVhbihjb20uYW5kcm9pZC4KICAgICAgICAgICAgICAgICAgICAgaW50ZXJuYWwuUi5ib29sLmNvbmZpZ19kb250UHJlZmVyQXBuKTsKICAgICAgICAgfSBjYXRjaCAoUmVzb3VyY2VzLk5vdEZvdW5kRXhjZXB0aW9uIGUpIHsKKyAgICAgICAgICAgIGlmIChEQkcpIGxvZygiYnVpbGRXYWl0aW5nQXBuczogdXNlUHJlZmVycmVkIE5vdEZvdW5kRXhjZXB0aW9uIHNldCB0byB0cnVlIik7CiAgICAgICAgICAgICB1c2VQcmVmZXJyZWQgPSB0cnVlOwogICAgICAgICB9CisgICAgICAgIGlmIChEQkcpIHsKKyAgICAgICAgICAgIGxvZygiYnVpbGRXYWl0aW5nQXBuczogdXNlUHJlZmVycmVkPSIgKyB1c2VQcmVmZXJyZWQKKyAgICAgICAgICAgICAgICAgICAgKyAiIGNhblNldFByZWZlckFwbj0iICsgbUNhblNldFByZWZlckFwbgorICAgICAgICAgICAgICAgICAgICArICIgbVByZWZlcnJlZEFwbj0iICsgbVByZWZlcnJlZEFwbgorICAgICAgICAgICAgICAgICAgICArICIgb3BlcmF0b3I9IiArIG9wZXJhdG9yICsgIiByYWRpb1RlY2g9IiArIHJhZGlvVGVjaAorICAgICAgICAgICAgICAgICAgICArICIgSWNjUmVjb3JkcyByPSIgKyByKTsKKyAgICAgICAgfQogCi0gICAgICAgIGlmICh1c2VQcmVmZXJyZWQgJiYgY2FuU2V0UHJlZmVyQXBuICYmIG1QcmVmZXJyZWRBcG4gIT0gbnVsbCAmJgorICAgICAgICBpZiAodXNlUHJlZmVycmVkICYmIG1DYW5TZXRQcmVmZXJBcG4gJiYgbVByZWZlcnJlZEFwbiAhPSBudWxsICYmCiAgICAgICAgICAgICAgICAgbVByZWZlcnJlZEFwbi5jYW5IYW5kbGVUeXBlKHJlcXVlc3RlZEFwblR5cGUpKSB7CiAgICAgICAgICAgICBpZiAoREJHKSB7CiAgICAgICAgICAgICAgICAgbG9nKCJidWlsZFdhaXRpbmdBcG5zOiBQcmVmZXJyZWQgQVBOOiIgKyBvcGVyYXRvciArICI6IgpAQCAtMjE3OCwxNCArMjE0NCwyNiBAQAogICAgICAgICAgICAgfQogICAgICAgICB9CiAgICAgICAgIGlmIChtQWxsQXBucyAhPSBudWxsKSB7CisgICAgICAgICAgICBpZiAoREJHKSBsb2coImJ1aWxkV2FpdGluZ0FwbnM6IG1BbGxBcG5zPSIgKyBtQWxsQXBucyk7CiAgICAgICAgICAgICBmb3IgKEFwblNldHRpbmcgYXBuIDogbUFsbEFwbnMpIHsKKyAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coImJ1aWxkV2FpdGluZ0FwbnM6IGFwbj0iICsgYXBuKTsKICAgICAgICAgICAgICAgICBpZiAoYXBuLmNhbkhhbmRsZVR5cGUocmVxdWVzdGVkQXBuVHlwZSkpIHsKICAgICAgICAgICAgICAgICAgICAgaWYgKGFwbi5iZWFyZXIgPT0gMCB8fCBhcG4uYmVhcmVyID09IHJhZGlvVGVjaCkgewotICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJhcG4gaW5mbyA6ICIgK2Fwbi50b1N0cmluZygpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygiYnVpbGRXYWl0aW5nQXBuczogYWRkaW5nIGFwbj0iICsgYXBuLnRvU3RyaW5nKCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgYXBuTGlzdC5hZGQoYXBuKTsKKyAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2coImJ1aWxkV2FpdGluZ0FwbnM6IGJlYXJlcjoiICsgYXBuLmJlYXJlciArICIgIT0gIgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyAicmFkaW9UZWNoOiIgKyByYWRpb1RlY2gpOworICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICBpZiAoREJHKSB7CisgICAgICAgICAgICAgICAgICAgIGxvZygiYnVpbGRXYWl0aW5nQXBuczogY291bGRuJ3QgaGFuZGxlIHJlcXVlc2VkQXBuVHlwZT0iCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyByZXF1ZXN0ZWRBcG5UeXBlKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CisgICAgICAgICAgICB9CiAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICBsb2dlKCJtQWxsQXBucyBpcyBlbXB0eSEiKTsKICAgICAgICAgfQpAQCAtMjIwMywxNCArMjE4MSwxNSBAQAogICAgICAgICByZXR1cm4gcmVzdWx0LnRvU3RyaW5nKCk7CiAgICAgfQogCi0gICAgcHJpdmF0ZSB2b2lkIHN0YXJ0RGVsYXllZFJldHJ5KEdzbURhdGFDb25uZWN0aW9uLkZhaWxDYXVzZSBjYXVzZSwKKyAgICBwcml2YXRlIHZvaWQgc3RhcnREZWxheWVkUmV0cnkoRGF0YUNvbm5lY3Rpb24uRmFpbENhdXNlIGNhdXNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBcG5Db250ZXh0IGFwbkNvbnRleHQsIGludCByZXRyeU92ZXJyaWRlKSB7CisgICAgICAgIGFwbkNvbnRleHQuc2V0U3RhdGUoRGN0Q29uc3RhbnRzLlN0YXRlLkZBSUxFRCk7CiAgICAgICAgIG5vdGlmeU5vRGF0YShjYXVzZSwgYXBuQ29udGV4dCk7CiAgICAgICAgIHJlY29ubmVjdEFmdGVyRmFpbChjYXVzZSwgYXBuQ29udGV4dCwgcmV0cnlPdmVycmlkZSk7CiAgICAgfQogCiAgICAgcHJpdmF0ZSB2b2lkIHNldFByZWZlcnJlZEFwbihpbnQgcG9zKSB7Ci0gICAgICAgIGlmICghY2FuU2V0UHJlZmVyQXBuKSB7CisgICAgICAgIGlmICghbUNhblNldFByZWZlckFwbikgewogICAgICAgICAgICAgbG9nKCJzZXRQcmVmZXJyZWRBcG46IFggIWNhblNFdFByZWZlckFwbiIpOwogICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICB9CkBAIC0yMjM4LDE2ICsyMjE3LDE5IEBACiAgICAgICAgICAgICAgICAgbnVsbCwgbnVsbCwgVGVsZXBob255LkNhcnJpZXJzLkRFRkFVTFRfU09SVF9PUkRFUik7CiAKICAgICAgICAgaWYgKGN1cnNvciAhPSBudWxsKSB7Ci0gICAgICAgICAgICBjYW5TZXRQcmVmZXJBcG4gPSB0cnVlOworICAgICAgICAgICAgbUNhblNldFByZWZlckFwbiA9IHRydWU7CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICBjYW5TZXRQcmVmZXJBcG4gPSBmYWxzZTsKKyAgICAgICAgICAgIG1DYW5TZXRQcmVmZXJBcG4gPSBmYWxzZTsKICAgICAgICAgfQorICAgICAgICBsb2coImdldFByZWZlcnJlZEFwbjogbVJlcXVlc3RlZEFwblR5cGU9IiArIG1SZXF1ZXN0ZWRBcG5UeXBlICsgIiBjdXJzb3I9IiArIGN1cnNvcgorICAgICAgICAgICAgICAgICsgIiBjdXJzb3IuY291bnQ9IiArICgoY3Vyc29yICE9IG51bGwpID8gY3Vyc29yLmdldENvdW50KCkgOiAwKSk7CiAKLSAgICAgICAgaWYgKGNhblNldFByZWZlckFwbiAmJiBjdXJzb3IuZ2V0Q291bnQoKSA+IDApIHsKKyAgICAgICAgaWYgKG1DYW5TZXRQcmVmZXJBcG4gJiYgY3Vyc29yLmdldENvdW50KCkgPiAwKSB7CiAgICAgICAgICAgICBpbnQgcG9zOwogICAgICAgICAgICAgY3Vyc29yLm1vdmVUb0ZpcnN0KCk7CiAgICAgICAgICAgICBwb3MgPSBjdXJzb3IuZ2V0SW50KGN1cnNvci5nZXRDb2x1bW5JbmRleE9yVGhyb3coVGVsZXBob255LkNhcnJpZXJzLl9JRCkpOwogICAgICAgICAgICAgZm9yKEFwblNldHRpbmcgcDptQWxsQXBucykgeworICAgICAgICAgICAgICAgIGxvZygiZ2V0UHJlZmVycmVkQXBuOiBhcG5TZXR0aW5nPSIgKyBwKTsKICAgICAgICAgICAgICAgICBpZiAocC5pZCA9PSBwb3MgJiYgcC5jYW5IYW5kbGVUeXBlKG1SZXF1ZXN0ZWRBcG5UeXBlKSkgewogICAgICAgICAgICAgICAgICAgICBsb2coImdldFByZWZlcnJlZEFwbjogWCBmb3VuZCBhcG5TZXR0aW5nIiArIHApOwogICAgICAgICAgICAgICAgICAgICBjdXJzb3IuY2xvc2UoKTsKQEAgLTI0MjMsMTAgKzI0MDUsMTAgQEAKIAogICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIGR1bXAoRmlsZURlc2NyaXB0b3IgZmQsIFByaW50V3JpdGVyIHB3LCBTdHJpbmdbXSBhcmdzKSB7Ci0gICAgICAgIHB3LnByaW50bG4oIkdzbURhdGFDb25uZWN0aW9uVHJhY2tlciBleHRlbmRzOiIpOworICAgICAgICBwdy5wcmludGxuKCJEYXRhQ29ubmVjdGlvblRyYWNrZXIgZXh0ZW5kczoiKTsKICAgICAgICAgc3VwZXIuZHVtcChmZCwgcHcsIGFyZ3MpOwogICAgICAgICBwdy5wcmludGxuKCIgbVJlcmVnaXN0ZXJPblJlY29ubmVjdEZhaWx1cmU9IiArIG1SZXJlZ2lzdGVyT25SZWNvbm5lY3RGYWlsdXJlKTsKLSAgICAgICAgcHcucHJpbnRsbigiIGNhblNldFByZWZlckFwbj0iICsgY2FuU2V0UHJlZmVyQXBuKTsKKyAgICAgICAgcHcucHJpbnRsbigiIGNhblNldFByZWZlckFwbj0iICsgbUNhblNldFByZWZlckFwbik7CiAgICAgICAgIHB3LnByaW50bG4oIiBtQXBuT2JzZXJ2ZXI9IiArIG1BcG5PYnNlcnZlcik7CiAgICAgICAgIHB3LnByaW50bG4oIiBnZXRPdmVyYWxsU3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ldHVwQ291bnRlciA9IGludGVudC5nZXRJbnRFeHRyYShGQUlMX0RBVEFfU0VUVVBfQ09VTlRFUiwgMSk7Ci0gICAgICAgICAgICAgICAgbUZhaWxEYXRhU2V0dXBGYWlsQ2F1c2UgPSBGYWlsQ2F1c2UuZnJvbUludCgKLSAgICAgICAgICAgICAgICAgICAgICAgIGludGVudC5nZXRJbnRFeHRyYShGQUlMX0RBVEFfU0VUVVBfRkFJTF9DQVVTRSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBGYWlsQ2F1c2UuRVJST1JfVU5TUEVDSUZJRUQuZ2V0RXJyb3JDb2RlKCkpKTsKLSAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coInNldCBtRmFpbERhdGFTZXR1cENvdW50ZXI9IiArIG1GYWlsRGF0YVNldHVwQ291bnRlciArCi0gICAgICAgICAgICAgICAgICAgICAgICAiIG1GYWlsRGF0YVNldHVwRmFpbENhdXNlPSIgKyBtRmFpbERhdGFTZXR1cEZhaWxDYXVzZSk7CisgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJXSUZJX1NUQVRFX0NIQU5HRURfQUNUSU9OOiBlbmFibGVkPSIgKyBlbmFibGVkCisgICAgICAgICAgICAgICAgICAgICAgICArICIgbUlzV2lmaUNvbm5lY3RlZD0iICsgbUlzV2lmaUNvbm5lY3RlZCk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICB9OwpAQCAtMzcyLDM1ICszNTgsMTcgQEAKICAgICAgICAgICAgIHJ4UGt0cyA9IC0xOwogICAgICAgICB9CiAKKyAgICAgICAgQE92ZXJyaWRlCiAgICAgICAgIHB1YmxpYyBTdHJpbmcgdG9TdHJpbmcoKSB7CiAgICAgICAgICAgICByZXR1cm4gInt0eFN1bT0iICsgdHhQa3RzICsgIiByeFN1bT0iICsgcnhQa3RzICsgIn0iOwogICAgICAgICB9CiAKICAgICAgICAgcHVibGljIHZvaWQgdXBkYXR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ICAgICAgaWYgKGRhdGFFbmFibGVkW2lkXSkgeworICAgICAgICAgICAgaWYgKG1EYXRhRW5hYmxlZFtpZF0pIHsKICAgICAgICAgICAgICAgICBtUGhvbmUubm90aWZ5RGF0YUNvbm5lY3Rpb24ocmVhc29uLCBhcG5JZFRvVHlwZShpZCkpOwogICAgICAgICAgICAgfQogICAgICAgICB9CkBAIC04MjEsNyArNzg4LDYgQEAKICAgICBwcml2YXRlIHZvaWQgbm90aWZ5QXBuSWRVcFRvQ3VycmVudChTdHJpbmcgcmVhc29uLCBpbnQgYXBuSWQpIHsKICAgICAgICAgc3dpdGNoIChtU3RhdGUpIHsKICAgICAgICAgICAgIGNhc2UgSURMRToKLSAgICAgICAgICAgIGNhc2UgSU5JVElORzoKICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIGNhc2UgQ09OTkVDVElORzoKICAgICAgICAgICAgIGNhc2UgU0NBTk5JTkc6CkBAIC04MzUsNiArODAxLDkgQEAKICAgICAgICAgICAgICAgICBtUGhvbmUubm90aWZ5RGF0YUNvbm5lY3Rpb24ocmVhc29uLCBhcG5JZFRvVHlwZShhcG5JZCksCiAgICAgICAgICAgICAgICAgICAgICAgICBQaG9uZUNvbnN0YW50cy5EYXRhU3RhdGUuQ09OTkVDVEVEKTsKICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgLy8gSW5nb3JlCisgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIH0KICAgICB9CiAKQEAgLTg2NCw3ICs4MzMsNyBAQAogCiAgICAgcHJvdGVjdGVkIHN5bmNocm9uaXplZCBib29sZWFuIGlzQXBuSWRFbmFibGVkKGludCBpZCkgewogICAgICAgICBpZiAoaWQgIT0gRGN0Q29uc3RhbnRzLkFQTl9JTlZBTElEX0lEKSB7Ci0gICAgICAgICAgICByZXR1cm4gZGF0YUVuYWJsZWRbaWRdOworICAgICAgICAgICAgcmV0dXJuI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Jvb2xlYW4gZW5hYmxlKSB7CiAgICAgICAgIGlmIChEQkcpIHsKLSAgICAgICAgICAgIGxvZygic2V0RW5hYmxlZCgiICsgaWQgKyAiLCAiICsgZW5hYmxlICsgIikgd2l0aCBvbGQgc3RhdGUgPSAiICsgZGF0YUVuYWJsZWRbaWRdCi0gICAgICAgICAgICAgICAgICAgICsgIiBhbmQgZW5hYmxlZENvdW50ID0gIiArIGVuYWJsZWRDb3VudCk7CisgICAgICAgICAgICBsb2coInNldEVuYWJsZWQoIiArIGlkICsgIiwgIiArIGVuYWJsZSArICIpIHdpdGggb2xkIHN0YXRlID0gIiArIG1EYXRhRW5hYmxlZFtpZF0KKyAgICAgICAgICAgICAgICAgICAgKyAiIGFuZCBlbmFibGVkQ291bnQgPSAiICsgbUVuYWJsZWRDb3VudCk7CiAgICAgICAgIH0KICAgICAgICAgTWVzc2FnZSBtc2cgPSBvYnRhaW5NZXNzYWdlKERjdENvbnN0YW50cy5FVkVOVF9FTkFCTEVfTkVXX0FQTik7CiAgICAgICAgIG1zZy5hcmcxID0gaWQ7CkBAIC05NTMsMTUgKzkyMiwxNSBAQAogICAgIHByb3RlY3RlZCB2b2lkIG9uRW5hYmxlQXBuKGludCBhcG5JZCwgaW50IGVuYWJsZWQpIHsKICAgICAgICAgaWYgKERCRykgewogICAgICAgICAgICAgbG9nKCJFVkVOVF9BUE5fRU5BQkxFX1JFUVVFU1QgYXBuSWQ9IiArIGFwbklkICsgIiwgYXBuVHlwZT0iICsgYXBuSWRUb1R5cGUoYXBuSWQpICsKLSAgICAgICAgICAgICAgICAgICAgIiwgZW5hYmxlZD0iICsgZW5hYmxlZCArICIsIGRhdGFFbmFibGVkID0gIiArIGRhdGFFbmFibGVkW2FwbklkXSArCi0gICAgICAgICAgICAgICAgICAgICIsIGVuYWJsZWRDb3VudCA9ICIgKyBlbmFibGVkQ291bnQgKyAiLCBpc0FwblR5cGVBY3RpdmUgPSAiICsKKyAgICAgICAgICAgICAgICAgICAgIiwgZW5hYmxlZD0iICsgZW5hYmxlZCArICIsIGRhdGFFbmFibGVkID0gIiArIG1EYXRhRW5hYmxlZFthcG5JZF0gKworICAgICAgICAgICAgICAgICAgICAiLCBlbmFibGVkQ291bnQgPSAiICsgbUVuYWJsZWRDb3VudCArICIsIGlzQXBuVHlwZUFjdGl2ZSA9ICIgKwogICAgICAgICAgICAgICAgICAgICBpc0FwblR5cGVBY3RpdmUoYXBuSWRUb1R5cGUoYXBuSWQpKSk7CiAgICAgICAgIH0KICAgICAgICAgaWYgKGVuYWJsZWQgPT0gRGN0Q29uc3RhbnRzLkVOQUJMRUQpIHsKICAgICAgICAgICAgIHN5bmNocm9uaXplZCAodGhpcykgewotICAgICAgICAgICAgICAgIGlmICghZGF0YUVuYWJsZWRbYXBuSWRdKSB7Ci0gICAgICAgICAgICAgICAgICAgIGRhdGFFbmFibGVkW2FwbklkXSA9IHRydWU7Ci0gICAgICAgICAgICAgICAgICAgIGVuYWJsZWRDb3VudCsrOworICAgICAgICAgICAgICAgIGlmICghbURhdGFFbmFibGVkW2FwbklkXSkgeworICAgICAgICAgICAgICAgICAgICBtRGF0YUVuYWJsZWRbYXBuSWRdID0gdHJ1ZTsKKyAgICAgICAgICAgICAgICAgICAgbUVuYWJsZWRDb3VudCsrOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KICAgICAgICAgICAgIFN0cmluZyB0eXBlID0gYXBuSWRUb1R5cGUoYXBuSWQpOwpAQCAtOTc1LDE0ICs5NDQsMTQgQEAKICAgICAgICAgICAgIC8vIGRpc2FibGUKICAgICAgICAgICAgIGJvb2xlYW4gZGlkRGlzYWJsZSA9IGZhbHNlOwogICAgICAgICAgICAgc3luY2hyb25pemVkICh0aGlzKSB7Ci0gICAgICAgICAgICAgICAgaWYgKGRhdGFFbmFibGVkW2FwbklkXSkgewotICAgICAgICAgICAgICAgICAgICBkYXRhRW5hYmxlZFthcG5JZF0gPSBmYWxzZTsKLSAgICAgICAgICAgICAgICAgICAgZW5hYmxlZENvdW50LS07CisgICAgICAgICAgICAgICAgaWYgKG1EYXRhRW5hYmxlZFthcG5JZF0pIHsKKyAgICAgICAgICAgICAgICAgICAgbURhdGFFbmFibGVkW2FwbklkXSA9IGZhbHNlOworICAgICAgICAgICAgICAgICAgICBtRW5hYmxlZENvdW50LS07CiAgICAgICAgICAgICAgICAgICAgIGRpZERpc2FibGUgPSB0cnVlOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KICAgICAgICAgICAgIGlmIChkaWREaXNhYmxlKSB7Ci0gICAgICAgICAgICAgICAgaWYgKChlbmFibGVkQ291bnQgPT0gMCkgfHwgKGFwbklkID09IERjdENvbnN0YW50cy5BUE5fRFVOX0lEKSkgeworICAgICAgICAgICAgICAgIGlmICgobUVuYWJsZWRDb3VudCA9PSAwKSB8fCAoYXBuSWQgPT0gRGN0Q29uc3RhbnRzLkFQTl9EVU5fSUQpKSB7CiAgICAgICAgICAgICAgICAgICAgIG1SZXF1ZXN0ZWRBcG5UeXBlID0gUGhvbmVDb25zdGFudHMuQVBOX1RZUEVfREVGQVVMVDsKICAgICAgICAgICAgICAgICAgICAgb25DbGVhblVwQ29ubmVjdGlvbih0cnVlLCBhcG5JZCwgUGhvbmUuUkVBU09OX0RBVEFfRElTQUJMRUQpOwogICAgICAgICAgICAgICAgIH0KQEAgLTk5MCw3ICs5NTksNyBAQAogICAgICAgICAgICAgICAgIC8vIHNlbmQgdGhlIGRpc2Nvbm5lY3QgbXNnIG1hbnVhbGx5LCBzaW5jZSB0aGUgbm9ybWFsIHJvdXRlIHdvbnQgc2VuZAogICAgICAgICAgICAgICAgIC8vIGl0IChpdCdzIG5vdCBlbmFibGVkKQogICAgICAgICAgICAgICAgIG5vdGlmeUFwbklkRGlzY29ubmVjdGVkKFBob25lLlJFQVNPTl9EQVRBX0RJU0FCTEVELCBhcG5JZCk7Ci0gICAgICAgICAgICAgICAgaWYgKGRhdGFFbmFibGVkW0RjdENvbnN0YW50cy5BUE5fREVGQVVMVF9JRF0gPT0gdHJ1ZQorICAgICAgICAgICAgICAgIGlmIChtRGF0YUVuYWJsZWRbRGN0Q29uc3RhbnRzLkFQTl9ERUZBVUxUX0lEXSA9PSB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAmJiAhaXNBcG5UeXBlQWN0aXZlKFBob25lQ29uc3RhbnRzLkFQTl9UWVBFX0RFRkFVTFQpKSB7CiAgICAgICAgICAgICAgICAgICAgIC8vIFRPRE8gLSB0aGlzIGlzIGFuIHVnbHkgd2F5IHRvIHJlc3RvcmUgdGhlIGRlZmF1bHQgY29ubiAtIHNob3VsZCBiZSBkb25lCiAgICAgICAgICAgICAgICAgICAgIC8vIGJ5IGEgcmVhbCBjb250ZW50aW9uIG1hbmFnZXIgYW5kIHBvbGljeSB0aGF0IGRpc2Nvbm5lY3RzIHRoZSBsb3dlciBwcmkKQEAgLTExNDEsNyArMTExMCw3IEBACiAgICAgICAgIGZvciAoQXBuQ29udGV4dCBhYyA6IG1BcG5Db250ZXh0cy52YWx1ZXMoKSkgewogICAgICAgICAgICAgYWMuc2V0UmV0cnlDb3VudCgwKTsKICAgICAgICAgfQotICAgICAgICBmb3IgKERhdGFDb25uZWN0aW9uIGRjIDogbURhdGFDb25uZWN0aW9ucy52YWx1ZXMoKSkgeworICAgICAgICBmb3IgKERhdGFDb25uZWN0aW9uQmFzZSBkYyA6IG1EYXRhQ29ubmVjdGlvbnMudmFsdWVzKCkpIHsKICAgICAgICAgICAgIGRjLnJlc2V0UmV0cnlDb3VudCgpOwogICAgICAgICB9CiAgICAgfQpAQCAtMTI1MSw3ICsxMjIwLDcgQEAKICAgICAgICAgICAgICAgICBFdmVudExvZy53cml0ZUV2ZW50KEV2ZW50TG9nVGFncy5EQVRBX1NUQUxMX1JFQ09WRVJZX0dFVF9EQVRBX0NBTExfTElTVCwKICAgICAgICAgICAgICAgICAgICAgICAgIG1TZW50U2luY2VMYXN0UmVjdik7CiAgICAgICAgICAgICAgICAgaWYgKERCRykg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dHJ5IHsKICAgICAgICAgICAgICAgICAvL2RlYnVnU29ja2V0ID0gbmV3IExvY2FsU2VydmVyU29ja2V0KCJjb20uYW5kcm9pZC5pbnRlcm5hbC50ZWxlcGhvbnkuZGVidWciKTsKLSAgICAgICAgICAgICAgICBkZWJ1Z1NvY2tldCA9IG5ldyBTZXJ2ZXJTb2NrZXQoKTsKLSAgICAgICAgICAgICAgICBkZWJ1Z1NvY2tldC5zZXRSZXVzZUFkZHJlc3ModHJ1ZSk7Ci0gICAgICAgICAgICAgICAgZGVidWdTb2NrZXQuYmluZCAobmV3IEluZXRTb2NrZXRBZGRyZXNzKCIxMjcuMC4wLjEiLCA2NjY2KSk7CisgICAgICAgICAgICAgICAgbURlYnVnU29ja2V0ID0gbmV3IFNlcnZlclNvY2tldCgpOworICAgICAgICAgICAgICAgIG1EZWJ1Z1NvY2tldC5zZXRSZXVzZUFkZHJlc3ModHJ1ZSk7CisgICAgICAgICAgICAgICAgbURlYnVnU29ja2V0LmJpbmQgKG5ldyBJbmV0U29ja2V0QWRkcmVzcygiMTI3LjAuMC4xIiwgNjY2NikpOwogCi0gICAgICAgICAgICAgICAgZGVidWdQb3J0VGhyZWFkCisgICAgICAgICAgICAgICAgbURlYnVnUG9ydFRocmVhZAogICAgICAgICAgICAgICAgICAgICA9IG5ldyBUaHJlYWQoCiAgICAgICAgICAgICAgICAgICAgICAgICBuZXcgUnVubmFibGUoKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgQE92ZXJyaWRlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHVibGljIHZvaWQgcnVuKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IoOzspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU29ja2V0IHNvY2s7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc29jayA9IGRlYnVnU29ja2V0LmFjY2VwdCgpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvY2sgPSBtRGVidWdTb2NrZXQuYWNjZXB0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUmxvZy5pKExPR19UQUcsICJOZXcgY29ubmVjdGlvbjsgcmVzZXR0aW5nIHJhZGlvIik7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUNNLnJlc2V0UmFkaW8obnVsbCk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUNpLnJlc2V0UmFkaW8obnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc29jay5jbG9zZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoSU9FeGNlcHRpb24gZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBSbG9nLncoTE9HX1RBRywKQEAgLTE4OCw3ICsxODUsNyBAQAogICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICJHU01QaG9uZSBkZWJ1ZyIpOwogCi0gICAgICAgICAgICAgICAgZGVidWdQb3J0VGhyZWFkLnN0YXJ0KCk7CisgICAgICAgICAgICAgICAgbURlYnVnUG9ydFRocmVhZC5zdGFydCgpOwogCiAgICAgICAgICAgICB9IGNhdGNoIChJT0V4Y2VwdGlvbiBleCkgewogICAgICAgICAgICAgICAgIFJsb2cudyhMT0dfVEFHLCAiRmFpbHVyZSB0byBvcGVuIGNvbS5hbmRyb2lkLmludGVybmFsLnRlbGVwaG9ueS5kZWJ1ZyBzb2NrZXQiLCBleCk7CkBAIC0yMDYsMTMgKzIwMywxMyBAQAogICAgICAgICAgICAgc3VwZXIuZGlzcG9zZSgpOwogCiAgICAgICAgICAgICAvL1VucmVnaXN0ZXIgZnJv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AgICAgICBzdXBlci5yZW1vdmVSZWZlcmVuY2VzKCk7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHJvdGVjdGVkIHZvaWQgZmluYWxpemUoKSB7CiAgICAgICAgIGlmKExPQ0FMX0RFQlVHKSBSbG9nLmQoTE9HX1RBRywgIkdTTVBob25lIGZpbmFsaXplZCIpOwogICAgIH0KIAogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFNlcnZpY2VTdGF0ZQogICAgIGdldFNlcnZpY2VTdGF0ZSgpIHsKLSAgICAgICAgcmV0dXJuIG1TU1Quc3M7CisgICAgICAgIHJldHVybiBtU1NULm1TUzsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgQ2VsbExvY2F0aW9uIGdldENlbGxMb2NhdGlvbigpIHsKLSAgICAgICAgcmV0dXJuIG1TU1QuY2VsbExvYzsKKyAgICAgICAgcmV0dXJuIG1TU1QubUNlbGxMb2M7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFBob25lQ29uc3RhbnRzLlN0YXRlIGdldFN0YXRlKCkgewotICAgICAgICByZXR1cm4gbUNULnN0YXRlOworICAgICAgICByZXR1cm4gbUNULm1TdGF0ZTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgU3RyaW5nIGdldFBob25lTmFtZSgpIHsKICAgICAgICAgcmV0dXJuICJHU00iOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBpbnQgZ2V0UGhvbmVUeXBlKCkgewogICAgICAgICByZXR1cm4gUGhvbmVDb25zdGFudHMuUEhPTkVfVFlQRV9HU007CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFNlcnZpY2VTdGF0ZVRyYWNrZXIgZ2V0U2VydmljZVN0YXRlVHJhY2tlcigpIHsKICAgICAgICAgcmV0dXJuIG1TU1Q7CiAgICAgfQogCisgICAgQE92ZXJyaWRlC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otICAgICAgICAgICAgICAgICAgICBpZiAoIG1DVC5zdGF0ZSAhPSBQaG9uZUNvbnN0YW50cy5TdGF0ZS5JRExFCisgICAgICAgICAgICAgICAgICAgIGlmICggbUNULm1TdGF0ZSAhPSBQaG9uZUNvbnN0YW50cy5TdGF0ZS5JRExFCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJiYgIW1TU1QuaXNDb25jdXJyZW50Vm9pY2VBbmREYXRhQWxsb3dlZCgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICByZXQgPSBQaG9uZUNvbnN0YW50cy5EYXRhU3RhdGUuU1VTUEVOREVEOwogICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewpAQCAtMzEzLDcgKzMyMCw2IEBACiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBicmVhazsKIAotICAgICAgICAgICAgICAgIGNhc2UgSU5JVElORzoKICAgICAgICAgICAgICAgICBjYXNlIENPTk5FQ1RJTkc6CiAgICAgICAgICAgICAgICAgY2FzZSBTQ0FOTklORzoKICAgICAgICAgICAgICAgICAgICAgcmV0ID0gUGhvbmVDb25zdGFudHMuRGF0YVN0YXRlLkNPTk5FQ1RJTkc7CkBAIC0zMjQsMTAgKzMzMCwxMSBAQAogICAgICAgICByZXR1cm4gcmV0OwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBEYXRhQWN0aXZpdHlTdGF0ZSBnZXREYXRhQWN0aXZpdHlTdGF0ZSgpIHsKICAgICAgICAgRGF0YUFjdGl2aXR5U3RhdGUgcmV0ID0gRGF0YUFjdGl2aXR5U3RhdGUuTk9ORTsKIAotICAgICAgICBpZiAobVNTVC5nZXRDdXJyZW50R3Byc1N0YXRlKCkgPT0gU2VydmljZVN0YXRlLlNUQVRFX0lOX1NFUlZJQ0UpIHsKKyAgICAgICAgaWYgKG1TU1QuZ2V0Q3VycmVudERhdGFDb25uZWN0aW9uU3RhdGUoKSA9PSBTZXJ2aWNlU3RhdGUuU1RBVEVfSU5fU0VSVklDRSkgewogICAgICAgICAgICAgc3dpdGNoIChtRGF0YUNvbm5lY3Rpb25UcmFja2VyLmdldEFjdGl2aXR5KCkpIHsKICAgICAgICAgICAgICAgICBjYXNlIERBVEFJTjoKICAgICAgICAgICAgICAgICAgICAgcmV0ID0gRGF0YUFjdGl2aXR5U3RhdGUuREFUQUlOOwpAQCAtMzQ0LDYgKzM1MSwxMCBAQAogICAgICAgICAgICAgICAgIGNhc2UgRE9STUFOVDoKICAgICAgICAgICAgICAgICAgICAgcmV0ID0gRGF0YUFjdGl2aXR5U3RhdGUuRE9STUFOVDsKICAgICAgICAgICAgICAgICBicmVhazsKKworICAgICAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgICAgIHJldCA9IERhdGFBY3Rpdml0eVN0YXRlLk5PTkU7CisgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KIApAQCAtMzUxLDE1ICszNjIsMTcgQEAKICAgICB9CiAKICAgICAvKioKLSAgICAgKiBOb3RpZnkgYW55IGludGVyZXN0ZWQgcGFydHkgb2YgYSBQaG9uZSBzdGF0ZSBjaGFuZ2Uge0BsaW5rIFBob25lQ29uc3RhbnRzLlN0YXRlfQorICAgICAqIE5vdGlmeSBhbnkgaW50ZXJlc3RlZCBwYXJ0eSBvZiBhIFBob25lIHN0YXRlIGNoYW5nZQorICAgICAqIHtAbGluayBjb20uYW5kcm9pZC5pbnRlcm5hbC50ZWxlcGhvbnkuUGhvbmVDb25zdGFudHMuU3RhdGV9CiAgICAgICovCiAgICAgLypwYWNrYWdlKi8gdm9pZCBub3RpZnlQaG9uZVN0YXRlQ2hhbmdlZCgpIHsKICAgICAgICAgbU5vdGlmaWVyLm5vdGlmeVBob25lU3RhdGUodGhpcyk7CiAgICAgfQogCiAgICAgLyoqCi0gICAgICogTm90aWZ5IHJlZ2lzdHJhbnRzIG9mIGEgY2hhbmdlIGluIHRoZSBjYWxs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wdWJsaWMgdm9pZCBleHBsaWNpdENhbGxUcmFuc2ZlcigpIHRocm93cyBDYWxsU3RhdGVFeGNlcHRpb24geworICAgIEBPdmVycmlkZQorICAgIHB1YmxpYyB2b2lkIGV4cGxpY2l0Q2FsbFRyYW5zZmVyKCkgewogICAgICAgICBtQ1QuZXhwbGljaXRDYWxsVHJhbnNmZXIoKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgR3NtQ2FsbAogICAgIGdldEZvcmVncm91bmRDYWxsKCkgewotICAgICAgICByZXR1cm4gbUNULmZvcmVncm91bmRDYWxsOworICAgICAgICByZXR1cm4gbUNULm1Gb3JlZ3JvdW5kQ2FsbDsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgR3NtQ2FsbAogICAgIGdldEJhY2tncm91bmRDYWxsKCkgewotICAgICAgICByZXR1cm4gbUNULmJhY2tncm91bmRDYWxsOworICAgICAgICByZXR1cm4gbUNULm1CYWNrZ3JvdW5kQ2FsbDsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgR3NtQ2FsbAogICAgIGdldFJpbmdpbmdDYWxsKCkgewotICAgICAgICByZXR1cm4gbUNULnJpbmdpbmdDYWxsOworICAgICAgICByZXR1cm4gbUNULm1SaW5naW5nQ2FsbDsKICAgICB9CiAKICAgICBwcml2YXRlIGJvb2xlYW4gaGFuZGxlQ2FsbERlZmxlY3Rpb25JbmNhbGxTdXBwbGVtZW50YXJ5U2VydmljZSgKLSAgICAgICAgICAgIFN0cmluZyBkaWFsU3RyaW5nKSB0aHJvd3MgQ2FsbFN0YXRlRXhjZXB0aW9uIHsKKyAgICAgICAgICAgIFN0cmluZyBkaWFsU3RyaW5nKSB7CiAgICAgICAgIGlmIChkaWFsU3RyaW5nLmxlbmd0aCgpID4gMSkgewogICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICB9CkBAIC00OTksMTQgKzUyNywxNCBAQ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KTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZAogICAgIHNlbmREdG1mKGNoYXIgYykgewogICAgICAgICBpZiAoIVBob25lTnVtYmVyVXRpbHMuaXMxMktleShjKSkgewogICAgICAgICAgICAgUmxvZy5lKExPR19UQUcsCiAgICAgICAgICAgICAgICAgICAgICJzZW5kRHRtZiBjYWxsZWQgd2l0aCBpbnZhbGlkIGNoYXJhY3RlciAnIiArIGMgKyAiJyIpOwogICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgaWYgKG1DVC5zdGF0ZSA9PSAgUGhvbmVDb25zdGFudHMuU3RhdGUuT0ZGSE9PSykgewotICAgICAgICAgICAgICAgIG1DTS5zZW5kRHRtZihjLCBudWxsKTsKKyAgICAgICAgICAgIGlmIChtQ1QubVN0YXRlID09ICBQaG9uZUNvbnN0YW50cy5TdGF0ZS5PRkZIT09LKSB7CisgICAgICAgICAgICAgICAgbUNpLnNlbmREdG1mKGMsIG51bGwpOwogICAgICAgICAgICAgfQogICAgICAgICB9CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQKICAgICBzdGFydER0bWYoY2hhciBjKSB7CiAgICAgICAgIGlmICghUGhvbmVOdW1iZXJVdGlscy5pczEyS2V5KGMpKSB7CiAgICAgICAgICAgICBSbG9nLmUoTE9HX1RBRywKICAgICAgICAgICAgICAgICAic3RhcnREdG1mIGNhbGxlZCB3aXRoIGludmFsaWQgY2hhcmFjdGVyICciICsgYyArICInIik7CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICBtQ00uc3RhcnREdG1mKGMsIG51bGwpOworICAgICAgICAgICAgbUNpLnN0YXJ0RHRtZihjLCBudWxsKTsKICAgICAgICAgfQogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkCiAgICAgc3RvcER0bWYoKSB7Ci0gICAgICAgIG1DTS5zdG9wRHRtZihudWxsKTsKKyAgICAgIC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AgcHVibGljIFN0cmluZyBnZXREZXZpY2VTdm4oKSB7CiAgICAgICAgIHJldHVybiBtSW1laVN2OwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdHJpbmcgZ2V0SW1laSgpIHsKICAgICAgICAgcmV0dXJuIG1JbWVpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdHJpbmcgZ2V0RXNuKCkgewogICAgICAgICBSbG9nLmUoTE9HX1RBRywgIltHU01QaG9uZV0gZ2V0RXNuKCkgaXMgYSBDRE1BIG1ldGhvZCIpOwogICAgICAgICByZXR1cm4gIjAiOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdHJpbmcgZ2V0TWVpZCgpIHsKICAgICAgICAgUmxvZy5lKExPR19UQUcsICJbR1NNUGhvbmVdIGdldE1laWQoKSBpcyBhIENETUEgbWV0aG9kIik7CiAgICAgICAgIHJldHVybiAiMCI7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFN0cmluZyBnZXRTdWJzY3JpYmVySWQoKSB7CiAgICAgICAgIEljY1JlY29yZHMgciA9IG1JY2NSZWNvcmRzLmdldCgpOwogICAgICAgICByZXR1cm4gKHIgIT0gbnVsbCkgPyByLmdldElNU0koKSA6IG51bGw7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFN0cmluZyBnZXRMaW5lMU51bWJlcigpIHsKICAgICAgICAgSWNjUmVjb3JkcyByID0gbUljY1JlY29yZHMuZ2V0KCk7CiAgICAgICAgIHJldHVybiAociAhPSBudWxsKSA/IHIuZ2V0TXNpc2RuTnVtYmVyKCkgOiBudWxsOwpAQCAtODY3LDExICs4OTcsMTMgQEAKICAgICAgICAgcmV0dXJuIChyICE9IG51bGwpID8gci5nZXRNc2lzZG5OdW1iZXIoKSA6ICIiOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdHJpbmcgZ2V0TGluZTFBbHBoYVRhZygpIHsKICAgICAgICAgSWNjUmVjb3JkcyByID0gbUljY1JlY29yZHMuZ2V0KCk7CiAgICAgICAgIHJldHVybiAociAhPSBudWxsKSA/IHIuZ2V0TXNpc2RuQWxwaGFUYWcoKSA6ICIiOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHNldExpbmUxTnVtYmVyKFN0cmluZyBhbHBoYVRhZywgU3RyaW5nIG51bWJlciwgTWVzc2FnZSBvbkNvbXBsZXRlKSB7CiAgICAgICAgIEljY1JlY29yZHMgciA9IG1JY2NSZWNvcmRzLmdldCgpOwogICAgICAgICBpZiAociAhPSBudWxsKSB7CkBAIC04NzksNiArOTExLDcgQEAKICAgICAgICAgfQogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHNldFZvaWNlTWFpbE51bWJlcihTdHJpbmcgYWxwaGFUYWcsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nIHZvaWNlTWFpbE51bWJlciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNZXNzYWdlIG9uQ29tcGxldGUpIHsKQEAgLTkyMiw2ICs5NTUsNyBAQAogICAgICAgICByZXR1cm4gKGFjdGlvbiA9PSBDRl9BQ1RJT05fRU5BQkxFKSB8fCAoYWN0aW9uID09IENGX0FDVElPTl9SRUdJU1RSQVRJT04pOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIGdldENhbGxGb3J3YXJkaW5nT3B0aW9uKGludCBjb21tYW5kSW50ZXJmYWNlQ0ZSZWFzb24sIE1lc3NhZ2Ugb25Db21wbGV0ZSkgewogICAgICAgICBpZiAoaXNWYWxpZENvbW1hbmRJbnRlcmZhY2VDRlJlYXNvbihjb21tYW5kSW50ZXJmYWNlQ0ZSZWFzb24pKSB7CiAgICAgICAgICAgICBpZiAoTE9DQUxfREVCVUcpIFJsb2cuZChMT0dfVEFHLCAicmVxdWVzdGluZyBjYWxsIGZvcndhcmRpbmcgcXVlcnkuIik7CkBAIC05MzEsMTAgKzk2NSwxMSBAQAogICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICByZXNwID0gb25Db21wbGV0ZTsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIG1DTS5xdWVyeUNhbGxGb3J3YXJkU3RhdHVzKGNvbW1hbmRJbnRlcmZhY2VDRlJlYXNvbiwwLG51bGwscmVzcCk7CisgICAgICAgICAgICBtQ2kucXVlcnlDYWxsRm9yd2FyZFN0YXR1cyhjb21tYW5kSW50ZXJmYWNlQ0ZSZWFzb24sMCxudWxsLHJlc3ApOwogICAgICAgICB9CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgc2V0Q2FsbEZvcndhcmRpbmdPcHRpb24oaW50IGNvbW1hbmRJbnRlcmZhY2VDRkFjdGlvbiwKICAgICAgICAgICAgIGludCBjb21tYW5kSW50ZXJmYWNlQ0ZSZWFzb24sCiAgICAgICAgICAgICBTdHJpbmcgZGlhbGluZ051bWJlciwKQEAgLTk1MCw3ICs5ODUsNyBAQAogICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICByZXNwID0gb25Db21wbGV0ZTsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIG1DTS5zZXRDYWxsRm9yd2FyZChjb21tYW5kSW50ZXJmYWNlQ0ZBY3Rpb24sCisgICAgICAgICAgICBtQ2kuc2V0Q2FsbEZvcndhcmQoY29tbWFuZEludGVyZmFjZUNGQWN0aW9uLAogICAgICAgICAgICAgICAgICAgICBjb21tYW5kSW50ZXJmYWNlQ0ZSZWFzb24sCiAgICAgICAgICAgICAgICAgICAgIENvbW1hbmRzSW50ZXJmYWNlLlNFUlZJQ0VfQ0xBU1NfVk9JQ0UsCiAgICAgICAgICAgICAgICAgICAgIGRpYWxpbmdOdW1iZXIsCkBAIC05NTksMjkgKzk5NCwzNCBAQ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ICBwdWJsaWMgdm9pZCBzZXRPblBvc3REaWFsQ2hhcmFjdGVyKEhhbmRsZXIgaCwgaW50IHdoYXQsIE9iamVjdCBvYmopIHsKICAgICAgICAgbVBvc3REaWFsSGFuZGxlciA9IG5ldyBSZWdpc3RyYW50KGgsIHdoYXQsIG9iaik7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgc2V0TXV0ZShib29sZWFuIG11dGVkKSB7CiAgICAgICAgIG1DVC5zZXRNdXRlKG11dGVkKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgYm9vbGVhbiBnZXRNdXRlKCkgewogICAgICAgICByZXR1cm4gbUNULmdldE11dGUoKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBnZXREYXRhQ2FsbExpc3QoTWVzc2FnZSByZXNwb25zZSkgewotICAgICAgICBtQ00uZ2V0RGF0YUNhbGxMaXN0KHJlc3BvbnNlKTsKKyAgICAgICAgbUNpLmdldERhdGFDYWxsTGlzdChyZXNwb25zZSk7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgdXBkYXRlU2VydmljZUxvY2F0aW9uKCkgewogICAgICAgICBtU1NULmVuYWJsZVNpbmdsZUxvY2F0aW9uVXBkYXRlKCk7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgZW5hYmxlTG9jYXRpb25VcGRhdGVzKCkgewogICAgICAgICBtU1NULmVuYWJsZUxvY2F0aW9uVXBkYXRlcygpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIGRpc2FibGVMb2NhdGlvblVwZGF0ZXMoKSB7CiAgICAgICAgIG1TU1QuZGlzYWJsZUxvY2F0aW9uVXBkYXRlcygpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBib29sZWFuIGdldERhdGFSb2FtaW5nRW5hYmxlZCgpIHsKICAgICAgICAgcmV0dXJuIG1EYXRhQ29ubmVjdGlvblRyYWNrZXIuZ2V0RGF0YU9uUm9hbWluZ0VuYWJsZWQoKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBzZXREYXRhUm9hbWluZ0VuYWJsZWQoYm9vbGVhbiBlbmFibGUpIHsKICAgICAgICAgbURhdGFDb25uZWN0aW9uVHJhY2tlci5zZXREYXRhT25Sb2FtaW5nRW5hYmxlZChlbmFibGUpOwogICAgIH0KQEAgLTExNTIsNyArMTIwNCw3IEBACiAgICAgICAgIFNoYXJlZFByZWZlcmVuY2VzIHNwID0gUHJlZmVyZW5jZU1hbmFnZXIuZ2V0RGVmYXVsdFNoYXJlZFByZWZlcmVuY2VzKGdldENvbnRleHQoKSk7CiAgICAgICAgIGludCBjbGlyU2V0dGluZyA9IHNwLmdldEludChDTElSX0tFWSwgLTEpOwogICAgICAgICBpZiAoY2xpclNldHRpbmcgPj0gMCkgewotICAgICAgICAgICAgbUNNLnNldENMSVIoY2xpclNldHRpbmcsIG51bGwpOworICAgICAgICAgICAgbUNpLnNldENMSVIoY2xpclNldHRpbmcsIG51bGwpOwogICAgICAgICB9CiAgICAgfQogCkBAIC0xMTYzLDExICsxMjE1LDExIEBACiAKICAgICAgICAgc3dpdGNoIChtc2cud2hhdCkgewogICAgICAgICAgICAgY2FzZSBFVkVOVF9SQURJT19BVkFJTEFCTEU6IHsKLSAgICAgICAgICAgICAgICBtQ00uZ2V0QmFzZWJhbmRWZXJzaW9uKAorICAgICAgICAgICAgICAgIG1DaS5nZXRCYXNlYmFuZFZlcnNpb24oCiAgICAgICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX0dFVF9CQVNFQkFORF9WRVJTSU9OX0RPTkUpKTsKIAotICAgICAgICAgICAgICAgIG1DTS5nZXRJTUVJKG9idGFpbk1lc3NhZ2UoRVZFTlRfR0VUX0lN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2UqLwogICAgIEdzbUNhbGwgKEdzbUNhbGxUcmFja2VyIG93bmVyKSB7Ci0gICAgICAgIHRoaXMub3duZXIgPSBvd25lcjsKKyAgICAgICAgbU93bmVyID0gb3duZXI7CiAgICAgfQogCiAgICAgcHVibGljIHZvaWQgZGlzcG9zZSgpIHsKQEAgLTYyLDUwICs2MCw1NSBAQAogCiAgICAgLyoqKioqKioqKioqKioqKioqKioqKioqKioqIE92ZXJyaWRkZW4gZnJvbSBDYWxsICoqKioqKioqKioqKioqKioqKioqKioqKiovCiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgTGlzdDxDb25uZWN0aW9uPgogICAgIGdldENvbm5lY3Rpb25zKCkgewogICAgICAgICAvLyBGSVhNRSBzaG91bGQgcmV0dXJuIENvbGxlY3Rpb25zLnVubW9kaWZpYWJsZUxpc3QoKTsKLSAgICAgICAgcmV0dXJuIGNvbm5lY3Rpb25zOworICAgICAgICByZXR1cm4gbUNvbm5lY3Rpb25zOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBQaG9uZQogICAgIGdldFBob25lKCkgewotICAgICAgICByZXR1cm4gb3duZXIucGhvbmU7CisgICAgICAgIHJldHVybiBtT3duZXIubVBob25lOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBib29sZWFuCiAgICAgaXNNdWx0aXBhcnR5KCkgewotICAgICAgICByZXR1cm4gY29ubmVjdGlvbnMuc2l6ZSgpID4gMTsKKyAgICAgICAgcmV0dXJuIG1Db25uZWN0aW9ucy5zaXplKCkgPiAxOwogICAgIH0KIAogICAgIC8qKiBQbGVhc2Ugbm90ZTogaWYgdGhpcyBpcyB0aGUgZm9yZWdyb3VuZCBjYWxsIGFuZCBhCiAgICAgICogIGJhY2tncm91bmQgY2FsbCBleGlzdHMsIHRoZSBiYWNrZ3JvdW5kIGNhbGwgd2lsbCBiZSByZXN1bWVkCiAgICAgICogIGJlY2F1c2UgYW4gQVQrQ0h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VjdGlvbkRpc2Nvbm5lY3RlZChHc21Db25uZWN0aW9uIGNvbm4pIHsKLSAgICAgICAgaWYgKHN0YXRlICE9IFN0YXRlLkRJU0NPTk5FQ1RFRCkgeworICAgICAgICBpZiAobVN0YXRlICE9IFN0YXRlLkRJU0NPTk5FQ1RFRCkgewogICAgICAgICAgICAgLyogSWYgb25seSBkaXNjb25uZWN0ZWQgY29ubmVjdGlvbnMgcmVtYWluLCB3ZSBhcmUgZGlzY29ubmVjdGVkKi8KIAogICAgICAgICAgICAgYm9vbGVhbiBoYXNPbmx5RGlzY29ubmVjdGVkQ29ubmVjdGlvbnMgPSB0cnVlOwogCi0gICAgICAgICAgICBmb3IgKGludCBpID0gMCwgcyA9IGNvbm5lY3Rpb25zLnNpemUoKSAgOyBpIDwgczsgaSArKykgewotICAgICAgICAgICAgICAgIGlmIChjb25uZWN0aW9ucy5nZXQoaSkuZ2V0U3RhdGUoKQorICAgICAgICAgICAgZm9yIChpbnQgaSA9IDAsIHMgPSBtQ29ubmVjdGlvbnMuc2l6ZSgpICA7IGkgPCBzOyBpICsrKSB7CisgICAgICAgICAgICAgICAgaWYgKG1Db25uZWN0aW9ucy5nZXQoaSkuZ2V0U3RhdGUoKQogICAgICAgICAgICAgICAgICAgICAhPSBTdGF0ZS5ESVNDT05ORUNURUQKICAgICAgICAgICAgICAgICApIHsKICAgICAgICAgICAgICAgICAgICAgaGFzT25seURpc2Nvbm5lY3RlZENvbm5lY3Rpb25zID0gZmFsc2U7CkBAIC0xMjgsNyArMTMxLDcgQEAKICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgaWYgKGhhc09ubHlEaXNjb25uZWN0ZWRDb25uZWN0aW9ucykgewotICAgICAgICAgICAgICAgIHN0YXRlID0gU3RhdGUuRElTQ09OTkVDVEVEOworICAgICAgICAgICAgICAgIG1TdGF0ZSA9IFN0YXRlLkRJU0NPTk5FQ1RFRDsKICAgICAgICAgICAgIH0KICAgICAgICAgfQogICAgIH0KQEAgLTEzN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iKTsKIAogICAgICAgICByZXQgPSAoc2VydmljZVN0YXRlICE9IFNlcnZpY2VTdGF0ZS5TVEFURV9QT1dFUl9PRkYpCiAgICAgICAgICAgICAgICAgJiYgcGVuZGluZ01PID09IG51bGwKLSAgICAgICAgICAgICAgICAmJiAhcmluZ2luZ0NhbGwuaXNSaW5naW5nKCkKKyAgICAgICAgICAgICAgICAmJiAhbVJpbmdpbmdDYWxsLmlzUmluZ2luZygpCiAgICAgICAgICAgICAgICAgJiYgIWRpc2FibGVDYWxsLmVxdWFscygidHJ1ZSIpCi0gICAgICAgICAgICAgICAgJiYgKCFmb3JlZ3JvdW5kQ2FsbC5nZXRTdGF0ZSgpLmlzQWxpdmUoKQotICAgICAgICAgICAgICAgICAgICB8fCAhYmFja2dyb3VuZENhbGwuZ2V0U3RhdGUoKS5pc0FsaXZlKCkpOworICAgICAgICAgICAgICAgICYmICghbUZvcmVncm91bmRDYWxsLmdldFN0YXRlKCkuaXNBbGl2ZSgpCisgICAgICAgICAgICAgICAgICAgIHx8ICFtQmFja2dyb3VuZENhbGwuZ2V0U3RhdGUoKS5pc0FsaXZlKCkpOwogCiAgICAgICAgIHJldHVybiByZXQ7CiAgICAgfQogCiAgICAgYm9vbGVhbgogICAgIGNhblRyYW5zZmVyKCkgewotICAgICAgICByZXR1cm4gZm9yZWdyb3VuZENhbGwuZ2V0U3RhdGUoKSA9PSBHc21DYWxsLlN0YXRlLkFDVElWRQotICAgICAgICAgICAgICAgICYmIGJhY2tncm91bmRDYWxsLmdldFN0YXRlKCkgPT0gR3NtQ2FsbC5TdGF0ZS5IT0xESU5HOworICAgICAgICByZXR1cm4gbUZvcmVncm91bmRDYWxsLmdldFN0YXRlKCkgPT0gR3NtQ2FsbC5TdGF0ZS5BQ1RJVkUKKyAgICAgICAgICAgICAgICAmJiBtQmFja2dyb3VuZENhbGwuZ2V0U3RhdGUoKSA9PSBHc21DYWxsLlN0YXRlLkhPTERJTkc7CiAgICAgfQogCiAgICAgLy8qKioqK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tTmVlZHNQb2xsKTsKIAogICAgICAgICByZXR1cm4gb2J0YWluTWVzc2FnZSh3aGF0KTsKICAgICB9CiAKICAgICBwcml2YXRlIHZvaWQKICAgICBvcGVyYXRpb25Db21wbGV0ZSgpIHsKLSAgICAgICAgcGVuZGluZ09wZXJhdGlvbnMtLTsKKyAgICAgICAgbVBlbmRpbmdPcGVyYXRpb25zLS07CiAKICAgICAgICAgaWYgKERCR19QT0xMKSBsb2coIm9wZXJhdGlvbkNvbXBsZXRlOiBwZW5kaW5nT3BlcmF0aW9ucz0iICsKLSAgICAgICAgICAgICAgICBwZW5kaW5nT3BlcmF0aW9ucyArICIsIG5lZWRzUG9sbD0iICsgbmVlZHNQb2xsKTsKKyAgICAgICAgICAgICAgICBtUGVuZGluZ09wZXJhdGlvbnMgKyAiLCBuZWVkc1BvbGw9IiArIG1OZWVkc1BvbGwpOwogCi0gICAgICAgIGlmIChwZW5kaW5nT3BlcmF0aW9ucyA9PSAwICYmIG5lZWRzUG9sbCkgewotICAgICAgICAgICAgbGFzdFJlbGV2YW50UG9sbCA9IG9idGFpbk1lc3NhZ2UoRVZFTlRfUE9MTF9DQUxMU19SRVNVTFQpOwotICAgICAgICAgICAgY20uZ2V0Q3VycmVudENhbGxzKGxhc3RSZWxldmFudFBvbGwpOwotICAgICAgICB9IGVsc2UgaWYgKHBlbmRpbmdPcGVyYXRpb25zIDwgMCkgeworICAgICAgICBpZiAobVBlbmRpbmdPcGVyYXRpb25zID09IDAgJiYgbU5lZWRzUG9sbCkgeworICAgICAgICAgICAgbUxhc3RSZWxldmFudFBvbGwgPSBvYnRhaW5NZXNzYWdlKEVWRU5UX1BPTExfQ0FMTFNfUkVTVUxUKTsKKyAgICAgICAgICAgIG1DaS5nZXRDdXJyZW50Q2FsbHMobUxhc3RSZWxldmFudFBvbGwpOworICAgICAgICB9IGVsc2UgaWYgKG1QZW5kaW5nT3BlcmF0aW9ucyA8IDApIHsKICAgICAgICAgICAgIC8vIHRoaXMgc2hvdW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CgpOworICAgICAgICBpZiAobVN0YXRlICE9IG9sZFN0YXRlKSB7CisgICAgICAgICAgICBtUGhvbmUubm90aWZ5UGhvbmVTdGF0ZUNoYW5nZWQoKTsKICAgICAgICAgfQogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHByb3RlY3RlZCBzeW5jaHJvbml6ZWQgdm9pZAogICAgIGhhbmRsZVBvbGxDYWxscyhBc3luY1Jlc3VsdCBhcikgewogICAgICAgICBMaXN0IHBvbGxlZENhbGxzOwpAQCAtNDMzLDggKzQzOSw4IEBACiAgICAgICAgIGJvb2xlYW4gdW5rbm93bkNvbm5lY3Rpb25BcHBlYXJlZCA9IGZhbHNlOwogCiAgICAgICAgIGZvciAoaW50IGkgPSAwLCBjdXJEQyA9IDAsIGRjU2l6ZSA9IHBvbGxlZENhbGxzLnNpemUoKQotICAgICAgICAgICAgICAgIDsgaSA8IGNvbm5lY3Rpb25zLmxlbmd0aDsgaSsrKSB7Ci0gICAgICAgICAgICBHc21Db25uZWN0aW9uIGNvbm4gPSBjb25uZWN0aW9uc1tpXTsKKyAgICAgICAgICAgICAgICA7IGkgPCBtQ29ubmVjdGlvbnMubGVuZ3RoOyBpKyspIHsKKyAgICAgICAgICAgIEdzbUNvbm5lY3Rpb24gY29ubiA9IG1Db25uZWN0aW9uc1tpXTsKICAgICAgICAgICAgIERyaXZlckNhbGwgZGMgPSBudWxsOwogCiAgICAgICAgICAgICAvLyBwb2xsZWRDYWxsIGxpc3QgaXMgc3BhcnNlCkBAIC00NTgsMTggKzQ2NCwxOCBAQAogICAgICAgICAgICAgICAgICAgICBpZiAoREJHX1BPTEwpIGxvZygicG9sbDogcGVuZGluZ01PPSIgKyBwZW5kaW5nTU8pOwogCiAgICAgICAgICAgICAgICAgICAgIC8vIEl0J3Mgb3VyIHBlbmRpbmcgbW9iaWxlIG9yaWdpbmF0aW5nIGNhbGwKLSAgICAgICAgICAgICAgICAgICAgY29ubmVjdGlvbnNbaV0gPSBwZW5kaW5nTU87Ci0gICAgICAgICAgICAgICAgICAgIHBlbmRpbmdNTy5pbmRleCA9IGk7CisgICAgICAgICAgICAgICAgICAgIG1Db25uZWN0aW9uc1tpXSA9IHBlbmRpbmdNTzsKKyAgICAgICAgICAgICAgICAgICAgcGVuZGluZ01PLm1JbmRleCA9IGk7CiAgICAgICAgICAgICAgICAgICAgIHBlbmRpbmdNTy51cGRhdGUoZGMpOwogICAgICAgICAgICAgICAgICAgICBwZW5kaW5nTU8gPSBudWxsOwogCiAgICAgICAgICAgICAgICAgICAgIC8vIFNvbWVvbmUgaGFzIGFscmVhZHkgYXNrZWQgdG8gaGFuZ3VwIHRoaXMgY2FsbAotICAgICAgICAgICAgICAgICAgICBpZiAoaGFuZ3VwUGVuZGluZ01PKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBoYW5ndXBQZW5kaW5nTU8gPSBmYWxzZTsKKyAgICAgICAgICAgICAgICAgICAgaWYgKG1IYW5ndXBQZW5kaW5nTU8pIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1IYW5ndXBQZW5kaW5nTU8gPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKFBob25lLkRFQlVHX1BIT05FKSBsb2coCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAicG9sbDogaGFuZ3VwUGVuZGluZ01PLCBoYW5ndXAgY29ubiAiICsgaSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFuZ3VwKGNvbm5lY3Rpb25zW2ldKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYW5ndXAobUNvbm5lY3Rpb25zW2ldKTsKICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKENhbGxTdGF0ZUV4Y2VwdGlvbiBleCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgIFJsb2cuZShMT0dfVEFHLCAidW5leHBlY3RlZCBlcnJvciBvbiBoYW5ndXAiKTsKICAgICAgICAgICAgICAgICAgICAgICAgIH0KQEAgLTQ3OSwxMSArNDg1LDExIEBACiAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgICAgICBjb25uZWN0aW9uc1tpXSA9IG5ldyBHc21Db25uZWN0aW9uKHBob25lLmdldENvbnRleHQoKSwgZGMsIHRoaXMsIGkpOworICAgICAgICAgICAgICAgICAgICBtQ29ubmVjdGlvbnNbaV0gPSBuZXcgR3NtQ29ubmVjdGlvbihtUGhvbmUuZ2V0Q29udGV4dCgpLCBkYywgdGhpcywgaSk7CiAKICAgICAgICAgICAgICAgICAgICAgLy8gaXQncyBhIHJpbmdpbmcgY2FsbAotICAgICAgICAgICAgICAgICAgICBpZiAoY29ubmVjdGlvbnNbaV0uZ2V0Q2FsbCgpID09IHJpbmdpbmdDYWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBuZXdSaW5naW5nID0gY29ubmVjdGlvbnNbaV07CisgICAgICAgICAgICAgICAgICAgIGlmIChtQ29ubmVjdGlvbnNbaV0uZ2V0Q2FsbCgpID09IG1SaW5naW5nQ2FsbCkgeworICAgICAgICAgICAgICAgICAgICAgICAgbmV3UmluZ2luZyA9IG1Db25uZWN0aW9uc1tpXTsKICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgIC8vIFNvbWV0aGluZyBzdHJhbmdlIGhhcHBlbmVkOiBhIGNhbGwgYXBwZWFyZWQKICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHdoaWNoIGlzIG5laXRoZXIgYSByaW5naW5nIGNhbGwgb3Igb25lIHdlIGNyZWF0ZWQuCkBAIC00OTcsMTAgKzUwMywxMCBAQAogICAgICAgICAgICAgICAgICAgICAgICAgLy8gaXQgd29uJ3QgYXBwZWFyIGFzIGEgTWlzc2VkIENhbGwuCiAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGMuc3RhdGUgIT0gRHJpdmVyQ2FsbC5TdGF0ZS5BTEVSVElORwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAmJiBkYy5zdGF0ZSAhPSBEcml2ZXJDYWxsLlN0YXRlLkRJQUxJTkcpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25uZWN0aW9uc1tpXS5vbkNvbm5lY3RlZEluT3JPdXQoKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBtQ29ubmVjdGlvbnNbaV0ub25Db25uZWN0ZWRJbk9yT3V0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRjLnN0YXRlID09IERyaXZlckNhbGwuU3RhdGUuSE9MRElORykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBXZSd2ZSB0cmFuc2l0aW9uZWQgaW50byBIT0xESU5HCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbm5lY3Rpb25zW2ldLm9uU3RhcnRlZEhvbGRpbmcoKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUNvbm5lY3Rpb25zW2ldLm9uU3RhcnRlZEhvbGRpbmcoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICB9CiAKQEAgLTUxMSwxOSArNTE3LDE5IEBACiAgICAgICAgICAgICB9IGVsc2UgaWYgKGNvbm4gIT0gbnVsbCAmJiBkYyA9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgLy8gQ29ubmVjdGlvbiBtaXNzaW5nIGluIENMQ0MgcmVzcG9uc2UgdGhhdCB3ZSB3ZXJlCiAgICAgICAgICAgICAgICAgLy8gdHJhY2tpbmcuCi0gICAgICAgICAgICAgICAgZHJvcHBlZER1cmluZ1BvbGwuYWRkKGNvbm4pOworICAgICAgICAgICAgICAgIG1Ecm9wcGVkRHVyaW5nUG9sbC5hZGQoY29ubik7CiAgICAgICAgICAgICAgICAgLy8gRHJvcHBlZCBjb25uZWN0aW9ucyBhcmUgcmVtb3ZlZCBmcm9tIHRoZSBDYWxsVHJhY2tlcgogICAgICAgICAgICAgICAgIC8vIGxpc3QgYnV0IGtlcHQgaW4gdGhlIEdzbUNhbGwgbGlzdAotICAgICAgICAgICAgICAgIGNvbm5lY3Rpb25zW2ldID0gbnVsbDsKKyAgICAgICAgICAgICAgICBtQ29ubmVjdGlvbnNbaV0gPSBudWxsOwogICAgICAgICAgICAgfSBlbHNlIGlmIChjb25uICE9IG51bGwgJiYgZGMgIT0gbnVsbCAmJiAhY29ubi5jb21wYXJlVG8oZGMpKSB7CiAgICAgICAgICAgICAgICAgLy8gQ29ubmVjdGlvbiBpbiBDTENDIHJlc3BvbnNlIGRvZXMgbm90IG1hdGNoIHdoYXQKICAgICAgICAgICAgICAgICAvLyB3ZSB3ZXJlIHRyYWNraW5nLiBBc3N1bWUgZHJvcHBlZCBjYWxsIGFuZCBuZXcgY2FsbAogCi0gICAgICAgICAgICAgICAgZHJvcHBlZER1cmluZ1BvbGwuYWRkKGNvbm4pOwotICAgICAgICAgICAgICAgIGNvbm5lY3Rpb25zW2ldID0gbmV3IEdzbUNvbm5lY3Rpb24gKHBob25lLmdldENvbnRleHQoKSwgZGMsIHRoaXMsIGkpOworICAgICAgICAgICAgICAgIG1Ecm9wcGVkRHVyaW5nUG9sbC5hZGQoY29ubik7CisgICAgICAgICAgICAgICAgbUNvbm5lY3Rpb25zW2ldID0gbmV3IEdzbUNvbm5lY3Rpb24gKG1QaG9uZS5nZXRDb250ZXh0KCksIGRjLCB0aGlzLCBpKTsKIAotICAgICAgICAgICAgICAgIGlmIChjb25uZWN0aW9uc1tpXS5nZXRDYWxsKCkgPT0gcmluZ2luZ0NhbGwpIHsKLSAgICAgICAgICAgICAgICAgICAgbmV3UmluZ2luZyA9IGNvbm5lY3Rpb25zW2ldOworICAgICAgICAgICAgICAgIGlmIChtQ29ubmVjdGlvbnNbaV0uZ2V0Q2FsbCgpID09IG1SaW5naW5nQ2FsbCkgeworICAgICAgICAgICAgICAgICAgICBuZXdSaW5naW5nID0gbUNvbm5lY3Rpb25zW2ldOwogICAgICAgICAgICAgICAgIH0gLy8gZWxzZSBzb21ldGhpbmcgc3RyYW5nZSBoYXBwZW5lZAogICAgICAgICAgICAgICAgIGhhc05vbkhhbmd1cFN0YXRlQ2hhbmdlZCA9IHRydWU7CiAgICAgICAgICAgICB9IGVsc2UgaWYgKGNvbm4gIT0gbnVsbCAmJiBkYyAhPSBudWxsKSB7IC8qIGltcGxpY2l0IGNvbm4uY29tcGFyZVRvKGRjKSAqLwpAQCAtNTU3LDUyICs1NjMsNTIgQEAKICAgICAgICAgLy8gSWYgaXQgZG9lcyBub3QsIHdlIGxhbmQgaGVyZQogICAgICAgICBpZiAocGVuZGluZ01PICE9IG51bGwpIHsKICAgICAgICAgICAgIFJsb2cuZChMT0dfVEFHLCJQZW5kaW5nIE1PIGRyb3BwZWQgYmVmb3JlIHBvbGwgZmcgc3RhdGU6IgotICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgZm9yZWdyb3VuZENhbGwuZ2V0U3RhdGUoKSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyBtRm9yZWdyb3VuZENhbGwuZ2V0U3RhdGUoKSk7CiAKLSAgICAgICAgICAgIGRyb3BwZWREdXJpbmdQb2xsLmFkZChwZW5kaW5nTU8pOworICAgICAgICAgICAgbURyb3BwZWREdXJpbmdQb2xsLmFkZChwZW5kaW5nTU8pOwogICAgICAgICAgICAgcGVuZGluZ01PID0gbnVsbDsKLSAgICAgICAgICAgIGhhbmd1cFBlbmRpbmdNTyA9IGZhbHNlOworICAgICAgICAgICAgbUhhbmd1cFBlbmRpbmdNTyA9IGZhbHNlOwogICAgICAgICB9CiAKICAgICAgICAgaWYgKG5ld1JpbmdpbmcgIT0gbnVsbCkgewotICAgICAgICAgICAgcGhvbmUubm90aWZ5TmV3U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iAgICAgICAgICAgICAgICAgICAgIGNhdXNlID0gQ29ubmVjdGlvbi5EaXNjb25uZWN0Q2F1c2UuSU5DT01JTkdfUkVKRUNURUQ7CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgY2F1c2UgPSBDb25uZWN0aW9uLkRpc2Nvbm5lY3RDYXVzZS5JTkNPTUlOR19NSVNTRUQ7CiAgICAgICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAgICAgaWYgKFBob25lLkRFQlVHX1BIT05FKSB7Ci0gICAgICAgICAgICAgICAgICAgIGxvZygibWlzc2VkL3JlamVjdGVkIGNhbGwsIGNvbm4uY2F1c2U9IiArIGNvbm4uY2F1c2UpOworICAgICAgICAgICAgICAgICAgICBsb2coIm1pc3NlZC9yZWplY3RlZCBjYWxsLCBjb25uLmNhdXNlPSIgKyBjb25uLm1DYXVzZSk7CiAgICAgICAgICAgICAgICAgICAgIGxvZygic2V0dGluZyBjYXVzZSB0byAiICsgY2F1c2UpOwogICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBkcm9wcGVkRHVyaW5nUG9sbC5yZW1vdmUoaSk7CisgICAgICAgICAgICAgICAgbURyb3BwZWREdXJpbmdQb2xsLnJlbW92ZShpKTsKICAgICAgICAgICAgICAgICBjb25uLm9uRGlzY29ubmVjdChjYXVzZSk7Ci0gICAgICAgICAgICB9IGVsc2UgaWYgKGNvbm4uY2F1c2UgPT0gQ29ubmVjdGlvbi5EaXNjb25uZWN0Q2F1c2UuTE9DQUwpIHsKKyAgICAgICAgICAgIH0gZWxzZSBpZiAoY29ubi5tQ2F1c2UgPT0gQ29ubmVjdGlvbi5EaXNjb25uZWN0Q2F1c2UuTE9DQUwpIHsKICAgICAgICAgICAgICAgICAvLyBMb2NhbCBoYW5ndXAKLSAgICAgICAgICAgICAgICBkcm9wcGVkRHVyaW5nUG9sbC5yZW1vdmUoaSk7CisgICAgICAgICAgICAgICAgbURyb3BwZWREdXJpbmdQb2xsLnJlbW92ZShpKTsKICAgICAgICAgICAgICAgICBjb25uLm9uRGlzY29ubmVjdChDb25uZWN0aW9uLkRpc2Nvbm5lY3RDYXVzZS5MT0NBTCk7Ci0gICAgICAgICAgICB9IGVsc2UgaWYgKGNvbm4uY2F1c2UgPT0KKyAgICAgICAgICAgIH0gZWxzZSBpZiAoY29ubi5tQ2F1c2UgPT0KICAgICAgICAgICAgICAgICBDb25uZWN0aW9uLkRpc2Nvbm5lY3RDYXVzZS5JTlZBTElEX05VTUJFUikgewotICAgICAgICAgICAgICAgIGRyb3BwZWREdXJpbmdQb2xsLnJlbW92ZShpKTsKKyAgICAgICAgICAgICAgICBtRHJvcHBlZER1cmluZ1BvbGwucmVtb3ZlKGkpOwogICAgICAgICAgICAgICAgIGNvbm4ub25EaXNjb25uZWN0KENvbm5lY3Rpb24uRGlzY29ubmVjdENhdXNlLklOVkFMSURfTlVNQkVSKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfQogCiAgICAgICAgIC8vIEFueSBub24tbG9jYWwgZGlzY29ubmVjdHM6IGRldGVybWluZSBjYXVzZQotICAgICAgICBpZiAoZHJvcHBlZER1cmluZ1BvbGwuc2l6ZSgpID4gMCkgewotICAgICAgICAgICAgY20uZ2V0TGFzdENhbGxGYWlsQ2F1c2UoCisgICAgICAgIGlmIChtRHJvcHBlZER1cmluZ1BvbGwuc2l6ZSgpID4gMCkgeworICAgICAgICAgICAgbUNpLmdldExhc3RDYWxsRmFpbENhdXNlKAogICAgICAgICAgICAgICAgIG9idGFpbk5vUG9sbENvbXBsZXRlTWVzc2FnZShFVkVOVF9HRVRfTEFTVF9DQUxMX0ZBSUxfQ0FVU0UpKTsKICAgICAgICAgfQogCkBAIC02MjIsMTEgKzYyOCwxMSBAQAogICAgICAgICB1cGRhdGVQaG9uZVN0YXRlKCk7CiAKICAgICAgICAgaWYgKHVua25vd25Db25uZWN0aW9uQXBwZWFyZWQpIHsKLSAgICAgICAgICAgIHBob25lLm5vdGlme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iAgICAgICAgICAgICB0aHJvdyBuZXcgQ2FsbFN0YXRlRXhjZXB0aW9uICgiR3NtQ29ubmVjdGlvbiAiICsgY29ubgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyAiZG9lcyBub3QgYmVsb25nIHRvIEdzbUNhbGxUcmFja2VyICIgKyB0aGlzKTsKICAgICAgICAgfQpAQCAtNjgzLDEwICs2ODksMTAgQEAKICAgICAgICAgICAgIC8vIEdTTSBpbmRleCBhc3NpZ25lZCB5ZXQKIAogICAgICAgICAgICAgaWYgKFBob25lLkRFQlVHX1BIT05FKSBsb2coImhhbmd1cDogc2V0IGhhbmd1cFBlbmRpbmdNTyB0byB0cnVlIik7Ci0gICAgICAgICAgICBoYW5ndXBQZW5kaW5nTU8gPSB0cnVlOworICAgICAgICAgICAgbUhhbmd1cFBlbmRpbmdNTyA9IHRydWU7CiAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICB0cnkgewotICAgICAgICAgICAgICAgIGNtLmhhbmd1cENvbm5lY3Rpb24gKGNvbm4uZ2V0R1NNSW5kZXgoKSwgb2J0YWluQ29tcGxldGVNZXNzYWdlKCkpOworICAgICAgICAgICAgICAgIG1DaS5oYW5ndXBDb25uZWN0aW9uIChjb25uLmdldEdTTUluZGV4KCksIG9idGFpbkNvbXBsZXRlTWVzc2FnZSgpKTsKICAgICAgICAgICAgIH0gY2F0Y2ggKENhbGxTdGF0ZUV4Y2VwdGlvbiBleCkgewogICAgICAgICAgICAgICAgIC8vIElnbm9yZSAiY29ubmVjdGlvbiBub3QgZm91bmQiCiAgICAgICAgICAgICAgICAgLy8gQ2FsbCBtYXkgaGF2ZSBodW5nIHVwIGFscmVhZHkKQEAgLTcwMCwxMiArNzA2LDEyIEBACiAKICAgICAvKnBhY2thZ2UqLyB2b2lkCiAgICAgc2VwYXJhdGUgKEdzbUNvbm5lY3Rpb24gY29ubikgdGhyb3dzIENhbGxTdGF0ZUV4Y2VwdGlvbiB7Ci0gICAgICA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Q2FsbFN0YXRlRXhjZXB0aW9uIHsKLSAgICAgICAgaW50IGNvdW50ID0gY2FsbC5jb25uZWN0aW9ucy5zaXplKCk7CisgICAgICAgIGludCBjb3VudCA9IGNhbGwubUNvbm5lY3Rpb25zLnNpemUoKTsKICAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBjb3VudDsgaSsrKSB7Ci0gICAgICAgICAgICBHc21Db25uZWN0aW9uIGNuID0gKEdzbUNvbm5lY3Rpb24pY2FsbC5jb25uZWN0aW9ucy5nZXQoaSk7CisgICAgICAgICAgICBHc21Db25uZWN0aW9uIGNuID0gKEdzbUNvbm5lY3Rpb24pY2FsbC5tQ29ubmVjdGlvbnMuZ2V0KGkpOwogICAgICAgICAgICAgaWYgKGNuLmdldEdTTUluZGV4KCkgPT0gaW5kZXgpIHsKICAgICAgICAgICAgICAgICByZXR1cm4gY247CiAgICAgICAgICAgICB9CkBAIC04MzUsNiArODQxLDcgQEAKIAogICAgIC8vKioqKioqIE92ZXJyaWRkZW4gZnJvbSBIYW5kbGVyCiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZAogICAgIGhhbmRsZU1lc3NhZ2UgKE1lc3NhZ2UgbXNnKSB7CiAgICAgICAgIEFzeW5jUmVzdWx0IGFyOwpAQCAtODQzLDExICs4NTAsMTEgQEAKICAgICAgICAgICAgIGNhc2UgRVZFTlRfUE9MTF9DQUxMU19SRVNVTFQ6CiAgICAgICAgICAgICAgICAgYXIgPSAoQXN5bmNSZXN1bHQpbXNnLm9iajsKIAotICAgICAgICAgICAgICAgIGlmIChtc2cgPT0gbGFzdFJlbGV2YW50UG9sbCkgeworICAgICAgICAgICAgICAgIGlmIChtc2cgPT0gbUxhc3RSZWxldmFudFBvbGwpIHsKICAgICAgICAgICAgICAgICAgICAgaWYgKERCR19QT0xMKSBsb2coCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgImhhbmRsZSBFVkVOVF9QT0xMX0NBTExfUkVTVUxUOiBzZXQgbmVlZHNQb2xsPUYiKTsKLSAgICAgICAgICAgICAgICAgICAgbmVlZHNQb2xsID0gZmFsc2U7Ci0gICAgICAgICAgICAgICAgICAgIGxhc3RSZWxldmFudFBvbGwgPSBudWxsOworICAgICAgICAgICAgICAgICAgICBtTmVlZHNQb2xsID0gZmFsc2U7CisgICAgICAgICAgICAgICAgICAgIG1MYXN0UmVsZXZhbnRQb2xsID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgaGFuZGxlUG9sbENhbGxzKChBc3luY1Jlc3VsdCltc2cub2JqKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICBicmVhazsKQEAgLTg2Myw3ICs4NzAsNyBAQAogICAgICAgICAgICAgY2FzZSBFVkVOVF9FQ1RfUkVTVUxUOgogICAgICAgICAgICAgICAgIGFyID0gKEFzeW5jUmVzdWx0KW1zZy5vYmo7CiAgICAgICAgICAgICAgICAgaWYgKGFyLmV4Y2VwdGlvbiAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgIHBob25lLm5vdGlmeVN1cHBTZXJ2aWNlRmFpbGVkKGdldEZhaWxlZFNlcnZpY2UobXNnLndoYXQpKTsKKyAgICAgICAgICAgICAgICAgICAgbVBob25lLm5vdGlmeVN1cHBTZXJ2aWNlRmFpbGVkKGdldEZhaWxlZFNlcnZpY2UobXNnLndoYXQpKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgb3BlcmF0aW9uQ29tcGxldGUoKTsKICAgICAgICAgICAgIGJyZWFrOwpAQCAtODkxLDI0ICs4OTgsMjQgQEAKICAgICAgICAgICAgICAgICAgICAgY2F1c2VDb2RlID09IENhbGxGYWlsQ2F1c2UuUU9TX05PVF9BVkFJTCB8fAogICAgICAgICAgICAgICAgICAgICBjYXVzZUNvZGUgPT0gQ2FsbEZhaWxDYXVzZS5CRUFSRVJfTk9UX0FWQUlMIHx8CiAgICAgICAgICAgICAgICAgICAgIGNhdXNlQ29kZSA9PSBDYWxsRmFpbENhdXNlLkVSUk9SX1VOU1BFQ0lGSUVEKSB7Ci0gICAgICAgICAgICAgICAgICAgIEdzbUNlbGxMb2NhdGlvbiBsb2MgPSAoKEdzbUNlbGxMb2NhdGlvbilwaG9uZS5nZXRDZWxsTG9jYXRpb24oKSk7CisgICAgICAgICAgICAgICAgICAgIEdzbUNlbGxMb2NhdGlvbiBsb2MgPSAoKEdzbUNlbGxMb2NhdGlvbiltUGhvbmUuZ2V0Q2VsbExvY2F0aW9uKCkpOwogICAgICAgICAgICAgICAgICAgICBFdmVudExvZy53cml0ZUV2ZW50KEV2ZW50TG9nVGFncy5DQUxMX0RST1AsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2F1c2VDb2RlLCBsb2MgIT0gbnVsbCA/IGxvYy5nZXRDaWQoKSA6IC0xLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIFRlbGVwaG9ueU1hbmFnZXIuZ2V0RGVmYXVsdCgpLmdldE5ldHdvcmtUeXBlKCkpOwogICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgICAgIGZvciAoaW50IGkgPSAwLCBzID0gIGRyb3BwZWREdXJpbmdQb2xsLnNpemUoKQorICAgICAgICAgICAgICAgIGZvciAoaW50IGkgPSAwLCBzID0gIG1Ecm9wcGVkRHVyaW5nUG9sbC5zaXplKCkKICAgICAgICAgICAgICAgICAgICAgICAgIDsgaSA8IHMgOyBpKysKICAgICAgICAgICAgICAgICApIHsKLSAgICAgICAgICAgICAgICAgICAgR3NtQ29ubmVjdGlvbiBjb25uID0gZHJvcHBlZER1cmluZ1BvbGwuZ2V0KGkpOworICAgICAgICAgICAgICAgICAgICBHc21Db25uZWN0aW9uIGNvbm4gPSBtRHJvcHBlZER1cmluZ1BvbGwuZ2V0KGkpOwogCiAgICAgICAgICAgICAgICAgICAgIGNvbm4ub25SZW1vdGVEaXNjb25uZWN0KGNhdXNlQ29kZSk7CiAgICAgICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAg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AgLTE0NSwyMyArMTQ3LDIzIEBACiAgICAgICAgIGNyZWF0ZVdha2VMb2NrKGNvbnRleHQpOwogICAgICAgICBhY3F1aXJlV2FrZUxvY2soKTsKIAotICAgICAgICBvd25lciA9IGN0OwotICAgICAgICBoID0gbmV3IE15SGFuZGxlcihvd25lci5nZXRMb29wZXIoKSk7CisgICAgICAgIG1Pd25lciA9IGN0OworICAgICAgICBtSGFuZGxlciA9IG5ldyBNeUhhbmRsZXIobU93bmVyLmdldExvb3BlcigpKTsKIAotICAgICAgICB0aGlzLmRpYWxTdHJpbmcgPSBkaWFsU3RyaW5nOworICAgICAgICBtRGlhbFN0cmluZyA9IGRpYWxTdHJpbmc7CiAKLSAgICAgICAgdGhpcy5hZGRyZXNzID0gUGhvbmVOdW1iZXJVdGlscy5leHRyYWN0TmV0d29ya1BvcnRpb25BbHQoZGlhbFN0cmluZyk7Ci0gICAgICAgIHRoaXMucG9zdERpYWxTdHJpbmcgPSBQaG9uZU51bWJlclV0aWxzLmV4dHJhY3RQb3N0RGlhbFBvcnRpb24oZGlhbFN0cmluZyk7CisgICAgICAgIG1BZGRyZXNzID0gUGhvbmVOdW1iZXJVdGlscy5leHRyYWN0TmV0d29ya1BvcnRpb25BbHQoZGlhbFN0cmluZyk7CisgICAgICAgIG1Qb3N0RGlhbFN0cmluZyA9IFBob25lTnVtYmVyVXRpbHMuZXh0cmFjdFBvc3REaWFsUG9ydGlvbihkaWFsU3RyaW5nKTsKIAotICAgICAgICBpbmRleCA9IC0xOworICAgICAgICBtSW5kZXggPSAtMTsKIAotICAgICAgICBpc0luY29taW5nID0gZmFsc2U7Ci0gICAgICAgIGNuYXBOYW1lID0gbnVsbDsKLSAgICAgICAgY25hcE5hbWVQcmVzZW50YXRpb24gPSBQaG9uZUNvbnN0YW50cy5QUkVTRU5UQVRJT05fQUxMT1dFRDsKLSAgICAgICAgbnVtYmVyUHJlc2VudGF0aW9uID0gUGhvbmVDb25zdGFudHMuUFJFU0VOVEFUSU9OX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AgIHJldHVybiBtRGlzY29ubmVjdFRpbWU7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGxvbmcgZ2V0RHVyYXRpb25NaWxsaXMoKSB7Ci0gICAgICAgIGlmIChjb25uZWN0VGltZVJlYWwgPT0gMCkgeworICAgICAgICBpZiAobUNvbm5lY3RUaW1lUmVhbCA9PSAwKSB7CiAgICAgICAgICAgICByZXR1cm4gMDsKLSAgICAgICAgfSBlbHNlIGlmIChkdXJhdGlvbiA9PSAwKSB7Ci0gICAgICAgICAgICByZXR1cm4gU3lzdGVtQ2xvY2suZWxhcHNlZFJlYWx0aW1lKCkgLSBjb25uZWN0VGltZVJlYWw7CisgICAgICAgIH0gZWxzZSBpZiAobUR1cmF0aW9uID09IDApIHsKKyAgICAgICAgICAgIHJldHVybiBTeXN0ZW1DbG9jay5lbGFwc2VkUmVhbHRpbWUoKSAtIG1Db25uZWN0VGltZVJlYWw7CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICByZXR1cm4gZHVyYXRpb247CisgICAgICAgICAgICByZXR1cm4gbUR1cmF0aW9uOwogICAgICAgICB9CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGxvbmcgZ2V0SG9sZER1cmF0aW9uTWlsbGlzKCkgewogICAgICAgICBpZiAoZ2V0U3RhdGUoKSAhPSBHc21DYWxsLlN0YXRlLkhPTERJTkcpIHsKICAgICAgICAgICAgIC8vIElmIG5vdCBob2xkaW5nLCByZXR1cm4gMAogICAgICAgICAgICAgcmV0dXJuIDA7CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICByZXR1cm4gU3lzdGVtQ2xvY2suZWxhcHNlZFJlYWx0aW1lKCkgLSBob2xkaW5nU3RhcnRUaW1lOworICAgICAgICAgICAgcmV0dXJuIFN5c3RlbUNsb2NrLmVsYXBzZWRSZWFsdGltZSgpIC0gbUhvbGRpbmdTdGFydFRpbWU7CiAgICAgICAgIH0KICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgRGlzY29ubmVjdENhdXNlIGdldERpc2Nvbm5lY3RDYXVzZSgpIHsKLSAgICAgICAgcmV0dXJuIGNhdXNlOworICAgICAgICByZXR1cm4gbUNhdXNlOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBib29sZWFuIGlzSW5jb21pbmcoKSB7Ci0gICAgICAgIHJldHVybiBpc0luY29taW5nOworICAgICAgICByZXR1cm4gbUlzSW5jb21pbmc7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIEdzbUNhbGwuU3RhdGUgZ2V0U3RhdGUoKSB7Ci0gICAgICAgIGlmIChkaXNjb25uZWN0ZWQpIHsKKyAgICAgICAgaWYgKG1EaXNjb25uZWN0ZWQpIHsKICAgICAgICAgICAgIHJldHVybiBHc21DYWxsLlN0YXRlLkRJU0NPTk5FQ1RFRDsKICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIHJldHVybiBzdXBlci5nZXRTdGF0ZSgpOwogICAgICAgICB9CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgaGFuZ3VwKCkgdGhyb3dzIENhbGxTdGF0ZUV4Y2VwdGlvbiB7Ci0gICAgICAgIGlmICghZGlzY29ubmVjdGVkKSB7Ci0gICAgICAgICAgICBvd25lci5oYW5ndXAodGhpcyk7CisgICAgICAgIGlmICghbURpc2Nvbm5lY3RlZCkgeworICAgICAgICAgICAgbU93bmVyLmhhbmd1cCh0aGlzKTsKICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIHRocm93IG5ldyBDYWxsU3RhdGVFeGNlcHRpb24gKCJkaXNjb25uZWN0ZWQiKTsKICAgICAgICAgfQogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHNlcGFyYXRlKCkgdGhyb3dzIENhbGxTdGF0ZUV4Y2VwdGlvbiB7Ci0gICAgICAgIGlmICghZGlzY29ubmVjdGVkKSB7Ci0gICAgICAgICAgICBvd25lci5zZXBhcmF0ZSh0aGlzKTsKKyAgICAgICAgaWYgKCFtRGlzY29ubmVjdGVkKSB7CisgICAgICAgICAgICBtT3duZXIuc2VwYXJhdGUodGhpcyk7CiAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICB0aHJvdyBuZXcgQ2FsbFN0YXRlRXhjZXB0aW9uICgiZGlzY29ubmVjdGVkIik7CiAgICAgICAgIH0KICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgUG9zdERpYWxTdGF0ZSBnZXRQb3N0RGlhbFN0YXRlKCkgewotICAgICAgICByZXR1cm4gcG9zdERpYWxTdGF0ZTsKKyAgICAgICAgcmV0dXJuIG1Qb3N0RGlhbFN0YXRlOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHByb2NlZWRBZnRlcldhaXRDaGFyKCkgewotICAgICAgICBpZiAocG9zdERpYWxTdGF0ZSAhPSBQb3N0RGlhbFN0YXRlLldBSVQpIHsKKyAgICAgICAgaWYgKG1Qb3N0RGlhbFN0YXRlICE9IFBvc3REaWFsU3RhdGUuV0FJVCkgewogICAgICAgICAgICAgUmxvZy53KExPR19UQUcsICJHc21Db25uZWN0aW9uLnByb2NlZWRBZnRlcldhaXRDaGFyKCk6IEV4cGVjdGVkICIKLSAgICAgICAgICAgICAgICArICJnZXRQb3N0RGlhbFN0YXRlKCkgdG8gYmUgV0FJVCBidXQgd2FzICIgKyBwb3N0RGlhbFN0YXRlKTsKKyAgICAgICAgICAgICAgICArICJnZXRQb3N0RGlhbFN0YXRlKCkgdG8gYmUgV0FJVCBidXQgd2FzICIgKyBtUG9zdERpYWxTdGF0ZSk7CiAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgIH0KIApAQCAtMjc2LDUzICsyOTIsMzIgQEAKICAgICAgICAgcHJvY2Vzc05leHRQb3N0RGlhbENoYXIoKTsKIC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0ci5jaGFyQXQoaSk7Ci0gICAgICAgICAgICAgICAgTWVzc2FnZSBtc2cgPSBudWxsOwotCi0gICAgICAgICAgICAgICAgaWYgKGkgPT0gbGVuLTEpIHsKLSAgICAgICAgICAgICAgICAgICAgbXNnID0gaC5vYnRhaW5NZXNzYWdlKEVWRU5UX0RUTUZfRE9ORSk7Ci0gICAgICAgICAgICAgICAgfQotCi0gICAgICAgICAgICAgICAgaWYgKFBob25lTnVtYmVyVXRpbHMuaXMxMktleShjKSkgewotICAgICAgICAgICAgICAgICAgICBvd25lci5jbS5zZW5kRHRtZihjLCBtc2cpOwotICAgICAgICAgICAgICAgICAgICBwbGF5ZWRUb25lID0gdHJ1ZTsKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgIGlmICghcGxheWVkVG9uZSkgewotICAgICAgICAgICAgICAgIHByb2Nlc3NOZXh0UG9zdERpYWxDaGFyKCk7Ci0gICAgICAgICAgICB9Ci0gICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAvLyBtYWtlIGEgbmV3IHBvc3REaWFsU3RyaW5nLCB3aXRoIHRoZSB3aWxkIGNoYXIgcmVwbGFjZW1lbnQgc3RyaW5nCi0gICAgICAgICAgICAvLyBhdCB0aGUgYmVnaW5uaW5nLCBmb2xsb3dlZCBieSB0aGUgcmVtYWluaW5nIHBvc3REaWFsU3RyaW5nLgotCi0gICAgICAgICAgICBTdHJpbmdCdWlsZGVyIGJ1ZiA9IG5ldyBTdHJpbmdCdWlsZGVyKHN0cik7Ci0gICAgICAgICAgICBidWYuYXBwZW5kKHBvc3REaWFsU3RyaW5nLnN1YnN0cmluZyhuZXh0UG9zdERpYWxDaGFyKSk7Ci0gICAgICAgICAgICBwb3N0RGlhbFN0cmluZyA9IGJ1Zi50b1N0cmluZygpOwotICAgICAgICAgICAgbmV4dFBvc3REaWFsQ2hhciA9IDA7Ci0gICAgICAgICAgICBpZiAoUGhvbmUuREVCVUdfUEhPTkUpIHsKLSAgICAgICAgICAgICAgICBsb2coInByb2NlZWRBZnRlcldpbGRDaGFyOiBuZXcgcG9zdERpYWxTdHJpbmcgaXMgIiArCi0gICAgICAgICAgICAgICAgICAgICAgICBwb3N0RGlhbFN0cmluZyk7Ci0gICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgIHByb2Nlc3NOZXh0UG9zdERpYWxDaGFyKCk7CisgICAgICAgIFN0cmluZ0J1aWxkZXIgYnVmID0gbmV3IFN0cmluZ0J1aWxkZXIoc3RyKTsKKyAgICAgICAgYnVmLmFwcGVuZChtUG9zdERpYWxTdHJpbmcuc3Vic3RyaW5nKG1OZXh0UG9zdERpYWxDaGFyKSk7CisgICAgICAgIG1Qb3N0RGlhbFN0cmluZyA9IGJ1Zi50b1N0cmluZygpOworICAgICAgICBtTmV4dFBvc3REaWFsQ2hhciA9IDA7CisgICAgICAgIGlmIChQaG9uZS5ERUJVR19QSE9ORSkgeworICAgICAgICAgICAgbG9nKCJwcm9jZWVkQWZ0ZXJXaWxkQ2hhcjogbmV3IHBvc3REaWFsU3RyaW5nIGlzICIgKworICAgICAgICAgICAgICAgICAgICBtUG9zdERpYWxTdHJpbmcpOwogICAgICAgICB9CisKKyAgICAgICAgcHJvY2Vzc05leHRQb3N0RGlhbENoYXIoKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBjYW5jZWxQb3N0RGlhbCgpIHsKICAgICAgICAgc2V0UG9zdERpYWxTdGF0ZShQb3N0RGlhbFN0YXRlLkNBTkNFTExFRCk7CiAgICAgfQpAQCAtMzM0LDcgKzMyOSw3IEBACiAgICAgICovCiAgICAgdm9pZAogICAgIG9uSGFuZ3VwTG9jYWwoKSB7Ci0gICAgICAgIGNhdXNlID0gRGlzY29ubmVjdENhdXNlLkxPQ0FMOworICAgICAgICBtQ2F1c2UgPSBEaXNjb25uZWN0Q2F1c2UuTE9DQUw7CiAgICAgfQogCiAgICAgRGlzY29ubmVjdENhdXNlCkBAIC0zNzEsNyArMzY2LDcgQEAKICAgICAgICAgICAgIGNhc2UgQ2FsbEZhaWxDYXVzZS5FUlJPUl9VTlNQRUNJRklFRDoKICAgICAgICAgICAgIGNhc2UgQ2FsbEZhaWxDYXVzZS5OT1JNQUxfQ0xFQVJJTkc6CiAgICAgICAgICAgICBkZWZhdWx0OgotICAgICAgICAgICAgICAgIEdTTVBob25lIHBob25lID0gb3duZXIucGhvbmU7CisgICAgICAgICAgICAgICAgR1NNUGhvbmUgcGhvbmUgPSBtT3duZXIubVBob25lOwogICAgICAgICAgICAgICAgIGludCBzZXJ2aWNlU3RhdGUgPSBwaG9uZS5nZXRTZXJ2aWNlU3RhdGUoKS5nZXRTdGF0ZSgpOwogICAgICAgICAgICAgICAgIFVpY2NDYXJkQXBwbGljYXRpb24gY2FyZEFwcCA9IFVpY2NDb250cm9sbGVyCiAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0SW5zdGFuY2UoKQpAQCAtNDEzLDIyICs0MDgsMjEgQEAKICAgICAvKiogQ2FsbGVkIHdoZW4gdGhlIHJhZGlvIGluZGljYXRlcyB0aGUgY29ubmVjdGlvbiBoYXMgYmVlbiBkaXNjb25uZWN0ZWQgKi8KICAgICAvKnBhY2thZ2UqLyB2b2lkCiAgICAgb25EaXNjb25uZWN0KERpc2Nvbm5lY3RDYXVzZSBjYXVzZSkgewotICAgICAgICB0aGlzLmNhdXNlID0gY2F1c2U7CisgICAgICAgIG1DYXVzZSA9IGNhdXNlOwogCi0gICAgICAgIGlmICghZGlzY29ubmVjdGVkKSB7Ci0gICAgICAgICAgICBpbmRleCA9IC0xOworICAgICAgICBpZiAoIW1EaXNjb25uZWN0ZWQpIHsKKyAgICAgICAgICAgIG1JbmRleCA9IC0xOwogCi0gICAgICAgICAgICBkaXNjb25uZWN0VGltZSA9IFN5c3RlbS5jdXJyZW50VGltZU1pbGxpcygpOwotICAgICAgICAgICAgZHVyYXRpb24gPSBTeXN0ZW1DbG9jay5lbGFwc2VkUmVhbHRpbWUoKSAtIGNvbm5lY3RUaW1lUmVhbDsKLSAgICAgICAgICAgIGRpc2Nvbm5lY3RlZCA9IHRydWU7CisgICAgICAgICAgICBtRGlzY29ubmVjdFRpbWUgPSBTeXN0ZW0uY3VycmVudFRpbWVNaWxsaXMoKTsKKyAgICAgICAgICAgIG1EdXJhdGlvbiA9IFN5c3RlbUNsb2NrLmVsYXBzZWRSZWFsdGltZSgpIC0gbUNvbm5lY3RUaW1lUmVhbDsKKyAgICAgICAgICAgIG1EaXNjb25uZWN0ZWQgPSB0cnVlOwogCi0gICAgICAgICAgICBpZiAoZmFsc2UpIFJsb2cuZChMT0dfVEFHLAotICAgICAgICAgICAgICAgICAgICAiW0dTTUNvbm5dIG9uRGlzY29ubmVjdDogY2F1c2U9IiArIGNhdXNlKTsKKyAgICAgICAgICAgIGlmIChEQkcpIFJsb2cuZChMT0dfVEFHLCAib25EaXNjb25uZWN0OiBjYXVzZT0iICsgY2F1c2UpOwogCi0gICAgICAgICAgICBvd25lci5waG9uZS5ub3RpZnlEaXNjb25uZWN0KHRoaXMpOworICAgICAgICAgICAgbU93bmVyLm1QaG9uZS5ub3RpZnlEaXNjb25uZWN0KHRoaXMpOwogCi0gICAgICAgICAgICBpZiAocGFyZW50ICE9IG51bGwpIHsKLSAgICAgICAgICAgICAgICBwYXJlbnQuY29ubmVjdGlvbkRpc2Nvbm5lY3RlZCh0aGlzKTsKKyAgICAgICAgICAgIGlmIChtUGFyZW50ICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICBtUGFyZW50LmNvbm5lY3Rpb25EaXNjb25uZWN0ZWQodGhpcyk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICAgICAgcmVsZWFzZVdha2VMb2NrKCk7CkBAIC00NDQsNDUgKzQzOCw0NSBAQAogCiAgICAgICAgIG5ld1BhcmVudCA9IHBhcmVudEZyb21EQ1N0YXRlKGRjLnN0YXRlKTsKIAotICAgICAgICBpZiAoIWVxdWFsc0hhbmRsZXNOdWxscyhhZGRyZXNzLCBkYy5udW1iZXIpKSB7CisgICAgICAgIGlmICghZXF1YWxzSGFuZGxlc051bGxzKG1BZGRyZXNzLCBkYy5udW1iZXIpKSB7CiAgICAgICAgICAgICBpZiAoUGhvbmUuREVCVUdfUEhPTkUpIGxvZygidXBkYXRlOiBwaG9uZSAjIGNoYW5nZWQhIik7Ci0gICAgICAgICAgICBhZGRyZXNzID0gZGMubnVtYmVyOworICAgICAgICAgICAgbUFkZHJlc3MgPSBkYy5udW1iZXI7CiAgICAgICAgICAgICBjaGFuZ2VkID0gdHJ1ZTsKICAgICAgICAgfQogCiAgICAgICAgIC8vIEEgbnVsbCBjbmFwTmFtZSBzaG91bGQgYmUgdGhlIHNhbWUgYXMgIiIKICAgICAgICAgaWYgKFRleHRVdGlscy5pc0VtcHR5KGRjLm5hbWUpKSB7Ci0gICAgICAgICAgICBpZiAoIVRleHRVdGlscy5pc0VtcHR5KGNuYXBOYW1lKSkgeworICAgICAgICAgICAgaWYgKCFUZXh0VXRpbHMuaXNFbXB0eShtQ25hcE5hbWUpKSB7CiAgICAgICAgICAgICAgICAgY2hhbmdlZCA9IHRydWU7Ci0gICAgICAgICAgICAgICAgY25hcE5hbWUgPSAiIjsKKyAgICAgICAgICAgICAgICBtQ25hcE5hbWUgPSAiIjsKICAgICAgICAgICAgIH0KLSAgICAgICAgfSBlbHNlIGlmICghZGMubmFtZS5lcXVhbHMoY25hcE5hbWUpKSB7CisgICAgICAgIH0gZWxzZSBpZiAoIWRjLm5hbWUuZXF1YWxzKG1DbmFwTmFtZSkpIHsKICAgICAgICAgICAgIGNoYW5nZWQgPSB0cnVlOwotICAgICAgICAgICAgY25hcE5hbWUgPSBkYy5uYW1lOworICAgICAgICAgICAgbUNuYXBOYW1lID0gZGMubmFtZTsKICAgICAgICAgfQogCi0gICAgICAgIGlmIChQaG9uZS5ERUJVR19QSE9ORSkgbG9nKCItLWRzc2RzLS0tLSIrY25hcE5hbWUpOwotICAgICAgICBjbmFwTmFtZVByZXNlbnRhdGlvbiA9IGRjLm5hbWVQcmVzZW50YXRpb247Ci0gICAgICAgIG51bWJlclByZXNlbnRhdGlvbiA9IGRjLm51bWJlclByZXNlbnRhdGlvbjsKKyAgICAgICAgaWYgKFBob25lLkRFQlVHX1BIT05FKSBsb2coIi0tZHNzZHMtLS0tIittQ25hcE5hbWUpOworICAgICAgICBtQ25hcE5hbWVQcmVzZW50YXRpb24gPSBkYy5uYW1lUHJlc2VudGF0aW9uOworICAgICAgICBtTnVtYmVyUHJlc2VudGF0aW9uID0gZGMubnVtYmVyUHJlc2VudGF0aW9uOwogCi0gICAgICAgIGlmIChuZXdQYXJlbnQgIT0gcGFyZW50KSB7Ci0gICAgICAgICAgICBpZiAocGFyZW50ICE9IG51bGwpIHsKLSAgICAgICAgICAgICAgICBwYXJlbnQuZGV0YWNoKHRoaXMpOworICAgICAgICBpZiAobmV3UGFyZW50ICE9IG1QYXJlbnQpIHsKKyAgICAgICAgICAgIGlmIChtUGFyZW50ICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICBtUGFyZW50LmRldGFjaCh0aGlzKTsKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIG5ld1BhcmVudC5hdHRhY2godGhpcywgZGMpOwotICAgICAgICAgICAgcGFyZW50ID0gbmV3UGFyZW50OworICAgICAgICAgICAgbVBhcmVudCA9IG5ld1BhcmVudDsKICAgICAgICAgICAgIGNoYW5nZWQgPSB0cnVlOwogICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgYm9vbGVhbiBwYXJlbnRTdGF0ZUNoYW5nZTsKLSAgICAgICAgICAgIHBhcmVudFN0YXRlQ2hhbmdlID0gcGFyZW50LnVwZGF0ZSAodGhpcywgZGMpOworICAgICAgICAgICAgcGFyZW50U3RhdGVDaGFuZ2UgPSBtUGFyZW50LnVwZGF0ZSAodGhpcywgZGMpOwogICAgICAgICAgICAgY2hhbmdlZCA9IGNoYW5nZWQgfHwgcGFyZW50U3RhdGVDaGFuZ2U7CiAgICAgICAgIH0KIAogICAgICAgICAvKiogU29tZSBzdGF0ZS10cmFuc2l0aW9uIGV2ZW50cyAqLwogCiAgICAgICAgIGlmIChQaG9uZS5ERUJVR19QSE9ORSkgbG9nKAotICAgICAgICAgICAgICAgICJ1cGRhdGU6IHBhcmVudD0iICsgcGFyZW50ICsKLSAgICAgICAgICAgICAgICAiLCBoYXNOZXdQYXJlbnQ9IiArIChuZXdQYXJlbnQgIT0gcGFyZW50KSArCisgICAgICAgICAgICAgICAgInVwZGF0ZTogcGFyZW50PSIgKyBtUGFyZW50ICsKKyAgICAgICAgICAgICAgICAiLCBoYXNOZXdQYXJlbnQ9IiArIChuZXdQYXJlbnQgIT0gbVBhcmVudCkgKwogICAgICAgICAgICAgICAgICIsIHdhc0Nvbm5lY3RpbmdJbk9yT3V0PSIgKyB3YXNDb25uZWN0aW5nSW5Pck91dCArCiAgICAgICAgICAgICAgICAgIiwgd2FzSG9sZGluZz0iICsgd2FzSG9sZGluZyArCiAgICAgICAgICAgICAgICAgIiwgaXNDb25uZWN0aW5nSW5Pck91dD0iICsgaXNDb25uZWN0aW5nSW5Pck91dCgpICsKQEAgLTUwOSwyMCArNTAzLDIwIEBACiAgICAgICovCiAgICAgdm9pZAogICAgIGZha2VIb2xkQmVmb3JlRGlhbCgpIHsKLSAgICAgICAgaWYgKHBhcmVudCAhPSBudWxsKSB7Ci0gICAgICAgICAgICBwYXJlbnQuZGV0YWNoKHRoaXMpOworICAgICAgICBpZiAobVBhcmVudCAhPSBudWxsKSB7CisgICAgICAgICAgICBtUGFyZW50LmRldGFjaCh0aGlzKTsKICAgICAgICAgfQogCi0gICAgICAgIHBhcmVudCA9IG93bmVyLmJhY2tncm91bmRDYWxsOwotICAgICAgICBwYXJlbnQuYXR0YWNoRmFrZSh0aGlzLCBHc21DYWxsLlN0YXRlLkhPTERJTkcpOworICAgICAgICBtUGFyZW50ID0gbU93bmVyLm1CYWNrZ3JvdW5kQ2FsbDsKKyAgICAgICAgbVBhcmVudC5hdHRhY2hGYWtlKHRoaXMsIEdzbUNhbGwuU3RhdGUuSE9MRElORyk7CiAKICAgICAgICAgb25TdGFydGVkSG9sZGluZygpOwogICAgIH0KIAogICAgIC8qcGFja2FnZSovIGludAogICAgIGdldEdTTUluZGV4KCkgdGhyb3dzIENhbGxTdGF0ZUV4Y2VwdGlvbiB7Ci0gICAgICAgIGlmIChpbmRleCA+PSAwKSB7Ci0gICAgICAgICAgICByZXR1cm4gaW5kZXggKyAxOworICAgICAgICBpZiAobUluZGV4ID49IDApIHsKKyAgICAgICAgICAgIHJldHVybiBtSW5kZXggKyAxOwogICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgdGhyb3cgbmV3IENhbGxTdGF0ZUV4Y2VwdGlvbiAoIkdTTSBpbmRleCBub3QgeWV0IGFzc2lnbmVkIik7CiAgICAgICAgIH0KQEAgLTUzMywxNyArNTI3LDE3IEBACiAgICAgICovCiAgICAgdm9pZAogICAgIG9uQ29ubmVjdGVkSW5Pck91dCgpIHsKLSAgICAgICAgY29ubmVjdFRpbWUgPSBTeXN0ZW0uY3VycmVudFRpbWVNaWxsaXMoKTsKLSAgICAgICAgY29ubmVjdFRpbWVSZWFsID0gU3lzdGVtQ2xvY2suZWxhcHNlZFJlYWx0aW1lKCk7Ci0gICAgICAgIGR1cmF0aW9uID0gMDsKKyAgICAgICAgbUNvbm5lY3RUaW1lID0gU3lzdGVtLmN1cnJlbnRUaW1lTWlsbGlzKCk7CisgICAgICAgIG1Db25uZWN0VGltZVJlYWwgPSBTeXN0ZW1DbG9jay5lbGFwc2VkUmVhbHRpbWUoKTsKKyAgICAgICAgbUR1cmF0aW9uID0gMDsKIAogICAgICAgICAvLyBidWcgIzY3ODQ3NDogaW5jb21pbmcgY2FsbCBpbnRlcnByZXRlZCBhcyBtaXNzZWQgY2FsbCwgZXZlbiB0aG91Z2gKICAgICAgICAgLy8gaXQgc291bmRzIGxpa2UgdGhlIHVzZXIgaGFzIHBpY2tlZCB1cCB0aGUgY2FsbC4KICAgICAgICAgaWYgKFBob25lLkRFQlVHX1BIT05FKSB7Ci0gICAgICAgICAgICBsb2coIm9uQ29ubmVjdGVkSW5Pck91dDogY29ubmVjdFRpbWU9IiArIGNvbm5lY3RUaW1lKTsKKyAgICAgICAgICAgIGxvZygib25Db25uZWN0ZWRJbk9yT3V0OiBjb25uZWN0VGltZT0iICsgbUNvbm5lY3RUaW1lKTsKICAgICAgICAgfQogCi0gICAgICAgIGlmICghaXNJbmNvbWluZykgeworICAgICAgICBpZiAoIW1Jc0luY29taW5nKSB7CiAgICAgICAgICAgICAvLyBvdXRnb2luZyBjYWxscyBvbmx5CiAgICAgICAgICAgICBwcm9jZXNzTmV4dFBvc3REaWFsQ2hhcigpOwogICAgICAgICB9CkBAIC01NTIsNyArNTQ2LDcgQEAKIAogICAgIC8qcGFja2FnZSovIHZvaWQKICAgICBvblN0YXJ0ZWRIb2xkaW5nKCkgewotICAgICAgICBob2xkaW5nU3RhcnRUaW1lID0gU3lzdGVtQ2xvY2suZWxhcHNlZFJlYWx0aW1lKCk7CisgICAgICAgIG1Ib2xkaW5nU3RhcnRUaW1lID0gU3lzdGVtQ2xvY2suZWxhcHNlZFJlYWx0aW1lKCk7CiAgICAgfQogICAgIC8qKgogICAgICAqIFBlcmZvcm1zIHRoZSBhcHByb3ByaWF0ZSBhY3Rpb24gZm9yIGEgcG9zdC1kaWFsIGNoYXIsIGJ1dCBkb2VzIG5vdApAQCAtNTYyLDIxICs1NTYsMjEgQEAKICAgICBwcml2YXRlIGJvb2xlYW4KICAgICBwcm9jZXNzUG9zdERpYWxDaGFyKGNoYXIgYykgewogICAgICAgICBpZiAoUGhvbmVOdW1iZXJVdGlscy5pczEyS2V5KGMpKSB7Ci0gICAgICAgICAgICBvd25lci5jbS5zZW5kRHRtZihjLCBoLm9idGFpbk1lc3NhZ2UoRVZFTlRfRFRNRl9ET05FKSk7CisgICAgICAgICAgICBtT3duZXIubUNpLnNlbmREdG1mKG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mIChtUG9zdERpYWxTdHJpbmcgPT0gbnVsbCB8fAorICAgICAgICAgICAgICAgIG1Qb3N0RGlhbFN0cmluZy5sZW5ndGgoKSA8PSBtTmV4dFBvc3REaWFsQ2hhcikgewogICAgICAgICAgICAgc2V0UG9zdERpYWxTdGF0ZShQb3N0RGlhbFN0YXRlLkNPTVBMRVRFKTsKIAogICAgICAgICAgICAgLy8gbm90aWZ5TWVzc2FnZS5hcmcxIGlzIDAgb24gY29tcGxldGUKQEAgLTYzOCwyNyArNjMzLDI3IEBACiAKICAgICAgICAgICAgIHNldFBvc3REaWFsU3RhdGUoUG9zdERpYWxTdGF0ZS5TVEFSVEVEKTsKIAotICAgICAgICAgICAgYyA9IHBvc3REaWFsU3RyaW5nLmNoYXJBdChuZXh0UG9zdERpYWxDaGFyKyspOworICAgICAgICAgICAgYyA9IG1Qb3N0RGlhbFN0cmluZy5jaGFyQXQobU5leHRQb3N0RGlhbENoYXIrKyk7CiAKICAgICAgICAgICAgIGlzVmFsaWQgPSBwcm9jZXNzUG9zdERpYWxDaGFyKGMpOwogCiAgICAgICAgICAgICBpZiAoIWlzVmFsaWQpIHsKICAgICAgICAgICAgICAgICAvLyBXaWxsIGNhbGwgcHJvY2Vzc05leHRQb3N0RGlhbENoYXIKLSAgICAgICAgICAgICAgICBoLm9idGFpbk1lc3NhZ2UoRVZFTlRfTkVYVF9QT1NUX0RJQUwpLnNlbmRUb1RhcmdldCgpOworICAgICAgICAgICAgICAgIG1IYW5kbGVyLm9idGFpbk1lc3NhZ2UoRVZFTlRfTkVYVF9QT1NUX0RJQUwpLnNlbmRUb1RhcmdldCgpOwogICAgICAgICAgICAgICAgIC8vIERvbid0IG5vdGlmeSBhcHBsaWNhdGlvbgogICAgICAgICAgICAgICAgIFJsb2cuZSgiR1NNIiwgInByb2Nlc3NOZXh0UG9zdERpYWxDaGFyOiBjPSIgKyBjICsgIiBpc24ndCB2YWxpZCEiKTsKICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAg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EVSVElORzsKKyAgICAgICAgcmV0dXJuIG1QYXJlbnQgPT0gbnVsbCB8fCBtUGFyZW50ID09IG1Pd25lci5tUmluZ2luZ0NhbGwKKyAgICAgICAgICAgIHx8IG1QYXJlbnQubVN0YXRlID09IEdzbUNhbGwuU3RhdGUuRElBTElORworICAgICAgICAgICAgfHwgbVBhcmVudC5tU3RhdGUgPT0gR3NtQ2FsbC5TdGF0ZS5BTEVSVElORzsKICAgICB9CiAKICAgICBwcml2YXRlIEdzbUNhbGwKQEAgLTY4OCwxNiArNjgzLDE2IEBACiAgICAgICAgICAgICBjYXNlIEFDVElWRToKICAgICAgICAgICAgIGNhc2UgRElBTElORzoKICAgICAgICAgICAgIGNhc2UgQUxFUlRJTkc6Ci0gICAgICAgICAgICAgICAgcmV0dXJuIG93bmVyLmZvcmVncm91bmRDYWxsOworICAgICAgICAgICAgICAgIHJldHVybiBtT3duZXIubUZvcmVncm91bmRDYWxsOwogICAgICAgICAgICAgLy9icmVhazsKIAogICAgICAgICAgICAgY2FzZSBIT0xESU5HOgotICAgICAgICAgICAgICAgIHJldHVybiBvd25lci5iYWNrZ3JvdW5kQ2FsbDsKKyAgICAgICAgICAgICAgICByZXR1cm4gbU93bmVyLm1CYWNrZ3JvdW5kQ2FsbDsKICAgICAgICAgICAgIC8vYnJlYWs7CiAKICAgICAgICAgICAgIGNhc2UgSU5DT01JTkc6CiAgICAgICAgICAgICBjYXNlIFdBSVRJTkc6Ci0gICAgICAgICAgICAgICAgcmV0dXJuIG93bmVyLnJpbmdpbmdDYWxsOworICAgICAgICAgICAgICAgIHJldHVybiBtT3duZXIubVJpbmdpbmdDYWxsOwogICAgICAgICAgICAgLy9icmVhazsKIAogICAgICAgICAgICAgZGVmYXVsdDoKQEAgLTcxMiwxNyArNzA3LDE3IEBACiAgICAgICogQHBhcmFtIHMgbmV3IFBvc3REaWFsU3RhdGUKICAgICAgKi8KICAgICBwcml2YXRlIHZvaWQgc2V0UG9zdERpYWxTdGF0ZShQb3N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AogICAgICAgICByZXR1cm4gcmV0OwpAQCAtMjMzLDE1ICsyMzMsMTUgQEAKIAogICAgICAgICByZXQgPSBuZXcgR3NtTW1pQ29kZShwaG9uZSwgYXBwKTsKIAotICAgICAgICByZXQubWVzc2FnZSA9IHVzc2RNZXNzYWdlOwotICAgICAgICByZXQuaXNVc3NkUmVxdWVzdCA9IGlzVXNzZFJlcXVlc3Q7CisgICAgICAgIHJldC5tTWVzc2FnZSA9IHVzc2RNZXNzYWdlOworICAgICAgICByZXQubUlzVXNzZFJlcXVlc3QgPSBpc1Vzc2RSZXF1ZXN0OwogCiAgICAgICAgIC8vIElmIGl0J3MgYSByZXF1ZXN0LCBzZXQgdG8gUEVORElORyBzbyB0aGF0IGl0J3MgY2FuY2VsYWJsZS4KICAgICAgICAgaWYgKGlzVXNzZFJlcXVlc3QpIHsKLSAgICAgICAgICAgIHJldC5pc1BlbmRpbmdVU1NEID0gdHJ1ZTsKLSAgICAgICAgICAgIHJldC5zdGF0ZSA9IFN0YXRlLlBFTkRJTkc7CisgICAgICAgICAgICByZXQubUlzUGVuZGluZ1VTU0QgPSB0cnVlOworICAgICAgICAgICAgcmV0Lm1TdGF0ZSA9IFN0YXRlLlBFTkRJTkc7CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICByZXQuc3RhdGUgPSBTdGF0ZS5DT01QTEVURTsKKyAgICAgICAgICAgIHJldC5tU3RhdGUgPSBTdGF0ZS5DT01QTEVURTsKICAgICAgICAgfQogCiAgICAgICAgIHJldHVybiByZXQ7CkBAIC0yNTIsOSArMjUyLDkgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBVaWNjQ2FyZEFwcGxpY2F0aW9uIGFwcCkgewogICAgICAgICBHc21NbWlDb2RlIHJldCA9IG5ldyBHc21NbWlDb2RlKHBob25lLCBhcHApOwogCi0gICAgICAgIHJldC5tZXNzYWdlID0gdXNzZE1lc3NnZTsKLSAgICAgICAgcmV0LnN0YXRlID0gU3RhdGUuUEVORElORzsKLSAgICAgICAgcmV0LmlzUGVuZGluZ1VTU0QgPSB0cnVlOworICAgICAgICByZXQubU1lc3NhZ2UgPSB1c3NkTWVzc2dlOworICAgICAgICByZXQubVN0YXRlID0gU3RhdGUuUEVORElORzsKKyAgICAgICAgcmV0Lm1Jc1BlbmRpbmdVU1NEID0gdHJ1ZTsKIAogICAgICAgICByZXR1cm4gcmV0OwogICAgIH0KQEAgLTQwNSw4ICs0MDUsOCBAQAogICAgICAgICAvLyBUaGUgdGVsZXBob255IHVuaXQtdGVzdCBjYXNlcyBtYXkgY3JlYXRlIEdzbU1taUNvZGUncwogICAgICAgICAvLyBpbiBzZWNvbmRhcnkgdGhyZWFkcwogICAgICAgICBzdXBlcihwaG9uZS5nZXRIYW5kbGVyKCkuZ2V0TG9vcGVyKCkpOwotICAgICAgICB0aGlzLnBob25lID0gcGhvbmU7Ci0gICAgICAgIHRoaXMuY29udGV4dCA9IHBob25lLmdldENvbnRleHQoKTsKKyAgICAgICAgbVBob25lID0gcGhvbmU7CisgICAgICAgIG1Db250ZXh0ID0gcGhvbmUuZ2V0Q29udGV4dCgpOwogICAgICAgICBtVWljY0FwcGxpY2F0aW9uID0gYXBwOwogICAgICAgICBpZiAoYXBwICE9IG51bGwpIHsKICAgICAgICAgICAgIG1JY2NSZWNvcmRzID0gYXBwLmdldEljY1JlY29yZHMoKTsKQEAgLTQxNSwzMiArNDE1LDM1IEBACiAKICAgICAvLyoqKioqIE1taUNvZGUgaW1wbGVtZW50YXRpb24KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdGF0ZQogICAgIGdldFN0YXRlKCkgewotICAgICAgICByZXR1cm4gc3RhdGU7CisgICAgICAgIHJldHVybiBtU3RhdGU7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIENoYXJTZXF1ZW5jZQogICAgIGdldE1lc3NhZ2UoKSB7Ci0gICAgICAgIHJldHVybiBtZXNzYWdlOworICAgICA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ENvZGUoKSB7Ci0gICAgICAgIHJldHVybiBwb3VuZFN0cmluZyA9PSBudWxsCi0gICAgICAgICAgICAgICAgICAgICYmIGRpYWxpbmdOdW1iZXIgIT0gbnVsbCAmJiBkaWFsaW5nTnVtYmVyLmxlbmd0aCgpIDw9IDI7CisgICAgICAgIHJldHVybiBtUG91bmRTdHJpbmcgPT0gbnVsbAorICAgICAgICAgICAgICAgICAgICAmJiBtRGlhbGluZ051bWJlciAhPSBudWxsICYmIG1EaWFsaW5nTnVtYmVyLmxlbmd0aCgpIDw9IDI7CiAKICAgICB9CiAKQEAgLTU1OCw4ICs1NjIsOCBAQAogICAgICAqIEByZXR1cm4gdHJ1ZSBpZiB0aGUgU2VydmljZSBDb2RlIGlzIFBJTi9QSU4yL1BVSy9QVUsyLXJlbGF0ZWQKICAgICAgKi8KICAgICBib29sZWFuIGlzUGluQ29tbWFuZCgpIHsKLSAgICAgICAgcmV0dXJuIHNjICE9IG51bGwgJiYgKHNjLmVxdWFscyhTQ19QSU4pIHx8IHNjLmVxdWFscyhTQ19QSU4yKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfHwgc2MuZXF1YWxzKFNDX1BVSykgfHwgc2MuZXF1YWxzKFNDX1BVSzIpKTsKKyAgICAgICAgcmV0dXJuIG1TYyAhPSBudWxsICYmIChtU2MuZXF1YWxzKFNDX1BJTikgfHwgbVNjLmVxdWFscyhTQ19QSU4yKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfHwgbVNjLmVxdWFscyhTQ19QVUspIHx8IG1TYy5lcXVhbHMoU0NfUFVLMikpOwogICAgICB9CiAKICAgICAvKioKQEAgLTU3MSw3ICs1NzUsNyBAQAogICAgICAqLwogICAgIGJvb2xlYW4KICAgICBpc1RlbXBvcmFyeU1vZGVDTElSKCkgewotICAgICAgICByZXR1cm4gc2MgIT0gbnVsbCAmJiBzYy5lcXVhbHMoU0NfQ0xJUikgJiYgZGlhbGluZ051bWJlciAhPSBudWxsCisgICAgICA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3MgYSBNTUkgY29kZSBvciBzaG9ydCBjb2RlLi4uYW55dGhpbmcgdGhhdCBpc24ndCBhIGRpYWxpbmcgbnVtYmVyICovCkBAIC02MzEsNDIgKzYzNiw0MiBAQAogICAgICAgICAgICAgaWYgKGlzU2hvcnRDb2RlKCkpIHsKICAgICAgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgImlzU2hvcnRDb2RlIik7CiAgICAgICAgICAgICAgICAgLy8gVGhlc2UganVzdCBnZXQgdHJlYXRlZCBhcyBVU1NELgotICAgICAgICAgICAgICAgIHNlbmRVc3NkKGRpYWxpbmdOdW1iZXIpOwotICAgICAgICAgICAgfSBlbHNlIGlmIChkaWFsaW5nTnVtYmVyICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICBzZW5kVXNzZChtRGlhbGluZ051bWJlcik7CisgICAgICAgICAgICB9IGVsc2UgaWYgKG1EaWFsaW5nTnVtYmVyICE9IG51bGwpIHsKICAgICAgICAgICAgICAgICAvLyBXZSBzaG91bGQgaGF2ZSBubyBkaWFsaW5nIG51bWJlcnMgaGVyZQogICAgICAgICAgICAgICAgIHRocm93IG5ldyBSdW50aW1lRXhjZXB0aW9uICgiSW52YWxpZCBvciBVbnN1cHBvcnRlZCBNTUkgQ29kZSIpOwotICAgICAgICAgICAgfSBlbHNlIGlmIChzYyAhPSBudWxsICYmIHNjLmVxdWFscyhTQ19DTElQKSkgeworICAgICAgICAgICAgfSBlbHNlIGlmIChtU2MgIT0gbnVsbCAmJiBtU2MuZXF1YWxzKFNDX0NMSVApKSB7CiAgICAgICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsICJpcyBDTElQIik7CiAgICAgICAgICAgICAgICAgaWYgKGlzSW50ZXJyb2dhdGUoKSkgewotICAgICAgICAgICAgICAgICAgICBwaG9uZS5tQ00ucXVlcnlDTElQKAorICAgICAgICAgICAgICAgICAgICBtUGhvbmUubUNpLnF1ZXJ5Q0xJUCgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX1FVRVJZX0NPTVBMRVRFLCB0aGlzKSk7CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IFJ1bnRpbWVFeGNlcHRpb24gKCJJbnZhbGlkIG9yIFVuc3VwcG9ydGVkIE1NSSBDb2RlIik7CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgfSBlbHNlIGlmIChzYyAhPSBudWxsICYmIHNjLmVxdWFscyhTQ19DTElSKSkgeworICAgICAgICAgICAgfSBlbHNlIGlmIChtU2MgIT0gbnVsbCAmJiBtU2MuZXF1YWxzKFNDX0NMSVIpKSB7CiAgICAgICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsICJpcyBDTElSIik7CiAgICAgICAgICAgICAgICAgaWYgKGlzQWN0aXZhdGUoKSkgewotICAgICAgICAgICAgICAgICAgICBwaG9uZS5tQ00uc2V0Q0xJUihDb21tYW5kc0ludGVyZmFjZS5DTElSX0lOVk9DQVRJT04sCisgICAgICAgICAgICAgICAgICAgIG1QaG9uZS5tQ2kuc2V0Q0xJUihDb21tYW5kc0ludGVyZmFjZS5DTElSX0lOVk9DQVRJT04sCiAgICAgICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX1NFVF9DT01QTEVURSwgdGhpcykpOwogICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNEZWFjdGl2YXRlKCkpIHsKLSAgICAgICAgICAgICAgICAgICAgcGhvbmUubUNNLnNldENMSVIoQ29tbWFuZHNJbnRlcmZhY2UuQ0xJUl9TVVBQUkVTU0lPTiwKKyAgICAgICAgICAgICAgICAgICAgbVBob25lLm1DaS5zZXRDTElSKENvbW1hbmRzSW50ZXJmYWNlLkNMSVJfU1VQUFJFU1NJT04sCiAgICAgICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX1NFVF9DT01QTEVURSwgdGhpcykpOwogICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNJbnRlcnJvZ2F0ZSgpKSB7Ci0gICAgICAgICAgICAgICAgICAgIHBob25lLm1DTS5nZXRDTElSKAorICAgICAgICAgICAgICAgICAgICBtUGhvbmUubUNpLmdldENMSVIoCiAgICAgICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX0dFVF9DTElSX0NPTVBMRVRFLCB0aGlzKSk7CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IFJ1bnRpbWVFeGNlcHRpb24gKCJJbnZhbGlkIG9yIFVuc3VwcG9ydGVkIE1NSSBDb2RlIik7CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgfSBlbHNlIGlmIChpc1NlcnZpY2VDb2RlQ2FsbEZvcndhcmRpbmcoc2MpKSB7CisgICAgICAgICAgICB9IGVsc2UgaWYgKGlzU2VydmljZUNvZGVDYWxsRm9yd2FyZGluZyhtU2MpKSB7CiAgICAgICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsICJpcyBDRiIpOwogCi0gICAgICAgICAgICAgICAgU3RyaW5nIGRpYWxpbmdOdW1iZXIgPSBzaWE7Ci0gICAgICAgICAgICAgICAgaW50IHNlcnZpY2VDbGFzcyA9IHNpVG9TZXJ2aWNlQ2xhc3Moc2liKTsKLSAgICAgICAgICAgICAgICBpbnQgcmVhc29uID0gc2NUb0NhbGxGb3J3YXJkUmVhc29uKHNjKTsKLSAgICAgICAgICAgICAgICBpbnQgdGltZSA9IHNpVG9UaW1lKHNpYyk7CisgICAgICAgICAgICAgICAgU3RyaW5nIGRpYWxpbmdOdW1iZXIgPSBtU2lhOworICAgICAgICAgICAgICAgIGludCBzZXJ2aWNlQ2xhc3MgPSBzaVRvU2VydmljZUNsYXNzKG1TaWIpOworICAgICAgICAgICAgICAgIGludCByZWFzb24gPSBzY1RvQ2FsbEZvcndhcmRSZWFzb24obVNjKTsKKyAgICAgICAgICAgICAgICBpbnQgdGltZSA9IHNpVG9UaW1lKG1TaWMpOwogCiAgICAgICAgICAgICAgICAgaWYgKGlzSW50ZXJyb2dhdGUoKSkgewotICAgICAgICAgICAgICAgICAgICBwaG9uZS5tQ00ucXVlcnlDYWxsRm9yd2FyZFN0YXR1cygKKyAgICAgICAgICAgICAgICAgICAgbVBob25lLm1DaS5xdWVyeUNhbGxGb3J3YXJkU3RhdHVzKAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbiwgc2VydmljZUNsYXNzLCAgZGlhbGluZ051bWJlciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZShFVkVOVF9RVUVSWV9DRl9DT01QTEVURSwgdGhpcykpOwogICAgICAgICAgICAgICAgIH0gZWxzZSB7CkBAIC02NzksMTAgKzY4NCwxMCBAQAogICAgICAgICAgICAgICAgICAgICAgICAgLy8gbnVtYmVyLCBvciBhbiBhY3RpdmF0aW9uIGlmIG5vdAogICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzRW1wdHlPck51bGwoZGlhbGluZ051bWJlcikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjZkFjdGlvbiA9IENvbW1hbmRzSW50ZXJmYWNlLkNGX0FDVElPTl9FTkFCTEU7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNDYWxsRndkUmVnID0gZmFsc2U7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUlzQ2FsbEZ3ZFJlZyA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjZkFjdGlvbiA9IENvbW1hbmRzSW50ZXJmYWNlLkNGX0FDVElPTl9SRUdJU1RSQVRJT047Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNDYWxsRndkUmVnID0gdHJ1ZTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBtSXNDYWxsRndkUmVnID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChpc0RlYWN0aXZhdGUoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgY2ZBY3Rpb24gPSBDb21tYW5kc0ludGVyZmFjZS5DRl9BQ1RJT05fRElTQUJMRTsKQEAgLTcwNSw1MCArNzEwLDUwIEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChjZkFjdGlvbiA9PSBDb21tYW5kc0ludGVyZmFjZS5DRl9BQ1RJT05fUkVHSVNUUkFUSU9OKSkgPyAxIDogMDsKIAogICAgICAgICAgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgImlzIENGIHNldENhbGxGb3J3YXJkIik7Ci0gICAgICAgICAgICAgICAgICAgIHBob25lLm1DTS5zZXRDYWxsRm9yd2FyZChjZkFjdGlvbiwgcmVhc29uLCBzZXJ2aWNlQ2xhc3MsCisgICAgICAgICAgICAgICAgICAgIG1QaG9uZS5tQ2kuc2V0Q2FsbEZvcndhcmQoY2ZBY3Rpb24sIHJlYXNvbiwgc2VydmljZUNsYXNzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpYWxpbmdOdW1iZXIsIHRpbWUsIG9idGFpbk1lc3NhZ2UoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBFVkVOVF9TRVRfQ0ZGX0NPTVBMRVRFLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNTZXR0aW5nVW5jb25kaXRpb25hbFZvaWNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNFbmFibGVEZXNpcmVkLCB0aGlzKSk7CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgfSBlbHNlIGlmIChpc1NlcnZpY2VDb2RlQ2FsbEJhcnJpbmcoc2MpKSB7CisgICAgICAgICAgICB9IGVsc2UgaWYgKGlzU2Vydm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gICAgICAgICAgICAgICAgICAgbVBob25lLm1DaS5zZXRGYWNpbGl0eUxvY2soZmFjaWxpdHksIGlzQWN0aXZhdGUoKSwgcGFzc3dvcmQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VydmljZUNsYXNzLCBvYnRhaW5NZXNzYWdlKEVWRU5UX1NFVF9DT01QTEVURSwgdGhpcykpOwogICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBSdW50aW1lRXhjZXB0aW9uICgiSW52YWxpZCBvciBVbnN1cHBvcnRlZCBNTUkgQ29kZSIpOwogICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgfSBlbHNlIGlmIChzYyAhPSBudWxsICYmIHNjLmVxdWFscyhTQ19QV0QpKSB7CisgICAgICAgICAgICB9IGVsc2UgaWYgKG1TYyAhPSBudWxsICYmIG1TYy5lcXVhbHMoU0NfUFdEKSkgewogICAgICAgICAgICAgICAgIC8vIHNpYSA9IGZhYwogICAgICAgICAgICAgICAgIC8vIHNpYiA9IG9sZCBwd2QKICAgICAgICAgICAgICAgICAvLyBzaWMgPSBuZXcgcHdkCiAgICAgICAgICAgICAgICAgLy8gcHdkID0gbmV3IHB3ZAogICAgICAgICAgICAgICAgIFN0cmluZyBmYWNpbGl0eTsKLSAgICAgICAgICAgICAgICBTdHJpbmcgb2xkUHdkID0gc2liOwotICAgICAgICAgICAgICAgIFN0cmluZyBuZXdQd2QgPSBzaWM7CisgICAgICAgICAgICAgICAgU3RyaW5nIG9sZFB3ZCA9IG1TaWI7CisgICAgICAgICAgICAgICAgU3RyaW5nIG5ld1B3ZCA9IG1TaWM7CiAgICAgICAgICAgICAgICAgaWYgKGlzQWN0aXZhdGUoKSB8fCBpc1JlZ2lzdGVyKCkpIHsKICAgICAgICAgICAgICAgICAgICAgLy8gRXZlbiB0aG91Z2ggQUNUSVZBVEUgaXMgYWNjZXB0YWJsZSwgdGhpcyBpcyByZWFsbHkgdGVybWVkIGEgUkVHSVNURVIKLSAgICAgICAgICAgICAgICAgICAgYWN0aW9uID0gQUNUSU9OX1JFR0lTVEVSOworICAgICAgICAgICAgICAgICAgICBtQWN0aW9uID0gQUNUSU9OX1JFR0lTVEVSOwogCi0gICAgICAgICAgICAgICAgICAgIGlmIChzaWEgPT0gbnVsbCkgeworICAgICAgICAgICAgICAgICAgICBpZiAobVNpYSA9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBJZiBzYyB3YXMgbm90IHNwZWNpZmllZCwgdHJlYXQgaXQgYXMgQkFfQUxMLgogICAgICAgICAgICAgICAgICAgICAgICAgZmFjaWxpdHkgPSBDb21tYW5kc0ludGVyZmFjZS5DQl9GQUNJTElUWV9CQV9BTEw7CiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBmYWNpbGl0eSA9IHNjVG9CYXJyaW5nRmFjaWxpdHkoc2lhKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGZhY2lsaXR5ID0gc2NUb0JhcnJpbmdGYWNpbGl0eShtU2lhKTsKICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBpZiAobmV3UHdkLmVxdWFscyhwd2QpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBwaG9uZS5tQ00uY2hhbmdlQmFycmluZ1Bhc3N3b3JkKGZhY2lsaXR5LCBvbGRQd2QsCisgICAgICAgICAgICAgICAgICAgIGlmIChuZXdQd2QuZXF1YWxzKG1Qd2QpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBtUGhvbmUubUNpLmNoYW5nZUJhcnJpbmdQYXNzd29yZChmYWNpbGl0eSwgb2xkUHdkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdQd2QsIG9idGFpbk1lc3NhZ2UoRVZFTlRfU0VUX0NPTVBMRVRFLCB0aGlzKSk7CiAgICAgICAgICAgICAgICAgICAgIH0gZWxz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FpdGluZyhzZXJ2aWNlQ2xhc3MsCisgICAgICAgICAgICAgICAgICAgIG1QaG9uZS5tQ2kucXVlcnlDYWxsV2FpdGluZyhzZXJ2aWNlQ2xhc3MsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZShFVkVOVF9RVUVSWV9DT01QTEVURSwgdGhpcykpOwogICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBSdW50aW1lRXhjZXB0aW9uICgiSW52YWxpZCBvciBVbnN1cHBvcnRlZCBNTUkgQ29kZSIpOwpAQCAtNzc1LDU5ICs3ODAsNTkgQEAKICAgICAgICAgICAgICAgICAvLyBzaWEgPSBvbGQgUElOIG9yIFBVSwogICAgICAgICAgICAgICAgIC8vIHNpYiA9IG5ldyBQSU4KICAgICAgICAgICAgICAgICAvLyBzaWMgPSBuZXcgUElOCi0gICAgICAgICAgICAgICAgU3RyaW5nIG9sZFBpbk9yUHVrID0gc2lhOwotICAgICAgICAgICAgICAgIFN0cmluZyBuZXdQaW4gPSBzaWI7CisgICAgICAgICAgICAgICAgU3RyaW5nIG9sZFBpbk9yUHVrID0gbVNpYTsKKyAgICAgICAgICAgICAgICBTdHJpbmcgbmV3UGluID0gbVNpYjsKICAgICAgICAgICAgICAgICBpbnQgcGluTGVuID0gbmV3UGluLmxlbmd0aCgpOwogICAgICAgICAgICAgICAgIGlmIChpc1JlZ2lzdGVyKCkpIHsKLSAgICAgICAgICAgICAgICAgICAgaWYgKCFuZXdQaW4uZXF1YWxzKHNpYykpIHsKKyAgICAgICAgICAgICAgICAgICAgaWYgKCFuZXdQaW4uZXF1YWxzKG1TaWMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBwYXNzd29yZCBtaXNtYXRjaDsgcmV0dXJuIGVycm9yCiAgICAgICAgICAgICAgICAgICAgICAgICBoYW5kbGVQYXNzd29yZEVycm9yKGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLm1pc21hdGNoUGluKTsKICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChwaW5MZW4gPCA0IHx8IHBpbkxlbiA+IDggKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBpbnZhbGlkIGxlbmd0aAogICAgICAgICAgICAgICAgICAgICAgICAgaGFuZGxlUGFzc3dvcmRFcnJvcihjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5pbnZhbGlkUGluKTsKLSAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzYy5lcXVhbHMoU0NfUElOKSAmJgorICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG1TYy5lcXVhbHMoU0NfUElOKSAmJgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1VaWNjQXBwbGljYXRpb24gIT0gbnVsbCAmJgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1VaWNjQXBwbGljYXRpb24uZ2V0U3RhdGUoKSA9PSBBcHBTdGF0ZS5BUFBTVEFURV9QVUsgKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBTaW0gaXMgcHVrLWxvY2tlZAogICAgICAgICAgICAgICAgICAgICAgICAgaGFuZGxlUGFzc3dvcmRFcnJvcihjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5uZWVkUHVrKTsKICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHByZS1jaGVja3MgT0sKLSAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzYy5lcXVhbHMoU0NfUElOKSkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBob25lLm1DTS5jaGFuZ2VJY2NQaW4ob2xkUGluT3JQdWssIG5ld1BpbiwKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtU2MuZXF1YWxzKFNDX1BJTikpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBtUGhvbmUubUNpLmNoYW5nZUljY1BpbihvbGRQaW5PclB1aywgbmV3UGluLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZShFVkVOVF9TRVRfQ09NUExFVEUsIHRoaXMpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoc2MuZXF1YWxzKFNDX1BJTjIpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgcGhvbmUubUNNLmNoYW5nZUljY1BpbjIob2xkUGluT3JQdWssIG5ld1BpbiwKKyAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAobVNjLmVxdWFscyhTQ19QSU4yKSkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1QaG9uZS5tQ2kuY2hhbmdlSWNjUGluMihvbGRQaW5PclB1aywgbmV3UGluLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZShFVkVOVF9TRVRfQ09NUExFVEUsIHRoaXMpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoc2MuZXF1YWxzKFNDX1BVSykpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBwaG9uZS5tQ00uc3VwcGx5SWNjUHVrKG9sZFBpbk9yUHVrLCBuZXdQaW4sCisgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG1TYy5lcXVhbHMoU0NfUFVLKSkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1QaG9uZS5tQ2kuc3VwcGx5SWNjUHVrKG9sZFBpbk9yUHVrLCBuZXdQaW4sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX1NFVF9DT01QTEVURSwgdGhpcykpOwotICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzYy5lcXVhbHMoU0NfUFVLMikpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBwaG9uZS5tQ00uc3VwcGx5SWNjUHVrMihvbGRQaW5PclB1aywgbmV3UGluLAorICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChtU2MuZXF1YWxzKFNDX1BVSzIpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbVBob25lLm1DaS5zdXBwbHlJY2NQdWsyKG9sZFBpbk9yUHVrLCBuZXdQaW4sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX1NFVF9DT01QTEVURSwgdGhpcykpOwogICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IFJ1bnRpbWVFeGNlcHRpb24gKCJJbnZhbGlkIG9yIFVuc3VwcG9ydGVkIE1NSSBDb2RlIik7CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgfSBlbHNlIGlmIChwb3VuZFN0cmluZyAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgc2VuZFVzc2QocG91bmRTdHJpbmcpOworICAgICAgICAgICAgfSBlbHNlIGlmIChtUG91bmRTdHJpbmcgIT0gbnVsbCkgeworICAgICAgICAgICAgICAgIHNlbmRVc3NkKG1Qb3VuZFN0cmluZyk7CiAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgIHRocm93IG5ldyBSdW50aW1lRXhjZXB0aW9uICgiSW52YWxpZCBvciBVbnN1cHBvcnRlZCBNTUkgQ29kZSIpOwogICAgICAgICAgICAgfQogICAgICAgICB9IGNhdGNoIChSdW50aW1lRXhjZXB0aW9uIGV4YykgewotICAgICAgICAgICAgc3RhdGUgPSBTdGF0ZS5GQUlMRUQ7Ci0gICAgICAgICAgICBtZXNzYWdlID0gY29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsL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ICAgICBpZiAodXNzZE1lc3NhZ2UgPT0gbnVsbCkgewotICAgICAgICAgICAgICAgIG1lc3NhZ2UgPSBjb250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcubW1pQ29tcGxldGUpOworICAgICAgICAgICAgICAgIG1NZXNzYWdlID0gbUNvbnRleHQuZ2V0VGV4dChjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5tbWlDb21wbGV0ZSk7CiAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgIG1lc3NhZ2UgPSB1c3NkTWVzc2FnZTsKKyAgICAgICAgICAgICAgICBtTWVzc2FnZSA9IHVzc2RNZXNzYWdlOwogICAgICAgICAgICAgfQotICAgICAgICAgICAgdGhpcy5pc1Vzc2RSZXF1ZXN0ID0gaXNVc3NkUmVxdWVzdDsKKyAgICAgICAgICAgIG1Jc1Vzc2RSZXF1ZXN0ID0gaXNVc3NkUmVxdWVzdDsKICAgICAgICAgICAgIC8vIElmIGl0J3MgYSByZXF1ZXN0LCBsZWF2ZSBpdCBQRU5ESU5HIHNvIHRoYXQgaXQncyBjYW5jZWxhYmxlLgogICAgICAgICAgICAgaWYgKCFpc1Vzc2RSZXF1ZXN0KSB7Ci0gICAgICAgICAgICAgICAgc3RhdGUgPSBTdGF0ZS5DT01QTEVURTsKKyAgICAgICAgICAgICAgICBtU3RhdGUgPSBTdGF0ZS5DT01QTEVURTsKICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgcGhvbmUub25NTUlEb25lKHRoaXMpOworICAgICAgICAgICAgbVBob25lLm9uTU1JRG9uZSh0aGlzKTsKICAgICAgICAgfQogICAgIH0KIApAQCAtODY1LDI4ICs4NzAsMjkgQEAKIAogICAgIHZvaWQKICAgICBvblVzc2RGaW5pc2hlZEVycm9yKCkgewotICAgICAgICBpZiAoc3RhdGUgPT0gU3RhdGUuUEVORElORykgewotICAgICAgICAgICAgc3RhdGUgPSBTdGF0ZS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Fpbk1lc3NhZ2UoRVZFTlRfVVNTRF9DT01QTEVURSwgdGhpcykpOwogICAgIH0KIAogICAgIC8qKiBDYWxsZWQgZnJvbSBHU01QaG9uZS5oYW5kbGVNZXNzYWdlOyBub3QgYSBIYW5kbGVyIHN1YmNsYXNzICovCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQKICAgICBoYW5kbGVNZXNzYWdlIChNZXNzYWdlIG1zZykgewogICAgICAgICBBc3luY1Jlc3VsdCBhcjsKQEAgLTkzNCwxMCArOTQwLDEwIEBACiAgICAgICAgICAgICAgICAgYXIgPSAoQXN5bmNSZXN1bHQpIChtc2cub2JqKTsKIAogICAgICAgICAgICAgICAgIGlmIChhci5leGNlcHRpb24gIT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICBzdGF0ZSA9IFN0YXRlLkZBSUxFRDsKLSAgICAgICAgICAgICAgICAgICAgbWVzc2FnZSA9IGdldEVycm9yTWVzc2FnZShhcik7CisgICAgICAgICAgICAgICAgICAgIG1TdGF0ZSA9IFN0YXRlLkZBSUxFRDsKKyAgICAgICAgICAgICAgICAgICAgbU1lc3NhZ2UgPSBnZXRFcnJvck1lc3NhZ2UoYXIpOwogCi0gICAgICAgICAgICAgICAgICAgIHBob25lLm9uTU1JRG9uZSh0aGlzKTsKKyAgICAgICAgICAgICAgICAgICAgbVBob25lLm9uTU1JRG9uZSh0aGlzKTsKICAgICAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgICAgICAvLyBOb3RlIHRoYXQgdW5saWtlIG1vc3QgZXZlcnl0aGluZyBlbHNlLCB0aGUgVVNTRCBjb21wbGV0ZQpAQCAtOTQ4LDcgKzk1NCw3IEBACiAgICAgICAgICAgICBicmVhazsKIAogICAgICAgICAgICAgY2FzZSBFVkVOVF9VU1NEX0NBTkNFTF9DT01QTEVURToKLSAgICAgICAgICAgICAgICBwaG9uZS5vbk1NSURvbmUodGhpcyk7CisgICAgICAgICAgICAgICAgbVBob25lLm9uTU1JRG9uZSh0aGlzKTsKICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICB9CiAgICAgfQpAQCAtOTYwLDI5ICs5NjYsMjkgQEAKICAgICAgICAgICAgIENvbW1hbmRFeGNlcHRpb24uRXJyb3IgZXJyID0gKChDb21tYW5kRXhjZXB0aW9uKShhci5leGNlcHRpb24pKS5nZXRDb21tYW5kRXJyb3IoKTsKICAgICAgICAgICAgIGlmIChlcnIgPT0gQ29tbWFuZEV4Y2VwdGlvbi5FcnJvci5GRE5fQ0hFQ0tfRkFJTFVSRSkgewogICAgICAgICAgICAgICAgIFJsb2cuaShMT0dfVEFHLCAiRkROX0NIRUNLX0ZBSUxVUkUiKTsKLSAgICAgICAgICAgICAgICByZXR1cm4gY29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLm1taUZkbkVycm9yKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gbUNvbnRleHQuZ2V0VGV4dChjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5tbWlGZG5FcnJvcik7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KIAotICAgICAgICByZXR1cm4gY29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLm1taUVycm9yKTsKKyAgICAgICAgcmV0dXJuIG1Db250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcubW1pRXJyb3IpOwogICAgIH0KIAogICAgIHByaXZhdGUgQ2hhclNlcXVlbmNlIGdldFNjU3RyaW5nKCkgewotICAgICAgICBpZiAoc2MgIT0gbnVsbCkgewotICAgICAgICAgICAgaWYgKGlzU2VydmljZUNvZGVDYWxsQmFycmluZyhzYykpIHsKLSAgICAgICAgICAgICAgICByZXR1cm4gY29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLkJhTW1pKTsKLSAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNTZXJ2aWNlQ29kZUNhbGxGb3J3YXJkaW5nKHNjKSkgewotICAgICAgICAgICAgICAgIHJldHVybiBjb250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuQ2ZNbWkpOwotICAgICAgICAgICAgfSBlbHNlIGlmIChzYy5lcXVhbHMoU0NfQ0xJUCkpIHsKLSAgICAgICAgICAgICAgICByZXR1cm4gY29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLkNsaXBNbWkpOwotICAgICAgICAgICAgfSBlbHNlIGlmIChzYy5lcXVhbHMoU0NfQ0xJUikpIHsKLSAgICAgICAgICAgICAgICByZXR1cm4gY29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLkNsaXJNbWkpOwotICAgICAgICAgICAgfSBlbHNlIGlmIChzYy5lcXVhbHMoU0NfUFdEKSkgewotICAgICAgICAgICAgICAgIHJldHVybiBjb250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuUHdkTW1pKTsKLSAgICAgICAgICAgIH0gZWxzZSBpZiAoc2MuZXF1YWxzKFNDX1dBSVQpKSB7Ci0gICAgICAgICAgICAgICAgcmV0dXJuIGNvbnRleHQuZ2V0VGV4dChjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5Dd01taSk7CisgICAgICAgIGlmIChtU2MgIT0gbnVsbCkgeworICAgICAgICAgICAgaWYgKGlzU2VydmljZUNvZGVDYWxsQmFycmluZyhtU2MpKSB7CisgICAgICAgICAgICAgICAgcmV0dXJuIG1Db250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuQmFNbWkpOworICAgICAgICAgICAgfSBlbHNlIGlmIChpc1NlcnZpY2VDb2RlQ2FsbEZvcndhcmRpbmcobVNjKSkgeworICAgICAgICAgICAgICAgIHJldHVybiBtQ29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLkNmTW1pKTsKKyAgICAgICAgICAgIH0gZWxzZSBpZiAobVNjLmVxdWFscyhTQ19DTElQKSkgeworICAgICAgICAgICAgICAgIHJldHVybiBtQ29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLkNsaXBNbWkpOworICAgICAgICAgICAgfSBlbHNlIGlmIChtU2MuZXF1YWxzKFNDX0NMSVIpKSB7CisgICAgICAgICAgICAgICAgcmV0dXJuIG1Db250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuQ2xpck1taSk7CisgICAgICAgICAgICB9IGVsc2UgaWYgKG1TYy5lcXVhbHMoU0NfUFdEKSkgeworICAgICAgICAgICAgICAgIHJldHVybiBtQ29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLlB3ZE1taSk7CisgICAgICAgICAgICB9IGVsc2UgaWYgKG1TYy5lcXVhbHMoU0NfV0FJVCkpIHsKKyAgICAgICAgICAgICAgICByZXR1cm4gbUNvbnRleHQuZ2V0VGV4dChjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5Dd01taSk7CiAgICAgICAgICAgICB9IGVsc2UgaWYgKGlzUGluQ29tbWFuZCgpKSB7Ci0gICAgICAgICAgICAgICAgcmV0dXJuIGNvbnRleHQuZ2V0VGV4dChjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5QaW5NbWkpOworICAgICAgICAgICAgICAgIHJldHVybiBtQ29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLlBpbk1taSk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KIApAQCAtOTk1LDc4ICsxMDAxLDc4IEBACiAgICAgICAgIHNiLmFwcGVuZCgiXG4iKTsKIAogICAgICAgICBpZiAoYXIuZXhjZXB0aW9uICE9IG51bGwpIHsKLSAgICAgICAgICAgIHN0YXRlID0gU3RhdGUuRkFJTEVEOworICAgICAgICAgICAgbVN0YXRlID0gU3RhdGUuRkFJTEVEOwogICAgICAgICAgICAgaWYgKGFyLmV4Y2VwdGlvbiBpbnN0YW5jZW9mIENvbW1hbmRFeGNlcHRpb24pIHsKICAgICAgICAgICAgICAgICBDb21tYW5kRXhjZXB0aW9uLkVycm9yIGVyciA9ICgoQ29tbWFuZEV4Y2VwdGlvbikoYXIuZXhjZXB0aW9uKSkuZ2V0Q29tbWFuZEVycm9yKCk7CiAgICAgICAgICAgICAgICAgaWYgKGVyciA9PSBDb21tYW5kRXhjZXB0aW9uLkVycm9yLlBBU1NXT1JEX0lOQ09SUkVDVCkgewogICAgICAgICAgICAgICAgICAgICBpZiAoaXNQaW5Db21tYW5kKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGxvb2sgc3BlY2lmaWNhbGx5IGZvciB0aGUgUFVLIGNvbW1hbmRzIGFuZCBhZGp1c3QKICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHRoZSBtZXNzYWdlIGFjY29yZGluZ2x5LgotICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNjLmVxdWFscyhTQ19QVUspIHx8IHNjLmVxdWFscyhTQ19QVUsyKSkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICAgICAgICAgICAgICBpZiAobVNjLmVxdWFscyhTQ19QVUspIHx8IG1TYy5lcXVhbHMoU0NfUFVLMikpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQobUNvbnRleHQuZ2V0VGV4dCgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLmJhZFB1aykpOwogICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQoY29udGV4dC5nZXRUZXh0KAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChtQ29udGV4dC5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuYmFkUGluKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQoY29udGV4dC5nZXRUZXh0KAorICAgICAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKG1Db250ZXh0LmdldFRleHQoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLnBhc3N3b3JkSW5jb3JyZWN0KSk7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGVyciA9PSBDb21tYW5kRXhjZXB0aW9uLkVycm9yLlNJTV9QVUsyKSB7Ci0gICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChtQ29udGV4dC5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLmJhZFBpbikpOwogICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQoIlxuIik7Ci0gICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChtQ29udGV4dC5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLm5lZWRQdWsyKSk7CiAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChlcnIgPT0gQ29tbWFuZEV4Y2VwdGlvbi5FcnJvci5GRE5fQ0hFQ0tfRkFJTFVSRSkgewogICAgICAgICAgICAgICAgICAgICBSbG9nLmkoTE9HX1RBRywgIkZETl9DSEVDS19GQUlMVVJFIik7Ci0gICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChjb250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcubW1pRmRuRXJyb3IpKTsKKyAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKG1Db250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcubW1pRmRuRXJyb3IpKTsKICAgICAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQoY29udGV4dC5nZXRUZXh0KAorICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQobUNvbnRleHQuZ2V0VGV4dCgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5tbWlFcnJvcikpOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgc2IuYXBwZW5kKGNvbnRleHQuZ2V0VGV4dCgKKyAgICAgICAgICAgICAgICBzYi5hcHBlbmQobUNvbnRleHQuZ2V0VGV4dCgKICAgICAgICAgICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLm1taUVycm9yKSk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0gZWxzZSBpZiAoaXNBY3RpdmF0ZSgpKSB7Ci0gICAgICAgICAgICBzdGF0ZSA9IFN0YXRlLkNPTVBMRVRFOwotICAgICAgICAgICAgaWYgKGlzQ2FsbEZ3ZFJlZykgewotICAgICAgICAgICAgICAgIHNiLmFwcGVuZChjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICBtU3RhdGUgPSBTdGF0ZS5DT01QTEVURTsKKyAgICAgICAgICAgIGlmIChtSXNDYWxsRndkUmVnKSB7CisgICAgICAgICAgICAgICAgc2IuYXBwZW5kKG1Db250ZXh0LmdldFRleHQoCiAgICAgICAgICAgICAgICAgICAgICAgICBjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5zZXJ2aWNlUmVnaXN0ZXJlZCkpOwogICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICBzYi5hcHBlbmQoY29udGV4dC5nZXRUZXh0KAorICAgICAgICAgICAgICAgIHNiLmFwcGVuZChtQ29udGV4dC5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuc2VydmljZUVuYWJsZWQpKTsKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIC8vIFJlY29yZCBDTElSIHNldHRpbmcKLSAgICAgICAgICAgIGlmIChzYy5lcXVhbHMoU0NfQ0xJUikpIHsKLSAgICAgICAgICAgICAgICBwaG9uZS5zYXZlQ2xpclNldHRpbmcoQ29tbWFuZHNJbnRlcmZhY2UuQ0xJUl9JTlZPQ0FUSU9OKTsKKyAgICAgICAgICAgIGlmIChtU2MuZXF1YWxzKFNDX0NMSVIpKSB7CisgICAgICAgICAgICAgICAgbVBob25lLnNhdmVDbGlyU2V0dGluZyhDb21tYW5kc0ludGVyZmFjZS5DTElSX0lOVk9DQVRJT04pOwogICAgICAgICAgICAgfQogICAgICAgICB9IGVsc2UgaWYgKGlzRGVhY3RpdmF0ZSgpKSB7Ci0gICAgICAgICAgICBzdGF0ZSA9IFN0YXRlLkNPTVBMRVRFOwotICAgICAgICAgICAgc2IuYXBwZW5kKGNvbnRleHQuZ2V0VGV4dCgKKyAgICAgICAgICAgIG1TdGF0ZSA9IFN0YXRlLkNPTVBMRVRFOworICAgICAgICAgICAgc2IuYXBwZW5kKG1Db250ZXh0LmdldFRleHQoCiAgICAgICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLnNlcnZpY2VEaXNhYmxlZCkpOwogICAgICAgICAgICAgLy8gUmVjb3JkIENMSVIgc2V0dGluZwotICAgICAgICAgICAgaWYgKHNjLmVxdWFscyhTQ19DTElSKSkgewotICAgICAgICAgICAgICAgIHBob25lLnNhdmVDbGlyU2V0dGluZyhDb21tYW5kc0ludGVyZmFjZS5DTElSX1NVUFBSRVNTSU9OKTsKKyAgICAgICAgICAgIGlmIChtU2MuZXF1YWxzKFNDX0NMSVIpKSB7CisgICAgICAgICAgICAgICAgbVBob25lLnNhdmVDbGlyU2V0dGluZyhDb21tYW5kc0ludGVyZmFjZS5DTElSX1NVUFBSRVNTSU9OKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfSBlbHNlIGlmIChpc1JlZ2lzdGVyKCkpIHsKLSAgICAgICAgICAgIHN0YXRlID0gU3RhdGUuQ09NUExFVEU7Ci0gICAgICAgICAgICBzYi5hcHBlbmQoY29udGV4dC5nZXRUZXh0KAorICAgICAgICAgICAgbVN0YXRlID0gU3RhdGUuQ09NUExFVEU7CisgICAgICAgICAgICBzYi5hcHBlbmQobUNvbnRleHQuZ2V0VGV4dCgKICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuc2VydmljZVJlZ2lzdGVyZWQpKTsKICAgICAgICAgfSBlbHNlIGlmIChpc0VyYXN1cmUoKSkgewotICAgICAgICAgICAgc3RhdGUgPSBTdGF0ZS5DT01QTEVURTsKLSAgICAgICAgICAgIHNiLmFwcGVuZChjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICBtU3RhdGUgPSBTdGF0ZS5DT01QTEVURTsKKyAgICAgICAgICAgIHNiLmFwcGVuZChtQ29udGV4dC5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICBjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5zZXJ2aWNlRXJhc2VkKSk7CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICBzdGF0ZSA9IFN0YXRlLkZBSUxFRDsKLSAgICAgICAgICAgIHNiLmFwcGVuZChjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICBtU3RhdGUgPSBTdGF0ZS5GQUlMRUQ7CisgICAgICAgICAgICBzYi5hcHBlbmQobUNvbnRleHQuZ2V0VGV4dCgKICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcubW1pRXJyb3IpKTsKICAgICAgICAgfQogCi0gICAgICAgIG1lc3NhZ2UgPSBzYjsKLSAgICAgICAgcGhvbmUub25NTUlEb25lKHRoaXMpOworICAgICAgICBtTWVzc2FnZSA9IHNiOworICAgICAgICBtUGhvbmUub25NTUlEb25lKHRoaXMpOwogICAgIH0KIAogICAgIHByaXZhdGUgdm9pZApAQCAtMTA3NSw3ICsxMDgxLDcgQEAKICAgICAgICAgc2IuYXBwZW5kKCJcbiIpOwogCiAgICAgICAgIGlmIChhci5leGNlcHRpb24gIT0gbnVsbCkgewotICAgICAgICAgICAgc3RhdGUgPSBTdGF0ZS5GQUlMRUQ7CisgICAgICAgICAgICBtU3RhdGUgPSBTdGF0ZS5GQUlMRUQ7CiAgICAgICAgICAgICBzYi5hcHBlbmQoZ2V0RXJyb3JNZXNzYWdlKGFyKSk7CiAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICBpbnQgY2xpckFyZ3NbXTsKQEAgLTEwODUsMjEgKzEwOTEsMjEgQEAKICAgICAgICAgICAgIC8vIHRoZSAnbScgcGFyYW1ldGVyIGZyb20gVFMgMjcuMDA3IDcuNwogICAgICAgICAgICAgc3dpdGNoIChjbGlyQXJnc1sxXSkgewogICAgICAgICAgICAgICAgIGNhc2UgMDogLy8gQ0xJUiBub3QgcHJvdmlzaW9uZWQKLSAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKGNvbnRleHQuZ2V0VGV4dCgKKyAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKG1Db250ZXh0LmdldFRleHQoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLnNlcnZpY2VOb3RQcm92aXNpb25lZCkpOwotICAgICAgICAgICAgICAgICAgICBzdGF0ZSA9IFN0YXRlLkNPTVBMRVRFOworICAgICAgICAgICAgICAgICAgICBtU3RhdGUgPSBTdGF0ZS5DT01QTEVURTsKICAgICAgICAgICAgICAgICBicmVhazsKIAogICAgICAgICAgICAgICAgIGNhc2UgMTogLy8gQ0xJUiBwcm92aXNpb25lZCBpbiBwZXJtYW5lbnQgbW9kZQotICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQoY29udGV4dC5nZXRUZXh0KAorICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQobUNvbnRleHQuZ2V0VGV4dCgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuQ0xJUlBlcm1hbmVudCkpOwotICAgICAgICAgICAgICAgICAgICBzdGF0ZSA9IFN0YXRlLkNPTVBMRVRFOworICAgICAgICAgICAgICAgICAgICBtU3RhdGUgPSBTdGF0ZS5DT01QTEVURTsKICAgICAgICAgICAgICAgICBicmVhazsKIAogICAgICAgICAgICAgICAgIGNhc2UgMjogLy8gdW5rbm93biAoZS5nLiBubyBuZXR3b3JrLCBldGMuKQotICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQoY29udGV4dC5nZXRUZXh0KAorICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQobUNvbnRleHQuZ2V0VGV4dCgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcubW1pRXJyb3IpKTsKLSAgICAgICAgICAgICAgICAgICAgc3RhdGUgPSBTdGF0ZS5GQUlMRUQ7CisgICAgICAgICAgICAgICAgICAgIG1TdGF0ZSA9IFN0YXRlLkZBSUxFRDsKICAgICAgICAgICAgICAgICBicmVhazsKIAogICAgICAgICAgICAgICAgIGNhc2UgMzogLy8gQ0xJUiB0ZW1wb3JhcnkgbW9kZSBwcmVzZW50YXRpb24gcmVzdHJpY3RlZApAQCAtMTEwOCwxOSArMTExNCwxOSBAQAogICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGNsaXJBcmdzWzBdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAwOiAvLyBEZWZhdWx0Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKGNvbnRleHQuZ2V0VGV4dCgKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQobUNvbnRleHQuZ2V0VGV4dCgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLkNMSVJEZWZhdWx0T25OZXh0Q2FsbE9uKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMTogLy8gQ0xJUiBpbnZvY2F0aW9uCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKGNvbnRleHQuZ2V0VGV4dCgKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQobUNvbnRleHQuZ2V0VGV4dCgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLkNMSVJEZWZhdWx0T25OZXh0Q2FsbE9uKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMjogLy8gQ0xJUiBzdXBwcmVzc2lvbgotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKG1Db250ZXh0LmdldFRleHQoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5DTElSRGVmYXVsdE9uTmV4dENhbGxPZmYpKTsKICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgIHN0YXRlID0gU3RhdGUuQ09NUExFVEU7CisgICAgICAgICAgICAgICAgICAgIG1TdGF0ZSA9IFN0YXRlLkNPTVBMRVRFOwogICAgICAgICAgICAgICAgIGJyZWFrOwogCiAgICAgICAgICAgICAgICAgY2FzZSA0OiAvLyBDTElSIHRlbXBvcmFyeSBtb2RlIHByZXNlbnRhdGlvbiBhbGxvd2VkCkBAIC0xMTI4LDI2ICsxMTM0LDI2IEBACiAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoY2xpckFyZ3NbMF0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDA6IC8vIERlZmF1bHQKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQoY29udGV4dC5nZXRUZXh0KAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChtQ29udGV4dC5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuQ0xJUkRlZmF1bHRPZmZOZXh0Q2FsbE9mZikpOwogICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDE6IC8vIENMSVIgaW52b2NhdGlvbgotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKG1Db250ZXh0LmdldFRleHQoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5DTElSRGVmYXVsdE9mZk5leHRDYWxsT24pKTsKICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAyOiAvLyBDTElSIHN1cHByZXNzaW9uCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKGNvbnRleHQuZ2V0VGV4dCgKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQobUNvbnRleHQuZ2V0VGV4dCgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLkNMSVJEZWZhdWx0T2ZmTmV4dENhbGxPZmYpKTsKICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgICAgICAgICAgc3RhdGUgPSBTdGF0ZS5DT01QTEVURTsKKyAgICAgICAgICAgICAgICAgICAgbVN0YXRlID0gU3RhdGUuQ09NUExFVEU7CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KIAotICAgICAgICBtZXNzYWdlID0gc2I7Ci0gICAgICAgIHBob25lLm9uTU1JRG9uZSh0aGlzKTsKKyAgICAgICAgbU1lc3NhZ2UgPSBzYjsKKyAgICAgICAgbVBob25lLm9uTU1JRG9uZSh0aGlzKTsKICAgICB9CiAKICAgICAvKioKQEAgLTExNjAsMjEgKzExNjYsMjEgQEAKICAgICBzZXJ2a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ICAgICAgICAgICAgICAgIHJldHVybiBjb250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuc2VydmljZUNsYXNzUEFEKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gbUNvbnRleHQuZ2V0VGV4dChjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5zZXJ2aWNlQ2xhc3NQQUQpOwogICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgfQpAQCAtMTE5NywyNCArMTIwMywyNCBAQAogCiAgICAgICAgIGlmIChpbmZvLnN0YXR1cyA9PSAxKSB7CiAgICAgICAgICAgICBpZiAobmVlZFRpbWVUZW1wbGF0ZSkgewotICAgICAgICAgICAgICAgIHRlbXBsYXRlID0gY29udGV4dC5nZXRUZXh0KAorICAgICAgICAgICAgICAgIHRlbXBsYXRlID0gbUNvbnRleHQuZ2V0VGV4dCgKICAgICAgICAgICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLmNmVGVtcGxhdGVGb3J3YXJkZWRUaW1lKTsKICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgdGVtcGxhdGUgPSBjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICAgICAgdGVtcGxhdGUgPSBtQ29udGV4dC5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuY2ZUZW1wbGF0ZUZvcndhcmRlZCk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0gZWxzZSBpZiAoaW5mby5zdGF0dXMgPT0gMCAmJiBpc0VtcHR5T3JOdWxsKGluZm8ubnVtYmVyKSkgewotICAgICAgICAgICAgdGVtcGxhdGUgPSBjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICB0ZW1wbGF0ZSA9IG1Db250ZXh0LmdldFRleHQoCiAgICAgICAgICAgICAgICAgICAgICAgICBjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5jZlRlbXBsYXRlTm90Rm9yd2FyZGVkKTsKICAgICAgICAgfSBlbHNlIHsgLyogKGluZm8uc3RhdHVzID09IDApICYmICFpc0VtcHR5T3JOdWxsKGluZm8ubnVtYmVyKSAqLwogICAgICAgICAgICAgLy8gQSBjYWxsIGZvcndhcmQgcmVjb3JkIHRoYXQgaXMgbm90IGFjdGl2ZSBidXQgY29udGFpbnMKICAgICAgICAgICAgIC8vIGEgcGhvbmUgbnVtYmVyIGlzIGNvbnNpZGVyZWQgInJlZ2lzdGVyZWQiCiAKICAgICAgICAgICAgIGlmIChuZWVkVGltZVRlbXBsYXRlKSB7Ci0gICAgICAgICAgICAgICAgdGVtcGxhdGUgPSBjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICAgICAgdGVtcGxhdGUgPSBtQ29udGV4dC5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuY2ZUZW1wbGF0ZVJlZ2lzdGVyZWRUaW1lKTsKICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgdGVtcGxhdGUgPSBjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICAgICAgdGVtcGxhdGUgPSBtQ29udGV4dC5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuY2ZUZW1wbGF0ZVJlZ2lzdGVyZWQpOwogICAgICAgICAgICAgfQogICAgICAgICB9CkBAIC0xMjQ3LDcgKzEyNTMsNyBAQAogICAgICAgICBzYi5hcHBlbmQoIlxuIik7CiAKICAgICAgICAgaWYgKGFyLmV4Y2VwdGlvbiAhPSBudWxsKSB7Ci0gICAgICAgICAgICBzdGF0ZSA9IFN0YXRlLkZBSUxFRDsKKyAgICAgICAgICAgIG1TdGF0ZSA9IFN0YXRlLkZBSUxFRDsKICAgICAgICAgICAgIHNiLmFwcGVuZChnZXRFcnJvck1lc3NhZ2UoYXIpKTsKICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIENhbGxGb3J3YXJkSW5mbyBpbmZvc1tdOwpAQCAtMTI1Niw3ICsxMjYyLDcgQEAKIAogICAgICAgICAgICAgaWYgKGluZm9zLmxlbmd0aCA9PSAwKSB7CiAgICAgICAgICAgICAgICAgLy8gQXNzdW1lIHRoZSBkZWZhdWx0IGlzIG5vdCBhY3RpdmUKLSAgICAgICAgICAgICAgICBzYi5hcHBlbmQoY29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLnNlcnZpY2VEaXNhYmxlZCkpOworICAgICAgICAgICAgICAgIHNiLmFwcGVuZChtQ29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLnNlcnZpY2VEaXNhYmxlZCkpOwogCiAgICAgICAgICAgICAgICAgLy8gU2V0IHVuY29uZGl0aW9uYWwgQ0ZGIGluIFNJTSB0byBmYWxzZQogICAgICAgICAgICAgICAgIGlmIChtSWNjUmVjb3JkcyAhPSBudWxsKSB7CkBAIC0xMjg3LDExICsxMjkzLDExIEBACiAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKHRiKTsKICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgc3RhdGUgPSBTdGF0ZS5DT01QTEVURTsKKyAgICAgICAgICAgIG1TdGF0ZSA9IFN0YXRlLkNPTVBMRVRFOwogICAgICAgICB9CiAKLSAgICAgICAgbWVzc2FnZSA9IHNiOwotICAgICAgICBwaG9uZS5vbk1NSURvbmUodGhpcyk7CisgICAgICAgIG1NZXNzYWdlID0gc2I7CisgICAgICAgIG1QaG9uZS5vbk1NSURvbmUodGhpcyk7CiAKICAgICB9CiAKQEAgLTEzMDEsNDAgKzEzMDcsNDAgQEAKICAgICAgICAgc2IuYXBwZW5kKCJcbiIpOwogCiAgICAgICAgIGlmIChhci5leGNlcHRpb24gIT0gbnVsbCkgewotICAgICAgICAgICAgc3RhdGUgPSBTdGF0ZS5GQUlMRUQ7CisgICAgICAgICAgICBtU3RhdGUgPSBTdGF0ZS5GQUlMRUQ7CiAgICAgICAgICAgICBzYi5hcHBlbmQoZ2V0RXJyb3JNZXNzYWdlKGFyKSk7CiAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICBpbnRbXSBpbnRzID0gKGludFtdKWFyLnJlc3VsdDsKIAogICAgICAgICAgICAgaWYgKGludHMubGVuZ3RoICE9IDApIHsKICAgICAgICAgICAgICAgICBpZiAoaW50c1swXSA9PSAwKSB7Ci0gICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChjb250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuc2VydmljZURpc2FibGVkKSk7Ci0gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzYy5lcXVhbHMoU0NfV0FJVCkpIHsKKyAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKG1Db250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuc2VydmljZURpc2FibGVkKSk7CisgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChtU2MuZXF1YWxzKFNDX1dBSVQpKSB7CiAgICAgICAgICAgICAgICAgICAgIC8vIENhbGwgV2FpdGluZyBpbmNsdWRlcyBhZGRpdGlvbmFsIGRhdGEgaW4gdGhlIHJlc3BvbnNlLgogICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQoY3JlYXRlUXVlcnlDYWxsV2FpdGluZ1Jlc3VsdE1lc3NhZ2UoaW50c1sxXSkpOwotICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNTZXJ2aWNlQ29kZUNhbGxCYXJyaW5nKHNjKSkgeworICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNTZXJ2aWNlQ29kZUNhbGxCYXJyaW5nKG1TYykpIHsKICAgICAgICAgICAgICAgICAgICAgLy8gaW50c1swXSBmb3IgQ2FsbCBCYXJyaW5nIGlzIGEgYml0IHZlY3RvciBvZiBzZXJ2aWNlcwogICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQoY3JlYXRlUXVlcnlDYWxsQmFycmluZ1Jlc3VsdE1lc3NhZ2UoaW50c1swXSkpOwogICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaW50c1swXSA9PSAxKSB7CiAgICAgICAgICAgICAgICAgICAgIC8vIGZvciBhbGwgb3RoZXIgc2VydmljZXMsIHRyZWF0IGl0IGFzIGEgYm9vbGVhbgotICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQoY29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLnNlcnZpY2VFbmFibGVkKSk7CisgICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChtQ29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLnNlcnZpY2VFbmFibGVkKSk7CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKGNvbnRleHQuZ2V0VGV4dChjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5tbWlFcnJvcikpOworICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQobUNvbnRleHQuZ2V0VGV4dChjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5tbWlFcnJvcikpOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgc2IuYXBwZW5kKGNvbnRleHQuZ2V0VGV4dChjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5tbWlFcnJvcikpOworICAgICAgICAgICAgICAgIHNiLmFwcGVuZChtQ29udGV4dC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RVZFTlRfTkVXX1NNU19TVEFUVVNfUkVQT1JULCBudWxsKTsKLSAgICAgICAgbUNtLnNldE9uTmV3R3NtQnJvYWRjYXN0U21zKHRoaXMsIEVWRU5UX05FV19CUk9BRENBU1RfU01TLCBudWxsKTsKKyAgICAgICAgbURhdGFEb3dubG9hZEhhbmRsZXIgPSBuZXcgVXNpbURhdGFEb3dubG9hZEhhbmRsZXIobUNpKTsKKyAgICAgICAgbUNpLnNldE9uTmV3R3NtU21zKHRoaXMsIEVWRU5UX05FV19TTVMsIG51bGwpOworICAgICAgICBtQ2kuc2V0T25TbXNTdGF0dXModGhpcywgRVZFTlRfTkVXX1NNU19TVEFUVVNfUkVQT1JULCBudWxsKTsKKyAgICAgICAgbUNpLnNldE9uTmV3R3NtQnJvYWRjYXN0U21zKHRoaXMsIEVWRU5UX05FV19CUk9BRENBU1RfU01TLCBudWxsKTsKICAgICB9CiAKICAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBkaXNwb3NlKCkgewotICAgICAgICBtQ20udW5TZXRPbk5ld0dzbVNtcyh0aGlzKTsKLSAgICAgICAgbUNtLnVuU2V0T25TbXNTdGF0dXModGhpcyk7Ci0gICAgICAgIG1DbS51blNldE9uTmV3R3NtQnJvYWRjYXN0U21zKHRoaXMpOworICAgICAgICBtQ2kudW5TZXRPbk5ld0dzbVNtcyh0aGlzKTsKKyAgICAgICAgbUNpLnVuU2V0T25TbXNTdGF0dXModGhpcyk7CisgICAgICAgIG1DaS51blNldE9uTmV3R3NtQnJvYWRjYXN0U21zKHRoaXMpOwogICAgIH0KIAogICAgIEBPdmVycmlkZQpAQCAtMTA1LDEwICsxMDYsMTAgQEAKICAgICAgICAgICAgIEFzeW5jUmVzdWx0IGFyID0gKEFzeW5jUmVzdWx0KSBtc2cub2JqOwogICAgICAgICAgICAgaWYgKGFyLmV4Y2VwdGlvbiA9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgUmxvZy5kKFRBRywgIlN1Y2Nlc3NmdWxseSB3cm90ZSBTTVMtUFAgbWVzc2FnZSB0byBVSUNDIik7Ci0gICAgICAgICAgICAgICAgbUNtLmFja25vd2xlZGdlTGFzdEluY29taW5nR3NtU21zKHRydWUsIDAsIG51bGwpOworICAgICAgICAgICAgICAgIG1DaS5hY2tub3dsZWRnZUxhc3RJbmNvbWluZ0dzbVNtcyh0cnVlLCAwLCBudWxsKTsKICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgUmxvZy5kKFRBRywgIkZhaWxlZCB0byB3cml0ZSBTTVMtUFAgbWVzc2FnZSB0byBVSUNDIiwgYXIuZXhjZXB0aW9uKTsKLSAgICAgICAgICAgICAgICBtQ20uYWNrbm93bGVkZ2VMYXN0SW5jb21pbmdHc21TbXMoZmFsc2UsCisgICAgICAgICAgICAgICAgbUNpLmFja25vd2xlZGdlTGFzdEluY29taW5nR3NtU21zKGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgQ29tbWFuZHNJbnRlcmZhY2UuR1NNX1NNU19GQUlMX0NBVVNFX1VOU1BFQ0lGSUVEX0VSUk9SLCBudWxsKTsKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIGJyZWFrOwpAQCAtMTMxLDcgKzEzMiw3IEBACiAKICAgICAgICAgaWYgKHNtcyAhPSBudWxsKSB7CiAgICAgICAgICAgICBpbnQgdHBTdGF0dXMgPSBzbXMuZ2V0U3RhdHVzKCk7Ci0gICAgICAgICAgICBpbnQgbWVzc2FnZVJlZiA9IHNtcy5tZXNzYWdlUmVmOworICAgICAgICAgICAgaW50IG1lc3NhZ2VSZWYgPSBzbXMubU1lc3NhZ2VSZWY7CiAgICAgICAgICAgICBmb3IgKGludCBpID0gMCwgY291bnQgPSBkZWxpdmVyeVBlbmRpbmdMaXN0LnNpemUoKTsgaSA8IGNvdW50OyBpKyspIHsKICAgICAgICAgICAgICAgICBTbXNUcmFja2VyIHRyYWNrZXIgPSBkZWxpdmVyeVBlbmRpbmdMaXN0Lm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ICAgICAgICAgICAgIlsiICsgbXNnLndoYXQgKyAiXSB3aGlsZSBiZWluZyBkZXN0cm95ZWQuIElnbm9yaW5nLiIpOwogICAgICAgICAgICAgcmV0dXJuOwpAQCAtMjg1LDE0ICsyNzIsMTQgQEAKIAogICAgICAgICAgICAgY2FzZSBFVkVOVF9TSU1fUkVBRFk6CiAgICAgICAgICAgICAgICAgLy8gU2V0IHRoZSBuZXR3b3JrIHR5cGUsIGluIGNhc2UgdGhlIHJhZGlvIGRvZXMgbm90IHJlc3RvcmUgaXQuCi0gICAgICAgICAgICAgICAgY20uc2V0Q3VycmVudFByZWZlcnJlZE5ldHdvcmtUeXBlKCk7CisgICAgICAgICAgICAgICAgbUNpLnNldEN1cnJlbnRQcmVmZXJyZWROZXR3b3JrVHlwZSgpOwogCi0gICAgICAgICAgICAgICAgYm9vbGVhbiBza2lwUmVzdG9yaW5nU2VsZWN0aW9uID0gcGhvbmUuZ2V0Q29udGV4dCgpLmdldFJlc291cmNlcygpLmdldEJvb2xlYW4oCisgICAgICAgICAgICAgICAgYm9vbGVhbiBza2lwUmVzdG9yaW5nU2VsZWN0aW9uID0gbVBob25lLmdldENvbnRleHQoKS5nZXRSZXNvdXJjZXMoKS5nZXRCb29sZWFuKAogICAgICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5ib29sLnNraXBfcmVzdG9yaW5nX25ldHdvcmtfc2VsZWN0aW9uKTsKIAogICAgICAgICAgICAgICAgIGlmICghc2tpcFJlc3RvcmluZ1NlbGVjdGlvbikgewogICAgICAgICAgICAgICAgICAgICAvLyByZXN0b3JlIHRoZSBwcmV2aW91cyBuZXR3b3JrIHNlbGVjdGlvbi4KLSAgICAgICAgICAgICAgICAgICAgcGhvbmUucmVzdG9yZVNhdmVkTmV0d29ya1NlbGVjdGlvbihudWxsKTsKKyAgICAgICAgICAgICAgICAgICAgbVBob25lLnJlc3RvcmVTYXZlZE5ldHdvcmtTZWxlY3Rpb24obnVsbCk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIHBvbGxTdGF0ZSgpOwogICAgICAgICAgICAgICAgIC8vIFNpZ25hbCBzdHJlbmd0aCBwb2xsaW5nIHN0b3BzIHdoZW4gcmFkaW8gaXMgb2ZmCkBAIC0zMTQsNyArMzAxLDcgQEAKICAgICAgICAgICAgICAgICAvLyBUaGlzIGNhbGxiYWNrIGlzIGNhbGxlZCB3aGVuIHNpZ25hbCBzdHJlbmd0aCBpcyBwb2xsZWQKICAgICAgICAgICAgICAgICAvLyBhbGwgYnkgaXRzZWxmCiAKLSAgICAgICAgICAgICAgICBpZiAoIShjbS5nZXRSYWRpb1N0YXRlKCkuaXNPbigpKSkgeworICAgICAgICAgICAgICAgIGlmICghKG1DaS5nZXRSYWRpb1N0YXRlKCkuaXNPbigpKSkgewogICAgICAgICAgICAgICAgICAgICAvLyBQb2xsaW5nIHdpbGwgY29udGludWUgd2hlbiByYWRpbyB0dXJucyBiYWNrIG9uCiAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICB9CkBAIC0zNDMsOCArMzMwLDggQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBSbG9nLncoTE9HX1RBRywgImVycm9yIHBhcnNpbmcgbG9jYXRpb246ICIgKyBleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgY2VsbExvYy5zZXRMYWNBbmRDaWQobGFjLCBjaWQpOwotICAgICAgICAgICAgICAgICAgICBwaG9uZS5ub3RpZnlMb2NhdGlvbkNoYW5nZWQoKTsKKyAgICAgICAgICAgICAgICAgICAgbUNlbGxMb2Muc2V0TGFjQW5kQ2lkKGxhYywgY2lkKTsKKyAgICAgICAgICAgICAgICAgICAgbVBob25lLm5vdGlmeUxvY2F0aW9uQ2hhbmdlZCgpOwogICAgICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgICAgIC8v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ICAgICAgICAgICAgICAgICAgICAgRXZlbnRMb2cud3JpdGVFdmVudChFdmVudExvZ1RhZ3MuREFUQV9ORVRXT1JLX1JFR0lTVFJBVElPTl9GQUlMLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNzLmdldE9wZXJhdG9yTnVtZXJpYygpLCBsb2MgIT0gbnVsbCA/IGxvYy5nZXRDaWQoKSA6IC0xKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBtU1MuZ2V0T3BlcmF0b3JOdW1lcmljKCksIGxvYyAhPSBudWxsID8gbG9jLmdldENpZCgpIDogLTEpOwogICAgICAgICAgICAgICAgICAgICBtUmVwb3J0ZWRHcHJzTm9SZWcgPSB0cnVlOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBtU3RhcnRlZEdwcnNSZWdDaGVjayA9IGZhbHNlOwpAQCAtNDYzLDE0ICs0NTAsMTUgQEAKICAgICAgICAgfQogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHByb3RlY3RlZCB2b2lkIHNldFBvd2VyU3RhdGVUb0Rlc2lyZWQoKSB7CiAgICAgICAgIC8vIElmIHdlIHdhbnQgaXQgb24gYW5kIGl0J3Mgb2ZmLCB0dXJuIGl0IG9uCiAgICAgICAgIGlmIChtRGVzaXJlZFBvd2VyU3RhdGUKLSAgICAgICAgICAgICYmIGNtLmdldFJhZGlvU3RhdGUoKSA9PSBDb21tYW5kc0ludGVyZmFjZS5SYWRpb1N0YXRlLlJBRElPX09GRikgewotICAgICAgICAgICAgY20uc2V0UmFkaW9Qb3dlcih0cnVlLCBudWxsKTsKLSAgICAgICAgfSBlbHNlIGlmICghbURlc2lyZWRQb3dlclN0YXRlICYmIGNtLmdldFJhZGlvU3RhdGUoKS5pc09uKCkpIHsKKyAgICAgICAgICAgICYmIG1DaS5nZXRSYWRpb1N0YXRlKCkgPT0gQ29tbWFuZHNJbnRlcmZhY2UuUmFkaW9TdGF0ZS5SQURJT19PRkYpIHsKKyAgICAg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ljZVJlZ1N0YXRlKCkgPT0gU2VydmljZVN0YXRlLlNUQVRFX0VNRVJHRU5DWV9PTkxZKSB7CiAgICAgICAgICAgICBzaG93UGxtbiA9IHRydWU7CiAgICAgICAgICAgICBpZiAobUVtZXJnZW5jeU9ubHkpIHsKICAgICAgICAgICAgICAgICAvLyBObyBzZXJ2aWNlIGJ1dCBlbWVyZ2VuY3kgY2FsbCBhbGxvd2VkCkBAIC01MjUsOSArNTEzLDkgQEAKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIGlmIChEQkcpIGxvZygidXBkYXRlU3BuRGlzcGxheTogcmFkaW8gaXMgb24gYnV0IG91dCAiICsKICAgICAgICAgICAgICAgICAgICAgIm9mIHNlcnZpY2UsIHNldCBwbG1uPSciICsgcGxtbiArICInIik7Ci0gICAgICAgIH0gZWxzZSBpZiAoc3MuZ2V0U3RhdGUoKSA9PSBTZXJ2aWNlU3RhdGUuU1RBVEVfSU5fU0VSVklDRSkgeworICAgICAgICB9IGVsc2UgaWYgKG1TUy5nZXRWb2ljZVJlZ1N0YXRlKCkgPT0gU2VydmljZVN0YXRlLlNUQVRFX0lOX1NFUlZJQ0UpIHsKICAgICAgICAgICAgIC8vIEluIGVpdGhlciBob21lIG9yIHJvYW1pbmcgc2VydmljZQotICAgICAgICAgICAgcGxtbiA9IHNzLmdldE9wZXJhdG9yQWxwaGFMb25nKCk7CisgICAgICAgICAgICBwbG1uID0gbVNTLmdldE9wZXJhdG9yQWxwaGFMb25nKCk7CiAgICAgICAgICAgICBzaG93UGxtbiA9ICFUZXh0VXRpbHMuaXNFbXB0eShwbG1uKSAmJgogICAgICAgICAgICAgICAgICAgICAoKHJ1bGUgJiBTSU1SZWNvcmRzLlNQTl9SVUxFX1NIT1dfUExNTikKICAgICAgICAgICAgICAgICAgICAgICAgICAgICA9PSBTSU1SZWNvcmRzLlNQTl9SVUxFX1NIT1dfUExNTik7CkBAIC01NDYsMTAgKzUzNCwxMCBAQAogICAgICAgICAgICAgICAgICAgICAgICAgPT0gU0lNUmVjb3Jkcy5TUE5fUlVMRV9TSE9XX1NQTik7CiAKICAgICAgICAgLy8gVXBkYXRlIFNQTl9TVFJJTkdTX1VQREFURURfQUNUSU9OIElGRiBhbnkgdmFsdWUgY2hhbmdlcwotICAgICAgICBpZiAoc2hvd1BsbW4gIT0gY3VyU2hvd1BsbW4KLSAgICAgICAgICAgICAgICB8fCBzaG93U3BuICE9IGN1clNob3dTcG4KLSAgICAgICAgICAgICAgICB8fCAhVGV4dFV0aWxzLmVxdWFscyhzcG4sIGN1clNwbikKLSAgICAgICAgICAgICAgICB8fCAhVGV4dFV0aWxzLmVxdWFscyhwbG1uLCBjdXJQbG1uKSkgeworICAgICAgICBpZiAoc2hvd1BsbW4gIT0gbUN1clNob3dQbG1uCisgICAgICAgICAgICAgICAgfHwgc2hvd1NwbiAhPSBtQ3VyU2hvd1NwbgorICAgICAgICAgICAgICAgIHx8ICFUZXh0VXRpbHMuZXF1YWxzKHNwbiwgbUN1clNwbikKKyAgICAgICAgICAgICAgICB8fCAhVGV4dFV0aWxzLmVxdWFscyhwbG1uLCBtQ3VyUGxtbikpIHsKICAgICAgICAgICAgIGlmIChEQkcpIHsKICAgICAgICAgICAgICAgICBsb2coU3RyaW5nLmZvcm1hdCgidXBkYXRlU3BuRGlzcGxheTogY2hhbmdlZCIgKwogICAgICAgICAgICAgICAgICAgICAgICAgIiBzZW5kaW5nIGludGVudCBydWxlPSIgKyBydWxlICsKQEAgLTU2MiwyNCArNTUwLDI1IEBACiAgICAgICAgICAgICBpbnRlbnQucHV0RXh0cmEoVGVsZXBob255SW50ZW50cy5FWFRSQV9TUE4sIHNwbik7CiAgICAgICAgICAgICBpbnRlbnQucHV0RXh0cmEoVGVsZXBob255SW50ZW50cy5FWFRSQV9TSE9XX1BMTU4sIHNob3dQbG1uKTsKICAgICAgICAgICAgIGludGVudC5wdXRFeHRyYShUZWxlcGhvbnlJbnRlbnRzLkVYVFJBX1BMTU4sIHBsbW4pOwotICA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21tYW5kRXhjZXB0aW9uLkVycm9yIGVycj1udWxsOwpAQCAtNTk0LDcgKzU4Myw3IEBACiAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgfQogCi0gICAgICAgICAgICBpZiAoIWNtLmdldFJhZGlvU3RhdGUoKS5pc09uKCkpIHsKKyAgICAgICAgICAgIGlmICghbUNpLmdldFJhZGlvU3RhdGUoKS5pc09uKCkpIHsKICAgICAgICAgICAgICAgICAvLyBSYWRpbyBoYXMgY3Jhc2hlZCBvciB0dXJuZWQgb2ZmCiAgICAgICAgICAgICAgICAgY2FuY2VsUG9sbFN0YXRlKCk7CiAgICAgICAgICAgICAgICAgcmV0dXJuOwpAQCAtNjA2LDExICs1OTUsMTIgQEAKICAgICAgICAgICAgIH0KICAgICAgICAgfSBlbHNlIHRyeSB7CiAgICAgICAgICAgICBzd2l0Y2ggKHdoYXQpIHsKLSAgICAgICAgICAgICAgICBjYXNlIEVWRU5UX1BPTExfU1RBVEVfUkVHSVNUUkFUSU9OOgorICAgICAgICAgICAgICAgIGNhc2UgRVZFTlRfUE9MTF9TVEFURV9SRUdJU1RSQVRJT046IHsKICAgICAgICAgICAgICAgICAgICAgc3RhdGVzID0gKFN0cmluZ1tdKWFyLnJlc3VsdDsKICAgICAgICAgICAgICAgICAgICAgaW50IGxhYyA9IC0xOwogICAgICAgICAgICAgICAgICAgICBpbnQgY2lkID0gLTE7Ci0gICAgICAgICAgICAgICAgICAgIGludCByZWdTdGF0ZSA9IC0xOworICAgICAgICAgICAgICAgICAgICBpbnQgdHlwZSA9IFNlcnZpY2VTdGF0ZS5SSUxfUkFESU9fVEVDSE5PTE9HWV9VTktOT1dOOworICAgICAgICAgICAgICAgICAgICBpbnQgcmVnU3RhdGUgPSBTZXJ2aWNlU3RhdGUuUklMX1JFR19TVEFURV9VTktOT1dOOwogICAgICAgICAgICAgICAgICAgICBpbnQgcmVhc29uUmVnU3RhdGVEZW5pZWQgPSAtMTsKICAgICAgICAgICAgICAgICAgICAgaW50IHBzYyA9IC0xOwogICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzLmxlbmd0aCA+IDApIHsKQEAgLTYyMyw2ICs2MTMsMTEgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlc1syXSAhPSBudWxsICYmIHN0YXRlc1syXS5sZW5ndGgoKSA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNpZCA9IEludGVnZXIucGFyc2VJbnQoc3RhdGVzWzJdLCAxNik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KKworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBzdGF0ZXNbM10gKGlmIHByZXNlbnQpIGlzIHRoZSBjdXJyZW50IHJhZGlvIHRlY2hub2xvZ3kKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlcy5sZW5ndGggPj0gNCAmJiBzdGF0ZXNbM10gIT0gbnVsbCkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZSA9IEludGVnZXIucGFyc2VJbnQoc3RhdGVzWzNdKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzLmxlbmd0aCA+IDE0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZXNbMTRdICE9IG51bGwgJiYgc3RhdGVzWzE0XS5sZW5ndGgoKSA+IDApIHsKQEAgLTYzNSwyNCArNjMwLDI5IEBACiAgICAgICAgICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgICAgICAgICBtR3NtUm9hbWluZyA9IHJlZ0NvZGVJc1JvYW1pbmcocmVnU3RhdGUpOwotICAgICAgICAgICAgICAgICAgICBuZXdTUy5zZXRTdGF0ZSAocmVnQ29kZVRvU2VydmljZVN0YXRlKHJlZ1N0YXRlKSk7CisgICAgICAgICAgICAgICAgICAgIG1OZXdTUy5zZXRTdGF0ZShyZWdDb2RlVG9TZXJ2aWNlU3RhdGUocmVnU3RhdGUpKTsKKyAgICAgICAgICAgICAgICAgICAgbU5ld1NTLnNldFJpbFZvaWNlUmFkaW9UZWNobm9sb2d5KHR5cGUpOwogCi0gICAgICAgICAgICAgICAgICAgIGlmIChyZWdTdGF0ZSA9PSAxMCB8fCByZWdTdGF0ZSA9PSAxMiB8fCByZWdTdGF0ZSA9PSAxMyB8fCByZWdTdGF0ZSA9PSAxNCkgeworICAgICAgICAgICAgICAgICAgICBpZiAocmVnU3RhdGUgPT0gU2VydmljZVN0YXRlLlJJTF9SRUdfU1RBVEVfREVOSUVEX0VNRVJHRU5DWV9DQUxMX0VOQUJMRUQKKyAgICAgICAgICAgICAgICAgICAgICAgICB8fCByZWdTdGF0ZSA9PSBTZXJ2aWNlU3RhdGUuUklMX1JFR19TVEFURV9OT1RfUkVHX0VNRVJHRU5DWV9DQUxMX0VOQUJMRUQKKyAgICAgICAgICAgICAgICAgICAgICAgICB8fCByZWdTdGF0ZSA9PSBTZXJ2aWNlU3RhdGUuUklMX1JFR19TVEFURV9TRUFSQ0hJTkdfRU1FUkdFTkNZX0NBTExfRU5BQkxFRAorICAgICAgICAgICAgICAgICAgICAgICAgIHx8IHJlZ1N0YXRlID09IFNlcnZpY2VTdGF0ZS5SSUxfUkVHX1NUQVRFX1VOS05PV05fRU1FUkdFTkNZX0NBTExfRU5BQkxFRCkgewogICAgICAgICAgICAgICAgICAgICAgICAgbUVtZXJnZW5jeU9ubHkgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgbUVtZXJnZW5jeU9ubHkgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAgICAgICAgIC8vIExBQyBhbmQgQ0lEIGFyZSAtMSBpZiBub3QgYXZhaWwKLSAgICAgICAgICAgICAgICAgICAgbmV3Q2VsbExvYy5zZXRMYWNBbmRDaWQobGFjLCBjaWQpOwotICAgICAgICAgICAgICAgICAgICBuZXdDZWxsTG9jLnNldFBzYyhwc2MpOwotICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICBtTmV3Q2VsbExvYy5zZXRMYWNBbmRDaWQobGFjLCBjaWQpOworICAgICAgICAgICAgICAgICAgICBtTmV3Q2VsbExvYy5zZXRQc2MocHNjKTsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgfQogCi0gICAgICAgICAgICAgICAgY2FzZSBFVkVOVF9QT0xMX1NUQVRFX0dQUlM6CisgICAgICAgICAgICAgICAgY2FzZSBFVkVOVF9QT0xMX1NUQVRFX0dQUlM6IHsKICAgICAgICAgICAgICAgICAgICAgc3RhdGVzID0gKFN0cmluZ1tdKWFyLnJlc3VsdDsKIAogICAgICAgICAgICAgICAgICAgICBpbnQgdHlwZSA9IDA7Ci0gICAgICAgICAgICAgICAgICAgIHJlZ1N0YXRlID0gLTE7CisgICAgICAgICAgICAgICAgICAgIGludCByZWdTdGF0ZSA9IFNlcnZpY2VTdGF0ZS5SSUxfUkVHX1NUQVRFX1VOS05PV047CiAgICAgICAgICAgICAgICAgICAgIG1OZXdSZWFzb25EYXRhRGVuaWVkID0gLTE7CiAgICAgICAgICAgICAgICAgICAgIG1OZXdNYXhEYXRhQ2FsbHMgPSAxOwogICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzLmxlbmd0aCA+IDApIHsKQEAgLTY2Myw3ICs2NjMsOCBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZXMubGVuZ3RoID49IDQgJiYgc3RhdGVzWzNdICE9IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZSA9IEludGVnZXIucGFyc2VJbnQoc3RhdGVzWzNdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKChzdGF0ZXMubGVuZ3RoID49IDUgKSAmJiAocmVnU3RhdGUgPT0gMykpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoKHN0YXRlcy5sZW5ndGggPj0gNSApICYmCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAocmVnU3RhdGUgPT0gU2VydmljZVN0YXRlLlJJTF9SRUdfU1RBVEVfREVOSUVEKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtTmV3UmVhc29uRGF0YURlbmllZCA9IEludGVnZXIucGFyc2VJbnQoc3RhdGVzWzRdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlcy5sZW5ndGggPj0gNikgewpAQCAtNjczLDQwICs2NzQsNDEgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2dlKCJlcnJvciBwYXJzaW5nIEdwcnNSZWdpc3RyYXRpb25TdGF0ZTogIiArIGV4KTsKICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBuZXdHUFJTU3RhdGUgPSByZWdDb2RlVG9TZXJ2aWNlU3RhdGUocmVnU3RhdGUpOworICAgICAgICAgICAgICAgICAgICBpbnQgZGF0YVJlZ1N0YXRlID0gcmVnQ29kZVRvU2VydmljZVN0YXRlKHJlZ1N0YXRlKTsKKyAgICAgICAgICAgICAgICAgICAgbU5ld1NTLnNldERhdGFSZWdTdGF0ZShkYXRhUmVnU3RhdGUpOwogICAgICAgICAgICAgICAgICAgICBtRGF0YVJvYW1pbmcgPSByZWdDb2RlSXNSb2FtaW5nKHJlZ1N0YXRlKTsKLSAgICAgICAgICAgICAgICAgICAgbU5ld1JpbFJhZGlvVGVjaG5vbG9neSA9IHR5cGU7Ci0gICAgICAgICAgICAgICAgICAgIG5ld1NTLnNldFJhZGlvVGVjaG5vbG9neSh0eXBlKTsKLSAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgbU5ld1NTLnNldFJpbERhdGFSYWRpb1RlY2hub2xvZ3kodHlwZSk7CisgICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGxvZygiaGFuZGxQb2xsU3RhdGVSZXN1bHRNZXNzYWdlOiBHc21TU1Qgc2V0RGF0YVJlZ1N0YXRlPSIgKyBkYXRhUmVnU3RhdGUKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyAiIHJlZ1N0YXRlPSIgKyByZWdTdGF0ZQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArICIgZGF0YVJhZGlvVGVjaG5vbG9neT0iICsgdHlwZSk7CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgfQogCi0gICAgICAgICAgICAgICAgY2FzZSBFVkVOVF9QT0xMX1NUQVRFX09QRVJBVE9SOgorICAgICAgICAgICAgICAgIGNhc2UgRVZFTlRfUE9MTF9TVEFURV9PUEVSQVRPUjogewogICAgICAgICAgICAgICAgICAgICBTdHJpbmcgb3BOYW1lc1tdID0gKFN0cmluZ1tdKWFyLnJlc3VsdDsKIAogICAgICAgICAgICAgICAgICAgICBpZiAob3BOYW1lcyAhPSBudWxsICYmIG9wTmFtZXMubGVuZ3RoID49IDMpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICBuZXdTUy5zZXRPcGVyYXRvck5hbWUgKG9wTmFtZXNbMF0sIG9wTmFtZXNbMV0sIG9wTmFtZXNbMl0pOworICAgICAgICAgICAgICAgICAgICAgICAgIG1OZXdTUy5zZXRPcGVyYXRvck5hbWUgKG9wTmFtZXNbMF0sIG9wTmFtZXNbMV0sIG9wTmFtZXNbMl0pOwogICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgICAgIGNhc2UgRVZFTlRfUE9MTF9TVEFURV9ORVRXT1JLX1NFTEVDVElPTl9NT0RFOgorICAgICAgICAgICAgICAgIGNhc2UgRVZFTlRfUE9MTF9TVEFURV9ORVRXT1JLX1NFTEVDVElPTl9NT0RFOiB7CiAgICAgICAgICAgICAgICAgICAgIGludHMgPSAoaW50W10pYXIucmVzdWx0OwotICAgICAgICAgICAgICAgICAgICBuZXdTUy5zZXRJc01hbnVhbFNlbGVjdGlvbihpbnRzWzBdID09IDEpOwotICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICBtTmV3U1Muc2V0SXNNYW51YWxTZWxlY3Rpb24oaW50c1swXSA9PSAxKTsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogCiAgICAgICAgIH0gY2F0Y2ggKFJ1bnRpbWVFeGNlcHRpb24gZXgpIHsKICAgICAgICAgICAgIGxvZ2UoIkV4Y2VwdGlvbiB3aGlsZSBwb2xsaW5nIHNlcnZpY2Ugc3RhdGUuIFByb2JhYmx5IG1hbGZvcm1lZCBSSUwgcmVzcG9uc2UuIiArIGV4KTsKICAgICAgICAgfQogCi0gICAgICAgIGZpbmFsIGJvb2xlYW4gdm9pY2VfY2FwYWJsZSA9IHBob25lLmdldENvbnRleHQoKS5nZXRSZXNvdXJjZXMoKS5nZXRCb29sZWFuKAotICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuYm9vbC5jb25maWdfdm9pY2VfY2FwYWJsZSk7CisgICAgICAgIG1Qb2xsaW5nQ29udGV4dFswXS0tOwogCi0gICAgICAgIGlmICghdm9pY2VfY2FwYWJsZSAmJiBuZXdHUFJTU3RhdGUgPT0gU2VydmljZVN0YXRlLlNUQVRFX0lOX1NFUlZJQ0UpIHsKLSAgICAgICAgICAgIG5ld1NTLnNldFN0YXRlIChuZXdHUFJTU3RhdGUpOwotICAgICAgICB9Ci0KLSAgICAgICAgcG9sbGluZ0NvbnRleHRbMF0tLTsKLQotICAgICAgICBpZiAocG9sbGluZ0NvbnRleHRbMF0gPT0gMCkgeworICAgICAgICBpZiAobVBvbGxpbmdDb250ZXh0WzBdID09IDApIHsKICAgICAgICAgICAgIC8qKgogICAgICAgICAgICAgICogIFNpbmNlIHRoZSByb2FtaW5nIHN0YXRlcyBvZiBnc20gc2VydmljZSAoZnJvbSArQ1JFRykgYW5kCiAgICAgICAgICAgICAgKiAgZGF0YSBzZXJ2aWNlIChmcm9tICtDR1JFRykgY291bGQgYmUgZGlmZmVyZW50LCB0aGUgbmV3IFNTCkBAIC03MTcsMTEgKzcxOSwxMSBAQAogICAgICAgICAgICAgICogIG5vdCByb2FtaW5nIGJldHdlZW4gb3BlcmF0b3JzLgogICAgICAgICAgICAgICovCiAgICAgICAgICAgICBib29sZWFuIHJvYW1pbmcgPSAobUdzbVJvYW1pbmcgfHwgbURhdGFSb2FtaW5nKTsKLSAgICAgICAgICAgIGlmIChtR3NtUm9hbWluZyAmJiAhaXNSb2FtaW5nQmV0d2Vlbk9wZXJhdG9ycyhtR3NtUm9hbWluZywgbmV3U1MpKSB7CisgICAgICAgICAgICBpZiAobUdzbVJvYW1pbmcgJiYgIWlzUm9hbWluZ0JldHdlZW5PcGVyYXRvcnMobUdzbVJvYW1pbmcsIG1OZXdTUykpIHsKICAgICAgICAgICAgICAgICByb2FtaW5nID0gZmFsc2U7CiAgICAgICAgICAgICB9Ci0gICAgICAgICAgICBuZXdTUy5zZXRSb2FtaW5nKHJvYW1pbmcpOwotICAgICAgICAgICAgbmV3U1Muc2V0RW1lcmdlbmN5T25seShtRW1lcmdlbmN5T25seSk7CisgICAgICAgICAgICBtTmV3U1Muc2V0Um9hbWluZyhyb2FtaW5nK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U7CkBAIC03NTQsOSArNzU1LDggQEAKICAgICAgICAgICAgIGJyZWFrOwogCiAgICAgICAgICAgICBjYXNlIFJBRElPX09GRjoKLSAgICAgICAgICAgICAgICBuZXdTUy5zZXRTdGF0ZU9mZigpOwotICAgICAgICAgICAgICAgIG5ld0dQUlNTdGF0ZSA9IFNlcnZpY2VTdGF0ZS5TVEFURV9QT1dFUl9PRkY7Ci0gICAgICAgICAgICAgICAgbmV3Q2VsbExvYy5zZXRTdGF0ZUludmFsaWQoKTsKKyAgICAgICAgICAgICAgICBtTmV3U1Muc2V0U3RhdGVPZmYoKTsKKyAgICAgICAgICAgICAgICBtTmV3Q2VsbExvYy5zZXRTdGF0ZUludmFsaWQoKTsKICAgICAgICAgICAgICAgICBzZXRTaWduYWxTdHJlbmd0aERlZmF1bHRWYWx1ZXMoKTsKICAgICAgICAgICAgICAgICBtR290Q291bnRyeUNvZGUgPSBmYWxzZTsKICAgICAgICAgICAgICAgICBtTml0elVwZGF0ZWRUaW1lID0gZmFsc2U7CkBAIC03NjgsMjUgKzc2OCwyNSBAQAogICAgICAgICAgICAgICAgIC8vIHRoZW4gY291bnQgZG93biB0aGUgcmVzcG9uc2VzLCB3aGljaAogICAgICAgICAgICAgICAgIC8vIGFyZSBhbGxvd2VkIHRvIGFycml2ZSBvdXQtb2Ytb3JkZXIKIAotICAgICAgICAgICAgICAgIHBvbGxpbmdDb250ZXh0WzBdKys7Ci0gICAgICAgICAgICAgICAgY20uZ2V0T3BlcmF0b3IoCisgICAgICAgICAgICAgICAgbVBvbGxpbmdDb250ZXh0WzBdKys7CisgICAgICAgICAgICAgICAgbUNpLmdldE9wZXJhdG9yKAogICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKAotICAgICAgICAgICAgICAgICAgICAgICAgRVZFTlRfUE9MTF9TVEFURV9PUEVSQVRPUiwgcG9sbGluZ0NvbnRleHQpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIEVWRU5UX1BPTExfU1RBVEVfT1BFUkFUT1IsIG1Qb2xsaW5nQ29udGV4dCkpOwogCi0gICAgICAgICAgICAgICAgcG9sbGluZ0NvbnRleHRbMF0rKzsKLSAgICAgICAgICAgICAgICBjbS5nZXREYXRhUmVnaXN0cmF0aW9uU3RhdGUoCisgICAgICAgICAgICAgICAgbVBvbGxpbmdDb250ZXh0WzBdKys7CisgICAgICAgICAgICAgICAgbUNpLmdldERhdGFSZWdpc3RyYXRpb25TdGF0ZSgKICAgICAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZSgKLSAgICAgICAgICAgICAgICAgICAgICAgIEVWRU5UX1BPTExfU1RBVEVfR1BSUywgcG9sbGluZ0NvbnRleHQpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIEVWRU5UX1BPTExfU1RBVEVfR1BSUywgbVBvbGxpbmdDb250ZXh0KSk7CiAKLSAgICAgICAgICAgICAgICBwb2xsaW5nQ29udGV4dFswXSsrOwotICAgICAgICAgICAgICAgIGNtLmdldFZvaWNlUmVnaXN0cmF0aW9uU3RhdGUoCisgICAgICAgICAgICAgICAgbVBvbGxpbmdDb250ZXh0WzBdKys7CisgICAgICAgICAgICAgICAgbUNpLmdldFZvaWNlUmVnaXN0cmF0aW9uU3RhdGUoCiAgICAgICAgICAgICAgICAgICAgIG9idGFpbk1lc3NhZ2UoCi0gICAgICAgICAgICAgICAgICAgICAgICBFVkVOVF9QT0xMX1NUQVRFX1JFR0lTVFJBVElPTiwgcG9sbGluZ0NvbnRleHQpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIEVWRU5UX1BPTExfU1RBVEVfUkVHSVNUUkFUSU9OLCBtUG9sbGluZ0NvbnRleHQpKTsKIAotICAgICAgICAgICAgICAgIHBvbGxpbmdDb250ZXh0WzBdKys7Ci0gICAgICAgICAgICAgICAgY20uZ2V0TmV0d29ya1NlbGVjdGlvbk1vZGUoCisgICAgICAgICAgICAgICAgbVBvbGxpbmdDb250ZXh0WzBdKys7CisgICAgICAgICAgICAgICAgbUNpLmdldE5ldHdvcmtTZWxlY3Rpb25Nb2RlKAogICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKAotICAgICAgICAgICAgICAgICAgICAgICAgRVZFTlRfUE9MTF9TVEFURV9ORVRXT1JLX1NFTEVDVElPTl9NT0RFLCBwb2xsaW5nQ29udGV4dCkpOworICAgICAgICAgICAgICAgICAgICAgICAgRVZFTlRfUE9MTF9TVEFURV9ORVRXT1JLX1NFTEVDVElPTl9NT0RFLCBtUG9sbGluZ0NvbnRleHQpKTsKICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICB9CiAgICAgfQpAQCAtNzk0LDg4ICs3OTQsODUgQEAKICAgICBwcml2YXRlIHZvaWQgcG9sbFN0YXRlRG9uZSgpIHsKICAgICAgICAgaWYgKERCRykgewogICAgICAgICAgICAgbG9nKCJQb2xsIFNlcnZpY2VTdGF0ZSBkb25lOiAiICsKLSAgICAgICAgICAgICAgICAiIG9sZFNTPVsiICsgc3MgKyAiXSBuZXdTUz1bIiArIG5ld1NTICsKLSAgICAgICAgICAgICAgICAiXSBvbGRHcHJzPSIgKyBncHJzU3RhdGUgKyAiIG5ld0RhdGE9IiArIG5ld0dQUlNTdGF0ZSArCisgICAgICAgICAgICAgICAgIiBvbGRTUz1bIiArIG1TUyArICJdIG5ld1NTPVsiICsgbU5ld1NTICsgIl0iICsKICAgICAgICAgICAgICAgICAiIG9sZE1heERhdGFDYWxscz0iICsgbU1heERhdGFDYWxscyArCiAgICAgICAgICAgICAgICAgIiBtTmV3TWF4RGF0YUNhbGxzPSIgKyBtTmV3TWF4RGF0YUNhbGxzICsKICAgICAgICAgICAgICAgICAiIG9sZFJlYXNvbkRhdGFEZW5pZWQ9IiArIG1SZWFzb25EYXRhRGVuaWVkICsKLSAgICAgICAgICAgICAgICAiIG1OZXdSZWFzb25EYXRhRGVuaWVkPSIgKyBtTmV3UmVhc29uRGF0YURlbmllZCArCi0gICAgICAgICAgICAgICAgIiBvbGRUeXBlPSIg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AgbU5ld1NTLmdldFJpbFZvaWNlUmFkaW9UZWNobm9sb2d5KCkpOwogICAgICAgICAgICAgaWYgKERCRykgewotICAgICAgICAgICAgICAgIGxvZygiUkFUIHN3aXRjaGVkICIgKyBTZXJ2aWNlU3RhdGUucmlsUmFkaW9UZWNobm9sb2d5VG9TdHJpbmcobVJpbFJhZGlvVGVjaG5vbG9neSkgKwotICAgICAgICAgICAgICAgICAgICAgICAgIiAtPiAiICsgU2VydmljZVN0YXRlLnJpbFJhZGlvVGVjaG5vbG9neVRvU3RyaW5nKG1OZXdSaWxSYWRpb1RlY2hub2xvZ3kpICsKKyAgICAgICAgICAgICAgICBsb2coIlJBVCBzd2l0Y2hlZCAiCisgICAgICAgICAgICAgICAgICAgICAgICArIFNlcnZpY2VTdGF0ZS5yaWxSYWRpb1RlY2hub2xvZ3lUb1N0cmluZyhtU1MuZ2V0UmlsVm9pY2VSYWRpb1RlY2hub2xvZ3koKSkKKyAgICAgICAgICAgICAgICAgICAgICAgICsgIiAtPiAiCisgICAgICAgICAgICAgICAgICAgICAgICArIFNlcnZpY2VTdGF0ZS5yaWxSYWRpb1RlY2hub2xvZ3lUb1N0cmluZyhtTmV3U1MuZ2V0UmlsVm9pY2VSYWRpb1RlY2hub2xvZ3koKSkgKwogICAgICAgICAgICAgICAgICAgICAgICAgIiBhdCBjZWxsICIgKyBjaWQpOwogICAgICAgICAgICAgfQogICAgICAgICB9CiAKLSAgICAgICAgZ3Byc1N0YXRlID0gbmV3R1BSU1N0YXRlOwogICAgICAgICBtUmVhc29uRGF0YURlbmllZCA9IG1OZXdSZWFzb25EYXRhRGVuaWVkOwogICAgICAgICBtTWF4RGF0YUNhbGxzID0gbU5ld01heERhdGFDYWxsczsKLSAgICAgICAgbVJpbFJhZGlvVGVjaG5vbG9neSA9IG1OZXdSaWxSYWRpb1RlY2hub2xvZ3k7Ci0gICAgICAgIC8vIHRoaXMgbmV3IHN0YXRlIGhhcyBiZWVuIGFwcGxpZWQgLSBmb3Jn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VRPUl9BTFBIQSwKLSAgICAgICAgICAgICAgICBzcy5nZXRPcGVyYXRvckFscGhhTG9uZygpKTsKKyAgICAgICAgICAgIG1QaG9uZS5zZXRTeXN0ZW1Qcm9wZXJ0eShUZWxlcGhvbnlQcm9wZXJ0aWVzLlBST1BFUlRZX09QRVJBVE9SX0FMUEhBLAorICAgICAgICAgICAgICAgIG1TUy5nZXRPcGVyYXRvckFscGhhTG9uZygpKTsKIAogICAgICAgICAgICAgU3RyaW5nIHByZXZPcGVyYXRvck51bWVyaWMgPQogICAgICAgICAgICAgICAgICAgICBTeXN0ZW1Qcm9wZXJ0aWVzLmdldChUZWxlcGhvbnlQcm9wZXJ0aWVzLlBST1BFUlRZX09QRVJBVE9SX05VTUVSSUMsICIiKTsKLSAgICAgICAgICAgIG9wZXJhdG9yTnVtZXJpYyA9IHNzLmdldE9wZXJhdG9yTnVtZXJpYygpOwotICAgICAgICAgICAgcGhvbmUuc2V0U3lzdGVtUHJvcGVydHkoVGVsZXBob255UHJvcGVydGllcy5QUk9QRVJUWV9PUEVSQVRPUl9OVU1FUklDLCBvcGVyYXRvck51bWVyaWMpOworICAgICAgICAgICAgb3BlcmF0b3JOdW1lcmljID0gbVNTLmdldE9wZXJhdG9yTnVtZXJpYygpOworICAgICAgICAgICAgbVBob25lLnNldFN5c3RlbVByb3BlcnR5KFRlbGVwaG9ueVByb3BlcnRpZXMuUFJPUEVSVFlfT1BFUkFUT1JfTlVNRVJJQywgb3BlcmF0b3JOdW1lcmljKTsKIAogICAgICAgICAgICAgaWYgKG9wZXJhdG9yTnVtZXJpYyA9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJvcGVyYXRvck51bWVyaWMgaXMgbnVsbCIpOwotICAgICAgICAgICAgICAgIHBob25lLnNldFN5c3RlbVByb3BlcnR5KFRlbGVwaG9ueVByb3BlcnRpZXMuUFJPUEVSVFlfT1BFUkFUT1JfSVNPX0NPVU5UUlksICIiKTsKKyAgICAgICAgICAgICAgICBtUGhvbmUuc2V0U3lzdGVtUHJvcGVydHkoVGVsZXBob255UHJvcGVydGllcy5QUk9QRVJUWV9PUEVSQVRPUl9JU09fQ09VTlRSWSwgIiIpOwogICAgICAgICAgICAgICAgIG1Hb3RDb3VudHJ5Q29kZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgIG1OaXR6VXBkYXRlZFRpbWUgPSBmYWxzZTsKICAgICAgICAgICAgIH0gZWxzZSB7CkBAIC05MTgsNyArOTE1LDcgQEAKICAgICAgICAgICAgICAgICAgICAgbG9nZSgicG9sbFN0YXRlRG9uZTogY291bnRyeUNvZGVGb3JNY2MgZXJyb3IiICsgZXgpOwogICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgICAgIHBob25lLnNldFN5c3RlbVByb3BlcnR5KFRlbGVwaG9ueVByb3BlcnRpZXMuUFJPUEVSVFlfT1BFUkFUT1JfSVNPX0NPVU5UUlksIGlzbyk7CisgICAgICAgICAgICAgICAgbVBob25lLnNldFN5c3RlbVByb3BlcnR5KFRlbGVwaG9ueVByb3BlcnRpZXMuUFJPUEVSVFlfT1BFUkFUT1JfSVNPX0NPVU5UUlksIGlzbyk7CiAgICAgICAgICAgICAgICAgbUdvdENvdW50cnlDb2RlID0gdHJ1ZTsKIAogICAgICAgICAgICAgICAgIFRpbWVab25lIHpvbmUgPSBudWxsOwpAQCAtOTUwLDcgKzk0Nyw3IEBACiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgICAgICBpZiAoc2hvdWxkRml4VGltZVpvbmVOb3cocGhvbmUsIG9wZXJhdG9yTnVtZXJpYywgcHJldk9wZXJhdG9yTnVtZXJpYywKKyAgICAgICAgICAgICAgICBpZiAoc2hvdWxkRml4VGltZVpvbmVOb3cobVBob25lLCBvcGVyYXRvck51bWVyaWMsIHByZXZPcGVyYXRvck51bWVyaWMsCiAgICAgICAgICAgICAgICAgICAgICAgICBtTmVlZEZpeFpvbmVBZnRlck5pdHopKSB7CiAgICAgICAgICAgICAgICAgICAgIC8vIElmIHRoZSBvZmZzZXQgaXMgKDAsIGZhbHNlKSBhbmQgdGhlIHRpbWV6b25lIHByb3BlcnR5CiAgICAgICAgICAgICAgICAgICAgIC8vIGlzIHNldCwgdXNlIHRoZSB0aW1lem9uZSBwcm9wZXJ0eSByYXRoZXIgdGhhbgpAQCAtMTAxNywxMCArMTAxNCwxMCBAQAogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgcGhvbmUuc2V0U3lzdGVtUHJvcGVydHkoVGVsZXBob255UHJvcGVydGllcy5QUk9QRVJUWV9PUEVSQVRPUl9JU1JPQU1JTkcsCi0gICAgICAgICAgICAgICAgc3MuZ2V0Um9hbWluZygpID8gInRydWUiIDogImZhbHNlIik7CisgICAgICAgICAgICBtUGhvbmUuc2V0U3lzdGVtUHJvcGVydHkoVGVsZXBob255UHJvcGVydGllcy5QUk9QRVJUWV9PUEVSQVRPUl9JU1JPQU1JTkcsCisgICAgICAgICAgICAgICAgbVNTLmdldFJvYW1pbmcoKSA/ICJ0cnVlIiA6ICJmYWxzZSIpOwogCi0gICAgICAgICAgICBwaG9uZS5ub3RpZnlTZXJ2aWNlU3RhdGVDaGFuZ2VkKHNzKTsKKyAgICAgICAgICAgIG1QaG9uZS5ub3RpZnlTZXJ2aWNlU3RhdGVDaGFuZ2VkKG1TUyk7CiAgICAgICAgIH0KIAogICAgICAgICBpZiAoaGFzR3Byc0F0dGFjaGVkKSB7CkBAIC0xMDMxLDggKzEwMjgsOCBAQAogICAgICAgICAgICAgbURldGFjaGVkUmVnaXN0cmFudHMubm90aWZ5UmVnaXN0cmFudHMoKTsKICAgICAgICAgfQogCi0gICAgICAgIGlmIChoYXNSYWRpb1RlY2hub2xvZ3lDaGFuZ2VkKSB7Ci0gICAgICAgICAgICBwaG9uZS5ub3RpZnlEYXRhQ29ubmVjdGlvbihQaG9uZS5SRUFTT05fTldfVFlQRV9DSEFOR0VEKTsKKyAgICAgICAgaWYgKGhhc1JpbFZvaWNlUmFkaW9UZWNobm9sb2d5Q2hhbmdlZCkgeworICAgICAgICAgICAgbVBob25lLm5vdGlmeURhdGFDb25uZWN0aW9uKFBob25lLlJFQVNPTl9OV19UWVBFX0NIQU5HRUQpOwogICAgICAgICB9CiAKICAgICAgICAgaWYgKGhhc1JvYW1pbmdPbikgewpAQCAtMTA0NCwxNSArMTA0MSwxNSBAQAogICAgICAgICB9CiAKICAgICAgICAgaWYgKGhhc0xvY2F0aW9uQ2hhbmdlZCkgewotICAgICAgICAgICAgcGhvbmUubm90aWZ5TG9jYXRpb25DaGFuZ2VkKCk7CisgICAgICAgICAgICBtUGhvbmUubm90aWZ5TG9jYXRpb25DaGFuZ2VkKCk7CiAgICAgICAgIH0KIAotICAgICAgICBpZiAoISBpc0dwcnNDb25zaXN0ZW50KGdwcnNTdGF0ZSwgc3MuZ2V0U3RhdGUoKSkpIHsKKyAgICAgICAgaWYgKCEgaXNHcHJzQ29uc2lzdGVudChtU1MuZ2V0RGF0YVJlZ1N0YXRlKCksIG1TUy5nZXRWb2ljZVJlZ1N0YXRlKCkpKSB7CiAgICAgICAgICAgICBpZiAoIW1TdGFydGVkR3Byc1JlZ0NoZWNrICYmICFtUmVwb3J0ZWRHcHJzTm9SZWcpIHsKICAgICAgICAgICAgICAgICBtU3RhcnRlZEdwcnNSZWdDaGVjayA9IHRydWU7CiAKICAgICAgICAgICAgICAgICBpbnQgY2hlY2tfcGVyaW9kID0gU2V0dGluZ3MuR2xvYmFsLmdldEludCgKLSAgICAgICAgICAgICAgICAgICAgICAgIHBob25lLmdldENvbnRleHQoKS5nZXRDb250ZW50UmVzb2x2ZXIoKSwKKyAgICAgICAgICAgICAgICAgICAgICAgIG1QaG9uZS5nZXRDb250ZXh0KCkuZ2V0Q29udGVudFJlc29sdmVyKCksCiAgICAgICAgICAgICAgICAgICAgICAgICBTZXR0aW5ncy5HbG9iYWwuR1BSU19SRUdJ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WzZdID0gJzonOwotCi0gICAgICAgIGJ1Zls3XSA9IChjaGFyKSAoJzAnICsgbWludXRlcyAvIDEwKTsKLSAgICAgICAgYnVmWzhdID0gKGNoYXIpICgnMCcgKyBtaW51dGVzICUgMTApOwotCi0gICAgICAgIHJldHVybiBuZXcgU3RyaW5nKGJ1Zik7CisgICAgICAgIHJldHVybiAobVNTLmdldFJpbFZvaWNlUmFkaW9UZWNobm9sb2d5KCkgPj0gU2VydmljZVN0YXRlLlJJTF9SQURJT19URUNITk9MT0dZX1VNVFMpOwogICAgIH0KIAogICAgIC8qKgpAQCAtMTUxMCw3ICsxNDU3LDcgQEAKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgU3lzdGVtUHJvcGVydGllcy5zZXQoImdzbS5uaXR6LnRpbWUiLCBTdHJpbmcudmFsdWVPZihjLmdldFRpbWVJbk1pbGxpcygpKSk7CiAgICAgICAgICAgICAgICAgc2F2ZU5pdHpUaW1lKGMuZ2V0VGltZUluTWlsbGlzKCkpOwotICAgICAgICAgICAgICAgIGlmIChmYWxzZSkgeworICAgICAgICAgICAgICAgIGlmIChWREJHKSB7CiAgICAgICAgICAgICAgICAgICAgIGxvbmcgZW5kID0gU3lzdGVtQ2xvY2suZWxhcHNlZFJlYWx0aW1lKCk7CiAgICAgICAgICAgICAgICAgICAgIGxvZygiTklUWjogZW5kPSIgKyBlbmQgKyAiIGR1cj0iICsgKGVuZCAtIHN0YXJ0KSk7CiAgICAgICAgICAgICAgICAgfQpAQCAtMTUyNSw4ICsxNDcyLDggQEAKIAogICAgIHByaXZhdGUgYm9vbGVhbiBnZXRBdXRvVGltZSgpIHsKICAgICAgICAgdHJ5IHsKLSAgICAgICAgICAgIHJldHVybiBTZXR0aW5ncy5TeXN0ZW0uZ2V0SW50KHBob25lLmdldENvbnRleHQoKS5nZXRDb250ZW50UmVzb2x2ZXIoKSwKLSAgICAgICAgICAgICAgICAgICAgU2V0dGluZ3MuU3lzdGVtLkFVVE9fVElNRSkgPiAwOworICAgICAgICAgICAgcmV0dXJuIFNldHRpbmdzLkdsb2JhbC5nZXRJbnQobVBob25lLmdldENvbnRleHQoKS5nZXRDb250ZW50UmVzb2x2ZXIoKSwKKyAgICAgICAgICAgICAgICAgICAgU2V0dGluZ3MuR2xvYmFsLkFVVE9fVElNRSkgPiAwOwogICAgICAgICB9IGNhdGNoIChTZXR0aW5nTm90Rm91bmRFeGNlcHRpb24gc25mZSkgewogICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgIH0KQEAgLTE1MzQsOCArMTQ4MSw4IEBACiAKICAgICBwcml2YXRlIGJvb2xlYW4gZ2V0QXV0b1RpbWVab25lKCkgewogICAgICAgICB0cnkgewotICAgICAgICAgICAgcmV0dXJuIFNldHRpbmdzLlN5c3RlbS5nZXRJbnQocGhvbmUuZ2V0Q29udGV4dCgpLmdldENvbnRlbnRSZXNvbHZlcigpLAotICAgICAgICAgICAgICAgICAgICBTZXR0aW5ncy5TeXN0ZW0uQVVUT19USU1FX1pPTkUpID4gMDsKKyAgICAgICAgICAgIHJldHVybiBTZXR0aW5ncy5HbG9iYWwuZ2V0SW50KG1QaG9uZS5nZXRDb250ZXh0KCkuZ2V0Q29udGVudFJlc29sdmVyKCksCisgICAgICAgICAgICAgICAgICAgIFNldHRpbmdzLkdsb2JhbC5BVVRPX1RJTUVfWk9ORSkgPiAwOwogICAgICAgICB9IGNhdGNoIChTZXR0aW5nTm90Rm91bmRFeGNlcHRpb24gc25mZSkgewogICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgIH0KQEAgLTE1NTksMTIgKzE1MDYsMTIgQEAKICAgICBwcml2YXRlIHZvaWQgc2V0QW5kQnJvYWRjYXN0TmV0d29ya1NldFRpbWVab25lKFN0cmluZyB6b25lSWQpIHsKICAgICAgICAgaWYgKERCRykgbG9nKCJzZXRBbmRCcm9hZGNhc3ROZXR3b3JrU2V0VGltZVpvbmU6IHNldFRpbWVab25lPSIgKyB6b25lSWQpOwogICAgICAgICBBbGFybU1hbmFnZXIgYWxhcm0gPQotICAgICAgICAgICAgKEFsYXJtTWFuYWdlcikgcGhvbmUuZ2V0Q29udGV4dCgpLmdldFN5c3RlbVNlcnZpY2UoQ29udGV4dC5BTEFSTV9TRVJWSUNFKTsKKyAgICAgICAgICAgIChBbGFybU1hbmFnZXIpIG1QaG9uZS5nZXRDb250ZXh0KCkuZ2V0U3lzdGVtU2VydmljZShDb250ZXh0LkFMQVJNX1NFUlZJQ0UpOwogICAgICAgICBhbGFybS5zZXRUaW1lWm9uZSh6b25lSWQpOwogICAgICAgICBJbnRlbnQgaW50ZW50ID0gbmV3IEludGVudChUZWxlcGhvbnlJbnRlbnRzLkFDVElPTl9ORVRXT1JLX1NFVF9USU1FWk9ORSk7CiAgICAgICAgIGludGVudC5hZGRGbGFncyhJbnRlbnQuRkxBR19SRUNFSVZFUl9SRVBMQUNFX1BFTkRJTkcpOwogICAgICAgICBpbnRlbnQucHV0RXh0cmEoInRpbWUtem9uZSIsIHpvbmVJZCk7Ci0gICAgICAgIHBob25lLmdldENvbnRleHQoKS5zZW5kU3RpY2t5QnJvYWRjYXN0QXNVc2VyKGludGVudCwgVXNlckhhbmRsZS5BTEwpOworICAgICAgICBtUGhvbmUuZ2V0Q29udGV4dCgpLnNlbmRTdGlja3lCcm9hZGNhc3RBc1VzZXIoaW50ZW50LCBVc2VySGFuZGxlLkFMTCk7CiAgICAgICAgIGlmIChEQkcpIHsKICAgICAgICAgICAgIGxvZygic2V0QW5kQnJvYWRjYXN0TmV0d29ya1NldFRpbWVab25lOiBjYWxsIGFsYXJtLnNldFRpbWVab25lIGFuZCBicm9hZGNhc3Qgem9uZUlkPSIgKwogICAgICAgICAgICAgICAgIHpvbmVJZCk7CkBAIC0xNTgzLDEyICsxNTMwLDEyIEBACiAgICAgICAgIEludGVudCBpbnRlbnQgPSBuZXcgSW50ZW50KFRlbGVwaG9ueUludGVudHMuQUNUSU9OX05FVFdPUktfU0VUX1RJTUUpOwogICAgICAgICBpbnRlbnQuYWRkRmxhZ3MoSW50ZW50LkZMQUdfUkVDRUlWRVJfUkVQTEFDRV9QRU5ESU5HKTsKICAgICAgICAgaW50ZW50LnB1dEV4dHJhKCJ0aW1lIiwgdGltZSk7Ci0gICAgICAgIHBob25lLmdldENvbnRleHQoKS5zZW5kU3RpY2t5QnJvYWRjYXN0QXNVc2VyKGludGVudCwgVXNlckhhbmRsZS5BTEwpOworICAgICAgICBtUGhvbmUuZ2V0Q29udGV4dCgpLnNlbmRTdGlja3lCcm9hZGNhc3RBc1VzZXIoaW50ZW50LCBVc2VySGFuZGxlLkFMTCk7CiAgICAgfQogCiAgICAgcHJpdmF0ZSB2b2lkIHJldmVydFRvTml0elRpbWUoKSB7Ci0gICAgICAgIGlmIChTZXR0aW5ncy5TeXN0ZW0uZ2V0SW50KHBob25lLmdldENvbnRleHQoKS5nZXRDb250ZW50UmVzb2x2ZXIoKSwKLSAgICAgICAgICAgICAgICBTZXR0aW5ncy5TeXN0ZW0uQVVUT19USU1FLCAwKSA9PSAwKSB7CisgICAgICAgIGlmIChTZXR0aW5ncy5HbG9iYWwuZ2V0SW50KG1QaG9uZS5nZXRDb250ZXh0KCkuZ2V0Q29udGVudFJlc29sdmVyKCksCisgICAgICAgICAgICAgICAgU2V0dGluZ3MuR2xvYmFsLkFVVE9fVElNRSwgMCkgPT0gMCkgewogICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICB9CiAgICAgICAgIGlmIChEQkcpIHsKQEAgLTE2MDIsOCArMTU0OSw4IEBACiAgICAgfQogCiAgICAgcHJpdmF0ZSB2b2lkIHJldmVydFRvTml0elRpbWVab25lKCkgewotICAgICAgICBpZiAoU2V0dGluZ3MuU3lzdGVtLmdldEludChwaG9uZS5nZXRDb250ZXh0KCkuZ2V0Q29udGVudFJlc29sdmVyKCksCi0gICAgICAgICAgICAgICAgU2V0dGluZ3MuU3lzdGVtLkFVVE9fVElNRV9aT05FLCAwKSA9PSAwKSB7CisgICAgICAgIGlmIChTZXR0aW5ncy5HbG9iYWwuZ2V0SW50KG1QaG9uZS5nZXRDb250ZXh0KCkuZ2V0Q29udGVudFJlc29sdmVyKCksCisgICAgICAgICAgICAgICAgU2V0dGluZ3MuR2xvYmFsLkFVVE9fVElNRV9aT05FLCAwKSA9PSAwKSB7CiAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgIH0KICAgICAgICAgaWYgKERCRykgbG9nKCJSZXZlcnRpbmcgdG8gTklUWiBUaW1lWm9uZTogdHo9JyIgKyBtU2F2ZWRUaW1lWm9uZSk7CkBAIC0xNjIwLDcgKzE1NjcsNyBAQAogICAgIHByaXZhdGUgdm9pZCBzZXROb3RpZmljYXRpb24oaW50IG5vdGlmeVR5cGUpIHsKIAogICAgICAgICBpZiAoREJHKSBsb2coInNldE5vdGlmaWNhdGlvbjogY3JlYXRlIG5vdGlmaWNhdGlvbiAiICsgbm90aWZ5VHlwZSk7Ci0gICAgICAgIENvbnRleHQgY29udGV4dCA9IHBob25lLmdldENvbnRleHQoKTsKKyAgICAgICAgQ29udGV4dCBjb250ZXh0ID0gbVBob25lLmdldENvbnRleHQoKTsKIAogICAgICAgICBtTm90aWZpY2F0aW9uID0gbmV3IE5vdGlmaWNhdGlvbigpOwogICAgICAgICBtTm90aWZpY2F0aW9uLndoZW4gPSBTeXN0ZW0uY3VycmVudFRpbWVNaWxsaXMoKTsKQEAgLTE2MzcsMTkgKzE1ODQsMTkgQEAKICAgICAgICAgc3dpdGNoIChub3RpZnlUeXBlKSB7CiAgICAgICAgIGNhc2UgUFNfRU5BQkxFRDoKICAgICAgICAgICAgIG5vdGlmaWNhdGlvbklkID0gUFNfTk9USUZJQ0FUSU9OOwotICAgICAgICAgICAgZGV0YWlscyA9IGNvbnRleHQuZ2V0VGV4dChjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5SZXN0cmljdGVkT25EYXRhKTs7CisgICAgICAgICAgICBkZXRhaWxzID0gY29udGV4dC5nZXRUZXh0KGNvb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mN5KTsKICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICBjYXNlIENTX0RJU0FCTEVEOgogICAgICAgICAgICAgLy8gZG8gbm90aGluZyBhbmQgY2FuY2VsIHRoZSBub3RpZmljYXRpb24gbGF0ZXIKQEAgLTE3MTMsMjAgKzE2NjAsMTYgQEAKICAgICAgICAgUmxvZy5lKExPR19UQUcsICJbR3NtU1NUXSAiICsgcyk7CiAgICAgfQogCi0gICAgcHJpdmF0ZSBzdGF0aWMgdm9pZCBzbG9nZShTdHJpbmcgcykgewotICAgICAgICBSbG9nLmUoTE9HX1RBRywgIltHc21TU1RdICIgKyBzKTsKLSAgICB9Ci0KICAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBkdW1wKEZpbGVEZXNjcmlwdG9yIGZkLCBQcmludFdyaXRlciBwdywgU3RyaW5nW10gYXJncykgewogICAgICAgICBwdy5wcmludGxuKCJHc21TZXJ2aWNlU3RhdGVUcmFja2VyIGV4dGVuZHM6Iik7CiAgICAgICAgIHN1cGVyLmR1bXAoZmQsIHB3LCBhcmdzKTsKLSAgICAgICAgcHcucHJpbnRsbigiIHBob25lPSIgKyBwaG9uZSk7Ci0gICAgICAgIHB3LnByaW50bG4oIiBjZWxsTG9jPSIgKyBjZWxsTG9jKTsKLSAgICAgICAgcHcucHJpbnRsbigiIG5ld0NlbGxMb2M9IiArIG5ld0NlbGxMb2MpOworICAgICAgICBwdy5wcmludGxuKCIgbVBob25lPSIgKyBtUGhvbmUpOworICAgICAgICBwdy5wcmludGxuKCIgbVNTPSIgKyBtU1MpOworICAgICAgICBwdy5wcmludGxuKCIgbU5ld1NTPSIgKyBtTmV3U1MpOworICAgICAgICBwdy5wcmludGxuKCIgbUNlbGxMb2M9IiArIG1DZWxsTG9jKTsKKyAgICAgICAgcHcucHJpbnRsbigiIG1OZXdDZWxsTG9jPSIgKyBtTmV3Q2VsbExvYyk7CiAgICAgICAgIHB3LnByaW50bG4oIiBtUHJlZmVycmVkTmV0d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ZWQgdm9pZCBmaW5hbGl6ZSgpIHsKICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgIHN1cGVyLmZpbmFsaXplKCk7CkBAIC01MSwzMCArNTMsMzMgQEAKICAgICAgICAgaWYoREJHKSBSbG9nLmQoTE9HX1RBRywgIlNpbVBob25lQm9va0ludGVyZmFjZU1hbmFnZXIgZmluYWxpemVkIik7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGludFtdIGdldEFkblJlY29yZHNTaXplKGludCBlZmlkKSB7CiAgICAgICAgIGlmIChEQkcpIGxvZ2QoImdldEFkblJlY29yZHNTaXplOiBlZmlkPSIgKyBlZmlkKTsKICAgICAgICAgc3luY2hyb25pemVkKG1Mb2NrKSB7CiAgICAgICAgICAgICBjaGVja1RocmVhZCgpOwotICAgICAgICAgICAgcmVjb3JkU2l6ZSA9IG5ldyBpbnRbM107CisgICAgICAgICAgICBtUmVjb3JkU2l6ZSA9IG5ldyBpbnRbM107CiAKICAgICAgICAgICAgIC8vVXNpbmcgbUJhc2VIYW5kbGVyLCBubyBkaWZmZXJlbmNlIGluIEVWRU5UX0dFVF9TSVpFX0RPTkUgaGFuZGxpbmcKICAgICAgICAgICAgIEF0b21pY0Jvb2xlYW4gc3RhdHVzID0gbmV3IEF0b21pY0Jvb2xlYW4oZmFsc2UpOwogICAgICAgICAgICAgTWVzc2FnZSByZXNwb25zZSA9IG1CYXNlSGFuZGxlci5vYnRhaW5NZXNzYWdlKEVWRU5UX0dFVF9TSVpFX0RPTkUsIHN0YXR1cyk7CiAKLSAgICAgICAgICAgIEljY0ZpbGVIYW5kbGVyIGZoID0gcGhvbmUuZ2V0SWNjRmlsZUhhbmRsZXIoKTsKKyAgICAgICAgICAgIEljY0ZpbGVIYW5kbGVyIGZoID0gbVBob25lLmdldEljY0ZpbGVIYW5kbGVyKCk7CiAgICAgICAgICAgICBpZiAoZmggIT0gbnVsbCkgewogICAgICAgICAgICAgICAgIGZoLmdldEVGTGluZWFy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Tg5LDcgQEAKICAgICAgICAgICAgIE1lc3NhZ2UgcmVzcG9uc2UgPSBtSGFuZGxlci5vYnRhaW5NZXNzYWdlKEVWRU5UX1NFVF9CUk9BRENBU1RfQ09ORklHX0RPTkUpOwogCiAgICAgICAgICAgICBtU3VjY2VzcyA9IGZhbHNlOwotICAgICAgICAgICAgbVBob25lLm1DTS5zZXRHc21Ccm9hZGNhc3RDb25maWcoY29uZmlncywgcmVzcG9uc2UpOworICAgICAgICAgICAgbVBob25lLm1DaS5zZXRHc21Ccm9hZGNhc3RDb25maWcoY29uZmlncywgcmVzcG9uc2UpOwogCiAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgIG1Mb2NrLndhaXQoKTsKQEAgLTE5OSw3ICsyMDksNyBAQAogICAgICAgICAgICAgTWVzc2FnZSByZXNwb25zZSA9IG1IYW5kbGVyLm9idGFpbk1lc3NhZ2UoRVZFTlRfU0VUX0JST0FEQ0FTVF9BQ1RJVkFUSU9OX0RPTkUpOwogCiAgICAgICAgICAgICBtU3VjY2VzcyA9IGZhbHNlOwotICAgICAgICAgICAgbVBob25lLm1DTS5zZXRHc21Ccm9hZGNhc3RBY3RpdmF0aW9uKGFjdGl2YXRlLCByZXNwb25zZSk7CisgICAgICAgICAgICBtUGhvbmUubUNpLnNldEdzbUJyb2FkY2FzdEFjdGl2YXRpb24oYWN0aXZhdGUsIHJlc3BvbnNlKTsKIAogICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICBtTG9jay53YWl0KCk7CmRpZmYgLS1naXQgYS9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvZ3NtL1NpbVRsdi5qYXZhIGIvc3JjL2phdmEvY29tL2FuZHJvaWQvaW50ZXJuYWwvdGVsZXBob255L2dzbS9TaW1UbHYuamF2YQppbmRleCA0OTdjZjVmLi5jOThiOWExIDEwMDY0NAotLS0gYS9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hb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AgICAgICAgICBpZiAoKHJlY29yZFtjdXJPZmZzZXQgKyAxXSAmIDB4ZmYpIDwgMHg4MCkgeworICAgICAgICAgICAgaWYgKChtUmVjb3JkW21DdXJPZmZzZXQgKyAxXSAmIDB4ZmYpIDwgMHg4MCkgewogICAgICAgICAgICAgICAgIC8vIG9uZSBieXRlIGxlbmd0aCAwIC0gMHg3ZgotICAgICAgICAgICAgICAgIGN1ckRhdGFMZW5ndGggPSByZWNvcmRbY3VyT2Zmc2V0ICsgMV0gJiAweGZmOwotICAgICAgICAgICAgICAgIGN1ckRhdGFPZmZzZXQgPSBjdXJPZmZzZXQgKyAyOwotICAgICAgICAgICAgfSBlbHNlIGlmICgocmVjb3JkW2N1ck9mZnNldCArIDFdICYgMHhmZikgPT0gMHg4MSkgeworICAgICAgICAgICAgICAgIG1DdXJEYXRhTGVuZ3RoID0gbVJlY29yZFttQ3VyT2Zmc2V0ICsgMV0gJiAweGZmOworICAgICAgICAgICAgICAgIG1DdXJEYXRhT2Zmc2V0ID0gbUN1ck9mZnNldCArIDI7CisgICAgICAgICAgICB9IGVsc2UgaWYgKChtUmVjb3JkW21DdXJPZmZzZXQgKyAxXSAmIDB4ZmYpID09IDB4ODEpIHsKICAgICAgICAgICAgICAgICAvLyB0d28gYnl0ZSBsZW5ndGggMHg4MCAtIDB4ZmYKLSAgICAgICAgICAgICAgICBjdXJEYXRhTGVuZ3RoID0gcmVjb3JkW2N1ck9mZnNldCArIDJdICYgMHhmZjsKLSAgICAgICAgICAgICAgICBjdXJEYXRhT2Zmc2V0ID0gY3VyT2Zmc2V0ICsgMzsKKyAgICAgICAgICAgICAgICBtQ3VyRGF0YUxlbmd0aCA9IG1SZWNvcmRbbUN1ck9mZnNldCArIDJdICYgMHhmZjsKKyAgICAgICAgICAgICAgICBtQ3VyRGF0YU9mZnNldCA9IG1DdXJPZmZzZXQgKyAzOwogICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7C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nJvbVNlcnZpY2VJZCkgewotICAgICAgICB0aGlzLmZyb21TZXJ2aWNlSWQgPSBmcm9tU2VydmljZUlkOworICAgICAgICBtRnJvbVNlcnZpY2VJZCA9IGZyb21TZXJ2aWNlSWQ7CiAgICAgfQogCiAgICAgLyoqCiAgICAgICogQHJldHVybiB0aGUgZnJvbVNlcnZpY2VJZAogICAgICAqLwogICAgIHB1YmxpYyBpbnQgZ2V0RnJvbVNlcnZpY2VJZCgpIHsKLSAgICAgICAgcmV0dXJuIGZyb21TZXJ2aWNlSWQ7CisgICAgICAgIHJldHVybiBtRnJvbVNlcnZpY2VJZDsKICAgICB9CiAKICAgICAvKioKICAgICAgKiBAcGFyYW0gdG9TZXJ2aWNlSWQgdGhlIHRvU2VydmljZUlkIHRvIHNldAogICAgICAqLwogICAgIHB1YmxpYyB2b2lkIHNldFRvU2VydmljZUlkKGludCB0b1NlcnZpY2VJZCkgewotICAgICAgICB0aGlzLnRvU2VydmljZUlkID0gdG9TZXJ2aWNlSWQ7CisgICAgICAgIG1Ub1NlcnZpY2VJZCA9IHRvU2VydmljZUlkOwogICAgIH0KIAogICAgIC8qKgogICAgICAqIEByZXR1cm4gdGhlIHRvU2VydmljZUlkCiAgICAgICovCiAgICAgcHVibGljIGludCBnZXRUb1NlcnZpY2VJZCgpIHsKLSAgICAgICAgcmV0dXJuIHRvU2VydmljZUlkOworICAgICAgICByZXR1cm4gbVRvU2VydmljZUlkOwogICAgIH0KIAogICAgIC8qKgogICAgICAqIEBwYXJhbSBmcm9tQ29kZVNjaGVtZSB0aGUgZnJvbUNvZGVTY2hlbWUgdG8gc2V0CiAgICAgICovCiAgICAgcHVibGljIHZvaWQgc2V0RnJvbUNvZGVTY2hlbWUoaW50IGZyb21Db2RlU2NoZW1lKSB7Ci0gICAgICAgIHRoaXMuZnJvbUNvZGVTY2hlbWUgPSBmcm9tQ29kZVNjaGVtZTsKKyAgICAgICAgbUZyb21Db2RlU2NoZW1lID0gZnJvbUNvZGVTY2hlbWU7CiAgICAgfQogCiAgICAgLyoqCiAgICAgICogQHJldHVybiB0aGUgZnJvbUNvZGVTY2hlbWUKICAgICAgKi8KICAgICBwdWJsaWMgaW50IGdldEZyb21Db2RlU2NoZW1lKCkgewotICAgICAgICByZXR1cm4gZnJvbUNvZGVTY2hlbWU7CisgICAgICAgIHJldHVybiBtRnJvbUNvZGVTY2hlbWU7CiAgICAgfQogCiAgICAgLyoqCiAgICAgICogQHBhcmFtIHRvQ29kZVNjaGVtZSB0aGUgdG9Db2RlU2NoZW1lIHRvIHNldAogICAgICAqLwogICAgIHB1YmxpYyB2b2lkIHNldFRvQ29kZVNjaGVtZShpbnQgdG9Db2RlU2NoZW1lKSB7Ci0gICAgICAgIHRoaXMudG9Db2RlU2NoZW1lID0gdG9Db2RlU2NoZW1lOworICAgICAgICBtVG9Db2RlU2NoZW1lID0gdG9Db2RlU2NoZW1lOwogICAgIH0KIAogICAgIC8qKgogICAgICAqIEByZXR1cm4gdGhlIHRvQ29kZVNjaGVtZQogICAgICAqLwogICAgIHB1YmxpYyBpbnQgZ2V0VG9Db2RlU2NoZW1lKCkgewotICAgICAgICByZXR1cm4gdG9Db2RlU2NoZW1lOworICAgICAgICByZXR1cm4gbVRvQ29kZVNjaGVtZTsKICAgICB9CiAKICAgICAvKioKICAgICAgKiBAcGFyYW0gc2VsZWN0ZWQgdGhlIHNlbGVjdGVkIHRvIHNldAogICAgICAqLwogICAgIHB1YmxpYyB2b2lkIHNldFNlbGVjdGVkKGJvb2xlYW4gc2VsZWN0ZWQpIHsKLSAgICAgICAgdGhpcy5zZWxlY3RlZCA9IHNlbGVjdGVkOworICAgICAgICBtU2VsZWN0ZWQgPSBzZWxlY3RlZDsKICAgICB9CiAKICAgICAvKioKICAgICAgKiBAcmV0dXJuIHRoZSBzZWxlY3RlZAogICAgICAqLwogICAgIHB1YmxpYyBib29sZWFuIGlzU2VsZWN0ZWQoKSB7Ci0gICAgICAgIHJldHVybiBzZWxlY3RlZDsKKyAgICAgIC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UNvZGluZ1NjaGVtZSA9IC0xOwotICAgICAgICAgICAgICAgIHBhZ2VJbmRleCA9IC0xOwotICAgICAgICAgICAgICAgIG5yT2ZQYWdlcyA9IC0xOworICAgICAgICAgICAgICAgIG1Gb3JtYXQgPSBGT1JNQVRfRVRXU19QUklNQVJZOworICAgICAgICAgICAgICAgIG1EYXRhQ29kaW5nU2NoZW1lID0gLTE7CisgICAgICAgICAgICAgICAgbVBhZ2VJbmRleCA9IC0xOworICAgICAgICAgICAgICAgIG1Ock9mUGFnZXMgPSAtMTsKICAgICAgICAgICAgICAgICBib29sZWFuIGVtZXJnZW5jeVVzZXJBbGVydCA9IChwZHVbNF0gJiAweDEpICE9IDA7CiAgICAgICAgICAgICAgICAgYm9vbGVhbiBhY3RpdmF0ZVBvcHVwID0gKHBkdVs1XSAmIDB4ODApICE9IDA7CiAgICAgICAgICAgICAgICAgaW50IHdhcm5pbmdUeXBlID0gKHBkdVs0XSAmIDB4ZmUpID4+PiAxOwpAQCAtMTI0LDggKzEyNCw4IEBACiAgICAgICAgICAgICAgICAgcmV0dXJuOyAgICAgLy8gc2tpcCB0aGUgRVRXUy9DTUFTIGluaXRpYWxpemF0aW9uIGNvZGUgZm9yIHJlZ3VsYXIgbm90aWZpY2F0aW9ucwogICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAvLyBHU00gcGR1cyBhcmUgbm8gbW9yZSB0aGFuIDg4IGJ5dGVzCi0gICAgICAgICAgICAgICAgZm9ybWF0ID0gRk9STUFUX0dTTTsKLSAgICAgICAgICAgICAgICBkYXRhQ29kaW5nU2NoZW1lID0gcGR1WzRdICYgMHhmZjsKKyAgICAgICAgICAgICAgICBtRm9ybWF0ID0gRk9STUFUX0dTTTsKKyAgICAgICAgICAgICAgICBtRGF0YUNvZGluZ1NjaGVtZSA9IHBkdVs0XSAmIDB4ZmY7CiAKICAgICAgICAgICAgICAgICAvLyBDaGVjayBmb3IgaW52YWxpZCBwYWdlIHBhcmFtZXRlcgogICAgICAgICAgICAgICAgIGludCBwYWdlSW5kZXggPSAocGR1WzVdICYgMHhmMCkgPj4+IDQ7CkBAIC0xMzYsMTMgKzEzNiwxMyBAQAogICAgICAgICAgICAgICAgICAgICBuck9mUGFnZXMgPSAxOwogICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgICAgIHRoaXMucGFnZUluZGV4ID0gcGFnZUluZGV4OwotICAgICAgICAgICAgICAgIHRoaXMubnJPZlBhZ2VzID0gbnJPZlBhZ2VzOworICAgICAgICAgICAgICAgIG1QYWdlSW5kZXggPSBwYWdlSW5kZXg7CisgICAgICAgICAgICAgICAgbU5yT2ZQYWdlcyA9IG5yT2ZQYWdlczsKICAgICAgICAgICAgIH0KICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIC8vIFVNVFMgcGR1cyBhcmUgYWx3YXlzIGF0IGxlYXN0IDkwIGJ5dGVzIHNpbmNlIHRoZSBwYXlsb2FkIGluY2x1ZGVzCiAgICAgICAgICAgICAvLyBhIG51bWJlci1vZi1wYWdlcyBvY3RldCBhbmQgYWxzbyBvbmUgbGVuZ3RoIG9jdGV0IHBlciBwYWdlCi0gICAgICAgICAgICBmb3JtYXQgPSBGT1JNQVRfVU1UUzsKKyAgICAgICAgICAgIG1Gb3JtYXQgPSBGT1JNQVRfVU1UUzsKIAogICAgICAgICAgICAgaW50IG1lc3NhZ2VUeXBlID0gcGR1WzBdOwogCkBAIC0xNTAsMTYgKzE1MCwxNiBAQAogICAgICAgICAgICAgICAgIHRocm93IG5ldyBJbGxlZ2FsQXJndW1lbnRFeGNlcHRpb24oIlVuc3VwcG9ydGVkIG1lc3NhZ2UgdHlwZSAiICsgbWVzc2FnZVR5cGUpOwogICAgICAgICAgICAgfQogCi0gICAgICAgICAgICBtZXNzYWdlSWRlbnRpZmllciA9ICgocGR1WzFdICYgMHhmZikgPDwgOCkgfCBwZHVbMl0gJiAweGZmOwotICAgICAgICAgICAgZ2VvZ3JhcGhpY2FsU2NvcG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NSw3ICsxMDYsNyBAQAogICAgICAqIGJ5IFRQX1BJRCBmaWVsZCBzZXQgdG8gdmFsdWUgMHg0MAogICAgICAqLwogICAgIHB1YmxpYyBib29sZWFuIGlzVHlwZVplcm8oKSB7Ci0gICAgICAgIHJldHVybiAocHJvdG9jb2xJZGVudGlmaWVyID09IDB4NDApOworICAgICAgICByZXR1cm4gKG1Qcm90b2NvbElkZW50aWZpZXIgPT0gMHg0MCk7CiAgICAgfQogCiAgICAgLyoqCkBAIC0xNjQsNyArMTU1LDcgQEAKICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgIFNtc01lc3NhZ2UgbXNnID0gbmV3IFNtc01lc3NhZ2UoKTsKIAotICAgICAgICAgICAgbXNnLmluZGV4T25JY2MgPSBpbmRleDsKKyAgICAgICAgICAgIG1zZy5tSW5kZXhPbkljYyA9IGluZGV4OwogCiAgICAgICAgICAgICAvLyBGaXJzdCBieXRlIGlzIHN0YXR1czogUkVDRUlWRURfUkVBRCwgUkVDRUlWRURfVU5SRUFELCBTVE9SRURfU0VOVCwKICAgICAgICAgICAgIC8vIG9yIFNUT1JFRF9VTlNFTlQKQEAgLTE3NCw3ICsxNjUsNyBAQAogICAgICAgICAgICAgICAgICAgICAgICAgIlNNUyBwYXJzaW5nIGZhaWxlZDogVHJ5aW5nIHRvIHBhcnNlIGEgZnJlZSByZWNvcmQiKTsKICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgbXNnLnN0YXR1c09uSWNjID0gZGF0YVswXSAmIDB4MDc7CisgICAgICAgICAgICAgICAgbXNnLm1TdGF0dXNPbkljYyA9IGRhdGFbMF0gJiAweDA3OwogICAgICAgICAgICAgfQogCiAgICAgICAgICAgICBpbnQgc2l6ZSA9IGRhdGEubGVuZ3RoIC0gMTsKQEAgLTM0NCw3ICszMzUsNyBAQAogICAgIC8qKgogICAgICAqIFBhY2tzIGhlYWRlciBhbmQgVU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tVXNlckRhdGE7CiAgICAgICAgIGludCBtVXNlckRhdGFTZXB0ZXRQYWRkaW5nOwotICAgICAgICBpbnQgbVVzZXJEYXRhU2l6ZTsKIAogICAgICAgICBQZHVQYXJzZXIoYnl0ZVtdIHBkdSkgewotICAgICAgICAgICAgdGhpcy5wZHUgPSBwZHU7Ci0gICAgICAgICAgICBjdXIgPSAwOworICAgICAgICAgICAgbVBkdSA9IHBkdTsKKyAgICAgICAgICAgIG1DdXIgPSAwOwogICAgICAgICAgICAgbVVzZXJEYXRhU2VwdGV0UGFkZGluZyA9IDA7CiAgICAgICAgIH0KIApAQCAtNTI4LDE0ICs1MTgsMTQgQEAKICAgICAgICAgICAgICAgICAvLyBTQyBhZGRyZXNzCiAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgcmV0ID0gUGhvbmVOdW1iZXJVdGlscwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5jYWxsZWRQYXJ0eUJDRFRvU3RyaW5nKHBkdSwgY3VyLCBsZW4pOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5jYWxsZWRQYXJ0eUJDRFRvU3RyaW5nKG1QZHUsIG1DdXIsIGxlbik7CiAgICAgICAgICAgICAgICAgfSBjYXRjaCAoUnVudGltZUV4Y2VwdGlvbiB0cikgewogICAgICAgICAgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgImludmFsaWQgU0MgYWRkcmVzczogIiwgdHIpOwogICAgICAgICAgICAgICAgICAgICByZXQgPSBudWxsOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgY3VyICs9IGxlbjsKKyAgICAgICAgICAgIG1DdXIgKz0gbGVuOwogCiAgICAgICAgICAgICByZXR1cm4gcmV0OwogICAgICAgICB9CkBAIC01NDQsNyArNTM0LDcgQEAKICAgICAgICAgICogcmV0dXJucyBub24tc2lnbi1leHRlbmRlZCBieXRlIHZhbHVlCiAgICAgICAgICAqLwogICAgICAgICBpbnQgZ2V0Qnl0ZSgpIHsKLSAgICAgICAgICAgIHJldHVybiBwZHVbY3VyKytdICYgMHhmZjsKKyAgICAgICAgICAgIHJldHVybiBtUGR1W21DdXIrK10gJiAweGZmOwogICAgICAgICB9CiAKICAgICAgICAgLyoqCkBAIC01NTgsMTcgKzU0OCwxNyBAQAogICAgICAgICAgICAgLy8gdGhlIG51bWJlciBmaWVsZCwgaS5lLiBleGNsdWRlcyBhbnkgc2VtaS1vY3RldCBjb250YWluaW5nIG9ubHkKICAgICAgICAgICAgIC8vIGZpbGwgYml0cy4iCiAgICAgICAgICAgICAvLyBUaGUgVE9BIGZpZWxkIGlzIG5vdCBpbmNsdWRlZCBhcyBwYXJ0IG9mIHRoaXMKLSAgICAgICAgICAgIGludCBhZGRyZXNzTGVuZ3RoID0gcGR1W2N1cl0gJiAweGZmOworICAgICAgICAgICAgaW50IGFkZHJlc3NMZW5ndGggPSBtUGR1W21DdXJdICYgMHhmZjsKICAgICAgICAgICAgIGludCBsZW5ndGhCeXRlcyA9IDIgKyAoYWRkcmVzc0xlbmd0aCArIDEpIC8gMjsKIAogICAgICAgICAgICAgdHJ5IHsKLSAgICAgICAgICAgICAgICByZXQgPSBuZXcgR3NtU21zQWRkcmVzcyhwZHUsIGN1ciwgbGVuZ3RoQnl0ZXMpOworICAgICAgICAgICAgICAgIHJldCA9IG5ldyBHc21TbXNBZGRyZXNzKG1QZHUsIG1DdXIsIGxlbmd0aEJ5dGVzKTsKICAgICAgICAgICAgIH0gY2F0Y2ggKFBhcnNlRXhjZXB0aW9uIGUpIHsKICAgICAgICAgICAgICAgICBSbG9nLmUoTE9HX1RBRywgZS5nZXRNZXNzYWdlKCkpOwogICAgICAgICAgICAgICAgIHJldCA9IG51bGw7CiAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgIGN1ciArPSBsZW5ndGhCeXRlczsKKyAgICAgICAgICAgIG1DdXIgKz0gbGVuZ3RoQnl0ZXM7CiAKICAgICAgICAgICAgIHJldHVybiByZXQ7CiAgICAgICAgIH0KQEAgLTU4MCwxOSArNTcwLDE5IEBACiAKICAgICAgICAgbG9uZyBnZXRTQ1RpbWVzdGFtcE1pbGxpcygpIHsKICAgICAgICAgICAgIC8vIFRQLVNlcnZpY2UtQ2VudHJlLVRpbWUtU3RhbXAKLSAgICAgICAgICAgIGludCB5ZWFyID0gSWNjVXRpbHMuZ3NtQmNkQnl0ZVRvSW50KHBkdVtjdXIrK10pOwotICAgICAgICAgICAgaW50IG1vbnRoID0gSWNjVXRpbHMuZ3NtQmNkQnl0ZVRvSW50KHBkdVtjdXIrK10pOwotICAgICAgICAgICAgaW50IGRheSA9IEljY1V0aWxzLmdzbUJjZEJ5dGVUb0ludChwZHVbY3VyKytdKTsKLSAgICAgICAgICAgIGludCBob3VyID0gSWNjVXRpbHMuZ3NtQmNkQnl0ZVRvSW50KHBkdVtjdXIrK10pOwotICAgICAgICAgICAgaW50IG1pbnV0ZSA9IEljY1V0aWxzLmdzbUJjZEJ5dGVUb0ludChwZHVbY3VyKytdKTsKLSAgICAgICAgICAgIGludCBzZWNvbmQgPSBJY2NVdGlscy5nc21CY2RCeXRlVG9JbnQocGR1W2N1cisrXSk7CisgICAgICAgICAgICBpbnQgeWVhciA9IEljY1V0aWxzLmdzbUJjZEJ5dGVUb0ludChtUGR1W21DdXIrK10pOworICAgICAgICAgICAgaW50IG1vbnRoID0gSWNjVXRpbHMuZ3NtQmNkQnl0ZVRvSW50KG1QZHVbbUN1cisrXSk7CisgICAgICAgICAgICBpbnQgZGF5ID0gSWNjVXRpbHMuZ3NtQmNkQnl0ZVRvSW50KG1QZHVbbUN1cisrXSk7CisgICAgICAgICAgICBpbnQgaG91ciA9IEljY1V0aWxzLmdzbUJjZEJ5dGVUb0ludChtUGR1W21DdXIrK10pOworICAgICAgICAgICAgaW50IG1pbnV0ZSA9IEljY1V0aWxzLmdzbUJjZEJ5dGVUb0ludChtUGR1W21DdXIrK10pOworICAgICAgICAgICAgaW50IHNlY29uZ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0aCA9IG1QZHVbb2Zmc2V0KytdICYgMHhmZjsKICAgICAgICAgICAgIGludCBoZWFkZXJTZXB0ZXRzID0gMDsKICAgICAgICAgICAgIGludCB1c2VyRGF0YUhlYWRlckxlbmd0aCA9IDA7CiAKICAgICAgICAgICAgIGlmIChoYXNVc2VyRGF0YUhlYWRlcikgewotICAgICAgICAgICAgICAgIHVzZXJEYXRhSGVhZGVyTGVuZ3RoID0gcGR1W29mZnNldCsrXSAmIDB4ZmY7CisgICAgICAgICAgICAgICAgdXNlckRhdGFIZWFkZXJMZW5ndGggPSBtUGR1W29mZnNldCsrXSAmIDB4ZmY7CiAKICAgICAgICAgICAgICAgICBieXRlW10gdWRoID0gbmV3IGJ5dGVbdXNlckRhdGFIZWFkZXJMZW5ndGhdOwotICAgICAgICAgICAgICAgIFN5c3RlbS5hcnJheWNvcHkocGR1LCBvZmZzZXQsIHVkaCwgMCwgdXNlckRhdGFIZWFkZXJMZW5ndGgpOwotICAgICAgICAgICAgICAgIHVzZXJEYXRhSGVhZGVyID0gU21zSGVhZGVyLmZyb21CeXRlQXJyYXkodWRoKTsKKyAgICAgICAgICAgICAgICBTeXN0ZW0uYXJyYXljb3B5KG1QZHUsIG9mZnNldCwgdWRoLCAwLCB1c2VyRGF0YUhlYWRlckxlbmd0aCk7CisgICAgICAgICAgICAgICAgbVVzZXJEYXRhSGVhZGVyID0gU21zSGVhZGVyLmZyb21CeXRlQXJyYXkodWRoKTsKICAgICAgICAgICAgICAgICBvZmZzZXQgKz0gdXNlckRhdGFIZWFkZXJMZW5ndGg7CiAKICAgICAgICAgICAgICAgICBpbnQgaGVhZGVyQml0cyA9ICh1c2VyRGF0YUhlYWRlckxlbmd0aCArIDEpICogODsKQEAgLTY0OSw3ICs2MzksNyBAQAogICAgICAgICAgICAgICAgICAqIHRoZSBwZHUgbWludXMgdGhlIHVzZXIgZGF0YSBoZWFkZXIsIHNpbmNlIHVzZXJEYXRhTGVuZ3RoIG1lYW5zCiAgICAgICAgICAgICAgICAgICogdGhlIG51bWJlciBvZiB1bmNvbXByZXNzZWQgc2VwdGV0cy4KICAgICAgICAgICAgICAgICAgKi8KLSAgICAgICAgICAgICAgICBidWZmZXJMZW4gPSBwZHUubGVuZ3RoIC0gb2Zmc2V0OworICAgICAgICAgICAgICAgIGJ1ZmZlckxlbiA9IG1QZHUubGVuZ3RoIC0gb2Zmc2V0OwogICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAvKgogICAgICAgICAgICAgICAgICAqIHVzZXJEYXRhTGVuZ3RoIGlzIHRoZSBjb3VudCBvZiBvY3RldHMsIHNvIGp1c3Qgc3VidHJhY3QgdGhlCkBAIC02NjEsOSArNjUxLDkgQEAKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgIHVzZXJEYXRhID0gbmV3IGJ5dGVbYnVmZmVyTGVuXTsKLSAgICAgICAgICAgIFN5c3RlbS5hcnJheWNvcHkocGR1LCBvZmZzZXQsIHVzZXJEYXRhLCAwLCB1c2VyRGF0YS5sZW5ndGgpOwotICAgICAgICAgICAgY3VyID0gb2Zmc2V0OworICAgICAgICAgICAgbVVzZXJEYXRhID0gbmV3IGJ5dGVbYnVmZmVyTGVuXTsKKyAgICAgICAgICAgIFN5c3RlbS5hcnJheWNvcHkobVBkdSwgb2Zmc2V0LCBtVXNlckRhdGEsIDAsIG1Vc2VyRGF0YS5sZW5ndGgpOworICAgICAgICAgICAgbUN1ciA9IG9mZnNldDsKIAogICAgICAgICAgICAgaWYgKGRhdGFJblNlcHRldHMpIHsKICAgICAgICAgICAgICAgICAvLyBSZXR1cm4gdGhlIG51bWJlciBvZiBzZXB0ZXRzCkBAIC02NzIsNyArNjYyLDcgQEAKICAgICAgICAgICAgICAgICByZXR1cm4gY291bnQgPCAwID8gMCA6IGNvdW50OwogICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAvLyBSZXR1cm4gdGhlIG51bWJlciBvZiBvY3RldHMKLSAgICAgICAgICAgICAgICByZXR1cm4gdXNlckRhdGEubGVuZ3RoOworICAgICAgICAgICAgICAgIHJldHVybiBtVXNlckRhdGEubGVuZ3RoOwogICAgICAgICAgICAgfQogICAgICAgICB9CiAKQEAgLTY4MiwxOCArNjcyLDcgQEAKICAgICAgICAgICogQHJldHVybiB0aGUgdXNlciBkYXRhIHBheWxvYWQsIG5vdCBpbmNsdWRpbmcgdGhlIGhlYWRlcnMKICAgICAgICAgICovCiAgICAgICAgIGJ5dGVbXSBnZXRVc2VyRGF0YSgpIHsKLSAgICAgICAgICAgIHJldHVybiB1c2VyRGF0YTsKLSAgICAgICAgfQotCi0gICAgICAgIC8qKgotICAgICAgICAgKiBSZXR1cm5zIHRoZSBudW1iZXIgb2YgcGFkZGluZyBiaXRzIGF0IHRoZSBiZWdpbm5pbmcgb2YgdGhlIHVzZXIgZGF0YQotICAgICAgICAgKiBhcnJheSBiZWZvcmUgdGhlIHN0YXJ0IG9mIHRoZSBzZXB0ZXRzLgotICAgICAgICAgKgotICAgICAgICAgKiBAcmV0dXJuIHRoZSBudW1iZXIgb2YgcGFkZGluZyBiaXRzIGF0IHRoZSBiZWdpbm5pbmcgb2YgdGhlIHVzZXIgZGF0YQotICAgICAgICAgKiBhcnJheSBiZWZvcmUgdGhlIHN0YXJ0IG9mIHRoZSBzZXB0ZXRzCi0gICAgICAgICAqLwotICAgICAgICBpbnQgZ2V0VXNlckRhdGFTZXB0ZXRQYWRkaW5nKCkgewotICAgICAgICAgICAgcmV0dXJuIG1Vc2VyRGF0YVNlcHRldFBhZGRpbmc7CisgICAgICAgICAgICByZXR1cm4gbVVzZXJEYXRhOwogICAgICAgICB9CiAKICAgICAgICAgLyoqCkBAIC03MDIsNyArNjgxLDcgQEAKICAgICAgICAgICoge0BoaWRlfQogICAgICAgICAgKi8KICAgICAgICAgU21zSGVhZGVyIGdldFVzZXJEYXRhSGVhZGVyKCkgewotICAgICAgICAgICAgcmV0dXJuIHVzZXJEYXRhSGVhZGVyOworICAgICAgICAgICAgcmV0dXJuIG1Vc2VyRGF0YUhlYWRlcjsKICAgICAgICAgfQogCiAgICAgICAgIC8qKgpAQCAtNzE2LDEwICs2OTUsMTAgQEAKICAgICAgICAgICAgICAgICBpbnQgbGFuZ3VhZ2VTaGlmdFRhYmxlKSB7CiAgICAgICAgICAgICBTdHJpbmcgcmV0OwogCi0gICAgICAgICAgICByZXQgPSBHc21BbHBoYWJldC5nc203Qml0UGFja2VkVG9TdHJpbmcocGR1LCBjdXIsIHNlcHRldENvdW50LAorICAgICAgICAgICAgcmV0ID0gR3NtQWxwaGFiZXQuZ3NtN0JpdFBhY2tlZFRvU3RyaW5nKG1QZHUsIG1DdXIsIHNlcHRldENvdW50LAogICAgICAgICAgICAgICAgICAgICBtVXNlckRhdGFTZXB0ZXRQYWRkaW5nLCBsYW5ndWFnZVRhYmxlLCBsYW5ndWFnZVNoaWZ0VGFibGUpOwogCi0gICAgICAgICAgICBjdXIgKz0gKHNlcHRldENvdW50ICogNykgLyA4OworICAgICAgICAgICAgbUN1ciArPSAoc2VwdGV0Q291bnQgKiA3KSAvIDg7CiAKICAgICAgICAgICAgIHJldHVybiByZXQ7CiAgICAgICAgIH0KQEAgLTczNSwxMyArNzE0LDEzIEBACiAgICAgICAgICAgICBTdHJpbmcgcmV0OwogCiAgICAgICAgICAgICB0cnkgewotICAgICAgICAgICAgICAgIHJldCA9IG5ldyBTdHJpbmcocGR1LCBjdXIsIGJ5dGVDb3VudCwgInV0Zi0xNiIpOworICAgICAgICAgICAgICAgIHJldCA9IG5ldyBTdHJpbmcobVBkdSwgbUN1ciwgYnl0ZUNvdW50LCAidXRmLTE2Iik7CiAgICAgICAgICAgICB9IGNhdGNoIChVbnN1cHBvcnRlZEVuY29kaW5nRXhjZXB0aW9uIGV4KSB7CiAgICAgICAgICAgICAgICAgcmV0ID0gIiI7CiAgICAgICAgICAgICAgICAgUmxvZy5lKExPR19UQUcsICJpbXBsYXVzaWJsZSBVbnN1cHBvcnRlZEVuY29kaW5nRXhjZXB0aW9uIiwgZXgpOwogICAgICAgICAgICAgfQogCi0gICAgICAgICAgICBjdXIgKz0gYnl0ZUNvdW50OworICAgICAgICAgICAgbUN1ciArPSBieXRlQ291bnQ7CiAgICAgICAgICAgICByZXR1cm4gcmV0OwogICAgICAgICB9CiAKQEAgLTc1NiwxOCArNzM1LDE4IEBACiAgICAgICAgICAgICBTdHJpbmcgcmV0OwogCiAgICAgICAgICAgICB0cnkgewotICAgICAgICAgICAgICAgIHJldCA9IG5ldyBTdHJpbmcocGR1LCBjdXIsIGJ5dGVDb3VudCwgIktTQzU2MDEiKTsKKyAgICAgICAgICAgICAgICByZXQgPSBuZXcgU3RyaW5nKG1QZHUsIG1DdXIsIGJ5dGVDb3VudCwgIktTQzU2MDEiKTsKICAgICAgICAgICAgIH0gY2F0Y2ggKFVuc3VwcG9ydGVkRW5jb2RpbmdFeGNlcHRpb24gZXgpIHsKICAgICAgICAgICAgICAgICByZXQgPSAiIjsKICAgICAgICAgICAgICAgICBSbG9nLmUoTE9HX1RBRywgImltcGxhdXNpYmxlIFVuc3VwcG9ydGVkRW5jb2RpbmdFeGNlcHRpb24iLCBleCk7CiAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgIGN1ciArPSBieXRlQ291bnQ7CisgICAgICAgICAgICBtQ3VyICs9IGJ5dGVDb3VudDsKICAgICAgICAgICAgIHJldHVybiByZXQ7CiAgICAgICAgIH0KIAogICAgICAgICBib29sZWFuIG1vcmVEYXRhUHJlc2VudCgpIHsKLSAgICAgICAgICAgIHJldHVybiAocGR1Lmxlbmd0aCA+IGN1cik7CisgICAgICAgICAgICByZXR1cm4gKG1QZHUubGVuZ3RoID4gbUN1cik7CiAgICAgICAgIH0KICAgICB9CiAKQEAgLTgwMiw3ICs3ODEsNyBAQAogICAgIC8qKiB7QGluaGVyaXREb2N9ICovCiAgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGludCBnZXRQcm90b2NvbElkZW50aWZpZXIoKSB7Ci0gICAgICAgIHJldHVybiBwcm90b2NvbElkZW50aWZpZXI7CisgICAgICAgIHJldHVybiBtUHJvdG9jb2xJZGVudGlmaWVyOwogICAgIH0KIAogICAgIC8qKgpAQCAtODEwLDUwICs3ODksNTAgQEAKICAgICAgKiBAcmV0dXJuIHRoZSBUUC1EQ1MgZmllbGQgb2YgdGhlIFNNUyBoZWFkZXIKICAgICAgKi8KICAgICBpbnQgZ2V0RGF0YUNvZGluZ1NjaGVtZSgpIHsKLSAgICAgICAgcmV0dXJuIGRhdGFDb2RpbmdTY2hlbWU7CisgICAgICAgIHJldHVybiBtRGF0YUNvZGluZ1NjaGVtZTsKICAgICB9CiAKICAgICAvKioge0Bpbmhlcml0RG9jfSAqLwogICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBib29sZWFuIGlzUmVwbGFjZSgpIHsKLSAgICAgICAgcmV0dXJuIChwcm90b2NvbElkZW50aWZpZXIgJiAweGMwKSA9PSAweDQwCi0gICAgICAgICAgICAgICAgJiYgKHByb3RvY29sSWRlbnRpZmllciAmIDB4M2YpID4gMAotICAgICAgICAgICAgICAgICYmIChwcm90b2NvbElkZW50aWZpZXIgJiAweDNmKSA8IDg7CisgICAgICAgIHJldHVybiAobVByb3RvY29sSWRlbnRpZmllciAmIDB4YzApID09IDB4NDAKKyAgICAgICAgICAgICAgICAmJiAobVByb3RvY29sSWRlbnRpZmllciAmIDB4M2YpID4gMAorICAgICAgICAgICAgICAgICYmIChtUHJvdG9jb2xJZGVudGlmaWVyICYgMHgzZikgPCA4OwogICAgIH0KIAogICAgIC8qKiB7QGluaGVyaXREb2N9ICovCiAgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGJvb2xlYW4gaXNDcGhzTXdpTWVzc2FnZSgpIHsKLSAgICAgICAgcmV0dXJuICgoR3NtU21zQWRkcmVzcykgb3JpZ2luYXRpbmdBZGRyZXNzKS5pc0NwaHNWb2ljZU1lc3NhZ2VDbGVhcigpCi0gICAgICAgICAgICAg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bU13aVNlbnNlKSB7CiAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgfQogCi0gICAgICAgIHJldHVybiBvcmlnaW5hdGluZ0FkZHJlc3MgIT0gbnVsbAotICAgICAgICAgICAgICAgICYmICgoR3NtU21zQWRkcmVzcykgb3JpZ2luYXRpbmdBZGRyZXNzKS5pc0NwaHNWb2ljZU1lc3NhZ2VTZXQoKTsKKyAgICAgICAgcmV0dXJuIG1PcmlnaW5hdGluZ0FkZHJlc3MgIT0gbnVsbAorICAgICAgICAgICAgICAgICYmICgoR3NtU21zQWRkcmVzcykgbU9yaWdpbmF0aW5nQWRkcmVzcykuaXNDcGhzVm9pY2VNZXNzYWdlU2V0KCk7CiAgICAgfQogCiAgICAgLyoqIHtAaW5oZXJpdERvY30gKi8KICAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgYm9vbGVhbiBpc013aURvbnRTdG9yZSgpIHsKLSAgICAgICAgaWYgKGlzTXdpICYmIG13aURvbnRTdG9yZSkgeworICAgICAgICBpZiAobUlzTXdpICYmIG1Nd2lEb250U3RvcmUpIHsKICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICB9CiAKQEAgLTg3MiwxOSArODUxLDE5IEBACiAgICAgLyoqIHtAaW5oZXJpdERvY30gKi8KICAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgaW50IGdldFN0YXR1cygpIHsKLSAgICAgICAgcmV0dXJuIHN0YXR1czsKKyAgICAgICAgcmV0dXJuIG1TdGF0dXM7CiAgICAgfQogCiAgICAgLyoqIHtAaW5oZXJpdERvY30gKi8KICAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgYm9vbGVhbiBpc1N0YXR1c1JlcG9ydE1lc3NhZ2UoKSB7Ci0gICAgICAgIHJldHVybiBpc1N0YXR1c1JlcG9ydE1lc3NhZ2U7CisgICAgICAgIHJldHVybiBtSXNTdGF0dXNSZXBvcnRNZXNzYWdlOwogICAgIH0KIAogICAgIC8qKiB7QGluaGVyaXREb2N9ICovCiAgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGJvb2xlYW4gaXNSZXBseVBhdGhQcmVzZW50KCkgewotICAgICAgICByZXR1cm4gcmVwbHlQYXRoUHJlc2VudDsKKyAgICAgICAgcmV0dXJuIG1SZXBseVBhdGhQcmVzZW50OwogICAgIH0KIAogICAgIC8qKgpAQCAtOTAyLDEwICs4ODEsMTAgQEAKIAogICAgICAgICBQZHVQYXJzZXIgcCA9IG5ldyBQZHVQYXJzZXIocGR1KTsKIAotICAgICAgICBzY0FkZHJlc3MgPSBwLmdldFNDQWRkcmVzcygpOworICAgICAgICBtU2NBZGRyZXNzID0gcC5nZXRTQ0FkZHJlc3MoKTsKIAotICAgICAgICBpZiAoc2NBZGRyZXNzICE9IG51bGwpIHsKLSAgICAgICAgICAgIGlmIChmYWxzZSkgUmxvZy5kKExPR19UQUcsICJTTVMgU0MgYWRkcmVzczogIiArIHNjQWRkcmVzcyk7CisgICAgICAgIGlmIChtU2NBZGRyZXNzICE9IG51bGwpIHsKKyAgICAgICAgICAgIGlmIChWREJHKSBSbG9nLmQoTE9HX1RBRywgIlNNUyBTQyBhZGRyZXNzOiAiICsgbVNjQWRkcmVzcyk7CiAgICAgICAgIH0KIAogICAgICAgICAvLyBUT0RPKG1rZikgc3VwcG9ydCByZXBseSBwYXRoLCB1c2VyIGRhdGEgaGVhZGVyIGluZGljYXRvcgpAQCAtOTE0LDggKzg5Myw4IEBACiAgICAgICAgIC8vIDkuMi4zCiAgICAgICAgIGludCBmaXJzdEJ5dGUgPSBwLmdldEJ5dGUoKTsKIAotICAgICAgICBtdGkgPSBmaXJzdEJ5dGUgJiAweDM7Ci0gICAgICAgIHN3aXRjaCAobXRpKSB7CisgICAgICAgIG1NdGkgPSBmaXJzdEJ5dGUgJiAweDM7CisgICAgICAgIHN3aXRjaCAobU10aSkgewogICAgICAgICAvLyBUUC1NZXNzYWdlLVR5cGUtSW5kaWNhdG9yCiAgICAgICAgIC8v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cC5nZXRTQ1RpbWVzdGFtcE1pbGxpcygpOworICAgICAgICBwLmdldFNDVGltZXN0YW1wTWlsbGlzKCk7CiAgICAgICAgIC8vIFRQLVN0YXR1cwotICAgICAgICBzdGF0dXMgPSBwLmdldEJ5dGUoKTsKKyAgICAgICAgbVN0YXR1cyA9IHAuZ2V0Qnl0ZSgpOwogCiAgICAgICAgIC8vIFRoZSBmb2xsb3dpbmcgYXJlIG9wdGlvbmFsIGZpZWxkcyB0aGF0IG1heSBvciBtYXkgbm90IGJlIHByZXNlbnQuCiAgICAgICAgIGlmIChwLm1vcmVEYXRhUHJlc2VudCgpKSB7CkBAIC05NzMsMTEgKzk0OSwxMSBAQAogICAgICAgICAgICAgaWYgKChleHRyYVBhcmFtcyAmIDB4NzgpID09IDApIHsKICAgICAgICAgICAgICAgICAvLyBUUC1Qcm90b2NvbC1JZGVudGlmaWVyCiAgICAgICAgICAgICAgICAgaWYgKChleHRyYVBhcmFtcyAmIDB4MDEpICE9IDApIHsKLSAgICAgICAgICAgICAgICAgICAgcHJvdG9jb2xJZGVudGlmaWVyID0gcC5nZXRCeXRlKCk7CisgICAgICAgICAgICAgICAgICAgIG1Qcm90b2NvbElkZW50aWZpZXIgPSBwLmdldEJ5dGUoKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgLy8gVFAtRGF0YS1Db2RpbmctU2NoZW1lCiAgICAgICAgICAgICAgICAgaWYgKChleHRyYVBhcmFtcyAmIDB4MDIpICE9IDApIHsKLSAgICAgICAgICAgICAgICAgICAgZGF0YUNvZGluZ1NjaGVtZSA9IHAuZ2V0Qnl0ZSgpOworICAgICAgICAgICAgICAgICAgICBtRGF0YUNvZGluZ1NjaGVtZSA9IHAuZ2V0Qnl0ZSgpOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAvLyBUUC1Vc2VyLURhdGEtTGVuZ3RoIChpbXBsaWVzIGV4aXN0ZW5jZSBvZiBUUC1Vc2VyLURhdGEpCiAgICAgICAgICAgICAgICAgaWYgKChleHRyYVBhcmFtcyAmIDB4MDQpICE9IDApIHsKQEAgLTk4OSwzMSArOTY1LDMxIEBACiAgICAgfQogCiAgICAgcHJpdmF0ZSB2b2lkIHBhcnNlU21zRGVsaXZlcihQZHVQYXJzZXIgcCwgaW50IGZpcnN0Qnl0ZSkgewotICAgICAgICByZXBseVBhdGhQcmVzZW50ID0gKGZpcnN0Qnl0ZSAmIDB4ODApID09IDB4ODA7CisgICAgICAgIG1SZXBseVBhdGhQcmVzZW50ID0gKGZpcnN0Qnl0ZSAmIDB4ODApID09IDB4ODA7CiAKLSAgICAgICAgb3JpZ2luYXRpbmdBZGRyZXNzID0gcC5nZXRBZGRyZXNzKCk7CisgICAgICAgIG1PcmlnaW5hdGluZ0FkZHJlc3MgPSBwLmdldEFkZHJlc3MoKTsKIAotICAgICAgICBpZiAob3JpZ2luYXRpbmdBZGRyZXNzICE9IG51bGwpIHsKLSAgICAgICAgICAgIGlmIChmYWxzZSkgUmxvZy52KExPR19UQUcsICJTTVMgb3JpZ2luYXRpbmcgYWRkcmVzczogIgotICAgICAgICAgICAgICAgICAgICArIG9yaWdpbmF0aW5nQWRkcmVzcy5hZGRyZXNzKTsKKyAgICAgICAgaWYgKG1PcmlnaW5hdGluZ0FkZHJlc3MgIT0gbnVsbCkgeworICAgICAgICAgICAgaWYgKFZEQkcpIFJsb2cudihMT0dfVEFHLCAiU01TIG9yaWdpbmF0aW5nIGFkZHJlc3M6ICIKKyAgICAgICAgICAgICAgICAgICAgKyBtT3JpZ2luYXRpbmdBZGRyZXNzLmFkZHJlc3MpOwogICAgICAgICB9CiAKICAgICAgICAgLy8gVFAtUHJvdG9jb2wtSWRlbnRpZmllciAoVFAtUElEKQogICAgICAgICAvLyBUUyAyMy4wNDAgOS4yLjMuOQotICAgICAgICBwcm90b2NvbElkZW50aWZpZXIgPSBwLmdldEJ5dGUoKTsKKyAgICAgICAgbVByb3RvY29sSWRlbnRpZmllciA9IHAuZ2V0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hlbWUgJiAweDQwKSk7Ci0gICAgICAgICAgICB1c2VyRGF0YUNvbXByZXNzZWQgPSAoMCAhPSAoZGF0YUNvZGluZ1NjaGVtZSAmIDB4MjApKTsKLSAgICAgICAgICAgIGhhc01lc3NhZ2VDbGFzcyA9ICgwICE9IChkYXRhQ29kaW5nU2NoZW1lICYgMHgxMCkpOworICAgICAgICBpZiAoKG1EYXRhQ29kaW5nU2NoZW1lICYgMHg4MCkgPT0gMCkgeworICAgICAgICAgICAgdXNlckRhdGFDb21wcmVzc2VkID0gKDAgIT0gKG1EYXRhQ29kaW5nU2NoZW1lICYgMHgyMCkpOworICAgICAgICAgICAgaGFzTWVzc2FnZUNsYXNzID0gKDAgIT0gKG1EYXRhQ29kaW5nU2NoZW1lICYgMHgxMCkpOwogCiAgICAgICAgICAgICBpZiAodXNlckRhdGFDb21wcmVzc2VkKSB7CiAgICAgICAgICAgICAgICAgUmxvZy53KExPR19UQUcsICI0IC0gVW5zdXBwb3J0ZWQgU01TIGRhdGEgY29kaW5nIHNjaGVtZSAiCi0gICAgICAgICAgICAgICAgICAgICAgICArICIoY29tcHJlc3Npb24pICIgKyAoZGF0YUNvZGluZ1NjaGVtZSAmIDB4ZmYpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICsgIihjb21wcmVzc2lvbikgIiArIChtRGF0YUNvZGluZ1NjaGVtZSAmIDB4ZmYpKTsKICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgc3dpdGNoICgoZGF0YUNvZGluZ1NjaGVtZSA+PiAyKSAmIDB4MykgeworICAgICAgICAgICAgICAgIHN3aXRjaCAoKG1EYXRhQ29kaW5nU2NoZW1lID4+IDIpICYgMHgzKSB7CiAgICAgICAgICAgICAgICAgY2FzZSAwOiAvLyBHU00gNyBiaXQgZGVmYXVsdCBhbHBoYWJldAogICAgICAgICAgICAgICAgICAgICBlbmNvZGluZ1R5cGUgPSBFTkNPRElOR183QklUOwogICAgICAgICAgICAgICAgICAgICBicmVhazsKQEAgLTExMTUsMTA1ICsxMDg4LDEwNCBAQAogICAgICAgICAgICAgICAgIGNhc2UgMTogLy8gOCBiaXQgZGF0YQogICAgICAgICAgICAgICAgIGNhc2UgMzogLy8gcmVzZXJ2ZWQKICAgICAgICAgICAgICAgICAgICAgUmxvZy53KExPR19UQUcsICIxIC0gVW5zdXBwb3J0ZWQgU01TIGRhdGEgY29kaW5nIHNjaGVtZSAiCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgKyAoZGF0YUNvZGluZ1NjaGVtZSAmIDB4ZmYpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICArIChtRGF0YUNvZGluZ1NjaGVtZSAmIDB4ZmYpKTsKICAgICAgICAgICAgICAgICAgICAgZW5jb2RpbmdUeXBlID0gRU5DT0RJTkdfOEJJVDsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQotICAgICAgICB9IGVsc2UgaWYgKChkYXRhQ29kaW5nU2NoZW1lICYgMHhmMCkgPT0gMHhmMCkgewotICAgICAgICAgICAgYXV0b21hdGljRGVsZXRpb24gPSBmYWxzZTsKKyAgICAgICAgfSBlbHNlIGlmICgobURhdGFDb2RpbmdTY2hlbWUgJiAweGYwKSA9PSAweGYwKSB7CiAgICAgICAgICAgICBoYXNNZXNzYWdlQ2xhc3MgPSB0cnVlOwogICAgICAgICAgICAgdXNlckRhdGFDb21wcmVzc2VkID0gZmFsc2U7CiAKLSAgICAgICAgICAgIGlmICgwID09IChkYXRhQ29kaW5nU2NoZW1lICYgMHgwNCkpIHsKKyAgICAgICAgICAgIGlmICgwID09IChtRGF0YUNvZGluZ1NjaGVtZSAmIDB4MDQpKSB7CiAgICAgICAgICAgICAgICAgLy8gR1NNIDcgYml0IGRlZmF1bHQgYWxwaGFiZXQKICAgICAgICAgICAgICAgICBlbmNvZGluZ1R5cGUgPSBFTkNPRElOR183QklUOwogICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAvLyA4IGJpdCBkYXRhCiAgICAgICAgICAgICAgICAgZW5jb2RpbmdUeXBlID0gRU5DT0RJTkdfOEJJVDsKICAgICAgICAgICAgIH0KLSAgICAgICAgfSBlbHNlIGlmICgoZGF0YUNvZGluZ1NjaGVtZSAmIDB4RjApID09IDB4QzAKLSAgICAgICAgICAgICAgICB8fCAoZGF0YUNvZGluZ1NjaGVtZSAmIDB4RjApID09IDB4RDAKLSAgICAgICAgICAgICAgICB8fCAoZGF0YUNvZGluZ1NjaGVtZSAmIDB4RjApID09IDB4RTApIHsKKyAgICAgICAgfSBlbHNlIGlmICgobURhdGFDb2RpbmdTY2hlbWUgJiAweEYwKSA9PSAweEMwCisgICAgICAgICAgICAgICAgfHwgKG1EYXRhQ29kaW5nU2NoZW1lICYgMHhGMCkgPT0gMHhEMAorICAgICAgICAgICAgICAgIHx8IChtRGF0YUNvZGluZ1NjaGVtZSAmIDB4RjApID09IDB4RTApIHsKICAgICAgICAgICAgIC8vIDNHUFAgVFMgMjMuMDM4IFY3LjAuMCAoMjAwNi0wMykgc2VjdGlvbiA0CiAKICAgICAgICAgICAgIC8vIDB4QzAgPT0gNyBiaXQsIGRvbid0IHN0b3JlCiAgICAgICAgICAgICAvLyAweEQwID09IDcgYml0LCBzdG9yZQogICAgICAgICAgICAgLy8gMHhFMCA9PSBVQ1MtMiwgc3RvcmUKIAotICAgICAgICAgICAgaWYgKChkYXRhQ29kaW5nU2NoZW1lICYgMHhGMCkgPT0gMHhFMCkgeworICAgICAgICAgICAgaWYgKChtRGF0YUNvZGluZ1NjaGVtZSAmIDB4RjApID09IDB4RTApIHsKICAgICAgICAgICAgICAgICBlbmNvZGluZ1R5cGUgPSBFTkNPRElOR18xNkJJVDsKICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgZW5jb2RpbmdUeXBlID0gRU5DT0RJTkdfN0JJVDsKICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgdXNlckRhdGFDb21wcmVzc2VkID0gZmFsc2U7Ci0gICAgICAgICAgICBib29sZWFuIGFjdGl2ZSA9ICgoZGF0YUNvZGluZ1NjaGVtZSAmIDB4MDgpID09IDB4MDgpOworICAgICAgICAgICAgYm9vbGVhbiBhY3RpdmUgPSAoKG1EYXRhQ29kaW5nU2NoZW1lICYgMHgwOCkgPT0gMHgwOCk7CiAKICAgICAgICAgICAgIC8vIGJpdCAweDA0IHJlc2VydmVkCiAKLSAgICAgICAgICAgIGlmICgoZGF0YUNvZGluZ1NjaGVtZSAmIDB4MDMpID09IDB4MDApIHsKLSAgICAgICAgICAgICAgICBpc013aSA9IHRydWU7Ci0gICAgICAgICAgICAgICAgbXdpU2Vuc2UgPSBhY3RpdmU7Ci0gICAgICAgICAgICAgICAgbXdpRG9udFN0b3JlID0gKChkYXRhQ29kaW5nU2NoZW1lICYgMHhGMCkgPT0gMHhDMCk7CisgICAgICAgICAgICBpZiAoKG1EYXRhQ29kaW5nU2NoZW1lICYgMHgwMykgPT0gMHgwMCkgeworICAgICAgICAgICAgICAgIG1Jc013aSA9IHRydWU7CisgICAgICAgICAgICAgICAgbU13aVNlbnNlID0gYWN0aXZlOworICAgICAgICAgICAgICAgIG1Nd2lEb250U3RvcmUgPSAoKG1EYXRhQ29kaW5nU2NoZW1lICYgMHhGMCkgPT0gMHhDMCk7CiAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgIGlzTXdpID0gZmFsc2U7CisgICAgICAgICAgICAgICAgbUlzTXdpID0gZmFsc2U7CiAKICAgICAgICAgICAgICAgICBSbG9nLncoTE9HX1RBRywgIk1XSSBmb3IgZmF4LCBlbWFpbCwgb3Igb3RoZXIgIgotICAgICAgICAgICAgICAgICAgICAgICAgKyAoZGF0YUNvZGluZ1NjaGVtZSAmIDB4ZmYpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICsgKG1EYXRhQ29kaW5nU2NoZW1lICYgMHhmZikpOwogICAgICAgICAgICAgfQotICAgICAgICB9IGVsc2UgaWYgKChkYXRhQ29kaW5nU2NoZW1lICYgMHhDMCkgPT0gMHg4MCkgeworICAgICAgICB9IGVsc2UgaWYgKChtRGF0YUNvZGluZ1NjaGVtZSAmIDB4QzApID09IDB4ODApIHsKICAgICAgICAgICAgIC8vIDNHUFAgVFMgMjMuMDM4IFY3LjAuMCAoMjAwNi0wMykgc2VjdGlvbiA0CiAgICAgICAgICAgICAvLyAweDgwLi4weEJGID09IFJlc2VydmVkIGNvZGluZyBncm91cHMKLSAgICAgICAgICAgIGlmIChkYXRhQ29kaW5nU2NoZW1lID09IDB4ODQpIHsKKyAgICAgICAgICAgIGlmIChtRGF0YUNvZGluZ1NjaGVtZSA9PSAweDg0KSB7CiAgICAgICAgICAgICAgICAgLy8gVGhpcyB2YWx1ZSB1c2VkIGZvciBLU0M1NjAxIGJ5IGNhcnJpZXJzIGluIEtvcmVhLgogICAgICAgICAgICAgICAgIGVuY29kaW5nVHlwZSA9IEVOQ09ESU5HX0tTQzU2MDE7CiAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgIFJsb2cudyhMT0dfVEFHLCAiNSAtIFVuc3VwcG9ydGVkIFNNUyBkYXRhIGNvZGluZyBzY2hlbWUgIgotICAgICAgICAgICAgICAgICAgICAgICAgKyAoZGF0YUNvZGluZ1NjaGVtZSAmIDB4ZmYpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICsgKG1EYXRhQ29kaW5nU2NoZW1lICYgMHhmZikpOwogICAgICAgICAgICAgfQogICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgUmxvZy53KExPR19UQUcsICIzIC0gVW5zdXBwb3J0ZWQgU01TIGRhdGEgY29kaW5nIHNjaGVtZSAiCi0gICAgICAgICAgICAgICAgICAgICsgKGRhdGFDb2RpbmdTY2hlbWUgJiAweGZmKSk7CisgICAgICAgICAgICAgICAgICAgICsgKG1EYXRhQ29kaW5nU2NoZW1lICYgMHhmZikpOwogICAgICAgICB9CiAKICAgICAgICAgLy8gc2V0IGJvdGggdGhlIHVzZXIgZGF0YSBhbmQgdGhlIHVzZXIgZGF0YSBoZWFkZXIuCiAgICAgICAgIGludCBjb3VudCA9IHAuY29uc3RydWN0VXNlckRhdGEoaGFzVXNlckRhdGFIZWFkZXIsCiAgICAgICAgICAgICAgICAgZW5jb2RpbmdUeXBlID09IEVOQ09ESU5HXzdCSVQpOwotICAgICAgICB0aGlzLnVzZXJEYXRhID0gcC5nZXRVc2VyRGF0YSgpOwotICAgICAgICB0aGlzLnVzZXJEYXRhSGVhZGVyID0gcC5nZXRVc2VyRGF0YUhlYWRlcigpOworICAgICAgICB0aGlzLm1Vc2VyRGF0YSA9IHAuZ2V0VXNlckRhdGEoKTsKKyAgICAgICAgdGhpcy5tVXNlckRhdGFIZWFkZXIgPSBwLmdldFVzZXJEYXRhSGVhZGVyKCk7CiAKICAgICAgICAgc3dpdGNoIChlbmNvZGluZ1R5cGUpIHsKICAgICAgICAgY2FzZSBFTkNPRElOR19VTktOT1dOOgogICAgICAgICBjYXNlIEVOQ09ESU5HXzhCSVQ6Ci0gICAgICAgICAgICBtZXNzYWdlQm9keSA9IG51bGw7CisgICAgICAgICAgICBtTWVzc2FnZUJvZHkgPSBudWxsOwogICAgICAgICAgICAgYnJlYWs7CiAKICAgICAgICAgY2FzZSBFTkNPRElOR183QklUOgotICAgICAgICAgICAgbWVzc2FnZUJvZHkgPSBwLmdldFVzZXJEYXRhR1NNN0JpdChjb3VudCwKLSAgICAgICAgICAgICAgICAgICAgaGFzVXNlckRhdGFIZWFkZXIgPyB1c2VyRGF0YUhlYWRlci5sYW5ndWFnZVRhYmxlIDogMCwKLSAgICAgICAgICAgICAgICAgICAgaGFzVXNlckRhdGFIZWFkZXIgPyB1c2VyRGF0YUhlYWRlci5sYW5ndWFnZVNoaWZ0VGFibGUgOiAwKTsKKyAgICAgICAgICAgIG1NZXNzYWdlQm9keSA9IHAuZ2V0VXNlckRhdGFHU003Qml0KGNvdW50LAorICAgICAgICAgICAgICAgICAgICBoYXNVc2VyRGF0YUhlYWRlciA/IG1Vc2VyRGF0YUhlYWRlci5sYW5ndWFnZVRhYmxlIDogMCwKKyAgICAgICAgICAgICAgICAgICAgaGFzVXNlckRhdGFIZWFkZXIgPyBtVXNlckRhdGFIZWFkZXIubGFuZ3VhZ2VTaGlmdFRhYmxlIDogMCk7CiAgICAgICAgICAgICBicmVhazsKIAogICAgICAgICBjYXNlIEVOQ09ESU5HXzE2QklUOgotICAgICAgICAgICAgbWVzc2FnZUJvZHkgPSBwLmdldFVzZXJEYXRhVUNTMihjb3VudCk7CisgICAgICAgICAgICBtTWVzc2FnZUJvZHkgPSBwLmdldFVzZXJEYXRhVUNTMihjb3VudCk7CiAgICAgICAgICAgICBicmVhazsKIAogICAgICAgICBjYXNlIEVOQ09ESU5HX0tTQzU2MDE6Ci0gICAgICAgICAgICBtZXNzYWdlQm9keSA9IHAuZ2V0VXNlckRhdGFLU0M1NjAxKGNvdW50KTsKKyAgICAgICAgICAgIG1NZXNzYWdlQm9keSA9IHAuZ2V0VXNlckRhdGFLU0M1NjAxKGNvdW50KTsKICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICB9CiAKLSAgICAgICAgaWYgKGZhbHNlKSBSbG9nLnYoTE9HX1RBRywgIlNNUyBtZXNzYWdlIGJvZHkgKHJhdyk6ICciICsgbWVzc2FnZUJvZHkgKyAiJyIpOworICAgICAgICBpZiAoVkRCRykgUmxvZy52KExPR19UQUcsICJTTVMgbWVzc2FnZSBib2R5IChyYXcpOiAnIiArIG1NZXNzYWdlQm9keSArICInIik7CiAKLSAgICAgICAgaWYgKG1lc3NhZ2VCb2R5ICE9IG51bGwpIHsKKyAgICAgICAgaWYgKG1NZXNzYWdlQm9keSAhPSBudWxsKSB7CiAgICAgICAgICAgICBwYXJzZU1lc3NhZ2VCb2R5KCk7CiAgICAgICAgIH0KIAogICAgICAgICBpZiAoIWhhc01lc3NhZ2VDbGFzcykgewogICAgICAgICAgICAgbWVzc2FnZ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vZygic2V0U3RhdGU6IHN0YXRlPSIgKyBzdGF0ZSk7CiAgICAgICAgIHN3aXRjaCAoc3RhdGUpIHsKICAgICAgICAgICAgIGNhc2UgQUNUSVZFOgotICAgICAgICAgICAgICAgIGlmIChjb25uZWN0VGltZSA9PSAwKSB7Ci0gICAgICAgICAgICAgICAgICAgIGNvbm5lY3RUaW1lUmVhbCA9IFN5c3RlbUNsb2NrLmVsYXBzZWRSZWFsdGltZSgpOwotICAgICAgICAgICAgICAgICAgICBjb25uZWN0VGltZSA9IFN5c3RlbS5jdXJyZW50VGltZU1pbGxpcygpOworICAgICAgICAgICAgICAgIGlmIChtQ29ubmVjdFRpbWUgPT0gMCkgeworICAgICAgICAgICAgICAgICAgICBtQ29ubmVjdFRpbWVSZWFsID0gU3lzdGVtQ2xvY2suZWxhcHNlZFJlYWx0aW1lKCk7CisgICAgICAgICAgICAgICAgICAgIG1Db25uZWN0VGltZSA9IFN5c3RlbS5jdXJyZW50VGltZU1pbGxpcygpOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIGNhc2UgRElTQ09OTkVDVEVEOgotICAgICAgICAgICAgICAgIGR1cmF0aW9uID0gZ2V0RHVyYXRpb25NaWxsaXMoKTsKLSAgICAgICAgICAgICAgICBkaXNjb25uZWN0VGltZSA9IFN5c3RlbS5jdXJyZW50VGltZU1pbGxpcygpOworICAgICAgICAgICAgICAgIG1EdXJhdGlvbiA9IGdldER1cmF0aW9uTWlsbGlzKCk7CisgICAgICAgICAgICAgICAgbURpc2Nvbm5lY3RUaW1lID0gU3lzdGVtLmN1cnJlbnRUaW1lTWlsbGlzKCk7CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICBjYXNlIEhPTERJTkc6Ci0gICAgICAgICAgICAgICAgaG9sZGluZ1N0YXJ0VGltZSA9IFN5c3RlbUNsb2NrLmVsYXBzZWRSZWFsdGltZSgpOworICAgICAgICAgICAgICAgIG1Ib2xkaW5nU3RhcnRUaW1lID0gU3lzdGVtQ2xvY2suZWxhcHNlZFJlYWx0aW1lKCk7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgIC8vIElnbm9yZQogICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICB9CiAgICAgfQogCiAgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGxvbmcgZ2V0Q3JlYXRlVGltZSgpIHsKLSAgICAgICAgcmV0dXJuIGNyZWF0ZVRpbWU7CisgICAgICAgIGlmIChWREJHKSBsb2coImdldENyZWF0ZVRpbWU6IHJldD0iICsgbUNyZWF0ZVRpbWUpOworICAgICAgICByZXR1cm4gbUNyZWF0ZVRpbWU7CiAgICAgfQogCiAgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGxvbmcgZ2V0Q29ubmVjdFRpbWUoKSB7Ci0gICAgICAgIHJldHVybiBjb25uZWN0VGltZTsKKyAgICAgICAgaWYgKFZEQkcpIGxvZygiZ2V0Q29ubmVjdFRpbWU6IHJldD0iICsgbUNvbm5lY3RUaW1lKTsKKyAgICAgICAgcmV0dXJuIG1Db25uZWN0VGltZTsKICAgICB9CiAKICAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgbG9uZyBnZXREaXNjb25uZWN0VGltZSgpIHsKLSAgICAgICAgcmV0dXJuIGRpc2Nvbm5lY3RUaW1lOworICAgICAgICBpZiAoVkRCRykgbG9nKCJnZXREaXNjb25uZWN0VGltZTogcmV0PSIgKyBtRGlzY29ubmVjdFRpbWUpOworICAgICAgICByZXR1cm4gbURpc2Nvbm5lY3RUaW1lOwogICAgIH0KIAogICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBsb25nIGdldER1cmF0aW9uTWlsbGlzKCkgewotICAgICAgICBpZiAoY29ubmVjdFRpbWVSZWFsID09IDApIHsKLSAgICAgICAgICAgIHJldHVybiAwOwotICAgICAgICB9IGVsc2UgaWYgKGR1cmF0aW9uIDwgMCkgewotICAgICAgICAgICAgcmV0dXJuIFN5c3RlbUNsb2NrLmVsYXBzZWRSZWFsdGltZSgpIC0gY29ubmVjdFRpbWVSZWFsOworICAgICAgICBsb25nIGR1cjsKKyAgICAgICAgaWYgKG1Db25uZWN0VGltZVJlYWwgPT0gMCkgeworICAgICAgICAgICAgZHVyID0gMDsKKyAgICAgICAgfSBlbHNlIGlmIChtRHVyYXRpb24gPCAwKSB7CisgICAgICAgICAgICBkdXIgPSBTeXN0ZW1DbG9jay5lbGFwc2VkUmVhbHRpbWUoKSAtIG1Db25uZWN0VGltZVJlYWw7CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICByZXR1cm4gZHVyYXRpb247CisgICAgICAgICAgICBkdXIgPSBtRHVyYXRpb247CiAgICAgICAgIH0KKyAgICAgICAgaWYgKFZEQkcpIGxvZygiZ2V0RHVyYXRpb25NaWxsaXM6IHJldD0iICsgZHVyKTsKKyAgICAgICAgcmV0dXJuIGR1cjsKICAgICB9CiAKICAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgbG9uZyBnZXRIb2xkRHVyYXRpb25NaWxsaXMoKSB7CisgICAgICAgIGxvbmcgZHVyOwogICAgICAgICBpZiAoZ2V0U3RhdGUoKSAhPSBDYWxsLlN0YXRlLkhPTERJTkcpIHsKICAgICAgICAgICAgIC8vIElmIG5vdCBob2xkaW5nLCByZXR1cm4gMAotICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgICAgICBkdXIgPSAwOwogICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgcmV0dXJuIFN5c3RlbUNsb2NrLmVsYXBzZWRSZWFsdGltZSgpIC0gaG9sZGluZ1N0YXJ0VGltZTsKKyAgICAgICAgICAgIGR1ciA9IFN5c3RlbUNsb2NrLmVsYXBzZWRSZWFsdGltZSgpIC0gbUhvbGRpbmdTdGFydFRpbWU7CiAgICAgICAgIH0KKyAgICAgICAgaWYgKFZEQkcpIGxvZygiZ2V0SG9sZER1cmF0aW9uTWlsbGlzOiByZXQ9IiArIGR1cik7CisgICAgICAgIHJldHVybiBkdXI7CiAgICAgfQogCiAgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIERpc2Nvbm5lY3RDYXVzZSBnZXREaXNjb25uZWN0Q2F1c2UoKSB7CisgICAgICAgIGlmIChWREJHKSBsb2coImdldERpc2Nvbm5lY3RDYXVzZTogcmV0PSIgKyBtQ2F1c2UpOwogICAgICAgICByZXR1cm4gbUNhdXNlOwogICAgIH0KIAogICAgIHZvaWQgc2V0RGlzY29ubmVjdENhdXNlKERpc2Nvbm5lY3RDYXVzZSBjYXVzZSkgeworICAgICAgICBpZiAoREJHKSBsb2coInNldERpc2Nvbm5lY3RDYXVzZTogcHJldj0iICsgbUNhdXNlICsgIiBuZXc9IiArIGNhdXNlKTsKICAgICAgICAgbUNhdXNlID0gY2F1c2U7CiAgICAgfQogCiAgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFBvc3REaWFsU3RhdGUgZ2V0UG9zdERpYWxTdGF0ZSgpIHsKLSAgICAgICAgcmV0dXJuIHBvc3REaWFsU3RhdGU7CisgICAgICAgIGlmIChWREJHKSBsb2coImdldFBvc3REaWFsU3RhdGU6IHJldD0iICsgbVBvc3REaWFsU3RhdGUpOworICAgICAgICByZXR1cm4gbVBvc3REaWFsU3RhdGU7CiAgICAgfQogCiAgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgcHJvY2VlZEFmdGVyV2FpdENoYXIoKSB7Ci0gICAgICAgIC8vIFRPRE8KKyAgICAgICAgaWYgKERCRykgbG9nKCJwcm9jZWVkQWZ0ZXJXYWl0Q2hhcjogaWdub3JlIik7CiAgICAgfQogCiAgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgcHJvY2VlZEFmdGVyV2lsZENoYXIoU3RyaW5nIHN0cikgewotICAgICAgICAvLyBUT0RPCisgICAgICAgIGlmIChEQkcpIGxvZygicHJvY2VlZEFmdGVyV2l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zZTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGlmIChtUmluZ2luZ0NhbGwuZ2V0U3RhdGUoKS5pc0FsaXZlKCkpIHsKKyAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coImNhblRha2U6IHJldD1mYWxzZSwgcmluZ2luZ0NhbGwgbm90IGFsaXZlIik7CisgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOworICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAvLyBGSVhNRTogaXMgaXQgdHJ1ZSB0aGF0IHdlIGNhbm5vdCB0YWtlIGFueSBpbmNvbWluZyBjYWxsIGlmCiAgICAgICAgICAgICAvLyBib3RoIGZvcmVncm91bmQgYW5kIGJhY2tncm91bmQgYXJlIGFjdGl2ZQotICAgICAgICAgICAgaWYgKGZvcmVncm91bmRDYWxsLmdldFN0YXRlKCkuaXNBbGl2ZSgpCi0gICAgICAgICAgICAgICAgICAgICYmIGJhY2tncm91bmRDYWxsLmdldFN0YXRlKCkuaXNBbGl2ZSgpKSB7CisgICAgICAgICAgICBpZiAobUZvcmVncm91bmRDYWxsLmdldFN0YXRlKCkuaXNBbGl2ZSgpCisgICAgICAgICAgICAgICAgICAgICYmIG1CYWNrZ3JvdW5kQ2FsbC5nZXRTdGF0ZSgpLmlzQWxpdmUoKSkgeworICAgICAgICAgICAgICAgIGlmIChEQkcpIHsKKyAgICAgICAgICAgICAgICAgICAgbG9nKCJjYW5UYWtlOiByZXQ9ZmFsc2UsIiArCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgIiBmb3JlZ3JvdW5kIGFuZCBiYWNrZ3JvdW5kIGJvdGggYWxpdmUiKTsKKyAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgfQogCiAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgIFNpcEF1ZGlvQ2FsbCBzaXBBdWRpb0NhbGwgPSAoU2lwQXVkaW9DYWxsKSBpb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QgdGhlIGNhbGwhCi0gICAgICAgICAgICAgICAgICAgICAgICBpZiAoREVCVUcpIFJsb2cuZChMT0dfVEFHLCAiICAgIGNhbGwgY2FuY2VsbGVkICEhIik7Ci0gICAgICAgICAgICAgICAgICAgICAgICByaW5naW5nQ2FsbC5yZXNldCgpOworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCIgICAgY2FuVGFrZTogY2FsbCBjYW5jZWxsZWQgISEiKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1SaW5naW5nQ2FsbC5yZXNldCgpOwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgIH0KQEAgLTEyNCwzNyArMTM5LDUwIEBACiAgICAgICAgICAgICAgICAgLy8gUGVlciBtYXkgY2FuY2VsIHRoZSBjYWxsIGF0IGFueSB0aW1lIGR1cmluZyB0aGUgdGltZSB3ZSBob29rCiAgICAgICAgICAgICAgICAgLy8gdXAgcmluZ2luZ0NhbGwgd2l0aCBzaXBBdWRpb0NhbGwuIENsZWFuIHVwIHJpbmdpbmdDYWxsIHdoZW4KICAgICAgICAgICAgICAgICAvLyB0aGF0IGhhcHBlbnMuCi0gICAgICAgICAgICAgICAgcmluZ2luZ0NhbGwucmVzZXQoKTsKKyAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coIiAgICBjYW5UYWtlOiBleGNlcHRpb24gZT0iICsgZSk7CisgICAgICAgICAgICAgICAgbVJpbmdpbmdDYWxsLnJlc2V0KCk7CiAgICAgICAgICAgICB9CisgICAgICAgICAgICBpZiAoREJHKSBsb2coImNhblRha2U6IE5PVCB0YWtpbmcgISEiKTsKICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgfQogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIGFjY2VwdENhbGwoKSB0aHJvd3MgQ2FsbFN0YXRlRXhjZXB0aW9uIHsKICAgICAgICAgc3luY2hyb25pemVkIChTaXBQaG9uZS5jbGFzcykgewotICAgICAgICAgICAgaWYgKChyaW5naW5nQ2FsbC5nZXRTdGF0ZSgpID09IENhbGwuU3RhdGUuSU5DT01JTkcpIHx8Ci0gICAgICAgICAgICAgICAgICAgIChyaW5naW5nQ2FsbC5nZXRTdGF0ZSgpID09IENhbGwuU3RhdGUuV0FJVElORykpIHsKLSAgICAgICAgICAgICAgICBpZiAoREVCVUcpIFJsb2cuZChMT0dfVEFHLCAiYWNjZXB0Q2FsbCIpOworICAgICAgICAgICAgaWYgKChtUmluZ2luZ0NhbGwuZ2V0U3RhdGUoKSA9PSBDYWxsLlN0YXRlLklOQ09NSU5HKSB8fAorICAgICAgICAgICAgICAgICAgICAobVJpbmdpbmdDYWxsLmdldFN0YXRlKCkgPT0gQ2FsbC5TdGF0ZS5XQUlUSU5HKSkgeworICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygiYWNjZXB0Q2FsbDogYWNjZXB0aW5nIik7CiAgICAgICAgICAgICAgICAgLy8gQWx3YXlzIHVubXV0ZSB3aGVuIGFuc3dlcmluZyBhIG5ldyBjYWxsCi0gICAgICAgICAgICAgICAgcmluZ2luZ0NhbGwuc2V0TXV0ZShmYWxzZSk7Ci0gICAgICAgICAgICAgICAgcmluZ2luZ0NhbGwuYWNjZXB0Q2FsbCgpOworICAgICAgICAgICAgICAgIG1SaW5naW5nQ2FsbC5zZXRNdXRlKGZhbHNlKTsKKyAgICAgICAgICAgICAgICBtUmluZ2luZ0NhbGwuYWNjZXB0Q2FsbCgpOwogICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICBpZiAoREJHKSB7CisgICAgICAgICAgICAgICAgICAgIGxvZygiYWNjZXB0Q2FsbDoiICsKKyAgICAgICAgICAgICAgICAgICAgICAgICIgdGhyb3cgQ2FsbFN0YXRlRXhjZXB0aW9uKFwicGhvbmUgbm90IHJpbmdpbmdcIikiKTsKKyAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IENhbGxTdGF0ZUV4Y2VwdGlvbigicGhvbmUgbm90IHJpbmdpbmciKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfQogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHJlamVjdENhbGwoKSB0aHJvd3MgQ2FsbFN0YXRlRXhjZXB0aW9uIHsKICAgICAgICAgc3luY2hyb25pemVkIChTaXBQaG9uZS5jbGFzcykgewotICAgICAgICAgICAgaWYgKHJpbmdpbmdDYWxsLmdldFN0YXRlKCkuaXNSaW5naW5nKCkpIHsKLSAgICAgICAgICAgICAgICBpZiAoREVCVUcpIFJsb2cuZChMT0dfVEFHLCAicmVqZWN0Q2FsbCIpOwotICAgICAgICAgICAgICAgIHJpbmdpbmdDYWxsLnJlamVjdENhbGwoKTsKKyAgICAgICAgICAgIGlmIChtUmluZ2luZ0NhbGwuZ2V0U3RhdGUoKS5pc1JpbmdpbmcoKSkgeworICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygicmVqZWN0Q2FsbDogcmVqZWN0aW5nIik7CisgICAgICAgICAgICAgICAgbVJpbmdpbmdDYWxsLnJlamVjdENhbGwoKTsKICAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgaWYgKERCRykgeworICAgICAgICAgICAgICAgICAgICBsb2coInJlamVjdENhbGw6IiArCisgICAgICAgICAgICAgICAgICAgICAgICAiIHRocm93IENhbGxTdGF0ZUV4Y2VwdGlvbihcInBob25lIG5vdCByaW5naW5nXCIpIik7CisgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIHRocm93IG5ldyBDYWxsU3RhdGVFeGNlcHRpb24oInBob25lIG5vdCByaW5naW5nIik7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgQ29ubmVjdGlvbiBkaWFsKFN0cmluZyBkaWFsU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ICBtQmFja2dyb3VuZENhbGwuY2xlYXJEaXNjb25uZWN0ZWQoKTsKIAogICAgICAgICAgICAgdXBkYXRlUGhvbmVTdGF0ZSgpOwogICAgICAgICAgICAgbm90aWZ5UHJlY2lzZUNhbGxTdGF0ZUNoYW5nZWQoKTsKICAgICAgICAgfQogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHNlbmREdG1mKGNoYXIgYykgewogICAgICAgICBpZiAoIVBob25lTnVtYmVyVXRpbHMuaXMxMktleShjKSkgewotICAgICAgICAgICAgUmxvZy5lKExPR19UQUcsCi0gICAgICAgICAgICAgICAgICAgICJzZW5kRHRtZiBjYWxsZWQgd2l0aCBpbnZhbGlkIGNoYXJhY3RlciAnIiArIGMgKyAiJyIpOwotICAgICAgICB9IGVsc2UgaWYgKGZvcmVncm91bmRDYWxsLmdldFN0YXRlKCkuaXNBbGl2ZSgpKSB7CisgICAgICAgICAgICBsb2dlKCJzZW5kRHRtZiBjYWxsZWQgd2l0aCBpbnZhbGlkIGNoYXJhY3RlciAnIiArIGMgKyAiJyIpOworICAgICAgICB9IGVsc2UgaWYgKG1Gb3JlZ3JvdW5kQ2FsbC5nZXRTdGF0ZSgpLmlzQWxpdmUoKSkgewogICAgICAgICAgICAgc3luY2hyb25pemVkIChTaXBQaG9uZS5jbGFzcykgewotICAgICAgICAgICAgICAgIGZvcmVncm91bmRDYWxsLnNlbmREdG1mKGMpOworICAgICAgICAgICAgICAgIG1Gb3JlZ3JvdW5kQ2FsbC5zZW5kRHRtZihjKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfQogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHN0YXJ0RHRtZihjaGFyIGMpIHsKICAgICAgICAgaWYgKCFQaG9uZU51bWJlclV0aWxzLmlzMTJLZXkoYykpIHsKLSAgICAgICAgICAgIFJsb2cuZShMT0dfVEFHLAotICAgICAgICAgICAgICAgICJzdGFydER0bWYgY2FsbGVkIHdpdGggaW52YWxpZCBjaGFyYWN0ZXIgJyIgKyBjICsgIiciKTsKKyAgICAgICAgICAgIGxvZ2UoInN0YXJ0RHRtZiBjYWxsZWQgd2l0aCBpbnZhbGlkIGNoYXJhY3RlciAnIiArIGMgKyAiJyIpOwogICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgc2VuZER0bWYoYyk7CiAgICAgICAgIH0KICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBzdG9wRHRtZigpIHsKICAgICAgICAgLy8gbm8gb3AKICAgICB9CiAKICAgICBwdWJsaWMgdm9pZCBzZW5kQnVyc3REdG1mKFN0cmluZyBkdG1mU3RyaW5nKSB7Ci0gICAgICAgIFJsb2cuZShMT0dfVEFHLCAiW1NpcFBob25lXSBzZW5kQnVyc3REdG1mKCkgaXMgYSBDRE1BIG1ldGhvZCIpOworICAgICAgICBsb2dlKCJzZW5kQnVyc3REdG1mKCkgaXMgYSBDRE1BIG1ldGhvZCIpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIGdldE91dGdvaW5nQ2FsbGVySWREaXNwbGF5KE1lc3NhZ2Ugb25Db21wbGV0ZSkgewogICAgICAgICAvLyBGSVhNRTogd2hhdCB0byByZXBseT8KICAgICAgICAgQXN5bmNSZXN1bHQuZm9yTWVzc2FnZShvbkNvbXBsZXRlLCBudWxsLCBudWxsKTsKICAgICAgICAgb25Db21wbGV0ZS5zZW5kVG9UYXJnZXQoKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBzZXRPdXRnb2luZ0NhbGxlcklkRGlzcGxheShpbnQgY29tbWFuZEludGVyZmFjZUNMSVJNb2RlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1lc3NhZ2Ugb25Db21wbGV0ZSkgewogICAgICAgICAvLyBGSVhNRTogd2hhdCdzIHRoaXMgZm9yIF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IGZpbmFsIFN0cmluZyBTQ19UQUcgPSAiU2lwQ2FsbCI7CisgICAgICAgIHByaXZhdGUgc3RhdGljIGZpbmFsIGJvb2xlYW4gU0NfREJHID0gdHJ1ZTsKKyAgICAgICAgcHJpdmF0ZSBzdGF0aWMgZmluYWwgYm9vbGVhbiBTQ19WREJHID0gZmFsc2U7IC8vIFNUT1BTSElQIGlmIHRydWUKKwogICAgICAgICB2b2lkIHJlc2V0KCkgewotICAgICAgICAgICAgY29ubmVjdGlvbnMuY2xlYXIoKTsKKyAgICAgICAgICAgIGlmIChTQ19EQkcpIGxvZygicmVzZXQiKTsKKyAgICAgICAgICAgIG1Db25uZWN0aW9ucy5jbGVhcigpOwogICAgICAgICAgICAgc2V0U3RhdGUoQ2FsbC5TdGF0ZS5JRExFKTsKICAgICAgICAgfQogCiAgICAgICAgIHZvaWQgc3dpdGNoV2l0aChTaXBDYWxsIHRoYXQpIHsKKyAgICAgICAgICAgIGlmIChTQ19EQkcpIGxvZygic3dpdGNoV2l0aCIpOwogICAgICAgICAgICAgc3luY2hyb25pemVkIChTaXBQaG9uZS5jbGFzcykgewogICAgICAgICAgICAgICAgIFNpcENhbGwgdG1wID0gbmV3IFNpcENhbGwoKTsKICAgICAgICAgICAgICAgICB0bXAudGFrZU92ZXIodGhpcyk7CkBAIC0zNjUsOSArNDUyLDEwIEBACiAgICAgICAgIH0KIAogICAgICAgICBwcml2YXRlIHZvaWQgdGFrZU92ZXIoU2lwQ2FsbCB0aGF0KSB7Ci0gICAgICAgICAgICBjb25uZWN0aW9ucyA9IHRoYXQuY29ubmVjdGlvbnM7Ci0gICAgICAgICAgICBzdGF0ZSA9IHRoYXQuc3RhdGU7Ci0gICAgICAgICAgICBmb3IgKENvbm5lY3Rpb24gYyA6IGNvbm5lY3Rpb25zKSB7CisgICAgICAgICAgICBpZiAoU0NfREJHKSBsb2coInRha2VPdmVyIik7CisgICAgICAgICAgICBtQ29ubmVjdGlvbnMgPSB0aGF0Lm1Db25uZWN0aW9uczsKKyAgICAgICAgICAgIG1TdGF0ZSA9IHRoYXQubVN0YXRlOworICAgICAgICAgICAgZm9yIChDb25uZWN0aW9uIGMgOiBtQ29ubmVjdGlvbnMpIHsKICAgICAgICAgICAgICAgICAoKFNpcENvbm5lY3Rpb24pIGMpLmNoYW5nZU93bmVyKHRoaXMpOwogICAgICAgICAgICAgfQogICAgICAgICB9CkBAIC0zNzksMTMgKzQ2NywxNiBAQAogCiAgICAgICAgIEBPdmVycmlkZQogICAgICAgICBwdWJsaWMgTGlzdDxDb25uZWN0aW9uPiBnZXRDb25uZWN0aW9ucygpIHsKKyAgICAgICAgICAgIGlmIChTQ19WREJHKSBsb2coImdldENvbm5lY3Rpb25zIik7CiAgICAgICAgICAgICBzeW5jaHJvbml6ZWQgKFNpcFBob25lLmNsYXNzKSB7CiAgICAgICAgICAgICAgICAgLy8gRklYTUUgc2hvdWxkIHJldHVybiBDb2xsZWN0aW9ucy51bm1vZGlmaWFibGVMaXN0KCk7Ci0gICAgICAgICAgICAgICAgcmV0dXJuIGNvbm5lY3Rpb25zOworICAgICAgICAgICAgICAgIHJldHVybiBtQ29ubmVjdGlvbnM7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KIAogICAgICAgICBDb25uZWN0aW9uIGRpYWwoU3RyaW5nIG9yaWdpbmFsTnVtYmVyKSB0aHJvd3MgU2lwRXhjZXB0aW9uIHsKKyAgICAgICAgICAgIGlmIChTQ19EQkcpIGxvZygiZGlhbDogbnVtPSIgKyAoU0NfVkRCRyA/IG9yaWdpbmFsTnVtYmVyIDogInh4eCIpKTsKKyAgICAgICAgICAgIC8vIFRPRE86IFNob3VsZCB0aGlzIGJlIHN5bmNocm9uaXplZD8KICAgICAgICAgICAgIFN0cmluZyBjYWxsZWVTaXBVcmkgPSBvcmlnaW5hbE51bWJlcjsKICAgICAgICAgICAgIGlmICghY2FsbGVlU2lwVXJpLmNvbnRhaW5zKCJAIikpIHsKICAgICAgICAgICAgICAgICBTdHJpbmcgcmVwbGFjZVN0ciA9IFBhdHRlcm4ucXVvdGUobVByb2ZpbGUuZ2V0VXNlck5hbWUoKSArICJAIik7CkBAIC0zOTgsNyArNDg5LDcgQEAKICAgICAgICAgICAgICAgICBTaXBDb25uZWN0aW9uIGMgPSBuZXcgU2lwQ29ubmVjdGlvbih0aGlzLCBjYWxsZWUsCiAgICAgICAgICAgICAgICAgICAgICAgICBvcmlnaW5hbE51bWJlcik7CiAgICAgICAgICAgICAgICAgYy5kaWFsKCk7Ci0gICAgICAgICAgICAgICAgY29ubmVjdGlvbnMuYWRkKGMpOworICAgICAgICAgICAgICAgIG1Db25uZWN0aW9ucy5hZGQoYyk7CiAgICAgICAgICAgICAgICAgc2V0U3RhdGUoQ2FsbC5TdGF0ZS5ESUFMSU5HKTsKICAgICAgICAgICAgICAgICByZXR1cm4gYzsKICAgICAgICAgICAgIH0gY2F0Y2ggKFBhcnNlRXhjZXB0aW9uIGUpIHsKQEAgLTQwOSwxMiArNTAwLDEyIEBACiAgICAgICAgIEBPdmVycmlkZQogICAgICAgICBwdWJsaWMgdm9pZCBoYW5ndXAoKSB0aHJvd3MgQ2FsbFN0YXRlRXhjZXB0aW9uIHsKICAgICAgICAgICAgIHN5bmNocm9uaXplZCAoU2lwUGhvbmUuY2xhc3MpIHsKLSAgICAgICAgICAgICAgICBpZiAoc3RhdGUuaXNBbGl2ZSgpKSB7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChERUJVRykgUmxvZy5kKExPR19UQUcsICJoYW5nIHVwIGNhbGw6ICIgKyBnZXRTdGF0ZSgpCisgICAgICAgICAgICAgICAgaWYgKG1TdGF0ZS5pc0FsaXZlKCkpIHsKKyAgICAgICAgICAgICAgICAgICAgaWYgKFNDX0RCRykgbG9nKCJoYW5ndXA6IGNhbGwgIiArIGdldFN0YXRlKCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICArICI6ICIgKyB0aGlzICsgIiBvbiBwaG9uZSAiICsgZ2V0UGhvbmUoKSk7CiAgICAgICAgICAgICAgICAgICAgIHNldFN0YXRlKFN0YXRlLkRJU0NPTk5FQ1RJTkcpOwogICAgICAgICAgICAgICAgICAgICBDYWxsU3RhdGVFeGNlcHRpb24gZXhjcCA9IG51bGw7Ci0gICAgICAgICAgICAgICAgICAgIGZvciAoQ29ubmVjdGlvbiBjIDogY29ubmVjdGlvbnMpIHsKKyAgICAgICAgICAgICAgICAgICAgZm9yIChDb25uZWN0aW9uIGMgOiBtQ29ubmVjdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYy5oYW5ndXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKENhbGxTdGF0ZUV4Y2VwdGlvbiBlKSB7CkBAIC00MjMsNyArNTE0LDcgQEAKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICBpZiAoZXhjcCAhPSBudWxsKSB0aHJvdyBleGNwOwogICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChERUJVRykgUmxvZy5kKExPR19UQUcsICJoYW5nIHVwIGRlYWQgY2FsbDogIiArIGdldFN0YXRlKCkKKyAgICAgICAgICAgICAgICAgICAgaWYgKFNDX0RCRykgbG9nKCJoYW5ndXA6IGRlYWQgY2FsbCAiICsgZ2V0U3RhdGUoKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgIjogIiArIHRoaXMgKyAiIG9uIHBob25lICIgKyBnZXRQaG9uZSgpKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CkBAIC00MzIsNyArNTIzLDcgQEAKICAgICAgICAgdm9pZCBpbml0SW5jb21pbmdDYWxsKFNpcEF1ZGlvQ2FsbCBzaXBBdWRpb0NhbGwsIGJvb2xlYW4gbWFrZUNhbGxXYWl0KSB7CiAgICAgICAgICAgICBTaXBQcm9maWxlIGNhbGxlZSA9IHNpcEF1ZGlvQ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EpIHsKICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgQ2FsbFN0YXRlRXhjZXB0aW9uKCJhY2NlcHRDYWxsKCkgaW4gYSBjb25mIGNhbGwiKTsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICgoU2lwQ29ubmVjdGlvbikgY29ubmVjdGlvbnMuZ2V0KDApKS5hY2NlcHRDYWxsKCk7CisgICAgICAgICAgICAoKFNpcENvbm5lY3Rpb24pIG1Db25uZWN0aW9ucy5nZXQoMCkpLmFjY2VwdENhbGwoKTsKICAgICAgICAgfQogCiAgICAgICAgIHByaXZhdGUgYm9vbGVhbiBpc1NwZWFrZXJPbigpIHsKLSAgICAgICAgICAgIHJldHVybiAoKEF1ZGlvTWFuYWdlcikgbUNvbnRleHQuZ2V0U3lzdGVtU2VydmljZShDb250ZXh0LkFVRElPX1NFUlZJQ0UpKQorICAgICAgICAgICAgQm9vbGVhbiByZXQgPSAoKEF1ZGlvTWFuYWdlcikgbUNvbnRleHQuZ2V0U3lzdGVtU2VydmljZShDb250ZXh0LkFVRElPX1NFUlZJQ0UpKQogICAgICAgICAgICAgICAgICAgICAuaXNTcGVha2VycGhvbmVPbigpOworICAgICAgICAgICAgaWYgKFNDX1ZEQkcpIGxvZygiaXNTcGVha2VyT246IHJldD0iICsgcmV0KTsKKyAgICAgICAgICAgIHJldHVybiByZXQ7CiAgICAgICAgIH0KIAogICAgICAgICB2b2lkIHNldEF1ZGlvR3JvdXBNb2RlKCkgewogICAgICAgICAgICAgQXVkaW9Hcm91cCBhdWRpb0dyb3VwID0gZ2V0QXVkaW9Hcm91cCgpOwotICAgICAgICAgICAgaWYgKGF1ZGlvR3JvdXAgPT0gbnVsbCkgcmV0dXJuOworICAgICAgICAgICAgaWYgKGF1ZGlvR3JvdXAgPT0gbnVsbCkgeworICAgICAgICAgICAgICAgIGlmIChTQ19EQkcpIGxvZygic2V0QXVkaW9Hcm91cE1vZGU6IGF1ZGlvR3JvdXAgPT0gbnVsbCBpZ25vcmUiKTsKKyAgICAgICAgICAgICAgICByZXR1cm47CisgICAgICAgICAgICB9CiAgICAgICAgICAgICBpbnQgbW9kZSA9IGF1ZGlvR3JvdXAuZ2V0TW9kZSgpOwotICAgICAgICAgICAgaWYgKHN0YXRlID09IFN0YXRlLkhPTERJTkcpIHsKKyAgICAgICAgICAgIGlmIChtU3RhdGUgPT0gU3RhdGUuSE9MRElORykgewogICAgICAgICAgICAgICAgIGF1ZGlvR3JvdXAuc2V0TW9kZShBdWRpb0dyb3VwLk1PREVfT05fSE9MRCk7CiAgICAgICAgICAgICB9IGVsc2UgaWYgKGdldE11dGUoKSkgewogICAgICAgICAgICAgICAgIGF1ZGlvR3JvdXAuc2V0TW9kZShBdWRpb0dyb3VwLk1PREVfTVVURUQpOwpAQCAtNDczLDQ1ICs1NzEsNTEgQEAKICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgYXVkaW9Hcm91cC5zZXRNb2RlKEF1ZGlvR3JvdXAuTU9ERV9OT1JNQUwpOwogICAgICAgICAgICAgfQotICAgICAgICAgICAgaWYgKERFQlVHKSBSbG9nLmQoTE9HX1RBRywgU3RyaW5nLmZvcm1hdCgKLSAgICAgICAgICAgICAgICAgICAgImF1ZGlvR3JvdXAgbW9kZSBjaGFuZ2U6ICVkIC0tPiAlZCIsIG1vZGUsCisgICAgICAgICAgICBpZiAoU0NfREJHKSBsb2coU3RyaW5nLmZvcm1hdCgKKyAgICAgICAgICAgICAgICAgICAgInNldEF1ZGlvR3JvdXBNb2RlIGNoYW5nZTogJWQgLS0+ICVkIiwgbW9kZSwKICAgICAgICAgICAgICAgICAgICAgYXVkaW9Hcm91cC5nZXRNb2RlKCkpKTsKICAgICAgICAgfQogCiAgICAgICAgIHZvaWQgaG9sZCgpIHRocm93cyBDYWxsU3RhdGVFeGNlcHRpb24geworICAgICAgICAgICAgaWYgKFNDX0RCRykgbG9nKCJob2xkOiIpOwogICAgICAgICAgICAgc2V0U3RhdGUoU3RhdGUuS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XRlKG11dGVkKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfQogCiAgICAgICAgIGJvb2xlYW4gZ2V0TXV0ZSgpIHsKLSAgICAgICAgICAgIHJldHVybiBjb25uZWN0aW9ucy5pc0VtcHR5KCkKKyAgICAgICAgICAgIGJvb2xlYW4gcmV0ID0gbUNvbm5lY3Rpb25zLmlzRW1wdHkoKQogICAgICAgICAgICAgICAgICAgICA/IGZhbHNlCi0gICAgICAgICAgICAgICAgICAgIDogKChTaXBDb25uZWN0aW9uKSBjb25uZWN0aW9ucy5nZXQoMCkpLmdldE11dGUoKTsKKyAgICAgICAgICAgICAgICAgICAgOiAoKFNpcENvbm5lY3Rpb24pIG1Db25uZWN0aW9ucy5nZXQoMCkpLmdldE11dGUoKTsKKyAgICAgICAgICAgIGlmIChTQ19EQkcpIGxvZygiZ2V0TXV0ZTogcmV0PSIgKyByZXQpOworICAgICAgICAgICAgcmV0dXJuIHJldDsKICAgICAgICAgfQogCiAgICAgICAgIHZvaWQgbWVyZ2UoU2lwQ2FsbCB0aGF0KSB0aHJvd3MgQ2FsbFN0YXRlRXhjZXB0aW9uIHsKKyAgICAgICAgICAgIGlmIChTQ19EQkcpIGxvZygibWVyZ2U6Iik7CiAgICAgICAgICAgICBBdWRpb0dyb3VwIGF1ZGlvR3JvdXAgPSBnZXRBdWRpb0dyb3VwKCk7CiAKICAgICAgICAgICAgIC8vIGNvcHkgdG8gYW4gYXJyYXkgdG8gYXZvaWQgY29uY3VycmVudCBtb2RpZmljYXRpb24gYXMgY29ubmVjdGlvbnMKICAgICAgICAgICAgIC8vIGluIHRoYXQuY29ubmVjdGlvbnMgd2lsbCBiZSByZW1vdmVkIGluIGFkZChTaXBDb25uZWN0aW9uKS4KLSAgICAgICAgICAgIENvbm5lY3Rpb25bXSBjYyA9IHRoYXQuY29ubmVjdGlvbnMudG9BcnJheSgKLSAgICAgICAgICAgICAgICAgICAgbmV3IENvbm5lY3Rpb25bdGhhdC5jb25uZWN0aW9ucy5zaXplKCldKTsKKyAgICAgICAgICAgIENvbm5lY3Rpb25bXSBjYyA9IHRoYXQubUNvbm5lY3Rpb25zLnRvQXJyYXkoCisgICAgICAgICAgICAgICAgICAgIG5ldyBDb25uZWN0aW9uW3RoYXQubUNvbm5lY3Rpb25zLnNpemUoKV0pOwogICAgICAgICAgICAgZm9yIChDb25uZWN0aW9uIGMgOiBjYykgewogICAgICAgICAgICAgICAgIFNpcENvbm5lY3Rpb24gY29ubiA9IChTaXBDb25uZWN0aW9uKSBjOwogICAgICAgICAgICAgICAgIGFkZChjb25uKTsKQEAgLTUyMywxNyArNjI3LDIyIEBACiAgICAgICAgIH0KIAogICAgICAgICBwcml2YXRlIHZvaWQgYWRkKFNpcENvbm5lY3Rpb24gY29ubikgeworICAgICAgICAgICAgaWYgKFNDX0RCRykgbG9nKCJhZGQ6Iik7CiAgICAgICAgICAgICBTaXBDYWxsIGNhbGwgPSBjb25uLmdldENhbGwoKTsKICAgICAgICAgICAgIGlmIChjYWxsID09IHRoaXMpIHJldHVybjsKLSAgICAgICAgICAgIGlmIChjYWxsICE9IG51bGwpIGNhbGwuY29ubmVjdGlvbnMucmVtb3ZlKGNvbm4pOworICAgICAgICAgICAgaWYgKGNhbGwgIT0gbnVsbCkgY2FsbC5tQ29ubmVjdGlvbnMucmVtb3ZlKGNvbm4pOwogCi0gICAgICAgICAgICBjb25uZWN0aW9ucy5hZGQoY29ubik7CisgICAgICAgICAgICBtQ29ubmVjdGlvbnMuYWRkKGNvbm4pOwogICAgICAgICAgICAgY29ubi5jaGFuZ2VPd25lcih0aGlzKTsKICAgICAgICAgfQogCiAgICAgICAgIHZvaWQgc2VuZER0bWYoY2hhciBjKSB7CisgICAgICAgICAgICBpZiAoU0NfREJHKSBsb2coInNlbmREdG1mOiBjPSIgKyBjKTsKICAgICAgICAgICAgIEF1ZGlvR3JvdXAgYXVkaW9Hcm91cCA9IGdldEF1ZGlvR3JvdXAoKTsKLSAgICAgICAgICAgIGlmIChhdWRpb0dyb3VwID09IG51bGwpIHJldHVybjsKKyAgICAgICAgICAgIGlmIChhdWRpb0dyb3VwID09IG51bGwpIHsKKyAgICAgICAgICAgICAgICBpZiAoU0NfREJHKSBsb2coInNlbmREdG1mOiBhdWRpb0dyb3VwID09IG51bGwsIGlnbm9yZSBjPSIgKyBjKTsKKyAgICAgICAgICAgICAgICByZXR1cm47CisgICAgICAgICAgICB9CiAgICAgICAgICAgICBhdWRpb0dyb3VwLnNlbmREdG1mKGNvbnZlcnREdG1mKGMpKTsKICAgICAgICAgfQogCkBAIC01NTcsMTggKzY2NiwxOCBAQAogCiAgICAgICAgIEBPdmVycmlkZQogICAgICAgICBwcm90ZWN0ZWQgdm9pZCBzZXRTdGF0ZShTdGF0ZSBuZXdTdGF0ZSkgewotICAgICAgICAgICAgaWYgKHN0YXRlICE9IG5ld1N0YXRlKSB7Ci0gICAgICAgICAgICAgICAgaWYgKERFQlVHKSBSbG9nLnYoTE9HX1RBRywgIisqKiorIGNhbGwgc3RhdGUgY2hhbmdlZDogIiArIHN0YXRlCisgICAgICAgICAgICBpZiAobVN0YXRlICE9IG5ld1N0YXRlKSB7CisgICAgICAgICAgICAgICAgaWYgKFNDX0RCRykgbG9nKCJzZXRTdGF0ZTogY3VyIHN0YXRlIiArIG1TdGF0ZQogICAgICAgICAgICAgICAgICAgICAgICAgKyAiIC0tPiAiICsgbmV3U3RhdGUgKyAiOiAiICsgdGhpcyArICI6IG9uIHBob25lICIKLSAgICAgICAgICAgICAgICAgICAgICAgICsgZ2V0UGhvbmUoKSArICIgIiArIGNvbm5lY3Rpb25zLnNpemUoKSk7CisgICAgICAgICAgICAgICAgICAgICAgICArIGdldFBob25lKCkgKyAiICIgKyBtQ29ubmVjdGlvbnMuc2l6ZSgpKTsKIAogICAgICAgICAgICAgICAgIGlmIChuZXdTdGF0ZSA9PSBDYWxsLlN0YXRlLkFMRVJUSU5HKSB7Ci0gICAgICAgICAgICAgICAgICAgIHN0YXRlID0gbmV3U3RhdGU7IC8vIG5lZWQgaW4gQUxFUlRJTkcgdG8gZW5hYmxlIHJpbmdiYWNrCi0gICAgICAgICAgICAgICAgICAgIFNpcFBob25lLnRoaXMuc3RhcnRSaW5nYmFja1RvbmUoKTsKLSAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHN0YXRlID09IENhbGwuU3RhdGUuQUxFUlRJTkcpIHsKLSAgICAgICAgICAgICAgICAgICAgU2lwUGhvbmUudGhpcy5zdG9wUmluZ2JhY2tUb25lKCk7CisgICAgICAgICAgICAgICAgICAgIG1TdGF0ZSA9IG5ld1N0YXRlOyAvLyBuZWVkIGluIEFMRVJUSU5HIHRvIGVuYWJsZSByaW5nYmFjaworICAgICAgICAgICAgICAgICAgICBzdGFydFJpbmdiYWNrVG9uZSgpOworICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAobVN0YXRlID09IENhbGwuU3RhdGUuQUxFUlRJTkcpIHsKKyAgICAgICAgICAgICAgICAgICAgc3RvcFJpbmdiYWNrVG9uZSgpOwogICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBzdGF0ZSA9IG5ld1N0YXRlOworICAgICAgICAgICAgICAgIG1TdGF0ZSA9IG5ld1N0YXRlOwogICAgICAgICAgICAgICAgIHVwZGF0ZVBob25lU3RhdGUoKTsKICAgICAgICAgICAgICAgICBub3RpZnlQcmVjaXNlQ2FsbFN0YXRlQ2hhbmdlZCgpOwogICAgICAgICAgICAgfQpAQCAtNTc2LDE5ICs2ODUsMjEgQEAKIAogICAgICAgICB2b2lkIG9uQ29ubmVjdGlvblN0YXRlQ2hhbmdlZChTaXBDb25uZWN0aW9uIGNvbm4pIHsKICAgICAgICAgICAgIC8vIHRoaXMgY2FuIGJlIGNhbGxlZCBiYWNrIHdoZW4gYSBjb25mIGNhbGwgaXMgZm9ybWVkCi0gICAgICAgICAgICBpZiAoc3RhdGUgIT0gU3RhdGUuQUNUSVZFKSB7CisgICAgICAgICAgICBpZiAoU0NfREJHKSBsb2coIm9uQ29ubmVjdGlvblN0YXRlQ2hhbmdlZDogY29ubj0iICsgY29ubik7CisgICAgICAgICAgICBpZiAobVN0YXRlICE9IFN0YXRlLkFDVElWRSkgewogICAgICAgICAgICAgICAgIHNldFN0YXRlKGNvbm4uZ2V0U3RhdGUoKSk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KIAogICAgICAgICB2b2lkIG9uQ29ubmVjdGlvbkVuZGVkKFNpcENvbm5lY3Rpb24gY29ubikgewogICAgICAgICAgICAgLy8gc2V0IHN0YXRlIHRvIERJU0NPTk5FQ1RFRCBvbmx5IHdoZW4gYWxsIGNvbm5zIGFyZSBkaXNjb25uZWN0ZWQKLSAgICAgICAgICAgIGlmIChzdGF0ZSAhPSBTdGF0ZS5ESVNDT05ORUNURUQpIHsKKyAgICAgICAgICAgIGlmIChTQ19EQkcpIGxvZygib25Db25uZWN0aW9uRW5kZWQ6IGNvbm49IiArIGNvbm4pOworICAgICAgICAgICAgaWYgKG1TdGF0ZSAhPSBTdGF0ZS5ESVNDT05ORUNURUQpIHsKICAgICAgICAgICAgICAgICBib29sZWFuIGFsbENvbm5lY3Rpb25zRGlzY29ubmVjdGVkID0gdHJ1ZTsKLSAgICAgICAgICAgICAgICBpZiAoREVCVUcpIFJsb2cuZChMT0dfVEFHLCAiLS0tY2hlY2sgY29ubmVjdGlvbnM6ICIKLSAgICAgICAgICAgICAgICAgICAgICAgICsgY29ubmVjdGlvbnMuc2l6ZSgpKTsKLSAgICAgICAgICAgICAgICBmb3IgKENvbm5lY3Rpb24gYyA6IGNvbm5lY3Rpb25zKSB7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChERUJVRykgUmxvZy5kKExPR19UQUcsICIgICBzdGF0ZT0iICsgYy5nZXRTdGF0ZSgpICsgIjogIgorICAgICAgICAgICAgICAgIGlmIChTQ19EQkcpIGxvZygiLS0tY2hlY2sgY29ubmVjdGlvbnM6ICIKKyAgICAgICAgICAgICAgICAgICAgICAgICsgbUNvbm5lY3Rpb25zLnNpemUoKSk7CisgICAgICAgICAgICAgICAgZm9yIChDb25uZWN0aW9uIGMgOiBtQ29ubmVjdGlvbnMpIHsKKyAgICAgICAgICAgICAgICAgICAgaWYgKFNDX0RCRykgbG9nKCIgICBzdGF0ZT0iICsgYy5nZXRTdGF0ZSgpICsgIjogIgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgYyk7CiAgICAgICAgICAgICAgICAgICAgIGlmIChjLmdldFN0YXRlKCkgIT0gU3RhdGUuRElTQ09OTkVDVEVEKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBhbGxDb25uZWN0aW9uc0Rpc2Nvbm5lY3RlZCA9IGZhbHNlOwpAQCAtNjAxLDE4ICs3MTIsMjUgQEAKICAgICAgICAgfQogCiAgICAgICAgIHByaXZhdGUgQXVkaW9Hcm91cCBnZXRBdWRpb0dyb3VwKCkgewotICAgICAgICAgICAgaWYgKGNvbm5lY3Rpb25zLmlzRW1wdHkoKSkgcmV0dXJuIG51bGw7Ci0gICAgICAgICAgICByZXR1cm4gKChTaXBDb25uZWN0aW9uKSBjb25uZWN0aW9ucy5nZXQoMCkpLmdldEF1ZGlvR3JvdXAoKTsKKyAgICAgICAgICAgIGlmIChtQ29ubmVjdGlvbnMuaXNFbXB0eSgpKSByZXR1cm4gbnVsbDsKKyAgICAgICAgICAgIHJldHVybiAoKFNpcENvbm5lY3Rpb24pIG1Db25uZWN0aW9ucy5nZXQoMCkpLmdldEF1ZGlvR3JvdXAoKTsKKyAgICAgICAgfQorCisgICAgICAgIHByaXZhdGUgdm9pZCBsb2coU3RyaW5nIHMpIHsKKyAgICAgICAgICAgIFJsb2cuZChTQ19UQUcsIHMpOwogICAgICAgICB9CiAgICAgfQogCiAgICAgcHJpdmF0ZSBjbGFzcyBTaXBDb25uZWN0aW9uIGV4dGVuZHMgU2lwQ29ubmVjdGlvbkJhc2UgeworICAgICAgICBwcml2YXRlIHN0YXRpYyBmaW5hbCBTdHJpbmcgU0NOX1RBRyA9ICJTaXBDb25uZ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wogICAgICAgICAgICAgICAgICAgICBTdHJpbmcgc2Vzc2lvblN0YXRlID0gKHNpcEF1ZGlvQ2FsbCA9PSBudWxsKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgID8gIiIKICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6IChzaXBBdWRpb0NhbGwuZ2V0U3RhdGUoKSArICIsICIpOwotICAgICAgICAgICAgICAgICAgICBpZiAoREVCVUcpIFJsb2cuZChMT0dfVEFHLCAiLS0tIGNvbm5lY3Rpb24gZW5kZWQ6ICIKKyAgICAgICAgICAgICAgICAgICAgaWYgKFNDTl9EQkcpIGxvZygiW1NpcEF1ZGlvQ2FsbEFkYXB0ZXJdIG9uQ2FsbEVuZGVkOiAiCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyBtUGVlci5nZXRVcmlTdHJpbmcoKSArICI6ICIgKyBzZXNzaW9uU3RhdGUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICArICJjYXVzZTogIiArIGdldERpc2Nvbm5lY3RDYXVzZSgpICsgIiwgb24gcGhvbmUgIgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgZ2V0UGhvbmUoKSk7CkBAIC02NDIsMTIgKzc2MSwxNCBAQAogICAgICAgICAgICAgQE92ZXJyaWRlCiAgICAgICAgICAgICBwdWJsaWMgdm9pZCBvbkNhbGxFc3RhYmxpc2hlZChTaXBBdWRpb0NhbGwgY2FsbCkgewogICAgICAgICAgICAgICAgIG9uQ2hhbmdlZChjYWxsKTsKKyAgICAgICAgICAgICAgICAvLyBSYWNlIG9uQ2hhbmdlZCBzeW5jaHJvbml6ZWQgdGhpcyBpc24ndAogICAgICAgICAgICAgICAgIGlmIChtU3RhdGUgPT0gQ2FsbC5TdGF0ZS5BQ1RJVkUpIGNhbGwuc3RhcnRBdWRpbygpOwogICAgICAgICAgICAgfQogCiAgICAgICAgICAgICBAT3ZlcnJpZGUKICAgICAgICAgICAgIHB1YmxpYyB2b2lkIG9uQ2FsbEhlbGQoU2lwQXVkaW9DYWxsIGNhbGwpIHsKICAgICAgICAgICAgICAgICBvbkNoYW5nZWQoY2FsbCk7CisgICAgICAgICAgICAgICAgLy8gUmFjZSBvbkNoYW5nZWQgc3luY2hyb25pemVkIHRoaXMgaXNuJ3QKICAgICAgICAgICAgICAgICBpZiAobVN0YXRlID09IENhbGwuU3RhdGUuSE9MRElORykgY2FsbC5zdGFydEF1ZGlvKCk7CiAgICAgICAgICAgICB9CiAKQEAgLTY1OSw4ICs3ODAsOCBAQAogICAgICAgICAgICAgICAgICAgICBpZiAobmV3U3RhdGUgPT0gQ2FsbC5TdGF0ZS5JTkNPTUlORykgewogICAgICAgICAgICAgICAgICAgICAgICAgc2V0U3RhdGUobU93bmVyLmdldFN0YXRlKCkpOyAvLyBJTkNPTUlORyBvciBXQUlUSU5HCiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBpZiAobU93bmVyID09IHJpbmdpbmdDYWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJpbmdpbmdDYWxsLmdldFN0YXRlKCkgPT0gQ2FsbC5TdGF0ZS5XQUlUSU5HKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAobU93bmVyID09IG1SaW5naW5nQ2FsbCkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtUmluZ2luZ0NhbGwuZ2V0U3RhdGUoKSA9PSBDYWxsLlN0YXRlLldBSVRJTkcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaEhvbGRpbmdBbmRBY3RpdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoQ2FsbFN0YXRlRXhjZXB0aW9uIGUpIHsKQEAgLTY2OSwxMiArNzkwLDEyIEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yZWdyb3VuZENhbGwuc3dpdGNoV2l0aChyaW5naW5nQ2FsbCk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUZvcmVncm91bmRDYWxsLnN3aXRjaFdpdGgobVJpbmdpbmdDYWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgIHNldFN0YXRlKG5ld1N0YXRlKTsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICBtT3duZXIub25Db25uZWN0aW9uU3RhdGVDaGFuZ2VkKFNpcENvbm5lY3Rpb24udGhpcyk7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChERUJVRykgUmxvZy52KExPR19UQUcsICIrKioqKyBjb25uZWN0aW9uIHN0YXRlIGNoYW5nZWQ6ICIKKyAgICAgICAgICAgICAgICAgICAgaWYgKFNDTl9EQkcpIGxvZygib25DaGFuZ2VkOiAiCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyBtUGVlci5nZXRVcmlTdHJpbmcoKSArICI6ICIgKyBtU3RhdGUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICArICIgb24gcGhvbmUgIiArIGdldFBob25lKCkpOwogICAgICAgICAgICAgICAgIH0KQEAgLTY4Miw3ICs4MDMsNyBAQAogCiAgICAgICAgICAgICBAT3ZlcnJpZGUKICAgICAgICAgICAgIHByb3RlY3RlZCB2b2lkIG9uRXJyb3IoRGlzY29ubmVjdENhdXNlIGNhdXNlKSB7Ci0gICAgICAgICAgICAgICAgaWYgKERFQlVHKSBSbG9nLmQoTE9HX1RBRywgIlNJUCBlcnJvcjogIiArIGNhdXNlKTsKKyAgICAgICAgICAgICAgICBpZiAoU0NOX0RCRykgbG9nKCJvbkVycm9yOiAiICsgY2F1c2UpOwogICAgICAgICAgICAgICAgIG9uQ2FsbEVuZGVkKGNhdXNlKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfTsKQEAgLTc2Myw2ICs4ODQsNyBAQAogCiAgICAgICAgIHZvaWQgc2V0TXV0ZShib29sZWFuIG11dGVkKSB7CiAgICAgICAgICAgICBpZiAoKG1TaXBBdWRpb0NhbGwgIT0gbnVsbCkgJiYgKG11dGVkICE9IG1TaXBBdWRpb0NhbGwuaXNNdXRlZCgpKSkgeworICAgICAgICAgICAgICAgIGlmIChTQ05fREJHKSBsb2coInNldFN0YXRlOiBwcmV2IG11dGVkPSIgKyAhbXV0ZWQgKyAiIG5ldyBtdXRlZD0iICsgbXV0ZWQpOwogICAgICAgICAgICAgICAgIG1TaXBBdWRpb0NhbGwudG9nZ2xlTXV0ZSgpOwogICAgICAgICAgICAgfQogICAgICAgICB9CkBAIC04MTAsNyArOTMyLDcgQEAKICAgICAgICAgQE92ZXJyaWRlCiAgICAgICAgIHB1YmxpYyB2b2lkIGhhbmd1cCgpIHRocm93cyBDYWxsU3RhdGVFeGNlcHRpb24gewogICAgICAgICAgICAgc3luY2hyb25pemVkIChTaXBQaG9uZS5jbGFzcykgewotICAgICAgICAgICAgICAgIGlmIChERUJVRykgUmxvZy5kKExPR19UQUcsICJoYW5ndXAgY29ubjogIiArIG1QZWVyLmdldFVyaVN0cmluZygpCisgICAgICAgICAgICAgICAgaWYgKFNDTl9EQkcpIGxvZygiaGFuZ3VwOiBjb25uPSIgKyBtUGVlci5nZXRVcmlTdHJpbmcoKQogICAgICAgICAgICAgICAgICAgICAgICAgKyAiOiAiICsgbVN0YXRlICsgIjogb24gcGhvbmUgIgogICAgICAgICAgICAgICAgICAgICAgICAgKyBnZXRQaG9uZSgpLmdldFBob25lTmFtZSgpKTsKICAgICAgICAgICAgICAgICBpZiAoIW1TdGF0ZS5pc0FsaXZlKCkpIHJldHVybjsKQEAgLTgzNSwxNCArOTU3LDE0IEBACiAgICAgICAgIHB1YmxpYyB2b2lkIHNlcGFyYXRlKCkgdGhyb3dzIENhbGxTdGF0ZUV4Y2VwdGlvbiB7CiAgICAgICAgICAgICBzeW5jaHJvbml6ZWQgKFNpcFBob25lLmNsYXNzKSB7CiAgICAgICAgICAgICAgICAgU2lwQ2FsbCBjYWxsID0gKGdldFBob25lKCkgPT0gU2lwUGhvbmUudGhpcykKLSAgICAgICAgICAgICAgICAgICAgICAgID8gKFNpcENhbGwpIFNpcFBob25lLnRoaXMuZ2V0QmFja2dyb3VuZENhbGwoKQotICAgICAgICAgICAgICAgICAgICAgICAgOiAoU2lwQ2FsbCkgU2lwUGhvbmUudGhpcy5nZXRGb3JlZ3JvdW5kQ2FsbCgpOworICAgICAgICAgICAgICAgICAgICAgICAgPyAoU2lwQ2FsbCkgZ2V0QmFja2dyb3VuZENhbGwoKQorICAgICAgICAgICAgICAgICAgICAgICAgOiAoU2lwQ2FsbCkgZ2V0Rm9yZWdyb3VuZENhbGwoKTsKICAgICAgICAgICAgICAgICBpZiAoY2FsbC5nZXRTdGF0ZSgpICE9IENhbGwuU3RhdGUuSURMRSkgewogICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgQ2FsbFN0YXRlRXhjZXB0aW9uKAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICJjYW5ub3QgcHV0IGNvbm4gYmFjayB0byBhIGNhbGwgaW4gbm9uLWlkbGUgc3RhdGU6ICIKICAgICAgICAgICAgICAgICAgICAgICAgICAgICArIGNhbGwuZ2V0U3RhdGUoKSk7CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIGlmIChERUJVRykgUmxvZy5kKExPR19UQUcsICJzZXBhcmF0ZSBjb25uOiAiCisgICAgICAgICAgICAgICAgaWYgKFNDTl9EQkcpIGxvZygic2VwYXJhdGU6IGNvbm49IgogICAgICAgICAgICAgICAgICAgICAgICAgKyBtUGVlci5nZXRVcmlTdHJpbmcoKSArICIgZnJvbSAiICsgbU93bmVyICsgIiBiYWNr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sLCBpbnQgZXJyb3JDb2RlLAogICAgICAgICAgICAgICAgIFN0cmluZyBlcnJvck1lc3NhZ2UpIHsKKyAgICAgICAgICAgIGlmIChTQUNBX0RCRykgeworICAgICAgICAgICAgICAgIGxvZygib25FcnJvcjogY2FsbD0iICsgY2FsbCArICIgY29kZT0iKyBTaXBFcnJvckNvZGUudG9TdHJpbmcoZXJyb3JDb2RlKQorICAgICAgICAgICAgICAgICAgICArICI6ICIgKyBlcnJvck1lc3NhZ2UpOworICAgICAgICAgICAgfQogICAgICAgICAgICAgc3dpdGNoIChlcnJvckNvZGUpIHsKICAgICAgICAgICAgICAgICBjYXNlIFNpcEVycm9yQ29kZS5TRVJWRVJfVU5SRUFDSEFCTEU6CiAgICAgICAgICAgICAgICAgICAgIG9uRXJyb3IoQ29ubmVjdGlvbi5EaXNjb25uZWN0Q2F1c2UuU0VSVkVSX1VOUkVBQ0hBQkxFKTsKQEAgLTkzMCwxMCArMTA0NiwxMiBAQAogICAgICAgICAgICAgICAgIGNhc2UgU2lwRXJyb3JDb2RlLlNPQ0tFVF9FUlJPUjoKICAgICAgICAgICAgICAgICBjYXNlIFNpcEVycm9yQ29kZS5DTElFTlRfRVJST1I6CiAgICAgICAgICAgICAgICAgZGVmYXVsdDoKLSAgICAgICAgICAgICAgICAgICAgUmxvZy53KExPR19UQUcsICJlcnJvcjogIiArIFNpcEVycm9yQ29kZS50b1N0cmluZyhlcnJvckNvZGUpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgKyAiOiAiICsgZXJyb3JNZXNzYWdlKTsKICAgICAgICAgICAgICAgICAgICAgb25FcnJvcihDb25uZWN0aW9uLkRpc2Nvbm5lY3RDYXVzZS5FUlJPUl9VTlNQRUNJRklFRCk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KKworICAgICAgICBwcml2YXRlIHZvaWQgbG9nKFN0cmluZyBzKSB7CisgICAgICAgICAgICBSbG9nLmQoU0FDQV9UQUcsIHMpOworICAgICAgICB9CiAgICA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ldFZvaWNlTWFpbEFscGhhVGFnKCkgewogICAgICAgICByZXR1cm4gbnVsbDsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgU3RyaW5nIGdldERldmljZUlkKCkgewogICAgICAgICByZXR1cm4gbnVsbDsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgU3RyaW5nIGdldERldmljZVN2bigpIHsKICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFN0cmluZyBnZXRJbWVpKCkgewogICAgICAgICByZXR1cm4gbnVsbDsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgU3RyaW5nIGdldEVzbigpIHsKICAgICAgICAgUmxvZy5lKExPR19UQUcsICJbU2lwUGhvbmVdIGdldEVzbigpIGlzIGEgQ0RNQSBtZXRob2QiKTsKICAgICAgICAgcmV0dXJuICIwIjsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgU3RyaW5nIGdldE1laWQoKSB7CiAgICAgICAgIFJsb2cuZShMT0dfVEFHLCAiW1NpcFBob25lXSBnZXRNZWlkKCkgaXMgYSBDRE1BIG1ldGhvZCIpOwogICAgICAgICByZXR1cm4gIjAiOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdHJpbmcgZ2V0U3Vic2NyaWJlcklkKCkgewogICAgICAgICByZXR1cm4gbnVsbDsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgU3RyaW5nIGdldEljY1NlcmlhbE51bWJlcigpIHsKICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFN0cmluZyBnZXRMaW5lMU51bWJlcigpIHsKICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFN0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0V4Y2VwdGlvbjsKQEAgLTQ1LDE1ICs0NCwxNSBAQAogICAgIHN0YXRpYyBmaW5hbCBpbnQgQlVGRkVSX1NJWkUgPSAweDEwMDA7CiAKICAgICAvLyBqdXN0IHRvIHByZXZlbnQgY29uc3RhbnQgYWxsb2NhdGlvbnMKLSAgICBieXRlIGJ1ZmZlcltdID0gbmV3IGJ5dGVbQlVGRkVSX1NJWkVdOworICAgIGJ5dGUgbUJ1ZmZlcltdID0gbmV3IGJ5dGVbQlVGRkVSX1NJWkVdOwogCiAgICAgLy8qKioqKiBJbnN0YW5jZSBWYXJpYWJsZXMKIAotICAgIElucHV0U3RyZWFtIGluU3RyZWFtOworICAgIElucHV0U3RyZWFtIG1JblN0cmVhbTsKIAogICAgIExpbmVSZWFkZXIgKElucHV0U3RyZWFtIHMpCiAgICAgewotICAgICAgICBpblN0cmVhbSA9IHM7CisgICAgICAgIG1JblN0cmVhbSA9IHM7CiAgICAgfQogCiAgICAgU3RyaW5nCkBAIC04NCw3ICs4Myw3IEBACiAgICAgICAgICAgICBmb3IgKDs7KSB7CiAgICAgICAgICAgICAgICAgaW50IHJlc3VsdDsKIAotICAgICAgICAgICAgICAgIHJlc3VsdCA9IGluU3RyZWFtLnJlYWQoKTsKKyAgICAgICAgICAgICAgICByZXN1bHQgPSBtSW5TdHJlYW0ucmVhZCgpOwogCiAgICAgICAgICAgICAgICAgaWYgKHJlc3VsdCA8IDApIHsKICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CkBAIC0xMDEsNyArMTAwLDcgQEAKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgICAgIGJ1ZmZlcltpKytdID0gKGJ5dGUpcmVzdWx0OworICAgICAgICAgICAgICAgIG1CdWZmZXJbaSsrXSA9IChieXRlKXJlc3VsdDsKICAgICAgICAgICAgIH0KICAgICAgICAgfSBjYXRjaCAoSU9FeGNlcHRpb24gZXgpIHsKICAgICAgICAgIC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ZpbmFsUmVzcG9uc2U7CisgICAgcHJpdmF0ZSBTdHJpbmcgbUZpbmFsUmVzcG9uc2U7CiAKLSAgICBTaW11bGF0ZWRHc21DYWxsU3RhdGUgc2ltdWxhdGVkQ2FsbFN0YXRlOworICAgIFNpbXVsYXRlZEdzbUNhbGxTdGF0ZSBtU2ltdWxhdGVkQ2FsbFN0YXRlOwogCiAgICAgSGFuZGxlclRocmVhZCBtSGFuZGxlclRocmVhZDsKIAotICAgIGludCBwYXVzZWRSZXNwb25zZUNvdW50OwotICAgIE9iamVjdCBwYXVzZWRSZXNwb25zZU1vbml0b3IgPSBuZXcgT2JqZWN0KCk7CisgICAgaW50IG1QYXVzZWRSZXNwb25zZUNvdW50OworICAgIE9iamVjdCBtUGF1c2VkUmVzcG9uc2VNb25pdG9yID0gbmV3IE9iamVjdCgpOwogCiAgICAgLy8qKioqKiBFdmVudHMKIApAQCAtMTY2LDggKzE2NSw4IEBACiAgICAgcHVibGljCiAgICAgTW9kZWxJbnRlcnByZXRlciAoSW5wdXRTdHJlYW0gaW4sIE91dHB1dFN0cmVhbSBvdXQpCiAgICAgewotICAgICAgICB0aGlzLmluID0gaW47Ci0gICAgICAgIHRoaXMub3V0ID0gb3V0OworICAgICAgICBtSW4gPSBpbjsKKyAgICAgICAgbU91dCA9IG91dDsKIAogICAgICAgICBpbml0KCk7CiAgICAgfQpAQCAtMTc1LDEwICsxNzQsMTAgQEAKICAgICBwdWJsaWMKICAgICBNb2RlbEludGVycHJldGVyIChJbmV0U29ja2V0QWRkcmVzcyBzYSkgdGhyb3dzIGphdmEuaW8uSU9FeGNlcHRpb24KICAgICB7Ci0gICAgICAgIHNzID0gbmV3IFNlcnZlclNvY2tldCgpOworICAgICAgICBtU1MgPSBuZXcgU2VydmVyU29ja2V0KCk7CiAKLSAgICAgICAgc3Muc2V0UmV1c2VBZGRyZXNzKHRydWUpOwotICAgICAgICBzcy5iaW5kKHNhKTsKKyAgICAgICAgbVNTLnNldFJldXNlQWRkcmVzcyh0cnVlKTsKKyAgICAgICAgbVNTLmJpbmQoc2EpOwogCiAgICAgICAgIGluaXQoKTsKICAgICB9CkBAIC0xOTAsMTkgKzE4OSwyMCBAQAogICAgICAgICBtSGFuZGxlclRocmVhZCA9IG5ldyBIYW5kbGVyVGhyZWFkKCJNb2RlbEludGVycHJldGVyIik7CiAgICAgICAgIG1IYW5kbGVyVGhyZWFkLnN0YXJ0KCk7CiAgICAgICAgIExvb3BlciBsb29wZXIgPSBtSGFuZGxlclRocmVhZC5nZXRMb29wZXIoKTsKLSAgICAgICAgc2ltdWxhdGVkQ2FsbFN0YXRlID0gbmV3IFNpbXVsYXRlZEdzbUNhbGxTdGF0ZShsb29wZXIpOworICAgICAgICBtU2ltdWxhdGVkQ2FsbFN0YXRlID0gbmV3IFNpbXVsYXRlZEdzbUNhbGxTdGF0ZShsb29wZXIpOwogICAgIH0KIAogICAgIC8vKioqKiogUnVubmFibGUgSW1wbGVtZW50YXRpb24KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHJ1bigpCiAgICAgewogICAgICAgICBmb3IgKDs7KSB7Ci0gICAgICAgICAgICBpZiAoc3MgIT0gbnVsbCkgeworICAgICAgICAgICAgaWYgKG1TUyAhPSBudWxsKSB7CiAgICAgICAgICAgICAgICAgU29ja2V0IHM7CiAKICAgICAgICAgICAgICAgICB0cnkgewotICAgICAgICAgICAgICAgICAgICBzID0gc3MuYWNjZXB0KCk7CisgICAgICAgICAgICAgICAgICAgIHMgPSBtU1MuYWNjZXB0KCk7CiAgICAgICAgICAgICAgICAgfSBjYXRjaCAoamF2YS5pby5JT0V4Y2VwdGlvbiBleCkgewogICAgICAgICAgICAgICAgICAgICBSbG9nLncoTE9HX1RBRywKICAgICAgICAgICAgICAgICAgICAgICAgICJJT0V4Y2VwdGlvbiBvbiBzb2NrZXQuYWNjZXB0KCk7IHN0b3BwaW5nIiwgZXgpOwpAQCAtMjEwLDggKzIxMCw4IEBACiAgICAgICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAgICAgdHJ5IHsKLSAgICAgICAgICAgICAgICAgICAgaW4gPSBzLmdldElucHV0U3RyZWFtKCk7Ci0gICAgICAgICAgICAgICAgICAgIG91dCA9IHMuZ2V0T3V0cHV0U3RyZWFtKCk7CisgICAgICAgICAgICAgICAgICAgIG1JbiA9IHMuZ2V0SW5wdXRTdHJlYW0oKTsKKyAgICAgICAgICAgICAgICAgICAgbU91dCA9IHMuZ2V0T3V0cHV0U3RyZWFtKCk7CiAgICAgICAgICAgICAgICAgfSBjYXRjaCAoamF2YS5pby5JT0V4Y2VwdGlvbiBleCkgewogICAgICAgICAgICAgICAgICAgICBSbG9nLncoTE9HX1RBRywKICAgICAgICAgICAgICAgICAgICAgICAgICJJT0V4Y2VwdGlvbiBvbiBhY2NlcHRlZCBzb2NrZXQoKTsgcmUtbGlzdGVuaW5nIiwgZXgpOwpAQCAtMjIyLDE0ICsyMjIsMTQgQEAKICAgICAgICAgICAgIH0KIAogCi0gICAgICAgICAgICBsaW5lUmVhZGVyID0gbmV3IExpbmVSZWFkZXIgKGluKTsKKyAgICAgICAgICAgIG1MaW5lUmVhZGVyID0gbmV3IExpbmVSZWFkZXIgKG1Jbik7CiAKICAgICAgICAgICAgIHByaW50bG4gKCJXZWxjb21lIik7CiAKICAgICAgICAgICAgIGZvciAoOzspIHsKICAgICAgICAgICAgICAgICBTdHJpbmcgbGluZTsKIAotICAgICAgICAgICAgICAgIGxpbmUgPSBsaW5lUmVhZGVyLmdldE5leHRMaW5lKCk7CisgICAgICAgICAgICAgICAgbGluZSA9IG1MaW5lUmVhZGVyLmdldE5leHRMaW5lKCk7CiAKICAgICAgICAgICAgICAgICAvL1N5c3RlbS5vdXQucHJpbnRsbigiTUk8PCAiICsgbGluZSk7CiAKQEAgLTIzNywxMCArMjM3LDEwIEBACiAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgICAgIHN5bmNocm9uaXplZChwYXVzZWRSZXNwb25zZU1vbml0b3IpIHsKLSAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHBhdXNlZFJlc3BvbnNlQ291bnQgPiAwKSB7CisgICAgICAgICAgICAgICAgc3luY2hyb25pemVkKG1QYXVzZWRSZXNwb25zZU1vbml0b3IpIHsKKyAgICAgICAgICAgICAgICAgICAgd2hpbGUgKG1QYXVzZWRSZXNwb25zZUNvdW50ID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXVzZWRSZXNwb25zZU1vbml0b3Iud2FpdCgpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1QYXVzZWRSZXNwb25zZU1vbml0b3Iud2FpdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoSW50ZXJydXB0ZWRFeGNlcHRpb24gZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgfQpAQCAtMjQ4LDExICsyNDgsMTEgQEAKIAogICAgICAgICAgICAgICAgIHN5bmNocm9uaXplZCAodGhpcykgewogICAgICAgICAgICAgICAgICAgICB0cnkgewotICAgICAgICAgICAgICAgICAgICAgICAgZmluYWxSZXNwb25zZSA9ICJPSyI7CisgICAgICAgICAgICAgICAgICAgICAgICBtRmluYWxSZXNwb25zZSA9ICJPSyI7CiAgICAgICAgICAgICAgICAgICAgICAgICBwcm9jZXNzTGluZShsaW5lKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIHByaW50bG4oZmluYWxSZXNwb25zZSk7CisgICAgICAgICAgICAgICAgICAgICAgICBwcmludGxuKG1GaW5hbFJlc3BvbnNlKTsKICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoSW50ZXJwcmV0ZXJFeCBleCkgewotICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRsbihleC5yZXN1bHQpOworICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRsbihleC5tUmVzdWx0KTsKICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoUnVudGltZUV4Y2VwdGlvbiBleCkgewogICAgICAgICAgICAgICAgICAgICAgICAgZXgucHJpbnRTdGFja1RyYWNlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICBwcmludGxuKCJFUlJPUiIpOwpAQCAtMjYyLDcgKzI2Miw3IEBACiAKICAgICAgICAgICAgIFJsb2cuaShMT0dfVEFHLCAiRGlzY29ubmVjdGVkIik7CiAKLSAgICAgICAgICAgIGlmIChzcyA9PSBudWxsKSB7CisgICAgICAgICAgICBpZiAobVNTID09IG51bGwpIHsKICAgICAgICAgICAgICAgICAvLyBubyByZWNvbm5lY3QgaW4gdGhpcyBjYXNlCiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICB9CkBAIC0yNzMsMTMgKzI3MywxNCBAQAogICAgIC8vKioqKiogSW5zdGFuY2UgTWV0aG9kcwogCiAgICAgLyoqIFN0YXJ0IHRoZSBzaW11bGF0ZWQgcGhvbmUgcmluZ2luZyAqLworICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkCiAgICAgdHJpZ2dlclJpbmcoU3RyaW5nIG51bWJlcikKICAgICB7CiAgICAgICAgIHN5bmNocm9uaXplZCAodGhpcykgewogICAgICAgICAgICAgYm9vbGVhbiBzdWNjZXNzOwogCi0gICAgICAgICAgICBzdWNjZXNzID0gc2ltdWxhdGVkQ2FsbFN0YXRlLnRyaWdnZXJSaW5nKG51bWJlcik7CisgICAgICAgICAgICBzdWNjZXNzID0gbVNpbXVsYXRlZENhbGxTdGF0ZS50cmlnZ2VyUmluZyhudW1iZXIpOwogCiAgICAgICAgICAgICBpZiAoc3VjY2VzcykgewogICAgICAgICAgICAgICAgIHByaW50bG4gKCJSSU5HIik7CkBAIC0yODgsMzUgKzI4OSw0MCBAQAogICAgIH0KIAogICAgIC8qKiBJZiBhIGNhbGwgaXMgRElBTElORyBvciBBTEVSVElORywgcH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iAqKioqKioqKioqKioqKi8KICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZAogICAgIHBhdXNlUmVzcG9uc2VzKCkKICAgICB7Ci0gICAgICAgIHN5bmNocm9uaXplZChwYXVzZWRSZXNwb25zZU1vbml0b3IpIHsKLSAgICAgICAgICAgIHBhdXNlZFJlc3BvbnNlQ291bnQrKzsKKyAgICAgICAgc3luY2hyb25pemVkKG1QYXVzZWRSZXNwb25zZU1vbml0b3IpIHsKKyAgICAgICAgICAgIG1QYXVzZWRSZXNwb25zZUNvdW50Kys7CiAgICAgICAgIH0KICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZAogICAgIHJlc3VtZVJlc3BvbnNlcygpCiAgICAgewotICAgICAgICBzeW5jaHJvbml6ZWQocGF1c2VkUmVzcG9uc2VNb25pdG9yKSB7Ci0gICAgICAgICAgICBwYXVzZWRSZXNwb25zZUNvdW50LS07CisgICAgICAgIHN5bmNocm9uaXplZChtUGF1c2VkUmVzcG9uc2VNb25pdG9yKSB7CisgICAgICAgICAgICBtUGF1c2VkUmVzcG9uc2VDb3VudC0tOwogCi0gICAgICAgICAgICBpZiAocGF1c2VkUmVzcG9uc2VDb3VudCA9PSAwKSB7Ci0gICAgICAgICAgICAgICAgcGF1c2VkUmVzcG9uc2VNb25pdG9yLm5vdGlmeUFsbCgpOworICAgICAgICAgICAgaWYgKG1QYXVzZWRSZXNwb25zZUNvdW50ID09IDApIHsKKyAgICAgICAgICAgICAgICBtUGF1c2VkUmVzcG9uc2VNb25pdG9yLm5vdGlmeUFsbCgpOwogICAgICAgICAgICAgfQogICAgICAgICB9CiAgICAgfQpAQCAtNDMwLDcgKzQ0NCw3IEBACiAgICAgewogICAgICAgICBib29sZWFuIHN1Y2Nlc3M7CiAKLSAgICAgICAgc3VjY2VzcyA9IHNpbXVsYXRlZENhbGxTdGF0ZS5vbkFuc3dlcigpOworICAgICAgICBzdWNjZXNzID0gbVNpbXVsYXRlZENhbGxTdGF0ZS5vbkFuc3dlcigpOwogCiAgICAgICAgIGlmICghc3VjY2VzcykgewogICAgICAgICAgICAgdGhyb3cgbmV3IEludGVycHJldGVyRXgoIkVSUk9SIik7CkBAIC00NDIsMTMgKzQ1NiwxMyBAQAogICAgIHsKICAgICAgICAgYm9vbGVhbiBzdWNjZXNzID0gZmFsc2U7CiAKLSAgICAgICAgc3VjY2VzcyA9IHNpbXVsYXRlZENhbGxTdGF0ZS5vbkFuc3dlcigpOworICAgICAgICBzdWNjZXNzID0gbVNpbXVsYXRlZENhbGxTdGF0ZS5vbkFuc3dlcigpOwogCiAgICAgICAgIGlmICghc3VjY2VzcykgewogICAgICAgICAgICAgdGhyb3cgbmV3IEludGVycHJldGVyRXgoIkVSUk9SIik7CiAgICAgICAgIH0KIAotICAgICAgICBmaW5hbFJlc3BvbnNlID0gIk5PIENBUlJJRVIiOworICAgICAgICBtRmluYWxSZXNwb25zZSA9ICJOTyBDQVJSSUVSIjsKICAgICB9CiAKICAgICBwcml2YXRlIHZvaWQKQEAgLTQ2NSw2NyArNDc5LDcgQEAKICAgICAgICAgICAgIGMxID0gY29tbWFuZC5jaGFyQXQoNyk7CiAgICAgICAgIH0KIAotICAgICAgICBzdWNjZXNzID0gc2ltdWxhdGVkQ2FsbFN0YXRlLm9uQ2hsZChjMCwgYzEpOwotCi0gICAgICAgIGlmICghc3VjY2VzcykgewotICAgICAgICAgICAgdGhyb3cgbmV3IEludGVycHJldGVyRXgoIkVSUk9SIik7Ci0gICAgICAgIH0KLSAgICB9Ci0KLSAgICBwcml2YXRlIHZvaWQKLSAgICByZWxlYXNlSGVsZE9yVURVQigpIHRocm93cyBJbnRlcnByZXRlckV4Ci0gICAgewotICAgICAgICBib29sZWFuIHN1Y2Nlc3M7Ci0KLSAgICAgICAgc3VjY2VzcyA9IHNpbXVsYXRlZENhbGxTdGF0ZS5yZWxlYXNlSGVsZE9yVURVQigpOwotCi0gICAgICAgIGlmICghc3Vj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AoaW50IGkgPSAwLCBzID0gbGluZXMuc2l6ZSgpIDsgaSA8IHMgOyBpKyspIHsKICAgICAgICAgICAgIHByaW50bG4gKGxpbmVzLmdldChpKSk7CkBAIC01NTcsMTIgKzUxMSwxMiBAQAogICAgIH0KIAogICAgIHByaXZhdGUgdm9pZAotICAgIG9uU01TU2VuZChTdHJpbmcgY29tbWFuZCkgdGhyb3dzIEludGVycHJldGVyRXgKKyAgICBvblNNU1NlbmQoU3RyaW5nIGNvbW1hbmQpCiAgICAgewogICAgICAgICBTdHJpbmcgcGR1OwogCiAgICAgICAgIHByaW50ICgiPiAiKTsKLSAgICAgICAgcGR1ID0gbGluZVJlYWRlci5nZXROZXh0TGluZUN0cmxaKCk7CisgICAgICAgIHBkdSA9IG1MaW5lUmVhZGVyLmdldE5leHRMaW5lQ3RybFooKTsKIAogICAgICAgICBwcmludGxuKCIrQ01HUzogMSIpOwogICAgIH0KQEAgLTY1NSw4ICs2MDksOCBAQAogCiAgICAgICAgICAgICAgICAgLy9TeXN0ZW0ub3V0LnByaW50bG4oIk1JPj4gIiArIHMpOwogCi0gICAgICAgICAgICAgICAgb3V0LndyaXRlKGJ5dGVzKTsKLSAgICAgICAgICAgICAgICBvdXQud3JpdGUoJ1xyJyk7CisgICAgICAgICAgICAgICAgbU91dC53cml0ZShieXRlcyk7CisgICAgICAgICAgICAgICAgbU91dC53cml0ZSgnXHInKTsKICAgICAgICAgICAgIH0gY2F0Y2ggKElPRXhjZXB0aW9uIGV4KSB7CiAgICAgICAgICAgICAgICAgZXgucHJpbnRTdGFja1RyYWNlKCk7CiAgICAgICAgICAgICB9CkBAIC02NzIsNyArNjI2LDcgQEAKIAogICAgICAgICAgICAgICAgIC8vU3lzdGVtLm91dC5wcmludGxuKCJNST4+ICIgKyBzICsgIiAobm8gPGNyPikiKTsKIAotICAgICAgICAgICAgICAgIG91dC53cml0ZShieXRlcyk7CisgICAgICAgICAgICAgICAgbU91dC53cml0ZShieXRlcyk7CiAgICAgICAgIC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XN1bHRbMV0gaXMgIGJpdCBlcnJvciByYXRlICgwLTcsIDk5KQogICAgICAqIGFzIGRlZmluZWQgaW4gVFMgMjcuMDA3IDguNQogICAgICAqLworICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIGdldFNpZ25hbFN0cmVuZ3RoIChNZXNzYWdlIHJlc3VsdCkgewogICAgICAgICBpbnQgcmV0W10gPSBuZXcgaW50WzJdOwogCkBAIC03NzUsNiArODExLDcgQEAKICAgICAgKiBAcGFyYW0gYmFuZE1vZGUgb25lIG9mIEJNXypfQkFORAogICAgICAqIEBwYXJhbSByZXN1bHQgaXMgY2FsbGJhY2sgbWVzc2FnZQogICAgICAqLworICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHNldEJhbmRNb2RlIChpbnQgYmFuZE1vZGUsIE1lc3NhZ2UgcmVzdWx0KSB7CiAgICAgICAgIHJlc3VsdFN1Y2Nlc3MocmVzdWx0LCBudWxsKTsKICAgICB9CkBAIC03ODYsNiArODIzLDcgQEAKICAgICAgKiAgICAgICAgKChBc3luY1Jlc3VsdClyZXNwb25zZS5vYmopLnJlc3VsdCAgaXMgYW4gaW50W10gd2l0aCBldmVyeQogICAgICAqICAgICAgICBlbGVtZW50IHJlcHJlc2VudGluZyBvbmUgYXZhaWxhYmxlIEJNXypfQkFORAogICAgICAqLworICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHF1ZXJ5QXZhaWxhYmxlQmFuZE1vZGUgKE1lc3NhZ2UgcmVzdWx0KSB7CiAgICAgICAgIGludCByZXRbXSA9IG5ldyBpbnQgWzRdOwogCkBAIC04MDAsNiArODM4LDcgQEAKICAgICAvKioKICAgICAgKiB7QGluaGVyaXREb2N9CiAgICAgICovCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgc2VuZFRlcm1pbmFsUmVzcG9uc2UoU3RyaW5nIGNvbnRlbnRzLCBNZXNzYWdlIHJlc3BvbnNlKSB7CiAgICAgICA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NpemUoKTsgaSA8IHMgOyBpKyspIHsKLSAgICAgICAgICAgICAgICBwYXVzZWRSZXNwb25zZXMuZ2V0KGkpLnNlbmRUb1RhcmdldCgpOworICAgICAgICBpZiAobVBhdXNlZFJlc3BvbnNlQ291bnQgPT0gMCkgeworICAgICAgICAgICAgZm9yIChpbnQgaSA9IDAsIHMgPSBtUGF1c2VkUmVzcG9uc2VzLnNpemUoKTsgaSA8IHMgOyBpKyspIHsKKyAgICAgICAgICAgICAgICBtUGF1c2VkUmVzcG9uc2VzLmdldChpKS5zZW5kVG9UYXJnZXQoKTsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIHBhdXNlZFJlc3BvbnNlcy5jbGVhcigpOworICAgICAgICAgICAgbVBhdXNlZFJlc3BvbnNlcy5jbGVhcigpOwogICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgUmxvZy5lKCJHU00iLCAiU2ltdWxhdGVkQ29tbWFuZHMucmVzdW1lUmVzcG9uc2VzIDwgMCIpOwogICAgICAgICB9CkBAIC0xMzMzLDggKzE0MzYsOCBAQAogICAgICAgICAgICAgQXN5bmNSZXN1bHQuZm9yTWVzc2FnZShyZXN1bHQpLmV4Y2VwdGlvbgogICAgICAgICAgICAgICAgID0gbmV3IFJ1bnRpbWVFeGNlcHRpb24oIlVuaW1wbGVtZW50ZWQiKTsKIAotICAgICAgICAgICAgaWYgKHBhdXNlZFJlc3BvbnNlQ291bnQgPiAwKSB7Ci0gICAgICAgICAgICAgICAgcGF1c2VkUmVzcG9uc2VzLmFkZChyZXN1bHQpOworICAgICAgICAgICAgaWYgKG1QYXVzZWRSZXNwb25zZUNvdW50ID4gMCkgeworICAgICAgICAgICAgICAgIG1QYXVzZWRSZXNwb25zZXMuYWRkKHJlc3VsdCk7CiAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgIHJlc3VsdC5zZW5kVG9UYXJnZXQoKTsKICAgICAgICAgICAgIH0KQEAgLTEzNDQsOCArMTQ0Nyw4IEBACiAgICAgcHJpdmF0ZSB2b2lkIHJlc3VsdFN1Y2Nlc3MoTWVzc2FnZSByZXN1bHQsIE9iamVjdCByZXQpIHsKICAgICAgICAgaWYgKHJlc3VsdCAhPSBudWxsKSB7CiAgICAgICAgICAgICBBc3luY1Jlc3VsdC5mb3JNZXNzYWdlKHJlc3VsdCkucmVzdWx0ID0gcmV0OwotICAgICAgICAgICAgaWYgKHBhdXNlZFJlc3BvbnNlQ291bnQgPiAwKSB7Ci0gICAgICAgICAgICAgICAgcGF1c2VkUmVzcG9uc2VzLmFkZChyZXN1bHQpOworICAgICAgICAgICAgaWYgKG1QYXVzZWRSZXNwb25zZUNvdW50ID4gMCkgeworICAgICAgICAgICAgICAgIG1QYXVzZWRSZXNwb25zZXMuYWRkKHJlc3VsdCk7CiAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgIHJlc3VsdC5zZW5kVG9UYXJnZXQoKTsKICAgICAgICAgICAgIH0KQEAgLTEzNTUsOCArMTQ1OCw4IEBACiAgICAgcHJpdmF0ZSB2b2lkIHJlc3VsdEZhaWwoTWVzc2FnZSByZXN1bHQsIFRocm93YWJsZSB0cikgewogICAgICAgICBpZiAocmVzdWx0ICE9IG51bGwpIHsKICAgICAgICAgICAgIEFzeW5jUmVzdWx0LmZvck1lc3NhZ2UocmVzdWx0KS5leGNlcHRpb24gPSB0cjsKLSAgICAgICAgICAgIGlmIChwYXVzZWRSZXNwb25zZUNvdW50ID4gMCkgewotICAgICAgICAgICAgICAgIHBhdXNlZFJlc3BvbnNlcy5hZGQocmVzdWx0KTsKKyAgICAgICAgICAgIGlmIChtUGF1c2VkUmVzcG9uc2VDb3VudCA+IDApIHsKKyAgICAgICAgICAgICAgICBtUGF1c2VkUmVzcG9uc2VzLmFkZChyZXN1bHQpOwogICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICByZXN1bHQuc2VuZFRvVGFyZ2V0KCk7CiAgICAgICAgICAgICB9CkBAIC0xMzY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5udW1iZXIgPSBudW1iZXI7CisgICAgICAgIG1Jc01UID0gaXNNVDsKKyAgICAgICAgbVN0YXRlID0gc3RhdGU7CisgICAgICAgIG1Jc01wdHkgPSBpc01wdHk7CisgICAgICAgIG1OdW1iZXIgPSBudW1iZXI7CiAKICAgICAgICAgaWYgKG51bWJlci5sZW5ndGgoKSA+IDAgJiYgbnVtYmVyLmNoYXJBdCgwKSA9PSAnKycpIHsKLSAgICAgICAgICAgIFRPQSA9IFBob25lTnVtYmVyVXRpbHMuVE9BX0ludGVybmF0aW9uYWw7CisgICAgICAgICAgICBtVE9BID0gUGhvbmVOdW1iZXJVdGlscy5UT0FfSW50ZXJuYXRpb25hbDsKICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgIFRPQSA9IFBob25lTnVtYmVyVXRpbHMuVE9BX1Vua25vd247CisgICAgICAgICAgICBtVE9BID0gUGhvbmVOdW1iZXJVdGlscy5UT0FfVW5rbm93bjsKICAgICAgICAgfQogICAgIH0KIApAQCAtNzUsOSArNzUsOSBAQAogICAgIHRvQ0xDQ0xpbmUoaW50IGluZGV4KSB7CiAgICAgICAgIHJldHVybgogICAgICAgICAgICAgIitDTENDOiAiCi0gICAgICAgICAgICArIGluZGV4ICsgIiwiICsgKGlzTVQgPyAiMSIgOiAiMCIpICsiLCIKLSAgICAgICAgICAgICsgc3RhdGUudmFsdWUoKSArICIsMCwiICsgKGlzTXB0eSA/ICIxIiA6ICIwIikKLSAgICAgICAgICAgICsgIixcIiIgKyBudW1iZXIgKyAiXCIsIiArIFRPQTsKKyAgICAgICAgICAgICsgaW5kZXggKyAiLCIgKyAobUlzTVQgPyAiMSIgOiAiMCIpICsiLCIKKyAgICAgICAgICAgICsgbVN0YXRlLnZhbHVlKCkgKyAiLDAsIiArIChtSXNNcHR5ID8gIjEiIDogIjAiKQorICAgICAgICAgICAgKyAiLFwiIiArIG1OdW1iZXIgKyAiXCIsIiArIG1UT0E7CiAgICAgfQogCiAgICAgRHJpdmVyQ2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ZXIobG9vcGVyKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZAogICAgIGhhbmRsZU1lc3NhZ2UoTWVzc2FnZSBtc2cpIHsKICAgICAgICAgc3luY2hyb25pemVkKHRoaXMpIHsgc3dpdGNoIChtc2cud2hhdCkgewpAQCAtMTgwLDE0ICsxODEsMTQgQEAKICAgICAgICAgICAgIGJvb2xlYW4gaXNDYWxsV2FpdGluZyA9IGZhbHNlOwogCiAgICAgICAgICAgICAvLyBlbnN1cmUgdGhlcmUgYXJlbid0IGFscmVhZHkgY2FsbHMgSU5DT01JTkcgb3IgV0FJVElORwotICAgICAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgY2FsbHMubGVuZ3RoIDsgaSsrKSB7Ci0gICAgICAgICAgICAgICAgQ2FsbEluZm8gY2FsbCA9IGNhbGxzW2ldOworICAgICAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgbUNhbGxzLmxlbmd0aCA7IGkrKykgeworICAgICAgICAgICAgICAgIENhbGxJbmZvIGNhbGwgPSBtQ2FsbHNbaV07CiAKICAgICAgICAgICAgICAgICBpZiAoY2FsbCA9PSBudWxsICYmIGVtcHR5IDwgMCkgewogICAgICAgICAgICAgICAgICAgICBlbXB0eSA9IGk7CiAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjYWxsICE9IG51bGwKLSAgICAgICAgICAgICAgICAgICAgJiYgKGNhbGwuc3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuSU5DT01JTkcKLSAgICAgICAgICAgICAgICAgICAgICAgIHx8IGNhbGwuc3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuV0FJVElORykKKyAgICAgICAgICAgICAgICAgICAgJiYgKGNhbGwubVN0YXRlID09IENhbGxJbmZvLlN0YXRlLklOQ09NSU5HCisgICAgICAgICAgICAgICAgICAgICAgICB8fCBjYWxsLm1TdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5XQUlUSU5HKQogICAgICAgICAgICAgICAgICkgewogICAgICAgICAgICAgICAgICAgICBSbG9nLncoIk1vZGVsSW50ZXJwcmV0ZXIiLAogICAgICAgICAgICAgICAgICAgICAgICAgInRyaWdnZXJSaW5nIGZhaWxlZDsgcGhvbmUgYWxyZWFkeSByaW5naW5nIik7CkBAIC0yMDIsMTEgKzIwMywxMSBAQAogICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgY2FsbHNbZW1wdHldID0gQ2FsbEluZm8uY3JlYXRlSW5jb21pbmdDYWxsKAorICAgICAgICAgICAgbUNhbGxzW2VtcHR5XSA9IENhbGxJbmZvLmNyZWF0ZUluY29taW5nQ2FsbCgKICAgICAgICAgICAgICAgICBQaG9uZU51bWJlclV0aWxzLmV4dHJhY3ROZXR3b3JrUG9ydGlvbihudW1iZXIpKTsKIAogICAgICAgICAgICAgaWYgKGlzQ2FsbFdhaXRpbmcpIHsKLSAgICAgICAgICAgICAgICBjYWxsc1tlbXB0eV0uc3RhdGUgPSBDYWxsSW5mby5TdGF0ZS5XQUlUSU5HOworICAgICAgICAgICAgICAgIG1DYWxsc1tlbXB0eV0ubVN0YXRlID0gQ2FsbEluZm8uU3RhdGUuV0FJVElORzsKICAgICAgICAgICAgIH0KIAogICAgICAgICB9CkBAIC0yMTcsMjIgKzIxOCwyMiBAQAogICAgIHB1YmxpYyB2b2lkCiAgICAgcHJvZ3Jlc3NDb25uZWN0aW5nQ2FsbFN0YXRlKCkgewogICAgICAgICBzeW5jaHJvbml6ZWQgKHRoaXMpICB7Ci0gICAgICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBjYWxscy5sZW5ndGggOyBpKyspIHsKLSAgICAgICAgICAgICAgICBDYWxsSW5mbyBjYWxsID0gY2FsbHNbaV07CisgICAgICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBtQ2FsbHMubGVuZ3RoIDsgaSsrKSB7CisgICAgICAgICAgICAgICAgQ2FsbEluZm8gY2FsbCA9IG1DYWxsc1tpXTsKIAotICAgICAgICAgICAgICAgIGlmIChjYWxsICE9IG51bGwgJiYgY2FsbC5zdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5ESUFMSU5HKSB7Ci0gICAgICAgICAgICAgICAgICAgIGNhbGwuc3RhdGUgPSBDYWxsSW5mby5TdGF0ZS5BTEVSVElORzsKKyAgICAgICAgICAgICAgICBpZiAoY2FsbCAhPSBudWxsICYmIGNhbGwubVN0YXRlID09IENhbGxJbmZvLlN0YXRlLkRJQUxJTkcpIHsKKyAgICAgICAgICAgICAgICAgICAgY2FsbC5tU3RhdGUgPSBDYWxsSW5mby5TdGF0ZS5BTEVSVElORzsKIAotICAgICAgICAgICAgICAgICAgICBpZiAoYXV0b1Byb2dyZXNzQ29ubmVjdGluZykgeworICAgICAgICAgICAgICAgICAgICBpZiAobUF1dG9Qcm9ncmVzc0Nvbm5lY3RpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIHNlbmRNZXNzYWdlRGVsYXllZCgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZShFVkVOVF9QUk9HUkVTU19DQUxMX1NUQVRFLCBjYWxsKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ09OTkVDVElOR19QQVVTRV9NU0VDKTsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNhbGwgIT0gbnVsbAotICAgICAgICAgICAgICAgICAgICAgICAgJiYgY2FsbC5zdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5BTEVSVElORworICAgICAgICAgICAgICAgICAgICAgICAgJiYgY2FsbC5tU3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuQUxFUlRJTkcKICAgICAgICAgICAgICAgICApIHsKLSAgICAgICAgICAgICAgICAgICAgY2FsbC5zdGF0ZSA9IENhbGxJbmZvLlN0YXRlLkFDVElWRTsKKyAgICAgICAgICAgICAgICAgICAgY2FsbC5tU3RhdGUgPSBDYWxsSW5mby5TdGF0ZS5BQ1RJVkU7CiAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KQEAgLTI0MywxMyArMjQ0LDEzIEBACiAgICAgcHVibGljIHZvaWQKICAgICBwcm9ncmVzc0Nvbm5lY3RpbmdUb0FjdGl2ZSgpIHsKICAgICAgICAgc3luY2hyb25pemVkICh0aGlzKSAgewotICAgICAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgY2FsbHMubGVuZ3RoIDsgaSsrKSB7Ci0gICAgICAgICAgICAgICAgQ2FsbEluZm8gY2FsbCA9IGNhbGxzW2ldOworICAgICAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgbUNhbGxzLmxlbmd0aCA7IGkrKykgeworICAgICAgICAgICAgICAgIENhbGxJbmZvIGNhbGwgPSBtQ2FsbHNbaV07CiAKLSAgICAgICAgICAgICAgICBpZiAoY2FsbCAhPSBudWxsICYmIChjYWxsLnN0YXRlID09IENhbGxJbmZvLlN0YXRlLkRJQUxJTkcKLSAgICAgICAgICAgICAgICAgICAgfHwgY2FsbC5zdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5BTEVSVElORykKKyAgICAgICAgICAgICAgICBpZiAoY2FsbCAhPSBudWxsICYmIChjYWxsLm1TdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5ESUFMSU5HCisgICAgICAgICAgICAgICAgICAgIHx8IGNhbGwubVN0YXRlID09IENhbGxJbmZvLlN0YXRlLkFMRVJUSU5HKQogICAgICAgICAgICAgICAgICkgewotICAgICAgICAgICAgICAgICAgICBjYWxsLnN0YXRlID0gQ2FsbEluZm8uU3RhdGUuQUNUSVZFOworICAgICAgICAgICAgICAgICAgICBjYWxsLm1TdGF0ZSA9IENhbGxJbmZvLlN0YXRlLkFDVElWRTsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQpAQCAtMjYxLDEyICsyNjIsMTIgQEAKICAgICAgKi8KICAgICBwdWJsaWMgdm9pZAogICAgIHNldEF1dG9Qcm9ncmVzc0Nvbm5lY3RpbmdDYWxsKGJvb2xlYW4gYikgewotICAgICAgICBhdXRvUHJvZ3Jlc3NDb25uZWN0aW5nID0gYjsKKyAgICAgICAgbUF1dG9Qcm9ncmVzc0Nvbm5lY3RpbmcgPSBiOwogICAgIH0KIAogICAgIHB1YmxpYyB2b2lkCiAgICAgc2V0TmV4dERpYWxGYWlsSW1tZWRpYXRlbHkoYm9vbGVhbiBiKSB7Ci0gICAgICAgIG5leHREaWFsRmFpbEltbWVkaWF0ZWx5ID0gYjsKKyAgICAgICAgbU5leHREaWFsRmFpbEltbWVkaWF0ZWx5ID0gYjsKICAgICB9CiAKICAgICAvKioKQEAgLTI4MCwyNyArMjgxLDI3IEBACiAKICAgICAgICAgICAgIGZvdW5kID0gZmFsc2U7CiAKLSAgICAgICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IGNhbGxzLmxlbmd0aCA7IGkrKykgewotICAgICAgICAgICAgICAgIENhbGxJbmZvIGNhbGwgPSBjYWxsc1tpXTsKKyAgICAgICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IG1DYWxscy5sZW5ndGggOyBpKyspIHsKKyAgICAgICAgICAgICAgICBDYWxsSW5mbyBjYWxsID0gbUNhbGxzW2ldOwogCiAgICAgICAgICAgICAgICAgaWYgKGNhbGwgIT0gbnVsbAotICAgICAgICAgICAgICAgICAgICAmJiAoY2FsbC5zdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5JTkNPTUlORwotICAgICAgICAgICAgICAgICAgICAgICAgfHwgY2FsbC5zdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5XQUlUSU5HKQorICAgICAgICAgICAgICAgICAgICAmJiAoY2FsbC5tU3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuSU5DT01JTkcKKyAgICAgICAgICAgICAgICAgICAgICAgIHx8IGNhbGwubVN0YXRlID09IENhbGxJbmZvLlN0YXRlLldBSVRJTkcpCiAgICAgICAgICAgICAgICAgKSB7Ci0gICAgICAgICAgICAgICAgICAgIGNhbGxzW2ldID0gbnVsbDsKKyAgICAgICAgICAgICAgICAgICAgbUNhbGxzW2ldID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgZm91bmQgPSB0cnVlOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgY2FsbHMubGVuZ3RoIDsgaSsrKSB7Ci0gICAgICAgICAgICAgICAgQ2FsbEluZm8gY2FsbCA9IGNhbGxzW2ldOworICAgICAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgbUNhbGxzLmxlbmd0aCA7IGkrKykgeworICAgICAgICAgICAgICAgIENhbGxJbmZvIGNhbGwgPSBtQ2FsbHNbaV07CiAKICAgICAgICAgICAgICAgICBpZiAoY2FsbCAhPSBudWxsCi0gICAgICAgICAgICAgICAgICAgICYmIChjYWxsLnN0YXRlID09IENhbGxJbmZvLlN0YXRlLkRJQUxJTkcKLSAgICAgICAgICAgICAgICAgICAgICAgIHx8IGNhbGwuc3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuQUNUSVZFCi0gICAgICAgICAgICAgICAgICAgICAgICB8fCBjYWxsLnN0YXRlID09IENhbGxJbmZvLlN0YXRlLkFMRVJUSU5HKQorICAgICAgICAgICAgICAgICAgICAmJiAoY2FsbC5tU3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuRElBTElORworICAgICAgICAgICAgICAgICAgICAgICAgfHwgY2FsbC5tU3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuQUNUSVZFCisgICAgICAgICAgICAgICAgICAgICAgICB8fCBjYWxsLm1TdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5BTEVSVElORykKICAgICAgICAgICAgICAgICApIHsKLSAgICAgICAgICAgICAgICAgICAgY2FsbHNbaV0gPSBudWxsOworICAgICAgICAgICAgICAgICAgICBtQ2FsbHNbaV0gPSBudWxsOwogICAgICAgICAgICAgICAgICAgICBmb3VuZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQpAQCAtMzE3LDExICszMTgsMTEgQEAKICAgICAgICAgc3luY2hyb25pemVkICh0aGlzKSB7CiAgICAgICAgICAgICBib29sZWFuIGZvdW5kID0gZmFsc2U7CiAKLSAgICAgICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IGNhbGxzLmxlbmd0aCA7IGkrKykgewotICAgICAgICAgICAgICAgIENhbGxJbmZvIGNhbGwgPSBjYWxsc1tpXTsKKyAgICAgICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IG1DYWxscy5sZW5ndGggOyBpKyspIHsKKyAgICAgICAgICAgICAgICBDYWxsSW5mbyBjYWxsID0gbUNhbGxzW2ldOwogCi0gICAgICAgICAgICAgICAgaWYgKGNhbGwgIT0gbnVsbCAmJiBjYWxsLnN0YXRlID09IENhbGxJbmZvLlN0YXRlLkhPTERJTkcpIHsKLSAgICAgICAgICAgICAgICAgICAgY2FsbHNbaV0gPSBudWxsOworICAgICAgICAgICAgICAgIGlmIChjYWxsICE9IG51bGwgJiYgY2FsbC5tU3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuSE9MRElORykgeworICAgICAgICAgICAgICAgICAgICBtQ2FsbHNbaV0gPSBudWxsOwogICAgICAgICAgICAgICAgICAgICBmb3VuZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQpAQCAtMzM5LDE0ICszNDAsMTQgQEAKICAgICAgICAgc3luY2hyb25pemVkKHRoaXMpIHsKICAgICAgICAgICAgIGJvb2xlYW4gZm91bmQgPSBmYWxzZTsKIAotICAgICAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgY2FsbHMubGVuZ3RoIDsgaSsrKSB7Ci0gICAgICAgICAgICAgICAgQ2FsbEluZm8gY2FsbCA9IGNhbGxzW2ldOworICAgICAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgbUNhbGxzLmxlbmd0aCA7IGkrKykgeworICAgICAgICAgICAgICAgIENhbGxJbmZvIGNhbGwgPSBtQ2FsbHNbaV07CiAKLSAgICAgICAgICAgICAgICBpZiAoY2FsbHNbaV0gIT0gbnVsbCkgeworICAgICAgICAgICAgICAgIGlmIChtQ2FsbHNbaV0gIT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICBmb3VuZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgfQogCi0gICAgICAgICAgICAgICAgY2FsbHNbaV0gPSBudWxsOworICAgICAgICAgICAgICAgIG1DYWxsc1tpXSA9IG51bGw7CiAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgIHJldHVybiBmb3VuZDsKQEAgLTM1NiwxMiArMzU3LDEyIEBACiAgICAgcHVibGljIGJvb2xlYW4KICAgICBvbkFuc3dlcigpIHsKICAgICAgICAgc3luY2hyb25pemVkICh0aGlzKSB7Ci0gICAgICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBjYWxscy5sZW5ndGggOyBpKyspIHsKLSAgICAgICAgICAgICAgICBDYWxsSW5mbyBjYWxsID0gY2FsbHNbaV07CisgICAgICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBtQ2FsbHMubGVuZ3RoIDsgaSsrKSB7CisgICAgICAgICAgICAgICAgQ2FsbEluZm8gY2FsbCA9IG1DYWxsc1tpXTsKIAogICAgICAgICAgICAgICAgIGlmIChjYWxsICE9IG51bGwKLSAgICAgICAgICAgICAgICAgICAgJiYgKGNhbGwuc3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuSU5DT01JTkcKLSAgICAgICAgICAgICAgICAgICAgICAgIHx8IGNhbGwuc3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuV0FJVElORykKKyAgICAgICAgICAgICAgICAgICAgJiYgKGNhbGwubVN0YXRlID09IENhbGxJbmZvLlN0YXRlLklOQ09NSU5HCisgICAgICAgICAgICAgICAgICAgICAgICB8fCBjYWxsLm1TdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5XQUlUSU5HKQogICAgICAgICAgICAgICAgICkgewogICAgICAgICAgICAgICAgICAgICByZXR1cm4gc3dpdGNoQWN0aXZlQW5kSGVsZE9yV2FpdGluZygpOwogICAgICAgICAgICAgICAgIH0KQEAgLTM3NSwxMSArMzc2LDExIEBACiAgICAgb25IYW5ndXAoKSB7CiAgICAgICAgIGJvb2xlYW4gZm91bmQgPSBmYWxzZTsKIAotICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBjYWxscy5sZW5ndGggOyBpKyspIHsKLSAgICAgICAgICAgIENhbGxJbmZvIGNhbGwgPSBjYWxsc1tpXTsKKyAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgbUNhbGxzLmxlbmd0aCA7IGkrKykgeworICAgICAgICAgICAgQ2FsbEluZm8gY2FsbCA9IG1DYWxsc1tpXTsKIAotICAgICAgICAgICAgaWYgKGNhbGwgIT0gbnVsbCAmJiBjYWxsLnN0YXRlICE9IENhbGxJbmZvLlN0YXRlLldBSVRJTkcpIHsKLSAgICAgICAgICAgICAgICBjYWxsc1tpXSA9IG51bGw7CisgICAgICAgICAgICBpZiAoY2FsbCAhPSBudWxsICYmIGNhbGwubVN0YXRlICE9IENhbGxJbmZvLlN0YXRlLldBSVRJTkcpIHsKKyAgICAgICAgICAgICAgICBtQ2FsbHNbaV0gPSBudWxsOwogICAgICAgICAgICAgICAgIGZvdW5kID0gdHJ1ZTsKICAgICAgICAgICAgIH0KICAgICAgICAgfQpAQCAtMzk1LDcgKzM5Niw3IEBACiAgICAgICAgIGlmIChjMSAhPSAwKSB7CiAgICAgICAgICAgICBjYWxsSW5kZXggPSBjMSAtICcxJzsKIAotICAgICAgICAgICAgaWYgKGNhbGxJbmRleCA8IDAgfHwgY2FsbEluZGV4ID49IGNhbGxzLmxlbmd0aCkgeworICAgICAgICAgICAgaWYgKGNhbGxJbmRleCA8IDAgfHwgY2FsbEluZGV4ID49IG1DYWxscy5sZW5ndGgpIHsKICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KQEAgLTQwOCwxMCArNDA5LDEwIEBACiAgICAgICAgICAgICAgICAgaWYgKGMxIDw9IDApIHsKICAgICAgICAgICAgICAgICAgICAgcmV0ID0gcmVsZWFzZUFjdGl2ZUFjY2VwdEhlbGRPcldhaXRpbmcoKTsKICAgICAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgICAgICBpZiAoY2FsbHNbY2FsbEluZGV4XSA9PSBudWxsKSB7CisgICAgICAgICAgICAgICAgICAgIGlmIChtQ2FsbHNbY2FsbEluZGV4XSA9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICByZXQgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxzW2NhbGxJbmRleF0gPSBudWxsOworICAgICAgICAgICAgICAgICAgICAgICAgbUNhbGxzW2NhbGxJbmRleF0gPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgcmV0ID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0KQEAgLTQ0NywyMyArNDQ4LDIzIEBACiAgICAgcmVsZWFzZUhlbGRPclVEVUIoKSB7CiAgICAgICAgIGJvb2xlYW4gZm91bmQgPSBmYWxzZTsKIAotICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBjYWxscy5sZW5ndGggOyBpKyspIHsKLSAgICAgICAgICAgIENhbGxJbmZvIGMgPSBjYWxsc1tpXTsKKyAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgbUNhbGxzLmxlbmd0aCA7IGkrKykgeworICAgICAgICAgICAgQ2FsbEluZm8gYyA9IG1DYWxsc1tpXTsKIAogICAgICAgICAgICAgaWYgKGMgIT0gbnVsbCAmJiBjLmlzUmluZ2luZygpKSB7CiAgICAgICAgICAgICAgICAgZm91bmQgPSB0cnVlOwotICAgICAgICAgICAgICAgIGNhbGxzW2ldID0gbnVsbDsKKyAgICAgICAgICAgICAgICBtQ2FsbHNbaV0gPSBudWxsOwogICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgfQogICAgICAgICB9CiAKICAgICAgICAgaWYgKCFmb3VuZCkgewotICAgICAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgY2FsbHMubGVuZ3RoIDsgaSsrKSB7Ci0gICAgICAgICAgICAgICAgQ2FsbEluZm8gYyA9IGNhbGxzW2ldOworICAgICAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgbUNhbGxzLmxlbmd0aCA7IGkrKykgeworICAgICAgICAgICAgICAgIENhbGxJbmZvIGMgPSBtQ2FsbHNbaV07CiAKLSAgICAgICAgICAgICAgICBpZiAoYyAhPSBudWxsICYmIGMuc3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuSE9MRElORykgeworICAgICAgICAgICAgICAgIGlmIChjICE9IG51bGwgJiYgYy5tU3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuSE9MRElORykgewogICAgICAgICAgICAgICAgICAgICBmb3VuZCA9IHRydWU7Ci0gICAgICAgICAgICAgICAgICAgIGNhbGxzW2ldID0gbnVsbDsKKyAgICAgICAgICAgICAgICAgICAgbUNhbGxzW2ldID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgLy8gZG9uJ3Qgc3RvcC4uLnRoZXJlIG1heSBiZSBtb3JlIHRoYW4gb25lCiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQpAQCAtNDc4LDExICs0NzksMTEgQEAKICAgICAgICAgYm9vbGVhbiBmb3VuZEhlbGQgPSBmYWxzZTsKICAgICAgICAgYm9vbGVhbiBmb3VuZEFjdGl2ZSA9IGZhbHNlOwogCi0gICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IGNhbGxzLmxlbmd0aCA7IGkrKykgewotICAgICAgICAgICAgQ2FsbEluZm8gYyA9IGNhbGxzW2ldOworICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBtQ2FsbHMubGVuZ3RoIDsgaSsrKSB7CisgICAgICAgICAgICBDYWxsSW5mbyBjID0gbUNhbGxzW2ldOwogCi0gICAgICAgICAgICBpZiAoYyAhPSBudWxsICYmIGMuc3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuQUNUSVZFKSB7Ci0gICAgICAgICAgICAgICAgY2FsbHNbaV0gPSBudWxsOworICAgICAgICAgICAgaWYgKGMgIT0gbnVsbCAmJiBjLm1TdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5BQ1RJVkUpIHsKKyAgICAgICAgICAgICAgICBtQ2FsbHNbaV0gPSBudWxsOwogICAgICAgICAgICAgICAgIGZvdW5kQWN0aXZlID0gdHJ1ZTsKICAgICAgICAgICAgIH0KICAgICAgICAgfQpAQCAtNDkwLDI0ICs0OTEsMjQgQEAKICAgICAgICAgaWYgKCFmb3VuZEFjdGl2ZSkgewogICAgICAgICAgICAgLy8gRklYTUUgdGhpcyBtYXkgbm90IGFjdHVhbGx5IGJlIGhvdyBtb3N0IGJhc2ViYW5kcyByZWFjdAogICAgICAgICAgICAgLy8gQ0hMRD0xIG1heSBub3QgaGFuZyB1cCBkaWFsaW5nL2FsZXJ0aW5nIGNhbGxzCi0gICAgICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBjYWxscy5sZW5ndGggOyBpKyspIHsKLSAgICAgICAgICAgICAgICBDYWxsSW5mbyBjID0gY2FsbHNbaV07CisgICAgICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBtQ2FsbHMubGVuZ3RoIDsgaSsrKSB7CisgICAgICAgICAgICAgICAgQ2FsbEluZm8gYyA9IG1DYWxsc1tpXTsKIAogICAgICAgICAgICAgICAgIGlmIChjICE9IG51bGwKLSAgICAgICAgICAgICAgICAgICAgICAgICYmIChjLnN0YXRlID09IENhbGxJbmZvLlN0YXRlLkRJQUxJTkcKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICB8fCBjLnN0YXRlID09IENhbGxJbmZvLlN0YXRlLkFMRVJUSU5HKQorICAgICAgICAgICAgICAgICAgICAgICAgJiYgKGMubVN0YXRlID09IENhbGxJbmZvLlN0YXRlLkRJQUxJTkcKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB8fCBjLm1TdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5BTEVSVElORykKICAgICAgICAgICAgICAgICApIHsKLSAgICAgICAgICAgICAgICAgICAgY2FsbHNbaV0gPSBudWxsOworICAgICAgICAgICAgICAgICAgICBtQ2FsbHNbaV0gPSBudWxsOwogICAgICAgICAgICAgICAgICAgICBmb3VuZEFjdGl2ZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogICAgICAgICB9CiAKLSAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgY2FsbHMubGVuZ3RoIDsgaSsrKSB7Ci0gICAgICAgICAgICBDYWxsSW5mbyBjID0gY2FsbHNbaV07CisgICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IG1DYWxscy5sZW5ndGggOyBpKyspIHsKKyAgICAgICAgICAgIENhbGxJbmZvIGMgPSBtQ2FsbHNbaV07CiAKLSAgICAgICAgICAgIGlmIChjICE9IG51bGwgJiYgYy5zdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5IT0xESU5HKSB7Ci0gICAgICAgICAgICAgICAgYy5zdGF0ZSA9IENhbGxJbmZvLlN0YXRlLkFDVElWRTsKKyAgICAgICAgICAgIGlmIChjICE9IG51bGwgJiYgYy5tU3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuSE9MRElORykgeworICAgICAgICAgICAgICAgIGMubVN0YXRlID0gQ2FsbEluZm8uU3RhdGUuQUNUSVZFOwogICAgICAgICAgICAgICAgIGZvdW5kSGVsZCA9IHRydWU7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KQEAgLTUxNiwxMSArNTE3LDExIEBACiAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgfQogCi0gICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IGNhbGxzLmxlbmd0aCA7IGkrKykgewotICAgICAgICAgICAgQ2FsbEluZm8gYyA9IGNhbGxzW2ldOworICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBtQ2FsbHMubGVuZ3RoIDsgaSsrKSB7CisgICAgICAgICAgICBDYWxsSW5mbyBjID0gbUNhbGxzW2ldOwogCiAgICAgICAgICAgICBpZiAoYyAhPSBudWxsICYmIGMuaXNSaW5naW5nKCkpIHsKLSAgICAgICAgICAgICAgICBjLnN0YXRlID0gQ2FsbEluZm8uU3RhdGUuQUNUSVZFOworICAgICAgICAgICAgICAgIGMubVN0YXRlID0gQ2FsbEluZm8uU3RhdGUuQUNUSVZFOwogICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgfQogICAgICAgICB9CkBAIC01MzMsMjYgKzUzNCwyNiBAQAogICAgICAgICBib29sZWFuIGhhc0hlbGQgPSBmYWxzZTsKIAogICAgICAgICAvLyBmaXJzdCwgYXJlIHRoZXJlIGhlbGQgY2FsbHM/Ci0gICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IGNhbGxzLmxlbmd0aCA7IGkrKykgewotICAgICAgICAgICAgQ2FsbEluZm8gYyA9IGNhbGxzW2ldOworICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBtQ2FsbHMubGVuZ3RoIDsgaSsrKSB7CisgICAgICAgICAgICBDYWxsSW5mbyBjID0gbUNhbGxzW2ldOwogCi0gICAgICAgICAgICBpZiAoYyAhPSBudWxsICYmIGMuc3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuSE9MRElORykgeworICAgICAgICAgICAgaWYgKGMgIT0gbnVsbCAmJiBjLm1TdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5IT0xESU5HKSB7CiAgICAgICAgICAgICAgICAgaGFzSGVsZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KIAogICAgICAgICAvLyBOb3csIHN3aXRjaAotICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBjYWxscy5sZW5ndGggOyBpKyspIHsKLSAgICAgICAgICAgIENhbGxJbmZvIGMgPSBjYWxsc1tpXTsKKyAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgbUNhbGxzLmxlbmd0aCA7IGkrKykgeworICAgICAgICAgICAgQ2FsbEluZm8gYyA9IG1DYWxsc1tpXTsKIAogICAgICAgICAgICAgaWYgKGMgIT0gbnVsbCkgewotICAgICAgICAgICAgICAgIGlmIChjLnN0YXRlID09IENhbGxJbmZvLlN0YXRlLkFDVElWRSkgewotICAgICAgICAgICAgICAgICAgICBjLnN0YXRlID0gQ2FsbEluZm8uU3RhdGUuSE9MRElORzsKLSAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGMuc3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuSE9MRElORykgewotICAgICAgICAgICAgICAgICAgICBjLnN0YXRlID0gQ2FsbEluZm8uU3RhdGUuQUNUSVZFOworICAgICAgICAgICAgICAgIGlmIChjLm1TdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5BQ1RJVkUpIHsKKyAgICAgICAgICAgICAgICAgICAgYy5tU3RhdGUgPSBDYWxsSW5mby5TdGF0ZS5IT0xESU5HOworICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoYy5tU3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuSE9MRElORykgeworICAgICAgICAgICAgICAgICAgICBjLm1TdGF0ZSA9IENhbGxJbmZvLlN0YXRlLkFDVElWRTsKICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKCFoYXNIZWxkICYmIGMuaXNSaW5naW5nKCkpICB7Ci0gICAgICAgICAgICAgICAgICAgIGMuc3RhdGUgPSBDYWxsSW5mby5TdGF0ZS5BQ1RJVkU7CisgICAgICAgICAgICAgICAgICAgIGMubVN0YXRlID0gQ2FsbEluZm8uU3RhdGUuQUNUSVZFOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KICAgICAgICAgfQpAQCAtNTY2LDIzICs1NjcsMjMgQEAKICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgIENhbGxJbmZvIGM7CiAKLSAgICAgICAgICAgIGMgPSBjYWxsc1tpbmRleF07CisgICAgICAgICAgICBjID0gbUNhbGxzW2luZGV4XTsKIAogICAgICAgICAgICAgaWYgKGMgPT0gbnVsbCB8fCBjLmlzQ29ubmVjdGluZygpIHx8IGNvdW50QWN0aXZlTGluZXMoKSAhPSAxKSB7CiAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgfQogCi0gICAgICAgICAgICBjLnN0YXRlID0gQ2FsbEluZm8uU3RhdGUuQUNUSVZFOwotICAgICAgICAgICAgYy5pc01wdHkgPSBmYWxzZTsKKyAgICAgICAgICAgIGMubVN0YXRlID0gQ2FsbEluZm8uU3RhdGUuQUNUSVZFOworICAgICAgICAgICAgYy5tSXNNcHR5ID0gZmFsc2U7CiAKLSAgICAgICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IGNhbGxzLmxlbmd0aCA7IGkrKykgeworICAgICAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgbUNhbGxzLmxlbmd0aCA7IGkrKykgewogICAgICAgICAgICAgICAgIGludCBjb3VudEhlbGQ9MCwgbGFzdEhlbGQ9MDsKIAogICAgICAgICAgICAgICAgIGlmIChpICE9IGluZGV4KSB7Ci0gICAgICAgICAgICAgICAgICAgIENhbGxJbmZvIGNiID0gY2FsbHNbaV07CisgICAgICAgICAgICAgICAgICAgIENhbGxJbmZvIGNiID0gbUNhbGxzW2ldOwogCi0gICAgICAgICAgICAgICAgICAgIGlmIChjYiAhPSBudWxsICYmIGNiLnN0YXRlID09IENhbGxJbmZvLlN0YXRlLkFDVElWRSkgewotICAgICAgICAgICAgICAgICAgICAgICAgY2Iuc3RhdGUgPSBDYWxsSW5mby5TdGF0ZS5IT0xESU5HOworICAgICAgICAgICAgICAgICAgICBpZiAoY2IgIT0gbnVsbCAmJiBjYi5tU3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuQUNUSVZFKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBjYi5tU3RhdGUgPSBDYWxsSW5mby5TdGF0ZS5IT0xESU5HOwogICAgICAgICAgICAgICAgICAgICAgICAgY291bnRIZWxkKys7CiAgICAgICAgICAgICAgICAgICAgICAgICBsYXN0SGVsZCA9IGk7CiAgICAgICAgICAgICAgICAgICAgIH0KQEAgLTU5MCw3ICs1OTEsNyBAQAogCiAgICAgICAgICAgICAgICAgaWYgKGNvdW50SGVsZCA9PSAxKSB7CiAgICAgICAgICAgICAgICAgICAgIC8vIGlmIHRoZXJlJ3Mgb25seSBvbmUgbGVmdCwgY2xlYXIgdGhlIE1QVFkgZmxhZwotICAgICAgICAgICAgICAgICAgICBjYWxsc1tsYXN0SGVsZF0uaXNNcHR5ID0gZmFsc2U7CisgICAgICAgICAgICAgICAgICAgIG1DYWxsc1tsYXN0SGVsZF0ubUlzTXB0eSA9IGZhbHNlOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KIApAQCAtNjA3LDggKzYwOCw4IEBACiAgICAgICAgIGludCBjb3VudENhbGxzID0gMDsKIAogICAgICAgICAvLyBpZiB0aGVyZSdzIGNvbm5lY3RpbmcgY2FsbHMsIHdlIGNhbid0IGRvIHRoaXMgeWV0Ci0gICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IGNhbGxzLmxlbmd0aCA7IGkrKykgewotICAgICAgICAgICAgQ2FsbEluZm8gYyA9IGNhbGxzW2ldOworICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBtQ2FsbHMubGVuZ3RoIDsgaSsrKSB7CisgICAgICAgICAgICBDYWxsSW5mbyBjID0gbUNhbGxzW2ldOwogCiAgICAgICAgICAgICBpZiAoYyAhPSBudWxsKSB7CiAgICAgICAgICAgICAgICAgY291bnRDYWxscysrOwpAQCAtNjE4LDEzICs2MTksMTMgQEAKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KLSAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgY2FsbHMubGVuZ3RoIDsgaSsrKSB7Ci0gICAgICAgICAgICBDYWxsSW5mbyBjID0gY2FsbHNbaV07CisgICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IG1DYWxscy5sZW5ndGggOyBpKyspIHsKKyAgICAgICAgICAgIENhbGxJbmZvIGMgPSBtQ2FsbHNbaV07CiAKICAgICAgICAgICAgIGlmIChjICE9IG51bGwpIHsKLSAgICAgICAgICAgICAgICBjLnN0YXRlID0gQ2FsbEluZm8uU3RhdGUuQUNUSVZFOworICAgICAgICAgICAgICAgIGMubVN0YXRlID0gQ2FsbEluZm8uU3RhdGUuQUNUSVZFOwogICAgICAgICAgICAgICAgIGlmIChjb3VudENhbGxzID4gMCkgewotICAgICAgICAgICAgICAgICAgICBjLmlzTXB0eSA9IHRydWU7CisgICAgICAgICAgICAgICAgICAgIGMubUlzTXB0eSA9IHRydWU7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogICAgICAgICB9CkBAIC02MzcsOCArNjM4LDggQEAKICAgICAgICAgaW50IGNvdW50Q2FsbHMgPSAwOwogCiAgICAgICAgIC8vIGlmIHRoZXJlJ3MgY29ubmVjdGluZyBjYWxscywgd2UgY2FuJ3QgZG8gdGhpcyB5ZXQKLSAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgY2FsbHMubGVuZ3RoIDsgaSsrKSB7Ci0gICAgICAgICAgICBDYWxsSW5mbyBjID0gY2FsbHNbaV07CisgICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IG1DYWxscy5sZW5ndGggOyBpKyspIHsKKyAgICAgICAgICAgIENhbGxJbmZvIGMgPSBtQ2FsbHNbaV07CiAKICAgICAgICAgICAgIGlmIChjICE9IG51bGwpIHsKICAgICAgICAgICAgICAgICBjb3VudENhbGxzKys7CkBAIC02NjAsOCArNjYxLDggQEAKIAogICAgICAgICBSbG9nLmQoIkdTTSIsICJTQz4gZGlhbCAnIiArIGFkZHJlc3MgKyAiJyIpOwogCi0gICAgICAgIGlmIChuZXh0RGlhbEZhaWxJbW1lZGlhdGVseSkgewotICAgICAgICAgICAgbmV4dERpYWxGYWlsSW1tZWRpYXRlbHkgPSBmYWxzZTsKKyAgICAgICAgaWYgKG1OZXh0RGlhbEZhaWxJbW1lZGlhdGVseSkgeworICAgICAgICAgICAgbU5leHREaWFsRmFpbEltbWVkaWF0ZWx5ID0gZmFsc2U7CiAKICAgICAgICAgICAgIFJsb2cuZCgiR1NNIiwgIlNDPCBkaWFsIGZhaWwgKHBlciByZXF1ZXN0KSIpOwogICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwpAQCAtNjkyLDE5ICs2OTMsMTkgQEAKICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgfQogCi0gICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IGNhbGxzLmxlbmd0aCA7IGkrKykgewotICAgICAgICAgICAgaWYgKGZyZWVTbG90IDwgMCAmJiBjYWxsc1tpXSA9PSBudWxsKSB7CisgICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IG1DYWxscy5sZW5ndGggOyBpKyspIHsKKyAgICAgICAgICAgIGlmIChmcmVlU2xvdCA8IDAgJiYgbUNhbGxzW2ldID09IG51bGwpIHsKICAgICAgICAgICAgICAgICBmcmVlU2xvdCA9IGk7CiAgICAgICAgICA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2FsbHNbaV07CiAKICAgICAgICAgICAgIGlmIChjICE9IG51bGwpIHsKICAgICAgICAgICAgICAgICBEcml2ZXJDYWxsIGRjOwpAQCAtNzQ4LDEwICs3NDksMTAgQEAKIAogICAgIHB1YmxpYyBMaXN0PFN0cmluZz4KICAgICBnZXRDbGNjTGluZXMoKSB7Ci0gICAgICAgIEFycmF5TGlzdDxTdHJpbmc+IHJldCA9IG5ldyBBcnJheUxpc3Q8U3RyaW5nPihjYWxscy5sZW5ndGgpOworICAgICAgICBBcnJheUxpc3Q8U3RyaW5nPiByZXQgPSBuZXcgQXJyYXlMaXN0PFN0cmluZz4obUNhbGxzLmxlbmd0aCk7CiAKLSAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgY2FsbHMubGVuZ3RoIDsgaSsrKSB7Ci0gICAgICAgICAgICBDYWxsSW5mbyBjID0gY2FsbHNbaV07CisgICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IG1DYWxscy5sZW5ndGggOyBpKyspIHsKKyAgICAgICAgICAgIENhbGxJbmZvIGMgPSBtQ2FsbHNbaV07CiAKICAgICAgICAgICAgIGlmIChjICE9IG51bGwpIHsKICAgICAgICAgICAgICAgICByZXQuYWRkKChjLnRvQ0xDQ0xpbmUoaSArIDEpKSk7CkBAIC03NzAsMjcgKzc3MSwyNyBAQAogICAgICAgICBib29sZWFuIGhhc1JpbmdpbmcgPSBmYWxzZTsKICAgICAgICAgYm9vbGVhbiBtcHR5SXNIZWxkID0gZmFsc2U7CiAKLSAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgY2FsbHMubGVuZ3RoIDsgaSsrKSB7Ci0gICAgICAgICAgICBDYWxsSW5mbyBjYWxsID0gY2FsbHNbaV07CisgICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IG1DYWxscy5sZW5ndGggOyBpKyspIHsKKyAgICAgICAgICAgIENhbGxJbmZvIGNhbGwgPSBtQ2FsbHNbaV07CiAKICAgICAgICAgICAgIGlmIChjYWxsICE9IG51bGwpIHsKLSAgICAgICAgICAgICAgICBpZiAoIWhhc01wdHkgJiYgY2FsbC5pc01wdHkpIHsKLSAgICAgICAgICAgICAgICAgICAgbXB0eUlzSGVsZCA9IGNhbGwuc3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuSE9MRElORzsKLSAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNhbGwuaXNNcHR5ICYmIG1wdHlJc0hlbGQKLSAgICAgICAgICAgICAgICAgICAgJiYgY2FsbC5zdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5BQ1RJVkUKKyAgICAgICAgICAgICAgICBpZiAoIWhhc01wdHkgJiYgY2FsbC5tSXNNcHR5KSB7CisgICAgICAgICAgICAgICAgICAgIG1wdHlJc0hlbGQgPSBjYWxsLm1TdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5IT0xESU5HOworICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2FsbC5tSXNNcHR5ICYmIG1wdHlJc0hlbGQKKyAgICAgICAgICAgICAgICAgICAgJiYgY2FsbC5tU3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuQUNUSVZFCiAgICAgICAgICAgICAgICAgKSB7CiAgICAgICAgICAgICAgICAgICAgIFJsb2cuZSgiTW9kZWxJbnRlcnByZXRlciIsICJJbnZhbGlkIHN0YXRlIik7CiAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBJbnZhbGlkU3RhdGVFeCgpOwotICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIWNhbGwuaXNNcHR5ICYmIGhhc01wdHkgJiYgbXB0eUlzSGVsZAotICAgICAgICAgICAgICAgICAgICAmJiBjYWxsLnN0YXRlID09IENhbGxJbmZvLlN0YXRlLkhPTERJTkcKKyAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKCFjYWxsLm1Jc01wdHkgJiYgaGFzTXB0eSAmJiBtcHR5SXNIZWxkCisgICAgICAgICAgICAgICAgICAgICYmIGNhbGwub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FuZHJvaWQvaW50ZXJuYWwvdGVsZXBob255L3VpY2MvQWRuUmVjb3JkLmphdmEKKysrIGIvc3JjL2phdmEvY29tL2FuZHJvaWQvaW50ZXJuYWwvdGVsZXBob255L3VpY2MvQWRuUmVjb3JkLmphdmEKQEAgLTM1LDE2ICszNSwxNiBAQAogICoKICAqLwogcHVibGljIGNsYXNzIEFkblJlY29yZCBpbXBsZW1lbnRzIFBhcmNlbGFibGUgewotICAgIHN0YXRpYyBmaW5hbCBTdHJpbmcgTE9HX1RBRyA9ICJHU00iOworICAgIHN0YXRpYyBmaW5hbCBTdHJpbmcgTE9HX1RBRyA9ICJBZG5SZWNvcmQiOwogCiAgICAgLy8qKioqKiBJbnN0YW5jZSBWYXJpYWJsZXMKIAotICAgIFN0cmluZyBhbHBoYVRhZyA9IG51bGw7Ci0gICAgU3RyaW5nIG51bWJlciA9IG51bGw7Ci0gICAgU3RyaW5nW10gZW1haWxzOwotICAgIGludCBleHRSZWNvcmQgPSAweGZmOwotICAgIGludCBlZmlkOyAgICAgICAgICAgICAgICAgICAvLyBvciAwIGlmIG5vbmUKLSAgICBpbnQgcmVjb3JkTnVtYmVyOyAgICAgICAgICAgLy8gb3IgMCBpZiBub25lCisgICAgU3RyaW5nIG1BbHBoYVRhZyA9IG51bGw7CisgICAgU3RyaW5nIG1OdW1iZXIgPSBudWxsOworICAgIFN0cmluZ1tdIG1FbWFpbHM7CisgICAgaW50IG1FeHRSZWNvcmQgPSAweGZmOworICAgIGludCBtRWZpZDsgICAgICAgICAgICAgICAgICAgLy8gb3IgMCBpZiBub25lCisgICAgaW50IG1SZWNvcmROdW1iZXI7ICAgICAgICAgICAvLyBvciAwIGlmIG5vbmUKIAogCiAgICAgLy8qKioqKiBDb25zdGFudHMKQEAgLTczLDYgKzczLDcgQEAKIAogICAgIHB1YmxpYyBzdGF0aWMgZmluYWwgUGFyY2VsYWJsZS5DcmVhdG9yPEFkblJlY29yZD4gQ1JFQVRPUgogICAgICAgICAgICAgPSB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hVGFnOworICAgICAgICByZXR1cm4gbUFscGhhVGFnOwogICAgIH0KIAogICAgIHB1YmxpYyBTdHJpbmcgZ2V0TnVtYmVyKCkgewotICAgICAgICByZXR1cm4gbnVtYmVyOworICAgICAgICByZXR1cm4gbU51bWJlcjsKICAgICB9CiAKICAgICBwdWJsaWMgU3RyaW5nW10gZ2V0RW1haWxzKCkgewotICAgICAgICByZXR1cm4gZW1haWxzOworICAgICAgICByZXR1cm4gbUVtYWlsczsKICAgICB9CiAKICAgICBwdWJsaWMgdm9pZCBzZXRFbWFpbHMoU3RyaW5nW10gZW1haWxzKSB7Ci0gICAgICAgIHRoaXMuZW1haWxzID0gZW1haWxzOworICAgICAgICB0aGlzLm1FbWFpbHMgPSBlbWFpbHM7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFN0cmluZyB0b1N0cmluZygpIHsKLSAgICAgICAgcmV0dXJuICJBRE4gUmVjb3JkICciICsgYWxwaGFUYWcgKyAiJyAnIiArIG51bWJlciArICIgIiArIGVtYWlscyArICInIjsKKyAgICAgICAgcmV0dXJuICJBRE4gUmVjb3JkICciICsgbUFscGhhVGFnICsgIicgJyIgKyBtTnVtYmVyICsgIiAiICsgbUVtYWlscyArICInIjsKICAgICB9CiAKICAgICBwdWJsaWMgYm9vbGVhbiBpc0VtcHR5KCkgewotICAgICAgICByZXR1cm4gVGV4dFV0aWxzLmlzRW1wdHkoYWxwaGFUYWcpICYmIFRleHRVdGlscy5pc0VtcHR5KG51bWJlcikgJiYgZW1haWxzID09IG51bGw7CisgICAgICAgIHJldHVybiBUZXh0VXRpbHMuaXNFbXB0eShtQWxwaGFUYWcpICYmIFRleHRVdGlscy5pc0VtcHR5KG1OdW1iZXIpICYmIG1FbWFpbHMgPT0gbnVsbDsKICAgICB9CiAKICAgICBwdWJsaWMgYm9vbGVhbiBoYXNFeHRlbmRlZFJlY29yZCgpIHsKLSAgICAgICAgcmV0dXJuIGV4dFJlY29yZCAhPSAwICYmIGV4dFJlY29yZCAhPSAweGZmOworICAgICAgICByZXR1cm4gbUV4dFJlY29yZCAhPSAwICYmIG1FeHRSZWNvcmQgIT0gMHhmZjsKICAgICB9CiAKICAgICAvKiogSGVscGVyIGZ1bmN0aW9uIGZvciB7QGxpbmsgI2lzRXF1YWx9LiAqLwpAQCAtMTc1LDIyICsxNzgsMjQgQEAKICAgICB9CiAKICAgICBwdWJsaWMgYm9vbGVhbiBpc0VxdWFsKEFkblJlY29yZCBhZG4pIHsKLSAgICAgICAgcmV0dXJuICggc3RyaW5nQ29tcGFyZU51bGxFcXVhbHNFbXB0eShhbHBoYVRhZywgYWRuLmFscGhhVGFnKSAmJgotICAgICAgICAgICAgICAgIHN0cmluZ0NvbXBhcmVOdWxsRXF1YWxzRW1wdHkobnVtYmVyLCBhZG4ubnVtYmVyKSAmJgotICAgICAgICAgICAgICAgIEFycmF5cy5lcXVhbHMoZW1haWxzLCBhZG4uZW1haWxzKSk7CisgICAgICAgIHJldHVybiAoIHN0cmluZ0NvbXBhcmVOdWxsRXF1YWxzRW1wdHkobUFscGhhVGFnLCBhZG4ubUFscGhhVGFnKSAmJgorICAgICAgICAgICAgICAgIHN0cmluZ0NvbXBhcmVOdWxsRXF1YWxzRW1wdHkobU51bWJlciwgYWRuLm1OdW1iZXIpICYmCisgICAgICAgICAgICAgICAgQXJyYXlzLmVxdWFscyhtRW1haWxzLCBhZG4ubUVtYWlscykpOwogICAgIH0KICAgICAvLyoqKioqIFBhcmNlbGFibGUgSW1wbGVtZW50YXRpb24KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBpbnQgZGVzY3JpYmVDb250ZW50cygpIHsKICAgICAgICAgcmV0dXJuIDA7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgd3JpdGVUb1BhcmNlbChQYXJjZWwgZGVzdCwgaW50IGZsYWdzKSB7Ci0gICAgICAgIGRlc3Qud3JpdGVJbnQoZWZpZCk7Ci0gICAgICAgIGRlc3Qud3JpdGVJbnQocmVjb3JkTnVtYmVyKTsKLSAgICAgICAgZGVzdC53cml0ZVN0cmluZyhhbHBoYVRhZyk7Ci0gICAgICAgIGRlc3Qud3JpdGVTdHJpbmcobnVtYmVyKTsKLSAgICAgICAgZGVzdC53cml0ZVN0cmluZ0FycmF5KGVtYWlscyk7CisgICAgICAgIGRlc3Qud3JpdGVJbnQobUVmaWQpOworICAgICAgICBkZXN0LndyaXRlSW50KG1SZWNvcmROdW1iZXIpOworICAgICAgICBkZXN0LndyaXRlU3RyaW5nKG1BbHBoYVRhZyk7CisgICAgICAgIGRlc3Qud3JpdGVTdHJpbmcobU51bWJlcik7CisgICAgICAgIGRlc3Qud3JpdGVTdHJpbmdBcnJheShtRW1haWxzKTsKICAgICB9CiAKICAgICAvKioKQEAgLTIxMywyMCArMjE4LDIwIEBACiAgICAgICAgICAgICBhZG5TdHJpbmdbaV0gPSAoYnl0ZSkgMHhGRjsKICAgICAgICAgfQogCi0gICAgICAgIGlmIChUZXh0VXRpbHMuaXNFbXB0eShudW1iZXIpKSB7CisgICAgICAgIGlmIChUZXh0VXRpbHMuaXNFbXB0eShtTnVtYmVyKSkgewogICAgICAgICAgICAgUmxvZy53KExPR19UQUcsICJbYnVpbGRBZG5TdHJpbmddIEVtcHR5IGRpYWxpbmcgbnVtYmVyIik7CiAgICAgICAgICAgICByZXR1cm4gYWRuU3RyaW5nOyAgIC8vIHJldHVybiB0aGUgZW1wdHkgcmVjb3JkIChmb3IgZGVsZXRlKQotICAgICAgICB9IGVsc2UgaWYgKG51bWJlci5sZW5ndGgoKQorICAgICAgICB9IGVsc2UgaWYgKG1OdW1iZXIubGVuZ3RoKCkKICAgICAgICAgICAgICAgICA+IChBRE5fRElBTElOR19OVU1CRVJfRU5EIC0gQUROX0RJQUxJTkdfTlVNQkVSX1NUQVJUICsgMSkgKiAyKSB7CiAgICAgICAgICAgICBSbG9nLncoTE9HX1RBRywKICAgICAgICAgICAgICAgICAgICAgIltidWlsZEFkblN0cmluZ10gTWF4IGxlbmd0aCBvZiBkaWFsaW5nIG51bWJlciBpcyAyMCIpOwogICAgICAgICAgICAgcmV0dXJuIG51bGw7Ci0gICAgICAgIH0gZWxzZSBpZiAoYWxwaGFUYWcgIT0gbnVsbCAmJiBhbHBoYVRhZy5sZW5ndGgoKSA+IGZvb3Rlck9mZnNldCkgeworICAgICAgICB9IGVsc2UgaWYgKG1BbHBoYVRhZyAhPSBudWxsICYmIG1BbHBoYVRhZy5sZW5ndGgoKSA+IGZvb3Rlck9mZnNldCkgewogICAgICAgICAgICAgUmxvZy53KExPR19UQUcsCiAgICAgICAgICAgICAgICAgICAgICJbYnVpbGRBZG5TdHJpbmddIE1heCBsZW5ndGggb2YgdGFnIGlzICIgKyBmb290ZXJPZmZzZXQpOwogICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICBiY2ROdW1iZXIgPSBQaG9uZU51bWJlclV0aWxzLm51bWJlclRvQ2FsbGVkUGFydHlCQ0QobnVtYmVyKTsKKyAgICAgICAgICAgIGJjZE51bWJlciA9IFBob25lTnVtYmVyVXRpbHMubnVtYmVyVG9DYWxsZWRQYXJ0eUJDRChtTnVtYmVyKTsKIAogICAgICAgICAgICAgU3lzdGVtLmFycmF5Y29weShiY2ROdW1iZXIsIDAsIGFkblN0cmluZywKICAgICAgICAgICAgICAgICAgICAgZm9vdGVyT2Zmc2V0ICsgQUROX1RPTl9BTkRfTlBJLCBiY2ROdW1iZXIubGVuZ3RoKTsKQEAgLTIzOCw4ICsyNDMsOCBAQAogICAgICAgICAgICAgYWRuU3RyaW5nW2Zvb3Rlck9mZnNldCArIEFETl9FWFRFTlNJT05fSURdCiAgICAgICAgICAgICAgICAgICAgID0gKGJ5dGUpIDB4RkY7IC8vIEV4dGVuc2lvbiBSZWNvcmQgSWQKIAotICAgICAgICAgICAgaWYgKCFUZXh0VXRpbHMuaXNFbXB0eShhbHBoYVRhZykpIHsKLSAgICAgICAgICAgICAgICBieXRlVGFnID0gR3NtQWxwaGFiZXQuc3RyaW5nVG9Hc204Qml0UGFja2VkKGFscGhhVGFnKTsKKyAgICAgICAgICAgIGlmICghVGV4dFV0aWxzLmlzRW1wdHkobUFscGhhVGFnKSkgeworICAgICAgICAgICAgICAgIGJ5dGVUYWcgPSBHc21BbHBoYWJldC5zdHJpbmdUb0dzbThCaXRQYWNrZWQobUFscGhhVGFnKTsKICAgICAgICAgICAgICAgICBTeXN0ZW0uYXJyYXljb3B5KGJ5dGVUYWcsIDAsIGFkblN0cmluZywgMCwgYnl0ZVRhZy5sZW5ndGgpOwogICAgICAgICAgICAgfQogCkBAIC0yNjcsNyArMjcyLDcgQEAKICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgIG51bWJlciArPSBQaG9uZU51bWJlclV0aWxzLmNhbGxlZFBhcnR5QkNERnJhZ21lbnRUb1N0cmluZygKKyAgICAgICAgICAgIG1OdW1iZXIgKz0gUGhvbmVOdW1iZXJVdGlscy5jYWxsZWRQYXJ0eUJDREZyYWdtZW50VG9TdHJpbmcoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXh0UmVjb3JkLCAyLCAweGZmICYgZXh0UmVjb3JkWzFdKTsKIAogICAgICAgICAgICAgLy8gV2UgZG9uJ3Qgc3VwcG9ydCBleHQgcmVjb3JkIGNoYWluaW5nLgpAQCAtMjg1LDcgKzI5MCw3IEBACiAgICAgcHJpdmF0ZSB2b2lkCiAgICAgcGFyc2VSZWNvcmQoYnl0ZVtdIHJlY29yZCkgewogICAgICAgICB0cnkgewotICAgICAgICAgICAgYWxwaGFUYWcgPSBJY2NVdGlscy5hZG5TdHJpbmdGaWVsZFRvU3RyaW5nKAorICAgICAgICAgICAgbUFscGhhVGFnID0gSWNjVXRpbHMuYWRuU3RyaW5nRmllbGRUb1N0cmluZygKICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWNvcmQsIDAsIHJlY29yZC5sZW5ndGggLSBGT09URVJfU0laRV9CWVRFUyk7CiAKICAgICAgICAgICAgIGludCBmb290ZXJPZmZzZXQgPSByZWNvcmQubGVuZ3RoIC0gRk9PVEVSX1NJWkVfQllURVM7CkBAIC0yOTQsNyArMjk5LDcgQEAKIAogICAgICAgICAgICAgaWYgKG51bWJlckxlbmd0aCA+IE1BWF9OVU1CRVJfU0laRV9CWVRFUykgewogICAgICAgICAgICAgICAgIC8vIEludmFsaWQgbnVtYmVyIGxlbmd0aAotICAgICAgICAgICAgICAgIG51bWJlciA9ICIiOworICAgICAgICAgICAgICAgIG1OdW1iZXIgPSAiIjsKICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICB9CiAKQEAgLTMwNSwxOSArMzEwLDE5IEBACiAgICAgICAgICAgICAvLyBhIHNlcnZpY2UsIHRoZSBUT04vTlBJIGJ5dGUgc2hhbGwgYmUgc2V0IHRvICdGRicgYnkKICAgICAgICAgICAgIC8vIHRoZSBNRSAoc2VlIG5vdGUgMikuIgogCi0gICAgICAgICAgICBudW1iZXIgPSBQaG9uZU51bWJlclV0aWxzLmNhbGxlZFBhcnR5QkNEVG9TdHJpbmcoCisgICAgICAgICAgICBtTnVtYmVyID0gUGhvbmVOdW1iZXJVdGlscy5jYWxsZWRQYXJ0eUJDRFRvU3RyaW5nKAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY29yZCwgZm9vdGVyT2Zmc2V0ICsgMSwgbnVtYmVyTGVuZ3RoKTsKIAogCi0gICAgICAgICAgICBleHRSZWNvcmQgPSAweGZmICYgcmVjb3JkW3JlY29yZC5sZW5ndGggLSAxXTsKKyAgICAgICAgICAgIG1FeHRSZWNvcmQgPSAweGZmICYgcmVjb3JkW3JlY29yZC5sZW5ndGggLSAxXTsKIAotICAgICAgICAgICAgZW1haWxzID0gbnVsbDsKKyAgICAgICAgICAgIG1FbWFpbHMgPSBudWxsOwogCiAgICAgICAgIH0gY2F0Y2gg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gICAgICAgIG5vdGlmeVdhaXRlcnMod2FpdGVycywgYXIpOwogICAgICAgICAgICAgICAgIGJyZWFrOwpAQCAtMzQ2LDEyICszNDYsMTIgQEAKICAgICAgICAgICAgICAgICBBZG5SZWNvcmQgYWRuID0gKEFkblJlY29yZCkgKGFyLnVzZXJPYmopOwogCiAgICAgICAgICAgICAgICAgaWYgKGFyLmV4Y2VwdGlvbiA9PSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgIGFkbkxpa2VGaWxlcy5nZXQoZWZpZCkuc2V0KGluZGV4IC0gMSwgYWRuKTsKKyAgICAgICAgICAgICAgICAgICAgbUFkbkxpa2VGaWxlcy5nZXQoZWZpZCkuc2V0KGluZGV4IC0gMSwgYWRuKTsKICAgICAgICAgICAgICAgICAgICAgbVVzaW1QaG9uZUJvb2tNYW5hZ2VyLmludmFsaWRhdGVDYWNoZSgpOwogICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgICAgIE1lc3NhZ2UgcmVzcG9uc2UgPSB1c2VyV3JpdGVSZXNwb25zZS5nZXQoZWZpZCk7Ci0gICAgICAgICAgICAgICAgdXNlcldyaXRlUmVzcG9uc2UuZGVsZXRlKGVmaWQpOworICAgICAgICAgICAgICAgIE1lc3NhZ2UgcmVzcG9uc2UgPSBtVXNlcldyaXRlUmVzcG9uc2UuZ2V0KGVmaWQpOworICAgICAgICAgICAgICAgIG1Vc2VyV3JpdGVSZXNwb25zZS5kZWxldGUoZWZpZCk7CiAKICAgICAgICAgICAgICAgICBBc3luY1Jlc3VsdC5mb3JNZXNzYWdlKHJlc3BvbnNlLCBudWxsLCBhci5leGNlcHRpb24pOwogICAgICAgICAgICAgICAgIHJlc3BvbnNlLnNlbmRUb1RhcmdldCgpOwpkaWZmIC0tZ2l0IGEvc3JjL2phdmEvY29tL2FuZHJvaWQvaW50ZXJuYWwvdGVsZXBob255L3VpY2MvQWRuUmVjb3JkTG9hZGVyLmphdmEgYi9zcmMvamF2YS9jb20vYW5kcm9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XNwb25zZTsKKyAgICAgICAgbVBpbjIgPSBwaW4yOwogCiAgICAgICAgIG1GaC5nZXRFRkxpbmVhclJlY29yZFNpemUoIGVmLAogICAgICAgICAgICAgb2J0YWluTWVzc2FnZShFVkVOVF9FRl9MSU5FQVJfUkVDT1JEX1NJWkVfRE9ORSwgYWRuKSk7CkBAIC0xMjYsNiArMTI3LDcgQEAKIAogICAgIC8vKioqKiogT3ZlcnJpZGRlbiBmcm9tIEhhbmRsZXIKIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkCiAgICAgaGFuZGxlTWVzc2FnZShNZXNzYWdlIG1zZykgewogICAgICAgICBBc3luY1Jlc3VsdCBhcjsKQEAgLTE0OSw3ICsxNTEsNyBAQAogICAgICAgICAgICAgICAgICAgICAvLyBpbnRbMV0gIGlzIHRoZSB0b3RhbCBsZW5ndGggb2YgdGhlIEVGIGZpbGUKICAgICAgICAgICAgICAgICAgICAgLy8gaW50WzJdICBpcyB0aGUgbnVtYmVyIG9mIHJlY29yZHMgaW4gdGhlIEVGIGZpbGUKICAgICAgICAgICAgICAgICAgICAgLy8gU28gaW50WzBdICogaW50WzJdID0gaW50WzFdCi0gICAgICAgICAgICAgICAgICAgaWYgKHJlY29yZFNpemUubGVuZ3RoICE9IDMgfHwgcmVjb3JkTnVtYmVyID4gcmVjb3JkU2l6ZVsyXSkgeworICAgICAgICAgICAgICAgICAgIGlmIChyZWNvcmRTaXplLmxlbmd0aCAhPSAzIHx8IG1SZWNvcmROdW1iZXIgPiByZWNvcmRTaXplWzJdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgUnVudGltZUV4Y2VwdGlvbigiZ2V0IHdyb25nIEVGIHJlY29yZCBzaXplIGZvcm1hdCIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFyLmV4Y2VwdGlvbik7CiAgICAgICAgICAgICAgICAgICAgIH0KQEAgLTE2MSwxMCArMTYzLDEwIEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFyLmV4Y2VwdGlvbik7CiAgICAgICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgICAgICAgICBtRmgudXBkYXRlRUZMaW5lYXJGaXhlZChlZiwgcmVjb3JkTnVtYmVyLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEsIHBpbjIsIG9idGFpbk1lc3NhZ2UoRVZFTlRfVVBEQVRFX1JFQ09SRF9ET05FKSk7CisgICAgICAgICAgICAgICAgICAgIG1GaC51cGRhdGVFRkxpbmVhckZpeGVkKG1FZiwgbVJlY29yZE51bWJlciwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLCBtUGluMiwgb2J0YWluTWVzc2FnZShFVkVOVF9VUERBVEVfUkVDT1JEX0RPTkUpKTsKIAotICAgICAgICAgICAgICAgICAgICBwZW5kaW5nRXh0TG9hZHMgPSAxOworICAgICAgICAgICAgICAgICAgICBtUGVuZGluZ0V4dExvYWRzID0gMTsKIAogICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICBjYXNlIEVWRU5UX1VQREFURV9SRUNPUkRfRE9ORToKQEAgLTE3Myw4ICsxNzUsOCBAQAogICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IFJ1bnRpbWVFeGNlcHRpb24oInVwZGF0ZSBFRiBhZG4gcmVjb3JkIGZhaWxlZCIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFyLmV4Y2VwdGlvbik7CiAgICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgcGVuZGluZ0V4dExvYWRzID0gMDsKLSAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gbnVsbDsKKyAgICAgICAgICAgICAgICAgICAgbVBlbmRpbmdFeHRMb2FkcyA9IDA7CisgICAgICAgICAgICAgICAgICAgIG1SZXN1bHQgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICBjYXNlIEVWRU5UX0FETl9MT0FEX0RPTkU6CiAgICAgICAgICAgICAgICAgICAgIGFyID0gKEFzeW5jUmVzdWx0KShtc2cub2JqKTsKQEAgLTE4NCwyNSArMTg2LDI1IEBACiAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgUnVudGltZUV4Y2VwdGlvbigibG9hZCBmYWlsZWQiLCBhci5leGNlcHRpb24pOwogICAgICAgICAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgICAgICAgICAgaWYgKGZhbHNlKSB7CisgICAgICAgICAgICAgICAgICAgIGlmIChWREJHKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywiQUROIEVGOiAweCIKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICArIEludGVnZXIudG9IZXhTdHJpbmcoZWYpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgKyAiOiIgKyByZWNvcmROdW1iZXIKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICArIEludGVnZXIudG9IZXhTdHJpbmcobUVmKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgIjoiICsgbVJlY29yZE51bWJlcgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgIlxuIiArIEljY1V0aWxzLmJ5dGVzVG9IZXhTdHJpbmcoZGF0YSkpOwogICAgICAgICAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgICAgICAgICAgYWRuID0gbmV3IEFkblJlY29yZChlZiwgcmVjb3JkTnVtYmVyLCBkYXRhKTsKLSAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gYWRuOworICAgICAgICAgICAgICAgICAgICBhZG4gPSBuZXcgQWRuUmVjb3JkKG1FZiwgbVJlY29yZE51bWJlciwgZGF0YSk7CisgICAgICAgICAgICAgICAgICAgIG1SZXN1bHQgPSBhZG47CiAKICAgICAgICAgICAgICAgICAgICAgaWYgKGFkbi5oYXNFeHRlbmRlZFJlY29yZCgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBJZiB3ZSBoYXZlIGEgdmFsaWQgdmFsdWUgaW4gdGhlIGV4dCByZWNvcmQgZmllbGQsCiAgICAgICAgICAgICAgICAgICAgICAgICAvLyB3ZSdyZSBub3QgZG9uZSB5ZXQ6IHdlIG5lZWQgdG8gcmVhZCB0aGUgY29ycmVzcG9uZGluZwogICAgICAgICAgICAgICAgICAgICAgICAgLy8gZXh0IHJlY29yZCBhbmQgYXBwZW5kIGl0CiAKLSAgICAgICAgICAgICAgICAgICAgICAgIHBlbmRpbmdFeHRMb2FkcyA9IDE7CisgICAgICAgICAgICAgICAgICAgICAgICBtUGVuZGluZ0V4dExvYWRzID0gMTsKIAogICAgICAgICAgICAgICAgICAgICAgICAgbUZoLmxvYWRFRkxpbmVhckZpeGVkKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4dGVuc2lvbkVGLCBhZG4uZXh0UmVjb3JkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1FeHRlbnNpb25FRiwgYWRuLm1FeHRSZWNvcmQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZShFVkVOVF9FWFRfUkVDT1JEX0xPQURfRE9ORSwgYWRuKSk7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBicmVhazsKQEAgLTIxNywxMyArMjE5LDEzIEBACiAgICAgICAgICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywiQUROIGV4dGVuc2lvbiBFRjogMHgiCi0gICAgICAgICAgICAgICAgICAgICAgICArIEludGVnZXIudG9IZXhTdHJpbmcoZXh0ZW5zaW9uRUYpCi0gICAgICAgICAgICAgICAgICAgICAgICArICI6IiArIGFkbi5leHRSZWNvcmQKKyAgICAgICAgICAgICAgICAgICAgICAgICsgSW50ZWdlci50b0hleFN0cmluZyhtRXh0ZW5zaW9uRUYpCisgICAgICAgICAgICAgICAgICAgICAgICArICI6IiArIGFkbi5tRXh0UmVjb3JkCiAgICAgICAgICAgICAgICAgICAgICAgICArICJcbiIgKyBJY2NVdGlscy5ieXRlc1RvSGV4U3RyaW5nKGRhdGEpKTsKIAogICAgICAgICAgICAgICAgICAgICBhZG4uYXBwZW5kRXh0UmVjb3JkKGRhdGEpOwogCi0gICAgICAgICAgICAgICAgICAgIHBlbmRpbmdFeHRMb2Fkcy0tOworICAgICAgICAgICAgICAgICAgICBtUGVuZGluZ0V4dExvYWRzLS07CiAgICAgICAgICAgICAgICAgICAgIC8vIHJlc3VsdCBzaG91bGQgaGF2ZSBiZWVuIHNldCBpbgogICAgICAgICAgICAgICAgICAgICAvLyBFVkVOVF9BRE5fTE9BRF9ET05FIG9yIEVWRU5UX0FETl9MT0FEX0FMTF9ET05FCiAgICAgICAgICAgICAgICAgYnJlYWs7CkBAIC0yMzYsNDYgKzIzOCw0NiBAQAogICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IFJ1bnRpbWVFeGNlcHRpb24oImxvYWQgZmFpbGVkIiwgYXIuZXhjZXB0aW9uKTsKICAgICAgICAgICAgICAgICAgICAgfQogCi0gICAgICAgICAgICAgICAgICAgIGFkbnMgPSBuZXcgQXJyYXlMaXN0PEFkblJlY29yZD4oZGF0YXMuc2l6ZSgpKTsKLSAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gYWRuczsKLSAgICAgICAgICAgICAgICAgICAgcGVuZGluZ0V4dExvYWRzID0gMDsKKyAgICAgICAgICAgICAgICAgICAgbUFkbnMgPSBuZXcgQXJyYXlMaXN0PEFkblJlY29yZD4oZGF0YXMuc2l6ZSgpKTsKKyAgICAgICAgICAgICAgICAgICAgbVJlc3VsdCA9IG1BZG5zOworICAgICAgICAgICAgICAgICAgICBtUGVuZGluZ0V4dExvYWRzID0gMDsKIAogICAgICAgICAgICAgICAgICAgICBmb3IoaW50IGkgPSAwLCBzID0gZGF0YXMuc2l6ZSgpIDsgaSA8IHMgOyBpKyspIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGFkbiA9IG5ldyBBZG5SZWNvcmQoZWYsIDEgKyBpLCBkYXRhcy5nZXQoaSkpOwotICAgICAgICAgICAgICAgICAgICAgICAgYWRucy5hZGQoYWRuKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGFkbiA9IG5ldyBBZG5SZWNvcmQobUVmLCAxICsgaSwgZGF0YXMuZ2V0KGkpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1BZG5zLmFkZChhZG4pOwogCiAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYWRuLmhhc0V4dGVuZGVkUmVjb3JkKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBJZiB3ZSBoYXZlIGEgdmFsaWQgdmFsdWUgaW4gdGhlIGV4dCByZWNvcmQgZmllbGQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gd2UncmUgbm90IGRvbmUgeWV0OiB3ZSBuZWVkIHRvIHJlYWQgdGhlIGNvcnJlc3BvbmRpbmcKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBleHQgcmVjb3JkIGFuZCBhcHBlbmQgaXQKIAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlbmRpbmdFeHRMb2FkcysrOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1QZW5kaW5nRXh0TG9hZHMrKzsKIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1GaC5sb2FkRUZMaW5lYXJGaXhlZCgKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXh0ZW5zaW9uRUYsIGFkbi5leHRSZWNvcmQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1FeHRlbnNpb25FRiwgYWRuLm1FeHRSZWNvcmQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9idGFpbk1lc3NhZ2UoRVZFTlRfRVhUX1JFQ09SRF9MT0FEX0RPTkUsIGFkbikpOwogICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0gY2F0Y2ggKFJ1bnRpbWVFeGNlcHRpb24gZXhjKSB7Ci0gICAgICAgICAgICBpZiAodXNlclJlc3BvbnNlICE9IG51bGwpIHsKLSAgICAgICAgICAgICAgICBBc3luY1Jlc3VsdC5mb3JNZXNzYWdlKHVzZXJSZXNwb25zZSkKKyAgICAgICAgICAgIGlmIChtVXNlclJlc3BvbnNlICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICBBc3luY1Jlc3VsdC5mb3JNZXNzYWdlKG1Vc2VyUmVzcG9uc2UpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5leGNlcHRpb24gPSBleGM7Ci0gICAgICAgICAgICAgICAgdXNlclJlc3BvbnNlLnNlbmRUb1RhcmdldCgpOworICAgICAgICAgICAgICAgIG1Vc2VyUmVzcG9uc2Uuc2VuZFRvVGFyZ2V0KCk7CiAgICAgICAgICAgICAgICAgLy8gTG9hZGluZyBpcyBhbGwgb3Igbm90aGluZy0tZWl0aGVyIGV2ZXJ5IGxvYWQgc3VjY2VlZHMKICAgICAgICAgICAgICAgICAvLyBvciB3ZSBmYWlsIHRoZSB3aG9sZSB0aGluZy4KLSAgICAgICAgICAgICAgICB1c2VyUmVzcG9uc2UgPSBudWxsOworICAgICAgICAgICAgICAgIG1Vc2VyUmVzcG9uc2UgPSBudWxsOwogICAgICAgICAgICAgfQogICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICB9CiAKLSAgICAgICAgaWYgKHVzZXJSZXNwb25zZSAhPSBudWxsICYmIHBlbmRpbmdFeHRMb2FkcyA9PSAwKSB7Ci0gICAgICAgICAgICBBc3luY1Jlc3VsdC5mb3JNZXNzYWdlKHVzZXJSZXNwb25zZSkucmVzdWx0Ci0gICAgICAgICAgICAgICAgPSByZXN1bHQ7CisgIC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gICAgfQotICAgIH07CisgICAgfQogCiAgICAgcHVibGljIGVudW0gUGVyc29TdWJTdGF0ZXsKICAgICAgICAgUEVSU09TVUJTVEFURV9VTktOT1dOLApAQCAtOTQsNyArOTQsNyBAQAogICAgICAgICBib29sZWFuIGlzUGVyc29TdWJTdGF0ZVVua25vd24oKSB7CiAgICAgICAgICAgICByZXR1cm4gdGhpcyA9PSBQRVJTT1NVQlNUQVRFX1VOS05PV047CiAgICAgICAgIH0KLSAgICB9OworICAgIH0KIAogICAgIHB1YmxpYyBBcHBUeXBlICAgICAgICBhcHBfdHlwZTsKICAgICBwdWJsaWMgQXBwU3RhdGUgICAgICAgYXBwX3N0YXRlOwpkaWZmIC0tZ2l0IGEvc3JjL2phdmEvY29tL2FuZHJvaWQvaW50ZXJuYWwvdGVsZXBob255L3VpY2MvSWNjQ2FyZFByb3h5LmphdmEgYi9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvdWljYy9JY2NDYXJkUHJveHkuamF2YQppbmRleCBlMGU3MTI0Li43MzNhZjY0IDEwMDY0NAotLS0gYS9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvdWljYy9JY2NDYXJkUHJveHkuamF2YQorKysgYi9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvdWljYy9JY2NDYXJkUHJveHkuamF2YQpAQCAtMzUsMTIgKzM1LDEyIEBACiBpbXBvcnQgY29tLmFuZHJvaWQuaW50ZXJuYWwudGVsZXBob255LkljY0NhcmQ7CiBpbXBvcnQgY29tLmFuZHJvaWQuaW50ZXJuYWwudGVsZXBob255LkljY0NhcmRDb25zdGFudHM7CiBpbXBvcnQgY29tLmFuZHJvaWQuaW50ZXJuYWwudGVsZXBob255LlBob25lQ29uc3RhbnRzOworaW1wb3J0IGNvbS5hbmRyb2lkLmludGVybmFsLnRlbGVwaG9ueS5SSUxDb25zdGFudHM7CiBp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aSA9IGNpOworICAgICAgICBtQ29udGV4dCA9IGNvbnRleHQ7CisgICAgICAgIG1DaSA9IGNpOwogICAgICAgICBtQ2RtYVNTTSA9IENkbWFTdWJzY3JpcHRpb25Tb3VyY2VNYW5hZ2VyLmdldEluc3RhbmNlKGNvbnRleHQsCiAgICAgICAgICAgICAgICAgY2ksIHRoaXMsIEVWRU5UX0NETUFfU1VCU0NSSVBUSU9OX1NPVVJDRV9DSEFOR0VELCBudWxsKTsKICAgICAgICAgbVVpY2NDb250cm9sbGVyID0gVWljY0NvbnRyb2xsZXIuZ2V0SW5zdGFuY2UoKTsKQEAgLTE5OCw2ICsxOTgsNyBAQAogICAgICAgICB9CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgaGFuZGxlTWVzc2FnZShNZXNzYWdlIG1zZykgewogICAgICAgICBzd2l0Y2ggKG1zZy53aGF0KSB7CiAgICAgICAgICAgICBjYXNlIEVWRU5UX1JBRElPX09GRl9PUl9VTkFWQUlMQUJMRToKQEAgLTM3NCw2ICszNzUsMTIgQEAKICAgICAgICAgICAgICAgICBjYXNlIEFQUFNUQVRFX1BVSzoKICAgICAgICAgICAgICAgICAgICAgc2V0RXh0ZXJuYWxTdGF0ZShTdGF0ZS5QVUtfUkVRVUlSRUQpOwogICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICBjYXNlIEFQUFNUQVRFX0RFVEVDVEVEOgorICAgICAgICAgICAgICAgIGNhc2UgQVBQU1RBVEVfUkVBRFk6CisgICAgICAgICAgICAgICAgY2FzZSBBUFBTVEFURV9TVUJTQ1JJUFRJT05fUEVSU086CisgICAgICAgICAgICAgICAgY2FzZSBBUFBTVEFURV9VTktOT1dOOgorICAgICAgICAgICAgICAgICAgICAvLyBOZWl0aGVyIHJlcXVpcmVkCisgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgfQogICAgICAgICB9CiAgICAgfQpkaWZmIC0tZ2l0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QAogcGFja2FnZSBjb20uYW5kcm9pZC5pbnRlcm5hbC50ZWxlcGhvbnkudWljYzsKIAogaW1wb3J0IGFuZHJvaWQub3MuKjsKLWltcG9ydCBhbmRyb2lkLnRlbGVwaG9ueS5SbG9nOwotCiBpbXBvcnQgY29tLmFuZHJvaWQuaW50ZXJuYWwudGVsZXBob255LkNvbW1hbmRzSW50ZXJmYWNlOwogCiBpbXBvcnQgamF2YS51dGlsLkFycmF5TGlzdDsKQEAgLTEwMSwyNiArOTksMjYgQEAKIAogICAgIHN0YXRpYyBjbGFzcyBMb2FkTGluZWFyRml4ZWRDb250ZXh0IHsKIAotICAgICAgICBpbnQgZWZpZDsKLSAgICAgICAgaW50IHJlY29yZE51bSwgcmVjb3JkU2l6ZSwgY291bnRSZWNvcmRzOwotICAgICAgICBib29sZWFuIGxvYWRBbGw7CisgICAgICAgIGludCBtRWZpZDsKKyAgICAgICAgaW50IG1SZWNvcmROdW0sIG1SZWNvcmRTaXplLCBtQ291bnRSZWNvcmRzOworICAgICAgICBib29sZWFuIG1Mb2FkQWxsOwogCi0gICAgICAgIE1lc3NhZ2Ugb25Mb2FkZWQ7CisgICAgICAgIE1lc3NhZ2UgbU9uTG9hZGVkOwogCiAgICAgICAgIEFycmF5TGlzdDxieXRlW10+IHJlc3VsdHM7CiAKICAgICAgICAgTG9hZExpbmVhckZpeGVkQ29udGV4dChpbnQgZWZpZCwgaW50IHJlY29yZE51bSwgTWVzc2FnZSBvbkxvYWRlZCkgewotICAgICAgICAgICAgdGhpcy5lZmlkID0gZWZpZDsKLSAgICAgICAgICAgIHRoaXMucmVjb3JkTnVtID0gcmVjb3JkTnVtOwotICAgICAgICAgICAgdGhpcy5vbkxvYWRlZCA9IG9uTG9hZGVkOwotICAgICAgICAgICAgdGhpcy5sb2FkQWxsID0gZmFsc2U7CisgICAgICAgICAgICBtRWZpZCA9IGVmaWQ7CisgICAgICAgICAgICBtUmVjb3JkTnVtID0gcmVjb3JkTnVtOworICAgICAgICAgICAgbU9uTG9hZGVkID0gb25Mb2FkZWQ7CisgICAgICAgICAgICBtTG9hZEFsbCA9IGZhbHNlOwogICAgICAgICB9CiAKICAgICAgICAgTG9hZExpbmVhckZpeGVkQ29udGV4dChpbnQgZWZpZCwgTWVzc2FnZSBvbkxvYWRlZCkgewotICAgICAgICAgICAgdGhpcy5lZmlkID0gZWZpZDsKLSAgICAgICAgICAgIHRoaXMucmVjb3JkTnVtID0gMTsKLSAgICAgICAgICAgIHRoaXMubG9hZEFsbCA9IHRydWU7Ci0gICAgICAgICAgICB0aGlzLm9uTG9hZGVkID0gb25Mb2FkZWQ7CisgICAgICAgICAgICBtRWZpZCA9IGVmaWQ7CisgICAgICAgICAgICBtUmVjb3JkTnVtID0gMTsKKyAgICAgICAgICAgIG1Mb2FkQWxsID0gdHJ1ZTsKKyAgICAgICAgICAgIG1PbkxvYWRlZCA9IG9uTG9hZGVkOwogICAgICAgICB9CiAgICAgfQogCkBAIC0zMjAsNiArMzE4LDcgQEAKIAogICAgIC8vKioqKiogT3ZlcnJpZGRlbiBmcm9tIEhhbmRsZXIKIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIGhhbmRsZU1lc3NhZ2UoTWVzc2FnZSBtc2cpIHsKICAgICAgICAgQXN5bmNSZXN1bHQgYXI7CiAgICAgICAgIEljY0lvUmVzdWx0IHJlc3VsdDsKQEAgLTM0MSw3ICszNDAsNyBAQAogICAgICAgICAgICAgICAgIGFyID0gKEFzeW5jUmVzdWx0KSBtc2cub2JqOwogICAgICAgICAgICAgICAgIGxjID0gKExvYWRMaW5lYXJGaXhlZENvbnRleHQpIGFyLnVzZXJPYmo7CiAgICAgICAgICAgICAgICAgcmVzdWx0ID0gKEljY0lvUmVzdWx0KSBhci5yZXN1bHQ7Ci0gICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBsYy5vbkxvYWRlZDsKKyAgICAgICAgICAgICAgICByZXNwb25zZSA9IGxjLm1PbkxvYWRlZDsKIAogICAgICAgICAgICAgICAgIGlmIChhci5leGNlcHRpb24gIT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICBzZW5kUmVzdWx0KHJlc3BvbnNlLCBudWxsLCBhci5leGNlcHRpb24pOwpAQCAtMzU2LDcgKzM1NSw3IEBACiAgICAgICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAgICAgZGF0YSA9IHJlc3VsdC5wYXlsb2FkOwotICAgICAgICAgICAgICAgIGxjLnJlY29yZFNpemUgPSBkYXRhW1JFU1BPTlNFX0RBVEFfUkVDT1JEX0xFTkdUSF0gJiAweEZGOworICAgICAgICAgICAgICAgIGxjLm1SZWNvcmRTaXplID0gZGF0YVtSRVNQT05TRV9EQVRBX1JFQ09SRF9MRU5HVEhdICYgMHhGRjsKIAogICAgICAgICAgICAgICAgIGlmICgoVFlQRV9FRiAhPSBkYXRhW1JFU1BPTlNFX0RBVEFfRklMRV9UWVBFXSkgfHwKICAgICAgICAgICAgICAgICAgICAgKEVGX1RZUEVfTElORUFSX0ZJWEVEICE9IGRhdGFbUkVTUE9OU0VfREFUQV9TVFJVQ1RVUkVdKSkgewpAQCAtMzY1LDEwICszNjQsMTAgQEAKICAgICAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgICAgICBsb2dkKCJJY2NGaWxlSGFuZGxlcjogcmVhZCBFRiBJTUciKTsKLSAgICAgICAgICAgICAgICBtQ2kuaWNjSU9Gb3JBcHAoQ09NTUFORF9SRUFEX1JFQ09SRCwgbGMuZWZpZCwgZ2V0RUZQYXRoKGxjLmVmaWQpLAotICAgICAgICAgICAgICAgICAgICAgICAgbGMucmVjb3JkTnVtLAorICAgICAgICAgICAgICAgIG1DaS5pY2NJT0ZvckFwcChDT01NQU5EX1JFQURfUkVDT1JELCBsYy5tRWZpZCwgZ2V0RUZQYXRoKGxjLm1FZmlkKSwKKyAgICAgICAgICAgICAgICAgICAgICAgIGxjLm1SZWNvcmROdW0sCiAgICAgICAgICAgICAgICAgICAgICAgICBSRUFEX1JFQ09SRF9NT0RFX0FCU09MVVRFLAotICAgICAgICAgICAgICAgICAgICAgICAgbGMucmVjb3JkU2l6ZSwgbnVsbCwgbnVsbCwgbUFpZCwKKyAgICAgICAgICAgICAgICAgICAgICAgIGxjLm1SZWNvcmRTaXplLCBudWxsLCBudWxsLCBtQWlkLAogICAgICAgICAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZShFVkVOVF9SRUFEX0lNR19ET05FLCBJY2NDb25zdGFudHMuRUZfSU1HLCAwLCByZXNwb25zZSkpOwogICAgICAgICAgICAgICAgIGJyZWFrOwogCkBAIC0zNzYsNyArMzc1LDcgQEAKICAgICAgICAgICAgICAgICBhciA9IChBc3luY1Jlc3VsdCkgbXNnLm9iajsKICAgICAgICAgICAgICAgICBsYyA9IChMb2FkTGluZWFyRml4ZWRDb250ZXh0KSBhci51c2VyT2JqOwogICAgICAgICAgICAgICAgIHJlc3VsdCA9IChJY2NJb1Jlc3VsdCkgYXIucmVzdWx0OwotICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gbGMub25Mb2FkZWQ7CisgICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBsYy5tT25Mb2FkZWQ7CiAKICAgICAgICAgICAgICAgICBpY2NFeGNlcHRpb24gPSByZXN1bHQuZ2V0RXhjZXB0aW9uKCk7CiAgICAgICAgICAgICAgICAgaWYgKGljY0V4Y2VwdGlvbiAhPSBudWxsKSB7CkBAIC0zOTcsNyArMzk2LDcgQEAKICAgICAgICAgICAgICAgICBhciA9IChBc3luY1Jlc3VsdCltc2cub2JqOwogICAgICAgICAgICAgICAgIGxjID0gKExvYWRMaW5lYXJGaXhlZENvbnRleHQpIGFyLnVzZXJPYmo7CiAgICAgICAgICAgICAgICAgcmVzdWx0ID0gKEljY0lvUmVzdWx0KSBhci5yZXN1bHQ7Ci0gICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBsYy5vbkxvYWRlZDsKKyAgICAgICAgICAgICAgICByZXNwb25zZSA9IGxjLm1PbkxvYWRlZDsKIAogICAgICAgICAgICAgICAgIGlmIChhci5leGNlcHRpb24gIT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICBzZW5kUmVzdWx0KHJlc3BvbnNlLCBudWxsLCBhci5leGNlcHRpb24pOwpAQCAtNDI5LDcgKzQyOCw3IEBACiAgICAgICAgICAgICAgICAgYXIgPSAoQXN5bmNSZXN1bHQpbXNnLm9iajsKICAgICAgICAgICAgICAgICBsYyA9IChMb2FkTGluZWFyRml4ZWRDb250ZXh0KSBhci51c2VyT2JqOwogICAgICAgICAgICAgICAgIHJlc3VsdCA9IChJY2NJb1Jlc3VsdCkgYXIucmVzdWx0OwotICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gbGMub25Mb2FkZWQ7CisgICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBsYy5tT25Mb2FkZWQ7CiAKICAgICAgICAgICAgICAgICBpZiAoYXIuZXhjZXB0aW9uICE9IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgc2VuZFJlc3VsdChyZXNwb25zZSwgbnVsbCwgYXIuZXhjZXB0aW9uKTsKQEAgLTQ0NCw4ICs0NDMsOCBAQAogICAgICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgICAgIGRhdGEgPSByZXN1bHQucGF5bG9hZDsKLSAgICAgICAgICAgICAgICBmaWxlaWQgPSBsYy5lZmlkOwotICAgICAgICAgICAgICAgIHJlY29yZE51bSA9IGxjLnJlY29yZE51bTsKKyAgICAgICAgICAgICAgICBmaWxlaWQgPSBsYy5tRWZpZDsKKyAgICAgICAgICAgICAgICByZWNvcmROdW0gPSBsYy5tUmVjb3JkTnVtOwogCiAgICAgICAgICAgICAgICAgaWYgKFRZUEVfRUYgIT0gZGF0YVtSRVNQT05TRV9EQVRBX0ZJTEVfVFlQRV0pIHsKICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEljY0ZpbGVUeXBlTWlzbWF0Y2goKTsKQEAgLTQ1NSwyMSArNDU0LDIxIEBACiAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBJY2NGaWxlVHlwZU1pc21hdGNoKCk7CiAgICAgICAgICAgICAgICAgfQogCi0gICAgICAgICAgICAgICAgbGMucmVjb3JkU2l6ZSA9IGRhdGFbUkVTUE9OU0VfREFUQV9SRUNPUkRfTEVOR1RIXSAmIDB4RkY7CisgICAgICAgICAgICAgICAgbGMubVJlY29yZFNpemUgPSBkYXRhW1JFU1BPTlNFX0RBVEFfUkVDT1JEX0xFTkdUSF0gJiAweEZGOwogCiAgICAgICAgICAgICAgICAgc2l6ZSA9ICgoZGF0YVtSRVNQT05TRV9EQVRBX0ZJTEVfU0laRV8xXSAmIDB4ZmYpIDw8IDgpCiAgICAgICAgICAgICAgICAgICAgICAgICsgKGRhdGFbUkVTUE9OU0VfREFUQV9GSUxFX1NJWkVfMl0gJiAweGZmKTsKIAotICAgICAgICAgICAgICAgIGxjLmNvdW50UmVjb3JkcyA9IHNpemUgLyBsYy5yZWNvcmRTaXplOworICAgICAgICAgICAgICAgIGxjLm1Db3VudFJlY29yZHMgPSBzaXplIC8gbGMubVJlY29yZFNpemU7CiAKLSAgICAgICAgICAgICAgICAgaWYgKGxjLmxvYWRBbGwpIHsKLSAgICAgICAgICAgICAgICAgICAgIGxjLnJlc3VsdHMgPSBuZXcgQXJyYXlMaXN0PGJ5dGVbXT4obGMuY291bnRSZWNvcmRzKTsKKyAgICAgICAgICAgICAgICAgaWYgKGxjLm1Mb2FkQWxsKSB7CisgICAgICAgICAgICAgICAgICAgICBsYy5yZXN1bHRzID0gbmV3IEFycmF5TGlzdDxieXRlW10+KGxjLm1Db3VudFJlY29yZHMpOwogICAgICAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgICAgICAgbUNpLmljY0lPRm9yQXBwKENPTU1BTkRfUkVBRF9SRUNPUkQsIGxjLmVmaWQsIGdldEVGUGF0aChsYy5lZmlkKSwKLSAgICAgICAgICAgICAgICAgICAgICAgICBsYy5yZWNvcmROdW0sCisgICAgICAgICAgICAgICAgIG1DaS5pY2NJT0ZvckFwcChDT01NQU5EX1JFQURfUkVDT1JELCBsYy5tRWZpZCwgZ2V0RUZQYXRoKGxjLm1FZmlkKSwKKyAgICAgICAgICAgICAgICAgICAgICAgICBsYy5tUmVjb3JkTnVtLAogICAgICAgICAgICAgICAgICAgICAgICAgIFJFQURfUkVDT1JEX01PREVfQUJTT0xVVEUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgbGMucmVjb3JkU2l6ZSwgbnVsbCwgbnVsbCwgbUFpZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICBsYy5tUmVjb3JkU2l6ZSwgbnVsbCwgbnVsbCwgbUFpZCwKICAgICAgICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX1JFQURfUkVDT1JEX0RPTkUsIGxjKSk7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgY2FzZSBFVkVOVF9HRVRfQklOQVJZX1NJWkVfRE9ORToKQEAgLTUxNSw3ICs1MTQsNyBAQAogICAgICAgICAgICAgICAgIGFyID0gKEFzeW5jUmVzdWx0KW1zZy5vYmo7CiAgICAgICAgICAgICAgICAgbGMgPSAoTG9hZExpbmVhckZpeGVkQ29udGV4dCkgYXIudXNlck9iajsKICAgICAgICAgICAgICAgICByZXN1bHQgPSAoSWNjSW9SZXN1bHQpIGFyLnJlc3VsdDsKLSAgICAgICAgICAgICAgICByZXNwb25zZSA9IGxjLm9uTG9hZGVkOworICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gbGMubU9uTG9hZGVkOwogCiAgICAgICAgICAgICAgICAgaWYgKGFyLmV4Y2VwdGlvbiAhPSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgIHNlbmRSZXN1bHQocmVzcG9uc2UsIG51bGwsIGFyLmV4Y2VwdGlvbik7CkBAIC01MjksMjAgKzUyOCwyMCBAQAogICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgICAgICBpZiAoIWxjLmxvYWRBbGwpIHsKKyAgICAgICAgICAgICAgICBpZiAoIWxjLm1Mb2FkQWxsKSB7CiAgICAgICAgICAgICAgICAgICAgIHNlbmRSZXN1bHQocmVzcG9uc2UsIHJlc3VsdC5wYXlsb2FkLCBudWxsKTsKICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICBsYy5yZXN1bHRzLmFkZChyZXN1bHQucGF5bG9hZCk7CiAKLSAgICAgICAgICAgICAgICAgICAgbGMucmVjb3JkTnVtKys7CisgICAgICAgICAgICAgICAgICAgIGxjLm1SZWNvcmROdW0rKzsKIAotICAgICAgICAgICAgICAgICAgICBpZiAobGMucmVjb3JkTnVtID4gbGMuY291bnRSZWNvcmRzKSB7CisgICAgICAgICAgICAgICAgICAgIGlmIChsYy5tUmVjb3JkTnVtID4gbGMubUNvdW50UmVjb3JkcykgewogICAgICAgICAgICAgICAgICAgICAgICAgc2VuZFJlc3VsdChyZXNwb25zZSwgbGMucmVzdWx0cywgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBtQ2kuaWNjSU9Gb3JBcHAoQ09NTUFORF9SRUFEX1JFQ09SRCwgbGMuZWZpZCwgZ2V0RUZQYXRoKGxjLmVmaWQpLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGMucmVjb3JkTnVtLAorICAgICAgICAgICAgICAgICAgICAgICAgbUNpLmljY0lPRm9yQXBwKENPTU1BTkRfUkVBRF9SRUNPUkQsIGxjLm1FZmlkLCBnZXRFRlBhdGgobGMubUVmaWQpLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGMubVJlY29yZE51bSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFJFQURfUkVDT1JEX01PREVfQUJTT0xVVEUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg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cmluZygpIHsKKyAgICAgICAgcmV0dXJuICJtRGVzdHJveWVkPSIgKyBtRGVzdHJveWVkCisgICAgICAgICAgICAgICAgKyAiIG1Db250ZXh0PSIgKyBtQ29udGV4dAorICAgICAgICAgICAgICAgICsgIiBtQ2k9IiArIG1DaQorICAgICAgICAgICAgICAgICsgIiBtRmg9IiArIG1GaAorICAgICAgICAgICAgICAgICsgIiBtUGFyZW50QXBwPSIgKyBtUGFyZW50QXBwCisgICAgICAgICAgICAgICAgKyAiIHJlY29yZHNMb2FkZWRSZWdpc3RyYW50cz0iICsgcmVjb3Jkc0xvYWRlZFJlZ2lzdHJhbnRzCisgICAgICAgICAgICAgICAgKyAiIG1JbXNpUmVhZHlSZWdpc3RyYW50cz0iICsgbUltc2lSZWFkeVJlZ2lzdHJhbnRzCisgICAgICAgICAgICAgICAgKyAiIG1SZWNvcmRzRXZlbnRzUmVnaXN0cmFudHM9IiArIG1SZWNvcmRzRXZlbnRzUmVnaXN0cmFudHMKKyAgICAgICAgICAgICAgICArICIgbU5ld1Ntc1JlZ2lzdHJhbnRzPSIgKyBtTmV3U21zUmVnaXN0cmFudHMKKyAgICAgICAgICAgICAgICArICIgbU5ldHdvcmtTZWxlY3Rpb25Nb2RlQXV0b21hdGljUmVnaXN0cmFudHM9IgorICAgICAgICAgICAgICAgICAgICAgICAgKyBtTmV0d29ya1NlbGVjdGlvbk1vZGVBdXRvbWF0aWNSZWdpc3RyYW50cworICAgICAgICAgICAgICAgICsgIiByZWNvcmRzVG9Mb2FkPSIgKyBtUmVjb3Jkc1RvTG9hZAorICAgICAgICAgICAgICAgICsgIiBhZG5DYWNoZT0iICsgbUFkbkNhY2hlCisgICAgICAgICAgICAgICAgKyAiIHJlY29yZHNSZXF1ZXN0ZWQ9IiArIG1SZWNvcmRzUmVxdWVzdGVkCisgICAgICAgICAgICAgICAgKyAiIGljY2lkPSIgKyBpY2NJZAorICAgICAgICAgICAgICAgICsgIiBtc2lzZG49IiArIG1Nc2lzZG4KKyAgICAgICAgICAgICAgICArICIgbXNpc2RuVGFnPSIgKyBtTXNpc2RuVGFnCisgICAgICAgICAgICAgICAgKyAiIHZvaWNlTWFpbE51bT0iICsgbVZvaWNlTWFpbE51bQorICAgICAgICAgICAgICAgICsgIiB2b2ljZU1haWxUYWc9IiArIG1Wb2ljZU1haWxUYWcKKyAgICAgICAgICAgICAgICArICIgbmV3Vm9pY2VNYWlsTnVtPSIgKyBtTmV3Vm9pY2VNYWlsTnVtCisgICAgICAgICAgICAgICAgKyAiIG5ld1ZvaWNlTWFpbFRhZz0iICsgbU5ld1ZvaWNlTWFpbFRhZworICAgICAgICAgICAgICAgICsgIiBpc1ZvaWNlTWFpbEZpeGVkPSIgKyBtSXNWb2ljZU1haWxGaXhlZAorICAgICAgICAgICAgICAgICsgIiBjb3VudFZvaWNlTWVzc2FnZXM9IiArIG1Db3VudFZvaWNlTWVzc2FnZXMKKyAgICAgICAgICAgICAgICArICIgbUltc2k9IiArIG1JbXNpCisgICAgICAgICAgICAgICAgKyAiIG1uY0xlbmd0aD0iICsgbU1uY0xlbmd0aAorICAgICAgICAgICAgICAgICsgIiBtYWlsYm94SW5kZXg9IiArIG1NYWlsYm94SW5kZXgKKyAgICAgICAgICAgICAgICArICIgc3BuPSIgKyBtU3BuOworCisgICAgfQorCiAgICAgLyoqCiAgICAgICogR2VuZXJpYyBJQ0MgcmVjb3JkIGxvYWRlZCBjYWxsYmFjay4gU3ViY2xhc3NlcyBjYW4gY2FsbCBFRiBsb2FkIG1ldGhvZHMgb24KICAgICAgKiB7QGxpbmsgSWNjRmlsZUhhbmRsZXJ9IHBhc3NpbmcgYSBNZXNzYWdlIGZvciBvbkxvYWRlZCB3aXRoIHRoZSB3aGF0IGZpZWxkIHNldCB0bwogICAgICAqIHtAbGluayAjRVZFTlRfR0VUX0lDQ19SRUNPUkRfRE9ORX0gYW5kIHRoZSBvYmogZmllbGQgc2V0IHRvIGFuIGluc3RhbmNlCiAgICAgICogb2YgdGhpcyBpbnR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gKyBtTXNpc2RuKTsKIAogCi0gICAgICAgIEFkblJlY29yZCBhZG4gPSBuZXcgQWRuUmVjb3JkKG1zaXNkblRhZywgbXNpc2RuKTsKKyAgICAgICAgQWRuUmVjb3JkIGFkbiA9IG5ldyBBZG5SZWNvcmQobU1zaXNkblRhZywgbU1zaXNkbik7CiAKICAgICAgICAgbmV3IEFkblJlY29yZExvYWRlcihtRmgpLnVwZGF0ZUVGKGFkbiwgRUZfTVNJU0ROLCBFRl9FWFQxLCAxLCBudWxsLAogICAgICAgICAgICAgICAgIG9idGFpbk1lc3NhZ2UoRVZFTlRfU0VUX01TSVNETl9ET05FLCBvbkNvbXBsZXRlKSk7CiAgICAgfQogCiAgICAgcHVibGljIFN0cmluZyBnZXRNc2lzZG5BbHBoYVRhZygpIHsKLSAgICAgICAgcmV0dXJuIG1zaXNkblRhZzsKKyAgICAgICAgcmV0dXJuIG1Nc2lzZG5UYWc7CiAgICAgfQogCiAgICAgcHVibGljIFN0cmluZyBnZXRWb2ljZU1haWxOdW1iZXIoKSB7Ci0gICAgICAgIHJldHVybiB2b2ljZU1haWxOdW07CisgICAgICAgIHJldHVybiBtVm9pY2VNYWlsTnVtOwogICAgIH0KIAogICAgIC8qKgpAQCAtMjU2LDcgKzI4OCw3IEBACiAgICAgICogQHJldHVybiBudWxsIGlmIFNJTSBpcyBub3QgeWV0IHJlYWR5IG9yIG5vIFJVSU0gZW50cnkKICAgICAgKi8KICAgICBwdWJsaWMgU3RyaW5nIGdldFNlcnZpY2VQcm92aWRlck5hbWUoKSB7Ci0gICAgICAgIHJldHVybiBzcG47CisgICAgICAgIHJldHVybiBtU3BuOwogICAgIH0KIAogICAgIC8qKgpAQCAtMjg3LDcgKzMxOSw3IEBACiAgICAgICAgICAgICBNZXNzYWdlIG9uQ29tcGxldGUpOwogCiAgICAgcHVibGljIFN0cmluZyBnZXRWb2ljZU1haWxBbHBoYVRhZygpIHsKLSAgICAgICAgcmV0dXJuIHZvaWNlTWFpbFRhZzsK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ICBwcml2YXRlIFN0cmluZyBtSG9tZVN5c3RlbUlkOwogICAgIHByaXZhdGUgU3RyaW5nIG1Ib21lTmV0d29ya0lkOwogCisgICAgQE92ZXJyaWRlCisgICAgcHVibGljIFN0cmluZyB0b1N0cmluZygpIHsKKyAgICAgICAgcmV0dXJuICJSdWltUmVjb3JkczogIiArIHN1cGVyLnRvU3RyaW5nKCkKKyAgICAgICAgICAgICAgICArICIgbV9vdGFfY29tbWl0ZWQiICsgbU90YUNvbW1pdGVkCisgICAgICAgICAgICAgICAgKyAiIG1NeU1vYmlsZU51bWJlcj0iICsgInh4eHgiCisgICAgICAgICAgICAgICAgKyAiIG1NaW4yTWluMT0iICsgbU1pbjJNaW4xCisgICAgICAgICAgICAgICAgKyAiIG1QcmxWZXJzaW9uPSIgKyBtUHJsVmVyc2lvbgorICAgICAgICAgICAgICAgICsgIiBtRUZwbD0iICsgbUVGcGwKKyAgICAgICAgICAgICAgICArICIgbUVGbGk9IiArIG1FRmxpCisgICAgICAgICAgICAgICAgKyAiIG1Dc2ltU3BuRGlzcGxheUNvbmRpdGlvbj0iICsgbUNzaW1TcG5EaXNwbGF5Q29uZGl0aW9uCisgICAgICAgICAgICAgICAgKyAiIG1NZG49IiArIG1NZG4KKyAgICAgICAgICAgICAgICArICIgbU1pbj0iICsgbU1pbgorICAgICAgICAgICAgICAgICsgIiBtSG9tZVN5c3RlbUlkPSIgKyBtSG9tZVN5c3RlbUlkCisgICAgICAgICAgICAgICAgKyAiIG1Ib21lTmV0d29ya0lkPSIgKyBtSG9tZU5ldHdvcmtJZDsKKyAgICB9CisKICAgICAvLyAqKioqKiBFdmVudCBDb25zdGFudHMKICAgICBwcml2YXRlIHN0YXRpYyBmaW5hbCBpbnQgRVZFTlRfQVBQX1JFQURZID0gMTsKICAgICBwcml2YXRlIHN0YXRpYyBmaW5hbCBpbnQgRVZFTlRfR0VUX0lNU0lfRE9ORSA9IDM7CkBAIC05MywxMiArMTAwLDEyIEBACiAgICAgcHVibGlj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ICAgICAgc3BuID0gIiI7CisgICAgICAgICAgICAgICAgbVNwbiA9ICIiOwogICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgc3dpdGNoIChlbmNvZGluZykgewogICAgICAgICAgICAgICAgIGNhc2UgVXNlckRhdGEuRU5DT0RJTkdfT0NURVQ6CiAgICAgICAgICAgICAgICAgY2FzZSBVc2VyRGF0YS5FTkNPRElOR19MQVRJTjoKLSAgICAgICAgICAgICAgICAgICAgc3BuID0gbmV3IFN0cmluZyhzcG5EYXRhLCAwLCBudW1CeXRlcywgIklTTy04ODU5LTEiKTsKKyAgICAgICAgICAgICAgICAgICAgbVNwbiA9IG5ldyBTdHJpbmcoc3BuRGF0YSwgMCwgbnVtQnl0ZXMsICJJU08tODg1OS0xIik7CiAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgIGNhc2UgVXNlckRhdGEuRU5DT0RJTkdfSUE1OgogICAgICAgICAgICAgICAgIGNhc2UgVXNlckRhdGEuRU5DT0RJTkdfR1NNXzdCSVRfQUxQSEFCRVQ6CiAgICAgICAgICAgICAgICAgY2FzZSBVc2VyRGF0YS5FTkNPRElOR183QklUX0FTQ0lJOgotICAgICAgICAgICAgICAgICAgICBzcG4gPSBHc21BbHBoYWJldC5nc203Qml0UGFja2VkVG9TdHJpbmcoc3BuRGF0YSwgMCwgKG51bUJ5dGVzKjgpLzcpOworICAgICAgICAgICAgICAgICAgICBtU3BuID0gR3NtQWxwaGFiZXQuZ3NtN0JpdFBhY2tlZFRvU3RyaW5nKHNwbkRhdGEsIDAsIChudW1CeXRlcyo4KS83KTsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgY2FzZSBVc2VyRGF0YS5FTkNPRElOR19VTklDT0RFXzE2OgotICAgICAgICAgICAgICAgICAgICBzcG4gPSAgbmV3IFN0cmluZyhzcG5EYXRhLCAwLCBudW1CeXRlcywgInV0Zi0xNiIpOworICAgICAgICAgICAgICAgICAgICBtU3BuID0gIG5ldyBTdHJpbmcoc3BuRGF0YSwgMCwgbnVtQnl0ZXMsICJ1dGYtMTYiKTsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgbG9nKCJTUE4gZW5jb2Rpbmcgbm90IHN1cHBvcnRlZCIpOwpAQCAtMzAzLDE3ICszMTcsMTkgQEAKICAgICAgICAgICAgIH0gY2F0Y2goRXhjZXB0aW9uIGUpIHsKICAgICAgICAgICAgICAgICBsb2coInNwbiBkZWNvZGUgZXJyb3I6ICIgKyBlKTsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGlmIChEQkcpIGxvZygic3BuPSIgKyBzcG4pOworICAgICAgICAgICAgaWYgKERCRykgbG9nKCJzcG49IiArIG1TcG4pOwogICAgICAgICAgICAgaWYgKERCRykgbG9nKCJzcG5Db25kaXRpb249IiArIG1Dc2ltU3BuRGlzcGxheUNvbmRpdGlvbik7Ci0gICAgICAgICAgICBTeXN0ZW1Qcm9wZXJ0aWVzLnNldChQUk9QRVJUWV9JQ0NfT1BFUkFUT1JfQUxQSEEsIHNwbik7CisgICAgICAgICAgICBTeXN0ZW1Qcm9wZXJ0aWVzLnNldChQUk9QRVJUWV9JQ0NfT1BFUkFUT1JfQUxQSEEsIG1TcG4pOwogICAgICAgICB9CiAgICAgfQogCiAgICAgcHJpdmF0ZSBjbGFzcyBFZkNzaW1NZG5Mb2FkZWQgaW1wbGVtZW50cyBJY2NSZWNvcmRMb2FkZWQgeworICAgICAgICBAT3ZlcnJpZGUKICAgICAgICAgcHVibGljIFN0cmluZyBnZXRFZk5hbWUoKSB7CiAgICAgICAgICAgICByZXR1cm4gIkVGX0NTSU1fTUROIjsKICAgICAgICAgfQogCisgICAgICAgIEBPdmVycmlkZQogICAgICAgICBwdWJsaWMgdm9pZCBvblJl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gICAgIC8vIFBlciBDLlMwMDY1IHNlY3Rpb24gNS4yLjgKICAgICAgICAgICAgIEFycmF5TGlzdDxieXRlW10+IGRhdGFMaXN0ID0gKEFycmF5TGlzdDxieXRlW10+KSBhci5yZXN1bHQ7CkBAIC0zOTIsOSArNDEyLDExIEBACiAgICAgfQogCiAgICAgcHJpdmF0ZSBjbGFzcyBFZkNzaW1FcHJsTG9hZGVkIGltcGxlbWVudHMgSWNjUmVjb3JkTG9hZGVkIHsKKyAgICAgICAgQE92ZXJyaWRlCiAgICAgICAgIHB1YmxpYyBTdHJpbmcgZ2V0RWZOYW1lKCkgewogICAgICAgICAgICAgcmV0dXJuICJFRl9DU0lNX0VQUkwiOwogICAgICAgICB9CisgICAgICAgIEBPdmVycmlkZQogICAgICAgICBwdWJsaWMgdm9pZCBvblJlY29yZExvYWRlZChBc3luY1Jlc3VsdCBhcikgewogICAgICAgICAgICAgb25HZXRDU2ltRXBybERvbmUoYXIpOwogICAgICAgICB9CkBAIC00OTEsOSArNTEzLDkgQEAKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgfQogCi0gICAgICAgICAgICAgICAgaWNjaWQgPSBJY2NVdGlscy5iY2RUb1N0cmluZyhkYXRhLCAwLCBkYXRhLmxlbmd0aCk7CisgICAgICAgICAgICAgICAgaWNjSWQgPSBJY2NVdGlscy5iY2RUb1N0cmluZyhkYXRhLCAwLCBkYXRhLmxlbmd0aCk7CiAKLSAgICAgICAgICAgICAgICBsb2coImljY2lkOiAiICsgaWNjaWQpOworICAgICAgICAgICAgICAgIGxvZygiaWNjaWQ6ICIgKyBpY2NJZCk7CiAKICAgICAgICAgICAgIGJyZWFrOwogCkBAIC01OTEsMTQgKzYxMywxNCBAQAogICAgIHByb3RlY3RlZCB2b2lkIG9uUmVjb3JkTG9hZGVkKCkgewogICAgICAgICAvLyBPbmUgcmVjb3JkIGxvYWRlZCBzdWNjZXNzZnVsbHkgb3IgZmFpbGVkLCBJbiB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XNwb25zZS5SRUZSRVNIX1JFU1VMVF9GSUxFX1VQREFURToKICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coImhhbmRsZVJ1aW1SZWZyZXNoIHdpdGggU0lNX1JFRlJFU0hfRklMRV9VUERBVEVEIik7Ci0gICAgICAgICAgICAgICAgYWRuQ2FjaGUucmVzZXQoKTsKKyAgICAgICAgICAgICAgICBtQWRuQ2FjaGUucmVzZXQoKTsKICAgICAgICAgICAgICAgICBmZXRjaFJ1aW1SZWNvcmRzKCk7CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICBjYXNlIEljY1JlZnJlc2hSZXNwb25zZS5SRUZSRVNIX1JFU1VMVF9JTklUOgpAQCAtODA2LDcgKzgyOCw3IEBACiAgICAgICAgIHB3LnByaW50bG4oIlJ1aW1SZWNvcmRzOiAiICsgdGhpcyk7CiAgICAgICAgIHB3LnByaW50bG4oIiBleHRlbmRzOiIpOwogICAgICAgICBzdXBlci5kdW1wKGZkLCBwdywgYXJncyk7Ci0gICAgICAgIHB3LnByaW50bG4oIiBtX290YV9jb21taXRlZD0iICsgbV9vdGFfY29tbWl0ZWQpOworICAgICAgICBwdy5wcmludGxuKCIgbU90YUNvbW1pdGVkPSIgKyBtT3RhQ29tbWl0ZWQpOwogICAgICAgICBwdy5wcmludGxuKCIgbU15TW9iaWxlTnVtYmVyPSIgKyBtTXlNb2JpbGVOdW1iZXIpOwogICAgICAgICBwdy5wcmludGxuKCIgbU1pbjJNaW4xPSIgKyBtTWluMk1pbjEpOwogICAgICAgICBwdy5wcmludGxuKCIgbVBybFZlcnNpb249IiArIG1QcmxWZXJzaW9uKTsKZGlmZiAtLWdpdCBhL3NyYy9qYXZhL2NvbS9hbmRyb2lkL2ludGVybmFsL3RlbGVwaG9ueS91aWNjL1NJTUZpbGVIYW5kbGVyLmphdmEgYi9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvdWljYy9TSU1GaWxlSGF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gQXJyYXlMaXN0PFN0cmluZz4gc3BkaU5ldHdvcmtzID0gbnVsbDsKKyAgICBBcnJheUxpc3Q8U3RyaW5nPiBtU3BkaU5ldHdvcmtzID0gbnVsbDsKIAotICAgIFN0cmluZyBwbm5Ib21lTmFtZSA9IG51bGw7CisgICAgU3RyaW5nIG1Qbm5Ib21lTmFtZSA9IG51bGw7CiAKICAgICBVc2ltU2VydmljZVRhYmxlIG1Vc2ltU2VydmljZVRhYmxlOwogCi0gICAgLy8gKioqKiogQ29uc3RhbnRzCisgICAgQE92ZXJyaWRlCisgICAgcHVibGljIFN0cmluZyB0b1N0cmluZygpIHsKKyAgICAgICAgcmV0dXJuICJTaW1SZWNvcmRzOiAiICsgc3VwZXIudG9TdHJpbmcoKQorICAgICAgICAgICAgICAgICsgIiBtVm1Db25maWciICsgbVZtQ29uZmlnCisgICAgICAgICAgICAgICAgKyAiIG1TcG5PdmVycmlkZT0iICsgIm1TcG5PdmVycmlkZSIKKyAgICAgICAgICAgICAgICArICIgY2FsbEZvcndhcmRpbmdFbmFibGVkPSIgKyBtQ2FsbEZvcndhcmRpbmdFbmFibGVkCisgICAgICAgICAgICAgICAgKyAiIHNwblN0YXRlPSIgKyBtU3BuU3RhdGUKKyAgICAgICAgICAgICAgICArICIgbUNwaHNJbmZvPSIgKyBtQ3Boc0luZm8KKyAgICAgICAgICAgICAgICArICIgbUNzcFBsbW5FbmFibGVkPSIgKyBtQ3NwUGxtbkVuYWJsZWQKKyAgICAgICAgICAgICAgICArICIgZWZNV0lTPSIgKyBtRWZNV0lTCisgICAgICAgICAgICAgICAgKyAiIGVmQ1BIU19NV0k9IiArIG1FZkNQSFNfTVdJCisgICAgICAgICAgICAgICAgKyAiIG1FZkNmZj0iICsgbUVmQ2ZmCisgICAgICAgICAgICAgICAgKyAiIG1FZkNmaXM9IiArIG1FZkNmaXMKKyAgICAgICAgICAgICAgICArICIgZ2V0T3BlcmF0b3JOdW1lcmljPSIgKyBnZXRPcGVyYXRvck51bW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ZXN0cyBhcmUgbWFkZS4KLSAgICAgICAgcmVjb3Jkc1JlcXVlc3RlZCA9IGZhbHNlOworICAgICAgICBtUmVjb3Jkc1JlcXVlc3RlZCA9IGZhbHNlOwogICAgIH0KIAogCkBAIC0yNDUsOCArMjUyLDkgQEAKICAgICAgICAgcmV0dXJuIG1JbXNpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdHJpbmcgZ2V0TXNpc2RuTnVtYmVyKCkgewotICAgICAgICByZXR1cm4gbXNpc2RuOworICAgICAgICByZXR1cm4gbU1zaXNkbjsKICAgICB9CiAKICAgICBAT3ZlcnJpZGUKQEAgLTI2OSwyNyArMjc3LDMwIEBACiAgICAgICogICAgICAgICgoQXN5bmNSZXN1bHQpb25Db21wbGV0ZS5vYmopLmV4Y2VwdGlvbiA9PSBudWxsIG9uIHN1Y2Nlc3MKICAgICAgKiAgICAgICAgKChBc3luY1Jlc3VsdClvbkNvbXBsZXRlLm9iaikuZXhjZXB0aW9uICE9IG51bGwgb24gZmFpbAogICAgICAqLworICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHNldE1zaXNkbk51bWJlcihTdHJpbmcgYWxwaGFUYWcsIFN0cmluZyBudW1iZXIsCiAgICAgICAgICAgICBNZXNzYWdlIG9uQ29tcGxldGUpIHsKIAotICAgICAgICBtc2lzZG4gPSBudW1iZXI7Ci0gICAgICAgIG1zaXNkblRhZyA9IGFscGhhVGFnOworICAgICAgICBtTXNpc2RuID0gbnVtYmVyOworICAgICAgICBtTXNpc2RuVGFnID0gYWxwaGFUYWc7CiAKLSAgICAgICAgaWYoREJHKSBsb2coIlNldCBNU0lTRE46ICIgKyBtc2lzZG5UYWcgKyAiICIgKyAvKm1zaXNkbiovICJ4eHh4eHh4Iik7CisgICAgICAgIGlmKERCRykgbG9nKCJTZXQgTVNJU0ROOiAiICsgbU1zaXNkblRhZyArICIgIiArIC8qbU1zaXNkbiovICJ4eHh4eHh4Iik7CiAKIAotICAgICAgICBBZG5SZWNvcmQgYWRuID0gbmV3IEFkblJlY29yZChtc2lzZG5UYWcsIG1zaXNkbik7CisgICAgICAgIEFkblJlY29yZCBhZG4gPSBuZXcgQWRuUmVjb3JkKG1Nc2lzZG5UYWcsIG1Nc2lzZG4pOwogCiAgICAgICAgIG5ldyBBZG5SZWNvcmRMb2FkZXIobUZoKS51cGRhdGVFRihhZG4sIEVGX01TSVNETiwgRUZfRVhUMSwgMSwgbnVsbCwKICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX1NFVF9NU0lTRE5fRE9ORSwgb25Db21wbGV0ZSkpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdHJpbmcgZ2V0TXNpc2RuQWxwaGFUYWcoKSB7Ci0gICAgICAgIHJldHVybiBtc2lzZG5UYWc7CisgICAgICAgIHJldHVybiBtTXNpc2RuVGFnOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdHJpbmcgZ2V0Vm9pY2VNYWlsTnVtYmVyKCkgewotICAgICAgICByZXR1cm4gdm9pY2VNYWlsTnVtOworICAgICAgICByZXR1cm4gbVZvaWNlTWFpbE51bTsKICAgICB9CiAKICAgICAvKioKQEAgLTMxNiwyNCArMzI3LDI1IEBACiAgICAgICogICAgICAgICgoQXN5bmNSZXN1bHQpb25Db21wbGV0ZS5vYmopLmV4Y2VwdGlvbiA9PSBudWxsIG9uIHN1Y2Nlc3MKICAgICAgKiAgICAgICAgKChBc3luY1Jlc3VsdClvbkNvbXBsZXRlLm9iaikuZXhjZXB0aW9uICE9IG51bGwgb24gZmFpbAogICAgICAqLworICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHNldFZvaWNlTWFpbE51bWJlcihTdHJpbmcgYWxwaGFUYWcsIFN0cmluZyB2b2ljZU51bWJlciwKICAgICAgICAgICAgIE1lc3NhZ2Ugb25Db21wbGV0ZSkgewotICAgICAgICBpZiAoaXNWb2ljZU1haWxGaXhlZCkgeworICAgICAgICBpZiAobUlzVm9pY2VNYWlsRml4ZWQpIHsKICAgICAgICAgICAgIEFzeW5jUmVzdWx0LmZvck1lc3NhZ2UoKG9uQ29tcGxldGUpKS5leGNlcHRpb24gPQogICAgICAgICAgICAgICAgICAgICBuZXcgSWNjVm1GaXhlZEV4Y2VwdGlvbigiVm9pY2VtYWlsIG51bWJlciBpcyBmaXhlZCBieSBvcGVyYXRvciIpOwogICAgICAgICAgICAgb25Db21wbGV0ZS5zZW5kVG9UYXJnZXQoKTsKICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgfQogCi0gICAgICAgIG5ld1ZvaWNlTWFpbE51bSA9IHZvaWNlTnVtYmVyOwotICAgICAgICBuZXdWb2ljZU1haWxUYWcgPSBhbHBoYVRhZzsKKyAgICAgICAgbU5ld1ZvaWNlTWFpbE51bSA9IHZvaWNlTnVtYmVyOworICAgICAgICBtTmV3Vm9pY2VNYWlsVGFnID0gYWxwaGFUYWc7CiAKLSAgICAgICAgQWRuUmVjb3JkIGFkbiA9IG5ldyBBZG5SZWNvcmQobmV3Vm9pY2VNYWlsVGFnLCBuZXdWb2ljZU1haWxOdW0pOworICAgICAgICBBZG5SZWNvcmQgYWRuID0gbmV3IEFkblJlY29yZChtTmV3Vm9pY2VNYWlsVGFnLCBtTmV3Vm9pY2VNYWlsTnVtKTsKIAotICAgICAgICBpZiAobWFpbGJveEluZGV4ICE9IDAgJiYgbWFpbGJveEluZGV4ICE9IDB4ZmYpIHsKKyAgICAgICAgaWYgKG1NYWlsYm94SW5kZXggIT0gMCAmJiBtTWFpbGJveEluZGV4ICE9IDB4ZmYpIHsKIAogICAgICAgICAgICAgbmV3IEFkblJlY29yZExvYWRlcihtRmgpLnVwZGF0ZUVGKGFkbiwgRUZfTUJETiwgRUZfRVhUNiwKLSAgICAgICAgICAgICAgICAgICAgbWFpbGJveEluZGV4LCBudWxsLAorICAgICAgICAgICAgICAgICAgICBtTWFpbGJveEluZGV4LCBudWxsLAogICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX1NFVF9NQkROX0RPTkUsIG9uQ29tcGxldGUpKTsKIAogICAgICAgICB9IGVsc2UgaWYgKGlzQ3Boc01haWxib3hFbmFibGVkKCkpIHsKQEAgLTM0OSw5ICszNjEsMTAgQEAKICAgICAgICAgfQogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdHJpbmcgZ2V0Vm9pY2VNYWlsQWxwaGFUYWcoKQogICAgIHsKLSAgICAgICAgcmV0dXJuIHZvaWNlTWFpbFRhZzsKKyAgICAgICAgcmV0dXJuIG1Wb2ljZU1haWxUYWc7CiAgICAgfQogCiAgICAgLyoqCkBAIC0zNjEsNiArMzc0LDcgQEAKICAgICAgKiAgICAgICAgICAgICAgICAgICAgIC0xIHRvIGluZGljYXRlIHRoYXQgYW4gdW5rbm93biBudW1iZXIgb2YKICAgICAgKiAgICAgICAgICAgICAgICAgICAgICBtZXNzYWdlcyBhcmUgd2FpdGluZwogICAgICAqLworICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkCiAgICAgc2V0Vm9pY2VNZXNzYWdlV2FpdGluZyhpbnQgbGluZSwgaW50IGNvdW50V2FpdGluZykgewogICAgICAgICBpZiAobGluZSAhPSAxKSB7CkBAIC0zNzcsMzkgKzM5MSwzOSBAQAogICAgICAgICAgICAgY291bnRXYWl0aW5nID0gMHhmZjsKICAgICAgICAgfQogCi0gICAgICAgIGNvdW50Vm9pY2VNZXNzYWdlcyA9IGNvdW50V2FpdGluZzsKKyAgICAgICAgbUNvdW50Vm9pY2VNZXNzYWdlcyA9IGNvdW50V2FpdGluZzsKIAogICAgICAgICBtUmVjb3Jkc0V2ZW50c1JlZ2lzdHJhbnRzLm5vdGlmeVJlc3VsdChFVkVOVF9NV0kpOwogCiAgICAgICAgIHRyeSB7Ci0gICAgICAgICAgICBpZiAoZWZNV0lTICE9IG51bGwpIHsKKyAgICAgICAgICAgIGlmIChtRWZNV0lTICE9IG51bGwpIHsKICAgICAgICAgICAgICAgICAvLyBUUyA1MS4wMTEgMTAuMy40NQogCiAgICAgICAgICAgICAgICAgLy8gbHNiIG9mIGJ5dGUgMCBpcyAndm9pY2VtYWlsJyBzdGF0dXMKLSAgICAgICAgICAgICAgICBlZk1XSVNbMF0gPSAoYnl0ZSkoKGVmTVdJU1swXSAmIDB4ZmUpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8IChjb3VudFZvaWNlTWVzc2FnZXMgPT0gMCA/IDAgOiAxKSk7CisgICAgICAgICAgICAgICAgbUVmTVdJU1swXSA9IChieXRlKSgobUVmTVdJU1swXSAmIDB4ZmUpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8IChtQ291bnRWb2ljZU1lc3NhZ2VzID09IDAgPyAwIDogMSkpOwogCiAgICAgICAgICAgICAgICAgLy8gYnl0ZSAxIGlzIHRoZSBudW1iZXIgb2Ygdm9pY2UgbWVzc2FnZXMgd2FpdGluZwogICAgICAgICAgICAgICAgIGlmIChjb3VudFdhaXRpbmcgPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgIC8vIFRoZSBzcGVjIGRvZXMgbm90IGRlZmluZSB3aGF0IHRoaXMgc2hvdWxkIGJlCiAgICAgICAgICAgICAgICAgICAgIC8vIGlmIHdlIGRvbid0IGtub3cgdGhlIGNvdW50Ci0gICAgICAgICAgICAgICAgICAgIGVmTVdJU1sxXSA9IDA7CisgICAgICAgICAgICAgICAgICAgIG1FZk1XSVNbMV0gPSAwOwogICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgIGVmTVdJU1sxXSA9IChieXRlKSBjb3VudFdhaXRpbmc7CisgICAgICAgICAgICAgICAgICAgIG1FZk1XSVNbMV0gPSAoYnl0ZSkgY291bnRXYWl0aW5nOwogICAgICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgICAgIG1GaC51cGRhdGVFRkxpbmVhckZpeGVkKAotICAgICAgICAgICAgICAgICAgICBFRl9NV0lTLCAxLCBlZk1XSVMsIG51bGwsCisgICAgICAgICAgICAgICAgICAgIEVGX01XSVMsIDEsIG1FZk1XSVMsIG51bGwsCiAgICAgICAgICAgICAgICAgICAgIG9idGFpbk1lc3NhZ2UgKEVWRU5UX1VQREFURV9ET05FLCBFRl9NV0lTKSk7CiAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgIGlmIChlZkNQSFNfTVdJICE9IG51bGwpIHsKKyAgICAgICAgICAgIGlmIChtRWZDUEhTX01XSSAhPSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgIC8vIFJlZmVyIENQSFM0XzIuV1c2IEI0LjIuMwotICAgICAgICAgICAgICAgIGVmQ1BIU19NV0lbMF0gPSAoYnl0ZSkoKGVmQ1BIU19NV0lbMF0gJiAweGYwKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgKGNvdW50Vm9pY2VNZXNzYWdlcyA9PSAwID8gMHg1IDogMHhhKSk7CisgICAgICAgICAgICAgICAgbUVmQ1BIU19NV0lbMF0gPSAoYnl0ZSkoKG1FZkNQSFNfTVdJWzBdICYgMHhmMCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB8IChtQ291bnRWb2ljZU1lc3NhZ2VzID09IDAgPyAweDUgOiAweGEpKTsKIAogICAgICAgICAgICAgICAgIG1GaC51cGRhdGVFRlRyYW5zcGFyZW50KAotICAgICAgICAgICAgICAgICAgICBFRl9WT0lDRV9NQUlMX0lORElDQVRPUl9DUEhTLCBlZkNQSFNfTVdJLAorICAgICAgICAgICAgICAgICAgICBFRl9WT0lDRV9NQUlMX0lORElDQVRPUl9DUEhTLCBtRWZDUEhTX01XSSwKICAgICAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZSAoRVZFTlRfVVBEQVRFX0RPTkUsIEVGX1ZPSUNFX01BSUxfSU5ESUNBVE9SX0NQSFMpKTsKICAgICAgICAgICAgI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CBhbmQKQEAgLTUwOSwxNyArNTI0LDE4IEBACiAgICAgICAgICAgICBsb2coImdldE9wZXJhdG9yTnVtZXJpYzogSU1TSSA9PSBudWxsIik7CiAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgfQotICAgICAgICBpZiAobW5jTGVuZ3RoID09IFVOSU5JVElBTElaRUQgfHwgbW5jTGVuZ3RoID09IFVOS05PV04pIHsKKyAgICAgICAgaWYgKG1NbmNMZW5ndGggPT0gVU5JTklUSUFMSVpFRCB8fCBtTW5jTGVuZ3RoID09IFVOS05PV04pIHsKICAgICAgICAgICAgIGxvZygiZ2V0U0lNT3BlcmF0b3JOdW1lcmljOiBiYWQgbW5jTGVuZ3RoIik7CiAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgfQogCiAgICAgICAgIC8vIExlbmd0aCA9IGxlbmd0aCBvZiBNQ0MgKyBsZW5ndGggb2YgTU5DCiAgICAgICAgIC8vIGxlbmd0aCBvZiBtY2MgPSAzIChUUyAyMy4wMDMgU2VjdGlvbiAyLjIpCi0gICAgICAgIHJldHVybiBtSW1zaS5zdWJzdHJpbmcoMCwgMyArIG1uY0xlbmd0aCk7CisgICAgICAgIHJldHVybiBtSW1zaS5zdWJzdHJpbmcoMCwgMyArIG1NbmNMZW5ndGgpOwogICAgIH0KIAogICAgIC8vICoqKioqIE92ZXJyaWRkZW4gZnJvbSBIYW5kbGVyCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgaGFuZGxlTWVzc2FnZShNZXNzYWdlIG1zZykgewogICAgICAgICBBc3luY1Jlc3VsdCBhcjsKICAgICAgICAgQWRuUmVjb3JkIGFkbjsKQEAgLTU2MSwzMiArNTc3LDMyIEBACiAKICAgICAgICAgICAgICAgICBsb2coIklNU0k6ICIgKyAvKiBpbXNpLnN1YnN0cmluZygwLCA2KSArKi8gInh4eHh4eHgiKTsKIAotICAgICAgICAgICAgICAgIGlmICgoKG1uY0xlbmd0aCA9PSBVTktOT1dOKSB8fCAobW5jTGVuZ3RoID09IDIpKSAmJgorICAgICAgICAgICAgICAgIGlmICgoKG1NbmNMZW5ndGggPT0gVU5LTk9XTikgfHwgKG1NbmNMZW5ndGggPT0gMikpICYmCiAgICAgICAgICAgICAgICAgICAgICAgICAoKG1JbXNpICE9IG51bGwpICYmIChtSW1zaS5sZW5ndGgoKSA+PSA2KSkpIHsKICAgICAgICAgICAgICAgICAgICAgU3RyaW5nIG1jY21uY0NvZGUgPSBtSW1zaS5zdWJzdHJpbmcoMCwgNik7CiAgICAgICAgICAgICAgICAgICAgIGZvciAoU3RyaW5nIG1jY21uYyA6IE1DQ01OQ19DT0RFU19IQVZJTkdfM0RJR0lUU19NTkMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtY2NtbmMuZXF1YWxzKG1jY21uY0NvZGUpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgbW5jTGVuZ3RoID0gMzsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBtTW5jTGVuZ3RoID0gMzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgICAgIGlmIChtbmNMZW5ndGggPT0gVU5LTk9XTikgeworICAgICAgICAgICAgICAgIGlmIChtTW5jTGVuZ3RoID09IFVOS05PV04pIHsKICAgICAgICAgICAgICAgICAgICAgLy8gdGhlIFNJTSBoYXMgdG9sZCB1cyBhbGwgaXQga25vd3MsIGJ1dCBpdCBkaWRuJ3Qga25vdyB0aGUgbW5jIGxlbmd0aC4KICAgICAgICAgICAgICAgICAgICAgLy8gZ3Vlc3MgdXNpbmcgdGhlIG1jYwogICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgaW50IG1jYyA9IEludGVnZXIucGFyc2VJbnQobUltc2kuc3Vic3RyaW5nKDAsMykpOwotICAgICAgICAgICAgICAgICAgICAgICAgbW5jTGVuZ3RoID0gTWNjVGFibGUuc21hbGxlc3REaWdpdHNNY2NGb3JNbmMobWNjKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1NbmNMZW5ndGggPSBNY2NUYWJsZS5zbWFsbGVzdERpZ2l0c01jY0Zvck1uYyhtY2MpOwogICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChOdW1iZXJGb3JtYXRFeGNlcHRpb24gZSkgewotICAgICAgICAgICAgICAgICAgICAgICAgbW5jTGVuZ3RoID0gVU5LTk9XTjsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1NbmNMZW5ndGggPSBVTktOT1dOOwogICAgICAgICAgICAgICAgICAgICAgICAgbG9nZSgiQ29ycnVwdCBJTVNJISIpOwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgfQogCi0gICAgICAgICAgICAgICAgaWYgKG1uY0xlbmd0aCAhPSBVTktOT1dOICYmIG1uY0xlbmd0aCAhPSBVTklOSVRJQUxJWkVEKSB7CisgICAgICAgICAgICAgICAgaWYgKG1NbmNMZW5ndGggIT0gVU5LTk9XTiAmJiBtTW5jTGVuZ3RoICE9IFVOSU5JVElBTElaRUQpIHsKICAgICAgICAgICAgICAgICAgICAgLy8gZmluYWxseSBoYXZlIGJvdGggdGhlIGltc2kgYW5kIHRoZSBtbmNMZW5ndGggYW5kIGNhbiBwYXJzZSB0aGUgaW1zaSBwcm9wZXJseQotICAgICAgICAgICAgICAgICAgICBNY2NUYWJsZS51cGRhdGVNY2NNbmNDb25maWd1cmF0aW9uKG1Db250ZXh0LCBtSW1zaS5zdWJzdHJpbmcoMCwgMyArIG1uY0xlbmd0aCkpOworICAgICAgICAgICAgICAgICAgICBNY2NUYWJsZS51cGRhdGVNY2NNbmNDb25maWd1cmF0aW9uKG1Db250ZXh0LCBtSW1zaS5zdWJzdHJpbmcoMCwgMyArIG1NbmNMZW5ndGgpKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgbUltc2lSZWFkeVJlZ2lzdHJhbnRzLm5vdGlmeVJlZ2lzdHJhbnRzKCk7CiAgICAgICAgICAgICBicmVhazsKQEAgLTYwNCwyMiArNjIwLDIyIEBACiAgICAgICAgICAgICAgICAgICAgIGxvZygiRUZfTUJJOiAiICsgSWNjVXRpbHMuYnl0ZXNUb0hleFN0cmluZyhkYXRhKSk7CiAKICAgICAgICAgICAgICAgICAgICAgLy8gVm9pY2UgbWFpbCByZWNvcmQgbnVtYmVyIHN0b3JlZCBmaXJzdAotICAgICAgICAgICAgICAgICAgICBtYWlsYm94SW5kZXggPSAoaW50KWRhdGFbMF0gJiAweGZmOworICAgICAgICAgICAgICAgICAgICBtTWFpbGJveEluZGV4ID0gZGF0YVswXSAmIDB4ZmY7CiAKICAgICAgICAgICAgICAgICAgICAgLy8gY2hlY2sgaWYgZGFpbGluZyBudW1iZSBpZCB2YWxpZAotICAgICAgICAgICAgICAgICAgICBpZiAobWFpbGJveEluZGV4ICE9IDAgJiYgbWFpbGJveEluZGV4ICE9IDB4ZmYpIHsKKyAgICAgICAgICAgICAgICAgICAgaWYgKG1NYWlsYm94SW5kZXggIT0gMCAmJiBtTWFpbGJveEluZGV4ICE9IDB4ZmYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIGxvZygiR290IHZhbGlkIG1haWxib3ggbnVtYmVyIGZvciBNQkROIik7CiAgICAgICAgICAgICAgICAgICAgICAgICBpc1ZhbGlkTWJkbiA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgICAgICAvLyBvbmUgbW9yZSByZWNvcmQgdG8gbG9hZAotICAgICAgICAgICAgICAgIHJlY29yZHNUb0xvYWQgKz0gMTsKKyAgICAgICAgICAgICAgICBtUmVjb3Jkc1RvTG9hZCArPSAxOwogCiAgICAgICAgICAgICAgICAgaWYgKGlzVmFsaWRNYmRuKSB7CiAgICAgICAgICAgICAgICAgICAgIC8vIE5vdGU6IE1CRE4gd2FzIG5vdCBpbmNsdWRlZCBpbiBOVU1fT0ZfU0lNX1JFQ09SRFNfTE9BREVECiAgICAgICAgICAgICAgICAgICAgIG5ldyBBZG5SZWNvcmRMb2FkZXIobUZoKS5sb2FkRnJvbUVGKEVGX01CRE4sIEVGX0VYVDYsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFpbGJveEluZGV4LCBvYnRhaW5NZXNzYWdlKEVWRU5UX0dFVF9NQkROX0RPTkUpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBtTWFpbGJveEluZGV4LCBvYnRhaW5NZXNzYWdlKEVWRU5UX0dFVF9NQkROX0RPTkUpKTsKICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAvLyBJZiB0aGlzIEVGIG5vdCBwcmVzZW50LCB0cnkgbWFpbGJveCBhcyBpbiBDUEhTIHN0YW5kYXJkCiAgICAgICAgICAgICAgICAgICAgIC8vIENQSFMgKENQSFM0XzIuV1c2KSBpcyBhIGV1cm9wZWFuIHN0YW5kYXJkLgpAQCAtNjM2LDggKzY1Miw4IEBACiAgICAgICAgICAgICAgICAgLy9JZiB0aGV5IGFyZSBub3QgcmVzZXQsIGluY2FzZSBvZiBpbnZhbGlkIGRhdGEvZXhjZXB0aW9uIHRoZXNlCiAgICAgICAgICAgICAgICAgLy92YXJpYWJsZXMgYXJlIHJldGFpbmluZyB0aGVpciBwcmV2aW91cyB2YWx1ZXMgYW5kIGFyZQogICAgICAgICAgICAgICAgIC8vY2F1c2luZyBpbnZhbGlkIHZvaWNlIG1haWxib3ggaW5mbyBkaXNwbGF5IHRvIHVzZXIuCi0gICAgICAgICAgICAgICAgdm9pY2VNYWlsTnVtID0gbnVsbDsKLSAgICAgICAgICAgICAgICB2b2ljZU1haWxUYWcgPSBudWxsOworICAgICAgICAgICAgICAgIG1Wb2ljZU1haWxOdW0gPSBudWxsOworICAgICAgICAgICAgICAgIG1Wb2ljZU1haWxUYWcgPSBudWxsOwogICAgICAgICAgICAgICAgIGlzUmVjb3JkTG9hZFJlc3BvbnNlID0gdHJ1ZTsKIAogICAgICAgICAgICAgICAgIGFyID0gKEFzeW5jUmVzdWx0KW1zZy5vYmo7CkBAIC02NTQsNyArNjcwLDcgQEAKICAgICAgICAgICAgICAgICAgICAgICAgIC8vbG9hZCBDUEhTIG9uIGZhaWwuLi4KICAgICAgICAgICAgICAgICAgICAgICAgIC8vIEZJWE1FIHJpZ2h0IG5vdywgb25seSBsb2FkIGxpbmUxJ3MgQ1BIUyB2b2ljZSBtYWlsIGVudHJ5CiAKLSAgICAgICAgICAgICAgICAgICAgICAgIHJlY29yZHNUb0xvYWQgKz0gMTsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1SZWNvcmRzVG9Mb2FkICs9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICBuZXcgQWRuUmVjb3JkTG9hZGVyKG1GaCkubG9hZEZyb21FRigKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRUZfTUFJTEJPWF9DUEhTLCBFRl9FWFQxLCAxLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX0dFVF9DUEhTX01BSUxCT1hfRE9ORSkpOwpAQCAtNjcxLDcgKzY4Nyw3IEBACiAgICAgICAgICAgICAgICAgICAgIC8vIEJ1ZyAjNjQ1NzcwIGZhbGwgYmFjayB0byBDUEhTCiAgICAgICAgICAgICAgICAgICAgIC8vIEZJWE1FIHNob3VsZCB1c2UgU1NUIHRvIGRlY2lkZQogICAgICAgICAgICAgICAgICAgICAvLyBGSVhNRSByaWdodCBub3csIG9ubHkgbG9hZCBsaW5lMSdzIENQSFMgdm9pY2UgbWFpbCBlbnRyeQotICAgICAgICAgICAgICAgICAgICByZWNvcmRzVG9Mb2FkICs9IDE7CisgICAgICAgICAgICAgICAgICAgIG1SZWNvcmRzVG9Mb2FkICs9IDE7CiAgICAgICAgICAgICAgICAgICAgIG5ldyBBZG5SZWNvcmRMb2FkZXIobUZoKS5sb2FkRnJvbUVGKAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIEVGX01BSUxCT1hfQ1BIUywgRUZfRVhUMSwgMSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX0dFVF9DUEhTX01BSUxCT1hfRE9ORSkpOwpAQCAtNjc5LDggKzY5NSw4IEBACiAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgICAgIHZvaWNlTWFpbE51bSA9IGFkbi5nZXROdW1iZXIoKTsKLSAgICAgICAgICAgICAgICB2b2ljZU1haWxUYWcgPSBhZG4uZ2V0QWxwaGFUYWcoKTsKKyAgICAgICAgICAgICAgICBtVm9pY2VNYWlsTnVtID0gYWRuLmdldE51bWJlcigpOworICAgICAgICAgICAgICAgIG1Wb2ljZU1haWxUYWcgPSBhZG4uZ2V0QWxwaGFUYWcoKTsKICAgICAgICAgICAgIGJyZWFrOwogCiAgICAgICAgICAgICBjYXNlIEVWRU5UX0dFVF9NU0lTRE5fRE9ORToKQEAgLTY5NSwxMCArNzExLDEwIEBACiAKICAgICAgICAgICAgICAgICBhZG4gPSAoQWRuUmVjb3JkKWFyLnJlc3VsdDsKIAotICAgICAgICAgICAgICAgIG1zaXNkbiA9IGFkbi5nZXROdW1iZXIoKTsKLSAgICAgICAgICAgICAgICBtc2lzZG5UYWcgPSBhZG4uZ2V0QWxwaGFUYWcoKTsKKyAgICAgICAgICAgICAgICBtTXNpc2RuID0gYWRuLmdldE51bWJlcigpOworICAgICAgICAgICAgICAgIG1Nc2lzZG5UYWcgPSBhZG4uZ2V0QWxwaGFUYWcoKTsKIAotICAgICAgICAgICAgICAgIGxvZygiTVNJU0ROOiAiICsgLyptc2lzZG4qLyAieHh4eHh4eCIpOworICAgICAgICAgICAgICAgIGxvZygiTVNJU0ROOiAiICsgLyptTXNpc2RuKi8gInh4eHh4eHgiKTsKICAgICAgICAgICAgIGJyZWFrOwogCiAgICAgICAgICAgICBjYXNlIEVWRU5UX1NFVF9NU0lTRE5fRE9ORToKQEAgLTcyNCw3ICs3NDAsNyBAQAogCiAgICAgICAgICAgICAgICAgbG9nKCJFRl9NV0lTOiAiICsgSWNjVXRpbHMuYnl0ZXNUb0hleFN0cmluZyhkYXRhKSk7CiAKLSAgICAgICAgICAgICAgICBlZk1XSVMgPSBkYXRhOworICAgICAgICAgICAgICAgIG1FZk1XSVMgPSBkYXRhOwogCiAgICAgICAgICAgICAgICAgaWYgKChkYXRhWzBdICYgMHhmZikgPT0gMHhmZikgewogICAgICAgICAgICAgICAgICAgICBsb2coIlVuaW5pdGlhbGl6ZWQgcmVjb3JkIE1XSVMiKTsKQEAgLTczMywxMSArNzQ5LDExIEBACiAKICAgICAgICAgICAgICAgICAvLyBSZWZlciBUUyA1MS4wMTEgU2VjdGlvbiAxMC4zLjQ1IGZvciB0aGUgY29udGVudCBkZXNjcmlwdGlvbgogICAgICAgICAgICAgICAgIGJvb2xlYW4gdm9pY2VNYWlsV2FpdGluZyA9ICgoZGF0YVswXSAmIDB4MDEpICE9IDApOwotICAgICAgICAgICAgICAgIGNvdW50Vm9pY2VNZXNzYWdlcyA9IGRhdGFbMV0gJiAweGZmOworICAgICAgICAgICAgICAgIG1Db3VudFZvaWNlTWVzc2FnZXMgPSBkYXRhWzFdICYgMHhmZjsKIAotICAgICAgICAgICAgICAgIGlmICh2b2ljZU1haWxXYWl0aW5nICYmIGNvdW50Vm9pY2VNZXNzYWdlcyA9PSAwKSB7CisgICAgICAgICAgICAgICAgaWYgKHZvaWNlTWFpbFdhaXRpbmcgJiYgbUNvdW50Vm9pY2VNZXNzYWdlcyA9PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgIC8vIFVua25vd24gY291bnQgPSAtMQotICAgICAgICAgICAgICAgICAgICBjb3VudFZvaWNlTWVzc2FnZXMgPSAtMTsKKyAgICAgICAgICAgICAgICAgICAgbUNvdW50Vm9pY2VNZXNzYWdlcyA9IC0xOwogICAgICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgICAgIG1SZWNvcmRzRXZlbnRzUmVnaXN0cmFudHMubm90aWZ5UmVzdWx0KEVWRU5UX01XSSk7CkBAIC03NTMsMjAgKzc2OSwyMCBAQAogICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgICAgICBlZkNQSFNfTVdJID0gZGF0YTsKKyAgICAgICAgICAgICAgICBtRWZDUEhTX01XSSA9IGRhdGE7CiAKICAgICAgICAgICAgICAgICAvLyBVc2UgdGhpcyBkYXRhIGlmIHRoZSBFRltNV0lTXSBleGlzdHMgYW5kCiAgICAgICAgICAgICAgICAgLy8gaGFzIGJlZW4gbG9hZGVkCiAKLSAgICAgICAgICAgICAgICBpZiAoZWZNV0lTID09IG51bGwpIHsKLSAgICAgICAgICAgICAgICAgICAgaW50IGluZGljYXRvciA9IChpbnQpKGRhdGFbMF0gJiAweGYpOworICAgICAgICAgICAgICAgIGlmIChtRWZNV0lTID09IG51bGwpIHsKKyAgICAgICAgICAgICAgICAgICAgaW50IGluZGljYXRvciA9IGRhdGFbMF0gJiAweGY7CiAKICAgICAgICAgICAgICAgICAgICAgLy8gUmVmZXIgQ1BIUzRfMi5XVzYgQjQuMi4zCiAgICAgICAgICAgICAgICAgICAgIGlmIChpbmRpY2F0b3IgPT0gMHhBKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBVbmtub3duIGNvdW50ID0gLTEKLSAgICAgICAgICAgICAgICAgICAgICAgIGNvdW50Vm9pY2VNZXNzYWdlcyA9IC0xOworICAgICAgICAgICAgICAgICAgICAgICAgbUNvdW50Vm9pY2VNZXNzYWdlcyA9IC0xOwogICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGluZGljYXRvciA9PSAweDUpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGNvdW50Vm9pY2VNZXNzYWdlcyA9IDA7CisgICAgICAgICAgICAgICAgICAgICAgICBtQ291bnRWb2ljZU1lc3NhZ2VzID0gMDsKICAgICAgICAgICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAgICAgICAgIG1SZWNvcmRzRXZlbnRzUmVnaXN0cmFudHMubm90aWZ5UmVzdWx0KEVWRU5UX01XSSk7CkBAIC03ODMsOSArNzk5LDkgQEAKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgfQogCi0gICAgICAgICAgICAgICAgaWNjaWQgPSBJY2NVdGlscy5iY2RUb1N0cmluZyhkYXRhLCAwLCBkYXRhLmxlbmd0aCk7CisgICAgICAgICAgICAgICAgaWNjSWQgPSBJY2NVdGlscy5iY2RUb1N0cmluZyhkYXRhLCAwLCBkYXRhLmxlbmd0aCk7CiAKLSAgICAgICAgICAgICAgICBsb2coImljY2lkOiAiICsgaWNjaWQpOworICAgICAgICAgICAgICAgIGxvZygiaWNjaWQ6ICIgKyBpY2NJZCk7CiAKICAgICAgICAgICAgIGJyZWFrOwogCkBAIC04MTMsNDUgKzgyOSw0NSBAQAogICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgICAgICAgICBtbmNMZW5ndGggPSAoaW50KWRhdGFbM10gJiAweGY7CisgICAgICAgICAgICAgICAgICAgIG1NbmNMZW5ndGggPSBkYXRhWzNdICYgMHhmOwogCi0gICAgICAgICAgICAgICAgICAgIGlmIChtbmNMZW5ndGggPT0gMHhmKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBtbmNMZW5ndGggPSBVTktOT1dOOworICAgICAgICAgICAgICAgICAgICBpZiAobU1uY0xlbmd0aCA9PSAweGYpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1NbmNMZW5ndGggPSBVTktOT1dOOwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgfSBmaW5hbGx5IHsKLSAgICAgICAgICAgICAgICAgICAgaWYgKCgobW5jTGVuZ3RoID09IFVOSU5JVElBTElaRUQpIHx8IChtbmNMZW5ndGggPT0gVU5LTk9XTikgfHwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAobW5jTGVuZ3RoID09IDIpKSAmJiAoKG1JbXNpICE9IG51bGwpICYmIChtSW1zaS5sZW5ndGgoKSA+PSA2KSkpIHsKKyAgICAgICAgICAgICAgICAgICAgaWYgKCgobU1uY0xlbmd0aCA9PSBVTklOSVRJQUxJWkVEKSB8fCAobU1uY0xlbmd0aCA9PSBVTktOT1dOKSB8fAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIChtTW5jTGVuZ3RoID09IDIpKSAmJiAoKG1JbXNpICE9IG51bGwpICYmIChtSW1zaS5sZW5ndGgoKSA+PSA2KSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZyBtY2NtbmNDb2RlID0gbUltc2kuc3Vic3RyaW5nKDAsIDYpOwogICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChTdHJpbmcgbWNjbW5jIDogTUNDTU5DX0NPREVTX0hBVklOR18zRElHSVRTX01OQykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtY2NtbmMuZXF1YWxzKG1jY21uY0NvZGUpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1uY0xlbmd0aCA9IDM7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1NbmNMZW5ndGggPSAzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgICAgICAgICBpZiAobW5jTGVuZ3RoID09IFVOS05PV04gfHwgbW5jTGVuZ3RoID09IFVOSU5JVElBTElaRUQpIHsKKyAgICAgICAgICAgICAgICAgICAgaWYgKG1NbmNMZW5ndGggPT0gVU5LTk9XTiB8fCBtTW5jTGVuZ3RoID09IFVOSU5JVElBTElaRUQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtSW1zaSAhPSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50IG1jYyA9IEludGVnZXIucGFyc2VJbnQobUltc2kuc3Vic3RyaW5nKDAsMykpOwogCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1uY0xlbmd0aCA9IE1jY1RhYmxlLnNtYWxsZXN0RGlnaXRzTWNjRm9yTW5jKG1jYyk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1NbmNMZW5ndGggPSBNY2NUYWJsZS5zbWFsbGVzdERpZ2l0c01jY0Zvck1uYyhtY2MpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKE51bWJlckZvcm1hdEV4Y2VwdGlvbiBlKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1uY0xlbmd0aCA9IFVOS05PV047CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1NbmNMZW5ndGggPSBVTktOT1dOOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2dlKCJDb3JydXB0IElNU0khIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBJbmRpY2F0ZSB3ZSBnb3QgdGhpcyBpbmZvLCBidXQgaXQgZGlkbid0IGNvbnRhaW4gdGhlIGxlbmd0aC4KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBtbmNMZW5ndGggPSBVTktOT1dOOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1NbmNMZW5ndGggPSBVTktOT1dOOwogCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9nKCJNTkMgbGVuZ3RoIG5vdCBwcmVzZW50IGluIEVGX0FEIik7CiAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgaWYgKG1JbXNpICE9IG51bGwgJiYgbW5jTGVuZ3RoICE9IFVOS05PV04pIHsKKyAgICAgICAgICAgICAgICAgICAgaWYgKG1JbXNpICE9IG51bGwgJiYgbU1uY0xlbmd0aCAhPSBVTktOT1dOKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBmaW5hbGx5IGhhdmUgYm90aCBpbXNpIGFuZCB0aGUgbGVuZ3RoIG9mIHRoZSBtbmMgYW5kIGNhbiBwYXJzZQogICAgICAgICAgICAgICAgICAgICAgICAgLy8gdGhlIGltc2kgcHJvcGVybHkKICAgICAgICAgICAgICAgICAgICAgICAgIE1jY1RhYmxlLnVwZGF0ZU1jY01uY0NvbmZpZ3VyYXRpb24obUNvbnRleHQsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1JbXNpLnN1YnN0cmluZygwLCAzICsgbW5jTGVuZ3RoKSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1JbXNpLnN1YnN0cmluZygwLCAzICsgbU1uY0xlbmd0aCkpOwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgYnJlYWs7CkBAIC04NzYsNyArODkyLDcgQEAKICAgICAgICAgICAgICAgICBtRWZDZmYgPSBkYXRhOwogCiAgICAgICAgICAgICAgICAgaWYgKHZhbGlkRWZDZmlzKG1FZkNmaXMpKSB7Ci0gICAgICAgICAgICAgICAgICAgIGNhbGxGb3J3YXJkaW5nRW5hYmxlZCA9CisgICAgICAgICAgICAgICAgICAgIG1DYWxsRm9yd2FyZGluZ0VuYWJsZWQgPQogICAgICAgICAgICAgICAgICAgICAgICAgKChkYXRhWzBdICYgQ0ZGX0xJTkUxX01BU0spID09IENGRl9VTkNPTkRJVElPTkFMX0FDVElWRSk7CiAKICAgICAgICAgICAgICAgICAgICAgbVJlY29yZHNFdmVudHNSZWdpc3RyYW50cy5ub3RpZnlSZXN1bHQoRVZFTlRfQ0ZJKTsKQEAgLTkyMCw3ICs5MzYsNyBAQAogCiAgICAgICAgICAgICAgICAgZm9yICggOyB0bHYuaXNWYWxpZE9iamVjdCgpIDsgdGx2Lm5leHRPYmplY3QoKSkgewogICAgICAgICAgICAgICAgICAgICBpZiAodGx2LmdldFRhZygpID09IFRBR19GVUxMX05FVFdPUktfTkFNRSkgewotICAgICAgICAgICAgICAgICAgICAgICAgcG5uSG9tZU5hbWUKKyAgICAgICAgICAgICAgICAgICAgICAgIG1Qbm5Ib21lTmFtZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgID0gSWNjVXRpbHMubmV0d29ya05hbWVUb1N0cmluZygKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGx2LmdldERhdGEoKSwgMCwgdGx2LmdldERhdGEoKS5sZW5ndGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CkBAIC05MzUsNyArOTUxLDcgQEAKICAgICAgICAgICAgICAgICBpZiAoYXIuZXhjZXB0aW9uICE9IG51bGwpCiAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogCi0gICAgICAgICAgICAgICAgaGFuZGxlU21zZXMoKEFycmF5TGlzdCkgYXIucmVzdWx0KTsKKyAgICAgICAgICAgICAgICBoYW5kbGVTbXNlcygoQXJyYXlMaXN0PGJ5dGUgW10+KSBhci5yZXN1bHQpOwogICAgICAgICAgICAgICAgIGJyZWFrOwogCiAgICAgICAgICAgICBjYXNlIEVWRU5UX01BUktfU01TX1JFQURfRE9ORToKQEAgLTEwMDIsMTIgKzEwMTgsMTIgQEAKICAgICAgICAgICAgICAgICBhciA9IChBc3luY1Jlc3VsdCltc2cub2JqOwogCiAgICAgICAgICAgICAgICAgaWYgKGFyLmV4Y2VwdGlvbiA9PSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgIHZvaWNlTWFpbE51bSA9IG5ld1ZvaWNlTWFpbE51bTsKLSAgICAgICAgICAgICAgICAgICAgdm9pY2VNYWlsVGFnID0gbmV3Vm9pY2VNYWlsVGFnOworICAgICAgICAgICAgICAgICAgICBtVm9pY2VNYWlsTnVtID0gbU5ld1ZvaWNlTWFpbE51bTsKKyAgICAgICAgICAgICAgICAgICAgbVZvaWNlTWFpbFRhZyA9IG1OZXdWb2ljZU1haWxUYWc7CiAgICAgICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAgICAgaWYgKGlzQ3Boc01haWxib3hFbmFibGVkKCkpIHsKLSAgICAgICAgICAgICAgICAgICAgYWRuID0gbmV3IEFkblJlY29yZCh2b2ljZU1haWxUYWcsIHZvaWNlTWFpbE51bSk7CisgICAgICAgICAgICAgICAgICAgIGFkbiA9IG5ldyBBZG5SZWNvcmQobVZvaWNlTWFpbFRhZywgbVZvaWNlTWFpbE51bSk7CiAgICAgICAgICAgICAgICAgICAgIE1lc3NhZ2Ugb25DcGhzQ29tcGxldGVkID0gKE1lc3NhZ2UpIGFyLnVzZXJPYmo7CiAKICAgICAgICAgICAgICAgICAgICAgLyogd3JpdGUgdG8gY3BocyBtYWlsYm94IHdoZW5ldmVyIGl0IGlzIGF2YWlsYWJsZSBidXQKQEAgLTEwNDMsOCArMTA1OSw4IEBACiAgICAgICAgICAgICAgICAgaXNSZWNvcmRMb2FkUmVzcG9uc2UgPSBmYWxzZTsKICAgICAgICAgICAgICAgICBhciA9IChBc3luY1Jlc3VsdCltc2cub2JqOwogICAgICAgICAgICAgICAgIGlmKGFyLmV4Y2VwdGlvbiA9PSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgIHZvaWNlTWFpbE51bSA9IG5ld1ZvaWNlTWFpbE51bTsKLSAgICAgICAgICAgICAgICAgICAgdm9pY2VNYWlsVGFnID0gbmV3Vm9pY2VNYWlsVGFnOworICAgICAgICAgICAgICAgICAgICBtVm9pY2VNYWlsTnVtID0gbU5ld1ZvaWNlTWFpbE51bTsKKyAgICAgICAgICAgICAgICAgICAgbVZvaWNlTWFpbFRhZyA9IG1OZXdWb2ljZU1haWxUYWc7CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJTZXQgQ1BIUyBNYWlsQm94IHdpdGggZXhjZXB0aW9uOiAiCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyBhci5leGNlcHRpb24pOwpAQCAtMTA4MCw4ICsxMDk2LDggQEAKICAgICAgICAgICAgICAgICAgICAgbUVmQ2ZpcyA9IGRhdGE7CiAKICAgICAgICAgICAgICAgICAgICAgLy8gUmVmZXIgVFMgNTEuMDExIFNlY3Rpb24gMTAuMy40NiBmb3IgdGhlIGNvbnRlbnQgZGVzY3JpcHRpb24KLSAgICAgICAgICAgICAgICAgICAgY2FsbEZvcndhcmRpbmdFbmFibGVkID0gKChkYXRhWzFdICYgMHgwMSkgIT0gMCk7Ci0gICAgICAgICAgICAgICAgICAgIGxvZygiRUZfQ0ZJUzogY2FsbEZvcmR3YXJkaW5nRW5hYmxlZD0iICsgY2FsbEZvcndhcmRpbmdFbmFibGVkKTsKKyAgICAgICAgICAgICAgICAgICAgbUNhbGxGb3J3YXJkaW5nRW5hYmxlZCA9ICgoZGF0YVsxXSAmIDB4MDEpICE9IDApOworICAgICAgICAgICAgICAgICAgICBsb2coIkVGX0NGSVM6IGNhbGxGb3Jkd2FyZGluZ0VuYWJsZWQ9IiArIG1DYWxsRm9yd2FyZGluZ0VuYWJsZWQpOwogCiAgICAgICAgICAgICAgICAgICAgIG1SZWNvcmRzRXZlbnRzUmVnaXN0cmFudHMubm90aWZ5UmVzdWx0KEVWRU5UX0NGSSk7CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKQEAgLTExMjIsMTcgKzExMzgsMTcgQEAKICAgICBwcml2YXRlIHZvaWQgaGFuZGxlRmlsZVVwZGF0ZShpbnQgZWZpZCkgewogICAgICAgICBzd2l0Y2goZWZpZCkgewogICAgICAgICAgICAgY2FzZSBFRl9NQkROOgotICAgICAgICAgICAgICAgIHJlY29yZHNUb0xvYWQrKzsKKyAgICAgICAgICAgICAgICBtUmVjb3Jkc1RvTG9hZCsrOwogICAgICAgICAgICAgICAgIG5ldyBBZG5SZWNvcmRMb2FkZXIobUZoKS5sb2FkRnJvbUVGKEVGX01CRE4sIEVGX0VYVDYsCi0gICAgICAgICAgICAgICAgICAgICAgICBtYWlsYm94SW5kZXgsIG9idGFpbk1lc3NhZ2UoRVZFTlRfR0VUX01CRE5fRE9ORSkpOworICAgICAgICAgICAgICAgICAgICAgICAgbU1haWxib3hJbmRleCwgb2J0YWluTWVzc2FnZShFVkVOVF9HRVRfTUJETl9ET05FKSk7CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICBjYXNlIEVGX01BSUxCT1hfQ1BIUzoKLSAgICAgICAgICAgICAgICByZWNvcmRzVG9Mb2FkKys7CisgICAgICAgICAgICAgICAgbVJlY29yZHNUb0xvYWQrKzsKICAgICAgICAgICAgICAgICBuZXcgQWRuUmVjb3JkTG9hZGVyKG1GaCkubG9hZEZyb21FRihFRl9NQUlMQk9YX0NQSFMsIEVGX0VYVDEsCiAgICAgICAgICAgICAgICAgICAgICAgICAxLCBvYnRhaW5NZXNzYWdlKEVWRU5UX0dFVF9DUEhTX01BSUxCT1hfRE9ORSkpOwogICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgY2FzZSBFRl9DU1BfQ1BIUzoKLSAgICAgICAgICAgICAgICByZWNvcmRzVG9Mb2FkKys7CisgICAgICAgICAgICAgICAgbVJlY29yZHNUb0xvYWQrKzsKICAgICAgICAgICAgICAgICBsb2coIltDU1BdIFNJTSBSZWZyZXNoIGZvciBFRl9DU1BfQ1BIUyIpOwogICAgICAgICAgICAgICAgIG1GaC5sb2FkRUZUcmFuc3BhcmVudChFRl9DU1BfQ1BIUywKICAgICAgICAgICAgICAgICAgICAgICAgIG9idGFpbk1lc3NhZ2UoRVZFTlRfR0VUX0NTUF9DUEhTX0RPTkUpKTsKQEAgLTExNDEsNyArMTE1Nyw3IEBACiAgICAgICAgICAgICAgICAgLy8gRm9yIG5vdywgZmV0Y2ggYWxsIHJlY29yZHMgaWYgdGhpcyBpcyBub3QgYQogICAgICAgICAgICAgICAgIC8vIHZvaWNlbWFpbCBudW1iZXIuCiAgICAgICAgICAgICAgICAgLy8gVE9ETzogSGFuZGxlIG90aGVyIGNhc2VzLCBpbnN0ZWFkIG9mIGZldGNoaW5nIGFsbC4KLSAgICAgICAgICAgICAgICBhZG5DYWNoZS5yZXNldCgpOworICAgICAgICAgICAgICAgIG1BZG5DYWNoZS5yZXNldCgpOwogICAgICAgICAgICAgICAgIGZldGNoU2ltUmVjb3JkcygpOwogICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICB9CkBAIC0xMTY3LDcgKzExODMsNyBAQAogICAgICAgICAgICAgY2FzZSBJY2NSZWZyZXNoUmVzcG9uc2UuUkVGUkVTSF9SRVNVTFRfSU5JVDoKICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coImhhbmRsZVNpbVJlZnJlc2ggd2l0aCBTSU1fUkVGUkVTSF9JTklUIik7CiAgICAgICAgICAgICAgICAgLy8gbmVlZCB0byByZWxvYWQgYWxsIGZpbGVzICh0aGF0IHdlIGNhcmUgYWJvdXQpCi0gICAgICAgICAgICAgICAgYWRuQ2FjaGUucmVzZXQoKTsKKyAgICAgICAgICAgICAgICBtQWRuQ2FjaGUucmVzZXQoKTsKICAgICAgICAgICAgICAgICBmZXRjaFNpbVJlY29yZHMoKTsKICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIGNhc2UgSWNjUmVmcmVzaFJlc3BvbnNlLlJFRlJFU0hfUkVTVUxUX1JFU0VUOgpAQCAtMTIxOCwxMSArMTIzNCwxMSBAQAogICAgIH0KIAogCi0gICAgcHJpdmF0ZSB2b2lkIGhhbmRsZVNtc2VzKEFycmF5TGlzdCBtZXNzYWdlcykgeworICAgIHByaXZhdGUgdm9pZCBoYW5kbGVTbXNlcyhBcnJheUxpc3Q8Ynl0ZVtdPiBtZXNzYWdlcykgewogICAgICAgICBpbnQgY291bnQgPSBtZXNzYWdlcy5zaXplKCk7CiAKICAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBjb3VudDsgaSsrKSB7Ci0gICAgICAgICAgICBieXRlW10gYmEgPSAoYnl0ZVtdKSBtZXNzYWdlcy5nZXQoaSk7CisgICAgICAgICAgICBieXRlW10gYmEgPSBtZXNzYWdlcy5nZXQoaSk7CiAKICAgICAgICAgICAgIGlmIChiYVswXSAhPSAwKQogICAgICAgICAgICAgICAgIFJsb2cuaSgiRU5GIiwgInN0YXR1cyAiICsgaSArICI6ICIgKyBiYVswXSk7CkBAIC0xMjQ2LDcgKzEyNjIsNyBAQAogCiAgICAgICAgICAgICAgICAgYmFbMF0gPSAxOwogCi0gICAgICAgICAgICAgICAgaWYgKGZhbHNlKSB7IC8vIFhYWCB3cml0aW5nIHNlZW1zIHRvIGNyYXNoIFJkb1NlcnZECisgICAgICAgICAgICAgICAgaWYgKGZhbHNlKSB7IC8vIEZJWE1FOiB3cml0aW5nIHNlZW1zIHRvIGNyYXNoIFJkb1NlcnZECiAgICAgICAgICAgICAgICAgICAgIG1GaC51cGRhdGVFRkxpbmVhckZpeGVkKEVGX1NNUywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpLCBiYSwgbnVsbCwgb2J0YWluTWVzc2FnZShFVkVOVF9NQVJLX1NNU19SRUFEX0RPTkUsIGkpKTsKICAgICAgICAgICAgICAgICB9CkBAIC0xMjU0LDIwICsxMjcwLDIyIEBACiAgICAgICAgIH0KICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwcm90ZWN0ZWQgdm9pZCBvblJlY29yZExvYWRlZCgpIHsKICAgICAg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KzE0MjcsMTggQEAKICAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgaW50IGdldERpc3BsYXlSdWxlKFN0cmluZyBwbG1uKSB7CiAgICAgICAgIGludCBydWxlOwotICAgICAgICBpZiAoVGV4dFV0aWxzLmlzRW1wdHkoc3BuKSB8fCBzcG5EaXNwbGF5Q29uZGl0aW9uID09IC0xKSB7CisgICAgICAgIGlmIChUZXh0VXRpbHMuaXNFbXB0eShtU3BuKSB8fCBtU3BuRGlzcGxheUNvbmRpdGlvbiA9PSAtMSkgewogICAgICAgICAgICAgLy8gTm8gRUZfU1BOIGNvbnRlbnQgd2FzIGZvdW5kIG9uIHRoZSBTSU0sIG9yIG5vdCB5ZXQgbG9hZGVkLiAgSnVzdCBzaG93IE9OUy4KICAgICAgICAgICAgIHJ1bGUgPSBTUE5fUlVMRV9TSE9XX1BMTU47CiAgICAgICAgIH0gZWxzZSBpZiAoaXNPbk1hdGNoaW5nUGxtbihwbG1uKSkgewogICAgICAgICAgICAgcnVsZSA9IFNQTl9SVUxFX1NIT1dfU1BOOwotICAgICAgICAgICAgaWYgKChzcG5EaXNwbGF5Q29uZGl0aW9uICYgMHgwMSkgPT0gMHgwMSkgeworICAgICAgICAgICAgaWYgKChtU3BuRGlzcGxheUNvbmRpdGlvbiAmIDB4MDEpID09IDB4MDEpIHsKICAgICAgICAgICAgICAgICAvLyBPTlMgcmVxdWlyZWQgd2hlbiByZWdpc3RlcmVkIHRvIEhQTE1OIG9yIFBMTU4gaW4gRUZfU1BESQogICAgICAgICAgICAgICAgIHJ1bGUgfD0gU1BOX1JVTEVfU0hPV19QTE1OOwogICAgICAgICAgICAgfQogICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgcnVsZSA9IFNQTl9SVUxFX1NIT1dfUExNTjsKLSAgICAgICAgICAgIGlmICgoc3BuRGlzcGxheUNvbmRpdGlvbiAmIDB4MDIpID09IDB4MDApIHsKKyAgICAgICAgICAgIGlmICgobVNwbkRpc3BsYXlDb25kaXRpb24gJiAweDAyKSA9PSAweDAwKSB7CiAgICAgICAgICAgICAgICAgLy8gU1BOIHJlcXVpcmVkIGlmIG5vdCByZWdpc3RlcmVkIHRvIEhQTE1OIG9yIFBMTU4gaW4gRUZfU1BESQogICAgICAgICAgICAgICAgIHJ1bGUgfD0gU1BOX1JVTEVfU0hPV19TUE47CiAgICAgICAgICAgICB9CkBAIC0xNDM4LDggKzE0NTYsOCBAQAogICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgIH0KIAotICAgICAgICBpZiAoc3BkaU5ldHdvcmtzICE9IG51bGwpIHsKLSAgICAgICAgICAgIGZvciAoU3RyaW5nIHNwZGlOZXQgOiBzcGRpTmV0d29ya3MpIHsKKyAgICAgICAgaWYgKG1TcGRpTmV0d29ya3MgIT0gbnVsbCkgeworICAgICAgICAgICAgZm9yIChTdHJpbmcgc3BkaU5ldCA6IG1TcGRpTmV0d29ya3MpIHsKICAgICAgICAgICAgICAgICBpZiAocGxtbi5lcXVhbHMoc3BkaU5ldCkpIHsKICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgfQpAQCAtMTQ1MSw3ICsxNDY5LDcgQEAKICAgICAvKioKICAgICAgKiBTdGF0ZXMgb2YgR2V0IFNQTiBGaW5pdGUgU3RhdGUgTWFjaGluZSB3aGljaCBvbmx5IHVzZWQgYnkgZ2V0U3BuRnNtKCkKICAgICAgKi8KLSAgICBwcml2YXRlIGVudW0gR2V0X1Nwbl9Gc21fU3RhdGUgeworICAgIHByaXZhdGUgZW51bSBHZXRTcG5Gc21TdGF0ZSB7CiAgICAgICAgIElETEUsICAgICAgICAgICAgICAgLy8gTm8gaW5pdGlhbGl6ZWQKICAgICAgICAgSU5JVCwgICAgICAgICAgICAgICAvLyBTdGFydCBGU00KICAgICAgICAgUkVBRF9TUE5fM0dQUCwgICAgICAvLyBMb2FkIEVGX1NQTiBmaXJzdGx5CkBAIC0xNDgyLDg0ICsxNTAw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ICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgc3BuU3RhdGUgPSBHZXRfU3BuX0ZzbV9TdGF0ZS5JTklUOworICAgICAgICAgICAgICAgIG1TcG5TdGF0ZSA9IEdldFNwbkZzbVN0YXRlLklOSVQ7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KIAotICAgICAgICBzd2l0Y2goc3BuU3RhdGUpeworICAgICAgICBzd2l0Y2gobVNwblN0YXRlKXsKICAgICAgICAgICAgIGNhc2UgSU5JVDoKLSAgICAgICAgICAgICAgICBzcG4gPSBudWxsOworICAgICAgICAgICAgICAgIG1TcG4gPSBudWxsOwogCiAgICAgICAgICAgICAgICAgbUZoLmxvYWRFRlRyYW5zcGFyZW50KEVGX1NQTiwKICAgICAgICAgICAgICAgICAgICAgICAgIG9idGFpbk1lc3NhZ2UoRVZFTlRfR0VUX1NQTl9ET05FKSk7Ci0gICAgICAgICAgICAgICAgcmVjb3Jkc1RvTG9hZCsrOworICAgICAgICAgICAgICAgIG1SZWNvcmRzVG9Mb2FkKys7CiAKLSAgICAgICAgICAgICAgICBzcG5TdGF0ZSA9IEdldF9TcG5fRnNtX1N0YXRlLlJFQURfU1BOXzNHUFA7CisgICAgICAgICAgICAgICAgbVNwblN0YXRlID0gR2V0U3BuRnNtU3RhdGUuUkVBRF9TUE5fM0dQUDsKICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIGNhc2UgUkVBRF9TUE5fM0dQUDoKICAgICAgICAgICAgICAgICBpZiAoYXIgIT0gbnVsbCAmJiBhci5leGNlcHRpb24gPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICBkYXRhID0gKGJ5dGVbXSkgYXIucmVzdWx0OwotICAgICAgICAgICAgICAgICAgICBzcG5EaXNwbGF5Q29uZGl0aW9uID0gMHhmZiAmIGRhdGFbMF07Ci0gICAgICAgICAgICAgICAgICAgIHNwbiA9IEljY1V0aWxzLmFkblN0cmluZ0ZpZWxkVG9TdHJpbmcoZGF0YSwgMSwgZGF0YS5sZW5ndGggLSAxKTsKKyAgICAgICAgICAgICAgICAgICAgbVNwbkRpc3BsYXlDb25kaXRpb24gPSAweGZmICYgZGF0YVswXTsKKyAgICAgICAgICAgICAgICAgICAgbVNwbiA9IEljY1V0aWxzLmFkblN0cmluZ0ZpZWxkVG9TdHJpbmcoZGF0YSwgMSwgZGF0YS5sZW5ndGggLSAxKTsKIAotICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coIkxvYWQgRUZfU1BOOiAiICsgc3BuCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgKyAiIHNwbkRpc3BsYXlDb25kaXRpb246ICIgKyBzcG5EaXNwbGF5Q29uZGl0aW9uKTsKLSAgICAgICAgICAgICAgICAgICAgU3lzdGVtUHJvcGVydGllcy5zZXQoUFJPUEVSVFlfSUNDX09QRVJBVE9SX0FMUEhBLCBzcG4pOworICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coIkxvYWQgRUZfU1BOOiAiICsgbVNwbgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgIiBzcG5EaXNwbGF5Q29uZGl0aW9uOiAiICsgbVNwbkRpc3BsYXlDb25kaXRpb24pOworICAgICAgICAgICAgICAgICAgICBTeXN0ZW1Qcm9wZXJ0aWVzLnNldChQUk9QRVJUWV9JQ0NfT1BFUkFUT1JfQUxQSEEsIG1TcG4pOwogCi0gICAgICAgICAgICAgICAgICAgIHNwblN0YXRlID0gR2V0X1Nwbl9Gc21fU3RhdGUuSURMRTsKKyAgICAgICAgICAgICAgICAgICAgbVNwblN0YXRlID0gR2V0U3BuRnNtU3RhdGUuSURMRTsKICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICBtRmgubG9hZEVGVHJhbnNwYXJlbnQoIEVGX1NQTl9DUEhTLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9idGFpbk1lc3NhZ2UoRVZFTlRfR0VUX1NQTl9ET05FKSk7Ci0gICAgICAgICAgICAgICAgICAgIHJlY29yZHNUb0xvYWQrKzsKKyAgICAgICAgICAgICAgICAgICAgbVJlY29yZHNUb0xvYWQrKzsKIAotICAgICAgICAgICAgICAgICAgICBzcG5TdGF0ZSA9IEdldF9TcG5fRnNtX1N0YXRlLlJFQURfU1BOX0NQSFM7CisgICAgICAgICAgICAgICAgICAgIG1TcG5TdGF0ZSA9IEdldFNwbkZzbVN0YXRlLlJFQURfU1BOX0NQSFM7CiAKICAgICAgICAgICAgICAgICAgICAgLy8gU2VlIFRTIDUxLjAxMSAxMC4zLjExLiAgQmFzaWNhbGx5LCBkZWZhdWx0IHRvCiAgICAgICAgICAgICAgICAgICAgIC8vIHNob3cgUExNTiBhbHdheXMsIGFuZCBTUE4gYWxzbyBpZiByb2FtaW5nLgotICAgICAgICAgICAgICAgICAgICBzcG5EaXNwbGF5Q29uZGl0aW9uID0gLTE7CisgICAgICAgICAgICAgICAgICAgIG1TcG5EaXNwbGF5Q29uZGl0aW9uID0gLTE7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgY2FzZSBSRUFEX1NQTl9DUEhTOgogICAgICAgICAgICAgICAgIGlmIChhciAhPSBudWxsICYmIGFyLmV4Y2VwdGlvbiA9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgIGRhdGEgPSAoYnl0ZVtdKSBhci5yZXN1bHQ7Ci0gICAgICAgICAgICAgICAgICAgIHNwbiA9IEljY1V0aWxzLmFkblN0cmluZ0ZpZWxkVG9TdHJpbmcoZGF0YSwgMCwgZGF0YS5sZW5ndGgpOworICAgICAgICAgICAgICAgICAgICBtU3BuID0gSWNjVXRpbHMuYWRuU3RyaW5nRmllbGRUb1N0cmluZyhkYXRhLCAwLCBkYXRhLmxlbmd0aCk7CiAKLSAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJMb2FkIEVGX1NQTl9DUEhTOiAiICsgc3BuKTsKLSAgICAgICAgICAgICAgICAgICAgU3lzdGVtUHJvcGVydGllcy5zZXQoUFJPUEVSVFlfSUNDX09QRVJBVE9SX0FMUEhBLCBzcG4pOworICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coIkxvYWQgRUZfU1BOX0NQSFM6ICIgKyBtU3BuKTsKKyAgICAgICAgICAgICAgICAgICAgU3lzdGVtUHJvcGVydGllcy5zZXQoUFJPUEVSVFlfSUNDX09QRVJBVE9SX0FMUEhBLCBtU3BuKTsKIAotICAgICAgICAgICAgICAgICAgICBzcG5TdGF0ZSA9IEdldF9TcG5fRnNtX1N0YXRlLklETEU7CisgICAgICAgICAgICAgICAgICAgIG1TcG5TdGF0ZSA9IEdldFNwbkZzbVN0YXRlLklETEU7CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgbUZoLmxvYWRFRlRyYW5zcGFyZW50KAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIEVGX1NQTl9TSE9SVF9DUEhTLCBvYnRhaW5NZXNzYWdlKEVWRU5UX0dFVF9TUE5fRE9ORSkpOwotICAgICAgICAgICAgICAgICAgICByZWNvcmRzVG9Mb2FkKys7CisgICAgICAgICAgICAgICAgICAgIG1SZWNvcmRzVG9Mb2FkKys7CiAKLSAgICAgICAgICAgICAgICAgICAgc3BuU3RhdGUgPSBHZXRfU3BuX0ZzbV9TdGF0ZS5SRUFEX1NQTl9TSE9SVF9DUEhTOworICAgICAgICAgICAgICAgICAgICBtU3BuU3RhdGUgPSBHZXRTcG5Gc21TdGF0ZS5SRUFEX1NQTl9TSE9SVF9DUEhTOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIGNhc2UgUkVBRF9TUE5fU0hPUlRfQ1BIUzoKICAgICAgICAgICAgICAgICBpZiAoYXIgIT0gbnVsbCAmJiBhci5leGNlcHRpb24gPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICBkYXRhID0gKGJ5dGVbXSkgYXIucmVzdWx0OwotICAgICAgICAgICAgICAgICAgICBzcG4gPSBJY2NVdGlscy5hZG5TdHJpbmdGaWVsZFRvU3RyaW5nKGRhdGEsIDAsIGRhdGEubGVuZ3RoKTsKKyAgICAgICAgICAgICAgICAgICAgbVNwbiA9IEljY1V0aWxzLmFkblN0cmluZ0ZpZWxkVG9TdHJpbmcoZGF0YSwgMCwgZGF0YS5sZW5ndGgpOwogCi0gICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygiTG9hZCBFRl9TUE5fU0hPUlRfQ1BIUzogIiArIHNwbik7Ci0gICAgICAgICAgICAgICAgICAgIFN5c3RlbVByb3BlcnRpZXMuc2V0KFBST1BFUlRZX0lDQ19PUEVSQVRPUl9BTFBIQSwgc3BuKTsKKyAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJMb2FkIEVGX1NQTl9TSE9SVF9DUEhTOiAiICsgbVNwbik7CisgICAgICAgICAgICAgICAgICAgIFN5c3RlbVByb3BlcnRpZXMuc2V0KFBST1BFUlRZX0lDQ19PUEVSQVRPUl9BTFBIQSwgbVNwbik7CiAgICAgICAgICAgICAgICAgfWVsc2UgewogICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coIk5vIFNQTiBsb2FkZWQgaW4gZWl0aGVyIENIUFMgb3IgM0dQUCIpOwogICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgICAgIHNwblN0YXRlID0gR2V0X1Nwbl9Gc21fU3RhdGUuSURMRTsKKyAgICAgICAgICAgICAgICBtU3BuU3RhdGUgPSBHZXRTcG5Gc21TdGF0ZS5JRExFOwogICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgZGVmYXVsdDoKLSAgICAgICAgICAgICAgICBzcG5TdGF0ZSA9IEdldF9TcG5fRnNtX1N0YXRlLklETEU7CisgICAgICAgICAgICAgICAgbVNwblN0YXRlID0gR2V0U3BuR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vbGVhbiBEQkcgPSB0cnVlOwogCiAgICAgcHJpdmF0ZSBzdGF0aWMgZmluYWwgaW50IEVWRU5UX1FVRVJZX0ZBQ0lMSVRZX0ZETl9ET05FID0gMTsKQEAgLTI4Myw2ICsyODMsMTAgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2dlKCJRVUVSWV9GQUNJTElUWV9MT0NLOmRpc2FibGVkIEdFVF9TSU1fU1RBVFVTLlBpbjE6ZW5hYmxlZC4iCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArICIgRml4bWUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgY2FzZSBQSU5TVEFURV9VTktOT1dOOgorICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJJZ25vcmluZzogcGluMXN0YXRlPSIgKyBtUGluMVN0YXRlKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgbG9nZSgiQm9ndXMgZmFjaWxpdHkgbG9jayByZXNwb25zZSIpOwpkaWZmIC0tZ2l0IGEvc3JjL2phdmEvY29tL2FuZHJvaWQvaW50ZXJuYWwvdGVsZXBob255L3VpY2MvVWljY0NvbnRyb2xsZXIuamF2YSBiL3NyYy9qYXZhL2NvbS9hbmRyb2lkL2ludGVybmFsL3RlbGVwaG9ueS91aWNjL1VpY2NDb250cm9sbGVyLmphdmEKaW5kZXggMjY0N2IzOS4uYzMzZGNmYSAxMDA2NDQKLS0tIGEvc3JjL2phdmEvY29tL2FuZHJvaWQvaW50ZXJuYWwvdGVsZXBob255L3VpY2MvVWljY0NvbnRyb2xsZXIuamF2YQorKysgYi9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvdWljYy9VaWNjQ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jeU51bWJlcjsKLSAgICAgICAgICAgICAgICBkZWZhdWx0OgotICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgVW5zdXBwb3J0ZWRPcGVyYXRpb25FeGNlcHRpb24oIk1pc3NpbmcgaGFuZGxpbmcgZm9yIHJlc2lkICIgKyByZXNJZCk7Ci0gICAgICAgICAgICB9Ci0gICAgICAgIH0KLSAgICB9Ci0KLSAgICAvLyBQYXJ0aWFsIGltcGxlbWVudGF0aW9uIG9mIE1vY2tDb250ZXh0LgotICAgIHB1YmxpYyBjbGFzcyBNb2NrQ29udGV4dCBleHRlbmRzIGFuZHJvaWQudGVzdC5tb2NrLk1vY2tDb250ZXh0IHsKLSAgICAgICAgcHJpdmF0ZSBDb250ZW50UmVzb2x2ZXIgbVJlc29sdmVyOwotICAgICAgICBwcml2YXRlIFJlc291cmNlcyBtUmVzb3VyY2VzOwotCi0gICAgICAgIHB1YmxpYyBNb2NrQ29udGV4dCgpIHsKLSAgICAgICAgICAgIG1SZXNvbHZlciA9IG5ldyBhbmRyb2lkLnRlc3QubW9jay5Nb2NrQ29udGVudFJlc29sdmVyKCk7Ci0gICAgICAgICAgICBtUmVzb3VyY2VzID0gbmV3IE1vY2tSZXNvdXJjZXMoKTsKLSAgICAgICAgfQotCi0gICAgICAgIEBPdmVycmlkZQotICAgICAgICBwdWJsaWMgQ29udGVudFJlc29sdmVyIGdldENvbnRlbnRSZXNvbHZlcigpIHsKLSAgICAgICAgICAgIHJldHVybiBtUmVzb2x2ZXI7Ci0gICAgICAgIH0KLQotICAgICAgICBAT3ZlcnJpZGUKLSAgICAgICAgcHVibGljIFJlc291cmNlcyBnZXRSZXNvdXJjZXMoKSB7Ci0gICAgICAgICAgICByZXR1cm4gbVJlc291cmNlczsKLSAgICAgICAgfQotICAgIH0KLQotICAgIC8qKgotICAgICAqIENsYXNzIHRvIHJ1biBhIENhbGxlckluZm9Bc3luY1F1ZXJ5IGluIGEgc2VwYXJhdGUgdGhyZWFkLCB3aXRo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yKCk7CisgICAgICAgICAgICAgICAgZW5jb2RlRGVjb2RlQXNzZXJ0RXF1YWxzKGZyYWdtZW50cy5nZXQoaSksIGhlYWRlciwgLTEpOworICAgICAgICAgICAgICAgIGVuY29kZURlY29kZUFzc2VydEVxdWFscyhmcmFnbWVudHMuZ2V0KGkpLCBoZWFkZXIyLCAtMSk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KIApAQCAtOTI4LDggKzk4MCwxMCBAQAogICAgICAgICAgICAgYXNzZXJ0RXF1YWxzKDMsIGZyYWdtZW50cy5zaXplKCkpOwogCiAgICAgICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IDM7IGkrKykgewotICAgICAgICAgICAgICAgIGVuY29kZURlY29kZUFzc2VydEVxdWFscyhmcmFnbWVudHMuZ2V0KGkpLCBpICsgMSwgMywgZmFsc2UpOwotICAgICAgICAgICAgICAgIGVuY29kZURlY29kZUFzc2VydEVxdWFscyhmcmFnbWVudHMuZ2V0KGkpLCBpICsgMSwgMywgdHJ1ZSk7CisgICAgICAgICAgICAgICAgU21zSGVhZGVyIGhlYWRlciA9IGdldENvbmNhdFVzZXJEYXRhSGVhZGVyKGkgKyAxLCAzKTsKKyAgICAgICAgICAgICAgICBTbXNIZWFkZXIgaGVhZGVyMiA9IGdldE9kZExlbmd0aFVzZXJEYXRhSGVhZGVyKCk7CisgICAgICAgICAgICAgICAgZW5jb2RlRGVjb2RlQXNzZXJ0RXF1YWxzKGZyYWdtZW50cy5nZXQoaSksIGhlYWRlciwgLTEpOworICAgICAgICAgICAgICAgIGVuY29kZURlY29kZUFzc2VydEVxdWFscyhmcmFnbWVudHMuZ2V0KGkpLCBoZWFkZXIyLCAtMSk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICB9CmRpZmYgLS1naXQgYS90ZXN0cy90ZWxlcGhvbnl0ZXN0cy9zcmMvY29tL2FuZHJvaWQvaW50ZXJuYWwvdGVsZXBob255L2dzbS9Hc21TbXNDYlRlc3QuamF2Y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