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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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2FnZVJlZiA9ICgoU21zUmVzcG9uc2UpYXIucmVzdWx0KS5tZXNzYWdlUmVmOworICAgICAgICAgICAgdHJhY2tlci5tTWVzc2FnZVJlZiA9ICgoU21zUmVzcG9uc2UpYXIucmVzdWx0KS5tTWVzc2FnZVJlZjsKICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIFJsb2cuZChUQUcsICJTbXNSZXNwb25zZSB3YXMgbnVsbCIpOwogICAgICAgICB9CiAKICAgICAgICAgaWYgKGFyLmV4Y2VwdGlvbiA9PSBudWxsKSB7Ci0gICAgICAgICAgICBpZiAoZmFsc2UpIHsKLSAgICAgICAgICAgICAgICBSbG9nLmQoVEFHLCAiU01TIHNlbmQgY29tcGxldGUuIEJyb2FkY2FzdGluZyAiCi0gICAgICAgICAgICAgICAgICAgICAgICArICJpbnRlbnQ6ICIgKyBzZW50SW50ZW50KTsKLSAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGlmIChEQkcpIFJsb2cuZChUQUcsICJTTVMgc2VuZCBjb21wbGV0ZS4gQnJvYWRjYXN0aW5nIGludGVudDogIiArIHNlbnRJbnRlbnQpOwogCiAgICAgICAgICAgICBpZiAodHJhY2tlci5tRGVsaXZlcnlJbnRlbnQgIT0gbnVsbCkgewogICAgICAgICAgICAgICAgIC8vIEV4cGVjdGluZyBhIHN0YXR1cyByZXBvcnQuICBBZGQgaXQgdG8gdGhlIGxpc3QuCkBAIC00NTcsOSArNDU4LDcgQEAKICAgICAgICAgICAgICAgICB9IGNhdGNoIChDYW5jZWxlZEV4Y2VwdGlvbiBleCkge30KICAgICAgICAgICAgIH0KICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgIGlmIChmYWxzZSkgewotICAgICAgICAgICAgICAgIFJsb2cuZChUQUcsICJTTVMgc2VuZCBmYWlsZWQiKTsKLSAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGlmIChEQkcpIFJsb2cuZChUQUcsICJTTVMgc2VuZCBmYWlsZWQiKTsKIAogICAgICAgICAgICAgaW50IHNzID0gbVBob25lLmdldFNlcnZpY2VTdGF0ZSgpLmdldFN0YXRlKCk7CiAKQEAgLTQ5MCw3ICs0ODksNyBAQAogICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgIEludGVudCBmaWxsSW4gPSBuZXcgSW50ZW50KCk7CiAgICAgICAgICAgICAgICAgICAgIGlmIChhci5yZXN1bHQgIT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICAgICAgZmlsbEluLnB1dEV4dHJhKCJlcnJvckNvZGUiLCAoKFNtc1Jlc3BvbnNlKWFyLnJlc3VsdCkuZXJyb3JDb2RlKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGZpbGxJbi5wdXRFeHRyYSgiZXJyb3JDb2RlIiwgKChTbXNSZXNwb25zZSlhci5yZXN1bHQpLm1FcnJvckNvZGUpOwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIGlmIChtUmVtYWluaW5nTWVzc2FnZXMgPiAtMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgbVJlbWFpbmluZ01lc3NhZ2VzLS07CkBAIC01MzEsNyArNTMwLDcgQEAKICAgICAgKiBEaXNwYXRjaGVzIGFuIGluY29taW5nIFNNUyBtZXNzYWdlcy4KICAgICAgKgogICAgICAqIEBwYXJhbSBzbXMgdGhlIGluY29taW5nIG1lc3NhZ2UgZnJvbSB0aGUgcGhvbmUKLSAgICAgKiBAcmV0dXJuIGEgcmVzdWx0IGNvZGUgZnJvbSB7QGxpbmsgVGVsZXBob255LlNtcy5JbnRlbnRzfSwgb3IKKyAgICAgKiBAcmV0dXJuIGEgcmVzdWx0IGNvZGUgZnJvbSB7QGxpbmsgYW5kcm9pZC5wcm92aWRlci5UZWxlcGhvbnkuU21zLkludGVudHN9LCBvcgogICAgICAqICAgICAgICAge0BsaW5rIEFjdGl2aXR5I1JFU1VMVF9PS30gaWYgdGhlIG1lc3NhZ2UgaGFzIGJlZW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IG51bGw7CiAgICAgICAgIH0KIAotICAgICAgICByZXR1cm4gb3JpZ2luYXRpbmdBZGRyZXNzLmdldEFkZHJlc3NTdHJpbmcoKTsKKyAgICAgICAgcmV0dXJuIG1PcmlnaW5hdGluZ0FkZHJlc3MuZ2V0QWRkcmVzc1N0cmluZygpOwogICAgIH0KIAogICAgIC8qKgpAQCAtMTI1LDggKzEyNCw4IEBACiAgICAgICogdW5hdmFpbGFibGUuCiAgICAgICovCiAgICAgcHVibGljIFN0cmluZyBnZXREaXNwbGF5T3JpZ2luYXRpbmdBZGRyZXNzKCkgewotICAgICAgICBpZiAoaXNFbWFpbCkgewotICAgICAgICAgICAgcmV0dXJuIGVtYWlsRnJvbTsKKyAgICAgICAgaWYgKG1Jc0VtYWlsKSB7CisgICAgICAgICAgICByZXR1cm4gbUVtYWlsRnJvbTsKICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIHJldHVybiBnZXRPcmlnaW5hdGluZ0FkZHJlc3MoKTsKICAgICAgICAgfQpAQCAtMTM3LDcgKzEzNiw3IEBACiAgICAgICogQHJldHVybiBtZXNzYWdlIGJvZHkgaXMgdGhlcmUgaXMgb25lLCBvdGhlcndpc2UgbnVsbAogICAgICAqLwogICAgIHB1YmxpYyBTdHJpbmcgZ2V0TWVzc2FnZUJvZHkoKSB7Ci0gICAgICAgIHJldHVybiBtZXNzYWdlQm9keTsKKyAgICAgICAgcmV0dXJuIG1NZXNzYWdlQm9keTsKICAgICB9CiAKICAgICAvKioKQEAgLTE1MCw4ICsxNDksOCBAQAogICAgICAqIGFuIGVtYWlsIGdhdGV3YXkuIFJldHVybnMgbnVsbCBpZiBtZXNzYWdlIGJvZHkgdW5hdmFpbGFibGUuCiAgICAgICovCiAgICAgcHVibGljIFN0cmluZyBnZXREaXNwbGF5TWVzc2FnZUJvZHkoKSB7Ci0gICAgICAgIGlmIChpc0VtYWlsKSB7Ci0gICAgICAgICAgICByZXR1cm4gZW1haWxCb2R5OworICAgICAgICBpZiAobUlzRW1haWwpIHsKKyAgICAgICAgICAgIHJldHVybiBtRW1haWxCb2R5OwogICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgcmV0dXJuIGdldE1lc3NhZ2VCb2R5KCk7CiAgICAgICAgIH0KQEAgLTE2MiwxNCArMTYxLDE0IEBACiAgICAgICogaWYgbm90IHByZXNlbnQKICAgICAgKi8KICAgICBwdWJsaWMgU3RyaW5nIGdldFBzZXVkb1N1YmplY3QoKSB7Ci0gICAgICAgIHJldHVybiBwc2V1ZG9TdWJqZWN0ID09IG51bGwgPyAiIiA6IHBzZXVkb1N1YmplY3Q7CisgICAgICAgIHJldHVybiBtUHNldWRvU3ViamVjdCA9PSBudWxsID8gIiIgOiBtUHNldWRvU3ViamVjdDsKICAgICB9CiAKICAgICAvKioKICAgICAgKiBSZXR1cm5zIHRoZSBzZXJ2aWNlIGNlbnRyZSB0aW1lc3RhbXAgaW4gY3VycmVudFRpbWVNaWxsaXMoKSBmb3JtYXQKICAgICAgKi8KICAgICBwdWJsaWMgbG9uZyBnZXRUaW1lc3RhbXBNaWxsaXMoKSB7Ci0gICAgICAgIHJldHVybiBzY1RpbWVNaWxsaXM7CisgICAgICAgIHJldHVybiBtU2NUaW1lTWlsbGlzOwogICAgIH0KIAogICAgIC8qKgpAQCAtMTc5LDcgKzE3OCw3IEBACiAgICAgICogICAgICAgICBzZW5kZXIgLyBzdWJqZWN0IC8gcGFyc2VkIGJvZHkgYXJlIGF2YWlsYWJsZQogICAgICAqLwogICAgIHB1YmxpYyBib29sZWFuIGlzRW1haWwoKSB7Ci0gICAgICAgIHJldHVybiBpc0VtYWlsOworICAgICAgICByZXR1cm4gbUlzRW1haWw7CiAgICAgfQogCiAgICAgLyoqCkBAIC0xODcsNyArMTg2LDcgQEAKICAgICAgKiAgICAgICAgIG51bGwgb3RoZXJ3aXNlCiAgICAgICovCiAgICAgcHVibGljIFN0cmluZyBnZXRFbWFpbEJvZHkoKSB7Ci0gICAgICAgIHJldHVybiBlbWFpbEJvZHk7CisgICAgICAgIHJldHVybiBtRW1haWxCb2R5OwogICAgIH0KIAogICAgIC8qKgpAQCAtMTk1LDcgKzE5NCw3IEBACiAgICAgICogICAgICAgICB0aGUgZ2F0ZXdheS4gbnVsbCBvdGhlcndpc2UKICAgICAgKi8KICAgICBwdWJsaWMgU3RyaW5nIGdldEVtYWlsRnJvbSgpIHsKLSAgICAgICAgcmV0dXJuIGVtYWlsRnJvbTsKKyAgICAgICAgcmV0dXJuIG1FbWFpbEZyb207CiAgICAgfQogCiAgICAgLyoqCkBAIC0yNDAsNyArMjM5LDcgQEAKICAgICAgKiBwcmVzZW50LgogICAgICAqLwogICAgIHB1YmxpYyBieXRlW10gZ2V0VXNlckRhdGEoKSB7Ci0gICAgICAgIHJldHVybiB1c2VyRGF0YTsKKyAgICAgICAgcmV0dXJuIG1Vc2VyRGF0YTsKICAgICB9CiAKICAgICAvKioKQEAgLTI0OSw3ICsyNDgsNyBAQAogICAgICAqIHtAaGlkZX0KICAgICAgKi8KICAgICBwdWJsaWMgU21zSGVhZGVyIGdldFVzZXJEYXRhSGVhZGVyKCkgewotICAgICAgICByZXR1cm4gdXNlckRhdGFIZWFkZXI7CisgICAgICAgIHJldHVybiBtVXNlckRhdGFIZWFkZXI7CiAgICAgfQogCiAgICAgLyoqCkBAIC0zMDAsNyArMjk5LDcgQEAKICAgICAgKiAgICAgICAgIFNtc01hbmFnZXIuU1RBVFVTX09OX0lDQ19VTlNFTlQKICAgICAgKi8KICAgICBwdWJsaWMgaW50IGdldFN0YXR1c09uSWNjKCkgewotICAgICAgICByZXR1cm4gc3RhdHVzT25JY2M7CisgICAgICAgIHJldHVybiBtU3RhdHVzT25JY2M7CiAgICAgfQogCiAgICAgLyoqCkBAIC0zMDksMTMgKzMwOCwxMyBAQAogICAgICAqICAgICAgICAgU21zTWVzc2FnZSB3YXMgbm90IGNyZWF0ZWQgZnJvbSBhIElDQyBTTVMgRUYgcmVjb3JkLgogICAgICAqLwogICAgIHB1Ymx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AgICBtQ2kudW5TZXRPbkljY1Ntc0Z1bGwodGhpcyk7CisgICAgICAgIG1DaS51bnJlZ2lzdGVyRm9yT24odGhpcyk7CiAgICAgICAgIG1Db250ZXh0LnVucmVnaXN0ZXJSZWNlaXZlcihtUmVzdWx0UmVjZWl2ZXIpOwogICAgIH0KIApAQCAtMTE4LDcgKzExOCw3IEBACiAgICAgICAgICAgICAgICAgaWYgKG1SZXBvcnRNZW1vcnlTdGF0dXNQZW5kaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgIFJsb2cudihUQUcsICJTZW5kaW5nIHBlbmRpbmcgbWVtb3J5IHN0YXR1cyByZXBvcnQgOiBtU3RvcmFnZUF2YWlsYWJsZSA9ICIKICAgICAgICAgICAgICAgICAgICAgICAgICAgICArIG1TdG9yYWdlQXZhaWxhYmxlKTsKLSAgICAgICAgICAgICAgICAgICAgbUNtLnJlcG9ydFNtc01lbW9yeVN0YXR1cyhtU3RvcmFnZUF2YWlsYWJsZSwKKyAgICAgICAgICAgICAgICAgICAgbUNpLnJlcG9ydFNtc01lbW9yeVN0YXR1cyhtU3RvcmFnZUF2YWlsYWJsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX1JFUE9SVF9NRU1PUllfU1RBVFVTX0RPTkUpKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgYnJlYWs7CkBAIC0xNTIsMTAgKzE1MiwxMCBAQAogICAgICAgICBwdWJsaWMgdm9pZCBvblJlY2VpdmUoQ29udGV4dCBjb250ZXh0LCBJbnRlbnQgaW50ZW50KSB7CiAgICAgICAgICAgICBpZiAoaW50ZW50LmdldEFjdGlvbigpLmVxdWFscyhJbnRlbnQuQUNUSU9OX0RFVklDRV9TVE9SQUdFX0ZVTEwpKSB7CiAgICAgICAgICAgICAgICAgbVN0b3JhZ2VBdmFpbGFibGUgPSBmYWxzZTsKLSAgICAgICAgICAgICAgICBtQ20ucmVwb3J0U21zT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pcy51dXNUeXBlID0gVVVTX1RZUEUxX0lNUExJQ0lUOwotICAgICAgICB0aGlzLnV1c0RjcyA9IFVVU19EQ1NfSUE1YzsKLSAgICAgICAgdGhpcy51dXNEYXRhID0gbnVsbDsKKyAgICAgICAgbVV1c1R5cGUgPSBVVVNfVFlQRTFfSU1QTElDSVQ7CisgICAgICAgIG1VdXNEY3MgPSBVVVNfRENTX0lBNWM7CisgICAgICAgIG1VdXNEYXRhID0gbnVsbDsKICAgICB9CiAKICAgICBwdWJsaWMgVVVTSW5mbyhpbnQgdXVzVHlwZSwgaW50IHV1c0RjcywgYnl0ZVtdIHV1c0RhdGEpIHsKLSAgICAgICAgdGhpcy51dXNUeXBlID0gdXVzVHlwZTsKLSAgICAgICAgdGhpcy51dXNEY3MgPSB1dXNEY3M7Ci0gICAgICAgIHRoaXMudXVzRGF0YSA9IHV1c0RhdGE7CisgICAgICAgIG1VdXNUeXBlID0gdXVzVHlwZTsKKyAgICAgICAgbVV1c0RjcyA9IHV1c0RjczsKKyAgICAgICAgbVV1c0RhdGEgPSB1dXNEYXRhOwogICAgIH0KIAogICAgIHB1YmxpYyBpbnQgZ2V0RGNzKCkgewotICAgICAgICByZXR1cm4gdXVzRGNzOworICAgICAgICByZXR1cm4gbVV1c0RjczsKICAgICB9CiAKICAgICBwdWJsaWMgdm9pZCBzZXREY3MoaW50IHV1c0RjcykgewotICAgICAgICB0aGlzLnV1c0RjcyA9IHV1c0RjczsKKyAgICAgICAgbVV1c0RjcyA9IHV1c0RjczsKICAgICB9CiAKICAgICBwdWJsaWMgaW50IGdldFR5cGUoKSB7Ci0gICAgICAgIHJldHVybiB1dXNUeXBlOworICAgICAgICByZXR1cm4gbVV1c1R5cGU7CiAgICAgfQogCiAgICAgcHVibGljIHZvaWQgc2V0VHlwZShpbnQgdXVzVHlwZSkgewotICAgICAgICB0aGlzLnV1c1R5cGUgPSB1dXNUeXBlOworICAgICAgICBtVXVzVHlwZSA9IHV1c1R5cGU7CiAgICAgfQ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lIG5hbWUsIElCaW5kZXIgc2VydmljZSkgewogICAgICAgICAgICAgbVdhcFB1c2hNYW4gPSBJV2FwUHVzaE1hbmFnZXIuU3R1Yi5hc0ludGVyZmFjZShzZXJ2aWNlKTsKLSAgICAgICAgICAgIGlmIChmYWxzZSkgUmxvZy52KExPR19UQUcsICJ3YXBwdXNoIG1hbmFnZXIgY29ubmVjdGVkIHRvICIgKworICAgICAgICAgICAgaWYgKERCRykgUmxvZy52KExPR19UQUcsICJ3YXBwdXNoIG1hbmFnZXIgY29ubmVjdGVkIHRvICIgKwogICAgICAgICAgICAgICAgICAgICBtT3duZXIuaGFzaENvZGUoKSk7CiAgICAgICAgIH0KIAorICAgICAgICBAT3ZlcnJpZGUKICAgICAgICAgcHVibGljIHZvaWQgb25TZXJ2aWNlRGlzY29ubmVjdGVkKENvbXBvbmVudE5hbWUgbmFtZSkgewogICAgICAgICAgICAgbVdhcFB1c2hNYW4gPSBudWxsOwotICAgICAgICAgICAgaWYgKGZhbHNlKSBSbG9nLnYoTE9HX1RBRywgIndhcHB1c2ggbWFuYWdlciBkaXNjb25uZWN0ZWQuIik7CisgICAgICAgICAgICBpZiAoREJHKSBSbG9nLnYoTE9HX1RBRywgIndhcHB1c2ggbWFuYWdlciBkaXNjb25uZWN0ZWQuIik7CiAgICAgICAgICAgICAvLyBEZXRhY2ggdGhlIHByZXZpb3VzIGJpbmRlcgogICAgICAgICAgICAgbU93bmVyLnVuYmluZFNlcnZpY2UobVdhcENvbm4pOwogICAgICAgICAgICAgLy8gV2FwUHVzaE1hbmFnZXIgbXVzdCBiZSBhbHdheXMgYXR0YWNoZWQuCkBAIC05Nyw2ICs5NCw3IEBACiAKICAgICAgICAgICAgIGZpbmFsIFNlcnZpY2VDb25uZWN0aW9uIHdhcFB1c2hDb25uZWN0aW9uID0gdGhpczsKICAgICAgICAgICAgIG5ldyBUaHJlYWQoKSB7CisgICAgICAgICAgICAgICAgQE92ZXJyaWRlCiAgICAgICAgICAgICAgICAgcHVibGljIHZvaWQgcnVuKCkgewogICAgICAgICAgICAgICAgICAgICB3aGlsZSAobVdhcFB1c2hNYW4gPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgbU93bmVyLmJpbmRTZXJ2aWNlKG5ldyBJbnRlbnQoSVdhcFB1c2hNYW5hZ2VyLmNsYXNzLmdldE5hbWUoKSksCkBAIC0xMDQsNyArMTAyLDcgQEAKICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVGhyZWFkLnNsZWVwKEJJTkRfUkVUUllfSU5URVJWQUwpOwogICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoSW50ZXJydXB0ZWRFeGNlcHRpb24gZSkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmYWxzZSkgUmxvZy52KExPR19UQUcsICJzbGVlcCBpbnRlcnJ1cHRlZC4iKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBSbG9nLnYoTE9HX1RBRywgInNsZWVwIGludGVycnVwdGVkLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgfQpAQCAtMTMyLDEzICsxMzAsMTMgQEAKICAgICAgKiB3YXAtMjMwLXdzcC0yMDAxMDcwNS1hIHNlY3Rpb24gOCBmb3IgZGV0YWlscyBvbiB0aGUgV0FQIFBEVSBmb3JtYXQuCiAgICAgICoKICAgICAgKiBAcGFyYW0gcGR1IFRoZSBXQVAgUERVLCBtYWRlIHVwIG9mIG9uZSBvciBtb3JlIFNNUyBQRFVzCi0gICAgICogQHJldHVybiBhIHJlc3VsdCBjb2RlIGZyb20ge0BsaW5rIFRlbGVwaG9ueS5TbXMuSW50ZW50c30sIG9yCisgICAgICogQHJldHVybiBhIHJlc3VsdCBjb2RlIGZyb20ge0BsaW5rIGFuZHJvaWQucHJvdmlkZXIuVGVsZXBob255LlNtc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d2lsbCBiZSBlbmNvZGVkIGluIG5vIG1vcmUgdGhhbiA1IG9jdGV0cy4KICAgICAgICAgICovCiAgICAgICAgIGlmIChwZHVEZWNvZGVyLmRlY29kZVVpbnR2YXJJbnRlZ2VyKGluZGV4KSA9PSBmYWxzZSkgewotICAgICAgICAgICAgaWYgKGZhbHNlKSBSbG9nLncoTE9HX1RBRywgIlJlY2VpdmVkIFBEVS4gSGVhZGVyIExlbmd0aCBlcnJvci4iKTsKKyAgICAgICAgICAgIGlmIChEQkcpIFJsb2cudyhMT0dfVEFHLCAiUmVjZWl2ZWQgUERVLiBIZWFkZXIgTGVuZ3RoIGVycm9yLiIpOwogICAgICAgICAgICAgcmV0dXJuIEludGVudHMuUkVTVUxUX1NNU19HRU5FUklDX0VSUk9SOwogICAgICAgICB9CiAgICAgICAgIGhlYWRlckxlbmd0aCA9IChpbnQpcGR1RGVjb2Rlci5nZXRWYWx1ZTMyKCk7CkBAIC0xODEsNyArMTc5LDcgQEAKICAgICAgICAgICogTGVuZ3RoID0gVWludHZhci1pbnRlZ2VyCiAgICAgICAgICAqLwogICAgICAgICBpZiAocGR1RGVjb2Rlci5kZWNvZGVDb250ZW50VHlwZShpbmRleCkgPT0gZmFsc2UpIHsKLSAgICAgICAgICAgIGlmIChmYWxzZSkgUmxvZy53KExPR19UQUcsICJSZWNlaXZlZCBQRFUuIEhlYWRlciBDb250ZW50LVR5cGUgZXJyb3IuIik7CisgICAgICAgICAgICBpZiAoREJHKSBSbG9nLncoTE9HX1RBRywgIlJlY2VpdmVkIFBEVS4gSGVhZGVyIENvbnRlbnQtVHlwZSBlcnJvci4iKTsKICAgICAgICAgICAgIHJldHVybiBJbnRlbnRzLlJFU1VMVF9TTVNfR0VORVJJQ19FUlJPUjsKICAgICAgICAgfQogCkBAIC0yMTgsMTQgKzIxNiwxNCBAQAogCiAgICAgICAgICAgICBTdHJpbmcgY29udGVudFR5cGUgPSAoKG1pbWVUeXBlID09IG51bGwpID8KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBMb25nLnRvU3RyaW5nKGJpbmFyeUNvbnRlbnRUeXBlKSA6IG1pbWVUeXBlKTsKLSAgICAgICAgICAgIGlmIChmYWxzZSkgUmxvZy52KExPR19UQUcsICJhcHBpZCBmb3VuZDogIiArIHdhcEFwcElkICsgIjoiICsgY29udGVudFR5cGUpOworICAgICAgICAgICAgaWYgKERCRykgUmxvZy52KExPR19UQUcsICJhcHBpZCBmb3VuZDogIiArIHdhcEFwcElkICsgIjoiICsgY29udGVudFR5cGUpOwogCiAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgIGJvb2xlYW4gcHJvY2Vzc0Z1cnRoZXIgPSB0cnVlOwogICAgICAgICAgICAgICAgIElXYXBQdXNoTWFuYWdlciB3YXBQdXNoTWFuID0gbVdhcENvbm4uZ2V0V2FwUHVzaE1hbmFnZXIoKTsKIAogICAgICAgICAgICAgICAgIGlmICh3YXBQdXNoTWFuID09IG51bGwpIHsKLSAgICAgICAgICAgICAgICAgICAgaWYgKGZhbHNlKSBSbG9nLncoTE9HX1RBRywgIndhcCBwdXNoIG1hbmFnZXIgbm90IGZvdW5kISIpOworICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBSbG9nLncoTE9HX1RBRywgIndhcCBwdXNoIG1hbmFnZXIgbm90IGZvdW5kISIpOwogICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgIEludGVudCBpbnRlbnQgPSBuZXcgSW50ZW50KCk7CiAgICAgICAgICAgICAgICAgICAgIGludGVudC5wdXRFeHRyYSgidHJhbnNhY3Rpb25JZCIsIHRyYW5zYWN0aW9uSWQpOwpAQCAtMjM2LDcgKzIzNCw3IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGR1RGVjb2Rlci5nZXRDb250ZW50UGFyYW1ldGVycygpKTsKIAogICAgICAgICAgICAgICAgICAgICBpbnQgcHJvY1JldCA9IHdhcFB1c2hNYW4ucHJvY2Vzc01lc3NhZ2Uod2FwQXBwSWQsIGNvbnRlbnRUeXBlLCBpbnRlbnQpOwotICAgICAgICAgICAgICAgICAgICBpZiAoZmFsc2UpIFJsb2cudihMT0dfVEFHLCAicHJvY1JldDoiICsgcHJvY1JldCk7CisgICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIFJsb2cudihMT0dfVEFHLCAicHJvY1JldDoiICsgcHJvY1JldCk7CiAgICAgICAgICAgICAgICAgICAgIGlmICgocHJvY1JldCAmIFdhcFB1c2hNYW5hZ2VyUGFyYW1zLk1FU1NBR0VfSEFORExFRCkgPiAwCiAgICAgICAgICAgICAgICAgICAgICAgICAmJiAocHJvY1JldCAmIFdhcFB1c2hNYW5hZ2VyUGFyYW1zLkZVUlRIRVJfUFJPQ0VTU0lORykgPT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgcHJvY2Vzc0Z1cnRoZXIgPSBmYWxzZTsKQEAgLTI0NiwyMiArMjQ0LDI1IEBACiAgICAgICAgICAgICAgICAgICAgIHJldHVybiBJbnRlbnRzLlJFU1VMVF9TTVNfSEFORExFRDsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9IGNhdGNoIChSZW1vdGVFeGNlcHRpb24gZSkgewotICAgICAgICAgICAgICAgIGlmIChmYWxzZSkgUmxvZy53KExPR19UQUcsICJyZW1vdGUgZnVuYyBmYWlsZWQuLi4iKTsKKyAgICAgICAgICAgICAgICBpZiAoREJHKSBSbG9nLncoTE9HX1RBRywgInJlbW90ZSBmdW5jIGZhaWxlZC4uLiIpOwogICAgICAgICAgICAgfQogICAgICAgICB9Ci0gICAgICAgIGlmIChmYWxzZSkgUmxvZy52KExPR19UQUcsICJmYWxsIGJhY2sgdG8gZXhpc3RpbmcgaGFuZGxlciIpOworICAgICAgICBpZiAoREJHKSBSbG9nLnYoTE9HX1RBRywgImZhbGwgYmFjayB0byBleGlzdGluZyBoYW5kbGVyIik7CiAKICAgICAgICAgaWYgKG1pbWVUeXBlID09IG51bGwpIHsKLSAgICAgICAgICAgIGlmIChmYWxzZSkgUmxvZy53KExPR19UQUcsICJIZWFkZXIgQ29udGVudC1UeXBlIGVycm9yLiIpOworICAgICAgICAgICAgaWYgKERCRykgUmxvZy53KExPR19UQUcsICJIZWFkZXIgQ29udGVudC1UeXBlIGVycm9yLiIpOwogICAgICAgICAgICAgcmV0dXJuIEludGVudHMuUkVTVUxUX1NNU19HRU5FUklDX0VSUk9SOwogICAgICAgICB9CiAKICAgICAgICAgU3RyaW5nIHBlcm1pc3Npb247CisgICAgICAgIGludCBhcHBPcDsKIAogICAgICAgICBpZiAobWltZVR5cGUuZXF1YWxzKFdzcFR5cGVEZWNvZGVyLkNPTlRFTlRfVFlQRV9CX01NUykpIHsKLSAgICAgICAgICAgIHBlcm1pc3Npb24gPSAiYW5kcm9pZC5wZXJtaXNzaW9uLlJFQ0VJVkVfTU1TIjsKKyAgICAgICAgICAgIHBlcm1pc3Npb24gPSBhbmRyb2lkLk1hbmlmZXN0LnBlcm1pc3Npb24uUkVDRUlWRV9NTVM7CisgICAgICAgICAgICBhcHBPcCA9IEFwcE9wc01hbmFnZXIuT1BfUkVDRUlWRV9NTVM7CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICBwZXJtaXNzaW9uID0gImFuZHJvaWQucGVybWlzc2lvbi5SRUNFSVZFX1dBUF9QVVNIIjsKKyAgICAgICAgICAgIHBlcm1pc3Npb24gPSBhbmRyb2lkLk1hbmlmZXN0LnBlcm1pc3Npb24uUkVDRUlWRV9XQVBfUFVTSDsKKyAgICAgICAgICAgIGFwcE9wID0gQXBwT3BzTWFuYWdlci5PUF9SRUNFSVZFX1dBUF9QVVNIOwogICAgICAgICB9CiAKICAgICAgICAgSW50ZW50IGludGVudCA9IG5ldyBJbnRlbnQoSW50ZW50cy5XQVBfUFVTSF9SRUNFSVZFRF9BQ1RJT04pOwpAQCAtMjcyLDcgKzI3Myw3IEBACiAgICAgICAgIGludGVudC5wdXRFeHRyYSgiZGF0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QCAtMjYwLDExICsyNjAsMTEgQEAKICAgICAgKiAgICAgICAgIGxlbmd0aCBvZiBkYXRhIGluIHBkdSBjYW4gYmUgcmV0cmlldmVkIGJ5IGdldERlY29kZWREYXRhTGVuZ3RoKCkgbWV0aG9kCiAgICAgICovCiAgICAgcHVibGljIGJvb2xlYW4gZGVjb2RlU2hvcnRJbnRlZ2VyKGludCBzdGFydEluZGV4KSB7Ci0gICAgICAgIGlmICgod3NwRGF0YVtzdGFydEluZGV4XSAmIDB4ODApID09IDApIHsKKyAgICAgICAgaWYgKChtV3NwRGF0YVtzdGFydEluZGV4XSAmIDB4ODApID09IDApIHsKICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgfQotICAgICAgICB1bnNpZ25lZDMyYml0ID0gd3NwRGF0YVtzdGFydEluZGV4XSAmIDB4N2Y7Ci0gICAgICAgIGRhdGFMZW5ndGggPSAxOworICAgICAgICBtVW5zaWduZWQzMmJpdCA9IG1Xc3BEYXRhW3N0YXJ0SW5kZXhdICYgMHg3ZjsKKyAgICAgICAgbURhdGFMZW5ndGggPSAxOwogICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICB9CiAKQEAgLTI3OCwxNiArMjc4LDE2IEBACiAgICAgICogICAgICAgICBsZW5ndGggb2YgZGF0YSBpbiBwZHUgY2FuIGJlIHJldHJpZXZlZCBieSBnZXREZWNvZGVkRGF0YUxlbmd0aCgpIG1ldGhvZAogICAgICAqLwogICAgIHB1YmxpYyBib29sZWFuIGRlY29kZUxvbmdJbnRlZ2VyKGludCBzdGFydEluZGV4KSB7Ci0gICAgICAgIGludCBsZW5ndGhNdWx0aU9jdGV0ID0gd3NwRGF0YVtzdGFydEluZGV4XSAmIDB4ZmY7CisgICAgICAgIGludCBsZW5ndGhNdWx0aU9jdGV0ID0gbVdzcERhdGFbc3RhcnRJbmRleF0gJiAweGZmOwogCiAgICAgICAgIGlmIChsZW5ndGhNdWx0aU9jdGV0ID4gV0FQX1BEVV9TSE9SVF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PCBXQVBfUERVX0xFTkdUSF9RVU9URSkgewotICAgICAgICAgICAgdW5zaWduZWQzMmJpdCA9IHdzcERhdGFbc3RhcnRJbmRleF07Ci0gICAgICAgICAgICBkYXRhTGVuZ3RoID0gMTsKKyAgICAgICAgaWYgKG1Xc3BEYXRhW3N0YXJ0SW5kZXhdIDwgV0FQX1BEVV9MRU5HVEhfUVVPVEUpIHsKKyAgICAgICAgICAgIG1VbnNpZ25lZDMyYml0ID0gbVdzcERhdGFbc3RhcnRJbmRleF07CisgICAgICAgICAgICBtRGF0YUxlbmd0aCA9IDE7CiAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICBkZWNvZGVVaW50dmFySW50ZWdlcihzdGFydEluZGV4ICsgMSk7Ci0gICAgICAgICAgICBkYXRhTGVuZ3RoKys7CisgICAgICAgICAgICBtRGF0YUxlbmd0aCsrOwogICAgICAgICB9CiAgICAgICAgIHJldHVybiB0cnVlOwogICAgIH0KQEAgLTM2NywxNyArMzY3LDE3IEBACiAgICAgICovCiAgICAgcHVibGljIGJvb2xlYW4gZGVjb2RlRXh0ZW5zaW9uTWVkaWEoaW50IHN0YXJ0SW5kZXgpIHsKICAgICAgICAgaW50IGluZGV4ID0gc3RhcnRJbmRleDsKLSAgICAgICAgZGF0YUxlbmd0aCA9IDA7Ci0gICAgICAgIHN0cmluZ1ZhbHVlID0gbnVsbDsKLSAgICAgICAgaW50IGxlbmd0aCA9IHdzcERhdGEubGVuZ3RoOworICAgICAgICBtRGF0YUxlbmd0aCA9IDA7CisgICAgICAgIG1TdHJpbmdWYWx1ZSA9IG51bGw7CisgICAgICAgIGludCBsZW5ndGggPSBtV3NwRGF0YS5sZW5ndGg7CiAgICAgICAgIGJvb2xlYW4gcnRybiA9IGluZGV4IDwgbGVuZ3RoOwogCi0gICAgICAgIHdoaWxlIChpbmRleCA8IGxlbmd0aCAmJiB3c3BEYXRhW2luZGV4XSAhPSAwKSB7CisgICAgICAgIHdoaWxlIChpbmRleCA8IGxlb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GFyYW1ldGVycyA9IG5ldyBIYXNoTWFwPFN0cmluZywgU3RyaW5nPigpOwogCiAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICBpZiAoZGVjb2RlVmFsdWVMZW5ndGgoc3RhcnRJbmRleCkgPT0gZmFsc2UpIHsKQEAgLTQyNCwzNSArNDI0LDM1IEBACiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIHJldHVybiBmb3VuZDsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGludCBoZWFkZXJzTGVuZ3RoID0gKGludCkgdW5zaWduZWQzMmJpdDsKKyAgICAgICAgICAgIGludCBoZWFkZXJzTGVuZ3RoID0gKGludCkgbVVuc2lnbmVkMzJiaXQ7CiAgICAgICAgICAgICBtZWRpYVByZWZpeExlbmd0aCA9IGdldERlY29kZWREYXRhTGVuZ3RoKCk7CiAgICAgICAgICAgICBpZiAoZGVjb2RlSW50ZWdlclZhbHVlKHN0YXJ0SW5kZXggKyBtZWRpYVByZWZpeExlbmd0aCkgPT0gdHJ1ZSkgewotICAgICAgICAgICAgICAgIGRhdGFMZW5ndGggKz0gbWVkaWFQcmVmaXhMZW5ndGg7Ci0gICAgICAgICAgICAgICAgaW50IHJlYWRMZW5ndGggPSBkYXRhTGVuZ3RoOwotICAgICAgICAgICAgICAgIHN0cmluZ1ZhbHVlID0gbnVsbDsKKyAgICAgICAgICAgICAgICBtRGF0YUxlbmd0aCArPSBtZWRpYVByZWZpeExlbmd0aDsKKyAgICAgICAgICAgICAgICBpbnQgcmVhZExlbmd0aCA9IG1EYXRhTGVuZ3RoOworICAgICAgICAgICAgICAgIG1TdHJpbmdWYWx1ZSA9IG51bGw7CiAgICAgICAgICAgICAgICAgZXhwYW5kV2VsbEtub3duTWltZVR5cGUoKTsKLSAgICAgICAgICAgICAgICBsb25nIHdlbGxLbm93blZhbHVlID0gdW5zaWduZWQzMmJpdDsKLSAgICAgICAgICAgICAgICBTdHJpbmcgbWltZVR5cGUgPSBzdHJpbmdWYWx1ZTsKLSAgICAgICAgICAgICAgICBpZiAocmVhZENvbnRlbnRQYXJhbWV0ZXJzKHN0YXJ0SW5kZXggKyBkYXRhTGVuZ3RoLAotICAgICAgICAgICAgICAgICAgICAgICAgKGhlYWRlcnNMZW5ndGggLSAoZGF0YUxlbmd0aCAtIG1lZGlhUHJlZml4TGVuZ3RoKSksIDApKSB7Ci0gICAgICAgICAgICAgICAgICAgIGRhdGFMZW5ndGggKz0gcmVhZExlbmd0aDsKLSAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQzMmJpdCA9IHdlbGxLbm93blZhbHVlOwotICAgICAgICAgICAgICAgICAgICBzdHJpbmdWYWx1ZSA9IG1pbWVUeXBlOworICAgICAgICAgICAgICAgIGxvbmcgd2VsbEtub3duVmFsdWUgPSBtVW5zaWduZWQzMmJpdDsKKyAgICAgICAgICAgICAgICBTdHJpbmcgbWltZVR5cGUgPSBtU3RyaW5nVmFsdWU7CisgICAgICAgICAgICAgICAgaWYgKHJlYWRDb250ZW50UGFyYW1ldGVycyhzdGFydEluZGV4ICsgbURhdGFMZW5ndGgsCisgICAgICAgICAgICAgICAgICAgICAgICAoaGVhZGVyc0xlbmd0aCAtIChtRGF0YUxlbmd0aCAtIG1lZGlhUHJlZml4TGVuZ3RoKSksIDApKSB7CisgICAgICAgICAgICAgICAgICAgIG1EYXRhTGVuZ3RoICs9IHJlYWRMZW5ndGg7CisgICAgICAgICAgICAgICAgICAgIG1VbnNpZ25lZDMyYml0ID0gd2VsbEtub3duVmFsdWU7CisgICAgICAgICAgICAgICAgICAgIG1TdHJpbmdWYWx1ZSA9IG1pbWVUeXBlOwogICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgfQogICAgICAgICAgICAgaWYgKGRlY29kZUV4dGVuc2lvbk1lZGlhKHN0YXJ0SW5kZXggKyBtZWRpYVByZWZpeExlbmd0aCkgPT0gdHJ1ZSkgewotICAgICAgICAgICAgICAgIGRhdGFMZW5ndGggKz0gbWVkaWFQcmVmaXhMZW5ndGg7Ci0gICAgICAgICAgICAgICAgaW50IHJlYWRMZW5ndGggPSBkYXRhTGVuZ3RoOworICAgICAgICAgICAgICAgIG1EYXRhTGVuZ3RoICs9IG1lZGlhUHJlZml4TGVuZ3RoOworICAgICAgICAgICAgICAgIGludCByZWFkTGVuZ3RoID0gbURhdGFMZW5ndGg7CiAgICAgICAgICAgICAgICAgZXhwYW5kV2VsbEtub3duTWltZVR5cGUoKTsKLSAgICAgICAgICAgICAgICBsb25nIHdlbGxLbm93blZhbHVlID0gdW5zaWduZWQzMmJpdDsKLSAgICAgICAgICAgICAgICBTdHJpbmcgbWltZVR5cGUgPSBzdHJpbmdWYWx1ZTsKLSAgICAgICAgICAgICAgICBpZiAocmVhZENvbnRlbnRQYXJhbWV0ZXJzKHN0YXJ0SW5kZXggKyBkYXRhTGVuZ3RoLAotICAgICAgICAgICAgICAgICAgICAgICAgKGhlYWRlcnNMZW5ndGggLSAoZGF0YUxlbmd0aCAtIG1lZGlhUHJlZml4TGVuZ3RoKSksIDApKSB7Ci0gICAgICAgICAgICAgICAgICAgIGRhdGFMZW5ndGggKz0gcmVhZExlbmd0aDsKLSAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQzMmJpdCA9IHdlbGxLbm93blZhbHVlOwotICAgICAgICAgICAgICAgICAgICBzdHJpbmdWYWx1ZSA9IG1pbWVUeXBlOworICAgICAgICAgICAgICAgIGxvbmcgd2VsbEtub3duVmFsdWUgPSBtVW5zaWduZWQzMmJpdDsKKyAgICAgICAgICAgICAgICBTdHJpbmcgbWltZVR5cGUgPSBtU3RyaW5nVmFsdWU7CisgICAgICAgICAgICAgICAgaWYgKHJlYWRDb250ZW50UGFyYW1ldGVycyhzdGFydEluZGV4ICsgbURhdGFMZW5ndGgsCisgICAgICAgICAgICAgICAgICAgICAgICAoaGVhZGVyc0xlbmd0aCAtIChtRGF0YUxlbmd0aCAtIG1lZGlhUHJlZml4TGVuZ3RoKSksIDApKSB7CisgICAgICAgICAgICAgICAgICAgIG1EYXRhTGVuZ3RoICs9IHJlYWRMZW5ndGg7CisgICAgICAgICAgICAgICAgICAgIG1VbnNpZ25lZDMyYml0ID0gd2VsbEtub3duVmFsdWU7CisgICAgICAgICAgICAgICAgICAgIG1TdHJpbmdWYWx1ZSA9IG1pbWVUeXBlOwogICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CkBAIC00NjgsMTcgKzQ2OCwxNyBAQAogICAgICAgICBpbnQgdG90YWxSZWFkID0gMDsKIAogICAgICAgICBpZiAobGVmdFRvUmVhZCA+IDApIHsKLSAgICAgICAgICAgIGJ5dGUgbmV4dEJ5dGUgPSB3c3BEYXRhW3N0YXJ0SW5kZXhdOworICAgICAgICAgICAgYnl0ZSBuZXh0Qnl0ZSA9IG1Xc3BEYXRhW3N0YXJ0SW5kZXhdOwogICAgICAgICAgICAgU3RyaW5nIHZhbHVlID0gbnVsbDsKICAgICAgICAgICAgIFN0cmluZyBwYXJhbSA9IG51bGw7CiAgICAgICAgICAgICBpZiAoKG5leHRCeXRlICYgMHg4MCkgPT0gMHgwMCAmJiBuZXh0Qnl0ZSA+IDMxKSB7IC8vIHVudHlwZWQKICAgICAgICAgICAgICAgICBkZWNvZGVUb2tlblRleHQoc3RhcnRJbmRleCk7Ci0gICAgICAgICAgICAgICAgcGFyYW0gPSBzdHJpbmdWYWx1ZTsKLSAgICAgICAgICAgICAgICB0b3RhbFJlYWQgKz0gZGF0YUxlbmd0aDsKKyAgICAgICAgICAgICAgICBwYXJhbSA9IG1TdHJpbmdWYWx1ZTsKKyAgICAgICAgICAgICAgICB0b3RhbFJlYWQgKz0gbURhdGFMZW5ndGg7CiAgICAgICAgICAgICB9IGVsc2UgeyAvLyB0eXBlZAogICAgICAgICAgICAgICAgIGlmIChkZWNvZGVJbnRlZ2VyVmFsdWUoc3RhcnRJbmRleCkpIHsKLSAgICAgICAgICAgICAgICAgICAgdG90YWxSZWFkICs9IGRhdGFMZW5ndGg7Ci0gICAgICAgICAgICAgICAgICAgIGludCB3ZWxsS25vd25QYXJhbWV0ZXJWYWx1ZSA9IChpbnQpIHVuc2lnbmVkMzJiaXQ7CisgICAgICAgICAgICAgICAgICAgIHRvdGFsUmVhZCArPSBtRGF0YUxlbmd0aDsKKyAgICAgICAgICAgICAgICAgICAgaW50IHdlbGxLbm93blBhcmFtZXRlclZhbHVlID0gKGludCkgbVVuc2lnbmVkMzJiaXQ7CiAgICAgICAgICAgICAgICAgICAgIHBhcmFtID0gV0VMTF9LTk9XTl9QQVJBTUVURVJTLmdldCh3ZWxsS25vd25QYXJhbWV0ZXJWYWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgIGlmIChwYXJhbSA9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBwYXJhbSA9ICJ1bmFzc2lnbmVkLzB4IiArIExvbmcudG9IZXhTdHJpbmcod2VsbEtub3duUGFyYW1ldGVyVmFsdWUpOwpAQCAtNDg2LDkgKzQ4Niw5IEBACiAgICAgICAgICAgICAgICAgICAgIC8vIHNwZWNpYWwgY2FzZSBmb3IgdGhlICJRIiBwYXJhbWV0ZXIsIHZhbHVlIGlzIGEgdWludHZhcgogICAgICAgICAgICAgICAgICAgICBpZiAod2VsbEtub3duUGFyYW1ldGVyVmFsdWUgPT0gUV9WQUxVRSkgewogICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRlY29kZVVpbnR2YXJJbnRlZ2VyKHN0YXJ0SW5kZXggKyB0b3RhbFJlYWQpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgdG90YWxSZWFkICs9IGRhdGFMZW5ndGg7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUgPSBTdHJpbmcudmFsdWVPZih1bnNpZ25lZDMyYml0KTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50UGFyYW1ldGVycy5wdXQocGFyYW0sIHZhbHVlKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB0b3RhbFJlYWQgKz0gbURhdGFMZW5ndGg7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUgPSBTdHJpbmcudmFsdWVPZihtVW5zaWduZWQzMmJpdCk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUNvbnRlbnRQYXJhbWV0ZXJzLnB1dChwYXJhbSwgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZWFkQ29udGVudFBhcmFtZXRlcnMoc3RhcnRJbmRleCArIHRvdGFsUmVhZCwgbGVmdFRvUmVhZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLSB0b3RhbFJlYWQsIGFjY3VtdWxhdG9yICsgdG90YWxSZWFkKTsKICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CkBAIC01MDEsMjcgKzUwMSwyNyBAQAogICAgICAgICAgICAgfQogCiAgICAgICAgICAgICBpZiAoZGVjb2RlTm9WYWx1ZShzdGFydEluZGV4ICsgdG90YWxSZWFkKSkgewotICAgICAgICAgICAgICAgIHRvdGFsUmVhZCArPSBkYXRhTGVuZ3RoOworICAgICAgICAgICAgICAgIHRvdGFsUmVhZCArPSBtRGF0YUxlbmd0aDsKICAgICAgICAgICAgICAgICB2YWx1ZSA9IG51bGw7CiAgICAgICAgICAgICB9IGVsc2UgaWYgKGRlY29kZUludGVnZXJWYWx1ZShzdGFydEluZGV4ICsgdG90YWxSZWFkKSkgewotICAgICAgICAgICAgICAgIHRvdGFsUmVhZCArPSBkYXRhTGVuZ3RoOwotICAgICAgICAgICAgICAgIGludCBpbnRWYWx1ZSA9IChpbnQpIHVuc2lnbmVkMzJiaXQ7CisgICAgICAgICAgICAgICAgdG90YWxSZWFkICs9IG1EYXRhTGVuZ3RoOworICAgICAgICAgICAgICAgIGludCBpbnRWYWx1ZSA9IChpbnQpIG1VbnNpZ25lZDMyYml0OwogICAgICAgICAgICAgICAgIHZhbHVlID0gU3RyaW5nLnZhbHVlT2YoaW50VmFsdWUpOwogICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICBkZWNvZGVUb2tlblRleHQoc3RhcnRJbmRleCArIHRvdGFsUmVhZCk7Ci0gICAgICAgICAgICAgICAgdG90YWxSZWFkICs9IGRhdGFMZW5ndGg7Ci0gICAgICAgICAgICAgICAgdmFsdWUgPSBzdHJpbmdWYWx1ZTsKKyAgICAgICAgICAgICAgICB0b3RhbFJlYWQgKz0gbURhdGFMZW5ndGg7CisgICAgICAgICAgICAgICAgdmFsdWUgPSBtU3RyaW5nVmFsdWU7CiAgICAgICAgICAgICAgICAgaWYgKHZhbHVlLnN0YXJ0c1dpdGgoIlwiIikpIHsKICAgICAgICAgICAgICAgICAgICAgLy8gcXVvdGVkIHN0cmluZywgc28gcmVtb3ZlIHRoZSBxdW90ZQogICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IHZhbHVlLnN1YnN0cmluZygxKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9Ci0gICAgICAgICAgICBjb250ZW50UGFyYW1ldGVycy5wdXQocGFyYW0sIHZhbHVlKTsKKyAgICAgICAgICAgIG1Db250ZW50UGFyYW1ldGVycy5wdXQocGFyYW0sIHZhbHVlKTsKICAgICAgICAgICAgIHJldHVybiByZWFkQ29udGVudFBhcmFtZXRlcnMoc3RhcnRJbmRleCArIHRvdGFsUmVhZCwgbGVmdFRvUmVhZCAtIHRvdGFsUmVhZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWNjdW11bGF0b3IgKyB0b3RhbFJlYWQpOwogCiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICBkYXRhTGVuZ3RoID0gYWNjdW11bGF0b3I7CisgICAgICAgICAgICBtRGF0YUxlbmd0aCA9IGFjY3VtdWxhdG9yOwogICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgIH0KICAgICB9CkBAIC01MzQsOCArNTM0LDggQEAKICAgICAgKiBAcmV0dXJuIHRydWUgaWYgYW5kIG9ubHkgaWYgdGhlIG5leHQgYnl0ZSBpcyAweDAwCiAgICAgICovCiAgICAgcHJpdmF0ZSBib29sZWFuIGRlY29kZU5vVmFsdWUoaW50IHN0YXJ0SW5kZXgpIHsKLSAgICAgICAgaWYgKHdzcERhdGFbc3RhcnRJbmRleF0gPT0gMCkgewotICAgICAgICAgICAgZGF0YUxlbmd0aCA9IDE7CisgICAgICAgIGlmIChtV3NwRGF0YVtzdGFydEluZGV4XSA9PSAwKSB7CisgICAgICAgICAgICBtRGF0YUxlbmd0aCA9IDE7CiAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKQEAgLTU0OCwxMSArNTQ4LDExIEBACiAgICAgICogU2V0cyB1bnNpZ25lZDMyYml0IHRvIC0xIGlmIHN0cmluZ1ZhbHVlIGlzIGFscmVhZHkgcG9wdWxhdGVkCiAgICAgICovCiAgICAgcHJpdmF0ZSB2b2lkIGV4cGFuZFdlbGxLbm93bk1pbWVUeXBlKCkgewotICAgICAgICBpZiAoc3RyaW5nVmFsdWUgPT0gbnVsbCkgewotICAgICAgICAgICAgaW50IGJpbmFyeUNvbnRlbnRUeXBlID0gKGludCkgdW5zaWduZWQzMmJpdDsKLSAgICAgICAgICAgIHN0cmluZ1ZhbHVlID0gV0VMTF9LTk9XTl9NSU1FX1RZUEVTLmdldChiaW5hcnlDb250ZW50VHlwZSk7CisgICAgICAgIGlmIChtU3RyaW5nVmFsdWUgPT0gbnVsbCkgeworICAgICAgICAgICAgaW50IGJpbmFyeUNvbnRlbnRUeXBlID0gKGludCkgbVVuc2lnbmVkMzJiaXQ7CisgICAgICAgICAgICBtU3RyaW5nVmFsdWUgPSBXRUxMX0tOT1dOX01JTUVfVFlQRVMuZ2V0KGJpbmFyeUNvbnRlbnRUeXBlKTsKICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgIHVuc2lnbmVkMzJiaXQgPSAtMTsKKyAgICAgICAgICAgIG1VbnNpZ25lZDMyYml0ID0gLTE7CiAgICAgICAgIH0KICAgICB9CiAKQEAgLTU5NCw3ICs1OTQsNyBAQAogICAgICAqLwogICAgIHB1YmxpYyBib29sZWFuIGRlY29kZVhXYXBBcHBsaWNhdGlvbklkKGludCBzdGFydEluZGV4KSB7CiAgICAgICAgIGlmIChkZWNvZGVJbnRlZ2VyVmFsdWUoc3RhcnRJbmRleCkgPT0gdHJ1ZSkgewotICAgICAgICAgICAgc3RyaW5nVmFsdWUgPSBudWxsOworICAgICAgICAgICAgbVN0cmluZ1ZhbHVlID0gbnVsbDsKICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICB9CiAgICAgICAgIHJldHVybiBkZWNvZGVUZXh0U3RyaW5nKHN0YXJ0SW5kZXgpOwpAQCAtNjIyLDcgKzYyMiw3IEBACiAgICAgICAgICAgICAgICAgICAgIGludCBmaWVsZFZhbHVlID0gKGludCkgZ2V0VmFsdWUzMigpOwogCiAgICAgICAgICAgICAgICAgICAgIGlmIChmaWVsZFZhbHVlID09IFBBUkFNRVRFUl9JRF9YX1dBUF9BUFBMSUNBVElPTl9JRCkgewotICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQzMmJpdCA9IGluZGV4ICsgMTsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1VbnNpZ25lZDMyYml0ID0gaW5kZXggKyAxOwogICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9IGVsc2UgewpAQCAtNjQyLDkgKzY0Miw5IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAoTlVMIGNoYXJhY3RlcikKICAgICAgICAgICAgICAgICAgKiAxMjggLSAyNTUgSXQgaXMgYW4gZW5jb2RlZCA3LWJpdCB2YWx1ZTsgdGhpcyBoZWFkZXIgaGFzIG5vIG1vcmUgZGF0YQogICAgICAgICAgICAgICAgICAqLwotICAgICAgICAgICAgICAgIGJ5dGUgdmFsID0gd3NwRGF0YVtpbmRleF07CisgICAgICAgICAgICAgICAgYnl0ZSB2YWwgPSBtV3NwRGF0YVtpbmRleF07CiAgICAgICAgICAgICAgICAgaWYgKDAgPD0gdmFsICYmIHZhbCA8PSBXQVBfUERVX1NIT1JUX0xFTkdUSF9NQVgpIHsKLSAgICAgICAgICAgICAgICAgICAgaW5kZXggKz0gd3NwRGF0YVtpbmRleF0gKyAxOworICAgICAgICAgICAgICAgICAgICBpbmRleCArPSBtV3NwRGF0YVtpbmRleF0gKyAxOwogICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodmFsID09IFdBUF9QRFVfTEVOR1RIX1FVT1RFKSB7CiAgICAgICAgICAgICAgICAgICAgIGlmIChpbmRleCArIDEgPj0gZW5kSW5kZXgpIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgaW5kZXgrKzsKQEAgLTY5NCwyMSArNjk0LDIxIEBACiAgICAgICogVGhlIGRhdGEgbGVuZ3RoIG9mIGxhdGVzdCBvcGVyYXRpb24uCiAgICAgICovCiAgICAgcHVibGljIGludCBnZXREZWNvZGVkRGF0YUxlbmd0aCgpIHsKLSAgICAgICAgcmV0dXJuIGRhdGFMZW5ndGg7CisgICAgICAgIHJldHVybiBtRGF0YUxlbmd0aDsKICAgICB9CiAKICAgICAvKioKICAgICAgKiBUaGUgMzItYml0cyByZXN1bHQgb2YgbGF0ZXN0IG9wZXJhdGlvbi4KICAgICAgKi8KICAgICBwdWJsaWMgbG9uZyBnZXRWYWx1ZTMyKCkgewotICAgICAgICByZXR1cm4gdW5zaWduZWQzMmJpdDsKKyAgICAgICAgcmV0dXJuIG1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Y21kUGFyYW1zLm1DbWREZXQ7CiAgICAgICAgIHN3aXRjaChnZXRDbWRUeXBlKCkpIHsKICAgICAgICAgY2FzZSBTRVRfVVBfTUVOVToKICAgICAgICAgY2FzZSBTRUxFQ1RfSVRFTToKLSAgICAgICAgICAgIG1NZW51ID0gKChTZWxlY3RJdGVtUGFyYW1zKSBjbWRQYXJhbXMpLm1lbnU7CisgICAgICAgICAgICBtTWVudSA9ICgoU2VsZWN0SXRlbVBhcmFtcykgY21kUGFyYW1zKS5tTWVudTsKICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICBjYXNlIERJU1BMQVlfVEVYVDoKICAgICAgICAgY2FzZSBTRVRfVVBfSURMRV9NT0RFX1RFWFQ6CkBAIC02MywzNyArNjMsNDIgQEAKICAgICAgICAgY2FzZSBTRU5EX1NNUzoKICAgICAgICAgY2FzZSBTRU5EX1NTOgogICAgICAgICBjYXNlIFNFTkRfVVNTRDoKLSAgICAgICAgICAgIG1UZXh0TXNnID0gKChEaXNwbGF5VGV4dFBhcmFtcykgY21kUGFyYW1zKS50ZXh0TXNnOworICAgICAgICAgICAgbVRleHRNc2cgPSAoKERpc3BsYXlUZXh0UGFyYW1zKSBjbWRQYXJhbXMpLm1UZXh0TXNnOwogICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIGNhc2UgR0VUX0lOUFVUOgogICAgICAgICBjYXNlIEdFVF9JTktFWToKLSAgICAgICAgICAgIG1JbnB1dCA9ICgoR2V0SW5wdXRQYXJhbXMpIGNtZFBhcmFtcykuaW5wdXQ7CisgICAgICAgICAgICBtSW5wdXQgPSAoKEdldElucHV0UGFyYW1zKSBjbWRQYXJhbXMpLm1JbnB1dDsKICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICBjYXNlIExBVU5DSF9CUk9XU0VSOgotICAgICAgICAgICAgbVRleHRNc2cgPSAoKExhdW5jaEJyb3dzZXJQYXJhbXMpIGNtZFBhcmFtcykuY29uZmlybU1zZzsKKyAgICAgICAgICAgIG1UZXh0TXNnID0gKChMYXVuY2hCcm93c2VyUGFyYW1zKSBjbWRQYXJhbXMpLm1Db25maXJtTXNnOwogICAgICAgICAgICAgbUJyb3dzZXJTZXR0aW5ncyA9IG5ldyBCcm93c2VyU2V0dGluZ3MoKTsKLSAgICAgICAgICAgIG1Ccm93c2VyU2V0dGluZ3MudXJsID0gKChMYXVuY2hCcm93c2VyUGFyYW1zKSBjbWRQYXJhbXMpLnVybDsKLSAgICAgICAgICAgIG1Ccm93c2VyU2V0dGluZ3MubW9kZSA9ICgoTGF1bmNoQnJvd3NlclBhcmFtcykgY21kUGFyYW1zKS5tb2RlOworICAgICAgICAgICAgbUJyb3dzZXJTZXR0aW5ncy51cmwgPSAoKExhdW5jaEJyb3dzZXJQYXJhbXMpIGNtZFBhcmFtcykubVVybDsKKyAgICAgICAgICAgIG1Ccm93c2VyU2V0dGluZ3MubW9kZSA9ICgoTGF1bmNoQnJvd3NlclBhcmFtcykgY21kUGFyYW1zKS5tTW9kZTsKICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICBjYXNlIFBMQVlfVE9ORToKICAgICAgICAgICAgIFBsYXlUb25lUGFyYW1zIHBhcmFtcyA9IChQbGF5VG9uZVBhcmFtcykgY21kUGFyYW1zOwotICAgICAgICAgICAgbVRvbmVTZXR0aW5ncyA9IHBhcmFtcy5zZXR0aW5nczsKLSAgICAgICAgICAgIG1UZXh0TXNnID0gcGFyYW1zLnRleHRNc2c7CisgICAgICAgICAgICBtVG9uZVNldHRpbmdzID0gcGFyYW1zLm1TZXR0aW5nczsKKyAgICAgICAgICAgIG1UZXh0TXNnID0gcGFyYW1zLm1UZXh0TXNnOwogICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIGNhc2UgR0VUX0NIQU5ORUxfU1RBVFVTOgotICAgICAgICAgICAgbVRleHRNc2cgPSAoKENhbGxTZXR1cFBhcmFtcykgY21kUGFyYW1zKS5jb25maXJtTXNnOworICAgICAgICAgICAgbVRleHRNc2cgPSAoKENhb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SVNUOgorICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIH0KICAgICB9CkBAIC0xMTcsOSArMTIyLDEyIEBACiAgICAgICAgICAgICBtQ2FsbFNldHRpbmdzLmNvbmZpcm1Nc2cgPSBpbi5yZWFkUGFyY2VsYWJsZShudWxsKTsKICAgICAgICAgICAgIG1DYWxsU2V0dGluZ3MuY2FsbE1zZyA9IGluLnJlYWRQYXJjZWxhYmxlKG51bGwpOwogICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHdyaXRlVG9QYXJjZWwoUGFyY2VsIGRlc3QsIGludCBmbGFncykgewogICAgICAgICBkZXN0LndyaXRlUGFyY2VsYWJsZShtQ21kRGV0LCAwKTsKICAgICAgICAgZGVzdC53cml0ZVBhcmNlbGFibGUobVRleHRNc2csIDApOwpAQCAtMTM3LDE5ICsxNDUsMjQgQEAKICAgICAgICAgICAgIGRlc3Qud3JpdGVQYXJjZWxhYmxlKG1DYWxsU2V0dGluZ3MuY29uZmlybU1zZywgMCk7CiAgICAgICAgICAgICBkZXN0LndyaXRlUGFyY2VsYWJsZShtQ2FsbFNldHRpbmdzLmNhbGxNc2csIDApOwogICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogICAgIH0KIAogICAgIHB1YmxpYyBzdGF0aWMgZmluYWwgUGFyY2VsYWJsZS5DcmVhdG9yPENhdENtZE1lc3NhZ2U+IENSRUFUT1IgPSBuZXcgUGFyY2VsYWJsZS5DcmVhdG9yPENhdENtZE1lc3NhZ2U+KCkgeworICAgICAgICBAT3ZlcnJpZGUKICAgICAgICAgcHVibGljIENhdENtZE1lc3NhZ2UgY3JlYXRlRnJvbVBhcmNlbChQYXJjZWwgaW4pI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gICAgU3RyaW5nIHVzZXJzSW5wdXQgID0gbnVsbDsKLSAgICAgICAgYm9vbGVhbiB1c2Vyc1llc05vU2VsZWN0aW9uID0gZmFsc2U7Ci0gICAgICAgIGJvb2xlYW4gdXNlcnNDb25maXJtID0gZmFsc2U7Ci0gICAgICAgIGJvb2xlYW4gaW5jbHVkZUFkZGl0aW9uYWxJbmZvID0gZmFsc2U7Ci0gICAgICAgIGludCBhZGRpdGlvbmFsSW5mbyA9IDA7CisgICAgICAgIENvbW1hbmREZXRhaWxzIG1DbWREZXQgPSBudWxsOworICAgICAgICBSZXN1bHRDb2RlIG1SZXNDb2RlICA9IFJlc3VsdENvZGUuT0s7CisgICAgICAgIGludCBtVXNlcnNNZW51U2VsZWN0aW9uID0gMDsKKyAgICAgICAgU3RyaW5nIG1Vc2Vyc0lucHV0ICA9IG51bGw7CisgICAgICAgIGJvb2xlYW4gbVVzZXJzWWVzTm9TZWxlY3Rpb24gPSBmYWxzZTsKKyAgICAgICAgYm9vbGVhbiBtVXNlcnNDb25maXJtID0gZmFsc2U7CisgICAgICAgIGJvb2xlYW4gbUluY2x1ZGVBZGRpdGlvbmFsSW5mbyA9IGZhbHNlOworICAgICAgICBpbnQgbUFkZGl0aW9uYWxJbmZvID0gMDsKICAgICAgICAgcHVibGljIENhdFJlc3BvbnNlTWVzc2FnZShDYXRDbWRNZXNzYWdlIGNtZE1zZykgewotICAgICAgICAgICAgdGhpcy5jbWREZXQgPSBjbWRNc2cubUNtZERldDsKKyAgICAgICAgICAgIG1DbWREZXQgPSBjbWRNc2cubUNtZERldDsKICAgICAgICAgfQogCiAgICAgICAgIHB1YmxpYyB2b2lkIHNldFJlc3VsdENvZGUoUmVzdWx0Q29kZSByZXNDb2RlKSB7Ci0gICAgICAgICAgICB0aGlzLnJlc0NvZGUgPSByZXNDb2RlOworICAgICAgICAgICAgbVJlc0NvZGUgPSByZXNDb2RlOwogICAgICAgICB9CiAKICAgICAgICAgcHVibGljIHZvaWQgc2V0TWVudVNlbGVjdGlvbihpbnQgc2VsZWN0aW9uKSB7Ci0gICAgICAgICAgICB0aGlzLnVzZXJzTWVudVNlbGVjdGlvbiA9IHNlbGVjdGlvbjsKKyAgICAgICAgICAgIG1Vc2Vyc01lbnVTZWxlY3Rpb24gPSBzZWxlY3Rpb247CiAgICAgICAgIH0KIAogICAgICAgICBwdWJsaWMgdm9pZCBzZXRJbnB1dChTdHJpbmcgaW5wdXQpIHsKLSAgICAgICAgICAgIHRoaXMudXNlcnNJbnB1dCA9IGlucHV0OworICAgICAgICAgICAgbVVzZXJzSW5wdXQgPSBpbnB1dDsKICAgICAgICAgfQogCiAgICAgICAgIHB1YmxpYyB2b2lkIHNldFllc05vKGJvb2xlYW4geWVzTm8pIHsKLSAgICAgICAgICAgIHVzZXJzWWVzTm9TZWxlY3Rpb24gPSB5ZXNObzsKKyAgICAgICAgICAgIG1Vc2Vyc1llc05vU2VsZWN0aW9uID0geWVzTm87CiAgICAgICAgIH0KIAogICAgICAgICBwdWJsaWMgdm9pZCBzZXRDb25maXJtYXRpb24oYm9vbGVhbiBjb25maXJtKSB7Ci0gICAgICAgICAgICB1c2Vyc0NvbmZpcm0gPSBjb25maXJtOworICAgICAgICAgICAgbVVzZXJzQ29uZmlybSA9IGNvbmZpcm07CiAgICAgICAgIH0KIAogICAgICAgICBwdWJsaWMgdm9pZCBzZXRBZGRpdGlvbmFsSW5mbyhpbnQgaW5mbykgewotICAgICAgICAgICAgdGhpcy5pbmNsdWRlQWRkaXRpb25hbEluZm8gPSB0cnVlOwotICAgICAgICAgICAgdGhpcy5hZGRpdGlvbmFsSW5mbyA9IGluZm87CisgICAgICAgICAgICBtSW5jbHVkZUFkZGl0aW9uYWxJbmZvID0gdHJ1ZTsKKyAgICAgICAgICAgIG1BZGRpdGlvbmFsSW5mbyA9IGluZm87CiAgICAgICAgIH0KIAogICAgICAgICBDb21tYW5kRGV0YWlscyBnZXRDbWREZXRhaWxzKCkgewotICAgICAgICAgICAgcmV0dXJuIGN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W5hbGl6ZWQiKTsKICAgICB9CkBAIC0xODYsNyArMTg0LDcgQEAKICAgICAgICAgICAgICAgICAgICAgLy8gZm9yIHByb2FjdGl2ZSBjb21tYW5kcyB0aGF0IGNvdWxkbid0IGJlIGRlY29kZWQKICAgICAgICAgICAgICAgICAgICAgLy8gc3VjY2Vzc2Z1bGx5IHJlc3BvbmQgd2l0aCB0aGUgY29kZSBnZW5lcmF0ZWQgYnkgdGhlCiAgICAgICAgICAgICAgICAgICAgIC8vIG1lc3NhZ2UgZGVjb2Rlci4KLSAgICAgICAgICAgICAgICAgICAgc2VuZFRlcm1pbmFsUmVzcG9uc2UoY21kUGFyYW1zLmNtZERldCwgcmlsTXNnLm1SZXNDb2RlLAorICAgICAgICAgICAgICAgICAgICBzZW5kVGVybWluYWxSZXNwb25zZShjbWRQYXJhbXMubUNtZERldCwgcmlsTXNnLm1SZXNDb2RlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZhbHNlLCAwLCBudWxsKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CkBAIC0yMjYsNDMgKzIyNCw0MyBAQAogICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgIG1NZW51Q21kID0gY21kTXNnOwogICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBzZW5kVGVybWluYWxSZXNwb25zZShjbWRQYXJhbXMuY21kRGV0LCBSZXN1bHRDb2RlLk9LLCBmYWxzZSwgMCwgbnVsbCk7CisgICAgICAgICAgICAgICAgc2VuZFRlcm1pbmFsUmVzcG9uc2UoY21kUGFyYW1zLm1DbWREZXQsIFJlc3VsdENvZGUuT0ssIGZhbHNlLCAwLCBudWxsKTsKICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIGNhc2UgRElTUExBWV9URVhUOgogICAgICAgICAgICAgICAgIC8vIHdoZW4gYXBwbGljYXRpb24gaXMgbm90IHJlcXVpcmVkIHRvIHJlc3BvbmQsIHNlbmQgYW4gaW1tZWRpYXRlIHJlc3BvbnNlLgogICAgICAgICAgICAgICAgIGlmICghY21kTXNnLmdlVGV4dE1lc3NhZ2UoKS5yZXNwb25zZU5lZWRlZCkgewotICAgICAgICAgICAgICAgICAgICBzZW5kVGVybWluYWxSZXNwb25zZShjbWRQYXJhbXMuY21kRGV0LCBSZXN1bHRDb2RlLk9LLCBmYWxzZSwgMCwgbnVsbCk7CisgICAgICAgICAgICAgICAgICAgIHNlbmRUZXJtaW5hbFJlc3BvbnNlKGNtZFBhcmFtcy5tQ21kRGV0LCBSZXN1bHRDb2RlLk9LLCBmYWxzZSwgMCwgbnVsbCk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgY2FzZSBSRUZSRVNIOgogICAgICAgICAgICAgICAgIC8vIE1FIHNpZGUgb25seSBoYW5kbGVzIHJlZnJlc2ggY29tbWFuZHMgd2hpY2ggbWVhbnQgdG8gcmVtb3ZlIElETEUKICAgICAgICAgICAgICAgICAvLyBNT0RFIFRFWFQuCi0gICAgICAgICAgICAgICAgY21kUGFyYW1zLmNtZERldC50eXBlT2ZDb21tYW5kID0gQ29tbWFuZFR5cGUuU0VUX1VQX0lETEVfTU9ERV9URVhULnZhbHVlKCk7CisgICAgICAgICAgICAgICAgY21kUGFyYW1zLm1DbWREZXQudHlwZU9mQ29tbWFuZCA9IENvbW1hbmRUeXBlLlNFVF9VUF9JRExFX01PREVfVEVYVC52YWx1ZSgpOwogICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgY2FzZSBTRVRfVVBfSURMRV9NT0RFX1RFWFQ6Ci0gICAgICAgICAgICAgICAgc2VuZFRlcm1pbmFsUmVzcG9uc2UoY21kUGFyYW1zLmNtZERldCwgUmVzdWx0Q29kZS5PSywgZmFsc2UsIDAsIG51bGwpOworICAgICAgICAgICAgICAgIHNlbmRUZXJtaW5hbFJlc3BvbnNlKGNtZFBhcmFtcy5tQ21kRGV0LCBSZXN1bHRDb2RlLk9LLCBmYWxzZSwgMCwgbnVsbCk7CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICBjYXNlIFBST1ZJREVfTE9DQUxfSU5GT1JNQVRJT046CiAgICAgICAgICAgICAgICAgUmVzcG9uc2VEYXRhIHJlc3A7Ci0gICAgICAgICAgICAgICAgc3dpdGNoIChjbWRQYXJhbXMuY21kRGV0LmNvbW1hbmRRdWFsaWZpZXIpIHsKKyAgICAgICAgICAgICAgICBzd2l0Y2ggKGNtZFBhcmFtcy5tQ21kRGV0LmNvbW1hbmRRdWFsaWZpZXIpIHsKICAgICAgICAgICAgICAgICAgICAgY2FzZSBDb21tYW5kUGFyYW1zRmFjdG9yeS5EVFRaX1NFVFRJTkc6CiAgICAgICAgICAgICAgICAgICAgICAgICByZXNwID0gbmV3IERUVFpSZXNwb25zZURhdGEobnVsbCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBzZW5kVGVybWluYWxSZXNwb25zZShjbWRQYXJhbXMuY21kRGV0LCBSZXN1bHRDb2RlLk9LLCBmYWxzZSwgMCwgcmVzcCk7CisgICAgICAgICAgICAgICAgICAgICAgICBzZW5kVGVybWluYWxSZXNwb25zZShjbWRQYXJhbXMubUNtZERldCwgUmVzdWx0Q29kZS5PSywgZmFsc2UsIDAsIHJlc3ApOwogICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgIGNhc2UgQ29tbWFuZFBhcmFtc0ZhY3RvcnkuTEFOR1VBR0VfU0VUVElORzoKICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3AgPSBuZXcgTGFuZ3VhZ2VSZXNwb25zZURhdGEoTG9jYWxlLmdldERlZmF1bHQoKS5nZXRMYW5ndWFnZSgpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIHNlbmRUZXJtaW5hbFJlc3BvbnNlKGNtZFBhcmFtcy5jbWREZXQsIFJlc3VsdENvZGUuT0ssIGZhbHNlLCAwLCByZXNwKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHNlbmRUZXJtaW5hbFJlc3BvbnNlKGNtZFBhcmFtcy5tQ21kRGV0LCBSZXN1bHRDb2RlLk9LLCBmYWxzZSwgMCwgcmVzcCk7CiAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKLSAgICAgICAgICAgICAgICAgICAgICAgIHNlbmRUZXJtaW5hbFJlc3BvbnNlKGNtZFBhcmFtcy5jbWREZXQsIFJlc3VsdENvZGUuT0ssIGZhbHNlLCAwLCBudWxsKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHNlbmRUZXJtaW5hbFJlc3BvbnNlKGNtZFBhcmFtcy5tQ21kRGV0LCBSZXN1bHRDb2RlLk9LLCBmYWxzZSwgMCwgbnVsbCk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIC8vIE5vIG5lZWQgdG8gc3RhcnQgU1RLIGFwcCBoZXJlLgogICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgIGNhc2UgTEFVTkNIX0JST1dTRVI6Ci0gICAgICAgICAgICAgICAgaWYgKCgoKExhdW5jaEJyb3dzZXJQYXJhbXMpIGNtZFBhcmFtcykuY29uZmlybU1zZy50ZXh0ICE9IG51bGwpCi0gICAgICAgICAgICAgICAgICAgICAgICAmJiAoKChMYXVuY2hCcm93c2VyUGFyYW1zKSBjbWRQYXJhbXMpLmNvbmZpcm1Nc2cudGV4dC5lcXVhbHMoU1RLX0RFRkFVTFQpKSkgeworICAgICAgICAgICAgICAgIGlmICgoKChMYXVuY2hCcm93c2VyUGFyYW1zKSBjbWRQYXJhbXMpLm1Db25maXJtTXNnLnRleHQgIT0gbnVsbCkKKyAgICAgICAgICAgICAgICAgICAgICAgICYmICgoKExhdW5jaEJyb3dzZXJQYXJhbXMpIGNtZFBhcmFtcykubUNvbmZpcm1Nc2cudGV4dC5lcXVhbHMoU1RLX0RFRkFVTFQpKSkgewogICAgICAgICAgICAgICAgICAgICBtZXNzYWdlID0gbUNvbnRleHQuZ2V0VGV4dChjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5sYXVuY2hCcm93c2VyRGVmYXVsdCk7Ci0gICAgICAgICAgICAgICAgICAgICgoTGF1bmNoQnJvd3NlclBhcmFtcykgY21kUGFyYW1zKS5jb25maXJtTXNnLnRleHQgPSBtZXNzYWdlLnRvU3RyaW5nKCk7CisgICAgICAgICAgICAgICAgICAgICgoTGF1bmNoQnJvd3NlclBhcmFtcykgY21kUGFyYW1zKS5tQ29uZmlybU1zZy50ZXh0ID0gbWVzc2FnZS50b1N0cmluZygpOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIGNhc2UgU0VMRUNUX0lURU06CkBAIC0yNzMsMTkgKzI3MSwxOSBAQAogICAgICAgICAgICAgY2FzZSBTRU5EX1NNUzoKICAgICAgICAgICAgIGNhc2UgU0VORF9TUzoKICAgICAgICAgICAgIGNhc2UgU0VORF9VU1NEOgotICAgICAgICAgICAgICAgIGlmICgoKChEaXNwbGF5VGV4dFBhcmFtcyljbWRQYXJhbXMpLnRleHRNc2cudGV4dCAhPSBudWxsKQotICAgICAgICAgICAgICAgICAgICAgICAgJiYgKCgoRGlzcGxheVRleHRQYXJhbXMpY21kUGFyYW1zKS50ZXh0TXNnLnRleHQuZXF1YWxzKFNUS19ERUZBVUxUKSkpIHsKKyAgICAgICAgICAgICAgICBpZiAoKCgoRGlzcGxheVRleHRQYXJhbXMpY21kUGFyYW1zKS5tVGV4dE1zZy50ZXh0ICE9IG51bGwpCisgICAgICAgICAgICAgICAgICAgICAgICAmJiAoKChEaXNwbGF5VGV4dFBhcmFtcyljbWRQYXJhbXMpLm1UZXh0TXNnLnRleHQuZXF1YWxzKFNUS19ERUZBVUxUKSkpIHsKICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZSA9IG1Db250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuc2VuZGluZyk7Ci0gICAgICAgICAgICAgICAgICAgICgoRGlzcGxheVRleHRQYXJhbXMpY21kUGFyYW1zKS50ZXh0TXNnLnRleHQgPSBtZXNzYWdlLnRvU3RyaW5nKCk7CisgICAgICAgICAgICAgICAgICAgICgoRGlzcGxheVRleHRQYXJhbXMpY21kUGFyYW1zKS5tVGV4dE1zZy50ZXh0ID0gbWVzc2FnZS50b1N0cmluZygpOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIGNhc2UgUExBWV9UT05FOgogICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgY2FzZSBTRVRfVVBfQ0FMTDoKLSAgICAgICAgICAgICAgICBpZiAoKCgoQ2FsbFNldHVwUGFyYW1zKSBjbWRQYXJhbXMpLmNvbmZpcm1Nc2cudGV4dCAhPSBudWxsKQotICAgICAgICAgICAgICAgICAgICAgICAgJiYgKCgoQ2FsbFNldHVwUGFyYW1zKSBjbWRQYXJhbXMpLmNvbmZpcm1Nc2cudGV4dC5lcXVhbHMoU1RLX0RFRkFVTFQpKSkgeworICAgICAgICAgICAgICAgIGlmICgoKChDYWxsU2V0dXBQYXJhbXMpIGNtZFBhcmFtcykubUNvbmZpcm1Nc2cudGV4dCAhPSBudWxsKQorICAgICAgICAgICAgICAgICAgICAgICAgJiYgKCgoQ2FsbFNldHVwUGFyYW1zKSBjbWRQYXJhbXMpLm1Db25maXJtTXNnLnRleHQuZXF1YWxzKFNUS19ERUZBVUxUKSkpIHsKICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZSA9IG1Db250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuU2V0dXBDYWxsRGVmYXVsdCk7Ci0gICAgICAgICAgICAgICAgICAgICgoQ2FsbFNldHVwUGFyYW1zKSBjbWRQYXJhbXMpLmNvbmZpcm1Nc2cudGV4dCA9IG1lc3NhZ2UudG9TdHJpbmcoKTsKKyAgICAgICAgICAgICAgICAgICAgKChDYWxsU2V0dXBQYXJhbXMpIGNtZFBhcmFtcykubUNvbmZpcm1Nc2cudGV4dCA9IG1lc3NhZ2UudG9TdHJpbmcoKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICBjYXNlIE9QRU5fQ0hBTk5FTDoKQEAgLTI5MywxMSArMjkxLDExIEBACiAgICAgICAgICAgICBjYXNlIFJFQ0VJVkVfREFUQToKICAgICAgICAgICAgIGNhc2UgU0VORF9EQVRBOgogICAgICAgICAgICAgICAgIEJJUENsaWVudFBhcmFtcyBjbWQgPSAoQklQQ2xpZW50UGFyYW1zKSBjbWRQYXJhbXM7Ci0gICAgICAgICAgICAgICAgaWYgKGNtZC5iSGFzQWxwaGFJZCAmJiAoY21kLnRleHRNc2cudGV4dCA9PSBudWxsKSkgeworICAgICAgICAgICAgICAgIGlmIChjbWQubUhhc0FscGhhSWQgJiYgKGNtZC5tVGV4dE1zZy50ZXh0ID09IG51bGwpKSB7CiAgICAgICAgICAgICAgICAgICAgIENhdExvZy5kKHRoaXMsICJjbWQgIiArIGNtZFBhcmFtcy5nZXRDb21tYW5kVHlwZSgpICsgIiB3aXRoIG51bGwgYWxwaGEgaWQiKTsKICAgICAgICAgICAgICAgICAgICAgLy8gSWYgYWxwaGEgbGVuZ3RoIGlzIHplcm8sIHdlIGp1c3QgcmVzcG9uZCB3aXRoIE9LLgogICAgICAgICAgICAgICAgICAgICBpZiAoaXNQcm9hY3RpdmVDbWQpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIHNlbmRUZXJtaW5hbFJlc3BvbnNlKGNtZFBhcmFtcy5jbWREZXQsIFJlc3VsdENvZGUuT0ssIGZhbHNlLCAwLCBudWxsKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHNlbmRUZXJtaW5hbFJlc3BvbnNlKGNtZFBhcmFtcy5tQ21kRGV0LCBSZXN1bHRDb2RlLk9LLCBmYWxzZSwgMCwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgIH0KQEAgLTMwNSw3ICszMDMsNyBAQAogICAgICAgICAgICAgICAgIGlmICghbVN0a0FwcEluc3RhbGxlZCkgewogICAgICAgICAgICAgICAgICAgICBDYXRMb2cuZCh0aGlzLCAiTm8gU1RLIGFwcGxpY2F0aW9uIGZvdW5kLiIpOwogICAgICAgICAgICAgICAgICAgICBpZiAoaXNQcm9hY3RpdmVDbWQpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIHNlbmRUZXJtaW5hbFJlc3BvbnNlKGNtZFBhcmFtcy5jbWREZXQsCisgICAgICAgICAgICAgICAgICAgICAgICBzZW5kVGVybWluYWxSZXNwb25zZShjbWRQYXJhbXMubUNtZERldCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFJlc3VsdENvZGUuQkVZT05EX1RFUk1JTkFMX0NBUEFCSUxJVFksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmYWxzZSwgMCwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CkBAIC0zMjEsNyArMzE5LDcgQEAKICAgICAgICAgICAgICAgICAgICAgKChjbWRQYXJhbXMuZ2V0Q29tbWFuZFR5cGUoKSA9PSBDb21tYW5kVHlwZS5DTE9TRV9DSEFOTkVMKSB8fAogICAgICAgICAgICAgICAgICAgICAgKGNtZFBhcmFtcy5nZXRDb21tYW5kVHlwZSgpID09IENvbW1hbmRUeXBlLlJFQ0VJVkVfREFUQSkgfHwKICAgICAgICAgICAgICAgICAgICAgIChjbWRQYXJhbXMuZ2V0Q29tbWFuZFR5cGUoKSA9PSBDb21tYW5kVHlwZS5TRU5EX0RBVEEpKSkgewotICAgICAgICAgIC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pbnQgbGVuID0gcmF3RGF0YS5sZW5ndGggLSAyOyAvLyBtaW51cyAodGFnICsgbGVuZ3RoKQotICAgICAgICByYXdEYXRhWzFdID0gKGJ5dGUpIGxlbjsKLQotICAgICAgICBTdHJpbmcgaGV4U3RyaW5nID0gSWNjVXRpbHMuYnl0ZXNUb0hleFN0cmluZyhyYXdEYXRhKTsKLQotICAgICAgICBtQ21kSWYuc2VuZEVudmVsb3BlKGhleFN0cmluZywgbnVsbCk7Ci0gICAgfQotCiAgICAgLyoqCiAgICAgICogVXNlZCBmb3IgaW5zdGFudGlhdGluZy91cGRhdGluZyB0aGUgU2VydmljZSBmcm9tIHRoZSBHc21QaG9uZSBvciBDZG1hUGhvbmUgY29uc3RydWN0b3IuCiAgICAgICoKICAgICAgKiBAcGFyYW0gY2kgQ29tbWFuZHNJbnRlcmZhY2Ugb2JqZWN0Ci0gICAgICogQHBhcmFtIGlyIEljY1JlY29yZHMgb2JqZWN0CiAgICAgICogQHBhcmFtIGNvbnRleHQgcGhvbmUgYXBwIGNvbnRleHQKLSAgICAgKiBAcGFyYW0gZmggSWNjIGZpbGUgaGFuZGxlcgogICAgICAqIEBwYXJhbSBpYyBJY2MgY2FyZAogICAgICAqIEByZXR1cm4gVGhlIG9ubHkgU2VydmljZSBvYmplY3QgaW4gdGhlIHN5c3RlbQogICAgICAqLwpAQCAtNjU5LDE4ICs2MTIsMTkgQEAKICAgICAgICAgfQogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBzeW5jaHJvbml6ZWQgdm9pZCBvbkNtZFJlc3BvbnNlKENhdFJlc3BvbnNlTWVzc2FnZSByZXNNc2cpIHsKICAgICAgICAgaWYgKHJlc01zZyA9PSBudWxsKSB7CiAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgIH0KICAgICAgICAgLy8gcXVldWUgYSByZXNwb25zZSBtZXNzYWdlLgotICAgICAgICBNZXNzYWdlIG1zZyA9IHRoaXMub2J0YWluTWVzc2FnZShNU0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SkgewogICAgICAgICAgICAgY2FzZSBTRVRfVVBfTUVOVToKLSAgICAgICAgICAgICAgICBoZWxwUmVxdWlyZWQgPSByZXNNc2cucmVzQ29kZSA9PSBSZXN1bHRDb2RlLkhFTFBfSU5GT19SRVFVSVJFRDsKLSAgICAgICAgICAgICAgICBzZW5kTWVudVNlbGVjdGlvbihyZXNNc2cudXNlcnNNZW51U2VsZWN0aW9uLCBoZWxwUmVxdWlyZWQpOworICAgICAgICAgICAgICAgIGhlbHBSZXF1aXJlZCA9IHJlc01zZy5tUmVzQ29kZSA9PSBSZXN1bHRDb2RlLkhFTFBfSU5GT19SRVFVSVJFRDsKKyAgICAgICAgICAgICAgICBzZW5kTWVudVNlbGVjdGlvbihyZXNNc2cubVVzZXJzTWVudVNlbGVjdGlvbiwgaGVscFJlcXVpcmVkKTsKICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICBjYXNlIFNFTEVDVF9JVEVNOgotICAgICAgICAgICAgICAgIHJlc3AgPSBuZXcgU2VsZWN0SXRlbVJlc3BvbnNlRGF0YShyZXNNc2cudXNlcnNNZW51U2VsZWN0aW9uKTsKKyAgICAgICAgICAgICAgICByZXNwID0gbmV3IFNlbGVjdEl0ZW1SZXNwb25zZURhdGEocmVzTXNnLm1Vc2Vyc01lbnVTZWxlY3Rpb24pOwogICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgY2FzZSBHRVRfSU5QVVQ6CiAgICAgICAgICAgICBjYXNlIEdFVF9JTktFWToKQEAgLTczNiwyNCArNjkwLDI2IEBACiAgICAgICAgICAgICAgICAgICAgIC8vIHdoZW4gaGVscCBpcyByZXF1ZXN0ZWQgdGhlcmUgaXMgbm8gbmVlZCB0byBzZW5kIHRoZSB0ZXh0CiAgICAgICAgICAgICAgICAgICAgIC8vIHN0cmluZyBvYmplY3QuCiAgICAgICAgICAgICAgICAgICAgIGlmICghaGVscFJlcXVpcmVkKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICByZXNwID0gbmV3IEdldElua2V5SW5wdXRSZXNwb25zZURhdGEocmVzTXNnLnVzZXJzSW5wdXQsCisgICAgICAgICAgICAgICAgICAgICAgICByZXNwID0gbmV3IEdldElua2V5SW5wdXRSZXNwb25zZURhdGEocmVzTXNnLm1Vc2Vyc0lucHV0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnB1dC51Y3MyLCBpbnB1dC5wYWNrZWQpOwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgcmVzcCA9IG5ldyBHZXRJbmtleUlucHV0UmVzcG9uc2VEYXRhKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc01zZy51c2Vyc1llc05vU2VsZWN0aW9uKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNNc2cubVVzZXJzWWVzTm9TZWxlY3Rpb24pOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIGNhc2UgRElTUExBWV9URVhUOgogICAgICAgICAgICAgY2FzZSBMQVVOQ0hfQlJPV1NFUjoKICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIGNhc2UgU0VUX1VQX0NBTEw6Ci0gICAgICAgICAgICAgICAgbUNtZElmLmhhbmRsZUNhbGxTZXR1cFJlcXVlc3RGcm9tU2ltKHJlc01zZy51c2Vyc0NvbmZpcm0sIG51bGwpOworICAgICAgICAgICAgICAgIG1DbWRJZi5oYW5kbGVDYWxsU2V0dXBSZXF1ZXN0RnJvbVNpbShyZXNNc2cubVVzZXJzQ29uZmlybSwgbnVsbCk7CiAgICAgICAgICAgICAgICAgLy8gTm8gbmVlZCB0byBzZW5kIHRlcm1pbmFsIHJlc3BvbnNlIGZvciBTRVQgVVAgQ0FMTC4gVGhlIHVzZXIncwogICAgICAgICAgICAgICAgIC8vIGNvbmZpcm1hdGlvbiByZXN1bHQgaXMgc2VuZCBiYWNrIHVzaW5nIGEgZGVkaWNhdGVkIHJpbCBtZXNzYWdlCiAgICAgICAgICAgICAgICAgLy8gaW52b2tlZCBieSB0aGUgQ29tbWFuZEludGVyZmFjZSBjYWxsIGFib3ZlLgogICAgICAgICAgICAgICAgIG1DdXJybnRDbWQgPSBudWxsOwogICAgICAgICAgICAgICAgIHJldHVybjsKKyAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBicmVhazsKICAgICAgICAgY2FzZSBCQUNLV0FSRF9NT1ZFX0JZX1VTRVI6CkBAIC03NzcsOCArNzMzLDggQEAKICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgfQotICAgICAgICBzZW5kVGVybWluYWxSZXNwb25zZShjbWREZXQsIHJlc01zZy5yZXNDb2RlLCByZXNNc2cuaW5jbHVkZUFkZGl0aW9uYWxJbmZvLAotICAgICAgICAgICAgICAgIHJlc01zZy5hZGRpdGlvbmFsSW5mbywgcmVzcCk7CisgICAgICAgIHNlbmRUZXJtaW5hbFJlc3BvbnNlKGNtZERldCwgcmVzTXNnLm1SZXNDb2RlLCByZXNNc2cubUluY2x1ZGVBZGRpdGlvbmFsSW5mbywKKyAgICAgICAgICAgICAgICByZXNNc2cubUFkZGl0aW9uYWxJbmZvLCByZXNwKTsKICAgICAgICAgbUN1cnJudENtZCA9IG51bGw7CiAgICAgfQogCmRpZmYgLS1naXQgYS9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvY2F0L0NvbW1hbmREZXRhaWxzLmphdmEgYi9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvY2F0L0NvbW1hbmREZXRhaWxzLmphdmEKaW5kZXggM2U3ZjcyMi4uYWFhOWQ2OCAxMDA2NDQKLS0tIGEvc3JjL2phdmEvY29tL2FuZHJvaWQv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CBQYXJjZWxhYmxlLkNyZWF0b3I8Q29tbWFuZERldGFpbHM+IENSRUFUT1IgPQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXcgUGFyY2VsYWJsZS5DcmVhdG9yPENvbW1hbmREZXRhaWxzPigpIHsKKyAgICAgICAgQE92ZXJyaWRlCiAgICAgICAgIHB1YmxpYyBDb21tYW5kRGV0YWlscyBjcmVhdGVGcm9tUGFyY2VsKFBhcmNlbCBpbikgewogICAgICAgICAgICAgcmV0dXJuIG5ldyBDb21tYW5kRGV0YWlscyhpbik7CiAgICAgICAgIH0KIAorICAgICAgICBAT3ZlcnJpZGUKICAgICAgICAgcHVibGljIENvbW1hbmREZXRhaWxzW10gbmV3QXJyYXkoaW50IHNpemUpIHsKICAgICAgICAgICAgIHJldHVybiBuZXcgQ29tbWFuZERldGFpbHNbc2l6ZV07CiAgICAgICAgIH0KICAgICB9OwogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGludCBkZXNjcmliZUNvbnRlbnRzKCkgewogICAgICAgICByZXR1cm4gMDsKICAgICB9CkBAIC04OSw2ICs5NCw3IEBACiAgICAgcHVibGljIGludCBzb3VyY2VJZDsKICAgICBwdWJsaWMgaW50IGRlc3RpbmF0aW9uSWQ7CiAKKyAgICBAT3ZlcnJpZGUKICAgICBDb21wcmVoZW5zaW9uVGx2VGFnIGdldFRhZygpIHsKICAgICAgICAgcmV0dXJuIENvbXByZWhlbnNpb25UbHZUYWcuREVWSUNFX0lERU5USVRJRVM7CiAgICAgfQpAQCAtOTksNiArMTA1LDcgQEAKICAgICBpbnQgcmVjb3JkTnVtYmVyOwogICAgIGJvb2xlYW4gc2VsZkV4cGxhbmF0b3J5OwogCisgICAgQE92ZXJyaWRlCiAgICAgQ29tcHJlaGVuc2lvblRsdlRhZyBnZXRUYWcoKSB7CiAgICAgICAgIHJldHVybiBDb21wcmVoZW5zaW9uVGx2VGFnLklDT05fSUQ7CiAgICAgfQpAQCAtMTA5LDYgKzExNi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yAgICAgICAgcmV0dXJuIEFwcEludGVyZmFjZS5Db21tYW5kVHlwZS5mcm9tSW50KG1DbWREZXQudHlwZU9mQ29tbWFuZCk7CiAgICAgfQogCiAgICAgYm9vbGVhbiBzZXRJY29uKEJpdG1hcCBpY29uKSB7IHJldHVybiB0cnVlOyB9CiAKICAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgU3RyaW5nIHRvU3RyaW5nKCkgewotICAgICAgICByZXR1cm4gY21kRGV0LnRvU3RyaW5nKCk7CisgICAgICAgIHJldHVybiBtQ21kRGV0LnRvU3RyaW5nKCk7CiAgICAgfQogfQogCiBjbGFzcyBEaXNwbGF5VGV4dFBhcmFtcyBleHRlbmRzIENvbW1hbmRQYXJhbXMgewotICAgIFRleHRNZXNzYWdlIHRleHRNc2c7CisgICAgVGV4dE1lc3NhZ2UgbVRleHRNc2c7CiAKICAgICBEaXNwbGF5VGV4dFBhcmFtcyhDb21tYW5kRGV0YWlscyBjbWREZXQsIFRleHRNZXNzYWdlIHRleHRNc2cpIHsKICAgICAgICAgc3VwZXIoY21kRGV0KTsKLSAgICAgICAgdGhpcy50ZXh0TXNnID0gdGV4dE1zZzsKKyAgICAgICAgbVRleHRNc2cgPSB0ZXh0TXNnOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIGJvb2xlYW4gc2V0SWNvbihCaXRtYXAgaWNvbikgewotICAgICAgICBpZiAoaWNvbiAhPSBudWxsICYmIHRleHRNc2cgIT0gbnVsbCkgewotICAgICAgICAgICAgdGV4dE1zZy5pY29uID0gaWNvbjsKKyAgICAgICAgaWYgKGljb24gIT0gbnVsbCAmJiBtVGV4dE1zZyAhPSBudWxsKSB7CisgICAgICAgICAgICBtVGV4dE1zZy5pY29uID0gaWNvbjsKICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICB9CiAgICAgICAgIHJldHVybiBmYWxzZTsKQEAgLTU5LDIxICs2MCwyMiBAQAogfQogCiBjbGFzcyBMYXVuY2hCcm93c2VyUGFyYW1zIGV4dGVuZHMgQ29tbWFuZFBhcmFtcyB7Ci0gICAgVGV4dE1lc3NhZ2UgY29uZmlybU1zZzsKLSAgICBMYXVuY2hCcm93c2VyTW9kZSBtb2RlOwotICAgIFN0cmluZyB1cmw7CisgICAgVGV4dE1lc3NhZ2UgbUNvbmZpcm1Nc2c7CisgICAgTGF1bmNoQnJvd3Nlck1vZGUgbU1vZGU7CisgICAgU3RyaW5nIG1Vcmw7CiAKICAgICBMYXVuY2hCcm93c2VyUGFyYW1zKENvbW1hbmREZXRhaWxzIGNtZERldCwgVGV4dE1lc3NhZ2UgY29uZmlybU1zZywKICAgICAgICAgICAgIFN0cmluZyB1cmwsIExhdW5jaEJyb3dzZXJNb2RlIG1vZGUpIHsKICAgICAgICAgc3VwZXIoY21kRGV0KTsKLSAgICAgICAgdGhpcy5jb25maXJtTXNnID0gY29uZmlybU1zZzsKLSAgICAgICAgdGhpcy5tb2RlID0gbW9kZTsKLSAgICAgICAgdGhpcy51cmwgPSB1cmw7CisgICAgICAgIG1Db25maXJtTXNnID0gY29uZmlybU1zZzsKKyAgICAgICAgbU1vZGUgPSBtb2RlOworICAgICAgICBtVXJsID0gdXJsOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIGJvb2xlYW4gc2V0SWNvbihCaXRtYXAgaWNvbikgewotICAgICAgICBpZiAoaWNvbiAhPSBudWxsICYmIGNvbmZpcm1Nc2cgIT0gbnVsbCkgewotICAgICAgICAgICAgY29uZmlybU1zZy5pY29uID0gaWNvbjsKKyAgICAgICAgaWYgKGljb24gIT0gbnVsbCAmJiBtQ29uZmlybU1zZyAhPSBudWxsKSB7CisgICAgICAgICAgICBtQ29uZmlybU1zZy5pY29uID0gaWNvbjsKICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICB9CiAgICAgICAgIHJldHVybiBmYWxzZTsKQEAgLTgxLDE5ICs4MywyMCBAQAogfQogCiBjbGFzcyBQbGF5VG9uZVBhcmFtcyBleHRlbmRzIENvbW1hbmRQYXJhbXMgewotICAgIFRleHRNZXNzYWdlIHRleHRNc2c7Ci0gICAgVG9uZVNldHRpbmdzIHNldHRpbmdzOworICAgIFRleHRNZXNzYWdlIG1UZXh0TXNnOworICAgIFRvbmVTZXR0aW5ncyBtU2V0dGluZ3M7CiAKICAgICBQbGF5VG9uZVBhcmFtcyhDb21tYW5kRGV0YWlscyBjbWREZXQsIFRleHRNZXNzYWdlIHRleHRNc2csCiAgICAgICAgICAgICBUb25lIHRvbmUsIER1cmF0aW9uIGR1cmF0aW9uLCBib29sZWFuIHZpYnJhdGUpIHsKICAgICAgICAgc3VwZXIoY21kRGV0KTsKLSAgICAgICAgdGhpcy50ZXh0TXNnID0gdGV4dE1zZzsKLSAgICAgICAgdGhpcy5zZXR0aW5ncyA9IG5ldyBUb25lU2V0dGluZ3MoZHVyYXRpb24sIHRvbmUsIHZpYnJhdGUpOworICAgICAgICBtVGV4dE1zZyA9IHRleHRNc2c7CisgICAgICAgIG1TZXR0aW5ncyA9IG5ldyBUb25lU2V0dGluZ3MoZHVyYXRpb24sIHRvbmUsIHZpYnJhdGUpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIGJvb2xlYW4gc2V0SWNvbihCaXRtYXAgaWNvbikgewotICAgICAgICBpZiAoaWNvbiAhPSBudWxsICYmIHRleHRNc2cgIT0gbnVsbCkgewotICAgICAgICAgICAgdGV4dE1zZy5pY29uID0gaWNvbjsKKyAgICAgICAgaWYgKGljb24gIT0gbnVsbCAmJiBtVGV4dE1zZyAhPSBudWxsKSB7CisgICAgICAgICAgICBtVGV4dE1zZy5pY29uID0gaWNvbjsKICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICB9CiAgICAgICAgIHJldHVybiBmYWxzZTsKQEAgLTEwMSwyNSArMTA0LDI2IEBACiB9CiAKIGNsYXNzIENhbGxTZXR1cFBhcmFtcyBleHRlbmRzIENvbW1hbmRQYXJhbXMgewotICAgIFRleHRNZXNzYWdlI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BudWxsICYmIG1DYWxsTXNnLmljb24gPT0gbnVsbCkgeworICAgICAgICAgICAgbUNhbGxNc2cuaWNvbiA9IGljb247CiAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgfQogICAgICAgICByZXR1cm4gZmFsc2U7CkBAIC0xMjcsMjEgKzEzMSwyMiBAQAogfQogCiBjbGFzcyBTZWxlY3RJdGVtUGFyYW1zIGV4dGVuZHMgQ29tbWFuZFBhcmFtcyB7Ci0gICAgTWVudSBtZW51ID0gbnVsbDsKLSAgICBib29sZWFuIGxvYWRUaXRsZUljb24gPSBmYWxzZTsKKyAgICBNZW51IG1NZW51ID0gbnVsbDsKKyAgICBib29sZWFuIG1Mb2FkVGl0bGVJY29uID0gZmFsc2U7CiAKICAgICBTZWxlY3RJdGVtUGFyYW1zKENvbW1hbmREZXRhaWxzIGNtZERldCwgTWVudSBtZW51LCBib29sZWFuIGxvYWRUaXRsZUljb24pIHsKICAgICAgICAgc3VwZXIoY21kRGV0KTsKLSAgICAgICAgdGhpcy5tZW51ID0gbWVudTsKLSAgICAgICAgdGhpcy5sb2FkVGl0bGVJY29uID0gbG9hZFRpdGxlSWNvbjsKKyAgICAgICAgbU1lbnUgPSBtZW51OworICAgICAgICBtTG9hZFRpdGxlSWNvbiA9IGxvYWRUaXRsZUljb247CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgYm9vbGVhbiBzZXRJY29uKEJpdG1hcCBpY29uKSB7Ci0gICAgICAgIGlmIChpY29uICE9IG51bGwgJiYgbWVudSAhPSBudWxsKSB7Ci0gICAgICAgICAgICBpZiAobG9hZFRpdGxlSWNvbiAmJiBtZW51LnRpdGxlSWNvbiA9PSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgbWVudS50aXRsZUljb24gPSBpY29uOworICAgICAgICBpZiAoaWNvbiAhPSBudWxsICYmIG1NZW51ICE9IG51bGwpIHsKKyAgICAgICAgICAgIGlmIChtTG9hZFRpdGxlSWNvbiAmJiBtTWVudS50aXRsZUljb24gPT0gbnVsbCkgeworICAgICAgICAgICAgICAgIG1NZW51LnRpdGxlSWNvbiA9IGljb247CiAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgIGZvciAoSXRlbSBpdGVtIDogbWVudS5pdGVtcykgeworICAgICAgICAgICAgICAgIGZvciAoSXRlbSBpdGVtIDogbU1lbnUuaXRlbXMpIHsKICAgICAgICAgICAgICAgICAgICAgaWYgKGl0ZW0uaWNvbiAhPSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgfQpAQCAtMTU2LDE2ICsxNjEsMTcgQEAKIH0KIAogY2xhc3MgR2V0SW5wdXRQYXJhbXMgZXh0ZW5kcyBDb21tYW5kUGFyYW1zIHsKLSAgICBJbnB1dCBpbnB1dCA9IG51bGw7CisgICAgSW5wdXQgbUlucHV0ID0gbnVsbDsKIAogICAgIEdldElucHV0UGFyYW1zKENvbW1hbmREZXRhaWxzIGNtZERldCwgSW5wdXQgaW5wdXQpIHsKICAgICAgICAgc3VwZXIoY21kRGV0KTsKLSAgICAgICAgdGhpcy5pbnB1dCA9IGlucHV0OworICAgICAgICBtSW5wdXQgPSBpbnB1dDsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBib29sZWFuIHNldEljb24oQml0bWFwIGljb24pIHsKLSAgICAgICAgaWYgKGljb24gIT0gbnVsbCAmJiBpbnB1dCAhPSBudWxsKSB7Ci0gICAgICAgICAgICBpbnB1dC5pY29uID0gaWNvbjsKKyAgICAgICAgaWYgKGljb24gIT0gbnVsbCAmJiBtSW5wdXQgIT0gbnVsbCkgeworICAgICAgICAgICAgbUlucHV0Lmljb24gPSBpY29uOwogICAgICAgICB9CiAgICAgICAgIHJldHVybiB0cnVlOwogICAgIH0KQEAgLTE4MCwxOCArMTg2LDE5IEBACiAgKiB0aGUgZGV0YWlscyBvZiBwcm9hY3RpdmUgY29tbWFuZHMgcHJvY2VkdXJlcyBhbmQgdGhlaXIgc3RydWN0dXJlcy4KICAqLwogY2xhc3MgQklQQ2xpZW50UGFyYW1zIGV4dGVuZHMgQ29tbWFuZFBhcmFtcyB7Ci0gICAgVGV4dE1lc3NhZ2UgdGV4dE1zZzsKLSAgICBib29sZWFuIGJIYXNBbHBoYUlkOworICAgIFRleHRNZXNzYWdlIG1UZXh0TXNnOworICAgIGJvb2xlYW4gbUhhc0FscGhhSWQ7CiAKICAgICBCSVBDbGllbnRQYXJhbXMoQ29tbWFuZERldGFpbHMgY21kRGV0LCBUZXh0TWVzc2FnZSB0ZXh0TXNnLCBib29sZWFuIGhhc19hbHBoYV9pZCkgewogICAgICAgICBzdXBlcihjbWREZXQpOwotICAgICAgICB0aGlzLnRleHRNc2cgPSB0ZXh0TXNnOwotICAgICAgICB0aGlzLmJIYXNBbHBoYUlkID0gaGFzX2FscGhhX2lkOworICAgICAgICBtVGV4dE1zZyA9IHRleHRNc2c7CisgICAgICAgIG1IYXNBbHBoYUlkID0gaGFzX2FscGhhX2lkOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIGJvb2xlYW4gc2V0SWNvbihCaXRtYXAgaWNvbikgewotICAgICAgICBpZiAoaWNvbiAhPSBudWxsICYmIHRleHRNc2cgIT0gbnVsbCkgewotICAgICAgICAgICAgdGV4dE1zZy5pY29uID0gaWNvbjsKKyAgICAgICAgaWYgKGljb24gIT0gbnVsbCAmJiBtVGV4dE1zZyAhPSBudWxsKSB7CisgICAgICAgICAgICBtVGV4dE1zZy5pY29uID0gaWNvbjsKICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICB9CiAgICAgICAgIHJldHVybiBmYWxzZTsKZGlmZiAtLWdpdCBhL3NyYy9qYXZhL2NvbS9hbmRyb2lkL2ludGVybmFsL3RlbGVwaG9ueS9jYXQvQ29tbWFuZFBhcmFtc0ZhY3RvcnkuamF2YSBiL3NyYy9qYXZhL2NvbS9hbmRyb2lkL2ludGVybmFsL3RlbG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worICAgIHByaXZhdGUgaW50IG1JZDsKIAogICAgIHB1YmxpYyBTZWxlY3RJdGVtUmVzcG9uc2VEYXRhKGludCBpZCkgewogICAgICAgICBzdXBlcigpOwotICAgICAgICB0aGlzLmlkID0gaWQ7CisgICAgICAgIG1JZCA9IGlkOwogICAgIH0KIAogICAgIEBPdmVycmlkZQpAQCAtNjEsNyArNjEsNyBAQAogICAgICAgICBpbnQgdGFnID0gMHg4MCB8IENvbXByZWhlbnNpb25UbHZUYWcuSVRFTV9JRC52YWx1ZSgpOwogICAgICAgICBidWYud3JpdGUodGFnKTsgLy8gdGFnCiAgICAgICAgIGJ1Zi53cml0ZSgxKTsgLy8gbGVuZ3RoCi0gICAgICAgIGJ1Zi53cml0ZShpZCk7IC8vIGlkZW50aWZpZXIgb2YgaXRlbSBjaG9zZW4KKyAgICAgICAgYnVmLndyaXRlKG1JZCk7IC8vIGlkZW50aWZpZXIgb2YgaXRlbSBjaG9zZW4KICAgICB9CiB9CiAKQEAgLTc5LDE5ICs3OSwxOSBAQAogCiAgICAgcHVibGljIEdldElua2V5SW5wdXRSZXNwb25zZURhdGEoU3RyaW5nIGluRGF0YSwgYm9vbGVhbiB1Y3MyLCBib29sZWFuIHBhY2tlZCkgewogICAgICAgICBzdXBlcigpOwotICAgICAgICB0aGlzLm1Jc1VjczIgPSB1Y3MyOwotICAgICAgICB0aGlzLm1Jc1BhY2tlZCA9IHBhY2tlZDsKLSAgICAgICAgdGhpcy5tSW5EYXRhID0gaW5EYXRhOwotICAgICAgICB0aGlzLm1Jc1llc05vID0gZmFsc2U7CisgICAgICAgIG1Jc1VjczIgPSB1Y3MyOworICAgICAgICBtSXNQYWNrZWQgPSBwYWNrZWQ7CisgICAgICAgIG1JbkRhdGEgPSBpbkRhdGE7CisgICAgICAgIG1Jc1llc05vID0gZmFsc2U7CiAgICAgfQogCiAgICAgcHVibGljIEdldElua2V5SW5wdXRSZXNwb25zZURhdGEoYm9vbGVhbiB5ZXNOb1Jlc3BvbnN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udHMuU3RhdGUuSURMRSAmJgorICAgICAgICAgICAgICAgICAgICBpZiAobUNULm1TdGF0ZSAhPSBQaG9uZUNvbnN0YW50cy5TdGF0ZS5JRExFICYmCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIW1TU1QuaXNDb25jdXJyZW50Vm9pY2VBbmREYXRhQWxsb3dlZCgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICByZXQgPSBQaG9uZUNvbnN0YW50cy5EYXRhU3RhdGUuU1VTUEVOREVEOwogICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewpAQCAtMTQxLDcgKzEzOSw2IEBACiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAKLSAgICAgICAgICAgICAgICBjYXNlIElOSVRJTkc6CiAgICAgICAgICAgICAgICAgY2FzZSBDT05ORUNUSU5HOgogICAgICAgICAgICAgICAgIGNhc2UgU0NBTk5JTkc6CiAgICAgICAgICAgICAgICAgICAgIHJldCA9IFBob25lQ29uc3RhbnRzLkRhdGFTdGF0ZS5DT05ORUNUSU5HOwpAQCAtMTY3LDcgKzE2NCw3IEBACiAgICAgICAgIC8vIGdldCB0aGUgbWVzc2FnZQogICAgICAgICBNZXNzYWdlIG1zZyA9IG9idGFpbk1lc3NhZ2UoRVZFTlRfU0VUX05FVFdPUktfTUFOVUFMX0NPTVBMRVRFLCBuc20pOwogCi0gICAgICAgIG1DTS5zZXROZXR3b3JrU2VsZWN0aW9uTW9kZU1hbnVhbChuZXR3b3JrLmdldE9wZXJhdG9yTnVtZXJpYygpLCBtc2cpOworICAgICAgICBtQ2kuc2V0TmV0d29ya1NlbGVjdGlvbk1vZGVNYW51YWwobmV0d29yay5nZXRPcGVyYXRvck51bWVyaWMoKSwgbXNnKTsKICAgICB9CiAKICAgICAvKioKQEAgLTE3Nyw3ICsxNzQsNyBAQAogICAgICAgICAvLyBsb29rIGZvciBvdXIgd3JhcHBlciB3aXRoaW4gdGhlIGFzeW5jcmVzdWx0LCBza2lwIHRoZSByZXN0IGlmIGl0CiAgICAgICAgIC8vIGlzIG51bGwuCiAgICAgICAgIGlmICghKGFyLnVzZXJPYmogaW5zdGFuY2VvZiBOZXR3b3JrU2VsZWN0TWVzc2FnZSkpIHsKLSAgICAgICAgICAgIFJsb2cuZShMT0dfVEFHLCAidW5leHBlY3RlZCByZXN1bHQgZnJvbSB1c2VyIG9iamVjdC4iKTsKKyAgICAgICAgICAgIGxvZ2UoInVuZXhwZWN0ZWQgcmVzdWx0IGZyb20gdXNlciBvYmplY3QuIik7CiAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgIH0KIApAQCAtMjAwLDcgKzE5Nyw3IEBACiAKICAgICAgICAgLy8gY29tbWl0IGFuZCBsb2cgdGhlIHJlc3VsdC4KICAgICAgICAgaWYgKCEgZWRpdG9yLmNvbW1pdCgpKSB7Ci0gICAgICAgICAgICBSbG9nLmUoTE9HX1RBRywgImZhaWxlZCB0byBjb21taXQgbmV0d29yayBzZWxlY3Rpb24gcHJlZmVyZW5jZSIpOworICAgICAgICAgICAgbG9nZSgiZmFpbGVkIHRvIGNvbW1pdCBuZXR3b3JrIHNlbGVjdGlvbiBwcmVmZXJlbmNlIik7CiAgICAgICAgIH0KIAogICAgIH0KQEAgLTIxOCw3ICsyMTUsNyBAQAogICAgICAgICAgICAgICAgIG1Db250ZXh0LmdldENvbnRlbnRSZXNvbHZlcigpLmluc2VydCh1cmksIG1hcCk7CiAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICB9IGNhdGNoIChTUUxFeGNlcHRpb24gZSkgewotICAgICAgICAgICAgICAgIFJsb2cuZShMT0dfVEFHLCAiW0NETUFMVEVQaG9uZV0gQ2FuJ3Qgc3RvcmUgY3VycmVudCBvcGVyYXRvciByZXQgZmFsc2UiLCBlKTsKKyAgICAgICAgICAgICAgICBsb2dlKCJDYW4ndCBzdG9yZSBjdXJyZW50IG9wZXJhdG9yIHJldCBmYWxzZSI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NlZFZvaWNlUHJpdmFjeShib29sZWFuIGVuYWJsZSwgTWVzc2FnZSBvbkNvbXBsZXRlKSB7Ci0gICAgICAgIHRoaXMubUNNLnNldFByZWZlcnJlZFZvaWNlUHJpdmFjeShlbmFibGUsIG9uQ29tcGxldGUpOworICAgICAgICBtQ2kuc2V0UHJlZmVycmVkVm9pY2VQcml2YWN5KGVuYWJsZSwgb25Db21wbGV0ZSk7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgZ2V0RW5oYW5jZWRWb2ljZVByaXZhY3koTWVzc2FnZSBvbkNvbXBsZXRlKSB7Ci0gICAgICAgIHRoaXMubUNNLmdldFByZWZlcnJlZFZvaWNlUHJpdmFjeShvbkNvbXBsZXRlKTsKKyAgICAgICAgbUNpLmdldFByZWZlcnJlZFZvaWNlUHJpdmFjeShvbkNvbXBsZXRlKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBjbGVhckRpc2Nvbm5lY3RlZCgpIHsKICAgICAgICAgbUNULmNsZWFyRGlzY29ubmVjdGVkKCk7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIERhdGFBY3Rpdml0eVN0YXRlIGdldERhdGFBY3Rpdml0eVN0YXRlKCkgewogICAgICAgICBEYXRhQWN0aXZpdHlTdGF0ZSByZXQgPSBEYXRhQWN0aXZpdHlTdGF0ZS5OT05FOwogCkBAIC0zNTIsMTEgKzM1OSwxNiBAQAogICAgICAgICAgICAgICAgIGNhc2UgRE9STUFOVDoKICAgICAgICAgICAgICAgICAgICAgcmV0ID0gRGF0YUFjdGl2aXR5U3RhdGUuRE9STUFOVDsKICAgICAgICAgICAgICAgICBicmVhazsKKworICAgICAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgICAgIHJldCA9IERhdGFBY3Rpdml0eVN0YXRlLk5PTkU7CisgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAg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XJuICIwIjsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgU3RyaW5nIGdldFN1YnNjcmliZXJJZCgpIHsKICAgICAgICAgcmV0dXJuIG1TU1QuZ2V0SW1zaSgpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdHJpbmcgZ2V0SW1laSgpIHsKICAgICAgICAgUmxvZy5lKExPR19UQUcsICJJTUVJIGlzIG5vdCBhdmFpbGFibGUgaW4gQ0RNQSIpOwogICAgICAgICByZXR1cm4gbnVsbDsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgYm9vbGVhbiBjYW5Db25mZXJlbmNlKCkgewogICAgICAgICBSbG9nLmUoTE9HX1RBRywgImNhbkNvbmZlcmVuY2U6IG5vdCBwb3NzaWJsZSBpbiBDRE1BIik7CiAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgQ2VsbExvY2F0aW9uIGdldENlbGxMb2NhdGlvbigpIHsKLSAgICAgICAgcmV0dXJuIG1TU1QuY2VsbExvYzsKKyAgICAgICAgcmV0dXJuIG1TU1QubUNlbGxMb2M7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIENkbWFDYWxsIGdldEZvcmVncm91bmRDYWxsKCkgewotICAgICAgICByZXR1cm4gbUNULmZvcmVncm91bmRDYWxsOworICAgICAgICByZXR1cm4gbUNULm1Gb3JlZ3JvdW5kQ2FsbDsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZAogICAgIHNlbGVjdE5ldHdvcmtNYW51YWxseShPcGVyYXRvckluZm8gbmV0d29yaywKICAgICAgICAgICAgIE1lc3NhZ2UgcmVzcG9uc2UpIHsKICAgICAgICAgUmxvZy5lKExPR19UQUcsICJzZWxlY3ROZXR3b3JrTWFudWFsbHk6IG5vdCBwb3NzaWJsZSBpb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XRhU3RhdGUgcmV0ID0gUGhvbmVDb25zdGFudHMuRGF0YVN0YXRlLkRJU0NPTk5FQ1RFRDsKIApAQCAtNjI3LDcgKzY4Miw3IEBACiAKICAgICAgICAgICAgICAgICBjYXNlIENPTk5FQ1RFRDoKICAgICAgICAgICAgICAgICBjYXNlIERJU0NPTk5FQ1RJTkc6Ci0gICAgICAgICAgICAgICAgICAgIGlmICggbUNULnN0YXRlICE9IFBob25lQ29uc3RhbnRzLlN0YXRlLklETEUKKyAgICAgICAgICAgICAgICAgICAgaWYgKCBtQ1QubVN0YXRlICE9IFBob25lQ29uc3RhbnRzLlN0YXRlLklETEUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAmJiAhbVNTVC5pc0NvbmN1cnJlbnRWb2ljZUFuZERhdGFBbGxvd2VkKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIHJldCA9IFBob25lQ29uc3RhbnRzLkRhdGFTdGF0ZS5TVVNQRU5ERUQ7CiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CkBAIC02MzUsNyArNjkwLDYgQEAKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIGJyZWFrOwogCi0gICAgICAgICAgICAgICAgY2FzZSBJTklUSU5HOgogICAgICAgICAgICAgICAgIGNhc2UgQ09OTkVDVElORzoKICAgICAgICAgICAgICAgICBjYXNlIFNDQU5OSU5HOgogICAgICAgICAgICAgICAgICAgICByZXQgPSBQaG9uZUNvbnN0YW50cy5EYXRhU3RhdGUuQ09OTkVDVElORzsKQEAgLTY0NywzNCArNzAxLDM5IEBACiAgICAgICAgIHJldHVybiByZXQ7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgc2VuZFVzc2RSZXNwb25zZShTdHJpbmcgdXNzZE1lc3NnZSkgewogICAgICAgICBSbG9nLmUoTE9HX1RBRywgInNlbmRVc3NkUmVzcG9uc2U6IG5vdCBwb3NzaWJsZSBpbiBDRE1BIik7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgc2VuZER0bWYoY2hhciBjKSB7CiAgICAgICAgIGlmICghUGhvbmVOdW1iZXJVdGlscy5pczEyS2V5KGMpKSB7CiAgICAgICAgICAgICBSbG9nLmUoTE9HX1RBRywKICAgICAgICAgICAgICAgICAgICAgInNlbmREdG1mIGNhbGxlZCB3aXRoIGludmFsaWQgY2hhcmFjdGVyICciICsgYyArICInIik7CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICBpZiAobUNULnN0YXRlID09ICBQaG9uZUNvbnN0YW50cy5TdGF0ZS5PRkZIT09LKSB7Ci0gICAgICAgICAgICAgICAgbUNNLnNlbmREdG1mKGMsIG51bGwpOworICAgICAgICAgICAgaWYgKG1DVC5tU3RhdGUgPT0gIFBob25lQ29uc3RhbnRzLlN0YXRlLk9GRkhPT0spIHsKKyAgICAgICAgICAgICAgICBtQ2kuc2VuZER0bWYoYywgbnVsbCk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBzdGFydER0bWYoY2hhciBjKSB7CiAgICAgICAgIGlmICghUGhvbmVOdW1iZXJVdGlscy5pczEyS2V5KGMpKSB7CiAgICAgICAgICAgICBSbG9nLmUoTE9HX1RBRywKICAgICAgICAgICAgICAgICAgICAgInN0YXJ0RHRtZiBjYWxsZWQgd2l0aCBpbnZhbGlkIGNoYXJhY3RlciAnIiArIGMgKyAiJyIpOwogICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgbUNNLnN0YXJ0RHRtZihjLCBudWxsKTsKKyAgICAgICAgICAgIG1DaS5zdGFydER0bWYoYywgbnVsbCk7CiAgICAgICAgIH0KICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBzdG9wRHRtZigpIHsKLSAgICAgICAgbUNNLnN0b3BEdG1mKG51bGwpOworICAgICAgICBt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2Ugb25Db21wbGV0ZSkgewogICAgICAgICBSbG9nLmUoTE9HX1RBRywgInNldE91dGdvaW5nQ2FsbGVySWREaXNwbGF5OiBub3QgcG9zc2libGUgaW4gQ0RNQSIpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIGVuYWJsZUxvY2F0aW9uVXBkYXRlcygpIHsKICAgICAgICAgbVNTVC5lbmFibGVMb2NhdGlvblVwZGF0ZXMoKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBkaXNhYmxlTG9jYXRpb25VcGRhdGVzKCkgewogICAgICAgICBtU1NULmRpc2FibGVMb2NhdGlvblVwZGF0ZXMoKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBnZXREYXRhQ2FsbExpc3QoTWVzc2FnZSByZXNwb25zZSkgewotICAgICAgICBtQ00uZ2V0RGF0YUNhbGxMaXN0KHJlc3BvbnNlKTsKKyAgICAgICAgbUNpLmdldERhdGFDYWxsTGlzdChyZXNwb25zZSk7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGJvb2xlYW4gZ2V0RGF0YVJvYW1pbmdFbmFibGVkKCkgewogICAgICAgICByZXR1cm4gbURhdGFDb25uZWN0aW9uVHJhY2tlci5nZXREYXRhT25Sb2FtaW5nRW5hYmxlZCgpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHNldFZvaWNlTWFpbE51bWJlcihTdHJpbmcgYWxwaGFUYWcsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZyB2b2ljZU1haWxOdW1iZXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1lc3NhZ2Ugb25Db21wbGV0ZSkgewpAQCAtNzI2LDYgKzc5Miw3IEBACiAgICAgICAgIH0KICAgICB9CiAKKyAgICBAT3ZlcnJpZ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gICAgICAgICAgICAgICAgbUNNLmdldERldmljZUlkZW50aXR5KG9idGFpbk1lc3NhZ2UoRVZFTlRfR0VUX0RFVklDRV9JREVOVElUWV9ET05FKSk7CisgICAgICAgICAgICAgICAgbUNpLmdldERldmljZUlkZW50aXR5KG9idGFpbk1lc3NhZ2UoRVZFTlRfR0VUX0RFVklDRV9JREVOVElUWV9ET05FKSk7CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBicmVhazsKIApAQCAtMTEyMSw2ICsxMjAyLDcgQEAKICAgICAvKioKICAgICAgKiBSZXRyaWV2ZXMgdGhlIFBob25lU3ViSW5mbyBvZiB0aGUgQ0RNQVBob25lCiAgICAgICovCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFBob25lU3ViSW5mbyBnZXRQaG9uZVN1YkluZm8oKSB7CiAgICAgICAgIHJldHVybiBtU3ViSW5mbzsKICAgICB9CkBAIC0xMTI4LDYgKzEyMTAsNyBAQAogICAgIC8qKgogICAgICAqIFJldHJpZXZlcyB0aGUgSWNjU21zSW50ZXJmYWNlTWFuYWdlciBvZiB0aGUgQ0RNQVBob25lCiAgICAgICovCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIEljY1Ntc0ludGVyZmFjZU1hbmFnZXIgZ2V0SWNjU21zSW50ZXJmYWNlTWFuYWdlcigpIHsKICAgICAgICAgcmV0dXJuIG1SdWltU21zSW50ZXJmYWNlTWFuYWdlcjsKICAgICB9CkBAIC0xMTM1LDYgKzEyMTgsNyBAQAogICAgIC8qKgogICAgICAqIFJldHJpZXZlcyB0aGUgSWNjUGhvbmVCb29rSW50ZXJmYWNlTWFuYWdlciBvZiB0aGUgQ0RNQVBob25lCiAgICAgICovCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIEljY1Bob25lQm9va0ludGVyZmFjZU1hbmFnZXIgZ2V0SWNjUGhvbmVCb29rSW50ZXJmYWNlTWFuYWdlcigpIHsKICAgICAgICAgcmV0dXJuIG1SdWltUGhvbmVCb29r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IHNlbE1pbiA9IEludGVnZXIucGFyc2VJbnQoKFN0cmluZylzY2hbaSsyXSk7Ci0gICAgICAgICAgICAgICAgICAgIGludCBzZWxNYXggPSBJbnRlZ2VyLnBhcnNlSW50KChTdHJpbmcpc2NoW2krM10pOworICAgICAgICAgICAgICAgICAgICBpbnQgc2VsTWluID0gSW50ZWdlci5wYXJzZUludChzY2hbaSsyXSk7CisgICAgICAgICAgICAgICAgICAgIGludCBzZWxNYXggPSBJbnRlZ2VyLnBhcnNlSW50KHNjaFtpKzNdKTsKICAgICAgICAgICAgICAgICAgICAgLy8gQ2hlY2sgaWYgdGhlIHNlbGVjdGlvbiBjb2RlIGV4dHJhY3RlZCBmcm9tIHRoZSBkaWFsIHN0cmluZyBmYWxscwogICAgICAgICAgICAgICAgICAgICAvLyB3aXRoaW4gYW55IG9mIHRoZSByYW5nZSBwYWlycyBzcGVjaWZpZWQgaW4gdGhlIHNjaGVtYS4KICAgICAgICAgICAgICAgICAgICAgaWYgKChzeXNTZWxDb2RlSW50ID49IHNlbE1pbikgJiYgKHN5c1NlbENvZGVJbnQgPD0gc2VsTWF4KSkgewpAQCAtMTMzNyw4ICsxNDI1LDggQEAKICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIVRleHRVdGlscy5pc0VtcHR5KHNjaFswXSkgJiYgc2NoWzBdLmVxdWFscygiRkMiKSkgewotICAgICAgICAgICAgICAgICAgICBpbnQgZmNMZW4gPSAgSW50ZWdlci5wYXJzZUludCgoU3RyaW5nKXNjaFsxXSk7Ci0gICAgICAgICAgICAgICAgICAgIFN0cmluZyBmYyA9IChTdHJpbmcpc2NoWzJdOworICAgICAgICAgICAgICAgICAgICBpbnQgZmNMZW4gPSAgSW50ZWdlci5wYXJzZUludChzY2hbMV0pOworICAgICAgICAgICAgICAgICAgICBTdHJpbmcgZmMgPSBzY2hbMl07CiAgICAgICAgICAgICAgICA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9ueS5Db25uZWN0aW9uOwogaW1wb3J0IGNvbS5hbmRyb2lkLmludGVybmFsLnRlbGVwaG9ueS5Ecml2ZXJDYWxsOwogaW1wb3J0IGNvbS5hbmRyb2lkLmludGVybmFsLnRlbGVwaG9ueS5QaG9uZTsKLWltcG9ydCBjb20uYW5kcm9pZC5pbnRlcm5hbC50ZWxlcGhvbnkuQ2FsbC5TdGF0ZTsKIAogLyoqCiAgKiB7QGhpZGV9CkBAIC0zMiw5ICszMCw3IEBACiBwdWJsaWMgZmluYWwgY2xhc3MgQ2RtYUNhbGwgZXh0ZW5kcyBDYWxsIHsKICAgICAvKioqKioqKioqKioqKioqKioqKioqKioqKioqIEluc3RhbmNlIFZhcmlhYmxlcyAqKioqKioqKioqKioqKioqKioqKioqKioqKi8KIAotICAgIC8qcGFja2FnZSovIEFycmF5TGlzdDxDb25uZWN0aW9uPiBjb25uZWN0aW9ucyA9IG5ldyBBcnJheUxpc3Q8Q29ubmVjdGlvbj4oKTsKLSAgICAvKnBhY2thZ2UqLyBTdGF0ZSBzdGF0ZSA9IFN0YXRlLklETEU7Ci0gICAgLypwYWNrYWdlKi8gQ2RtYUNhbGxUcmFja2VyIG93bmVyOworICAgIC8qcGFja2FnZSovIENkbWFDYWxsVHJhY2tlciBtT3duZXI7CiAKICAgICAvKioqKioqKioqKioqKioqKioqKioqKioqKioqKiogQ2xhc3MgTWV0aG9kcyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KIApAQCAtNTUsNjEgKzUxLDYxIEBACiAgICAgLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiBDb25zdHJ1Y3RvcnMgKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCiAgICAgLypwYWNrYWdlKi8KICAgICBDZG1hQ2FsbCAoQ2RtYUNhbGxUcmFja2VyIG93bmVyKSB7Ci0gICAgICAgIHRoaXMub3duZXIgPSBvd25lcjsKKyAgICAgICAgbU93bmVyID0gb3duZXI7CiAgICAgfQogCiAgICAgcHVibGljIHZvaWQgZGlzcG9zZSgpIHsKICAgICB9CiAKICAgICAvKioqKioqKioqKioqKioqKioqKioqKioqKiogT3ZlcnJpZGRlbiBmcm9tIENhbGwgKioqKioqKioqKioqKioqKioqKioqKioqKi8KKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgTGlzdDxDb25uZWN0aW9uPgogICAgIGdldENvbm5lY3Rpb25zKCkgewogICAgICAgICAvLyBGSVhNRSBzaG91bGQgcmV0dXJuIENvbGxlY3Rpb25zLnVubW9kaWZpYWJsZUxpc3QoKTsKLSAgICAgICAgcmV0dXJuIGNvbm5lY3Rpb25zOworICAgICAgICByZXR1cm4gbUNvbm5lY3Rpb25zOwogICAgIH0KIAotICAgIHB1YmxpYyBTdGF0ZQotICAgIGdldFN0YXRlKCkgewotICAgICAgICByZXR1cm4gc3RhdGU7Ci0gICAgfQotCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFBob25lCiAgICAgZ2V0UGhvbmUoKSB7Ci0gICAgICAgIHJldHVybiBvd25lci5waG9uZTsKKyAgICAgICAgcmV0dXJuIG1Pd25lci5tUGhvbmU7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGJvb2xlYW4gaXNNdWx0aXBhcnR5KCkgewotICAgICAgICByZXR1cm4gY29ubmVjdGlvbnMuc2l6ZSgpID4gMTsKKyAgICAgICAgcmV0dXJuIG1Db25uZWN0aW9ucy5zaXplKCkgPiAxOwogICAgIH0KIAogICAgIC8qKiBQbGVhc2Ugbm90ZTogaWYgdGhpcyBpcyB0aGUgZm9yZWdyb3VuZCBjYWxsIGFuZCBhCiAgICAgICogIGJhY2tncm91bmQgY2FsbCBleGlzdHMsIHRoZSBiYWNrZ3JvdW5kIGNhbGwgd2lsbCBiZSByZXN1bWVkCiAgICAgICogIGJlY2F1c2UgYW4gQVQrQ0hMRD0xIHdpbGwgYmUgc2VudAogICAgICAqLworICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkCi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T0gU3RhdGUuRElTQ09OTkVDVEVEKSB7CisgICAgICAgIGlmIChtU3RhdGUgIT0gU3RhdGUuRElTQ09OTkVDVEVEKSB7CiAgICAgICAgICAgICAvKiBJZiBvbmx5IGRpc2Nvbm5lY3RlZCBjb25uZWN0aW9ucyByZW1haW4sIHdlIGFyZSBkaXNjb25uZWN0ZWQqLwogCiAgICAgICAgICAgICBib29sZWFuIGhhc09ubHlEaXNjb25uZWN0ZWRDb25uZWN0aW9ucyA9IHRydWU7CiAKLSAgICAgICAgICAgIGZvciAoaW50IGkgPSAwLCBzID0gY29ubmVjdGlvbnMuc2l6ZSgpICA7IGkgPCBzOyBpICsrKSB7Ci0gICAgICAgICAgICAgICAgaWYgKGNvbm5lY3Rpb25zLmdldChpKS5nZXRTdGF0ZSgpCisgICAgICAgICAgICBmb3IgKGludCBpID0gMCwgcyA9IG1Db25uZWN0aW9ucy5zaXplKCkgIDsgaSA8IHM7IGkgKyspIHsKKyAgICAgICAgICAgICAgICBpZiAobUNvbm5lY3Rpb25zLmdldChpKS5nZXRTdGF0ZSgpCiAgICAgICAgICAgICAgICAgICAgICE9IFN0YXRlLkRJU0NPTk5FQ1RFRAogICAgICAgICAgICAgICAgICkgewogICAgICAgICAgICAgICAgICAgICBoYXNPbmx5RGlzY29ubmVjdGVkQ29ubmVjdGlvbnMgPSBmYWxzZTsKQEAgLTEzMiw3ICsxMjgsNyBAQAogICAgICAgICAgICAgfQogCiAgICAgICAgICAgICBpZiAoaGFzT25seURpc2Nvbm5lY3RlZENvbm5lY3Rpb25zKSB7Ci0gICAgICAgICAgICAgICAgc3RhdGUgPSBTdGF0ZS5ESVNDT05ORUNURUQ7CisgICAgICAgICAgICAgICAgbVN0YXRlID0gU3RhdGUuRElTQ09OTkVDVEVEOwogICAgICAgICAgICAgfQogICAgICAgICB9CiAgICAgfQpAQCAtMTQwLDEwICsxMzYsMTAgQEAKIAogICAgIC8qcGFja2FnZSovIHZvaWQKICAgICBkZXRhY2goQ2RtYUN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lKCkpIHsKKyAgICAgICAgaWYgKCFtRm9yZWdyb3VuZENhbGwuaXNJZGxlKCkpIHsKICAgICAgICAgICAgIC8vIENoZWNrIGRhdGEgY2FsbAogICAgICAgICAgICAgZGlzYWJsZURhdGFDYWxsSW5FbWVyZ2VuY3lDYWxsKGRpYWxTdHJpbmcpOwogCiAgICAgICAgICAgICAvLyBBdHRhY2ggdGhlIG5ldyBjb25uZWN0aW9uIHRvIGZvcmVncm91bmRDYWxsCi0gICAgICAgICAgICBwZW5kaW5nTU8gPSBuZXcgQ2RtYUNvbm5lY3Rpb24ocGhvbmUuZ2V0Q29udGV4dCgpLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGVja0ZvclRlc3RFbWVyZ2VuY3lOdW1iZXIoZGlhbFN0cmluZyksIHRoaXMsIGZvcmVncm91bmRDYWxsKTsKLSAgICAgICAgICAgIGNtLnNlbmRDRE1BRmVhdHVyZUNvZGUocGVuZGluZ01PLmFkZHJlc3MsCisgICAgICAgICAgICBtUGVuZGluZ01PID0gbmV3IENkbWFDb25uZWN0aW9uKG1QaG9uZS5nZXRDb250ZXh0KCksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoZWNrRm9yVGVzdEVtZXJnZW5jeU51bWJlcihkaWFsU3RyaW5nKSwgdGhpcywgbUZvcmVncm91bmRDYWxsKTsKKyAgICAgICAgICAgIG1DaS5zZW5kQ0RNQUZlYXR1cmVDb2RlKG1QZW5kaW5nTU8ubUFkZHJlc3MsCiAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZShFVkVOVF9USFJFRV9XQVlfRElBTF9MMl9SRVNVTFRfQ0RNQSkpOwotICAgICAgICAgICAgcmV0dXJuIHBlbmRpbmdNTzsKKyAgICAgICAgICAgIHJldHVybiBtUGVuZGluZ01POwogICAgICAgICB9CiAgICAgICAgIHJldHVybiBudWxsOwogICAgIH0KIAogICAgIHZvaWQKICAgICBhY2NlcHRDYWxsKCkgdGhyb3dzIENhb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hvbnlQcm9wZXJ0aWVzLlBST1BFUlRZX0RJU0FCTEVfQ0FMTCwgImZhbHNlIik7CiAKICAgICAgICAgcmV0ID0gKHNlcnZpY2VTdGF0ZSAhPSBTZXJ2aWNlU3RhdGUuU1RBVEVfUE9XRVJfT0ZGKQotICAgICAgICAgICAgICAgICYmIHBlbmRpbmdNTyA9PSBudWxsCi0gICAgICAgICAgICAgICAgJiYgIXJpbmdpbmdDYWxsLmlzUmluZ2luZygpCisgICAgICAgICAgICAgICAgJiYgbVBlbmRpbmdNTyA9PSBudWxsCisgICAgICAgICAgICAgICAgJiYgIW1SaW5naW5nQ2FsbC5pc1JpbmdpbmcoKQogICAgICAgICAgICAgICAgICYmICFkaXNhYmxlQ2FsbC5lcXVhbHMoInRydWUiKQotICAgICAgICAgICAgICAgICYmICghZm9yZWdyb3VuZENhbGwuZ2V0U3RhdGUoKS5pc0FsaXZlKCkKLSAgICAgICAgICAgICAgICAgICAgfHwgKGZvcmVncm91bmRDYWxsLmdldFN0YXRlKCkgPT0gQ2RtYUNhbGwuU3RhdGUuQUNUSVZFKQotICAgICAgICAgICAgICAgICAgICB8fCAhYmFja2dyb3VuZENhbGwuZ2V0U3RhdGUoKS5pc0FsaXZlKCkpOworICAgICAgICAgICAgICAgICYmICghbUZvcmVncm91bmRDYWxsLmdldFN0YXRlKCkuaXNBbGl2ZSgpCisgICAgICAgICAgICAgICAgICAgIHx8IChtRm9yZWdyb3VuZENhbGwuZ2V0U3RhdGUoKSA9PSBDZG1hQ2FsbC5TdGF0ZS5BQ1RJVkUpCisgICAgICAgICAgICAgICAgICAgIHx8ICFtQmFja2dyb3VuZENhbGwuZ2V0U3RhdGUoKS5pc0FsaXZlKCkpOwogCiAgICAgICAgIGlmICghcmV0KSB7CiAgICAgICAgICAgICBsb2coU3RyaW5nLmZvcm1hdCgiY2FuRGlhbCBpcyBmYWxzZVxuIiArCkBAIC0zNzQsMTIgKzM2MywxMiBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIiAgIHx8IWJhY2tncm91bmRDYWxsLmdldFN0YXRlKCkuaXNBbGl2ZSgpKTo6PSVzKSIsCiAgICAgICAgICAgICAgICAgICAgIHNlcnZpY2VTdGF0ZSwKICAgICAgICAgICAgICAgICAgICAgc2VydmljZVN0YXRlICE9IFNlcnZpY2VTdGF0ZS5TVEFURV9QT1dFUl9PRkYsCi0gICAgICAgICAgICAgICAgICAgIHBlbmRpbmdNTyA9PSBudWxsLAotICAgICAgICAgICAgICAgICAgICAhcmluZ2luZ0NhbGwuaXNSaW5naW5nKCksCisgICAgICAgICAgICAgICAgICAgIG1QZW5kaW5nTU8gPT0gbnVsbCwKKyAgICAgICAgICAgICAgICAgICAgIW1SaW5naW5nQ2FsbC5pc1JpbmdpbmcoKSwKICAgICAgICAgICAgICAgICAgICAgIWRpc2FibGVDYWxsLmVxdWFscygidHJ1ZSIpLAotICAgICAgICAgICAgICAgICAgICAhZm9yZWdyb3VuZENhbGwuZ2V0U3RhdGUoKS5pc0FsaXZlKCksCi0gICAgICAgICAgICAgICAgICAgIGZvcmVncm91bmRDYWxsLmdldFN0YXRlKCkgPT0gQ2RtYUNhbGwuU3RhdGUuQUNUSVZFLAotICAgICAgICAgICAgICAgICAgICAhYmFja2dyb3VuZENhbGwuZ2V0U3RhdGUoKS5pc0FsaXZlKCkpKTsKKyAgICAgICAgICAgICAgICAgICAgIW1Gb3JlZ3JvdW5kQ2FsbC5nZXRTdGF0ZSgpLmlzQWxpdmUoKSwKKyAgICAgICAgICAgICAgICAgICAgbUZvcmVncm91bmRDYWxsLmdldFN0YXRlKCkgPT0gQ2RtYUNhbGwuU3RhdGUuQUNUSVZFLAorICAgICAgICAgICAgICAgICAgICAhbUJhY2tncm91bmRDYWxsLmdldFN0YXRlKCkuaXNBbGl2ZSgpKSk7CiAgICAgICAgIH0KICAgICAgICAgcmV0dXJuIHJldDsKICAgICB9CkBAIC0zOTQsOSArMzgzLDkgQEAKIAogICAgIHByaXZhdGUgdm9pZAogIC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TsKICAgICB9CiAKICAgICBwcml2YXRlIHZvaWQKICAgICBvcGVyYXRpb25Db21wbGV0ZSgpIHsKLSAgICAgICAgcGVuZGluZ09wZXJhdGlvbnMtLTsKKyAgICAgICAgbVBlbmRpbmdPcGVyYXRpb25zLS07CiAKICAgICAgICAgaWYgKERCR19QT0xMKSBsb2coIm9wZXJhdGlvbkNvbXBsZXRlOiBwZW5kaW5nT3BlcmF0aW9ucz0iICsKLSAgICAgICAgICAgICAgICBwZW5kaW5nT3BlcmF0aW9ucyArICIsIG5lZWRzUG9sbD0iICsgbmVlZHNQb2xsKTsKKyAgICAgICAgICAgICAgICBtUGVuZGluZ09wZXJhdGlvbnMgKyAiLCBuZWVkc1BvbGw9IiArIG1OZWVkc1BvbGwpOwogCi0gICAgICAgIGlmIChwZW5kaW5nT3BlcmF0aW9ucyA9PSAwICYmIG5lZWRzUG9sbCkgewotICAgICAgICAgICAgbGFzdFJlbGV2YW50UG9sbCA9IG9idGFpbk1lc3NhZ2UoRVZFTlRfUE9MTF9DQUxMU19SRVNVTFQpOwotICAgICAgICAgICAgY20uZ2V0Q3VycmVudENhbGxzKGxhc3RSZWxldmFudFBvbGwpOwotICAgICAgICB9IGVsc2UgaWYgKHBlbmRpbmdPcGVyYXRpb25zIDwgMCkgeworICAgICAgICBpZiAobVBlbmRpbmdPcGVyYXRpb25zID09IDAgJiYgbU5lZWRzUG9sbCkgeworICAgICAgICAgICAgbUxhc3RSZWxldmFudFBvbGwgPSBvYnRhaW5NZXNzYWdlKEVWRU5UX1BPTExfQ0FMTFNfUkVTVUxUKTsKKyAgICAgICAgICAgIG1DaS5nZXRDdXJyZW50Q2FsbHMobUxhc3RSZWxldmFudFBvbGwpOworICAgICAgICB9IGVsc2UgaWYgKG1QZW5kaW5nT3BlcmF0aW9ucyA8IDApIHsKICAgICAgICAgICAgIC8vIHRoaXMgc2hvdWxkIG5ldmVyIGhhcHBlbgogICAgICAgICAgICAgUmxvZy5lKExPR19UQUcsIkNkbWFDY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w7CiAKICAgICAgICAgICAgIC8vIHBvbGxlZENhbGwgbGlzdCBpcyBzcGFyc2UKQEAgLTUxNywyOCArNTA3LDI4IEBACiAKICAgICAgICAgICAgIGlmIChjb25uID09IG51bGwgJiYgZGMgIT0gbnVsbCkgewogICAgICAgICAgICAgICAgIC8vIENvbm5lY3Rpb24gYXBwZWFyZWQgaW4gQ0xDQyByZXNwb25zZSB0aGF0IHdlIGRvbid0IGtub3cgYWJvdXQKLSAgICAgICAgICAgICAgICBpZiAocGVuZGluZ01PICE9IG51bGwgJiYgcGVuZGluZ01PLmNvbXBhcmVUbyhkYykpIHsKKyAgICAgICAgICAgICAgICBpZiAobVBlbmRpbmdNTyAhPSBudWxsICYmIG1QZW5kaW5nTU8uY29tcGFyZVRvKGRjKSkgewogCi0gICAgICAgICAgICAgICAgICAgIGlmIChEQkdfUE9MTCkgbG9nKCJwb2xsOiBwZW5kaW5nTU89IiArIHBlbmRpbmdNTyk7CisgICAgICAgICAgICAgICAgICAgIGlmIChEQkdfUE9MTCkgbG9nKCJwb2xsOiBwZW5kaW5nTU89IiArIG1QZW5kaW5nTU8pOwogCiAgICAgICAgICAgICAgICAgICAgIC8vIEl0J3Mgb3VyIHBlbmRpbmcgbW9iaWxlIG9yaWdpbmF0aW5nIGNhbGwKLSAgICAgICAgICAgICAgICAgICAgY29ubmVjdGlvbnNbaV0gPSBwZW5kaW5nTU87Ci0gICAgICAgICAgICAgICAgICAgIHBlbmRpbmdNTy5pbmRleCA9IGk7Ci0gICAgICAgICAgICAgICAgICAgIHBlbmRpbmdNTy51cGRhdGUoZGMpOwotICAgICAgICAgICAgICAgICAgICBwZW5kaW5nTU8gPSBudWxsOworICAgICAgICAgICAgICAgICAgICBtQ29ubmVjdGlvbnNbaV0gPSBtUGVuZGluZ01POworICAgICAgICAgICAgICAgICAgICBtUGVuZGluZ01PLm1JbmRleCA9IGk7CisgICAgICAgICAgICAgICAgICAgIG1QZW5kaW5nTU8udXBkYXRlKGRjKTsKKyAgICAgICAgICAgICAgICAgICAgbVBlbmRpbmdNTyA9IG51bGw7CiAKICAgICAgICAgICAgICAgICAgICAgLy8gU29tZW9uZSBoYXMgYWxyZWFkeSBhc2tlZCB0byBoYW5ndXAgdGhpcyBjYWxsCi0gICAgICAgICAgICAgICAgICAgIGlmIChoYW5ndXBQZW5kaW5nTU8pIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGhhbmd1cFBlbmRpbmdNTyA9IGZhbHNlOworICAgICAgICAgICAgICAgICAgICBpZiAobUhhbmd1cFBlbmRpbmdNTykgeworICAgICAgICAgICAgICAgICAgICAgICAgbUhhbmd1cFBlbmRpbmdNTyA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgLy8gUmUtc3RhcnQgRWNtIHRpbWVyIHdoZW4gYW4gdW5jb21wbGV0ZWQgZW1lcmdlbmN5IGNhbGwgZW5kcwogICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1Jc0VjbVRpbWVyQ2FuY2VsZWQpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYW5kbGVFY21UaW1lcihwaG9uZS5SRVNUQVJUX0VDTV9USU1FUik7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFuZGxlRWNtVGltZXIoQ0RNQVBob25lLlJFU1RBUlRfRUNNX1RJTUVSKTsKICAgICAgICAgICAgICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoUGhvbmUuREVCVUdfUEhPTkUpIGxvZygKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJwb2xsOiBoYW5ndXBQZW5kaW5nTU8sIGhhbmd1cCBjb25uICIgKyBpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYW5ndXAoY29ubmVjdGlvbnNbaV0pOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhbmd1cChtQ29ubmVjdGlvbnNbaV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoQ2FsbFN0YXRlRXhjZXB0aW9uIGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUmxvZy5lKExPR19UQUcsICJ1bmV4cGVjdGVkIGVycm9yIG9uIGhhbmd1cCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgfQpAQCAtNTQ5LDcgKzUzOSw3IEBACiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICBpZiAoUGhvbmUuREVCVUdfUEhPTkUpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGxvZygicGVuZGluZ01vPSIgKyBwZW5kaW5nTU8gKyAiLCBkYz0iICsgZGMpOworICAgICAgICAgICAgICAgICAgICAgICAgbG9nKCJwZW5kaW5nTW89IiArIG1QZW5kaW5nTU8gKyAiLCBkYz0iICsgZGMpOwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIC8vIGZpbmQgaWYgdGhlIE1UIGNhbGwgaXMgYSBuZXcgcmluZyBvciB1bmtub3duIGNvbm5lY3Rpb24KICAgICAgICAgICAgICAgICAgICAgbmV3UmluZ2luZyA9IGNoZWNrTXRGaW5kTmV3UmluZ2luZyhkYyxpKTsKQEAgLTU2NCwzOSArNTU0LDM5IEBACiAgICAgICAgICAgICAgICAgLy8gd2UgbmVlZCB0byBjbGVhbiB1cCB0aGUgZm9yZWdyb3VuZENhbGwgYW5kIHJpbmdpbmdDYWxsLgogICAgICAgICAgICAgICAgIC8vIExvb3AgdGhyb3VnaCBmb3JlZ3JvdW5kIGNhbGwgY29ubmVjdGlvbnMgYXMKICAgICAgICAgICAgICAgICAvLyBpdCBjb250YWlucyB0aGUga25vd24gbG9naWNhbCBjb25uZWN0aW9ucy4KLSAgICAgICAgICAgICAgICBpbnQgY291bnQgPSBmb3JlZ3JvdW5kQ2FsbC5jb25uZWN0aW9ucy5zaXplKCk7CisgICAgICAgICAgICAgICAgaW50IGNvdW50ID0gbUZvcmVncm91bmRDYWxsLm1Db25uZWN0aW9ucy5zaXplKCk7CiAgICAgICAgICAgICAgICAgZm9yIChpbnQgbiA9IDA7IG4gPCBjb3VudDsgbisrKSB7CiAgICAgICAgICAgICAgICAgICAgIGlmIChQaG9uZS5ERUJVR19QSE9ORSkgbG9nKCJhZGRpbmcgZmdDYWxsIGNuICIgKyBuICsgIiB0byBkcm9wcGVkRHVyaW5nUG9sbCIpOwotICAgICAgICAgICAgICAgICAgICBDZG1hQ29ubmVjdGlvbiBjbiA9IChDZG1hQ29ubmVjdGlvbilmb3JlZ3JvdW5kQ2FsbC5jb25uZWN0aW9ucy5nZXQobik7Ci0gICAgICAgICAgICAgICAgICAgIGRyb3BwZWREdXJpbmdQb2xsLmFkZChjbik7CisgICAgICAgICAgICAgICAgICAgIENkbWFDb25uZWN0aW9uIGNuID0gKENkbWFDb25uZWN0aW9uKW1Gb3JlZ3JvdW5kQ2FsbC5tQ29ubmVjdGlvbnMuZ2V0KG4pOworICAgICAgICAgICAgICAgICAgICBtRHJvcHBlZER1cmluZ1BvbGwuYWRkKGNuKTsKICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgY291bnQgPSByaW5naW5nQ2FsbC5jb25uZWN0aW9ucy5zaXplKCk7CisgICAgICAgICAgICAgICAgY291bnQgPSBtUmluZ2luZ0NhbGwubUNvbm5lY3Rpb25zLnNpemUoKTsKICAgICAgICAgICAgICAgICAvLyBMb29wIHRocm91Z2ggcmluZ2luZyBjYWxsIGNvbm5lY3Rpb25zIGFzCiAgICAgICAgICAgICAgICAgLy8gaXQgbWF5IGNvbnRhaW4gdGhlIGtub3duIGxvZ2ljYWwgY29ubmVjdGlvbnMuCiAgICAgICAgICAgICAgICAgZm9yIChpbnQgbiA9IDA7IG4gPCBjb3VudDsgbisrKSB7CiAgICAgICAgICAgICAgICAgICAgIGlmIChQaG9uZS5ERUJVR19QSE9ORSkgbG9nKCJhZGRpbmcgcmdDYWxsIGNuICIgKyBuICsgIiB0byBkcm9wcGVkRHVyaW5nUG9sbCIpOwotICAgICAgICAgICAgICAgICAgICBDZG1hQ29ubmVjdGlvbiBjbiA9IChDZG1hQ29ubmVjdGlvbilyaW5naW5nQ2FsbC5jb25uZWN0aW9ucy5nZXQobik7Ci0gICAgICAgICAgICAgICAgICAgIGRyb3BwZWREdXJpbmdQb2xsLmFkZChjbik7CisgICAgICAgICAgICAgICAgICAgIENkbWFDb25uZWN0aW9uIGNuID0gKENkbWFDb25uZWN0aW9uKW1SaW5naW5nQ2FsbC5tQ29ubmVjdGlvbnMuZ2V0KG4pOworICAgICAgICAgICAgICAgICAgICBtRHJvcHBlZER1cmluZ1BvbGwuYWRkKGNuKTsKICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgZm9yZWdyb3VuZENhbGwuc2V0R2VuZXJpYyhmYWxzZSk7Ci0gICAgICAgICAgICAgICAgcmluZ2luZ0NhbGwuc2V0R2VuZXJpYyhmYWxzZSk7CisgICAgICAgICAgICAgICAgbUZvcmVncm91bmRDYWxsLnNldEdlbmVyaWMoZmFsc2UpOworICAgICAgICAgICAgICAgIG1SaW5naW5nQ2FsbC5zZXRHZW5lcmljKGZhbHNlKTsKIAogICAgICAgICAgICAgICAgIC8vIFJlLXN0YXJ0IEVjbSB0aW1lciB3aGVuIHRoZSBjb25uZWN0ZWQgZW1lcmdlbmN5IGNhbGwgZW5kcwogICAgICAgICAgICAgICAgIGlmIChtSXNFY21UaW1lckNhbmNlbGVkKSB7Ci0gICAgICAgICAgICAgICAgICAgIGhhbmRsZUVjbVRpbWVyKHBob25lLlJFU1RBUlRfRUNNX1RJTUVSKTsKKyAgICAgICAgICAgICAgICAgICAgaGFuZGxlRWNtVGltZXIoQ0RNQVBob25lLlJFU1RBUlRfRUNNX1RJTUVSKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgLy8gSWYgZW1lcmdlbmN5IGNhbGwgaXMgbm90IGdvaW5nIHRocm91Z2ggd2hpbGUgZGlhbGluZwogICAgICAgICAgICAgICAgIGNoZWNrQW5kRW5hYmxlRGF0YUNhbGxBZnRlckVtZXJnZW5jeUNhbGxEcm9wcGVkKCk7CiAKICAgICAgICAgICAgICAgICAvLyBEcm9wcGVkIGNvbm5lY3Rpb25zIGFyZSByZW1vdmVkIGZyb20gdGhlIENhbGxUcmFja2VyCiAgICAgICAgICAgICAgICAgLy8gbGlzdCBidXQga2VwdCBpbiB0aGUgQ2FsbCBsaXN0Ci0gICAgICAgICAgICAgICAgY29ubmVjdGlvbnNbaV0gPSBudWxsOworICAgICAgICAgICAgICAgIG1Db25uZWN0aW9uc1tpXSA9IG51bGw7CiAgICAgICAgICAgICB9IGVsc2UgaWYgKGNvbm4gIT0gbnVsbCAmJiBkYyAhPSBudWxsKSB7IC8qIGltcGxpY2l0IGNvbm4uY29tcGFyZVRvKGRjKSAqLwogICAgICAgICAgICAgICAgIC8vIENhbGwgY29sbGlzaW9uIGNhc2UKLSAgICAgICAgICAgICAgICBpZiAoY29ubi5pc0luY29taW5nICE9IGRjLmlzTVQpIHsKKyAgICAgICAgICAgICAgICBpZiAoY29ubi5tSXNJbmNvbWluZyAhPSBkYy5pc01UKSB7CiAgICAgICAgICAgICAgICAgICAgIGlmIChkYy5pc01UID09IHRydWUpewogICAgICAgICAgICAgICAgICAgICAgICAgLy8gTXQgY2FsbCB0YWtlcyBwcmVjZWRlbmNlIHRoYW4gTW8sZHJvcHMgTW8KLSAgICAgICAgICAgICAgICAgICAgICAgIGRyb3BwZWREdXJpbmdQb2xsLmFkZChjb25uKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1Ecm9wcGVkRHVyaW5nUG9sbC5hZGQoY29ubik7CiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBmaW5kIGlmIHRoZSBNVCBjYWxsIGlzIGEgbmV3IHJpbmcgb3IgdW5rbm93biBjb25uZWN0aW9uCiAgICAgICAgICAgICAgICAgICAgICAgICBuZXdSaW5naW5nID0gY2hlY2tNdEZpbmROZXdSaW5naW5nKGRjLGkpOwogICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5ld1JpbmdpbmcgPT0gbnVsbCkgewpAQCAtNjQwLDU2ICs2MzAsNTYgQEAKICAgICAgICAgLy8gVGhpcyBpcyB0aGUgZmlyc3QgcG9sbCBhZnRlciBhbiBBVEQuCiAgICAgICAgIC8vIFdlIGV4cGVjdCB0aGUgcGVuZGluZyBjYWxsIHRvIGFwcGVhciBpbiB0aGUgbGlzdAogICAgICAgICAvLyBJZiBpdCBkb2VzIG5vdCwgd2UgbGFuZCBoZXJlCi0gICAgICAgIGlmIChwZW5kaW5nTU8gIT0gbnVsbCkgeworICAgICAgICBpZiAobVBlbmRpbmdNTyAhPSBudWxsKSB7CiAgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywiUGVuZGluZyBNTyBkcm9wcGVkIGJlZm9yZSBwb2xsIGZnIHN0YXRlOiIKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICArIGZvcmVncm91bmRDYWxsLmdldFN0YXRlKCkpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgbUZvcmVncm91bmRDYWxsLmdldFN0YXRlKCkpOwogCi0gICAgICAgICAgICBkcm9wcGVkRHVyaW5nUG9sbC5hZGQocGVuZGluZ01PKTsKLSAgICAgICAgICAgIHBlbmRpbmdNTyA9IG51bGw7Ci0gICAgICAgICAgICBoYW5ndXBQZW5kaW5nTU8gPSBmYWxzZTsKLSAgICAgICAgICAgIGlmKCBwZW5kaW5nQ2FsbEluRWNtKSB7Ci0gICAgICAgICAgICAgICAgcGVuZGluZ0NhbGxJbkVjbSA9IGZhbHNlOworICAgICAgICAgICAgbURyb3BwZWREdXJpbmdQb2xsLmFkZChtUGVuZGluZ01PKTsKKyAgICAgICAgICAgIG1QZW5kaW5nTU8gPSBudWxsOworICAgICAgICAgICAgbUhhbmd1cFBlbmRpbmdNTyA9IGZhbHNlOworICAgICAgICAgICAgaWYoIG1QZW5kaW5nQ2FsbEluRWNtKSB7CisgICAgICAgICAgICAgICAgbVBlbmRpbmdDYWxsSW5FY20gPSBmYWxzZTsKICAgICAgICAgICAgIH0KICAgICAgICAgfQogCiAgICAgICAgIGlmIChuZXdSaW5naW5nICE9IG51bGwpIHsKLSAgICAgICAgICAgIHBob25lLm5vdGlmeU5ld1JpbmdpbmdDb25uZWN0aW9uKG5ld1JpbmdpbmcpOworICAgICAgICAgICAgbVBob25lLm5vdGlmeU5ld1JpbmdpbmdDb25uZWN0aW9uKG5ld1JpbmdpbmcpOwogICAgICAgICB9CiAKICAgICAgICAgLy8gY2xlYXIgdGhlICJsb2NhbCBoYW5ndXAiIGFuZCAibWlzc2VkL3JlamVjdGVkIGNhbGwiCiAgICAgICAgIC8vIGNhc2VzIGZyb20gdGhlICJkcm9wcGVkIGR1cmluZyBwb2xsIiBsaXN0CiAgICAgICAgIC8vIFRoZXNlIGNhc2VzIG5lZWQgbm8gImxhc3QgY2FsbCBmYWlsIiByZWFzb24KLSAgICAgICAgZm9yIChpbnQgaSA9IGRyb3BwZWREdXJpbmdQb2xsLnNpemUoKSAtIDE7IGkgPj0gMCA7IGktLSkgewotICAgICAgICAgICAgQ2RtYUNvbm5lY3Rpb24gY29ubiA9IGRyb3BwZWREdXJpbmdQb2xsLmdldChpKTsKKyAgICAgICAgZm9yIChpbnQgaSA9IG1Ecm9wcGVkRHVyaW5nUG9sbC5zaXplKCkgLSAxOyBpID49IDAgOyBpLS0pIHsKKyAgICAgICAgICAgIENkbWFDb25uZWN0aW9uIGNvbm4gPSBtRHJvcHBlZER1cmluZ1BvbGwuZ2V0KGkpOwogCiAgICAgICAgICAgICBpZiAoY29ubi5pc0luY29taW5nKCkgJiYgY29ubi5nZXRDb25uZWN0VGltZSgpID09IDApIHsKICAgICAgICAgICAgICAgICAvLyBNaXNzZWQgb3IgcmVqZWN0ZWQgY2FsbAogICAgICAgICAgICAgICAgIENvbm5lY3Rpb24uRGlzY29ubmVjdENhdXNlIGNhdXNlOwotICAgICAgICAgICAgICAgIGlmIChjb25uLmNhdXNlID09IENvbm5lY3Rpb24uRGlzY29ubmVjdENhdXNlLkxPQ0FMKSB7CisgICAgICAgICAgICAgICAgaWYgKGNvbm4ubUNhdXNlID09IENvbm5lY3Rpb24uRGlzY29ubmVjdENhdXNlLkxPQ0FMKSB7CiAgICAgICAgICAgICAgICAgICAgIGNhdXNlID0gQ29ubmVjdGlvbi5EaXNjb25uZWN0Q2F1c2UuSU5DT01JTkdfUkVKRUNURUQ7CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgY2F1c2UgPSBDb25uZWN0aW9uLkRpc2Nvbm5lY3RDYXVzZS5JTkNPTUlOR19NSVNTRUQ7CiAgICAgICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAgICAgaWYgKFBob25lLkRFQlVHX1BIT05FKSB7Ci0gICAgICAgICAgICAgICAgICAgIGxvZygibWlzc2VkL3JlamVjdGVkIGNhbGwsIGNvbm4uY2F1c2U9IiArIGNvbm4uY2F1c2UpOworICAgICAgICAgICAgICAgICAgICBsb2coIm1pc3NlZC9yZWplY3RlZCBjYWxsLCBjb25uLmNhdXNlPSIgKyBjb25uLm1DYXVzZSk7CiAgICAgICAgICAgICAgICAgICAgIGxvZygic2V0dGluZyBjYXVzZSB0byAiICsgY2F1c2UpOwogICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBkcm9wcGVkRHVyaW5nUG9sbC5yZW1vdmUoaSk7CisgICAgICAgICAgICAgICAgbURyb3BwZWREdXJpbmdQb2xsLnJlbW92ZShpKTsKICAgICAgICAgICAgICAgICBjb25uLm9uRGlzY29ubmVjdChjYXVzZSk7Ci0gICAgICAgICAgICB9IGVsc2UgaWYgKGNvbm4uY2F1c2UgPT0gQ29ubmVjdGlvbi5EaXNjb25uZWN0Q2F1c2UuTE9DQUwpIHsKKyAgICAgICAgICAgIH0gZWxzZSBpZiAoY29ubi5tQ2F1c2UgPT0gQ29ubmVjdGlvbi5EaXNjb25uZWN0Q2F1c2UuTE9DQUwpIHsKICAgICAgICAgICAgICAgICAvLyBMb2NhbCBoYW5ndXAKLSAgICAgICAgICAgICAgICBkcm9wcGVkRHVyaW5nUG9sbC5yZW1vdmUoaSk7CisgICAgICAgICAgICAgICAgbURyb3BwZWREdXJpbmdQb2xsLnJlbW92ZShpKTsKICAgICAgICAgICAgICAgICBjb25uLm9uRGlzY29ubmVjdChDb25uZWN0aW9uLkRpc2Nvbm5lY3RDYXVzZS5MT0NBTCk7Ci0gICAgICAgICAgICB9IGVsc2UgaWYgKGNvbm4uY2F1c2UgPT0gQ29ubmVjdGlvbi5EaXNjb25uZWN0Q2F1c2UuSU5WQUxJRF9OVU1CRVIpIHsKLSAgICAgICAgICAgICAgICBkcm9wcGVkRHVyaW5nUG9sbC5yZW1vdmUoaSk7CisgICAgICAgICAgICB9IGVsc2UgaWYgKGNvbm4ubUNhdXNlID09IENvbm5lY3Rpb24uRGlzY29ubmVjdENhdXNlLklOVkFMSURfTlVNQkVSKSB7CisgICAgICAgICAgICAgICAgbURyb3BwZWREdXJpbmdQb2xsLnJlbW92ZShpKTsKICAgICAgICAgICAgICAgICBjb25uLm9uRGlzY29ubmVjdChDb25uZWN0aW9uLkRpc2Nvbm5lY3RDYXVzZS5JTlZBTElEX05VTUJFUik7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KIAogICAgICAgICAvLyBBbnkgbm9uLWxvY2FsIGRpc2Nvbm5lY3RzOiBkZXRlcm1pbmUgY2F1c2UKLSAgICAgICAgaWYgKGRyb3BwZWREdXJpbmdQb2xsLnNpemUoKSA+IDApIHsKLSAgICAgICAgICAgIGNtLmdldExhc3RDYWxsRmFpbENhdXNlKAorICAgICAgICBpZiAobURyb3BwZWREdXJpbmdQb2xsLnNpemUoKSA+IDApIHsKKyAgICAgICAgICAgIG1DaS5nZXRMYXN0Q2FsbEZhaWxDYXVzZSgKICAgICAgIC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ChjYWxsID09IHJpbmdpbmdDYWxsKSB7CisgICAgICAgIGlmIChjYWxsID09IG1SaW5naW5nQ2FsbCkgewogICAgICAgICAgICAgaWYgKFBob25lLkRFQlVHX1BIT05FKSBsb2coIihyaW5naW5nKSBoYW5ndXAgd2FpdGluZyBvciBiYWNrZ3JvdW5kIik7Ci0gICAgICAgICAgICBjbS5oYW5ndXBXYWl0aW5nT3JCYWNrZ3JvdW5kKG9idGFpbkNvbXBsZXRlTWVzc2FnZSgpKTsKLSAgICAgICAgfSBlbHNlIGlmIChjYWxsID09IGZvcmVncm91bmRDYWxsKSB7CisgICAgICAgICAgICBtQ2kuaGFuZ3VwV2FpdGluZ09yQmFja2dyb3VuZChvYnRhaW5Db21wbGV0ZU1lc3NhZ2UoKSk7CisgICAgICAgIH0gZWxzZSBpZiAoY2FsbCA9PSBtRm9yZWdyb3VuZENhbGwpIHsKICAgICAgICAgICAgIGlmIChjYWxsLmlzRGlhbGluZ09yQWxlcnRpbmcoKSkgewogICAgICAgICAgICAgICAgIGlmIChQaG9uZS5ERUJVR19QSE9ORSkgewogICAgICAgICAgICAgICAgICAgICBsb2coIihmb3JlZ25kKSBoYW5ndXAgZGlhbGluZyBvciBhbGVydGluZy4uLiIpOwpAQCAtODE1LDggKzgwNSw4IEBACiAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgIGhhbmd1cEZvcmVncm91bmRSZXN1bWVCYWNrZ3JvdW5kKCk7CiAgICAgICAgICAgICB9Ci0gICAgICAgIH0gZWxzZSBpZiAoY2FsbCA9PSBiYWNrZ3JvdW5kQ2FsbCkgewotICAgICAgICAgICAgaWYgKHJpbmdpbmdDYWxsLmlzUmluZ2luZygpKSB7CisgICAgICAgIH0gZWxzZSBpZiAoY2FsbCA9PSBtQmFja2dyb3VuZENhbGwpIHsKKyAgICAgICAgICAgIGlmIChtUmluZ2luZ0NhbGwuaXNSaW5naW5nKCkpIHsKICAgICAgICAgICAgICAgICBpZiAoUGhvbmUuREVC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IGhhbmd1cENvbm5lY3Rpb25CeUluZGV4KENkbWFDYWxsIGNhbGwsIGludCBpbmRleCkKICAgICAgICAgICAgIHRocm93cyBDYWxsU3RhdGVFeGNlcHRpb24gewotICAgICAgICBpbnQgY291bnQgPSBjYWxsLmNvbm5lY3Rpb25zLnNpemUoKTsKKyAgICAgICAgaW50IGNvdW50ID0gY2FsbC5tQ29ubmVjdGlvbnMuc2l6ZSgpOwogICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IGNvdW50OyBpKyspIHsKLSAgICAgICAgICAgIENkbWFDb25uZWN0aW9uIGNuID0gKENkbWFDb25uZWN0aW9uKWNhbGwuY29ubmVjdGlvbnMuZ2V0KGkpOworICAgICAgICAgICAgQ2RtYUNvbm5lY3Rpb24gY24gPSAoQ2RtYUNvbm5lY3Rpb24pY2FsbC5tQ29ubmVjdGlvbnMuZ2V0KGkpOwogICAgICAgICAgICAgaWYgKGNuLmdldENETUFJbmRleCgpID09IGluZGV4KSB7Ci0gICAgICAgICAgICAgICAgY20uaGFuZ3VwQ29ubmVjdGlvbihpbmRleCwgb2J0YWluQ29tcGxldGVNZXNzYWdlKCkpOworICAgICAgICAgICAgICAgIG1DaS5oYW5ndXBDb25uZWN0aW9uKGluZGV4LCBvYnRhaW5Db21wbGV0ZU1lc3NhZ2UoKSk7CiAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgfQogICAgICAgICB9CkBAIC04NTksMTIgKzg0OSwxMiBAQAogICAgICAgICB0aHJvdyBuZXcgQ2FsbFN0YXRlRXhjZXB0aW9uKCJubyBnc20gaW5kZXggZm91bmQiKTsKICAgICB9CiAKLSAgICB2b2lkIGhhbmd1cEFsbENvbm5lY3Rpb25zKENkbWFDYWxsIGNhbGwpIHRocm93cyBDYWxsU3RhdGVFeGNlcHRpb257CisgICAgdm9pZCBoYW5ndXBBbGxDb25uZWN0aW9ucyhDZG1hQ2FsbCBjYWxsKSB7CiAgICAgICAgIHRyeSB7Ci0gICAgICAgICAgICBpbnQgY291bnQgPSBjYWxsLmNvbm5lY3Rpb25zLnNpemUoKTsKKyAgICAgICAgICAgIGludCBjb3VudCA9IGNhbGwubUNvbm5lY3Rpb25zLnNpemUoKTsKICAgICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgY291bnQ7IGkrKykgewotICAgICAgICAgICAgICAgIENkbWFDb25uZWN0aW9uIGNuID0gKENkbWFDb25uZWN0aW9uKWNhbGwuY29ubmVjdGlvbnMuZ2V0KGkpOwotICAgICAgICAgICAgICAgIGNtLmhhbmd1cENvbm5lY3Rpb24oY24uZ2V0Q0RNQUluZGV4KCksIG9idGFpbkNvbXBsZXRlTWVzc2FnZSgpKTsKKyAgICAgICAgICAgICAgICBDZG1hQ29ubmVjdGlvbiBjbiA9IChDZG1hQ29ubmVjdGlvbiljYWxsLm1Db25uZWN0aW9ucy5nZXQoaSk7CisgICAgICAgICAgICAgICAgbUNpLmhhbmd1cENvbm5lY3Rpb24oY24uZ2V0Q0RNQUluZGV4KCksIG9idGFpbkNvbXBsZXRlTWVzc2FnZSgpKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfSBjYXRjaCAoQ2FsbFN0YXRlRXhjZXB0aW9uIGV4KSB7CiAgICAgICAgICAgICBSbG9nLmUoTE9HX1RBRywgImhhbmd1cENvbm5lY3Rpb25CeUluZGV4IGNhdWdodCAiICsgZXgpOwpAQCAtODc0LDkgKzg2NCw5IEBACiAgICAgLyogcGFja2FnZSAqLwogICAgIENkbWFDb25uZWN0aW9uIGdldENvbm5lY3Rpb25CeUluZGV4KENkbWFDYWxsIGNhbGwsIGludCBpbmRleCkKICAgICAgICAgICAgIHRocm93cyBDYWxsU3RhdGVFeGNlcHRpb24gewotICAgICAgICBpbnQgY291bnQgPSBjYWxsLmNvbm5lY3Rpb25zLnNpemUoKTsKKyAgICAgICAgaW50IGNvdW50ID0gY2FsbC5tQ29ubmVjdGlvbnMuc2l6ZSgpOwogICAgICAgICBmb3IgKGludCBpID0gMD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KCksIGN3LCB0aGlzLCByaW5naW5nQ2FsbCk7CisgICAgICAgIG1SaW5naW5nQ2FsbC5zZXRHZW5lcmljKGZhbHNlKTsKKyAgICAgICAgbmV3IENkbWFDb25uZWN0aW9uKG1QaG9uZS5nZXRDb250ZXh0KCksIGN3LCB0aGlzLCBtUmluZ2luZ0NhbGwpOwogICAgICAgICB1cGRhdGVQaG9uZVN0YXRlKCk7CiAKICAgICAgICAgLy8gRmluYWxseSBub3RpZnkgYXBwbGljYXRpb24KQEAgLTk0Myw2ICs5MTksNyBAQAogICAgIH0KICAgICAvLyoqKioqKiBPdmVycmlkZGVuIGZyb20gSGFuZGxlcgogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQKICAgICBoYW5kbGVNZXNzYWdlIChNZXNzYWdlIG1zZykgewogICAgICAgICBBc3luY1Jlc3VsdCBhcjsKQEAgLTk1MiwxMSArOTI5LDExIEBACiAgICAgICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsICJFdmVudCBFVkVOVF9QT0xMX0NBTExTX1JFU1VMVCBSZWNlaXZlZCIpOwogICAgICAgICAgICAgICAgIGFyID0gKEFzeW5jUmVzdWx0KW1zZy5vYmo7CiAKLSAgICAgICAgICAgICAgICBpZihtc2cgPT0gbGFzdFJlbGV2YW50UG9sbCkgeworICAgICAgICAgICAgICAgIGlmKG1zZyA9PSBtTGFzdFJlbGV2YW50UG9sbCkgewogICAgICAgICAgICAgICAgICAgICBpZihEQkdfUE9MTCkgbG9nKAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICJoYW5kbGUgRVZFTlRfUE9MTF9DQUxMX1JFU1VMVDogc2V0IG5lZWRzUG9sbD1GIik7Ci0gICAgICAgICAgICAgICAgICAgIG5lZWRzUG9sbCA9IGZhbHNlOwotICAgICAgICAgICAgICAgICAgICBsYXN0UmVsZXZhbnRQb2xsID0gbnVsbDsKKyAgICAgICAgICAgICAgICAgICAgbU5lZWRzUG9sbCA9IGZhbHNlOworICAgICAgICAgICAgICAgICAgICBtTGFzdFJlbGV2YW50UG9sbCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgIGhhbmRsZVBvbGxDYWxscygoQXN5bmNSZXN1bHQpbXNnLm9iaik7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQpAQCAtOTg4LDE4ICs5NjUsMTggQEAKICAgICAgICAgICAgICAgICAgICAgY2F1c2VDb2RlID0gKChpbnRbXSlhci5yZXN1bHQpWzBdOwogICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgICAgIGZvciAoaW50IGkgPSAwLCBzID0gIGRyb3BwZWREdXJpbmdQb2xsLnNpemUoKQorICAgICAgICAgICAgICAgIGZvciAoaW50IGkgPSAwLCBzID0gIG1Ecm9wcGVkRHVyaW5nUG9sbC5zaXplKCkKICAgICAgICAgICAgICAgICAgICAgICAgIDsgaSA8IHMgOyBpKysKICAgICAgICAgICAgICAgICApIHsKLSAgICAgICAgICAgICAgICAgICAgQ2RtYUNvbm5lY3Rpb24gY29ubiA9IGRyb3BwZWREdXJpbmdQb2xsLmdldChpKTsKKyAgICAgICAgICAgICAgICAgICAgQ2RtYUNvbm5lY3Rpb24gY29ubiA9IG1Ecm9wcGVkRHVyaW5nUG9sbC5nZXQoaSk7CiAKICAgICAgICAgICAgICAgICAgICAgY29ubi5vblJlbW90ZURpc2Nvbm5lY3QoY2F1c2VDb2RlKTsKICAgICAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgICAgICB1cGRhdGVQaG9uZVN0YXRlKCk7CiAKLSAgICAgICAgICAgICAgICBwaG9uZS5ub3RpZnlQcmVjaXNlQ2FsbFN0YXRlQ2hhbmdlZCgpOwotICAgICAgICAgICAgICAgIGRyb3BwZWREdXJpbmdQb2xsLmNsZWFyKCk7CisgICAgICAgICAgICAgICAgbVBob25lLm5vdGlmeVByZWNpc2VDYWxsU3RhdGVDaGFuZ2VkKCk7CisgICAgICAgICAgICAgICAgbURyb3BwZWREdXJpbmdQb2xsLmNsZWFyKCk7CiAgICAgICAgICAgICBicmVhazsKIAogICAgICAgICAgICAgY2FzZSBFVkVOVF9SRVBPTExfQUZURVJfREVMQVk6CkBAIC0xMDE3LDExICs5OTQsMTEgQEAKIAogICAgICAgICAgICAgY2FzZSBFVkVOVF9FWElUX0VDTV9SRVNQT05TRV9DRE1BOgogICAgICAgICAgICAgICAgLy9ubyBtYXR0ZXIgdGhlIHJlc3VsdCwgd2Ugc3RpbGwgZG8gdGhlIHNhbWUgaGVyZQotICAgICAgICAgICAgICAgaWYgKHBlbmRpbmdDYWxsSW5FY20pIHsKLSAgICAgICAgICAgICAgICAgICBjbS5kaWFsKHBlbmRpbmdNTy5hZGRyZXNzLCBwZW5kaW5nQ2FsbENsaXJNb2RlLCBvYnRhaW5Db21wbGV0ZU1lc3NhZ2UoKSk7Ci0gICAgICAgICAgICAgICAgICAgcGVuZGluZ0NhbGxJbkVjbSA9IGZhbHNlOworICAgICAgICAgICAgICAgaWYgKG1QZW5kaW5nQ2FsbEluRWNtKSB7CisgICAgICAgICAgICAgICAgICAgbUNpLmRpYWwobVBlbmRpbmdNTy5tQWRkcmVzcywgbVBlbmRpbmdDYWxsQ2xpck1vZGUsIG9idGFpbkNvbXBsZXRlTWVzc2FnZSgpKTsKKyAgICAgICAgICAgICAgICAgICBtUGVuZGluZ0NhbGxJbkVjbSA9IGZhbHNlOwogICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgcGhvbmUudW5zZXRPbkVjYk1vZGVFeGl0UmVzcG9uc2UodGhpcyk7CisgICAgICAgICAgICAgICBtUGhvbmUudW5zZXRPbkVjYk1vZGVFeGl0UmVzcG9uc2UodGhpcyk7CiAgICAgICAgICAgICBicmVhazsKIAogICAgICAgICAgICAgY2FzZSBFVkVOVF9DQUxMX1dBSVRJTkdfSU5GT19DRE1BOgpAQCAtMTAzNiw4ICsxMDEzLDggQEAKICAgICAgICAgICAgICAgICBhciA9IChBc3luY1Jlc3VsdCltc2cub2JqOwogICAgICAgICAgICAgICAgIGlmIChhci5leGNlcHRpb24gPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAvLyBBc3N1bWUgMyB3YXkgY2FsbCBpcyBjb25uZWN0ZWQKLSAgICAgICAgICAgICAgICAgICAgcGVuZGluZ01PLm9uQ29ubmVjdGVkSW5Pck91dCgpOwotICAgICAgICAgICAgICAgICAgICBwZW5kaW5nTU8gPSBudWxsOworICAgICAgICAgICAgICAgICAgICBtUGVuZGluZ01PLm9uQ29ubmVjdGVkSW5Pck91dCgpOworICAgICAgICAgICAgICAgICAgICBtUGVuZGluZ01PID0gbnVsbDsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICBicmVhazsKIApAQCAtMTA1MSw3ICsxMDI4LDcgQEAKICAgICAgKiBIYW5kbGUgRWNtIHRpbWVyIHRvIGJlIGNhbmNlbGVkIG9yIHJlLXN0YXJ0ZWQKICAgICAgKi8KICAgICBwcml2YXRlIHZvaWQgaGFuZGxlRWNtVGltZXIoaW50IGFjdGlvbikgewotICAgICAgICBwaG9uZS5oYW5kbGVUaW1lckluRW1lcmdlbmN5Q2FsbGJhY2tNb2RlKGFjdGlvbik7CisgICAgICAgIG1QaG9uZS5oYW5kbGVUaW1lckluRW1lcmdlbmN5Q2FsbGJhY2tNb2RlKGFjdGlvbik7CiAgICAgICAgIHN3aXRjaChhY3Rpb24pIHsKICAgICAgICAgY2FzZSBDRE1BUGhvbmUuQ0FOQ0VMX0VDTV9USU1FUjogbUlzRWNtVGltZXJDYW5jZWxlZCA9IHRydWU7IGJyZWFrOwogICAgICAgICBjYXNlIENETUFQaG9uZS5SRVNUQVJUX0VDTV9USU1FUjogbUlzRWNtVGltZXJDYW5jZWxlZCA9IGZhbHNlOyBicmVhazsKQEAgLTEwNjQsMTAgKzEwNDEsMTAgQEAKICAgICAgKiBEaXNhYmxlIGRhdGEgY2FsbCB3aGVuIGVtZXJnZW5jeSBjYWxsIGlzIGNvbm5lY3RlZAogICAgICAqLwogICAgIHByaXZhdGU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WRJbk9yT3V0KCk7CisgICAgICAgICAgICAgICAgbUNvbm5lY3Rpb25zW2ldLm9uQ29ubmVjdGVkSW5Pck91dCgpOwogICAgICAgICAgICAgICAgIGlmIChkYy5zdGF0ZSA9PSBEcml2ZXJDYWxsLlN0YXRlLkhPTERJTkcpIHsKICAgICAgICAgICAgICAgICAgICAgLy8gV2UndmUgdHJhbnNpdGlvbmVkIGludG8gSE9MRElORwotICAgICAgICAgICAgICAgICAgICBjb25uZWN0aW9uc1tpXS5vblN0YXJ0ZWRIb2xkaW5nKCk7CisgICAgICAgICAgICAgICAgICAgIG1Db25uZWN0aW9uc1tpXS5vblN0YXJ0ZWRIb2xkaW5nKCk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogICAgICAgICB9CkBAIC0xMTMyLDYgKzExMDksNyBAQAogICAgICAgICByZXR1cm4gbUlzSW5FbWVyZ2VuY3lDYWxsOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHByb3RlY3RlZCB2b2lkIGxvZyhTdHJpbmcgbXNnKSB7CiAgICAgICAgIFJsb2cuZChMT0dfVEFHLCAiW0NkbWFDYWxsVHJhY2tlcl0gIiArIG1zZyk7CiAgICAgfQpAQCAtMTE0MCwyOCArMTExOCwyOCBAQAogICAgIHB1YmxpYyB2b2lkIGR1bXAoRmlsZURlc2NyaXB0b3IgZmQsIFByaW50V3JpdGVyIHB3LCBTdHJpbmdbXSBhcmdzKSB7CiAgICAgICAgIHB3LnByaW50bG4oIkdzbUNhbGxUcmFja2VyIGV4dGVuZHM6Iik7CiAgICAgICAgIHN1cGVyLmR1bXAoZmQsIHB3LCBhcmdzKTsKLSAgICAgICAgcHcucHJpbnRsbigiZHJvcHBlZER1cmluZ1BvbGw6IGxlbmd0aD0iICsgY29ubmVjdGlvbnMubGVuZ3RoKTsKLSAgICAgICAgZm9yKGludCBpPTA7IGkgPCBjb25uZWN0aW9ucy5sZW5ndGg7IGkrKykgewotICAgICAgICAgICAgcHcucHJpb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ICAgICBhZGRyZXNzID0gZGMubnVtYmVyOworICAgICAgICBtQWRkcmVzcyA9IGRjLm51bWJlcjsKIAotICAgICAgICBpc0luY29taW5nID0gZGMuaXNNVDsKLSAgICAgICAgY3JlYXRlVGltZSA9IFN5c3RlbS5jdXJyZW50VGltZU1pbGxpcygpOwotICAgICAgICBjbmFwTmFtZSA9IGRjLm5hbWU7Ci0gICAgICAgIGNuYXBOYW1lUHJlc2VudGF0aW9uID0gZGMubmFtZVByZXNlbnRhdGlvbjsKLSAgICAgICAgbnVtYmVyUHJlc2VudGF0aW9uID0gZGMubnVtYmVyUHJlc2VudGF0aW9uOworICAgICAgICBtSXNJbmNvbWluZyA9IGRjLmlzTVQ7CisgICAgICAgIG1DcmVhdGVUaW1lID0gU3lzdGVtLmN1cnJlbnRUaW1lTWlsbGlzKCk7CisgICAgICAgIG1DbmFwTmFtZSA9IGRjLm5hbWU7CisgICAgICAgIG1DbmFwTmFtZVByZXNlbnRhdGlvbiA9IGRjLm5hbWVQcmVzZW50YXRpb247CisgICAgICAgIG1OdW1iZXJQcmVzZW50YXRpb24gPSBkYy5udW1iZXJQcmVzZW50YXRpb247CiAKLSAgICAgICAgdGhpcy5pbmRleCA9IGluZGV4OworICAgICAgICBtSW5kZXggPSBpbmRleDsKIAotICAgICAgICBwYXJlbnQgPSBwYXJlbnRGcm9tRENTdGF0ZSAoZGMuc3RhdGUpOwotICAgICAgICBwYXJlbnQuYXR0YWNoKHRoaXMsIGRjKTsKKyAgICAgICAgbVBhcmVudCA9IHBhcmVudEZyb21EQ1N0YXRlIChkYy5zdGF0ZSk7CisgICAgICAgIG1QYXJlbnQuYXR0YWNoKHRoaXMsIGRjKTsKICAgICB9CiAKICAgICAvKiogVGhpcyBpcyBhbiBNTyBjYWxsL3RocmVlIHdheSBjYWxsLCBjcmVhdGVkIHdoZW4gZGlhbGluZyAqLwpAQCAtMTQ1LDMwICsxNDcsMzAgQEAKICAgICAgICAgY3JlYXRlV2FrZUxvY2soY29udGV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BQ1RJVkUpOwogICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICBwYXJlbnQuYXR0YWNoRmFrZSh0aGlzLCBDZG1hQ2FsbC5TdGF0ZS5ESUFMSU5HKTsKQEAgLTE4MiwxNyArMTg0LDE3IEBACiAgICAgICAgIGNyZWF0ZVdha2VMb2NrKGNvbnRleHQpOwogICAgICAgICBhY3F1aXJlV2FrZUxvY2soKTsKIAotICAgICAgICBvd25lciA9IGN0OwotICAgICAgICBoID0gbmV3IE15SGFuZGxlcihvd25lci5nZXRMb29wZXIoKSk7Ci0gICAgICAgIGFkZHJlc3MgPSBjdy5udW1iZXI7Ci0gICAgICAgIG51bWJlclByZXNlbnRhdGlvbiA9IGN3Lm51bWJlclByZXNlbnRhdGlvbjsKLSAgICAgICAgY25hcE5hbWUgPSBjdy5uYW1lOwotICAgICAgICBjbmFwTmFtZVByZXNlbnRhdGlvbiA9IGN3Lm5hbWVQcmVzZW50YXRpb247Ci0gICAgICAgIGluZGV4ID0gLTE7Ci0gICAgICAgIGlzSW5jb21pbmcgPSB0cnVlOwotICAgICAgICBjcmVhdGVUaW1lID0gU3lzdGVtLmN1cnJlbnRUaW1lTWlsbGlzKCk7Ci0gICAgICAgIGNvbm5lY3RUaW1lID0gMDsKLSAgICAgICAgdGhpcy5wYXJlbnQgPSBwYXJlbnQ7CisgICAgICAgIG1Pd25lciA9IGN0OworICAgICAgICBtSGFuZGxlciA9IG5ldyBNeUhhbmRsZXIobU93bmVyLmdldExvb3BlcigpKTsKKyAgICAgICAgbUFkZHJlc3MgPSBjdy5udW1iZXI7CisgICAgICAgIG1OdW1iZXJQcmVzZW50YXRpb24gPSBjdy5udW1iZXJQcmVzZW50YXRpb247CisgICAgICAgIG1DbmFwTmFtZSA9IGN3Lm5hbWU7CisgICAgICAgIG1DbmFwTmFtZVByZXNlbnRhdGlvbiA9IGN3Lm5hbWVQcmVzZW50YXRpb247CisgICAgICAgIG1JbmRleCA9IC0xOworICAgICAgICB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IGVxdWFsc0hhbmRsZXNOdWxscyhtQWRkcmVzcywgY0FkZHJlc3MpOwogICAgIH0KIAogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFN0cmluZyBnZXRPcmlnRGlhbFN0cmluZygpewotICAgICAgICByZXR1cm4gZGlhbFN0cmluZzsKKyAgICAgICAgcmV0dXJuIG1EaWFsU3RyaW5nOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdHJpbmcgZ2V0QWRkcmVzcygpIHsKLSAgICAgICAgcmV0dXJuIGFkZHJlc3M7CisgICAgICAgIHJldHVybiBtQWRkcmVzczsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgQ2RtYUNhbGwgZ2V0Q2FsbCgpIHsKLSAgICAgICAgcmV0dXJuIHBhcmVudDsKKyAgICAgICAgcmV0dXJuIG1QYXJlbnQ7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGxvbmcgZ2V0Q3JlYXRlVGltZSgpIHsKLSAgICAgICAgcmV0dXJuIGNyZWF0ZVRpbWU7CisgICAgICAgIHJldHVybiBtQ3JlYXRlVGltZTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgbG9uZyBnZXRDb25uZWN0VGltZSgpIHsKLSAgICAgICAgcmV0dXJuIGNvbm5lY3RUaW1lOworICAgICAgICByZXR1cm4gbUNvbm5lY3RUaW1lOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBsb25nIGdldERpc2Nvbm5lY3RUaW1lKCkgewotICAgICAgICByZXR1cm4gZGlzY29ubmVjdFRpbWU7CisgICAgICAgIHJldHVybiBtRGlzY29ubmVjdFRpbWU7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGxvbmcgZ2V0RHVyYXRpb25NaWxsaXMoKSB7Ci0gICAgICAgIGlmIChjb25uZWN0VGltZVJlYWwgPT0gMCkgeworICAgICAgICBpZiAobUNvbm5lY3RUaW1lUmVhbCA9PSAwKSB7CiAgICAgICAgICAgICByZXR1cm4gMDsKLSAgICAgICAgfSBlbHNlIGlmIChkdXJhdGlvbiA9PSAwKSB7Ci0gICAgICAgICAgICByZXR1cm4gU3lzdGVtQ2xvY2suZWxhcHNlZFJlYWx0aW1lKCkgLSBjb25uZWN0VGltZVJlYWw7CisgICAgICAgIH0gZWxzZSBpZiAobUR1cmF0aW9uID09IDApIHsKKyAgICAgICAgICAgIHJldHVybiBTeXN0ZW1DbG9jay5lbGFwc2VkUmVhbHRpbWUoKSAtIG1Db25uZWN0VGltZVJlYWw7CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICByZXR1cm4gZHVyYXRpb247CisgICAgICAgICAgICByZXR1cm4gbUR1cmF0aW9uOwogICAgICAgICB9CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGxvbmcgZ2V0SG9sZER1cmF0aW9uTWlsbGlzKCkgewogICAgICAgICBpZiAoZ2V0U3RhdGUoKSAhPSBDZG1hQ2FsbC5TdGF0ZS5IT0xESU5HKSB7CiAgICAgICAgICAgICAvLyBJZiBub3QgaG9sZGluZywgcmV0dXJuIDAKICAgICAgICAgICAgIHJldHVybiAwOwogICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgcmV0dXJuIFN5c3RlbUNsb2NrLmVsYXBzZWRSZWFsdGltZSgpIC0gaG9sZGluZ1N0YXJ0VGltZTsKKyAgICAgICAgICAgIHJldHVybiBTeXN0ZW1DbG9jay5lbGFwc2VkUmVhbHRpbWUoKSAtIG1Ib2xkaW5nU3RhcnRUaW1lOwogICAgICAgICB9CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIERpc2Nvbm5lY3RDYXVzZSBnZXREaXNjb25uZWN0Q2F1c2UoKSB7Ci0gICAgICAgIHJldHVybiBjYXVzZTsKKyAgICAgICAgcmV0dXJuIG1DYXVzZTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgYm9vbGVhbiBpc0luY29taW5nKCkgewotICAgICAgICByZXR1cm4gaXNJbmNvbWluZzsKKyAgICAgICAgcmV0dXJuIG1Jc0luY29taW5nOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBDZG1hQ2FsbC5TdGF0ZSBnZXRTdGF0ZSgpIHsKLSAgICAgICAgaWYgKGRpc2Nvbm5lY3RlZCkgeworICAgICAgICBpZiAobURpc2Nvbm5lY3RlZCkgewogICAgICAgICAgICAgcmV0dXJuIENkbWFDYWxsLlN0YXRlLkRJU0NPTk5FQ1RFRDsKICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIHJldHVybiBzdXBlci5nZXRTdGF0ZSgpOwogICAgICAgICB9CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgaGFuZ3VwKCkgdGhyb3dzIENhbGxTdGF0ZUV4Y2VwdGlvbiB7Ci0gICAgICAgIGlmICghZGlzY29ubmVjdGVkKSB7Ci0gICAgICAgICAgICBvd25lci5oYW5ndXAodGhpcyk7CisgICAgICAgIGlmICghbURpc2Nvbm5lY3RlZCkgeworICAgICAgICAgICAgbU93bmVyLmhhbmd1cCh0aGlzKTsKICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIHRocm93IG5ldyBDYWxsU3RhdGVFeGNlcHRpb24gKCJkaXNjb25uZWN0ZWQiKTsKICAgICAgICAgfQogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHNlcGFyYXRlKCkgdGhyb3dzIENhbGxTdGF0ZUV4Y2VwdGlvbiB7Ci0gICAgICAgIGlmICghZGlzY29ubmVjdGVkKSB7Ci0gICAgICAgICAgICBvd25lci5zZXBhcmF0ZSh0aGlzKTsKKyAgICAgICAgaWYgKCFtRGlzY29ubmVjdGVkKSB7CisgICAgICAgICAgICBtT3duZXIuc2VwYXJhdGUodGhpcyk7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gPSBoLm9idGFpbk1lc3NhZ2UoRVZFTlRfRFRNRl9ET05FKTsKLSAgICAgICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgICAgICBpZiAoUGhvbmVOdW1iZXJVdGlscy5pczEyS2V5KGMpKSB7Ci0gICAgICAgICAgICAgICAgICAgIG93bmVyLmNtLnNlbmREdG1mKGMsIG1zZyk7Ci0gICAgICAgICAgICAgICAgICAgIHBsYXllZFRvbmUgPSB0cnVlOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIH0KLQotICAgICAgICAgICAgaWYgKCFwbGF5ZWRUb25lKSB7Ci0gICAgICAgICAgICAgICAgcHJvY2Vzc05leHRQb3N0RGlhbENoYXIoKTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgIC8vIG1ha2UgYSBuZXcgcG9zdERpYWxTdHJpbmcsIHdpdGggdGhlIHdpbGQgY2hhciByZXBsYWNlbWVudCBzdHJpbmcKLSAgICAgICAgICAgIC8vIGF0IHRoZSBiZWdpbm5pbmcsIGZvbGxvd2VkIGJ5IHRoZSByZW1haW5pbmcgcG9zdERpYWxTdHJpbmcuCi0KLSAgICAgICAgICAgIFN0cmluZ0J1aWxkZXIgYnVmID0gbmV3IFN0cmluZ0J1aWxkZXIoc3RyKTsKLSAgICAgICAgICAgIGJ1Zi5hcHBlbmQocG9zdERpYWxTdHJpbmcuc3Vic3RyaW5nKG5leHRQb3N0RGlhbENoYXIpKTsKLSAgICAgICAgICAgIHBvc3REaWFsU3RyaW5nID0gYnVmLnRvU3RyaW5nKCk7Ci0gICAgICAgICAgICBuZXh0UG9zdERpYWxDaGFyID0gMDsKLSAgICAgICAgICAgIGlmIChQaG9uZS5ERUJVR19QSE9ORSkgewotICAgICAgICAgICAgICAgIGxvZygicHJvY2VlZEFmdGVyV2lsZENoYXI6IG5ldyBwb3N0RGlhbFN0cmluZyBpcyAiICsKLSAgICAgICAgICAgICAgICAgICAgICAgIHBvc3REaWFsU3RyaW5nKTsKLSAgICAgICAgICAgIH0KLQotICAgICAgICAgICAgcHJvY2Vzc05leHRQb3N0RGlhbENoYXIoKTsKKyAgICAgICAgU3RyaW5nQnVpbGRlciBidWYgPSBuZXcgU3RyaW5nQnVpbGRlcihzdHIpOworICAgICAgICBidWYuYXBwZW5kKG1Qb3N0RGlhbFN0cmluZy5zdWJzdHJpbmcobU5leHRQb3N0RGlhbENoYXIpKTsKKyAgICAgICAgbVBvc3REaWFsU3RyaW5nID0gYnVmLnRvU3RyaW5nKCk7CisgICAgICAgIG1OZXh0UG9zdERpYWxDaGFyID0gMDsKKyAgICAgICAgaWYgKFBob25lLkRFQlVHX1BIT05FKSB7CisgICAgICAgICAgICBsb2coInByb2NlZWRBZnRlcldpbGRDaGFyOiBuZXcgcG9zdERpYWxTdHJpbmcgaXMgIiArCisgICAgICAgICAgICAgICAgICAgIG1Qb3N0RGlhbFN0cmluZyk7CiAgICAgICAgIH0KKworICAgICAgICBwcm9jZXNzTmV4dFBvc3REaWFsQ2hhcigpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIGNhbmNlbFBvc3REaWFsKCkgewogICAgICAgICBzZXRQb3N0RGlhbFN0YXRlKFBvc3REaWFsU3RhdGUuQ0FOQ0VMTEVEKTsKICAgICB9CkBAIC0zNzAsNyArMzY2LDcgQEAKICAgICAgKi8KICAgICB2b2lkCiAgICAgb25IYW5ndXBMb2NhbCgpIHsKLSAgICAgICAgY2F1c2UgPSBEaXNjb25uZWN0Q2F1c2UuTE9DQUw7CisgICAgICAgIG1DYXVzZSA9IERpc2Nvbm5lY3RDYXVzZS5MT0NBTDsKICAgICB9CiAKICAgICBEaXNjb25uZWN0Q2F1c2UKQEAgLTQxNCw3ICs0MTAsNyBAQAogICAgICAgICAgICAgY2FzZSBDYWxsRmFpbENhdXNlLkVSUk9SX1VOU1BFQ0lGSUVEOgogICAgICAgICAgICAgY2FzZSBDYWxsRmFpbENhdXNlLk5PUk1BTF9DTEVBUklORzoKICAgICAgICAgICAgIGRlZmF1bHQ6Ci0gICAgICAgICAgICAgICAgQ0RNQVBob25lIHBob25lID0gb3duZXIucGhvbmU7CisgICAgICAgICAgICAgICAgQ0RNQVBob25lIHBob25lID0gbU93bmVyLm1QaG9uZTsKICAgICAgICAgICAgICAgICBpbnQgc2VydmljZVN0YXRlID0gcGhvbmUuZ2V0U2VydmljZVN0YXRlKCkuZ2V0U3RhdGUoKTsKICAgICAgICAgICAgICAgICBVaWNjQ2FyZEFwcGxpY2F0aW9uIGFwcCA9IFVpY2NDb250cm9sbGVyCiAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0SW5zdGFuY2UoKQpAQCAtNDQ1LDE3ICs0NDEsMTYgQEAKICAgICAvKiogQ2FsbGVkIHdoZW4gdGhlIHJhZGlvIGluZGljYXRlcyB0aGUgY29ubmVjdGlvbiBoYXMgYmVlbiBkaXNjb25uZWN0ZWQgKi8KICAgICAvKnBhY2thZ2UqLyB2b2lkCiAgICAgb25EaXNjb25uZWN0KERpc2Nvbm5lY3RDYXVzZSBjYXVzZSkgewotICAgICAgICB0aGlzLmNhdXNlID0gY2F1c2U7CisgICAgICAgIG1DYXVzZSA9IGNhdXNlOwogCi0gICAgICAgIGlmICghZGlzY29ubmVjdGVkKSB7CisgICAgICAgIGlmICghbURpc2Nvbm5lY3RlZCkgewogICAgICAgICAgICAgZG9EaXNjb25uZWN0KCk7Ci0gICAgICAgICAgICBpZiAoZmFsc2UpIFJsb2cuZChMT0dfVEFHLAotICAgICAgICAgICAgICAgICAgICAiW0NETUFDb25uXSBvbkRpc2Nvbm5lY3Q6IGNhdXNlPSIgKyBjYXVzZSk7CisgICAgICAgICAgICBpZiAoVkRCRykgUmxvZy5kKExPR19UQUcsICJvbkRpc2Nvbm5lY3Q6IGNhdXNlPSIgKyBjYXVzZSk7CiAKLSAgICAgICAgICAgIG93bmVyLnBob25lLm5vdGlmeURpc2Nvbm5lY3QodGhpcyk7CisgICAgICAgICAgICBtT3duZXIubVBob25lLm5vdGlmeURpc2Nvbm5lY3QodGhpcyk7CiAKLSAgICAgICAgICAgIGlmIChwYXJlbnQgIT0gbnVsbCkgewotICAgICAgICAgICAgICAgIHBhcmVudC5jb25uZWN0aW9uRGlzY29ubmVjdGVkKHRoaXMpOworICAgICAgICAgICAgaWYgKG1QYXJlbnQgIT0gbnVsbCkgeworICAgICAgICAgICAgICAgIG1QYXJlbnQuY29ubmVjdGlvbkRpc2Nvbm5lY3RlZCh0aGlzKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfQogICAgICAgICByZWxlYXNlV2FrZUxvY2soKTsKQEAgLTQ2NCwxMyArNDU5LDEyIEBACiAgICAgLyoqIENhbGxlZCB3aGVuIHRoZSBjYWxsIHdhaXRpbmcgY29ubmVjdGlvbiBoYXMgYmVlbiBodW5nIHVwICovCiAgICAgLypwYWNrYWdlKi8gdm9pZAogICAgIG9uTG9jYWxEaXNjb25uZWN0KCkgewotICAgICAgICBpZiAoIWRpc2Nvbm5lY3RlZCkgeworICAgICAgICBpZiAoIW1EaXNjb25uZWN0ZWQpIHsKICAgICAgICAgICAgIGRvRGlzY29ubmVjdCgpOwotICAgICAgICAgICAgaWYgKGZhbHNlKSBSbG9nLmQoTE9HX1RBRywKLSAgICAgICAgICAgICAgICAgICAgIltDRE1BQ29ubl0gb25Mb2FsRGlzY29ubmVjdCIgKTsKKyAgICAgICAgICAgIGlmIChWREJHKSBSbG9nLmQoTE9HX1RBRywgIm9uTG9hbERpc2Nvbm5lY3QiICk7CiAKLSAgICAgICAgICAgIGlmIChwYXJlbnQgIT0gbnVsbCkgewotICAgICAgICAgICAgICAgIHBhcmVudC5kZXRhY2godGhpcyk7CisgICAgICAgICAgICBpZiAobVBhcmVudCAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgbVBhcmVudC5kZXRhY2godGhpcyk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICAgICAgcmVsZWFzZVdha2VMb2NrKCk7CkBAIC00ODYsMzkgKzQ4MCwzOSBAQAogCiAgICAgICAgIG5ld1BhcmVudCA9IHBhcmVudEZyb21EQ1N0YXRlKGRjLnN0YXRlKTsKIAotICAgICAgICBpZiAoUGhvbmUuREVCVUdfUEhPTkUpIGxvZygicGFyZW50PSAiICtwYXJlbnQgKyIsIG5ld1BhcmVudD0gIiArIG5ld1BhcmVudCk7CisgICAgICAgIGlmIChQaG9uZS5ERUJVR19QSE9ORSkgbG9nKCJwYXJlbnQ9ICIgK21QYXJlbnQgKyIsIG5ld1BhcmVudD0gIiArIG5ld1BhcmVudCk7CiAKLSAgICAgICAgaWYgKCFlcXVhbHNIYW5kbGVzTnVsbHMoYWRkcmVzcywgZGMubnVtYmVyKSkgeworICAgICAgICBpZiAoIWVxdWFsc0hhbmRsZXNOdWxscyhtQWRkcmVzcywgZGMubnVtYmVyKSkgewogICAgICAgICAgICAgaWYgKFBob25lLkRFQlVHX1BIT05FKSBsb2coInVwZGF0ZTogcGhvbmUgIyBjaGFuZ2VkISIpOwotICAgICAgICAgICAgYWRkcmVzcyA9IGRjLm51bWJlcjsKKyAgICAgICAgICAgIG1BZGRyZXNzID0gZGMubnVtYmVyOwogICAgICAgICAgICAgY2hhbmdlZCA9IHRydWU7CiAgICAgICAgIH0KIAogICAgICAgICAvLyBBIG51bGwgY25hcE5hbWUgc2hvdWxkIGJlIHRoZSBzYW1lIGFzICIiCiAgICAgICAgIGlmIChUZXh0VXRpbHMuaXNFbXB0eShkYy5uYW1lKSkgewotICAgICAgICAgICAgaWYgKCFUZXh0VXRpbHMuaXNFbXB0eShjbmFwTmFtZSkpIHsKKyAgICAgICAgICAgIGlmICghVGV4dFV0aWxzLmlzRW1wdHkobUNuYXBOYW1lKSkgewogICAgICAgICAgICAgICAgIGNoYW5nZWQgPSB0cnVlOwotICAgICAgICAgICAgICAgIGNuYXBOYW1lID0gIiI7CisgICAgICAgICAgICAgICAgbUNuYXBOYW1lID0gIiI7CiAgICAgICAgICAgICB9Ci0gICAgICAgIH0gZWxzZSBpZiAoIWRjLm5hbWUuZXF1YWxzKGNuYXBOYW1lKSkgeworICAgICAgICB9IGVsc2UgaWYgKCFkYy5uYW1lLmVxdWFscyhtQ25hcE5hbWUpKSB7CiAgICAgICAgICAgICBjaGFuZ2VkID0gdHJ1ZTsKLSAgICAgICAgICAgIGNuYXBOYW1lID0gZGMubmFtZTsKKyAgICAgICAgICAgIG1DbmFwTmFtZSA9IGRjLm5hbWU7CiAgICAgICAgIH0KIAotICAgICAgICBpZiAoUGhvbmUuREVCVUdfUEhPTkUpIGxvZygiLS1kc3Nkcy0tLS0iK2NuYXBOYW1lKTsKLSAgICAgICAgY25hcE5hbWVQcmVzZW50YXRpb24gPSBkYy5uYW1lUHJlc2VudGF0aW9uOwotICAgICAgICBudW1iZXJQcmVzZW50YXRpb24gPSBkYy5udW1iZXJQcmVzZW50YXRpb247CisgICAgICAgIGlmIChQaG9uZS5ERUJVR19QSE9ORSkgbG9nKCItLWRzc2RzLS0tLSIrbUNuYXBOYW1lKTsKKyAgICAgICAgbUNuYXBOYW1lUHJlc2VudGF0aW9uID0gZGMubmFtZVByZXNlbnRhdGlvbjsKKyAgICAgICAgbU51bWJlclByZXNlbnRhdGlvbiA9IGRjLm51bWJlclByZXNlbnRhdGlvbjsKIAotICAgICAgICBpZiAobmV3UGFyZW50ICE9IHBhcmVudCkgewotICAgICAgICAgICAgaWYgKHBhcmVudCAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgcGFyZW50LmRldGFjaCh0aGlzKTsKKyAgICAgICAgaWYgKG5ld1BhcmVudCAhPSBtUGFyZW50KSB7CisgICAgICAgICAgICBpZiAobVBhcmVudCAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgbVBhcmVudC5kZXRhY2godGhpcyk7CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBuZXdQYXJlbnQuYXR0YWNoKHRoaXMsIGRjKTsKLSAgICAgICAgICAgIHBhcmVudCA9IG5ld1BhcmVudDsK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AgICAgIGlmIChpbmRleCA+PSAwKSB7Ci0gICAgICAgICAgICByZXR1cm4gaW5kZXggKyAxOworICAgICAgICBpZiAobUluZGV4ID49IDApIHsKKyAgICAgICAgICAgIHJldHVybiBtSW5kZXggKyAxOwogICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgdGhyb3cgbmV3IENhbGxTdGF0ZUV4Y2VwdGlvbiAoIkNETUEgY29ubmVjdGlvbiBpbmRleCBub3QgYXNzaWduZWQiKTsKICAgICAgICAgfQpAQCAtNTc1LDE3ICs1NjksMTcgQEAKICAgICAgKi8KICAgICB2b2lkCiAgICAgb25Db25uZWN0ZWRJbk9yT3V0KCkgewotICAgICAgICBjb25uZWN0VGltZSA9IFN5c3RlbS5jdXJyZW50VGltZU1pbGxpcygpOwotICAgICAgICBjb25uZWN0VGltZVJlYWwgPSBTeXN0ZW1DbG9jay5lbGFwc2VkUmVhbHRpbWUoKTsKLSAgICAgICAgZHVyYXRpb24gPSAwOworICAgICAgICBtQ29ubmVjdFRpbWUgPSBTeXN0ZW0uY3VycmVudFRpbWVNaWxsaXMoKTsKKyAgICAgICAgbUNvbm5lY3RUaW1lUmVhbCA9IFN5c3RlbUNsb2NrLmVsYXBzZWRSZWFsdGltZSgpOworICAgICAgICBtRHVyYXRpb24gPSAwOwogCiAgICAgICAgIC8vIGJ1ZyAjNjc4NDc0OiBpbmNvbWluZyBjYWxsIGludGVycHJldGVkIGFzIG1pc3NlZCBjYWxsLCBldmVuIHRob3VnaAogICAgICAgICAvLyBpdCBzb3VuZHMgbGlrZSB0aGUgdXNlciBoYXMgcGlja2VkIHVwIHRoZSBjYWxsLgogICAgICAgICBpZiAoUGhvbmUuREVCVUdfUEhPTkUpIHsKLSAgICAgICAgICAgIGxvZygib25Db25uZWN0ZWRJbk9yT3V0OiBjb25uZWN0VGltZT0iICsgY29ubmVjdFRpbWUpOworICAgICAgICAgICAgbG9nKCJvbkNvbm5lY3RlZEluT3JPdXQ6IGNvbm5lY3RUaW1lPS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zdC1kaWFsIGNoYXIsIGJ1dCBkb2VzIG5vdApAQCAtNjE1LDE0ICs2MDksMTQgQEAKICAgICBwcml2YXRlIGJvb2xlYW4KICAgICBwcm9jZXNzUG9zdERpYWxDaGFyKGNoYXIgYykgewogICAgICAgICBpZiAoUGhvbmVOdW1iZXJVdGlscy5pczEyS2V5KGMpKSB7Ci0gICAgICAgICAgICBvd25lci5jbS5zZW5kRHRtZihjLCBoLm9idGFpbk1lc3NhZ2UoRVZFTlRfRFRNRl9ET05FKSk7CisgICAgICAgICAgICBtT3duZXIubUNpLnNlbmREdG1mKGMsIG1IYW5kbGVyLm9idGFpbk1lc3NhZ2UoRVZFTlRfRFRNRl9ET05FKSk7CiAgICAgICAgIH0gZWxzZSBpZiAoYyA9PSBQaG9uZU51bWJlclV0aWxzLlBBVVNFKSB7CiAgICAgICAgICAgICBzZXRQb3N0RGlhbFN0YXRlKFBvc3REaWFsU3RhdGUuUEFVU0UpOwogCiAgICAgICAgICAgICAvLyBVcG9uIG9jY3VycmVuY2VzIG9mIHRoZSBzZXBhcmF0b3IsIHRoZSBVRSBzaGFsbAogICAgICAgICAgICAgLy8gcGF1c2UgYWdhaW4gZm9yIDIgc2Vjb25kcyBiZWZvcmUgc2VuZGluZyBhbnkKICAgICAgICAgICAgIC8vIGZ1cnRoZXIgRFRNRiBkaWdpdHMuCi0gICAgICAgICAgICBoLnNlbmRNZXNzYWdlRGVsYXllZChoLm9idGFpbk1lc3NhZ2UoRVZFTlRfUEFVU0VfRE9ORSksCisgICAgICAgICAgICBtSGFuZGxlci5zZW5kTWVzc2FnZURlbGF5ZWQobUhhbmRsZXIub2J0YWluTWVzc2FnZShFVkVOVF9QQVVTRV9ET05FKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUEFVU0VfREVMQVlfTUlMTElTKTsKICAgICAgICAgfSBlbHNlIGlmIChjID09IFBob25lTnVtYmVyVXRpbHMuV0FJVCkgewogICAgICAgICAgICAgc2V0UG9zdERpYWxTdGF0ZShQb3N0RGlhbFN0YXRlLldBSVQpOwpAQCAtNjM1LDE1ICs2MjksMTYgQEAKICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFN0cmluZyBnZXRSZW1haW5pbmdQb3N0RGlhbFN0cmluZygpIHsKLSAgICAgICAgaWYgKHBvc3REaWFsU3RhdGUgPT0gUG9zdERpYWxTdGF0ZS5DQU5DRUxMRUQKLSAgICAgICAgICAgICAgICB8fCBwb3N0RGlhbFN0YXRlID09IFBvc3REaWFsU3RhdGUuQ09NUExFVEUKLSAgICAgICAgICAgICAgICB8fCBwb3N0RGlhbFN0cmluZyA9PSBudWxsCi0gICAgICAgICAgICAgICAgfHwgcG9zdERpYWxTdHJpbmcubGVuZ3RoKCkgPD0gbmV4dFBvc3REaWFsQ2hhcikgeworICAgICAgICBpZiAobVBvc3REaWFsU3RhdGUgPT0gUG9zdERpYWxTdGF0ZS5DQU5DRUxMRUQKKyAgICAgICAgICAgICAgICB8fCBtUG9zdERpYWxTdGF0ZSA9PSBQb3N0RGlhbFN0YXRlLkNPTVBMRVRFCisgICAgICAgICAgICAgICAgfHwgbVBvc3REaWFsU3RyaW5nID09IG51bGwKKyAgICAgICAgICAgICAgICB8fCBtUG9zdERpYWxTdHJpbmcubGVuZ3RoKCkgPD0gbU5leHRQb3N0RGlhbENoYXIpIHsKICAgICAgICAgICAgIHJldHVybiAiIjsKICAgICAgICAgfQogCi0gICAgICAgIFN0cmluZyBzdWJTdHIgPSBwb3N0RGlhbFN0cmluZy5zdWJzdHJpbmcobmV4dFBvc3REaWFsQ2hhcik7CisgICAgICAgIFN0cmluZyBzdWJTdHIgPSBtUG9zdERpYWxTdHJpbmcuc3Vic3RyaW5nKG1OZXh0UG9zdERpYWxDaGFyKTsKICAgICAgICAgaWYgKHN1YlN0ciAhPSBudWxsKSB7CiAgICAgICAgICAgICBpbnQgd0luZGV4ID0gc3ViU3RyLmluZGV4T2YoUGhvbmVOdW1iZXJVdGlscy5XQUlUKTsKICAgICAgICAgICAgIGludCBwSW5kZXggPSBzdWJTdHIuaW5kZXhPZihQaG9uZU51bWJlclV0aWxzLlBBVVNFKTsKQEAgLTY2Myw3ICs2NTgsNyBAQAogICAgICAgICAgICAgICAgIG9sZFBhcmVudC5kZXRhY2godGhpcyk7CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBuZXdQYXJlbnQuYXR0YWNoRmFrZSh0aGlzLCBDZG1hQ2FsbC5TdGF0ZS5BQ1RJVkUpOwotICAgICAgICAgICAgcGFyZW50ID0gbmV3UGFyZW50OworICAgICAgICAgICAgbVBhcmVudCA9IG5ld1BhcmVudDsKICAgICAgICAgfQogICAgIH0KIApAQCAtNjg2LDE0ICs2ODEsMTQgQEAKICAgICAgICAgY2hhciBjID0gMDsKICAgICAgICAgUmVnaXN0cmFudCBwb3N0RGlhbEhhbmRsZXI7CiAKLSAgICAgICAgaWYgKHBvc3REaWFsU3RhdGUgPT0gUG9zdERpYWxTdGF0ZS5DQU5DRUxMRUQpIHsKKyAgICAgICAgaWYgKG1Qb3N0RGlhbFN0YXRlID09IFBvc3REaWFsU3RhdGUuQ0FOQ0VMTEVEKSB7CiAgICAgICAgICAgICByZWxlYXNlV2FrZUxvY2soKTsKICAgICAgICAgICAgIC8vUmxvZy52KCJDRE1BIiwgIiMjIyMjIHByb2Nlc3NOZXh0UG9zdERpYWxDaGFyOiBwb3N0RGlhbFN0YXRlID09IENBTkNFTExFRCwgYmFpbCIpOwogICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICB9CiAKLSAgICAgICAgaWYgKHBvc3REaWFsU3RyaW5nID09IG51bGwgfHwKLSAgICAgICAgICAgICAgICBwb3N0RGlhbFN0cmluZy5sZW5ndGgoKSA8PSBuZXh0UG9zdERpYWxDaGFyKSB7CisgICAgICAgIGlmIChtUG9zdERpYWxTdHJpbmcgPT0gbnVsbCB8fAorICAgICAgICAgICAgICAgIG1Qb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ICAgICAgICB9CiAgICAgICAgIH0KIAotICAgICAgICBwb3N0RGlhbEhhbmRsZXIgPSBvd25lci5waG9uZS5tUG9zdERpYWxIYW5kbGVyOworICAgICAgICBwb3N0RGlhbEhhbmRsZXIgPSBtT3duZXIubVBob25lLm1Qb3N0RGlhbEhhbmRsZXI7CiAKICAgICAgICAgTWVzc2FnZSBub3RpZnlNZXNzYWdlOwogCiAgICAgICAgIGlmIChwb3N0RGlhbEhhbmRsZXIgIT0gbnVsbCAmJgogICAgICAgICAgICAgICAgIChub3RpZnlNZXNzYWdlID0gcG9zdERpYWxIYW5kbGVyLm1lc3NhZ2VGb3JSZWdpc3RyYW50KCkpICE9IG51bGwpIHsKICAgICAgICAgICAgIC8vIFRoZSBBc3luY1Jlc3VsdC5yZXN1bHQgaXMgdGhlIENvbm5lY3Rpb24gb2JqZWN0Ci0gICAgICAgICAgICBQb3N0RGlhbFN0YXRlIHN0YXRlID0gcG9zdERpYWxTdGF0ZTsKKyAgICAgICAgICAgIFBvc3REaWFsU3RhdGUgc3RhdGUgPSBtUG9zdERpYWxTdGF0ZTsKICAgICAgICAgICAgIEFzeW5jUmVzdWx0IGFyID0gQXN5bmNSZXN1bHQuZm9yTWVzc2FnZShub3RpZnlNZXNzYWdlKTsKICAgICAgICAgICAgIGFyLnJlc3VsdCA9IHRoaXM7CiAgICAgICAgICAgICBhci51c2VyT2JqID0gc3RhdGU7CkBAIC03NDQsOSArNzM5LDkgQEAKICAgICAgKi8KICAgICBwcml2YXRlIGJvb2xlYW4KICAgICBpc0Nvbm5lY3RpbmdJbk9yT3V0KCkgewotICAgICAgICByZXR1cm4gcGFyZW50ID09IG51bGwgfHwgcGFyZW50ID09IG93bmVyLnJpbmdpbmdDYWxsCi0gICAgICAgICAgICB8fCBwYXJlbnQuc3RhdGUgPT0gQ2RtYUNhbGwuU3RhdGUuRElBTElORwotICAgICAgICAgICAgfHwgcGFyZW50LnN0YXRlID09IENkbWFDYWxsLlN0YXRlLkFMRVJUSU5HOworICAgICAgICByZXR1cm4gbVBhcmVudCA9PSBudWxsIHx8IG1QYXJlbnQgPT0gbU93bmVyLm1SaW5naW5nQ2FsbAorICAgICAgICAgICAgfHwgbVBhcmVudC5tU3RhdGUgPT0gQ2RtYUNhbGwuU3RhdGUuRElBTElORworICAgICAgICAgICAgfHwgbVBhcmVudC5tU3RhdGUgPT0gQ2RtYUNhbGwuU3RhdGUuQUxFUlRJTkc7CiAgICAgfQogCiAgICAgcHJpdmF0ZSBDZG1hQ2FsbApAQCAtNzU1LDE2ICs3NTAsMTYgQEAKICAgICAgICAgICAgIGNhc2UgQUNUSVZFOgogICAgICAgICAgICAgY2FzZSBESUFMSU5HOgogICAgICAgICAgICAgY2FzZSBBTEVSVElORzoKLSAgICAgICAgICAgICAgICByZXR1cm4gb3duZXIuZm9yZWdyb3VuZENhbGw7CisgICAgICAgICAgICAgICAgcmV0dXJuIG1Pd25lci5tRm9yZWdyb3VuZENhbGw7CiAgICAgICAgICAgICAvL2JyZWFrOwogCiAgICAgICAgICAgICBjYXNlIEhPTERJTkc6Ci0gICAgICAgICAgICAgICAgcmV0dXJuIG93bmVyLmJhY2tncm91bmRDYWxsOworICAgICAgICAgICAgICAgIHJldHVybiBtT3duZXIubUJhY2tncm91bmRDYWxsOwogICAgICAgICAgICAgLy9icmVhazsKIAogICAgICAgICAgICAgY2FzZSBJTkNPTUlORzoKICAgICAgICAgICAgIGNhc2UgV0FJVElORzoKLSAgICAgICAgICAgICAgICByZXR1cm4gb3duZXIucmluZ2luZ0NhbGw7CisgICAgICAgICAgICAgICAgcmV0dXJuIG1Pd25lci5tUmluZ2luZ0NhbGw7CiAgICAgICAgICAgICAvL2JyZWFrOwogCiAgICAgICAgICAgICBkZWZhdWx0OgpAQCAtNzgzLDE4ICs3NzgsMTggQEAKICAgICAgICAgICAgICAgICBzID09IFBvc3REaWFsU3RhdGUuUEFVU0UpIHsKICAgICAgICAgICAgIHN5bmNocm9uaXplZCAobVBhcnRpYWxXYWtlTG9jaykgewogICAgICAgICAgICAgICAgIGlmIChtUGFydGlhbFdha2VMb2NrLmlzSGVsZCgpKSB7Ci0gICAgICAgICAgICAgICAgICAgIGgucmVtb3ZlTWVzc2FnZXMoRVZFTlRfV0FLRV9MT0NLX1RJTUVPVVQpOworICAgICAgICAgICAgICAgICAgICBtSGFuZGxlci5yZW1vdmVNZXNzYWdlcyhFVkVOVF9XQUtFX0xPQ0tfVElNRU9VVCk7CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgYWNxdWlyZVdha2VMb2NrKCk7CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIE1lc3NhZ2UgbXNnID0gaC5vYnRhaW5NZXNzYWdlKEVWRU5UX1dBS0VfTE9DS19USU1FT1VUKTsKLSAgICAgICAgICAgICAgICBoLnNlbmRNZXNzYWdlRGVsYXllZChtc2csIFdBS0VfTE9DS19USU1FT1VUX01JTExJUyk7CisgICAgICAgICAgICAgICAgTWVzc2FnZSBtc2cgPSBtSGFuZGxlci5vYnRhaW5NZXNzYWdlKEVWRU5UX1dBS0VfTE9DS19USU1FT1VUKTsKKyAgICAgICAgICAgICAgICBtSGFuZGxlci5zZW5kTWVzc2FnZURlbGF5ZWQobXNnLCBXQUtFX0xPQ0tfVElNRU9VVF9NSUxMSVMpOwogICAgICAgICAgICAgfQogICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgaC5yZW1vdmVNZXNzYWdlcyhFVkVOVF9XQUtFX0xPQ0tfVElNRU9VVCk7CisgICAgICAgICAgICBtSGFuZGxlci5yZW1vdmVNZXNzYWdlcyhFVkVOVF9XQUtFX0xPQ0tfVElNRU9VVCk7CiAgICAgICAgICAgICByZWxlYXNlV2FrZUxvY2soKTsKICAgICAgICAgfQotICAgICAgICBwb3N0RGlhbFN0YXRlID0gczsKKyAgICAgICAgbVBvc3REaWFsU3RhdGUgPSBzOwogICAgIH0KIAogICAgIHByaXZhdGUgdm9pZCBjcmVhdGV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SAgICAgICAgfQotCi0gICAgICAgIGludCBwc1N0YXRlID0gbUNkbWFQaG9uZS5tU1NULmdldEN1cnJlbnREYXRhQ29ubmVjdGlvblN0YXRlKCk7Ci0gICAgICAgIGJvb2xlYW4gcm9hbWluZyA9IChtUGhvbmUuZ2V0U2VydmljZVN0YXRlKCkuZ2V0Um9hbWluZygpICYmICFnZXREYXRhT25Sb2FtaW5nRW5hYmxlZCgpKTsKLSAgICAgICAgYm9vbGVhbiBkZXNpcmVkUG93ZXJTdGF0ZSA9IG1DZG1hUGhvbmUubVNTVC5nZXREZXNpcmVkUG93ZXJTdGF0ZSgpOwotICAgICAgICBib29sZWFuIHN1YnNjcmlwdGlvbkZyb21OdiA9IChtQ2RtYVNTTS5nZXRDZG1hU3Vic2NyaXB0aW9uU291cmNlKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID09IENkbWFTdWJzY3JpcHRpb25Tb3VyY2VNYW5hZ2VyLlNVQlNDUklQVElPTl9GUk9NX05WKTsKLQotICAgICAgICBJY2NSZWNvcmRzIHIgPSBtSWNjUmVjb3Jkcy5nZXQoKTsKLSAgICAgICAgYm9vbGVhbiBhbGxvd2VkID0KLSAgICAgICAgICAgICAgICAgICAgKHBzU3RhdGUgPT0gU2VydmljZVN0YXRlLlNUQVRFX0lOX1NFUlZJQ0UgfHwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBtQXV0b0F0dGFjaE9uQ3JlYXRpb24pICYmCi0gICAgICAgICAgICAgICAgICAgIChzdWJzY3JpcHRpb25Gcm9tTnYgfHwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAociAhPSBudWxsICYmIHIuZ2V0UmVjb3Jkc0xvYWRlZCgpKSkgJiYKLSAgICAgICAgICAgICAgICAgICAgKG1DZG1hUGhvbmUubVNTVC5pc0NvbmN1cnJlbnRWb2ljZUFuZERhdGFBbGxvd2VkKCkgfHwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBtUGhvbmUuZ2V0U3RhdGUoKSA9PVBob25lQ29uc3RhbnRzLlN0YXRlLklETEUpICYmCi0gICAgICAgICAgICAgICAgICAgICFyb2FtaW5nICYmCi0gICAgICAgICAgICAgICAgICAgIGludGVybmFsRGF0YUVuYWJsZWQgJiYKLSAgICAgICAgICAgICAgICAgICAgZGVzaXJlZFBvd2VyU3RhdGUgJiYKLSAgICAgICAgICAgICAgICAgICAgIW1QZW5kaW5nUmVzdGFydFJhZGlvICYmCi0gICAgICAgICAgICAgICAgICAgICgobVBob25lLmdldEx0ZU9uQ2RtYU1vZGUoKSA9PVBob25lQ29uc3RhbnRzLkxURV9PTl9DRE1BX1RSVUUpIHx8Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgIW1DZG1hUGhvbmUubmVlZHNPdGFTZXJ2aWNlUHJvdmlzaW9uaW5nKCkpOwotICAgICAgICBpZiAoIWFsbG93ZWQgJiYgREJHKSB7Ci0gICAgICAgICAgICBTdHJpbmcgcmVhc29uID0gIiI7Ci0gICAgICAgICAgICBpZiAoISgocHNTdGF0ZSA9PSBTZXJ2aWNlU3RhdGUuU1RBVEVfSU5fU0VSVklDRSkgfHwgbUF1dG9BdHRhY2hPbkNyZWF0aW9uKSkgewotICAgICAgICAgICAgICAgIHJlYXNvbiArPSAiIC0gcHNTdGF0ZT0gIiArIHBzU3RhdGU7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBpZiAoIXN1YnNjcmlwdGlvbkZyb21OdiAmJgotICAgICAgICAgICAgICAgICAgICAhKHIgIT0gbnVsbCAmJiByLmdldFJlY29yZHNMb2FkZWQoKSkpIHsKLSAgICAgICAgICAgICAgICByZWFzb24gKz0gIiAtIFJVSU0gbm90IGxvYWRlZCI7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBpZiAoIShtQ2RtYVBob25lLm1TU1QuaXNDb25jdXJyZW50Vm9pY2VBbmREYXRhQWxsb3dlZCgpIHx8Ci0gICAgICAgICAgICAgICAgICAgIG1QaG9uZ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LSAgICAgKiAgICAgICAgICAgICAgbXVsdGlwbGUgQVBOIHR5cGVzIGFyZSBhc3NvY2lhdGVkIHdpdGggaXQuCi0gICAgICovCi0gICAgcHJpdmF0ZSB2b2lkIGNsZWFuVXBDb25uZWN0aW9uKGJvb2xlYW4gdGVhckRvd24sIFN0cmluZyByZWFzb24sIGJvb2xlYW4gZG9BbGwpIHsKLSAgICAgICAgaWYgKERCRykgbG9nKCJjbGVhblVwQ29ubmVjdGlvbjogcmVhc29uOiAiICsgcmVhc29uKTsKLQotICAgICAgICAvLyBDbGVhciB0aGUgcmVjb25uZWN0IGFsYXJtLCBpZiBzZXQuCi0gICAgICAgIGlmIChtUmVjb25uZWN0SW50ZW50ICE9IG51bGwpIHsKLSAgICAgICAgICAgIEFsYXJtTWFuYWdlciBhbSA9Ci0gICAgICAgICAgICAgICAgKEFsYXJtTWFuYWdlcikgbVBob25lLmdldENvbnRleHQoKS5nZXRTeXN0ZW1TZXJ2aWNlKENvbnRleHQuQUxBUk1fU0VSVklDRSk7Ci0gICAgICAgICAgICBhbS5jYW5jZWwobVJlY29ubmVjdEludGVudCk7Ci0gICAgICAgICAgICBtUmVjb25uZWN0SW50ZW50ID0gbnVsbDsKLSAgICAgICAgfQotCi0gICAgICAgIHNldFN0YXRlKERjdENvbnN0YW50cy5TdGF0ZS5ESVNDT05ORUNUSU5HKTsKLSAgICAgICAgbm90aWZ5T2ZmQXBuc09mQXZhaWxhYmlsaXR5KHJlYXNvbik7Ci0KLSAgICAgICAgYm9vbGVhbiBub3RpZmljYXRpb25EZWZlcnJlZCA9IGZhbHNlOwotICAgICAgICBmb3IgKERhdGFDb25uZWN0aW9uIGNvbm4gOiBtRGF0YUNvbm5lY3Rpb25zLnZhbHVlcygpKSB7Ci0gICAgICAgICAgICBpZihjb25uICE9IG51bGwpIHsKLSAgICAgICAgICAgICAgICBEYXRhQ29ubmVjdGlvbkFjIGRjYWMgPQotICAgICAgICAgICAgICAgICAgICBtRGF0YUNvbm5lY3Rpb25Bc3luY0NoYW5uZWxzLmdldChjb25uLmdldERhdGFDb25uZWN0aW9uSWQoKSk7Ci0gICAgICAgICAgICAgICAgaWYgKHRlYXJEb3duKSB7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChkb0FsbCkgewotICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJjbGVhblVwQ29ubmVjdGlvbjogdGVhcmRvd24sIGNvbm4udGVhckRvd25BbGwiKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGNvbm4udGVhckRvd25BbGwocmVhc29uLCBvYnRhaW5NZXNzYWdlKERjdENvbnN0YW50cy5FVkVOVF9ESVNDT05ORUNUX0RPTkUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbm4uZ2V0RGF0YUNvbm5lY3Rpb25JZCgpLCAwLCByZWFzb24pKTsKLSAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygiY2xlYW5VcENvbm5lY3Rpb246IHRlYXJkb3duLCBjb25uLnRlYXJEb3duIik7Ci0gICAgICAgICAgICAgICAgICAgICAgICBjb25uLnRlYXJEb3duKHJlYXNvbiwgb2J0YWluTWVzc2FnZShEY3RDb25zdGFudHMuRVZFTlRfRElTQ09OTkVDVF9ET05FLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25uLmdldERhdGFDb25uZWN0aW9uSWQoKSwgMCwgcmVhc29uKSk7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgbm90aWZpY2F0aW9uRGVmZXJyZWQgPSB0cnVlOwotICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygiY2xlYW5VcENvbm5lY3Rpb246ICF0ZWFyRG93biwgY2FsbCBjb25uLnJlc2V0U3luY2hyb25vdXNseSIpOwotICAgICAgICAgICAgICAgICAgICBpZiAoZGNhYyAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBkY2FjLnJlc2V0U3luYygpOwotICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgIG5vdGlmaWNhdGlvbkRlZmVycmVkID0gZmFsc2U7Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgfQotICAgICAgICB9Ci0KLSAgICAgICAgc3RvcE5ldFN0YXRQb2xsKCk7Ci0gICAgICAgIHN0b3BEYXRhU3RhbGxBbGFybSgpOwotCi0gICAgICAgIGlmICghbm90aWZpY2F0aW9uRGVmZXJyZWQpIHsKLSAgICAgICAgICAgIGlmIChEQkcpIGxvZygiY2xlYW51cENvbm5lY3Rpb246ICFub3RpZmljYXRpb25EZWZlcnJlZCIpOwotICAgICAgICAgICAgZ290b0lkbGVBbmROb3RpZnlEYXRhQ29ubmVjdGlvbihyZWFzb24pOwotICAgICAgICB9Ci0gICAgfQotCi0gICAgcHJpdmF0ZSBDZG1hRGF0YUNvbm5lY3Rpb24gZmluZEZyZWVEYXRhQ29ubmVjdGlvbigpIHsKLSAgICAgICAgZm9yIChEYXRhQ29ubmVjdGlvbkFjIGRjYWMgOiBtRGF0YUNvbm5lY3Rpb25Bc3luY0NoYW5uZWxzLnZhbHVlcygpKSB7Ci0gICAgICAgICAgICBpZiAoZGNhYy5pc0luYWN0aXZlU3luYygpKSB7Ci0gICAgICAgICAgICAgICAgbG9nKCJmb3VuZCBmcmVlIEdzbURhdGFDb25uZWN0aW9uIik7Ci0gICAgICAgICAgICAgICAgcmV0dXJuIChDZG1hRGF0YUNvbm5lY3Rpb24pIGRjYWMuZGF0YUNvbm5lY3Rpb247Ci0gICAgICAgICAgICB9Ci0gICAgICAgIH0KLSAgICAgICAgbG9nKCJOTyBmcmVlIENkbWFEYXRhQ29ubmVjdGlvbiIpOwotICAgICAgICByZXR1cm4gbnVsbDsKLSAgICB9Ci0KLSAgICBwcml2YXRlIGJvb2xlYW4gc2V0d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JlYXNvbik7Ci0KLSAgICAgICAgICAgIGlmICghc2hvdWxkUG9zdE5vdGlmaWNhdGlvbihsYXN0RmFpbENhdXNlQ29kZSkpIHsKLSAgICAgICAgICAgICAgICBsb2coIk5PVCBQb3N0aW5nIERhdGEgQ29ubmVjdGlvbiBVbmF2YWlsYWJsZSBub3RpZmljYXRpb24gIgotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArICItLSBsaWtlbHkgdHJhbnNpZW50IGVycm9yIik7Ci0gICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgIG5vdGlmeU5vRGF0YShsYXN0RmFpbENhdXNlQ29kZSk7Ci0gICAgICAgICAgICB9Ci0gICAgICAgIH0KLSAgICB9Ci0KLSAgICBwcml2YXRlIHZvaWQgc3RhcnRBbGFybUZvclJlY29ubmVjdChpbnQgZGVsYXksIFN0cmluZyByZWFzb24pIHsKLQotICAgICAgICBsb2coIkRhdGEgQ29ubmVjdGlvbiBhY3RpdmF0ZSBmYWlsZWQuIFNjaGVkdWxpbmcgbmV4dCBhdHRlbXB0IGZvciAiCi0gICAgICAgICAgICAgICAgKyAoZGVsYXkgLyAxMDAwKSArICJzIik7Ci0KLSAgICAgICAgQWxhcm1NYW5hZ2VyIGFtID0KLSAgICAgICAgICAgIChBbGFybU1hbmFnZXIpIG1QaG9uZS5nZXRDb250ZXh0KCkuZ2V0U3lzdGVtU2VydmljZShDb250ZXh0LkFMQVJNX1NFUlZJQ0UpOwotICAgICAgICBJbnRlbnQgaW50ZW50ID0gbmV3IEludGVudChJTlRFTlRfUkVDT05ORUNUX0FMQVJNKTsKLSAgICAgICAgaW50ZW50LnB1dEV4dHJhKElOVEVOVF9SRUNPTk5FQ1RfQUxBUk1fRVhUUkFfUkVBU09OLCByZWFzb24pOwotICAgICAgICBtUmVjb25uZWN0SW50ZW50ID0gUGVuZGluZ0ludGVudC5nZXRCcm9hZGNhc3QoCi0gICAgICAgICAgICAgICAgbVBob25lLmdldENvbnRleHQoKSw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gc2V0dXAKLSAgICAgICAgICAgIG5vdGlmeURlZmF1bHREYXRhKHJlYXNvbik7Ci0gICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICBGYWlsQ2F1c2UgY2F1c2UgPSAoRmFpbENhdXNlKSAoYXIucmVzdWx0KTsKLSAgICAgICAgICAgIGlmKERCRykgbG9nKCJEYXRhIENvbm5lY3Rpb24gc2V0dXAgZmFpbGVkICIgKyBjYXVzZSk7Ci0KLSAgICAgICAgICAgIC8vIE5vIHRyeSBmb3IgcGVybWFuZW50IGZhaWx1cmUKLSAgICAgICAgICAgIGlmIChjYXVzZS5pc1Blcm1hbmVudEZhaWwoKSkgewotICAgICAgICAgICAgICAgIG5vdGlmeU5vRGF0YShjYXVzZSk7Ci0gICAgICAgICAgICAgICAgcmV0dXJuOwotICAgICAgICAgICAgfQotCi0gICAgICAgICAgICBpbnQgcmV0cnlPdmVycmlkZSA9IC0xOwotICAgICAgICAgICAgaWYgKGFyLmV4Y2VwdGlvbiBpbnN0YW5jZW9mIERhdGFDb25uZWN0aW9uLkNhbGxTZXR1cEV4Y2VwdGlvbikgewotICAgICAgICAgICAgICAgIHJldHJ5T3ZlcnJpZGUgPQotICAgICAgICAgICAgICAgICAgICAoKERhdGFDb25uZWN0aW9uLkNhbGxTZXR1cEV4Y2VwdGlvbilhci5leGNlcHRpb24pLmdldFJldHJ5T3ZlcnJpZGUoKTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGlmIChyZXRyeU92ZXJyaWRlID09IFJJTENvbnN0YW50cy5NQVhfSU5UKSB7Ci0gICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJObyByZXRyeSBpcyBzdWdnZXN0ZWQuIik7Ci0gICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgIHN0YXJ0RGVsYXllZFJldHJ5KGNhdXNlLCByZWFzb24sIHJldHJ5T3ZlcnJpZGUpOwotICAgICAgICAgICAgfQotICAgICAgICB9Ci0gICAgfQotCi0gICA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W50IFtdKWFyLnJlc3VsdDsKLSAgICAgICAgICAgIGlmICgob3RhUHJpdmlzaW9uICE9IG51bGwpICYmIChvdGFQcml2aXNpb24ubGVuZ3RoID4gMSkpIHsKLSAgICAgICAgICAgICAgICBzd2l0Y2ggKG90YVByaXZpc2lvblswXSkgewotICAgICAgICAgICAgICAgIGNhc2UgUGhvbmUuQ0RNQV9PVEFfUFJPVklTSU9OX1NUQVRVU19DT01NSVRURUQ6Ci0gICAgICAgICAgICAgICAgY2FzZSBQaG9uZS5DRE1BX09UQV9QUk9WSVNJT05fU1RBVFVTX09UQVBBX1NUT1BQRUQ6Ci0gICAgICAgICAgICAgICAgICAgIG1EYXRhQ29ubmVjdGlvbnMuZ2V0KDApLnJlc2V0UmV0cnlDb3VudCgpOwotICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICBkZWZhdWx0OgotICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICB9Ci0gICAgICAgIH0KLSAgICB9Ci0KLSAgICBwcml2YXRlIHZvaWQgb25SZXN0YXJ0UmFkaW8oKSB7Ci0gICAgICAgIGlmIChtUGVuZGluZ1Jlc3RhcnRSYWRpbykgewotICAgICAgICAgICAgbG9nKCIqKioqKioqKioqKipUVVJOIE9GRiBSQURJTyoqKioqKioqKioqKioqIik7Ci0gICAgICAgICAgICBtUGhvbmUubUNNLnNldFJhZGlvUG93ZXIoZmFsc2UsIG51bGwpOwotICAgICAgICAgICAgLyogTm90ZTogbm8gbmVlZCB0byBjYWxsIHNldFJhZGlvUG93ZXIodHJ1ZSkuICBBc3N1bWluZyB0aGUgZGVzaXJlZAotICAgICAgICAgICAgICogcmFkaW8gcG93ZXIgc3RhdGUgaXMgc3RpbGwgT04gKGFzIHRyYWNrZWQgYnkgU2VydmljZVN0YXRlVHJhY2tlciksCi0gICAgICAgICAgICAgKiBTZXJ2aWNlU3RhdGVUcmFja2VyIHdpbGwgY2Fs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uZXhjZXB0aW9uICE9IG51bGwpIHsKLSAgICAgICAgICAgIC8vIFRoaXMgaXMgcHJvYmFibHkgInJhZGlvIG5vdCBhdmFpbGFibGUiIG9yIHNvbWV0aGluZwotICAgICAgICAgICAgLy8gb2YgdGhhdCBzb3J0LiBJZiBzbywgdGhlIHdob2xlIGNvbm5lY3Rpb24gaXMgZ29pbmcKLSAgICAgICAgICAgIC8vIHRvIGNvbWUgZG93biBzb29uIGFueXdheQotICAgICAgICAgICAgcmV0dXJuOwotICAgICAgICB9Ci0KLSAgICAgICAgaWYgKG1TdGF0ZSA9PSBEY3RDb25zdGFudHMuU3RhdGUuQ09OTkVDVEVEKSB7Ci0gICAgICAgICAgICBib29sZWFuIGlzQWN0aXZlT3JEb3JtYW50Q29ubmVjdGlvblByZXNlbnQgPSBmYWxzZTsKLSAgICAgICAgICAgIGludCBjb25uZWN0aW9uU3RhdGUgPSBEQVRBX0NPTk5FQ1RJT05fQUNUSVZFX1BIX0xJTktfSU5BQ1RJVkU7Ci0KLSAgICAgICAgICAgIC8vIENoZWNrIGZvciBhbiBhY3RpdmUgb3IgZG9ybWFudCBjb25uZWN0aW9uIGVsZW1lbnQgaW4KLSAgICAgICAgICAgIC8vIHRoZSBEQVRBX0NBTExfTElTVCBhcnJheQotICAgICAgICAgICAgZm9yIChpbnQgaW5kZXggPSAwOyBpbmRleCA8IGRhdGFDYWxsU3RhdGVzLnNpemUoKTsgaW5kZXgrKykgewotICAgICAgICAgICAgICAgIGNvbm5lY3Rpb25TdGF0ZSA9IGRhdGFDYWxsU3RhdGVzLmdldChpbmRleCkuYWN0aXZlOwotICAgICAgICAgICAgICAgIGlmIChjb25uZWN0aW9uU3RhdGUgIT0gREFUQV9DT05ORUNUSU9OX0FDVElWRV9QSF9MSU5LX0lOQUNUSVZFKSB7Ci0gICAgICAgICAgICAgICAgICAgIGlzQWN0aXZlT3JEb3JtYW50Q29ubmVjdGlvblByZXNlbnQgPSB0cnVlOwotICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgIGlmICghaXNBY3RpdmVPckRvcm1hbnRDb25uZWN0aW9uUHJlc2VudCkgewotICAgICAgICAgICAgICAgIC8vIE5vIGFjdGl2ZSBvciBkb3JtYW50IGNvbm5lY3Rpb24KLSAgICAgICAgICAgICAgICBsb2coIm9uRGF0YVN0YXRlQ2hhbmdlZDogTm8gYWN0aXZlIGNvbm5lY3Rpb24iCi0gICAgICAgICAgICAgICAgICAgICAgICArICJzdGF0ZSBpcyBDT05ORUNURUQsIGRpc2Nvbm5lY3RpbmcvY2xlYW51cCIpOwotICAgICAgICAgICAgICAgIHdyaXRlRXZlbnRMb2dDZG1hRGF0YURyb3AoKTsKLSAgICAgICAgICAgICAgICBjbGVhblVwQ29ubmVjdGlvbih0cnVlLCBudWxsLCBmYWxzZSk7Ci0gICAgICAgICAgICAgICAgcmV0dXJuOwotICAgICAgICAgICAgfQotCi0gICAgICAgICAgICBzd2l0Y2ggKGNvbm5lY3Rpb25TdGF0ZSkgewotICAgICAgICAgICAgICAgIGNhc2UgREFUQV9DT05ORUNUSU9OX0FDVElWRV9QSF9MSU5LX1VQOgotICAgICAgICAgICAgICAgICAgICBsb2coIm9uRGF0YVN0YXRlQ2hhbmdlZDogYWN0aXZlPUxJTktfQUNUSVZFICYmIENPTk5FQ1RFRCwgaWdub3JlIik7Ci0gICAgICAgICAgICAgICAgICAgIG1BY3Rpdml0eSA9IERjdENvbnN0YW50cy5BY3Rpdml0eS5OT05FOwotICAgICAgICAgICAgICAgICAgICBtUGhvbmUubm90aWZ5RGF0YUFjdGl2aXR5KCk7Ci0gICAgICAgICAgICAgICAgICAgIHN0YXJ0TmV0U3RhdFBvbGwoKTsKLSAgICAgICAgICAgICAgICAgICAgc3RhcnREYXRhU3RhbGxBbGFybShEQVRBX1NUQUxMX05PVF9TVVNQRUNURUQpOwotICAgICAgICAgICAgICAgICAgICBicmVhazsKLQotICAgICAgICAgICAgICAgIGNhc2UgREFUQV9DT05ORUNUSU9OX0FDVElWRV9QSF9MSU5LX0RPV046Ci0gICAgICAgICAgICAgICAgICAgIGxvZygib25EYXRhU3RhdGVDaGFuZ2VkIGFjdGl2ZT1MSU5LX0RPV04gJiYgQ09OTkVDVEVELCBkb3JtYW50Iik7Ci0gICAgICAgICAgICAgICAgICAgIG1BY3Rpdml0eSA9IERjdENvbnN0YW50cy5BY3Rpdml0eS5ET1JNQU5UOwotICAgICAgICAgICAgICAgICAgICBtUGhvbmUubm90aWZ5RGF0YUFjdGl2aXR5KCk7Ci0gICAgICAgICAgICAgICAgICAgIHN0b3BOZXRTdGF0UG9sbCgpOwotICAgICAgICAgICAgICAgICAgICBzdG9wRGF0YVN0YWxsQWxhcm0oKTsKLSAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0KLSAgICAgICAgICAgICAgICBkZWZhdWx0OgotICAgICAgICAgICAgICAgICAgICBsb2coIm9uRGF0YVN0YXRlQ2hhbmdlZDogSUdOT1JFIHVuZXhwZWN0ZWQgRGF0YUNhbGxTdGF0ZS5hY3RpdmU9IgotICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgY29ubmVjdGlvblN0YXRlKTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgIC8vIFRPRE86IERvIHdlIG5lZWQgdG8gZG8gYW55dGhpbmc/Ci0gICAgICAgICAgICBsb2coIm9uRGF0YVN0YXRlQ2hhbmdlZDogbm90IGNvbm5lY3RlZCwgc3RhdGU9IiArIG1TdGF0ZSArICIgaWdub3JpbmciKTsKLSAgICAgICAgfQotICAgIH0KLQotICAgIHByaXZhdGUgdm9pZCBzdGFydERlbGF5ZWRSZXRyeShGYWlsQ2F1c2UgY2F1c2UsIFN0cmluZyByZWFzb24sIGludCByZXRyeU92ZXJyaWRlKSB7Ci0gICAgICAgIG5vdGlmeU5vRGF0YShjYXVzZSk7Ci0gICAgICAgIHJlY29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gICAgICAgICAgICBvbkNkbWFEYXRhRGV0YWNoZWQoKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLQotICAgICAgICAgICAgY2FzZSBEY3RDb25zdGFudHMuRVZFTlRfREFUQV9TVEFURV9DSEFOR0VEOgotICAgICAgICAgICAgICAgIG9uRGF0YVN0YXRlQ2hhbmdlZCgoQXN5bmNSZXN1bHQpIG1zZy5vYmopOwotICAgICAgICAgICAgICAgIGJyZWFrOwotCi0gICAgICAgICAgICBjYXNlIERjdENvbnN0YW50cy5FVkVOVF9DRE1BX09UQV9QUk9WSVNJT046Ci0gICAgICAgICAgICAgICAgb25DZG1hT3RhUHJvdmlzaW9uKChBc3luY1Jlc3VsdCkgbXNnLm9iaik7Ci0gICAgICAgICAgICAgICAgYnJlYWs7Ci0KLSAgICAgICAgICAgIGNhc2UgRGN0Q29uc3RhbnRzLkVWRU5UX1JFU1RBUlRfUkFESU86Ci0gICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJFVkVOVF9SRVNUQVJUX1JBRElPIik7Ci0gICAgICAgICAgICAgICAgb25SZXN0YXJ0UmFkaW8oKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLQotICAgICAgICAgICAgZGVmYXVsdDoKLSAgICAgICAgICAgICAgICAvLyBoYW5kbGUgdGhlIG1lc3NhZ2UgaW4gdGhlIHN1cGVyIGNsYXNzIERhdGFDb25uZWN0aW9uVHJhY2tlcgotICAgICAgICAgICAgICAgIHN1cGVyLmhhbmRsZU1lc3NhZ2UobXNnKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgfQotICAgIH0KLQotICAgIEBPdmVycmlkZQotICAgIHByb3RlY3RlZCB2b2lkIG9uVXBkYXRlSWNjKCkgewotICAgICAgICBpZiAobVVpY2NDb250cm9sbGVyID09IG51bGwgKSB7Ci0gICAgICAgICAgICByZXR1cm47Ci0gICAgICAgIH0KLQotICAgICAgICBJY2NSZWNvcmRzIG5ld0ljY1JlY29yZHMgPSBtVWljY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3IgRVZFTlRfUE9MTF9TVEFURV9SRUdJU1RSQVRJT05fQ0RNQQotICAgICAqLwotICAgIEBPdmVycmlkZQotICAgIHByb3RlY3RlZCB2b2lkIHNldENkbWFUZWNobm9sb2d5KGludCByYWRpb1RlY2hub2xvZ3kpIHsKLSAgICAgICAgLy8gQ2FsbGVkIG9uIHZvaWNlIHJlZ2lzdHJhdGlvbiBzdGF0ZSByZXNwb25zZS4KLSAgICAgICAgLy8gSnVzdCByZWNvcmQgbmV3IENETUEgcmFkaW8gdGVjaG5vbG9neQotICAgICAgICBuZXdTUy5zZXRSYWRpb1RlY2hub2xvZ3kocmFkaW9UZWNobm9sb2d5KTsKLSAgICB9Ci0KLSAgICAvKioKICAgICAgKiBIYW5kbGUgdGhlIHJlc3VsdCBvZiBvbmUgb2YgdGhlIHBvbGxTdGF0ZSgpLXJlbGF0ZWQgcmVxdWVzdHMKICAgICAgKi8KICAgICBAT3ZlcnJpZGUKQEAgLTE0OCwxMSArMTI4LDExIEBACiAgICAgICAgICAgICAgICAgICAgIFN0cmluZyBvcGVyYXRvck51bWVyaWMgPSBudWxsOwogCiAgICAgICAgICAgICAgICAgICAgIHRyeSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBvcGVyYXRvck51bWVyaWMgPSBtTHRlU1MuZ2V0T3BlcmF0b3JOdW1lcmljKCk7CisgICAgICAgICAgICAgICAgICAgICAgICBvcGVyYXRvck51bWVyaWMgPSBtTmV3U1MuZ2V0T3BlcmF0b3JOdW1lcmljKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICBtY2MgPSBJbnRlZ2VyLnBhcnNlSW50KG9wZXJhdG9yTnVtZXJpYy5zdWJzdHJpbmcoMCwzKSk7CiAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKEV4Y2VwdGlvbiBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTnVtZXJpYyA9IHNzLmdldE9wZXJhdG9yTnVtZXJpYygpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTnVtZXJpYyA9IG1TUy5nZXRPcGVyYXRvck51bWVyaWMoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtY2MgPSBJbnRlZ2VyLnBhcnNlSW50KG9wZXJhdG9yTnVtZXJpYy5zdWJzdHJpbmcoMCwzKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2dlKCJoYW5kbGVQb2xsU3RhdGVSZXN1bHRNZXNzYWdlOiBiYWQgbWNjIG9wZXJhdG9yTnVtZXJpYz0iICsKQEAgLTIwOCw4ICsxODgsMTQgQEAKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgIG1MdGVTUy5zZXRSYWRpb1RlY2hub2xvZ3kodHlwZSk7Ci0gICAgICAgICAgICBtTHRlU1Muc2V0U3RhdGUocmVnQ29kZVRvU2VydmljZVN0YXRlKHJlZ1N0YXRlKSk7CisgICAgICAgICAgICBtTmV3U1Muc2V0UmlsRGF0YVJhZGlvVGVjaG5vbG9neSh0eXBlKTsKKyAgICAgICAgICAgIGludCBkYXRhUmVnU3RhdGUgPSByZWdDb2RlVG9TZXJ2aWNlU3RhdGUocmVnU3RhdGUpOworICAgICAgICAgICAgbU5ld1NTLnNldERhdGFSZWdTdGF0ZShkYXRhUmVnU3RhdGUpOworICAgICAgICAgICAgaWYgKERCRykgeworICAgICAgICAgICAgICAgIGxvZygiaGFuZGxQb2xsU3RhdGVSZXN1bHRNZXNzYWdlOiBDZG1hTHRlU1NUIHNldERhdGFSZWdTdGF0ZT0iICsgZGF0YVJlZ1N0YXRlCisgICAgICAgICAgICAgICAgICAgICAgICArICIgcmVnU3RhdGU9IiArIHJlZ1N0YXRlCisgICAgICAgICAgICAgICAgICAgICAgICArICIgZGF0YVJ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iAKICAgICAgICAgICAgIGNhc2UgUkFESU9fT0ZGOgotICAgICAgICAgICAgICAgIG5ld1NTLnNldFN0YXRlT2ZmKCk7Ci0gICAgICAgICAgICAgICAgbUx0ZVNTLnNldFN0YXRlT2ZmKCk7Ci0gICAgICAgICAgICAgICAgbmV3Q2VsbExvYy5zZXRTdGF0ZUludmFsaWQoKTsKKyAgICAgICAgICAgICAgICBtTmV3U1Muc2V0U3RhdGVPZmYoKTsKKyAgICAgICAgICAgICAgICBtTmV3Q2VsbExvYy5zZXRTdGF0ZUludmFsaWQoKTsKICAgICAgICAgICAgICAgICBzZXRTaWduYWxTdHJlbmd0aERlZmF1bHRWYWx1ZXMoKTsKICAgICAgICAgICAgICAgICBtR290Q291bnRyeUNvZGUgPSBmYWxzZTsKIApAQCAtMjQ2LDEwNyArMjMwLDc0IEBACiAgICAgICAgICAgICAgICAgLy8gZG93biB0aGUgcmVzcG9uc2VzIHdoaWNoIGFyZSBhbGxvd2VkIHRvIGFycml2ZQogICAgICAgICAgICAgICAgIC8vIG91dC1vZi1vcmRlci4KIAotICAgICAgICAgICAgICAgIHBvbGxpbmdDb250ZXh0WzBdKys7CisgICAgICAgICAgICAgICAgbVBvbGxpbmdDb250ZXh0WzBdKys7CiAgICAgICAgICAgICAgICAgLy8gUklMX1JFUVVFU1RfT1BFUkFUT1IgaXMgbmVjZXNzYXJ5IGZvciBDRE1BCi0gICAgICAgICAgICAgICAgY20uZ2V0T3BlcmF0b3Iob2J0YWluTWVzc2FnZShFVkVOVF9QT0xMX1NUQVRFX09QRVJBVE9SX0NETUEsIHBvbGxpbmdDb250ZXh0KSk7CisgICAgICAgICAgICAgICAgbUNpLmdldE9wZXJhdG9yKG9idGFpbk1lc3NhZ2UoRVZFTlRfUE9MTF9TVEFURV9PUEVSQVRPUl9DRE1BLCBtUG9sbGluZ0NvbnRleHQpKTsKIAotICAgICAgICAgICAgICAgIHBvbGxpbmdDb250ZXh0WzBdKys7CisgICAgICAgICAgICAgICAgbVBvbGxpbmdDb250ZXh0WzBdKys7CiAgICAgICAgICAgICAgICAgLy8gUklMX1JFUVVFU1RfVk9JQ0VfUkVHSVNUUkFUSU9OX1NUQVRFIGlzIG5lY2Vzc2FyeSBmb3IgQ0RNQQotICAgICAgICAgICAgICAgIGNtLmdldFZvaWNlUmVnaXN0cmF0aW9uU3RhdGUob2J0YWluTWVzc2FnZShFVkVOVF9QT0xMX1NUQVRFX1JFR0lTVFJBVElPTl9DRE1BLAotICAgICAgICAgICAgICAgICAgICAgICAgcG9sbGluZ0NvbnRleHQpKTsKKyAgICAgICAgICAgICAgICBtQ2kuZ2V0Vm9pY2VSZWdpc3RyYXRpb25TdGF0ZShvYnRhaW5NZXNzYWdlKEVWRU5UX1BPTExfU1RBVEVfUkVHSVNUUkFUSU9OX0NETUEsCisgICAgICAgICAgICAgICAgICAgICAgICBtUG9sbGluZ0NvbnRleHQpKTsKIAotICAgICAgICAgICAgICAgIHBvbGxpbmdDb250ZXh0WzBdKys7CisgICAgICAgICAgICAgICAgbVBvbGxpbmdDb250ZXh0WzBdKys7CiAgICAgICAgICAgICAgICAgLy8gUklMX1JFUVVFU1RfREFUQV9SRUdJU1RSQVRJT05fU1RBVEUKLSAgICAgICAgICAgICAgICBjbS5nZXREYXRhUmVnaXN0cmF0aW9uU3RhdGUob2J0YWluTWVzc2FnZShFVkVOVF9QT0xMX1NUQVRFX0dQUlMsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvbGxpbmdDb250ZXh0KSk7CisgICAgICAgICAgICAgICAgbUNpLmdldERhdGFSZWdpc3RyYXRpb25TdGF0ZShvYnRhaW5NZXNzYWdlKEVWRU5UX1BPTExfU1RBVEVfR1BSUywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbVBvbGxpbmdDb250ZXh0KSk7CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIH0KICAgICB9CiAKICAgICBAT3ZlcnJp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cGRhdGUgc2VjdXJlIHNldCB2YWx1ZT0nMTEnIHdoZXJlIG5hbWU9J3ByZWZlcnJlZF9uZXR3b3JrX21vZGUnIgotICAgICAgICBpZiAobmV3U1MuZ2V0U3RhdGUoKSA9PSBTZXJ2aWNlU3RhdGUuU1RBVEVfT1VUX09GX1NFUlZJQ0UpIHsKLSAgICAgICAgICAgIGludCBuZXR3b3JrTW9kZSA9IGFuZHJvaWQucHJvdmlkZXIuU2V0dGluZ3MuR2xvYmFsLmdldEludChwaG9uZS5nZXRDb250ZXh0KCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0Q29udGVudFJlc29sdmVyKCksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5kcm9pZC5wcm92aWRlci5TZXR0aW5ncy5HbG9iYWwuUFJFRkVSUkVEX05FVFdPUktfTU9ERSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBSSUxDb25zdGFudHMuUFJFRkVSUkVEX05FVFdPUktfTU9ERSk7Ci0gICAgICAgICAgICBpZiAobmV0d29ya01vZGUgPT0gUklMQ29uc3RhbnRzLk5FVFdPUktfTU9ERV9MVEVfT05MWSkgewotICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygicG9sbFN0YXRlOiBMVEUgT25seSBtb2RlIik7Ci0gICAgICAgICAgICAgICAgbmV3U1Muc2V0U3RhdGUobUx0ZVNTLmdldFN0YXRlKCkpOwotICAgICAgICAgICAgfQotICAgICAgICB9CisgICAgICAgIGJvb2xlYW4gaGFzUmVnaXN0ZXJlZCA9IG1TUy5nZXRWb2ljZVJlZ1N0YXRlKCkgIT0gU2VydmljZVN0YXRlLlNUQVRFX0lOX1NFUlZJQ0UKKyAgICAgICAgICAgICAgICAmJiBtTmV3U1MuZ2V0Vm9pY2VSZWdTdGF0ZSgpID09IFNlcnZpY2VTdGF0ZS5TVEFURV9JTl9TRVJWSUNFOwogCi0gICAgICAgIGlmIChEQkcpIGxvZ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ICAgaWYgKHNzLmdldFN0YXRlKCkgPT0gU2VydmljZVN0YXRlLlNUQVRFX0lOX1NFUlZJQ0UpIHsKLSAgICAgICAgICAgICAgICAgICAgZXJpVGV4dCA9IHBob25lLmdldENkbWFFcmlUZXh0KCk7Ci0gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzcy5nZXRTdGF0ZSgpID09IFNlcnZpY2VTdGF0ZS5TVEFURV9QT1dFUl9PRkYpIHsKKyAgICAgICAgICAgICAgICBpZiAobVNTLmdldFZvaWNlUmVnU3RhdGUoKSA9PSBTZXJ2aWNlU3RhdGUuU1RBVEVfSU5fU0VSVklDRSkgeworICAgICAgICAgICAgICAgICAgICBlcmlUZXh0ID0gbVBob25lLmdldENkbWFFcmlUZXh0KCk7CisgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChtU1MuZ2V0Vm9pY2VSZWdTdGF0ZSgpID09IFNlcnZpY2VTdGF0ZS5TVEFURV9QT1dFUl9PRkYpIHsKICAgICAgICAgICAgICAgICAgICAgZXJpVGV4dCA9IChtSWNjUmVjb3JkcyAhPSBudWxsKSA/IG1JY2NSZWNvcmRzLmdldFNlcnZpY2VQcm92aWRlck5hbWUoKSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgIGlmIChUZXh0VXRpbHMuaXNFbXB0eShlcmlUZXh0KSkgewogICAgICAgICAgICAgICAgICAgICAgICAgLy8gU2V0cyBvcGVyYXRvciBhbHBoYSBwcm9wZXJ0eSBieSByZXRyaWV2aW5nIGZyb20KQEAgLTQyOSw0MCArMzYyLDQwIEBACiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgLy8gTm90ZSB0aGF0IFNlcnZpY2VTdGF0ZS5TVEFURV9PVVRfT0ZfU0VSVklDRSBpcyB2YWxpZCB1c2VkCiAgICAgICAgICAgICAgICAgICAgIC8vIGZvciBtUmVnaXN0cmF0aW9uU3RhdGUgMCwyLDMgYW5kIDQKLSAgICAgICAgICAgICAgICAgICAgZXJpVGV4dCA9IHBob25lLmdldENvbnRleHQoKQorICAgICAgICAgICAgICAgICAgICBlcmlUZXh0ID0gbVBob25lLmdldENvbnRleHQoKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLnJvYW1pbmdUZXh0U2VhcmNoaW5nKS50b1N0cmluZygpOwogICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBzcy5zZXRPcGVyYXRvckFscGhhTG9uZyhlcmlUZXh0KTsKKyAgICAgICAgICAgICAgICBtU1Muc2V0T3BlcmF0b3JBbHBoYUxvbmcoZXJpVGV4dCk7CiAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgIGlmIChtVWljY0FwcGxjYXRpb24gIT0gbnVsbCAmJiBtVWljY0FwcGxjYXRpb24uZ2V0U3RhdGUoKSA9PSBBcHBTdGF0ZS5BUFBTVEFURV9SRUFEWSAmJgogICAgICAgICAgICAgICAgICAgICBtSWNjUmVjb3JkcyAhPSBudWxsKSB7CiAgICAgICAgICAgICAgICAgLy8gU0lNIGlzIGZvdW5kIG9uIHRoZSBkZXZpY2UuIElmIEVSSSByb2FtaW5nIGlzIE9GRiwgYW5kIFNJRC9OSUQgbWF0Y2hlcwotICAgICAgICAgICAgICAgIC8vIG9uZSBjb25maWdmdXJlZCBpbiBTSU0sIHVzZSBvcGVyYXRvciBuYW1lICBmcm9tIENTSU0gcmVjb3JkLgorICAgICAgICAgICAgICAgIC8vIG9uZSBjb25maWd1cmVkIGluIFNJTSwgdXNlIG9wZXJhdG9yIG5hbWUgIGZyb20gQ1NJTSByZWNvcmQuCiAgICAgICAgICAgICAgICAgYm9vbGVhbiBzaG93U3BuID0KICAgICAgICAgICAgICAgICAgICAgKChSdWltUmVjb3JkcyltSWNjUmVjb3JkcykuZ2V0Q3NpbVNwbkRpc3BsYXlDb25kaXRpb24oKTsKLSAgICAgICAgICAgICAgICBpbnQgaWNvbkluZGV4ID0gc3MuZ2V0Q2RtYUVyaUljb25JbmRleCgpOworICAgICAgICAgICAgICAgIGludCBpY29uSW5kZXggPSBtU1MuZ2V0Q2RtYUVyaUljb25JbmRleCgpOwogCiAgICAgICAgICAgICAgICAgaWYgKHNob3dTcG4gJiYgKGljb25JbmRleCA9PSBFcmlJbmZvLlJPQU1JTkdfSU5ESUNBVE9SX09GRikgJiYKLSAgICAgICAgICAgICAgICAgICAgaXNJbkhvbWVTaWROaWQoc3MuZ2V0U3lzdGVtSWQoKSwgc3MuZ2V0TmV0d29ya0lkKCkpICYmCisgICAgICAgICAgICAgICAgICAgIGlzSW5Ib21lU2lkTmlkKG1TUy5nZXRTeXN0ZW1JZCgpLCBtU1MuZ2V0TmV0d29ya0lkKCkpICYmCiAgICAgICAgICAgICAgICAgICAgIG1JY2NSZWNvcmRzICE9IG51bGwpIHsKLSAgICAgICAgICAgICAgICAgICAgc3Muc2V0T3BlcmF0b3JBbHBoYUxvbmcobUljY1JlY29yZHMuZ2V0U2VydmljZVByb3ZpZGVyTmFtZSgpKTsKKyAgICAgICAgICAgICAgICAgICAgbVNTLnNldE9wZXJhdG9yQWxwaGFMb25nKG1JY2NSZWNvcmRzLmdldFNlcnZpY2VQcm92aWRlck5hbWUoKSk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogCiAgICAgICAgICAgICBTdHJpbmcgb3BlcmF0b3JOdW1lcmljOwogCi0gICAgICAgICAgICBwaG9uZS5zZXRTeXN0ZW1Qcm9wZXJ0eShUZWxlcGhvbnlQcm9wZXJ0aWVzLlBST1BFUlRZX09QRVJBVE9SX0FMUEhBLAotICAgICAgICAgICAgICAgICAgICBzcy5nZXRPcGVyYXRvckFscGhhTG9uZygpKTsKKyAgICAgICAgICAgIG1QaG9uZS5zZXRTeXN0ZW1Qcm9wZXJ0eShUZWxlcGhvbnlQcm9wZXJ0aWVzLlBST1BFUlRZX09QRVJBVE9SX0FMUEhBLAorICAgICAgICAgICAgICAgIC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H0gZWxzZSB7CiAgICAgICAgICAgICAgICAgU3RyaW5nIGlzb0NvdW50cnlDb2RlID0gIiI7CkBAIC00NzYsMjEgKzQwOSwyMSBAQAogICAgICAgICAgICAgICAgICAgICBsb2dlKCJjb3VudHJ5Q29kZUZvck1jYyBlcnJvciIgKyBleCk7CiAgICAgICAgICAgICAgICAgfQogCi0gICAgICAgICAgICAgICAgcGhvbmUuc2V0U3lzdGVtUHJvcGVydHkoVGVsZXBob255UHJvcGVydGllcy5QUk9QRVJUWV9PUEVSQVRPUl9JU09fQ09VTlRSWSwKKyAgICAgICAgICAgICAgICBtUGhvbmUuc2V0U3lzdGVtUHJvcGVydHkoVGVsZXBob255UHJvcGVydGllcy5QUk9QRVJUWV9PUEVSQVRPUl9JU09fQ09VTlRSWSwKICAgICAgICAgICAgICAgICAgICAgICAgIGlzb0NvdW50cnlDb2RlKTsKICAgICAgICAgICAgICAgICBtR290Q291bnRyeUNvZGUgPSB0cnVlOwogCi0gICAgICAgICAgICAgICAgaWYgKHNob3VsZEZpeFRpbWVab25lTm93KHBob25lLCBvcGVyYXRvck51bWVyaWMsIHByZXZPcGVyYXRvck51bWVyaWMsCisgICAgICAgICAgICAgICAgaWYgKHNob3VsZEZpeFRpbWVab25lTm93KG1QaG9uZSwgb3BlcmF0b3JOdW1lcmljLCBwcmV2T3BlcmF0b3JOdW1lcmljLAogICAgICAgICAgICAgICAgICAgICAgICAgbU5lZWRGaXhab25lKSkgewogICAgICAgICAgICAgICAgICAgICBmaXhUaW1lWm9uZShpc29Db3VudHJ5Q29kZSk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogCi0gICAgICAgICAgICBwaG9uZS5zZXRTeXN0ZW1Qcm9wZXJ0eShUZWxlcGhvbnlQcm9wZXJ0aWVzLlBST1BFUlRZX09QRVJBVE9SX0lTUk9BTUlORywKLSAgICAgICAgICAgICAgICAgICAgc3MuZ2V0Um9hbWluZygpID8gInRydWUiIDogImZhbHNlIik7CisgICAgICA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gICAgICAgICAgICByZXQubVB3ZCA9IG1ha2VFbXB0eU51bGwobS5ncm91cChNQVRDSF9HUk9VUF9QV0RfQ09ORklSTSkpOworICAgICAgICAgICAgcmV0Lm1EaWFsaW5nTnVtYmVyID0gbWFrZUVtcHR5TnVsbChtLmdyb3VwKE1BVENIX0dST1VQX0RJQUxJTkdfTlVNQkVSKSk7CiAKICAgICAgICAgfQogCkBAIC0xMzcsMzQgKzEzNywzOCBAQAogCiAgICAgQ2RtYU1taUNvZGUgKENETUFQaG9uZSBwaG9uZSkgewogICAgICAgICBzdXBlcihwaG9uZS5nZXRIYW5kbGVyKCkuZ2V0TG9vcGVyKCkpOwotICAgICAgICB0aGlzLnBob25lID0gcGhvbmU7Ci0gICAgICAgIHRoaXMuY29udGV4dCA9IHBob25lLmdldENvbnRleHQoKTsKKyAgICAgICAgbVBob25lID0gcGhvbmU7CisgICAgICAgIG1Db250ZXh0ID0gcGhvbmUuZ2V0Q29udGV4dCgpOwogICAgIH0KIAogICAgIC8vIE1taUNvZGUgaW1wbGVtZW50YXRpb24KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdGF0ZQogICAgIGdldFN0YXRlKCkgewotICAgICAgICByZXR1cm4gc3RhdGU7CisgICAgICAgIHJldHVybiBtU3RhdGU7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIENoYXJTZXF1ZW5jZQogICAgIGdldE1lc3NhZ2UoKSB7Ci0gICAgICAgIHJldHVybiBtZXNzYWdlOworICAgICAgICByZXR1cm4gbU1lc3NhZ2U7CiAgICAgfQogCiAgICAgLy8gaW5oZXJpdGVkIGphdmFkb2Mgc3VmZmljZXMKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZAogICAgIGNhbmNlbCgpIHsKICAgICAgICAgLy8gQ29tcGxldGUgb3IgZmFpbGVkIGNhbm5vdCBiZSBjYW5jZWxsZWQKLSAgICAgICAgaWYgKHN0YXRlID09IFN0YXRlLkNPTVBMRVRFIHx8IHN0YXRlID09IFN0YXRlLkZBSUxFRCkgeworICAgICAgICBpZiAobVN0YXRlID09IFN0YXRlLkNPTVBMRVRFIHx8IG1TdGF0ZSA9PSBTdGF0ZS5GQUlMRUQpIHsKICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgfQogCi0gICAgICAgIHN0YXRlID0gU3RhdGUuQ0FOQ0VMTEVEOwotICAgICAgICBwaG9uZS5vbk1NSURvbmUgKHRoaXMpOworICAgICAgICBtU3RhdGUgPSBTdGF0ZS5DQU5DRUxMRUQ7CisgICAgICAgIG1QaG9uZS5vbk1NSURvbmUgKHRoaXMpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBib29sZWFuIGlzQ2FuY2VsYWJsZSgpIHsKICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgIH0KQEAgLTE3NSwxMyArMTc5LDE0IEBACiAgICAgICogQHJldHVybiB0cnVlIGlmIHRoZSBTZXJ2aWNlIENvZGUgaXMgUElOL1BJTjIvUFVLL1BVSzItcmVsYXRlZAogICAgICAqLwogICAgIGJvb2xlYW4gaXNQdWtDb21tYW5kKCkgewotICAgICAgICByZXR1cm4gc2MgIT0gbnVsbCAmJiBzYy5lcXVhbHMoU0NfUFVLKTsKKyAgICAgICAgcmV0dXJuIG1TYyAhPSBudWxsICYmIG1TYy5lcXVhbHMoU0NfUFVLKTsKICAgICAgfQogCiAgICAgYm9vbGVhbiBpc1JlZ2lzdGVyKCkgewotICAgICAgICByZXR1cm4gYWN0aW9uICE9IG51bGwgJiYgYWN0aW9uLmVxdWFscyhBQ1RJT05fUkVHSVNURVIpOworICAgICAgICByZXR1cm4gbUFjdGlvbiAhPSBudWxsICYmIG1BY3Rpb24uZXF1YWxzKEFDVElPTl9SRUdJU1RFUik7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGJvb2xlYW4gaXNVc3NkUmVxdWVzdCgpIHsKICAgICAgICAgUmxvZy53KExPR19UQUcsICJpc1Vzc2RSZXF1ZXN0IGlzIG5vdCBpbXBsZW1lbnRlZCBpbiBDZG1hTW1pQ29kZSIpOwogICAgICAgICByZXR1cm4gZmFsc2U7CkBAIC0xOTUsMTggKzIwMCwxOCBAQAogICAgICAgICAgICAgICAgIC8vIHNpYSA9IG9sZCBQVUsKICAgICAgICAgICAgICAgICAvLyBzaWIgPSBuZXcgUElOCiAgICAgICAgICAgICAgICAgLy8gc2ljID0gbmV3IFBJTgotICAgICAgICAgICAgICAgIFN0cmluZyBvbGRQaW5PclB1ayA9IHNpYTsKLSAgICAgICAgICAgICAgICBTdHJpbmcgbmV3UGluID0gc2liOworICAgICAgICAgICAgICAgIFN0cmluZyBvbGRQaW5PclB1ayA9IG1TaWE7CisgICAgICAgICAgICAgICAgU3RyaW5nIG5ld1BpbiA9IG1TaWI7CiAgICAgICAgICAgICAgICAgaW50IHBpbkxlbiA9IG5ld1Bpbi5sZW5ndGgoKTsKICAgICAgICAgICAgICAgICBpZiAoaXNSZWdpc3RlcigpKSB7Ci0gICAgICAgICAgICAgICAgICAgIGlmICghbmV3UGluLmVxdWFscyhzaWMpKSB7CisgICAgICAgICAgICAgICAgICAgIGlmICghbmV3UGluLmVxdWFscyhtU2ljKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgLy8gcGFzc3dvcmQgbWlzbWF0Y2g7IHJldHVybiBlcnJvcgogICAgICAgICAgICAgICAgICAgICAgICAgaGFuZGxlUGFzc3dvcmRFcnJvcihjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5taXNtYXRjaFBpbik7CiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAocGluTGVuIDwgNCB8fCBwaW5MZW4gPiA4ICkgewogICAgICAgICAgICAgICAgICAgICAgICAgLy8gaW52YWxpZCBsZW5ndGgKICAgICAgICAgICAgICAgICAgICAgICAgIGhhbmRsZVBhc3N3b3JkRXJyb3IoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuaW52YWxpZFBpbik7CiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBwaG9uZS5tQ00uc3VwcGx5SWNjUHVrKG9sZFBpbk9yUHVrLCBuZXdQaW4sCisgICAgICAgICAgICAgICAgICAgICAgICBtUGhvbmUubUNpLnN1cHBseUljY1B1ayhvbGRQaW5PclB1aywgbmV3UGluLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX1NFVF9DT01QTEVURSwgdGhpcykpOwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKQEAgLTIxNiwyMSArMjIxLDIyIEBACiAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IFJ1bnRpbWVFeGNlcHRpb24gKCJJbnZhbGlkIG9yIFVuc3VwcG9ydGVkIE1NSSBDb2RlIik7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0gY2F0Y2ggKFJ1bnRpbWVFeGNlcHRpb24gZXhjKSB7Ci0gICAgICAgICAgICBzdGF0ZSA9IFN0YXRlLkZBSUxFRDsKLSAgICAgICAgICAgIG1lc3NhZ2UgPSBjb250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcubW1pRXJyb3IpOwotICAgICAgICAgICAgcGhvbmUub25NTUlEb25lKHRoaXMpOworICAgICAgICAgICAgbVN0YXRlID0gU3RhdGUuRkFJTEVEOworICAgICAgICAgICAgbU1lc3NhZ2UgPSBtQ29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLm1taUVycm9yKTsKKyAgICAgICAgICAgIG1QaG9uZS5vbk1NSURvbmUodGhpcyk7CiAgICAgICAgIH0KICAgICB9CiAKICAgICBwcml2YXRlIHZvaWQgaGFuZGxlUGFzc3dvcmRFcnJvcihpbnQgcmVzKSB7Ci0gICAgICAgIHN0YXRlID0gU3RhdGUuRkFJTEVEOworICAgICAgICBtU3RhdGUgPSBTdGF0ZS5GQUlMRUQ7CiAgICAgICAgIFN0cmluZ0J1aWxkZXIgc2IgPSBuZXcgU3RyaW5nQnVpbGRlcihnZXRTY1N0cmluZygpKTsKICAgICAgICAgc2IuYXBwZW5kKCJcbiIpOwotICAgICAgICBzYi5hcHBlbmQoY29udGV4dC5nZXRUZXh0KHJlcykpOwotICAgICAgICBtZXNzYWdlID0gc2I7Ci0gICAgICAgIHBob25lLm9uTU1JRG9uZSh0aGlzKTsKKyAgICAgICAgc2IuYXBwZW5kKG1Db250ZXh0LmdldFRleHQocmVzKSk7CisgICAgICAgIG1NZXNzYWdlID0gc2I7CisgICAgICAgIG1QaG9uZS5vbk1NSURvbmUodGhpcyk7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQKICAgICBoYW5kbGVNZXNzYWdlIChNZXNzYWdlIG1zZykgewogICAgICAgICBBc3luY1Jlc3VsdCBhcjsKQEAgLTI0NSw5ICsyNTEsOSBAQAogICAgIC8vIFByaXZhdGUgaW5zdGFuY2UgbWV0aG9kcwogCiAgICAgcHJpdmF0ZSBDaGFyU2VxdWVuY2UgZ2V0U2NTdHJpbmcoKSB7Ci0gICAgICAgIGlmIChzYyAhPSBudWxsKSB7CisgICAgICAgIGlmIChtU2MgIT0gbnVsbCkgewogICAgICAgICAgICAgaWYgKGlzUHVrQ29tbWFuZCgpKSB7Ci0gICAgICAgICAgICAgICAgcmV0dXJuIGNvbnRleHQuZ2V0VGV4dChjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5QaW5NbWkpOworICAgICAgICAgICAgICAgIHJldHVybiBtQ29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLlBpbk1taSk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KIApAQCAtMjYwLDM3ICsyNjYsMzcgQEAKICAgICAgICAgc2IuYXBwZW5kKCJcbiIpOwogCiAgICAgICAgIGlmIChhci5leGNlcHRpb24gIT0gbnVsbCkgewotICAgICAgICAgICAgc3RhdGUgPSBTdGF0ZS5GQUlMRUQ7CisgICAgICAgICAgICBtU3RhdGUgPSBTdGF0ZS5GQUlMRUQ7CiAgICAgICAgICAgICBpZiAoYXIuZXhjZXB0aW9uIGluc3RhbmNlb2YgQ29tbWFuZEV4Y2VwdGlvbikgewogICAgICAgICAgICAgICAgIENvbW1hbmRFeGNlcHRpb24uRXJyb3IgZXJyID0gKChDb21tYW5kRXhjZXB0aW9uKShhci5leGNlcHRpb24pKS5nZXRDb21tYW5kRXJyb3IoKTsKICAgICAgICAgICAgICAgICBpZiAoZXJyID09IENvbW1hbmRFeGNlcHRpb24uRXJyb3IuUEFTU1dPUkRfSU5DT1JSRUNUKSB7CiAgICAgICAgICAgICAgICAgICAgIGlmIChpc1B1a0NvbW1hbmQoKSkgewotICAgICAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKGNvbnRleHQuZ2V0VGV4dCgKKyAgICAgICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChtQ29udGV4dC5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5iYWRQdWspKTsKICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQobUNvbnRleHQuZ2V0VGV4dCgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcucGFzc3dvcmRJbmNvcnJlY3QpKTsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChtQ29udGV4dC5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLm1taUVycm9yKSk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICBzYi5hcHBlbmQoY29udGV4dC5nZXRUZXh0KAorICAgICAgICAgICAgICAgIHNiLmFwcGVuZChtQ29udGV4dC5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcubW1pRXJyb3IpKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfSBlbHNlIGlmIChpc1JlZ2lzdGVyKCkpIHsKLSAgICAgICAgICAgIHN0YXRlID0gU3RhdGUuQ09NUExFVEU7Ci0gICAgICAgICAgICBzYi5hcHBlbmQoY29udGV4dC5nZXRUZXh0KAorICAgICAgICAgICAgbVN0YXRlID0gU3RhdGUuQ09NUExFVEU7CisgICAgICAgICAgICBzYi5hcHBlbmQobUNvbnRleHQuZ2V0VGV4dCgKICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuc2VydmljZVJlZ2lzdGVyZWQpKTsKICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgIHN0YXRlID0gU3RhdGUuRkFJTEVEOwotICAgICAgICAgICAgc2IuYXBwZW5kKGNvbnRleHQuZ2V0VGV4dCgKKyAgICAgICAgICAgIG1TdGF0ZSA9IFN0YXRlLkZBSUxFRDsKKyAgICAgICAgICAgIHNiLmFwcGVuZChtQ29udGV4dC5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICBjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5tbWlFcnJvcikpOwogICAgICAgICB9CiAKLSAgICAgICAgbWVzc2FnZ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IGRvIGluIEdzbVNTVC4KICAgICAgICAgICAgIC8vIGNtLnNldEN1cnJlbnRQcmVmZXJyZWROZXR3b3JrVHlwZSgpOwogCi0gICAgICAgICAgICBpZiAocGhvbmUuZ2V0THRlT25DZG1hTW9kZSgpID09IFBob25lQ29uc3RhbnRzLkxURV9PTl9DRE1BX1RSVUUpIHsKKyAgICAgICAgICAgIGlmIChtUGhvbmUuZ2V0THRlT25DZG1hTW9kZSgpID09IFBob25lQ29uc3RhbnRzLkxURV9PTl9DRE1BX1RSVUUpIHsKICAgICAgICAgICAgICAgICAvLyBTdWJzY3JpcHRpb24gd2lsbCBiZSByZWFkIGZyb20gU0lNIEkvTwogICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygiUmVjZWl2ZSBFVkVOVF9SVUlNX1JFQURZIik7CiAgICAgICAgICAgICAgICAgcG9sbFN0YXRlKCk7CkBAIC0yOTQsNyArMjg4LDcgQEAKICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coIlJlY2VpdmUgRVZFTlRfUlVJTV9SRUFEWSBhbmQgU2VuZCBSZXF1ZXN0IGdldENETUFTdWJzY3JpcHRpb24uIik7CiAgICAgICAgICAgICAgICAgZ2V0U3Vic2NyaXB0aW9uSW5mb0FuZFN0YXJ0UG9sbGluZ1RocmVhZHMoKTsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIHBob25lLnByZXBhcmVFcmkoKTsKKyAgICAgICAgICAgIG1QaG9uZS5wcmVwYXJlRXJpKCk7CiAgICAgICAgICAgICBicmVhazsKIAogICAgICAgICBjYXNlIEVWRU5UX05WX1JFQURZOgpAQCAtMzA1LDcgKzI5OSw3IEBACiAgICAgICAgICAgICBicmVhazsKIAogICAgICAgICBjYXNlIEVWRU5UX1JBRElPX1NUQVRFX0NIQU5HRUQ6Ci0gICAgICAgICAgICBpZihjbS5nZXRSYWRpb1N0YXRlKCkgPT0gUmFkaW9TdGF0ZS5SQURJT19PTikgeworICAgICAgICAgICAgaWYobUNpLm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gICAgcGhvbmUubm90aWZ5TG9jYXRpb25DaGFuZ2VkKCk7CisgICAgICAgICAgICAgICAgbVBob25lLm5vdGlmeUxvY2F0aW9uQ2hhbmdlZCgpOwogICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAvLyBSZWxlYXNlIGFueSB0ZW1wb3JhcnkgY2VsbCBsb2NrLCB3aGljaCBjb3VsZCBoYXZlIGJlZW4KQEAgLTM4NCw2ICszNzgsNyBAQAogCiAgICAgICAgIGNhc2UgRVZFTlRfUE9MTF9TVEFURV9SRUdJU1RSQVRJT05fQ0RNQToKICAgICAgICAgY2FzZSBFVkVOVF9QT0xMX1NUQVRFX09QRVJBVE9SX0NETUE6CisgICAgICAgIGNhc2UgRVZFTlRfUE9MTF9TVEFURV9HUFJTOgogICAgICAgICAgICAgYXIgPSAoQXN5bmNSZXN1bHQpIG1zZy5vYmo7CiAgICAgICAgICAgICBoYW5kbGVQb2xsU3RhdGVSZXN1bHQobXNnLndoYXQsIGFyKTsKICAgICAgICAgICAgIGJyZWFrOwpAQCAtNDA0LDcgKzM5OSw3IEBACiAgICAgICAgICAgICAgICAgICAgIG1Jc01pbkluZm9SZWFkeSA9IHRydWU7CiAKICAgICAgICAgICAgICAgICAgICAgdXBkYXRlT3Rhc3BTdGF0ZSgpOwotICAgICAgICAgICAgICAgICAgICBpZiAoIWlzU3Vic2NyaXB0aW9uRnJvbVJ1aW0gJiYgbUljY1JlY29yZHMgIT0gbnVsbCkgeworICAgICAgICAgICAgICAgICAgICBpZiAoIW1Jc1N1YnNjcmlwdGlvbkZyb21SdWltICYmIG1JY2NSZWNvcmRzICE9IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2coIkdFVF9DRE1BX1NVQlNDUklQVElPTiBzZXQgaW1zaSBpbiBtSWNjUmVjb3JkcyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgfQpAQCAtNDI3LDcgKzQy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AgICAgICAgICAgICAvL1s4XSBzeXN0ZW1JZAotICAgICAgICAgICAgaW50IG5ldHdvcmtJZCA9IDA7ICAgICAgICAgICAgIC8vWzldIG5ldHdvcmtJZAotICAgICAgICAgICAgaW50IHJvYW1pbmdJbmRpY2F0b3IgPSAtMTsgICAgIC8vWzEwXSBSb2FtaW5nIGluZGljYXRvcgotICAgICAgICAgICAgaW50IHN5c3RlbUlzSW5QcmwgPSAwOyAgICAgICAgIC8vWzExXSBJbmRpY2F0ZXMgaWYgY3VycmVudCBzeXN0ZW0gaXMgaW4gUFJMCi0gICAgICAgICAgICBpbnQgZGVmYXVsdFJvYW1pbmdJbmRpY2F0b3IgPSAwOyAgLy9bMTJdIElzIGRlZmF1bHQgcm9hbWluZyBpbmRpY2F0b3IgZnJvbSBQUkwKLSAgICAgICAgICAgIGludCByZWFzb25Gb3JEZW5pYWwgPSAwOyAgICAgICAvL1sxM10gRGVuaWFsIHJlYXNvbiBpZiByZWdpc3RyYXRpb25TdGF0ZSA9IDMKLQotICAgICAgICAgICAgaWYgKHN0YXRlcy5sZW5ndGggPj0gMTQpIHsKLSAgICAgICAgICAgICAgICB0cnkgewotICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzWzBdICE9IG51bGwpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIHJlZ2lzdHJhdGlvblN0YXRlID0gSW50ZWdlci5wYXJzZUludChzdGF0ZXNbMF0pOwotICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZXNbM10gIT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICAgICAgcmFkaW9UZWNobm9sb2d5ID0gSW50ZWdlci5wYXJzZUludChzdGF0ZXNbM10pOwotICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZXNbNF0gIT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICAgICAgYmFzZVN0YXRpb25JZCA9IEludGVnZXIucGFyc2VJbnQoc3RhdGVzWzRdKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzWzVdICE9IG51bGwpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VTdGF0aW9uTGF0aXR1ZGUgPSBJbnRlZ2VyLnBhcnNlSW50KHN0YXRlc1s1XSk7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlc1s2XSAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBiYXNlU3RhdGlvbkxvbmdpdHVkZSA9IEludGVnZXIucGFyc2VJbnQoc3RhdGVzWzZdKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICAvLyBTb21lIGNhcnJpZXJzIG9ubHkgcmV0dXJuIGxhdC1sbmdzIG9mIDAsMAotICAgICAgICAgICAgICAgICAgICBpZiAoYmFzZVN0YXRpb25MYXRpdHVkZSA9PSAwICYmIGJhc2VTdGF0aW9uTG9uZ2l0dWRlID09IDApIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VTdGF0aW9uTGF0aXR1ZGUgID0gQ2RtYUNlbGxMb2NhdGlvbi5JTlZBTElEX0xBVF9MT05HOwotICAgICAgICAgICAgICAgICAgICAgICAgYmFzZVN0YXRpb25Mb25naXR1ZGUgPSBDZG1hQ2VsbExvY2F0aW9uLklOVkFMSURfTEFUX0xPTkc7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlc1s3XSAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBjc3NJbmRpY2F0b3IgPSBJbnRlZ2VyLnBhcnNlSW50KHN0YXRlc1s3XSk7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlc1s4XSAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBzeXN0ZW1JZCA9IEludGVnZXIucGFyc2VJbnQoc3RhdGVzWzhdKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzWzldICE9IG51bGwpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIG5ldHdvcmtJZCA9IEludGVnZXIucGFyc2VJbnQoc3RhdGVzWzldKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzWzEwXSAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICByb2FtaW5nSW5kaWNhdG9yID0gSW50ZWdlci5wYXJzZUludChzdGF0ZXNbMTBdKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzWzExXSAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBzeXN0ZW1Jc0luUHJsID0gSW50ZWdlci5wYXJzZUludChzdGF0ZXNbMTFdKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzWzEyXSAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0Um9hbWluZ0luZGljYXRvciA9IEludGVnZXIucGFyc2VJbnQoc3RhdGVzWzEyXSk7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlc1sxM10gIT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uRm9yRGVuaWFsID0gSW50ZWdlci5wYXJzZUludChzdGF0ZXNbMTNdKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIH0gY2F0Y2ggKE51bWJlckZvcm1hdEV4Y2VwdGlvbiBleCkgewotICAgICAgICAgICAgICAgICAgICBsb2dlKCJFVkVOVF9QT0xMX1NUQVRFX1JFR0lTVFJBVElPTl9DRE1BOiBlcnJvciBwYXJzaW5nOiAiICsgZXgpOworICAgICAgICAgICAgY2FzZSBFVkVOVF9QT0xMX1NUQVRFX0dQUlM6IHsKKyAgICAgICAgICAgICAgICBzdGF0ZXMgPSAoU3RyaW5nW10pYXIucmVzdWx0OworICAgICAgICAgICAgICAgIGlmIChEQkcpIHsKKyAgICAgICAgICAgICAgICAgICAgbG9nKCJoYW5kbGVQb2xsU3RhdGVSZXN1bHRNZXNzYWdlOiBFVkVOVF9QT0xMX1NUQVRFX0dQUlMgc3RhdGVzLmxlbmd0aD0iICsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZXMubGVuZ3RoICsgIiBzdGF0ZXM9IiArIHN0YXRlcyk7CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICB0aHJvdyBuZXcgUnVudGltZUV4Y2VwdGlvbigiV2FybmluZyEgV3JvbmcgbnVtYmVyIG9mIHBhcmFtZXRlcnMgcmV0dXJuZWQgZnJvbSAiCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyAiUklMX1JFUVVFU1RfUkVHSVNUUkFUSU9OX1NUQVRFOiBleHBlY3RlZCAxNCBvciBtb3JlICIKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArICJzdHJpbmdzIGFuZCBnb3QgIiArIHN0YXRlcy5sZW5ndGggKyAiIHN0cmluZ3MiKTsKLSAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgbVJlZ2lzdHJhdGlvblN0YXRlID0gcmVnaXN0cmF0aW9uU3RhdGU7Ci0gICAgICAgICAgICAvLyBXaGVuIHJlZ2lzdHJhdGlvbiBzdGF0ZSBpcyByb2FtaW5nIGFuZCBUU0I1OAotICAgICAgICAgICAgLy8gcm9hbWluZyBpbmRpY2F0b3IgaXMgbm90IGluIHRoZSBjYXJyaWVyLXNwZWNpZmllZAotICA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Glzbid0IHZhbGlkIHVzZSBQUk9QRVJUWV9DRE1BX0hPTUVfT1BFUkFUT1JfTlVNRVJJQwotICAgICAgICAgICAgICAgIGlmICgob3BOYW1lc1syXSA9PSBudWxsKSB8fCAob3BOYW1lc1syXS5sZW5ndGgoKSA8IDUpCi0gICAgICAgICAgICAgICAgICAgICAgICB8fCAoIjAwMDAwIi5lcXVhbHMob3BOYW1lc1syXSkpKSB7Ci0gICAgICAgICAgICAgICAgICAgIG9wTmFtZXNbMl0gPSBTeXN0ZW1Qcm9wZXJ0aWVzLmdldCgKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBDRE1BUGhvbmUuUFJPUEVSVFlfQ0RNQV9IT01FX09QRVJBVE9SX05VTUVSSUMsICIwMDAwMCIpOwotICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBsb2coIlJJTF9SRVFVRVNUX09QRVJBVE9SLnJlc3BvbnNlWzJdLCB0aGUgbnVtZXJpYywgIiArCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICIgaXMgYmFkLiBVc2luZyBTeXN0ZW1Qcm9wZXJ0aWVzICciICsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDRE1BUGhvbmUuUFJPUEVSVFlfQ0RNQV9IT01FX09QRVJBVE9SX05VTUVSSUMgKwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiJz0gIiArIG9wTmFtZXNbMl0pOworICAgICAgICAgICAgICAgIGlmIChzdGF0ZXMubGVuZ3RoID4gMCkgeworICAgICAgICAgICAgICAgICAgICB0cnkgeworICAgICAgICAgICAgICAgICAgICAgICAgcmVnU3RhdGUgPSBJbnRlZ2VyLnBhcnNlSW50KHN0YXRlc1swXSk7CisgICAgCisgICAgICAgICAgICAgICAgICAgICAgICAvLyBzdGF0ZXNbM10gKGlmIHByZXNlbnQpIGlzIHRoZSBjdXJyZW50IHJhZGlvIHRlY2hub2xvZ3kKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZXMubGVuZ3RoID49IDQgJiYgc3RhdGVzWzNdICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhUmFkaW9UZWNobm9sb2d5ID0gSW50ZWdlci5wYXJzZUludChzdGF0ZXNbM10pOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChOdW1iZXJGb3JtYXRFeGNlcHRpb24gZXgpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGxvZ2UoImhhbmRsZVBvbGxTdGF0ZVJlc3VsdE1lc3NhZ2U6IGVycm9yIHBhcnNpbmcgR3Byc1JlZ2lzdHJhdGlvblN0YXRlOiAiCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyBleCk7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgICAgICBpZiAoIWlzU3Vic2NyaXB0aW9uRnJvbVJ1aW0pIHsKLSAgICAgICAgICAgICAgICAgICAgLy8gSW4gQ0RNQSBpbiBjYXNlIG9uIE5WLCB0aGUgc3MubU9wZXJhdG9yQWxwaGFMb25nIGlzIHNldCBsYXRlciB3aXRoIHRoZQotICAgICAgICAgICAgICAgICAgICAvLyBFUkkgdGV4dCwgc28gaGVyZSBpdCBpcyBpZ25vcmVkIHdoYXQgaXMgY29taW5nIGZyb20gdGhlIG1vZGVtLgotICAgICAgICAgICAgICAgICAgICBuZXdTUy5zZXRPcGVyYXRvck5hbWUobnVsbCwgb3BOYW1lc1sxXSwgb3BOYW1lc1syXSk7CisgICAgICAgICAgICAgICAgaW50IGRhdGFSZWdTdGF0ZSA9IHJlZ0NvZGVUb1NlcnZpY2VTdGF0ZShyZWdTdGF0ZSk7CisgICAgICAgICAgICAgICAgbU5ld1NTLnNldERhdGFSZWdTdGF0ZShkYXRhUmVnU3RhdGUpOworICAgICAgICAgICAgICAgIG1OZXdTUy5zZXRSaWxEYXRhUmFkaW9UZWNobm9sb2d5KGRhdGFSYWRpb1RlY2hub2xvZ3kpOworICAgICAgICAgICAgICAgIGlmIChEQkcpIHsKKyAgICAgICAgICAgICAgICAgICAgbG9nKCJoYW5kbFBvbGxTdGF0ZVJlc3VsdE1lc3NhZ2U6IGNkbWEgc2V0RGF0YVJlZ1N0YXRlPSIgKyBkYXRhUmVnU3RhdGUKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICArICIgcmVnU3RhdGU9IiArIHJlZ1N0YXRlCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyAiIGRhdGFSYWRpb1RlY2hub2xvZ3k9IiArIGRhdGFSYWRpb1RlY2hub2xvZ3kpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIH0KKworICAgICAgICAgICAgY2FzZSBFVkVOVF9QT0xMX1NUQVRFX1JFR0lTVFJBVElPTl9DRE1BOiAvLyBIYW5kbGUgUklMX1JFUVVFU1RfUkVHSVNUUkFUSU9OX1NUQVRFLgorICAgICAgICAgICAgICAgIHN0YXRlcyA9IChTdHJpbmdbXSlhci5yZXN1bHQ7CisKKyAgICAgICAgICAgICAgICBpbnQgcmVnaXN0cmF0aW9uU3RhdGUgPSA0OyAgICAgLy9bMF0gcmVnaXN0cmF0aW9uU3RhdGUKKyAgICAgICAgICAgICAgICBpbnQgcmFkaW9UZWNobm9sb2d5ID0gLTE7ICAgICAgLy9bM10gcmFkaW9UZWNobm9sb2d5CisgICAgICAgICAgICAgICAgaW50IGJhc2VTdGF0aW9uSWQgPSAtMTsgICAgICAgIC8vWzRdIGJhc2VTdGF0aW9uSWQKKyAgICAgICAgICAgICAgICAvL1s1XSBiYXNlU3RhdGlvbkxhdGl0dWRlCisgICAgICAgICAgICAgICAgaW50IGJhc2VTdGF0aW9uTGF0aXR1ZGUgPSBDZG1hQ2VsbExvY2F0aW9uLklOVkFMSURfTEFUX0xPTkc7CisgICAgICAgICAgICAgICAgLy9bNl0gYmFzZVN0YXRpb25Mb25naXR1ZGUKKyAgICAgICAgICAgICAgICBpbnQgYmFzZVN0YXRpb25Mb25naXR1ZGUgPSBDZG1hQ2VsbExvY2F0aW9uLklOVkFMSURfTEFUX0xPTkc7CisgICAgICAgICAgICAgICAgaW50IGNzc0luZGljYXRvciA9IDA7ICAgICAgICAgIC8vWzddIGluaXQgd2l0aCAwLCBiZWNhdXNlIGl0IGlzIHRyZWF0ZWQgYXMgYSBib29sZWFuCisgICAgICAgICAgICAgICAgaW50IHN5c3RlbUlkID0gMDsgICAgICAgICAgICAgIC8vWzhdIHN5c3RlbUlkCisgICAgICAgICAgICAgICAgaW50IG5ldHdvcmtJZCA9IDA7ICAgICAgICAgICAgIC8vWzldIG5ldHdvcmtJZAorICAgICAgICAgICAgICAgIGludCByb2FtaW5nSW5kaWNhdG9yID0gLTE7ICAgICAvL1sxMF0gUm9hbWluZyBpbmRpY2F0b3IKKyAgICAgICAgICAgICAgICBpbnQgc3lzdGVtSXNJblBybCA9IDA7ICAgICAgICAgLy9bMTFdIEluZGljYXRlcyBpZiBjdXJyZW50IHN5c3RlbSBpcyBpbiBQUkwKKyAgICAgICAgICAgICAgICBpbnQgZGVmYXVsdFJvYW1pbmdJbmRpY2F0b3IgPSAwOyAgLy9bMTJdIElzIGRlZmF1bHQgcm9hbWluZyBpbmRpY2F0b3IgZnJvbSBQUkwKKyAgICAgICAgICAgICAgICBpbnQgcmVhc29uRm9yRGVuaWFsID0gMDsgICAgICAgLy9bMTNdIERlbmlhbCByZWFzb24gaWYgcmVnaXN0cmF0aW9uU3RhdGUgPSAzCisKKyAgICAgICAgICAgICAgICBpZiAoc3RhdGVzLmxlbmd0aCA+PSAxNCkgeworICAgICAgICAgICAgICAgICAgICB0cnkgeworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlc1swXSAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVnaXN0cmF0aW9uU3RhdGUgPSBJbnRlZ2VyLnBhcnNlSW50KHN0YXRlc1swXSk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzWzNdICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICByYWRpb1RlY2hub2xvZ3kgPSBJbnRlZ2VyLnBhcnNlSW50KHN0YXRlc1szXSk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzWzRdICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYXNlU3RhdGlvbklkID0gSW50ZWdlci5wYXJzZUludChzdGF0ZXNbNF0pOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlc1s1XSAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFzZVN0YXRpb25MYXRpdHVkZSA9IEludGVnZXIucGFyc2VJbnQoc3RhdGVzWzVdKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZXNbNl0gIT0gbnVsbCkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VTdGF0aW9uTG9uZ2l0dWRlID0gSW50ZWdlci5wYXJzZUludChzdGF0ZXNbNl0pOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgLy8gU29tZSBjYXJyaWVycyBvbmx5IHJldHVybiBsYXQtbG5ncyBvZiAwLDAKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChiYXNlU3RhdGlvbkxhdGl0dWRlID09IDAgJiYgYmFzZVN0YXRpb25Mb25naXR1ZGUgPT0gMCkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VTdGF0aW9uTGF0aXR1ZGUgID0gQ2RtYUNlbGxMb2NhdGlvbi5JTlZBTElEX0xBVF9MT05HOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VTdGF0aW9uTG9uZ2l0dWRlID0gQ2RtYUNlbGxMb2NhdGlvbi5JTlZBTElEX0xBVF9MT05HOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlc1s3XSAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3NzSW5kaWNhdG9yID0gSW50ZWdlci5wYXJzZUludChzdGF0ZXNbN10pOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlc1s4XSAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3lzdGVtSWQgPSBJbnRlZ2VyLnBhcnNlSW50KHN0YXRlc1s4XSk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzWzldICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXR3b3JrSWQgPSBJbnRlZ2VyLnBhcnNlSW50KHN0YXRlc1s5XSk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzWzEwXSAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm9hbWluZ0luZGljYXRvciA9IEludGVnZXIucGFyc2VJbnQoc3RhdGVzWzEwXSk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzWzExXSAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3lzdGVtSXNJblBybCA9IEludGVnZXIucGFyc2VJbnQoc3RhdGVzWzExXSk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzWzEyXSAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdFJvYW1pbmdJbmRpY2F0b3IgPSBJbnRlZ2VyLnBhcnNlSW50KHN0YXRlc1sxMl0pOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlc1sxM10gIT0gbnVsbCkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbkZvckRlbmlhbCA9IEludGVnZXIucGFyc2VJbnQoc3RhdGVzWzEzXSk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKE51bWJlckZvcm1hdEV4Y2VwdGlvbiBleCkgeworICAgICAgICAgICAgICAgICAgICAgICAgbG9nZSgiRVZFTlRfUE9MTF9TVEFURV9SRUdJU1RSQVRJT05fQ0RNQTogZXJyb3IgcGFyc2luZzogIiArIGV4KTsKKyAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgIG5ld1NTLnNldE9wZXJhdG9yTmFtZShvcE5hbWVzWzBdLCBvcE5hbWVzWzFdLCBvcE5hbWVzWzJdKTsKKyAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IFJ1bnRpbWVFeGNlcHRpb24oIldhcm5pbmchIFdyb25nIG51bWJlciBvZiBwYXJhbWV0ZXJzIHJldHVybmVkIGZyb20gIgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArICJSSUxfUkVRVUVTVF9SRUdJU1RSQVRJT05fU1RBVEU6IGV4cGVjdGVkIDE0IG9yIG1vcmUgIgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArICJzdHJpbmdzIGFuZCBnb3QgIiArIHN0YXRlcy5sZW5ndGggKyAiIHN0cmluZ3M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isgICAgICAgICAgICAgICAgbU5ld1NTLnNldFJpbFZvaWNlUmFkaW9UZWNobm9sb2d5KHJhZGlvVGVjaG5vbG9neSk7CisKKyAgICAgICAgICAgICAgICBtTmV3U1Muc2V0Q3NzSW5kaWNhdG9yKGNzc0luZGljYXRvcik7CisgICAgICAgICAgICAgICAgbU5ld1NTLnNldFN5c3RlbUFuZE5ldHdvcmtJZChzeXN0ZW1JZCwgbmV0d29ya0lkKTsKKyAgICAgICAgICAgICAgICBtUm9hbWluZ0luZGljYXRvciA9IHJvYW1pbmdJbmRpY2F0b3I7CisgICAgICAgICAgICAgICAgbUlzSW5QcmwgPSAoc3lzdGVtSXNJblBybCA9PSAwKSA/IGZhbHNlIDogdHJ1ZTsKKyAgICAgICAgICAgICAgICBtRGVmYXVsdFJvYW1pbmdJbmRpY2F0b3IgPSBkZWZhdWx0Um9hbWluZ0luZGljYXRvcjsKKworCisgICAgICAgICAgICAgICAgLy8gVmFsdWVzIGFyZSAtMSBpZiBub3QgYXZhaWxhYmxlLgorICAgICAgICAgICAgICAgIG1OZXdDZWxsTG9jLnNldENlbGxMb2NhdGlvbkRhdGEoYmFzZVN0YXRpb25JZCwgYmFzZVN0YXRpb25MYXRpdHVkZSwKKyAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VTdGF0aW9uTG9uZ2l0dWRlLCBzeXN0ZW1JZCwgbmV0d29ya0lkKTsKKworICAgICAgICAgICAgICAgIGlmIChyZWFzb25Gb3JEZW5pYWwgPT0gMCkgeworICAgICAgICAgICAgICAgICAgICBtUmVnaXN0cmF0aW9uRGVuaWVkUmVhc29uID0gU2VydmljZVN0YXRlVHJhY2tlci5SRUdJU1RSQVRJT05fREVOSUVEX0dFTjsKKyAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHJlYXNvbkZvckRlbmlhbCA9PSAxKSB7CisgICAgICAgICAgICAgICAgICAgIG1SZWdpc3RyYXRpb25EZW5pZWRSZWFzb24gPSBTZXJ2aWNlU3RhdGVUcmFja2VyLlJFR0lTVFJBVElPTl9ERU5JRURfQVVUSDsKKyAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICBtUmVnaXN0cmF0aW9uRGVuaWVkUmVhc29uID0gIiI7CisgICAgICAgICAgICAgICAgfQorICAgIAorICAgICAgICAgICAgICAgIGlmIChtUmVnaXN0cmF0aW9uU3RhdGUgPT0gMykgeworICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coIlJlZ2lzdHJhdGlvbiBkZW5pZWQsICIgKyBtUmVnaXN0cmF0aW9uRGVuaWVkUmVhc29uKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgYnJlYWs7CisKKyAgICAgICAgICAgIGNhc2UgRVZFTlRfUE9MTF9TVEFURV9PUEVSQVRPUl9DRE1BOiAvLyBIYW5kbGUgUklMX1JFUVVFU1RfT1BFUkFUT1IKKyAgICAgICAgICAgICAgICBTdHJpbmcgb3BOYW1lc1tdID0gKFN0cmluZ1tdKWFyLnJlc3VsdDsKKyAgICAKKyAgICAgICAgICAgICAgICBpZiAob3BOYW1lcyAhPSBudWxsICYmIG9wTmFtZXMubGVuZ3RoID49IDMpIHsKKyAgICAgICAgICAgICAgICAgICAgLy8gSWYgdGhlIE5VTUVSSUMgZmllbGQgaXNuJ3QgdmFsaWQgdXNlIFBST1BFUlRZX0NETUFfSE9NRV9PUEVSQVRPUl9OVU1FUklDCisgICAgICAgICAgICAgICAgICAgIGlmICgob3BOYW1lc1syXSA9PSBudWxsKSB8fCAob3BOYW1lc1syXS5sZW5ndGgoKSA8IDUpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgfHwgKCIwMDAwMCIuZXF1YWxzKG9wTmFtZXNbMl0pKSkgeworICAgICAgICAgICAgICAgICAgICAgICAgb3BOYW1lc1syXSA9IFN5c3RlbVByb3BlcnRpZXMuZ2V0KAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDRE1BUGhvbmUuUFJPUEVSVFlfQ0RNQV9IT01FX09QRVJBVE9SX05VTUVSSUMsICIwMDAwMCIpOworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvZygiUklMX1JFUVVFU1RfT1BFUkFUT1IucmVzcG9uc2VbMl0sIHRoZSBudW1lcmljLCAiICsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICIgaXMgYmFkLiBVc2luZyBTeXN0ZW1Qcm9wZXJ0aWVzICciICsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ0RNQVBob25lLlBST1BFUlRZX0NETUFfSE9NRV9PUEVSQVRPUl9OVU1FUklDICsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICInPSAiICsgb3BOYW1lc1syXSk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIH0KKworICAgICAgICAgICAgICAgICAgICBpZiAoIW1Jc1N1YnNjcmlwdGlvbkZyb21SdWltKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAvLyBJbiBDRE1BIGluIGNhc2Ugb24gTlYsIHRoZSBzcy5tT3BlcmF0b3JBbHBoYUxvbmcgaXMgc2V0IGxhdGVyIHdpdGggdGhlCisgICAgICAgICAgICAgICAgICAgICAgICAvLyBFUkkgdGV4dCwgc28gaGVyZSBpdCBpcyBpZ25vcmVkIHdoYXQgaXMgY29taW5nIGZyb20gdGhlIG1vZGVtLgorICAgICAgICAgICAgICAgICAgICAgICAgbU5ld1NTLnNldE9wZXJhdG9yTmFtZShudWxsLCBvcE5hbWVzWzFdLCBvcE5hbWVzWzJdKTsKKyAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1OZXdTUy5zZXRPcGVyYXRvck5hbWUob3BOYW1lc1swXSwgb3BOYW1lc1sxXSwgb3BOYW1lc1syXSk7CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coIkVWRU5UX1BPTExfU1RBVEVfT1BFUkFUT1JfQ0RNQTogZXJyb3IgcGFyc2luZyBvcE5hbWVzIik7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGJyZWFrOworCisgICAgICAgICAgICAKKyAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgCisgICAgICAgICAgICAgICAgCisgICAgICAgICAgICAgICAgbG9nZSgiaGFuZGxlUG9sbFN0YXRlUmVzdWx0TWVzc2FnZTogUklMIHJlc3BvbnNlIGhhbmRsZSBpbiB3cm9uZyBwaG9uZSEiCisgICAgICAgICAgICAgICAgICAgICAgICArICIgRXhwZWN0ZWQgQ0RNQSBSSUwgcmVxdWVzdCBhbmQgZ2V0IEdTTSBSSUwgcmVxdWVzdC4iKTsKKyAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogICAgIH0KIApAQCAtNzE1LDcgKzc0MCw3IEBACiAgICAgQE92ZXJyaWRlCiAgICAgcHJvdGVjdGVkIHZvaWQgaGFuZGxlUG9sbFN0YXRlUmVzdWx0KGludCB3aGF0LCBBc3luY1Jlc3VsdCBhcikgewogICAgICAgICAvLyBJZ25vcmUgc3RhbGUgcmVxdWVzdHMgZnJvbSBsYXN0IHBvbGwuCi0gICAgICAgIGlmIChhci51c2VyT2JqICE9IHBvbGxpbmdDb250ZXh0KSByZXR1cm47CisgICAgICAgIGlmIChhci51c2VyT2JqICE9IG1Qb2xsaW5nQ29udGV4dCkgcmV0dXJuOwogCiAgICAgICAgIGlmIChhci5leGNlcHRpb24gIT0gbnVsbCkgewogICAgICAgICAgICAgQ29tbWFuZEV4Y2VwdGlvbi5FcnJvciBlcnI9bnVsbDsKQEAgLTczMCw3ICs3NTUsNyBAQAogICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgaWYgKCFjbS5nZXRSYWRpb1N0YXRlKCkuaXNPbigpKSB7CisgICAgICAgICAgICBpZiAoIW1DaS5nZXRSYWRpb1N0YXRlKCkuaXNPbigpKSB7CiAgICAgICAgICAgICAgICAgLy8gUmFkaW8gaGFzIGNyYXNoZWQgb3IgdHVybmVkIG9mZi4KICAgICAgICAgICAgICAgICBjYW5jZWxQb2xsU3RhdGUoKTsKICAgICAgICAgICAgICAgICByZXR1cm47CkBAIC03NDcsNjEgKzc3Miw2MSBAQAogICAgICAgICAgICAgICAgICAgICArICJQcm9iYWJseSBtYWxmb3JtZWQgUklMIHJlc3BvbnNlLiIgKyBleCk7CiAgICAgICAgIH0KIAotICAgICAgICBwb2xsaW5nQ29udGV4dFswXS0tOworICAgICAgICBtUG9sbGluZ0NvbnRleHRbMF0tLTsKIAotICAgICAgICBpZiAocG9sbGluZ0NvbnRleHRbMF0gPT0gMCkgeworICAgICAgICBpZiAobVBvbGxpbmdDb250ZXh0WzBdID09IDApIHsKICAgICAgICAgICAgIGJvb2xlYW4gbmFtTWF0Y2ggPSBmYWxzZTsKLSAgICAgICAgICAgIGlmICghaXNTaWRzQWxsWmVyb3MoKSAmJiBpc0hvbWVTaWQobmV3U1MuZ2V0U3lzdGVtSWQoKSkpIHsKKyAgICAgICAgICAgIGlmICghaXNTaWRzQWxsWmVyb3MoKSAmJiBpc0hvbWVTaWQobU5ld1NTLmdldFN5c3RlbUlkKCkpKSB7CiAgICAgICAgICAgICAgICAgbmFtTWF0Y2ggPSB0cnVlOwogICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAvLyBTZXR0aW5nIFNTIFJvYW1pbmcgKGdlbmVyYWwpCi0gICAgICAgICAgICBpZiAoaXNTdWJzY3JpcHRpb25Gcm9tUnVpbSkgewotICAgICAgICAgICAgICAgIG5ld1NTLnNldFJvYW1pbmcoaXNSb2FtaW5nQmV0d2Vlbk9wZXJhdG9ycyhtQ2RtYVJvYW1pbmcsIG5ld1NTKSk7CisgICAgICAgICAgICBpZi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pSW5mby5ST0FNSU5HX0lORElDQVRPUl9PRkYpOworICAgICAgICAgICAgICAgIG1OZXdTUy5zZXRDZG1hUm9hbWluZ0luZGljYXRvcihFcmlJbmZvLlJPQU1JTkdfSU5ESUNBVE9SX09GRik7CiAgICAgICAgICAgICB9IGVsc2UgaWYgKCFpc1NpZHNBbGxaZXJvcygpKSB7CiAgICAgICAgICAgICAgICAgaWYgKCFuYW1NYXRjaCAmJiAhbUlzSW5QcmwpIHsKICAgICAgICAgICAgICAgICAgICAgLy8gVXNlIGRlZmF1bHQKLSAgICAgICAgICAgICAgICAgICAgbmV3U1Muc2V0Q2RtYVJvYW1pbmdJbmRpY2F0b3IobURlZmF1bHRSb2FtaW5nSW5kaWNhdG9yKTsKKyAgICAgICAgICAgICAgICAgICAgbU5ld1NTLnNldENkbWFSb2FtaW5nSW5kaWNhdG9yKG1EZWZhdWx0Um9hbWluZ0luZGljYXRvcik7CiAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChuYW1NYXRjaCAmJiAhbUlzSW5QcmwpIHsKLSAgICAgICAgICAgICAgICAgICAgbmV3U1Muc2V0Q2RtYVJvYW1pbmdJbmRpY2F0b3IoRXJpSW5mby5ST0FNSU5HX0lORElDQVRPUl9GTEFTSCk7CisgICAgICAgICAgICAgICAgICAgIG1OZXdTUy5zZXRDZG1hUm9hbWluZ0luZGljYXRvcihFcmlJbmZvLlJPQU1JTkdfSU5ESUNBVE9SX0ZMQVNIKTsKICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKCFuYW1NYXRjaCAmJiBtSXNJblBybCkgewogICAgICAgICAgICAgICAgICAgICAvLyBVc2UgdGhlIG9uZSBmcm9tIFBSTC9FUkkKLSAgICAgICAgICAgICAgICAgICAgbmV3U1Muc2V0Q2RtYVJvYW1pbmdJbmRpY2F0b3IobVJvYW1pbmdJbmRpY2F0b3IpOworICAgICAgICAgICAgICAgICAgICBtTmV3U1Muc2V0Q2RtYVJvYW1pbmdJbmRpY2F0b3IobVJvYW1pbmdJbmRpY2F0b3IpOwogICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgIC8vIEl0IG1lYW5zIG5hbU1hdGNoICYmIG1Jc0luUHJsCiAgICAgICAgICAgICAgICAgICAgIGlmICgobVJvYW1pbmdJbmRpY2F0b3IgPD0gMikpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIG5ld1NTLnNldENkbWFSb2FtaW5nSW5kaWNhdG9yKEVyaUluZm8uUk9BTUlOR19JTkRJQ0FUT1JfT0ZGKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1OZXdTUy5zZXRDZG1hUm9hbWluZ0luZGljYXRvcihFcmlJbmZvLlJPQU1JTkdfSU5ESUNBVE9SX09GRik7CiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBVc2UgdGhlIG9uZSBmcm9tIFBSTC9FUkkKLSAgICAgICAgICAgICAgICAgICAgICAgIG5ld1NTLnNldENkbWFSb2FtaW5nSW5kaWNhdG9yKG1Sb2FtaW5nSW5kaWNhdG9yKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1OZXdTUy5zZXRDZG1hUm9hbWluZ0luZGljYXRvcihtUm9hbWluZ0luZGljYXRvcik7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgIGludCByb2FtaW5nSW5kaWNhdG9yID0gbmV3U1MuZ2V0Q2RtYVJvYW1pbmdJbmRpY2F0b3IoKTsKLSAgICAgICAgICAgIG5ld1NTLnNldENkbWFFcmlJY29uSW5kZXgocGhvbmUubUVyaU1hbmFnZXIuZ2V0Q2RtYUVyaUljb25JbmRleChyb2FtaW5nSW5kaWNhdG9yLAorICAgICAgICAgICAgaW50IHJvYW1pbmdJbmRpY2F0b3IgPSBtTmV3U1MuZ2V0Q2RtYVJvYW1pbmdJbmRpY2F0b3IoKTsKK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ICAgICAgICArICIuIG5hbU1hdGNoID0gIiArIG5hbU1hdGNoICsgIiAsIG1Jc0luUHJsID0gIiArIG1Jc0luUHJsCiAgICAgICAgICAgICAgICAgICAgICsgIiwgbVJvYW1pbmdJbmRpY2F0b3IgPSAiICsgbVJvYW1pbmdJbmRpY2F0b3IKQEAgLTgyNiwxNCArODUxLDEzIEBACiAgICAgICovCiAgICAgcHJvdGVjdGVkIHZvaWQKICAgICBwb2xsU3RhdGUoKSB7Ci0gICAgICAgIHBvbGxpbmdDb250ZXh0ID0gbmV3IGludFsxXTsKLSAgICAgICAgcG9sbGluZ0NvbnRleHRbMF0gPSAwOworICAgICAgICBtUG9sbGluZ0NvbnRleHQgPSBuZXcgaW50WzFdOworICAgICAgICBtUG9sbGluZ0NvbnRleHRbMF0gPSAwOwogCi0gICAgICAgIHN3aXRjaCAoY20uZ2V0UmFkaW9TdGF0ZSgpKSB7CisgICAgICAgIHN3aXRjaCAobUNpLmdldFJhZGlvU3RhdGUoKSkgewogICAgICAgICBjYXNlIFJBRElPX1VOQVZBSUxBQkxFOgotICAgICAgICAgICAgbmV3U1Muc2V0U3RhdGVPdXRPZlNlcnZpY2UoKTsKLSAgICAgICAgICAgIG1OZXdEYXRhQ29ubmVjdGlvblN0YXRlID0gU2VydmljZVN0YXRlLlNUQVRFX09VVF9PRl9TRVJWSUNFOwotICAgICAgICAgICAgbmV3Q2VsbExvYy5zZXRTdGF0ZUludmFsaWQoKTsKKyAgICAgICAgICAgIG1OZXdTUy5zZXRTdGF0ZU91dE9mU2VydmljZSgpOworICAgICAgICAgICAgbU5ld0NlbGxMb2Muc2V0U3RhdGVJbnZhbGlkKCk7CiAgICAgICAgICAgICBzZXRTaWduYWxTdHJlbmd0aERlZmF1bHRWYWx1ZXMoKTsKICAgICAgICAgICAgIG1Hb3RDb3VudHJ5Q29kZSA9IGZhbHNlOwogCkBAIC04NDEsOSArODY1LDggQEAKICAgICAgICAgICAgIGJyZWFrOwogCiAgICAgICAgIGNhc2UgUkFESU9fT0ZGOgotICAgICAgICAgICAgbmV3U1Muc2V0U3RhdGVPZmYoKTsKLSAgICAgICAgICAgIG1OZXdEYXRhQ29ubmVjdGlvblN0YXRlID0gU2VydmljZVN0YXRlLlNUQVRFX1BPV0VSX09GRjsKLSAgICAgICAgICAgIG5ld0NlbGxMb2Muc2V0U3RhdGVJbnZhbGlkKCk7CisgICAgICAgICAgICBtTmV3U1Muc2V0U3RhdGVPZmYoKTsKKyAgICAgICAgICAgIG1OZXdDZWxsTG9jLnNldFN0YXRlSW52YWxpZCgpOwogICAgICAgICAgICAgc2V0U2lnbmFsU3RyZW5ndGhEZWZhdWx0VmFsdWVzKCk7CiAgICAgICAgICAgICBtR290Q291bnRyeUNvZGUgPSBmYWxzZTsKIApAQCAtODU1LDE2ICs4NzgsMjAgQEAKICAgICAgICAgICAgIC8vIGRvd24gdGhlIHJlc3BvbnNlcyB3aGljaCBhcmUgYWxsb3dlZCB0byBhcnJpdmUKICAgICAgICAgICAgIC8vIG91dC1vZi1vcmRlci4KIAotICAgICAgICAgICAgcG9sbGluZ0NvbnRleHRbMF0rKzsKKyAgICAgICAgICAgIG1Qb2xsaW5nQ29udGV4dFswXSsrOwogICAgICAgICAgICAgLy8gUklMX1JFUVVFU1RfT1BFUkFUT1IgaXMgbmVjZXNzYXJ5IGZvciBDRE1BCi0gICAgICAgICAgICBjbS5nZXRPcGVyYXRvcigKLSAgICAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZShFVkVOVF9QT0xMX1NUQVRFX09QRVJBVE9SX0NETUEsIHBvbGxpbmdDb250ZXh0KSk7CisgICAgICAgICAgICBtQ2kuZ2V0T3BlcmF0b3IoCisgICAgICAgICAgICAgICAgICAgIG9idGFpbk1lc3NhZ2UoRVZFTlRfUE9MTF9TVEFURV9PUEVSQVRPUl9DRE1BLCBtUG9sbGluZ0NvbnRleHQpKTsKIAotICAgICAgICAgICAgcG9sbGluZ0NvbnRleHRbMF0rKzsKKyAgICAgICAgICAgIG1Qb2xsaW5nQ29udGV4dFswXSsrOwogICAgICAgICAgICAgLy8gUklMX1JFUVVFU1RfVk9JQ0VfUkVHSVNUUkFUSU9OX1NUQVRFIGlzIG5lY2Vzc2FyeSBmb3IgQ0RNQQotICAgICAgICAgICAgY20uZ2V0Vm9pY2VSZWdpc3RyYXRpb25TdGF0ZSgKLSAgICAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZShFVkVOVF9QT0xMX1NUQVRFX1JFR0lTVFJBVElPTl9DRE1BLCBwb2xsaW5nQ29udGV4dCkpOworICAgICAgICAgICAgbUNpLmdldFZvaWNlUmVnaXN0cmF0aW9uU3RhdGUoCisgICAgICAgICAgICAgICAgICAgIG9idGFpbk1lc3NhZ2UoRVZFTlRfUE9MTF9TVEFURV9SRUdJU1RSQVRJT05fQ0RNQSwgbVBvbGxpbmdDb250ZXh0KSk7CiAKKyAgICAgICAgICAgIG1Qb2xsaW5nQ29udGV4dFswXSsrOworICAgICAgICAgICAgLy8gUklMX1JFUVVFU1RfREFUQV9SRUdJU1RSQVRJT05fU1RBVEUKKyAgICAgICAgICAgIG1DaS5nZXREYXRhUmVnaXN0cmF0aW9uU3RhdGUob2J0YWluTWVzc2FnZShFVkVOVF9QT0xMX1NUQVRFX0dQUlMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbVBvbGxpbmdDb250ZXh0KSk7CiAgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogICAgIH0KQEAgLTkzMCw2NiArOTU3LDYyIEBACiAgICAgfQogCiAgICAgcHJvdGVjdGVkIHZvaWQgcG9sbFN0YXRlRG9uZSgpIHsKLSAgICAgICAgaWYgKERCRykgbG9nKCJwb2xsU3RhdGVEb25lOiBvbGRTUz1bIiArIHNzICsgIl0gbmV3U1M9WyIgKyBuZXdTUyArICJdIik7CisgICAgICAgIGlmIChEQkcpIGxvZygicG9sbFN0YXRlRG9uZTogY2RtYSBvbGRTUz1bIiArIG1TUyArICJdIG5ld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RSBpcyB2YWxpZCB1c2VkIGZvcgogICAgICAgICAgICAgICAgICAgICAvLyBtUmVnaXN0cmF0aW9uU3RhdGUgMCwyLDMgYW5kIDQKLSAgICAgICAgICAgICAgICAgICAgZXJpVGV4dCA9IHBob25lLmdldENvbnRleHQoKS5nZXRUZXh0KAorICAgICAgICAgICAgICAgICAgICBlcmlUZXh0ID0gbVBob25lLmdldENvbnRleHQoKS5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLnJvYW1pbmdUZXh0U2VhcmNoaW5nKS50b1N0cmluZygpOwogICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBzcy5zZXRPcGVyYXRvckFscGhhTG9uZyhlcmlUZXh0KTsKKyAgICAgICAgICAgICAgICBtU1Muc2V0T3BlcmF0b3JBbHBoYUxvbmcoZXJpVGV4dCk7CiAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgIFN0cmluZyBvcGVyYXRvck51bWVyaWM7CiAKLSAgICAgICAgICAgIHBob25lLnNldFN5c3RlbVByb3BlcnR5KFRlbGVwaG9ueVByb3BlcnRpZXMuUFJPUEVSVFlfT1BFUkFUT1JfQUxQSEEsCi0gICAgICAgICAgICAgICAgICAgIHNzLmdldE9wZXJhdG9yQWxwaGFMb25nKCkpOworICAgICAgICAgICAgbVBob25lLnNldFN5c3RlbVByb3BlcnR5KFRlbGVwaG9ueVByb3BlcnRpZXMuUFJPUEVSVFlfT1BFUkFUT1JfQUxQSEEsCisgICAgICAgICAgICAgICAgICAgIG1TUy5nZXRPcGVyYXRvckFscGhhTG9uZygpKTsKIAogICAgICAgICAgICAgU3RyaW5nIHByZXZPcGVyYXRvck51bWVyaWMgPQogICAgICAgICAgICAgICAgICAgICBTeXN0ZW1Qcm9wZXJ0aWVzLmdldChUZWxlcGhvbnlQcm9wZXJ0aWVzLlBST1BFUlRZX09QRVJBVE9SX05VTUVSSUMsICIiKTsKLSAgICAgICAgICAgIG9wZXJhdG9yTnVtZXJpYyA9IHNzLmdldE9wZXJhdG9yTnVtZXJpYygpOwotICAgICAgICAgICAgcGhvbmUuc2V0U3lzdGVtUHJvcGVydHkoVGVsZXBob255UHJvcGVydGllcy5QUk9QRVJUWV9PUEVSQVRPUl9OVU1FUklDLCBvcGVyYXRvck51bWVyaWMpOworICAgICAgICAgICAgb3BlcmF0b3JOdW1lcmljID0gbVNTLmdldE9wZXJhdG9yTnVtZXJpYygpOworICAgICAgICAgICAgbVBob25lLnNldFN5c3RlbVByb3BlcnR5KFRlbGVwaG9ueVByb3BlcnRpZXMuUFJPUEVSVFlfT1BFUkFUT1JfTlVNRVJJQywgb3BlcmF0b3JOdW1lcmljKTsKIAogICAgICAgICAgICAgaWYgKG9wZXJhdG9yTnVtZXJpYyA9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJvcGVyYXRvck51bWVyaWMgaXMgbnVsbCIpOwotICAgICAgICAgICAgICAgIHBob25lLnNldFN5c3RlbVByb3BlcnR5KFRlbGVwaG9ueVByb3BlcnRpZXMuUFJPUEVSVFlfT1BFUkFUT1JfSVNPX0NPVU5UUlksICIiKTsKKyAgICAgICAgICAgICAgICBtUGhvbmUuc2V0U3lzdGVtUHJvcGVydHkoVGVsZXBob255UHJvcGVydGllcy5QUk9QRVJUWV9PUEVSQVRPUl9JU09fQ09VTlRSWSwgIiIpOwogICAgICAgICAgICAgICAgIG1Hb3RDb3VudHJ5Q29kZSA9IGZhbHNlOwogICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICBTdHJpbmcgaXNvQ291bnRyeUNvZGUgPSAiIjsKQEAgLTEwMzcsMjEgKzEwNjAsMjEgQEAKICAgICAgICAgICAgICAgICAgICAgbG9nZSgicG9sbFN0YXRlRG9uZTogY291bnRyeUNvZGVGb3JNY2MgZXJyb3IiICsgZXgpOwogICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgICAgIHBob25lLnNldFN5c3RlbVByb3BlcnR5KFRlbGVwaG9ueVByb3BlcnRpZXMuUFJPUEVSVFlfT1BFUkFUT1JfSVNPX0NPVU5UUlksCisgICAgICAgICAgICAgICAgbVBob25lLnNldFN5c3RlbVByb3BlcnR5KFRlbGVwaG9ueVByb3BlcnRpZXMuUFJPUEVSVFlfT1BFUkFUT1JfSVNPX0NPVU5UUlksCiAgICAgICAgICAgICAgICAgICAgICAgICBpc29Db3VudHJ5Q29kZSk7CiAgICAgICAgICAgICAgICAgbUdvdENvdW50cnlDb2RlID0gdHJ1ZTsKIAotICAgICAgICAgICAgICAgIGlmIChzaG91bGRGaXhUaW1lWm9uZU5vdyhwaG9uZSwgb3BlcmF0b3JOdW1lcmljLCBwcmV2T3BlcmF0b3JOdW1lcmljLAorICAgICAgICAgICAgICAgIGlmIChzaG91bGRGaXhUaW1lWm9uZU5vdyhtUGhvbmUsIG9wZXJhdG9yTnVtZXJpYywgcHJldk9wZXJhdG9yTnVtZXJpYywKICAgICAgICAgICAgICAgICAgICAgICAgIG1OZWVkRml4Wm9uZSkpIHsKICAgICAgICAgICAgICAgICAgICAgZml4VGltZVpvbmUoaXNvQ291bnRyeUNvZGUpOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgcGhvbmUuc2V0U3lzdGVtUHJvcGVydHkoVGVsZXBob255UHJvcGVydGllcy5QUk9QRVJUWV9PUEVSQVRPUl9JU1JPQU1JTkcsCi0gICAgICAgICAgICAgICAgICAgIHNzLmdldFJvYW1pbmcoKSA/ICJ0cnVlIiA6ICJmYWxzZSIpOworICAgICAgICAgICAgbVBob25lLnNldFN5c3RlbVByb3BlcnR5KFRlbGVwaG9ueVByb3BlcnRpZXMuUFJPUEVSVFlfT1BFUkFUT1JfSVNST0FNSU5HLAorICAgICAgICAgICAgICAgICAgICBtU1MuZ2V0Um9hbWluZygpID8gInRydWUiIDogImZhbHNlIik7CiAKICAgICAgICAgICAgIHVwZ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3RoKSB7CiAgICAgICAgICAgICAvLyBUaGUgcmFkaW8gaXMgdGVsbGluZyB1cyBhYm91dCBzaWduYWwgc3RyZW5ndGggY2hhbmdlcwogICAgICAgICAgICAgLy8gd2UgZG9uJ3QgaGF2ZSB0byBhc2sgaXQKICAgICAgICAgICAgIHJldHVybjsKQEAgLTExODEsOCArMTIwNCw5IEBACiAgICAgICAgIH0KICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgaW50IGdldEN1cnJlbnREYXRhQ29ubmVjdGlvblN0YXRlKCkgewotICAgICAgICByZXR1cm4gbURhdGFDb25uZWN0aW9uU3RhdGU7CisgICAgICAgIHJldHVybiBtU1MuZ2V0RGF0YVJlZ1N0YXRlKCk7CiAgICAgfQogCiAgICAgLyoqCkBAIC0xNDAyLDkgKzE0MjYsOSBAQAogICAgICAgICAgICAgICAgICAgICAgKi8KICAgICAgICAgICAgICAgICAgICAgbG9uZyBnYWluZWQgPSBjLmdldFRpbWVJbk1pbGxpcygpIC0gU3lzdGVtLmN1cnJlbnRUaW1lTWlsbGlzKCk7CiAgICAgICAgICAgICAgICAgICAgIGxvbmcgdGltZVNpbmNlTGFzdFVwZGF0ZSA9IFN5c3RlbUNsb2NrLmVsYXBzZWRSZWFsdGltZSgpIC0gbVNhdmVkQXRUaW1lOwotICAgICAgICAgICAgICAgICAgICBpbnQgbml0elVwZGF0ZVNwYWNpbmcgPSBTZXR0aW5ncy5HbG9iYWwuZ2V0SW50KGNyLAorICAgICAgICAgICAgICAgICAgICBpbnQgbml0elVwZGF0ZVNwYWNpbmcgPSBTZXR0aW5ncy5HbG9iYWwuZ2V0SW50KG1DciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTZXR0aW5ncy5HbG9iYWwuTklUWl9VUERBVEVfU1BBQ0lORywgbU5pdHpVcGRhdGVTcGFjaW5nKTsKLSAgICAgICAgICAgICAgICAgICAgaW50IG5pdHpVcGRhdGVEaWZmID0gU2V0dGluZ3MuR2x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meVJlZ2lzdHJhbnRzKCk7CiAgICAgICAgIH0KICAgICAgICAgaWYgKG9sZE90YXNwTW9kZSAhPSBtQ3VycmVudE90YXNwTW9kZSkgewogICAgICAgICAgICAgaWYgKERCRykgewogICAgICAgICAgICAgICAgIGxvZygiQ0RNQV9TVUJTQ1JJUFRJT046IGNhbGwgbm90aWZ5T3Rhc3BDaGFuZ2VkIG9sZCBvdGFzcE1vZGU9IiArCiAgICAgICAgICAgICAgICAgICAgIG9sZE90YXNwTW9kZSArICIgbmV3IG90YXNwTW9kZT0iICsgbUN1cnJlbnRPdGFzcE1vZGUpOwogICAgICAgICAgICAgfQotICAgICAgICAgICAgcGhvbmUubm90aWZ5T3Rhc3BDaGFuZ2VkKG1DdXJyZW50T3Rhc3BNb2RlKTsKKyAgICAgICAgICAgIG1QaG9uZS5ub3RpZnlPdGFzcENoYW5nZWQobUN1cnJlbnRPdGFzcE1vZGUpOwogICAgICAgICB9CiAgICAgfQogCkBAIC0xNjkxLDcgKzE3MTYsNyBAQAogICAgICAgICAgICAgICAgIGxvZygiTmV3IGNhcmQgZm91bmQiKTsKICAgICAgICAgICAgICAgICBtVWljY0FwcGxjYXRpb24gPSBuZXdVaWNjQXBwbGljYXRpb247CiAgICAgICAgICAgICAgICAgbUljY1JlY29yZHMgPSBtVWljY0FwcGxjYXRpb24uZ2V0SWNjUmVjb3JkcygpOwotICAgICAgICAgICAgICAgIGlmIChpc1N1YnNjcmlwdGlvbkZyb21SdWltKSB7CisgICAgICAgICAgICAgICAgaWYgKG1Jc1N1YnNjcmlwdGlvbkZyb21SdWltKSB7CiAgICAgICAgICAgICAgICAgICAgIG1VaWNjQXBwbGNhdGlvbi5yZWdpc3RlckZvclJlYWR5KHRoaXMsIEVWRU5UX1JVSU1fUkVBRFksIG51bGwpOwogICAgICAgICAgICAgICAgICAgICBpZiAobUljY1JlY29yZHMgIT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgbUljY1JlY29yZHMucmVnaXN0Z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ICAgICAgIH0KLSAgICAgICAgICAgIHNJbnN0YW5jZS5zUmVmZXJlbmNlQ291bnQrKzsKKyAgICAgICAgICAgIENkbWFTdWJzY3JpcHRpb25Tb3VyY2VNYW5hZ2VyLnNSZWZlcmVuY2VDb3VudCsrOwogICAgICAgICB9CiAgICAgICAgIHNJbnN0YW5jZS5yZWdpc3RlckZvckNkbWFTdWJzY3JpcHRpb25Tb3VyY2VDaGFuZ2VkKGgsIHdoYXQsIG9iaik7CiAgICAgICAgIHJldHVybiBzSW5zdGFuY2U7CkBAIC05MSw4ICs4OSw4IEBACiAgICAgICAgIHN5bmNocm9uaXplZCAoc1JlZmVyZW5jZUNvdW50TW9uaXRvcikgewogICAgICAgICAgICAgc1JlZmVyZW5jZUNvdW50LS07CiAgICAgICAgICAgICBpZiAoc1JlZmVyZW5jZUNvdW50IDw9IDApIHsKLSAgICAgICAgICAgICAgICBtQ00udW5yZWdpc3RlckZvckNkbWFTdWJzY3JpcHRpb25DaGFuZ2VkKHRoaXMpOwotICAgICAgICAgICAgICAgIG1DTS51bnJlZ2lzdGVyRm9yT24odGhpcyk7CisgICAgICAgICAgICAgICAgbUNpLnVucmVnaXN0ZXJGb3JDZG1hU3Vic2NyaXB0aW9uQ2hhbmdlZCh0aGlzKTsKKyAgICAgICAgICAgICAgICBtQ2kudW5yZWdpc3RlckZvck9uKHRoaXMpOwogICAgICAgICAgICAgICAgIHNJbnN0YW5jZSA9IG51bGw7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KQEAgLTExNSw3ICsxMTMsNyBAQAogICAgICAgICAgICAgfQogICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICBjYXNlIEVWRU5UX1JBRElPX09OOiB7Ci0gICAgICAgICAgICAgICAgbUNNLmdldENkbWFTdWJzY3JpcHRpb25Tb3VyY2Uob2J0YWluTWVzc2FnZShFVkVOVF9HRVRfQ0RNQV9TVUJTQ1JJUFRJT05fU09VUkNFKSk7CisgICAgICAgICAgICAgICAgbUNp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U1JTkdfSUNPTl9NT0RFX05PUk1BTCAgICA9IDA7CiAgICAgcHVibGljIHN0YXRpYyBmaW5hbCBpbnQgUk9BTUlOR19JQ09OX01PREVfRkxBU0ggICAgID0gMTsKIAotICAgIHB1YmxpYyBpbnQgbVJvYW1pbmdJbmRpY2F0b3I7Ci0gICAgcHVibGljIGludCBtSWNvbkluZGV4OwotICAgIHB1YmxpYyBpbnQgbUljb25Nb2RlOwotICAgIHB1YmxpYyBTdHJpbmcgbUVyaVRleHQ7Ci0gICAgcHVibGljIGludCBtQ2FsbFByb21wdElkOwotICAgIHB1YmxpYyBpbnQgbUFsZXJ0SWQ7CisgICAgcHVibGljIGludCByb2FtaW5nSW5kaWNhdG9yOworICAgIHB1YmxpYyBpbnQgaWNvbkluZGV4OworICAgIHB1YmxpYyBpbnQgaWNvbk1vZGU7CisgICAgcHVibGljIFN0cmluZyBlcmlUZXh0OworICAgIHB1YmxpYyBpbnQgY2FsbFByb21wdElkOworICAgIHB1YmxpYyBpbnQgYWxlcnRJZDsKIAogICAgIHB1YmxpYyBFcmlJbmZvIChpbnQgcm9hbWluZ0luZGljYXRvciwgaW50IGljb25JbmRleCwgaW50IGljb25Nb2RlLCBTdHJpbmcgZXJpVGV4dCwKICAgICAgICAgICAgIGludCBjYWxsUHJvbXB0SWQsIGludCBhbGVydElkKSB7CiAKLSAgICAgICAgdGhpcy5tUm9hbWluZ0luZGljYXRvciA9IHJvYW1pbmdJbmRpY2F0b3I7Ci0gICAgICAgIHRoaXMubUljb25JbmRleCA9IGljb25JbmRleDsKLSAgICAgICAgdGhpcy5tSWNvbk1vZGUgPSBpY29uTW9kZTsKLSAgICAgICAgdGhpcy5tRXJpVGV4dCA9IGVyaVRleHQ7Ci0gICAgICAgIHRoaXMubUNhbGxQcm9tcHRJZCA9IGNhbGxQcm9tcHRJZDsKLSAgICAgICAgdGhpcy5tQWxlcnRJZCA9IGFsZXJ0SWQ7CisgICAgICAgIHRoaXMucm9hbWluZ0luZGljYXRvci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vbmVCYXNlOwogaW1wb3J0IGNvbS5hbmRyb2lkLmludGVybmFsLnV0aWwuWG1sVXRpbHM7CiAKQEAgLTQ0LDM4ICs0MiwzOCBAQAogCiAgICAgY2xhc3MgRXJpRmlsZSB7CiAKLSAgICAgICAgcHVibGljIGludCBtVmVyc2lvbk51bWJlcjsgICAgICAgICAgICAgICAgICAgICAgLy8gRmlsZSB2ZXJzaW9uIG51bWJlcgotICAgICAgICBwdWJsaWMgaW50IG1OdW1iZXJPZkVyaUVudHJpZXM7ICAgICAgICAgICAgICAgICAvLyBOdW1iZXIgb2YgZW50cmllcwotICAgICAgICBwdWJsaWMgaW50IG1FcmlGaWxlVHlwZTsgICAgICAgICAgICAgICAgICAgICAgICAvLyBFcmkgUGhhc2UgMC8xCi0gICAgICAgIC8vcHVibGljIGludCBtTnVtYmVyT2ZJY29uSW1hZ2VzOyAgICAgICAgICAgICAgIC8vIHJlc2VydmVkIGZvciBmdXR1cmUgdXNlCi0gICAgICAgIC8vcHVibGljIGludCBtSWNvbkltYWdlVHlwZTsgICAgICAgICAgICAgICAgICAgIC8vIHJlc2VydmVkIGZvciBmdXR1cmUgdXNlCi0gICAgICAgIHB1YmxpYyBTdHJpbmdbXSBtQ2FsbFByb21wdElkOyAgICAgICAgICAgICAgICAgIC8vIHJlc2VydmVkIGZvciBmdXR1cmUgdXNlCi0gICAgICAgIHB1YmxpYyBIYXNoTWFwPEludGVnZXIsIEVyaUluZm8+IG1Sb2FtSW5kVGFibGU7IC8vIFJvYW1pbmcgSW5kaWNhdG9yIFRhYmxlCisgICAgICAgIGludCBtVmVyc2lvbk51bWJlcjsgICAgICAgICAgICAgICAgICAgICAgLy8gRmlsZSB2ZXJzaW9uIG51bWJlcgorICAgICAgICBpbnQgbU51bWJlck9mRXJpRW50cmllczsgICAgICAgICAgICAgICAgIC8vIE51bWJlciBvZiBlbnRyaWVzCisgICAgICAgIGludCBtRXJpRmlsZVR5cGU7ICAgICAgICAgICAgICAgICAgICAgICAgLy8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TsKICAgICAgICAgfQogICAgIH0KIAogICAgIGNsYXNzIEVyaURpc3BsYXlJbmZvcm1hdGlvbiB7Ci0gICAgICAgIHB1YmxpYyBpbnQgbUVyaUljb25JbmRleDsKLSAgICAgICAgcHVibGljIGludCBtRXJpSWNvbk1vZGU7Ci0gICAgICAgIHB1YmxpYyBTdHJpbmcgbUVyaUljb25UZXh0OworICAgICAgICBpbnQgbUVyaUljb25JbmRleDsKKyAgICAgICAgaW50IG1FcmlJY29uTW9kZTsKKyAgICAgICAgU3RyaW5nIG1FcmlJY29uVGV4dDsKIAotICAgICAgICBwdWJsaWMgRXJpRGlzcGxheUluZm9ybWF0aW9uKGludCBlcmlJY29uSW5kZXgsIGludCBlcmlJY29uTW9kZSwgU3RyaW5nIGVyaUljb25UZXh0KSB7CisgICAgICAgIEVyaURpc3BsYXlJbmZvcm1hdGlvbihpbnQgZXJpSWNvbkluZGV4LCBpbnQgZXJpSWNvbk1vZGUsIFN0cmluZyBlcmlJY29uVGV4dCkgewogICAgICAgICAgICAgbUVyaUljb25JbmRleCA9IGVyaUljb25JbmRleDsKICAgICAgICAgICAgIG1FcmlJY29uTW9kZSA9IGVyaUljb25Nb2RlOwogICAgICAgICAgICAgbUVyaUljb25UZXh0ID0gZXJpSWNvblRleHQ7CiAgICAgICAgIH0KIAogLy8gICAgICAgIHB1YmxpYyB2b2lkIHNldFBhcmFtZXRlcnMoaW50IGVyaUljb25JbmRleCwgaW50IGVyaUljb25Nb2RlLCBTdHJpbmcgZXJpSWNvblRleHQpewotLy8gICAgICAgICAgICB0aGlzLm1FcmlJY29uSW5kZXggPSBlcmlJY29uSW5kZXg7Ci0vLyAgICAgICAgICAgIHRoaXMubUVyaUljb25Nb2RlID0gZXJpSWNvbk1vZGU7Ci0vLyAgICAgICAgICAgIHRoaXMubUVyaUljb25UZXh0ID0gZXJpSWNvblRleHQ7CisvLyAgICAgICAgICAgIG1FcmlJY29uSW5kZXggPSBlcmlJY29uSW5kZXg7CisvLyAgICAg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YWRlZDsKKyAgICAgICAgcmV0dXJuIG1Jc0VyaUZpbGVMb2FkZWQ7CiAgICAgfQogCiAgICAgLyoqCkBAIC0yODcsMTQgKzI4MywxNCBAQAogICAgICAgICBFcmlEaXNwbGF5SW5mb3JtYXRpb24gcmV0OwogCiAgICAgICAgIC8vIENhcnJpZXIgY2FuIHVzZSBlcmkueG1sIHRvIGN1c3RvbWl6ZSBhbnkgYnVpbHQtaW4gcm9hbWluZyBkaXNwbGF5IGluZGljYXRpb25zCi0gICAgICAgIGlmIChpc0VyaUZpbGVMb2FkZWQpIHsKKyAgICAgICAgaWYgKG1Jc0VyaUZpbGVMb2FkZWQpIHsKICAgICAgICAgICAgIEVyaUluZm8gZXJpSW5mbyA9IGdldEVyaUluZm8ocm9hbUluZCk7CiAgICAgICAgICAgICBpZiAoZXJpSW5mbyAhPSBudWxsKSB7CiAgICAgICAgICAgICAgICAgaWYgKFZEQkcpIFJsb2cudihMT0dfVEFHLCAiRVJJIHJvYW1JbmQgIiArIHJvYW1JbmQgKyAiIGZvdW5kIGluIEVSSSBmaWxlIik7CiAgICAgICAgICAgICAgICAgcmV0ID0gbmV3IEVyaURpc3BsYXlJbmZvcm1hdGlvbigKLSAgICAgICAgICAgICAgICAgICAgICAgIGVyaUluZm8ubUljb25JbmRleCwKLSAgICAgICAgICAgICAgICAgICAgICAgIGVyaUluZm8ubUljb25Nb2RlLAotICAgICAgICAgICAgICAgICAgICAgICAgZXJpSW5mby5tRXJpVGV4dCk7CisgICAgICAgICAgICAgICAgICAgICAgICBlcmlJbmZvLmljb25JbmRleCwKKyAgICAgICAgICAgICAgICAgICAgICAgIGVyaUluZm8uaWNvbk1vZGUsCisgICAgICAgICAgICAgICAgICAgICAgICBlcmlJbmZvLmVyaVRleHQpOwogICAgICAgICAgICAgICAgIHJldHVybiByZXQ7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KQEAgLTM5Niw3ICszOTIsNyBAQAogCiAgICAgICAgIC8vIEhhbmRsaW5nIHRoZSBub24gc3RhbmRhcmQgRW5oYW5jZWQgUm9hbWluZyBJbmRpY2F0b3IgKHJvYW1JbmQgPiA2MykKICAgICAgICAgZGVmYXVsdDoKLSAgICAgICAgICAgIGlmICghaXNFcmlGaWxlTG9hZGVkKSB7CisgICAgICAgICAgICBpZiAoIW1Jc0VyaUZpbGVMb2FkZWQpIHsKICAgICAgICAgICAgICAgICAvLyBFUkkgZmlsZSBOT1QgbG9hZGVkCiAgICAgICAgICAgICAgICAgaWYgKERCRykgUmxvZy5kKExPR19UQUcsICJFUkkgRmlsZSBub3QgbG9hZGVkIik7CiAgICAgICAgICAgICAgICAgaWYoZGVmUm9hbUluZCA+IDIpIHsKQEAgLTQ2MCwxNiArNDU2LDE2IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUmxvZy52KExPR19UQUcsICJFUkkgZGVmUm9hbUluZCAiICsgZGVmUm9hbUluZCArICIgZm91bmQgaW4gRVJJIGZpbGUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgIHJldCA9IG5ldyBFcmlEaXNwbGF5SW5mb3JtYXRpb24oCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZkVyaUluZm8ubUljb25JbmRleCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmRXJpSW5mby5tSWNvbk1vZGUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZkVyaUluZm8ubUVyaVRleHQpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZFcmlJbmZvLmljb25JbmRleCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmRXJpSW5mby5pY29uTW9kZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmRXJpSW5mby5lcmlUZXh0KTsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgIGlmIChWREJHKSBSbG9nLnYoTE9HX1RBRywgIkVSSSByb2FtSW5kICIgKyByb2FtSW5kICsgIiBmb3VuZCBpbiBFUkkgZmlsZSIpOwogICAgICAgICAgICAgICAgICAgICByZXQgPSBuZXcgRXJpRGlzcGxheUluZm9ybWF0aW9uKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVyaUluZm8ubUljb25JbmRleCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcmlJbmZvLm1JY29uTW9kZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcmlJbmZvLm1FcmlUZXh0KTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcmlJbmZvLmljb25JbmRleCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcmlJbmZvLmljb25Nb2RlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVyaUluZm8uZXJpVGV4dCk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogICAgICAgICAgICAgYnJlYWs7CmRpZmYgLS1naXQgYS9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvY2RtYS9SdWltUGhvbmVCb29rSW50ZXJmYWNlTWFuYWdlci5qYXZhIGIvc3JjL2phdmEvY29tL2FuZHJvaWQvaW50ZXJuYWwvdGVsZXBob255L2NkbWEvUnVpbVBob25lQm9va0ludGVyZmFjZU1hbmFnZXIuamF2YQppbmRleCA3NWIyZjU5Li5hZjE4MzI0IDEwMDY0NAotLS0gYS9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvY2RtYS9SdWltUGhvbmVCb29rSW50ZXJmYWNlTWFuYWdlci5qYXZhCisrKyBiL3NyYy9qYXZhL2NvbS9hbmRyb2lkL2ludGVybmFsL3RlbGVwaG9ueS9jZG1hL1J1aW1QaG9uZUJvb2tJbnRlcmZhY2VNYW5hZ2VyLmphdmEKQEAgLTMxLDE3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gICAgICAgLy8gbGluayB0aGUgdGhlIGZpbGxlZCBvYmplY3RzIHRvIHRoZSBTTVMKICAgICAgICAgZW52Lm9yaWdBZGRyZXNzID0gYWRkcjsKICAgICAgICAgZW52Lm9yaWdTdWJhZGRyZXNzID0gc3ViYWRkcjsKLSAgICAgICAgbXNnLm9yaWdpbmF0aW5nQWRkcmVzcyA9IGFkZHI7CisgICAgICAgIG1zZy5tT3JpZ2luYXRpbmdBZGRyZXNzID0gYWRkcjsKICAgICAgICAgbXNnLm1FbnZlbG9wZSA9IGVudjsKIAogICAgICAgICAvLyBjcmVhdGUgYnl0ZSBzdHJlYW0gcmVwcmVzZW50YXRpb24gZm9yIHRyYW5zcG9ydGF0aW9uIHRocm91Z2ggdGhlIGxheWVycy4KQEAgLTIzMiw3ICsyMzIsNyBAQAogICAgICAgICB0cnkgewogICAgICAgICAgICAgU21zTWVzc2FnZSBtc2cgPSBuZXcgU21zTWVzc2FnZSgpOwogCi0gICAgICAgICAgICBtc2cuaW5kZXhPbkljYyA9IGluZGV4OworICAgICAgICAgICAgbXNnLm1JbmRleE9uSWNjID0gaW5kZXg7CiAKICAgICAgICAgICAgIC8vIEZpcnN0IGJ5dGUgaXMgc3RhdHVzOiBSRUNFSVZFRF9SRUFELCBSRUNFSVZFRF9VTlJFQUQsIFNUT1JFRF9TRU5ULAogICAgICAgICAgICAgLy8gb3IgU1RPUkVEX1VOU0VOVApAQCAtMjQxLDcgKzI0MSw3IEBACiAgICAgICAgICAgICAgICAgUmxvZy53KExPR19UQUcsICJTTVMgcGFyc2luZyBmYWlsZWQ6IFRyeWluZyB0byBwYXJzZSBhIGZyZWUgcmVjb3JkIik7CiAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgIG1zZy5zdGF0dXNPbkljYyA9IGRhdGFbMF0gJiAweDA3OworICAgICAgICAgICAgICAgIG1zZy5tU3RhdHVzT25JY2MgPSBkYXRhWzB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BpcyBub3Qgc3VwcG9ydGVkIGluIENETUEgbW9kZS4KICAgICAgKi8KKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgYm9vbGVhbiBpc0NwaHNNd2lNZXNzYWdlKCkgewogICAgICAgICBSbG9nLncoTE9HX1RBRywgImlzQ3Boc013aU1lc3NhZ2U6IGlzIG5vdCBzdXBwb3J0ZWQgaW4gQ0RNQSBtb2RlLiIpOwogICAgICAgICByZXR1cm4gZmFsc2U7CkBAIC0zOTUsNiArMzk4LDcgQEAKICAgICAvKioKICAgICAgKiB7QGluaGVyaXREb2N9CiAgICAgICovCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGJvb2xlYW4gaXNNV0lDbGVhck1lc3NhZ2UoKSB7CiAgICAgICAgIHJldHVybiAoKG1CZWFyZXJEYXRhICE9IG51bGwpICYmIChtQmVhcmVyRGF0YS5udW1iZXJPZk1lc3NhZ2VzID09IDApKTsKICAgICB9CkBAIC00MDIsNiArNDA2LDcgQEAKICAgICAvKioKICAgICAgKiB7QGluaGVyaXREb2N9CiAgICAgICovCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGJvb2xlYW4gaXNNV0lTZXRNZXNzYWdlKCkgewogICAgICAgICByZXR1cm4gKChtQmVhcmVyRGF0YSAhPSBudWxsKSAmJiAobUJlYXJlckRhdGEubnVtYmVyT2ZNZXNzYWdlcyA+IDApKTsKICAgICB9CkBAIC00MDksNiArNDE0LDcgQEAKICAgICAvKioKICAgICAgKiB7QGluaGVyaXREb2N9CiAgICAgICovCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGJvb2xlYW4gaXNNd2lEb250U3RvcmUoKSB7CiAgICAgICAgIHJldHVybiAoKG1CZWFyZXJEYXRhICE9IG51bGwpICYmCiAgICAgICAgICAgICAgICAgKG1CZWFyZXJEYXRhLm51bWJlck9mTWVzc2FnZXMgPiAwKSAmJgpAQCAtNDIwLDExICs0MjYsMTMgQEAKICAgICAgKiBGb3Igbm90IGludGVy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ICAgICAgIG1PcmlnaW5hdGluZ0FkZHJlc3MgPSBhZGRyOwogICAgICAgICBlbnYub3JpZ0FkZHJlc3MgPSBhZGRyOwogICAgICAgICBtRW52ZWxvcGUgPSBlbnY7CiAgICAgICAgIG1QZHUgPSBwZHU7CkBAIC02NjAsNyArNjY5LDcgQEAKICAgICAgICAgfQogCiAgICAgICAgIC8vIGxpbmsgdGhlIGZpbGxlZCBvYmplY3RzIHRvIHRoaXMgU01TCi0gICAgICAgIG9yaWdpbmF0aW5nQWRkcmVzcyA9IGFkZHI7CisgICAgICAgIG1PcmlnaW5hdGluZ0FkZHJlc3MgPSBhZGRyOwogICAgICAgICBlbnYub3JpZ0FkZHJlc3MgPSBhZGRyOwogICAgICAgICBlbnYub3JpZ1N1YmFkZHJlc3MgPSBzdWJBZGRyOwogICAgICAgICBtRW52ZWxvcGUgPSBlbnY7CkBAIC02ODAsNyArNjg5LDcgQEAKICAgICAgICAgICAgIGlmIChtRW52ZWxvcGUuYmVhcmVyRGF0YSAhPSBudWxsKSB7CiAgICAgICAgICAgICAgICAgbUJlYXJlckRhdGEubnVtYmVyT2ZNZXNzYWdlcyA9IDB4MDAwMDAwRkYgJiBtRW52ZWxvcGUuYmVhcmVyRGF0YVswXTsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGlmIChmYWxzZSkgeworICAgICAgICAgICAgaWYgKFZEQkcpIHsKICAgICAgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgInBhcnNlU21zOiBnZXQgTVdJICIgKwogICAgICAgICAgICAgICAgICAgICAgIEludGVnZXIudG9TdHJpbmcobUJlYXJlckRhdGEubnVtYmVyT2ZNZXNzYWdlcykpOwogICAgICAgICAgICAgfQpAQCAtNjkyLDI0ICs3MDEsMjQgQEAKICAgICAgICAgICAgICAgICAgICAgICBIZXhEdW1wLnRvSGV4U3RyaW5nKG1FbnZlbG9wZS5iZWFyZXJEYXRhKSArICInIik7CiAgICAgICAgICAgICBSbG9nLmQoTE9HX1RBR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IDApLgogICAgICAgICAgICAgaWYgKCEgbUJlYXJlckRhdGEubWVzc2FnZVN0YXR1c1NldCkgewogICAgICAgICAgICAgICAgIFJsb2cuZChMT0dfVEFHLCAiREVMSVZFUllfQUNLIG1lc3NhZ2Ugd2l0aG91dCBtc2dTdGF0dXMgKCIgKwotICAgICAgICAgICAgICAgICAgICAgICAgKHVzZXJEYXRhID09IG51bGwgPyAiYWxzbyBtaXNzaW5nIiA6ICJkb2VzIGhhdmUiKSArCisgICAgICAgICAgICAgICAgICAgICAgICAobVVzZXJEYXRhID09IG51bGwgPyAiYWxzbyBtaXNzaW5nIiA6ICJkb2VzIGhhdmUiKSArCiAgICAgICAgICAgICAgICAgICAgICAgICAiIHVzZXJEYXRhKS4iKTsKICAgICAgICAgICAgICAgICBzdGF0dXMgPSAwOwogICAgICAgICAgICAgfSBlbHNlIHsKQEAgLTczMywxMSArNzQyLDExIEBACiAgICAgICAgICAgICB0aHJvdyBuZXcgUnVudGltZUV4Y2VwdGlvbigiVW5zdXBwb3J0ZWQgbWVzc2FnZSB0eXBlOiAiICsgbUJlYXJlckRhdGEubWVzc2FnZVR5cGUpOwogICAgICAgICB9CiAKLSAgICAgICAgaWYgKG1lc3NhZ2VCb2R5ICE9IG51bGwpIHsKLSAgICAgICAgICAgIGlmIChmYWxzZSkgUmxvZy52KExPR19UQUcsICJTTVMgbWVzc2FnZSBib2R5OiAnIiArIG1lc3NhZ2VCb2R5ICsgIiciKTsKKyAgICAgICAgaWYgKG1NZXNzYWdlQm9keSAhPSBudWxsKSB7CisgICAgICAgICAgICBpZiAoVkRCRykgUmxvZy52KExPR19UQUcsICJTTVMgbWVzc2FnZSBib2R5OiAnIiArIG1NZXNzYWdlQm9keSArICInIik7CiAgICAgICAgICAgICBwYXJzZU1lc3NhZ2VCb2R5KCk7Ci0gICAgICAgIH0gZWxzZSBpZiAoKHVzZXJEYXRhICE9IG51bGwpICYmIChmYWxzZSkpIHsKLSAgICAgICAgICAgIFJsb2cudihMT0d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F0YUNvbm5lY3Rpb247CiAgICAgfQogCi0gICAgcHVibGljIHN5bmNocm9uaXplZCB2b2lkIHNldERhdGFDb25uZWN0aW9uKERhdGFDb25uZWN0aW9uIGRjKSB7CisgICAgcHVibGljIHN5bmNocm9uaXplZCB2b2lkIHNldERhdGFDb25uZWN0aW9uKERhdGFDb25uZWN0aW9uQmFzZSBkYykgewogICAgICAgICBpZiAoREJHKSB7CiAgICAgICAgICAgICBsb2coInNldERhdGFDb25uZWN0aW9uOiBvbGQgZGM9IiArIG1EYXRhQ29ubmVjdGlvbiArICIgbmV3IGRjPSIgKyBkYyArICIgdGhpcz0iICsgdGhpcyk7CiAgICAgICAgIH0KQEAgLTk1LDE0ICs5OCwxNCBAQAogCiAgICAgcHVibGljIHN5bmNocm9uaXplZCB2b2lkIHNldERhdGFDb25uZWN0aW9uQWMoRGF0YUNvbm5lY3Rpb25BYyBkY2FjKSB7CiAgICAgICAgIGlmIChEQkcpIHsKLSAgICAgICAgICAgIGxvZygic2V0RGF0YUNvbm5lY3Rpb25BYzogb2xkIGRjYWM9IiArIG1EYXRhQ29ubmVjdGlvbkFjICsgIiBuZXcgZGNhYz0iICsgZGNhYyk7CisgICAgICAgICAgICBsb2coInNldERhdGFDb25uZWN0aW9uQWM6IG9sZCBkY2FjPSIgKyBtRGF0YUNvbm5lY3Rpb25BYyArICIgbmV3IGRjYWM9IiArIGRjYWMKKyAgICAgICAgICAgICAgICAgICAgKyAiIHRoaXM9IiArIHRoaXMpOwogICAgICAgICB9Ci0gICAgICAgIGlmIChkY2FjICE9IG51bGwpIHsKLSAgICAgICAgICAgIGRjYWMuYWRkQXBuQ29udGV4dFN5bmModGhpcyk7Ci0gICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICBpZiAobURhdGFDb25uZWN0aW9uQWMgIT0gbnVsbCkgewotICAgICAgICAgICAgICAgIG1EYXRhQ29ubmVjdGlvbkFjLnJlbW92ZUFwbkNvbnRleHRTeW5jKHRoaXMpOwotICAgICAgICAgICAgfQorICAgICAgICBpZiAoKGRjYWMgPT0gbnVsbCkgJiYgKG1EYXRhQ29ubmVjdGlvbkFjICE9IG51bGwpICYmCisgICAgICAgICAgICAgICAgKG1EYXRhQ29ubmVjdGlvbkFjLmRhdGFDb25uZWN0aW9uICE9IG51bGwpKSB7CisgICAgICAgICAgICAvLyBUT0RPOiBUaGlzIHRlYXJEb3duIHNob3VsZCBiZSBkb25lIGJ5IGNhbGxlciwgYnV0IGZvciBub3cgd2UnbGwgZG8gaXQKKyAgICAgICAgICAgIGlmIChEQkcpIGxvZygic2V0RGF0YUNvbm5lY3Rpb246IGNhbGwgdGVhckRvd24iKTsKKyAgICAgICAgICAgIG1EYXRhQ29ubmVjdGlvbkFjLmRhdGFDb25uZWN0aW9uLnRlYXJEb3duKHRoaXMsICIiLCBudWxsKTsKICAgICAgICAgfQogICAgICAgICBtRGF0YUNvbm5lY3Rpb25BYyA9IGRjYWM7CiAgICAgfQpAQCAtMTkwLDcgKzE5Myw3IEBACiAgICAgICAgICAgICBsb2coInNldFJldHJ5Q291bnQ6ICIgKyByZXRyeUNvdW50KTsKICAgICAgICAgfQogICAgICAgICBtUmV0cnlDb3VudCA9IHJldHJ5Q291bnQ7Ci0gICAgICAgIERhdGFDb25uZWN0aW9uIGRjID0gbURhdGFDb25uZWN0aW9uOworICAgICAgICBEYXRhQ29ubmVjdGlvbkJhc2UgZGMgPSBtRGF0YUNvbm5lY3Rpb247CiAgICAgICAgIGlmIChkYyAhPSBudWxsKSB7CiAgICAgICAgICAgICBkYy5zZXRSZXRyeUNvdW50KHJldHJ5Q291bnQpOwogICAgICAgICB9CkBAIC0yMzEsNyArMjM0LDkgQEAKICAgICAgICAgLy8gV2UgZG9uJ3QgcHJpbnQgbURhdGFDb25uZWN0aW9uIGJlY2F1c2UgaXRzIHJlY3Vyc2l2ZS4KICAgICAgICAgcmV0dXJuICJ7bUFwblR5cGU9IiArIG1BcG5UeXBlICsgIiBtU3RhdGU9IiArIGdldFN0YXRlKCkgKyAiIG1XYWl0aW5nQXBucz0iICsgbVdhaXRpbmdBcG5zICsKICAgICAgICAgICAgICAgICAiIG1XYWl0aW5nQXBuc1Blcm1hbmVudEZhaWx1cmVDb3VudERvd249IiArIG1XYWl0aW5nQXBuc1Blcm1hbmVudEZhaWx1cmVDb3VudERvd24gKwotICAgICAgICAgICAgICAgICIgbUFwblNldHRpbmc9IiArIG1BcG5TZXR0aW5nICsgIiBtRGF0YUNvbm5lY3Rpb25BYz0iICsgbURhdGFDb25uZWN0aW9uQWMgKworICAgICAgICAgICAgICAgICIgbUFwblNldHRpbmc9IiArIG1BcG5TZXR0aW5nICsKKyAgICAgICAgICAgICAgICAiIG1EYXRhQ29ubmVjdGlvbj0iICsgKChtRGF0YUNvbm5lY3Rpb24gIT0gbnVsbCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPyBtRGF0YUNvbm5lY3Rpb24udG9TdHJpbmdTaW1wbGUoKSA6ICJudWxsIikgKwogICAgICAgICAgICAgICAgICIgbVJlYXNvbj0iICsgbVJlYXNvbiArICIgbVJldHJ5Q291bnQ9IiArIG1SZXRyeUNvdW50ICsKICAgICAgICAgICAgICAgICAiIG1EYXRhRW5hYmxlZD0iICsgbURhdGFFbmFibGVkICsgIiBtRGVwZW5kZW5jeU1ldD0iICsgbURlcGVuZGVuY3lNZXQgKyAifSI7CiAgICAgfQpkaWZmIC0tZ2l0IGEvc3JjL2phdmEvY29tL2FuZHJvaWQvaW50ZXJuYWwvdGVsZXBob255L0FwblNldHRpbmcuamF2YSBiL3NyYy9qYXZhL2NvbS9hbmRyb2lkL2ludGVybmFsL3RlbGVwaG9ueS9kYXRhY29ubmVjdGlvbi9BcG5TZXR0aW5nLmphdmEKc2ltaWxhcml0eSBpbmRleCA5NiUKcmVuYW1lIGZyb20gc3JjL2phdmEvY29tL2FuZHJvaWQvaW50ZXJuYWwvdGVsZXBob255L0FwblNldHRpbmcuamF2YQpyZW5hbWUgdG8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KSk7CiAgICAgICAgIHJldHVybiBnc21EYzsKQEAgLTczLDE1ICs2OSwxNSBAQAogICAgIEBPdmVycmlkZQogICAgIHByb3RlY3RlZAogICAgIHZvaWQgb25Db25uZWN0KENvbm5lY3Rpb25QYXJhbXMgY3ApIHsKLSAgICAgICAgbUFwbiA9IGNwLmFwbjsKKyAgICAgICAgbUFwbiA9IGNwLm1BcG5Db250ZXh0LmdldEFwblNldHRpbmcoKTsKIAotICAgICAgICBpZiAoREJHKSBsb2coIkNvbm5lY3RpbmcgdG8gY2FycmllcjogJyIgKyBtQXBuLmNhcnJpZXIKLSAgICAgICAgICAgICAgICArICInIEFQTjogJyIgKyBtQXBuLmFwbgotICAgICAgICAgICAgICAgICsgIicgcHJveHk6ICciICsgbUFwbi5wcm94eSArICInIHBvcnQ6ICciICsgbUFwbi5wb3J0KTsKKyAgICAgICAgaWYgKERCRykgbG9nKCJvbkNvbm5lY3Q6IGNhcnJpZXI9JyIgKyBtQXBuLmNhcnJpZXIKKyAgICAgICAgICAgICAgICArICInIEFQTj0nIiArIG1BcG4uYXBuCisgICAgICAgICAgICAgICAgKyAiJyBwcm94eT0nIiArIG1BcG4ucHJveHkgKyAiJyBwb3J0PSciICsgbUFwbi5wb3J0ICsgIiciKTsKIAotICAgICAgICBjcmVhdGVUaW1lID0gLTE7Ci0gICAgICAgIGxhc3RGYWlsVGltZSA9IC0xOwotICAgICAgICBsYXN0RmFpbENhdXNlID0gRmFpbENhdXNlLk5PTkU7CisgICAgICAgIG1DcmVhdGVUaW1lID0gLTE7CisgICAgICAgIG1MYXN0RmFpbFRpbWUgPSAtMTsKKyAgICAgICAgbUxhc3RGYWlsQ2F1c2UgPSBGYWlsQ2F1c2UuTk9ORTsKIAogICAgICAgICAvLyBtc2cub2JqIHdpbGwgYmUgcmV0dXJuZWQgaW4gQXN5bmNSZXN1bHQudXNlck9iajsKICAgICAgICAgTWVzc2FnZSBtc2cgPSBvYnRhaW5NZXNzYWdlKEVWRU5UX1NFVFVQX0RBVEFfQ09OTkVDVElPTl9ET05FLCBjcCk7CkBAIC05NCwxNCArOTAsMTQgQEAKICAgICAgICAgfQogCiAgICAgICAgIFN0cmluZyBwcm90b2NvbDsKLSAgICAgICAgaWYgKHBob25lLmdldFNlcnZpY2VTdGF0ZSgpLmdldFJvYW1pbmcoKSkgeworICAgICAgICBpZiAobVBob25lLmdldFNlcnZpY2VTdGF0ZSgpLmdldFJvYW1pbmcoKSkgewogICAgICAgICAgICAgcHJvdG9jb2wgPSBtQXBuLnJvYW1pbmdQcm90b2NvbDsKICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIHByb3RvY29sID0gbUFwbi5wcm90b2NvbDsKICAgICAgICAgfQogCi0gICAgICAgIHBob25lLm1DTS5zZXR1cERhdGFDYWxsKAotICAgICAgICAgICAgICAgIEludGVnZXIudG9TdHJpbmcoZ2V0UmlsUmFkaW9UZWNobm9sb2d5KFJJTENvbnN0YW50cy5TRVRVUF9EQVRBX1RFQ0hfR1NNKSksCisgICAgICAgIG1QaG9uZS5tQ2kuc2V0dXBEYXRhQ2FsbCgKKyAgICAgICAgICAgICAgICBJbnRlZ2VyLnRvU3RyaW5nKGdldFJpbFJhZGlvVGVjaG5vbG9neSgpKSwKICAgICAgICAgICAgICAgICBJbnRlZ2VyLnRvU3RyaW5nKG1Qcm9maWxlSWQpLAogICAgICAgICAgICAgICAgIG1BcG4uYXBuLCBtQXBuLnVzZXIsIG1BcG4ucGFzc3dvcmQsCiAgICAgICAgICAgICAgICAgSW50ZWdlci50b1N0cmluZyhhdXRoVHlwZSksCkBAIC0xMTYsMTggKzExMiwyNCBAQAogICAgICAgICByZXR1cm4gbVByb2ZpbGVJZDsKICAgICB9CiAKKyAgICAvKiogRG9lc24ndCBwcmludCBtQXBuTGlzdCBvZiBBcG5Db250ZXh0J3Mgd2hpY2ggd291bGQgYmUgcmVjdXJzaXZlICovCisgICAgQE92ZXJyaWRlCisgICAgcHVibGljIFN0cmluZyB0b1N0cmluZ1N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AgICAgTWVzc2FnZSBtT25Db21wbGV0ZWRNc2c7CiAgICAgfQogCiAgICAgLyoqCiAgICAgICogVXNlZCBpbnRlcm5hbGx5IGZvciBzYXZpbmcgZGlzY29ubmVjdGluZyBwYXJhbWV0ZXJzLgogICAgICAqLwogICAgIHByb3RlY3RlZCBzdGF0aWMgY2xhc3MgRGlzY29ubmVjdFBhcmFtcyB7Ci0gICAgICAgIHB1YmxpYyBEaXNjb25uZWN0UGFyYW1zKFN0cmluZyByZWFzb24sIE1lc3NhZ2Ugb25Db21wbGV0ZWRNc2cpIHsKLSAgICAgICAgICAgIHRoaXMucmVhc29uID0gcmVhc29uOwotICAgICAgICAgICAgdGhpcy5vbkNvbXBsZXRlZE1zZyA9IG9uQ29tcGxldGVkTXNnOworICAgICAgICBEaXNjb25uZWN0UGFyYW1zKEFwbkNvbnRleHQgYXBuQ29udGV4dCwgU3RyaW5nIHJlYXNvbiwgTWVzc2FnZSBvbkNvbXBsZXRlZE1zZykgeworICAgICAgICAgICAgbUFwbkNvbnRleHQgPSBhcG5Db250ZXh0OworICAgICAgICAgICAgbVJlYXNvbiA9IHJlYXNvbjsKKyAgICAgICAgICAgIG1PbkNvbXBsZXRlZE1zZyA9IG9uQ29tcGxldGVkTXNnOwogICAgICAgICB9Ci0gICAgICAgIHB1YmxpYyBpbnQgdGFnOwotICAgICAgICBwdWJsaWMgU3RyaW5nIHJlYXNvbjsKLSAgICAgICAgcHVibGljIE1lc3NhZ2Ugb25Db21wbGV0ZWRNc2c7CisKKyAgICAgICAgaW50IG1UaGVUYWc7CisgICAgICAgIEFwbkNvbnRleHQgbUFwbkNvbnRleHQ7CisgICAgICAgIFN0cmluZyBtUmVhc29uOworICAgICAgICBNZXNzYWdlIG1PbkNvbXBsZXRlZE1zZzsKICAgICB9CiAKICAgICAvKioKQEAgLTE1Niw3ICsxNzAsNyBAQAogICAgICAgICAgICAgbUVycm9yQ29kZSA9IGVycm9yQ29kZTsKICAgICAgICAgfQogCi0gICAgICA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9pZCBnZXRFaVBhcmFtZXRlcnMoSW50ZW50IGludGVudCwgU3RyaW5nIHMpIHsKKyAgICAgICAgICAgIGlmIChEQkcpIHNEY0xvZyhzICsgIi5nZXRFaVBhcmFtZXRlcnM6IGFjdGlvbj0iICsgaW50ZW50LmdldEFjdGlvbigpKTsKKyAgICAgICAgICAgIGNvdW50ZXIgPSBpbnRlbnQuZ2V0SW50RXh0cmEoRmFpbEJyaW5nVXAuQ09VTlRFUiwKKyAgICAgICAgICAgICAgICAgICAgRmFpbEJyaW5nVXAuREVGQVVMVF9DT1VOVEVSKTsKKyAgICAgICAgICAgIGZhaWxDYXVzZSA9IEZhaWxDYXVzZS5mcm9tSW50KAorICAgICAgICAgICAgICAgICAgICBpbnRlbnQuZ2V0SW50RXh0cmEoRmFpbEJyaW5nVXAuRkFJTF9DQVVTRSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBGYWlsQnJpbmdVcC5ERUZBVUxUX0ZBSUxfQ0FVU0UuZ2V0RXJyb3JDb2RlKCkpKTsKKyAgICAgICAgICAgIHN1Z2dlc3RlZFJldHJ5VGltZSA9CisgICAgICAgICAgICAgICAgICAgIGludGVudC5nZXRJbnRFeHRyYShGYWlsQnJpbmdVcC5TVUdHRVNURURfUkVUUllfVElNRSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBGYWlsQnJpbmdVcC5ERUZBVUxUX1NVR0dFU1RFRF9SRVRSWV9USU1FKTsKKyAgICAgICAgICAgIGlmIChEQkcpIHsKKyAgICAgICAgICAgICAgICBzRGNMb2cocyArICIuZ2V0RWlQYXJhbWV0ZXJzOiAiICsgdGhpcyk7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKworICAgICAgICBAT3ZlcnJpZGUKKyAgICAgICAgcHVibGljIFN0cmluZyB0b1N0cmluZygpIHsKKyAgICAgICAgICAgIHJldHVybiAie2NvdW50ZXI9IiArIGNvdW50ZXIgKworICAgICAgICAgICAgICAgICAgICAiIGZhaWxDYXVzZT0iIC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MAorICAgIHByb3RlY3RlZCBGYWlsQnJpbmdVcCBtRmFpbEJyaW5nVXAgPSBuZXcgRmFpbEJyaW5nVXAoKTsKKworICAgIHByb3RlY3RlZCBCcm9hZGNhc3RSZWNlaXZlciBtSW50ZW50UmVjZWl2ZXIgPSBuZXcgQnJvYWRjYXN0UmVjZWl2ZXIgKCkKKyAgICB7CisgICAgICAgIEBPdmVycmlkZQorICAgICAgICBwdWJsaWMgdm9pZCBvblJlY2VpdmUoQ29udGV4dCBjb250ZXh0LCBJbnRlbnQgaW50ZW50KQorICAgICAgICB7CisgICAgICAgICAgICBTdHJpbmcgYWN0aW9uID0gaW50ZW50LmdldEFjdGlvbigpOworICAgICAgICAgICAgaWYgKERCRykgbG9nKCJtSW50ZW50UmVjZWl2ZXIub25SZWNlaXZlOiBhY3Rpb249IiArIGFjdGlvbik7CisgICAgICAgICAgICBpZiAoREJHX0ZBSUxVUkUgJiYgYWN0aW9uLmVxdWFscyhtQWN0aW9uRmFpbEJyaW5nVXApKSB7CisgICAgICAgICAgICAgICAgbUZhaWxCcmluZ1VwLmdldEVpUGFyYW1ldGVycyhpbnRlbnQsICJtRmFpbEJyaW5nVXAiKTsKKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJvblJlY2VpdmU6IHVua25vd24gYWN0aW9uPSIgKyBhY3Rpb24pOworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgfTsKKworICAgIC8qKgorICAgICAqIERvIHRoZSBvbiBjb25uZWN0IG9yIGZha2UgaXQgaWYgYW4gZXJyb3IKKyAgICAgKi8KKyAgICBwcm90ZWN0ZWQgdm9pZCBkb09uQ29ubmVjdChDb25uZWN0aW9uUGFyYW1zIGNwKSB7CisgICAgICAgIC8vIENoZWNrIGlmIHdlIHNob3VsZCBmYWtlIGFuIGVycm9yLgorICAgICAgICBpZiAoc0ZhaWxCcmluZ1VwLmNvdW50ZXIgID4gMCkgeworICAgICAgICAgICAgRGF0YUNhbGxTdGF0ZSByZXNwb25zZSA9IG5ldyBEYXRhQ2FsbFN0YXRlKCk7CisgICAgICAgICAgICByZXNwb25zZS52ZXJzaW9uID0gbVBob25lLm1DaS5nZXRSaWxWZXJzaW9uKCk7CisgICAgICAgICAgICByZXNwb25zZS5zdGF0dXMgPSBzRmFpbEJyaW5nVXAuZmFpbENhdXNlLmdldEVycm9yQ29kZSgpOworICAgICAgICAgICAgcmVzcG9uc2UuY2lkID0gMDsKKyAgICAgICAgICAgIHJlc3BvbnNlLmFjdGl2ZSA9IDA7CisgICAgICAgICAgICByZXNwb25zZS50eXBlID0gIiI7CisgICAgICAgICAgICByZXNwb25zZS5pZm5hbWUgPSAiIjsKKyAgICAgICAgICAgIHJlc3BvbnNlLmFkZHJlc3NlcyA9IG5ldyBTdHJpbmdbMF07CisgICAgICAgICAgICByZXNwb25zZS5kbnNlcyA9IG5ldyBTdHJpbmdbMF07CisgICAgICAgICAgICByZXNwb25zZS5nYXRld2F5cyA9IG5ldyBTdHJpbmdbMF07CisgICAgICAgICAgICByZXNwb25zZS5zdWdnZXN0ZWRSZXRyeVRpbWUgPSBzRmFpbEJyaW5nVXAuc3VnZ2VzdGVkUmV0cnlUaW1lOworCisgICAgICAgICAgICBNZXNzYWdlIG1zZyA9IG9idGFpbk1lc3NhZ2UoRVZFTlRfU0VUVVBfREFUQV9DT05ORUNUSU9OX0RPTkUsIGNwKTsKKyAgICAgICAgICAgIEFzeW5jUmVzdWx0LmZvck1lc3NhZ2UobXNnLCByZXNwb25zZSwgbnVsbCk7CisgICAgICAgICAgICBzZW5kTWVzc2FnZShtc2cpOworICAgICAgICAgICAgaWYgKERCRykgeworICAgICAgICAgICAgICAgIGxvZygiZG9PbkNvbm5lY3Q6IHNGYWlsQnJpbmdVcC5jb3VudGVyPSIgKyBzRmFpbEJyaW5nVXAuY291bnRlciArCisgICAgICAgICAgICAgICAgICAgICAgICAiIHNlbmQgZXJyb3IgcmVzcG9uc2U9IiArIHJlc3BvbnNlKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIHNGYWlsQnJpbmdVcC5jb3VudGVyIC09IDE7CisgICAgICAgICAgICByZXR1cm47CisgICAgICAgIH0KKyAgICAgICAgaWYgKG1GYWlsQnJpbmdVcC5jb3VudGVyID4gMCkgeworICAgICAgICAgICAgRGF0YUNhbGxTdGF0ZSByZXNwb25zZSA9IG5ldyBEYXRhQ2FsbFN0YXRlKCk7CisgICAgICAgICAgICByZXNwb25zZS52ZXJzaW9uID0gbVBob25lLm1DaS5nZXRSaWxWZXJzaW9uKCk7CisgICAgICAgICAgICByZXNwb25zZS5zdGF0dXMgPSBtRmFpbEJyaW5nVXAuZmFpbENhdXNlLmdldEVycm9yQ29kZSgpOworICAgICAgICAgICAgcmVzcG9uc2UuY2lkID0gMDsKKyAgICAgICAgICAgIHJlc3BvbnNlLmFjdGl2ZSA9IDA7CisgICAgICAgICAgICByZXNwb25zZS50eXBlID0gIiI7CisgICAgICAgICAgICByZXNwb25zZS5pZm5hbWUgPSAiIjsKKyAgICAgICAgICAgIHJlc3BvbnNlLmFkZHJlc3NlcyA9IG5ldyBTdHJpbmdbMF07CisgICAgICAgICAgICByZXNwb25zZS5kbnNlcyA9IG5ldyBTdHJpbmdbMF07CisgICAgICAgICAgICByZXNwb25zZS5nYXRld2F5cyA9IG5ldyBTdHJpbmdbMF07CisgICAgICAgICAgICByZXNwb25zZS5zdWdnZXN0ZWRSZXRyeVRpbWUgPSBtRmFpbEJyaW5nVXAuc3VnZ2VzdGVkUmV0cnlUaW1lOworCisgICAgICAgICAgICBNZXNzYWdlIG1zZyA9IG9idGFpbk1lc3NhZ2UoRVZFTlRfU0VUVVBfREFUQV9DT05ORUNUSU9OX0RPTkUsIGNwKTsKKyAgICAgICAgICAgIEFzeW5jUmVzdWx0LmZvck1lc3NhZ2UobXNnLCByZXNwb25zZSwgbnVsbCk7CisgICAgICAgICAgICBzZW5kTWVzc2FnZShtc2cpOworICAgICAgICAgICAgaWYgKER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ZyBuYW1lLCBpbnQgaWQsIFJldHJ5TWFuYWdlciBybSwKLSAgICAgICAgICAgIERhdGFDb25uZWN0aW9uVHJhY2tlciBkY3QpIHsKKyAgICBwcm90ZWN0ZWQgRGF0YUNvbm5lY3Rpb25CYXNlKFBob25lQmFzZSBwaG9uZSwgU3RyaW5nIG5hbWUsIGludCBpZCwgUmV0cnlNYW5hZ2VyIHJtLAorICAgICAgICAgICAgRGF0YUNvbm5lY3Rpb25UcmFja2VyQmFzZSBkY3QpIHsKICAgICAgICAgc3VwZXIobmFtZSk7Ci0gICAgICAgIHNldExvZ1JlY1NpemUoMTAwKTsKLSAgICAgICAgaWYgKERCRykgbG9nKCJEYXRhQ29ubmVjdGlvbiBjb25zdHJ1Y3RvciBFIik7Ci0gICAgICAgIHRoaXMucGhvbmUgPSBwaG9uZTsKLSAgICAgICAgdGhpcy5tRGF0YUNvbm5lY3Rpb25UcmFja2VyID0gZGN0OworICAgICAgICBzZXRMb2dSZWNTaXplKDMwMCk7CisgICAgICAgIHNldExvZ09ubHlUcmFuc2l0aW9ucyh0cnVlKTsKKyAgICAgICAgaWYgKERCRykgbG9nKCJEYXRhQ29ubmVjdGlvbkJhc2UgY29uc3RydWN0b3IgRSIpOworICAgICAgICBtUGhvbmUgPSBwaG9uZTsKKyAgICAgICAgbURhdGFDb25uZWN0aW9uVHJhY2tlciA9IGRjdDsKICAgICAgICAgbUlkID0gaWQ7CiAgICAgICAgIG1SZXRyeU1nciA9IHJtOwotICAgICAgICB0aGlzLmNpZCA9IC0xOworICAgICAgICBtQ2lkID0gLTE7CiAKLSAgICAgICAgc2V0RGJnKGZhbHNlKTsKKyAgICAgICAgaWYgKERCR19GQUlMVVJFKSB7CisgICAgICAgICAgICBJbnRlbnRGaWx0ZXIgZmlsdGVyOworCisgICAgICAgICAgICBzeW5jaHJvbml6ZWQgKERhdGFDb25uZWN0aW9uQmFzZS5jbGFzcykgeworICAgICAgICAgICAgICAgIC8vIFJlZ2lzdGVyIHRoZSBzdGF0aWMgSW50ZW50IHJlY2VpdmVyIG9uY2UKKyAgICAgICAgICAgICAgICBpZiAoc0FjdGlvbkZhaWxCcmluZ1VwID09IG51bGwpIHsKKyAgICAgICAgICAgICAgICAgICAgc0FjdGlvbkZhaWxCcmluZ1VwID0gSU5URU5UX0JBU0UgKyAiLkRDLiIgKworICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZhaWxCcmluZ1VwLkFDVElPTl9GQUlMX0JSSU5HVVA7CisKKyAgICAgICAgICAgICAgICAgICAgZmlsdGVyID0gbmV3IEludGVudEZpbHRlcigpOworICAgICAgICAgICAgICAgICAgICBmaWx0ZXIuYWRkQWN0aW9uKHNBY3Rpb25GYWlsQnJpbmdVcCk7CisgICAgICAgICAgICAgICAgICAgIHBob25lLmdldENvbnRleHQoKS5yZWdpc3RlclJlY2VpdmVyKHNJbnRlbnRSZWNlaXZlciwgZmlsdGVyLCBudWxsLCBwaG9uZSk7CisgICAgICAgICAgICAgICAgICAgIGxvZygiRGF0YUNvbm5lY3Rpb25CYXNlOiByZWdpc3RlciBzQWN0aW9uRmFpbEJyaW5nVXA9IiArIHNBY3Rpb25GYWlsQnJpbmdVcCk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfQorCisgICAgICAgICAgICAvLyBSZWdpc3RlciB0aGUgcGVyIGluc3RhbmNlIEludGVudCByZWNlaXZlcgorICAgICAgICAgICAgbUFjdGlvbkZhaWxCcmluZ1VwID0gSU5URU5UX0JBU0UgKyAiLiIgKyBnZXROYW1lKCkgKyAiLiIgKworICAgICAgICAgICAgICAgICAgICBGYWlsQnJpbmdVcC5BQ1RJT05fRkFJTF9CUklOR1VQOworICAgICAgICAgICAgZmlsdGVyID0gbmV3IEludGVudEZpbHRlcigpOworICAgICAgICAgICAgZmlsdGVyLmFkZEFjdGlvbihtQWN0aW9uRmFpbEJyaW5nVXApOworICAgICAgICAgICAgcGhvbmUuZ2V0Q29udGV4dCgpLnJlZ2lzdGVyUmVjZWl2ZX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ZSA9IG51bGw7CisgICAgICAgIG1Vc2VyRGF0YSA9IG51bGw7CiAgICAgfQogCiAgICAgLyoqCkBAIC0zMjAsMTYgKzUyOCwxNiBAQAogICAgICAgICBpbnQgZGlzY1JlYXNvbiA9IFJJTENvbnN0YW50cy5ERUFDVElWQVRFX1JFQVNPTl9OT05FOwogICAgICAgICBpZiAoKG8gIT0gbnVsbCkgJiYgKG8gaW5zdGFuY2VvZiBEaXNjb25uZWN0UGFyYW1zKSkgewogICAgICAgICAgICAgRGlzY29ubmVjdFBhcmFtcyBkcCA9IChEaXNjb25uZWN0UGFyYW1zKW87Ci0gICAgICAgICAgICBNZXNzYWdlIG0gPSBkcC5vbkNvbXBsZXRlZE1zZzsKLSAgICAgICAgICAgIGlmIChUZXh0VXRpbHMuZXF1YWxzKGRwLnJlYXNvbiwgUGhvbmUuUkVBU09OX1JBRElPX1RVUk5FRF9PRkYpKSB7CisgICAgICAgICAgICBNZXNzYWdlIG0gPSBkcC5tT25Db21wbGV0ZWRNc2c7CisgICAgICAgICAgICBpZiAoVGV4dFV0aWxzLmVxdWFscyhkcC5tUmVhc29uLCBQaG9uZS5SRUFTT05fUkFESU9fVFVSTkVEX09GRikpIHsKICAgICAgICAgICAgICAgICBkaXNjUmVhc29uID0gUklMQ29uc3RhbnRzLkRFQUNUSVZBVEVfUkVBU09OX1JBRElPX09GRjsKLSAgICAgICAgICAgIH0gZWxzZSBpZiAoVGV4dFV0aWxzLmVxdWFscyhkcC5yZWFzb24sIFBob25lLlJFQVNPTl9QRFBfUkVTRVQpKSB7CisgICAgICAgICAgICB9IGVsc2UgaWYgKFRleHRVdGlscy5lcXVhbHMoZHAubVJlYXNvbiwgUGhvbmUuUkVBU09OX1BEUF9SRVNFVCkpIHsKICAgICAgICAgICAgICAgICBkaXNjUmVhc29uID0gUklMQ29uc3RhbnRzLkRFQUNUSVZBVEVfUkVBU09OX1BEUF9SRVNFVDsKICAgICAgICAgICAgIH0KICAgICAgICAgfQotICAgICAgICBpZ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ICAgIGlmIChjb25uZWN0aW9uQ29tcGxldGVkTXNnID09IG51bGwpIHsKICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgfQogCiAgICAgICAgIGxvbmcgdGltZVN0YW1wID0gU3lzdGVtLmN1cnJlbnRUaW1lTWlsbGlzKCk7Ci0gICAgICAgIGNvbm5lY3Rpb25Db21wbGV0ZWRNc2cuYXJnMSA9IGNpZDsKKyAgICAgICAgY29ubmVjdGlvbkNvbXBsZXRlZE1zZy5hcmcxID0gbUNpZDsKIAogICAgICAgICBpZiAoY2F1c2UgPT0gRmFpbENhdXNlLk5PTkUpIHsKLSAgICAgICAgICAgIGNyZWF0ZVRpbWUgPSB0aW1lU3RhbXA7CisgICAgICAgICAgICBtQ3JlYXRlVGltZSA9IHRpbWVTdGFtcDsKICAgICAgICAgICAgIEFzeW5jUmVzdWx0LmZvck1lc3NhZ2UoY29ubmVjdGlvbkNvbXBsZXRlZE1zZyk7CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICBsYXN0RmFpbENhdXNlID0gY2F1c2U7Ci0gICAgICAgICAgICBsYXN0RmFpbFRpbWUgPSB0aW1lU3RhbXA7CisgICAgICAgICAgICBtTGFzdEZhaWxDYXVzZSA9IGNhdXNlOworICAgICAgICAgICAgbUxhc3RGYWlsVGltZSA9IHRpbWVTdGFtcDsKICAgICAgICAgICAgIEFzeW5jUmVzdWx0LmZvck1lc3NhZ2UoY29ubmVjdGlvbkNvbXBsZXRlZE1zZywgY2F1c2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBDYWxsU2V0dXBFeGNlcHRpb24obVJldHJ5T3ZlcnJpZGUpKTsKICAgICAgICAgfQpAQCAtMzc3LDEzICs1ODUsMTMgQEAKICAgICAgICAgQXBuQ29udGV4dCBhbHJlYWR5U2VudCA9IG51bGw7CiAgICAgICAgIFN0cmluZyByZWFzb24gPSBudWxsOwogCi0gICAgICAgIGlmIChkcC5vbkNvbXBsZXRlZE1zZyAhPSBudWxsKSB7CisgICAgICAgIGlmIChkcC5tT25Db21wbGV0ZWRNc2cgIT0gbnVsbCkgewogICAgICAgICAgICAgLy8gR2V0IEFwbkNvbnRleHQsIGJ1dCBvbmx5IHZhbGlkIG9uIEdTTSBkZXZpY2VzIHRoaXMgaXMgYSBzdHJpbmcgb24gQ0RNQSBkZXZpY2VzLgotICAgICAgICAgICAgTWVzc2FnZSBtc2cgPSBkcC5vbkNvbXBsZXRlZE1zZzsKKyAgICAgICAgICAgIE1lc3NhZ2UgbXNnID0gZHAubU9uQ29tcGxldGVkTXNnOwogICAgICAgICAgICAgaWYgKG1zZy5vYmogaW5zdGFuY2VvZiBBcG5Db250ZXh0KSB7CiAgICAgICAgICAgICAgICAgYWxyZWFkeVNlbnQgPSAoQXBuQ29udGV4dCltc2cub2JqOwogICAgICAgICAgICAgfQotICAgICAgICAgICAgcmVhc29uID0gZHAucmVhc29uOworICAgICAgICAgICAgcmVhc29uID0gZHAubVJlYXNvbjsKICAgICAgICAgICAgIGlmIChWREJHKSB7CiAgICAgICAgICAgICAgICAgbG9nKFN0cmluZy5mb3JtYXQoIm1zZz0lcyBtc2cub2JqPSVzIiwgbXNnLnRvU3RyaW5nKCksCiAgICAgICAgICAgICAgICAgICAgICgobXNnLm9iaiBpbnN0YW5jZW9mIFN0cmluZykgPyAoU3RyaW5nKSBtc2cub2JqIDogIjxuby1yZWFzb24+IikpKTsKQEAgLTQwNSwxMiArNjEzLDEyIEBACiAgICAgICAgIGlmIChEQkcpIGxvZygiTm90aWZ5RGlzY29ubmVjdENvbXBsZXRlZCBEaXNjb25uZWN0UGFyYW1zPSIgKyBkcCk7CiAgICAgfQogCi0gICAgcHJvdGVjdGVkIGludCBnZXRSaWxSYWRpb1RlY2hub2xvZ3koaW50IGRlZmF1bHRSaWxSYWRpb1RlY2hub2xvZ3kpIHsKKyAgICBwcm90ZWN0ZWQgaW50IGdldFJpbFJhZGlvVGVjaG5vbG9neSgpIHsKICAgICAgICAgaW50IHJpbFJhZGlvVGVjaG5vbG9neTsKLSAgICAgICAgaWYgKG1SaWxWZXJzaW9uIDwgNikgewotICAgICAgICAgICAgcmlsUmFkaW9UZWNobm9sb2d5ID0gZGVmYXVsdFJpbFJhZGlvVGVjaG5vbG9neTsKKyAgICAgICAgaWYgKG1BcG4uYmVhcmVyID4gMCkgeworICAgICAgICAgICAgcmlsUmFkaW9UZWNobm9sb2d5ID0gbUFwbi5iZWFyZXIgKyAyOwogICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgcmlsUmFkaW9UZWNobm9sb2d5ID0gcGhvbmUuZ2V0U2VydmljZVN0YXRlKCkuZ2V0UmlsUmFkaW9UZWNobm9sb2d5KCkgKyAyOworICAgICAgICAgICAgcmlsUmFkaW9UZWNobm9sb2d5ID0gbVBob25lLmdldFNlcnZpY2VTdGF0ZSgpLmdldFJpbERhdGFSYWRpb1RlY2hub2xvZ3koKSArIDI7CiAgICAgICAgIH0KICAgICAgICAgcmV0dXJuIHJpbFJhZGlvVGVjaG5vbG9neTsKICAgICB9CkBAIC00MTgsNyArNjI2LDcgQEAKICAgICAvKgogICAgICAqICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCiAgICAgICogQmVnaW4gTWVtYmVycyBhbmQgbWV0aG9kcyBvd25lZCBieSBEYXRhQ29ubmVjdGlvblRyYWNrZXIgYnV0IHN0b3JlZAotICAgICAqIGluIGEgRGF0YUNvbm5lY3Rpb24gYmVjYXVzZSB0aGVyZSBpcyBvbmUgcGVyIGNvbm5lY3Rpb24uCisgICAgICogaW4gYSBEYXRhQ29ubmVjdGlvbkJhc2UgYmVjYXVzZSB0aGVyZSBpcyBvbmUgcGVyIGNvbm5lY3Rpb24uCiAgICAgICogKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKICAgICAgKi8KIApAQCAt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JpbENvbm5lY3RlZChnZXRIYW5kbGVyKCksIEVWRU5UX1JJTF9DT05ORUNURUQsIG51bGwpOwogICAgICAgICB9CiAgICAgICAgIEBPdmVycmlkZQogICAgICAgICBwdWJsaWMgdm9pZCBleGl0KCkgewotICAgICAgICAgICAgcGhvbmUubUNNLnVucmVnaXN0ZXJGb3JSaWxDb25uZWN0ZWQoZ2V0SGFuZGxlcigpKTsKKyAgICAgICAgICAgIG1QaG9uZS5tQ2kudW5yZWdpc3RlckZvclJpbENvbm5lY3RlZChnZXRIYW5kbGVyKCkpOwogICAgICAgICAgICAgc2h1dERvd24oKTsKICAgICAgICAgfQogICAgICAgICBAT3ZlcnJpZGUKQEAgLTY1OCw2ICs4NjYsMTAgQEAKICAgICAgICAgICAgIGJvb2xlYW4gcmV0VmFsID0gSEFORExFRDsKICAgICAgICAgICAgIEFzeW5jUmVzdWx0IGFyOwogCisgICAgICAgICAgICBpZiAoVkRCRykgeworICAgICAgICAgICAgICAgIGxvZygiRGNEZWZhdWx0IG1zZz0weCIgKyBJbnRlZ2VyLnRvSGV4U3RyaW5nKG1zZy53aGF0KQorICAgICAgICAgICAgICAgICAgICAgICAgKyAiIFJlZkNvdW50PSIgKyBtQXBuTGlzdC5zaXplKCkpOworICAgICAgICAgICAgfQogICAgICAgICAgICAgc3dpdGNoIChtc2cud2hhdCkgewogICAgICAgICAgICAgICAgIGNhc2UgQXN5bmNDaGFubmVsLkNNRF9DSEFOTkVMX0ZVTExfQ09OTkVDVElPTjogewogICAgICAgICAgICAgICAgICAgICBpZiAobUFjICE9IG51bGwpIHsKQEAgLTY4NSw4ICs4OTcsOCBAQAogICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgY2FzZSBEYXRhQ29ubmVjdGlvbkFjLlJFUV9HRVRfQ0lEOiB7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChWREJHKSBsb2coIlJFUV9HRVRfQ0lEICBjaWQ9IiArIGNpZCk7Ci0gICAgICAgICAgICAgICAgICAgIG1BYy5yZXBseVRvTWVzc2FnZShtc2csIERhdGFDb25uZWN0aW9uQWMuUlNQX0dFVF9DSUQsIGNpZCk7CisgICAgICAgICAgICAgICAgICAgIGlmIChWREJHKSBsb2coIlJFUV9HRVRfQ0lEICBjaWQ9IiArIG1DaWQpOworICAgICAgICAgICAgICAgICAgICBtQWMucmVwbHlUb01lc3NhZ2UobXNnLCBEYXRhQ29ubmVjdGlvbkFjLlJTUF9HRVRfQ0lELCBtQ2lkKTsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIGNhc2UgRGF0YUNvbm5lY3Rpb25BYy5SRVFfR0VUX0FQTlNFVFRJTkc6IHsKQEAgLTczMiwyNCArOTQ0LDggQEAKICAgICAgICAgICAgICAgICAgICAgdHJhbnNpdGlvblRvKG1JbmFjdGl2ZVN0YXRlKTsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgY2FzZSBEYXRhQ29ubmVjdGlvbkFjLlJFUV9HRVRfUkVGQ09VTlQ6IHsKLSAgICAgICAgICAgICAgICAgICAgaWYgKFZEQkcpIGxvZygiUkVRX0dFVF9SRUZDT1VOVCAgcmVmQ291bnQ9IiArIG1SZWZDb3VudCk7Ci0gICAgICAgICAgICAgICAgICAgIG1BYy5yZXBseVRvTWVzc2FnZShtc2csIERhdGFDb25uZWN0aW9uQWMuUlNQX0dFVF9SRUZDT1VOVCwgbVJlZkNvdW50KTsKLSAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIGNhc2UgRGF0YUNvbm5lY3Rpb25BYy5SRVFfQUREX0FQTkNPTlRFWFQ6IHsKLSAgICAgICAgICAgICAgICAgICAgQXBuQ29udGV4dCBhcG5Db250ZXh0ID0gKEFwbkNvbnRleHQpIG1zZy5vYmo7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChWREJHKSBsb2coIlJFUV9BRERfQVBOQ09OVEVYVCBhcG49IiArIGFwbkNvbnRleHQuZ2V0QXBuVHlwZSgpKTsKLSAgICAgICAgICAgICAgICAgICAgaWYgKCFtQXBuTGlzdC5jb250YWlucyhhcG5Db250ZXh0KSkgewotICAgICAgICAgICAgICAgICAgICAgICAgbUFwbkxpc3QuYWRkKGFwbkNvbnRleHQpOwotICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgIG1BYy5yZXBseVRvTWVzc2FnZShtc2csIERhdGFDb25uZWN0aW9uQWMuUlNQX0FERF9BUE5DT05URVhUKTsKLSAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIGNhc2UgRGF0YUNvbm5lY3Rpb25BYy5SRVFfUkVNT1ZFX0FQTkNPTlRFWFQ6IHsKLSAgICAgICAgICAgICAgICAgICAgQXBuQ29udGV4dCBhcG5Db250ZXh0ID0gKEFwbkNvbnRleHQpIG1zZy5vYmo7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChWREJHKSBsb2coIlJFUV9SRU1PVkVfQVBOQ09OVEVYVCBhcG49IiArIGFwbkNvbnRleHQuZ2V0QXBuVHlwZSgpKTsKLSAgICAgICAgICAgICAgICAgICAgbUFwbkxpc3QucmVtb3ZlKGFwbkNvbnRleHQpOwotICAgICAgICAgICAgICAgICAgICBtQWMucmVwbHlUb01lc3NhZ2UobXNnLCBEYXRhQ29ubmVjdGlvbkFjLlJTUF9SRU1PVkVfQVBOQ09OVEVYVCk7CisgICAgICAgICAgICAgICAgICAgIGlmIChWREJHKSBsb2coIlJFUV9HRVRfUkVGQ09VTlQgIFJlZkNvdW50PSIgKyBtQXBuTGlzdC5zaXplKCkpOworICAgICAgICAgICAgICAgICAgICBtQWMucmVwbHlUb01lc3NhZ2UobXNnLCBEYXRhQ29ubmVjdGlvbkFjLlJTUF9HRVRfUkVGQ09VTlQsIG1BcG5MaXN0LnNpemUoKSk7CiAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBjYXNlIERhdGFDb25uZWN0aW9uQWMuUkVRX0dFVF9BUE5DT05URVhUX0xJU1Q6IHsKQEAgLTc3OSwxNCArOTc1LDE2IEBACiAKICAgICAgICAgICAgICAgICBjYXNlIEVWRU5UX0RJU0NPTk5FQ1Q6CiAgICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGxvZygiRGNEZWZhdWx0U3RhdGUgZGVmZXJyaW5nIG1zZy53aGF0PUVWRU5UX0RJU0NPTk5FQ1QiICsgbVJlZkNvdW50KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGxvZygiRGNEZWZhdWx0U3RhdGUgZGVmZXJyaW5nIG1zZy53aGF0PUVWRU5UX0RJU0NPTk5FQ1QgUmVmQ291bnQ9IgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArIG1BcG5MaXN0LnNpemUoKSk7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgZGVmZXJNZXNzYWdlKG1zZyk7CiAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogCiAgICAgICAgICAgICAgICAgY2FzZSBFVkVOVF9ESVNDT05ORUNUX0FMTDoKICAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgewotICAgICAgICAgICAgICAgICAgICAgICAgbG9nKCJEY0RlZmF1bHRTdGF0ZSBkZWZlcnJpbmcgbXNnLndoYXQ9RVZFTlRfRElTQ09OTkVDVF9BTEwiICsgbVJlZkNvdW50KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGxvZygiRGNEZWZhdWx0U3RhdGUgZGVmZXJyaW5nIG1zZy53aGF0PUVWRU5UX0RJU0NPTk5FQ1RfQUxMIFJlZkNvdW50PSIKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyBtQXBuTGlzdC5zaXplKCkpOwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIGRlZmVyTWVzc2FnZShtc2cpOwogICAgICAgICAgICAgICAgICAgICBicmVhazsKQEAgLTg4NCwxMyArMTA4MiwxMyBAQAogCiAgICAgICAgICAgICAgICAgY2FzZSBFVkVOVF9DT05ORUNUOgogICAgICAgICAgICAgICAgICAgICBDb25uZWN0aW9uUGFyYW1zIGNwID0gKENvbm5lY3Rpb25QYXJhbXMpIG1zZy5vYmo7Ci0gICAgICAgICAgICAgICAgICAgIGNwLnRhZyA9IG1UYWc7CisgICAgICAgICAgICAgICAgICAgIG1BcG5MaXN0LmFkZChjcC5tQXBuQ29udGV4dCk7CisgICAgICAgICAgICAgICAgICAgIGNwLm1UaGVUYWcgPSBtVGFnOwogICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBsb2coIkRjSW5hY3RpdmVTdGF0ZSBtc2cud2hhdD1FVkVOVF9DT05ORUNULiIgKyAiUmVmQ291bnQgPSAiCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgbVJlZkNvdW50KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGxvZygiRGNJbmFjdGl2ZVN0YXRlIG1zZy53aGF0PUVWRU5UX0NPTk5FQ1QgIiArICJSZWZDb3VudD0iCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgbUFwbkxpc3Quc2l6ZSgpKTsKICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBtUmVmQ291bnQgPSAxOwotICAgICAgICAgICAgICAgICAgICBvbkNvbm5lY3QoY3ApOworICAgICAgICAgICAgICAgICAgICBkb09uQ29ubmVjdChjcCk7CiAgICAgICAgICAgICAgICAgICAgIHRyYW5zaXRpb25UbyhtQWN0aXZhdGluZ1N0YXRlKTsKICAgICAgICAgICAgICAgICAgICAgcmV0VmFsID0gSEFORExFRDsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CkBAIC05MzIsMTQgKzExMzAsMTkgQEAKIAogICAgICAgICAgICAgc3dpdGNoIChtc2cud2hhdCkgewogICAgICAgICAgICAgICAgIGNhc2UgRVZFTlRfQ09OTkVDVDoKLSAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJEY0FjdGl2YXRpbmdTdGF0ZSBkZWZlcnJpbmcgbXNnLndoYXQ9RVZFTlRfQ09OTkVDVCByZWZDb3VudCA9ICIKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICArIG1SZWZDb3VudCk7CisgICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGxvZygiRGNBY3RpdmF0aW5nU3RhdGUgZGVmZXJyaW5nIG1zZy53aGF0PUVWRU5UX0NPTk5FQ1QgUmVmQ291bnQ9IgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArIG1BcG5MaXN0LnNpemUoKSk7CisgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgZGVmZXJNZXNzYWdlKG1zZyk7CiAgICAgICAgICAgICAgICAgICAgIHJldFZhbCA9IEhBTkRMRUQ7CiAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogCiAgICAgICAgICAgICAgICAgY2FzZSBFVkVOVF9TRVRVUF9EQVRBX0NPTk5FQ1RJT05fRE9ORToKLSAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJEY0FjdGl2YXRpbmdTdGF0ZSBtc2cud2hhdD1FVkVOVF9TRVRVUF9EQVRBX0NPTk5FQ1RJT05fRE9ORSIpOworICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBsb2coIkRjQWN0aXZhdGluZ1N0YXRlIG1zZy53aGF0PUVWRU5UX1NFVFVQX0RBVEFfQ09OTkVDVElPTl9ET05FIgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArICIgUmVmQ291bnQ9IiArIG1BcG5MaXN0LnNpemUoKSk7CisgICAgICAgICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgICAgICAgICBhciA9IChBc3luY1Jlc3VsdCkgbXNnLm9iajsKICAgICAgICAgICAgICAgICAgICAgY3AgPSAoQ29ubmVjdGlvblBhcmFtcykgYXIudXNlck9iajsKQEAgLTk2Niw3ICsxMTY5LDcgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgRVJSX0dldExhc3RFcnJvckZyb21SaWw6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gUmVxdWVzdCBmYWlsZWQgYW5kIHRoaXMgaXMgYW4gb2xkIFJJTAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBob25lLm1DTS5nZXRMYXN0RGF0YUNhbGxGYWlsQ2F1c2UoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbVBob25lLm1DaS5nZXRMYXN0RGF0YUNhbGxGYWlsQ2F1c2UoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX0dFVF9MQVNUX0ZBSUxfRE9ORSwgY3ApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgRVJSX1JpbEVycm9yOgpAQCAtOTg5LDggKzExOTIsMTEgQEAKICAgICAgICAgICAgICAgICAgICAgY3AgPSAoQ29ubmVjdGlvblBhcmFtcykgYXIudXNlck9iajsKICAgICAgICAgICAgICAgICAgICAgRmFpbENhdXNlIGNhdXNlID0gRmFpbENhdXNlLlVOS05PV047CiAKLSAgICAgICAgICAgICAgICAgICAgaWYgKGNwLnRhZyA9PSBtVGFnKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coIkRjQWN0aXZhdGluZ1N0YXRlIG1zZy53aGF0PUVWRU5UX0dFVF9MQVNUX0ZBSUxfRE9ORSIpOworICAgICAgICAgICAgICAgICAgICBpZiAoY3AubVRoZVRhZyA9PSBtVGFnKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9nKCJEY0FjdGl2YXRpbmdTdGF0ZSBtc2cud2hhdD1FVkVOVF9HRVRfTEFTVF9GQUlMX0RPTkUiCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArICIgUmVmQ291bnQ9IiArIG1BcG5MaXN0LnNpemUoKSk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYXIuZXhjZXB0aW9uID09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgcmlsRmFpbENhdXNlID0gKChpbnRbXSkgKGFyLnJlc3VsdCkpWzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhdXNlID0gRmFpbENhdXNlLmZyb21JbnQocmlsRmFpbENhdXNlKTsKQEAgLTEwMDIsNyArMTIwOCw3IEBACiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9nKCJEY0FjdGl2YXRpbmdTdGF0ZSBFVkVOVF9HRVRfTEFTVF9GQUlMX0RPTkUgaXMgc3RhbGUgY3AudGFnPSIKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyBjcC50YWcgKyAiLCBtVGFnPSIgKyBtVGFnKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyBjcC5tVGhlVGFnICsgIiwgbVRhZz0iICsgbVRhZyArICIgUmVmQ291bnQ9IiArIG1BcG5MaXN0LnNpemUoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIH0KIApAQCAtMTAxMiw3ICsxMjE4LDcgQEAKICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICBpZiAoVkRCRykgewogICAgICAgICAgICAgICAgICAgICAgICAgbG9nKCJEY0FjdGl2YXRpbmdTdGF0ZSBub3QgaGFuZGxlZCBtc2cud2hhdD0weCIgKwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbnRlZ2VyLnRvSGV4U3RyaW5nKG1zZy53aGF0KSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEludGVnZXIudG9IZXhTdHJpbmcobXNnLndoYXQpICsgIiBSZWZDb3VudD0iICsgbUFwbkxpc3Quc2l6ZSgpKTsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICByZXRWYWwgPSBOT1RfSEFORExFRDsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CkBAIC0xMDYxLDQzICsxMjY3LDU5IEBACiAgICAgICAgICAgICBib29sZWFuIHJldFZhbDsKIAogICAgICAgICAgICAgc3dpdGNoIChtc2cud2hhdCkgewotICAgICAgICAgICAgICAgIGNhc2UgRVZFTlRfQ09OTkVDVDoKLSAgICAgICAgICAgICAgICAgICAgbVJlZkNvdW50Kys7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygiRGNBY3RpdmVTdGF0ZSBtc2cud2hhdD1FVkVOVF9DT05ORUNUIFJlZkNvdW50PSIgKyBtUmVmQ291bnQpOwotICAgICAgICAgICAgICAgICAgICBpZiAobXNnLm9iaiAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBub3RpZnlDb25uZWN0Q29tcGxldGVkKChDb25uZWN0aW9uUGFyYW1zKSBtc2cub2JqLCBGYWlsQ2F1c2UuTk9ORSk7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgcmV0VmFsID0gSEFORExFRDsKLSAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgY2FzZSBFVkVOVF9ESVNDT05ORUNUOgotICAgICAgICAgICAgICAgICAgICBtUmVmQ291bnQtLTsKLSAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJEY0FjdGl2ZVN0YXRlIG1zZy53aGF0PUVWRU5UX0RJU0NPTk5FQ1QgUmVmQ291bnQ9IiArIG1SZWZDb3VudCk7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChtUmVmQ291bnQgPT0gMCkKLSAgICAgICAgICAgICAgICAgICAgewotICAgICAgICAgICAgICAgICAgICAgICAgRGlzY29ubmVjdFBhcmFtcyBkcCA9IChEaXNjb25uZWN0UGFyYW1zKSBtc2cub2JqOwotICAgICAgICAgICAgICAgICAgICAgICAgZHAudGFnID0gbVRhZzsKLSAgICAgICAgICAgICAgICAgICAgICAgIHRlYXJEb3duRGF0YShkcCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2l0aW9uVG8obURpc2Nvbm5lY3RpbmdTdGF0ZSk7CisgICAgICAgICAgICAgICAgY2FzZSBFVkVOVF9DT05ORUNUOiB7CisgICAgICAgICAgICAgICAgICAgIENvbm5lY3Rpb25QYXJhbXMgY3AgPSAoQ29ubmVjdGlvblBhcmFtcykgbXNnLm9iajsKKyAgICAgICAgICAgICAgICAgICAgaWYgKG1BcG5MaXN0LmNvbnRhaW5zKGNwLm1BcG5Db250ZXh0KSkgeworICAgICAgICAgICAgICAgICAgICAgICAgbG9nKCJEY0FjdGl2ZVN0YXRlIEVSUk9SIGFscmVhZHkgYWRkZWQgYXBuQ29udGV4dD0iICsgY3AubUFwbkNvbnRleHQKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgIiB0byB0aGlzIERDPSIgKyB0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtc2cub2JqICE9IG51bGwpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBub3RpZnlEaXNjb25uZWN0Q29tcGxldGVkKChEaXNjb25uZWN0UGFyYW1zKSBtc2cub2JqLCBmYWxzZSk7CisgICAgICAgICAgICAgICAgICAgICAgICBtQXBuTGlzdC5hZGQoY3AubUFwbkNvbnRleHQpOworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvZygiRGNBY3RpdmVTdGF0ZSBtc2cud2hhdD1FVkVOVF9DT05ORUNUIFJlZkNvdW50PSIgKyBtQXBuTGlzdC5zaXplKCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIG5vdGlmeUNvbm5lY3RDb21wbGV0ZWQoY3AsIEZhaWxDYXVzZS5OT05FKTsKICAgICAgICAgICAgICAgICAgICAgcmV0VmFsID0gSEFORExFRDsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0KLSAgICAgICAgICAgICAgICBjYXNlIEVWRU5UX0RJU0NPTk5FQ1RfQUxMOgotICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBsb2coIkRjQWN0aXZlU3RhdGUgbXNnLndoYXQ9RVZFTlRfRElTQ09OTkVDVF9BTEwgUmVmQ291bnQ9IiArIG1SZWZDb3VudCk7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgbVJlZkNvdW50ID0gMDsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgY2FzZSBFVkVOVF9ESVNDT05ORUNUOiB7CiAgICAgICAgICAgICAgICAgICAgIERpc2Nvbm5lY3RQYXJhbXMgZHAgPSAoRGlzY29ubmVjdFBhcmFtcykgbXNnLm9iajsKLSAgICAgICAgICAgICAgICAgICAgZHAudGFnID0gbVRhZzsKKyAgICAgICAgICAgICAgICAgICAgaWYgKG1BcG5MaXN0LmNvbnRhaW5zKGRwLm1BcG5Db250ZXh0KSkgeworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvZygiRGNBY3RpdmVTdGF0ZSBtc2cud2hhdD1FVkVOVF9ESVNDT05ORUNUIFJlZkNvdW50PSIKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgbUFwbkxpc3Quc2l6ZSgpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1BcG5MaXN0LnNpemUoKSA9PSAxKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUFwbkxpc3QuY2xlYXIoKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBkcC5tVGhlVGFnID0gbVRhZzsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZWFyRG93bkRhdGEoZHApOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zaXRpb25UbyhtRGlzY29ubmVjdGluZ1N0YXRlKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUFwbkxpc3QucmVtb3ZlKGRwLm1BcG5Db250ZXh0KTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBub3RpZnlEaXNjb25uZWN0Q29tcGxldGVkKGRwLCBmYWxzZSk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgICAgICAgICBsb2coIkRjQWN0aXZlU3RhdGUgRVJST1Igbm8gc3VjaCBhcG5Db250ZXh0PSIgKyBkcC5tQXBuQ29udGV4dAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArICIgaW4gdGhpcyBEQz0iICsgdGhpcyk7CisgICAgICAgICAgICAgICAgICAgICAgICBub3RpZnlEaXNjb25uZWN0Q29tcGxldGVkKGRwLCBmYWxzZSk7CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgcmV0VmFsID0gSEFORExFRDsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGNhc2UgRVZFTlRfRElTQ09OTkVDVF9BTEw6IHsKKyAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgeworICAgICAgICAgICAgICAgICAgICAgICAgbG9nKCJEY0FjdGl2ZVN0YXRlIG1zZy53aGF0PUVWRU5UX0RJU0NPTk5FQ1RfQUxMIFJlZkNvdW50PSIKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyBtQXBuTGlzdC5zaXplKCkgKyAiIGNsZWFyaW5nIGFwbiBjb250ZXh0cyIpOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIG1BcG5MaXN0LmNsZWFyKCk7CisgICAgICAgICAgICAgICAgICAgIERpc2Nvbm5lY3RQYXJhbXMgZHAgPSAoRGlzY29ubmVjdFBhcmFtcykgbXNnLm9iajsKKyAgICAgICAgICAgICAgICAgICAgZHAubVRoZVRhZyA9IG1UYWc7CiAgICAgICAgICAgICAgICAgICAgIHRlYXJEb3duRGF0YShkcCk7CiAgICAgICAgICAgICAgICAgICAgIHRyYW5zaXRpb25UbyhtRGlzY29ubmVjdGluZ1N0YXRlKTsKICAgICAgICAgICAgICAgICAgICAgcmV0VmFsID0gSEFORExFRDsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0KKyAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgaWYgKFZEQkcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIGxvZygiRGNBY3RpdmVTdGF0ZSBub3QgaGFuZGxlZCBtc2cud2hhdD0weCIgKwpAQCAtMTEyMiwyMyArMTM0NCwyNCBAQAogICAgICAgICAgICAgc3dpdGNoIChtc2cud2hhdCkgewogICAgICAgICAgICAgICAgIGNhc2UgRVZFTlRfQ09OTkVDVDoKICAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJEY0Rpc2Nvbm5lY3RpbmdTdGF0ZSBtc2cud2hhdD1FVkVOVF9DT05ORUNULiBEZWZlci4gUmVmQ291bnQgPSAiCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgKyBtUmVmQ291bnQpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgbUFwbkxpc3Quc2l6ZSgpKTsKICAgICAgICAgICAgICAgICAgICAgZGVmZXJNZXNzYWdlKG1zZyk7CiAgICAgICAgICAgICAgICAgICAgIHJldFZhbCA9IEhBTkRMRUQ7CiAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogCiAgICAgICAgICAgICAgICAgY2FzZSBFVkVOVF9ERUFDVElWQVRFX0RPTkU6Ci0gICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygiRGNEaXNjb25uZWN0aW5nU3RhdGUgbXNnLndoYXQ9RVZFTlRfREVBQ1RJVkFURV9ET05FIik7CisgICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygiRGNEaXNjb25uZWN0aW5nU3RhdGUgbXNnLndoYXQ9RVZFTlRfREVBQ1RJVkFURV9ET05FIFJlZkNvdW50PSIKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICArIG1BcG5MaXN0LnNpemUoKSk7CiAgICAgICAgICAgICAgICAgICAgIEFzeW5jUmVzdWx0IGFyID0gKEFzeW5jUmVzdWx0KSBtc2cub2JqOwogICAgICAgICAgICAgICAgICAgICBEaXNjb25uZWN0UGFyYW1zIGRwID0gKERpc2Nvbm5lY3RQYXJhbXMpIGFyLnVzZXJPYmo7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChkcC50YWcgPT0gbVRhZykgeworICAgICAgICAgICAgICAgICAgICBpZiAoZHAubVRoZVRhZyA9PSBtVGFnKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBUcmFuc2l0aW9uIHRvIGluYWN0aXZlIGJ1dCBzZW5kIG5vdGlmaWNhdGlvbnMgYWZ0ZXIKICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHdlJ3ZlIGVudGVyZWQgdGhlIG1JbmFjdGl2ZSBzdGF0ZS4KICAgICAgICAgICAgICAgICAgICAgICAgIG1JbmFjdGl2ZVN0YXRlLnNldEVudGVyTm90aWZpY2F0aW9uUGFyYW1zKChEaXNjb25uZWN0UGFyYW1zKSBhci51c2VyT2JqKTsKICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zaXRpb25UbyhtSW5hY3RpdmVTdGF0ZSk7CiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coIkRjRGlzY29ubmVjdFN0YXRlIEVWRU5UX0RFQUNUSVZBVEVfRE9ORSBzdGFsZSBkcC50YWc9IgotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArIGRwLnRhZyArICIgbVRhZz0iICsgbVRhZyk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgZHAubVRoZVRhZyArICIgbVRhZz0iICsgbVRhZyk7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgcmV0VmFsID0gSEFORExFRDsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CkBAIC0xMTY4LDcgKzEzOTEsNyBAQAogICAgICAgICAgICAgICAgIGNhc2UgRVZFTlRfREVBQ1RJVkFURV9ET05FOgogICAgICAgICAgICAgICAgICAgICBBc3luY1Jlc3VsdCBhciA9IChBc3luY1Jlc3VsdCkgbXNnLm9iajsKICAgICAgICAgICAgICAgICAgICAgQ29ubmVjdGlvblBhcmFtcyBjcCA9IChDb25uZWN0aW9uUGFyYW1zKSBhci51c2VyT2JqOwotICAgICAgICAgICAgICAgICAgICBpZiAoY3AudGFnID09IG1UYWcpIHsKKyAgICAgICAgICAgICAgICAgICAgaWYgKGNwLm1UaGVUYWcgPT0gbVRhZykgewogICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvZygiRGNEaXNjb25uZWN0aW9uRXJyb3JDcmVhdGluZ0Nvbm5lY3Rpb24iICsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIiBtc2cud2hhdD1FVkVOVF9ERUFDVElWQVRFX0RPTkUiKTsKQEAgLTExODIsNyArMTQwNSw3IEBACiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9nKCJEY0Rpc2Nvbm5lY3Rpb25FcnJvckNyZWF0aW5nQ29ubmVjdGlvbiBFVkVOVF9ERUFDVElWQVRFX0RPTkUiICsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICIgc3RhbGUgZHAudGFnPSIgKyBjcC50YWcgKyAiLCBtVGFnPSIgKyBtVGFnKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICIgc3RhbGUgZHAudGFnPSIgKyBjcC5tVGhlVGFnICsgIiwgbVRhZz0iICsgbVRhZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgcmV0VmFsID0gSEFORExFRDsKQEAgLTEyMDksMTMgKzE0MzIsMTQgQEAKICAgICAgKiBVc2VkIGZvciBjZWxsdWxhciBuZXR3b3JrcyB0aGF0IHVzZSBBY2Vzc3MgUG9pbnQgTmFtZXMgKEFQTikgc3VjaAogICAgICAqIGFzIEdTTSBuZXR3b3Jrcy4KICAgICAgKgorICAgICAqIEBwYXJhbSBhcG5Db250ZXh0IGlzIHRoZSBBY2Nlc3MgUG9pbnQgTmFtZ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YmouCiAgICAgICovCiAgICAgcHVibGljIHZvaWQgdGVhckRvd25BbGwoU3RyaW5nIHJlYXNvbiwgTWVzc2FnZSBvbkNvbXBsZXRlZE1zZykgeworICAgICAgICBpZiAoREJHKSBsb2coInRlYXJEb3duQWxsOiByZWFzb249IiArIHJlYXNvbiArICIgb25Db21wbGV0ZWRNc2c9IiArIG9uQ29tcGxldGVkTXNnKTsKICAgICAgICAgc2VuZE1lc3NhZ2Uob2J0YWluTWVzc2FnZShFVkVOVF9ESVNDT05ORUNUX0FMTCwKLSAgICAgICAgICAgICAgICBuZXcgRGlzY29ubmVjdFBhcmFtcyhyZWFzb24sIG9uQ29tcGxldGVkTXNnKSkpOworICAgICAgICAgICAgICAgIG5ldyBEaXNjb25uZWN0UGFyYW1zKG51bGwsIHJlYXNvbiwgb25Db21wbGV0ZWRNc2cpKSk7CiAgICAgfQogCiAgICAgLyoqCkBAIC0xMjYyLDI4ICsxNDkyLDI4IEBACiAgICAgICovCiAgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgZHVtcChGaWxlRGVzY3JpcHRvciBmZCwgUHJpbnRXcml0ZXIgcHcsIFN0cmluZ1tdIGFyZ3MpIHsKLSAgICAgICAgcHcucHJpbnQoIkRhdGFDb25uZWN0aW9uICIpOworICAgICAgICBwdy5wcmludCgiRGF0YUNvbm5lY3Rpb25CYXNlICIpOwogICAgICAgICBzdXBlci5kdW1wKGZkLCBwdywgYXJncyk7Ci0gICAgICAgIHB3LnByaW50bG4oIiBtQXBuTGlzdD0iICsgbUFwbkxpc3QpOworICAgICAgICBwdy5wcmludGxuKCIgbUFwbkNvbnRleHRzLnNpemU9IiArIG1BcG5MaXN0LnNpemUoKSk7CisgICAgICAgIHB3LnByaW50bG4oIiBtQXBuQ29udGV4dHM9IiArIG1BcG5MaXN0KTsKICAgICAgICAgcHcuZmx1c2goKTsKICAgICAgICAgcHcucHJpbnRsbigiIG1EYXRhQ29ubmVjdGlvblRyYWNrZXI9IiArIG1EYXRhQ29ubmVjdGlvblRyYWNrZXIpOwogICAgICAgICBwdy5wcmludGxuKCIgbUFwbj0iICsgbUFwbik7CiAgICAgICAgIHB3LnByaW50bG4oIiBtVGFnPSIgKyBtVGFnKTsKICAgICAgICAgcHcuZmx1c2goKTsKLSAgICAgICAgcHcucHJpbnRsbigiIHBob25lPSIgKyBwaG9uZSk7CisgICAgICAgIHB3LnByaW50bG4oIiBtUGhvbmU9IiArIG1QaG9uZSk7CiAgICAgICAgIHB3LnByaW50bG4oIiBtUmlsVmVyc2lvbj0iICsgbVJpbFZlcnNpb24pOwotICAgICAgICBwdy5wcmludGxuKCIgY2lkPSIgKyBjaWQpOworICAgICAgICBwdy5wcmludGxuKCIgbUNpZD0iICsgbUNpZCk7CiAgICAgICAgIHB3LmZsdXNoKCk7CiAgICAgICAgIHB3LnByaW50bG4oIiBtTGlua1Byb3BlcnRpZXM9IiArIG1MaW5rUHJvcGVydGllcyk7CiAgICAgICAgIHB3LmZsdXNoKCk7CiAgICAgICAgIHB3LnByaW50bG4oIiBtQ2FwYWJpbGl0aWVzPSIgKyBtQ2FwYWJpbGl0aWVzKTsKLSAgICAgICAgcHcucHJpbnRsbigiIGNyZWF0ZVRpbWU9IiArIFRpbWVVdGlscy5sb2dUaW1lT2ZEYXkoY3JlYXRlVGltZSkpOwotICAgICAgICBwdy5wcmludGxuKCIgbGFzdEZhaWxUaW1lPSIgKyBUaW1lVXRpbHMubG9nVGltZU9mRGF5KGxhc3RGYWlsVGltZSkpOwotICAgICAgICBwdy5wcmludGxuKCIgbGFzdEZhaWxDYXVzZT0iICsgbGFzdEZhaWxDYXVzZSk7CisgICAgICAgIHB3LnByaW50bG4oIiBtQ3JlYXRlVGltZT0iICsgVGltZVV0aWxzLmxvZ1RpbWVPZkRheShtQ3JlYXRlVGltZSkpOworICAgICAgICBwdy5wcmludGxuKCIgbUxhc3RGYWlsVGltZT0iICsgVGltZVV0aWxzLmxvZ1RpbWVPZkRheShtTGFzdEZhaWxUaW1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bj0iICsgcmVhc29uICsKLSAgICAgICAgICAgICAgICAgICAgIiBjb25uZWN0aW9uSWQ9IiArIGNvbm5lY3Rpb25JZCArICIgcmV0cnlDb3VudD0iICsgcmV0cnlDb3VudCArICIgZGNhYz0iICsgZGNhYwotICAgICAgICAgICAgICAgICAgICArICIgbURhdGFDb25uZWN0aW9uQXN5bmNDaGFubmVscz0iICsgbURhdGFDb25uZWN0aW9uQXN5bmNDaGFubmVscyk7CisgICAgICAgICAgICAgICAgICAgICIgcmV0cnlDb3VudD0iICsgcmV0cnlDb3VudCArCisgICAgICAgICAgICAgICAgICAgICIgYXBuVHlwZT0iICsgYXBuVHlwZSArICIgYXBuQ29udGV4dD0iICsgYXBuQ29udGV4dCArCisgICAgICAgICAgICAgICAgICAgICIgbURhdGFDb25uZWN0aW9uQXN5bmNDaGFubmVscz0iICsgbURhdGFDb25uZWN0aW9uQXN5bmNDaGFubmVscyk7CiAgICAgICAgIH0KIAotICAgICAgICBpZiAoZGNhYyAhPSBudWxsKSB7Ci0gICAgICAgICAgICBmb3IgKEFwbkNvbnRleHQgYXBuQ29udGV4dCA6IGRjYWMuZ2V0QXBuTGlzdFN5bmMoKSkgewotICAgICAgICAgICAgICAgIGFwbkNvbnRleHQuc2V0UmVhc29uKHJlYXNvbik7Ci0gICAgICAgICAgICAgICAgYXBuQ29udGV4dC5zZXRSZXRyeUNvdW50KHJldHJ5Q291bnQpOwotICAgICAgICAgICAgICAgIERjdENvbnN0YW50cy5TdGF0ZSBhcG5Db250ZXh0U3RhdGUgPSBhcG5Db250ZXh0LmdldFN0YXRlKCk7Ci0gICAgICAgICAgICAgICAgaWYgKERCRykgewotICAgICAgICAgICAgICAgICAgICBsb2coIm9uQWN0aW9uSW50ZW50UmVjb25uZWN0QWxhcm06IGFwbkNvbnRleHQgc3RhdGU9IiArIGFwbkNvbnRleHRTdGF0ZSk7Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIGlmICgoYXBuQ29udGV4dFN0YXRlID09IERjdENvbnN0YW50cy5TdGF0ZS5GQUlMRUQpCi0gICAgICAgICAgICAgICAgICAgICAgICB8fCAoYXBuQ29udGV4dFN0YXRlID09IERjdENvbnN0YW50cy5TdGF0ZS5JRExFKSkgewotICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBsb2coIm9uQWN0aW9uSW50ZW50UmVjb25uZWN0QWxhcm06IHN0YXRlIGlzIEZBSUxFRHxJRExFLCBkaXNhc3NvY2lhdGUiKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBhcG5Db250ZXh0LnNldERhdGFDb25uZWN0aW9uQWMobnVsbCk7Ci0gICAgICAgICAgICAgICAgICAgIGFwbkNvbnRleHQuc2V0RGF0YUNvbm5lY3Rpb24obnVsbCk7Ci0gICAgICAgICAgICAgICAgICAgIGFwbkNvbnRleHQuc2V0U3RhdGUoRGN0Q29uc3RhbnRzLlN0YXRlLklETEUpOwotICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGxvZygib25BY3Rpb25JbnRlbnRSZWNvbm5lY3RBbGFybToga2VlcCBhc3NvY2lhdGVkIik7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgc2VuZE1lc3NhZ2Uob2J0YWluTWVzc2FnZShEY3RDb25zdGFudHMuRVZFTlRfVFJZX1NFVFVQX0RBVEEsIGFwbkNvbnRleHQpKTsKKyAgICAgICAgaWYgKChhcG5Db250ZXh0ICE9IG51bGwpICYmIChhcG5Db250ZXh0LmlzRW5hYmxlZCgpKSkgeworICAgICAgICAgICAgYXBuQ29udGV4dC5zZXRSZWFzb24ocmVhc29uKTsKKyAgICAgICAgICAgIGFwbkNvbnRleHQuc2V0UmV0cnlDb3VudChyZXRyeUNvdW50KTsKKyAgICAgICAgICAgIERjdENvbnN0YW50cy5TdGF0ZSBhcG5Db250ZXh0U3RhdGUgPSBhcG5Db250ZXh0LmdldFN0YXRlKCk7CisgICAgICAgICAgICBpZiAoREJHKSB7CisgICAgICAgICAgICAgICAgbG9nKCJvbkFjdGlvbkludGVudFJlY29ubmVjdEFsYXJtOiBhcG5Db250ZXh0IHN0YXRlPSIgKyBhcG5Db250ZXh0U3RhdGUpOwogICAgICAgICAgICAgfQotICAgICAgICAgICAgLy8gQWxyYW0gaGFkIGV4cGlyZWQuIENsZWFyIHBlbmRpbmcgaW50ZW50IHJlY29yZGVkIG9uIHRoZSBEYXRhQ29ubmVjdGlvbi4KLSAgICAgICAgICAgIGRjYWMuc2V0UmVjb25uZWN0SW50ZW50U3luYyhudWxsKTsKKyAgICAgICAgICAgIGlmICgoYXBuQ29udGV4dFN0YXRlID09IERjdENvbnN0YW50cy5TdGF0ZS5GQUlMRUQpCisgICAgICAgICAgICAgICAgICAgIHx8IChhcG5Db250ZXh0U3RhdGUgPT0gRGN0Q29uc3RhbnRzLlN0YXRlLklETEUpKSB7CisgICAgICAgICAgICAgICAgaWYgKERCRykgeworICAgICAgICAgICAgICAgICAgICBsb2coIm9uQWN0aW9uSW50ZW50UmVjb25uZWN0QWxhcm06IHN0YXRlIGlzIEZBSUxFRHxJRExFLCBkaXNhc3NvY2lhdGUiKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgYXBuQ29udGV4dC5zZXREYXRhQ29ubmVjdGlvbkFjKG51bGwpOworICAgICAgICAgICAgICAgIGFwbkNvbnRleHQuc2V0RGF0YUNvbm5lY3Rpb24obnVsbCk7CisgICAgICAgICAgICAgICAgYXBuQ29udGV4dC5zZXRTdGF0ZShEY3RDb25zdGFudHMuU3RhdGUuSURMRSk7CisgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygib25BY3Rpb25JbnRlbnRSZWNvbm5lY3RBbGFybToga2VlcCBhc3NvY2lhdGVkIik7CisgICAgICAgICAgICB9CisgICAgICAgICAgICAvLyBUT0RPOiBJRiBhbHJlYWR5IGFzc29jaWF0ZWQgc2hvdWxkIHdlIHNlbmQgdGhlIEVWRU5UX1RSWV9TRVRVUF9EQVRBPz8/CisgICAgICAgICAgICBzZW5kTWVzc2FnZShvYnRhaW5NZXNzYWdlKERjdENvbnN0YW50cy5FVkVOVF9UUllfU0VUVVBfREFUQSwgYXBuQ29udGV4dCkpOworCisgICAgICAgICAgICBEYXRhQ29ubmVjdGlvbkFjIGRjYWMgPSBhcG5Db250ZXh0LmdldERhdGFDb25uZWN0aW9uQWMoKTsKKyAgICAgICAgICAgIGlmIChkY2FjICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICBDb2xsZWN0aW9uPEFwbkNvbnRleHQ+IGFwbkxpc3QgPSBkY2FjLmdldEFwbkxpc3RTeW5jKCk7CisgICAgICAgICAgICAgICAgbG9nKCJvbkFjdGlvbkludGVudFJlY29ubmVjdEFsYXJtOiBkY2FjLmdldEFwbkxpc3RTeW5jKCk9IiArIGFwbkxpc3QpOworICAgICAgICAgICAgICAgIC8vIEFsYXJtIGhhZCBleHBpcmVkLiBDbGVhciBwZW5kaW5nIGludGVudCByZWNvcmRlZCBvbiB0aGUgRGF0YUNvbm5lY3Rpb24uCisgICAgICAgICAgICAgICAgLy8gVE9ETzogTWF5YmUgc3RvcmUgaW4gYXBuQ29udGV4dD8/Pz8KKyAgICAgICAgICAgICAgICBkY2FjLnNldFJlY29ubmVjdEludGVudFN5bmMobnVsbCk7CisgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICB9CiAKQEAgLTE3MywxMyArMTcyLDEzIEBACiAKICAgICAvLyoqKioqIENvbnN0cnVjdG9yCiAKLSAgICBwdWJsaWMgR3NtRGF0YUNvbm5lY3Rpb25UcmFja2VyKFBob25lQmFzZSBwKSB7CisgICAgcHVibGljIERhdGFDb25uZWN0aW9uVHJhY2tlcihQaG9uZUJhc2U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vbGVhbiBpc0ZhaWxlZCA9IHRydWU7IC8vIEFsbCBlbmFibGVkIEFwbnMgc2hvdWxkIGJlIEZBSUxFRC4KQEAgLTQzNiw3ICs0MzYsNiBAQAogICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coIm92ZXJhbGwgc3RhdGUgaXMgQ09OTkVDVEVEIik7CiAgICAgICAgICAgICAgICAgICAgIHJldHVybiBEY3RDb25zdGFudHMuU3RhdGUuQ09OTkVDVEVEOwogICAgICAgICAgICAgICAgIGNhc2UgQ09OTkVDVElORzoKLSAgICAgICAgICAgICAgICBjYXNlIElOSVRJTkc6CiAgICAgICAgICAgICAgICAgICAgIGlzQ29ubmVjdGluZyA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgIGlzRmFpbGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwpAQCAtNDQ0LDYgKzQ0Myw5IEBACiAgICAgICAgICAgICAgICAgY2FzZSBTQ0FOTklORzoKICAgICAgICAgICAgICAgICAgICAgaXNGYWlsZWQgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICAgICAgaXNBbnlFbmFibGVkID0gdHJ1ZTsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogICAgICAgICB9CkBAIC00NjgsNyArNDcwLDcgQEAKICAgICAvKioKICAgICAgKiBFbnN1cmUgdGhhdCB3ZSBhcmUgY29ubmVjdGVkIHRvIGFuIEFQTiBvZiB0aGUgc3BlY2lmaWVkIHR5cGUuCiAgICAgICoKLSAgICAgKiBAcGFyYW0gdHlwZSB0aGUgQVBOIHR5cGUKKyAgICAgKiBAcGFyYW0gYXBuVHlwZSB0aGUgQVBOIHR5cGUKICAgICAgKiBAcmV0dXJuIFN1Y2Nlc3MgaXMgaW5kaWNhdGVkIGJ5IHtAY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0gICAgICAgICAgICAgICAgbVBob25lLm5vdGlmeURhdGFDb25uZWN0aW9uKHJlYXNvbiwgdHlwZSwgUGhvbmVDb25zdGFudHMuRGF0YVN0YXRlLkNPTk5FQ1RJTkcpOwotICAgICAgICAgICAgICAgIG1QaG9uZS5ub3RpZnlEYXRhQ29ubmVjdGlvbihyZWFzb24sIHR5cGUsIFBob25lQ29uc3RhbnRzLkRhdGFTdGF0ZS5DT05ORUNURUQpOwotICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICB9Ci0gICAgfQotCiAgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHN5bmNocm9uaXplZCBpbnQgZGlzYWJsZUFwblR5cGUoU3RyaW5nIHR5cGUpIHsKICAgICAgICAgaWYgKERCRykgbG9nKCJkaXNhYmxlQXBuVHlwZToiICsgdHlwZSk7CkBAIC01NjYsNyArNTQ5LDcgQEAKICAgICAgICAgc3luY2hyb25pemVkIChtRGF0YUVuYWJsZWRMb2NrKSB7CiAgICAgICAgICAgICBpZiAoIShtSW50ZXJuYWxEYXRhRW5hYmxlZCAmJiBtVXNlckRhdGFFbmFibGVkICYmIHNQb2xpY3lEYXRhRW5hYmxlZCkpIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgIGZvciAoQXBuQ29udGV4dCBhcG5Db250ZXh0IDogbUFwbkNvbnRleHRzLnZhbHVlcygpKSB7Ci0gICAgICAgICAgICAgICAgLy8gTWFrZSBzdXJlIHdlIGRvbnQgaGF2ZSBhIGNvbnRleHQgdGhhdCBnb2luZyBkb3duCisgICAgICAgICAgICAgICAgLy8gTWFrZSBzdXJlIHdlIGRvbid0IGhhdmUgYSBjb250ZXh0IHRoYXQgaXMgZ29pbmcgZG93bgogICAgICAgICAgICAgICAgIC8vIGFuZCBpcyBleHBsaWNpdGx5IGRpc2FibGVkLgogICAgICAgICAgICAgICAgIGlmIChpc0RhdGFBbGxvd2VkKGFwbkNvbnRleHQpKSB7CiAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwpAQCAtNzI2LDcgKzcwOSw3IEBACiAgICAgcHJpdmF0ZSBib29sZWFuIHRyeVNldHVwRGF0YShBcG5Db250ZXh0IGFwbkNvbnRleHQpIHsKICAgICAgICAgaWYgKERCRykgewogICAgICAgICAgICAgbG9nKCJ0cnlTZXR1cERhdGEgZm9yIHR5cGU6IiArIGFwbkNvbnRleHQuZ2V0QXBuVHlwZSgpICsKLSAgICAgICAgICAgICAgICAgICAgIiBkdWUgdG8gIiArIGFwbkNvbnRleHQuZ2V0UmVhc29uKCkpOworICAgICAgICAgICAgICAgICAgICAiIGR1ZSB0byAiICsgYXBuQ29udGV4dC5nZXRSZWFzb24oKSArICIgYXBuQ29udGV4dD0iICsgYXBuQ29udGV4dCk7CiAgICAgICAgICAgICBsb2coInRyeVNldHVwRGF0YSB3aXRoIG1Jc1BzUmVzdHJpY3RlZD0iICsgbUlzUHNSZXN0cmljdGVkKTsKICAgICAgICAgfQogCkBAIC03MzYsNyArNzE5LDcgQEAKICAgICAgICAgICAgIGFwbkNvbnRleHQuc2V0U3RhdGUoRGN0Q29uc3RhbnRzLlN0YXRlLkNPTk5FQ1RFRCk7CiAgICAgICAgICAgICBtUGhvbmUubm90aWZ5RGF0YUNvbm5lY3Rpb24oYXBuQ29udGV4dC5nZXRSZWFzb24oKSwgYXBuQ29udGV4dC5nZXRBcG5UeXBlKCkpOwogCi0gICAgICAgICAgICBsb2coInRyeVNldHVwRGF0YTogKGZpeD8pIFdlJ3JlIG9uIHRoZSBzaW11bGF0b3I7IGFzc3VtaW5nIGRhdGEgaXMgY29ubmVjdGVkIik7CisgICAgICAgICAgICBsb2coInRyeVNldHVwRGF0YTogWCBXZSdyZSBvbiB0aGUgc2ltdWxhdG9yOyBhc3N1bWluZyBjb25uZWN0ZWQgcmV0VmFsdWU9dHJ1ZSIpOwogICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgIH0KIApAQCAtNzQ5LDkgKzczMiw5IEBACiAgICAgICAgICAgICBpZiAoYXBuQ29udGV4dC5nZXRTdGF0ZSgpID09IERjdENvbnN0YW50cy5TdGF0ZS5JRExFKSB7CiAgICAgICAgICAgICAgICAgQXJyYXlMaXN0PEFwblNldHRpbmc+IHdhaXRpbmdBcG5zID0gYnVpbGRXYWl0aW5nQXBucyhhcG5Db250ZXh0LmdldEFwblR5cGUoKSk7CiAgICAgICAgICAgICAgICAgaWYgKHdhaXRpbmdBcG5zLmlzRW1wdHkoKSkgewotICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coInRyeVNldHVwRGF0YTogTm8gQVBOIGZvdW5kIik7Ci0gICAgICAgICAgICAgICAgICAgIG5vdGlmeU5vRGF0YShHc21EYXRhQ29ubmVjdGlvbi5GYWlsQ2F1c2UuTUlTU0lOR19VTktOT1dOX0FQTiwgYXBuQ29udGV4dCk7CisgICAgICAgICAgICAgICAgICAgIG5vdGlmeU5vRGF0YShEYXRhQ29ubmVjdGlvbkJhc2UuRmFpbENhdXNlLk1JU1NJTkdfVU5LTk9XTl9BUE4sIGFwbkNvbnRleHQpOwogICAgICAgICAgICAgICAgICAgICBub3RpZnlPZmZBcG5zT2ZBdmFpbGFiaWxpdHkoYXBuQ29udGV4dC5nZXRSZWFzb24oKSk7CisgICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygidHJ5U2V0dXBEYXRhOiBYIE5vIEFQTiBmb3VuZCByZXRWYWx1ZT1mYWxzZSIpOwogICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgYXBuQ29udGV4dC5zZXRXYWl0aW5nQXBucyh3YWl0aW5nQXBucyk7CkBAIC03NjIsMTEgKzc0NSwxNCBAQAogICAgICAgICAgICAgfQogCiAgICAgICAgICAgICBpZiAoREJHKSB7Ci0gICAgICAgICAgICAgICAgbG9nICgiU2V0dXAgd2F0aW5nQXBucyA6ICIgKyBhcG5MaXN0VG9TdHJpbmcoYXBuQ29udGV4dC5nZXRXYWl0aW5nQXBucygpKSk7CisgICAgICAgICAgICAgICAgbG9nKCJ0cnlTZXR1cERhdGE6IGNhbGwgc2V0dXBEYXRhLCB3YWl0aW5nQXBucyA6ICIKKyAgICAgICAgICAgICAgICAgICAgICAgICsgYXBuTGlzdFRvU3RyaW5nKGFwbkNvbnRleHQuZ2V0V2FpdGluZ0FwbnMoKSkpOwogICAgICAgICAgICAgfQogICAgICAgICAgICAgLy8gYXBuQ29udGV4dC5zZXRSZWFzb24oYXBuQ29udGV4dC5nZXRSZWFzb24oKSk7CiAgICAgICAgICAgICBib29sZWFuIHJldFZhbHVlID0gc2V0dXBEYXRhKGFwbkNvbnRleHQpOwogICAgICAgICAgICAgbm90aWZ5T2ZmQXBuc09mQXZhaWxhYmlsaXR5KGFwbkNvbnRleHQuZ2V0UmVhc29uKCkpOworCisgICAgICAgICAgICBpZiAoREJHKSBsb2coInRyeVNldHVwRGF0YTogWCByZXRWYWx1ZT0iICsgcmV0VmFsdWUpOwogICAgICAgICAgICAgcmV0dXJuIHJldFZhbHVlOwogICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgLy8gVE9ETzogY2hlY2sgdGhlIGNvbmRpdGlvbi4KQEAgLTc3NSw2ICs3NjEsNyBAQAogICAgICAgICAgICAgICAgICAgICB8fCBhcG5Db250ZXh0LmdldFN0YXRlKCkgPT0gRGN0Q29uc3RhbnRzLlN0YXRlLlNDQU5OSU5HKSkKICAgICAgICAgICAgICAgICBtUGhvbmUubm90aWZ5RGF0YUNvbm5lY3Rpb25GYWlsZWQoYXBuQ29udGV4dC5nZXRSZWFzb24oKSwgYXBuQ29udGV4dC5nZXRBcG5UeXBlKCkpOwogICAgICAgICAgICAgbm90aWZ5T2ZmQXBuc09mQXZhaWxhYmlsaXR5KGFwbkNvbnRleHQuZ2V0UmVhc29uKCkpOworICAgICAgICAgICAgaWYgKERCRykgbG9nICgidHJ5U2V0dXBEYXRhOiBYIGFwbkNvbnRleHQgbm90ICdyZWFkeScgcmV0VmFsdWU9ZmFsc2UiKTsKICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgfQogICAgIH0KQEAgLTc5MCw3ICs3NzcsNyBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBQaG9uZUNvbnN0YW50cy5EYXRhU3RhdGUuRElTQ09OTkVDVEVEKTsKICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgaWYgKERCRykgewotICAgICAgICAgICAgICAgICAgICBsb2coIm5vdGlmeU9mZkFwbnNPZkF2YWlsYWJpbGl0eSBza2lwcGVkIGFwbiBkdWUgdG8gaXNSZWFkeT09ZmFsc2U6ICIgKworICAgICAgICAgICAgICAgICAgICBsb2coIm5vdGlmeU9mZkFwbnNPZkF2YWlsYWJpbGl0eSBza2lwcGVkIGFwbiBkdWUgdG8gaXNSZWFkeT09dHJ1ZTogIiArCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBuQ29udGV4dC50b1N0cmluZygpKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CkBAIC03OTksMTAgKzc4NiwxMCBAQAogCiAgICAgLyoqCiAgICAgICogSWYgdGVhckRvd24gaXMgdHJ1ZSwgdGhpcyBvbmx5IHRlYXJzIGRvd24gYSBDT05ORUNURUQgc2Vzc2lvbi4gUHJlc2VudGx5LAotICAgICAqIHRoZXJlIGlzIG5vIG1lY2hhbmlzbSBmb3IgYWJhbmRvbmluZyBhbiBJTklUSU5HL0NPTk5FQ1RJTkcgc2Vzc2lvbiwKKyAgICAgKiB0aGVyZSBpcyBubyBtZWNoYW5pc20gZm9yIGFiYW5kb25pbmcgYW4gQ09OTkVDVElORyBzZXNzaW9uLAogICAgICAqIGJ1dCB3b3VsZCBsaWtlbHkgaW52b2x2ZSBjYW5jZWxsaW5nIHBlbmRpbmcgYXN5bmMgcmVxdWVzdHMgb3IKICAgICAgKiBzZXR0aW5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IHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcG5Db250ZXh0LmdldERhdGFDb25uZWN0aW9uKCkudGVhckRvd24oYXBuQ29udGV4dC5nZXRSZWFzb24oKSwgbXNnKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcG5Db250ZXh0LmdldERhdGFDb25uZWN0aW9uKCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnRlYXJEb3duKGFwbkNvbnRleHQsIGFwbkNvbnRleHQuZ2V0UmVhc29uKCksIG1zZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICBhcG5Db250ZXh0LnNldFN0YXRlKERjdENvbnN0YW50cy5TdGF0ZS5ESVNDT05ORUNUSU5HKTsKICAgICAgICAgICAgICAgICAgICAgfQpAQCAtOTIwLDcgKzkwNyw3IEBACiAgICAgLyoqCiAgICAgICogQ2FuY2VscyB0aGUgYWxhcm0gYXNzb2NpYXRlZCB3aXRoIERDQUMuCiAgICAgICoKLSAgICAgKiBAcGFyYW0gRGF0YUNvbm5lY3Rpb25BYyBvbiB3aGljaCB0aGUgYWxhcm0gc2hvdWxkIGJlIHN0b3BwZWQuCisgICAgICogQHBhcmFtIGRjYWMgb24gd2hpY2ggdGhlIGFsYXJtIHNob3VsZCBiZSBzdG9wcGVkLgogICAgICAqLwogICAgIHByaXZhdGUgdm9pZCBjYW5jZWxSZWNvbm5lY3RBbGFybShEYXRhQ29ubmVjdGlvbkFjIGRjYWMpIHsKICAgICAgICAgaWYgKGRjYWMgPT0gbnVsbCkgcmV0dXJuOwpAQCAtMTAwMSw2MiArOTg4LDMxIEBACiAgICAgICAgIC8vIFRPRE86IEZpeCByZXRyeSBoYW5kbGluZyBzbyBmcmVlIERhdGFDb25uZWN0aW9ucyBoYXZlIGVtcHR5IGFwbmxpc3RzLgogICAgICAgICAvLyBQcm9iYWJseSBtb3ZlIHJldHJ5IGhhbmRsaW5nIGludG8gRGF0YUN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GNhYy5kYXRhQ29ubmVjdGlvbjsKKyAgICAgICAgICAgICAgICBEYXRhQ29ubmVjdGlvbkJhc2UgZGMgPSBkY2FjLmRhdGFDb25uZWN0aW9uOwogICAgICAgICAgICAgICAgIGlmIChEQkcpIHsKLSAgICAgICAgICAgICAgICAgICAgbG9nKCJmaW5kRnJlZURhdGFDb25uZWN0aW9uOiBmb3VuZCBmcmVlIEdzbURhdGFDb25uZWN0aW9uPSIgKworICAgICAgICAgICAgICAgICAgICBsb2coImZpbmRGcmVlRGF0YUNvbm5lY3Rpb246IGZvdW5kIGZyZWUgRGF0YUNvbm5lY3Rpb249IiArCiAgICAgICAgICAgICAgICAgICAgICAgICAiIGRjYWM9IiArIGRjYWMgKyAiIGRjPSIgKyBkYyk7CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIHJldHVybiAoR3NtRGF0YUNvbm5lY3Rpb24pIGRjOworICAgICAgICAgICAgICAgIHJldHVybiAoRGF0YUNvbm5lY3Rpb24pIGRjOwogICAgICAgICAgICAgfQogICAgICAgICB9Ci0gICAgICAgIGxvZygiZmluZEZyZWVEYXRhQ29ubmVjdGlvbjogTk8gZnJlZSBHc21EYXRhQ29ubmVjdGlvbiIpOworICAgICAgICBsb2coImZpbmRGcmVlRGF0YUNvbm5lY3Rpb246IE5PIGZyZWUgRGF0YUNvbm5lY3Rpb24iKTsKICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgfQogCi0gICAgcHJvdGVjdGVkIEdzbURhdGFDb25uZWN0aW9uIGZpbmRSZWFkeURhdGFDb25uZWN0aW9uKEFwblNldHRpbmcgYXBuKSB7Ci0gICAgICAgIGlmIChhcG4gPT0gbnVsbCkgewotICAgICAgICAgICAgcmV0dXJuIG51bGw7Ci0gICAgICAgIH0KLSAgICAgICAgaWYgKERCRykgewotICAgICAgICAgICAgbG9nKCJmaW5kUmVhZHlEYXRhQ29ubmVjdGlvbjogYXBuIHN0cmluZyA8IiArIGFwbiArICI+IiArCi0gICAgICAgICAgICAgICAgICAgICIgZGNhY3Muc2l6ZT0iICsgbURhdGFDb25uZWN0aW9uQXN5bmNDaGFubmVscy5zaXplKCkpOwotICAgICAgICB9Ci0gICAgICAgIGZvciAoRGF0YUNvbm5lY3Rpb25BYyBkY2FjIDogbURhdGFDb25uZWN0aW9uQXN5bmNDaGFubmVscy52YWx1ZXMoKSkgewotICAgICAgICAgICAgQXBuU2V0dGluZyBhcG5TZXR0aW5nID0gZGNhYy5nZXRBcG5TZXR0aW5nU3luYygpOwotICAgICAgICAgICAgaWYgKERCRykgewotICAgICAgICAgICAgICAgIGxvZygiZmluZFJlYWR5RGF0YUNvbm5lY3Rpb246IGRjIGFwbiBzdHJpbmcgPCIgKwotICAgICAgICAgICAgICAgICAgICAgICAgIChhcG5TZXR0aW5nICE9IG51bGwgPyAoYXBuU2V0dGluZy50b1N0cmluZygpKSA6ICJudWxsIikgKyAiPiIpOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgaWYgKChhcG5TZXR0aW5nICE9IG51bGwpICYmIFRleHRVdGlscy5lcXVhbHMoYXBuU2V0dGluZy50b1N0cmluZygpLCBhcG4udG9TdHJpbmcoKSkpIHsKLSAgICAgICAgICAgICAgICBEYXRhQ29ubmVjdGlvbiBkYyA9IGRjYWMuZGF0YUNvbm5lY3Rpb247Ci0gICAgICAgICAgICAgICAgaWYgKERCRykgewotICAgICAgICAgICAgICAgICAgICBsb2coImZpbmRSZWFkeURhdGFDb25uZWN0aW9uOiBmb3VuZCByZWFkeSBHc21EYXRhQ29ubmVjdGlvbj0iICsKLSAgICAgICAgICAgICAgICAgICAgICAgICIgZGNhYz0iICsgZGNhYyArICIgZGM9IiArIGRjKTsKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgcmV0dXJuIChHc21EYXRhQ29ubmVjdGlvbikgZGM7Ci0gICAgICAgICAgICB9Ci0gICAgICAgIH0KLSAgICAgICAgcmV0dXJuIG51bGw7Ci0gICAgfQotCi0KICAgICBwc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Z2V0IHRoZSB3cm9uZyBvbmU/PwotICAgICAgICAgICAgICAgIGRjID0gZmluZEZyZWVEYXRhQ29ubmVjdGlvbigpOwotICAgICAgICAgICAgfQorICAgICAgICAgICAgLy8gVE9ETzogV2hlbiBhbGxvY2F0aW5nIHlvdSBhcmUgbWFwcGluZyB0eXBlIHRvIGlkLiBJZiBtb3JlIHRoYW4gMSBmcmVlLAorICAgICAgICAgICAgLy8gdGhlbiBjb3VsZCBmaW5kRnJlZURhdGFDb25uZWN0aW9uIGdldCB0aGUgd3Jvbmcgb25lPz8KKyAgICAgICAgICAgIGRjID0gZmluZEZyZWVEYXRhQ29ubmVjdGlvbigpOwogCiAgICAgICAgICAgICBpZiAoZGMgPT0gbnVsbCkgewogICAgICAgICAgICAgICAgIGRjID0gY3JlYXRlRGF0YUNvbm5lY3Rpb24oKTsKICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgaWYgKGRjID09IG51bGwpIHsKLSAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coInNldHVwRGF0YTogTm8gZnJlZSBHc21EYXRhQ29ubmVjdGlvbiBmb3VuZCEiKTsKKyAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coInNldHVwRGF0YTogTm8gZnJlZSBEYXRhQ29ubmVjdGlvbiBmb3VuZCEiKTsKICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0gZWxzZSB7CkBAIC0xMDk0LDcgKzEwNDUsNyBAQAogICAgICAgICBkYy5zZXRQcm9maWxlSWQoIHByb2ZpbGVJZCApOyAgLy8gIGFzc3VtZWQgbm8gY29ubmVjdGlvbiBzaGFyaW5nIG9uIHByb2ZpbGVkIHR5cGVzCiAKICAgICAgICAgaW50IHJlZkNvdW50ID0gZGNhYy5nZXRSZWZDb3VudFN5bmMoKTsKLSAgICAgICAgaWYgKERCRykgbG9nKCJzZXR1cERhdGE6IGluaXQgZGMgYW5kIGFwbkNvbnRleHQgcmVmQ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udFN5bmMoKSAhPSBudWxsKSB7CiAgICAgICAgICAgICBpZiAoREJHKSBsb2coInNldHVwRGF0YTogZGF0YSByZWNvbm5lY3Rpb24gcGVuZGluZyIpOwogICAgICAgICAgICAgYXBuQ29udGV4dC5zZXRTdGF0ZShEY3RDb25zdGFudHMuU3RhdGUuRkFJTEVEKTsKQEAgLTExMTksNyArMTA3MCw3IEBACiAgICAgICAgIE1lc3NhZ2UgbXNnID0gb2J0YWluTWVzc2FnZSgpOwogICAgICAgICBtc2cud2hhdCA9IERjdENvbnN0YW50cy5FVkVOVF9EQVRBX1NFVFVQX0NPTVBMRVRFOwogICAgICAgICBtc2cub2JqID0gYXBuQ29udGV4dDsKLSAgICAgICAgZGMuYnJpbmdVcChtc2csIGFwbik7CisgICAgICAgIGRjLmJyaW5nVXAoYXBuQ29udGV4dCwgbXNnKTsKIAogICAgICAgICBpZiAoREJHKSBsb2coInNldHVwRGF0YTogaW5pdGluZyEiKTsKICAgICAgICAgcmV0dXJuIHRydWU7CkBAIC0xMTg0LDggKzExMzUsNyBAQAogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBpZiAoIWZvdW5kKSB7CiAgICAgICAgICAgICAgICAgICAgIC8vIEFwbkNvbnRleHQgZG9lcyBub3QgaGF2ZSBkY2FjIHJlcG9ydGVkIGluIGRhdGEgY2FsbCBsaXN0LgotICAgICAgICAgICAgICAgICAgICAvLyBGZXRjaCBhbGwgdGhlIEFwbkNvbnRleHRzIHRoYXQgbWFwIHRvIHRoaXMgZGNhYyB3aGljaCBhcmUgaW4KLSAgICAgICAgICAgICAgICAgICAgLy8gSU5JVElORyBzdGF0ZSB0b28uCisgICAgICAgICAgICAgICAgICAgIC8vIEZldGNoIGFsbCB0aGUgQXBuQ29udGV4dHMgdGhhdCBtYXAgdG8gdGhpcyBkY2FjLgogICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coImZpbmRBcG5Db250ZXh0VG9DbGVhbihhcik6IENvbm5lY3RlZCBhcG4gbm90IGZvdW5kIGluIHRoZSBsaXN0ICgiICsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFwbkNvbnRleHQudG9TdHJpbmcoKSArICIpIik7CiAgICAgICAgICAgICAgICAgICAgIGlmIChhcG5Db250ZXh0LmdldERhdGFDb25uZWN0aW9uQWMoKSAhPSBudWxsKSB7CkBAIC0xMjUzLDggKzEyMDMsNyBAQAogICAgICAgICAgICAgQXJyYXlMaXN0PEFwbkNvbnRleHQ+IGNvbm5lY3RlZEFwbnMgPSBuZXcgQXJyYXlMaXN0PEFwbkNvbnRleHQ+KCk7CiAgICAgICAgICAgICBmb3IgKEFwbkNvbnRleHQgYXBuQ29udGV4dCA6IGFwbnMpIHsKICAgICAgICAgICAgICAgICBpZiAoYXBuQ29udGV4dC5nZXRTdGF0ZSgpID09IERjdENvbnN0YW50cy5TdGF0ZS5DT05ORUNURUQgfHwKLSAgICAgICAgICAgICAgICAgICAgICAgYXBuQ29udGV4dC5nZXRTdGF0ZSgpID09IERjdENvbnN0YW50cy5TdGF0ZS5DT05ORUNUSU5HIHx8Ci0gICAgICAgICAgICAgICAgICAgICAgIGFwbkNvbnRleHQuZ2V0U3RhdGUoKSA9PSBEY3RDb25zdGFudHMuU3RhdGUuSU5JVElORykgeworICAgICAgICAgICAgICAgICAgICAgICBhcG5Db250ZXh0LmdldFN0YXRlKCkgPT0gRGN0Q29uc3RhbnRzLlN0YXRlLkNPTk5FQ1RJTkcpIHsKICAgICAgICAgICAgICAgICAgICAgY29ubmVjdGVkQXBucy5hZGQoYXBuQ29udGV4dCk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQpAQCAtMTM4NCw2ICsxMzMzLDcgQEAKICAgICB9CiAKICAgICAvLyBUT0RPOiBGb3IgbXVsdGlwbGUgQWN0aXZlIEFQTnMgbm90IGV4YWN0bHkgc3VyZSBob3cgdG8gZG8gdGhpcy4KKyAgICBAT3ZlcnJpZGUKICAgICBwcm90ZWN0Z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0gZmV0Y2hEdW5BcG4oKTsKICAgICAgICAgfQogCi0gICAgICAgIERhdGFDb25uZWN0aW9uIHBvdGVudGlhbCA9IG51bGw7CisgICAgICAgIERhdGFDb25uZWN0aW9uQmFzZSBwb3RlbnRpYWwgPSBudWxsOwogICAgICAgICBmb3IgKEFwbkNvbnRleHQgYyA6IG1BcG5Db250ZXh0cy52YWx1ZXMoKSkgewotICAgICAgICAgICAgRGF0YUNvbm5lY3Rpb24gY29ubiA9IGMuZ2V0RGF0YUNvbm5lY3Rpb24oKTsKKyAgICAgICAgICAgIERhdGFDb25uZWN0aW9uQmFzZSBjb25uID0gYy5nZXREYXRhQ29ubmVjdGlvbigpOwogICAgICAgICAgICAgaWYgKGNvbm4gIT0gbnVsbCkgewogICAgICAgICAgICAgICAgIEFwblNldHRpbmcgYXBuU2V0dGluZyA9IGMuZ2V0QXBuU2V0dGluZygpOwogICAgICAgICAgICAgICAgIGlmIChkdW5TZXR0aW5nICE9IG51bGwpIHsKQEAgLTE2MzAsNiArMTU4MCw5IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjb25uOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgQ09OTkVDVElORzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcG90ZW50aWFsID0gY29ubjsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBOb3QgY29ubmVjdGVkLCBwb3RlbnRpYWwgdW5jaGFuZ2VkCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChhcG5TZXR0aW5nICE9IG51bGwgJiYgYXBuU2V0dGluZy5jYW5IYW5kbGVUeXBlKGFwblR5cGUpKSB7CkBAIC0xNjQyLDYgKzE1OTUsOSBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjb25uOwogICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBDT05ORUNUSU5HOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvdGVudGlhbCA9IGNvbm47CisgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIE5vdCBjb25uZWN0ZWQsIHBvdGVudGlhbCB1bmNoYW5nZWQKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KQEAgLTE3NTYsNyArMTcxMiw3IEBACiAgICAgQE92ZXJyaWRlCiAgICAgcHJvdGVjdGVkIHZvaWQgb25EYXRhU2V0dXBDb21wbGV0ZShBc3luY1Jlc3VsdCBhcikgewogCi0gICAgICAgIERhdGFDb25uZWN0aW9uLkZhaWxDYXVzZSBjYXVzZSA9IERhdGFDb25uZWN0aW9uLkZhaWxDYXVzZS5VTktOT1dOOworICAgICAgICBEYXRhQ29ubmVjdGlvbkJhc2UuRmFpbENhdXNlIGNhdXNlID0gRGF0YUNvbm5lY3Rpb25CYXNlLkZhaWxDYXVzZS5VTktOT1dOOwogICAgICAgICBib29sZWFuIGhhbmRsZUVycm9yID0gZmFsc2U7CiAgICAgICAgIEFwbkNvbnRleHQgYXBuQ29udGV4dCA9IG51bGw7CiAKQEAgLTE3NjYsNyArMTcyMiw3IEBACiAgICAgICAgICAgICB0aHJvdyBuZXcgUnVudGltZUV4Y2VwdGlvbigib25EYXRhU2V0dXBDb21wbGV0ZTogTm8gYXBuQ29udGV4dCIpOwogICAgICAgICB9CiAKLSAgICAgICAgaWYgKGlzRGF0YVNldHVwQ29tcGxldGVPayhhcikpIHsKKyAgICAgICAgaWYgKGFyLmV4Y2VwdGlvbiA9PSBudWxsKSB7CiAgICAgICAgICAgICBEYXRhQ29ubmVjdGlvbkFjIGRjYWMgPSBhcG5Db250ZXh0LmdldERhdGFDb25uZWN0aW9uQWMoKTsKIAogICAgICAgICAgICAgaWYgKFJBRElPX1RFU1RTKSB7CkBAIC0xNzg5LDEwICsxNzQ1LDEwIEBACiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBpZiAoZGNhYyA9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgbG9nKCJvbkRhdGFTZXR1cENvbXBsZXRlOiBubyBjb25uZWN0aW9uIHRvIERDLCBoYW5kbGUgYXMgZXJyb3IiKTsKLSAgICAgICAgICAgICAgICBjYXVzZSA9IERhdGFDb25uZWN0aW9uLkZhaWxDYXVzZS5DT05ORUNUSU9OX1RPX0RBVEFDT05ORUNUSU9OQUNfQlJPS0VOOworICAgICAgICAgICAgICAgIGNhdXNlID0gRGF0YUNvbm5lY3Rpb25CYXNlLkZhaWxDYXVzZS5DT05ORUNUSU9OX1RPX0RBVEFDT05ORUNUSU9OQUNfQlJPS0VOOwogICAgICAgICAgICAgICAgIGhhbmRsZUVycm9yID0gdHJ1ZTsKICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgRGF0YUNvbm5lY3Rpb24gZGMgPSBhcG5Db250ZXh0LmdldERhdGFDb25uZWN0aW9uKCk7CisgICAgICAgICAgICAgICAgRGF0YUNvbm5lY3Rpb25CYXNlIGRjID0gYXBuQ29udGV4dC5nZXREYXRhQ29ubmVjdGlvbigpOwogICAgICAgICAgICAgICAgIEFwblNldHRpbmcgYXBuID0gYXBuQ29udGV4dC5nZXRBcG5TZXR0aW5nKCk7CiAgICAgICAgICAgICAgICAgaWYgKERCRykgewogICAgICAgICAgICAgICAgICAgICBsb2coIm9uRGF0YVNldHVwQ29tcGxldGU6IHN1Y2Nlc3MgYXBuPSIgKyAoYXBuID09IG51bGwgPyAidW5rbm93biIgOiBhcG4uYXBuKSk7CkBAIC0xODEzLDcgKzE3NjksNyBAQAogICAgICAgICAgICAgICAgIC8vIGV2ZXJ5dGhpbmcgaXMgc2V0dXAKICAgICAgICAgICAgICAgICBpZihUZXh0VXRpbHMuZXF1YWxzKGFwbkNvbnRleHQuZ2V0QXBuVHlwZSgpLFBob25lQ29uc3RhbnRzLkFQTl9UWVBFX0RFRkFVTFQpKSB7CiAgICAgICAgICAgICAgICAgICAgIFN5c3RlbVByb3BlcnRpZXMuc2V0KCJnc20uZGVmYXVsdHBkcGNvbnRleHQuYWN0aXZlIiwgInRydWUiKTsKLSAgICAgICAgICAgICAgICAgICAgaWYgKGNhblNldFByZWZlckFwbiAmJiBtUHJlZmVycmVkQXBuID09IG51bGwpIHsKKyAgICAgICAgICAgICAgICAgICAgaWYgKG1DYW5TZXRQcmVmZXJBcG4gJiYgbVByZWZlcnJlZEFwbiA9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coIm9uRGF0YVNldHVwQ29tcGxldGU6IFBSRUZFUkVEIEFQTiBpcyBudWxsIik7CiAgICAgICAgICAgICAgICAgICAgICAgICBtUHJlZmVycmVkQXBuID0gYXBuOwogICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1QcmVmZXJyZWRBcG4gIT0gbnVsbCkgewpAQCAtMTgyNiw3ICsxNzgyLDcgQEAKICAgICAgICAgICAgICAgICBub3RpZnlEZWZhdWx0RGF0YShhcG5Db250ZXh0KTsKICAgICAgICAgICAgIH0KICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgIGNhdXNlID0gKERhdGFDb25uZWN0aW9uLkZhaWxDYXVzZSkgKGFyLnJlc3VsdCk7CisgICAgICAgICAgICBjYXVzZSA9IChEYXRhQ29ubmVjdGlvbkJhc2UuRmFpbENhdXNlKSAoYXIucmVzdWx0KTsKICAgICAgICAgICAgIGlmIChEQkcpIHsKICAgICAgICAgICAgICAgICBBcG5TZXR0aW5nIGFwbiA9IGFwbkNvbnRleHQuZ2V0QXBuU2V0dGluZygpOwogICAgICAgICAgICAgICAgIGxvZyhTdHJpbmcuZm9ybWF0KCJvbkRhdGFTZXR1cENvbXBsZXRlOiBlcnJvciBhcG49JXMgY2F1c2U9JXMiLApAQCAtMTg2OCw5ICsxODI0LDkgQEAKICAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJvbkRhdGFTZXR1cENvbXBsZXRlOiBOb3QgYWxsIHBlcm1hbmVudCBmYWlsdXJlcywgcmV0cnkiKTsKICAgICAgICAgICAgICAgICAgICAgLy8gY2hlY2sgdG8gc2VlIGlmIHJldHJ5IHNob3VsZCBiZSBvdmVycmlkZGVuIGZvciB0aGlzIGZhaWx1cmUuCiAgICAgICAgICAgICAgICAgICAgIGludCByZXRyeU92ZXJyaWRlID0gLTE7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChhci5leGNlcHRpb24gaW5zdGFuY2VvZiBEYXRhQ29ubmVjdGlvbi5DYWxsU2V0dXBFeGNlcHRpb24pIHsKKyAgICAgICAgICAgICAgICAgICAgaWYgKGFyLmV4Y2VwdGlvbiBpbnN0YW5jZW9mIERhdGFDb25uZWN0aW9uQmFzZS5DYWxsU2V0dXBFeGNlcHRpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgIHJldHJ5T3ZlcnJpZGUgPQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICgoRGF0YUNvbm5lY3Rpb24uQ2FsbFNldHVwRXhjZXB0aW9uKWFyLmV4Y2VwdGlvbikuZ2V0UmV0cnlPdmVycmlkZSgpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICgoRGF0YUNvbm5lY3Rpb25CYXNlLkNhbGxTZXR1cEV4Y2VwdGlvbilhci5leGNlcHRpb24pLmdldFJldHJ5T3ZlcnJpZGUoKTsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICBpZiAocmV0cnlPdmVycmlkZSA9PSBSSUxDb25zdGFudHMuTUFYX0lOVCkgewogICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKC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hbihjb20uYW5kcm9pZC4KICAgICAgICAgICAgICAgICAgICAgaW50ZXJuYWwuUi5ib29sLmNvbmZpZ19kb250UHJlZmVyQXBuKTsKICAgICAgICAgfSBjYXRjaCAoUmVzb3VyY2VzLk5vdEZvdW5kRXhjZXB0aW9uIGUpIHsKKyAgICAgICAgICAgIGlmIChEQkcpIGxvZygiYnVpbGRXYWl0aW5nQXBuczogdXNlUHJlZmVycmVkIE5vdEZvdW5kRXhjZXB0aW9uIHNldCB0byB0cnVlIik7CiAgICAgICAgICAgICB1c2VQcmVmZXJyZWQgPSB0cnVlOwogICAgICAgICB9CisgICAgICAgIGlmIChEQkcpIHsKKyAgICAgICAgICAgIGxvZygiYnVpbGRXYWl0aW5nQXBuczogdXNlUHJlZmVycmVkPSIgKyB1c2VQcmVmZXJyZWQKKyAgICAgICAgICAgICAgICAgICAgKyAiIGNhblNldFByZWZlckFwbj0iICsgbUNhblNldFByZWZlckFwbgorICAgICAgICAgICAgICAgICAgICArICIgbVByZWZlcnJlZEFwbj0iICsgbVByZWZlcnJlZEFwbgorICAgICAgICAgICAgICAgICAgICArICIgb3BlcmF0b3I9IiArIG9wZXJhdG9yICsgIiByYWRpb1RlY2g9IiArIHJhZGlvVGVjaAorICAgICAgICAgICAgICAgICAgICArICIgSWNjUmVjb3JkcyByPSIgKyByKTsKKyAgICAgICAgfQogCi0gICAgICAgIGlmICh1c2VQcmVmZXJyZWQgJiYgY2FuU2V0UHJlZmVyQXBuICYmIG1QcmVmZXJyZWRBcG4gIT0gbnVsbCAmJgorICAgICAgICBpZiAodXNlUHJlZmVycmVkICYmIG1DYW5TZXRQcmVmZXJBcG4gJiYgbVByZWZlcnJlZEFwbiAhPSBudWxsICYmCiAgICAgICAgICAgICAgICAgbVByZWZlcnJlZEFwbi5jYW5IYW5kbGVUeXBlKHJlcXVlc3RlZEFwblR5cGUpKSB7CiAgICAgICAgICAgICBpZiAoREJHKSB7CiAgICAgICAgICAgICAgICAgbG9nKCJidWlsZFdhaXRpbmdBcG5zOiBQcmVmZXJyZWQgQVBOOiIgKyBvcGVyYXRvciArICI6IgpAQCAtMjE3OCwxNCArMjE0NCwyNiBAQAogICAgICAgICAgICAgfQogICAgICAgICB9CiAgICAgICAgIGlmIChtQWxsQXBucyAhPSBudWxsKSB7CisgICAgICAgICAgICBpZiAoREJHKSBsb2coImJ1aWxkV2FpdGluZ0FwbnM6IG1BbGxBcG5zPSIgKyBtQWxsQXBucyk7CiAgICAgICAgICAgICBmb3IgKEFwblNldHRpbmcgYXBuIDogbUFsbEFwbnMpIHsKKyAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coImJ1aWxkV2FpdGluZ0FwbnM6IGFwbj0iICsgYXBuKTsKICAgICAgICAgICAgICAgICBpZiAoYXBuLmNhbkhhbmRsZVR5cGUocmVxdWVzdGVkQXBuVHlwZSkpIHsKICAgICAgICAgICAgICAgICAgICAgaWYgKGFwbi5iZWFyZXIgPT0gMCB8fCBhcG4uYmVhcmVyID09IHJhZGlvVGVjaCkgewotICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJhcG4gaW5mbyA6ICIgK2Fwbi50b1N0cmluZygpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygiYnVpbGRXYWl0aW5nQXBuczogYWRkaW5nIGFwbj0iICsgYXBuLnRvU3RyaW5nKCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgYXBuTGlzdC5hZGQoYXBuKTsKKyAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2coImJ1aWxkV2FpdGluZ0FwbnM6IGJlYXJlcjoiICsgYXBuLmJlYXJlciArICIgIT0gIgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyAicmFkaW9UZWNoOiIgKyByYWRpb1RlY2gpOworICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICBpZiAoREJHKSB7CisgICAgICAgICAgICAgICAgICAgIGxvZygiYnVpbGRXYWl0aW5nQXBuczogY291bGRuJ3QgaGFuZGxlIHJlcXVlc2VkQXBuVHlwZT0iCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyByZXF1ZXN0ZWRBcG5UeXBlKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CisgICAgICAgICAgICB9CiAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICBsb2dlKCJtQWxsQXBucyBpcyBlbXB0eSEiKTsKICAgICAgICAgfQpAQCAtMjIwMywxNCArMjE4MSwxNSBAQAogICAgICAgICByZXR1cm4gcmVzdWx0LnRvU3RyaW5nKCk7CiAgICAgfQogCi0gICAgcHJpdmF0ZSB2b2lkIHN0YXJ0RGVsYXllZFJldHJ5KEdzbURhdGFDb25uZWN0aW9uLkZhaWxDYXVzZSBjYXVzZSwKKyAgICBwcml2YXRlIHZvaWQgc3RhcnREZWxheWVkUmV0cnkoRGF0YUNvbm5lY3Rpb24uRmFpbENhdXNlIGNhdXNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBcG5Db250ZXh0IGFwbkNvbnRleHQsIGludCByZXRyeU92ZXJyaWRlKSB7CisgICAgICAgIGFwbkNvbnRleHQuc2V0U3RhdGUoRGN0Q29uc3RhbnRzLlN0YXRlLkZBSUxFRCk7CiAgICAgICAgIG5vdGlmeU5vRGF0YShjYXVzZSwgYXBuQ29udGV4dCk7CiAgICAgICAgIHJlY29ubmVjdEFmdGVyRmFpbChjYXVzZSwgYXBuQ29udGV4dCwgcmV0cnlPdmVycmlkZSk7CiAgICAgfQogCiAgICAgcHJpdmF0ZSB2b2lkIHNldFByZWZlcnJlZEFwbihpbnQgcG9zKSB7Ci0gICAgICAgIGlmICghY2FuU2V0UHJlZmVyQXBuKSB7CisgICAgICAgIGlmICghbUNhblNldFByZWZlckFwbikgewogICAgICAgICAgICAgbG9nKCJzZXRQcmVmZXJyZWRBcG46IFggIWNhblNFdFByZWZlckFwbiIpOwogICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICB9CkBAIC0yMjM4LDE2ICsyMjE3LDE5IEBACiAgICAgICAgICAgICAgICAgbnVsbCwgbnVsbCwgVGVsZXBob255LkNhcnJpZXJzLkRFRkFVTFRfU09SVF9PUkRFUik7CiAKICAgICAgICAgaWYgKGN1cnNvciAhPSBudWxsKSB7Ci0gICAgICAgICAgICBjYW5TZXRQcmVmZXJBcG4gPSB0cnVlOworICAgICAgICAgICAgbUNhblNldFByZWZlckFwbiA9IHRydWU7CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICBjYW5TZXRQcmVmZXJBcG4gPSBmYWxzZTsKKyAgICAgICAgICAgIG1DYW5TZXRQcmVmZXJBcG4gPSBmYWxzZTsKICAgICAgICAgfQorICAgICAgICBsb2coImdldFByZWZlcnJlZEFwbjogbVJlcXVlc3RlZEFwblR5cGU9IiArIG1SZXF1ZXN0ZWRBcG5UeXBlICsgIiBjdXJzb3I9IiArIGN1cnNvcgorICAgICAgICAgICAgICAgICsgIiBjdXJzb3IuY291bnQ9IiArICgoY3Vyc29yICE9IG51bGwpID8gY3Vyc29yLmdldENvdW50KCkgOiAwKSk7CiAKLSAgICAgICAgaWYgKGNhblNldFByZWZlckFwbiAmJiBjdXJzb3IuZ2V0Q291bnQoKSA+IDApIHsKKyAgICAgICAgaWYgKG1DYW5TZXRQcmVmZXJBcG4gJiYgY3Vyc29yLmdldENvdW50KCkgPiAwKSB7CiAgICAgICAgICAgICBpbnQgcG9zOwogICAgICAgICAgICAgY3Vyc29yLm1vdmVUb0ZpcnN0KCk7CiAgICAgICAgICAgICBwb3MgPSBjdXJzb3IuZ2V0SW50KGN1cnNvci5nZXRDb2x1bW5JbmRleE9yVGhyb3coVGVsZXBob255LkNhcnJpZXJzLl9JRCkpOwogICAgICAgICAgICAgZm9yKEFwblNldHRpbmcgcDptQWxsQXBucykgeworICAgICAgICAgICAgICAgIGxvZygiZ2V0UHJlZmVycmVkQXBuOiBhcG5TZXR0aW5nPSIgKyBwKTsKICAgICAgICAgICAgICAgICBpZiAocC5pZCA9PSBwb3MgJiYgcC5jYW5IYW5kbGVUeXBlKG1SZXF1ZXN0ZWRBcG5UeXBlKSkgewogICAgICAgICAgICAgICAgICAgICBsb2coImdldFByZWZlcnJlZEFwbjogWCBmb3VuZCBhcG5TZXR0aW5nIiArIHApOwogICAgICAgICAgICAgICAgICAgICBjdXJzb3IuY2xvc2UoKTsKQEAgLTI0MjMsMTAgKzI0MDUsMTAgQEAKIAogICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIGR1bXAoRmlsZURlc2NyaXB0b3IgZmQsIFByaW50V3JpdGVyIHB3LCBTdHJpbmdbXSBhcmdzKSB7Ci0gICAgICAgIHB3LnByaW50bG4oIkdzbURhdGFDb25uZWN0aW9uVHJhY2tlciBleHRlbmRzOiIpOworICAgICAgICBwdy5wcmludGxuKCJEYXRhQ29ubmVjdGlvblRyYWNrZXIgZXh0ZW5kczoiKTsKICAgICAgICAgc3VwZXIuZHVtcChmZCwgcHcsIGFyZ3MpOwogICAgICAgICBwdy5wcmludGxuKCIgbVJlcmVnaXN0ZXJPblJlY29ubmVjdEZhaWx1cmU9IiArIG1SZXJlZ2lzdGVyT25SZWNvbm5lY3RGYWlsdXJlKTsKLSAgICAgICAgcHcucHJpbnRsbigiIGNhblNldFByZWZlckFwbj0iICsgY2FuU2V0UHJlZmVyQXBuKTsKKyAgICAgICAgcHcucHJpbnRsbigiIGNhblNldFByZWZlckFwbj0iICsgbUNhblNldFByZWZlckFwbik7CiAgICAgICAgIHB3LnByaW50bG4oIiBtQXBuT2JzZXJ2ZXI9IiArIG1BcG5PYnNlcnZlcik7CiAgICAgICAgIHB3LnByaW50bG4oIiBnZXRPdmVyYWxsU3RhdGU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JrSW5mbyBuZXR3b3JrSW5mbyA9IChOZXR3b3JrSW5mbykKICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudC5nZXRQYXJjZWxhYmxlRXh0cmEoV2lmaU1hbmFnZXIuRVhUUkFfTkVUV09SS19JTkZPKTsKICAgICAgICAgICAgICAgICBtSXNXaWZpQ29ubmVjdGVkID0gKG5ldHdvcmtJbmZvICE9IG51bGwgJiYgbmV0d29ya0luZm8uaXNDb25uZWN0ZWQoKSk7CisgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJORVRXT1JLX1NUQVRFX0NIQU5HRURfQUNUSU9OOiBtSXNXaWZpQ29ubmVjdGVkPSIgKyBtSXNXaWZpQ29ubmVjdGVkKTsKICAgICAgICAgICAgIH0gZWxzZSBpZiAoYWN0aW9uLmVxdWFscyhXaWZpTWFuYWdlci5XSUZJX1NUQVRFX0NIQU5HRURfQUNUSU9OKSkgewogICAgICAgICAgICAgICAgIGZpbmFsIGJvb2xlYW4gZW5hYmxlZCA9IGludGVudC5nZXRJbnRFeHRyYShXaWZpTWFuYWdlci5FWFRSQV9XSUZJX1NUQVRFLAogICAgICAgICAgICAgICAgICAgICAgICAgV2lmaU1hbmFnZXIuV0lGSV9TVEFURV9VTktOT1dOKSA9PSBXaWZpTWFuYWdlci5XSUZJX1NUQVRFX0VOQUJMRUQ7CkBAIC0yODcsMTMgKzI3OCw4IEBACiAgICAgICAgICAgICAgICAgICAgIC8vIHF1aXQgYW5kIHdvbid0IHJlcG9ydCBkaXNjb25uZWN0ZWQgdW50aWwgbmV4dCBlbmFibGluZy4KICAgICAgICAgICAgICAgICAgICAgbUlzV2lmaUNvbm5lY3RlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIH0gZWxzZSBpZiAoYWN0aW9uLmVxdWFscyhJTlRFTlRfU0VUX0ZBSUxfREFUQV9TRVRVUF9DT1VOVEVSKSkgewotICAgICAgICAgICAgICAgIG1GYWlsRGF0YVNldHVwQ291bnRlciA9IGludGVudC5nZXRJbnRFeHRyYShGQUlMX0RBVEFfU0VUVVBfQ09VTlRFUiwgMSk7Ci0gICAgICAgICAgICAgICAgbUZhaWxEYXRhU2V0dXBGYWlsQ2F1c2UgPSBGYWlsQ2F1c2UuZnJvbUludCgKLSAgICAgICAgICAgICAgICAgICAgICAgIGludGVudC5nZXRJbnRFeHRyYShGQUlMX0RBVEFfU0VUVVBfRkFJTF9DQVVTRSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBGYWlsQ2F1c2UuRVJST1JfVU5TUEVDSUZJRUQuZ2V0RXJyb3JDb2RlKCkpKTsKLSAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coInNldCBtRmFpbERhdGFTZXR1cENvdW50ZXI9IiArIG1GYWlsRGF0YVNldHVwQ291bnRlciArCi0gICAgICAgICAgICAgICAgICAgICAgICAiIG1GYWlsRGF0YVNldHVwRmFpbENhdXNlPSIgKyBtRmFpbERhdGFTZXR1cEZhaWxDYXVzZSk7CisgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJXSUZJX1NUQVRFX0NIQU5HRURfQUNUSU9OOiBlbmFibGVkPSIgKyBlbmFibGVkCisgICAgICAgICAgICAgICAgICAgICAgICArICIgbUlzV2lmaUNvbm5lY3RlZD0iICsgbUlzV2lmaUNvbm5lY3RlZCk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICB9OwpAQCAtMzcyLDM1ICszNTgsMTcgQEAKICAgICAgICAgICAgIHJ4UGt0cyA9IC0xOwogICAgICAgICB9CiAKKyAgICAgICAgQE92ZXJyaWRlCiAgICAgICAgIHB1YmxpYyBTdHJpbmcgdG9TdHJpbmcoKSB7CiAgICAgICAgICAgICByZXR1cm4gInt0eFN1bT0iICsgdHhQa3RzICsgIiByeFN1bT0iICsgcnhQa3RzICsgIn0iOwogICAgICAgICB9CiAKICAgICAgICAgcHVibGljIHZvaWQgdXBkYXRlVHhS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gaWYgKGRhdGFFbmFibGVkW2lkXSkgeworICAgICAgICAgICAgaWYgKG1EYXRhRW5hYmxlZFtpZF0pIHsKICAgICAgICAgICAgICAgICBtUGhvbmUubm90aWZ5RGF0YUNvbm5lY3Rpb24ocmVhc29uLCBhcG5JZFRvVHlwZShpZCkpOwogICAgICAgICAgICAgfQogICAgICAgICB9CkBAIC04MjEsNyArNzg4LDYgQEAKICAgICBwcml2YXRlIHZvaWQgbm90aWZ5QXBuSWRVcFRvQ3VycmVudChTdHJpbmcgcmVhc29uLCBpbnQgYXBuSWQpIHsKICAgICAgICAgc3dpdGNoIChtU3RhdGUpIHsKICAgICAgICAgICAgIGNhc2UgSURMRToKLSAgICAgICAgICAgIGNhc2UgSU5JVElORzoKICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIGNhc2UgQ09OTkVDVElORzoKICAgICAgICAgICAgIGNhc2UgU0NBTk5JTkc6CkBAIC04MzUsNiArODAxLDkgQEAKICAgICAgICAgICAgICAgICBtUGhvbmUubm90aWZ5RGF0YUNvbm5lY3Rpb24ocmVhc29uLCBhcG5JZFRvVHlwZShhcG5JZCksCiAgICAgICAgICAgICAgICAgICAgICAgICBQaG9uZUNvbnN0YW50cy5EYXRhU3RhdGUuQ09OTkVDVEVEKTsKICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgLy8gSW5nb3JlCisgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIH0KICAgICB9CiAKQEAgLTg2NCw3ICs4MzMsNyBAQAogCiAgICAgcHJvdGVjdGVkIHN5bmNocm9uaXplZCBib29sZWFuIGlzQXBuSWRFbmFibGVkKGludCBpZCkgewogICAgICAgICBpZiAoaWQgIT0gRGN0Q29uc3RhbnRzLkFQTl9JTlZBTElEX0lEKSB7Ci0gICAgICAgICAgICByZXR1cm4gZGF0YUVuYWJsZWRbaWRdOworICAgICAgICAgICAgcmV0dXJuIG1EYX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lYW4gZW5hYmxlKSB7CiAgICAgICAgIGlmIChEQkcpIHsKLSAgICAgICAgICAgIGxvZygic2V0RW5hYmxlZCgiICsgaWQgKyAiLCAiICsgZW5hYmxlICsgIikgd2l0aCBvbGQgc3RhdGUgPSAiICsgZGF0YUVuYWJsZWRbaWRdCi0gICAgICAgICAgICAgICAgICAgICsgIiBhbmQgZW5hYmxlZENvdW50ID0gIiArIGVuYWJsZWRDb3VudCk7CisgICAgICAgICAgICBsb2coInNldEVuYWJsZWQoIiArIGlkICsgIiwgIiArIGVuYWJsZSArICIpIHdpdGggb2xkIHN0YXRlID0gIiArIG1EYXRhRW5hYmxlZFtpZF0KKyAgICAgICAgICAgICAgICAgICAgKyAiIGFuZCBlbmFibGVkQ291bnQgPSAiICsgbUVuYWJsZWRDb3VudCk7CiAgICAgICAgIH0KICAgICAgICAgTWVzc2FnZSBtc2cgPSBvYnRhaW5NZXNzYWdlKERjdENvbnN0YW50cy5FVkVOVF9FTkFCTEVfTkVXX0FQTik7CiAgICAgICAgIG1zZy5hcmcxID0gaWQ7CkBAIC05NTMsMTUgKzkyMiwxNSBAQAogICAgIHByb3RlY3RlZCB2b2lkIG9uRW5hYmxlQXBuKGludCBhcG5JZCwgaW50IGVuYWJsZWQpIHsKICAgICAgICAgaWYgKERCRykgewogICAgICAgICAgICAgbG9nKCJFVkVOVF9BUE5fRU5BQkxFX1JFUVVFU1QgYXBuSWQ9IiArIGFwbklkICsgIiwgYXBuVHlwZT0iICsgYXBuSWRUb1R5cGUoYXBuSWQpICsKLSAgICAgICAgICAgICAgICAgICAgIiwgZW5hYmxlZD0iICsgZW5hYmxlZCArICIsIGRhdGFFbmFibGVkID0gIiArIGRhdGFFbmFibGVkW2FwbklkXSArCi0gICAgICAgICAgICAgICAgICAgICIsIGVuYWJsZWRDb3VudCA9ICIgKyBlbmFibGVkQ291bnQgKyAiLCBpc0FwblR5cGVBY3RpdmUgPSAiICsKKyAgICAgICAgICAgICAgICAgICAgIiwgZW5hYmxlZD0iICsgZW5hYmxlZCArICIsIGRhdGFFbmFibGVkID0gIiArIG1EYXRhRW5hYmxlZFthcG5JZF0gKworICAgICAgICAgICAgICAgICAgICAiLCBlbmFibGVkQ291bnQgPSAiICsgbUVuYWJsZWRDb3VudCArICIsIGlzQXBuVHlwZUFjdGl2ZSA9ICIgKwogICAgICAgICAgICAgICAgICAgICBpc0FwblR5cGVBY3RpdmUoYXBuSWRUb1R5cGUoYXBuSWQpKSk7CiAgICAgICAgIH0KICAgICAgICAgaWYgKGVuYWJsZWQgPT0gRGN0Q29uc3RhbnRzLkVOQUJMRUQpIHsKICAgICAgICAgICAgIHN5bmNocm9uaXplZCAodGhpcykgewotICAgICAgICAgICAgICAgIGlmICghZGF0YUVuYWJsZWRbYXBuSWRdKSB7Ci0gICAgICAgICAgICAgICAgICAgIGRhdGFFbmFibGVkW2FwbklkXSA9IHRydWU7Ci0gICAgICAgICAgICAgICAgICAgIGVuYWJsZWRDb3VudCsrOworICAgICAgICAgICAgICAgIGlmICghbURhdGFFbmFibGVkW2FwbklkXSkgeworICAgICAgICAgICAgICAgICAgICBtRGF0YUVuYWJsZWRbYXBuSWRdID0gdHJ1ZTsKKyAgICAgICAgICAgICAgICAgICAgbUVuYWJsZWRDb3VudCsrOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KICAgICAgICAgICAgIFN0cmluZyB0eXBlID0gYXBuSWRUb1R5cGUoYXBuSWQpOwpAQCAtOTc1LDE0ICs5NDQsMTQgQEAKICAgICAgICAgICAgIC8vIGRpc2FibGUKICAgICAgICAgICAgIGJvb2xlYW4gZGlkRGlzYWJsZSA9IGZhbHNlOwogICAgICAgICAgICAgc3luY2hyb25pemVkICh0aGlzKSB7Ci0gICAgICAgICAgICAgICAgaWYgKGRhdGFFbmFibGVkW2FwbklkXSkgewotICAgICAgICAgICAgICAgICAgICBkYXRhRW5hYmxlZFthcG5JZF0gPSBmYWxzZTsKLSAgICAgICAgICAgICAgICAgICAgZW5hYmxlZENvdW50LS07CisgICAgICAgICAgICAgICAgaWYgKG1EYXRhRW5hYmxlZFthcG5JZF0pIHsKKyAgICAgICAgICAgICAgICAgICAgbURhdGFFbmFibGVkW2FwbklkXSA9IGZhbHNlOworICAgICAgICAgICAgICAgICAgICBtRW5hYmxlZENvdW50LS07CiAgICAgICAgICAgICAgICAgICAgIGRpZERpc2FibGUgPSB0cnVlOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KICAgICAgICAgICAgIGlmIChkaWREaXNhYmxlKSB7Ci0gICAgICAgICAgICAgICAgaWYgKChlbmFibGVkQ291bnQgPT0gMCkgfHwgKGFwbklkID09IERjdENvbnN0YW50cy5BUE5fRFVOX0lEKSkgeworICAgICAgICAgICAgICAgIGlmICgobUVuYWJsZWRDb3VudCA9PSAwKSB8fCAoYXBuSWQgPT0gRGN0Q29uc3RhbnRzLkFQTl9EVU5fSUQpKSB7CiAgICAgICAgICAgICAgICAgICAgIG1SZXF1ZXN0ZWRBcG5UeXBlID0gUGhvbmVDb25zdGFudHMuQVBOX1RZUEVfREVGQVVMVDsKICAgICAgICAgICAgICAgICAgICAgb25DbGVhblVwQ29ubmVjdGlvbih0cnVlLCBhcG5JZCwgUGhvbmUuUkVBU09OX0RBVEFfRElTQUJMRUQpOwogICAgICAgICAgICAgICAgIH0KQEAgLTk5MCw3ICs5NTksNyBAQAogICAgICAgICAgICAgICAgIC8vIHNlbmQgdGhlIGRpc2Nvbm5lY3QgbXNnIG1hbnVhbGx5LCBzaW5jZSB0aGUgbm9ybWFsIHJvdXRlIHdvbnQgc2VuZAogICAgICAgICAgICAgICAgIC8vIGl0IChpdCdzIG5vdCBlbmFibGVkKQogICAgICAgICAgICAgICAgIG5vdGlmeUFwbklkRGlzY29ubmVjdGVkKFBob25lLlJFQVNPTl9EQVRBX0RJU0FCTEVELCBhcG5JZCk7Ci0gICAgICAgICAgICAgICAgaWYgKGRhdGFFbmFibGVkW0RjdENvbnN0YW50cy5BUE5fREVGQVVMVF9JRF0gPT0gdHJ1ZQorICAgICAgICAgICAgICAgIGlmIChtRGF0YUVuYWJsZWRbRGN0Q29uc3RhbnRzLkFQTl9ERUZBVUxUX0lEXSA9PSB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAmJiAhaXNBcG5UeXBlQWN0aXZlKFBob25lQ29uc3RhbnRzLkFQTl9UWVBFX0RFRkFVTFQpKSB7CiAgICAgICAgICAgICAgICAgICAgIC8vIFRPRE8gLSB0aGlzIGlzIGFuIHVnbHkgd2F5IHRvIHJlc3RvcmUgdGhlIGRlZmF1bHQgY29ubiAtIHNob3VsZCBiZSBkb25lCiAgICAgICAgICAgICAgICAgICAgIC8vIGJ5IGEgcmVhbCBjb250ZW50aW9uIG1hbmFnZXIgYW5kIHBvbGljeSB0aGF0IGRpc2Nvbm5lY3RzIHRoZSBsb3dlciBwcmkKQEAgLTExNDEsNyArMTExMCw3IEBACiAgICAgICAgIGZvciAoQXBuQ29udGV4dCBhYyA6IG1BcG5Db250ZXh0cy52YWx1ZXMoKSkgewogICAgICAgICAgICAgYWMuc2V0UmV0cnlDb3VudCgwKTsKICAgICAgICAgfQotICAgICAgICBmb3IgKERhdGFDb25uZWN0aW9uIGRjIDogbURhdGFDb25uZWN0aW9ucy52YWx1ZXMoKSkgeworICAgICAgICBmb3IgKERhdGFDb25uZWN0aW9uQmFzZSBkYyA6IG1EYXRhQ29ubmVjdGlvbnMudmFsdWVzKCkpIHsKICAgICAgICAgICAgIGRjLnJlc2V0UmV0cnlDb3VudCgpOwogICAgICAgICB9CiAgICAgfQpAQCAtMTI1MSw3ICsxMjIwLDcgQEAKICAgICAgICAgICAgICAgICBFdmVudExvZy53cml0ZUV2ZW50KEV2ZW50TG9nVGFncy5EQVRBX1NUQUxMX1JFQ09WRVJZX0dFVF9EQVRBX0NBTExfTElTVCwKICAgICAgICAgICAgICAgICAgICAgICAgIG1TZW50U2luY2VMYXN0UmVjdik7CiAgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nK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IHsKICAgICAgICAgICAgICAgICAvL2RlYnVnU29ja2V0ID0gbmV3IExvY2FsU2VydmVyU29ja2V0KCJjb20uYW5kcm9pZC5pbnRlcm5hbC50ZWxlcGhvbnkuZGVidWciKTsKLSAgICAgICAgICAgICAgICBkZWJ1Z1NvY2tldCA9IG5ldyBTZXJ2ZXJTb2NrZXQoKTsKLSAgICAgICAgICAgICAgICBkZWJ1Z1NvY2tldC5zZXRSZXVzZUFkZHJlc3ModHJ1ZSk7Ci0gICAgICAgICAgICAgICAgZGVidWdTb2NrZXQuYmluZCAobmV3IEluZXRTb2NrZXRBZGRyZXNzKCIxMjcuMC4wLjEiLCA2NjY2KSk7CisgICAgICAgICAgICAgICAgbURlYnVnU29ja2V0ID0gbmV3IFNlcnZlclNvY2tldCgpOworICAgICAgICAgICAgICAgIG1EZWJ1Z1NvY2tldC5zZXRSZXVzZUFkZHJlc3ModHJ1ZSk7CisgICAgICAgICAgICAgICAgbURlYnVnU29ja2V0LmJpbmQgKG5ldyBJbmV0U29ja2V0QWRkcmVzcygiMTI3LjAuMC4xIiwgNjY2NikpOwogCi0gICAgICAgICAgICAgICAgZGVidWdQb3J0VGhyZWFkCisgICAgICAgICAgICAgICAgbURlYnVnUG9ydFRocmVhZAogICAgICAgICAgICAgICAgICAgICA9IG5ldyBUaHJlYWQoCiAgICAgICAgICAgICAgICAgICAgICAgICBuZXcgUnVubmFibGUoKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgQE92ZXJyaWRlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHVibGljIHZvaWQgcnVuKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IoOzspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU29ja2V0IHNvY2s7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc29jayA9IGRlYnVnU29ja2V0LmFjY2VwdCgpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvY2sgPSBtRGVidWdTb2NrZXQuYWNjZXB0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUmxvZy5pKExPR19UQUcsICJOZXcgY29ubmVjdGlvbjsgcmVzZXR0aW5nIHJhZGlvIik7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUNNLnJlc2V0UmFkaW8obnVsbCk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUNpLnJlc2V0UmFkaW8obnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc29jay5jbG9zZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoSU9FeGNlcHRpb24gZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBSbG9nLncoTE9HX1RBRywKQEAgLTE4OCw3ICsxODUsNyBAQAogICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICJHU01QaG9uZSBkZWJ1ZyIpOwogCi0gICAgICAgICAgICAgICAgZGVidWdQb3J0VGhyZWFkLnN0YXJ0KCk7CisgICAgICAgICAgICAgICAgbURlYnVnUG9ydFRocmVhZC5zdGFydCgpOwogCiAgICAgICAgICAgICB9IGNhdGNoIChJT0V4Y2VwdGlvbiBleCkgewogICAgICAgICAgICAgICAgIFJsb2cudyhMT0dfVEFHLCAiRmFpbHVyZSB0byBvcGVuIGNvbS5hbmRyb2lkLmludGVybmFsLnRlbGVwaG9ueS5kZWJ1ZyBzb2NrZXQiLCBleCk7CkBAIC0yMDYsMTMgKzIwMywxMyBAQAogICAgICAgICAgICAgc3VwZXIuZGlzcG9zZSgpOwogCiAgICAgICAgICAgICAvL1VucmVnaXN0ZXIgZnJvbSBhb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ICBzdXBlci5yZW1vdmVSZWZlcmVuY2VzKCk7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHJvdGVjdGVkIHZvaWQgZmluYWxpemUoKSB7CiAgICAgICAgIGlmKExPQ0FMX0RFQlVHKSBSbG9nLmQoTE9HX1RBRywgIkdTTVBob25lIGZpbmFsaXplZCIpOwogICAgIH0KIAogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFNlcnZpY2VTdGF0ZQogICAgIGdldFNlcnZpY2VTdGF0ZSgpIHsKLSAgICAgICAgcmV0dXJuIG1TU1Quc3M7CisgICAgICAgIHJldHVybiBtU1NULm1TUzsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgQ2VsbExvY2F0aW9uIGdldENlbGxMb2NhdGlvbigpIHsKLSAgICAgICAgcmV0dXJuIG1TU1QuY2VsbExvYzsKKyAgICAgICAgcmV0dXJuIG1TU1QubUNlbGxMb2M7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFBob25lQ29uc3RhbnRzLlN0YXRlIGdldFN0YXRlKCkgewotICAgICAgICByZXR1cm4gbUNULnN0YXRlOworICAgICAgICByZXR1cm4gbUNULm1TdGF0ZTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgU3RyaW5nIGdldFBob25lTmFtZSgpIHsKICAgICAgICAgcmV0dXJuICJHU00iOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBpbnQgZ2V0UGhvbmVUeXBlKCkgewogICAgICAgICByZXR1cm4gUGhvbmVDb25zdGFudHMuUEhPTkVfVFlQRV9HU007CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFNlcnZpY2VTdGF0ZVRyYWNrZXIgZ2V0U2VydmljZVN0YXRlVHJhY2tlcigpIHsKICAgICAgICAgcmV0dXJuIG1TU1Q7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICA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AgICAgICAgICAgICAgICBpZiAoIG1DVC5zdGF0ZSAhPSBQaG9uZUNvbnN0YW50cy5TdGF0ZS5JRExFCisgICAgICAgICAgICAgICAgICAgIGlmICggbUNULm1TdGF0ZSAhPSBQaG9uZUNvbnN0YW50cy5TdGF0ZS5JRExFCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJiYgIW1TU1QuaXNDb25jdXJyZW50Vm9pY2VBbmREYXRhQWxsb3dlZCgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICByZXQgPSBQaG9uZUNvbnN0YW50cy5EYXRhU3RhdGUuU1VTUEVOREVEOwogICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewpAQCAtMzEzLDcgKzMyMCw2IEBACiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBicmVhazsKIAotICAgICAgICAgICAgICAgIGNhc2UgSU5JVElORzoKICAgICAgICAgICAgICAgICBjYXNlIENPTk5FQ1RJTkc6CiAgICAgICAgICAgICAgICAgY2FzZSBTQ0FOTklORzoKICAgICAgICAgICAgICAgICAgICAgcmV0ID0gUGhvbmVDb25zdGFudHMuRGF0YVN0YXRlLkNPTk5FQ1RJTkc7CkBAIC0zMjQsMTAgKzMzMCwxMSBAQAogICAgICAgICByZXR1cm4gcmV0OwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBEYXRhQWN0aXZpdHlTdGF0ZSBnZXREYXRhQWN0aXZpdHlTdGF0ZSgpIHsKICAgICAgICAgRGF0YUFjdGl2aXR5U3RhdGUgcmV0ID0gRGF0YUFjdGl2aXR5U3RhdGUuTk9ORTsKIAotICAgICAgICBpZiAobVNTVC5nZXRDdXJyZW50R3Byc1N0YXRlKCkgPT0gU2VydmljZVN0YXRlLlNUQVRFX0lOX1NFUlZJQ0UpIHsKKyAgICAgICAgaWYgKG1TU1QuZ2V0Q3VycmVudERhdGFDb25uZWN0aW9uU3RhdGUoKSA9PSBTZXJ2aWNlU3RhdGUuU1RBVEVfSU5fU0VSVklDRSkgewogICAgICAgICAgICAgc3dpdGNoIChtRGF0YUNvbm5lY3Rpb25UcmFja2VyLmdldEFjdGl2aXR5KCkpIHsKICAgICAgICAgICAgICAgICBjYXNlIERBVEFJTjoKICAgICAgICAgICAgICAgICAgICAgcmV0ID0gRGF0YUFjdGl2aXR5U3RhdGUuREFUQUlOOwpAQCAtMzQ0LDYgKzM1MSwxMCBAQAogICAgICAgICAgICAgICAgIGNhc2UgRE9STUFOVDoKICAgICAgICAgICAgICAgICAgICAgcmV0ID0gRGF0YUFjdGl2aXR5U3RhdGUuRE9STUFOVDsKICAgICAgICAgICAgICAgICBicmVhazsKKworICAgICAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgICAgIHJldCA9IERhdGFBY3Rpdml0eVN0YXRlLk5PTkU7CisgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KIApAQCAtMzUxLDE1ICszNjIsMTcgQEAKICAgICB9CiAKICAgICAvKioKLSAgICAgKiBOb3RpZnkgYW55IGludGVyZXN0ZWQgcGFydHkgb2YgYSBQaG9uZSBzdGF0ZSBjaGFuZ2Uge0BsaW5rIFBob25lQ29uc3RhbnRzLlN0YXRlfQorICAgICAqIE5vdGlmeSBhbnkgaW50ZXJlc3RlZCBwYXJ0eSBvZiBhIFBob25lIHN0YXRlIGNoYW5nZQorICAgICAqIHtAbGluayBjb20uYW5kcm9pZC5pbnRlcm5hbC50ZWxlcGhvbnkuUGhvbmVDb25zdGFudHMuU3RhdGV9CiAgICAgICovCiAgICAgLypwYWNrYWdlKi8gdm9pZCBub3RpZnlQaG9uZVN0YXRlQ2hhbmdlZCgpIHsKICAgICAgICAgbU5vdGlmaWVyLm5vdGlmeVBob25lU3RhdGUodGhpcyk7CiAgICAgfQogCiAgICAgLyoqCi0gICAgICogTm90aWZ5IHJlZ2lzdHJhbnRzIG9mIGEgY2hhbmdlIGluIHRoZSBjYWxsIHN0Y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aWMgdm9pZCBleHBsaWNpdENhbGxUcmFuc2ZlcigpIHRocm93cyBDYWxsU3RhdGVFeGNlcHRpb24geworICAgIEBPdmVycmlkZQorICAgIHB1YmxpYyB2b2lkIGV4cGxpY2l0Q2FsbFRyYW5zZmVyKCkgewogICAgICAgICBtQ1QuZXhwbGljaXRDYWxsVHJhbnNmZXIoKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgR3NtQ2FsbAogICAgIGdldEZvcmVncm91bmRDYWxsKCkgewotICAgICAgICByZXR1cm4gbUNULmZvcmVncm91bmRDYWxsOworICAgICAgICByZXR1cm4gbUNULm1Gb3JlZ3JvdW5kQ2FsbDsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgR3NtQ2FsbAogICAgIGdldEJhY2tncm91bmRDYWxsKCkgewotICAgICAgICByZXR1cm4gbUNULmJhY2tncm91bmRDYWxsOworICAgICAgICByZXR1cm4gbUNULm1CYWNrZ3JvdW5kQ2FsbDsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgR3NtQ2FsbAogICAgIGdldFJpbmdpbmdDYWxsKCkgewotICAgICAgICByZXR1cm4gbUNULnJpbmdpbmdDYWxsOworICAgICAgICByZXR1cm4gbUNULm1SaW5naW5nQ2FsbDsKICAgICB9CiAKICAgICBwcml2YXRlIGJvb2xlYW4gaGFuZGxlQ2FsbERlZmxlY3Rpb25JbmNhbGxTdXBwbGVtZW50YXJ5U2VydmljZSgKLSAgICAgICAgICAgIFN0cmluZyBkaWFsU3RyaW5nKSB0aHJvd3MgQ2FsbFN0YXRlRXhjZXB0aW9uIHsKKyAgICAgICAgICAgIFN0cmluZyBkaWFsU3RyaW5nKSB7CiAgICAgICAgIGlmIChkaWFsU3RyaW5nLmxlbmd0aCgpID4gMSkgewogICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICB9CkBAIC00OTksMTQgKzUyNywxNCBAQAogICAg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AgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZAogICAgIHNlbmREdG1mKGNoYXIgYykgewogICAgICAgICBpZiAoIVBob25lTnVtYmVyVXRpbHMuaXMxMktleShjKSkgewogICAgICAgICAgICAgUmxvZy5lKExPR19UQUcsCiAgICAgICAgICAgICAgICAgICAgICJzZW5kRHRtZiBjYWxsZWQgd2l0aCBpbnZhbGlkIGNoYXJhY3RlciAnIiArIGMgKyAiJyIpOwogICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgaWYgKG1DVC5zdGF0ZSA9PSAgUGhvbmVDb25zdGFudHMuU3RhdGUuT0ZGSE9PSykgewotICAgICAgICAgICAgICAgIG1DTS5zZW5kRHRtZihjLCBudWxsKTsKKyAgICAgICAgICAgIGlmIChtQ1QubVN0YXRlID09ICBQaG9uZUNvbnN0YW50cy5TdGF0ZS5PRkZIT09LKSB7CisgICAgICAgICAgICAgICAgbUNpLnNlbmREdG1mKGMsIG51bGwpOwogICAgICAgICAgICAgfQogICAgICAgICB9CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQKICAgICBzdGFydER0bWYoY2hhciBjKSB7CiAgICAgICAgIGlmICghUGhvbmVOdW1iZXJVdGlscy5pczEyS2V5KGMpKSB7CiAgICAgICAgICAgICBSbG9nLmUoTE9HX1RBRywKICAgICAgICAgICAgICAgICAic3RhcnREdG1mIGNhbGxlZCB3aXRoIGludmFsaWQgY2hhcmFjdGVyICciICsgYyArICInIik7CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICBtQ00uc3RhcnREdG1mKGMsIG51bGwpOworICAgICAgICAgICAgbUNpLnN0YXJ0RHRtZihjLCBudWxsKTsKICAgICAgICAgfQogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkCiAgICAgc3RvcER0bWYoKSB7Ci0gICAgICAgIG1DTS5zdG9wRHRtZihudWxsKTsKKyAgICAgICAgbUN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ibGljIFN0cmluZyBnZXREZXZpY2VTdm4oKSB7CiAgICAgICAgIHJldHVybiBtSW1laVN2OwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdHJpbmcgZ2V0SW1laSgpIHsKICAgICAgICAgcmV0dXJuIG1JbWVpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdHJpbmcgZ2V0RXNuKCkgewogICAgICAgICBSbG9nLmUoTE9HX1RBRywgIltHU01QaG9uZV0gZ2V0RXNuKCkgaXMgYSBDRE1BIG1ldGhvZCIpOwogICAgICAgICByZXR1cm4gIjAiOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdHJpbmcgZ2V0TWVpZCgpIHsKICAgICAgICAgUmxvZy5lKExPR19UQUcsICJbR1NNUGhvbmVdIGdldE1laWQoKSBpcyBhIENETUEgbWV0aG9kIik7CiAgICAgICAgIHJldHVybiAiMCI7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFN0cmluZyBnZXRTdWJzY3JpYmVySWQoKSB7CiAgICAgICAgIEljY1JlY29yZHMgciA9IG1JY2NSZWNvcmRzLmdldCgpOwogICAgICAgICByZXR1cm4gKHIgIT0gbnVsbCkgPyByLmdldElNU0koKSA6IG51bGw7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFN0cmluZyBnZXRMaW5lMU51bWJlcigpIHsKICAgICAgICAgSWNjUmVjb3JkcyByID0gbUljY1JlY29yZHMuZ2V0KCk7CiAgICAgICAgIHJldHVybiAociAhPSBudWxsKSA/IHIuZ2V0TXNpc2RuTnVtYmVyKCkgOiBudWxsOwpAQCAtODY3LDExICs4OTcsMTMgQEAKICAgICAgICAgcmV0dXJuIChyICE9IG51bGwpID8gci5nZXRNc2lzZG5OdW1iZXIoKSA6ICIiOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdHJpbmcgZ2V0TGluZTFBbHBoYVRhZygpIHsKICAgICAgICAgSWNjUmVjb3JkcyByID0gbUljY1JlY29yZHMuZ2V0KCk7CiAgICAgICAgIHJldHVybiAociAhPSBudWxsKSA/IHIuZ2V0TXNpc2RuQWxwaGFUYWcoKSA6ICIiOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHNldExpbmUxTnVtYmVyKFN0cmluZyBhbHBoYVRhZywgU3RyaW5nIG51bWJlciwgTWVzc2FnZSBvbkNvbXBsZXRlKSB7CiAgICAgICAgIEljY1JlY29yZHMgciA9IG1JY2NSZWNvcmRzLmdldCgpOwogICAgICAgICBpZiAociAhPSBudWxsKSB7CkBAIC04NzksNiArOTExLDcgQEAKICAgICAgICAgfQogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHNldFZvaWNlTWFpbE51bWJlcihTdHJpbmcgYWxwaGFUYWcsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nIHZvaWNlTWFpbE51bWJlciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNZXNzYWdlIG9uQ29tcGxldGUpIHsKQEAgLTkyMiw2ICs5NTUsNyBAQAogICAgICAgICByZXR1cm4gKGFjdGlvbiA9PSBDRl9BQ1RJT05fRU5BQkxFKSB8fCAoYWN0aW9uID09IENGX0FDVElPTl9SRUdJU1RSQVRJT04pOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIGdldENhbGxGb3J3YXJkaW5nT3B0aW9uKGludCBjb21tYW5kSW50ZXJmYWNlQ0ZSZWFzb24sIE1lc3NhZ2Ugb25Db21wbGV0ZSkgewogICAgICAgICBpZiAoaXNWYWxpZENvbW1hbmRJbnRlcmZhY2VDRlJlYXNvbihjb21tYW5kSW50ZXJmYWNlQ0ZSZWFzb24pKSB7CiAgICAgICAgICAgICBpZiAoTE9DQUxfREVCVUcpIFJsb2cuZChMT0dfVEFHLCAicmVxdWVzdGluZyBjYWxsIGZvcndhcmRpbmcgcXVlcnkuIik7CkBAIC05MzEsMTAgKzk2NSwxMSBAQAogICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICByZXNwID0gb25Db21wbGV0ZTsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIG1DTS5xdWVyeUNhbGxGb3J3YXJkU3RhdHVzKGNvbW1hbmRJbnRlcmZhY2VDRlJlYXNvbiwwLG51bGwscmVzcCk7CisgICAgICAgICAgICBtQ2kucXVlcnlDYWxsRm9yd2FyZFN0YXR1cyhjb21tYW5kSW50ZXJmYWNlQ0ZSZWFzb24sMCxudWxsLHJlc3ApOwogICAgICAgICB9CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgc2V0Q2FsbEZvcndhcmRpbmdPcHRpb24oaW50IGNvbW1hbmRJbnRlcmZhY2VDRkFjdGlvbiwKICAgICAgICAgICAgIGludCBjb21tYW5kSW50ZXJmYWNlQ0ZSZWFzb24sCiAgICAgICAgICAgICBTdHJpbmcgZGlhbGluZ051bWJlciwKQEAgLTk1MCw3ICs5ODUsNyBAQAogICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICByZXNwID0gb25Db21wbGV0ZTsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIG1DTS5zZXRDYWxsRm9yd2FyZChjb21tYW5kSW50ZXJmYWNlQ0ZBY3Rpb24sCisgICAgICAgICAgICBtQ2kuc2V0Q2FsbEZvcndhcmQoY29tbWFuZEludGVyZmFjZUNGQWN0aW9uLAogICAgICAgICAgICAgICAgICAgICBjb21tYW5kSW50ZXJmYWNlQ0ZSZWFzb24sCiAgICAgICAgICAgICAgICAgICAgIENvbW1hbmRzSW50ZXJmYWNlLlNFUlZJQ0VfQ0xBU1NfVk9JQ0UsCiAgICAgICAgICAgICAgICAgICAgIGRpYWxpbmdOdW1iZXIsCkBAIC05NTksMjkgKzk5NCwzNCBAQAogICAg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JsaWMgdm9pZCBzZXRPblBvc3REaWFsQ2hhcmFjdGVyKEhhbmRsZXIgaCwgaW50IHdoYXQsIE9iamVjdCBvYmopIHsKICAgICAgICAgbVBvc3REaWFsSGFuZGxlciA9IG5ldyBSZWdpc3RyYW50KGgsIHdoYXQsIG9iaik7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgc2V0TXV0ZShib29sZWFuIG11dGVkKSB7CiAgICAgICAgIG1DVC5zZXRNdXRlKG11dGVkKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgYm9vbGVhbiBnZXRNdXRlKCkgewogICAgICAgICByZXR1cm4gbUNULmdldE11dGUoKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBnZXREYXRhQ2FsbExpc3QoTWVzc2FnZSByZXNwb25zZSkgewotICAgICAgICBtQ00uZ2V0RGF0YUNhbGxMaXN0KHJlc3BvbnNlKTsKKyAgICAgICAgbUNpLmdldERhdGFDYWxsTGlzdChyZXNwb25zZSk7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgdXBkYXRlU2VydmljZUxvY2F0aW9uKCkgewogICAgICAgICBtU1NULmVuYWJsZVNpbmdsZUxvY2F0aW9uVXBkYXRlKCk7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgZW5hYmxlTG9jYXRpb25VcGRhdGVzKCkgewogICAgICAgICBtU1NULmVuYWJsZUxvY2F0aW9uVXBkYXRlcygpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIGRpc2FibGVMb2NhdGlvblVwZGF0ZXMoKSB7CiAgICAgICAgIG1TU1QuZGlzYWJsZUxvY2F0aW9uVXBkYXRlcygpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBib29sZWFuIGdldERhdGFSb2FtaW5nRW5hYmxlZCgpIHsKICAgICAgICAgcmV0dXJuIG1EYXRhQ29ubmVjdGlvblRyYWNrZXIuZ2V0RGF0YU9uUm9hbWluZ0VuYWJsZWQoKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBzZXREYXRhUm9hbWluZ0VuYWJsZWQoYm9vbGVhbiBlbmFibGUpIHsKICAgICAgICAgbURhdGFDb25uZWN0aW9uVHJhY2tlci5zZXREYXRhT25Sb2FtaW5nRW5hYmxlZChlbmFibGUpOwogICAgIH0KQEAgLTExNTIsNyArMTIwNCw3IEBACiAgICAgICAgIFNoYXJlZFByZWZlcmVuY2VzIHNwID0gUHJlZmVyZW5jZU1hbmFnZXIuZ2V0RGVmYXVsdFNoYXJlZFByZWZlcmVuY2VzKGdldENvbnRleHQoKSk7CiAgICAgICAgIGludCBjbGlyU2V0dGluZyA9IHNwLmdldEludChDTElSX0tFWSwgLTEpOwogICAgICAgICBpZiAoY2xpclNldHRpbmcgPj0gMCkgewotICAgICAgICAgICAgbUNNLnNldENMSVIoY2xpclNldHRpbmcsIG51bGwpOworICAgICAgICAgICAgbUNpLnNldENMSVIoY2xpclNldHRpbmcsIG51bGwpOwogICAgICAgICB9CiAgICAgfQogCkBAIC0xMTYzLDExICsxMjE1LDExIEBACiAKICAgICAgICAgc3dpdGNoIChtc2cud2hhdCkgewogICAgICAgICAgICAgY2FzZSBFVkVOVF9SQURJT19BVkFJTEFCTEU6IHsKLSAgICAgICAgICAgICAgICBtQ00uZ2V0QmFzZWJhbmRWZXJzaW9uKAorICAgICAgICAgICAgICAgIG1DaS5nZXRCYXNlYmFuZFZlcnNpb24oCiAgICAgICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX0dFVF9CQVNFQkFORF9WRVJTSU9OX0RPTkUpKTsKIAotICAgICAgICAgICAgICAgIG1DTS5nZXRJTUVJKG9idGFpbk1lc3NhZ2UoRVZFTlRfR0VUX0lNRUlfR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wogICAgIEdzbUNhbGwgKEdzbUNhbGxUcmFja2VyIG93bmVyKSB7Ci0gICAgICAgIHRoaXMub3duZXIgPSBvd25lcjsKKyAgICAgICAgbU93bmVyID0gb3duZXI7CiAgICAgfQogCiAgICAgcHVibGljIHZvaWQgZGlzcG9zZSgpIHsKQEAgLTYyLDUwICs2MCw1NSBAQAogCiAgICAgLyoqKioqKioqKioqKioqKioqKioqKioqKioqIE92ZXJyaWRkZW4gZnJvbSBDYWxsICoqKioqKioqKioqKioqKioqKioqKioqKiovCiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgTGlzdDxDb25uZWN0aW9uPgogICAgIGdldENvbm5lY3Rpb25zKCkgewogICAgICAgICAvLyBGSVhNRSBzaG91bGQgcmV0dXJuIENvbGxlY3Rpb25zLnVubW9kaWZpYWJsZUxpc3QoKTsKLSAgICAgICAgcmV0dXJuIGNvbm5lY3Rpb25zOworICAgICAgICByZXR1cm4gbUNvbm5lY3Rpb25zOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBQaG9uZQogICAgIGdldFBob25lKCkgewotICAgICAgICByZXR1cm4gb3duZXIucGhvbmU7CisgICAgICAgIHJldHVybiBtT3duZXIubVBob25lOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBib29sZWFuCiAgICAgaXNNdWx0aXBhcnR5KCkgewotICAgICAgICByZXR1cm4gY29ubmVjdGlvbnMuc2l6ZSgpID4gMTsKKyAgICAgICAgcmV0dXJuIG1Db25uZWN0aW9ucy5zaXplKCkgPiAxOwogICAgIH0KIAogICAgIC8qKiBQbGVhc2Ugbm90ZTogaWYgdGhpcyBpcyB0aGUgZm9yZWdyb3VuZCBjYWxsIGFuZCBhCiAgICAgICogIGJhY2tncm91bmQgY2FsbCBleGlzdHMsIHRoZSBiYWNrZ3JvdW5kIGNhbGwgd2lsbCBiZSByZXN1bWVkCiAgICAgICogIGJlY2F1c2UgYW4gQVQrQ0hMRD0x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vbkRpc2Nvbm5lY3RlZChHc21Db25uZWN0aW9uIGNvbm4pIHsKLSAgICAgICAgaWYgKHN0YXRlICE9IFN0YXRlLkRJU0NPTk5FQ1RFRCkgeworICAgICAgICBpZiAobVN0YXRlICE9IFN0YXRlLkRJU0NPTk5FQ1RFRCkgewogICAgICAgICAgICAgLyogSWYgb25seSBkaXNjb25uZWN0ZWQgY29ubmVjdGlvbnMgcmVtYWluLCB3ZSBhcmUgZGlzY29ubmVjdGVkKi8KIAogICAgICAgICAgICAgYm9vbGVhbiBoYXNPbmx5RGlzY29ubmVjdGVkQ29ubmVjdGlvbnMgPSB0cnVlOwogCi0gICAgICAgICAgICBmb3IgKGludCBpID0gMCwgcyA9IGNvbm5lY3Rpb25zLnNpemUoKSAgOyBpIDwgczsgaSArKykgewotICAgICAgICAgICAgICAgIGlmIChjb25uZWN0aW9ucy5nZXQoaSkuZ2V0U3RhdGUoKQorICAgICAgICAgICAgZm9yIChpbnQgaSA9IDAsIHMgPSBtQ29ubmVjdGlvbnMuc2l6ZSgpICA7IGkgPCBzOyBpICsrKSB7CisgICAgICAgICAgICAgICAgaWYgKG1Db25uZWN0aW9ucy5nZXQoaSkuZ2V0U3RhdGUoKQogICAgICAgICAgICAgICAgICAgICAhPSBTdGF0ZS5ESVNDT05ORUNURUQKICAgICAgICAgICAgICAgICApIHsKICAgICAgICAgICAgICAgICAgICAgaGFzT25seURpc2Nvbm5lY3RlZENvbm5lY3Rpb25zID0gZmFsc2U7CkBAIC0xMjgsNyArMTMxLDcgQEAKICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgaWYgKGhhc09ubHlEaXNjb25uZWN0ZWRDb25uZWN0aW9ucykgewotICAgICAgICAgICAgICAgIHN0YXRlID0gU3RhdGUuRElTQ09OTkVDVEVEOworICAgICAgICAgICAgICAgIG1TdGF0ZSA9IFN0YXRlLkRJU0NPTk5FQ1RFRDsKICAgICAgICAgICAgIH0KICAgICAgICAgfQogICAgIH0KQEAgLTEzNiwxMC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IAogICAgICAgICByZXQgPSAoc2VydmljZVN0YXRlICE9IFNlcnZpY2VTdGF0ZS5TVEFURV9QT1dFUl9PRkYpCiAgICAgICAgICAgICAgICAgJiYgcGVuZGluZ01PID09IG51bGwKLSAgICAgICAgICAgICAgICAmJiAhcmluZ2luZ0NhbGwuaXNSaW5naW5nKCkKKyAgICAgICAgICAgICAgICAmJiAhbVJpbmdpbmdDYWxsLmlzUmluZ2luZygpCiAgICAgICAgICAgICAgICAgJiYgIWRpc2FibGVDYWxsLmVxdWFscygidHJ1ZSIpCi0gICAgICAgICAgICAgICAgJiYgKCFmb3JlZ3JvdW5kQ2FsbC5nZXRTdGF0ZSgpLmlzQWxpdmUoKQotICAgICAgICAgICAgICAgICAgICB8fCAhYmFja2dyb3VuZENhbGwuZ2V0U3RhdGUoKS5pc0FsaXZlKCkpOworICAgICAgICAgICAgICAgICYmICghbUZvcmVncm91bmRDYWxsLmdldFN0YXRlKCkuaXNBbGl2ZSgpCisgICAgICAgICAgICAgICAgICAgIHx8ICFtQmFja2dyb3VuZENhbGwuZ2V0U3RhdGUoKS5pc0FsaXZlKCkpOwogCiAgICAgICAgIHJldHVybiByZXQ7CiAgICAgfQogCiAgICAgYm9vbGVhbgogICAgIGNhblRyYW5zZmVyKCkgewotICAgICAgICByZXR1cm4gZm9yZWdyb3VuZENhbGwuZ2V0U3RhdGUoKSA9PSBHc21DYWxsLlN0YXRlLkFDVElWRQotICAgICAgICAgICAgICAgICYmIGJhY2tncm91bmRDYWxsLmdldFN0YXRlKCkgPT0gR3NtQ2FsbC5TdGF0ZS5IT0xESU5HOworICAgICAgICByZXR1cm4gbUZvcmVncm91bmRDYWxsLmdldFN0YXRlKCkgPT0gR3NtQ2FsbC5TdGF0ZS5BQ1RJVkUKKyAgICAgICAgICAgICAgICAmJiBtQmFja2dyb3VuZENhbGwuZ2V0U3RhdGUoKSA9PSBHc21DYWxsLlN0YXRlLkhPTERJTkc7CiAgICAgfQogCiAgICAgLy8qKioqKiBQcml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ZHNQb2xsKTsKIAogICAgICAgICByZXR1cm4gb2J0YWluTWVzc2FnZSh3aGF0KTsKICAgICB9CiAKICAgICBwcml2YXRlIHZvaWQKICAgICBvcGVyYXRpb25Db21wbGV0ZSgpIHsKLSAgICAgICAgcGVuZGluZ09wZXJhdGlvbnMtLTsKKyAgICAgICAgbVBlbmRpbmdPcGVyYXRpb25zLS07CiAKICAgICAgICAgaWYgKERCR19QT0xMKSBsb2coIm9wZXJhdGlvbkNvbXBsZXRlOiBwZW5kaW5nT3BlcmF0aW9ucz0iICsKLSAgICAgICAgICAgICAgICBwZW5kaW5nT3BlcmF0aW9ucyArICIsIG5lZWRzUG9sbD0iICsgbmVlZHNQb2xsKTsKKyAgICAgICAgICAgICAgICBtUGVuZGluZ09wZXJhdGlvbnMgKyAiLCBuZWVkc1BvbGw9IiArIG1OZWVkc1BvbGwpOwogCi0gICAgICAgIGlmIChwZW5kaW5nT3BlcmF0aW9ucyA9PSAwICYmIG5lZWRzUG9sbCkgewotICAgICAgICAgICAgbGFzdFJlbGV2YW50UG9sbCA9IG9idGFpbk1lc3NhZ2UoRVZFTlRfUE9MTF9DQUxMU19SRVNVTFQpOwotICAgICAgICAgICAgY20uZ2V0Q3VycmVudENhbGxzKGxhc3RSZWxldmFudFBvbGwpOwotICAgICAgICB9IGVsc2UgaWYgKHBlbmRpbmdPcGVyYXRpb25zIDwgMCkgeworICAgICAgICBpZiAobVBlbmRpbmdPcGVyYXRpb25zID09IDAgJiYgbU5lZWRzUG9sbCkgeworICAgICAgICAgICAgbUxhc3RSZWxldmFudFBvbGwgPSBvYnRhaW5NZXNzYWdlKEVWRU5UX1BPTExfQ0FMTFNfUkVTVUxUKTsKKyAgICAgICAgICAgIG1DaS5nZXRDdXJyZW50Q2FsbHMobUxhc3RSZWxldmFudFBvbGwpOworICAgICAgICB9IGVsc2UgaWYgKG1QZW5kaW5nT3BlcmF0aW9ucyA8IDApIHsKICAgICAgICAgICAgIC8vIHRoaXMgc2hvdWxkIG5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ICAgICAgICBpZiAobVN0YXRlICE9IG9sZFN0YXRlKSB7CisgICAgICAgICAgICBtUGhvbmUubm90aWZ5UGhvbmVTdGF0ZUNoYW5nZWQoKTsKICAgICAgICAgfQogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHByb3RlY3RlZCBzeW5jaHJvbml6ZWQgdm9pZAogICAgIGhhbmRsZVBvbGxDYWxscyhBc3luY1Jlc3VsdCBhcikgewogICAgICAgICBMaXN0IHBvbGxlZENhbGxzOwpAQCAtNDMzLDggKzQzOSw4IEBACiAgICAgICAgIGJvb2xlYW4gdW5rbm93bkNvbm5lY3Rpb25BcHBlYXJlZCA9IGZhbHNlOwogCiAgICAgICAgIGZvciAoaW50IGkgPSAwLCBjdXJEQyA9IDAsIGRjU2l6ZSA9IHBvbGxlZENhbGxzLnNpemUoKQotICAgICAgICAgICAgICAgIDsgaSA8IGNvbm5lY3Rpb25zLmxlbmd0aDsgaSsrKSB7Ci0gICAgICAgICAgICBHc21Db25uZWN0aW9uIGNvbm4gPSBjb25uZWN0aW9uc1tpXTsKKyAgICAgICAgICAgICAgICA7IGkgPCBtQ29ubmVjdGlvbnMubGVuZ3RoOyBpKyspIHsKKyAgICAgICAgICAgIEdzbUNvbm5lY3Rpb24gY29ubiA9IG1Db25uZWN0aW9uc1tpXTsKICAgICAgICAgICAgIERyaXZlckNhbGwgZGMgPSBudWxsOwogCiAgICAgICAgICAgICAvLyBwb2xsZWRDYWxsIGxpc3QgaXMgc3BhcnNlCkBAIC00NTgsMTggKzQ2NCwxOCBAQAogICAgICAgICAgICAgICAgICAgICBpZiAoREJHX1BPTEwpIGxvZygicG9sbDogcGVuZGluZ01PPSIgKyBwZW5kaW5nTU8pOwogCiAgICAgICAgICAgICAgICAgICAgIC8vIEl0J3Mgb3VyIHBlbmRpbmcgbW9iaWxlIG9yaWdpbmF0aW5nIGNhbGwKLSAgICAgICAgICAgICAgICAgICAgY29ubmVjdGlvbnNbaV0gPSBwZW5kaW5nTU87Ci0gICAgICAgICAgICAgICAgICAgIHBlbmRpbmdNTy5pbmRleCA9IGk7CisgICAgICAgICAgICAgICAgICAgIG1Db25uZWN0aW9uc1tpXSA9IHBlbmRpbmdNTzsKKyAgICAgICAgICAgICAgICAgICAgcGVuZGluZ01PLm1JbmRleCA9IGk7CiAgICAgICAgICAgICAgICAgICAgIHBlbmRpbmdNTy51cGRhdGUoZGMpOwogICAgICAgICAgICAgICAgICAgICBwZW5kaW5nTU8gPSBudWxsOwogCiAgICAgICAgICAgICAgICAgICAgIC8vIFNvbWVvbmUgaGFzIGFscmVhZHkgYXNrZWQgdG8gaGFuZ3VwIHRoaXMgY2FsbAotICAgICAgICAgICAgICAgICAgICBpZiAoaGFuZ3VwUGVuZGluZ01PKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBoYW5ndXBQZW5kaW5nTU8gPSBmYWxzZTsKKyAgICAgICAgICAgICAgICAgICAgaWYgKG1IYW5ndXBQZW5kaW5nTU8pIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1IYW5ndXBQZW5kaW5nTU8gPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKFBob25lLkRFQlVHX1BIT05FKSBsb2coCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAicG9sbDogaGFuZ3VwUGVuZGluZ01PLCBoYW5ndXAgY29ubiAiICsgaSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFuZ3VwKGNvbm5lY3Rpb25zW2ldKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYW5ndXAobUNvbm5lY3Rpb25zW2ldKTsKICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKENhbGxTdGF0ZUV4Y2VwdGlvbiBleCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgIFJsb2cuZShMT0dfVEFHLCAidW5leHBlY3RlZCBlcnJvciBvbiBoYW5ndXAiKTsKICAgICAgICAgICAgICAgICAgICAgICAgIH0KQEAgLTQ3OSwxMSArNDg1LDExIEBACiAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgICAgICBjb25uZWN0aW9uc1tpXSA9IG5ldyBHc21Db25uZWN0aW9uKHBob25lLmdldENvbnRleHQoKSwgZGMsIHRoaXMsIGkpOworICAgICAgICAgICAgICAgICAgICBtQ29ubmVjdGlvbnNbaV0gPSBuZXcgR3NtQ29ubmVjdGlvbihtUGhvbmUuZ2V0Q29udGV4dCgpLCBkYywgdGhpcywgaSk7CiAKICAgICAgICAgICAgICAgICAgICAgLy8gaXQncyBhIHJpbmdpbmcgY2FsbAotICAgICAgICAgICAgICAgICAgICBpZiAoY29ubmVjdGlvbnNbaV0uZ2V0Q2FsbCgpID09IHJpbmdpbmdDYWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBuZXdSaW5naW5nID0gY29ubmVjdGlvbnNbaV07CisgICAgICAgICAgICAgICAgICAgIGlmIChtQ29ubmVjdGlvbnNbaV0uZ2V0Q2FsbCgpID09IG1SaW5naW5nQ2FsbCkgeworICAgICAgICAgICAgICAgICAgICAgICAgbmV3UmluZ2luZyA9IG1Db25uZWN0aW9uc1tpXTsKICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgIC8vIFNvbWV0aGluZyBzdHJhbmdlIGhhcHBlbmVkOiBhIGNhbGwgYXBwZWFyZWQKICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHdoaWNoIGlzIG5laXRoZXIgYSByaW5naW5nIGNhbGwgb3Igb25lIHdlIGNyZWF0ZWQuCkBAIC00OTcsMTAgKzUwMywxMCBAQAogICAgICAgICAgICAgICAgICAgICAgICAgLy8gaXQgd29uJ3QgYXBwZWFyIGFzIGEgTWlzc2VkIENhbGwuCiAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGMuc3RhdGUgIT0gRHJpdmVyQ2FsbC5TdGF0ZS5BTEVSVElORwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAmJiBkYy5zdGF0ZSAhPSBEcml2ZXJDYWxsLlN0YXRlLkRJQUxJTkcpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25uZWN0aW9uc1tpXS5vbkNvbm5lY3RlZEluT3JPdXQoKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBtQ29ubmVjdGlvbnNbaV0ub25Db25uZWN0ZWRJbk9yT3V0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRjLnN0YXRlID09IERyaXZlckNhbGwuU3RhdGUuSE9MRElORykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBXZSd2ZSB0cmFuc2l0aW9uZWQgaW50byBIT0xESU5HCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbm5lY3Rpb25zW2ldLm9uU3RhcnRlZEhvbGRpbmcoKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUNvbm5lY3Rpb25zW2ldLm9uU3RhcnRlZEhvbGRpbmcoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICB9CiAKQEAgLTUxMSwxOSArNTE3LDE5IEBACiAgICAgICAgICAgICB9IGVsc2UgaWYgKGNvbm4gIT0gbnVsbCAmJiBkYyA9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgLy8gQ29ubmVjdGlvbiBtaXNzaW5nIGluIENMQ0MgcmVzcG9uc2UgdGhhdCB3ZSB3ZXJlCiAgICAgICAgICAgICAgICAgLy8gdHJhY2tpbmcuCi0gICAgICAgICAgICAgICAgZHJvcHBlZER1cmluZ1BvbGwuYWRkKGNvbm4pOworICAgICAgICAgICAgICAgIG1Ecm9wcGVkRHVyaW5nUG9sbC5hZGQoY29ubik7CiAgICAgICAgICAgICAgICAgLy8gRHJvcHBlZCBjb25uZWN0aW9ucyBhcmUgcmVtb3ZlZCBmcm9tIHRoZSBDYWxsVHJhY2tlcgogICAgICAgICAgICAgICAgIC8vIGxpc3QgYnV0IGtlcHQgaW4gdGhlIEdzbUNhbGwgbGlzdAotICAgICAgICAgICAgICAgIGNvbm5lY3Rpb25zW2ldID0gbnVsbDsKKyAgICAgICAgICAgICAgICBtQ29ubmVjdGlvbnNbaV0gPSBudWxsOwogICAgICAgICAgICAgfSBlbHNlIGlmIChjb25uICE9IG51bGwgJiYgZGMgIT0gbnVsbCAmJiAhY29ubi5jb21wYXJlVG8oZGMpKSB7CiAgICAgICAgICAgICAgICAgLy8gQ29ubmVjdGlvbiBpbiBDTENDIHJlc3BvbnNlIGRvZXMgbm90IG1hdGNoIHdoYXQKICAgICAgICAgICAgICAgICAvLyB3ZSB3ZXJlIHRyYWNraW5nLiBBc3N1bWUgZHJvcHBlZCBjYWxsIGFuZCBuZXcgY2FsbAogCi0gICAgICAgICAgICAgICAgZHJvcHBlZER1cmluZ1BvbGwuYWRkKGNvbm4pOwotICAgICAgICAgICAgICAgIGNvbm5lY3Rpb25zW2ldID0gbmV3IEdzbUNvbm5lY3Rpb24gKHBob25lLmdldENvbnRleHQoKSwgZGMsIHRoaXMsIGkpOworICAgICAgICAgICAgICAgIG1Ecm9wcGVkRHVyaW5nUG9sbC5hZGQoY29ubik7CisgICAgICAgICAgICAgICAgbUNvbm5lY3Rpb25zW2ldID0gbmV3IEdzbUNvbm5lY3Rpb24gKG1QaG9uZS5nZXRDb250ZXh0KCksIGRjLCB0aGlzLCBpKTsKIAotICAgICAgICAgICAgICAgIGlmIChjb25uZWN0aW9uc1tpXS5nZXRDYWxsKCkgPT0gcmluZ2luZ0NhbGwpIHsKLSAgICAgICAgICAgICAgICAgICAgbmV3UmluZ2luZyA9IGNvbm5lY3Rpb25zW2ldOworICAgICAgICAgICAgICAgIGlmIChtQ29ubmVjdGlvbnNbaV0uZ2V0Q2FsbCgpID09IG1SaW5naW5nQ2FsbCkgeworICAgICAgICAgICAgICAgICAgICBuZXdSaW5naW5nID0gbUNvbm5lY3Rpb25zW2ldOwogICAgICAgICAgICAgICAgIH0gLy8gZWxzZSBzb21ldGhpbmcgc3RyYW5nZSBoYXBwZW5lZAogICAgICAgICAgICAgICAgIGhhc05vbkhhbmd1cFN0YXRlQ2hhbmdlZCA9IHRydWU7CiAgICAgICAgICAgICB9IGVsc2UgaWYgKGNvbm4gIT0gbnVsbCAmJiBkYyAhPSBudWxsKSB7IC8qIGltcGxpY2l0IGNvbm4uY29tcGFyZVRvKGRjKSAqLwpAQCAtNTU3LDUyICs1NjMsNTIgQEAKICAgICAgICAgLy8gSWYgaXQgZG9lcyBub3QsIHdlIGxhbmQgaGVyZQogICAgICAgICBpZiAocGVuZGluZ01PICE9IG51bGwpIHsKICAgICAgICAgICAgIFJsb2cuZChMT0dfVEFHLCJQZW5kaW5nIE1PIGRyb3BwZWQgYmVmb3JlIHBvbGwgZmcgc3RhdGU6IgotICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgZm9yZWdyb3VuZENhbGwuZ2V0U3RhdGUoKSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyBtRm9yZWdyb3VuZENhbGwuZ2V0U3RhdGUoKSk7CiAKLSAgICAgICAgICAgIGRyb3BwZWREdXJpbmdQb2xsLmFkZChwZW5kaW5nTU8pOworICAgICAgICAgICAgbURyb3BwZWREdXJpbmdQb2xsLmFkZChwZW5kaW5nTU8pOwogICAgICAgICAgICAgcGVuZGluZ01PID0gbnVsbDsKLSAgICAgICAgICAgIGhhbmd1cFBlbmRpbmdNTyA9IGZhbHNlOworICAgICAgICAgICAgbUhhbmd1cFBlbmRpbmdNTyA9IGZhbHNlOwogICAgICAgICB9CiAKICAgICAgICAgaWYgKG5ld1JpbmdpbmcgIT0gbnVsbCkgewotICAgICAgICAgICAgcGhvbmUubm90aWZ5TmV3UmluZ2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gICAgICAgICAgICAgICAgIGNhdXNlID0gQ29ubmVjdGlvbi5EaXNjb25uZWN0Q2F1c2UuSU5DT01JTkdfUkVKRUNURUQ7CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgY2F1c2UgPSBDb25uZWN0aW9uLkRpc2Nvbm5lY3RDYXVzZS5JTkNPTUlOR19NSVNTRUQ7CiAgICAgICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAgICAgaWYgKFBob25lLkRFQlVHX1BIT05FKSB7Ci0gICAgICAgICAgICAgICAgICAgIGxvZygibWlzc2VkL3JlamVjdGVkIGNhbGwsIGNvbm4uY2F1c2U9IiArIGNvbm4uY2F1c2UpOworICAgICAgICAgICAgICAgICAgICBsb2coIm1pc3NlZC9yZWplY3RlZCBjYWxsLCBjb25uLmNhdXNlPSIgKyBjb25uLm1DYXVzZSk7CiAgICAgICAgICAgICAgICAgICAgIGxvZygic2V0dGluZyBjYXVzZSB0byAiICsgY2F1c2UpOwogICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBkcm9wcGVkRHVyaW5nUG9sbC5yZW1vdmUoaSk7CisgICAgICAgICAgICAgICAgbURyb3BwZWREdXJpbmdQb2xsLnJlbW92ZShpKTsKICAgICAgICAgICAgICAgICBjb25uLm9uRGlzY29ubmVjdChjYXVzZSk7Ci0gICAgICAgICAgICB9IGVsc2UgaWYgKGNvbm4uY2F1c2UgPT0gQ29ubmVjdGlvbi5EaXNjb25uZWN0Q2F1c2UuTE9DQUwpIHsKKyAgICAgICAgICAgIH0gZWxzZSBpZiAoY29ubi5tQ2F1c2UgPT0gQ29ubmVjdGlvbi5EaXNjb25uZWN0Q2F1c2UuTE9DQUwpIHsKICAgICAgICAgICAgICAgICAvLyBMb2NhbCBoYW5ndXAKLSAgICAgICAgICAgICAgICBkcm9wcGVkRHVyaW5nUG9sbC5yZW1vdmUoaSk7CisgICAgICAgICAgICAgICAgbURyb3BwZWREdXJpbmdQb2xsLnJlbW92ZShpKTsKICAgICAgICAgICAgICAgICBjb25uLm9uRGlzY29ubmVjdChDb25uZWN0aW9uLkRpc2Nvbm5lY3RDYXVzZS5MT0NBTCk7Ci0gICAgICAgICAgICB9IGVsc2UgaWYgKGNvbm4uY2F1c2UgPT0KKyAgICAgICAgICAgIH0gZWxzZSBpZiAoY29ubi5tQ2F1c2UgPT0KICAgICAgICAgICAgICAgICBDb25uZWN0aW9uLkRpc2Nvbm5lY3RDYXVzZS5JTlZBTElEX05VTUJFUikgewotICAgICAgICAgICAgICAgIGRyb3BwZWREdXJpbmdQb2xsLnJlbW92ZShpKTsKKyAgICAgICAgICAgICAgICBtRHJvcHBlZER1cmluZ1BvbGwucmVtb3ZlKGkpOwogICAgICAgICAgICAgICAgIGNvbm4ub25EaXNjb25uZWN0KENvbm5lY3Rpb24uRGlzY29ubmVjdENhdXNlLklOVkFMSURfTlVNQkVSKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfQogCiAgICAgICAgIC8vIEFueSBub24tbG9jYWwgZGlzY29ubmVjdHM6IGRldGVybWluZSBjYXVzZQotICAgICAgICBpZiAoZHJvcHBlZER1cmluZ1BvbGwuc2l6ZSgpID4gMCkgewotICAgICAgICAgICAgY20uZ2V0TGFzdENhbGxGYWlsQ2F1c2UoCisgICAgICAgIGlmIChtRHJvcHBlZER1cmluZ1BvbGwuc2l6ZSgpID4gMCkgeworICAgICAgICAgICAgbUNpLmdldExhc3RDYWxsRmFpbENhdXNlKAogICAgICAgICAgICAgICAgIG9idGFpbk5vUG9sbENvbXBsZXRlTWVzc2FnZShFVkVOVF9HRVRfTEFTVF9DQUxMX0ZBSUxfQ0FVU0UpKTsKICAgICAgICAgfQogCkBAIC02MjIsMTEgKzYyOCwxMSBAQAogICAgICAgICB1cGRhdGVQaG9uZVN0YXRlKCk7CiAKICAgICAgICAgaWYgKHVua25vd25Db25uZWN0aW9uQXBwZWFyZWQpIHsKLSAgICAgICAgICAgIHBob25lLm5vdGlmeVVua25v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gICAgICAgICB0aHJvdyBuZXcgQ2FsbFN0YXRlRXhjZXB0aW9uICgiR3NtQ29ubmVjdGlvbiAiICsgY29ubgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyAiZG9lcyBub3QgYmVsb25nIHRvIEdzbUNhbGxUcmFja2VyICIgKyB0aGlzKTsKICAgICAgICAgfQpAQCAtNjgzLDEwICs2ODksMTAgQEAKICAgICAgICAgICAgIC8vIEdTTSBpbmRleCBhc3NpZ25lZCB5ZXQKIAogICAgICAgICAgICAgaWYgKFBob25lLkRFQlVHX1BIT05FKSBsb2coImhhbmd1cDogc2V0IGhhbmd1cFBlbmRpbmdNTyB0byB0cnVlIik7Ci0gICAgICAgICAgICBoYW5ndXBQZW5kaW5nTU8gPSB0cnVlOworICAgICAgICAgICAgbUhhbmd1cFBlbmRpbmdNTyA9IHRydWU7CiAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICB0cnkgewotICAgICAgICAgICAgICAgIGNtLmhhbmd1cENvbm5lY3Rpb24gKGNvbm4uZ2V0R1NNSW5kZXgoKSwgb2J0YWluQ29tcGxldGVNZXNzYWdlKCkpOworICAgICAgICAgICAgICAgIG1DaS5oYW5ndXBDb25uZWN0aW9uIChjb25uLmdldEdTTUluZGV4KCksIG9idGFpbkNvbXBsZXRlTWVzc2FnZSgpKTsKICAgICAgICAgICAgIH0gY2F0Y2ggKENhbGxTdGF0ZUV4Y2VwdGlvbiBleCkgewogICAgICAgICAgICAgICAgIC8vIElnbm9yZSAiY29ubmVjdGlvbiBub3QgZm91bmQiCiAgICAgICAgICAgICAgICAgLy8gQ2FsbCBtYXkgaGF2ZSBodW5nIHVwIGFscmVhZHkKQEAgLTcwMCwxMiArNzA2LDEyIEBACiAKICAgICAvKnBhY2thZ2UqLyB2b2lkCiAgICAgc2VwYXJhdGUgKEdzbUNvbm5lY3Rpb24gY29ubikgdGhyb3dzIENhbGxTdGF0ZUV4Y2VwdGlvbiB7Ci0gICAgICAgIGlm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bFN0YXRlRXhjZXB0aW9uIHsKLSAgICAgICAgaW50IGNvdW50ID0gY2FsbC5jb25uZWN0aW9ucy5zaXplKCk7CisgICAgICAgIGludCBjb3VudCA9IGNhbGwubUNvbm5lY3Rpb25zLnNpemUoKTsKICAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBjb3VudDsgaSsrKSB7Ci0gICAgICAgICAgICBHc21Db25uZWN0aW9uIGNuID0gKEdzbUNvbm5lY3Rpb24pY2FsbC5jb25uZWN0aW9ucy5nZXQoaSk7CisgICAgICAgICAgICBHc21Db25uZWN0aW9uIGNuID0gKEdzbUNvbm5lY3Rpb24pY2FsbC5tQ29ubmVjdGlvbnMuZ2V0KGkpOwogICAgICAgICAgICAgaWYgKGNuLmdldEdTTUluZGV4KCkgPT0gaW5kZXgpIHsKICAgICAgICAgICAgICAgICByZXR1cm4gY247CiAgICAgICAgICAgICB9CkBAIC04MzUsNiArODQxLDcgQEAKIAogICAgIC8vKioqKioqIE92ZXJyaWRkZW4gZnJvbSBIYW5kbGVyCiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZAogICAgIGhhbmRsZU1lc3NhZ2UgKE1lc3NhZ2UgbXNnKSB7CiAgICAgICAgIEFzeW5jUmVzdWx0IGFyOwpAQCAtODQzLDExICs4NTAsMTEgQEAKICAgICAgICAgICAgIGNhc2UgRVZFTlRfUE9MTF9DQUxMU19SRVNVTFQ6CiAgICAgICAgICAgICAgICAgYXIgPSAoQXN5bmNSZXN1bHQpbXNnLm9iajsKIAotICAgICAgICAgICAgICAgIGlmIChtc2cgPT0gbGFzdFJlbGV2YW50UG9sbCkgeworICAgICAgICAgICAgICAgIGlmIChtc2cgPT0gbUxhc3RSZWxldmFudFBvbGwpIHsKICAgICAgICAgICAgICAgICAgICAgaWYgKERCR19QT0xMKSBsb2coCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgImhhbmRsZSBFVkVOVF9QT0xMX0NBTExfUkVTVUxUOiBzZXQgbmVlZHNQb2xsPUYiKTsKLSAgICAgICAgICAgICAgICAgICAgbmVlZHNQb2xsID0gZmFsc2U7Ci0gICAgICAgICAgICAgICAgICAgIGxhc3RSZWxldmFudFBvbGwgPSBudWxsOworICAgICAgICAgICAgICAgICAgICBtTmVlZHNQb2xsID0gZmFsc2U7CisgICAgICAgICAgICAgICAgICAgIG1MYXN0UmVsZXZhbnRQb2xsID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgaGFuZGxlUG9sbENhbGxzKChBc3luY1Jlc3VsdCltc2cub2JqKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICBicmVhazsKQEAgLTg2Myw3ICs4NzAsNyBAQAogICAgICAgICAgICAgY2FzZSBFVkVOVF9FQ1RfUkVTVUxUOgogICAgICAgICAgICAgICAgIGFyID0gKEFzeW5jUmVzdWx0KW1zZy5vYmo7CiAgICAgICAgICAgICAgICAgaWYgKGFyLmV4Y2VwdGlvbiAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgIHBob25lLm5vdGlmeVN1cHBTZXJ2aWNlRmFpbGVkKGdldEZhaWxlZFNlcnZpY2UobXNnLndoYXQpKTsKKyAgICAgICAgICAgICAgICAgICAgbVBob25lLm5vdGlmeVN1cHBTZXJ2aWNlRmFpbGVkKGdldEZhaWxlZFNlcnZpY2UobXNnLndoYXQpKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgb3BlcmF0aW9uQ29tcGxldGUoKTsKICAgICAgICAgICAgIGJyZWFrOwpAQCAtODkxLDI0ICs4OTgsMjQgQEAKICAgICAgICAgICAgICAgICAgICAgY2F1c2VDb2RlID09IENhbGxGYWlsQ2F1c2UuUU9TX05PVF9BVkFJTCB8fAogICAgICAgICAgICAgICAgICAgICBjYXVzZUNvZGUgPT0gQ2FsbEZhaWxDYXVzZS5CRUFSRVJfTk9UX0FWQUlMIHx8CiAgICAgICAgICAgICAgICAgICAgIGNhdXNlQ29kZSA9PSBDYWxsRmFpbENhdXNlLkVSUk9SX1VOU1BFQ0lGSUVEKSB7Ci0gICAgICAgICAgICAgICAgICAgIEdzbUNlbGxMb2NhdGlvbiBsb2MgPSAoKEdzbUNlbGxMb2NhdGlvbilwaG9uZS5nZXRDZWxsTG9jYXRpb24oKSk7CisgICAgICAgICAgICAgICAgICAgIEdzbUNlbGxMb2NhdGlvbiBsb2MgPSAoKEdzbUNlbGxMb2NhdGlvbiltUGhvbmUuZ2V0Q2VsbExvY2F0aW9uKCkpOwogICAgICAgICAgICAgICAgICAgICBFdmVudExvZy53cml0ZUV2ZW50KEV2ZW50TG9nVGFncy5DQUxMX0RST1AsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2F1c2VDb2RlLCBsb2MgIT0gbnVsbCA/IGxvYy5nZXRDaWQoKSA6IC0xLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIFRlbGVwaG9ueU1hbmFnZXIuZ2V0RGVmYXVsdCgpLmdldE5ldHdvcmtUeXBlKCkpOwogICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgICAgIGZvciAoaW50IGkgPSAwLCBzID0gIGRyb3BwZWREdXJpbmdQb2xsLnNpemUoKQorICAgICAgICAgICAgICAgIGZvciAoaW50IGkgPSAwLCBzID0gIG1Ecm9wcGVkRHVyaW5nUG9sbC5zaXplKCkKICAgICAgICAgICAgICAgICAgICAgICAgIDsgaSA8IHMgOyBpKysKICAgICAgICAgICAgICAgICApIHsKLSAgICAgICAgICAgICAgICAgICAgR3NtQ29ubmVjdGlvbiBjb25uID0gZHJvcHBlZER1cmluZ1BvbGwuZ2V0KGkpOworICAgICAgICAgICAgICAgICAgICBHc21Db25uZWN0aW9uIGNvbm4gPSBtRHJvcHBlZER1cmluZ1BvbGwuZ2V0KGkpOwogCiAgICAgICAgICAgICAgICAgICAgIGNvbm4ub25SZW1vdGVEaXNjb25uZWN0KGNhdXNlQ29kZSk7CiAgICAgICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAgICAgdX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0NSwyMyArMTQ3LDIzIEBACiAgICAgICAgIGNyZWF0ZVdha2VMb2NrKGNvbnRleHQpOwogICAgICAgICBhY3F1aXJlV2FrZUxvY2soKTsKIAotICAgICAgICBvd25lciA9IGN0OwotICAgICAgICBoID0gbmV3IE15SGFuZGxlcihvd25lci5nZXRMb29wZXIoKSk7CisgICAgICAgIG1Pd25lciA9IGN0OworICAgICAgICBtSGFuZGxlciA9IG5ldyBNeUhhbmRsZXIobU93bmVyLmdldExvb3BlcigpKTsKIAotICAgICAgICB0aGlzLmRpYWxTdHJpbmcgPSBkaWFsU3RyaW5nOworICAgICAgICBtRGlhbFN0cmluZyA9IGRpYWxTdHJpbmc7CiAKLSAgICAgICAgdGhpcy5hZGRyZXNzID0gUGhvbmVOdW1iZXJVdGlscy5leHRyYWN0TmV0d29ya1BvcnRpb25BbHQoZGlhbFN0cmluZyk7Ci0gICAgICAgIHRoaXMucG9zdERpYWxTdHJpbmcgPSBQaG9uZU51bWJlclV0aWxzLmV4dHJhY3RQb3N0RGlhbFBvcnRpb24oZGlhbFN0cmluZyk7CisgICAgICAgIG1BZGRyZXNzID0gUGhvbmVOdW1iZXJVdGlscy5leHRyYWN0TmV0d29ya1BvcnRpb25BbHQoZGlhbFN0cmluZyk7CisgICAgICAgIG1Qb3N0RGlhbFN0cmluZyA9IFBob25lTnVtYmVyVXRpbHMuZXh0cmFjdFBvc3REaWFsUG9ydGlvbihkaWFsU3RyaW5nKTsKIAotICAgICAgICBpbmRleCA9IC0xOworICAgICAgICBtSW5kZXggPSAtMTsKIAotICAgICAgICBpc0luY29taW5nID0gZmFsc2U7Ci0gICAgICAgIGNuYXBOYW1lID0gbnVsbDsKLSAgICAgICAgY25hcE5hbWVQcmVzZW50YXRpb24gPSBQaG9uZUNvbnN0YW50cy5QUkVTRU5UQVRJT05fQUxMT1dFRDsKLSAgICAgICAgbnVtYmVyUHJlc2VudGF0aW9uID0gUGhvbmVDb25zdGFudHMuUFJFU0VOVEFUSU9OX0FMTE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ldHVybiBtRGlzY29ubmVjdFRpbWU7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGxvbmcgZ2V0RHVyYXRpb25NaWxsaXMoKSB7Ci0gICAgICAgIGlmIChjb25uZWN0VGltZVJlYWwgPT0gMCkgeworICAgICAgICBpZiAobUNvbm5lY3RUaW1lUmVhbCA9PSAwKSB7CiAgICAgICAgICAgICByZXR1cm4gMDsKLSAgICAgICAgfSBlbHNlIGlmIChkdXJhdGlvbiA9PSAwKSB7Ci0gICAgICAgICAgICByZXR1cm4gU3lzdGVtQ2xvY2suZWxhcHNlZFJlYWx0aW1lKCkgLSBjb25uZWN0VGltZVJlYWw7CisgICAgICAgIH0gZWxzZSBpZiAobUR1cmF0aW9uID09IDApIHsKKyAgICAgICAgICAgIHJldHVybiBTeXN0ZW1DbG9jay5lbGFwc2VkUmVhbHRpbWUoKSAtIG1Db25uZWN0VGltZVJlYWw7CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICByZXR1cm4gZHVyYXRpb247CisgICAgICAgICAgICByZXR1cm4gbUR1cmF0aW9uOwogICAgICAgICB9CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGxvbmcgZ2V0SG9sZER1cmF0aW9uTWlsbGlzKCkgewogICAgICAgICBpZiAoZ2V0U3RhdGUoKSAhPSBHc21DYWxsLlN0YXRlLkhPTERJTkcpIHsKICAgICAgICAgICAgIC8vIElmIG5vdCBob2xkaW5nLCByZXR1cm4gMAogICAgICAgICAgICAgcmV0dXJuIDA7CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICByZXR1cm4gU3lzdGVtQ2xvY2suZWxhcHNlZFJlYWx0aW1lKCkgLSBob2xkaW5nU3RhcnRUaW1lOworICAgICAgICAgICAgcmV0dXJuIFN5c3RlbUNsb2NrLmVsYXBzZWRSZWFsdGltZSgpIC0gbUhvbGRpbmdTdGFydFRpbWU7CiAgICAgICAgIH0KICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgRGlzY29ubmVjdENhdXNlIGdldERpc2Nvbm5lY3RDYXVzZSgpIHsKLSAgICAgICAgcmV0dXJuIGNhdXNlOworICAgICAgICByZXR1cm4gbUNhdXNlOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBib29sZWFuIGlzSW5jb21pbmcoKSB7Ci0gICAgICAgIHJldHVybiBpc0luY29taW5nOworICAgICAgICByZXR1cm4gbUlzSW5jb21pbmc7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIEdzbUNhbGwuU3RhdGUgZ2V0U3RhdGUoKSB7Ci0gICAgICAgIGlmIChkaXNjb25uZWN0ZWQpIHsKKyAgICAgICAgaWYgKG1EaXNjb25uZWN0ZWQpIHsKICAgICAgICAgICAgIHJldHVybiBHc21DYWxsLlN0YXRlLkRJU0NPTk5FQ1RFRDsKICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIHJldHVybiBzdXBlci5nZXRTdGF0ZSgpOwogICAgICAgICB9CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgaGFuZ3VwKCkgdGhyb3dzIENhbGxTdGF0ZUV4Y2VwdGlvbiB7Ci0gICAgICAgIGlmICghZGlzY29ubmVjdGVkKSB7Ci0gICAgICAgICAgICBvd25lci5oYW5ndXAodGhpcyk7CisgICAgICAgIGlmICghbURpc2Nvbm5lY3RlZCkgeworICAgICAgICAgICAgbU93bmVyLmhhbmd1cCh0aGlzKTsKICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIHRocm93IG5ldyBDYWxsU3RhdGVFeGNlcHRpb24gKCJkaXNjb25uZWN0ZWQiKTsKICAgICAgICAgfQogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHNlcGFyYXRlKCkgdGhyb3dzIENhbGxTdGF0ZUV4Y2VwdGlvbiB7Ci0gICAgICAgIGlmICghZGlzY29ubmVjdGVkKSB7Ci0gICAgICAgICAgICBvd25lci5zZXBhcmF0ZSh0aGlzKTsKKyAgICAgICAgaWYgKCFtRGlzY29ubmVjdGVkKSB7CisgICAgICAgICAgICBtT3duZXIuc2VwYXJhdGUodGhpcyk7CiAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICB0aHJvdyBuZXcgQ2FsbFN0YXRlRXhjZXB0aW9uICgiZGlzY29ubmVjdGVkIik7CiAgICAgICAgIH0KICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgUG9zdERpYWxTdGF0ZSBnZXRQb3N0RGlhbFN0YXRlKCkgewotICAgICAgICByZXR1cm4gcG9zdERpYWxTdGF0ZTsKKyAgICAgICAgcmV0dXJuIG1Qb3N0RGlhbFN0YXRlOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHByb2NlZWRBZnRlcldhaXRDaGFyKCkgewotICAgICAgICBpZiAocG9zdERpYWxTdGF0ZSAhPSBQb3N0RGlhbFN0YXRlLldBSVQpIHsKKyAgICAgICAgaWYgKG1Qb3N0RGlhbFN0YXRlICE9IFBvc3REaWFsU3RhdGUuV0FJVCkgewogICAgICAgICAgICAgUmxvZy53KExPR19UQUcsICJHc21Db25uZWN0aW9uLnByb2NlZWRBZnRlcldhaXRDaGFyKCk6IEV4cGVjdGVkICIKLSAgICAgICAgICAgICAgICArICJnZXRQb3N0RGlhbFN0YXRlKCkgdG8gYmUgV0FJVCBidXQgd2FzICIgKyBwb3N0RGlhbFN0YXRlKTsKKyAgICAgICAgICAgICAgICArICJnZXRQb3N0RGlhbFN0YXRlKCkgdG8gYmUgV0FJVCBidXQgd2FzICIgKyBtUG9zdERpYWxTdGF0ZSk7CiAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgIH0KIApAQCAtMjc2LDUzICsyOTIsMzIgQEAKICAgICAgICAgcHJvY2Vzc05leHRQb3N0RGlhbENoYXIoKTsKICAgICB9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aGFyQXQoaSk7Ci0gICAgICAgICAgICAgICAgTWVzc2FnZSBtc2cgPSBudWxsOwotCi0gICAgICAgICAgICAgICAgaWYgKGkgPT0gbGVuLTEpIHsKLSAgICAgICAgICAgICAgICAgICAgbXNnID0gaC5vYnRhaW5NZXNzYWdlKEVWRU5UX0RUTUZfRE9ORSk7Ci0gICAgICAgICAgICAgICAgfQotCi0gICAgICAgICAgICAgICAgaWYgKFBob25lTnVtYmVyVXRpbHMuaXMxMktleShjKSkgewotICAgICAgICAgICAgICAgICAgICBvd25lci5jbS5zZW5kRHRtZihjLCBtc2cpOwotICAgICAgICAgICAgICAgICAgICBwbGF5ZWRUb25lID0gdHJ1ZTsKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgIGlmICghcGxheWVkVG9uZSkgewotICAgICAgICAgICAgICAgIHByb2Nlc3NOZXh0UG9zdERpYWxDaGFyKCk7Ci0gICAgICAgICAgICB9Ci0gICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAvLyBtYWtlIGEgbmV3IHBvc3REaWFsU3RyaW5nLCB3aXRoIHRoZSB3aWxkIGNoYXIgcmVwbGFjZW1lbnQgc3RyaW5nCi0gICAgICAgICAgICAvLyBhdCB0aGUgYmVnaW5uaW5nLCBmb2xsb3dlZCBieSB0aGUgcmVtYWluaW5nIHBvc3REaWFsU3RyaW5nLgotCi0gICAgICAgICAgICBTdHJpbmdCdWlsZGVyIGJ1ZiA9IG5ldyBTdHJpbmdCdWlsZGVyKHN0cik7Ci0gICAgICAgICAgICBidWYuYXBwZW5kKHBvc3REaWFsU3RyaW5nLnN1YnN0cmluZyhuZXh0UG9zdERpYWxDaGFyKSk7Ci0gICAgICAgICAgICBwb3N0RGlhbFN0cmluZyA9IGJ1Zi50b1N0cmluZygpOwotICAgICAgICAgICAgbmV4dFBvc3REaWFsQ2hhciA9IDA7Ci0gICAgICAgICAgICBpZiAoUGhvbmUuREVCVUdfUEhPTkUpIHsKLSAgICAgICAgICAgICAgICBsb2coInByb2NlZWRBZnRlcldpbGRDaGFyOiBuZXcgcG9zdERpYWxTdHJpbmcgaXMgIiArCi0gICAgICAgICAgICAgICAgICAgICAgICBwb3N0RGlhbFN0cmluZyk7Ci0gICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgIHByb2Nlc3NOZXh0UG9zdERpYWxDaGFyKCk7CisgICAgICAgIFN0cmluZ0J1aWxkZXIgYnVmID0gbmV3IFN0cmluZ0J1aWxkZXIoc3RyKTsKKyAgICAgICAgYnVmLmFwcGVuZChtUG9zdERpYWxTdHJpbmcuc3Vic3RyaW5nKG1OZXh0UG9zdERpYWxDaGFyKSk7CisgICAgICAgIG1Qb3N0RGlhbFN0cmluZyA9IGJ1Zi50b1N0cmluZygpOworICAgICAgICBtTmV4dFBvc3REaWFsQ2hhciA9IDA7CisgICAgICAgIGlmIChQaG9uZS5ERUJVR19QSE9ORSkgeworICAgICAgICAgICAgbG9nKCJwcm9jZWVkQWZ0ZXJXaWxkQ2hhcjogbmV3IHBvc3REaWFsU3RyaW5nIGlzICIgKworICAgICAgICAgICAgICAgICAgICBtUG9zdERpYWxTdHJpbmcpOwogICAgICAgICB9CisKKyAgICAgICAgcHJvY2Vzc05leHRQb3N0RGlhbENoYXIoKTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBjYW5jZWxQb3N0RGlhbCgpIHsKICAgICAgICAgc2V0UG9zdERpYWxTdGF0ZShQb3N0RGlhbFN0YXRlLkNBTkNFTExFRCk7CiAgICAgfQpAQCAtMzM0LDcgKzMyOSw3IEBACiAgICAgICovCiAgICAgdm9pZAogICAgIG9uSGFuZ3VwTG9jYWwoKSB7Ci0gICAgICAgIGNhdXNlID0gRGlzY29ubmVjdENhdXNlLkxPQ0FMOworICAgICAgICBtQ2F1c2UgPSBEaXNjb25uZWN0Q2F1c2UuTE9DQUw7CiAgICAgfQogCiAgICAgRGlzY29ubmVjdENhdXNlCkBAIC0zNzEsNyArMzY2LDcgQEAKICAgICAgICAgICAgIGNhc2UgQ2FsbEZhaWxDYXVzZS5FUlJPUl9VTlNQRUNJRklFRDoKICAgICAgICAgICAgIGNhc2UgQ2FsbEZhaWxDYXVzZS5OT1JNQUxfQ0xFQVJJTkc6CiAgICAgICAgICAgICBkZWZhdWx0OgotICAgICAgICAgICAgICAgIEdTTVBob25lIHBob25lID0gb3duZXIucGhvbmU7CisgICAgICAgICAgICAgICAgR1NNUGhvbmUgcGhvbmUgPSBtT3duZXIubVBob25lOwogICAgICAgICAgICAgICAgIGludCBzZXJ2aWNlU3RhdGUgPSBwaG9uZS5nZXRTZXJ2aWNlU3RhdGUoKS5nZXRTdGF0ZSgpOwogICAgICAgICAgICAgICAgIFVpY2NDYXJkQXBwbGljYXRpb24gY2FyZEFwcCA9IFVpY2NDb250cm9sbGVyCiAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0SW5zdGFuY2UoKQpAQCAtNDEzLDIyICs0MDgsMjEgQEAKICAgICAvKiogQ2FsbGVkIHdoZW4gdGhlIHJhZGlvIGluZGljYXRlcyB0aGUgY29ubmVjdGlvbiBoYXMgYmVlbiBkaXNjb25uZWN0ZWQgKi8KICAgICAvKnBhY2thZ2UqLyB2b2lkCiAgICAgb25EaXNjb25uZWN0KERpc2Nvbm5lY3RDYXVzZSBjYXVzZSkgewotICAgICAgICB0aGlzLmNhdXNlID0gY2F1c2U7CisgICAgICAgIG1DYXVzZSA9IGNhdXNlOwogCi0gICAgICAgIGlmICghZGlzY29ubmVjdGVkKSB7Ci0gICAgICAgICAgICBpbmRleCA9IC0xOworICAgICAgICBpZiAoIW1EaXNjb25uZWN0ZWQpIHsKKyAgICAgICAgICAgIG1JbmRleCA9IC0xOwogCi0gICAgICAgICAgICBkaXNjb25uZWN0VGltZSA9IFN5c3RlbS5jdXJyZW50VGltZU1pbGxpcygpOwotICAgICAgICAgICAgZHVyYXRpb24gPSBTeXN0ZW1DbG9jay5lbGFwc2VkUmVhbHRpbWUoKSAtIGNvbm5lY3RUaW1lUmVhbDsKLSAgICAgICAgICAgIGRpc2Nvbm5lY3RlZCA9IHRydWU7CisgICAgICAgICAgICBtRGlzY29ubmVjdFRpbWUgPSBTeXN0ZW0uY3VycmVudFRpbWVNaWxsaXMoKTsKKyAgICAgICAgICAgIG1EdXJhdGlvbiA9IFN5c3RlbUNsb2NrLmVsYXBzZWRSZWFsdGltZSgpIC0gbUNvbm5lY3RUaW1lUmVhbDsKKyAgICAgICAgICAgIG1EaXNjb25uZWN0ZWQgPSB0cnVlOwogCi0gICAgICAgICAgICBpZiAoZmFsc2UpIFJsb2cuZChMT0dfVEFHLAotICAgICAgICAgICAgICAgICAgICAiW0dTTUNvbm5dIG9uRGlzY29ubmVjdDogY2F1c2U9IiArIGNhdXNlKTsKKyAgICAgICAgICAgIGlmIChEQkcpIFJsb2cuZChMT0dfVEFHLCAib25EaXNjb25uZWN0OiBjYXVzZT0iICsgY2F1c2UpOwogCi0gICAgICAgICAgICBvd25lci5waG9uZS5ub3RpZnlEaXNjb25uZWN0KHRoaXMpOworICAgICAgICAgICAgbU93bmVyLm1QaG9uZS5ub3RpZnlEaXNjb25uZWN0KHRoaXMpOwogCi0gICAgICAgICAgICBpZiAocGFyZW50ICE9IG51bGwpIHsKLSAgICAgICAgICAgICAgICBwYXJlbnQuY29ubmVjdGlvbkRpc2Nvbm5lY3RlZCh0aGlzKTsKKyAgICAgICAgICAgIGlmIChtUGFyZW50ICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICBtUGFyZW50LmNvbm5lY3Rpb25EaXNjb25uZWN0ZWQodGhpcyk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICAgICAgcmVsZWFzZVdha2VMb2NrKCk7CkBAIC00NDQsNDUgKzQzOCw0NSBAQAogCiAgICAgICAgIG5ld1BhcmVudCA9IHBhcmVudEZyb21EQ1N0YXRlKGRjLnN0YXRlKTsKIAotICAgICAgICBpZiAoIWVxdWFsc0hhbmRsZXNOdWxscyhhZGRyZXNzLCBkYy5udW1iZXIpKSB7CisgICAgICAgIGlmICghZXF1YWxzSGFuZGxlc051bGxzKG1BZGRyZXNzLCBkYy5udW1iZXIpKSB7CiAgICAgICAgICAgICBpZiAoUGhvbmUuREVCVUdfUEhPTkUpIGxvZygidXBkYXRlOiBwaG9uZSAjIGNoYW5nZWQhIik7Ci0gICAgICAgICAgICBhZGRyZXNzID0gZGMubnVtYmVyOworICAgICAgICAgICAgbUFkZHJlc3MgPSBkYy5udW1iZXI7CiAgICAgICAgICAgICBjaGFuZ2VkID0gdHJ1ZTsKICAgICAgICAgfQogCiAgICAgICAgIC8vIEEgbnVsbCBjbmFwTmFtZSBzaG91bGQgYmUgdGhlIHNhbWUgYXMgIiIKICAgICAgICAgaWYgKFRleHRVdGlscy5pc0VtcHR5KGRjLm5hbWUpKSB7Ci0gICAgICAgICAgICBpZiAoIVRleHRVdGlscy5pc0VtcHR5KGNuYXBOYW1lKSkgeworICAgICAgICAgICAgaWYgKCFUZXh0VXRpbHMuaXNFbXB0eShtQ25hcE5hbWUpKSB7CiAgICAgICAgICAgICAgICAgY2hhbmdlZCA9IHRydWU7Ci0gICAgICAgICAgICAgICAgY25hcE5hbWUgPSAiIjsKKyAgICAgICAgICAgICAgICBtQ25hcE5hbWUgPSAiIjsKICAgICAgICAgICAgIH0KLSAgICAgICAgfSBlbHNlIGlmICghZGMubmFtZS5lcXVhbHMoY25hcE5hbWUpKSB7CisgICAgICAgIH0gZWxzZSBpZiAoIWRjLm5hbWUuZXF1YWxzKG1DbmFwTmFtZSkpIHsKICAgICAgICAgICAgIGNoYW5nZWQgPSB0cnVlOwotICAgICAgICAgICAgY25hcE5hbWUgPSBkYy5uYW1lOworICAgICAgICAgICAgbUNuYXBOYW1lID0gZGMubmFtZTsKICAgICAgICAgfQogCi0gICAgICAgIGlmIChQaG9uZS5ERUJVR19QSE9ORSkgbG9nKCItLWRzc2RzLS0tLSIrY25hcE5hbWUpOwotICAgICAgICBjbmFwTmFtZVByZXNlbnRhdGlvbiA9IGRjLm5hbWVQcmVzZW50YXRpb247Ci0gICAgICAgIG51bWJlclByZXNlbnRhdGlvbiA9IGRjLm51bWJlclByZXNlbnRhdGlvbjsKKyAgICAgICAgaWYgKFBob25lLkRFQlVHX1BIT05FKSBsb2coIi0tZHNzZHMtLS0tIittQ25hcE5hbWUpOworICAgICAgICBtQ25hcE5hbWVQcmVzZW50YXRpb24gPSBkYy5uYW1lUHJlc2VudGF0aW9uOworICAgICAgICBtTnVtYmVyUHJlc2VudGF0aW9uID0gZGMubnVtYmVyUHJlc2VudGF0aW9uOwogCi0gICAgICAgIGlmIChuZXdQYXJlbnQgIT0gcGFyZW50KSB7Ci0gICAgICAgICAgICBpZiAocGFyZW50ICE9IG51bGwpIHsKLSAgICAgICAgICAgICAgICBwYXJlbnQuZGV0YWNoKHRoaXMpOworICAgICAgICBpZiAobmV3UGFyZW50ICE9IG1QYXJlbnQpIHsKKyAgICAgICAgICAgIGlmIChtUGFyZW50ICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICBtUGFyZW50LmRldGFjaCh0aGlzKTsKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIG5ld1BhcmVudC5hdHRhY2godGhpcywgZGMpOwotICAgICAgICAgICAgcGFyZW50ID0gbmV3UGFyZW50OworICAgICAgICAgICAgbVBhcmVudCA9IG5ld1BhcmVudDsKICAgICAgICAgICAgIGNoYW5nZWQgPSB0cnVlOwogICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgYm9vbGVhbiBwYXJlbnRTdGF0ZUNoYW5nZTsKLSAgICAgICAgICAgIHBhcmVudFN0YXRlQ2hhbmdlID0gcGFyZW50LnVwZGF0ZSAodGhpcywgZGMpOworICAgICAgICAgICAgcGFyZW50U3RhdGVDaGFuZ2UgPSBtUGFyZW50LnVwZGF0ZSAodGhpcywgZGMpOwogICAgICAgICAgICAgY2hhbmdlZCA9IGNoYW5nZWQgfHwgcGFyZW50U3RhdGVDaGFuZ2U7CiAgICAgICAgIH0KIAogICAgICAgICAvKiogU29tZSBzdGF0ZS10cmFuc2l0aW9uIGV2ZW50cyAqLwogCiAgICAgICAgIGlmIChQaG9uZS5ERUJVR19QSE9ORSkgbG9nKAotICAgICAgICAgICAgICAgICJ1cGRhdGU6IHBhcmVudD0iICsgcGFyZW50ICsKLSAgICAgICAgICAgICAgICAiLCBoYXNOZXdQYXJlbnQ9IiArIChuZXdQYXJlbnQgIT0gcGFyZW50KSArCisgICAgICAgICAgICAgICAgInVwZGF0ZTogcGFyZW50PSIgKyBtUGFyZW50ICsKKyAgICAgICAgICAgICAgICAiLCBoYXNOZXdQYXJlbnQ9IiArIChuZXdQYXJlbnQgIT0gbVBhcmVudCkgKwogICAgICAgICAgICAgICAgICIsIHdhc0Nvbm5lY3RpbmdJbk9yT3V0PSIgKyB3YXNDb25uZWN0aW5nSW5Pck91dCArCiAgICAgICAgICAgICAgICAgIiwgd2FzSG9sZGluZz0iICsgd2FzSG9sZGluZyArCiAgICAgICAgICAgICAgICAgIiwgaXNDb25uZWN0aW5nSW5Pck91dD0iICsgaXNDb25uZWN0aW5nSW5Pck91dCgpICsKQEAgLTUwOSwyMCArNTAzLDIwIEBACiAgICAgICovCiAgICAgdm9pZAogICAgIGZha2VIb2xkQmVmb3JlRGlhbCgpIHsKLSAgICAgICAgaWYgKHBhcmVudCAhPSBudWxsKSB7Ci0gICAgICAgICAgICBwYXJlbnQuZGV0YWNoKHRoaXMpOworICAgICAgICBpZiAobVBhcmVudCAhPSBudWxsKSB7CisgICAgICAgICAgICBtUGFyZW50LmRldGFjaCh0aGlzKTsKICAgICAgICAgfQogCi0gICAgICAgIHBhcmVudCA9IG93bmVyLmJhY2tncm91bmRDYWxsOwotICAgICAgICBwYXJlbnQuYXR0YWNoRmFrZSh0aGlzLCBHc21DYWxsLlN0YXRlLkhPTERJTkcpOworICAgICAgICBtUGFyZW50ID0gbU93bmVyLm1CYWNrZ3JvdW5kQ2FsbDsKKyAgICAgICA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cCB0aGUgY2FsbC4KICAgICAgICAgaWYgKFBob25lLkRFQlVHX1BIT05FKSB7Ci0gICAgICAgICAgICBsb2coIm9uQ29ubmVjdGVkSW5Pck91dDogY29ubmVjdFRpbWU9IiArIGNvbm5lY3RUaW1lKTsKKyAgICAgICAgICAgIGxvZygib25Db25uZWN0ZWRJbk9yT3V0OiBjb25uZWN0VGltZT0iICsgbUNvbm5lY3RUaW1lKTsKICAgICAgICAgfQogCi0gICAgICAgIGlmICghaXNJbmNvbWluZykgeworICAgICAgICBpZiAoIW1Jc0luY29taW5nKSB7CiAgICAgICAgICAgICAvLyBvdXRnb2luZyBjYWxscyBvbmx5CiAgICAgICAgICAgICBwcm9jZXNzTmV4dFBvc3REaWFsQ2hhcigpOwogICAgICAgICB9CkBAIC01NTIsNyArNTQ2LDcgQEAKIAogICAgIC8qcGFja2FnZSovIHZvaWQKICAgICBvblN0YXJ0ZWRIb2xkaW5nKCkgewotICAgICAgICBob2xkaW5nU3RhcnRUaW1lID0gU3lzdGVtQ2xvY2suZWxhcHNlZFJlYWx0aW1lKCk7CisgICAgICAgIG1Ib2xkaW5nU3RhcnRUaW1lID0gU3lzdGVtQ2xvY2suZWxhcHNlZFJlYWx0aW1lKCk7CiAgICAgfQogICAgIC8qKgogICAgICAqIFBlcmZvcm1zIHRoZSBhcHByb3ByaWF0ZSBhY3Rpb24gZm9yIGEgcG9zdC1kaWFsIGNoYXIsIGJ1dCBkb2VzIG5vdApAQCAtNTYyLDIxICs1NTYsMjEgQEAKICAgICBwcml2YXRlIGJvb2xlYW4KICAgICBwcm9jZXNzUG9zdERpYWxDaGFyKGNoYXIgYykgewogICAgICAgICBpZiAoUGhvbmVOdW1iZXJVdGlscy5pczEyS2V5KGMpKSB7Ci0gICAgICAgICAgICBvd25lci5jbS5zZW5kRHRtZihjLCBoLm9idGFpbk1lc3NhZ2UoRVZFTlRfRFRNRl9ET05FKSk7CisgICAgICAgICAgICBtT3duZXIubUNpLnNlbmREdG1mKGMsIG1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G9zdERpYWxTdHJpbmcgPT0gbnVsbCB8fAorICAgICAgICAgICAgICAgIG1Qb3N0RGlhbFN0cmluZy5sZW5ndGgoKSA8PSBtTmV4dFBvc3REaWFsQ2hhcikgewogICAgICAgICAgICAgc2V0UG9zdERpYWxTdGF0ZShQb3N0RGlhbFN0YXRlLkNPTVBMRVRFKTsKIAogICAgICAgICAgICAgLy8gbm90aWZ5TWVzc2FnZS5hcmcxIGlzIDAgb24gY29tcGxldGUKQEAgLTYzOCwyNyArNjMzLDI3IEBACiAKICAgICAgICAgICAgIHNldFBvc3REaWFsU3RhdGUoUG9zdERpYWxTdGF0ZS5TVEFSVEVEKTsKIAotICAgICAgICAgICAgYyA9IHBvc3REaWFsU3RyaW5nLmNoYXJBdChuZXh0UG9zdERpYWxDaGFyKyspOworICAgICAgICAgICAgYyA9IG1Qb3N0RGlhbFN0cmluZy5jaGFyQXQobU5leHRQb3N0RGlhbENoYXIrKyk7CiAKICAgICAgICAgICAgIGlzVmFsaWQgPSBwcm9jZXNzUG9zdERpYWxDaGFyKGMpOwogCiAgICAgICAgICAgICBpZiAoIWlzVmFsaWQpIHsKICAgICAgICAgICAgICAgICAvLyBXaWxsIGNhbGwgcHJvY2Vzc05leHRQb3N0RGlhbENoYXIKLSAgICAgICAgICAgICAgICBoLm9idGFpbk1lc3NhZ2UoRVZFTlRfTkVYVF9QT1NUX0RJQUwpLnNlbmRUb1RhcmdldCgpOworICAgICAgICAgICAgICAgIG1IYW5kbGVyLm9idGFpbk1lc3NhZ2UoRVZFTlRfTkVYVF9QT1NUX0RJQUwpLnNlbmRUb1RhcmdldCgpOwogICAgICAgICAgICAgICAgIC8vIERvbid0IG5vdGlmeSBhcHBsaWNhdGlvbgogICAgICAgICAgICAgICAgIFJsb2cuZSgiR1NNIiwgInByb2Nlc3NOZXh0UG9zdERpYWxDaGFyOiBjPSIgKyBjICsgIiBpc24ndCB2YWxpZCEiKTsKICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICA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ORzsKKyAgICAgICAgcmV0dXJuIG1QYXJlbnQgPT0gbnVsbCB8fCBtUGFyZW50ID09IG1Pd25lci5tUmluZ2luZ0NhbGwKKyAgICAgICAgICAgIHx8IG1QYXJlbnQubVN0YXRlID09IEdzbUNhbGwuU3RhdGUuRElBTElORworICAgICAgICAgICAgfHwgbVBhcmVudC5tU3RhdGUgPT0gR3NtQ2FsbC5TdGF0ZS5BTEVSVElORzsKICAgICB9CiAKICAgICBwcml2YXRlIEdzbUNhbGwKQEAgLTY4OCwxNiArNjgzLDE2IEBACiAgICAgICAgICAgICBjYXNlIEFDVElWRToKICAgICAgICAgICAgIGNhc2UgRElBTElORzoKICAgICAgICAgICAgIGNhc2UgQUxFUlRJTkc6Ci0gICAgICAgICAgICAgICAgcmV0dXJuIG93bmVyLmZvcmVncm91bmRDYWxsOworICAgICAgICAgICAgICAgIHJldHVybiBtT3duZXIubUZvcmVncm91bmRDYWxsOwogICAgICAgICAgICAgLy9icmVhazsKIAogICAgICAgICAgICAgY2FzZSBIT0xESU5HOgotICAgICAgICAgICAgICAgIHJldHVybiBvd25lci5iYWNrZ3JvdW5kQ2FsbDsKKyAgICAgICAgICAgICAgICByZXR1cm4gbU93bmVyLm1CYWNrZ3JvdW5kQ2FsbDsKICAgICAgICAgICAgIC8vYnJlYWs7CiAKICAgICAgICAgICAgIGNhc2UgSU5DT01JTkc6CiAgICAgICAgICAgICBjYXNlIFdBSVRJTkc6Ci0gICAgICAgICAgICAgICAgcmV0dXJuIG93bmVyLnJpbmdpbmdDYWxsOworICAgICAgICAgICAgICAgIHJldHVybiBtT3duZXIubVJpbmdpbmdDYWxsOwogICAgICAgICAgICAgLy9icmVhazsKIAogICAgICAgICAgICAgZGVmYXVsdDoKQEAgLTcxMiwxNyArNzA3LDE3IEBACiAgICAgICogQHBhcmFtIHMgbmV3IFBvc3REaWFsU3RhdGUKICAgICAgKi8KICAgICBwcml2YXRlIHZvaWQgc2V0UG9zdERpYWxTdGF0ZShQb3N0RGlh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ICAgICByZXR1cm4gcmV0OwpAQCAtMjMzLDE1ICsyMzMsMTUgQEAKIAogICAgICAgICByZXQgPSBuZXcgR3NtTW1pQ29kZShwaG9uZSwgYXBwKTsKIAotICAgICAgICByZXQubWVzc2FnZSA9IHVzc2RNZXNzYWdlOwotICAgICAgICByZXQuaXNVc3NkUmVxdWVzdCA9IGlzVXNzZFJlcXVlc3Q7CisgICAgICAgIHJldC5tTWVzc2FnZSA9IHVzc2RNZXNzYWdlOworICAgICAgICByZXQubUlzVXNzZFJlcXVlc3QgPSBpc1Vzc2RSZXF1ZXN0OwogCiAgICAgICAgIC8vIElmIGl0J3MgYSByZXF1ZXN0LCBzZXQgdG8gUEVORElORyBzbyB0aGF0IGl0J3MgY2FuY2VsYWJsZS4KICAgICAgICAgaWYgKGlzVXNzZFJlcXVlc3QpIHsKLSAgICAgICAgICAgIHJldC5pc1BlbmRpbmdVU1NEID0gdHJ1ZTsKLSAgICAgICAgICAgIHJldC5zdGF0ZSA9IFN0YXRlLlBFTkRJTkc7CisgICAgICAgICAgICByZXQubUlzUGVuZGluZ1VTU0QgPSB0cnVlOworICAgICAgICAgICAgcmV0Lm1TdGF0ZSA9IFN0YXRlLlBFTkRJTkc7CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICByZXQuc3RhdGUgPSBTdGF0ZS5DT01QTEVURTsKKyAgICAgICAgICAgIHJldC5tU3RhdGUgPSBTdGF0ZS5DT01QTEVURTsKICAgICAgICAgfQogCiAgICAgICAgIHJldHVybiByZXQ7CkBAIC0yNTIsOSArMjUyLDkgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBVaWNjQ2FyZEFwcGxpY2F0aW9uIGFwcCkgewogICAgICAgICBHc21NbWlDb2RlIHJldCA9IG5ldyBHc21NbWlDb2RlKHBob25lLCBhcHApOwogCi0gICAgICAgIHJldC5tZXNzYWdlID0gdXNzZE1lc3NnZTsKLSAgICAgICAgcmV0LnN0YXRlID0gU3RhdGUuUEVORElORzsKLSAgICAgICAgcmV0LmlzUGVuZGluZ1VTU0QgPSB0cnVlOworICAgICAgICByZXQubU1lc3NhZ2UgPSB1c3NkTWVzc2dlOworICAgICAgICByZXQubVN0YXRlID0gU3RhdGUuUEVORElORzsKKyAgICAgICAgcmV0Lm1Jc1BlbmRpbmdVU1NEID0gdHJ1ZTsKIAogICAgICAgICByZXR1cm4gcmV0OwogICAgIH0KQEAgLTQwNSw4ICs0MDUsOCBAQAogICAgICAgICAvLyBUaGUgdGVsZXBob255IHVuaXQtdGVzdCBjYXNlcyBtYXkgY3JlYXRlIEdzbU1taUNvZGUncwogICAgICAgICAvLyBpbiBzZWNvbmRhcnkgdGhyZWFkcwogICAgICAgICBzdXBlcihwaG9uZS5nZXRIYW5kbGVyKCkuZ2V0TG9vcGVyKCkpOwotICAgICAgICB0aGlzLnBob25lID0gcGhvbmU7Ci0gICAgICAgIHRoaXMuY29udGV4dCA9IHBob25lLmdldENvbnRleHQoKTsKKyAgICAgICAgbVBob25lID0gcGhvbmU7CisgICAgICAgIG1Db250ZXh0ID0gcGhvbmUuZ2V0Q29udGV4dCgpOwogICAgICAgICBtVWljY0FwcGxpY2F0aW9uID0gYXBwOwogICAgICAgICBpZiAoYXBwICE9IG51bGwpIHsKICAgICAgICAgICAgIG1JY2NSZWNvcmRzID0gYXBwLmdldEljY1JlY29yZHMoKTsKQEAgLTQxNSwzMiArNDE1LDM1IEBACiAKICAgICAvLyoqKioqIE1taUNvZGUgaW1wbGVtZW50YXRpb24KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdGF0ZQogICAgIGdldFN0YXRlKCkgewotICAgICAgICByZXR1cm4gc3RhdGU7CisgICAgICAgIHJldHVybiBtU3RhdGU7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIENoYXJTZXF1ZW5jZQogICAgIGdldE1lc3NhZ2UoKSB7Ci0gICAgICAgIHJldHVybiBtZXNzYWdlOworICAgICAgICByZX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oKSB7Ci0gICAgICAgIHJldHVybiBwb3VuZFN0cmluZyA9PSBudWxsCi0gICAgICAgICAgICAgICAgICAgICYmIGRpYWxpbmdOdW1iZXIgIT0gbnVsbCAmJiBkaWFsaW5nTnVtYmVyLmxlbmd0aCgpIDw9IDI7CisgICAgICAgIHJldHVybiBtUG91bmRTdHJpbmcgPT0gbnVsbAorICAgICAgICAgICAgICAgICAgICAmJiBtRGlhbGluZ051bWJlciAhPSBudWxsICYmIG1EaWFsaW5nTnVtYmVyLmxlbmd0aCgpIDw9IDI7CiAKICAgICB9CiAKQEAgLTU1OCw4ICs1NjIsOCBAQAogICAgICAqIEByZXR1cm4gdHJ1ZSBpZiB0aGUgU2VydmljZSBDb2RlIGlzIFBJTi9QSU4yL1BVSy9QVUsyLXJlbGF0ZWQKICAgICAgKi8KICAgICBib29sZWFuIGlzUGluQ29tbWFuZCgpIHsKLSAgICAgICAgcmV0dXJuIHNjICE9IG51bGwgJiYgKHNjLmVxdWFscyhTQ19QSU4pIHx8IHNjLmVxdWFscyhTQ19QSU4yKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfHwgc2MuZXF1YWxzKFNDX1BVSykgfHwgc2MuZXF1YWxzKFNDX1BVSzIpKTsKKyAgICAgICAgcmV0dXJuIG1TYyAhPSBudWxsICYmIChtU2MuZXF1YWxzKFNDX1BJTikgfHwgbVNjLmVxdWFscyhTQ19QSU4yKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfHwgbVNjLmVxdWFscyhTQ19QVUspIHx8IG1TYy5lcXVhbHMoU0NfUFVLMikpOwogICAgICB9CiAKICAgICAvKioKQEAgLTU3MSw3ICs1NzUsNyBAQAogICAgICAqLwogICAgIGJvb2xlYW4KICAgICBpc1RlbXBvcmFyeU1vZGVDTElSKCkgewotICAgICAgICByZXR1cm4gc2MgIT0gbnVsbCAmJiBzYy5lcXVhbHMoU0NfQ0xJUikgJiYgZGlhbGluZ051bWJlciAhPSBudWxsCisgICAgICAgIHJld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BNTUkgY29kZSBvciBzaG9ydCBjb2RlLi4uYW55dGhpbmcgdGhhdCBpc24ndCBhIGRpYWxpbmcgbnVtYmVyICovCkBAIC02MzEsNDIgKzYzNiw0MiBAQAogICAgICAgICAgICAgaWYgKGlzU2hvcnRDb2RlKCkpIHsKICAgICAgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgImlzU2hvcnRDb2RlIik7CiAgICAgICAgICAgICAgICAgLy8gVGhlc2UganVzdCBnZXQgdHJlYXRlZCBhcyBVU1NELgotICAgICAgICAgICAgICAgIHNlbmRVc3NkKGRpYWxpbmdOdW1iZXIpOwotICAgICAgICAgICAgfSBlbHNlIGlmIChkaWFsaW5nTnVtYmVyICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICBzZW5kVXNzZChtRGlhbGluZ051bWJlcik7CisgICAgICAgICAgICB9IGVsc2UgaWYgKG1EaWFsaW5nTnVtYmVyICE9IG51bGwpIHsKICAgICAgICAgICAgICAgICAvLyBXZSBzaG91bGQgaGF2ZSBubyBkaWFsaW5nIG51bWJlcnMgaGVyZQogICAgICAgICAgICAgICAgIHRocm93IG5ldyBSdW50aW1lRXhjZXB0aW9uICgiSW52YWxpZCBvciBVbnN1cHBvcnRlZCBNTUkgQ29kZSIpOwotICAgICAgICAgICAgfSBlbHNlIGlmIChzYyAhPSBudWxsICYmIHNjLmVxdWFscyhTQ19DTElQKSkgeworICAgICAgICAgICAgfSBlbHNlIGlmIChtU2MgIT0gbnVsbCAmJiBtU2MuZXF1YWxzKFNDX0NMSVApKSB7CiAgICAgICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsICJpcyBDTElQIik7CiAgICAgICAgICAgICAgICAgaWYgKGlzSW50ZXJyb2dhdGUoKSkgewotICAgICAgICAgICAgICAgICAgICBwaG9uZS5tQ00ucXVlcnlDTElQKAorICAgICAgICAgICAgICAgICAgICBtUGhvbmUubUNpLnF1ZXJ5Q0xJUCgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX1FVRVJZX0NPTVBMRVRFLCB0aGlzKSk7CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IFJ1bnRpbWVFeGNlcHRpb24gKCJJbnZhbGlkIG9yIFVuc3VwcG9ydGVkIE1NSSBDb2RlIik7CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgfSBlbHNlIGlmIChzYyAhPSBudWxsICYmIHNjLmVxdWFscyhTQ19DTElSKSkgeworICAgICAgICAgICAgfSBlbHNlIGlmIChtU2MgIT0gbnVsbCAmJiBtU2MuZXF1YWxzKFNDX0NMSVIpKSB7CiAgICAgICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsICJpcyBDTElSIik7CiAgICAgICAgICAgICAgICAgaWYgKGlzQWN0aXZhdGUoKSkgewotICAgICAgICAgICAgICAgICAgICBwaG9uZS5tQ00uc2V0Q0xJUihDb21tYW5kc0ludGVyZmFjZS5DTElSX0lOVk9DQVRJT04sCisgICAgICAgICAgICAgICAgICAgIG1QaG9uZS5tQ2kuc2V0Q0xJUihDb21tYW5kc0ludGVyZmFjZS5DTElSX0lOVk9DQVRJT04sCiAgICAgICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX1NFVF9DT01QTEVURSwgdGhpcykpOwogICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNEZWFjdGl2YXRlKCkpIHsKLSAgICAgICAgICAgICAgICAgICAgcGhvbmUubUNNLnNldENMSVIoQ29tbWFuZHNJbnRlcmZhY2UuQ0xJUl9TVVBQUkVTU0lPTiwKKyAgICAgICAgICAgICAgICAgICAgbVBob25lLm1DaS5zZXRDTElSKENvbW1hbmRzSW50ZXJmYWNlLkNMSVJfU1VQUFJFU1NJT04sCiAgICAgICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX1NFVF9DT01QTEVURSwgdGhpcykpOwogICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNJbnRlcnJvZ2F0ZSgpKSB7Ci0gICAgICAgICAgICAgICAgICAgIHBob25lLm1DTS5nZXRDTElSKAorICAgICAgICAgICAgICAgICAgICBtUGhvbmUubUNpLmdldENMSVIoCiAgICAgICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX0dFVF9DTElSX0NPTVBMRVRFLCB0aGlzKSk7CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IFJ1bnRpbWVFeGNlcHRpb24gKCJJbnZhbGlkIG9yIFVuc3VwcG9ydGVkIE1NSSBDb2RlIik7CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgfSBlbHNlIGlmIChpc1NlcnZpY2VDb2RlQ2FsbEZvcndhcmRpbmcoc2MpKSB7CisgICAgICAgICAgICB9IGVsc2UgaWYgKGlzU2VydmljZUNvZGVDYWxsRm9yd2FyZGluZyhtU2MpKSB7CiAgICAgICAgICAgICAgICAgUmxvZy5kKExPR19UQUcsICJpcyBDRiIpOwogCi0gICAgICAgICAgICAgICAgU3RyaW5nIGRpYWxpbmdOdW1iZXIgPSBzaWE7Ci0gICAgICAgICAgICAgICAgaW50IHNlcnZpY2VDbGFzcyA9IHNpVG9TZXJ2aWNlQ2xhc3Moc2liKTsKLSAgICAgICAgICAgICAgICBpbnQgcmVhc29uID0gc2NUb0NhbGxGb3J3YXJkUmVhc29uKHNjKTsKLSAgICAgICAgICAgICAgICBpbnQgdGltZSA9IHNpVG9UaW1lKHNpYyk7CisgICAgICAgICAgICAgICAgU3RyaW5nIGRpYWxpbmdOdW1iZXIgPSBtU2lhOworICAgICAgICAgICAgICAgIGludCBzZXJ2aWNlQ2xhc3MgPSBzaVRvU2VydmljZUNsYXNzKG1TaWIpOworICAgICAgICAgICAgICAgIGludCByZWFzb24gPSBzY1RvQ2FsbEZvcndhcmRSZWFzb24obVNjKTsKKyAgICAgICAgICAgICAgICBpbnQgdGltZSA9IHNpVG9UaW1lKG1TaWMpOwogCiAgICAgICAgICAgICAgICAgaWYgKGlzSW50ZXJyb2dhdGUoKSkgewotICAgICAgICAgICAgICAgICAgICBwaG9uZS5tQ00ucXVlcnlDYWxsRm9yd2FyZFN0YXR1cygKKyAgICAgICAgICAgICAgICAgICAgbVBob25lLm1DaS5xdWVyeUNhbGxGb3J3YXJkU3RhdHVzKAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbiwgc2VydmljZUNsYXNzLCAgZGlhbGluZ051bWJlciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZShFVkVOVF9RVUVSWV9DRl9DT01QTEVURSwgdGhpcykpOwogICAgICAgICAgICAgICAgIH0gZWxzZSB7CkBAIC02NzksMTAgKzY4NCwxMCBAQAogICAgICAgICAgICAgICAgICAgICAgICAgLy8gbnVtYmVyLCBvciBhbiBhY3RpdmF0aW9uIGlmIG5vdAogICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzRW1wdHlPck51bGwoZGlhbGluZ051bWJlcikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjZkFjdGlvbiA9IENvbW1hbmRzSW50ZXJmYWNlLkNGX0FDVElPTl9FTkFCTEU7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNDYWxsRndkUmVnID0gZmFsc2U7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUlzQ2FsbEZ3ZFJlZyA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjZkFjdGlvbiA9IENvbW1hbmRzSW50ZXJmYWNlLkNGX0FDVElPTl9SRUdJU1RSQVRJT047Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNDYWxsRndkUmVnID0gdHJ1ZTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBtSXNDYWxsRndkUmVnID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChpc0RlYWN0aXZhdGUoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgY2ZBY3Rpb24gPSBDb21tYW5kc0ludGVyZmFjZS5DRl9BQ1RJT05fRElTQUJMRTsKQEAgLTcwNSw1MCArNzEwLDUwIEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChjZkFjdGlvbiA9PSBDb21tYW5kc0ludGVyZmFjZS5DRl9BQ1RJT05fUkVHSVNUUkFUSU9OKSkgPyAxIDogMDsKIAogICAgICAgICAgICAgICAgICAgICBSbG9nLmQoTE9HX1RBRywgImlzIENGIHNldENhbGxGb3J3YXJkIik7Ci0gICAgICAgICAgICAgICAgICAgIHBob25lLm1DTS5zZXRDYWxsRm9yd2FyZChjZkFjdGlvbiwgcmVhc29uLCBzZXJ2aWNlQ2xhc3MsCisgICAgICAgICAgICAgICAgICAgIG1QaG9uZS5tQ2kuc2V0Q2FsbEZvcndhcmQoY2ZBY3Rpb24sIHJlYXNvbiwgc2VydmljZUNsYXNzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpYWxpbmdOdW1iZXIsIHRpbWUsIG9idGFpbk1lc3NhZ2UoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBFVkVOVF9TRVRfQ0ZGX0NPTVBMRVRFLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNTZXR0aW5nVW5jb25kaXRpb25hbFZvaWNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNFbmFibGVEZXNpcmVkLCB0aGlzKSk7CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgfSBlbHNlIGlmIChpc1NlcnZpY2VDb2RlQ2FsbEJhcnJpbmcoc2MpKSB7CisgICAgICAgICAgICB9IGVsc2UgaWYgKGlzU2VydmljZUNv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AgICAgICAgICAgICAgbVBob25lLm1DaS5zZXRGYWNpbGl0eUxvY2soZmFjaWxpdHksIGlzQWN0aXZhdGUoKSwgcGFzc3dvcmQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VydmljZUNsYXNzLCBvYnRhaW5NZXNzYWdlKEVWRU5UX1NFVF9DT01QTEVURSwgdGhpcykpOwogICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBSdW50aW1lRXhjZXB0aW9uICgiSW52YWxpZCBvciBVbnN1cHBvcnRlZCBNTUkgQ29kZSIpOwogICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgfSBlbHNlIGlmIChzYyAhPSBudWxsICYmIHNjLmVxdWFscyhTQ19QV0QpKSB7CisgICAgICAgICAgICB9IGVsc2UgaWYgKG1TYyAhPSBudWxsICYmIG1TYy5lcXVhbHMoU0NfUFdEKSkgewogICAgICAgICAgICAgICAgIC8vIHNpYSA9IGZhYwogICAgICAgICAgICAgICAgIC8vIHNpYiA9IG9sZCBwd2QKICAgICAgICAgICAgICAgICAvLyBzaWMgPSBuZXcgcHdkCiAgICAgICAgICAgICAgICAgLy8gcHdkID0gbmV3IHB3ZAogICAgICAgICAgICAgICAgIFN0cmluZyBmYWNpbGl0eTsKLSAgICAgICAgICAgICAgICBTdHJpbmcgb2xkUHdkID0gc2liOwotICAgICAgICAgICAgICAgIFN0cmluZyBuZXdQd2QgPSBzaWM7CisgICAgICAgICAgICAgICAgU3RyaW5nIG9sZFB3ZCA9IG1TaWI7CisgICAgICAgICAgICAgICAgU3RyaW5nIG5ld1B3ZCA9IG1TaWM7CiAgICAgICAgICAgICAgICAgaWYgKGlzQWN0aXZhdGUoKSB8fCBpc1JlZ2lzdGVyKCkpIHsKICAgICAgICAgICAgICAgICAgICAgLy8gRXZlbiB0aG91Z2ggQUNUSVZBVEUgaXMgYWNjZXB0YWJsZSwgdGhpcyBpcyByZWFsbHkgdGVybWVkIGEgUkVHSVNURVIKLSAgICAgICAgICAgICAgICAgICAgYWN0aW9uID0gQUNUSU9OX1JFR0lTVEVSOworICAgICAgICAgICAgICAgICAgICBtQWN0aW9uID0gQUNUSU9OX1JFR0lTVEVSOwogCi0gICAgICAgICAgICAgICAgICAgIGlmIChzaWEgPT0gbnVsbCkgeworICAgICAgICAgICAgICAgICAgICBpZiAobVNpYSA9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBJZiBzYyB3YXMgbm90IHNwZWNpZmllZCwgdHJlYXQgaXQgYXMgQkFfQUxMLgogICAgICAgICAgICAgICAgICAgICAgICAgZmFjaWxpdHkgPSBDb21tYW5kc0ludGVyZmFjZS5DQl9GQUNJTElUWV9CQV9BTEw7CiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBmYWNpbGl0eSA9IHNjVG9CYXJyaW5nRmFjaWxpdHkoc2lhKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGZhY2lsaXR5ID0gc2NUb0JhcnJpbmdGYWNpbGl0eShtU2lhKTsKICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBpZiAobmV3UHdkLmVxdWFscyhwd2QpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBwaG9uZS5tQ00uY2hhbmdlQmFycmluZ1Bhc3N3b3JkKGZhY2lsaXR5LCBvbGRQd2QsCisgICAgICAgICAgICAgICAgICAgIGlmIChuZXdQd2QuZXF1YWxzKG1Qd2QpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBtUGhvbmUubUNpLmNoYW5nZUJhcnJpbmdQYXNzd29yZChmYWNpbGl0eSwgb2xkUHdkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdQd2QsIG9idGFpbk1lc3NhZ2UoRVZFTlRfU0VUX0NPTVBMRVRFLCB0aGlzKSk7CiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBwYXNzd29yZCBtaXNtYXRjaDsgcmV0dXJuIGVycm9yCkBAIC03NTgsMTUgKzc2MywxNSBAQAogICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgUnVudGltZUV4Y2VwdGlvbiAoIkludmFsaWQgb3IgVW5zdXBwb3J0ZWQgTU1JIENvZGUiKTsKICAgICAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgIH0gZWxzZSBpZiAoc2MgIT0gbnVsbCAmJiBzYy5lcXVhbHMoU0NfV0FJVCkpIHsKKyAgICAgICAgICAgIH0gZWxzZSBpZiAobVNjICE9IG51bGwgJiYgbVNjLmVxdWFscyhTQ19XQUlUKSkgewogICAgICAgICAgICAgICAgIC8vIHNpYSA9IGJhc2ljIHNlcnZpY2UgZ3JvdXAKLSAgICAgICAgICAgICAgICBpbnQgc2VydmljZUNsYXNzID0gc2lUb1NlcnZpY2VDbGFzcyhzaWEpOworICAgICAgICAgICAgICAgIGludCBzZXJ2aWNlQ2xhc3MgPSBzaVRvU2VydmljZUNsYXNzKG1TaWEpOwogCiAgICAgICAgICAgICAgICAgaWYgKGlzQWN0aXZhdGUoKSB8fCBpc0RlYWN0aXZhdGUoKSkgewotICAgICAgICAgICAgICAgICAgICBwaG9uZS5tQ00uc2V0Q2FsbFdhaXRpbmcoaXNBY3RpdmF0ZSgpLCBzZXJ2aWNlQ2xhc3MsCisgICAgICAgICAgICAgICAgICAgIG1QaG9uZS5tQ2kuc2V0Q2FsbFdhaXRpbmcoaXNBY3RpdmF0ZSgpLCBzZXJ2aWNlQ2xhc3MsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZShFVkVOVF9TRVRfQ09NUExFVEUsIHRoaXMpKTsKICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGlzSW50ZXJyb2dhdGUoKSkgewotICAgICAgICAgICAgICAgICAgICBwaG9uZS5tQ00ucXVlcnlDYWxsV2FpdGluZyhzZXJ2aWNlQ2xhc3MsCisgICAgICAgICAgICAgICAgICAgIG1QaG9uZS5tQ2kucXVlcnlDYWxsV2FpdGluZyhzZXJ2aWNlQ2xhc3MsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZShFVkVOVF9RVUVSWV9DT01QTEVURSwgdGhpcykpOwogICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBSdW50aW1lRXhjZXB0aW9uICgiSW52YWxpZCBvciBVbnN1cHBvcnRlZCBNTUkgQ29kZSIpOwpAQCAtNzc1LDU5ICs3ODAsNTkgQEAKICAgICAgICAgICAgICAgICAvLyBzaWEgPSBvbGQgUElOIG9yIFBVSwogICAgICAgICAgICAgICAgIC8vIHNpYiA9IG5ldyBQSU4KICAgICAgICAgICAgICAgICAvLyBzaWMgPSBuZXcgUElOCi0gICAgICAgICAgICAgICAgU3RyaW5nIG9sZFBpbk9yUHVrID0gc2lhOwotICAgICAgICAgICAgICAgIFN0cmluZyBuZXdQaW4gPSBzaWI7CisgICAgICAgICAgICAgICAgU3RyaW5nIG9sZFBpbk9yUHVrID0gbVNpYTsKKyAgICAgICAgICAgICAgICBTdHJpbmcgbmV3UGluID0gbVNpYjsKICAgICAgICAgICAgICAgICBpbnQgcGluTGVuID0gbmV3UGluLmxlbmd0aCgpOwogICAgICAgICAgICAgICAgIGlmIChpc1JlZ2lzdGVyKCkpIHsKLSAgICAgICAgICAgICAgICAgICAgaWYgKCFuZXdQaW4uZXF1YWxzKHNpYykpIHsKKyAgICAgICAgICAgICAgICAgICAgaWYgKCFuZXdQaW4uZXF1YWxzKG1TaWMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBwYXNzd29yZCBtaXNtYXRjaDsgcmV0dXJuIGVycm9yCiAgICAgICAgICAgICAgICAgICAgICAgICBoYW5kbGVQYXNzd29yZEVycm9yKGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLm1pc21hdGNoUGluKTsKICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChwaW5MZW4gPCA0IHx8IHBpbkxlbiA+IDggKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBpbnZhbGlkIGxlbmd0aAogICAgICAgICAgICAgICAgICAgICAgICAgaGFuZGxlUGFzc3dvcmRFcnJvcihjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5pbnZhbGlkUGluKTsKLSAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzYy5lcXVhbHMoU0NfUElOKSAmJgorICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG1TYy5lcXVhbHMoU0NfUElOKSAmJgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1VaWNjQXBwbGljYXRpb24gIT0gbnVsbCAmJgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1VaWNjQXBwbGljYXRpb24uZ2V0U3RhdGUoKSA9PSBBcHBTdGF0ZS5BUFBTVEFURV9QVUsgKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBTaW0gaXMgcHVrLWxvY2tlZAogICAgICAgICAgICAgICAgICAgICAgICAgaGFuZGxlUGFzc3dvcmRFcnJvcihjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5uZWVkUHVrKTsKICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHByZS1jaGVja3MgT0sKLSAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzYy5lcXVhbHMoU0NfUElOKSkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBob25lLm1DTS5jaGFuZ2VJY2NQaW4ob2xkUGluT3JQdWssIG5ld1BpbiwKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtU2MuZXF1YWxzKFNDX1BJTikpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBtUGhvbmUubUNpLmNoYW5nZUljY1BpbihvbGRQaW5PclB1aywgbmV3UGluLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZShFVkVOVF9TRVRfQ09NUExFVEUsIHRoaXMpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoc2MuZXF1YWxzKFNDX1BJTjIpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgcGhvbmUubUNNLmNoYW5nZUljY1BpbjIob2xkUGluT3JQdWssIG5ld1BpbiwKKyAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAobVNjLmVxdWFscyhTQ19QSU4yKSkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1QaG9uZS5tQ2kuY2hhbmdlSWNjUGluMihvbGRQaW5PclB1aywgbmV3UGluLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZShFVkVOVF9TRVRfQ09NUExFVEUsIHRoaXMpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoc2MuZXF1YWxzKFNDX1BVSykpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBwaG9uZS5tQ00uc3VwcGx5SWNjUHVrKG9sZFBpbk9yUHVrLCBuZXdQaW4sCisgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG1TYy5lcXVhbHMoU0NfUFVLKSkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1QaG9uZS5tQ2kuc3VwcGx5SWNjUHVrKG9sZFBpbk9yUHVrLCBuZXdQaW4sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX1NFVF9DT01QTEVURSwgdGhpcykpOwotICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzYy5lcXVhbHMoU0NfUFVLMikpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBwaG9uZS5tQ00uc3VwcGx5SWNjUHVrMihvbGRQaW5PclB1aywgbmV3UGluLAorICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChtU2MuZXF1YWxzKFNDX1BVSzIpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbVBob25lLm1DaS5zdXBwbHlJY2NQdWsyKG9sZFBpbk9yUHVrLCBuZXdQaW4sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX1NFVF9DT01QTEVURSwgdGhpcykpOwogICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IFJ1bnRpbWVFeGNlcHRpb24gKCJJbnZhbGlkIG9yIFVuc3VwcG9ydGVkIE1NSSBDb2RlIik7CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgfSBlbHNlIGlmIChwb3VuZFN0cmluZyAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgc2VuZFVzc2QocG91bmRTdHJpbmcpOworICAgICAgICAgICAgfSBlbHNlIGlmIChtUG91bmRTdHJpbmcgIT0gbnVsbCkgeworICAgICAgICAgICAgICAgIHNlbmRVc3NkKG1Qb3VuZFN0cmluZyk7CiAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgIHRocm93IG5ldyBSdW50aW1lRXhjZXB0aW9uICgiSW52YWxpZCBvciBVbnN1cHBvcnRlZCBNTUkgQ29kZSIpOwogICAgICAgICAgICAgfQogICAgICAgICB9IGNhdGNoIChSdW50aW1lRXhjZXB0aW9uIGV4YykgewotICAgICAgICAgICAgc3RhdGUgPSBTdGF0ZS5GQUlMRUQ7Ci0gICAgICAgICAgICBtZXNzYWdlID0gY29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3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pZiAodXNzZE1lc3NhZ2UgPT0gbnVsbCkgewotICAgICAgICAgICAgICAgIG1lc3NhZ2UgPSBjb250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcubW1pQ29tcGxldGUpOworICAgICAgICAgICAgICAgIG1NZXNzYWdlID0gbUNvbnRleHQuZ2V0VGV4dChjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5tbWlDb21wbGV0ZSk7CiAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgIG1lc3NhZ2UgPSB1c3NkTWVzc2FnZTsKKyAgICAgICAgICAgICAgICBtTWVzc2FnZSA9IHVzc2RNZXNzYWdlOwogICAgICAgICAgICAgfQotICAgICAgICAgICAgdGhpcy5pc1Vzc2RSZXF1ZXN0ID0gaXNVc3NkUmVxdWVzdDsKKyAgICAgICAgICAgIG1Jc1Vzc2RSZXF1ZXN0ID0gaXNVc3NkUmVxdWVzdDsKICAgICAgICAgICAgIC8vIElmIGl0J3MgYSByZXF1ZXN0LCBsZWF2ZSBpdCBQRU5ESU5HIHNvIHRoYXQgaXQncyBjYW5jZWxhYmxlLgogICAgICAgICAgICAgaWYgKCFpc1Vzc2RSZXF1ZXN0KSB7Ci0gICAgICAgICAgICAgICAgc3RhdGUgPSBTdGF0ZS5DT01QTEVURTsKKyAgICAgICAgICAgICAgICBtU3RhdGUgPSBTdGF0ZS5DT01QTEVURTsKICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgcGhvbmUub25NTUlEb25lKHRoaXMpOworICAgICAgICAgICAgbVBob25lLm9uTU1JRG9uZSh0aGlzKTsKICAgICAgICAgfQogICAgIH0KIApAQCAtODY1LDI4ICs4NzAsMjkgQEAKIAogICAgIHZvaWQKICAgICBvblVzc2RGaW5pc2hlZEVycm9yKCkgewotICAgICAgICBpZiAoc3RhdGUgPT0gU3RhdGUuUEVORElORykgewotICAgICAgICAgICAgc3RhdGUgPSBTdGF0ZS5GQUl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lc3NhZ2UoRVZFTlRfVVNTRF9DT01QTEVURSwgdGhpcykpOwogICAgIH0KIAogICAgIC8qKiBDYWxsZWQgZnJvbSBHU01QaG9uZS5oYW5kbGVNZXNzYWdlOyBub3QgYSBIYW5kbGVyIHN1YmNsYXNzICovCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQKICAgICBoYW5kbGVNZXNzYWdlIChNZXNzYWdlIG1zZykgewogICAgICAgICBBc3luY1Jlc3VsdCBhcjsKQEAgLTkzNCwxMCArOTQwLDEwIEBACiAgICAgICAgICAgICAgICAgYXIgPSAoQXN5bmNSZXN1bHQpIChtc2cub2JqKTsKIAogICAgICAgICAgICAgICAgIGlmIChhci5leGNlcHRpb24gIT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICBzdGF0ZSA9IFN0YXRlLkZBSUxFRDsKLSAgICAgICAgICAgICAgICAgICAgbWVzc2FnZSA9IGdldEVycm9yTWVzc2FnZShhcik7CisgICAgICAgICAgICAgICAgICAgIG1TdGF0ZSA9IFN0YXRlLkZBSUxFRDsKKyAgICAgICAgICAgICAgICAgICAgbU1lc3NhZ2UgPSBnZXRFcnJvck1lc3NhZ2UoYXIpOwogCi0gICAgICAgICAgICAgICAgICAgIHBob25lLm9uTU1JRG9uZSh0aGlzKTsKKyAgICAgICAgICAgICAgICAgICAgbVBob25lLm9uTU1JRG9uZSh0aGlzKTsKICAgICAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgICAgICAvLyBOb3RlIHRoYXQgdW5saWtlIG1vc3QgZXZlcnl0aGluZyBlbHNlLCB0aGUgVVNTRCBjb21wbGV0ZQpAQCAtOTQ4LDcgKzk1NCw3IEBACiAgICAgICAgICAgICBicmVhazsKIAogICAgICAgICAgICAgY2FzZSBFVkVOVF9VU1NEX0NBTkNFTF9DT01QTEVURToKLSAgICAgICAgICAgICAgICBwaG9uZS5vbk1NSURvbmUodGhpcyk7CisgICAgICAgICAgICAgICAgbVBob25lLm9uTU1JRG9uZSh0aGlzKTsKICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICB9CiAgICAgfQpAQCAtOTYwLDI5ICs5NjYsMjkgQEAKICAgICAgICAgICAgIENvbW1hbmRFeGNlcHRpb24uRXJyb3IgZXJyID0gKChDb21tYW5kRXhjZXB0aW9uKShhci5leGNlcHRpb24pKS5nZXRDb21tYW5kRXJyb3IoKTsKICAgICAgICAgICAgIGlmIChlcnIgPT0gQ29tbWFuZEV4Y2VwdGlvbi5FcnJvci5GRE5fQ0hFQ0tfRkFJTFVSRSkgewogICAgICAgICAgICAgICAgIFJsb2cuaShMT0dfVEFHLCAiRkROX0NIRUNLX0ZBSUxVUkUiKTsKLSAgICAgICAgICAgICAgICByZXR1cm4gY29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLm1taUZkbkVycm9yKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gbUNvbnRleHQuZ2V0VGV4dChjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5tbWlGZG5FcnJvcik7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KIAotICAgICAgICByZXR1cm4gY29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLm1taUVycm9yKTsKKyAgICAgICAgcmV0dXJuIG1Db250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcubW1pRXJyb3IpOwogICAgIH0KIAogICAgIHByaXZhdGUgQ2hhclNlcXVlbmNlIGdldFNjU3RyaW5nKCkgewotICAgICAgICBpZiAoc2MgIT0gbnVsbCkgewotICAgICAgICAgICAgaWYgKGlzU2VydmljZUNvZGVDYWxsQmFycmluZyhzYykpIHsKLSAgICAgICAgICAgICAgICByZXR1cm4gY29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLkJhTW1pKTsKLSAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNTZXJ2aWNlQ29kZUNhbGxGb3J3YXJkaW5nKHNjKSkgewotICAgICAgICAgICAgICAgIHJldHVybiBjb250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuQ2ZNbWkpOwotICAgICAgICAgICAgfSBlbHNlIGlmIChzYy5lcXVhbHMoU0NfQ0xJUCkpIHsKLSAgICAgICAgICAgICAgICByZXR1cm4gY29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLkNsaXBNbWkpOwotICAgICAgICAgICAgfSBlbHNlIGlmIChzYy5lcXVhbHMoU0NfQ0xJUikpIHsKLSAgICAgICAgICAgICAgICByZXR1cm4gY29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLkNsaXJNbWkpOwotICAgICAgICAgICAgfSBlbHNlIGlmIChzYy5lcXVhbHMoU0NfUFdEKSkgewotICAgICAgICAgICAgICAgIHJldHVybiBjb250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuUHdkTW1pKTsKLSAgICAgICAgICAgIH0gZWxzZSBpZiAoc2MuZXF1YWxzKFNDX1dBSVQpKSB7Ci0gICAgICAgICAgICAgICAgcmV0dXJuIGNvbnRleHQuZ2V0VGV4dChjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5Dd01taSk7CisgICAgICAgIGlmIChtU2MgIT0gbnVsbCkgeworICAgICAgICAgICAgaWYgKGlzU2VydmljZUNvZGVDYWxsQmFycmluZyhtU2MpKSB7CisgICAgICAgICAgICAgICAgcmV0dXJuIG1Db250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuQmFNbWkpOworICAgICAgICAgICAgfSBlbHNlIGlmIChpc1NlcnZpY2VDb2RlQ2FsbEZvcndhcmRpbmcobVNjKSkgeworICAgICAgICAgICAgICAgIHJldHVybiBtQ29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLkNmTW1pKTsKKyAgICAgICAgICAgIH0gZWxzZSBpZiAobVNjLmVxdWFscyhTQ19DTElQKSkgeworICAgICAgICAgICAgICAgIHJldHVybiBtQ29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLkNsaXBNbWkpOworICAgICAgICAgICAgfSBlbHNlIGlmIChtU2MuZXF1YWxzKFNDX0NMSVIpKSB7CisgICAgICAgICAgICAgICAgcmV0dXJuIG1Db250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuQ2xpck1taSk7CisgICAgICAgICAgICB9IGVsc2UgaWYgKG1TYy5lcXVhbHMoU0NfUFdEKSkgeworICAgICAgICAgICAgICAgIHJldHVybiBtQ29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLlB3ZE1taSk7CisgICAgICAgICAgICB9IGVsc2UgaWYgKG1TYy5lcXVhbHMoU0NfV0FJVCkpIHsKKyAgICAgICAgICAgICAgICByZXR1cm4gbUNvbnRleHQuZ2V0VGV4dChjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5Dd01taSk7CiAgICAgICAgICAgICB9IGVsc2UgaWYgKGlzUGluQ29tbWFuZCgpKSB7Ci0gICAgICAgICAgICAgICAgcmV0dXJuIGNvbnRleHQuZ2V0VGV4dChjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5QaW5NbWkpOworICAgICAgICAgICAgICAgIHJldHVybiBtQ29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLlBpbk1taSk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KIApAQCAtOTk1LDc4ICsxMDAxLDc4IEBACiAgICAgICAgIHNiLmFwcGVuZCgiXG4iKTsKIAogICAgICAgICBpZiAoYXIuZXhjZXB0aW9uICE9IG51bGwpIHsKLSAgICAgICAgICAgIHN0YXRlID0gU3RhdGUuRkFJTEVEOworICAgICAgICAgICAgbVN0YXRlID0gU3RhdGUuRkFJTEVEOwogICAgICAgICAgICAgaWYgKGFyLmV4Y2VwdGlvbiBpbnN0YW5jZW9mIENvbW1hbmRFeGNlcHRpb24pIHsKICAgICAgICAgICAgICAgICBDb21tYW5kRXhjZXB0aW9uLkVycm9yIGVyciA9ICgoQ29tbWFuZEV4Y2VwdGlvbikoYXIuZXhjZXB0aW9uKSkuZ2V0Q29tbWFuZEVycm9yKCk7CiAgICAgICAgICAgICAgICAgaWYgKGVyciA9PSBDb21tYW5kRXhjZXB0aW9uLkVycm9yLlBBU1NXT1JEX0lOQ09SUkVDVCkgewogICAgICAgICAgICAgICAgICAgICBpZiAoaXNQaW5Db21tYW5kKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGxvb2sgc3BlY2lmaWNhbGx5IGZvciB0aGUgUFVLIGNvbW1hbmRzIGFuZCBhZGp1c3QKICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHRoZSBtZXNzYWdlIGFjY29yZGluZ2x5LgotICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNjLmVxdWFscyhTQ19QVUspIHx8IHNjLmVxdWFscyhTQ19QVUsyKSkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICAgICAgICAgICAgICBpZiAobVNjLmVxdWFscyhTQ19QVUspIHx8IG1TYy5lcXVhbHMoU0NfUFVLMikpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQobUNvbnRleHQuZ2V0VGV4dCgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLmJhZFB1aykpOwogICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQoY29udGV4dC5nZXRUZXh0KAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChtQ29udGV4dC5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuYmFkUGluKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQoY29udGV4dC5nZXRUZXh0KAorICAgICAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKG1Db250ZXh0LmdldFRleHQoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLnBhc3N3b3JkSW5jb3JyZWN0KSk7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGVyciA9PSBDb21tYW5kRXhjZXB0aW9uLkVycm9yLlNJTV9QVUsyKSB7Ci0gICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChtQ29udGV4dC5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLmJhZFBpbikpOwogICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQoIlxuIik7Ci0gICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChtQ29udGV4dC5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLm5lZWRQdWsyKSk7CiAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChlcnIgPT0gQ29tbWFuZEV4Y2VwdGlvbi5FcnJvci5GRE5fQ0hFQ0tfRkFJTFVSRSkgewogICAgICAgICAgICAgICAgICAgICBSbG9nLmkoTE9HX1RBRywgIkZETl9DSEVDS19GQUlMVVJFIik7Ci0gICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChjb250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcubW1pRmRuRXJyb3IpKTsKKyAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKG1Db250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcubW1pRmRuRXJyb3IpKTsKICAgICAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQoY29udGV4dC5nZXRUZXh0KAorICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQobUNvbnRleHQuZ2V0VGV4dCgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5tbWlFcnJvcikpOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgc2IuYXBwZW5kKGNvbnRleHQuZ2V0VGV4dCgKKyAgICAgICAgICAgICAgICBzYi5hcHBlbmQobUNvbnRleHQuZ2V0VGV4dCgKICAgICAgICAgICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLm1taUVycm9yKSk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0gZWxzZSBpZiAoaXNBY3RpdmF0ZSgpKSB7Ci0gICAgICAgICAgICBzdGF0ZSA9IFN0YXRlLkNPTVBMRVRFOwotICAgICAgICAgICAgaWYgKGlzQ2FsbEZ3ZFJlZykgewotICAgICAgICAgICAgICAgIHNiLmFwcGVuZChjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICBtU3RhdGUgPSBTdGF0ZS5DT01QTEVURTsKKyAgICAgICAgICAgIGlmIChtSXNDYWxsRndkUmVnKSB7CisgICAgICAgICAgICAgICAgc2IuYXBwZW5kKG1Db250ZXh0LmdldFRleHQoCiAgICAgICAgICAgICAgICAgICAgICAgICBjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5zZXJ2aWNlUmVnaXN0ZXJlZCkpOwogICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICBzYi5hcHBlbmQoY29udGV4dC5nZXRUZXh0KAorICAgICAgICAgICAgICAgIHNiLmFwcGVuZChtQ29udGV4dC5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuc2VydmljZUVuYWJsZWQpKTsKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIC8vIFJlY29yZCBDTElSIHNldHRpbmcKLSAgICAgICAgICAgIGlmIChzYy5lcXVhbHMoU0NfQ0xJUikpIHsKLSAgICAgICAgICAgICAgICBwaG9uZS5zYXZlQ2xpclNldHRpbmcoQ29tbWFuZHNJbnRlcmZhY2UuQ0xJUl9JTlZPQ0FUSU9OKTsKKyAgICAgICAgICAgIGlmIChtU2MuZXF1YWxzKFNDX0NMSVIpKSB7CisgICAgICAgICAgICAgICAgbVBob25lLnNhdmVDbGlyU2V0dGluZyhDb21tYW5kc0ludGVyZmFjZS5DTElSX0lOVk9DQVRJT04pOwogICAgICAgICAgICAgfQogICAgICAgICB9IGVsc2UgaWYgKGlzRGVhY3RpdmF0ZSgpKSB7Ci0gICAgICAgICAgICBzdGF0ZSA9IFN0YXRlLkNPTVBMRVRFOwotICAgICAgICAgICAgc2IuYXBwZW5kKGNvbnRleHQuZ2V0VGV4dCgKKyAgICAgICAgICAgIG1TdGF0ZSA9IFN0YXRlLkNPTVBMRVRFOworICAgICAgICAgICAgc2IuYXBwZW5kKG1Db250ZXh0LmdldFRleHQoCiAgICAgICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLnNlcnZpY2VEaXNhYmxlZCkpOwogICAgICAgICAgICAgLy8gUmVjb3JkIENMSVIgc2V0dGluZwotICAgICAgICAgICAgaWYgKHNjLmVxdWFscyhTQ19DTElSKSkgewotICAgICAgICAgICAgICAgIHBob25lLnNhdmVDbGlyU2V0dGluZyhDb21tYW5kc0ludGVyZmFjZS5DTElSX1NVUFBSRVNTSU9OKTsKKyAgICAgICAgICAgIGlmIChtU2MuZXF1YWxzKFNDX0NMSVIpKSB7CisgICAgICAgICAgICAgICAgbVBob25lLnNhdmVDbGlyU2V0dGluZyhDb21tYW5kc0ludGVyZmFjZS5DTElSX1NVUFBSRVNTSU9OKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfSBlbHNlIGlmIChpc1JlZ2lzdGVyKCkpIHsKLSAgICAgICAgICAgIHN0YXRlID0gU3RhdGUuQ09NUExFVEU7Ci0gICAgICAgICAgICBzYi5hcHBlbmQoY29udGV4dC5nZXRUZXh0KAorICAgICAgICAgICAgbVN0YXRlID0gU3RhdGUuQ09NUExFVEU7CisgICAgICAgICAgICBzYi5hcHBlbmQobUNvbnRleHQuZ2V0VGV4dCgKICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuc2VydmljZVJlZ2lzdGVyZWQpKTsKICAgICAgICAgfSBlbHNlIGlmIChpc0VyYXN1cmUoKSkgewotICAgICAgICAgICAgc3RhdGUgPSBTdGF0ZS5DT01QTEVURTsKLSAgICAgICAgICAgIHNiLmFwcGVuZChjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICBtU3RhdGUgPSBTdGF0ZS5DT01QTEVURTsKKyAgICAgICAgICAgIHNiLmFwcGVuZChtQ29udGV4dC5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICBjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5zZXJ2aWNlRXJhc2VkKSk7CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICBzdGF0ZSA9IFN0YXRlLkZBSUxFRDsKLSAgICAgICAgICAgIHNiLmFwcGVuZChjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICBtU3RhdGUgPSBTdGF0ZS5GQUlMRUQ7CisgICAgICAgICAgICBzYi5hcHBlbmQobUNvbnRleHQuZ2V0VGV4dCgKICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcubW1pRXJyb3IpKTsKICAgICAgICAgfQogCi0gICAgICAgIG1lc3NhZ2UgPSBzYjsKLSAgICAgICAgcGhvbmUub25NTUlEb25lKHRoaXMpOworICAgICAgICBtTWVzc2FnZSA9IHNiOworICAgICAgICBtUGhvbmUub25NTUlEb25lKHRoaXMpOwogICAgIH0KIAogICAgIHByaXZhdGUgdm9pZApAQCAtMTA3NSw3ICsxMDgxLDcgQEAKICAgICAgICAgc2IuYXBwZW5kKCJcbiIpOwogCiAgICAgICAgIGlmIChhci5leGNlcHRpb24gIT0gbnVsbCkgewotICAgICAgICAgICAgc3RhdGUgPSBTdGF0ZS5GQUlMRUQ7CisgICAgICAgICAgICBtU3RhdGUgPSBTdGF0ZS5GQUlMRUQ7CiAgICAgICAgICAgICBzYi5hcHBlbmQoZ2V0RXJyb3JNZXNzYWdlKGFyKSk7CiAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICBpbnQgY2xpckFyZ3NbXTsKQEAgLTEwODUsMjEgKzEwOTEsMjEgQEAKICAgICAgICAgICAgIC8vIHRoZSAnbScgcGFyYW1ldGVyIGZyb20gVFMgMjcuMDA3IDcuNwogICAgICAgICAgICAgc3dpdGNoIChjbGlyQXJnc1sxXSkgewogICAgICAgICAgICAgICAgIGNhc2UgMDogLy8gQ0xJUiBub3QgcHJvdmlzaW9uZWQKLSAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKGNvbnRleHQuZ2V0VGV4dCgKKyAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKG1Db250ZXh0LmdldFRleHQoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLnNlcnZpY2VOb3RQcm92aXNpb25lZCkpOwotICAgICAgICAgICAgICAgICAgICBzdGF0ZSA9IFN0YXRlLkNPTVBMRVRFOworICAgICAgICAgICAgICAgICAgICBtU3RhdGUgPSBTdGF0ZS5DT01QTEVURTsKICAgICAgICAgICAgICAgICBicmVhazsKIAogICAgICAgICAgICAgICAgIGNhc2UgMTogLy8gQ0xJUiBwcm92aXNpb25lZCBpbiBwZXJtYW5lbnQgbW9kZQotICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQoY29udGV4dC5nZXRUZXh0KAorICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQobUNvbnRleHQuZ2V0VGV4dCgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuQ0xJUlBlcm1hbmVudCkpOwotICAgICAgICAgICAgICAgICAgICBzdGF0ZSA9IFN0YXRlLkNPTVBMRVRFOworICAgICAgICAgICAgICAgICAgICBtU3RhdGUgPSBTdGF0ZS5DT01QTEVURTsKICAgICAgICAgICAgICAgICBicmVhazsKIAogICAgICAgICAgICAgICAgIGNhc2UgMjogLy8gdW5rbm93biAoZS5nLiBubyBuZXR3b3JrLCBldGMuKQotICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQoY29udGV4dC5nZXRUZXh0KAorICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQobUNvbnRleHQuZ2V0VGV4dCgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcubW1pRXJyb3IpKTsKLSAgICAgICAgICAgICAgICAgICAgc3RhdGUgPSBTdGF0ZS5GQUlMRUQ7CisgICAgICAgICAgICAgICAgICAgIG1TdGF0ZSA9IFN0YXRlLkZBSUxFRDsKICAgICAgICAgICAgICAgICBicmVhazsKIAogICAgICAgICAgICAgICAgIGNhc2UgMzogLy8gQ0xJUiB0ZW1wb3JhcnkgbW9kZSBwcmVzZW50YXRpb24gcmVzdHJpY3RlZApAQCAtMTEwOCwxOSArMTExNCwxOSBAQAogICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGNsaXJBcmdzWzBdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAwOiAvLyBEZWZhdWx0Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKGNvbnRleHQuZ2V0VGV4dCgKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQobUNvbnRleHQuZ2V0VGV4dCgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLkNMSVJEZWZhdWx0T25OZXh0Q2FsbE9uKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMTogLy8gQ0xJUiBpbnZvY2F0aW9uCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKGNvbnRleHQuZ2V0VGV4dCgKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQobUNvbnRleHQuZ2V0VGV4dCgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLkNMSVJEZWZhdWx0T25OZXh0Q2FsbE9uKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMjogLy8gQ0xJUiBzdXBwcmVzc2lvbgotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKG1Db250ZXh0LmdldFRleHQoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5DTElSRGVmYXVsdE9uTmV4dENhbGxPZmYpKTsKICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgIHN0YXRlID0gU3RhdGUuQ09NUExFVEU7CisgICAgICAgICAgICAgICAgICAgIG1TdGF0ZSA9IFN0YXRlLkNPTVBMRVRFOwogICAgICAgICAgICAgICAgIGJyZWFrOwogCiAgICAgICAgICAgICAgICAgY2FzZSA0OiAvLyBDTElSIHRlbXBvcmFyeSBtb2RlIHByZXNlbnRhdGlvbiBhbGxvd2VkCkBAIC0xMTI4LDI2ICsxMTM0LDI2IEBACiAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoY2xpckFyZ3NbMF0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDA6IC8vIERlZmF1bHQKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQoY29udGV4dC5nZXRUZXh0KAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChtQ29udGV4dC5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuQ0xJUkRlZmF1bHRPZmZOZXh0Q2FsbE9mZikpOwogICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDE6IC8vIENMSVIgaW52b2NhdGlvbgotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKG1Db250ZXh0LmdldFRleHQoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5DTElSRGVmYXVsdE9mZk5leHRDYWxsT24pKTsKICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAyOiAvLyBDTElSIHN1cHByZXNzaW9uCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKGNvbnRleHQuZ2V0VGV4dCgKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQobUNvbnRleHQuZ2V0VGV4dCgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLkNMSVJEZWZhdWx0T2ZmTmV4dENhbGxPZmYpKTsKICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgICAgICAgICAgc3RhdGUgPSBTdGF0ZS5DT01QTEVURTsKKyAgICAgICAgICAgICAgICAgICAgbVN0YXRlID0gU3RhdGUuQ09NUExFVEU7CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KIAotICAgICAgICBtZXNzYWdlID0gc2I7Ci0gICAgICAgIHBob25lLm9uTU1JRG9uZSh0aGlzKTsKKyAgICAgICAgbU1lc3NhZ2UgPSBzYjsKKyAgICAgICAgbVBob25lLm9uTU1JRG9uZSh0aGlzKTsKICAgICB9CiAKICAgICAvKioKQEAgLTExNjAsMjEgKzExNjYsMjEgQEAKICAgICBzZXJ2aWNlQ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gICAgICAgICAgIHJldHVybiBjb250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuc2VydmljZUNsYXNzUEFEKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gbUNvbnRleHQuZ2V0VGV4dChjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5zZXJ2aWNlQ2xhc3NQQUQpOwogICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgfQpAQCAtMTE5NywyNCArMTIwMywyNCBAQAogCiAgICAgICAgIGlmIChpbmZvLnN0YXR1cyA9PSAxKSB7CiAgICAgICAgICAgICBpZiAobmVlZFRpbWVUZW1wbGF0ZSkgewotICAgICAgICAgICAgICAgIHRlbXBsYXRlID0gY29udGV4dC5nZXRUZXh0KAorICAgICAgICAgICAgICAgIHRlbXBsYXRlID0gbUNvbnRleHQuZ2V0VGV4dCgKICAgICAgICAgICAgICAgICAgICAgICAgIGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLmNmVGVtcGxhdGVGb3J3YXJkZWRUaW1lKTsKICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgdGVtcGxhdGUgPSBjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICAgICAgdGVtcGxhdGUgPSBtQ29udGV4dC5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuY2ZUZW1wbGF0ZUZvcndhcmRlZCk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0gZWxzZSBpZiAoaW5mby5zdGF0dXMgPT0gMCAmJiBpc0VtcHR5T3JOdWxsKGluZm8ubnVtYmVyKSkgewotICAgICAgICAgICAgdGVtcGxhdGUgPSBjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICB0ZW1wbGF0ZSA9IG1Db250ZXh0LmdldFRleHQoCiAgICAgICAgICAgICAgICAgICAgICAgICBjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5jZlRlbXBsYXRlTm90Rm9yd2FyZGVkKTsKICAgICAgICAgfSBlbHNlIHsgLyogKGluZm8uc3RhdHVzID09IDApICYmICFpc0VtcHR5T3JOdWxsKGluZm8ubnVtYmVyKSAqLwogICAgICAgICAgICAgLy8gQSBjYWxsIGZvcndhcmQgcmVjb3JkIHRoYXQgaXMgbm90IGFjdGl2ZSBidXQgY29udGFpbnMKICAgICAgICAgICAgIC8vIGEgcGhvbmUgbnVtYmVyIGlzIGNvbnNpZGVyZWQgInJlZ2lzdGVyZWQiCiAKICAgICAgICAgICAgIGlmIChuZWVkVGltZVRlbXBsYXRlKSB7Ci0gICAgICAgICAgICAgICAgdGVtcGxhdGUgPSBjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICAgICAgdGVtcGxhdGUgPSBtQ29udGV4dC5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuY2ZUZW1wbGF0ZVJlZ2lzdGVyZWRUaW1lKTsKICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgdGVtcGxhdGUgPSBjb250ZXh0LmdldFRleHQoCisgICAgICAgICAgICAgICAgdGVtcGxhdGUgPSBtQ29udGV4dC5nZXRUZXh0KAogICAgICAgICAgICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuY2ZUZW1wbGF0ZVJlZ2lzdGVyZWQpOwogICAgICAgICAgICAgfQogICAgICAgICB9CkBAIC0xMjQ3LDcgKzEyNTMsNyBAQAogICAgICAgICBzYi5hcHBlbmQoIlxuIik7CiAKICAgICAgICAgaWYgKGFyLmV4Y2VwdGlvbiAhPSBudWxsKSB7Ci0gICAgICAgICAgICBzdGF0ZSA9IFN0YXRlLkZBSUxFRDsKKyAgICAgICAgICAgIG1TdGF0ZSA9IFN0YXRlLkZBSUxFRDsKICAgICAgICAgICAgIHNiLmFwcGVuZChnZXRFcnJvck1lc3NhZ2UoYXIpKTsKICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIENhbGxGb3J3YXJkSW5mbyBpbmZvc1tdOwpAQCAtMTI1Niw3ICsxMjYyLDcgQEAKIAogICAgICAgICAgICAgaWYgKGluZm9zLmxlbmd0aCA9PSAwKSB7CiAgICAgICAgICAgICAgICAgLy8gQXNzdW1lIHRoZSBkZWZhdWx0IGlzIG5vdCBhY3RpdmUKLSAgICAgICAgICAgICAgICBzYi5hcHBlbmQoY29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLnNlcnZpY2VEaXNhYmxlZCkpOworICAgICAgICAgICAgICAgIHNiLmFwcGVuZChtQ29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLnNlcnZpY2VEaXNhYmxlZCkpOwogCiAgICAgICAgICAgICAgICAgLy8gU2V0IHVuY29uZGl0aW9uYWwgQ0ZGIGluIFNJTSB0byBmYWxzZQogICAgICAgICAgICAgICAgIGlmIChtSWNjUmVjb3JkcyAhPSBudWxsKSB7CkBAIC0xMjg3LDExICsxMjkzLDExIEBACiAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKHRiKTsKICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgc3RhdGUgPSBTdGF0ZS5DT01QTEVURTsKKyAgICAgICAgICAgIG1TdGF0ZSA9IFN0YXRlLkNPTVBMRVRFOwogICAgICAgICB9CiAKLSAgICAgICAgbWVzc2FnZSA9IHNiOwotICAgICAgICBwaG9uZS5vbk1NSURvbmUodGhpcyk7CisgICAgICAgIG1NZXNzYWdlID0gc2I7CisgICAgICAgIG1QaG9uZS5vbk1NSURvbmUodGhpcyk7CiAKICAgICB9CiAKQEAgLTEzMDEsNDAgKzEzMDcsNDAgQEAKICAgICAgICAgc2IuYXBwZW5kKCJcbiIpOwogCiAgICAgICAgIGlmIChhci5leGNlcHRpb24gIT0gbnVsbCkgewotICAgICAgICAgICAgc3RhdGUgPSBTdGF0ZS5GQUlMRUQ7CisgICAgICAgICAgICBtU3RhdGUgPSBTdGF0ZS5GQUlMRUQ7CiAgICAgICAgICAgICBzYi5hcHBlbmQoZ2V0RXJyb3JNZXNzYWdlKGFyKSk7CiAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICBpbnRbXSBpbnRzID0gKGludFtdKWFyLnJlc3VsdDsKIAogICAgICAgICAgICAgaWYgKGludHMubGVuZ3RoICE9IDApIHsKICAgICAgICAgICAgICAgICBpZiAoaW50c1swXSA9PSAwKSB7Ci0gICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChjb250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuc2VydmljZURpc2FibGVkKSk7Ci0gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzYy5lcXVhbHMoU0NfV0FJVCkpIHsKKyAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKG1Db250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuc2VydmljZURpc2FibGVkKSk7CisgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChtU2MuZXF1YWxzKFNDX1dBSVQpKSB7CiAgICAgICAgICAgICAgICAgICAgIC8vIENhbGwgV2FpdGluZyBpbmNsdWRlcyBhZGRpdGlvbmFsIGRhdGEgaW4gdGhlIHJlc3BvbnNlLgogICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQoY3JlYXRlUXVlcnlDYWxsV2FpdGluZ1Jlc3VsdE1lc3NhZ2UoaW50c1sxXSkpOwotICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNTZXJ2aWNlQ29kZUNhbGxCYXJyaW5nKHNjKSkgeworICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNTZXJ2aWNlQ29kZUNhbGxCYXJyaW5nKG1TYykpIHsKICAgICAgICAgICAgICAgICAgICAgLy8gaW50c1swXSBmb3IgQ2FsbCBCYXJyaW5nIGlzIGEgYml0IHZlY3RvciBvZiBzZXJ2aWNlcwogICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQoY3JlYXRlUXVlcnlDYWxsQmFycmluZ1Jlc3VsdE1lc3NhZ2UoaW50c1swXSkpOwogICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaW50c1swXSA9PSAxKSB7CiAgICAgICAgICAgICAgICAgICAgIC8vIGZvciBhbGwgb3RoZXIgc2VydmljZXMsIHRyZWF0IGl0IGFzIGEgYm9vbGVhbgotICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQoY29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLnNlcnZpY2VFbmFibGVkKSk7CisgICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZChtQ29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLnNlcnZpY2VFbmFibGVkKSk7CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKGNvbnRleHQuZ2V0VGV4dChjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5tbWlFcnJvcikpOworICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQobUNvbnRleHQuZ2V0VGV4dChjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5tbWlFcnJvcikpOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgc2IuYXBwZW5kKGNvbnRleHQuZ2V0VGV4dChjb20uYW5kcm9pZC5pbnRlcm5hbC5SLnN0cmluZy5tbWlFcnJvcikpOworICAgICAgICAgICAgICAgIHNiLmFwcGVuZChtQ29udGV4dC5nZXR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lRfTkVXX1NNU19TVEFUVVNfUkVQT1JULCBudWxsKTsKLSAgICAgICAgbUNtLnNldE9uTmV3R3NtQnJvYWRjYXN0U21zKHRoaXMsIEVWRU5UX05FV19CUk9BRENBU1RfU01TLCBudWxsKTsKKyAgICAgICAgbURhdGFEb3dubG9hZEhhbmRsZXIgPSBuZXcgVXNpbURhdGFEb3dubG9hZEhhbmRsZXIobUNpKTsKKyAgICAgICAgbUNpLnNldE9uTmV3R3NtU21zKHRoaXMsIEVWRU5UX05FV19TTVMsIG51bGwpOworICAgICAgICBtQ2kuc2V0T25TbXNTdGF0dXModGhpcywgRVZFTlRfTkVXX1NNU19TVEFUVVNfUkVQT1JULCBudWxsKTsKKyAgICAgICAgbUNpLnNldE9uTmV3R3NtQnJvYWRjYXN0U21zKHRoaXMsIEVWRU5UX05FV19CUk9BRENBU1RfU01TLCBudWxsKTsKICAgICB9CiAKICAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBkaXNwb3NlKCkgewotICAgICAgICBtQ20udW5TZXRPbk5ld0dzbVNtcyh0aGlzKTsKLSAgICAgICAgbUNtLnVuU2V0T25TbXNTdGF0dXModGhpcyk7Ci0gICAgICAgIG1DbS51blNldE9uTmV3R3NtQnJvYWRjYXN0U21zKHRoaXMpOworICAgICAgICBtQ2kudW5TZXRPbk5ld0dzbVNtcyh0aGlzKTsKKyAgICAgICAgbUNpLnVuU2V0T25TbXNTdGF0dXModGhpcyk7CisgICAgICAgIG1DaS51blNldE9uTmV3R3NtQnJvYWRjYXN0U21zKHRoaXMpOwogICAgIH0KIAogICAgIEBPdmVycmlkZQpAQCAtMTA1LDEwICsxMDYsMTAgQEAKICAgICAgICAgICAgIEFzeW5jUmVzdWx0IGFyID0gKEFzeW5jUmVzdWx0KSBtc2cub2JqOwogICAgICAgICAgICAgaWYgKGFyLmV4Y2VwdGlvbiA9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgUmxvZy5kKFRBRywgIlN1Y2Nlc3NmdWxseSB3cm90ZSBTTVMtUFAgbWVzc2FnZSB0byBVSUNDIik7Ci0gICAgICAgICAgICAgICAgbUNtLmFja25vd2xlZGdlTGFzdEluY29taW5nR3NtU21zKHRydWUsIDAsIG51bGwpOworICAgICAgICAgICAgICAgIG1DaS5hY2tub3dsZWRnZUxhc3RJbmNvbWluZ0dzbVNtcyh0cnVlLCAwLCBudWxsKTsKICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgUmxvZy5kKFRBRywgIkZhaWxlZCB0byB3cml0ZSBTTVMtUFAgbWVzc2FnZSB0byBVSUNDIiwgYXIuZXhjZXB0aW9uKTsKLSAgICAgICAgICAgICAgICBtQ20uYWNrbm93bGVkZ2VMYXN0SW5jb21pbmdHc21TbXMoZmFsc2UsCisgICAgICAgICAgICAgICAgbUNpLmFja25vd2xlZGdlTGFzdEluY29taW5nR3NtU21zKGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgQ29tbWFuZHNJbnRlcmZhY2UuR1NNX1NNU19GQUlMX0NBVVNFX1VOU1BFQ0lGSUVEX0VSUk9SLCBudWxsKTsKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIGJyZWFrOwpAQCAtMTMxLDcgKzEzMiw3IEBACiAKICAgICAgICAgaWYgKHNtcyAhPSBudWxsKSB7CiAgICAgICAgICAgICBpbnQgdHBTdGF0dXMgPSBzbXMuZ2V0U3RhdHVzKCk7Ci0gICAgICAgICAgICBpbnQgbWVzc2FnZVJlZiA9IHNtcy5tZXNzYWdlUmVmOworICAgICAgICAgICAgaW50IG1lc3NhZ2VSZWYgPSBzbXMubU1lc3NhZ2VSZWY7CiAgICAgICAgICAgICBmb3IgKGludCBpID0gMCwgY291bnQgPSBkZWxpdmVyeVBlbmRpbmdMaXN0LnNpemUoKTsgaSA8IGNvdW50OyBpKyspIHsKICAgICAgICAgICAgICAgICBTbXNUcmFja2VyIHRyYWNrZXIgPSBkZWxpdmVyeVBlbmRpbmdMaXN0LmdldChpK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y5pc013aURvbnRTdG9yZSgpOwotICAgICAgICAgICAgaWYgKGZhbHNlKSB7CisgICAgICAgICAgICBpZiAoVkRCRykgewogICAgICAgICAgICAgICAgIFJsb2cuZChUQUcsICJSZWNlaXZlZCB2b2ljZSBtYWlsIGluZGljYXRvciBzZXQgU01TIHNob3VsZFN0b3JlPSIgKyAhaGFuZGxlZCk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0gZWxzZSBpZiAoc21zLmlzTVdJQ2xlYXJNZXNzYWdlKCkpIHsKICAgICAgICAgICAgIG1QaG9uZS5zZXRWb2ljZU1lc3NhZ2VXYWl0aW5nKDEsIDApOyAgIC8vIGxpbmUgMTogbm8gbXNncyB3YWl0aW5nCiAgICAgICAgICAgICBoYW5kbGVkID0gc21zLmlzTXdpRG9udFN0b3JlKCk7Ci0gICAgICAgICAgICBpZiAoZmFsc2UpIHsKKyAgICAgICAgICAgIGlmIChWREJHKSB7CiAgICAgICAgICAgICAgICAgUmxvZy5kKFRBRywgIlJlY2VpdmVkIHZvaWNlIG1haWwgaW5kaWNhdG9yIGNsZWFyIFNNUyBzaG91bGRTdG9yZT0iICsgIWhhbmRsZWQpOwogICAgICAgICAgICAgfQogICAgICAgICB9CkBAIC0zMDksMTMgKzMxMCwxMyBAQAogICAgICAgICAgICAgICAgIHBkdVsxXSA9IChieXRlKSB0cmFja2VyLm1NZXNzYWdlUmVmOyAvLyBUUC1NUgogICAgICAgICAgICAgfQogICAgICAgICB9Ci0gICAgICAgIG1DbS5zZW5kU01TKEljY1V0aWxzLmJ5dGVzVG9IZXhTdHJpbmcoc21zYyksIEljY1V0aWxzLmJ5dGVzVG9IZXhTdHJpbmcocGR1KSwgcmVwbHkpOworICAgICAgICBtQ2kuc2VuZFNNUyhJY2NVdGlscy5ieXRlc1RvSGV4U3RyaW5nKHNtc2MpLCBJY2NVdGlscy5ieXRlc1RvSGV4U3RyaW5nKHBkdSksIHJlcGx5KTsKICAgICB9CiAKICAgICAvKioge0Bpbmhlcml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ZUNoYW5nZWQodGhpcyk7CisgICAgICAgIG1DaS51blNldE9uTklUWlRpbWUodGhpcyk7CisgICAgICAgIG1Dci51bnJlZ2lzdGVyQ29udGVudE9ic2VydmVyKG1BdXRvVGltZU9ic2VydmVyKTsKKyAgICAgICAgbUNyLnVucmVnaXN0ZXJDb250ZW50T2JzZXJ2ZXIobUF1dG9UaW1lWm9uZU9ic2VydmVyKTsKKyAgICAgICAgbVBob25lLmdldENvbnRleHQoKS51bnJlZ2lzdGVyUmVjZWl2ZXIobUludGVudFJlY2VpdmVyKTsKICAgICAgICAgc3VwZXIuZGlzcG9zZSgpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHByb3RlY3RlZCB2b2lkIGZpbmFsaXplKCkgewogICAgICAgICBpZihEQkcpIGxvZygiZmluYWxpemUiKTsKICAgICB9CiAKICAgICBAT3ZlcnJpZGUKICAgICBwcm90ZWN0ZWQgUGhvbmUgZ2V0UGhvbmUoKSB7Ci0gICAgICAgIHJldHVybiBwaG9uZTsKKyAgICAgICAgcmV0dXJuIG1QaG9uZTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBoYW5kbGVNZXNzYWdlIChNZXNzYWdlIG1zZykgewogICAgICAgICBBc3luY1Jlc3VsdCBhcjsKICAgICAgICAgaW50W10gaW50czsKICAgICAgICAgU3RyaW5nW10gc3RyaW5nczsKICAgICAgICAgTWVzc2FnZSBtZXNzYWdlOwogCi0gICAgICAgIGlmICghcGhvbmUubUlzVGhlQ3VycmVudEFjdGl2ZVBob25lKSB7CisgICAgICAgIGlmICghbVBob25lLm1Jc1RoZUN1cnJlbnRBY3RpdmVQaG9uZSkgewogICAgICAgICAgICAgUmxvZy5lKExPR19UQUcsICJSZWNlaXZlZCBtZXNzYWdlICIgKyBtc2cgKwogICAgICAgICAgICAgICAgICAgICAiWyIgKyBtc2cud2hhdCArICJdIHdoaWxlIGJlaW5nIGRlc3Ryb3llZC4gSWdub3JpbmcuIik7CiAgICAgICAgICAgICByZXR1cm47CkBAIC0yODUsMTQgKzI3MiwxNCBAQAogCiAgICAgICAgICAgICBjYXNlIEVWRU5UX1NJTV9SRUFEWToKICAgICAgICAgICAgICAgICAvLyBTZXQgdGhlIG5ldHdvcmsgdHlwZSwgaW4gY2FzZSB0aGUgcmFkaW8gZG9lcyBub3QgcmVzdG9yZSBpdC4KLSAgICAgICAgICAgICAgICBjbS5zZXRDdXJyZW50UHJlZmVycmVkTmV0d29ya1R5cGUoKTsKKyAgICAgICAgICAgICAgICBtQ2kuc2V0Q3VycmVudFByZWZlcnJlZE5ldHdvcmtUeXBlKCk7CiAKLSAgICAgICAgICAgICAgICBib29sZWFuIHNraXBSZXN0b3JpbmdTZWxlY3Rpb24gPSBwaG9uZS5nZXRDb250ZXh0KCkuZ2V0UmVzb3VyY2VzKCkuZ2V0Qm9vbGVhbigKKyAgICAgICAgICAgICAgICBib29sZWFuIHNraXBSZXN0b3JpbmdTZWxlY3Rpb24gPSBtUGhvbmUuZ2V0Q29udGV4dCgpLmdldFJlc291cmNlcygpLmdldEJvb2xlYW4oCiAgICAgICAgICAgICAgICAgICAgICAgICBjb20uYW5kcm9pZC5pbnRlcm5hbC5SLmJvb2wuc2tpcF9yZXN0b3JpbmdfbmV0d29ya19zZWxlY3Rpb24pOwogCiAgICAgICAgICAgICAgICAgaWYgKCFza2lwUmVzdG9yaW5nU2VsZWN0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgIC8vIHJlc3RvcmUgdGhlIHByZXZpb3VzIG5ldHdvcmsgc2VsZWN0aW9uLgotICAgICAgICAgICAgICAgICAgICBwaG9uZS5yZXN0b3JlU2F2ZWROZXR3b3JrU2VsZWN0aW9uKG51bGwpOworICAgICAgICAgICAgICAgICAgICBtUGhvbmUucmVzdG9yZVNhdmVkTmV0d29ya1NlbGVjdGlvbihudWxsKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgcG9sbFN0YXRlKCk7CiAgICAgICAgICAgICAgICAgLy8gU2lnbmFsIHN0cmVuZ3RoIHBvbGxpbmcgc3RvcHMgd2hlbiByYWRpbyBpcyBvZmYKQEAgLTMxNCw3ICszMDEsNyBAQAogICAgICAgICAgICAgICAgIC8vIFRoaXMgY2FsbGJhY2sgaXMgY2FsbGVkIHdoZW4gc2lnbmFsIHN0cmVuZ3RoIGlzIHBvbGxlZAogICAgICAgICAgICAgICAgIC8vIGFsbCBieSBpdHNlbGYKIAotICAgICAgICAgICAgICAgIGlmICghKGNtLmdldFJhZGlvU3RhdGUoKS5pc09uKCkpKSB7CisgICAgICAgICAgICAgICAgaWYgKCEobUNpLmdldFJhZGlvU3RhdGUoKS5pc09uKCkpKSB7CiAgICAgICAgICAgICAgICAgICAgIC8vIFBvbGxpbmcgd2lsbCBjb250aW51ZSB3aGVuIHJhZGlvIHR1cm5zIGJhY2sgb24KICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgIH0KQEAgLTM0Myw4ICszMzAsOCBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIFJsb2cudyhMT0dfVEFHLCAiZXJyb3IgcGFyc2luZyBsb2NhdGlvbjogIiArIGV4KTsKICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBjZWxsTG9jLnNldExhY0FuZENpZChsYWMsIGNpZCk7Ci0gICAgICAgICAgICAgICAgICAgIHBob25lLm5vdGlmeUxvY2F0aW9uQ2hhbmdlZCgpOworICAgICAgICAgICAgICAgICAgICBtQ2VsbExvYy5zZXRMYWNBbmRDaWQobGFjLCBjaWQpOworICAgICAgICAgICAgICAgICAgICBtUGhvbmUubm90aWZ5TG9jYXRpb25DaGFuZ2VkKCk7CiAgICAgICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAgICAgLy8gUmVsZWFzZSBhbnkgdGVtcG9yYXJ5IGNlbGwgbG9jaywgd2hpY2ggY291bGQgaGF2ZSBiZWVuCkBAIC0zNjQsNyArMzUxLDcgQEAKICAgICAgICAgICAgIGNhc2UgRVZFTlRfUE9MTF9TSUdOQUxfU1RSRU5HVEg6CiAgICAgICAgICAgICAgICAgLy8gSnVzdCBwb2xsIHNpZ25hbCBzdHJlbmd0aC4uLm5vdCBwYXJ0IG9mIHBvbGxTdGF0ZSgpCiAKLSAgICAgICAgICAgICAgICBjbS5nZXRTaWduYWxTdHJlbmd0aChvYnRhaW5NZXNzYWdlKEVWRU5UX0dFVF9TSUdOQUxfU1RSRU5HVEgpKTsKKyAgICAgICAgICAgICAgICBtQ2kuZ2V0U2lnbmFsU3RyZW5ndGgob2J0YWluTWVzc2FnZShFVkVOVF9HRVRfU0lHTkFMX1NUUkVOR1RIKSk7CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAKICAgICAgICAgICAgIGNhc2UgRVZFTlRfTklUWl9USU1FOgpAQCAtMzg0LDcgKzM3MSw3IEBACiAKICAgICAgICAgICAgICAgICAvLyBUaGUgcmFkaW8gaXMgdGVsbGluZyB1cyBhYm91dCBzaWduYWwgc3RyZW5ndGggY2hhbmdlcwogICAgICAgICAgICAgICAgIC8vIHdlIGRvbid0IGhhdmUgdG8gYXNrIGl0Ci0gICAgICAgICAgICAgICAgZG9udFBvbGxTaWduYWxTdHJlbmd0aCA9IHRydWU7CisgICAgICAgICAgICAgICAgbURvbnRQb2xsU2lnbmFsU3RyZW5ndGggPSB0cnVlOwogCiAgICAgICAgICAgICAgICAgb25TaWduYWxTdHJlbmd0aFJlc3VsdChhciwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgYnJlYWs7CkBAIC0zOTcsNyArMzg0LDcgQEAKICAgICAgICAgICAgICAgICBhciA9IChBc3luY1Jlc3VsdCkgbXNnLm9iajsKIAogICAgICAgICAgICAgICAgIGlmIChhci5leGNlcHRpb24gPT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICBjbS5nZXRWb2ljZVJlZ2lzdHJhdGlvblN0YXRlKG9idGFpbk1lc3NhZ2UoRVZFTlRfR0VUX0xPQ19ET05FLCBudWxsKSk7CisgICAgICAgICAgICAgICAgICAgIG1DaS5nZXRWb2ljZVJlZ2lzdHJhdGlvblN0YXRlKG9idGFpbk1lc3NhZ2UoRVZFTlRfR0VUX0xPQ19ET05FLCBudWxsKSk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIGJyZWFrOwogCkBAIC00MDUsNyArMzkyLDcgQEAKICAgICAgICAgICAgICAgICBhciA9IChBc3luY1Jlc3VsdCkgbXNnLm9iajsKICAgICAgICAgICAgICAgICAvLyBEb24ndCBjYXJlIHRoZSByZXN1bHQsIG9ubHkgdXNlIGZvciBkZXJlZyBuZXR3b3JrIChDT1BTPTIpCiAgICAgICAgICAgICAgICAgbWVzc2FnZSA9IG9idGFpbk1lc3NhZ2UoRVZFTlRfUkVTRVRfUFJFRkVSUkVEX05FVFdPUktfVFlQRSwgYXIudXNlck9iaik7Ci0gICAgICAgICAgICAgICAgY20uc2V0UHJlZmVycmVkTmV0d29ya1R5cGUobVByZWZlcnJlZE5ldHdvcmtUeXBlLCBtZXNzYWdlKTsKKyAgICAgICAgICAgICAgICBtQ2kuc2V0UHJlZmVycmVkTmV0d29ya1R5cGUobVByZWZlcnJlZE5ldHdvcmtUeXBlLCBtZXNzYWdlKTsKICAgICAgICAgICAgICAgICBicmVhazsKIAogICAgICAgICAgICAgY2FzZSBFVkVOVF9SRVNFVF9QUkVGRVJSRURfTkVUV09SS19UWVBFOgpAQCAtNDI5LDE4ICs0MTYsMTggQEAKICAgICAgICAgICAgICAgICBtZXNzYWdlID0gb2J0YWluTWVzc2FnZShFVkVOVF9TRVRfUFJFRkVSUkVEX05FVFdPUktfVFlQRSwgYXIudXNlck9iaik7CiAgICAgICAgICAgICAgICAgaW50IHRvZ2dsZWROZXR3b3JrVHlwZSA9IFJJTENvbnN0YW50cy5ORVRXT1JLX01PREVfR0xPQkFMOwogCi0gICAgICAgICAgICAgICAgY20uc2V0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0gdHJ1ZTsKICAgICAgICAgICAgIGlmIChtRW1lcmdlbmN5T25seSkgewogICAgICAgICAgICAgICAgIC8vIE5vIHNlcnZpY2UgYnV0IGVtZXJnZW5jeSBjYWxsIGFsbG93ZWQKQEAgLTUyNSw5ICs1MTMsOSBAQAogICAgICAgICAgICAgfQogICAgICAgICAgICAgaWYgKERCRykgbG9nKCJ1cGRhdGVTcG5EaXNwbGF5OiByYWRpbyBpcyBvbiBidXQgb3V0ICIgKwogICAgICAgICAgICAgICAgICAgICAib2Ygc2VydmljZSwgc2V0IHBsbW49JyIgKyBwbG1uICsgIiciKTsKLSAgICAgICAgfSBlbHNlIGlmIChzcy5nZXRTdGF0ZSgpID09IFNlcnZpY2VTdGF0ZS5TVEFURV9JTl9TRVJWSUNFKSB7CisgICAgICAgIH0gZWxzZSBpZiAobVNTLmdldFZvaWNlUmVnU3RhdGUoKSA9PSBTZXJ2aWNlU3RhdGUuU1RBVEVfSU5fU0VSVklDRSkgewogICAgICAgICAgICAgLy8gSW4gZWl0aGVyIGhvbWUgb3Igcm9hbWluZyBzZXJ2aWNlCi0gICAgICAgICAgICBwbG1uID0gc3MuZ2V0T3BlcmF0b3JBbHBoYUxvbmcoKTsKKyAgICAgICAgICAgIHBsbW4gPSBtU1MuZ2V0T3BlcmF0b3JBbHBoYUxvbmcoKTsKICAgICAgICAgICAgIHNob3dQbG1uID0gIVRleHRVdGlscy5pc0VtcHR5KHBsbW4pICYmCiAgICAgICAgICAgICAgICAgICAgICgocnVsZSAmIFNJTVJlY29yZHMuU1BOX1JVTEVfU0hPV19QTE1OKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgID09IFNJTVJlY29yZHMuU1BOX1JVTEVfU0hPV19QTE1OKTsKQEAgLTU0NiwxMCArNTM0LDEwIEBACiAgICAgICAgICAgICAgICAgICAgICAgICA9PSBTSU1SZWNvcmRzLlNQTl9SVUxFX1NIT1dfU1BOKTsKIAogICAgICAgICAvLyBVcGRhdGUgU1BOX1NUUklOR1NfVVBEQVRFRF9BQ1RJT04gSUZGIGFueSB2YWx1ZSBjaGFuZ2VzCi0gICAgICAgIGlmIChzaG93UGxtbiAhPSBjdXJTaG93UGxtbgotICAgICAgICAgICAgICAgIHx8IHNob3dTcG4gIT0gY3VyU2hvd1NwbgotICAgICAgICAgICAgICAgIHx8ICFUZXh0VXRpbHMuZXF1YWxzKHNwbiwgY3VyU3BuKQotICAgICAgICAgICAgICAgIHx8ICFUZXh0VXRpbHMuZXF1YWxzKHBsbW4sIGN1clBsbW4pKSB7CisgICAgICAgIGlmIChzaG93UGxtbiAhPSBtQ3VyU2hvd1BsbW4KKyAgICAgICAgICAgICAgICB8fCBzaG93U3BuICE9IG1DdXJTaG93U3BuCisgICAgICAgICAgICAgICAgfHwgIVRleHRVdGlscy5lcXVhbHMoc3BuLCBtQ3VyU3BuKQorICAgICAgICAgICAgICAgIHx8ICFUZXh0VXRpbHMuZXF1YWxzKHBsbW4sIG1DdXJQbG1uKSkgewogICAgICAgICAgICAgaWYgKERCRykgewogICAgICAgICAgICAgICAgIGxvZyhTdHJpbmcuZm9ybWF0KCJ1cGRhdGVTcG5EaXNwbGF5OiBjaGFuZ2VkIiArCiAgICAgICAgICAgICAgICAgICAgICAgICAiIHNlbmRpbmcgaW50ZW50IHJ1bGU9IiArIHJ1bGUgKwpAQCAtNTYyLDI0ICs1NTAsMjUgQEAKICAgICAgICAgICAgIGludGVudC5wdXRFeHRyYShUZWxlcGhvbnlJbnRlbnRzLkVYVFJBX1NQTiwgc3BuKTsKICAgICAgICAgICAgIGludGVudC5wdXRFeHRyYShUZWxlcGhvbnlJbnRlbnRzLkVYVFJBX1NIT1dfUExNTiwgc2hvd1BsbW4pOwogICAgICAgICAgICAgaW50ZW50LnB1dEV4dHJhKFRlbGVwaG9ueUludGVudHMuRVhUUkFfUExNTiwgcGxtbik7Ci0gICAgICAgICAgICBwaG9uZS5nZXRDb250ZXh0KCkuc2VuZFN0aWNreUJyb2FkY2FzdEFzVXNlcihpbnRlbnQsIFVzZXJIYW5kbGUuQUxMKTsKKyAgICAgICAgICAgIG1QaG9uZS5nZXRDb250ZXh0KCkuc2VuZFN0aWNreUJyb2FkY2FzdEFzVXNlcihpbnRlbnQsIFVzZXJIYW5kbGUuQUxMKTsKICAgICAgICAgfQogCi0gICAgICAgIGN1clNob3dTcG4gPSBzaG93U3BuOwotICAgICAgICBjdXJTaG93UGxtbiA9IHNob3dQbG1uOwotICAgICAgICBjdXJTcG4gPSBzcG47Ci0gICAgICAgIGN1clBsbW4gPSBwbG1uOworICAgICAgICBtQ3VyU2hvd1NwbiA9IHNob3dTcG47CisgICAgICAgIG1DdXJTaG93UGxtbiA9IHNob3dQbG1uOworICAgICAgICBtQ3VyU3BuID0gc3BuOworICAgICAgICBtQ3VyUGxtbiA9IHBsbW47CiAgICAgfQogCiAgICAgLyoqCiAgICAgICogSGFuZGxlIHRoZSByZXN1bHQgb2Ygb25lIG9mIHRoZSBwb2xsU3RhdGUoKS1yZWxhdGVkIHJlcXVlc3RzCiAgICAgICovCisgICAgQE92ZXJyaWRlCiAgICAgcHJvdGVjdGVkIHZvaWQgaGFuZGxlUG9sbFN0YXRlUmVzdWx0IChpbnQgd2hhdCwgQXN5bmNSZXN1bHQgYXIpIHsKICAgICAgICAgaW50IGludHNbXTsKICAgICAgICAgU3RyaW5nIHN0YXRlc1tdOwogCiAgICAgICAgIC8vIElnbm9yZSBzdGFsZSByZXF1ZXN0cyBmcm9tIGxhc3QgcG9sbAotICAgICAgICBpZiAoYXIudXNlck9iaiAhPSBwb2xsaW5nQ29udGV4dCkgcmV0dXJuOworICAgICAgICBpZiAoYXIudXNlck9iaiAhPSBtUG9sbGluZ0NvbnRleHQpIHJldHVybjsKIAogICAgICAgICBpZiAoYXIuZXhjZXB0aW9uICE9IG51bGwpIHsKICAgICAgICAgICAgIENvbW1hbmRFeGNlcHRpb24uRXJyb3IgZXJyPW51bGw7CkBAIC01OTQsNyArNTgzLDcgQEAKICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgIGlmICghY20uZ2V0UmFkaW9TdGF0ZSgpLmlzT24oKSkgeworICAgICAgICAgICAgaWYgKCFtQ2kuZ2V0UmFkaW9TdGF0ZSgpLmlzT24oKSkgewogICAgICAgICAgICAgICAgIC8vIFJhZGlvIGhhcyBjcmFzaGVkIG9yIHR1cm5lZCBvZmYKICAgICAgICAgICAgICAgICBjYW5jZWxQb2xsU3RhdGUoKTsKICAgICAgICAgICAgICAgICByZXR1cm47CkBAIC02MDYsMTEgKzU5NSwxMiBAQAogICAgICAgICAgICAgfQogICAgICAgICB9IGVsc2UgdHJ5IHsKICAgICAgICAgICAgIHN3aXRjaCAod2hhdCkgewotICAgICAgICAgICAgICAgIGNhc2UgRVZFTlRfUE9MTF9TVEFURV9SRUdJU1RSQVRJT046CisgICAgICAgICAgICAgICAgY2FzZSBFVkVOVF9QT0xMX1NUQVRFX1JFR0lTVFJBVElPTjogewogICAgICAgICAgICAgICAgICAgICBzdGF0ZXMgPSAoU3RyaW5nW10pYXIucmVzdWx0OwogICAgICAgICAgICAgICAgICAgICBpbnQgbGFjID0gLTE7CiAgICAgICAgICAgICAgICAgICAgIGludCBjaWQgPSAtMTsKLSAgICAgICAgICAgICAgICAgICAgaW50IHJlZ1N0YXRlID0gLTE7CisgICAgICAgICAgICAgICAgICAgIGludCB0eXBlID0gU2VydmljZVN0YXRlLlJJTF9SQURJT19URUNITk9MT0dZX1VOS05PV047CisgICAgICAgICAgICAgICAgICAgIGludCByZWdTdGF0ZSA9IFNlcnZpY2VTdGF0ZS5SSUxfUkVHX1NUQVRFX1VOS05PV047CiAgICAgICAgICAgICAgICAgICAgIGludCByZWFzb25SZWdTdGF0ZURlbmllZCA9IC0xOwogICAgICAgICAgICAgICAgICAgICBpbnQgcHNjID0gLTE7CiAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZXMubGVuZ3RoID4gMCkgewpAQCAtNjIzLDYgKzYxMywxMSBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzWzJdICE9IG51bGwgJiYgc3RhdGVzWzJdLmxlbmd0aCgpID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2lkID0gSW50ZWdlci5wYXJzZUludChzdGF0ZXNbMl0sIDE2KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQorCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHN0YXRlc1szXSAoaWYgcHJlc2VudCkgaXMgdGhlIGN1cnJlbnQgcmFkaW8gdGVjaG5vbG9neQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzLmxlbmd0aCA+PSA0ICYmIHN0YXRlc1szXSAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlID0gSW50ZWdlci5wYXJzZUludChzdGF0ZXNbM10pOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZXMubGVuZ3RoID4gMTQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlc1sxNF0gIT0gbnVsbCAmJiBzdGF0ZXNbMTRdLmxlbmd0aCgpID4gMCkgewpAQCAtNjM1LDI0ICs2MzAsMjkgQEAKICAgICAgICAgICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAgICAgICAgIG1Hc21Sb2FtaW5nID0gcmVnQ29kZUlzUm9hbWluZyhyZWdTdGF0ZSk7Ci0gICAgICAgICAgICAgICAgICAgIG5ld1NTLnNldFN0YXRlIChyZWdDb2RlVG9TZXJ2aWNlU3RhdGUocmVnU3RhdGUpKTsKKyAgICAgICAgICAgICAgICAgICAgbU5ld1NTLnNldFN0YXRlKHJlZ0NvZGVUb1NlcnZpY2VTdGF0ZShyZWdTdGF0ZSkpOworICAgICAgICAgICAgICAgICAgICBtTmV3U1Muc2V0UmlsVm9pY2VSYWRpb1RlY2hub2xvZ3kodHlwZSk7CiAKLSAgICAgICAgICAgICAgICAgICAgaWYgKHJlZ1N0YXRlID09IDEwIHx8IHJlZ1N0YXRlID09IDEyIHx8IHJlZ1N0YXRlID09IDEzIHx8IHJlZ1N0YXRlID09IDE0KSB7CisgICAgICAgICAgICAgICAgICAgIGlmIChyZWdTdGF0ZSA9PSBTZXJ2aWNlU3RhdGUuUklMX1JFR19TVEFURV9ERU5JRURfRU1FUkdFTkNZX0NBTExfRU5BQkxFRAorICAgICAgICAgICAgICAgICAgICAgICAgIHx8IHJlZ1N0YXRlID09IFNlcnZpY2VTdGF0ZS5SSUxfUkVHX1NUQVRFX05PVF9SRUdfRU1FUkdFTkNZX0NBTExfRU5BQkxFRAorICAgICAgICAgICAgICAgICAgICAgICAgIHx8IHJlZ1N0YXRlID09IFNlcnZpY2VTdGF0ZS5SSUxfUkVHX1NUQVRFX1NFQVJDSElOR19FTUVSR0VOQ1lfQ0FMTF9FTkFCTEVECisgICAgICAgICAgICAgICAgICAgICAgICAgfHwgcmVnU3RhdGUgPT0gU2VydmljZVN0YXRlLlJJTF9SRUdfU1RBVEVfVU5LTk9XTl9FTUVSR0VOQ1lfQ0FMTF9FTkFCTEVEKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBtRW1lcmdlbmN5T25seSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBtRW1lcmdlbmN5T25seSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgICAgICAgICAgLy8gTEFDIGFuZCBDSUQgYXJlIC0xIGlmIG5vdCBhdmFpbAotICAgICAgICAgICAgICAgICAgICBuZXdDZWxsTG9jLnNldExhY0FuZENpZChsYWMsIGNpZCk7Ci0gICAgICAgICAgICAgICAgICAgIG5ld0NlbGxMb2Muc2V0UHNjKHBzYyk7Ci0gICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgICAgIG1OZXdDZWxsTG9jLnNldExhY0FuZENpZChsYWMsIGNpZCk7CisgICAgICAgICAgICAgICAgICAgIG1OZXdDZWxsTG9jLnNldFBzYyhwc2MpOworICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgICAgICBjYXNlIEVWRU5UX1BPTExfU1RBVEVfR1BSUzoKKyAgICAgICAgICAgICAgICBjYXNlIEVWRU5UX1BPTExfU1RBVEVfR1BSUzogewogICAgICAgICAgICAgICAgICAgICBzdGF0ZXMgPSAoU3RyaW5nW10pYXIucmVzdWx0OwogCiAgICAgICAgICAgICAgICAgICAgIGludCB0eXBlID0gMDsKLSAgICAgICAgICAgICAgICAgICAgcmVnU3RhdGUgPSAtMTsKKyAgICAgICAgICAgICAgICAgICAgaW50IHJlZ1N0YXRlID0gU2VydmljZVN0YXRlLlJJTF9SRUdfU1RBVEVfVU5LTk9XTjsKICAgICAgICAgICAgICAgICAgICAgbU5ld1JlYXNvbkRhdGFEZW5pZWQgPSAtMTsKICAgICAgICAgICAgICAgICAgICAgbU5ld01heERhdGFDYWxscyA9IDE7CiAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZXMubGVuZ3RoID4gMCkgewpAQCAtNjYzLDcgKzY2Myw4IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlcy5sZW5ndGggPj0gNCAmJiBzdGF0ZXNbM10gIT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlID0gSW50ZWdlci5wYXJzZUludChzdGF0ZXNbM10pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoKHN0YXRlcy5sZW5ndGggPj0gNSApICYmIChyZWdTdGF0ZSA9PSAzKSkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgoc3RhdGVzLmxlbmd0aCA+PSA1ICkgJiYKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChyZWdTdGF0ZSA9PSBTZXJ2aWNlU3RhdGUuUklMX1JFR19TVEFURV9ERU5JRUQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1OZXdSZWFzb25EYXRhRGVuaWVkID0gSW50ZWdlci5wYXJzZUludChzdGF0ZXNbNF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVzLmxlbmd0aCA+PSA2KSB7CkBAIC02NzMsNDAgKzY3NCw0MSBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvZ2UoImVycm9yIHBhcnNpbmcgR3Byc1JlZ2lzdHJhdGlvblN0YXRlOiAiICsgZXgpOwogICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgIG5ld0dQUlNTdGF0ZSA9IHJlZ0NvZGVUb1NlcnZpY2VTdGF0ZShyZWdTdGF0ZSk7CisgICAgICAgICAgICAgICAgICAgIGludCBkYXRhUmVnU3RhdGUgPSByZWdDb2RlVG9TZXJ2aWNlU3RhdGUocmVnU3RhdGUpOworICAgICAgICAgICAgICAgICAgICBtTmV3U1Muc2V0RGF0YVJlZ1N0YXRlKGRhdGFSZWdTdGF0ZSk7CiAgICAgICAgICAgICAgICAgICAgIG1EYXRhUm9hbWluZyA9IHJlZ0NvZGVJc1JvYW1pbmcocmVnU3RhdGUpOwotICAgICAgICAgICAgICAgICAgICBtTmV3UmlsUmFkaW9UZWNobm9sb2d5ID0gdHlwZTsKLSAgICAgICAgICAgICAgICAgICAgbmV3U1Muc2V0UmFkaW9UZWNobm9sb2d5KHR5cGUpOwotICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICBtTmV3U1Muc2V0UmlsRGF0YVJhZGlvVGVjaG5vbG9neSh0eXBlKTsKKyAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgeworICAgICAgICAgICAgICAgICAgICAgICAgbG9nKCJoYW5kbFBvbGxTdGF0ZVJlc3VsdE1lc3NhZ2U6IEdzbVNTVCBzZXREYXRhUmVnU3RhdGU9IiArIGRhdGFSZWdTdGF0ZQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArICIgcmVnU3RhdGU9IiArIHJlZ1N0YXRlCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgIiBkYXRhUmFkaW9UZWNobm9sb2d5PSIgKyB0eXBlKTsKKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgICAgICBjYXNlIEVWRU5UX1BPTExfU1RBVEVfT1BFUkFUT1I6CisgICAgICAgICAgICAgICAgY2FzZSBFVkVOVF9QT0xMX1NUQVRFX09QRVJBVE9SOiB7CiAgICAgICAgICAgICAgICAgICAgIFN0cmluZyBvcE5hbWVzW10gPSAoU3RyaW5nW10pYXIucmVzdWx0OwogCiAgICAgICAgICAgICAgICAgICAgIGlmIChvcE5hbWVzICE9IG51bGwgJiYgb3BOYW1lcy5sZW5ndGggPj0gMykgewotICAgICAgICAgICAgICAgICAgICAgICAgIG5ld1NTLnNldE9wZXJhdG9yTmFtZSAob3BOYW1lc1swXSwgb3BOYW1lc1sxXSwgb3BOYW1lc1syXSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgbU5ld1NTLnNldE9wZXJhdG9yTmFtZSAob3BOYW1lc1swXSwgb3BOYW1lc1sxXSwgb3BOYW1lc1syXSk7CiAgICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgfQogCi0gICAgICAgICAgICAgICAgY2FzZSBFVkVOVF9QT0xMX1NUQVRFX05FVFdPUktfU0VMRUNUSU9OX01PREU6CisgICAgICAgICAgICAgICAgY2FzZSBFVkVOVF9QT0xMX1NUQVRFX05FVFdPUktfU0VMRUNUSU9OX01PREU6IHsKICAgICAgICAgICAgICAgICAgICAgaW50cyA9IChpbnRbXSlhci5yZXN1bHQ7Ci0gICAgICAgICAgICAgICAgICAgIG5ld1NTLnNldElzTWFudWFsU2VsZWN0aW9uKGludHNbMF0gPT0gMSk7Ci0gICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgICAgIG1OZXdTUy5zZXRJc01hbnVhbFNlbGVjdGlvbihpbnRzWzBdID09IDEpOworICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CiAKICAgICAgICAgfSBjYXRjaCAoUnVudGltZUV4Y2VwdGlvbiBleCkgewogICAgICAgICAgICAgbG9nZSgiRXhjZXB0aW9uIHdoaWxlIHBvbGxpbmcgc2VydmljZSBzdGF0ZS4gUHJvYmFibHkgbWFsZm9ybWVkIFJJTCByZXNwb25zZS4iICsgZXgpOwogICAgICAgICB9CiAKLSAgICAgICAgZmluYWwgYm9vbGVhbiB2b2ljZV9jYXBhYmxlID0gcGhvbmUuZ2V0Q29udGV4dCgpLmdldFJlc291cmNlcygpLmdldEJvb2xlYW4oCi0gICAgICAgICAgICAgICAgY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5ib29sLmNvbmZpZ192b2ljZV9jYXBhYmxlKTsKKyAgICAgICAgbVBvbGxpbmdDb250ZXh0WzBdLS07CiAKLSAgICAgICAgaWYgKCF2b2ljZV9jYXBhYmxlICYmIG5ld0dQUlNTdGF0ZSA9PSBTZXJ2aWNlU3RhdGUuU1RBVEVfSU5fU0VSVklDRSkgewotICAgICAgICAgICAgbmV3U1Muc2V0U3RhdGUgKG5ld0dQUlNTdGF0ZSk7Ci0gICAgICAgIH0KLQ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sbFN0YXRlRG9uZSgpOwogICAgICAgICB9CiAgICAgfQpAQCAtNzM5LDE0ICs3NDEsMTMgQEAKICAgICAgKiBldmVudCBoYXMgY2hhbmdlZAogICAgICAqLwogICAgIHByaXZhdGUgdm9pZCBwb2xsU3RhdGUoKSB7Ci0gICAgICAgIHBvbGxpbmdDb250ZXh0ID0gbmV3IGludFsxXTsKLSAgICAgICAgcG9sbGluZ0NvbnRleHRbMF0gPSAwOworICAgICAgICBtUG9sbGluZ0NvbnRleHQgPSBuZXcgaW50WzFdOworICAgICAgICBtUG9sbGluZ0NvbnRleHRbMF0gPSAwOwogCi0gICAgICAgIHN3aXRjaCAoY20uZ2V0UmFkaW9TdGF0ZSgpKSB7CisgICAgICAgIHN3aXRjaCAobUNpLmdldFJhZGlvU3RhdGUoKSkgewogICAgICAgICAgICAgY2FzZSBSQURJT19VTkFWQUlMQUJMRToKLSAgICAgICAgICAgICAgICBuZXdTUy5zZXRTdGF0ZU91dE9mU2VydmljZSgpOwotICAgICAgICAgICAgICAgIG5ld0dQUlNTdGF0ZSA9IFNlcnZpY2VTdGF0ZS5TVEFURV9PVVRfT0ZfU0VSVklDRTsKLSAgICAgICAgICAgICAgICBuZXdDZWxsTG9jLnNldFN0YXRlSW52YWxpZCgpOworICAgICAgICAgICAgICAgIG1OZXdTUy5zZXRTdGF0ZU91dE9mU2VydmljZSgpOworICAgICAgICAgICAgICAgIG1OZXdDZWxsTG9jLnNldFN0YXRlSW52YWxpZCgpOwogICAgICAgICAgICAgICAgIHNldFNpZ25hbFN0cmVuZ3RoRGVmYXVsdFZhbHVlcygpOwogICAgICAgICAgICAgICAgIG1Hb3RDb3VudHJ5Q29kZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgIG1OaXR6VXBkYXRlZFRpbWUgPSBmYWxzZTsKQEAgLTc1NCw5ICs3NTUsOCBAQAogICAgICAgICAgICAgYnJlYWs7CiAKICAgICAgICAgICAgIGNhc2UgUkFESU9fT0ZGOgotICAgICAgICAgICAgICAgIG5ld1NTLnNldFN0YXRlT2ZmKCk7Ci0gICAgICAgICAgICAgICAgbmV3R1BSU1N0YXRlID0gU2VydmljZVN0YXRlLlNUQVRFX1BPV0VSX09GRjsKLSAgICAgICAgICAgICAgICBuZXdDZWxsTG9jLnNldFN0YXRlSW52YWxpZCgpOworICAgICAgICAgICAgICAgIG1OZXdTUy5zZXRTdGF0ZU9mZigpOworICAgICAgICAgICAgICAgIG1OZXdDZWxsTG9jLnNldFN0YXRlSW52YWxpZCgpOwogICAgICAgICAgICAgICAgIHNldFNpZ25hbFN0cmVuZ3RoRGVmYXVsdFZhbHVlcygpOwogICAgICAgICAgICAgICAgIG1Hb3RDb3VudHJ5Q29kZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgIG1OaXR6VXBkYXRlZFRpbWUgPSBmYWxzZTsKQEAgLTc2OCwyNSArNzY4LDI1IEBACiAgICAgICAgICAgICAgICAgLy8gdGhlbiBjb3VudCBkb3duIHRoZSByZXNwb25zZXMsIHdoaWNoCiAgICAgICAgICAgICAgICAgLy8gYXJlIGFsbG93ZWQgdG8gYXJyaXZlIG91dC1vZi1vcmRlcgogCi0gICAgICAgICAgICAgICAgcG9sbGluZ0NvbnRleHRbMF0rKzsKLSAgICAgICAgICAgICAgICBjbS5nZXRPcGVyYXRvcigKKyAgICAgICAgICAgICAgICBtUG9sbGluZ0NvbnRleHRbMF0rKzsKKyAgICAgICAgICAgICAgICBtQ2kuZ2V0T3BlcmF0b3IoCiAgICAgICAgICAgICAgICAgICAgIG9idGFpbk1lc3NhZ2UoCi0gICAgICAgICAgICAgICAgICAgICAgICBFVkVOVF9QT0xMX1NUQVRFX09QRVJBVE9SLCBwb2xsaW5nQ29udGV4dCkpOworICAgICAgICAgICAgICAgICAgICAgICAgRVZFTlRfUE9MTF9TVEFURV9PUEVSQVRPUiwgbVBvbGxpbmdDb250ZXh0KSk7CiAKLSAgICAgICAgICAgICAgICBwb2xsaW5nQ29udGV4dFswXSsrOwotICAgICAgICAgICAgICAgIGNtLmdldERhdGFSZWdpc3RyYXRpb25TdGF0ZSgKKyAgICAgICAgICAgICAgICBtUG9sbGluZ0NvbnRleHRbMF0rKzsKKyAgICAgICAgICAgICAgICBtQ2kuZ2V0RGF0YVJlZ2lzdHJhdGlvblN0YXRlKAogICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKAotICAgICAgICAgICAgICAgICAgICAgICAgRVZFTlRfUE9MTF9TVEFURV9HUFJTLCBwb2xsaW5nQ29udGV4dCkpOworICAgICAgICAgICAgICAgICAgICAgICAgRVZFTlRfUE9MTF9TVEFURV9HUFJTLCBtUG9sbGluZ0NvbnRleHQpKTsKIAotICAgICAgICAgICAgICAgIHBvbGxpbmdDb250ZXh0WzBdKys7Ci0gICAgICAgICAgICAgICAgY20uZ2V0Vm9pY2VSZWdpc3RyYXRpb25TdGF0ZSgKKyAgICAgICAgICAgICAgICBtUG9sbGluZ0NvbnRleHRbMF0rKzsKKyAgICAgICAgICAgICAgICBtQ2kuZ2V0Vm9pY2VSZWdpc3RyYXRpb25TdGF0ZSgKICAgICAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZSgKLSAgICAgICAgICAgICAgICAgICAgICAgIEVWRU5UX1BPTExfU1RBVEVfUkVHSVNUUkFUSU9OLCBwb2xsaW5nQ29udGV4dCkpOworICAgICAgICAgICAgICAgICAgICAgICAgRVZFTlRfUE9MTF9TVEFURV9SRUdJU1RSQVRJT04sIG1Qb2xsaW5nQ29udGV4dCkpOwogCi0gICAgICAgICAgICAgICAgcG9sbGluZ0NvbnRleHRbMF0rKzsKLSAgICAgICAgICAgICAgICBjbS5nZXROZXR3b3JrU2VsZWN0aW9uTW9kZSgKKyAgICAgICAgICAgICAgICBtUG9sbGluZ0NvbnRleHRbMF0rKzsKKyAgICAgICAgICAgICAgICBtQ2kuZ2V0TmV0d29ya1NlbGVjdGlvbk1vZGUoCiAgICAgICAgICAgICAgICAgICAgIG9idGFpbk1lc3NhZ2UoCi0gICAgICAgICAgICAgICAgICAgICAgICBFVkVOVF9QT0xMX1NUQVRFX05FVFdPUktfU0VMRUNUSU9OX01PREUsIHBvbGxpbmdDb250ZXh0KSk7CisgICAgICAgICAgICAgICAgICAgICAgICBFVkVOVF9QT0xMX1NUQVRFX05FVFdPUktfU0VMRUNUSU9OX01PREUsIG1Qb2xsaW5nQ29udGV4dCkpOwogICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIH0KICAgICB9CkBAIC03OTQsODggKzc5NCw4NSBAQAogICAgIHByaXZhdGUgdm9pZCBwb2xsU3RhdGVEb25lKCkgewogICAgICAgICBpZiAoREJHKSB7CiAgICAgICAgICAgICBsb2coIlBvbGwgU2VydmljZVN0YXRlIGRvbmU6ICIgKwotICAgICAgICAgICAgICAgICIgb2xkU1M9WyIgKyBzcyArICJdIG5ld1NTPVsiICsgbmV3U1MgKwotICAgICAgICAgICAgICAgICJdIG9sZEdwcnM9IiArIGdwcnNTdGF0ZSArICIgbmV3RGF0YT0iICsgbmV3R1BSU1N0YXRlICsKKyAgICAgICAgICAgICAgICAiIG9sZFNTPVsiICsgbVNTICsgIl0gbmV3U1M9WyIgKyBtTmV3U1MgKyAiXSIgKwogICAgICAgICAgICAgICAgICIgb2xkTWF4RGF0YUNhbGxzPSIgKyBtTWF4RGF0YUNhbGxzICsKICAgICAgICAgICAgICAgICAiIG1OZXdNYXhEYXRhQ2FsbHM9IiArIG1OZXdNYXhEYXRhQ2FsbHMgKwogICAgICAgICAgICAgICAgICIgb2xkUmVhc29uRGF0YURlbmllZD0iICsgbVJlYXNvbkRhdGFEZW5pZWQgKwotICAgICAgICAgICAgICAgICIgbU5ld1JlYXNvbkRhdGFEZW5pZWQ9IiArIG1OZXdSZWFzb25EYXRhRGVuaWVkICsKLSAgICAgICAgICAgICAgICAiIG9sZFR5cGU9IiArIFNlcnZpY2VTdGF0ZS5yaWxSYWRpb1RlY2hub2xvZ3lUb1N0cmluZyhtUmlsUmFkaW9UZWNobm9sb2d5KSAr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E9SX0lTT19DT1VOVFJZLCAiIik7CiAgICAgICAgICAgICAgICAgbUdvdENvdW50cnlDb2RlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgbU5pdHpVcGRhdGVkVGltZSA9IGZhbHNlOwogICAgICAgICAgICAgfSBlbHNlIHsKQEAgLTkxOCw3ICs5MTUsNyBAQAogICAgICAgICAgICAgICAgICAgICBsb2dlKCJwb2xsU3RhdGVEb25lOiBjb3VudHJ5Q29kZUZvck1jYyBlcnJvciIgKyBleCk7CiAgICAgICAgICAgICAgICAgfQogCi0gICAgICAgICAgICAgICAgcGhvbmUuc2V0U3lzdGVtUHJvcGVydHkoVGVsZXBob255UHJvcGVydGllcy5QUk9QRVJUWV9PUEVSQVRPUl9JU09fQ09VTlRSWSwgaXNvKTsKKyAgICAgICAgICAgICAgICBtUGhvbmUuc2V0U3lzdGVtUHJvcGVydHkoVGVsZXBob255UHJvcGVydGllcy5QUk9QRVJUWV9PUEVSQVRPUl9JU09fQ09VTlRSWSwgaXNvKTsKICAgICAgICAgICAgICAgICBtR290Q291bnRyeUNvZGUgPSB0cnVlOwogCiAgICAgICAgICAgICAgICAgVGltZVpvbmUgem9uZSA9IG51bGw7CkBAIC05NTAsNyArOTQ3LDcgQEAKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgICAgIGlmIChzaG91bGRGaXhUaW1lWm9uZU5vdyhwaG9uZSwgb3BlcmF0b3JOdW1lcmljLCBwcmV2T3BlcmF0b3JOdW1lcmljLAorICAgICAgICAgICAgICAgIGlmIChzaG91bGRGaXhUaW1lWm9uZU5vdyhtUGhvbmUsIG9wZXJhdG9yTnVtZXJpYywgcHJldk9wZXJhdG9yTnVtZXJpYywKICAgICAgICAgICAgICAgICAgICAgICAgIG1OZWVkRml4Wm9uZUFmdGVyTml0eikpIHsKICAgICAgICAgICAgICAgICAgICAgLy8gSWYgdGhlIG9mZnNldCBpcyAoMCwgZmFsc2UpIGFuZCB0aGUgdGltZXpvbmUgcHJvcGVydHkKICAgICAgICAgICAgICAgICAgICAgLy8gaXMgc2V0LCB1c2UgdGhlIHRpbWV6b25lIHByb3BlcnR5IHJhdGhlciB0aGFuCkBAIC0xMDE3LDEwICsxMDE0LDEwIEBACiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogCi0gICAgICAgICAgICBwaG9uZS5zZXRTeXN0ZW1Qcm9wZXJ0eShUZWxlcGhvbnlQcm9wZXJ0aWVzLlBST1BFUlRZX09QRVJBVE9SX0lTUk9BTUlORywKLSAgICAgICAgICAgICAgICBzcy5nZXRSb2FtaW5nKCkgPyAidHJ1ZSIgOiAiZmFsc2UiKTsKKyAgICAgICAgICAgIG1QaG9uZS5zZXRTeXN0ZW1Qcm9wZXJ0eShUZWxlcGhvbnlQcm9wZXJ0aWVzLlBST1BFUlRZX09QRVJBVE9SX0lTUk9BTUlORywKKyAgICAgICAgICAgICAgICBtU1MuZ2V0Um9hbWluZygpID8gInRydWUiIDogImZhbHNlIik7CiAKLSAgICAgICAgICAgIHBob25lLm5vdGlmeVNlcnZpY2VTdGF0ZUNoYW5nZWQoc3MpOworICAgICAgICAgICAgbVBob25lLm5vdGlmeVNlcnZpY2VTdGF0ZUNoYW5nZWQobVNTKTsKICAgICAgICAgfQogCiAgICAgICAgIGlmIChoYXNHcHJzQXR0YWNoZWQpIHsKQEAgLTEwMzEsOCArMTAyOCw4IEBACiAgICAgICAgICAgICBtRGV0YWNoZWRSZWdpc3RyYW50cy5ub3RpZnlSZWdpc3RyYW50cygpOwogICAgICAgICB9CiAKLSAgICAgICAgaWYgKGhhc1JhZGlvVGVjaG5vbG9neUNoYW5nZWQpIHsKLSAgICAgICAgICAgIHBob25lLm5vdGlmeURhdGFDb25uZWN0aW9uKFBob25lLlJFQVNPTl9OV19UWVBFX0NIQU5HRUQpOworICAgICAgICBpZiAoaGFzUmlsVm9pY2VSYWRpb1RlY2hub2xvZ3lDaGFuZ2VkKSB7CisgICAgICAgICAgICBtUGhvbmUubm90aWZ5RGF0YUNvbm5lY3Rpb24oUGhvbmUuUkVBU09OX05XX1RZUEVfQ0hBTkdFRCk7CiAgICAgICAgIH0KIAogICAgICAgICBpZiAoaGFzUm9hbWluZ09uKSB7CkBAIC0xMDQ0LDE1ICsxMDQxLDE1IEBACiAgICAgICAgIH0KIAogICAgICAgICBpZiAoaGFzTG9jYXRpb25DaGFuZ2VkKSB7Ci0gICAgICAgICAgICBwaG9uZS5ub3RpZnlMb2NhdGlvbkNoYW5nZWQoKTsKKyAgICAgICAgICAgIG1QaG9uZS5ub3RpZnlMb2NhdGlvbkNoYW5nZWQoKTsKICAgICAgICAgfQogCi0gICAgICAgIGlmICghIGlzR3Byc0NvbnNpc3RlbnQoZ3Byc1N0YXRlLCBzcy5nZXRTdGF0ZSgpKSkgeworICAgICAgICBpZiAoISBpc0dwcnNDb25zaXN0ZW50KG1TUy5nZXREYXRhUmVnU3RhdGUoKSwgbVNTLmdldFZvaWNlUmVnU3RhdGUoKSkpIHsKICAgICAgICAgICAgIGlmICghbVN0YXJ0ZWRHcHJzUmVnQ2hlY2sgJiYgIW1SZXBvcnRlZEdwcnNOb1JlZykgewogICAgICAgICAgICAgICAgIG1TdGFydGVkR3Byc1JlZ0NoZWNrID0gdHJ1ZTsKIAogICAgICAgICAgICAgICAgIGludCBjaGVja19wZXJpb2QgPSBTZXR0aW5ncy5HbG9iYWwuZ2V0SW50KAotICAgICAgICAgICAgICAgICAgICAgICAgcGhvbmUuZ2V0Q29udGV4dCgpLmdldENvbnRlbnRSZXNvbHZlcigpLAorICAgICAgICAgICAgICAgICAgICAgICAgbVBob25lLmdldENvbnRleHQoKS5nZXRDb250ZW50UmVzb2x2ZXIoKSwKICAgICAgICAgICAgICAgICAgICAgICAgIFNldHRpbmdzLkdsb2JhbC5HUFJTX1JFR0lTVEVSX0NIRUNLX1BFUklPRF9NUywKICAgICAgICAgICAgICAgICAgICAgICAgIERFRkFVTFRfR1BSU19DSEVDS19QRVJJ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zQ29uY3VycmVudFZvaWNlQW5kRGF0YUFsbG93ZWQoKSB7Ci0gICAgICAgIHJldHVybiAobVJpbFJhZGlvVGVjaG5vbG9neSA+PSBTZXJ2aWNlU3RhdGUuUklMX1JBRElPX1RFQ0hOT0xPR1lfVU1UUyk7Ci0gICAgfQotCi0gICAgLyoqCi0gICAgICogUHJvdmlkZXMgdGhlIG5hbWUgb2YgdGhlIGFsZ29yaXRobWljIHRpbWUgem9uZSBmb3IgdGhlIHNwZWNpZmllZAotICAgICAqIG9mZnNldC4gIFRha2VuIGZyb20gVGltZVpvbmUuamF2YS4KLSAgICAgKi8KLSAgICBwcml2YXRlIHN0YXRpYyBTdHJpbmcgZGlzcGxheU5hbWVGb3IoaW50IG9mZikgewotICAgICAgICBvZmYgPSBvZmYgLyAxMDAwIC8gNjA7Ci0KLSAgICAgICAgY2hhcltdIGJ1ZiA9IG5ldyBjaGFyWzldOwotICAgICAgICBidWZbMF0gPSAnRyc7Ci0gICAgICAgIGJ1ZlsxXSA9ICdNJzsKLSAgICAgICAgYnVmWzJdID0gJ1QnOwotCi0gICAgICAgIGlmIChvZmYgPCAwKSB7Ci0gICAgICAgICAgICBidWZbM10gPSAnLSc7Ci0gICAgICAgICAgICBvZmYgPSAtb2ZmOwotICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgYnVmWzNdID0gJysnOwotICAgICAgICB9Ci0KLSAgICAgICAgaW50IGhvdXJzID0gb2ZmIC8gNjA7Ci0gICAgICAgIGludCBtaW51dGVzID0gb2ZmICUgNjA7Ci0KLSAgICAgICAgYnVmWzRdID0gKGNoYXIpICgnMCcgKyBob3VycyAvIDEwKTsKLSAgICAgICAgYnVmWzVdID0gKGNoYXIpICgnMCcgKyBob3VycyAlIDEwKTsKLQotICAgICAgICBidWZbNl0gPSAnOic7Ci0KLSAgICAgICAgYnVmWzddID0gKGNoYXIpICgnMCcgKyBtaW51dGVzIC8gMTApOwotICAgICAgICBidWZbOF0gPSAoY2hhcikgKCcwJyArI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VyKSBwaG9uZS5nZXRDb250ZXh0KCkuZ2V0U3lzdGVtU2VydmljZShDb250ZXh0LkFMQVJNX1NFUlZJQ0UpOworICAgICAgICAgICAgKEFsYXJtTWFuYWdlcikgbVBob25lLmdldENvbnRleHQoKS5nZXRTeXN0ZW1TZXJ2aWNlKENvbnRleHQuQUxBUk1fU0VSVklDRSk7CiAgICAgICAgIGFsYXJtLnNldFRpbWVab25lKHpvbmVJZCk7CiAgICAgICAgIEludGVudCBpbnRlbnQgPSBuZXcgSW50ZW50KFRlbGVwaG9ueUludGVudHMuQUNUSU9OX05FVFdPUktfU0VUX1RJTUVaT05FKTsKICAgICAgICAgaW50ZW50LmFkZEZsYWdzKEludGVudC5GTEFHX1JFQ0VJVkVSX1JFUExBQ0VfUEVORElORyk7CiAgICAgICAgIGludGVudC5wdXRFeHRyYSgidGltZS16b25lIiwgem9uZUlkKTsKLSAgICAgICAgcGhvbmUuZ2V0Q29udGV4dCgpLnNlbmRTdGlja3lCcm9hZGNhc3RBc1VzZXIoaW50ZW50LCBVc2VySGFuZGxlLkFMTCk7CisgICAgICAgIG1QaG9uZS5nZXRDb250ZXh0KCkuc2VuZFN0aWNreUJyb2FkY2FzdEFzVXNlcihpbnRlbnQsIFVzZXJIYW5kbGUuQUxMKTsKICAgICAgICAgaWYgKERCRykgewogICAgICAgICAgICAgbG9nKCJzZXRBbmRCcm9hZGNhc3ROZXR3b3JrU2V0VGltZVpvbmU6IGNhbGwgYWxhcm0uc2V0VGltZVpvbmUgYW5kIGJyb2FkY2FzdCB6b25lSWQ9IiArCiAgICAgICAgICAgICAgICAgem9uZUlkKTsKQEAgLTE1ODMsMTIgKzE1MzAsMTIgQEAKICAgICAgICAgSW50ZW50IGludGVudCA9IG5ldyBJbnRlbnQoVGVsZXBob255SW50ZW50cy5BQ1RJT05fTkVUV09SS19TRVRfVElNRSk7CiAgICAgICAgIGludGVudC5hZGRGbGFncyhJbnRlbnQuRkxBR19SRUNFSVZFUl9SRVBMQUNFX1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RDb250ZW50UmVzb2x2ZXIoKSwKKyAgICAgICAgICAgICAgICBTZXR0aW5ncy5HbG9iYWwuQVVUT19USU1FX1pPTkUsIDApID09IDApIHsKICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgfQogICAgICAgICBpZiAoREJHKSBsb2coIlJldmVydGluZyB0byBOSVRaIFRpbWVab25lOiB0ej0nIiArIG1TYXZlZFRpbWVab25lKTsKQEAgLTE2MjAsNyArMTU2Nyw3IEBACiAgICAgcHJpdmF0ZSB2b2lkIHNldE5vdGlmaWNhdGlvbihpbnQgbm90aWZ5VHlwZSkgewogCiAgICAgICAgIGlmIChEQkcpIGxvZygic2V0Tm90aWZpY2F0aW9uOiBjcmVhdGUgbm90aWZpY2F0aW9uICIgKyBub3RpZnlUeXBlKTsKLSAgICAgICAgQ29udGV4dCBjb250ZXh0ID0gcGhvbmUuZ2V0Q29udGV4dCgpOworICAgICAgICBDb250ZXh0IGNvbnRleHQgPSBtUGhvbmUuZ2V0Q29udGV4dCgpOwogCiAgICAgICAgIG1Ob3RpZmljYXRpb24gPSBuZXcgTm90aWZpY2F0aW9uKCk7CiAgICAgICAgIG1Ob3RpZmljYXRpb24ud2hlbiA9IFN5c3RlbS5jdXJyZW50VGltZU1pbGxpcygpOwpAQCAtMTYzNywxOSArMTU4NCwxOSBAQAogICAgICAgICBzd2l0Y2ggKG5vdGlmeVR5cGUpIHsKICAgICAgICAgY2FzZSBQU19FTkFCTEVEOgogICAgICAgICAgICAgbm90aWZpY2F0aW9uSWQgPSBQU19OT1RJRklDQVRJT047Ci0gICAgICAgICAgICBkZXRhaWxzID0gY29udGV4dC5nZXRUZXh0KGNvbS5hbmRyb2lkLmludGVybmFsLlIuc3RyaW5nLlJlc3RyaWN0ZWRPbkRhdGEpOzsKKyAgICAgICAgICAgIGRldGFpbHMgPSBjb250ZXh0LmdldFRleHQoY29tLmFuZHJvaWQuaW50ZXJuYWwuUi5zdHJpbmcuUmVzdHJpY3RlZE9uRGF0YSk7CiAg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KG1SZWNvcmRbbUN1ck9mZnNldCArIDFdICYgMHhmZikgPCAweDgwKSB7CiAgICAgICAgICAgICAgICAgLy8gb25lIGJ5dGUgbGVuZ3RoIDAgLSAweDdmCi0gICAgICAgICAgICAgICAgY3VyRGF0YUxlbmd0aCA9IHJlY29yZFtjdXJPZmZzZXQgKyAxXSAmIDB4ZmY7Ci0gICAgICAgICAgICAgICAgY3VyRGF0YU9mZnNldCA9IGN1ck9mZnNldCArIDI7Ci0gICAgICAgICAgICB9IGVsc2UgaWYgKChyZWNvcmRbY3VyT2Zmc2V0ICsgMV0gJiAweGZmKSA9PSAweDgxKSB7CisgICAgICAgICAgICAgICAgbUN1ckRhdGFMZW5ndGggPSBtUmVjb3JkW21DdXJPZmZzZXQgKyAxXSAmIDB4ZmY7CisgICAgICAgICAgICAgICAgbUN1ckRhdGFPZmZzZXQgPSBtQ3VyT2Zmc2V0ICsgMjsKKyAgICAgICAgICAgIH0gZWxzZSBpZiAoKG1SZWNvcmRbbUN1ck9mZnNldCArIDFdICYgMHhmZikgPT0gMHg4MSkgewogICAgICAgICAgICAgICAgIC8vIHR3byBieXRlIGxlbmd0aCAweDgwIC0gMHhmZgotICAgICAgICAgICAgICAgIGN1ckRhdGFMZW5ndGggPSByZWNvcmRbY3VyT2Zmc2V0ICsgMl0gJiAweGZmOwotICAgICAgICAgICAgICAgIGN1ckRhdGFPZmZzZXQgPSBjdXJPZmZzZXQgKyAzOworICAgICAgICAgICAgICAgIG1DdXJEYXRhTGVuZ3RoID0gbVJlY29yZFttQ3VyT2Zmc2V0ICsgMl0gJiAweGZmOworICAgICAgICAgICAgICAgIG1DdXJEYXRhT2Zmc2V0ID0gbUN1ck9mZnNldCArIDM7CiAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgIH0KQEAgLTEwOCw3ICsxMDgsNyBAQAogICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICB9CiA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mljZUlkID0gZnJvbVNlcnZpY2VJZDsKICAgICB9CiAKICAgICAvKioKICAgICAgKiBAcmV0dXJuIHRoZSBmcm9tU2VydmljZUlkCiAgICAgICovCiAgICAgcHVibGljIGludCBnZXRGcm9tU2VydmljZUlkKCkgewotICAgICAgICByZXR1cm4gZnJvbVNlcnZpY2VJZDsKKyAgICAgICAgcmV0dXJuIG1Gcm9tU2VydmljZUlkOwogICAgIH0KIAogICAgIC8qKgogICAgICAqIEBwYXJhbSB0b1NlcnZpY2VJZCB0aGUgdG9TZXJ2aWNlSWQgdG8gc2V0CiAgICAgICovCiAgICAgcHVibGljIHZvaWQgc2V0VG9TZXJ2aWNlSWQoaW50IHRvU2VydmljZUlkKSB7Ci0gICAgICAgIHRoaXMudG9TZXJ2aWNlSWQgPSB0b1NlcnZpY2VJZDsKKyAgICAgICAgbVRvU2VydmljZUlkID0gdG9TZXJ2aWNlSWQ7CiAgICAgfQogCiAgICAgLyoqCiAgICAgICogQHJldHVybiB0aGUgdG9TZXJ2aWNlSWQKICAgICAgKi8KICAgICBwdWJsaWMgaW50IGdldFRvU2VydmljZUlkKCkgewotICAgICAgICByZXR1cm4gdG9TZXJ2aWNlSWQ7CisgICAgICAgIHJldHVybiBtVG9TZXJ2aWNlSWQ7CiAgICAgfQogCiAgICAgLyoqCiAgICAgICogQHBhcmFtIGZyb21Db2RlU2NoZW1lIHRoZSBmcm9tQ29kZVNjaGVtZSB0byBzZXQKICAgICAgKi8KICAgICBwdWJsaWMgdm9pZCBzZXRGcm9tQ29kZVNjaGVtZShpbnQgZnJvbUNvZGVTY2hlbWUpIHsKLSAgICAgICAgdGhpcy5mcm9tQ29kZVNjaGVtZSA9IGZyb21Db2RlU2NoZW1lOworICAgICAgICBtRnJvbUNvZGVTY2hlbWUgPSBmcm9tQ29kZVNjaGVtZTsKICAgICB9CiAKICAgICAvKioKICAgICAgKiBAcmV0dXJuIHRoZSBmcm9tQ29kZVNjaGVtZQogICAgICAqLwogICAgIHB1Ymxp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ICAgICAgICAgbnJPZlBhZ2VzID0gLTE7CisgICAgICAgICAgICAgICAgbUZvcm1hdCA9IEZPUk1BVF9FVFdTX1BSSU1BUlk7CisgICAgICAgICAgICAgICAgbURhdGFDb2RpbmdTY2hlbWUgPSAtMTsKKyAgICAgICAgICAgICAgICBtUGFnZUluZGV4ID0gLTE7CisgICAgICAgICAgICAgICAgbU5yT2ZQYWdlcyA9IC0xOwogICAgICAgICAgICAgICAgIGJvb2xlYW4gZW1lcmdlbmN5VXNlckFsZXJ0ID0gKHBkdVs0XSAmIDB4MSkgIT0gMDsKICAgICAgICAgICAgICAgICBib29sZWFuIGFjdGl2YXRlUG9wdXAgPSAocGR1WzVdICYgMHg4MCkgIT0gMDsKICAgICAgICAgICAgICAgICBpbnQgd2FybmluZ1R5cGUgPSAocGR1WzRdICYgMHhmZSkgPj4+IDE7CkBAIC0xMjQsOCArMTI0LDggQEAKICAgICAgICAgICAgICAgICByZXR1cm47ICAgICAvLyBza2lwIHRoZSBFVFdTL0NNQVMgaW5pdGlhbGl6YXRpb24gY29kZSBmb3IgcmVndWxhciBub3RpZmljYXRpb25zCiAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgIC8vIEdTTSBwZHVzIGFyZSBubyBtb3JlIHRoYW4gODggYnl0ZXMKLSAgICAgICAgICAgICAgICBmb3JtYXQgPSBGT1JNQVRfR1NNOwotICAgICAgICAgICAgICAgIGRhdGFDb2RpbmdTY2hlbWUgPSBwZHVbNF0gJiAweGZmOworICAgICAgICAgICAgICAgIG1Gb3JtYXQgPSBGT1JNQVRfR1NNOworICAgICAgICAgICAgICAgIG1EYXRhQ29kaW5nU2NoZW1lID0gcGR1WzRdICYgMHhmZjsKIAogICAgICAgICAgICAgICAgIC8vIENoZWNrIGZvciBpbnZhbGlkIHBhZ2UgcGFyYW1ldGVyCiAgICAgICAgICAgICAgICAgaW50IHBhZ2VJbmRleCA9IChwZHVbNV0gJiAweGYwKSA+Pj4gNDsKQEAgLTEzN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aGljYWxTY29wZTsKICAgICB9CiAKICAgICBpbnQgZ2V0U2VyaWFsTnVtYmVyKCkgewotICAgICAgICByZXR1cm4gc2VyaWFsTnVtYmVyOworICAgICAgICByZXR1cm4gbVNlcmlhbE51bWJlcjsKICAgICB9CiAKICAgICBpbnQgZ2V0U2VydmljZUNhdGVnb3J5KCkgewotICAgICAgICByZXR1cm4gbWVzc2FnZUlkZW50aWZpZXI7CisgICAgICAgIHJldHVybiBtTWVzc2FnZUlkZW50aWZpZXI7CiAgICAgfQogCiAgICAgaW50IGdldERhdGFDb2RpbmdTY2hlbWUoKSB7Ci0gICAgICAgIHJldHVybiBkYXRhQ29kaW5nU2NoZW1lOworICAgICAgICByZXR1cm4gbURhdGFDb2RpbmdTY2hlbWU7CiAgICAgfQogCiAgICAgaW50IGdldFBhZ2VJbmRleCgpIHsKLSAgICAgICAgcmV0dXJuIHBhZ2VJbmRleDsKKyAgICAgICAgcmV0dXJuIG1QYWdlSW5kZXg7CiAgICAgfQogCiAgICAgaW50IGdldE51bWJlck9mUGFnZXMoKSB7Ci0gICAgICAgIHJldHVybiBuck9mUGFnZXM7CisgICAgICAgIHJldHVybiBtTnJPZlBhZ2VzOwogICAgIH0KIAogICAgIFNtc0NiRXR3c0luZm8gZ2V0RXR3c0luZm8oKSB7CkBAIC0yMTksOCArMjE5LDggQEAKICAgICAgKiBAcmV0dXJuIHRydWUgaWYgdGhpcyBtZXNzYWdlIGlzIGVtZXJnZW5jeSB0eXBlOyBmYWxzZSBvdGhlcndpc2UKICAgICAgKi8KICAgICBib29sZWFuIGlzRW1lcmdlbmN5TWVzc2FnZSgpIHsKLSAgICAgICAgcmV0dXJuIG1lc3NhZ2VJZGVudGlmaWVyID49IFNtc0NiQ29uc3RhbnRzLk1FU1NBR0VfSURfUFdTX0ZJUlNUX0lERU5USUZJRVIKLSAgICAgICAgICAgICAgICAmJiBtZXNzYWdlSWRlbnRpZmllciA8PSBTbXNDYkNvbnN0YW50cy5NRVNTQUdFX0lE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ICAgICAgICAgICAgY2FzZSBTbXNDYkNvbnN0YW50cy5NRVNTQUdFX0lEX0NNQVNfQUxFUlRfRVhUUkVNRV9JTU1FRElBVEVfT0JTRVJWRUQ6CiAgICAgICAgICAgICBjYXNlIFNtc0NiQ29uc3RhbnRzLk1FU1NBR0VfSURfQ01BU19BTEVSVF9FWFRSRU1FX0VYUEVDVEVEX09CU0VSVkVEOgogICAgICAgICAgICAgY2FzZSBTbXNDYkNvbnN0YW50cy5NRVNTQUdFX0lEX0NNQVNfQUxFUlRfU0VWRVJFX0lNTUVESUFURV9PQlNFUlZFRDoKQEAgLTQwMywxMCArNDAzLDEwIEBACiAKICAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgU3RyaW5nIHRvU3RyaW5nKCkgewotICAgICAgICByZXR1cm4gIlNtc0NiSGVhZGVye0dTPSIgKyBnZW9ncmFwaGljYWxTY29wZSArICIsIHNlcmlhbE51bWJlcj0weCIgKwotICAgICAgICAgICAgICAgIEludGVnZXIudG9IZXhTdHJpbmcoc2VyaWFsTnVtYmVyKSArCi0gICAgICAgICAgICAgICAgIiwgbWVzc2FnZUlkZW50aWZpZXI9MHgiICsgSW50ZWdlci50b0hleFN0cmluZyhtZXNzYWdlSWRlbnRpZmllcikgKwotICAgICAgICAgICAgICAgICIsIERDUz0weCIgKyBJbnRlZ2VyLnRvSGV4U3RyaW5nKGRhdGFDb2RpbmdTY2hlbWUpICsKLSAgICAgICAgICAgICAgICAiLCBwYWdlICIgKyBwYWdlSW5kZXggKyAiIG9mICIgKyBuck9mUGFnZXMgKyAnfSc7CisgICAgICAgIHJldHVybiAiU21zQ2JIZWFkZXJ7R1M9IiArIG1HZW9ncmFwaGljYWxTY29wZSArICIsIHNlcmlhbE51bWJlcj0weCIgKworICAgICAgICAgICAgICAgIEludGVnZXIudG9IZXhTdHJpbmcobVNlcmlhbE51bWJlcikgKworICAgICAgICAgICAgICAgICIsIG1lc3NhZ2VJZGVudGlmaWVyPTB4IiArIEludGVnZXI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ZW50aWZpZXIgPT0gMHg0MCk7CisgICAgICAgIHJldHVybiAobVByb3RvY29sSWRlbnRpZmllciA9PSAweDQwKTsKICAgICB9CiAKICAgICAvKioKQEAgLTE2NCw3ICsxNTUsNyBAQAogICAgICAgICB0cnkgewogICAgICAgICAgICAgU21zTWVzc2FnZSBtc2cgPSBuZXcgU21zTWVzc2FnZSgpOwogCi0gICAgICAgICAgICBtc2cuaW5kZXhPbkljYyA9IGluZGV4OworICAgICAgICAgICAgbXNnLm1JbmRleE9uSWNjID0gaW5kZXg7CiAKICAgICAgICAgICAgIC8vIEZpcnN0IGJ5dGUgaXMgc3RhdHVzOiBSRUNFSVZFRF9SRUFELCBSRUNFSVZFRF9VTlJFQUQsIFNUT1JFRF9TRU5ULAogICAgICAgICAgICAgLy8gb3IgU1RPUkVEX1VOU0VOVApAQCAtMTc0LDcgKzE2NSw3IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAiU01TIHBhcnNpbmcgZmFpbGVkOiBUcnlpbmcgdG8gcGFyc2UgYSBmcmVlIHJlY29yZCIpOwogICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICBtc2cuc3RhdHVzT25JY2MgPSBkYXRhWzBdICYgMHgwNzsKKyAgICAgICAgICAgICAgICBtc2cubVN0YXR1c09uSWNjID0gZGF0YVswXSAmIDB4MDc7CiAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgIGludCBzaXplID0gZGF0YS5sZW5ndGggLSAxOwpAQCAtMzQ0LDcgKzMzNSw3IEBACiAgICAgLyoqCiAgICAgICogUGFja3MgaGVhZGVyIGFuZCBVQ1MtMiBlbmNvZGVkIG1lc3NhZ2UuIEluY2x1ZGVzIFRQLVVETCAmIFRQLVVESEwgaWYgbmVjZXNzYXJ5CiAgICAgICoKLSAgICAgKiBAcmV0dXJuCisgICAgICogQHJldHVybiBlbmNvZGVkIG1lc3NhZ2UgYXMgVUNTMgogICAgICA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kdSA9IHBkdTsKLSAgICAgICAgICAgIGN1ciA9IDA7CisgICAgICAgICAgICBtUGR1ID0gcGR1OworICAgICAgICAgICAgbUN1ciA9IDA7CiAgICAgICAgICAgICBtVXNlckRhdGFTZXB0ZXRQYWRkaW5nID0gMDsKICAgICAgICAgfQogCkBAIC01MjgsMTQgKzUxOCwxNCBAQAogICAgICAgICAgICAgICAgIC8vIFNDIGFkZHJlc3MKICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICByZXQgPSBQaG9uZU51bWJlclV0aWxzCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgLmNhbGxlZFBhcnR5QkNEVG9TdHJpbmcocGR1LCBjdXIsIGxlbik7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmNhbGxlZFBhcnR5QkNEVG9TdHJpbmcobVBkdSwgbUN1ciwgbGVuKTsKICAgICAgICAgICAgICAgICB9IGNhdGNoIChSdW50aW1lRXhjZXB0aW9uIHRyKSB7CiAgICAgICAgICAgICAgICAgICAgIFJsb2cuZChMT0dfVEFHLCAiaW52YWxpZCBTQyBhZGRyZXNzOiAiLCB0cik7CiAgICAgICAgICAgICAgICAgICAgIHJldCA9IG51bGw7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogCi0gICAgICAgICAgICBjdXIgKz0gbGVuOworICAgICAgICAgICAgbUN1ciArPSBsZW47CiAKICAgICAgICAgICAgIHJldHVybiByZXQ7CiAgICAgICAgIH0KQEAgLTU0NCw3ICs1MzQsNyBAQAogICAgICAgICAgKiByZXR1cm5zIG5vbi1zaWduLWV4dGVuZGVkIGJ5dGUgdmFsdWUKICAgICAgICAgICovCiAgICAgICAgIGludCBnZXRCeXRlKCkgewotICAgICAgICAgICAgcmV0dXJuIHBkdVtjdXIrK10gJiAweGZmOworICAgICAgICAgICAgcmV0dXJuIG1QZHVbbUN1cisrXSAmIDB4ZmY7CiAgICAgICAgIH0KIAogICAgICAgICAvKioKQEAgLTU1OCwxNyArNTQ4LDE3IEBACiAgICAgICAgICAgICAvLyB0aGUgbnVtYmVyIGZpZWxkLCBpLmUuIGV4Y2x1ZGVzIGFueSBzZW1pLW9jdGV0IGNvbnRhaW5pbmcgb25seQogICAgICAgICAgICAgLy8gZmlsbCBiaXRzLiIKICAgICAgICAgICAgIC8vIFRoZSBUT0EgZmllbGQgaXMgbm90IGluY2x1ZGVkIGFzIHBhcnQgb2YgdGhpcwotICAgICAgICAgICAgaW50IGFkZHJlc3NMZW5ndGggPSBwZHVbY3VyXSAmIDB4ZmY7CisgICAgICAgICAgICBpbnQgYWRkcmVzc0xlbmd0aCA9IG1QZHVbbUN1cl0gJiAweGZmOwogICAgICAgICAgICAgaW50IGxlbmd0aEJ5dGVzID0gMiArIChhZGRyZXNzTGVuZ3RoICsgMSkgLyAyOwogCiAgICAgICAgICAgICB0cnkgewotICAgICAgICAgICAgICAgIHJldCA9IG5ldyBHc21TbXNBZGRyZXNzKHBkdSwgY3VyLCBsZW5ndGhCeXRlcyk7CisgICAgICAgICAgICAgICAgcmV0ID0gbmV3IEdzbVNtc0FkZHJlc3MobVBkdSwgbUN1ciwgbGVuZ3RoQnl0ZXMpOwogICAgICAgICAgICAgfSBjYXRjaCAoUGFyc2VFeGNlcHRpb24gZSkgewogICAgICAgICAgICAgICAgIFJsb2cuZShMT0dfVEFHLCBlLmdldE1lc3NhZ2UoKSk7CiAgICAgICAgICAgICAgICAgcmV0ID0gbnVsbDsKICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgY3VyICs9IGxlbmd0aEJ5dGVzOworICAgICAgICAgICAgbUN1ciArPSBsZW5ndGhCeXRlczsKIAogICAgICAgICAgICAgcmV0dXJuIHJldDsKICAgICAgICAgfQpAQCAtNTgwLDE5ICs1NzAsMTkgQEAKIAogICAgICAgICBsb25nIGdldFNDVGltZXN0YW1wTWlsbGlzKCkgewogICAgICAgICAgICAgLy8gVFAtU2VydmljZS1DZW50cmUtVGltZS1TdGFtcAotICAgICAgICAgICA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25pZmljYW50IG5pYmJsZSBpcyB0aGUgc2lnbiBieXRlCiAgICAgICAgICAgICAvLyAobWVhbmluZyB0aGUgbWF4IHJhbmdlIG9mIHRoaXMgZmllbGQgaXMgNzkgcXVhcnRlci1ob3VycywKICAgICAgICAgICAgIC8vIHdoaWNoIGlzIG1vcmUgdGhhbiBlbm91Z2gpCiAKLSAgICAgICAgICAgIGJ5dGUgdHpCeXRlID0gcGR1W2N1cisrXTsKKyAgICAgICAgICAgIGJ5dGUgdHpCeXRlID0gbVBkdVttQ3VyKytdOwogCiAgICAgICAgICAgICAvLyBNYXNrIG91dCBzaWduIGJpdC4KICAgICAgICAgICAgIGludCB0aW1lem9uZU9mZnNldCA9IEljY1V0aWxzLmdzbUJjZEJ5dGVUb0ludCgoYnl0ZSkgKHR6Qnl0ZSAmICh+MHgwOCkpKTsKQEAgLTYyMywxNyArNjEzLDE3IEBACiAgICAgICAgICAqIEByZXR1cm4gdGhlIG51bWJlciBvZiBzZXB0ZXRzIG9yIG9jdGV0cyBpbiB0aGUgdXNlciBkYXRhIHBheWxvYWQKICAgICAgICAgICovCiAgICAgICAgIGludCBjb25zdHJ1Y3RVc2VyRGF0YShib29sZWFuIGhhc1VzZXJEYXRhSGVhZGVyLCBib29sZWFuIGRhdGFJblNlcHRldHMpIHsKLSAgICAgICAgICAgIGludCBvZmZzZXQgPSBjdXI7Ci0gICAgICAgICAgICBpbnQgdXNlckRhdGFMZW5ndGggPSBwZHVbb2Zmc2V0KytdICYgMHhmZjsKKyAgICAgICAgICAgIGludCBvZmZzZXQgPSBtQ3VyOworICAgICAgICAgICAgaW50IHVzZXJEYXRhTGVuZ3RoID0gbVBkdVtvZmZzZXQrK10gJiAweGZmOwogICAgICAgICAgICAgaW50IGhlYWRlclNlcHRldHMgPSAwOwogICAgICAgICAgICAgaW50IHVzZXJEYXRhSGVhZGVyTGVuZ3RoID0gMDsKIAogICAgICAgICAgICAgaWYgKGhhc1VzZXJEYXRhSGVhZGVyKSB7Ci0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yTGVuID0gbVBkdS5sZW5ndGggLSBvZmZzZXQ7CiAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgIC8qCiAgICAgICAgICAgICAgICAgICogdXNlckRhdGFMZW5ndGggaXMgdGhlIGNvdW50IG9mIG9jdGV0cywgc28ganVzdCBzdWJ0cmFjdCB0aGUKQEAgLTY2MSw5ICs2NTEsOSBAQAogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgdXNlckRhdGEgPSBuZXcgYnl0ZVtidWZmZXJMZW5dOwotICAgICAgICAgICAgU3lzdGVtLmFycmF5Y29weShwZHUsIG9mZnNldCwgdXNlckRhdGEsIDAsIHVzZXJEYXRhLmxlbmd0aCk7Ci0gICAgICAgICAgICBjdXIgPSBvZmZzZXQ7CisgICAgICAgICAgICBtVXNlckRhdGEgPSBuZXcgYnl0ZVtidWZmZXJMZW5dOworICAgICAgICAgICAgU3lzdGVtLmFycmF5Y29weShtUGR1LCBvZmZzZXQsIG1Vc2VyRGF0YSwgMCwgbVVzZXJEYXRhLmxlbmd0aCk7CisgICAgICAgICAgICBtQ3VyID0gb2Zmc2V0OwogCiAgICAgICAgICAgICBpZiAoZGF0YUluU2VwdGV0cykgewogICAgICAgICAgICAgICAgIC8vIFJldHVybiB0aGUgbnVtYmVyIG9mIHNlcHRldHMKQEAgLTY3Miw3ICs2NjIsNyBAQAogICAgICAgICAgICAgICAgIHJldHVybiBjb3VudCA8IDAgPyAwIDogY291bnQ7CiAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgIC8vIFJldHVybiB0aGUgbnVtYmVyIG9mIG9jdGV0cwotICAgICAgICAgICAgICAgIHJldHVybiB1c2VyRGF0YS5sZW5ndGg7CisgICAgICAgICAgICAgICAgcmV0dXJuIG1Vc2VyRGF0YS5sZW5ndGg7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KIApAQCAtNjgyLDE4ICs2NzIsNyBAQAogICAgICAgICAgKiBAcmV0dXJuIHRoZSB1c2VyIGRhdGEgcGF5bG9hZCwgbm90IGluY2x1ZGluZyB0aGUgaGVhZGVycwogICAgICAgICAgKi8KICAgICAgICAgYnl0ZVtdIGdldFVzZXJEYXRhKCkgewotICAgICAgICAgICAgcmV0dXJuIHVzZXJEYXRhOwotICAgICAgICB9Ci0KLSAgICAgICAgLyoqCi0gICAgICAgICAqIFJldHVybnMgdGhlIG51bWJlciBvZiBwYWRkaW5nIGJpdHMgYXQgdGhlIGJlZ2lubmluZyBvZiB0aGUgdXNlciBkYXRhCi0gICAgICAgICAqIGFycmF5IGJlZm9yZSB0aGUgc3RhcnQgb2YgdGhlIHNlcHRldHMuCi0gICAgICAgICAqCi0gICAgICAgICAqIEByZXR1cm4gdGhlIG51bWJlciBvZiBwYWRkaW5nIGJpdHMgYXQgdGhlIGJlZ2lubmluZyBvZiB0aGUgdXNlciBkYXRhCi0gICAgICAgICAqIGFycmF5IGJlZm9yZSB0aGUgc3RhcnQgb2YgdGhlIHNlcHRldHMKLSAgICAgICAgICovCi0gICAgICAgIGludCBnZXRVc2VyRGF0YVNlcHRldFBhZGRpbmcoKSB7Ci0gICAgICAgICAgICByZXR1cm4gbVVzZXJEYXRhU2VwdGV0UGFkZGluZzsKKyAgICAgICAgICAgIHJldHVybiBtVXNlckRhdGE7CiAgICAgICAgIH0KIAogICAgICAgICAvKioKQEAgLTcwMiw3ICs2ODEsNyBAQAogICAgICAgICAgKiB7QGhpZGV9CiAgICAgICAgICAqLwogICAgICAgICBTbXNIZWFkZXIgZ2V0VXNlckRhdGFIZWFkZXIoKSB7Ci0gICAgICAgICAgICByZXR1cm4gdXNlckRhdGFIZWFkZXI7CisgICAgICAgICAgICByZXR1cm4gbVVzZXJEYXRhSGVhZGVyOwogICAgICAgICB9CiAKICAgICAgICAgLyoqCkBAIC03MTYsMTAgKzY5NSwxMCBAQAogICAgICAgICAgICAgICAgIGludCBsYW5ndWFnZVNoaWZ0VGFibGUpIHsKICAgICAgICAgICAgIFN0cmluZyByZXQ7CiAKLSAgICAgICAgICAgIHJldCA9IEdzbUFscGhhYmV0LmdzbTdCaXRQYWNrZWRUb1N0cmluZyhwZHUsIGN1ciwgc2VwdGV0Q291bnQsCisgICAgICAgICAgICByZXQgPSBHc21BbHBoYWJldC5nc203Qml0UGFja2VkVG9TdHJpbmcobVBkdSwgbUN1ciwgc2VwdGV0Q291bnQsCiAgICAgICAgICAgICAgICAgICAgIG1Vc2VyRGF0YVNlcHRldFBhZGRpbmcsIGxhbmd1YWdlVGFibGUsIGxhbmd1YWdlU2hpZnRUYWJsZSk7CiAKLSAgICAgICAgICAgIGN1ciArPSAoc2VwdGV0Q291bnQgKiA3KSAvIDg7CisgICAgICAgICAgICBtQ3VyICs9IChzZXB0ZXRDb3VudCAqIDcpIC8gODsKIAogICAgICAgICAgICAgcmV0dXJuIHJldDsKICAgICAgICAgfQpAQCAtNzM1LDEzICs3MTQsMTMgQEAKICAgICAgICAgICAgIFN0cmluZyByZXQ7CiAKICAgICAgICAgICAgIHRyeSB7Ci0gICAgICAgICAgICAgICAgcmV0ID0gbmV3IFN0cmluZyhwZHUsIGN1ciwgYnl0ZUNvdW50LCAidXRmLTE2Iik7CisgICAgICAgICAgICAgICAgcmV0ID0gbmV3IFN0cmluZyhtUGR1LCBtQ3VyLCBieXRlQ291bnQsICJ1dGYtMTYiKTsKICAgICAgICAgICAgIH0gY2F0Y2ggKFVuc3VwcG9ydGVkRW5jb2RpbmdFeGNlcHRpb24gZXgpIHsKICAgICAgICAgICAgICAgICByZXQgPSAiIjsKICAgICAgICAgICAgICAgICBSbG9nLmUoTE9HX1RBRywgImltcGxhdXNpYmxlIFVuc3VwcG9ydGVkRW5jb2RpbmdFeGNlcHRpb24iLCBleCk7CiAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgIGN1ciArPSBieXRlQ291bnQ7CisgICAgICAgICAgICBtQ3VyICs9IGJ5dGVDb3VudDsKICAgICAgICAgICAgIHJldHVybiByZXQ7CiAgICAgICAgIH0KIApAQCAtNzU2LDE4ICs3MzUsMTggQEAKICAgICAgICAgICAgIFN0cmluZyByZXQ7CiAKICAgICAgICAgICAgIHRyeSB7Ci0gICAgICAgICAgICAgICAgcmV0ID0gbmV3IFN0cmluZyhwZHUsIGN1ciwgYnl0ZUNvdW50LCAiS1NDNTYwMSIpOworICAgICAgICAgICAgICAgIHJldCA9IG5ldyBTdHJpbmcobVBkdSwgbUN1ciwgYnl0ZUNvdW50LCAiS1NDNTYwMSIpOwogICAgICAgICAgICAgfSBjYXRjaCAoVW5zdXBwb3J0ZWRFbmNvZGluZ0V4Y2VwdGlvbiBleCkgewogICAgICAgICAgICAgICAgIHJldCA9ICIiOwogICAgICAgICAgICAgICAgIFJsb2cuZShMT0dfVEFHLCAiaW1wbGF1c2libGUgVW5zdXBwb3J0ZWRFbmNvZGluZ0V4Y2VwdGlvbiIsIGV4KTsKICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgY3VyICs9IGJ5dGVDb3VudDsKKyAgICAgICAgICAgIG1DdXIgKz0gYnl0ZUNvdW50OwogICAgICAgICAgICAgcmV0dXJuIHJldDsKICAgICAgICAgfQogCiAgICAgICAgIGJvb2xlYW4gbW9yZURhdGFQcmVzZW50KCkgewotICAgICAgICAgICAgcmV0dXJuIChwZHUubGVuZ3RoID4gY3VyKTsKKyAgICAgICAgICAgIHJldHVybiAobVBkdS5sZW5ndGggPiBtQ3VyKTsKICAgICAgICAgfQogICAgIH0KIApAQCAtODAyLDcgKzc4MSw3IEBACiAgICAgLyoqIHtAaW5oZXJpdERvY30gKi8KICAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgaW50IGdldFByb3RvY29sSWRlbnRpZmllcigpIHsKLSAgICAgICAgcmV0dXJuIHByb3RvY29sSWRlbnRpZmllcjsKKyAgICAgICAgcmV0dXJuIG1Qcm90b2NvbElkZW50aWZpZXI7CiAgICAgfQogCiAgICAgLyoqCkBAIC04MTAsNTAgKzc4OSw1MCBAQAogICAgICAqIEByZXR1cm4gdGhlIFRQLURDUyBmaWVsZCBvZiB0aGUgU01TIGhlYWRlcgogICAgICAqLwogICAgIGludCBnZXREYXRhQ29kaW5nU2NoZW1lKCkgewotICAgICAgICByZXR1cm4gZGF0YUNvZGluZ1NjaGVtZTsKKyAgICAgICAgcmV0dXJuIG1EYXRhQ29kaW5nU2NoZW1lOwogICAgIH0KIAogICAgIC8qKiB7QGluaGVyaXREb2N9ICovCiAgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGJvb2xlYW4gaXNSZXBsYWNlKCkgewotICAgICAgICByZXR1cm4gKHByb3RvY29sSWRlbnRpZmllciAmIDB4YzApID09IDB4NDAKLSAgICAgICAgICAgICAgICAmJiAocHJvdG9jb2xJZGVudGlmaWVyICYgMHgzZikgPiAwCi0gICAgICAgICAgICAgICAgJiYgKHByb3RvY29sSWRlbnRpZmllciAmIDB4M2YpIDwgODsKKyAgICAgICAgcmV0dXJuIChtUHJvdG9jb2xJZGVudGlmaWVyICYgMHhjMCkgPT0gMHg0MAorICAgICAgICAgICAgICAgICYmIChtUHJvdG9jb2xJZGVudGlmaWVyICYgMHgzZikgPiAwCisgICAgICAgICAgICAgICAgJiYgKG1Qcm90b2NvbElkZW50aWZpZXIgJiAweDNmKSA8IDg7CiAgICAgfQogCiAgICAgLyoqIHtAaW5oZXJpdERvY30gKi8KICAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgYm9vbGVhbiBpc0NwaHNNd2lNZXNzYWdlKCkgewotICAgICAgICByZXR1cm4gKChHc21TbXNBZGRyZXNzKSBvcmlnaW5hdGluZ0FkZHJlc3MpLmlzQ3Boc1ZvaWNlTWVzc2FnZUNsZWFyKCkKLSAgICAgICAgICAgICAgICB8fCAoKEdzbVNtc0FkZHJlc3MpIG9yaWdpbmF0aW5nQWRkcmVzcykuaXNDcGhzVm9pY2VNZXNzYWdlU2V0KCk7CisgICAgICAgIHJldHVybiAoKEdzbVNtc0FkZHJlc3MpIG1PcmlnaW5hdGluZ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gJiYgKChHc21TbXNBZGRyZXNzKSBvcmlnaW5hdGluZ0FkZHJlc3MpLmlzQ3Boc1ZvaWNlTWVzc2FnZVNldCgpOworICAgICAgICByZXR1cm4gbU9yaWdpbmF0aW5nQWRkcmVzcyAhPSBudWxsCisgICAgICAgICAgICAgICAgJiYgKChHc21TbXNBZGRyZXNzKSBtT3JpZ2luYXRpbmdBZGRyZXNzKS5pc0NwaHNWb2ljZU1lc3NhZ2VTZXQoKTsKICAgICB9CiAKICAgICAvKioge0Bpbmhlcml0RG9jfSAqLwogICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBib29sZWFuIGlzTXdpRG9udFN0b3JlKCkgewotICAgICAgICBpZiAoaXNNd2kgJiYgbXdpRG9udFN0b3JlKSB7CisgICAgICAgIGlmIChtSXNNd2kgJiYgbU13aURvbnRTdG9yZSkgewogICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgIH0KIApAQCAtODcyLDE5ICs4NTEsMTkgQEAKICAgICAvKioge0Bpbmhlcml0RG9jfSAqLwogICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBpbnQgZ2V0U3RhdHVzKCkgewotICAgICAgICByZXR1cm4gc3RhdHVzOworICAgICAgICByZXR1cm4gbVN0YXR1czsKICAgICB9CiAKICAgICAvKioge0Bpbmhlcml0RG9jfSAqLwogICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBib29sZWFuIGlzU3RhdHVzUmVwb3J0TWVzc2FnZSgpIHsKLSAgICAgICAgcmV0dXJuIGlzU3RhdHVzUmVwb3J0TWVzc2FnZTsKKyAgICAgICAgcmV0dXJuIG1Jc1N0YXR1c1JlcG9ydE1lc3NhZ2U7CiAgICAgfQogCiAgICAgLyoqIHtAaW5oZXJpdERvY30gKi8KICAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgYm9vbGVhbiBpc1JlcGx5UGF0aFByZXNlbnQoKSB7Ci0gICAgICAgIHJldHVybiByZXBseVBhdGhQcmVzZW50OworICAgIC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cyA9IHAuZ2V0Qnl0ZSgpOworICAgICAgICBtU3RhdHVzID0gcC5nZXRCeXRlKCk7CiAKICAgICAgICAgLy8gVGhlIGZvbGxvd2luZyBhcmUgb3B0aW9uYWwgZmllbGRzIHRoYXQgbWF5IG9yIG1heSBub3QgYmUgcHJlc2VudC4KICAgICAgICAgaWYgKHAubW9yZURhdGFQcmVzZW50KCkpIHsKQEAgLTk3MywxMSArOTQ5LDExIEBACiAgICAgICAgICAgICBpZiAoKGV4dHJhUGFyYW1zICYgMHg3OCkgPT0gMCkgewogICAgICAgICAgICAgICAgIC8vIFRQLVByb3RvY29sLUlkZW50aWZpZXIKICAgICAgICAgICAgICAgICBpZiAoKGV4dHJhUGFyYW1zICYgMHgwMSkgIT0gMCkgewotICAgICAgICAgICAgICAgICAgICBwcm90b2NvbElkZW50aWZpZXIgPSBwLmdldEJ5dGUoKTsKKyAgICAgICAgICAgICAgICAgICAgbVByb3RvY29sSWRlbnRpZmllciA9IHAuZ2V0Qnl0ZSgpOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAvLyBUUC1EYXRhLUNvZGluZy1TY2hlbWUKICAgICAgICAgICAgICAgICBpZiAoKGV4dHJhUGFyYW1zICYgMHgwMikgIT0gMCkgewotICAgICAgICAgICAgICAgICAgICBkYXRhQ29kaW5nU2NoZW1lID0gcC5nZXRCeXRlKCk7CisgICAgICAgICAgICAgICAgICAgIG1EYXRhQ29kaW5nU2NoZW1lID0gcC5nZXRCeXRlKCk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIC8vIFRQLVVzZXItRGF0YS1MZW5ndGggKGltcGxpZXMgZXhpc3RlbmNlIG9mIFRQLVVzZXItRGF0YSkKICAgICAgICAgICAgICAgICBpZiAoKGV4dHJhUGFyYW1zICYgMHgwNCkgIT0gMCkgewpAQCAtOTg5LDMxICs5NjUsMzEgQEAKICAgICB9CiAKICAgICBwcml2YXRlIHZvaWQgcGFyc2VTbXNEZWxpdmVyK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gKDAgIT0gKGRhdGFDb2RpbmdTY2hlbWUgJiAweDEwKSk7CisgICAgICAgIGlmICgobURhdGFDb2RpbmdTY2hlbWUgJiAweDgwKSA9PSAwKSB7CisgICAgICAgICAgICB1c2VyRGF0YUNvbXByZXNzZWQgPSAoMCAhPSAobURhdGFDb2RpbmdTY2hlbWUgJiAweDIwKSk7CisgICAgICAgICAgICBoYXNNZXNzYWdlQ2xhc3MgPSAoMCAhPSAobURhdGFDb2RpbmdTY2hlbWUgJiAweDEwKSk7CiAKICAgICAgICAgICAgIGlmICh1c2VyRGF0YUNvbXByZXNzZWQpIHsKICAgICAgICAgICAgICAgICBSbG9nLncoTE9HX1RBRywgIjQgLSBVbnN1cHBvcnRlZCBTTVMgZGF0YSBjb2Rpbmcgc2NoZW1lICIKLSAgICAgICAgICAgICAgICAgICAgICAgICsgIihjb21wcmVzc2lvbikgIiArIChkYXRhQ29kaW5nU2NoZW1lICYgMHhmZikpOworICAgICAgICAgICAgICAgICAgICAgICAgKyAiKGNvbXByZXNzaW9uKSAiICsgKG1EYXRhQ29kaW5nU2NoZW1lICYgMHhmZikpOwogICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICBzd2l0Y2ggKChkYXRhQ29kaW5nU2NoZW1lID4+IDIpICYgMHgzKSB7CisgICAgICAgICAgICAgICAgc3dpdGNoICgobURhdGFDb2RpbmdTY2hlbWUgPj4gMikgJiAweDMpIHsKICAgICAgICAgICAgICAgICBjYXNlIDA6IC8vIEdTTSA3IGJpdCBkZWZhdWx0IGFscGhhYmV0CiAgICAgICAgICAgICAgICAgICAgIGVuY29kaW5nVHlwZSA9IEVOQ09ESU5HXzdCSVQ7CiAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwpAQCAtMTExNSwxMDUgKzEwODgsMTA0IEBACiAgICAgICAgICAgICAgICAgY2FzZSAxOiAvLyA4IGJpdCBkYXRhCiAgICAgICAgICAgICAgICAgY2FzZSAzOiAvLyByZXNlcnZlZAogICAgICAgICAgICAgICAgICAgICBSbG9nLncoTE9HX1RBRywgIjEgLSBVbnN1cHBvcnRlZCBTTVMgZGF0YSBjb2Rpbmcgc2NoZW1lICIKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICArIChkYXRhQ29kaW5nU2NoZW1lICYgMHhmZikpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgKG1EYXRhQ29kaW5nU2NoZW1lICYgMHhmZikpOwogICAgICAgICAgICAgICAgICAgICBlbmNvZGluZ1R5cGUgPSBFTkNPRElOR184QklUOwogICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9Ci0gICAgICAgIH0gZWxzZSBpZiAoKGRhdGFDb2RpbmdTY2hlbWUgJiAweGYwKSA9PSAweGYwKSB7Ci0gICAgICAgICAgICBhdXRvbWF0aWNEZWxldGlvbiA9IGZhbHNlOworICAgICAgICB9IGVsc2UgaWYgKChtRGF0YUNvZGluZ1NjaGVtZSAmIDB4ZjApID09IDB4ZjApIHsKICAgICAgICAgICAgIGhhc01lc3NhZ2VDbGFzcyA9IHRydWU7CiAgICAgICAgICAgICB1c2VyRGF0YUNvbXByZXNzZWQgPSBmYWxzZTsKIAotICAgICAgICAgICAgaWYgKDAgPT0gKGRhdGFDb2RpbmdTY2hlbWUgJiAweDA0KSkgeworICAgICAgICAgICAgaWYgKDAgPT0gKG1EYXRhQ29kaW5nU2NoZW1lICYgMHgwNCkpIHsKICAgICAgICAgICAgICAgICAvLyBHU00gNyBiaXQgZGVmYXVsdCBhbHBoYWJldAogICAgICAgICAgICAgICAgIGVuY29kaW5nVHlwZSA9IEVOQ09ESU5HXzdCSVQ7CiAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgIC8vIDggYml0IGRhdGEKICAgICAgICAgICAgICAgICBlbmNvZGluZ1R5cGUgPSBFTkNPRElOR184QklUOwogICAgICAgICAgICAgfQotICAgICAgICB9IGVsc2UgaWYgKChkYXRhQ29kaW5nU2NoZW1lICYgMHhGMCkgPT0gMHhDMAotICAgICAgICAgICAgICAgIHx8IChkYXRhQ29kaW5nU2NoZW1lICYgMHhGMCkgPT0gMHhEMAotICAgICAgICAgICAgICAgIHx8IChkYXRhQ29kaW5nU2NoZW1lICYgMHhGMCkgPT0gMHhFMCkgeworICAgICAgICB9IGVsc2UgaWYgKChtRGF0YUNvZGluZ1NjaGVtZSAmIDB4RjApID09IDB4QzAKKyAgICAgICAgICAgICAgICB8fCAobURhdGFDb2RpbmdTY2hlbWUgJiAweEYwKSA9PSAweEQwCisgICAgICAgICAgICAgICAgfHwgKG1EYXRhQ29kaW5nU2NoZW1lICYgMHhGMCkgPT0gMHhFMCkgewogICAgICAgICAgICAgLy8gM0dQUCBUUyAyMy4wMzggVjcuMC4wICgyMDA2LTAzKSBzZWN0aW9uIDQKIAogICAgICAgICAgICAgLy8gMHhDMCA9PSA3IGJpdCwgZG9uJ3Qgc3RvcmUKICAgICAgICAgICAgIC8vIDB4RDAgPT0gNyBiaXQsIHN0b3JlCiAgICAgICAgICAgICAvLyAweEUwID09IFVDUy0yLCBzdG9yZQogCi0gICAgICAgICAgICBpZiAoKGRhdGFDb2RpbmdTY2hlbWUgJiAweEYwKSA9PSAweEUwKSB7CisgICAgICAgICAgICBpZiAoKG1EYXRhQ29kaW5nU2NoZW1lICYgMHhGMCkgPT0gMHhFMCkgewogICAgICAgICAgICAgICAgIGVuY29kaW5nVHlwZSA9IEVOQ09ESU5HXzE2QklUOwogICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICBlbmNvZGluZ1R5cGUgPSBFTkNPRElOR183QklUOwogICAgICAgICAgICAgfQogCiAgICAgICAgICAgICB1c2VyRGF0YUNvbXByZXNzZWQgPSBmYWxzZTsKLSAgICAgICAgICAgIGJvb2xlYW4gYWN0aXZlID0gKChkYXRhQ29kaW5nU2NoZW1lICYgMHgwOCkgPT0gMHgwOCk7CisgICAgICAgICAgICBib29sZWFuIGFjdGl2ZSA9ICgobURhdGFDb2RpbmdTY2hlbWUgJiAweDA4KSA9PSAweDA4KTsKIAogICAgICAgICAgICAgLy8gYml0IDB4MDQgcmVzZXJ2ZWQKIAotICAgICAgICAgICAgaWYgKChkYXRhQ29kaW5nU2NoZW1lICYgMHgwMykgPT0gMHgwMCkgewotICAgICAgICAgICAgICAgIGlzTXdpID0gdHJ1ZTsKLSAgICAgICAgICAgICAgICBtd2lTZW5zZSA9IGFjdGl2ZTsKLSAgICAgICAgICAgICAgICBtd2lEb250U3RvcmUgPSAoKGRhdGFDb2RpbmdTY2hlbWUgJiAweEYwKSA9PSAweEMwKTsKKyAgICAgICAgICAgIGlmICgobURhdGFDb2RpbmdTY2hlbWUgJiAweDAzKSA9PSAweDAwKSB7CisgICAgICAgICAgICAgICAgbUlzTXdpID0gdHJ1ZTsKKyAgICAgICAgICAgICAgICBtTXdpU2Vuc2UgPSBhY3RpdmU7CisgICAgICAgICAgICAgICAgbU13aURvbnRTdG9yZSA9ICgobURhdGFDb2RpbmdTY2hlbWUgJiAweEYwKSA9PSAweEMwKTsKICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgaXNNd2kgPSBmYWxzZTsKKyAgICAgICAgICAgICAgICBtSXNNd2kgPSBmYWxzZTsKIAogICAgICAgICAgICAgICAgIFJsb2cudyhMT0dfVEFHLCAiTVdJIGZvciBmYXgsIGVtYWlsLCBvciBvdGhlciAiCi0gICAgICAgICAgICAgICAgICAgICAgICArIChkYXRhQ29kaW5nU2NoZW1lICYgMHhmZikpOworICAgICAgICAgICAgICAgICAgICAgICAgKyAobURhdGFDb2RpbmdTY2hlbWUgJiAweGZmKSk7CiAgICAgICAgICAgICB9Ci0gICAgICAgIH0gZWxzZSBpZiAoKGRhdGFDb2RpbmdTY2hlbWUgJiAweEMwKSA9PSAweDgwKSB7CisgICAgICAgIH0gZWxzZSBpZiAoKG1EYXRhQ29kaW5nU2NoZW1lICYgMHhDMCkgPT0gMHg4MCkgewogICAgICAgICAgICAgLy8gM0dQUCBUUyAyMy4wMzggVjcuMC4wICgyMDA2LTAzKSBzZWN0aW9uIDQKICAgICAgICAgICAgIC8vIDB4ODAuLjB4QkYgPT0gUmVzZXJ2ZWQgY29kaW5nIGdyb3VwcwotICAgICAgICAgICAgaWYgKGRhdGFDb2RpbmdTY2hlbWUgPT0gMHg4NCkgeworICAgICAgICAgICAgaWYgKG1EYXRhQ29kaW5nU2NoZW1lID09IDB4ODQpIHsKICAgICAgICAgICAgICAgICAvLyBUaGlzIHZhbHVlIHVzZWQgZm9yIEtTQzU2MDEgYnkgY2FycmllcnMgaW4gS29yZWEuCiAgICAgICAgICAgICAgICAgZW5jb2RpbmdUeXBlID0gRU5DT0RJTkdfS1NDNTYwMTsKICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgUmxvZy53KExPR19UQUcsICI1IC0gVW5zdXBwb3J0ZWQgU01TIGRhdGEgY29kaW5nIHNjaGVtZSAiCi0gICAgICAgICAgICAgICAgICAgICAgICArIChkYXRhQ29kaW5nU2NoZW1lICYgMHhmZikpOworICAgICAgICAgICAgICAgICAgICAgICAgKyAobURhdGFDb2RpbmdTY2hlbWUgJiAweGZmKSk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICBSbG9nLncoTE9HX1RBRywgIjMgLSBVbnN1cHBvcnRlZCBTTVMgZGF0YSBjb2Rpbmcgc2NoZW1lICIKLSAgICAgICAgICAgICAgICAgICAgKyAoZGF0YUNvZGluZ1NjaGVtZSAmIDB4ZmYpKTsKKyAgICAgICAgICAgICAgICAgICAgKyAobURhdGFDb2RpbmdTY2hlbWUgJiAweGZmKSk7CiAgICAgICAgIH0KIAogICAgICAgICAvLyBzZXQgYm90aCB0aGUgdXNlciBkYXRhIGFuZCB0aGUgdXNlciBkYXRhIGhlYWRlci4KICAgICAgICAgaW50IGNvdW50ID0gcC5jb25zdHJ1Y3RVc2VyRGF0YShoYXNVc2VyRGF0YUhlYWRlciwKICAgICAgICAgICAgICAgICBlbmNvZGluZ1R5cGUgPT0gRU5DT0RJTkdfN0JJVCk7Ci0gICAgICAgIHRoaXMudXNlckRhdGEgPSBwLmdldFVzZXJEYXRhKCk7Ci0gICAgICAgIHRoaXMudXNlckRhdGFIZWFkZXIgPSBwLmdldFVzZXJEYXRhSGVhZGVyKCk7CisgICAgICAgIHRoaXMubVVzZXJEYXRhID0gcC5nZXRVc2VyRGF0YSgpOworICAgICAgICB0aGlzLm1Vc2VyRGF0YUhlYWRlciA9IHAuZ2V0VXNlckRhdGFIZWFkZXIoKTsKIAogICAgICAgICBzd2l0Y2ggKGVuY29kaW5nVHlwZSkgewogICAgICAgICBjYXNlIEVOQ09ESU5HX1VOS05PV046CiAgICAgICAgIGNhc2UgRU5DT0RJTkdfOEJJVDoKLSAgICAgICAgICAgIG1lc3NhZ2VCb2R5ID0gbnVsbDsKKyAgICAgICAgICAgIG1NZXNzYWdlQm9keSA9IG51bGw7CiAgICAgICAgICAgICBicmVhazsKIAogICAgICAgICBjYXNlIEVOQ09ESU5HXzdCSVQ6Ci0gICAgICAgICAgICBtZXNzYWdlQm9keSA9IHAuZ2V0VXNlckRhdGFHU003Qml0KGNvdW50LAotICAgICAgICAgICAgICAgICAgICBoYXNVc2VyRGF0YUhlYWRlciA/IHVzZXJEYXRhSGVhZGVyLmxhbmd1YWdlVGFibGUgOiAwLAotICAgICAgICAgICAgICAgICAgICBoYXNVc2VyRGF0YUhlYWRlciA/IHVzZXJEYXRhSGVhZGVyLmxhbmd1YWdlU2hpZnRUYWJsZSA6IDApOworICAgICAgICAgICAgbU1lc3NhZ2VCb2R5ID0gcC5nZXRVc2VyRGF0YUdTTTdCaXQoY291bnQsCisgICAgICAgICAgICAgICAgICAgIGhhc1VzZXJEYXRhSGVhZGVyID8gbVVzZXJEYXRhSGVhZGVyLmxhbmd1YWdlVGFibGUgOiAwLAorICAgICAgICAgICAgICAgICAgICBoYXNVc2VyRGF0YUhl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IDApIHsKLSAgICAgICAgICAgICAgICAgICAgY29ubmVjdFRpbWVSZWFsID0gU3lzdGVtQ2xvY2suZWxhcHNlZFJlYWx0aW1lKCk7Ci0gICAgICAgICAgICAgICAgICAgIGNvbm5lY3RUaW1lID0gU3lzdGVtLmN1cnJlbnRUaW1lTWlsbGlzKCk7CisgICAgICAgICAgICAgICAgaWYgKG1Db25uZWN0VGltZSA9PSAwKSB7CisgICAgICAgICAgICAgICAgICAgIG1Db25uZWN0VGltZVJlYWwgPSBTeXN0ZW1DbG9jay5lbGFwc2VkUmVhbHRpbWUoKTsKKyAgICAgICAgICAgICAgICAgICAgbUNvbm5lY3RUaW1lID0gU3lzdGVtLmN1cnJlbnRUaW1lTWlsbGlzKCk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgY2FzZSBESVNDT05ORUNURUQ6Ci0gICAgICAgICAgICAgICAgZHVyYXRpb24gPSBnZXREdXJhdGlvbk1pbGxpcygpOwotICAgICAgICAgICAgICAgIGRpc2Nvbm5lY3RUaW1lID0gU3lzdGVtLmN1cnJlbnRUaW1lTWlsbGlzKCk7CisgICAgICAgICAgICAgICAgbUR1cmF0aW9uID0gZ2V0RHVyYXRpb25NaWxsaXMoKTsKKyAgICAgICAgICAgICAgICBtRGlzY29ubmVjdFRpbWUgPSBTeXN0ZW0uY3VycmVudFRpbWVNaWxsaXMoKTsKICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIGNhc2UgSE9MRElORzoKLSAgICAgICAgICAgICAgICBob2xkaW5nU3RhcnRUaW1lID0gU3lzdGVtQ2xvY2suZWxhcHNlZFJlYWx0aW1lKCk7CisgICAgICAgICAgICAgICAgbUhvbGRpbmdTdGFydFRpbWUgPSBTeXN0ZW1DbG9jay5lbGFwc2VkUmVhbHRpbWUoKTsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgLy8gSWdub3JlCiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIH0KICAgICB9CiAKICAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgbG9uZyBnZXRDcmVhdGVUaW1lKCkgewotICAgICAgICByZXR1cm4gY3JlYXRlVGltZTsKKyAgICAgICAgaWYgKFZEQkcpIGxvZygiZ2V0Q3JlYXRlVGltZTogcmV0PSIgKyBtQ3JlYXRlVGltZSk7CisgICAgICAgIHJldHVybiBtQ3JlYXRlVGltZTsKICAgICB9CiAKICAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgbG9uZyBnZXRDb25uZWN0VGltZSgpIHsKLSAgICAgICAgcmV0dXJuIGNvbm5lY3RUaW1lOworICAgICAgICBpZiAoVkRCRykgbG9nKCJnZXRDb25uZWN0VGltZTogcmV0PSIgKyBtQ29ubmVjdFRpbWUpOworICAgICAgICByZXR1cm4gbUNvbm5lY3RUaW1lOwogICAgIH0KIAogICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBsb25nIGdldERpc2Nvbm5lY3RUaW1lKCkgewotICAgICAgICByZXR1cm4gZGlzY29ubmVjdFRpbWU7CisgICAgICAgIGlmIChWREJHKSBsb2coImdldERpc2Nvbm5lY3RUaW1lOiByZXQ9IiArIG1EaXNjb25uZWN0VGltZSk7CisgICAgICAgIHJldHVybiBtRGlzY29ubmVjdFRpbWU7CiAgICAgfQogCiAgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGxvbmcgZ2V0RHVyYXRpb25NaWxsaXMoKSB7Ci0gICAgICAgIGlmIChjb25uZWN0VGltZVJlYWwgPT0gMCkgewotICAgICAgICAgICAgcmV0dXJuIDA7Ci0gICAgICAgIH0gZWxzZSBpZiAoZHVyYXRpb24gPCAwKSB7Ci0gICAgICAgICAgICByZXR1cm4gU3lzdGVtQ2xvY2suZWxhcHNlZFJlYWx0aW1lKCkgLSBjb25uZWN0VGltZVJlYWw7CisgICAgICAgIGxvbmcgZHVyOworICAgICAgICBpZiAobUNvbm5lY3RUaW1lUmVhbCA9PSAwKSB7CisgICAgICAgICAgICBkdXIgPSAwOworICAgICAgICB9IGVsc2UgaWYgKG1EdXJhdGlvbiA8IDApIHsKKyAgICAgICAgICAgIGR1ciA9IFN5c3RlbUNsb2NrLmVsYXBzZWRSZWFsdGltZSgpIC0gbUNvbm5lY3RUaW1lUmVhbDsKICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgIHJldHVybiBkdXJhdGlvbjsKKyAgICAgICAgICAgIGR1ciA9IG1EdXJhdGlvbjsKICAgICAgICAgfQorICAgICAgICBpZiAoVkRCRykgbG9nKCJnZXREdXJhdGlvbk1pbGxpczogcmV0PSIgKyBkdXIpOworICAgICAgICByZXR1cm4gZHVyOwogICAgIH0KIAogICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBsb25nIGdldEhvbGREdXJhdGlvbk1pbGxpcygpIHsKKyAgICAgICAgbG9uZyBkdXI7CiAgICAgICAgIGlmIChnZXRTdGF0ZSgpICE9IENhbGwuU3RhdGUuSE9MRElORykgewogICAgICAgICAgICAgLy8gSWYgbm90IGhvbGRpbmcsIHJldHVybiAwCi0gICAgICAgICAgICByZXR1cm4gMDsKKyAgICAgICAgICAgIGR1ciA9IDA7CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICByZXR1cm4gU3lzdGVtQ2xvY2suZWxhcHNlZFJlYWx0aW1lKCkgLSBob2xkaW5nU3RhcnRUaW1lOworICAgICAgICAgICAgZHVyID0gU3lzdGVtQ2xvY2suZWxhcHNlZFJlYWx0aW1lKCkgLSBtSG9sZGluZ1N0YXJ0VGltZTsKICAgICAgICAgfQorICAgICAgICBpZiAoVkRCRykgbG9nKCJnZXRIb2xkRHVyYXRpb25NaWxsaXM6IHJldD0iICsgZHVyKTsKKyAgICAgICAgcmV0dXJuIGR1cjsKICAgICB9CiAKICAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgRGlzY29ubmVjdENhdXNlIGdldERpc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gIC8vIFRPRE8KKyAgICAgICAgaWYgKERCRykgbG9nKCJjYW5jZWxQb3N0RGlhbDogaWdub3JlIik7CiAgICAgfQogCiAgICAgcHJvdGVjdGVkIGFic3RyYWN0IFBob25lIGdldFBob25lKCk7CiAKICAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgU3RyaW5nIGdldFJlbWFpbmluZ1Bvc3REaWFsU3RyaW5nKCkgewotICAgICAgICBpZiAocG9zdERpYWxTdGF0ZSA9PSBQb3N0RGlhbFN0YXRlLkNBTkNFTExFRAotICAgICAgICAgICAgfHwgcG9zdERpYWxTdGF0ZSA9PSBQb3N0RGlhbFN0YXRlLkNPTVBMRVRFCi0gICAgICAgICAgICB8fCBwb3N0RGlhbFN0cmluZyA9PSBudWxsCi0gICAgICAgICAgICB8fCBwb3N0RGlhbFN0cmluZy5sZW5ndGgoKSA8PSBuZXh0UG9zdERpYWxDaGFyKSB7CisgICAgICAgIGlmIChtUG9zdERpYWxTdGF0ZSA9PSBQb3N0RGlhbFN0YXRlLkNBTkNFTExFRAorICAgICAgICAgICAgfHwgbVBvc3REaWFsU3RhdGUgPT0gUG9zdERpYWxTdGF0ZS5DT01QTEVURQorICAgICAgICAgICAgfHwgbVBvc3REaWFsU3RyaW5nID09IG51bGwKKyAgICAgICAgICAgIHx8IG1Qb3N0RGlhbFN0cmluZy5sZW5ndGgoKSA8PSBtTmV4dFBvc3REaWFsQ2hhcikgeworICAgICAgICAgICAgaWYgKERCRykgbG9nKCJnZXRSZW1haW5nUG9zdERpYWxTdHJpbmc6IHJldCBlbXB0eSBzdHJpbmciKTsKICAgICAgICAgICAgIHJldHVybiAiIjsKICAgICAgICAgfQogCi0gICAgICAgIHJldHVybiBwb3N0RGlhbFN0cmluZy5zdWJzdHJpbmcobmV4dFBvc3REaWFsQ2hhcik7CisgICAgICAgIHJldHVybiBtUG9zdERpYWxTdHJpbmcuc3Vic3RyaW5nKG1OZXh0UG9zdERpYWxDaGFyKTsKICAgICB9CiAKICAg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0PWZhbHNlLCByaW5naW5nQ2FsbCBub3QgYWxpdmUiKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CisgICAgICAgICAgICB9CiAKICAgICAgICAgICAgIC8vIEZJWE1FOiBpcyBpdCB0cnVlIHRoYXQgd2UgY2Fubm90IHRha2UgYW55IGluY29taW5nIGNhbGwgaWYKICAgICAgICAgICAgIC8vIGJvdGggZm9yZWdyb3VuZCBhbmQgYmFja2dyb3VuZCBhcmUgYWN0aXZlCi0gICAgICAgICAgICBpZiAoZm9yZWdyb3VuZENhbGwuZ2V0U3RhdGUoKS5pc0FsaXZlKCkKLSAgICAgICAgICAgICAgICAgICAgJiYgYmFja2dyb3VuZENhbGwuZ2V0U3RhdGUoKS5pc0FsaXZlKCkpIHsKKyAgICAgICAgICAgIGlmIChtRm9yZWdyb3VuZENhbGwuZ2V0U3RhdGUoKS5pc0FsaXZlKCkKKyAgICAgICAgICAgICAgICAgICAgJiYgbUJhY2tncm91bmRDYWxsLmdldFN0YXRlKCkuaXNBbGl2ZSgpKSB7CisgICAgICAgICAgICAgICAgaWYgKERCRykgeworICAgICAgICAgICAgICAgICAgICBsb2coImNhblRha2U6IHJldD1mYWxzZSwiICsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAiIGZvcmVncm91bmQgYW5kIGJhY2tncm91bmQgYm90aCBhbGl2ZSIpOworICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgU2lwQXVkaW9DYWxsIHNpcEF1ZGlvQ2FsbCA9IChTaXBBdWRpb0NhbGwpIGluY29taW5nQ2FsbDsKLSAgICAgICAgICAgICAgICBpZiAoREVCVUcpIFJsb2cuZChMT0dfVEFHLCAiKysrIHRha2luZyBjYWxsIGZyb206ICIKKyAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coImNhblRha2U6IHRha2luZyBjYWxsIGZyb206ICIKICAgICAgICAgICAgICAgICAgICAgICAgICsgc2lwQXVkaW9DYWxsLmdldFBlZXJQcm9maWxlKCkuZ2V0VXJpU3RyaW5nKCkpOwogICAgICAgICAgICAgICAgIFN0cmluZyBsb2NhbFVyaSA9IHNpcEF1ZGlvQ2FsbC5nZXRMb2NhbFByb2ZpbGUoKS5nZXRVcmlTdHJpbmcoKTsKICAgICAgICAgICAgICAgICBpZiAobG9jYWxVcmkuZXF1YWxzKG1Qcm9maWxlLmdldFVyaVN0cmluZygpKSkgewotICAgICAgICAgICAgICAgICAgICBib29sZWFuIG1ha2VDYWxsV2FpdCA9IGZvcmVncm91bmRDYWxsLmdldFN0YXRlKCkuaXNBbGl2ZSgpOwotICAgICAgICAgICAgICAgICAgICByaW5naW5nQ2FsbC5pbml0SW5jb21pbmdDYWxsKHNpcEF1ZGlvQ2FsbCwgbWFrZUNhbGxXYWl0KTsKKyAgICAgICAgICAgICAgICAgICAgYm9vbGVhbiBtYWtlQ2FsbFdhaXQgPSBtRm9yZWdyb3VuZENhbGwuZ2V0U3RhdGUoKS5pc0FsaXZlKCk7CisgICAgICAgICAgICAgICAgICAgIG1SaW5naW5nQ2FsbC5pbml0SW5jb21pbmdDYWxsKHNpcEF1ZGlvQ2FsbCwgbWFrZUNhbGxXYWl0KTsKICAgICAgICAgICAgICAgICAgICAgaWYgKHNpcEF1ZGlvQ2FsbC5nZXRTdGF0ZSgpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIT0gU2lwU2Vzc2lvbi5TdGF0ZS5JTkNPTUlOR19DQUxMKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBQZWVyIGNhbmNlbGxlZCB0aGUgY2FsbCEKLSAgICAgICAgICAgICAgICAgICAgICAgIGlmIChERUJVRykgUmxvZy5kKExPR19UQUcsICIgICAgY2FsbCBjYW5jZWxsZWQgISEiKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIHJpbmdpbmdDYWxsLnJlc2V0KCk7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coIiAgICBjYW5UYWtlOiBjYWxsIGNhbmNlbGxlZCAhISIpOworICAgICAgICAgICAgICAgICAgICAgICAgbVJpbmdpbmdDYWxsLnJlc2V0KCk7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgfQpAQCAtMTI0LDM3ICsxMzksNTAgQEAKICAgICAgICAgICAgICAgICAvLyBQZWVyIG1heSBjYW5jZWwgdGhlIGNhbGwgYXQgYW55IHRpbWUgZHVyaW5nIHRoZSB0aW1lIHdlIGhvb2sKICAgICAgICAgICAgICAgICAvLyB1cCByaW5naW5nQ2FsbCB3aXRoIHNpcEF1ZGlvQ2FsbC4gQ2xlYW4gdXAgcmluZ2luZ0NhbGwgd2hlbgogICAgICAgICAgICAgICAgIC8vIHRoYXQgaGFwcGVucy4KLSAgICAgICAgICAgICAgICByaW5naW5nQ2FsbC5yZXNldCgpOworICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygiICAgIGNhblRha2U6IGV4Y2VwdGlvbiBlPSIgKyBlKTsKKyAgICAgICAgICAgICAgICBtUmluZ2luZ0NhbGwucmVzZXQoKTsKICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGlmIChEQkcpIGxvZygiY2FuVGFrZTogTk9UIHRha2luZyAhISIpOwogICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICB9CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgYWNjZXB0Q2FsbCgpIHRocm93cyBDYWxsU3RhdGVFeGNlcHRpb24gewogICAgICAgICBzeW5jaHJvbml6ZWQgKFNpcFBob25lLmNsYXNzKSB7Ci0gICAgICAgICAgICBpZiAoKHJpbmdpbmdDYWxsLmdldFN0YXRlKCkgPT0gQ2FsbC5TdGF0ZS5JTkNPTUlORykgfHwKLSAgICAgICAgICAgICAgICAgICAgKHJpbmdpbmdDYWxsLmdldFN0YXRlKCkgPT0gQ2FsbC5TdGF0ZS5XQUlUSU5HKSkgewotICAgICAgICAgICAgICAgIGlmIChERUJVRykgUmxvZy5kKExPR19UQUcsICJhY2NlcHRDYWxsIik7CisgICAgICAgICAgICBpZiAoKG1SaW5naW5nQ2FsbC5nZXRTdGF0ZSgpID09IENhbGwuU3RhdGUuSU5DT01JTkcpIHx8CisgICAgICAgICAgICAgICAgICAgIChtUmluZ2luZ0NhbGwuZ2V0U3RhdGUoKSA9PSBDYWxsLlN0YXRlLldBSVRJTkcpKSB7CisgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJhY2NlcHRDYWxsOiBhY2NlcHRpbmciKTsKICAgICAgICAgICAgICAgICAvLyBBbHdheXMgdW5tdXRlIHdoZW4gYW5zd2VyaW5nIGEgbmV3IGNhbGwKLSAgICAgICAgICAgICAgICByaW5naW5nQ2FsbC5zZXRNdXRlKGZhbHNlKTsKLSAgICAgICAgICAgICAgICByaW5naW5nQ2FsbC5hY2NlcHRDYWxsKCk7CisgICAgICAgICAgICAgICAgbVJpbmdpbmdDYWxsLnNldE11dGUoZmFsc2UpOworICAgICAgICAgICAgICAgIG1SaW5naW5nQ2FsbC5hY2NlcHRDYWxsKCk7CiAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgIGlmIChEQkcpIHsKKyAgICAgICAgICAgICAgICAgICAgbG9nKCJhY2NlcHRDYWxsOiIgKworICAgICAgICAgICAgICAgICAgICAgICAgIiB0aHJvdyBDYWxsU3RhdGVFeGNlcHRpb24oXCJwaG9uZSBub3QgcmluZ2luZ1wiKSIpOworICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgQ2FsbFN0YXRlRXhjZXB0aW9uKCJwaG9uZSBub3QgcmluZ2luZyIpOwogICAgICAgICAgICAgfQogICAgICAgICB9CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgcmVqZWN0Q2FsbCgpIHRocm93cyBDYWxsU3RhdGVFeGNlcHRpb24gewogICAgICAgICBzeW5jaHJvbml6ZWQgKFNpcFBob25lLmNsYXNzKSB7Ci0gICAgICAgICAgICBpZiAocmluZ2luZ0NhbGwuZ2V0U3RhdGUoKS5pc1JpbmdpbmcoKSkgewotICAgICAgICAgICAgICAgIGlmIChERUJVRykgUmxvZy5kKExPR19UQUcsICJyZWplY3RDYWxsIik7Ci0gICAgICAgICAgICAgICAgcmluZ2luZ0NhbGwucmVqZWN0Q2FsbCgpOworICAgICAgICAgICAgaWYgKG1SaW5naW5nQ2FsbC5nZXRTdGF0ZSgpLmlzUmluZ2luZygpKSB7CisgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJyZWplY3RDYWxsOiByZWplY3RpbmciKTsKKyAgICAgICAgICAgICAgICBtUmluZ2luZ0NhbGwucmVqZWN0Q2FsbCgpOwogICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICBpZiAoREJHKSB7CisgICAgICAgICAgICAgICAgICAgIGxvZygicmVqZWN0Q2FsbDoiICsKKyAgICAgICAgICAgICAgICAgICAgICAgICIgdGhyb3cgQ2FsbFN0YXRlRXhjZXB0aW9uKFwicGhvbmUgbm90IHJpbmdpbmdcIikiKTsKKyAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IENhbGxTdGF0ZUV4Y2VwdGlvbigicGhvbmUgbm90IHJpbmdpbmciKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfQogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBDb25uZWN0aW9uIGRpYWwoU3RyaW5nIGRpYWxTdHJpbmcpIHRocm93cyBDYWxsU3RhdGVFeGNlcHRpb24gewogICAgICAgICBzeW5jaHJvbml6ZWQgKFNpcFBob25lLmNsYXNzKSB7CiAgICAgICAgICAgICByZXR1cm4gZGlhbEludGVybmFsKGRpYWxTdHJpbmc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CiAgICAgcHVibGljIHZvaWQgc2VuZER0bWYoY2hhciBjKSB7CiAgICAgICAgIGlmICghUGhvbmVOdW1iZXJVdGlscy5pczEyS2V5KGMpKSB7Ci0gICAgICAgICAgICBSbG9nLmUoTE9HX1RBRywKLSAgICAgICAgICAgICAgICAgICAgInNlbmREdG1mIGNhbGxlZCB3aXRoIGludmFsaWQgY2hhcmFjdGVyICciICsgYyArICInIik7Ci0gICAgICAgIH0gZWxzZSBpZiAoZm9yZWdyb3VuZENhbGwuZ2V0U3RhdGUoKS5pc0FsaXZlKCkpIHsKKyAgICAgICAgICAgIGxvZ2UoInNlbmREdG1mIGNhbGxlZCB3aXRoIGludmFsaWQgY2hhcmFjdGVyICciICsgYyArICInIik7CisgICAgICAgIH0gZWxzZSBpZiAobUZvcmVncm91bmRDYWxsLmdldFN0YXRlKCkuaXNBbGl2ZSgpKSB7CiAgICAgICAgICAgICBzeW5jaHJvbml6ZWQgKFNpcFBob25lLmNsYXNzKSB7Ci0gICAgICAgICAgICAgICAgZm9yZWdyb3VuZENhbGwuc2VuZER0bWYoYyk7CisgICAgICAgICAgICAgICAgbUZvcmVncm91bmRDYWxsLnNlbmREdG1mKGMpOwogICAgICAgICAgICAgfQogICAgICAgICB9CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgc3RhcnREdG1mKGNoYXIgYykgewogICAgICAgICBpZiAoIVBob25lTnVtYmVyVXRpbHMuaXMxMktleShjKSkgewotICAgICAgICAgICAgUmxvZy5lKExPR19UQUcsCi0gICAgICAgICAgICAgICAgInN0YXJ0RHRtZiBjYWxsZWQgd2l0aCBpbnZhbGlkIGNoYXJhY3RlciAnIiArIGMgKyAiJyIpOworICAgICAgICAgICAgbG9nZSgic3RhcnREdG1mIGNhbGxlZCB3aXRoIGludmFsaWQgY2hhcmFjdGVyICciICsgYyArICInIik7CiAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICBzZW5kRHRtZihjKTsKICAgICAgICA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WQgcmVzZXQoKSB7Ci0gICAgICAgICAgICBjb25uZWN0aW9ucy5jbGVhcigpOworICAgICAgICAgICAgaWYgKFNDX0RCRykgbG9nKCJyZXNldCIpOworICAgICAgICAgICAgbUNvbm5lY3Rpb25zLmNsZWFyKCk7CiAgICAgICAgICAgICBzZXRTdGF0ZShDYWxsLlN0YXRlLklETEUpOwogICAgICAgICB9CiAKICAgICAgICAgdm9pZCBzd2l0Y2hXaXRoKFNpcENhbGwgdGhhdCkgeworICAgICAgICAgICAgaWYgKFNDX0RCRykgbG9nKCJzd2l0Y2hXaXRoIik7CiAgICAgICAgICAgICBzeW5jaHJvbml6ZWQgKFNpcFBob25lLmNsYXNzKSB7CiAgICAgICAgICAgICAgICAgU2lwQ2FsbCB0bXAgPSBuZXcgU2lwQ2FsbCgpOwogICAgICAgICAgICAgICAgIHRtcC50YWtlT3Zlcih0aGlzKTsKQEAgLTM2NSw5ICs0NTIsMTAgQEAKICAgICAgICAgfQogCiAgICAgICAgIHByaXZhdGUgdm9pZCB0YWtlT3ZlcihTaXBDYWxsIHRoYXQpIHsKLSAgICAgICAgICAgIGNvbm5lY3Rpb25zID0gdGhhdC5jb25uZWN0aW9uczsKLSAgICAgICAgICAgIHN0YXRlID0gdGhhdC5zdGF0ZTsKLSAgICAgICAgICAgIGZvciAoQ29ubmVjdGlvbiBjIDogY29ubmVjdGlvbnMpIHsKKyAgICAgICAgICAgIGlmIChTQ19EQkcpIGxvZygidGFrZU92ZXIiKTsKKyAgICAgICAgICAgIG1Db25uZWN0aW9ucyA9IHRoYXQubUNvbm5lY3Rpb25zOworICAgICAgICAgICAgbVN0YXRlID0gdGhhdC5tU3RhdGU7CisgICAgICAgICAgICBmb3IgKENvbm5lY3Rpb24gYyA6IG1Db25uZWN0aW9ucykgewogICAgICAgICAgICAgICAgICgoU2lwQ29ubmVjdGlvbikgYykuY2hhbmdlT3duZXIodGhpcyk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KQEAgLTM3OSwxMyArNDY3LDE2IEBACiAKICAgICAgICAgQE92ZXJyaWRlCiAgICAgICAgIHB1YmxpYyBMaXN0PENvbm5lY3Rpb24+IGdldENvbm5lY3Rpb25zKCkgeworICAgICAgICAgICAgaWYgKFNDX1ZEQkcpIGxvZygiZ2V0Q29ubmVjdGlvbnMiKTsKICAgICAgICAgICAgIHN5bmNocm9uaXplZCAoU2lwUGhvbmUuY2xhc3MpIHsKICAgICAgICAgICAgICAgICAvLyBGSVhNRSBzaG91bGQgcmV0dXJuIENvbGxlY3Rpb25zLnVubW9kaWZpYWJsZUxpc3QoKTsKLSAgICAgICAgICAgICAgICByZXR1cm4gY29ubmVjdGlvbnM7CisgICAgICAgICAgICAgICAgcmV0dXJuIG1Db25uZWN0aW9uczsKICAgICAgICAgICAgIH0KICAgICAgICAgfQogCiAgICAgICAgIENvbm5lY3Rpb24gZGlhbChTdHJpbmcgb3JpZ2luYWxOdW1iZXIpIHRocm93cyBTaXBFeGNlcHRpb24geworICAgICAgICAgICAgaWYgKFNDX0RCRykgbG9nKCJkaWFsOiBudW09IiArIChTQ19WREJHID8gb3JpZ2luYWxOdW1iZXIgOiAieHh4IikpOworICAgICAgICAgICAgLy8gVE9ETzogU2hvdWxkIHRoaXMgYmUgc3luY2hyb25pemVkPwogICAgICAgICAgICAgU3RyaW5nIGNhbGxlZVNpcFVyaSA9IG9yaWdpbmFsTnVtYmVyOwogICAgICAgICAgICAgaWYgKCFjYWxsZWVTaXBVcmkuY29udGFpbnMoIkAiKSkgewogICAgICAgICAgICAgICAgIFN0cmluZyByZXBsYWNlU3RyID0gUGF0dGVybi5xdW90ZShtUHJvZmlsZS5nZXRVc2VyTmFtZSgpICsgIkAiKTsKQEAgLTM5OCw3ICs0ODksNyBAQAogICAgICAgICAgICAgICAgIFNpcENvbm5lY3Rpb24gYyA9IG5ldyBTaXBDb25uZWN0aW9uKHRoaXMsIGNhbGxlZSwKICAgICAgICAgICAgICAgICAgICAgICAgIG9yaWdpbmFsTnVtYmVyKTsKICAgICAgICAgICAgICAgICBjLmRpYWwoKTsKLSAgICAgICAgICAgICAgICBjb25uZWN0aW9ucy5hZGQoYyk7CisgICAgICAgICAgICAgICAgbUNvbm5lY3Rpb25zLmFkZChjKTsKICAgICAgICAgICAgICAgICBzZXRTdGF0ZShDYWxsLlN0YXRlLkRJQUxJTkcpOwogICAgICAgICAgICAgICAgIHJldHVybiBjOwogICAgICAgICAgICAgfSBjYXRjaCAoUGFyc2VFeGNlcHRpb24gZSkgewpAQCAtNDA5LDEyICs1MDAsMTIgQEAKICAgICAgICAgQE92ZXJyaWRlCiAgICAgICAgIHB1YmxpYyB2b2lkIGhhbmd1cCgpIHRocm93cyBDYWxsU3RhdGVFeGNlcHRpb24gewogICAgICAgICAgICAgc3luY2hyb25pemVkIChTaXBQaG9uZS5jbGFzcykgewotICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5pc0FsaXZlKCkpIHsKLSAgICAgICAgICAgICAgICAgICAgaWYgKERFQlVHKSBSbG9nLmQoTE9HX1RBRywgImhhbmcgdXAgY2FsbDogIiArIGdldFN0YXRlKCkKKyAgICAgICAgICAgICAgICBpZiAobVN0YXRlLmlzQWxpdmUoKSkgeworICAgICAgICAgICAgICAgICAgICBpZiAoU0NfREJHKSBsb2coImhhbmd1cDogY2FsbCAiICsgZ2V0U3RhdGUoKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgIjogIiArIHRoaXMgKyAiIG9uIHBob25lICIgKyBnZXRQaG9uZSgpKTsKICAgICAgICAgICAgICAgICAgICAgc2V0U3RhdGUoU3RhdGUuRElTQ09OTkVDVElORyk7CiAgICAgICAgICAgICAgICAgICAgIENhbGxTdGF0ZUV4Y2VwdGlvbiBleGNwID0gbnVsbDsKLSAgICAgICAgICAgICAgICAgICAgZm9yIChDb25uZWN0aW9uIGMgOiBjb25uZWN0aW9ucykgeworICAgICAgICAgICAgICAgICAgICBmb3IgKENvbm5lY3Rpb24gYyA6IG1Db25uZWN0aW9ucykgewogICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjLmhhbmd1cCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoQ2FsbFN0YXRlRXhjZXB0aW9uIGUpIHsKQEAgLTQyMyw3ICs1MTQsNyBAQAogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIGlmIChleGNwICE9IG51bGwpIHRocm93IGV4Y3A7CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgaWYgKERFQlVHKSBSbG9nLmQoTE9HX1RBRywgImhhbmcgdXAgZGVhZCBjYWxsOiAiICsgZ2V0U3RhdGUoKQorICAgICAgICAgICAgICAgICAgICBpZiAoU0NfREJHKSBsb2coImhhbmd1cDogZGVhZCBjYWxsICIgKyBnZXRTdGF0ZSgpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyAiOiAiICsgdGhpcyArICIgb24gcGhvbmUgIiArIGdldFBob25lKCkpOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KQEAgLTQzMiw3ICs1MjMsNyBAQAogICAgICAgICB2b2lkIGluaXRJbmNvbWluZ0NhbGwoU2lwQXVkaW9DYWxsIHNpcEF1ZGlvQ2FsbCwgYm9vbGVhbiBtYWtlQ2FsbFdhaXQpIHsKICAgICAgICAgICAgIFNpcFByb2ZpbGUgY2FsbGVlID0gc2lwQXVkaW9DYWxsLmdldFBlZXJQcm9maWxlKCk7CiAgICAgICAgICAgICBTaXBDb25uZWN0aW9uIGMgPSBuZXcgU2lwQ29ubmVjdGlvbih0aGlzLCBjYWxsZWUpOwotICAgICAgICAgICAgY29ubmVjdGlvbnMuYWRkKGMpOworICAgICAgICAgICAgbUNvbm5lY3Rpb25zLmFkZChjKTsKIAogICAgICAgICAgICAgQ2FsbC5TdGF0ZSBuZXdTdGF0ZSA9IG1ha2VDYWxsV2FpdCA/IFN0YXRlLldBSVRJTkcgOiBTdGF0ZS5JTkNPTUlORzsKICAgICAgICAgICAgIGMuaW5pdEluY29taW5nQ2FsbChzaXBBdWRpb0NhbGwsIG5ld1N0YXRlKTsKQEAgLTQ0MiwyOSArNTMzLDM2IEBACiAgICAgICAgIH0KIAogICAgICAgICB2b2lkIHJlamVjdENhbGwoKSB0aHJvd3MgQ2FsbFN0YXRlRXhjZXB0aW9uIHsKKyAgICAgICAgICAgIGlmIChTQ19EQkcpIGxvZygicmVqZWN0Q2FsbDoiKTsKICAgICAgICAgICAgIGhhbmd1cCgpOwogICAgICAgICB9CiAKICAgICAgICAgdm9pZCBhY2NlcHRDYWxsKCkgdGhyb3dzIENhbGxTdGF0ZUV4Y2VwdGlvbiB7Ci0gICAgICAgICAgICBpZiAodGhpcyAhPSByaW5naW5nQ2FsbCkgeworICAgICAgICAgICAgaWYgKFNDX0RCRykgbG9nKCJhY2NlcHRDYWxsOiBhY2NlcHRpbmciKTsKKyAgICAgICAgICAgIGlmICh0aGlzICE9IG1SaW5naW5nQ2FsbCkgewogICAgICAgICAgICAgICAgIHRocm93IG5ldyBDYWxsU3RhdGVFeGNlcHRpb24oImFjY2VwdENhbGwoKSBpbiBhIG5vbi1yaW5naW5nIGNhbGwiKTsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGlmIChjb25uZWN0aW9ucy5zaXplKCkgIT0gMSkgeworICAgICAgICAgICAgaWYgKG1Db25uZWN0aW9ucy5zaXplKCkgIT0gMSkgewogICAgICAgICAgICAgICAgIHRocm93IG5ldyBDYWxsU3RhdGVFeGNlcHRpb24oImFjY2VwdENhbGwoKSBpbiBhIGNvbmYgY2FsbCIpOwogICAgICAgICAgICAgfQotICAgICAgICAgICAgKChTaXBDb25uZWN0aW9uKSBjb25uZWN0aW9ucy5nZXQoMCkpLmFjY2VwdENhbGwoKTsKKyAgICAgICAgICAgICgoU2lwQ29ubmVjdGlvbikgbUNvbm5lY3Rpb25zLmdldCgwKSkuYWNjZXB0Q2FsbCgpOwogICAgICAgICB9CiAKICAgICAgICAgcHJpdmF0ZSBib29sZWFuIGlzU3BlYWtlck9uKCkgewotICAgICAgICAgICAgcmV0dXJuICgoQXVkaW9NYW5hZ2VyKSBtQ29udGV4dC5nZXRTeXN0ZW1TZXJ2aWNlKENvbnRleHQuQVVESU9fU0VSVklDRSkpCisgICAgICAgICAgICBCb29sZWFuIHJldCA9ICgoQXVkaW9NYW5hZ2VyKSBtQ29udGV4dC5nZXRTeXN0ZW1TZXJ2aWNlKENvbnRleHQuQVVESU9fU0VSVklDRSkpCiAgICAgICAgICAgICAgICAgICAgIC5pc1NwZWFrZXJwaG9uZU9uKCk7CisgICAgICAgICAgICBpZiAoU0NfVkRCRykgbG9nKCJpc1NwZWFrZXJPbjogcmV0PSIgKyByZXQpOworICAgICAgICAgICAgcmV0dXJuIHJldDsKICAgICAgICAgfQogCiAgICAgICAgIHZvaWQgc2V0QXVkaW9Hcm91cE1vZGUoKSB7CiAgICAgICAgICAgICBBdWRpb0dyb3VwIGF1ZGlvR3JvdXAgPSBnZXRBdWRpb0dyb3VwKCk7Ci0gICAgICAgICAgICBpZiAoYXVkaW9Hcm91cCA9PSBudWxsKSByZXR1cm47CisgICAgICAgICAgICBpZiAoYXVkaW9Hcm91cCA9PSBudWxsKSB7CisgICAgICAgICAgICAgICAgaWYgKFNDX0RCRykgbG9nKCJzZXRBdWRpb0dyb3VwTW9kZTogYXVkaW9Hcm91cCA9PSBudWxsIGlnbm9yZSIpOworICAgICAgICAgICAgICAgIHJldHVybjsKKyAgICAgICAgICAgIH0KICAgICAgICAgICAgIGludCBtb2RlID0gYXVkaW9Hcm91cC5nZXRNb2RlKCk7Ci0gICAgICAgICAgICBpZiAoc3RhdGUgPT0gU3RhdGUuSE9MRElORykgeworICAgICAgICAgICAgaWYgKG1TdGF0ZSA9PSBTdGF0ZS5IT0xESU5HKSB7CiAgICAgICAgICAgICAgICAgYXVkaW9Hcm91cC5zZXRNb2RlKEF1ZGlvR3JvdXAuTU9ERV9PTl9IT0xEKTsKICAgICAgICAgICAgIH0gZWxzZSBpZiAoZ2V0TXV0ZSgpKSB7CiAgICAgICAgICAgICAgICAgYXVkaW9Hcm91cC5zZXRNb2RlKEF1ZGlvR3JvdXAuTU9ERV9NVVRFRCk7CkBAIC00NzMsNDUgKzU3MSw1MSBAQAogICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICBhdWRpb0dyb3VwLnNldE1vZGUoQXVkaW9Hcm91cC5NT0RFX05PUk1BTCk7CiAgICAgICAgICAgICB9Ci0gICAgICAgICAgICBpZiAoREVCVUcpIFJsb2cuZChMT0dfVEFHLCBTdHJpbmcuZm9ybWF0KAotICAgICAgICAgICAgICAgICAgICAiYXVkaW9Hcm91cCBtb2RlIGNoYW5nZTogJWQgLS0+ICVkIiwgbW9kZSwKKyAgICAgICAgICAgIGlmIChTQ19EQkcpIGxvZyhTdHJpbmcuZm9ybWF0KAorICAgICAgICAgICAgICAgICAgICAic2V0QXVkaW9Hcm91cE1vZGUgY2hhbmdlOiAlZCAtLT4gJWQiLCBtb2RlLAogICAgICAgICAgICAgICAgICAgICBhdWRpb0dyb3VwLmdldE1vZGUoKSkpOwogICAgICAgICB9CiAKICAgICAgICAgdm9pZCBob2xkKCkgdGhyb3dzIENhbGxTdGF0ZUV4Y2VwdGlvbiB7CisgICAgICAgICAgICBpZiAoU0NfREJHKSBsb2coImhvbGQ6Iik7CiAgICAgICAgICAgICBzZXRTdGF0ZShTdGF0ZS5IT0xESU5HKTsKLSAgICAgICAgICAgIGZvciAoQ29ubmVjdGlvbiBjIDogY29ubmVjdGlvbnMpICgoU2lwQ29ubmVjdGlvbikgYykuaG9sZCgpOworICAgICAgICAgICAgZm9yIChDb25uZWN0aW9uIGMgOiBtQ29ubmVjdGlvbnMpICgoU2lwQ29ubmVjdGlvbikgYykuaG9sZCgpOwogICAgICAgICAgICAgc2V0QXVkaW9Hcm91cE1vZGUoKTsKICAgICAgICAgfQogCiAgICAgICAgIHZvaWQgdW5ob2xkKCkgdGhyb3dzIENhbGxTdGF0ZUV4Y2VwdGlvbiB7CisgICAgICAgICAgICBpZiAoU0NfREJHKSBsb2coInVuaG9sZDoiKTsKICAgICAgICAgICAgIHNldFN0YXRlKFN0YXRlLkFDVElWRSk7CiAgICAgICAgICAgICBBdWRpb0dyb3VwIGF1ZGlvR3JvdXAgPSBuZXcgQXVkaW9Hcm91cCgpOwotICAgICAgICAgICAgZm9yIChDb25uZWN0aW9uIGMgOiBjb25uZWN0aW9ucykgeworICAgICAgICAgICAgZm9yIChDb25uZWN0aW9uIGMgOiBtQ29ubmVjdGlvbnMpIHsKICAgICAgICAgICAgICAgICAoKFNpcENvbm5lY3Rpb24pIGMpLnVuaG9sZChhdWRpb0dyb3VwKTsKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIHNldEF1ZGlvR3JvdXBNb2RlKCk7CiAgICAgICAgIH0KIAogICAgICAgICB2b2lkIHNldE11dGUoYm9vbGVhbiBtdXRlZCkgewotICAgICAgICAgICAgZm9yIChDb25uZWN0aW9uIGMgOiBjb25uZWN0aW9ucykgeworICAgICAgICAgICAgaWYgKFNDX0RCRykgbG9nKCJzZXRNdXRlOiBtdXRlZD0iICsgbXV0ZWQpOworICAgICAgICAgICAgZm9yIChDb25uZWN0aW9uIGMgOiBtQ29ubmVjdGlvbnMpIHsKICAgICAgICAgICAgICAgICAoKFNpcENvbm5lY3Rpb24pIGMpLnNldE11dGUobXV0ZWQpOwogICAgICAgICAgICAgfQogICAgICAgICB9CiAKICAgICAgICAgYm9vbGVhbiBnZXRNdXRlKCkgewotICAgICAgICAgICAgcmV0dXJuIGNvbm5lY3Rpb25zLmlzRW1wdHkoKQorICAgICAgICAgICAgYm9vbGVhbiByZXQgPSBtQ29ubmVjdGlvbnMuaXNFbXB0eSgpCiAgICAgICAgICAgICAgICAgICAgID8gZmFsc2UKLSAgICAgICAgICAgICAgICAgICAgOiAoKFNpcENvbm5lY3Rpb24pIGNvbm5lY3Rpb25zLmdldCgwKSkuZ2V0TXV0ZSgpOworICAgICAgICAgICAgICAgICAgICA6ICgoU2lwQ29ubmVjdGlvbikgbUNvbm5lY3Rpb25zLmdldCgwKSkuZ2V0TXV0ZSgpOworICAgICAgICAgICAgaWYgKFNDX0RCRykgbG9nKCJnZXRNdXRlOiByZXQ9IiArIHJldCk7CisgICAgICAgICAgICByZXR1cm4gcmV0OwogICAgICAgICB9CiAKICAgICAgICAgdm9pZCBtZXJnZShTaXBDYWxsIHRoYXQpIHRocm93cyBDYWxsU3RhdGVFeGNlcHRpb24geworICAgICAgICAgICAgaWYgKFNDX0RCRykgbG9nKCJtZXJnZToiKTsKICAgICAgICAgICAgIEF1ZGlvR3JvdXAgYXVkaW9Hcm91cCA9IGdldEF1ZGlvR3JvdXAoKTsKIAogICAgICAgICAgICAgLy8gY29weSB0byBhbiBhcnJheSB0byBhdm9pZCBjb25jdXJyZW50IG1vZGlmaWNhdGlvbiBhcyBjb25uZWN0aW9ucwogICAgICAgICAgICAgLy8gaW4gdGhhdC5jb25uZWN0aW9ucyB3aWxsIGJlIHJlbW92ZWQgaW4gYWRkKFNpcENvbm5lY3Rpb24pLgotICAgICAgICAgICAgQ29ubmVjdGlvbltdIGNjID0gdGhhdC5jb25uZWN0aW9ucy50b0FycmF5KAotICAgICAgICAgICAgICAgICAgICBuZXcgQ29ubmVjdGlvblt0aGF0LmNvbm5lY3Rpb25zLnNpemUoKV0pOworICAgICAgICAgICAgQ29ubmVjdGlvbltdIGNjID0gdGhhdC5tQ29ubmVjdGlvbnMudG9BcnJheSgKKyAgICAgICAgICAgICAgICAgICAgbmV3IENvbm5lY3Rpb25bdGhhdC5tQ29ubmVjdGlvbnMuc2l6ZSgpXSk7CiAgICAgICAgICAgICBmb3IgKENvbm5lY3Rpb24gYyA6IGNjKSB7CiAgICAgICAgICAgICAgICAgU2lwQ29ubmVjdGlvbiBjb25uID0gKFNpcENvbm5lY3Rpb24pIGM7CiAgICAgICAgICAgICAgICAgYWRkKGNvbm4pOwpAQCAtNTIzLDE3ICs2MjcsMjIgQEAKICAgICAgICAgfQogCiAgICAgICAgIHByaXZhdGUgdm9pZCBhZGQoU2lwQ29ubmVjdGlvbiBjb25uKSB7CisgICAgICAgICAgICBpZiAoU0NfREJHKSBsb2coImFkZDoiKTsKICAgICAgICAgICAgIFNpcENhbGwgY2FsbCA9IGNvbm4uZ2V0Q2FsbCgpOwogICAgICAgICAgICAgaWYgKGNhbGwgPT0gdGhpcykgcmV0dXJuOwotICAgICAgICAgICAgaWYgKGNhbGwgIT0gbnVsbCkgY2FsbC5jb25uZWN0aW9ucy5yZW1vdmUoY29ubik7CisgICAgICAgICAgICBpZiAoY2FsbCAhPSBudWxsKSBjYWxsLm1Db25uZWN0aW9ucy5yZW1vdmUoY29ubik7CiAKLSAgICAgICAgICAgIGNvbm5lY3Rpb25zLmFkZChjb25uKTsKKyAgICAgICAgICAgIG1Db25uZWN0aW9ucy5hZGQoY29ubik7CiAgICAgICAgICAgICBjb25uLmNoYW5nZU93bmVyKHRoaXMpOwogICAgICAgICB9CiAKICAgICAgICAgdm9pZCBzZW5kRHRtZihjaGFyIGMpIHsKKyAgICAgICAgICAgIGlmIChTQ19EQkcpIGxvZygic2VuZER0bWY6IGM9IiArIGMpOwogICAgICAgICAgICAgQXVkaW9Hcm91cCBhdWRpb0dyb3VwID0gZ2V0QXVkaW9Hcm91cCgpOwotICAgICAgICAgICAgaWYgKGF1ZGlvR3JvdXAgPT0gbnVsbCkgcmV0dXJuOworICAgICAgICAgICAgaWYgKGF1ZGlvR3JvdXAgPT0gbnVsbCkgeworICAgICAgICAgICAgICAgIGlmIChTQ19EQkcpIGxvZygic2VuZER0bWY6IGF1ZGlvR3JvdXAgPT0gbnVsbCwgaWdub3JlIGM9IiArIGMpOworICAgICAgICAgICAgICAgIHJldHVybjsKKyAgICAgICAgICAgIH0KICAgICAgICAgICAgIGF1ZGlvR3JvdXAuc2VuZER0bWYoY29udmVydER0bWYoYykpOwogICAgICAgICB9CiAKQEAgLTU1NywxOCArNjY2LDE4IEBACiAKICAgICAgICAgQE92ZXJyaWRlCiAgICAgICAgIHByb3RlY3RlZCB2b2lkIHNldFN0YXRlKFN0YXRlIG5ld1N0YXRlKSB7Ci0gICAgICAgICAgICBpZiAoc3RhdGUgIT0gbmV3U3RhdGUpIHsKLSAgICAgICAgICAgICAgICBpZiAoREVCVUcpIFJsb2cudihMT0dfVEFHLCAiKyoqKisgY2FsbCBzdGF0ZSBjaGFuZ2VkOiAiICsgc3RhdGUKKyAgICAgICAgICAgIGlmIChtU3RhdGUgIT0gbmV3U3RhdGUpIHsKKyAgICAgICAgICAgICAgICBpZiAoU0NfREJHKSBsb2coInNldFN0YXRlOiBjdXIgc3RhdGUiICsgbVN0YXRlCiAgICAgICAgICAgICAgICAgICAgICAgICArICIgLS0+ICIgKyBuZXdTdGF0ZSArICI6ICIgKyB0aGlzICsgIjogb24gcGhvbmUgIgotICAgICAgICAgICAgICAgICAgICAgICAgKyBnZXRQaG9uZSgpICsgIiAiICsgY29ubmVjdGlvbnMuc2l6ZSgpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICsgZ2V0UGhvbmUoKSArICIgIiArIG1Db25uZWN0aW9ucy5zaXplKCkpOwogCiAgICAgICAgICAgICAgICAgaWYgKG5ld1N0YXRlID09IENhbGwuU3RhdGUuQUxFUlRJTkcpIHsKLSAgICAgICAgICAgICAgICAgICAgc3RhdGUgPSBuZXdTdGF0ZTsgLy8gbmVlZCBpbiBBTEVSVElORyB0byBlbmFibGUgcmluZ2JhY2sKLSAgICAgICAgICAgICAgICAgICAgU2lwUGhvbmUudGhpcy5zdGFydFJpbmdiYWNrVG9uZSgpOwotICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoc3RhdGUgPT0gQ2FsbC5TdGF0ZS5BTEVSVElORykgewotICAgICAgICAgICAgICAgICAgICBTaXBQaG9uZS50aGlzLnN0b3BSaW5nYmFja1RvbmUoKTsKKyAgICAgICAgICAgICAgICAgICAgbVN0YXRlID0gbmV3U3RhdGU7IC8vIG5lZWQgaW4gQUxFUlRJTkcgdG8gZW5hYmxlIHJpbmdiYWNrCisgICAgICAgICAgICAgICAgICAgIHN0YXJ0UmluZ2JhY2tUb25lKCk7CisgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChtU3RhdGUgPT0gQ2FsbC5TdGF0ZS5BTEVSVElORykgeworICAgICAgICAgICAgICAgICAgICBzdG9wUmluZ2JhY2tUb25lKCk7CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIHN0YXRlID0gbmV3U3RhdGU7CisgICAgICAgICAgICAgICAgbVN0YXRlID0gbmV3U3RhdGU7CiAgICAgICAgICAgICAgICAgdXBkYXRlUGhvbmVTdGF0ZSgpOwogICAgICAgICAgICAgICAgIG5vdGlmeVByZWNpc2VDYWxsU3RhdGVDaGFuZ2VkKCk7CiAgICAgICAgICAgICB9CkBAIC01NzYsMTkgKzY4NSwyMSBAQAogCiAgICAgICAgIHZvaWQgb25Db25uZWN0aW9uU3RhdGVDaGFuZ2VkKFNpcENvbm5lY3Rpb24gY29ubikgewogICAgICAgICAgICAgLy8gdGhpcyBjYW4gYmUgY2FsbGVkIGJhY2sgd2hlbiBhIGNvbmYgY2FsbCBpcyBmb3JtZWQKLSAgICAgICAgICAgIGlmIChzdGF0ZSAhPSBTdGF0ZS5BQ1RJVkUpIHsKKyAgICAgICAgICAgIGlmIChTQ19EQkcpIGxvZygib25Db25uZWN0aW9uU3RhdGVDaGFuZ2VkOiBjb25uPSIgKyBjb25uKTsKKyAgICAgICAgICAgIGlmIChtU3RhdGUgIT0gU3RhdGUuQUNUSVZFKSB7CiAgICAgICAgICAgICAgICAgc2V0U3RhdGUoY29ubi5nZXRTdGF0ZSgpKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfQogCiAgICAgICAgIHZvaWQgb25Db25uZWN0aW9uRW5kZWQoU2lwQ29ubmVjdGlvbiBjb25uKSB7CiAgICAgICAgICAgICAvLyBzZXQgc3RhdGUgdG8gRElTQ09OTkVDVEVEIG9ubHkgd2hlbiBhbGwgY29ubnMgYXJlIGRpc2Nvbm5lY3RlZAotICAgICAgICAgICAgaWYgKHN0YXRlICE9IFN0YXRlLkRJU0NPTk5FQ1RFRCkgeworICAgICAgICAgICAgaWYgKFNDX0RCRykgbG9nKCJvbkNvbm5lY3Rpb25FbmRlZDogY29ubj0iICsgY29ubik7CisgICAgICAgICAgICBpZiAobVN0YXRlICE9IFN0YXRlLkRJU0NPTk5FQ1RFRCkgewogICAgICAgICAgICAgICAgIGJvb2xlYW4gYWxsQ29ubmVjdGlvbnNEaXNjb25uZWN0ZWQgPSB0cnVlOwotICAgICAgICAgICAgICAgIGlmIChERUJVRykgUmxvZy5kKExPR19UQUcsICItLS1jaGVjayBjb25uZWN0aW9uczogIgotICAgICAgICAgICAgICAgICAgICAgICAgKyBjb25uZWN0aW9ucy5zaXplKCkpOwotICAgICAgICAgICAgICAgIGZvciAoQ29ubmVjdGlvbiBjIDogY29ubmVjdGlvbnMpIHsKLSAgICAgICAgICAgICAgICAgICAgaWYgKERFQlVHKSBSbG9nLmQoTE9HX1RBRywgIiAgIHN0YXRlPSIgKyBjLmdldFN0YXRlKCkgKyAiOiAiCisgICAgICAgICAgICAgICAgaWYgKFNDX0RCRykgbG9nKCItLS1jaGVjayBjb25uZWN0aW9uczogIgorICAgICAgICAgICAgICAgICAgICAgICAgKyBtQ29ubmVjdGlvbnMuc2l6ZSgpKTsKKyAgICAgICAgICAgICAgICBmb3IgKENvbm5lY3Rpb24gYyA6IG1Db25uZWN0aW9ucykgeworICAgICAgICAgICAgICAgICAgICBpZiAoU0NfREJHKSBsb2coIiAgIHN0YXRlPSIgKyBjLmdldFN0YXRlKCkgKyAiOiAiCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyBjKTsKICAgICAgICAgICAgICAgICAgICAgaWYgKGMuZ2V0U3RhdGUoKSAhPSBTdGF0ZS5ESVNDT05ORUNURUQpIHsKICAgICAgICAgICAgICAg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AgcHJpdmF0ZSBTdHJpbmcgbU9yaWdpbmFsTnVtYmVyOyAvLyBtYXkgYmUgYSBQU1ROIG51bWJlcgogICAgICAgICBwcml2YXRlIGJvb2xlYW4gbUluY29taW5nID0gZmFsc2U7CisgICAgICAgIHByaXZhdGUgU3RyaW5nIG1PcmlnaW5hbE51bWJlcjsgLy8gbWF5IGJlIGEgUFNUTiBudW1iZXIKIAogICAgICAgICBwcml2YXRlIFNpcEF1ZGlvQ2FsbEFkYXB0ZXIgbUFkYXB0ZXIgPSBuZXcgU2lwQXVkaW9DYWxsQWRhcHRlcigpIHsKICAgICAgICAgICAgIEBPdmVycmlkZQpAQCAtNjIzLDExICs3NDEsMTIgQEAKICAgICAgICAgICAgICAgICBzeW5jaHJvbml6ZWQgKFNpcFBob25lLmNsYXNzKSB7CiAgICAgICAgICAgICAgICAgICAgIHNldFN0YXRlKENhbGwuU3RhdGUuRElTQ09OTkVDVEVEKTsKICAgICAgICAgICAgICAgICAgICAgU2lwQXVkaW9DYWxsIHNpcEF1ZGlvQ2FsbCA9IG1TaXBBdWRpb0NhbGw7CisgICAgICAgICAgICAgICAgICAgIC8vIEZJWE1FOiBUaGlzIGdvZXMgbnVsbCBhbmQgaXMgc3luY2hyb25pemVkLCBidXQgbWFueSB1c2VzIGFyZW4ndCBzeW5jJ2QKICAgICAgICAgICAgICAgICAgICAgbVNpcEF1ZGlvQ2FsbCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgIFN0cmluZyBzZXNzaW9uU3RhdGUgPSAoc2lwQXVkaW9DYWxsID09IG51bGwpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPyAiIgogICAgICAgICAgICAgICAgICAgICAgICAgICAgIDogKHNpcEF1ZGlvQ2FsbC5nZXRTdGF0ZSgpICsgIiwgIik7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChERUJVRykgUmxvZy5kKExPR19UQUcsICItLS0gY29ubmVjdGlvbiBlbmRlZDogIgorICAgICAgICAgICAgICAgICAgICBpZiAoU0NOX0RCRykgbG9nKCJbU2lwQXVkaW9DYWxsQWRhcHRlcl0gb25DYWxsRW5kZWQ6ICIKICAgICAgICAgICAgICAgICAgICAgICAgICAgICArIG1QZWVyLmdldFVyaVN0cmluZygpICsgIjogIiArIHNlc3Npb25TdGF0ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgImNhdXNlOiAiICsgZ2V0RGlzY29ubmVjdENhdXNlKCkgKyAiLCBvbiBwaG9uZSAiCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyBnZXRQaG9uZSgpKTsKQEAgLTY0MiwxMiArNzYxLDE0IEBACiAgICAgICAgICAgICBAT3ZlcnJpZGUKICAgICAgICAgICAgIHB1YmxpYyB2b2lkIG9uQ2FsbEVzdGFibGlzaGVkKFNpcEF1ZGlvQ2FsbCBjYWxsKSB7CiAgICAgICAgICAgICAgICAgb25DaGFuZ2VkKGNhbGwpOworICAgICAgICAgICAgICAgIC8vIFJhY2Ugb25DaGFuZ2VkIHN5bmNocm9uaXplZCB0aGlzIGlzbid0CiAgICAgICAgICAgICAgICAgaWYgKG1TdGF0ZSA9PSBDYWxsLlN0YXRlLkFDVElWRSkgY2FsbC5zdGFydEF1ZGlvKCk7CiAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgIEBPdmVycmlkZQogICAgICAgICAgICAgcHVibGljIHZvaWQgb25DYWxsSGVsZChTaXBBdWRpb0NhbGwgY2FsbCkgewogICAgICAgICAgICAgICAgIG9uQ2hhbmdlZChjYWxsKTsKKyAgICAgICAgICAgICAgICAvLyBSYWNlIG9uQ2hhbmdlZCBzeW5jaHJvbml6ZWQgdGhpcyBpc24ndAogICAgICAgICAgICAgICAgIGlmIChtU3RhdGUgPT0gQ2FsbC5TdGF0ZS5IT0xESU5HKSBjYWxsLnN0YXJ0QXVkaW8oKTsKICAgICAgICAgICAgIH0KIApAQCAtNjU5LDggKzc4MCw4IEBACiAgICAgICAgICAgICAgICAgICAgIGlmIChuZXdTdGF0ZSA9PSBDYWxsLlN0YXRlLklOQ09NSU5HKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBzZXRTdGF0ZShtT3duZXIuZ2V0U3RhdGUoKSk7IC8vIElOQ09NSU5HIG9yIFdBSVRJTkcKICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtT3duZXIgPT0gcmluZ2luZ0NhbGwpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocmluZ2luZ0NhbGwuZ2V0U3RhdGUoKSA9PSBDYWxsLlN0YXRlLldBSVRJTkcpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtT3duZXIgPT0gbVJpbmdpbmdDYWxsKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1SaW5naW5nQ2FsbC5nZXRTdGF0ZSgpID09IENhbGwuU3RhdGUuV0FJVElORykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoSG9sZGluZ0FuZEFjdGl2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChDYWxsU3RhdGVFeGNlcHRpb24gZSkgewpAQCAtNjY5LDEyICs3OTAsMTIgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JlZ3JvdW5kQ2FsbC5zd2l0Y2hXaXRoKHJpbmdpbmdDYWxsKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBtRm9yZWdyb3VuZENhbGwuc3dpdGNoV2l0aChtUmluZ2luZ0NhbGwpOwogICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgc2V0U3RhdGUobmV3U3RhdGUpOwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIG1Pd25lci5vbkNvbm5lY3Rpb25TdGF0ZUNoYW5nZWQoU2lwQ29ubmVjdGlvbi50aGlzKTsKLSAgICAgICAgICAgICAgICAgICAgaWYgKERFQlVHKSBSbG9nLnYoTE9HX1RBRywgIisqKiorIGNvbm5lY3Rpb24gc3RhdGUgY2hhbmdlZDogIgorICAgICAgICAgICAgICAgICAgICBpZiAoU0NOX0RCRykgbG9nKCJvbkNoYW5nZWQ6ICIKICAgICAgICAgICAgICAgICAgICAgICAgICAgICArIG1QZWVyLmdldFVyaVN0cmluZygpICsgIjogIiArIG1TdGF0ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgIiBvbiBwaG9uZSAiICsgZ2V0UGhvbmUoKSk7CiAgICAgICAgICAgICAgICAgfQpAQCAtNjgyLDcgKzgwMyw3IEBACiAKICAgICAgICAgICAgIEBPdmVycmlkZQogICAgICAgICAgICAgcHJvdGVjdGVkIHZvaWQgb25FcnJvcihEaXNjb25uZWN0Q2F1c2UgY2F1c2UpIHsKLSAgICAgICAgICAgICAgICBpZiAoREVCVUcpIFJsb2cuZChMT0dfVEFHLCAiU0lQIGVycm9yOiAiICsgY2F1c2UpOworICAgICAgICAgICAgICAgIGlmIChTQ05fREJHKSBsb2coIm9uRXJyb3I6ICIgKyBjYXVzZSk7CiAgICAgICAgICAgICAgICAgb25DYWxsRW5kZWQoY2F1c2UpOwogICAgICAgICAgICAgfQogICAgICAgICB9OwpAQCAtNzYzLDYgKzg4NCw3IEBACiAKICAgICAgICAgdm9pZCBzZXRNdXRlKGJvb2xlYW4gbXV0ZWQpIHsKICAgICAgICAgICAgIGlmICgobVNpcEF1ZGlvQ2FsbCAhPSBudWxsKSAmJiAobXV0ZWQgIT0gbVNpcEF1ZGlvQ2FsbC5pc011dGVkKCkpKSB7CisgICAgICAgICAgICAgICAgaWYgKFNDTl9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3JvdW5kQ2FsbCgpCi0gICAgICAgICAgICAgICAgICAgICAgICA6IChTaXBDYWxsKSBTaXBQaG9uZS50aGlzLmdldEZvcmVncm91bmRDYWxsKCk7CisgICAgICAgICAgICAgICAgICAgICAgICA/IChTaXBDYWxsKSBnZXRCYWNrZ3JvdW5kQ2FsbCgpCisgICAgICAgICAgICAgICAgICAgICAgICA6IChTaXBDYWxsKSBnZXRGb3JlZ3JvdW5kQ2FsbCgpOwogICAgICAgICAgICAgICAgIGlmIChjYWxsLmdldFN0YXRlKCkgIT0gQ2FsbC5TdGF0ZS5JRExFKSB7CiAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBDYWxsU3RhdGVFeGNlcHRpb24oCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgImNhbm5vdCBwdXQgY29ubiBiYWNrIHRvIGEgY2FsbCBpbiBub24taWRsZSBzdGF0ZTogIgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgY2FsbC5nZXRTdGF0ZSgpKTsKICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgaWYgKERFQlVHKSBSbG9nLmQoTE9HX1RBRywgInNlcGFyYXRlIGNvbm46ICIKKyAgICAgICAgICAgICAgICBpZiAoU0NOX0RCRykgbG9nKCJzZXBhcmF0ZTogY29ubj0iCiAgICAgICAgICAgICAgICAgICAgICAgICArIG1QZWVyLmdldFVyaVN0cmluZygpICsgIiBmcm9tICIgKyBtT3duZXIgKyAiIGJhY2sgdG8gIgogICAgICAgICAgICAgICAgICAgICAgICAgKyBjYWxsKTsKIApAQCAtODU3LDM3ICs5NzksMjYgQEAKICAgICAgICAgICAgICAgICBvcmlnaW5hbFBob25lLnN3aXRjaEhvbGRpbmdBbmRBY3RpdmUoKTsKIAogICAgICAgICAgICAgICAgIC8vIHN0YXJ0IGF1ZGlvIGFuZCBub3RpZnkgdGhlIHBob25lIGFwcCBvZiB0aGUgc3RhdGUgY2hhbmdlCi0gICAgICAgICAgICAgICAgY2Fs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lKTsKIAogICAgICAgICBAT3ZlcnJpZGUKICAgICAgICAgcHVibGljIHZvaWQgb25DYWxsRW5kZWQoU2lwQXVkaW9DYWxsIGNhbGwpIHsKKyAgICAgICAgICAgIGlmIChTQUNBX0RCRykgbG9nKCJvbkNhbGxFbmRlZDogY2FsbD0iICsgY2FsbCk7CiAgICAgICAgICAgICBvbkNhbGxFbmRlZChjYWxsLmlzSW5DYWxsKCkKICAgICAgICAgICAgICAgICAgICAgPyBDb25uZWN0aW9uLkRpc2Nvbm5lY3RDYXVzZS5OT1JNQUwKICAgICAgICAgICAgICAgICAgICAgOiBDb25uZWN0aW9uLkRpc2Nvbm5lY3RDYXVzZS5JTkNPTUlOR19NSVNTRUQpOwpAQCAtODk1LDEyICsxMDA2LDE3IEBACiAKICAgICAgICAgQE92ZXJyaWRlCiAgICAgICAgIHB1YmxpYyB2b2lkIG9uQ2FsbEJ1c3koU2lwQXVkaW9DYWxsIGNhbGwpIHsKKyAgICAgICAgICAgIGlmIChTQUNBX0RCRykgbG9nKCJvbkNhbGxCdXN5OiBjYWxsPSIgKyBjYWxsKTsKICAgICAgICAgICAgIG9uQ2FsbEVuZGVkKENvbm5lY3Rpb24uRGlzY29ubmVjdENhdXNlLkJVU1kpOwogICAgICAgICB9CiAKICAgICAgICAgQE92ZXJyaWRlCiAgICAgICAgIHB1YmxpYyB2b2lkIG9uRXJyb3IoU2lwQXVkaW9DYWxsIGNhbGwsIGludCBlcnJvckNvZGUsCiAgICAgICAgICAgICAgICAgU3RyaW5nIGVycm9yTWVzc2FnZSkgeworICAgICAgICAgICAgaWYgKFNBQ0FfREJHKSB7CisgICAgICAgICAgICAgICAgbG9nKCJvbkVycm9yOiBjYWxsPSIgKyBjYWxsICsgIiBjb2RlPSIrIFNpcEVycm9yQ29kZS50b1N0cmluZyhlcnJvckNvZGUpCisgICAgICAgICAgICAgICAgICAgICsgIjogIiArIGVycm9yTWVzc2FnZSk7CisgICAgICAgICAgICB9CiAgICAgICAgICAgICBzd2l0Y2ggKGVycm9yQ29kZSkgewogICAgICAgICAgICAgICAgIGNhc2UgU2lwRXJyb3JDb2RlLlNFUlZFUl9VTlJFQUNIQUJMRToKICAgICAgICAgICAgICAgICAgICAgb25FcnJvcihDb25uZWN0aW9uLkRpc2Nvbm5lY3RDYXVzZS5TRVJWRVJfVU5SRUFDSEFCTEUpOwpAQCAtOTMwLDEwICsxMDQ2LDEyIEBACiAgICAgICAgICAgICAgICAgY2FzZSBTaXBFcnJvckNvZGUuU09DS0VUX0VSUk9SOgogICAgICAgICAgICAgICAgIGNhc2UgU2lwRXJyb3JDb2RlLkNMSUVOVF9FUlJPUjoKICAgICAgICAgICAgICAgICBkZWZhdWx0OgotICAgICAgICAgICAgICAgICAgICBSbG9nLncoTE9HX1RBRywgImVycm9yOiAiICsgU2lwRXJyb3JDb2RlLnRvU3RyaW5nKGVycm9yQ29kZSkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICArICI6ICIgKyBlcnJvck1lc3NhZ2UpOwogICAgICAgICAgICAgICAgICAgICBvbkVycm9yKENvbm5lY3Rpb24uRGlzY29ubmVjdENhdXNlLkVSUk9SX1VOU1BFQ0lGSUVEKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfQorCisgICAgICAgIHByaXZhdGUgdm9pZCBsb2coU3RyaW5nIHMpIHsKKyAgICAgICAgICAgIFJsb2cuZChTQUNBX1RBRywgcyk7CisgICAgICAgIH0KICAgICB9CiB9CmRpZmYgLS1naXQgYS9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvc2lwL1NpcFBob25lQmFzZS5qYXZhIGIvc3JjL2phdmEvY29tL2FuZHJvaWQvaW50ZXJuYWwvdGVsZXBob255L3NpcC9TaXBQaG9uZUJhc2UuamF2YQppbmRleCAwNDFhYzc5Li40OWNhN2M2IDEwMDc1NQotLS0gYS9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvc2lwL1NpcF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7CiAgICAgICAgIHJldHVybiBudWxsOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdHJpbmcgZ2V0RXNuKCkgewogICAgICAgICBSbG9nLmUoTE9HX1RBRywgIltTaXBQaG9uZV0gZ2V0RXNuKCkgaXMgYSBDRE1BIG1ldGhvZCIpOwogICAgICAgICByZXR1cm4gIjAiOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdHJpbmcgZ2V0TWVpZCgpIHsKICAgICAgICAgUmxvZy5lKExPR19UQUcsICJbU2lwUGhvbmVdIGdldE1laWQoKSBpcyBhIENETUEgbWV0aG9kIik7CiAgICAgICAgIHJldHVybiAiMCI7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFN0cmluZyBnZXRTdWJzY3JpYmVySWQoKSB7CiAgICAgICAgIHJldHVybiBudWxsOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBTdHJpbmcgZ2V0SWNjU2VyaWFsTnVtYmVyKCkgewogICAgICAgICByZXR1cm4gbnVsbDsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgU3RyaW5nIGdldExpbmUxTnVtYmVyKCkgewogICAgICAgICByZXR1cm4gbnVsbDsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgU3RyaW5nIGdldExpbmUxQWxwaGFUYWcoKSB7CiAgICAgICAgIHJldHVybiBudWxsOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHNldExpbmUxTnVtYmVyKFN0cmluZyBhbHBoYVRhZywgU3RyaW5nIG51bWJlciwgTWVzc2FnZSBvbkNvbXBsZXRlKSB7CiAgICAgICAgIC8vIEZJWE1FOiB3aGF0IHRvIHJlcGx5IGZvciBTSVA/CiAgICAgICAgIEFzeW5jUmVzdWx0LmZvck1lc3NhZ2Uob25Db21wbGV0ZSwgbnVsbC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iAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgc2V0T3V0Z29pbmdDYWxsZXJJZERpc3BsYXkoaW50IGNvbW1hbmRJbnRlcmZhY2VDTElSTW9kZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNZXNzYWdlIG9uQ29tcGxldGUpIHsKICAgICAgICAgLy8gRklYTUU6IHdoYXQncyB0aGlzIGZvciBTSVA/CkBAIC0zMzgsNjAgKzM3Nyw3NSBAQAogICAgICAgICBvbkNvbXBsZXRlLnNlbmRUb1RhcmdldCgpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIGdldENhbGxXYWl0aW5nKE1lc3NhZ2Ugb25Db21wbGV0ZSkgewogICAgICAgICBBc3luY1Jlc3VsdC5mb3JNZXNzYWdlKG9uQ29tcGxldGUsIG51bGwsIG51bGwpOwogICAgICAgICBvbkNvbXBsZXRlLnNlbmRUb1RhcmdldCgpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHNldENhbGxXYWl0aW5nKGJvb2xlYW4gZW5hYmxlLCBNZXNzYWdlIG9uQ29tcGxldGUpIHsKICAgICAgICAgUmxvZy5lKExPR19UQUcsICJjYWxsIHdhaXRpbmcgbm90IHN1cHBvcnRlZCIpOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBib29sZWFuIGdldEljY1JlY29yZHNMb2FkZWQoKSB7CiAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgSWNjQ2FyZCBnZXRJY2NDYXJkKCkgewogICAgICAgICByZXR1cm4gbnVsbDsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBnZXRBdmFpbGFibGVOZXR3b3JrcyhNZXNzYWdlIHJlc3BvbnNlKSB7CiAgICAgfQogCisg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VzKCkgewogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBib29sZWFuIGdldERhdGFSb2FtaW5nRW5hYmxlZCgpIHsKICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkIHNldERhdGFSb2FtaW5nRW5hYmxlZChib29sZWFuIGVuYWJsZSkgewogICAgIH0KIApAQCAtNDAzLDYgKzQ1Nyw3IEBACiAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgYm9vbGVhbiBpc0RhdGFDb25uZWN0aXZpdHlQb3NzaWJsZSgpIHsKICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgIH0KQEAgLTQxNCw2MCArNDY5LDY5IEBACiAgICAgcHVibGljIHZvaWQgc2F2ZUNsaXJTZXR0aW5nKGludCBjb21tYW5kSW50ZXJmYWNlQ0xJUk1vZGUpIHsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgUGhvbmVTdWJJbmZvIGdldFBob25lU3ViSW5mbygpewogICAgICAgICByZXR1cm4gbnVsbDsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgSWNjU21zSW50ZXJmYWNlTWFuYWdlciBnZXRJY2NTbXNJbnRlcmZhY2VNYW5hZ2VyKCl7CiAgICAgICAgIHJldHVybiBudWxsOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBJY2NQaG9uZUJvb2tJbnRlcmZhY2VNYW5hZ2VyIGdldEljY1Bob25lQm9va0ludGVyZmFjZU1hbmFnZXIoKXsKICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIEljY0ZpbGVIYW5kbGVyIGdldEljY0ZpbGVIYW5kbGVyKCl7CiAgICAgICAgIHJldHVybiBudWxsOwogICAgIH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gaW5TdHJlYW07CisgICAgSW5wdXRTdHJlYW0gbUluU3RyZWFtOwogCiAgICAgTGluZVJlYWRlciAoSW5wdXRTdHJlYW0gcykKICAgICB7Ci0gICAgICAgIGluU3RyZWFtID0gczsKKyAgICAgICAgbUluU3RyZWFtID0gczsKICAgICB9CiAKICAgICBTdHJpbmcKQEAgLTg0LDcgKzgzLDcgQEAKICAgICAgICAgICAgIGZvciAoOzspIHsKICAgICAgICAgICAgICAgICBpbnQgcmVzdWx0OwogCi0gICAgICAgICAgICAgICAgcmVzdWx0ID0gaW5TdHJlYW0ucmVhZCgpOworICAgICAgICAgICAgICAgIHJlc3VsdCA9IG1JblN0cmVhbS5yZWFkKCk7CiAKICAgICAgICAgICAgICAgICBpZiAocmVzdWx0IDwgMCkgewogICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKQEAgLTEwMSw3ICsxMDAsNyBAQAogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgfQogCi0gICAgICAgICAgICAgICAgYnVmZmVyW2krK10gPSAoYnl0ZSlyZXN1bHQ7CisgICAgICAgICAgICAgICAgbUJ1ZmZlcltpKytdID0gKGJ5dGUpcmVzdWx0OwogICAgICAgICAgICAgfQogICAgICAgICB9IGNhdGNoIChJT0V4Y2VwdGlvbiBleCkgewogICAgICAgICAgICAgcmV0dXJuIG51bGw7CkBAIC0xMTAsNyArMTA5LDcgQEAKICAgICAgICAgfQogCiAgICAgICAgIHRyeSB7Ci0gICAgICAgICAgICByZXR1cm4gbmV3IFN0cmluZyhidWZmZXIsIDAsIGksICJVUy1BU0NJSSIpOworICAgICAgICAgICAgcmV0dXJuIG5ldyBTdHJpbmcobUJ1ZmZlciwgMCwgaSwgIlVTLUFTQ0lJIik7CiAgICAgICAgIH0gY2F0Y2ggKFVuc3VwcG9ydGVkRW5jb2RpbmdFeGNlcHRpb24gZXgpIHsKICAgICAgICAgICAgIFN5c3RlbS5lcnIucHJpbnRsbigiQVRDaGFubmVsOi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0ZWRDYWxsU3RhdGUgPSBuZXcgU2ltdWxhdGVkR3NtQ2FsbFN0YXRlKGxvb3Blcik7CisgICAgICAgIG1TaW11bGF0ZWRDYWxsU3RhdGUgPSBuZXcgU2ltdWxhdGVkR3NtQ2FsbFN0YXRlKGxvb3Blcik7CiAgICAgfQogCiAgICAgLy8qKioqKiBSdW5uYWJsZSBJbXBsZW1lbnRhdGlvbgogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgcnVuKCkKICAgICB7CiAgICAgICAgIGZvciAoOzspIHsKLSAgICAgICAgICAgIGlmIChzcyAhPSBudWxsKSB7CisgICAgICAgICAgICBpZiAobVNTICE9IG51bGwpIHsKICAgICAgICAgICAgICAgICBTb2NrZXQgczsKIAogICAgICAgICAgICAgICAgIHRyeSB7Ci0gICAgICAgICAgICAgICAgICAgIHMgPSBzcy5hY2NlcHQoKTsKKyAgICAgICAgICAgICAgICAgICAgcyA9IG1TUy5hY2NlcHQoKTsKICAgICAgICAgICAgICAgICB9IGNhdGNoIChqYXZhLmlvLklPRXhjZXB0aW9uIGV4KSB7CiAgICAgICAgICAgICAgICAgICAgIFJsb2cudyhMT0dfVEFHLAogICAgICAgICAgICAgICAgICAgICAgICAgIklPRXhjZXB0aW9uIG9uIHNvY2tldC5hY2NlcHQoKTsgc3RvcHBpbmciLCBleCk7CkBAIC0yMTAsOCArMjEwLDggQEAKICAgICAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgICAgICB0cnkgewotICAgICAgICAgICAgICAgICAgICBpbiA9IHMuZ2V0SW5wdXRTdHJlYW0oKTsKLSAgICAgICAgICAgICAgICAgICAgb3V0ID0gcy5nZXRPdXRwdXRTdHJlYW0oKTsKKyAgICAgICAgICAgICAgICAgICAgbUluID0gcy5nZXRJbnB1dFN0cmVhbSgpOworICAgICAgICAgICAgICAgICAgICBtT3V0ID0gcy5nZXRPdXRwdXRTdHJlYW0oKTsKICAgICAgICAgICAgICAgICB9IGNhdGNoIChqYXZhLmlvLklPRXhjZXB0aW9uIGV4KSB7CiAgICAgICAgICAgICAgICAgICAgIFJsb2cudyhMT0dfVEFHLAogICAgICAgICAgICAgICAgICAgICAgICAgIklPRXhjZXB0aW9uIG9uIGFjY2VwdGVkIHNvY2tldCgpOyByZS1saXN0ZW5pbmciLCBleCk7CkBAIC0yMjIsMTQgKzIyMiwxNCBAQAogICAgICAgICAgICAgfQogCiAKLSAgICAgICAgICAgIGxpbmVSZWFkZXIgPSBuZXcgTGluZVJlYWRlciAoaW4pOworICAgICAgICAgICAgbUxpbmVSZWFkZXIgPSBuZXcgTGluZVJlYWRlciAobUluKTsKIAogICAgICAgICAgICAgcHJpbnRsbiAoIldlbGNvbWUiKTsKIAogICAgICAgICAgICAgZm9yICg7OykgewogICAgICAgICAgICAgICAgIFN0cmluZyBsaW5lOwogCi0gICAgICAgICAgICAgICAgbGluZSA9IGxpbmVSZWFkZXIuZ2V0TmV4dExpbmUoKTsKKyAgICAgICAgICAgICAgICBsaW5lID0gbUxpbmVSZWFkZXIuZ2V0TmV4dExpbmUoKTsKIAogICAgICAgICAgICAgICAgIC8vU3lzdGVtLm91dC5wcmludGxuKCJNSTw8ICIgKyBsaW5lKTsKIApAQCAtMjM3LDEwICsyMzcsMTAgQEAKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgfQogCi0gICAgICAgICAgICAgICAgc3luY2hyb25pemVkKHBhdXNlZFJlc3BvbnNlTW9uaXRvcikgewotICAgICAgICAgICAgICAgICAgICB3aGlsZSAocGF1c2VkUmVzcG9uc2VDb3VudCA+IDApIHsKKyAgICAgICAgICAgICAgICBzeW5jaHJvbml6ZWQobVBhdXNlZFJlc3BvbnNlTW9uaXRvcikgeworICAgICAgICAgICAgICAgICAgICB3aGlsZSAobVBhdXNlZFJlc3BvbnNlQ291bnQgPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdXNlZFJlc3BvbnNlTW9uaXRvci53YWl0KCk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbVBhdXNlZFJlc3BvbnNlTW9uaXRvci53YWl0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChJbnRlcnJ1cHRlZEV4Y2VwdGlvbiBleCkgewogICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICB9CkBAIC0yNDgsMTEgKzI0OCwxMSBAQAogCiAgICAgICAgICAgICAgICAgc3luY2hyb25pemVkICh0aGlzKSB7CiAgICAgICAgICAgICAgICAgICAgIHRyeSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBmaW5hbFJlc3BvbnNlID0gIk9LIjsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1GaW5hbFJlc3BvbnNlID0gIk9LIjsKICAgICAgICAgICAgICAgICAgICAgICAgIHByb2Nlc3NMaW5lKGxpbmUpOwotICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRsbihmaW5hbFJlc3BvbnNlKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaW50bG4obUZpbmFsUmVzcG9uc2UpOwogICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChJbnRlcnByZXRlckV4IGV4KSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBwcmludGxuKGV4LnJlc3VsdCk7CisgICAgICAgICAgICAgICAgICAgICAgICBwcmludGxuKGV4Lm1SZXN1bHQpOwogICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChSdW50aW1lRXhjZXB0aW9uIGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBleC5wcmludFN0YWNrVHJhY2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgIHByaW50bG4oIkVSUk9SIik7CkBAIC0yNjIsNyArMjYyLDcgQEAKIAogICAgICAgICAgICAgUmxvZy5pKExPR19UQUcsICJEaXNjb25uZWN0ZWQiKTsKIAotICAgICAgICAgICAgaWYgKHNzID09IG51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AgICAgICAgICAgbVBhdXNlZFJlc3BvbnNlQ291bnQrKzsKICAgICAgICAgfQogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyB2b2lkCiAgICAgcmVzdW1lUmVzcG9uc2VzKCkKICAgICB7Ci0gICAgICAgIHN5bmNocm9uaXplZChwYXVzZWRSZXNwb25zZU1vbml0b3IpIHsKLSAgICAgICAgICAgIHBhdXNlZFJlc3BvbnNlQ291bnQtLTsKKyAgICAgICAgc3luY2hyb25pemVkKG1QYXVzZWRSZXNwb25zZU1vbml0b3IpIHsKKyAgICAgICAgICAgIG1QYXVzZWRSZXNwb25zZUNvdW50LS07CiAKLSAgICAgICAgICAgIGlmIChwYXVzZWRSZXNwb25zZUNvdW50ID09IDApIHsKLSAgICAgICAgICAgICAgICBwYXVzZWRSZXNwb25zZU1vbml0b3Iubm90aWZ5QWxsKCk7CisgICAgICAgICAgICBpZiAobVBhdXNlZFJlc3BvbnNlQ291bnQgPT0gMCkgeworICAgICAgICAgICAgICAgIG1QYXVzZWRSZXNwb25zZU1vbml0b3Iubm90aWZ5QWxsKCk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICB9CkBAIC00MzAsNyArNDQ0LDcgQEAKICAgICB7CiAgICAgICAgIGJvb2xlYW4gc3VjY2VzczsKIAotICAgICAgICBzdWNjZXNzID0gc2ltdWxhdGVkQ2FsbFN0YXRlLm9uQW5zd2VyKCk7CisgICAgICAgIHN1Y2Nlc3MgPSBtU2ltdWxhdGVkQ2FsbFN0YXRlLm9uQW5zd2VyKCk7CiAKICAgICAgICAgaWYgKCFzdWNjZXNzKSB7CiAgICAgICAgICAgICB0aHJvdyBuZXcgSW50ZXJwcmV0ZXJFeCgiRVJST1IiKTsKQEAgLTQ0MiwxMyArNDU2LDEzIEBACiAgICAgewogICAgICAgICBib29sZWFuIHN1Y2Nlc3MgPSBmYWxzZTsKIAotICAgICAgICBzdWNjZXNzID0gc2ltdWxhdGVkQ2FsbFN0YXRlL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tYW5kKSB0aHJvd3MgSW50ZXJwcmV0ZXJFeAorICAgIG9uU01TU2VuZChTdHJpbmcgY29tbWFuZCkKICAgICB7CiAgICAgICAgIFN0cmluZyBwZHU7CiAKICAgICAgICAgcHJpbnQgKCI+ICIpOwotICAgICAgICBwZHUgPSBsaW5lUmVhZGVyLmdldE5leHRMaW5lQ3RybFooKTsKKyAgICAgICAgcGR1ID0gbUxpbmVSZWFkZXIuZ2V0TmV4dExpbmVDdHJsWigpOwogCiAgICAgICAgIHByaW50bG4oIitDTUdTOiAxIik7CiAgICAgfQpAQCAtNjU1LDggKzYwOSw4IEBACiAKICAgICAgICAgICAgICAgICAvL1N5c3RlbS5vdXQucHJpbnRsbigiTUk+PiAiICsgcyk7CiAKLSAgICAgICAgICAgICAgICBvdXQud3JpdGUoYnl0ZXMpOwotICAgICAgICAgICAgICAgIG91dC53cml0ZSgnXHInKTsKKyAgICAgICAgICAgICAgICBtT3V0LndyaXRlKGJ5dGVzKTsKKyAgICAgICAgICAgICAgICBtT3V0LndyaXRlKCdccicpOwogICAgICAgICAgICAgfSBjYXRjaCAoSU9FeGNlcHRpb24gZXgpIHsKICAgICAgICAgICAgICAgICBleC5wcmludFN0YWNrVHJhY2UoKTsKICAgICAgICAgICAgIH0KQEAgLTY3Miw3ICs2MjYsNyBAQAogCiAgICAgICAgICAgICAgICAgLy9TeXN0ZW0ub3V0LnByaW50bG4oIk1JPj4gIiArIHMgKyAiIChubyA8Y3I+KSIpOwogCi0gICAgICAgICAgICAgICAgb3V0LndyaXRlKGJ5dGVzKTsKKyAgICAgICAgICAgICAgICBtT3V0LndyaXRlKGJ5dGVzKTsKICAgICAgICAgICAgIH0gY2F0Y2ggKElPRXhjZXB0aW9uIGV4KSB7CiAgICAgICAgICAgICAgICAgZXgucHJpbnRTdGFja1RyYWNlKCk7CiAgICAgICAgICAgICB9CkBAIC02ODAsNiArNjM0LDcgQEAKICAgICB9CiAKIAorICAgIEBPdmVycmlkZQogICAgIHB1YmxpYy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BhdXNlZFJlc3BvbnNlcy5nZXQoaSkuc2VuZFRvVGFyZ2V0KCk7CisgICAgICAgIGlmIChtUGF1c2VkUmVzcG9uc2VDb3VudCA9PSAwKSB7CisgICAgICAgICAgICBmb3IgKGludCBpID0gMCwgcyA9IG1QYXVzZWRSZXNwb25zZXMuc2l6ZSgpOyBpIDwgcyA7IGkrKykgeworICAgICAgICAgICAgICAgIG1QYXVzZWRSZXNwb25zZXMuZ2V0KGkpLnNlbmRUb1RhcmdldCgpOwogICAgICAgICAgICAgfQotICAgICAgICAgICAgcGF1c2VkUmVzcG9uc2VzLmNsZWFyKCk7CisgICAgICAgICAgICBtUGF1c2VkUmVzcG9uc2VzLmNsZWFyKCk7CiAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICBSbG9nLmUoIkdTTSIsICJTaW11bGF0ZWRDb21tYW5kcy5yZXN1bWVSZXNwb25zZXMgPCAwIik7CiAgICAgICAgIH0KQEAgLTEzMzMsOCArMTQzNiw4IEBACiAgICAgICAgICAgICBBc3luY1Jlc3VsdC5mb3JNZXNzYWdlKHJlc3VsdCkuZXhjZXB0aW9uCiAgICAgICAgICAgICAgICAgPSBuZXcgUnVudGltZUV4Y2VwdGlvbigiVW5pbXBsZW1lbnRlZCIpOwogCi0gICAgICAgICAgICBpZiAocGF1c2VkUmVzcG9uc2VDb3VudCA+IDApIHsKLSAgICAgICAgICAgICAgICBwYXVzZWRSZXNwb25zZXMuYWRkKHJlc3VsdCk7CisgICAgICAgICAgICBpZiAobVBhdXNlZFJlc3BvbnNlQ291bnQgPiAwKSB7CisgICAgICAgICAgICAgICAgbVBhdXNlZFJlc3BvbnNlcy5hZGQocmVzdWx0KTsKICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgcmVzdWx0LnNlbmRUb1RhcmdldCgpOwogICAgICAgICAgICAgfQpAQCAtMTM0NCw4ICsxNDQ3LDggQEAKICAgICBwcml2YXRlIHZvaWQgcmVzdWx0U3VjY2VzcyhNZXNzYWdlIHJlc3VsdCwgT2JqZWN0IHJldCkgewogICAgICAgICBpZiAocmVzdWx0ICE9IG51bGwpIHsKICAgICAgICAgICAgIEFzeW5jUmVzdWx0LmZvck1lc3NhZ2UocmVzdWx0KS5yZXN1bHQgPSByZXQ7Ci0gICAgICAgICAgICBpZiAocGF1c2VkUmVzcG9uc2VDb3VudCA+IDApIHsKLSAgICAgICAgICAgICAgICBwYXVzZWRSZXNwb25zZXMuYWRkKHJlc3VsdCk7CisgICAgICAgICAgICBpZiAobVBhdXNlZFJlc3BvbnNlQ291bnQgPiAwKSB7CisgICAgICAgICAgICAgICAgbVBhdXNlZFJlc3BvbnNlcy5hZGQocmVzdWx0KTsKICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgcmVzdWx0LnNlbmRUb1RhcmdldCgpOwogICAgICAgICAgICAgfQpAQCAtMTM1NSw4ICsxNDU4LDggQEAKICAgICBwcml2YXRlIHZvaWQgcmVzdWx0RmFpbChNZXNzYWdlIHJlc3VsdCwgVGhyb3dhYmxlIHRyKSB7CiAgICAgICAgIGlmIChyZXN1bHQgIT0gbnVsbCkgewogICAgICAgICAgICAgQXN5bmNSZXN1bHQuZm9yTWVzc2FnZShyZXN1bHQpLmV4Y2VwdGlvbiA9IHRyOwotICAgICAgICAgICAgaWYgKHBhdXNlZFJlc3BvbnNlQ291bnQgPiAwKSB7Ci0gICAgICAgICAgICAgICAgcGF1c2VkUmVzcG9uc2VzLmFkZChyZXN1bHQpOworICAgICAgICAgICAgaWYgKG1QYXVzZWRSZXNwb25zZUNvdW50ID4gMCkgeworICAgICAgICAgICAgICAgIG1QYXVzZWRSZXNwb25zZXMuYWRkKHJlc3VsdCk7CiAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgIHJlc3VsdC5zZW5kVG9UYXJnZXQoKTsKICAgICAgICAgICAgIH0KQEAgLTEzNjQsNDQgKzE0NjcsNTIgQEAKICAgICB9CiAKICAgICAvLyA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bnkvdGVzdC9TaW11bGF0ZWRHc21DYWxsU3RhdGUuamF2YQpAQCAtMzYsMjggKzM2LDI4IEBACiAgICAgICAgIElOQ09NSU5HKDQpLCAgIC8vIE1UIGNhbGwgb25seQogICAgICAgICBXQUlUSU5HKDUpOyAgICAvLyBNVCBjYWxsIG9ubHkKIAotICAgICAgICBTdGF0ZSAoaW50IHZhbHVlKSB7dGhpcy52YWx1ZSA9IHZhbHVlO30KKyAgICAgICAgU3RhdGUoaW50IHZhbHVlKSB7bVZhbHVlID0gdmFsdWU7fQogCi0gICAgICAgIHByaXZhdGUgZmluYWwgaW50IHZhbHVlOwotICAgICAgICBwdWJsaWMgaW50IHZhbHVlKCkge3JldHVybiB2YWx1ZTt9OwotICAgIH07CisgICAgICAgIHByaXZhdGUgZmluYWwgaW50IG1WYWx1ZTsKKyAgICAgICAgcHVibGljIGludCB2YWx1ZSgpIHtyZXR1cm4gbVZhbHVlO30KKyAgICB9CiAKLSAgICBib29sZWFuIGlzTVQ7Ci0gICAgU3RhdGUgc3RhdGU7Ci0gICAgYm9vbGVhbiBpc01wdHk7Ci0gICAgU3RyaW5nIG51bWJlcjsKLSAgICBpbnQgVE9BOworICAgIGJvb2xlYW4gbUlzTVQ7CisgICAgU3RhdGUgbVN0YXRlOworICAgIGJvb2xlYW4gbUlzTXB0eTsKKyAgICBTdHJpbmcgbU51bWJlcjsKKyAgICBpbnQgbVRPQTsKIAogICAgIENhbGxJbmZvIChib29sZWFuIGlzTVQsIFN0YXRlIHN0YXRlLCBib29sZWFuIGlzTXB0eSwgU3RyaW5nIG51bWJlcikgewotICAgICAgICB0aGlzLmlzTVQgPSBpc01UOwotICAgICAgICB0aGlzLnN0YXRlID0gc3RhdGU7Ci0gICAgICAgIHRoaXMuaXNNcHR5ID0gaXNNcHR5OwotICAgICAgICB0aGlzLm51bWJlciA9IG51bWJlcjsKKyAgICAgICAgbUlzTVQgPSBpc01UOworICAgICAgICBtU3RhdGUgPSBzdGF0ZTsKKyAgICAgICAgbUlzTXB0eSA9IGlzTXB0eTsKKyAgICAgICAgbU51bWJlciA9IG51bWJlcjsKIAogICAgICAgICBpZiAobnVtYmVyLmxlbmd0aCgpID4gMCAmJiBudW1iZXIuY2hhckF0KDApID09ICcrJykgewotICAgICAgICAgICAgVE9BID0gUGhvbmVOdW1iZXJVdGlscy5UT0FfSW50ZXJuYXRpb25hbDsKKyAgICAgICAgICAgIG1UT0EgPSBQaG9uZU51bWJlclV0aWxzLlRPQV9JbnRlcm5hdGlvbmFsOwogICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgVE9BID0gUGhvbmVOdW1iZXJVdGlscy5UT0FfVW5rbm93bjsKKyAgICAgICAgICAgIG1UT0EgPSBQaG9uZU51bWJlclV0aWxzLlRPQV9Vbmtub3duOwogICAgICAgICB9CiAgICAgfQogCkBAIC03NSw5ICs3NSw5IEBACiAgICAgdG9DTENDTGluZShpbnQgaW5kZXgpIHsKICAgICAgICAgcmV0dXJuCiAgICAgICAgICAgICAiK0NMQ0M6ICIKLSAgICAgICAgICAgICsgaW5kZXggKyAiLCIgKyAoaXNNVCA/ICIxIiA6ICIwIikgKyIsIgotICAgICAgICAgICAgKyBzdGF0ZS52YWx1ZSgpICsgIiwwLCIgKyAoaXNNcHR5ID8gIjEiIDogIjAiKQotICAgICAgICAgICAgKyAiLFwiIiArIG51bWJlciArICJcIiwiICsgVE9BOworICAgICAgICAgICAgKyBpbmRleCArICIsIiArIChtSXNNVCA/ICIxIiA6ICIwIikgKyIsIgorICAgICAgICAgICAgKyBtU3RhdGUudmFsdWUoKSArICIsMCwiICsgKG1Jc01wdHkgPyAiMSIgOiAiMCIpCisgICAgICAgICAgICArICIsXCIiICsgbU51bWJlciArICJcIiwiICsgbVRPQTsKICAgICB9CiAKICAgICBEcml2ZXJDYWxsCkBAIC04NywxNyArODcsMTcgQEAKICAgICAgICAgcmV0ID0gbmV3IERyaXZlckNhbGwoKTsKIAogICAgICAgICByZXQuaW5kZXggPSBpbmRleDsKLSAgICAgICAgcmV0LmlzTVQgPSBpc01UOworICAgICAgICByZXQuaXNNVCA9IG1Jc01UOwogCiAgICAgICAgIHRyeSB7Ci0gICAgICAgICAgICByZXQuc3RhdGUgPSBEcml2ZXJDYWxsLnN0YXRlRnJvbUNMQ0Moc3RhdGUudmFsdWUoKSk7CisgICAgICAgICAgICByZXQuc3RhdGUgPSBEcml2ZXJDYWxsLnN0YXRlRnJvbUNMQ0MobVN0YXRlLnZhbHVlKCkpOwogICAgICAgICB9IGNhdGNoIChBVFBhcnNlRXggZXgpIHsKICAgICAgICAgICAgIHRocm93IG5ldyBSdW50aW1lRXhjZXB0aW9uKCJzaG91bGQgbmV2ZXIgaGFwcGVuIiwgZXgpOwogICAgICAgICB9CiAKLSAgICAgICAgcmV0LmlzTXB0eSA9IGlzTXB0eTsKLSAgICAgICAgcmV0Lm51bWJlciA9IG51bWJlcjsKLSAgICAgICAgcmV0LlRPQSA9IFRPQTsKKyAgICAgICAgcmV0LmlzTXB0eSA9IG1Jc01wdHk7CisgICAgICAgIHJldC5udW1iZXIgPSBtTnVtYmVyOworICAgICAgICByZXQuVE9BID0gbVRPQTsKICAgICAgICAgcmV0LmlzVm9pY2UgPSB0cnVlOwogICAgICAgICByZXQuYWxzID0gMDsKIApAQCAtMTA3LDE3ICsxMDcsMTcgQEAKIAogICAgIGJvb2xlYW4KICAgICBpc0FjdGl2ZU9ySGVsZCgpIHsKLSAgICAgICAgcmV0dXJuIHN0YXRlID09IFN0YXRlLkFDVElWRSB8fCBzdGF0ZSA9PSBTdGF0ZS5IT0xESU5HOworICAgICAgICByZXR1cm4gbVN0YXRlID09IFN0YXRlLkFDVElWRSB8fCBtU3RhdGUgPT0gU3RhdGUuSE9MRElORzsKICAgICB9CiAKICAgICBib29sZWFuCiAgICAgaXNDb25uZWN0aW5nKCkgewotICAgICAgICByZXR1cm4gc3RhdGUgPT0gU3RhdGUuRElBTElORyB8fCBzdGF0ZSA9PSBTdGF0ZS5BTEVSVElORzsKKyA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WQodGhpcykgeyBzd2l0Y2ggKG1zZy53aGF0KSB7CkBAIC0xODAsMTQgKzE4MSwxNCBAQAogICAgICAgICAgICAgYm9vbGVhbiBpc0NhbGxXYWl0aW5nID0gZmFsc2U7CiAKICAgICAgICAgICAgIC8vIGVuc3VyZSB0aGVyZSBhcmVuJ3QgYWxyZWFkeSBjYWxscyBJTkNPTUlORyBvciBXQUlUSU5HCi0gICAgICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBjYWxscy5sZW5ndGggOyBpKyspIHsKLSAgICAgICAgICAgICAgICBDYWxsSW5mbyBjYWxsID0gY2FsbHNbaV07CisgICAgICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBtQ2FsbHMubGVuZ3RoIDsgaSsrKSB7CisgICAgICAgICAgICAgICAgQ2FsbEluZm8gY2FsbCA9IG1DYWxsc1tpXTsKIAogICAgICAgICAgICAgICAgIGlmIChjYWxsID09IG51bGwgJiYgZW1wdHkgPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgIGVtcHR5ID0gaTsKICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNhbGwgIT0gbnVsbAotICAgICAgICAgICAgICAgICAgICAmJiAoY2FsbC5zdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5JTkNPTUlORwotICAgICAgICAgICAgICAgICAgICAgICAgfHwgY2FsbC5zdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5XQUlUSU5HKQorICAgICAgICAgICAgICAgICAgICAmJiAoY2FsbC5tU3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuSU5DT01JTkcKKyAgICAgICAgICAgICAgICAgICAgICAgIHx8IGNhbGwubVN0YXRlID09IENhbGxJbmZvLlN0YXRlLldBSVRJTkcpCiAgICAgICAgICAgICAgICAgKSB7CiAgICAgICAgICAgICAgICAgICAgIFJsb2cudygiTW9kZWxJbnRlcnByZXRlciIsCiAgICAgICAgICAgICAgICAgICAgICAgICAidHJpZ2dlclJpbmcgZmFpbGVkOyBwaG9uZSBhbHJlYWR5IHJpbmdpbmciKTsKQEAgLTIwMiwxMSArMjAzLDExIEBACiAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgfQogCi0gICAgICAgICAgICBjYWxsc1tlbXB0eV0gPSBDYWxsSW5mby5jcmVhdGVJbmNvbWluZ0NhbGwoCisgICAgICAgICAgICBtQ2FsbHNbZW1wdHldID0gQ2FsbEluZm8uY3JlYXRlSW5jb21pbmdDYWxsKAogICAgICAgICAgICAgICAgIFBob25lTnVtYmVyVXRpbHMuZXh0cmFjdE5ldHdvcmtQb3J0aW9uKG51bWJlcikpOwogCiAgICAgICAgICAgICBpZiAoaXNDYWxsV2FpdGluZykgewotICAgICAgICAgICAgICAgIGNhbGxzW2VtcHR5XS5zdGF0ZSA9IENhbGxJbmZvLlN0YXRlLldBSVRJTkc7CisgICAgICAgICAgICAgICAgbUNhbGxzW2VtcHR5XS5tU3RhdGUgPSBDYWxsSW5mby5TdGF0ZS5XQUlUSU5HOwogICAgICAgICAgICAgfQogCiAgICAgICAgIH0KQEAgLTIxNywyMiArMjE4LDIyIEBACiAgICAgcHVibGljIHZvaWQKICAgICBwcm9ncmVzc0Nvbm5lY3RpbmdDYWxsU3RhdGUoKSB7CiAgICAgICAgIHN5bmNocm9uaXplZCAodGhpcykgIHsKLSAgICAgICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IGNhbGxzLmxlbmd0aCA7IGkrKykgewotICAgICAgICAgICAgICAgIENhbGxJbmZvIGNhbGwgPSBjYWxsc1tpXTsKKyAgICAgICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IG1DYWxscy5sZW5ndGggOyBpKyspIHsKKyAgICAgICAgICAgICAgICBDYWxsSW5mbyBjYWxsID0gbUNhbGxzW2ldOwogCi0gICAgICAgICAgICAgICAgaWYgKGNhbGwgIT0gbnVsbCAmJiBjYWxsLnN0YXRlID09IENhbGxJbmZvLlN0YXRlLkRJQUxJTkcpIHsKLSAgICAgICAgICAgICAgICAgICAgY2FsbC5zdGF0ZSA9IENhbGxJbmZvLlN0YXRlLkFMRVJUSU5HOworICAgICAgICAgICAgICAgIGlmIChjYWxsICE9IG51bGwgJiYgY2FsbC5tU3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuRElBTElORykgeworICAgICAgICAgICAgICAgICAgICBjYWxsLm1TdGF0ZSA9IENhbGxJbmZvLlN0YXRlLkFMRVJUSU5HOwogCi0gICAgICAgICAgICAgICAgICAgIGlmIChhdXRvUHJvZ3Jlc3NDb25uZWN0aW5nKSB7CisgICAgICAgICAgICAgICAgICAgIGlmIChtQXV0b1Byb2dyZXNzQ29ubmVjdGluZykgewogICAgICAgICAgICAgICAgICAgICAgICAgc2VuZE1lc3NhZ2VEZWxheWVkKAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX1BST0dSRVNTX0NBTExfU1RBVEUsIGNhbGwpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDT05ORUNUSU5HX1BBVVNFX01TRUMpOwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2FsbCAhPSBudWxsCi0gICAgICAgICAgICAgICAgICAgICAgICAmJiBjYWxsLnN0YXRlID09IENhbGxJbmZvLlN0YXRlLkFMRVJUSU5HCisgICAgICAgICAgICAgICAgICAgICAgICAmJiBjYWxsLm1TdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5BTEVSVElORwogICAgICAgICAgICAgICAgICkgewotICAgICAgICAgICAgICAgICAgICBjYWxsLnN0YXRlID0gQ2FsbEluZm8uU3RhdGUuQUNUSVZFOworICAgICAgICAgICAgICAgICAgICBjYWxsLm1TdGF0ZSA9IENhbGxJbmZvLlN0YXRlLkFDVElWRTsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQpAQCAtMjQzLDEzICsyNDQsMTMgQEAKICAgICBwdWJsaWMgdm9pZAogICAgIHByb2dyZXNzQ29ubmVjdGluZ1RvQWN0aXZlKCkgewogICAgICAgICBzeW5jaHJvbml6ZWQgKHRoaXMpICB7Ci0gICAgICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBjYWxscy5sZW5ndGggOyBpKyspIHsKLSAgICAgICAgICAgICAgICBDYWxsSW5mbyBjYWxsID0gY2FsbHNbaV07CisgICAgICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBtQ2FsbHMubGVuZ3RoIDsgaSsrKSB7CisgICAgICAgICAgICAgICAgQ2FsbEluZm8gY2FsbCA9IG1DYWxsc1tpXTsKIAotICAgICAgICAgICAgICAgIGlmIChjYWxsICE9IG51bGwgJiYgKGNhbGwuc3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuRElBTElORwotICAgICAgICAgICAgICAgICAgICB8fCBjYWxsLnN0YXRlID09IENhbGxJbmZvLlN0YXRlLkFMRVJUSU5HKQorICAgICAgICAgICAgICAgIGlmIChjYWxsICE9IG51bGwgJiYgKGNhbGwubVN0YXRlID09IENhbGxJbmZvLlN0YXRlLkRJQUxJTkcKKyAgICAgICAgICAgICAgICAgICAgfHwgY2FsbC5tU3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuQUxFUlRJTkcpCiAgICAgICAgICAgICAgICAgKSB7Ci0gICAgICAgICAgICAgICAgICAgIGNhbGwuc3RhdGUgPSBDYWxsSW5mby5TdGF0ZS5BQ1RJVkU7CisgICAgICAgICAgICAgICAgICAgIGNhbGwubVN0YXRlID0gQ2FsbEluZm8uU3RhdGUuQUNUSVZFOwogICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CkBAIC0yNjEsMTIgKzI2MiwxMiBAQAogICAgICAqLwogICAgIHB1YmxpYyB2b2lkCiAgICAgc2V0QXV0b1Byb2dyZXNzQ29ubmVjdGluZ0NhbGwoYm9vbGVhbiBiKSB7Ci0gICAgICAgIGF1dG9Qcm9ncmVzc0Nvbm5lY3RpbmcgPSBiOworICAgICAgICBtQXV0b1Byb2dyZXNzQ29ubmVjdGluZyA9IGI7CiAgICAgfQogCiAgICAgcHVibGljIHZvaWQKICAgICBzZXROZXh0RGlhbEZhaWxJbW1lZGlhdGVseShib29sZWFuIGIpIHsKLSAgICAgICAgbmV4dERpYWxGYWlsSW1tZWRpYXRlbHkgPSBiOworICAgICAgICBtTmV4dERpYWxGYWlsSW1tZWRpYXRlbHkgPSBiOwogICAgIH0KIAogICAgIC8qKgpAQCAtMjgwLDI3ICsyODEsMjcgQEAKIAogICAgICAgICAgICAgZm91bmQgPSBmYWxzZTsKIAotICAgICAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgY2FsbHMubGVuZ3RoIDsgaSsrKSB7Ci0gICAgICAgICAgICAgICAgQ2FsbEluZm8gY2FsbCA9IGNhbGxzW2ldOworICAgICAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgbUNhbGxzLmxlbmd0aCA7IGkrKykgeworICAgICAgICAgICAgICAgIENhbGxJbmZvIGNhbGwgPSBtQ2FsbHNbaV07CiAKICAgICAgICAgICAgICAgICBpZiAoY2FsbCAhPSBudWxsCi0gICAgICAgICAgICAgICAgICAgICYmIChjYWxsLnN0YXRlID09IENhbGxJbmZvLlN0YXRlLklOQ09NSU5HCi0gICAgICAgICAgICAgICAgICAgICAgICB8fCBjYWxsLnN0YXRlID09IENhbGxJbmZvLlN0YXRlLldBSVRJTkcpCisgICAgICAgICAgICAgICAgICAgICYmIChjYWxsLm1TdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5JTkNPTUlORworICAgICAgICAgICAgICAgICAgICAgICAgfHwgY2FsbC5tU3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuV0FJVElORykKICAgICAgICAgICAgICAgICApIHsKLSAgICAgICAgICAgICAgICAgICAgY2FsbHNbaV0gPSBudWxsOworICAgICAgICAgICAgICAgICAgICBtQ2FsbHNbaV0gPSBudWxsOwogICAgICAgICAgICAgICAgICAgICBmb3VuZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogCi0gICAgICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBjYWxscy5sZW5ndGggOyBpKyspIHsKLSAgICAgICAgICAgICAgICBDYWxsSW5mbyBjYWxsID0gY2FsbHNbaV07CisgICAgICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBtQ2FsbHMubGVuZ3RoIDsgaSsrKSB7CisgICAgICAgICAgICAgICAgQ2FsbEluZm8gY2FsbCA9IG1DYWxsc1tpXTsKIAogICAgICAgICAgICAgICAgIGlmIChjYWxsICE9IG51bGwKLSAgICAgICAgICAgICAgICAgICAgJiYgKGNhbGwuc3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuRElBTElORwotICAgICAgICAgICAgICAgICAgICAgICAgfHwgY2FsbC5zdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5BQ1RJVkUKLSAgICAgICAgICAgICAgICAgICAgICAgIHx8IGNhbGwuc3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuQUxFUlRJTkcpCisgICAgICAgICAgICAgICAgICAgICYmIChjYWxsLm1TdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5ESUFMSU5HCisgICAgICAgICAgICAgICAgICAgICAgICB8fCBjYWxsLm1TdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5BQ1RJVkUKKyAgICAgICAgICAgICAgICAgICAgICAgIHx8IGNhbGwubVN0YXRlID09IENhbGxJbmZvLlN0YXRlLkFMRVJUSU5HKQogICAgICAgICAgICAgICAgICkgewotICAgICAgICAgICAgICAgICAgICBjYWxsc1tpXSA9IG51bGw7CisgICAgICAgICAgICAgICAgICAgIG1DYWxsc1tpXSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgIGZvdW5kID0gdHJ1ZTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CkBAIC0zMTcsMTEgKzMxOCwxMSBAQAogICAgICAgICBzeW5jaHJvbml6ZWQgKHRoaXMpIHsKICAgICAgICAgICAgIGJvb2xlYW4gZm91bmQgPSBmYWxzZTsKIAotICAgICAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgY2FsbHMubGVuZ3RoIDsgaSsrKSB7Ci0gICAgICAgICAgICAgICAgQ2FsbEluZm8gY2FsbCA9IGNhbGxzW2ldOworICAgICAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgbUNhbGxzLmxlbmd0aCA7IGkrKykgeworICAgICAgICAgICAgICAgIENhbGxJbmZvIGNhbGwgPSBtQ2FsbHNbaV07CiAKLSAgICAgICAgICAgICAgICBpZiAoY2FsbCAhPSBudWxsICYmIGNhbGwuc3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuSE9MRElORykgewotICAgICAgICAgICAgICAgICAgICBjYWxsc1tpXSA9IG51bGw7CisgICAgICAgICAgICAgICAgaWYgKGNhbGwgIT0gbnVsbCAmJiBjYWxsLm1TdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5IT0xESU5HKSB7CisgICAgICAgICAgICAgICAgICAgIG1DYWxsc1tpXSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgIGZvdW5kID0gdHJ1ZTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CkBAIC0zMzksMTQgKzM0MCwxNCBAQAogICAgICAgICBzeW5jaHJvbml6ZWQodGhpcykgewogICAgICAgICAgICAgYm9vbGVhbiBmb3VuZCA9IGZhbHNlOwogCi0gICAgICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBjYWxscy5sZW5ndGggOyBpKyspIHsKLSAgICAgICAgICAgICAgICBDYWxsSW5mbyBjYWxsID0gY2FsbHNbaV07CisgICAgICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBtQ2FsbHMubGVuZ3RoIDsgaSsrKSB7CisgICAgICAgICAgICAgICAgQ2FsbEluZm8gY2FsbCA9IG1DYWxsc1tpXTsKIAotICAgICAgICAgICAgICAgIGlmIChjYWxsc1tpXSAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgaWYgKG1DYWxsc1tpXSAhPSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgIGZvdW5kID0gdHJ1ZTsKICAgICAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgICAgICBjYWxsc1tpXSA9IG51bGw7CisgICAgICAgICAgICAgICAgbUNhbGxzW2ldID0gbnVsbDsKICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgcmV0dXJuIGZvdW5kOwpAQCAtMzU2LDEyICszNTcsMTIgQEAKICAgICBwdWJsaWMgYm9vbGVhbgogICAgIG9uQW5zd2VyKCkgewogICAgICAgICBzeW5jaHJvbml6ZWQgKHRoaXMpIHsKLSAgICAgICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IGNhbGxzLmxlbmd0aCA7IGkrKykgewotICAgICAgICAgICAgICAgIENhbGxJbmZvIGNhbGwgPSBjYWxsc1tpXTsKKyAgICAgICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IG1DYWxscy5sZW5ndGggOyBpKyspIHsKKyAgICAgICAgICAgICAgICBDYWxsSW5mbyBjYWxsID0gbUNhbGxzW2ldOwogCiAgICAgICAgICAgICAgICAgaWYgKGNhbGwgIT0gbnVsbAotICAgICAgICAgICAgICAgICAgICAmJiAoY2FsbC5zdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5JTkNPTUlORwotICAgICAgICAgICAgICAgICAgICAgICAgfHwgY2FsbC5zdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5XQUlUSU5HKQorICAgICAgICAgICAgICAgICAgICAmJiAoY2FsbC5tU3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuSU5DT01JTkcKKyAgICAgICAgICAgICAgICAgICAgICAgIHx8IGNhbGwubVN0YXRlID09IENhbGxJbmZvLlN0YXRlLldBSVRJTkcpCiAgICAgICAgICAgICAgICAgKSB7CiAgICAgICAgICAgICAgICAgICAgIHJldHVybiBzd2l0Y2hBY3RpdmVBbmRIZWxkT3JXYWl0aW5nKCk7CiAgICAgICAgICAgICAgICAgfQpAQCAtMzc1LDExICszNzYsMTEgQEAKICAgICBvbkhhbmd1cCgpIHsKICAgICAgICAgYm9vbGVhbiBmb3VuZCA9IGZhbHNlOwogCi0gICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IGNhbGxzLmxlbmd0aCA7IGkrKykgewotICAgICAgICAgICAgQ2FsbEluZm8gY2FsbCA9IGNhbGxzW2ldOworICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBtQ2FsbHMubGVuZ3RoIDsgaSsrKSB7CisgICAgICAgICAgICBDYWxsSW5mbyBjYWxsID0gbUNhbGxzW2ldOwogCi0gICAgICAgICAgICBpZiAoY2FsbCAhPSBudWxsICYmIGNhbGwuc3RhdGUgIT0gQ2FsbEluZm8uU3RhdGUuV0FJVElORykgewotICAgICAgICAgICAgICAgIGNhbGxzW2ldID0gbnVsbDsKKyAgICAgICAgICAgIGlmIChjYWxsICE9IG51bGwgJiYgY2FsbC5tU3RhdGUgIT0gQ2FsbEluZm8uU3RhdGUuV0FJVElORykgeworICAgICAgICAgICAgICAgIG1DYWxsc1tpXSA9IG51bGw7CiAgICAgICAgICAgICAgICAgZm91bmQgPSB0cnVlOwogICAgICAgICAgICAgfQogICAgICAgICB9CkBAIC0zOTUsNyArMzk2LDcgQEAKICAgICAgICAgaWYgKGMxICE9IDApIHsKICAgICAgICAgICAgIGNhbGxJbmRleCA9IGMxIC0gJzEnOwogCi0gICAgICAgICAgICBpZiAoY2FsbEluZGV4IDwgMCB8fCBjYWxsSW5kZXggPj0gY2FsbHMubGVuZ3RoKSB7CisgICAgICAgICAgICBpZiAoY2FsbEluZGV4IDwgMCB8fCBjYWxsSW5kZXggPj0gbUNhbGxzLmxlbmd0aCkgewogICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgIH0KICAgICAgICAgfQpAQCAtNDA4LDEwICs0MDksMTAgQEAKICAgICAgICAgICAgICAgICBpZiAoYzEgPD0gMCkgewogICAgICAgICAgICAgICAgICAgICByZXQgPSByZWxlYXNlQWN0aXZlQWNjZXB0SGVsZE9yV2FpdGluZygpOwogICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChjYWxsc1tjYWxsSW5kZXhdID09IG51bGwpIHsKKyAgICAgICAgICAgICAgICAgICAgaWYgKG1DYWxsc1tjYWxsSW5kZXhdID09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIHJldCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgICAgICAgICAgY2FsbHNbY2FsbEluZGV4XSA9IG51bGw7CisgICAgICAgICAgICAgICAgICAgICAgICBtQ2FsbHNbY2FsbEluZGV4XSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICByZXQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgfQpAQCAtNDQ3LDIzICs0NDgsMjMgQEAKICAgICByZWxlYXNlSGVsZE9yVURVQigpIHsKICAgICAgICAgYm9vbGVhbiBmb3VuZCA9IGZhbHNlOwogCi0gICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IGNhbGxzLmxlbmd0aCA7IGkrKykgewotICAgICAgICAgICAgQ2FsbEluZm8gYyA9IGNhbGxzW2ldOworICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBtQ2FsbHMubGVuZ3RoIDsgaSsrKSB7CisgICAgICAgICAgICBDYWxsSW5mbyBjID0gbUNhbGxzW2ldOwogCiAgICAgICAgICAgICBpZiAoYyAhPSBudWxsICYmIGMuaXNSaW5naW5nKCkpIHsKICAgICAgICAgICAgICAgICBmb3VuZCA9IHRydWU7Ci0gICAgICAgICAgICAgICAgY2FsbHNbaV0gPSBudWxsOworICAgICAgICAgICAgICAgIG1DYWxsc1tpXSA9IG51bGw7CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KIAogICAgICAgICBpZiAoIWZvdW5kKSB7Ci0gICAgICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBjYWxscy5sZW5ndGggOyBpKyspIHsKLSAgICAgICAgICAgICAgICBDYWxsSW5mbyBjID0gY2FsbHNbaV07CisgICAgICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBtQ2FsbHMubGVuZ3RoIDsgaSsrKSB7CisgICAgICAgICAgICAgICAgQ2FsbEluZm8gYyA9IG1DYWxsc1tpXTsKIAotICAgICAgICAgICAgICAgIGlmIChjICE9IG51bGwgJiYgYy5zdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5IT0xESU5HKSB7CisgICAgICAgICAgICAgICAgaWYgKGMgIT0gbnVsbCAmJiBjLm1TdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5IT0xESU5HKSB7CiAgICAgICAgICAgICAgICAgICAgIGZvdW5kID0gdHJ1ZTsKLSAgICAgICAgICAgICAgICAgICAgY2FsbHNbaV0gPSBudWxsOworICAgICAgICAgICAgICAgICAgICBtQ2FsbHNbaV0gPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAvLyBkb24ndCBzdG9wLi4udGhlcmUgbWF5IGJlIG1vcmUgdGhhbiBvbmUKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CkBAIC00NzgsMTEgKzQ3OSwxMSBAQAogICAgICAgICBib29sZWFuIGZvdW5kSGVsZCA9IGZhbHNlOwogICAgICAgICBib29sZWFuIGZvdW5kQWN0aXZlID0gZmFsc2U7CiAKLSAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgY2FsbHMubGVuZ3RoIDsgaSsrKSB7Ci0gICAgICAgICAgICBDYWxsSW5mbyBjID0gY2FsbHNbaV07CisgICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IG1DYWxscy5sZW5ndGggOyBpKyspIHsKKyAgICAgICAgICAgIENhbGxJbmZvIGMgPSBtQ2FsbHNbaV07CiAKLSAgICAgICAgICAgIGlmIChjICE9IG51bGwgJiYgYy5zdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5BQ1RJVkUpIHsKLSAgICAgICAgICAgICAgICBjYWxsc1tpXSA9IG51bGw7CisgICAgICAgICAgICBpZiAoYyAhPSBudWxsICYmIGMubVN0YXRlID09IENhbGxJbmZvLlN0YXRlLkFDVElWRSkgeworICAgICAgICAgICAgICAgIG1DYWxsc1tpXSA9IG51bGw7CiAgICAgICAgICAgICAgICAgZm91bmRBY3RpdmUgPSB0cnVlOwogICAgICAgICAgICAgfQogICAgICAgICB9CkBAIC00OTAsMjQgKzQ5MSwyNCBAQAogICAgICAgICBpZiAoIWZvdW5kQWN0aXZlKSB7CiAgICAgICAgICAgICAvLyBGSVhNRSB0aGlzIG1heSBub3QgYWN0dWFsbHkgYmUgaG93IG1vc3QgYmFzZWJhbmRzIHJlYWN0CiAgICAgICAgICAgICAvLyBDSExEPTEgbWF5IG5vdCBoYW5nIHVwIGRpYWxpbmcvYWxlcnRpbmcgY2FsbHMKLSAgICAgICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IGNhbGxzLmxlbmd0aCA7IGkrKykgewotICAgICAgICAgICAgICAgIENhbGxJbmZvIGMgPSBjYWxsc1tpXTsKKyAgICAgICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IG1DYWxscy5sZW5ndGggOyBpKyspIHsKKyAgICAgICAgICAgICAgICBDYWxsSW5mbyBjID0gbUNhbGxzW2ldOwogCiAgICAgICAgICAgICAgICAgaWYgKGMgIT0gbnVsbAotICAgICAgICAgICAgICAgICAgICAgICAgJiYgKGMuc3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuRElBTElORwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHx8IGMuc3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuQUxFUlRJTkcpCisgICAgICAgICAgICAgICAgICAgICAgICAmJiAoYy5tU3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuRElBTElORworICAgICAgICAgICAgICAgICAgICAgICAgICAgIHx8IGMubVN0YXRlID09IENhbGxJbmZvLlN0YXRlLkFMRVJUSU5HKQogICAgICAgICAgICAgICAgICkgewotICAgICAgICAgICAgICAgICAgICBjYWxsc1tpXSA9IG51bGw7CisgICAgICAgICAgICAgICAgICAgIG1DYWxsc1tpXSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgIGZvdW5kQWN0aXZlID0gdHJ1ZTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KIAotICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBjYWxscy5sZW5ndGggOyBpKyspIHsKLSAgICAgICAgICAgIENhbGxJbmZvIGMgPSBjYWxsc1tpXTsKKyAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgbUNhbGxzLmxlbmd0aCA7IGkrKykgeworICAgICAgICAgICAgQ2FsbEluZm8gYyA9IG1DYWxsc1tpXTsKIAotICAgICAgICAgICAgaWYgKGMgIT0gbnVsbCAmJiBjLnN0YXRlID09IENhbGxJbmZvLlN0YXRlLkhPTERJTkcpIHsKLSAgICAgICAgICAgICAgICBjLnN0YXRlID0gQ2FsbEluZm8uU3RhdGUuQUNUSVZFOworICAgICAgICAgICAgaWYgKGMgIT0gbnVsbCAmJiBjLm1TdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5IT0xESU5HKSB7CisgICAgICAgICAgICAgICAgYy5tU3RhdGUgPSBDYWxsSW5mby5TdGF0ZS5BQ1RJVkU7CiAgICAgICAgICAgICAgICAgZm91bmRIZWxkID0gdHJ1ZTsKICAgICAgICAgICAgIH0KICAgICAgICAgfQpAQCAtNTE2LDExICs1MTcsMTEgQEAKICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICB9CiAKLSAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgY2FsbHMubGVuZ3RoIDsgaSsrKSB7Ci0gICAgICAgICAgICBDYWxsSW5mbyBjID0gY2FsbHNbaV07CisgICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IG1DYWxscy5sZW5ndGggOyBpKyspIHsKKyAgICAgICAgICAgIENhbGxJbmZvIGMgPSBtQ2FsbHNbaV07CiAKICAgICAgICAgICAgIGlmIChjICE9IG51bGwgJiYgYy5pc1JpbmdpbmcoKSkgewotICAgICAgICAgICAgICAgIGMuc3RhdGUgPSBDYWxsSW5mby5TdGF0ZS5BQ1RJVkU7CisgICAgICAgICAgICAgICAgYy5tU3RhdGUgPSBDYWxsSW5mby5TdGF0ZS5BQ1RJVkU7CiAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KQEAgLTUzMywyNiArNTM0LDI2IEBACiAgICAgICAgIGJvb2xlYW4gaGFzSGVsZCA9IGZhbHNlOwogCiAgICAgICAgIC8vIGZpcnN0LCBhcmUgdGhlcmUgaGVsZCBjYWxscz8KLSAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgY2FsbHMubGVuZ3RoIDsgaSsrKSB7Ci0gICAgICAgICAgICBDYWxsSW5mbyBjID0gY2FsbHNbaV07CisgICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IG1DYWxscy5sZW5ndGggOyBpKyspIHsKKyAgICAgICAgICAgIENhbGxJbmZvIGMgPSBtQ2FsbHNbaV07CiAKLSAgICAgICAgICAgIGlmIChjICE9IG51bGwgJiYgYy5zdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5IT0xESU5HKSB7CisgICAgICAgICAgICBpZiAoYyAhPSBudWxsICYmIGMubVN0YXRlID09IENhbGxJbmZvLlN0YXRlLkhPTERJTkcpIHsKICAgICAgICAgICAgICAgICBoYXNIZWxkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIH0KICAgICAgICAgfQogCiAgICAgICAgIC8vIE5vdywgc3dpdGNoCi0gICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IGNhbGxzLmxlbmd0aCA7IGkrKykgewotICAgICAgICAgICAgQ2FsbEluZm8gYyA9IGNhbGxzW2ldOworICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBtQ2FsbHMubGVuZ3RoIDsgaSsrKSB7CisgICAgICAgICAgICBDYWxsSW5mbyBjID0gbUNhbGxzW2ldOwogCiAgICAgICAgICAgICBpZiAoYyAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgaWYgKGMuc3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuQUNUSVZFKSB7Ci0gICAgICAgICAgICAgICAgICAgIGMuc3RhdGUgPSBDYWxsSW5mby5TdGF0ZS5IT0xESU5HOwotICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoYy5zdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5IT0xESU5HKSB7Ci0gICAgICAgICAgICAgICAgICAgIGMuc3RhdGUgPSBDYWxsSW5mby5TdGF0ZS5BQ1RJVkU7CisgICAgICAgICAgICAgICAgaWYgKGMubVN0YXRlID09IENhbGxJbmZvLlN0YXRlLkFDVElWRSkgeworICAgICAgICAgICAgICAgICAgICBjLm1TdGF0ZSA9IENhbGxJbmZvLlN0YXRlLkhPTERJTkc7CisgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjLm1TdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5IT0xESU5HKSB7CisgICAgICAgICAgICAgICAgICAgIGMubVN0YXRlID0gQ2FsbEluZm8uU3RhdGUuQUNUSVZFOwogICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIWhhc0hlbGQgJiYgYy5pc1JpbmdpbmcoKSkgIHsKLSAgICAgICAgICAgICAgICAgICAgYy5zdGF0ZSA9IENhbGxJbmZvLlN0YXRlLkFDVElWRTsKKyAgICAgICAgICAgICAgICAgICAgYy5tU3RhdGUgPSBDYWxsSW5mby5TdGF0ZS5BQ1RJVkU7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogICAgICAgICB9CkBAIC01NjYsMjMgKzU2NywyMyBAQAogICAgICAgICB0cnkgewogICAgICAgICAgICAgQ2FsbEluZm8gYzsKIAotICAgICAgICAgICAgYyA9IGNhbGxzW2luZGV4XTsKKyAgICAgICAgICAgIGMgPSBtQ2FsbHNbaW5kZXhdOwogCiAgICAgICAgICAgICBpZiAoYyA9PSBudWxsIHx8IGMuaXNDb25uZWN0aW5nKCkgfHwgY291bnRBY3RpdmVMaW5lcygpICE9IDEpIHsKICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgIGMuc3RhdGUgPSBDYWxsSW5mby5TdGF0ZS5BQ1RJVkU7Ci0gICAgICAgICAgICBjLmlzTXB0eSA9IGZhbHNlOworICAgICAgICAgICAgYy5tU3RhdGUgPSBDYWxsSW5mby5TdGF0ZS5BQ1RJVkU7CisgICAgICAgICAgICBjLm1Jc01wdHkgPSBmYWxzZTsKIAotICAgICAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgY2FsbHMubGVuZ3RoIDsgaSsrKSB7CisgICAgICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBtQ2FsbHMubGVuZ3RoIDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgaW50IGNvdW50SGVsZD0wLCBsYXN0SGVsZD0wOwogCiAgICAgICAgICAgICAgICAgaWYgKGkgIT0gaW5kZXgpIHsKLSAgICAgICAgICAgICAgICAgICAgQ2FsbEluZm8gY2IgPSBjYWxsc1tpXTsKKyAgICAgICAgICAgICAgICAgICAgQ2FsbEluZm8gY2IgPSBtQ2FsbHNbaV07CiAKLSAgICAgICAgICAgICAgICAgICAgaWYgKGNiICE9IG51bGwgJiYgY2Iuc3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuQUNUSVZFKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBjYi5zdGF0ZSA9IENhbGxJbmZvLlN0YXRlLkhPTERJTkc7CisgICAgICAgICAgICAgICAgICAgIGlmIChjYiAhPSBudWxsICYmIGNiLm1TdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5BQ1RJVkUpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGNiLm1TdGF0ZSA9IENhbGxJbmZvLlN0YXRlLkhPTERJTkc7CiAgICAgICAgICAgICAgICAgICAgICAgICBjb3VudEhlbGQrKzsKICAgICAgICAgICAgICAgICAgICAgICAgIGxhc3RIZWxkID0gaTsKICAgICAgICAgICAgICAgICAgICAgfQpAQCAtNTkwLDcgKzU5MSw3IEBACiAKICAgICAgICAgICAgICAgICBpZiAoY291bnRIZWxkID09IDEpIHsKICAgICAgICAgICAgICAgICAgICAgLy8gaWYgdGhlcmUncyBvbmx5IG9uZSBsZWZ0LCBjbGVhciB0aGUgTVBUWSBmbGFnCi0gICAgICAgICAgICAgICAgICAgIGNhbGxzW2xhc3RIZWxkXS5pc01wdHkgPSBmYWxzZTsKKyAgICAgICAgICAgICAgICAgICAgbUNhbGxzW2xhc3RIZWxkXS5tSXNNcHR5ID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogCkBAIC02MDcsOCArNjA4LDggQEAKICAgICAgICAgaW50IGNvdW50Q2FsbHMgPSAwOwogCiAgICAgICAgIC8vIGlmIHRoZXJlJ3MgY29ubmVjdGluZyBjYWxscywgd2UgY2FuJ3QgZG8gdGhpcyB5ZXQKLSAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgY2FsbHMubGVuZ3RoIDsgaSsrKSB7Ci0gICAgICAgICAgICBDYWxsSW5mbyBjID0gY2FsbHNbaV07CisgICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IG1DYWxscy5sZW5ndGggOyBpKyspIHsKKyAgICAgICAgICAgIENhbGxJbmZvIGMgPSBtQ2FsbHNbaV07CiAKICAgICAgICAgICAgIGlmIChjICE9IG51bGwpIHsKICAgICAgICAgICAgICAgICBjb3VudENhbGxzKys7CkBAIC02MTgsMTMgKzYxOSwxMyBAQAogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KICAgICAgICAgfQotICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBjYWxscy5sZW5ndGggOyBpKyspIHsKLSAgICAgICAgICAgIENhbGxJbmZvIGMgPSBjYWxsc1tpXTsKKyAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgbUNhbGxzLmxlbmd0aCA7IGkrKykgeworICAgICAgICAgICAgQ2FsbEluZm8gYyA9IG1DYWxsc1tpXTsKIAogICAgICAgICAgICAgaWYgKGMgIT0gbnVsbCkgewotICAgICAgICAgICAgICAgIGMuc3RhdGUgPSBDYWxsSW5mby5TdGF0ZS5BQ1RJVkU7CisgICAgICAgICAgICAgICAgYy5tU3RhdGUgPSBDYWxsSW5mby5TdGF0ZS5BQ1RJVkU7CiAgICAgICAgICAgICAgICAgaWYgKGNvdW50Q2FsbHMgPiAwKSB7Ci0gICAgICAgICAgICAgICAgICAgIGMuaXNNcHR5ID0gdHJ1ZTsKKyAgICAgICAgICAgICAgICAgICAgYy5tSXNNcHR5ID0gdHJ1ZTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KQEAgLTYzNyw4ICs2MzgsOCBAQAogICAgICAgICBpbnQgY291bnRDYWxscyA9IDA7CiAKICAgICAgICAgLy8gaWYgdGhlcmUncyBjb25uZWN0aW5nIGNhbGxzLCB3ZSBjYW4ndCBkbyB0aGlzIHlldAotICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBjYWxscy5sZW5ndGggOyBpKyspIHsKLSAgICAgICAgICAgIENhbGxJbmZvIGMgPSBjYWxsc1tpXTsKKyAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgbUNhbGxzLmxlbmd0aCA7IGkrKykgeworICAgICAgICAgICAgQ2FsbEluZm8gYyA9IG1DYWxsc1tpXTsKIAogICAgICAgICAgICAgaWYgKGMgIT0gbnVsbCkgewogICAgICAgICAgICAgICAgIGNvdW50Q2FsbHMrKzsKQEAgLTY2MCw4ICs2NjEsOCBAQAogCiAgICAgICAgIFJsb2cuZCgiR1NNIiwgIlNDPiBkaWFsICciICsgYWRkcmVzcyArICInIik7CiAKLSAgICAgICAgaWYgKG5leHREaWFsRmFpbEltbWVkaWF0ZWx5KSB7Ci0gICAgICAgICAgICBuZXh0RGlhbEZhaWxJbW1lZGlhdGVseSA9IGZhbHNlOworICAgICAgICBpZiAobU5leHREaWFsRmFpbEltbWVkaWF0ZWx5KSB7CisgICAgICAgICAgICBtTmV4dERpYWxGYWlsSW1tZWRpYXRlbHkgPSBmYWxzZTsKIAogICAgICAgICAgICAgUmxvZy5kKCJHU00iLCAiU0M8IGRpYWwgZmFpbCAocGVyIHJlcXVlc3QpIik7CiAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CkBAIC02OTIsMTkgKzY5MywxOSBAQAogICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICB9CiAKLSAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgY2FsbHMubGVuZ3RoIDsgaSsrKSB7Ci0gICAgICAgICAgICBpZiAoZnJlZVNsb3QgPCAwICYmIGNhbGxzW2ldID09IG51bGwpIHsKKyAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgbUNhbGxzLmxlbmd0aCA7IGkrKykgeworICAgICAgICAgICAgaWYgKGZyZWVTbG90IDwgMCAmJiBtQ2FsbHNbaV0gPT0gbnVsbCkgewogICAgICAgICAgICAgICAgIGZyZWVTbG90ID0gaTsKICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgaWYgKGNhbGxzW2ldICE9IG51bGwgJiYgIWNhbGxzW2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2FsbEluZm8uY3JlYXRlT3V0Z29pbmdDYWxsKHBoTnVtKTsKIAotICAgICAgICBpZiAoYXV0b1Byb2dyZXNzQ29ubmVjdGluZykgeworICAgICAgICBpZiAobUF1dG9Qcm9ncmVzc0Nvbm5lY3RpbmcpIHsKICAgICAgICAgICAgIHNlbmRNZXNzYWdlRGVsYXllZCgKLSAgICAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZShFVkVOVF9QUk9HUkVTU19DQUxMX1NUQVRFLCBjYWxsc1tmcmVlU2xvdF0pLAorICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX1BST0dSRVNTX0NBTExfU1RBVEUsIG1DYWxsc1tmcmVlU2xvdF0pLAogICAgICAgICAgICAgICAgICAgICBDT05ORUNUSU5HX1BBVVNFX01TRUMpOwogICAgICAgICB9CiAKQEAgLTcyOCwxMCArNzI5LDEwIEBACiAKICAgICBwdWJsaWMgTGlzdDxEcml2ZXJDYWxsPgogICAgIGdldERyaXZlckNhbGxzKCkgewotICAgICAgICBBcnJheUxpc3Q8RHJpdmVyQ2FsbD4gcmV0ID0gbmV3IEFycmF5TGlzdDxEcml2ZXJDYWxsPihjYWxscy5sZW5ndGgpOworICAgICAgICBBcnJheUxpc3Q8RHJpdmVyQ2FsbD4gcmV0ID0gbmV3IEFycmF5TGlzdDxEcml2ZXJDYWxsPihtQ2FsbHMubGVuZ3RoKTsKIAotICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBjYWxscy5sZW5ndGggOyBpKyspIHsKLSAgICAgICAgICAgIENhbGxJbmZvIGMgPSBjYWxsc1tpXTsKKyAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgbUNhbGxzLmxlbmd0aCA7IGkrKykgeworICAgICAgICAgICAgQ2FsbEluZm8gYyA9IG1DYWxsc1tpXTsKIAogICAgICAgICAgICAgaWYgKGMgIT0gbnVsbCkgewogICAgICAgICAgICAgICAgIERyaXZlckNhbGwgZGM7CkBAIC03NDgsMTAgKzc0OSwxMCBAQAogCiAgICAgcHVibGljIExpc3Q8U3RyaW5nPgogICAgIGdldENsY2NMaW5lcygpIHsKLSAgICAgICAgQXJyYXlMaXN0PFN0cmluZz4gcmV0ID0gbmV3IEFycmF5TGlzdDxTdHJpbmc+KGNhbGxzLmxlbmd0aCk7CisgICAgICAgIEFycmF5TGlzdDxTdHJpbmc+IHJldCA9IG5ldyBBcnJheUxpc3Q8U3RyaW5nPihtQ2FsbHMubGVuZ3RoKTsKIAotICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBjYWxscy5sZW5ndGggOyBpKyspIHsKLSAgICAgICAgICAgIENhbGxJbmZvIGMgPSBjYWxsc1tpXTsKKyAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgbUNhbGxzLmxlbmd0aCA7IGkrKykgeworICAgICAgICAgICAgQ2FsbEluZm8gYyA9IG1DYWxsc1tpXTsKIAogICAgICAgICAgICAgaWYgKGMgIT0gbnVsbCkgewogICAgICAgICAgICAgICAgIHJldC5hZGQoKGMudG9DTENDTGluZShpICsgMSkpKTsKQEAgLTc3MCwyNyArNzcxLDI3IEBACiAgICAgICAgIGJvb2xlYW4gaGFzUmluZ2luZyA9IGZhbHNlOwogICAgICAgICBib29sZWFuIG1wdHlJc0hlbGQgPSBmYWxzZTsKIAotICAgICAgICBmb3IgKGludCBpID0gMCA7IGkgPCBjYWxscy5sZW5ndGggOyBpKyspIHsKLSAgICAgICAgICAgIENhbGxJbmZvIGNhbGwgPSBjYWxsc1tpXTsKKyAgICAgICAgZm9yIChpbnQgaSA9IDAgOyBpIDwgbUNhbGxzLmxlbmd0aCA7IGkrKykgeworICAgICAgICAgICAgQ2FsbEluZm8gY2FsbCA9IG1DYWxsc1tpXTsKIAogICAgICAgICAgICAgaWYgKGNhbGwgIT0gbnVsbCkgewotICAgICAgICAgICAgICAgIGlmICghaGFzTXB0eSAmJiBjYWxsLmlzTXB0eSkgewotICAgICAgICAgICAgICAgICAgICBtcHR5SXNIZWxkID0gY2FsbC5zdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5IT0xESU5HOwotICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2FsbC5pc01wdHkgJiYgbXB0eUlzSGVsZAotICAgICAgICAgICAgICAgICAgICAmJiBjYWxsLnN0YXRlID09IENhbGxJbmZvLlN0YXRlLkFDVElWRQorICAgICAgICAgICAgICAgIGlmICghaGFzTXB0eSAmJiBjYWxsLm1Jc01wdHkpIHsKKyAgICAgICAgICAgICAgICAgICAgbXB0eUlzSGVsZCA9IGNhbGwubVN0YXRlID09IENhbGxJbmZvLlN0YXRlLkhPTERJTkc7CisgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjYWxsLm1Jc01wdHkgJiYgbXB0eUlzSGVsZAorICAgICAgICAgICAgICAgICAgICAmJiBjYWxsLm1TdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5BQ1RJVkUKICAgICAgICAgICAgICAgICApIHsKICAgICAgICAgICAgICAgICAgICAgUmxvZy5lKCJNb2RlbEludGVycHJldGVyIiwgIkludmFsaWQgc3RhdGUiKTsKICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEludmFsaWRTdGF0ZUV4KCk7Ci0gICAgICAgICAgICAgICAgfSBlbHNlIGlmICghY2FsbC5pc01wdHkgJiYgaGFzTXB0eSAmJiBtcHR5SXNIZWxkCi0gICAgICAgICAgICAgICAgICAgICYmIGNhbGwuc3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuSE9MRElORworICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIWNhbGwubUlzTXB0eSAmJiBoYXNNcHR5ICYmIG1wdHlJc0hlbGQKKyAgICAgICAgICAgICAgICAgICAgJiYgY2FsbC5tU3RhdGUgPT0gQ2FsbEluZm8uU3RhdGUuSE9MRElORwogICAgICAgICAgICAgICAgICkgewogICAgICAgICAgICAgICAgICAgICBSbG9nLmUoIk1vZGVsSW50ZXJwcmV0ZXIiLCAiSW52YWxpZCBzdGF0ZSIpOwogICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgSW52YWxpZFN0YXRlRXgoKTsKICAgICAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgICAgICBoYXNNcHR5IHw9IGNhbGwuaXNNcHR5OwotICAgICAgICAgICAgICAgIGhhc0hlbGQgfD0gY2FsbC5zdGF0ZSA9PSBDYWxsSW5mby5TdGF0ZS5IT0xESU5HOwotICAgICAgICAgICAgICAgIGhhc0FjdGl2ZSB8PSBjYWxsLnN0YXRlID09IENhbGxJbmZvLlN0YXRlLkFDVElWRTsKKyAgICAgICAgICAgICAgICBoYXNNcHR5IHw9IGNhbGwubUlzTXB0eTsKKyAgICAgICAgICAgICAgICBoYXNIZWxkIHw9IGNhbGwubVN0YXRlID09IENhbGxJbmZvLlN0YXRlLkhPTERJTkc7CisgICAgICAgICAgICAgICAgaGFzQWN0aXZlIHw9IGNhbGwubVN0YXRlID09IENhbGxJbmZvLlN0YXRlLkFDVElWRTsKICAgICAgICAgICAgICAgICBoYXNDb25uZWN0aW5nIHw9IGNhbGwuaXNDb25uZWN0aW5nKCk7CiAgICAgICAgICAgICAgICAgaGFzUmluZ2luZyB8PSBjYWxsLmlzUmluZ2luZygpOwogICAgICAgICAgICAgfQpkaWZmIC0tZ2l0IGEvc3JjL2phdmEvY29tL2FuZHJvaWQvaW50ZXJuYWwvdGVsZXBob255L3VpY2MvQWRuUmVjb3JkLmphdmEgYi9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvdWljYy9BZG5SZWNvcmQuamF2YQppbmRleCBjZTVjMzI5Li44YmE3ODY5IDEwMDY0NAotLS0gYS9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvdWljYy9BZG5SZWNvcmQuamF2YQorKysgYi9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvdWljYy9BZG5SZWN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lRnJvbVBhcmNlbChQYXJjZWwgc291cmNlKSB7CiAgICAgICAgICAgICBpbnQgZWZpZDsKICAgICAgICAgICAgIGludCByZWNvcmROdW1iZXI7CkBAIC04OSw2ICs5MCw3IEBACiAgICAgICAgICAgICByZXR1cm4gbmV3IEFkblJlY29yZChlZmlkLCByZWNvcmROdW1iZXIsIGFscGhhVGFnLCBudW1iZXIsIGVtYWlscyk7CiAgICAgICAgIH0KIAorICAgICAgICBAT3ZlcnJpZGUKICAgICAgICAgcHVibGljIEFkblJlY29yZFtdIG5ld0FycmF5KGludCBzaXplKSB7CiAgICAgICAgICAgICByZXR1cm4gbmV3IEFkblJlY29yZFtzaXplXTsKICAgICAgICAgfQpAQCAtMTAxLDggKzEwMyw4IEBACiAgICAgfQogCiAgICAgcHVibGljIEFkblJlY29yZCAoaW50IGVmaWQsIGludCByZWNvcmROdW1iZXIsIGJ5dGVbXSByZWNvcmQpIHsKLSAgICAgICAgdGhpcy5lZmlkID0gZWZpZDsKLSAgICAgICAgdGhpcy5yZWNvcmROdW1iZXIgPSByZWNvcmROdW1iZXI7CisgICAgICAgIHRoaXMubUVmaWQgPSBlZmlkOworICAgICAgICB0aGlzLm1SZWNvcmROdW1iZXIgPSByZWNvcmROdW1iZXI7CiAgICAgICAgIHBhcnNlUmVjb3JkKHJlY29yZCk7CiAgICAgfQogCkBAIC0xMTUsNDkgKzExNyw1MCBAQAogICAgIH0KIAogICAgIHB1YmxpYyBBZG5SZWNvcmQgKGludCBlZmlkLCBpbnQgcmVjb3JkTnVtYmVyLCBTdHJpbmcgYWxwaGFUYWcsIFN0cmluZyBudW1iZXIsIFN0cmluZ1tdIGVtYWlscykgewotICAgICAgICB0aGlzLmVmaWQgPSBlZmlkOwotICAgICAgICB0aGlzLnJlY29yZE51bWJlciA9IHJlY29yZE51bWJlcjsKLSAgICAgICAgdGhpcy5hbHBoYVRhZyA9IGFscGhhVGFnOwotICAgICAgICB0aGlzLm51bWJlciA9IG51bWJlcjsKLSAgICAgICAgdGhpcy5lbWFpbHMgPSBlbWFpbHM7CisgICAgICAgIHRoaXMubUVmaWQgPSBlZmlkOworICAgICAgICB0aGlzLm1SZWNvcmROdW1iZXIgPSByZWNvcmROdW1iZXI7CisgICAgICAgIHRoaXMubUFscGhhVGFnID0gYWxwaGFUYWc7CisgICAgICAgIHRoaXMubU51bWJlciA9IG51bWJlcjsKKyAgICAgICAgdGhpcy5tRW1haWxzID0gZW1haWxzOwogICAgIH0KIAogICAgIHB1YmxpYyBBZG5SZWNvcmQoaW50IGVmaWQsIGludCByZWNvcmROdW1iZXIsIFN0cmluZyBhbHBoYVRhZywgU3RyaW5nIG51bWJlcikgewotICAgICAgICB0aGlzLmVmaWQgPSBlZmlkOwotICAgICAgICB0aGlzLnJlY29yZE51bWJlciA9IHJlY29yZE51bWJlcjsKLSAgICAgICAgdGhpcy5hbHBoYVRhZyA9IGFscGhhVGFnOwotICAgICAgICB0aGlzLm51bWJlciA9IG51bWJlcjsKLSAgICAgICAgdGhpcy5lbWFpbHMgPSBudWxsOworICAgICAgICB0aGlzLm1FZmlkID0gZWZpZDsKKyAgICAgICAgdGhpcy5tUmVjb3JkTnVtYmVyID0gcmVjb3JkTnVtYmVyOworICAgICAgICB0aGlzLm1BbHBoYVRhZyA9IGFscGhhVGFnOworICAgICAgICB0aGlzLm1OdW1iZXIgPSBudW1iZXI7CisgICAgICAgIHRoaXMubUVtYWlscyA9IG51bGw7CiAgICAgfQogCiAgICAgLy8qKioqKiBJbnN0YW5jZSBNZXRob2RzCiAKICAgICBwdWJsaWMgU3RyaW5nIGdldEFscGhhVGFnKCkgewotICAgICAgICByZXR1cm4gYWxwaGFUYWc7CisgICAgICAgIHJldHVybiBtQWxwaGFUYWc7CiAgICAgfQogCiAgICAgcHVibGljIFN0cmluZyBnZXROdW1iZXIoKSB7Ci0gICAgICAgIHJldHVybiBudW1iZXI7CisgICAgICAgIHJldHVybiBtTnVtYmVyOwogICAgIH0KIAogICAgIHB1YmxpYyBTdHJpbmdbXSBnZXRFbWFpbHMoKSB7Ci0gICAgICAgIHJldHVybiBlbWFpbHM7CisgICAgICAgIHJldHVybiBtRW1haWxzOwogICAgIH0KIAogICAgIHB1YmxpYyB2b2lkIHNldEVtYWlscyhTdHJpbmdbXSBlbWFpbHMpIHsKLSAgICAgICAgdGhpcy5lbWFpbHMgPSBlbWFpbHM7CisgICAgICAgIHRoaXMubUVtYWlscyA9IGVtYWlsczsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgU3RyaW5nIHRvU3RyaW5nKCkgewotICAgICAgICByZXR1cm4gIkFETiBSZWNvcmQgJyIgKyBhbHBoYVRhZyArICInICciICsgbnVtYmVyICsgIiAiICsgZW1haWxzICsgIiciOworICAgICAgICByZXR1cm4gIkFETiBSZWNvcmQgJyIgKyBtQWxwaGFUYWcgKyAiJyAnIiArIG1OdW1iZXIgKyAiICIgKyBtRW1haWxzICsgIiciOwogICAgIH0KIAogICAgIHB1YmxpYyBib29sZWFuIGlzRW1wdHkoKSB7Ci0gICAgICAgIHJldHVybiBUZXh0VXRpbHMuaXNFbXB0eShhbHBoYVRhZykgJiYgVGV4dFV0aWxzLmlzRW1wdHkobnVtYmVyKSAmJiBlbWFpbHMgPT0gbnVsbDsKKyAgICAgICAgcmV0dXJuIFRleHRVdGlscy5pc0VtcHR5KG1BbHBoYVRhZykgJiYgVGV4dFV0aWxzLmlzRW1wdHkobU51bWJlcikgJiYgbUVtYWlscyA9PSBudWxsOwogICAgIH0KIAogICAgIHB1YmxpYyBib29sZWFuIGhhc0V4dGVuZGVkUmVjb3JkKCkgewotICAgICAgICByZXR1cm4gZXh0UmVjb3JkICE9IDAgJiYgZXh0UmVjb3JkICE9IDB4ZmY7CisgICAgICAgIHJldHVybiBtRXh0UmVjb3JkICE9IDAgJiYgbUV4dFJlY29yZCAhPSAweGZmOwogICAgIH0KIAogICAgIC8qKiBIZWxwZXIgZnVuY3Rpb24gZm9yIHtAbGluayAjaXNFcXVhbH0uICovCkBAIC0xNzUsMjIgKzE3OCwyNCBAQAogICAgIH0KIAogICAgIHB1YmxpYyBib29sZWFuIGlzRXF1YWwoQWRuUmVjb3JkIGFkbikgewotICAgICAgICByZXR1cm4gKCBzdHJpbmdDb21wYXJlTnVsbEVxdWFsc0VtcHR5KGFscGhhVGFnLCBhZG4uYWxwaGFUYWcpICYmCi0gICAgICAgICAgICAgICAgc3RyaW5nQ29tcGFyZU51bGxFcXVhbHNFbXB0eShudW1iZXIsIGFkbi5udW1iZXIpICYmCi0gICAgICAgICAgICAgICAgQXJyYXlzLmVxdWFscyhlbWFpbHMsIGFkbi5lbWFpbHMpKTsKKyAgICAgICAgcmV0dXJuICggc3RyaW5nQ29tcGFyZU51bGxFcXVhbHNFbXB0eShtQWxwaGFUYWcsIGFkbi5tQWxwaGFUYWcpICYmCisgICAgICAgICAgICAgICAgc3RyaW5nQ29tcGFyZU51bGxFcXVhbHNFbXB0eShtTnVtYmVyLCBhZG4ubU51bWJlcikgJiYKKyAgICAgICAgICAgICAgICBBcnJheXMuZXF1YWxzKG1FbWFpbHMsIGFkbi5tRW1haWxzKSk7CiAgICAgfQogICAgIC8vKioqKiogUGFyY2VsYWJsZSBJbXBsZW1lbnRhdGlvbgogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIGludCBkZXNjcmliZUNvbnRlbnRzKCkgewogICAgICAgICByZXR1cm4gMDsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCB3cml0ZVRvUGFyY2VsKFBhcmNlbCBkZXN0LCBpbnQgZmxhZ3MpIHsKLSAgICAgICAgZGVzdC53cml0ZUludChlZmlkKTsKLSAgICAgICAgZGVzdC53cml0ZUludChyZWNvcmROdW1iZXIpOwotICAgICAgICBkZXN0LndyaXRlU3RyaW5nKGFscGhhVGFnKTsKLSAgICAgICAgZGVzdC53cml0ZVN0cmluZyhudW1iZXIpOwotICAgICAgICBkZXN0LndyaXRlU3RyaW5nQXJyYXkoZW1haWxzKTsKKyAgICAgICAgZGVzdC53cml0ZUludChtRWZpZCk7CisgICAgICAgIGRlc3Qud3JpdGVJbnQobVJlY29yZE51bWJlcik7CisgICAgICAgIGRlc3Qud3JpdGVTdHJpbmcobUFscGhhVGFnKTsKKyAgICAgICAgZGVzdC53cml0ZVN0cmluZyhtTnVtYmVyKTsKKyAgICAgICAgZGVzdC53cml0ZVN0cmluZ0FycmF5KG1FbWFpbHMpOwogICAgIH0KIAogICAgIC8qKgpAQCAtMjEzLDIwICsyMTgsMjAgQEAKICAgICAgICAgICAgIGFkblN0cmluZ1tpXSA9IChieXRlKSAweEZGOwogICAgICAgICB9CiAKLSAgICAgICAgaWYgKFRleHRVdGlscy5pc0VtcHR5KG51bWJlcikpIHsKKyAgICAgICAgaWYgKFRleHRVdGlscy5pc0VtcHR5KG1OdW1iZXIpKSB7CiAgICAgICAgICAgICBSbG9nLncoTE9HX1RBRywgIltidWlsZEFkblN0cmluZ10gRW1wdHkgZGlhbGluZyBudW1iZXIiKTsKICAgICAgICAgICAgIHJldHVybiBhZG5TdHJpbmc7ICAgLy8gcmV0dXJuIHRoZSBlbXB0eSByZWNvcmQgKGZvciBkZWxldGUpCi0gICAgICAgIH0gZWxzZSBpZiAobnVtYmVyLmxlbmd0aCgpCisgICAgICAgIH0gZWxzZSBpZiAobU51bWJlci5sZW5ndGgoKQogICAgICAgICAgICAgICAgID4gKEFETl9ESUFMSU5HX05VTUJFUl9FTkQgLSBBRE5fRElBTElOR19OVU1CRVJfU1RBUlQgKyAxKSAqIDIpIHsKICAgICAgICAgICAgIFJsb2cudyhMT0dfVEFHLAogICAgICAgICAgICAgICAgICAgICAiW2J1aWxkQWRuU3RyaW5nXSBNYXggbGVuZ3RoIG9mIGRpYWxpbmcgbnVtYmVyIGlzIDIwIik7CiAgICAgICAgICAgICByZXR1cm4gbnVsbDsKLSAgICAgICAgfSBlbHNlIGlmIChhbHBoYVRhZyAhPSBudWxsICYmIGFscGhhVGFnLmxlbmd0aCgpID4gZm9vdGVyT2Zmc2V0KSB7CisgICAgICAgIH0gZWxzZSBpZiAobUFscGhhVGFnICE9IG51bGwgJiYgbUFscGhhVGFnLmxlbmd0aCgpID4gZm9vdGVyT2Zmc2V0KSB7CiAgICAgICAgICAgICBSbG9nLncoTE9HX1RBRywKICAgICAgICAgICAgICAgICAgICAgIltidWlsZEFkblN0cmluZ10gTWF4IGxlbmd0aCBvZiB0YWcgaXMgIiArIGZvb3Rlck9mZnNldCk7CiAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgIGJjZE51bWJlciA9IFBob25lTnVtYmVyVXRpbHMubnVtYmVyVG9DYWxsZWRQYXJ0eUJDRChudW1iZXIpOworICAgICAgICAgICAgYmNkTnVtYmVyID0gUGhvbmVOdW1iZXJVdGlscy5udW1iZXJUb0NhbGxlZFBhcnR5QkNEKG1OdW1iZXIpOwogCiAgICAgICAgICAgICBTeXN0ZW0uYXJyYXljb3B5KGJjZE51bWJlciwgMCwgYWRuU3RyaW5nLAogICAgICAgICAgICAgICAgICAgICBmb290ZXJPZmZzZXQgKyBBRE5fVE9OX0FORF9OUEksIGJjZE51bWJlci5sZW5ndGgpOwpAQCAtMjM4LDggKzI0Myw4IEBACiAgICAgICAgICAgICBhZG5TdHJpbmdbZm9vdGVyT2Zmc2V0ICsgQUROX0VYVEVOU0lPTl9JRF0KICAgICAgICAgICAgICAgICAgICAgPSAoYnl0ZSkgMHhGRjsgLy8gRXh0ZW5zaW9uIFJlY29yZCBJZAogCi0gICAgICAgICAgICBpZiAoIVRleHRVdGlscy5pc0VtcHR5KGFscGhhVGFnKSkgewotICAgICAgICAgICAgICAgIGJ5dGVUYWcgPSBHc21BbHBoYWJldC5zdHJpbmdUb0dzbThCaXRQYWNrZWQoYWxwaGFUYWcpOworICAgICAgICAgICAgaWYgKCFUZXh0VXRpbHMuaXNFbXB0eShtQWxwaGFUYWcpKSB7CisgICAgICAgICAgICAgICAgYnl0ZVRhZyA9IEdzbUFscGhhYmV0LnN0cmluZ1RvR3NtOEJpdFBhY2tlZChtQWxwaGFUYWcpOwogICAgICAgICAgICAgICAgIFN5c3RlbS5hcnJheWNvcHkoYnl0ZVRhZywgMCwgYWRuU3RyaW5nLCAwLCBieXRlVGFnLmxlbmd0aCk7CiAgICAgICAgICAgICB9CiAKQEAgLTI2Nyw3ICsyNzIsNyBAQAogICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgbnVtYmVyICs9IFBob25lTnVtYmVyVXRpbHMuY2FsbGVkUGFydHlCQ0RGcmFnbWVudFRvU3RyaW5nKAorICAgICAgICAgICAgbU51bWJlciArPSBQaG9uZU51bWJlclV0aWxzLmNhbGxlZFBhcnR5QkNERnJhZ21lbnRUb1N0cmluZygKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBleHRSZWNvcmQsIDIsIDB4ZmYgJiBleHRSZWNvcmRbMV0pOwogCiAgICAgICAgICAgICAvLyBXZSBkb24ndCBzdXBwb3J0IGV4dCByZWNvcmQgY2hhaW5pbmcuCkBAIC0yODUsNyArMjkwLDcgQEAKICAgICBwcml2YXRlIHZvaWQKICAgICBwYXJzZVJlY29yZChieXRlW10gcmVjb3JkKSB7CiAgICAgICAgIHRyeSB7Ci0gICAgICAgICAgICBhbHBoYVRhZyA9IEljY1V0aWxzLmFkblN0cmluZ0ZpZWxkVG9TdHJpbmcoCisgICAgICAgICAgICBtQWxwaGFUYWcgPSBJY2NVdGlscy5hZG5TdHJpbmdGaWVsZFRvU3RyaW5nKAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY29yZCwgMCwgcmVjb3JkLmxlbmd0aCAtIEZPT1RFUl9TSVpFX0JZVEVTKTsKIAogICAgICAgICAgICAgaW50IGZvb3Rlck9mZnNldCA9IHJlY29yZC5sZW5ndGggLSBGT09URVJfU0laRV9CWVRFUzsKQEAgLTI5NCw3ICsyOTksNyBAQAogCiAgICAgICAgICAgICBpZiAobnVtYmVyTGVuZ3RoID4gTUFYX05VTUJFUl9TSVpFX0JZVEVTKSB7CiAgICAgICAgICAgICAgICAgLy8gSW52YWxpZCBudW1iZXIgbGVuZ3RoCi0gICAgICAgICAgICAgICAgbnVtYmVyID0gIiI7CisgICAgICAgICAgICAgICAgbU51bWJlciA9ICIiOwogICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgIH0KIApAQCAtMzA1LDE5ICszMTAsMTkgQEAKICAgICAgICAgICAgIC8vIGEgc2VydmljZSwgdGhlIFRPTi9OUEkgYnl0ZSBzaGFsbCBiZSBzZXQgdG8gJ0ZGJyBieQogICAgICAgICAgICAgLy8gdGhlIE1FIChzZWUgbm90ZSAyKS4iCiAKLSAgICAgICAgICAgIG51bWJlciA9IFBob25lTnVtYmVyVXRpbHMuY2FsbGVkUGFydHlCQ0RUb1N0cmluZygKKyAgICAgICAgICAgIG1OdW1iZXIgPSBQaG9uZU51bWJlclV0aWxzLmNhbGxlZFBhcnR5QkNEVG9TdHJpbmcoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjb3JkLCBmb290ZXJPZmZzZXQgKyAxLCBudW1iZXJMZW5ndGgpOwogCiAKLSAgICAgICAgICAgIGV4dFJlY29yZCA9IDB4ZmYgJiByZWNvcmRbcmVjb3JkLmxlbmd0aCAtIDFdOworICAgICAgICAgICAgbUV4dFJlY29yZCA9IDB4ZmYgJiByZWNvcmRbcmVjb3JkLmxlbmd0aCAtIDFdOwogCi0gICAgICAgICAgICBlbWFpbHMgPSBudWxsOworICAgICAgICAgICAgbUVtYWlscyA9IG51bGw7CiAKICAgICAgICAgfSBjYXRjaCAoUnVudGltZUV4Y2VwdGlvbiBleCkgewogICAgICAgICAgICAgUmxvZy53KExPR19UQUcsICJFcnJvciBwYXJzaW5nIEFkblJlY29yZCIsIGV4KTsKLSAgICAgICAgICAgIG51bWJlciA9ICIiOwotICAgICAgICAgICAgYWxwaGFUYW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DYWNlIHJlc2V0Iik7CisgICAgICAgICAgICBzZW5kRXJyb3JSZXNwb25zZShtVXNlcldyaXRlUmVzcG9uc2UudmFsdWVBdChpKSwgIkFkbkNhY2UgcmVzZXQiKTsKICAgICAgICAgfQotICAgICAgICB1c2VyV3JpdGVSZXNwb25zZS5jbGVhcigpOworICAgICAgICBtVXNlcldyaXRlUmVzcG9uc2UuY2xlYXIoKTsKICAgICB9CiAKICAgICAvKioKQEAgLTk5LDcgKzk4LDcgQEAKICAgICAgKi8KICAgICBwdWJsaWMgQXJyYXlMaXN0PEFkblJlY29yZD4KICAgICBnZXRSZWNvcmRzSWZMb2FkZWQoaW50IGVmaWQpIHsKLSAgICAgICAgcmV0dXJuIGFkbkxpa2VGaWxlcy5nZXQoZWZpZCk7CisgICAgICAgIHJldHVybiBtQWRuTGlrZUZpbGVzLmdldChlZmlkKTsKICAgICB9CiAKICAgICAvKioKQEAgLTE0NywxMyArMTQ2LDEzIEBACiAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgIH0KIAotICAgICAgICBNZXNzYWdlIHBlbmRpbmdSZXNwb25zZSA9IHVzZXJXcml0ZVJlc3BvbnNlLmdldChlZmlkKTsKKyAgICAgICAgTWVzc2FnZSBwZW5kaW5nUmVzcG9uc2UgPSBtVXNlcldyaXRlUmVzcG9uc2UuZ2V0KGVmaWQpOwogICAgICAgICBpZiAocGVuZGluZ1Jlc3BvbnNlICE9IG51bGwpIHsKICAgICAgICAgICAgIHNlbmRFcnJvclJlc3BvbnNlKHJlc3BvbnNlLCAiSGF2ZSBwZW5kaW5nIHVwZGF0ZSBmb3IgRUY6IiArIGVmaWQpOwogICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICB9CiAKLSAgICAgICAgdXNlcldyaXRlUmVzcG9uc2UucHV0KGVmaWQsIHJlc3BvbnNlKTsKKyAgICAgICAgbVVzZXJXcml0ZVJlc3BvbnNlLnB1dChlZmlkLCByZXNwb25zZSk7CiAKICAgICAgICAgbmV3IEFkblJ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kVmIDwgMCkgewpAQCAtMzE5LDYgKzMxOCw3IEBACiAKICAgICAvLyoqKioqIE92ZXJyaWRkZW4gZnJvbSBIYW5kbGVyCiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZAogICAgIGhhbmRsZU1lc3NhZ2UoTWVzc2FnZSBtc2cpIHsKICAgICAgICAgQXN5bmNSZXN1bHQgYXI7CkBAIC0zMzEsMTEgKzMzMSwxMSBAQAogICAgICAgICAgICAgICAgIGVmaWQgPSBtc2cuYXJnMTsKICAgICAgICAgICAgICAgICBBcnJheUxpc3Q8TWVzc2FnZT4gd2FpdGVyczsKIAotICAgICAgICAgICAgICAgIHdhaXRlcnMgPSBhZG5MaWtlV2FpdGVycy5nZXQoZWZpZCk7Ci0gICAgICAgICAgICAgICAgYWRuTGlrZVdhaXRlcnMuZGVsZXRlKGVmaWQpOworICAgICAgICAgICAgICAgIHdhaXRlcnMgPSBtQWRuTGlrZVdhaXRlcnMuZ2V0KGVmaWQpOworICAgICAgICAgICAgICAgIG1BZG5MaWtlV2FpdGVycy5kZWxldGUoZWZpZCk7CiAKICAgICAgICAgICAgICAgICBpZiAoYXIuZXhjZXB0aW9uID09IG51bGwpIHsKLSAgICAgICAgICAgICAgICAgICAgYWRuTGlrZUZpbGVzLnB1dChlZmlkLCAoQXJyYXlMaXN0PEFkblJlY29yZD4pIGFyLnJlc3VsdCk7CisgICAgICAgICAgICAgICAgICAgIG1BZG5MaWtlRmlsZXMucHV0KGVmaWQsIChBcnJheUxpc3Q8QWRuUmVjb3JkPikgYXIucmVzdWx0KTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgbm90aWZ5V2FpdGVycyh3YWl0ZXJzLCBhcik7CiAgICAgICAgICAgICAgICAgYnJlYWs7CkBAIC0zNDYsMTIgKzM0NiwxMiBAQAogICAgICAgICAgICAgICAgIEFkblJlY29yZCBhZG4gPSAoQWRuUmVjb3JkKSAoYXIudXNlck9iaik7CiAKICAgICAgICAgICAgICAgICBpZiAoYXIuZXhjZXB0aW9uID09IG51bGwpIHsKLSAgICAgICAgICAgICAgICAgICAgYWRuTGlrZUZpbGVzLmdldChlZmlkKS5zZXQoaW5kZXggLSAxLCBhZG4pOworICAgICAgICAgICAgICAgICAgICBtQWRuTGlrZUZpbGVzLmdldChlZmlkKS5zZXQoaW5kZXggLSAxLCBhZG4pOwogICAgICAgICAgICAgICAgICAgICBtVXNpbVBob25lQm9va01hbmFnZXIuaW52YWxpZGF0ZUNhY2hlKCk7CiAgICAgICAgICAgICAgICAgfQogCi0gICAgICAgICAgICAgICAgTWVzc2FnZSByZXNwb25zZSA9IHVzZXJXcml0ZVJlc3BvbnNlLmdldChlZmlkKTsKLSAgICAgICAgICAgICAgICB1c2VyV3JpdGVSZXNwb25zZS5kZWxldGUoZWZpZCk7CisgICAgICAgICAgICAgICAgTWVzc2FnZSByZXNwb25zZSA9IG1Vc2VyV3JpdGVSZXNwb25zZS5nZXQoZWZpZCk7CisgICAgICAgICAgICAgICAgbVVzZXJXcml0ZVJlc3BvbnNlLmRlbGV0ZShlZmlkKTsKIAogICAgICAgICAgICAgICAgIEFzeW5jUmVzdWx0LmZvck1lc3NhZ2UocmVzcG9uc2UsIG51bGwsIGFyLmV4Y2VwdGlvbik7CiAgICAgICAgICAgICAgICAgcmVzcG9uc2Uuc2VuZFRvVGFyZ2V0KCk7CmRpZmYgLS1naXQgYS9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvdWljYy9BZG5SZWNvcmRMb2FkZXIuamF2YSBiL3NyYy9qYXZhL2NvbS9hbmRyb2lkL2ludGVybmFsL3RlbGVwaG9ueS91aWNjL0FkblJlY29yZExvYWRlci5qYXZhCmluZGV4IDRkZTY5ZDEuLjhkZjgyMTYgMTAwNjQ0Ci0tLSBhL3NyYy9qYXZhL2NvbS9hbmRyb2lkL2ludGVybmFsL3RlbGVwaG9ueS91aWNjL0FkblJlY29yZExvYWRlci5qYXZhCis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NyBAQAogCiAgICAgLy8qKioqKiBPdmVycmlkZGVuIGZyb20gSGFuZGxlcgogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQKICAgICBoYW5kbGVNZXNzYWdlKE1lc3NhZ2UgbXNnKSB7CiAgICAgICAgIEFzeW5jUmVzdWx0IGFyOwpAQCAtMTQ5LDcgKzE1MSw3IEBACiAgICAgICAgICAgICAgICAgICAgIC8vIGludFsxXSAgaXMgdGhlIHRvdGFsIGxlbmd0aCBvZiB0aGUgRUYgZmlsZQogICAgICAgICAgICAgICAgICAgICAvLyBpbnRbMl0gIGlzIHRoZSBudW1iZXIgb2YgcmVjb3JkcyBpbiB0aGUgRUYgZmlsZQogICAgICAgICAgICAgICAgICAgICAvLyBTbyBpbnRbMF0gKiBpbnRbMl0gPSBpbnRbMV0KLSAgICAgICAgICAgICAgICAgICBpZiAocmVjb3JkU2l6ZS5sZW5ndGggIT0gMyB8fCByZWNvcmROdW1iZXIgPiByZWNvcmRTaXplWzJdKSB7CisgICAgICAgICAgICAgICAgICAgaWYgKHJlY29yZFNpemUubGVuZ3RoICE9IDMgfHwgbVJlY29yZE51bWJlciA+IHJlY29yZFNpemVbMl0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBSdW50aW1lRXhjZXB0aW9uKCJnZXQgd3JvbmcgRUYgcmVjb3JkIHNpemUgZm9ybWF0IiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXIuZXhjZXB0aW9uKTsKICAgICAgICAgICAgICAgICAgICAgfQpAQCAtMTYxLDEwICsxNjMsMTAgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXIuZXhjZXB0aW9uKTsKICAgICAgICAgICAgICAgICAgICAgfQogCi0gICAgICAgICAgICAgICAgICAgIG1GaC51cGRhdGVFRkxpbmVhckZpeGVkKGVmLCByZWNvcmROdW1iZXIsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSwgcGluMiwgb2J0YWluTWVzc2FnZShFVkVOVF9VUERBVEVfUkVDT1JEX0RPTkUpKTsKKyAgICAgICAgICAgICAgICAgICAgbUZoLnVwZGF0ZUVGTGluZWFyRml4ZWQobUVmLCBtUmVjb3JkTnVtYmVyLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEsIG1QaW4yLCBvYnRhaW5NZXNzYWdlKEVWRU5UX1VQREFURV9SRUNPUkRfRE9ORSkpOwogCi0gICAgICAgICAgICAgICAgICAgIHBlbmRpbmdFeHRMb2FkcyA9IDE7CisgICAgICAgICAgICAgICAgICAgIG1QZW5kaW5nRXh0TG9hZHMgPSAxOwogCiAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgIGNhc2UgRVZFTlRfVVBEQVRFX1JFQ09SRF9ET05FOgpAQCAtMTczLDggKzE3NSw4IEBACiAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgUnVudGltZUV4Y2VwdGlvbigidXBkYXRlIEVGIGFkbiByZWNvcmQgZmFpbGVkIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXIuZXhjZXB0aW9uKTsKICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBwZW5kaW5nRXh0TG9hZHMgPSAwOwotICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSBudWxsOworICAgICAgICAgICAgICAgICAgICBtUGVuZGluZ0V4dExvYWRzID0gMDsKKyAgICAgICAgICAgICAgICAgICAgbVJlc3VsdCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgIGNhc2UgRVZFTlRfQUROX0xPQURfRE9ORToKICAgICAgICAgICAgICAgICAgICAgYXIgPSAoQXN5bmNSZXN1bHQpKG1zZy5vYmopOwpAQCAtMTg0LDI1ICsxODYsMjUgQEAKICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBSdW50aW1lRXhjZXB0aW9uKCJsb2FkIGZhaWxlZCIsIGFyLmV4Y2VwdGlvbik7CiAgICAgICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgICAgICAgICBpZiAoZmFsc2UpIHsKKyAgICAgICAgICAgICAgICAgICAgaWYgKFZEQkcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIFJsb2cuZChMT0dfVEFHLCJBRE4gRUY6IDB4IgotICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgSW50ZWdlci50b0hleFN0cmluZyhlZikKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICArICI6IiArIHJlY29yZE51bWJlcgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgSW50ZWdlci50b0hleFN0cmluZyhtRWYpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyAiOiIgKyBtUmVjb3JkTnVtYmVyCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyAiXG4iICsgSWNjVXRpbHMuYnl0ZXNUb0hleFN0cmluZyhkYXRhKSk7CiAgICAgICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgICAgICAgICBhZG4gPSBuZXcgQWRuUmVjb3JkKGVmLCByZWNvcmROdW1iZXIsIGRhdGEpOwotICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSBhZG47CisgICAgICAgICAgICAgICAgICAgIGFkbiA9IG5ldyBBZG5SZWNvcmQobUVmLCBtUmVjb3JkTnVtYmVyLCBkYXRhKTsKKyAgICAgICAgICAgICAgICAgICAgbVJlc3VsdCA9IGFkbjsKIAogICAgICAgICAgICAgICAgICAgICBpZiAoYWRuLmhhc0V4dGVuZGVkUmVjb3JkKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIC8vIElmIHdlIGhhdmUgYSB2YWxpZCB2YWx1ZSBpbiB0aGUgZXh0IHJlY29yZCBmaWVsZCwKICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHdlJ3JlIG5vdCBkb25lIHlldDogd2UgbmVlZCB0byByZWFkIHRoZSBjb3JyZXNwb25kaW5nCiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBleHQgcmVjb3JkIGFuZCBhcHBlbmQgaXQKIAotICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ0V4dExvYWRzID0gMTsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1QZW5kaW5nRXh0TG9hZHMgPSAxOwogCiAgICAgICAgICAgICAgICAgICAgICAgICBtRmgubG9hZEVGTGluZWFyRml4ZWQoCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgZXh0ZW5zaW9uRUYsIGFkbi5leHRSZWNvcmQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUV4dGVuc2lvbkVGLCBhZG4ubUV4dFJlY29yZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX0VYVF9SRUNPUkRfTE9BRF9ET05FLCBhZG4pKTsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIGJyZWFrOwpAQCAtMjE3LDEzICsyMTksMTMgQEAKICAgICAgICAgICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAgICAgICAgIFJsb2cuZChMT0dfVEFHLCJBRE4gZXh0ZW5zaW9uIEVGOiAweCIKLSAgICAgICAgICAgICAgICAgICAgICAgICsgSW50ZWdlci50b0hleFN0cmluZyhleHRlbnNpb25FRikKLSAgICAgICAgICAgICAgICAgICAgICAgICsgIjoiICsgYWRuLmV4dFJlY29yZAorICAgICAgICAgICAgICAgICAgICAgICAgKyBJbnRlZ2VyLnRvSGV4U3RyaW5nKG1FeHRlbnNpb25FRikKKyAgICAgICAgICAgICAgICAgICAgICAgICsgIjoiICsgYWRuLm1FeHRSZWNvcmQKICAgICAgICAgICAgICAgICAgICAgICAgICsgIlxuIiArIEljY1V0aWxzLmJ5dGVzVG9IZXhTdHJpbmcoZGF0YSkpOwogCiAgICAgICAgICAgICAgICAgICAgIGFkbi5hcHBlbmRFeHRSZWNvcmQoZGF0YSk7CiAKLSAgICAgICAgICAgICAgICAgICAgcGVuZGluZ0V4dExvYWRzLS07CisgICAgICAgICAgICAgICAgICAgIG1QZW5kaW5nRXh0TG9hZHMtLTsKICAgICAgICAgICAgICAgICAgICAgLy8gcmVzdWx0IHNob3VsZCBoYXZlIGJlZW4gc2V0IGluCiAgICAgICAgICAgICAgICAgICAgIC8vIEVWRU5UX0FETl9MT0FEX0RPTkUgb3IgRVZFTlRfQUROX0xPQURfQUxMX0RPTkUKICAgICAgICAgICAgICAgICBicmVhazsKQEAgLTIzNiw0NiArMjM4LDQ2IEBACiAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgUnVudGltZUV4Y2VwdGlvbigibG9hZCBmYWlsZWQiLCBhci5leGNlcHRpb24pOwogICAgICAgICAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgICAgICAgICAgYWRucyA9IG5ldyBBcnJheUxpc3Q8QWRuUmVjb3JkPihkYXRhcy5zaXplKCkpOwotICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSBhZG5zOwotICAgICAgICAgICAgICAgICAgICBwZW5kaW5nRXh0TG9hZHMgPSAwOworICAgICAgICAgICAgICAgICAgICBtQWRucyA9IG5ldyBBcnJheUxpc3Q8QWRuUmVjb3JkPihkYXRhcy5zaXplKCkpOworICAgICAgICAgICAgICAgICAgICBtUmVzdWx0ID0gbUFkbnM7CisgICAgICAgICAgICAgICAgICAgIG1QZW5kaW5nRXh0TG9hZHMgPSAwOwogCiAgICAgICAgICAgICAgICAgICAgIGZvcihpbnQgaSA9IDAsIHMgPSBkYXRhcy5zaXplKCkgOyBpIDwgcyA7IGkrKykgewotICAgICAgICAgICAgICAgICAgICAgICAgYWRuID0gbmV3IEFkblJlY29yZChlZiwgMSArIGksIGRhdGFzLmdldChpKSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBhZG5zLmFkZChhZG4pOworICAgICAgICAgICAgICAgICAgICAgICAgYWRuID0gbmV3IEFkblJlY29yZChtRWYsIDEgKyBpLCBkYXRhcy5nZXQoaSkpOworICAgICAgICAgICAgICAgICAgICAgICAgbUFkbnMuYWRkKGFkbik7CiAKICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhZG4uaGFzRXh0ZW5kZWRSZWNvcmQoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIElmIHdlIGhhdmUgYSB2YWxpZCB2YWx1ZSBpbiB0aGUgZXh0IHJlY29yZCBmaWVsZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyB3ZSdyZSBub3QgZG9uZSB5ZXQ6IHdlIG5lZWQgdG8gcmVhZCB0aGUgY29ycmVzcG9uZGluZwogICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGV4dCByZWNvcmQgYW5kIGFwcGVuZCBpdAogCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ0V4dExvYWRzKys7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbVBlbmRpbmdFeHRMb2FkcysrOwogCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUZoLmxvYWRFRkxpbmVhckZpeGVkKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBleHRlbnNpb25FRiwgYWRuLmV4dFJlY29yZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUV4dGVuc2lvbkVGLCBhZG4ubUV4dFJlY29yZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZShFVkVOVF9FWFRfUkVDT1JEX0xPQURfRE9ORSwgYWRuKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIH0KICAgICAgICAgfSBjYXRjaCAoUnVudGltZUV4Y2VwdGlvbiBleGMpIHsKLSAgICAgICAgICAgIGlmICh1c2VyUmVzcG9uc2UgIT0gbnVsbCkgewotICAgICAgICAgICAgICAgIEFzeW5jUmVzdWx0LmZvck1lc3NhZ2UodXNlclJlc3BvbnNlKQorICAgICAgICAgICAgaWYgKG1Vc2VyUmVzcG9uc2UgIT0gbnVsbCkgeworICAgICAgICAgICAgICAgIEFzeW5jUmVzdWx0LmZvck1lc3NhZ2UobVVzZXJSZXNwb25zZSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmV4Y2VwdGlvbiA9IGV4YzsKLSAgICAgICAgICAgICAgICB1c2VyUmVzcG9uc2Uuc2VuZFRvVGFyZ2V0KCk7CisgICAgICAgICAgICAgICAgbVVzZXJSZXNwb25zZS5zZW5kVG9UYXJnZXQoKTsKICAgICAgICAgICAgICAgICAvLyBMb2FkaW5nIGlzIGFsbCBvciBub3RoaW5nLS1laXRoZXIgZXZlcnkgbG9hZCBzdWNjZWVkcwogICAgICAgICAgICAgICAgIC8vIG9yIHdlIGZhaWwgdGhlIHdob2xlIHRoaW5nLgotICAgICAgICAgICAgICAgIHVzZXJSZXNwb25zZSA9IG51bGw7CisgICAgICAgICAgICAgICAgbVVzZXJSZXNwb25zZSA9IG51bGw7CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgIH0KIAotICAgICAgICBpZiAodXNlclJlc3BvbnNlICE9IG51bGwgJiYgcGVuZGluZ0V4dExvYWRzID09IDApIHsKLSAgICAgICAgICAgIEFzeW5jUmVzdWx0LmZvck1lc3NhZ2UodXNlclJlc3BvbnNlKS5yZXN1bHQKLSAgICAgICAgICAgICAgICA9IHJlc3VsdDsKKyAgICAgICAgaWYgKG1Vc2VyUmVzcG9uc2UgIT0gbnVsbCAmJiBtUGVuZGluZ0V4dExvYWRzID09IDApIHsKKyAgICAgICAgICAgIEFzeW5jUmVzdWx0LmZvck1lc3NhZ2UobVVzZXJSZXNwb25zZSkucmVzdWx0CisgICAgICAgICAgICAgICAgPSBtUmVzdWx0OwogCi0gICAgICAgICAgICB1c2VyUmVzcG9uc2Uuc2VuZFRvVGFyZ2V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dCwKICAgICAgICAgICAgICAgICBjaSwgdGhpcywgRVZFTlRfQ0RNQV9TVUJTQ1JJUFRJT05fU09VUkNFX0NIQU5HRUQsIG51bGwpOwogICAgICAgICBtVWljY0NvbnRyb2xsZXIgPSBVaWNjQ29udHJvbGxlci5nZXRJbnN0YW5jZSgpOwpAQCAtMTk4LDYgKzE5OCw3IEBACiAgICAgICAgIH0KICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBoYW5kbGVNZXNzYWdlKE1lc3NhZ2UgbXNnKSB7CiAgICAgICAgIHN3aXRjaCAobXNnLndoYXQpIHsKICAgICAgICAgICAgIGNhc2UgRVZFTlRfUkFESU9fT0ZGX09SX1VOQVZBSUxBQkxFOgpAQCAtMzc0LDYgKzM3NSwxMiBAQAogICAgICAgICAgICAgICAgIGNhc2UgQVBQU1RBVEVfUFVLOgogICAgICAgICAgICAgICAgICAgICBzZXRFeHRlcm5hbFN0YXRlKFN0YXRlLlBVS19SRVFVSVJFRCk7CiAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgQVBQU1RBVEVfREVURUNURUQ6CisgICAgICAgICAgICAgICAgY2FzZSBBUFBTVEFURV9SRUFEWToKKyAgICAgICAgICAgICAgICBjYXNlIEFQUFNUQVRFX1NVQlNDUklQVElPTl9QRVJTTzoKKyAgICAgICAgICAgICAgICBjYXNlIEFQUFNUQVRFX1VOS05PV046CisgICAgICAgICAgICAgICAgICAgIC8vIE5laXRoZXIgcmVxdWlyZWQKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICB9CmRpZmYgLS1naXQgYS9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvdWljYy9JY2NDYXJkU3RhdHVzLmphdmEgYi9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvdWljY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zYWdlIG9uTG9hZGVkKSB7Ci0gICAgICAgICAgICB0aGlzLmVmaWQgPSBlZmlkOwotICAgICAgICAgICAgdGhpcy5yZWNvcmROdW0gPSAxOwotICAgICAgICAgICAgdGhpcy5sb2FkQWxsID0gdHJ1ZTsKLSAgICAgICAgICAgIHRoaXMub25Mb2FkZWQgPSBvbkxvYWRlZDsKKyAgICAgICAgICAgIG1FZmlkID0gZWZpZDsKKyAgICAgICAgICAgIG1SZWNvcmROdW0gPSAxOworICAgICAgICAgICAgbUxvYWRBbGwgPSB0cnVlOworICAgICAgICAgICAgbU9uTG9hZGVkID0gb25Mb2FkZWQ7CiAgICAgICAgIH0KICAgICB9CiAKQEAgLTMyMCw2ICszMTgsNyBAQAogCiAgICAgLy8qKioqKiBPdmVycmlkZGVuIGZyb20gSGFuZGxlcgogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgaGFuZGxlTWVzc2FnZShNZXNzYWdlIG1zZykgewogICAgICAgICBBc3luY1Jlc3VsdCBhcjsKICAgICAgICAgSWNjSW9SZXN1bHQgcmVzdWx0OwpAQCAtMzQxLDcgKzM0MCw3IEBACiAgICAgICAgICAgICAgICAgYXIgPSAoQXN5bmNSZXN1bHQpIG1zZy5vYmo7CiAgICAgICAgICAgICAgICAgbGMgPSAoTG9hZExpbmVhckZpeGVkQ29udGV4dCkgYXIudXNlck9iajsKICAgICAgICAgICAgICAgICByZXN1bHQgPSAoSWNjSW9SZXN1bHQpIGFyLnJlc3VsdDsKLSAgICAgICAgICAgICAgICByZXNwb25zZSA9IGxjLm9uTG9hZGVkOworICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gbGMubU9uTG9hZGVkOwogCiAgICAgICAgICAgICAgICAgaWYgKGFyLmV4Y2VwdGlvbiAhPSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgIHNlbmRSZXN1bHQocmVzcG9uc2UsIG51bGwsIGFyLmV4Y2VwdGlvbik7CkBAIC0zNTYsNyArMzU1LDcgQEAKICAgICAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgICAgICBkYXRhID0gcmVzdWx0LnBheWxvYWQ7Ci0gICAgICAgICAgICAgICAgbGMucmVjb3JkU2l6ZSA9IGRhdGFbUkVTUE9OU0VfREFUQV9SRUNPUkRfTEVOR1RIXSAmIDB4RkY7CisgICAgICAgICAgICAgICAgbGMubVJlY29yZFNpemUgPSBkYXRhW1JFU1BPTlNFX0RBVEFfUkVDT1JEX0xFTkdUSF0gJiAweEZGOwogCiAgICAgICAgICAgICAgICAgaWYgKChUWVBFX0VGICE9IGRhdGFbUkVTUE9OU0VfREFUQV9GSUxFX1RZUEVdKSB8fAogICAgICAgICAgICAgICAgICAgICAoRUZfVFlQRV9MSU5FQVJfRklYRUQgIT0gZGF0YVtSRVNQT05TRV9EQVRBX1NUUlVDVFVSRV0pKSB7CkBAIC0zNjUsMTAgKzM2NCwxMCBAQAogICAgICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgICAgIGxvZ2QoIkljY0ZpbGVIYW5kbGVyOiByZWFkIEVGIElNRyIpOwotICAgICAgICAgICAgICAgIG1DaS5pY2NJT0ZvckFwcChDT01NQU5EX1JFQURfUkVDT1JELCBsYy5lZmlkLCBnZXRFRlBhdGgobGMuZWZpZCksCi0gICAgICAgICAgICAgICAgICAgICAgICBsYy5yZWNvcmROdW0sCisgICAgICAgICAgICAgICAgbUNpLmljY0lPRm9yQXBwKENPTU1BTkRfUkVBRF9SRUNPUkQsIGxjLm1FZmlkLCBnZXRFRlBhdGgobGMubUVmaWQpLAorICAgICAgICAgICAgICAgICAgICAgICAgbGMubVJlY29yZE51bSwKICAgICAgICAgICAgICAgICAgICAgICAgIFJFQURfUkVDT1JEX01PREVfQUJTT0xVVEUsCi0gICAgICAgICAgICAgICAgICAgICAgICBsYy5yZWNvcmRTaXplLCBudWxsLCBudWxsLCBtQWlkLAorICAgICAgICAgICAgICAgICAgICAgICAgbGMubVJlY29yZFNpemUsIG51bGwsIG51bGwsIG1BaWQsCiAgICAgICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlKEVWRU5UX1JFQURfSU1HX0RPTkUsIEljY0NvbnN0YW50cy5FRl9JTUcsIDAsIHJlc3BvbnNlKSk7CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAKQEAgLTM3Niw3ICszNzUsNyBAQAogICAgICAgICAgICAgICAgIGFyID0gKEFzeW5jUmVzdWx0KSBtc2cub2JqOwogICAgICAgICAgICAgICAgIGxjID0gKExvYWRMaW5lYXJGaXhlZENvbnRleHQpIGFyLnVzZXJPYmo7CiAgICAgICAgICAgICAgICAgcmVzdWx0ID0gKEljY0lvUmVzdWx0KSBhci5yZXN1bHQ7Ci0gICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBsYy5vbkxvYWRlZDsKKyAgICAgICAgICAgICAgICByZXNwb25zZSA9IGxjLm1PbkxvYWRlZDsKIAogICAgICAgICAgICAgICAgIGljY0V4Y2VwdGlvbiA9IHJlc3VsdC5nZXRFeGNlcHRpb24oKTsKICAgICAgICAgICAgICAgICBpZiAoaWNjRXhjZXB0aW9uICE9IG51bGwpIHsKQEAgLTM5Nyw3ICszOTYsNyBAQAogICAgICAgICAgICAgICAgIGFyID0gKEFzeW5jUmVzdWx0KW1zZy5vYmo7CiAgICAgICAgICAgICAgICAgbGMgPSAoTG9hZExpbmVhckZpeGVkQ29udGV4dCkgYXIudXNlck9iajsKICAgICAgICAgICAgICAgICByZXN1bHQgPSAoSWNjSW9SZXN1bHQpIGFyLnJlc3VsdDsKLSAgICAgICAgICAgICAgICByZXNwb25zZSA9IGxjLm9uTG9hZGVkOworICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gbGMubU9uTG9hZGVkOwogCiAgICAgICAgICAgICAgICAgaWYgKGFyLmV4Y2VwdGlvbiAhPSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgIHNlbmRSZXN1bHQocmVzcG9uc2UsIG51bGwsIGFyLmV4Y2VwdGlvbik7CkBAIC00MjksNyArNDI4LDcgQEAKICAgICAgICAgICAgICAgICBhciA9IChBc3luY1Jlc3VsdCltc2cub2JqOwogICAgICAgICAgICAgICAgIGxjID0gKExvYWRMaW5lYXJGaXhlZENvbnRleHQpIGFyLnVzZXJPYmo7CiAgICAgICAgICAgICAgICAgcmVzdWx0ID0gKEljY0lvUmVzdWx0KSBhci5yZXN1bHQ7Ci0gICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBsYy5vbkxvYWRlZDsKKyAgICAgICAgICAgICAgICByZXNwb25zZSA9IGxjLm1PbkxvYWRlZDsKIAogICAgICAgICAgICAgICAgIGlmIChhci5leGNlcHRpb24gIT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICBzZW5kUmVzdWx0KHJlc3BvbnNlLCBudWxsLCBhci5leGNlcHRpb24pOwpAQCAtNDQ0LDggKzQ0Myw4IEBACiAgICAgICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAgICAgZGF0YSA9IHJlc3VsdC5wYXlsb2FkOwotICAgICAgICAgICAgICAgIGZpbGVpZCA9IGxjLmVmaWQ7Ci0gICAgICAgICAgICAgICAgcmVjb3JkTnVtID0gbGMucmVjb3JkTnVtOworICAgICAgICAgICAgICAgIGZpbGVpZCA9IGxjLm1FZmlkOworICAgICAgICAgICAgICAgIHJlY29yZE51bSA9IGxjLm1SZWNvcmROdW07CiAKICAgICAgICAgICAgICAgICBpZiAoVFlQRV9FRiAhPSBkYXRhW1JFU1BPTlNFX0RBVEFfRklMRV9UWVBFXSkgewogICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgSWNjRmlsZVR5cGVNaXNtYXRjaCgpOwpAQCAtNDU1LDIxICs0NTQsMjEgQEAKICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEljY0ZpbGVUeXBlTWlzbWF0Y2goKTsKICAgICAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgICAgICBsYy5yZWNvcmRTaXplID0gZGF0YVtSRVNQT05TRV9EQVRBX1JFQ09SRF9MRU5HVEhdICYgMHhGRjsKKyAgICAgICAgICAgICAgICBsYy5tUmVjb3JkU2l6ZSA9IGRhdGFbUkVTUE9OU0VfREFUQV9SRUNPUkRfTEVOR1RIXSAmIDB4RkY7CiAKICAgICAgICAgICAgICAgICBzaXplID0gKChkYXRhW1JFU1BPTlNFX0RBVEFfRklMRV9TSVpFXzFdICYgMHhmZikgPDwgOCkKICAgICAgICAgICAgICAgICAgICAgICAgKyAoZGF0YVtSRVNQT05TRV9EQVRBX0ZJTEVfU0laRV8yXSAmIDB4ZmYpOwogCi0gICAgICAgICAgICAgICAgbGMuY291bnRSZWNvcmRzID0gc2l6ZSAvIGxjLnJlY29yZFNpemU7CisgICAgICAgICAgICAgICAgbGMubUNvdW50UmVjb3JkcyA9IHNpemUgLyBsYy5tUmVjb3JkU2l6ZTsKIAotICAgICAgICAgICAgICAgICBpZiAobGMubG9hZEFsbCkgewotICAgICAgICAgICAgICAgICAgICAgbGMucmVzdWx0cyA9IG5ldyBBcnJheUxpc3Q8Ynl0ZVtdPihsYy5jb3VudFJlY29yZHMpOworICAgICAgICAgICAgICAgICBpZiAobGMubUxvYWRBbGwpIHsKKyAgICAgICAgICAgICAgICAgICAgIGxjLnJlc3VsdHMgPSBuZXcgQXJyYXlMaXN0PGJ5dGVbXT4obGMubUNvdW50UmVjb3Jkcyk7CiAgICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgICAgICBtQ2kuaWNjSU9Gb3JBcHAoQ09NTUFORF9SRUFEX1JFQ09SRCwgbGMuZWZpZCwgZ2V0RUZQYXRoKGxjLmVmaWQpLAotICAgICAgICAgICAgICAgICAgICAgICAgIGxjLnJlY29yZE51bSwKKyAgICAgICAgICAgICAgICAgbUNpLmljY0lPRm9yQXBwKENPTU1BTkRfUkVBRF9SRUNPUkQsIGxjLm1FZmlkLCBnZXRFRlBhdGgobGMubUVmaWQpLAorICAgICAgICAgICAgICAgICAgICAgICAgIGxjLm1SZWNvcmROdW0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgUkVBRF9SRUNPUkRfTU9ERV9BQlNPTFVURSwKLSAgICAgICAgICAgICAgICAgICAgICAgICBsYy5yZWNvcmRTaXplLCBudWxsLCBudWxsLCBtQWlkLAorICAgICAgICAgICAgICAgICAgICAgICAgIGxjLm1SZWNvcmRTaXplLCBudWxsLCBudWxsLCBtQWlkLAogICAgICAgICAgICAgICAgICAgICAgICAgIG9idGFpbk1lc3NhZ2UoRVZFTlRfUkVBRF9SRUNPUkRfRE9ORSwgbGMpKTsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICBjYXNlIEVWRU5UX0dFVF9CSU5BUllfU0laRV9ET05FOgpAQCAtNTE1LDcgKzUxNCw3IEBACiAgICAgICAgICAgICAgICAgYXIgPSAoQXN5bmNSZXN1bHQpbXNnLm9iajsKICAgICAgICAgICAgICAgICBsYyA9IChMb2FkTGluZWFyRml4ZWRDb250ZXh0KSBhci51c2VyT2JqOwogICAgICAgICAgICAgICAgIHJlc3VsdCA9IChJY2NJb1Jlc3VsdCkgYXIucmVzdWx0OwotICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gbGMub25Mb2FkZWQ7CisgICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBsYy5tT25Mb2FkZWQ7CiAKICAgICAgICAgICAgICAgICBpZiAoYXIuZXhjZXB0aW9uICE9IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgc2VuZFJlc3VsdChyZXNwb25zZSwgbnVsbCwgYXIuZXhjZXB0aW9uKTsKQEAgLTUyOSwyMCArNTI4LDIwIEBACiAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgICAgIGlmICghbGMubG9hZEFsbCkgeworICAgICAgICAgICAgICAgIGlmICghbGMubUxvYWRBbGwpIHsKICAgICAgICAgICAgICAgICAgICAgc2VuZFJlc3VsdChyZXNwb25zZSwgcmVzdWx0LnBheWxvYWQsIG51bGwpOwogICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgIGxjLnJlc3VsdHMuYWRkKHJlc3VsdC5wYXlsb2FkKTsKIAotICAgICAgICAgICAgICAgICAgICBsYy5yZWNvcmROdW0rKzsKKyAgICAgICAgICAgICAgICAgICAgbGMubVJlY29yZE51bSsrOwogCi0gICAgICAgICAgICAgICAgICAgIGlmIChsYy5yZWNvcmROdW0gPiBsYy5jb3VudFJlY29yZHMpIHsKKyAgICAgICAgICAgICAgICAgICAgaWYgKGxjLm1SZWNvcmROdW0gPiBsYy5tQ291bnRSZWNvcmRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBzZW5kUmVzdWx0KHJlc3BvbnNlLCBsYy5yZXN1bHRzLCBudWxsKTsKICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIG1DaS5pY2NJT0ZvckFwcChDT01NQU5EX1JFQURfUkVDT1JELCBsYy5lZmlkLCBnZXRFRlBhdGgobGMuZWZpZCksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYy5yZWNvcmROdW0sCisgICAgICAgICAgICAgICAgICAgICAgICBtQ2kuaWNjSU9Gb3JBcHAoQ09NTUFORF9SRUFEX1JFQ09SRCwgbGMubUVmaWQsIGdldEVGUGF0aChsYy5tRWZpZCksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYy5tUmVjb3JkTnVtLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUkVBRF9SRUNPUkRfTU9ERV9BQlNPTFVURSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxjLnJlY29yZFNpemUsIG51bGwsIG51bGwsIG1BaWQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYy5tUmVjb3JkU2l6ZSwgbnVsbCwgbnVsbCwgbUFpZCwKICAgICAgICAgICAgICAgICAgICAgICAgIC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AgICAgICAgKyAiIG1GaD0iICsgbUZoCisgICAgICAgICAgICAgICAgKyAiIG1QYXJlbnRBcHA9IiArIG1QYXJlbnRBcHAKKyAgICAgICAgICAgICAgICArICIgcmVjb3Jkc0xvYWRlZFJlZ2lzdHJhbnRzPSIgKyByZWNvcmRzTG9hZGVkUmVnaXN0cmFudHMKKyAgICAgICAgICAgICAgICArICIgbUltc2lSZWFkeVJlZ2lzdHJhbnRzPSIgKyBtSW1zaVJlYWR5UmVnaXN0cmFudHMKKyAgICAgICAgICAgICAgICArICIgbVJlY29yZHNFdmVudHNSZWdpc3RyYW50cz0iICsgbVJlY29yZHNFdmVudHNSZWdpc3RyYW50cworICAgICAgICAgICAgICAgICsgIiBtTmV3U21zUmVnaXN0cmFudHM9IiArIG1OZXdTbXNSZWdpc3RyYW50cworICAgICAgICAgICAgICAgICsgIiBtTmV0d29ya1NlbGVjdGlvbk1vZGVBdXRvbWF0aWNSZWdpc3RyYW50cz0iCisgICAgICAgICAgICAgICAgICAgICAgICArIG1OZXR3b3JrU2VsZWN0aW9uTW9kZUF1dG9tYXRpY1JlZ2lzdHJhbnRzCisgICAgICAgICAgICAgICAgKyAiIHJlY29yZHNUb0xvYWQ9IiArIG1SZWNvcmRzVG9Mb2FkCisgICAgICAgICAgICAgICAgKyAiIGFkbkNhY2hlPSIgKyBtQWRuQ2FjaGUKKyAgICAgICAgICAgICAgICArICIgcmVjb3Jkc1JlcXVlc3RlZD0iICsgbVJlY29yZHNSZXF1ZXN0ZWQKKyAgICAgICAgICAgICAgICArICIgaWNjaWQ9IiArIGljY0lkCisgICAgICAgICAgICAgICAgKyAiIG1zaXNkbj0iICsgbU1zaXNkbgorICAgICAgICAgICAgICAgICsgIiBtc2lzZG5UYWc9IiArIG1Nc2lzZG5UYWcKKyAgICAgICAgICAgICAgICArICIgdm9pY2VNYWlsTnVtPSIgKyBtVm9pY2VNYWlsTnVtCisgICAgICAgICAgICAgICAgKyAiIHZvaWNlTWFpbFRhZz0iICsgb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3luY1Jlc3VsdChudWxsLCBudWxsLCBudWxsKSk7CiAgICAgICAgIH0KICAgICB9CkBAIC0yMDUsMTIgKzIzNywxMiBAQAogICAgICAqIEBwYXJhbSBpbXNpCiAgICAgICovCiAgICAgcHVibGljIHZvaWQgc2V0SW1zaShTdHJpbmcgaW1zaSkgewotICAgICAgICB0aGlzLm1JbXNpID0gaW1zaTsKKyAgICAgICAgbUltc2kgPSBpbXNpOwogICAgICAgICBtSW1zaVJlYWR5UmVnaXN0cmFudHMubm90aWZ5UmVnaXN0cmFudHMoKTsKICAgICB9CiAKICAgICBwdWJsaWMgU3RyaW5nIGdldE1zaXNkbk51bWJlcigpIHsKLSAgICAgICAgcmV0dXJuIG1zaXNkbjsKKyAgICAgICAgcmV0dXJuIG1Nc2lzZG47CiAgICAgfQogCiAgICAgLyoqCkBAIC0yMzEsMjQgKzI2MywyNCBAQAogICAgIHB1YmxpYyB2b2lkIHNldE1zaXNkbk51bWJlcihTdHJpbmcgYWxwaGFUYWcsIFN0cmluZyBudW1iZXIsCiAgICAgICAgICAgICBNZXNzYWdlIG9uQ29tcGxldGUpIHsKIAotICAgICAgICBtc2lzZG4gPSBudW1iZXI7Ci0gICAgICAgIG1zaXNkblRhZyA9IGFscGhhVGFnOworICAgICAgICBtTXNpc2RuID0gbnVtYmVyOworICAgICAgICBtTXNpc2RuVGFnID0gYWxwaGFUYWc7CiAKLSAgICAgICAgaWYoREJHKSBsb2coIlNldCBNU0lTRE46ICIgKyBtc2lzZG5UYWcgKyIgIiArIG1zaXNkbik7CisgICAgICAgIGlmIChEQkcpIGxvZygiU2V0IE1TSVNETjogIiArIG1Nc2lzZG5UYWcgKyIgIiArIG1Nc2lzZG4pOwogCiAKLSAgICAgICAgQWRuUmVjb3JkIGFkbiA9IG5ldyBBZG5SZWNvcmQobXNpc2RuVGFnLCBtc2lzZG4pOworICAgICAgICBBZG5SZWNvcmQgYWRuID0gbmV3IEFkblJlY29yZChtTXNpc2RuVGFnLCBtTXNpc2R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KKyAgICAgICAgcHcucHJpbnRsbigiIGljY2lkPSIgKyBpY2NJZCk7CisgICAgICAgIHB3LnByaW50bG4oIiBtTXNpc2RuPSIgKyBtTXNpc2RuKTsKKyAgICAgICAgcHcucHJpbnRsbigiIG1Nc2lzZG5UYWc9IiArIG1Nc2lzZG5UYWcpOworICAgICAgICBwdy5wcmludGxuKCIgbVZvaWNlTWFpbE51bT0iICsgbVZvaWNlTWFpbE51bSk7CisgICAgICAgIHB3LnByaW50bG4oIiBtVm9pY2VNYWlsVGFnPSIgKyBtVm9pY2VNYWlsVGFnKTsKKyAgICAgICAgcHcucHJpbnRsbigiIG1OZXdWb2ljZU1haWxOdW09IiArIG1OZXdWb2ljZU1haWxOdW0pOworICAgICAgICBwdy5wcmludGxuKCIgbU5ld1ZvaWNlTWFpbFRhZz0iICsgbU5ld1ZvaWNlTWFpbFRhZyk7CisgICAgICAgIHB3LnByaW50bG4oIiBtSXNWb2ljZU1haWxGaXhlZD0iICsgbUlzVm9pY2VNYWlsRml4ZWQpOworICAgICAgICBwdy5wcmludGxuKCIgbUNvdW50Vm9pY2VNZXNzYWdlcz0iICsgbUNvdW50Vm9pY2VNZXNzYWdlcyk7CiAgICAgICAgIHB3LnByaW50bG4oIiBtSW1zaT0iICsgbUltc2kpOwotICAgICAgICBwdy5wcmludGxuKCIgbW5jTGVuZ3RoPSIgKyBtbmNMZW5ndGgpOwotICAgICAgICBwdy5wcmludGxuKCIgbWFpbGJveEluZGV4PSIgKyBtYWlsYm94SW5kZXgpOwotICAgICAgICBwdy5wcmludGxuKCIgc3BuPSIgKyBzcG4pOworICAgICAgICBwdy5wcmludGxuKCIgbU1uY0xlbmd0aD0iICsgbU1uY0xlbmd0aCk7CisgICAgICAgIHB3LnByaW50bG4oIiBtTWFpbGJveEluZGV4PSIgKyBtTWFpbGJveEluZGV4KTsKKyAgICAgICAgcHcucHJpbnRsbigiIG1TcG49IiArIG1TcG4pOwogICAgICAgICBwdy5mbHVzaCgpOwogICAgIH0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RzOiAiICsgc3VwZXIudG9TdHJpbmcoKQorICAgICAgICAgICAgICAgICsgIiBtX290YV9jb21taXRlZCIgKyBtT3RhQ29tbWl0ZWQKKyAgICAgICAgICAgICAgICArICIgbU15TW9iaWxlTnVtYmVyPSIgKyAieHh4eCIKKyAgICAgICAgICAgICAgICArICIgbU1pbjJNaW4xPSIgKyBtTWluMk1pbjEKKyAgICAgICAgICAgICAgICArICIgbVBybFZlcnNpb249IiArIG1QcmxWZXJzaW9uCisgICAgICAgICAgICAgICAgKyAiIG1FRnBsPSIgKyBtRUZwbAorICAgICAgICAgICAgICAgICsgIiBtRUZsaT0iICsgbUVGbGkKKyAgICAgICAgICAgICAgICArICIgbUNzaW1TcG5EaXNwbGF5Q29uZGl0aW9uPSIgKyBtQ3NpbVNwbkRpc3BsYXlDb25kaXRpb24KKyAgICAgICAgICAgICAgICArICIgbU1kbj0iICsgbU1kbgorICAgICAgICAgICAgICAgICsgIiBtTWluPSIgKyBtTWluCisgICAgICAgICAgICAgICAgKyAiIG1Ib21lU3lzdGVtSWQ9IiArIG1Ib21lU3lzdGVtSWQKKyAgICAgICAgICAgICAgICArICIgbUhvbWVOZXR3b3JrSWQ9IiArIG1Ib21lTmV0d29ya0lkOworICAgIH0KKwogICAgIC8vICoqKioqIEV2ZW50IENvbnN0YW50cwogICAgIHByaXZhdGUgc3RhdGljIGZpbmFsIGludCBFVkVOVF9BUFBfUkVBRFkgPSAxOwogICAgIHByaXZhdGUgc3RhdGljIGZpbmFsIGludCBFVkVOVF9HRVRfSU1TSV9ET05FID0gMzsKQEAgLTkzLDEyICsxMDAsMTIgQEAKICAgICBwdWJsaWMgUnVpbVJlY29yZHMoVWljY0NhcmRBcHBsaWNhdGlvbiBhcHAsIENvbnRleHQgYywgQ29tbWFuZHNJbnRlcmZhY2UgY2kpIHsKICAgICAgICAgc3VwZXIoYXBwLCBjLCBjaSk7CiAKLSAgICAgICAgYWRuQ2FjaGUgPSBuZXcgQWRuUmVjb3JkQ2Fja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aWMgU3RyaW5nIGdldEVmTmFtZSgpIHsKICAgICAgICAgICAgIHJldHVybiAiRUZfQ1NJTV9MSSI7CiAgICAgICAgIH0KIAorICAgICAgICBAT3ZlcnJpZGUKICAgICAgICAgcHVibGljIHZvaWQgb25SZWNvcmRMb2FkZWQoQXN5bmNSZXN1bHQgYXIpIHsKICAgICAgICAgICAgIG1FRmxpID0gKGJ5dGVbXSkgYXIucmVzdWx0OwogICAgICAgICAgICAgLy8gY29udmVydCBjc2ltIGVmbGkgZGF0YSB0byBpc28gNjM5IGZvcm1hdApAQCAtMjU2LDEwICsyNjgsMTIgQEAKIAogICAgIC8vIFJlZmVyIHRvIEMuUzAwNjUgNS4yLjMyCiAgICAgcHJpdmF0ZSBjbGFzcyBFZkNzaW1TcG5Mb2FkZWQgaW1wbGVtZW50cyBJY2NSZWNvcmRMb2FkZWQgeworICAgICAgICBAT3ZlcnJpZGUKICAgICAgICAgcHVibGljIFN0cmluZyBnZXRFZk5hbWUoKSB7CiAgICAgICAgICAgICByZXR1cm4gIkVGX0NTSU1fU1BOIjsKICAgICAgICAgfQogCisgICAgICAgIEBPdmVycmlkZQogICAgICAgICBwdWJsaWMgdm9pZCBvblJlY29yZExvYWRlZChBc3luY1Jlc3VsdCBhcikgewogICAgICAgICAgICAgYnl0ZVtdIGRhdGEgPSAoYnl0ZVtdKSBhci5yZXN1bHQ7CiAgICAgICAgICAgICBpZiAoREJHKSBsb2coIkNTSU1fU1BOPSIgKwpAQCAtMjgwLDIyICsyOTQsMjIgQEAKICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgaWYgKG51bUJ5dGVzID09IDApIHsKLSAgICAgICAgICAgICAgICBzcG4gPSAiIjsKKyAgICAgICAgICAgICAgICBtU3BuID0gIiI7CiAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgfQogICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICBzd2l0Y2ggKGVuY29kaW5nKSB7CiAgICAgICAgICAgICAgICAgY2FzZSBVc2VyRGF0YS5FTkNPRElOR19PQ1RFVDoKICAgICAgICAgICAgICAgICBjYXNlIFVzZXJEYXRhLkVOQ09ESU5HX0xBVElOOgotICAgICAgICAgICAgICAgICAgICBzcG4gPSBuZXcgU3RyaW5nKHNwbkRhdGEsIDAsIG51bUJ5dGVzLCAiSVNPLTg4NTktMSIpOworICAgICAgICAgICAgICAgICAgICBtU3BuID0gbmV3IFN0cmluZyhzcG5EYXRhLCAwLCBudW1CeXRlcywgIklTTy04ODU5LTEiKTsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgY2FzZSBVc2VyRGF0YS5FTkNPRElOR19JQTU6CiAgICAgICAgICAgICAgICAgY2FzZSBVc2VyRGF0YS5FTkNPRElOR19HU01fN0JJVF9BTFBIQUJFVDoKICAgICAgICAgICAgICAgICBjYXNlIFVzZXJEYXRhLkVOQ09ESU5HXzdCSVRfQVNDSUk6Ci0gICAgICAgICAgICAgICAgICAgIHNwbiA9IEdzbUFscGhhYmV0LmdzbTdCaXRQYWNrZWRUb1N0cmluZyhzcG5EYXRhLCAwLCAobnVtQnl0ZXMqOCkvNyk7CisgICAgICAgICAgICAgICAgICAgIG1TcG4gPSBHc21BbHBoYWJldC5nc203Qml0UGFja2VkVG9TdHJpbmcoc3BuRGF0YSwgMCwgKG51bUJ5dGVzKjgpLzcpOwogICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICBjYXNlIFVzZXJEYXRhLkVOQ09ESU5HX1VOSUNPREVfMTY6Ci0gICAgICAgICAgICAgICAgICAgIHNwbiA9ICBuZXcgU3RyaW5nKHNwbkRhdGEsIDAsIG51bUJ5dGVzLCAidXRmLTE2Iik7CisgICAgICAgICAgICAgICAgICAgIG1TcG4gPSAgbmV3IFN0cmluZyhzcG5EYXRhLCAwLCBudW1CeXRlcywgInV0Zi0xNiIpOwogICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICBsb2coIlNQTiBlbmNvZGluZyBub3Qgc3VwcG9ydGVkIik7CkBAIC0zMDMsMTcgKzMxNywxOSBAQAogICAgICAgICAgICAgfSBjYXRjaChFeGNlcHRpb24gZSkgewogICAgICAgICAgICAgICAgIGxvZygic3BuIGRlY29kZSBlcnJvcjogIiArIGUpOwogICAgICAgICAgICAgfQotICAgICAgICAgICAgaWYgKERCRykgbG9nKCJzcG49IiArIHNwbik7CisgICAgICAgICAgICBpZiAoREJHKSBsb2coInNwbj0iICsgbVNwbik7CiAgICAgICAgICAgICBpZiAoREJHKSBsb2coInNwbkNvbmRpdGlvbj0iICsgbUNzaW1TcG5EaXNwbGF5Q29uZGl0aW9uKTsKLSAgICAgICAgICAgIFN5c3RlbVByb3BlcnRpZXMuc2V0KFBST1BFUlRZX0lDQ19PUEVSQVRPUl9BTFBIQSwgc3BuKTsKKyAgICAgICAgICAgIFN5c3RlbVByb3BlcnRpZXMuc2V0KFBST1BFUlRZX0lDQ19PUEVSQVRPUl9BTFBIQSwgbVNwbik7CiAgICAgICAgIH0KICAgICB9CiAKICAgICBwcml2YXRlIGNsYXNzIEVmQ3NpbU1kbkxvYWRlZCBpbXBsZW1lbnRzIEljY1JlY29yZExvYWRlZCB7CisgICAgICAgIEBPdmVycmlkZQogICAgICAgICBwdWJsaWMgU3RyaW5nIGdldEVmTmFtZSgpIHsKICAgICAgICAgICAgIHJldHVybiAiRUZfQ1NJTV9NRE4iOwogICAgICAgICB9CiAKKyAgICAgICAgQE92ZXJyaWRlCiAgICAgICAgIHB1YmxpYyB2b2lkIG9uUmVjb3JkTG9hZGVkKEFzeW5jUmVzdWx0IGFyKSB7CiAgICAgICAgICAgICBieXRlW10gZGF0YSA9IChieXRlW10pIGFyLnJlc3VsdDsKICAgICAgICAgICAgIGlmIChEQkcpIGxvZygiQ1NJTV9NRE49IiArIEljY1V0aWxzLmJ5dGVzVG9IZXhTdHJpbmcoZGF0Y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WVOYW1lID0gbnVsbDsKIAogICAgIFVzaW1TZXJ2aWNlVGFibGUgbVVzaW1TZXJ2aWNlVGFibGU7CiAKLSAgICAvLyAqKioqKiBDb25zdGFudHMKKyAgICBAT3ZlcnJpZGUKKyAgICBwdWJsaWMgU3RyaW5nIHRvU3RyaW5nKCkgeworICAgICAgICByZXR1cm4gIlNpbVJlY29yZHM6ICIgKyBzdXBlci50b1N0cmluZygpCisgICAgICAgICAgICAgICAgKyAiIG1WbUNvbmZpZyIgKyBtVm1Db25maWcKKyAgICAgICAgICAgICAgICArICIgbVNwbk92ZXJyaWRlPSIgKyAibVNwbk92ZXJyaWRlIgorICAgICAgICAgICAgICAgICsgIiBjYWxsRm9yd2FyZGluZ0VuYWJsZWQ9IiArIG1DYWxsRm9yd2FyZGluZ0VuYWJsZWQKKyAgICAgICAgICAgICAgICArICIgc3BuU3RhdGU9IiArIG1TcG5TdGF0ZQorICAgICAgICAgICAgICAgICsgIiBtQ3Boc0luZm89IiArIG1DcGhzSW5mbworICAgICAgICAgICAgICAgICsgIiBtQ3NwUGxtbkVuYWJsZWQ9IiArIG1Dc3BQbG1uRW5hYmxlZAorICAgICAgICAgICAgICAgICsgIiBlZk1XSVM9IiArIG1FZk1XSVMKKyAgICAgICAgICAgICAgICArICIgZWZDUEhTX01XST0iICsgbUVmQ1BIU19NV0kKKyAgICAgICAgICAgICAgICArICIgbUVmQ2ZmPSIgKyBtRWZDZmYKKyAgICAgICAgICAgICAgICArICIgbUVmQ2Zpcz0iICsgbUVmQ2ZpcworICAgICAgICAgICAgICAgICsgIiBnZXRPcGVyYXRvck51bWVyaWM9IiArIGdldE9wZXJhdG9yTnVtZXJpYygpOworICAgIH0KIAotICAgIC8vIEJpdG1hc2tzIGZvciBTUE4gZGlzcGxheSBydWxlcy4KLSAgICBwdWJsaWMgc3RhdGljIGZpbmFsIGludCBTUE5fUlVMRV9TSE9XX1NQTiAgPSAweDAxOwotICAgIHB1YmxpYyBzdGF0aWMgZmluYWwga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ZvaWQgZGlzcG9zZSgpIHsKLSAgICAgICAgaWYgKERCRykgbG9nKCJEaXNwb3NpbmcgU0lNUmVjb3JkcyAiICsgdGhpcyk7CisgICAgICAgIGlmIChEQkcpIGxvZygiRGlzcG9zaW5nIFNJTVJlY29yZHMgdGhpcz0iICsgdGhpcyk7CiAgICAgICAgIC8vVW5yZWdpc3RlciBmb3IgYWxsIGV2ZW50cwogICAgICAgICBtQ2kudW5yZWdpc3RlckZvckljY1JlZnJlc2godGhpcyk7CiAgICAgICAgIG1DaS51blNldE9uU21zT25TaW0odGhpcyk7CkBAIC0yMDMsMjUgKzIwOSwyNiBAQAogICAgICAgICBzdXBlci5kaXNwb3NlKCk7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHJvdGVjdGVkIHZvaWQgZmluYWxpemUoKSB7CiAgICAgICAgIGlmKERCRykgbG9nKCJmaW5hbGl6ZWQiKTsKICAgICB9CiAKICAgICBwcm90ZWN0ZWQgdm9pZCByZXNldFJlY29yZHMoKSB7CiAgICAgICAgIG1JbXNpID0gbnVsbDsKLSAgICAgICAgbXNpc2RuID0gbnVsbDsKLSAgICAgICAgdm9pY2VNYWlsTnVtID0gbnVsbDsKLSAgICAgICAgY291bnRWb2ljZU1lc3NhZ2VzID0gMDsKLSAgICAgICAgbW5jTGVuZ3RoID0gVU5JTklUSUFMSVpFRDsKLSAgICAgICAgaWNjaWQgPSBudWxsOworICAgICAgICBtTXNpc2RuID0gbnVsbDsKKyAgICAgICAgbVZvaWNlTWFpbE51bSA9IG51bGw7CisgICAgICAgIG1Db3VudFZvaWNlTWVzc2FnZXMgPSAwOworICAgICAgICBtTW5jTGVuZ3RoID0gVU5JTklUSUFMSVpFRDsKKyAgICAgICAgaWNjSWQgPSBudWxsOwogICAgICAgICAvLyAtMSBtZWFucyBubyBFRl9TUE4gZm91bmQ7IHRyZWF0IGFjY29yZGluZ2x5LgotICAgICAgICBzcG5EaXNwbGF5Q29uZGl0aW9uID0gLTE7Ci0gICAgICAgIGVmTVdJUyA9IG51bGw7Ci0gICAgICAgIGVmQ1BIU19NV0kgPSBudWxsOwotICAgICAgICBzcGRpTmV0d29ya3MgPSBudWxsOwotICAgICAgICBwbm5Ib21lTmFtZSA9IG51bGw7CisgICAgICAgIG1TcG5EaXNwbGF5Q29uZGl0aW9uID0gLTE7CisgICAgICAgIG1FZk1XSVMgPSBudWxsOworICAgICAgICBtRWZDUEhTX01XSSA9IG51bGw7CisgICAgICAgIG1TcGRpTmV0d29ya3MgPSBudWxsOworICAgICAgICBtUG5uSG9tZU5hbWUgPSBudWxsOwogCi0gICAgICAgIGFkbkNhY2hlLnJlc2V0KCk7CisgICAgICAgIG1BZG5DYWNoZS5yZXNldCgpOwogCiAgICAgICAgIGxvZygiU0lNUmVjb3Jkczogb25SYWRpb09mZk9yTm90QXZhaWxhYmxlIHNldCAnZ3NtLnNpbS5vcGVyYXRvci5udW1lcmljJyB0byBvcGVyYXRvcj1udWxsIik7CiAgICAgICAgIFN5c3RlbVByb3BlcnRpZXMuc2V0KFBST1BFUlRZX0lDQ19PUEVSQVRPUl9OVU1FUklDLCBudWxsKTsKQEAgLTIzMSw3ICsyMzgsNyBAQAogICAgICAgICAvLyByZWNvcmRzUmVxdWVzdGVkIGlzIHNldCB0byBmYWxzZSBpbmRpY2F0aW5nIHRoYXQgdGhlIFNJTQogICAgICAgICAvLyByZWFkIHJlcXVlc3RzIG1hZGUgc28gZmFyIGFyZSBub3QgdmFsaWQuIFRoaXMgaXMgc2V0IHRvCiAgICAgICAgIC8vIHRydWUgb25seSB3aGVuIGZyZXNoIHNldCBvZiByZWFkIHJlcXVlc3RzIGFyZSBtYWRlLgotICAgICAgICByZWNvcmRzUmVxdWVzdGVkID0gZmFsc2U7CisgICAgICAgIG1SZWNvcmRzUmVxdWVzdGVkID0gZmFsc2U7CiAgICAgfQogCiAKQEAgLTI0NSw4ICsyNTIsOSBAQAogICAgICAgICByZXR1cm4gbUltc2k7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFN0cmluZyBnZXRNc2lzZG5OdW1iZXIoKSB7Ci0gICAgICAgIHJldHVybiBtc2lzZG47CisgICAgICAgIHJldHVybiBtTXNpc2RuOwogICAgIH0KIAogICAgIEBPdmVycmlkZQpAQCAtMjY5LDI3ICsyNzcsMzAgQEAKICAgICAgKiAgICAgICAgKChBc3luY1Jlc3VsdClvbkNvbXBsZXRlLm9iaikuZXhjZXB0aW9uID09IG51bGwgb24gc3VjY2VzcwogICAgICAqICAgICAgICAoKEFzeW5jUmVzdWx0KW9uQ29tcGxldGUub2JqKS5leGNlcHRpb24gIT0gbnVsbCBvbiBmYWlsCiAgICAgICovCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQgc2V0TXNpc2RuTnVtYmVyKFN0cmluZyBhbHBoYVRhZywgU3RyaW5nIG51bWJlciwKICAgICAgICAgICAgIE1lc3NhZ2Ugb25Db21wbGV0ZSkgewogCi0gICAgICAgIG1zaXNkbiA9IG51bWJlcjsKLSAgICAgICAgbXNpc2RuVGFnID0gYWxwaGFUYWc7CisgICAgICAgIG1Nc2lzZG4gPSBudW1iZXI7CisgICAgICAgIG1Nc2lzZG5UYWcgPSBhbHBoYVRhZzsKIAotICAgICAgICBpZihEQkcpIGxvZygiU2V0IE1TSVNETjogIiArIG1zaXNkblRhZyArICIgIiArIC8qbXNpc2RuKi8gInh4eHh4eHgiKTsKKyAgICAgICAgaWYoREJHKSBsb2coIlNldCBNU0lTRE46ICIgKyBtTXNpc2RuVGFnICsgIiAiICsgLyptTXNpc2RuKi8gInh4eHh4eHgiKTsKIAogCi0gICAgICAgIEFkblJlY29yZCBhZG4gPSBuZXcgQWRuUmVjb3JkKG1zaXNkblRhZywgbXNpc2RuKTsKKyAgICAgICAgQWRuUmVjb3JkIGFkbiA9IG5ldyBBZG5SZWNvcmQobU1zaXNkblRhZywgbU1zaXNkbik7CiAKICAgICAgICAgbmV3IEFkblJlY29yZExvYWRlcihtRmgpLnV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0aW9uKCJWb2ljZW1haWwgbnVtYmVyIGlzIGZpeGVkIGJ5IG9wZXJhdG9yIik7CiAgICAgICAgICAgICBvbkNvbXBsZXRlLnNlbmRUb1RhcmdldCgpOwogICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICB9CiAKLSAgICAgICAgbmV3Vm9pY2VNYWlsTnVtID0gdm9pY2VOdW1iZXI7Ci0gICAgICAgIG5ld1ZvaWNlTWFpbFRhZyA9IGFscGhhVGFnOworICAgICAgICBtTmV3Vm9pY2VNYWlsTnVtID0gdm9pY2VOdW1iZXI7CisgICAgICAgIG1OZXdWb2ljZU1haWxUYWcgPSBhbHBoYVRhZzsKIAotICAgICAgICBBZG5SZWNvcmQgYWRuID0gbmV3IEFkblJlY29yZChuZXdWb2ljZU1haWxUYWcsIG5ld1ZvaWNlTWFpbE51bSk7CisgICAgICAgIEFkblJlY29yZCBhZG4gPSBuZXcgQWRuUmVjb3JkKG1OZXdWb2ljZU1haWxUYWcsIG1OZXdWb2ljZU1haWxOdW0pOwogCi0gICAgICAgIGlmIChtYWlsYm94SW5kZXggIT0gMCAmJiBtYWlsYm94SW5kZXggIT0gMHhmZikgeworICAgICAgICBpZiAobU1haWxib3hJbmRleCAhPSAwICYmIG1NYWlsYm94SW5kZXggIT0gMHhmZikgewogCiAgICAgICAgICAgICBuZXcgQWRuUmVjb3JkTG9hZGVyKG1GaCkudXBkYXRlRUYoYWRuLCBFRl9NQkROLCBFRl9FWFQ2LAotICAgICAgICAgICAgICAgICAgICBtYWlsYm94SW5kZXgsIG51bGwsCisgICAgICAgICAgICAgICAgICAgIG1NYWlsYm94SW5kZXgsIG51bGwsCiAgICAgICAgICAgICAgICAgICAgIG9idGFpbk1lc3NhZ2UoRVZFTlRfU0VUX01CRE5fRE9ORSwgb25Db21wbGV0ZSkpOwogCiAgICAgICAgIH0gZWxzZSBpZiAoaXNDcGhzTWFpbGJveEVuYWJsZWQoKSkgewpAQCAtMzQ5LDkgKzM2MSwxMCBAQAogICAgICAgICB9CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIFN0cmluZyBnZXRWb2ljZU1haWxBbHBoYVRhZygpCiAgICAgewotICAgICAgICByZXR1cm4gdm9pY2VNYWlsVGFnOworICAgICAgICByZXR1cm4gbVZvaWNlTWFpbFRhZzsKICAgICB9CiAKICAgICAvKioKQEAgLTM2MSw2ICszNzQsNyBAQAogICAgICAqICAgICAgICAgICAgICAgICAgICAgLTEgdG8gaW5kaWNhdGUgdGhhdCBhbiB1bmtub3duIG51bWJlciBvZgogICAgICAqICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VzIGFyZSB3YWl0aW5nCiAgICAgICovCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIHZvaWQKICAgICBzZXRWb2ljZU1lc3NhZ2VXYWl0aW5nKGludCBsaW5lLCBpbnQgY291bnRXYWl0aW5nKSB7CiAgICAgICAgIGlmIChsaW5lICE9IDEpIHsKQEAgLTM3NywzOSArMzkxLDM5IEBACiAgICAgICAgICAgICBjb3VudFdhaXRpbmcgPSAweGZmOwogICAgICAgICB9CiAKLSAgICAgICAgY291bnRWb2ljZU1lc3NhZ2VzID0gY291bnRXYWl0aW5nOworICAgICAgICBtQ291bnRWb2ljZU1lc3NhZ2VzID0gY291bnRXYWl0aW5nOwogCiAgICAgICAgIG1SZWNvcmRzRXZlbnRzUmVnaXN0cmFudHMubm90aWZ5UmVzdWx0KEVWRU5UX01XSSk7CiAKICAgICAgICAgdHJ5IHsKLSAgICAgICAgICAgIGlmIChlZk1XSVMgIT0gbnVsbCkgeworICAgICAgICAgICAgaWYgKG1FZk1XSVMgIT0gbnVsbCkgewogICAgICAgICAgICAgICAgIC8vIFRTIDUxLjAxMSAxMC4zLjQ1CiAKICAgICAgICAgICAgICAgICAvLyBsc2Igb2YgYnl0ZSAwIGlzICd2b2ljZW1haWwnIHN0YXR1cwotICAgICAgICAgICAgICAgIGVmTVdJU1swXSA9IChieXRlKSgoZWZNV0lTWzBdICYgMHhmZSkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgKGNvdW50Vm9pY2VNZXNzYWdlcyA9PSAwID8gMCA6IDEpKTsKKyAgICAgICAgICAgICAgICBtRWZNV0lTWzBdID0gKGJ5dGUpKChtRWZNV0lTWzBdICYgMHhmZSkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgKG1Db3VudFZvaWNlTWVzc2FnZXMgPT0gMCA/IDAgOiAxKSk7CiAKICAgICAgICAgICAgICAgICAvLyBieXRlIDEgaXMgdGhlIG51bWJlciBvZiB2b2ljZSBtZXNzYWdlcyB3YWl0aW5nCiAgICAgICAgICAgICAgICAgaWYgKGNvdW50V2FpdGluZyA8IDApIHsKICAgICAgICAgICAgICAgICAgICAgLy8gVGhlIHNwZWMgZG9lcyBub3QgZGVmaW5lIHdoYXQgdGhpcyBzaG91bGQgYmUKICAgICAgICAgICAgICAgICAgICAgLy8gaWYgd2UgZG9uJ3Qga25vdyB0aGUgY291bnQKLSAgICAgICAgICAgICAgICAgICAgZWZNV0lTWzFdID0gMDsKKyAgICAgICAgICAgICAgICAgICAgbUVmTVdJU1sxXSA9IDA7CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgZWZNV0lTWzFdID0gKGJ5dGUpIGNvdW50V2FpdGluZzsKKyAgICAgICAgICAgICAgICAgICAgbUVmTVdJU1sxXSA9IChieXRlKSBjb3VudFdhaXRpbmc7CiAgICAgICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAgICAgbUZoLnVwZGF0ZUVGTGluZWFyRml4ZWQoCi0gICAgICAgICAgICAgICAgICAgIEVGX01XSVMsIDEsIGVmTVdJUywgbnVsbCwKKyAgICAgICAgICAgICAgICAgICAgRUZfTVdJUywgMSwgbUVmTVdJUywgbnVsbCwKICAgICAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZSAoRVZFTlRfVVBEQVRFX0RPTkUsIEVGX01XSVMpKTsKICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgaWYgKGVmQ1BIU19NV0kgIT0gbnVsbCkgeworICAgICAgICAgICAgaWYgKG1FZkNQSFNfTVdJICE9IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgLy8gUmVmZXIgQ1BIUzRfMi5XVzYgQjQuMi4zCi0gICAgICAgICAgICAgICAgZWZDUEhTX01XSVswXSA9IChieXRlKSgoZWZDUEhTX01XSVswXSAmIDB4ZjApCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgfCAoY291bnRWb2ljZU1lc3NhZ2VzID09IDAgPyAweDUgOiAweGEpKTsKKyAgICAgICAgICAgICAgICBtRWZDUEhTX01XSVswXSA9IChieXRlKSgobUVmQ1BIU19NV0lbMF0gJiAweGYwKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgKG1Db3VudFZvaWNlTWVzc2FnZXMgPT0gMCA/IDB4NSA6IDB4YSkpOwogCiAgICAgICAgICAgICAgICAgbUZoLnVwZGF0ZUVGVHJhbnNwYXJlbnQoCi0gICAgICAgICAgICAgICAgICAgIEVGX1ZPSUNFX01BSUxfSU5ESUNBVE9SX0NQSFMsIGVmQ1BIU19NV0ksCisgICAgICAgICAgICAgICAgICAgIEVGX1ZPSUNFX01BSUxfSU5ESUNBVE9SX0NQSFMsIG1FZkNQSFNfTVdJLAogICAgICAgICAgICAgICAgICAgICBvYnRhaW5NZXNzYWdlIChFVkVOVF9VUERBVEVfRE9ORSwgRUZfVk9JQ0VfTUFJTF9JTkRJQ0FUT1JfQ1BIUykpOwogICAgICAgICAgICAgfQogICAgICAgICB9IGNhdGNoIChBcnJheUluZGV4T3V0T2ZCb3VuZHNFeGNlcHRpb24gZXgpIHsKQEAgLTQyOCw3ICs0NDIsNyBAQAogICAgICAqLwogICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBib29sZWFuIGdldFZvaWNlQ2FsbEZvcndhcmRpbmdGbGFnKCkgewotICAgICAgICByZXR1c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BpZiAobU1uY0xlbmd0aCA9PSBVTklOSVRJQUxJWkVEIHx8IG1NbmNMZW5ndGggPT0gVU5LTk9XTikgewogICAgICAgICAgICAgbG9nKCJnZXRTSU1PcGVyYXRvck51bWVyaWM6IGJhZCBtbmNMZW5ndGgiKTsKICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICB9CiAKICAgICAgICAgLy8gTGVuZ3RoID0gbGVuZ3RoIG9mIE1DQyArIGxlbmd0aCBvZiBNTkMKICAgICAgICAgLy8gbGVuZ3RoIG9mIG1jYyA9IDMgKFRTIDIzLjAwMyBTZWN0aW9uIDIuMikKLSAgICAgICAgcmV0dXJuIG1JbXNpLnN1YnN0cmluZygwLCAzICsgbW5jTGVuZ3RoKTsKKyAgICAgICAgcmV0dXJuIG1JbXNpLnN1YnN0cmluZygwLCAzICsgbU1uY0xlbmd0aCk7CiAgICAgfQogCiAgICAgLy8gKioqKiogT3ZlcnJpZGRlbiBmcm9tIEhhbmRsZXIKKyAgICBAT3ZlcnJpZGUKICAgICBwdWJsaWMgdm9pZCBoYW5kbGVNZXNzYWdlKE1lc3NhZ2UgbXNnKSB7CiAgICAgICAgIEFzeW5jUmVzdWx0IGFyOwogICAgICAgICBBZG5SZWNvcmQgYWRuOwpAQCAtNTYxLDMyICs1NzcsMzIgQEAKIAogICAgICAgICAgICAgICAgIGxvZygiSU1TSTogIiArIC8qIGltc2kuc3Vic3RyaW5nKDAsIDYpICsqLyAieHh4eHh4eCIpOwogCi0gICAgICAgICAgICAgICAgaWYgKCgobW5jTGVuZ3RoID09IFVOS05PV04pIHx8IChtbmNMZW5ndGggPT0gMikpICYmCisgICAgICAgICAgICAgICAgaWYgKCgobU1uY0xlbmd0aCA9PSBVTktOT1dOKSB8fCAobU1uY0xlbmd0aCA9PSAyKSkgJiYKICAgICAgICAgICAgICAgICAgICAgICAgICgobUltc2kgIT0gbnVsbCkgJiYgKG1JbXNpLmxlbmd0aCgpID49IDYpKSkgewogICAgICAgICAgICAgICAgICAgICBTdHJpbmcgbWNjbW5jQ29kZSA9IG1JbXNpLnN1YnN0cmluZygwLCA2KTsKICAgICAgICAgICAgICAgICAgICAgZm9yIChTdHJpbmcgbWNjbW5jIDogTUNDTU5DX0NPREVTX0hBVklOR18zRElHSVRTX01OQykgewogICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1jY21uYy5lcXVhbHMobWNjbW5jQ29kZSkpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBtbmNMZW5ndGggPSAzOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1NbmNMZW5ndGggPSAzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgfQogCi0gICAgICAgICAgICAgICAgaWYgKG1uY0xlbmd0aCA9PSBVTktOT1dOKSB7CisgICAgICAgICAgICAgICAgaWYgKG1NbmNMZW5ndGggPT0gVU5LTk9XTikgewogICAgICAgICAgICAgICAgICAgICAvLyB0aGUgU0lNIGhhcyB0b2xkIHVzIGFsbCBpdCBrbm93cywgYnV0IGl0IGRpZG4ndCBrbm93IHRoZSBtbmMgbGVuZ3RoLgogICAgICAgICAgICAgICAgICAgICAvLyBndWVzcyB1c2luZyB0aGUgbWNjCiAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgbWNjID0gSW50ZWdlci5wYXJzZUludChtSW1zaS5zdWJzdHJpbmcoMCwzKSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBtbmNMZW5ndGggPSBNY2NUYWJsZS5zbWFsbGVzdERpZ2l0c01jY0Zvck1uYyhtY2MpOworICAgICAgICAgICAgICAgICAgICAgICAgbU1uY0xlbmd0aCA9IE1jY1RhYmxlLnNtYWxsZXN0RGlnaXRzTWNjRm9yTW5jKG1jYyk7CiAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKE51bWJlckZvcm1hdEV4Y2VwdGlvbiBlKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBtbmNMZW5ndGggPSBVTktOT1dOOworICAgICAgICAgICAgICAgICAgICAgICAgbU1uY0xlbmd0aCA9IFVOS05PV047CiAgICAgICAgICAgICAgICAgICAgICAgICBsb2dlKCJDb3JydXB0IElNU0khIik7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgICAgICBpZiAobW5jTGVuZ3RoICE9IFVOS05PV04gJiYgbW5jTGVuZ3RoICE9IFVOSU5JVElBTElaRUQpIHsKKyAgICAgICAgICAgICAgICBpZiAobU1uY0xlbmd0aCAhPSBVTktOT1dOICYmIG1NbmNMZW5ndGggIT0gVU5JTklUSUFMSVpFRCkgewogICAgICAgICAgICAgICAgICAgICAvLyBmaW5hbGx5IGhhdmUgYm90aCB0aGUgaW1zaSBhbmQgdGhlIG1uY0xlbmd0aCBhbmQgY2FuIHBhcnNlIHRoZSBpbXNpIHByb3Blcmx5Ci0gICAgICAgICAgICAgICAgICAgIE1jY1RhYmxlLnVwZGF0ZU1jY01uY0NvbmZpZ3VyYXRpb24obUNvbnRleHQsIG1JbXNpLnN1YnN0cmluZygwLCAzICsgbW5jTGVuZ3RoKSk7CisgICAgICAgICAgICAgICAgICAgIE1jY1RhYmxlLnVwZGF0ZU1jY01uY0NvbmZpZ3VyYXRpb24obUNvbnRleHQsIG1JbXNpLnN1YnN0cmluZygwLCAzICsgbU1uY0xlbmd0aCkpOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBtSW1zaVJlYWR5UmVnaXN0cmFudHMubm90aWZ5UmVnaXN0cmFudHMoKTsKICAgICAgICAgICAgIGJyZWFrOwpAQCAtNjA0LDIyICs2MjAsMjIgQEAKICAgICAgICAgICAgICAgICAgICAgbG9nKCJFRl9NQkk6ICIgKyBJY2NVdGlscy5ieXRlc1RvSGV4U3RyaW5nKGRhdGEpKTsKIAogICAgICAgICAgICAgICAgICAgICAvLyBWb2ljZSBtYWlsIHJlY29yZCBudW1iZXIgc3RvcmVkIGZpcnN0Ci0gICAgICAgICAgICAgICAgICAgIG1haWxib3hJbmRleCA9IChpbnQpZGF0YVswXSAmIDB4ZmY7CisgICAgICAgICAgICAgICAgICAgIG1NYWlsYm94SW5kZXggPSBkYXRhWzBdICYgMHhmZjsKIAogICAgICAgICAgICAgICAgICAgICAvLyBjaGVjayBpZiBkYWlsaW5nIG51bWJlIGlkIHZhbGlkCi0gICAgICAgICAgICAgICAgICAgIGlmIChtYWlsYm94SW5kZXggIT0gMCAmJiBtYWlsYm94SW5kZXggIT0gMHhmZikgeworICAgICAgICAgICAgICAgICAgICBpZiAobU1haWxib3hJbmRleCAhPSAwICYmIG1NYWlsYm94SW5kZXggIT0gMHhmZikgewogICAgICAgICAgICAgICAgICAgICAgICAgbG9nKCJHb3QgdmFsaWQgbWFpbGJveCBudW1iZXIgZm9yIE1CRE4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgIGlzVmFsaWRNYmRuID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgICAgIC8vIG9uZSBtb3JlIHJlY29yZCB0byBsb2FkCi0gICAgICAgICAgICAgICAgcmVjb3Jkc1RvTG9hZCArPSAxOworICAgICAgICAgICAgICAgIG1SZWNvcmRzVG9Mb2FkICs9IDE7CiAKICAgICAgICAgICAgICAgICBpZiAoaXNWYWxpZE1iZG4pIHsKICAgICAgICAgICAgICAgICAgICAgLy8gTm90ZTogTUJETiB3YXMgbm90IGluY2x1ZGVkIGluIE5VTV9PRl9TSU1fUkVDT1JEU19MT0FERUQKICAgICAgICAgICAgICAgICAgICAgbmV3IEFkblJlY29yZExvYWRlcihtRmgpLmxvYWRGcm9tRUYoRUZfTUJETiwgRUZfRVhUNiwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYWlsYm94SW5kZXgsIG9idGFpbk1lc3NhZ2UoRVZFTlRfR0VUX01CRE5fRE9ORSkpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1NYWlsYm94SW5kZXgsIG9idGFpbk1lc3NhZ2UoRVZFTlRfR0VUX01CRE5fRE9ORSkpOwogICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgIC8vIElmIHRoaXMgRUYgbm90IHByZXNlbnQsIHRyeSBtYWlsYm94IGFzIGluIENQSFMgc3RhbmRhcmQKICAgICAgICAgICAgICAgICAgICAgLy8gQ1BIUyAoQ1BIUzRfMi5XVzYpIGlzIGEgZXVyb3BlYW4gc3RhbmRhcmQuCkBAIC02MzYsOCArNjUyLDggQEAKICAgICAgICAgICAgICAgICAvL0lmIHRoZXkgYXJlIG5vdCByZXNldCwgaW5jYXNlIG9mIGludmFsaWQgZGF0YS9leGNlcHRpb24gdGhlc2UKICAgICAgICAgICAgICAgICAvL3ZhcmlhYmxlcyBhcmUgcmV0YWluaW5nIHRoZWlyIHByZXZpb3VzIHZhbHVlcyBhbmQgYXJlCiAgICAgICAgICAgICAgICAgLy9jYXVzaW5nIGludmFsaWQgdm9pY2UgbWFpbGJveCBpbmZvIGRpc3BsYXkgdG8gdXNlci4KLSAgICAgICAgICAgICAgICB2b2ljZU1haWxOdW0gPSBudWxsOwotICAgICAgICAgICAgICAgIHZvaWNlTWFpbFRhZyA9IG51bGw7CisgICAgICAgICAgICAgICAgbVZvaWNlTWFpbE51bSA9IG51bGw7CisgICAgICAgICAgICAgICAgbVZvaWNlTWFpbFRhZyA9IG51bGw7CiAgICAgICAgICAgICAgICAgaXNSZWNvcmRMb2FkUmVzcG9uc2UgPSB0cnVlOwogCiAgICAgICAgICAgICAgICAgYXIgPSAoQXN5bmNSZXN1bHQpbXNnLm9iajsKQEAgLTY1NCw3ICs2NzAsNyBAQAogICAgICAgICAgICAgICAgICAgICAgICAgLy9sb2FkIENQSFMgb24gZmFpbC4uLgogICAgICAgICAgICAgICAgICAgICAgICAgLy8gRklYTUUgcmlnaHQgbm93LCBvbmx5IGxvYWQgbGluZTEncyBDUEhTIHZvaWNlIG1haWwgZW50cnkKIAotICAgICAgICAgICAgICAgICAgICAgICAgcmVjb3Jkc1RvTG9hZCArPSAxOworICAgICAgICAgICAgICAgICAgICAgICAgbVJlY29yZHNUb0xvYWQgKz0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBBZG5SZWNvcmRMb2FkZXIobUZoKS5sb2FkRnJvbUVGKAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBFRl9NQUlMQk9YX0NQSFMsIEVGX0VYVDEsIDEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9idGFpbk1lc3NhZ2UoRVZFTlRfR0VUX0NQSFNfTUFJTEJPWF9ET05FKSk7CkBAIC02NzEsNyArNjg3LDcgQEAKICAgICAgICAgICAgICAgICAgICAgLy8gQnVnICM2NDU3NzAgZmFsbCBiYWNrIHRvIENQSFMKICAgICAgICAgICAgICAgICAgICAgLy8gRklYTUUgc2hvdWxkIHVzZSBTU1QgdG8gZGVjaWRlCiAgICAgICAgICAgICAgICAgICAgIC8vIEZJWE1FIHJpZ2h0IG5vdywgb25seSBsb2FkIGxpbmUxJ3MgQ1BIUyB2b2ljZSBtYWlsIGVudHJ5Ci0gICAgICAgICAgICAgICAgICAgIHJlY29yZHNUb0xvYWQgKz0gMTsKKyAgICAgICAgICAgICAgICAgICAgbVJlY29yZHNUb0xvYWQgKz0gMTsKICAgICAgICAgICAgICAgICAgICAgbmV3IEFkblJlY29yZExvYWRlcihtRmgpLmxvYWRGcm9tRUYoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRUZfTUFJTEJPWF9DUEhTLCBFRl9FWFQxLCAxLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9idGFpbk1lc3NhZ2UoRVZFTlRfR0VUX0NQSFNfTUFJTEJPWF9ET05FKSk7CkBAIC02NzksOCArNjk1LDggQEAKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgfQogCi0gICAgICAgICAgICAgICAgdm9pY2VNYWlsTnVtID0gYWRuLmdldE51bWJlcigpOwotICAgICAgICAgICAgICAgIHZvaWNlTWFpbFRhZyA9IGFkbi5nZXRBbHBoYVRhZygpOworICAgICAgICAgICAgICAgIG1Wb2ljZU1haWxOdW0gPSBhZG4uZ2V0TnVtYmVyKCk7CisgICAgICAgICAgICAgICAgbVZvaWNlTWFpbFRhZyA9IGFkbi5nZXRBbHBoYVRhZygpOwogICAgICAgICAgICAgYnJlYWs7CiAKICAgICAgICAgICAgIGNhc2UgRVZFTlRfR0VUX01TSVNETl9ET05FOgpAQCAtNjk1LDEwICs3MTEsMTAgQEAKIAogICAgICAgICAgICAgICAgIGFkbiA9IChBZG5SZWNvcmQpYXIucmVzdWx0OwogCi0gICAgICAgICAgICAgICAgbXNpc2RuID0gYWRuLmdldE51bWJlcigpOwotICAgICAgICAgICAgICAgIG1zaXNkblRhZyA9IGFkbi5nZXRBbHBoYVRhZygpOworICAgICAgICAgICAgICAgIG1Nc2lzZG4gPSBhZG4uZ2V0TnVtYmVyKCk7CisgICAgICAgICAgICAgICAgbU1zaXNkblRhZyA9IGFkbi5nZXRBbHBoYVRhZygpOwogCi0gICAgICAgICAgICAgICAgbG9nKCJNU0lTRE46ICIgKyAvKm1zaXNkbiovICJ4eHh4eHh4Iik7CisgICAgICAgICAgICAgICAgbG9nKCJNU0lTRE46ICIgKyAvKm1Nc2lzZG4qLyAieHh4eHh4eCIpOwogICAgICAgICAgICAgYnJlYWs7CiAKICAgICAgICAgICAgIGNhc2UgRVZFTlRfU0VUX01TSVNETl9ET05FOgpAQCAtNzI0LDcgKzc0MCw3IEBACiAKICAgICAgICAgICAgICAgICBsb2coIkVGX01XSVM6ICIgKyBJY2NVdGlscy5ieXRlc1RvSGV4U3RyaW5nKGRhdGEpKTsKIAotICAgICAgICAgICAgICAgIGVmTVdJUyA9IGRhdGE7CisgICAgICAgICAgICAgICAgbUVmTVdJUyA9IGRhdGE7CiAKICAgICAgICAgICAgICAgICBpZiAoKGRhdGFbMF0gJiAweGZmKSA9PSAweGZmKSB7CiAgICAgICAgICAgICAgICAgICAgIGxvZygiVW5pbml0aWFsaXplZCByZWNvcmQgTVdJUyIpOwpAQCAtNzMzLDExICs3NDksMTEgQEAKIAogICAgICAgICAgICAgICAgIC8vIFJlZmVyIFRTIDUxLjAxMSBTZWN0aW9uIDEwLjMuNDUgZm9yIHRoZSBjb250ZW50IGRlc2NyaXB0aW9uCiAgICAgICAgICAgICAgICAgYm9vbGVhbiB2b2ljZU1haWxXYWl0aW5nID0gKChkYXRhWzBdICYgMHgwMSkgIT0gMCk7Ci0gICAgICAgICAgICAgICAgY291bnRWb2ljZU1lc3NhZ2VzID0gZGF0YVsxXSAmIDB4ZmY7CisgICAgICAgICAgICAgICAgbUNvdW50Vm9pY2VNZXNzYWdlcyA9IGRhdGFbMV0gJiAweGZmOwogCi0gICAgICAgICAgICAgICAgaWYgKHZvaWNlTWFpbFdhaXRpbmcgJiYgY291bnRWb2ljZU1lc3NhZ2VzID09IDApIHsKKyAgICAgICAgICAgICAgICBpZiAodm9pY2VNYWlsV2FpdGluZyAmJiBtQ291bnRWb2ljZU1lc3NhZ2VzID09IDApIHsKICAgICAgICAgICAgICAgICAgICAgLy8gVW5rbm93biBjb3VudCA9IC0xCi0gICAgICAgICAgICAgICAgICAgIGNvdW50Vm9pY2VNZXNzYWdlcyA9IC0xOworICAgICAgICAgICAgICAgICAgICBtQ291bnRWb2ljZU1lc3NhZ2VzID0gLTE7CiAgICAgICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAgICAgbVJlY29yZHNFdmVudHNSZWdpc3RyYW50cy5ub3RpZnlSZXN1bHQoRVZFTlRfTVdJKTsKQEAgLTc1MywyMCArNzY5LDIwIEBACiAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgICAgIGVmQ1BIU19NV0kgPSBkYXRhOworICAgICAgICAgICAgICAgIG1FZkNQSFNfTVdJID0gZGF0YTsKIAogICAgICAgICAgICAgICAgIC8vIFVzZSB0aGlzIGRhdGEgaWYgdGhlIEVGW01XSVNdIGV4aXN0cyBhbmQKICAgICAgICAgICAgICAgICAvLyBoYXMgYmVlbiBsb2FkZWQKIAotICAgICAgICAgICAgICAgIGlmIChlZk1XSVMgPT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICBpbnQgaW5kaWNhdG9yID0gKGludCkoZGF0YVswXSAmIDB4Zik7CisgICAgICAgICAgICAgICAgaWYgKG1FZk1XSVMgPT0gbnVsbCkgeworICAgICAgICAgICAgICAgICAgICBpbnQgaW5kaWNhdG9yID0gZGF0YVswXSAmIDB4ZjsKIAogICAgICAgICAgICAgICAgICAgICAvLyBSZWZlciBDUEhTNF8yLldXNiBCNC4yLjMKICAgICAgICAgICAgICAgICAgICAgaWYgKGluZGljYXRvciA9PSAweEEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIC8vIFVua25vd24gY291bnQgPSAtMQotICAgICAgICAgICAgICAgICAgICAgICAgY291bnRWb2ljZU1lc3NhZ2VzID0gLTE7CisgICAgICAgICAgICAgICAgICAgICAgICBtQ291bnRWb2ljZU1lc3NhZ2VzID0gLTE7CiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5kaWNhdG9yID09IDB4NSkgewotICAgICAgICAgICAgICAgICAgICAgICAgY291bnRWb2ljZU1lc3NhZ2VzID0gMDsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1Db3VudFZvaWNlTWVzc2FnZXMgPSAwOwogICAgICAgICAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgICAgICAgICAgbVJlY29yZHNFdmVudHNSZWdpc3RyYW50cy5ub3RpZnlSZXN1bHQoRVZFTlRfTVdJKTsKQEAgLTc4Myw5ICs3OTksOSBAQAogICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgICAgICBpY2NpZCA9IEljY1V0aWxzLmJjZFRvU3RyaW5nKGRhdGEsIDAsIGRhdGEubGVuZ3RoKTsKKyAgICAgICAgICAgICAgICBpY2NJZCA9IEljY1V0aWxzLmJjZFRvU3RyaW5nKGRhdGEsIDAsIGRhdGEubGVuZ3RoKTsKIAotICAgICAgICAgICAgICAgIGxvZygiaWNjaWQ6ICIgKyBpY2NpZCk7CisgICAgICAgICAgICAgICAgbG9nKCJpY2NpZDogIiArIGljY0lkKTsKIAogICAgICAgICAgICAgYnJlYWs7CiAKQEAgLTgxMyw0NSArODI5LDQ1IEBACiAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgfQogCi0gICAgICAgICAgICAgICAgICAgIG1uY0xlbmd0aCA9IChpbnQpZGF0YVszXSAmIDB4ZjsKKyAgICAgICAgICAgICAgICAgICAgbU1uY0xlbmd0aCA9IGRhdGFbM10gJiAweGY7CiAKLSAgICAgICAgICAgICAgICAgICAgaWYgKG1uY0xlbmd0aCA9PSAweGYpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIG1uY0xlbmd0aCA9IFVOS05PV047CisgICAgICAgICAgICAgICAgICAgIGlmIChtTW5jTGVuZ3RoID09IDB4ZikgeworICAgICAgICAgICAgICAgICAgICAgICAgbU1uY0xlbmd0aCA9IFVOS05PV047CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9IGZpbmFsbHkgewotICAgICAgICAgICAgICAgICAgICBpZiAoKChtbmNMZW5ndGggPT0gVU5JTklUSUFMSVpFRCkgfHwgKG1uY0xlbmd0aCA9PSBVTktOT1dOKSB8fAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIChtbmNMZW5ndGggPT0gMikpICYmICgobUltc2kgIT0gbnVsbCkgJiYgKG1JbXNpLmxlbmd0aCgpID49IDYpKSkgeworICAgICAgICAgICAgICAgICAgICBpZiAoKChtTW5jTGVuZ3RoID09IFVOSU5JVElBTElaRUQpIHx8IChtTW5jTGVuZ3RoID09IFVOS05PV04pIHx8CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgKG1NbmNMZW5ndGggPT0gMikpICYmICgobUltc2kgIT0gbnVsbCkgJiYgKG1JbXNpLmxlbmd0aCgpID49IDYpKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nIG1jY21uY0NvZGUgPSBtSW1zaS5zdWJzdHJpbmcoMCwgNik7CiAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKFN0cmluZyBtY2NtbmMgOiBNQ0NNTkNfQ09ERVNfSEFWSU5HXzNESUdJVFNfTU5DKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1jY21uYy5lcXVhbHMobWNjbW5jQ29kZSkpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbW5jTGVuZ3RoID0gMzsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbU1uY0xlbmd0aCA9IDM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgfQogCi0gICAgICAgICAgICAgICAgICAgIGlmIChtbmNMZW5ndGggPT0gVU5LTk9XTiB8fCBtbmNMZW5ndGggPT0gVU5JTklUSUFMSVpFRCkgeworICAgICAgICAgICAgICAgICAgICBpZiAobU1uY0xlbmd0aCA9PSBVTktOT1dOIHx8IG1NbmNMZW5ndGggPT0gVU5JTklUSUFMSVpFRCkgewogICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1JbXNpICE9IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgbWNjID0gSW50ZWdlci5wYXJzZUludChtSW1zaS5zdWJzdHJpbmcoMCwzKSk7CiAKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbW5jTGVuZ3RoID0gTWNjVGFibGUuc21hbGxlc3REaWdpdHNNY2NGb3JNbmMobWNjKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbU1uY0xlbmd0aCA9IE1jY1RhYmxlLnNtYWxsZXN0RGlnaXRzTWNjRm9yTW5jKG1jYyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoTnVtYmVyRm9ybWF0RXhjZXB0aW9uIGUpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbW5jTGVuZ3RoID0gVU5LTk9XTjsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbU1uY0xlbmd0aCA9IFVOS05PV047CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvZ2UoIkNvcnJ1cHQgSU1TSSEiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIEluZGljYXRlIHdlIGdvdCB0aGlzIGluZm8sIGJ1dCBpdCBkaWRuJ3QgY29udGFpbiB0aGUgbGVuZ3RoLgotICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1uY0xlbmd0aCA9IFVOS05PV047CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbU1uY0xlbmd0aCA9IFVOS05PV047CiAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2coIk1OQyBsZW5ndGggbm90IHByZXNlbnQgaW4gRUZfQUQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBpZiAobUltc2kgIT0gbnVsbCAmJiBtbmNMZW5ndGggIT0gVU5LTk9XTikgeworICAgICAgICAgICAgICAgICAgICBpZiAobUltc2kgIT0gbnVsbCAmJiBtTW5jTGVuZ3RoICE9IFVOS05PV04pIHsKICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGZpbmFsbHkgaGF2ZSBib3RoIGltc2kgYW5kIHRoZSBsZW5ndGggb2YgdGhlIG1uYyBhbmQgY2FuIHBhcnNlCiAgICAgICAgICAgICAgICAgICAgICAgICAvLyB0aGUgaW1zaSBwcm9wZXJseQogICAgICAgICAgICAgICAgICAgICAgICAgTWNjVGFibGUudXBkYXRlTWNjTW5jQ29uZmlndXJhdGlvbihtQ29udGV4dCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUltc2kuc3Vic3RyaW5nKDAsIDMgKyBtbmNMZW5ndGgpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUltc2kuc3Vic3RyaW5nKDAsIDMgKyBtTW5jTGVuZ3RoKSk7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICBicmVhazsKQEAgLTg3Niw3ICs4OTIsNyBAQAogICAgICAgICAgICAgICAgIG1FZkNmZiA9IGRhdGE7CiAKICAgICAgICAgICAgICAgICBpZiAodmFsaWRFZkNmaXMobUVmQ2ZpcykpIHsKLSAgICAgICAgICAgICAgICAgICAgY2FsbEZvcndhcmRpbmdFbmFibGVkID0KKyAgICAgICAgICAgICAgICAgICAgbUNhbGxGb3J3YXJkaW5nRW5hYmxlZCA9CiAgICAgICAgICAgICAgICAgICAgICAgICAoKGRhdGFbMF0gJiBDRkZfTElORTFfTUFTSykgPT0gQ0ZGX1VOQ09ORElUSU9OQUxfQUNUSVZFKTsKIAogICAgICAgICAgICAgICAgICAgICBtUmVjb3Jkc0V2ZW50c1JlZ2lzdHJhbnRzLm5vdGlmeVJlc3VsdChFVkVOVF9DRkkpOwpAQCAtOTIwLDcgKzkzNiw3IEBACiAKICAgICAgICAgICAgICAgICBmb3IgKCA7IHRsdi5pc1ZhbGlkT2JqZWN0KCkgOyB0bHYubmV4dE9iamVjdCgpKSB7CiAgICAgICAgICAgICAgICAgICAgIGlmICh0bHYuZ2V0VGFnKCkgPT0gVEFHX0ZVTExfTkVUV09SS19OQU1FKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBwbm5Ib21lTmFtZQorICAgICAgICAgICAgICAgICAgICAgICAgbVBubkhvbWVOYW1lCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPSBJY2NVdGlscy5uZXR3b3JrTmFtZVRvU3RyaW5nKAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bHYuZ2V0RGF0YSgpLCAwLCB0bHYuZ2V0RGF0YSgpLmxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKQEAgLTkzNSw3ICs5NTEsNyBAQAogICAgICAgICAgICAgICAgIGlmIChhci5leGNlcHRpb24gIT0gbnVsbCkKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAKLSAgICAgICAgICAgICAgICBoYW5kbGVTbXNlcygoQXJyYXlMaXN0KSBhci5yZXN1bHQpOworICAgICAgICAgICAgICAgIGhhbmRsZVNtc2VzKChBcnJheUxpc3Q8Ynl0ZSBbXT4pIGFyLnJlc3VsdCk7CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAKICAgICAgICAgICAgIGNhc2UgRVZFTlRfTUFSS19TTVNfUkVBRF9ET05FOgpAQCAtMTAwMiwxMiArMTAxOCwxMiBAQAogICAgICAgICAgICAgICAgIGFyID0gKEFzeW5jUmVzdWx0KW1zZy5vYmo7CiAKICAgICAgICAgICAgICAgICBpZiAoYXIuZXhjZXB0aW9uID09IG51bGwpIHsKLSAgICAgICAgICAgICAgICAgICAgdm9pY2VNYWlsTnVtID0gbmV3Vm9pY2VNYWlsTnVtOwotICAgICAgICAgICAgICAgICAgICB2b2ljZU1haWxUYWcgPSBuZXdWb2ljZU1haWxUYWc7CisgICAgICAgICAgICAgICAgICAgIG1Wb2ljZU1haWxOdW0gPSBtTmV3Vm9pY2VNYWlsTnVtOworICAgICAgICAgICAgICAgICAgICBtVm9pY2VNYWlsVGFnID0gbU5ld1ZvaWNlTWFpbFRhZzsKICAgICAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgICAgICBpZiAoaXNDcGhzTWFpbGJveEVuYWJsZWQoKSkgewotICAgICAgICAgICAgICAgICAgICBhZG4gPSBuZXcgQWRuUmVjb3JkKHZvaWNlTWFpbFRhZywgdm9pY2VNYWlsTnVtKTsKKyAgICAgICAgICAgICAgICAgICAgYWRuID0gbmV3IEFkblJlY29yZChtVm9pY2VNYWlsVGFnLCBtVm9pY2VNYWlsTnVtKTsKICAgICAgICAgICAgICAgICAgICAgTWVzc2FnZSBvbkNwaHNDb21wbGV0ZWQgPSAoTWVzc2FnZSkgYXIudXNlck9iajsKIAogICAgICAgICAgICAgICAgICAgICAvKiB3cml0ZSB0byBjcGhzIG1haWxib3ggd2hlbmV2ZXIgaXQgaXMgYXZhaWxhYmxlIGJ1dApAQCAtMTA0Myw4ICsxMDU5LDggQEAKICAgICAgICAgICAgICAgICBpc1JlY29yZExvYWRSZXNwb25zZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgIGFyID0gKEFzeW5jUmVzdWx0KW1zZy5vYmo7CiAgICAgICAgICAgICAgICAgaWYoYXIuZXhjZXB0aW9uID09IG51bGwpIHsKLSAgICAgICAgICAgICAgICAgICAgdm9pY2VNYWlsTnVtID0gbmV3Vm9pY2VNYWlsTnVtOwotICAgICAgICAgICAgICAgICAgICB2b2ljZU1haWxUYWcgPSBuZXdWb2ljZU1haWxUYWc7CisgICAgICAgICAgICAgICAgICAgIG1Wb2ljZU1haWxOdW0gPSBtTmV3Vm9pY2VNYWlsTnVtOworICAgICAgICAgICAgICAgICAgICBtVm9pY2VNYWlsVGFnID0gbU5ld1ZvaWNlTWFpbFRhZzsKICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coIlNldCBDUEhTIE1haWxCb3ggd2l0aCBleGNlcHRpb246ICIKICAgICAgICAgICAgICAgICAgICAgICAgICAgICArIGFyLmV4Y2VwdGlvbik7CkBAIC0xMDgwLDggKzEwOTYsOCBAQAogICAgICAgICAgICAgICAgICAgICBtRWZDZmlzID0gZGF0YTsKIAogICAgICAgICAgICAgICAgICAgICAvLyBSZWZlciBUUyA1MS4wMTEgU2VjdGlvbiAxMC4zLjQ2IGZvciB0aGUgY29udGVudCBkZXNjcmlwdGlvbgotICAgICAgICAgICAgICAgICAgICBjYWxsRm9yd2FyZGluZ0VuYWJsZWQgPSAoKGRhdGFbMV0gJiAweDAxKSAhPSAwKTsKLSAgICAgICAgICAgICAgICAgICAgbG9nKCJFRl9DRklTOiBjYWxsRm9yZHdhcmRpbmdFbmFibGVkPSIgKyBjYWxsRm9yd2FyZGluZ0VuYWJsZWQpOworICAgICAgICAgICAgICAgICAgICBtQ2FsbEZvcndhcmRpbmdFbmFibGVkID0gKChkYXRhWzFdICYgMHgwMSkgIT0gMCk7CisgICAgICAgICAgICAgICAgICAgIGxvZygiRUZfQ0ZJUzogY2FsbEZvcmR3YXJkaW5nRW5hYmxlZD0iICsgbUNhbGxGb3J3YXJkaW5nRW5hYmxlZCk7CiAKICAgICAgICAgICAgICAgICAgICAgbVJlY29yZHNFdmVudHNSZWdpc3RyYW50cy5ub3RpZnlSZXN1bHQoRVZFTlRfQ0ZJKTsKICAgICAgICAgICAgICAgICB9IGVsc2UgewpAQCAtMTEyMiwxNyArMTEzOCwxNyBAQAogICAgIHByaXZhdGUgdm9pZCBoYW5kbGVGaWxlVXBkYXRlKGludCBlZmlkKSB7CiAgICAgICAgIHN3aXRjaChlZmlkKSB7CiAgICAgICAgICAgICBjYXNlIEVGX01CRE46Ci0gICAgICAgICAgICAgICAgcmVjb3Jkc1RvTG9hZCsrOworICAgICAgICAgICAgICAgIG1SZWNvcmRzVG9Mb2FkKys7CiAgICAgICAgICAgICAgICAgbmV3IEFkblJlY29yZExvYWRlcihtRmgpLmxvYWRGcm9tRUYoRUZfTUJETiwgRUZfRVhUNiwKLSAgICAgICAgICAgICAgICAgICAgICAgIG1haWxib3hJbmRleCwgb2J0YWluTWVzc2FnZShFVkVOVF9HRVRfTUJETl9ET05FKSk7CisgICAgICAgICAgICAgICAgICAgICAgICBtTWFpbGJveEluZGV4LCBvYnRhaW5NZXNzYWdlKEVWRU5UX0dFVF9NQkROX0RPTkUpKTsKICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIGNhc2UgRUZfTUFJTEJPWF9DUEhTOgotICAgICAgICAgICAgICAgIHJlY29yZHNUb0xvYWQrKzsKKyAgICAgICAgICAgICAgICBtUmVjb3Jkc1RvTG9hZCsrOwogICAgICAgICAgICAgICAgIG5ldyBBZG5SZWNvcmRMb2FkZXIobUZoKS5sb2FkRnJvbUVGKEVGX01BSUxCT1hfQ1BIUywgRUZfRVhUMSwKICAgICAgICAgICAgICAgICAgICAgICAgIDEsIG9idGFpbk1lc3NhZ2UoRVZFTlRfR0VUX0NQSFNfTUFJTEJPWF9ET05FKSk7CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICBjYXNlIEVGX0NTUF9DUEhTOgotICAgICAgICAgICAgICAgIHJlY29yZHNUb0xvYWQrKzsKKyAgICAgICAgICAgICAgICBtUmVjb3Jkc1RvTG9hZCsrOwogICAgICAgICAgICAgICAgIGxvZygiW0NTUF0gU0lNIFJlZnJlc2ggZm9yIEVGX0NTUF9DUEhTIik7CiAgICAgICAgICAgICAgICAgbUZoLmxvYWRFRlRyYW5zcGFyZW50KEVGX0NTUF9DUEhTLAogICAgICAgICAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZShFVkVOVF9HRVRfQ1NQX0NQSFNfRE9ORSkpOwpAQCAtMTE0MSw3ICsxMTU3LDcgQEAKICAgICAgICAgICAgICAgICAvLyBGb3Igbm93LCBmZXRjaCBhbGwgcmVjb3JkcyBpZiB0aGlzIGlzIG5vdCBhCiAgICAgICAgICAgICAgICAgLy8gdm9pY2VtYWlsIG51bWJlci4KICAgICAgICAgICAgICAgICAvLyBUT0RPOiBIYW5kbGUgb3RoZXIgY2FzZXMsIGluc3RlYWQgb2YgZmV0Y2hpbmcgYWxsLgotICAgICAgICAgICAgICAgIGFkbkNhY2hlLnJlc2V0KCk7CisgICAgICAgICAgICAgICAgbUFkbkNhY2hlLnJlc2V0KCk7CiAgICAgICAgICAgICAgICAgZmV0Y2hTaW1SZWNvcmRzKCk7CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIH0KQEAgLTExNjcsNyArMTE4Myw3IEBACiAgICAgICAgICAgICBjYXNlIEljY1JlZnJlc2hSZXNwb25zZS5SRUZSRVNIX1JFU1VMVF9JTklUOgogICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygiaGFuZGxlU2ltUmVmcmVzaCB3aXRoIFNJTV9SRUZSRVNIX0lOSVQiKTsKICAgICAgICAgICAgICAgICAvLyBuZWVkIHRvIHJlbG9hZCBhbGwgZmlsZXMgKHRoYXQgd2UgY2FyZSBhYm91dCkKLSAgICAgICAgICAgICAgICBhZG5DYWNoZS5yZXNldCgpOworICAgICAgICAgICAgICAgIG1BZG5DYWNoZS5yZXNldCgpOwogICAgICAgICAgICAgICAgIGZldGNoU2ltUmVjb3JkcygpOwogICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgY2FzZSBJY2NSZWZyZXNoUmVzcG9uc2UuUkVGUkVTSF9SRVNVTFRfUkVTRVQ6CkBAIC0xMjE4LDExICsxMjM0LDExIEBACiAgICAgfQogCiAKLSAgICBwcml2YXRlIHZvaWQgaGFuZGxlU21zZXMoQXJyYXlMaXN0IG1lc3NhZ2VzKSB7CisgICAgcHJpdmF0ZSB2b2lkIGhhbmRsZVNtc2VzKEFycmF5TGlzdDxieXRlW10+IG1lc3NhZ2VzKSB7CiAgICAgICAgIGludCBjb3VudCA9IG1lc3NhZ2VzLnNpemUoKTsKIAogICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IGNvdW50OyBpKyspIHsKLSAgICAgICAgICAgIGJ5dGVbXSBiYSA9IChieXRlW10pIG1lc3NhZ2VzLmdldChpKTsKKyAgICAgICAgICAgIGJ5dGVbXSBiYSA9IG1lc3NhZ2VzLmdldChpKTsKIAogICAgICAgICAgICAgaWYgKGJhWzBdICE9IDApCiAgICAgICAgICAgICAgICAgUmxvZy5pKCJFTkYiLCAic3RhdHVzICIgKyBpICsgIjogIiArIGJhWzBdKTsKQEAgLTEyNDYsNyArMTI2Miw3IEBACiAKICAgICAgICAgICAgICAgICBiYVswXSA9IDE7CiAKLSAgICAgICAgICAgICAgICBpZiAoZmFsc2UpIHsgLy8gWFhYIHdyaXRpbmcgc2VlbXMgdG8gY3Jhc2ggUmRvU2VydkQKKyAgICAgICAgICAgICAgICBpZiAoZmFsc2UpIHsgLy8gRklYTUU6IHdyaXRpbmcgc2VlbXMgdG8gY3Jhc2ggUmRvU2VydkQKICAgICAgICAgICAgICAgICAgICAgbUZoLnVwZGF0ZUVGTGluZWFyRml4ZWQoRUZfU01TLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGksIGJhLCBudWxsLCBvYnRhaW5NZXNzYWdlKEVWRU5UX01BUktfU01TX1JFQURfRE9ORSwgaSkpOwogICAgICAgICAgICAgICAgIH0KQEAgLTEyNTQsMjAgKzEyNzAsMjIgQEAKICAgICAgICAgfQogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHByb3RlY3RlZCB2b2lkIG9uUmVjb3JkTG9hZGVkKCkgewogICAgICAgICAvLyBPbmUgcmVjb3JkIGxvYWRlZCBzdWNjZXNzZnVsbHkgb3IgZmFpbGVkLCBJbiBlaXRoZXIgY2FzZQogICAgICAgICAvLyB3ZSBuZWVkIHRvIHVwZGF0ZSB0aGUgcmVjb3Jkc1RvTG9hZCBjb3VudAotICAgICAgICByZWNvcmRzVG9Mb2FkIC09IDE7Ci0gICAgICAgIGlmIChEQkcpIGxvZygib25SZWNvcmRMb2FkZWQgIiArIHJl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VtcHR5KG1TcG4pIHx8IG1TcG5EaXNwbGF5Q29uZGl0aW9uID09IC0xKSB7CiAgICAgICAgICAgICAvLyBObyBFRl9TUE4gY29udGVudCB3YXMgZm91bmQgb24gdGhlIFNJTSwgb3Igbm90IHlldCBsb2FkZWQuICBKdXN0IHNob3cgT05TLgogICAgICAgICAgICAgcnVsZSA9IFNQTl9SVUxFX1NIT1dfUExNTjsKICAgICAgICAgfSBlbHNlIGlmIChpc09uTWF0Y2hpbmdQbG1uKHBsbW4pKSB7CiAgICAgICAgICAgICBydWxlID0gU1BOX1JVTEVfU0hPV19TUE47Ci0gICAgICAgICAgICBpZiAoKHNwbkRpc3BsYXlDb25kaXRpb24gJiAweDAxKSA9PSAweDAxKSB7CisgICAgICAgICAgICBpZiAoKG1TcG5EaXNwbGF5Q29uZGl0aW9uICYgMHgwMSkgPT0gMHgwMSkgewogICAgICAgICAgICAgICAgIC8vIE9OUyByZXF1aXJlZCB3aGVuIHJlZ2lzdGVyZWQgdG8gSFBMTU4gb3IgUExNTiBpbiBFRl9TUERJCiAgICAgICAgICAgICAgICAgcnVsZSB8PSBTUE5fUlVMRV9TSE9XX1BMTU47CiAgICAgICAgICAgICB9CiAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICBydWxlID0gU1BOX1JVTEVfU0hPV19QTE1OOwotICAgICAgICAgICAgaWYgKChzcG5EaXNwbGF5Q29uZGl0aW9uICYgMHgwMikgPT0gMHgwMCkgeworICAgICAgICAgICAgaWYgKChtU3BuRGlzcGxheUNvbmRpdGlvbiAmIDB4MDIpID09IDB4MDApIHsKICAgICAgICAgICAgICAgICAvLyBTUE4gcmVxdWlyZWQgaWYgbm90IHJlZ2lzdGVyZWQgdG8gSFBMTU4gb3IgUExNTiBpbiBFRl9TUERJCiAgICAgICAgICAgICAgICAgcnVsZSB8PSBTUE5fUlVMRV9TSE9XX1NQTjsKICAgICAgICAgICAgIH0KQEAgLTE0MzgsOCArMTQ1Niw4IEBACiAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgfQogCi0gICAgICAgIGlmIChzcGRpTmV0d29ya3MgIT0gbnVsbCkgewotICAgICAgICAgICAgZm9yIChTdHJpbmcgc3BkaU5ldCA6IHNwZGlOZXR3b3JrcykgeworICAgICAgICBpZiAobVNwZGlOZXR3b3JrcyAhPSBudWxsKSB7CisgICAgICAgICAgICBmb3IgKFN0cmluZyBzcGRpTmV0IDogbVNwZGlOZXR3b3JrcykgewogICAgICAgICAgICAgICAgIGlmIChwbG1uLmVxdWFscyhzcGRpTmV0KSkgewogICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICB9CkBAIC0xNDUxLDcgKzE0NjksNyBAQAogICAgIC8qKgogICAgICAqIFN0YXRlcyBvZiBHZXQgU1BOIEZpbml0ZSBTdGF0ZSBNYWNoaW5lIHdoaWNoIG9ubHkgdXNlZCBieSBnZXRTcG5Gc20oKQogICAgICAqLwotICAgIHByaXZhdGUgZW51bSBHZXRfU3BuX0ZzbV9TdGF0ZSB7CisgICAgcHJpdmF0ZSBlbnVtIEdldFNwbkZzbVN0YXRlIHsKICAgICAgICAgSURMRSwgICAgICAgICAgICAgICAvLyBObyBpbml0aWFsaXplZAogICAgICAgICBJTklULCAgICAgICAgICAgICAgIC8vIFN0YXJ0IEZTTQogICAgICAgICBSRUFEX1NQTl8zR1BQLCAgICAgIC8vIExvYWQgRUZfU1BOIGZpcnN0bHkKQEAgLTE0ODIsODQgKzE1MDAsODQgQEAKICAgICAgICAgaWYgKHN0YXJ0KSB7CiAgICAgICAgICAgICAvLyBDaGVjayBwcmV2aW91cyBzdGF0ZSB0byBzZWUgaWYgdGhlcmUgaXMgb3V0c3RhbmRpbmcKICAgICAgICAgICAgIC8vIFNQTiByZWFkCi0gICAgICAgICAgICBpZihzcG5TdGF0ZSA9PSBHZXRfU3BuX0ZzbV9TdGF0ZS5SRUFEX1NQTl8zR1BQIHx8Ci0gICAgICAgICAgICAg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ZSl7CisgICAgICAgIHN3aXRjaChtU3BuU3RhdGUpewogICAgICAgICAgICAgY2FzZSBJTklUOgotICAgICAgICAgICAgICAgIHNwbiA9IG51bGw7CisgICAgICAgICAgICAgICAgbVNwbiA9IG51bGw7CiAKICAgICAgICAgICAgICAgICBtRmgubG9hZEVGVHJhbnNwYXJlbnQoRUZfU1BOLAogICAgICAgICAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZShFVkVOVF9HRVRfU1BOX0RPTkUpKTsKLSAgICAgICAgICAgICAgICByZWNvcmRzVG9Mb2FkKys7CisgICAgICAgICAgICAgICAgbVJlY29yZHNUb0xvYWQrKzsKIAotICAgICAgICAgICAgICAgIHNwblN0YXRlID0gR2V0X1Nwbl9Gc21fU3RhdGUuUkVBRF9TUE5fM0dQUDsKKyAgICAgICAgICAgICAgICBtU3BuU3RhdGUgPSBHZXRTcG5Gc21TdGF0ZS5SRUFEX1NQTl8zR1BQOwogICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgY2FzZSBSRUFEX1NQTl8zR1BQOgogICAgICAgICAgICAgICAgIGlmIChhciAhPSBudWxsICYmIGFyLmV4Y2VwdGlvbiA9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgIGRhdGEgPSAoYnl0ZVtdKSBhci5yZXN1bHQ7Ci0gICAgICAgICAgICAgICAgICAgIHNwbkRpc3BsYXlDb25kaXRpb24gPSAweGZmICYgZGF0YVswXTsKLSAgICAgICAgICAgICAgICAgICAgc3BuID0gSWNjVXRpbHMuYWRuU3RyaW5nRmllbGRUb1N0cmluZyhkYXRhLCAxLCBkYXRhLmxlbmd0aCAtIDEpOworICAgICAgICAgICAgICAgICAgICBtU3BuRGlzcGxheUNvbmRpdGlvbiA9IDB4ZmYgJiBkYXRhWzBdOworICAgICAgICAgICAgICAgICAgICBtU3BuID0gSWNjVXRpbHMuYWRuU3RyaW5nRmllbGRUb1N0cmluZyhkYXRhLCAxLCBkYXRhLmxlbmd0aCAtIDEpOwogCi0gICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygiTG9hZCBFRl9TUE46ICIgKyBzcG4KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICArICIgc3BuRGlzcGxheUNvbmRpdGlvbjogIiArIHNwbkRpc3BsYXlDb25kaXRpb24pOwotICAgICAgICAgICAgICAgICAgICBTeXN0ZW1Qcm9wZXJ0aWVzLnNldChQUk9QRVJUWV9JQ0NfT1BFUkFUT1JfQUxQSEEsIHNwbik7CisgICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygiTG9hZCBFRl9TUE46ICIgKyBtU3BuCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyAiIHNwbkRpc3BsYXlDb25kaXRpb246ICIgKyBtU3BuRGlzcGxheUNvbmRpdGlvbik7CisgICAgICAgICAgICAgICAgICAgIFN5c3RlbVByb3BlcnRpZXMuc2V0KFBST1BFUlRZX0lDQ19PUEVSQVRPUl9BTFBIQSwgbVNwbik7CiAKLSAgICAgICAgICAgICAgICAgICAgc3BuU3RhdGUgPSBHZXRfU3BuX0ZzbV9TdGF0ZS5JRExFOworICAgICAgICAgICAgICAgICAgICBtU3BuU3RhdGUgPSBHZXRTcG5Gc21TdGF0ZS5JRExFOwogICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgIG1GaC5sb2FkRUZUcmFuc3BhcmVudCggRUZfU1BOX0NQSFMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2J0YWluTWVzc2FnZShFVkVOVF9HRVRfU1BOX0RPTkUpKTsKLSAgICAgICAgICAgICAgICAgICAgcmVjb3Jkc1RvTG9hZCsrOworICAgICAgICAgICAgICAgICAgICBtUmVjb3Jkc1RvTG9hZCsrOwogCi0gICAgICAgICAgICAgICAgICAgIHNwblN0YXRlID0gR2V0X1Nwbl9Gc21fU3RhdGUuUkVBRF9TUE5fQ1BIUzsKKyAgICAgICAgICAgICAgICAgICAgbVNwblN0YXRlID0gR2V0U3BuRnNtU3RhdGUuUkVBRF9TUE5fQ1BIUzsKIAogICAgICAgICAgICAgICAgICAgICAvLyBTZWUgVFMgNTEuMDExIDEwLjMuMTEuICBCYXNpY2FsbHksIGRlZmF1bHQgdG8KICAgICAgICAgICAgICAgICAgICAgLy8gc2hvdyBQTE1OIGFsd2F5cywgYW5kIFNQTiBhbHNvIGlmIHJvYW1pbmcuCi0gICAgICAgICAgICAgICAgICAgIHNwbkRpc3BsYXlDb25kaXRpb24gPSAtMTsKKyAgICAgICAgICAgICAgICAgICAgbVNwbkRpc3BsYXlDb25kaXRpb24gPSAtMTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICBjYXNlIFJFQURfU1BOX0NQSFM6CiAgICAgICAgICAgICAgICAgaWYgKGFyICE9IG51bGwgJiYgYXIuZXhjZXB0aW9uID09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgZGF0YSA9IChieXRlW10pIGFyLnJlc3VsdDsKLSAgICAgICAgICAgICAgICAgICAgc3BuID0gSWNjVXRpbHMuYWRuU3RyaW5nRmllbGRUb1N0cmluZyhkYXRhLCAwLCBkYXRhLmxlbmd0aCk7CisgICAgICAgICAgICAgICAgICAgIG1TcG4gPSBJY2NVdGlscy5hZG5TdHJpbmdGaWVsZFRvU3RyaW5nKGRhdGEsIDAsIGRhdGEubGVuZ3RoKTsKIAotICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coIkxvYWQgRUZfU1BOX0NQSFM6ICIgKyBzcG4pOwotICAgICAgICAgICAgICAgICAgICBTeXN0ZW1Qcm9wZXJ0aWVzLnNldChQUk9QRVJUWV9JQ0NfT1BFUkFUT1JfQUxQSEEsIHNwbik7CisgICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygiTG9hZCBFRl9TUE5fQ1BIUzogIiArIG1TcG4pOworICAgICAgICAgICAgICAgICAgICBTeXN0ZW1Qcm9wZXJ0aWVzLnNldChQUk9QRVJUWV9JQ0NfT1BFUkFUT1JfQUxQSEEsIG1TcG4pOwogCi0gICAgICAgICAgICAgICAgICAgIHNwblN0YXRlID0gR2V0X1Nwbl9Gc21fU3RhdGUuSURMRTsKKyAgICAgICAgICAgICAgICAgICAgbVNwblN0YXRlID0gR2V0U3BuRnNtU3RhdGUuSURMRTsKICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICBtRmgubG9hZEVGVHJhbnNwYXJlbnQoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRUZfU1BOX1NIT1JUX0NQSFMsIG9idGFpbk1lc3NhZ2UoRVZFTlRfR0VUX1NQTl9ET05FKSk7Ci0gICAgICAgICAgICAgICAgICAgIHJlY29yZHNUb0xvYWQrKzsKKyAgICAgICAgICAgICAgICAgICAgbVJlY29yZHNUb0xvYWQrKzsKIAotICAgICAgICAgICAgICAgICAgICBzcG5TdGF0ZSA9IEdldF9TcG5fRnNtX1N0YXRlLlJFQURfU1BOX1NIT1JUX0NQSFM7CisgICAgICAgICAgICAgICAgICAgIG1TcG5TdGF0ZSA9IEdldFNwbkZzbVN0YXRlLlJFQURfU1BOX1NIT1JUX0NQSFM7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgY2FzZSBSRUFEX1NQTl9TSE9SVF9DUEhTOgogICAgICAgICAgICAgICAgIGlmIChhciAhPSBudWxsICYmIGFyLmV4Y2VwdGlvbiA9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgIGRhdGEgPSAoYnl0ZVtdKSBhci5yZXN1bHQ7Ci0gICAgICAgICAgICAgICAgICAgIHNwbiA9IEljY1V0aWxzLmFkblN0cmluZ0ZpZWxkVG9TdHJpbmcoZGF0YSwgMCwgZGF0YS5sZW5ndGgpOworICAgICAgICAgICAgICAgICAgICBtU3BuID0gSWNjVXRpbHMuYWRuU3RyaW5nRmllbGRUb1N0cmluZyhkYXRhLCAwLCBkYXRhLmxlbmd0aCk7CiAKLSAgICAgICAgICAgICAgICAgICAgaWYgKERCRykgbG9nKCJMb2FkIEVGX1NQTl9TSE9SVF9DUEhTOiAiICsgc3BuKTsKLSAgICAgICAgICAgICAgICAgICAgU3lzdGVtUHJvcGVydGllcy5zZXQoUFJPUEVSVFlfSUNDX09QRVJBVE9SX0FMUEhBLCBzcG4pOworICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coIkxvYWQgRUZfU1BOX1NIT1JUX0NQSFM6ICIgKyBtU3BuKTsKKyAgICAgICAgICAgICAgICAgICAgU3lzdGVtUHJvcGVydGllcy5zZXQoUFJPUEVSVFlfSUNDX09QRVJBVE9SX0FMUEhBLCBtU3BuKTsKICAgICAgICAgICAgICAgICB9ZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgIGlmIChEQkcpIGxvZygiTm8gU1BOIGxvYWRlZCBpbiBlaXRoZXIgQ0hQUyBvciAzR1BQIik7CiAgICAgICAgICAgICAgICAgfQogCi0gICAgICAgICAgICAgICAgc3BuU3RhdGUgPSBHZXRfU3BuX0ZzbV9TdGF0ZS5JRExFOworICAgICAgICAgICAgICAgIG1TcG5TdGF0ZSA9IEdldFNwbkZzbVN0YXRlLklETEU7CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICBkZWZhdWx0OgotICAgICAgICAgICAgICAgIHNwblN0YXRlID0gR2V0X1Nwbl9Gc21fU3RhdGUuSURMRTsKKyAgICAgICAgICAgICAgICBtU3BuU3RhdGUgPSBHZXRTcG5Gc21TdGF0ZS5JRExFOwogICAgICAgICB9CiAgICAgfQogCkBAIC0xNTkwLDcgKzE2MDgsNyBAQAogICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICB9CiAKLSAgICAgICAgc3BkaU5ldHdvcmtzID0gbmV3IEFycmF5TGlzdDxTdHJpbmc+KHBsbW5FbnRyaWVzLmxlbmd0aCAvIDMpOworICAgICAgICBtU3BkaU5ldHdvcmtzID0gbmV3IEFycmF5TGlzdDxTdHJpbmc+KHBsbW5FbnRyaWVzLmxlbmd0aCAvIDMpOwogCiAgICAgICAgIGZvciAoaW50IGkgPSAwIDsgaSArIDIgPCBwbG1uRW50cmllcy5sZW5ndGggOyBpICs9IDMpIHsKICAgICAgICAgICAgIFN0cmluZyBwbG1uQ29kZTsKQEAgLTE1OTksNyArMTYxNyw3IEBACiAgICAgICAgICAgICAvLyBWYWxpZCBvcGVyYXRvciBjb2RlcyBhcmUgNSBvciA2IGRpZ2l0cwogICAgICAgICAgICAgaWYgKHBsbW5Db2RlLmxlbmd0aCgpID49IDUpIHsKICAgICAgICAgICAgICAgICBsb2coIkVGX1NQREkgbmV0d29yazogIiArIHBsbW5Db2RlKTsKLSAgICAgICAgICAgICAgICBzcGRpTmV0d29ya3MuYWRkKHBsbW5Db2RlKTsKKyAgICAgICAgICAgICAgICBtU3BkaU5ldHdvcmtzLmFkZChwbG1uQ29kZSk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICB9CkBAIC0xNjEyLDEwICsxNjMwLDEyIEBACiAgICAgICAgIHJldHVybiAoKG1DcGhzSW5mb1sxXSAmIENQSFNfU1NUX01CTl9NQVNLKSA9PSBDUEhTX1NTVF9NQk5fRU5BQkxFRCApOwogICAgIH0KIAorICAgIEBPdmVycmlkZQogICAgIHByb3RlY3RlZCB2b2lkIGxvZyhTdHJpbmcgcykgewogICAgICAgICBSbG9nLmQoTE9HX1RBRywgIltTSU1SZWNvcmRzXSAiICsgcyk7CiAgICAgfQogCisgICAgQE92ZXJyaWRlCiAgICAgcHJvdGVjdGVkIHZvaWQgbG9nZShTdHJpbmcgcykgewogICAgICAgICBSbG9nLmUoTE9HX1RBRywgIltTSU1SZWNvcmRzXSAiICsgcyk7CiAgICAgfQpAQCAtMTYzMiw2ICsxNjUyLDcgQEAKICAgICAgKiBSZXR1cm4gdHJ1ZSBpZiAiUmVzdHJpY3Rpb24gb2YgbWVudSBvcHRpb25zIGZvciBtYW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VyU3BuTWFwLmNvbnRhaW5zS2V5KGNhcnJpZXIpOworICAgICAgICByZXR1cm4gbUNhcnJpZXJTcG5NYXAuY29udGFpbnNLZXkoY2Fycmllcik7CiAgICAgfQogCiAgICAgU3RyaW5nIGdldFNwbihTdHJpbmcgY2FycmllcikgewotICAgICAgICByZXR1cm4gQ2FycmllclNwbk1hcC5nZXQoY2Fycmllcik7CisgICAgICAgIHJldHVybiBtQ2FycmllclNwbk1hcC5nZXQoY2Fycmllcik7CiAgICAgfQogCiAgICAgcHJpdmF0ZSB2b2lkIGxvYWRTcG5PdmVycmlkZXMoKSB7CkBAIC02MCw3ICs2MCw3IEBACiAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICBzcG5SZWFkZXIgPSBuZXcgRmlsZVJlYWRlcihzcG5GaWxlKTsKICAgICAgICAgfSBjYXRjaCAoRmlsZU5vdEZvdW5kRXhjZXB0aW9uIGUpIHsKLSAgICAgICAgICAgIFJsb2cudyhMT0dfVEFHLCAiQ2FuJ3Qgb3BlbiAiICsKKyAgICAgICAgICAgIFJsb2cudyhMT0dfVEFHLCAiQ2FuIG5vdCBvcGVuICIgKwogICAgICAgICAgICAgICAgICAgICBFbnZpcm9ubWVudC5nZXRSb290RGlyZWN0b3J5KCkgKyAiLyIgKyBQQVJUTkVSX1NQTl9PVkVSUklERV9QQVRIKTsKICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgfQpAQCAtODIsNyArODIsNyBAQAogICAgICAgICAgICAgICAgIFN0cmluZyBudW1lcmljID0gcGFyc2VyLmdldEF0dHJpYnV0ZVZhbHVlKG51bGwsICJudW1lcmljIik7CiAgICAgICAgICAgICAgICAgU3RyaW5nIGRhdGEgICAgPSBwYXJzZXIuZ2V0QXR0cmlidXRlVmFsdWUobnVsbCwgInNwbiIpOwogCi0gICAgICAgICAgICAgICAgQ2FycmllclNwbk1hcC5wdXQobnVtZXJpYywgZGF0YSk7CisgICAgICAgICAgICAgICAgbUNhcnJpZXJTcG5NYXAuc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AgICAgICAgICAgICAgICAgICAgICAgICsgIiBGaXhtZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICBjYXNlIFBJTlNUQVRFX1VOS05PV046CisgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoREJHKSBsb2coIklnbm9yaW5nOiBwaW4xc3RhdGU9IiArIG1QaW4xU3RhdGUpOworICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICBsb2dlKCJCb2d1cyBmYWNpbGl0eSBsb2NrIHJlc3BvbnNlIik7CmRpZmYgLS1naXQgYS9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvdWljYy9VaWNjQ29udHJvbGxlci5qYXZhIGIvc3JjL2phdmEvY29tL2FuZHJvaWQvaW50ZXJuYWwvdGVsZXBob255L3VpY2MvVWljY0NvbnRyb2xsZXIuamF2YQppbmRleCAyNjQ3YjM5Li5jMzNkY2ZhIDEwMDY0NAotLS0gYS9zcmMvamF2YS9jb20vYW5kcm9pZC9pbnRlcm5hbC90ZWxlcGhvbnkvdWljYy9VaWNjQ29udHJvbGxlci5qYXZhCisrKyBiL3NyYy9qYXZhL2NvbS9hbmRyb2lkL2ludGVybmFsL3RlbGVwaG9ueS91aWNjL1VpY2NDb250cm9sbGVyLmphdmEKQEAgLTY3LDExICs2NywxMSBAQAogICogICAgICAgICBeIHN0YW5kcyBmb3IgR2VuZXJhbGl6YXRpb24KICAqCiAgKiBTZWUgYWxzbyB7QGxpbmsgY29tLmFuZHJvaWQuaW50ZXJuYWwudGVsZXBob255LkljY0NhcmR9Ci0gKiBhbmQge0BsaW5rIGNvbS5hbmRyb2lkLmludGVybmFsLnRlbGVwaG9ueS5JY2NDYXJkUHJveHl9CisgKiBhbmQge0BsaW5rIGNvb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ckRhdGEuTUVTU0FHRV9UWVBFX0RFTElWRVI7CisgICAgICAgIGJlYXJlckRhdGEubWVzc2FnZUlkID0gNTU7CisgICAgICAgIFVzZXJEYXRhIHVzZXJEYXRhID0gbmV3IFVzZXJEYXRhKCk7CisgICAgICAgIHVzZXJEYXRhLnBheWxvYWRTdHIgPSBwYXlsb2FkOworICAgICAgICB1c2VyRGF0YS51c2VyRGF0YUhlYWRlciA9IHNtc0hlYWRlcjsgICAgLy8gbWF5IGJlIG51bGwKKyAgICAgICAgaWYgKG1zZ0VuY29kaW5nICE9IC0xKSB7CisgICAgICAgICAgICB1c2VyRGF0YS5tc2dFbmNvZGluZyA9IG1zZ0VuY29kaW5nOworICAgICAgICAgICAgdXNlckRhdGEubXNnRW5jb2RpbmdTZXQgPSB0cnVlOwogICAgICAgICB9Ci0gICAgICAgIGFzc2VydFRydWUoQXJyYXlzLmVxdWFscyhlbmNvZGVIZWFkZXIsIGhlYWRlcikpOworICAgICAgICBiZWFyZXJEYXRhLnVzZXJEYXRhID0gdXNlckRhdGE7CisgICAgICAgIGJ5dGVbXSBlbmNvZGVkU21zID0gQmVhcmVyRGF0YS5lbmNvZGUoYmVhcmVyRGF0YSk7CisgICAgICAgIEJlYXJlckRhdGEgcmV2QmVhcmVyRGF0YSA9IEJlYXJlckRhdGEuZGVjb2RlKGVuY29kZWRTbXMpOworICAgICAgICBhc3NlcnRFcXVhbHModXNlckRhdGEucGF5bG9hZFN0ciwgcmV2QmVhcmVyRGF0YS51c2VyRGF0YS5wYXlsb2FkU3RyKTsKKyAgICAgICAgaWYgKHNtc0hlYWRlciAhPSBudWxsKSB7CisgICAgICAgICAgICBhc3NlcnRUcnVlKHJldkJlYXJlckRhdGEuaGFzVXNlckRhdGFIZWFkZXIpOworICAgICAgICAgICAgYnl0ZVtdIGVuY29kZUhlYWRlciA9IFNtc0hlYWRlci50b0J5dGVBcnJheShzbXNIZWFkZXIpOworICAgICAgICAgICAgYnl0ZVtdIGRlY29kZUhlYWR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GVsZXBob255dGVzdHMvc3JjL2NvbS9hbmRyb2lkL2ludGVybmFsL3RlbGVwaG9ueS9nc20vVXNpbURhdGFEb3dubG9hZFRlc3QuamF2YQpAQCAtMzksNyArMzksNyBAQAogICAgICAgICBAT3ZlcnJpZGUKICAgICAgICAgcHJvdGVjdGVkIHZvaWQgb25Mb29wZXJQcmVwYXJlZCgpIHsKICAgICAgICAgICAgIHN5bmNocm9uaXplZCAodGhpcykgewotICAgICAgICAgICAgICAgIG1IYW5kbGVyID0gbmV3IFVzaW1EYXRhRG93bmxvYWRIYW5kbGVyKG1DbSk7CisgICAgICAgICAgICAgICAgbUhhbmRsZXIgPSBuZXcgVXNpbURhdGFEb3dubG9hZEhhbmRsZXIobUNpKTsKICAgICAgICAgICAgICAgICBub3RpZnlBbGwoKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfQpAQCAtNTYsMTQgKzU2LDE0IEBACiAgICAgICAgIH0KICAgICB9CiAKLSAgICBwcml2YXRlIFVzaW1EYXRhRG93bmxvYWRDb21tYW5kcyBtQ207CisgICAgcHJpdmF0ZSBVc2ltRGF0YURvd25sb2FkQ29tbWFuZHMgbUNpOwogICAgIHByaXZhdGUgVGVzdEhhbmRsZXJUaHJlYWQgbUhhbmRsZXJUaHJlYWQ7CiAgICAgVXNpbURhdGFEb3dubG9hZEhhbmRsZXIgbUhhbmRsZXI7CiAKICAgICBAT3ZlcnJpZGUKICAgICBwcm90ZWN0ZWQgdm9pZCBzZXRVcCgpIHRocm93cyBFeGNlcHRpb24gewogICAgICAgICBzdXBlci5zZXRVcCgpOwotICAgICAgICBtQ20gPSBuZXcgVXNpbURhdGFEb3dubG9hZENvbW1hbmRzKG1Db250ZXh0KTsKKyAgICAgICAgbUNpID0gbmV3IFVzaW1EYXRhRG93bmxvYWRDb21tYW5kcyhtQ29udGV4dCk7CiAgICAgICAgIG1IYW5kbGVyVGhyZWFkID0gbmV3IFRlc3RIYW5kbGVyVGhyZWFkKCk7CiAgICAgICAgIG1I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