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qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIENvcHlyaWdodCAoYykgMjAwMCwgMjAwNiBJQk0gQ29ycG9yYXRpb24gYW5kIG90aGVycy4KKyAqIEFsbCByaWdodHMgcmVzZXJ2ZWQuIFRoaXMgcHJvZ3JhbSBhbmQgdGhlIGFjY29tcGFueWluZyBtYXRlcmlhbHMKKyAqIGFyZSBtYWRlIGF2YWlsYWJsZSB1bmRlciB0aGUgdGVybXMgb2YgdGhlIEVjbGlwc2UgUHVibGljIExpY2Vuc2UgdjEuMAorICogd2hpY2ggYWNjb21wYW5pZXMgdGhpcyBkaXN0cmlidXRpb24sIGFuZCBpcyBhdmFpbGFibGUgYXQKKyAqIGh0dHA6Ly93d3cuZWNsaXBzZS5vcmcvbGVnYWwvZXBsLXYxMC5odG1sCisgKgorICogQ29udHJpYnV0b3JzOgorICogICAgIElCTSBDb3Jwb3JhdGlvbiAtIGluaXRpYWwgQVBJIGFuZCBpbXBsZW1lbnRhdGlvbgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCitwYWNrYWdlIG9yZy5lY2xpcHNlLmpkdC5pbnRlcm5hbC5jb2RlYXNzaXN0LmNvbXBsZXRlOworCitpbXBvcnQgb3JnLmVjbGlwc2UuamR0LmludGVybmFsLmNvbXBpbGVyLmFzdC4qOworaW1wb3J0IG9yZy5lY2xpcHNlLmpkdC5pbnRlcm5hbC5jb21waWxlci5sb29rdXAuKjsKKworLyoqCisgKiBOb2RlIHJlcHJlc2VudGluZyBhIEphdmFkb2MgY29tbWVudCBpbmNsdWRpbmcgY29kZSBzZWxlY3Rpb24uCisgKi8KK3B1YmxpYyBjbGFzcyBDb21wbGV0aW9uSmF2YWRvYyBleHRlbmRzIEphdmFkb2MgeworCisJRXhwcmVzc2lvbiBjb21wbGV0aW9uTm9kZT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IDEwMDc1NQppbmRleCAwMDAwMDAwLi5iNWE3ZDk1Ci0tLSAvZGV2L251bGwKKysrIGIvb3JnLmVjbGlwc2UuamR0LmNvcmUvY29kZWFzc2lzdC9vcmcvZWNsaXBzZS9qZHQvaW50ZXJuYWwvY29kZWFzc2lzdC9jb21wbGV0ZS9Db21wbGV0aW9uT25KYXZhZG9jLmphdmEKQEAgLTAsMCArMSwzNyBAQAorLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIENvcHlyaWdodCAoYykgMjAwMCwgMjAwNyBJQk0gQ29ycG9yYXRpb24gYW5kIG90aGVycy4KKyAqIEFsbCByaWdodHMgcmVzZXJ2ZWQuIFRoaXMgcHJvZ3JhbSBhbmQgdGhlIGFjY29tcGFueWluZyBtYXRlcmlhbHMKKyAqIGFyZSBtYWRlIGF2YWlsYWJsZSB1bmRlciB0aGUgdGVybXMgb2YgdGhlIEVjbGlwc2UgUHVibGljIExpY2Vuc2UgdjEuMAorICogd2hpY2ggYWNjb21wYW5pZXMgdGhpcyBkaXN0cmlidXRpb24sIGFuZCBpcyBhdmFpbGFibGUgYXQKKyAqIGh0dHA6Ly93d3cuZWNsaXBzZS5vcmcvbGVnYWwvZXBsLXYxMC5odG1sCisgKgorICogQ29udHJpYnV0b3JzOgorICogICAgIElCTSBDb3Jwb3JhdGlvbiAtIGluaXRpYWwgQVBJIGFuZCBpbXBsZW1lbnRhdGlvbgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCitwYWNrYWdlIG9yZy5lY2xpcHNlLmpkdC5pbnRlcm5hbC5jb2RlYXNzaXN0LmNvbXBsZXRlOworCitwdWJsaWMgaW50ZXJmYWNlIENvbXBsZXRpb25PbkphdmFkb2MgeworCisJLy8gQml0IHBhdHRlcm4gZm9yIGphdmFkb2M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phdmEKQEAgLTAsMCArMSw2MSBAQAorLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIENvcHlyaWdodCAoYykgMjAwMCwgMjAwNSBJQk0gQ29ycG9yYXRpb24gYW5kIG90aGVycy4KKyAqIEFsbCByaWdodHMgcmVzZXJ2ZWQuIFRoaXMgcHJvZ3JhbSBhbmQgdGhlIGFjY29tcGFueWluZyBtYXRlcmlhbHMKKyAqIGFyZSBtYWRlIGF2YWlsYWJsZSB1bmRlciB0aGUgdGVybXMgb2YgdGhlIEVjbGlwc2UgUHVibGljIExpY2Vuc2UgdjEuMAorICogd2hpY2ggYWNjb21wYW5pZXMgdGhpcyBkaXN0cmlidXRpb24sIGFuZCBpcyBhdmFpbGFibGUgYXQKKyAqIGh0dHA6Ly93d3cuZWNsaXBzZS5vcmcvbGVnYWwvZXBsLXYxMC5odG1sCisgKgorICogQ29udHJpYnV0b3JzOgorICogICAgIElCTSBDb3Jwb3JhdGlvbiAtIGluaXRpYWwgQVBJIGFuZCBpbXBsZW1lbnRhdGlvbgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCitwYWNrYWdlIG9yZy5lY2xpcHNlLmpkdC5pbnRlcm5hbC5jb2RlYXNzaXN0LmNvbXBsZXRlOworCitpbXBvcnQgb3JnLmVjbGlwc2UuamR0LmludGVybmFsLmNvbXBpbGVyLmFzdC5KYXZhZG9jU2luZ2xlTmFtZVJlZmVyZW5jZTsKK2ltcG9ydCBvcmcuZWNsaXBzZS5qZHQuaW50ZXJuYWwuY29tcGlsZXIubG9va3VwLkJsb2NrU2NvcGU7CitpbXBvcnQgb3JnLmVjbGlwc2UuamR0LmludGVybmFsLmNvbXBpbGVyLmxvb2t1cC5UeXBlQmluZGluZzsKKworcHVibGljIGNsYXNzIENvbXBsZXRp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cvZWNsaXBzZS9qZHQvaW50ZXJuYWwvY29kZWFzc2lzdC9jb21wbGV0ZS9Db21wbGV0aW9uT25NZXNzYWdlU2VuZE5hbWUuamF2YQpuZXcgZmlsZSBtb2RlIDEwMDc1NQppbmRleCAwMDAwMDAwLi44OGFlYzljCi0tLSAvZGV2L251bGwKKysrIGIvb3JnLmVjbGlwc2UuamR0LmNvcmUvY29kZWFzc2lzdC9vcmcvZWNsaXBzZS9qZHQvaW50ZXJuYWwvY29kZWFzc2lzdC9jb21wbGV0ZS9Db21wbGV0aW9uT25NZXNzYWdlU2VuZE5hbWUuamF2YQpAQCAtMCwwICsxLDcwIEBACisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogQ29weXJpZ2h0IChjKSAyMDA2IElCTSBDb3Jwb3JhdGlvbiBhbmQgb3RoZXJzLgorICogQWxsIHJpZ2h0cyByZXNlcnZlZC4gVGhpcyBwcm9ncmFtIGFuZCB0aGUgYWNjb21wYW55aW5nIG1hdGVyaWFscworICogYXJlIG1hZGUgYXZhaWxhYmxlIHVuZGVyIHRoZSB0ZXJtcyBvZiB0aGUgRWNsaXBzZSBQdWJsaWMgTGljZW5zZSB2MS4wCisgKiB3aGljaCBhY2NvbXBhbmllcyB0aGlzIGRpc3RyaWJ1dGlvbiwgYW5kIGlzIGF2YWlsYWJsZSBhdAorICogaHR0cDovL3d3dy5lY2xpcHNlLm9yZy9sZWdhbC9lcGwtdjEwLmh0bWwKKyAqCisgKiBDb250cmlidXRvcnM6CisgKiAgICAgSUJNIENvcnBvcmF0aW9uIC0gaW5pdGlhbCBBUEkgYW5kIGltcGxlbWVudGF0aW9uCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK3BhY2thZ2Ugb3JnLmVjbGlwc2UuamR0LmludGVybmFsLmN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Glwc2UuamR0LmNvcmUvY29kZWFzc2lzdC9vcmcvZWNsaXBzZS9qZHQvaW50ZXJuYWwvY29kZWFzc2lzdC9jb21wbGV0ZS9Db21wbGV0aW9uT25TdHJpbmdMaXRlcmFsLmphdmEKQEAgLTAsMCArMSw2MiBAQAorLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIENvcHlyaWdodCAoYykgMjAwNSBJQk0gQ29ycG9yYXRpb24gYW5kIG90aGVycy4KKyAqIEFsbCByaWdodHMgcmVzZXJ2ZWQuIFRoaXMgcHJvZ3JhbSBhbmQgdGhlIGFjY29tcGFueWluZyBtYXRlcmlhbHMKKyAqIGFyZSBtYWRlIGF2YWlsYWJsZSB1bmRlciB0aGUgdGVybXMgb2YgdGhlIEVjbGlwc2UgUHVibGljIExpY2Vuc2UgdjEuMAorICogd2hpY2ggYWNjb21wYW5pZXMgdGhpcyBkaXN0cmlidXRpb24sIGFuZCBpcyBhdmFpbGFibGUgYXQKKyAqIGh0dHA6Ly93d3cuZWNsaXBzZS5vcmcvbGVnYWwvZXBsLXYxMC5odG1sCisgKgorICogQ29udHJpYnV0b3JzOgorICogICAgIElCTSBDb3Jwb3JhdGlvbiAtIGluaXRpYWwgQVBJIGFuZCBpbXBsZW1lbnRhdGlvbgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCitwYWNrYWdlIG9yZy5lY2xpcHNlLmpkdC5pbnRlcm5hbC5jb2RlYXNzaXN0LmNvbXBsZXRlOworCitpbXBvcnQgb3JnLmVjbGlwc2UuamR0LmludGVybmFsLmNvbXBpbGVyLmFzdC5TdHJpbmdMaXRlcmFsOworaW1wb3J0IG9yZy5lY2xpcHNlLmpkdC5pbnRlcm5hbC5jb21waWxlci5sb29rdXAuQmxvY2tTY29wZTsKK2ltcG9ydCBvcmcuZWNsaXBzZS5qZHQuaW50ZXJuYWwuY29tcGlsZXIubG9va3VwLkNsYXNzU2NvcGU7CitpbXBvcnQgb3JnLmVjbGlwc2UuamR0LmludGVybmFsLmNvbXBpbGVyLmxvb2t1cC5UeXBlQmluZGluZzsKKworLyoKKyAqIENvbXBsZXRpb24gbm9kZSBidWlsZCBieSB0aGUgcGFyc2VyIGluIGFueSBjYXNlIGl0IHdhcyBpbnRlbmRpbmcgdG8KKyAqIHJlZHVjZSBhIHN0cmluZyBsaXRlcmFsLgorICogZS5nLgorICoKKyAqCWNsYXNzIFggeworICogICAgdm9pZCBmb28oKSB7CisgKiAgICAgIFN0cmluZyBzID0gImFbY3Vyc29yXSIKKyAqICAgIH0KKyAqICB9CisgKgorICoJLS0tPiBjbGFzcyBYIHsKKyAqICAgICAgICAgdm9pZCBmb28oKSB7CisgKiAgICAgICAgICAgU3RyaW5nIHMgPSA8Q29tcGxldGVPblN0cmluZ0xpdGVyYWw6YT4KKyAqICAgICAgICAgfQorICogICAgICAgfQorICovCisKK3B1YmxpYyBjbGFzcyBDb21wbGV0aW9uT25TdHJpbmdMaXRlcmFsIGV4dGVuZHMgU3RyaW5nTGl0ZXJhbCB7CisJcHVibGljIGludCBjb250ZW50U3RhcnQ7CisJcHVibGljIGludCBjb250ZW50RW5kOworCXB1YmxpYyBDb21wbGV0aW9uT25TdHJpbmdMaXRlcmFsKGNoYXJbXSB0b2tlbiwgaW50IHMsIGludCBlLCBpbnQgY3MsIGludCBjZSwgaW50IGxpbmVOdW1iZXIpIHsKKwkJc3VwZXIodG9rZW4sIHMsIGUsIGxpbmVOdW1iZXIpOworCQl0aGlzLmNvbnRlbnRTdGFydCA9IGNzOworCQl0aGlzLmNvbnRlbnRFbmQgPSBjZTsKKwl9CisKKwlwdWJsaWMgQ29tcGxldGlvbk9uU3RyaW5nTGl0ZXJhbChpbnQgcywgaW50IGUsIGludCBjcywgaW50IGNlKSB7CisJCXN1cGVyKHMsZSk7CisJCXR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pkdC9jb3JlL2NvbXBpbGVyL0NhdGVnb3JpemVkUHJvYmxlbS5qYXZhCm5ldyBmaWxlIG1vZGUgMTAwNzU1CmluZGV4IDAwMDAwMDAuLjExMmEzZDgKLS0tIC9kZXYvbnVsbAorKysgYi9vcmcuZWNsaXBzZS5qZHQuY29yZS9jb21waWxlci9vcmcvZWNsaXBzZS9qZHQvY29yZS9jb21waWxlci9DYXRlZ29yaXplZFByb2JsZW0uamF2YQpAQCAtMCwwICsxLDE1MSBAQAorLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIENvcHlyaWdodCAoYykgMjAwMCwgMjAwNiBJQk0gQ29ycG9yYXRpb24gYW5kIG90aGVycy4KKyAqIEFsbCByaWdodHMgcmVzZXJ2ZWQuIFRoaXMgcHJvZ3JhbSBhbmQgdGhlIGFjY29tcGFueWluZyBtYXRlcmlhbHMKKyAqIGFyZSBtYWRlIGF2YWlsYWJsZSB1bmRlciB0aGUgdGVybXMgb2YgdGhlIEVjbGlwc2UgUHVibGljIExpY2Vuc2UgdjEuMAorICogd2hpY2ggYWNjb21wYW5pZXMgdGhpcyBkaXN0cmlidXRpb24sIGFuZCBpcyBhdmFpbGFibGUgYXQKKyAqIGh0dHA6Ly93d3cuZWNsaXBzZS5vcmcvbGVnYWwvZXBsLXYxMC5odG1sCisgKgorICogQ29udHJpYnV0b3JzOgorICogICAgIElCTSBDb3Jwb3JhdGlvbiAtIGluaXRpYWwgQVBJIGFuZCBpbXBsZW1lbnRhdGlvbgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCitwYWNrYWdlIG9yZy5lY2xpcHNlLmpkdC5jb3JlLmNvbXBpbGVyOworCitpbXBvcnQgb3JnLmVjbGlwc2UuamR0LmludGVybmFsLmNvbXBpbGVyLnByb2JsZW0uR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iBGb3IgaW5zdGFuY2UsICdOUEV4Y2VwJyB3aWxsIG1hdGNoICdOdWxsUG9pbnRlckV4Y2VwdGlvbicsIGJ1dCBub3QgJ051bGxQb2ludGVyRXhDRVBUSU9OJworICogb3IgJ051UG9FeCcgd2lsbCBtYXRjaCAnTnVsbFBvaW50ZXJFeGNlcHRpb24nLCBidXQgbm90ICdOb1BvaW50ZXJFeGNlcHRpb24nLgorICogPGJyPjxicj4KKyAqIEV4YW1wbGVzOgorICogPG9sPgorICogPGxpPjxwcmU+CisgKiAgICBwYXR0ZXJuID0geyAnTicsICdQJywgJ0UnIH0KKyAqICAgIG5hbWUgPSB7ICdOJywgJ3UnLCdsJywgJ2wnLCAnUCcsICdvJywgJ2knLCAnbicsICd0JywgJ2UnLCAncicsICdFJywgJ3gnLCAnYycsICdlJywgJ3AnLCAndCcsICdpJywgJ28nLCAnbicgfQorICogICAgcmVzdWx0ID0+IHRydWUKKyAqIDwvcHJlPgorICogPC9saT4KKyAqIDxsaT48cHJlPgorICogICAgcGF0dGVybiA9IHsgJ04nLCAnUCcsICdFJyB9CisgKiAgICBuYW1lID0geyAnTicsICdvJywgJ1AnLCAnZScsICdyJywgJ20nLCAnaScsICdzJywgJ3MnLCAnaScsICdvJywgJ24nLCAnRScsICd4JywgJ2MnLCAnZScsICdwJywgJ3QnLCAnaScsICdvJywgJ24nIH0KKyAqICAgIHJlc3VsdCA9PiB0cnVlCisgKiA8L3ByZT4KKyAqIDwvbGk+CisgKiA8bGk+PHByZT4KKyAqICAgIHBhdHRlcm4gPSB7ICdOJywgJ3UnLCAnUCcsICdvJywgJ0UnLCAneCcgfQorICogICAgbmFtZSA9IHsgJ04nLCAndScsJ2wnLCAnbCcsICdQJywgJ28nLCAnaScsICduJywgJ3QnLCAnZScsICdyJywgJ0UnLCAneCcsICdjJywgJ2UnLCAncCcsICd0JywgJ2knLCAnbycsICduJyB9CisgKiAgICByZXN1bHQgPT4gdHJ1ZQorICogPC9wcmU+CisgKiA8L2xp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InLCAnbScsICdpJywgJ3MnLCAncycsICdpJywgJ28nLCAnbicsICdFJywgJ3gnLCAnYycsICdlJywgJ3AnLCAndCcsICdpJywgJ28nLCAnbicgfQorICogICAgbmFtZVN0YXJ0ID0gMAorICogICAgbmFtZUVuZCA9IDIxCisgKiAgICByZXN1bHQgPT4gdHJ1ZQorICogPC9wcmU+CisgKiA8L2xpPgorICogPGxpPjxwcmU+CisgKiAgICBwYXR0ZXJuID0geyAnTicsICd1JywgJ1AnLCAnbycsICdFJywgJ3gnIH0KKyAqICAgIHBhdHRlcm5TdGFydCA9IDAKKyAqICAgIHBhdHRlcm5FbmQgPSA2CisgKiAgICBuYW1lID0geyAnTicsICd1JywnbCcsICdsJywgJ1AnLCAnbycsICdpJywgJ24nLCAndCcsICdlJywgJ3InLCAnRScsICd4JywgJ2MnLCAnZScsICdwJywgJ3QnLCAnaScsICdvJywgJ24nIH0KKyAqICAgIG5hbWVTdGFydCA9IDAKKyAqICAgIG5hbWVFbmQgPSAyMAorICogICAgcmVzdWx0ID0+IHRydWUKKyAqIDwvcHJlPgorICogPC9saT4KKyAqIDxsaT48cHJlPgorICogICAgcGF0dGVybiA9IHsgJ04nLCAndScsICdQJywgJ28nLCAnRScsICd4JyB9CisgKiAgICBwYXR0ZXJuU3RhcnQgPSAwCisgKiAgICBwYXR0ZXJuRW5kID0gNgorICogICAgbmFtZSA9IHsgJ04nLCAnbycsICdQJywgJ2UnLCAncicsICdtJywgJ2knLCAncycsICdzJywgJ2knLCAnbycsICduJywgJ0UnLCAneCcsICdjJywgJ2UnLCAncCcsICd0JywgJ2knLCAnbycsICduJyB9CisgKiAgICBuYW1lU3RhcnQgPSAwCisgKiAgICBuYW1lRW5kID0gMjEKKyAqICAgIHJlc3VsdCA9PiBmYWxzZQorICogPC9wcmU+CisgKiA8L2xpPgorICogPGxpPjxwcmU+CisgKiAgICBwYXR0ZXJuID0geyAnbicsIHAnLCAnZScgfQorICogICAgcGF0dGVyblN0YXJ0ID0gMAorICog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N0ZXJzIHRoYXQgYXJlIG5vdCBlcXVhbCA8L2xpPgorICogPGxpPm9uZSBpZiBhcnJheSBsZW5ndGggaXMgbG93ZXIgdGhhbiB0aGUgcHJlZml4IGxlbmd0aCBhbmQgdGhhdCB0aGUgcHJlZml4IHN0YXJ0cyB3aXRoIHRoZSAKKyAqIGFycmF5IGNvbnRlbnRzLjwvbGk+CisgKiA8L3VsPgorICogPHA+CisgKiBGb3IgZXhhbXBsZToKKyAqIDxvbD4KKyAqIDxsaT48cHJlPgorICogICAgYXJyYXkgPSBudWxsCisgKiAgICBwcmVmaXggPSBudWxsCisgKiAgICA9PiByZXN1bHQgPSBOdWxsUG9pbnRlckV4Y2VwdGlvbgorICogPC9wcmU+CisgKiA8L2xpPgorICogPGxpPjxwcmU+CisgKiAgICBhcnJheSA9IHsgJ2EnLCAnYicsICdjJywgJ2QnLCAnZScgfQorICogICAgcHJlZml4ID0geyAnYScsICdiJywgJ2MnfQorICogICAgPT4gcmVzdWx0ID0gMAorICogPC9wcmU+CisgKiA8L2xpPgorICogPGxpPjxwcmU+CisgKiAgICBhcnJheSA9IHsgJ2EnLCAnYicsICdjJywgJ2QnLCAnZScgfQorICogICAgcHJlZml4ID0geyAnYScsICdCJywgJ2MnfQorICogICAgPT4gcmVzdWx0ID0gMzIKKyAqIDwvcHJlPgorICogPC9saT4KKyAqIDxsaT48cHJlPgorICogICAgYXJyYXkgPSB7ICdkJywgJ2InLCAnYycsICdkJywgJ2UnIH0KKyAqICAgIHByZWZpeCA9IHsgJ2EnLCAnYicsICdjJ30KKyAqICAgID0+IHJlc3VsdCA9IDMKKyAqIDwvcHJlPgorICogPC9saT4KKyAqIDxsaT48cHJlPgorICogICAgYXJyYXkgPSB7ICdhJywgJ2InLCAnYycsICdkJywgJ2UnIH0KKyAqICAgIHByZWZpeCA9IHsgJ2QnLCAnYicsICdjJ30KKyAqICAgID0+IHJlc3VsdCA9IC0zCisgKiA8L3ByZT4KKyAqIDwvbGk+CisgKiA8bGk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uIEl0IGFuc3dlcnMgbnVsbCBpZiB0aGUgdHdvIGFycmF5cyBhcmUgbnVsbC4KKyAqIElmIHRoZSBmaXJzdCBhcnJheSBpcyBudWxsLCB0aGVuIHRoZSBzZWNvbmQgYXJyYXkgaXMgcmV0dXJuZWQuCisgKiBJZiB0aGUgc2Vjb25kIGFycmF5IGlzIG51bGwsIHRoZW4gdGhlIGZpcnN0IGFycmF5IGlzIHJldHVybmVkLgorICogPGJyPgorICogPGJyPgorICogRm9yIGV4YW1wbGU6CisgKiA8b2w+CisgKiA8bGk+PHByZT4KKyAqICAgIGZpcnN0ID0gbnVsbAorICogICAgc2Vjb25kID0geyAnYScgfQorICogICAgPT4gcmVzdWx0ID0geyAnIGEnIH0KKyAqIDwvcHJlPgorICogPC9saT4KKyAqIDxsaT48cHJlPgorICogICAgZmlyc3QgPSB7ICcgYScgfQorICogICAgc2Vjb25kID0gbnVsbAorICogICAgPT4gcmVzdWx0ID0geyAnIGEnIH0KKyAqIDwvcHJlPgorICogPC9saT4KKyAqIDxsaT48cHJlPgorICogICAgZmlyc3QgPSB7ICcgYScgfQorICogICAgc2Vjb25kID0geyAnIGInIH0KKyAqICAgID0+IHJlc3VsdCA9IHsgJyBhJyAsICcgYicgfQorICogPC9wcmU+CisgKiA8L2xpPgorICogPC9vbD4KKyAqIAorICogQHBhcmFtIGZpcnN0IHRoZSBmaXJzdCBhcnJheSB0byBjb25jYXRlbmF0ZQorICogQHBhcmFtIHNlY29uZCB0aGUgc2Vjb25kIGFycmF5IHRvIGNvbmNhdGVuYXRlCisgKiBAcmV0dXJuIHRoZSBjb25jYXRlbmF0aW9uIG9mIHRoZSB0d28gYXJyYXlzLCBvciBudWxsIGlmIHRoZSB0d28gYXJyYXlzIGFyZSBudWxsLgorICovCitwdWJsaWMgc3RhdGljIGZpbmFsIGNoYXJbXSBjb25jYXQoY2hhcltdIGZpcnN0LCBjaGFyW10gc2Vjb25kKSB7CisJaWYgKGZpcnN0ID09IG51bGwpCisJCXJ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bmF0aW9uIG9mIGZpcnN0IGFuZCB0aGlyZCBpbnNlcnRpbmcKKyAqIHRoZSBzZXAxIGNoYXJhY3RlciBiZXR3ZWVuIHRoZW0uCisgKiBJZiB0aGUgdGhpcmQgYXJyYXkgaXMgbnVsbCwgdGhlbiBpdCBhbnN3ZXJzIHRoZSBjb25jYXRlbmF0aW9uIG9mIGZpcnN0IGFuZCBzZWNvbmQgaW5zZXJ0aW5nCisgKiB0aGUgc2VwMSBjaGFyYWN0ZXIgYmV0d2VlbiB0aGVtLgorICogPGJyPgorICogPGJyPgorICogRm9yIGV4YW1wbGU6CisgKiA8b2w+CisgKiA8bGk+PHByZT4KKyAqICAgIGZpcnN0ID0gbnVsbAorICogICAgc2VwMSA9ICcvJworICogICAgc2Vjb25kID0geyAnYScgfQorICogICAgc2VwMiA9ICc6JworICogICAgdGhpcmQgPSB7ICdiJyB9CisgKiAgICA9PiByZXN1bHQgPSB7ICcgYScgLCAnOicsICdiJyB9CisgKiA8L3ByZT4KKyAqIDwvbGk+CisgKiA8bGk+PHByZT4KKyAqICAgIGZpcnN0ID0geyAnYScgfQorICogICAgc2VwMSA9ICcvJworICogICAgc2Vjb25kID0gbnVsbAorICogICAgc2VwMiA9ICc6JworICogICAgdGhpcmQgPSB7ICdiJyB9CisgKiAgICA9PiByZXN1bHQgPSB7ICcgYScgLCAnLycsICdiJyB9CisgKiA8L3ByZT4KKyAqIDwvbGk+CisgKiA8bGk+PHByZT4KKyAqICAgIGZpcnN0ID0geyAnYScgfQorICogICAgc2VwMSA9ICcvJworICogICAgc2Vjb25kID0geyAnYicgfQorICogICAgc2VwMiA9ICc6JworICogICAgdGhpcmQgPSBudWxsCisgKiAgICA9PiByZXN1bHQgPSB7ICcgYScgLCAnLycsICdiJyB9CisgKiA8L3ByZT4KKyAqIDwvbGk+CisgKiA8bGk+PHByZT4KKyAqICAgIGZpcnN0ID0geyAnYScgfQorICogICAgc2VwMSA9ICcvJworICogICAgc2Vjb25kID0geyAnYicgfQor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SBsZW5ndGggLSAxOworCXdoaWxlIChzdGFydCA8IGxlbmd0aCAmJiBhcnJheVtzdGFydF0gPT0gJyAnKQorCQlzdGFydCsrOworCXdoaWxlIChlbmQgPiBzdGFydCAmJiBhcnJheVtlbmRdID09ICcgJykKKwkJZW5kLS07CisJc3BsaXRbY3VycmVudFdvcmRdID0gbmV3IGNoYXJbZW5kIC0gc3RhcnQgKyAxXTsKKwlTeXN0ZW0uYXJyYXljb3B5KAorCQlhcnJheSwKKwkJc3RhcnQsCisJCXNwbGl0W2N1cnJlbnRXb3JkKytdLAorCQkwLAorCQllbmQgLSBzdGFydCArIDEpOworCXJldHVybiBzcGxpdDsKK30KKworLyoqCisgKiBSZXR1cm4gYSBuZXcgYXJyYXkgd2hpY2ggaXMgdGhlIHNwbGl0IG9mIHRoZSBnaXZlbiBhcnJheSB1c2luZyB0aGUgZ2l2ZW4gZGl2aWRlci4KKyAqIDxicj4KKyAqIDxicj4KKyAqIEZvciBleGFtcGxlOgorICogPG9sPgorICogPGxpPjxwcmU+CisgKiAgICBkaXZpZGVyID0gJ2InCisgKiAgICBhcnJheSA9IHsgJ2EnICwgJ2InLCAnYicsICdhJywgJ2InLCAnYScgfQorICogICAgcmVzdWx0ID0+IHsgeyAnYScgfSwgeyAgfSwgeyAnYScgfSwgeyAnYScgfSB9CisgKiA8L3ByZT4KKyAqIDwvbGk+CisgKiA8bGk+PHByZT4KKyAqICAgIGRpdmlkZXIgPSAnYycKKyAqICAgIGFycmF5ID0geyAnYScgLCAnYicsICdiJywgJ2EnLCAnYicsICdhJyB9CisgKiAgICByZXN1bHQgPT4geyB7ICdhJywgJ2InLCAnYicsICdhJywgJ2InLCAnYScgfSB9CisgKiA8L3ByZT4KKyAqIDwvbGk+CisgKiA8bGk+PHByZT4KKyAqICAgIGRpdmlkZXIgPSAnYycKKyAqICAgIGFycmF5ID0geyAnICcsICcgJywgJ2EnICwgJ2InLCAnYicsICdhJywgJ2InLCAnYScsICcgJyB9CisgKiAgICByZ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lOTFNUYWcKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTG9jYWxWYXJpYWJsZU1heUJlTnVsbAorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBFbnVtQ29uc3RhbnRzQ2Fubm90QmVTdXJyb3VuZGVkQnlQYXJlbnRoZXNpcworICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBKYXZhZG9jTWlzc2luZ0lkZW50aWZpZXIKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSmF2YWRvY05vblN0YXRpY1R5cGVGcm9tU3RhdGljSW52b2NhdGlvbgorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBSYXdUeXBlUmVmZXJlbmNlCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE5vQWRkaXRpb25hbEJvdW5kQWZ0ZXJUeXBlVmFyaWFibGUKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVW5zYWZlR2VuZXJpY0FycmF5Rm9yVmFyYXJncworICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbGxlZ2FsQWNjZXNzRnJvbVR5cGVWYXJpYWJsZQorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBbm5vdGF0aW9uVmFsdWVNdXN0QmVBcnJheUluaXRpYWxpemVyCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEludmFsaWRFbmNvZGluZworICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDYW5ub3RSZWFkU291cmNlCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEVudW1TdGF0aWNGaWVsZEluSW5Jbml0aWFsaXplckNvbnRleHQKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRXh0ZXJuYWxQcm9ibGVtTm90Rml4YWJsZQorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBFeHRlcm5hbFByb2JsZW1GaXhhYmxlCisgKiAgICAgSUJNIENvcnBvcmF0aW9uIC0gYWRkZWQgdGhlIGZvbGxvd2luZyBjb25zdGFudHMKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQW5ub3RhdGlvblZhbHVlTXVzdEJlQW5FbnVtQ29uc3RhbnQKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgT3ZlcnJpZGluZ01ldGhvZFdpdGhvdXRTdXBlckludm9jYXRpb24KKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTWV0aG9kTXVzdE92ZXJyaWRlT3JJbXBsZW1lbnQKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVHlwZUhpZGluZ1R5cGVQYXJhbWV0ZXJGcm9tVHlwZQorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBUeXBlSGlkaW5nVHlwZVBhcmFtZXRlckZyb21NZXRob2QKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVHlwZUhpZGluZ1R5cGUKKyAqICAgICBJQk0gQ29ycG9yYXRpb24gLSBhZGRlZCB0aGUgZm9sbG93aW5nIGNvbnN0YW50cworICoJCQkJCQkJCSAgIE51bGxMb2NhbFZhcmlhYmxlUmVmZXJlbmNlCisgKgkJCQkJCQkJICAgUG90ZW50aWFsTnVsbExvY2FsVmFyaWFibGVSZWZlcmVuY2UKKyAqCQkJCQkJCQkgICBSZWR1bmRhbnROdWxsQ2hlY2tPbk51bGxMb2NhbFZhcmlhYmxlCisgKiAJCQkJCQkJCSAgIE51bGxMb2NhbFZhcmlhYmxlQ29tcGFyaXNvbllpZWxkc0ZhbHNlCisgKiAJCQkJCQkJCSAgIFJlZHVuZGFudExvY2FsVmFyaWFibGVOdWxsQXNzaWdubWVudAorICogCQkJCQkJCQkgICBOdWxsTG9jYWxWYXJpYWJsZUluc3RhbmNlb2ZZaWVsZHNGYWxzZQorICogCQkJCQkJCQkgICBSZWR1bmRhbnROdWxsQ2hlY2tPbk5vbk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KzEsNSBAQAogLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKLSAqIENvcHlyaWdodCAoYykgMjAwMCwgMjAwNSBJQk0gQ29ycG9yYXRpb24gYW5kIG90aGVycy4KKyAqIENvcHlyaWdodCAoYykgMjAwMCwgMjAwNyBJQk0gQ29ycG9yYXRpb24gYW5kIG90aGVycy4KICAqIEFsbCByaWdodHMgcmVzZXJ2ZWQuIFRoaXMgcHJvZ3JhbSBhbmQgdGhlIGFjY29tcGFueWluZyBtYXRlcmlhbHMKICAqIGFyZSBtYWRlIGF2YWlsYWJsZSB1bmRlciB0aGUgdGVybXMgb2YgdGhlIEVjbGlwc2UgUHVibGljIExpY2Vuc2UgdjEuMAogICogd2hpY2ggYWNjb21wYW5pZXMgdGhpcyBkaXN0cmlidXRpb24sIGFuZCBpcyBhdmFpbGFibGUgYXQKQEAgLTEwLDE3MyArMTAsMzkgQEAKICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwogcGFja2FnZSBvcmcuZWNsaXBzZS5qZHQuaW50ZXJuYWwuY29tcGlsZXIuYXN0OwogCi1pbXBvcnQgamF2YS51dGlsLio7CitpbXBvcnQgamF2YS51dGlsLkFycmF5TGlzdDsKIAogaW1wb3J0IG9yZy5lY2xpcHNlLmpkdC5jb3JlLmNvbXBpbGVyLkNoYXJPcGVyYXRpb247CiBpbXBvcnQgb3JnLmVjbGlwc2UuamR0LmludGVybmFsLmNvbXBpbGVyLkFTVFZpc2l0b3I7Ci1pbXBvcnQgb3JnLmVjbGlwc2UuamR0LmludGVybmFsLmNvbXBpbGVyLmltcGwuKjsKLWltcG9ydCBvcmcuZWNsaXBzZS5qZHQuaW50ZXJuYWwuY29tcGlsZXIuY29kZWdlbi4qOwotaW1wb3J0IG9yZy5lY2xpcHNlLmpkdC5p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2UuamR0LmNvcmUvY29tcGlsZXIvb3JnL2VjbGlwc2UvamR0L2ludGVybmFsL2NvbXBpbGVyL2FzdC9PcGVyYXRvckV4cHJlc3Npb24uamF2YQorKysgYi9vcmcuZWNsaXBzZS5qZHQuY29yZS9jb21waWxlci9vcmcvZWNsaXBzZS9qZHQvaW50ZXJuYWwvY29tcGlsZXIvYXN0L09wZXJhdG9yRXhwcmVzc2lvbi5qYXZhCkBAIC0xLDUgKzEsNSBAQAogLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKLSAqIENvcHlyaWdodCAoYykgMjAwMCwgMjAwNCBJQk0gQ29ycG9yYXRpb24gYW5kIG90aGVycy4KKyAqIENvcHlyaWdodCAoYykgMjAwMCwgMjAwNiBJQk0gQ29ycG9yYXRpb24gYW5kIG90aGVycy4KICAqIEFsbCByaWdodHMgcmVzZXJ2ZWQuIFRoaXMgcHJvZ3JhbSBhbmQgdGhlIGFjY29tcGFueWluZyBtYXRlcmlhbHMKICAqIGFyZSBtYWRlIGF2YWlsYWJsZSB1bmRlciB0aGUgdGVybXMgb2YgdGhlIEVjbGlwc2UgUHVibGljIExpY2Vuc2UgdjEuMAogICogd2hpY2ggYWNjb21wYW5pZXMgdGhpcyBkaXN0cmlidXRpb24sIGFuZCBpcyBhdmFpbGFibGUgYXQKQEAgLTcsMTAgKzcsMTIgQEAKICAqCiAgKiBDb250cmlidXRvcnM6CiAgKiAgICAgSUJNIENvcnBvcmF0aW9uIC0gaW5pdGlhbCBBUEkgYW5kIGltcGxlbWVudGF0aW9uCisgKiAgICAgUGVycnkgSmFtZXMgLSBudWxsU3RhdHVzIG1ldGhvZCBpbXByb3ZlbWVudCAoMTY1MzQ2KQogICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCiBwYWNrYWdlIG9yZy5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XRob2RJbmZvV2l0aEFubm90YXRpb25zLmphdmEKQEAgLTAsMCArMSw0NCBAQAorLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIENvcHlyaWdodCAoYykgMjAwNSwgMjAwNyBCRUEgU3lzdGVtcywgSW5jLgorICogQWxsIHJpZ2h0cyByZXNlcnZlZC4gVGhpcyBwcm9ncmFtIGFuZCB0aGUgYWNjb21wYW55aW5nIG1hdGVyaWFscworICogYXJlIG1hZGUgYXZhaWxhYmxlIHVuZGVyIHRoZSB0ZXJtcyBvZiB0aGUgRWNsaXBzZSBQdWJsaWMgTGljZW5zZSB2MS4wCisgKiB3aGljaCBhY2NvbXBhbmllcyB0aGlzIGRpc3RyaWJ1dGlvbiwgYW5kIGlzIGF2YWlsYWJsZSBhdAorICogaHR0cDovL3d3dy5lY2xpcHNlLm9yZy9sZWdhbC9lcGwtdjEwLmh0bWwKKyAqCisgKiBDb250cmlidXRvcnM6CisgKiAgICB0eWV1bmdAYmVhLmNvbSAtIGluaXRpYWwgQVBJIGFuZCBpbXBsZW1lbnRhdGlvbgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCitwYWNrYWdlIG9yZy5lY2xpcHNlLmpkdC5pbnRlcm5hbC5jb21waWxlci5jbGFzc2ZtdDsKKworaW1wb3J0IG9yZy5lY2xpcHNlLmpkdC5pbnRlcm5hbC5jb21waWxlci5lbnYuSUJpbmFyeUFubm90YXRpb247CisKK3B1YmxpYyBjbGFzcyBBbm5vdGF0aW9uTWV0aG9kSW5mb1dpdGhBbm5vdGF0aW9ucyBleHRlbmRzIEFubm90YXRpb25NZXRob2RJbmZvIHsKKwlwcml2YXRlIEFubm90YXRpb25JbmZvW10gYW5ub3RhdGlvbnM7CisKK0Fubm90YXRpb25NZXRob2RJbmZvV2l0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YWxzCiAgKiBhcmUgbWFkZSBhdmFpbGFibGUgdW5kZXIgdGhlIHRlcm1zIG9mIHRoZSBFY2xpcHNlIFB1YmxpYyBMaWNlbnNlIHYxLjAKICAqIHdoaWNoIGFjY29tcGFuaWVzIHRoaXMgZGlzdHJpYnV0aW9uLCBhbmQgaXMgYXZhaWxhYmxlIGF0CkBAIC0xMCwxMCArMTAsNDMgQEAKICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwogcGFja2FnZSBvcmcuZWNsaXBzZS5qZHQuaW50ZXJuYWwuY29tcGlsZXIuY2xhc3NmbXQ7CiAKLWltcG9ydCBvcmcuZWNsaXBzZS5qZHQuaW50ZXJuYWwuY29tcGlsZXIuZW52Lio7CitpbXBvcnQgb3JnLmVjbGlwc2UuamR0LmludGVybmFsLmNvbXBpbGVyLmFzdC5BU1ROb2RlOwogCi1wdWJsaWMgaW50ZXJmYWNlIENsYXNzRmlsZUNvbnN0YW50cyBleHRlbmRzIElDb25zdGFudHMgeworcHVibGljIGludGVyZmFjZSBDbGFzc0ZpbGVDb25zdGFudHMgewogCQorCWludCBBY2NEZWZhdWx0ID0gMDsKKwkvKgorCSAqIE1vZGlmaWVycworCSAqLworCWludCBBY2NQdWJsaWMgICAgICAgPSAweDAwMDE7CisJaW50IEFjY1ByaXZhdGUgICAgICA9IDB4MDAwMjsKKwlpbnQgQWNjUHJvdGVjdGVkICAgID0gMHgwMDA0OworCWludCBBY2NTdGF0aWMgICAgICAgPSAweDAwMDg7CisJaW50IEFjY0ZpbmFsICAgICAgICA9IDB4MDAxMDsKKwlpbnQgQWNjU3luY2hyb25pemVkID0gMHgwMDIwOworCWludCBBY2NWb2xhdGlsZSAgICAgPSAweDAwNDA7CisJaW50IEFjY0JyaWRnZSAgICAgICA9IDB4MDA0MDsKKwlpbnQgQWNjVHJhbnNpZW50ICAgID0gMHgwMDgwOworCWludCBBY2NW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24gKyAiXHRcdGludm9rZXN0YXRpYyBqYXZhLmxhbmcuQnl0ZS52YWx1ZU9mKGJ5dGUpIik7IC8vJE5PTi1OTFMtMSQKKyAgICAgICAgICAgICAgIC8vIGludm9rZXN0YXRpYzogQnl0ZS52YWx1ZU9mKGJ5dGUpCisgICAgICAgICAgICAgICAgdGhpcy5pbnZva2UoCisgICAgICAgICAgICAgICAgICAgIE9wY29kZXMuT1BDX2ludm9rZXN0YXRpYywKKyAgICAgICAgICAgICAgICAgICAgMSwgLy8gYXJnQ291bnQKKyAgICAgICAgICAgICAgICAgICAgMSwgLy8gcmV0dXJuIHR5cGUgc2l6ZQorICAgICAgICAgICAgICAgICAgICBDb25zdGFudFBvb2wuSmF2YUxhbmdCeXRlQ29uc3RhbnRQb29sTmFtZSwKKyAgICAgICAgICAgICAgICAgICAgQ29uc3RhbnRQb29sLlZhbHVlT2YsCisgICAgICAgICAgICAgICAgICAgIENvbnN0YW50UG9vbC5ieXRlQnl0ZVNpZ25hdHVyZSk7CisgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgLy8gbmV3IEJ5dGUoIGJ5dGUgKQorICAgIAkJCWlmIChERUJVRykgU3lzdGVtLm91dC5wcmludGxuKHBvc2l0aW9uICsgIlx0XHRpbnZva2VzcGVjaWFsIGphdmEubGFuZy5CeXRlKGJ5dGUpIik7IC8vJE5PTi1OTFMtMSQKKyAgICAgICAgICAgICAgICBuZXdXcmFwcGVyRm9yKHVuYm94ZWRUeXBlSUQpOworICAgICAgICAgICAgICAgIGR1cF94MSgpOworICAgICAgICAgICAgICAgIHN3YXAoKTsKKyAgICAgICAgICAgICAgICB0aGlzLmludm9rZSgKKyAgICAgICAgICAgICAgICAgICAgT3Bjb2Rlcy5PUENfaW52b2tlc3BlY2lhbCwKKyAgICAgICAgICAgICAgICAgICAgMSwgLy8gYXJnQ291bnQKKyAgICAgICAgICAgICAgICAgICAgMCwgLy8gcmV0dXJuIHR5cGUgc2l6ZQorICAgICAgICAgICAgICAgICAgICBDb25zdGFudFBvb2wuSmF2YUxhbmdCeXRlQ29uc3RhbnRQb29sTmFtZSwKKyAgICAgICAgICAgICAgICAgICAgQ29uc3RhbnRQb29sLkluaXQsCisgICAgICAgICAgICAgICAgICAgIENvbnN0YW50UG9vbC5CeXRlQ29uc3RyU2lnbmF0dXJlKTsKKyAgICAgICAgICAgIH0gICAgICAgCisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBUeXBlSWRzLlRfc2hvcnQgOgorICAgICAgICAgICAgaWYgKCB0aGlzLnRhcmdldExldmVsID49IENsYXNzRmlsZUNvbnN0YW50cy5KREsxXzUgKSB7CisgICAgICAgICAgICAgICAgLy8gaW52b2tlc3RhdGljOiBTaG9ydC52YWx1ZU9mKHNob3J0KQorICAgIAkJCWlmIChERUJVRykgU3lzdGVtLm91dC5wcmludGxuKHBvc2l0aW9uICsgIlx0XHRpbnZva2VzdGF0aWMgamF2YS5sYW5nLlNob3J0LnZhbHVlT2Yoc2hvcnQpIik7IC8vJE5PTi1OTFMtMSQKKyAgICAgICAgICAgICAgICB0aGlzLmludm9rZSgKKyAgICAgICAgICAgICAgICAgICAgT3Bjb2Rlcy5PUENfaW52b2tlc3RhdGljLAorICAgICAgICAgICAgICAgICAgICAxLCAvLyBhcmdDb3VudAorICAgICAgICAgICAgICAgICAgICAxLCAvLyByZXR1cm4gdHlwZSBzaXplCisgICAgICAgICAgICAgICAgICAgIENvbnN0YW50UG9vbC5KYXZhTGFuZ1Nob3J0Q29uc3RhbnRQb29sTmFtZSwKKyAgICAgICAgICAgICAgICAgICAgQ29uc3RhbnRQb29sLlZhbHVlT2YsCisgICAgICAgICAgICAgICAgICAgIENvbnN0YW50UG9vbC5zaG9ydFNob3J0U2lnbmF0dXJlKTsKKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgLy8gbmV3IFNob3J0KHNob3J0KQorICAgICAgICAgICAgCWlmIChERUJVRykgU3lzdGVtLm91dC5wcmludGxuKHBvc2l0aW9uICsgIlx0XHRpbnZva2VzcGVjaWFsIGphdmEubGFuZy5TaG9ydChzaG9ydCkiKTsgLy8kTk9OLU5MUy0xJAorICAgICAgICAgICAgCW5ld1dyYXBwZXJGb3IodW5ib3hlZFR5cGVJRCk7ICAgICAgICAgICAgICAgIAorICAgICAgICAgICAgICAgIGR1cF94MSgpOworICAgICAgICAgICAgICAgIHN3YXAoKTsgICAgICAgICAgICAgCisgICAgICAgICAgICAgICAgdGhpcy5pbnZva2UoCisgICAgICAgICAgICAgICAgICAgIE9wY29kZXMuT1BDX2ludm9rZXNwZWNpYWwsCisgICAgICAgICAgICAgICAgICAgIDEsIC8vIGFyZ0NvdW50CisgICAgICAgICAgICAgICAgICAgIDAsIC8vIHJldHVybiB0eXBlIHNpemUKKyAgICAgICAgICAgICAgICAgICAgQ29uc3RhbnRQb29sLkphdmFMYW5nU2hvcnRDb25zdGFudFBvb2xOYW1lLAorICAgICAgICAgICAgICAgICAgICBDb25zdGFudFBvb2wuSW5pdCwKKyAgICAgICAgICAgICAgICAgICAgQ29uc3RhbnRQb29sLlNob3J0Q29uc3RyU2lnbmF0dXJlKTsgICAgIAorICAgICAgICAgICAgfQorICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgVHlwZUlkcy5UX2NoYXIgOgorICAgICAgICAgICAgaWYgKCB0aGlzLnRhcmdldExldmVsID49IENsYXNzRmlsZUNvbnN0YW50cy5KREsxXzUgKSB7CisgICAgICAgICAgICAgICAgLy8gaW52b2tlc3RhdGljOiBDaGFyYWN0ZXIudmFsdWVPZihjaGFyKQorICAgICAgICAgICAgCWlmIChERUJVRykgU3lzdGVtLm91dC5wcmludGxuKHBvc2l0aW9uICsgIlx0XHRpbnZva2VzdGF0aWMgamF2YS5sYW5nLkNoYXJhY3Rlci52YWx1ZU9mKGNoYXIpIik7IC8vJE5PTi1OTFMtMSQKKyAgICAgICAgICAgICAgICB0aGlzLmludm9rZSgKKyAgICAgICAgICAgICAgICAgICAgT3Bjb2Rlcy5PUENfaW52b2tlc3RhdGljLAorICAgICAgICAgICAgICAgICAgICAxLCAvLyBhcmdDb3VudAorICAgICAgICAgICAgICAgICAgICAxLCAvLyByZXR1cm4gdHlwZSBzaXplCisgICAgICAgICAgICAgICAgICAgIENvbnN0YW50UG9vbC5KYXZhTGFuZ0NoYXJhY3RlckNvbnN0YW50UG9vbE5hbWUsCisgICAgICAgICAgICAgICAgICAgIENvbnN0YW50UG9vbC5WYWx1ZU9mLAorICAgICAgICAgICAgICAgICAgICBDb25zdGFudFBvb2wuY2hhckNoYXJhY3RlclNpZ25hdHVyZSk7CisgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgIC8vIG5ldyBDaGFyKCBjaGFyICkKKyAgICAgICAgICAgIAlpZiAoREVCVUcpIFN5c3RlbS5vdXQucHJpbnRsbihwb3NpdGlvbiArICJcdFx0aW52b2tlc3BlY2lhbCBqYXZhLmxhbmcuQ2hhcmFjdGVyKGNoYXIpIik7IC8vJE5PTi1OTFMtMSQKKyAgICAgICAgICAgICAgICBuZXdXcmFwcGVyRm9yKHVuYm94ZWRUeXBlSUQpOworICAgICAgICAgICAgICAgIGR1cF94MSgpOworICAgICAgICAgICAgICAgIHN3YXAoKTsKKyAgICAgICAgICAgICAgICB0aGlzLmludm9rZSgKKyAgICAgICAgICAgICAgICAgICAgT3Bjb2Rlcy5PUENfaW52b2tlc3BlY2lhbCwKKyAgICAgICAgICAgICAgICAgICAgMSwgLy8gYXJnQ291bnQKKyAgICAgICAgICAgICAgICAgICAgMCwgLy8gcmV0dXJuIHR5cGUgc2l6ZQorICAgICAgICAgICAgICAgICAgICBDb25zdGFudFBvb2wuSmF2YUxhbmdDaGFyYWN0ZXJDb25zdGFudFBvb2xOYW1lLAorICAgICAgICAgICAgICAgICAgICBDb25zdGFudFBvb2wuSW5pdCwKKyAgICAgICAgICAgICAgICAgICAgQ29uc3RhbnRQb29sLkNoYXJDb25zdHJTaWduYXR1cmUpOworICAgICAgICAgICAgfSAgICAgICAKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIFR5cGVJZHMuVF9pbnQgOiAgICAgICAgICAgICAKKyAgICAgICAgICAgIGlmICh0aGlzLnRhcmdldExldmVsID49IENsYXNzRmlsZUNvbnN0YW50cy5KREsxXzUpIHsKKyAgICAgICAgICAgICAgICAvLyBpbnZva2VzdGF0aWM6IEludGVnZXIudmFsdWVPZihpbnQpCisgICAgICAgICAgICAJaWYgKERFQlVHKSBTeXN0ZW0ub3V0LnByaW50bG4ocG9zaXRpb24gKyAiXHRcdGludm9rZXN0YXRpYyBqYXZhLmxhbmcuSW50ZWdlci52YWx1ZU9mKGludCkiKTsgLy8kTk9OLU5MUy0xJAorICAgICAgICAgICAgICAgIHRoaXMuaW52b2tlKAorICAgICAgICAgICAgICAgICAgICBPcGNvZGVzLk9QQ19pbnZva2VzdGF0aWMsCisgICAgICAgICAgICAgICAgICAgIDEsIC8vIGFyZ0NvdW50CisgICAgICAgICAgICAgICAgICAgIDEsIC8vIHJldHVybiB0eXBlIHNpemUKKyAgICAgICAgICAgICAgICAgICAgQ29uc3RhbnRQb29sLkphdmFMYW5nSW50ZWdlckNvbnN0YW50UG9vbE5hbWUsCisgICAgICAgICAgICAgICAgICAgIENvbnN0YW50UG9vbC5WYWx1ZU9mLAorICAgICAgICAgICAgICAgICAgICBDb25zdGFudFBvb2wuSW50SW50ZWdlclNpZ25hdHVyZSk7CisgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgIC8vIG5ldyBJbnRlZ2VyKGludCkKKyAgICAgICAgICAgIAlpZiAoREVCVUcpIFN5c3RlbS5vdXQucHJpbnRsbihwb3NpdGlvbiArICJcdFx0aW52b2tlc3BlY2lhbCBqYXZhLmxhbmcuSW50ZWdlcihpbnQpIik7IC8vJE5PTi1OTFMtMSQKKyAgICAgICAgICAgICAgICBuZXdXcmFwcGVyRm9yKHVuYm94ZWRUeXBlSUQpOworICAgICAgICAgICAgICAgIGR1cF94MSgpOworICAgICAgICAgICAgICAgIHN3YXAoKTsgICAgICAgICAgICAgCisgICAgICAgICAgICAgICAgdGhpcy5pbnZva2UoCisgICAgICAgICAgICAgICAgICAgIE9wY29kZXMuT1BDX2ludm9rZXNwZWNpYWwsCisgICAgICAgICAgICAgICAgICAgIDEsIC8vIGFyZ0NvdW50CisgICAgICAgICAgICAgICAgICAgIDAsIC8vIHJldHVybiB0eXBlIHNpemUKKyAgICAgICAgICAgICAgICAgICAgQ29uc3RhbnRQb29sLkphdmFMYW5nSW50ZWdlckNvbnN0YW50UG9vbE5hbWUsCisgICAgICAgICAgICAgICAgICAgIENvbnN0YW50UG9vbC5Jbml0LAorICAgICAgICAgICAgICAgICAgICBDb25zdGFudFBvb2wuSW50Q29uc3RyU2lnbmF0dXJlKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIFR5cGVJZHMuVF9sb25nIDoKKyAgICAgICAgICAgIGlmICh0aGlzLnRhcmdldExldmVsID49IENsYXNzRmlsZUNvbnN0YW50cy5KREsxXzUpIHsgCisgICAgICAgICAgICAgICAgLy8gaW52b2tlc3RhdGljOiBMb25nLnZhbHVlT2YobG9uZykKKyAgICAgICAgICAgIAlpZiAoREVCVUcpIFN5c3RlbS5vdXQucHJpbnRsbihwb3NpdGlvbiArICJcdFx0aW52b2tlc3RhdGljIGphdmEubGFuZy5Mb25nLnZhbHVlT2YobG9uZykiKTsgLy8kTk9OLU5MUy0xJAorICAgICAgICAgICAgICAgIHRoaXMuaW52b2tlKAorICAgICAgICAgICAgICAgICAgICBPcGNvZGVzLk9QQ19pbnZva2VzdGF0aWMsCisgICAgICAgICAgICAgICAgICAgIDIsIC8vIGFyZ0NvdW50CisgICAgICAgICAgICAgICAgICAgIDEsIC8vIHJldHVybiB0eXBlIHNpemUKKyAgICAgICAgICAgICAgICAgICAgQ29uc3RhbnRQb29sLkphdmFMYW5nTG9uZ0NvbnN0YW50UG9vbE5hbWUsCisgICAgICAgICAgICAgICAgICAgIENvbnN0YW50UG9vbC5WYWx1ZU9mLAorICAgICAgICAgICAgICAgICAgICBDb25zdGFudFBvb2wubG9uZ0xvbmdTaWduYXR1cmUpOworICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAvLyBuZXcgTG9uZyggbG9uZyApCisgICAgICAgICAgICAJaWYgKERFQlVHKSBTeXN0ZW0ub3V0LnByaW50bG4ocG9zaXRpb24gKyAiXHRcdGludm9rZXNwZWNpYWwgamF2YS5sYW5nLkxvbmcobG9uZykiKTsgLy8kTk9OLU5MUy0xJAorICAgICAgICAgICAgICAgIG5ld1dyYXBwZXJGb3IodW5ib3hlZFR5cGVJRCk7CisgICAgICAgICAgICAgICAgZHVwX3gyKCk7CisgICAgICAgICAgICAgICAgZHVwX3gyKCk7CisgICAgICAgICAgICAgICAgcG9wKCk7CisgICAgICAgICAgICAgICAgdGhpcy5pbnZva2UoCisgICAgICAgICAgICAgICAgICAgIE9wY29kZXMuT1BDX2ludm9rZXNwZWNpYWwsCisgICAgICAgICAgICAgICAgICAgIDIsIC8vIGFyZ0NvdW50CisgICAgICAgICAgICAgICAgICAgIDAsIC8vIHJldHVybiB0eXBlIHNpemUKKyAgICAgICAgICAgICAgICAgICAgQ29uc3RhbnRQb29sLkphdmFMYW5nTG9uZ0NvbnN0YW50UG9vbE5hbWUsCisgICAgICAgICAgICAgICAgICAgIENvbnN0YW50UG9vbC5Jbml0LAorICAgICAgICAgICAgICAgICAgICBDb25zdGFudFBvb2wuTG9uZ0NvbnN0clNpZ25hdHVyZSk7CisgICAgICAgICAgICB9ICAgICAgICAgICAgICAgICAgIAorICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgVHlwZUlkcy5UX2Zsb2F0IDoKKyAgICAgICAgICAgIGlmICggdGhpcy50YXJnZXRMZXZlbCA+PSBDbGFzc0ZpbGVDb25zdGFudHMuSkRLMV81ICkgeworICAgICAgICAgICAgICAgIC8vIGludm9rZXN0YXRpYzogRmxvYXQudmFsdWVPZihmbG9hdCkKKyAgICAgICAgICAgIAlpZiAoREVCVUcpIFN5c3RlbS5vdXQucHJpbnRsbihwb3NpdGlvbiArICJcdFx0aW52b2tlc3RhdGljIGphdmEubGFuZy5GbG9hdC52YWx1ZU9mKGZsb2F0KSIpOyAvLyROT04tTkxTLTEkCisgICAgICAgICAgICAgICAgdGhpcy5pbnZva2UoCisgICAgICAgICAgICAgICAgICAgIE9wY29kZXMuT1BDX2ludm9rZXN0YXRpYywKKyAgICAgICAgICAgICAgICAgICAgMSwgLy8gYXJnQ291bnQKKyAgICAgICAgICAgICAgICAgICAgMSwgLy8gcmV0dXJuIHR5cGUgc2l6ZQorICAgICAgICAgICAgICAgICAgICBDb25zdGFudFBvb2wuSmF2YUxhbmdGbG9hdENvbnN0YW50UG9vbE5hbWUsCisgICAgICAgICAgICAgICAgICAgIENvbnN0YW50UG9vbC5WYWx1ZU9mLAorICAgICAgICAgICAgICAgICAgICBDb25zdGFudFBvb2wuZmxvYXRGbG9hdFNpZ25hdHVyZSk7CisgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgIC8vIG5ldyBGbG9hdChmbG9hdCkKKyAgICAgICAgICAgIAlpZiAoREVCVUcpIFN5c3RlbS5vdXQucHJpbnRsbihwb3NpdGlvbiArICJcdFx0aW52b2tlc3BlY2lhbCBqYXZhLmxhbmcuRmxvYXQoZmxvYXQpIik7IC8vJE5PTi1OTFMtMSQKKyAgICAgICAgICAgICAgICBuZXdXcmFwcGVyRm9yKHVuYm94ZWRUeXBlSUQpOworICAgICAgICAgICAgICAgIGR1cF94MSgpOworICAgICAgICAgICAgICAgIHN3YXAoKTsgICAgICAgICAgICAgCisgICAgICAgICAgICAgICAgdGhpcy5pbnZva2UoCisgICAgICAgICAgICAgICAgICAgIE9wY29kZXMuT1BDX2ludm9rZXNwZWNpYWwsCisgICAgICAgICAgICAgICAgICAgIDEsIC8vIGFyZ0NvdW50CisgICAgICAgICAgICAgICAgICAgIDAsIC8vIHJldHVybiB0eXBlIHNpemUKKyAgICAgICAgICAgICAgICAgICAgQ29uc3RhbnRQb29sLkphdmFMYW5nRmxvYXRDb25zdGFudFBvb2xOYW1lLAorICAgICAgICAgICAgICAgICAgICBDb25zdGFudFBvb2wuSW5pdCwKKyAgICAgICAgICAgICAgICAgICAgQ29uc3RhbnRQb29sLkZsb2F0Q29uc3RyU2lnbmF0dXJlKTsKKyAgICAgICAgICAgIH0gICAgICAgCisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBUeXBlSWRzLlRfZG91YmxlIDoKKyAgICAgICAgICAgIGlmICggdGhpcy50YXJnZXRMZXZlbCA+PSBDbGFzc0ZpbGVDb25zdGFudHMuSkRLMV81ICkgeyAKKyAgICAgICAgICAgICAgICAvLyBpbnZva2VzdGF0aWM6IERvdWJsZS52YWx1ZU9mKGRvdWJsZSkKKyAgICAgICAgICAgIAlpZiAoREVCVUcpIFN5c3RlbS5vdXQucHJpbnRsbihwb3NpdGlvbiArICJcdFx0aW52b2tlc3RhdGljIGphdmEubGFuZy5Eb3VibGUudmFsdWVPZihkb3VibGUpIik7IC8vJE5PTi1OTFMtMSQKKyAgICAgICAgICAgICAgICB0aGlzLmludm9rZSgKKyAgICAgICAgICAgICAgICAgICAgT3Bjb2Rlcy5PUENfaW52b2tlc3RhdGljLAorICAgICAgICAgICAgICAgICAgICAyLCAvLyBhcmdDb3VudAorICAgICAgICAgICAgICAgICAgICAxLCAvLyByZXR1cm4gdHlwZSBzaXplCisgICAgICAgICAgICAgICAgICAgIENvbnN0YW50UG9vbC5KYXZhTGFuZ0RvdWJsZUNvbnN0YW50UG9vbE5hbWUsCisgICAgICAgICAgICAgICAgICAgIENvbnN0YW50UG9vbC5WYWx1ZU9mLAorICAgICAgICAgICAgICAgICAgICBDb25zdGFudFBvb2wuZG91YmxlRG91YmxlU2lnbmF0dXJlKTsKKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgLy8gbmV3IERvdWJsZSggZG91YmxlICkKKyAgICAgICAgICAgIAlpZiAoREVCVUcpIFN5c3RlbS5vdXQucHJpbnRsbihwb3NpdGlvbiArICJcdFx0aW52b2tlc3BlY2lhbCBqYXZhLmxhbmcuRG91YmxlKGRvdWJsZSkiKTsgLy8kTk9OLU5MUy0xJAorICAgICAgICAgICAgCW5ld1dyYXBwZXJGb3IodW5ib3hlZFR5cGVJRCk7ICAgICAgICAgICAgICAgIAorICAgICAgICAgICAgICAgIGR1cF94MigpOworICAgICAgICAgICAgICAgIGR1cF94MigpOworICAgICAgICAgICAgICAgIHBvcCgpOworICAgICAgICAgICAgICAgIAorICAgICAgICAgICAgICAgIHRoaXMuaW52b2tlKAorICAgICAgICAgICAgICAgICAgICBPcGNvZGVzLk9QQ19pbnZva2VzcGVjaWFsLAorICAgICAgICAgICAgICAgICAgICAyLCAvLyBhcmdDb3VudAorICAgICAgICAgICAgICAgICAgICAwLCAvLyByZXR1cm4gdHlwZSBzaXplCisgICAgICAgICAgICAgICAgICAgIENvbnN0YW50UG9vbC5KYXZhTGFuZ0RvdWJsZUNvbnN0YW50UG9vbE5hbWUsCisgICAgICAgICAgICAgICAgICAgIENvbnN0YW50UG9vbC5Jbml0LAorICAgICAgICAgICAgICAgICAgICBDb25zdGFudFBvb2wuRG91YmxlQ29uc3RyU2lnbmF0dXJlKTsKKyAgICAgICAgICAgIH0gICAgICAgCisgICAgICAgICAgICAKKyAgICAgICAgICAgIGJyZWFrOyAgCisgICAgICAgIGNhc2UgVHlwZUlkcy5UX2Jvb2xlYW4gOgorICAgICAgICAgICAgaWYgKCB0aGlzLnRhcmdldExldmVsID49IENsYXNzRmlsZUNvbnN0YW50cy5KREsxXzUgKSB7CisgICAgICAgICAgICAgICAgLy8gaW52b2tlc3RhdGljOiBCb29sZWFuLnZhbHVlT2YoYm9vbGVhbikKKyAgICAgICAgICAgIAlpZiAoREVCVUcpIFN5c3RlbS5vdXQucHJpbnRsbihwb3NpdGlvbiArICJcdFx0aW52b2tlc3RhdGljIGphdmEubGFuZy5Cb29sZWFuLnZhbHVlT2YoYm9vbGVhbikiKTsgLy8kTk9OLU5MUy0xJAorICAgICAgICAgICAgICAgIHRoaXMuaW52b2tlKAorICAgICAgICAgICAgICAgICAgICBPcGNvZGVzLk9QQ19pbnZva2VzdGF0aWMsCisgICAgICAgICAgICAgICAgICAgIDEsIC8vIGFyZ0NvdW50CisgICAgICAgICAgICAgICAgICAgIDEsIC8vIHJldHVybiB0eXBlIHNpemUKKyAgICAgICAgICAgICAgICAgICAgQ29uc3RhbnRQb29sLkphdmFMYW5nQm9vbGVhbkNvbnN0YW50UG9vbE5hbWUsCisgICAgICAgICAgICAgICAgICAgIENvbnN0YW50UG9vbC5WYWx1ZU9mLAorICAgICAgICAgICAgICAgICAgICBDb25zdGFudFBvb2wuYm9vbGVhbkJvb2xlYW5TaWduYXR1cmUpOworICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAvLyBuZXcgQm9vbGVhbihib29sZWFuKQorICAgICAgICAgICAgCWlmIChERUJVRykgU3lzdGVtLm91dC5wcmludGxuKHBvc2l0aW9uICsgIlx0XHRpbnZva2VzcGVjaWFsIGphdmEubGFuZy5Cb29sZWFuKGJvb2xlYW4pIik7IC8vJE5PTi1OTFMtMSQKKyAgICAgICAgICAgICAgICBuZXdXcmFwcGVyRm9yKHVuYm94ZWRUeXBlSUQpOworICAgICAgICAgICAgICAgIGR1cF94MSgpOworICAgICAgICAgICAgICAgIHN3YXAoKTsgICAgICAgICAgICAgCisgICAgICAgICAgICAgICAgdGhpcy5pbnZva2UoCisgICAgICAgICAgICAgICAgICAgIE9wY29kZXMuT1BDX2ludm9rZXNwZWNpYWwsCisgICAgICAgICAgICAgICAgICAgIDEsIC8vIGFyZ0NvdW50CisgICAgICAgICAgICAgICAgICAgIDAsIC8vIHJldHVybiB0eXBlIHNpemUKKyAgICAgICAgICAgICAgICAgICAgQ29uc3RhbnR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XRlSW5kZXgsIGxvY2FsQmluZGluZyk7CisgICAgICAgICAgICBpZiAoIWlzRGVmaW5pdGVseUFzc2lnbmVkKSB7CisgICAgICAgICAgICAgICAgaWYgKHRoaXMuc3RhdGVJbmRleGVzICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICAgICAgZm9yIChpbnQgaiA9IDAsIG1heCA9IHRoaXMuc3RhdGVJbmRleGVzQ291bnRlcjsgaiA8IG1heDsgaisrKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNEZWZpbml0ZWx5QXNzaWduZWQoc2NvcGUsIHRoaXMuc3RhdGVJbmRleGVzW2pdLCBsb2NhbEJpbmRpbmcpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudEZyYW1lLnB1dExvY2FsKGxvY2FsQmluZGluZy5yZXNvbHZlZFBvc2l0aW9uLCBuZXcgVmVyaWZpY2F0aW9uVHlwZUluZm8obG9jYWxCaW5kaW5nLnR5cGUpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoKGxvY2FsQmluZGluZy5pbml0aWFsaXphdGlvbkNvdW50ID09IDApIHx8IChsb2NhbEJpbmRpbmcuaW5pdGlhbGl6YXRpb25QQ3NbKChsb2NhbEJpbmRpbmcuaW5pdGlhbGl6YXRpb25Db3VudCAtIDEpIDw8IDEpICsgMV0gIT0gLTEpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8qIFRoZXJlIGFyZSB0d28gY2FzZXM6CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqIDEpIHRoZXJlIGlzIG5vIGluaXRpYWxpemF0aW9uIGludGVydmFsIG9wZW5lZCA9PT4gYWRkIGFuIG9wZW5lZCBpbnRlcnZhbAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKiAyKSB0aGVyZSBpcyBhbHJlYWR5IHNvbWUgaW5pdGlhbGl6YXRpb24gaW50ZXJ2YWxzIGJ1dCB0aGUgbGFzdCBvbmUgaXMgY2xvc2VkID09PiBhZGQgYW4gb3BlbmVkIGludGVydmFsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqIEFuIG9wZW5lZCBpbnRlcnZhbCBtZWFucyB0aGF0IHRoZSB2YWx1ZSBhdCBsb2NhbEJpbmRpbmcuaW5pdGlhbGl6YXRpb25QQ3NbbG9jYWxCaW5kaW5nLmluaXRpYWxpemF0aW9uQ291bnQgLSAxXVsxXQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKiBpcyBlcXVhbHMgdG8gLTEuCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqIGluaXRpYWxpemF0aW9uUENzIGlzIGEgY29sbGVjdGlvbiBvZiBwYWlycyBvZiBpbnQ6CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqIAlmaXJzdCB2YWx1ZSBpcyB0aGUgc3RhcnRQQyBhbmQgc2Vjb25kIHZhbHVlIGlzIHRoZSBlbmRQQy4gLTEgb25lIGZvciB0aGUgbGFzdCB2YWx1ZSBtZWFucyB0aGF0IHRoZSBpbnRlcnZhbAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKiAJaXMgbm90IGNsb3NlZCB5ZXQuCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqLworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2NhbEJpbmRpbmcucmVjb3JkSW5pdGlhbGl6YXRpb25TdGFydFBDKHBvc2l0aW9uKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWUgbG9vcDsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgY3VycmVudEZyYW1lLnB1dExvY2FsKGxvY2FsQmluZGluZy5yZXNvbHZlZFBv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KyAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUubnVtYmVyT2ZTdGFja0l0ZW1zLS07CisgICAgICAgIFZlcmlmaWNhdGlvblR5cGVJbmZvIGluZm8yID0gdGhpcy5jdXJyZW50RnJhbWUuc3RhY2tJdGVtc1t0aGlzLmN1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbXMgLSAxXTsKKyAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUubnVtYmVyT2ZTdGFja0l0ZW1zLS07CisgICAgICAgIHN3aXRjaChpbmZvMi5pZCgpKSB7CisgICAgICAgICAgICBjYXNlIFR5cGVJZHMuVF9sb25nIDoKKyAgICAgICAgICAgIGNhc2UgVHlwZUlkcy5UX2RvdWJsZSA6CisgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUuYWRkU3RhY2tJdGVtKGluZm8pOworICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudEZyYW1lLmFkZFN0YWNrSXRlbShpbmZvMik7CisgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUuYWRkU3RhY2tJdGVtKGluZm8pOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICBudW1iZXJPZlN0YWNrSXRlbXMgPSB0aGlzLmN1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbXM7CisgICAgICAgICAgICAgICAgaWYgKG51bWJlck9mU3RhY2tJdGVtcyA+PSAxKSB7CisgICAgICAgICAgICAgICAgICAgIFZlcmlmaWNhdGlvblR5cGVJbmZvIGluZm8zID0gdGhpcy5jdXJyZW50RnJhbWUuc3RhY2tJdGVtc1tudW1iZXJPZlN0YWNrSXRlbXMgLSAxXTsKKyAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUubnVtYmVyT2ZTdGFja0l0ZW1zLS07CisgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudEZyYW1lLmFkZFN0YWNrSXRlbShpbmZvKTsKKyAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUuYWRkU3RhY2tJdGVtKGluZm8zKTsKKyAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUuYWRkU3RhY2tJdGVtKGluZm8yKTsKKyAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUuYWRkU3RhY2tJdGVtKGluZm8pOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgIH0KK30KK3B1YmxpYyB2b2lkIGR1cDIoKSB7CisgICAgc3VwZXIuZHVwMigpOworICAgIGludCBudW1iZXJPZlN0YWNrSXRlbXMgPSB0aGlzLmN1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbXM7CisgICAgaWYgKG51bWJlck9mU3RhY2tJdGVtcyA+PSAxKSB7CisgICAgICAgIFZlcmlmaWNhdGlvblR5cGVJbmZvIGluZm8gPSB0aGlzLmN1cnJlbnRGcmFtZS5zdGFja0l0ZW1zW251bWJlck9mU3RhY2tJdGVtcyAtIDFdOworICAgICAgICB0aGlzLmN1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbXMtLTsKKyAgICAgICAgc3dpdGNoKGluZm8uaWQoKSkgeworICAgICAgICAgICAgY2FzZSBUeXBlSWRzLlRfZG91YmxlIDoKKyAgICAgICAgICAgIGNhc2UgVHlwZUlkcy5UX2xvbmcgOgorICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudEZyYW1lLmFkZFN0YWNrSXRlbShpbmZvKTsKKyAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnRGcmFtZS5hZGRTdGFja0l0ZW0oaW5mbyk7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgIG51bWJlck9mU3RhY2tJdGVtcyA9IHRoaXMuY3VycmVudEZyYW1lLm51bWJlck9mU3RhY2tJdGVtczsKKyAgICAgICAgICAgICAgICBpZiAobnVtYmVyT2ZTdGFja0l0ZW1zID49IDEpIHsKKyAgICAgICAgICAgICAgICAgICAgVmVyaWZpY2F0aW9uVHlwZUluZm8gaW5mbzIgPSB0aGlzLmN1cnJlbnRGcmFtZS5zdGFja0l0ZW1zW251bWJlck9mU3RhY2tJdGVtcyAtIDFdOworICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbXMtLTsKKyAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUuYWRkU3RhY2tJdGVtKGluZm8yKTsKKyAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUuYWRkU3RhY2tJdGVtKGluZm8pOworICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnRGcmFtZS5hZGRTdGFja0l0ZW0oaW5mbzIpOworICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnRGcmFtZS5hZGRTdGFja0l0ZW0oaW5mbyk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgfQorfQorcHVibGljIHZvaWQgZHVwMl94MSgpIHsKKyAgICBzdXBlci5kdXAyX3gxKCk7CisgICAgaW50IG51bWJlck9mU3RhY2tJdGVtcyA9IHRoaXMuY3VycmVudEZyYW1lLm51bWJlck9mU3RhY2tJdGVtczsKKyAgICBpZiAobnVtYmVyT2ZTdGFja0l0ZW1zID49IDIpIHsKKyAgICAgICAgVmVyaWZpY2F0aW9uVHlwZUluZm8gaW5mbyA9IHRoaXMuY3VycmVudEZyYW1lLnN0YWNrSXRlbXNbbnVtYmVyT2ZTdGFja0l0ZW1zIC0gMV07CisgICAgICAgIHRoaXMuY3VycmVudEZyYW1lLm51bWJlck9mU3RhY2tJdGVtcy0tOworICAgICAgICBWZXJpZmljYXRpb25UeXBlSW5mbyBpbmZvMiA9IHRoaXMuY3VycmVudEZyYW1lLnN0YWNrSXRlbXNbdGhpcy5jdXJyZW50RnJhbWUubnVtYmVyT2ZTdGFja0l0ZW1zIC0gMV07CisgICAgICAgIHRoaXMuY3VycmVudEZyYW1lLm51bWJlck9mU3RhY2tJdGVtcy0tOworICAgICAgICBzd2l0Y2goaW5mby5pZCgpKSB7CisgICAgICAgICAgICBjYXNlIFR5cGVJZHMuVF9kb3VibGUgOgorICAgICAgICAgICAgY2FzZSBUeXBlSWRzLlRfbG9uZyA6CisgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUuYWRkU3RhY2tJdGVtKGluZm8pOworICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudEZyYW1lLmFkZFN0YWNrSXRlbShpbmZvMik7CisgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUuYWRkU3RhY2tJdGVtKGluZm8pOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICBudW1iZXJPZlN0YWNrSXRlbXMgPSB0aGlzLmN1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbXM7CisgICAgICAgICAgICAgICAgaWYgKG51bWJlck9mU3RhY2tJdGVtcyA+PSAxKSB7CisgICAgICAgICAgICAgICAgICAgIFZlcmlmaWNhdGlvblR5cGVJbmZvIGluZm8zID0gdGhpcy5jdXJyZW50RnJhbWUuc3RhY2tJdGVtc1tudW1iZXJPZlN0YWNrSXRlbXMgLSAxXTsKKyAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUubnVtYmVyT2ZTdGFja0l0ZW1zLS07CisgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudEZyYW1lLmFkZFN0YWNrSXRlbShpbmZvMik7CisgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudEZyYW1lLmFkZFN0YWNrSXRlbShpbmZvKTsKKyAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUuYWRkU3RhY2tJdGVtKGluZm8zKTsKKyAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUuYWRkU3RhY2tJdGVtKGluZm8yKTsKKyAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUuYWRkU3RhY2tJdGVtKGluZm8pOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgIH0KK30KK3B1YmxpYyB2b2lkIGR1cDJfeDIoKSB7CisgICAgc3VwZXIuZHVwMl94MigpOworICAgIGludCBudW1iZXJPZlN0YWNrSXRlbXMgPSB0aGlzLmN1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbXM7CisgICAgaWYgKG51bWJlck9mU3RhY2tJdGVtcyA+PSAyKSB7CisgICAgICAgIFZlcmlmaWNhdGlvblR5cGVJbmZvIGluZm8gPSB0aGlzLmN1cnJlbnRGcmFtZS5zdGFja0l0ZW1zW251bWJlck9mU3RhY2tJdGVtcyAtIDFdOworICAgICAgICB0aGlzLmN1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbXMtLTsKKyAgICAgICAgVmVyaWZpY2F0aW9uVHlwZUluZm8gaW5mbzIgPSB0aGlzLmN1cnJlbnRGcmFtZS5zdGFja0l0ZW1zW3RoaXMuY3VycmVudEZyYW1lLm51bWJlck9mU3RhY2tJdGVtcyAtIDFdOworICAgICAgICB0aGlzLmN1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbXMtLTsKKyAgICAgICAgc3dpdGNoKGluZm8uaWQoKSkgeworICAgICAgICAgICAgY2FzZSBUeXBlSWRzLlRfbG9uZyA6CisgICAgICAgICAgICBjYXNlIFR5cGVJZHMuVF9kb3VibGUgOgorICAgICAgICAgICAgICAgIHN3aXRjaChpbmZvMi5pZCgpKSB7CisgICAgICAgICAgICAgICAgICAgIGNhc2UgVHlwZUlkcy5UX2xvbmcgOgorICAgICAgICAgICAgICAgICAgICBjYXNlIFR5cGVJZHMuVF9kb3VibGUgOgorICAgICAgICAgICAgICAgICAgICAgICAgLy8gZm9ybSA0CisgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnRGcmFtZS5hZGRTdGFja0l0ZW0oaW5mbyk7CisgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnRGcmFtZS5hZGRTdGFja0l0ZW0oaW5mbzIpOworICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUuYWRkU3RhY2tJdGVtKGluZm8pOworICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgICAgICAgICAvLyBmb3JtIDIKKyAgICAgICAgICAgICAgICAgICAgICAgIG51bWJlck9mU3RhY2tJdGVtcyA9IHRoaXMuY3VycmVudEZyYW1lLm51bWJlck9mU3RhY2tJdGVtczsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChudW1iZXJPZlN0YWNrSXRlbXMgPj0gMSkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIFZlcmlmaWNhdGlvblR5cGVJbmZvIGluZm8zID0gdGhpcy5jdXJyZW50RnJhbWUuc3RhY2tJdGVtc1tudW1iZXJPZlN0YWNrSXRlbXMgLSAxXTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbXMtLTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnRGcmFtZS5hZGRTdGFja0l0ZW0oaW5mbyk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUuYWRkU3RhY2tJdGVtKGluZm8zKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnRGcmFtZS5hZGRTdGFja0l0ZW0oaW5mbzIpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudEZyYW1lLmFkZFN0YWNrSXRlbShpbmZvKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgIG51bWJlck9mU3RhY2tJdGVtcyA9IHRoaXMuY3VycmVudEZyYW1lLm51bWJlck9mU3RhY2tJdGVtczsKKyAgICAgICAgICAgICAgICBpZiAobnVtYmVyT2ZTdGFja0l0ZW1zID49IDEpIHsKKyAgICAgICAgICAgICAgICAgICAgVmVyaWZpY2F0aW9uVHlwZUluZm8gaW5mbzMgPSB0aGlzLmN1cnJlbnRGcmFtZS5zdGFja0l0ZW1zW251bWJlck9mU3RhY2tJdGVtcyAtIDFdOworICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbXMtLTsKKyAgICAgICAgICAgICAgICAgICAgc3dpdGNoKGluZm8zLmlkKCkpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgVHlwZUlkcy5UX2xvbmcgOgorICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBUeXBlSWRzLlRfZG91YmxlIDoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBmb3JtIDMKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnRGcmFtZS5hZGRTdGFja0l0ZW0oaW5mbzIpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudEZyYW1lLmFkZFN0YWNrSXRlbShpbmZvKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnRGcmFtZS5hZGRTdGFja0l0ZW0oaW5mbzMpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudEZyYW1lLmFkZFN0YWNrSXRlbShpbmZvMik7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUuYWRkU3RhY2tJdGVtKGluZm8pOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBmb3JtIDEKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBudW1iZXJPZlN0YWNrSXRlbXMgPSB0aGlzLmN1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbXM7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG51bWJlck9mU3RhY2tJdGVtcyA+PSAxKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFZlcmlmaWNhdGlvblR5cGVJbmZvIGluZm80ID0gdGhpcy5jdXJyZW50RnJhbWUuc3RhY2tJdGVtc1tudW1iZXJPZlN0YWNrSXRlbXMgLSAxXTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUubnVtYmVyT2ZTdGFja0l0ZW1zLS07CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudEZyYW1lLmFkZFN0YWNrSXRlbShpbmZvMik7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudEZyYW1lLmFkZFN0YWNrSXRlbShpbmZvKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUuYWRkU3RhY2tJdGVtKGluZm80KTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUuYWRkU3RhY2tJdGVtKGluZm8zKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUuYWRkU3RhY2tJdGVtKGluZm8yKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUuYWRkU3RhY2tJdGVtKGluZm8pOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgIH0KK30KK3B1YmxpYyB2b2lkIGV4aXRVc2VyU2NvcGUoQmxvY2tTY29wZSBjdXJyZW50U2NvcGUpIHsKKyAgICBpbnQgaW5kZXggPSB0aGlzLnZpc2libGVMb2NhbHNDb3VudCAtIDE7CisgICAgd2hpbGUgKGluZGV4ID49IDApIHsKKyAgICAgICAgTG9jYWxWYXJpYWJsZUJpbmRpbmcgdmlzaWJsZUxvY2FsID0gdmlzaWJsZUxvY2Fsc1tpbmRleF07CisgICAgICAgIGlmICh2aXNpYmxlTG9jYWwgPT0gbnVsbCkgeworICAgICAgICAgICAgaW5kZXgtLTsKKyAgICAgICAgICAgIGNvbnRpbnVlOworICAgICAgICB9CisgICAgICAgIGlmICh2aXNpYmxlTG9jYWwuZGVjbGFyaW5nU2NvcGUgIT0gY3VycmVudFNjb3BlKSAvLyBsZWZ0IGN1cnJlbnRTY29wZQorICAgICAgICAgICAgYnJlYWs7CisKKyAgICAgICAgLy8gdGhlcmUgbWF5IGJlIHNvbWUgcHJlc2VydmVkIGxvY2FscyBuZXZlciBpbml0aWFsaXplZAorICAgICAgICBpZiAodmlzaWJsZUxvY2FsLmluaXRpYWxpemF0aW9uQ291bnQgPiAwKXsKKyAgICAgICAgICAgIHRoaXMuY3VycmVudEZyYW1lLnJlbW92ZUxvY2Fscyh2aXNpYmxlTG9jYWwucmVzb2x2ZWRQb3NpdGlvbik7CisgICAgICAgIH0KKyAgICAgICAgaW5kZXgtLTsKKyAgICB9CisgICAgaWYgKGN1cnJlbnRTY29wZSAhPSBudWxsKSB7CisgICAgICAgIGludCBsb2NhbEluZGV4ID0gY3VycmVudFNjb3BlLmxvY2FsSW5kZXg7CisgICAgICAgIGlmIChsb2NhbEluZGV4ICE9IDApIHsKKyAgICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbG9jYWxJbmRleDsgaSsrKSB7CisgICAgICAgICAgICAgICAgTG9jYWxWYXJpYWJsZUJpbmRpbmcgdmFyaWFibGVCaW5kaW5nID0gY3VycmVudFNjb3BlLmxvY2Fsc1tpXTsKKyAgICAgICAgICAgICAgICBpZiAodmFyaWFibGVCaW5kaW5nICE9IG51bGwgJiYgdmFyaWFibGVCaW5kaW5nLnVzZUZsYWcgPT0gTG9jYWxWYXJpYWJsZUJpbmRpbmcuVVNFRCAmJiB2YXJpYWJsZUJpbmRpbmcucmVzb2x2ZWRQb3NpdGlvbiAhPSAtMSkgeworICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnRGcmFtZS5yZW1vdmVMb2NhbHModmFyaWFibGVCaW5kaW5nLnJlc29sdmVkUG9zaXRpb24pOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgIH0KKyAgICBzdXBlci5leGl0VXNlclNjb3BlKGN1cnJlbnRTY29wZSk7Cit9CitwdWJsaWMgdm9pZCBleGl0VXNlclNjb3BlKEJsb2NrU2NvcGUgY3VycmVudFNjb3BlLCBMb2NhbFZhcmlhYmxlQmluZGluZyBiaW5kaW5nKSB7CisgICAgaW50IGluZGV4ID0gdGhpcy52aXNpYmxlTG9jYWxzQ291bnQgLSAxOworICAgIHdoaWxlIChpbmRleCA+PSAwKSB7CisgICAgICAgIExvY2FsVmFyaWFibGVCaW5kaW5nIHZpc2libGVMb2NhbCA9IHZpc2libGVMb2NhbHNbaW5kZXhdOworICAgICAgICBpZiAodmlzaWJsZUxvY2FsID09IG51bGwgfHwgdmlzaWJsZUxvY2FsID09IGJpbmRpbmcpIHsKKyAgICAgICAgICAgIGluZGV4LS07CisgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgfQorICAgICAgICBpZiAodmlzaWJsZUxvY2FsLmRlY2xhcmluZ1Njb3BlICE9IGN1cnJlbnRTY29wZSkgLy8gbGVmdCBjdXJyZW50U2NvcGUKKyAgICAgICAgICAgIGJyZWFrOworCisgICAgICAgIC8vIHRoZXJlIG1heSBiZSBzb21lIHByZXNlcnZlZCBsb2NhbHMgbmV2ZXIgaW5pdGlhbGl6ZWQKKyAgICAgICAgaWYgKHZpc2libGVMb2NhbC5pbml0aWFsaXphdGlvbkNvdW50ID4gMCl7CisgICAgICAgICAgICB0aGlzLmN1cnJlbnRGcmFtZS5yZW1vdmVMb2NhbHModmlzaWJsZUxvY2FsLnJlc29sdmVkUG9zaXRpb24pOworICAgICAgICB9CisgICAgICAgIGluZGV4LS07CisgICAgfQorICAgIGlmIChjdXJyZW50U2NvcGUgIT0gbnVsbCkgeworICAgICAgICBpbnQgbG9jYWxJbmRleCA9IGN1cnJlbnRTY29wZS5sb2NhbEluZGV4OworICAgICAgICBpZiAobG9jYWxJbmRleCAhPSAwKSB7CisgICAgICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IGxvY2FsSW5kZXg7IGkrKykgeworICAgICAgICAgICAgICAgIExvY2FsVmFyaWFibGVCaW5kaW5nIHZhcmlhYmxlQmluZGluZyA9IGN1cnJlbnRTY29wZS5sb2NhbHNbaV07CisgICAgICAgICAgICAgICAgaWYgKHZhcmlhYmxlQmluZGluZyAhPSBudWxsICYmIHZhcmlhYmxlQmluZGluZyAhPSBiaW5kaW5nICYmIHZhcmlhYmxlQmluZGluZy51c2VGbGFnID09IExvY2FsVmFyaWFibGVCaW5kaW5nLlVTRUQgJiYgdmFyaWFibGVCaW5kaW5nLnJlc29sdmVkUG9zaXRpb24gIT0gLTEpIHsKKyAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUucmVtb3ZlTG9jYWxzKHZhcmlhYmxlQmluZGluZy5yZXNvbHZlZFBvc2l0aW9uKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICB9CisgICAgdGhpcy5zdG9yZVN0YWNrTWFwRnJhbWUoKTsKKyAgICBz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Y3RlckNvbnN0YW50UG9vbE5hbWUpOworICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBUeXBlSWRzLlRfaW50IDoKKyAgICAgICAgICAgICAgIGluZm8gPSBuZXcgVmVyaWZpY2F0aW9uVHlwZUluZm8oVHlwZUlkcy5UX0phdmFMYW5nSW50ZWdlciwgQ29uc3RhbnRQb29sLkphdmFMYW5nSW50ZWdlckNvbnN0YW50UG9vbE5hbWUpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgVHlwZUlkcy5UX2xvbmcgOgorICAgICAgICAgICAgICAgaW5mbyA9IG5ldyBWZXJpZmljYXRpb25UeXBlSW5mbyhUeXBlSWRzLlRfSmF2YUxhbmdMb25nLCBDb25zdGFudFBvb2wuSmF2YUxhbmdMb25nQ29uc3RhbnRQb29sTmFtZSk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBUeXBlSWRzLlRfZmxvYXQgOgorICAgICAgICAgICAgICAgaW5mbyA9IG5ldyBWZXJpZmljYXRpb25UeXBlSW5mbyhUeXBlSWRzLlRfSmF2YUxhbmdGbG9hdCwgQ29uc3RhbnRQb29sLkphdmFMYW5nRmxvYXRDb25zdGFudFBvb2xOYW1lKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIFR5cGVJZHMuVF9kb3VibGUgOgorICAgICAgICAgICAgICAgaW5mbyA9IG5ldyBWZXJpZmljYXRpb25UeXBlSW5mbyhUeXBlSWRzLlRfSmF2YUxhbmdEb3VibGUsIENvbnN0YW50UG9vbC5KYXZhTGFuZ0RvdWJsZUNvbnN0YW50UG9vbE5hbWUpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgVHlwZUlkcy5UX2Jvb2xlYW4gOgorICAgICAgICAgICAgICAgaW5mbyA9IG5ldyBWZXJpZmljYXRpb25UeXBlSW5mbyhUeXBlSWRzLlRfSmF2YUxhbmdCb29sZWFuLCBDb25zdGFudFBvb2wuSm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GluZy5TSE9SVCk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBUeXBlSWRzLlRfY2hhciA6CisgICAgICAgICAgICBpbmZvID0gbmV3IFZlcmlmaWNhdGlvblR5cGVJbmZvKFR5cGVCaW5kaW5nLkNIQVIpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgVHlwZUlkcy5UX2ludCA6CisgICAgICAgICAgICBpbmZvID0gbmV3IFZlcmlmaWNhdGlvblR5cGVJbmZvKFR5cGVCaW5kaW5nLklOVCk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBUeXBlSWRzLlRfbG9uZyA6CisgICAgICAgICAgICBpbmZvID0gbmV3IFZlcmlmaWNhdGlvblR5cGVJbmZvKFR5cGVCaW5kaW5nLkxPTkcpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgVHlwZUlkcy5UX2Zsb2F0IDoKKyAgICAgICAgICAgIGluZm8gPSBuZXcgVmVyaWZpY2F0aW9uVHlwZUluZm8oVHlwZUJpbmRpbmcuRkxPQVQpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgVHlwZUlkcy5UX2RvdWJsZSA6CisgICAgICAgICAgICBpbmZvID0gbmV3IFZlcmlmaWNhdGlvblR5cGVJbmZvKFR5cGVCaW5kaW5nLkRPVUJMRSk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBUeXBlSWRzLlRfYm9vbGVhbiA6CisgICAgICAgICAgICBpbmZvID0gbmV3IFZlcmlmaWNhdGlvblR5cGVJbmZvKFR5cGVCaW5kaW5nLkJPT0xFQU4pOworICAgIH0KKyAgICBpbnQgbnVtYmVyT2ZTdGFja0l0ZW1zID0gdGhpcy5jdXJyZW50RnJhbWUubnVtYmVyT2ZTdGFja0l0ZW1zOworICAgIGlmIChpbmZvICE9IG51bGwgJiYgKG51bWJlck9mU3RhY2tJdGVtcyA+PSAxKSkgeworICAgICAgICB0aGlz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N1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbXMtPTI7CisgICAgfQorfQorcHVibGljIHZvaWQgaWZfaWNtcGVxKEJyYW5jaExhYmVsIGxibCkgeworICAgIHN1cGVyLmlmX2ljbXBlcShsYmwpOworICAgIGlmICh0aGlzLmN1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbXMgPj0gMikgeworICAgICAgICB0aGlzLmN1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbXMtPTI7CisgICAgfQorfQorcHVibGljIHZvaWQgaWZfaWNtcGdlKEJyYW5jaExhYmVsIGxibCkgeworICAgIHN1cGVyLmlmX2ljbXBnZShsYmwpOworICAgIGlmICh0aGlzLmN1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbXMgPj0gMikgeworICAgICAgICB0aGlzLmN1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbXMtPTI7CisgICAgfQorfQorcHVibGljIHZvaWQgaWZfaWNtcGd0KEJyYW5jaExhYmVsIGxibCkgeworICAgIHN1cGVyLmlmX2ljbXBndChsYmwpOworICAgIGlmICh0aGlzLmN1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbXMgPj0gMikgeworICAgICAgICB0aGlzLmN1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbXMtPTI7CisgICAgfQorfQorcHVibGljIHZvaWQgaWZfaWNtcGxlKEJyYW5jaExhYmVsIGxibCkgeworICAgIHN1cGVyLmlmX2ljbXBsZShsYmwpOworICAgIGlmICh0aGlzLmN1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbXMgPj0gMikgeworICAgICAgICB0aGlzLmN1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbXMtPTI7CisgICAgfQorfQorcHVibGljIHZvaWQgaWZfaWNtcGx0KEJyYW5jaExhYmVsIGxibCkgeworICAgIHN1cGVyLmlmX2ljbXBsdChsYmwpOworICAgIGl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oTGFiZWwgdGFyZ2V0TGFiZWwsIGludCBnb3RvTG9jYXRpb24pIHsKKyAgICBpZiAodGFyZ2V0TGFiZWwuZGVsZWdhdGUgIT0gbnVsbCkgcmV0dXJuIGZhbHNlOyAvLyBhbHJlYWR5IGlubGluZWQKKyAgICBpbnQgY2hhaW5pbmcgPSBMX1VOS05PV047CisKKyAgICBib29sZWFuIHJlbW92ZUZyYW1lID0gdHJ1ZTsKKyAgICBmb3IgKGludCBpID0gdGhpcy5jb3VudExhYmVscyAtIDE7IGkgPj0gMDsgaS0tKSB7CisgICAgICAgIEJyYW5jaExhYmVsIGN1cnJlbnRMYWJlbCA9IGxhYmVsc1tpXTsKKyAgICAgICAgaWYgKGN1cnJlbnRMYWJlbC5wb3NpdGlvbiAhPSBnb3RvTG9jYXRpb24pIGJyZWFrOworICAgICAgICBpZiAoY3VycmVudExhYmVsID09IHRhcmdldExhYmVsKSB7CisgICAgICAgICAgICBjaGFpbmluZyB8PSBMX0NBTk5PVF9PUFRJTUlaRTsKKyAgICAgICAgICAgIGNvbnRpbnVlOworICAgICAgICB9CisgICAgICAgIGlmIChjdXJyZW50TGFiZWwuaXNTdGFuZGFyZExhYmVsKCkpIHsKKyAgICAgICAgICAgIGlmIChjdXJyZW50TGFiZWwuZGVsZWdhdGUgIT0gbnVsbCkgY29udGludWU7CisgICAgICAgICAgICBjaGFpbmluZyB8PSBMX09QVElNSVpBQkxFOworICAgICAgICAgICAgaWYgKGN1cnJlbnRMYWJlbC5mb3J3YXJkUmVmZXJlbmNlQ291bnQoKSA9PSAwICYmICgoY3VycmVudExhYmVsLnRhZ0JpdHMgJiBCcmFuY2hMYWJlbC5VU0VEKSAhPSAwKSkgeworICAgICAgICAgICAgICAgIHJlbW92ZUZyYW1lID0gZmFsc2U7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgfQorICAgICAgICAvLyBjYXNlIGxhYmVsCisgICAgICAgIHJlbW92ZUZyYW1lID0gZmFsc2U7CisgICAgICAgIGNoYWluaW5nIHw9IExfQ0FOTk9UX09QVElNSVpFOworICAgIH0KKyAgICBpZiAoKGNoYWluaW5nICYgTF9PUFRJTUlaQUJMRSkgIT0gMCkgeworICAgICAgICBmb3IgKGludCBpID0gdGhpcy5jb3VudExhYmVscyAtIDE7IGkgPj0gMDsgaS0tKSB7CisgICAgICAgICAgICBCcmFuY2hMYWJlbCBjdXJyZW50TGFiZWwgPSBsYWJlbHNbaV07CisgICAgICAgICAgICBpZiAoY3VycmVudExhYmVsLnBvc2l0aW9uICE9IGdvdG9Mb2NhdGlvbikgYnJlYWs7CisgICAgICAgICAgICBpZiAoY3VycmVudExhYmVsID09IHRhcmdldExhYmVsKSBjb250aW51ZTsKKyAgICAgICAgICAgIGlmIChjdXJyZW50TGFiZWwuaXNTdGFuZGFyZExhYmVsKCkpIHsKKyAgICAgICAgICAgICAgICBpZiAoY3VycmVudExhYmVsLmRlbGVnYXRlICE9IG51bGwpIGNvbnRpbnVlOworICAgICAgICAgICAgICAgIHRhcmdldExhYmVsLmJlY29tZURlbGVnYXRlRm9yKGN1cnJlbnRMYWJlbCk7CisgICAgICAgICAgICAgICAgLy8gd2Ugc2hvdWxkIHJlbW92ZSB0aGUgZnJhbWUgY29ycmVzcG9uZGluZyB0byBvdGhlckxhYmVsIHBvc2l0aW9uIGluIG9yZGVyIHRvIHByZXZlbnQgdW51c2VkIHN0YWNrIGZyYW1lCisgICAgICAgICAgICAgICAgaWYgKHJlbW92ZUZyYW1lKSB7CisgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRMYWJlbC50YWdCaXRzICY9IH5CcmFuY2hMYWJlbC5VU0VEOworICAgICAgICAgICAgICAgICAgICB0aGlzLnJlbW92ZVN0YWNrRnJhbWVGb3IoZ290b0xvY2F0aW9uKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICB9CisgICAgcmV0dXJuIChjaGFpbmluZyAmIChMX09QVElNSVpBQ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yAgICAgICAgICAgICAgICBpZiAoKGVuY2xvc2luZ0luc3RhbmNlVHlwZXMgPSBtZXRob2RCaW5kaW5nLmRlY2xhcmluZ0NsYXNzLnN5bnRoZXRpY0VuY2xvc2luZ0luc3RhbmNlVHlwZXMoKSkgIT0gbnVsbCkgeworICAgICAgICAgICAgICAgICAgICBmb3IgKGludCBpID0gMCwgbWF4ID0gZW5jbG9zaW5nSW5zdGFuY2VUeXBlcy5sZW5ndGg7IGkgPCBtYXg7IGkrKykgeworICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGFuIGVuY2xvc2luZ0luc3RhbmNlVHlwZSBjYW4gb25seSBiZSBhIHJlZmVyZW5jZSBiaW5kaW5nLiBJdCBjYW5ub3QgYmUKKyAgICAgICAgICAgICAgICAgICAgICAgIC8vIExvbmdCaW5kaW5nIG9yIERvdWJsZUJpbmRpbmcKKyAgICAgICAgICAgICAgICAgICAgICAgIGZyYW1lLnB1dExvY2FsKHJlc29sdmVkUG9zaXRpb24sIG5ldyBWZXJpZmljYXRpb25UeXBlSW5mbyhlbmNsb3NpbmdJbnN0YW5jZVR5cGVzW2ldKSk7CisgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlZFBvc2l0aW9uKys7CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICB9CisKKyAgICAgICAgICAgICAgICBUeXBlQmluZGluZ1tdIGFyZ3VtZW50czsKKyAgICAgICAgICAgICAgICBpZiAoKGFyZ3VtZW50cyA9IG1ldGhvZEJpbmRpbmcucGFyYW1ldGVycykgIT0gbnVsbCkgeworICAgICAgICAgICAgICAgICAgICBmb3IgKGludCBpID0gMCwgbWF4ID0gYXJndW1lbnRzLmxlbmd0aDsgaSA8IG1heDsgaSsrKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBmaW5hbCBUeXBlQmluZGluZyB0eXBlQmluZGluZyA9IGFyZ3VtZW50c1tpXTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGZyYW1lLnB1dExvY2FsKHJlc29sdmVkUG9zaXRpb24sIG5ldyBWZXJpZmljYXRpb25UeXBlSW5mbyh0eXBlQmluZGluZykpOworICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoKHR5cGVCaW5kaW5nLmlkKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBUeXBlSWRzLlRfZG91YmxlIDoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFR5cGVJZHMuVF9sb25nIDoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZWRQb3NpdGlvbiArPSAyOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlZFBvc2l0aW9uKys7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICB9CisKKyAgICAgICAgICAgICAgICBTeW50aGV0aWNBcmd1bWVudEJpbmRpbmcgc3ludGhldGljQXJndW1lbnRzW107CisgICAgICAgICAgICAgICAgaWYgKChzeW50aGV0aWNBcmd1bWVudHMgPSBtZXRob2RCaW5kaW5nLmRlY2xhcmluZ0NsYXNzLnN5bnRoZXRpY091dGVyTG9jYWxWYXJpYWJsZXMoKSkgIT0gbnVsbCkgeworICAgICAgICAgICAgICAgICAgICBmb3IgKGludCBpID0gMCwgbWF4ID0gc3ludGhldGljQXJndW1lbnRzLmxlbmd0aDsgaSA8IG1heDsgaSsrKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBmaW5hbCBUeXBlQmluZGluZyB0eXBlQmluZGluZyA9IHN5bnRoZXRpY0FyZ3VtZW50c1tpXS50eXBlOworICAgICAgICAgICAgICAgICAgICAgICAgZnJhbWUucHV0TG9jYWwocmVzb2x2ZWRQb3NpdGlvbiwgbmV3IFZlcmlmaWNhdGlvblR5cGVJbmZvKHR5cGVCaW5kaW5nKSk7CisgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2godHlwZUJpbmRpbmcuaWQpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFR5cGVJZHMuVF9kb3VibGUgOgorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgVHlwZUlkcy5UX2xvbmcgOgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlZFBvc2l0aW9uKz0yOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlZFBvc2l0aW9uKys7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgIFR5cGVCaW5kaW5nW10gYXJndW1lbnRzOworICAgICAgICAgICAgICAgIGlmICgoYXJndW1lbnRzID0gbWV0aG9kQmluZGluZy5wYXJhbWV0ZXJzKSAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgICAgIGZvciAoaW50IGkgPSAwLCBtYXggPSBhcmd1bWVudHMubGVuZ3RoOyBpIDwgbWF4OyBpKyspIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGZpbmFsIFR5cGVCaW5kaW5nIHR5cGVCaW5kaW5nID0gYXJndW1lbnRzW2ldOworICAgICAgICAgICAgICAgICAgICAgICAgZnJhbWUucHV0TG9jYWwocmVzb2x2ZWRQb3NpdGlvbiwgbmV3IFZlcmlmaWNhdGlvblR5cGVJbmZvKHR5cGVCaW5kaW5nKSk7CisgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2godHlwZUJpbmRpbmcuaWQpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFR5cGVJZHMuVF9kb3VibGUgOgorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgVHlwZUlkcy5UX2xvbmcgOgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlZFBvc2l0aW9uICs9IDI7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmVkUG9zaXRpb24rKzsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0KKyAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgIFR5cGVCaW5kaW5nW10gYXJndW1lbnRzOworICAgICAgICAgICAgaWYgKChhcmd1bWVudHMgPSBtZXRob2RCaW5kaW5nLnBhcmFtZXRlcnMpICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICBmb3IgKGludCBpID0gMCwgbWF4ID0gYXJndW1lbnRzLmxlbmd0aDsgaSA8IG1heDsgaSsrKSB7CisgICAgICAgICAgICAgICAgICAgIGZpbmFsIFR5cGVCaW5kaW5nIHR5cGVCaW5kaW5nID0gYXJndW1lbnRzW2ldOworICAgICAgICAgICAgICAgICAgICBmcmFtZS5wdXRMb2NhbChyZXNvbHZlZFBvc2l0aW9uLCBuZXcgVmVyaWZpY2F0aW9uVHlwZUluZm8odHlwZUJpbmRpbmcpKTsKKyAgICAgICAgICAgICAgICAgICAgc3dpdGNoKHR5cGVCaW5kaW5nLmlkKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFR5cGVJZHMuVF9kb3VibGUgOgorICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBUeXBlSWRzLlRfbG9uZyA6CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZWRQb3NpdGlvbiArPSAyOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlZFBvc2l0aW9uKys7CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICB9CisgICAgdHJ5IHsKKyAgICAgICAgdGhpcy5mcmFtZXMgPSBuZXcgQXJyYXlMaXN0KCk7CisgICAgICAgIHRoaXMuZnJhbWVzLmFkZChmcmFtZS5jbG9uZSgpKTsKKyAgICB9IGNhdGNoIChDbG9uZU5vdFN1cHBvcnRlZEV4Y2VwdGlvbiBlKSB7CisgICAgICAgIGUucHJpbnRTdGFja1RyYWNlKCk7CisgICAgfQorICAgIHRoaXMuY3VycmVudEZyYW1lID0gZnJhbWU7CisgICAgdGhpcy5mcmFtZVBvc2l0aW9ucyA9IG5ldyBIYXNoU2V0KCk7CisgICAgdGhpcy52YXJpYWJsZXNNb2RpZmljYXRpb25zUG9zaXRpb25zID0gbmV3IEFycmF5TGlzdCgpOworfQorcHVibGljIHZvaWQgaW5zdGFuY2Vfb2YoVHlwZUJpbmRpbmcgdHlwZUJpbmRpbmcpIHsKKyAgICBzdXBlci5pbnN0YW5jZV9vZih0eXBlQmluZGluZyk7CisgICAgaW50IG51bWJlck9mU3RhY2tJdGVtcyA9IHRoaXMuY3VycmVudEZyYW1lLm51bWJlck9mU3RhY2tJdGVtczsKKyAgICBpZiAobnVtYmVyT2ZTdGFja0l0ZW1zID49IDEpIHsKKyAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUuc3RhY2tJdGVtc1tudW1iZXJPZlN0YWNrSXRlbXMgLSAxXSA9IG5ldyBWZXJpZmljYXRpb25UeXBlSW5mbyhUeXBlQmluZGluZy5JTlQpOworICAgIH0KK30KK3Byb3RlY3RlZCB2b2lkIGludm9rZUFjY2Vzc2libGVPYmplY3RTZXRBY2Nlc3N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maWNhdGlvblR5cGVJbmZvKFR5cGVCaW5kaW5nLlNIT1JUKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIFR5cGVJZHMuVF9sb25nIDoKKyAgICAgICAgICAgIGluZm8gPSBuZXcgVmVyaWZpY2F0aW9uVHlwZUluZm8oVHlwZUJpbmRpbmcuTE9ORyk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBUeXBlSWRzLlRfZmxvYXQgOgorICAgICAgICAgICAgaW5mbyA9IG5ldyBWZXJpZmljYXRpb25UeXBlSW5mbyhUeXBlQmluZGluZy5GTE9BVCk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBUeXBlSWRzLlRfZG91YmxlIDoKKyAgICAgICAgICAgIGluZm8gPSBuZXcgVmVyaWZpY2F0aW9uVHlwZUluZm8oVHlwZUJpbmRpbmcuRE9VQkxFKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIFR5cGVJZHMuVF9jaGFyIDoKKyAgICAgICAgICAgIGluZm8gPSBuZXcgVmVyaWZpY2F0aW9uVHlwZUluZm8oVHlwZUJpbmRpbmcuQ0hBUik7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBUeXBlSWRzLlRfYm9vbGVhbiA6CisgICAgICAgICAgICBpbmZvID0gbmV3IFZlcmlmaWNhdGlvblR5cGVJbmZvKFR5cGVCaW5kaW5nLkJPT0xFQU4pOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGRlZmF1bHQgOgorICAgICAgICAgICAgaW5mbyA9IG5ldyBWZXJpZmljYXRpb25UeXBlSW5mbyhUeXBlSWRzLlRfSmF2YUxhbmdPYmplY3QsIENvbnN0YW50UG9vbC5KYXZhTGFuZ09iamVjdENvbnN0YW50UG9vbE5hbWUpOworICAgICAgICAgICAgYnJlYWs7CisgICAgfQorICAgIGlmICh0aGlzLmN1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbX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XJpbmdDbGFzcy5zeW50aGV0aWNFbmNsb3NpbmdJbnN0YW5jZVR5cGVzKCk7CisgICAgICAgICAgICBpZiAoc3ludGhldGljQXJndW1lbnRUeXBlcyAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgYXJnQ291bnQgKz0gc3ludGhldGljQXJndW1lbnRUeXBlcy5sZW5ndGg7CisgICAgICAgICAgICB9CisgICAgICAgICAgICAvLyBvdXRlciBsb2NhbCB2YXJpYWJsZXMKKyAgICAgICAgICAgIFN5bnRoZXRpY0FyZ3VtZW50QmluZGluZ1tdIHN5bnRoZXRpY0FyZ3VtZW50cyA9IGRlY2xhcmluZ0NsYXNzLnN5bnRoZXRpY091dGVyTG9jYWxWYXJpYWJsZXMoKTsKKyAgICAgICAgICAgIGlmIChzeW50aGV0aWNBcmd1bWVudHMgIT0gbnVsbCkgeworICAgICAgICAgICAgICAgIGFyZ0NvdW50ICs9IHN5bnRoZXRpY0FyZ3VtZW50cy5sZW5ndGg7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICAgICAgaWYgKGRlY2xhcmluZ0NsYXNzLmlzRW51bSgpKSB7CisgICAgICAgICAgICBhcmdDb3VudCArPSAyOworICAgICAgICB9CisgICAgICAgIGFyZ0NvdW50ICs9IG1ldGhvZEJpbmRpbmcucGFyYW1ldGVycy5sZW5ndGg7CisgICAgICAgIGlmICh0aGlzLmN1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbXMgPj0gKGFyZ0NvdW50ICsgMSkpIHsKKwkgICAgICAgIHRoaXMuY3VycmVudEZyYW1lLm51bWJlck9mU3RhY2tJdGVtcyAtPSBhcmdDb3VudDsKKwkgICAgICAgIHRoaXMuY3VycmVudEZyYW1lLmluaXRpYWxpemVSZWNlaXZlcigpOworCSAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUubnVtYmVyT2ZTdGFja0l0ZW1zLS07IC8vIHJlbW92ZSB0aGUgdG9wIG9mIHN0YWNrCisgICAgICAgIH0KK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onIH07CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBDbGFzc0ZpbGVDb25zdGFudHMuU0hPUlRfQVJSQVkgOgorICAgICAgICAgICAgY29uc3RhbnRQb29sTmFtZSA9IG5ldyBjaGFyW10geyAnWycsICdTJyB9OworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgQ2xhc3NGaWxlQ29uc3RhbnRzLkNIQVJfQVJSQVkgOgorICAgICAgICAgICAgY29uc3RhbnRQb29sTmFtZSA9IG5ldyBjaGFyW10geyAnWycsICdDJyB9OworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgQ2xhc3NGaWxlQ29uc3RhbnRzLkxPTkdfQVJSQVkgOgorICAgICAgICAgICAgY29uc3RhbnRQb29sTmFtZSA9IG5ldyBjaGFyW10geyAnWycsICdKJyB9OworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgQ2xhc3NGaWxlQ29uc3RhbnRzLkZMT0FUX0FSUkFZIDoKKyAgICAgICAgICAgIGNvbnN0YW50UG9vbE5hbWUgPSBuZXcgY2hhcltdIHsgJ1snLCAnRicgfTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIENsYXNzRmlsZUNvbnN0YW50cy5ET1VCTEVfQVJSQVkgOgorICAgICAgICAgICAgY29uc3RhbnRQb29sTmFtZSA9IG5ldyBjaGFyW10geyAnWycsICdEJyB9OworICAgICAgICAgICAgYnJlYWs7CisgICAgfQorICAgIGludCBudW1iZXJPZlN0YWNrSXRlbXMgPSB0aGlzLmN1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbXM7CisgICAgaWYgKG51bWJlck9mU3RhY2tJdGVtcyA+PSAxKSB7CisgICAgICAgIHRoaXMuY3VycmVudEZyYW1lLnN0YWNrSXRlbXNbbnVtYmVyT2ZTdGFja0l0ZW1zIC0gMV0gPSBuZXcgVmVyaWZpY2F0aW9uVHlwZUluZm8oVHlwZUlkcy5UX0phdm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pdGlvbiwgbGJsKTsKKyAgICBpbnQgZnJhbWVJbmRleCA9IHRoaXMuZnJhbWVzLnNpemUoKSAtIDE7CisgICAgbG9vcDogd2hpbGUoZnJhbWVJbmRleCA+IDApIHsKKyAgICAgICAgU3RhY2tNYXBGcmFtZSBmcmFtZSA9IChTdGFja01hcEZyYW1lKSB0aGlzLmZyYW1lcy5nZXQoZnJhbWVJbmRleCk7CisgICAgICAgIGlmIChmcmFtZS5wYyA9PSBvbGRQb3NpdGlvbikgeworICAgICAgICAgICAgaWYgKHRoaXMuZnJhbWVQb3NpdGlvbnMucmVtb3ZlKG5ldyBJbnRlZ2VyKG9sZFBvc2l0aW9uKSkpIHsKKyAgICAgICAgICAgICAgICB0aGlzLmZyYW1lUG9zaXRpb25zLmFkZChuZXcgSW50ZWdlcih0aGlzLnBvc2l0aW9uKSk7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBpZiAodGhpcy52YXJpYWJsZXNNb2RpZmljYXRpb25zUG9zaXRpb25zLnJlbW92ZShuZXcgSW50ZWdlcihvbGRQb3NpdGlvbikpKSB7CisgICAgICAgICAgICAgICAgdGhpcy52YXJpYWJsZXNNb2RpZmljYXRpb25zUG9zaXRpb25zLmFkZChuZXcgSW50ZWdlcih0aGlzLnBvc2l0aW9uKSk7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBmcmFtZS5wYyA9IHRoaXMucG9zaXRpb247CisgICAgICAgICAgICBTdGFja01hcEZyYW1lIHByZXZpb3VzRnJhbWUgPSAoU3RhY2tNYXBGcmFtZSkgdGhpcy5mcmFtZXMuZ2V0KGZyYW1lSW5kZXggLSAxKTsKKyAgICAgICAgICAgIGlmIChwcmV2aW91c0ZyYW1lLnBjID09IHRoaXMucG9zaXRpb24pIHsKKyAgICAgICAgICAgICAgICAvLyByZW1vdmUgdGhlIGN1cnJlbnQgZnJhbWUKKyAgICAgICAgICAgICAgICB0aGlzLmZyYW1lcy5zZXQoZnJhbWVJbmRleCAtIDEsIGZyYW1lKTsKKyAgICAgICAgICAgICAgICB0aGlzLmZyYW1lcy5yZW1vdmUoZnJhbWVJbmRleCk7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBicmVhayBsb29wOworICAgICAgICB9IGVsc2UgaWYgKGZyYW1lLnBjID4gb2xkUG9zaXRpb24pIHsKKyAgICAgICAgICAgIHJldHVybjsKKyAgICAgICAgfQorICAgICAgICBmcmFtZUluZGV4LS07CisgICAgfQorfQorcHVibGljIHZvaWQgcG9wKCkgeworICAgIHN1cGVyLnBvcCgpOworICAgIGlmICh0aGlzLmN1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbXMgPj0gMSkgeworICAgICAgICB0aGlzLmN1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbXMtLTsKKyAgICB9Cit9CitwdWJsaWMgdm9pZCBwb3AyKCkgeworICAgIHN1cGVyLnBvcDIoKTsKKyAgICBpbnQgbnVtYmVyT2ZTdGFja0l0ZW1zID0gdGhpcy5jdXJyZW50RnJhbWUubnVtYmVyT2ZTdGFja0l0ZW1zOworICAgIGlmIChudW1iZXJPZlN0YWNrSXRlbXMgPj0gMSkgeworICAgICAgICBzd2l0Y2godGhpcy5jdXJyZW50RnJhbWUuc3RhY2tJdGVtc1tudW1iZXJPZlN0YWNrSXRlbXMgLSAxXS5pZCgpKSB7CisgICAgICAgICAgICBjYXNlIFR5cGVJZHMuVF9sb25nIDoKKyAgICAgICAgICAgIGNhc2UgVHlwZUlkcy5UX2RvdWJsZSA6CisgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUubnVtYmVyT2ZTdGFja0l0ZW1zLS07CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgIGlmIChudW1iZXJPZlN0YWNrSXRlbXMgPj0gMikgeworICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnRGcmFtZS5udW1iZXJPZlN0YWNrSXRlbXMgLT0gMjsK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pYmxlTG9jYWxzW2ldOworICAgICAgICBpZiAobG9jYWxCaW5kaW5nICE9IG51bGwgJiYgbG9jYWxCaW5kaW5nLmluaXRpYWxpemF0aW9uQ291bnQgPiAwKSB7CisgICAgICAgICAgICBib29sZWFuIGlzRGVmaW5pdGVseUFzc2lnbmVkID0gaXNEZWZpbml0ZWx5QXNzaWduZWQoc2NvcGUsIGluaXRTdGF0ZUluZGV4LCBsb2NhbEJpbmRpbmcpOworICAgICAgICAgICAgaWYgKCFpc0RlZmluaXRlbHlBc3NpZ25lZCkgeworICAgICAgICAgICAgICAgIGlmICh0aGlzLnN0YXRlSW5kZXhlcyAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgICAgIGZvciAoaW50IGogPSAwLCBtYXggPSB0aGlzLnN0YXRlSW5kZXhlc0NvdW50ZXI7IGogPCBtYXg7IGorKykgeworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzRGVmaW5pdGVseUFzc2lnbmVkKHNjb3BlLCB0aGlzLnN0YXRlSW5kZXhlc1tqXSwgbG9jYWxCaW5kaW5nKSkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlIGxvb3A7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50RnJhbWUucmVtb3ZlTG9jYWxzKGxvY2FsQmluZGluZy5yZXNvbHZlZFBvc2l0aW9uKTsKKyAgICAgICAgICAgICAgICBsb2NhbEJpbmRpbmcucmVjb3JkSW5pdGlhbGl6YXRpb25FbmRQQyhwb3NpdGlvbik7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICB9CisgICAgSW50ZWdlciBuZXdWYWx1ZSA9IG5ldyBJbnRlZ2VyKHRoaXMucG9zaXRpb24pOworICAgIGlmICh0aGlzLnZhcmlhYmxlc01vZGlmaWNhdGlvbnNQb3NpdGlvbnMuc2l6ZSg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b21waWxlci9vcmcvZWNsaXBzZS9qZHQvaW50ZXJuYWwvY29tcGlsZXIvY29kZWdlbi9WZXJpZmljYXRpb25UeXBlSW5mby5qYXZhCm5ldyBmaWxlIG1vZGUgMTAwNzU1CmluZGV4IDAwMDAwMDAuLmRjZTliZTYKLS0tIC9kZXYvbnVsbAorKysgYi9vcmcuZWNsaXBzZS5qZHQuY29yZS9jb21waWxlci9vcmcvZWNsaXBzZS9qZHQvaW50ZXJuYWwvY29tcGlsZXIvY29kZWdlbi9WZXJpZmljYXRpb25UeXBlSW5mby5qYXZhCkBAIC0wLDAgKzEsMjE1IEBACisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogQ29weXJpZ2h0IChjKSAyMDAwLCAyMDA2IElCTSBDb3Jwb3JhdGlvbiBhbmQgb3RoZXJzLgorICogQWxsIHJpZ2h0cyByZXNlcnZlZC4gVGhpcyBwcm9ncmFtIGFuZCB0aGUgYWNjb21wYW55aW5nIG1hdGVyaWFscworICogYXJlIG1hZGUgYXZhaWxhYmxlIHVuZGVyIHRoZSB0ZXJtcyBvZiB0aGUgRWNsaXBzZSBQdWJsaWMgTGljZW5zZSB2MS4wCisgKiB3aGljaCBhY2NvbXBhbmllcyB0aGlzIGRpc3RyaWJ1dGlvbiwgYW5kIGlzIGF2YWlsYWJsZSBhdAorICogaHR0cDovL3d3dy5lY2xpcHNlLm9yZy9sZWdhbC9lcGwtdjEwLmh0bWwKKyAqCisgKiBDb250cmlidXRvcnM6CisgKiAgICAgSUJNIENvcnBvcmF0aW9uIC0gaW5pdGlhbCBBUEkgYW5kIGltcGxlbWVudGF0aW9uCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK3BhY2thZ2Ugb3JnLmVjbGlwc2UuamR0LmludGVybmFsLmNvbXBpbGVy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BpbGVyL2Vudi9FbnVtQ29uc3RhbnRTaWduYXR1cmUuamF2YSBiL29yZy5lY2xpcHNlLmpkdC5jb3JlL2NvbXBpbGVyL29yZy9lY2xpcHNlL2pkdC9pbnRlcm5hbC9jb21waWxlci9lbnYvRW51bUNvbnN0YW50U2lnbmF0dXJlLmphdmEKbmV3IGZpbGUgbW9kZSAxMDA3NTUKaW5kZXggMDAwMDAwMC4uNjZhODQzNAotLS0gL2Rldi9udWxsCisrKyBiL29yZy5lY2xpcHNlLmpkdC5jb3JlL2NvbXBpbGVyL29yZy9lY2xpcHNlL2pkdC9pbnRlcm5hbC9jb21waWxlci9lbnYvRW51bUNvbnN0YW50U2lnbmF0dXJlLmphdmEKQEAgLTAsMCArMSw0OCBAQAorLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIENvcHlyaWdodCAoYykgMjAwNSwgMjAwNyBCRUEgU3lzdGVtcywgSW5jLgorICogQWxsIHJpZ2h0cyByZXNlcnZlZC4gVGhpcyBwcm9ncmFtIGFuZCB0aGUgYWNjb21wYW55aW5nIG1hdGVyaWFscworICogYXJlIG1hZGUgYXZhaWxhYmxlIHVuZGVyIHRoZSB0ZXJtcyBvZiB0aGUgRWNsaXBzZSBQdWJsaWMgTGljZW5zZSB2MS4wCisgKiB3aGljaCBhY2NvbXBhbmllcyB0aGlzIGRpc3RyaWJ1dGlvbiwgYW5kIGlzIGF2YWlsYWJsZSBhdAorICogaHR0cDovL3d3dy5lY2xpcHNlLm9yZy9sZWdhbC9lcGwtdjEwLmh0bWwKKyAqCisgKiBDb250cmlidXRvcnM6CisgKiAgICB0eWV1bmdAYmVhLmNvbSAtIGluaXRpYWwgQVBJIGFuZCBpbXBsZW1lbnRhdGlvbgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiov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waWxlci9vcmcvZWNsaXBzZS9qZHQvaW50ZXJuYWwvY29tcGlsZXIvZW52L0lCaW5hcnlFbGVtZW50VmFsdWVQYWlyLmphdmEKQEAgLTAsMCArMSwzMSBAQAorLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIENvcHlyaWdodCAoYykgMjAwNSwgMjAwNyBCRUEgU3lzdGVtcywgSW5jLgorICogQWxsIHJpZ2h0cyByZXNlcnZlZC4gVGhpcyBwcm9ncmFtIGFuZCB0aGUgYWNjb21wYW55aW5nIG1hdGVyaWFscworICogYXJlIG1hZGUgYXZhaWxhYmxlIHVuZGVyIHRoZSB0ZXJtcyBvZiB0aGUgRWNsaXBzZSBQdWJsaWMgTGljZW5zZSB2MS4wCisgKiB3aGljaCBhY2NvbXBhbmllcyB0aGlzIGRpc3RyaWJ1dGlvbiwgYW5kIGlzIGF2YWlsYWJsZSBhdAorICogaHR0cDovL3d3dy5lY2xpcHNlLm9yZy9sZWdhbC9lcGwtdjEwLmh0bWwKKyAqCisgKiBDb250cmlidXRvcnM6CisgKiAgICB0eWV1bmdAYmVhLmNvbSAtIGluaXRpYWwgQVBJIGFuZCBpbXBsZW1lbnRhdGlvbgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCitwYWNrYWdlIG9yZy5lY2xpcHNlLmpkdC5pbnRlcm5hbC5jb21waWxlci5lbnY7CisKKy8qKgorICogVGhpcyByZXByZXNlbnRzIHRoZSBjbGFzcyBmaWxlIGluZm9ybWF0aW9uIGFib3V0IGEgbWVtYmVyIHZhbHVlIHBhaXIgb2YgYW4gYW5ub3RhdGlvbi4KKyAqLworcHVibGljIGludGVyZmFjZSBJQmluYXJ5RWxlbWVudFZhbHVlUGFpciB7CisKKy8qKiBAcmV0dXJuIHRoZSBuYW1lIG9mI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worcHVibGljIGJvb2xlYW4gaXNCcmVha2FibGUoKSB7CisJcmV0dXJuIGZhbHNlOworfQorCitwdWJsaWMgYm9vbGVhbiBpc0NvbnRpbnVhYmxlKCkgeworCXJldHVybiBmYWxzZTsKK30KKworcHVibGljIGJvb2xlYW4gaXNOb25SZXR1cm5pbmdDb250ZXh0KCkgeworCXJldHVybiBmYWxzZTsKK30KKworcHVibGljIGJvb2xlYW4gaXNTdWJSb3V0aW5lKCkgeworCXJldHVybiBmYWxzZTsKK30KKworcHVibGljIGNoYXJbXSBsYWJlbE5hbWUoKSB7CisJcmV0dXJuIG51bGw7Cit9CisKK3B1YmxpYyB2b2lkIHJlY29yZEJyZWFrRnJvbShGbG93SW5mbyBmbG93SW5mbykgeworCS8vIGRlZmF1bHQgaW1wbGVtZW50YXRpb246IGRvIG5vdGhpbmcKK30KKworcHVibGljIHZvaWQgcmVjb3JkQnJlYWtUbyhGbG93Q29udGV4dCB0YXJnZXRDb250ZXh0KSB7CisJLy8gZGVmYXVsdCBpbXBsZW1lbnRhdGlvbjogZG8gbm90aGluZworfQorCitwdWJsaWMgdm9pZCByZWNvcmRDb250aW51ZUZyb20oRmxvd0NvbnRleHQgaW5uZXJGbG93Q29udGV4dCwgRmxvd0luZm8gZmxvd0luZm8pIHsKKwkvLyBkZWZhdWx0IGltcGxlbWVudGF0aW9uOiBkbyBub3RoaW5nCit9CisKK3Byb3RlY3RlZCBib29sZWFuIHJlY29yZEZpbmFsQXNzaWdubWVudChWYXJpYWJsZUJpbmRpbmcgdmFyaWFibGUsIFJlZmVyZW5jZSBmaW5hbFJlZmVyZW5jZSkgeworCXJldHVybiB0cnVlOyAvLyBrZWVwIGdvaW5nCit9CisKKy8qKgorICogUmVjb3JkIGEgbnVsbCByZWZlcmVuY2UgZm9yIHVzZSBieSBkZWZlcnJlZCBjaGVja3MuIE9ubHkgbG9vcGluZyBvciAKKyAqIGZpbmFsbHkgY29udGV4dHMgcmVhbGx5IHJlY29yZCB0aGF0IGluZ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MiA9IHRoaXMuZXh0cmFbMiArIDFdW2ldKSB8IChhNCA9IHRoaXMuZXh0cmFbNCArIDFdW2ldKSk7CisgICAgICAgIAltMiA9IHMxICYgKHMyID0gdGhpcy5leHRyYVsyICsgMV1baV0pICYgKHMzIF4gczQpCisgICAgICAgIAkJJiAoKGEzID0gdGhpcy5leHRyYVszICsgMV1baV0pIHwgYTQpOworICAgICAgICAJbTMgPSBzMQkmIChzMiAmIChuczMgPSB+czMpICYgKG5zNCA9IH5zNCkgJiAoYTMgfCBhNCkKKyAgICAgICAgCQkJCXwgKG5zMiA9IH5zMikgJiBzMyAmIG5zNCAmIChhMiB8IGE0KQorICAgICAgICAJCQkJfCBuczIgJiBuczMgJiBzNCAmIChhMiB8IGEzKSk7IAorICAgICAgICAJaWYgKChtID0gKG0xIHwgbTIgfCBtMykpICE9IDApIHsKKyAgICAgICAgCSAgCWlmICghIG5ld0NvcHkpIHsKKyAgICAgICAgICAgIAkJbmV3Q29weSA9IHRydWU7CisgICAgICAgICAgICAJCXNvdXJjZSA9IHNvdXJjZS51bmNvbmRpdGlvbmFsQ29weSgpOworICAgICAgICAJICAJfQorICAgICAgICAJCXNvdXJjZS5leHRyYVsxICsgMV1baV0gJj0gfm07CisgICAgICAgIAkJc291cmNlLmV4dHJhWzIgKyAxXVtpXSAmPSAobm0xID0gfm0xKSAmICgobm0yID0gfm0yKSB8IGE0KTsKKyAgICAgICAgCQlzb3VyY2UuZXh0cmFbMyArIDFdW2ldICY9IChubTEgfCBhMikgJiBubTI7CisgICAgICAgIAkJc291cmNlLmV4dHJhWzQgKyAxXVtpXSAmPSBubTEgJiBubTI7CisgICAgICAgIAl9CisJCX0KKwl9CisJcmV0dXJuIHNvdXJjZTsKK30KKworcHVibGljIFN0cmluZyB0b1N0cmluZygpeworCWlmICh0aGlzLmV4dHJhID09IG51bGwpIHsKKwkJcmV0dXJuICJOdWxsSW5mb1JlZ2lzdHJ5PCIgKyB0aGlzLm51bGxCaXQxIC8vJE5PTi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xID0gb3RoZXJJbml0cy5udWxsQml0MSkKKyAgICAgICAgICAgICAgICAJCQkJfCAoYTEgPSB0aGlzLm51bGxCaXQxKSAmICgoYTMgPSB0aGlzLm51bGxCaXQzKSAKKyAgICAgICAgICAgICAgICAJCQkJCSYgKGE0ID0gdGhpcy5udWxsQml0NCkgJiAobmIyID0gfihiMiA9IG90aGVySW5pdHMubnVsbEJpdDIpKSAKKyAgICAgICAgICAgICAgICAJCQkJCSYgKG5iNCA9IH4oYjQgPSBvdGhlckluaXRzLm51bGxCaXQ0KSkKKyAgICAgICAgICAgICAgICAgICAgICAgIAkJfCAoKG5hNCA9IH5hNCkgfCAobmEzID0gfmEzKSkgCisgICAgICAgICAgICAgICAgICAgICAgICAJCQkmICgobmEyID0gfihhMiA9IHRoaXMubnVsbEJpdDIpKSAmIG5iMiAKKyAgICAgICAgICAgICAgICAgICAgICAgIAkJCQl8IGEyICYgKG5iMyA9IH4oYjMgPSBvdGhlckluaXRzLm51bGxCaXQzKSkgJiBuYjQpKTsKKwkJCXRoaXMubnVsbEJpdDIgID0gYjIgJiAobmI0IHwgbmIzKQorICAgICAgICAgICAgICAgICAgICAJCQl8IG5hMyAmIG5hNCAmIGIyCisgICAgICAgICAgICAgICAgICAgIAkJCXwgYTIgJiAobmIzICYgbmI0CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAkJCXwgKG5iMSA9IH5iMSkgJiAobmEzIHwgKG5hMSA9IH5hMSkpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAkJCXwgYTEgJiBiMik7CisJCQl0aGlzLm51bGxCaXQzID0gYjMgJiAobmIxICYgKGIyIHwgYTIgfCBuYTEpCisgICAgICAgICAgICAgICAgICAgICAgICAJCQl8IGIxICYgKGI0IHwgbmIyIHwgYTEgJiBhMykKKyAgICAgICAgICAgICAgICAgICAgICAgICAJCQl8IG5hMSAmIG5hMiAmIG5hNCkKKyAgICAgICAgICAgICAgICAgICAgCQkJfCBhMyAmIG5iMiAmIG5iNAorICAgICAgICAgICAgICAgICAgICAJCQl8IG5iMSAmICgobmEyICYgYTQgfCBuYTEpICYgYTMKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCQkJfCBhMSAmIG5hMiAmIG5hNCAmIGIyKTsKKwkJCXRoaXMubnVsbEJpdDQgPSBuYjEgJiAoYTQgJiAobmEzICYgbmIzCXwgKGEzIHwgbmEyKSAmIG5iMikKKyAgICAgICAgICAgICAgICAgICAgICAJCQl8IGExICYgKGEzICYgbmIyICYgYjQKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAkJCXwgYTIgJiBiMiAmIChiNAl8IGEzICYgbmE0ICYgbmIzKSkpCisgICAgICAgICAgICAgICAgICAgICAgCQkJfCBiMSAmIChhMyAmIGE0ICYgYjQKKyAgICAgICAgICAgICAgICAgICAgICAgICAgCQkJfCBuYTIgJiBuYTQgJiBuYjMgJiBiNAorICAgICAgICAgICAgICAgICAgICAgICAgICAJCQl8IGEyICYgKChiMyB8IGE0KSAmIGI0CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCQkJCXwgbmEzICYgYTQgJiBiMiAmIGIzKQorICAgICAgICAgICAgICAgICAgICAgICAgICAJCQl8IG5hMSAmIChiNAl8IChhNCB8IGEyKSAmIGIyICYgYjMpKQorICAgICAgICAgICAgICAgICAgICAgIAkJCXwgKG5hMSAmIChuYTMgJiBuYjMgfCBuYTIgJiBuYjIpCisgICAgICAgICAgICAgICAgICAgICAgCQkJCXwgYTEgJiAobmIyICYgbmIzIHwgYTIgJiBhMykpICYgYjQ7CQorCQkJaWYgKGNvdmVyYWdlVGVzdEZsYWcgJiYgY292ZXJhZ2VUZXN0SWQgPT0gMikgeworCQkJICB0aGlzLm51bGxCaXQ0ID0gfjA7CisJCQl9CisJCX0KKwkJdGhpcy50YWdCaXRzIHw9IE5VTExfRkxBR19NQVNLOyAvLyBpbiBhbGwgY2FzZXMgLSBhdm9pZCBmb3JnZXR0aW5nIGV4dHJh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ldKQorICAgICAgICAgICAgICAgIAkJCQl8IChhMSA9IHRoaXMuZXh0cmFbMSArIDFdW2ldKSAmICgoYTMgPSB0aGlzLmV4dHJhWzMgKyAxXVtpXSkgCisgICAgICAgICAgICAgICAgCQkJCQkmIChhNCA9IHRoaXMuZXh0cmFbNCArIDFdW2ldKSAmIChuYjIgPSB+KGIyID0gb3RoZXJJbml0cy5leHRyYVsyICsgMV1baV0pKSAKKyAgICAgICAgICAgICAgICAJCQkJCSYgKG5iNCA9IH4oYjQgPSBvdGhlckluaXRzLmV4dHJhWzQgKyAxXVtpXSkpCisgICAgICAgICAgICAgICAgICAgICAgICAJCXwgKChuYTQgPSB+YTQpIHwgKG5hMyA9IH5hMykpIAorICAgICAgICAgICAgICAgICAgICAgICAgCQkJJiAoKG5hMiA9IH4oYTIgPSB0aGlzLmV4dHJhWzIgKyAxXVtpXSkpICYgbmIyIAorICAgICAgICAgICAgICAgICAgICAgICAgCQkJCXwgYTIgJiAobmIzID0gfihiMyA9IG90aGVySW5pdHMuZXh0cmFbMyArIDFdW2ldKSkgJiBuYjQpKTsKKwkJCXRoaXMuZXh0cmFbMiArIDFdW2ldICA9IGIyICYgKG5iNCB8IG5iMykKKyAgICAgICAgICAgICAgICAgICAgCQkJfCBuYTMgJiBuYTQgJiBiMgorICAgICAgICAgICAgICAgICAgICAJCQl8IGEyICYgKG5iMyAmIG5iNAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAJCQl8IChuYjEgPSB+YjEpICYgKG5hMyB8IChuYTEgPSB+YTEpKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAJCQl8IGExICYgYjIpOworCQkJdGhpcy5leHRyYVszICsgMV1baV0gPSBiMyAmIChuYjEgJiAoYjIgfCBhMiB8IG5hMSkKKyAgICAgICAgICAgICAgICAgICAgICAgIAkJCXwgYjEgJiAoYjQgfCBuYjIgfCBhMSAmIGEzKQorICAgICAgICAgICAgICAgICAgICAgICAgIAkJCXwgbmExICYgbmEyICYgbmE0KQorICAgICAgICAgICAgICAgICAgICAJCQl8IGEzICYgbmIyICYgbmI0CisgICAgICAgICAgICAgICAgICAgIAkJCXwgbmIxICYgKChuYTIgJiBhNCB8IG5hMSkgJiBhMworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAJCQl8IGExICYgbmEyICYgbmE0ICYgYjIpOworCQkJdGhpcy5leHRyYVs0ICsgMV1baV0gPSBuYjEgJiAoYTQgJiAobmEzICYgbmIzCXwgKGEzIHwgbmEyKSAmIG5iMikKKyAgICAgICAgICAgICAgICAgICAgICAJCQl8IGExICYgKGEzICYgbmIyICYgYjQKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAkJCXwgYTIgJiBiMiAmIChiNAl8IGEzICYgbmE0ICYgbmIzKSkpCisgICAgICAgICAgICAgICAgICAgICAgCQkJfCBiMSAmIChhMyAmIGE0ICYgYjQKKyAgICAgICAgICAgICAgICAgICAgICAgICAgCQkJfCBuYTIgJiBuYTQgJiBuYjMgJiBiNAorICAgICAgICAgICAgICAgICAgICAgICAgICAJCQl8IGEyICYgKChiMyB8IGE0KSAmIGI0CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCQkJCXwgbmEzICYgYTQgJiBiMiAmIGIzKQorICAgICAgICAgICAgICAgICAgICAgICAgICAJCQl8IG5hMSAmIChiNAl8IChhNCB8IGEyKSAmIGIyICYgYjMpKQorICAgICAgICAgICAgICAgICAgICAgIAkJCXwgKG5hMSAmIChuYTMgJiBuYjMgfCBuYTIgJiBuYjIpCisgICAgICAgICAgICAgICAgICAgICAgCQkJCXwgYTEgJiAobmIyICYgbmIzIHwgYTIgJiBhMykpICYgYjQ7CQorCQkJaWYgKGNvdmVyYWdlVGVzdEZsYWcgJiYgY292ZXJhZ2VUZXN0SWQgPT0gNykgeworCQkJICB0aGlzLmV4dHJhWzVdW2ldID0gfjA7CisJCQl9CisJCX0KKwkJZm9yICg7IGkgPCBjb3B5TGltaXQ7IGkrKykgeworCQkJZm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gICAJCQkJCQkJCQkJJiAobmI0ID0gfihiNCA9IG90aGVySW5pdHMuZXh0cmFbNCArIDFdW2ldKSkgCisgICAgCQkJCQkJCQkJCQl8IChiMSA9IG90aGVySW5pdHMuZXh0cmFbMSArIDFdW2ldKSAmIChiMyA9IG90aGVySW5pdHMuZXh0cmFbMyArIDFdW2ldKSkKKyAgICAgICAgICAgICAgICAgICAgCQkJfCAobmEyID0gfihhMiA9IHRoaXMuZXh0cmFbMiArIDFdW2ldKSkgCisgICAgICAgICAgICAgICAgICAgIAkJCQkmIChiMSAmIGIzIHwgKChuYTQgPSB+YTQpIHwgKG5hMyA9IH5hMykpICYgbmIyKQorICAgICAgICAgICAgICAgICAgICAJCQl8IGEyICYgKChuYTQgfCBuYTMpICYgKChuYjMgPSB+YjMpICYgbmI0IHwgYjEgJiBiMikpKTsKKyAgICAJCXRoaXMuZXh0cmFbMiArIDFdW2ldID0gYjIgJiAobmIzIHwgKG5iMSA9IH5iMSkpCisgICAgICAgIAkJCXwgYTIgJiAobmIzICYgbmI0IHwgYjIgfCBuYTMgfCAobmExID0gfmExKSk7CisgICAgCQl0aGlzLmV4dHJhWzMgKyAxXVtpXSA9IGIzICYgKG5iMSAmIGIyCisgICAgICAgICAgICAgICAgCQl8IGEyICYgKG5iMgl8IGEzKQorICAgICAgICAgICAgICAgIAkJfCBuYTEgJiBuYjIKKyAgICAgICAgICAgICAgICAJCXwgYTEgJiBuYTIgJiBuYTQgJiBiMSkKKyAgICAgICAgCQkJfCBhMyAmIChuYjIgJiBuYjQgfCBuYTIgJiBhNCB8IG5hMSkKKyAgICAgICAgCQkJfCBhMSAmIG5hMiAmIG5hNCAmIGIyOworICAgIAkJdGhpcy5leHRyYVs0ICsgMV1baV0gPSBuYTMgJiAobmIxICYgbmIzICYgYjQKKyAgICAgICAgCQkJCXwgYTQgJiAobmIzIHwgYjEgJiBiMikpCisgICAgICAgIAkJCXwgbmIyICYgKG5hMyAmIGIxICYgbmIzCXwgbmEyICYgKG5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IChiNCA9IG90aGVySW5pdHMubnVsbEJpdDQpCisgICAgICAgICAgICAgICAgICAJCQkJCQkJCQkJCQl8IChuYTIgPSB+YTIpICYgbmIyIAorICAgICAgICAgICAgICAgICAgCQkJCQkJCQkJCQkJCSYgKChuYjQgPSB+YjQpIHwgKG5hNCA9IH5hNCkgCisgICAgICAgICAgICAgICAgICAJCQkJCQkJCQkJCQkJCQl8IChuYTMgPSB+YTMpICYgKG5iMyA9IH5iMykpCisgICAgICAgICAgICAgICAgICAJCQkJCQkJCQkJCQl8IGEyICYgYjIgJiAoKG5hNCB8IG5hMykgJiAobmI0CXwgbmIzKSkpCisgICAgICAgICAgICAgICAgICAJCQkJCQkJCQkJCXwgbmEyICYgYjIgJiBiMyAmIGI0KTsKKyAgICAJCXRoaXMubnVsbEJpdDIgPSBiMiAmIChuYjMgfCAobmIxID0gfmIxKSB8IGEzICYgKGE0IHwgKG5hMSA9IH5hMSkpICYgbmI0KQorICAgICAgICAJCQl8IGEyICYgKGIyIHwgbmE0ICYgYjMgJiAoYjQgfCBuYjEpIHwgbmEzIHwgbmExKTsKKyAgICAJCXRoaXMubnVsbEJpdDMgPSBiMyAmIChuYjIgJiBiNCB8IG5iMSB8IGEzICYgKG5hNCAmIG5iNCB8IGE0ICYgYjQpKQorICAgICAgICAJCQl8IGEzICYgKG5hMiAmIGE0IHwgbmExKQorICAgICAgICAJCQl8IChhMiB8IG5hMSkgJiBiMSAmIG5iMiAmIG5iNAorICAgICAgICAJCQl8IGExICYgbmEyICYgbmE0ICYgKGIyIHwgbmIxKTsKKyAgICAJCXRoaXMubnVsbEJpdDQgPSBuYTMgJiAobmIxICYgbmIzICYgYjQKKyAgICAgICAgICAgICAgCQkJfCBiMSAmIChuYjIgJiBuYjMgfCBhNCAmIGIyICYgbmI0KQorICAgICAgICAgICAgICAJCQl8IG5hMSAmIGE0ICYgKG5iMyB8IGIxICYgYjIpKQorICAgICAgICAJCQl8IGEzICYgYTQgJiAoYjMgJiBiNCB8IGIxICYgbmIyKQorICAgICAgICAJCQl8IG5hMiAmIChuYjEgJiBiNCB8IGIxICYgbmIzIHwgbmExICYgYTQpICYgbmIyCisgICAgICAgIAkJCXwgYTEgJiAobmEzICYgKG5iMyAmIGI0CisgICAgICAgICAgICAgICAgICAgICAgICAJCQl8IGIxICYgYjIgJiBiMyAmIG5iNAorICAgICAgICAgICAgICAgICAgICAgICAgCQkJfCBuYTIgJiAobmIzIHwgbmIyKSkKKyAgICAgICAgICAgICAgICAJCQl8IG5hMiAmIGIzICYgYjQKKyAgICAgICAgICAgICAgICAJCQl8IGEyICYgKG5iMSAmIGI0IHwgYTMgJiBuYTQgJiBiMSkgJiBuYjMpOworICAgIAkJaWYgKGNvdmVyYWdlVGVzdEZsYWcgJiYgY292ZXJhZ2VUZXN0SWQgPT0gMzApIHsKKyAgICAJCSAgCXRoaXMubnVsbEJpdDQgPSB+MDsKKyAgICAJCX0KKyAgICAJfSBlbHNlIHsgLy8gb3RoZXIgaGFzIG5vIG51bGwgaW5mbyAKKyAgICAJCWExID0gdGhpcy5udWxsQml0MTsKKyAgICAgIAkJdGhpcy5udWxsQml0MSA9IDA7CisgICAgICAJCXRoaXMubnVsbEJpdDIgPSAoYTIgPSB0aGlzLm51bGxCaXQyKSAmIChuYTMgPSB+KGEzID0gdGhpcy5udWxsQml0MykgfCAobmExID0gfmExKSk7CisgICAgICAJCXRoaXMubnVsbEJpdDMgPSBhMyAmICgobmEyID0gfmEyKSAmIChhNCA9IHRoaXMubnVsbEJpdDQpIHwgbmExKSB8IGExICYgbmEyICYgfmE0OworICAgICAgCQl0aGlzLm51bGxCaXQ0ID0gKG5hMyB8IG5hMikgJiBuYTEgJiBhNAl8IGExICYgbmEzICYgbmEyOworICAgIAkJaWYgKGNvdmVyYWdlVGVzdEZsYWcgJiYgY292ZXJhZ2VUZXN0SWQgPT0gMzEpIHsKKyAgICAJCSAgCXRoaXMubnVsbEJpdDQgPSB+MDsKKyAgICAJCX0KKyAgICAJfQorCX0gZW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5qZHQuY29yZS9jb21waWxlci9vcmcvZWNsaXBzZS9qZHQvaW50ZXJuYWwvY29tcGlsZXIvbG9va3VwL0Fubm90YXRpb25Ib2xkZXIuamF2YQpuZXcgZmlsZSBtb2RlIDEwMDc1NQppbmRleCAwMDAwMDAwLi4wNTkzM2UzCi0tLSAvZGV2L251bGwKKysrIGIvb3JnLmVjbGlwc2UuamR0LmNvcmUvY29tcGlsZXIvb3JnL2VjbGlwc2UvamR0L2ludGVybmFsL2NvbXBpbGVyL2xvb2t1cC9Bbm5vdGF0aW9uSG9sZGVyLmphdmEKQEAgLTAsMCArMSw4NSBAQAorLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIENvcHlyaWdodCAoYykgMjAwMCwgMjAwNyBJQk0gQ29ycG9yYXRpb24gYW5kIG90aGVycy4KKyAqIEFsbCByaWdodHMgcmVzZXJ2ZWQuIFRoaXMgcHJvZ3JhbSBhbmQgdGhlIGFjY29tcGFueWluZyBtYXRlcmlhbHMKKyAqIGFyZSBtYWRlIGF2YWlsYWJsZSB1bmRlciB0aGUgdGVybXMgb2YgdGhlIEVjbGlwc2UgUHVibGljIExpY2Vuc2UgdjEuMAorICogd2hpY2ggYWNjb21wYW5pZXMgdGhpcyBkaXN0cmlidXRpb24sIGFuZCBpcyBhdmFpbGFibGUgYXQKKyAqIGh0dHA6Ly93d3cuZWNsaXBzZS5vcmcvbGVnYWwvZXBsLXYxMC5odG1sCisgKgorICogQ29udHJpYnV0b3JzOgorICogICAgIElCTSBDb3Jwb3JhdGlvbiAtIGluaXRpYWwgQVBJIGFuZCBpbXBsZW1lbnRhdGlvbgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCitwYWNrYWdlIG9yZy5lY2xpcHNlLmpkdC5pbnRlcm5hbC5jb21waWxlci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XphdGlvblBDc1tpbmRleCArIDFdID0gLTE7Ci0JCQlpbml0aWFsaXphdGlvbkNvdW50Kys7CisJCQkvLyBvcHRpbWl6ZSBjYXNlcyB3aGVyZSByZW9wZW5pbmcgYSBjb250aWd1b3VzIGludGVydmFsCisJCQlpZiAocHJldmlvdXNFbmRQQyA9PSBwYykgeworCQkJCWluaXRpYWxpemF0aW9uUENzWyAoKGluaXRpYWxpemF0aW9uQ291bnQgLSAxKSA8PCAxKSArIDFdID0gLTE7IC8vIHJldXNlIHByZXZpb3VzIGludGVydmFsIChpdHMgcmFuZ2Ugd2lsbCBiZSBhdWdtZW50ZWQpCisJCQkJcmV0dXJuOworCQkJfQogCQl9CisJCWludCBpbmRleCA9IGluaXRpYWxpemF0aW9uQ291bnQgPDwgMTsKKwkJaWYgKGluZGV4ID09IGluaXRpYWxpemF0aW9uUENzLmxlbmd0aCkgeworCQkJU3lzdGVtLmFycmF5Y29weShpbml0aWFsaXphdGlvblBDcywgMCwgKGluaXRpYWxpemF0aW9uUENzID0gbmV3IGludFtpbml0aWFsaXphdGlvbkNvdW50IDw8IDJdKSwgMCwgaW5kZXgpOworCQl9CisJCWluaXRpYWxpemF0aW9uUENzW2luZGV4XSA9IHBjOworCQlpbml0aWFsaXphdGlvblBDc1tpbmRleCArIDFdID0gLTE7CisJCWluaXRpYWxpemF0aW9uQ291bnQrKzsKKwl9CisKKwlwdWJsaWMgdm9pZCBzZXRBbm5vdGF0aW9ucyhBbm5vdGF0aW9uQmluZGluZ1tdIGFubm90YXRpb25zKSB7CisJCWlmICh0aGlzLmRlY2xhcmluZ1Njb3BlID09IG51bGwpIHJldHVybjsKKworCQlTb3VyY2VUeXBlQmluZGluZyBzb3VyY2VUeXBlID0gdGhpcy5kZWNsYXJpbmdTY29wZS5lbmNsb3NpbmdTb3VyY2VUeXBlKCk7CisJCWlmIChzb3VyY2VUeXBlICE9IG51bGwpCisJCQlzb3VyY2VUeXBlLnN0b3JlQW5ub3RhdGlvbnModGhpcyw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jb3JlL2NvbXBpbGVyL29yZy9lY2xpcHNlL2pkdC9pbnRlcm5hbC9jb21waWxlci9sb29rdXAvUGFyYW1ldGVyaXplZFR5cGVCaW5kaW5nLmphdmEKaW5kZXggM2RjZjQzOS4uNTc4YjRjNyAxMDA2NDQKLS0tIGEvb3JnLmVjbGlwc2UuamR0LmNvcmUvY29tcGlsZXIvb3JnL2VjbGlwc2UvamR0L2ludGVybmFsL2NvbXBpbGVyL2xvb2t1cC9QYXJhbWV0ZXJpemVkVHlwZUJpbmRpbmcuamF2YQorKysgYi9vcmcuZWNsaXBzZS5qZHQuY29yZS9jb21waWxlci9vcmcvZWNsaXBzZS9qZHQvaW50ZXJuYWwvY29tcGlsZXIvbG9va3VwL1BhcmFtZXRlcml6ZWRUeXBlQmluZGluZy5qYXZhCkBAIC0xLDUgKzEsNSBAQAogLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKLSAqIENvcHlyaWdodCAoYykgMjAwNSBJQk0gQ29ycG9yYXRpb24gYW5kIG90aGVycy4KKyAqIENvcHlyaWdodCAoYykgMjAwNSwgMjAwNyBJQk0gQ29ycG9yYXRpb24gYW5kIG90aGVycy4KICAqIEFsbCByaWdodHMgcmVzZXJ2ZWQuIFRoaXMgcHJvZ3JhbSBhbmQgdGhlIGFjY29tcGFueWluZyBtYXRlcmlhbHMKICAqIGFyZSBtYWRlIGF2YWlsYWJsZSB1bmRlciB0aGUgdGVybXMgb2YgdGhlIEVjbGlwc2UgUHVibGljIExpY2Vuc2UgdjEuMAogICogd2hpY2ggYWNjb21wYW5pZXMgdGhpcyBkaXN0cmlidXRpb24sIGFuZCBpcyBhdmFpbGFibGUgYXQKQEAgLTEwLDcgKzEwLDYgQEAKICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwogcGFja2FnZS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CQkJCWlmIChlbmNsb3NpbmcgIT0gb3RoZXJFbmNsb3NpbmcpIHJldHVybiBmYWxzZTsKLSAgICAgICAgICAgIAkJfSBlbHNlIHsKLSAgICAgICAgICAgIAkJCWlmICghZW5jbG9zaW5nLmlzRXF1aXZhbGVudFRvKG90aGVyUGFyYW1UeXBlLmVuY2xvc2luZ1R5cGUoKSkpIHJldHVybiBmYWxzZTsKLSAgICAgICAgICAgIAkJfQotICAgICAgICAgICAgCX0KLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGludCBsZW5ndGggPSBwYXJhbVR5cGUuYXJndW1lbnRzID09IG51bGwgPyAwIDogcGFyYW1UeXBlLmFyZ3VtZW50cy5sZW5ndGg7Ci0gICAgICAgICAgICBUeXBlQmluZGluZ1tdIG90aGVyQXJndW1lbnRzID0gb3RoZXJQYXJhbVR5cGUuYXJndW1lbnRzOwotICAgICAgICAgICAgaW50IG90aGVyTGVuZ3RoID0gb3RoZXJBcmd1bWVudHMgPT0gbnVsbCA/IDAgOiBvdGhlckFyZ3VtZW50cy5sZW5ndGg7Ci0gICAgICAgICAgICBpZiAob3RoZXJMZW5ndGggIT0gbGVuZ3RoKSAKLSAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7Ci0gICAgICAgICAgICBuZXh0QXJndW1lbnQ6IGZvciAoaW50IGkgPSAwOyBpIDwgbGVuZ3RoOyBpKyspIHsKLSAgICAgICAgICAgIAlUeXBlQmluZGluZyBhcmd1bWVudCA9IHBhcmFtVHlwZS5hcmd1bWVudHNbaV07Ci0gICAgICAgICAgICAJVHlwZUJpbmRpbmcgb3RoZXJBcmd1bWVudCA9IG90aGVyQXJndW1lbnRzW2ldOwotICAgICAgICAgICAgCWlmIChhcmd1bWVudCA9PSBvdGhlckFyZ3VtZW50KSAKLSAgICAgICAgICAgIAkJY29udGludWUgbmV4dEFyZ3VtZW50OwotICAgICAgICAgICAgCWludCBraW5kID0gYXJndW1lbnQua2luZCgpOwotICAgICAgICAgICAgCWl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pbmRpbmcuamF2YQpuZXcgZmlsZSBtb2RlIDEwMDc1NQppbmRleCAwMDAwMDAwLi41MTk2NzI5Ci0tLSAvZGV2L251bGwKKysrIGIvb3JnLmVjbGlwc2UuamR0LmNvcmUvY29tcGlsZXIvb3JnL2VjbGlwc2UvamR0L2ludGVybmFsL2NvbXBpbGVyL2xvb2t1cC9VbnJlc29sdmVkQW5ub3RhdGlvbkJpbmRpbmcuamF2YQpAQCAtMCwwICsxLDU2IEBACisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogQ29weXJpZ2h0IChjKSAyMDAwLCAyMDA2IElCTSBDb3Jwb3JhdGlvbiBhbmQgb3RoZXJzLgorICogQWxsIHJpZ2h0cyByZXNlcnZlZC4gVGhpcyBwcm9ncmFtIGFuZCB0aGUgYWNjb21wYW55aW5nIG1hdGVyaWFscworICogYXJlIG1hZGUgYXZhaWxhYmxlIHVuZGVyIHRoZSB0ZXJtcyBvZiB0aGUgRWNsaXBzZSBQdWJsaWMgTGljZW5zZSB2MS4wCisgKiB3aGljaCBhY2NvbXBhbmllcyB0aGlzIGRpc3RyaWJ1dGlvbiwgYW5kIGlzIGF2YWlsYWJsZSBhdAorICogaHR0cDovL3d3dy5lY2xpcHNlLm9yZy9sZWdhbC9lcGwtdjEwLmh0bWwKKyAqCisgKiBDb250cmlidXRvcnM6CisgKiAgICAgSUJNIENvcnBvcmF0aW9uIC0gaW5pdGlhbCBBUEkgYW5kIGltcGxlbWVudGF0aW9uCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK3BhY2thZ2Ugb3JnLmVjbGlwc2UuamR0LmludGVybmFsLmNvbXBpbGVyLmxvb2t1cDsKKworcHVibGljIGNsYXNzIFVucmVzb2x2ZWRBbm5vdGF0aW9uQmluZGluZyBleHRlbmR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JpYWJsZTsKKwkJCXRoaXMudGFnQml0cyB8PSBzb21lQm91bmQudGFnQml0cyAmIFRhZ0JpdHMuSGFzVHlwZVZhcmlhYmxlOwogCQl9CiAJfQogCkBAIC0zNDMsNyArMzYwLDcgQEAKICAgICAgICAgICAgIGlmICh0aGlzLmJvdW5kIGluc3RhbmNlb2YgUmVmZXJlbmNlQmluZGluZykgewogICAgICAgICAgICAgICAgIHJldHVybiAoKFJlZmVyZW5jZUJpbmRpbmcpIHRoaXMuYm91bmQpLmlzU3VwZXJjbGFzc09mKG90aGVyVHlwZSk7CiAgICAgICAgICAgICB9IGVsc2UgeyAvLyBhcnJheSBib3VuZAotICAgICAgICAgICAgICAgIHJldHVybiBvdGhlclR5cGUuaWQgPT0gVF9KYXZhTGFuZ09iamVjdDsKKyAgICAgICAgICAgICAgICByZXR1cm4gb3RoZXJUeXBlLmlkID09IFR5cGVJZHMuVF9KYXZhTGFuZ09iamVjdDsKICAgICAgICAgICAgIH0KICAgICAgICAgfQogICAgICAgICByZXR1cm4gZmFsc2U7CkBAIC0zNzYsMTAgKzM5MywxMCBAQAogICAgIHB1YmxpYyBjaGFyW10gcmVhZGFibGVOYW1lKCkgewogICAgICAgICBzd2l0Y2ggKHRoaXMuYm91bmRLaW5kKSB7CiAgICAgICAgICAgICBjYXNlIFdpbGRjYXJkLlVOQk9VTkQgOiAKLSAgICAgICAgICAgICAgICByZXR1cm4gV0lMRENBUkRfTkFNRTsKKyAgICAgICAgICAgICAgICByZXR1cm4gVHlwZUNvbnN0YW50cy5XSUxEQ0FSRF9OQU1FOwogICAgICAgICAgICAgY2FzZSBXaWxkY2FyZC5FWFRFTkRTIDoKICAgICAgICAgICAgIAlpZiAodGhpcy5vdGhlckJvdW5kcyA9PSBudWxsKSAKLQkgICAgICAgICAgICAgICAgcmV0dXJuIENoYXJPcGVyYXRpb24uY29uY2F0KFdJTERDQVJEX05BTUUsIFdJTERDQVJEX0VYVEVORFMsIHRoaXMuYm91bmQucmVhZGFibG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hbnRzLmphdmEKbmV3IGZpbGUgbW9kZSAxMDA3NTUKaW5kZXggMDAwMDAwMC4uMDMwMWMwNAotLS0gL2Rldi9udWxsCisrKyBiL29yZy5lY2xpcHNlLmpkdC5jb3JlL2NvbXBpbGVyL29yZy9lY2xpcHNlL2pkdC9pbnRlcm5hbC9jb21waWxlci9wYXJzZXIvSmF2YWRvY1RhZ0NvbnN0YW50cy5qYXZhCkBAIC0wLDAgKzEsMTkwIEBACisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogQ29weXJpZ2h0IChjKSAyMDAwLCAyMDA3IElCTSBDb3Jwb3JhdGlvbiBhbmQgb3RoZXJzLgorICogQWxsIHJpZ2h0cyByZXNlcnZlZC4gVGhpcyBwcm9ncmFtIGFuZCB0aGUgYWNjb21wYW55aW5nIG1hdGVyaWFscworICogYXJlIG1hZGUgYXZhaWxhYmxlIHVuZGVyIHRoZSB0ZXJtcyBvZiB0aGUgRWNsaXBzZSBQdWJsaWMgTGljZW5zZSB2MS4wCisgKiB3aGljaCBhY2NvbXBhbmllcyB0aGlzIGRpc3RyaWJ1dGlvbiwgYW5kIGlzIGF2YWlsYWJsZSBhdAorICogaHR0cDovL3d3dy5lY2xpcHNlLm9yZy9sZWdhbC9lcGwtdjEwLmh0bWwKKyAqCisgKiBDb250cmlidXRvcnM6CisgKiAgICAgSUJNIENvcnBvcmF0aW9uIC0gaW5pdGlhbCBBUEkgYW5kIGltcGxlbWVudGF0aW9uCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworcGFja2FnZSBvcmcuZWNsaXBzZS5qZHQuaW50ZXJuYWwuY29tcGlsZXIucGFyc2VyOworCisvKioKKyAqIEphdmFkb2MgdGFnIGNvbnN0YW50cy4KKyAqCisgKiBAc2luY2UgMy4yCisgKi8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WwvY29tcGlsZXIvcGFyc2VyL1JlY292ZXJlZEluaXRpYWxpemVyLmphdmEKKysrIGIvb3JnLmVjbGlwc2UuamR0LmNvcmUvY29tcGlsZXIvb3JnL2VjbGlwc2UvamR0L2ludGVybmFsL2NvbXBpbGVyL3BhcnNlci9SZWNvdmVyZWRJbml0aWFsaXplci5qYXZhCkBAIC0xLDUgKzEsNSBAQAogLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKLSAqIENvcHlyaWdodCAoYykgMjAwMCwgMjAwNCBJQk0gQ29ycG9yYXRpb24gYW5kIG90aGVycy4KKyAqIENvcHlyaWdodCAoYykgMjAwMCwgMjAwNiBJQk0gQ29ycG9yYXRpb24gYW5kIG90aGVycy4KICAqIEFsbCByaWdodHMgcmVzZXJ2ZWQuIFRoaXMgcHJvZ3JhbSBhbmQgdGhlIGFjY29tcGFueWluZyBtYXRlcmlhbHMKICAqIGFyZSBtYWRlIGF2YWlsYWJsZSB1bmRlciB0aGUgdGVybXMgb2YgdGhlIEVjbGlwc2UgUHVibGljIExpY2Vuc2UgdjEuMAogICogd2hpY2ggYWNjb21wYW5pZXMgdGhpcyBkaXN0cmlidXRpb24sIGFuZCBpcyBhdmFpbGFibGUgYXQKQEAgLTEwLDkgKzEwLDYgQEAKICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwogcGFja2FnZSBvcmcuZWNsaXBzZS5qZHQuaW50ZXJuYWwuY29tcGlsZXIucGFyc2VyOwogCi0vKioKLSAqIEludGVybmFsIGluaXRpYWxpemVyIHN0cnVjdHVyZSBmb3IgcGFyc2luZyByZWNvdmVyeSAKLSAqLwogaW1wb3J0IG9yZy5lY2xpcHNlLmpkdC5jb3JlLmNvbXBpbGVyLio7CiBpbXBvcnQgb3JnLmVjbGlwc2UuamR0LmludGV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ICAgICAgICAgICAgIAlpbnQgdG1wQWRkZWRUb2tlbiA9IFBhcnNlci5yZXZlcnNlX2luZGV4W1BhcnNlci5zY29wZV9yaHNbaV1dOworCQkgICAgICAgICAgICAgICAgaWYgKHRtcEFkZGVkVG9rZW4gPiAtMSkgeworCQkgICAgICAgICAgICAgICAgCWludCBsZW5ndGggPSBhZGRlZFRva2Vucy5sZW5ndGg7CisJCSAgICAgICAgICAgICAgICAJaWYoYWRkZWRUb2tlbkNvdW50ID09IGxlbmd0aCkgeworCQkgICAgICAgICAgICAgICAgCQlTeXN0ZW0uYXJyYXljb3B5KGFkZGVkVG9rZW5zLCAwLCBhZGRlZFRva2VucyA9IG5ldyBpbnRbbGVuZ3RoICogMl0sIDAsIGxlbmd0aCk7CisJCSAgICAgICAgICAgICAgICAJfQorCQkgICAgICAgICAgICAgICAgCWFkZGVkVG9rZW5zW2FkZGVkVG9rZW5Db3VudCsrXSA9IHRtcEFkZGVkVG9rZW47CisJCSAgICAgICAgICAgICAgICB9IGVsc2UgeworCQkgICAgICAgICAgICAgICAgCWludFtdIHRlbXBsYXRlID0gZ2V0TlRlcm1UZW1wbGF0ZSgtdG1wQWRkZWRUb2tlbik7CisJCSAgICAgICAgICAgICAgICAJaWYodGVtcGxhdGUgIT0gbnVsbCkgeworCQkJICAgICAgICAgICAgICAgIAlmb3IgKGludCBqID0gMDsgaiA8IHRlbXBsYXRlLmxlbmd0aDsgaisrKSB7CisJCQkJCQkJCQlpbnQgbGVuZ3RoID0gYWRkZWRUb2tlbnMubGVuZ3RoOworCQkgICAgICAgICAgICAgICAgCQkJaWYoYWRkZWRUb2tlbkNvdW50ID09IGxlbmd0aCkgeworCQkJCSAgICAgICAgICAgICAgICAJCVN5c3RlbS5hcnJheWNvcHkoYWRkZWRUb2tlbnMsIDAsIGFkZGVkVG9rZW5zID0gbmV3IGludFtsZW5ndGggKiAyXSwgMCwgbGVuZ3RoKTsKKwkJCQkgICAgICAgICAgICAgICAgCX0KKwkJICAgICAgICAgICAgICAgIAkJCWFkZGVkVG9rZW5zW2FkZGVkVG9rZW5Db3VudCsrXSA9IHRlbXBsYXRlW2pdOworCQkJCQkJCQl9CisJCSAgICAgICAgICAgICAgICAJfSBlbHNlIHsKKwkJCSAgICAgICAgICAgICAgICAJYWRkZWRUb2tlbkNvdW50ID0gMDsKKwkJCSAgICAgICAgICAgICAgICAJYWRkZWRUb2tlbnMgPSBudWxsOworCQkgICAgICAgICAgICAgICAgCX0KKwkJICAgICAgICAgICAgICAgIH0KKwkgICAgICAgICAgICAgICAgfQogCQkJCX0KIAorCQkJCWlmKGFkZGVkVG9rZW5Db3VudCA+IDApIHsKKwkgICAgICAgICAgICAJU3lzdGVtLmFycmF5Y29weShhZGRlZFRva2VucywgMCwgYWRkZWRUb2tlbnMgPSBuZXcgaW50W2FkZGVkVG9rZW5Db3VudF0sIDAsIGFkZGVkVG9rZW5Db3VudCk7CisJICAgICAgICAgICAgCQorCSAgICAgICAgICAgIAlpbnQgY29tcGxldGVkVG9rZW4gPSAtMTsKKwkgICAgICAgICAgICAJaWYoc2NvcGVOYW1lSW5kZXggIT0gMCkgeworCSAgICAgICAgICAgIAkJY29tcGxldGVkVG9rZW4gPSAtUGFyc2VyLnJldmVyc2VfaW5kZXhbc2NvcGVOYW1lSW5kZXhdOworCSAgICAgICAgICAgIAl9CisJICAgICAgICAgICAgCXRoaXMucmVjb3ZlcnlTY2FubmVyLmluc2VydFRva2VucyhhZGRlZFRva2VucywgY29tcGxldGVkVG9rZW4sIGVycm9yRW5kKTsKKwkgICAgICAgICAgICB9CisJCQkJCiAJCQkJaWYgKHNjb3BlTmFtZUluZGV4ICE9IDApIHsKLQkJCQkJcHJvYmxlbVJlcG9ydGVyKCkucGFyc2VFcnJvckluc2VydFRvQ29tcGxldGUoCisJCQkJCWlmKHRoaXMucmVwb3J0UHJvYmxlbSkgcHJvYmxlbVJlcG9ydGVyKCkucGFyc2VFcnJvckluc2VydFRvQ29tcGxldGUoCiAJCQkJCQllcn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AgICAgICAgICAgIGlmKHRoaXMucmVjb3ZlcnlTY2FubmVyICE9IG51bGwpIHsKKwkgICAgICAgICAgICAJYWRkZWRUb2tlbnMgPSBuZXcgaW50W1BhcnNlci5zY29wZV9yaHMubGVuZ3RoIC0gUGFyc2VyLnNjb3BlX3N1ZmZpeFstIG5hbWVJbmRleF1dOworCSAgICAgICAgICAgIH0KKwkgICAgICAgICAgICAKIAkgICAgICAgICAgICBmb3IgKGludCBpID0gUGFyc2VyLnNjb3BlX3N1ZmZpeFstIG5hbWVJbmRleF07IFBhcnNlci5zY29wZV9yaHNbaV0gIT0gMDsgaSsrKSB7CisJICAgICAgICAgICAgICAgIAogCSAgICAgICAgICAgICAgICBidWYuYXBwZW5kKFBhcnNlci5yZWFkYWJsZU5hbWVbUGFyc2VyLnNjb3BlX3Joc1tpXV0pOwogCSAgICAgICAgICAgICAgICBpZiAoUGFyc2VyLnNjb3BlX3Joc1tpKzFdICE9IDApCiAJICAgICAgICAgICAgICAgICAgICAgYnVmLmFwcGVuZCgnICcpOworCSAgICAgICAgICAgICAgICAKKwkgICAgICAgICAgICAgICAgaWYoYWRkZWRUb2tlbnMgIT0gbnVsbCkgeworCSAgICAgICAgICAgICAgICAJaW50IHRtcEFkZGVkVG9rZW4gPSBQYXJzZXIucmV2ZXJzZV9pbmRleFtQYXJzZXIuc2NvcGVfcmhzW2ldXTsKKwkJICAgICAgICAgICAgICAgIGlmICh0bXBBZGRlZFRva2VuID4gLTEpIHsKKwkJICAgICAgICAgICAgICAgIAlpbnQgbGVuZ3RoID0gYWRkZWRUb2tlbnMubGVuZ3RoOworCQkgICAgICAgICAgICAgICAgCWlmKGFkZGVkVG9rZW5Db3VudCA9PSBsZW5ndGgpIHsKKwkJICAgICAgICAgICAgICAgIAkJU3lzdGVtLmFycmF5Y29weShhZGRlZFRva2VucywgMCwgYWRkZWRUb2tlbnMgPSBuZXcgaW50W2xlbmd0aCAqIDJdLCAwLCBsZW5ndGgpOworCQkgICAgICAgICAgICAgICAgCX0KKwkJICAgICAgICAgICAgICAgIAlhZGRlZFRva2Vuc1thZGRlZFRva2VuQ291bnQrK10gPSB0bXBBZGRlZFRva2VuOworCQkgICAgICAgICAgICAgICAgfSBlbHNlIHsKKwkJICAgICAgICAgICAgICAgIAlpbnRbXSB0ZW1wbGF0ZSA9IGdldE5UZXJtVGVtcGxhdGUoLXRtcEFkZGVkVG9rZW4pOworCQkgICAgICAgICAgICAgICAgCWlmKHRlbXBsYXRlICE9IG51bGwpIHsKKwkJCSAgICAgICAgICAgICAgICAJZm9yIChpbnQgaiA9IDA7IGogPCB0ZW1wbGF0ZS5sZW5ndGg7IGorKykgeworCQkJCQkJCQkJaW50IGxlbmd0aCA9IGFkZGVkVG9rZW5zLmxlbmd0aDsKKwkJICAgICAgICAgICAgICAgIAkJCWlmKGFkZGVkVG9rZW5Db3VudCA9PSBsZW5ndGgpIHsKKwkJCQkgICAgICAgICAgICAgICAgCQlTeXN0ZW0uYXJyYXljb3B5KGFkZGVkVG9rZW5zLCAwLCBhZGRlZFRva2VucyA9IG5ldyBpbnRbbGVuZ3RoICogMl0sIDAsIGxlbmd0aCk7CisJCQkJICAgICAgICAgICAgICAgIAl9CisJCSAgICAgICAgICAgICAgICAJCQlhZGRlZFRva2Vuc1thZGRlZFRva2VuQ291bnQrK10gPSB0ZW1wbGF0ZVtqXTsKKwkJCQkJCQkJfQorCQkgICAgICAgICAgICAgICAgCX0gZWxzZSB7CisJCQkgICAgICAgICAgICAgICAgCWFkZGVkVG9rZW5Db3VudCA9IDA7CisJCQkgICAgICAgICAgICAgICAgCWFkZGVkVG9rZW5zID0gbnVsbDsKKwkJICAgICAgICAgICAgICAgIAl9CisJCSAgICAgICAgICAgICAgICB9CisJICAgICAgICAgICAgICAgIH0KKwkgICAgICAgICAgICB9CisJICAgICAgICAgICAgaWYoYWRkZWRUb2tlbkNvdW50ID4gMCkgeworCSAgICAgICAgICAgIAlTeXN0ZW0uYXJyYXljb3B5KGFkZGVkVG9rZW5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amR0LmNvcmUvY29tcGlsZXIvb3JnL2VjbGlwc2UvamR0L2ludGVybmFsL2NvbXBpbGVyL3Byb2JsZW0vQWJvcnRDb21waWxhdGlvblVuaXQuamF2YQppbmRleCBkOWI5MzdjLi45MjZjYjU0IDEwMDY0NAotLS0gYS9vcmcuZWNsaXBzZS5qZHQuY29yZS9jb21waWxlci9vcmcvZWNsaXBzZS9qZHQvaW50ZXJuYWwvY29tcGlsZXIvcHJvYmxlbS9BYm9ydENvbXBpbGF0aW9uVW5pdC5qYXZhCisrKyBiL29yZy5lY2xpcHNlLmpkdC5jb3JlL2NvbXBpbGVyL29yZy9lY2xpcHNlL2pkdC9pbnRlcm5hbC9jb21waWxlci9wcm9ibGVtL0Fib3J0Q29tcGlsYXRpb25Vbml0LmphdmEKQEAgLTEsNSArMSw1IEBACiAvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgotICogQ29weXJpZ2h0IChjKSAyMDAwLCAyMDA0IElCTSBDb3Jwb3JhdGlvbiBhbmQgb3RoZXJzLgorICogQ29weXJpZ2h0IChjKSAyMDAwLCAyMDA2IElCTSBDb3Jwb3JhdGlvbiBhbmQgb3RoZXJzLgogICogQWxsIHJpZ2h0cyByZXNlcnZlZC4gVGhpcyBwcm9ncmFtIGFuZCB0aGUgYWNjb21wYW55aW5nIG1hdGVyaWFscwogICogYXJlIG1hZGUgYXZhaWxhYmxlIHVuZGVyIHRoZSB0ZXJtcyBvZiB0aGUgRWNsaXBzZSBQdWJsaWMgTGljZW5zZSB2MS4wCiAgKiB3aGljaCBhY2NvbXBhbmllcyB0aGlzIGRpc3RyaWJ1dGlvbiwgYW5kIGlzIGF2YWlsYWJsZSBhdApAQCAtMTAsNyArMTAsOSBAQAogICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCiBwYWN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KKyAqIGh0dHA6Ly93d3cuZWNsaXBzZS5vcmcvbGVnYWwvZXBsLXYxMC5odG1sCisgKgorICogQ29udHJpYnV0b3JzOgorICogICAgIElCTSBDb3Jwb3JhdGlvbiAtIGluaXRpYWwgQVBJIGFuZCBpbXBsZW1lbnRhdGlvbgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCitwYWNrYWdlIG9yZy5lY2xpcHNlLmpkdC5pbnRlcm5hbC5jb21waWxlci51dGlsOworCisvKioKKyAqIEhhc2h0YWJsZSBvZiB7T2JqZWN0IC0tPiBpbnRbXSB9CisgKi8KK3B1YmxpYyBmaW5hbCBjbGFzcyBIYXNodGFibGVPZk9iamVjdFRvSW50QXJyYXkgaW1wbGVtZW50cyBDbG9uZWFibGUgeworCQorCS8vIHRvIGF2b2lkIHVzaW5nIEVudW1lcmF0aW9ucywgd2FsayB0aGUgaW5kaXZpZHVhbCB0YWJsZXMgc2tpcHBpbmcgbnVsbHMKKwlwdWJsaWMgT2JqZWN0W10ga2V5VGFibGU7CisJcHVibGljIGludFtdW10gdmFsdWVUYWJsZTsKKworCXB1YmxpYyBpbnQgZWxlbWVudFNpemU7IC8vIG51bWJlciBvZiBlbGVtZW50cyBpbiB0aGUgdGFibGUKKwlpbnQgdGhyZXNob2xkOworCisJcHVibGljIEhhc2h0YWJsZU9mT2JqZWN0VG9JbnRBcnJheSgpIHsKKwkJdGhpcygxMyk7CisJfQorCisJcHVibGljIEhhc2h0YWJsZU9mT2JqZWN0VG9JbnRBcnJheShpbnQgc2l6ZSkgeworCisJCXRoaXMuZWxlbWVudFNpemUgPSAwOworCQl0aGlzLnRocmVzaG9sZCA9IHNpemU7IC8vIHNpemUgcmVwcmVzZW50cyB0aGUgZXhwZWN0ZWQgbnVtYmVyIG9mIGVsZW1lbnRzCisJCWludCBleHRyYVJvb20gPSAoaW50KSAoc2l6ZSAqIDEuNzVmK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Glwc2UuamR0LmNvcmUvZG9tL29yZy9lY2xpcHNlL2pkdC9jb3JlL2RvbS9BU1RSZWNvdmVyeVByb3BhZ2F0b3IuamF2YQpAQCAtMCwwICsxLDM3OSBAQAorLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIENvcHlyaWdodCAoYykgMjAwNiBJQk0gQ29ycG9yYXRpb24gYW5kIG90aGVycy4KKyAqIEFsbCByaWdodHMgcmVzZXJ2ZWQuIFRoaXMgcHJvZ3JhbSBhbmQgdGhlIGFjY29tcGFueWluZyBtYXRlcmlhbHMKKyAqIGFyZSBtYWRlIGF2YWlsYWJsZSB1bmRlciB0aGUgdGVybXMgb2YgdGhlIEVjbGlwc2UgUHVibGljIExpY2Vuc2UgdjEuMAorICogd2hpY2ggYWNjb21wYW5pZXMgdGhpcyBkaXN0cmlidXRpb24sIGFuZCBpcyBhdmFpbGFibGUgYXQKKyAqIGh0dHA6Ly93d3cuZWNsaXBzZS5vcmcvbGVnYWwvZXBsLXYxMC5odG1sCisgKgorICogQ29udHJpYnV0b3JzOgorICogICAgIElCTSBDb3Jwb3JhdGlvbiAtIGluaXRpYWwgQVBJIGFuZCBpbXBsZW1lbnRhdGlvbgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKK3BhY2thZ2Ugb3JnLmVjbGlwc2UuamR0LmNvcmUuZG9tOworCitpbXBvcnQgamF2YS51dGlsLkxpc3Q7CitpbXBvcnQgamF2YS51dGlsLlZlY3RvcjsKKworaW1wb3J0IG9yZy5lY2xpcHNlLmpkdC5jb3JlLmNvbXBpbGVyLkNhdGVnb3JpemVkUHJvYmxlbTsKK2ltcG9ydCBvcmcuZWNsaXBzZS5qZHQuY29yZS5jb21waWxlci5DaGFyT3BlcmF0aW9uOworaW1wb3J0IG9yZy5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0LmNvcmUvZG9tL29yZy9lY2xpcHNlL2pkdC9jb3JlL2RvbS9JTWVtYmVyVmFsdWVQYWlyQmluZGluZy5qYXZhCkBAIC0wLDAgKzEsNjEgQEAKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBDb3B5cmlnaHQgKGMpIDIwMDUsIDIwMDcgQkVBIFN5c3RlbXMsIEluYy4KKyAqIEFsbCByaWdodHMgcmVzZXJ2ZWQuIFRoaXMgcHJvZ3JhbSBhbmQgdGhlIGFjY29tcGFueWluZyBtYXRlcmlhbHMKKyAqIGFyZSBtYWRlIGF2YWlsYWJsZSB1bmRlciB0aGUgdGVybXMgb2YgdGhlIEVjbGlwc2UgUHVibGljIExpY2Vuc2UgdjEuMAorICogd2hpY2ggYWNjb21wYW5pZXMgdGhpcyBkaXN0cmlidXRpb24sIGFuZCBpcyBhdmFpbGFibGUgYXQKKyAqIGh0dHA6Ly93d3cuZWNsaXBzZS5vcmcvbGVnYWwvZXBsLXYxMC5odG1sCisgKgorICogQ29udHJpYnV0b3JzOgorICogICAgdHlldW5nQGJlYS5jb20gLSBpbml0aWFsIEFQSSBhbmQgaW1wbGVtZW50YXRpb24KKyAqICAgIElCTSBDb3Jwb3JhdGlvbiAtIGNoYW5nZWQgaW50ZXJmYWNlIHRvIGV4dGVuZCBJQmluZGluZworICogICAgSUJNIENvcnBvcmF0aW9uIC0gcmVuYW1lZCBmcm9tIElSZXNvbHZlZE1lbWJlclZhbHVlUGFpciB0byBJTWVtYmVyVmFsdWVQYWlyQmluZGluZworICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCitwYWNrYWdlIG9yZy5lY2xpcHNlLmpkdC5jb3JlLmRvbTsKKworLyoqCisgKiBSZXByZXNlbnRzIGEgcmVzb2x2ZWQgaW5zdGFuY2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3RhdGljIGZpbmFsIGludCBOT05FID0gMHgwMDAwOworCisJLyoqCisJICogInByaXZhdGUiIG1vZGlmaWVyIGNvbnN0YW50IChiaXQgbWFzaykuCisJICogQXBwbGljYWJsZSB0byB0eXBlcywgbWV0aG9kcywgY29uc3RydWN0b3JzLCBhbmQgZmllbGRzLgorCSAqIEBzaW5jZSAyLjAKKwkgKi8KKwlwdWJsaWMgc3RhdGljIGZpbmFsIGludCBQUklWQVRFID0gMHgwMDAyOworCisJLyoqCisJICogQSBsaXN0IG9mIHByb3BlcnR5IGRlc2NyaXB0b3JzIChlbGVtZW50IHR5cGU6IAorCSAqIHtAbGluayBTdHJ1Y3R1cmFsUHJvcGVydHlEZXNjcmlwdG9yfSksCisJICogb3IgbnVsbCBpZiB1bmluaXRpYWxpemVkLgorCSAqLworCXByaXZhdGUgc3RhdGljIGZpbmFsIExpc3QgUFJPUEVSVFlfREVTQ1JJUFRPUlM7CisKKwkvKioKKwkgKiAicHJvdGVjdGVkIiBtb2RpZmllciBjb25zdGFudCAoYml0IG1hc2spLgorCSAqIEFwcGxpY2FibGUgdG8gdHlwZXMsIG1ldGhvZHMsIGNvbnN0cnVjdG9ycywgYW5kIGZpZWxkcy4KKwkgKiBAc2luY2UgMi4wCisJICovCisJcHVibGljIHN0YXRpYyBmaW5hbCBpbnQgUFJPVEVDVEVEID0gMHgwMDA0OworCisJLyoqCisJICogInB1YmxpYyIgbW9kaWZpZXIgY29uc3RhbnQgKGJpdCBtYXNrKS4KKwkgKiBBcHBsaWNhYmxlIHRvIHR5cGVzLCBtZXRob2RzLCBjb25zdHJ1Y3RvcnMsIGFuZCBmaWVsZHMuCisJICogQHNpbmNlIDIuMAorCSAqLworCXB1YmxpYyBzdGF0aWMgZmluYWwgaW50IFBVQkxJQyA9IDB4MDAwMTsKKworCS8qKgorCSAqICJzdGF0aWMiIG1vZGlmaWVyIGNvbnN0YW50IChiaXQgbWFzaykuCisJICogQXBwbGljYWJsZSB0byB0eXBlcywgbWV0a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0ltcG9ydFJld3JpdGVBbmFseXplci5qYXZhIGIvb3JnLmVjbGlwc2UuamR0LmNvcmUvZG9tL29yZy9lY2xpcHNlL2pkdC9pbnRlcm5hbC9jb3JlL2RvbS9yZXdyaXRlL0ltcG9ydFJld3JpdGVBbmFseXplci5qYXZhCm5ldyBmaWxlIG1vZGUgMTAwNzU1CmluZGV4IDAwMDAwMDAuLjlkZjI4M2QKLS0tIC9kZXYvbnVsbAorKysgYi9vcmcuZWNsaXBzZS5qZHQuY29yZS9kb20vb3JnL2VjbGlwc2UvamR0L2ludGVybmFsL2NvcmUvZG9tL3Jld3JpdGUvSW1wb3J0UmV3cml0ZUFuYWx5emVyLmphdmEKQEAgLTAsMCArMSwxMDM4IEBACisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogQ29weXJpZ2h0IChjKSAyMDAwLCAyMDA2IElCTSBDb3Jwb3JhdGlvbiBhbmQgb3RoZXJzLgorICogQWxsIHJpZ2h0cyByZXNlcnZlZC4gVGhpcyBwcm9ncmFtIGFuZCB0aGUgYWNjb21wYW55aW5nIG1hdGVyaWFscworICogYXJlIG1hZGUgYXZhaWxhYmxlIHVuZGVyIHRoZSB0ZXJtcyBvZiB0aGUgRWNsaXBzZSBQdWJsaWMgTGljZW5zZSB2MS4wCisgKiB3aGljaCBhY2NvbXBhbmllcyB0aGlzIGRpc3RyaWJ1dGlvbiwgYW5kIGlzIGF2YWlsYWJsZSBhdAorICogaHR0cDovL3d3dy5lY2xpcHNlLm9yZy9sZWdhbC9lcGwtdjEwLmh0bWwKKyAqCisgKiBDb250cmlidXRvcnM6CisgKiAgICAgSUJNIENvcnBvcmF0aW9uIC0gaW5pdGlhbCBBUEkgYW5kIGltcGxlbWVudGF0aW9uCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqK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bGFibGUgYXQKKyAqIGh0dHA6Ly93d3cuZWNsaXBzZS5vcmcvbGVnYWwvZXBsLXYxMC5odG1sCisgKgorICogQ29udHJpYnV0b3JzOgorICogICAgIElCTSBDb3Jwb3JhdGlvbiAtIGluaXRpYWwgQVBJIGFuZCBpbXBsZW1lbnRhdGlvbgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKK3BhY2thZ2Ugb3JnLmVjbGlwc2UuamR0LmludGVybmFsLmNvcmUuZG9tLnJld3JpdGU7CisKK2ltcG9ydCBqYXZhLnV0aWwuQXJyYXlzOworaW1wb3J0IGphdmEudXRpbC5MaXN0OworCitpbXBvcnQgb3JnLmVjbGlwc2UuamR0LmNvcmUuZG9tLkxpbmVDb21tZW50OworaW1wb3J0IG9yZy5lY2xpcHNlLmpkdC5jb3JlLmZvcm1hdHRlci5JbmRlbnRNYW5pcHVsYXRpb247CitpbXBvcnQgb3JnLmVjbGlwc2UuamR0LmludGVybmFsLmNvbXBpbGVyLnV0aWwuVXRpbDsKKworcHVibGljIGNsYXNzIExpbmVDb21tZW50RW5kT2Zmc2V0cyB7CisJCisJcHJpdmF0ZSBpbnRbXSBvZmZzZXRzOworCXByaXZhdGUgZmluYWwgTGlzdCBjb21tZW50TGlzdDsKKwkKKwlwdWJsaWMgTGluZUNvbW1lbnRFbmRPZmZzZXRzKExpc3QgY29tbWVudExpc3QpIHsKKwkJdGhpcy5jb21tZW50TGlzdD0gY29tbWVudExpc3Q7CisJCXRoaXMub2Zmc2V0cz0gbnVsbDsgLy8gY3JlYXRlIG9uIGRlbWFuZAorCX0KKwkKKwlwcml2YXRlIGludFtdIGdldE9mZnNldHMoKSB7CisJCWlmICh0aGlzLm9mZnNldHMgPT0gbnVsbCkgeworCQkJaWYgKHRoaXMuY29tbWVudExpc3QgIT0gbnVsbCkgeworCQkJCWludCBuQ29tbWVudHM9IHRoaXMuY29tb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UuamR0LmNvcmUvZG9tL29yZy9lY2xpcHNlL2pkdC9pbnRlcm5hbC9jb3JlL2RvbS9yZXdyaXRlL0xpbmVJbmZvcm1hdGlvbi5qYXZhCm5ldyBmaWxlIG1vZGUgMTAwNzU1CmluZGV4IDAwMDAwMDAuLjA1NWVlMDgKLS0tIC9kZXYvbnVsbAorKysgYi9vcmcuZWNsaXBzZS5qZHQuY29yZS9kb20vb3JnL2VjbGlwc2UvamR0L2ludGVybmFsL2NvcmUvZG9tL3Jld3JpdGUvTGluZUluZm9ybWF0aW9uLmphdmEKQEAgLTAsMCArMSw1OSBAQAorLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIENvcHlyaWdodCAoYykgMjAwMCwgMjAwNiBJQk0gQ29ycG9yYXRpb24gYW5kIG90aGVycy4KKyAqIEFsbCByaWdodHMgcmVzZXJ2ZWQuIFRoaXMgcHJvZ3JhbSBhbmQgdGhlIGFjY29tcGFueWluZyBtYXRlcmlhbHMKKyAqIGFyZSBtYWRlIGF2YWlsYWJsZSB1bmRlciB0aGUgdGVybXMgb2YgdGhlIEVjbGlwc2UgUHVibGljIExpY2Vuc2UgdjEuMAorICogd2hpY2ggYWNjb21wYW5pZXMgdGhpcyBkaXN0cmlidXRpb24sIGFuZCBpcyBhdmFpbGFibGUgYXQKKyAqIGh0dHA6Ly93d3cuZWNsaXBzZS5vcmcvbGVnYWwvZXBsLXYxMC5odG1sCisgKgorICogQ29udHJpYnV0b3JzOgorICogICAgIElCTSBDb3Jwb3JhdGlvbiAtIGluaXRpYWwgQVBJIGFuZCBpbXBsZW1lbnRhdGlvbgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKK3BhY2thZ2Ugb3JnLmVjbGlwc2UuamR0LmludGVybmFsLmNvcmUuZG9tLnJld3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