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T09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CiAgKiBTREMKICAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBDb3B5cmlnaHQgKEMpIDIwMTcgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCisgKiBDb3B5cmlnaHQgKEMpIDIwMjAgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCiAgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQogICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7CiAgKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCiAgKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKLSAqIAorICoKICAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wCi0gKiAKKyAqCiAgKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlCiAgKiBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0cmlidXRlZCBvbiBhbiAiQVMgSVMiIEJBU0lTLAogICogV0lUSE9VVCBXQVJSQU5USUVTIE9SIENPTkRJVElPTlMgT0YgQU5ZIEtJTkQsIGVpdGhlciBleHByZXNzIG9yIGltcGxpZWQuCk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iwxNCBAQAogICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KICAqIFNEQwogICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIENvcHlyaWdodCAoQykgMjAxNyBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqIENvcHlyaWdodCAoQykgMjAyMCBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KICAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CiAgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKICAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KICAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAotICogCisgKgogICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKLSAqIAorICoKICAqIFVubGVzcyByZXF1aXJlZCBieSBhcHBsaWNhYmxlIGxhdyBvciBhZ3JlZWQgdG8gaW4gd3JpdGluZywgc29mdHdhcmUKICAqIGRpc3RyaWJ1dGVkIHVuZGVyIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1dGVkIG9uIGFuICJBUyBJUyIgQkFTSVMsCiAgKiBXSVRIT1VUIFdBUlJBTlRJRVMgT1IgQ09ORElUSU9OUyBPRiBBTlkgS0lORCwgZWl0aGV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CmNvcHkgdG8gY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2NhdGFsb2cvZW51bXMvUmVzdWx0U3RhdHVzRW51bS5qYXZhCmluZGV4IDIwNzYzZDAuLjUzYTI0MjMgMTAwNjQ0Ci0tLSBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9jb21tb24vdHJhbnNhY3Rpb24vYXBpL0lEQkFjdGlvbi5qYXZhCisrKyBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jYXRhbG9nL2VudW1zL1Jlc3VsdFN0YXR1c0VudW0uamF2YQpAQCAtMiwxNCArMiwxNCBAQAogICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KICAqIFNEQwogICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIENvcHlyaWdodCAoQykgMjAxNyBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqIENvcHlyaWdodCAoQykgMjAyMCBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KICAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CiAgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKICAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW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db21wb25lbnRNZXNzYWdlLmphdmEgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvY2F0YWxvZy9pbXBsL0NvbXBvbmVudE1lc3NhZ2UuamF2YQpuZXcgZmlsZSBtb2RlIDEwMDY0NAppbmRleCAwMDAwMDAwLi44MmI2NDY3Ci0tLSAvZGV2L251bGwKKysrIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2NhdGFsb2cvaW1wbC9Db21wb25lbnRNZXNzYWdlLmphdmEKQEAgLTAsMCArMSwxNTEgQEAKKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAyMCBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKKyAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KKyAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAorICoKKyAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wCisgKgorICogVW5sZXNzIHJ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3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvY2F0YWxvZy9pbXBsL0RtYWFwUHJvZHVjZXIuamF2YQpAQCAtMCwwICsxLDE0MCBAQAorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDIwIEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgorICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0CisgKgorICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKKyAqCisgKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlCisgKiBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0cmlidXRlZCBvbiBhbiAiQVMgSVMiIEJBU0lTLAorICogV0lUSE9VVCBXQVJSQU5USUVTIE9SIENPTkRJVElPTlMgT0YgQU5ZIEtJTkQsIGVpdGhlciBleHByZ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ZWNrSW5mbzsKKyAgICAgICAgSGVhbHRoQ2hlY2tJbmZvUmVzdWx0KEhlYWx0aENoZWNrSW5mbyBoZWFsdGhDaGVja0luZm8pIHsKKyAgICAgICAgICAgIHRoaXMuaGVhbHRoQ2hlY2tJbmZvID0gaGVhbHRoQ2hlY2tJbmZvOworICAgICAgICB9CisgICAgICAgIHB1YmxpYyBIZWFsdGhDaGVja0luZm8gZ2V0SGVhbHRoQ2hlY2tJbmZvKCkgeworICAgICAgICAgICAgcmV0dXJuIGhlYWx0aENoZWNrSW5mbzsKKyAgICAgICAgfQorICAgIH0KKworICAgIHB1YmxpYyBlbnVtIERtYWFwU3RhdHVzRGVzY3JpcHRpb24geworICAgICAgICBPSygiT0siKSwgVU5BVkFJTEFCTEUoIkRtYWFwUHJvZHVjZXIgaXMgbm90IGF2YWlsYWJsZSIpLERPV04oIkRPV04iKSwgTk9UX0NPTkZJR1VSRUQoIkRtYWFwUHJvZHVjZXIgY29uZmlndXJhdGlvbiBpcyBtaXNzaW5nL3dyb25nICIpOworCisgICAgICAgIHByaXZhdGUgU3RyaW5nIGRlc2M7CisgICAgICAgIERtYWFwU3RhdHVzRGVzY3JpcHRpb24oU3RyaW5nIGRlc2MpIHsKKyAgICAgICAgICAgIHRoaXMuZGVzYyA9IGRlc2M7CisgICAgICAgIH0KKyAgICAgICAgcHVibGljIFN0cmluZyBnZXREZXNjcmlwdGlvbigpIHsKKyAgICAgICAgICAgIHJldHVybiBkZXNjOworICAgICAgICB9CisKKyAgICB9CisKKyAgICBAUG9zdENvbnN0cnVjdAorICAgIHB1YmxpYyBEbWFhcFByb2R1Y2VySGVhbHRoIGluaXQoKSB7CisgICAgICAgIGxvZy50cmFjZSgiRW50ZXIgaW5pdCBtZXRob2Qgb2YgRG1hYXBQcm9kdWNlciBoZWFsdGgiKTsKKyAgICAgICAgc3luY2hyb25pemVkIChEbWFhcFByb2R1Y2VySGVhbHRoLmNsYXNzKXsKKyAgICAgICAgICAgIHRoaXMuY29uZ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dGgiKTsKKyAgICAgICAgcmV0dXJuIHRoaXM7CisgICAgfQorCisgICAgQFByZURlc3Ryb3kKKyAgICBwcm90ZWN0ZWQgdm9pZCBkZXN0cm95KCkgeworICAgICAgICBpZiAoc2NoZWR1bGVkRnV0dXJlICE9IG51bGwpIHsKKyAgICAgICAgICAgIHNjaGVkdWxlZEZ1dHVyZS5jYW5jZWwodHJ1ZSk7CisgICAgICAgICAgICBzY2hlZHVsZWRGdXR1cmUgPSBudWxsOworICAgICAgICB9CisgICAgICAgIGlmIChzY2hlZHVsZXIgIT0gbnVsbCkgeworICAgICAgICAgICAgc2NoZWR1bGVyLnNodXRkb3duKCk7CisgICAgICAgIH0KKyAgICB9CisKKyAgICAvKioKKyAgICAgKiBTdGFydCBoZWFsdGggY2hlY2sgdGFzay4KKyAgICAgKgorICAgICAqIEBwYXJhbSBzdGFydFRhc2sKKyAgICAgKi8KKyAgICBwcml2YXRlIHZvaWQgc3RhcnRIZWFsdGhDaGVja1Rhc2soYm9vbGVhbiBzdGFydFRhc2spIHsKKyAgICAgICAgc3luY2hyb25pemVkIChEbWFhcFByb2R1Y2VySGVhbHRoLmNsYXNzKXsKKyAgICAgICAgICAgIGlmIChzdGFydFRhc2sgJiYgdGhpcy5zY2hlZHVsZWRGdXR1cmUgPT0gbnVsbCkgeworICAgICAgICAgICAgICAgIHRoaXMuc2NoZWR1bGVkRnV0dXJlID0gdGhpcy5zY2hlZHVsZXIuc2NoZWR1bGVBdEZpeGVkUmF0ZSh0aGlzLmhlYWx0aENoZWNrU2NoZWR1bGVkVGFzayAsIDAsIHJlY29ubmVjdEludGVydmFsLCBUaW1lVW5pdC5TRUNPTkRTKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgIH0KKworICAgIHZvaWQgcmVwb3J0KEJvb2xlYW4gaXNVcCl7CisgICAgICAgIGlmIChyZXBvcnRlZEhlYWx0aFN0YXRlID09IG51bGwpCisgICAgICAgICAgICByZXBvcnRlZEhlYWx0aFN0YXRlID0gbmV3IEF0b21pY0Jvb2xlYW4oaXNVcCk7CisgICAgICAgIHJlcG9ydGVkSGVhbHRoU3RhdGUuc2V0KGlzVXApOworICAgIH0KKworCisgICAgcHVibGljIEhlYWx0aENoZWNrSW5mbyBnZXRIZWFsdGhDaGVja0luZm8oKSB7CisgICAgICAgIHJldHVybiBoZWFsdGhDaGVja0luZm87CisgICAgfQorCisgICAgLyoqCisgICAgICogSGVhbHRoIENoZWNrIFRhc2sgU2NoZWR1bGVyIC0gaW5maW5pdGUgY2hlY2suCisgICAgICovCisgICAgcHVibGljIGNsYXNzIEhlYWx0aENoZWNrU2NoZWR1bGVkVGFzayBpbXBsZW1lbnRzIFJ1bm5hYmxlIHsKKyAgICAgICAgcHJpdmF0ZSBmaW5hbCBEbWFhcFByb2R1Y2VyQ29uZmlndXJhdGlvbiBjb25maWc7CisgICAgICAgIHByaXZhdGUgc3RhdGljIGZpbmFsIGludCBUSU1FT1VUID0gODE5MjsKKworICAgICAgICBIZWFsdGhDaGVja1NjaGVkdWxlZFRhc2soZmluYWwgRG1hYXBQcm9kdWNlckNvbmZpZ3VyYXRpb24gY29uZmlnKXsKKyAgICAgICAgICAgIHRoaXMuY29uZmlnID0gY29uZmlnOworICAgICAgICB9CisgICAgICAgIEBPdmVycmlkZQorICAgICAgICBwdWJsaWMgdm9pZCBydW4oKSB7CisgICAgICAgICAgICBsb2dIZWFsdGgudHJhY2UoIkV4ZWN1dGluZyBEbWFhcCBIZWFsdGggQ2hlY2sgVGFzayAtIFN0YXJ0Iik7CisgICAgICAgICAgICBib29sZWFuIHByZXZJc1JlYWNoYWJsZTsKKyAgICAgICAgICAgIGJvb2xlYW4gcmVhY2hhYmxlOworICAgICAgICAgICAgLy9maXJzdCB0cnkgc2ltcGxlIHBpbmcKKyAgICAgICAgICAgIHRyeXsKKyAgICAgICAgICAgICAgICBpZiAoIHJlcG9ydGVkSGVhbHRoU3RhdGUgIT0gbnVsbCApeworICAgICAgICAgICAgICAgICAgICByZWFjaGFibGUgPSByZXBvcnRlZEhlYWx0aFN0YXRlLmdldCgpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBlbHNleworICAgICAgICAgICAgICAgICAgICByZWFjaGFibGUgPSAgZmFsc2U7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIHByZXZJc1JlYWNoYWJsZSA9IGxhc3RIZWFsdGhTdGF0ZS5nZXRBbmRTZXQoIHJlYWNoYWJsZSApOworICAgICAgICAgICAgICAgIGhlYWx0aENoZWNrSW5mbyA9IHJlYWNoYWJsZSA/IEhlYWx0aENoZWNrSW5mb1Jlc3VsdC5PSy5oZWFsdGhDaGVja0luZm8gOiBIZWFsdGhDaGVja0luZm9SZXN1bHQuRE9XTi5oZWFsdGhDaGVja0luZm87CisgICAgICAgICAgICB9CisgICAgICAgICAgICBjYXRjaCggRXhjZXB0aW9uIGUgKXsKKyAgICAgICAgICAgICAgICBsb2cuZGVidWcoInt9IC0gY2Fubm90IGNoZWNrIGNvbm5lY3Rpdml0eSAtPiB7fSIsRE1BQVBfSEVBTFRIX0NIRUNLX1NUUiwgZSApOworICAgICAgICAgICAgICAgIHByZXZJc1JlYWNoYWJsZSA9IGxhc3RIZWFsdGhTdGF0ZS5nZXRBbmRTZXQoZmFsc2UpOworICAgICAgICAgICAgICAgIGhlYWx0aENoZWNrSW5mbyA9IEhlYWx0aENoZWNrSW5mb1Jlc3VsdC5VTkFWQUlMQUJMRS5oZWFsdGhDaGVja0luZm87CisgICAgICAgICAgICB9CisgICAgICAgICAgICBpZiAocHJldklzUmVhY2hhYmxlICE9IGxhc3RIZWFsdGhTdGF0ZS5nZXQoKSkKKyAgICAgICAgICAgICAgICBsb2dBbGFybSggbGFzdEhlYWx0aFN0YXRlLmdldCgpICk7CisgICAgICAgIH0KKworCisgICAgICAgCisKKyAgICAgICAgcHJpdmF0ZSB2b2lkIGxvZ0FsYXJtKGJvb2xlYW4gbGFzdEhlYWx0aFN0YXRlKSB7CisgICAg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ShyZXNvdXJjZSwgYXJ0aWZhY3RzTWV0YUZpbGUsIGFydGlmYWN0c01ldGFGaWxlTmFtZSkKICAgICAgICAgICAgICAgICAubGVmdCgpCi0gICAgICAgICAgICAgICAgLmJpbmQoIHAtPiBjcmVhdGVSZXNvdXJjZUFydGlmYWN0cyhjc2FySW5mbywgcmVzb3VyY2UsIHAsIGNyZWF0ZWRBcnRpZmFjdHMsc2hvdWxkTG9jaywgaW5UcmFuc2FjdGlvbikpCisgICAgICAgICAgICAgICAgLmJpbmQoIHAtPiBjcmVhdGVSZXNvdXJjZUFydGlmYWN0cyhjc2FySW5mbywgcmVzb3VyY2UsIHAsIGNyZWF0ZWRBcnRpZmFjdHMpKQogICAgICAgICAgICAgICAgIC5yaWdodCgpCiAgICAgICAgICAgICAgICAgLm1hcChyZiAtPiB7IGNvbXBvbmVudHNVdGlscy5hdWRpdFJlc291cmNlKHJmLCBjc2FySW5mby5nZXRNb2RpZmllcigpLCByZXNvdXJjZSwgQXVkaXRpbmdBY3Rpb25FbnVtLklNUE9SVF9SRVNPVVJDRSk7IHJldHVybiByZjt9KQogICAgICAgICAgICAgICAgIC5sZWZ0KCkKQEAgLTEzNywzNSArMTYwLDM0IEBACiAgICAgICAgIH0KIAogICAgICAgICBMaXN0PEdyb3VwRGVmaW5pdGlvbj4gZ3JvdXBzID0gdXBkYXRlZFJlc291cmNlLmdldEdyb3VwcygpOwotICAgICAgICBNYXA8U3RyaW5nLCBBcnRpZmFjdERlZmluaXRpb24+IGRlcGx5bWVudEFydGlmYWN0ID0gdXBkYXRlZFJlc291cmNlLmdldERlcGxveW1lbnRBcnRpZmFjdHMoKTsKLSAgICAgICAgaWYgKGRlcGx5bWVudEFydGlmYWN0ID09IG51bGwgfHwgZGVwbHltZW50QXJ0aWZhY3QuaXNFbXB0eSgpKSB7Ci0gICAgICAgICAgICBpZihncm91cHMgIT0gbnVsbCl7Ci0gICAgICAgICAgICAgICAgTGlzdDxHcm91cERlZmluaXRpb24+IGxpc3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S5zdHJlYW0oKS5jb2xsZWN0KENvbGxlY3RvcnMudG9MaXN0KCkpOworICAgICAgICBMaXN0PEFydGlmYWN0RGVmaW5pdGlvbj4gY3JlYXRlZERlcGxveW1lbnRBcnRpZmFjdHNBZnRlckRlbGV0ZSA9IGRlcGxveW1lbnRBcnRpZmFjdC52YWx1ZXMoKS5zdHJlYW0oKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuY29sbGVjdChDb2xsZWN0b3JzLnRvTGlzdCgpKTsKIAotICAgICAgICBpbnQgbGFiZWxDb3VudGVyID0gY3JlYXRlZERlcGx5bWVudEFydGlmYWN0c0FmdGVyRGVsZXRlLnNpemUoKTsKLQorICAgICAgICBpbnQgbGFiZWxDb3VudGVyID0gY3JlYXRlZERlcGxveW1lbnRBcnRpZmFjdHNBZnRlckRlbGV0ZQorICAgICAgICAgICAgICAgIC5zdHJlYW0oKQorICAgICAgICAgICAgICAgIC5tYXAoQXJ0aWZhY3REZWZpbml0aW9uOjpnZXRBcnRpZmFjdExhYmVsKQorICAgICAgICAgICAgICAgIC5maWx0ZXIodGhpczo6aXNMYXN0Q2hhcmFjdGVySW5MYWJlbEFEaWdpdCkKKyAgICAgICAgICAgICAgICAubWFwKHRoaXM6OmdldE5leHRJbnQpCisgICAgICAgICAgICAgICAgLmZsYXRNYXBUb0ludCh0aGlzOjp0b1N0cmVhbSkKKyAgICAgICAgICAgICAgICAubWF4KCkKKyAgICAgICAgICAgICAgICAub3JFbHNlKC0xKSArIDE7CiAKICAgICAgICAgLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8gY3JlYXRlIHNldCBwYXJzZWQKICAgICAgICAgLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8gYXJ0aWZhY3RzLy8vLy8vLy8vLy8vLy8vLy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ICAgICAgZm9yIChBcnRpZmFjdERlZmluaXRpb24gZGVsZXRlZEFydGlmYWN0IDogZGVsZXRlZEFydGlmYWN0cykgewotICAgICAgICAgICAgICAgIEFydGlmYWN0RGVmaW5pdGlvbiBhcnRUb1JlbW92ZSA9IG51bGw7Ci0gICAgICAgICAgICAgICAgZm9yIChBcnRpZmFjdERlZmluaXRpb24gYXJ0RnJvbVJlc291cmNlIDogY3JlYXRlZERlcGx5bWVudEFydGlmYWN0c0FmdGVyRGVsZXRlKSB7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChkZWxldGVkQXJ0aWZhY3QuZ2V0VW5pcXVlSWQoKS5lcXVhbHNJZ25vcmVDYXNlKGFydEZyb21SZXNvdXJjZS5nZXRVbmlxdWVJZCgpKSkgewotICAgICAgICAgICAgICAgICAgICAgICAgYXJ0VG9SZW1vdmUgPSBhcnRGcm9tUmVzb3VyY2U7Ci0gICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBpZiAoYXJ0VG9SZW1vdmUgIT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICBjcmVhdGVkRGVwbHltZW50QXJ0aWZhY3RzQWZ0ZXJEZWxldGUucmVtb3ZlKGFydFRvUmVtb3ZlKTsKLSAgICAgICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgIH0KLSAgICAgICAgfQorICAgICAgICBleGNsdWRlRGVsZXRlZEFydGlmYWN0cyhkZWxldGVkQXJ0aWZhY3RzLCBjcmVhdGVkRGVwbG95bWVudEFydGlmYWN0c0FmdGVyRGVsZXRlKTsKIAogICAgICAgICAvLy8vLy8vLy8vLy8vLyBkaXNzb2NpYXRlLCBhc3NvY2lhdGUgb3IgY3JlYXRlCiAgICAgICAgIC8vLy8vLy8vLy8vLy8vIGFydGlmYWN0cy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8KICAgICAgICAgRW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SZXNvdXJjZSwgU3RvcmFnZU9wZXJhdGlvblN0YXR1cz4gZWl0aGVyR2V0UmVzb3VyY2UgPSB0b3NjYU9wZXJhdGlvbkZhY2FkZS5nZXRUb3NjYUVsZW1lbnQodXBkYXRlZFJlc291cmNlLmdldFVuaXF1ZUlkKCkpOworICAgICAgICByZXR1cm4gbWFwUmVzdWx0KGVpdGhlckdldFJlc291cmNlLCB1cGRhdGVkUmVzb3VyY2UpOworICAgIH0KKworICAgIHByaXZhdGUgRWl0aGVyPFJlc291cmNlLCBSZXNwb25zZUZvcm1hdD4gaGFuZGxlQXJ0aWZhY3RzSW5Hcm91cChDc2FySW5mbyBjc2FySW5mbywgTGlzdDxBcnRpZmFjdERlZmluaXRpb24+IGNyZWF0ZWROZXdBcnRpZmFjdHMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFJlc291cmNlIHVwZGF0ZWRSZXNvdXJjZSwgTGlzdDxHcm91cERlZmluaXRpb24+IGdyb3VwcywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTGlzdDxBcnRpZmFjdERlZmluaXRpb24+IGNyZWF0ZWREZXBsb3ltZW50QXJ0aWZhY3RzQWZ0ZXJEZWxldGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludCBsYWJlbENvdW50ZXIsIExpc3Q8QXJ0aWZhY3RUZW1wbGF0ZUluZm8+IG5ld0FydGlmYWN0c0dyb3VwKSB7CisgICAgICAgIGlmICghbmV3QXJ0aWZhY3RzR3JvdXAuaXNFbXB0eSgpKSB7CisgICAgICAgICAgICBDb2xsZWN0aW9ucy5zb3J0KG5ld0FydGlmYWN0c0dyb3VwLCBBcnRpZmFjdFRlbXBsYXRlSW5mbzo6Y29tcGFyZUJ5R3JvdXBOYW1lK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JzKCkuaXNFbXB0eSgpKSB7Ci0gICAgICAgICAgICAgICAgICAgIHVwZGF0ZWRHcm91cERlZi5nZXRNZW1iZXJzKCkuY2xlYXIoKTsKKyAgICAgICAgICAgIEVpdGhlcjxMaXN0PEdyb3VwRGVmaW5pdGlvbj4sIFJlc3BvbnNlRm9ybWF0PiB1cGRhdGVWZXJzaW9uRWl0aGVyID0gZ3JvdXBCdXNpbmVzc0xvZ2ljCisgICAgICAgICAgICAgICAgICAgIC51cGRhdGVHcm91cHModXBkYXRlZFJlc291cmNlLCBncm91cHNJZCwgdHJ1ZSk7CisgICAgICAgICAgICBpZiAodXBkYXRlVmVyc2lvbkVpdGhlci5pc1JpZ2h0KCkpIHsKKyAgICAgICAgICAgICAgICBsb2cuZGVidWcoIkZhaWxlZCB0byB1cGRhdGUgZ3JvdXBzIHZlcnNpb24uIFN0YXR1cyBpcyB7fSAiLCB1cGRhdGVWZXJzaW9uRWl0aGVyLnJpZ2h0KCkudmFsdWUoKSk7CisKKyAgICAgICAgICAgICAgICByZXR1cm4gRWl0aGVyLnJpZ2h0KHVwZGF0ZVZlcnNpb25FaXRoZXIucmlnaHQoKS52YWx1ZSgpKTsKKworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgICAgIHJldHVybiBudWxsOworICAgIH0KKworICAgIHByaXZhdGUgSW50U3RyZWFtIHRvU3RyZWFtKE9wdGlvbmFsSW50IG9wdGlvbmFsSW50KSB7CisgICAgICAgIGlmIChvcHRpb25hbEludC5pc1ByZXNlbnQoKSkgeworICAgICAgICAgICAgcmV0dXJuIEludFN0cmVhbS5vZihvcHRpb25hbEludC5nZXRBc0ludCgpKTsKKyAgICAgICAgfQorICAgICAgICByZXR1cm4gSW50U3RyZWFtLmVtcHR5KCk7CisgICAgfQorCisgICAgcHJpdmF0ZSBPcHRpb25hbEludCBnZXROZXh0SW50KFN0cmluZyBhcnRpZmFjdExhYmVsKSB7CisgICAgICAgIHRyeShTY2FubmVyIHNjYW5uZXIgPSBuZ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JjZS5nZXRVbmlxdWVJZCgpKSkgeworICAgICAgICAgICAgICAgICAgICBhcnRUb1JlbW92ZSA9IGFydEZyb21SZXNvdXJjZTsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIE1hcDxTdHJpbmcsIFN0cmluZz4gbWVtYmVycyA9IG5ldyBIYXNoTWFwPD4oKTsKLSAgICAgICAgICAgICAgICBTZXQ8U3RyaW5nPiBhcnRpZmFjdHNHcm91cCA9IG5ldyBIYXNoU2V0PD4oKTsKLSAgICAgICAgICAgICAgICBhcnRpZmFjdHNHcm91cC5hZGRBbGwodXBkYXRlZEdyb3VwRGVmLmdldEFydGlmYWN0cygpKTsKLSAgICAgICAgICAgICAgICBhc3NvY2lhdGVNZW1iZXJzVG9BcnRpZmFjdHMoY3JlYXRlZE5ld0FydGlmYWN0cywgY3JlYXRlZERlcGx5bWVudEFydGlmYWN0c0FmdGVyRGVsZXRlLCBoZWF0R3JvdXBzLAotICAgICAgICAgICAgICAgICAgICAgICAgYXJ0aWZhY3RzR3JvdXAsIG1lbWJlcnMpOwotICAgICAgICAgICAgICAgIGlmICghbWVtYmVycy5pc0VtcHR5KCkpIHsKLSAgICAgICAgICAgICAgICAgICAgdXBkYXRlZEdyb3VwRGVmLnNldE1lbWJlcnMobWVtYmVycyk7Ci0KLSAgICAgICAgICAgICAgICB9Ci0KKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGlmIChhcnRUb1JlbW92ZSAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgY3JlYXRlZERlcGxveW1lbnRBcnRpZmFjdHNBZnRlckRlbGV0ZS5yZW1vdmUoYXJ0VG9SZW1vdmUpOwogICAgICAgICAgICAgfQogCiAgICAgICAgIH0KKyAgICB9CiAKLSAgICAgICAgLy8vLy8vLy8vLy8vLy8vLyBjcmVhdGUgbmV3IGFydGlmYWN0cyBpbiB1cGRhdGUKLSAgICAgICAgLy8vLy8vLy8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R5cGUoKSkpewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFydGlmYWN0c1RvRGVsZXRlLmFkZChvcC5nZXQoKSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgCisgICAgICAgICAgICAgICAgICAgIE9wdGlvbmFsPEFydGlmYWN0RGVmaW5pdGlvbj4gb3AgPSBjcmVhdGVkRGVwbG95bWVudEFydGlmYWN0c0FmdGVyRGVsZXRlLnN0cmVhbSgpLmZpbHRlcihhIC0+IGEuZ2V0QXJ0aWZhY3ROYW1lKCkuZXF1YWxzSWdub3JlQ2FzZSh0ZW1wbGF0ZS5nZXRGaWxlTmFtZSgpKSkuZmluZEFueSgpOworICAgICAgICAgICAgICAgICAgICBpZiAob3AuaXNQcmVzZW50KCkgJiYgIW9wLmdldCgpLmdldEFydGlmYWN0VHlwZSgpLmVxdWFsc0lnbm9yZUNhc2UodGVtcGxhdGUuZ2V0VHlwZSgpKSkgeworICAgICAgICAgICAgICAgICAgICAgICAgYXJ0aWZhY3RzVG9EZWxldGUuYWRkKG9wLmdldCgpKTsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0gCiAgICAgICAgICAgICB9CkBAIC0zNzMsNyArNDU4LDcgQEAKIAogICAgIHByaXZhdGUgRWl0aGVyPFJlc291cmNlLCBSZXNwb25zZUZvcm1hdD4gY3JlYXRlUmVzb3VyY2VBcnRpZmFjdHMoQ3NhckluZm8gY3NhckluZm8sIFJlc291cmNlIHJlc291cmNlLAogICAgICAgICAgICAgTWFwPFN0cmluZywgTGlzdDxBcnRpZmFjdFRlbXBsYXRlSW5mbz4+IGFydGlmYWN0c01hcCwKLSAgICAgICAgICAgIExpc3Q8QXJ0aWZhY3REZWZpbml0aW9uPiBjcmVhdGVkQXJ0aWZhY3RzLCBib29sZWFuIHNob3VsZExvY2ssIGJvb2xlYW4gaW5UcmFuc2FjdGlvbikgeworICAgICAgICAgICAgTGl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ICAgICAgICAgICAgICBsYWJlbENvdW50ZXIsIHNob3VsZExvY2ssIGluVHJhbnNhY3Rpb24pOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc291cmNlLCBhcnJ0aWZhY3RzLCBjcmVhdGVkTmV3QXJ0aWZhY3RzLCBjcmVhdGVkRGVwbG95bWVudEFydGlmYWN0c0FmdGVyRGVsZXRlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxhYmVsQ291bnRlcik7CiAgICAgICAgICAgICAgICAgICAgIGlmIChyZXNTdGF0dXMuaXNSaWdodCgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gRWl0aGVyLnJpZ2h0KHJlc1N0YXR1cy5yaWdodCgpLnZhbHVlKCkpOwogICAgICAgICAgICAgICAgICAgICB9CkBAIC00NDAsMjAgKzUyNSwyMCBAQAogCiAgICAgICAgICAgICBKc29uRWxlbWVudCBpbXBvcnRTdHJ1Y3R1cmVFbGVtZW50ID0ganNvbkVsZW1lbnQuZ2V0KENvbnN0YW50cy5JTVBPUlRfU1RSVUNUVVJFKTsKICAgICAgICAgICAgIGlmIChpbXBvcnRTdHJ1Y3R1cmVFbGVtZW50ID09IG51bGwgfHwgaW1wb3J0U3RydWN0dXJlRWxlbWVudC5pc0pzb25OdWxsKCkpIHsKLSAgICAgICAgICAgICAgICBsb2cuZGVidWcoQVJUSUZBQ1RfRklMRV9JU19OT1RfSU5fRVhQRUNURURfRk9STUFUUl9GSUxFX05BTUUsIGFydGlmYWN0RmlsZU5hbWUpOworICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZyhBUlRJRkFDVF9GSUxFX0lTX05PVF9JTl9FWFBFQ1RFRF9GT1JNQVRfRklMRV9OQU1FLCBhcnRpZmFjdEZpbGVOYW1lKTsKICAgICAgICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nSW50ZXJuYWxEYXRhRXJyb3IoCi0gICAgICAgICAgICAgICAgICA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wgYXJ0aWZhY3RzR3JvdXAsCi0gICAgICAgICAgICAgICAgICAgICAgICBhcnRpZmFjdHNVVUlER3JvdXAsIHJlbGF0ZWRBcnRpZmFjdFRlbXBsYXRlSW5mbywgY3JlYXRlZEFydGlmYWN0cywgbGFiZWxDb3VudGVyLCBzaG91ZExvY2ssCi0gICAgICAgICAgICAgICAgICAgICAgICBpblRyYW5zYWN0aW9uKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGFydGlmYWN0c1VVSURHcm91cCwgcmVsYXRlZEFydGlmYWN0VGVtcGxhdGVJbmZvLCBjcmVhdGVkQXJ0aWZhY3RzLCBsYWJlbENvdW50ZXIpOwogICAgICAgICAgICAgICAgIGlmIChyZXNTdGF0dXMuaXNSaWdodCgpKSB7CiAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXNTdGF0dXM7CiAgICAgICAgICAgICAgICAgfQpAQCAtNzI0LDcgKzc5MCw3IEBACiAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKEFSVElGQUNUX1dJVEhfTkFNRV9BTkRfVFlQRV9BTFJFQURZX0VYSVNUX1dJVEhfVFlQRSwgYXJ0aWZhY3RGaWxlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgIGFydGlmYWN0VGVtcGxhdGVJbmZvLmdldFR5cGUoKSwgcmVzLmdldEFydGlmYWN0VHlwZSgpKTsKICAgICAgICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nSW50ZXJuYWxEYXRhRXJyb3IoCi0gICAgICAgICAgICAgICAgICAgICAgICBBUlRJRkFDVF9GSUxFX0lTX05PVF9JTl9FWFBFQ1RFRF9GT1JNQVRSX0ZJTEVfTkFNRTEgKyBhcnRpZmFjdEZpbGVOYW1lLAorICAgICAgICAgICAgICAgICAgICAgICAgQVJUSUZBQ1RfRklMRV9JU19OT1RfSU5fRVhQRUNURURfRk9STUFUX0ZJTEVfTkFNRSArIGFydGlmYWN0RmlsZU5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICBBUlRJRkFDVF9JTlRFUk5BTFNfQVJFX0lOVkFMSUQsIEVycm9yU2V2ZXJpdHkuRVJST1IpOwogICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQoY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KAogICAgICAgICAgICAgICAgICAgICAgICAgQWN0aW9uU3RhdHVzLkFSVElGQUNUX0FMUkVBRFlfRVhJU1RfSU5fRElGRkVSRU5UX1RZUEVfSU5fQ1NBUiwgYXJ0aWZhY3RGaWxlTmFtZSwKQEAgLTc0MSwxNiArODA3LDE2IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludCBsYWJlbCkgewogICAgICAgICBpbnQgdXBkYXRlZGxhYmVsID0gbGFiZWw7CiAgICAgICAgIGZpbmFsIFN0cmluZyBhcnRpZmFjdEZpbGVOYW1lID0gYXJ0aWZhY3RUZW1wbGF0ZUluZm8uZ2V0RmlsZU5hbWUoKTsKLSAgICAgICAgRWl0aGVyPEltbXV0YWJsZVBhaXI8U3RyaW5nLCBieXRlW10+LCBSZXNwb25zZUZvcm1hdD4gYXJ0aWZhY3RDb250ZW50ZW50U3RhdHVzID0gQ3NhclZhbGlkYXRpb25VdGlscwotICAgICAgICAgICAgICAgIC5nZXRBcnRpZmFjdHNDb250ZW50KGNzYXJJbmZvLmdldENzYXJVVUlEKCksIGNzYXJJbmZvLmdldENzYXIoKSwgYXJ0aWZhY3RQYXRoICsgYXJ0aWZhY3RGaWxlTmFtZSwKKyAgICAgICAgRWl0aGVyPEltbXV0YWJsZVBhaXI8U3RyaW5nLCBieXRlW10+LCBSZXNwb25zZUZvcm1hdD4gYXJ0aWZhY3RDb250ZW50U3RhdHVzID0gQ3NhclZhbGlkYXRpb25VdGlscworICAgICAgICAgICAgICAgIC5nZXRBcnRpZmFjd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SksIHVwZGF0ZWRSZXNvdXJjZSk7Ci0KLSAgICAgICAgICAgICAgICByZXNTdGF0dXMgPSBFaXRoZXIucmlnaHQocmVzcG9uc2VGb3JtYXQpOwotICAgICAgICAgICAgICAgIHJldHVybiByZXNTdGF0dXM7Ci0KLSAgICAgICAgICAgIH0KLQotICAgICAgICAgICAgdXBkYXRlZFJlc291cmNlID0gZWl0aGVyR2VyUmVzb3VyY2UubGVmdCgpLnZhbHVlKCk7CiAgICAgICAgICAgICBNYXA8U3RyaW5nLCBBcnRpZmFjdERlZmluaXRpb24+IGFydGlmYWN0cyA9IHVwZGF0ZWRSZXNvdXJjZS5nZXREZXBsb3ltZW50QXJ0aWZhY3RzKCk7CiAgICAgICAgICAgICBPcHRpb25hbDxBcnRpZmFjdERlZmluaXRpb24+IG9wID0gYXJ0aWZhY3RzLnZhbHVlcygpLnN0cmVhbSgpLmZpbHRlcigKICAgICAgICAgICAgICAgICAgICAgcCAtPiBwLmdldEdlbmVyYXRlZEZyb21JZCgpICE9IG51bGwgJiYgcC5nZXRHZW5lcmF0ZWRGcm9tSWQoKS5lcXVhbHMoY3VycmVudEluZm8uZ2V0VW5pcXVlSWQoKSkpCiAgICAgICAgICAgICAgICAgICAgIC5maW5kQW55KCk7CiAgICAgICAgICAgICBpZiAob3AuaXNQcmVzZW50KCkpIHsKICAgICAgICAgICAgICAgICBBcnRpZmFjdERlZmluaXRpb24gYXJ0aWZhY3RJbmZvSGVhdEVudiA9IG9wLmdldCgpOwotICAgICAgICAgICAgICAgIEVpdGhlcjxBcnRpZmFjdERlZmluaXRpb24sIFN0b3JhZ2VPcGVyYXRpb25TdGF0dXM+IHVwZGF0ZUFyaWZhY3RPblJlc291cmNlID0gYXJ0aWZhY3RUb3NjYU9wZXJhdGlvbgotICAgICAgICAgICAgICAgICAgICAgICAgLnVwZGF0ZUFydGlmYWN0T25SZXNvdXJjZShhcnRpZmFjdEluZm9IZWF0RW52LCB1cGRhdGVkUmVzb3VyY2UuZ2V0V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AgICAgICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tcG9uZW50c1V0aWxzLmNvbnZlcnRGcm9tU3RvcmFnZVJlc3BvbnNlKHVwZGF0ZUFyaWZhY3RPblJlc291cmNlLnJpZ2h0KCkudmFsdWUoKSkpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21wb25lbnRzVXRpbHMuY29udmVydEZyb21TdG9yYWdlUmVzcG9uc2UodXBkYXRlQXJ0aWZhY3RPblJlc291cmNlLnJpZ2h0KCkudmFsdWUoKSkpKTsKICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgcmVzU3RhdHVzID0gRWl0aGVyLmxlZnQodXBkYXRlQXJpZmFjdE9uUmVzb3VyY2UubGVmdCgpLnZhbHVlKCkpOworICAgICAgICAgICAgICAgIHJlc291cmNlLmdldERlcGxveW1lbnRBcnRpZmFjdHMoKS5wdXQodXBkYXRlQXJ0aWZhY3RPblJlc291cmNlLmxlZnQoKS52YWx1ZSgpLmdldEFydGlmYWN0TGFiZWwoKSwgdXBkYXRlQXJ0aWZhY3RPblJlc291cmNlLmxlZnQoKS52YWx1ZSgpKTsKKyAgICAgICAgICAgICAgICByZXNTdGF0dXMgPSBFaXRoZXIubGVmdCh1cGRhdGVBcnRpZmFjdE9uUmVzb3VyY2UubGVmdCgpLnZhbHVlKCkpOwogICAgICAgICAgICAgfQorCiAgICAgICAgIH0KICAgICAgICAgcmV0dXJuIHJlc1N0YXR1czsKICAgICB9CkBAIC05MDgsNDMgKzk1Nyw0MiBAQAogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KICAgICAgICAgICAgIGN1cnJlbnRJbmZvLnNldExpc3RIZWF0UGFyYW1ldGVycyhjdXJyZW50SGVhdEVudlBhcmFtcyk7Ci0gICAgICAgICAgICBFaXRoZXI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bWUoKS5lcXVhbHMoQ29uc3RhbnRzLkhFQVRfRklMRV9QUk9QUykpLmZpbmRBbnkoKTsKICAgICAgICAgaWYgKG9wLmlzUHJlc2VudCgpKSB7CkBAIC05NzQsMjIgKzEwMjEsMTYgQEAKICAgICAgICAgICAgIGZvciAoU3RyaW5nIGFydGlmYWN0SWQgOiBhcnRpZmFjdHNHcm91cCkgewogICAgICAgICAgICAgICAgIE9wdGlvbmFsPEFydGlmYWN0RGVmaW5pdGlvbj4gb3BBcnQgPSBjcmVhdGVkQXJ0aWZhY3RzLnN0cmVhbSgpCiAgICAgICAgICAgICAgICAgICAgICAgICAuZmlsdGVyKHAgLT4gcC5nZXRVbmlxdWVJZCgpLmVxdWFscyhhcnRpZmFjdElkKSkuZmluZEFueSgpOwotICAgICAgICAgICAgICAgIGlmIChvcEFydC5pc1ByZXNlbnQoKSkgewotICAgICAgICAgICAgICAgICAgICBhcnRpZmFjdHMuYWRkKG9wQXJ0LmdldCgpKTsKLSAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgb3BBcnQuaWZQcmVzZW50KGFydGlmYWN0czo6YWRkKTsKICAgICAgICAgICAgICAgICBpZiAoYXJ0aWZhY3RzRnJvbVJlc291cmNlICE9IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgb3BBcnQgPSBhcnRpZmFjdHNGcm9tUmVzb3VyY2Uuc3RyZWFtKCkuZmlsdGVyKHAgLT4gcC5nZXRVbmlxdWVJZCgpLmVxdWFscyhhcnRpZmFjdElkKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZmluZEFueSgpOwotICAgICAgICAgICAgICAgICAgICBpZiAob3BBcnQuaXNQcmVzZW50KCkpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGFydGlmYWN0cy5hZGQob3BBcnQuZ2V0KCkpOwotICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIG9wQXJ0LmlmUHJlc2VudChhcnRpZmFjdHM6OmFkZCk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VJbmZvIDogcmVsYXRlZEFydGlmYWN0cykgewogICAgICAgICAgICAgICAgIHJlc1N0YXR1cyA9IGNyZWF0ZURlcGxveW1lbnRBcnRpZmFjdHNGcm9tQ3Nhcihjc2FySW5mbywgcmVzb3VyY2UsIGFydGlmYWN0c0dyb3VwLCBhcnRpZmFjdHNVVUlER3JvdXAsCi0gICAgICAgICAgICAgICAgICAgICAgICByZWxhdGVkQXJ0aWZhY3RUZW1wbGF0ZUluZm8sIGNyZWF0ZWRBcnRpZmFjdHMsIGFydGlmYWN0c0Zyb21SZXNvdXJjZSwgbGFiZWxDb3VudGVyLCBzaG91ZExvY2ssCi0gICAgICAgICAgICAgICAgICAgICAgICBpblRyYW5zYWN0aW9uKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHJlbGF0ZWRBcnRpZmFjdFRlbXBsYXRlSW5mbywgY3JlYXRlZEFydGlmYWN0cywgYXJ0aWZhY3RzRnJvbVJlc291cmNlLCBsYWJlbENvdW50ZXIpOwogICAgICAgICAgICAgICAgIGlmIChyZXNTdGF0dXMuaXNSaWdodCgpKSB7CiAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXNTdGF0dXM7CiAgICAgICAgICAgICAgICAgfQpAQCAtMTQzNiwxMSArMTQ5MiwxMSBAQAogCiAgICAgcHJpdmF0ZSBFaXRoZXI8UmVzb3VyY2UsIFJlc3BvbnNlRm9ybWF0PiBhc3NvY2lhdGVBbmREaXNzb2NpYXRlQXJ0aWZhY3RzVG9Hcm91cChDc2FySW5mbyBjc2FySW5mbywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFJlc291cmNlIHJlc291cmNlLCBMaXN0PEFydGlmYWN0RGVmaW5pdGlvbj4gY3JlYXRlZE5ld0FydGlmYWN0cywgaW50IGxhYmVsQ291bnRlciwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2xlYW4gaW5UcmFuc2FjdGlvbiwgTGlzdDxBcnRpZmFjdERlZmluaXRpb24+IGNyZWF0ZWREZXBseW1lbnRBcnRpZmFjdHNBZnRlckRlbGV0ZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIExpc3Q8QXJ0aWZhY3REZWZpbml0aW9uPiBjcmVhdGVkRGVwbG95bWVudEFydGlmYWN0c0FmdGVyRGVsZXRlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTWFwPEdyb3VwRGVmaW5pdGlvbiwgTWVyZ2VkQXJ0aWZhY3RJbmZvPiBtZXJnZWRncm91cCwgTGlzdDxBcnRpZmFjdERlZmluaXRpb24+IGRlbGV0ZWRBcnRpZmFjdHMpIHsKICAgICAgICAgTWFwPEdyb3VwRGVmaW5pdGlvbiwgTGlzdDxBcnRpZmFjdFRlbXBsYXRlSW5mbz4+IGFydGlmYWN0c1RvQXNzb3RpYXRlID0gbmV3IEhhc2hNYXA8PigpOwogICAgICAgICBNYXA8R3JvdXBEZWZpbml0aW9uLCBMaXN0PEltbXV0YWJsZVBhaXI8QXJ0aWZhY3REZWZpbml0aW9uLCBBcnRpZmFjdFRlbXBsYXRlSW5mbz4+PiBhcnRpZmFjdHNUb1VwZGF0ZU1hcCA9IG5ldyBIYXNoTWFwPD4oKTsKLSAgICAgICAgRWl0aGVyPFJlc291cmNlLCBSZXNwb25zZUZvcm1hdD4gcmVzRWl0aGVyID0gRWl0aGVyLmxlZnQocmVzb3VyY2UpOworICAgICAgICBFaXRoZXI8UmVzb3VyY2UsIFJlc3BvbnNlRm9ybWF0PiByZXNFaXRoZXI7CiAgICAgICAgIGZvciAoRW50cnk8R3JvdXBEZ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AgICAgU3RyaW5nIGhlYXRFbnZJZCA9IGNoZWNrQW5kR2V0SGVhdEVudklkKGNyZWF0ZWRBcnRpZmFjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWhlYXRFbnZJZC5pc0VtcHR5KCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmlmYWN0c1VpZHMuYWRkKGhlYXRFbnZJZCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgT3B0aW9uYWw8QXJ0aWZhY3REZWZpbml0aW9uPiBvcCA9IGNyZWF0ZWREZXBseW1lbnRBcnRpZmFjdHNBZnRlckRlbGV0ZS5zdHJlYW0oKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIE9wdGlvbmFsPEFydGlmYWN0RGVmaW5pdGlvbj4gb3AgPSBjcmVhdGVkRGVwbG95bWVudEFydGlmYWN0c0FmdGVyRGVsZXRlLnN0cmVhbSgpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZmlsdGVyKHAgLT4gcC5nZXRVbmlxdWVJZCgpLmVxdWFscyhoZWF0RW52SWQpKS5maW5kQW55KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wLmlzUHJlc2VudCgpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYXJ0aWZhY3RUb3NjYU9wZXJhdGlvbi51cGRhdGVIZWF0RW52UGxhY2Vob2xkZXIob3AuZ2V0KCksIHJlc291cmNlLmdldFVuaXF1ZUlkKCksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYXJ0aWZhY3RUb3NjYU9wZXJhdGlvbi51cGRhdGVIZWF0RW52UGxhY2Vob2xkZXIob3AuZ2V0KCksIHJlc291cmNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc291cmNlLmdldENvbXBvbmVudFR5cGUoKS5nZXROb2RlVHlwZSgpKTsKIAogICAgICAg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AgICAgICAgICAgICAgICByZXNvdXJjZS5nZXRVbmlxdWVJZCgpLCBOb2RlVHlwZUVudW0uUmVzb3VyY2UsIHJlc291cmNlLmdldE5hbWUoKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjc2FySW5mby5nZXRNb2RpZmllcigpLCByZXNvdXJjZSwgbnVsbCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3JlYXRlSGVhdEVudlBsYWNlSG9sZGVyLmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQoY3JlYXRlSGVhdEVudlBsYWNlSG9sZGVyLnJpZ2h0KCkudmFsdWUoKSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmcgaGVhdEVudklkID0gY3JlYXRlSGVhdEVudlBsYWNlSG9sZGVyLmxlZnQoKS52YWx1ZSgpLmdldFVuaXF1ZUlkKCk7CisgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmcgaGVhdEVudklkID0gY3JlYXRlSGVhdEVudlBsYWNlSG9sZGVyLmdldFVuaXF1ZUlkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICBhcmlmYWN0c1VpZHMuYWRkKGhlYXRFbnZJZCk7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9CkBAIC0xNjI0LDcgKzE2NzcsNyBAQAogICAgICAgICAgICAgICAgICAgICBsb2cuZGVidWcoIkFydGlmYWN0IHdpdGggbmFtZSB7fSBhbmQgdHlwZSB7fSBhbHJlYWR5IHVwZGF0ZWQgd2l0aCB0eXBlICB7fSIsIGFydGlmYWN0RmlsZU5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJ0aWZhY3RUZW1wbGF0ZUluZm8uZ2V0VHlwZSgpLCB1cGRhdGVkQXJ0aWZhY3QuZ2V0QXJ0aWZhY3RUeXBlKCkpOwogICAgICAgICAgICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nSW50ZXJuYWxEYXRhRXJyb3IoCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgQVJUSUZBQ1RfRklMRV9JU19OT1RfSU5fRVhQRUNURURfRk9STUFUUl9GSUxFX05BTUUxICsgYXJ0aWZhY3RGaWxlTmFtZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBBUlRJRkFDVF9GSUxFX0lTX05PVF9JTl9FWFBFQ1RFRF9GT1JNQVRfRklMRV9OQU1FICsgYXJ0aWZhY3RGaWxlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBUlRJRkFDVF9JTlRFUk5BTFNfQVJFX0lOVkFMSUQsIEVycm9yU2V2ZXJpdHkuRVJST1IpOwogICAgICAgICAgICAgICAgICAgICByZXNTdGF0dXMgPSBFaXRoZXIucmlnaHQoY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFjdGlvblN0YXR1cy5BUlRJRkFDVF9BTFJFQURZX0VYSVNUX0lOX0RJRkZFUkVOVF9UWVBFX0lOX0NTQVIsIGFydGlmYWN0RmlsZU5hbWUsCkBAIC0xNjM4LDcgKzE2OTEsNyBAQAogICAgICAgICB9CiAKICAgICAgICAgRWl0aGVyPEltbXV0YWJsZVBhaXI8U3RyaW5nLCBieXRlW10+LCBSZXNwb25zZUZvcm1hdD4gYXJ0aWZhY3RDb250ZW50ZW50U3RhdHVzID0gQ3NhclZhbGlkYXRpb25VdGlscwotICAgICAgICAgICAgICAgIC5nZXRBcnRpZmFjdHNDb250ZW50KGNzYXJJbmZvLmdldENzYXJVVUlEKCksIGNzYXJJbmZvLmdldENzYXIoKSwKKyAgICAgICAgICAgICAgICAuZ2V0QXJ0aWZhY3RDb250ZW50KGNzYXJJbmZvLmdldENzYXJVVUlEKCksIGNzY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2FtYnJpYVRvcGljTWFuYWdlcjsKIGltcG9ydCBjb20uZ29vZ2xlLmNvbW1vbi5hbm5vdGF0aW9ucy5WaXNpYmxlRm9yVGVzdGluZzsKIGltcG9ydCBjb20uZ29vZ2xlLmdzb24uR3NvbjsKIGltcG9ydCBmai5kYXRhLkVpdGhlcjsKQEAgLTUzLDcgKzU5LDcgQEAKIGltcG9ydCBzdGF0aWMgamF2YS51dGlsLmNvbmN1cnJlbnQuVGltZVVuaXQuU0VDT05EUzsKIAogQENvbXBvbmVudCgiY2FtYnJpYUhhbmRsZXIiKQotcHVibGljIGNsYXNzIENhbWJyaWFIYW5kbGVyIHsKK3B1YmxpYyBjbGFzcyBDYW1icmlhSGFuZGxlciBpbXBsZW1lbnRzIElDYW1icmlhSGFuZGxlcnsKIAogICAgIHByaXZhdGUgc3RhdGljIGZpbmFsIExvZ2dlciBsb2cgPSBMb2dnZXIuZ2V0TG9nZ2VyKENhbWJyaWFIYW5kbGVyLmNsYXNzLmdldE5hbWUoKSk7CiAgICAgcHJpdmF0ZSBzdGF0aWMgZmluYWwgU3RyaW5nIFBBUlRJVElPTl9LRVkgPSAiYXNkYyIgKyAiYWEiOwpAQCAtNjIsNiArNjgsOSBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldERpc3RyaWJ1dGlvbkVuZ2luZUNvbmZpZ3VyYXRpb24oKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldERpc3RyaWJ1dGlvblN0YXR1c1RvcGljKCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRDb25zdW1lcklkKCk7CisgICAgcHJpdmF0ZSBzdGF0aWMgZmluYWwgYm9vbGVhbiBVU0VfSFRUUFNfV0lUSF9ETUFBUCA9IENvbmZpZ3VyYXRpb25NYW5hZ2VyLmdldENvbmZpZ3VyYXRpb25NYW5hZ2VyKCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldERpc3RyaWJ1dGlvbkVuZ2luZUNvbmZpZ3VyYXRpb24oKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuaXNVc2VIdHRwc1dpdGhEbWFhcCgpOwogICAgIHByaXZhdGUgZmluYWwgR3NvbiBnc29uID0gbmV3IEdzb24oKTsKIAogCkBAIC0xMTksMTIgKzEyOCwxMyBAQAogICAgICAqIEBwYXJhbSBob3N0U2V0CiAgICAgICogQHJldHVybgogICAgICAqLworICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBFaXRoZXI8U2V0PFN0cmluZz4sIENhbWJyaWFFcnJvclJlc3BvbnNlPiBnZXRUb3BpY3MoTGlzdDxTdHJpbmc+IGhvc3RTZXQpIHsKIAogICAgICAgICBDYW1icmlhVG9waWNNYW5hZ2VyIGNyZWF0ZVRvcGljTWFuYWdlciA9IG51bGw7CiAgICAgICAgIHRyeSB7CiAKLSAgICAgICAgICAgIGNyZWF0ZVRvcGljTWFuYWdlciA9IGJ1aWxkQ2FtYnJpYUNsaWVudChuZXcgVG9waWNNYW5hZ2VyQnVpbGRlcigpLnVzaW5nSG9zdHMoaG9zdFNldCkpOworICAgICAgICAgICAgY3JlYXRlVG9waWNNYW5hZ2VyID0gYnVpbGRDYW1icmlhQ2xpZW50KGNyZWF0ZVRvcGljTWFuYWdlckJ1aWxkZXIoaG9zdFNldCkpOwogCiAgICAgICAgICAgICBTZXQ8U3RyaW5nPiB0b3BpY3MgPSBjcmVhdGVUb3BpY01hbmFnZXIuZ2V0VG9waWNzKCk7CiAKQEAgLTI1MSwxNCArMjYxLDE1IEBACiAgICAgICogQHBhcmFtIHJlcGxpY2F0aW9uQ291bnQKICAgICAgKiBAcmV0dXJuCiAgICAgICovCisgICAgQE92ZXJyaWRlCiAgICAgcHVibGljIENhbWJyaWFFcnJvclJlc3BvbnNlIGNyZWF0ZVRvcGljKENvbGxlY3Rpb248U3RyaW5nPiBob3N0U2V0LCBTdHJpbmcgYXBpS2V5LCBTdHJpbmcgc2VjcmV0S2V5LCBTdHJpbmcgdG9waWNOYW1lLCBpbnQgcGFydGl0aW9uQ291bnQsIGludCByZXBsaWNhdGlvbkNvdW50KSB7CiAKICAgICAgICAgQ2FtYnJpYVRvcGljTWFuYWdlciBjcmVhdGVUb3BpY01hbmFnZXIgPSBudWxsOwogICAgICAgICB0cnkgewogCi0gICAgICAgICAgICBjcmVhdGVUb3BpY01hbmFnZXIgPSBidWlsZENhbWJyaWFDbGllbnQobmV3IFRvcGljTWFuYWdlckJ1aWxkZXIoKS51c2luZ0hvc3RzKGhvc3RTZXQpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5hdXRoZW50aWNhdGVkQnkoYXBpS2V5LCBzZWNyZXRLZXkpKTsKLQorICAgICAgICAgICAgQWJzdHJhY3RBdXRoZW50aWNhdGVkTWFuYWdlckJ1aWxkZXI8Q2FtYnJpYVRvcGljTWFuYWdlcj4gY2xpZW50QnVpbGRlciA9IGNyZWF0ZVRvcGljTWFuYWdlckJ1aWxkZXIoaG9zdFNldCwgYXBpS2V5LCBzZWNyZXRLZXkpOworICAgICAgICAgICAgY3JlYXRlVG9waWNNYW5hZ2VyID0gYnVpbGRDYW1icmlhQ2xpZW50KGNsaWVudEJ1aWxkZXIpOworICAgICAgICAgICAgCiAgICAgICAgICAgICBjcmVhdGVUb3BpY01hbmFnZXIuY3JlYXRlVG9waWModG9waWNOYW1lLCAiQVNEQyBkaXN0cmlidXRpb24gbm90aWZpY2F0aW9uIHRvcGljIiwgcGFydGl0aW9uQ291bnQsIHJlcGxpY2F0aW9uQ291bnQpOw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BvcEVudkVudHJ5LmdldFN0YXR1cygpLCBFbnZpcm9ubWVudHNFbmdpbmUuY2xhc3MuZ2V0TmFtZSgpLCBlcnJvcldyYXBwZXIudG9TdHJpbmcoKSApOwogICAgICAgICB0cnkgewogICAgICAgICAgICAgYm9vbGVhbiBpc0tleUZpZWxkc1ZhbGlkID0gIWlzRW1wdHkob3BFbnZFbnRyeS5nZXRUZW5hbnQoKSkgJiYgIWlzRW1wdHkob3BFbnZFbnRyeS5nZXRFY29tcFdvcmtsb2FkQ29udGV4dCgpKTsKICAgICAgICAgICAgIGlmIChpc0tleUZpZWxkc1ZhbGlkKSB7CiAgICAgICAgICAgICAgICAgU3RyaW5nIG9wRW52S2V5ID0gbWFwMk9wRW52S2V5KG9wRW52RW50cnkpOwotICAgICAgICAgICAgICAgIFN0cmluZyBlbnZpcm9ubWVudElkID0gb3BFbnZFbnRyeS5nZXRFbnZpcm9ubWVudElkKCk7Ci0gICAgICAgICAgICAgICAgTGlzdDxTdHJpbmc+IHVlYkhvc3RzID0gZGlzY292ZXJVZWJIb3N0cyhvcEVudktleSwgZW52aXJvbm1lbnRJZCk7CisgICAgICAgICAgICAgICAgTGlzdDxTdHJpbmc+IHVlYkhvc3RzID0gZGlzY292ZXJVZWJIb3N0cyhvcEVudktleSk7CiAgICAgICAgICAgICAgICAgb3BFbnZFbnRyeS5zZXREbWFhcFVlYkFkZHJlc3ModWViSG9zdHMuc3RyZWFtKCkuY29sbGVjdChDb2xsZWN0b3JzLnRvU2V0KCkpKTsKKyAgICAgICAgICAgICAgICBsb2cuaW52b2tlUmV0dXJuKG9wRW52RW50cnkuZ2V0RW52aXJvbm1lbnRJZCgpLCAicmV0cmlldmVVZWJBZGRyZXNzZXNGcm9tQWZ0RG1lIiwgb3BFbnZFbnRyeS5nZXRTdGF0dXMoKSwgIlNEQy1CRSIsIGVycm9yV3JhcHBlci50b1N0cmluZygpICk7CiAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgIGVycm9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kYy9iZS9jb21wb25lbnRzL2Rpc3RyaWJ1dGlvbi9lbmdpbmUvSUNhbWJyaWFIYW5kbGVyLmphdmEKQEAgLTAsMCArMSw0NSBAQAorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDIwIEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgorICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0CisgKgorICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKKyAqCisgKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlCisgKiBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0cmlidXRlZCBvbiBhbiAiQVMgSVMiIEJBU0lTLAorICogV0lUSE9VVCBXQVJSQU5USUVTIE9SIENPTkRJVElPTlMgT0YgQU5ZIEtJTkQsIGVpdGhlciBleHByZXNzIG9yIGlt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aGVja01hcCA9IG1hcHBlci5yZWFkVmFsdWUocmVzcG9uc2UsIG5ldyBUeXBlUmVmZXJlbmNlPE1hcDxTdHJpbmcsIE9iamVjdD4+KCkgewogICAgICAgICAgICAgICAgICAgICB9KTsKLSAgICAgICAgICAgICAgICAgICAgdmVyc2lvbiA9IGhlYWx0aENoZWNrTWFwLmdldCgic2RjVmVyc2lvbiIpICE9IG51bGwgPyBoZWFsdGhDaGVja01hcC5nZXQoInNkY1ZlcnNpb24iKS50b1N0cmluZygpIDogbnVsbDsKKyAgICAgICAgICAgICAgICAgICAgdmVyc2lvbiA9IGdldFZlcnNpb24oaGVhbHRoQ2hlY2tNYXApOwogICAgICAgICAgICAgICAgICAgICBpZiAoaGVhbHRoQ2hlY2tNYXAuY29udGFpbnNLZXkoImNvbXBvbmVudHNJbmZvIikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBvbmVudHNJbmZvID0gbWFwcGVyLmNvbnZlcnRWYWx1ZShoZWFsdGhDaGVja01hcC5nZXQoImNvbXBvbmVudHNJbmZvIiksIG5ldyBUeXBlUmVmZXJlbmNlPExpc3Q8SGVhbHRoQ2hlY2tJbmZvPj4oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgfQotCi0gICAgICAgICAgICAgICAgICAgIGlmICghY29tcG9uZW50c0luZm8uaXNFbXB0eSgpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBhZ2dEZXNjcmlwdGlvbiA9IGhlYWx0aENoZWNrVXRpbC5nZXRBZ2dyZWdhdGVEZXNjcmlwdGlvbihjb21wb25lbnRzSW5mbywgbnVsbCk7Ci0gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBjb21wb25lbnRzSW5mby5hZGQobmV3IEhlYWx0aENoZWNrSW5mbyhIQ19DT01QT05FTlRfQkUsIERPV04sIG51bGwsIG51bGwpKTsKLSAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICBhZ2dEZXNjcmlwdGlvbiA9IGdldEFnZ0Rlc2NyaXB0aW9uKGNvbXBvbmVudHNJbmZvLCBhZ2dEZXNjcmlwdGlvbik7CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgbG9nLnRyYWNlKCJ7fSBIZWFsdGggQ2hlY2sgUmVzcG9uc2UgY29kZToge30iLCBjb21wb25lbnROYW1lLCBzdGF0dXNDb2RlKTsKICAgICAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgICAgICBpZiAoc3RhdHVzQ29kZSAhPSBTQ19PSykgewogICAgICAgICAgICAgICAgICAgICBoZWFsdGhDaGVja1N0YXR1cyA9IERPV047Ci0gICAgICAgICAgICAgICAgICAgIGRlc2NyaXB0aW9uID0gYWdnRGVzY3JpcHRpb24ubGVuZ3RoKCkgPiAwCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgPyBhZ2dEZXNjcmlwdGlvbgotICAgICAgICAgICAgICAgICAgICAgICAgICAgIDogY29tcG9uZW50TmFtZSArICIgaXMgRG93biwgc3BlY2lmaWMgcmVhc29uIHVua25vd24iOy8vTm8gaW5uZXIgY29tcG9uZW50IHJldHVybmVkIERPV04sIGJ1dCB0aGUgc3RhdHVzIG9mIEhDIGlzIHN0aWxsIERPV04uCi0gICAgICAgICAgICAgICAgICAgIGlmIChjb21wb25lbnRzSW5mby5pc0VtcHR5KCkpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBvbmVudHNJbmZvLmFkZChuZXcgSGVhbHRoQ2hlY2tJbmZvKEhDX0NPTVBPTkVOVF9CRSwgRE9XTiwgbnVsbCwgZGVzY3JpcHRpb24pKTsKLSAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICBkZXNjcmlwdGlvbiA9IGdldERlc2NyaXB0aW9uKGNvbXBvbmVudE5hbWUsIGFnZ0Rlc2NyaXB0aW9uKTsKKyAgICAgICAgICAgICAgICAgICAgc2V0RGVzY3JpcHRpb25Ub09iamVjdChkZXNjcmlwdGlvbiwgY29tcG9uZW50c0luZm8pOwogICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgIGhlYWx0aENoZWNrU3RhdHVzID0gVVA7CiAgICAgICAgICAgICAgICAgICAgIGRlc2NyaXB0aW9uID0gIk9LIjsKQEAgLTMxNSwxOSArMjk0LDQ5IEBACiAgICAgICAgICAgICAgICAgbG9nLmVycm9yKCJ7fSB1bmV4cGVjdGVkIHJlc3BvbnNlOiAiLCBjb21wb25lbnROYW1lLCBlKTsKICAgICAgICAgICAgICAgICBoZWFsdGhDaGVja1N0YXR1cyA9IERPV047CiAgICAgICAgICAgICAgICAgZGVzY3JpcHRpb24gPSBjb21wb25lbnROYW1lICsgIiB1bmV4cGVjdGVkIHJlc3BvbnNlOiAiICsgZS5nZXRNZXNzYWdlKCk7Ci0gICAgICAgICAgICAgICAgaWYgKGNvbXBvbmVudHNJbmZvICE9IG51bGwgJiYgY29tcG9uZW50c0luZm8uaXNFbXB0eSgpKSB7Ci0gICAgICAgICAgICAgICAgICAgIGNvbXBvbmVudHNJbmZvLmFkZChuZXcgSGVhbHRoQ2hlY2tJbmZvKEhDX0NPTVBPTkVOVF9CRSwgRE9XTiwgbnVsbCwgZGVzY3JpcHRpb24pKTsKLSAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgYWRkVG9IZWFsdGhDaGVja0luZm9PYmplY3QoZGVzY3JpcHRpb24sIGNvbXBvbmVudHNJbmZvKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIGhlYWx0aENoZWNrU3RhdHVzID0gRE9XTjsKICAgICAgICAgICAgIGRlc2NyaXB0aW9uID0gY29tcG9uZW50TmFtZSArICIgaGVhbHRoIGNoZWNrIENvbmZpZ3VyYXRpb24gaXMgbWlzc2luZyI7CiAgICAgICAgICAgICBjb21wb25lbnRzSW5mby5hZGQobmV3IEhlYWx0aENoZWNrSW5mbyhIQ19DT01QT05FTlRfQkUsIERPV04sIG51bGwsIGRlc2NyaXB0aW9uKSk7CiAgICAgICAgIH0KLQogICAgICAgICByZXR1cm4gbmV3IEhlYWx0aENoZWNrSW5mbyhjb21wb25lbnROYW1lLCBoZWFsdGhDaGVja1N0YXR1cywgdmVyc2lvbiwgZGVzY3JpcHRpb24sIGNvbXBvbmVudHNJbmZvKTsKICAgICB9CiAKKyAgICBwcml2YXRlIHZvaWQgYWRkVG9IZWFsdGhDaGVja0luZm9PYmplY3QoU3RyaW5nIGRlc2NyaXB0aW9uLCBMaXN0PEhlYWx0aENoZWNrSW5mbz4gY29tcG9uZW50c0luZm8pIHsKKyAgICAgICAgaWYgKGNvbXBvbmVudHNJbmZvICE9IG51bGwgJiYgY29tcG9uZW50c0luZm8uaXNFbXB0eSgpKSB7CisgICAgICAgICAgICBjb21wb25lbnRzSW5mby5hZGQobmV3IEhlYWx0aENoZWNrSW5mbyhIQ19DT01QT05FTlRfQkUsIERPV04sIG51bGwsIGRlc2NyaXB0aW9uKSk7CisgICAgICAgIH0KKyAgICB9CisKKyAgICBwcml2YXRlIHZvaWQgc2V0RGVzY3JpcHRpb25Ub09iamVjdChTdHJpbmcgZGVzY3JpcHRpb24sIExpc3Q8SGVhbHRoQ2hlY2tJbmZvPiBjb21wb25lbnRzSW5mbykgeworICAgICAgICBpZiAoY29tcG9uZW50c0luZm8uaXNFbXB0eSgpKSB7CisgICAgICAgICAgICBjb21wb25lbnRzSW5mby5hZGQobmV3IEhlYWx0aENoZWNrSW5mbyhIQ19DT01QT05FTlRfQkUsIERPV04sIG51bGwsIGRlc2NyaXB0aW9uKSk7CisgICAgICAgIH0KKyAgICB9CisKKyAgICBwcml2YXRlIFN0cmluZyBnZXREZXNjcmlwdGlvbihTdHJpbmcgY29tcG9uZW50TmFtZSwgU3RyaW5nIGFnZ0Rlc2NyaXB0aW9uKSB7CisgICAgICAgIFN0cmlu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GVzY3JpcHRpb247CisgICAgfQorCiAgICAgQFByZURlc3Ryb3kKICAgICBwcm90ZWN0ZWQgdm9pZCBkZXN0cm95KCkgewogCkBAIC0zNjQsOTIgKzM3Myw5MyBAQAogICAgICAgICAgICAgICAgIGludCBwcmV2U2l6ZSA9IHByZXZWYWx1ZXMuc2l6ZSgpOwogCiAgICAgICAgICAgICAgICAgaWYgKGN1cnJlbnRTaXplICE9IHByZXZTaXplKSB7Ci0KICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gdHJ1ZTsgLy9leHRyYS9taXNzaW5nIGNvbXBvbmVudAotCi0gICAgICAgICAgICAgICAgICAgIE1hcDxTdHJpbmcsIEhlYWx0aENoZWNrU3RhdHVzPiBub3RQcmVzZW50ID0gbnVsbDsKLSAgICAgICAgICAgICAgICAgICAgaWYgKGN1cnJlbnRWYWx1ZXMua2V5U2V0KCkuY29udGFpbnNBbGwocHJldlZhbHVlcy5rZXlTZXQoKSkpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIG5vdFByZXNlbnQgPSBuZXcgSGFzaE1hcDw+KGN1cnJlbnRWYWx1ZXMpOwotICAgICAgICAgICAgICAgICAgICAgICAgbm90UHJlc2VudC5rZXlTZXQoKS5yZW1vdmVBbGwocHJldlZhbHVlcy5rZXlTZXQoKSk7Ci0gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBub3RQcmVzZW50ID0gbmV3IEhhc2hNYXA8PihwcmV2VmFsdWVzKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIG5vdFByZXNlbnQua2V5U2V0KCkucmVtb3ZlQWxsKGN1cnJlbnRWYWx1ZXMua2V5U2V0KCkpOwotICAgICAgICAgICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgICAgICAgICAgZm9yIChTdHJpbmcgY29tcG9uZW50IDogbm90UHJlc2VudC5rZXlTZXQoKSkgewotICAgICAgICAgICAgICAgICAgICAgICAgbG9nQWxhcm0oZm9ybWF0KENPTVBPTkVOVF9DSEFOR0VEX01FU1NBR0UsIGNvbXBvbmVudCwgcHJldlZhbHVlcy5nZXQoY29tcG9uZW50KSwgY3VycmVudFZhbHVlcy5nZXQoY29tcG9uZW50KSkpOwotICAgICAgICAgICAgICAgICAgICB9Ci0KKyAgICAgICAgICAgICAgICAgICAgdXBkYXRlSGVhbHRoQ2hlY2tTdGF0dXNNYXAoY3VycmVudFZhbHVlcywgcHJldlZhbHVlcyk7CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKLQotICAgICAgICAgICAgICAgICAgICBmb3IgKEVudHJ5PFN0cmluZywgSGVhbHRoQ2hlY2tTdGF0dXM+IGVudHJ5IDogY3VycmVudFZhbHVlcy5lbnRyeVNldCgpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmcga2V5ID0gZW50cnkuZ2V0S2V5KCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBIZWFsdGhDaGVja1N0YXR1cyB2YWx1ZSA9IGVudHJ5LmdldFZhbHVlKCk7Ci0KLSAgICAgICAgICAgICAgICAgICAgICAgIGlmICghcHJldlZhbHVlcy5jb250YWluc0tleShrZXkpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gdHJ1ZTsgLy9jb21wb25lbnQgbWlzc2luZwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvZ0FsYXJtKGZvcm1hdChDT01QT05FTlRfQ0hBTkdFRF9NRVNTQUdFLCBrZXksIHByZXZWYWx1ZXMuZ2V0KGtleSksIGN1cnJlbnRWYWx1ZXMuZ2V0KGtleSkpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICAgICAgICAgIH0KLQotICAgICAgICAgICAgICAgICAgICAgICAgSGVhbHRoQ2hlY2tTdGF0dXMgcHJldkhlYWx0aENoZWNrU3RhdHVzID0gcHJldlZhbHVlcy5nZXQoa2V5KTsKLQotICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlICE9IHByZXZIZWFsdGhDaGVja1N0YXR1cykgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCA9IHRydWU7IC8vY29tcG9uZW50IHN0YXR1cyBjaGFuZ2VkCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9nQWxhcm0oZm9ybWF0KENPTVBPTkVOVF9DSEFOR0VEX01FU1NBR0UsIGtleSwgcHJldlZhbHVlcy5nZXQoa2V5KSwgY3VycmVudFZhbHVlcy5nZXQoa2V5KSkpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIHJlc3VsdCA9IGlzSGVhbHRoU3RhdHVzQ2hhbmdlZChyZXN1bHQsIGN1cnJlbnRWYWx1ZXMsIHByZXZWYWx1ZXMpOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KIAogICAgICAgICB9IGVsc2UgaWYgKGJlSGVhbHRoQ2hlY2tJbmZvcyA9PSBudWxsICYmIHByZXZCZUhlYWx0aENoZWNrSW5mb3MgPT0gbnVsbCkgewogICAgICAgICAgICAgcmVzdWx0ID0gZmFsc2U7CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICBsb2dBbGFybShmb3JtYXQoQ09NUE9ORU5UX0NIQU5HRURfTUVTU0FHRSwgIiIsIHByZXZCZUhlYWx0aENoZWNrSW5mb3MgPT0gbnVsbCA/ICJudWxsIiA6ICJ0cnVlIiwgcHJldkJlSGVhbHRoQ2hlY2tJbmZvcyA9PSBudWxsID8gInRydWUiIDogIm51bGwiKSk7CisgICAgICAgICAgICB3cml0ZUxvZ0FsYXJtKHByZXZCZUhlYWx0aENoZWNrSW5mb3MpOwogICAgICAgICAgICAgcmVzdWx0ID0gdHJ1ZTsKICAgICAgICAgfQogCiAgICAgICAgIHJldHVybiBy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aW5nQ29uZmlnICE9IG51bGwpIHsKLSAgICAgICAgICAgIFN0cmluZyBwcm90b2NvbCA9IG9uYm9hcmRpbmdDb25maWcuZ2V0UHJvdG9jb2woKTsKLSAgICAgICAgICAgIFN0cmluZyBob3N0ID0gb25ib2FyZGluZ0NvbmZpZy5nZXRIb3N0KCk7Ci0gICAgICAgICAgICBJbnRlZ2VyIHBvcnQgPSBvbmJvYXJkaW5nQ29uZmlnLmdldFBvcnQoKTsKLSAgICAgICAgICAgIFN0cmluZyB1cmkgPSBvbmJvYXJkaW5nQ29uZmlnLmdldEhlYWx0aENoZWNrVXJpKCk7CisgICAgICAgICAgICBpZiAoIXByZXZWYWx1ZXMuY29udGFpbnNLZXkoa2V5KSkgeworICAgICAgICAgICAgICAgIHJlc3VsdCA9IHRydWU7IC8vY29tcG9uZW50IG1pc3NpbmcKKyAgICAgICAgICAgICAgICBsb2dBbGFybShmb3JtYXQoQ09NUE9ORU5UX0NIQU5HRURfTUVTU0FHRSwga2V5LCBwcmV2VmFsdWVzLmdldChrZXkpLCBjdXJyZW50VmFsdWVzLmdldChrZXkpKSk7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgIHJldHVybiBwcm90b2NvbCArICI6Ly8iICsgaG9zdCArICI6IiArIHBvcnQgKyB1cmk7CisgICAgICAgICAgICBIZWFsdGhDaGVja1N0YXR1cyBwcmV2SGVhbHRoQ2hlY2tTdGF0dXMgPSBwcmV2VmFsdWVzLmdldChrZXkpOworCisgICAgICAgICAgICBpZiAodmFsdWUgIT0gcHJldkhlYWx0aENoZWNrU3RhdHVzKSB7CisgICAgICAgICAgICAgICAgcmVzdWx0ID0gdHJ1ZTsgLy9jb21wb25lbnQgc3RhdHVzIGNoYW5nZWQKKyAgICAgICAgICAgICAgICBsb2dBbGFybShmb3JtYXQoQ09NUE9ORU5UX0NIQU5HRURfTUVTU0FHRSwga2V5LCBwcmV2VmFsdWVzLmdldChrZXkpLCBjdXJyZW50VmFsdWVzLmdldChrZXkpKSk7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICAgICAgcmV0dXJuIHJlc3VsdDsKKyAgICB9CisKKyAgICBwcml2YXRlIHZvaWQgdXBkYXRlSGVhbHRoQ2hlY2tTdGF0dXNNYXAoTWFwPFN0cmluZywgSGVhbHRoQ2hlY2tTdGF0dXM+IGN1cnJlbnRWYWx1ZXMsIE1hcDxTdHJpbmcsIEhlYWx0aENoZWNrU3RhdHVzPiBwcmV2VmFsdWVzKSB7CisgICAgICAgIE1hcDxTdHJpbmcsIEhlYWx0aENoZWNrU3RhdHVzPiBub3RQcmVzZW50OworICAgICAgICBpZiAoY3VycmVudFZhbHVlcy5rZXlTZXQoKS5jb250YWluc0FsbChwcmV2VmFsdWVzLmtleVNldCgpKSkgeworICAgICAgICAgICAgbm90UHJlc2VudCA9IG5ldyBIYXNoTWFwPD4oY3VycmVudFZhbHVlcyk7CisgICAgICAgICAgICBub3RQcmVzZW50LmtleVNldCgpLnJlbW92ZUFsbChwcmV2VmFsdWVzLmtleVNldCgpKTsKKyAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgIG5vdFByZXNlbnQgPSBuZXcgSGFzaE1hcDw+KHByZXZWYWx1ZXMpOworICAgICAgICAgICAgbm90UHJlc2VudC5rZXlTZXQoKS5yZW1vdmVBbGwoY3VycmVudFZhbHVlcy5rZXlTZXQoKSk7CiAgICAgICAgIH0KIAotICAgICAgICBsb2cuZXJyb3IoIm9uYm9hcmRpbmcgaGVhbHRoIGNoZWNrIGNvbmZpZ3VyYXRpb24gaXMgbWlzc2luZy4iKTsKKyAgICAgICAgZm9yIChTdHJpbmcgY29tcG9uZW50IDogbm90UHJlc2VudC5rZXlTZXQoKSkgeworICAgICAgICAgICAgbG9nQWxhcm0oZm9ybWF0KENPTVBPTkVOVF9DSEFOR0VEX01FU1NBR0UsIGNvbXBvbmVudCwgcHJldlZhbHVl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ZmlnICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICAgICAgdGhpcy5oZWFsdGhDaGVja1JlYWRUaW1lb3V0ID0gaGVhbHRoQ2hlY2tSZWFkVGltZW91dENvbmZpZzsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgdGhpcy5oZWFsdGhDaGVja1NjaGVkdWxlZFRhc2sgPSBuZXcgSGVhbHRoQ2hlY2tTY2hlZHVsZWRUYXNrKGNvbmZpZ3VyYXRpb24pOworICAgICAgICAgICAgICAgIHN0YXJ0SGVhbHRoQ2hlY2tUYXNrKHRydWUpOworICAgICAgICAgICAgfQorICAgICAgICAgICAgZWxzZSB7CisgICAgICAgICAgICAgICAgbG9nLmVycm9yKCJFQ09NUCBQb3J0YWwgaGVhbHRoIGNoZWNrIGNvbmZpZ3VyYXRpb24gaXMgbWlzc2luZy4iKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgICAgICBsb2cudHJhY2UoIkV4aXQgaW5pdCBtZXRob2Qgb2YgUG9ydGFsIGhlYWx0aGNoZWNrIik7CisgICAgICAgIHJldHVybiB0aGlzOworICAgIH0KKworICAgIEBQb3N0Q29uc3RydWN0CisgICAgcHVibGljIFBvcnRhbEhlYWx0aENoZWNrQnVpbGRlciBpbml0KCkgdGhyb3dzIENpcGhlclV0aWxFeGNlcHRpb24geworICAgICAgICByZXR1cm4gaW5pdChDb25maWd1cmF0aW9uTWFuYWdlci5nZXRDb25maWd1cmF0aW9uTWFuYWdlcigpLmdldENvbmZpZ3VyYXRpb24oKS5nZXRFY29tcFBvcnRhbCgpKTsKKyAgICB9CisKKworICAgIEBQcmVEZXN0cm95CisgICAgcHJvdGVjdGVkIHZvaWQgZGVzdHJveSgpIHsKKyAgICAgICAgaWYgKHNjaGVkdWxlZEZ1dHVyZSAhPSBudWxsKSB7CisgICAgICAgICAgICBzY2hlZHVsZWRGdXR1cmUuY2FuY2VsKHRydWUpOworICAgICAgICAgICAgc2NoZWR1bGVkRnV0dXJlID0gbnVsbDsKKyAgICAgICAgfQorICAgICAgICBpZiAoc2NoZWR1bGVyICE9IG51bGwpIHsKKyAgICAgICAgICAgIHNjaGVkdWxlci5zaHV0ZG93bigpOworICAgICAgICB9CisgICAgfQorCisgICAgLyoqCisgICAgICogU3RhcnQgaGVhbHRoIGNoZWNrIHRhc2suCisgICAgICoKKyAgICAgKiBAcGFyYW0gc3RhcnRUYXNrCisgICAgICovCisgICAgcHJpdmF0ZSB2b2lkIHN0YXJ0SGVhbHRoQ2hlY2tUYXNrKGJvb2xlYW4gc3RhcnRUYXNrKSB7CisgICAgICAgIHN5bmNocm9uaXplZCAoUG9ydGFsSGVhbHRoQ2hlY2tCdWlsZGVyLmNsYXNzKXsKKyAgICAgICAgICAgIGlmIChzdGFydFRhc2sgJiYgdGhpcy5zY2hlZHVsZWRGdXR1cmUgPT0gbnVsbCkgeworICAgICAgICAgICAgICAgIHRoaXMuc2NoZWR1bGVkRnV0dXJlID0gdGhpcy5zY2hlZHVsZXIuc2NoZWR1bGVBdEZpeGVkUmF0ZSh0aGlzLmhlYWx0aENoZWNrU2NoZWR1bGVkVGFzayAsIDAsIHJlY29ubmVjdEludGVydmFsLCBUaW1lVW5pdC5TRUNPTkRTKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgIH0KKworICAgIEBWaXNpYmxlRm9yVGVzdGluZworICAgIHZvaWQgcnVuVGFzaygpIHsKKyAgICAgICAgaGVhbHRoQ2hlY2tTY2hlZHVsZWRUYXNrLnJ1bigpOworICAgIH0KKworICAgIHB1YmxpYyBIZWFsdGhDaGVja0luZm8gZ2V0SGVhbHRoQ2hlY2tJbmZvKCkgeworICAgICAgICByZXR1cm4gaGVhbHRoQ2hlY2tJbmZvOworICAgIH0KKworICAgIC8qKgorICAgICAqIEhlYWx0aCBDaGVjayBUYXNrIFNjaGVkdWxlciAtIGluZmluaXRlIGNoZWNrLgorICAgICAqLworICAgIHB1YmxpYyBjbGFzcyBIZWFsdGhDaGVja1NjaGVkdWxlZFRhc2sgaW1wbGVtZW50cyBSdW5uYWJsZSB7CisgICAgICAgIHByaXZhdGUgZmluYWwgRWNvbXBQb3J0YWxDb25maWcgY29uZmlnOworICAgICAgICBTdHJpbmcgaGVhbHRoQ2hlY2tVcmwgPSBidWlsZFBvcnRhbEhlYWx0aENoZWNrVXJsKCk7CisgICAgICAgIEhlYWx0aENoZWNrU3RhdHVzIGhlYWx0aENoZWNrU3RhdHVzID0gRE9XTjsKKyAgICAgICAgU3RyaW5nIGNvbXBvbmVudE5hbWUgPSBIQ19DT01QT05FTlRfRUNPTVBfUE9SVEFMOworICAgICAgICBTdHJpbmcgZGVzY3JpcHRpb247CisgICAgICAgIGZpbmFsIGludCB0aW1lb3V0ID0gMzAwMDsKKworICAgICAgICBIZWFsdGhDaGVja1NjaGVkdWxlZFRhc2soZmluYWwgRWNvbXBQb3J0YWxDb25maWcgY29uZmlnKXsKKyAgICAgICAgICAgIHRoaXMuY29uZmlnID0gY29uZmlnOworICAgICAgICB9CisgICAgICAgIEBPdmVycmlkZQorICAgICAgICBwdWJsaWMgdm9pZCBydW4oKSB7CisgICAgICAgICAgICBpZiAoaGVhbHRoQ2hlY2tVcmwgIT0gbnVsbCkgeworICAgICAgICAgICAgICAgIHRyeSB7CisgICAgICAgICAgICAgICAgICAgIGludCBzdGF0dXNDb2RlID0gZ2V0U3RhdHVzQ29kZShoZWFsdGhDaGVja1VybCwgdGltZW91dCk7CisgICAgICAgICAgICAgICAgICAgIGxvZy50cmFjZSgie30gSGVhbHRoIENoZWNrIHJlc3BvbnNlIGNvZGU6IHt9IiwgY29tcG9uZW50TmFtZSwgc3RhdHVzQ29kZSk7CisgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0dXNDb2RlICE9IFNDX09LKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBkZXNjcmlwdGlvbiA9IFN0cmluZy5mb3JtYXQoUE9SVEFMX0VSUk9SLCBzdGF0dXNDb2RlKTsKKyAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGhlYWx0aENoZWNrU3RhdHVzID0gVVA7CisgICAgICAgICAgICAgICAgICAgICAgICBkZXNjcmlwdGlvbiA9ICJPSyI7CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZSkgeworICAgICAgICAgICAgICAgICAgICBsb2cuZXJyb3IoInt9IGlzIG5vdCBhdmFpbGFibGU6ICIsIGNvbXBvbmVudE5hbWUsIGUuZ2V0TWVzc2FnZSgpKTsKKyAgICAgICAgICAgICAgICAgICAgZGVzY3JpcHRpb24gPSBQT1JUQUxfTk9UX0FWQUlMQUJMRTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgIGRlc2NyaXB0aW9uID0gQ09ORklHX0lTX01JU1NJTkc7CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIGhlYWx0aENoZWNrSW5mby5zZXRIZWFsdGhDaGVja1N0YXR1cyhoZWFsdGhDaGVja1N0YXR1cyk7CisgICAgICAgICAgICBoZWFsdGhDaGVja0luZm8uc2V0RGVzY3JpcHRpb24oZGVzY3JpcHRpb24pOworICAgICAgICB9CisgICAgfQorCisgICAgcHJpdmF0ZSBzdGF0aWMgU3RyaW5nIGdldFBvcnRhbFByb3BlcnR5KFN0cmluZyBrZXkpIHsKKyAgICAgICAgU3RyaW5nIHZhbHVlID0gUG9ydGFsQXBpUHJvcGVydGllcy5nZXRQcm9wZXJ0eShrZXkpOworICAgICAgICBpZiAoU3RyaW5nVXRpbHMuaXNFbXB0eSh2YWx1ZSkpIHsKKyAgICAgICAgICAgIHRocm93IG5ldyBJbnZhbGlkUGFyYW1ldGVyRXhjZXB0aW9uKFN0cmluZy5mb3JtYXQoUFJPUEVSVFlfTk9UX1NFVCwga2V5KSk7CisgICAgICAgIH0KKyAgICAgICAgcmV0dXJuIHZhbHVlOworIC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gICAgIC5nZXRCeXRlcygpKTsKKyAgICAgICAgaGVhZGVycy5wdXQoSHR0cEhlYWRlcnMuQUNDRVBULCBNZWRpYVR5cGUuQVBQTElDQVRJT05fSlNPTik7CisgICAgICAgIGhlYWRlcnMucHV0KEh0dHBIZWFkZXJzLkNPTlRFTlRfVFlQRSwgTWVkaWFUeXBlLkFQUExJQ0FUSU9OX0pTT04pOworICAgICAgICBoZWFkZXJzLnB1dChDb25zdGFudHMuWF9UUkFOU0FDVElPTl9JRF9IRUFERVIsIFVVSUQucmFuZG9tVVVJRCgpLnRvU3RyaW5nKCkpOworICAgICAgICBoZWFkZXJzLnB1dCgiQXV0aG9yaXphdGlvbiIsICJCYXNpYyAiICsgZW5jb2RlZEJhc2ljQXV0aENyZWQpOworICAgICAgICBoZWFkZXJzLnB1dCgiY2FjaGUtY29udHJvbCIsICJuby1jYWNoZSIpOworICAgICAgICBoZWFkZXJzLnB1dCgidWVia2V5IiwgUG9ydGFsQXBpUHJvcGVydGllcy5nZXRQcm9wZXJ0eSgidWViX2FwcF9rZXkiKSk7CisgICAgICAgIHJldHVybiBoZWFkZXJzOworICAgIH0KKworICAgIGludCBnZXRTdGF0dXNDb2RlKFN0cmluZyBoZWFsdGhDaGVja1VybCwgaW50IHRpbWVvdXQpIHRocm93cyBIdHRwRXhlY3V0ZUV4Y2VwdGlvbiB7CisgICAgICAgIEh0dHBSZXNwb25zZTxTdHJpbmc+IGh0dHBSZXNwb25zZSA9IEh0dHBSZXF1ZXN0LmdldChoZWFsdGhDaGVja1VybCwgY3JlYXRlSGVhZGVycygpLCBuZXcgSHR0cENsaWVudENvbmZpZyhuZXcgVGltZW91dHModGltZW91dCwgdGltZW91dCkpKTsKKyAgICAgICAgcmV0dXJuIGh0dHBSZXNwb25zZS5nZXRTdGF0dXNDb2RlKCk7CisgICAgfQorCisgICAgQFZpc2libGVGb3JUZXN0aW5nCisgICAgcHVibGljIEVjb21wUG9ydGFsQ29uZmlnIGdldENvbmZpZ3VyYX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lmYWN0RGVmaW5pdGlvbiBhcnRpZmFjdEluZm8sCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZyBvcmlnTWQ1LCBTdHJpbmcgb3JpZ2luRGF0YSwgU3RyaW5nIGludGVyZmFjZVV1aWQsIFN0cmluZyBvcGVyYXRpb25VdWlkLCBTdHJpbmcgcGFyZW50SWQsIFN0cmluZyBjb250YWluZXJDb21wb25lbnRUeXBlLCBib29sZWFuIHNob3VsZExvY2ssIGJvb2xlYW4gaW5UcmFuc2FjdGlvbikgeworICAgIHB1YmxpYyBFaXRoZXI8QXJ0aWZhY3REZWZpbml0aW9uLCBPcGVyYXRpb24+IGhhbmRsZUFydGlmYWN0UmVxdWVzdChTdHJpbmcgY29tcG9uZW50SWQsIFN0cmluZyB1c2VySWQsIENvbXBvbmVudFR5cGVFbnVtIGNvbXBvbmVudFR5cGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFydGlmYWN0T3BlcmF0aW9uSW5mbyBvcGVyYXRpb24sIFN0cmluZyBhcnRpZmFjdElkLCBBcnRpZmFjdERlZmluaXRpb24gYXJ0aWZhY3RJbmZvLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmcgb3JpZ01kNSwgU3RyaW5nIG9yaWdpbkRhdGEsIFN0cmluZyBpbnRlcmZhY2VOYW1lLCBTdHJpbmcgb3BlcmF0aW9uTmFtZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nIHBhcmVudElkLCBTdHJpbmcgY29udGFpbmVyQ29tcG9uZW50VHlwZSwgYm9vbGVhbiBzaG91b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VyLCBDb21wb25lbnQgY29tcG9uZW50LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFydGlmYWN0RGVmaW5pdGlvbiBhcnRpZmFjdERlZmluaXRpb24sIGJvb2xlYW4gc2hvdWxkTG9jaywgYm9vbGVhbiBpblRyYW5zYWN0aW9uKSB7CiAKLSAgICAgICAgaWYgKHZhbGlkYXRlZEFydGlmYWN0LmdldEFydGlmYWN0VHlwZSgpLmVxdWFsc0lnbm9yZUNhc2UoQXJ0aWZhY3RUeXBlRW51bS5IRUFUX0VOVi5nZXRUeXBlKCkpCisgICAgICAgIGlmIChhcnRpZmFjdERlZmluaXRpb24uZ2V0QXJ0aWZhY3RUeXBlKCkuZXF1YWxzSWdub3JlQ2FzZShBcnRpZmFjdFR5cGVFbnVtLkhFQVRfRU5WLmdldFR5cGUoKSkKICAgICAgICAgICAgICAgICAmJiBDb21wb25lbnRUeXBlRW51bS5TRVJWSUNFID09IGNvbXBvbmVudC5nZXRDb21wb25lbnRUeXBlKCkpIHsKICAgICAgICAgICAgIENvbXBvbmVudEluc3RhbmNlIGNvbXBvbmVudEluc3RhbmNlID0gY29tcG9uZW50LmdldENvbXBvbmVudEluc3RhbmNlcygpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5zdHJlYW0oKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZmlsdGVyKHAgLT4gcC5nZXRVbmlxdWVJZCgpLmVxdWFscyhjb21wb25lbnRJZCkpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5maW5kQW55KCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldCgpOworICAgICAgICAgICAgICAgICAgICAuc3RyZWFtKCkKKyAgICAgICAgICAgICAgICAgICAgLmZpbHRlcihwIC0+IHAuZ2V0VW5pcXVlSWQoKS5lcXVhbHMoY29tcG9uZW50SWQpKQorICAgICAgICAgICAgICAgICAgICAuZmluZEFueSgpCisgICAgICAgICAgICAgICAgICAgIC5vckVsc2UobnVsbCk7CisgICAgICAgICAgICBpZiAoY29tcG9uZW50SW5zdGFuY2UgPT0gbnVsbCkgeworICAgICAgICAgICAgICAgIHRocm93IG5ldyBCeUFjdGlvblN0YXR1c0NvbXBvbmVudEV4Y2VwdGlvbihBY3Rpb25TdGF0dXMuQ09NUE9ORU5UX0lOU1RBTkNFX05PVF9GT1VORF9PTl9DT05UQUlORVIsIGNvbXBvbmVudElkLAorICAgICAgICAgICAgICAgICAgICAgICAgImluc3RhbmNlIiwgIlNlcnZpY2UiLCBjb21wb25lbnQuZ2V0TmFtZSgpKTsKKyAgICAgICAgICAgIH0KICAgICAgICAgICAgIE1hcDxTdHJpbmcsIEFydGlmYWN0RGVmaW5pdGlvbj4gZGVwbG95bWVudEFydGlmYWN0cyA9IGNvbXBvbmVudEluc3RhbmNlLmdldERlcGxveW1lbnRBcnRpZmFjdHMoKTsKIAogICAgICAgICAgICAgQXJ0aWZhY3REZWZpbml0aW9uIGhlYXRFbnZXaXRoSGVhdFBhcmFtcyA9IGRlcGxveW1lbnRBcnRpZmFjdHMudmFsdWVzKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnN0cmVhbSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5maWx0ZXIocCAtPiBwLmdldFVuaXF1ZUlkKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZXF1YWxzKHZhbGlkYXRlZEFydGlmYWN0LmdldFVuaXF1ZUlkKCkpKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZmluZEFueSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXQoKTsKLSAgICAgICAgICAgIEVpdGhlcjxBcnRpZmFjdERlZmluaXRpb24sIFJlc3BvbnNlRm9ybWF0PiBlaXRoZXJHZW5lcmF0ZWQgPSBnZW5lcmF0ZUhlYXRFbnZBcnRpZmFjdChoZWF0RW52V2l0aEhlYXRQYXJhbXMsIGNvbXBvbmVudFR5cGUsIGNvbXBvbmVudCwgY29tcG9uZW50SW5zdGFuY2UKLSAgICAgICAgICAgICAgICAgICAgLmdldE5hbWUoKSwgdXNlciwgY29tcG9uZW50SWQsIHNob3VsZExvY2ssIGluVHJhbnNhY3Rpb24pOworICAgICAgICAgICAgICAgICAgICAuc3RyZWFtKCkKKyAgICAgICAgICAgICAgICAgICAgLmZpbHRlcihwIC0+IHAuZ2V0VW5pcXVlSWQoKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5lcXVhbHMoYXJ0aWZhY3REZWZpbml0aW9uLmdldFVuaXF1ZUlkKCkpKQorICAgICAgICAgICAgICAgICAgICAuZmluZEFueSgpCisgICAgICAgICAgICAgICAgICAgIC5vckVsc2UobnVsbCk7CisgICAgICAgICAgICBFaXRoZXI8QXJ0aWZhY3REZWZpbml0aW9uLCBSZXNwb25zZUZvcm1hdD4gZWl0aGVyR2VuZXJhdGVkID0gZ2VuZXJhdGVIZWF0RW52QXJ0aWZhY3QoaGVhdEVudldpdGhIZWF0UGFyYW1zLAorICAgICAgICAgICAgICAgICAgICBjb21wb25lbnRUeXBlLCBjb21wb25lbnQsIGNvbXBvbmVudEluc3RhbmNlLmdldE5hbWUoKSwgdXNlciwgY29tcG9uZW50SWQsIHNob3VsZExvY2ssIGluVHJhbnNhY3Rpb24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VuZXJhdGUgfHwgKENvbXBvbmVudFR5cGVFbnVtLlJFU09VUkNFID09IGNvbXBvbmVudC5nZXRDb21wb25lbnRUeXBlKCkgJiYgKGFydGlmYWN0SW5mby5nZXRBcnRpZmFjdFR5cGUoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5lcXVhbHNJZ25vcmVDYXNlKEFydGlmYWN0VHlwZUVudW0uSEVBVF9FTlYKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRUeXBlKCkpIHx8IGlzQWJzdHJhY3RWZmNFbXB0eUNzYXIoKFJlc291cmNlKSBjb21wb25lbnQsIGFydGlmYWN0SW5mbykpKTsKKyAgICAgICAgICAgICAgICAuZXF1YWxzSWdub3JlQ2FzZShBcnRpZmFjdFR5cGVFbnVtLkhFQVRfRU5WCisgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0VHlwZSgpKSB8fCBpc0Fic3RyYWN0VmZjRW1wdHlDc2FyKChSZXNvdXJjZSkgY29tcG9uZW50LCBhcnRpZmFjdEluZm8pKSk7CiAgICAgICAgIHJldHVybiBuZWVkR2VuZXJhdGU7CiAgICAgfQogCkBAIC0zODksMTM5ICszODAsMTgzIEBACiAgICAgICAgICAgICAgICAgLmVxdWFscyhBcnRpZmFjdFR5cGVFbnVtLlRPU0NBX0NTQVIuZ2V0VHlwZSgpKSAmJiBTdHJpbmdVdGlscy5pc0VtcHR5KGFydGlmYWN0SW5mby5nZXRBcnRpZmFjdENoZWNrc3VtKCkpOwogICAgIH0KIAotICAgIHB1YmxpYyBFaXRoZXI8RWl0aGVyPEFydGlmYWN0RGVmaW5pdGlvbiwgT3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otCiAgICAgICAgICAgICBpZiAoZ2VuZXJhdGVkLmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiRmFpbGVkIHRvIGV4cG9ydCB0b3NjYSBjc2FyIGZvciBjb21wb25lbnQge30gZXJyb3Ige30iLCBwYXJlbnQuZ2V0VW5pcXVlSWQoKSwgZ2VuZXJhdGVkLnJpZ2h0KCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC52YWx1ZSgpKTsKLQotICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQoZ2VuZXJhdGVkLnJpZ2h0KCkudmFsdWUoKSk7CisgICAgICAgICAgICAgICAgUmVzcG9uc2VGb3JtYXQgZXJyb3IgPSBnZW5lcmF0ZWQucmlnaHQoKS52YWx1ZSgpOworICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiRmFpbGVkIHRvIGdlbmVyYXRlIHRvc2NhIGNzYXIgZm9yIGNvbXBvbmVudCB7fSBlcnJvciB7fSIsIHBhcmVudC5nZXRVbmlxdWVJZCgpLCBlcnJvcik7CisgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEJ5UmVzcG9uc2VGb3JtYXRDb21wb25lbnRFeGNlcHRpb24oZXJyb3IpOwogICAgICAgICAgICAgfQotICAgICAgICAgICAgYnl0ZVtdIHZhbHVlID0gZ2VuZXJhdGVkLmxlZnQoKS52YWx1ZSgpOwotICAgICAgICAgICAgYXJ0aWZhY3RJbmZvLnNldFBheWxvYWQodmFsdWUpOworICAgICAgICAgICAgYXJ0aWZhY3RJbmZvLnNldFBheWxvYWQoZ2VuZXJhdGVkLmxlZnQoKS52YWx1ZSgpKTsKIAogICAgICAgICB9CiAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgRWl0aGVyPFRvc2NhUmVwcmVzZW50YXRpb24sIFRvc2NhRXJyb3I+IGV4cG9ydENvbXBvbmVudCA9IHRvc2NhRXhwb3J0VXRpbHMuZXhwb3J0Q29tcG9uZW50KHBhcmVudCk7CiAgICAgICAgICAgICBpZiAoZXhwb3J0Q29tcG9uZW50LmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiRmFpbGVkIGV4cG9ydCB0b3NjYSB5YW1sIGZvciBjb21wb25lbnQge30gZXJyb3Ige30iLCBwYXJlbnQuZ2V0VW5pcXVlSWQoKSwgZXhwb3J0Q29tcG9uZW50LnJpZ2h0KCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC52YWx1ZSgpKTsKLSAgICAgICAgICAgICAgICBBY3Rpb25TdGF0dXMgc3RhdHVzID0gY29tcG9uZW50c1V0aWxzLmNvbnZlcnRGcm9tVG9zY2FFcnJvcihleHBvcnRDb21wb25lbnQucmlnaHQoKS52YWx1ZSgpKTsKLSAgICAgICAgICAgICAgICBSZXNwb25zZUZvcm1hdCByZXNwb25zZUZvcm1hdCA9IGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChzdGF0dXMpOwotICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQocmVzcG9uc2VGb3JtYXQpOworICAgICAgICAgICAgICAgIFRvc2NhRXJyb3IgdG9zY2FFcnJvciA9IGV4cG9ydENvbXBvbmVudC5yaWdodCgpLnZhbHVlKCk7CisgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJGYWlsZWQgZXhwb3J0IHRvc2NhIHlhbWwgZm9yIGNvbXBvbmVudCB7fSBlcnJvciB7fSIsIHBhcmVudC5nZXRVbmlxdWVJZCgpLCB0b3NjYUVycm9yKTsKKyAgICAgICAgICAgICAgICBBY3Rpb25TdGF0dXMgc3R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ICAgICAgICAgICAgICAgICAgIEFjdGlvblN0YXR1cyBlcnJvciA9IHVwZGF0ZUdyb3VwSW5zdGFuY2UoYXJ0aWZhY3RJbmZvLCB1cGRhdGVSZXN1bHQubGVmdCgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnZhbHVlKCksIHBhcmVudCwgY29tcG9uZW50VHlwZSwgY29tcG9uZW50SWQpOwotICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVycm9yICE9IEFjdGlvblN0YXR1cy5PSykgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCA9IEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoZXJyb3IpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgaWYgKGNvbXBvbmVudFR5cGUuZXF1YWxzKENvbXBvbmVudFR5cGVFbnVtLlJFU09VUkNFKSAmJiBhcnRpZmFjdFR5cGUgPT0gQXJ0aWZhY3RUeXBlRW51bS5IRUFUX0VOVikgewotICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gaGFuZGxlVXBkYXRlSGVhdFdpdGhIZWF0RW52UGFyYW1zKGNvbXBvbmVudElkLCBhcnRpZmFjdEluZm8sIGF1ZGl0aW5nQWN0aW9uLCBhcnRpZmFjdElkLCB1c2VyLCBjb21wb25lbnRUeXBlLCBwYXJlbnQsIG9yaWdpbkRhdGEsIG9yaWdNZDUsIG9wZXJhdGlvbiwgc2hvdWxkTG9jaywgaW5UcmFuc2FjdGlvbiwgbmVlZFVwZGF0ZUdyb3VwKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBpZiAocmVzdWx0ID09IG51bGwpIHsKLSAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gaGFuZGxlVXBkYXRlKGNvbXBvbmVudElkLCBhcnRpZmFjdEluZm8sIG9wZXJhdGlvbiwgYXVkaXRpbmdBY3Rpb24sIGFydGlmYWN0SWQsIHVzZXIsIGNvbXBvbmVudFR5cGUsIHBhcmVudCwgb3JpZ01kNSwgb3JpZ2luRGF0YSwgaW50ZXJmYWNlTmFtZSwgb3BlcmF0aW9uTmFtZSwgc2hvdWxkTG9jaywgaW5UcmFuc2FjdGlvbik7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChuZWVkVXBkYXRlR3JvdXAgJiYgcmVzdWx0LmlzTGVmdCgpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBFaXRoZXI8QXJ0aWZhY3REZWZpbml0aW9uLCBPcGVyYXRpb24+IHVwZGF0ZVJlc3VsdCA9IHJlc3VsdC5sZWZ0KCkudmFsdWUoKTsKLQotICAgICAgICAgICAgICAgICAgICAgICAgQWN0aW9uU3RhdHVzIGVycm9yID0gdXBkYXRlR3JvdXBGb3JIZWF0KGFydGlmYWN0SW5mbywgdXBkYXRlUmVzdWx0LmxlZnQoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnZhbHVlKCksIHBhcmVudCwgY29tcG9uZW50VHlwZSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXJyb3IgIT0gQWN0aW9uU3RhdHVzLk9LKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gRWl0aGVyLnJpZ2h0KGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChlcnJvcikpOwotICAgICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAg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zaG91bGRMb2NrLCBib29sZWFuIGluVHJhbnNhY3Rpb24sIGJvb2xlYW4gbmVlZFVwZGF0ZUdyb3VwKSB7CisgICAgICAgIGlmIChpbnRlcmZhY2VOYW1lICE9IG51bGwgJiYgb3BlcmF0aW9uTmFtZSAhPSBudWxsKSB7CisgICAgICAgICAgICBpbnRlcmZhY2VOYW1lID0gaW50ZXJmYWNlTmFtZS50b0xvd2VyQ2FzZSgpOworICAgICAgICAgICAgb3BlcmF0aW9uTmFtZSA9IG9wZXJhdGlvbk5hbWUudG9Mb3dlckNhc2UoKTsKICAgICAgICAgfQotICAgICAgICByZXR1cm4gbnVsbDsKKyAgICAgICAgaWYgKHNob3VsZExvY2spIHsKKyAgICAgICAgICAgIGxvY2tDb21wb25lbnQoY29tcG9uZW50VHlwZSwgYXJ0aWZhY3RJZCwgYXVkaXRpbmdBY3Rpb24sIHVzZXIsIHBhcmVudCk7CisgICAgICAgIH0KKyAgICAgICAgRWl0aGVyPEFydGlmYWN0RGVmaW5pdGlvbiwgT3BlcmF0aW9uPiByZXN1bHQ7CisgICAgICAgIGJvb2xlYW4gb3BlcmF0aW9uU3VjY2VlZGVkID0gZmFsc2U7CisgICAgICAgIHRyeSB7CisgICAgICAgICAgICBzd2l0Y2ggKG9wZXJhdGlvbi5nZXRBcnRpZmFjdE9wZXJhdGlvbkVudW0oKSkgeworICAgICAgICAgICAgICAgIGNhc2UgRE9XTkxPQUQ6CisgICAgICAgICAgICAgICAgICAgIGlmIChhcnRpZmFjdEdlbmVyYXRpb25SZXF1aXJlZChwYXJlbnQsIGFydGlmYWN0SW5mbykpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCA9IEVpdGhlci5sZWZ0KGdlbmVyYXRlTm90U2F2ZWRBcnRpZmFjdChwYXJlbnQsIGFydGlmYWN0SW5mbykpOworICAgICAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gRWl0aGVyLmxlZnQoaGFuZGxlRG93bmxvYWQoY29tcG9uZW50SWQsIGFydGlmYWN0SWQsIGNvbXBvbmVudFR5cGUsIHBhcmVudCkpOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgREVMRVRFOgorICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSBFaXRoZXIubGVmdChoYW5kbGVEZWxldGVJbnRlcm5hbChjb21wb25lbnRJZCwgYXJ0aWZhY3RJZCwgY29tcG9uZW50VHlwZSwgcGFyZW50KSk7CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgVVBEQVRFOgorICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSBoYW5kbGVVcGRhdGUoY29tcG9uZW50SWQsIGNvbXBvbmVudFR5cGUsIG9wZXJhdGlvbiwgYXJ0aWZhY3RJZCwgYXJ0aWZhY3RJbmZvLCBudWxsLCBvcmlnTWQ1LCBvcmlnaW5EYXRhLCBpbnRlcmZhY2VOYW1lLCBvcGVyYXRpb25OYW1lLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGl0aW5nQWN0aW9uLCB1c2VyLCBwYXJlbnQsIG5lZWRVcGRhdGVHcm91cCk7CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgQ1JFQVRFOgorICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSBoYW5kbGVDcmVhdGUoY29tcG9uZW50SWQsIGFydGlmYWN0SW5mbywgb3BlcmF0aW9uLCBhdWRpdGluZ0FjdGlvbiwgdXNlciwgY29tcG9uZW50VHlwZSwgcGFyZW50LCBvcmlnTWQ1LCBvcmlnaW5EYXRhLCBpbnRlcmZhY2VOYW1lLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wZXJhdGlvbk5hbWUpOworICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICA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ZXIgdXNlciwgQ29tcG9uZW50IHBhcmVudCkgeworICAgICAgICB0cnkgeworICAgICAgICAgICAgbG9ja0NvbXBvbmVudChwYXJlbnQsIEFSVElGQUNUX0FDVElPTl9MT0NLKTsKKyAgICAgICAgfWNhdGNoIChDb21wb25lbnRFeGNlcHRpb24gZSl7CisgICAgICAgICAgICBoYW5kbGVBdWRpdGluZyhhdWRpdGluZ0FjdGlvbiwgcGFyZW50LCBwYXJlbnQuZ2V0VW5pcXVlSWQoKSwgdXNlciwgbnVsbCwgbnVsbCwgYXJ0aWZhY3RJZCwgZS5nZXRSZXNwb25zZUZvcm1hdCgpLAorICAgICAgICAgICAgICAgICAgICBjb21wb25lbnRUeXBlLCBudWxsKTsKKyAgICAgICAgICAgIHRocm93IGU7CisgICAgICAgIH0KKyAgICB9CisKKyAgICBAVmlzaWJsZUZvclRlc3RpbmcKKyAgICBwdWJsaWMgRWl0aGVyPEFydGlmYWN0RGVmaW5pdGlvbiwgT3BlcmF0aW9uPiBoYW5kbGVVcGRhdGUoU3RyaW5nIGNvbXBvbmVudElkLCBDb21wb25lbnRUeXBlRW51bSBjb21wb25lbnRUeXBlLCBBcnRpZmFjdE9wZXJhdGlvbkluZm8gb3BlcmF0aW9uLCBTdHJpbmcgYXJ0aWZhY3RJZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBcnRpZmFjdERlZmluaXRpb24gYXJ0aWZhY3RJbmZvLCBieXRlW10gZGVjb2RlZFBheWxvYWQsIFN0cmluZyBvcmlnTWQ1LCBTdHJpbmcgb3JpZ2luRGF0YSwgU3RyaW5nIGludGVyZmFjZU5hbWUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nIG9wZXJhdGlvbk5hbWUsIEF1ZGl0aW5nQWN0aW9uRW51bSBhdWRpdGluZ0FjdGlvbiwgVXNlciB1c2VyLCBDb21wb25lbnQgcG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nRpZmFjdERlZmluaXRpb24gYXJ0QWZ0ZXJVcGRhdGUsIENvbXBvbmVudCBwYXJlbnQpIHsKKyAgICAgICAgcmV0dXJuIEFjdGlvblN0YXR1cy5PSzsKKyAgICB9CisKKyAgICBAVmlzaWJsZUZvclRlc3RpbmcKKyAgICBwdWJsaWMgQWN0aW9uU3RhdHVzIHVwZGF0ZUdyb3VwRm9ySGVhdChBcnRpZmFjdERlZmluaXRpb24gYXJ0aWZhY3RJbmZvLCBBcnRpZmFjdERlZmluaXRpb24gYXJ0QWZ0ZXJVcGRhdGUsIENvbXBvbmVudCBwYXJlbnQpIHsKICAgICAgICAgTGlzdDxHcm91cERlZmluaXRpb24+IGdyb3VwcyA9IHBhcmVudC5nZXRHcm91cHMoKTsKICAgICAgICAgaWYgKGdyb3VwcyAhPSBudWxsICYmICFncm91cHMuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICBMaXN0PEdyb3VwRGF0YURlZmluaXRpb24+IGdyb3VwVG9VcGRhdGUgPSBncm91cHMuc3RyZWFtKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5maWx0ZXIoZyAtPiBnLmdldEFydGlmYWN0cygpICE9IG51bGwgJiYgZy5nZXRBcnRpZmFjdHMoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmNvbnRhaW5zKGFydGlmYWN0SW5mbwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0VW5pcXVlSWQoKSkpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuY29sbGVjdChDb2xsZWN0b3JzLnRvTGlzdCgpKTsKKyAgICAgICAgICAgICAgICAgICAgLmZpbHRlcihnIC0+IGcuZ2V0QXJ0aWZhY3RzKCkgIT0gbnVsbCAmJiBnLmdldEFydGlmYWN0cygpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmNvbnRhaW5zKGFydGlmYWN0SW5mbworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldFVuaXF1ZUlkKCkpKQorICAgICAgICAgICAgICAgICAgICAuY29sbGVjdChDb2xsZWN0b3JzLnRvTGlzdCgpKTsKICAgICAgICAgICAgIGlmIChncm91cFRvVXBkYXRlICE9IG51bGwgJiYgIWdyb3VwVG9VcGRhdGUuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgZ3JvdXBUb1VwZGF0ZS5mb3JFYWNoKGcgLT4gewogICAgICAgICAgICAgICAgICAgICBnLmdldEFydGlmYWN0cygpLnJlbW92ZShhcnRpZmFjdEluZm8uZ2V0VW5pcXVlSWQoKSk7CiAgICAgICAgICAgICAgICAgICAgIGcuZ2V0QXJ0aWZhY3RzVXVpZCgpLnJlbW92ZShhcnRpZmFjdEluZm8uZ2V0QXJ0aWZhY3RVVUlEKCkpOwogICAgICAgICAgICAgICAgICAgICBnLmdldEFydGlmYWN0cygpLmFkZChhcnRBZnRlclVwZGF0ZS5nZXRVbmlxdWVJZCgpKTsKICAgICAgICAgICAgICAgICAgICAgZy5nZXRBcnRpZmFjdHNVdWlkKCkuYWRkKGFydEFmdGVyVXBkYXRlLmdldEFydGlmYWN0VVVJRCgpKTsKKyAgICAgICAgICAgICAgICAgICAgaWYoIWFydGlmYWN0SW5mby5nZXRBcnRpZmFjdFVVSUQoKS5lcXVhbHMoYXJ0QWZ0ZXJVcGRhdGUuZ2V0QXJ0aWZhY3RVVUlEKCkpKXsKKyAgICAgICAgICAgICAgICAgICAgICAgIGcuc2V0R3JvdXBVVUlEKFVuaXF1ZUlkQnVpbGRlci5nZW5lcmF0ZVVVSUQoKSk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ENvbXBvbmVudFR5cGVFbnVtIGNvbXBvbmVudFR5cGUpIHsKKyAgICBAVmlzaWJsZUZvclRlc3RpbmcKKyAgICBBY3Rpb25TdGF0dXMgdXBkYXRlR3JvdXBGb3JIZWF0KEFydGlmYWN0RGVmaW5pdGlvbiBhcnRpZmFjdEluZm9IZWF0LCBBcnRpZmFjdERlZmluaXRpb24gYXJ0SGVhdEFmdGVyVXBkYXRlLCBBcnRpZmFjdERlZmluaXRpb24gYXJ0aWZhY3RJbmZvSGVhdEUsIEFydGlmYWN0RGVmaW5pdGlvbiBhcnRIRUFmdGVyVXBkYXRlLCBDb21wb25lbnQgcGFyZW50KSB7CiAgICAgICAgIExpc3Q8R3JvdXBEZWZpbml0aW9uPiBncm91cHMgPSBwYXJlbnQuZ2V0R3JvdXBzKCk7CiAgICAgICAgIGlmIChncm91cHMgIT0gbnVsbCAmJiAhZ3JvdXBzLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgTGlzdDxHcm91cERhdGFEZWZpbml0aW9uPiBncm91cFRvVXBkYXRlID0gZ3JvdXBzLnN0cmVhbSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZmlsdGVyKGcgLT4gZy5nZXRBcnRpZmFjdHMoKSAhPSBudWxsICYmIGcuZ2V0QXJ0aWZhY3RzKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5jb250YWlucyhhcnRpZmFjdEluZm9IZWF0Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRVbmlxdWVJZCgpKSkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA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XBvbmVudCBwYXJlbnQsIFN0cmluZyBwYXJlbnRJZCkgewogICAgICAgICBMaXN0PEdyb3VwSW5zdGFuY2U+IHVwZGF0ZWRHcm91cEluc3RhbmNlcyA9IG5ldyBBcnJheUxpc3Q8PigpOwogICAgICAgICBMaXN0PEdyb3VwSW5zdGFuY2U+IGdyb3VwSW5zdGFuY2VzID0gbnVsbDsKICAgICAgICAgT3B0aW9uYWw8Q29tcG9uZW50SW5zdGFuY2U+IGNvbXBvbmVudEluc3RPcCA9IHBhcmVudC5nZXRDb21wb25lbnRJbnN0YW5jZXMoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnN0cmVhbSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZmlsdGVyKGNpIC0+IGNpLmdldFVuaXF1ZUlkKCkuZXF1YWxzKHBhcmVudElkKSkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5maW5kRmlyc3QoKTsKKyAgICAgICAgICAgICAgICAuc3RyZWFtKCkKKyAgICAgICAgICAgICAgICAuZmlsdGVyKGNpIC0+IGNpLmdldFVuaXF1ZUlkKCkuZXF1YWxzKHBhcmVudElkKSkKKyAgICAgICAgICAgICAgICAuZmluZEZpcnN0KCk7CiAgICAgICAgIGlmIChjb21wb25lbnRJbnN0T3AuaXNQcmVzZW50KCkpIHsKICAgICAgICAgICAgIGdyb3VwSW5zdGFuY2VzID0gY29tcG9uZW50SW5zdE9wLmdldCgpLmdldEdyb3VwSW5zdGFuY2VzKCk7CiAgICAgICAgIH0KQEAgLTU1NiwxNSArNTkxLDE1IEBACiAgICAgICAgICAgICBmb3IgKEdyb3VwSW5zdGFuY2UgZ3JvdXBJbnN0YW5jZSA6IGdyb3VwSW5zdGFuY2VzKSB7CiAgICAgICAgICAgICAgICAgaXNVcGRhdGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgaWYgKENvbGxlY3Rpb25VdGlscy5pc05vdEVtcHR5KGdyb3VwSW5zdGFuY2UuZ2V0R3JvdXBJbnN0YW5jZUFydGlmYWN0cygpKSAmJiBncm91cEluc3RhbmNlLmdldEdyb3VwSW5zdGFuY2VBcnRpZmFjdHMoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5jb250YWlucyhhcnRpZmFjdEluZm8KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRVbmlxdWVJZCgpKSkgeworICAgICAgICAgICAgICAgICAgICAgICAgLmNvbnRhaW5zKGFydGlmYWN0SW5mbworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0VW5pcXVlSWQoKSkpIHsKICAgICAgICAgICAgICAgICAgICAgZ3JvdXBJbnN0YW5jZS5nZXRHcm91cEluc3RhbmNlQXJ0aWZhY3RzKCkucmVtb3ZlKGFydGlmYWN0SW5mby5nZXRVbmlxdWVJZCgpKTsKICAgICAgICAgICAgICAgICAgICAgZ3JvdXBJbnN0YW5jZS5nZXRHcm91cEluc3RhbmNlQXJ0aWZhY3RzKCkuYWRkKGFydEFmdGVyVXBkYXRlLmdldFVuaXF1ZUlkKCkpOwogICAgICAgICAgICAgICAgICAgICBpc1VwZGF0ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBpZiAoQ29sbGVjdGlvblV0aWxzLmlzTm90RW1wdHkoZ3JvdXBJbnN0YW5jZS5nZXRHcm91cEluc3RhbmNlQXJ0aWZhY3RzVXVpZCgpKSAmJiBncm91cEluc3RhbmNlLmdldEdyb3VwSW5zdGFuY2VBcnRpZmFjdHNVdWlkKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmNvbnRhaW5zKGFydGlmYWN0SW5mbwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRBcnRpZmFjdFVVSUQoKSkpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIC5jb250YWlucyhhcnRpZmFjdEluZm8KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldEFydGlmYWN0VVVJRCgpKSkgewogICAgICAgICAgICAgICAgICAgICBncm91cEluc3RhbmNlLmdldEdyb3VwSW5zdGFuY2VBcnRpZmFjdHNVdWlkKCkucmVtb3ZlKGFydGlmYWN0SW5mby5nZXRBcnRpZmFjdFVVSUQoKSk7CiAgICAgICAgICAgICAgICAgICAgIGdyb3VwSW5zdGFuY2UuZ2V0R3JvdXBJbnN0YW5jZUFydGlmYWN0cygpLmFkZChhcnRBZnRlclVwZGF0ZS5nZXRBcnRpZmFjdFVVSUQoKSk7CiAgICAgICAgICAgICAgICAgICAgIGlzVXBkYXRlZCA9IHRydWU7CkBAIC01ODIsMTIxICs2MTcsNzcgQEAKICAgICAgICAgcmV0dXJuIEFjdGlvblN0YXR1cy5PSzsKICAgICB9CiAKLSAgICBFaXRoZXI8RWl0aGVyPEFydGlmYWN0RGVmaW5pdGlvbiwgT3BlcmF0aW9uPiwgUmVzcG9uc2VGb3JtYXQ+IGdlbmVyYXRlTm90U2F2ZWRBcnRpZmFjdChDb21wb25lbnQgcGFyZW50LCBBcnRpZmFjdERlZmluaXRpb24gYXJ0aWZhY3RJbmZvKSB7Ci0gICAgICAgIEVpdGhlcj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sIG5lZWRUb1VwZGF0ZUdyb3VwKTsKKyAgICB9CiAKLSAgICAgICAgLy8gbG9jayByZXNvdXJjZQotICAgICAgICBpZiAoc2hvdWxkTG9jaykgewotICAgICAgICAgICAgRWl0aGVyPEJvb2xlYW4sIFJlc3BvbnNlRm9ybWF0PiBsb2NrQ29tcG9uZW50ID0gbG9ja0NvbXBvbmVudChwYXJlbnQsIFVQREFURV9BUlRJRkFDVF9MT0NLKTsKLSAgICAgICAgICAgIGlmIChsb2NrQ29tcG9uZW50LmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgIGhhbmRsZUF1ZGl0aW5nKGF1ZGl0aW5nQWN0aW9uLCBwYXJlbnQsIHBhcmVudElkLCB1c2VyLCBudWxsLCBudWxsLCBhcnRpZmFjdElkLCBsb2NrQ29tcG9uZW50LnJpZ2h0KCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC52YWx1ZSgpLCBjb21wb25lbnRUeXBlLCBudWxsKTsKLSAgICAgICAgICAgICAgICByZXR1cm4gRWl0aGVyLnJpZ2h0KGxvY2tDb21wb25lbnQucmlnaHQoKS52YWx1ZSgpKTsKKyAgICBwcml2YXRlIHZvaWQgaGFuZGxlTG9ja2luZ0FuZENvbW1pdChDb21wb25lbnQgcGFyZW50LCBib29sZWFuIHNob3VsZExvY2ssIGJvb2xlYW4gaW5UcmFuc2FjdGlvbiwgYm9vbGVhbiBhY3Rpb25TdWNjZWVkZWQpIHsKKyAgICAgICAgaWYgKGFjdGlvblN1Y2NlZWRlZCkgeworICAgICAgICAgICAgbG9nLmRlYnVnKENPTU1JVCk7CisgICAgICAgICAgICBpZiAoIWluVHJhbnNhY3Rpb24pIHsKKyAgICAgICAgICAgICAgICBqYW51c0dyYXBoRGFvLmNvbW1pdCgpOwogICAgICAgICAgICAgfQotICAgICAgICB9Ci0gICAgICAgIEVpdGhlcjxFaXRoZXI8QXJ0aWZhY3REZWZpbml0aW9uLCBPcGVyYXRpb24+LCBSZXNwb25zZUZvcm1hdD4gcmVzdWx0T3AgPSBudWxsOwotICAgICAgICB0cnkgewotICAgICAgICAgICAgcmVzdWx0T3AgPSB1cGRhdGVIZWF0UGFyYW1zKGNvbXBvbmVudElkLCBhcnRpZmFjdElkLCBhcnRpZmFjdEluZm8sIHVzZXIsIGF1ZGl0aW5nQWN0aW9uLCBwYXJlbnQsIGNvbXBvbmVudFR5cGUsIGN1cnJIZWF0QXJ0aWZhY3QsIG5lZWRUb1VwZGF0ZUdyb3VwKTsKLSAgICAgICAgICAgIHJldHVybiByZXN1bHRPcDsKLQotICAgICAgICB9Ci0gICAgICAgIGZpbmFsbHkgewotICAgICAgICAgICAgLy8gdW5sb2NrIHJlc291cmNlCi0gICAgICAgICAgICBpZiAocmVzdWx0T3AgPT0gbnVsbCB8fCByZXN1bHRPcC5pc1JpZ2h0KCkpIHsKLSAgICAgICAgICAgICAgICBsb2cuZGVidWcoUk9MTEJBQ0spOwotICAgICAgICAgICAgICAgIGlmICghaW5UcmFuc2FjdGlvbikgeworICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgbG9nLmRlYnVnKFJPTExCQUNLKTsKKyAgICAgICAgICAgIGlmICghaW5UcmFuc2FjdGlvbikgewogICAgICAgICAgICAgICAgICAgICBqYW51c0dyYXBoRGFvLnJvbGxiYWNrKCk7Ci0gICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQotICAgICAgICAgICAgZWxzZSB7Ci0gICAgICAgICAgICAgICAgbG9nLmRlYnVnKENPTU1JVCk7Ci0gICAgICAgICAgICAgICAgaWYgKCFpblRyYW5zYWN0aW9uKSB7Ci0gICAgICAgICAgICAgICAgICAgIGphbnVzR3JhcGhEYW8uY29tbWl0KCk7Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgfQotICAgICAgICAgICAgaWYgKHNob3VsZExvY2spIHsKL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leHBvcnQgdG9zY2EgY3NhciBmb3IgY29tcG9uZW50IHt9IGVycm9yIHt9IiwgY29tcG9uZW50LmdldFVuaXF1ZUlkKCksIGdlbmVyYXRlZC5yaWdodCgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAudmFsdWUoKSk7Ci0KLSAgICAgICAgICAgICAgICByZXR1cm4gRWl0aGVyLnJpZ2h0KGdlbmVyYXRlZC5yaWdodCgpLnZhbHVlKCkpOworICAgICAgICAgICAgICAgICAgICAgICAgLnZhbHVlKCkpOworICAgICAgICAgICAgICAgIHRocm93IG5ldyBCeVJlc3BvbnNlRm9ybWF0Q29tcG9uZW50RXhjZXB0aW9uKGdlbmVyYXRlZC5yaWdodCgpLnZhbHVlKCkpOwogICAgICAgICAgICAgfQotICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5sZWZ0KG5ldyBJbW11dGFibGVQYWlyPFN0cmluZywgYnl0ZVtdPihjc2FyQXJ0aWZhY3QuZ2V0QXJ0aWZhY3ROYW1lKCksIGdlbmVyYXRlZC5sZWZ0KCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAudmFsdWUoKSkpOworICAgICAgICAgICAgcmV0dXJuIG5ldyBJbW11dGFibGVQYWlyPD4oY3NhckFydGlmYWN0LmdldEFydGlmYWN0TmFtZSgpLCBnZW5lcmF0ZWQubGVmdCgpLnZhbHVlKCkpOwogICAgICAgICB9CiAgICAgICAgIHJldHVybiBkb3dubG9hZEFydGlmYWN0KGNzYXJBcnRpZmFjdCk7CiAgICAgfQogCi0gICAgcHVibGljIEVpdGhlcjxJbW11dGFibGVQYWlyPFN0cmluZywgYnl0ZVtdPiwgUmVzcG9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W9uSW5mbyhmYWxzZSwgZmFsc2UsIEFydGlmYWN0T3BlcmF0aW9uRW51bS5ET1dOTE9BRCksIGFydGlmYWN0SWQsIG51bGwsIG51bGwsIG51bGwsIG51bGwsCiAgICAgICAgICAgICAgICAgbnVsbCwgcGFyZW50SWQsIGNvbnRhaW5lckNvbXBvbmVudFR5cGUpOwotICAgICAgICBpZiAocmVzdWx0LmlzUmlnaHQoKSkgewotICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChyZXN1bHQucmlnaHQoKS52YWx1ZSgpKTsKLSAgICAgICAgfQogICAgICAgICBBcnRpZmFjdERlZmluaXRpb24gYXJ0aWZhY3REZWZpbml0aW9uOwotICAgICAgICBFaXRoZXI8QXJ0aWZhY3REZWZpbml0aW9uLCBPcGVyYXRpb24+IGluc2lkZVZhbHVlID0gcmVzdWx0LmxlZnQoKS52YWx1ZSgpOworICAgICAgICBFaXRoZXI8QXJ0aWZhY3REZWZpbml0aW9uLCBPcGVyYXRpb24+IGluc2lkZVZhbHVlID0gcmVzdWx0OwogICAgICAgICBpZiAoaW5zaWRlVmFsdWUuaXNMZWZ0KCkpIHsKICAgICAgICAgICAgIGFydGlmYWN0RGVmaW5pdGlvbiA9IGluc2lkZVZhbHVlLmxlZnQoKS52YWx1ZSgpOwogICAgICAgICB9CkBAIC03MDUsMzkgKzY5NiwzNSBAQAogICAgICAgICB9CiAgICAgICAgIC8vIGZvciB0b3NjYSBhcnRpZmFjdHMgYW5kIGhlYXQgZW52IG9uIFZGIGxldmVsIGdlbmVyYXRlZCBvbiBkb3dubG9hZCB3aXRob3V0IHNhdmluZwogICAgICAgICBpZiAoYXJ0aWZhY3REZWZpbml0aW9uLmdldFBheWxvYWREYXRhKCkgIT0gbnVsbCkgewotICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5sZWZ0KG5ldyBJbW11dGFibGVQYWlyPFN0cmluZywgYnl0ZVtdPihhcnRpZmFjdERlZmluaXRpb24uZ2V0QXJ0aWZhY3RO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Jlc3BvbnNlRm9ybWF0IHJlc3BvbnNlRm9ybWF0ID0gY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5NSVNTSU5HX0lORk9STUFUSU9OKTsKLSAgICAgICAgICAgICAgICBsb2cuZGVidWcoImhhbmRsZUdldEFydGlmYWN0c0J5VHlwZSAtIG5vdCBmYWxpZCBncm91cFR5cGUge30gLCBjb21wb25lbnQgaWQge30iLCBhcnRpZmFjdEdyb3VwVHlwZSwgY29tcG9uZW50SWQpOwotCi0gICAgICAgICAgICAgICAgcmVzdWx0T3AgPSBFaXRoZXIucmlnaHQocmVzcG9uc2VGb3JtYXQpOwotICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHRPcDsKLQorICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiaGFuZGxlR2V0QXJ0aWZhY3RzQnlUeXBlIC0gbm90IGZhaWxlZCBncm91cFR5cGUge30gLCBjb21wb25lbnQgaWQge30iLCBhcnRpZmFjdEdyb3VwVHlwZSwgY29tcG9uZW50SWQpOworICAgICAgICAgICAgICAgIHRocm93IG5ldyBCeUFjdGlvblN0YXR1c0NvbXBvbmVudEV4Y2VwdGlvbihBY3Rpb25TdGF0dXMuTUlTU0lOR19JTkZPUk1BVElPTik7CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBpZiAoZ3JvdXBUeXBlID09IEFydGlmYWN0R3JvdXBUeXBlRW51bS5ERVBMT1lNRU5UKSB7CiAgICAgICAgICAgICAgICAgTGlzdDxBcnRpZmFjdERlZmluaXRpb24+IGxpc3QgPSBnZXREZXBsb3ltZW50QXJ0aWZhY3RzKGNvbXBvbmVudCwgY29tcG9uZW50VHlwZS5nZXROb2RlVHlwZSgpLCBjb21wb25lbnRJZCk7CiAgICAgICAgICAgICAgICAgaWYgKGxpc3QgIT0gbnVsbCAmJiAhbGlzdC5pc0VtcHR5KCkpIHsKLSAgICAgICAgICAgICAgICAgICAgcmVzTWFwID0gbGlzdC5zdHJlYW0oKS5jb2xsZWN0KENvbGxlY3RvcnMudG9NYXAoYSAtPiBhLmdldEFydGlmYWN0TGFiZWwoKSwgYSAtPiBhKSk7CisgICAgICAgICAgICAgICAgICAgIHJlc01hcCA9IGxpc3Quc3RyZWFtKCkuY29sbGVjdChDb2xsZWN0b3JzLnRvTWFwKEFydGlmYWN0RGF0YURlZmluaXRpb246OmdldEFydGlmYWN0TGFiZWwsIEZ1bmN0aW9uLmlkZW50aXR5KCkpKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgIHJlc01hcCA9IG5ldyBIYXNoTWFwPD4oKTsKICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgcmVzdWx0T3AgPSBFaXRoZXIubGVmdChyZXNNYXApOwotICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHRPcDsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGVsc2UgeworICAgICAgICAgICAgICAgIHJldHVybiByZXNNYXA7CisgICAgICAgICAgICB9IGVsc2UgewogCiAgICAgICAgICAgICAgICAgRWl0aGVyPE1hcDxTdHJpbmcsIEFydGlmYWN0RGVmaW5pdGlvbj4sIFN0b3JhZ2VPcGVyYXRpb25TdGF0dXM+IGFydGlmYWN0c01hcFN0YXR1cyA9IGdldEFydGlmYWN0cyhyZWFsQ29tcG9uZW50SWQsIGNvbXBvbmVudFR5cGUKICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXROb2RlVHlwZSgpLCBncm91cFR5cGUsIGNvbXBvbmVudElkKTsKICAgICAgICAgICAgICAgICBpZiAoYXJ0aWZhY3RzTWFwU3RhdHVzLmlzUmlnaHQoKSkgewogICAgICAgICAgICAgICAgICAgICBpZiAoYXJ0aWZhY3RzTWFwU3RhdHVzLnJpZ2h0KCkudmFsdWUoKSAhPSBTdG9yYWdlT3BlcmF0aW9uU3RhdHVzLk5PVF9GT1VORCkgewotICAgICAgICAgICAgICAgICAgICAgICAgUmVzcG9uc2VGb3JtYXQgcmVzcG9uc2VGb3JtYXQgPSBjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLk1JU1NJTkdfSU5GT1JNQVRJT04pOwotICAgICAgICAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJoYW5kbGVHZXRBcnRpZmFjdHNCeVR5cGUgLSBub3QgZmFsaWQgZ3JvdXBUeXBlIHt9ICwgY29tcG9uZW50IGlkIHt9IiwgYXJ0aWZhY3RHcm91cFR5cGUsIGNvbXBvbmVudElkKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdE9wID0gRWl0aGVyLnJpZ2h0KHJlc3BvbnNlRm9ybWF0KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiaGFuZGxlR2V0QXJ0aWZhY3RzQnlUeXBlIC0gbm90IGZhaWxlZCBncm91cFR5cGUge30gLCBjb21wb25lbnQgaWQge30iLCBhcnRpZmFjdEdyb3VwVHlwZSwgY29tcG9uZW50SWQpOworICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEJ5QWN0aW9uU3RhdHVzQ29tcG9uZW50RXhjZXB0aW9uKEFjdGlvblN0YXR1cy5NSVNTSU5HX0lORk9STUFUSU9OKTsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgIHJlc01hcCA9IG5ldyBIYXNoTWFwPD4oKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdE9wID0gRWl0aGVyLmxlZnQocmVzTWFwKTsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgcmVzTWFwID0gYXJ0aWZhY3RzTWFwU3RhdHVzLmxlZnQoKS52YWx1ZSgpOwotICAgICAgICAgICAgICAgICAgICByZXN1bHRPcCA9IEVpdGhlci5sZWZ0KHJlc01hcCk7CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHRPcDsKKyAgICAgICAgICAgICAgICByZXR1cm4gcmVzTWFwOwogICAgICAgICAgICAgfQotICAgICAgICB9Ci0gICAgICAgIGZpbmFsbHkgeworICAgICAgICB9Y2F0Y2ggKENvbXBvbmVudEV4Y2VwdGlvbiBlKXsKKyAgICAgICAgICAgIGZhaWxlZCA9IHRydWU7CisgICAgICAgICAgICB0aHJvdyBlOworICAgICAgICB9IGZpbmFsbHkgewogICAgICAgICAgICAgLy8gdW5sb2NrIHJlc291cmNlCi0gICAgICAgICAgICBpZiAocmVzdWx0T3AgPT0gbnVsbCB8fCByZXN1bHRPcC5pc1JpZ2h0KCkpIHsKKyAgICAgICAgICAgIGlmIChmYWlsZWQpIHsKICAgICAgICAgICAgICAgICBsb2cuZGVidWcoUk9MTEJBQ0spOwogICAgICAgICAgICAgICAgIGphbnVzR3JhcGhEYW8ucm9sbGJhY2soKTsKICAgICAgICAgICAgIH0KQEAgLTgyMywzMCArNzkyLDE1IEBACiAKICAgICB9CiAKLSAgICBwcml2YXRlIEVpdGhlcjxBcnRpZmFjdERlZmluaXRpb24sIFJlc3BvbnNlRm9ybWF0PiB2YWxpZGF0ZUFydGlmYWN0KFN0cmluZyBjb21wb25lbnRJZCwgQ29tcG9uZW50VHlwZUVudW0gY29tcG9uZW50VHlwZSwgU3RyaW5nIGFydGlmYWN0SWQsIENvbXBvbmVudCBjb21wb25lbnQpIHsKLSAgICAgICAgLy8gc3RlcCA5CisgICAgcHJpdmF0ZSBBcnRpZmFjdERlZmluaXRpb24gZ2V0QXJ0aWZhY3RJZkJlbG9uZ3NUb0NvbXBvbmVudChTdHJpbmcgY29tcG9uZW50SWQsIENvbXBvbmVudFR5cGVFbnVtIGNvbXBvbmVudFR5cGUsIFN0cmluZyBhcnRpZmFjdElkLC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BFaXRoZXIucmlnaHQocmVzcG9uc2VGb3JtYXQpOwotCi0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBlbHNlIHsKLSAgICAgICAgICAgICAgICBSZXNwb25zZUZvcm1hdCByZXNwb25zZUZvcm1hdCA9IGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChjb21wb25lbnRzVXRpbHMuY29udmVydEZyb21TdG9yYWdlUmVzcG9uc2UoYXJ0aWZhY3RSZXN1bHQKLSAgICAgICAgICAgICAgICAgICAgICAgIC5yaWdodCgpCi0gICAgICAgICAgICAgICAgICAgICAgICAudmFsdWUoKSkpOwotICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiYWRkQXJ0aWZhY3QgLSBmYWlsZWQgdG8gZmV0Y2ggYXJ0aWZhY3Qge30sIGVycm9yIHt9IiwgYXJ0aWZhY3RJZCwgYXJ0aWZhY3RSZXN1bHQucmlnaHQoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAudmFsdWUoKSk7Ci0gICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChyZXNwb25zZUZvcm1hdCk7Ci0gICAgICAgICAgICB9CisgICAgICAgICAgICB0aHJvdyBuZXcgQnlBY3Rpb25TdGF0dXNDb21wb25lbnRFeGNlcHRpb24oQWN0aW9uU3RhdHVzLkNPTVBPTkVOVF9BUlRJRkFDVF9OT1RfRk9VTkQsIGFydGlmYWN0SWQsIGNvbXBvbmVudElkKTsKICAgICAgICAgfQotICAgICAgICAvLyBzdGVwIDkuMQotICAgICAgICAvLyBjaGVjayBhcnRpZmFjdCBiZWxvbmcgdG8gY29tcG9uZW50Ci0gICAgICAgIGJvb2xlYW4gZm91bmQgPSBmYWxzZTsKKyAgICAgICAgLy8gdmVyaWZ5IGFydGlmYWN0IGJlbG9uZ3MgdG8gY29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kNSwgb3JpZ2luRGF0YSwgaW50ZXJmYWNlVHlwZSwgb3BlcmF0aW9uTmFtZSk7Ci0gICAgICAgIGlmIChwYXlsb2FkRWl0aGVyLmlzUmlnaHQoKSkgewotICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChwYXlsb2FkRWl0aGVyLnJpZ2h0KCkudmFsdWUoKSk7CisgICAgcHJpdmF0ZSBBcnRpZmFjdERlZmluaXRpb24gaGFuZGxlTGluayhTdHJpbmcgY29tcG9uZW50SWQsIEFydGlmYWN0RGVmaW5pdGlvbiBhcnRpZmFjdEluZm8sIENvbXBvbmVudFR5cGVFbnVtIGNvbXBvbmVudFR5cGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb21wb25lbnQgcGFyZW50KSB7CisgICAgICAgIENvbXBvbmVudEluc3RhbmNlIGZvdW5kSW5zdGFuY2UgPSBmaW5kQ29tcG9uZW50SW5zdGFuY2UoY29tcG9uZW50SWQsIHBhcmVudCk7CisgICAgICAgIFN0cmluZyBpbnN0YW5jZUlkID0gbnVsbDsKKyAgICAgICAgaWYgKGZvdW5kSW5zdGFuY2UgIT0gbnVsbCkgeworICAgICAgICAgICAgaW5zdGFuY2VJZCA9IGZvdW5kSW5zdGFuY2UuZ2V0VW5pcXVlSWQoKTsKICAgICAgICAgfQotICAgICAgICBieXRlW10gZGVjb2RlZFBheWxvYWQgPSBwYXlsb2FkRWl0aGVyLmxlZnQoKS52YWx1ZSgpOwotICAgICAgICBjb252ZXJ0UGFyZW50VHlwZShjb21wb25lbnRUeXBlKTsKLQotICAgICAgICBpZiAoc2hvdWxkTG9jaykgewotICAgICAgICAgICAgRWl0aGVyPEJvb2xlYW4sIFJlc3BvbnNlRm9ybWF0PiBsb2NrQ29tcG9uZW50ID0gbG9ja0NvbXBvbmVudChwYXJlbnQsICJVcGxvYWQgQXJ0aWZhY3QgLSBsb2NrICIpOwotICAgICAgICAgICAgaWYgKGxvY2tDb21wb25lbnQuaXNSaWdodCgpKSB7Ci0gICAgICAgICAgICAgICAgaGFuZGxlQXVkaXRpbmcoYXVkaXRpbmdBY3Rpb24sIHBhcmVudCwgY29tcG9uZW50SWQsIHVzZXIsIG51bGwsIG51bGwsIG51bGwsIGxvY2tDb21wb25lbnQucmlnaHQoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnZhbHVlKCksIGNvbXBvbmVudFR5cGUsIG51bGwpOwotICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQobG9ja0NvbXBvbmVudC5yaWdodCgpLnZhbHVlKCkpOwotICAgICAgICAgICAgfQorICAgICAgICBOb2RlVHlwZUVudW0gbm9kZVR5cGUgPSBjb252ZXJ0UGFyZW50VHlwZShjb21wb25lbnRUeXBlKTsKKyAgICAgICAgRWl0aGVyPEFydGlmYWN0RGVmaW5pdGlvbiwgU3RvcmFnZU9wZXJhdGlvblN0YXR1cz4gYXJ0aWZhY3REZWZpbml0aW9uRWl0aGVyID0gYXJ0aWZhY3RUb3NjYU9wZXJhdGlvbi5hZGRBcnRpZmFjdFRvQ29tcG9uZW50KGFydGlmYWN0SW5mbywgcGFyZW50LAorICAgICAgICAgICAgICAgIG5vZGVUeXBlLCB0cnVlLCBpbnN0YW5jZUlkKTsKKyAgICAgICAgaWYgKGFydGlmYWN0RGVmaW5pdGlvbkVpdGhlci5pc1JpZ2h0KCkpIHsKKyAgICAgICAgICAgIHRocm93IG5ldyBTdG9yYWdlRXhjZXB0aW9uKGFydGlmYWN0RGVmaW5pdGlvbkVpdGhlci5yaWdodCgpLnZhbHVlKCksIGFydGlmYWN0SW5mby5nZXRBcnRpZmFjdERpc3BsYXlOYW1lKCkpOwogICAgICAgICB9Ci0gICAgICAgIEVpdGhlcjxFaXRoZXI8QXJ0aWZhY3REZWZpbml0aW9uLCBPcGVyYXRpb24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worICAgICAgICB9CisgICAgICAgIGNhdGNoIChTdG9yYWdlRXhjZXB0aW9uIHNlKSB7CisgICAgICAgICAgICAvL1RPRE86IGF1ZGl0CisgICAgICAgICAgICBmYWlsZWQgPSB0cnVlOworICAgICAgICAgICAgdGhyb3cgc2U7CisgICAgICAgIH0KICAgICAgICAgZmluYWxseSB7CiAgICAgICAgICAgICBpZiAoc2hvdWxkTG9jaykgewotICAgICAgICAgICAgICAgIHVubG9ja0NvbXBvbmVudChyZXN1bHRPcCwgcGFyZW50LCBpblRyYW5zYWN0aW9uKTsKLSAgICAgICAgICAgIH0KLQotICAgICAgICB9Ci0KLSAgICB9Ci0KLSAgICBwcml2YXRlIEVpdGhlcjxFaXRoZXI8QXJ0aWZhY3REZWZpbml0aW9uLCBPcGVyYXRpb24+LCBSZXNwb25zZUZvcm1hdD4gaGFuZGxlTGluayhTdHJpbmcgY29tcG9uZW50SWQsIEFydGlmYWN0RGVmaW5pdGlvbiBhcnRpZmFjdEluZm8sIEF1ZGl0aW5nQWN0aW9uRW51bSBhdWRpdGluZ0FjdGlvbiwgVXNlciB1c2VyLCBDb21wb25lbnRUeXBlRW51bSBjb21wb25lbnRUeXBlLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbXBvbmVudCBwYXJlbnQsIGJvb2xlYW4gc2hvdWxkTG9jaywgYm9vbGVhbiBpblRyYW5zYWN0aW9uKSB7Ci0KLSAgICAgICAgaWYgKHNob3VsZExvY2spIHsKLSAgICAgICAgICAgIEVpdGhlcjxCb29sZWFuLCBSZXNwb25zZUZvcm1hdD4gbG9ja0NvbXBvbmVudCA9IGxvY2tDb21wb25lbnQocGFyZW50LCAiVXBsb2FkIEFydGlmYWN0IC0gbG9jayAiKTsKLSAgICAgICAgICAgIGlmIChsb2NrQ29tcG9uZW50LmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgIGhhbmRsZUF1ZGl0aW5nKGF1ZGl0aW5nQWN0aW9uLCBwYXJlbnQsIGNvbXBvbmVudElkLCB1c2VyLCBudWxsLCBudWxsLCBudWxsLCBsb2NrQ29tcG9uZW50LnJpZ2h0KCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC52YWx1ZSgpLCBjb21wb25lbnRUeXBlLCBudWxsKTsKLSAgICAgICAgICAgICAgICByZXR1cm4gRWl0aGVyLnJpZ2h0KGxvY2tDb21wb25lbnQucmlnaHQoKS52YWx1ZSgpKTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgfQotICAgICAgICBFaXRoZXI8RWl0aGVyPEFydGlmYWN0RGVmaW5pdGlvbiwgT3BlcmF0aW9uPiwgUmVzcG9uc2VGb3JtYXQ+IHJlc3VsdE9wID0gbnVsbDsKLQotICAgICAgICB0cnkgewotICAgICAgICAgICAgcmVzdWx0T3AgPSBjcmVhdGVBbmRMaW5rQXJ0aWZhY3QocGFyZW50LCBjb21wb25lbnRJZCwgYXJ0aWZhY3RJbmZvLCB1c2VyLCBjb21wb25lbnRUeXBlLCBhdWRpdGluZ0FjdGlvbik7Ci0gICAgICAgICAgICByZXR1cm4gcmVzdWx0T3A7Ci0gICAgICAgIH0KLSAgICAgICAgZmluYWxseSB7Ci0gICAgICAgICAgICBpZiAoc2hvdWxkTG9jaykgewotICAgICAgICAgICAgICAgIHVubG9ja0NvbXBvbmVudChyZXN1bHRPcCwgcGFyZW50LCBpblRyYW5zYWN0aW9uKTsKLSAgICAgICAgICAgIH0KLQotICAgICAgICB9Ci0KLSAgICB9Ci0KLSAgICBwcml2YXRlIEVpdGhlcjxFaXRoZXI8QXJ0aWZhY3REZWZpbml0aW9uLCBPcGVyYXRpb24+LCBSZXNwb25zZUZvcm1hdD4gbG9ja0NvbXBvbmVudEFuZFVwZGF0ZUFydGlmYWN0KFN0cmluZyBwYXJlbnRJZCwgQXJ0aWZhY3REZWZpbml0aW9uIGFydGlmYWN0SW5mbywgQXVkaXRpbmdBY3Rpb25FbnVtIGF1ZGl0aW5nQWN0aW9uLCBTdHJpbmcgYXJ0aWZhY3RJZCwgVXNlciB1c2VyLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29tcG9uZW50VHlwZUVudW0gY29tcG9uZW50VHlwZSwgb3JnLm9wZW5lY29tcC5zZGMuYmUubW9kZWwuQ29tcG9uZW50IHBhcmVudCwgYnl0ZVtdIGRlY29kZWRQYXlsb2FkLCBTdHJpbmcgaW50ZXJmYWNlVHlwZSwgU3RyaW5nIG9wZXJhdGlvbk5hbWUsIGJvb2xlYW4gc2hvdWxkTG9jaywgYm9vbGVhbiBpblRyYW5zYWN0aW9uKSB7Ci0KLSAgICAgICAgY29udmVydFBhcmVudFR5cGUoY29tcG9uZW50VHlwZSk7Ci0KLSAgICAgICAgLy8gbG9jayByZXNvdXJjZQotICAgICAgICBpZiAoc2hvdWxkTG9jaykgewotICAgICAgICAgICAgRWl0aGVyPEJvb2xlYW4sIFJlc3BvbnNlRm9ybWF0PiBsb2NrQ29tcG9uZW50ID0gbG9ja0NvbXBvbmVudChwYXJlbnQsIFVQREFURV9BUlRJRkFDVF9MT0NLKTsKLQotICAgICAgICAgICAgaWYgKGxvY2tDb21wb25lbnQuaXNSaWdodCgpKSB7Ci0gICAgICAgICAgICAgICAgaGFuZGxlQXVkaXRpbmcoYXVkaXRpbmdBY3Rpb24sIHBhcmVudCwgcGFyZW50SWQsIHVzZXIsIG51bGwsIG51bGwsIGFydGlmYWN0SWQsIGxvY2tDb21wb25lbnQucmlnaHQoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC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25zZUZvcm1hdCByZXNwb25zZUZvcm1hdCwgQ29tcG9uZW50VHlwZUVudW0gY29tcG9uZW50VHlwZUVudW0sIFN0cmluZyByZXNvdXJjZUluc3RhbmNlTmFtZSkgewogCiAgICAgICAgIGlmIChjb21wb25lbnRzVXRpbHMuaXNFeHRlcm5hbEFwaUV2ZW50KGF1ZGl0aW5nQWN0aW9uRW51bSkpIHsKICAgICAgICAgICAgIHJldHVybjsKQEAgLTEwNzcsMTAgKzk4MCwxMCBAQAogCiAgICAgcHJpdmF0ZSBTdHJpbmcgZ2V0UmVzb3VyY2VJbnN0YW5jZU5hbWVGcm9tQ29tcG9uZW50KENvbXBvbmVudCBjb21wb25lbnQsIFN0cmluZyBjb21wb25lbnRJZCkgewogICAgICAgICBDb21wb25lbnRJbnN0YW5jZSByZXNvdXJjZUluc3RhbmNlID0gY29tcG9uZW50LmdldENvbXBvbmVudEluc3RhbmNlcygpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuc3RyZWFtKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5maWx0ZXIocCAtPiBwLmdldFVuaXF1ZUlkKCkuZXF1YWxzKGNvbXBvbmVudElkKSkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5maW5kRmlyc3QoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLm9yRWxzZShudWxsKTsKKyAgICAgICAgICAgICAgICAuc3RyZWFtKCkKKyAgICAgICAgICAgICAgICAuZmlsdGVyKHAgLT4gcC5nZXRVbmlxdWVJZCgpLmVxdWFscyhjb21wb25lbnRJZCkpCisgICAgICAgICAgICAgICAgLmZpbmRGaXJzdCgpCisgICAgICAgICAgICAgICAgLm9yRWxzZShudWxsKTsKICAgICAgICAgU3RyaW5nIHJlc291cmNlSW5zdGFuY2VOYW1lID0gbnVsbDsKICAgICAgICAgaWYgKHJlc291cmNlSW5zdGFuY2UgIT0gbnVsbCkgewogICAgICAgICAgICAgcmVzb3VyY2VJbnN0YW5jZU5hbWUgPSByZXNvdXJjZUluc3RhbmNlLmdldE5hbWUoKTsKQEAgLTEwODgsODMgKzk5MSw0MCBAQAogICAgICAgICByZXR1cm4gcmVzb3VyY2VJbnN0YW5jZU5hbWU7CiAgICAgfQogCi0gICAgcHJpdmF0ZSBTdHJpbmcgYnVpbGRBdWRpdGluZ0FydGlmYWN0RGF0YShBcnRpZmFjdERlZmluaXRpb24gYXJ0aWZhY3REZWZpbml0aW9uKSB7Ci0gICAgICAgIFN0cmluZ0J1aWxkZXIgc2IgPSBuZXcgU3RyaW5nQnVpbGRlcigpOwotICAgICAgICBpZiAoYXJ0aWZhY3REZWZpbml0aW9uICE9IG51bGwpIHsKLSAgICAgICAgICAgIHNiLmFwcGVuZChhcnRpZmFjdERlZmluaXRpb24uZ2V0QXJ0aWZhY3RHcm91cFR5cGUoKS5nZXRUeXBlKCkpCi0gICAgICAgICAgICAgIC5hcHBlbmQoIiwiKQotICAgICAgICAgICAgICAuYXBwZW5kKCInIikKLSAgICAgICAgICAgICAgLmFwcGVuZChhcnRpZmFjdERlZmluaXRpb24uZ2V0QXJ0aWZhY3RMYWJlbCgpKQotICAgICAgICAgICAgICAuYXBwZW5kKCInIikKLSAgICAgICAgICAgICAgLmFwcGVuZCgiLCIpCi0gICAgICAgICAgICAgIC5hcHBlbmQoYXJ0aWZhY3REZWZpbml0aW9uLmdldEFydGlmYWN0VHlwZSgpKQotICAgICAgICAgICAgICAuYXBwZW5kKCIsIikKLSAgICAgICAgICAgICAgLmFwcGVuZChhcnRpZmFjdERlZmluaXRpb24uZ2V0QXJ0aWZhY3ROYW1lKCkpCi0gICAgICAgICAgICAgIC5hcHBlbmQoIiwiKQotICAgICAgICAgICAgICAuYXBwZW5kKGFydGlmYWN0RGVmaW5pdGlvbi5nZXRUaW1lb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ZhY3RJbmZvLmdldEFydGlmYWN0VHlwZSgpKTsKICAgICAgICAgfQogICAgICAgICBlbHNlIGlmIChwYXJlbnRDb21wb25lbnRUeXBlID09IENvbXBvbmVudFR5cGVFbnVtLlJFU09VUkNFICYmIGdyb3VwVHlwZSA9PSBBcnRpZmFjdEdyb3VwVHlwZUVudW0uSU5GT1JNQVRJT05BTCkgewogICAgICAgICAgICAgU3RyaW5nIGFydGlmYWN0VHlwZU5hbWUgPSBhcnRpZmFjdFR5cGUuZ2V0VHlwZSgpOwogICAgICAgICAgICAgUmVzb3VyY2VUeXBlRW51bSBwYXJlbnRSZXNvdXJjZVR5cGUgPSAoKFJlc291cmNlKSBwYXJlbnRDb21wb25lbnQpLmdldFJlc291cmNlVHlwZSgpOwogICAgICAgICAgICAgTWFwPFN0cmluZywgQXJ0aWZhY3RUeXBlQ29uZmlnPiByZXNvdXJjZUluZm9ybWF0aW9uYWxBcnRpZmFjdHMgPSBDb25maWd1cmF0aW9uTWFuYWdlci5nZXRDb25maWd1cmF0aW9uTWFuYWdlcigpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldENvbmZpZ3VyYXRpb24oKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRSZXNvdXJjZUluZm9ybWF0aW9uYWxBcnRpZmFjdHMoKTsKKyAgICAgICAgICAgICAgICAgICAgLmdldENvbmZpZ3VyYXRpb24oKQorICAgICAgICAgICAgICAgICAgICAuZ2V0UmVzb3VyY2VJbmZvcm1hdGlvbmFsQXJ0aWZhY3RzKCk7CiAgICAgICAgICAgICBTZXQ8U3RyaW5nPiB2YWxpZEFydGlmYWN0VHlwZXMgPSByZXNvdXJjZUluZm9ybWF0aW9uYWxBcnRpZmFjdHMua2V5U2V0KCk7CiAgICAgICAgICAgICBpZiAoIXZhbGlkQXJ0aWZhY3RUeXBlcy5jb250YWlucyhhcnRpZmFjdFR5cGVOYW1lKSkgewotICAgICAgICAgICAgICAgIHZhbGlkYXRpb25SZXN1bHQgPSBFaXRoZXIucmlnaHQoY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5BUlRJRkFDVF9UWVBFX05PVF9TVVBQT1JURUQsIGFydGlmYWN0VHlwZU5hbWUpKTsKKyAgICAgICAgICAgICAgICB0aHJvdyBuZXcgQnlBY3Rpb25TdGF0dXNDb21wb25lbnRFeGNlcHRpb24oQWN0aW9uU3RhdHVzLkFSVElGQUNUX1RZUEVfTk9UX1NVUFBPUlRFRCwgYXJ0aWZhY3RUeXBlTmFtZSk7CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgICAgICBMaXN0PFN0cmluZz4gdmFsaWRSZXNvdXJjZVR5cGUgPSByZXNvdXJjZUluZm9ybWF0aW9uYWxBcnRpZmFjdHMuZ2V0KGFydGlmYWN0VHlwZU5hbWUpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldFZhbGlkRm9yUmVzb3VyY2VUeXBlcygpOworICAgICAgICAgICAgICAgICAgICAgICAgLmdldFZhbGlkRm9yUmVzb3VyY2VUeXBlcygpOwogICAgICAgICAgICAgICAgIGlmICghdmFsaWRSZXNvdXJjZVR5cGUuY29udGFpbnMocGFyZW50UmVzb3VyY2VUeXBlLm5hbWUoKSkpIHsKLSAgICAgICAgICAgICAgICAgICAgdmFsaWRhdGlvblJlc3VsdCA9IEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLkFSVElGQUNUX1RZUEVfTk9UX1NVUFBPUlRFRCwgYXJ0aWZhY3RUeXBlTmFtZSkpOworICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgQnlBY3Rpb25TdGF0dXNDb21wb25lbnRFeGNlcHRpb24oQWN0aW9uU3RhdHVzLkFSVElGQUNUX1RZUEVfTk9UX1NVUFBPUlRFRCwgYXJ0aWZhY3RUeXBlTmFtZSk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogICAgICAgICB9Ci0gICAgICAgIHJldHVybiB2YWxpZGF0aW9uUmVzdWx0OwogICAgIH0KIAogICAgIHByaXZhdGUgTm9kZVR5cGVFbnVtIGNvbnZlcnRQYXJlbnRUeXBlKENvbXBvbmVudFR5cGVFbnVtIGNvbXBvbmVudFR5cGUpIHsKLSAgICAgICAgaWYgKGNvbXBvbmVudFR5cGUuZXF1YWxzKENvbXBvbmVudFR5cGVFbnVtLlJFU09VUkNFKSkgeworICAgICAgICBpZiAoY29tcG9uZW50VHlwZSA9PSBDb21wb25lbnRUeXBlRW51bS5SRVNPVVJDRSkgewogICAgICAgICAgICAgcmV0dXJuIE5vZGVUeXBlRW51bS5SZXNvdXJjZTsKICAgICAgICAgfQotICAgICAgICBlbHNlIGlmIChjb21wb25lbnRUeXBlLmVxdWFscyhDb21wb25lbnRUeXBlRW51bS5SRVNPVVJDRV9JTlNUQU5DRSkpIHsKKyAgICAgICAgZWxzZSBpZiAoY29tcG9uZW50VHlwZSA9PSBDb21wb25lbnRUeXBlRW51bS5SRVNPVVJDRV9JTlNUQU5DRSkgewogICAgICAgICAgICAgcmV0dXJuIE5vZGVUeXBlRW51bS5SZXNvdXJjZUluc3RhbmNlOwogICAgICAgICB9CiAgICAgICAgIGVsc2UgewpAQCAtMTMzOCwyMTMgKzExODksMTMzIEBACiAgICAgICAgIH0KICAgICB9CiAKKyAgICAvLyBUaGlzIG1ldGhvZCBpcyBoZXJlIGZvciBiYWNrd2FyZCBjb21wYXRpYmlsaXR5IC0gd2hlbiBvdGhlciBwYXJ0c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0gICAgICAgIEVpdGhlcjxvcmcub3BlbmVjb21wLnNkYy5iZS5tb2RlbC5Db21wb25lbnQsIFN0b3JhZ2VPcGVyYXRpb25TdGF0dXM+IGdldENvbnRhaW5lclJlcyA9IG51bGw7Ci0gICAgICAgIG9yZy5vcGVuZWNvbXAuc2RjLmJlLm1vZGVsLkNvbXBvbmVudCBmZXRjaGVkQ29udGFpbmVyQ29tcG9uZW50ID0gbnVsbDsKLSAgICAgICAgYm9vbGVhbiBpc0R1cGxpY2F0ZWQgPSBmYWxzZTsKLSAgICAgICAgU3RyaW5nIGVzSWQgPSBudWxsOwotICAgICAgICBFaXRoZXI8Qm9vbGVhbiwgU3RvcmFnZU9wZXJhdGlvblN0YXR1cz4gbmVlZENsb25lUmVzID0gbnVsbDsKLSAgICAgICAgdHJ5IHsKLSAgICAgICAgICAgIGlmIChzaG91bGRMb2NrKSB7Ci0gICAgICAgICAgICAgICAgRWl0aGVyPEJvb2xlYW4sIFJlc3BvbnNlRm9ybWF0PiBsb2NrQ29tcG9uZW50ID0gbG9ja0NvbXBvbmVudChwYXJlbnQsICJEZWxldGUgQXJ0aWZhY3QgLSBsb2NrIHJlc291cmNlOiAiKTsKLSAgICAgICAgICAgICAgICBpZiAobG9ja0NvbXBvbmVudC5pc1JpZ2h0KCkpIHsKLSAgICAgICAgICAgICAgICAgICAgaGFuZGxlQXVkaXRpbmcoYXVkaXRpbmdBY3Rpb24sIHBhcmVudCwgcGFyZW50SWQsIHVzZXIsIG51bGwsIG51bGwsIGFydGlmYWN0SWQsIGxvY2tDb21wb25lbnQucmlnaHQoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC52YWx1ZSgpLCBjb21wb25lbnRUeXBlLCBudWxsKTsKLSAgICAgICAgICAgICAgICAgICAgcmVzdWx0T3AgPSBFaXRoZXIucmlnaHQobG9ja0NvbXBvbmVudC5yaWdodCgpLnZhbHVlKCkpOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGlmIChyZXN1bHRPcCA9PSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJHb2luZyB0byBmZXRjaCB0aGUgY29udGFpbmVyIGNvbXBvbmVudCB7fS4gIiwgcGFyZW50LmdldFVuaXF1ZUlkKCkpOwotICAgICAgICAgICAgICAgIGdldENvbnRhaW5lclJlcyA9IHRvc2NhT3BlcmF0aW9uRmFjYWRlLmdldFRvc2NhRWxlbWVudChwYXJlbnQuZ2V0VW5pcXVlSWQoKSk7Ci0gICAgICAgICAgICAgICAgaWYgKGdldENvbnRhaW5lclJlcy5pc1JpZ2h0KCkpIHsKLSAgICAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJGYWlsZWQgdG8gZmV0Y2ggdGhlIGNvbnRhaW5lciBjb21wb25lbnQge30uICIsIHBhcmVudElkKTsKLSAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2VGb3JtYXQgPSBjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXRCeUFydGlmYWN0SWQoY29tcG9uZW50c1V0aWxzLmNvbnZlcnRGcm9tU3RvcmFnZVJlc3BvbnNlKGdldENvbnRhaW5lclJlcwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5yaWdodCgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgLnZhbHVlKCkpLCBhcnRpZmFjdElkKTsKLSAgICAgICAgICAgICAgICAgICAgaGFuZGxlQXVkaXRpbmcoYXVkaXRpbmdBY3Rpb24sIHBhcmVudCwgcGFyZW50SWQsIHVzZXIsIG51bGwsIG51bGwsIGFydGlmYWN0SWQsIHJlc3BvbnNlRm9ybWF0LCBjb21wb25lbnRUeXBlLCBudWxsKTsKLSAgICAgICAgICAgICAgICAgICAgcmVzdWx0T3AgPSBFaXRoZXIucmlnaHQocmVzcG9uc2VGb3JtYXQpOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGlmIChyZXN1bHRPcCA9PSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgZmV0Y2hlZENvbnRhaW5lckNvbXBvbmVudCA9IGdldENvbnRhaW5lclJlcy5sZWZ0KCkudmFsdWUoKTsKLSAgICAgICAgICAgICAgICBsb2cuZGVidWcoIkdvaW5nIHRvIGZpbmQgdGhlIGFydGlmYWN0IHt9IG9uIHRoZSBjb21wb25lbnQge30iLCBhcnRpZmFjdElkLCBmZXRjaGVkQ29udGFpbmVyQ29tcG9uZW50LmdldFVuaXF1ZUlkKCkpOwotICAgICAgICAgICAgICAgIGdldEFydGlmYWN0UmVzID0gZmluZEFydGlmYWN0KGFydGlmYWN0SWQsIGZldGNoZWRDb250YWluZXJDb21wb25lbnQsIHBhcmVudElkLCBjb21wb25lbnRUeXBlKTsKLSAgICAgICAgICAgICAgICBpZiAoZ2V0QXJ0aWZhY3RSZXMuaXNSaWdodCgpKSB7Ci0gICAgICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiRmFpbGVkIHRvIGZpbmQgdGhlIGFydGlmYWN0IHt9IGJlbG9uZ2luZyB0byB7fSBvbiB0aGUgY29tcG9uZW50IHt9IiwgYXJ0aWZhY3RJZCwgcGFyZW50SWQsIGZldGNoZWRDb250YWluZXJDb21wb25lbnQKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0VW5pcXVlSWQoKSk7Ci0gICAgICAgICAgICAgICAgICAgIHJlc3BvbnNlRm9ybWF0ID0gY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0QnlBcnRpZmFjdElkKGdldEFydGlmYWN0UmVzLnJpZ2h0KCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAudmFs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CwgaW5zdGFuY2VJZCk7Ci0KLSAgICAgICAgICAgICAgICAgICAgaWYgKGlzT25seVJlc291cmNlSW5zdGFuY2VBcnRpZmFjdC5pc1JpZ2h0KCkpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZyhGQUlMRURfVVBEQVRFX0FSVElGQUNULCBhcnRpZmFjdElkLCBwYXJlbnRJZCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICByZXNwb25zZUZvcm1hdCA9IGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdEJ5QXJ0aWZhY3RJZChpc09ubHlSZXNvdXJjZUluc3RhbmNlQXJ0aWZhY3QucmlnaHQoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnZhbHVlKCksIGZvdW5kQXJ0aWZhY3QKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldEFydGlmYWN0RGlzcGxheU5hbWUoKSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBoYW5kbGVBdWRpdGluZyhhdWRpdGluZ0FjdGlvbiwgcGFyZW50LCBwYXJlbnRJZCwgdXNlciwgbnVsbCwgbnVsbCwgYXJ0aWZhY3RJZCwgcmVzcG9uc2VGb3JtYXQsIGNvbXBvbmVudFR5cGUsIG51bGwpOwotICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChyZXNwb25zZUZvcm1hdCk7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgaXNOZWVkVG9EZWxldGVBcnRpZmFjdEZyb21EQiA9IGlzT25seVJlc291cmNlSW5zdGFuY2VBcnRpZmFjdC5sZWZ0KCkudmFsdWUoKTsKLSAgICAgICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgICAgICBFaXRoZX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vblN0YXR1cyhjYXNzYW5kcmFTdGF0dXMpKSwgZm91bmRBcnRpZmFjdAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRBcnRpZmFjdERpc3BsYXlOYW1lKCkpOwotICAgICAgICAgICAgICAgICAgICBoYW5kbGVBdWRpdGluZyhhdWRpdGluZ0FjdGlvbiwgcGFyZW50LCBwYXJlbnRJZCwgdXNlciwgbnVsbCwgbnVsbCwgYXJ0aWZhY3RJZCwgcmVzcG9uc2VGb3JtYXQsIGNvbXBvbmVudFR5cGUsIG51bGwpOwotICAgICAgICAgICAgICAgICAgICByZXN1bHRPcCA9IEVpdGhlci5yaWdodChyZXNwb25zZUZvcm1hdCk7Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgfQotICAgICAgICAgICAgaWYgKHJlc3VsdE9wID09IG51bGwgJiYgY29tcG9uZW50VHlwZSA9PSBDb21wb25lbnRUeXBlRW51bS5SRVNPVVJDRV9JTlNUQU5DRSkgewotCi0gICAgICAgICAgICAgICAgTGlzdDxHcm91cEluc3RhbmNlPiB1cGRhdGVkR3JvdXBJbnN0YW5jZXMgPSBnZXRVcGRhdGVkR3JvdXBJbnN0YW5jZXMoYXJ0aWZhY3RJZCwgZm91bmRBcnRpZmFjdCwgZ2V0QXJ0aWZhY3RSZXMKLSAgICAgICAgICAgICAgICAgICAgICAgIC5sZWZ0KCkKLSAgICAgICAgICAgICAgICAgICAgICAgIC52YWx1ZSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAuZ2V0UmlnaHQoKQotICAgICAgICAgICAgICAgICAgICAgICAgLmdldEdyb3VwSW5zdGFuY2VzKCkpOwotICAgICAgICAgICAgICAgIGlmIChDb2xsZWN0aW9uVXRpbHMuaXNOb3RFbXB0eSh1cGRhdGVkR3JvdXBJbnN0YW5jZXMpKSB7Ci0gICAgICAgICAgICAgICAgICAgIEVpdGhlcjxMaXN0PEdyb3VwSW5zdGFuY2U+LCBTdG9yYWdlT3BlcmF0aW9uU3RhdHVzPiBzdGF0dXMgPSB0b3NjYU9wZXJhdGlvbkZhY2FkZS51cGRhdGVHcm91cEluc3RhbmNlc09uQ29tcG9uZW50KGZldGNoZWRDb250YWluZXJDb21wb25lbnQsIHBhcmVudElkLCB1cGRhdGVkR3JvdXBJbnN0YW5jZXMpOwotICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdHVzLmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKEZBSUxFRF9VUERBVEVfR1JPVVBTLCBmZXRjaGVkQ29udGFpbmVyQ29tcG9uZW50LmdldFVuaXF1ZUlkKCkpOwotICAgICAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2VGb3JtYXQgPSBjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXRCeUFydGlmYWN0SWQoY29tcG9uZW50c1V0aWxzLmNvbnZlcnRGcm9tU3RvcmFnZVJlc3BvbnNlKHN0YXR1cwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAucmlnaHQoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAudmFsdWUoKSksIGZvdW5kQXJ0aWZhY3QuZ2V0QXJ0aWZhY3REaXNwbGF5TmFtZSgpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGhhbmRsZUF1ZGl0aW5nKGF1ZGl0aW5nQWN0aW9uLCBwYXJlbnQsIHBhcmVudElkLCB1c2VyLCBudWxsLCBudWxsLCBhcnRpZmFjdElkLCByZXNwb25zZUZvcm1hdCwgY29tcG9uZW50VHlwZSwgbnVsbCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICByZXN1bHRPcCA9IEVpdGhlci5yaWdodChyZXNwb25zZUZvcm1hdCk7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBpZiAocmVzdWx0T3AgPT0gbnVsbCAmJiBjb21wb25lbnRUeXBlID09IENv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GlmYWN0RGlzcGxheU5hbWUoKSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBoYW5kbGVBdWRpdGluZyhhdWRpdGluZ0FjdGlvbiwgcGFyZW50LCBwYXJlbnRJZCwgdXNlciwgbnVsbCwgbnVsbCwgYXJ0aWZhY3RJZCwgcmVzcG9uc2VGb3JtYXQsIGNvbXBvbmVudFR5cGUsIG51bGwpOwotICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0T3AgPSBFaXRoZXIucmlnaHQocmVzcG9uc2VGb3JtYXQpOwotICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgfQotICAgICAgICAgICAgaWYgKHJlc3VsdE9wID09IG51bGwpIHsKLSAgICAgICAgICAgICAgICByZXN1bHRPcCA9IEVpdGhlci5sZWZ0KEVpdGhlci5sZWZ0KGZvdW5kQXJ0aWZhY3QpKTsKLSAgICAgICAgICAgICAgICBoYW5kbGVBdWRpdGluZyhhdWRpdGluZ0FjdGlvbiwgcGFyZW50LCBwYXJlbnRJZCwgdXNlciwgZm91bmRBcnRpZmFjdCwgbnVsbCwgYXJ0aWZhY3RJZCwgcmVzcG9uc2VGb3JtYXQsIGNvbXBvbmVudFR5cGUsIG51bGwpOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgcmV0dXJuIHJlc3VsdE9wOworICAgICAgICBSZXNwb25zZUZvcm1hdCByZXNwb25zZUZvcm1hdDsKKyAgICAgICAgYm9vbGVhbiBvcGVyYXRpb25TdWNjZWVkZWQgPSBmYWxzZTsKKyAgICAgICAgaWYgKHNob3VsZExvY2spIHsKKyAgICAgICAgICAgIGxvY2tDb21wb25lbnQoY29tcG9uZW50VHlwZSwgYXJ0aWZhY3RJZCwgYXVkaXRpbmdBY3Rpb24sIHVzZXIsIHBhcmVudCk7CiAgICAgICAgIH0KLSAgICAgICAgZmluYWxseSB7Ci0gICAgICAgICAgICBpZiAoc2hvdWxkTG9jaykgewotICAgICAgICAgICAgIC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GNvbXBvbmVudFR5cGUsIG51bGwpOworICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChyZXNwb25zZUZvcm1hdCk7CisgICAgICAgIH0gZmluYWxseSB7CisgICAgICAgICAgICBoYW5kbGVMb2NraW5nQW5kQ29tbWl0KHBhcmVudCwgc2hvdWxkTG9jaywgaW5UcmFuc2FjdGlvbiwgb3BlcmF0aW9uU3VjY2VlZGVkKTsKICAgICAgICAgfQogICAgIH0KIAotICAgIHByaXZhdGUgRWl0aGVyPEJvb2xlYW4sIEFjdGlvblN0YXR1cz4gaXNBcnRpZmFjdE9ubHlSZXNvdXJjZUluc3RhbmNlQXJ0aWZhY3QoQXJ0aWZhY3REZWZpbml0aW9uIGZvdW5kQXJ0aWZhY3QsIENvbXBvbmVudCBwYXJlbnQsIFN0cmluZyBpbnN0YW5jZUlkKSB7Ci0gICAgICAgIEVpdGhlcjxCb29sZWFuLCBBY3Rpb25TdGF0dXM+IHJlc3VsdCA9IEVpdGhlci5sZWZ0KHRydWUpOwotICAgICAgICBDb21wb25lbnRJbnN0YW5jZSBmb3VuZEluc3RhbmNlID0gbnVsbDsKLSAgICAgICAgT3B0aW9uYWw8Q29tcG9uZW50SW5zdGFuY2U+IGNvbXBvbmVudEluc3RhbmNlT3B0ID0gcGFyZW50LmdldENvbXBvbmVudEluc3RhbmNlcygpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5zdHJlYW0oKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZmlsdGVyKGkgLT4gaS5nZXRVbmlxdWVJZCgpLmVxdWFscyhpbnN0YW5jZUlkKSkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmZpbmRGaXJzdCgpOwotICAgICAgICBpZiAoIWNvbXBvbmVudEluc3Rh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UoKTsKLSAgICAgICAgICAgIE1hcDxTdHJpbmcsIEFydGlmYWN0RGVmaW5pdGlvbj4gZGVwbG95bWVudEFydGlmYWN0cyA9IG9yaWdDb21wb25lbnQuZ2V0RGVwbG95bWVudEFydGlmYWN0cygpOwotICAgICAgICAgICAgaWYgKGRlcGxveW1lbnRBcnRpZmFjdHMgIT0gbnVsbCAmJiAhZGVwbG95bWVudEFydGlmYWN0cy5pc0VtcHR5KCkpIHsKLSAgICAgICAgICAgICAgICBPcHRpb25hbDxTdHJpbmc+IG9wID0gZGVwbG95bWVudEFydGlmYWN0cy5rZXlTZXQoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnN0cmVhbSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZmlsdGVyKGEgLT4gYS5lcXVhbHMoZm91bmRBcnRpZmFjdC5nZXRBcnRpZmFjdExhYmVsKCkpKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmZpbmRBbnkoKTsKLSAgICAgICAgICAgICAgICBpZiAob3AuaXNQcmVzZW50KCkpIHsKLSAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5sZWZ0KGZhbHNlKTsKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBNYXA8U3RyaW5nLCBBcnRpZmFjdERlZmluaXRpb24+IGFydGlmYWN0cyA9IG9yaWdDb21wb25lbnQuZ2V0QXJ0aWZhY3RzKCk7Ci0gICAgICAgICAgICBpZiAoYXJ0aWZhY3RzICE9IG51bGwgJiYgIWFydGlmYWN0cy5pc0VtcHR5KCkpIHsKLSAgICAgICAgICAgICAgICBPcHRpb25hbDxTdHJpbmc+IG9wID0gYXJ0aWZhY3RzLmtleVNldCgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5zdHJlYW0oKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZmlsdGVyKGEgLT4gYS5lcXVhbHMoZm91bmRBcnRpZmFjdC5nZXRBcnRpZmFjdExhYmVsKCkpKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZmluZEFueSgpOwotICAgICAgICAgICAgICAgIGlmIChvcC5pc1ByZXNlbnQoKSkgewotICAgICAgICAgICAgICAgICAgICByZXR1cm4gRWl0aGVyLmxlZnQoZmFsc2UpOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgICAgICBib29sZWFuIGlzTmVlZFRvRGVsZXRlQXJ0aWZhY3RGcm9tREIgPSB0cnVlOworICAgICAgICBib29sZWFuIGlzRHVwbGljYXRlZCA9IGZhbHNlOworICAgICAgICBpZiAoY29tcG9uZW50VHlwZSA9PSBDb21wb25lbnRUeXBlRW51bS5SRVNPVVJDRV9JTlNUQU5DRSkgeworICAgICAgICAgICAgaXNOZWVkVG9EZWxldGVBcnRpZmFjdEZyb21EQiA9IGlzQXJ0aWZhY3RPbmx5UmVzb3VyY2VJbnN0YW5jZUFydGlmYWN0KGZvdW5kQXJ0aWZhY3QsIHBhcmVudCwgcGFyZW50SWQpOworICAgICAgICB9CisgICAgICAgIEFydGlmYWN0RGF0YURlZmluaXRpb24gdXBkYXRlZEFydGlmYWN0ID0gZGVsZXRlT3JVcGRhdGVBcnRpZmFjdE9uR3JhcGgocGFyZW50LCBwYXJlbnRJZCwgYXJ0aWZhY3RJZCwgcGFyZW50VHlwZSwgZm91bmRBcnRpZmFjdCwgbmVlZFRvQ2xvbmUpOworICAgICAgICBpc0R1cGxpY2F0ZWQgPSB1cGRhdGVkQXJ0aWZhY3QuZ2V0RHVwbGljYXRlZCgpOwogCisgICAgICAgIGlmICghbmVlZFRvQ2xvbmUgJiYgIWlzRHVwbGljYXRlZ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JpZ0NvbXBvbmVudCA9IGdldENvbnRhaW5lclJlcy5sZWZ0KCkudmFsdWUoKTsKKyAgICAgICAgTWFwPFN0cmluZywgQXJ0aWZhY3REZWZpbml0aW9uPiBkZXBsb3ltZW50QXJ0aWZhY3RzID0gb3JpZ0NvbXBvbmVudC5nZXREZXBsb3ltZW50QXJ0aWZhY3RzKCk7CisgICAgICAgIGlmIChNYXBVdGlscy5pc05vdEVtcHR5KGRlcGxveW1lbnRBcnRpZmFjdHMpKSB7CisgICAgICAgICAgICBPcHRpb25hbDxTdHJpbmc+IG9wID0gZGVwbG95bWVudEFydGlmYWN0cy5rZXlTZXQoKQorICAgICAgICAgICAgICAgICAgICAuc3RyZWFtKCkKKyAgICAgICAgICAgICAgICAgICAgLmZpbHRlcihhIC0+IGEuZXF1YWxzKGZvdW5kQXJ0aWZhY3QuZ2V0QXJ0aWZhY3RMYWJlbCgpKSkKKyAgICAgICAgICAgICAgICAgICAgLmZpbmRBbnkoKTsKKyAgICAgICAgICAgIGlmIChvcC5pc1ByZXNlbnQoKSkgeworICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgICAgICBNYXA8U3RyaW5nLCBBcnRpZmFjdERlZmluaXRpb24+IGFydGlmYWN0cyA9IG9yaWdDb21wb25lbnQuZ2V0QXJ0aWZhY3RzKCk7CisgICAgICAgIGlmIChNYXBVdGlscy5pc05vdEVtcHR5KGFydGlmYWN0cykpIHsKKyAgICAgICAgICAgIE9wdGlvbmFsPFN0cmluZz4gb3AgPSBhcnRpZmFjdHMua2V5U2V0KCkKKyAgICAgICAgICAgICAgICAgICAgLnN0cmVhbSgpCisgICAgICAgICAgICAgICAgICAgIC5maWx0ZXIoYSAtPiBhLmVxdWFscyhmb3VuZEFydGlmYWN0LmdldEFydGlmYWN0TGFiZWwoKSkpCisgICAgICAgICAgICAgICAgICAgIC5maW5kQW55KCk7CisgICAgICAgICAgICBpZiAob3AuaXNQcmVzZW50KCkpIHsKKyAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgfQogCiAgICAgcHJpdmF0ZSBMaXN0PEdyb3VwRGF0YURlZmluaXRpb24+IGdldFVwZGF0ZWRHcm91cHMoU3RyaW5nIGFydGlmYWN0SWQsIEFydGlmYWN0RGVmaW5pdGlvbiBmb3VuZEFydGlmYWN0LCBMaXN0PEdyb3VwRGVmaW5pdGlvbj4gZ3JvdXBzKSB7CkBAIC0xNTU4LDcgKzEzMjksNyBAQAogICAgICAgICAgICAgICAgICAgICBpc1VwZGF0ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBpZiAoQ29sbGVjdGlvblV0aWxzLmlzTm90RW1wdHkoZ3JvdXAuZ2V0QXJ0aWZhY3RzVXVpZCgpKSAmJiBncm91cC5nZXRBcnRpZmFjdHNVdWlkKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5jb250YWlucyhmb3VuZEFydGlmYWN0LmdldEFydGlmYWN0VVVJRCgpKSkgeworICAgICAgICAgICAgICAgICAgICAgICAgLmNvbnRhaW5zKGZvdW5kQXJ0aWZhY3QuZ2V0QXJ0aWZhY3RVVUlEKCkpKSB7CiAgICAgICAgICAgICAgICAgICAgIGdyb3VwLmdldEFydGlmYWN0c1V1aWQoKS5yZW1vdmUoZm91bmRBcnRpZmFjdC5nZXRBcnRpZmFjdFVVSUQoKSk7CiAgICAgICAgICAgICAgICAgICAgIGlzVXBkYXRlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgfQpAQCAtMTU3NiwxNCArMTM0NywxMiBAQAogICAgICAgICAgICAgYm9vbGVhbiBpc1VwZGF0ZWQgPSBmYWxzZTsKICAgICAgICAgICAgIGZvciAoR3JvdXBJbnN0YW5jZSBncm91cEluc3RhbmNlIDogZ3JvdXBJbnN0YW5jZXMpIHsKICAgICAgICAgICAgICAgICBpc1VwZGF0ZWQgPSBmYWxzZTsKLSAgICAgICAgICAgICAgICBpZiAoQ29sbGVjdGlvblV0aWxzLmlzTm90RW1wdHkoZ3JvdXBJbnN0YW5jZS5nZXRHcm91cEluc3RhbmNlQXJ0aWZhY3RzKCkpICYmIGdyb3VwSW5zdGFuY2UuZ2V0R3JvdXBJbnN0YW5jZUFydGlmYWN0cygpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmNvbnRhaW5zKGFydGlmYWN0SWQpKSB7CisgICAgICAgICAgICAgICAgaWYgKENvbGxlY3Rpb25VdGlscy5pc05vdEVtcHR5KGdyb3VwSW5zdGFuY2UuZ2V0R3JvdXBJbnN0YW5jZUFydGlmYWN0cygpKSAmJiBncm91cEluc3RhbmNlLmdldEdyb3VwSW5zdGFuY2VBcnRpZmFjdHMoKS5jb250YWlucyhhcnRpZmFjdElkKSkgewogICAgICAgICAgICAgICAgICAgICBncm91cEluc3RhbmNlLmdldEdyb3VwSW5zdGFuY2VBcnRpZmFjdHMoKS5yZW1vdmUoYXJ0aWZhY3RJZCk7CiAgICAgICAgICAgICAgICAgICAgIGlzVXBkYXRlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIGlmIChDb2xsZWN0aW9uVXRpbHMuaXNOb3RFbXB0eShncm91cEluc3RhbmNlLmdldEdyb3VwSW5zdGFuY2VBcnRpZmFjdHNVdWlkKCkpICYmIGdyb3VwSW5zdGFuY2UuZ2V0R3JvdXBJbnN0YW5jZUFydGlmYWN0c1V1aWQoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuY29udGFpbnMoZm91bmRBcnRpZmFjdAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRBcnRpZmFjdFVVSUQoKSkpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIC5jb250YWlucyhmb3VuZEFydGlmYWN0LmdldEFydGlmYWN0VVVJRCgpKSkgewogICAgICAgICAgICAgICAgICAgICBncm91cEluc3RhbmNlLmdldEdyb3VwSW5zdGFuY2VBcnRpZmFjdHNVdWlkKCkucmVtb3ZlKGZvdW5kQXJ0aWZhY3QuZ2V0QXJ0aWZhY3RVVUlEKCkpOwogICAgICAgICAgICAgICAgICAgICBpc1VwZGF0ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgIH0KQEAgLTE1OTUsNyArMTM2NCw3IEBACiAgICAgICAgIHJldHVybiB1cGRhdGVkR3JvdXBJbnN0YW5jZXM7CiAgICAgfQogCi0gICAgcHJpdmF0ZSBFaXRoZXI8QXJ0aWZhY3REYXRhRGVmaW5pdGlvbiwgU3RvcmFnZU9wZXJhdGlvblN0YXR1cz4gZGVsZXRlT3JVcGRhdGVBcnRpZmFjdE9uR3JhcGgoQ29tcG9uZW50IGNvbXBvbmVudCwgU3RyaW5nIHBhcmVudElkLCBTdHJpbmcgYXJ0aWZhY3RJZCwgTm9kZVR5cGVFbnVtIHBhcmVudFR5cGUsIEFydGlmYWN0RGVmaW5pdGlvbiBmb3VuZEFydGlmYWN0LCBCb29sZWFuIGNsb25lSXNOZWVkZWQpIHsKKyAgICBwcml2YXRlIEFydGlmYWN0RGF0YURlZmluaXRpb24gZGVsZXRlT3JVcGRhdGVBcnRpZmFjdE9uR3JhcGgoQ29tcG9uZW50IGNvbXBvbmVudCwgU3RyaW5nIHBhcmVudElkLCBTdHJpbmcgYXJ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xMzk2LDEwIEBACiAgICAgICAgIENvbXBvbmVudEluc3RhbmNlIGZvdW5kSW5zdGFuY2UgPSBudWxsOwogICAgICAgICBpZiAoY29tcG9uZW50VHlwZSA9PSBDb21wb25lbnRUeXBlRW51bS5SRVNPVVJDRV9JTlNUQU5DRSAmJiBTdHJpbmdVdGlscy5pc05vdEVtcHR5KHBhcmVudElkKSkgewogICAgICAgICAgICAgT3B0aW9uYWw8Q29tcG9uZW50SW5zdGFuY2U+IGNvbXBvbmVudEluc3RhbmNlT3B0ID0gZmV0Y2hlZENvbnRhaW5lckNvbXBvbmVudC5nZXRDb21wb25lbnRJbnN0YW5jZXMoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5zdHJlYW0oKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5maWx0ZXIoaSAtPiBpLmdldFVuaXF1ZUlkKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5lcXVhbHMocGFyZW50SWQpKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5maW5kRmlyc3QoKTsKKyAgICAgICAgICAgICAgICAgICAgLnN0cmVhbSgpCisgICAgICAgICAgICAgICAgICAgIC5maWx0ZXIoaSAtPiBpLmdldFVuaXF1ZUlkKCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZXF1YWxzKHBhcmVudElkKSkKKyAgICAgICAgICAgICAgICAgICAgLmZpbmRGaXJzdCgpOwogICAgICAgICAgICAgaWYgKCFjb21wb25lbnRJbnN0YW5jZU9wdC5pc1ByZXNlbnQoKSkgewogICAgICAgICAgICAgICAgIHJlc3VsdCA9IEVpdGhlci5yaWdodChBY3Rpb25TdGF0dXMuQ09NUE9ORU5UX0lOU1RBTkNFX05PVF9GT1VORF9PTl9DT05UQUlORVIpOwogICAgICAgICAgICAgfQpAQCAtMTY1NCwyNyArMTQyNiwyNyBAQAogICAgICAgICBNYXA8U3RyaW5nLCBBcnRpZmFjdERlZmluaXRpb24+IGN1cnJBcnRpZmFjdHM7CiAgICAgICAgIGlmICghYXJ0aWZhY3RzLmNvbnRhaW5zS2V5KGFydGlmYWN0SWQpICYmIE1hcFV0aWxzLmlzTm90RW1wdHkoY29tcG9uZW50LmdldERlcGxveW1lbnRBcnRpZmFjdHMoKSkpIHsKICAgICAgICAgICAgIGN1cnJBcnRpZmFjdHMgPSBjb21wb25lbnQuZ2V0RGVwbG95bWVudEFydGlmYWN0cygpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnZhbHVlcygpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnN0cmVhbSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmNvbGxlY3QoQ29sbGVjdG9ycy50b01hcChpIC0+IGkuZ2V0VW5pcXVlSWQoKSwgaSAtPiBpKSk7CisgICAgICAgICAgICAgICAgICAgIC52YWx1ZXMoKQorICAgICAgICAgICAgICAgICAgICAuc3RyZWFtKCkKKyAgICAgICAgICAgICAgICAgICAgLmNvbGxlY3QoQ29sbGVjdG9ycy50b01hcChBcnRpZmFjdERhdGFEZWZpbml0aW9uOjpnZXRVbmlxdWVJZCwgaSAtPiBpKSk7CiAgICAgICAgICAgICBpZiAoTWFwVXRpbHMuaXNOb3RFbXB0eShjdXJyQXJ0aWZhY3RzKSkgewogICAgICAgICAgICAgICAgIGFydGlmYWN0cy5wdXRBbGwoY3VyckFydGlmYWN0cyk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICAgICAgaWYgKCFhcnRpZmFjdHMuY29udGFpbnNLZXkoYXJ0aWZhY3RJZCkgJiYgTWFwVXRpbHMuaXNOb3RFbXB0eShjb21wb25lbnQuZ2V0QXJ0aWZhY3RzKCkpKSB7CiAgICAgICAgICAgICBjdXJyQXJ0aWZhY3RzID0gY29tcG9uZW50LmdldEFydGlmYWN0cygpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnZhbHVlcygpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnN0cmVhbSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmNvbGxlY3QoQ29sbGVjdG9ycy50b01hcChpIC0+IGkuZ2V0VW5pcXVlSWQoKSwgaSAtPiBpKSk7CisgICAgICAgICAgICAgICAgICAgIC52YWx1ZXMoKQorICAgICAgICAgICAgICAgICAgICAuc3RyZWFtKCkKKyAgICAgICAgICAgICAgICAgICAgLmNvbGxlY3QoQ29sbGVjdG9ycy50b01hcChBcnRpZmFjdERhdGFEZWZpbml0aW9uOjpnZXRVbmlxdWVJZCwgRnVuY3Rpb24uaWRlbnRpdHkoKSkpOwogICAgICAgICAgICAgaWYgKE1hcFV0aWxzLmlzTm90RW1wdHkoY3VyckFydGlmYWN0cykpIHsKICAgICAgICAgICAgICAgICBhcnRpZmFjdHMucHV0QWxsKGN1cnJBcnRpZmFjdHMpOwogICAgICAgICAgICAgfQogICAgICAgICB9CiAgICAgICAgIGlmICghYXJ0aWZhY3RzLmNvbnRhaW5zS2V5KGFydGlmYWN0SWQpICYmIE1hcFV0aWxzLmlzTm90RW1wdHkoY29tcG9uZW50LmdldEFydGlmYWN0cygpKSkgewogICAgICAgICAgICAgY3VyckFydGlmYWN0cyA9IGNvbXBvbmVudC5nZXRUb3NjYUFydGlmYWN0cygpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnZhbHVlcygpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnN0cmVhbSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmNvbGxlY3QoQ29sbGVjdG9ycy50b01hcChpIC0+IGkuZ2V0VW5pcXVlSWQoKSwgaSAtPiBpKSk7CisgICAgICAgICAgICAgICAgICAgIC52YWx1ZXMoKQorICAgICAgICAgICAgICAgICAgICAuc3RyZWFtKCkKKyAgICAgICAgICAgICAgICAgICAgLmNvbGxlY3QoQ29sbGVjdG9ycy50b01hcChBcnRpZmFjdERhdGFEZWZpbml0aW9uOjpnZXRVbmlxdWVJZCwgRnVuY3Rpb24uaWRlbnRpdHkoKSkpOwogICAgICAgICAgICAgaWYgKE1hcFV0aWxzLmlzTm90RW1wdHkoY3VyckFydGlmYWN0cykpIHsKICAgICAgICAgICAgICAgICBhcnRpZmFjdHMucHV0QWxsKGN1cnJBcnRpZmFjdHMpOwogICAgICAgICAgICAgfQpAQCAtMTY4NSwyNCArMTQ1Nyw0NCBAQAogICAgICAgICBNYXA8U3RyaW5nLCBBcnRpZmFjdERlZmluaXRpb24+IGN1cnJBcnRpZmFjdHM7CiAgICAgICAgIGlmIChNYXBVdGlscy5pc05vdEVtcHR5KGluc3RhbmNlLmdldERlcGxveW1lbnRBcnRpZmFjdHMoKSkpIHsKICAgICAgICAgICAgIGN1cnJBcnRpZmFjdHMgPSBpbnN0YW5jZS5nZXREZXBsb3ltZW50QXJ0aWZhY3RzKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC52YWx1ZXMoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnN0cmVhbSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuY29sbGVjdChDb2xsZWN0b3JzLnRvTWFwKGkgLT4gaS5nZXRVbmlxdWVJZCgpLCBpIC0+IGkpKTsKKyAgICAgICAgICAgICAgICAgICAgLnZhbHVlcygpCisgICAgICAgICAgICAgICAgICAgIC5zdHJlYW0oKQorICAgICAgICAgICAgICAgICAgICAuY29sbGVjdChDb2xsZWN0b3JzLnRvTWFwKEFydGlmYWN0RGF0YURlZmluaXRpb246OmdldFVuaXF1ZUlkLCBGdW5jdGlvbi5pZGVudGl0eSgpKSk7CiAgICAgICAgICAgICBpZiAoTWFwVXRpbHMuaXNOb3RFbXB0eShjdXJyQXJ0aWZhY3RzKSkgewogICAgICAgICAgICAgICAgIGFydGlmYWN0cy5wdXRBbGwoY3VyckFydGlmYWN0cyk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICAgICAgaWYgKCFhcnRpZmFjdHMuY29udGFpbnNLZXkoYXJ0aWZhY3RJZCkgJiYgTWFwVXRpbHMuaXNOb3RFbXB0eShpbnN0YW5jZS5nZXRBcnRpZmFjdHMoKSkpIHsKICAgICAgICAgICAgIGN1cnJBcnRpZmFjdHMgPSBpbnN0YW5jZS5nZXRBcnRpZmFjdHMoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnZhbHVlcygpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuc3RyZWFtKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5jb2xsZWN0KENvbGxlY3RvcnMudG9NYXAoaSAtPiBpLmdldFVuaXF1ZUlkKCksIGkgLT4gaSkpOworICAgICAgICAgICAgICAgICAgICAudmFsdWVzKCkKKyAgICAgICAgICAgICAgICAgICAgLnN0cmVhbSgpCisgICAgICAgICAgICAgICAgICAgIC5jb2xsZWN0KENvbGxlY3RvcnMudG9NYXAoQXJ0aWZhY3REYXRhRGVmaW5pdGlvbjo6Z2V0VW5pcXVlSWQsIEZ1bmN0aW9uLmlkZW50aXR5KCkpKTsKICAgICAgICAgICAgIGlmIChNYXBVdGlscy5pc05vdEVtcHR5KGN1cnJBcnRpZmFjdHMpKSB7CiAgICAgICAgICAgICAgICAgYXJ0aWZhY3RzLnB1dEFsbChjdXJyQXJ0aWZhY3RzKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfQogICAgIH0KIAorICAgIHByaXZhdGUgU3RvcmFnZU9wZXJhdGlvblN0YXR1cyBjb252ZXJ0VG9TdG9yYWdlT3BlcmF0aW9uU3RhdHVzKENhc3NhbmRyYU9wZXJhdGlvblN0YXR1cyBjYXNzYW5kcmFTdGF0dXMpIHsKKyAgICAgICAgU3RvcmFnZU9wZXJhdGlvblN0YXR1cyByZXN1bHQ7CisgICAgICAgIHN3aXRjaCAoY2Fzc2FuZHJhU3RhdHVzKSB7CisgICAgICAgICAgICBjYXNlIE9LOgorICAgICAgICAgICAgICAgIHJlc3VsdCA9IFN0b3JhZ2VPcGVyYXRpb25TdGF0dXMuT0s7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIE5PVF9GT1VORDoKKyAgICAgICAgICAgICAgICByZXN1bHQgPSBTdG9yYWdlT3BlcmF0aW9uU3RhdHVzLk5PVF9GT1VORDsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgQ0xVU1RFUl9OT1RfQ09OTkVDVEVEOgorICAgICAgICAgICAgY2FzZSBLRVlTUEFDRV9OT1RfQ09OTkVDVEVEOgorICAgICAgICAgICAgICAgIHJlc3VsdCA9IFN0b3JhZ2VPcGVyYXRpb25TdGF0dXMuQ09OTkVDVElPTl9GQUlMVVJFOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICByZXN1bHQgPSBTdG9yYWdlT3BlcmF0aW9uU3RhdHVzLkdFTkVSQUxfRVJST1I7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICAgICAgcmV0dXJuIHJlc3VsdDsKKyAgICB9CisKICAgICBwcml2YXRlIHZvaWQgcmVzZXRNYW5kYXRvcnlBcnRpZmFjdEZpZWxkcyhBcnRpZmFjdERlZmluaXRpb24gZmV0Y2hlZEFydGlmYWN0KSB7CiAgIC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m1hdCA9IGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuT0spOwotICAgICAgICBoYW5kbGVBdWRpdGluZyhhdWRpdGluZ0FjdGlvbiwgcGFyZW50LCBjb21wb25lbnRJZCwgdXNlciwgYXJ0aWZhY3REZWZpbml0aW9uLCBudWxsLCBhcnRpZmFjdElkLCByZXNwb25zZUZvcm1hdCwgY29tcG9uZW50VHlwZSwgbnVsbCk7Ci0gICAgICAgIHJldHVybiBFaXRoZXIubGVmdChpbnNpZGVFaXRoZXIpOworICAgICAgICByZXR1cm4gYXJ0aWZhY3REZWZpbml0aW9uOwogICAgIH0KIAogICAgIHByaXZhdGUgRWl0aGVyPEFjdGlvblN0YXR1cywgUmVzcG9uc2VGb3JtYXQ+IGhhbmRsZUFydGlmYWN0TGFiZWwoU3RyaW5nIGNvbXBvbmVudElkLCBDb21wb25lbnQgcGFyZW50Q29tcG9uZW50LCBBcnRpZmFjdE9wZXJhdGlvbkluZm8gb3BlcmF0aW9uLCBBcnRpZmFjdERlZmluaXRpb24gYXJ0aWZhY3RJbmZvLCBTdHJpbmcgb3BlcmF0aW9uTmFtZSwKQEAgLTE3NTksOSArMTU0MCw5IEBACiAKICAgICAgICAgU3RyaW5nIGFydGlmYWN0TGFiZWwgPSBhcnRpZmFjdEluZm8uZ2V0QXJ0aWZhY3RMYWJlbCgpOwogICAgICAgICBpZiAob3BlcmF0aW9uTmFtZSA9PSBudWxsICYmIChhcnRpZmFjdEluZm8uZ2V0QXJ0aWZhY3RMYWJlbCgpID09IG51bGwgfHwgYXJ0aWZhY3RJbmZvLmdldEFydGlmYWN0TGFiZWwoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmlzRW1wdHkoKSkpIHsKKyAgICAgICAgICAgICAgICAuaXNFbXB0eSgpKSkgewogICAgICAgICAgIC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yYXRpb24uZ2V0SW1wbGVtZW50YXRpb24oKSAhPSBudWxsICYmIG9wZXJhdGlvbi5nZXRJbXBsZW1lbnRhdGlvbigpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0QXJ0aWZhY3RMYWJlbCgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZXF1YWxzKGFydGlmYWN0TGFiZWwpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNVbmlxdWUgPSBmYWxzZTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIH0KKyAgICAgICAgaWYgKGNvbXBvbmVudFR5cGUgPT0gQ29tcG9uZW50VHlwZUVudW0uUkVTT1VSQ0UgJiYgaXNVbmlxdWUpIHsKKyAgICAgICAgICAgIGlzVW5pcXVlID0gaXNVbmlxdWVMYWJlbEluUmVzb3VyY2VJbnRlcmZhY2VzKGNvbXBvbmVudElkLCBhcnRpZmFjdExhYmVsKTsKICAgICAgICAgfQogICAgICAgICByZXR1cm4gaXNVbmlxdWU7CiAgICAgfQpAQCAtMTg1OSw3ICsxNjI3LDcgQEAKICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KLSAgICAgICAgaWYgKENvbXBvbmVudFR5cGVFbnVtLlJFU09VUkNFLmVxdWFscyhjb21wb25lbnRUeXBlKSkgeworICAgICAgICBpZiAoQ29tcG9uZW50VHlwZUVudW0uUkVTT1VSQ0UgPT0gY29tcG9uZW50VHlwZSkgewogICAgICAgICAgICAgcmV0dXJuIGlzVW5pcXVlQXJ0aWZhY3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KQogICAgICAgICAgICAgICAgICAgICAuZmlsdGVyKE9iamVjdHM6Om5vbk51bGwpCi0gICAgICAgICAgICAgICAgICAgIC5hbnlNYXRjaChhZGQgLT4gYXJ0aWZhY3ROYW1lLmVxdWFscyhhZGQuZ2V0QXJ0aWZhY3ROYW1lKCkpCisgICAgICAgICAgICAgICAgICAgIC5ub25lTWF0Y2goYWRkIC0+IGFydGlmYWN0TmFtZS5lcXVhbHMoYWRkLmdldEFydGlmYWN0TmFtZSgpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICYmICFhcnRpZmFjdExhYmVsLmVxdWFscyhhZGQuZ2V0QXJ0aWZhY3RMYWJlbCgpKSk7CiAgICAgICAgIH0KICAgICAgICAgcmV0dXJuIHRydWU7CkBAIC0xODg3LDEzICsxNjU1LDEzIEBACiAgICAgICAgICAgICAgICAgLmdldEFsbEludGVyZmFjZXNPZlJlc291cmNlKGNvbXBvbmVudElkLCB0cnVlLCB0cnVlKTsKIAogICAgICAgICBpZiAoYWxsSW50ZXJmYWNlc09mUmVzb3VyY2UuaXNMZWZ0KCkpewotICAgICAgICAgICAgcmV0dXJuICFhbGxJbnRlcmZhY2VzT2ZSZXNvdXJjZS5sZWZ0KCkudmFsdWUoKQorICAgICAgICAgICAgcmV0dXJuIGFsbEludGVyZmFjZXNPZlJlc291cmNlLmxlZnQoKS52YWx1ZSgpCiAgICAgICAgICAgICAgICAgICAgIC52YWx1ZXMoKQogICAgICAgICAgICAgICAgICAgICAuc3RyZWFtKCkubWFwKEludGVyZmFjZURlZmluaXRpb24gOjogZ2V0T3BlcmF0aW9uc01hcCkKICAgICAgICAgICAgICAgICAgICAgLmZsYXRNYXAobWFwIC0+IG1hcC52YWx1ZXMoKS5zdHJlYW0oKSkKICAgICAgICAgICAgICAgICAgICAgLm1hcChPcGVyYXRpb25EYXRhRGVmaW5pdGlvbjo6Z2V0SW1wbGVtZW50YXRpb24pCiAgICAgICAgICAgICAgICAgICAgIC5maWx0ZXIoT2JqZWN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2V0VmFsdWUoKS5nZXRBcnRpZmFjdEdyb3VwVHlwZSgpKQogICAgICAgICAgICAgICAgIC5jb2xsZWN0KENvbGxlY3RvcnMudG9NYXAoRW50cnk6OmdldEtleSwgRW50cnk6OmdldFZhbHVlKSkpOwogICAgIH0KIAotICAgIHByaXZhdGUgTGlzdDxTdHJpbmc+IGdldExpc3RPZkFydGlmYWN0TmFtZShNYXA8U3RyaW5nLCBBcnRpZmFjdERlZmluaXRpb24+IGFydGlmYWN0cykgewotICAgICAgICByZXR1cm4gYXJ0aWZhY3RzLmVudHJ5U2V0KCkKLSAgICAgICAgICAgICAgICAuc3RyZWFtKCkKLSAgICAgICAgICAgICAgICAubWFwKHggLT4geC5nZXRWYWx1ZSgpLmdldEFydGlmYWN0TmFtZSgpKQotICAgICAgICAgICAgICAgIC5jb2xsZWN0KENvbGxlY3RvcnMudG9MaXN0KCkpOwotICAgIH0KLQogICAgIC8vICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgogCi0gICAgcHJpdmF0ZSBFaXRoZXI8RWl0aGVyPEFydGlmYWN0RGVmaW5pdGlvbiwgT3BlcmF0aW9uPiwgUmVzcG9uc2VGb3JtYXQ+IGNyZWF0ZUFuZExpbmtBcnRpZmFjdChvcmcub3BlbmVjb21wLnNkYy5iZS5tb2RlbC5Db21wb25lbnQgcGFyZW50LCBTdHJpbmcgcGFyZW50SWQsIEFydGlmYWN0RGVmaW5pdGlvbiBhcnRpZmFjdEluZm8sIFVzZXIgdXNlciwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbXBvbmVudFR5cGVFbnVtIGNvbXBvbmVudFR5cGVFbnVtLCBBdWRpdGluZ0FjdGlvbkVudW0gYXVkaXRpbmdBY3Rpb25FbnVtKSB7Ci0gICAgICAgIEVpdGhlcjx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pOworICAgICAgICAgICAgaWYgKHJlc3VsdC5pc1JpZ2h0KCkpIHsKKyAgICAgICAgICAgICAgICB0aHJvdyBuZXcgU3RvcmFnZUV4Y2VwdGlvbihyZXN1bHQucmlnaHQoKS52YWx1ZSgpKTsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGVsc2UgewotICAgICAgICAgICAgICAgIGVycm9yID0gcmVzdWx0LnJpZ2h0KCkudmFsdWUoKTsKLSAgICAgICAgICAgIH0KKyAgICAgICAgICAgIG9wZXJhdGlvblJlc3VsdCA9IEVpdGhlci5yaWdodChyZXN1bHQubGVmdCgpLnZhbHVlKCkpOwogICAgICAgICB9CiAgICAgICAgIGVsc2UgewotICAgICAgICAgICAgLy8gaW5mb3JtYXRpb24vZGVwbG95bWVudC9hcGkgYXJpdGZhY3RzCi0gICAgICAgICAgICBsb2cudHJhY2UoIlRyeSB0byBjcmVhdGUgZW50cnkgb24gZ3JhcGgiKTsKKyAgICAgICAgICAgIC8vIGluZm9ybWF0aW9uL2RlcGxveW1lbnQvYXBpIGFydGlmYWN0cwogICAgICAgICAgICAgTm9kZVR5cGVFbnVtIG5vZGVUeXBlID0gY29udmVydFBhcmVudFR5cGUoY29tcG9uZW50VHlwZUVudW0pOwotICAgICAgICAgICAgRWl0aGVyPEFydGlmYWN0RGVmaW5pdGlvbiwgU3RvcmFnZU9wZXJhdGlvblN0YXR1cz4gcmVzdWx0ID0gYXJ0aWZhY3RUb3NjYU9wZXJhdGlvbi5hZGRBcmlmYWN0VG9Db21wb25lbnQoYXJ0aWZhY3RJbmZvLCBwYXJlbnQKLSAgICAgICAgICAgICAgICAgICAgLmdldFVuaXF1ZUlkKCksIG5vZGVUeXBlLCB0cnVlLCBpbnN0YW5jZUlkKTsKLQotICAgICAgICAgICAgaXNMZWZ0ID0gcmVzdWx0LmlzTGVmdCgpOwotICAgICAgICAgICAgaWYgKGlzTGVmdCkgewotICAgICAgICAgICAgICAgIGFydGlmYWN0VW5pcXVlSWQgPSByZX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AgICAgICAgICAgIEFydGlmYWN0RGVmaW5pdGlvbiBhcnRpZmFjdERlZmluaXRpb24gPSByZXN1bHQubGVmdCgpLnZhbHVlKCk7CisgICAgICAgICAgICBhcnRpZmFjdERhdGEuc2V0SWQoYXJ0aWZhY3REZWZpbml0aW9uLmdldEVzSWQoKSk7CisgICAgICAgICAgICBvcGVyYXRpb25SZXN1bHQgPSBFaXRoZXIubGVmdChhcnRpZmFjdERlZmluaXRpb24pOworCisgICAgICAgICAgICBpZiAoZ2VuZXJhdGVDdXN0b21pemF0aW9uVVVJRE9uSW5zdGFuY2UocGFyZW50LmdldFVuaXF1ZUlkKCksIHBhcmVudElkLCBjb21wb25lbnRUeXBlRW51bSkgIT0gU3RvcmFnZU9wZXJhdGlvblN0YXR1cy5PSykgeworICAgICAgICAgICAgICAgIHRocm93IG5ldyBTdG9yYWdlRXhjZXB0aW9uKGdlbmVyYXRlQ3VzdG9taXphdGlvblVVSURPbkluc3RhbmNlKHBhcmVudC5nZXRVbmlxdWVJZCgpLCBwYXJlbnRJZCwgY29tcG9uZW50VHlwZUVudW0pKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfQotICAgICAgICBpZiAoaXNMZWZ0KSB7Ci0gICAgICAgICAgICBib29sZWFuIHJlcyA9IHNhdmVBcnRpZmFjdHMoYXJ0aWZhY3REYXRhLCBwYXJlbnRJZCk7Ci0KLSAgICAgICAgICAgIGlmIChyZXMpIHsKLSAgICAgICAgICAgICAgICBsb2cuZGVidWcoQVJUSUZBQ1RfU0FWRUQsIGFydGlmYWN0VW5pcXVlSWQpOwotCi0gICAgICAgICAgICAgICAgUmVzcG9uc2VGb3JtYXQgcmVzcG9uc2VGb3JtYXQgPSBjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLk9LKTsKLSAgICAgICAgICAgICAgICBoYW5kbGVBdWRpdGluZyhhdWRpdGluZ0FjdGlvbkVudW0sIHBhcmVudCwgcGFyZW50S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ZXJDb21wb25lbnQuZ2V0Q29tcG9uZW50SW5zdGFuY2VzKCkpKSB7CiAgICAgICAgICAgICBmb3VuZEluc3RhbmNlID0gY29udGFpbmVyQ29tcG9uZW50LmdldENvbXBvbmVudEluc3RhbmNlcygpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnN0cmVhbSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmZpbHRlcihpIC0+IGkuZ2V0VW5pcXVlSWQoKS5lcXVhbHMoY29tcG9uZW50SW5zdGFuY2VJZCkpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmZpbmRGaXJzdCgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLm9yRWxzZShudWxsKTsKKyAgICAgICAgICAgICAgICAgICAgLnN0cmVhbSgpCisgICAgICAgICAgICAgICAgICAgIC5maWx0ZXIoaSAtPiBpLmdldFVuaXF1ZUlkKCkuZXF1YWxzKGNvbXBvbmVudEluc3RhbmNlSWQpKQorICAgICAgICAgICAgICAgICAgICAuZmluZEZpcnN0KCkKKyAgICAgICAgICAgICAgICAgICAgLm9yRWxzZShudWxsKTsKICAgICAgICAgfQogICAgICAgICByZXR1cm4gZm91bmRJbnN0YW5jZTsKICAgICB9CiAKLSAgICBwcml2YXRlIEVpdGhlcjxCb29sZWFuLCBSZXNwb25zZUZvcm1hdD4gdmFsaWRhdGVEZXBsb3ltZW50QXJ0aWZhY3QoQ29tcG9uZW50IHBhcmVudENvbXBvbmVudCwgU3RyaW5nIHBhcmVudElkLCBib29sZWFuIGlzQ3JlYXRlLCBBcnRpZmFjdERlZmluaXRpb24gYXJ0aWZhY3RJbmZvLCBBcnRpZmFjdERlZmluaXRpb24gY3VycmVudEFydGlmYWN0LCBOb2RlVHlwZUVudW0gcGFyZW50VHlwZSkgeworICAgIHByaXZhdGUgdm9pZCB2YWxp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51bSByZXNvdXJjZVR5cGUgPSByZXNvdXJjZS5nZXRSZXNvdXJjZVR5cGUoKTsKKyAgICAgICAgICAgIEFydGlmYWN0VHlwZUNvbmZpZyBjb25maWcgPSByZXNvdXJjZURlcGxveW1lbnRBcnRpZmFjdHMuZ2V0KGFydGlmYWN0VHlwZS5nZXRUeXBlKCkpOworICAgICAgICAgICAgaWYgKGNvbmZpZyA9PSBudWxsKSB7CisgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEJ5QWN0aW9uU3RhdHVzQ29tcG9uZW50RXhjZXB0aW9uKEFjdGlvblN0YXR1cy5BUlRJRkFDVF9UWVBFX05PVF9TVVBQT1JURUQsIGFydGlmYWN0SW5mby5nZXRBcnRpZmFjdFR5cGUoKSk7CiAgICAgICAgICAgICB9Ci0gICAgICAgIH0KLSAgICAgICAgaWYgKHJlc3BvbnNlV3JhcHBlci5pc0VtcHR5KCkpIHsKLSAgICAgICAgICAgIGlmIChwYXJlbnRUeXBlLmVxdWFscyhOb2RlVHlwZUVudW0uUmVzb3VyY2UpKSB7Ci0gICAgICAgICAgICAgICAgUmVzb3VyY2UgcmVzb3VyY2UgPSAoUmVzb3VyY2UpIHBhcmVudENvbXBvbmVudDsKLSAgICAgICAgICAgICAgICBSZXNvdXJjZVR5cGVFbnVtIHJlc291cmNlVHlwZSA9IHJlc291cmNlLmdldFJlc291cmNlVHlwZSgpOwotICAgICAgICAgICAgICAgIEFydGlmYWN0VHlwZUNvbmZpZyBjb25maWcgPSByZXNvdXJjZURlcGxveW1lbnRBcnRpZmFjdHMuZ2V0KGFydGlmYWN0VHlwZS5nZXRUeXBlKCkpOwotICAgICAgICAgICAgICAgIGlmIChjb25maWcgPT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICByZXNwb25zZVdyYXBwZXIuc2V0SW5uZXJFbGVtZW50KFJlc3BvbnNlRm9ybWF0TWFuYWdlci5nZXRJbnN0YW5jZSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5BUlRJRkFDVF9UWVBFX05PVF9TVVBQT1JURUQsIGFydGlmYWN0SW5mbwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldEFydGlmYWN0VHlwZSgpKSk7Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIGVsc2UgewotICAgICAgICAgICAgICAgICAgICBMaXN0PFN0cmluZz4gbXlMaXN0ID0gY29uZmlnLmdldFZhbGlkRm9yUmVzb3VyY2VUeXBlcygpOwotICAgICAgICAgICAgICAgICAgICBFaXRoZXI8Qm9vbGVhbiwgUmVzcG9uc2VGb3JtYXQ+IGVpdGhlciA9IHZhbGlkYXRlUmVzb3VyY2VUeXBlKHJlc291cmNlVHlwZSwgYXJ0aWZhY3RJbmZvLCBteUxpc3QpOwotICAgICAgICAgICAgICAgICAgICBpZiAoZWl0aGVyLmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2VXcmFwcGVyLnNldElubmVyRWxlbWVudChlaXRoZXIucmlnaHQoKS52YWx1ZSgpKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIH0KLQotICAgICAgICAgICAgdmFsaWRhdGVGaWxlRXh0ZW5zaW9uKHJlc3BvbnNlV3JhcHBlciwgKCkgLT4gZ2V0RGVwbG95bWVudEFydGlmYWN0VHlwZUNvbmZpZyhwYXJlbnRUeXBlLCBhcnRpZmFjdFR5cGUpLCBhcnRpZmFjdEluZm8sIHBhcmVudFR5cGUsIGFydGlmYWN0VHlwZSk7CisgICAgICAgICAgICBMaXN0PFN0cmluZz4gbXlMaXN0ID0gY29uZmlnLmdldFZhbGlkRm9yUmVzb3VyY2VUeXBlcygp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gICAgIHN3aXRjaCAoYXJ0aWZhY3RUeXBlKSB7Ci0gICAgICAgICAgICAgICAgY2FzZSBIRUFUOgotICAgICAgICAgICAgICAgIGNhc2UgSEVBVF9WT0w6Ci0gICAgICAgICAgICAgICAgY2FzZSBIRUFUX05FVDoKLSAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gdmFsaWRhdGVIZWF0RGVwbG95bWVudEFydGlmYWN0KGlzQ3JlYXRlLCBhcnRpZmFjdEluZm8sIGN1cnJlbnRBcnRpZmFjdCk7Ci0gICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgIGNhc2UgSEVBVF9FTlY6Ci0gICAgICAgICAgICAgICAgICAgIHJlc3VsdCA9IHZhbGlkYXRlSGVhdEVudkRlcGxveW1lbnRBcnRpZmFjdChwYXJlbnRDb21wb25lbnQsIHBhcmVudElkLCBhcnRpZmFjdEluZm8sIHBhcmVudFR5cGUpOwotICAgICAgICAgICAgICAgICAgICBhcnRpZmFjdEluZm8uc2V0VGltZW91dChOb2RlVGVtcGxhdGVPcGVyYXRpb24uTk9OX0hFQVRfVElNRU9VVCk7Ci0gICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgIGNhc2UgRENBRV9JTlZFTlRPUllfVE9TQ0E6Ci0gICAgICAgICAgICAgICAgY2FzZSBEQ0FFX0lOVkVOVE9SWV9KU09OOgotICAgICAgICAgICAgICAgIGNhc2UgRENBRV9JTlZFTlRPUllfUE9MSUNZOgotICAgICAgICAgICAgICAgICAgICAvLyBWYWxpZGF0aW9uIGlzIGRvbmUgaW4gaGFuZGxlIHBheWxvYWQuCi0gICAgICAgICAgICAgICAgY2FzZSBEQ0FFX0lOVkVOVE9SWV9ET0M6Ci0gICAgICAgICAgICAgICAgY2FzZSBEQ0FFX0lOVkVOVE9SWV9CTFVFUFJJTlQ6Ci0gICAgICAgICAgICAgICAgY2FzZSBEQ0FFX0lOVkVOVE9SWV9FVkVOVDoKLSAgICAgICAgICAgICAgICAgICAgLy8gTm8gc3BlY2lmaWMgdmFsaWRhdGlvbgotICAgICAgICAgICAgICAgIGRlZmF1bHQ6Ci0gICAgICAgICAgICAgICAgICAgIGFydGlmYWN0SW5mby5zZXRUaW1lb3V0KE5vZGVUZW1wbGF0ZU9wZXJhdGlvbi5OT05fSEVBVF9USU1FT1VUKTsKLSAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICB9Ci0KKyAgICAgICAgc3dpdGNoIChhcnRpZmFjdFR5cGUpIHsKKyAgICAgICAgICAgIGNhc2UgSEVBVDoKKyAgICAgICAgICAgIGNhc2UgSEVBVF9WT0w6CisgICAgICAgICAgICBjYXNlIEhFQVRfTkVUOgorICAgICAgICAgICAgICAgIHZhbGlkYXRlSGVhdFRpbWVvdXRWYWx1ZShpc0NyZWF0ZSwgYXJ0aWZhY3RJbmZvLCBjdXJyZW50QXJ0aWZhY3QpOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBIRUFUX0VOVjoKKyAgICAgICAgICAgICAgICB2YWxpZGF0ZUhlYXRFbnZEZXBsb3ltZW50QXJ0aWZhY3QocGFyZW50Q29tcG9uZW50LCBwYXJlbnRJZCwgYXJ0aWZhY3RJbmZvLCBwYXJlbnRUeXBlKTsKKyAgICAgICAgICAgICAgICBhcnRpZmFjdEluZm8uc2V0VGltZW91dChOb2RlVGVtcGxhdGVPcGVyYXRpb24uTk9OX0hFQVRfVElNRU9VVCk7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIERDQUVfSU5WRU5UT1JZX1RPU0NBOgorICAgICAgICAgICAgY2FzZSBEQ0FFX0lOVkVOVE9SWV9KU09OOgorICAgICAgICAgICAgY2FzZSBEQ0FFX0lOVkVOVE9SWV9QT0xJQ1k6CisgICAgICAgICAgICAgICAgLy8gVmFsaWRhdGlvbiBpcyBkb25lIGluIGhhbmRsZSBwYXlsb2FkLgorICAgICAgICA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eXBlQ29uZmlnPiByZXNvdXJjZURlcGxveW1lbnRBcnRpZmFjdHMpIHsKICAgICAgICAgaWYgKChyZXNvdXJjZURlcGxveW1lbnRBcnRpZmFjdHMgPT0gbnVsbCkgfHwgIXJlc291cmNlRGVwbG95bWVudEFydGlmYWN0cy5jb250YWluc0tleShhcnRpZmFjdFR5cGUubmFtZSgpKSkgewotICAgICAgICAgICAgUmVzcG9uc2VGb3JtYXQgcmVzcG9uc2VGb3JtYXQgPSBSZXNwb25zZUZvcm1hdE1hbmFnZXIuZ2V0SW5zdGFuY2UoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLkFSVElGQUNUX1RZUEVfTk9UX1NVUFBPUlRFRCwgYXJ0aWZhY3RJbmZvCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldEFydGlmYWN0VHlwZSgpKTsKLSAgICAgICAgICAgIHJlc3BvbnNlV3JhcHBlci5zZXRJbm5lckVsZW1lbnQocmVzcG9uc2VGb3JtYXQpOwogICAgICAgICAgICAgbG9nLmRlYnVnKCJBcnRpZmFjdCBUeXBlOiB7fSBOb3QgZm91bmQgISIsIGFydGlmYWN0SW5mby5nZXRBcnRpZmFjdFR5cGUoKSk7CisgICAgICAgICAgICB0aHJvdyBuZXcgQnlBY3Rpb25TdGF0dXNDb21wb25lbnRFeGNlcHRpb24oQWN0aW9uU3RhdHVzLkFSVElGQUNUX1RZUEVfTk9UX1NVUFBPUlRFRCwgYXJ0aWZhY3RJbmZvLmdldEFydGlmYWN0VHlwZSgpKTsKICAgICAgICAgfQogICAgIH0KIAogICAgIHByaXZhdGUgTWFwPFN0cmluZywgQXJ0aWZhY3RUeXBlQ29uZmlnPiBmaWxsRGVwbG95bWVudEFydGlmYWN0VHlwZUNvbmYoTm9kZVR5cGVFbnVtIHBhcmVudFR5cGUpIHsKLSAgICAgICAgTWFwPFN0cmluZywgQXJ0aWZhY3RUeXBlQ29uZmlnPiByZXNvdXJjZURlcGxveW1lbnRBcnRpZmFjdHMgPSBudWxsOwotICAgICAgICBpZiAocGFyZW50VHlwZS5lcXVhbHMoTm9kZVR5cGVFbnVtLlJlc291cmNlKSkgeworICAgICAgICBNYXA8U3RyaW5nLCBBcnRpZmFjdFR5cGVDb25maWc+IHJlc291cmNlRGVwbG95bWVudEFydGlmYWN0czsKKyAgICAgICAgaWYgKHBhcmVudFR5cGUgPT0gTm9kZVR5cGVFbnVtLlJlc291cmNlKSB7CiAgICAgICAgICAgICByZXNvdXJjZURlcGxveW1lbnRBcnRpZmFjdHMgPSBDb25maWd1cmF0aW9uTWFuYWdlci5nZXRDb25maWd1cmF0aW9uTWFuYWdlcigpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRDb25maWd1cmF0aW9uKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldFJlc291cmNlRGVwbG95bWVudEFydGlmYWN0cygpOworICAgICAgICAgICAgICAgICAgICAuZ2V0Q29uZmlndXJhdGlvbigpCisgICAgICAgICAgICAgICAgICAgIC5nZXRSZXNvdXJjZURlcGxveW1lbnRBcnRpZmFjdHMoKTsKICAgICAgICAgfQotICAgICAgICBlbHNlIGlmIChwYXJlbnRUeXBlLmVxdWFscyhOb2RlVHlwZUVudW0uUmVzb3VyY2VJbnN0YW5jZSkpIHsKKyAgICAgICAgZWxzZSBpZiAocGFyZW50VHlwZSA9PSBOb2RlVHlwZUVudW0uUmVzb3VyY2VJbnN0YW5jZSkgewogICAgICAgICAgICAgcmVzb3VyY2VEZXBsb3ltZW50QXJ0aWZhY3RzID0gQ29uZmlndXJhdGlvbk1hbmFnZXIuZ2V0Q29uZmlndXJhdGlvbk1hbmFnZXIoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0Q29uZmlndXJhdGlvbigpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRSZXNvdXJjZUluc3RhbmNlRGVwbG95bWVudEFydGlmYWN0cygpOworICAgICAgICAgICAgICAgICAgICAuZ2V0Q29uZmlndXJhdGlvbigpCisgICAgICAgICAgICAgICAgICAgIC5nZXRSZXNvdXJjZUluc3RhbmNlRGVwbG95bWVudEFydGlmYWN0cygpOwogICAgICAgICB9CiAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgcmVzb3VyY2VEZXBsb3ltZW50QXJ0aWZhY3RzID0gQ29uZmlndXJhdGlvbk1hbmFnZXIuZ2V0Q29uZmlndXJhdGlvbk1hbmFnZXIoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0Q29uZmlndXJhdGlvbigpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRTZXJ2aWNlRGVwbG95bWVudEFydGlmYWN0cygpOworICAgICAgICAgICAgICAgICAgICAuZ2V0Q29uZmlndXJhdGlvbigpCisgICAgICAgICAgICAgICAgICAgIC5nZXRTZXJ2aWNlRGVwbG95bWVudEFydGlmYWN0cygpOwogICAgICAgICB9CiAgICAgICAgIHJldHVybiByZXNvdXJjZURlcGxveW1lbnRBcnRpZmFjdHM7CiAgICAgfQogCi0gICAgcHVibGljIHZvaWQgdmFsaWRhdGVBcnRpZmFjdFR5cGVFeGlzdHMoV3JhcHBlcjxSZXNwb25zZUZvcm1hdD4gcmVzcG9uc2VXcmFwcGVyLCBBcnRpZmFjdERlZmluaXRpb24gYXJ0aWZhY3RJbmZvKSB7CisgICAgcHVibGljIEFydGlmYWN0VHlwZUVudW0gZ2V0VmFsaWRBcnRpZmFjdFR5cGUoQXJ0aWZhY3REZWZpbml0aW9uIGFydGlmYWN0SW5mbykgewogICAgICAgICBBcnRpZmFjdFR5cGVFbnVtIGFydGlmYWN0VHlwZSA9IEFydGlmYWN0VHlwZUVudW0uZmluZFR5cGUoYXJ0aWZhY3RJbmZvLmdldEFydGlmYWN0VHlwZSgpKTsKICAgICAgICAgaWYgKGFydGlmYWN0VHlwZSA9PSBudWxsKSB7Ci0gICAgICAgICAgICBSZXNwb25zZUZvcm1hdCByZXNwb25zZUZvcm1hdCA9IFJlc3BvbnNlRm9ybWF0TWFuYWdlci5nZXRJbnN0YW5jZSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuQVJUSUZBQ1RfVFlQRV9OT1RfU1VQUE9SVEVELCBhcnRpZmFjdEluZm8KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0QXJ0aWZhY3RUeXBlKCkpOwotICAgICAgICAgICAgcmVzcG9uc2VXcmFwcGVyLnNldElubmVyRWxlbWVudChyZXNwb25zZUZvcm1hdCk7CiAgICAgICAgICAgICBsb2cuZGVidWcoIkFydGlmYWN0IFR5cGU6IHt9IE5vdCBmb3VuZCAhIiwgYXJ0aWZhY3RJbmZvLmdldEFydGlmYWN0VHlwZSgpKTsKKyAgICAgICAgICAgIHRocm93IG5ldyBCeUFjdGlvblN0YXR1c0NvbXBvbmVudEV4Y2VwdGlvbihBY3Rpb25TdGF0dXMuQVJUSUZBQ1RfVFlQRV9OT1RfU1VQUE9SVEVELCBhcnRpZmFjdEluZm8uZ2V0QXJ0aWZhY3RUeXBlKCkpOwogICAgICAgICB9CisgICAgICAgIHJldHVybiBhcnRpZmFjdFR5cGU7CiAgICAgfQogCiAgICAgcHJpdmF0ZSBBcnRpZmFjdFR5cGVDb25maWcgZ2V0RGVwbG95bWVudEFydGlmYWN0VHlwZUNvbmZpZyhOb2RlVHlwZUVudW0gcGFyZW50VHlwZSwgQXJ0aWZhY3RUeXBlRW51bSBhcnRpZmFjdFR5cGUpIHsKICAgICAgICAgQXJ0aWZhY3RUeXBlQ29uZmlnIHJldENvbmZpZyA9IG51bGw7CiAgICAgICAgIFN0cmluZyBmaWxlVHlwZSA9IGFydGlmYWN0VHlwZS5nZXRUeXBlKCk7Ci0gICAgICAgIGlmIChwYXJlbnRUeXBlLmVxdWFscyhOb2RlVHlwZUVudW0uUmVzb3VyY2UpKSB7CisgICAgICAgIGlmIChwYXJlbnRUeXBlID09IE5vZGVUeXBlRW51bS5SZXNvdXJjZSkgewogICAgICAgICAgICAgcmV0Q29uZmlnID0gQ29uZmlndXJhdGlvbk1hbmFnZXIuZ2V0Q29uZmlndXJhdGlvbk1hbmFnZXIoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0Q29uZmlndXJhdGlvbigpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRSZXNvdXJjZURlcGxveW1lbnRBcnRpZmFjdHMoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0KGZpbGVUeXBlKTsKKyAgICAgICAgICAgICAgICAgICAgLmdldENvbmZpZ3VyYXRpb24oKQorICAgICAgICAgICAgICAgICAgICAuZ2V0UmVzb3VyY2VEZXBsb3ltZW50QXJ0aWZhY3RzKCkKKyAgICAgICAgICAgICAgICAgICAgLmdldChmaWxlVHlwZSk7CiAgICAgICAgIH0KLSAgICAgICAgZWxzZSBpZiAocGFyZW50VHlwZS5lcXVhbHMoTm9kZVR5cGVFbnVtLlNlcnZpY2UpKSB7CisgICAgICAgIGVsc2UgaWYgKHBhcmVudFR5cGUgPT0gTm9kZVR5cGVFbnVtLlNlcnZpY2UpIHsKICAgICAgICAgICAgIHJldENvbmZpZyA9IENvbmZpZ3VyYXRpb25NYW5hZ2VyLmdldENvbmZpZ3VyYXRpb25NYW5hZ2VyKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldENvbmZpZ3VyYXRpb24oKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0U2VydmljZURlcGxveW1lbnRBcnRpZmFjdHMoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0KGZpbGVUeXBlKTsKKyAgICAgICAgICAgICAgICAgICAgLmdldENvbmZpZ3VyYXRpb24oKQorICAgICAgICAgICAgICAgICAgICAuZ2V0U2VydmljZURlcGxveW1lbnRBcnRpZmFjdHMoKQorICAgICAgICAgICAgICAgICAgICAuZ2V0KGZpbGVUeXBlKTsKICAgICAgICAgfQotICAgICAgICBlbHNlIGlmIChwYXJlbnRUeXBlLmVxdWFscyhOb2RlVHlwZUVudW0uUmVzb3VyY2VJbnN0YW5jZSkpIHsKKyAgICAgICAgZWxzZSBpZiAocGFyZW50VHlwZSA9PSBOb2RlVHlwZUVudW0uUmVzb3VyY2VJbnN0YW5jZSkgewogICAgICAgICAgICAgcmV0Q29uZmlnID0gQ29uZmlndXJhdGlvbk1hbmFnZXIuZ2V0Q29uZmlndXJhdGlvbk1hbmFnZXIoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0Q29uZmlndXJhdGlvbigpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRSZXNvdXJjZUluc3RhbmNlRGVwbG95bWVudEFydGlmYWN0cygpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXQoZmlsZVR5cGUpOworICAgICAgICAgICAgICAgICAgICAuZ2V0Q29uZmlndXJhdGlvbigpCisgICAgICAgICAgICAgICAgICAgIC5nZXRSZXNvdXJjZUluc3RhbmNlRGVwbG95bWVudEFydGlmYWN0cygpCisgICAgICAgICAgICAgICAgICAgIC5nZXQoZmlsZVR5cGUpOwogICAgICAgICB9CiAgICAgICAgIHJldHVybiByZXRDb25maWc7CiAgICAgfQpAQCAtMjI1NCw5ICsxODY5LDcgQEAKICAgICAgICAgICAgIFN0cmluZyBoZWF0RGVjb2RlZFBheWxvYWQgPSBuZXcgU3RyaW5nKEJhc2U2NC5kZWNvZGVCYXNlNjQoYXJ0aWZhY3RJbmZvLmdldFBheWxvYWREYXRhKCkpKTsKICAgICAgICAgICAgIEVpdGhlcjxMaXN0PEhlYXRQYXJhbWV0ZXJEZWZpbml0aW9uPiwgUmVzdWx0U3RhdHVzRW51bT4gaGVhdFBhcmFtZXRlcnMgPSBJbXBvcnRVdGlscy5nZXRIZWF0UGFyYW1zV2l0aG91dEltcGxpY2l0VHlwZXMoaGVhdERlY29kZWRQYXlsb2FkLCBhcnRpZmFjdEluZm8KICAgICAgICAgICAgICAgICAgICAgLmdldEFydGlmYWN0VHlwZSgpKTsKLSAgICAgICAgICAgIGlmIChoZWF0UGFyYW1ldGVycy5pc1JpZ2h0KCkgJiYgKCFoZWF0UGFyYW1ldGVycy5yaWdodCgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAudmFsdWUoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmVxdWFscyhSZXN1bHRTdGF0dXNFbnVtLkVMRU1FTlRfTk9UX0ZPVU5EKSkpIHsKKyAgICAgICAgICAgIGlmIChoZWF0UGFyYW1ldGVycy5pc1JpZ2h0KCkgJiYgKGhlYXRQYXJhbWV0ZXJzLnJpZ2h0KCkudmFsdWUoKSAhPSBSZXN1bHRTdGF0dXNFbnVtLkVMRU1FTlRfTk9UX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3QuZ2V0QXJ0aWZhY3ROYW1lKCkpOworICAgICAgICAgICAgdGhyb3cgbmV3IEJ5QWN0aW9uU3RhdHVzQ29tcG9uZW50RXhjZXB0aW9uKEFjdGlvblN0YXR1cy5DT1JSVVBURURfRk9STUFULCAiSGVhdCIpOwogICAgICAgICB9Ci0gICAgICAgIGVsc2UgewotICAgICAgICAgICAgU2V0PFN0cmluZz4gaGVhdFByb3BlcnRpZXNLZXlzID0gZWl0aGVySGVhdFByb3BlcnRpZXMubGVmdCgpLnZhbHVlKCkua2V5U2V0KCk7Ci0gICAgICAgICAgICBTZXQ8U3RyaW5nPiBoZWF0RW52UHJvcGVydGllc0tleXMgPSBlaXRoZXJIZWF0RW52UHJvcGVydGllcy5sZWZ0KCkudmFsdWUoKS5rZXlTZXQoKTsKLSAgICAgICAgICAgIGhlYXRFbnZQcm9wZXJ0aWVzS2V5cy5yZW1vdmVBbGwoaGVhdFByb3BlcnRpZXNLZXlzKTsKLSAgICAgICAgICAgIGlmICghaGVhdEVudlByb3BlcnRpZXNLZXlzLmlzRW1wdHkoKSkgewotICAgICAgICAgICAgICAgIFJlc3BvbnNlRm9ybWF0IHJlc3BvbnNlRm9ybWF0ID0gUmVzcG9uc2VGb3JtYXRNYW5hZ2VyLmdldEluc3RhbmNlKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuTUlTTUFUQ0hfSEVBVF9WU19IRUFUX0VOViwgZW52QXJ0aWZhY3QKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldEFydGlmYWN0TmFtZSgpLCBoZWF0QXJ0aWZhY3QuZ2V0QXJ0aWZhY3ROYW1lKCkpOwotICAgICAgICAgICAgICAgIGVycm9yV3JhcHBlci5zZXRJbm5lckVsZ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RlciB5YW1sQ29udmVydG9yID0gbmV3IFlhbWxUb09iamVjdENvbnZlcnRlcigpOwotICAgICAgICBib29sZWFuIGlzWWFtbFZhbGlkID0geWFtbENvbnZlcnRvci5pc1ZhbGlkWWFtbEVuY29kZWQ2NChhcnRpZmFjdEluZm8uZ2V0UGF5bG9hZERhdGEoKSk7CisgICAgcHJpdmF0ZSB2b2lkIHZhbGlkYXRlWWFtbChBcnRpZmFjdERlZmluaXRpb24gYXJ0aWZhY3RJbmZvKSB7CisgICAgICAgIFlhbWxUb09iamVjdENvbnZlcnRlciB5YW1sQ29udmVydGVyID0gbmV3IFlhbWxUb09iamVjdENvbnZlcnRlcigpOworICAgICAgICBib29sZWFuIGlzWWFtbFZhbGlkID0geWFtbENvbnZlcnRlci5pc1ZhbGlkWWFtbEVuY29kZWQ2NChhcnRpZmFjdEluZm8uZ2V0UGF5bG9hZERhdGEoKSk7CiAgICAgICAgIGlmICghaXNZYW1sVmFsaWQpIHsKLSAgICAgICAgICAgIFJlc3BvbnNlRm9ybWF0IHJlc3BvbnNlRm9ybWF0ID0gUmVzcG9uc2VGb3JtYXRNYW5hZ2VyLmdldEluc3RhbmNlKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5JTlZBTElEX1lBTUwsIGFydGlmYWN0SW5mbwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRBcnRpZmFjdFR5cGUoKSk7Ci0gICAgICAgICAgICBlcnJvcldyYXBwZXIuc2V0SW5uZXJFbGVtZW50KHJlc3BvbnNlRm9ybWF0KTsKICAgICAgICAgICAgIGxvZy5kZWJ1ZygiWWFtbCBpcyBub3QgdmFsaWQgZm9yIGFydGlmYWN0IDoge30iLCBhcnRpZmFjdEluZm8uZ2V0QXJ0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ydGlmYWN0TmFtZSgpKTsKICAgICAgICAgfQogICAgICAgICBpZiAoYXJ0aWZhY3ROYW1lRm91bmQpIHsKLSAgICAgICAgICAgIFN0cmluZyBwYXJlbnROYW1lID0gcGFyZW50Q29tcG9uZW50LmdldE5hbWUoKTsKLSAgICAgICAgICAgIFJlc3BvbnNlRm9ybWF0IHJlc3BvbnNlRm9ybWF0ID0gUmVzcG9uc2VGb3JtYXRNYW5hZ2VyLmdldEluc3RhbmNlKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5ERVBMT1lNRU5UX0FSVElGQUNUX05BTUVfQUxSRUFEWV9FWElTVFMsIHBhcmVudFR5cGUKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAubmFtZSgpLCBwYXJlbnROYW1lLCBhcnRpZmFjdE5hbWUpOwotCi0gICAgICAgICAgICBlcnJvcldyYXBwZXIuc2V0SW5uZXJFbGVtZW50KHJlc3BvbnNlRm9ybWF0KTsKICAgICAgICAgICAgIGxvZy5kZWJ1ZygiQ2FuJ3QgdXBsb2FkIGFydGlmYWN0OiB7fSwgYmVjYXVzZSBhbm90aGVyIGFydGlmYWN0IHdpdGggdGhpcyBuYW1lIGFscmVhZHkgZXhpc3QuIiwgYXJ0aWZhY3ROYW1lKTsKLQorICAgICAgICAgICAgdGhyb3cgbmV3IEJ5QWN0aW9uU3RhdHVzQ29tcG9uZW50RXhjZXB0aW9uKEFjdGlvblN0YXR1cy5ERVBMT1lNRU5UX0FSVElGQUNUX05BTUVfQUxSRUFEWV9FWElTVFMsIHBhcmVudFR5cGUubmFtZSgpLAorICAgICAgICAgICAgICAgICAgICBwYXJlbnRDb21wb25lbnQuZ2V0TmFtZSgpLCBhcnRpZmFjdE5hbWUpOwogICAgICAgICB9C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sb3ltZW50QXJ0aWZhY3RUeXBlcyhwYXJlbnRUeXBlKTsKICAgICAgICAgfQogICAgICAgICBlbHNlIHsKQEAgLTI2NjIsMTIgKzIyMDUsMTIgQEAKICAgICAgICAgfQogICAgICAgICBpZiAoYWxsQXJ0aWZhY3RUeXBlcy5pc1JpZ2h0KCkpIHsKICAgICAgICAgICAgIEJlRWNvbXBFcnJvck1hbmFnZXIuZ2V0SW5zdGFuY2UoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5sb2dCZUludmFsaWRDb25maWd1cmF0aW9uRXJyb3IoIkFydGlmYWN0IFVwbG9hZCAvIFVwZGF0ZSIsICJhcnRpZmFjdFR5cGVzIiwgYWxsQXJ0aWZhY3RUeXBlcwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnJpZ2h0KCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC52YWx1ZSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAubmFtZSgpKTsKKyAgICAgICAgICAgICAgICAgICAgLmxvZ0JlSW52YWxpZENvbmZpZ3VyYXRpb25FcnJvcigiQXJ0aWZhY3QgVXBsb2FkIC8gVXBkYXRlIiwgImFydGlmYWN0VHlwZXMiLCBhbGxBcnRpZmFjdFR5cGVzCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnJpZ2h0KCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAudmFsdWUoKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5uYW1lKCkpOwogICAgICAgICAgICAgbG9nLmRlYnVnKCJGYWlsZWQgdG8gcmV0cmlldmUgbGlzdCBvZiBzdXBvcnRlZCBhcnRpZmFjdCB0eXBlcy4gZXJyb3I6IHt9IiwgYWxsQXJ0aWZhY3RUeXBlcy5yaWdodCgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA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mYWN0SW5mby5nZXRBcnRpZmFjdFR5cGUoKSk7CiAgICAgICAgICAgICByZXR1cm4gRWl0aGVyLnJpZ2h0KGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuQVJUSUZBQ1RfVFlQRV9OT1RfU1VQUE9SVEVELCBhcnRpZmFjdEluZm8KICAgICAgICAgICAgICAgICAgICAgLmdldEFydGlmYWN0VHlwZSgpKSk7CkBAIC0yNjk2LDIwICsyMjM5LDIwIEBACiAgICAgICAgIE1hcDxTdHJpbmcsIEFydGlmYWN0VHlwZUNvbmZpZz4gZGVwbG95bWVudEFydGlmYWN0cyA7CiAgICAgICAgIExpc3Q8QXJ0aWZhY3RUeXBlPiBhcnRpZmFjdFR5cGVzID0gbmV3IEFycmF5TGlzdDw+KCk7CiAKLSAgICAgICAgaWYgKHBhcmVudFR5cGUuZXF1YWxzKE5vZGVUeXBlRW51bS5TZXJ2aWNlKSkgeworICAgICAgICBpZiAocGFyZW50VHlwZSA9PSBOb2RlVHlwZUVudW0uU2VydmljZSkgewogICAgICAgICAgICAgZGVwbG95bWVudEFydGlmYWN0cyA9IENvbmZpZ3VyYXRpb25NYW5hZ2VyLmdldENvbmZpZ3VyYXRpb25NYW5hZ2VyKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRDb25maWd1cmF0aW9uKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRTZXJ2aWNlRGVwbG95bWVudEFydGlmYWN0cygpOworICAgICAgICAgICAgICAgICAgICAuZ2V0Q29uZmlndXJhdGlvbigpCisgICAgICAgICAgICAgICAgICAgIC5nZXRTZXJ2aWNlRGVwbG95bWVudEFydGlmYWN0cygpOwogICAgICAgICB9Ci0gICAgICAgIGVsc2UgaWYgKHBhcmVudFR5cGUuZXF1YWxzKE5vZGVUeXBlRW51bS5SZXNvdXJjZUluc3RhbmNlKSkgeworICAgICAgICBlbHNlIGlmIChwYXJlbnRUeXBlID09IE5vZGVUeXBlRW51bS5SZXNvdXJjZUluc3RhbmNlKSB7CiAgICAgICAgICAgICBkZXBsb3ltZW50QXJ0aWZhY3RzID0gQ29uZmlndXJhdGlvbk1hbmFnZXIuZ2V0Q29uZmlndXJhdGlvbk1hbmFnZXIoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldENvbmZpZ3VyYXRpb24oKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldFJlc291cmNlSW5zdGFuY2VEZXBsb3ltZW50QXJ0aWZhY3RzKCk7CisgICAgICAgICAgICAgICAgICAgIC5nZXRDb25maWd1cmF0aW9uKCkKKyAgICAgICAgICAgICAgICAgICAgLmdldFJlc291cmNlSW5zdGFuY2VEZXBsb3ltZW50QXJ0aWZhY3RzKCk7CiAgICAgICAgIH0KICAgICAgICAgZWxzZSB7CiAgICAgICAgICAgICBkZXBsb3ltZW50QXJ0aWZhY3RzID0gQ29uZmlndXJhdGlvbk1hbmFnZXIuZ2V0Q29uZmlndXJhdGlvbk1hbmFnZXIoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldENvbmZpZ3VyYXRpb24oKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldFJlc291cmNlRGVwbG95bWVudEFydGlmYWN0cygpOworICAgICAgICAgICAgICAgICAgICAuZ2V0Q29uZmlndXJhdGlvbigpCisgICAgICAgICAgICAgICAgICAgIC5nZXRSZXNvdXJjZURlcGxveW1lbnRBcnRpZmFjdHMoKTsKICAgICAgICAgfQogICAgICAgICBpZiAoZGVwbG95bWVudEFydGlmYWN0cyAhPSBudWxsKSB7CiAgICAgICAgICAgICBmb3IgKFN0cmluZyBhc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T05URU5UKSk7CisgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICAgICAgcmV0dXJuIEVpdGhlci5sZWZ0KGFydGlmYWN0SW5mbyk7CiAgICAgfQpAQCAtMjc5MSw1NiArMjMzNCw1NiBAQAogICAgICAgICBhcnRpZmFjdEluZm8uc2V0VW5pcXVlSWQoY3VycmVudEFydGlmYWN0LmdldFVuaXF1ZUlkKCkpOwogCiAgICAgICAgIGlmIChhcnRpZmFjdEluZm8uZ2V0QXJ0aWZhY3RSZWYoKSAhPSBudWxsICYmICFjdXJyZW50QXJ0aWZhY3QuZ2V0QXJ0aWZhY3RSZWYoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmVxdWFscyhhcnRpZmFjdEluZm8uZ2V0QXJ0aWZhY3RSZWYoKSkpIHsKKyAgICAgICAgICAgICAgICAuZXF1YWxzKGFydGlmYWN0SW5mby5nZXRBcnRpZmFjdFJlZigpKSkgewogICAgICAgICAgICAgbG9nLmVycm9yKCJhcnRpZmFjdCByZWYgY2Fubm90IGJlIHNldCBpZ25vcmluZyIpOwogICAgICAgICB9CiAgICAgICAgIGFydGlmYWN0SW5mby5zZXRBcnRpZmFjdFJlZihjdXJyZW50QXJ0aWZhY3QuZ2V0QXJ0aWZhY3RSZWYoKSk7CiAKICAgICAgICAgaWYgKGFydGlmYWN0SW5mby5nZXRBcnRpZmFjdFJlcG9zaXRvcnkoKSAhPSBudWxsICYmICFjdXJyZW50QXJ0aWZhY3QuZ2V0QXJ0aWZhY3RSZXBvc2l0b3J5KCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZXF1YWxzKGFydGlmYWN0SW5mby5nZXRBcnRpZmFjdFJlcG9zaXRvcnkoKSkpIHsKKyAgICAgICAgICAgICAgICAuZXF1YWxzKGFydGlmYWN0SW5mby5nZXRBcnRpZmFjdFJlcG9zaXRvcnkoKSkpIHsKICAgICAgICAgICAgIGxvZy5lcnJvcigiYXJ0aWZhY3QgcmVwb3NpdG9yeSBjYW5ub3QgYmUgc2V0IGlnbm9yaW5nIik7CiAgICAgICAgIH0KICAgICAgICAgYXJ0aWZhY3RJbmZvLnNldEFydGlmYWN0UmVwb3NpdG9yeShjdXJyZW50QXJ0aWZhY3QuZ2V0QXJ0aWZhY3RSZXBvc2l0b3J5KCkpOwogCiAgICAgICAgIGlmIChhcnRpZmFjdEluZm8uZ2V0VXNlcklkQ3JlYXRvcigpICE9IG51bGwgJiYgIWN1cnJlbnRBcnRpZmFjdC5nZXRVc2VySWRDcmVhdG9yKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmVxdWFscyhhcnRpZmFjdEluZm8uZ2V0VXNlcklkQ3JlYXRvcigpKSkgeworICAgICAgICAgICAgICAgIC5lcXVhbHMoYXJ0aWZhY3RJbmZvLmdldFVzZXJJZENyZWF0b3IoKSkpIHsKICAgICAgICAgICAgIGxvZy5lcnJvcigiY3JlYXRvciB1dWlkIGNhbm5vdCBiZSBzZXQgaWdub3JpbmciKTsKICAgICAgICAgfQogICAgICAgICBhcnRpZmFjdEluZm8uc2V0VXNlcklkQ3JlYXRvcihjdXJyZW50QXJ0aWZhY3QuZ2V0VXNlcklkQ3JlYXRvcigpKTsKIAogICAgICAgICBpZiAoYXJ0aWZhY3RJbmZvLmdldEFydGlmYWN0Q3JlYXRvcigpICE9IG51bGwgJiYgIWN1cnJlbnRBcnRpZmFjdC5nZXRBcnRpZmFjdENyZWF0b3IoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5lcXVhbHMoYXJ0aWZhY3RJbmZvLmdldEFydGlmYWN0Q3JlYXRvcigpKSkgeworICAgICAgICAgICAgICAgIC5lcXVhbHMoYXJ0aWZhY3RJbmZvLmdldEFydGlmYWN0Q3JlYXRvcigpKSkgewogICAgICAgICAgICAgbG9nLmVycm9yKCJhcnRpZmFjdCBjcmVhdG9yIGNhbm5vdCBiZSBzZXQgaWdub3JpbmciKTsKICAgICAgICAgfQogICAgICAgICBhcnRpZmFjdEluZm8uc2V0QXJ0aWZhY3RDcmVhdG9yKGN1cnJlbnRBcnRpZmFjdC5nZXRBcnRpZmFjdENyZWF0b3IoKSk7CiAKICAgICAgICAgaWYgKGFydGlmYWN0SW5mby5nZXRVc2VySWRMYXN0VXBkYXRlcigpICE9IG51bGwgJiYgIWN1cnJlbnRBcnRpZmFjdC5nZXRVc2VySWRMYXN0VXBkYXRlcigpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZXF1YWxzKGFydGlmYWN0SW5mby5nZXRVc2VySWRMYXN0VXBkYXRlcigpKSkgeworICAgICAgICAgICAgICAgIC5lcXVhbHMoYXJ0aWZhY3RJbmZvLmdldFVzZXJJZExhc3RVcGRhdGVyKCkpKSB7CiAgICAgICAgICAgICBsb2cuZXJyb3IoInVzZXJJZCBvZiBsYXN0IHVwZGF0ZXIgY2Fubm90IGJlIHNldCBpZ25vcmluZyIpOwogICAgICAgICB9CiAgICAgICAgIGFydGlmYWN0SW5mby5zZXRVc2VySWRMYXN0VXBkYXRlcih1c2VyLmdldFVzZXJJZCgpKTsKIAogICAgICAgICBpZiAoYXJ0aWZhY3RJbmZvLmdldENyZWF0b3JGdWxsTmFtZSgpICE9IG51bGwgJiYgIWN1cnJlbnRBcnRpZmFjdC5nZXRDcmVhdG9yRnVsbE5hbWUoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5lcXVhbHMoYXJ0aWZhY3RJbmZvLmdldENyZWF0b3JGdWxsTmFtZSgpKSkgeworIC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ICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5lcXVhbHMoYXJ0aWZhY3RJbmZvLmdldENyZWF0aW9uRGF0ZSgpKSkgeworICAgICAgICAgICAgICAgIC5lcXVhbHMoYXJ0aWZhY3RJbmZvLmdldENyZWF0aW9uRGF0ZSgpKSkgewogICAgICAgICAgICAgbG9nLmVycm9yKCJDcmVhdGlvbiBEYXRlIGNhbm5vdCBiZSBzZXQgaWdub3JpbmciKTsKICAgICAgICAgfQogICAgICAgICBhcnRpZmFjdEluZm8uc2V0Q3JlYXRpb25EYXRlKGN1cnJlbnRBcnRpZmFjdC5nZXRDcmVhdGlvbkRhdGUoKSk7CiAKICAgICAgICAgaWYgKGFydGlmYWN0SW5mby5nZXRMYXN0VXBkYXRlRGF0ZSgpICE9IG51bGwgJiYgIWN1cnJlbnRBcnRpZmFjdC5nZXRMYXN0VXBkYXRlRGF0ZSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZXF1YWxzKGFydGlmYWN0SW5mby5nZXRMYXN0VXBkYXRlRGF0ZSgpKSkgeworICAgICAgICAgICAgICAgIC5lcXVhbHMoYXJ0aWZhY3RJbmZvLmdldExhc3RVcGRhdGVEYXRlKCkpKSB7CiAgICAgICAgICAgICBsb2cuZXJyb3IoIkxhc3QgVXBkYXRlIERhdGUgY2Fubm90IGJlIHNldCBpZ25vcmluZyIpOwogICAgICAgICB9CiAgICAgICAgIGxvbmcgdGltZSA9IFN5c3RlbS5jdXJyZW50VGltZU1pbGxpcygpOwpAQCAtMjg1MiwxOSArMjM5NSwxOCBAQAogICAgICAgICBhcnRpZmFjdEluZm8uc2V0RXNJZChjdXJyZW50QXJ0aWZhY3QuZ2V0VW5pcXVlSWQoKSk7CiAKICAgICAgICAgaWYgKGFydGlmYWN0SW5mby5nZXRBcnRpZmFjdERpc3BsYXlOYW1lKCkgIT0gbnVsbCAmJiAhY3VycmVudEFydGlmYWN0LmdldEFydGlmYWN0RGlzcGxheU5hbWUoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZXF1YWxzKGFydGlmYWN0SW5mby5nZXRBcnRpZmFjdERpc3BsYXlOYW1lKCkpKSB7CisgICAgICAgICAgICAgICAgLmVxdWFscyhhcnRpZmFjdEluZm8uZ2V0QXJ0aWZhY3REaXNwbGF5TmFtZSgpKSkgewogICAgICAgICAgICAgbG9nLmVycm9yKCIgQXJ0aWZhY3QgRGlzcGxheSBOYW1lIGNhbm5vdCBiZSBzZXQgaWdub3JpbmciKTsKICAgICAgICAgfQogICAgICAgICBhcnRpZmFjdEluZm8uc2V0QXJ0aWZhY3REaXNwbGF5TmFtZShjdXJyZW50QXJ0aWZhY3QuZ2V0QXJ0aWZhY3REaXNwbGF5TmFtZSgpKTsKIAogICAgICAgICBpZiAoYXJ0aWZhY3RJbmZvLmdldFNlcnZpY2VBcGkoKSAhPSBudWxsICYmICFjdXJyZW50QXJ0aWZhY3QuZ2V0U2VydmljZUFwaSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5lcXVhbHMoYXJ0aWZhY3RJbmZvLmdldFNlcnZpY2VBcGkoKSkpIHsKKyAgICAgICAgICAgICAgICAuZXF1YWxzKGFydGlmYWN0SW5mby5nZXRTZXJ2aWNlQXBpKCkpKSB7CiAgICAgICAgICAgICBsb2cuZGVidWcoInNlcnZpY2VBcGkgY2Fubm90IGJlIHNldC4gaWdub3JpbmcuIik7CiAgICAgICAgIH0KICAgICAgICAgYXJ0aWZhY3RJbmZvLnNldFNlcnZpY2VBcGkoY3VycmVudEFydGlmYWN0LmdldFNlcnZpY2VBcGkoKSk7CiAKLSAgICAgICAgaWYgKGFydGlmYWN0SW5mby5nZXRBcnRpZmFjdEdyb3VwVHlwZSgpICE9IG51bGwgJiYgIWN1cnJlbnRBcnRpZmFjdC5nZXRBcnRpZmFjdEdyb3VwVHlwZSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZXF1YWxzKGFydGlmYWN0SW5mby5nZXRBcnRpZmFjdEdyb3VwVHlwZSgpKSkgeworICAgICAgICBpZiAoYXJ0aWZhY3RJbmZvLmdldEFydGlmYWN0R3JvdXBUeXBlKCkgIT0gbnVsbCAmJiBjdXJyZW50QXJ0aWZhY3QuZ2V0QXJ0aWZhY3RHcm91cFR5cGUoKSAhPSBhcnRpZmFjdEluZm8uZ2V0QXJ0aWZhY3RHcm91cFR5cGUoKSkgewogICAgICAgICAgICAgbG9nLmRlYnVnKCJhcnRpZmFjdCBncm91cCBjYW5ub3QgYmUgc2V0LiBpZ25vcmluZy4iKTsKICAgICAgICAgfQogICAgICAgICBhcnRpZmFjdEluZm8uc2V0QXJ0aWZhY3RHcm91cFR5cGUoY3VycmVudEFydGlmYWN0LmdldEFydGlmYWN0R3JvdXBUeXBlKCkpOwpAQCAtMjg3Miw4ICsyNDE0LDggQEAKICAgICAgICAgYXJ0aWZhY3RJbmZvLnNldEFydGlmYWN0VmVyc2lvbihjdXJyZW50QXJ0aWZhY3QuZ2V0QXJ0aWZhY3RWZXJzaW9uKCkpOwogCiAgICAgICAgIGlmIChhcnRpZmFjdEluZm8uZ2V0QXJ0aWZhY3RVVUlEKCkgIT0gbnVsbCAmJiAhYXJ0aWZhY3RJbmZvLmdldEFydGlmYWN0VVVJRCgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmlzRW1wdHkoKSAmJiAhY3VycmVudEFydGlmYWN0LmdldEFydGlmYWN0VVVJRCgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg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2V0RGVmYXVsdFZhbHVlKCkpOwogICAgICAgICAgICAgICAgICAgICBwYXJhbWV0ZXIuc2V0RGVmYXVsdFZhbHVlKGN1cnJlbnRQYXJhbS5nZXREZWZhdWx0VmFsdWUoKSk7CiAgICAgICAgICAgICAgICAgfQpAQCAtMjkwNyw3ICsyNDQ5LDcgQEAKICAgICAgICAgICAgICAgICAgICAgcGFyYW1ldGVyLnNldFR5cGUoY3VycmVudFBhcmFtLmdldFR5cGUoKSk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIGlmIChwYXJhbWV0ZXIuZ2V0RGVzY3JpcHRpb24oKSAhPSBudWxsICYmICFwYXJhbWV0ZXIuZ2V0RGVzY3JpcHRpb24oKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZXF1YWxzSWdub3JlQ2FzZShjdXJyZW50UGFyYW0uZ2V0RGVzY3JpcHRpb24oKSkpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIC5lcXVhbHNJZ25vcmVDYXNlKGN1cnJlbnRQYXJhbS5nZXREZXNjcmlwdGlvbigpKSkgewogICAgICAgICAgICAgICAgICAgICBsb2cuZGVidWcoImhlYXQgcGFyYW1ldGVyIGRlc2NyaXB0aW9uIGNhbm5vdCBiZSB1cGRhdGVkICAoe30pLiBpZ25vcmluZy4iLCBwYXJhbWV0ZXIuZ2V0RGVzY3JpcHRpb24oKSk7CiAgICAgICAgICAgICAgICAgICAgIHBhcmFtZXRlci5zZXREZXNjcmlwdGlvbihjdXJyZW50UGFyYW0uZ2V0RGVzY3JpcHRpb24oKSk7CiAgICAgICAgICAgICAgICAgfQpAQCAtMjkyMyw3ICsyNDY1LDcgQEAKIAogICAgIHByaXZhdGUgTWFwPFN0cmluZywgSGVhdFBhcmFtZXRlckRlZmluaXRpb24+IGdldE1hcE9mUGFyYW1ldGVycyhMaXN0PEhlYXRQYXJhbWV0ZXJEZWZpbml0aW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LSAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgaWYgKGFydGlmYWN0RGVmaW5pdGlvbi5nZXRFc0lkKCkgPT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICBhcnRpZmFjdERlZmluaXRpb24uc2V0RXNJZChhcnRpZmFjdERlZmluaXRpb24uZ2V0VW5pcXVlSWQoKSk7Ci0gICAgICAgICAgICAgICAgICAgIGFydGlmYWN0RGF0YS5zZXRJZChhcnRpZmFjdERlZmluaXRpb24uZ2V0VW5pcXVlSWQoKSk7Ci0gICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIC8vIGNsb25lIGRhdGEgdG8gbmV3IGFydGlmYWN0CisgICAgICAgICAgICAgICAgYXJ0aWZhY3REYXRhLnNldERhdGEoYXJ0aWZhY3RGcm9tQ2Fzc2FuZHJhLmxlZnQoKS52YWx1ZSgpLmdldERhdGEoKSk7CisgICAgICAgICAgICAgICAgYXJ0aWZhY3REYXRhLnNldElkKGFydGlmYWN0RnJvbUNhc3NhbmRyYS5sZWZ0KCkudmFsdWUoKS5nZXRJZCgpKTsKICAgICAgICAgICAgIH0KLQotICAgICAgICAgICAgTm9kZVR5cGVFbnVtIGNvbnZlcnRQYXJlbnRUeXBlID0gY29udmVydFBhcmVudFR5cGUoY29tcG9uZW50VHlwZSk7Ci0gICAgICAgICAgICBFaXRoZXI8QXJ0aWZhY3REZWZpbml0aW9uLCBTdG9yYWdlT3BlcmF0aW9uU3RhdHVzPiByZXN1bHQgPSBhcnRpZmFjdFRvc2NhT3BlcmF0aW9uLnVwZGF0ZUFydGlmYWN0T25SZXNvdXJjZShhcnRpZmFjdEluZm8sIHBhcmVudAotICAgICAgICAgICAgICAgICAgICAuZ2V0VW5pcXVlSWQoKSwgYXJ0aWZhY3RJZCwgY29udmVydFBhcmVudFR5cGUsIHBhcmVudElkKTsKLSAgICAgICAgICAgIGlzTGVmdCA9IHJlc3VsdC5pc0xlZnQoKTsKLSAgICAgICAgICA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wdGlvbmFsPEVudHJ5PFN0cmluZywgQXJ0aWZhY3REZWZpbml0aW9uPj4gZmluZEZpcnN0ID0gZGVwbG95bWVudEFydGlmYWN0cy5lbnRyeVNldCgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgLnN0cmVhbSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgLmZpbHRlcihhIC0+IGEuZ2V0VmFsdWUoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldEdlbmVyYXRlZEZyb21JZCgpICE9IG51bGwgJiYgYQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldFZhbHVlKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRHZW5lcmF0ZWRGcm9tSWQoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmVxdWFscyhhcnRpZmFjdElkKSkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZmluZEZpcnN0KCk7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChmaW5kRmlyc3QuaXNQcmVzZW50KCkpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIEFydGlmYWN0RGVmaW5pdGlvbiBhcnRpZmFjdEVudkluZm8gPSBmaW5kRmlyc3QuZ2V0KCkuZ2V0VmFsdWUoKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGFydGlmYWN0RW52SW5mby5zZXRBcnRpZmFjdENoZWNrc3VtKG51bGwpOwotICAgICAgICAgICAgICAgICAgICAgICAgYXJ0aWZhY3RUb3NjYU9wZXJhdGlvbi51cGRhdGVIZWF0RW52QXJ0aWZhY3QocGFyZW50LmdldFVuaXF1ZUlkKCksIGFydGlmYWN0RW52SW5mbywgYXJ0aWZhY3RJZCwgYXJ0aWZhY3RVbmlxdWVJZCwgY29udmVydFBhcmVudFR5cGUsIHBhcmVudElkKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBlcnJvciA9IGdlbmVyYXRlQ3VzdG9taXphdGlvblVVSURPbkluc3RhbmNlKHBhcmVudC5nZXRVbmlxdWVJZCgpLCBwYXJlbnRJZCwgY29tcG9uZW50VHlwZSk7Ci0KLSAgICAgICAgICAgICAgICBpbnNpZGVFaXRoZXIgPSBFaXRoZXIubGVmdChyZXN1bHQubGVmdCgpLnZhbHVlKCkpOwotICAgICAgICAgICAgICAgIHJlc3VsdE9wID0gRWl0aGVyLmxlZnQoaW5zaWRlRWl0aGVyKTsKLSAgICAgICAgICAgICAgICBpZiAoZXJyb3IgIT0gU3RvcmFnZU9wZXJhdGlvblN0YXR1cy5PSykgewotICAgICAgICAgICAgICAgICAgICBpc0xlZnQgPSBmYWxzZTsKLSAgICAgICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgZXJyb3IgPSByZXN1bHQucmlnaHQoKS52YWx1ZSgpOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgaWYgKGlzTGVmdCkgewotCi0gICAgICAgICAgICAgICAgLy8gY3JlYXRlIG5ldyBlbnRyeSBpbiBFUwotICAgICAgICAgICAgICAgIHJlcyA9IHRydWU7Ci0gICAgICAgICAgICAgICAgaWYgKGFydGlmYWN0RGF0YS5nZXREYXRhKCkgIT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICBpZiAoIWFydGlmYWN0RGVmaW5pdGlvbi5nZXREdXBsaWNhdGVkKCkgfHwgYXJ0aWZhY3REYXRhLmdldElkKCkgPT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICAgICAgYXJ0aWZhY3REYXRhLnNldElkKGFydGlmYWN0RGVmaW5pdGlvbi5nZXRFc0lkKCkpOwotICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgIHJlcyA9IHNhdmVBcnRpZmFjdHMoYXJ0aWZhY3REYXRhLCBwYXJlbnRJZCk7Ci0KLSAgICAgICA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0RGVmaW5pdGlvbi5nZXRBcnRpZmFjdE5hbWUoKSAhPSBudWxsICYmIGFydGlmYWN0RGVmaW5pdGlvbi5nZXRBcnRpZmFjdE5hbWUoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5lcXVhbHMoYXJ0aWZhY3ROYW1lKSkgeworICAgICAgICAgICAgICAgICAgICAuZXF1YWxzKGFydGlmYWN0TmFtZSkpIHsKICAgICAgICAgICAgICAgICBsb2cuZGVidWcoRk9VTkRfREVQTE9ZTUVOVF9BUlRJRkFDVCwgYXJ0aWZhY3ROYW1lKTsKICAgICAgICAgICAgICAgICBkZXBsb3ltZW50QXJ0aWZhY3QgPSBhcnRpZmFjdERlZmluaXRpb247CiAgICAgICAgICAgICAgICAgYnJlYWs7CkBAIC0zMjkzLDEwMCArMjgwNiw5MSBAQAogCiAgICAgICAgIGlmIChkZXBsb3ltZW50QXJ0aWZhY3QgPT0gbnVsbCkgewogICAgICAgICAgICAgbG9nLmRlYnVnKCJObyBkZXBsb3ltZW50IGFydGlmYWN0IHt9IHdhcyBmb3VuZCBmb3IgcmVzb3VyY2Uge30iLCBhcnRpZmFjdE5hbWUsIHJlc291cmNlSWQpOwotICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLkFSVElGQUNUX05PVF9GT1VORCwgYXJ0aWZhY3ROYW1lKSk7CisgICAgICAgICAgICB0aHJvdyBuZXcgQnlBY3Rpb25TdGF0dXNDb21wb25lbnRFeGNlcHRpb24oQWN0aW9uU3RhdHVzLkFSVElGQUNUX05PVF9GT1VORCwgYXJ0aWZhY3ROYW1lKTsKICAgICAgICAgfQogCiAgICAgICAgIC8vIERvd25sb2FkaW5nIHRoZSBhcnRpZmFjdAotICAgICAgICBFaXRoZXI8SW1tdXRhYm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VyY2VJbnN0YW5jZU5hbWUpOwogCiAgICAgICAgIE1hcDxTdHJpbmcsIEFydGlmYWN0RGVmaW5pdGlvbj4gYXJ0aWZhY3RzID0gcmVzb3VyY2VJbnN0YW5jZS5nZXREZXBsb3ltZW50QXJ0aWZhY3RzKCk7CiAKICAgICAgICAgZmluYWwgU3RyaW5nIGZpbmFsQXJ0aWZhY3ROYW1lID0gYXJ0aWZhY3ROYW1lOwogICAgICAgICBQcmVkaWNhdGU8QXJ0aWZhY3REZWZpbml0aW9uPiBmaWx0ZXJBcnRpZmFjdEJ5TmFtZSA9IHAgLT4gcC5nZXRBcnRpZmFjdE5hbWUoKS5lcXVhbHMoZmluYWxBcnRpZmFjdE5hbWUpOwogCi0gICAgICAgIGJvb2xlYW4gaGFzRGVwbG95bWVudEFydGlmYWN0cyA9IGFydGlmYWN0cyAhPSBudWxsICYmIGFydGlmYWN0cy52YWx1ZXMoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuc3RyZWFtKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmFueU1hdGNoKGZpbHRlckFydGlmYWN0QnlOYW1lKTsKLSAgICAgICAgQXJ0aWZhY3REZWZpbml0aW9uIGRlcGxveWFibGVBcnRpZmFjdDsKKyAgICAgICAgQXJ0aWZhY3REZWZpbml0aW9uIGRlcGxveWFibGVBcnRpZmFjdCA9IGFydGlmYWN0cz09bnVsbCA/IG51bGwgOgorICAgICAgICAgICAgICAgIGFydGlmYWN0cy52YWx1ZXMoKS5zdHJlYW0oKQorICAgICAgICAgICAgICAgICAgICAgICAgLmZpbHRlcihmaWx0ZXJBcnRpZmFjdEJ5TmFtZSkKKyAgICAgICAgICAgICAgICAgICAgICAgIC5maW5kRmlyc3QoKQorICAgICAgICAgICAgICAgICAgICAgICAgLm9yRWxzZShudWxsKT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ZhY3RJZCkgewogICAgICAgICBib29sZWFuIGZvdW5kID0gZmFsc2U7CiAgICAgICAgIE1hcDxTdHJpbmcsIEFydGlmYWN0RGVmaW5pdGlvbj4gYXJ0aWZhY3RzUyA9IGNvbXBvbmVudC5nZXRBcnRpZmFjdHMoKTsKICAgICAgICAgaWYgKGFydGlmYWN0c1MgIT0gbnVsbCkgewpAQCAtMzUzNSw3ICszMDQxLDYgQEAKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KLQogICAgICAgICBzd2l0Y2ggKGNvbXBvbmVudC5nZXRDb21wb25lbnRUeXBlKCkpIHsKICAgICAgICAgICAgIGNhc2UgUkVTT1VSQ0U6CiAgICAgICAgICAgICAgICAgYnJlYWs7CkBAIC0zNTkzLDQxICszMDk4LDQxIEBACiAgICAgICAgIHJldHVybiBmb3VuZDsKICAgICB9CiAKLSAgICBwcml2YXRlIEVpdGhlcjw/IGV4dGVuZHMgb3JnLm9wZW5lY29tcC5zZGMuYmUubW9kZWwuQ29tcG9uZW50LCBSZXNwb25zZUZvcm1hdD4gdmFsaWRhdGVDb21wb25lbnRFeGlzdHMoU3RyaW5nIGNvbXBvbmVudElkLCBBdWRpdGluZ0FjdGlvbkVudW0gYXVkaXRpbmdBY3Rpb24sIFVzZXIgdXNlciwgU3RyaW5nIGFydGlmYWN0SWQsIENvbXBvbmVudFR5cGVFbnVtIGNvbXBvbmVudFR5cGUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZyBjb250YWluZXJDb21wb25lbnRUeXBlKSB7CisgICAgcHJpdmF0ZSBDb21wb25lbnQgdmFsaWRhdGVDb21wb25lbnRFeGlzdHMoU3RyaW5nIGNvbXBvbmVudElkLCBBdWRpdGluZ0FjdGlvbkVudW0gYXVkaXRpbmdBY3Rpb24sIFVzZXI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gU3RyaW5nIHVuaXF1ZUlkID0gY29tcG9uZW50LmdldFVuaXF1ZUlkKCk7CiAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJTZXJ2aWNlIHN0YXR1cyBpc24ndCAgQ0hFQ0tPVVQgb3IgdXNlciBpc24ndCBvd25lciwgc2VydmljZUlkIHt9IiwgdW5pcXVlSWQpOwotICAgICAgICAgICAgICAgIGhhbmRsZUF1ZGl0aW5nKGF1ZGl0aW5nQWN0aW9uLCBjb21wb25lbnQsIHVuaXF1ZUlkLCB1c2VyLCBudWxsLCBudWxsLCBhcnRpZmFjdElkLCBjYW5Xb3JrLnJpZ2h0KCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC52YWx1ZSgpLCBjb21wb25lbnQKLSAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRDb21wb25lbnRUeXBlKCksIG51bGwpOwotICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQoY2FuV29yay5yaWdodCgpLnZhbHVlKCkpOworICAgICAgICAgICAgICAgIGhhbmRsZUF1ZGl0aW5nKGF1ZGl0aW5nQWN0aW9uLCBjb21wb25lbnQsIHVuaXF1ZUlkLCB1c2VyLCBudWxsLCBudWxsLCBhcnRpZmFjdElkLCBlLmdldFJlc3BvbnNlRm9ybWF0KCksCisgICAgICAgICAgICAgICAgICAgICAgICBjb21wb25lbnQuZ2V0Q29tcG9uZW50VHlwZSgpLCBudWxsKTsKKyAgICAgICAgICAgICAgICB0aHJvdyBlOwogICAgICAgICAgICAgfQogICAgICAgICB9Ci0gICAgICAgIHJldHVybiBFaXRoZXIubGVmdCh0cnVlKTsKKyAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgfQogCi0gICAgcHJpdmF0ZSBFaXRoZXI8Qm9vbGVhbiwgUmVzcG9uc2VGb3JtYXQ+IHZhbGl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YXRlSGVhdEVudkFydGlmYWN0KEFydGlmYWN0RGVmaW5pdGlvbiBhcnRpZmFjdERlZmluaXRpb24sIENvbXBvbmVudFR5cGVFbnVtIGNvbXBvbmVudFR5cGUsIENvbXBvbmVudCBjb21wb25lbnQsIFN0cmluZyByZXNvdXJjZUluc3RhbmNlTmFtZSwgVXNlciBtb2RpZmllciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZyBpbnN0YW5jZUlkLCBib29sZWFuIHNob3VsZExvY2ssIGJvb2xlYW4gaW5UcmFuc2FjdGlvbikgewogICAgICAgICBTdHJpbmcgcGF5bG9hZCA9IGdlbmVyYXRlSGVhdEVudlBheWxvYWQoYXJ0aWZhY3REZWZpbml0aW9uKTsKICAgICAgICAgU3RyaW5nIHByZXZVVUlEID0gYXJ0aWZhY3REZWZpbml0aW9uLmdldEFydGlmYWN0VVVJRCgpOwogICAgICAgICBBcnRpZmFjdERlZmluaXRpb24gY2xvbmVkQmVmb3JlR2VuZXJhdGUgPSBuZXcgQXJ0aWZhY3REZWZpbml0aW9uKGFydGlmYWN0RGVmaW5pdGlvbik7CiAgICAgICAgIHJldHVybiBnZW5lcmF0ZUFuZFNhdmVIZWF0RW52QXJ0aWZhY3QoYXJ0aWZhY3REZWZpbml0aW9uLCBwYXlsb2FkLCBjb21wb25lbnRUeXBlLCBjb21wb25lbnQsIHJlc291cmNlSW5zdGFuY2VOYW1lLCBtb2RpZmllciwgaW5zdGFuY2VJZCwgc2hvdWxkTG9jaywgaW5UcmFuc2FjdGlvbikKICAgICAgICAgICAgICAgICAubGVmdCgpCi0gICAgICAgICAgICAgICAgLmJpbmQoYXJ0aWZhY3REZWYgLT4gdXBkYXRlQXJ0aWZhY3RPbkdyb3VwSW5zdGFuY2UoY29tcG9uZW50VHlwZSwgY29tcG9uZW50LCBpbnN0YW5jZUlkLCBwcmV2VVVJRCwgY2xvbm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ZSwgQ29tcG9uZW50IGNvbXBvbmVudCwgU3RyaW5nIGluc3RhbmNlSWQsIFN0cmluZyBwcmV2VVVJRCwgQXJ0aWZhY3REZWZpbml0aW9uIGNsb25lZEJlZm9yZUdlbmVyYXRlLCBBcnRpZmFjdERlZmluaXRpb24gdXBkYXRlZEFydERlZikgeworICAgIEBWaXNpYmxlRm9yVGVzdGluZworICAgIEVpdGhlcjxBcnRpZmFjdERlZmluaXRpb24sIFJlc3BvbnNlRm9ybWF0PiB1cGRhdGVBcnRpZmFjdE9uR3JvdXBJbnN0YW5jZShDb21wb25lbnQgY29tcG9uZW50LCBTdHJpbmcgaW5zdGFuY2VJZCwgU3RyaW5nIHByZXZVVUlELCBBcnRpZmFjdERlZmluaXRpb24gY2xvbmVkQmVmb3JlR2VuZXJhdGUsIEFydGlmYWN0RGVmaW5pdGlvbiB1cGRhdGVkQXJ0RGVmKSB7CiAgICAgICAgIGlmIChwcmV2VVVJRCA9PSBudWxsIHx8ICFwcmV2VVVJRC5lcXVhbHModXBkYXRlZEFydERlZi5nZXRBcnRpZmFjdFVVSUQoKSkpIHsKICAgICAgICAgICAgIExpc3Q8Q29tcG9uZW50SW5zdGFuY2U+IGNvbXBvbmVudEluc3RhbmNlcyA9IGNvbXBvbmVudC5nZXRDb21wb25lbnRJbnN0YW5jZXMoKTsKICAgICAgICAgICAgIGlmIChjb21wb25lbnRJbnN0YW5jZXMgIT0gbnVsbCkgewogICAgICAgICAgICAgICAgIE9wdGlvbmFsPENvbXBvbmVudEluc3RhbmNlPiBmaW5kRmlyc3QgPSBjb21wb25lbnRJbnN0YW5jZXMuc3RyZWFtKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmZpbHRlcihjaSAtPiBjaS5nZXRVbmlxdWVJZCgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZXF1YWxzKGluc3RhbmNlSWQpKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZmluZEZpcnN0KCk7CisgICAgICAgICAgICAgICAgICAgICAgICAuZmlsdGVyKGNpIC0+IGNpLmdldFVuaXF1ZUlkKCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmVxdWFscyhpbnN0YW5jZUlkKSkKKyAgICAgICAgICAgICAgICAgICAgICAgIC5maW5kRmlyc3QoKTsKICAgICAgICAgICAgICAgICBpZiAoZmluZEZpcnN0LmlzUHJlc2VudCgpKSB7CiAgICAgICAgICAgICAgICAgICAgIENvbXBvbmVudEluc3RhbmNlIHJlbGV2YW50SW5zdCA9IGZpbmRGaXJzdC5nZXQoKTsKICAgICAgICAgICAgICAgICAgICAgTGlzdDxHcm91cEluc3RhbmNlPiB1cGRhdGVkR3JvdXBJbnN0YW5jZXMgPSBnZXRVcGRhdGVkR3JvdXBJbnN0YW5jZXModXBkYXRlZEFydERlZi5nZXRVbmlxdWVJZCgpLCBjbG9uZWRCZWZvcmVHZW5lcmF0ZSwgcmVsZXZhbnRJbnN0CkBAIC0zODYxLDcgKzMzNTMsNyBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZyhGQUlMRURfVVBEQVRFX0dST1VQUywgY29tcG9uZW50LmdldFVuaXF1ZUlkKCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgIFJlc3BvbnNlRm9ybWF0IHJlc3BvbnNlRm9ybWF0ID0gY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0QnlBcnRpZmFjdElkKGNvbXBvbmVudHNVdGlscwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmNvbnZlcnRGcm9tU3RvcmFnZVJlc3BvbnNlKHN0YXR1cy5yaWdodCgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnZhbHVlKCkpLCBjbG9uZWRCZWZvcmVHZW5lcmF0ZS5nZXRBcnRpZmFjdERpc3BsYXlOYW1lKCkpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAudmFsdWUoKSksIGNsb25lZEJlZm9yZUdlbmVyYXRlLmdldEFydGlmYWN0RGlzcGxheU5hbWUoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChyZXNwb25zZUZvcm1hdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIH0KQEAgLTM4NzcsNyArMzM2OSw3IEBACiAgICAgICAgIHNiLmFwcGVuZChDb25maWd1cmF0aW9uTWFuYWdlci5nZXRDb25maWd1cmF0aW9uTWFuYWdlcigpLmdldENvbmZpZ3VyYXRpb24oKS5nZXRIZWF0RW52QXJ0aWZhY3RIZWFkZXIoKSk7CiAgICAgICAgIHNiLmFwcGVuZCgicGFyYW1ldGVyczpcbiIpOwogICAgICAgICBpZiAoaGVhdFBhcmFtZXRlcnMgIT0gbnVsbCkgewotICAgICAgICAgICAgaGVhdFBhcmFtZXRlcnMuc29ydChDb21wYXJhdG9yLmNvbXBhcmluZyhlIC0+IGUuZ2V0TmFtZSgpKSk7CisgICAgICAgICAgICBoZWF0UGFyYW1ldGVycy5zb3J0KENvbXBhcmF0b3IuY29tcGFyaW5nKEhlYXRQYXJhbWV0ZXJEYXRhRGVmaW5pdGlvbjo6Z2V0TmFtZSkpOwogCiAgICAgICAgICAgICBMaXN0PEhlYXRQYXJhbWV0ZXJEZWZpbml0aW9uPiBlbXBsdHlIZWF0VmFsdWVzID0gbmV3IEFycmF5TGlzdDw+KCk7CiAKQEAgLTM4OTYsMjggKzMzODgsMjggQEAKICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0eXBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIEJPT0xFQU46CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKCIgICIpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuYXBwZW5kKGhlYXRQYXJhbWV0ZXJEZWZpbml0aW9uLmdldE5hbWUoKSkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5hcHBlbmQoIjoiKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmFwcGVuZCgiICIpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuYXBwZW5kKEJvb2xlYW4ucGFyc2VCb29sZWFuKGhlYXRWYWx1ZSkpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuYXBwZW5kKCJcbiIpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmFwcGVuZChoZWF0UGFyYW1ldGVyRGVmaW5pdGlvbi5nZXROYW1lKCkpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuYXBwZW5kKCI6IikKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5hcHBlbmQoIiAiKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmFwcGVuZChCb29sZWFuLnBhcnNlQm9vbGVhbihoZWF0VmFsdWUpKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmFwcGVuZCgiXG4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgTlVNQkVSOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNiLmFwcGVuZCgiICAiKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmFwcGVuZChoZWF0UGFyYW1ldGVyRGVmaW5pdGlvbi5nZXROYW1lKCkpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuYXBwZW5kKCI6IikKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5hcHBlbmQoIiAiKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmFwcGVuZChuZXcgQmlnRGVjaW1hbChoZWF0VmFsdWUpLnRvUGxhaW5TdHJpbmcoKSkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5hcHBlbmQoIlxuIik7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuYXBwZW5kKGhlYXRQYXJhbWV0ZXJEZWZpbml0aW9uLmdldE5hbWUoKSkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5hcHBlbmQoIjoiKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmFwcGVuZCgiICIpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuYXBwZW5kKG5ldyBCaWdEZWNpbWFsKGhlYXRWYWx1ZSkudG9QbGFpblN0cmluZygpKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmFwcGVuZCgiXG4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgQ09NTUFfREVMSU1JVEVEX0xJU1Q6CiAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIEpTT046CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKCIgICIpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuYXBwZW5kKGhlYXRQYXJhbWV0ZXJEZWZpbml0aW9uLmdldE5hbWUoKSkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5hcHBlbmQoIjoiKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmFwcGVuZCgiICIpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuYXBwZW5kKGhlYXRWYWx1ZSkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5hcHBlbmQoIlxuIik7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuYXBwZW5kKGhlYXRQYXJhbWV0ZXJEZWZpbml0aW9uLmdldE5hbWUoKSkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5hcHBlbmQoIjoiKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmFwcGVuZCgiICIpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuYXBwZW5kKGhlYXRWYWx1ZSkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5hcHBlbmQoIlxuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZyB2YWx1ZSA9IGhlYXRWYWx1ZTsKQEAgLTM5MzEsMTAgKzM0MjMsMTAgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQoIiAgIikKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5hcHBlbmQoaGVhdFBhcmFtZXRlckRlZmluaXRpb24uZ2V0TmFtZSgpKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmFwcGVuZCgiOiIpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuYXBwZW5kKCIgIikKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5hcHBlbmQodmFsdWUpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmFwcGVuZChoZWF0UGFyYW1ldGVyRGVmaW5pdGlvbi5nZXROYW1lKCkpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuYXBwZW5kKCI6IikKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5hcHBlbmQoIiAiKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmFwcGVuZCh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2IuYXBwZW5kKCJcbiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogCkBAIC0zOTQyLDcgKzM0MzQsNyBAQAogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KICAgICAgICAgICAgIGlmICghZW1wbHR5SGVhdFZhbHVlcy5pc0VtcHR5KCkpIHsKLSAgICAgICAgICAgICAgICBlbXBsdHlIZWF0VmFsdWVzLnNvcnQoQ29tcGFyYXRvci5jb21wYXJpbmcoZSAtPiBlLmdldE5hbWUoKSkpOworICAgICAgICAgICAgICAgIGVtcGx0eUhlYXRWYWx1ZXMuc29ydChDb21wYXJhdG9yLmNvbXBhcmluZyhIZWF0UGFyYW1ldGVyRGF0YURlZmluaXRpb246OmdldE5hbWUpKTsKICAgICAgICAgICAgICAgICBlbXBsdHlIZWF0VmFsdWVzLmZvckVhY2goaHYgLT4gewogICAgICAgICAgICAgICAgICAgICBzYi5hcHBlbmQoIiAgIikuYXBwZW5kKGh2LmdldE5hbWUoKSkuYXBwZW5kKCI6Iik7CiAgICAgICAgICAgICAgICAgICAgIEhlYXRQYXJhbWV0ZXJUeXBlIHR5cGUgPSBIZWF0UGFyYW1ldGVyVHlwZS5pc1ZhbGlkVHlwZShodi5nZXRUeXBlKCkpOwpAQCAtMzk2NywyMyArMzQ1OSwyMiBAQAogICAgICAqIEBwYXJhbSBwYXlsb2FkCiAgICAgICogQHJldHVybgogICAgICAqLwotICAgIHB1YmxpYyBFaXRoZXI8QXJ0aWZhY3REZWZpbml0aW9uLCBSZXNwb25zZUZvcm1hdD4gZ2VuZXJhdGVBbmRTYXZlSGVhdEVudkFydGlmYWN0KEFydGlmYWN0RGVmaW5pdGlvbiBhcnRpZmFjdERlZmluaXRpb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V0RGF0YUFzQXJyYXkoKSk7CisgICAgICAgICAgICAgICAgREFPQXJ0aWZhY3REYXRhID0gYXJ0aWZhY3Rmcm9tRVMubGVmdCgpLnZhbHVlKCk7CisgICAgICAgICAgICAgICAgb2xkQ2hlY2tTdW0gPSBHZW5lcmFsVXRpbGl0eS5jYWxjdWxhdGVNRDVCYXNlNjRFbmNvZGVkQnlCeXRlQXJyYXkoREFPQXJ0aWZhY3REYXRhLmdldERhdGFBc0FycmF5KCkpOwogICAgICAgICAgICAgfQogICAgICAgICAgICAgZWxzZSB7CiAgICAgICAgICAgICAgICAgb2xkQ2hlY2tTdW0gPSBhcnRpZmFjdERlZmluaXRpb24uZ2V0QXJ0aWZhY3RDaGVja3N1bSgpOwpAQCAtNDAzMCwxMSArMzUyMSwxMiBAQAogICAgICAgICAgICAgRWl0aGVyPEFydGlmYWN0RGVmaW5pdGlvbiwgU3RvcmFnZU9wZXJhdGlvblN0YXR1cz4gdXBkYXRlQXJpZmFjdERlZmluaXRpb25TdGF0dXMgPSBudWxsOwogCiAgICAgICAgICAgICBpZiAoc2hvdWxkTG9jaykgewotICAgICAgICAgICAgICAgIEVpdGhlcjxCb29sZWFuLCBSZXNwb25zZUZvcm1hdD4gbG9ja0NvbXBvbmVudCA9IGxvY2tDb21wb25lbnQoY29tcG9uZW50LCAiVXBkYXRlIEFydGlmYWN0IC0gbG9jayByZXNvdXJjZTogIik7Ci0gICAgICAgICAgICAgICAgaWYgKGxvY2tDb21wb25lbnQuaXNSaWdodCgpKSB7CisgICAgICAgICAgICAgICAgdHJ5IHsKKyAgICAgICAgICAgICAgICAgICAgbG9ja0NvbXBvbmVudChjb21wb25lbnQsICJVcGRhdGUgQXJ0aWZhY3QgLSBsb2NrIHJlc291cmNlOiAiKTsKKyAgICAgICAgICAgICAgICB9Y2F0Y2ggKENvbXBvbmVudEV4Y2VwdGlvbiBlKXsKICAgICAgICAgICAgICAgICAgICAgaGFuZGxlQXVkaXRpbmcoQXVkaXRpbmdBY3Rpb25FbnVtLkFSVElGQUNUX01FVEFEQVRBX1VQREFURSwgY29tcG9uZW50LCBjb21wb25lbnQuZ2V0VW5pcXVlSWQoKSwgbW9kaWZpZXIsIG51bGwsIG51bGwsIGFydGlmYWN0RGVmaW5pdGlvbgotICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRVbmlxdWVJZCgpLCBsb2NrQ29tcG9uZW50LnJpZ2h0KCkudmFsdWUoKSwgY29tcG9uZW50LmdldENvbXBvbmVudFR5cGUoKSwgbnVsbCk7Ci0gICAgICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQobG9ja0NvbXBvbmVudC5yaWdodCgpLnZhbHVlKCkpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRVbmlxdWVJZCgpLCBlLmdldFJlc3BvbnNlRm9ybWF0KCksIGNvbXBvbmVudC5nZXRDb21wb25lbnRUeXBlKCksIG51bGwpOworICAgICAgICAgICAgICAgICAgICB0aHJvdyBlOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KICAgICAgICAgICAgIHRyeSB7CkBAIC00MDQyLDcgKzM1MzQsNyBAQAogCiAgICAgICAgICAgICAgICAgICAgIGFydGlmYWN0RGVmaW5pdGlvbi5zZXRQYXlsb2FkVXBkYXRlRGF0ZShwYXlsb2FkVXBkYXRlRGF0ZUdlbi5nZXQoKSk7CiAgICAgICAgICAgICAgICAgICAgIHVwZGF0ZUFyaWZhY3REZWZpbml0aW9uU3RhdHVzID0gYXJ0aWZhY3RUb3NjYU9wZXJhdGlvbi51cGRhdGVBcnRpZmFjdE9uUmVzb3VyY2UoYXJ0aWZhY3REZWZpbml0aW9uLCBjb21wb25lbnQKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0VW5pcXVlSWQoKSwgYXJ0aWZhY3REZWZpbml0aW9uLmdldFVuaXF1ZUlkKCksIGNvbXBvbmVudFR5cGUuZ2V0Tm9kZVR5cGUoKSwgaW5zdGFuY2VJZCk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgLGFydGlmYWN0RGVmaW5pdGlvbi5nZXRVbmlxdWVJZCgpLCBjb21wb25lbnRUeXBlLmdldE5vZGVUeXBlKCksIGluc3RhbmNlSWQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICBsb2cudHJhY2UoIk5vIHJlYWwgdXBkYXRlIGRvbmUgaW4gcGF5bG9hZCBmb3Ige30gYXJ0aWZhY3QsIHVwZGF0aW5nIHBheWxvYWRVcGRhdGVEYXRlIHt9IiwgYXJ0aWZhY3REZWZpbml0aW9uCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldEFydGlmYWN0VHlwZSgpLCBhcnRpZmFjdERlZmluaXRpb24uZ2V0RXNJZCgpKTsKICAgICAgICAgICAgICAgICAgICAgaWYgKHVwZGF0ZUFyaWZhY3REZWZpbml0aW9uU3RhdHVzLmlzUmlnaHQoKSkgewpAQCAtNDA1OCwyOCArMzU1MCwyNyBAQAogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIGVsc2UgewotCi0gICAgICAgICAgICAgICAgICAgIG9sZENoZWNrU3VtID0gYXJ0aWZhY3REZWZpbml0aW9uLmdldEFydGlmYWN0Q2hlY2tzdW0oKTsKKyAgICAgICAgICAgICAgICAgICAgYXJ0aWZhY3REZWZpbml0aW9uLmdldEFydGlmYWN0Q2hlY2tzdW0oKTsKICAgICAgICAgICAgICAgICAgICAgYXJ0aWZhY3REZWZpbml0aW9uLnNldEFydGlmYWN0Q2hlY2tzdW0obmV3Q2hlY2tTdW0pOwogICAgICAgICAgICAgICAgICAgICBhcnRpZmFjdERlZmluaXRpb24uc2V0RXNJZChhcnRpZmFjdERlZmluaXRpb24uZ2V0VW5pcXVlSWQoKSk7CiAgICAgICAgICAgICAgICAgICAgIGxvZy50cmFjZSgiTm8gcmVhbCB1cGRhdGUgZG9uZSBpbiBwYXlsb2FkIGZvciB7fSBhcnRpZmFjdCwgdXBkYXRpbmcgcGF5bG9hZFVwZGF0ZURhdGUge30iLCBhcnRpZmFjdERlZmluaXRpb24KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0QXJ0aWZhY3RUeXBlKCksIGFydGlmYWN0RGVmaW5pdGlvbi5nZXRFc0lkKCkpOwotICAgICAgICAgICAgICAgICAgICB1cGRhdGVBcmlmYWN0RGVmaW5pdGlvblN0YXR1cyA9IGFydGlmYWN0VG9zY2FPcGVyYXRpb24udXBkYXRlQXJ0aWZhY3RPblJlc291cmNlKGFydGlmYWN0RGVmaW5pdGlvbiwgY29tcG9uZW50Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldFVuaXF1ZUlkKCksIGFydGlmYWN0RGVmaW5pdGlvbi5nZXRVbmlxdWVJZCgpLCBjb21wb25lbnRUeXBlLmdldE5vZGVUeXBlKCksIGluc3RhbmNlSWQpOworICAgICAgICAgICAgICAgICAgICB1cGRhdGVBcmlmYWN0RGVmaW5pdGlvblN0YXR1cyA9IGFydGlmYWN0VG9zY2FPcGVyYXRpb24udXBkYXRlQXJ0aWZhY3RPblJlc291cmNlKGFydGlmYWN0RGVmaW5pdGlvbiwgY29tcG9uZW50LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFydGlmYWN0RGVmaW5pdGlvbi5nZXRVbmlxdWVJZCgpLCBjb21wb25lbnRUeXBlLmdldE5vZGVUeXBlKCksIGluc3RhbmNlSWQsIHRydWUpOwogCi0gICAgICAgICAgICAgICAgICAgIGxvZy50cmFjZSgiVXBkYXRlIFBheWxvYWQgICIsIGFydGlmYWN0RGVmaW5pdGlvbi5nZXRFc0lkKCkpOworICAgICAgICAgICAgICAgICAgICBsb2cudHJhY2UoIlVwZGF0ZSBQYXlsb2FkIHt9IiwgYXJ0aWZhY3REZWZpbml0aW9uLmdldEVzSWQoKSk7CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIGlmICh1cGRhdGVBcmlmYWN0RGVma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FuZHJhIHt9IiwgYXJ0aWZhY3REYXRhLmdldElkKCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgUmVzcG9uc2VGb3JtYXQgcmVzcG9uc2VGb3JtYXQgPSBjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLk9LKTsKICAgICAgICAgICAgICAgICAgICAgICAgIGhhbmRsZUF1ZGl0aW5nKEF1ZGl0aW5nQWN0aW9uRW51bS5BUlRJRkFDVF9QQVlMT0FEX1VQREFURSwgY29tcG9uZW50LCBjb21wb25lbnQuZ2V0VW5pcXVlSWQoKSwgbW9kaWZpZXIsIGFydGlmYWN0RGVmaW5pdGlvbiwgYXJ0aWZhY3REZWZpbml0aW9uCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldFVuaXF1ZUlkKCksIGFydGlmYWN0RGVmaW5pdGlvbi5nZXRVbmlxdWVJZCgpLCByZXNwb25zZUZvcm1hdCwKQEAgLTQxMTUsNyArMzYwNiw3IEBACiAgICAgICAgICAgICBmaW5hbGx5IHsKICAgICAgICAgICAgICAgICBpZiAoc2hvdWxkTG9jaykgewogICAgICAgICAgICAgICAgICAgICBncmFwaExvY2tPcGVyYXRpb24udW5sb2NrQ29tcG9uZW50KGNvbXBvbmVudC5nZXRVbmlxdWVJZCgpLCBjb21wb25lbnQuZ2V0Q29tcG9uZW50VHlwZSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXROb2RlVHlwZSgpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0Tm9kZVR5cGUoKSk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogICAgICAgICB9CkBAIC00MTUzLDI1OSArMzY0NCwyMDggQEAKICAgICAgICAganNvbi5wdXQoQ29uc3RhbnRzLkFSVElGQUNUX0dST1VQX1RZUEUsIGFydGlmYWN0R3JvdXBUeXBlLmdldFR5cGUoKSk7CiAgICAgICAgIGpzb24ucHV0KENvbnN0YW50cy5SRVFVSVJFRF9BUlRJRkFDVFMsICh1cGRhdGVkUmVxdWlyZWRBcnRpZmFjdHMgPT0gbnVsbCB8fCB1cGRhdGVkUmVxdWlyZWRBcnRpZmFjdHMuaXNFbXB0eSgpKSA/IG5ldyBBcnJheUxpc3Q8PigpCiAgICAgICAgICAgICAgICAgOiB1cGRhdGVkUmVxdWlyZWRBcnRpZmFjdHMuc3RyZWFtKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5maWx0ZXIoZSAtPiBlLmdldFR5cGUoKS5lcXVhbHMoQXJ0aWZhY3RUeXBlRW51bS5IRUFUX0FSVElGQUNULmdldFR5cGUoKSkgfHwgZQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0VHlwZSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5lcXVhbHMoQXJ0aWZhY3RUeXBlRW51bS5IRUFUX05FU1RFRC5nZXRUeXBlKCkpKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLm1hcChlIC0+IGUuZ2V0RmlsZU5hbWUoKSkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5jb2xsZWN0KENvbGxlY3RvcnMudG9MaXN0KCkpKTsKKyAgICAgICAgICAgICAgICAuZmlsdGVyKGUgLT4gZS5nZXRUeXBlKCkuZXF1YWxzKEFydGlmYWN0VHlwZUVudW0uSEVBVF9BUlRJRkFDVC5nZXRUeXBlKCkpIHx8IGUKKyAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRUeXBlKCkKKyAgICAgICAgICAgICAgICAgICAgICAgIC5lcXVhbHMoQXJ0aWZhY3RUeXBlRW51bS5IRUFUX05FU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PSBsb2NrQ29tcG9uZW50KHBhcmVudCwgVVBEQVRFX0FSVElGQUNUX0xPQ0spOwotICAgICAgICAgICAgaWYgKGxvY2tDb21wb25lbnQuaXNSaWdodCgpKSB7Ci0gICAgICAgICAgICAgICAgaGFuZGxlQXVkaXRpbmcoYXVkaXRpbmdBY3Rpb24sIHBhcmVudCwgcGFyZW50SWQsIHVzZXIsIG51bGwsIG51bGwsIGFydGlmYWN0SWQsIGxvY2tDb21wb25lbnQucmlnaHQoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnZhbHVlKCksIGNvbXBvbmVudFR5cGUsIG51bGwpOwotICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQobG9ja0NvbXBvbmVudC5yaWdodCgpLnZhbHVlKCkpOwotICAgICAgICAgICAgfQotICAgICAgICB9Ci0gICAgICAgIEVpdGhlcjxFaXRoZXI8QXJ0aWZhY3REZWZpbml0aW9uLCBPcGVyYXRpb24+LCBSZXNwb25zZUZvcm1hdD4gcmVzdWx0T3AgPSBudWxsOwotICAgICAgICB0cnkgewotICAgICAgICAgICAgcmVzdWx0T3AgPSB1cGRhdGVIZWF0RW52UGFyYW1zKGNvbXBvbmVudElkLCBhcnRpZmFjdElkLCBhcnRpZmFjdEluZm8sIHVzZXIsIGF1ZGl0aW5nQWN0aW9uLCBwYXJlbnQsIGNvbXBvbmVudFR5cGUsIG9yaWdNZDUpOwotICAgICAgICAgICAgcmV0dXJuIHJlc3VsdE9wOwotCi0gICAgICAgIH0KLSAgICAgICAgZmluYWxseSB7Ci0gICAgICAgICAgICAvLyB1bmxvY2sgcmVzb3VyY2UKLSAgICAgICAgICAgIGlmIChyZXN1bHRPcCA9PSBudWxsIHx8IHJlc3VsdE9wLmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZyhST0xMQkFDSyk7Ci0gICAgICAgICAgICAgICAgaWYgKCFpblRyYW5zYWN0aW9uKSB7Ci0gICAgICAgICAgICAgICAgICAgIGphbnVzR3JhcGhEYW8ucm9sbGJhY2soKTsKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBlbHNlIHsKLSAgICAgICAgICAgICAgICBsb2cuZGVidWcoQ09NTUlUKTsKLSAgICAgICAgICAgICAgICBpZiAoIWluVHJhbnNhY3Rpb24pIHsKLSAgICAgICAgICAgICAgICAgICAgamFudXNHcmFwaERhby5jb21taXQoKTsKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBpZiAoc2hvdWxkTG9jaykgewotICAgICAgICAgICAgICAgIGNvbXBvbmVudFR5cGUgPSBwYXJlbnQuZ2V0Q29tcG9uZW50VHlwZSgpOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgTm9kZVR5cGVFbnVtIG5vZGVUeXBlID0gY29tcG9uZW50VHlwZS5nZXROb2RlVHlwZSgpOwotICAgICAgICAgICAgZ3JhcGhMb2NrT3BlcmF0aW9uLnVubG9ja0NvbXBvbmVudChwYXJlbnQuZ2V0VW5pcXVlSWQoKSwgbm9kZVR5cGUpOwotICAgICAgICB9CisgICAgICAgIHJldHVybiB1cGRhdGVIZWF0RW52UGFyYW1zQW5kTWV0YWRhdGEoY29tcG9uZW50SWQsIGFydGlmYWN0SWQsIGFydGlmYWN0SW5mbywgdXNlciwgYXVkaXRpbmdBY3Rpb24sIHBhcmVudCwgY29tcG9uZW50VHlwZSwgb3JpZ01kNSk7CiAgICAgfQogCi0gICAgcHJpdmF0ZSBFaXRoZXI8RWl0aGVyPEFydGlmYWN0RGVmaW5pdGlvbiwgT3BlcmF0aW9uPiwgUmVzcG9uc2VGb3JtYXQ+IHVwZGF0ZUhlYXRFbnZQYXJhbXMoU3RyaW5nIGNvbXBvbmVudElkLCBTdHJpbmcgYXJ0aWZhY3RJZCwgQXJ0aWZhY3REZWZpbml0aW9uIGFydGlmYWN0SW5mbywgVXNlciB1c2VyLCBBdWRpdGluZ0FjdGlvbkVudW0gYXVkaXRpbmdBY3Rpb24sIENvbXBvbmVudCBwYXJlbnQsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29tcG9uZW50VHlwZUVudW0gY29tcG9uZW50VHlwZSwgU3RyaW5nIG9yaWdNZDUpIHsKLQotICAgICAgICBFaXRoZXI8RWl0aGVyPEFydGlmYWN0RGVmaW5pdGlvbiwgT3BlcmF0aW9uPiwgUmVzcG9uc2VGb3JtYXQ+IHJlc3VsdE9wID0gbnVsbDsKLSAgICAgICAgRWl0aGVyPEFydGlmYWN0RGVmaW5pdGlvbiwgT3BlcmF0aW9uPiBpbnNpZGVFaXRoZXIgPSBudWxsOworICAgIHByaXZhdGUgRWl0aGVyPEFydGlmYWN0RGVmaW5pdGlvbiwgT3BlcmF0aW9uPiB1cGRhdGVIZWF0RW52UGFyYW1zQW5kTWV0YWRhdGEoU3RyaW5nIGNvbXBvbmVudElkLCBTdHJpbmcgYXJ0aWZhY3RJZCwgQXJ0aWZhY3REZWZpbml0aW9uIGFydGlmYWN0SW5mbywgVXNlciB1c2VyLCBBdWRpdGluZ0FjdGlvbkVudW0gYXVkaXRpbmdBY3Rpb24sIENvbXBvbmVudCBwYXJlbnQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb21wb25lbnRUeXBlRW51bSBjb21wb25lbnRUeXBlLCBTdHJpbmcgb3JpZ01kNSkgewogICAgICAgICBFaXRoZXI8Q29tcG9uZW50SW5zdGFuY2UsIFJlc3BvbnNlRm9ybWF0PiBnZXRSSSA9IGdldFJJRnJvbUNvbXBvbmVudChwYXJlbnQsIGNvbXBvb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ZSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5lcXVhbHMoQXJ0aWZhY3RUeXBlRW51bS5IRUFUX1ZPTAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRUeXBlKCkpIHx8IGN1cnJBcnRpZmFjdAotICAgICAgICAgICAgICAgIC5nZXRBcnRpZmFjdFR5cGUoKQotICAgICAgICAgICAgICAgIC5lcXVhbHMoQXJ0aWZhY3RUeXBlRW51bS5IRUFUX05FVC5nZXRUeXBlKCkpKSB7Ci0gICAgICAgICAgICBSZXNwb25zZUZvcm1hdCByZXNwb25zZUZvcm1hdCA9IGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuUkVTVFJJQ1RFRF9PUEVSQVRJT04pOwotICAgICAgICAgICAgaGFuZGxlQXVkaXRpbmcoYXVkaXRpbmdBY3Rpb24sIHBhcmVudCwgcGFyZW50LmdldFVuaXF1ZUlkKCksIHVzZXIsIGFydGlmYWN0SW5mbywgbnVsbCwgYXJ0aWZhY3RJZCwgcmVzcG9uc2VGb3JtYXQsIGNvbXBvbmVudFR5cGUsIHJpCi0gICAgICAgICAgICAgICAgICAgIC5nZXROYW1lKCkpOwotICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChyZXNwb25zZUZvcm1hdCk7CisgICAgICAgIGlmIChjdXJyQXJ0aWZhY3QuZ2V0QXJ0aWZhY3RUeXBlKCkuZXF1YWxzKEFydGlmYWN0VHlwZUVudW0uSEVBVC5nZXRUeXBlKCkpIHx8CisgICAgICAgICAgICAgICAgY3VyckFydGlmYWN0LmdldEFydGlmYWN0VHlwZSgpLmVxdWFscyhBcnRpZm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gICAgICAgICAgICAgICBSZXNwb25zZUZvcm1hdCByZXNwb25zZUZvcm1hdCA9IGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChjb21wb25lbnRzVXRpbHMuY29udmVydEZyb21TdG9yYWdlUmVzcG9uc2UoZXJyb3IpKTsKLSAgICAgICAgICAgICAgICBoYW5kbGVBdWRpdGluZyhhdWRpdGluZ0FjdGlvbiwgcGFyZW50LCBwYXJlbnQuZ2V0VW5pcXVlSWQoKSwgdXNlciwgYXJ0aWZhY3RJbmZvLCBudWxsLCBhcnRpZmFjdElkLCByZXNwb25zZUZvcm1hdCwgY29tcG9uZW50VHlwZSwgcmkKLSAgICAgICAgICAgICAgICAgICAgICAgIC5nZXROYW1lKCkpOwotICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQocmVzcG9uc2VGb3JtYXQpOwotICAgICAgICAgICAgfQotCi0gICAgICAgICAgICBlcnJvciA9IGdlbmVyYXRlQ3VzdG9taXphdGlvblVVSURPbkdyb3VwSW5zdGFuY2UocmksIHVwZGF0ZUFyaWZhY3RSZXMubGVmdCgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAudmFsdWUoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldFVuaXF1ZUlkKCksIHBhcmVudC5nZXRVbmlxdWVJZCgpKTsKLSAgICAgICAgICAgIGlmIChlcnJvciAhPSBTdG9yYWdlT3BlcmF0aW9uU3RhdHVzLk9LKSB7Ci0gICAgICAgICAgICAgICAgUmVzcG9uc2VGb3JtYXQgcmVzcG9uc2VGb3JtYXQgPSBjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoY29tcG9uZW50c1V0aWxzLmNvbnZlcnRGcm9tU3RvcmFnZVJlc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gIGlzVXBkYXRlID0gdHJ1ZTsKKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgICAgICByZXR1cm4gaXNVcGRhdGU7CisgICAgfQorCisgICAgcHJpdmF0ZSB2b2lkIHZhbGlkYXRlUGFyYW1OYW1lKFN0cmluZyBwYXJhbU5hbWUsIExpc3Q8U3RyaW5nPiBoZWF0UGFyYW1zTmFtZXMpIHsKKyAgICAgICAgaWYgKCFoZWF0UGFyYW1zTmFtZXMuY29udGFpbnMocGFyYW1OYW1lKSkgeworICAgICAgICAgICAgdGhyb3cgbmV3IEJ5QWN0aW9uU3RhdHVzQ29tcG9uZW50RXhjZXB0aW9uKEFjdGlvblN0YXR1cy5QUk9QRVJUWV9OT1RfRk9VTkQsIHBhcmFtTmFtZSk7CisgICAgICAgIH0KKyAgICB9CisKKyAgICBwcml2YXRlIEVpdGhlcjxBcnRpZmFjdERlZmluaXRpb24sIE9wZXJhdGlvbj4gdXBkYXRlSGVhdFBhcmFtcyhTdHJpbmcgY29tcG9uZW50SWQsIEFydGlmYWN0RGVmaW5pdGlvbiBhcnRpZmFjdEVudkluZm8sIEF1ZGl0aW5nQWN0aW9uRW51bSBhdWRpdGluZ0FjdGlvbiwgQ29tcG9uZW50IHBhcmVudCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb21wb25lbnRUeXBlRW51bSBjb21wb25lbnRUeXBlLCBBcnRpZmFjdERlZmluaXRpb24gY3VyckhlYXRBcnRpZmFjdCwgYm9vbGVhbiBuZWVkVG9VcGRhdGVHcm91cCkgewogICAgICAgICBFaXRoZXI8QXJ0aWZhY3REZWZpbml0aW9uLCBPcGVyYXRpb24+IGluc2lkZUVpdGhlciA9IG51bGw7CiAgICAgICAgIFN0cmluZyBjdXJyZW50SGVhdElkID0gY3VyckhlYXRBcnRpZmFjdC5nZXR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IHsKLQogICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nIHVwZGF0ZWRQYXJhbVZhbHVlID0gaGVhdEVudlBhcmFtLmdldEN1cnJlbnRWYWx1ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHVwZGF0ZWRQYXJhbVZhbHVlID09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cGRhdGVkUGFyYW1WYWx1ZSA9IGhlYXRFbnZQYXJhbS5nZXREZWZhdWx0VmFsdWUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgIEhlYXRQYXJhbWV0ZXJUeXBlIHBhcmFtVHlwZSA9IEhlYXRQYXJhbWV0ZXJUeXBlLmlzVmFsaWRUeXBlKGN1cnJIZWF0UGFyYW0uZ2V0VHlwZSgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghcGFyYW1UeXBlLmdldFZhbGlkYXRvcigpLmlzVmFsaWQodXBkYXRlZFBhcmFtVmFsdWUsIG51bGwpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgQWN0aW9uU3RhdHVzIHN0YXR1cyA9IEFjdGlvblN0YXR1cy5JTlZBTElEX0hFQVRfUEFSQU1FVEVSX1ZBTFVFOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIFJlc3BvbnNlRm9ybWF0IHJlc3BvbnNlRm9ybWF0ID0gY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KHN0YXR1cywgQXJ0aWZhY3RUeXBlRW51bS5IRUFUX0VOVgotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldFR5cGUoKSwgcGFyYW1UeXBlLmdldFR5cGUoKSwgcGFyYW1OYW1lKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYW5kbGVBdWRpdGluZyhhdWRpdGluZ0FjdGlvbiwgcGFyZW50LCBwYXJlbnQuZ2V0VW5pcXVlSWQoKSwgdXNlciwgYXJ0aWZhY3RFbnZJbmZvLCBudWxsLCBhcnRpZmFjdElkLCByZXNwb25zZUZvcm1hdCwgY29tcG9uZW50VHlwZSwgIiIpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQocmVzcG9uc2VGb3JtYXQpOwotCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEJ5QWN0aW9uU3RhdHVzQ29tcG9uZW50RXhjZXB0aW9uKEFjdGlvblN0YXR1cy5JTlZBTElEX0hFQVRfUEFSQU1FVEVSX1ZBTFVFLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQXJ0aWZhY3RUeXBlRW51bS5IRUFUX0VOVi5nZXRUeXBlKCksIHBhcmFtVHlwZS5nZXRUeXBlKCksIHBhcmFtTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICBjdXJySGVhdFBhcmFtLnNldEN1cnJlbnRWYWx1ZShwYXJhbVR5cGUuZ2V0Q29udmVydGVyKCkuY29udmVydCh1cGRhdGVkUGFyYW1WYWx1ZSwgbnVsbCwgbnVsbCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgbmV3SGVhdEVudlBhcmFtcy5hZGQoY3VyckhlYXRQYXJhbSk7CkBAIC00NDE1LDc4ICszODU1LDQ1IEBACiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBpZiAoIW5ld0hlYXRFbnZQYXJhbXMuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgY3VyckhlYXRBcnRpZmFjdC5zZXRMaXN0SGVhdFBhcmFtZXRlcnMoY3VycmVudEhlYXRFbnZQYXJhbXMpOwotICAgICAgICAgICAgICAgIEVpdGhlcjxBcnRpZmFjdERlZmluaXRpb24sIFN0b3JhZ2VPcGVyYXRpb25TdGF0dXM+IG9wZXJhdGlvblN0YXR1cyA9IGFydGlmYWN0VG9zY2FPcGV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AgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQocmVzcG9uc2VGb3JtYXQpOwotCisgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBTdG9yYWdlRXhjZXB0aW9uKG9wZXJhdGlvblN0YXR1cy5yaWdodCgpLnZhbHVlKCkpOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB1cGRhdGVkSGVhdEFydCA9IG9wZXJhdGlvblN0YXR1cy5sZWZ0KCkudmFsdWUoKTsKLSAgICAgICAgICAgICAgICBib29sZWFuIHJlcyA9IHRydWU7Ci0gICAgICAgICAgICAgICAgaWYgKCF1cGRhdGVkSGVhdEFydC5nZXREdXBsaWNhdGVkKCkgfHwgZXNBcnRpZmFjdERhdGEuZ2V0SWQoKSA9PSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgIGVzQXJ0aWZhY3REYXRhLnNldElkKHVwZGF0ZWRIZWF0QXJ0LmdldEVzSWQoKSk7CisgICAgICAgICAgICAgICAgaWYgKCF1cGRhdGVkSGVhdEFydC5nZXREdXBsaWNhdGVkKCkgfHwgREFPQXJ0aWZhY3REYXRhLmdldElkKCkgPT0gbnVsbCkgeworICAgICAgICAgICAgICAgICAgICBEQU9BcnRpZmFjdERhdGEuc2V0SWQodXBkYXRlZEhlYXRBcnQuZ2V0RXNJZCgpKTsKICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgcmVzID0gc2F2ZUFydGlmYWN0cyhlc0FydGlmYWN0RGF0YSwgcGFyZW50LmdldFVuaXF1ZUlkKCkpOwotCi0gICAgICAgICAgICAgICAgaWYgKHJlcykgewotICAgICAgICAgICAgICAgICAgICBsb2cuZGVidWcoQVJUSUZBQ1RfU0FWRUQsIHVwZGF0ZWRIZWF0QXJ0LmdldFVuaXF1ZUlkKCkpOwotICAgICAgICAgICAgICAgICAgICBSZXNwb25zZUZvcm1hdCByZXNwb25zZUZvcm1hdCA9IGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZ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C00NDk3LDEwICszOTA0LDEwIEBACiAgICAgICAgIExpc3Q8U3RyaW5nPiBncm91cEluc3RhbmNlc0lkID0gbnVsbDsKICAgICAgICAgaWYgKGdyb3Vwc0luc3RhbmNlcyAhPSBudWxsICYmICFncm91cHNJbnN0YW5jZXMuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICBncm91cEluc3RhbmNlc0lkID0gZ3JvdXBzSW5zdGFuY2VzLnN0cmVhbSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmZpbHRlcihwIC0+IHAuZ2V0R3JvdXBJbnN0YW5jZUFydGlmYWN0cygpICE9IG51bGwgJiYgcC5nZXRHcm91cEluc3RhbmNlQXJ0aWZhY3RzKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmNvbnRhaW5zKGFydGlmYWN0SWQpKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5tYXAoR3JvdXBJbnN0YW5jZURhdGFEZWZpbml0aW9uOjpnZXRVbmlxdWVJZCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuY29sbGVjdChDb2xsZWN0b3JzLnRvTGlzdCgpKTsKKyAgICAgICAgICAgICAgICAgICAgLmZpbHRlcihwIC0+IHAuZ2V0R3JvdXBJbnN0YW5jZUFydGlmYWN0cygpICE9IG51bGwgJiYgcC5nZXRHcm91cEluc3RhbmNlQXJ0aWZhY3RzKCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAuY29udGFpbnMoYXJ0aWZhY3RJZCkpCisgICAgICAgICAgICAgICAgICAgIC5tYXAoR3JvdXBJbnN0YW5jZURhdGFEZWZpbml0aW9uOjpnZXRVbmlxdWVJZCkKKyAgICAgICAgICAgICAgICAgICAgLmNvbGxlY3QoQ29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dFRvQ29tcG9uZW50QnlVVUlEKFN0cmluZyBkYXRhLCBIdHRwU2VydmxldFJlcXVlc3QgcmVxdWVzdCwgQ29tcG9uZW50VHlwZUVudW0gY29tcG9uZW50VHlwZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nIGNvbXBvbmVudFV1aWQsIFJlc291cmNlQ29tbW9uSW5mbyByZXNvdXJjZUNvbW1vbkluZm8sICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBcnRpZmFjdE9wZXJhdGlvbkluZm8gb3BlcmF0aW9uKSB7CisgICAgICAgIEVpdGhlcjxBcnRpZmFjdERlZmluaXRpb24sIE9wZXJhdGlvbj4gYWN0aW9uUmVzdWx0OworICAgICAgICBDb21wb25lbnQgY29tcG9uZW50OworICAgICAgICBTdHJpbmcgY29tcG9uZW50SWQ7CisgICAgICAgIEFydGlmYWN0RGVmaW5pdGlvbiBhcnRpZmFjdEluZm8gPSBSZXByZXNlbnRhdGlvblV0aWxzLmNvbnZlcnRKc29uVG9BcnRpZmFjdERlZmluaXRpb24oZGF0YSwgQXJ0aWZhY3REZWZpbml0aW9uLmNsYXNzLCBmYWxzZSk7CiAgICAgICAgIFN0cmluZyBvcmlnTWQ1ID0gcmVxdWVzdC5nZXRIZWFkZXIoQ29uc3RhbnRzLk1ENV9IRUFERVIpOwogICAgICAgICBTdHJpbmcgdXNlcklkID0gcmVxdWVzdC5nZXRIZWFkZXIoQ29uc3RhbnRzLlVTRVJfSURfSEVBREVSKTsKIAotICAgICAgICBFaXRoZXI8Q29tcG9uZW50TWV0YWRhdGFEYXRhLCBTdG9yYWdlT3BlcmF0aW9uU3RhdHVzPiBnZXRDb21wb25lbnRSZXMgPSB0b3NjYU9wZXJhdGlvbkZhY2FkZS5nZXRMYXRlc3RDb21wb25lbnRNZXRh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HsKLSAgICAgICAgICAgIGNvbXBvbmVudElkID0gZ2V0Q29tcG9uZW50UmVzLmxlZnQoKS52YWx1ZSgpLmdldE1ldGFkYXRhRGF0YURlZmluaXRpb24oKS5nZXRVbmlxdWVJZCgpOwotICAgICAgICAgICAgU3RyaW5nIGNvbXBvbmVudE5hbWUgPSBnZXRDb21wb25lbnRSZXMubGVmdCgpLnZhbHVlKCkuZ2V0TWV0YWRhdGFEYXRhRGVmaW5pdGlvbigpLmdldE5hbWUoKTsKIAotICAgICAgICAgICAgaWYgKCFnZXRDb21wb25lbnRSZXMubGVmdCgpCi0gICAgICAgICAgICAgICAgICAgIC52YWx1ZSgpCi0gICAgICAgICAgICAgICAgICAgIC5nZXRNZXRhZGF0YURhdGFEZWZpbml0aW9uKCkKLSAgICAgICAgICAgICAgICAgICAgLmdldFN0YXRlKCkKLSAgICAgICAgICAgICAgICAgICAgLmVxdWFscyhMaWZlY3ljbGVTdGF0ZUVudW0uTk9UX0NFUlRJRklFRF9DSEVDS09VVC5uYW1lKCkpKSB7Ci0gICAgICAgICAgICAgICAgY29tcG9uZW50ID0gY2hlY2tvdXRQYXJlbnRDb21wb25lbnQoY29tcG9uZW50VHlwZSwgY29tcG9uZW50SWQsIHVzZXJJZCwgZXJyb3JXcmFwcGVyKTsKLSAgICAgICAgICAgICAgICBpZiAoY29tcG9uZW50ICE9IG51bGwpIHsKLSAgICAgICAgICAgICAgICAgICAgY29tcG9uZW50SWQgPSBjb21wb25lbnQuZ2V0VW5pcXVlSWQoKTsKLSAgICAgICAgICAgICAgICAgICAgY29tcG9uZW50TmFtZSA9IGNvbXBvbmVudC5nZXROYW1lKCk7Ci0gICAgICAgICAgICAgICAgfQorICAgICAgICBDb21wb25lbnRNZXRhZGF0YURhdGFEZWZpbml0aW9uIGNvbXBvbmVudE1ldGFkYXRhRGF0YURlZmluaXRpb24gPSBnZXRDb21wb25lbnRSZXMubGVmdCgpLnZhbHVlKCkuZ2V0TWV0YWRhdGFEYXRhRGVmaW5pdGlvbigpOworICAgICAgICBjb21wb25lbnRJZCA9IGNvbXBvbmVudE1ldGFkYXRhRGF0YURlZmluaXRpb24uZ2V0VW5pcXVlSWQoKTsKKyAgICAgICAgU3RyaW5nIGNvbXBvbmVudE5hbWUgPSBjb21wb25lbnRNZXRhZGF0YURhdGFEZWZpbml0aW9uLmdldE5hbWUoKTsKKworICAgICAgICBpZiAoIWNvbXBvbmVudE1ldGFkYXRhRGF0YURlZmluaXRpb24KKyAgICAgICAgICAgICAgICAuZ2V0U3RhdGUoKQorICAgICAgICAgICAgICAgIC5lcXVhbHMoTGlmZWN5Y2xlU3RhdGVFbnVtLk5PVF9DRVJUSUZJRURfQ0hFQ0tPVVQubmFtZSgpKSkgeworICAgICAgICAgICAgY29tcG9uZW50ID0gY2hlY2tvdXRQYXJlbnRDb21wb25lbnQoY29tcG9uZW50VHlwZSwgY29tcG9uZW50SWQsIHVzZXJJZCk7CisgICAgICAgICAgICBpZiAoY29tcG9uZW50ICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICBjb21wb25lbnRJZCA9IGNvbXBvbmVudC5nZXRVbmlxdWVJZCgpOworICAgICAgICAgICAgICAgIGNvbXBvbmVudE5hbWUgPSBjb21wb25lbnQuZ2V0TmFtZSgpOwogICAgICAgICAgICAgfQotICAgICAgICAgICAgcmVzb3VyY2VDb21tb25JbmZvLnNldFJlc291cmNlTmFtZShjb21wb25lbnROYW1lKTsKICAgICAgICAgfQotICAgICAgICBpZiAoZXJyb3JXcmFwcGVyLmlzRW1wdHkoKSkgewotICAgICAgICAgICAgYWN0aW9uUmVzdWx0ID0gaGFuZGxlQXJ0aWZhY3RSZXF1ZXN0KGNvbXBvbmVudElkLCB1c2VySWQsIGNvbXBvbmVudFR5cGUsIG9wZXJhdGlvbiwgbnVsbCwgYXJ0aWZhY3RJbmZvLCBvcmlnTWQ1LCBkYXRhLCBudWxsLCBudWxsLCBudWxsLCBudWxsKTsKLSAgICAgICAgICAgIGlmIChhY3Rpb25SZXN1bHQuaXNSaWdodCgpKSB7Ci0gICAgICAgICAgICAgICAgbG9nLmRlYnVnKEZBSUxFRF9VUExPQURfQVJUSUZBQ1RfVE9fQ09NUE9ORU5ULCBjb21wb25lbnRUeXBlLCBjb21wb25lbnRVdWlkLCBhY3Rpb25SZXN1bHQKLSAgICAgICAgICAgICAgICAgICAgICAgIC5yaWdodCgpCi0gICAgICAgICAgICAgICAgICAgICAgICAudmFsdWUoKSk7Ci0gICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChhY3Rpb25SZXN1bHQucmlnaHQoKS52YWx1ZSgpKTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIHJldHVybiBFaXRoZXIubGVmdChhY3Rpb25SZXN1bHQubGVmdCgpLnZhbHVlKCkubGVmdCgpLnZhbHVlKCkpOwotICAgICAgICB9Ci0gICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQoZXJyb3JXcmFwcGVyLmdldElubmVyRWxlbWVudCgpKTsKKyAgICAgICAgcmVzb3VyY2VDb21tb25JbmZvLnNldFJlc291cmNlTmFtZShjb21wb25lbnROYW1lKTsKKworICAgICAgICBhY3Rpb25SZXN1bHQgPSBoYW5kbGVBcnRpZmFjdFJlcXVlc3QoY29tcG9uZW50SWQsIHVzZXJJZCwgY29tcG9uZW50VHlwZSwgb3BlcmF0aW9uLCBudWxsLCBhcnRpZmFjdEluZm8sCisgICAgICAgICAgICAgICAgb3JpZ01kNSwgZGF0YSwgbnVsbCwgbnVsbCwgbnVsbCwgbnVsbCk7CisgICAgICAgIHJldHVybiBhY3Rpb25SZXN1bHQubGVmdCgpLnZhbHVlKCk7CiAgICAgfQorCiAgICAgLyoqCiAgICAgICogdXBsb2FkIGFuIGFydGlmYWN0IHRvIGEgcmVzb3VyY2UgaW5zdGFuY2UgYnkgVVVJRAogICAgICAqCkBAIC00NzAxLDEyICs0MDY5LDkgQEAKICAgICAgKiBAcGFyYW0gb3BlcmF0aW9uCiAgICAgICogQHJldHV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VJbnN0YW5jZU5hbWUpKTsKKyAgICAgICAgICAgIGxvZy5kZWJ1ZyhGQUlMRURfRkVUQ0hfQ09NUE9ORU5ULCBjb21wb25lbnRUeXBlLCBjb21wb25lbnRVdWlkLCBzdGF0dXMpOworICAgICAgICAgICAgdGhyb3cgbmV3IEJ5QWN0aW9uU3RhdHVzQ29tcG9uZW50RXhjZXB0aW9uKGNvbXBvbmVudHNVdGlscy5jb252ZXJ0RnJvbVN0b3JhZ2VSZXNwb25zZShzdGF0dXMsIGNvbXBvbmVudFR5cGUpLCByZXNvdXJjZUluc3RhbmNlTmFtZSk7CiAgICAgICAgIH0KLSAgICAgICAgaWYgKGVycm9yV3JhcHBlci5pc0VtcHR5KCkgJiYgIWdldENvbXBvbmVudFJlcy5sZWZ0KCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC52YWx1ZSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0TWV0YWRhdGFEYXRhRGVmaW5pdGlvbigpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0U3RhdGUoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmVxdWFscyhMaWZlY3ljbGVTdGF0ZUVudW0uTk9UX0NFUlRJRklFRF9DSEVDS09VVC5uYW1lKCkpKSB7CisgICAgICAgIGlmICghZ2V0Q29tcG9uZW50UmVzLmxlZnQoKQorICAgICAgICAgICAgICAgIC52YWx1ZSgpCisgICAgICAgICAgICAgICAgLmdldE1ldGFkYXRhRGF0YURlZmluaXRpb24oKQorICAgICAgICAgICAgICAgIC5nZXRTdGF0ZSgpCisgICAgICAgICAgICAgICAgLmVxdWFscyhMaWZlY3ljbGVTdGF0ZUVudW0uTk9UX0NFUlRJRklFRF9DSEVDS09VVC5uYW1lKCkpKSB7CiAgICAgICAgICAgICBjb21wb25lbnQgPSBjaGVja291dFBhcmVudENvbXBvbmVudChjb21wb25lbnRUeXBlLCBnZXRDb21wb25lbnRSZXMubGVmdCgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAudmFsdWUoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldE1ldGFkYXRhRGF0YURlZmluaXRpb24oKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldFVuaXF1ZUlkKCksIHVzZXJJZCwgZXJyb3JXcmFwcGVyKTsKKyAgICAgICAgICAgICAgICAgICAgLnZhbHVlKCkKKyAgICAgICAgICAgICAgICAgICAgLmdldE1ldGFkYXRhRGF0YURlZmluaXRpb24oKQorICAgICAgICAgICAgICAgICAgICAuZ2V0VW5pcXVlSWQoKSwgdXNlcklkKTsKICAgICAgICAgfQotICAgICAgICBpZiAoZXJyb3JXcmFwcGVyLmlzRW1wdHkoKSkgewotICAgICAgICAgICAgaWYgKGNvbXBvbmVudCA9PSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgY29tcG9uZW50UmlQYWlyID0gZ2V0UmVsYXRlZENvbXBvbmVudENvbXBvbmVudEluc3RhbmNlKGNvbXBvbmVudFR5cGUsIGNvbXBvbmVudFV1aWQsIHJlc291cmNlSW5zdGFuY2VOYW1lLCBlcnJvcldyYXBwZXIpOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgZWxzZSB7Ci0gICAgICAgICAgICAgICAgY29tcG9uZW50UmlQYWlyID0gZ2V0UmVsYXRlZENvbXBvbmVudENvbXBvbmVudEluc3RhbmNlKGNvbXBvbmVudCwgcmVzb3VyY2VJbnN0YW5jZU5hbWUsIGVycm9yV3JhcH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gIC52YWx1ZSgpKTsKLSAgICAgICAgICAgICAgICBlcnJvcldyYXBwZXIuc2V0SW5uZXJFbGVtZW50KGFjdGlvblJlc3VsdC5yaWdodCgpLnZhbHVlKCkpOwotICAgICAgICAgICAgfQotICAgICAgICB9Ci0gICAgICAgIGlmIChlcnJvcldyYXBwZXIuaXNFbXB0eSgpKSB7Ci0gICAgICAgICAgICB1cGxvYWRBcnRpZmFjdCA9IGFjdGlvblJlc3VsdC5sZWZ0KCkudmFsdWUoKS5sZWZ0KCkudmFsdWUoKTsKLSAgICAgICAgICAgIHVwbG9hZEFydGlmYWN0UmVzdWx0ID0gRWl0aGVyLmxlZnQodXBsb2FkQXJ0aWZhY3QpOworICAgICAgICBpZiAoY29tcG9uZW50ID09IG51bGwpIHsKKyAgICAgICAgICAgIGNvbXBvbmVudFJpUGFpciA9IGdldFJlbGF0ZWRDb21wb25lbnRDb21wb25lbnRJbnN0YW5jZShjb21wb25lbnRUeXBlLCBjb21wb25lbnRVdWlkLCByZXNvdXJjZUluc3RhbmNlTmFtZSk7CiAgICAgICAgIH0KICAgICAgICAgZWxzZSB7Ci0gICAgICAgICAgICB1cGxvYWRBcnRpZmFjdFJlc3VsdCA9IEVpdGhlci5yaWdodChlcnJvcldyYXBwZXIuZ2V0SW5uZXJFbGVtZW50KCkpOworICAgICAgICAgICAgY29tcG9uZW50UmlQYWlyID0gZ2V0UmVsYXRlZENvbXBvbmVudENvbXBvbmVudEluc3RhbmNlKGNvbXBvbmVudCwgcmVzb3VyY2VJbnN0YW5jZU5hbWUpOwogICAgICAgICB9Ci0gICAgICAgIHJldHVybiB1cGxvYWRBcnRpZmFjdFJlc3VsdDsKKyAgICAgICAgY29tcG9uZW50SW5zdGFuY2VJZCA9IGNvbXBvbmVudFJpUGFpci5nZXRSaWdodCgpLmdldFVuaXF1ZUlkKCk7CisgICAgICAgIGNvbXBvbmVudElkID0gY29tcG9uZW50UmlQYWlyLmdldExlZnQoKS5nZXRVbmlxdWVJZCgpOworIC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ICAgIFN0cmluZyBjb21wb25lbnROYW1lID0gZ2V0Q29tcG9uZW50UmVzLmxlZnQoKS52YWx1ZSgpLmdldE1ldGFkYXRhRGF0YURlZmluaXRpb24oKS5nZXROYW1lKCk7CiAKLSAgICAgICAgICAgIGlmICghZ2V0Q29tcG9uZW50UmVzLmxlZnQoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAudmFsdWUoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0TWV0YWRhdGFEYXRhRGVmaW5pdGlvbigpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRTdGF0ZSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5lcXVhbHMoTGlmZWN5Y2xlU3RhdGVFbnVtLk5PVF9DRVJUSUZJRURfQ0hFQ0tPVVQubmFtZSgpKSkgewotICAgICAgICAgICAgICAgIGNvbXBvbmVudCA9IGNoZWNrb3V0UGFyZW50Q29tcG9uZW50KGNvbXBvbmVudFR5cGUsIGNvbXBvbmVudElkLCB1c2VySWQsIGVycm9yV3JhcHBlcik7Ci0gICAgICAgICAgICAgICAgaWYgKGNvbXBvbmVudCAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgIGNvbXBvbmVudElkID0gY29tcG9uZW50LmdldFVuaXF1ZUlkKCk7Ci0gICAgICAgICAgICAgICAgICAgIGNvbXBvbmVudE5hbWUgPSBjb21wb25lbnQuZ2V0TmFtZSgpOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIHJlc291cmNlQ29tbW9uSW5mby5zZXRSZXNvdXJjZU5hbWUoY29tcG9uZW50TmFtZSk7Ci0gICAgICAgIH0KLSAgICAgICAgaWYgKGVycm9yV3JhcHBlci5pc0VtcHR5KCkpIHsKLSAgICAgICAgICAgIGFydGlmYWN0SWQgPSBnZXRMYXRlc3RQYXJlbnRBcnRpZmFjdERhdGFJZEJ5QXJ0aWZhY3RVVUlEKGFydGlmYWN0VVVJRCwgZXJyb3JXcmFwcGVyLCBjb21wb25lbnRJZCwgY29tcG9uZW50VHlwZSk7Ci0gICAgICAgIH0KLSAgICAgICAgaWYgKGVycm9yV3JhcHBlci5pc0VtcHR5KCkpIHsKLSAgICAgICAgICAgIGFjdGlvblJlc3VsdCA9IGhhbmRsZUFydGlmYWN0UmVxdWVzdChjb21wb25lbnRJZCwgdXNlcklkLCBjb21wb25lbnRUeXBlLCBvcGVyYXRpb24sIGFydGlmYWN0SWQsIGFydGlmYWN0SW5mbywgb3JpZ01kNSwgZGF0YSwgbnVsbCwgbnVsbCwgbnVsbCwgbnVsbCk7Ci0gICAgICAgICAgICBpZiAoYWN0aW9uUmVzdWx0LmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZyhGQUlMRURfVVBMT0FEX0FSVElGQUNUX1RPX0NPTVBPTkVOVCwgY29tcG9uZW50VHlwZSwgY29tcG9uZW50VXVpZCwgYWN0aW9uUmVzdWx0Ci0gICAgICAgICAgICAgICAgICAgICAgICAucmlnaHQoKQotICAgICAgICAgICAgICAgICAgICAgICAgLnZhbHVlKCkpOwotICAgICAgICAgICAgICAgIGVycm9yV3JhcHBlci5zZXRJbm5lckVsZW1lbnQoYWN0aW9uUmVzdWx0LnJpZ2h0KCkudmFsdWUoKSk7CisgICAgICAgIGlmICghZ2V0Q29tcG9uZW50UmVzLmxlZnQoKQorICAgICAgICAgICAgICAgIC52YWx1ZSgpCisgICAgICAgICAgICAgICAgLmdldE1ldGFkYXRhRGF0YURlZmluaXRpb24oKQorICAgICAgICAgICAgICAgIC5nZXRTdGF0ZSgpCisgICAgICAgICAgICAgICAgLmVxdWFscyhMaWZlY3ljbGVTdGF0ZUVudW0uTk9UX0NFUlRJRklFRF9DSEVDS09VVC5uYW1lKCkpKSB7CisgICAgICAgICAgICBjb21wb25lbnQgPSBjaGVja291dFBhcmVudENvbXBvbmVudChjb21wb25lbnRUeXBlLCBjb21w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aWQsIGFjdGlvblJlc3VsdAorICAgICAgICAgICAgICAgICAgICAucmlnaHQoKQorICAgICAgICAgICAgICAgICAgICAudmFsdWUoKSk7CisgICAgICAgIH0KIAotICAgICAgICB9Ci0gICAgICAgIGVsc2UgewotICAgICAgICAgICAgdXBkYXRlQXJ0aWZhY3RSZXN1bHQgPSBFaXRoZXIucmlnaHQoZXJyb3JXcmFwcGVyLmdldElubmVyRWxlbWVudCgpKTsKLSAgICAgICAgfQotICAgICAgICByZXR1cm4gdXBkYXRlQXJ0aWZhY3RSZXN1bHQ7CisgICAgICAgIHJldHVybiBhY3Rpb25SZXN1bHQubGVmdCgpLnZhbHVlKCk7CiAgICAgfQogCiAgICAgLyoqCkBAIC00ODQ0LDE3ICs0MTc5LDE0IEBACiAgICAgICogQHBhcmFtIG9wZXJhdGlvbiAgICAgICAgICAgIFRPRE8KICAgICAgKiBAcmV0dXJuCiAgICAgICovCi0gICAgcHVibGljIEVpdGhlcjxBcnRpZmFjdERlZmluaXRpb24sIFJlc3BvbnNlRm9ybWF0PiB1cGRhdGVBcnRpZmFjdE9uUmlCeVVVSUQoU3RyaW5nIGRhdGEsIEh0dHBTZXJ2bGV0UmVxdWVzdCByZXF1ZXN0LCBDb21wb25lbnRUeXBlRW51bSBjb21wb25lbnRUeXBlLCBTdHJpbmcgY29tcG9uZW50VXVpZCwgU3RyaW5nIHJlc291cmNlSW5zdGFuY2VOYW1lLCBTdHJpbmcgYXJ0aWZhY3RVVUlELAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBcnRpZmFjdE9wZXJhdGlvbkluZm8gb3BlcmF0aW9uKSB7CisgICAgcHVibGljIEFydGlmYWN0RGVmaW5pdGlvbiB1cGRhdGVBcnRpZmFjdE9uUmlCeVVVSUQoU3RyaW5nIGRhdGEsIEh0dHBTZXJ2bGV0UmVxdWVzdCByZXF1ZXN0LCBDb21wb25lbnRU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ZXJ0RnJvbVN0b3JhZ2VSZXNwb25zZShzdGF0dXMpKTsKICAgICAgICAgfQotICAgICAgICBpZiAoZXJyb3JXcmFwcGVyLmlzRW1wdHkoKSAmJiAhZ2V0Q29tcG9uZW50UmVzLmxlZnQoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnZhbHVlKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRNZXRhZGF0YURhdGFEZWZpbml0aW9uKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRTdGF0ZSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZXF1YWxzKExpZmVjeWNsZVN0YXRlRW51bS5OT1RfQ0VSVElGSUVEX0NIRUNLT1VULm5hbWUoKSkpIHsKKyAgICAgICAgaWYgKCFnZXRDb21wb25lbnRSZXMubGVmdCgpCisgICAgICAgICAgICAgICAgLnZhbHVlKCkKKyAgICAgICAgICAgICAgICAuZ2V0TWV0YWRhdGFEYXRhRGVmaW5pdGlvbigpCisgICAgICAgICAgICAgICAgLmdldFN0YXRlKCkKKyAgICAgICAgICAgICAgICAuZXF1YWxzKExpZmVjeWNsZVN0YXRlRW51bS5OT1RfQ0VSVElGSUVEX0NIRUNLT1VULm5hbWUoKSkpIHsKICAgICAgICAgICAgIGNvbXBvbmVudCA9IGNoZWNrb3V0UGFyZW50Q29tcG9uZW50KGNvbXBvbmVudFR5cGUsIGdldENvbXBvbmVudFJlcy5sZWZ0KCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC52YWx1ZSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0TWV0YWRhdGFEYXRhRGVmaW5pdGlvbigpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0VW5pcXVlSWQoKSwgdXNlcklkLCBlcnJvcldyYXBwZXIpOworICAgICAgICAgICAgICAgICAgICAudmFsdWUoKQorICAgICAgICAgICAgICAgICAgICAuZ2V0TWV0YWRhdGFEYXRhRGVmaW5pdGlvbigpCisgICAgICAgICAgICAgICAgICAgIC5nZXRVbmlxdWVJZCgpLCB1c2VySWQpOwogICAgICAgICB9Ci0gICAgICAgIGlmIChlcnJvcldyYXBwZXIuaXNFbXB0eSgpKSB7Ci0gICAgICAgICAgICBpZiAoY29tcG9uZW50ID09IG51bGwpIHsKLSAgICAgICAgICAgICAgICBjb21wb25lbnRSaVBhaXIgPSBnZXRSZWxhdGVkQ29tcG9uZW50Q29tcG9uZW50SW5zdGFuY2UoY29tcG9uZW50VHlwZSwgY29tcG9uZW50VXVpZCwgcmVzb3VyY2VJbnN0YW5jZU5hbWUsIGVycm9yV3JhcHBlcik7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBlbHNlIHsKLSAgICAgICAgICAgICAgICBjb21wb25lbnRSaVBhaXIgPSBnZXRSZWxhdGVkQ29tcG9uZW50Q29tcG9uZW50SW5zdGFuY2UoY29tcG9uZW50LCByZXNvdXJjZUluc3RhbmNlTmFtZSwgZXJyb3JXcmFwcGVyKTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgfQotICAgICAgICBpZiAoZXJyb3JXcmFwcGVyLmlzRW1wdHkoKSkgewotICAgICAgICAgICAgY29tcG9uZW50SW5zdGFuY2VJZCA9IGNvbXBvbmVudFJpUGFpci5nZXRSaWdodCgpLmdldFVuaXF1ZUlkKCk7Ci0gICAgICAgICAgICBjb21wb25lbnRJZCA9IGNvbXBvbmVudFJpUGFpci5nZXRMZWZ0KCkuZ2V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SW5uZXJFbGVtZW50KGFjdGlvblJlc3VsdC5yaWdodCgpLnZhbHVlKCkpOwotICAgICAgICAgICAgfQotICAgICAgICB9Ci0gICAgICAgIGlmIChlcnJvcldyYXBwZXIuaXNFbXB0eSgpKSB7Ci0gICAgICAgICAgICB1cGRhdGVBcnRpZmFjdCA9IGFjdGlvblJlc3VsdC5sZWZ0KCkudmFsdWUoKS5sZWZ0KCkudmFsdWUoKTsKLSAgICAgICAgICAgIHVwZGF0ZUFydGlmYWN0UmVzdWx0ID0gRWl0aGVyLmxlZnQodXBkYXRlQXJ0aWZhY3QpOworICAgICAgICBpZiAoY29tcG9uZW50ID09IG51bGwpIHsKKyAgICAgICAgICAgIGNvbXBvbmVudFJpUGFpciA9IGdldFJlbGF0ZWRDb21wb25lbnRDb21wb25lbnRJbnN0YW5jZShjb21wb25lbnRUeXBlLCBjb21wb25lbnRVdWlkLCByZXNvdXJjZUluc3RhbmNlTmFtZSk7CiAgICAgICAgIH0KICAgICAgICAgZWxzZSB7Ci0gICAgICAgICAgICB1cGRhdGVBcnRpZmFjdFJlc3VsdCA9IEVpdGhlci5yaWdodChlcnJvcldyYXBwZXIuZ2V0SW5uZXJFbGVtZW50KCkpOworICAgICAgICAgICAgY29tcG9uZW50UmlQYWlyID0gZ2V0UmVsYXRlZENvbXBvbmVudENvbXBvbmVudEluc3RhbmNlKGNvbXBvbmVudCwgcmVzb3VyY2VJbnN0YW5jZU5hbWUpOwogICAgICAgICB9Ci0gICAgICAgIHJldHVybiB1cGRhdGVBcnRpZmFjdFJlc3VsdDsKKyAgICAgICAgY29tcG9uZW50SW5zdGFuY2VJZCA9IGNvbXBvbmVudFJpUGFpci5nZXRSaWdodCgpLmdldFVuaXF1ZUlkKCk7CisgICAgICAgIGNvbXBvbmVudElkID0gY29tcG9uZW50UmlQYWlyLmdldExlZnQoKS5nZXRVbmlxdWVJZCgpOworICAgICAgICBhcnRpZmFjdElkID0gZmluZEFydGlmYWN0SWQoY29tcG9uZW50UmlQ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V0T3BlcmF0aW9uc01hcCgpOwogICAgICAgICBPcHRpb25hbDxPcGVyYXRpb24+IG9wdGlvbmFsT3BlcmF0aW9uID0gb3BlcmF0aW9uc01hcC52YWx1ZXMoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuc3RyZWFtKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmZpbHRlcihvIC0+IG8uZ2V0VW5pcXVlSWQoKS5lcXVhbHMob3BlcmF0aW9uVXVpZCkpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5maW5kRmlyc3QoKTsKKyAgICAgICAgICAgICAgICAuc3RyZWFtKCkKKyAgICAgICAgICAgICAgICAuZmlsdGVyKG8gLT4gby5nZXRVbmlxdWVJZCgpLmVxdWFscyhvcGVyYXRpb25VdWlkKSkKKyAgICAgICAgICAgICAgICAuZmluZEZpcnN0KCk7CiAgICAgICAgIGlmICghb3B0aW9uYWxPcGVyYXRpb24uaXNQcmVzZW50KCkpIHsKICAgICAgICAgICAgIGxvZy5kZWJ1ZygiRmFpbGVkIHRvIGdldCByZXNvdXJjZSBpbnRlcmZhY2Ugb3BlcmF0aW9uIGZvciByZXNvdXJjZSBJZCB7fSBhbmQgb3BlcmF0aW9uSWQge30iLCBjb21wb25lbnRJZCwgb3BlcmF0aW9uVXVpZCk7CiAgICAgICAgICAgICBSZXNwb25zZUZvcm1hdCByZXNwb25zZUZvcm1hdCA9IGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuSU5URVJGQUNFX09QRVJBVElPTl9OT1RfRk9VTkQsIGNvbXBvbmVudElkKTsKQEAgLTQ5NjIsNiArNDI3NSw3IEBACiAgICAgICAgIHJldHVybiBFaXRoZXIubGVmdChhcnRpZmFjdEluZm8pOwogICAgIH0KIAorCiAgICAgLyoqCiAgICAgICogdXBkYXRlcyBhbiBhcnRpZmFjdCBvbiBhIGNvbXBvbmVudCBieSBVVUlECiAgICAgICoKQEAgLTUwMDMsNyArNDMxNyw3IEBACiAgICAgICAgICAgICAgICAgICAgIC5nZXRNZXRhZGF0YURhdGFEZWZpbml0aW9uKCkKICAgICAgICAgICAgICAgICAgICAgLmdldFN0YXRlKCkKICAgICAgICAgICAgICAgICAgICAgLmVxdWFscyhMaWZlY3ljbGVTdGF0ZUVudW0uTk9UX0NFUlRJRklFRF9DSEVDS09VVC5uYW1lKCkpKSB7Ci0gICAgICAgICAgICAgICAgQ29tcG9uZW50IGNvbXBvbmVudCA9IGNoZWNrb3V0UGFyZW50Q29tcG9uZW50KGNvbXBvbmVudFR5cGUsIGNvbXBvbmVudElkLCB1c2VySWQsIGVycm9yV3JhcHBlcik7CisgICAgICAgICAgICAgICAgQ29tcG9uZW50IGNvbXBvbmVudCA9IGNoZWNrb3V0UGFyZW50Q29tcG9uZW50KGNvbXBvbmVudFR5cGUsIGNvbXBvbmVudElkLCB1c2VySWQpOwogICAgICAgICAgICAgICAgIGlmIChjb21wb25lbnQgIT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICBjb21wb25lbnRJZCA9IGNvbXBvbmVudC5nZXRVbmlxdWVJZCgpOwogICAgICAgICAgICAgICAgICAgICBjb21wb25lbnROYW1lID0gY29tcG9uZW50LmdldE5hbWUoKTsKQEAgLTUwNDcsMTQgKzQzNjEsMTIgQEAKICAgICAgICAgfQogCiAgICAgICAgIGlmIChlcnJvcldyYXBwZXIuaXNFbXB0eSgpKSB7Ci0gICAgICAgICAgICBhY3Rpb25SZXN1bHQgPSBoYW5kbGVBcnRpZmFjdFJlcXVlc3QoY29tcG9uZW50SWQsIHVzZXJJZCwgY29tcG9uZW50VHlwZSwgb3BlcmF0aW9uLAotICAgICAgICAgICAgICAgICAgICBhcnRpZmFjdFVVSUQsIGFydGlmYWN0SW5mbywgb3JpZ01kNSwgZGF0YSwgaW50ZXJmYWNlTmFtZSwKLSAgICAgICAgICAgICAgICAgICAgb3BlcmF0aW9uVVVJRCwgbnVsbCwgbnVsbCk7Ci0gICAgICAgICAgICBpZiAoYWN0aW9uUmVzdWx0LmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZyhGQUlMRURfVVBMT0FEX0FSVElGQUNUX1RPX0NPTVBPTkVOVCwgY29tcG9uZW50VHlwZSwgY29tcG9uZW50VXVpZCwgYWN0aW9uUmVzdWx0Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5yaWdodCgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC52YWx1ZSgpKTsKLSAgICAgICAgICAgICAgICBlcnJvcldyYXBwZXIuc2V0SW5uZXJFbGVtZW50KGFjdGlvblJlc3VsdC5yaWdodCgpLnZhbHVlKCkpOworICAgICAgICAgICAgICAgIHRyeSB7CisgICAgICAgICAgICAgICAgICAgIGFjdGlvblJlc3VsdCA9IEVpdGhlci5sZWZ0KGhhbmRsZUFydGlmYWN0UmVxdWVzdChjb21wb25lbnRJZCwgdXNlcklkLCBjb21wb25lbnRUeXBlLCBvcGVyYXRpb24sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJ0aWZhY3RVVUlELCBhcnRpZmFjdEluZm8sIG9yaWdNZDUsIGRhdGEsIGludGVyZmFjZU5hbWUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3BlcmF0aW9uVVVJRCwgbnVsbCwgbnVsbCkpOworICAgICAgICAgICAgICAgIH1jYXRjaCAoQ29tcG9uZW50RXhjZXB0aW9uIGUpeworICAgICAgICAgICAgICAgICAgICBlcnJvcldyYXBwZXIuc2V0SW5u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5pc0VtcHR5KCkpIHsKLSAgICAgICAgICAgIGNvbXBvbmVudElkID0gZ2V0Q29tcG9uZW50UmVzLmxlZnQoKS52YWx1ZSgpLmdldE1ldGFkYXRhRGF0YURlZmluaXRpb24oKS5nZXRVbmlxdWVJZCgpOwotICAgICAgICAgICAgU3RyaW5nIGNvbXBvbmVudE5hbWUgPSBnZXRDb21wb25lbnRSZXMubGVmdCgpLnZhbHVlKCkuZ2V0TWV0YWRhdGFEYXRhRGVmaW5pdGlvbigpLmdldE5hbWUoKTsKLSAgICAgICAgICAgIGlmICghZ2V0Q29tcG9uZW50UmVzLmxlZnQoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAudmFsdWUoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0TWV0YWRhdGFEYXRhRGVmaW5pdGlvbigpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRTdGF0ZSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5lcXVhbHMoTGlmZWN5Y2xlU3RhdGVFbnVtLk5PVF9DRVJUSUZJRURfQ0hFQ0tPVVQubmFtZSgpKSkgewotICAgICAgICAgICAgICAgIGNvbXBvbmVudCA9IGNoZWNrb3V0UGFyZW50Q29tcG9uZW50KGNvbXBvbmVudFR5cGUsIGNvbXBvbmVudElkLCB1c2VySWQsIGVycm9yV3JhcHBlcik7Ci0gICAgICAgICAgICAgICAgaWYgKGNvbXBvbmVudCAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgIGNvbXBvbmVudElkID0gY29tcG9uZW50LmdldFVuaXF1ZUlkKCk7Ci0gICAgICAgICAgICAgICAgICAgIGNvbXBvbmVudE5hbWUgPSBjb21wb25lbnQuZ2V0TmFtZSgpOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIHJlc291cmNlQ29tbW9uSW5mby5zZXRSZXNvdXJjZU5hbWUoY29tcG9uZW50Tm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HVlKCkuZ2V0TWV0YWRhdGFEYXRhRGVmaW5pdGlvbigpLmdldE5hbWUoKTsKKyAgICAgICAgaWYgKCFnZXRDb21wb25lbnRSZXMubGVmdCgpCisgICAgICAgICAgICAgICAgLnZhbHVlKCkKKyAgICAgICAgICAgICAgICAuZ2V0TWV0YWRhdGFEYXRhRGVmaW5pdGlvbigpCisgICAgICAgICAgICAgICAgLmdldFN0YXRlKCkKKyAgICAgICAgICAgICAgICAuZXF1YWxzKExpZmVjeWNsZVN0YXRlRW51bS5OT1RfQ0VSVElGSUVEX0NIRUNLT1VULm5hbWUoKSkpIHsKKyAgICAgICAgICAgIGNvbXBvbmVudCA9IGNoZWNrb3V0UGFyZW50Q29tcG9uZW50KGNvbXBvbmVudFR5cGUsIGNvbXBvbmVudElkLCB1c2VySWQpOworICAgICAgICAgICAgaWYgKGNvbXBvbmVudCAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgY29tcG9uZW50SWQgPSBjb21wb25lbnQuZ2V0VW5pcXVlSWQoKTsKKyAgICAgICAgICAgICAgICBjb21wb25lbnROYW1lID0gY29tcG9uZW50LmdldE5hbWUoKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfQotICAgICAgICBpZiAoZXJyb3JXcmFwcGVyLmlzRW1wdHkoKSkgewotICAgICAgICAgICAgZGVsZXRlQXJ0aWZhY3QgPSBhY3Rpb25SZXN1bHQubGVmdCgpLnZhbHVlKCkubGVmdCgpLnZhbHVlKCk7Ci0gICAgICAgICAgICBkZWxldGVBcnRpZmFjdFJlc3VsdCA9IEVpdGhlci5sZWZ0KGRlbGV0ZUFydGlmYWN0KTsKLSAgICAgICAgfQotICAgICAgICBlbHNlIHsKLSAgICAgICAgICAgIGRlbGV0ZUFydGlmYWN0UmVzdWx0ID0gRWl0aGVyLnJpZ2h0KGVycm9yV3JhcHBlci5nZXRJbm5lckVsZW1lbnQoKSk7Ci0gICAgICAgIH0KLSAgICAgICAgcmV0dXJuIGRlbGV0ZUFydGlmYWN0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Rpb24gZGVsZXRlQXJ0aWZhY3RPblJpQnlVVUlEKEh0dHBTZXJ2bGV0UmVxdWVzdCByZXF1ZXN0LCBDb21wb25lbnRUeXBlRW51bSBjb21wb25lbnRUeXBlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZyBjb21wb25lbnRVdWlkLCBTdHJpbmcgcmVzb3VyY2VJbnN0YW5jZU5hbWUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nIGFydGlmYWN0VVVJRCwgQXJ0aWZhY3RPcGVyYXRpb25JbmZvIG9wZXJhdGlvbikgewogCi0gICAgICAgIFdyYXBwZXI8UmVzcG9uc2VGb3JtYXQ+IGVycm9yV3JhcHBlciA9IG5ldyBXcmFwcGVyPD4oKTsKLSAgICAgICAgRWl0aGVyPEFydGlmYWN0RGVmaW5pdGlvbiwgUmVzcG9uc2VGb3JtYXQ+IGRlbGV0ZUFydGlmYWN0UmVzdWx0OwotICAgICAgICBFaXRoZXI8RWl0aGVyPEFydGlmYWN0RGVmaW5pdGlvbiwgT3BlcmF0aW9uPiwgUmVzcG9uc2VGb3JtYXQ+IGFjdGlvblJlc3VsdCA9IG51bGw7Ci0gICAgICAgIEFydGlmYWN0RGVmaW5pdGlvbiBkZWxldGVBcnRpZmFjdCA9IG51bGw7CisgICAgICAgIEVpdGhlcjxBcnRpZmFjdERlZmluaXRpb24sIE9wZXJhdGlvbj4gYWN0aW9uUmVzdWx0OwogICAgICAgICBDb21wb25lbnQgY29tcG9uZW50ID0gbnVsbDsKLSAgICAgICAgU3RyaW5nIGNvbXBvbmVudEluc3RhbmNlSWQgPSBudWxsOwotICAgICAgICBTdHJpbmcgY29tcG9uZW50SWQgPSBudWxsOwotICAgICAgICBTdHJpbmcgYXJ0aWZhY3RJZCA9IG51bGw7CisgICAgICAgIFN0cmluZyBjb21wb25lbnRJbnN0YW5jZUlkOworIC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ZXRjaCBjb21wb25lbnQgd2l0aCB0eXBlIHt9IGFuZCB1dWlkIHt9LiBTdGF0dXMgaXMge30uICIsIGNvbXBvbmVudFR5cGUsIGNvbXBvbmVudFV1aWQsIHN0YXR1cyk7Ci0gICAgICAgICAgICBlcnJvcldyYXBwZXIuc2V0SW5uZXJFbGVtZW50KGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChjb21wb25lbnRzVXRpbHMuY29udmVydEZyb21TdG9yYWdlUmVzcG9uc2Uoc3RhdHVzKSkpOworICAgICAgICAgICAgbG9nLmRlYnVnKEZBSUxFRF9GRVRDSF9DT01QT05FTlQsIGNvbXBvbmVudFR5cGUsIGNvbXBvbmVudFV1aWQsIHN0YXR1cyk7CisgICAgICAgICAgICB0aHJvdyBuZXcgQnlBY3Rpb25TdGF0dXNDb21wb25lbnRFeGNlcHRpb24oY29tcG9uZW50c1V0aWxzLmNvbnZlcnRGcm9tU3RvcmFnZVJlc3BvbnNlKHN0YXR1cykpOwogICAgICAgICB9Ci0gICAgICAgIGlmIChlcnJvcldyYXBwZXIuaXNFbXB0eSgpICYmICFnZXRDb21wb25lbnRSZXMubGVmdCgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAudmFsdWUoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldE1ldGFkYXRhRGF0YURlZmluaXRpb24oKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldFN0YXRlKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5lcXVhbHMoTGlmZWN5Y2xlU3RhdGVFbnVtLk5PVF9DRVJUSUZJRURfQ0hFQ0tPVVQubmFtZSgpKSkgeworICAgICAgICBpZiAoIWdldENvbXBvbmVudFJlcy5sZWZ0KCkKKyAgICAgICAgICAgICAgICAudmFsdWUoKQorICAgICAgICAgICAgICAgIC5nZXRNZXRhZGF0YURhdGFEZWZpbml0aW9uKCkKKyAgICAgICAgICAgICAgICAuZ2V0U3RhdGUoKQorICAgICAgICAgICAgICAgIC5lcXVhbHMoTGlmZWN5Y2xlU3RhdGVFbnVtLk5PVF9DRVJUSUZJRURfQ0hFQ0tPVVQubmFtZSgpKSkgewogICAgICAgICAgICAgY29tcG9uZW50ID0gY2hlY2tvdXRQYXJlbnRDb21wb25lbnQoY29tcG9uZW50VHlwZSwgZ2V0Q29tcG9uZW50UmVzLmxlZnQoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnZhbHVlKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRNZXRhZGF0YURhdGFEZWZpbml0aW9uKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRVbmlxdWVJZCgpLCB1c2VySWQsIGVycm9yV3JhcHBlcik7CisgICAgICAgICAgICAgICAgICAgIC52YWx1ZSgpCisgICAgICAgICAgICAgICAgICAgIC5nZXRNZXRhZGF0YURhdGFEZWZpbml0aW9uKCkKKyAgICAgICAgICAgICAgICAgICAgLmdldFVuaXF1ZUlkKCksIHVzZXJJZCk7CiAgICAgICAgIH0KLSAgICAgICAgaWYgKGVycm9yV3JhcHBlci5pc0VtcHR5KCkpIHsKLSAgICAgICAgICAgIGlmIChjb21wb25lbnQgPT0gbnVsbCkgewotICAgICAgICAgICAgICAgIGNvbXBvbmVudFJpUGFpciA9IGdldFJlbGF0ZWRDb21wb25lbnRDb21wb25lbnRJbnN0YW5jZShjb21wb25lbnRUeXBlLCBjb21wb25lbnRVdWlkLCByZXNvdXJjZU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lnaHQoKSkgewotICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZyhGQUlMRURfVVBMT0FEX0FSVElGQUNUX1RPX0lOU1RBTkNFLCByZXNvdXJjZUluc3RhbmNlTmFtZSwgY29tcG9uZW50VHlwZSwgY29tcG9uZW50VXVpZCwgYWN0aW9uUmVzdWx0Ci0gICAgICAgICAgICAgICAgICAgICAgICAucmlnaHQoKQotICAgICAgICAgICAgICAgICAgICAgICAgLnZhbHVlKCkpOwotICAgICAgICAgICAgICAgIGVycm9yV3JhcHBlci5zZXRJbm5lckVsZW1lbnQoYWN0aW9uUmVzdWx0LnJpZ2h0KCkudmFsdWUoKSk7Ci0gICAgICAgICAgICB9Ci0gICAgICAgIH0KLSAgICAgICAgaWYgKGVycm9yV3JhcHBlci5pc0VtcHR5KCkpIHsKLSAgICAgICAgICAgIGRlbGV0ZUFydGlmYWN0ID0gYWN0aW9uUmVzdWx0LmxlZnQoKS52YWx1ZSgpLmxlZnQoKS52YWx1ZSgpOwotICAgICAgICAgICAgZGVsZXRlQXJ0aWZhY3RSZXN1bHQgPSBFaXRoZXIubGVmdChkZWxldGVBcnRpZmFjdCk7CisgICAgICAgIGlmIChjb21wb25lbnQgPT0gbnVsbCkgeworICAgICAgICAgICAgY29tcG9uZW50UmlQYWlyID0gZ2V0UmVsYXRlZENvbXBvbmVudENvbXBvbmVudEluc3RhbmNlKGNvbXBvbmVudFR5cGUsIGNvbXBvbmVudFV1aWQsIHJlc291cmNlSW5zdGFuY2VOYW1lKTsKICAgICAgICAgfQogICAgICAgICBlbHNlIHsKLSAgICAgICAgICAgIGRlbGV0ZUFydGlmYWN0UmVzdWx0ID0gRWl0aGVyLnJpZ2h0KGVycm9yV3JhcHBlci5nZXRJbm5lckVsZW1lbnQoKSk7CisgICAgICAgICAgICBjb21wb25lbnRSaVBhaXIgPSBnZXRSZWxhdGVkQ29tcG9uZW50Q29tcG9uZW50SW5zdGFuY2UoY29tcG9uZW50LCByZXNvdXJjZUluc3RhbmN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WxsOwogICAgICAgICBBcnRpZmFjdERlZmluaXRpb24gZm91bmRBcnRpZmFjdCA9IG51bGw7CiAgICAgICAgIGlmIChpbnN0YW5jZS5nZXREZXBsb3ltZW50QXJ0aWZhY3RzKCkgIT0gbnVsbCkgewogICAgICAgICAgICAgZm91bmRBcnRpZmFjdCA9IGluc3RhbmNlLmdldERlcGxveW1lbnRBcnRpZmFjdHMoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnZhbHVlcygpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuc3RyZWFtKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5maWx0ZXIoZSAtPiBlLmdldEFydGlmYWN0VVVJRCgpICE9IG51bGwgJiYgZS5nZXRBcnRpZmFjdFVVSUQoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmVxdWFscyhhcnRpZmFjdFVVSUQpKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmZpbmRGaXJzdCgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAub3JFbHNlKG51bGwpOworICAgICAgICAgICAgICAgICAgICAudmFsdWVzKCkKKyAgICAgICAgICAgICAgICAgICAgLnN0cmVhbSgpCisgICAgICAgICAgICAgICAgICAgIC5maWx0ZXIoZSAtPiBlLmdldEFydGlmYWN0VVVJRCgpICE9IG51bGwgJiYgZS5nZXRBcnRpZmFjdFVVSUQoKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5lcXVhbHMoYXJ0aWZhY3RVVUlEKSkKKyAgICAgICAgICAgICAgICAgICAgLmZpbmRGaXJzdCgpCisgICAgICAgICAgICAgICAgICAgIC5vckVsc2UobnVsbCk7CiAgICAgICAgIH0KICAgICAgICAgaWYgKGZvdW5kQXJ0aWZhY3QgPT0gbnVsbCAmJiBpbnN0YW5jZS5nZXRBcnRpZmFjdHMoKSAhPSBudWxsKSB7CiAgICAgICAgICAgICBmb3VuZEFydGlmYWN0ID0gaW5zdGFuY2UuZ2V0QXJ0aWZhY3RzKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC52YWx1ZXMoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnN0cmVhbSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZmlsdGVyKGUgLT4gZS5nZXRBcnRpZmFjdFVVSUQoKSAhPSBudWxsICYmIGUuZ2V0QXJ0aWZhY3RVVUlEKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5lcXVhbHMoYXJ0aWZhY3RVVUlEKSkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5maW5kRmlyc3QoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLm9yRWxzZShudWxsKTsKKyAgICAgICAgICAgICAgICAgICAgLnZhbHVlcygpCisgICAgICAgICAgICAgICAgICAgIC5zdHJlYW0oKQorICAgICAgICAgICAgICAgICAgICAuZmlsdGVyKGUgLT4gZS5nZXRBcnRpZmFjdFVVSUQoKSAhPSBudWxsICYmIGUuZ2V0QXJ0aWZhY3RVVUlEKCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZXF1YWxzKGFydGlmYWN0VVVJRCkpCisgICAgICAgICAgICAgICAgICAgIC5maW5kRmlyc3QoKQorICAgICAgICAgICAgICAgICAgICAub3JFbHNlKG51bGwpOwogICAgICAgICB9CiAgICAgICAgIGlmIChmb3VuZEFydGlmYWN0ID09IG51bGwpIHsKICAgICAgICAgICAgIGxvZy5kZWJ1ZygiVGhlIGFydGlmYWN0IHt9IHdhcyBub3QgZm91bmQgb24gaW5zdGFuY2Uge30uICIsIGFydGlmYWN0VVVJRCw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VmaW5pdGlvbj4gY3JlYXRlZEFydGlmYWN0cywgQXJ0aWZhY3REZWZpbml0aW9uIGhlYXRBcnRpZmFjdCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmcgZW52VHlwZSwgU3RyaW5nIHBhcmVudElkLCBOb2RlVHlwZUVudW0gcGFyZW50VHlwZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmcgcGFyZW50TmFtZSwgVXNlciB1c2VyLCBDb21wb25lbnQgY29tcG9uZW50LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1hcDxTdHJpbmcsIFN0cmluZz4gZXhpc3RpbmdFbnZWZXJzaW9ucykgewogICAgICAgICBNYXA8U3RyaW5nLCBPYmplY3Q+IGRlcGxveW1lbnRSZXNvdXJjZUFydGlmYWN0cyA9IENvbmZpZ3VyYXRpb25NYW5hZ2VyLmdldENvbmZpZ3VyYXRpb25NYW5hZ2VyKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRDb25maWd1cmF0aW9uKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXREZXBsb3ltZW50UmVzb3VyY2VJbnN0YW5jZUFydGlmYWN0cygpOworICAgICAgICAgICAgICAgIC5nZXRDb25maWd1cmF0aW9uKCkKKyAgICAgICAgICAgICAgICAuZ2V0RGVwbG95bWVudFJlc291cmNlSW5zdGFuY2VBcnRpZmFjdHMoKTsKICAgICAgICAgaWYgKGRlcGxveW1lbnRSZXNvdXJjZUFydGlmYWN0cyA9PSBudWxsKSB7CiAgICAgICAgICAgICBsb2cuZGVidWcoIm5vIGRlcGxveW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gc2hvdWxkTG9jawotICAgICAqIEBwYXJhbSBpblRyYW5zYWN0aW9uCi0gICAgICogQHJldHVybgotICAgICAqLwotICAgIHB1YmxpYyBFaXRoZXI8TGlzdDxBcnRpZmFjdERlZmluaXRpb24+LCBSZXNwb25zZUZvcm1hdD4gaGFuZGxlQXJ0aWZhY3RzUmVxdWVzdEZvcklubmVyVmZjQ29tcG9uZW50KExpc3Q8QXJ0aWZhY3REZWZpbml0aW9uPiBhcnRpZmFjdHNUb0hhbmRsZSwgUmVzb3VyY2UgY29tcG9uZW50LCBVc2VyIHVzZXIsIExpc3Q8QXJ0aWZhY3REZWZpbml0aW9uPiB2ZmNzTmV3Q3JlYXRlZEFydGlmYWN0cywKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBcnRpZmFjdE9wZXJhdGlvbkluZm8gb3BlcmF0aW9uLCBib29sZWFuIHNob3VsZExvY2ssIGJvb2xlYW4gaW5UcmFuc2FjdGlvbikgewotCi0gICAgICAgIEVpdGhlcjxMaXN0PEFydGlmYWN0RGVmaW5pdGlvbj4sIFJlc3BvbnNlRm9ybWF0PiBoYW5kbGVBcnRpZmFjdHNSZXN1bHQgPSBudWxsOworICAgIHB1YmxpYyBMaXN0PEFydGlmYWN0RGVmaW5pdGlvbj4gaGFuZGxlQXJ0aWZhY3RzRm9ySW5uZXJWZmNDb21wb25lbnQoTGlzdDxBcnRpZmFjdERlZmluaXRpb24+IGFydGlmYWN0c1RvSGFuZGxlLCBSZXNvdXJjZSBjb21wb25lbnQsIFVzZXIgdXNlciwgTGlzdDxBcnRpZmFjdERlZmluaXRpb24+IHZmY3NOZXdDcmVhdGVkQXJ0aWZhY3RzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQXJ0aWZhY3RPcGVy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0aWZhY3REZWZpbml0aW9uLCBvcGVyYXRpb24sIGF1ZGl0aW5nQWN0aW9uLCBhcnRpZmFjdElkLCB1c2VyLCBjb21wb25lbnRUeXBlLCBjb21wb25lbnQsIG51bGwsIG51bGwpOworICAgICAgICAgICAgICAgIHJlc3VsdCA9IGhhbmRsZVVwZGF0ZShjb21wb25lbnRJZCwgY29tcG9uZW50VHlwZSwgb3BlcmF0aW9uLCBhcnRpZmFjdElkLCBhcnRpZmFjdERlZmluaXRpb24sIHZhbGlkUGF5bG9hZCwgbnVsbCwgbnVsbCwgbnVsbCwgbnVsbCwKKyAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGl0aW5nQWN0aW9uLCB1c2VyLCBjb21wb25lbnQsIHRydWUpOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBERUxFVEU6CisgICAgICAgICAgICAgICAgcmVzdWx0ID0gRWl0aGVyLmxlZnQoaGFuZGxlRGVsZXRlSW50ZXJuYWwoY29tcG9uZW50SWQsIGFydGlmYWN0SWQsIGNvbXBvbmVudFR5cGUsIGNvbXBvbmVudCkpOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBET1dOTE9BRDoKKyAgICAgICAgICAgICAgICBpZiAoYXJ0aWZhY3RHZW5lcmF0aW9uUmVxdWlyZWQoY29tcG9uZW50LCBhcnRpZmFjdERlZmluaXRpb24pKSB7CisgICAgICAgICAgICAgICAgICAgIHJlc3VsdCA9IEVpdGhlci5sZWZ0KGdlbmVyYXRlTm90U2F2ZWRBcnRpZmFjdChjb21wb25lbnQsIGFydGlmYWN0RGVmaW5pdGlvbikpOworICAgICAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgICAgIHJlc3VsdCA9IEVpdGhlci5sZWZ0KGhhbmRsZURvd25sb2FkKGNvbXBvbmVudElkLCBhcnRpZmFjdElkLCBjb21wb25lbnRUeXBlLCBjb21wb25lbnQpKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIExJTks6CisgICAgICAgICAgICAgICAgcmVzdWx0ID0gRWl0aGVyLmxlZnQoaGFuZGxlTGluayhjb21wb25lbnRJZCwgYXJ0aWZhY3REZWZpbml0aW9uLCBjb21wb25lbnRUeXBlLCBjb21wb25lbnQpKTsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgdGhyb3cgbmV3IFVuc3VwcG9ydGVkT3BlcmF0aW9uRXhjZXB0aW9uKCJJbiBBcnRpZmFjdHNCdXNpbmVzc0xvZ2ljIHJlY2VpdmVkIGlsbGVnYWwgb3BlcmF0aW9uOiAiICsgb3BlcmF0aW9uLmdldEFydGlmYWN0T3BlcmF0aW9uRW51bSgpKTsKKyAgICAgICAgfQorICAgICAgICByZXR1cm4gcmVzdWx0OworICAgIH0KKworICAgIHB1YmxpYyBMaXN0PEFydGlmYWN0RGVmaW5pdGlvbj4gaGFuZGxlQXJ0aWZhY3RzUmVxdWVzdEZvcklubmVyVmZjQ29tcG9uZW50KExpc3Q8QXJ0aWZhY3REZWZpbml0aW9uPiBhcnRpZmFjdHNUb0hhbmRsZSwgUmVzb3VyY2UgY29tcG9uZW50LCBVc2VyIHVzZXIsIExpc3Q8QXJ0aWZhY3REZWZpbml0aW9uPiB2ZmNzTmV3Q3JlYXRlZEFydGlmYWN0cywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBcnRpZmFjdE9wZXJhdGlvbkluZm8gb3BlcmF0aW9uLCBib29sZWFuIHNob3VsZExvY2ssIGJvb2xlYW4gaW5UcmFuc2FjdGlvbikgeworCisgICAgICAgIExpc3Q8QXJ0aWZhY3REZWZpbml0aW9uPiBoYW5kbGVBcnRpZmFjdHNSZXN1bHQ7CisgICAgICAgIENvbXBvbm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hcHBlcikgewotICAgICAgICBDb21wb25lbnRJbnN0YW5jZSBjb21wb25lbnRJbnN0YW5jZSA9IG51bGw7CisgICAgcHJpdmF0ZSBDb21wb25lbnRJbnN0YW5jZSBnZXRSZWxhdGVkQ29tcG9uZW50SW5zdGFuY2UoQ29tcG9uZW50VHlwZUVudW0gY29tcG9uZW50VHlwZSwgU3RyaW5nIGNvbXBvbmVudFV1aWQsIFN0cmluZyByZXNvdXJjZUluc3RhbmNlTmFtZSkgeworICAgICAgICBDb21wb25lbnRJbnN0YW5jZSBjb21wb25lbnRJbnN0YW5jZTsKICAgICAgICAgU3RyaW5nIG5vcm1hbGl6ZWROYW1lID0gVmFsaWRhdGlvblV0aWxzLm5vcm1hbGl6ZUNvbXBvbmVudEluc3RhbmNlTmFtZShyZXNvdXJjZUluc3RhbmNlTmFtZSk7Ci0gICAgICAgIENvbXBvbmVudCBjb21wb25lbnQgPSBnZXRDb21wb25lbnRCeVV1aWQoY29tcG9uZW50VHlwZSwgY29tcG9uZW50VXVpZCwgZXJyb3JXcmFwcGVyKTsKLSAgICAgICAgaWYgKGVycm9yV3JhcHBlci5pc0VtcHR5KCkpIHsKLSAgICAgICAgICAgIGNvbXBvbmVudEluc3RhbmNlID0gY29tcG9uZW50LmdldENvbXBvbmVudEluc3RhbmNlcygpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5zdHJlYW0oKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZmlsdGVyKGNpIC0+IFZhbGlkYXRpb25VdGlscy5ub3JtYWxpemVDb21wb25lbnRJbnN0YW5jZU5hbWUoY2kuZ2V0TmFtZSgpKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5lcXVhbHMobm9ybWFsaXplZE5hbWUpKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZmluZEZpcnN0KCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLm9yRWxzZShudWxsKTsKLSAgICAgICAgICAgIGlmIChjb21wb25lbnRJbnN0YW5jZSA9PSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgZXJyb3JXcmFwcGVyLnNldElubmVyRWxlbWVudChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLkNPTVBPTkVOVF9JTlNUQU5DRV9OT1RfRk9VTkRfT05fQ09OVEFJTkVSLCByZXNvdXJjZUluc3RhbmNlTmFtZSwgUkVTT1VSQ0VfSU5TVEFOQ0UsIGNvbXBvbmVudAotICAgICAgICAgICAgICAgICAgICAgICAgLmdldENvbXBvbmVudFR5cGUoKQotICAgICAgICAgICAgICAgICAgICAgICAgLmdldFZhbHVlKCksIGNvbXBvbmVudC5nZXROYW1lKCkpKTsKLSAgICAgICAgICAgICAgICBsb2cuZGVidWcoQ09NUE9ORU5UX0lOU1RBTkNFX05PVF9GT1VORCwgcmVzb3VyY2VJbnN0YW5jZU5hbWUsIGNvbXBvbmVudC5nZXROYW1lKCkpOwotICAgICAgICAgICAgfQorICAgICAgICBDb21wb25lbnQgY29tcG9uZW50ID0gZ2V0Q29tcG9uZW50QnlVdWlkKGNvbXBvbmVudFR5cGUsIGNvbXBvbmVudFV1aWQpOworICAgICAgICBjb21wb25lbnRJbnN0YW5jZSA9IChjb21wb25lbnQgPT0gbnVsbCkgPyBudWxsIDogY29tcG9uZW50LmdldENvbXBvbmVudEluc3RhbmNlcygpCisgICAgICAgICAgICAgICAgLnN0cmVhbSgpCisgICAgICAgICAgICAgICAgLmZpbHRlcihjaSAtPiBWYWxpZGF0aW9uVXRpbHMubm9ybWFsaXplQ29tcG9uZW50SW5zdGFuY2VOYW1lKGNpLmdldE5hbWUoKSkKKyAgICAgICAgICAgICAgICAgICAgICAgIC5lcXVhbHMobm9ybWFsaXplZE5hbWUpKQorICAgICAgICAgICA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CwgQ29tcG9uZW50SW5zdGFuY2U+IHJlbGF0ZWRDb21wb25lbnRDb21wb25lbnRJbnN0YW5jZVBhaXIgPSBudWxsOwogICAgICAgICBTdHJpbmcgbm9ybWFsaXplZE5hbWUgPSBWYWxpZGF0aW9uVXRpbHMubm9ybWFsaXplQ29tcG9uZW50SW5zdGFuY2VOYW1lKHJlc291cmNlSW5zdGFuY2VOYW1lKTsKICAgICAgICAgQ29tcG9uZW50SW5zdGFuY2UgY29tcG9uZW50SW5zdGFuY2UgPSBjb21wb25lbnQuZ2V0Q29tcG9uZW50SW5zdGFuY2VzKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuc3RyZWFtKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZmlsdGVyKGNpIC0+IFZhbGlkYXRpb25VdGlscy5ub3JtYWxpemVDb21wb25lbnRJbnN0YW5jZU5hbWUoY2kuZ2V0TmFtZSgpKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmVxdWFscyhub3JtYWxpemVkTmFtZSkpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmZpbmRGaXJzdCgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLm9yRWxzZShudWxsKTsKKyAgICAgICAgICAgICAgICAuc3RyZWFtKCkKKyAgICAgICAgICAgICAgICAuZmlsdGVyKGNpIC0+IFZhbGlkYXRpb25VdGlscy5ub3JtYWxpemVDb21wb25lbnRJbnN0YW5jZU5hbWUoY2kuZ2V0TmFtZSgpKQorICAgICAgICAgICAgICAgICAgICAgICAgLmVxdWFscyhub3JtYWxpemVkTmFtZSkpCisgICAgICAgICAgICAgICAgLmZpbmRGaX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yw1NyBAQAogICAgICAgICByZXR1cm4gcmVsYXRlZENvbXBvbmVudENvbXBvbmVudEluc3RhbmNlUGFpcjsKICAgICB9CiAKLSAgICBwcml2YXRlIEltbXV0YWJsZVBhaXI8Q29tcG9uZW50LCBDb21wb25lbnRJbnN0YW5jZT4gZ2V0UmVsYXRlZENvbXBvbmVudENvbXBvbmVudEluc3RhbmNlKENvbXBvbmVudFR5cGVFbnVtIGNvbXBvbmVudFR5cGUsIFN0cmluZyBjb21wb25lbnRVdWlkLCBTdHJpbmcgcmVzb3VyY2VJbnN0YW5jZU5hbWUsIFdyYXBwZXI8UmVzcG9uc2VGb3JtYXQ+IGVycm9yV3JhcHBlcikgeworICAgIHByaXZhdGUgSW1tdXRhYmxlUGFpcjxDb21wb25lbnQsIENvbXBvbmVudEluc3RhbmNlPiBnZXRSZWxhdGVkQ29tcG9uZW50Q29tcG9uZW50SW5zdGFuY2UoQ29tcG9uZW50VHlwZUVudW0gY29tcG9uZW50VHlwZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZyBjb21wb25lbnRVdWlkLCBTdHJpbmcgcmVzb3VyY2VJbnN0YW5jZU5hbWUpIHsKICAgICAgICAgQ29tcG9uZW50SW5zdGFuY2UgY29tcG9uZW50SW5zdGFuY2U7Ci0gICAgICAgIEltbXV0YWJsZVBhaXI8Q29tcG9uZW50LCBDb21wb25lbnRJbnN0YW5jZT4gcmVsYXRlZENvbXBvbmVudENvbXBvbmVudEluc3RhbmNlUGFpciA9IG51bGw7Ci0gICAgICAgIENvbXBvbmVudCBjb21wb25lbnQgPSBnZXRMYXRlc3RDb21wb25lbnRCeVV1aWQoY29tcG9uZW50VHlwZSwgY29tcG9uZW50VXVpZCwgZXJyb3JXcmFwcGVyKTsKLSAgICAgICAgaWYgKGVycm9yV3JhcHBlci5pc0VtcHR5KCkpIHsKLSAgICAgICAgICAgIGNvbXBvbmVudEluc3RhbmNlID0gY29tcG9uZW50LmdldENvbXBvbmVudEluc3RhbmNlcygpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5zdHJlYW0oKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZmlsdGVyKGNpIC0+IGNpLmdldE5vcm1hbGl6ZWROYW1lKCkuZXF1YWxzKHJlc291cmNlSW5zdGFuY2VOYW1lKSkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmZpbmRGaXJzdCgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5vckVsc2UobnVsbCk7Ci0gICAgICAgICAgICBpZiAoY29tcG9uZW50SW5zdGFuY2UgPT0gbnVsbCkgewotICAgICAgICAgICAgICAgIGVycm9yV3JhcHBlci5zZXRJbm5lckVsZW1lbnQoY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5DT01QT05FTlRfSU5TVEFOQ0VfTk9UX0ZPVU5EX09OX0NPTlRBSU5FUiwgcmVzb3VyY2VJbnN0YW5jZU5hbWUsIFJFU09VUkNFX0lOU1RBTkNFLCBjb21wb25lbnQKLSAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRDb21wb25lbnRUeXBlKCkKLSAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRWYWx1ZSgpLCBjb21wb25lbnQuZ2V0TmFtZSgpKSk7Ci0gICAgICAgICAgICAgICAgbG9nLmRlYnVnKENPTVBPTkVOVF9JTlNUQU5DRV9OT1RfRk9VTkQsIHJlc291cmNlSW5zdGFuY2VOYW1lLCBjb21wb25lbnQuZ2V0TmFtZSgpKTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGVsc2UgewotICAgICAgICAgICAgICAgIHJlbGF0ZWRDb21wb25lbnRDb21wb25lbnRJbnN0YW5jZVBhaXIgPSBuZXcgSW1tdXRhYmxlUGFpcjw+KGNvbXBvbmVudCwgY29tcG9uZW50SW5zdGFuY2UpOwotICAgICAgICAgICAgfQorICAgICAgICBJbW11dGFibGVQYWlyPENvbXBvbmVudCwgQ29tcG9uZW50SW5zdGFuY2U+IHJlbGF0ZWRDb21wb25lbnRDb21wb25lbnRJbnN0YW5jZVBhaXI7CisgICAgICAgIENvbXBvbmVudCBjb21wb25lbnQgPSBnZXRMYXRlc3RDb21wb25lbnRCeVV1aWQoY29tcG9uZW50VHlwZSwgY29tcG9uZW50VXVpZCk7CisgICAgICAgIGNvbXBvbmVudEluc3RhbmNlID0gY29tcG9uZW50LmdldENvbXBvbmVudEluc3RhbmNlcygpCisgICAgICAgICAgICAgICAgLnN0cmVhbSgpCisgICAgICAgICAgICAgICAgLmZpbHRlcihjaSAtPiBjaS5nZXROb3JtYWxpemVkTmFtZSgpLmVxdWFscyhyZXNvdXJjZUluc3RhbmNlTmFtZSkpCisgICAgICAgICAgICAgICAgLmZpbmRGaXJzdCgpCisgICAgICAgICAgICAgICAgLm9yRWxzZShudWxsKTsKKyAgICAgICAgaWYgKGNvbXBvbmVudEluc3RhbmNlID09IG51bGwpIHsKKyAgICAgICAgICAgIGxvZy5kZWJ1ZyhDT01QT05FTlRfSU5TVEFOQ0VfTk9UX0ZPVU5ELCByZXNvdXJjZUluc3RhbmNlTmFtZSwgY29tcG9uZW50LmdldE5hbWUoKSk7CisgICAgICAgICAgICB0aHJvdyBuZXcgQnlBY3Rpb25TdGF0dXNDb21wb25lbnRFeGNlcHRpb24oQWN0aW9uU3RhdHVzLkNPTVBPTkVOVF9JTlNUQU5DRV9OT1RfRk9VTkRfT05fQ09OVEFJTkVSLAorICAgICAgICAgICAgICAgICAgICByZXNvdXJjZUluc3RhbmNlTmFtZSwgUkVTT1VSQ0VfSU5TVEFOQ0UsIGNvbXBvbmVudAorICAgICAgICAgICAgICAgICAgICAuZ2V0Q29tcG9uZW50VHlwZSgpLmdldFZhbHVlKCks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ZmFjdERlZmluaXRpb24gZGVwbG95bWVudEFydGlmYWN0OwogICAgICAgICBpZiAoYXJ0aWZhY3RzICE9IG51bGwgJiYgIWFydGlmYWN0cy5pc0VtcHR5KCkpIHsKICAgICAgICAgICAgIGFydGlmYWN0c0xpc3QgPSBhcnRpZmFjdHMudmFsdWVzKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuc3RyZWFtKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZmlsdGVyKGFydCAtPiBhcnQuZ2V0QXJ0aWZhY3RVVUlEKCkgIT0gbnVsbCAmJiBhcnQuZ2V0QXJ0aWZhY3RVVUlEKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZXF1YWxzKGFydGlmYWN0VVVJRCkpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmNvbGxlY3QoQ29sbGVjdG9ycy50b0xpc3QoKSk7CisgICAgICAgICAgICAgICAgICAgIC5zdHJlYW0oKQorICAgICAgICAgICAgICAgICAgICAuZmlsdGVyKGFydCAtPiBhcnQuZ2V0QXJ0aWZhY3RVVUlEKCkgIT0gbnVsbCAmJiBhcnQuZ2V0QXJ0aWZhY3RVVUlEKCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZXF1YWxzKGFydGlmYWN0VVVJRCkpCisgICAgICAgICAgICAgICAgICAgIC5jb2xsZWN0KENvbGxlY3RvcnMudG9MaXN0KCkpOwogICAgICAgICB9CiAgICAgICAgIGlmIChhcnRpZmFjdHNMaXN0ID09IG51bGwgfHwgYXJ0aWZhY3RzTGlzdC5pc0VtcHR5KCkpIHsKICAgICAgICAgICAgIGxvZy5kZWJ1ZygiRGVwbG95bWVudCBhcnRpZmFjdCB3aXRoIHV1aWQge30gd2FzIG5vdCBmb3VuZCBmb3IgY29tcG9uZW50IH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G95bWVudEFydGlmYWN0LmdldFVuaXF1ZUlkKCkpOwotICAgICAgICAgICAgZG93bmxvYWRlZEFydGlmYWN0ID0gZG93bmxvYWRBcnRpZmFjdEVpdGhlci5sZWZ0KCkudmFsdWUoKS5nZXRSaWdodCgpOwotICAgICAgICB9Ci0gICAgICAgIHJldHVybiBkb3dubG9hZGVkQXJ0aWZhY3Q7CisgICAgICAgIGRlcGxveW1lbnRBcnRpZmFjdCA9IGFydGlmYWN0c0xpc3QuZ2V0KDApOworICAgICAgICBkb3dubG9hZEFydGlmYWN0ID0gZG93bmxvYWRBcnRpZmFjdChkZXBsb3ltZW50QXJ0aWZhY3QpOworICAgICAgICBsb2cudHJhY2UoIlN1Y2NlZWRlZCB0byBkb3dubG9hZCBhcnRpZmFjdCB3aXRoIHVuaXF1ZUlkIHt9IiwgZGVwbG95bWVudEFydGlmYWN0LmdldFVuaXF1ZUlkKCkpOworICAgICAgICByZXR1cm4gZG93bmxvYWRBcnRpZmFjdC5nZXRSaWdodCgpOwogICAgIH0KIAotICAgIHByaXZhdGUgQ29tcG9uZW50IGdldExhdGVzdENvbXBvbmVudEJ5VXVpZChDb21wb25lbnRUeXBlRW51bSBjb21wb25lbnRUeXBlLCBTdHJpbmcgY29tcG9uZW50VXVpZCwgV3JhcHBlcjxSZXNwb25zZUZvcm1hdD4gZXJyb3JXcmFwcGVyKSB7Ci0gICAgICAgIENvbXBvbmVudCBjb21wb25lbnQgPSBudWxsOworICAgIHByaXZhdGUgQ29tcG9uZW50IGdldExhdGVzdENvbXBvbmVudEJ5VXVpZChDb21wb25lbnRUeXBlRW51bSBjb21wb25lbnRUeXBlLCBTdHJpbmcgY29tcG9uZW50VXVpZCkgeworICAgICAgICBDb21wb25lbnQgY29tcG9uZW50OwogICAgICAgICBFaXRoZXI8Q29tcG9uZW50LCBTdG9yYWdlT3BlcmF0aW9uU3RhdHVzPiBnZXRDb21wb25lbnRSZXMgPSB0b3NjYU9wZXJhdGlvbkZhY2FkZS5nZXR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YWN0c1Jlcy5yaWdodCgpLnZhbHVlKCk7CiAgICAgICAgICAgICBsb2cuZGVidWcoIkNvdWxkbid0IGZldGNoIGFydGlmYWN0cyBkYXRhIGZvciBwYXJlbnQgY29tcG9uZW50IHt9IHdpdGggdWlkIHt9LCBlcnJvcjoge30iLCBjb21wb25lbnRUeXBlLCBwYXJlbnRJZCwgc3RvcmFnZVN0YXR1cyk7Ci0gICAgICAgICAgICBpZiAoIXN0b3JhZ2VTdGF0dXMuZXF1YWxzKFN0b3JhZ2VPcGVyYXRpb25TdGF0dXMuTk9UX0ZPVU5EKSkgeworICAgICAgICAgICAgaWYgKHN0b3JhZ2VTdGF0dXMgIT0gU3RvcmFnZU9wZXJhdGlvblN0YXR1cy5OT1RfRk9VTkQpIHsKICAgICAgICAgICAgICAgICBhY3Rpb25TdGF0dXMgPSBjb21wb25lbnRzVXRpbHMuY29udmVydEZyb21TdG9yYWdlUmVzcG9uc2Uoc3RvcmFnZVN0YXR1cyk7CiAgICAgICAgICAgICB9Ci0gICAgICAgICAgICBlcnJvcldyYXBwZXIuc2V0SW5uZXJFbGVtZW50KGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChhY3Rpb25TdGF0dXMsIGFydGlmYWN0VVVJRCkpOworICAgICAgICAgICAgdGhyb3cgbmV3IEJ5QWN0aW9uU3RhdHVzQ29tcG9uZW50RXhjZXB0aW9uKGFjdGlvblN0YXR1cywgYXJ0aWZhY3RVVUlEKTsKICAgICAgICAgfQotICAgICAgICBpZiAoZXJyb3JXcmFwcGVyLmlzRW1wdHkoKSkgewotICAgICAgICAgICAgYXJ0aWZhY3RzID0gZ2V0QXJ0aWZhY3RzUmVzLmxlZnQoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnZhbHVlKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC52YWx1ZXMoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnN0cmVhbSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZmlsdGVyKGEgLT4gYS5nZXRBcnRpZmFjdFVVSUQoKSAhPSBudWxsICYmIGEuZ2V0QXJ0aWZhY3RVVUlEKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5lcXVhbHMoYXJ0aWZhY3RVVUlEKSkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5jb2xsZWN0KENvbGxlY3RvcnMudG9MaXN0KCkpOwotICAgICAgICAgICAgaWYgKGFydGlmYWN0cyA9PSBudWxsIHx8IGFydGlmYWN0cy5pc0VtcHR5KCkpIHsKLSAgICAgICAgICAgICAgICBsb2cuZGVidWcoIkNvdWxkbid0IGZldGNoIGFydGlmYWN0IHdpdGggVVVJRCB7fSBkYXRhIGZvciBwYXJlbnQgY29tcG9uZW50IHt9IHdpdGggdWlkIHt9LCBlcnJvcjoge30iLCBhcnRpZmFjdFVVSUQsIGNvbXBvbmVudFR5cGUsIHBhcmVudElkLCBhY3Rpb25TdGF0dXMpOwotICAgICAgICAgICAgICAgIGVycm9yV3JhcHBlci5zZXRJbm5lckVsZW1lbnQoY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KGFjdGlvblN0YXR1cywgYXJ0aWZhY3RVVUlEKSk7CisgICAgICAgIGFydGlmYWN0cyA9IGdldEFydGlmYWN0c1Jlcy5sZWZ0KCkKKyAgICAgICAgICAgICAgICAudmFsdWUoKQorICAgICAgICAgICAgICAgIC52YWx1ZXMoKQorICAgICAgICAgICAgICAgIC5zdHJlYW0oKQorICAgICAgICAgICAgICAgIC5maWx0ZXIoYSAtPiBhLmdldEFydGlmYWN0VVVJRCgpICE9IG51bGwgJiYgYS5nZXRBcnRpZmFjdFVVSUQoKQorICAgICAgICAgICAgICAgICAgICAgICAg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IHsKLSAgICAgICAgcmV0dXJuIGxvY2tFbGVtZW50KCBjb21wb25lbnRJZCwgIGNvbXBvbmVudCwgIGVjb21wRXJyb3JDb250ZXh0KQotICAgICAgICAgICAgICAgIC5yaWdodCgpCi0gICAgICAgICAgICAgICAgLm1hcChyIC0+IGxvZ0FuZENvbnZlcnRFcnJvcihyLCBjb21wb25lbnQuZ2V0VW5pcXVlSWQoKSwgY29tcG9uZW50LmdldE5hbWUoKSkgKTsKLSAgICB9Ci0KLSAgICBwcm90ZWN0ZWQgdm9pZCBsb2NrQ29tcG9uZW50KFN0cmluZyBjb21wb25lbnRJZCwgQ29tcG9uZW50IGNvbXBvbmVudCwgYm9vbGVhbiBuZWVkTG9jaywgU3RyaW5nIGVjb21wRXJyb3JDb250ZXh0KSB7Ci0gICAgICAgIGlmIChuZWVkTG9jayl7Ci0gICAgICAgICAgICBsb2NrRWxlbWVudCggY29tcG9uZW50SWQsICBjb21wb25lbnQsICBlY29tcEVycm9yQ29udGV4dCkKLSAgICAgICAgICAgICAgICAgICAubGVmdCgpCi0gICAgICAgICAgICAgICAgICAgLm9uKHIgLT4gbG9nQW5kVGhyb3dFeGNlcHRpb24ociwgY29tcG9uZW50LmdldFVuaXF1ZUlkKCksIGNvbXBvbmVudC5nZXROYW1lKCkpICk7CisgICAgcHJvdGVjdGVkIHZvaWQgbG9ja0NvbXBvbmVudChDb21wb25lbnQgY29tcG9uZW50LCBib29sZWFuIHNob3VsZExvY2ssIFN0cmluZyBlY29tcEVycm9yQ29udGV4dCkgeworICAgICAgICBpZihzaG91bGRMb2NrKXsKKyAgICAgICAgICAgIGxvY2tDb21wb25lbnQoY29tcG9uZW50LmdldFVuaXF1ZUlkKCksIGNvbXBvbmVudCwgZWNvbXBFcnJvckNvbnRleHQpOwogICAgICAgICB9CiAgICAgfQogCi0gICAgcHJpdmF0ZSBCb29sZWFuIGxvZ0FuZFRocm93RXhjZXB0aW9uKEFjdGlvblN0YXR1cyBzdGF0dXMsIFN0cmluZyBjb21wb25lbnRJZCwgU3RyaW5nIG5hbWUpeworICAgIHByb3RlY3RlZCB2b2lkIGxvY2tDb21wb25lbnQoU3RyaW5nIGNvbXBvbmVudElkLCBDb21wb25lbnQgY29tcG9uZW50LCBTdHJpbmcgZWNvbXBFcnJvckNvbnRleHQpIHsKKyAgICAgICAgQWN0aW9uU3RhdHVzIGxvY2sgPSBsb2NrRWxlbWVudChjb21wb25lbnRJZCwgY29tcG9uZW50LCBlY29tcEVycm9yQ29udGV4dCk7CisgICAgICAgIGlmICggbG9jayE9IEFjdGlvblN0YXR1cy5PSyApIHsKKyAgICAgICAgICAgIGxvZ0FuZFRocm93Q29tcG9uZW50RXhjZXB0aW9uKGxvY2ssIGNvbXBvbmVudC5nZXRVbmlxdWVJZCgpLCBjb21wb25lbnQuZ2V0TmFtZSgpKTsKKyAgICAgICAgfQorICAgIH0KKworICAgIHByb3RlY3RlZCB2b2lkIGxvY2tDb21wb25lbnQoU3RyaW5nIGNvbXBvbmVudElkLCBDb21wb25lbnQgY29tcG9uZW50LCBib29sZWFuIG5lZWRMb2NrLCBTdHJpbmcgZWNvbXBFcnJvckNvbnRleHQpIHsKKyAgICAgICAgaWYgKG5lZWRMb2NrKSB7CisgICAgICAgICAgICBsb2NrQ29tcG9uZW50KGNvbXBvbmVudElkLCBjb21wb25lbnQsIGVjb21wRXJyb3JDb250ZXh0KTsKKyAgICAgICAgfQorICAgIH0KKworICAgIHByaXZhdGUgUmVzcG9uc2VGb3JtYXQgbG9nQW5kVGhyb3dDb21wb25lbnRFeGNlcHRpb24oQWN0aW9uU3RhdHVzIHN0YXR1cywgU3RyaW5nIGNvbXBvbmVudElkLCBTdHJpbmcgbmFtZSl7CiAgICAgICAgIGxvZy5kZWJ1ZyhGQUlMRURfVE9fTE9DS19DT01QT05FTlRfRVJST1IsIGNvbXBvbmVudElkLCBzdGF0dXMpOwogICAgICAgICB0aHJvdyBuZXcgQnlBY3Rpb25TdGF0dXNDb21wb25lbnRFeGNlcHRp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VudW0gbm9kZVR5cGUgPSBjb21wb25lbnRUeXBlLmdldE5vZGVUeXBlKCk7Ci0gICAgICAgIGlmICghaW5UcmFuc2FjdGlvbikgewotICAgICAgICAgICAgaWYgKGVpdGhlciA9PSBudWxsIHx8IGVpdGhlci5pc1JpZ2h0KCkpIHsKLSAgICAgICAgICAgICAgICBqYW51c0dyYXBoRGFvLnJvbGxiYWNrKCk7Ci0gICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgIGphbnVzR3JhcGhEYW8uY29tbWl0KCk7CisgICAgcHJvdGVjdGVkIHZvaWQgdW5sb2NrQ29tcG9uZW50KGJvb2xlYW4gZmFpbGVkLCBDb21wb25lbnQgY29tcG9uZW50LCBib29sZWFuIGluVHJhbnNhY3Rpb24pIHsKKyAgICAgICAgaWYgKGNvbXBvbmVudCAhPSBudWxsKSB7CisgICAgICAgICAgICBDb21wb25lbnRUeXBlRW51bSBjb21wb25lbnRUeXBlID0gY29tcG9uZW50LmdldENvbXBvbmVudFR5cGUoKTsKKyAgICAgICAgICAgIE5vZGVUeXBlRW51bSBub2RlVHlwZSA9IGNvbXBvbmVudFR5cGUuZ2V0Tm9kZVR5cGUoKTsKKyAgICAgICAgICAgIGlmICghaW5UcmFuc2FjdGlvbikgeworICAgICAgICAgICAgICAgIGlmIChmYWlsZWQpIHsKKyAgICAgICAgICAgICAgICAgICAgamFudXNHcmFwaERhby5yb2xsYmFjaygpOworICAgICAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgICAgIGphbnVzR3JhcGhEYW8uY29tbWl0KCk7CisgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQorICAgICAgICAgICAgLy8gdW5sb2NrIHJlc291cmNlCisgICAgICAgICAgICBncmFwaExvY2tPcGVyYXRpb24udW5sb2NrQ29tcG9uZW50KGNvbXBvbmVudC5nZXRVbmlxdWVJZCgpLCBub2RlVHlwZSk7CiAgICAgICAgIH0KLSAgICAgICAgLy8gdW5sb2NrI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FyYW1OYW1lKGNvbXBvbmVudFR5cGUpOwogICAgICAgICBpZiAoY29tcG9uZW50VHlwZUVudW0gPT0gbnVsbCkgewogICAgICAgICAgICAgbG9nLmRlYnVnKCJJbnZhbGlkIGNvbXBvbmVudCB0eXBlIHt9IiwgY29tcG9uZW50VHlwZSk7Ci0gICAgICAgICAgICByZXR1cm4gRWl0aGVyLnJpZ2h0KGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuVU5TVVBQT1JURURfRVJST1IsIGNvbXBvbmVudFR5cGUpKTsKKyAgICAgICAgICAgIHRocm93IG5ldyBCeUFjdGlvblN0YXR1c0NvbXBvbmVudEV4Y2VwdGlvbihBY3Rpb25TdGF0dXMuVU5TVVBQT1JURURfRVJST1IsIGNvbXBvbmVudFR5cGUpOwogICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5sZWZ0KGNvbXBvbmVudFR5cGVFbnVtKTsKKyAgICAgICAgICAgIHJldHVybiBjb21wb25lbnRUeXBlRW51bTsKICAgICAgICAgfQogICAgIH0KIAotICAgIHByb3RlY3RlZCBFaXRoZXI8Q29tcG9uZW50LCBSZXNwb25zZUZvcm1hdD4gdmFsaWRhdGVDb21wb25lbnRFeGlzdHMoU3RyaW5nIGNvbXBvbmVudElkLCBDb21wb25lbnRUeXBlRW51bSBjb21wb25lbnRUeXBlLCBDb21wb25lbnRQYXJhbWV0ZXJzVmlldyBmaWx0ZXIpIHsKLSAgICAgICAgcmV0dXJuIHRvc2NhT3BlcmF0aW9uRmFjYWRlLmdldFRvc2NhRWxlbWVudChjb21wb25lbnRJZCwgZmlsdGVyID09IG51bGwgPyBuZXcgQ29tcG9uZW50UGFyYW1ldGVyc1ZpZXcoKSA6IGZpbHRlcikKLSAgICAgICAgICAgICAgICAucmlnaHQoKQotICAgICAgICAgICAgICAgIC5tYXAoZXJyIC0+IGhhbmRsZUdldENvbXBvbmVudEVycm9yKGN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AgICAgICByZXR1cm4gRWl0aGVyLnJpZ2h0KGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChjb21wb25lbnRzVXRpbHMuY29udmVydEZyb21TdG9yYWdlUmVzcG9uc2UoRGFvU3RhdHVzQ29udmVydGVyLmNvbnZlcnRKYW51c0dyYXBoU3RhdHVzVG9TdG9yYWdlU3RhdHVzKAotICAgICAgICAgICAgICAgICAgICBKYW51c0dyYXBoT3BlcmF0aW9uU3RhdHVzLklMTEVHQUxfQVJHVU1FTlQpKSkpOworICAgICAgICAgICAgICAgIHRocm93IG5ldyBCeUFjdGlvblN0YXR1c0NvbXBvbmVudEV4Y2VwdGlvbihjb21wb25lbnRzVXRpbHMuY29udmVydEZyb21TdG9yYWdlUmVzcG9uc2UoRGFvU3RhdHVzQ29udmVydGVyLmNvbnZlcnRKYW51c0dyYXBoU3RhdHVzVG9TdG9yYWdlU3RhdHVzKEphbnVzR3JhcGhPcGVyYXRpb25TdGF0dXMuSUxMRUdBTF9BUkdVTUVOVCkpKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIE9iamVjdCBvYmplY3QgPSBpc1ZhbGlkLmxlZnQoKS52YWx1ZSgpOwpAQCAtMzQ1LDEwICszNTUsMTAgQEAKICAgICAgICAgICAgICAgICBuZXdWYWx1ZSA9IG9iamVjdC50b1N0cmluZygpOwogICAgICAgICAgICAgfQogICAgICAgICB9Ci0gICAgICAgIHJldHVybiBFaXRoZXIubGVmdChuZXdWYWx1ZSk7CisgICAgICAgIHJldHVybiBuZXdWYWx1ZTsKICAgICB9CiAKLSAgICBwcml2YXRlIDxUIGV4dGVuZHMgUHJvcGVydHlEYXRhRGVmaW5pdGlvbj4gU3RyaW5nIGdldElubmVyVHlwZShUIHByb3BlcnR5KXsKKyAgICA8VCBleHRlbmRzIFByb3BlcnR5RGF0YURlZmluaXRpb24+IFN0cmluZyBnZXRJbm5lclR5cGUoVCBwcm9wZXJ0e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01QT05FTlRfSVNfQVJDSElWRUQ7CisgICAgICAgICAgICB0aHJvdyBuZXcgQnlBY3Rpb25TdGF0dXNDb21wb25lbnRFeGNlcHRpb24oYWN0aW9uU3RhdHVzLCBjb21wb25lbnQuZ2V0TmFtZSgpKTsKKyAgICAgICAgfQorCiAgICAgICAgIGlmIChjb21wb25lbnQuZ2V0TGlmZWN5Y2xlU3RhdGUoKSAhPSBMaWZlY3ljbGVTdGF0ZUVudW0uTk9UX0NFUlRJRklFRF9DSEVDS09VVCkgewogICAgICAgICAgICAgbG9nLmRlYnVnKCJDb21wb25lbnQge30gaXMgbm90IGNoZWNrZWQtb3V0IiwgY29tcG9uZW50LmdldE5hbWUoKSk7Ci0gICAgICAgICAgICByZXR1cm4gY2FuV29yazsKKyAgICAgICAgICAgIHRocm93IG5ldyBCeUFjdGlvblN0YXR1c0NvbXBvbmVudEV4Y2VwdGlvbihhY3Rpb25TdGF0dXMpOwogICAgICAgICB9CiAKICAgICAgICAgLy8gdmVyaWZ5IHVzZXJJZCBpcyBub3QgbnVsbAogICAgICAgICBpZiAodXNlcklkID09IG51bGwpIHsKICAgICAgICAgICAgIGxvZy5kZWJ1ZygiQ3VycmVudCB1c2VyIHVzZXJJZCBpcyBudWxsIik7Ci0gICAgICAgICAgICByZXR1cm4gY2FuV29yazsKKyAgICAgICAgICAgIHRocm93IG5ldyBCeUFjdGlvblN0YXR1c0NvbXBvbmVudEV4Y2VwdGlvbihhY3Rpb25TdGF0dXMpOwogICAgICAgICB9CiAKICAgICAgICAgLy8gdmVyaWZ5IGNvbXBvbmVudCBsYXN0IHVwZGF0ZSB1c2VyIGlzIHRoZSBjdXJyZW50IHVzZXIKICAgICAgICAgU3RyaW5nIGxhc3RVcGRhdGVyVXNlcklkID0gY29tcG9uZW50LmdldExhc3RVcGRhdGVyVXNlcklkKCk7CiAgICAgICAgIGlmICghdXNlcklkLmVxdWFscyhsYXN0VXBkYXRlclVzZXJJZCkpIHsKICAgICAgICAgICAgIGxvZy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GF0dXNUb1N0b3JhZ2VTdGF0dXMoCi0gICAgICAgICAgICAgICAgSmFudXNHcmFwaE9wZXJhdGlvblN0YXR1cy5JTExFR0FMX0FSR1VNRU5UKSk7CisgICAgICAgICAgICAgICAgICAgIEphbnVzR3JhcGhPcGVyYXRpb25TdGF0dXMuSUxMRUdBTF9BUkdVTUVOVCkpOwogICAgICAgICB9CiAgICAgICAgIHJldHVybiBuZXdWYWx1ZTsKICAgICB9CkBAIC02OTcsNyArNzEzLDcgQEAKICAgICB9CiAKICAgICBwdWJsaWMgIDxUIGV4dGVuZHMgVG9zY2FEYXRhRGVmaW5pdGlvbj4gRWl0aGVyPExpc3Q8VD4sIFJlc3BvbnNlRm9ybWF0PiBkZWNsYXJlUHJvcGVydGllcyhTdHJpbmcgdXNlcklkLCBTdHJpbmcgY29tcG9uZW50SWQsCi0gICAgICAgICAgICBDb21wb25lbnRUeXBlRW51bSBjb21wb25lbnRUeXBlRW51bSwgQ29tcG9uZW50SW5zdElucHV0c01hcCBjb21wb25lbnRJbnN0SW5wdXRzTWFwKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29tcG9uZW50VHlwZUVudW0gY29tcG9uZW50VHlwZUVudW0sIENvbXBvbmVudEluc3RJbnB1dHNNYXAgY29tcG9uZW50SW5zdElucHV0c01hcCkgewogCiAgICAgICAgIHJldHVybiBFaXRoZXIubGVmdChuZXcgQXJyYXlMaXN0PD4oKSk7CiAgICAgfQpAQCAtNzA1LDcgKzcyMSw3IEBACiAgICAgcHVibGljIDxUIGV4dGVuZHMgUHJvcGVydHlEYXRhRGVmaW5pdGlvbj4gTGlzdDxQcm9wZXJ0eUNvbnN0cmFpbnQ+IHNldElucHV0Q29uc3RyYWludChUIGlucHV0RGVmaW5pdGlvbikgewogICAgICAgICBpZiAoU3RyaW5nVXRpbHMuaXNOb3RCbGFuayhpbnB1dERlZmluaXRpb24uZ2V0UGFyZW50UHJvcGVydHlUeXBlKCkpCiAgICAgICAgICAgICAgICAgJiYgU3RyaW5nVXRpbHMuaXNOb3RCbGFuayhpbnB1dERlZmluaXRpb24uZ2V0U3ViUHJvcGVydHlJbnB1dFBhdGgoKSkpIHsKLSAgICAgICAgICAgICAgICByZXR1cm4gc2V0Q29uc3RyYWludChpbnB1dERlZmluaXRpb24pOworICAgICAgICAgICAgcmV0dXJuIHNldENvbnN0cmFpbnQoaW5wdXREZWZpbml0aW9uKTsKICAgICAgICAgfQogCiAgICAgICAgIHJldHVybiBDb2xsZWN0aW9ucy5lbXB0eUxpc3QoKTsKQEAgLTc1Niw0ICs3NzIsNTMgQEAKIAogICAgICAgICByZXR1cm4gdHlwZTsKICAgICB9CisKKworICAgIHByb3RlY3RlZCB2b2lkIHJvbGxiYWNrV2l0aEV4Y2VwdGlvbihTdG9yYWdlRXhjZXB0aW9uIGUpIHsKKyAgICAgICAgamFudXNHcmFwaERhby5yb2xsYmFjaygpOworICAgICAgICB0aHJvdyBlOworICAgIH0KKworICAgIHByb3RlY3RlZCB2b2lkIHJvbGxiYWNrV2l0aEV4Y2VwdGlvbihDb21wb25lbnRFeGNlcHRpb24gZSkgeworICAgICAgICBqYW51c0dyYXBoRGFvLnJvbGxiYWNrKCk7CisgICAgICAgIHRocm93IGU7CisgICAgfQorCisgICAgcHJvdGVjdGVkIHZvaWQgdW5sb2NrUm9sbGJhY2tXaXRoRXhjZXB0aW9uKENvbXBvbmVudCBjb21wb25lbnQsIFJ1bnRpbWVFeGNlcHRpb24gZSkgeworICAgICAgICBqYW51c0dyYXBoRGFvLnJvbGxiYWNrKCk7CisgICAgICAgIGdyYXBoTG9ja09wZXJhdGlvbi51bmxvY2tDb21wb25lbnQoY29tcG9uZW50LmdldFVuaXF1ZUlkKCksIGNvbXBvbmVudC5nZXRDb21wb25lbnRUeXBlKCkuZ2V0Tm9kZVR5cGUoKSk7CisgICAgICAgIHRocm93IGU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2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jb21wb25lbnRzL2ltcGwvQ0FESUhlYWx0aENoZWNrLmphdmEKQEAgLTAsMCArMSw1OCBAQAorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDIwIEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgorICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0CisgKgorICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKKyAqCisgKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlCisgKiBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0cmlidXRlZCBvbiBhbiAiQVMgSVMiIEJBU0lTLAorICogV0lUSE9VVCBXQVJSQU5USUVTIE9SIENPTkRJVElPTlMgT0YgQU5ZIEtJT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LmJlLmRhby5hcGkuQWN0aW9uU3RhdHVzOwpAQCAtMTMxLDcgKzEzMiw3IEBACiAgICAgcHJpdmF0ZSBFaXRoZXI8Q29tcG9uZW50LCBSZXNwb25zZUZvcm1hdD4gdmFsaWRhdGVVc2VyQW5kQ2FwYWJpbGl0aWVzKFVzZXIgdXNlciwgU3RyaW5nIGNvbXBvbmVudElkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmcgZXJyb3JDb250ZXh0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBMaXN0PENhcGFiaWxpdHlEZWZpbml0aW9uPiBjYXBhYmlsaXR5RGVmaW5pdGlvbnMgKSB7Ci0gICAgICAgIHZhbGlkYXRlVXNlckV4aXN0cyh1c2VyLmdldFVzZXJJZCgpLCBlcnJvckNvbnRleHQsIHRydWUpOworICAgICAgICB2YWxpZGF0ZVVzZXJFeGlzdHModXNlci5nZXRVc2VySWQoKSk7CiAgICAgICAgIEVpdGhlcjxDb21wb25lbnQsIFJlc3BvbnNlRm9ybWF0PiBjb21wb25lbnRFaXRoZXIgPSBnZXRDb21wb25lbnREZXRhaWxzKGNvbXBvbmVudElkKTsKICAgICAgICAgaWYgKGNvbXBvbmVudEVpdGhlci5pc1JpZ2h0KCkpIHsKICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQoY29tcG9uZW50RWl0aGVyLnJpZ2h0KCkudmFsdWUoKSk7CkBAIC0xOTQsNyArMTk1LDcgQEAKICAgICBwdWJsaWMgRWl0aGVyPExpc3Q8Q2FwYWJpbGl0eURlZmluaXRpb24+LCBSZXNwb25zZUZvcm1hdD4gdXBkYXRlQ2FwYWJpbGl0aWVzKFN0cmluZyBjb21wb25lbnRJZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIExpc3Q8Q2FwYWJpbGl0eURlZmluaXRpb24+IGNhcGFiaWxpdHlEZWZpbml0aW9ucywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFVzZXIgdXNlciwgU3RyaW5nIGVycm9yQ29udGV4dCwgYm9vbGVhbiBsb2NrKSB7Ci0gICAgICAgIHZhbGlkYXRlVXNlckV4aXN0cyh1c2VyLmdldFVzZXJJZCgpLCBlcnJvckNvbnRleHQsIHRydWUpOworICAgICAgICB2YWxpZGF0ZVVzZXJFeGlzdHModXNlci5nZXRVc2VySWQoKSk7CiAgICAgICAgIEVpdGhlcjxDb21wb25lbnQsIFJlc3BvbnNlRm9ybWF0PiBjb21wb25lbnRFaXRoZXIgPSBnZXRDb21wb25lbnREZXRhaWxzKGNvbXBvbmVudElkKTsKICAgICAgICAgaWYgKGNvbXBvbmVudEVpdGhlci5pc1JpZ2h0KCkpIHsKICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQoY29tcG9uZW50RWl0aGVyLnJpZ2h0KCkudmFsdWUoKSk7CkBAIC0zNzEsNyArMzcyLDcgQEAKIAogICAgIHB1YmxpYyBFaXRoZXI8Q2FwYWJpbGl0eURlZmluaXRpb24sIFJlc3BvbnNlRm9ybWF0PiBnZXRDYXBhYmlsaXR5KFN0cmluZyBjb21wb25lbnRJZCwgU3RyaW5nIGNhcGFiaWxpdHlUb0dldCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBVc2VyIHVzZXIsIGJvb2xlYW4gbG9jaykgewotICAgICAgICB2YWxpZGF0ZVVzZXJFeGlzdHModXNlci5nZXRVc2VySWQoKSwgR0VUX0NBUEFCSUxJVElFUywgdHJ1ZSk7CisgICAgICAgIHZhbGlkYXRlVXNlckV4aXN0cyh1c2VyLmdldFVzZXJJZCgpKTsKICAgICAgICAgRWl0aGVyPENvbXBvbmVudCwgUmVzcG9uc2VGb3JtYXQ+IGNvbXBvbmVudEVpdGhlciA9IGdldENvbXBvbmVudERldGFpbHMoY29tcG9uZW50SWQpOwogICAgICAgICBpZiAoY29tcG9uZW50RWl0aGVyLmlzUmlnaHQoKSkgewogICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChjb21wb25lbnRFaXRoZXIucmlnaHQoKS52YWx1ZSgpKTsKQEAgLTQyMyw3ICs0MjQsNyBAQAogCiAgICAgcHVibGljIEVpdGhlcjxDYXBhYmlsaXR5RGVmaW5pdGlvbiwgUmVzcG9uc2VGb3JtYXQ+IGRlbGV0ZUNhcGFiaWxpdHkoU3RyaW5nIGNvbXBvbmVudElkLCBTdHJpbmcgY2FwYWJpbGl0eUlkVG9EZWxldGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVXNlciB1c2VyLCBib29sZWFuIGxvY2spIHsKLSAgICAgICAgdmFsaWRhdGVVc2VyRXhpc3RzKHVzZXIuZ2V0VXNlcklkKCksIERFTEVURV9DQVBBQklMSVRJRVMsIHRydWUpOworICAgICAgICB2YWxpZGF0ZVVzZXJFeGlzdHModXNlci5nZXRVc2VySWQoKSk7CiAgICAgICAgIEVpdGhlcjxDb21wb25lbnQsIFJlc3BvbnNlRm9ybWF0PiBjb21wb25lbnRFaXRoZXIgPSBnZXRDb21wb25lbnREZXRhaWxzKGNvbXBvbmVudElkKTsKICAgICAgICAgaWYgKGNvbXBvbmVudEVpdGhlci5pc1JpZ2h0KCkpIHsKICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQoY29tcG9uZW50RWl0aGVyLnJpZ2h0KCkudmFsdWUoKSk7CkBAIC01NDYsMTIgKzU0NywxMiBAQAogCiAgICAgcHJpdmF0ZSBFaXRoZXI8Qm9vbG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ycm9yKCJGYWlsdXJlIGdldCBjYXNzYW5kcmEgbWV0YWRhdGEuIik7CkBAIC0xNTMsNyArMTU1LDggQEAKICAgICAgICAgfQogCiAgICAgfQotCisgICAgCisgCiAgICAgcHVibGljIGJvb2xlYW4gZ2V0Q2Fzc2FuZHJhU3RhdHVzKCkgIHsKIAogICAgICAgICBpZiAoR2VuZXJhbFV0aWxpdHkuaXNFbXB0eVN0cmluZyhsb2NhbERhdGFDZW50ZXJOYW1lKSkgewpAQCAtMTYxLDE3ICsxNjQsMTkgQEAKICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgfQogCi0gICAgICAgIENsdXN0ZXIgY2x1c3RlciA9IG51bGw7CisgICAgICAgCiAgICAgICAgIFNlc3Npb24gc2Vzc2lvbiA9IG51bGw7CiAgICAgICAgIHRyeSB7Ci0gICAgICAgICAgICBsb2cuaW5mbygiY3JlYXRpbmcgY2x1c3RlciBmb3IgQ2Fzc2FuZHJhIGZvciBtb25pdG9yaW5nLiIpOwotICAgICAgICAgICAgY2x1c3RlciA9IHNkY1NjaGVtYVV0aWxzLmNyZWF0ZUNsdXN0ZXIoKTsKLSAgICAgICAgICAgIGlmIChjbHVzdGVyID09IG51bGwpIHsKLSAgICAgICAgICAgICAgICBsb2cuZXJyb3IoIkZhaWx1cmUgY3JlYXRlIGNhc3NhbmRyYSBjbHVzdGVyLiIpOworICAgICAgICAgICAgbG9nLmluZm8oImNyZWF0aW5nIGNsdXN0ZXIgZm9yIENhc3NhbmRyYSBmb3IgbW9uaXRvcmluZy4iKTsgICAgICAgICAgIAorICAgICAgICAgICAgCisgICAgICAgICAgICBzZXNzaW9uID0gc2RjU2NoZW1hVXRpbHMuY29ubmVjdCgpOworICAgICAgICAgICAgbG9nLmluZm8oIlRoZSBjYXNzYW5kcmEgc2Vzc2lvbiBpcyB7fSIsIHNlc3Npb24pOworICAgICAgICAgICAgaWYoc2Vzc2lvbiA9PSBudWxsKXsKKyAgICAgICAgICAgICAgICBsb2cuZXJyb3IoIkZhaWxlZCB0byBjb25uZWN0IHRvIGNhc3NhbmRyYSAiKTsKICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICB9Ci0gICAgICAgICAgICBzZXNzaW9uID0gY2x1c3Rlci5jb25uZWN0KCk7Ci0gICAgICAgICAgICBNZXRhZGF0YSBtZXRhZGF0YSA9IGNsdXN0ZXIuZ2V0TWV0YWRhdGEoKTsKKyAgICAgICAgICAgIAorICAgICAgICAgICAgTWV0YWRhdGEgbWV0YWRhdGEgPSBzZGNTY2hlbWFVdGlscy5nZXRNZXRhZGF0YSgpOwogCiAgICAgICAgICAgICBpZiAobWV0YWRhdGEgPT0gbnVsbCkgewogICAgICAgICAgICAgICAgIGxvZy5lcnJvcigiRmFpbHVyZSBnZXQgY2Fzc2FuZHJhIG1ldGFkYXRhLiIpOwpAQCAtMTkyLDExICsxOTcsMTggQEAKICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgfSBmaW5hbGx5IHsKICAgICAgICAgICAgIGlmIChzZXNzaW9uICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICBsb2cuaW5mbygiY2xvc2Ugc2Vzc2lvbiBmb3IgQ2Fzc2FuZHJhIGZvciBtb25pdG9yaW5nLiIpOwogICAgICAgICAgICAgICAgIHNlc3Npb24uY2xvc2UoKTsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGlmIChjbHVzdGVyICE9IG51bGwpIHsKLSAgICAgICAgICAgICAgICBjbHVzdGVyLmNsb3NlKCk7Ci0gICAgICAgICAgICB9CisgICAgICAgICAgICAKICAgICAgICAgfQogICAgIH0KKyAgICAKKyAgICBAUHJlRGVzdHJveQorICAgIHB1YmxpYyB2b2lkIGNsb3NlQ2xpZW50KCkgeworICAgICAgICBpZiAoc2RjU2NoZW1hVXRpbHMhPSBudWxsKSB7CisgICAgICAgICAgICBzZGNTY2hlbWFVdGlscy5jbG9zZUNsdXN0ZXIoKTsKKyAg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3ViY2F0ZWdvcnkuZ2V0R3JvdXBpbmdzKCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZ3JvdXBpbmdzICE9IG51bGwpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBMaXN0PEdyb3VwaW5nRGVmaW5pdGlvbj4gbmV3Z3JvdXBpbmdzID0gbmV3IEFycmF5TGlzdDw+KCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChHcm91cGluZ0RlZmluaXRpb24gZ3JvdXBpbmcgOiBncm91cGluZ3MpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRWl0aGVyPEdyb3VwaW5nRGVmaW5pdGlvbiwgUmVzcG9uc2VGb3JtYXQ+IGNyZWF0ZWRHcm91cGluZyA9IGNyZWF0ZUdyb3VwaW5nRGVvKGVudHJ5LCBncm91cGluZywgc3ViY2F0ZWdvcnksIGNhdGVnb3J5LCBub2RlVHlwZUdyb3VwKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNyZWF0ZWRHcm91cGluZy5pc1JpZ2h0KCkpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQoY3JlYXRlZENhdGVnb3J5UmVzLnJpZ2h0KCkudmFsdWUoKSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3Z3JvdXBpbmdzLmFkZChjcmVhdGVkR3JvdXBpbmcubGVmdCgpLnZhbHVlKCkpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdzdWJjYXRlZ29yeS5zZXRHcm91cGluZ3MobmV3Z3JvdXBpbmdzKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgICAgIG5ld3N1YmNhdGVnb3JpZXM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AgICAgICAgICAgICAgICBpZiAoY3JlYXRlZEdyb3VwaW5nLmlzUmlnaHQoKSkgeworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIG5ld2dyb3VwaW5ncy5hZGQoY3JlYXRlZEdyb3VwaW5nLmxlZnQoKS52YWx1ZSgpKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgbmV3c3ViY2F0ZWdvcnkuc2V0R3JvdXBpbmdzKG5ld2dyb3VwaW5ncyk7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBuZXdzdWJjYXRlZ29yaWVzLmFkZChuZXdzdWJjYXRlZ29yeSk7CisgICAgICAgIH0KKyAgICAgICAgcmV0dXJuIHRydWU7CisgICAgfQorCiAgICAgcHJpdmF0ZSBFaXRoZXI8R3JvdXBpbmdEZWZpbml0aW9uLCBSZXNwb25zZUZvcm1hdD4gY3JlYXRlR3JvdXBpbmdEZW8oTWFwLkVudHJ5PFN0cmluZywgTGlzdDxDYXRlZ29yeURlZmluaXRpb24+PiBlbnRyeSwgR3JvdXBpbmdEZWZpbml0aW9uIGdyb3VwaW5nLCBTdWJDYXRlZ29yeURlZmluaXRpb24gc3ViY2F0ZWdvcnksIENhdGVnb3J5RGVmaW5pdGlvbiBjYXRlZ29yeSwgTm9kZVR5cGVFbnVtIG5vZGVUeXBlR3JvdXApIHsKIAogICAgICAgICBsb2cuZGVidWcoImNyZWF0ZUdyb3VwaW5nRGVvOiBjcmVhdGluZyBncm91cGluZyAge30iLCBncm91cGluZyk7CiAgICAgICAgIEVpdGhlcjxHcm91cGluZ0RlZmluaXRpb24sIEFjdGlvblN0YXR1cz4gY3JlYXRlZEdyb3VwaW5nID0gZWxlbWVudE9wZXJhdGlvbi5jcmVhdGVHcm91cGluZyhzdWJjYXRlZ29yeS5nZXRVbmlxdWVJZCgpLCBncm91cGluZywgbm9kZVR5cGVHcm91cCk7C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aWRhdG9yID0gY29tcG9uZW50VGFnc1ZhbGlkYXRvcjsKKyAgICAgICAgdGhpcy5jb21wb25lbnRWYWxpZGF0b3IgPSBjb21wb25lbnRWYWxpZGF0b3I7CisgICAgICAgIHRoaXMuY29tcG9uZW50SWNvblZhbGlkYXRvciA9IGNvbXBvbmVudEljb25WYWxpZGF0b3I7CisgICAgICAgIHRoaXMuY29tcG9uZW50UHJvamVjdENvZGVWYWxpZGF0b3IgPSBjb21wb25lbnRQcm9qZWN0Q29kZVZhbGlkYXRvcjsKKyAgICAgICAgdGhpcy5jb21wb25lbnREZXNjcmlwdGlvblZhbGlkYXRvciA9IGNvbXBvbmVudERlc2NyaXB0aW9uVmFsaWRhdG9yOwogICAgIH0KIAorICAgIHB1YmxpYyB2b2lkIHNldENvbXBvbmVudERlc2NyaXB0aW9uVmFsaWRhdG9yKENvbXBvbmVudERlc2NyaXB0aW9uVmFsaWRhdG9yIGNvbXBvbmVudERlc2NyaXB0aW9uVmFsaWRhdG9yKSB7CisgICAgICAgIHRoaXMuY29tcG9uZW50RGVzY3JpcHRpb25WYWxpZGF0b3IgPSBjb21wb25lbnREZXNjcmlwdGlvblZhbGlkYXRvcjsKKyAgICB9CisKKyAgICBwdWJsaWMgdm9pZCBzZXRDb21wb25lbnRQcm9qZWN0Q29kZVZhbGlkYXRvcihDb21wb25lbnRQcm9qZWN0Q29kZVZhbGlkYXRvciBjb21wb25lbnRQcm9qZWN0Q29kZVZhbGlkYXRvcikgeworICAgICAgICB0aGlzLmNvbXBvbmVudFByb2plY3RDb2RlVmFsaWRhdG9yID0gY29tcG9uZW50UHJvamVjdENvZGVWYWxpZGF0b3I7CisgICAgfQorCisgICAgcHVibGljIHZvaWQgc2V0Q29tcG9uZW50SWNvblZhbGlkYXRvcihDb21wb25lbnRJY29uVmFsaWRhdG9yIGNvbXBvbmVudEljb25WYWxpZGF0b3IpIHsKKyAgICAgICAgdGhpcy5jb21wb25lbnRJY29uVmFsaWRhdG9yID0gY29tcG9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ICAgICAgfQotICAgICAgICAgICAgICAgIGlmICh2YWxpZGF0ZVRhZ1BhdHRlcm4odGFnKSkgewotICAgICAgICAgICAgICAgICAgICBpZiAoIWluY2x1ZGVzQ29tcG9uZW50TmFtZSkgewotICAgICAgICAgICAgICAgICAgICAgICAgaW5jbHVkZXNDb21wb25lbnROYW1lID0gbmFtZS5lcXVhbHModGFnKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiaW52YWxpZCB0YWcge30iLCB0YWcpOwotICAgICAgICAgICAgICAgICAgICByZXNwb25zZUZvcm1hdCA9IGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuSU5WQUxJRF9GSUVMRF9GT1JNQVQsIGNvbXBvbmVudFR5cGUuZ2V0VmFsdWUoKSwgVEFHX0ZJRUxEX0xBQkVMKTsKLSAgICAgICAgICAgICAgICAgICAgY29tcG9uZW50c1V0aWxzLmF1ZGl0Q29tcG9uZW50QWRtaW4ocmVzcG9uc2VGb3JtYXQsIHVzZXIsIGNvbXBvbmVudCwgYWN0aW9uLCBjb21wb25lbnRUeXBlKTsKLSAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEJ5QWN0aW9uU3RhdHVzQ29tcG9uZW50RXhjZXB0aW9uKEFjdGlvblN0YXR1cy5JTlZBTElEX0ZJRUxEX0ZPUk1BVCwgY29tcG9uZW50VHlwZS5nZXRWYWx1ZSgpLCBUQUdfRklFTERfTEFCRUwpOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICB0YWdMaXN0U2l6ZSArPSB0YWcubGVuZ3RoKCkgKyAxOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgaWYgKHRhZ0xpc3RTaXplID4gMCkgewotICAgICAgICAgICAgICAgIHRhZ0xpc3RTaXplLS07Ci0gICAgICAgICAgICB9Ci0KLS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b2plY3RDb2RlKHByb2plY3RDb2RlKTsKLSAgICAgICAgaWYgKHZhbGlkYXRlUHJvamVjdENvZGVSZXNwb25zZS5pc1JpZ2h0KCkpIHsKLSAgICAgICAgICAgIFJlc3BvbnNlRm9ybWF0IHJlc3BvbnNlRm9ybWF0ID0gdmFsaWRhdGVQcm9qZWN0Q29kZVJlc3BvbnNlLnJpZ2h0KCkudmFsdWUoKTsKLSAgICAgICAgICAgIGNvbXBvbmVudHNVdGlscy5hdWRpdENvbXBvbmVudEFkbWluKHJlc3BvbnNlRm9ybWF0LCB1c2VyLCBjb21wb25lbnQsIGFjdGlvbkVudW0sIGNvbXBvbmVudC5nZXRDb21wb25lbnRUeXBlKCksCi0gICAgICAgICAgICAgICAgICAgIFJlc291cmNlVmVyc2lvbkluZm8ubmV3QnVpbGRlcigpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgLmJ1aWxkKCkpOwotICAgICAgICB9Ci0gICAgICAgIHJldHVybiB2YWxpZGF0ZVByb2plY3RDb2RlUmVzcG9uc2U7Ci0KLSAgICB9Ci0KLSAgICBwcml2YXRlIEVpdGhlcjxCb29sZWFuLCBSZXNwb25zZUZvcm1hdD4gdmFsaWRhdGVQcm9qZWN0Q29kZShTdHJpbmcgcHJvamVjdENvZGUpIHsKLSAgICAgICAgaWYgKHByb2plY3RDb2RlICE9IG51bGwpIHsKLSAgICAgICAgICAgIGlmICghVmFsaWRhdGlvblV0aWxzLnZhbGlkYXRlUHJvamVjdENvZGUocHJvamVjdENvZGUpKSB7Ci0gICAgICAgICAgICAgICAgbG9nLmluZm8oInByb2plY3RDb2RlICBpcyBub3QgdmFsaWQuIik7Ci0gICAgICAgICAgICAgICAgUmVzcG9uc2VGb3JtYXQgZXJyb3JSZXNwb25zZSA9IGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuSU5WQUxJRF9QUk9KRUNUX0NPREUpOwotICAgICAgICAgICAgICAgIHJldHVybiB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bnRzQW5kQ2FwYWJpbGl0aWVzIiwgY29tcG9uZW50VHlwZUVudW0uZ2V0VmFsdWUoKSwgY29tcG9uZW50SWQpOwotICAgICAgICAgICAgZWl0aGVyUmV0ID0gRWl0aGVyLnJpZ2h0KGVpdGhlckNvbXBvbmVudC5yaWdodCgpLnZhbHVlKCkpOworICAgICAgICAgICAgdGhyb3dDb21wb25lbnRFeGNlcHRpb24oZS5nZXRSZXNwb25zZUZvcm1hdCgpKTsKICAgICAgICAgfQotICAgICAgICByZXR1cm4gZWl0aGVyUmV0OworICAgICAgICByZXR1cm4gbnVsbDsKICAgICB9CiAKICAgICBwdWJsaWMgRWl0aGVyPExpc3Q8Q29tcG9uZW50PiwgUmVzcG9uc2VGb3JtYXQ+IGdldExhdGVzdFZlcnNpb25Ob3RBYnN0cmFjdENvbXBvbmVudHMoYm9vbGVhbiBpc0Fic3RyYWN0QWJzdHJhY3QsIENvbXBvbmVudFR5cGVFbnVtIGNvbXBvbmVudFR5cGVFbnVtLCBTdHJpbmcgaW50ZXJuYWxDb21wb25lbnRUeXBlLCBMaXN0PFN0cmluZz4gY29tcG9uZW50VWlkcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nIHVzZXJJZCkgewogICAgICAgICB0cnl7Ci0gICAgICAgICAgICB2YWxpZGF0ZVVzZXJFeGlzdHModXNlcklkLCAiZ2V0IExhdGVzdCBWZXJzaW9uIE5vdCBBYnN0cmFjdCBDb21wb25lbnRzIiwgZmFsc2UpOworICAgICAgICAgICAgdmFsaWRhdGVVc2VyRXhpc3RzKHVzZXJJZCk7CiAgICAgICAgICAgICBMaXN0PENvbXBvbmVudD4gcmVzdWx0ID0gbmV3IEFycmF5TGlzdDw+KCk7CiAgICAgICAgICAgICBMaXN0PFN0cmluZz4gY29tcG9uZW50c1VpZFRvRmV0Y2ggPSBuZXcgQXJyYXlM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pOwogICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQoZXJyb3JSZXNwb25zKTsKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIGN1cnJlbnRDb21wb25lbnQuc2V0UHJvamVjdENvZGUodXBkYXRlZENvbXBvbmVudC5nZXRQcm9qZWN0Q29kZSgpKTsKQEAgLTc2OSw3ICs1NTgsNyBAQAogICAgICAgICBTdHJpbmcgaWNvbkN1cnJlbnQgPSBjdXJyZW50Q29tcG9uZW50LmdldEljb24oKTsKICAgICAgICAgaWYgKGljb25VcGRhdGVkICE9IG51bGwgJiYgIWljb25DdXJyZW50LmVxdWFscyhpY29uVXBkYXRlZCkpIHsKICAgICAgICAgICAgIGlmICghaGFzQmVlbkNlcnRpZmllZCkgewotICAgICAgICAgICAgICAgIHZhbGlkYXRlSWNvbih1c2VyLCB1cGRhdGVkQ29tcG9uZW50LCBudWxsKTsKKyAgICAgICAgICAgICAgICBjb21wb25lbnRJY29uVmFsaWRhdG9yLnZhbGlkYXRlQW5kQ29ycmVjdEZpZWxkKHVzZXIsIHVwZGF0ZWRDb21wb25lbnQsIG51bGwpOwogICAgICAgICAgICAgICAgIGN1cnJlbnRDb21wb25lbnQuc2V0SWNvbih1cGRhdGVkQ29tcG9uZW50LmdldEljb24oKSk7CiAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgIGxvZy5pbmZvKCJpY29uIHt9IGNhbm5vdCBiZSB1cGRhdGVkIG9uY2UgdGhlIGNvbXBvbmVudCBoYXMgYmVlbiBjZXJ0aWZpZWQgb25jZS4iLCBpY29uVXBkYXRlZCk7CkBAIC04MDAsNyArNTg5LDcgQEAKICAgICAgICAgTGlzdDxBcnRpZmFjdERlZmluaXRpb24+IGFydGlmYWN0cyA9IG5ldyBBcnJheUxpc3Q8PigpOwogICAgICAgICBFaXRoZXI8TWFwPFN0cmluZywgQXJ0aWZhY3REZWZpbml0aW9uPiwgU3RvcmFnZU9wZXJhdGlvblN0YXR1c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IAogICAgICAgICBVaUNvbXBvbmVudERhdGFUcmFuc2ZlciByZXN1bHQgPSAgbmV3IFVpQ29tcG9uZW50RGF0YVRyYW5zZmVyKCk7CkBAIC04ODUsNyArNjc0LDcgQEAKICAgICAgICAgICAgICAgICByZXNwb25zZSA9IEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLklOVkFMSURfQ09OVEVOVCkpOwogICAgICAgICAgICAgfQogICAgICAgICAgICAgaWYgKHVzZXJJZCAhPSBudWxsICYmIHJlc3BvbnNlID09IG51bGwpIHsKLSAgICAgICAgICAgICAgICB2YWxpZGF0ZVVzZXJFeGlzdHModXNlcklkLCAiR2V0IGZpbHRlcmVkIGNvbXBvbmVudCBpbnN0YW5jZSBwcm9wZXJ0aWVzIiwgZmFsc2UpOworICAgICAgICAgICAgICAgIHZhbGlkYXRlVXNlckV4aXN0cyh1c2VySWQpOwogICAgICAgICAgICAgfQogICAgICAgICAgICAgaWYocmVzcG9uc2UgPT0gbnVsbCl7CiAgICAgICAgICAgICAgICAgZ2V0UmVzb3VyY2VSZXMgPSB0b3NjYU9wZXJhdGlvbkZhY2FkZS5nZXRUb3NjYUVsZW1lbnQoY29tcG9uZW50SWQpOwpAQCAtOTIwLDE4ICs3MDksMTIgQEAKICAgICAgICAgICAgIGZvcihDb21wb25lbnRJbnN0YW5jZSBpbnN0YW5jZSA6IGZpbHRlcmVkSW5zdGFuY2VzKXsKICAgICAgICAgICAgICAgICBpZihjb21wb25lbnQuZ2V0Q29tcG9uZW50SW5zdGFuY2VzUHJvcGVydGllcygpIT1udWxsICYmY29tcG9uZW50LmdldENvbXBvbmVudEluc3RhbmNlc1Byb3BlcnRpZXMoKS5jb250YWluc0tleShpbnN0YW5jZS5nZXRVbmlxdWVJZCgpKSl7CiAgICAgICAgICAgICAgICAgICAgIExpc3Q8SUNvbXBvbmVudEluc3RhbmNlQ29ubmVjdGVkRWxlbWVudD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AgICAgICAgICAgICAgICAgIGlmKENvbGxlY3Rpb25VdGlscy5pc05vdEVtcHR5KGN1cnJJbnB1dHMpKXsKLSAgICAgICAgICAgICAgICAgICAgICAgIGlmKGZpbHRlcmVkUHJvcGVydGllcy5nZXQoaW5zdGFuY2UuZ2V0VW5pcXVlSWQoKSkhPW51bGwpewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlcmVkUHJvcGVydGllcy5nZXQoaW5zdGFuY2UuZ2V0VW5pcXVlSWQoKSkuYWRkQWxsKGN1cnJJbnB1dHMpOwotICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWx0ZXJlZFByb3BlcnRpZXMucHV0KGluc3RhbmNlLmdldFVuaXF1ZUlkKCksIGN1cnJJbnB1dHMpOwotICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgY2hlY2tGaWx0ZXJlZFByb3BlcnRpZXMoZmlsdGVyZWRQcm9wZXJ0aWVzLCBpbnN0YW5jZSwgY3VycklucHV0cyk7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CkBAIC05MzksNiArNzIyLDIwIEBACiAgICAgICAgIHJldHVybiByZXN1bHQ7CiAgICAgfQogCisgICAgcHJpdmF0ZSB2b2lkIHNldEZpbHRlcmVkUHJvcGVydGllcyhNYXA8U3RyaW5nLCBMaXN0PElDb21wb25lbnRJbnN0YW5jZUNvbm5lY3RlZEVsZW1lbnQ+PiBmaWx0ZXJlZFByb3BlcnRpZXMsIENvbXBvbmVudEluc3RhbmNlIGluc3RhbmNlLCBMaXN0PElDb21wb25lbnRJbnN0YW5jZUNvbm5lY3RlZEVsZW1lbnQ+IGN1cnJQcm9wZXJ0aWVzKSB7CisgICAgICAgIGlmKENvbGxlY3Rpb25VdGlscy5pc05vdEVtcHR5KGN1cnJQcm9wZXJ0aWVzKSl7Cis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nR5QnlSZWN1cnNpdmVseShwcm9wLCBwcm9wZXJ0eU5hbWVGcmFnbWVudCwgc2VhcmNoQnlGcmFnbWVudCkpewotICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKLSAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICBpZiAoaXNNYXRjaGluZ0NvbXBsZXhQcm9wZXJ0eShwcm9wZXJ0eU5hbWVGcmFnbWVudCwgc2VhcmNoQnlGcmFnbWVudCwgZGF0YVR5cGVQcm9wZXJ0aWVzKSl7CisgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICAgICAgcmV0dXJuIGZhbHNlOworICAgIH0KKworICAgIHByaXZhdGUgYm9vbGVhbiBpc01hdGNoaW5nQ29tcGxleFByb3BlcnR5KFN0cmluZyBwcm9wZXJ0eU5hbWVGcmFnbWVudCwgYm9vbGVhbiBzZWFyY2hCeUZyYWdtZW50LCBMaXN0PFByb3BlcnR5RGVmaW5pdGlvbj4gZGF0YVR5cGVQcm9wZXJ0aWVzKSB7CisgICAgICAgIGZvcihQcm9wZXJ0eURlZmluaXRpb24gcHJvcCA6IGRhdGFUeXBlUHJvcGVydGllcyl7CisgICAgICAgICAgICBpZihpc01hdGNoaW5nQ29tcGxleFByb3BlcnR5QnlSZWN1cnNpdmVseShwcm9wLCBwcm9wZXJ0eU5hbWVGcmFnbWVudCwgc2VhcmNoQnlGcmFnbWVudCkpeworICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgfQogICAgICAgICB9CiAgICAgICAgIHJldHVybiBmYWxzZTsKQEAgLTExMjAsMjIgKzkyMiwzNCBAQAogICAgICAgICByZXR1cm4gaXNNYXRjaGluZ1R5cGU7CiAgICAgfQogCi0gICAgU3RyaW5nIGNsZWFuVXBUZXh0KFN0cmluZyB0ZXh0KXsKLSAgICAgICAgdGV4dCA9IFZhbGlkYXRpb25VdGlscy5yZW1vdmVOb25lVXR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JvcExpc3QuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBmb3IoQ29tcG9uZW50SW5zdGFuY2VQcm9wZXJ0eSBwcm9wOiBjaVByb3BMaXN0KXsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBMaXN0PEdldElucHV0VmFsdWVEYXRhRGVmaW5pdGlvbj4gaW5wdXRzVmFsdWVzID0gcHJvcC5nZXRHZXRJbnB1dFZhbHVlcygpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmKGlucHV0c1ZhbHVlcyAhPSBudWxsICYmICFpbnB1dHNWYWx1ZXMuaXNFbXB0eSgpKXsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yKEdldElucHV0VmFsdWVEYXRhRGVmaW5pdGlvbiBpbnB1dERhdGE6IGlucHV0c1ZhbHVlcyl7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZihpc0dldElucHV0VmFsdWVGb3JJbnB1dChpbnB1dERhdGEsIGlucHV0SWQpKXsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm9wLnNldENvbXBvbmVudEluc3RhbmNlSWQocyk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvcC5zZXRDb21wb25lbnRJbnN0YW5jZU5hbWUoY2lOYW1lKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNMaXN0LmFkZChwcm9wKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KLQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFkZENvbXBJbnN0YW5jZVByb3BlcnR5KHMsIGNpTmFtZSwgcHJvcCwgaW5wdXRzVmFsdWVzLCBpbnB1dElkLCByZXNMaXN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0pOwogICAgICAgICB9CiAgICAgICAgIHJldHVybiByZXNMaXN0OworCisgICAgfQorCisgICAgcHJpdmF0ZSB2b2lkIGFkZENvbXBJbnN0YW5jZVByb3BlcnR5KFN0cmluZyBzLCBTdHJpbmcgY2lOYW1lLCBDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5IHByb3AsIExpc3Q8R2V0SW5wdXRWYWx1ZURhdGFEZWZpbml0aW9uPiBpbnB1dHNWYWx1ZXMsIFN0cmluZyBpbnB1dElkLCBMaXN0PENvbXBvbmVudEluc3RhbmNlUHJvcGVydHk+IHJlc0xpc3QpIHsKKyAgICAgICAgaWYoaW5wdXRzVmFsdWVzICE9IG51bGwgJiYgIWlucHV0c1ZhbHVlcy5pc0VtcHR5KCkpeworICAgICAgICAgICAgZm9yKEdldElucHV0VmFsdWVEYXRhRGVmaW5pdGlvbiBpbnB1dERhdGE6IGlucHV0c1ZhbHVlcyl7CisgICAgICAgICAgICAgICAgaWYoaXNHZXRJbnB1dFZhbHVlRm9ySW5wdXQoaW5wdXREYXRhLCBpbnB1dElkKSl7CisgICAgICAgICAgICAgICAgICAgIHByb3Auc2V0Q29tcG9uZW50SW5zdGFuY2VJZChzKTsKKyAgICAgICAgICAgICAgICAgICAgcHJvcC5zZXRDb21wb25lbnRJbnN0YW5jZU5hbWUoY2lOYW1lKTsKKyAgICAgICAgICAgICAgICAgICAgcmVzTGlzdC5hZGQocHJvcCk7CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0KKyAgICAgICAgfQogICAgIH0KIAogICAgIHB1YmxpYyBPcHRpb25hbDxDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5PiBnZXRDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5QnlQb2xpY3lJZChDb21wb25lbnQgY29tcG9uZW50LApAQCAtMjg2LDE2ICsyOTgsNyBAQAogICAgICAgICAgICAgICAgICAgICBpZiAoY2lQcm9wTGlzdCAhPSBudWxsICYmICFjaVByb3BMaXN0LmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgZm9yKENvbXBvbmVudEluc3RhbmNlSW5wdXQgcHJvcDogY2lQcm9wTGlzdCl7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTGlzdDxHZXRJbnB1dFZhbHVlRGF0YURlZmluaXRpb24+IGlucHV0c1ZhbHVlcyA9IHByb3AuZ2V0R2V0SW5wdXRWYWx1ZXMoKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZihpbnB1dHNWYWx1ZXMgIT0gbnVsbCAmJiAhaW5wdXRzVmFsdWVzLmlzRW1wdHkoKSl7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcihHZXRJbnB1dFZhbHVlRGF0YURlZmluaXRpb24gaW5wdXREYXRhOiBpbnB1dHNWYWx1ZXMpewotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYoaXNHZXRJbnB1dFZhbHVlRm9ySW5wdXQoaW5wdXREYXRhLCBpbnB1dElkKSl7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvcC5zZXRDb21wb25lbnRJbnN0YW5jZUlkKHMpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb3Auc2V0Q29tcG9uZW50SW5zdGFuY2VOYW1lKGNpTmFtZSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzTGlzdC5hZGQocHJvcCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWRkQ29tcEluc3RhbmNlSW5wdXQocywgY2lOYW1lLCBwcm9wLCBpbnB1dHNWYWx1ZXMsIGlucHV0SWQsIHJlc0xpc3QpOwogCiAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIH0KQEAgLTMwMyw5MiArMzA2LDE5MiBAQAogICAgICAgICAgICAgfSk7CiAgICAgICAgIH0KICAgICAgICAgcmV0dXJuIHJlc0xpc3Q7CisKICAgICB9CiAKLSAgICBwdWJsaWMgRWl0aGVyPENvbXBvbmVudEluc3RhbmNlLCBSZXNwb25zZUZvcm1hdD4gY3JlYXRlQ29tcG9uZW50SW5zdGFuY2UoCi0gICAgICAgICAgICBTdHJpbmcgY29udGFpbmVyQ29tcG9uZW50UGFyYW0sIFN0cmluZyBjb250YWluZXJDb21wb25lbnRJZCwgU3RyaW5nIHVzZXJJZCwgQ29tcG9uZW50SW5zdGFuY2UgcmVzb3VyY2VJbnN0YW5jZSwgYm9vbGVhbiBpblRyYW5zYWN0aW9uLCBib29sZWFuIG5lZWRMb2NrKSB7CisgICAgcHJpdmF0ZSB2b2lkIGFkZENvbXBJbnN0YW5jZUlucHV0KFN0cmluZyBzLCBTdHJpbmcgY2lOYW1lLCBDb21wb25lbnRJbnN0YW5jZUlucHV0IHByb3AsIExpc3Q8R2V0SW5wdXRWYWx1ZURhdGFEZWZpbml0aW9uPiBpbnB1dHNWYWx1ZXMsIFN0cmluZyBpbnB1dElkLCBMaXN0PENvbXBvbmVudEluc3RhbmNlSW5wdXQ+IHJlc0xpc3QpIHsKKyAgICAgICAgaWYoaW5wdXRzVmFsdWVzICE9IG51bGwgJiYgIWlucHV0c1ZhbHVlcy5pc0VtcHR5KCkpeworICAgICAgICAgICAgZm9yKEdldElucHV0VmFsdWVEYXRhRGVmaW5pdGlvbiBpbnB1dERhdGE6IGlucHV0c1ZhbHVlcyl7CisgICAgICAgICAgICAgICAgaWYoaXNHZXRJbnB1dFZhbHVlRm9ySW5wdXQoaW5wdXREYXRhLCBpbnB1dElkKSl7CisgICAgICAgICAgICAgICAgICAgIHByb3Auc2V0Q29tcG9uZW50SW5zdGFuY2VJZChzKTsKKyAgICAgICAgICAgICAgICAgICAgcHJvcC5zZXRDb21wb25lbnRJbnN0YW5jZU5hbWUoY2lOYW1lKTsKKyAgICAgICAgICAgICAgICAgICAgcmVzTGlzdC5hZGQocHJvcCk7CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgIH0KKworICAgIHB1YmxpYyBDb21wb25lbnRJbnN0YW5jZSBjcmVhdGVDb21wb25lbnRJbnN0YW5jZShTdHJpbmcgY29udGFpbmVyQ29tcG9uZW50UGFyYW0sIFN0cmluZyBjb250YWluZXJDb21wb25lbnRJZCwgU3RyaW5nIHVzZXJJZCwgQ29tcG9uZW50SW5zdGFuY2UgcmVzb3VyY2VJbnN0YW5jZSwgYm9vbGVhbiBpblRyYW5zYWN0aW9uLCBib29sZWFuIG5lZWRMb2NrKSB7CiAKICAgICAgICAgQ29tcG9uZW50IG9yaWdDb21wb25lbnQgPSBudWxsOwotICAgICAgICBFaXRoZXI8Q29tcG9uZW50SW5zdGFuY2UsIFJlc3BvbnNlRm9ybWF0PiByZXN1bHRPcCA9IG51bGw7Ci0gICAgICAgIFVzZXIgdXNlciA9IG51bGw7CisgICAgICAgIFVzZXIgdXNlcjsKICAgICAgICAgb3JnLm9wZW5lY29tcC5zZGMuYmUubW9kZWwuQ29tcG9uZW50IGNvbnRhaW5lckNvbXBvbmVudCA9IG51bGw7CiAgICAgICAgIENvbXBvbmVudFR5cGVFbnVtIGNvbnRhaW5lckNvbXBvbmVudFR5cGU7Ci0KICAgICAgICAgdHJ5IHsKLSAgICAgICAgICAgIHVzZXIgP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N0cyhjb250YWluZXJDb21wb25lbnRJZCwgY29udGFpbmVyQ29tcG9uZW50VHlwZSwgbnVsbCk7Ci0gICAgICAgICAgICBpZiAodmFsaWRhdGVDb21wb25lbnRFeGlzdHMuaXNSaWdodCgpKSB7Ci0gICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodCh2YWxpZGF0ZUNvbXBvbmVudEV4aXN0cy5yaWdodCgpLnZhbHVlKCkpOwotICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICBjb250YWluZXJDb21wb25lbnQgPSB2YWxpZGF0ZUNvbXBvbmVudEV4aXN0cy5sZWZ0KCkudmFsdWUoKTsKLSAgICAgICAgICAgIH0KKyAgICAgICAgICAgIHVzZXIgPSB2YWxpZGF0ZVVzZXJFeGlzdHModXNlcklkKTsKKyAgICAgICAgICAgIHZhbGlkYXRlVXNlck5vdEVtcHR5KHVzZXIsICJDcmVhdGUgY29tcG9uZW50IGluc3RhbmNlIik7CisgICAgICAgICAgICB2YWxpZGF0ZUpzb25Cb2R5KHJlc291cmNlSW5zdGFuY2UsIENvbXBvbmVudEluc3RhbmNlLmNsYXNzKTsKKyAgICAgICAgICAgIGNvbnRhaW5lckNvbXBvbmVudFR5cGUgPSB2YWxpZGF0ZUNvbXBvbmVudFR5cGUoY29udGFpbmVyQ29tcG9uZW50UGFyYW0pOworICAgICAgICAgICAgY29udGFpbmVyQ29tcG9uZW50ID0gdmFsaWRhdGVDb21wb25lbnRFeGlzdHMoY29udGFpbmVyQ29tcG9uZW50SWQsIGNvbnRhaW5lckNvbXBvbmVudFR5cGUsIG51bGwpOwogCiAgICAgICAgICAgICBpZiAoTW9kZWxDb252ZXJ0ZXIuaXNBdG9taWNDb21wb25lbnQoY29udGFpbmVyQ29tcG9uZW50KSkgewogICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiQ2Fubm90IGF0dGFjaCByZXNvdXJjZSBpbnN0YW5jZXMgdG8gY29udGFpbmVyIHJlc291cmNlIG9mIHR5cGUge30iLCBjb250YWluZXJDb21wb25lbnQuYXNzZXRUeXBlKCkpOwotICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQoY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5SRVNPVVJDRV9DQU5OT1RfQ09OVEFJTl9SRVNPVVJDRV9JTlNUQU5DRVMsIGNvbnRhaW5lckNvbXBvbmVudC5hc3NldFR5cGUoKSkpOworICAgICAgICAgICAgICAgIHRocm93IG5ldyBCeUFjdGlvblN0YXR1c0NvbXBvbmVudEV4Y2VwdGlvbihBY3Rpb25TdGF0dXMuUkVTT1VSQ0VfQ0FOTk9UX0NPTlRBSU5fUkVTT1VSQ0VfSU5TVEFOQ0VTLCBjb250YWluZXJDb21wb25lbnQuYXNzZXRUeXBlKCkpOwogICAgICAgICAgICAgfQogCi0gICAgICAgICAgICBFaXRoZXI8Qm9vbGVhbiwgUmVzcG9uc2VGb3JtYXQ+IHZhbGlkYXRlQ2FuV29ya09uQ29tcG9uZW50ID0gdmFsaWRhdGVDYW5Xb3JrT25Db21wb25lbnQoY29udGFpbmVyQ29tcG9uZW50LCB1c2VySWQpOwotICAgICAgICAgICAgaWYgKHZhbGlkYXRlQ2FuV29ya09uQ29tcG9uZW50LmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQodmFsaWRhdGVDYW5Xb3JrT25Db21wb25lbnQucmlnaHQoKS52YWx1ZSgpKTsKLSAgICAgICAgICAgIH0KKyAgICAgICAgICAgIHZhbGlkYXRlQ2FuV29ya09uQ29tcG9uZW50KGNvbnRhaW5lckNvbXBvbmVudCwgdXNlcklkKTsKIAogICAgICAgICAgICAgaWYgKHJlc291cmNlSW5zdGFuY2UgIT0gbnVsbCAmJiBjb250YWluZXJDb21wb25lbnRUeXBlICE9IG51bGwpIHsKICAgICAgICAgICAgICAgICBPcmlnaW5UeXBlRW51bSBvcml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9yYWdlUmVzcG9uc2Uoc2VydmljZVByb3h5T3JpZ2luLnJpZ2h0KCkudmFsdWUoKSkpOwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIG9yaWdDb21wb25lbnQgPSBzZXJ2aWNlUHJveHlPcmlnaW4ubGVmdCgpLnZhbHVlKCk7CiAKICAgICAgICAgICAgICAgICAgICAgU3RvcmFnZU9wZXJhdGlvblN0YXR1cyBmaWxsUHJveHlSZXMgPSBmaWxsUHJveHlJbnN0YW5jZURhdGEocmVzb3VyY2VJbnN0YW5jZSwgb3JpZ0NvbXBvbmVudCk7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChmaWxsUHJveHlSZXMgIT0gU3RvcmFnZU9wZXJhdGlvblN0YXR1cy5PSykgewotICAgICAgICAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJGYWlsZWQgdG8gZmlsbCBzZXJ2aWNlIHByb3h5IHJlc291cmNlIGRhdGEgd2l0aCBkYXRhIGZyb20gc2VydmljZSwgZXJyb3Ige30iLCBmaWxsUHJveHlSZXMpOwotICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoY29tcG9uZW50c1V0aWxzLmNvbnZlcnRGcm9tU3RvcmFnZVJlc3BvbnNlKGZpbGxQcm94eVJlcykpKTsKLQotICAgICAgICAgICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgICAgICBFaXRoZXI8Q29tcG9uZW50LCBSZXNwb25zZUZvcm1hdD4gZ2V0T3JpZ2luQ29tcG9uZW50UmVzID0gZ2V0QW5kVmFsaWRhdGVPcmlnaW5Db21wb25lbnRPZkNvbXBvbmVudEluc3RhbmNlKGNvbnRhaW5lckNvbXBvbmVudFR5cGUsIHJlc291cmNlSW5zdGFuY2UpOwotCi0gICAgICAgICAgICAgICAgICAgIGlmIChnZXRPcmlnaW5Db21wb25lbnRSZXMuaXNSaWdodCgpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gRWl0aGVyLnJpZ2h0KGdldE9yaWdpbkNvbXBvbmVudFJlcy5yaWdodCgpLnZhbHVlKCkpOwotICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgICAgICAgICAgb3JpZ0NvbXBvbmVudCA9IGdldE9yaWdpbkNvbXBvbmVudFJlcy5sZWZ0KCkudmFsdWUoKTsKKyAgICAgICAgICAgICAgICAgICAgaWYgKGlzRmlsbFByb3h5UmVzKGZpbGxQcm94eVJlcykpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBCeUFjdGlvblN0YXR1c0NvbXBvbmVudEV4Y2VwdGlvbihjb21wb25lbnRzVXRpbHMuY29udmVydEZyb21TdG9yYWdlUmVzcG9uc2UoZmlsbFByb3h5UmVzKSk7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgZWxzZSB7CisgICAgICAgICAgICAgICAgICAgIG9yaWdDb21wb25lbnQgPSBnZXRBbmRWYWxpZGF0ZU9yaWdpbkNvbXBvbmVudE9mQ29tcG9uZW50SW5zdGFuY2UoY29udGFpbmVyQ29tcG9uZW50LCByZXNvdXJjZUluc3RhbmNlKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgdmFsaWRhdGVPcmlnaW5BbmRSZXNvdXJjZUluc3RhbmNlVHlwZXMoY29udGFpbmVyQ29tcG9uZW50LCBvcmlnQ29tcG9uZW50LCBvcmlnaW5UeXBlKTsKKyAgICAgICAgICAgICAgICB2YWxpZGF0ZVJlc291cmNlSW5zdGFuY2VTdGF0ZShjb250YWluZXJDb21wb25lbnQsIG9yaWdDb21wb25lbnQpOworICAgICAgICAgICAgICAgIG92ZXJyaWRlRmllbGRzKG9yaWdDb21wb25lbnQsIHJlc291cmNlSW5zdGFuY2UpOworICAgICAgICAgICAgICAgIGNvbXBvc2l0aW9uQnVzaW5lc3NMb2dpYy52YWxpZGF0ZUFuZFNldERlZmF1bHRDb29yZGluYXRlcyhyZXNvdXJjZUluc3RhbmNlKTsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGlmIChuZWVkTG9jaykgewotICAgICAgICAgICAgICAgIEVpdGhlcjxCb29sZWFuLCBSZXNwb25zZUZvcm1hdD4gbG9ja0NvbXBvbmVudCA9IGxvY2tDb21wb25lbnQoY29udGFpbmVyQ29tcG9uZW50LCAiY3JlYXRlQ29tcG9uZW50SW5zdGFuY2UiKTsKLSAgICAgICAgICAgICAgICBpZiAobG9ja0NvbXBvbmVudC5pc1JpZ2h0KCkpIHsKLSAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChsb2NrQ29tcG9uZW50LnJpZ2h0KCkudmFsdWUoKSk7Ci0gICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgcmV0dXJuIGNyZWF0ZUNvbXBvbmVudChuZWVkTG9jaywgY29udGFpbmVyQ29tcG9uZW50LG9yaWdDb21wb25lbnQsIHJlc291cmNlSW5zdGFuY2UsIHVzZXIpOworCisgICAgICAgIH1jYXRjaCAoQ29tcG9uZW50RXhjZXB0aW9uIGUpeworICAgICAgICAgICAgdGhyb3cgZTsKKyAgICAgICAgfQorICAgIH0KKworICAgIHByaXZhdGUgQ29tcG9uZW50SW5zdGFuY2UgY3JlYXRlQ29tcG9uZW50KGJvb2xlYW4gbmVlZExvY2ssIENvbXBvbmVudCBjb250YWluZXJDb21wb25lbnQsIENvbXBvbmVudCBvcmlnQ29tcG9uZW50LCBDb21wb25lbnRJbnN0YW5jZSByZXNvdXJjZUluc3RhbmNlLCBVc2VyIHVzZXIpIHsKKworICAgICAgICBib29sZWFuIGZhaWxlZCA9IGZhbHNlOworICAgICAgICB0cnkgeworCisgICAgICAgICAgICBDb21wb25lbnRJbnN0YW5jZSBsb2NrQ29tcG9uZW50ID0gaXNOZWVkTG9jayhuZWVkTG9jaywgY29udGFpbmVyQ29tcG9uZW50KTsKKyAgICAgICAgICAgIGlmIChsb2NrQ29tcG9uZW50ICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICByZXR1cm4gbG9ja0NvbXBvbmVudDsKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIGxvZy5kZWJ1ZyhUUllfVE9fQ1JFQVRFX0VOVFJZX09OX0dSQVBIKTsKLSAgICAgICAgICAgIHJlc3VsdE9wID0gY3JlYXRlQ29tcG9uZW50SW5zdGFuY2VPbkdyYXBoKGNvbnRhaW5lckNvbXBvbmVudCwgb3JpZ0NvbXBvbmVudCwgcmVzb3VyY2VJbnN0YW5jZSwgdXNlcik7Ci0gICAgICAgICAgICByZXR1cm4gcmVzdWx0T3A7Ci0KLSAgICAgICAgfSBmaW5hbGx5IHsKKyAgICAgICAgICAgIHJldHVybiBjcmVhdGVDb21wb25lbnRJbnN0YW5jZU9uR3JhcGgoY29udGFpbmVyQ29tcG9uZW50LCBvcmlnQ29tcG9uZW50LCByZXNvdXJjZUluc3RhbmNlLCB1c2VyKTsKKyAgICAgICAgfWNhdGNoIChDb21wb25lbnRFeGNlcHRpb24gZSl7CisgICAgICAgICAgICBmYWlsZWQgPSB0cnVlOworICAgICAgICAgICAgdGhyb3cgZTsKKyAgICAgICAgfWZpbmFsbHkgewogICAgICAgICAgICAgaWYgKG5lZWRMb2NrKQotICAgICAgICAgICAgICAgIHVubG9ja0NvbXBvbmVudChyZXN1bHRPcCwgY29udGFpbmVyQ29tcG9uZW50KTsKKyAgICAgICAgICAgICAgICB1bmxvY2tDb21wb25lbnQoZmFpbGVkLCBjb250YWluZXJDb21wb25lbnQpOwogICAgICAgICB9CiAgICAgfQogCisgICAgcHJpdmF0ZSB2b2lkIG92ZXJyaWRlRmllbGRzKENvbXBvbmVudCBvcmlnQ29tcG9uZW50LCBDb21wb25lbnRJbnN0YW5jZSByZXNvdXJjZUluc3RhbmNlKSB7C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TlRBSU5FUl9DQU5OT1RfQ09OVEFJTl9JTlNUQU5DRSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXJDb21wb25lbnQuZ2V0Q29tcG9uZW50VHlwZSgpLnRvU3RyaW5nKCksIHJlc291cmNlVHlwZS5uYW1lKCkpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgUkVTT1VSQ0U6CisgICAgICAgICAgICAgICAgaWYgKCFjb250YWluZXJJbnN0YW5jZVR5cGVzRGF0YS5nZXRWYWxpZEluc3RhbmNlVHlwZXNJblJlc291cmNlQ29udGFpbmVyKCkuZ2V0KCgoUmVzb3VyY2UpIGNvbnRhaW5lckNvbXBvbmVudCkuZ2V0UmVzb3VyY2VUeXBlKCkpLmNvbnRhaW5zKHJlc291cmNlVHlwZSkpIHsKKyAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEJ5QWN0aW9uU3RhdHVzQ29tcG9uZW50RXhjZXB0aW9uKEFjdGlvblN0YXR1cy5DT05UQUlORVJfQ0FOTk9UX0NPTlRBSU5fSU5TVEFOQ0UsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyQ29tcG9uZW50LmdldENvbXBvbmVudFR5cGUoKS50b1N0cmluZygpLCByZXNvdXJjZVR5cGUubmFtZSgpKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgIHRocm93IG5ldyBCeUFjdGlvblN0YXR1c0NvbXBvbmVudEV4Y2VwdGlvbihBY3Rpb25TdGF0dXMuSU5WQUxJRF9DT05URU5UKTsKKyAgICAgICAgfQorICAgIH0KKworICAgIHByaXZhdGUgdm9pZCB2YWxpZGF0ZU9yaWdpblR5cGUoT3JpZ2luVHlwZUVudW0gb3JpZ2luVHlwZSwgUmVzb3VyY2VUeXBlRW51bSByZXNvdXJjZVR5cGUpIHsKKyAgICAgICAgUmVzb3VyY2VUeXBlRW51bSBjb252ZXJ0ZWRPcmlnaW5UeXBlOworICAgICAgICB0cnkgeworICAgICAgICAgICAgY29udmVydGVkT3JpZ2luVHlwZSA9IFJlc291cmNlVHlwZUVudW0uZ2V0VHlwZUlnbm9yZUNhc2Uob3JpZ2luVHlwZS5uYW1lKCkpOworICAgICAgICB9CisgICAgICAgIGNhdGNoIChFeGNlcHRpb24gZSl7CisgICAgICAgICAgICB0aHJvdyBuZXcgQnlBY3Rpb25TdGF0dXNDb21wb25lbnRFeGNlcHRpb24oQWN0aW9uU3RhdHVzLklOVkFMSURfQ09OVEVOVCk7CisgICAgICAgIH0KKworICAgICAgICBpZiAocmVzb3VyY2VUeXBlICE9IGNvbnZlcnRlZE9yaWdpblR5cGUpICB0aHJvdyBuZXcgQnlBY3Rpb25TdGF0dXNDb21wb25lbnRFeGNlcHRpb24oQWN0aW9uU3RhdHVzLklOVkFMSURfQ09OVEVOVCk7CisgICAgfQorCisgICAgcHJpdmF0ZSBSZXNvdXJjZVR5cGVFbnVtIGdldFJlc291cmNlVHlwZUVudW1Gcm9tT3JpZ2luQ29tcG9uZW50KENvbXBvbmVudCBvcmlnQ29tcG9uZW50LCBSZXNvdXJjZVR5cGVFbnVtIHJlc291cmNlVHlwZSkgeworICAgICAgICBzd2l0Y2ggKG9yaWdDb21wb25lbnQuZ2V0Q29tcG9uZW50VHlwZSgpKSB7CisgICAgICAgICAgICBjYXNlIFNFUlZJQ0U6CisgICAgICAgICAgICAgICAgcmVzb3VyY2VUeXBlID0gUmVzb3VyY2VUeXBlRW51bS5TZXJ2aWNlUHJveHk7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIFJFU09VUkNFOgorICAgICAgICAgICAgICAgIHJlc291cmNlVHlwZSA9ICgoUmVzb3VyY2UpIG9yaWdDb21wb25lbnQpLmdldFJlc291cmNlVHlwZSgpOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICB0aHJvdyBuZXcgQnlBY3Rpb25TdGF0dXNDb21wb25lbnRFeGNlcHRpb24oQWN0aW9uU3RhdHVzLklOVkFMSURfQ09OVEVOVCk7CisgICAgICAgIH0KKyAgICAgICAgcmV0dXJuIHJlc291cmNlVHlwZTsKKyAgICB9CisKKyAgICBwcml2YXRlIENvbXBvbmVudEluc3RhbmNlIGlzTmVlZExvY2soYm9vbGVhbiBuZWVkTG9jaywgQ29tcG9uZW50IGNvbnRhaW5lckNvbXBvbmVudCkgeworICAgICAgICBpZiAobmVlZExvY2spIHsKKyAgICAgICAgICAgIGxvY2tDb21wb25lbnQoY29udGFpbmVyQ29tcG9uZW50LCAiY3JlYXRlQ29tcG9uZW50SW5zdGFuY2UiKTsKKyAgICAgICAgfQorICAgICAgICByZXR1cm4gbnVsbDsKKyAgICB9CisKKyAgICBwcml2YXRlIGJvb2xlYW4gaXNTZXJ2aWNlUHJveHlPcmlnaW4oRWl0aGVyPENvbXBvbmVudCwgU3RvcmFnZU9wZXJhdGlvblN0YXR1cz4gc2VydmljZVByb3h5T3JpZ2luKSB7CisgICAgICAgIGlmIChzZXJ2aWNlUHJveHlPcmlnaW4uaXNSaWdodCgpKSB7CisgICAgICAgICAgICBsb2cuZGVidWcoIkZhaWxlZCB0byBmZXRjaCBub3JtYXRpdmUgc2VydmljZSBwcm94eSByZXNvdXJjZSBieSB0b3NjYSBuYW1lLCBlcnJvciB7fSIsIHNlcnZpY2VQcm94eU9yaWdpbi5yaWdodCgpLnZhbHVlKCkpOworICAgICAgICAgICAgcmV0dXJuIHRydWU7CisgICAgICAgIH0KKyAgICAgICAgcmV0dXJuIGZhbHNlOworICAgIH0KKwogICAgIHByaXZhdGUgU3RvcmFnZU9wZXJhdGlvblN0YXR1cyBmaWxsUHJveHlJbnN0YW5jZURhdGEoQ29tcG9uZW50SW5zdGFuY2UgcmVzb3VyY2VJbnN0YW5jZSwgQ29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ICAgICAgICAgICAgICBsb2cuZGVidWcoIkZhaWxlZCB0byBjcmVhdGUgcmVzb3VyY2UgaW5zdGFuY2Uge30iLCBjb250YWluZXJDb21wb25lbnRJZCk7Ci0gICAgICAgICAgICAgICAgcmVzdWx0T3AgPSBFaXRoZXIucmlnaHQocmVzdWx0LnJpZ2h0KCkudmFsdWUoKSk7Ci0gICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdE9wOwotCi0gICAgICAgICAgICB9CisgICAgICAgICAgICBDb21wb25lbnQgb3JpZ0NvbXBvbmVudCA9IGdldE9yaWdpbkNvbXBvbmVudEZyb21Db21wb25lbnRJbnN0YW5jZShyZXNvdXJjZUluc3RhbmNlKTsKIAogICAgICAgICAgICAgbG9nLmRlYnVnKEVOVElUWV9PTl9HUkFQSF9JU19DUkVBVEVEKTsKLSAgICAgICAgICAgIENvbXBvbmVudEluc3RhbmNlIHJlc1Jlc291cmNlSW5mbyA9IHJlc3VsdC5sZWZ0KCkudmFsdWUoKTsKKyAgICAgICAgICAgIENvbXBvbmVudEluc3RhbmNlIHJlc1Jlc291cmNlSW5mbyA9IGNyZWF0ZUNvbXBvbmVudEluc3RhbmNlT25HcmFwaChjb250YWluZXJDb21wb25lbnQsIG9yaWdDb21wb25lbnQsIHJlc291cmNlSW5zdGFuY2UsIHVzZXIpOwogICAgICAgICAgICAgaWYgKGFzc29jaWF0aW9uSW5mby5nZXRGcm9tTm9kZSgpID09IG51bGwgfHwgYXNzb2NpYXRpb25JbmZvLmdldEZyb21Ob2RlKCkuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgYXNzb2NpYXRpb25JbmZvLnNldEZyb21Ob2RlKHJlc1Jlc291cmNlSW5mby5nZXRVbmlxdWVJZCgpKTsKICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgYXNzb2NpYXRpb25JbmZvLnNldFRvTm9kZShyZXNSZXNvdXJjZUluZm8uZ2V0VW5pcXVlSWQoKSk7CiAgICAgIC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B1c2VyLCBjb250YWluZXJDb21wb25lbnQsIGV4aXN0aW5nRW52VmVyc2lvbnMpOwotICAgICAgICAgICAgICAgICAgICBpZiAoY3JlYXRlSGVhdEVudlBsYWNlSG9sZGVyLmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChjcmVhdGVIZWF0RW52UGxhY2VIb2xkZXIucmlnaHQoKS52YWx1ZSgpKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBBcnRpZmFjdERlZmluaXRpb24gYXJ0aWZhY3REZWZpbml0aW9uID0gY3JlYXRlSGVhdEVudlBsYWNlSG9sZGVyLmxlZnQoKS52YWx1ZSgpOworICAgICAgICAgICAgICAgICAgICBBcnRpZmFjdERlZmluaXRpb24gYXJ0aWZhY3REZWZpbml0aW9uID0gYXJ0aWZhY3RCdXNpbmVzc0xvZ2ljLmNyZWF0ZUhlYXRFbnZQbGFjZUhvbGRlcihuZXcgQXJyYXlMaXN0PD4oKSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcnRpZmFjdCwgQXJ0aWZhY3RzQnVzaW5lc3NMb2dpYy5IRUFUX0VOVl9OQU1FLCBjb21wb25lbnRJbnN0YW5jZS5nZXRVbmlxdWVJZCgpLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIE5vZGVUeXBlRW51bS5SZXNvdXJjZUluc3RhbmNlLCBjb21wb25lbnRJbnN0YW5jZS5nZXROYW1lKCksIHVzZXIsIGNvbnRhaW5lckNvbXBvbmVudCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBleGlzdGluZ0VudlZlcnNpb25zKTsKICAgICAgICAgICAgICAgICAgICAgLy8gcHV0IGVudgogICAgICAgICAgICAgICAgICAgICBmaW5hbERlcGxveW1lbnRBcnRpZmFjdHMucHV0KGFydGlmYWN0RGVmaW5pdGlvbi5nZXRBcnRpZmFjdExhYmVsKCksIGFydGlmYWN0RGVmaW5pdGlvbik7CiAKQEAgLTYzNywzNyArNzAxLDI1IEBACiAgICAgICAgICAgICAgICAgICAgICAgICBmaWx0ZXJlZEdyb3VwcyA9IG9yaWdpbkNvbXBvbmVudC5nZXRHcm91cHMoKS5zdHJlYW0oKS5maWx0ZXIoZyAtPiBnLmdldFR5cGUoKS5lcXVhbHMoVkZfTU9EVUxFKSkuY29sbGVjdChDb2xsZWN0b3JzLnRvTGlzdCgpKTsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICBpZiAoQ29sbGVjdGlvblV0aWxzLmlzTm90RW1wdHkoZmlsdGVyZWRHcm91cHMpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKEdyb3VwRGVmaW5pdGlvbiBncm91cEluc3RhbmNlIDogZmlsdGVyZWRHcm91cHMpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBPcHRpb25hbDxTdHJpbmc+IG9wID0gZ3JvdXBJbnN0YW5jZS5nZXRBcnRpZmFjdHMoKS5zdHJlYW0oKS5maWx0ZXIocCAtPiBwLmVxdWFscyhhcnRpZmFjdERlZmluaXRpb24uZ2V0R2VuZXJhdGVkRnJvbUlkKCkpKS5maW5kQW55KCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wLmlzUHJlc2VudCgpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIExpc3Q8QXJ0aWZhY3REZWZpbml0aW9uPiBhcnRpZmFjdHNVaWQ7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChncm91cEluc3RhbmNlc0FydGlmYWN0cy5jb250YWluc0tleShncm91cEluc3RhbmNlLmdldFVuaXF1ZUlkKCkpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcnRpZmFjdHNVaWQgPSBncm91cEluc3RhbmNlc0FydGlmYWN0cy5nZXQoZ3JvdXBJbnN0YW5jZS5nZXRVbmlxdWVJZCgpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFydGlmYWN0c1VpZCA9IG5ldyBBcnJheUxpc3Q8PigpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFydGlmYWN0c1VpZC5hZGQoYXJ0aWZhY3REZWZpbml0aW9uKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ3JvdXBJbnN0YW5jZXNBcnRpZmFjdHMucHV0KGdyb3VwSW5zdGFuY2UuZ2V0VW5pcXVlSWQoKSwgYXJ0aWZhY3RzVWlkKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgfQotCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzQ2xvdWRTcGVjaWZpY0FydGlmYWN0KGFydGlmYWN0RGVmaW5pdGlvbi5nZXRBcnRpZmFjdE5hbWUoKSkpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ3JvdXBJbnN0YW5jZS5nZXRBcnRpZmFjdHMoKS5hZGQoYXJ0aWZhY3REZWZpbml0aW9uLmdldEdlbmVyYXRlZEZyb21JZCgpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBmaWx0ZXJlZEdyb3Vwcy5zdHJlYW0oKS5maWx0ZXIoZyAtPgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnLmdldEFydGlmYWN0cygpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnN0cmVhbSgpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmFueU1hdGNoKHAgLT4gcC5lcXVhbHMoYXJ0aWZhY3REZWZpbml0aW9uLmdldEdlbmVyYXRlZEZyb21JZCgpKSkpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5maW5kRmlyc3QoKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuaWZQcmVzZW50KGcgLT4gZmlsbEluc3RhbmNlQXJ0aWZhY3RNYXAoZ3JvdXBJbnN0YW5jZXNBcnRpZmFjdHMsIGFydGlmYWN0RGVmaW5pdGlvbiwgZykpOwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogICAgICAgICAgICAgYXJ0U3RhdHVzID0gdG9zY2FPcGVyYXRpb25GYWNhZGUuYWRkRGVwbG95bWVudEFydGlmYWN0c1RvSW5zdGFuY2UoY29udGFpbmVyQ29tcG9uZW50LmdldFVuaXF1ZUlkKCksIGNvbXBvbmVudEluc3RhbmNlLCBmaW5hbERlcGxveW1lbnRBcnRpZmFjdHMpOwogICAgICAgICAgICAgaWYgKGFydFN0YXR1cyAhPSBTdG9yYWdlT3BlcmF0aW9uU3RhdHVzLk9LKSB7CiAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJGYWlsZWQgdG8gYWRkIGluc3RhbmNlIGRlcGxveW1lbnQgYXJ0aWZhY3RzIGZvciBpbnN0YW5jZSB7fSBpbiBjb25hdGluZXIge30gZXJyb3Ige30iLCBjb21wb25lbnRJbnN0YW5jZS5nZXRVbmlxdWVJZCgpLCBjb250YWluZXJDb21wb25lbnQuZ2V0VW5pcXVlSWQoKSwgYXJ0U3RhdHVzKTsKLSAgICAgICAgICAgICAgICByZXR1cm4gRWl0aGVyLnJpZ2h0KGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChjb21wb25lbnRzVXRpbHMuY29udmVydEZyb21TdG9yYWdlUmVzcG9uc2VGb3JSZXNvdXJjZUluc3RhbmNlKGFydFN0YXR1cywgZmFsc2UpKSk7CisgICAgICAgICAgICA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uY2UpIHsKLSAgICAgICAgcmV0dXJuIHVwZGF0ZUNvbXBvbmVudEluc3RhbmNlTWV0YWRhdGEoY29udGFpbmVyQ29tcG9uZW50UGFyYW0sIGNvbnRhaW5lckNvbXBvbmVudElkLCBjb21wb25lbnRJbnN0YW5jZUlkLCB1c2VySWQsIGNvbXBvbmVudEluc3RhbmNlLCBmYWxzZSwgdHJ1ZSwgdHJ1ZSk7CisgICAgICAgIHJldHVybiB1cGRhdGVDb21wb25lbnRJbnN0YW5jZU1ldGFkYXRhKGNvbnRhaW5lckNvbXBvbmVudFBhcmFtLCBjb250YWluZXJDb21wb25lbnRJZCwgY29tcG9uZW50SW5zdGFuY2VJZCwgdXNlcklkLCBjb21wb25lbnRJbnN0YW5jZSwgZmFsc2UsIHRydWUpOwogICAgIH0KIAogICAgIHB1YmxpYyBFaXRoZXI8Q29tcG9uZW50SW5zdGFuY2UsIFJlc3BvbnNlRm9ybWF0PiB1cGRhdGVDb21wb25lbnRJbnN0YW5jZU1ldGFkYXRhKFN0cmluZyBjb250YWluZXJDb21wb25lbnRQYXJhbSwgU3RyaW5nIGNvbnRhaW5lckNvbXBvbmVudElkLCBTdHJpbmcgY29tcG9uZW50SW5zdGFuY2VJZCwgU3RyaW5nIHVzZXJJZCwgQ29tcG9uZW50SW5zdGFuY2UgY29tcG9uZW50SW5zdGFuY2UsIGJvb2xlYW4gaW5UcmFuc2FjdGlvbiwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sZWFuIG5lZWRMb2NrLCBib29sZWFuIGNyZWF0ZU5ld1RyYW5zYWN0aW9uKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbGVhbiBuZWVkTG9jaykgewogCi0gICAgICAgIHZhbGlkYXRlVXNlckV4aXN0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5UX0lOU1RBTkNFX05PVF9GT1VORF9PTl9DT05UQUlORVIsIGNvbXBvbmVudEluc3RhbmNlLmdldE5hbWUoKSwgaW5zdGFuY2VUeXBlLmdldFZhbHVlKCkudG9Mb3dlckNhc2UoKSwgY29udGFpbmVyQ29tcG9uZW50VHlwZS5nZXRWYWx1ZSgpLnRvTG93ZXJDYXNlKCksIGNvbnRhaW5lckNvbXBvbmVudElkKSk7Ci0gICAgICAgICAgICByZXR1cm4gcmVzdWx0T3A7CisgICAgICAgICAgICB0aHJvdyBuZXcgQnlBY3Rpb25TdGF0dXNDb21wb25lbnRFeGNlcHRpb24oQWN0aW9uU3RhdHVzLkNPTVBPTkVOVF9JTlNUQU5DRV9OT1RfRk9VTkRfT05fQ09OVEFJTkVSLCBjb21wb25lbnRJbnN0YW5jZS5nZXROYW1lKCksIGluc3RhbmNlVHlwZS5nZXRWYWx1ZSgpLnRvTG93ZXJDYXNlKCksIGNvbnRhaW5lckNvbXBvbmVudFR5cGUuZ2V0VmFsdWUoKS50b0xvd2VyQ2FzZSgpLCBjb250YWluZXJDb21wb25lbnRJZCk7CiAgICAgICAgIH0KIAogICAgICAgICBpZiAobmVlZExvY2spIHsKLSAgICAgICAgICAgIEVpdGhlcjxCb29sZWFuLCBSZXNwb25zZUZvcm1hdD4gbG9ja0NvbXBvbmVudCA9IGxvY2tDb21wb25lbnQoY29udGFpbmVyQ29tcG9uZW50LCAidXBkYXRlQ29tcG9uZW50SW5zdGFuY2UiKTsKLSAgICAgICAgICAgIGlmIChsb2NrQ29tcG9uZW50LmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQobG9ja0NvbXBvbmVudC5yaWdodCgpLnZhbHVlKCkpOwotICAgICAgICAgICAgfQorICAgICAgICAgICAgbG9ja0NvbXBvbmVudChjb250YWluZXJDb21wb25lbnQsICJ1cGRhdGVDb21wb25lbnRJbnN0YW5jZSIpOwogICAgICAgICB9CisgICAgICAgIENvbXBvbmVudCBvcmlnQ29tcG9uZW50OworICAgICAgICBib29sZWFuIGZhaWxlZCA9IGZhbHNlOwogICAgICAgICB0cnkgewotCi0gICAgICAgICAgICBFaXRoZXI8Q29tcG9uZW50LCBSZXNwb25zZUZvcm1hdD4gZWl0aGVyUmVzb3VyY2VOYW1lID0gZ2V0T3JpZ2luQ29tcG9uZW50RnJvbUNvbXBvbmVudEluc3RhbmNlKGNvbXBvbmVudEluc3RhbmNlKTsKLQotICAgICAgICAgICAgaWYgKGVpdGhlclJlc291cmNlTmFtZS5pc1JpZ2h0KCkpIHsKLSAgICAgICAgICAgICAgICByZXN1bHRPcCA9IEVpdGhlci5yaWdodChlaXRoZXJSZXNvdXJjZU5hbWUucmlnaHQoKS52YWx1ZSgpKTsKLSAgICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0T3A7CisgICAgICAgICAgICBvcmlnQ29tcG9uZW50ID0gZ2V0T3JpZ2luQ29tcG9uZW50RnJvbUNvbXBvbmVudEluc3RhbmNlKGNvbXBvbmVudEluc3RhbmNlKTsKKyAgICAgICAgICAgIGNvbXBvbmVudEluc3RhbmNlID0gdXBkYXRlQ29tcG9uZW50SW5zdGFuY2VNZXRhZGF0YShjb250YWluZXJDb21wb25lbnQsIGNvbnRhaW5lckNvbXBvbmVudFR5cGUsIG9yaWdDb21wb25lbnQsIGNvbXBvbmVudEluc3RhbmNlSWQsIGNvbXBvbmVudEluc3RhbmNlKTsKKyAgICAgICAgfWNhdGNoIChDb21wb25lbnRFeGNlcHRpb24gZSkgeworICAgICAgICAgICAgZmFpbGVkID0gdHJ1ZTsKKyAgICAgICAgICAgIHRocm93IGU7CisgICAgICAgIH1maW5hbGx5IHsKKyAgICAgICAgICAgIGlmIChuZWVkTG9jaykgeworICAgICAgICAgICAgICAgIHVubG9ja0NvbXBvbmVudChmYWlsZWQsIGNvbnRhaW5lckNvbXBvbmVudCk7CiAgICAgICAgICAgICB9Ci0gICAgICAgICAgICBDb21wb25lbnQgb3JpZ0NvbXBvbmVudCA9IGVpdGhlclJlc291cmNlTmFtZS5sZWZ0KCkudmFsdWUoKTsKLQotICAgICAgICAgICAgcmVzdWx0T3AgPSB1cGRhdGVDb21wb25lbnRJbnN0YW5jZU1ldGFkYXRhKGNvbnRhaW5lckNvbXBvbmVudCwgY29udGFpbmVyQ29tcG9uZW50VHlwZSwgb3JpZ0NvbXBvbmVudCwgY29tcG9uZW50SW5zdGFuY2VJZCwgY29tcG9uZW50SW5zdGFuY2UpOwotICAgICAgICAgICAgcmV0dXJuIHJlc3VsdE9wOwotCi0gICAgICAgIH0gZmluYWxseSB7Ci0gICAgICAgICAgICBpZiAobmVlZExvY2spCi0gICAgICAgICAgICAgICAgdW5sb2NrQ29tcG9uZW50KHJlc3VsdE9wLCBjb250YWluZXJDb21wb25lbnQpOwogICAgICAgICB9CisgICAgICAgIHJldHVybiBFaXRoZXIubGVmdChjb21wb25lbnRJbnN0YW5jZSk7CiAgICAgfQogCiAgICAgLy8gTmV3IE11bHRpcGxlIEluc3RhbmNlIFVwZGF0ZSBBUEkKLSAgICBwdWJsaWMgRWl0aGVyPExpc3Q8Q29tcG9uZW50SW5zdGFuY2U+LCBSZXNwb25zZUZvcm1hdD4gdXBkYXRlQ29tcG9uZW50SW5zdGFuY2UoU3RyaW5nIGNvbnRhaW5lckNvbXBvbmVudFBhcmFtLCBTdHJpbmcgY29udGFpbmVyQ29tcG9uZW50SWQsIFN0cmluZyB1c2VySWQsIExpc3Q8Q29tcG9uZW50SW5zdGFuY2U+IGNvbXBvbmVudEluc3RhbmNlTGlzdCwgYm9vbGVhbiBuZWVkTG9jaykgeworICAgIHB1YmxpYyBMaXN0PENvbXBvbmVudEluc3RhbmNlPiB1cGRhdGVDb21wb25lbnRJbnN0YW5jZShTdHJpbmcgY29udGFpbmVyQ29tcG9uZW50UGFyYW0sIENvbXBvbmVudCBjb250YWluZXJDb21wb25lbnQsIFN0cmluZyBjb250YWluZXJDb21wb25lbnRJZCwgU3RyaW5nIHVzZXJJZ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ZW50VHlwZShjb250YWluZXJDb21wb25lbnRQYXJhbSk7CiAgICAgICAgICAgICBDb21wb25lbnRQYXJhbWV0ZXJzVmlldyBjb21wb25lbnRGaWx0ZXIgPSBuZXcgQ29tcG9uZW50UGFyYW1ldGVyc1ZpZXcoKTsKICAgICAgICAgICAgIGNvbXBvbmVudEZpbHRlci5kaXNhYmxlQWxsKCk7CiAgICAgICAgICAgICBjb21wb25lbnRGaWx0ZXIuc2V0SWdub3JlVXNlcnMoZmFsc2UpOwogICAgICAgICAgICAgY29tcG9uZW50RmlsdGVyLnNldElnbm9yZUNvbXBvbmVudEluc3RhbmNlcyhmYWxzZSk7Ci0gICAgICAgICAgICBFaXRoZXI8b3JnLm9wZW5lY29tcC5zZGMuYmUubW9kZWwuQ29tcG9uZW50LCBSZXNwb25zZUZvcm1hdD4gdmFsaWRhdGVDb21wb25lbnRFeGlzdHMgPSB2YWxpZGF0ZUNvbXBvbmVudEV4aXN0c0J5RmlsdGVyKGNvbnRhaW5lckNvbXBvbmVudElkLCBjb250YWluZXJDb21wb25lbnRUeXBlLCBjb21wb25lbnRGaWx0ZXIpOwotICAgICAgICAgICAgaWYgKHZhbGlkYXRlQ29tcG9uZW50RXhpc3RzLmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQodmFsaWRhdGVDb21wb25lbnRFeGlzdHMucmlnaHQoKS52YWx1ZSgpKTsKKyAgICAgICAgICAgIGlmIChjb250YWluZXJDb21wb25lbnQgPT0gbnVsbCkgeworICAgICAgICAgICAgICAgIGNvbnRhaW5lckNvbXBvbmVudCA9IHZhbGlkYXRlQ29tcG9uZW50RXhpc3RzQnlGaWx0ZXIoY29udGFpbmVyQ29tcG9uZW50SWQsIGNvbnRhaW5lckNvbXBvbmVudFR5cGUsIGNvbXBvbmVudEZpbHRlcik7CiAgICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgIGNvbnRhaW5lckNvbXBvbmVudCA9IHZhbGlkYXRlQ29tcG9uZW50RXhpc3RzLmxlZnQoKS52YWx1ZSgpOwotCi0gICAgICAgICAgICBFaXRoZXI8Qm9vbGVhbiwgUmVzcG9uc2VGb3JtYXQ+IHZhbGlkYXRlQ2FuV29ya09uQ29tcG9uZW50ID0gdmFsaWRhdGVDYW5Xb3JrT25Db21wb25lbnQoY29udGFpbmVyQ29tcG9uZW50LCB1c2VySWQpOwotICAgICAgICAgICAgaWYgKHZhbGlkYXRlQ2FuV29ya09uQ29tcG9uZW50LmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQodmFsaWRhdGVDYW5Xb3JrT25Db21wb25lbnQucmlnaHQoKS52YWx1ZSgpKTsKLSAgICAgICAgICAgIH0KKyAgICAgICAgICAgIHZhbGlkYXRlQ2FuV29ya09uQ29tcG9uZW50KGNvbnRhaW5lckNvbXBvbmVudCwgdXNlcklkKTsKIAogICAgICAgICAgICAgQ29tcG9uZW50VHlwZUVudW0gaW5zdGFuY2VUeXBlID0gZ2V0Q29tcG9uZW50VHlwZShjb250YWluZXJDb21wb25lbnRUeXBlKTsKIAogICAgICAgICAgICAgZm9yIChDb21wb25lbnRJbnN0YW5jZSBjb21wb25lbnRJbnN0YW5jZSA6IGNvbXBvbmVudEluc3RhbmNlTGlzdCkgewogICAgICAgICAgICAgICAgIGJvb2xlYW4gdmFsaWRhdGVQYXJlbnQgPSB2YWxpZGF0ZVBhcmVudChjb250YWluZXJDb21wb25lbnQsIGNvbXBvbmVudEluc3RhbmNlLmdldFVuaXF1ZUlkKCkpOwogICAgICAgICAgICAgICAgIGlmICghdmFsaWRhdGVQYXJlbnQpIHsKLSAgICAgICAgICAgICAgICAgICAgcmVzdWx0T3AgPSBFaXRoZXIucmlnaHQoY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5DT01QT05FTlRfSU5TVEFOQ0VfTk9UX0ZPVU5EX09OX0NPTlRBSU5FUiwgY29tcG9uZW50SW5zdGFuY2UuZ2V0TmFtZSgpLCBpbnN0YW5jZVR5cGUuZ2V0VmFsdWUoKS50b0xvd2VyQ2FzZSgpLCBjb250YWluZXJDb21wb25lbnRUeXBlLmdldFZhbHVlKCkudG9Mb3dlckNhc2UoKSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXJDb21wb25lbnRJZCkpOwotICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0T3A7CisgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBCeUFjdGlvblN0YXR1c0NvbXBvbmVudEV4Y2VwdGlvbihBY3Rpb25TdGF0dXMuQ09NUE9ORU5UX0lOU1RBTkNFX05PVF9GT1VORF9PTl9DT05UQUlORVIsIGNvbXBvbmVudEluc3RhbmNlLmdldE5hbWUoKSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnN0YW5jZVR5cGUuZ2V0VmFsdWUoKS50b0xvd2VyQ2FzZSgpLCBjb250YWluZXJDb21wb25lbnRUeXBlLmdldFZhbHVlKCkudG9Mb3dlckNhc2UoKSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXJDb21wb25lbnRJZCk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogCiAgICAgICAgICAgICBpZiAobmVlZExvY2spIHsKLQotICAgICAgICAgICAgICAgIEVpdGhlcjxCb29sZWFuLCBSZXNwb25zZUZvcm1hdD4gbG9ja0NvbXBvbmVudCA9IGxvY2tDb21wb25lbnQoY29udGFpbmVyQ29tcG9uZW50LCAidXBkYXRlQ29tcG9uZW50SW5zdGFuY2UiKTsKLSAgICAgICAgICAgICAgICBpZiAobG9ja0NvbXBvbmVudC5pc1JpZ2h0KCkpIHsKLSAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChsb2NrQ29tcG9uZW50LnJpZ2h0KCkudmFsdWUoKSk7Ci0gICAgICAgICAgICAgICAgfQorICAgICAgICAg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luZXIgY29tcG9uZW50IHt9LiBTdGF0dXMgaXMge30uICIsIGNvbnRhaW5lckNvbXBvbmVudC5nZXROYW1lKCksIHVwZGF0ZVN0YXR1cy5yaWdodCgpLnZhbHVlKCkpOwotICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0T3AgPSBFaXRoZXIucmlnaHQoY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0Rm9yUmVzb3VyY2VJbnN0YW5jZShjb21wb25lbnRzVXRpbHMuY29udmVydEZyb21TdG9yYWdlUmVzcG9uc2VGb3JSZXNvdXJjZUluc3RhbmNlKHVwZGF0ZVN0YXR1cy5yaWdodCgpLnZhbHVlKCksIHRydWUpLCAiIiwgbnVsbCkpOwotICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdE9wOwotICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgIGZvciAoQ29tcG9uZW50SW5zdGFuY2UgdXBkYXRlZEluc3RhbmNlIDogdXBkYXRlU3RhdHVzLmxlZnQoKS52YWx1ZSgpLmdldENvbXBvbmVudEluc3RhbmNlcygpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBPcHRpb25hbDxDb21wb25lbnRJbnN0YW5jZT4gb3AgPSBjb21wb25lbnRJbnN0YW5jZUxpc3Quc3RyZWFtKCkuZmlsdGVyKGNpIC0+IGNpLmdldE5hbWUoKS5lcXVhbHModXBkYXRlZEluc3RhbmNlLmdldE5hbWUoKSkpLmZpbmRBbnkoKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvcC5pc1ByZXNlbnQoKSkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVwZGF0ZWRMaXN0LmFkZCh1cGRhdGVkSW5zdGFuY2UpOwotICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIEVpdGhlcjxDb21wb25lbnQsIFN0b3JhZ2VPcGVyYXRpb25TdGF0dXM+IHVwZGF0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pbHRlcihjaSAtPiBjaS5nZXROYW1lKCkuZXF1YWxzKHVwZGF0ZWRJbnN0YW5jZS5nZXROYW1lKCkpKS5maW5kQW55KCk7CisgICAgICAgICAgICAgICAgICAgIGlmIChvcC5pc1ByZXNlbnQoKSkgeworICAgICAgICAgICAgICAgICAgICAgICAgdXBkYXRlZExpc3QuYWRkKHVwZGF0ZWRJbnN0YW5jZSk7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgIHJlc3VsdE9wID0gRWl0aGVyLmxlZnQodXBkYXRlZExpc3QpOwotICAgICAgICAgICAgcmV0dXJuIHJlc3VsdE9wOwotCi0gICAgICAgIH0gZmluYWxseSB7CisgICAgICAgICAgICByZXR1cm4gdXBkYXRlZExpc3Q7CisgICAgICAgIH1jYXRjaCAoQ29tcG9uZW50RXhjZXB0aW9uIGUpeworICAgICAgICAgICAgZmFpbGVkID0gdHJ1ZTsKKyAgICAgICAgICAgIHRocm93IGU7CisgICAgICAgIH1maW5hbGx5IHsKICAgICAgICAgICAgIGlmIChuZWVkTG9jaykgewotICAgICAgICAgICAgICAgIHVubG9ja0NvbXBvbmVudChyZXN1bHRPcCwgY29udGFpbmVyQ29tcG9uZW50KTsKKyAgICAgICAgICAgICAgICB1bmxvY2tDb21wb25lbnQoZmFpbGVkLCBjb250YWluZXJDb21wb25lbnQpOwogICAgICAgICAgICAgfQogICAgICAgICB9CiAgICAgfQpAQCAtODgzLDk0ICs5MDYsOTQgQEAKICAgICB9CiAKICAgICBwcml2YXRlIENvbXBvbmVudFR5cGVFbnVtIGdldENvbXBvbmVudFR5cGUoQ29tcG9uZW50VHlwZUVudW0gY29udGFpbmVyQ29tcG9uZW50VHlwZSkgewotICAgICAgICBpZiAoQ29tcG9uZW50VHlwZUVudW0uUFJPRFVDVC5lcXVhbHMoY29udGFpbmVyQ29tcG9uZW50VHlwZSkpIHsKKyAgICAgICAgaWYgKENvbXBvbmVudFR5cGVFbnVtLlBST0RVQ1QgPT0gY29udGFpbmVyQ29tcG9uZW50VHlwZSkgewogICAgICAgICAgICAgcmV0dXJuIENvbXBvbmVudFR5cGVFbnVtLlNFUlZJQ0VfSU5TVEFOQ0U7CiAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICByZXR1cm4gQ29tcG9uZW50VHlwZUVudW0uUkVTT1VSQ0VfSU5TVEFOQ0U7CiAgICAgICAgIH0KICAgICB9CiAKLSAgICBwcml2YXRlIEVpdGhlcjxDb21wb25lbnRJbnN0YW5jZSwgUmVzcG9uc2VGb3JtYXQ+IHVwZGF0ZUNvbXBvbmVudEluc3RhbmNlTWV0YWRhdGEoQ29tcG9uZW50IGNvbnRhaW5lckNvbXBvbmVudCwgQ29tcG9uZW50VHlwZUVudW0gY29udGFpbmVyQ29tcG9uZW50VHlwZSwgb3JnLm9wZW5lY29tcC5zZGMuYmUubW9kZWwuQ29tcG9uZW50IG9yaWdDb21wb25lbnQsIFN0cmluZyBjb21wb25lbnRJbnN0YW5jZUlkLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb21wb25lbnRJbnN0YW5jZSBjb21wb25lbnRJbnN0YW5jZSkgeworICAgIHByaXZhdGUgQ29tcG9uZW50SW5zdGFuY2UgdXBkYXRlQ29tcG9uZW50SW5zdGFuY2VNZXRhZGF0YShDb21wb25lbnQgY29udGFpbmVyQ29tcG9uZW50LCBDb21wb25lbnRUeXBlRW51bSBjb250YWluZXJDb21wb25lbnRUeXBlLCBvcmcub3BlbmVjb21wLnNkYy5iZS5tb2RlbC5Db21wb25lbnQgb3JpZ0NvbXBvbmVudCwgU3RyaW5nIGNvbXBvbmVudEluc3RhbmNlSWQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbXBvbmVudEluc3RhbmN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blN0YXR1cy5DT01QT05FTlRfTkFNRV9BTFJFQURZX0VYSVNULCBjb250YWluZXJDb21wb25lbnRUeXBlLmdldFZhbHVlKCksIGNvbXBvbmVudEluc3RhbmNlLmdldE5hbWUoKSkpOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgaWYoIURpcmVjdGl2ZXNVdGlscy5pc1ZhbGlkKGNvbXBvbmVudEluc3RhbmNlLmdldERpcmVjdGl2ZXMoKSkpIHsKLSAgICAgICAgICAgICAgICBmaW5hbCBTdHJpbmcgZGlyZWN0aXZlc1N0ciA9Ci0gICAgICAgICAgICAgICAgICAgICAgICBjb21wb25lbnRJbnN0YW5jZS5nZXREaXJlY3RpdmVzKCkuc3RyZWFtKCkuY29sbGVjdChDb2xsZWN0b3JzLmpvaW5pbmcoIiAsICIsICIgWyAiLCAiIF0gIikpOwotICAgICAgICAgICAgICAgIENvbW1vblV0aWxpdHkuYWRkUmVjb3JkVG9Mb2cobG9nLCBMb2dMZXZlbEVudW0uREVCVUcsCi0gICAgICAgICAgICAgICAgICAgICAgICAiRmFpbGVkIHRvIHVwZGF0ZSB0aGUgZGlyZWN0aXZlcyBvZiB0aGUgY29tcG9uZW50IGluc3RhbmNlIHt9IHRvIHt9LiBEaXJlY3RpdmVzIGRhdGEge30gaXMgaW52YWxpZC4gIiwKLSAgICAgICAgICAgICAgICAgICAgICAgIG9sZENvbXBvbmVudEluc3RhbmNlLmdldE5hbWUoKSwgbmV3SW5zdGFuY2VOYW1lICwKLSAgICAgICAgICAgICAgICAgICAgICAgIGRpcmVjdGl2ZXNTdHIpOwotICAgICAgICAgICAgICAgIHJlc3VsdE9wID0gRWl0aGVyLnJpZ2h0KGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuRElSRUNUSVZFU19JTlZBTElEX1ZBTFVFLAotICAgICAgICAgICAgICAgICAgICAgICAgZGlyZWN0aXZlc1N0cikpOwotICAgICAgICAgICAgfQotICAgICAgICB9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lzIHt9LiAiLCBjb21wb25lbnRJbnN0YW5jZS5nZXROYW1lKCksIGNvbnRhaW5lckNvbXBvbmVudC5nZXROYW1lKCksCi0gICAgICAgICAgICAgICAgICAgICAgICB1cGRhdGVSZXMucmlnaHQoKS52YWx1ZSgpKTsKLSAgICAgICAgICAgICAgICByZXN1bHRPcCA9IEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXRGb3JSZXNvdXJjZUluc3RhbmNlKGNvbXBvbmVudHNVdGlscy5jb252ZXJ0RnJvbVN0b3JhZ2VSZXNwb25zZUZvclJlc291cmNlSW5zdGFuY2UodXBkYXRlUmVzLnJpZ2h0KCkudmFsdWUoKSwgdHJ1ZSksICIiLCBudWxsKSk7Ci0gICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgIC8vIHJlZ2lvbiAtIFVwZGF0ZSBpbnN0YW5jZSBHcm91cHMKLSAgICAgICAgICAgICAgICBpZiAoaXNOYW1lQ2hhbmdlZCkgewotICAgICAgICAgICAgICAgICAgICBFaXRoZXIgcmVzdWx0ID0gdG9zY2FPcGVyYXRpb25GYWNhZGUuY2xlYW5BbmRBZGRHcm91cEluc3RhbmNlc1RvQ29tcG9uZW50SW5zdGFuY2UoY29udGFpbmVyQ29tcG9uZW50LCBvbGRDb21wb25lbnRJbnN0YW5jZSwgY29tcG9uZW50SW5zdGFuY2VJZCk7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChyZXN1bHQuaXNSaWdodCgpKQotICAgICAgICAgICAgICAgICAgICAgICAgQ29tbW9uVXRpbGl0eS5hZGRSZWNvcmRUb0xvZyhsb2csIExvZ0xldmVsRW51bS5ERUJVRywgIkZhaWxlZCB0byByZW5hbWUgZ3JvdXAgaW5zdGFuY2VzIGZvciBjb250YWluZXIge30uIGVycm9yIHt9ICIsIGNvbXBvbmVudEluc3RhbmNlSWQsIHJlc3VsdC5yaWdodCgpLnZhbHVlKCkpOwotICAgICAgICAgICAgICAgICAgICBpZiAoY29udGFpbmVyQ29tcG9uZW50IGluc3RhbmNlb2YgU2VydmljZSkgewotICAgICAgICAgICAgICAgICAgICAgICAgRWl0aGVyPENvbXBvbmVudEluc3RhbmNlLCBSZXNwb25zZUZvcm1hdD4gcmVuYW1lRWl0aGVyID0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVuYW1lU2VydmljZUZpbHRlcigoU2VydmljZSkgY29udGFpbmVyQ29tcG9uZW50LCBuZXdJbnN0YW5jZU5hbWUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2xkSW5zdGFuY2VOYW1lKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZW5hbWVFaXRoZXIuaXNSaWdodCgpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlbmFtZUVpdGhlcjsKLSAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgaWYgKG9sZENvbXBvbmVudE5hbWUgIT0gbnVsbCAmJiAhb2xkQ29tcG9uZW50SW5zdGFuY2UuZ2V0TmFtZSgpLmVxdWFscyhuZXdJbnN0YW5jZU5hbWUpKQorICAgICAgICAgICAgaXNOYW1lQ2hhbmdlZCA9IHRydWU7CisgICAgICAgIEJvb2xlYW4gaXNVbmlxdWVOYW1lID0gdmFsaWRhdGVJbnN0YW5jZU5hbWVVbmlxdWVuZXNzVXBvblVwZGF0ZShjb250YWluZXJDb21wb25lbnQsIG9sZENvbXBvbmVudEluc3RhbmNlLCBuZXdJbnN0YW5jZU5hbWUpOworICAgICAgICBpZiAoIWlzVW5pcXVlTmFtZSkgeworICAgICAgICAgICAgQ29tbW9uVXRpbGl0eS5hZGRSZWNvcmRUb0xvZyhsb2csIExvZ0xldmVsRW51bS5ERUJVRywgIkZhaWxlZCB0byB1cGRhdGUgdGhlIG5hbWUgb2YgdGhlIGNvbXBvbmVudCBpbnN0YW5jZSB7fSB0byB7fS4gQSBjb21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JjZUluc3RhbmNlKHVwZGF0ZVJlcy5yaWdodCgpLnZhbHVlKCksIHRydWUpLCAiIiwgbnVsbCkpOworICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgLy8gcmVnaW9uIC0gVXBkYXRlIGluc3RhbmNlIEdyb3VwcworICAgICAgICAgICAgaWYgKGlzTmFtZUNoYW5nZWQpIHsKKyAgICAgICAgICAgICAgICBFaXRoZXI8U3RvcmFnZU9wZXJhdGlvblN0YXR1cywgU3RvcmFnZU9wZXJhdGlvblN0YXR1cz4gcmVzdWx0ID0KKyAgICAgICAgICAgICAgICAgICAgICAgIHRvc2NhT3BlcmF0aW9uRmFjYWRlLmNsZWFuQW5kQWRkR3JvdXBJbnN0YW5jZXNUb0NvbXBvbmVudEluc3RhbmNlKGNvbnRhaW5lckNvbXBvbmVudCwgb2xkQ29tcG9uZW50SW5zdGFuY2UsIGNvbXBvbmVudEluc3RhbmNlSWQpOworICAgICAgICAgICAgICAgIGlmIChyZXN1bHQuaXNSaWdodCgpKQorICAgICAgICAgICAgICAgICAgICBDb21tb25VdGlsaXR5LmFkZFJlY29yZFRvTG9nKGxvZywgTG9nTGV2ZWxFbnVtLkRFQlVHLCAiRmFpbGVkIHRvIHJlbmFtZSBncm91cCBpbnN0YW5jZXMgZm9yIGNvbnRhaW5lciB7fS4gZXJyb3Ige30gIiwgY29tcG9uZW50SW5zdGFuY2VJZCwgcmVzdWx0LnJpZ2h0KCkudmFsdWUoKSk7CisKKyAgICAgICAgICAgICAgICBpZiAoY29udGFpbmVyQ29tcG9uZW50IGluc3RhbmNlb2YgU2VydmljZSl7CisgICAgICAgICAgICAgICAgICAgIEVpdGhlcjxDb21wb25lbnRJbnN0YW5jZSwgUmVzcG9uc2VGb3JtYXQ+IHJlbmFtZUVpdGhlciA9CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVuYW1lU2VydmljZUZpbHRlcigoU2VydmljZSkgY29udGFpbmVyQ29tcG9uZW50LCBuZXdJbnN0YW5jZU5hbWUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvbGRDb21wb25lbnRJbnN0YW5jZS5nZXROYW1lKCkpOworICAgICAgICAgICAgICAgICAgICBpZiAocmVuYW1lRWl0aGVyLmlzUmlnaHQoKSkgeworICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEJ5UmVzcG9uc2VGb3JtYXRDb21wb25lbnRFeGNlcHRpb24ocmVuYW1lRWl0aGVyLnJpZ2h0KCkudmFsdWUoKSk7CiAgICAgICAgICAgICAgICAgICAgIH0KKworICAgICAgICAgICAgICAgICAgICB1cGRhdGVGb3J3YXJkaW5nUGF0aERlZmluaXRpb24oY29udGFpbmVyQ29tcG9uZW50LCBjb21wb25lbnRJbnN0YW5jZSwgb2xkQ29tcG9uZW50TmFtZSk7CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIC8vIGVuZHJlZ2lvbgogICAgICAgICAgICAgfQorICAgICAgICAgICAgLy8gZW5kcmVnaW9uCiAgICAgICAgIH0KLSAgICAgICAgaWYgKHJlc3VsdE9wID09IG51bGwpIHsKLSAgICAgICAgICAgIFN0cmluZyBuZXdJbnN0YW5jZUlkID0gdXBkYXRlUmVzLmxlZnQoKS52YWx1ZSgpLmdldFJpZ2h0KCk7Ci0gICAgICAgICAgICBPcHRpb25hbDxDb21wb25lbnRJbnN0YW5jZT4gdXBkYXRlZEluc3RhbmNlT3B0aW9uYWwgPSB1cGRhdGVSZXMubGVmdCgpLnZhbHVlKCkuZ2V0TGVmdCgpLmdldENvbXBvbmVudEluc3RhbmNlcygpLnN0cmVhbSgpLmZpbHRlcihjaSAtPiBjaS5nZXRVbmlxdWVJZCgpLmVxdWFscyhuZXdJbnN0YW5jZUlkKSkuZmluZEZpcnN0KCk7CisgICAgICAgIFN0cmluZyBuZXdJbnN0YW5jZUlkID0gdXBkYXRlUmVzLmxlZnQoKS52YWx1ZSgpLmdldFJpZ2h0KCk7CisgICAgICAgIE9wdGlvbmF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AgICAgICAgICAgICBqYW51c0dyYXBoRGFvLnJvbGxiYWNrKCk7Ci0gICAgICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQoY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KHN0YXR1cywgY29tcG9uZW50SW5zdGFuY2VJZCkpOworICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgQnlSZXNwb25zZUZvcm1hdENvbXBvbmVudEV4Y2VwdGlvbihjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoc3RhdHVzLCBjb21wb25lbnRJbnN0YW5jZUlkKSk7CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIHJlc3VsdE9wID0gZGVsZXRlU2VydmljZUZpbHRlcnNSZWxhdGVkVG9iZURlbGV0ZWRDb21wb25lbnRJbnN0YW5jZSgoU2VydmljZSkgY29udGFpbmVyQ29tcG9uZW50LAorICAgICAgICAgICAgICAgIEVpdGhlcjxDb21wb25lbnRJbnN0YW5jZSwgUmVzcG9uc2VGb3JtYXQ+IHJlc3VsdE9wID0gZGVsZXRlU2VydmljZUZpbHRlcnNSZWxhdGVkVG9iZURlbGV0ZWRDb21wb25lbnRJbnN0YW5jZSgoU2VydmljZSkgY29udGFpbmVyQ29tcG9uZW50LAogICAgICAgICAgICAgICAgICAgICAgICAgY29tcG9uZW50SW5zdGFuY2UsIENvbXBvbmVudFR5cGVFbnVtLlNFUlZJQ0UsIHVzZXJJZCk7CiAgICAgICAgICAgICAgICAgaWYgKHJlc3VsdE9wLmlzUmlnaHQoKSkgewogICAgICAgICAgICAgICAgICAgICBqYW51c0dyYXBoRGFvLnJvbGxiYWNrKCk7Ci0gICAgICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHRPcDsKKyAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEJ5UmVzcG9uc2VGb3JtYXRDb21wb25lbnRFeGNlcHRpb24ocmVzdWx0T3AucmlnaHQoKS52YWx1ZSgpKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9Ci0gICAgICAgICAgICByZXN1bHRPcCA9IGRlbGV0ZUNvbXBvbmVudEluc3RhbmNlKGNvbnRhaW5lckNvbXBvbmVudCwgY29tcG9uZW50SW5zdGFuY2VJZCwgY29udGFpbmVyQ29tcG9uZW50VHlwZSk7Ci0gICAgICAgICAgICBpZiAocmVzdWx0T3AuaXNSaWdodCgpKXsKLSAgICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0T3A7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBFaXRoZXI8Q29tcG9uZW50SW5zdGFuY2UsIFJlc3BvbnNlRm9ybWF0PiBkZWxldGVFaXRoZXIgPSBkZWxldGVGb3J3YXJkaW5nUGF0aHNSZWxhdGVkVG9iZURlbGV0ZWRDb21wb25lbnRJbnN0YW5jZShjb250YWluZXJDb21wb25lbnRJZCwKLSAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyQ29tcG9uZW50VHlwZSwgcmVzdWx0T3ApOwotICAgICAgICAgICAgaWYgKGRlbGV0ZUVpdGhlci5pc1JpZ2h0KCkpewotICAgICAgICAgICAgICAgIHJldHVybiBkZWxldGVFaXRoZXI7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICByZXR1cm4gZGVsZXRlRWl0aGVyOworICAgICAgICAgICAgbG9ja0NvbXBvbmVudChjb250YWluZXJDb21wb25lbnQsICJkZWxldGVDb21wb25lbnRJbnN0YW5jZSIpOworICAgICAgICAgICAgQ29tcG9uZW50SW5zdGFuY2UgZGVsZXRlZENvbXBJbnN0YW5jZSA9IGRlbGV0ZUNvbXBvbmVudEluc3RhbmNlKGNvbnRhaW5lckNvbXBvbmVudCwgY29tcG9uZW50SW5zdGFuY2VJZCwgY29udGFpbmVyQ29tcG9uZW50VHlwZSk7CiAKLSAgICAgICAgfSBmaW5hbGx5IHsKLSAgICAgICAgICAgIHVubG9ja0NvbXBvbmVudChyZXN1bHRPcCw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bXBvbmVudElkLCBDb21wb25lbnRUeXBlRW51bSBjb250YWluZXJDb21wb25lbnRUeXBlLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBFaXRoZXI8Q29tcG9uZW50SW5zdGFuY2UsIFJlc3BvbnNlRm9ybWF0PiByZXN1bHRPcCkgewotICAgICAgICBpZihjb250YWluZXJDb21wb25lbnRUeXBlLmVxdWFscyhDb21wb25lbnRUeXBlRW51bS5TRVJWSUNFKSAmJiByZXN1bHRPcC5pc0xlZnQoKSApewotICAgICAgICAgICAgZmluYWwgQ29tcG9uZW50SW5zdGFuY2UgY29tcG9uZW50SW5zdGFuY2UgPSByZXN1bHRPcC5sZWZ0KCkudmFsdWUoKTsKKyAgICBDb21wb25lbnRJbnN0YW5jZSBkZWxldGVGb3J3YXJkaW5nUGF0aHNSZWxhdGVkVG9iZURlbGV0ZWRDb21wb25lbnRJbnN0YW5jZShTdHJpbmcgY29udGFpbmVyQ29tcG9uZW50SWQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29tcG9uZW50VHlwZUVudW0gY29udGFpbmVyQ29tcG9uZW50VHlwZSwgQ29tcG9uZW50SW5zdGFuY2UgY29tcG9uZW50SW5zdGFuY2UpIHsKKyAgICAgICAgaWYoY29udGFpbmVyQ29tcG9uZW50VHlwZSA9PSBDb21wb25lbnRUeXBlRW51bS5TRVJWSUNFKXsKICAgICAgICAgICAgIExpc3Q8U3RyaW5nPiBwYXRoSURzVG9CZURlbGV0ZWQgPSBnZXRGb3J3YXJkaW5nUGF0aHNSZWxhdGVkVG9Db21wb25lbnRJbnN0YW5jZShjb250YWluZXJDb21wb25lbnRJZCwgY29tcG9uZW50SW5zdGFuY2UuZ2V0TmFtZSgpKTsKICAgICA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b25TdGF0dXMgc3RhdHVzID0gY29tcG9uZW50c1V0aWxzLmNvbnZlcnRGcm9tU3RvcmFnZVJlc3BvbnNlKHVwZGF0ZUdyb3Vwc1Jlcy5yaWdodCgpLnZhbHVlKCksIGNvbnRhaW5lckNvbXBvbmVudFR5cGUpOwotICAgICAgICAgICAgICAgIHJlc3VsdE9wID0gRWl0aGVyLnJpZ2h0KGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChzdGF0dXMsIGNvbXBvbmVudEluc3RhbmNlSWQpKTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgfQotICAgICAgICBpZiAocmVzdWx0T3AuaXNMZWZ0KCkgJiYgQ29sbGVjdGlvblV0aWxzLmlzTm90RW1wdHkoY29udGFpbmVyQ29tcG9uZW50LmdldElucHV0cygpKSkgeworICAgICAgICBsb2cuZGVidWcoIlRoZSBjb21wb25lbnQgaW5zdGFuY2Uge30gaGFzIGJlZW4gcmVtb3ZlZCBmcm9tIGNvbnRhaW5lciBjb21wb25lbnQge30uICIsIGNvbXBvbmVudEluc3RhbmNlSWQsIGNvbnRhaW5lckNvbXBvbmVudCk7CisgICAgICAgIENvbXBvbmVudEluc3RhbmNlIGRlbGV0ZWRJbnN0YW5jZSA9IGZpbmRBbmRSZW1vdmVDb21wb25lbnRJbnN0YW5jZUZyb21Db250YWluZXJDb21wb25lbnQoY29tcG9uZW50SW5zdGFuY2VJZCwgY29udGFpbmVyQ29tcG9uZW50KTsKKworICAgICAgICBpZiAoQ29sbGVjdGlvblV0aWxzLmlzTm90RW1wdHkoY29udGFpbmVyQ29tcG9uZW50LmdldElucHV0cygpKSkgewogICAgICAgICAgICAgTGlzdDxJbnB1dERlZmluaXRpb24+IGlucHV0c1RvRGVsZXRlID0gY29udGFpbmVyQ29tcG9uZW50LmdldElucHV0cygpLnN0cmVhbSgpLmZpbHRlcihpIC0+IGkuZ2V0SW5zdGFuY2VVbmlxdWVJZCgpICE9IG51bGwgJiYgaS5nZXRJb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0ZUNhbldvcmtPbkNvbXBvbmVudChjb250YWluZXJDb21wb25lbnQsIHVzZXJJZCk7Ci0gICAgICAgIGlmICh2YWxpZGF0ZUNhbldvcmtPbkNvbXBvbmVudC5pc1JpZ2h0KCkpIHsKLSAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQodmFsaWRhdGVDYW5Xb3JrT25Db21wb25lbnQucmlnaHQoKS52YWx1ZSgpKTsKLSAgICAgICAgfQotICAgICAgICBpZiAobmVlZExvY2spIHsKLSAgICAgICAgICAgIEVpdGhlcjxCb29sZWFuLCBSZXNwb25zZUZvcm1hdD4gbG9ja0NvbXBvbmVudCA9IGxvY2tDb21wb25lbnQoY29udGFpbmVyQ29tcG9uZW50LCAiYXNzb2NpYXRlUklUb1JJIik7Ci0KLSAgICAgICAgICAgIGlmIChsb2NrQ29tcG9uZW50LmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQobG9ja0NvbXBvbmVudC5yaWdodCgpLnZhbHVlKCkpOwotICAgICAgICAgICAgfQotICAgICAgICB9Ci0KKyAgICAgICAgdmFsaWRhdGVDYW5Xb3JrT25Db21wb25lbnQoY29udGFpbmVyQ29tcG9uZW50LCB1c2VySWQpOworICAgICAgICBib29sZWFuIGZhaWxlZCA9IGZhbHNlOwogICAgICAgICB0cnkgewotCi0gICAgICAgICAgICByZXN1bHRPcCA9IGFzc29jaWF0ZVJJVG9SSU9uR3JhcGgodmFsaWRhdGVDb21wb25lbnRFeGlzdHMubGVmdCgpLnZhbHVlKCksIHJlcXVpcmVtZW50RGVmLCBjb21wb25lbnRUeXBlRW51bSwgaW5UcmFuc2FjdGlvbik7Ci0KLSAgICAgICAgICAgIHJldHVybiByZXN1bHRPcDsKLQotICAgICAgICB9IGZpbmFsbHkgeworICAgICAgICAgICAgaWYgKG5lZWRMb2NrKSB7CisgICAgICAgICAgICAgICAgbG9ja0NvbXBvbmVudChjb250YWluZXJDb21wb25lbnQsICJhc3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FaXRoZXI8Qm9vbGVhbiwgUmVzcG9uc2VGb3JtYXQ+IGxvY2tDb21wb25lbnQgPSBsb2NrQ29tcG9uZW50KGNvbnRhaW5lckNvbXBvbmVudCwgImFzc29jaWF0ZVJJVG9SSSIpOwotICAgICAgICBpZiAobG9ja0NvbXBvbmVudC5pc1JpZ2h0KCkpIHsKLSAgICAgICAgICAgIHJldHVybiBkZWxPa1Jlc3VsdDsKLSAgICAgICAgfQogICAgICAgICB0cnkgeworICAgICAgICAgICAgbG9ja0NvbXBvbmVudChjb250YWluZXJDb21wb25lbnQsICJhc3NvY2lhdGVSSVRvUkkiKTsKICAgICAgICAgICAgIGZvciAoUmVxdWlyZW1lbnRDYXBhYmlsaXR5UmVsRGVmIHJlcXVpcmVtZW50RGVmIDogcmVxdWlyZW1lbnREZWZMaXN0KSB7Ci0gICAgICAgICAgICAgICAgRWl0aGVyPFJlcXVpcmVtZW50Q2FwYWJpbGl0eVJlbERlZiwgUmVzcG9uc2VGb3JtYXQ+IGFjdGlvblJlc3BvbnNlID0gZGlzc29jaWF0ZVJJRnJvbVJJKAotICAgICAgICAgICAgICAgICAgICAgICAgY29tcG9uZW50SWQsIHJlcXVpcmVtZW50RGVmLCBjb250YWluZXJDb21wb25lbnQpOwotCi0gICAgICAgICAgICAgICAgaWYgKGFjdGlvblJlc3BvbnNlLmlzTGVmdCgpKSB7Ci0gICAgICAgICAgICAgICAgICAgIGRlbE9rUmVzdWx0LmFkZChhY3Rpb25SZXNwb25zZS5sZWZ0KCkudmFsdWUoKSk7Ci0gICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIFJlcXVpcmVtZW50Q2FwYWJpbGl0eVJlbERlZiByZXF1aXJlbWVudENhcGFiaWxpdHlSZWxEZWYgPSBkaXNzb2NpYXRlUklGcm9tUkkoCisgICAgICAgICAgICAgICAgICAgICAgICBjb21wb25lbnRJZCwgdXNlcklkLCByZXF1aXJlbWVudERlZiwgY29udGFpbmVyQ29tcG9uZW50LmdldENvbXBvbmVudFR5cGUoKSk7CisgICAgICAgICAgICAgICAgZGVsT2tSZXN1bHQuYWRkKHJlcXVpcmVtZW50Q2FwYWJpbGl0eVJlbERlZik7CiAgICAgICAgICAgICB9Ci0gICAgICAgIH0gZmluYWxseSB7Ci0gICAgICAgICAgICB1bmxvY2tDb21wb25lbnQodmFsaWRhdGVSZXNwb25zZSwgY29udGFpbmVyQ29tcG9uZW50KTsKKyAgICAgICAgfWNhdGNoIChDb21wb25lbnRFeGNlcHRpb24gZSl7CisgICAgICAgICAgICBmYWlsZWQgPSB0cnVlOworICAgICAgICAgICAgdGhyb3cgZTsKKyAgICAgICAgfWZpbmFsbHkgeworICAgICAgICAgICAgdW5sb2NrQ29tcG9uZW50KGZhaWxlZCwgY29udGFpbmVyQ29tcG9uZW50KTsKICAgICAgICAgfQogICAgICAgICByZXR1cm4gZGVsT2tSZXN1bHQ7CiAgICAgfQogCi0gICAgcHVibGljIEVpdGhlcjxSZXF1aXJlbWVudENhcGFiaWxpdHlSZWxEZWYsIFJlc3BvbnNlRm9ybWF0PiBkaXNzb2NpYXRlUklGcm9tUkkoCi0gICAgICAgICAgICBTdHJpbmcgY29tcG9uZW50SWQsIFN0cmluZyB1c2VySWQsIFJlcXVpcmVtZW50Q2FwYWJpbGl0eVJlbERlZiByZXF1aXJlbWVudERlZiwgQ29tcG9uZW50VHlwZUVudW0gY29tcG9uZW50VHlwZUVudW0pIHsKLSAgICAgICAgRWl0aGVyPENvbXBvbmVudCwgUmVzcG9uc2VGb3JtYXQ+IHZhbGlkYXRlUmVzcG9uc2UgPSB2YWxpZGF0ZURpc3NvY2lhdGVSSShjb21wb25lbnRJZCwgIHVzZXJJZCwgIGNvbXBvbmVudFR5cGVFbnVtKTsKLSAgICAgICAgaWYodmFsaWRhdGVSZXNwb25zZS5pc1JpZ2h0KCkpCi0gICAgICAgIHsKLSAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQodmFsaWRhdGVSZXNwb25zZS5yaWdodCgp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Ci0gICAgICAgICAgICBsb2cuZGVidWcoIkZhaWxlZCB0byBkaXNzb2NhaXRlIG5vZGUgIHt9IGZyb20gbm9kZSB7fSIsIHJlcXVpcmVtZW50RGVmLmdldEZyb21Ob2RlKCksIHJlcXVpcmVtZW50RGVmLmdldFRvTm9kZSgpKTsKLSAgICAgICAgICAgIFN0cmluZyBmcm9tTmFtZU9ySWQgPSAiIjsKLSAgICAgICAgICAgIFN0cmluZyB0b05hbWVPcklkID0gIiI7Ci0gICAgICAgICAgICBFaXRoZXI8Q29tcG9uZW50SW5zdGFuY2UsIFN0b3JhZ2VPcGVyYXRpb25TdGF0dXM+IGZyb21SZXN1bHQgPSBnZXRSZXNvdXJjZUluc3RhbmNlQnlJZCgKLSAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyQ29tcG9uZW50LCByZXF1aXJlbWVudERlZi5nZXRGcm9tTm9kZSgpKTsKLSAgICAgICAgICAgIEVpdGhlcjxDb21wb25lbnRJbnN0YW5jZSwgU3RvcmFnZU9wZXJhdGlvblN0YXR1cz4gdG9SZXN1bHQgPSBnZXRSZXNvdXJjZUluc3RhbmNlQnlJZCgKLSAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyQ29tcG9uZW50LCByZXF1aXJlbWVudERlZi5nZXRUb05vZGUoKSk7CisgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJGYWlsZWQgdG8gZGlzc29jYWl0ZSBub2RlICB7fSBmcm9tIG5vZGUge30iLCByZXF1aXJlbWVudERlZi5nZXRGcm9tTm9kZSgpLCByZXF1aXJlbWVudERlZi5nZXRUb05vZGUoKSk7CisgICAgICAgICAgICAgICAgU3RyaW5nIGZyb21OYW1lT3JJZCA9ICIiOworICAgICAgICAgICAgICAgIFN0cmluZyB0b05hbWVPcklkID0gIiI7CisgICAgICAgICAgICAgICAgRWl0aGVyPENvbXBvbmVudEluc3RhbmNlLCBTdG9yYWdlT3BlcmF0aW9uU3RhdHVzPiBmcm9tUmVzdWx0ID0gZ2V0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AgICAgICAgICAgICAgdGhyb3cgbmV3IEJ5QWN0aW9uU3RhdHVzQ29tcG9uZW50RXhjZXB0aW9uKAorICAgICAgICAgICAgICAgICAgICAgICAgY29tcG9uZW50c1V0aWxzLmNvbnZlcnRGcm9tU3RvcmFnZVJlc3BvbnNlRm9yUmVzb3VyY2VJbnN0YW5jZShyZXN1bHQucmlnaHQoKS52YWx1ZSgpLCB0cnVlKSwKKyAgICAgICAgICAgICAgICAgICAgICAgIGZyb21OYW1lT3JJZCwgdG9OYW1lT3JJZCwgcmVxdWlyZW1lbnREZWYuZ2V0UmVsYXRpb25zaGlwcygpLmdldCgwKS5nZXRSZWxhdGlvbigpLmdldFJlcXVpcmVtZW50KCkpOwogICAgICAgICAgICAgfQotICAgICAgICAgICAgaWYgKHRvUmVzdWx0LmlzTGVmdCgpKSB7Ci0gICAgICAgICAgICAgICAgdG9OYW1lT3JJZCA9IHRvUmVzdWx0LmxlZnQoKS52YWx1ZSgpLmdldE5hbWUoKTsKLSAgICAgICAgICAgIH0KLQotICAgICAgICAgICAgcmVzdWx0T3AgPSBFaXRoZXIKLSAgICAgICAgICAgICAgICAgICAgLnJpZ2h0KGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdCgKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21wb25lbnRzVXRpbHMuY29udmVydEZyb21TdG9yYWdlUmVzcG9uc2VGb3JSZXNvdXJjZUluc3RhbmNlKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0LnJpZ2h0KCkudmFsdWUoKSwgdHJ1ZSksIGZyb21OYW1lT3JJZCwgdG9OYW1lT3JJZCwgcmVxdWlyZW1lbnREZWYuZ2V0UmVsYXRpb25zaGlwcygpLmdldCgwKS5nZXRSZWxhdGlvbigpLmdldFJlcXVpcmVtZW50KCkpKTsKLSAgICAgICAgICAgIHJldHVybiByZXN1bHRPcDsKKyAgICAgICAgfWNhdGNoIChDb21wb25lbnRFeGNlcHRpb24gZSl7CisgICAgICAgICAgICBmYWlsZWQgPSB0cnVlOworICAgICAgICAgICAgdGhyb3cgZTsKKyAgICAgICAgfWZpbmFsbHkgeworICAgICAgICAgICAgdW5sb2NrQ29tcG9uZW50KGZhaWxlZCwgY29udGFpbmVyQ29tcG9uZW50KTsKICAgICAgICAgfQogICAgIH0KLQogICAgIC8qKgogICAgICAqIEFsbG93cyB0byBnZXQgcmVsYXRpb24gY29udGFpbmVkIGluIHNwZWNpZmllZCBjb21wb25lbnQgYWNjb3JkaW5nIHRvIHJlY2VpdmVkIElkCiAgICAgICogQHBhcmFtIGNvbXBvbmVudElkCkBAIC0xNDczLDIzICsxNDA4LDE0IEBACiAgICAgICAgICAgICBFaXRoZXI8b3JnLm9wZW5lY29tcC5zZGMuYmUubW9kZWwuQ29tcG9uZW50LCBSZXNwb25zZUZvcm1hdD4gdmFsaWRhdGVDb21wb25lbnRFeGlzdHMgPSBudWxsOwogICAgICAgICAgICAgUmVxdWlyZW1lbnRDYXBhYmlsaXR5UmVsRGVmIGZvdW5kUmVsYXRpb24gPSBudWxsOwogCi0gICAgICAgICAgICB2YWxpZGF0ZVVzZXJFeGlzdHModXNlcklkLCAiZ2V0IHJlbGF0aW9uIGJ5IElkIiwgZmFsc2UpOwotCi0gICAgICAgICAgICBpZihyZXN1bHRPcCA9PSBudWxsKXsKLSAgICAgICAgICAgICAgICB2YWxpZGF0ZUNvbXBvbmVudEV4aXN0cyA9IHZhbGlkYXRlQ29tcG9uZW50RXhpc3RzKGNvbXBvbmVudElkLCBjb21wb25lbnRUeXBlRW51bSwgbnVsbCk7Ci0gICAgICAgICAgICAgICAgaWYgKHZhbGlkYXRlQ29tcG9uZW50RXhpc3RzLmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgICAgICByZXN1bHRPcCA9IEVpdGhlci5yaWdodCh2YWxpZGF0ZUNvbXBvbmVudEV4aXN0cy5yaWdodCgpLnZhbHVlKCkpOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGlmKHJlc3VsdE9wID09IG51bGwpewotICAgICAgICAgICAgICAgIGNvbnRhaW5lckNvbXBvbmVudCA9IHZhbGlkYXRlQ29tcG9uZW50RXhpc3RzLmxlZnQoKS52YWx1ZSgpOwotICAgICAgICAgICAgICAgIExpc3Q8UmVxdWlyZW1lbnRDYXBhYmlsaXR5UmVsRGVmPiByZXF1aXJlbWVudENhcGFiaWxpdHlSZWxhdGlvbnMgPSBjb250YWluZXJDb21wb25lbnQuZ2V0Q29tcG9uZW50SW5zdGFuY2VzUmVsYXRpb25zKCk7Ci0gICAgICAgICAgICAgICAgZm91bmRSZWxhdGlvbiA9IGZpbmRSZWxhdGlvbihyZWxhdGlvbklkLCByZXF1aXJlbWVudENhcGFiaWxpdHlSZWxhdGlvbnMpOwotICAgICAgICAgICAgICAgIGlmKGZvdW5kUmVsYXRpb24gPT0gbnVsbCl7Ci0gICAgICAgICAgICAgICAgICAgIFJlc3BvbnNlRm9ybWF0IHJlc3BvbnNlRm9ybWF0ID0gY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5SRUxBVElPTl9OT1RfRk9VTkQsIHJlbGF0aW9uSWQsIGNvbXBvbmVudElkKTsKLSAgICAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJSZWxhdGlvbiB3aXRoIGlkIHt9IHdhcyBub3QgZm91bmQgb24gdGhlIGNvbXBvbmVudCIsIHJlbGF0aW9uSWQsIGNvbXBvbmVudElkKTsKLSAgICAgICAgICAgICAgICAgICAgcmVzdWx0T3AgPSBFaXRoZXIucmlnaHQocmVzcG9uc2VGb3JtYXQpOwotICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIHZhbGlkYXRlVXNlckV4aXN0cyh1c2VySWQpOworICAgICAgICAgICAgY29udGFpbmVyQ29tcG9uZW50ID0gdmFsaWRhdGVDb21wb25lbnRFeGlzdHMoY29tcG9uZW50SWQsIGNvbXBvbmVudFR5cGVFbnVtLCBudWxsKTsKKyAgICAgICAgICAgIExpc3Q8UmVxdWlyZW1lbnRDYXBhYmlsaXR5UmVsRGVmPiByZXF1aXJlbWVudENhcGFiaWxpdHlSZWxhdGlvbnMgPSBjb250YWluZXJDb21wb25lbnQuZ2V0Q29tcG9uZW50SW5zdGFuY2VzUmVsYXRpb25zKCk7CisgICAgICAgICAgICBmb3VuZFJlbGF0aW9uID0gZmluZFJlbGF0aW9uKHJlbGF0aW9uSWQsIHJlcXVpcmVtZW50Q2FwYWJpbGl0eVJlbGF0aW9ucyk7CisgICAgICAgICAgICBpZihmb3VuZFJlbGF0aW9uID09IG51bGwpeworICAgICAgICAgICAgICAgIFJlc3BvbnNlRm9ybWF0IHJlc3BvbnNlRm9ybWF0ID0gY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5SRUxBVElPTl9OT1RfRk9VTkQsIHJlbGF0aW9uSWQsIGNvbXBvbmVudElkKTsKKyAgICAgICAgICAgICAgICBsb2cuZGVidWcoIlJlbGF0aW9uIHdpdGggaWQge30gd2FzIG5vdCBmb3VuZCBvbiB0aGUgY29tcG9uZW50IiwgcmVsYXRpb25JZCwgY29tcG9uZW50SWQpOworICAgICAgICAgICAgICAgIHJlc3VsdE9wID0gRWl0aGVyLnJpZ2h0KHJlc3BvbnNlRm9ybWF0KTsKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIGlmKHJlc3VsdE9wID09IG51bGwpewogICAgICAgICAgICAgICAgIHJlc3VsdE9wID0gc2V0UmVsYXRlZENhcGFiaWxpdHkoZm91bmRSZWxhdGlvbiwgY29udGFpbmVyQ29tcG9uZW50KTsKQEAgLTE1MjYsNyArMTQ1Miw3IEBACiAgICAgICAgIH0KICAgICAgICAgaWYocmVzdWx0ID09IG51bGwpewogICAgICAgICAgICAgZm9yKExpc3Q8UmVxdWlyZW1lbnREZWZpbml0aW9uPiByZXF1aXJlbWVudHM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USU9OKSk7Ci0gICAgICAgICAgICByZXR1cm4gcmVzdWx0T3A7CisgICAgICAgICAgICBBY3Rpb25TdGF0dXMgYWN0aW9uU3RhdHVzID0gY29tcG9uZW50c1V0aWxzLmNvbnZlcnRGcm9tU3RvcmFnZVJlc3BvbnNlKGdldFJlc291cmNlUmVzdWx0LnJpZ2h0KCkudmFsdWUoKSwgY29tcG9uZW50VHlwZUVudW0pOworICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoYWN0aW9uU3RhdHVzLCBjb21wb25lbnRJZCkpOwogICAgICAgICB9CiAgICAgICAgIENvbXBvbmVudCBjb250YWluZXJDb21wb25lbnQgPSBnZXRSZXNvdXJjZVJlc3VsdC5sZWZ0KCkudmFsdWUoKTsKIAogICAgICAgICBpZiAoIUNvbXBvbmVudFZhbGlkYXRpb25VdGlscy5jYW5Xb3JrT25Db21wb25lbnQoY29udGFpbmVyQ29tcG9uZW50LCB1c2VySWQpKSB7CisgICAgICAgICAgICBpZiAoY29udGFpbmVyQ29tcG9uZW50LmlzQXJjaGl2ZWQoKSkgeworICAgICAgICAgICAgICAgIGxvZy5pbmZvKCJDb21wb25lbnQgaXMgYXJjaGl2ZWQuIENvbXBvbmVudCBpZDoge30iLCBjb21wb25lbnRJZCk7CisgICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLkNPTVBPTkVOVF9JU19BUkNISVZFRCwgY29udGFpbmVyQ29tcG9uZW50LmdldE5hbWUoKSkpOworICAgICAgICAgICAgfQogICAgICAgICAgICAgbG9nLmluZm8oIlJlc3RyaWN0ZWQgb3BlcmF0aW9uIGZvciB1c2VyOiB7fSBvbiBzZXJ2aWNlIHt9IiwgdXNlcklkLCBjb21wb25lbnRJZCk7Ci0gICAgICAgICAgICByZXN1bH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AgICBMaXN0IDxDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5PiB1cGRhdGVkUHJvcGVydGllcyA9IG5ldyBBcnJheUxpc3Q8PigpOwogICAgICAgICB0cnkgewogICAgICAgICAgICAgZm9yIChDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5IHByb3BlcnR5OiBwcm9wZXJ0aWVzKSB7CisgICAgICAgICAgICAgICAgdmFsaWRhdGVNYW5kYXRvcnlGaWVsZHMocHJvcGVydHkpOworICAgICAgICAgICAgICAgIENvbXBvbmVudEluc3RhbmNlUHJvcGVydHkgY29tcG9uZW50SW5zdGFuY2VQcm9wZXJ0eSA9IHZhbGlkYXRlUHJvcGVydHlFeGlzdHNPbkNvbXBvbmVudChwcm9wZXJ0eSwgY29udGFpbmVyQ29tcG9uZW50LCBmb3VuZFJlc291cmNlSW5zdGFuY2UpOwogICAgICAgICAgICAgICAgIFN0cmluZyBwcm9wZXJ0eVBhcmVudFVuaXF1ZUlkID0gcHJvcGVydHkuZ2V0UGFyZW50VW5pcXVlSWQoKTsKICAgICAgICAgICAgICAgICBFaXRoZXI8U3RyaW5nLCBSZXNwb25zZUZvcm1hdD4gdXBkYXRlZFByb3BlcnR5VmFsdWUgPSB1cGRhdGVQcm9wZXJ0eU9iamVjdFZhbHVlKHByb3BlcnR5LCBmYWxzZSk7CisgICAgICAgICAgICAgICAgaWYgKHVwZGF0ZWRQcm9wZXJ0eVZhbHVlLmlzUmlnaHQoKSkgeworICAgICAgICAgICAgICAgICAgICBsb2cuZXJyb3IoIkZhaWxlZCB0byB1cGRhdGUgcHJvcGVydHkgb2JqZWN0IHZhbHVlIG9mIHByb3BlcnR5OiB7fSIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvcGVydHkpOworICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgQnlSZXNwb25zZUZvcm1hdENvbXBvbmVudEV4Y2VwdGlvbih1cGRhdGVkUHJvcGVydHlWYWx1ZS5yaWdodCgpLnZhbHVlKCkpOworICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBPcHRpb25hbDxDYXBhYmlsaXR5RGVmaW5pdGlvbj4KICAgICAgICAgICAgICAgICAgICAgICAgIGNhcFByb3BEZWZpbml0aW9uID0gZ2V0UHJvcGVydHlDYXBhYmlsaXR5T2ZDaGlsZEluc3RhbmNlKHByb3BlcnR5UGFyZW50VW5pcXVlSWQsIGZvdW5kUmVzb3VyY2VJbnN0YW5jZS5nZXRDYXBhYmlsaXRpZXMoKSk7CiAgICAgICAgICAgICAgICAgaWYoY2FwUHJvcERlZmluaXRpb24uaXNQcmVzZW50KCkpIHsKQEAgLTE4MDEsNiArMTcwNiw3IEBACiAgICAgICAgICAgICAgICAgZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgIHVwZGF0ZWRQcm9wZXJ0eVZhbHVlLmJpbWFwKHVwZGF0ZWRWYWx1ZSAtPiB1cGRhdGVQcm9wZXJ0eU9uQ29udGFpbmVyQ29tcG9uZW50KHByb3BlcnR5LCB1cGRhdGVkVmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyQ29tcG9uZW50LCBmb3VuZFJlc291cmNlSW5zdGFuY2UpLCBFaXRoZXI6OnJpZ2h0KTsKKyAgICAgICAgICAgICAgICAgICAgdXBkYXRlZFByb3BlcnRpZXMuYWRkKGNvbXBvbmVudEluc3RhbmNlUHJvcGVydHkpOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KIApAQCAtMTgxMCw3ICsxNzE2LDcgQEAKICAgICAgICAgICAgICAgICByZXN1bHRPcCA9IEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXRGb3JSZXNvdXJjZUluc3RhbmNlUHJvcGVydHkoYWN0aW9uU3RhdHVzLCAiIikpOwogICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHRPcDsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIHJlc3VsdE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ID0gbmV3IFN0cmluZ0J1aWxkZXIoY29tcG9uZW50SW5zdGFuY2VVbmlxdWVJZCk7Ci0KLSAgICAgICAgc2IuYXBwZW5kKE1vZGVsQ29udmVydGVyLkNBUF9QUk9QX0RFTElNKS5hcHBlbmQocHJvcE93bmVyKS5hcHBlbmQoTW9kZWxDb252ZXJ0ZXIuQ0FQX1BST1BfREVMSU0pCi0gICAgICAgICAgICAgICAgLmFwcGVuZChjYXBhYmlsaXR5VHlwZSkuYXBwZW5kKE1vZGVsQ29udmVydGVyLkNBUF9QUk9QX0RFTElNKS5hcHBlbmQoY2FwYWJpbGl0eU5hbWUpOwotICAgICAgICBTdHJpbmcgY2FwS2V5ID0gc2IudG9TdHJpbmcoKTsKIAogICAgICAgICBSZXNwb25zZUZvcm1hdCBhY3Rpb25TdGF0dXMgPSB1cGRhdGVDYXBQcm9wT25Db250YWluZXJDb21wb25lbnQocHJvcGVydHksIG5ld1ZhbHVlLCBjb250YWluZXJDb21wb25lbnQsCi0gICAgICAgICAgICAgICAgZm91bmRSZXNvdXJjZUluc3RhbmNlLCBjYXBhYmlsaXR5VHlwZSwgY2FwYWJpbGl0eU5hbWUsIGNvbXBvbmVudEluc3RhbmNlVW5pcXVlSWQsIGNhcEtleSk7CisgICAgICAgICAgICAgICAgZm91bmRSZXNvdXJjZUluc3RhbmNlLCBjYXBhYmlsaXR5VHlwZSwgY2FwYWJpbGl0eU5hbWUsIGNvbXBvbmVudEluc3RhbmNlVW5pcXVlSWQpOwogICAgICAgICBpZiAoYWN0aW9uU3RhdHVzICE9IG51bGwpIHsKICAgICAgICAgICAgIHJldHVybiBhY3Rpb25TdGF0dXM7CiAgICAgICAgIH0KQEAgLTE4NzcsNyArMTc5MCw3IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29tcG9uZW50IGNvbnRhaW5lckNvbXBvbmVudCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb21wb25lbnRJbnN0YW5jZSBmb3VuZFJlc291cmNlSW5zdGFuY2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nIGNhcGFiaWxpdHlUeXBlLCBTdHJpbmcgY2FwYWJpbGl0eU5hbWUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nIGNvbXBvbmVudEluc3RhbmNlVW5pcXVlSWQsIFN0cmluZyBjYXBLZXkpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmcgY29tcG9uZW50SW5zdGFuY2VVbmlxdWVJZCkgewogICAgICAgICBNYXA8U3RyaW5nLCBMaXN0PENhcGFiaWxpdHlEZWZpbml0aW9uPj4gY2FwYWJpbGl0aWVzID0KICAgICAgICAgICAgICAgICBPcHRpb25hbC5vZk51bGxhYmxlKGZvdW5kUmVzb3VyY2VJbnN0YW5jZS5nZXRDYXBhYmlsaXRpZXMoKSkub3JFbHNlKENvbGxlY3Rpb25zLmVtcHR5TWFwKCkpOwogICAgICAgICBMaXN0PENhcGFiaWxpdHlEZWZpbml0aW9uPiBjYXBQZXJUeXBlID0KQEAgLTE4OTEsNiArMTgwNCw3IEBACiAgICAgICAgICAgICAgICAgICAgICAgICBjYXBQcm9wZXJ0aWVzLnN0cmVhbSgpLmZpbHRlcihwIC0+IHAuZ2V0VW5pcXVlSWQoKS5lcXVhbHMocHJvcGVydHkuZ2V0VW5pcXVlSWQoKSkpLmZpbmRBbnkoKTsKICAgICAgICAgICAgICAgICBTdG9yYWdlT3BlcmF0aW9uU3RhdHVzIHN0YXR1czsKICAgICAgICAgICAgICAgICBpZiAoaW5zdGFuY2VQcm9wZXJ0eS5pc1ByZXNlbnQoKSkgeworICAgICAgICAgICAgICAgICAgICBTdHJpbmcgY2FwS2V5ID0gTW9kZWxDb252ZXJ0ZXIuYnVpbGRDYXBhYmlsaXR5UHJvcGVydHlLZXkoZm91bmRSZXNvdXJjZUluc3RhbmNlLmdldE9yaWdpblR5cGUoKS5pc0F0b21pY1R5cGUoKSwgY2FwYWJpbGl0eVR5cGUsIGNhcGFiaWxpdHlOYW1lLCBjb21wb25lbnRJbnN0YW5jZVVuaXF1ZUlkLCBjYXAuZ2V0KCkpOwogICAgICAgICAgICAgICAgICAgICBpbnN0YW5jZVByb3BlcnR5LmdldCgpLnNldFZhbHVlKG5ld1ZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgTGlzdDxTdHJpbmc+IHBhdGggPSBuZXcgQXJyYXlMaXN0PD4oKTsKICAgICAgICAgICAgICAgICAgICAgcGF0aC5hZGQoY29tcG9uZW50SW5zdGFuY2VVbmlxdWVJZCk7CkBAIC0xOTExLDM1ICsxODI1LDU5IEBACiAgICAgICAgIHJldHVybiBudWxsOwogICAgIH0KIAotICAgIHByaXZhdGUgUmVzcG9uc2VGb3JtYXQgdXBkYXRlUHJvcGVydHlPbkNvbnRhaW5lckNvbXBvbmVudChDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5IHByb3BlcnR5LCBTdHJpbmcgbmV3VmFsdWUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbXBvbmVudCBjb250YWluZXJDb21wb25lbnQsIENvbXBvbmVudEluc3RhbmNlIGZvdW5kUmVzb3VyY2VJbnN0YW5jZSkgewotICAgICAgICBMaXN0PENvbXBvbmVudEluc3RhbmNlUHJvcGVydHk+IGluc3RhbmNlUHJvcGVydGllcyA9Ci0gICAgICAgICAgICAgICAgY29udGFpbmVyQ29tcG9uZW50LmdldENvbXBvbmVudEluc3RhbmNlc1Byb3BlcnRpZXMoKS5nZXQoZm91bmRSZXNvdXJjZUluc3RhbmNlLmdldFVuaXF1ZUlkKCkpOwotICAgICAgICBPcHRpb25hbDxDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5PiBpbnN0YW5jZVByb3BlcnR5ID0KLSAgICAgICAgICAgICAgICBpbnN0YW5jZVByb3BlcnRpZXMuc3RyZWFtKCkuZmlsdGVyKHAgLT4gcC5nZXRVbmlxdWVJZCgpLmVxdWFscyhwcm9wZXJ0eS5nZXRVbmlxdWVJZCgpKSkuZmluZEFueSgpOworICAgIHByaXZhdGUgUmVzcG9uc2VGb3JtYXQgdXBkYXRlUHJvcGVydHlPbkNvbnRhaW5lckNvbXBvbmVudChDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5IGluc3RhbmNlUHJvcGVydHksIFN0cmluZyBuZXdWYWx1ZSwgQ29tcG9uZW50IGNvbnRhaW5lckNvbXBvbmVudCwgQ29tcG9uZW50SW5zdGFuY2UgZm91bmRSZXNvdXJjZUluc3RhbmNlKSB7CiAgICAgICAgIFN0b3JhZ2VPcGVyYXRpb25TdGF0dXMgc3RhdHVzOwotICAgICAgICBpbnN0YW5jZVByb3BlcnR5LmdldCgpLnNldFZhbHVlKG5ld1ZhbHVlKTsKLSAgICAgICAgaWYgKGluc3RhbmNlUHJvcGVydHkuaXNQcmVzZW50KCkpIHsKLSAgICAgICAgICAgIHN0YXR1cyA9IHRvc2NhT3BlcmF0aW9uRmFjYWRlCi0gICAgICAgICAgICAgICAgICAgIC51cGRhdGVDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5KGNvbnRhaW5lckNvbXBvbmVudCwgZm91bmRSZXNvdXJjZUluc3RhbmNlLmdldFVuaXF1ZUlkKCksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvcGVydHkpOwotICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgc3RhdHVzID0gdG9zY2FPcGVyYXRpb25GYWNhZGUKLSAgICAgICAgICAgICAgICAgICAgLmFkZENvbXBvbmVudEluc3RhbmNlUHJvcGVydHkoY29udGFpbmVyQ29tcG9uZW50LCBmb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KyAgICAgICAgTWFwPFN0cmluZywgRGF0YVR5cGVEZWZpbml0aW9uPiBhbGxEYXRhVHlwZXMgPSBhbGxEYXRhVHlwZXNFaXRoZXIubGVmdCgpLnZhbHVlKCk7CisgICAgICAgIFN0cmluZyBwcm9wZXJ0eVR5cGUgPSBwcm9wZXJ0eS5nZXRUeXBlKCk7CisgICAgICAgIFN0cmluZyBpbm5lclR5cGUgPSBnZXRJbm5lclR5cGUocHJvcGVydHkpOworCisgICAgICAgIC8vIFNwZWNpZmljIFVwZGF0ZSBMb2dpYworICAgICAgICBFaXRoZXI8T2JqZWN0LCBCb29sZWFuPiBpc1ZhbGlkID0gcHJvcGVydHlPcGVyYXRpb24udmFsaWRhdGVBbmRVcGRhdGVQcm9wZXJ0eVZhbHVlKHByb3BlcnR5LmdldFR5cGUoKSwgbmV3VmFsdWUsIHRydWUsIGlubmVyVHlwZSwgYWxsRGF0YVR5cGVzKTsKKyAgICAgICAgaWYgKGlzVmFsaWQuaXNSaWdodCgpKSB7CisgICAgICAgICAgICBCb29sZWFuIHJlcyA9IGlzVmFsaWQucmlnaHQoKS52YWx1ZSgpOworICAgICAgICAgICAgaWYgKCFyZXMpIHsKKyAgICAgICAgICAgICAgICBsb2cuZXJyb3IoIkludmFsaWQgdmFsdWUge30gb2YgcHJvcGVydHkge30gIiwgbmV3VmFsdWUsIHByb3BlcnR5LmdldE5hbWUoKSk7CisgICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLklOVkFMSURfQ09OVEVOVCkpOworICAgICAgICAgICAgfQorICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgT2JqZWN0IG9iamVjdCA9IGlzVmFsaWQubGVmdCgpLnZhbHVlKCk7CisgICAgICAgICAgICBpZiAob2JqZWN0ICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICBuZXdWYWx1ZSA9IG9iamVjd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RJZCk7Ci0gICAgICAgICAgICByZXN1bHRPcCA9IEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLlJFU1RSSUNURURfT1BFUkFUSU9OKSk7Ci0gICAgICAgICAgICByZXR1cm4gcmVzdWx0T3A7CisgICAgICAgICAgICBBY3Rpb25TdGF0dXMgYWN0aW9uU3RhdHVzID0gY29tcG9uZW50c1V0aWxzLmNvbnZlcnRGcm9tU3RvcmFnZVJlc3BvbnNlKGdldFJlc291cmNlUmVzdWx0LnJpZ2h0KCkudmFsdWUoKSwgY29tcG9uZW50VHlwZUVudW0pOworICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoYWN0aW9uU3RhdHVzLCBjb21wb25lbnRJZCkpOwogICAgICAgICB9CiAgICAgICAgIENvbXBvbmVudCBjb250YWluZXJDb21wb25lbnQgPSBnZXRSZXNvdXJjZVJlc3VsdC5sZWZ0KCkudmFsdWUoKTsKIAogICAgICAgICBpZiAoIUNvbXBvbmVudFZhbGlkYXRpb25VdGlscy5jYW5Xb3JrT25Db21wb25lbnQoY29udGFpbmVyQ29tcG9uZW50LCB1c2VySWQpKSB7CisgICAgICAgICAgICBpZiAoY29udGFpbmVyQ29tcG9uZW50LmlzQXJjaGl2ZWQoKSkgeworICAgICAgICAgICAgICAgIGxvZy5pbmZvKCJDb21wb25lbnQgaXMgYXJjaGl2ZWQuIENvbXBvbmVudCBpZDoge30iLCBjb21wb25lbnRJZCk7CisgICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLkNPTVBPTkVOVF9JU19BUkNISVZFRCwgY29udGFpbmVyQ29tcG9uZW50LmdldE5hbWUoKSkpOworICAgICAgICAgICAgfQogICAgICAgICA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bnB1dHMpOwogICAgICAgICAgICAgcmV0dXJuIHJlc3VsdE9wOwogCiAgICAgICAgIH0gZmluYWxseSB7CkBAIC0yMDc3LDEyICsyMDE3LDIwIEBACiAKICAgICB9CiAKLSAgICBwdWJsaWMgRWl0aGVyPENvbXBvbmVudEluc3RhbmNlUHJvcGVydHksIFJlc3BvbnNlRm9ybWF0PiBjcmVhdGVPclVwZGF0ZUdyb3VwSW5zdGFuY2VQcm9wZXJ0eVZhbHVlKENvbXBvbmVudFR5cGVFbnVtIGNvbXBvbmVudFR5cGVFbnVtLCBTdHJpbmcgY29tcG9uZW50SWQsIFN0cmluZyByZXNvdXJjZUluc3RhbmNlSWQsIFN0cmluZyBncm91cEluc3RhbmNlSWQsIENvbXBvbmVudEluc3RhbmNlUHJvcGVydHkgcHJvcGVydHksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmcgdXNlcklkKSB7CisgICAgcHJpdmF0ZSBDb21wb25lbnRJbnN0YW5jZUlucHV0IHZhbGlkYXRlSW5wdXRFeGlzdHNPbkNvbXBvbmVudChDb21wb25lbnRJbnN0YW5jZUlucHV0IGlucHV0LCBDb21wb25lbnQgY29udGFpbmVyQ29tcG9uZW50LCBDb21wb25lbnRJbnN0YW5jZSBmb3VuZFJlc291cmNlSW5zdGFuY2UpIHsKKyAgICAgICAgTGlzdDxDb21wb25lbnRJbnN0YW5jZUlucHV0PiBpbnN0YW5jZVByb3BlcnRpZXMgPSBjb250YWluZXJDb21wb25lbnQuZ2V0Q29tcG9uZW50SW5zdGFuY2VzSW5wdXRzKCkuZ2V0KGZvdW5kUmVzb3VyY2VJbnN0YW5jZS5nZXRVbmlxdWVJZCgpKTsKKyAgICAgICAgT3B0aW9uYWw8Q29tcG9uZW50SW5zdGFuY2VJbnB1dD4gaW5zdGFuY2VJbnB1dCA9IGluc3Rhb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Z2VSZXNwb25zZUZvclJlc291cmNlSW5zdGFuY2VQcm9wZXJ0eShyZXN1bHQucmlnaHQoKS52YWx1ZSgpKTsKLQotICAgICAgICAgICAgICAgICAgICByZXN1bHRPcCA9IEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXRGb3JSZXNvdXJjZUluc3RhbmNlUHJvcGVydHkoYWN0aW9uU3RhdHVzLCAiIikpOwotCi0gICAgICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHRPcDsKLSAgICAgICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgRWl0aGVyPENvbXBvbmVudEluc3RhbmNlSW5wdXQsIFN0b3JhZ2VPcGVyYXRpb25TdGF0dXM+IHJlc3VsdCA9IGNvbXBvbmVudEluc3RhbmNlT3BlcmF0aW9uLnVwZGF0ZUlucHV0VmFsdWVJblJlc291cmNlSW5zdGFuY2UoaW5wdXRQcm9wZXJ0eSwgcmVzb3VyY2VJbnN0YW5jZUlkLCB0cnVlKTsKLQotICAgICAgICAgICAgICAgIGlmIChyZXN1bHQuaXNMZWZ0KCkpIHsKLSAgICAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJJbnB1dCB2YWx1ZSB7fSB3YXMgdXBkYXRlZCBvbiBncmFwaC4iLCBpbnB1dFByb3BlcnR5LmdldFZhbHVlVW5pcXVlVWlkKCkpOwotICAgICAgICAgICAgICAgICAgICBDb21wb25lbnRJbnN0YW5jZUlucHV0IGluc3RhbmNlUHJvcGVydHkgPSByZXN1bHQubGVmdCgpLnZhbHVlKCk7Ci0KLSAgICAgICAgICAgICAgICAgICAgcmVzdWx0T3AgPSBFaXRoZXIubGVmdChpbnN0YW5jZVByb3BlcnR5KTsKLSAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdE9wOwotCi0gICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJGYWlsZWQgdG8gdXBkYXRlIHByb3BlcnR5IHZhbHVlIHt9IGluIHJlc291cmNlIGluc3RhbmNlIHt9IiwgaW5wdXRQcm9wZXJ0eSwgcmVzb3VyY2VJbnN0YW5jZUlkKTsKLQotICAgICAgICAgICAgICAgICAgICBBY3Rpb25TdGF0dXMgYWN0aW9uU3RhdHVzID0gY29tcG9uZW50c1V0aWxzLmNvbnZlcnRGcm9tU3RvcmFnZVJlc3BvbnNlRm9yUmVzb3VyY2VJbnN0YW5jZVByb3BlcnR5KHJlc3VsdC5yaWdodCgpLnZhbHVlKCkpOwotCi0gICAgICAgICAgICAgICAgICAgIHJlc3VsdE9wID0gRWl0aGVyLnJpZ2h0KGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdEZvclJlc291cmNlSW5zdGFuY2VQcm9wZXJ0eShhY3Rpb25TdGF0dXMsICIiKSk7Ci0KLSAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdE9wOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIH0KLQotICAgICAgICB9IGZpbmFsbHkgewotICAgICAgICAgICAgaWYgKHJlc3VsdE9wID09IG51bGwgfHwgcmVzdWx0T3AuaXNSaWdodCgpKSB7Ci0gICAgICAgICAgICAgICAgamFudXNHcmFwaERhby5yb2xsYmFjaygpOwotICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICBqYW51c0dyYXBoRGFvLmNvbW1pdCgpOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgLy8gdW5sb2NrIHJlc291cmNlCi0gICAgICAgICAgICBncmFwaExvY2tPcGVyYXRpb24udW5sb2NrQ29tcG9uZW50KGNvbXBvbmVudElkLCBjb21wb25lbnRUeXBlRW51bS5nZXROb2RlVHlwZSgpKTsKLSAgICAgICAgfQotCi0gICAgfQotCiAgICAgcHVibGljIEVpdGhlcjxDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5LCBS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dHJpbmc+LCBSZXNwb25zZUZvcm1hdD4gZm9yd2FyZGluZ1BhdGhPblZlcnNpb25DaGFuZ2UoU3RyaW5nIGNvbnRhaW5lckNvbXBvbmVudFBhcmFtLApAQCAtMjM1MCwyMCArMjIwNCwxMSBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmcgY29tcG9uZW50SW5zdGFuY2VJZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29tcG9uZW50SW5zdGFuY2UgbmV3Q29tcG9uZW50SW5zdGFuY2UpIHsKICAgICAgICAgRWl0aGVyPFNldDxTdHJpbmc+LCBSZXNwb25zZUZvcm1hdD4gcmVzdWx0T3A7Ci0gICAgICAgIEVpdGhlcjxDb21wb25lbnRUeXBlRW51bSwgUmVzcG9uc2VGb3JtYXQ+IHZhbGlkYXRlQ29tcG9uZW50VHlwZSA9IHZhbGlkYXRlQ29tcG9uZW50VHlwZShjb250YWluZXJDb21wb25lbnRQYXJhbSk7Ci0gICAgICAgIGlmICh2YWxpZGF0ZUNvbXBvbmVudFR5cGUuaXNSaWdodCgpKSB7Ci0gICAgICAgICAgICByZXR1cm4gRWl0aGVyLnJpZ2h0KHZhbGlkYXRlQ29tcG9uZW50VHlwZS5yaWdodCgpLnZhbHVlKCkpOwotICAgICAgICB9Ci0gICAgICAgIGZpbmFsIENvbXBvbmVudFR5cGVFbnVtIGNvbnRhaW5lckNvbXBvbmVudFR5cGUgPSB2YWxpZGF0ZUNvbXBvbmVudFR5cGUubGVmdCgpLnZhbHVlKCk7CisgICAgICAgIGZpbmFsIENvbXBvbmVudFR5cGVFbnVtIGNvbnRhaW5lckNvbXBvbmVudFR5cGUgPSB2YWxpZGF0ZUNvbXBvbmVudFR5cGUoY29udGFpbmVyQ29tcG9uZW50UGFyYW0pOwog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oYW5nZUluc3RhbmNlVmVyc2lvbihjb250YWluZXJDb21wb25lbnQsIGN1cnJlbnRSZXNvdXJjZUluc3RhbmNlLCBuZXdDb21wb25lbnRJbnN0YW5jZSwgdXNlciwgY29udGFpbmVyQ29tcG9uZW50VHlwZSApOwogICAgIH0KIAotICAgIHB1YmxpYyBFaXRoZXI8Q29tcG9uZW50SW5zdGFuY2UsIFJlc3BvbnNlRm9ybWF0PiBjaGFuZ2VJbnN0YW5jZVZlcnNpb24ob3JnLm9wZW5lY29tcC5zZGMuYmUubW9kZWwuQ29tcG9uZW50IGNvbnRhaW5lckNvbXBvbmVudCwgQ29tcG9uZW50SW5zdGFuY2UgY3VycmVudFJlc291cmNlSW5zdGFuY2UsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb21wb25lbnRJbnN0YW5jZSBuZXdDb21wb25lbnRJbnN0YW5jZSwgVXNlciB1c2VyLCBmaW5hbCBDb21wb25lbnRUeXBlRW51bSBjb250YWluZXJDb21wb25lbnRUeXBlICAgICkgewotICAgICAgICBFaXRoZXI8Q29tcG9uZW50SW5zdGFuY2UsIFJlc3BvbnNlRm9ybWF0PiByZXN1bHRPcCA9IG51bGw7CisgICAgcHVibGljIENvbXBvbmVudEluc3RhbmNlIGNoYW5nZUluc3RhbmNlVmVyc2lvbihvcmcub3BlbmVjb21wLnNkYy5iZS5tb2RlbC5Db21wb25lbnQgY29udGFpbmVyQ29tcG9uZW50LCBDb21wb25lbnRJbnN0YW5jZSBjdXJyZW50UmVzb3VyY2VJbnN0YW5jZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbXBvbmVudEluc3RhbmNlIG5ld0NvbXBvbmVudEluc3RhbmNlLCBVc2VyIHVzZXIsIGZpbmFsIENvbXBvbmVudFR5cGVFbnVtIGNvbnRhaW5lckNvbXBvbmVudFR5cGUgICAgKS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dE9wID0gRWl0aGVyLmxlZnQocmVzb3VyY2VJbnN0YW5jZVN0YXR1cy5sZWZ0KCkudmFsdWUoKSk7Ci0gICAgICAgICAgICByZXR1cm4gcmVzdWx0T3A7CisgICAgICAgICAgICByZXR1cm4gIHJlc291cmNlSW5zdGFuY2VTdGF0dXMubGVmdCgpLnZhbHVlKCk7CiAKLSAgICAgICAgfSBmaW5hbGx5IHsKLSAgICAgICAgICAgIHVubG9ja0NvbXBvbmVudChyZXN1bHRPcCwgY29udGFpbmVyQ29tcG9uZW50KTsKKyAgICAgICAgfWNhdGNoIChDb21wb25lbnRFeGNlcHRpb24gZSl7CisgICAgICAgICAgICBmYWlsZWQgPSB0cnVlOworICAgICAgICAgICAgdGhyb3cgZTsKKyAgICAgICAgfWZpbmFsbHkgeworICAgICAgICAgICAgdW5sb2NrQ29tcG9uZW50KGZhaWxlZCwgY29udGFpbmVyQ29tcG9uZW50KTsKICAgICAgICAgfQogICAgIH0KIAorICAgIHByaXZhdGUgYm9vbGVhbiBpc0ZpbGxQcm94eVJlcyhTdG9yYWdlT3BlcmF0aW9uU3RhdHVzIGZpbGxQcm94eVJlcykgeworICAgICAgICBpZiAoZmlsbFByb3h5UmVzICE9IFN0b3JhZ2VPcGVyYXRpb25TdGF0dXMuT0spIHsKKyAgICAgICAgICAgIGxvZy5kZWJ1ZygiRmFpbGVkIHRvIGZpbGwgc2VydmljZSBwcm94eSByZXNvdXJjZSBkYXRhIHdpdGggZGF0YSBmcm9tIHNlcnZpY2UsIGVycm9yIHt9IiwgZmlsbFByb3h5UmVzKTsKKyAgICAgICAgICAgIHJldHVybiB0cnVlOworICAgICAgICB9CisgICAgICAgIHJldHVybiBmYWxzZTsKKyAgICB9CisKICAgICAvLyBVUzgzMTY5OAotICAgIHB1YmxpYyBFaXRoZXI8TGlzdDxDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5PiwgUmVzcG9uc2VGb3JtYXQ+IGdldENvbXBvbmVudEluc3RhbmNlUHJvcGVydG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Wx0T3AgPT0gbnVsbCl7Ci0gICAgICAgICAgICAgICAgRWl0aGVyPENvbXBvbmVudCwgU3RvcmFnZU9wZXJhdGlvblN0YXR1cz4gdmFsaWRhdGVDb250YWluZXJDb21wb25lbnRFeGlzdHMgPSB0b3NjYU9wZXJhdGlvbkZhY2FkZS5nZXRUb3NjYUZ1bGxFbGVtZW50KGNvbnRhaW5lckNvbXBvbmVudElkKTsKLSAgICAgICAgICAgICAgICBpZiAodmFsaWRhdGVDb250YWluZXJDb21wb25lbnRFeGlzdHMuaXNSaWdodCgpKSB7Ci0gICAgICAgICAgICAgICAgICAgIHJlc3VsdE9wID0gRWl0aGVyLnJpZ2h0KGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChjb21wb25lbnRzVXRpbHMuY29udmVydEZyb21TdG9yYWdlUmVzcG9uc2UodmFsaWRhdGVDb250YWluZXJDb21wb25lbnRFeGlzdHMucmlnaHQoKS52YWx1ZSgpKSkpOwotICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lckNvbXBvbmVudCA9IHZhbGlkYXRlQ29udGFpbmVyQ29tcG9uZW50RXhpc3RzLmxlZnQoKS52YWx1ZSgpOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGlmKHJlc3VsdE9wID09IG51bGwpewotICAgICAgICAgICAgICAgIEVpdGhlcjxDb21wb25lbnRJbnN0YW5jZSwgU3RvcmFnZU9wZXJhdGlvblN0YXR1cz4gcmVzb3VyY2VJbnN0YW5jZVN0YXR1cyA9IGdldFJlc291cmNlSW5zdGFuY2VCeUlkKGNvbnRhaW5lckNvbXBvbmVudCwgY29tcG9uZW50SW5zdGFuY2VVbmlxdWVJZCk7Ci0gICAgICAgICAgICAgICAgaWYgKHJlc291cmNlSW5zdGFuY2VTdGF0dXMuaXNSaWdodCgpKSB7Ci0gICAgICAgICAgICAgICAgICAgIHJlc3Vsd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mNlQ2FwYWJpbGl0eVByb3BlcnRpZXMgIT0gbnVsbCkgewotICAgICAgICAgICAgICAgIGlmIChnZXRDb21wb25lbnRJbnN0YW5jZUNhcGFiaWxpdHlQcm9wZXJ0aWVzLmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgICAgICByZXN1bHRPcCA9IEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoY29tcG9uZW50c1V0aWxzLmNvbnZlcnRGcm9tU3RvcmFnZVJlc3BvbnNlKGdldENvbXBvbmVudEluc3RhbmNlQ2FwYWJpbGl0eVByb3BlcnRpZXMucmlnaHQoKS52YWx1ZSgpKSwgY2FwYWJpbGl0eVR5cGUsIGluc3RhbmNlSWQsIGNvbXBvbmVudElkKSk7Ci0gICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgcmVzdWx0T3AgPSBFaXRoZXIubGVmdChnZXRDb21wb25lbnRJbnN0YW5jZUNhcGFiaWxpdHlQcm9wZXJ0aWVzLmxlZnQoKS52YWx1ZSgpKTsKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgIHJlc3VsdE9wID0gRWl0aGVyLmxlZnQobmV3IEFycmF5TGlzdDw+KCkpOwotICAgICAgICAgICAgfQorICAgICAgICAgICAgcmV0dXJuIHRvc2NhT3BlcmF0aW9uRmFjYWRlLmdldENvbXBvbmVudEluc3RhbmNlQ2FwYWJpbGl0eVByb3BlcnRpZXMoY29tcG9uZW50SWQsIGluc3RhbmNlSWQsIGNhcGFiaWxpdHlOYW1lLCBjYXBhYmlsaXR5VHlwZSwgb3duZXJJZCkKKyAgICAgICAgICAgICAgICAgICAgLmxlZnQoKQorICAgICAgICAgICAgICAgICAgICAub24odGhpczo6Y29tcG9uZW50SW5zdGFuY2VQcm9wZXJ0eUxpc3RFeGNlcHRpb24pOwogICAgICAgICB9IGNhdGNoKEV4Y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VVuaXF1ZUlkLCBTdHJpbmcgY2FwYWJpbGl0eVR5cGUsIFN0cmluZyBjYXBhYmlsaXR5TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIExpc3Q8Q29tcG9uZW50SW5zdGFuY2VQcm9wZXJ0eT4gcHJvcGVydGllcywgU3RyaW5nIHVzZXJJZCkgewogICAgICAgICBFaXRoZXI8TGlzdDxDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5PiwgUmVzcG9uc2VGb3JtYXQ+IHJlc3VsdE9wID0gbnVsbDsKIAotICAgICAgICB2YWxpZGF0ZVVzZXJFeGlzdHModXNlcklkLCAidXBkYXRlIGluc3RhbmNlIGNhcGFiaWxpdHkgcHJvcGVydHkiLCBmYWxzZSk7Ci0KKyAgICAgICAgdmFsaWRhdGVVc2VyRXhpc3RzKHVzZXJJZCk7CiAgICAgICAgIGlmIChjb21wb25lbnRUeXBlRW51bSA9PSBudWxsKSB7CiAgICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nSW52YWxpZElucHV0RXJyb3IoInVwZGF0ZUluc3RhbmNlQ2FwYWJpbGl0eVByb3BlcnR5IiwgSU5WQUxJRF9DT01QT05FTlRfVFlQRSwgRXJyb3JTZXZlcml0eS5JTkZPKTsKICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQoY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5OT1RfQUxMT1dFRCkpOwpAQCAtMjk4MCw5ICsyNzI3LDkgQEAKIAogICAgICAgICB0cnkgewogICAgICAgICAgICAgZm9yIChDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5IHByb3BlcnR5IDogcHJvcGVydGllcykgewotICAgICAgICAgICAgICAgIEVpdGhlcjxTdHJpbmcsIF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D4gYWN0aW9uUmVzcG9uc2UgPSBudWxsOworICAgICAgICBib29sZWFuIGZhaWxlZCA9IGZhbHNlOworICAgICAgICBDb21wb25lbnRJbnN0YW5jZSBhY3Rpb25SZXNwb25zZSA9IG51bGw7CiAgICAgICAgIHRyeSB7CisKICAgICAgICAgICAgIGFjdGlvblJlc3BvbnNlID0gY3JlYXRlQ29tcG9uZW50SW5zdGFuY2UoCiAgICAgICAgICAgICAgICAgICAgICJzZXJ2aWNlcyIsIGNvbnRhaW5lckNvbXBvbmVudElkLCB1c2VySWQsIGlucHV0Q29tcG9uZW50SW5zdGFuY2UsIHRydWUsIGZhbHNlKTsKIAotICAgICAgICAgICAgaWYgKGFjdGlvblJlc3BvbnNlLmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgIGxvZy5lcnJvcihGQUlMRURfVE9fQ09QWV9DT01QX0lOU1RBTkNFX1RPX0NBTlZBUyk7Ci0gICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoCi0gICAgICAgICAgICAgICAgICAgICAgICBBY3Rpb25TdGF0dXMuVVNFUl9ERUZJTkVELCBGQUlMRURfVE9fQ09QWV9DT01QX0lOU1RBTkNFX1RPX0NBTlZBUykpOwotICAgICAgICAgICAgfQotCisgICAgICAgIH0gY2F0Y2ggKENvbXBvbmVudEV4Y2VwdGlvbiBlKSB7CisgICAgICAgICAgICBmYWlsZWQgPSB0cnVlOworICAgICAgICAgICAgdGhyb3cgZTsKICAgICAgICAgfSBmaW5hbGx5IHsKIAogICAgICAgICAgICAgLy8gb24gZmFpbHVyZSBvZiB0aGUgY3JlYXRlIGluc3RhbmNlIHVubG9jayB0aGUgcmVzb3VyY2UgYW5kIHJvbGxiYWNrIHRoZSB0cmFuc2FjdGlvbi4KLSAgICAgICAgICAgIGlmIChudWxsID09IGFjdGlvblJlc3BvbnNlIHx8IGFjdGlvblJlc3BvbnNlLmlzUmlnaHQoKSkgeworICAgICAgICAgICAgaWYgKG51bGwgPT0gYWN0aW9uUmVzcG9uc2UgfHwgZmFpbGVkKSB7CiAgICAgICAgICAgICAgICAgamFudXNHcmFwaERhby5yb2xsYmFjaygpOworICAgICAgICAgICAgICAgIGxvZy5lcnJvcigiRmFpbGVkIHRvIGNvcHkgdGhlIGNvbXBvbmVudCBpbnN0YW5jZSB0byB0aGUgY2FudmFzIik7CisKKyAgICAgICAgICAgICAgICB1bmxvY2tDb21wb25lbnQoZmFpbGVkLCBvcmlnQ29tcG9uZW50KTsKKworICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQoY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KAorICAgICAgICAgICAgICAgICAgICAgICAgQWN0aW9uU3RhdHVzLlVTRVJfREVGSU5FRCwgIkZhaWxlZCB0byBjb3B5IHRoZSBjb21wb25lbnQgaW5zdGFuY2UgdG8gdGhlIGNhbnZhcyIpKTsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIHVubG9ja0NvbXBvbmVudChhY3Rpb25SZXNwb25zZSwgb3JpZ0NvbXBvbmVudCk7CiAgICAgICAgIH0KIAogICAgICAgICBFaXRoZXI8U3RyaW5nLCBSZXNwb25zZUZvcm1hdD4gcmVzdWx0T3AgPSBudWxsOwogCiAgICAgICAgIHRyeSB7Ci0gICAgICAgICAgICBDb21wb25lbnRJbnN0YW5jZSBkZXN0Q29tcG9uZW50SW5zdGFuY2UgPSBhY3Rpb25SZXNwb25zZS5sZWZ0KCkudmFsdWUoKTsKKyAgICAgICAgICAgIENvbXBvbmVudEluc3RhbmNlIGRlc3RDb21wb25lbnRJbnN0YW5jZSA9IGFjdGlvblJlc3BvbnNlOwogICAgICAgICAgICAgbG9nLmRlYnVnKCJkZXN0Q29tcG9uZW50SW5zdGFuY2UncyBkYXRhIGlzIHt9IiwgZGVzdENvbXBvbmVudEluc3RhbmNlLnRvU3RyaW5nKCkpOwogCiAKICAgICAgICAgICAgIHJlc3VsdE9wID0gZGVlcENvcHlDb21wb25lbnRJbnN0YW5jZSgKICAgICAgICAgICAgICAgICAgICAgb3JpZ0NvbXBvbmVudCwgY29udGFpbmVyQ29tcG9uZW50SWQsIGNvbXBvbmVudEluc3RhbmNlSWQsIGRlc3RDb21wb25lbnRJbnN0YW5jZSwgdXNlcklkKTsKIAotICAgICAgICAgICAgaWYgKHJlc3VsdE9wLmlzUmlnaHQoKSkgeworICAgICAgICAgICAgcmVzdWx0TWFwLnB1dCgiY29tcG9uZW50SW5zdGFuY2UiLCBkZXN0Q29tcG9uZW50SW5zdGFuY2UpOworICAgICAgICB9IGZpbmFsbHkgeworICAgICAgICAgICAgLy8gdW5sb2NrIHJlc291cmNlCisKKyAgICAgICAgICAgIGlmIChyZXN1bHRPcCA9PSBudWxsIHx8IHJlc3VsdE9wLmlzUmlnaHQoKSkgeworICAgICAgICAgICAgICAgIHVubG9ja0NvbXBvbmVudCh0cnVlLCBvcmlnQ29tcG9uZW50KTsKKyAgICAgICAgICAgICAgICBqYW51c0dyYXBoRGFvLnJvbGxiYWNrKCk7CiAgICAgICAgICAgICAgICAgbG9nLmVycm9yKCJGYWlsZWQgdG8gZGVlcCBjb3B5IGNvbXBvbmVudCBpbnN0YW5jZSIpOwogICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQoY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KAogICAgICAgICAgICAgICAgICAgICAgICAgQWN0aW9uU3RhdHVzLlVTRVJfREVGSU5FRCwgIkZhaWxlZCB0byBkZWVwIGNvcHkgdGhlIGNvbXBvbmVudCBpbnN0YW5jZSB0byB0aGUgY2FudmFzIikpOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgcmVzdWx0TWFwLnB1dCgiY29tcG9uZW50SW5zdGFuY2UiLCBkZXN0Q29tcG9uZW50SW5zdGFuY2UpOwotICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5sZWZ0KHJlc3VsdE1hcCk7Ci0gICAgICAgIH0gZmluYWxseSB7Ci0KLSAgICAgICAgICAgIGlmIChyZXN1bHRPcCA9PSBudWxsIHx8IHJlc3VsdE9wLmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgIGphbnVzR3JhcGhEYW8ucm9sbGJhY2soKTsKLQogICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICB1bmxvY2tDb21wb25lbnQoZmFsc2UsIG9yaWdDb21wb25lbnQpOwogICAgICAgICAgICAgICAgIGphbnVzR3JhcGhEYW8uY29tbWl0KCk7CiAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJTdWNjZXNzIHRyYXNhY3Rpb24gY29tbWl0Iik7CiAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAvLyB1bmxvY2sgcmVzb3VyY2UKLSAgICAgICAgICAgIHVubG9ja0NvbXBvbmVudChyZXN1bHRPcCwgb3JpZ0NvbXBvbmVudCk7CiAgICAgICAgIH0KKworICAgICAgICByZXR1cm4gRWl0aGVyLmxlZnQocmVzdWx0TWFwKTsKICAgICB9CiAKICAgICBwcml2YXRlIEVpdGhlcjxTdHJpbmcsIFJlc3BvbnNlRm9ybWF0PiBkZWVwQ29weUNvbXBvbmVudEluc3RhbmNlKApAQCAtMzE2MCw4ICsyOTEyLDggQEAKICAgICAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJOb3cgc3RhcnQgdG8gdXBkYXRlIGlucHV0cyIpOwogCiAgICAgICAgICAgICAgICAgICAgIGlmIChzb3VyY2VQcm9wLmdldEdldElucHV0VmFsdWVzKCkgIT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNvdXJjZVByb3AuZ2V0R2V0SW5wdXRWYWx1ZXMoKS5pc0VtcHR5KCkpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2cuZGVidWcoInNvdXJjZSBwcm9wZXJ0eSBpbnB1dCB2YWx1ZXMgZW1wdHkiKTsKK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AgICAgIHRocm93IGU7CisgICAgICAgIH1maW5hbGx5IHsKKyAgICAgICAgICAgIHVubG9ja0NvbXBvbmVudChmYWlsZWQsIGNvbnRhaW5lckNvbXBvbmVudCk7CiAgICAgICAgIH0KICAgICB9CiAKLSAgICBwcml2YXRlIEVpdGhlcjxDb21wb25lbnQsIFJlc3BvbnNlRm9ybWF0PiB2YWxpZGF0ZVVzZXIoU3RyaW5nIGNvbnRhaW5lckNvbXBvbmVudFBhcmFtLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmcgY29udGFpbmVyQ29tcG9uZW50SWQsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZyB1c2VySWQpIHsKLSAgICAgICAgdmFsaWRhdGVVc2VyRXhpc3RzKHVzZXJJZCwgImRlbGV0ZSBDb21wb25lbnQgSW5zdGFuY2UiLCBmYWxzZSk7Ci0gICAgICAgIEVpdGhlcjxDb21wb25lbnRUeXBlRW51bSwgUmVzcG9uc2VGb3JtYXQ+IHZhbGlkYXRlQ29tcG9uZW50VHlwZSA9IHZhbGlkYXRlQ29tcG9uZW50VHlwZShjb250YWluZXJDb21wb25lbnRQYXJhbSk7Ci0gICAgICAgIGlmICh2YWxpZGF0ZUNvbXBvbmVudFR5cGUuaXNSaWdodCgpKSB7Ci0gICAgICAgICAgICBsb2cuZXJyb3IoIkNvbXBvbmVudFR5cGVbe31dIGRvZXNuJ3Qgc3VwcG9ydCIsIGNvbnRhaW5lckNvbXBvbmVudFBhcmFtKTsKLSAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQodmFsaWRhdGVDb21wb25lbnRUeXBlLnJpZ2h0KCkudmFsdWUoKSk7Ci0gICAgICAgIH0KLQotICAgICAgICBmaW5hbCBDb21wb25lbnRUeXBlRW51bSBjb250YWluZXJDb21wb25lbnRUeXBlID0gdmFsaWRhdGVDb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SBFaXRoZXI8Q29tcG9uZW50SW5zdGFuY2UsIFJlc3BvbnNlRm9ybWF0PiBiYXRjaERlbGV0ZUNvbXBvbmVudEluc3RhbmNlKENvbXBvbmVudCBjb250YWluZXJDb21wb25lbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZyBjb250YWluZXJDb21wb25lbnRUeXBlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmcgY29udGFpbmVyQ29tcG9uZW50SWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZyBjb21wb25lbnRJbnN0YW5jZUlkKSB7CiAKLSAgICAgICAgRWl0aGVyPENvbXBvbmVudEluc3RhbmNlLCBSZXNwb25zZUZvcm1hdD4gcmVzdWx0T3A7CisgICAgICAgIENvbXBvbmVudEluc3RhbmNlIHJlc3VsdE9wOwogICAgICAgICBmaW5hbCBDb21wb25lbnRUeXBlRW51bSBjb250YWluZXJDb21wb25lbnRUeXBlRW51bSA9IENvbXBvbmVudFR5cGVFbnVtLmZpbmRCeVBhcmFtTmFtZShjb250YWluZXJDb21wb25lbnRUeXBlKTsKIAotICAgICAgICByZXN1bHRPcCA9IGRlbGV0ZUNvbXBvbmVudEluc3RhbmNlKGNvbnRhaW5lckNvbXBvbmVudCwgY29tcG9uZW50SW5zdGFuY2VJZCwgY29udGFpbmVyQ29tcG9uZW50VHlwZUVudW0pOwotCi0gICAgICAgIGlmIChyZXN1bHRPcC5pc1JpZ2h0KCkpIHsKKyAgICAgICAgYm9vbGVhbiBmYWlsZWQgPSBmYWxzZTsKKyAgICAgICAgdHJ5IHsKKyAgICAgICAgICAgIHJlc3VsdE9wID0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ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEludGVyZmFjZU9wZXJhdGlvbiBpbnRlcmZhY2VPcGVyYXRpb24sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbnRlcmZhY2VMaWZlY3ljbGVPcGVyYXRpb24gaW50ZXJmYWNlTGlmZWN5Y2xlVHlwZU9wZXJhdGlvbiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFydGlmYWN0c09wZXJhdGlvbnMgYXJ0aWZhY3RUb3NjYU9wZXJhdGlvbikgewogICAgICAgICBzdXBlcihlbGVtZW50RGFvLCBncm91cE9wZXJhdGlvbiwgZ3JvdXBJbnN0YW5jZU9wZXJhdGlvbiwgZ3JvdXBUeXBlT3BlcmF0aW9uLAogICAgICAgICAgICAgaW50ZXJmYWNlT3BlcmF0aW9uLCBpbnRlcmZhY2VMaWZlY3ljbGVUeXBlT3BlcmF0aW9uLCBhcnRpZmFjdFRvc2NhT3BlcmF0aW9uKTsKICAgICB9CkBAIC0xMzUsOCArMTM2LDEwIEBACiAgICAgICAgICAgICByZXR1cm4gRWl0aGVyLnJpZ2h0KHJlc3BvbnNlRm9ybWF0KTsKICAgICAgICAgfQogICAgICAgICBsb2cuZGVidWcoImdldCB1c2VyIGZyb20gREIiKTsKLSAgICAgICAgRWl0aGVyPFVzZXIsIEFjdGlvblN0YXR1cz4gZWl0aGVyQ3JlYXRvciA9IHVzZXJBZG1pbi5nZXRVc2VyKHVzZXIuZ2V0VXNlcklkKCksIGZhbHNlKTsKLSAgICAgICAgaWYgKGVpdGhlckNyZWF0b3IuaXNSaWdodCgpIHx8IGVpdGhlckNyZWF0b3IubGVmdCgpLnZhbHVlKCkgPT0gbnVsbCkgeworICAgICAgICBVc2VyIHVzZXJGcm9tREI7CisgICAgICAgIHRyeSB7CisgICAgICAgICAgICB1c2VyRnJvbURCID0gdXNlckFkbWluLmdldFVzZXIodXNlci5nZXRVc2VySWQoKSwgZmFsc2UpOworICAgICAgIC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gICAvKioKICAgICAgKgogICAgICAqIEBwYXJhbSB1c2VyCkBAIC0xMjEsMzcgKzE0OSwyNSBAQAogICAgICAgICBSb2xlIGN1cnJlbnRSb2xlID0gUm9sZS52YWx1ZU9mKHJvbGUpOwogCiAgICAgICAgIHN3aXRjaCAoY3VycmVudFJvbGUpIHsKLSAgICAgICAgICAgIGNhc2UgREVTSUdORVI6Ci0gICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBoYW5kbGVEZXNpZ25lcih1c2VySWQpOwotICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIERFU0lHTkVSOgorICAgICAgICAgICAgcmVzcG9uc2UgPSBoYW5kbGVEZXNpZ25lcih1c2VySWQpOworICAgICAgICAgICAgYnJlYWs7CiAKLSAgICAgICAgICAgIGNhc2UgVEVTVEVSOgotICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gaGFuZGxlVGVzdGVyKCk7Ci0gICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgUFJPRFVDVF9TVFJBVEVHSVNUOgorICAgICAgICAgICAgcmVzcG9uc2UgPSBoYW5kbGVQcm9kdWN0U3RyYXRlZ2lzdCgpOworICAgICAgICAgICAgYnJlYWs7CiAKLSAgICAgICAgICAgIGNhc2UgR09WRVJOT1I6Ci0gICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBoYW5kbGVHb3Zlcm5vcigpOwotICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIFBST0RVQ1RfTUFOQUdFUjoKKyAgICAgICAgICAgIHJlc3BvbnNlID0gaGFuZGxlUHJvZHVjdE1hbmFnZXIodXNlcklkKTsKKyAgICAgICAgICAgIGJyZWFrOwogCi0gICAgICAgICAgICBjYXNlIE9QUzoKLSAgICAgICAgICAgICAgICByZXNwb25zZSA9IGhhbmRsZU9wcygpOwotICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIEFETUlOOgorICAgICAgICAgICAgcmVzcG9uc2UgPSBoYW5kbGVBZG1pbigpOworICAgICAgICAgICAgYnJlYWs7CiAKLSAgICAgICAgICAgIGNhc2UgUFJPRFVDVF9TVFJBVEVHSVNUOgotICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gaGFuZGxlUHJvZHVjdFN0cmF0ZWdpc3QoKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLQotICAgICAgICAgICAgY2FzZSBQUk9EVUNUX01BTkFHRVI6Ci0gICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBoYW5kbGVQcm9kdWN0TWFuYWdlcih1c2VySWQpOwotICAgICAgICAgICAgICAgIGJyZWFrOwotCi0gICAgICAgICAgICBjYXNlIEFETUlOOgotICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gaGFuZGxlQWRtaW4oKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLQotICAgICAgICAgICAgZGVmYXVsdDoKLSAgICAgICAgICAgICAgICByZXNwb25zZSA9IEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLlJFU1RSSUNURURfT1BFUkFUSU9OKSk7Ci0gICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICByZXNwb25zZSA9IEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLlJFU1RSSUNURURfT1BFUkFUSU9OKSk7CisgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogICAgICAgICAvLyBjb252ZXJ0aW5nIHRoZSBTZXQgdG8gTGlzdCBzbyB0aGUgcmVzdCBvZiB0aGUgY29kZSB3aWxsIGhhbmRsZSBpdCBub3JtYWxseSAoV2FzIGNoYW5nZWQgYmVjYXVzZSB0aGUgc2FtZSBlbGVtZW50IHdpdGggdGhlIHNhbWUgdXVpZCB3YXMgcmV0dXJuZWQgdHdpY2UpCiAgICA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FETUlOLm5hbWUoKSkgJiYgKGNvbXBvbmVudFR5cGVFbnVtID09IENvbXBvbmVudFR5cGVFbnVtLlNFUlZJQ0UgfHwgY29tcG9uZW50VHlwZUVudW0gPT0gQ29tcG9uZW50VHlwZUVudW0uUkVTT1VSQ0UpOwpAQCAtOTE5LDEwICs4NzEsMTAgQEAKICAgICAgICAgYm9vbGVhbiB2YWxpZFJlc291cmNlQWN0aW9uID0gY29tcG9uZW50VHlwZSA9PSBDb21wb25lbnRUeXBlRW51bS5SRVNPVVJDRSAmJiAoY2F0ZWdvcnlUeXBlID09IENhdGVnb3J5VHlwZUVudW0uQ0FURUdPUlkgfHwgY2F0ZWdvcnlUeXBlID09IENhdGVnb3J5VHlwZUVudW0uU1VCQ0FURUdPUlkpOwogICAgICAgICBib29sZWFuIHZhbGlkU2VydmljZUFjdGlvbiA9IGNvbXBvbmVudFR5cGUgPT0gQ29tcG9uZW50VHlwZUVudW0uU0VSVklDRSAmJiBjYXRlZ29yeVR5cGUgPT0gQ2F0ZWdvcnlUeXBlRW51bS5DQVRFR09SWTsKICAgICAgICAgYm9vbGVhbiB2YWxpZFByb2R1Y3RBY3Rpb24gPSBjb21wb25lbnRUeXBlID09IENvbXBvbmVudFR5cGVFbnVtLlBST0RVQ1Q7IC8vIGNhbgotICAgICAgICAvLyBiZQotICAgICAgICAvLyBhbnkKLSAgICAgICAgLy8gY2F0ZWdvcnkKLSAgICAgICAgLy8gdHlwZQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gYmUKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGFueQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gY2F0ZWdvcnkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHR5cGUKIAogICAgICAgICBpZiAoISh2YWxpZFJlc291cmNlQWN0aW9uIHx8IHZhbGlkU2VydmljZUFjdGlvbiB8fCB2YWxpZFByb2R1Y3RBY3Rpb24pKSB7CiAgICAgICAgICAgICBSZXNwb25zZUZvcm1hdCByZXNwb25zZUZvcm1hdCA9IGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuSU5WQUxJRF9DT05URU5UKTsKQEAgLTk4MSwyNSArOTMzLDI1IEBACiAgICAgICovCiAKICAgICBwdWJsaWMgRWl0aGVyPExpc3Q8VGFnPiwgQWN0aW9uU3RhdHVzPiBnZXRBbGxUYWdzKFN0cmluZyB1c2VySWQpIHsKLSAgICAgICAgRWl0aGVyPFVzZXIsIEFjdGlvblN0YXR1cz4gcmVzcCA9IHZhbGlkYXRlVXNlckV4aXN0c0FjdGlvblN0YXR1cyh1c2VySWQsICJnZXQgQWxsIFRhZ3MiKTsKLSAgICAgICAgaWYgKHJlc3AuaXNSaWdodCgpKSB7Ci0gICAgICAgICAgICByZXR1cm4gRWl0aGVyLnJpZ2h0KHJlc3AucmlnaHQoKS52YWx1ZSgpKTsKKyAgICAgICAgQWN0aW9uU3RhdHVzIHN0YXR1cyA9IHZhbGlkYXRlVXNlckV4aXN0c0FjdGlvblN0YXR1cyh1c2VySWQpOworICAgICAgICBpZiAoQWN0aW9uU3RhdHVzLk9LICE9IHN0YXR1cykgeworICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChzdGF0dXMpOwogICAgICAgICB9CiAgICAgICAgIHJldHVybiBlbGVtZW50T3BlcmF0aW9uLmdldEFsbFRhZ3MoKTsKICAgICB9CiAKICAgICBwdWJsaWMgRWl0aGVyPExpc3Q8UHJvcGVydHlTY29wZT4sIEFjdGlvblN0Y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R5cGVFbnVtKSB7CiAgICAgICAgIHN3aXRjaCAoY29tcG9uZW50VHlwZUVudW0pIHsKLSAgICAgICAgICAgIGNhc2UgUkVTT1VSQ0U6Ci0gICAgICAgICAgICAgICAgcmV0dXJuIFJFU09VUkNFUzsKLSAgICAgICAgICAgIGNhc2UgU0VSVklDRToKLSAgICAgICAgICAgICAgICByZXR1cm4gU0VSVklDRVM7Ci0gICAgICAgICAgICBkZWZhdWx0OgotICAgICAgICAgICAgICAgIHRocm93IG5ldyBJbGxlZ2FsU3RhdGVFeGNlcHRpb24oInJlc291cmNlcyBvciBzZXJ2aWNlcyBvbmx5Iik7CisgICAgICAgIGNhc2UgUkVTT1VSQ0U6CisgICAgICAgICAgICByZXR1cm4gUkVTT1VSQ0VTOworICAgICAgICBjYXNlIFNFUlZJQ0U6CisgICAgICAgICAgICByZXR1cm4gU0VSVklDRVM7CisgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICB0aHJvdyBuZXcgSWxsZWdhbFN0YXRlRXhjZXB0aW9uKCJyZXNvdXJjZXMgb3Igc2VydmljZXMgb25seSIpOwogICAgICAgICB9CiAgICAgfQogCkBAIC0xMDc3LDcgKzEwMjQsNyBAQAogICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoY29tcG9uZW50c1V0aWxzLmNvbnZlcnRGcm9tU3RvcmFnZVJlc3BvbnNlKHJlc3VsdC5yaWdodCgpLnZhbHVlKCkpLCBwYXJhbXMuZ2V0KDApLCBwYXJhbXMuZ2V0KDEpLCBwYXJhbXMuZ2V0KDIpKSk7CiAgICAgICAgIH0KICAgICAgICAgaWYgKHJlc3VsdC5sZWZ0KCkudmFsdWUoKS5pc0VtcHR5KCkpIHsvLyBubyBhc3NldHMgZm91bmQgZm9yIHJlcXVlc3RlZAotICAgICAgICAgICAgLy8gY3JpdGVyaWEKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICA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ICByZXR1cm4gY29tcG9uZW50LmdldFVuaXF1ZUlkKCk7CisgICAgfQogCi0gICAgICAgIC8vTG9jayBBc3NldAotICAgICAgICB0aGlzLmNvbXBvbmVudExvY2tlci5sb2NrKGNvbXBvbmVudCk7Ci0gICAgICAgIHRoaXMuYWNjZXNzVmFsaWRhdGlvbnMudmFsaWRhdGVVc2VyQ2FuV29ya09uQ29tcG9uZW50KGNvbXBvbmVudCwgdXNlcklkLCBhY3Rpb24gKyAiIEVYVEVSTkFMIFJFRiIpOwogCi0gICAgICAgIEVpdGhlcjxTdHJpbmcsIEFjdGlvblN0YXR1cz4gb3BSZXN1bHQgPSBFaXRoZXIucmlnaHQoQWN0aW9uU3RhdHVzLkdFTkVSQUxfRVJST1IpOwotICAgICAgICB0cnkgewotICAgICAgICAgICAgc3dpdGNoIChhY3Rpb24pIHsKLSAgICAgICAgICAgICAgICBjYXNlICJQT1NUIjoKLSAgICAgICAgICAgICAgICAgICAgb3BSZXN1bHQgPSB0aGlzLmV4dGVybmFsUmVmZXJlbmNlc09wZXJhdGlvbi5hZGRFeHRlcm5hbFJlZmVyZW5jZVdpdGhDb21taXQodW5pcXVlSWQsIGNvbXBvbmVudEluc3RhbmNlTmFtZSwgb2JqZWN0VHlwZSwgcmVmMSk7Ci0gICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgIGNhc2UgIlBVVCI6Ci0gICAgICAgICAgICAgICAgICAgIG9wUmVzdWx0ID0gdGhpcy5leHRlcm5hbFJlZmVyZW5jZXNPcGVyYXRpb24udXBkYXRlRXh0ZXJuYWxSZWZlcmVuY2VXaXRoQ29tbWl0KHVuaXF1ZUlkLCBjb21wb25lbnRJbnN0YW5jZU5hbWUsIG9iamVjdFR5cGUsIHJlZjEsIHJlZjIpOwotICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICBjYXNlICJERUxFVEUiOgotICAgICAgICAgICAgICAgICAgICBvcFJlc3VsdCA9IHRoaX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9uZW50SWQsIGNvbXBvbmVudFR5cGUsIG51bGwpOwotICAgICAgICAgICAgaWYgKHZhbGlkYXRlQ29tcG9uZW50LmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgIHJlc3VsdCA9IEVpdGhlci5yaWdodCh2YWxpZGF0ZUNvbXBvbmVudC5yaWdodCgpLnZhbHVlKCkpOwotICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBvcmcub3BlbmVjb21wLnNkYy5iZS5tb2RlbC5Db21wb25lbnQgY29tcG9uZW50ID0gdmFsaWRhdGVDb21wb25lbnQubGVmdCgpLnZhbHVlKCk7CisgICAgICAgICAgICBvcmcub3BlbmVjb21wLnNkYy5iZS5tb2RlbC5Db21wb25lbnQgY29tcG9uZW50ID0gdmFsaWRhdGVDb21wb25lbnRFeGlzdHMoY29tcG9uZW50SWQsIGNvbXBvbmVudFR5cGUsIG51bGwpOwogICAgICAgICAgICAgLy8gdmFsaWRhdGUgd2UgY2FuIHdvcmsgb24gY29tcG9uZW50Ci0gICAgICAgICAgICBFaXRoZXI8Qm9vbGVhbiwgUmVzcG9uc2VGb3JtYXQ+IGNhbldvcmsgPSB2YWxpZGF0ZUNhbldvcmtPbkNvbXBvbmVudChjb21wb25lbnQsIHVzZXIuZ2V0VXNlcklkKCkpOwotICAgICAgICAgICAgaWYgKGNhbldvcmsuaXNSaWdodCgpKSB7Ci0gICAgICAgICAgICAgICAgcmVzdWx0ID0gRWl0aGVyLnJpZ2h0KGNhbldvcmsucmlnaHQoKS52YWx1ZSgpKTsKLSAgICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0OwotICAgICAgICAgICAgfQorICAgICAgICAgICAgdmFsaWRhdGVDYW5Xb3JrT25Db21wb25lbnQoY29tcG9uZW50LCB1c2VyLmdldFVzZXJJZCgpKTsKICAgICAgICAgICAgIExpc3Q8R3JvdXBEZWZpbml0aW9uPiBjdXJyZW50R3JvdXBzID0gY29tcG9uZW50LmdldEdyb3VwcygpOwogICAgICAgICAgICAgaWYgKENvbGxlY3Rpb25VdGlscy5pc0VtcHR5KGN1cnJlbnRHcm91cHMpKSB7CiAgICAgICAgICAgICAgICAgbG9nLmVycm9yKCJGYWlsZWQgdG8gdXBkYXRlIHRoZSBtZXRhZGF0YSBvZiBncm91cCB7fSBvbiBjb21wb25lbnQge30uIFRoZSBzdGF0dXMgaXMge30uICIsIHVwZGF0ZWRHcm91cC5nZXROYW1lKCksIGNvbXBvbmVudC5nZXROYW1lKCksIEFjdGlvblN0YXR1cy5HUk9VUF9JU19NSVNTSU5HKTsKQEAgLTI0OSwxMSArMjcwLDcgQEAKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIEdyb3VwRGVmaW5pdGlvbiBjdXJyZW50R3JvdXAgPSBjdXJyZW50R3JvdXBPcHQuZ2V0KCk7CiAgICAgICAgICAgICBpZiAoIHNob3VsZExvY2sgKXsKLSAgICAgICAgICAgICAgICBFaXRoZXI8Qm9vbGVhbiwgUmVzcG9uc2VGb3JtYXQ+IGxvY2tSZXN1bHQgPSBsb2NrQ29tcG9uZW50KGNvbXBvbmVudElkLCBjb21wb25lbnQsICJVcGRhdGUgR3JvdXBEZWZpbml0aW9uIE1ldGFkYXRhIik7Ci0gICAgICAgICAgICAgICAgaWYgKGxvY2tSZXN1bHQuaXNSaWdodCgpKSB7Ci0gICAgICAgICAgICAgICAgICAgIHJlc3VsdCA9IEVpdGhlci5yaWdodChsb2NrUmVzdWx0LnJpZ2h0KCkudmFsdWUoKSk7Ci0gICAgICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7Ci0gICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGxvY2tDb21wb25lbnQoY29tcG9uZW50SWQsIGNvbXBvbmVudCwgIlVwZGF0ZSBHcm91cERlZmluaXRpb24gTWV0YWRhdGEiKTsKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIC8vIFZhbGlkYXRlIGdyb3VwIHR5cGUgaXMgdmZNb2R1bGUKICAgICAgICAgICAgIGlmIChjdXJyZW50R3JvdXAuZ2V0VHlwZSgpLmVxdWFscyhDb25zdGFudHMuR1JPVVBfVE9TQ0FfSEVBVCkpIHsKQEAgLTI2NSw4ICsyODIsMTEgQEAKICAgICAgICAgICAgIHJlc3VsdCA9IHVwZGF0ZUdyb3VwTWV0YWRhdGEoY29tcG9uZW50LCBjdXJyZW50R3JvdXAsIHVwZGF0ZWRHcm91cCk7CiAgICAgICAgICAgICByZXR1cm4gcmVzdWx0OwogCi0gICAgICAgIH0gZmluYWxseSB7Ci0gICAgICAgICAgICBpZiAocmVzdWx0ICE9IG51bGwgJiYgcmVzdWx0LmlzTGVmdCgpKSB7CisgICAgICAgIH1jYXRjaCAoQ29tcG9uZW50RXhjZXB0aW9uIGUpeworICAgICAgICAgICAgZmFpbGVkID0gdHJ1ZTsKKyAgICAgICAgICAgIHRocm93IGU7CisgICAgICAgIH1maW5hbGx5IHsKKyAgICAgICAgICAgIGlmICghZmFpbGVkKSB7CiAgICAgICAgICAgICAgICAgamFudXNHcmFwaERhby5jb21taXQoKTsKICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgamFudXNHcmFwaERhby5yb2xsYmFjaygpOwpAQCAtMjkzLDIzICszMTMsMTAgQEAKICAgICBwcml2YXRlIEVpdGhlcjxHcm91cERlZmluaXRpb24sIFJlc3BvbnNlRm9ybWF0PiB1cGRhdGVHcm91cChDb21wb25lbnQgY29tcG9uZW50LCBHcm91cERlZmluaXRpb24gdXBkYXRlZEdyb3VwLCBTdHJpbmcgY3VycmVudEdyb3VwTmFtZSkgewogICAgICAgICBFaXRoZXI8R3JvdXBEZWZpbml0aW9uLCBTdG9yYWdlT3BlcmF0aW9uU3RhdHVzPiBoYW5kbGVHcm91cFJlczsKICAgICAgICAgRWl0aGVyPEdyb3VwRGVmaW5pdGlvbiwgUmVzcG9uc2VGb3JtYXQ+IHJlc3VsdCA9IG51bGw7Ci0gICA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uZW50UGFyYW1ldGVyc1ZpZXcpOwotICAgICAgICAgICAgaWYgKHZhbGlkYXRlQ29tcG9uZW50LmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgIHJlc3VsdCA9IEVpdGhlci5yaWdodCh2YWxpZGF0ZUNvbXBvbmVudC5yaWdodCgpLnZhbHVlKCkpOwotICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBjb21wb25lbnQgPSB2YWxpZGF0ZUNvbXBvbmVudC5sZWZ0KCkudmFsdWUoKTsKKyAgICAgICAgICAgIGNvbXBvbmVudCA9IHZhbGlkYXRlQ29tcG9uZW50RXhpc3RzKGNvbXBvbmVudElkLCBjb21wb25lbnRUeXBlLCBjb21wb25lbnRQYXJhbWV0ZXJzVmlldyk7CiAKICAgICAgICAgICAgIEVpdGhlcjxHcm91cERlZmluaXRpb24sIFN0b3JhZ2VPcGVyYXRpb25TdGF0dXM+IGdyb3VwRWl0aGVyID0gZmluZEdyb3VwT25Db21wb25lbnQoY29tcG9uZW50LCBncm91cElkKTsKIAogICAgICAgICAgICAgaWYgKGdyb3VwRWl0aGVyLmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiRmFpbGQgdG8gZmluZCBncm91cCB7fSB1bmRlciBjb21wb25lbnQge30iLCBncm91cElkLCBjb21wb25lbnQuZ2V0VW5pcXVlSWQoKSk7CisgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJGYWlsZWQgdG8gZmluZCBncm91cCB7fSB1bmRlciBjb21wb25lbnQge30iLCBncm91cElkLCBjb21wb25lbnQuZ2V0VW5pcXVlSWQoKSk7CiAgICAgICAgICAgICAgICAgQmVFY29tcEVycm9yTWFuYWdlci5nZXRJbnN0YW5jZSgpLmxvZ0ludmFsaWRJbnB1dEVycm9yKEdFVF9HUk9VUCwgImdyb3VwICAiICsgZ3JvdXBJZCArICIgbm90IGZvdW5kIHVuZGVyIGN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Ci0gICAgICAgICAgICAgICAgICAgIGlzQmFzZSA9IEJvb2xlYW4ucGFyc2VCb29sZWFuKHByb3BJc0Jhc2UuZ2V0VmFsdWUoKSk7Ci0KLSAgICAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nSW52YWxpZElucHV0RXJyb3IoR0VUX0dST1VQLCAiZmFpbGVkIHRvIGZpbmQgcHJvcCBpc0Jhc2UgIiArIGNvbXBvbmVudC5nZXROb3JtYWxpemVkTmFtZSgpLCBFcnJvclNldmVyaXR5LklORk8pOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIH0KKyAgICAgICAgICAgIEJvb2xlYW4gaXNCYXNlID0gaXNCYXNlUHJvcChjb21wb25lbnQsIHByb3BzKTsKIAogICAgICAgICAgICAgTGlzdDxBcnRpZmFjdERlZmluaXRpb25JbmZvPiBhcnRpZmFjdHMgPSBuZXcgQXJyYXlMaXN0PD4oKTsKICAgICAgICAgICAgIExpc3Q8QXJ0aWZhY3REZWZpbml0aW9uPiBhcnRpZmFjdHNGcm9tQ29tcG9uZW50ID0gbmV3IEFycmF5TGlzdDw+KCk7CkBAIC00ODUsMTIgKzQ3Nyw3IEBACiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgYXJ0aWZhY3RzRnJvbUNvbXBvbmVudC5hZGQoZGVwbG95bWVudEFydGlmYWN0cy5nZXQoaWQpKTsKICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgaWYgKCFhcnRpZmFjdHNGcm9tQ29tcG9uZW50LmlzRW1wdHkoKSkgewotICAgICAgICAgICAgICAgICAgICBmb3IgKEFydGlmYWN0RGVmaW5pdGlvbiBhcnRpZmFjdERlZmluaXRpb24gOiBhcnRpZmFjdHNGcm9tQ29tcG9uZW50KSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBBcnRpZmFjdERlZmluaXRpb25JbmZvIGFydGlmYWN0RGVmaW5pdGlvbkluZm8gPSBuZXcgQXJ0aWZhY3REZWZpbml0aW9uSW5mbyhhcnRpZmFjdERlZmluaXRpb24pOwotICAgICAgICAgICAgICAgICAgICAgICAgYXJ0aWZhY3RzLmFkZChhcnRpZmFjdERlZmluaXRpb25JbmZvKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBhZGRBcnRpZmFjdHNUb0xpc3QoYXJ0aWZhY3RzLCBhcnRpZmFjdHNGcm9tQ29tcG9uZW50KTsKIAogICAgICAgICAgICAgfQogICAgICAgICAgICAgR3JvdXBEZWZpbml0aW9uSW5mbyByZXN1bHRJbmZvID0gbmV3IEdyb3VwRGVmaW5pdGlvbkluZm8oZ3JvdXApOwpAQCAtNTAzLDIzICs0OTAsMzAgQEAKICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7CiAKICAgICAgICAgfSBmaW5hbGx5IHsKLQotICAgICAgICAgICAgaWYgKCFpblRyYW5zYWN0aW9uKSB7Ci0KLSAgICAgICAgICAgICAgICBpZiAocmVzdWx0ID09IG51bGwgfHwgcmVzdWx0LmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgICAgICBsb2cuZGVidWcoIkdvaW5nIHRvIGV4ZWN1dGUgcm9sbGJhY2sgb24gY3JlYXRlIGdyb3VwLiIpOwotICAgICAgICAgICAgICAgICAgICBqYW51c0dyYXBoRGFvLnJvbGxiYWNrKCk7Ci0gICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJHb2luZyB0byBleGVjdXRlIGNvbW1pdCBvbiBjcmVhdGUgZ3JvdXAuIik7Ci0gICAgICAgICAgICAgICAgICAgIGphbnVzR3JhcGhEYW8uY29tbWl0KCk7Ci0gICAgICAgICAgICAgICAgfQotCi0gICAgICAgICAgICB9Ci0KKyAgICAgICAgICAgIGNsb3NlVHJhb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aXR5LklORk8pOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIH0KKyAgICAgICAgICAgIEJvb2xlYW4gaXNCYXNlID0gaXNCYXNlUHJvcGVydHkoY29tcG9uZW50LCBncm91cCk7CiAKICAgICAgICAgICAgIExpc3Q8QXJ0aWZhY3REZWZpbml0aW9uSW5mbz4gYXJ0aWZhY3RzID0gbmV3IEFycmF5TGlzdDw+KCk7CiAgICAgICAgICAgICBMaXN0PFN0cmluZz4gYXJ0aWZhY3RzSWRzID0gZ3JvdXAuZ2V0QXJ0aWZhY3RzKCk7CkBAIC03MDIsMjUgKzY4MSw5IEBACiAKICAgICAgICAgICAgICAgICBMaXN0PENvbXBvbmVudEluc3RhbmNlPiBpbnN0YW5jZXMgPSBjb21wb25lbnQuZ2V0Q29tcG9uZW50SW5zdGFuY2VzKCk7CiAgICAgICAgICAgICAgICAgaWYgKGluc3RhbmNlcyAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgIE9wdGlvbmFsPENvbXBvbmVudEluc3RhbmNlPiBmaW5kRmlyc3QgPSBpbnN0YW5jZXMuc3RyZWFtKCkuZmlsdGVyKGkgLT4gaS5nZXRVbmlxdWVJZCgpLmVxdWFscyhjb21wb25lbnRJbnN0YW5jZUlkKSkuZmluZEZpcnN0KCk7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChmaW5kRmlyc3QuaXNQcmVzZW50KCkpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIENvbXBvbmVudEluc3RhbmNlIGNpID0gZmluZEZpcnN0LmdldCgpOwotICAgICAgICAgICAgICAgICAgICAgICAgTWFwPFN0cmluZywgQXJ0aWZhY3REZWZpbml0aW9uPiBkZXBsb3ltZW50QXJ0aWZhY3RzID0gY2kuZ2V0RGVwbG95bWVudEFydGlmYWN0cygpOwotICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChTdHJpbmcgaWQgOiBhcnRpZmFjdHNJZHMpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBPcHRpb25hbDxBcnRpZmFjdERlZmluaXRpb24+IGFydE9wID0gZGVwbG95bWVudEFydGlmYWN0cy52YWx1ZXMoKS5zdHJlYW0oKS5maWx0ZXIoYSAtPiBhLmdldFVuaXF1ZUlkKCkuZXF1YWxzKGlkKSkuZmluZEZpcnN0KCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFydE9wLmlzUHJlc2VudCgpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFydGlmYWN0cy5hZGQobmV3IEFydGlmYWN0RGVmaW5pdGlvbkluZm8oYXJ0T3AuZ2V0KCkpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgICAgICBMaXN0PFN0cmluZz4gaW5zdEFydGlmYWN0c0lkcyA9IGdyb3VwLmdldEdyb3VwSW5zdGFuY2VBcnRpZmFjdHMoKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoU3RyaW5nIGlkIDogaW5zdEFydGlmYWN0c0lkcykgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIE9wdGlvbmFsPEFydGlmYWN0RGVmaW5pdGlvbj4gYXJ0T3AgPSBkZXBsb3ltZW50QXJ0aWZhY3RzLnZhbHVlcygpLnN0cmVhbSgpLmZpbHRlcihhIC0+IGEuZ2V0VW5pcXVlSWQoKS5lcXVhbHMoaWQpKS5maW5kRmlyc3QoKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYXJ0T3AuaXNQcmVzZW50KCkpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJ0aWZhY3RzLmFkZChuZXcgQXJ0aWZhY3REZWZpbml0aW9uSW5mbyhhcnRPcC5nZXQoKSkpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgfQotCisgICAgICAgICAgICAgICAgICAgIGluc3RhbmNlcy5zdHJlYW0oKS5maWx0ZXIoaSAtPiBpLmdldFVuaXF1ZUlkKCkuZXF1YWxzKGNvbXBvbmVudEluc3RhbmNlSWQpKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5maW5kRmlyc3QoKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5pZlByZXNlbnQoZi0+Z2V0Rmlyc3RDb21wb25lbnRJbnN0YW5jZShncm91cCwgYXJ0aWZhY3RzLCBhcnRpZmFjdHNJZHMsIGYpKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBHcm91cERlZmluaXRpb25JbmZvIHJlc3VsdEluZm8gPSBuZXcgR3JvdXBEZWZpbml0aW9uSW5mbyhncm91cCk7CkBAIC03MzMsMTkgKzY5Niw1MSBAQAogICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKIAogICAgICAgICB9IGZpbmFsbHkgeworICAgICAgICAgICAgY2xvc2VUcmFuc2FjdGlvbihpblRyYW5zYWN0aW9uLCByZXN1bHQpOworICAgICAgICB9CisgICAgfQogCi0gICAgICAgICAgICBpZiAoIWluVHJhbnNhY3Rpb24pIHsKKyAgICBwcml2YXRlIHZvaWQgZ2V0Rmlyc3RDb21wb25lbnRJbnN0YW5jZShHcm91cEluc3RhbmNlIGdyb3VwLCBMaXN0PEFydGlmYWN0RGVmaW5pdGlvbkluZm8+IGFydGlmYWN0cywgTGlzdDxTdHJpbmc+IGFydGlmYWN0c0lkcywgQ29tcG9uZW50SW5zdGFuY2UgY2kpIHsKKyAgICAgICAgTWFwPFN0cmluZywgQXJ0aWZhY3REZWZpbml0aW9uPiBkZXBsb3ltZW50QXJ0aWZhY3RzID0gY2kuZ2V0RGVwbG95bWVudEFydGlmYWN0cygpOworICAgICAgICBhcnRpZmFjdHNJZHMuZm9yRWFjaChpZCAtPiBkZXBsb3ltZW50QXJ0aWZhY3RzLnZhbHVlcygpLnN0cmVhbSgpCisgICAgICAgICAgICAgICAgLmZpbHRlcihhIC0+IGEuZ2V0VW5pcXVlSWQoKS5lcXVhbHMoaWQpKQorICAgICAgICAgICAgICAgIC5maW5kRmlyc3QoKQorICAgICAgICAgICAgICAgIC5pZlByZXNlbnQoZyAtPiBhcnRpZmFjdHMuYWRkKG5ldyBBcnRpZmFjdERlZmluaXRpb25JbmZvKGcpKSkpOwogCi0gICAgICAgICAgICAgICAgaWYgKHJlc3VsdCA9PSBudWxsIHx8IHJlc3VsdC5pc1JpZ2h0KCkpIHsKLSAgICAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJHb2luZyB0byBleGVjdXRlIHJvbGxiYWNrIG9uIGNyZWF0ZSBncm91cC4iKTsKLSAgICAgICAgICAgICAgICAgICAgamFudXNHcmFwaERhby5yb2xsYmFjaygpOwotICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiR29pbmcgdG8gZXhlY3V0ZSBjb21taXQgb24gY3JlYXRlIGdyb3VwLiIpOwotICAgICAgICAgICAgICAgICAgICBqYW51c0dyYXBoRGFvLmNvbW1pdCgpOwotICAgICAgICAgICAgICAgIH0KKyAgICAgICAgTGlzdDxTdHJpbmc+IGluc3RBcnRpZmFjdHNJZHMgPSBncm91cC5nZXRHcm91cEluc3RhbmNlQXJ0aWZhY3RzKCk7CisgICAgICAgIGluc3RBcnRpZmFjdHNJZHMuZm9yRWFjaChpZCAtPiBkZXBsb3ltZW50QXJ0aWZhY3RzLnZhbHVlcygpCisgICAgICAgICAgICAgICAgLnN0cmVhbSgpCisgICAgICAgICAgICAgICAgLmZpbHRlcihhIC0+IGEuZ2V0VW5pcXVlSWQoKS5lcXVhbHMoaWQpKQorICAgICAgICAgICAgICAgIC5maW5kRmlyc3QoKQorICAgICAgICAgICAgICAgIC5pZlByZXNlbnQoZyAtPiBhcnRpZmFjdHMuYWRkKG5ldyBBcnRpZmFj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udHNVdGlscy5jb252ZXJ0RnJvbVN0b3JhZ2VSZXNwb25zZShzdGF0dXMpKTsKICAgICAgICAgfQotICAgICAgICBpZiAodmFsaWRhdGlvblJlcyA9PSBudWxsKSB7Ci0gICAgICAgICAgICB2YWxpZGF0aW9uUmVzID0gRWl0aGVyLmxlZnQodHJ1ZSk7Ci0gICAgICAgIH0KLSAgICAgICAgcmV0dXJuIHZhbGlkYXRpb25SZXM7CisgICAgICAgIHJldHVybiB0cnVlOwogICAgIH0KIAogICAgIHByaXZhdGUgdm9pZCB2YWxpZGF0ZUltbXV0YWJsZVByb3BlcnR5KEdyb3VwUHJvcGVydHkgb2xkUHJvcGVydHksIEdyb3VwUHJvcGVydHkgbmV3UHJvcGVydHkpIHsKQEAgLTEwNjksNyArMTA0MCw3IEBACiAgICAgcHJpdmF0ZSBpbnQgZ2V0TmV3R3JvdXBDb3VudGVyKENvbXBvbmVudCBjb21wb25lbnQpIHsKICAgICAgICAgTGlzdDxTdHJpbmc+IGV4aXN0aW5nTmFtZXMgPSBjb21wb25lbnQuZ2V0R3JvdXBzKCkKICAgICAgICAgICAgICAgICAuc3RyZWFtKCkKLSAgICAgICAgICAgICAgICAubWFwKEdyb3VwRGF0YURlZmluaXRpb246OmdldE5hbWUpCisgICAgICAgICAgICAgICAgLm1hcChHcm91cERhdGFEZWZpbml0aW9uOjpnZXRJbnZhcmlhbnROYW1lKQogICAgICAgICAgICAgICAgIC5jb2xsZWN0KHRvTGlzdCgpKTsKICAgICAgICAgTGlzdDxTdHJpbmc+IGV4aXN0aW5nSWRzID0gY29tcG9uZW50LmdldEdyb3VwcygpCiAgICAgICAgICAgICAgICAgLnN0cmVhbSgpCkBAIC0xMTgwLDcgKzExNTEsNyBAQAogICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgR3JvdXBEZWZpbml0aW9uIGhhbmRsZWRHcm91cCA9IGhhbmRsZUdyb3VwUmVzLmxlZnQoK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lcnR5LnNldENvbnN0cmFpbnRzKGNvbnN0cmFpbnRzKTsKKyAgICAgICAgfQorICAgIH0KIAorICAgIHByaXZhdGUgc3RhdGljIExpc3Q8UHJvcGVydHlDb25zdHJhaW50PiBnZXRQcm9wZXJ0eUNvbnN0cmFpbnRzKE1hcDxTdHJpbmcsIE9iamVjdD4gcHJvcGVydHlWYWx1ZSwgU3RyaW5nIHByb3BlcnR5VHlwZSkgeworICAgICAgICBMaXN0PE9iamVjdD4gcHJvcGVydHlGaWVsZENvbnN0cmFpbnRzID0gZmluZEN1cnJlbnRMZXZlbENvbnN0cmFpbnRzRWxlbWVudChwcm9wZXJ0eVZhbHVlKTsKKyAgICAgICAgaWYgKENvbGxlY3Rpb25VdGlscy5pc05vdEVtcHR5KHByb3BlcnR5RmllbGRDb25zdHJhaW50cykpIHsKICAgICAgICAgICAgIExpc3Q8UHJvcGVydHlDb25zdHJhaW50PiBjb25zdHJhaW50TGlzdCA9IG5ldyBBcnJheUxpc3Q8PigpOwogICAgICAgICAgICAgVHlwZSBjb25zdHJhaW50VHlwZSA9IG5ldyBUeXBlVG9rZW48UHJvcGVydHlDb25zdHJhaW50PigpIHsKICAgICAgICAgICAgIH0uZ2V0VHlwZSgpOwogICAgICAgICAgICAgR3NvbiBnc29uID0gbmV3IEdzb25CdWlsZGVyKCkucmVnaXN0ZXJUeXBlQWRhcHRlcihjb25zdHJhaW50VHlwZSwgbmV3IFByb3BlcnR5Q29uc3RyYWludERlc2VyaWFsaXNlcigpKS5jcmVhdGUoKTsKIAotICAgICAgICAgICAgZm9yIChPYmplY3QgY29uc3RyYWludEpzb24gOiBqc29uQ29uc3RyYWludExpc3QpIHsKLSAgICAgICAgICAgICAgICBQcm9wZXJ0eUNvbnN0cmFpbnQgcHJvcGVydHlDb25zdHJhaW50ID0gZ3Nvbi5mcm9tSnNvbihnc29uLnRvSnNvbihjb25zdHJhaW50SnNvbiksIGNvbnN0cmFpbnRUeXBlKTsKKyAgICAgICAgICAgIGZvciAoT2JqZWN0IGNvbnN0cmFpbnRKc29uIDogcHJvcGVydHlGaWVsZENvbnN0cmFpbnRzKSB7CisgICAgICAgICAgICAgICAgUHJvcGVydHlDb25zdHJhaW50IHByb3BlcnR5Q29uc3RyYWludCA9IHZhbGlkYXRlQW5kR2V0UHJvcGVydHlDb25zdHJhaW50KHByb3BlcnR5VHlwZSwgY29uc3RyYWludFR5cGUsIGdzb24sIGNvbnN0cmFpbnRKc29uKTsKICAgICAgICAgICAgICAgICBjb25zdHJhaW50TGlzdC5hZGQocHJvcGVydHlDb25zdHJhaW50KTsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIHByb3BlcnR5LnNldENvbnN0cmFpbnRzKGNvbnN0cmFpbnRMaXN0KTsKKyAgICAgICAgICAgIHJldHVybiBjb25zdHJhaW50TGlzdDsKICAgICAgICAgfQorICAgICAgICByZXR1cm4gbnVsbDsKKyAgICB9CisKKyAgICBwcml2YXRlIHN0YXRpYyBMaXN0PE9iamVjdD4gZmluZEN1cnJlbnRMZXZlbENvbnN0cmFpbnRzRWxlbWVudChNYXA8U3RyaW5nLCBPYmplY3Q+IHRvc2NhSnNvbikgeworICAgICAgICBMaXN0PE9iamVjdD4gY29uc3RyYWludHMgPSBudWxsOworICAgICAgICBpZiAodG9zY2FKc29uLmNvbnRhaW5zS2V5KFR5cGVVdGlscy5Ub3NjYVRhZ05hbWVzRW51bS5DT05TVFJBSU5UUy5nZXRFbGVtZW50TmFtZSgpKSkgeworICAgICAgICAgICAgdHJ5IHsKKyAgICAgICAgICAgICAgICBjb25zdHJhaW50cyA9IChMaXN0PE9iamVjdD4pIHRvc2NhSnNvbi5nZXQoVHlwZVV0aWxzLlRvc2NhVGFnTmFtZXNFbnVtLkNPTlNUUkFJTlRTLmdldEVsZW1lbnROYW1lKCkpOworICAgICAgICAgICAgfSBjYXRjaCAoQ2xhc3NDYXN0RXhjZXB0aW9uIGUpeworICAgICAgICAgICAgICAgIHRocm93IG5ldyBCeUFjdGlvblN0YXR1c0NvbXBvbmVudEV4Y2VwdGlvbihBY3Rpb25TdGF0dXMuSU5WQUxJRF9QUk9QRVJUWV9DT05TVFJBSU5UU19GT1JNQVQsIHRvc2NhSnNvbi5nZXQoVHlwZVV0aWxzLlRvc2NhVGFnTmFtZXNFbnVtLkNPTlNUUkFJTlRTLmdldEVsZW1lbnROYW1lKCkpLnRvU3RyaW5nKCkpOworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgICAgIHJldHVybiBjb25zdHJhaW50czsKKworICAgIH0KKworICAgIHByaXZhdGUgc3RhdGljIFByb3BlcnR5Q29uc3RyYWludCB2YWxpZGF0ZUFuZEdldFByb3BlcnR5Q29uc3RyYWludChTdHJpbmcgcHJvcGVydHlUeXBlLCBUeXBlIGNvbnN0cmFpbnRUeXBlLCBHc29uIGdzb24sIE9iamVjdCBjb25zdHJhaW50SnNvbikgeworICAgICAgICBQcm9wZXJ0eUNvbnN0cmFpbnQgcHJvcGVydHlDb25zdHJhaW50OworICAgICAgICB0cnl7CisgICAgICAgICAgICBwcm9wZXJ0eUNvbnN0cmFpbnQgPSBnc29uLmZyb21Kc29uKGdzb24udG9Kc29uKGNvbnN0cmFpbnRKc29uKSwgY29uc3RyYWludFR5cGUpOworICAgICAgICB9IGNhdGNoIChDbGFzc0Nhc3RFeGNlcHRpb258SnNvblBhcnNlRXhjZXB0aW9uIGUpeworICAgICAgICAgICAgdGhyb3cgbmV3IEJ5QWN0aW9uU3RhdHVzQ29tcG9uZW50RXhjZXB0aW9uKEFjdGlvblN0YXR1cy5JTlZBTElEX1BST1BFUlRZX0NPTlNUUkFJTlRTX0ZPUk1BVCwgY29uc3RyYWludEpzb24udG9TdHJpbmcoKSk7CisgICAgICAgIH0KKyAgICAgICAgaWYocHJvcGVydHlDb25zdHJhaW50IT0gbnVsbCAmJiBwcm9wZXJ0eUNvbnN0cmFpbnQgaW5zdGFuY2VvZiBWYWxpZFZhbHVlc0NvbnN0cmFpbnQpeworICAgICAgICAgICAgdHJ5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Ub1N0b3JhZ2VTdGF0dXMoCi0gICAgICAgICAgICAgICAgICAgIEphbnVzR3JhcGhPcGVyYXRpb25TdGF0dXMuSUxMRUdBTF9BUkdVTUVOVCkpKSk7CisgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEJ5QWN0aW9uU3RhdHVzQ29tcG9uZW50RXhjZXB0aW9uKGNvbXBvbmVudHNVdGlscy5jb252ZXJ0RnJvbVN0b3JhZ2VSZXNwb25zZShEYW9TdGF0dXNDb252ZXJ0ZXIuY29udmVydEphbnVzR3JhcGhTdGF0dXNUb1N0b3JhZ2VTdGF0dXMoSmFudXNHcmFwaE9wZXJhdGlvblN0YXR1cy5JTExFR0FMX0FSR1VNRU5UKSkpOwogICAgICAgICAgICAgfQogICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgT2JqZWN0IG9iamVjdCA9IGlzVmFsaWQubGVmdCgpLnZhbHVlKCk7CkBAIC0yNzAsNyArMjc4LDcgQEAKICAgICAgICAgICAgICAgICBuZXdWYWx1ZSA9IG9iamVjdC50b1N0cmluZygpOwogICAgICAgICAgICAgfQogICAgICAgICB9Ci0gICAgICAgIHJldHVybiBFaXRoZXIubGVmdChuZXdWYWx1ZSk7CisgICAgICAgIHJldHVybiBuZXdWYWx1ZTsKICAgICB9CiAKICAgICBwcml2YXRlIElucHV0RGVmaW5pdGlvbiBnZXRJbnB1dEZyb21JbnB1dHNMaXN0QnlJZChMaXN0PElucHV0RGVmaW5pdGlvbj4gY29tcG9uZW50c09sZElucHV0cywgSW5wdXREZWZpbml0aW9uIGlucHV0KSB7CkBAIC0yODQsNyArMjkyLDcgQEAKICAgICAgICAgb3JnLm9wZW5lY29tcC5zZGMuYmUubW9kZWwuQ29tcG9uZW50IGNvbXBvbmVudCA9IG51bGw7CiAKICAgICAgICAgdHJ5IHsKLSAgICAgICAgICAgIHZhbGlkYXRlVXNlckV4aXN0cyh1c2VySWQsICJnZXQgaW5wdXQiLCBmYWxzZSk7CisgICAgICAgICAgICB2YWx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bXBvbmVudFBhcmFtZXRlcnNWaWV3KTsKIAogICAgICAgICAgICAgaWYgKHNob3VsZExvY2tDb21wKSB7Ci0gICAgICAgICAgICAgICAgRWl0aGVyPEJvb2xlYW4sIFJlc3BvbnNlRm9ybWF0PiBsb2NrQ29tcG9uZW50ID0gbG9ja0NvbXBvbmVudChjb21wb25lbnQsIFVQREFURV9JTlBVVCk7Ci0gICAgICAgICAgICAgICAgaWYgKGxvY2tDb21wb25lbnQuaXNSaWdodCgpKSB7Ci0gICAgICAgICAgICAgICAgICAgIHJlc3VsdCA9IEVpdGhlci5yaWdodChsb2NrQ29tcG9uZW50LnJpZ2h0KCkudmFsdWUoKSk7CisgICAgICAgICAgICAgICAgdHJ5IHsKKyAgICAgICAgICAgICAgICAgICAgbG9ja0NvbXBvbmVudChjb21wb25lbnQsIFVQREFURV9JTlBVVCk7CisgICAgICAgICAgICAgICAgfWNhdGNoIChDb21wb25lbnRFeGNlcHRpb24gZSl7CisgICAgICAgICAgICAgICAgICAgIHJlc3VsdCA9IEVpdGhlci5yaWdodChlLmdldFJlc3BvbnNlRm9ybWF0KCkpOwogICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgRWl0aGVyPEJvb2xlYW4sIFJlc3BvbnNlRm9ybWF0PiBjYW5Xb3JrID0gdmFsaWRhdGVDYW5Xb3JrT25Db21wb25lbnQoY29tcG9uZW50LCB1c2VySWQpOwotICAgICAgICAgICAgaWYgKGNhbldvcmsuaXNSaWdodCgpKSB7Ci0gICAgICAgICAgICAgICAgcmVzdWx0ID0gRWl0aGVyLnJpZ2h0KGNhbldvcmsucmlnaHQoKS52YWx1ZSgpKTsKLSAgICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0OwotICAgICAgICAgICAgfQotCi0JCQkvL1ZhbGlkYXRlIHZhbHVlIGFuZCBDb25zdHJhaW50IG9mIGlucHV0CisgICAgICAg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iwKKyAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0cmFpbnRWYWxpZGF0b3JSZXNwb25zZS5yaWdodCgpLnZhbHVlKCkpOworICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQoY29uc3RyYWludFZhbGlkYXRvclJlc3BvbnNlLnJpZ2h0KCkudmFsdWUoKSk7CiAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgIE1hcDxTdHJpbmcsIERhdGFUeXBlRGVmaW5pdGlvbj4gZGF0YVR5cGVzID0gYWxsRGF0YVR5cGVzLmxlZnQoKS52YWx1ZSgpOworICAgICAgICAgICAgdmFsaWRhdGVDYW5Xb3JrT25Db21wb25lbnQoY29tcG9uZW50LCB1c2VySWQpOworICAgICAgICAgICAgTWFwPFN0cmluZywgRGF0YVR5cGVEZWZpbml0aW9uPiBkYXRhVHlwZXM7CisgICAgICAgICAgICBkYXRhVHlwZXMgPSBnZXRBbGxEYXRhVHlwZXMoYXBwbGljYXRpb25EYXRhVHlwZUNhY2hlKTsKKwogICAgICAgICAgICAgTGlzdDxJbnB1dERlZmluaXRpb24+IGNvbXBvbmVudHNPbGRJbnB1dHMgPSBPcHRpb25hbC5vZk51bGxhYmxlKGNvbXBvbmVudC5nZXRJbnB1dHMoKSkub3JFbHNlKENvbGxlY3Rpb25zLmVtcHR5TGlzdCgpKTsKICAgICAgICAgICAgIGZvciAoSW5wdXREZWZpbml0aW9uIG5ld0lucHV0OiBpbnB1dHMpIHsKICAgICAgICAgICAgICAgICBJbnB1dERlZmluaXRpb24gY3VycklucHV0ID0gZ2V0SW5wdXRGcm9tSW5wdXRzTGlzdEJ5SWQoY29tcG9uZW50c09sZElucHV0cywgbmV3SW5wdXQpOwpAQCAtMzQwLDEzICszMzQsOCBAQAogICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSBFaXRoZXIucmlnaHQoY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KGFjdGlvblN0YXR1cykpOwogICAgIC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Db21wb25lbnQoY29tcG9uZW50LCBjdXJySW5wdXQpOwogICAgICAgICAgICAgICAgIGlmKHN0YXR1cy5pc1JpZ2h0KCkpewpAQCAtMzU4LDIyICszNDcsMTYgQEAKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICByZXN1bHQgPSBFaXRoZXIubGVmdChyZXR1cm5JbnB1dHMpOwotICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKLSAgICAgICAgfSBmaW5hbGx5IHsKLSAgICAgICAgICAgICAgICBpZiAoIWluVHJhbnNhY3Rpb24pIHsKLSAgICAgICAgICAgICAgICAgICAgaWYgKHJlc3VsdCA9PSBudWxsIHx8IHJlc3VsdC5pc1JpZ2h0KCkpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZyhHT0lOR19UT19FWEVDVVRFX1JPTExCQUNLX09OX0NSRUFURV9HUk9VUCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBqYW51c0dyYXBoRGFvLnJvbGxiYWNrKCk7Ci0gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBsb2cuZGVidWcoR09JTkdfVE9fRVhFQ1VURV9DT01NSVRfT05fQ1JFQVRFX0dST1VQKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGphbnVzR3JhcGhEYW8uY29tbWl0KCk7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgLy8gdW5sb2NrIHJlc291cmNlCi0gICAgICAgICAgICAgICAgaWYgKHNob3VsZExvY2tDb21wICYmIGNvbXBvbmVudCAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgIGdyYXBoTG9ja09wZXJhdGlvbi51bmxvY2tDb21wb25lbnQoY29tcG9uZW50SWQsIGNvbXBvbmVudFR5cGUuZ2V0Tm9kZVR5cGUoKSk7Ci0gICAgICAgICAgICAgICAg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bnQgLT4gdmFsaWRhdGVDYW5Xb3JrT25Db21wb25lbnQoY29tcG9uZW50LCB1c2VySWQpLmxlZnQoKS5tYXAocmVzdWx0IC0+IGNvbXBvbmVudCkpOwotICAgICAgICBpZiAoY29tcG9uZW50RWl0aGVyLmlzUmlnaHQoKSkgewotICAgICAgICAgICAgdGhyb3cgbmV3IEJ5UmVzcG9uc2VGb3JtYXRDb21wb25lbnRFeGNlcHRpb24oY29tcG9uZW50RWl0aGVyLnJpZ2h0KCkudmFsdWUoKSk7CisgICAgICAgIG9yZy5vcGVuZWNvbXAuc2RjLmJlLm1vZGVsLkNvbXBvbmVudCBjb21wb25lbnQgPSB2YWxpZGF0ZUNvbXBvbmVudEV4aXN0cyhjb21wb25lbnRJZCwgY29tcG9uZW50VHlwZSwgY29tcG9uZW50UGFyYW1ldGVyc1ZpZXcpOworICAgICAgICBpZiAoc2hvdWxkTG9ja0NvbXApIHsKKyAgICAgICAgICAgIC8vIGxvY2sgdGhlIGNvbXBvbmVudAorICAgICAgICAgICAgbG9ja0NvbXBvbmVudChjb21wb25lbnQsIENSRUFURV9JTlBVVCk7CiAgICAgICAgIH0KLSAgICAgICAgcmV0dXJuIGNvbXBvbmVudEVpdGhlci5sZWZ0KCkudmFsdWUoKTsKKyAgICAgICAgdmFsaWRhdGVDYW5Xb3JrT25Db21wb25lbnQoY29tcG9uZW50LCB1c2VySWQpOworICAgICAgICByZXR1cm4gY29tcG9uZW50OwogICAgIH0KIAogICAgIHByaXZhdGUgRGF0YVR5cGVEZWZpbml0aW9uIHByZXBhcmVEYXRhVHlwZUZvckxpc3RJbnB1dChDb21wb25lbnRJbnN0SW5wdXRzTWFwIGlucHV0c01hcCwgSW5wdXREZWZpbml0aW9uIGlucHV0KSB7CkBAIC02MTUsNyArNTg5LDcgQEAKICAgICAgICAgRGF0YVR5cGVEZWZpbml0aW9uIGRhdGFUeXBlID0gbmV3IERhdGFUeXBlRGVmaW5pdGlvbigpOwogICAgICAgICBMaXN0PENvbX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bnB1dCgpKSl7CiAgICAgICAgICAgICAgICAgZGVsZXRlRWl0aGVyID0gZGVsZXRlTGlzdElucHV0KGNvbXBvbmVudElkLCBpbnB1dElkLCBjb21wb25lbnQsIGlucHV0Rm9yRGVsZXRlLCBzdGF0dXMpOwotICAgICAgICAgICAgICAgIHJldHVybiBkZWxldGVFaXRoZXI7CisgICAgICAgICAgICAgICAgaWYgKGRlbGV0ZUVpdGhlci5pc1JpZ2h0KCkpeworICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgQnlSZXNwb25zZUZvcm1hdENvbXBvbmVudEV4Y2VwdGlvbihkZWxldGVFaXRoZXIucmlnaHQoKS52YWx1ZSgpKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgcmV0dXJuIGRlbGV0ZUVpdGhlci5sZWZ0KCkudmFsdWUoKTsKICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgU3RvcmFnZU9wZXJhdGlvblN0YXR1cyBzdG9yYWdlT3BlcmF0aW9uU3RhdHVzID0KICAgICAgICAgICAgICAgICBwcm9wZXJ0eURlY2xhcmF0aW9uT3JjaGVzdHJhdG9yLnVuRGVjbGFyZVByb3BlcnRpZXNBc0lucHV0cyhjb21wb25lbnQsIGlucHV0Rm9yRGVsZXRlKTsKICAgICAgICAgICAgIGlmIChzdG9yYWdlT3BlcmF0aW9uU3RhdHVzICE9IFN0b3JhZ2VPcGVyYXRpb25TdGF0dXMuT0spIHsKICAgICAgICAgICAgICAgICBsb2cuZGVidWcoIkNvbXBvbmVudCBpZDoge30gdXBkYXRlIHByb3BlcnRpZXMgZGVjbGFyZWQgYXMgaW5wdXQgZm9yIGlucHV0IGlkOiB7fSBmYWlsZWQiLCBjb21wb25lbnRJZCwgaW5wdXRJZCk7Ci0gICAgICAgICAgICAgICAgZGVsZXRlRWl0aGVyID0gRWl0aGVyLnJpZ2h0KGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdCgKLSAgICAgICAgICAgICAgICAgICAgY29tcG9uZW50c1V0aWxzLmNvbnZlcnRGcm9tU3RvcmFnZVJlc3BvbnNlKHN0YXR1cyksIGNvbXBvbmVudC5nZXROYW1lKCkpKTsKLSAgICAgICAgICAgICAgICByZXR1cm4gZGVsZXRlRWl0aGVyOworICAgICAgICAgICAgICAgIHRocm93IG5ldyBCeUFjdGlvblN0YXR1c0NvbXBvbmVudEV4Y2VwdGlvbihjb21wb25lbnRzVXRpbHMuY29udmVydEZyb21TdG9yYWdlUmVzcG9uc2Uoc3RvcmFnZU9wZXJhdGlvblN0YXR1cyksIGNvbXBvbmVudC5nZXROYW1lKCkpOwogICAgICAgICAgICAgfQotCi0gICAgICAgICAgICBkZWxldGVFaXRoZXIgPSBFaXRoZXIubGVmdChpbnB1dEZvckRlbGV0ZSk7Ci0gICAgICAgICAgICByZXR1cm4gZGVsZXRlRWl0aGVyOwotICAgICAgICB9IGZpbmFsbHkgewotICAgICAgICAgICAgaWYgKGRlbGV0ZUVpdGhlciA9PSBudWxsIHx8IGRlbGV0ZUVpdGhlci5pc1JpZ2h0KCkpIHsKLSAgICAgICAgICAgICAgICBsb2cuZGVidWcoIkNvbXBvbmVudCBpZDoge30gZGVsZXRlIGlucHV0IGlkOiB7fSBmYWlsZWQiLCBjb21wb25lbnRJZCwgaW5wdXRJZCk7Ci0gICAgICAgICAgICAgICAgamFudXNHcmFwaERhby5yb2xsYmFjaygpOwotICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICBsb2cuZGVidWcoIkNvbXBvbmVudCBpZDoge30gZGVsZXRlIGlucHV0IGlkOiB7fSBzdWNjZXNzIiwgY29tcG9uZW50SWQsIGlucHV0SWQpOwotICAgICAgICAgICAgICAgIGphbnVzR3JhcGhEYW8uY29tbWl0KCk7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICB1bmxvY2tDb21wb25lbnQoZGVsZXRlRWl0aGVyLCBjb21wb25lbnQpOworICAgICAgICAgICAgcmV0dXJuICBpb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LDEwICsyMDUsOCBAQAogICAgICAgICAgICAgamFudXNHcmFwaERhby5yb2xsYmFjaygpOwogICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLklOVEVSRkFDRV9PUEVSQVRJT05fTk9UX0RFTEVURUQpKTsKICAgICAgICAgfSBmaW5hbGx5IHsKLSAgICAgICAgICAgIGlmIChsb2NrUmVzdWx0LmlzTGVmdCgpICYmIGxvY2tSZXN1bHQubGVmdCgpLnZhbHVlKCkpIHsKLSAgICAgICAgICAgICAgICBncmFwaExvY2tPcGVyYXRpb24udW5sb2NrQ29tcG9uZW50KHN0b3JlZENvbXBvbmVudC5nZXRVbmlxdWVJZCgpLAotICAgICAgICAgICAgICAgICAgICAgICAgTm9kZVR5cGVFbnVtLmdldEJ5TmFtZUlnbm9yZUNhc2Uoc3RvcmVkQ29tcG9uZW50LmdldENvbXBvbmVudFR5cGUoKS5nZXRWYWx1ZSgpKSk7Ci0gICAgICAgICAgICB9CisgICAgICAgICAgICBncmFwaExvY2tPcGVyYXRpb24udW5sb2NrQ29tcG9uZW50KHN0b3JlZENvbXBvbmVudC5nZXRVbmlxdWVJZCgpLAorICAgICAgICAgICAgICAgICAgICBOb2RlVHlwZUVudW0uZ2V0QnlOYW1lSWdub3JlQ2FzZShzdG9yZWRDb21wb25lbnQuZ2V0Q29tcG9uZW50VHlwZSgpLmdldFZhbHVlKCkpKTsKICAgICAgICAgfQogICAgIH0KIApAQCAtMjI4LDE4ICsyMjMsMTkgQEAKICAgICBwcml2YXRlIEVpdGhlcjxCb29sZWFuLCBSZXNwb25zZUZvcm1hdD4gbG9ja0NvbXBvbmVudFJlc3VsdChib29sZWFuIGxvY2ssCiAgICAgICAgICAgICBvcmcub3BlbmVjb21wLnNkYy5iZS5tb2RlbC5Db21wb25lbnQgY29tcG9uZW50LCBTdHJpbmcgYWN0aW9uKSB7CiAgICAg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pY3lUeXBlTmFtZSwgYyk7CiAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZSkgeworICAgICAgICAgICAgaWYgKENvbXBvbmVudEV4Y2VwdGlvbi5jbGFzcy5lcXVhbHMoZS5nZXRDbGFzcygpKSkgeworICAgICAgICAgICAgICAgIHRocm93IGU7CisgICAgICAgICAgICB9CiAgICAgICAgICAgICBsb2cuZXJyb3IoIiNjcmVhdGVQb2xpY3kgLSB0aGUgZXhjZXB0aW9uICBvY2N1cnJlZCB1cG9uIGNyZWF0aW9uIG9mIGEgcG9saWN5IG9mIHRoZSB0eXBlIHt9IGZvciB0aGUgY29tcG9uZW50IHt9OiAiLCBwb2xpY3lUeXBlTmFtZSwgY29tcG9uZW50SWQsIGUpOwogICAgICAgICAgICAgcmVzdWx0ID0gRWl0aGVyLnJpZ2h0KGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUikpOwogICAgICAgICB9IGZpbmFsbHkgewotCisgICAgICAgICAgICAvL1RPRE8gQW5kcmV5IHJlc3VsdCA9IGJvb2xlYW4KICAgICAgICAgICAgIHVubG9ja0NvbXBvbmVudChzaG91bGRMb2NrLCByZXN1bHQsIGNvbXBvbmVudCk7CiAgICAgICAgIH0KICAgICAgICAgcmV0dXJuIHJlc3VsdDsKLSAgICB9CisgICAgfSovCiAKICAgICBwdWJsaWMgRWl0aGVyPExpc3Q8UG9saWN5RGVmaW5pdGlvbj4sIFJlc3BvbnNlRm9ybWF0PiBnZXRQb2xpY2llc0xpc3QoQ29tcG9uZW50VHlwZUVudW0gY29tcG9uZW50VHlwZSwgU3RyaW5nIGNvbXBvbmVudElkLCBTdHJpbmcgdXNlcklkKSB7CiAgICAgICAgIEVpdGhlcjxMaXN0PFBvbGljeURlZmluaXRpb24+LCBSZXNwb25zZUZvcm1hdD4gcmVzdWx0OwogICAgICAgICBsb2cudHJhY2UoIiNnZXRQb2xpY2llcyAtIHN0YXJ0aW5nIHRvIHJldHJpZXZlIHBvbGljaWVzIG9mIGNvbXBvbmVudCB7fS4gIiwgY29tcG9uZW50SWQpOwogICAgICAgICB0cnkgewotICAgICAgICAgICAgcmVzdWx0ID0gdmFsaWRhdGVDb250YWluZXJDb21wb25lbnRBbmRVc2VyQmVmb3JlUmVhZE9wZXJhdGlvbihjb21wb25lbnRUeXBlLCBjb21wb25lbnRJZCwgdXNlcklkKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAubGVmdCgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5iaW5kKGMgLT4gRWl0aGVyLmxlZnQoYy5yZXNvbHZlUG9saWNpZXNMaXN0KCkpKTsKKyAgICAgICAgICAgIENvbXBvbmVudCBjb21wb25lbnQgPSB2YWxpZGF0ZUNvbnRhaW5lckNvbXBvbmVudEFuZFVzZXJCZWZvcmVSZWFkT3BlcmF0aW9uKGNvbXBvbmVudFR5cGUsIGNvbXBvbmVudElkLCB1c2VySWQpOworICAgICAgICAgICAgcmVzdWx0ID0gRWl0aGVyLmxlZnQoY29tcG9uZW50LnJlc29sdmVQb2xpY2llc0xpc3QoKSk7CiAgICAgICAgIH0gY2F0Y2ggKEV4Y2VwdGlvbiBlKSB7CiAgICAgICAgICAgICBsb2cuZXJyb3IoIiNnZXRQb2xpY3kgLSB0aGUgZXhjZXB0aW9uIG9jY3VycmVkIHVwb24gcmV0cmlldmluZyBwb2xpY2llcyBsaXN0IG9mIGNvbXBvbmVudCB7fTogIiwgY29tcG9uZW50SWQsIGUpOwogICAgICAgICAgICAgcmVzdWx0ID0gRWl0aGVyLnJpZ2h0KGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUikpOwpAQCAtMTQxLDYgKzE2MSw4IEBACiAgICAgICAgIHJldHVybiByZXN1bHQ7CiAgICAgfQogCisKKwogICAgIC8qKg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cmUgcG9saWN5IHt9IG9uIGNvbXBvbmVudCB7fS4gIiwgcG9saWN5SWQsIGNvbXBvbmVudElkKTsKICAgICAgICAgV3JhcHBlcjxDb21wb25lbnQ+IGNvbXBvbmVudCA9IG5ldyBXcmFwcGVyPD4oKTsKICAgICAgICAgdHJ5IHsKLSAgICAgICAgICAgIEVpdGhlcjxDb21wb25lbnQsIFJlc3BvbnNlRm9ybWF0PiBjb21wb25lbnRFaXRoZXIgPQotICAgICAgICAgICAgICAgICAgICB2YWxpZGF0ZUFuZExvY2tDb21wb25lbnRBbmRVc2VyQmVmb3JlV3JpdGVPcGVyYXRpb24oY29tcG9uZW50VHlwZSwgY29tcG9uZW50SWQsIHVzZXJJZCwgc2hvdWxkTG9jayk7Ci0gICAgICAgICAgICBpZiAoY29tcG9uZW50RWl0aGVyLmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQoY29tcG9uZW50RWl0aGVyLnJpZ2h0KCkudmFsdWUoKSk7Ci0gICAgICAgICAgICB9CisgICAgICAgICAgICB2YWxpZGF0ZUFuZExvY2tDb21wb25lbnRBbmRVc2VyQmVmb3JlV3JpdGVPcGVyYXRpb24oY29tcG9uZW50VHlwZSwgY29tcG9uZW50SWQsIHVzZXJJZCwgc2hvdWxkTG9jayk7CiAKICAgICAgICAgICAgIENvbXBvbmVudFBhcmFtZXRlcnNWaWV3IGNvbXBvbmVudFBhcmFtZXRlcnNWaWV3ID0gbmV3IENvbXBvbmVudFBhcmFtZXRlcnNWaWV3KCk7CiAgICAgICAgICAgICBjb21wb25lbnRQYXJhbWV0ZXJzVmlldy5kaXNhYmxlQWxsKCk7CkBAIC0yODcsMTE3ICszNDgsMTEzIEBACiAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7Ci0gICAgICAgIH0gY2F0Y2ggKEV4Y2VwdGlvbiBlKSB7CisgICAgfWNhdGNoIChFeGNlcHRpb24gZSkgewogICAgICAgICAgICAgbG9nLmVycm9yKCIjdW5kZWNsYXJlUG9saWN5IC0gdGhlIGV4Y2VwdGlvbiBvY2N1cnJlZCB1cG9uIHVwZGF0ZSBvZiBhIHBvbGljeSBvZiB0eXBlIHt9IGZvciBjb21wb25lbnQge306ICIsIHBvbGljeUlkLCBjb21wb25lbnRJZCwgZSk7CiAgICAgICAgICAgICByZXR1cm4gRWl0aGVyLnJpZ2h0KGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUiwgZS5nZXRNZXNzYWdlKCkpKTsKICAgICAgICAgfSBmaW5hbGx5IHsKLSAgICAgICAgICAgIHVubG9ja0NvbXBvbmVudChzaG91bGRMb2NrLCByZXN1bHQsIGNvbXBvbmVudCk7CisgICAgICAgICAgICBpZiAocmVzdWx0ID09IG51bGwgfHwgcmVzdWx0LmlzUmlnaHQoKSl7CisgICAgICAgICAgICAgICAgdW5sb2NrQ29tcG9uZW50KHNob3VsZExvY2ssIHRydWUsIGNvbXBvbmVudCk7CisgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgIHVubG9ja0NvbXBvbmVudChzaG91bGRMb2NrLCBmYWxzZSwgY29tcG9uZW50KTsKKyAgICAgICAgICAgIH0KICAgICAgICAgfQogICAgIH0KIAotCi0gICAgcHJpdmF0ZSBFaXRoZXI8UG9saWN5RGVmaW5pdGlvbiwgUmVzcG9uc2VGb3JtYXQ+IHVuZGVjbGFyZVBvbGljeShQb2xpY3lEZWZpbml0aW9uIHBvbGljeURlZmluaXRpb24sIENvbXBvbmVudCBjb250YWluZXJDb21wb25lbnQpIHsKLSAgICAgICAgU3RvcmFnZU9wZXJhdGlvblN0YXR1cyB1bmRlY2xhcmVTdGF0dXMgPSBwcm9wZXJ0eURlY2xhcmF0aW9uT3JjaGVzdHJhdG9yCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC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ICAgICAgaWYodW5kZWNsYXJlU3RhdHVzICE9IFN0b3JhZ2VPcGVyYXRpb25TdGF0dXMuT0speworICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQoY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KHVuZGVjbGFyZVN0YXR1cykpOworICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICByZXR1cm4gRWl0aGVyLmxlZnQocG9saWN5RGVmaW5pdGlvbik7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KIAotICAgICAgICByZXR1cm4gT3B0aW9uYWwuZW1wdHkoKTsKLSAgICB9CiAKLSAgICBwcml2YXRlIE9wdGlvbmFsPENvbXBvbmVudEluc3RhbmNlUHJvcGVydHk+IGdldFByb3BlcnR5Rm9yRGVjbGFyZWRQb2xpY3koU3RyaW5nIHBvbGljeUlkLCBMaXN0PENvbXBvbmVudEluc3RhbmNlUHJvcGVydHk+IGNvbXBvbmVudEluc3RhbmNlUHJvcGVydGllcykgewotICAgICAgICBmb3IoQ29tcG9uZW50SW5zdGFuY2VQcm9wZXJ0eSBwcm9wZXJ0eSA6IGNvbXBvbmVudEluc3RhbmNlUHJvcGVydGllcykgewotICAgICAgICAgICAgT3B0aW9uYWw8R2V0UG9saWN5VmFsdWVEYXRhRGVmaW5pdGlvbj4gZ2V0UG9saWN5Q2FuZGlkYXRlID0gcHJvcGVydHkuc2FmZUdldEdldFBvbGljeVZhbHVlcygpLnN0cmVhbSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5maWx0ZXIoZ2V0UG9saWN5VmFsdWUgLT4gZ2V0UG9saWN5VmFsdWUuZ2V0UG9saWN5SWQoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmVxdWFscyhwb2xpY3lJZCkpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5maW5kQW55KCk7Ci0KLSAgICAgICAgICAgIGlmKGdldFBvbGljeUNhbmRpZGF0ZS5pc1ByZXNlbnQoKSkgewotICAgICAgICAgICAgICAgIHJldHVybiBPcHRpb25hbC5vZihwcm9wZXJ0eSk7CisgICAgICAgIHByaXZhdGUgT3B0aW9uYWw8UG9saWN5RGVmaW5pdGlvbj4gZ2V0UG9saWN5Rm9yVW5kZWNsYXJhdGlvbihTdHJpbmcgcG9saWN5SWQsIENvbXBvbmVudCBjb21wb25lbnQpIHsKKyAgICAgICAgICAgIE1hcDxTdHJpbmcsIFBvbGljeURlZmluaXRpb24+IHBvbGljaWVzID0gY29tcG9uZW50LmdldFBvbGljaWVzKCk7CisgICAgICAgICAgICBpZihNYXBVdGlscy5pc05vdEVtcHR5KHBvbGljaWVzKSAmJiBwb2xpY2llcy5jb250YWluc0tleShwb2xpY3lJZCkpIHsKKyAgICAgICAgICAgICAgICByZXR1cm4gT3B0aW9uYWwub2YocG9saWNpZXMuZ2V0KHBvbGljeUlkKSk7CiAgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIE1hcDxTdHJpbmcsIExpc3Q8Q29tcG9uZW50SW5zdGFuY2VQcm9wZXJ0eT4+IGNvbXBvbmVudEluc3RhbmNlc1Byb3BlcnRpZXMgPQorICAgICAgICAgICAgICAgICAgICBNYXBVdGlscy5pc0VtcHR5KGNvbXBvbmVudC5nZXRDb21wb25lbnRJbnN0YW5jZXNQcm9wZXJ0aWVzKCkpID8gbmV3IEhhc2hNYXA8PigpIDogY29tcG9uZW50LmdldENvbXBvbmVudEluc3RhbmNlc1Byb3BlcnRpZXMoKTsKKworICAgICAgICAgICAgZm9yKE1hcC5FbnRyeTxTdHJpbmcsIExpc3Q8Q29tcG9uZW50SW5zdGFuY2VQcm9wZXJ0eT4+IGluc3RhbmNlUHJvcGVydHlFbnRyeSA6IGNvbXBvbmVudEluc3RhbmNlc1Byb3BlcnRpZXMuZW50cnlTZXQoKSkgeworICAgICAgICAgICAgICAgIE9wdGlvbmFsPENvbXBvbmVudEluc3RhbmNlUHJvcGVydHk+IHByb3BlcnR5Q2FuZGlkYXRlID0gZ2V0UHJvcGVydHlGb3JEZWNsYXJlZFBvbGljeShwb2xpY3lJZCwgaW5zdGFuY2VQcm9wZXJ0eUVudHJ5LmdldFZhbHVlKCkpOworCisgICAgICAgICAgICAgICAgaWYocHJvcGVydHlDYW5kaWRhdGUuaXNQcmVzZW50KCkpIHsKKyAgICAgICAgICAgICAgICAgICAgcmV0dXJuIE9wdGlvbmFsLm9mKAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIFBvbGljeVV0aWxzLmdldERlY2xhcmVkUG9saWN5RGVmaW5pdGlvbihpbnN0YW5jZVByb3BlcnR5RW50cnkuZ2V0S2V5KCksIHByb3BlcnR5Q2FuZGlkYXRlLmdldCgpKSk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfQorCisgICAgICAgICAgICByZXR1cm4gT3B0aW9uYWwuZW1wdHkoKTsKICAgICAgICAgfQogCi0gICAgICAgIHJldHVybiBPcHRpb25hbC5lbXB0eSgpOwotICAgIH0KKyAgICAgICAgcHJpdmF0ZSBPcHRpb25hbDxDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5PiBnZXRQcm9wZXJ0eUZvckRlY2xhcmVkUG9saWN5KFN0cmluZyBwb2xpY3lJZCwgTGlzdDxDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5PiBjb21wb25lbnRJbnN0YW5jZVByb3BlcnRpZXMpIHsKKyAgICAgICAgICAgIGZvcihDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5IHByb3BlcnR5IDogY29tcG9uZW50SW5zdGFuY2VQcm9wZXJ0aWVzKSB7CisgICAgICAgICAgICAgICAgT3B0aW9uYWw8R2V0UG9saWN5VmFsdWVEYXRhRGVmaW5pdGlvbj4gZ2V0UG9saWN5Q2FuZGlkYXRlID0gcHJvcGVydHkuc2FmZUdldEdldFBvbGljeVZhbHVlcygpLnN0cmVhbSgpCisgICAgICAgICAgICAgICAgICAgICAgICAuZmlsdGVyKGdldFBvbGljeVZhbHVlIC0+IGdldFBvbGljeVZhbHVlLmdldFBvbGljeUlkKCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmVxdWFscyhwb2xpY3lJZCkpCisgICAgICAgICAgICAgICAgICAgICAgICAuZmluZEFueSgpOwogCi0gICAgcHVibGljIEVpdGhlcjxQb2xpY3lEZWZpbml0aW9uLCBSZXNwb25zZUZvcm1hdD4gdXBkYXRlUG9saWN5VGFyZ2V0cyhDb21wb25lbnRUeXBlRW51bSBjb21wb25lbnRUeXBlRW51bSwgU3RyaW5nIGNvbXBvbmVudElkLCBTdHJpbmcgcG9saWN5SWQsIE1hcDxQb2xpY3lUYXJnZXRUeXBlLCBMaXN0PFN0cmluZz4+IHRhcmdldHMsIFN0cmluZyB1c2VySWQpIHsKKyAgICAgICAgICAgICAgICBpZihnZXRQb2xpY3lDYW5kaWRhdGUuaXNQcmVzZW50KCkpIHsKKyAgICAgICAgICAgICAgICAgICAgcmV0dXJuIE9wdGlvbmFsLm9mKHByb3BlcnR5KTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIHJldHVybiBPcHRpb25hbC5lbXB0eSgpOworICAgICAgICB9CisKKworICAgICAgICBwdWJsaWMgUG9saWN5RGVmaW5pdGlvbiB1cGRhdGVQb2xpY3lUYXJnZXRzKENvbXBvbmVudFR5cGVFbnVtIGNvbXBvbmVudFR5cGVFbnVtLCBTdHJpbmcgY29tcG9uZW50SWQsIFN0cmluZyBwb2xpY3lJZCwgTWFwPFBvbGljeVRhcmdldFR5cGUsIExpc3Q8U3RyaW5nPj4gdGFyZ2V0cywgU3RyaW5nIHVzZXJJZCkgewogCiAgICAgICAgIEVpdGhlcjxQb2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IHBvbGljeSBwcm9wZXJ0aWVzIGZvciBjb21wb25lbnQge30gYW5kIHBvbGljeSB7fSIsIGNvbXBvbmVudElkLCBwb2xpY3lJZCk7CisgICAgICAgIHRyeSB7CisgICAgICAgICAgICBDb21wb25lbnQgY29tcG9uZW50ID0gdmFsaWRhdGVDb250YWluZXJDb21wb25lbnRBbmRVc2VyQmVmb3JlUmVhZE9wZXJhdGlvbihjb21wb25lbnRUeXBlLCBjb21wb25lbnRJZCwgdXNlcklkKTsKKyAgICAgICAgICAgIHJldHVybiBnZXRQb2xpY3lCeUlkKGNvbXBvbmVudCwgcG9saWN5SWQpLmdldFByb3BlcnRpZXMoKTsKKyAgICAgICAgfSBmaW5hbGx5IHsKKyAgICAgICAgICAgIGphbnVzR3JhcGhEYW8uY29tbWl0KCk7CisgICAgICAgIH0KKyAgICB9CisKKyAgICAvKnB1YmxpYyBFaXRoZXI8TGlzdDxQcm9wZXJ0eURhdGFEZWZpbml0aW9uPiwgUmVzcG9uc2VGb3JtYXQ+IGdldFBvbGljeVByb3BlcnRpZXMoQ29tcG9uZW50VHlwZUVudW0gY29tcG9uZW50VHlwZSwgU3RyaW5nIGNvbXBvbmVudElkLCBTdHJpbmcgcG9saWN5SWQsIFN0cmluZyB1c2VySWQpIHsKICAgICAgICAgbG9nLmRlYnVnKCIjZ2V0UG9saWN5UHJvcGVydGllcyAtIGZldGNoaW5nIHBvbGljeSBwcm9wZXJ0aWVzIGZvciBjb21wb25lbnQge30gYW5kIHBvbGljeSB7fSIsIGNvbXBvbmVudElkLCBwb2xpY3lJZCk7CiAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICByZXR1cm4gdmFsaWRhdGVDb250YWluZXJDb21wb25lbnRBbmRVc2VyQmVmb3JlUmVhZE9wZXJhdGlvbihjb21wb25lbnRUeXBlLCBjb21wb25lbnRJZCwgdXNlcklkKQpAQCAtNDMxLDcgKzQ5OCw3IEBACiAgICAgICAgIH0gZmluYWxseSB7CiAgICAgICAgICAgICBqY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NlRm9ybWF0KEFjdGlvblN0YXR1cy5HRU5FUkFMX0VSUk9SKSk7CisgICAgICAgICAgICBjb21wb25lbnQgPSB2YWxpZGF0ZUFuZExvY2tDb21wb25lbnRBbmRVc2VyQmVmb3JlV3JpdGVPcGVyYXRpb24oY29tcG9uZW50VHlwZSwgY29tcG9uZW50SWQsIHVzZXJJZCwgc2hvdWxkTG9jayk7CisgICAgICAgICAgICBmYWlsZWQgPSBmYWxzZTsKKyAgICAgICAgICAgIHJlc3VsdCA9IHNldENvbXBvbmVudFZhbGlkYXRlVXBkYXRlUG9saWN5UHJvcGVydGllcyhwb2xpY3lJZCwgcHJvcGVydGllcywgY29tcG9uZW50KTsKICAgICAgICAgfSBmaW5hbGx5IHsKLSAgICAgICAgICAgIGlmIChzaG91bGRMb2NrICYmICFjb21wb25lbnQuaXNFbXB0eSgpKSB7Ci0gICAgICAgICAgICAgICAgdW5sb2NrQ29tcG9uZW50KHJlc3VsdCwgY29tcG9uZW50LmdldElubmVyRWxlbWVudCgpKTsKKyAgICAgICAgICAgIGlmIChzaG91bGRMb2NrICYmICFmYWlsZWQpIHsKKyAgICAgICAgICAgICAgICB1bmxvY2tDb21wb25lbnQoZmFpbGVkLCBjb21wb25lbnQpOwogICAgICAgICAgICAgfQogICAgICAgICB9CiAgICAgICAgIHJldHVybiByZXN1bHQ7CkBAIC00NzYsNyArNTQyLDcgQEAKICAgICAgICAgb3JnLm9wZW5lY29tcC5zZGMuYmUubW9kZWwuQ29tcG9uZW50IGNvbXBvbmVudCA9IG51bGw7CiAKICAgICAgICAgdHJ5IHsKLSAgICAgICAgICAgIHZhbGlkYXRlVXNlckV4aXN0cyh1c2VySWQsIERFQ0xBUkVfUFJPUEVSVElFU19UT19QT0xJQ0lFUywgZmFsc2UpOworICAgICAgICAgICAgdmFsaWRhdGVVc2VyRXhpc3RzKHVzZXJJZCk7CiAKICAgICAgICAgICAgIENvbXBvbmVudFBhcmFtZXRlcnNWaWV3IGNvbXBvbmVudFBhcm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sb2NrQ29tcG9uZW50KGJvb2xlYW4gc2hvdWxkTG9jaywgYm9vbGVhbiByZXN1bHQsIFdyYXBwZXI8Q29tcG9uZW50PiBjb21wb25lbnQpIHsKICAgICAgICAgaWYgKHNob3VsZExvY2sgJiYgIWNvbXBvbmVudC5pc0VtcHR5KCkpIHsKICAgICAgICAgICAgIHVubG9ja0NvbXBvbmVudChyZXN1bHQsIGNvbXBvbmVudC5nZXRJbm5lckVsZW1lbnQoKSk7CiAgICAgICAgIH0KICAgICB9CiAKLSAgICBwcml2YXRlIEVpdGhlcjxQb2xpY3lEZWZpbml0aW9uLCBSZXNwb25zZUZvcm1hdD4gZ2V0UG9saWN5QnlJZChDb21wb25lbnQgY29tcG9uZW50LCBTdHJpbmcgcG9saWN5SWQpIHsKKyAgICBwcml2YXRlIFBvbGljeURlZmluaXRpb24gZ2V0UG9saWN5QnlJZChDb21wb25lbnQgY29tcG9uZW50LCBTdHJpbmcgcG9saWN5SWQpIHsKICAgICAgICAgUG9saWN5RGVmaW5pdGlvbiBwb2xpY3lCeUlkID0gY29tcG9uZW50LmdldFBvbGljeUJ5SWQocG9saWN5SWQpOwogICAgICAgICBpZiAocG9saWN5QnlJZCA9PSBudWxsKSB7CiAgICAgICAgICAgICBTdHJpbmcgY21wdElkID0gY29tcG9uZW50LmdldFVuaXF1ZUlkKCk7CiAgICAgICAgICAgICBsb2cuZGVidWcoIiNnZXRQb2xpY3lCeUlkIC0gcG9saWN5IHdpdGggaWQge30gZG9lcyBub3QgZXhpc3Qgb24gY29tcG9uZW50IHdpdGggaWQge30iLCBwb2xpY3lJZCwgY21wdElkKTsKLSAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQoY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5QT0xJQ1lfTk9UX0ZPVU5EX09OX0NPTlRBSU5FUiwgcG9saWN5SWQsIGNtcHRJZCkpOworICAgICAgICAgICAgdGhyb3cgbmV3I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ZWZvcmVXcml0ZU9wZXJhdGlvbihDb21wb25lbnRUeXBlRW51bSBjb21wb25lbnRUeXBlLCBTdHJpbmcgY29tcG9uZW50SWQsIFN0cmluZyB1c2VySWQsIGJvb2xlYW4gc2hvdWxkTG9jaykgewogICAgICAgICBXcmFwcGVyPENvbXBvbmVudD4gY29tcG9uZW50ID0gbmV3IFdyYXBwZXI8PigpOwogICAgICAgICByZXR1cm4gdmFsaWRhdGVDb250YWluZXJDb21wb25lbnRBbmRVc2VyQmVmb3JlUmVhZE9wZXJhdGlvbihjb21wb25lbnRUeXBlLCBjb21wb25lbnRJZCwgdXNlcklkKQogICAgICAgICAgICAgICAgIC5sZWZ0KCkKQEAgLTU4OCw3ICs2NzYsOCBAQAogICAgICAgICAgICAgICAgIC5sZWZ0KCkKICAgICAgICAgICAgICAgICAuYmluZChjIC0+IHsKICAgICAgICAgICAgICAgICAgICAgY29tcG9uZW50LnNldElubmVyRWxlbWVudChjKTsKLSAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbGlkYXRlQ2FuV29ya09uQ29tcG9uZW50KGMsIHVzZXJJZCk7CisgICAgICAgICAgICAgICAgICAgIHZhbGlkYXRlQ2FuV29ya09uQ29tcG9uZW50KGMsIHVzZXJJZCk7CisgICAgICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIubGVmdChjb21wb25lbnQpOwogICAgICAgICAgICAgICAgIH0pCiAgICAgICAgICAgICAgICAgLmxlZnQoKQogICAgICAgICAgICAgICAgIC5iaW5kKGwgLT4gbG9ja0NvbXBvbmVudChjb21wb25lbnQuZ2V0SW5uZXJFbGVtZW50KCksIHNob3VsZExvY2ssICJwb2xpY3lXcml0aW5nT3BlcmF0aW9uIikpCkBAIC01OTYsMjggKzY4NSwzMiBAQAogICAgICAgICAgICAgICAgICAgICBsb2cuZXJyb3IoRkFJTEVEX1RPX1ZBTElEQVRFX0NPTVBPTkVOVCwgY29tcG9uZW50SWQpOwogICAgICAgICAgICAgICAgICAgICByZXR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GFEZWZpbml0aW9uW10gcHJvcGVydGllcykgewotICAgICAgICByZXR1cm4gZ2V0UG9saWN5QnlJZChjb21wb25lbnQsIHBvbGljeUlkKQorICAgIHByaXZhdGUgUG9saWN5RGVmaW5pdGlvbiB1cGRhdGVQb2xpY3lPZkNvbXBvbmVudChTdHJpbmcgY29tcG9uZW50SWQsIFBvbGljeURlZmluaXRpb24gcG9saWN5KSB7CisgICAgICAgIHJldHVybiB0b3NjYU9wZXJhdGlvbkZhY2FkZS51cGRhdGVQb2xpY3lPZkNvbXBvbmVudChjb21wb25lbnRJZCwgcG9saWN5LCBQcm9tb3RlVmVyc2lvbkVudW0uTUlOT1IpCiAgICAgICAgICAgICAgICAgLmxlZnQoKQotICAgICAgICAgICAgICAgIC5iaW5kKHAgLT4gdmFsaWRhdGVVcGRhdGVQb2xpY3lQcm9wZXJ0aWVzQmVmb3JlVXBkYXRlKHAsIHByb3BlcnRpZXMpKQotICAgICAgICAgICAgICAgIC5sZWZ0KCkuYmluZChsIC0+IHVwZGF0ZVBvbGljeU9mQ29tcG9uZW50KGNvbXBvbmVudC5nZXRVbmlxdWVJZCgpLCBsKSk7CisgICAgICAgICAgICAgICAgLm9uKGNlLT5jb21wb25lbnRFeGNlcHRpb25Qb2xpY3lEZWZpbml0aW9uKGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChjb21wb25lbnRzVXRpbHMuY29udmVydEZyb21TdG9yYWdlUmVzcG9uc2UoY2UpKSkpOwogICAgIH0KIAotICAgIHByaXZhdGUgRWl0aGVyPFBvbGljeURlZmluaXRpb24sIFJlc3BvbnNlRm9ybWF0PiB1cGRhdGVQb2xpY3lPZkNvbXBvbmVudChTdHJpbmcgY29tcG9uZW50SWQsIFBvbGljeURlZmluaXRpb24gcG9saWN5KSB7Ci0gICAgICAgIHJldHVybiB0b3NjYU9wZXJhdGlvbkZhY2FkZS51cGRhdGVQb2xpY3lPZkNvbXBvbmVudChjb21wb25lbnRJZCwgcG9saWN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ZWZhdWx0VmFsdWVzVmFsaWRhdGlvbi5yaWdodCgpLnZhbHVlKCkpOwogICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0OwpAQCAtMTkxLDcgKzE4Nyw3IEBACiAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmcgY29udmVydGVkVmFsdWUgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5ld1Byb3BlcnR5RGVmaW5pdGlvbi5nZXREZWZhdWx0VmFsdWUoKSAhPSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udmVydGVkVmFsdWUgPSBjb252ZXJ0ZXIuY29udmVydCgKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3UHJvcGVydHlEZWZpbml0aW9uLmdldERlZmF1bHRWYWx1ZSgpLCBpbm5lclR5cGUsIGFsbERhdGFUeXBlcy5sZWZ0KCkudmFsdWUoKSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld1Byb3BlcnR5RGVmaW5pdGlvbi5nZXREZWZhdWx0VmFsdWUoKSwgaW5uZXJUeXBlLCBhbGxEYXRhVHlwZXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld1Byb3BlcnR5RGVmaW5pdGlvbi5zZXREZWZhdWx0VmFsdWUoY29udmVydGVkVmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICB9CkBAIC0yMDgsMTYgKzIwNCwxMyBAQAogICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KLQogICAgICAgICAgICAgcmVzdWx0ID0gRWl0aGVyLmxlZnQobmV3IEVudHJ5RGF0YTw+KHByb3BlcnR5TmFtZSwgbmV3UHJvcGVydHlEZWZpbml0aW9uKSk7CiAgICAgICAgICAgICByZXR1cm4gcmVzdWx0OwotCiAgICAgICAgIH0gZmluYWxseSB7CiAgICAgICAgICAgICBjb21taXRPclJvbGxiYWNrKHJlc3VsdCk7CiAgICAgICAgICAgICAvLyB1bmxvY2sgY29tcG9uZW50CiAgICAgICAgICAgICBncmFwaExvY2tPcGVyYXRpb24udW5sb2NrQ29tcG9uZW50KGNvbXBvbmVudElkLCBub2RlVHlwZSk7CiAgICAgICAgIH0KLQogICAgIH0KIAogICAgIC8qKgpAQCAtMzAwLDcgKzI5Myw3IEBACiAKICAgICBwdWJsaWMgRWl0aGVyPE1hcC5FbnRyeTxTdHJpbmcsIFByb3BlcnR5RGVmaW5pdGlvbj4sIFJlc3BvbnNlRm9ybWF0PiBnZXRDb21wb25lbnRQcm9wZXJ0eShTdHJpbmcgY29tcG9uZW50SWQsIFN0cmluZyBwcm9wZXJ0eUlkLCBTdHJpbmcgdXNlcklkKSB7CiAKLSAgICAgICAgdmFsaWRhdGVVc2VyRXhpc3RzKHVzZXJJZCwgImNyZWF0ZSBDb21wb25lbnQgSW5zdGFuY2UiLCBmYWxzZSk7CisgICAgICAgIHZhbGlkYXRlVXNlckV4aXN0cyh1c2VySWQpOwogICAgICAgICAvLyBHZXQgdGhlIHJlc291cmNlIGZyb20gREIKICAgICAgICAgRWl0aGVyPENvbXBvbmVudCwgU3RvcmFnZU9wZXJhdGlvblN0YXR1cz4gc3RhdHVzID0KICAgICAgICAgICAgIHRvc2NhT3BlcmF0aW9uRmFjYWRlLmdldFRvc2NhRWxlbWVudChjb21wb25lbnRJZCk7CkBAIC0zMjQsNyArMzE3LDcgQEAKIAogICAgIHB1YmxpYyBFaXRoZXI8TGlzdDxQcm9wZXJ0eURlZmluaXRpb24+LCBSZXNwb25zZUZvcm1hdD4gZ2V0UHJvcGVydGllc0xpc3QoU3RyaW5nIGNvbXBvbmVudElkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nIHVzZXJJZCkgewotICAgICAgICB2Y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3JtYXQ+IGdldFJlcXVpcmVtZW50KFN0cmluZyBjb21wb25lbnRJZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZyByZXF1aXJlbWVudElkVG9HZXQsIFVzZXIgdXNlciwgYm9vbGVhbiBsb2NrKSB7Ci0gICAgICAgIHZhbGlkYXRlVXNlckV4aXN0cyh1c2VyLmdldFVzZXJJZCgpLCBHRVRfUkVRVUlSRU1FTlRTLCB0cnVlKTsKKyAgICAgICAgdmFsaWRhdGVVc2VyRXhpc3RzKHVzZXIuZ2V0VXNlcklkKCkpOwogICAgICAgICBFaXRoZXI8b3JnLm9wZW5lY29tcC5zZGMuYmUubW9kZWwuQ29tcG9uZW50LCBSZXNwb25zZUZvcm1hdD4gY29tcG9uZW50RWl0aGVyID0gZ2V0Q29tcG9uZW50RGV0YWlscyhjb21wb25lbnRJZCk7CiAgICAgICAgIGlmIChjb21wb25lbnRFaXRoZXIuaXNSaWdodCgpKSB7CiAgICAgICAgICAgICByZXR1cm4gRWl0aGVyLnJpZ2h0KGNvbXBvbmVudEVpdGhlci5yaWdodCgpLnZhbHVlKCkpOwpAQCAtMzY5LDcgKzM3MCw3IEBACiAgICAgcHVibGljIEVpdGhlcjxSZXF1aXJlbWVudERlZmluaXRpb24sIFJlc3BvbnNlRm9ybWF0PiBkZWxldGVSZXF1aXJlbWVudChTdHJpbmcgY29tcG9uZW50SWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmcgcmVxdWlyZW1lbnRJZFRvRGVsZXRlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVXNlciB1c2VyLCBib29sZWFuIGxvY2spIHsKLSAgICAgICAgdmFsaWRhdGVVc2VyRXhpc3RzKHVzZXIuZ2V0VXNlcklkKCksIERFTEVURV9SRVFVSVJFTUVOVFMsIHRydWUpOworICAgICAgICB2YWxpZGF0ZVVzZXJFeGlzdHModXNlci5nZXRVc2VySWQoKSk7CiAgICAgICAgIEVpdGhlcjxvcmcub3BlbmVjb21wLnNkYy5iZS5tb2RlbC5Db21wb25lbnQsIFJlc3BvbnNlRm9ybWF0PiBjb21wb25lbnRFaXRoZXIKICAgICAgICAgICAgICAgICA9IGdldENvbXBvbmVudERldGFpbHMoY29tcG9uZW50SWQpOwogICAgICAgICBpZiAoY29tcG9uZW50RWl0aGVyLmlzUmlnaHQoKSkgewpAQCAtNDc2LDEyICs0NzcsMTMgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcmcub3BlbmVjb21wLnNkYy5iZS5tb2RlbC5Db21wb25lbnQgY29tcG9uZW50LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZyBhY3Rpb24pIHsKICAgICAgICAgaWYgKGxvY2spIHsKLSAgICAgICAgICAgIEVpdGhlcjxCb29sZWFuLCBSZXNwb25zZUZvcm1hdD4gbG9ja1Jlc3VsdCA9IGxvY2tDb21wb25lbnQoY29tcG9uZW50LmdldFVuaXF1ZUlkKCksIGNvbXBvbmVudCwgYWN0aW9uKTsKLSAgICAgICAgICAgIGlmIChsb2NrUmVzdWx0LmlzUmlnaHQoKSkgeworICAgICAgICAgICAgdHJ5eworICAgICAgICAgICAgbG9ja0NvbXBvbmVudChjb21wb25lbnQuZ2V0VW5pcXVlSWQoKSwgY29tcG9uZW50LCBhY3Rpb24pOworICAgICAgICAgICAgfSBjYXRjaCAoQ29tcG9uZW50RXhjZXB0aW9uIGUpewogICAgICAgICAgICAgICAgIExPR0dFUi5kZWJ1ZyhGQUlMRURfVE9fTE9DS19DT01QT05FTlRfUkVTUE9OU0VfSVMsIGN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KSwgbmV3UmVzb3VyY2UpKTsKLSAgICAgICAgfQotCi0gICAgICAgIHJldHVybiByZXN1bHQ7Ci0gICAgfQotCi0gICAgcHJpdmF0ZSBSZXNvdXJjZSB1cGRhdGVSZXNvdXJjZUZyb21ZYW1sKFJlc291cmNlIG9sZFJyZXNvdXJjZSwgUmVzb3VyY2UgbmV3UnJlc291cmNlLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBdWRpdGluZ0FjdGlvbkVudW0gYWN0aW9uRW51bSwgTGlzdDxBcnRpZmFjdERlZmluaXRpb24+IGNyZWF0ZWRBcnRpZmFjdHMsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZyB5YW1sRmlsZU5hbWUsIFN0cmluZyB5YW1sRmlsZUNvbnRlbnQsIENzYXJJbmZvIGNzYXJJbmZvLCBNYXA8U3RyaW5nLCBOb2RlVHlwZUluZm8+IG5vZGVUeXBlc0luZm8sCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1hcDxTdHJpbmcsIEVudW1NYXA8QXJ0aWZhY3RPcGVyYXRpb25FbnVtLCBMaXN0PEFydGlmYWN0RGVmaW5pdGlvbj4+PiBub2RlVHlwZXNBcnRpZmFjdHNUb0hhbmRsZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nIG5vZGVOYW1lLCBib29sZWFuIGlzTmVzdGVkKSB7Ci0gICAgICAgIGJvb2xlYW4gaW5UcmFuc2FjdGlvbiA9IHRydWU7Ci0gICAgICAgIGJvb2xlYW4gc2hvdWxkTG9jayA9IGZhbHNlOwotICAgICAgICBSZXNvdXJjZSBwcmVwYXJlZFJlc291cmNlID0gbnVsbDsKLSAgICAgICAgUGFyc2VkVG9zY2FZYW1sSW5mbyB1cGxvYWRDb21wb25lbnRJbnN0YW5jZUluZm9NYXAgPSBudWxsOwotICAgICAgICB0c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XJjZSBjdXJOb2RlVHlwZSkgewotICAgICAgICBNYXA8U3RyaW5nLCBBcnRpZmFjdERlZmluaXRpb24+IGV4aXN0aW5nQXJ0aWZhY3RzID0gbmV3IEhhc2hNYXA8PigpOwotICAgICAgICBpZiAoY3VyTm9kZVR5cGUgPT0gbnVsbCkgewotICAgICAgICAgICAgcmV0dXJuIGV4aXN0aW5nQXJ0aWZhY3RzOwotICAgICAgICB9Ci0gICAgICAgIGlmIChNYXBVdGlscy5pc05vdEVtcHR5KGN1ck5vZGVUeXBlLmdldERlcGxveW1lbnRBcnRpZmFjdHMoKSkpIHsKLSAgICAgICAgICAgIGV4aXN0aW5nQXJ0aWZhY3RzLnB1dEFsbChjdXJOb2RlVHlwZS5nZXREZXBsb3ltZW50QXJ0aWZhY3RzKCkpOwotICAgICAgICB9Ci0gICAgICAgIGlmIChNYXBVdGlscy5pc05vdEVtcHR5KGN1ck5vZGVUeXBlLmdldEFydGlmYWN0cygpKSkgewotICAgICAgICAgICAgZXhpc3RpbmdBcnRpZmFjdHMKLSAgICAgICAgICAgICAgICAgICAgLnB1dEFsbChjdXJOb2RlVHlwZS5nZXRBcnRpZmFjdHMoKS5lbnRyeVNldCgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgLnN0cmVhbSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgLmZpbHRlcihlIC0+IGUuZ2V0VmFsdWUoKS5nZXRBcnRpZmFjdEdyb3VwVHlwZSgpID09IEFydGlmYWN0R3JvdXBUeXBlRW51bS5JTkZPUk1BVElPTkFMKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5jb2xsZWN0KHRvTWFwKE1hcC5FbnRyeTo6Z2V0S2V5LCBNYXAuRW50cnk6OmdldFZhbHVlKSkpOwotICAgICAgICB9Ci0gICAgICAgIHJldHVybiBleGlzdGluZ0FydGlmYWN0czsKLSAgICB9CisJcHJpdmF0ZSBFaXRoZXI8TWFwPFN0cmluZywgRW51bU1hcDxBcnRpZmF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2xlIHN0YXRlIG9mIHJlc291cmNlIHt9IHRvIG5vdCBjZXJ0aWZpZWQgY2hlY2tlZCBvdXQuICIsCi0gICAgICAgICAgICAgICAgICAgICAgICByZXNvdXJjZS5nZXROYW1lKCkpOwotICAgICAgICAgICAgICAgIEVpdGhlcjw/IGV4dGVuZHMgQ29tcG9uZW50LCBSZXNwb25zZUZvcm1hdD4gY2hlY2tvdXRSZXMgPSBsaWZlY3ljbGVCdXNpbmVzc0xvZ2ljLmNoYW5nZUNvbXBvbmVudFN0YXRlKAotICAgICAgICAgICAgICAgICAgICAgICAgcmVzb3VyY2UuZ2V0Q29tcG9uZW50VHlwZSgpLCByZXNvdXJjZS5nZXRVbmlxdWVJZCgpLCB1c2VyLCBMaWZlQ3ljbGVUcmFuc2l0aW9uRW51bS5DSEVDS09VVCwKLSAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBMaWZlY3ljbGVDaGFuZ2VJbmZvV2l0aEFjdGlvbihDRVJUSUZJQ0FUSU9OX09OX0lNUE9SVCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTGlmZWN5Y2xlQ2hhbmNlQWN0aW9uRW51bS5DUkVBVEVfRlJPTV9DU0FSKSwKLSAgICAgICAgICAgICAgICAgICAgICAgIGluVHJhbnNhY3Rpb24sIHRydWUpOwotICAgICAgICAgICAgICAgIGlmIChjaGVja291dFJlcy5pc1JpZ2h0KCkpIHsKLSAgICAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJDb3VsZCBub3QgY2hhbmdlIHN0YXRlIG9mIGNvbXBvbmVudCB7fSB3aXRoIHVpZCB7fSB0byBjaGVja2VkIG91dC4gU3RhdHVzIGlzIHt9LiAiLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc291cmNlLmdldENvbXBvbmVudFR5cGUoKS5nZXROb2RlVHlwZSgpLCByZXNvdXJjZS5nZXRVbmlxdWVJZCgpLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoZWNrb3V0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FydGlmYWN0c1JlcXVlc3RSZXMgPSBhcnRpZmFjdHNCdXNpbmVzc0xvZ2ljCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgLmhhbmRsZUFydGlmYWN0c1JlcXVlc3RGb3JJbm5lclZmY0NvbXBvbmVudChjdXJBcnRpZmFjdHNUb0hhbmRsZSwgbm9kZVR5cGVSZXNvdXJjZSwgdXNlciwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZWRBcnRpZmFjdHMsIGFydGlmYWN0c0J1c2luZXNzTG9naWMubmV3IEFydGlmYWN0T3BlcmF0aW9uSW5mbyhmYWxzZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlTGlmZWN5Y2xlU3RhdGUsIGN1ck9wZXJhdGlvbiksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmYWxzZSwgaW5UcmFuc2FjdGlvbik7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChoYW5kbGVOb2RlVHlwZUFydGlmYWN0c1JlcXVlc3RSZXMuaXNSaWdodCgpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBoYW5kbGVOb2RlVHlwZUFydGlmYWN0c1JlcyA9IEVpdGhlci5yaWdodChoYW5kbGVOb2RlVHlwZUFydGlmYWN0c1JlcXVlc3RSZXMucmlnaHQoKS52YWx1ZSgpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgIGlmIChBcnRpZmFjdE9wZXJhdGlvbkVudW0uaXNDcmVhdGVPckxpbmsoY3VyT3BlcmF0aW9uKSkgewotICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlZEFydGlmYWN0cy5hZGRBbGwoaGFuZGxlTm9kZVR5cGVBcnRpZmFjdHNSZXF1ZXN0UmVzLmxlZnQoKS52YWx1ZSgpKTsKLSAgICAgICAgICAg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mVzb3VyY2U7CiAKLSAgICB9CisJfQogCi0gICAgcHVibGljIE1hcDxTdHJpbmcsIFJlc291cmNlPiBjcmVhdGVSZXNvdXJjZXNGcm9tWWFtbE5vZGVUeXBlc0xpc3QoU3RyaW5nIHlhbWxOYW1lLCBSZXNvdXJjZSByZXNvdXJjZSwgTWFwPFN0cmluZywgT2JqZWN0PiBtYXBwZWRUb3NjYVRlbXBsYXRlLCBib29sZWFuIG5lZWRMb2NrLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1hcDxTdHJpbmcsIEVudW1NYXA8QXJ0aWZhY3RPcGVyYXRpb25FbnVtLCBMaXN0PEFydGlmYWN0RGVmaW5pdGlvbj4+PiBub2RlVHlwZXNBcnRpZmFjdHNUb0hhbmRsZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBMaXN0PEFydGlmYWN0RGVmaW5pdGlvbj4gbm9kZVR5cGVzTmV3Q3JlYXRlZEFydGlmYWN0cywgTWFwPFN0cmluZywgTm9kZVR5cGVJbmZvPiBub2RlVHlwZXNJbmZvLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENzYXJJbmZvIGNzYXJJbmZvKSB7CisJcHVibGljIE1hcDxTdHJpbmcsIFJlc291cmNlPiBjcmVhdGVSZXNvdXJjZXNGcm9tWWFtbE5vZGVUeXBlc0xpc3QoU3RyaW5nIHlhbWxOYW1lLCBSZXNvdXJjZSByZXNvdXJjZSwKKwkJCQkJCQkJCQkJCQkJCQkJICBNYXA8U3RyaW5nLCBPYmplY3Q+IG1hcHBlZFRvc2NhVGVtcGxhdGUsIGJvb2xlYW4gbmVlZExvY2ssCisJCQkJCQkJCQkJCQkJCQkJCSAgTWFwPFN0cmluZywgRW51bU1hcDxBcnRpZm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5hbWUgPSByZXNvdXJjZVZmTmFtZSArICItIiArIG5hbWVXaXRob3VOYW1lc3BhY2VQcmVmaXguc3Vic3RyaW5nKHJlc291cmNlVHlwZS5sZW5ndGgoKSArIDEpOworCQlyZXR1cm4gYWRkQ3ZmY1N1ZmZpeFRvUmVzb3VyY2VOYW1lKHJlc291cmNlTmFtZSk7CisJfQogCi0gICAgcHJpdmF0ZSBSZXNvdXJjZSBjcmVhdGVSZXNvdXJjZUFuZFJJc0Zyb21ZYW1sKFN0cmluZyB5YW1sTmFtZSwgUmVzb3VyY2UgcmVzb3VyY2UsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFBhcnNlZFRvc2NhWWFtbEluZm8gcGFyc2VkVG9zY2FZYW1sSW5mbywgQXVkaXRpbmdBY3Rpb25FbnVtIGFjdGlvbkVudW0sIGJvb2xlYW4gaXNOb3JtYXRpdmUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIExpc3Q8QXJ0aWZhY3REZWZpbml0aW9uPiBjcmVhdGVkQXJ0aWZhY3RzLCBTdHJpbmcgdG9wb2xvZ3lUZW1wbGF0ZVlhbWwsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1hcDxTdHJpbmcsIE5vZGVUeXBlSW5mbz4gbm9kZVR5cGVzSW5mbywgQ3NhckluZm8gY3NhckluZm8sCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1hcDxTdHJpbmcsIEVudW1NYXA8QXJ0aWZhY3RPcGVyYXRpb25FbnVtLCBMaXN0PEFydGlmYWN0RGVmaW5pdGlvbj4+PiBub2RlVHlwZXNBcnRpZmFjdHNUb0NyZWF0ZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbGVhbiBzaG91bGRMb2NrLCBib29sZWFuI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HsKICAgICAgICAgICAgICAgICBsb2cudHJhY2UoIioqKioqKioqKioqKiogQWRkaW5nIGdlbmVyaWMgcHJvcGVydGllcyB0byBQTkYiKTsKICAgICAgICAgICAgICAgICByZXNvdXJjZSA9IChSZXNvdXJjZSkgcHJvcGVydHlCdXNpbmVzc0xvZ2ljLmNvcHlQcm9wZXJ0eVRvQ29tcG9uZW50KHJlc291cmNlLCBnZW5lcmljUmVzb3VyY2UuZ2V0UHJvcGVydGllcygpKTsKQEAgLTEzNzIsMjAgKzE2MDIsMjEgQEAKICAgICAgICAgICAgICAgICBzb2Z0d2FyZUluZm9ybWF0aW9uQnVzaW5lc3NMb2dpYy5zZXRTb2Z0d2FyZUluZm9ybWF0aW9uKHJlc291cmNlLCBjc2FySW5mbyk7CiAgICAgICAgICAgICAgICAgbG9nLnRyYWNlKCIqKioqKioqKioqKioqIFJlbW92aW5nIG5vbi1tYW5vIHNvZnR3YXJlIGluZm9ybWF0aW9uIGZpbGUgZnJvbSBQTkYiKTsKICAgICAgICAgICAgICAgICBpZiAoY3NhckluZm8uZ2V0U29mdHdhcmVJbmZvcm1hdGlvblBhdGgoKS5pc1ByZXNlbnQoKSAmJgotICAgICAgICAgICAgICAgICAgICAhc29mdHdhcmVJbmZvcm1hdGlvbkJ1c2luZXNzTG9naWMucmVtb3ZlU29mdHdhcmVJbmZvcm1hdGlvbkZpbGUoY3NhckluZm8pKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAhc29mdHdhcmVJbmZvcm1hdGlvbkJ1c2luZXNzTG9naWMucmVtb3ZlU29mdHdhcmVJbmZvcm1hdGlvbkZpbGUoY3NhckluZm8pKSB7CiAgICAgICAgICAgICAgICAgICAgIGxvZy53YXJuKEVjb21wTG9nZ2VyRXJyb3JDb2RlLkJVU0lORVNTX1BST0NFU1NfRVJST1IgLCBSZXNvdXJjZUJ1c2luZXNzTG9naWMuY2xhc3MuZ2V0TmFtZSgpLAotICAgICAgICAgICAgICAgICAgICAgICAgImNhdGFsb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LnZhbHVlKCk7CisJfQogCi0gICAgcHJpdmF0ZSBFaXRoZXI8UmVzb3VyY2UsIFJlc3BvbnNlRm9ybWF0PiBjcmVhdGVHcm91cHNPblJlc291cmNlKFJlc291cmNlIHJlc291cmNlLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNYXA8U3RyaW5nLCBHcm91cERlZmluaXRpb24+IGdyb3VwcykgewotICAgICAgICBpZiAoZ3JvdXBzICE9IG51bGwgJiYgIWdyb3Vwcy5pc0VtcHR5KCkpIHsKLSAgICAgICAgICAgIExpc3Q8R3JvdXBEZWZpbml0aW9uPiBncm91cHNBc0xpc3QgPSB1cGRhdGVHcm91cHNNZW1iZXJzVXNpbmdSZXNvdXJjZSgKLSAgICAgICAgICAgICAgICAgICAgZ3JvdXBzLCByZXNvdXJjZSk7Ci0gICAgICAgICAgICBoYW5kbGVHcm91cHNQcm9wZXJ0aWVzKHJlc291cmNlLCBncm91cHMpOwotICAgICAgICAgICAgZmlsbEdyb3Vwc0ZpbmFsRmllbGRzKGdyb3Vwc0FzTGlzdCk7Ci0gICAgICAgICAgICBFaXRoZXI8TGlzdDxHcm91cERlZmluaXRpb24+LCBSZXNwb25zZUZvcm1hdD4gY3JlYXRlR3JvdXBzID0gZ3JvdXBCdXNpbmVzc0xvZ2ljLmNyZWF0ZUdyb3VwcyhyZXNvdXJjZSwKLSAgICAgICAgICAgICAgICAgICAgZ3JvdXBzQXNMaXN0LCB0cnVlKTsKLSAgICAgICAgICAgIGlmIChjcmVhdGVHcm91cHMuaXNSaWdodCgpKSB7Ci0gICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChjcmVhdGVHcm91cHMucmlnaHQoKS52YWx1ZSgpKTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgIHJldHVybiBFaXRoZXIubGVmdChyZXNvdXJjZSk7Ci0gICAgICAgIH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gIC5zdHJlYW0oKQotICAgICAgICAgICAgICAgICAgICAgICAgLm1hcChHZXRJbnB1dFZhbHVlRGF0YURlZmluaXRpb246OmdldElucHV0TmFtZSkKLSAgICAgICAgICAgICAgICAgICAgICAgIC5jb2xsZWN0KHRvTGlzdCgpKS50b1N0cmluZygpKTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIExpc3RJdGVyYXRvcjxHZXRJbnB1dFZhbHVlRGF0YURlZmluaXRpb24+IGdldElucHV0VmFsdWVzSXRlciA9IHByb3BlcnR5LmdldEdldElucHV0VmFsdWVzKCkubGlzdEl0ZXJhdG9yKCk7Ci0gICAgICAgICAgICB3aGlsZSAoZ2V0SW5wdXRWYWx1ZXNJdGVyLmhhc05leHQoKSkgewotICAgICAgICAgICAgICAgIEdldElucHV0VmFsdWVEYXRhRGVmaW5pdGlvbiBnZXRJbnB1dCA9IGdldElucHV0VmFsdWVzSXRlci5uZXh0KCk7Ci0gICAgICAgICAgICAgICAgSW5wdXREZWZpbml0aW9uIGlucHV0ID0gZmluZElucHV0QnlOYW1lKGlucHV0cywgZ2V0SW5wdXQpOwotICAgICAgICAgICAgICAgIGdldElucHV0LnNldElucHV0SWQoaW5wdXQuZ2V0VW5pcXVlSWQoKSk7Ci0gICAgICAgICAgICAgICAgaWYgKGdldElucHV0LmdldEdldElucHV0SW5kZXgoKSAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgIEdldElucHV0VmFsdWVEYXRhRGVmaW5pdGlvbiBnZXRJbnB1dEluZGV4ID0gZ2V0SW5wdXQuZ2V0R2V0SW5wdXRJbmRleCgpOwotICAgICAgICAgICAgICAgICAgICBpbnB1dCA9IGZpbmRJbnB1dEJ5TmFtZShpbnB1dHMsIGdldElucHV0SW5kZXgpOwotICAgICAgICAgICAgICAgICAgICBnZXRJbnB1dEluZGV4LnNldElucHV0SWQoaW5wdXQuZ2V0VW5pcXVlSWQoKSk7Ci0gICAgICAgICAgICAgICAgICAgIGdldElucHV0Vm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LmNyZWF0ZUdyb3VwcyhyZXNvdXJjZSwKLSAgICAgICAgICAgICAgICAgICAgICAgIGdyb3Vwc1RvQ3JlYXRlLCB0cnVlKQotICAgICAgICAgICAgICAgICAgICAgICAgLmxlZnQoKQotICAgICAgICAgICAgICAgICAgICAgICAgLm9uKHRoaXM6OnRocm93Q29tcG9uZW50RXhjZXB0aW9uKTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgfQotICAgICAgICBpZiAoaXNOb3RFbXB0eShncm91cHNUb0RlbGV0ZSkpIHsKLSAgICAgICAgICAgIGdyb3VwQnVzaW5lc3NMb2dpYy5kZWxldGVHcm91cHMocmVzb3VyY2UsIGdyb3Vwc1RvRGVsZXRlKQotICAgICAgICAgICAgICAgICAgICAubGVmdCgpCi0gICAgICAgICAgICAgICAgICAgIC5vbih0aGlzOjp0aHJvd0NvbXBvbmVudEV4Y2VwdGlvbik7Ci0gICAgICAgIH0KLSAgICAgICAgaWYgKGlzTm90RW1wdHkoZ3JvdXBzVG9VcGRhdGUpKSB7Ci0gICAgICAgICAgICBncm91cEJ1c2luZXNzTG9naWMudXBkYXRlR3JvdXBzKHJlc291cmNlLCBncm91cHNUb1VwZGF0ZSwgdHJ1ZSkKLSAgICAgICAgICAgICAgICAgICAgLmxlZnQoKQotICAgICAgICAgICAgICAgICAgICAub24odGhpczo6dGhyb3dDb21wb25lbnRFeGNlcHRpb24pOwotICAgICAgICB9Ci0gICAgfQorCXByaXZhdGUgUmVzb3VyY2UgdXBkYXRlT3JDcmVhdGVHcm91cHMoUmVzb3VyY2UgcmVzb3VyY2UsIE1hcDxTdHJpbmcsIEdyb3VwRGVmaW5pdGlvbj4gZ3JvdXBzKSB7CisJCUxpc3Q8R3JvdXBEZWZpbml0aW9uPiBncm91cHNGcm9tUmVzb3VyY2UgPSByZXNvdXJjZS5nZXRHcm91cHMoKTsKKwkJTGlzdDxHcm91cERlZmluaXRpb24+IGdyb3Vwc0FzTGlzdCA9IHVwZGF0ZUdyb3Vwc01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dyb3Vwc0RlcGVuZGVuY2llcy5pc1JpZ2h0KCkpIHsKLSAgICAgICAgICAgICAgICB0aHJvdyBuZXcgQnlSZXNwb25zZUZvcm1hdENvbXBvbmVudEV4Y2VwdGlvbih2YWxpZGF0ZUN5Y2xpY0dyb3Vwc0RlcGVuZGVuY2llcy5yaWdodCgpLnZhbHVlKCkpOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgZm9yIChFbnRyeTxTdHJpbmcsIEdyb3VwRGVmaW5pdGlvbj4gZW50cnkgOiBncm91cHMuZW50cnlTZXQoKSkgewotICAgICAgICAgICAgICAgIFN0cmluZyBncm91cE5hbWUgPSBlbnRyeS5nZXRLZXkoKTsKLSAgICAgICAgICAgICAgICBHcm91cERlZmluaXRpb24gZ3JvdXBEZWZpbml0aW9uID0gZW50cnkuZ2V0VmFsdWUoKTsKLSAgICAgICAgICAgICAgICBHcm91cERlZmluaXRpb24gdXBkYXRlZEdyb3VwRGVmaW5pdGlvbiA9IG5ldyBHcm91cERlZmluaXRpb24oZ3JvdXBEZWZpbml0aW9uKTsKLSAgICAgICAgICAgICAgICB1cGRhdGVkR3JvdXBEZWZpbml0aW9uLnNldE1lbWJlcnMobnVsbCk7Ci0gICAgICAgICAgICAgICAgTWFwPFN0cmluZywgU3RyaW5nPiBtZW1iZXJzID0gZ3JvdXBEZWZpbml0aW9uLmdldE1lbWJlcnMoKTsKLSAgICAgICAgICAgICAgICBpZiAobWVtYmVycyAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgIHVwZGF0ZUdyb3VwTWVtYmVycyhncm91cHMsIHVwZGF0ZWRHcm91cERlZmluaXRpb24sIGNvbXBvbmVudCwgY29tcG9uZW50SW5zdGFuY2VzLCBncm91cE5hbWUsIG1lbWJlcnMpOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICByZXN1bHQuYWRkKHVwZGF0ZWRHcm91cERlZmluaXRpb24pOwotICAgICAgICAgICAgfQotICAgICAgICB9Ci0gICA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XJ0aWZhY3RzVG9IYW5kbGUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBMaXN0PEFydGlmYWN0RGVmaW5pdGlvbj4gbm9kZVR5cGVzTmV3Q3JlYXRlZEFydGlmYWN0cywgTWFwPFN0cmluZywgTm9kZVR5cGVJbmZvPiBub2RlVHlwZXNJbmZvLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ3NhckluZm8gY3NhckluZm8sIFN0cmluZyBub2RlTmFtZSkgewotICAgICAgICB0cnl7Ci0gICAgICAgICAgICBmb3IgKEVudHJ5PFN0cmluZywgTm9kZVR5cGVJbmZvPiBub2RlVHlwZUVudHJ5IDogbm9kZVR5cGVzSW5mby5lbnRyeVNldCgpKSB7Ci0gICAgICAgICAgICAgICAgaWYgKG5vZGVUeXBlRW50cnkuZ2V0VmFsdWUoKS5pc05lc3RlZCgpKSB7Ci0KLSAgICAgICAgICAgICAgICAgICAgaGFuZGxlTmVzdGVkVmZjKHJlc291cmNlLCBub2RlVHlwZXNBcnRpZmFjdHNUb0hhbmRsZSwgbm9kZVR5cGVzTmV3Q3JlYXRlZEFydGlmYWN0cywKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBub2RlVHlwZXNJbmZvLCBjc2FySW5mbywgbm9kZVR5cGVFbnRyeS5nZXRLZXkoKSk7Ci0gICAgICAgICAgICAgICAgICAgIGxvZy50cmFjZSgiKioqKioqKioqKioqKiBmaW5pc2hlZCB0byBjcmVhdGUgbm9kZSB7fSIsIG5vZGVUeXBlRW50cnkuZ2V0S2V5KCkpOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIE1hcDxTdHJpbmcsIE9iamVjdD4gbWFwcGVkVG9zY2FUZW1wbGF0ZSA9IG51bGw7Ci0gICAgICAgICAgICBpZiAoU3RyaW5nVXRpbHMuaXNOb3RFbXB0eShub2RlTmFtZSkgJiYgaXNOb3RFbXB0eShub2RlVHlwZXNJbmZvKQotIC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aW5nIGFydGlmYWN0TGFiZWwsIFN0cmluZyBhcnRpZmFjdERpc3BsYXlOYW1lLCBTdHJpbmcgYXJ0aWZhY3REZXNjcmlwdGlvbiwgU3RyaW5nIGFydGlmYWN0SWQsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFydGlmYWN0T3BlcmF0aW9uSW5mbyBvcGVyYXRpb24sIExpc3Q8QXJ0aWZhY3REZWZpbml0aW9uPiBjcmVhdGVkQXJ0aWZhY3RzLCBib29sZWFuIGlzRnJvbUNzYXIsIGJvb2xlYW4gc2hvdWxkTG9jaywKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbGVhbiBpblRyYW5zYWN0aW9uKSB7Ci0gICAgICAgIGJ5dGVbXSBhcnRpZmFjdEZpbGVCeXRlcyA9IG51bGw7CisJCQl9CisJCX0KKwkJcmV0dXJuIEVpdGhlci5sZWZ0KHJlc291cmNlKTsKKwl9CiAKLSAgICAgICAgaWYgKGNzYXJJbmZvLmdldENzYXIoKS5jb250YWluc0tleShhcnRpZmFjdFBhdGgpKSB7Ci0gICAgICAgICAgICBhcnRpZmFjdEZpbGVCeXRlcyA9IGNzYXJJbmZvLmdldENzYXIoKS5nZXQoYXJ0aWZhY3RQYXRoKTsKLSAgICAgICAgfQotICAgICAgICBFaXRoZXI8Qm9vbGVhbiwgUmVzcG9uc2VGb3JtYXQ+IHJlc3VsdCA9IEVpdGhlci5sZWZ0KHRydWUpOwotICAgICAgICBpZiAob3BlcmF0aW9uLmdldEFydGlmYWN0T3BlcmF0aW9uRW51bSgpID09IEFydGlmYWN0T3BlcmF0aW9uRW51bS5VUERBVEUgfHwgb3BlcmF0aW9uLmdldEFydGlmYWN0T3BlcmF0aW9uRW51bSgpID09IEFydGlmYWN0T3BlcmF0aW9uRW51b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W9uUGFpci5nZXRWYWx1ZSgpLnN0cmVhbSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gY3JlYXRlIGVhY2ggYXJ0aWZhY3QKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAubWFwKGUgLT4gY3JlYXRlT3JVcGRhdGVTaW5nbGVOb25NZXRhQXJ0aWZhY3QocmVzb3VyY2UsIGNzYXJJbmZvLCBlLmdldFBhdGgoKSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGUuZ2V0QXJ0aWZhY3ROYW1lKCksIGUuZ2V0QXJ0aWZhY3RUeXBlKCkuZ2V0VHlwZSgpLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZS5nZXRBcnRpZmFjdEdyb3VwVHlwZSgpLCBlLmdldEFydGlmYWN0TGFiZWwoKSwgZS5nZXREaXNwbGF5TmFtZSgpLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ3NhclV0aWxzLkFSVElGQUNUX0NSRUFURURfRlJPTV9DU0FSLCBlLmdldEFydGlmYWN0VW5pcXVlSWQoKSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFydGlmYWN0c0J1c2luZXNzTG9naWMubmV3IEFydGlmYWN0T3BlcmF0aW9uSW5mbyhmYWxzZSwgZmFsc2UsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJBcnRpZmFjdE9wZXJhdGlvblBhaXIuZ2V0S2V5KCkpLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlZEFydGlmYWN0cywgZS5pc0Zyb21Dc2FyKCksIHNob3VsZExvY2ssIGluVHJhbnNhY3Rpb24pKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGZpbHRlciBpbiBvbmx5IGVycm9yCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgLmZpbHRlcihFaXRoZXI6OmlzUmlnaHQpLgotICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIENvbnZlcnQgdGhlIGVycm9yIGZyb20gZWl0aGVyIHRvCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gUmVzcG9uc2VGb3JtYXQKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hcChlIC0+IGUucmlnaHQoKS52YWx1ZSgpKS4KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBDaGVjayBpZiBhbiBlcnJvciBvY2N1cnJlZAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmluZEFueSgpOwotICAgICAgICAgICAgLy8gRXJyb3IgZm91bmQgb24gYXJ0aWZhY3QgQ3JlYXRpb24KLSAgICAgICAgICAgIGlmIChvcHRpb25hbENyZWF0ZUluREJFcnJvci5pc1ByZXNlbnQoKSkgewotICAgICAgICAgICAgICAgIHJlc1N0YXR1cyA9IEVpdGhlci5yaWdodChvcHRpb25hbENyZWF0ZUluREJFcnJvci5nZXQoKSk7Ci0gICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICB9Ci0gICAgICAgIH0KLSAgICAgICAgcmV0dXJuIHJlc1N0YXR1czsKLSAgICB9CisJCQlPcHRpb25hbDxSZXNwb25zZUZvcm1hdD4gb3B0aW9uYWxDcmVhdGVJbkRCRXJyb3IgPQorCQkJCQkvLyBTdHJlYW0gb2YgYXJ0aWZhY3RzIHRvIGJlIGNyZWF0ZWQKKwkJCQkJY3VyckFydGlmYWN0T3BlcmF0aW9uUGFpci5nZXRWYWx1ZSgpCisJCQkJCQkJLnN0cmVhbSgpCisJCQkJCQkJLy8gY3JlYXRlIGVhY2ggYXJ0aWZhY3QKKwkJCQkJCQkubWFwKGUgLT4gY3JlYXRlT3JVcGRhdGVTaW5nbGVOb25NZXRhQXJ0aWZhY3QocmVzb3VyY2UsIGNzYXJJbmZvLCBlLmdldFBhdGgoKSwKKwkJCQkJCQkJCWUuZ2V0QXJ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ZUluREJFcnJvci5nZXQoKSk7CisJCQkJYnJlYWs7CisJCQl9CisJCX0KKwkJcmV0dXJuIHJlc1N0YXR1czsKKwl9CiAKLSAgICBwcml2YXRlIEVpdGhlcjxMaXN0PE5vbk1ldGFBcnRpZmFjdEluZm8+LCBTdHJpbmc+IGdldFZhbGlkQXJ0aWZhY3ROYW1lcyhDc2FySW5mbyBjc2FySW5mbywgTWFwPFN0cmluZywgU2V0PExpc3Q8U3RyaW5nPj4+IGNvbGxlY3RlZFdhcm5pbmdNZXNzYWdlcykgewotICAgICAgICBMaXN0PE5vbk1ldGFBcnRpZmFjdEluZm8+IGFydGlmYWN0UGF0aEFuZE5hbWVMaXN0ID0KLSAgICAgICAgICAgICAgICAvLyBTdHJlYW0gb2YgZmlsZSBwYXRocyBjb250YWluZWQgaW4gY3NhcgotICAgICAgICAgICAgICAgIGNzYXJJbmZvLmdldENzYXIoKS5lbnRyeVNldCgpLnN0cmVhbSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAvLyBGaWx0ZXIgaW4gb25seSBWRiBhcnRpZmFjdCBwYXRoIGxvY2F0aW9uCi0gICAgICAgICAgICAgICAgICAgICAgICAuZmlsdGVyKGUgLT4gUGF0dGVybi5jb21waWxlKFZGX05PREVfVFlQRV9BUlRJRkFDVFNfUEFUSF9QQVRURVJOKS5tYXRjaGVyKGUuZ2V0S2V5KCkpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5tYXRjaGVzKCkpCi0gICAgICAgICAgICAgICAgICAgICAgICAvLyBWYWxpZGF0ZSBhbmQgYWRkIHdhcm5pbmdzCi0gICAgICAgICAgICAgICAgICAgICAgICAubWFwKGUgLT4gQ3NhclV0aWxzLnZhbGlkYXRlTm9uTWV0YUFydGlmYWN0KGUuZ2V0S2V5KCksIGUuZ2V0VmFsdWUoKSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sbGVjdGVkV2FybmluZ01lc3NhZ2VzKSkKLSAgICAgICAgICA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5zdGFuY2UpIHsKLSAgICAgICAgUmVzb3VyY2Ugb3JpZ2luUmVzb3VyY2U7Ci0gICAgICAgIGlmICghb3JpZ2luQ29tcE1hcC5jb250YWluc0tleShjdXJyZW50Q29tcEluc3RhbmNlLmdldENvbXBvbmVudFVpZCgpKSkgewotICAgICAgICAgICAgRWl0aGVyPFJlc291cmNlLCBTdG9yYWdlT3BlcmF0aW9uU3RhdHVzPiBnZXRPcmlnaW5SZXNvdXJjZVJlcyA9IHRvc2NhT3BlcmF0aW9uRmFjYWRlCi0gICAgICAgICAgICAgICAgICAgIC5nZXRUb3NjYUZ1bGxFbGVtZW50KGN1cnJlbnRDb21wSW5zdGFuY2UuZ2V0Q29tcG9uZW50VWlkKCkpOwotICAgICAgICAgICAgaWYgKGdldE9yaWdpblJlc291cmNlUmVzLmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiZmFpbGVkIHRvIGZldGNoIHJlc291cmNlIHdpdGggdW5pcXVlSWQge30gYW5kIHRvc2NhIGNvbXBvbmVudCBuYW1lIHt9IHN0YXR1cyBpcyB7fSIsCi0gICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50Q29tcEluc3RhbmNlLmdldENvbXBvbmVudFVpZCgpLCBjdXJyZW50Q29tcEluc3RhbmNlLmdldFRvc2NhQ29tcG9uZW50TmFtZSgpLAotICAgICAgICAgICAgICAgICAgICAgICAgZ2V0T3JpZ2luUmVzb3VyY2VSZXMpOwotICAgICAgICAgICAgICAgIFJlc3BvbnNlRm9ybWF0IHJlc3BvbnNlRm9ybWF0ID0gY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KAotICAgICAgICAgICAgICAgICAgICAgICAgY29tcG9uZW50c1V0aWxzLmNvbnZlcnRGcm9tU3RvcmFnZVJlc3BvbnNlKGdldE9yaWdpblJlc291cmNlUmVzLnJpZ2h0KCkudmFsdWUoKSksIHlhbWxOYW1lKTsKLSAgICAgICAgICAgICAgICB0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mVxdWlyZW1lbnRzLmdldFZhbHVlKCkuc3RyZWFtKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmZpbHRlcihyIC0+IHJlcXVpcmVtZW50c05hbWVzVG9VcGRhdGUuY29udGFpbnNLZXkoci5nZXROYW1lKCkpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJiYgIXVwZGF0ZWRSZXFOYW1lcy5jb250YWlucyhyZXF1aXJlbWVudHNOYW1lc1RvVXBkYXRlLmdldChyLmdldE5hbWUoKSkpKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAubWFwKHIgLT4gewotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgci5zZXRQYXJlbnROYW1lKHIuZ2V0TmFtZSgpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHIuc2V0TmFtZShyZXF1aXJlbWVudHNOYW1lc1RvVXBkYXRlLmdldChyLmdldE5hbWUoKSkpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXBkYXRlZFJlcU5hbWVzLmFkZChyLmdldE5hbWUoKSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcjsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSkuY29sbGVjdCh0b0xpc3QoKSkpOwotICAgICAgICAgICAgfQotICAgICAgICB9Ci0gICAgICAgIGlmIChpc05vdEVtcHR5KHVwZGF0ZWRSZXF1aXJlbWVudHMpKSB7Ci0gICAgICAgICAgICB1cGRhdGVkSW5zdFJlcXVpcmVtZW50cy5wdXQoaW5zdGFuY2UsIHVwZGF0ZWRSZXF1aXJlbWVudHMpOwotICAgICAgICB9Ci0gICAgfQorCXByaXZhdGUgdm9pZCBmaWxsVXBkYXRlZEluc3RSZXF1aXJlbWVudHMoCisJCQlNYXA8Q29tcG9uZW50SW5zdGFuY2UsIE1hcDxTdHJpbmcsIExpc3Q8Um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JlcXVpcmVtZW50cy5nZXRLZXkoKSwKLSAgICAgICAgICAgICAgICAgICAgICAgIHJlcXVpcmVtZW50cy5nZXRWYWx1ZSgpLnN0cmVhbSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5maWx0ZXIoYyAtPiBjYXBhYmlsaXRpZXNOYW1lc1RvVXBkYXRlLmNvbnRhaW5zS2V5KGMuZ2V0TmFtZSgpKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICYmICF1cGRhdGVkQ2FwTmFtZXMuY29udGFpbnMoY2FwYWJpbGl0aWVzTmFtZXNUb1VwZGF0ZS5nZXQoYy5nZXROYW1lKCkpKSkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLm1hcChjIC0+IHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGMuc2V0UGFyZW50TmFtZShjLmdldE5hbWUoKSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjLnNldE5hbWUoY2FwYWJpbGl0aWVzTmFtZXNUb1VwZGF0ZS5nZXQoYy5nZXROYW1lKCkpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVwZGF0ZWRDYXBOYW1lcy5hZGQoYy5nZXROYW1lKCkpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGM7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pLmNvbGxlY3QodG9MaXN0KCkpKTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgfQotICAgICAgICBpZiAoaXNOb3RFbXB0eSh1cGRhdGVkQ2FwYWJpbGl0aWVzKSkgewotICAgICAgICAgICAgdXBkYXRlZEluc3RDYXBhYmlsdGllcy5wdXQoaW5zdGFuY2UsIHVwZGF0ZWRDYXBhYmlsaXRpZXMpOwotICAgICAgICB9Ci0gICAgfQorCXByaXZhdGUgdm9pZCBmaWxsVXBkYXRlZEluc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IG5vZGVzUmVnSW5mb0VudHJ5LmdldFZhbHVlKCk7Ci0gICAgICAgICAgICAgICAgZm9yIChVcGxvYWRSZXFJbmZvIHVwbG9hZFJlZ0luZm8gOiB1cGxvYWRSZWdJbmZvTGlzdCkgewotICAgICAgICAgICAgICAgICAgICBsb2cuZGVidWcoIkdvaW5nIHRvIGNyZWF0ZSAgcmVsYXRpb24ge30iLCB1cGxvYWRSZWdJbmZvLmdldE5hbWUoKSk7Ci0gICAgICAgICAgICAgICAgICAgIFN0cmluZyByZWdOYW1lID0gdXBsb2FkUmVnSW5mby5nZXROYW1lKCk7Ci0gICAgICAgICAgICAgICAgICAgIFJlcXVpcmVtZW50Q2FwYWJpbGl0eVJlbERlZiByZWdDYXBSZWxEZWYgPSBuZXcgUmVxdWlyZW1lbnRDYXBhYmlsaXR5UmVsRGVmKCk7Ci0gICAgICAgICAgICAgICAgICAgIHJlZ0NhcFJlbERlZi5zZXRGcm9tTm9kZShyZXNvdXJjZUluc3RhbmNlSWQpOwotICAgICAgICAgICAgICAgICAgICBsb2cuZGVidWcoInRyeSB0byBmaW5kIGF2YWlsYWJsZSByZXF1aXJlbWVudCB7fSAiLCByZWdOYW1lKTsKLSAgICAgICAgICAgICAgICAgICAgRWl0aGVyPFJlcXVpcmVtZW50RGVmaW5pdGlvbiwgUmVzcG9uc2VGb3JtYXQ+IGVpdGhlclJlcVN0YXR1cyA9IGZpbmRBdmlhYmxlUmVxdWlyZW1lbihyZWdOYW1lLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHlhbWxOYW1lLCBub2Rlc0luZm9WYWx1ZSwgY3VycmVudENvbXBJbnN0YW5jZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cGxvYWRSZWdJbmZvLmdldENhcGFiaWxpdHlOYW1lKCkpOwotICAgICAgICAgICAgICAgICAgICBpZiAoZWl0aGVyUmVxU3RhdHVzLmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgICAgICAgICAgbG9nLmRlYn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W9uIHZhbGlkUmVxID0gZWl0aGVyUmVxU3RhdHVzLmxlZnQoKS52YWx1ZSgpOwotICAgICAgICAgICAgICAgICAgICBMaXN0PENhcGFiaWxpdHlSZXF1aXJlbWVudFJlbGF0aW9uc2hpcD4gcmVxQW5kUmVsYXRpb25zaGlwUGFpckxpc3QgPSByZWdDYXBSZWxEZWYKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0UmVsYXRpb25zaGlwcygpOwotICAgICAgICAgICAgICAgICAgICBpZiAocmVxQW5kUmVsYXRpb25zaGlwUGFpckxpc3QgPT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICAgICAgcmVxQW5kUmVsYXRpb25zaGlwUGFpckxpc3QgPSBuZXcgQXJyYXlMaXN0PD4oKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBSZWxhdGlvbnNoaXBJbmZvIHJlcUFuZFJlbGF0aW9uc2hpcFBhaXIgPSBuZXcgUmVsYXRpb25zaGlwSW5mbygpOwotICAgICAgICAgICAgICAgICAgICByZXFBbmRSZWxhdGlvbnNoaXBQYWlyLnNldFJlcXVpcmVtZW50KHJlZ05hbWUpOwotICAgICAgICAgICAgICAgICAgICByZXFBbmRSZWxhdGlvbnNoaXBQYWlyLnNldFJlcXVpcmVtZW50T3duZXJJZCh2YWxpZFJlcS5nZXRPd25lcklkKCkpOwotICAgICAgICAgICAgICAgICAgICByZXFBbmRSZWxhdGlvbnNoaXBQYWlyLnNldFJlcXVpcmVtZW50VWlkKHZhbGlkUmVxLmdldFVuaXF1ZUlkKCkpOwotICAgICAgICAgICAgICAgICAgICBSZWxhdGlvbnNoaXBJbXBsIHJlbGF0aW9uc2hpcCA9IG5ldyBSZWxhdGlvbnNoaXBJbXBsKCk7Ci0gICAgICAgICAgICAgICAgICAgIHJlbGF0aW9uc2hpcC5zZXRUeXBlKHZhbGlkUmVxLmdldENhcGFiaWxpdHkoKSk7Ci0gICAgICAgICAgICAgICAgICAg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HJlbGF0aW9uc2hpcCk7CiAKLSAgICAgICAgICAgICAgICAgICAgQ29tcG9uZW50SW5zdGFuY2UgY3VycmVudENhcENvbXBJbnN0YW5jZSA9IG51bGw7Ci0gICAgICAgICAgICAgICAgICAgIGZvciAoQ29tcG9uZW50SW5zdGFuY2UgY29tcEluc3RhbmNlIDogY29tcG9uZW50SW5zdGFuY2VzTGlzdCkgewotICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNvbXBJbnN0YW5jZS5nZXROYW1lKCkuZXF1YWxzKHVwbG9hZFJlZ0luZm8uZ2V0Tm9kZSgpKSkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRDYXBDb21wSW5zdGFuY2UgPSBjb21wSW5zdGFuY2U7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgIH0KKwkJCQkJQ29tcG9uZW50SW5zdGFuY2UgY3VycmVudENhcENvbXBJbnN0YW5jZSA9IG51bGw7CisJCQkJCWZvciAoQ29tcG9uZW50SW5zdGFuY2UgY29tcEluc3RhbmNlIDogY29tcG9uZW50SW5zdGFuY2VzTGlzdCkgeworCQkJCQkJaWYgKGNvbXBJbnN0YW5jZS5nZXROYW1lKCkKKwkJCQkJCQkJLmVxdWFscyh1cGxvYWRSZWdJbmZvLmdldE5vZGUoKSkpIHsKKwkJCQkJCQljdXJyZW50Q2FwQ29tcEluc3RhbmNlID0gY29tcEluc3RhbmNlOworCQkJCQkJCWJyZWFrOworCQkJCQkJfQorCQkJCQl9CiAKLSAgICAgICAgICAgICAgICAgICAgaWYgKGN1cnJlbnRDYXBDb21wSW5zdGFuY2UgPT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJUaGUgY29tcG9uZW50IGluc3RhbmNlICB3aXRoIG5hbWUge30gbm90IGZvdW5kIG9uIHJlc291cmNlIHt9ICIsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVwbG9hZFJlZ0luZm8uZ2V0Tm9kZSgpLCByZXNvdXJjZS5nZXRVbmlxdWVJZCgpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIEJlRWNvbXBFcnJvck1hbmFnZXIuZ2V0SW5zdGFuY2UoKS5sb2dJbnRlcm5hbERhdGFFcnJvcigKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ09NUE9ORU5UX0lOU1RBTkNFX1dJVEhfTkFNRSArIHVwbG9hZFJlZ0luZm8uZ2V0Tm9kZSgpICsgSU5fUkVTT1VSQ0UsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc291cmNlLmdldFVuaXF1ZUlkKCksIEVycm9yU2V2ZXJpdHkuRVJST1IpOwotICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNvbXBvbmVudHNVdGlscwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLk5PVF9UT1BPTE9HWV9UT1NDQV9URU1QTEFURSwgeWFtbE5hbWUpOwotICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgIHJlZ0NhcFJlbERlZi5zZXRUb05vZGUoY3VycmVudENhcENvbXBJbnN0YW5jZS5nZXRVbmlxdWVJZCgpKTsKLSAgICAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJ0cnkgdG8gZmluZCBhdmlhYmxlIENhcGFiaWxpdHkgIHJlcSBuYW1lIGlzIHt9ICIsIHZhbGlkUmVxLmdldE5hbWUoKSk7Ci0gICAgICAgICAgICAgICAgICAgIENhcGFiaWxpdHlEZWZpbml0aW9uIGF2aWFibGVDYXBGb3JSZWwgPSBmaW5kQXZhaWxhYmxlQ2FwYWJpbGl0eUJ5VHlwZU9yTmFtZSh2YWxpZFJlcSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50Q2FwQ29tcEluc3RhbmNlLCB1cGxvYWRSZWdJbmZvKTsKLSAgICAgICAgICAgICAgICAgICAgcmVxQW5kUmVsYXRpb25zaGlwUGFpci5zZXRDYXBhYmlsaXR5KGF2aWFibGVDYXBGb3JSZWwuZ2V0TmFtZSgpKTsKLSAgICAgICAgICAgICAgICAgICAgcmVxQW5kUmVsYXRpb25zaGlwUGFpci5zZXRDYXBhYmlsaXR5VWlkKGF2aWFibGVDYXBGb3JSZWwuZ2V0VW5pcXVlSWQoKSk7Ci0gICAgICAgICAgICAgICAgICAgIHJlcUFuZFJlbGF0aW9uc2hpcFBhaXIuc2V0Q2FwYWJpbGl0eU93bmVySWQoYXZpYWJsZUNhcEZvclJlbC5nZXRPd25lcklkKCkpOwotICAgICAgICAgICAgICAgICAgICBpZiAoYXZpYWJsZUNhcEZvclJlbCA9PSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBsb2cuZGVidWcoImF2aWFibGUgY2FwYWJpbGl0eSB3YXMgbm90IGZvdW5kLiByZXEgbmFtZSBpcyB7fSBjb21wb25lbnQgaW5zdGFuY2UgaXMge30iLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWxpZFJlcS5nZXROYW1lKCksIGN1cnJlbnRDYXBDb21wSW5zdGFuY2UuZ2V0VW5pcXVlSWQoKSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nSW50ZXJuYWxEYXRhRXJyb3IoCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJhdmlhYmxlIGNhcGFiaWxpdHkgd2FzIG5vdCBmb3VuZC4gcmVxIG5hbWUgaXMgIiArIHZhbGlkUmVxLmdldE5hbWUoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgIiBjb21wb25lbnQgaW5zdGFuY2UgaXMgIiArIGN1cnJlbnRDYXBDb21wSW5zdGFuY2UuZ2V0VW5pcXVlSWQoKSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzb3VyY2UuZ2V0VW5pcXVlSWQoKSwgRXJyb3JTZXZlcml0eS5FUlJPUik7Ci0gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY29tcG9uZW50c1V0aWxzCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuTk9UX1RPUE9MT0dZX1RPU0NBX1RFTVBMQVRFLCB5YW1sTmFtZSk7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgQ2FwYWJpbGl0eVJlcXVpcmVtZW50UmVsYXRpb25zaGlwIGNhcFJlcVJlbCA9IG5ldyBDYXBhYmlsaXR5UmVxdWlyZW1lbnRSZWxhdGlvbnNoaXAoKTsKLSAgICAgICAgICAgICAgICAgICAgY2FwUmVxUmVsLnNldFJlbGF0aW9uKHJlcUFuZFJlbGF0aW9uc2hpcFBhaXIpOwotICAgICAgICAgICAgICAgICAgICByZXFBbmRSZWxhdGlvbnNoaXBQYWlyTGlzdC5hZGQoY2FwUmVxUmVsKTsKLSAgICAgICAgICAgICAgICAgICAgcmVnQ2FwUmVsRGVmLnNldFJlbGF0aW9uc2hpcHMocmVxQW5kUmVsYXRpb25zaGlwUGFpckxpc3QpOwotICAgICAgICAgICAgICAgICAgICByZWxhdGlvbnMuYWRkKHJlZ0NhcFJlbERlZik7Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgfQotICAgICAgICB9IGVsc2UgaWYgKHJlc291cmNlLmdldFJlc291cmNlVHlwZSgpICE9IFJlc291cmNlVHlwZUVudW0uQ1ZGQykgewotICAgICAgICAgICAgcmV0dXJuIGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuT0ssIHlhbWxOYW1lKTsKLSAgICAgICAgfQotICAgICAgICByZXR1c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udWxsOwotICAgICAgICBib29sZWFuIGlzVmFsaWRhdGUgPSB0cnVlOwotICAgICAgICBpZiAocHJvcGVydHlJbmZvLmdldFZhbHVlKCkgIT0gbnVsbCkgewotICAgICAgICAgICAgZ2V0SW5wdXRzID0gcHJvcGVydHlJbmZvLmdldEdldF9pbnB1dCgpOwotICAgICAgICAgICAgaXNWYWxpZGF0ZSA9IGdldElucHV0cyA9PSBudWxsIHx8IGdldElucHV0cy5pc0VtcHR5KCk7Ci0gICAgICAgICAgICBpZiAoaXNWYWxpZGF0ZSkgewotICAgICAgICAgICAgICAgIHZhbHVlID0gZ2V0UHJvcGVydHlKc29uU3RyaW5nVmFsdWUocHJvcGVydHlJbmZvLmdldFZhbHVlKCksCi0gICAgICAgICAgICAgICAgICAgICAgICBjdXJQcm9wZXJ0eURlZi5nZXRUeXBlKCkpOwotICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICB2YWx1ZSA9IGdldFByb3BlcnR5SnNvblN0cmluZ1ZhbHVlKHByb3BlcnR5SW5mby5nZXRWYWx1ZSgpLAotICAgICAgICAgICAgICAgICAgICAgICAgVHlwZVV0aWxzLlRvc2NhVGFnTmFtZXNFbnVtLkdFVF9JTlBVVC5nZXRFbGVtZW50TmFtZSgpKTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgfQotICAgICAgICBTdHJpbmcgaW5uZXJUeXBlID0gbnVsbDsKLSAgICAgICAgcHJvcGVydHkgPSBuZXcgQ29tcG9uZW50SW5zdGFuY2VJbnB1dChjdXJQcm9wZXJ0eURlZiwgdmFsdWUsIG51bGwpOworCQlTdHJpbmcgdmFsdWUgPSBudWxsOworCQlMaXN0PEdldElucHV0VmFsdWVEYXRhRGVmaW5pdGlvbj4gZ2V0SW5wdXRzID0gbnVsbDsKKwkJYm9vbGVhbiBpc1ZhbGlkYXRlID0gdHJ1ZTsKKwkJaWYgKHByb3BlcnR5SW5mby5nZXRWYWx1ZSgpICE9IG51bGwpIHsKKwkJCWd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B1dEluZGV4KTsKKwkJfQorCX0KIAotICAgIHByaXZhdGUgdm9pZCBhZGRJbnB1dChNYXA8U3RyaW5nLCBJbnB1dERlZmluaXRpb24+IGN1cnJQcm9wZXJ0aWVzTWFwLCBJbnB1dERlZmluaXRpb24gcHJvcCkgewotICAgICAgICBTdHJpbmcgcHJvcE5hbWUgPSBwcm9wLmdldE5hbWUoKTsKLSAgICAgICAgaWYgKCFjdXJyUHJvcGVydGllc01hcC5jb250YWluc0tleShwcm9wTmFtZSkpIHsKLSAgICAgICAgICAgIGN1cnJQcm9wZXJ0aWVzTWFwLnB1dChwcm9wTmFtZSwgcHJvcCk7Ci0gICAgICAgIH0KLSAgICB9CisJcHJpdmF0ZSB2b2lkIGFkZElucHV0KE1hcDxTdHJpbmcsIElucHV0RGVmaW5pdGlvbj4gY3VyclByb3BlcnRpZXNNYXAsIElucHV0RGVmaW5pdGlvbiBwcm9wKSB7CisJCVN0cmluZyBwcm9wTmFtZSA9IHByb3AuZ2V0TmFtZSgpOworCQlpZiAoIWN1cnJQcm9wZXJ0aWVzTWFwLmNvbnRhaW5zS2V5KHByb3BOYW1lKSkgeworCQkJY3VyclByb3BlcnRpZXNNYXAucHV0KHByb3BOYW1lLCBwcm9wKTsKKwkJfQorCX0KIAotICAgIHByaXZhdGUgUmVzcG9uc2VGb3JtYXQgYWRkUHJvcGVydHlWYWx1ZXNUb1JpKFVwbG9hZENvbXBvbmVudEluc3RhbmNlSW5mbyB1cGxvYWRDb21wb25lbnRJbnN0YW5jZUluZm8sCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUmVzb3VyY2UgcmVzb3VyY2UsIFJlc291cmNlIG9yaWdpblJlc291cmNlLCBDb21wb25lbnRJbnN0YW5jZSBjdXJyZW50Q29tcEluc3RhbmNlLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1hcDxTdHJpbmcsIExpc3Q8Q29tcG9uZW50S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0KKwkJTGlzdDxDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5PiBpbnN0UHJvcExpc3QgPSBuZXcgQXJyYXlMaXN0PD4oKTsKKwkJaWYgKHByb3BNYXAgIT0gbnVsbCAmJiBwcm9wTWFwLnNpemUoKSA+IDApIHsKKwkJCWZvciAoTGlzdDxVcGxvYWRQcm9wSW5mbz4gcHJvcGVydHlMaXN0IDogcHJvcE1hcC52YWx1ZXMoKSkgewogCi0gICAgICAgICAgICAgICAgVXBsb2FkUHJvcEluZm8gcHJvcGVydHlJbmZvID0gcHJvcGVydHlMaXN0LmdldCgwKTsKLSAgICAgICAgICAgICAgICBTdHJpbmcgcHJvcE5hbWUgPSBwcm9wZXJ0eUluZm8uZ2V0TmFtZSgpOwotICAgICAgICAgICAgICAgIGlmICghY3VyclByb3BlcnRpZXNNYXAuY29udGFpbnNLZXkocHJvcE5hbWUpKSB7Ci0gICAgICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiZmFpbGVkIHRvIGZpbmQgcHJvcGVydHkge30gIiwgcHJvcE5hbWUpOwotICAgICAgICAgICAgICAgICAgICByZXR1cm4gY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5QUk9QRVJUWV9OT1RfRk9VTkQsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvcE5hbWUpOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBQcm9wZXJ0eURlZmluaXRpb24gY3VyUHJvcGVydHlEZWYgPSBjdXJyUHJvcGVydGllc01hcC5nZXQocHJvcE5hbWUpOwotICAgICAgICAgICAgICAgIENvbXBvbmVudEluc3RhbmNlUHJvcGVydHkgcHJvcGVydHkgPSBudWxsOworCQkJCVVwbG9hZFByb3BJbmZvIHByb3BlcnR5SW5mbyA9IHByb3BlcnR5TGlzdC5nZXQoMCk7CisJCQkJU3RyaW5nIHByb3BOYW1lID0gcHJvcGVydHlJbmZvLmdldE5hbW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BudWxsIHx8IGdldElucHV0cy5pc0VtcHR5KCk7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChpc1ZhbGlkYXRlKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IGdldFByb3BlcnR5SnNvblN0cmluZ1ZhbHVlKHByb3BlcnR5SW5mby5nZXRWYWx1ZSgpLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJQcm9wZXJ0eURlZi5nZXRUeXBlKCkpOwotICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUgPSBnZXRQcm9wZXJ0eUpzb25TdHJpbmdWYWx1ZShwcm9wZXJ0eUluZm8uZ2V0VmFsdWUoKSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVHlwZVV0aWxzLlRvc2NhVGFnTmFtZXNFbnVtLkdFVF9JTlBVVC5nZXRFbGVtZW50TmFtZSgpKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBTdHJpbmcgaW5uZXJUeXBlID0gbnVsbDsKLSAgICAgICAgICAgICAgICBwcm9wZXJ0eSA9IG5ldyBDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5KGN1clByb3BlcnR5RGVmLCB2YWx1ZSwgbnVsbCk7CisJCQkJU3RyaW5nIHZhbHVlID0gbnVsbDsKKwkJCQlMaXN0PEdldElucHV0VmFsdWVEYXRhRGVmaW5pdGlvbj4gZ2V0SW5wdXRzID0gbnVsbDsKKwkJCQlib29sZWFuIGlzVmFsaWRhdGUgPSB0cnVlOworCQkJCWlmIChwcm9wZXJ0eUluZm8uZ2V0VmFsdWUoKSAhPSBudWxsKSB7CisJCQkJCWdldElucHV0cyA9IHByb3BlcnR5SW5mby5nZXRHZXRfaW5wdXQoKTsKKwkJCQkJaXNWYWxpZGF0ZSA9IGdldElucHV0cyA9PSBudWxsIHx8IGdldElucHV0cy5p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1dFZhbHVlRGF0YURlZmluaXRpb24gZ2V0SW5wdXQgOiBnZXRJbnB1dHMpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIExpc3Q8SW5wdXREZWZpbml0aW9uPiBpbnB1dHMgPSByZXNvdXJjZS5nZXRJbnB1dHMoKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dHMgPT0gbnVsbCB8fCBpbnB1dHMuaXNFbXB0eSgpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJGYWlsZWQgdG8gYWRkIHByb3BlcnR5IHt9IHRvIGluc3RhbmNlLiBJbnB1dHMgbGlzdCBpcyBlbXB0eSAiLCBwcm9wZXJ0eSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgcm9sbGJhY2tXaXRoRXhjZXB0aW9uKEFjdGlvblN0YXR1cy5JTlBVVFNfTk9UX0ZPVU5ELCBwcm9wZXJ0eS5nZXRHZXRJbnB1dFZhbHVlcygpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuc3RyZWFtKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5tYXAoR2V0SW5wdXRWYWx1ZURhdGFEZWZpbml0aW9uOjpnZXRJbnB1dE5hbWUpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuY29sbGVjdCh0b0xpc3QoKSkudG9TdHJpbmcoKSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgICAgICBJbnB1dERlZmluaXRpb24gaW5wdXQgPSBmaW5kSW5wdXRCeU5hbWUoaW5wdXRzLCBnZXRJbnB1dCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBnZXRJbnB1dC5zZXRJbnB1dElkKGlucHV0LmdldFVuaXF1ZUlkKCkpOwotICAgICAgICAgICAgICAgICAgICAgICAgZ2V0SW5wdXRWYWx1ZXMuYWRkKGdldElucHV0KTsKKw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IHsKLSAgICAgICAgICAgIGZvciAoRW50cnk8U3RyaW5nLCBMaXN0PFJlcXVpcmVtZW50RGVmaW5pdGlvbj4+IGVudHJ5IDogY29tSW5zdFJlZ0RlZk1hcC5lbnRyeVNldCgpKSB7Ci0gICAgICAgICAgICAgICAgZm9yIChSZXF1aXJlbWVudERlZmluaXRpb24gcmVxRGVmIDogZW50cnkuZ2V0VmFsdWUoKSkgewotICAgICAgICAgICAgICAgICAgICBpZiAocmVxRGVmLmdldE5hbWUoKS5lcXVhbHMocmVnTmFtZSkpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZXFEZWYuZ2V0TWF4T2NjdXJyZW5jZXMoKSAhPSBudWxsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICYmICFyZXFEZWYuZ2V0TWF4T2NjdXJyZW5jZXMoKS5lcXVhbHMoUmVxdWlyZW1lbnREYXRhRGVmaW5pdGlvbi5NQVhfT0NDVVJSRU5DRVMpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nIGxlZnRPY2N1cnJlbmNlcyA9IHJlcURlZi5nZXRMZWZ0T2NjdXJyZW5jZXMoKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobGVmdE9jY3VycmVuY2VzID09IG51bGwpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGVmdE9jY3VycmVuY2VzID0gcmVxRGVmLmdldE1heE9jY3VycmVuY2VzKCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludCBsZWZ0ID0gSW50ZWdlci5wYXJzZUludChsZWZ0T2NjdXJyZW5jZXMpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsZWZ0ID4gMCkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtLWxlZnQ7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlcURlZi5zZXRMZWZ0T2NjdXJyZW5jZXMoU3RyaW5nLnZhbHVlT2YobGVmdCkpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWxpZFJlZ0RlZiA9IHJlcURlZjsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWxpZFJlZ0RlZiA9IHJlcURlZjsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICAgICAgICAgIH0KKwlwcml2YXRlIEVpdGhlcjxSZXF1aXJlbWVudERlZmluaXRpb24sIFJlc3BvbnNlRm9ybWF0PiBmaW5kQXZpYWJsZVJlcXVpcmVtZW4oU3RyaW5nIHJlZ05hbWUsIFN0cmluZyB5YW1sTmFtZSwKKwkJCQkJCQkJCQkJCQkJCQkJCQkJVXBsb2FkQ29tcG9uZW50SW5zdGFuY2VJbmZvIHVwbG9hZENvbXBvbmVudEluc3RhbmNlSW5mbywgQ29tcG9uZW50SW5zdGFuY2UgY3VycmVudENvbXBJbnN0YW5jZSwKKwkJCQkJCQkJCQkJCQkJCQkJCQkJU3RyaW5nIGNhcE5hbWUpIHsKKwkJTWFwPFN0cmluZywgTGlzdDxSZXF1aXJlbWVudERlZmluaXRpb24+PiBjb21JbnN0UmVnRGVmTWFwID0gY3VycmVudENvbXBJbnN0YW5jZS5nZXRSZXF1aXJlbWVudHMoKTsKKwkJTGlzdDxSZXF1aXJlbWVudERlZmluaXRpb24+IGxpc3QgPSBjb21JbnN0UmVnRGVmTWFwLmdldChjYXBOYW1lKTsKKwkJUmVxdWlyZW1lbnREZWZpbml0aW9uIHZhb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lbHNlIHsKKwkJCQkJCQl2YWxpZFJlZ0RlZiA9IHJlcURlZjsKKwkJCQkJCQlicmVhazsKKwkJCQkJCX0KIAotICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIGlmICh2YWxpZFJlZ0RlZiAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIH0KLSAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgIGZvciAoUmVxdWlyZW1lbnREZWZpbml0aW9uIHJlcURlZiA6IGxpc3QpIHsKLSAgICAgICAgICAgICAgICBpZiAocmVxRGVmLmdldE5hbWUoKS5lcXVhbHMocmVnTmFtZSkpIHsKLSAgICAgICAgICAgICAgICAgICAgaWYgKHJlcURlZi5nZXRNYXhPY2N1cnJlbmNlcygpICE9IG51bGwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAmJiAhcmVxRGVmLmdldE1heE9jY3VycmVuY2VzKCkuZXF1YWxzKFJlcXVpcmVtZW50RGF0YURlZmluaXRpb24uTUFYX09DQ1VSUkVOQ0VTKSkgewotICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nIGxlZnRPY2N1cnJlbmNlcyA9IHJlcURlZi5nZXRMZWZ0T2NjdXJyZW5jZXMoKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsZWZ0T2NjdXJyZW5jZXMgPT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxlZnRPY2N1cnJlbmNlcyA9IHJlcURlZi5nZXRNYXhPY2N1cnJlbmNlcygpOwotICAgICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICAgICAgaW50IGxlZnQgPSBJbnRlZ2VyLnBhcnNlSW50KGxlZnRPY2N1cnJlbmNlcyk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBpZiAobGVmdCA+IDApIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAtLWxlZnQ7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxRGVmLnNldExlZnRPY2N1cnJlbmNlcyhTdHJpbmcudmFsdWVPZihsZWZ0KSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsaWRSZWdEZWYgPSByZXFEZWY7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwotICAgICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgICAgICAgICAgdmFsaWRSZWdEZWYgPSByZXFEZWY7Ci0gICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIH0KLSAgICAgICAgfQotICAgICAgICBpZiAodmFsaWRSZWdEZWYgPT0gbnVsbCkgewotICAgICAgICAgICAgUmVzcG9uc2VGb3JtYXQgcmVzcG9uc2VGb3JtYXQgPSBjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLklOVkFMSURfTk9ERV9URU1QTEFURSwKLSAgICAgICAgICAgICAgICAgICAgeWFtbE5hbWUsIHVwbG9hZENvbXBvbmVudEluc3RhbmNlSW5mby5nZXROYW1lKCksIHVwbG9hZENvbXBvbmVudEluc3RhbmNlSW5mby5nZXRUeXBlKCkpOwotICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChyZXNwb25zZUZvcm1hdCk7Ci0gICAgICAgIH0KLSAgICAgICAgcmV0dXJuIEVpdGhlci5sZWZ0KHZhbGlkUmVnRGVmKTsKLSAgICB9CisJCQkJCX0KKwkJCQl9CisJCQkJaWYgKHZhbGlkUmVnRGVmICE9IG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ICAgICAgICAgICAgICAgY29tcG9uZW50SW5zdGFuY2UuZ2V0VW5pcXVlSWQoKSkpOwogICAgICAgICB9Ci0KICAgICAgICAgQ29tcG9uZW50VHlwZUVudW0gY29udGFpbmVyQ29tcG9uZW50VHlwZSA9IHJlc291cmNlLmdldENvbXBvbmVudFR5cGUoKTsKLSAgICAgICAgTm9kZVR5cGVFbnVtIGNvbnRhaW5lck5vZGVUeXBlID0gY29udGFpbmVyQ29tcG9uZW50VHlwZS5nZXROb2RlVHlwZSgpOwotICAgICAgICBpZiAoY29udGFpbmVyTm9kZVR5cGUuZXF1YWxzKE5vZGVUeXBlRW51bS5SZXNvdXJjZSkKLSAgICAgICAgICAgICAgICAmJiBpc05vdEVtcHR5KHVwbG9hZENvbXBvbmVudEluc3RhbmNlSW5mby5nZXRDYXBhYmlsaXRpZXMoKSkKLSAgICAgICAgICAgICAgICAmJiBpc05vdEVtcHR5KHJlZlJlc291cmNlLmdldENhcGFiaWxpdGllcygpKSkgewotICAgICAgICAgICAgc2V0Q2FwYWJpbGl0eU5hbWVzVHlwZXMocmVmUmVzb3VyY2UuZ2V0Q2FwYWJpbGl0aWVzKCksIHVwbG9hZENvbXBvbmVudEluc3RhbmNlSW5mby5nZXRDYXBhYmlsaXRpZXMoKSk7Ci0gICAgICAgICAgICBNYXA8U3RyaW5nLCBMaXN0PENhcGFiaWxpdHlEZWZpbml0aW9uPj4gdmFsaWRDb21wb25lbnRJbnN0YW5jZUNhcGFiaWxpdGllcyA9IGdldFZhbGlkQ29tcG9uZW50SW5zdGFuY2VDYXBhYmlsaXRpZXMoCi0gICAgICAgICAgICAgICAgICAgIHJlZlJlc291cmNlLmdldFVuaXF1ZUlkKCksIHJlZlJlc291cmNlLmdldENhcGFiaWxpdGllcygpLAotICAgICAgICAgICAgICAgICAgICB1cGxvYWRDb21wb25lbnRJbnN0YW5jZUluZm8uZ2V0Q2FwYWJpbGl0aWVzKCkpOwotICAgICAgICAgICAgY29tcG9uZW50SW5zdGFuY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ICAgICAgICAgICAgICAgICAgLnN0YXRlKG9sZFJlc291cmNlLmdldExpZmVjeWNsZVN0YXRlKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5uYW1lKCkpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgLnZlcnNpb24ob2xkUmVzb3VyY2UuZ2V0VmVyc2lvbigpKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5idWlsZCgpKTsKKwkJCWxvZy5kZWJ1ZygiUmVzb3VyY2UgdXBkYXRlZCBzdWNjZXNzZnVsbHkhISEiKTsKKwkJCVJlc3BvbnNlRm9ybWF0IHJlc3BvbnNlRm9ybWF0ID0gY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5PSyk7CisJCQljb21wb25lbnRzVXRpbHMuYXVkaXRSZXNvdXJjZShyZXNwb25zZUZvcm1hdCwgdXNlciwgbmV3UmVzb3VyY2UsIEF1ZGl0aW5nQWN0aW9uRW51bS5JTVBPUlRfUkVTT1VSQ0UsCisJCQkJCVJlc291cmNlVmVyc2lvbkluZm8ubmV3QnVpbGRlcigpCisJCQkJCQkJLnN0YXRlKG9sZFJlc291cmNlLmdldExpZmVjeWNsZVN0YXRlKCkKKwkJCQkJCQkJCS5uYW1lKCkpCisJCQkJCQkJLnZlcnNpb24ob2xkUmVzb3VyY2UuZ2V0VmVyc2lvbigpKQorCQkJCQkJCS5idWlsZCgpKTsKIAotICAgICAgICAgICAgcmVzb3VyY2VQYWlyID0gbmV3IEltbXV0YWJsZVBhaXI8PihvdmVycmlkZVJlc291cmNlLmxlZnQoKS52YWx1ZSgpLAotICAgICAgICAgICAgICAgICAgICBBY3Rpb25TdGF0dXMuT0spOwotICAgICAgICAgICAgcmV0dXJuIHJlc291cmNlUGFpcjsKLSAgICAgICAgfSBmaW5hbGx5IHsKLSAgICAgICAgICAgIGlmIChyZXNvdXJjZVBhaXIgPT0gbnVsbCkgewotICAgICAgICAg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aHQoKSkgewotICAgICAgICAgICAgICAgICAgICByZXR1cm4gRWl0aGVyLnJpZ2h0KGVpdGhlclJlc3VsdC5yaWdodCgpLnZhbHVlKCkpOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIH0KLSAgICAgICAgfQorCQkJCQlSZXNwb25zZUZvcm1hdCBlcnJvclJlc3BvbnNlID0gY29tcG9uZW50c1V0aWxzCisJCQkJCQkJLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5NSVNTSU5HX0xJRkVDWUNMRV9UWVBFLCBpbnRUeXBlKTsKKwkJCQkJZWl0aGVyUmVzdWx0ID0gRWl0aGVyLnJpZ2h0KGVycm9yUmVzcG9uc2UpOworCQkJCQljb21wb25lbnRzVXRpbHMuYXVkaXRSZXNvdXJjZShlcnJvclJlc3BvbnNlLCB1c2VyLCByZXNvdXJjZSwgYWN0aW9uRW51bSk7CisJCQkJfQogCi0gICAgICAgIHJldHVybiBlaXRoZXJSZXN1bHQ7Ci0gICAgfQorCQkJfQorCQl9CisJCXJldHVybiBlaXRoZXJSZXN1bHQ7CisJfQogCi0gICAgLy8gQHBhcmFtIHR5cGVPYmplY3QtIHRoZSBvYmplY3QgdG8gd2hpY2ggdGhlIHZhbGlkYXRpb24gaXMgZG9uZQotICAgIHByaXZhdGUgRWl0aGVyPEJvb2xlYW4sIFJlc3BvbnNlRm9ybWF0PiB2YWxpZGF0ZUNhcGFiaWxpdHlUeXBlRXhpc3RzKFVzZXIgdXNlciwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJQ2FwYWJpbGl0eVR5cGVPcGVyYXRpb24gY2FwYWJpbGl0eVR5cGVPcGVyYXRpb24sIFJlc291cmNlIHJlc291cmNlLCBMaXN0PD8+IHZhbGlkYXRpb25PYmplY3RzLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg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Ci0gICAgICAgICAgICAgICAgaWYgKHByb3BlcnRpZXMgPT0gbnVsbCB8fCBwcm9wZXJ0aWVzLmlzRW1wdHkoKSkgewotICAgICAgICAgICAgICAgICAgICBwcm9wZXJ0aWVzID0gbmV3IEFycmF5TGlzdDw+KCk7Ci0gICAgICAgICAgICAgICAgICAgIGZvciAoRW50cnk8U3RyaW5nLCBQcm9wZXJ0eURlZmluaXRpb24+IHByb3AgOiBjYXBhYmlsaXR5VHlwZURlZmluaXRpb24uZ2V0UHJvcGVydGllcygpLmVudHJ5U2V0KCkpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIENvbXBvbmVudEluc3RhbmNlUHJvcGVydHkgbmV3UHJvcCA9IG5ldyBDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5KHByb3AuZ2V0VmFsdWUoKSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBwcm9wZXJ0aWVzLmFkZChuZXdQcm9wKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgIGZvciAoRW50cnk8U3RyaW5nLCBQcm9wZXJ0eURlZmluaXRpb24+IHByb3AgOiBjYXBhYmlsaXR5VHlwZURlZmluaXRpb24uZ2V0UHJvcGVydGllcygpLmVudHJ5U2V0KCkpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIFByb3BlcnR5RGVmaW5pdGlvbiBwb3JwRnJvbURlZiA9IHByb3AuZ2V0VmFsdWUoKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIExpc3Q8Q29tcG9uZW50SW5zdGFuY2VQcm9wZXJ0eT4gcHJvcHNUb0FkZCA9IG5ldyBBcnJheUxpc3Q8PigpOwotICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5IGNpcCA6IHByb3BlcnRpZXMpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWNpcC5nZXROYW1lKCkuZXF1YWxzKHBvcnBGcm9tRGVmLmdldE5hbWUoKSkpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29tcG9uZW50SW5zdGFuY2VQcm9wZXJ0eSBuZXdQcm9wID0gbmV3IENvbXBvbmVudEluc3RhbmNlUHJvcGVydHkocG9ycEZyb21EZWYpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm9wc1RvQWRkLmFkZChuZXdQcm9wKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXByb3BzVG9BZGQuaXNFbXB0eSgpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvcGVydGllcy5hZGRBbGwocHJvcHNUb0FkZCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgY2FwRGVmLnNldFByb3BlcnRpZXMocHJvcGVydGllcyk7Ci0gICAgICAgICAgICB9Ci0gICAgICAgIH0KLSAgICAgICAgcmV0dXJuIGVpdGhlclJlc3VsdDsKLSAgICB9CisJCUVpdGhlcjxCb29sZWFuLCBSZXNwb25zZUZvcm1hdD4gZWl0aGVyUmVzdWx0ID0gRWl0aGVyLmxlZnQodHJ1ZSk7CisJCWlmIChyZXNvdXJjZS5nZXRDYXBhYmlsaXRpZXMoKSAhPSBudWxsICYmIHJlc291cmNlLmdldENhcGFiaWxpdGllcygpCisJCQkJLnNpemUoKSA+IDApIHsKKwkJCWxvZy5kZWJ1ZygidmFsaWRhdGUgY2FwYWJpbGl0eSBUeXBlcyBFeGlzdCAtIGNhcGFiaWxpdGllcyBzZWN0aW9uIik7CiAKLSAgICBwdWJsaWMgUmVzb3VyY2UgY3JlYXRlUmVzb3VyY2VCeURhbyhSZXNvdXJjZSByZXNvdXJjZS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VyY2UuZ2V0UmVzb3VyY2VUeXBlKCkubmFtZSgpKSkgewotICAgICAgICAgICAgICAgIHNob3VsZENyZWF0ZUFydGlmYWN0ID0gZmFsc2U7Ci0gICAgICAgICAgICAgICAgcmV0dXJuOwotICAgICAgICAgICAgfQotICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgbG9nLmluZm8oInJlc291cmNlIHR5cGVzIGZvciBhcnRpZmFjdCBwbGFjZWhvbGRlciB7fSB3ZXJlIG5vdCBkZWZpbmVkLiBkZWZhdWx0IGlzIGFsbCByZXNvdXJjZXMiLAotICAgICAgICAgICAgICAgICAgICBrKTsKLSAgICAgICAgfQotICAgICAgICBpZiAoc2hvdWxkQ3JlYXRlQXJ0aWZhY3QpIHsKLSAgICAgICAgICAgIGlmIChhcnRpZmFjdHNCdXNpbmVzc0xvZ2ljICE9IG51bGwpIHsKLSAgICAgICAgICAgICAgICBBcnRpZmFjdERlZmluaXRpb24gYXJ0aWZhY3REZWZpbml0aW9uID0gYXJ0aWZhY3RzQnVzaW5lc3NMb2dpYy5jcmVhdGVBcnRpZmFjdFBsYWNlSG9sZGVySW5mbygKLSAgICAgICAgICAgICAgICAgICAgICAgIHJlc291cmNlLmdldFVuaXF1ZUlkKCksIGssIChNYXA8U3RyaW5nLCBPYmplY3Q+KSB2LAotICAgICAgICAgICAgICAgICAgICAgICAgdXNlciwgQXJ0aWZhY3RHcm91cFR5cGVFbnVtLkRFUExPWU1FTlQpOwotICAgICAgICAgICAgICAgIGlmIChhcnRpZmFjdERlZmluaXRpb24gIT0gbnVsbAotICAgICAgICAgICAgICAgICAgICAgICAgJiYgIWFydGlmYWN0TWFwLmNvbnRhaW5zS2V5KGFydGlmYWN0RGVmaW5pdGlvbi5nZXRBcnRpZmFjdExhYmVsKCkpKSB7Ci0gICAgICAgICAgICAgICAgICAgIGFydGlmYWN0TWFwLnB1dChhcnRpZmFjdERlZmluaXRpb24uZ2V0QXJ0aWZhY3RMYWJlbCgpLCBhcnRpZmFjd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dXJjZU5hbWUpOwotICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICBqYW51c0dyYXBoRGFvLmNvbW1pdCgpOwotICAgICAgICAgICAgfQotICAgICAgICB9Ci0gICAgICAgIGlmIChyZXNvdXJjZSAhPSBudWxsKSB7Ci0gICAgICAgICAgICBFaXRoZXI8Qm9vbGVhbiwgUmVzcG9uc2VGb3JtYXQ+IGxvY2tSZXN1bHQgPSBsb2NrQ29tcG9uZW50KHJlc291cmNlLmdldFVuaXF1ZUlkKCksIHJlc291cmNlLAotICAgICAgICAgICAgICAgICAgICBERUxFVEVfUkVTT1VSQ0UpOwotICAgICAgICAgICAgaWYgKGxvY2tSZXN1bHQuaXNSaWdodCgpKSB7Ci0gICAgICAgICAgICAgICAgcmVzdWx0ID0gU3RvcmFnZU9wZXJhdGlvblN0YXR1cy5HRU5FUkFMX0VSUk9SOwotICAgICAgICAgICAgICAgIHJldHVybiBjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLkdFTkVSQUxfRVJST1IpOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgdHJ5IHsKLSAgICAgICAgICAgICAgICByZXN1bHQgPSBtYXJrQ29tcG9uZW50VG9EZWxldGUocmVzb3VyY2UpOwotICAgICAgICAgICAgICAgIGlmICghcmVzdWx0LmVxdWFscyhTdG9yYWdlT3BlcmF0aW9uU3RhdHVzLk9LKSkgewotICAgICAgICAgICAgICAgICAgICBBY3Rpb25TdGF0dXMgYWN0aW9uU3RhdHVzID0gY29tcG9uZW50c1V0aWxzLmNvbnZlcnRGcm9tU3RvcmFnZVJlc3BvbnNlKHJlc3VsdCk7Ci0gICAgICAgICAgICAgICAgICAgIHJlc3BvbnNlRm9ybWF0ID0gY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0QnlSZXNvdXJjZShhY3Rpb25TdGF0dXMsIHJlc291cmNlLmdldE5hbWUoKSk7Ci0gIC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CgpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgT3BlcmF0aW9uIG9wZXJhdGlvbiA9IG9wZXJhdGlvbkVudHJ5LmdldFZhbHVlKCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgQXJ0aWZhY3REZWZpbml0aW9uIGltcGxlbWVudGF0aW9uID0gb3BlcmF0aW9uLmdldEltcGxlbWVudGF0aW9uQXJ0aWZhY3QoKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW1wbGVtZW50YXRpb24gIT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmcgdW5pcXVlSWQgPSBpbXBsZW1lbnRhdGlvbi5nZXRVbmlxdWVJZCgpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2cuZGVidWcoIlJlbW92aW5nIGludGVyZmFjZSBhcnRpZmFjdCBkZWZpbml0aW9uIHt9LCBvcGVyYXRpb24ge30sIGludGVyZmFjZVR5cGUge30iLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuaXF1ZUlkLCBvcGVyYXRpb25FbnRyeS5nZXRLZXkoKSwgaW50ZXJmYWNlVHlwZSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIG9ubHkgdGhpbmcgdGhhdCB0cmFuc2FjdHMgYW5kIGxvY2tzIGhlcmUKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlQXJ0aWZhY3RCeUludGVyZmFjZSA9IGFydGlmYWN0c0J1c2luZXNzTG9naWMuZGVsZXRlQXJ0aWZhY3RCeUludGVyZmFjZShyZXNvdXJjZUlkLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVzZXJJZCwgdW5pcXVlSWQsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ1ZSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICA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JmYWNlVHlwZSB7fSIsCisJCQkJCQkJCQkJdW5pcXVlSWQsIG9wZXJhdGlvbkVudHJ5LmdldEtleSgpLCBpbnRlcmZhY2VUeXBlKTsKKwkJCQkJCQkJLy8gb25seSB0aGluZyB0aGF0IHRyYW5zYWN0cyBhbmQgbG9ja3MgaGVyZQorCQkJCQkJCQlkZWxldGVBcnRpZmFjdEJ5SW50ZXJmYWNlID0gYXJ0aWZhY3RzQnVzaW5lc3NMb2dpYy5kZWxldGVBcnRpZmFjdEJ5SW50ZXJmYWNlKHJlc291cmNlSWQsCisJCQkJCQkJCQkJdXNlcklkLCB1bmlxdWVJZCwgdHJ1ZSk7CisJCQkJCQkJCWlmIChkZWxldGVBcnRpZmFjdEJ5SW50ZXJmYWNlLmlzUmlnaHQoKSkgeworCQkJCQkJCQkJbG9nLmRlYnVnKCJDb3VsZG4ndCByZW1vdmUgYXJ0aWZhY3QgZGVmaW5pdGlvbiB3aXRoIGlkIHt9IiwgdW5pcXVlSWQpOworCQkJCQkJCQkJaWYgKCFpblRyYW5zYWN0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgamFudXNHcmFwaERhby5yb2xsYmFjaygpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChkZWxldGVBcnRpZmFjdEJ5SW50ZXJmYWNlLnJpZ2h0KCkudmFsdWUoKSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2cudHJhY2UoIk5vIGltcGxlbWVudGF0aW9uIGZvdW5kIGZvciBvcGVyYXRpb24ge30gLSBub3RoaW5nIHRvIGRlbGV0ZSIsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC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ICAgICAgICAgICAgICAgICAgIC5vckVsc2UobnVsbCk7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChmb3VuZEFydGlmYWN0ICE9IG51bGwpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGlmIChBcnRpZmFjdFR5cGVFbnVtLmZpbmRUeXBlKGZvdW5kQXJ0aWZhY3QuZ2V0QXJ0aWZhY3RUeXBlKCkpID09IGN1cnJOZXdBcnRpZmFjdAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0QXJ0aWZhY3RUeXBlKCkpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWZvdW5kQXJ0aWZhY3QuZ2V0QXJ0aWZhY3RDaGVja3N1bSgpLmVxdWFscyhjdXJyTmV3QXJ0aWZhY3QuZ2V0QXJ0aWZhY3RDaGVja3N1bSgpKSkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyTmV3QXJ0aWZhY3Quc2V0QXJ0aWZhY3RVbmlxdWVJZChmb3VuZEFydGlmYWN0LmdldFVuaXF1ZUlkKCkpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBpZiBjdXJyZW50IGFydGlmYWN0IGFscmVhZHkgZXhpc3RzLCBidXQgaGFzCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGRpZmZlcmVudCBjb250ZW50LCBhZGQgaGltIHRvIHRoZSBsaXN0IHRvCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHVwZGF0ZQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcnRpZmFjdHNUb1VwZGF0ZS5hZGQoY3Vyck5ld0FydGlmYWN0KTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gcmVtb3ZlIGZvdW5kIGFydGlmYWN0IGZyb20gdGhlIGxpc3Qgb2YgZXhpc3RpbmcKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBhcnRpZmFjdHMgdG8gaGFuZGxlLCBiZWNhdXNlIGl0IHdhcyBhbHJlYWR5Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gaGFuZGxlZAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4aXN0aW5nQXJ0aWZhY3RzVG9IYW5kbGUucmVtb3ZlKGZvdW5kQXJ0aWZhY3QpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGFuZCByZW1vdmUgZm91bmQgYXJ0aWZhY3QgZnJvbSB0aGUgbGlzdCB0bwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHVwbG9hZCwgYmVjYXVzZSBpdCBzaG91bGQgZWl0aGVyIGJlIHVwZGF0ZWQgb3IgYmUKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBpZ25vcmVkCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJ0aWZhY3RzVG9VcGxvYWQucmVtb3ZlKGN1cnJOZXdBcnRpZmFjdCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiQ2FuJ3QgdXBsb2FkIHR3byBhcnRpZmFjdCB3aXRoIHRoZSBzYW1lIG5hbWUge30uIiwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJOZXdBcnRpZmFjdC5nZXRBcnRpZmFjdE5hbWUoKSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgUmVzcG9uc2VGb3JtYXQgcmVzcG9uc2VGb3JtYXQgPSBSZXNwb25zZUZvcm1hdE1hbmFnZXIuZ2V0SW5zdGFuY2UoKS5nZXRSZXNwb25zZUZvcm1hdCgKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFjdGlvblN0YXR1cy5BUlRJRkFDVF9BTFJFQURZX0VYSVNUX0lOX0RJRkZFUkVOVF9UWVBFX0lOX0NTQVIsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyTmV3QXJ0aWZhY3QuZ2V0QXJ0aWZhY3ROYW1lKCksIGN1cnJOZXdBcnRpZmFjdC5nZXRBcnRpZmFjdFR5cGUoKS5uYW1lKCksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3VuZEFydGlmYWN0LmdldEFydGlmYWN0VHlwZSgpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBBdWRpdGluZ0FjdGlvbkVudW0gYXVkaXRpbmdBY3Rpb24gPSBhcnRpZmFjdHNCdXNpbmVzc0xvZ2ljCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZGV0ZWN0QXVkaXRpbmdUeXBlKGFydGlmYWN0c0J1c2luZXNzTG9naWMubmV3IEFydGlmYWN0T3BlcmF0aW9uSW5mbyhmYWxzZSwgZmFsc2UsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFydGlmYWN0T3BlcmF0aW9uRW51bS5DUkVBVEUpLCBmb3VuZEFydGlmYWN0LmdldEFydGlmYWN0Q2hlY2tzdW0oKSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJ0aWZhY3RzQnVzaW5lc3NMb2dpYy5oYW5kbGVBdWRpdGluZyhhdWRpdGluZ0FjdGlvbiwgcmVzb3VyY2UsIHJlc291cmNlLmdldFVuaXF1ZUlkKCksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2VyLCBudWxsLCBudWxsLCBmb3VuZEFydGlmYWN0LmdldFVuaXF1ZUlkKCksIHJlc3BvbnNlRm9ybWF0LAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzb3VyY2UuZ2V0Q29tcG9uZW50VHlwZSgpLCBudWxsKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNwb25zZVdyYXBwZXIuc2V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7Ci0gICAgICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gRWl0aGVyLnJpZ2h0KGNoYW5nZVN0YXRlUmVzcG9uc2UucmlnaHQoKS52YWx1ZSgpKTsKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgIHJlc3BvbnNlUGFpciA9IG5ldyBJbW11dGFibGVQYWlyPD4oY2hhbmdlU3RhdGVSZXNwb25zZS5sZWZ0KCkudmFsdWUoKSwgcmVzcG9uc2UubGVmdCgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgLnZhbHVlKCkucmlnaHQpOwotICAgICAgICAgICAgICAgICAgICByZXNwb25zZSA9IEVpdGhlci5sZWZ0KHJlc3BvbnNlUGFpcik7Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgfQotICAgICAgICAgICAgZWxzZSB7Ci0gICAgICAgICAgICAgICAgUmVzcG9uc2VGb3JtYXQgdmFsaWRhdGlvbkVycm9yUmVzcG9uc2UgPSBpc1ZhbGlkUmVzb3VyY2UucmlnaHQoKS52YWx1ZSgpOwotICAgICAgICAgICAgICAgIGF1ZGl0RXJyb3JJbXBvcnQocmVzb3VyY2VNZXRhRGF0YSwgY3JlYXRvciwgdmFsaWRhdGlvbkVycm9yUmVzcG9uc2UsIHRydWUpOwotICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gRWl0aGVyLnJpZ2h0KHZhbGlkYXRpb25FcnJvclJlc3BvbnNlKTsKLSAgICAgICAgICAgIH0KLQorICAgICAgICAgICAgICAgIHJlc3BvbnNlUGFpciA9IG5ldyBJbW11dGFibGVQYWlyPD4oY2hhbmdlU3RhdGVSZXNwb25zZSwgcmVzcG9uc2UubGVmdCgpCisgICAgICAgICAgICAgICAgICAgICAgICAudmFsdWUoKS5yaWdodCk7CiAgICAgICAgIH0KICAgICAgICAgY2F0Y2ggKFJ1bnRpbWVFeGNlcHRpb24gZSkgewotICAgICAgICAgICAg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5cGVFbnVtLkNWRkMpIHsKKyAgICAgICAgICAgICAgICB0b3NjYUpzb24gPSBuZXcgSGFzaE1hcDw+KCk7CisgICAgICAgICAgICAgICAgdG9zY2FKc29uLnB1dChUeXBlVXRpbHMuVG9zY2FUYWdOYW1lc0VudW0uTk9ERV9UWVBFUy5nZXRFbGVtZW50TmFtZSgpLCB0b3NjYUpzb25BbGwuZ2V0KFR5cGVVdGlscy5Ub3NjYVRhZ05hbWVzRW51bS5OT0RFX1RZUEVTLmdldEVsZW1lbnROYW1lKCkpKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIC8vIERlcml2ZWQgRnJvbQorICAgICAgICAgICAgUmVzb3VyY2UgcGFyZW50UmVzb3VyY2UgPSBzZXREZXJpdmVkRnJvbSh0b3NjYUpzb24sIHJlc291cmNlKTsKKyAgICAgICAgICAgIGlmIChTdHJpbmdVdGlscy5pc0VtcHR5KHJlc291cmNlLmdldFRvc2NhUmVzb3VyY2VOYW1lKCkpKSB7CisgICAgICAgICAgICAgICAgc2V0VG9zY2FSZXNvdXJjZU5hbWUodG9zY2FKc29uLCByZXNvdXJjZSk7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBzZXRBdHRyaWJ1dGVzKHRvc2NhSnNvbiwgcmVzb3VyY2UpOworICAgICAgICAgICAgc2V0Q2FwYWJpbGl0aWVzKHRvc2NhSnNvbiwgcmVzb3VyY2UsIHBhcmVudFJlc291cmNlKTsKKyAgICAgICAgICAgIHNldFByb3BlcnRpZXModG9zY2FKc29uLCByZXNvdXJjZSk7CisgICAgICAgICAgICBzZXRSZXF1aXJlbWVudHModG9zY2FKc29uLCByZXNvdXJjZSwgcGFyZW50UmVzb3VyY2UpOworICAgICAgICAgICAgc2V0SW50ZXJmYWNlTGlmZWN5Y2xlKHRvc2NhSnNvbiwgcmVzb3VyY2UpOwogICAgICAgICB9Ci0gICAgICAgIC8vIERlcml2ZWQgRnJvbQotICAgICAgICBFaXRoZXI8UmVzb3VyY2UsIFJl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JFUV9DQVBfTkFNRSwgInJlcXVpcmVtZW50IiwgcmVxTmFtZUxvd2VyQ2FzZSkpOworICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgQnlBY3Rpb25TdGF0dXNDb21wb25lbnRFeGNlcHRpb24oQWN0aW9uU3RhdHVzLklNUE9SVF9EVVBMSUNBVEVfUkVRX0NBUF9OQU1FLCAicmVxdWlyZW1lbnQiLCByZXFOYW1lTG93ZXJDYXNlKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgcmVxTmFtZXMuYWRkKHJlcU5hbWVMb3dlckNhc2UpOwotICAgICAgICAgICAgICAgIEVpdGhlcjxSZXF1aXJlbWVudERlZmluaXRpb24sIFJlc3BvbnNlRm9ybWF0PiBlaXRoZXJSZXF1aXJlbWVudCA9IGNyZWF0ZVJlcXVpcmVtZW50RnJvbUltcG9ydEZpbGUocmVxdWlyZW1lbnRKc29uV3JhcHBlcgorICAgICAgICAgICAgICAgIFJlcXVpcmVtZW50RGVmaW5pdGlvbiByZXF1aXJlbWVudERlZiA9IGNyZWF0ZVJlcXVpcmVtZW50RnJvbUltcG9ydEZpbGUocmVxdWlyZW1lbnRKc29uV3JhcHBlcgogICAgICAgICAgICAgICAgICAgICAgICAgLmdldChyZXF1aXJlbWVudE5hbWUpKTsKLSAgICAgICAgICAgICAgICBpZiAoZWl0aGVyUmVxdWlyZW1lbnQuaXNSaWdodCgpKSB7Ci0gICAgICAgICAgICAgICAgICAgIGxvZy5pbmZvKCJlcnJvciB3aGVuIGNyZWF0aW5nIFJlcXVpcmVtZW50Ont9LCBmb3IgcmVzb3VyY2U6e30iLCByZXF1aXJlbWVudE5hbWUsIHJlc291cmNlLmdldE5hbWUoKSk7Ci0gICAgICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQoZWl0aGVyUmVxdWlyZW1lbnQucmlnaHQoKS52YWx1ZSgpKTsKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgUm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udENhcC5yaWdodCgpLnZhbHVlKCkpOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBpZiAoIXZhbGlkYXRlVnNQYXJlbnRDYXAubGVmdCgpLnZhbHVlKCkpIHsKKyAgICAgICAgICAgICAgICBpZiAoIXZhbGlkYXRlVnNQYXJlbnRDYXApIHsKICAgICAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJSZXF1aXJlbWVudCB3aXRoIG5hbWUge30gYWxyZWFkeSBleGlzdHMgaW4gcGFyZW50IHt9IiwgcmVxdWlyZW1lbnREZWYuZ2V0TmFtZSgpLCBwYXJlbnRSZXNvdXJjZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXROYW1lKCkpOwotICAgICAgICAgICAgICAgICAgICBSZXNwb25zZUZvcm1hdCByZXNwb25zZUZvcm1hdCA9IGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuSU1QT1JUX1JFUV9DQVBfTkFNRV9FWElTVFNfSU5fREVSSVZFRCwgInJlcXVpcmVtZW50IiwgcmVxdWlyZW1lbnREZWYKKyAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEJ5QWN0aW9uU3RhdHVzQ29tcG9uZW50RXhjZXB0aW9uKEFjdGlvblN0YXR1cy5JTVBPUlRfUkVRX0NBUF9OQU1FX0VYSVNUU19JTl9ERVJJVkVELCAicmVxdWlyZW1lbnQiLCByZXF1aXJlbWVudERlZgogICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXROYW1lKCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAudG9Mb3dlckNhc2UoKSwgcGFyZW50UmVzb3VyY2UuZ2V0TmFtZSgpKTsKLSAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChyZXNwb25zZUZvcm1hdCk7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogICAgICAgICAgICAgaWYgKG1vZHVsZVJ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hcDxTdHJpbmcsIE9iamVjdD4pIHJlcXVpcmVtZW50SnNvbjsKLSAgICAgICAgICAgICAgICBpZiAocmVxdWlyZW1lbnRKc29uTWFwLmNvbnRhaW5zS2V5KFR5cGVVdGlscy5Ub3NjYVRhZ05hbWVzRW51bS5DQVBBQklMSVRZLmdldEVsZW1lbnROYW1lKCkpKSB7Ci0gICAgICAgICAgICAgICAgICAgIHJlcXVpcmVtZW50LnNldENhcGFiaWxpdHkoKFN0cmluZykgcmVxdWlyZW1lbnRKc29uTWFwLmdldChUeXBlVXRpbHMuVG9zY2FUYWdOYW1lc0VudW0uQ0FQQUJJTElUWS5nZXRFbGVtZW50TmFtZSgpKSk7Ci0gICAgICAgICAgICAgICAgfQotCi0gICAgICAgICAgICAgICAgaWYgKHJlcXVpcmVtZW50SnNvbk1hcC5jb250YWluc0tleShUeXBlVXRpbHMuVG9zY2FUYWdOYW1lc0VudW0uTk9ERS5nZXRFbGVtZW50TmFtZSgpKSkgewotICAgICAgICAgICAgICAgICAgICByZXF1aXJlbWVudC5zZXROb2RlKChTdHJpbmcpIHJlcXVpcmVtZW50SnNvbk1hcC5nZXQoVHlwZVV0aWxzLlRvc2NhVGFnTmFtZXNFbnVtLk5PREUuZ2V0RWxlbWVudE5hbWUoKSkpOwotICAgICAgICAgICAgICAgIH0KLQotICAgICAgICAgICAgICAgIGlmIChyZXF1aXJlbWVudEpzb25NYXAuY29udGFpbnNLZXkoVHlwZVV0aWxzLlRvc2NhVGFnTmFtZXNFbnVtLlJFTEFUSU9OU0hJUC5nZXRFbGVtZW50TmFtZSgpKSkgewotICAgICAgICAgICAgICAgICAgICByZXF1aXJlbWVudC5zZXRSZWxhdGlvbnNoaXAoKFN0cmluZykgcmVxdWlyZW1lbnRKc29uTWFwLmdldChUeXBlVXRpbHMuVG9zY2FUYWdOYW1lc0VudW0uUkVMQVRJT05TSElQLmdldEVsZW1lbnROYW1lKCkpKTsKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICA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HMuY29udmVydEZyb21SZXN1bHRTdGF0dXNFbnVtKFJlc3VsdFN0YXR1c0VudW0uSU5WQUxJRF9QUk9QRVJUWV9OQU1FLCBKc29uUHJlc2VudGF0aW9uRmllbGRzLlBST1BFUlRZKSkpOworICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEJ5QWN0aW9uU3RhdHVzQ29tcG9uZW50RXhjZXB0aW9uKGNvbXBvbmVudHNVdGlscy5jb252ZXJ0RnJvbVJlc3VsdFN0YXR1c0VudW0oUmVzdWx0U3RhdHVzRW51bS5JTlZBTElEX1BST1BFUlRZX05BTUUsIEpzb25QcmVzZW50YXRpb25GaWVsZHMuUFJPUEVSVFkpKTsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICBQcm9wZXJ0eURlZmluaXRpb24gcHJvcGVydHlEZWZpbml0aW9uID0gZW50cnkuZ2V0VmFsdWUoKTsKICAgICAgICAgICAgICAgICAgICAgcHJvcGVydHlEZWZpbml0aW9uLnNldE5hbWUobmFtZSk7CkBAIC01MTUsMTEgKzQ2MCwxMCBAQAogICAgICAgICAgICAgcmVzb3VyY2Uuc2V0UHJvcGVydGllcyhwcm9wZXJ0aWVzTGlzdCk7CiAgICAgICAgIH0KICAgICAgICAgZWxzZSBpZiAocHJvcGVydGllcy5yaWdodCgpLnZhbHVlKCkgIT0gUmVzdWx0U3RhdHVzRW51bS5FTEVNRU5UX05PVF9GT1VORCkgewotICAgICAgICAgICAgcmVzdWx0ID0gRWl0aGVyLnJpZ2h0KGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChjb21wb25lbnRzVXRpbHMuY29udmVydEZyb21SZXN1bHRTdGF0dXNFbnVtKHByb3BlcnRpZXMKKyAgICAgICAgICAgIHRocm93IG5ldyBCeUFjdGlvblN0YXR1c0NvbXBvbmVudEV4Y2VwdGlvbihjb21wb25lbnRzVXRpbHMuY29udmVydEZyb21SZXN1bHRTdGF0dXNFbnVtKHBy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nJpZ2h0KCkudmFsdWUoKSk7Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIGlmICghdmFsaWRhdGVWc1BhcmVudENhcC5sZWZ0KCkudmFsdWUoKSkgeworCisgICAgICAgICAgICAgICAgaWYgKCF2YWxpZGF0ZVZzUGFyZW50Q2FwKSB7CiAgICAgICAgICAgICAgICAgICAgIC8vIEhlcmUgcGFyZW50UmVzb3VyY2UgaXMgZm9yIHN1cmUgbm90IG51bGwsIHNvIGl0J3MKICAgICAgICAgICAgICAgICAgICAgLy8gbnVsbC1zYWZlCiAgICAgICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiQ2FwYWJpbGl0eSB3aXRoIG5hbWUge30gYWxyZWFkeSBleGlzdHMgaW4gcGFyZW50IHt9IiwgY2FwYWJpbGl0eURlZi5nZXROYW1lKCksIHBhcmVudFJlc291cmNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldE5hbWUoKSk7Ci0gICAgICAgICAgICAgICAgICAgIFJlc3BvbnNlRm9ybWF0IHJlc3BvbnNlRm9ybWF0ID0gY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5JTVBPUlRfUkVRX0NBUF9OQU1FX0VYSVNUU19JTl9ERVJJVkVELCAiY2FwYWJpbGl0eSIsIGNhcGFiaWxpdHlEZWYKKyAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEJ5QWN0aW9uU3RhdHVzQ29tcG9uZW50RXhjZXB0aW9uKEFjdGlvblN0YXR1cy5JTVBPUlRfUkVRX0NBUF9OQU1FX0VYSVNUU19JTl9ERVJJVkVELCAiY2FwYWJpbGl0eSIsIGNhcGFiaWxpdHlEZWYKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0TmFtZSgpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnRvTG93ZXJDYXNlKCksIHBhcmVudFJlc291cmNlLmdldE5hbWUoKSk7Ci0gICAgICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQocmVzcG9uc2VGb3JtYXQpOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KICAgICAgICAgICAgIGlmIChtb2R1bGVDYXBhYmlsaXRpZXMuc2l6ZSgpID4gMCkgewogICAgICAgICAgICAgICAgIHJlc291cmNlLnNldENhcGFiaWxpdGllcyhtb2R1bGVDYXBhYmlsaXRpZXMpOwogICAgICAgICAgICAgfQogICAgICAgICB9Ci0KLSAgICAgICAgcmV0dXJuIGVpdGhlclJlc3VsdDsKLQogICAgIH0KIAotICAgIHByaXZhdGUgRWl0aGVyPE1hcDxTdHJpbmcsIFN0cmluZz4sIFJlc3BvbnNlRm9ybWF0PiBnZXRDYXBOYW1lMlR5cGUoUmVzb3VyY2UgcGFyZW50UmVzb3VyY2UpIHsKKyAgICBwcml2YXRlIE1hcDxTdHJpbmcsIFN0cmluZz4gZ2V0Q2FwTmFtZTJUeXBlKFJlc291cmNlIHBhcmVudFJlc291cmNlKSB7CiAgICAgICAgIE1hcDxTdHJpbmcsIFN0cmluZz4gY2FwTmFtZTJ0eXBlID0gbmV3IEhhc2hNYXA8PigpOwogICAgICAgICBpZiAocGFyZW50UmVzb3VyY2UgIT0gbnVsbCkgewogICAgICAgICAgICAgTWFwPFN0cmluZywgTGlzdDxDYXBhYmlsaXR5RGVmaW5pdGlvbj4+IGNhcGFiaWxpdGllcyA9IHBhcmVudFJlc291cmNlLmdldENhcGFiaWxpdGllcygpOwpAQCAtNjU1LDE3ICs1NzksMTcgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2cuZGVidWcoIlJlc291cmNlIHdpdGggbmFtZSB7fSBoYXMgbW9yZSB0aGFuIG9uZSBjYXBhYmlsaXR5IHdpdGggbmFtZSB7fSwgaWdub3JpbmcgY2FzZSIsIHBhcmVudFJlc291cmNlTmFtZSwgbmFtZUxvd2VyQ2FzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQmVFY29tcEVycm9yTWFuYWdlci5nZXRJbnN0YW5jZSgpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5sb2dJbnRlcm5hbERhdGFFcnJvcigiSW1wb3J0IHJlc291cmNlIiwgIlBhcmVudCByZXNvdXJjZSAiICsgcGFyZW50UmVzb3VyY2VOYW1lICsgIiBvZiBpbXBvcnRlZCByZXNvdXJjZSBoYXMgb25lIG9yIG1vcmUgY2FwYWJpbGl0aWVzIHdpdGggbmFtZSAiICsgbmFtZUxvd2VyQ2FzZSwgRXJyb3JTZXZlcml0eS5FUlJPUik7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLkdFTkVSQUxfRVJST1IpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgQnlBY3Rpb25TdGF0dXNDb21wb25lbnRFeGNlcHRpb24oQWN0aW9uU3RhdHVzLkdFTkVSQUxfRVJST1IpOwogICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgY2FwTmFtZTJ0eXBlLnB1dChuYW1lTG93ZXJDYXNlLCBjYXBEZWZpbml0aW9uLmdldFR5cGUoKSk7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KLSAgICAgICAgcmV0dXJuIEVpdGhlci5sZWZ0KGNhcE5hbWUydHlwZSk7CisgICAgICAgIHJldHVybiBjYXBOYW1lMnR5cGU7CiAgICAgfQogCi0gICAgcHJpdmF0ZSBFaXRoZXI8TWFwPFN0cmluZywgU3RyaW5nPiwgUmVzcG9uc2VGb3JtYXQ+IGdldFJlcU5hbWUyVHlwZShSZXNvdXJjZSBwYXJlbnRSZXNvdXJjZSkgeworICAgIHBy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NSaWdodCgpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSBFaXRoZXIucmlnaHQodmFsaWRhdGVBbmRTZXRPY2N1cnJlbmNlc1N0YXR1cy5yaWdodCgpLnZhbHVlKCkpOwotICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBpZiAodmFsaWRhdGVBbmRTZXRPY2N1cnJlbmNlc1N0YXR1cy5sZWZ0KCkudmFsdWUoKSkgewotICAgICAgICAgICAgICAgICAgICAgICAgY2FwYWJpbGl0eURlZmluaXRpb24uc2V0TWluT2NjdXJyZW5jZXMob2NjdXJyZW5jZXNMaXN0LmdldCgwKS50b1N0cmluZygpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGNhcGFiaWxpdHlEZWZpbml0aW9uLnNldE1heE9jY3VycmVuY2VzKG9jY3VycmVuY2VzTGlzdC5nZXQoMSkudG9TdHJpbmcoKSk7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgaWYgKGNhcGFiaWxpdHlKc29uTWFwLmNvbnRhaW5zS2V5KFR5cGVVdGlscy5Ub3NjYVRhZ05hbWVzRW51bS5QUk9QRVJUSUVTLmdldEVsZW1lbnROYW1lKCkpKSB7Ci0KLSAgICAgICAgICAgICAgICAgICAgRWl0aGVyPE1hcDxTdHJpbmcsIFByb3BlcnR5RGVmaW5pdGlvbj4sIFJlc3VsdFN0YXR1c0VudW0+IHByb3BlcnRpZXNSZXMgPSBJbXBvcnRVdGlscy5nZXRQcm9wZXJ0aWVzKGNhcGFiaWxpdHlKc29uTWFwKTsKLSAgICAgICAgICAgICAgICAgICAgaWYgKHByb3BlcnRpZXNSZXMuaXNSaWdodCgpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSBFaXRoZXIucmlnaHQoY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5QUk9QRVJUWV9OT1RfRk9VTkQpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBwcm9wZXJ0aWVzUmVzLmxlZnQoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC52YWx1ZSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmVudHJ5U2V0KCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuc3RyZWFtKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZm9yRWFjaChlIC0+IGUuZ2V0VmFsdWUoKS5zZXROYW1lKGUuZ2V0S2V5KCkudG9Mb3dlckNhc2UoKSkpOwotICAgICAgICAgICAgICAgICAgICAgICAgTGlzdDxDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5PiBjYXBhYmlsaXR5UHJvcGVydGllcyA9IHByb3BlcnRpZXNSZXMubGVmdCgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC52YWx1ZSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC52YWx1ZXMoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuc3RyZWFtKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLm1hcChwIC0+IG5ldyBDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5KHAsIHAKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0RGVmYXVsdFZhbHVlKCksIG51bGwpKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuY29sbGVjdChDb2xsZWN0b3JzLnRvTGlzdCgpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGNhcGFiaWxpdHlEZWZpbml0aW9uLnNldFByb3BlcnRpZXMoY2FwYWJpbGl0eVByb3BlcnRpZXMpOwotICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgLy8gVmFsaWRTb3VyY2VUeXBlcworICAgICAgICAgICAgaWYgKGNhcGFiaWxpdHlKc29uTWFwLmNvbnRhaW5zS2V5KFR5cGVVdGlscy5Ub3NjYVRhZ05hbWVzRW51bS5WQUxJRF9TT1VSQ0VfVFlQRVMuZ2V0RWxlbWVudE5hbWUoKSkpIHsKKyAgICAgICAgICAgICAgICBjYXBhYmlsaXR5RGVmaW5pdGlvbi5zZXRWYWxpZFNvdXJjZVR5cGVzKChMaXN0PFN0cmluZz4pIGNhcGFiaWxpdHlKc29uTWFwLmdldChUeXBlVXRpbHMuVG9zY2FUYWdOYW1lc0VudW0uVkFMSURfU09VUkNFX1RZUEVTCisgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0RWxlbWVudE5hbWUoKSkpOwogICAgICAgICAgICAgfQotICAgICAgICAgICAgZWxzZSBpZiAoIShjYXBhYmlsaXR5SnNvbiBpbnN0YW5jZW9mIExpc3QpKSB7CisgICAgICAgICAgICAvLyBWYWxpZFNvdXJjZVR5cGVzCis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ZXNFbnVtLlBST1BFUlRJRVMuZ2V0RWxlbWVudE5hbWUoKSkpIHsKIAotICAgICAgICAgICAgICAgIHJlc3VsdCA9IEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLklOVkFMSURfWUFNTCkpOwotCisgICAgICAgICAgICAgICAgRWl0aGVyPE1hcDxTdHJpbmcsIFByb3BlcnR5RGVmaW5pdGlvbj4sIFJlc3VsdFN0YXR1c0VudW0+IHByb3BlcnRpZXNSZXMgPSBJbXBvcnRVdGlscy5nZXRQcm9wZXJ0aWVzKGNhcGFiaWxpdHlKc29uTWFwKTsKKyAgICAgICAgICAgICAgICBpZiAocHJvcGVydGllc1Jlcy5pc1JpZ2h0KCkpIHsKKyAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEJ5QWN0aW9uU3RhdHVzQ29tcG9uZW50RXhjZXB0aW9uKEFjdGlvblN0YXR1cy5QUk9QRVJUWV9OT1RfRk9VTkQpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgcHJvcGVydGllc1Jlcy5sZWZ0KCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC52YWx1ZSgpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZW50cnlTZXQoKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnN0cmVhbSgpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZm9yRWFjaChlIC0+IGUuZ2V0VmFsdWUoKS5zZXROYW1lKGUuZ2V0S2V5KCkudG9Mb3dlckNhc2UoKSkpOworICAgICAgICAgICAgICAgICAgICBMaXN0PENvbXBvbmVudEluc3RhbmNlUHJvcGVydHk+IGNhcGFiaWxpdHlQcm9wZXJ0aWVzID0gcHJvcGVydGllc1Jlcy5sZWZ0KCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAudmFsdWUoKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC52YWx1ZXMoKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5zdHJlYW0oKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5tYXAocCAtPiBuZXcgQ29tcG9uZW50SW5zdGFuY2VQcm9wZXJ0eShwLCBwCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0RGVmYXVsdFZhbHVlKCksIG51bGwpKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5jb2xsZWN0KENvbGxlY3RvcnMudG9MaXN0KCkpOworICAgICAgICAgICAgICAgICAgICBjYXBhYmlsaXR5RGVmaW5pdGlvbi5zZXRQcm9wZXJ0aWVzKGNhcGFiaWxpdHlQcm9wZXJ0aWVzKTsKKyAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KLSAgICAgICAgY2F0Y2ggKEV4Y2VwdGlvbiBlKSB7Ci0gICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nQmVTeXN0ZW1FcnJvcigiSW1wb3J0IFJlc291cmNlIC0gY3JlYXRlIGNhcGFiaWxpdHkiKTsKLSAgICAgICAgICAgI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9uZW50RXhjZXB0aW9uKEFjdGlvblN0YXR1cy5JTlZBTElEX09DQ1VSUkVOQ0VTKTsKICAgICAgICAgfQogCi0gICAgICAgIGlmIChtYXhPYmogaW5zdGFuY2VvZiBTdHJpbmcpIHsKLSAgICAgICAgICAgIGlmICgiVU5CT1VOREVEIi5lcXVhbHMobWF4T2JqKSkgewotICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIubGVmdCh0cnVlKTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGVsc2UgeworICAgICAgICBpZiAobWF4T2JqIGluc3RhbmNlb2YgU3RyaW5nKXsKKyAgICAgICAgICAgIGlmKCEiVU5CT1VOREVEIi5lcXVhbHMobWF4T2JqKSkgewogICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiSW52YWxpZCBvY2N1cnJlbnNlcyBmb3JtYXQuIE1heCBvY2N1cnJlbmNlIGlzIHt9IiwgbWF4T2JqKTsKLSAgICAgICAgICAgICAgICBSZXNwb25zZUZvcm1hdCByZXNwb25zZUZvcm1hdCA9IGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuSU5WQUxJRF9PQ0NVUlJFTkNFUyk7Ci0gICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChyZXNwb25zZUZvcm1hdCk7CisgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEJ5QWN0aW9uU3RhdHVzQ29tcG9uZW50RXhjZXB0aW9uKEFjdGlvblN0YXR1cy5JTlZBTElEX09DQ1VSUkVOQ0VTKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfQogICAgICAgICBlbHNlIHsKQEAgLTkyMywxOSArODMxLDE0IEBACiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgICAgICBsb2cuZGVidWcoIkludmFsaWQgb2NjdXJyZW5zZXMgZm9ybWF0LiAgTWF4IG9jY3VycmVuY2UgaXMge30iLCBtYXh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lvbiwgU3RyaW5nIGNvbXBvbmVudFVVSUQsIFN0cmluZyB1c2VySWQpIHsKLSAgICAgICAgdmFsaWRhdGVVc2VyRXhpc3RzKHVzZXJJZCwgImdldCBDb21wb25lbnQgQXVkaXQgUmVjb3JkcyIsIGZhbHNlKTsKKyAgICAgICAgdmFsaWRhdGVVc2VyRXhpc3RzKHVzZXJJZCk7CiAgICAgICAgIEVpdGhlcjxMaXN0PE1hcDxTdHJpbmcsIE9iamVjdD4+LCBBY3Rpb25TdGF0dXM+IHJlc3VsdDsKICAgICAgICAgdHJ5IHsKIApAQCAtMzU4LDcgKzM0NCw3IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nIG9wZXJhdGlvbklkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZyB1c2VySWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU2VydmljZUNvbnN1bXB0aW9uRGF0YSBzZXJ2aWNlQ29uc3VtcHRpb25EYXRhKSB7Ci0gICAgICAgIHZhbGlkYXRlVXNlckV4aXN0cyh1c2VySWQsICJjcmVhdGUgUHJvcGVydHkiLCBmYWxzZSk7CisgICAgICAgIHZhbGlkYXRlVXNlckV4aXN0cyh1c2VySWQpOwogCiAgICAgICAgIEVpdGhlcjxTZXJ2aWNlLCBTdG9yYWdlT3BlcmF0aW9uU3RhdHVzPiBzZXJ2aWNlRWl0aGVyID0KICAgICAgICAgICAgICAgICB0b3NjYU9wZXJhdGlvbkZhY2FkZS5nZXRUb3NjYUVsZW1lbnQoc2VydmljZUlkKTsKQEAgLTcwMywzMyArNjg5LDE5IEBACiAKIAlwcml2YXRlIEVpdGhlcjxCb29sZWFuLCBSZXNwb25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lKCkpOworICAgICAgICAgICAgcmV0dXJuIHRvc2NhT3BlcmF0aW9uRmFjYWRlLnVwZGF0ZVRvc2NhRWxlbWVudChzZXJ2aWNlVG9VcGRhdGUpCisgICAgICAgICAgICAgICAgICAgIC5yaWdodCgpCisgICAgICAgICAgICAgICAgICAgIC5tYXAocmYgLT4geworICAgICAgICAgICAgICAgICAgICAgICAgamFudXNHcmFwaERhby5yb2xsYmFjaygpOworICAgICAgICAgICAgICAgICAgICAgICAgQmVFY29tcEVycm9yTWFuYWdlci5nZXRJbnN0YW5jZSgpLmxvZ0JlU3lzdGVtRXJyb3IoIlVwZGF0ZSBTZXJ2aWNlIE1ldGFkYXRhIik7CisgICAgICAgICAgICAgICAgICAgICAgICBsb2cuZGVidWcoImZhaWxlZCB0byB1cGRhdGUgc2V2aWNlIHt9Iiwgc2VydmljZVRvVXBkYXRlLmdldFVuaXF1ZUlkKCkpOworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLkdFTkVSQUxfRVJST1IpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgfSkKKyAgICAgICAgICAgICAgICAgICAgLmxlZnQoKQorICAgICAgICAgICAgICAgICAgICAuYmluZChjIC0+ICB1cGRhdGVDYXRhbG9nQW5kQ29tbWl0KGMpKTsKKwogICAgICAgICB9IGZpbmFsbHkgewogICAgICAgICAgICAgZ3JhcGhMb2NrT3BlcmF0aW9uLnVubG9ja0NvbXBvbmVudChzZXJ2aWNlSWQsIE5vZGVUeXBlRW51bS5TZXJ2aWNlKTsKICAgICAgICAgfQogICAgIH0KIAotICAgIHB1YmxpYyBFaXRoZXI8U2V0PFN0cmluZz4sIFJlc3BvbnNlRm9ybWF0PiBkZWxldGVGb3J3YXJkaW5nUGF0aHMoU3RyaW5nIHNlcnZpY2VJZCwgU2V0PFN0cmluZz4gcGF0aElkc1RvRGVsZXRlLCBVc2V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ZXRlIEZvcndhcmRpbmcgUGF0aCBvbiBTZXJ2aWNlIik7CisgICAgICAgICAgICB9IGNhdGNoIChDb21wb25lbnRFeGNlcHRpb24gZSkgewogICAgICAgICAgICAgICAgIGphbnVzR3JhcGhEYW8ucm9sbGJhY2soKTsKLSAgICAgICAgICAgICAgICByZXR1cm4gRWl0aGVyLnJpZ2h0KGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChjb21wb25lbnRzVXRpbHMKLSAgICAgICAgICAgICAgICAgICAgLmNvbnZlcnRGcm9tU3RvcmFnZVJlc3BvbnNlKHN0b3JhZ2VTdGF0dXMucmlnaHQoKS52YWx1ZSgpLCBDb21wb25lbnRUeXBlRW51bS5TRVJWSUNFKSwgIiIpKTsKKyAgICAgICAgICAgICAgICB0aHJvdyBuZXcgQnlBY3Rpb25TdGF0dXNDb21wb25lbnRFeGNlcHRpb24oY29tcG9uZW50c1V0aWxzLmNvbnZlcnRGcm9tU3RvcmFnZVJlc3BvbnNlCisgICAgICAgICAgICAgICAgICAgICAgICAoc3RvcmFnZVN0YXR1cy5yaWdodCgpLnZhbHVlKCksIENvbXBvbmVudFR5cGVFbnVtLlNFUlZJQ0UpLCAiIik7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICAgICAgdHJ5ewpAQCAtMTEyMSwxOSArMTA4MCwyMCBAQAogICAgICAgICAgICAgaWYgKHJlc3VsdC5pc1JpZ2h0KCkpIHsKICAgICAgICAgICAgICAgICBsb2cuZGVidWcoRkFJTEVEX1RPX0xPQ0tfU0VSVklDRV9SRVNQT05TRV9JUywgc2VydmljZS5nZXROYW1lKCksIHJlc3VsdC5yaWdodCgpLnZhbHVlKCkpOwogICAgICAgICAgICAgICAgIGphbnVzR3JhcGhEYW8ucm9sbGJhY2soKTsKLSAgICAgICAgICAgICAgICByZXR1cm4gRWl0aGVyLnJpZ2h0KGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChjb21wb25lbnRz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0b3JlZFNlcnZpY2UuZ2V0U3lzdGVtTmFtZSgpKTsKICAgICAgICAgfQogICAgICAgICBNYXA8U3RyaW5nLCBGb3J3YXJkaW5nUGF0aERhdGFEZWZpbml0aW9uPiByZXN1bHRNYXAgPSBuZXcgSGFzaE1hcDw+KCk7CiAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICB0cmltbWVkRm9yd2FyZGluZ1BhdGhzLnZhbHVlcygpLmZvckVhY2goZnAgLT4gZnAuc2V0VG9zY2FSZXNvdXJjZU5hbWUodG9zY2FSZXNvdXJjZU5hbWUpKTsKIAotICAgICAgICAgICAgdHJ5IHsKLSAgICAgICAgICAgICAgICBmb3IgKEZvcndhcmRpbmdQYXRoRGF0YURlZmluaXRpb24gZm9yd2FyZGluZ1BhdGhEYXRhRGVmaW5pdGlvbiA6IHRyaW1tZWRGb3J3YXJkaW5nUGF0aHMudmFsdWVzKCkpIHsKLSAgICAgICAgICAgICAgICAgICAgaWYgKGlzVXBkYXRlKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSBmb3J3YXJkaW5nUGF0aE9wZXJhdGlvbi51cGRhdGVGb3J3YXJkaW5nUGF0aChzZXJ2aWNlSWQsIGZvcndhcmRpbmdQYXRoRGF0YURlZmluaXRpb24pOwotICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gZm9yd2FyZGluZ1BhdGhPcGVyYXRpb24uYWRkRm9yd2FyZGluZ1BhdGgoc2VydmljZUlkLCBmb3J3YXJkaW5nUGF0aERhdGFEZWZpbml0aW9uKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBpZiAocmVzdWx0LmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgICAgICAgICAgamFudXNHcmFwaERhby5yb2xsYmFjaygpOwotICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tcG9uZW50c1V0aWxzLmNvbnZlcnRGcm9tU3RvcmFnZVJlc3BvbnNlKHJlc3VsdC5yaWdodCgpLnZhbHVlKCksIENvbXBvbmVudFR5cGVFbnVtLlNFUlZJQ0UpLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICIiKSk7Ci0gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBGb3J3YXJkaW5nUGF0aERhdGFEZWZpbml0aW9uIGZwRGF0YURlZmluaXRpb24gPSByZXN1bHQubGVmdCgpLnZhbHVlKCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICByZXN1bHRNYXAucHV0KGZwRGF0YURlZmluaXRpb24uZ2V0VW5pcXVlSWQoKSwgZm9yd2FyZGluZ1BhdGhEYXRhRGVmaW5pdGlvbik7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgIH0gY2F0Y2ggKEV4Y2VwdGlvbiBlKSB7Ci0gICAgICAgICAgICAgICAgamFudXNHcmFwaERhby5yb2xsYmFjaygpOwotICAgICAgICAgICAgICAgIGxvZy5lcnJvcigiRXhjZXB0aW9uIG9jY3VycmVkIGR1cmluZyBhZGQgb3IgdXBkYXRlIGZvcndhcmRpbmcgcGF0aCBwcm9wZXJ0eSB2YWx1ZXM6IHt9IiwgZS5nZXRNZXNzYWdlKCksCi0gICAgICAgICAgICAgICAgICAgIGUpOwotICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQoY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5HRU5FUkFMX0VSUk9SKSk7Ci0gICAgICAgICAgICB9CisgICAgICAgICAgICBwb3B1bGF0ZUZvcndhcmRpbmdQYXRocyhzZXJ2aWNlSWQsIGlzV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ZGF0ZSkgeworICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSBmb3J3YXJkaW5nUGF0aE9wZXJhdGlvbi51cGRhdGVGb3J3YXJkaW5nUGF0aChzZXJ2aWNlSWQsIGZvcndhcmRpbmdQYXRoRGF0YURlZmluaXRpb24pOworICAgICAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgICAgIHJlc3VsdCA9IGZvcndhcmRpbmdQYXRoT3BlcmF0aW9uLmFkZEZvcndhcmRpbmdQYXRoKHNlcnZpY2VJZCwgZm9yd2FyZGluZ1BhdGhEYXRhRGVmaW5pdGlvbik7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGlmIChyZXN1bHQuaXNSaWdodCgpKSB7CisgICAgICAgICAgICAgICAgICAgIGphbnVzR3JhcGhEYW8ucm9sbGJhY2soKTsKKyAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEJ5UmVzcG9uc2VGb3JtYXRDb21wb25lbnRFeGNlcHRpb24oY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KAorICAgICAgICAgICAgICAgICAgICAgICAgY29tcG9uZW50c1V0aWxzLmNvbnZlcnRGcm9tU3RvcmFnZVJlc3BvbnNlKHJlc3VsdC5yaWdodCgpLnZhbHVlKCksIENvbXBvbmVudFR5cGVFbnVtLlNFUlZJQ0UpLAorICAgICAgICAgICAgICAgICAgICAgICAgIiIpKTsKKyAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICBGb3J3YXJkaW5nUGF0aERhdGFEZWZpbml0aW9uIGZwRGF0YURlZmluaXRpb24gPSByZXN1bHQubGVmdCgpLnZhbHVlKCk7CisgICAgICAgICAgICAgICAgICAgIHJlc3VsdE1hcC5wdXQoZnBEYXRhRGVmaW5pdGlvbi5nZXRVbmlxdWVJZCgpLCBmb3J3YXJkaW5nUGF0aERhdGFEZWZpbml0aW9uKTsKKyAgICAgICAgICAgICAgICB9Cisg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vbGUodXNlciwgY3VycmVudFNlcnZpY2UsIHNlcnZpY2VVcGRhdGUsIFVQREFURV9TRVJWSUNFX01FVEFEQVRBKTsKICAgICAgICAgICAgIGlmIChyZXNwb25zZS5pc1JpZ2h0KCkpIHsKQEAgLTEzNjMsNyArMTMyMSw3IEBACiAgICAgICAgICAgICBjdXJyZW50U2VydmljZS5zZXRFY29tcEdlbmVyYXRlZE5hbWluZyhpc0Vjb21wR2VuZXJhdGVkVXBkYXRlKTsKICAgICAgICAgfQogICAgICAgICBTdHJpbmcgbmFtaW5nUG9saWN5VXBkYXRlID0gc2VydmljZVVwZGF0ZS5nZXROYW1pbmdQb2xpY3koKTsKLSAgICAgICAgaWYgKGN1cnJlbnRTZXJ2aWNlLmlzRWNvbXBHZW5lcmF0ZWROYW1pbmcoKSkgeworICAgICAgICBpZiAoY3VycmVudFNlcnZpY2UuaXNFY29tcEdlbmVyYXRlZE5hbWluZygpICE9IG51bGwgJiYgY3VycmVudFNlcnZpY2UuaXNFY29tcEdlbmVyYXRlZE5hbWluZygpKSB7CiAgICAgICAgICAgICBjdXJyZW50U2VydmljZS5zZXROYW1pbmdQb2xpY3kobmFtaW5nUG9saWN5VXBkYXRlKTsKICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIGlmICghU3RyaW5nVXRpbHMuaXNFbXB0eShuYW1pbmdQb2xpY3lVcGRhdGUpKSB7CkBAIC0xMzc3LDcgKzEzMzUsNyBAQAogICAgICAgICBTdHJpbmcgY29udGFjdElkVXBkYXRlZCA9IHNlcnZpY2VVcGRhdGUuZ2V0Q29udGFjdElkKCk7CiAgICAgICAgIFN0cmluZyBjb250YWN0SWRDdXJyZW50ID0gY3VycmVudFNlcnZpY2UuZ2V0Q29udGFjdElkKCk7CiAgICAgICAgIGlmICghY29udGFjdElkQ3VycmVudC5lcXVhbHMoY29udGFjdElkVXBkYXRlZCkpIHsKLSAgICAgICAgICAgdmFsaWRhdGVDb250YWN0SWQodXNlciwgc2VydmljZVVwZ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0gbnVsbCAmJiAhYXJ0aWZhY3RHZW5MaXN0LmlzRW1wdHkoKSkgewotICAgICAgICAgICAgICAgIGZvciAoQXJ0aWZhY3RHZW5lcmF0b3I8Q2FsbFZhbD4gZW50cnkgOiBhcnRpZmFjdEdlbkxpc3QpIHsKLSAgICAgICAgICAgICAgICAgICAgRWl0aGVyPENhbGxWYWwsIFJlc3BvbnNlRm9ybWF0PiBjYWxsUmVzOwotICAgICAgICAgICAgICAgICAgICB0cnkgewotICAgICAgICAgICAgICAgICAgICAgICAgY2FsbFJlcyA9IGVudHJ5LmNhbGwoKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjYWxsUmVzLmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiRmFpbGVkIHRvIGdlbmVyYXRlIGFydGlmYWN0IGVycm9yIDoge30iLCBjYWxsUmVzLnJpZ2h0KCkudmFsdWUoKSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChjYWxsUmVzLnJpZ2h0KCkudmFsdWUoKSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKEV4Y2VwdGlvbiBlKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBsb2cuZGVidWcoIkZhaWxlZCB0byBnZW5lcmF0ZSBhcnRpZmFjdCBleGNlcHRpb24gOiB7fSIsIGUpOwotICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLkdFTkVSQUxfRVJST1IpKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBFaXRoZXI8U2VydmljZSwgUmVzcG9uc2VGb3JtYXQ+IGNhbGxSZXMgPSBjaG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VyYXRpb25GYWNhZGUuZ2V0VG9zY2FFbGVtZW50KHNlcnZpY2VJZCk7CiAgICAgICAgIGlmIChzdG9yYWdlU3RhdHVzLmlzUmlnaHQoKSkgewpAQCAtMjY4NywxNSArMjUwOSwxMCBAQAogICAgICAgICB9CiAKICAgICAgICAgRWl0aGVyPFN0cmluZywgU3RvcmFnZU9wZXJhdGlvblN0YXR1cz4gcmVzdWx0OwotICAgICAgICBpZiAobG9jaykgewotICAgICAgICAgICAgRWl0aGVyPEJvb2xlYW4sIFJlc3BvbnNlRm9ybWF0PiBsb2NrUmVzdWx0ID0gbG9ja0NvbXBvbmVudChzZXJ2aWNlLmdldFVuaXF1ZUlkKCksIHNlcnZpY2UsICJEZWxldGUgU2VydmljZSBGaWx0ZXIgZnJvbSBzZXJ2aWNlIik7Ci0gICAgICAgICAgICBpZiAobG9ja1Jlc3VsdC5pc1JpZ2h0KCkpIHsKLSAgICAgICAgICAgICAgICBqYW51c0dyYXBoRGFvLnJvbGxiYWNrKCk7Ci0gICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoY29tcG9uZW50c1V0aWxzCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuY29udmVydEZyb21TdG9yYWdlUmVzcG9uc2Uoc3RvcmFnZVN0YXR1cy5yaWdodCgpLnZhbHVlKCksIENvbXBvbmVudFR5cGVFbnVtLlNFUlZJQ0UpLCAiIikpOwotICAgICAgICAgICAgfQotICAgICAgICB9CiAgICAgICAgIHRyeXsKKyAgICAgICAgICAgIGlmIChsb2NrKSB7CisgICAgICAgICAgICAgICAgbG9ja0NvbXBvbmVudChzZXJ2aWNlLmdldFVuaXF1ZUlkKCksIHNlcnZpY2UsICJEZWxldGUgU2VydmljZSBGaWx0ZXIgZnJvbSBzZXJ2aWNlIik7CisgICA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jQxCi0tLSAvZGV2L251bGwKKysrIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2NvbXBvbmVudHMvaW1wbC9hYWYvQWFmUGVybWlzc2lvbi5qYXZhCkBAIC0wLDAgKzEsNjYgQEAKKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAyMCBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKKyAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KKyAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAorICoKKyAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wCisgKgorICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZQorICogZGlzdHJpYnV0ZWQgdW5kZXIgdGhlIExpY2Vuc2UgaXMgZGlzdHJpYnV0ZWQgb24gYW4gIkFTIElTIiBCQVNJUywKKyAqIFdJVE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W50cy9pbXBsL2FhZi9BYWZSb2xlcy5qYXZhCkBAIC0yLDE0ICsyLDE0IEBACiAgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQogICogU0RDCiAgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogQ29weXJpZ2h0IChDKSAyMDIwIEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgogICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KICAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOwogICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgogICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0Ci0gKiAKKyAqCiAgKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAotICogCisgKgogICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZQogICogZGlzdHJpYnV0ZWQgdW5kZXIgdGhlIExpY2Vuc2UgaXMgZGlzdHJpYnV0ZWQgb24gYW4gIkFTIElTIiBCQVNJUywKICAqIFdJVEhPVVQgV0FSU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vUm9sZUF1dGhvcml6YXRpb25IYW5kbGVyLmphdmEKQEAgLTAsMCArMSw4MiBAQAorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDIwIEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgorICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0CisgKgorICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKKyAqCisgKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlCisgKiBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0cmlidXRlZCBvbiBhbiAiQVMgSVMiIEJBU0lTLAorICogV0lUSE9VVCBXQVJSQU5USUVTIE9SIENPTkRJVElPTlMgT0YgQU5ZIEtJTkQsIGVpdGhlciBleHByZXNzIG9yIGltcGxpZWQuCisgKiBTZWUgdGhlIExpY2Vuc2UgZm9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amF2YQorKysgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvY29tcG9uZW50cy9pbXBsL2V4Y2VwdGlvbnMvQ29tcG9uZW50RXhjZXB0aW9uLmphdmEKQEAgLTIsNyArMiw3IEBACiAgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQogICogU0RDCiAgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogQ29weXJpZ2h0IChDKSAyMDIwIEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgogICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KICAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOwogICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgpAQCAtMTYsMjIgKzE2LDY0IEBACiAgKiBTZWUgdGhlIExpY2Vuc2UgZm9yIHRoZSBzcGVjaWZpYyBsYW5ndWFnZSBnb3Zlcm5pbmcgcGVybWlzc2lvbnMgYW5kCiAgKiBsaW1pdGF0aW9ucyB1bmRlciB0aGUgTGljZW5zZS4KICAqID09PT09PT09PT09PUxJQ0VOU0VfRU5EPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT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b21wb25lbnRzL2ltcGwvZ3JvdXAvR3JvdXBWZXJzaW9uVXBkYXRlci5qYXZhCm5ldyBmaWxlIG1vZGUgMTAwNjQ0CmluZGV4IDAwMDAwMDAuLmJiNGQ4ODQKLS0tIC9kZXYvbnVsbAorKysgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvY29tcG9uZW50cy9pbXBsL2dyb3VwL0dyb3VwVmVyc2lvblVwZGF0ZXIuamF2YQpAQCAtMCwwICsxLDEyNSBAQAorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDIwIEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgorICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0CisgKgorICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKKyAqCisgKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcs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9CisKKyAgCisgICAgcHJpdmF0ZSB2b2lkIGluY3JlYXNlTWFqb3JWZXJzaW9uKEdyb3VwRGVmaW5pdGlvbiBncm91cCwgQ29tcG9uZW50IGNvbnRhaW5lcikgeworICAgICAgICBTdHJpbmcgdmVyc2lvbiA9IGdyb3VwLmdldFZlcnNpb24oKTsKKyAgICAgICAgCisgICAgICAgIFN0cmluZyBuZXdWZXJzaW9uID0gR3JvdXBVdGlscy51cGRhdGVWZXJzaW9uKFByb21vdGVWZXJzaW9uRW51bS5NQUpPUiwgZ3JvdXAuZ2V0VmVyc2lvbigpKTsKKyAgICAgIAorICAgICAgICBpZighdmVyc2lvbi5lcXVhbHMobmV3VmVyc2lvbikgKXsKKyAgICAgICAgICAgIGlmKGlzR2VuZXJhdGVHcm91cFVVSUQoZ3JvdXAsIGNvbnRhaW5lcikpIHsKKyAgICAgICAgICAgICAgICBTdHJpbmcgZ3JvdXBVVUlEID0gVW5pcXVlSWRCdWlsZGVyLmdlbmVyYXRlVVVJRCgpOworICAgICAgICAgICAgICAgIGdyb3VwLnNldEdyb3VwVVVJRChncm91cFVVSUQpOworICAgICAgICAgICAgfQorICAgICAgICAgICAgZ3JvdXAuc2V0VmVyc2lvbihTdHJpbmcudmFsdWVPZihuZXdWZXJzaW9uKSk7CisgICAgICAgIH0KKworICAgIH0KKworICAgIHByaXZhdGUgYm9vbGVhbiBpc0dlbmVyYXRlR3JvdXBVVUlEKEdyb3VwRGVmaW5pdGlvbiBncm91cCwgQ29tcG9uZW50IGNvbnRhaW5lcikgeworICAgICAgICBpZihHcm91cFR5cGVFbnVtLlZGX01PRFVMRS5nZXRHcm91cFR5cGVOYW1lKCkuZXF1YWxzKGdyb3VwLmdldFR5cGUoKSkpeworICAgICAgICAgICAgTGlzdDxTdHJpbmc+IGFydGlmYWN0c1V1aWQgPSBncm91cC5nZXRBcnRpZmFjdHNVdWlkKCk7CisgICAgICAgICAgICBMaXN0PFN0cmluZz4gaGVhdEFydGlmYWN0VW5pcX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URlZmluaXRpb24sIFBvbGljeVRhcmdldFR5cGUgdGFyZ2V0VHlwZSkgewpkaWZmIC0tZ2l0IGEvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2NvbXBvbmVudHMvaW1wbC9wb2xpY3kvUG9saWN5VmVyc2lvblVwZGF0ZXIuamF2YSBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jb21wb25lbnRzL2ltcGwvcG9saWN5L1BvbGljeVZlcnNpb25VcGRhdGVyLmphdmEKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uZWYyZjhjYgotLS0gL2Rldi9udWxsCisrKyBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jb21wb25lbnRzL2ltcGwvcG9saWN5L1BvbGljeVZlcnNpb25VcGRhdGVyLmphdmEKQEAgLTAsMCArMSwxMDQgQEAKKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAyMCBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKKyAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbG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aW1wbC92ZXJzaW9uL09uQ2hhbmdlVmVyc2lvbkNvbW1hbmQuamF2YQpAQCAtMCwwICsxLDM5IEBACisvKi0KKyAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBTREMKKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBDb3B5cmlnaHQgKEMpIDIwMjAgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7CisgKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCisgKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKKyAqCisgKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAorICoKKyAqIFVubGVzcyByZXF1aXJlZCBieSBhcHBsaWNhYmxlIGxhdyBvciBhZ3JlZWQgdG8gaW4gd3JpdGluZywgc29mdHdhcmUKKyAqIGRpc3RyaWJ1dGVkIHVuZGVyIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1dGVkIG9uIGFuICJBUyBJUyIgQkFTSVMsCisgKiBXSVRIT1VUIFdBUlJBTlRJRVMgT1IgQ09ORElUSU9OUyBPRiBBTlkgS0lORCwgZWl0aGVyIGV4cHJlc3Mgb3I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KKyAgICAgKiBAcmV0dXJuIHRoZSBzdGF0dXMgb2YgdGhlIG9wZXJhdGlvbgorICAgICAqLworICAgIEFjdGlvblN0YXR1cyBvbkNoYW5nZVZlcnNpb24oQ29tcG9uZW50IGNvbnRhaW5lcik7CisKK30KZGlmZiAtLWdpdCBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jb21wb25lbnRzL2ltcGwvdmVyc2lvbi9WZXNpb25VcGRhdGVIYW5kbGVyLmphdmEgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvY29tcG9uZW50cy9pbXBsL3ZlcnNpb24vVmVzaW9uVXBkYXRlSGFuZGxlci5qYXZhCm5ldyBmaWxlIG1vZGUgMTAwNjQ0CmluZGV4IDAwMDAwMDAuLjEzMDg2YzcKLS0tIC9kZXYvbnVsbAorKysgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvY29tcG9uZW50cy9pbXBsL3ZlcnNpb24vVmVzaW9uVXBkYXRlSGFuZGxlci5qYXZhCkBAIC0wLDAgKzEsNjYgQEAKKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAyMCBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2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TsKKyAgICAgICAgfQorCisgICAgICAgIExpc3Q8Q29tcG9uZW50SW5zdGFuY2U+IHJlc291cmNlSW5zdGFuY2UgPSBjb21wb25lbnQuZ2V0Q29tcG9uZW50SW5zdGFuY2VzKCk7CisgICAgICAgIGlmIChyZXNvdXJjZUluc3RhbmNlICE9IG51bGwpIHsKKworICAgICAgICAgICAgLy9GaWx0ZXIgY29tcG9uZW50cyBpbnN0YW5jZXMgd2l0aCBhcmNoaXZlZCBvcmlnaW5zCisgICAgICAgICAgICBPcHRpb25hbDxDb21wb25lbnRJbnN0YW5jZT4gYXJjaGl2ZWRSSU9wdGlvbmFsID0gcmVzb3VyY2VJbnN0YW5jZS5zdHJlYW0oKS5maWx0ZXIoQ29tcG9uZW50SW5zdGFuY2VEYXRhRGVmaW5pdGlvbjo6aXNPcmlnaW5BcmNoaXZlZCkuZmluZEFueSgpOworCisgICAgICAgICAgICAvL1JJcyB3aXRoIGFyY2hpdmVkIG9yaWdpbnMgZm91bmQsIHJldHVybiByZWxldmFudCBlcnJvcgorICAgICAgICAgICAgaWYgKGFyY2hpdmVkUklPcHRpb25hbC5pc1ByZXNlbnQoKSl7CisgICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChjb21wb25lbnRVdGlscy5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuQVJDSElWRURfT1JJR0lOU19GT1VORCwgY29tcG9uZW50LmdldENvbXBvbmVudFR5cGUoKS5uYW1lKCksIGNvbXBvbmVudC5nZXROYW1lKCkpKTsKKyAgICAgICAgICAgIH0KKworICAgICAgICAgICAgLy9Db250aW51ZSB3aXRoIHNlYXJjaGluZyBmb3Igbm9uIGNlcnRpZmllZCBSSXMKKyAgICAgICAgICAgIE9wdGlvbmFsPENvbXBvbmVudEluc3RhbmNlPiBub25DZXJ0aWZpZWRSSU9wdGlvbmFsID0gcmVzb3VyY2VJbnN0YW5jZS5zdHJlYW0oKS5maWx0ZXIocCAtPiAhVmFsaWRhdGlvblV0aWxzLnZhbGlkYXRlQ2VydGlmaWVkVmVyc2lvbihwLmdldENvbXBvbmVudFZlcnNpb24oKSkpLmZpbmRBbnkoKTsKKyAgICAgICAgICAgIC8vIFVuY2VydGlmaWVkIFJlc291cmNlIEZvdW5kCisgICAgICAgICAgICBpZiAobm9uQ2VydGlmaWVkUklPcHRpb25hbC5pc1ByZXNlbnQoKSkgeworICAgICAgICAgICAgICAgIENvbXBvbmVudEluc3RhbmNlIG5vbkNlcnRpZmllZFJJID0gbm9uQ2VydGlmaWVkUklPcHRpb25hbC5nZXQoKTsKKyAgICAgICAgICAgICAgICBSZXNwb25zZUZvcm1hdCByZXNGb3JtYXQgPSBnZXRSZWxldmFudFJlc3BvbnNlRm9ybWF0VW5jZXJ0aWZpZWRSSShub25DZXJ0aWZpZWRSSSwgY29tcG9uZW50LmdldENvbXBvbmVudFR5cGUoKSk7CisgICAgICAgICAgICAgICAgZWl0aGVyUmVzdWx0ID0gRWl0aGVyLnJpZ2h0KHJlc0Zvcm1hdCk7CisgICAgICAgICAgICB9CisKKyAgICAgICAgfQorICAgICAgICByZXR1cm4gZWl0aGVyUmVzdWx0OworICAgIH0KKworICAgIHByaXZhdGUgUmVzcG9uc2VGb3JtYXQgZ2V0UmVsZXZhbnRSZXNwb25zZUZvcm1hdFVuY2VydGlmaWVkUkkoQ29tcG9uZW50SW5zdGFuY2Ugbm9uQ2VydGlmaWVkUkksIENvbXBvbmVudFR5cGVFbnVtIGNvbXBvbmVudFR5cGUpIHsKKworICAgICAgICBFaXRoZXI8UmVzb3VyY2UsIFN0b3JhZ2VPcGVyYXRpb25TdGF0dXM+IGVpdGhlclJlc291cmNlID0gdG9zY2FPcGVyYXRpb25GYWNhZGUuZ2V0VG9zY2FFbGVtZW50KG5vbkNlcnRpZmllZFJJLmdldENvbXBvbmVudFVpZCgpKTsKKyAgICAgICAgaWYgKGVpdGhlclJlc291cmNlLmlzUmlnaHQoKSkgeworICAgICAgICAgICAgcmV0dXJuIGNv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gICAgICAgICAgICAgICAgYWN0aW9uU3RhdHVzID0gQWN0aW9uU3RhdHVzLkZPVU5EX0FMUkVBRFlfVkFMSURBVEVEX1JFU09VUkNFOworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgICAgIHJldHVybiBjb21wb25lbnRVdGlscy5nZXRSZXNwb25zZUZvcm1hdChhY3Rpb25TdGF0dXMsIGNvbXBvbmVudFR5cGUgPT0gQ29tcG9uZW50VHlwZUVudW0uUkVTT1VSQ0UgPyAiVkYiIDogInNlcnZpY2UiLCByZXNvdXJjZS5nZXROYW1lKCkpOworICAgIH0KKworICAgIHByaXZhdGUgdm9pZCBoYW5kbGVWYWxpZGF0aW9uc0FuZEFydGlmYWN0c0dlbmVyYXRpb25CZWZvcmVDZXJ0aWZ5aW5nKENvbXBvbmVudFR5cGVFbnVtIGNvbXBvbmVudFR5cGUsIENvbXBvbmVudCBjb21wb25lbnQsIENvbXBvbmVudEJ1c2luZXNzTG9naWMgY29tcG9uZW50QmwsIFVzZXIgbW9kaWZpZXIsIGJvb2xlYW4gc2hvdWxkTG9jaywgYm9vbGVhbiBpblRyYW5zYWN0aW9uKSB7CisgICAgICAgIGlmIChjb21wb25lbnQuaXNUb3BvbG9neVRlbXBsYXRlKCkpIHsKKyAgICAgICAgICAgIEVpdGhlcjxCb29sZWFuLCBSZXNwb25zZUZvcm1hdD4gc3RhdHVzQ2VydCA9IHZhbGlkYXRlQWxsUmVzb3VyY2VJbnN0YW5jZUNlcnRpZmllZChjb21wb25lbnQpOworICAgICAgICAgICAgaWYgKHN0YXR1c0NlcnQuaXNSaWdodCgpKSB7CisgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEJ5UmVzcG9uc2VGb3JtYXRDb21wb25lbnRFeGNlcHRpb24oc3RhdHVzQ2VydC5yaWdodCgpLnZhbHVlKCkpOworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgICAgIGlmIChjb21wb25lbnRUeXBlID09IENvbXBvbmVudFR5cGVFbnVtLlNFUl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OU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBTREMKLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBDb3B5cmlnaHQgKEMpIDIwMTcgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7Ci0gKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCi0gKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKLSAqIAotICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKLSAqIAotICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZQotICogZGlzdHJpYnV0ZWQgdW5kZXIgdGhlIExpY2Vuc2UgaXMgZGlzdHJpYnV0ZWQgb24gYW4gIkFTIElTIiBCQVNJUywKLSAqIFdJVEhPVVQgV0FSUkFOVElFUyBPUiBDT05ESVRJT05TIE9GIEFOWSBLSU5ELCBlaXRoZXIgZXhwcmVzcyBvciBpbXBsaWVkLgotICogU2VlIHRoZSBMaWNlbnNlIGZvciB0aGUgc3BlY2lmaWMgbGFuZ3VhZ2UgZ292ZXJuaW5nIHBlcm1pc3Npb25zIG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AgICBpZiAobnVsbCAhPSByZXF1aXJlbWVudHNUb0Z1bGZpbGxCZWZvcmVDZXJ0KSB7Ci0gICAgICAgICAgICAgICAgICAgIFNldDxTdHJpbmc+IHJlcVRvRnVsZmlsbEZvclR5cGUgPSByZXF1aXJlbWVudHNUb0Z1bGZpbGxCZWZvcmVDZXJ0LmdldChjb21wSW5zdFR5cGUpOwotICAgICAgICAgICAgICAgICAgICBpZiAocmVxVG9GdWxmaWxsRm9yVHlwZSAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKFN0cmluZyByZXFOYW1lVG9GdWxmaWxsIDogcmVxVG9GdWxmaWxsRm9yVHlwZSkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIExpc3Q8U3RyaW5nPiByZXFOYW1lTGlzdCA9IHJlcU5hbWUySWRzLmdldChyZXFOYW1lVG9GdWxmaWxsKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocmVxTmFtZUxpc3QgPT0gbnVsbCB8fCAhcmVxTmFtZUxpc3QuY29udGFpbnMoY29tcEluc3RJZCkpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJSZXF1aXJlbWVudCB7fSB3YXNuJ3QgZnVsZmlsbGVkIGZvciBjb21wb25lbnQgaW5zdGFuY2Uge30gb2YgdHlwZSB7fSIsIHJlcU5hbWVUb0Z1bGZpbGwsIGNvbXBJbnN0SWQsIGNvbXBJbnN0VHlwZSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbXBvbmVudFR5cGVFbnVtIGNvbXBvbmVudFR5cGUgPSBjb21wb25lbnQuZ2V0Q29tcG9uZW50VHlwZSgpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmcgY29tcFBhcmFtID0gKGNvbXBvbmVudFR5cGUgPT0gQ29tcG9uZW50VHlwZUVudW0uUkVTT1VSQ0UpID8gIlZGIiA6IGNvbXBvbmVudFR5cGUuZ2V0VmFsdWUoKS50b0xvd2VyQ2FzZSgpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBSZXNwb25zZUZvcm1hdCByZXNwb25zZUZvcm1hdCA9IGNvbXBvbmVudFV0aWxzLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5SRVFfQ0FQX05PVF9TQVRJU0ZJRURfQkVGT1JFX0NFUlRJRklDQVRJT04sIGNvbXBvbmVudC5nZXROYW1lKCksIGNvbXBQYXJhbSwgb3JpZ2luVHlwZS5nZXREaXNwbGF5VmFsdWUoKSwgY29tcEluc3QuZ2V0TmFtZSgpLCAicmVxdWlyZW1lbnQiLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlcU5hbWVUb0Z1bGZpbGwsICJmdWxmaWxsZWQiKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChyZXNwb25zZUZvcm1hdCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIC8vIFZhbGlkYXRpbmcgY29uZmlndXJlZCBjYXBhYmlsaXRpZXMgY29uc3VtZWQKLSAgICAgICAgICAgICAgICBpZiAobnVsbCAhPSBjYXBhYmlsaXRpZXNUb0NvbnN1bWVCZWZvcmVDZXJ0KSB7Ci0gICAgICAgICAgICAgICAgICAgIFNldDxTdHJpbmc+IGNhcFRvQ29uc3VtZUZvclR5cGUgPSBjYXBhYmlsaXRpZXNUb0NvbnN1bWVCZWZvcmVDZXJ0LmdldChjb21wSW5zdFR5cGUpOwotICAgICAgICAgICAgICAgICAgICBpZiAoY2FwVG9Db25zdW1lRm9yVHlwZSAhPSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKFN0cmluZyBjYXBOYW1lVG9Db25zdW1lIDogY2FwVG9Db25zdW1lRm9yVHlwZSkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIExpc3Q8U3RyaW5nPiBjYXBOYW1lTGlzdCA9IGNhcE5hbWUySWRzLmdldChjYXBOYW1lVG9Db25zdW1lKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2FwTmFtZUxpc3QgPT0gbnVsbCB8fCAhY2FwTmFtZUxpc3QuY29udGFpbnMoY29tcEluc3RJZCkpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJDYXBhYmlsaXR5IHt9IHdhc24ndCBjb25zdW1lZCBmb3IgY29tcG9uZW50IGluc3RhbmNlIHt9IG9mIHR5cGUge30iLCBjYXBOYW1lVG9Db25zdW1lLCBjb21wSW5zdElkLCBjb21wSW5zdFR5cGUpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb21wb25lbnRUeXBlRW51bSBjb21wb25lbnRUeXBlID0gY29tcG9uZW50LmdldENvbXBvbmVudFR5cGUoKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nIGNvbXBQYXJhbSA9IChjb21wb25lbnRUeXBlID09IENvbXBvbmVudFR5cGVFbnVtLlJFU09VUkNFKSA/ICJWRiIgOiBjb21wb25lbnRUeXBlLmdldFZhbHVlKCkudG9Mb3dlckNhc2UoKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUmVzcG9uc2VGb3JtYXQgcmVzcG9uc2VGb3JtYXQgPSBjb21wb25lbnRVdGlscy5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuUkVRX0NBUF9OT1RfU0FUSVNGSUVEX0JFRk9SRV9DRVJUSUZJQ0FUSU9OLCBjb21wb25lbnQuZ2V0TmFtZSgpLCBjb21wUGFyYW0sIG9yaWdpblR5cGUuZ2V0RGlzcGxheVZhbHVlKCksIGNvbXBJbnN0LmdldE5hbWU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ICAgIHByaXZhdGUgTWFwPFN0cmluZywgTGlmZUN5Y2xlVHJhbnNpdGlvbj4gc3RhdGVUcmFuc2l0aW9uczsKLSAgICBwcml2YXRlIHN0YXRpYyB2b2xhdGlsZSBib29sZWFuIGlzSW5pdGlhbGl6ZWQgPSBmYWxzZTsKIAogICAgIEBQb3N0Q29uc3RydWN0CiAgICAgcHVibGljIHZvaWQgaW5pdCgpIHsKLSAgICAgICAgLy8gaW5pdCBwYXJhbWV0ZXJzCi0gICAgICAgIGlmICghaXNJbml0aWFsaXplZCkgewotICAgICAgICAgICAgc3luY2hyb25pemVkICh0aGlzKSB7Ci0gICAgICAgICAgICAgICAgaWYgKCFpc0luaXRpYWxpemVkKSB7Ci0gICAgICAgICAgICAgICAgICAgIGluaXRTdGF0ZU9wZXJhdGlvbnMoKTsKLSAgICAgICAgICAgICAgICAgICAgaXNJbml0aWFsaXplZCA9IHRydWU7Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgfQotICAgICAgICB9CisgICAgICAgaW5pdFN0YXRlT3BlcmF0aW9ucygpOwogICAgIH0KIAogICAgIHByaXZhdGUgdm9pZCBpbml0U3RhdGVPcGVyYXRpb25zKCkgewpAQCAtMTI4LDQyICsxMjUsMjEgQEAKICAgICAgICAgICAgIGphbnVzR3JhcGhEYW8pOwogICAgICAgICBzdGF0ZVRyYW5zaXRpb25zLnB1dChjaGVja291dE9wLmdldE5hbWUoKS5uYW1lKCksIGNoZWNrb3V0T3ApOwogCi0gICAgICAgIFVuZG9DaGVja291dFRyYW5zaXRpb24gdW5kb0NoZWNrb3V0T3AgPSBuZXcgVW5kb0NoZWNrb3V0VHJhbnNpdGlvbihjb21wb25lbnRVdGlscywgbGlmZWN5Y2xlT3BlcmF0aW9uLCB0b3NjYU9wZXJhdGlvbkZhY2FkZSwKLSAgICAgICAgICAgIGphbnVzR3JhcGhEYW8pOworICAgICAgICBVbmRvQ2hlY2tvdXRUcmFuc2l0aW9uIHVuZG9DaGVja291dE9wID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ZENvbnRlbnRFcnJvckFuZEF1ZGl0KG1vZGlmaWVyLCBjb21wb25lbnRJZCwgQXVkaXRpbmdBY3Rpb25FbnVtLkNIRUNLT1VUX1JFU09VUkNFKTsKICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQoZXJyb3IpOwogICAgICAgICB9Ci0gICAgICAgIENvbXBvbmVudCBjb21wb25lbnQgPSBudWxsOworICAgICAgICBDb21wb25lbnQgY29tcG9uZW50OwogICAgICAgICBsb2cuZGVidWcoImdldCByZXNvdXJjZSBmcm9tIGdyYXBoIik7CiAgICAgICAgIFJlc3BvbnNlRm9ybWF0IGVycm9yUmVzcG9uc2U7CiAKQEAgLTIwNSw5ICsxODEsMTAgQEAKICAgICAgICAgLy8gbG9jayByZXNvdXJjZQogICAgICAgICBpZiAoIWluVHJhbnNhY3Rpb24gJiYgbmVlZExvY2spIHsKICAgICAgICAgICAgIGxvZy5kZWJ1ZygibG9jayBjb21wb25lbnQge30iLCBjb21wb25lbnRJZCk7Ci0gICAgICAgICAgICBFaXRoZXI8Qm9vbGVhbiwgUmVzcG9uc2VGb3JtYXQ+IGVpdGhlckxvY2tSZXNvdXJjZSA9IGxvY2tDb21wb25lbnQoY29tcG9uZW50VHlwZSwgY29tcG9uZW50KTsKLSAgICAgICAgICAgIGlmIChlaXRoZXJMb2NrUmVzb3VyY2UuaXNSaWdodCgpKSB7Ci0gICAgICAgICAgICAgICAgZXJyb3JSZXNwb25zZSA9IGVpdGhlckxvY2tSZXNvdXJjZS5yaWdodCgpLnZhbHVlKCk7CisgICAgICAgICAgICB0cnkgeworICAgICAgICAgICAgICAgIGxvY2tDb21wb25lbnQoY29tcG9uZW50VHlwZSwgY29tcG9uZW50KTsKKyAgICAgICAgICAgIH1jYXRjaCAoQ29tcG9uZW50RXhjZXB0aW9uIGUpeworICAgICAgICAgICAgICAgIGVycm9yUmVzcG9uc2UgPSBlLmdldFJlc3BvbnNlRm9ybWF0KCk7CiAgICAgICAgICAgICAgICAgY29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CgpLnZhbHVlKCk7CisgICAgICAgICAgICBmaW5hbCBDb21wb25lbnQgb2xkQ29tcG9uZW50ID0gY29tcG9uZW50OworICAgICAgICAgICAgRWl0aGVyPD8gZXh0ZW5kcyBDb21wb25lbnQsIFJlc3BvbnNlRm9ybWF0PiBjaGVja2VkSW5Db21wb25lbnRFaXRoZXIgPSBjaGVja0luQmVmb3JlQ2VydGlmeUlmTmVlZGVkKGNvbXBvbmVudFR5cGUsIG1vZGlmaWVyLCB0cmFuc2l0aW9uRW51bSwgY2hhbmdlSW5mbywgaW5UcmFuc2FjdGlvbiwgY29tcG9uZW50KTsKKyAgICAgICAgICAgIGlmKGNoZWNrZWRJbkNvbXBvbmVudEVpdGhlci5pc1JpZ2h0KCkpIHsKKyAgICAgICAgICAgICAgICByZXR1cm4gRWl0aGVyLnJpZ2h0KGNoZWNrZWRJbkNvbXBvbmVudEVpdGhlci5yaWdodCgpLnZhbHVlKCkpOwogICAgICAgICAgICAgfQotICAgICAgICAgICAgcmV0dXJuIGNoYW5nZVN0YXRlKGNvbXBvbmVudCwgbGlmZUN5Y2xlVHJhbnNpdGlvbiwgY29tcG9uZW50VHlwZSwgbW9kaWZpZXIsIGNoYW5nZUluZm8sIGluVHJhbnNhY3Rpb24pOworICAgICAgICAgICAgY29tcG9uZW50ID0gY2hlY2tlZEluQ29tcG9uZW50RWl0aGVyLmxlZnQoKS52YWx1ZSgpOworICAgICAgICAgICAgcmV0dXJuIGNoYW5nZVN0YXRlKGNvbXBvbmVudCwgbGlmZUN5Y2xlVHJhbnNpdGlvbiwgY29tcG9uZW50VHlwZSwgbW9kaWZpZXIsIGNoYW5nZUluZm8sIGluVHJhbnNhY3Rpb24pCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmxlZnQoKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5iaW5kKGMgLT4gdXBkYXRlQ2F0YWxvZyhjLCBvbGRDb21wb25lbnQsIENoYW5n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XR1cy5OT1RfQUxMT1dFRCkpOworICAgICAgICAgICAgdGhyb3cgbmV3IEJ5QWN0aW9uU3RhdHVzQ29tcG9uZW50RXhjZXB0aW9uKEFjdGlvblN0YXR1cy5OT1RfQUxMT1dFRCk7CiAgICAgICAgIH0KICAgICAgICAgLy8gbG9jayByZXNvdXJjZQotICAgICAgICBpZiAocmVzdWx0ID09IG51bGwgJiYgIWluVHJhbnNhY3Rpb24gJiYgbmVlZExvY2spIHsKKyAgICAgICAgaWYgKCFpblRyYW5zYWN0aW9uICYmIG5lZWRMb2NrKSB7CiAgICAgICAgICAgICBsb2cuaW5mbygibG9jayBjb21wb25lbnQge30iLCByZXNvdXJjZS5nZXRVbmlxdWVJZCgpKTsKLSAgICAgICAgICAgIEVpdGhlcjxCb29sZWFuLCBSZXNwb25zZUZvcm1hdD4gZWl0aGVyTG9ja1Jlc291cmNlID0gbG9ja0NvbXBvbmVudChyZXNvdXJjZS5nZXRDb21wb25lbnRUeXBlKCksIHJlc291cmNlKTsKLSAgICAgICAgICAgIGlmIChlaXRoZXJMb2NrUmVzb3VyY2UuaXNSaWdodCgpKSB7Ci0gICAgICAgICAgICAgICAgbG9nLmVycm9yKCJsb2NrIGNvbXBvbmVudCB7fSBmYWlsZWQiLCByZXNvdXJjZS5nZXRVbmlxdWVJZCgpKTsKLSAgICAgICAgICAgICAgICByZXN1bHQgPSBFaXRoZXIucmlnaHQoZWl0aGVyTG9ja1Jlc291cmNlLnJpZ2h0KCkudmFsdWUoKSk7Ci0gICAgICAgICAgICB9CisgICAgICAgICAgICBsb2NrQ29tcG9uZW50KHJlc291cmNlLmdldENvbXBvbmVudFR5cGUoKSwgcmVzb3VyY2UpOwogICAgICAgICAgICAgbG9nLmluZm8oImFmdGVyIGxvY2sgY29tcG9uZW50IHt9IiwgcmVzb3VyY2UuZ2V0VW5pcXVlSWQoKSk7CiAgICAgICAgIH0KICAgICAgICAgdHJ5IHsKLSAgICAgICAgICAgIGlmIChyZXN1bHQgPT0gb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29tcG9uZW50cy9saWZlY3ljbGUvU3RhcnRDZXJ0aWZpY2F0aW9uVHJhbnNpdGlvbi5qYXZhCisrKyAvZGV2L251bGwKQEAgLTEsMTQxICswLDAgQEAKLS8qLQotICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIFNEQwotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIENvcHlyaWdodCAoQykgMjAxNyBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKLSAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KLSAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAotICogCi0gKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAotICogCi0gKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlCi0gKiBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0cmlidXRlZCBvbiBhbiAiQVMgSVMiIEJBU0lTLAotICogV0lUSE9VVCBXQVJSQU5USUVTIE9SIENPTkRJVElPTlMgT0YgQU5ZIEtJT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lbnRUeXBlKTsKLSAgICAgICAgICAgICAgICByZXN1bHQgPSAgRWl0aGVyLnJpZ2h0KHJlc3BvbnNlRm9ybWF0KTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGVsc2UgewotICAgICAgICAgICAgICAgIHJlc3VsdCA9ICBFaXRoZXIubGVmdChNb2RlbENvbnZlcnRlci5jb252ZXJ0RnJvbVRvc2NhRWxlbWVudChzdGF0ZUNoYW5nZVJlc3VsdC5sZWZ0KCkudmFsdWUoKSkpOwotICAgICAgICAgICAgfQotICAgICAgICB9IGZpbmFsbHkgewotICAgICAgICAgICAgaWYgKHJlc3VsdCA9PSBudWxsIHx8IHJlc3VsdC5pc1JpZ2h0KCkpIHsKLSAgICAgICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nQmVEYW9TeXN0ZW1FcnJvcigiQ2hhbmdlIExpZmVjeWNsZVN0YXRlIik7Ci0gICAgICAgICAgICAgICAgaWYgKCFpblRyYW5zYWN0aW9uKSB7Ci0gICAgICAgICAgICAgICAgICAgIGxvZy5kZWJ1Zygib3BlcmF0aW9uIGZhaWxlZC4gZG8gcm9sbGJhY2siKTsKLSAgICAgICAgICAgICAgICAgICAgamFudXNHcmFwaERhby5yb2xsYmFjaygpOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgaWYgKCFpblRyYW5zYWN0aW9uKSB7Ci0gICAgICAgICAgICAgICAgICAgIGxvZy5kZWJ1Zygib3BlcmF0aW9uIHN1Y2Nlc3MuIGRvIGNvbW1pdCIpOwotICAgICAgICAgICAgICAgICAgICBqYW51c0dyYXBoRGFvLmNvbW1pdCgpOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIH0KLSAgICAgICAgfQotICAgICAgICByZXR1cm4gcmVzdWx0OwotICAgIH0KLQotICAgIEBPdmVycmlkZQotICAgIHB1YmxpYyBFaXRoZXI8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AQCAtMTEwLDcgKzExOCwxNCBAQAogICAgICAgICAgICAgICAgIHJlc3VsdCA9ICBFaXRoZXIucmlnaHQocmVzcG9uc2VGb3JtYXQpOwogICAgICAgICAgICAgfQogICAgICAgICAgICAgZWxzZSB7Ci0gICAgICAgICAgICAgICAgcmVzdWx0ID0gIEVpdGhlci5sZWZ0KE1vZGVsQ29udmVydGVyLmNvbnZlcnRGcm9tVG9zY2FFbGVtZW50KHVuZG9DaGVja291dFJlc291cmNlUmVzdWx0LmxlZnQoKS52YWx1ZSgpKSk7CisgICAgICAgICAgICAgICAgVG9zY2FFbGVtZW50IGVsZW1lbnQgPSB1bmRvQ2hlY2tvdXRSZXNvdXJjZVJlc3VsdC5sZWZ0KCkudmFsdWUoKTsKKyAgICAgICAgICAgICAgICBpZihlbGVtZW50ID09IG51bGwpeyAKKyAgICAgICAgICAgICAgICAgICAgY2F0YWxvZ09wZXJhdGlvbnMudXBkYXRlQ2F0YWxvZyhDaGFuZ2VUeXBlRW51bS5ERUxFVEUsIGNvbXBvbmVudCk7CisgICAgICAgICAgICAgICAgICAgIHJlc3VsdCA9IEVpdGhlci5sZWZ0KG51bGwpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBlbHNleworICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSAgRWl0aGVyLmxlZnQoTW9kZWxDb252ZXJ0ZXIuY29udmVydEZyb21Ub3NjYUVsZW1lbnQoZWxlbWVudCkpOworICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KICAgICAgICAgfSBmaW5hbGx5IHsKICAgICAgICAgICAgIGlmIChyZXN1bHQgPT0gbnVsbCB8fCByZXN1bHQuaXNSaWdodCgpKSB7CkBAIC0xMjQsNSArMTM5LDYgQEAKICAgICAgICAgfQogICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgIH0KKyAgICAKIAogfQpkaWZmIC0tZ2l0IGEvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVu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IAogaW1wb3J0IHN0YXRpYyBvcmcub3BlbmVjb21wLnNkYy5iZS51dGlscy5Qcm9wZXJ0eURlZmluaXRpb25VdGlscy5yZXNvbHZlR2V0SW5wdXRQcm9wZXJ0aWVzOwpAQCAtODgsNiArODgsNyBAQAogICAgICAgICBMaXN0PElucHV0RGVmaW5pdGlvbj4gaW5wdXRzRm9yUmVkZWNsYXJhdGlvbiA9IHJlZGVjbGFyZUlucHV0RGF0YS5kZWNsYXJlZElucHV0SWRzLnN0cmVhbSgpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5maWx0ZXIob2xkSW5wdXRzQnlJZDo6Y29udGFpbnNLZXkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5tYXAob2xkSW5wdXRzQnlJZDo6Z2V0KQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZmlsdGVyKE9iamVjdHM6Om5vbk51bGwpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5tYXAoSW5wdXREZWZpbml0aW9uOjpuZXcpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5jb2xsZWN0KENvbGxlY3RvcnMudG9MaXN0KCkpOwogICAgICAgICAKZGlmZiAtLWdpdCBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jb21wb25lbnRzL21lcmdlL2lucHV0L0dsb2JhbElucHV0c01lcmdlQ29tbWFuZC5qYXZhIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2NvbXBvbmVudHMvbWVyZ2UvaW5wdXQvR2xvYmFsSW5wdXRzTWVyZ2VDb21tYW5kLmphdmEKaW5kZXggMzMwM2ZlNS4uOTFjNmZmMCAxMDA2NDQKLS0tIGEvY2F0YWxvZy1iZS9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udCk7CkBAIC03Miw2ICs3NSwxNCBAQAogICAgICAgICByZXR1cm4gaW5wdXRzVG9NZXJnZTsKICAgICB9CiAKKyAgICBwcml2YXRlIExpc3Q8SW5wdXREZWZpbml0aW9uPiBnZXRVbmlxdWVQcmV2aW91c2x5RGVjbGFyZWRJbnB1dHNUb01lcmdlKENvbXBvbmVudCBwcmV2Q29tcG9uZW50LCBDb21wb25lbnQgY3VyckNvbXBvbmVudCwgTGlzdDxJbnB1dERlZmluaXRpb24+IG1lcmdlZElucHV0cykgeworICAgICAgICBMaXN0PElucHV0RGVmaW5pdGlvbj4gcHJldmlvdXNseURlY2xhcmVkSW5wdXRzVG9NZXJnZSA9IGdldFByZXZpb3VzbHlEZWNsYXJlZElucHV0c1RvTWVyZ2UocHJldkNvbXBvbmVudCwgY3VyckNvbXBvbmVudCk7CisgICAgICAgIHJldHVybiBwcmV2aW91c2x5RGVjbGFyZWRJbnB1dHNUb01lcmdlLnN0cmVhbSgpCisgICAgICAgICAgICAgICAgLmZpbHRlcihwcmV2IC0+IG1lcmdlZElucHV0cy5zdHJlYW0oKQorICAgICAgICAgICAgICAgICAgICAgICAgLm5vbmVNYXRjaChtZXJnZWQgLT4gbWVyZ2VkLmdldE5hbWUoKS5lcXVhbHMocHJldi5nZXROYW1lKCkpKSkuY29sbGVjdChDb2xsZWN0b3JzLnRvTGlzdCgpKTsKKyAgICB9CisKKwogICAgIHByaXZhdGUgTGlzdDxJbnB1dERlZmluaXRpb24+IGdldFByZXZpb3VzbHlEZWNsYXJlZElucHV0c1RvTWVyZ2UoQ29tcG9uZW50IHByZXZDb21wb25lbnQsIENvbXBvbmVudCBjdXJyQ29tcG9uZW50KSB7CiAgICAgICAgIGxvZy5kZWJ1ZygiI2dldFByZXZpb3VzbHlEZWNsYXJlZElucHV0c1RvTWVyZ2UgLSBnZXR0aW5nIGlucHV0cyB0aGF0IHdlcmUgcHJldmlvdXNseSBkZWNsYXJlZCBmcm9tIHByZXZpb3VzIGNvbXBvbm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AgICAgIHJldHVybiBFaXRoZXIucmlnaHQodXBsb2FkQXJ0aWZhY3RUb1NlcnZpY2UucmlnaHQoKS52YWx1ZSgpKTsKLSAgICAgICAgICAgIH0KICAgICAgICAgfQotICAgICAgICByZXR1cm4gRWl0aGVyLmxlZnQodXBkYXRlZENvbnRhaW5lckNvbXBvbmVudCk7CisgICAgICAgIHJldHVybiB1cGRhdGVkQ29udGFpbmVyQ29tcG9uZW50OworICAgIH0KKworICAgIHByaXZhdGUgTWFwPFN0cmluZywgQXJ0aWZhY3REZWZpbml0aW9uPiBnZXRVcGRhdGVkVGltZU91dERlcGxveW1lbnRBcnRpZmFjdHMoRGF0YUZvck1lcmdlSG9sZGVyIGRhdGFIb2xkZXIsIE1hcDxTdHJpbmcsIEFydGlmYWN0RGVmaW5pdGlvbj4gY3VycmVudEluc3RhbmNlRGVwbG95bWVudEFydGlmYWN0cykgeworICAgICAgICByZXR1cm4gY3VycmVudEluc3RhbmNlRGVwbG95bWVudEFydGlmYWN0cy5lbnRyeVNldCgpLnN0cmVhbSgpCisgICAgICAgICAgICAgICAgLmZpbHRlcihhcnRpZmFjdCAtPiBPYmplY3RzLmlzTnVsbChhcnRpZmFjdC5nZXRWYWx1ZSgpLmdldFRpbWVvdXQoKSkgfHwgIWFydGlmYWN0LmdldFZhbHVlKCkuZ2V0VGltZW91dCgpCisgICAgICAgICAgICAgICAgICAgICAgICAuZXF1YWxzKGRhdGFIb2xkZXIuZ2V0Q29tcG9uZW50SW5zdGFuY2VEZXBsb3ltZW50QXJ0aWZhY3RzVGltZU91dCgpLmdldChhcnRpZmFjdC5nZXRLZXkoKSkpKQorICAgICAgICAgICAgICAgIC5jb2xsZWN0KENvbGxlY3RvcnMudG9NYXAoTWFwLkVudHJ5OjpnZXRLZXksIGFydGlmYWN0IC0+IG1lcmdlVGltZU91dChhcnRpZmFjdC5nZXRWYWx1ZSgpLCBkYXRhSG9sZGVyCisgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0Q29tcG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WxpdHlSZWxEZWY+IGdldFVwZGF0ZWRDYXBSZXFEZWZzKFJlc291cmNlIG9sZFJlc291cmNlLAorICAgIHByaXZhdGUgTGlzdDxSZXF1aXJlbWVudENhcGFiaWxpdHlSZWxEZWY+IGdldFVwZGF0ZWRDYXBSZXFEZWZzKENvbXBvbmVudCBvbGRSZXNvdXJjZSwgQ29tcG9uZW50IG5ld0NvbXBvbmVudCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNYXA8U3RyaW5nLCBDb21wb25lbnRJbnN0YW5jZT4gbWFwT2xkQ29tcG9uZW50SW5zdGFuY2VzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1hcDxTdHJpbmcsIENvbXBvbmVudEluc3RhbmNlPiBtYXBOZXdDb21wb25lbnRJbnN0YW5jZXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUHJlZGljYXRlPD8gc3VwZXIgUmVxdWlyZW1lbnRDYXBhYmlsaXR5UmVsRGVmPiBmaWx0ZXIpIHsKQEAgLTI5MCw5ICszMDEsMzYgQEAKICAgICAgICAgICAgICAgICAgICAgICAgIC5tYXAocmVsIC0+IGNyZWF0ZVJlbGF0aW9uTWVyZ2VJbmZvUGFpcihyZWwsIG1hcE9sZENvbXBvbmVudEluc3RhbmNlcykpCiAgICAgICAgICAgICAgICAgICAgICAgICAubWFwKGluZm9QYWlyIC0+IHJlc3RvcmVSZXF1aXJlbWVudENhcGFiaWxpdHlSZWxEZWYoaW5mb1BhaXIsIG1hcE5ld0NvbXBvbmVudEluc3RhbmNlcykpCiAgICAgICAgICAgICAgICAgICAgICAgICAuZmlsdGVyKE9iamVjdHM6Om5vbk51bGwpCisgICAgICAgICAgICAgICAgICAgICAgICAuZmlsdGVyKHItPiBjYXBSZXFNYXRjaEV4aXN0KHIsIG5ld0NvbXBvbmVudCkpCiAgICAgICAgICAgICAgICAgICAgICAgICAuY29sbGVjdChDb2xsZWN0b3JzLnRvTGlzdCgpKTsKICAgICB9CiAKKworICAgIHByaXZhdGUgYm9vbGVhbiBjYXBSZXFNYXRjaEV4aXN0KFJlcXVpcmVtZW50Q2FwYWJpbGl0eVJlbERlZiByZWwsIENvbXBvbmVudCBjdXJyZW50Q29tcG9uZW50KSB7CisgICAgICAgIHJldHVybiBjdXJyZW50Q29tcG9uZW50LmdldENvbXBvbmVudEluc3RhbmNlcygpLnN0cmVhbSgpCisgICAgICAgICAgICAgICAgICAgIC5hbnlNYXRjaChpLT5pc0Zyb21JbnN0YW5jZShpLCByZWwpKSAmJgorICAgICAgICAgICAgICAgIGN1cnJlbnRDb21wb25lbnQuZ2V0Q29tcG9uZW50SW5zdGFuY2VzKCkuc3RyZWFtKCkKKyAgICAgICAgICAgICAgICAgICAgLmFueU1hdGNoKGktPmlzVG9JbnN0YW5jZShpLCByZWwpKTsKKyAgICB9CisKKyAgICBwcml2YXRlIGJvb2xlYW4gaXNUb0luc3RhbmNlKENvbXBvbmVudEluc3RhbmNlIGluc3QsIFJlcXVpcmVtZW50Q2FwYWJpbGl0eVJlbERlZiByZWwpIHsKKyAgICAgICAgcmV0dXJuIGluc3QuZ2V0VW5pcXVlSWQoKS5lcXVhbHMocmVsLmdldFRvTm9kZSgpKSAmJgorICAgICAgICAgICAgICAgIGluc3QuZ2V0Q2FwYWJpbGl0aWVzKCkudmFsdWVzKCkKKyAgICAgICAgICAgICAgICAgICAgICAgIC5zdHJlYW0oKQorICAgICAgICAgICAgICAgICAgICAgICAgLmZsYXRNYXAoQ29sbGVjdGlvbjo6c3RyZWFtKQorICAgICAgICAgICAgICAgICAgICAgICAgLmFueU1hdGNoKGNhcC0+Y2FwLmdldE5hbWUoKS5lcXVhbHMocmVsLnJlc29sdmVTaW5nbGVSZWxhdGlvbnNoaXAoKS5nZXRSZWxhdG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fTEVOR1RIID0gMjAwOwogICAgIHByaXZhdGUgc3RhdGljIGZpbmFsIGludCAgREVTVElOQVRJT05fUE9SVF9MRU5HVEggPSAyMDA7CiAKLSAgICBwdWJsaWMgRWl0aGVyPEJvb2xlYW4sIFJlc3BvbnNlRm9ybWF0PiB2YWxpZGF0ZUZvcndhcmRpbmdQYXRocyhDb2xsZWN0aW9uPEZvcndhcmRpbmdQYXRoRGF0YURlZmluaXRpb24+IHBhdGhzLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZyBzZXJ2aWNlSWQsIGJvb2xlYW4gaXNVcGRhdGUpIHsKKyAgICBwdWJsaWMgdm9pZCB2YWxpZGF0ZUZvcndhcmRpbmdQYXRocyhDb2xsZWN0aW9uPEZvcndhcmRpbmdQYXRoRGF0YURlZmluaXRpb24+IHBhdGhzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZyBzZXJ2aWNlSWQsIGJvb2xlYW4gaXNVcGRhdGUpIHsKICAgICAgICAgZm9yIChGb3J3YXJkaW5nUGF0aERhdGFEZWZpbml0aW9uIHBhdGggOiBwYXRocykgewotICAgICAgICAgICAgRWl0aGVyPEJvb2xlYW4sIFJlc3BvbnNlRm9ybWF0PiBmb3J3YXJkaW5nUGF0aFJlc3BvbnNlRWl0aGVyID0gdmFsaWRhdGVGb3J3YXJkaW5nUGF0aChwYXRoLAotICAgICAgICAgICAgICAgICAgICBzZXJ2aWNlSWQsIGlzVXBkYXRlKTsKLSAgICAgICAgICAgIGlmIChmb3J3YXJkaW5nUGF0aFJlc3BvbnNlRWl0aGVyLmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgIHJldHVybiBmb3J3YXJkaW5nUGF0aFJlc3BvbnNlRWl0aGVyOwotICAgICAgICAgICAgfQorICAgICAgICAgICAgdmFsaWRhdGVGb3J3YXJkaW5nUGF0aChwYXRoLCBzZXJ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5pdGlvbi5nZXREZXN0aW5hdGlvblBvcnROdW1iZXIoKSAhPSBudWxsICYmCiAgICAgICAgICAgICBkYXRhRGVmaW5pdGlvbi5nZXREZXN0aW5hdGlvblBvcnROdW1iZXIoKS5sZW5ndGgoKSA+IERFU1RJTkFUSU9OX1BPUlRfTEVOR1RIICkgewogICAgICAgICAgICAgbG9nZ2VyLmRlYnVnKCJGb3J3YXJkaW5nIHBhdGggZGVzdGluYXRpb24gcG9ydCB7fSB0b28gbG9uZywgLCBtYXhpbXVtIGFsbG93ZWQgMjAwIGNoYXJhY3RlcnMgIiwKICAgICAgICAgICAgICAgICAgICAgZGF0YURlZmluaXRpb24uZ2V0RGVzdGluYXRpb25Qb3J0TnVtYmVyKCkpOwotICAgICAgICAgICAgUmVzcG9uc2VGb3JtYXQgZXJyb3JSZXNwb25zZSA9IHJlc3BvbnNlRm9ybWF0TWFuYWdlci5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMKKyAgICAgICAgICAgIHRocm93IG5ldyBCeUFjdGlvblN0YXR1c0NvbXBvbmVudEV4Y2VwdGlvbihBY3Rpb25TdGF0dXMKICAgICAgICAgICAgICAgICAgICAgLkZPUldBUkRJTkdfUEFUSF9ERVNUSU5BVElPTl9QT1JUX01BWElNVU1fTEVOR1RILCBkYXRhRGVmaW5pdGlvbi5nZXREZXN0aW5hdGlvblBvcnROdW1iZXIoKSk7Ci0gICAgICAgICAgICByZXR1cm4gRWl0aGVyLnJpZ2h0KGVycm9yUmVzcG9uc2UpOwogICAgICAgICB9Ci0gICAgICAgIHJldHVybiBudWxsOwogICAgIH0KIAotICAgIHByaXZhdGUgRWl0aGVyPEJvb2xlYW4sIFJlc3BvbnNlRm9ybWF0PiB2YWxpZGF0ZVByb3RvY29sKEZvcndhcmRpbmdQYXRoRGF0YURlZmluaXRpb24gZGF0YURlZmluaXRpb24sCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA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bGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uODUzNzBkMgotLS0gL2Rldi9udWxsCisrKyBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jb21wb25lbnRzL3Byb3BlcnR5L1Byb3BlcnR5Q29uc3RyYWludHNVdGlscy5qYXZhCkBAIC0wLDAgKzEsNzUgQEAKKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAyMCBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKKyAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KKyAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAorICoKKyAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wCisgKgorICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZQorICogZGlzdHJpYnV0ZWQgdW5kZXIgdGhlIExpY2Vuc2UgaXM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WMgamF2YS51dGlsLk9iamVjdHMubm9uTnVsbDsKK2ltcG9ydCBzdGF0aWMgamF2YS51dGlsLnN0cmVhbS5Db2xsZWN0b3JzLnRvTWFwOworCisvKioKKyAqIFByb3ZpZGVzIHNwZWNpZmljIGZ1bmN0aW9uYWxpdHkgZm9yIHByb3BlcnR5IGNvbnN0cmFpbnRzCisgKi8KK3B1YmxpYyBjbGFzcyBQcm9wZXJ0eUNvbnN0cmFpbnRzVXRpbHMgeworCisgICAgcHJpdmF0ZSBQcm9wZXJ0eUNvbnN0cmFpbnRzVXRpbHMoKXt9CisKKyAgICBwdWJsaWMgc3RhdGljIHZvaWQgdmFsaWRhdGVQcm9wZXJ0aWVzQ29uc3RyYWludHMoUmVzb3VyY2UgbmV3UmVzb3VyY2UsIFJlc291cmNlIG9sZFJlc291cmNlKSB7CisgICAgICAgIGlmKG9sZFJlc291cmNlLmdldFByb3BlcnRpZXMoKSAhPSBudWxsICYmIG5ld1Jlc291cmNlLmdldFByb3BlcnRpZXMoKSAhPSBudWxsKXsKKyAgICAgICAgICAgIE1hcDxTdHJpbmcsIFByb3BlcnR5RGVmaW5pdGlvbj4gb2xkUHJvcFdpdGhDb25zdHJhaW50cyA9IG9sZFJlc291cmNlLmdldFByb3BlcnRpZXMoKQorICAgICAgICAgICAgICAgICAgICAuc3RyZWFtKCkKKyAgICAgICAgICAgICAgICAgICAgLmZpbHRlcihwIC0+IHAuZ2V0Q29uc3RyYWludHMoKSAhPSBudWxsKQorICAgICAgICAgICAgICAgICAgICAuY29sbGVjdCh0b01hcChQcm9wZXJ0eURlZmluaXRpb246OmdldE5hbWUscCAtPiBwKSk7CisKKyAgICAgICAgICAgIG5ld1Jlc291cmNlLmdldFByb3BlcnRpZXMoKQorICAgICAgICAgICAgICAgICAgICAuc3RyZWFtKCkKKyAgICAgICAgICAgICAgICAgICAgLmZpbHRlcihwIC0+IHAuZ2V0Q29uc3RyYWludHMoKSAhPSBudWxsICYmIG9sZFByb3BXaXRoQ29uc3RyYWludHMuY29udGFpbnNLZXkocC5nZXROYW1lKCkpKQorICAgICAgICAgICAgICAgICAgICAuZm9yRWFjaChwIC0+IHZhbGlkYXRlUHJvcGVydHlDb25zdHJhaW50cyhwLmdldENvbnN0cmFpbnRzKCksIG9sZFByb3BXaXRoQ29uc3RyYWludHMuZ2V0KHAuZ2V0TmFtZSgpKS5nZXRDb25zdHJhaW50cygpKSk7CisgICAgICAgIH0KKyAgICB9CisKKyAgICBwcml2YXRlIHN0YXRpYyB2b2lkIHZhbGlkYXRlUHJvcGVydHlDb25zdHJhaW50cyhMaXN0PFByb3BlcnR5Q29uc3RyYWludD4gbmV3Q29uc3RyYWludHMsIExpc3Q8UHJvcGVydHlDb25zdHJhaW50PiBvbGRDb25zdHJhaW50cykgeworICAgICAgICBNYXAgPENvbnN0cmFpbnRUeXBlLCBQcm9wZXJ0eUNvbnN0cmFpbnQ+IG9sZENvbnN0cmFpbnRzQnlUeXBlID0gb2xkQ29uc3RyYWludHMuc3RyZWFtKCkKKyAgICAgICAgICAgICAgICAuZmlsdGVyKGMgLT4gbm9uTnVsbChjKSAmJiBub25OdWxsKGMuZ2V0Q29uc3RyYWludFR5cGUoKSkpCisgICAgICAgICAgICAgICAgLmNvbGxlY3QodG9NYXAoUHJvcGVydHlDb25zdHJhaW50OjpnZXRDb25zdHJhaW50VHlwZSwgYyAtPiBjKSk7CisKKyAgICAgICAgbmV3Q29uc3RyYWludHMuc3RyZWFtKCkKKyAgICAgICAgICAgICAgICAuZmlsdGVyKGMgLT4gbm9uTnVsbChjKSAmJiBvbGRDb25zdHJhaW50c0J5VHlwZS5jb250YWluc0tleShjLmdldENvbnN0cmFpbnRUeXBlKCkpKQorICAgICAgICAgICAgICAgIC5mb3JFYWNoKGMgLT4gdmFsaWRhdGVQcm9wZXJ0eUNvbnN0cmFpbnQoYywgb2xkQ29uc3RyYWludHNCeVR5cGUuZ2V0KGMuZ2V0Q29uc3RyYWludFR5cGUoKSkpKTsKKyAgICB9CisKK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KCkKKyAgICAgICAgICAgICAgICAuZmlsdGVyKGUgLT4gZS5nZXRLZXkoKS5lcXVhbHMob3duZXJJZCkpCisgICAgICAgICAgICAgICAgLm1hcChNYXAuRW50cnk6OmdldFZhbHVlKQorICAgICAgICAgICAgICAgIC5maW5kRmlyc3QoKTsKKyAgICAgICAgaWYocHJvcGVydGllc09wdC5pc1ByZXNlbnQoKSl7CisgICAgICAgICAgICBNYXA8U3RyaW5nLCBQcm9wZXJ0eURhdGFEZWZpbml0aW9uPiBpbnN0UHJvcHMgPSBwcm9wZXJ0aWVzT3B0LmdldCgpCisgICAgICAgICAgICAgICAgICAgIC5zdHJlYW0oKQorICAgICAgICAgICAgICAgICAgICAuY29sbGVjdChDb2xsZWN0b3JzLnRvTWFwKFByb3BlcnR5RGF0YURlZmluaXRpb246OmdldE5hbWUsIHAtPnApKTsKKyAgICAgICAgICAgIGlucHV0cy5zdHJlYW0oKQorICAgICAgICAgICAgICAgICAgICAuZmlsdGVyKGktPmluc3RQcm9wcy5jb250YWluc0tleShpLmdldE5hbWUoKSkpCisgICAgICAgICAgICAgICAgICAgIC5mb3JFYWNoKGktPnVwZGF0ZVByb3BDb25zdHJhaW50cyhpLCBpbnN0UHJvcHMuZ2V0KGkuZ2V0TmFtZSgpKSkpOworCisgICAgICAgIH0KKyAgICB9CisKKyAgICBwcml2YXRlIHZvaWQgdXBkYXRlUHJvcENvbnN0cmFpbnRzKFByb3BlcnR5RGF0YURlZmluaXRpb24gaW5wdXQsIFByb3BlcnR5RGF0YURlZmluaXRpb24gcHJvcGVydHkpIHsKKyAgICAgICAgaWYoQ29sbGVjdGlvblV0aWxzLmlzTm90RW1wdHkocHJvcGVydHkuZ2V0UHJvcGVydHlDb25zdHJhaW50cygpKSl7CisgICAgICAgICAgICBpbnB1dC5zZXRQcm9wZXJ0eUNvbnN0cmFpbnRzKHByb3BlcnR5LmdldFByb3BlcnR5Q29uc3RyYWludHMoKSk7CisgICAgICAgIH0gZWxzZSBpZihwcm9w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uIHZhbGlkYXRlVXNlckV4aXN0cyh1c2VyLmdldFVzZXJJZCgpKTsKIAl9CiAKKwogfQpkaWZmIC0tZ2l0IGEvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2NvbXBvbmVudHMvdmFsaWRhdGlvbi9jb21wb25lbnQvQ29tcG9uZW50Q29udGFjdElkVmFsaWRhdG9yLmphdmEgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvY29tcG9uZW50cy92YWxpZGF0aW9uL2NvbXBvbmVudC9Db21wb25lbnRDb250YWN0SWRWYWxpZGF0b3IuamF2YQpuZXcgZmlsZSBtb2RlIDEwMDY0NAppbmRleCAwMDAwMDAwLi4wYzFmYWNlCi0tLSAvZGV2L251bGwKKysrIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2NvbXBvbmVudHMvdmFsaWRhdGlvbi9jb21wb25lbnQvQ29tcG9uZW50Q29udGFjdElkVmFsaWRhdG9yLmphdmEKQEAgLTAsMCArMSw2NyBAQAorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDIwIEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2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jL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jb21wb25lbnRzL3ZhbGlkYXRpb24vY29tcG9uZW50L0NvbXBvbmVudERlc2NyaXB0aW9uVmFsaWRhdG9yLmphdmEKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uNDdkOWY4YgotLS0gL2Rldi9udWxsCisrKyBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jb21wb25lbnRzL3ZhbGlkYXRpb24vY29tcG9uZW50L0NvbXBvbmVudERlc2NyaXB0aW9uVmFsaWRhdG9yLmphdmEKQEAgLTAsMCArMSw4MSBAQAorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDIwIEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgorICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0CisgKgorICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKKyAq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Fsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9jb21tb24vdHJhbnNhY3Rpb24vYXBpL0lEQlR5cGUuamF2YQorKysgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvY29tcG9uZW50cy92YWxpZGF0aW9uL2NvbXBvbmVudC9Db21wb25lbnRGaWVsZFZhbGlkYXRvci5qYXZhCkBAIC0yLDE0ICsyLDE0IEBACiAgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQogICogU0RDCiAgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogQ29weXJpZ2h0IChDKSAyMDIwIEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgogICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KICAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOwogICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgogICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0Ci0gKiAKKyAqCiAgKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAotICogCisgKgogICogVW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bmVudCBjb21wb25lbnQsIEF1ZGl0aW5nQWN0aW9uRW51bSBhY3Rpb25FbnVtKTsKIH0KZGlmZiAtLWdpdCBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jb21wb25lbnRzL3ZhbGlkYXRpb24vY29tcG9uZW50L0NvbXBvbmVudEljb25WYWxpZGF0b3IuamF2YSBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jb21wb25lbnRzL3ZhbGlkYXRpb24vY29tcG9uZW50L0NvbXBvbmVudEljb25WYWxpZGF0b3IuamF2YQpuZXcgZmlsZSBtb2RlIDEwMDY0NAppbmRleCAwMDAwMDAwLi40MzJmZjQxCi0tLSAvZGV2L251bGwKKysrIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2NvbXBvbmVudHMvdmFsaWRhdGlvbi9jb21wb25lbnQvQ29tcG9uZW50SWNvblZhbGlkYXRvci5qYXZhCkBAIC0wLDAgKzEsMTAzIEBACisvKi0KKyAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBTREMKKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBDb3B5cmlnaHQgKEMpIDIwMjAgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJM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YXRpYyBmaW5hbCBTdHJpbmcgREVGQVVMVF9JQ09OID0gImRlZmF1bHRpY29uIjsKKyAgICBwcml2YXRlIENvbXBvbmVudHNVdGlscyBjb21wb25lbnRzVXRpbHM7CisKKyAgICBwdWJsaWMgQ29tcG9uZW50SWNvblZhbGlkYXRvcihDb21wb25lbnRzVXRpbHMgY29tcG9uZW50c1V0aWxzKSB7CisgICAgICAgIHRoaXMuY29tcG9uZW50c1V0aWxzID0gY29tcG9uZW50c1V0aWxzOworICAgIH0KKworICAgIEBPdmVycmlkZQorICAgIHB1YmxpYyB2b2lkIHZhbGlkYXRlQW5kQ29ycmVjdEZpZWxkKFVzZXIgdXNlciwgQ29tcG9uZW50IGNvbXBvbmVudCwgQXVkaXRpbmdBY3Rpb25FbnVtIGFjdGlvbkVudW0pIHsKKyAgICAgICAgbG9nLmRlYnVnKCJ2YWxpZGF0ZSBJY29uIik7CisgICAgICAgIENvbXBvbmVudFR5cGVFbnVtIHR5cGUgPSBjb21wb25lbnQuZ2V0Q29tcG9uZW50VHlwZSgpOworICAgICAgICBTdHJpbmcgaWNvbiA9IGNvbXBvbmVudC5nZXRJY29uKCk7CisgICAgICAgIGlmIChTdHJpbmdVdGlscy5pc0VtcHR5KGljb24pKSB7CisgICAgICAgICAgICBsb2cuaW5mbygiaWNvbiBpcyBtaXNzaW5nLiIpOworICAgICAgICAgICAgY29tcG9uZW50LnNldEljb24oREVGQVVMVF9JQ09OKTsKKyAgICAgICAgfQorICAgICAgICB0cnkgeworICAgICAgICAgICAgaWYgKGNvbXBvbmVudC5nZXRDb21wb25lbnRUeXBlKCkuZXF1YWxzKENvbXBvbmVudFR5cGVFbnVtLlNFUlZJQ0UpKSB7CisgICAgICAgICAgICAgICAgdmFsaWRhdGVBbmRTZXREZWZhdWx0SWNvbihpY29uLCBjb21wb25lbnQpOworICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICB2YWxpZGF0ZUljb24oaWNvbixjb21wb25lbnQuZ2V0Q29tcG9uZW50VHlwZSgpKTsKKyAgICAgICAgICAgIH0KKworICAgICAgICB9IGNhdGNoKENvbXBvbmVudEV4Y2VwdGlvbiBlKXsKKyAgICAgICAgICAgIFJlc3BvbnNlRm9ybWF0IHJlc3BvbnNlRm9ybWF0ID0gZS5nZXRSZXNwb25zZUZvcm1hdCgpICE9IG51bGwgPyBlLmdldFJlc3BvbnNlRm9ybWF0KCkKKyAgICAgICAgICAgICAgICAgICAgOiBjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoZS5nZXRBY3Rpb25TdGF0dXMoKSwgZS5nZXRQYXJhbXMoKSk7CisgICAgICAgICAgICBjb21wb25lbnRzVXRpbHMuYXVkaXRDb21wb25lbnRBZG1pbihyZXNwb25zZUZvcm1hdCwgdXNlciwgY29tcG9uZW50LCBhY3Rpb25FbnVtLCB0eXBlKTsKKyAgICAgICAgICAgIHRocm93IGU7CisgICAgICAgIH0KKyAgICB9CisKKyAgICBwcml2YXRlIHZvaWQgdmFsaWRhdGVBbmRTZXREZWZhdWx0SWNvbihTdHJpbmcgaWNvbiwgb3JnLm9wZW5lY29tcC5zZGMuYmUubW9kZWwuQ29tcG9uZW50IGNvbXBvbm5ldCkgeworICAgICAgICB0cnkgeworICAgICAgICAgICAgaWYgKGNvbXBvbm5ldC5nZXRDYXRlZ29yaWVzKCkuZ2V0KDApLmdldEljb25zKCkgPT0gbnVsbCkgeworICAgICAgICAgICAgICAgIGNvbXBvbm5ldC5nZXRDYXRlZ29yaWVzKCkuZ2V0KDApLnNldEljb25zKEFycmF5cy5hc0xpc3QoREVGQVVMVF9JQ09OKSk7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBpZiAoaWNvbiAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgaWYgKGNvbXBvbm5ldC5nZXRDYXRlZ29yaWVzKCkuZ2V0KDApLmdldEljb25zKCkuY29udGFpbnMoaWNvbikpIHsKKyAgICAgICAgICAgICAgICAgICAgcmV0dXJuOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0KKyAgICAgICAgfSBjYXRjaCAoTnVsbFBvaW50ZXJFeGNlcHRpb24gZXhwKSB7CisgICAgICAgICAgICB0aHJvdyBuZXcgQnlBY3Rpb25TdGF0dXNDb21wb25lbnRFeGNlcHRpb24oQWN0aW9uU3RhdHVzLkNPTVBPTkVOVF9NSVNTSU5HX0NBVEVHT1JZLAorICAgICAgICAgICAgICAgICAgICBDb21wb25lbnRUeXBlRW51bS5TRVJWSUNFLmdldFZhbHVlKCkpOworICAgICAgICB9CisgICAgICAgIGNvbXBvbm5ldC5zZXRJY29uKERFRkFVTFRfSUNPTik7CisgICAgfQorCisgICAgcHJpdmF0ZSB2b2lkIHZhbGlkYXRlSWNvbihTdHJpbmcgaWNvbiwgQ29tcG9uZW50VHlwZUVudW0gdHlwZSkgeworICAgICAgICBpZiAoaWNvbiAhPSBudWxsKSB7CisgICAgICAgICAgICBpZiAoIVZhbGlkYXRpb25VdGlscy52YWxpZGF0ZUljb25MZW5ndGgoaWNvbikpIHsKKyAgICAgICAgICAgICAgICBsb2cuZGVidWcoImljb24gZXhjZWVkcyBtYXggbGVuZ3RoIik7CisgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEJ5QWN0aW9uU3RhdHVzQ29tcG9uZW50RXhjZXB0aW9uKEFjdGlvblN0YXR1cy5DT01QT05FTlRfSUNPTl9FWENFRURTX0xJTUlULCB0eXBlLmdldFZhbHVlKCksICIiICsgVmFsaWRhdGlvblV0aWxzLklDT05fTUFYX0xFTkdUSCk7CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIGlmICghVmFsaWRhdGlvblV0aWxzLnZhbGlkYXRlSWNvbihpY29uKSkgeworICAgICAgICAgICAgICAgIGxvZy5pbmZvKCJpY29uIGlzIGludmFsaWQuIik7CisgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEJ5QWN0aW9uU3RhdHVzQ29tcG9uZW50RXhjZXB0aW9uKEFjdGlvblN0YXR1cy5DT01QT05FTlRfSU5WQUxJRF9JQ09OLCB0eXBlLmdldFZhbHVlKCkpOworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgfQorfQpkaWZmIC0tZ2l0IGEvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2NvbXBvbmVudHMvdmFsaWRhdGlvbi9jb21wb25lbnQvQ29tcG9uZW50TmFtZVZhbGlkYXRvci5qYXZhIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2NvbXBvbmVudHMvdmFsaWRhdGlvbi9jb21wb25lbnQvQ29tcG9uZW50TmFtZVZhbGlkYXRvci5qYXZhCm5ldyBmaWxlIG1vZGUgMTAwNjQ0CmluZGV4IDAwMDAwMDAuLjdiMTNkMmUKLS0tIC9kZXYvbnVsbAorKysgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvY29tcG9uZW50cy92YWxpZGF0aW9uL2NvbXBvbmVudC9Db21wb25lbnROYW1lVmFsaWRhdG9yLmphdmEKQEAgLTAsMCArMSwxMDkgQEAKKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAyMCBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY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VlKCkpOworICAgIH0KK30KZGlmZiAtLWdpdCBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jb21wb25lbnRzL3ZhbGlkYXRpb24vY29tcG9uZW50L0NvbXBvbmVudFByb2plY3RDb2RlVmFsaWRhdG9yLmphdmEgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvY29tcG9uZW50cy92YWxpZGF0aW9uL2NvbXBvbmVudC9Db21wb25lbnRQcm9qZWN0Q29kZVZhbGlkYXRvci5qYXZhCm5ldyBmaWxlIG1vZGUgMTAwNjQ0CmluZGV4IDAwMDAwMDAuLjhkMGZkZjEKLS0tIC9kZXYvbnVsbAorKysgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvY29tcG9uZW50cy92YWxpZGF0aW9uL2NvbXBvbmVudC9Db21wb25lbnRQcm9qZWN0Q29kZVZhbGlkYXRvci5qYXZhCkBAIC0wLDAgKzEsODAgQEAKKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAyMCBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKKyAqIHlvdS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lscyBjb21wb25lbnRzVXRpbHM7CisKKyAgICBwdWJsaWMgQ29tcG9uZW50UHJvamVjdENvZGVWYWxpZGF0b3IoQ29tcG9uZW50c1V0aWxzIGNvbXBvbmVudHNVdGlscykgeworICAgICAgICB0aGlzLmNvbXBvbmVudHNVdGlscyA9IGNvbXBvbmVudHNVdGlsczsKKyAgICB9CisKKyAgICBAT3ZlcnJpZGUKKyAgICBwdWJsaWMgdm9pZCB2YWxpZGF0ZUFuZENvcnJlY3RGaWVsZChVc2VyIHVzZXIsIENvbXBvbmVudCBjb21wb25lbnQsIEF1ZGl0aW5nQWN0aW9uRW51bSBhY3Rpb25FbnVtKSB7CisgICAgICAgIGlmIChDb21wb25lbnRUeXBlRW51bS5SRVNPVVJDRSA9PSBjb21wb25lbnQuZ2V0Q29tcG9uZW50VHlwZSgpKSB7CisgICAgICAgICAgICByZXR1cm47CisgICAgICAgIH0KKyAgICAgICAgbG9nLmRlYnVnKCJ2YWxpZGF0ZSBQcm9qZWN0Q29kZSBuYW1lICIpOworICAgICAgICBTdHJpbmcgcHJvamVjdENvZGUgPSBjb21wb25lbnQuZ2V0UHJvamVjdENvZGUoKTsKKworICAgICAgICBpZiAoIVZhbGlkYXRpb25VdGlscy52YWxpZGF0ZVN0cmluZ05vdEVtcHR5KHByb2plY3RDb2RlKSkgeworICAgICAgICAgICAgbG9nLmluZm8oInByb2plY3RDb2RlIGlzIGVtcHR5IGlzIGFsbG93ZWQgQ1IuIik7CisgICAgICAgICAgICByZXR1cm47CisgICAgICAgIH0KKworICAgICAgICB0cnkgeworICAgICAgICAgICAgdmFsaWRhdGVQcm9qZWN0Q29kZShwcm9qZWN0Q29kZSk7CisgICAgICAgIH0gY2F0Y2ggKENvbXBvbmVudEV4Y2VwdGlvbiBleHApIHsKKyAgICAgICAgICAgIFJlc3BvbnNlRm9ybWF0IHJlc3BvbnNlRm9ybWF0ID0gZXhwLmdldFJlc3BvbnNlRm9ybWF0KCk7CisgICAgICAgICAgICBjb21wb25lbnRzVXRpbHMuYXVkaXRDb21wb25lbnRBZG1pbihyZXNwb25zZUZvcm1hdCwgdXNlciwgY29tcG9uZW50LCBhY3Rpb25FbnVtLCBjb21wb25lbnQuZ2V0Q29tcG9uZW50VHlwZSgpLAorICAgICAgICAgICAgICAgICAgICBSZXNvdXJjZVZlcnNpb25JbmZvLm5ld0J1aWxkZXIoKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5idWlsZCgpKTsKKyAgICAgICAgICAgIHRocm93IGV4cDsKKyAgICAgICAgfQorCisgICAgfQorCisgICAgcHJpdmF0ZSB2b2lkIHZhbGlkYXRlUHJvamVjdENvZGUoU3RyaW5nIHByb2plY3RDb2RlKSB7CisgICAgICAgIGlmIChwcm9qZWN0Q29kZSAhPSBudWxsKSB7CisgICAgICAgICAgICBpZiAoIVZhbGlkYXRpb25VdGlscy52YWxpZGF0ZVByb2plY3RDb2RlKHByb2plY3RDb2RlKSkgeworICAgICAgICAgICAgICAgIGxvZy5pbmZvKCJwcm9qZWN0Q29kZSAgaXMgbm90IHZhbGlkLiIpOworICAgICAgICAgICAgICAgIFJlc3BvbnNlRm9ybWF0IGVycm9yUmVzcG9uc2UgPSBjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLklOVkFMSURfUFJPSkVDVF9DT0RFKTsKKyAgICAgICAgICAgICAgICB0aHJvdyBuZXcgQnlSZXNwb25zZUZvcm1hdENvbXBvbmVudEV4Y2VwdGlvbihlcnJvclJlc3BvbnNlKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgIH0KK30KZGlmZiAtLWdpdCBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jb21wb25lbnRzL3ZhbGlkYXRpb24vY29tcG9uZW50L0NvbXBvbmVudFRhZ3NWYWxpZGF0b3IuamF2YSBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jb21wb25lbnRzL3ZhbGlkYXRpb24vY29tcG9uZW50L0NvbXBvbmVudFRhZ3NWYWxpZGF0b3IuamF2YQpuZXcgZmlsZSBtb2RlIDEwMDY0NAppbmRleCAwMDAwMDAwLi4yNDNlMDQwCi0tLSAvZGV2L251bGwKKysrIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2NvbXBvbmVudHMvdmFsaWRhdGlvbi9jb21wb25lbnQvQ29tcG9uZW50VGFnc1ZhbGlkYXRvci5qYXZhCkBAIC0wLDAgKzEsMTI0IEBACisvKi0KKyAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBTREMKKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBDb3B5cmlnaHQgKEMpIDIwMjAgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7CisgKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCisgKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKKyAqCisgKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAorICoKKyAqIFVubGV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ZJRUxEX0xBQkVMKTsKKyAgICAgICAgICAgICAgICAgICAgY29tcG9uZW50c1V0aWxzLmF1ZGl0Q29tcG9uZW50QWRtaW4ocmVzcG9uc2VGb3JtYXQsIHVzZXIsIGNvbXBvbmVudCwgYWN0aW9uLCBjb21wb25lbnRUeXBlKTsKKyAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEJ5QWN0aW9uU3RhdHVzQ29tcG9uZW50RXhjZXB0aW9uKEFjdGlvblN0YXR1cy5JTlZBTElEX0ZJRUxEX0ZPUk1BVCwgY29tcG9uZW50VHlwZS5nZXRWYWx1ZSgpLCBUQUdfRklFTERfTEFCRUwpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICB0YWdMaXN0U2l6ZSArPSB0YWcubGVuZ3RoKCkgKyAxOworICAgICAgICAgICAgfQorICAgICAgICAgICAgaWYgKHRhZ0xpc3RTaXplID4gMCkgeworICAgICAgICAgICAgICAgIHRhZ0xpc3RTaXplLS07CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIGlmICghaW5jbHVkZXNDb21wb25lbnROYW1lKSB7CisgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJ0YWdzIG11c3QgaW5jbHVkZSBjb21wb25lbnQgbmFtZSIpOworICAgICAgICAgICAgICAgIHJlc3BvbnNlRm9ybWF0ID0gY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5DT01QT05FTlRfSU5WQUxJRF9UQUdTX05PX0NPTVBfTkFNRSk7CisgICAgICAgICAgICAgICAgY29tcG9uZW50c1V0aWxzLmF1ZGl0Q29tcG9uZW50QWRtaW4ocmVzcG9uc2VGb3JtYXQsIHVzZXIsIGNvbXBvbmVudCwgYWN0aW9uLCBjb21wb25lbnRUeXBlKTsKKyAgICAgICAgICAgICAgICB0aHJvdyBuZXcgQnlBY3Rpb25TdGF0dXNDb21wb25lbnRFeGNlcHRpb24oQWN0aW9uU3RhdHVzL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gICAgICAgIHRocm93IG5ldyBCeUFjdGlvblN0YXR1c0NvbXBvbmVudEV4Y2VwdGlvbihBY3Rpb25TdGF0dXMuQ09NUE9ORU5UX1NJTkdMRV9UQUdfRVhDRUVEX0xJTUlULCAiIiArIFZhbGlkYXRpb25VdGlscy5UQUdfTUFYX0xFTkdUSCk7CisgICAgICAgIH0KKyAgICB9CisKKyAgICBwcm90ZWN0ZWQgYm9vbGVhbiB2YWxpZGF0ZVRhZ1BhdHRlcm4oU3RyaW5nIHRhZykgeworICAgICAgICByZXR1cm4gVmFsaWRhdGlvblV0aWxzLnZhbGlkYXRlVGFnUGF0dGVybih0YWcpOworICAgIH0KK30KZGlmZiAtLWdpdCBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jb21wb25lbnRzL3ZhbGlkYXRpb24vY29tcG9uZW50L0NvbXBvbmVudFZhbGlkYXRvci5qYXZhIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2NvbXBvbmVudHMvdmFsaWRhdGlvbi9jb21wb25lbnQvQ29tcG9uZW50VmFsaWRhdG9yLmphdmEKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uM2YzMDBhZgotLS0gL2Rldi9udWxsCisrKyBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jb21wb25lbnRzL3ZhbGlkYXRpb24vY29tcG9uZW50L0NvbXBvbmVudFZhbGlkYXRvci5qYXZhCkBAIC0wLDAgKzEsNDggQEAKKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09P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09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDIwIEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgorICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0CisgKgorICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKKyAqCisgKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlCisgKiBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0cmlidXRlZCBvbiBhbiAiQVMgSVMiIEJBU0lTLAorICogV0lUSE9VVCBXQVJSQU5USUVTIE9SIENPTkRJVElPTlMgT0YgQU5ZIEtJTkQsIGVpdGhlciBleHByZXNzIG9yIGltcGxpZWQuCisgKiBTZWUgdGhlIExpY2Vuc2UgZm9yIHRoZSBzcGVjaWZpYyBsYW5ndWFnZSBnb3Zlcm5pbmcgcGVybWlzc2lvbnMgYW5kCisgKiBsaW1pdGF0aW9ucyB1bmRlciB0aGUgTGljZW5zZS4KKyAqID09PT09PT09PT09PUxJQ0VOU0VfRU5EPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT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XNwb25zZUZvcm1hdCwgdXNlciwgc2VydmljZSwgYWN0aW9uRW51bSwgQ29tcG9uZW50VHlwZUVudW0uU0VSVklDRSk7CisgICAgICAgICAgICB0aHJvdyBuZXcgQnlSZXNwb25zZUZvcm1hdENvbXBvbmVudEV4Y2VwdGlvbihyZXNwb25zZUZvcm1hdCk7CisgICAgICAgIH0KKworICAgIH0KKworICAgIHByaXZhdGUgRWl0aGVyPEJvb2xlYW4sIFJlc3BvbnNlRm9ybWF0PiB2YWxpZGF0ZVNlcnZpY2VDYXRlZ29yeShMaXN0PENhdGVnb3J5RGVmaW5pdGlvbj4gbGlzdCkgeworICAgICAgICBpZiAobGlzdCAhPSBudWxsKSB7CisgICAgICAgICAgICBpZiAobGlzdC5zaXplKCkgPiAxKSB7CisgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJNdXN0IGJlIG9ubHkgb25lIGNhdGVnb3J5IGZvciBzZXJ2aWNlIik7CisgICAgICAgICAgICAgICAgUmVzcG9uc2VGb3JtYXQgcmVzcG9uc2VGb3JtYXQgPSBjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLkNPTVBPTkVOVF9UT09fTVVDSF9DQVRFR09SSUVTLCBDb21wb25lbnRUeXBlRW51bS5TRVJWSUNFLmdldFZhbHVlKCkpOworICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQocmVzcG9uc2VGb3JtYXQpOworICAgICAgICAgICAgfQorICAgICAgICAgICAgQ2F0ZWdvcnlEZWZpbml0aW9uIGNhdGVnb3J5ID0gbGlzdC5nZXQoMCk7CisgICAgICAgICAgICBpZiAoY2F0ZWdvcnkuZ2V0U3ViY2F0ZWdvcmllcygpICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICBsb2cuZGVidWcoIlN1YmNhdGVnb3JpZXMgY2Fubm90IGJlIGRlZmluZWQgZm9yIHNlcnZpY2UiKTsKKyAgICAgICAgICAgICAgICBSZXNw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IH0KK30KZGlmZiAtLWdpdCBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jb21wb25lbnRzL3ZhbGlkYXRpb24vc2VydmljZS9TZXJ2aWNlRW52aXJvbm1lbnRDb250ZXh0VmFsaWRhdG9yLmphdmEgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvY29tcG9uZW50cy92YWxpZGF0aW9uL3NlcnZpY2UvU2VydmljZUVudmlyb25tZW50Q29udGV4dFZhbGlkYXRvci5qYXZhCm5ldyBmaWxlIG1vZGUgMTAwNjQ0CmluZGV4IDAwMDAwMDAuLjYxMjA2NzMKLS0tIC9kZXYvbnVsbAorKysgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvY29tcG9uZW50cy92YWxpZGF0aW9uL3NlcnZpY2UvU2VydmljZUVudmlyb25tZW50Q29udGV4dFZhbGlkYXRvci5qYXZhCkBAIC0wLDAgKzEsNTIgQEAKKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAyMCBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKKyAqIHlvdSBt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5qYXZhCmNvcHkgdG8gY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2NvbXBvbmVudHMvdmFsaWRhdGlvbi9zZXJ2aWNlL1NlcnZpY2VGaWVsZFZhbGlkYXRvci5qYXZhCmluZGV4IDNhYTJlOWEuLjI0ZDkxYzIgMTAwNjQ0Ci0tLSBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9jb21tb24vdHJhbnNhY3Rpb24vYXBpL0lEQlR5cGUuamF2YQorKysgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvY29tcG9uZW50cy92YWxpZGF0aW9uL3NlcnZpY2UvU2VydmljZUZpZWxkVmFsaWRhdG9yLmphdmEKQEAgLTIsMTQgKzIsMTQgQEAKICAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CiAgKiBTREMKICAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBDb3B5cmlnaHQgKEMpIDIwMTcgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCisgKiBDb3B5cmlnaHQgKEMpIDIwMjAgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCiAgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQogICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7CiAgKiB5b3UgbWF5IG5v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AgIHRocm93IG5ldyBCeVJlc3BvbnNlRm9ybWF0Q29tcG9uZW50RXhjZXB0aW9uKGVycm9yUmVzcG9uc2UpOworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgfQorfQpkaWZmIC0tZ2l0IGEvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2NvbXBvbmVudHMvdmFsaWRhdGlvbi9zZXJ2aWNlL1NlcnZpY2VJbnN0YW50aWF0aW9uVHlwZVZhbGlkYXRvci5qYXZhIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2NvbXBvbmVudHMvdmFsaWRhdGlvbi9zZXJ2aWNlL1NlcnZpY2VJbnN0YW50aWF0aW9uVHlwZVZhbGlkYXRvci5qYXZhCm5ldyBmaWxlIG1vZGUgMTAwNjQ0CmluZGV4IDAwMDAwMDAuLmJhYTU5YTEKLS0tIC9kZXYvbnVsbAorKysgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvY29tcG9uZW50cy92YWxpZGF0aW9uL3NlcnZpY2UvU2VydmljZUluc3RhbnRpYXRpb25UeXBlVmFsaWRhdG9yLmphdmEKQEAgLTAsMCArMSw1OCBAQAorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDIwIEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09P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50c1V0aWxzOworCisgICAgcHVibGljIFNlcnZpY2VJbnN0YW50aWF0aW9uVHlwZVZhbGlkYXRvcihDb21wb25lbnRzVXRpbHMgY29tcG9uZW50c1V0aWxzKSB7CisgICAgICAgIHRoaXMuY29tcG9uZW50c1V0aWxzID0gY29tcG9uZW50c1V0aWxzOworICAgIH0KKworICAgIEBPdmVycmlkZQorICAgIHB1YmxpYyB2b2lkIHZhbGlkYXRlQW5kQ29ycmVjdEZpZWxkKFVzZXIgdXNlciwgU2VydmljZSBzZXJ2aWNlLCBBdWRpdGluZ0FjdGlvbkVudW0gYWN0aW9uRW51bSkgeworICAgICAgICBsb2cuZGVidWcoInZhbGlkYXRlIGluc3RhbnRpYXRpb24gdHlwZSIpOworICAgICAgICBTdHJpbmcgaW5zdGFudGlhdGlvblR5cGUgPSBzZXJ2aWNlLmdldEluc3RhbnRpYXRpb25UeXBlKCk7CisgICAgICAgIGlmIChTdHJpbmdVdGlscy5pc0VtcHR5KGluc3RhbnRpYXRpb25UeXBlKSkgeworICAgICAgICAgICAgc2VydmljZS5zZXRJbnN0YW50aWF0aW9uVHlwZShJbnN0YW50aWF0aW9uVHlwZXMuQV9MQV9DQVJURS5nZXRWYWx1ZSgpKTsKKyAgICAgICAgfQorICAgICAgICBpZiAoIUluc3RhbnRpYXRpb25UeXBlcy5jb250YWluc05hbWUoc2VydmljZS5nZXRJbnN0YW50aWF0aW9uVHlwZSgpKSl7CisgICAgICAgICAgICBsb2cuZXJyb3IoIlJlY2lldmVkIEluc3RhbnRpYXRpb24gdHlwZSB7fSBpcyBub3QgdmFsaWQuIiwgaW5zdGFudGlhdGlvblR5cGUpOworICAgICAgICAgICAgUmVzcG9uc2VGb3JtYXQgZXJyb3JSZXNwb25zZSA9IGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuSU5WQUxJRF9JTlNUQU5USUFUSU9OX1RZUEUsIGluc3RhbnRpYXRpb25UeXBlKTsKKyAg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ZUZvcm1hdCByZXNwb25zZUZvcm1hdCA9IGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuTkFNSU5HX1BPTElDWV9FWENFRURTX0xJTUlULCAiIiArIFZhbGlkYXRpb25VdGlscy5TRVJWSUNFX05BTUlOR19QT0xJQ1lfTUFYX1NJWkUpOworICAgICAgICAgICAgICAgIHRocm93IG5ldyBCeVJlc3BvbnNlRm9ybWF0Q29tcG9uZW50RXhjZXB0aW9uKHJlc3BvbnNlRm9ybWF0KTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGlmIChTdHJpbmdVdGlscy5pc0VtcHR5KG5hbWluZ1BvbGljeVVwZGF0ZSkpIHsKKyAgICAgICAgICAgICAgICBzZXJ2aWNlLnNldE5hbWluZ1BvbGljeSgiIik7CisgICAgICAgICAgICAgICAgcmV0dXJuOworICAgICAgICAgICAgfQorICAgICAgICAgICAgaWYgKCFWYWxpZGF0aW9uVXRpbHMudmFsaWRhdGVDb21tZW50UGF0dGVybihuYW1pbmdQb2xpY3lVcGRhdGUpKSB7CisgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEJ5QWN0aW9uU3RhdHVzQ29tcG9uZW50RXhjZXB0aW9uKEFjdGlvblN0YXR1cy5JTlZBTElEX05BTUlOR19QT0xJQ1kpOworICAgICAgICAgICAgfQorICAgICAgICAgICAgc2VydmljZS5zZXROYW1pbmdQb2xpY3kobmFtaW5nUG9saWN5VXBkYXRlKTsKKyAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgIGlmICghU3RyaW5nVXRpbHMuaXNFbXB0eShuYW1pbmdQb2xpY3lVcGRhdGUpKSB7CisgICAgICAgICAgICAgICAgbG9nLndhcm4oIk5hbWluZ1BvbGljeSBtdXN0IGJlIGVtcHR5IGZvciBFY29tcEdlbmVyYXRlZE5hbWluZz1mYWxzZSIpOworICAgICAgICAgICAgfQorICAgICAgICAgICAgc2VydmljZS5zZXROYW1pbmdQb2xpY3koIiIpOworICAgICAgICB9CisgICAgfQorfQpkaWZmIC0tZ2l0IGEvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2NvbXBvbmVudHMvdmFsaWRhdGlvbi9zZXJ2aWNlL1NlcnZpY2VSb2xlVmFsaWRhdG9yLmphdmEgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvY29tcG9uZW50cy92YWxpZGF0aW9uL3NlcnZpY2UvU2VydmljZVJvbGVWYWxpZGF0b3IuamF2YQpuZXcgZmlsZSBtb2RlIDEwMDY0NAppbmRleCAwMDAwMDAwLi41OWQyZTgzCi0tLSAvZGV2L251bGwKKysrIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2NvbXBvbmVudHMvdmFsaWRhdGlvbi9zZXJ2aWNlL1NlcnZpY2VSb2xlVmFsaWRhdG9yLmphdmEKQEAgLTAsMCArMSw3NCBAQAorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDIwIEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIH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YXRpb24vc2VydmljZS9TZXJ2aWNlVHlwZVZhbGlkYXRvci5qYXZhCkBAIC0wLDAgKzEsNjggQEAKKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAyMCBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKKyAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KKyAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAorICoKKyAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wCisgKgorICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZQorICogZGlzdHJpYnV0ZWQgdW5kZXIgdGhlIExpY2Vuc2UgaXMgZGlzdHJpYnV0ZWQgb24gYW4gIkFTIElTIiBCQVNJUywKKyAqIFdJVEhPVVQgV0FSUkFOVElFUyBPUiBDT05ESVRJT05TIE9GIEFOWSBLSU5ELCBlaXRoZXIgZXhwcmVzcyBvciBpbXBsaWVkLgor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GF0b3IuamF2YSBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jb21wb25lbnRzL3ZhbGlkYXRpb24vc2VydmljZS9TZXJ2aWNlVmFsaWRhdG9yLmphdmEKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uNWNmNDkwZAotLS0gL2Rldi9udWxsCisrKyBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jb21wb25lbnRzL3ZhbGlkYXRpb24vc2VydmljZS9TZXJ2aWNlVmFsaWRhdG9yLmphdmEKQEAgLTAsMCArMSw0OSBAQAorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDIwIEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgorICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0CisgKgorICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKKyAqC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pbHMvQ29udGFpbmVySW5zdGFuY2VUeXBlc0RhdGEuamF2YQpAQCAtMCwwICsxLDYyIEBACisvKi0KKyAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBTREMKKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBDb3B5cmlnaHQgKEMpIDIwMjAgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7CisgKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCisgKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKKyAqCisgKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAorICoKKyAqIFVubGVzcyByZXF1aXJlZCBieSBhcHBsaWNhYmxlIGxhdyBvciBhZ3JlZWQgdG8gaW4gd3JpdGluZywgc29mdHdhcmUKKyAqIGRpc3RyaWJ1dGVkIHVuZGVyIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1dGVkIG9uIGFuICJBUyBJUyIgQkFTSVMsCisgKiBXSVRIT1VUIFdBUlJBTlRJRVMgT1IgQ09ORElUSU9OUyBPRiBBTlkgS0lORCwgZWl0aGVyIGV4cHJlc3Mgb3IgaW1wbGllZ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cDxSZXNvdXJjZVR5cGVFbnVtLExpc3Q8UmVzb3VyY2VUeXBlRW51bT4+IHZhbGlkSW5zdGFuY2VUeXBlc0luUmVzb3VyY2VDb250YWluZXIgPSBuZXcgSGFzaE1hcDw+KCk7CisKKyAgICBwcml2YXRlIENvbnRhaW5lckluc3RhbmNlVHlwZXNEYXRhKCkgeworICAgICAgICBMaXN0PFJlc291cmNlVHlwZUVudW0+IHZmQ29udGFpbmVySW5zdGFuY2VzID0gQXJyYXlzLmFzTGlzdChSZXNvdXJjZVR5cGVFbnVtLkNQLAorICAgICAgICAgICAgICAgIFJlc291cmNlVHlwZUVudW0uVkwsIFJlc291cmNlVHlwZUVudW0uQ29uZmlndXJhdGlvbiwKKyAgICAgICAgICAgICAgICBSZXNvdXJjZVR5cGVFbnVtLlZGQyk7CisgICAgICAgIExpc3Q8UmVzb3VyY2VUeXBlRW51bT4gY3JDb250YWluZXJJbnN0YW5jZXMgPSBBcnJheXMuYXNMaXN0KFJlc291cmNlVHlwZUVudW0uQ1AsCisgICAgICAgICAgICAgICAgUmVzb3VyY2VUeXBlRW51bS5WTCwgUmVzb3VyY2VUeXBlRW51bS5Db25maWd1cmF0aW9uLAorICAgICAgICAgICAgICAgIFJlc291cmNlVHlwZUVudW0uVkZDKTsKKyAgICAgICAgTGlzdDxSZXNvdXJjZVR5cGVFbnVtPiBwbmZDb250YWluZXJJbnN0YW5jZXMgPSBBcnJheXMuYXNMaXN0KFJlc291cmNlVHlwZUVudW0uQ1AsCisgICAgICAgICAgICAgICAgUmVzb3VyY2VUeXBlRW51bS5WTCwgUmVzb3VyY2VUeXBlRW51bS5Db25maWd1cmF0aW9uLAorICAgICAgICAgICAgICAgIFJlc291cmNlVHlwZUVudW0uVkZDKTsKKyAgICAgICAgdmFsaWRJbnN0YW5jZVR5cGVzSW5SZXNvdXJjZUNvbnRhaW5lci5wdXQoUmVzb3VyY2VUeXBlRW51bS5WRiwgdmZDb250YWluZXJJbnN0YW5jZXMpOworICAgICAg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VibGljIHZvaWQgYXVkaXRVblJlZ2lzdGVyUmVxdWVzdChDYW1icmlhRXJyb3JSZXNwb25zZSByZWdpc3RlclJlc3BvbnNlKSB7DQotICAgICAgICBjb21wb25lbnRzVXRpbHMuYXVkaXRSZWdpc3Rlck9yVW5SZWdpc3RlckV2ZW50KEF1ZGl0aW5nQWN0aW9uRW51bS5ESVNUUklCVVRJT05fVU5fUkVHSVNURVIsIGluc3RhbmNlSUQsIHJlZ2lzdHJhdGlvblJlcXVlc3QuZ2V0QXBpUHVibGljS2V5KCksIHJlZ2lzdHJhdGlvblJlcXVlc3QuZ2V0RGlzdHJFbnZOYW1lKCksIFN0cmluZy52YWx1ZU9mKHJlZ2lzdGVyUmVzcG9uc2UuZ2V0SHR0cENvZGUoKSksDQotICAgICAgICAgICAgICAgIHJlZ2lzdGVyUmVzcG9uc2UuZ2V0T3BlcmF0aW9uU3RhdHVzKCkubmFtZSgpLCBEaXN0cmlidXRpb25CdXNpbmVzc0xvZ2ljLmdldE5vdGlmaWNhdGlvblRvcGljTmFtZShyZWdpc3RyYXRpb25SZXF1ZXN0LmdldERpc3RyRW52TmFtZSgpKSwgRGlzdHJpYnV0aW9uQnVzaW5lc3NMb2dpYy5nZXRTdGF0dXNUb3BpY05hbWUocmVnaXN0cmF0aW9uUmVxdWVzdC5nZXREaXN0ckVudk5hbWUoKSkpOw0KLSAgICB9DQotfQ0KKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAxNyBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09P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0xLDMxMyArMSwzMjIgQEAKLS8qLQ0KLSAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogU0RDDQotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NCi0gKiBDb3B5cmlnaHQgKEMpIDIwMTcgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NCi0gKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsNCi0gKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuDQotICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0DQotICogDQotICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjANCi0gKiANCi0gKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlDQotICogZGlzdHJpYnV0ZWQgdW5kZXIgdGhlIExpY2Vuc2UgaXMgZGlzdHJpYnV0ZWQgb24gYW4gIkFTIElTIiBCQVNJUywNCi0gKiBXSVRIT1VUIFdBUlJBTlRJRVMgT1IgQ09ORElUSU9OUyBPRiBBTlkgS0lORCwgZWl0aGVyIGV4cHJlc3Mgb3IgaW1wbGllZC4NCi0gKiBTZWUgdGhlIExpY2Vuc2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DT05TVU1FUiwNCi0gICAgICAgICAgICAgICAgICAgICAgICBEaXN0cmlidXRpb25Ub3BpY0RhdGEubmV3QnVpbGRlcigpDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5ub3RpZmljYXRpb25Ub3BpYyhub3RpZmljYXRpb25Ub3BpY05hbWUpDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5idWlsZCgpKTsNCi0gICAgICAgICAgICB9DQotICAgICAgICAgICAgLy8gVW5yZWdpc3RlciBSb2xsYmFjaw0KLSAgICAgICAgICAgIGlmICghcmVzcG9uc2VXcmFwcGVyLmlzRW1wdHkoKSkgew0KLSAgICAgICAgICAgICAgICBpZiAoaXNSZWdpc3RlcmVkQXNQcm9kdWNlck9uU3RhdHVzU3VjY2Vzcykgew0KLSAgICAgICAgICAgICAgICAgICAgQ2FtYnJpYUVycm9yUmVzcG9uc2UgdW5SZWdpc3RlclJlc3BvbnNlID0gdW5SZWdpc3RlckRpc3RyaWJ1dGlvbkNsaWVudEZyb21Ub3BpYyhyZWdpc3RyYXRpb25SZXF1ZXN0LA0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdWJzY3JpYmVyVHlwZUVudW0uUFJPRFVDRVIsIHN0YXR1c1RvcGljTmFtZSk7DQotICAgICAgICAgICAgICAgICAgICBhdWRpdEhhbmRsZXIuYXVkaXRVblJlZ2lzdGVyQUNMKHVuUmVnaXN0ZXJSZXNwb25zZSwgU3Vic2NyaWJlclR5cGVFbnVtLlBST0RVQ0VSLA0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBEaXN0cmlidXRpb25Ub3BpY0RhdGEubmV3QnVpbGRlcigpDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnN0YXR1c1RvcGljKHN0YXR1c1RvcGljTmFtZSkNCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuYnVpbGQoKSk7DQotICAgICAgICAgICAgICAgIH0NCi0gICAgICAgICAgICAgICAgaWYgKHJlZ2lzdGVyZWRBc0NvbnN1bWVyT25TdGF0dXMpIHsNCi0gICAgICAgICAgICAgICAgICAgIENhbWJyaWFFcnJvclJlc3BvbnNlIHVuUmVnaXN0ZXJSZXNwb25zZSA9IHVuUmVnaXN0ZXJEaXN0cmlidXRpb25DbGllbnRGcm9tVG9waWMocmVnaXN0cmF0aW9uUmVxdWVzdCwNCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgU3Vic2NyaWJlclR5cGVFbnVtLkNPTlNVTUVSLCBzdGF0dXNUb3BpY05hbWUpOw0KLSAgICAgICAgICAgICAgICAgICAgYXVkaXRIYW5kbGVyLmF1ZGl0VW5SZWdpc3RlckFDTCh1blJlZ2lzdGVyUmVzcG9uc2UsIFN1YnNjcmliZXJUeXBlRW51bS5DT05TVU1FUiwNCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgRGlzdHJpYnV0aW9uVG9waWNEYXRhLm5ld0J1aWxkZXIoKQ0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAuc3RhdHVzVG9waWMoc3RhdHVzVG9waWNOYW1lKQ0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAuYnVpbGQoKSk7DQotICAgICAgICAgICAgICAgIH0NCi0gICAgICAgICAgICB9DQotDQotICAgICAgICAgICAgaWYgKHJlc3BvbnNlV3JhcHBlci5pc0VtcHR5KCkpIHsNCi0gICAgICAgICAgICAgICAgVG9waWNSZWdpc3RyYXRpb25SZXNwb25zZSBva1RvcGljUmVzcG9uc2UgPSBidWlsZFRvcGljUmVzcG9uc2UocmVnaXN0cmF0aW9uUmVxdWVzdCk7DQotICAgICAgICAgICAgICAgIHJlc3BvbnNlV3JhcHBlci5zZXRJbm5lckVsZW1lbnQoUmVzcG9uc2Uuc3RhdHVzKEh0dHBTdGF0dXMuU0NfT0spLmVudGl0eShva1RvcGljUmVzcG9uc2UpLmJ1aWxkKCkpOw0KLSAgICAgICAgICAgIH0NCi0NCi0gICAgICAgIH0gY2F0Y2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0gbmV3IENhbWJyaWFIYW5kbGVyKCk7DQotICAgICAgICB9DQotICAgICAgICByZXR1cm4gY2FtYnJpYUhhbmRsZXI7DQotICAgIH0NCi0NCi19DQorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgorICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0CisgKiAKKyAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wCisgKiAKKyAqIFVubGVzcyByZXF1aXJlZCBieSBhcHBsaWNhYmxlIGxhdyBvciBhZ3JlZWQgdG8gaW4gd3JpdGluZywgc29mdHdhcmUKKyAqIGRpc3RyaWJ1dGVkIHVuZGVyIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1dGVkIG9uIGFuICJBUyBJUyIgQkFTSVMsCisgKiBXSVRIT1VUIFdBUlJBTlRJRVMgT1IgQ09ORElUSU9OUyBPRiBBTlkgS0lORCwgZWl0aGVy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YXRpb24gZnJvbQorICAgICAgICAgICAgLy8gY29tcG9uZW50IHdoZXRoZXIgdG8gcmVnaXN0ZXIgYXMgY29uc3VtZXIgYW5kIHByb2R1Y2VyIG9uCisgICAgICAgICAgICAvLyBzdGF0dXMgdG9waWMKKyAgICAgICAgICAgIGJvb2xlYW4gcmVnaXN0ZXJlZEFzQ29uc3VtZXJPblN0YXR1cyA9IGZhbHNlOworICAgICAgICAgICAgaWYgKGlzUmVnaXN0ZXJlZEFzUHJvZHVjZXJPblN0YXR1c1N1Y2Nlc3MgJiYgaXNUcnVlKHJlZ2lzdHJhdGlvblJlcXVlc3QuZ2V0SXNDb25zdW1lclRvU2RjRGlzdHJTdGF0dXNUb3BpYygpKSkgeworICAgICAgICAgICAgICAgIHJlZ2lzdGVyUmVzcG9uc2UgPSByZWdpc3RlckRpc3RyaWJ1dGlvbkNsaWVudFRvVG9waWMocmVzcG9uc2VXcmFwcGVyLCByZWdpc3RyYXRpb25SZXF1ZXN0LAorICAgICAgICAgICAgICAgICAgICAgICAgU3Vic2NyaWJlclR5cGVFbnVtLkNPTlNVTUVSLCBzdGF0dXNUb3BpY05hbWUpOworICAgICAgICAgICAgICAgIGF1ZGl0SGFuZGxlci5hdWRpdFJlZ2lzdGVyQUNMKHJlZ2lzdGVyUmVzcG9uc2UsIFN1YnNjcmliZXJUeXBlRW51bS5DT05TVU1FUiwKKyAgICAgICAgICAgICAgICAgICAgICAgIERpc3RyaWJ1dGlvblRvcGljRGF0YS5uZXdCdWlsZGVyKCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnN0YXR1c1RvcGljKHN0YXR1c1RvcGljTmFtZSkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmJ1aWxkKCkpOworICAgICAgICAgICAgICAgIHJlZ2lzdGVyZWRBc0NvbnN1bWVyT25TdGF0dXMgPSByZXNwb25zZVdyYXBwZXIuaXNFbXB0eSgpOworCisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIGlmIChyZXNwb25zZVdyYXBwZXIuaXNFbXB0eSgpKSB7CisgICAgICAgICAgICAgICAgU3RyaW5nIG5vdGlmaWNhdGlvblRvcGljTmFtZSA9IGJ1aWxkVG9waWNOYW1lKGNvbmZpZy5nZXREaXN0cmlidXRpb25Ob3RpZlRvcGljTmFtZSgpLAorICAgICAgICAgICAgICAgICAgICAgICAgcmVnaXN0cmF0aW9uUmVxdWVzdC5nZXREaXN0ckVudk5hbWUoKSk7CisgICAgICAgICAgICAgICAgcmVnaXN0ZXJSZXNwb25zZSA9IHJlZ2lzdGVyRGlzdHJpYnV0aW9uQ2xpZW50VG9Ub3BpYyhyZXNwb25zZVdyYXBwZXIsIHJlZ2lzdHJhdGlvblJlcXVlc3QsCisgICAgICAgICAgICAgICAgICAgICAgICBTdWJzY3JpYmVyVHlwZUVudW0uQ09OU1VNRVIsIG5vdGlmaWNhdGlvblRvcGljTmFtZSk7CisgICAgICAgICAgICAgICAgYXVkaXRIYW5kbGVyLmF1ZGl0UmVnaXN0ZXJBQ0wocmVnaXN0ZXJSZXNwb25zZSwgU3Vic2NyaWJlclR5cGVFbnVtLkNPTlNVTUVSLAorICAgICAgICAgICAgICAgICAgICAgICAgRGlzdHJpYnV0aW9uVG9waWNEYXRhLm5ld0J1aWxkZXIoKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5ub3RpZmljYXRpb25Ub3BpYyhub3RpZmljYXRpb25Ub3BpY05hbWUpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmJ1aWxkKCkpOworICAgICAgICAgICAgfQorICAgICAgICAgICAgLy8gVW5yZWdpc3RlciBSb2xsYmFjaworICAgICAgICAgICAgaWYgKCFyZXNwb25zZVdyYXBwZXIuaXNFbXB0eSgpKSB7CisgICAgICAgICAgICAgICAgaWYgKGlzUmVnaXN0ZXJlZEFzUHJvZHVjZXJPblN0YXR1c1N1Y2Nlc3MpIHsKKyAgICAgICAgICAgICAgICAgICAgQ2FtYnJpYUVycm9yUmVzcG9uc2UgdW5SZWdpc3RlclJlc3BvbnNlID0gdW5SZWdpc3RlckRpc3RyaWJ1dGlvbkNsaWVudEZyb21Ub3BpYyhyZWdpc3RyYXRpb25SZXF1ZXN0LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN1YnNjcmliZXJUeXBlRW51bS5QUk9EVUNFUiwgc3RhdHVzVG9waWNOYW1lKTsKKyAgICAgICAgICAgICAgICAgICAgYXVkaXRIYW5kbGVyLmF1ZGl0VW5SZWdpc3RlckFDTCh1blJlZ2lzdGVyUmVzcG9uc2UsIFN1YnNjcmliZXJUeXBlRW51bS5QUk9EVUNFUiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBEaXN0cmlidXRpb25Ub3BpY0RhdGEubmV3QnVpbGRlcigpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuc3RhdHVzVG9waWMoc3RhdHVzVG9waWNOYW1lKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmJ1aWxkKCkpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBpZiAocmVnaXN0ZXJlZEFzQ29uc3VtZXJPblN0YXR1cykgeworICAgICAgICAgICAgICAgICAgICBDYW1icmlhRXJyb3JSZXNwb25zZSB1blJlZ2lzdGVyUmVzcG9uc2UgPSB1blJlZ2lzdGVyRGlzdHJpYnV0aW9uQ2xpZW50RnJvbVRvcGljKHJlZ2lzdHJhdGlvblJlcXVlc3QsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3Vic2NyaWJlclR5cGVFbnVtLkNPTlNVTUVSLCBzdGF0dXNUb3BpY05hbWUpOworICAgICAgICAgICAgICAgICAgICBhdWRpdEhhbmRsZXIuYXVkaXRVblJlZ2lzdGVyQUNMKHVuUmVnaXN0ZXJSZXNwb25zZSwgU3Vic2NyaWJlclR5cGVFbnVtLkNPTlNVTUVSLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIERpc3RyaWJ1dGlvblRvcGljRGF0YS5uZXdCdWlsZGVyKCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAuc3RhdHVzVG9waWMoc3RhdHVzVG9waWNOYW1lKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5idWlsZCgpKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIGlmIChyZXNwb25zZVdyYXBwZXIuaXNFbXB0eSgpKSB7CisgICAgICAgICAgICAgICAgVG9waWNSZWdpc3RyYXRpb25SZXNwb25zZSBva1RvcGljUmVzcG9uc2UgPSBidWlsZFRvcGljUmVzcG9uc2UocmVnaXN0cmF0aW9uUmVxdWVzdCk7CisgICAgICAgICAgICAgICAgcmVzcG9uc2VXcmFwcGVyLnNldElubmVyRWxlbWVudChSZXNwb25zZS5zdGF0dXMoSHR0cFN0YXR1cy5TQ19PSykuZW50aXR5KG9rVG9waWNSZXNwb25zZSkuYnVpbGQoKSk7CisgICAgICAgICAgICB9CisKKyAgICAgICAgfSBjYXRjaCAoRXhjZXB0aW9uIGUpIHsKKyAgICAgICAgICAgIGxvZy5lcnJvcigicmVnaXN0cmF0aW9uIHRvIHRvcGljIGZhaWxlZCIsIGUpOworICAgICAgICAgICAgQmVFY29tcEVycm9yTWFuYWdlci5nZXRJbnN0YW5jZSgpLmxvZ0JlRGlzdHJpYnV0aW9uRW5naW5lU3lzdGVtRXJyb3IoUkVHSVNURVJfSU5fRElTVFJJQlVUSU9OX0VOR0lORSwKKyAgICAgICAgICAgICAgICAgICAgInJlZ2lzdHJhdGlvbiBvZiBzdWJzY3JpYmVyIHRvIHRvcGljIik7CisgICAgICAgICAgICBSZXNwb25zZSBlcnJvclJlc3BvbnNlID0gYnVpbGRFcnJvclJlc3BvbnNlKAorICAgICAgICAgICAgICAgICAgICBnZXRSZXNwb25zZUZvcm1hdE1hbmFnZXIoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUikpOworICAgIC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ICBhdWRpdEhhbmRsZXIuYXVkaXRVblJlZ2lzdGVyQUNMKHVucmVnaXN0ZXJDbGllbnRDb25zdW1lclRvcGljUmVzcG9uc2UsIFN1YnNjcmliZXJUeXBlRW51bS5DT05TVU1FUiwKKyAgICAgICAgICAgICAgICAgICAgRGlzdHJpYnV0aW9uVG9waWNEYXRhLm5ld0J1aWxkZXIoKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5ub3RpZmljYXRpb25Ub3BpYyhub3RpZmljYXRpb25Ub3BpY05hbWUpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmJ1aWxkKCkpOworICAgICAgICAgICAgdXBkYXRlUmVzcG9uc2VXcmFwcGVyKGNhbWJyaWFSZXNwb25zZVdyYXBwZXIsIHVucmVnaXN0ZXJDbGllbnRDb25zdW1lclRvcGljUmVzcG9uc2UpOworCisgICAgICAgICAgICAvLyBTdWNjZXNzIHVucmVnaXN0ZXIgYm90aCB0b3BpY3MKKyAgICAgICAgICAgIFRvcGljVW5yZWdpc3RyYXRpb25SZXNwb25zZSB1bnJlZ2lzdGVyUmVzcG9uc2UgPSBuZXcgVG9waWNVbnJlZ2lzdHJhdGlvblJlc3BvbnNlKAorICAgICAgICAgICAgICAgICAgICBnZXROb3RpZmljYXRpb25Ub3BpY05hbWUodW5SZWdpc3RyYXRpb25SZXF1ZXN0LmdldERpc3RyRW52TmFtZSgpKSwKKyAgICAgICAgICAgICAgICAgICAgZ2V0U3RhdHVzVG9waWNOYW1lKHVuUmVnaXN0cmF0aW9uUmVxdWVzdC5nZXREaXN0ckVudk5hbWUoKSksCisgICAgICAgICAgICAgICAgICAgIHVucmVnaXN0ZXJDbGllbnRDb25zdW1lclRvcGljUmVzcG9uc2UuZ2V0T3BlcmF0aW9uU3RhdHVzKCksCisgICAgICAgICAgICAgICAgICAgIHVucmVnaXN0ZXJDbGllbnRQcm9kdWNlclRvcGljUmVzcG9uc2UuZ2V0T3BlcmF0aW9uU3RhdHVzKCkpOworCisgICA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GFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9kaXN0cmlidXRpb24vc2VydmxldC9EaXN0cmlidXRpb25DYXRhbG9nU2VydmxldC5qYXZhCmluZGV4IDMxYzNkNjcuLjRjNWI0ZjYgMTAwNjQ0Ci0tLSBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9kaXN0cmlidXRpb24vc2VydmxldC9EaXN0cmlidXRpb25DYXRhbG9nU2VydmxldC5qYXZhCisrKyBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9kaXN0cmlidXRpb24vc2VydmxldC9EaXN0cmlidXRpb25DYXRhbG9nU2VydmxldC5qYXZhCkBAIC0xLDMyMyArMSwzMDkgQEAKLS8qLQ0KLSAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogU0RDDQotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NCi0gKiBDb3B5cmlnaHQgKEMpIDIwMTcgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NCi0gKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsNCi0gKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuDQotICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0DQotICogDQotICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjANCi0gKiANCi0gKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlDQotICogZGlzdHJpYnV0ZWQgdW5kZXIgdGhlIExpY2Vuc2UgaXMgZGlzdHJpYnV0ZWQgb24gYW4gIkFTIElTIiBCQVNJUywNCi0gKiBXSVRIT1VUIFdBUlJBTlRJRVMgT1IgQ09ORElUSU9OUyBPRiBBTlkgS0lORCwgZWl0aGVyIGV4cHJlc3Mgb3IgaW1wbGllZC4NCi0gKiBTZWUgdGhlIExpY2Vuc2UgZm9yIHRoZSBzcGVjaWZpYyBsYW5ndWFnZSBnb3Zlcm5pbmcgcGVybWlzc2lvbnMgYW5kDQotICogbGltaXRhdGlvbnMgdW5kZXIgdGhlIExpY2Vuc2UuDQotICogPT09PT09PT09PT09TElDRU5TRV9FTkQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NCi0gKiBNb2RpZmljYXRpb25zIGNvcHlyaWdodCAoYykgMjAxOSBOb2tpYQ0KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICovDQotDQotcGFja2FnZSBvcmcub3BlbmVjb21wLnNkYy5iZS5kaXN0cmlidXRpb24uc2VydmxldDsNCi0NCi1pbXBvcnQgamF2YS5pby5CeXRlQXJyYXlJbnB1dFN0cmVhbTsNCi1pbXBvcnQgamF2YS5pby5JbnB1dFN0cmVhbTsNCi1pbXBvcnQgamF2YS51dGlsLkhhc2hNYXA7DQotaW1wb3J0IGphdmEudXRpbC5NYXA7DQotaW1wb3J0IGphdmF4LmluamVjdC5JbmplY3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WxvZ1NlcnZsZXQoVXNlckJ1c2luZXNzTG9naWMgdXNlckJ1c2luZXNzTG9naWMsDQotICAgICAgICBDb21wb25lbnRzVXRpbHMgY29tcG9uZW50c1V0aWxzLA0KLSAgICAgICAgQXJ0aWZhY3RzQnVzaW5lc3NMb2dpYyBhcnRpZmFjdHNCdXNpbmVzc0xvZ2ljKSB7DQotICAgICAgICBzdXBlcih1c2VyQnVzaW5lc3NMb2dpYywgY29tcG9uZW50c1V0aWxzKTsNCi0gICAgICAgIHRoaXMuYXJ0aWZhY3RzQnVzaW5lc3NMb2dpYyA9IGFydGlmYWN0c0J1c2luZXNzTG9naWM7DQotICAgIH0NCi0NCi0gICAgQENvbnRleHQNCi0gICAgcHJpdmF0ZSBIdHRwU2VydmxldFJlcXVlc3QgcmVxdWVzdDsNCi0NCi0gICAgLy8gKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KLSAgICAvLyBEb3dubG9hZCAoR0VUKSBhcnRpZmFjdHMNCi0gICAgLy8gKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8NCi0gICAgLyoqDQotICAgICAqDQotICAgICAqIEBwYXJhbSByZXF1ZXN0SWQNCi0gICAgICogQHBhcmFtIGluc3RhbmNlSWRIZWFkZXINCi0gICAgICogQHBhcmFtIGFjY2VwdA0KLSAgICAgKiBAcGFyYW0gYXV0aG9yaXphdGlvbg0KLSAgICAgKiBAcGFyYW0gc2VydmljZU5hbWUNCi0gICAgICogQHBhcmFtIHNlcnZpY2VWZXJzaW9uDQotICAgICAqIEBwYXJhbSBhcnRpZmFjdE5hbWUNCi0gICAgICogQHJldHVybg0KLSAgICAgKi8NCi0gICAgQEdFVA0KLSAgICBAUGF0aCgiL3NlcnZpY2VzL3tzZXJ2aWNlTmFtZX0ve3NlcnZpY2VWZXJzaW9ufS9hcnRpZmFjdHMve2FydGlmYWN0TmFtZX0iKQ0KLS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2NC1lbmNvZGVkIGFzIGl0IHdhcyByZWNlaXZlZCBkdXJpbmcgdXBsb2FkDQotICAgICAgICAgICAgICAgIElucHV0U3RyZWFtIGlzID0gbmV3IEJ5dGVBcnJheUlucHV0U3RyZWFtKHZhbHVlKTsNCi0gICAgICAgICAgICAgICAgTWFwPFN0cmluZywgU3RyaW5nPiBoZWFkZXJzID0gbmV3IEhhc2hNYXA8PigpOw0KLSAgICAgICAgICAgICAgICBoZWFkZXJzLnB1dChDb25zdGFudHMuQ09OVEVOVF9ESVNQT1NJVElPTl9IRUFERVIsIGdldENvbnRlbnREaXNwb3NpdGlvblZhbHVlKGFydGlmYWN0TmFtZSkpOw0KLSAgICAgICAgICAgICAgICBSZXNwb25zZUZvcm1hdCByZXNwb25zZUZvcm1hdCA9IGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5PSyk7DQotICAgICAgICAgICAgICAgIGdldENvbXBvbmVudHNVdGlscygpLmF1ZGl0RGlzdHJpYnV0aW9uRG93bmxvYWQocmVzcG9uc2VGb3JtYXQsIG5ldyBEaXN0cmlidXRpb25EYXRhKGluc3RhbmNlSWRIZWFkZXIsIHJlcXVlc3RVUkkpKTsNCi0gICAgICAgICAgICAgICAgcmVzcG9uc2VXcmFwcGVyLnNldElubmVyRWxlbWVudChidWlsZE9rUmVzcG9uc2UocmVzcG9uc2VGb3JtYXQsIGlzLCBoZWFkZXJzKSk7DQotICAgICAgICAgICAgfQ0KLSAgICAgICAgICAgIHJldHVybiByZXNwb25zZVdyYXBwZXIuZ2V0SW5uZXJFbGVtZW50KCk7DQotDQotICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZSkgew0KLSAgICAgICAgICAgIEJlRWNvbXBFcnJvck1hbmFnZXIuZ2V0SW5zdGFuY2UoKS5sb2dCZVJlc3RBcGlHZW5lcmFsRXJyb3IoImRvd25sb2FkIGludGVyZmFjZSBhcnRpZmFjdCBmb3IgcmVzb3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mdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5PSyk7DQotICAgICAgICAgICAgICAgIGdldENvbXBvbmVudHNVdGlscygpLmF1ZGl0RGlzdHJpYnV0aW9uRG93bmxvYWQocmVzcG9uc2VGb3JtYXQsIG5ldyBEaXN0cmlidXRpb25EYXRhKGluc3RhbmNlSWRIZWFkZXIsIHJlcXVlc3RVUkkpKTsNCi0gICAgICAgICAgICAgICAgcmVzcG9uc2VXcmFwcGVyLnNldElubmVyRWxlbWVudChidWlsZE9rUmVzcG9uc2UocmVzcG9uc2VGb3JtYXQsIGlzLCBoZWFkZXJzKSk7DQotICAgICAgICAgICAgfQ0KLSAgICAgICAgICAgIHJldHVybiByZXNwb25zZVdyYXBwZXIuZ2V0SW5uZXJFbGVtZW50KCk7DQotDQotICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZSkgew0KLSAgICAgICAgICAgIEJlRWNvbXBFcnJvck1hbmFnZXIuZ2V0SW5zdGFuY2UoKS5sb2dCZVJlc3RBcGlHZW5lcmFsRXJyb3IoImRvd25sb2FkIGludGVyZmFjZSBhcnRpZmFjdCBmb3IgcmVzb3VyY2UgLSBleHRlcm5hbCBBUEkiKTsNCi0gICAgICAgICAgICBsb2cuZGVidWcoRE9XTkxPQURfQVJUSUZBQ1RfRkFJTEVEX1dJVEhfRVhDRVBUSU9OLCBlKTsNCi0gICAgICAgICAgICByZXR1cm4gYnVpbGRFcnJvclJlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5HRU5FUkFMX0VSUk9SKSk7DQotICAgICAgICB9DQotICAgIH0NCi19DQorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgorICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0CisgKiAKKyAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wCisgKiAKKyAqIFVubGVzcyByZXF1aXJlZCBieSBhcHBsaWNhYmxlIGxhdyBvciBhZ3JlZWQgdG8gaW4gd3JpdGluZywgc29mdHdhcmUKKyAqIGRpc3RyaWJ1dGVkIHVuZGVyIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1dGVkIG9uIGFuICJBUyBJUyIgQkFTSVMsCisgKiBXSVRIT1VUIFdBUlJBTlRJRVMgT1IgQ09ORElUSU9OUyBPRiBBTlkgS0lORCwgZWl0aGVyIGV4cHJlc3Mgb3IgaW1wbGllZC4KKyAqIFNlZSB0aGUgTGljZW5zZSBmb3IgdGhlIHNwZWNpZmljIGxhbmd1YWdlIGdvdmVybmluZyBwZXJtaXNzaW9ucyBhbmQKKyAqIGxpbWl0YXRpb25zIHVuZGVyIHRoZSBMaWNlbnNlLgorICogPT09PT09PT09PT09TElDRU5TRV9FTkQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KK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8vIERvd25sb2FkIChHRVQpIGFydGlmYWN0cworICAgIC8vICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisgICAgLyoqCisgICAgICoKKyAgICAgKiBAcGFyYW0gcmVxdWVzdElkCisgICAgICogQHBhcmFtIGluc3RhbmNlSWRIZWFkZXIKKyAgICAgKiBAcGFyYW0gYWNjZXB0CisgICAgICogQHBhcmFtIGF1dGhvcml6YXRpb24KKyAgICAgKiBAcGFyYW0gc2VydmljZU5hbWUKKyAgICAgKiBAcGFyYW0gc2VydmljZVZlcnNpb24KKyAgICAgKiBAcGFyYW0gYXJ0aWZhY3ROYW1lCisgICAgICogQHJldHVybgorICAgICAqLworICAgIEBHRVQKKyAgICBAUGF0aCgiL3NlcnZpY2VzL3tzZXJ2aWNlTmFtZX0ve3NlcnZpY2VWZXJzaW9ufS9hcnRpZmFjdHMve2FydGlmYWN0TmFtZX0iKQorICAgIEBDb25zdW1lcyhNZWRpYVR5cGUuQVBQTElDQVRJT05fSlNPTikKKyAgICBAUHJvZHVjZXMoTWVkaWFUeXBlLkFQUExJQ0FUSU9OX09DVEVUX1NUUkVBTSkKKyAgICBAT3BlcmF0aW9uKGRlc2NyaXB0aW9uID0gIkRvd25sb2FkIHNlcnZpY2UgYXJ0aWZhY3QiLCBtZXRob2QgPSAiR0VUIiwgc3VtbWFyeSA9ICJSZXR1cm5zIGRvd25sb2FkZWQgYXJ0aWZhY3QiLAorICAgICAgICAgICAgcmVzcG9uc2VzID0gQEFwaVJlc3BvbnNlKAorICAgICAgICAgICAgICAgICAgICBjb250ZW50ID0gQENvbnRlbnQoYXJyYXkgPSBAQXJyYXlTY2hlbWEoc2NoZW1hID0gQFNjaGVtYShpbXBsZW1lbnRhdGlvbiA9IFN0cmluZy5jbGFzcykpKSkpCisgICAgQEFwaVJlc3BvbnNlcyh2YWx1ZSA9IHsKKyAgICAgICAgICAgIEBBcGlSZXNwb25zZShyZXNwb25zZUNv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3JnL29wZW5lY29tcC9zZGMvYmUvZGlzdHJpYnV0aW9uL3NlcnZsZXQvRGlzdHJpYnV0aW9uU2VydmxldC5qYXZhCisrKyBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9kaXN0cmlidXRpb24vc2VydmxldC9EaXN0cmlidXRpb25TZXJ2bGV0LmphdmEKQEAgLTEsMzg1ICsxLDM4OCBAQAotLyotDQotICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NCi0gKiBTREMNCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLSAqIENvcHlyaWdodCAoQykgMjAxNyBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLSAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOw0KLSAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4NCi0gKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQNCi0gKiANCi0gKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMA0KLSAqIA0KLSAqIFVubGVzcyByZXF1aXJlZCBieSBhcHBsaWNhYmxlIGxhdyBvciBhZ3JlZWQgdG8gaW4gd3JpdGluZywgc29mdHdhcmUNC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zZXRJbm5lckVsZW1lbnQobWlzc2luZ0JvZHlSZXNwb25zZSk7DQotICAgICAgICAgICAgICAgIH0gZWxzZSB7DQotICAgICAgICAgICAgICAgICAgICByZWdpc3RyYXRpb25SZXF1ZXN0V3JhcHBlci5zZXRJbm5lckVsZW1lbnQocmVnaXN0cmF0aW9uUmVxdWVzdCk7DQotICAgICAgICAgICAgICAgIH0NCi0gICAgICAgICAgICB9IGVsc2Ugew0KLSAgICAgICAgICAgICAgICBSZXNwb25zZSBtaXNzaW5nQm9keVJlc3BvbnNlID0gYnVpbGRFcnJvclJlc3BvbnNlKGRpc3RyaWJ1dGlvbkxvZ2ljLmdldFJlc3BvbnNlRm9ybWF0TWFuYWdlcigpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5NSVNTSU5HX0JPRFkpKTsNCi0gICAgICAgICAgICAgICAgcmVzcG9uc2VXcmFwcGVyLnNldElubmVyRWxlbWVudChtaXNzaW5nQm9keVJlc3BvbnNlKTsNCi0gICAgICAgICAgICB9DQotICAgICAgICB9DQotDQotICAgIH0NCi0NCi0gICAgcHJpdmF0ZSBBdWRpdEhhbmRsZXIgYnVpbGRBdWRpdEhhbmRsZXIoSHR0cFNlcnZsZXRSZXF1ZXN0IHJlcXVlc3QsIFJlZ2lzdHJhdGlvblJlcXVlc3QgcmVnaXN0cmF0aW9uUmVxdWVzdCkgew0KLSAgICAgICAgcmV0dXJuIG5ldyBBdWRpdEhhbmRsZXIoZ2V0Q29tcG9uZW50c1V0aWxzKCksIHJlcXVlc3QuZ2V0SGVhZGVyKENvbnN0YW50cy5YX0VDT01QX0lOU1RBTkNFX0lEX0hFQURFUiksIHJlZ2lzdHJhdGlvblJlcXVlc3QpOw0KLSAgICB9DQotfQ0KKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAxNyBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKKyAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KKyAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAorICogCisgKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAorICogCisgKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlCisgKiBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0cmlidXRlZCBvbiBhbiAiQVMgSVMiIEJBU0lTLAorICogV0lUSE9VVCBXQVJSQU5USUVTIE9SIENPTkRJVElPTlMgT0YgQU5ZIEtJTkQsIGVpdGhlciBleHByZXNzIG9yIGltcGxpZWQuCisgKiBTZWUgdGhlIExpY2Vuc2UgZm9yIHRoZSBzcGVjaWZpYyBsYW5ndWFnZSBnb3Zlcm5pbmcgcGVybWlzc2lvbnMgYW5kCisgKiBsaW1pdGF0aW9ucyB1bmRlciB0aGUgTGljZW5zZS4KKyAqID09PT09PT09PT09PUxJQ0VOU0VfRU5EPT09PT09PT09PT09PT09PT09PT09PT09PT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51bGwsIHJlc3BvbnNlRm9ybWF0LmdldFN0YXR1cygpLnRvU3RyaW5nKCksIHJlc3BvbnNlRm9ybWF0LmdldEZvcm1hdHRlZE1lc3NhZ2UoKSk7CisgICAgICAgICAgICByZXR1cm4gcmVzcG9uc2U7CisgICAgICAgIH0KKworICAgICAgICB0cnkgeworICAgICAgICAgICAgRWl0aGVyPFNlcnZlckxpc3RSZXNwb25zZSwgUmVzcG9uc2VGb3JtYXQ+IGFjdGlvblJlc3BvbnNlID0gZGlzdHJpYnV0aW9uTG9naWMuZ2V0VWViU2VydmVyTGlzdCgpOworCisgICAgICAgICAgICBpZiAoYWN0aW9uUmVzcG9uc2UuaXNSaWdodCgpKSB7CisgICAgICAgICAgICAgICAgcmVzcG9uc2VGb3JtYXQgPSBhY3Rpb25SZXNwb25zZS5yaWdodCgpLnZhbHVlKCk7CisgICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBidWlsZEVycm9yUmVzcG9uc2UocmVzcG9uc2VGb3JtYXQpOworICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICByZXNwb25zZUZvcm1hdCA9IGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5PSyk7CisgICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBidWlsZE9rUmVzcG9uc2UocmVzcG9uc2VGb3JtYXQsIGFjdGlvblJlc3BvbnNlLmxlZnQoKS52YWx1ZSgpKTsKKyAgICAgICAgICAgIH0KKworICAgICAgICAgICAgZ2V0Q29tcG9uZW50c1V0aWxzKCkuYXVkaXRHZXRVZWJDbHVzdGVyKGluc3RhbmNlSWQsIHJlc3BvbnNlRm9ybWF0LmdldFN0YXR1cygpLnRvU3RyaW5nKCksIHJlc3BvbnNlRm9ybWF0LmdldEZvcm1hdHRlZE1lc3NhZ2UoKSk7CisgICAgICAgICAgICByZXR1cm4gcmVzcG9uc2U7CisKKyAgICAgICAgfSBjYXRjaCAoRXh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KCkudmFsdWUoKTsKKyAgICAgICAgICAgICAgICBpZiAocmVnaXN0cmF0aW9uUmVxdWVzdC5nZXRBcGlQdWJsaWNLZXkoKSA9PSBudWxsKSB7CisgICAgICAgICAgICAgICAgICAgIFJlc3BvbnNlIG1pc3NpbmdCb2R5UmVzcG9uc2UgPSBidWlsZEVycm9yUmVzcG9uc2UoZGlzdHJpYnV0aW9uTG9naWMuZ2V0UmVzcG9uc2VGb3JtYXRNYW5hZ2VyKCkuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLk1JU1NJTkdfUFVCTElDX0tFWSkpOworICAgICAgICAgICAgICAgICAgICByZXNwb25zZVdyYXBwZXIuc2V0SW5uZXJFbGVtZW50KG1pc3NpbmdCb2R5UmVzcG9uc2UpOworCisgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChyZWdpc3RyYXRpb25SZXF1ZXN0LmdldERpc3RyRW52TmFtZSgpID09IG51bGwpIHsKKyAgICAgICAgICAgICAgICAgICAgUmVzcG9uc2UgbWlzc2luZ0JvZHlSZXNwb25zZSA9IGJ1aWxkRXJyb3JSZXNwb25zZShkaXN0cmlidXRpb25Mb2dpYy5nZXRSZXNwb25zZUZvcm1hdE1hbmFnZXIoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuTUlTU0lOR19FTlZfTkFNRSkpOworICAgICAgICAgICAgICAgICAgICByZXNwb25zZVdyYXBwZXIuc2V0SW5uZXJFbGVtZW50KG1pc3NpbmdCb2R5UmVzcG9uc2UpOworICAgICAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgICAgIHJlZ2lzdHJhdGlvblJlcXVlc3RXcmFwcGVyLnNldElubmVyRWxlbWVudChyZWdpc3RyYXRpb25SZXF1ZXN0KTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgIFJlc3BvbnNlIG1pc3NpbmdCb2R5UmVzcG9uc2Ug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FRF9UT19DUkVBVEVfVVNFUiwgRXJyb3JTZXZlcml0eS5FUlJPUik7CiAgICAgICAgICAgICB0aHJvdyBuZXcgUG9ydGFsQVBJRXhjZXB0aW9uKEZBSUxFRF9UT19DUkVBVEVfVVNFUiwgZSk7CkBAIC0xNTMsMTQgKzE0OSwxNCBAQAogICAgICAgICAgICAgICAgIHVzZXIuc2V0TG9naW5JZChsb2dpbklkKTsKICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgVXNlciBjb252ZXJ0ZWRBc2RjVXNlciA9IEVjb21wVXNlckNvbnZlcnRlci5jb252ZXJ0RWNvbXBVc2VyVG9Vc2VyKHVzZXIpOwotICAgICAgICAgICAgaWYgKGNvbnZlcnRlZEFzZGNVc2VyID09IG51bGwpIHsKLSAgICAgICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nSW52YWxpZElucHV0RXJyb3IoUFVTSF9VU0VSLCBGQUlMRURfVE9fQ09OVkVSVF9VU0VSLCBFcnJvclNldmVyaXR5LklORk8pOwotICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZyhGQUlMRURfVE9fQ1JFQVRFX1VTRVIsIHVzZXIpOwotICAgICAgICAgICAgICAgIHRocm93IG5ldyBQb3J0YWxBUElFeGNlcHRpb24oIkZhaWxlZCB0byBjb252ZXJ0IHVzZXIgIiArIHVzZXIpOworICAgICAgICAgICAgVXNlciBhc2RjVXNlciA9IEVjb21wVXNlckNvbnZlcnRlci5jb252ZXJ0RWNvbXBVc2VyVG9Vc2VyKHVzZXIpOworICAgICAgICAgICAgaWYgKGFzZGNVc2VyID09IG51bGwpIHsKKyAgICAgICAgICAgICAgICBsb2cuZGVidWcoTlVMTF9QT0lOVEVSX1JFVFVSTkVEX0ZST01fVVNFUl9DT05WRVJURVIpOworICAgICAgICAgICAgICAgIEJlRWNvbXBFcnJvck1hbmFnZXIuZ2V0SW5zdGFuY2UoKS5sb2dJbnZhbGlkSW5wdXRFcnJ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pbmtlZExpc3Q8PigpOwotICAgICAgICAgICAgICAgICAgICBmb3IgKFVzZXIgdXNlciA6IGdldFVzZXJzUmVzcG9uc2UubGVmdCgpLnZhbHVlKCkpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIEVpdGhlcjxFY29tcFVzZXIsIFN0cmluZz4gZWNvbXBVc2VyID0gRWNvbXBVc2VyQ29udmVydGVyLmNvbnZlcnRVc2VyVG9FY29tcFVzZXIodXNlcik7Ci0gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWNvbXBVc2VyLmlzUmlnaHQoKSkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZyhGQUlMRURfVE9fQ09OVkVSVF9VU0VSMiwgdXNlcik7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgQmVFY29tcEVycm9yTWFuYWdlci5nZXRJbnN0YW5jZSgpLmxvZ0ludmFsaWRJbnB1dEVycm9yKEdFVF9VU0VSUywgIkZhaWxlZCB0byBjb252ZXJ0IFVzZXIiICsgdXNlci50b1N0cmluZygpLCBFcnJvclNldmVyaXR5LldBUk5JTkcpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwotICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChlY29tcFVzZXIubGVmdCgpLnZhbHVlKCkgPT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZyhGQUlMRURfVE9fQ09OVkVSVF9VU0VSMiwgdXNlcik7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgQmVFY29tcEVycm9yTWFuYWdlci5nZXRJbnN0YW5jZSgpLmxvZ0ludmFsaWRJbnB1dEVycm9yKEdFVF9VU0VSUywgIkZhaWxlZCB0byBjb252ZXJ0IFVzZXIiICsgdXNlci50b1N0cmluZygpLCBFcnJvclNldmVyaXR5LldBUk5JTkcpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwotICAgICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICAgICAgZWNvbXBVc2VyTGlzdC5hZGQoZWNvbXBVc2VyLmxlZnQoKS52YWx1ZSgpKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICByZXR1cm4gZWNvbXBVc2VyTGlzdDsKLSAgICAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgICAgICBsb2cuZGVidWcoRkFJTEVEX1RPX0dFVF9VU0VSUyk7Ci0gICAgICAgICAgICAgICAgICAgIEJlRWNvbXBFcnJvck1hbmFnZXIuZ2V0SW5zdGFuY2UoKS5sb2dJbnZhbGlkSW5wdXRFcnJvcihHRVRfVVNFUlMsIEZBSUxFRF9UT19HRVRfVVNFUlMsIEVycm9yU2V2ZXJpdHkuSU5GTyk7Ci0gICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBQb3J0YWxBUElFeGNlcHRpb24oRkFJTEVEX1RPX0dFVF9VU0VSUyArIGdldFVzZXJzUmVzcG9uc2UucmlnaHQoKSk7CisgICAgICAgICAgICBMaXN0PFVzZXI+IHVzZXJzID0gdXNlckJ1c2luZXNzTG9naWMuZ2V0VXNlcnNMaXN0KEpIMDAwMywgbnVsbCwgbnVsbCk7CisgICAgICAgICAgICBMaXN0PEVjb21wVXNlcj4gZWNvbXBVc2VyTGlzdCA9IG5ldyBMaW5rZWRMaXN0PD4oKTsKKyAgICAgICAgICAgIGZvciAoVXNlciB1c2VyIDogdXNlcnMpIHsKKyAgICAgICAgICAgICAgICBFaXRoZXI8RWNvbXBVc2VyLCBTdHJpbmc+IGVjb21wVXNlciA9IEVjb21wVXNlckNvbnZlcnRlci5jb252ZXJ0VXNlclRvRWNvbXBVc2VyKHVzZXIpOworICAgICAgICAgICAgICAgIGlmIChlY29tcFVzZXIuaXNSaWdodCgpKSB7CisgICAgICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZyhGQUlMRURfVE9fQ09OVkVSVF9VU0VSMiwgdXNlcik7CisgICAgICAgICAgICAgICAgICAgIEJlRWNvbXBFcnJvck1hbmFnZXIuZ2V0SW5zdGFuY2UoKS5sb2dJbnZhbGlkSW5wdXRFcnJvcihHRVRfVVNFUlMsICJGYWlsZWQgdG8gY29udmVydCBVc2VyIiArIHVzZXIudG9TdHJpbmcoKSwgRXJyb3JTZXZlcml0eS5XQVJOSU5HKTsKKyAgICAgICAgICAgICAgICAgICAgY29udGludWU7CisgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChlY29tcFVzZXIubGVmdCgpLnZhbHVlKCkgPT0gbnVsbCkgeworICAgICAgICAgICAgICAgICAgICBsb2cuZGVidWcoRkFJTEVEX1RPX0NPTlZFUlRfVVNFUjIsIHVzZXIpOworICAgICAgICAgICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nSW52YWxpZElucHV0RXJyb3IoR0VUX1VTRVJTLCAiRmFpbGVkIHRvIGNvbnZlcnQgVXNlciIgKyB1c2VyLnRvU3RyaW5nKCksIEVycm9yU2V2ZXJpdHkuV0FSTklORyk7CisgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBlY29tcFVzZXJMaXN0LmFkZChlY29tcFVzZXIubGVmdCgpLnZhbHVlKCkpOwogICAgICAgICAgICAgfQorICAgICAgICAgICAgcmV0dXJuIGVjb21wVXNlckxpc3Q7CiAgICAgICAgIH0gY2F0Y2ggKEV4Y2VwdGlvbiBlKSB7CiAgICAgICAgICAgICBsb2cuZGVidWcoRkFJTEVEX1RPX0dFVF9VU0VSUyk7CiAgICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nSW52YWxpZElucHV0RXJyb3IoR0VUX1VTRVJTLCBGQUlMRURfVE9fR0VUX1VTRVJTLCBFcnJvclNldmVyaXR5LklORk8pOwpAQCAtMjY2LD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0ludmFsaWRJbnB1dEVycm9yKEdFVF9VU0VSX1JPTEVTLCBGQUlMRURfVE9fQ09OVkVSVF9ST0xFUywgRXJyb3JTZXZlcml0eS5FUlJPUik7Ci0gICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgUG9ydGFsQVBJRXhjZXB0aW9uKGVjb21wVXNlci5yaWdodCgpLnZhbHVlKCkpOwotICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGVjb21wVXNlci5sZWZ0KCkudmFsdWUoKSA9PSBudWxsKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBsb2cuZGVidWcoIkVycm9yOiBGYWlsZWQgdG8gY29udmVydCBSb2xlcyIpOwotICAgICAgICAgICAgICAgICAgICAgICAgQmVFY29tcEVycm9yTWFuYWdlci5nZXRJbnN0YW5jZSgpLmxvZ0ludmFsaWRJbnB1dEVycm9yKEdFVF9VU0VSX1JPTEVTLCBGQUlMRURfVE9fQ09OVkVSVF9ST0xFUywgRXJyb3JTZXZlcml0eS5FUlJPUik7Ci0gICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgUG9ydGFsQVBJRXhjZXB0aW9uKCk7Ci0gICAgICAgICAgICAgICAgICAgIH0KLQotICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IExpbmtlZExpc3Q8PihlY29tcFVzZXIubGVmdCgpLnZhbHVlKCkuZ2V0Um9sZXMoKSk7Ci0gICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKEVSUk9SX0ZBSUxFRF9UT19HRVRfUk9MRVMpOwotICAgICAgICAgICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nSW52YWxpZElucHV0RXJyb3IoR0VUX1VTRVJfUk9MRVMsIEZBSUxFRF9UT19HRVRfUk9MRVMsIEVycm9yU2V2ZXJpdHkuRVJST1IpOwotICAgICAgICAgICAgICAgICAgICB0aH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aXNFbXB0eSgpKSB7DQotICAgICAgICAgICAgICAgIEVpdGhlcjxBcnRpZmFjdERlZmluaXRpb24sIFJlc3BvbnNlRm9ybWF0PiB1cGxvYWRBcnRpZmFjdEVpdGhlciA9DQotICAgICAgICAgICAgICAgICAgICAgICAgYXJ0aWZhY3RzQnVzaW5lc3NMb2dpYy51cGRhdGVBcnRpZmFjdE9uSW50ZXJmYWNlT3BlcmF0aW9uQnlSZXNvdXJjZVVVSUQoZGF0YSwgcmVxdWVzdCwNCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbXBvbmVudFR5cGVFbnVtLmZpbmRCeVBhcmFtTmFtZShhc3NldFR5cGUpLCB1dWlkLCBpbnRlcmZhY2VVVUlELCBvcGVyYXRpb25VVUlELA0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJ0aWZhY3RVVUlELCByZXNvdXJjZUNvbW1vbkluZm8sIGFydGlmYWN0c0J1c2luZXNzTG9naWMubmV3IEFydGlmYWN0T3BlcmF0aW9uSW5mbyh0cnVlLA0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmYWxzZSwgQXJ0aWZhY3RPcGVyYXRpb25FbnVtLlVQREFURSkpOw0KLSAgICAgICAgICAgICAgICBpZiAodXBsb2FkQXJ0aWZhY3RFaXRoZXIuaXNSaWdodCgpKSB7DQotICAgICAgICAgICAgICAgICAgICBsb2cuZGVidWcoRkFJTEVEX1RPX1VQREFURV9BUlRJRkFDVCk7DQotICAgICAgICAgICAgICAgICAgICByZXNwb25zZUZvcm1hdCA9IHVwbG9hZEFydGlmYWN0RWl0aGVyLnJpZ2h0KCkudmFsdWUoKTsNCi0gICAgICAgICAgICAgICAgICAgIHJlc3BvbnNlV3JhcHBlci5zZXRJbm5lckVsZW1lbnQoYnVpbGRFcnJvclJlc3BvbnNlKHJlc3BvbnNlRm9ybWF0KSk7DQotICAgICAgICAgICAgICAgIH0gZWxzZSB7DQotICAgICAgICAgICAgICAgICAgICBhcnRpZmFjdERlZmluaXRpb24gPSB1cGxvYWRBcnRpZmFjdEVpdGhlci5sZWZ0KCkudmFsdWUoKTsNCi0gICAgICAgICAgICAgICAgICAgIE9iamVjdCByZXByZXNlbnRhdGlvbiA9IFJlcHJlc2VudGF0aW9uVXRpbHMudG9SZXByZXNlbnRhdGlvbihhcnRpZmFjdERlZmluaXRpb24pOw0KLSAgICAgICAgICAgICAgICAgICAgTWFwPFN0cmluZywgU3RyaW5nPiBoZWFkZXJzID0gbmV3IEhhc2hNYXA8PigpOw0KLSAgICAgICAgICAgICAgICAgICAgaGVhZGVycy5wdXQoQ29uc3RhbnRzLk1ENV9IRUFERVIsDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgIEdlbmVyYWxVdGlsaXR5LmNhbGN1bGF0ZU1ENUJhc2U2NEVuY29kZWRCeVN0cmluZygoU3RyaW5nKSByZXByZXNlbnRhdGlvbikpOw0KLSAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2VGb3JtYXQgPSBnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuT0spOw0KLSAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2VXcmFwcGVyLnNldElubmVyRWxlbWVudChidWlsZE9rUmVzcG9uc2UoDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5PSyksIHJlcHJlc2VudGF0aW9uLCBoZWFkZXJzKSk7DQotICAgICAgICAgICAgICAgIH0NCi0gICAgICAgICAgICB9DQotICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZSkgew0KLSAgICAgICAgICAgIGZpbmFsIFN0cmluZyBtZXNzYWdlID0gImZhaWxlZCB0byB1cGRhdGUgYXJ0aWZhY3Qgb24gYSByZXNvdXJjZSBvciBzZXJ2aWNlIjsNCi0gICAgICAgICAgICBCZUVjb21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YXBwZXIuc2V0SW5uZXJFbGVtZW50KHVwbG9hZEFydGlmYWN0RWl0aGVyLnJpZ2h0KCkudmFsdWUoKSk7DQotICAgICAgICAgICAgICAgIH0gZWxzZSB7DQotICAgICAgICAgICAgICAgICAgICBhcnRpZmFjdERlZmluaXRpb24gPSB1cGxvYWRBcnRpZmFjdEVpdGhlci5sZWZ0KCkudmFsdWUoKTsNCi0gICAgICAgICAgICAgICAgICAgIE9iamVjdCByZXByZXNlbnRhdGlvbiA9IFJlcHJlc2VudGF0aW9uVXRpbHMudG9SZXByZXNlbnRhdGlvbihhcnRpZmFjdERlZmluaXRpb24pOw0KLSAgICAgICAgICAgICAgICAgICAgTWFwPFN0cmluZywgU3RyaW5nPiBoZWFkZXJzID0gbmV3IEhhc2hNYXA8PigpOw0KLSAgICAgICAgICAgICAgICAgICAgaGVhZGVycy5wdXQoQ29uc3RhbnRzLk1ENV9IRUFERVIsDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgIEdlbmVyYWxVdGlsaXR5LmNhbGN1bGF0ZU1ENUJhc2U2NEVuY29kZWRCeVN0cmluZygoU3RyaW5nKSByZXByZXNlbnRhdGlvbikpOw0KLSAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2VXcmFwcGVyLnNldElubmVyRWxlbWVudChnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuT0spKTsNCi0gICAgICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gYnVpbGRPa1Jlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5PSyksIHJlcHJlc2VudGF0aW9uLA0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWFkZXJzKTsNCi0gICAgICAgICAgICAgICAgfQ0KLSAgICAgICAgICAgIH0NCi0gICAgICAgIH0gY2F0Y2ggKElPRXhjZXB0aW9uIGUpIHsNCi0gICAgICAg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ICAgICAgICAgICAgICAgIHJlc291cmNlSW5zdGFuY2VOYW1lLCBhcnRpZmFjdHNCdXNpbmVzc0xvZ2ljLm5ldyBBcnRpZmFjdE9wZXJhdGlvbkluZm8odHJ1ZSwgZmFsc2UsDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFydGlmYWN0T3BlcmF0aW9uRW51bS5DUkVBVEUpKTsNCi0gICAgICAgICAgICAgICAgaWYgKHVwbG9hZEFydGlmYWN0RWl0aGVyLmlzUmlnaHQoKSkgew0KLSAgICAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJmYWlsZWQgdG8gdXBsb2FkIGFydGlmYWN0Iik7DQotICAgICAgICAgICAgICAgICAgICByZXNwb25zZUZvcm1hdCA9IHVwbG9hZEFydGlmYWN0RWl0aGVyLnJpZ2h0KCkudmFsdWUoKTsNCi0gICAgICAgICAgICAgICAgICAgIHJlc3BvbnNlV3JhcHBlci5zZXRJbm5lckVsZW1lbnQoYnVpbGRFcnJvclJlc3BvbnNlKHJlc3BvbnNlRm9ybWF0KSk7DQotICAgICAgICAgICAgICAgIH0gZWxzZSB7DQotICAgICAgICAgICAgICAgICAgICBPYmplY3QgcmVwcmVzZW50YXRpb24gPSBSZXByZXNlbnRhdGlvblV0aWxzLnRvUmVwcmVzZW50YXRpb24odXBsb2FkQXJ0aWZhY3RFaXRoZXIubGVmdCgpLnZhbHVlKCkpOw0KLSAgICAgICAgICAgICAgICAgICAgTWFwPFN0cmluZywgU3RyaW5nPiBoZWFkZXJzID0gbmV3IEhhc2hNYXA8PigpOw0KLSAgICAgICAgICAgICAgICAgICAgaGVhZGVycy5wdXQoQ29uc3RhbnRzLk1ENV9IRUFERVIsDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgIEdlbmVyYWxVdGlsaXR5LmNhbGN1bGF0ZU1ENUJhc2U2NEVuY29kZWRCeVN0cmluZygoU3RyaW5nKSByZXByZXNlbnRhdGlvbikpOw0KLSAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2VGb3JtYXQgPSBnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuT0spOw0KLSAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2VXcmFwcGVyLnNldElubmVyRWxlbWVudChidWlsZE9rUmVzcG9uc2UoDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5PSyksIHJlcHJlc2VudGF0aW9uLCBoZWFkZXJzKSk7DQotICAgICAgICAgICAgICAgIH0NCi0gICAgICAgICAgICB9DQotICAgICAgICB9IGNhdGNoIChJT0V4Y2VwdGlvbiBlKSB7DQotICAgICAgICAgICAgZmluYWwgU3RyaW5nIG1lc3NhZ2UgPSAiZmFpbGVkIHRvIHVwbG9hZCBhcnRpZmFjdCB0byBhIHJlc291cmNlIGluc3RhbmNlIjsNCi0gICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nQmVSZXN0QXBpR2VuZXJhbEVycm9yKG1lc3NhZ2UpOw0KLSAgICAgICAgICAgIGxvZy5kZWJ1ZyhtZXNzYWdlLCBlKTsNCi0gICAgICAgICAgICByZXNwb25zZUZvcm1hdCA9IGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5HRU5FUkFMX0VSUk9SKTsNCi0gICAgICAgICAgICByZXNwb25zZVdyYXBwZXIuc2V0SW5uZXJFbGVtZW50KGJ1aWxkRXJyb3JSZXNwb25zZShyZXNwb25zZUZvcm1hdCkpOw0KLSAgICAgICAgfSBjYXRjaCAoQ29tcG9uZW50RXhjZXB0aW9uIGUpIHsNCi0gICAgICAgICAgICByZXNwb25zZUZvcm1hdCA9IGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KGUpOw0KL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c3QsIGNvbXBvbmVudFR5cGUsIHV1aWQsDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcnRpZmFjdFVVSUQsIHJlc291cmNlQ29tbW9uSW5mbywgYXJ0aWZhY3RzQnVzaW5lc3NMb2dpYy5uZXcgQXJ0aWZhY3RPcGVyYXRpb25JbmZvKHRydWUsDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZhbHNlLCBBcnRpZmFjdE9wZXJhdGlvbkVudW0uVVBEQVRFKSk7DQotICAgICAgICAgICAgICAgIGlmICh1cGxvYWRBcnRpZmFjdEVpdGhlci5pc1JpZ2h0KCkpIHsNCi0gICAgICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZyhGQUlMRURfVE9fVVBEQVRFX0FSVElGQUNUKTsNCi0gICAgICAgICAgICAgICAgICAgIHJlc3BvbnNlRm9ybWF0ID0gdXBsb2FkQXJ0aWZhY3RFaXRoZXIucmlnaHQoKS52YWx1ZSgpOw0KLSAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2VXcmFwcGVyLnNldElubmVyRWxlbWVudChidWlsZEVycm9yUmVzcG9uc2UocmVzcG9uc2VGb3JtYXQpKTsNCi0gICAgICAgICAgICAgICAgfSBlbHNlIHsNCi0gICAgICAgICAgICAgICAgICAgIE9iamVjdCByZXByZXNlbnRhdGlvbiA9IFJlcHJlc2VudGF0aW9uVXRpbHMudG9SZXByZXNlbnRhdGlvbih1cGxvYWRBcnRpZmFjdEVpdGhlci5sZWZ0KCkudmFsdWUoKSk7DQotICAgICAgICAgICAgICAgICAgICBNYXA8U3RyaW5nLCBTdHJpbmc+IGhlYWRlcnMgPSBuZXcgSGFzaE1hcDw+KCk7DQotICAgICAgICAgICAgICAgICAgICBoZWFkZXJzLnB1dChDb25zdGFudHMuTUQ1X0hFQURFUiwNCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgR2VuZXJhbFV0aWxpdHkuY2FsY3VsYXRlTUQ1QmFzZTY0RW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lRm9ybWF0KSk7DQotICAgICAgICAgICAgICAgIH0gZWxzZSB7DQotICAgICAgICAgICAgICAgICAgICBPYmplY3QgcmVwcmVzZW50YXRpb24gPSBSZXByZXNlbnRhdGlvblV0aWxzLnRvUmVwcmVzZW50YXRpb24odXBsb2FkQXJ0aWZhY3RFaXRoZXIubGVmdCgpLnZhbHVlKCkpOw0KLSAgICAgICAgICAgICAgICAgICAgTWFwPFN0cmluZywgU3RyaW5nPiBoZWFkZXJzID0gbmV3IEhhc2hNYXA8PigpOw0KLSAgICAgICAgICAgICAgICAgICAgaGVhZGVycy5wdXQoQ29uc3RhbnRzLk1ENV9IRUFERVIsDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgIEdlbmVyYWxVdGlsaXR5LmNhbGN1bGF0ZU1ENUJhc2U2NEVuY29kZWRCeVN0cmluZygoU3RyaW5nKSByZXByZXNlbnRhdGlvbikpOw0KLSAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2VGb3JtYXQgPSBnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuT0spOw0KLSAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2VXcmFwcGVyLnNldElubmVyRWxlbWVudChidWlsZE9rUmVzcG9uc2UoDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5PSyksIHJlcHJlc2VudGF0aW9uLCBoZWFkZXJzKSk7DQotICAgICAgICAgICAgICAgIH0NCi0gICAgICAgICAgICB9DQotICAgICAgICB9IGNhdGNoIChJT0V4Y2VwdGlvbiBlKSB7DQotICAgICAgICAgICAgZmluYWwgU3RyaW5nIG1lc3NhZ2UgPSAiZmFpbGVkIHRvIHVwZGF0ZSBhcnRpZmFjdCBvbiByZXNvdXJjZSBpbnN0YW5jZSI7DQotICAgICAgICAgICAgQmVFY29tcEVycm9yTWFuYW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gICAgICAgICAgICAgbG9nLmRlYnVnKCJmYWlsZWQgdG8gZGVsZXRlIGFydGlmYWN0Iik7DQotICAgICAgICAgICAgICAgICAgICByZXNwb25zZUZvcm1hdCA9IHVwbG9hZEFydGlmYWN0RWl0aGVyLnJpZ2h0KCkudmFsdWUoKTsNCi0gICAgICAgICAgICAgICAgICAgIHJlc3BvbnNlV3JhcHBlci5zZXRJbm5lckVsZW1lbnQoYnVpbGRFcnJvclJlc3BvbnNlKHJlc3BvbnNlRm9ybWF0KSk7DQotICAgICAgICAgICAgICAgIH0gZWxzZSB7DQotICAgICAgICAgICAgICAgICAgICBPYmplY3QgcmVwcmVzZW50YXRpb24gPSBSZXByZXNlbnRhdGlvblV0aWxzLnRvUmVwcmVzZW50YXRpb24odXBsb2FkQXJ0aWZhY3RFaXRoZXIubGVmdCgpLnZhbHVlKCkpOw0KLSAgICAgICAgICAgICAgICAgICAgTWFwPFN0cmluZywgU3RyaW5nPiBoZWFkZXJzID0gbmV3IEhhc2hNYXA8PigpOw0KLSAgICAgICAgICAgICAgICAgICAgaGVhZGVycy5wdXQoQ29uc3RhbnRzLk1ENV9IRUFERVIsDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgIEdlbmVyYWxVdGlsaXR5LmNhbGN1bGF0ZU1ENUJhc2U2NEVuY29kZWRCeVN0cmluZygoU3RyaW5nKSByZXByZXNlbnRhdGlvbikpOw0KLSAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2VGb3JtYXQgPSBnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuT0spOw0KLSAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2VXcmFwcGVyLnNldElubmVyRWxlbWVudChidWlsZE9rUmVzcG9uc2UoDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5PSyksIHJlcHJl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gICAgICAgICB9IGVsc2Ugew0KLSAgICAgICAgICAgICAgICAgICAgT2JqZWN0IHJlcHJlc2VudGF0aW9uID0gUmVwcmVzZW50YXRpb25VdGlscy50b1JlcHJlc2VudGF0aW9uKHVwbG9hZEFydGlmYWN0RWl0aGVyLmxlZnQoKS52YWx1ZSgpKTsNCi0gICAgICAgICAgICAgICAgICAgIE1hcDxTdHJpbmcsIFN0cmluZz4gaGVhZGVycyA9IG5ldyBIYXNoTWFwPD4oKTsNCi0gICAgICAgICAgICAgICAgICAgIGhlYWRlcnMucHV0KENvbnN0YW50cy5NRDVfSEVBREVSLA0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBHZW5lcmFsVXRpbGl0eS5jYWxjdWxhdGVNRDVCYXNlNjRFbmNvZGVkQnlTdHJpbmcoKFN0cmluZykgcmVwcmVzZW50YXRpb24pKTsNCi0gICAgICAgICAgICAgICAgICAgIHJlc3BvbnNlRm9ybWF0ID0gZ2V0Q29tcG9uZW50c1V0aWxzKCkuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLk9LKTsNCi0gICAgICAgICAgICAgICAgICAgIHJlc3BvbnNlV3JhcHBlci5zZXRJbm5lckVsZW1lbnQoYnVpbGRPa1Jlc3BvbnNlKA0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuT0spLCByZXByZXNlbnRhdGlvbiwgaGVhZGVycykpOw0KLSAgICAgICAgICAgICAgICB9DQotICAgICAgICAgICAgfQ0KLSAgICAgICAgfSBjYXRjaCAoSU9FeGNlcHRpb24gZSkgew0KLSAgICAgICAgICAgIGZpbmFsIFN0cmluZyBtZXNzYWdlID0gImZhaWxlZCB0byBkZWxldGUgYW4gYXJ0aWZhY3Qgb2YgYSByZXNvdXJjZSBpbnN0YW5jZSI7DQotICAgICAgICAgICAgQmVFY29tcEVycm9yTWFuYWdl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ICAgICAgICAgIHJlc3BvbnNlV3JhcHBlci5zZXRJbm5lckVsZW1lbnQoYnVpbGRPa1Jlc3BvbnNlKHJlc3BvbnNlRm9ybWF0LCBpcywgaGVhZGVycykpOw0KLSAgICAgICAgICAgICAgICB9DQotICAgICAgICAgICAgfQ0KLSAgICAgICAgfSBjYXRjaCAoQ29tcG9uZW50RXhjZXB0aW9uIGUpIHsNCi0gICAgICAgICAgICByZXNwb25zZUZvcm1hdCA9IGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KGUpOw0KLSAgICAgICAgICAgIHJlc3BvbnNlV3JhcHBlci5zZXRJbm5lckVsZW1lbnQoYnVpbGRFcnJvclJlc3BvbnNlKHJlc3BvbnNlRm9ybWF0KSk7DQotICAgICAgICB9IGZpbmFsbHkgew0KLSAgICAgICAgICAgIGdldENvbXBvbmVudHNVdGlscygpLmF1ZGl0RXh0ZXJuYWxEb3dubG9hZEFydGlmYWN0KHJlc3BvbnNlRm9ybWF0LA0KLSAgICAgICAgICAgICAgICAgICAgbmV3IFJlc291cmNlQ29tbW9uSW5mbyhyZXNvdXJjZUluc3RhbmNlTmFtZSwgY29tcG9uZW50VHlwZVZhbHVlKSwNCi0gICAgICAgICAgICAgICAgICAgIG5ldyBEaXN0cmlidXRpb25EYXRhKGluc3RhbmNlSWRIZWFkZXIsIHJlcXVlc3RVUkkpLCByZXF1ZXN0SWQsIGFydGlmYWN0VVVJRCwgdXNlcklkKTsNCi0gICAgICAgIH0NCi0gICAgICAgIHJldHVybiByZXNwb25zZVdyYXBwZXIuZ2V0SW5uZXJFbGVtZW50KCk7DQotICAgIH0NCi19DQorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgorICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0CisgKgorICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKKyAqCisgKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlCisgKiBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0cmlidXRlZCBvbiBhbiAiQVMgSVMiIEJBU0lTLAorICogV0lUSE9VVCBXQVJSQU5USUVTIE9SIENPTkRJVElPTlMgT0YgQU5ZIEtJTkQsIGVpdGhlciBleHByZXNzIG9yIGltcGxpZWQuCisgKiBTZWUgdGhlIExpY2Vuc2UgZm9yIHRoZSBzcGVjaWZpYyBsYW5ndWFnZSBnb3Zlcm5pbmcgcGVybWlzc2lvbnMgYW5kCisgKiBsaW1pdGF0aW9ucyB1bmRlciB0aGUgTGljZW5zZS4KKyAqID09PT09PT09PT09PUxJQ0VOU0VfRU5EPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKi8KKworcGFja2FnZSBvcmcub3BlbmVjb21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VwZGF0ZUFydGlmYWN0T25JbnRlcmZhY2VPcGVyYXRpb25CeVJlc291cmNlVVVJRChkYXRhLCByZXF1ZXN0LCBDb21wb25lbnRUeXBlRW51bQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5maW5kQnlQYXJhbU5hbWUoYXNzZXRUeXBlKSwgdXVpZCwgaW50ZXJmYWNlVVVJRCwgb3BlcmF0aW9uVVVJRCwgYXJ0aWZhY3RVVUlELAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvdXJjZUNvbW1vbkluZm8sIGFydGlmYWN0c0J1c2luZXNzTG9naWMubmV3IEFydGlmYWN0T3BlcmF0aW9uSW5mbyh0cnVlLCBmYWxzZSwgQXJ0aWZhY3RPcGVyYXRpb25FbnVtLlVQREFURSkpOworICAgICAgICAgICAgICAgIGlmICh1cGxvYWRBcnRpZmFjdEVpdGhlci5pc1JpZ2h0KCkpIHsKKyAgICAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKEZBSUxFRF9UT19VUERBVEVfQVJUSUZBQ1QpOworICAgICAgICAgICAgICAgICAgICByZXNwb25zZUZvcm1hdCA9IHVwbG9hZEFydGlmYWN0RWl0aGVyLnJpZ2h0KCkudmFsdWUoKTsKKyAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2VXcmFwcGVyLnNldElubmVyRWxlbWVudChidWlsZEVycm9yUmVzcG9uc2UocmVzcG9uc2VGb3JtYXQpKTsKKyAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICBhcnRpZmFjdERlZmluaXRpb249dXBsb2FkQXJ0aWZhY3RFaXRoZXIubGVmdCgpLnZhbHVlKCk7CisgICAgICAgICAgICAgICAgICAgIE9iamVjdCByZXByZXNlbnRhdGlvbiA9IFJlcHJlc2VudGF0aW9uVXRpbHMudG9SZXByZXNlbnRhdGlvbihhcnRpZmFjdERlZmluaXRpb24pOworICAgICAgICAgICAgICAgICAgICBNYXA8U3RyaW5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cmNlQ29tbW9uSW5mbyByZXNvdXJjZUNvbW1vbkluZm8gPSBuZXcgUmVzb3VyY2VDb21tb25JbmZvKGNvbXBvbmVudFR5cGVWYWx1ZSk7CisKKyAgICAgICAgaWYgKGNvbXBvbmVudFR5cGUgPT0gbnVsbCkgeworICAgICAgICAgICAgbG9nLmRlYnVnKCJ1cGxvYWRBcnRpZmFjdDogYXNzZXRUeXBlIHBhcmFtZXRlciB7fSBpcyBub3QgdmFsaWQiLCBhc3NldFR5cGUpOworICAgICAgICAgICAgcmVzcG9uc2VXcmFwcGVyLnNldElubmVyRWxlbWVudChnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuSU5WQUxJRF9DT05URU5UKSk7CisgICAgICAgIH0KKyAgICAgICAgaWYgKHJlc3BvbnNlV3JhcHBlci5pc0VtcHR5KCkpIHsKKyAgICAgICAgICAgIHZhbGlkYXRlWEVDT01QSW5zdGFuY2VJREhlYWRlcihpbnN0YW5jZUlkSGVhZGVyLCByZXNwb25zZVdyYXBwZXIpOworICAgICAgICB9CisgICAgICAgIGlmIChyZXNwb25zZVdyYXBwZXIuaXNFbXB0eSgpICkgeworICAgICAgICAgICAgdmFsaWRhdGVIdHRwQ3NwVXNlcklkSGVhZGVyKHVzZXJJZCwgcmVzcG9uc2VXcmFwcGVyKTsKKyAgICAgICAgfQorICAgICAgICBSZXNwb25zZSByZXNwb25zZSA9IG51bGw7CisgICAgICAgIEFydGlmYWN0RGVmaW5pdGlvbiBhcnRpZmFjdERlZmluaXRpb24gPSBudWxsOworICAgICAgICB0cnkgeworICAgICAgICAgICAgaWYgKHJlc3BvbnNlV3JhcHBlci5pc0VtcHR5KCkpIHsKKyAgICAgICAgICAgICAgICBhcnRpZmFjdERlZmluaXRpb24gPSBhcnRpZmFjdHNCdXNpbmVzc0xvZ2ljLnVwbG9hZEFydGlmYWN0VG9Db21wb25lbnRCeVVVSUQoZGF0YSwgcmVxdWVzdCwgY29tcG9uZW50VHlwZSwgdXVpZCwKKyAgICAgICAgICAgICAgICAgICAgICAgIHJlc291cmNlQ29tbW9uSW5mbywgYXJ0aWZhY3RzQnVzaW5lc3NMb2dpYy5uZXcgQXJ0aWZhY3RPcGVyYXRpb25JbmZvKHRydWUsIGZhbHNlLCBBcnRpZmFjdE9wZXJhdGlvbkVudW0uQ1JFQVRFKSk7CisgICAgICAgICAgICAgICAgT2JqZWN0IHJlcHJlc2VudGF0aW9uID0gUmVwcmVzZW50YXRpb25VdGlscy50b1JlcHJlc2VudGF0aW9uKGFydGlmYWN0RGVmaW5pdGlvbik7CisgICAgICAgICAgICAgICAgTWFwPFN0cmluZywgU3RyaW5nPiBoZWFkZXJzID0gbmV3IEhhc2hNYXA8PigpOworICAgICAgICAgICAgICAgIGhlYWRlcnMucHV0KENvbnN0YW50cy5NRDVfSEVBREVSLCBHZW5lcmFsVXRpbGl0eS5jYWxjdWxhdGVNRDVCYXNlNjRFbmNvZGVkQnlTdHJpbmcoKFN0cmluZykgcmVwcmVzZW50YXRpb24pKTsKKyAgICAgICAgICAgICAgICByZXNwb25zZVdyYXBwZXIuc2V0SW5uZXJFbGVtZW50KGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5PSykpOworICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gYnVpbGRPa1Jlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5PSyksIHJlcHJlc2VudGF0aW9uLCBoZWFkZXJzKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfSBjYXRjaCAoSU9FeGNlcHRpb24gZSkgeworICAgICAgICAgICAgZmluYWwgU3RyaW5nIG1lc3NhZ2UgPSAiZmFpbGVkIHRvIHVwbG9hZCBhcnRpZmFjdCB0byBhIHJlc291cmNlIG9yIHNlcnZpY2UiOworICAgICAgICAgICAgQmVFY29tcEV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5KCkpKSB7CisgICAgICAgICAgICBsb2cuZGVidWcoInVwbG9hZEFydGlmYWN0OiBNaXNzaW5nIFVTRVJfSUQgaGVhZGVyIik7CisgICAgICAgICAgICByZXNwb25zZUZvcm1hdCA9IGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5NSVNTSU5HX1VTRVJfSUQpOworICAgICAgICAgICAgcmVzcG9uc2VXcmFwcGVyLnNldElubmVyRWxlbWVudChidWlsZEVycm9yUmVzcG9uc2UocmVzcG9uc2VGb3JtYXQpKTsKKyAgICAgICAgfQorICAgICAgICB0cnkgeworICAgICAgICAgICAgaWYgKHJlc3BvbnNlV3JhcHBlci5pc0VtcHR5KCkpIHsKKyAgICAgICAgICAgICAgICBhcnRpZmFjdERlZmluaXRpb24gPSBhcnRpZmFjdHNCdXNpbmVzc0xvZ2ljLnVwbG9hZEFydGlmYWN0VG9SaUJ5VVVJRChkYXRhLCByZXF1ZXN0LCBjb21wb25lbnRUeXBlLCB1dWlkLCByZXNvdXJjZUluc3RhbmNlTmFtZSwKKyAgICAgICAgICAgICAgICAgICAgICAgIGFydGlmYWN0c0J1c2luZXNzTG9naWMubmV3IEFydGlmYWN0T3BlcmF0aW9uSW5mbyh0cnVlLCBmYWxzZSwgQXJ0aWZhY3RPcGVyYXRpb25FbnVtLkNSRUFURSkpOworICAgICAgICAgICAgICAgIE9iamVjdCByZXByZXNlbnRhdGlvbiA9IFJlcHJlc2VudGF0aW9uVXRpbHMudG9SZXByZXNlbnRhdGlvbihhcnRpZmFjdERlZmluaXRpb24pOworICAgICAgICAgICAgICAgIE1hcDxTdHJpbmcsIFN0cmluZz4gaGVhZGVycyA9IG5ldyBIYXNoTWFwPD4oKTsKKyAgICAgICAgICAgICAgICBoZWFkZXJzLnB1dChDb25zdGFudHMuTUQ1X0hFQURFUiwgR2VuZXJhbFV0aWxpdHkuY2FsY3VsYXRlTUQ1QmFzZTY0RW5jb2RlZEJ5U3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bmFnZXIuZ2V0SW5zdGFuY2UoKS5sb2dCZVJlc3RBcGlHZW5lcmFsRXJyb3IobWVzc2FnZSk7CisgICAgICAgICAgICBsb2cuZGVidWcobWVzc2FnZSwgZSk7CisgICAgICAgICAgICByZXNwb25zZUZvcm1hdCA9IGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5HRU5FUkFMX0VSUk9SKTsKKyAgICAgICAgICAgIHJlc3BvbnNlV3JhcHBlci5zZXRJbm5lckVsZW1lbnQoYnVpbGRFcnJvclJlc3BvbnNlKHJlc3BvbnNlRm9ybWF0KSk7CisgICAgICAgIH0gIGNhdGNoIChDb21wb25lbnRFeGNlcHRpb24gZSl7CisgICAgICAgICAgICByZXNwb25zZUZvcm1hdCA9IGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KGUpOworICAgICAgICAgICAgdGhyb3cgZTsKKyAgICAgICAgfQorICAgICAgICBmaW5hbGx5eworICAgICAgICAgICAgZ2V0Q29tcG9uZW50c1V0aWxzKCkuYXVkaXRFeHRlcm5hbENydWRBcGkocmVzcG9uc2VGb3JtYXQsIEF1ZGl0aW5nQWN0aW9uRW51bS5BUlRJRkFDVF9VUERBVEVfQllfQVBJLCByZXNvdXJjZUNvbW1vbkluZm8sCisgICAgICAgICAgICAgICAgICAgIHJlcXVlc3QsIGFydGlmYWN0RGVmaW5pdGlvbiwgYXJ0aWZhY3RVVUlEKTsKKyAgICAgICAgfQorICAgICAgICByZXR1cm4gcmVzcG9uc2VXcmFwcGVyLmdldElubmVyRWxlbWVudCgpOworICAgIH0KKworICAgIC8qKgorICAgICAqIGRlbGV0ZXMgYW4gYXJ0aWZhY3Qgb2YgYSByZXNvdXJjZSBvciBzZXJ2aWNlCisgICAgICovCisgICAgQERFTEVURQorICAgIEBQYXRoKCIve2Fzc2V0VHlwZX0ve3V1aWR9L2FydGlmYWN0cy97YXJ0aWZhY3RVVUlEfSIpCisgICAgQFByb2R1Y2VzKE1lZGlhVHlwZS5BUFBMSUNBVElPTl9KU09OKQorICAgIEBPcGVyYXRpb24oZGVzY3JpcHRpb24gPSAiZGVsZXRlcyBhbiBhcnRpZmFjdCBvZiBhIHJlc291cmNlIG9yIHNlcnZpY2UiLCBtZXRob2QgPSAiREVMRVRFIiwKKyAgICAgICAgICAgIHN1bW1hcnkgPSAiZGVsZXRlcyBhbiBhcnRpZmFjdCBvZiBhIHJlc291cmNlIG9yIHNlcnZpY2UiLCByZXNwb25zZXMgPSBAQXBpUmVzcG9uc2UoCisgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQgPSBAQ29udGVudChhcnJheSA9IEBBcnJheVNjaGVtYShzY2hlbWEgPSBAU2NoZW1hKGltcGxlbWVudGF0aW9uID0gUmVzcG9uc2UuY2xhc3MpKSkpKQorICAgIEBBcGlSZXNwb25zZXModmFsdWUgPSB7CisgICAgICAgICAgICBAQXBpUmVzcG9uc2UocmVzcG9uc2VDb2RlID0gIjIwMCIsIGRlc2NyaXB0aW9uID0gIkFydGlmYWN0IGRlbGV0ZWQiLAorICAgICAgICAgICAgICAgICAgICBjb250ZW50ID0gQENvbnRlbnQoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJyYXkgPSBAQXJyYXlTY2hlbWEoc2NoZW1hID0gQFNjaGVtYShpbXBsZW1lbnRhdGlvbiA9IEFydGlmYWN0RGVmaW5pdGlvbi5jbGFzcykpKSksCisgICAgICAgICAgICBAQXBpUmVzcG9uc2UocmVzcG9uc2VDb2RlID0gIjQwMCIsIGRlc2NyaXB0aW9uID0gIk1pc3NpbmcgICdYLUVDT01QLUluc3RhbmNlSUQnICBIVFRQIGhlYWRlciAtIFBPTDUwMDEiKSwKKyAgICAgICAgICAgIEBBcGlSZXNwb25zZShyZXNwb25zZUNvZGUgPSAiNDAxIiwKKyAgICAgICAgICAgICAgICAgICAgZGVzY3JpcHRpb24gPSAiRUNPTVAgY29tcG9uZW50ICBzaG91bGQ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SA9PSBudWxsKSB7CisgICAgICAgICAgICBsb2cuZGVidWcoImRlbGV0ZUFydGlmYWN0OiBhc3NldFR5cGUgcGFyYW1ldGVyIHt9IGlzIG5vdCB2YWxpZCIsIGFzc2V0VHlwZSk7CisgICAgICAgICAgICByZXNwb25zZUZvcm1hdCA9IGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5JTlZBTElEX0NPTlRFTlQpOworICAgICAgICAgICAgcmVzcG9uc2VXcmFwcGVyLnNldElubmVyRWxlbWVudChidWlsZEVycm9yUmVzcG9uc2UocmVzcG9uc2VGb3JtYXQpKTsKKyAgICAgICAgfQorICAgICAgICBpZiAocmVzcG9uc2VXcmFwcGVyLmlzRW1wdHkoKSAmJiAoaW5zdGFuY2VJZEhlYWRlciA9PSBudWxsIHx8IGluc3RhbmNlSWRIZWFkZXIuaXNFbXB0eSgpKSkgeworICAgICAgICAgICAgbG9nLmRlYnVnKCJkZWxldGVBcnRpZmFjdDogTWlzc2luZyBYLUVDT01QLUluc3RhbmNlSUQgaGVhZGVyIik7CisgICAgICAgICAgICByZXNwb25zZUZvcm1hdCA9IGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5NSVNTSU5HX1hfRUNPTVBfSU5TVEFOQ0VfSUQpOworICAgICAgICAgICAgcmVzcG9uc2VXcmFwcGVyLnNldElubmVyRWxlbWVudChidWlsZEVycm9yUmVzcG9uc2UocmVzcG9uc2VGb3JtYXQpKTsKKyAgICAgICAgfQorICAgICAgICBpZiAocmVzcG9uc2VXcmFwcGVyLmlzRW1wdHkoKSAmJiAodXNlcklkID09IG51bGwgfHwgdXNlcklkLmlzRW1wdHkoKSkpIHsKKyAgICAgICAgICAgIGxvZy5kZWJ1ZygiZGVsZXRlQXJ0aWZhY3Q6IE1pc3NpbmcgVVNFUl9JRCBoZWFkZXIiKTsKKyAgICAgICAgICAgIHJlc3Bv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Avc2RjL2JlL2V4dGVybmFsYXBpL3NlcnZsZXQvQXNzZXRzRGF0YVNlcnZsZXQuamF2YQorKysgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvZXh0ZXJuYWxhcGkvc2VydmxldC9Bc3NldHNEYXRhU2VydmxldC5qYXZhCkBAIC0xLDQ1MSArMSw0NDQgQEAKLS8qLQ0KLSAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogU0RDDQotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NCi0gKiBDb3B5cmlnaHQgKEMpIDIwMTcgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NCi0gKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsNCi0gKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuDQotICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0DQotICogDQotICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjANCi0gKiANCi0gKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlDQotICogZGlzdHJpYnV0ZWQgdW5kZXIg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AgZmlsdGVycy5wdXQoRmlsdGVyS2V5RW51bS5TVUJfQ0FURUdPUlksIHN1YkNhdGVnb3J5KTsNCi0gICAgICAgICAgICB9DQotICAgICAgICAgICAgaWYgKGRpc3RyaWJ1dGlvblN0YXR1cyAhPSBudWxsKSB7DQotICAgICAgICAgICAgICAgIGZpbHRlcnMucHV0KEZpbHRlcktleUVudW0uRElTVFJJQlVUSU9OX1NUQVRVUywgZGlzdHJpYnV0aW9uU3RhdHVzKTsNCi0gICAgICAgICAgICB9DQotICAgICAgICAgICAgaWYgKHJlc291cmNlVHlwZSAhPSBudWxsKSB7DQotICAgICAgICAgICAgICAgIFJlc291cmNlVHlwZUVudW0gcmVzb3VyY2VUeXBlRW51bSA9IFJlc291cmNlVHlwZUVudW0uZ2V0VHlwZUlnbm9yZUNhc2UocmVzb3VyY2VUeXBlKTsNCi0gICAgICAgICAgICAgICAgaWYgKHJlc291cmNlVHlwZUVudW0gPT0gbnVsbCkgew0KLSAgICAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJnZXRBc3NldExpc3Q6IEFzc2V0IEZldGNoaW5nIEZhaWxlZC4gSW52YWxpZCByZXNvdXJjZSB0eXBlIHdhcyByZWNlaXZlZCIpOw0KLSAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2VGb3JtYXQgPSBnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuSU5WQUxJRF9DT05URU5UKTsNCi0gICAgICAgICAgICAgICAgICAgIGdldENvbXBvbmVudHNVdGlscygpLmF1ZGl0RXh0ZXJuYWxHZXRBc3NldExpc3QocmVzcG9uc2VGb3JtYXQsIGF1ZGl0aW5nQWN0aW9uRW51bSwgZGlzdHJpYnV0aW9uRGF0YSwNCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdElkKTsNCi0gICAgICAgICAgICAgICAgICAgIHJldHVybiBidWlsZEVycm9yUmVzcG9uc2UocmVzcG9uc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AgICBnZXRDb21wb25lbnRzVXRpbHMoKS5hdWRpdEV4dGVybmFsR2V0QXNzZXQocmVzcG9uc2VGb3JtYXQsIGF1ZGl0aW5nQWN0aW9uRW51bSwgZGlzdHJpYnV0aW9uRGF0YSwNCi0gICAgICAgICAgICAgICAgICAgIHJlc291cmNlQ29tbW9uSW5mbywgcmVxdWVzdElkLCB1dWlkKTsNCi0gICAgICAgICAgICByZXR1cm4gcmVzcG9uc2U7DQotICAgICAgICB9DQotICAgIH0NCi0NCi0NCi0gICAgcHJpdmF0ZSBTdHJpbmcgcmVtb3ZlRHVwbGljYXRlU2xhc2hTZXBhcmF0b3IoU3RyaW5nIHJlcXVlc3RVcmkpIHsNCi0gICAgICAgIHJldHVybiByZXF1ZXN0VXJpLnN1YnN0cmluZygwLCByZXF1ZXN0VXJpLmxlbmd0aCgpIC0gMSk7DQotICAgIH0NCi0NCi0NCi19DQorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgorICogWW91IG1heSBvYnRhaW4gYS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QgPSBnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuTUlTU0lOR19YX0VDT01QX0lOU1RBTkNFX0lEKTsKKyAgICAgICAgICAgIGdldENvbXBvbmVudHNVdGlscygpLmF1ZGl0RXh0ZXJuYWxHZXRBc3NldExpc3QocmVzcG9uc2VGb3JtYXQsIGF1ZGl0aW5nQWN0aW9uRW51bSwgZGlzdHJpYnV0aW9uRGF0YSwgcmVxdWVzdElkKTsKKyAgICAgICAgICAgIHJldHVybiBidWlsZEVycm9yUmVzcG9uc2UocmVzcG9uc2VGb3JtYXQpOworICAgICAgICB9CisKKyAgICAgICAgdHJ5IHsKKyAgICAgICAgICAgIE1hcDxGaWx0ZXJLZXlFbnVtLCBTdHJpbmc+IGZpbHRlcnMgPSBuZXcgRW51bU1hcDw+KEZpbHRlcktleUVudW0uY2xhc3MpOworCisgICAgICAgICAgICBpZiAoY2F0ZWdvcnkgIT0gbnVsbCkgeworICAgICAgICAgICAgICAgIGZpbHRlcnMucHV0KEZpbHRlcktleUVudW0uQ0FURUdPUlksIGNhdGVnb3J5KTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGlmIChzdWJDYXRlZ29yeSAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgZmlsdGVycy5wdXQoRmlsdGVyS2V5RW51bS5TVUJfQ0FURUdPUlksIHN1YkNhdGVnb3J5KTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGlmIChkaXN0cmlidXRpb25TdGF0dXMgIT0gbnVsbCkgeworICAgICAgICAgICAgICAgIGZpbHRlcnMucHV0KEZpbHRlcktleUVudW0uRElTVFJJQlVUSU9OX1NUQVRVUywgZGlzdHJpYnV0aW9uU3RhdHVzKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGlmIChyZXNvdXJjZVR5cGUgIT0gbnVsbCkgeworICAgICAgICAgICAgICAgIFJlc291cmNlVHlwZUVudW0gcmVzb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y2VwdGlvbiIsIGUpOworICAgICAgICAgICAgdGhyb3cgZTsKKyAgICAgICAgfQorICAgIH0KKworICAgIC8qKgorICAgICAqCisgICAgICogQHBhcmFtIHJlcXVlc3RJZAorICAgICAqIEBwYXJhbSBpbnN0YW5jZUlkSGVhZGVyCisgICAgICogQHBhcmFtIGFjY2VwdAorICAgICAqIEBwYXJhbSBhdXRob3JpemF0aW9uCisgICAgICogQHBhcmFtIGFzc2V0VHlwZQorICAgICAqIEBwYXJhbSB1dWlkCisgICAgICogQHJldHVybgorICAgICAqLworICAgIEBHRVQKKyAgICBAUGF0aCgiL3thc3NldFR5cGV9L3t1dWlkfS9tZXRhZGF0YSIpCisgICAgQFByb2R1Y2VzKE1lZGlhVHlwZS5BUFBMSUNBVElPTl9KU09OKQorICAgIEBPcGVyYXRpb24oZGVzY3JpcHRpb24gPSAiRGV0YWlsZWQgbWV0YWRhdGEgb2YgYXNzZXQgYnkgdXVpZCIsIG1ldGhvZCA9ICJHRVQiLAorICAgICAgICAgICAgc3VtbWFyeSA9ICJSZXR1cm5zIGRldGFpbGVkIG1ldGFkYXRhIG9mIGFuIGFzc2V0IGJ5IHV1aWQiKQorICAgIEBBcGlSZXNwb25zZXModmFsdWUgPSB7CisgICAgICAgICAgICBAQXBpUmVzcG9uc2UocmVzcG9uc2VDb2RlID0gIjIwMCIsCisgICAgICAgICAgICAgICAgICAgIGRlc2NyaXB0aW9uID0gIkVDT01QIGNvbXBvbmVudCBpcyBhdXRoZW50aWNhdGVkIGFuZCBsaXN0IG9mIENhdGFsb2cgQXNzZXRzIE1ldGFkYXRhIGlzIHJldHVybmVkIiwKKyAgICAgICAgICAgICAgICAgICAgY29udGVudCA9IEBDb250ZW50KGFycmF5ID0gQEFycmF5U2NoZW1hKHNjaGVtYSA9IEBTY2hlbWEoaW1wbGVtZW50YXRpb24gPSBBc3NldE1ldGFkYXRhLmNsYXNzKSkpKSwKKyAgICAgICAgICAgIEBBcGlSZXNwb25zZShyZXNwb25zZUN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Iik7CisgICAgICAgICAgICBFaXRoZXI8TGlzdDw/IGV4dGVuZHMgQXNzZXRNZXRhZGF0YT4sIFJlc3BvbnNlRm9ybWF0PiByZXNNZXRhZGF0YSA9IGFzc2V0TWV0YWRhdGFDb252ZXJ0ZXIuY29udmVydFRvQXNzZXRNZXRhZGF0YShhc3NldFR5cGVEYXRhLmxlZnQoKS52YWx1ZSgpLCByZXF1ZXN0VVJJLCB0cnVlKTsKKyAgICAgICAgICAgIGlmIChyZXNNZXRhZGF0YS5pc1JpZ2h0KCkpIHsKKyAgICAgICAgICAgICAgICBsb2cuZGVidWcoImdldEFzc2V0TGlzdDogQXNzZXQgY29udmVyc2lvbiBGYWlsZWQiKTsKKyAgICAgICAgICAgICAgICByZXNwb25zZUZvcm1hdCA9IHJlc01ldGFkYXRhLnJpZ2h0KCkudmFsdWUoKTsKKworICAgICAgICAgICAgICAgIGdldENvbXBvbmVudHNVdGlscygpLmF1ZGl0RXh0ZXJuYWxHZXRBc3NldChyZXNwb25zZUZvcm1hdCwgYXVkaXRpbmdBY3Rpb25FbnVtLCBkaXN0cmlidXRpb25EYXRhLAorICAgICAgICAgICAgICAgICAgICAgICAgcmVzb3VyY2VDb21tb25JbmZvLCByZXF1ZXN0SWQsIHV1aWQpOworICAgICAgICAgICAgICAgIHJldHVybiBidWlsZEVycm9yUmVzcG9uc2UocmVzcG9uc2VGb3JtYXQpOworICAgICAgICAgICAgfQorICAgICAgICAgICAgT2JqZWN0IHJlc3VsdCA9IFJlcHJlc2VudGF0aW9uVXRpbHMudG9SZXByZXNlbnRhdGlvbihyZXNNZXRhZGF0YS5sZWZ0KCkudmFsdWUoKS5pdGVyYXRvcigpLm5leHQoKSk7CisgICAgICAgICAgICByZXNwb25zZUZvcm1hdCA9IGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5PSyk7CisgICAgICAgICAgICBnZXRDb21wb25lbnRzVXRpbHMoKS5hdWRpdEV4dGVybmFsR2V0QXNzZXQocmVzcG9uc2VGb3JtYXQsIGF1ZGl0aW5nQWN0aW9uRW51bSwgZGlzdHJpYnV0aW9uRGF0YSwKKyAgICAgICAgICAgICAgICAgICAgcmVzb3VyY2VDb21tb25JbmZvLCByZXF1ZXN0SWQsIHV1aWQpOworCisgICAgICAgICAgICByZXNwb25zZSA9IGJ1aWxkT2tSZXNwb25zZShyZXNwb25zZUZvcm1hdCwgcmVzdWx0KTsKKyAgICAgICAgICAgIHJldHVybiByZXNwb25zZTsKKworICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZSkgeworICAgICAgICAgICAgQmVFY29tcEVycm9yTWFuYWdlci5nZXRJbnN0YW5jZSgpLmxvZ0JlUmVzdEFwaUdlbmVyYWxFcnJvcigiRmV0Y2ggZmlsdGVyZWQgbGlzdCBvZiBhc3NldHMiKTsKKyAgICAgICAgICAgIGxvZy5kZWJ1ZygiZ2V0QXNzZXRMaXN0OiBGZXRjaCBsaXN0IG9mIGFzc2V0cyBmYWlsZWQgd2l0aCBleGNlcHRpb24iLCBlKTsKKyAgICAgICAgICAgIHRocm93IGU7CisgICAgICAgIH0KKyAgICB9CisKKyAgICBwcml2YXRlIENvbXBvbmVudEJ1c2luZXNzTG9naWMgZ2V0Q29tcG9uZW50QkxCeVR5cGUoQ29tcG9uZW50VHlwZUVudW0gY29tcG9uZW50VHlwZUVudW0pIHsKKyAgICAgICAgaWYoY29tcG9uZW50VHlwZUVudW0uZXF1YWxzKFJFU09VUkNFKSkgeworICAgICAgICAgICAgcmV0dXJuIHJlc291cmNlQnVzaW5lc3NMb2dpYzsKKyAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgIC8vIEltcGxlbWVudGF0aW9uIGlzIHRoZSBzYW1lIGZvciBhbnkgQ29tcG9uZW50QnVzaW5lc3NMb2dpYworICAgICAgICAgICAgcmV0dXJuIHNlcnZpY2VCdXNpbmVzc0xvZ2ljOworICAgICAgICB9CisgICAgfQorCisgICAgLyoqCis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gICAgIEFjdGlvblN0YXR1cy5NSVNTSU5HX0NPTVBPTkVOVF9OQU1FLCBDb21wb25lbnRUeXBlRW51bS5TRVJWSUNFLmdldFZhbHVlKCkpKTsKICAgICAgICAgICAgICAgICB9CkBAIC0zMjMsNyArMzI4LDcgQEAKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgLy92YWxpZGF0ZSBuYW1lIGV4aXN0CiAgICAgICAgICAgICAgICAgaWYocmVzcG9uc2VXcmFwcGVyLmlzRW1wdHkoKSl7Ci0gICAgICAgICAgICAgICAgICAgIGlmKCBTdHJpbmdzLmlzRW1wdHkocmVzb3VyY2UuZ2V0TmFtZSgpKSl7CisgICAgICAgICAgICAgICAgICAgIGlmKGlzTnVsbE9yRW1wdHkocmVzb3VyY2UuZ2V0TmFtZSgpKSl7CiAgICAgICAgICAgICAgICAgICAgICAgICByZXNwb25zZVdyYXBwZXIuc2V0SW5uZXJFbGVtZW50KGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBY3Rpb25TdGF0dXMuTUlTU0lOR19DT01QT05FTlRfTkFNRSwgQ29tcG9uZW50VHlwZUVudW0uUkVTT1VSQ0UuZ2V0VmFsdWUoKSkpOwogCkBAIC0zMzUsMTggKzM0MCwxOCBAQAogICAgICAgICAgICAgICAgICAgICByZXNvdXJjZS5zZXRTeXN0ZW1OYW1lKFZhbGlkYXRpb25VdGlscy5jb252ZXJ0VG9TeXN0ZW1OYW1lKHJlc291cmNlLmdldE5hbWUoKSkpOwogICAgICAgICAgICAgICAgICAgICByZXNvdXJjZS5zZXRUb3NjYVJlc291cmNlTmFtZShDb21tb25CZVV0aWxzLmdlbmVyYXRlVG9zY2FSZXNvdXJjZU5hbWUoUmVzb3VyY2VUeXBlRW51bS5WRkNNVC5uYW1lKCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzb3VyY2UuZ2V0U3lzdGVtTmFtZSgpKSk7Ci0gICAgICAgICAgICAgICAgICAgIGhhbmRsZUNhdGVnb3JpZXMoY29udGV4dCwgZGF0YSwgcmVzb3VyY2UsIHJlc3BvbnNlV3JhcHBlcik7CisgICAgICAgICAgICAgICAgICAgIGhhbmRsZUNhdGVnb3JpZXMoZGF0YSwgcmVzb3VyY2UsIHJlc3BvbnNlV3JhcHBlcik7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIC8vIENyZWF0ZSB0aGUgcmVzb3VyY2UgaW4gdGhlIGRhdGFNb2RlbAogICAgICAgICAgICAgICAgIGlmIChyZXNwb25zZVdyYXBwZXIuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgIHJlc291cmNlID0gcmVzb3VyY2VCdXNpbmVzc0xvZ2ljLmNyZWF0ZVJlc291cmNlKHJlc291cmNlLCBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGlmaWVyLCBudWxsLCBudWxsKTsKLSAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGJ1aWxkQ3JlYXRlZFJlc291cmNlUmVzcG9uc2UocmVzb3VyY2UsIGNvbnRleHQsIHJlc3BvbnNlV3JhcHBlcik7CisgICAgICAgICAgICAgICAgICAgIHJldHVybiBidWlsZENyZWF0ZWRSZXNvdXJjZVJlc3BvbnNlKHJlc291cmNlLCByZXNwb25zZVdyYXBwZXIpOwogICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgIHJldHVybiBidWlsZEVycm9yUmVzcG9uc2UocmVzcG9uc2VXcmFwcGVyLmdldElubmVyRWxlbWVudCgpKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAKKwogICAgICAgICB9IGNhdGNoIChJT0V4Y2VwdGlvbnxQYXJzZUV4Y2VwdGlvbiBlKSB7CiAgICAgICAgICAgICBmaW5hbCBTdHJpbmcgbWVzc2FnZSA9ICJmYWlsZWQgdG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GEvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2V4dGVybmFsYXBpL3NlcnZsZXQvU2VydmljZUFjdGl2YXRpb25TZXJ2bGV0LmphdmEKKysrIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2V4dGVybmFsYXBpL3NlcnZsZXQvU2VydmljZUFjdGl2YXRpb25TZXJ2bGV0LmphdmEKQEAgLTEsMjI1ICsxLDIyMiBAQAotLyotDQotICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NCi0gKiBTREMNCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLSAqIENvcHlyaWdodCAoQykgMjAxOSBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLSAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOw0KLSAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4NCi0gKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQNCi0gKiANCi0gKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMA0KLSAqIA0KLSAqIFVubGVzcyByZXF1aXJlZCBieSBhcHBsaWNhYm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AgICBtb2RpZmllci5zZXRVc2VySWQodXNlcklkKTsNCi0gICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJtb2RpZmllciBpZCBpcyB7fSIsIHVzZXJJZCk7DQotDQotICAgICAgICAgICAgICAgIFNlcnZpY2VEaXN0cmlidXRpb25SZXFJbmZvIHJlcU1ldGFkYXRhID0gY29udmVydEpzb25Ub0FjdGl2YXRpb25NZXRhZGF0YShkYXRhKTsNCi0gICAgICAgICAgICAgICAgRWl0aGVyPFN0cmluZywgUmVzcG9uc2VGb3JtYXQ+IGRpc3RSZXNwb25zZSA9IHNlcnZpY2VCdXNpbmVzc0xvZ2ljDQotICAgICAgICAgICAgICAgICAgICAgICAgLmFjdGl2YXRlU2VydmljZU9uVGVuYW50RW52aXJvbm1lbnQoc2VydmljZVVVSUQsIG9wRW52SWQsIG1vZGlmaWVyLCByZXFNZXRhZGF0YSk7DQotDQotICAgICAgICAgICAgICAgIGlmIChkaXN0UmVzcG9uc2UuaXNSaWdodCgpKSB7DQotICAgICAgICAgICAgICAgICAgICBsb2cuZGVidWcoImZhaWxlZCB0byBhY3RpdmF0ZSBzZXJ2aWNlIGRpc3RyaWJ1dGlvbiIpOw0KLSAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2VGb3JtYXQgPSBkaXN0UmVzcG9uc2UucmlnaHQoKS52YWx1ZSgpOw0KLSAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGJ1aWxkRXJyb3JSZXNwb25zZShyZXNwb25zZUZvcm1hdCk7DQotICAgICAgICAgICAgICAgIH0NCi0gICAgICAgICAgICAgICAgU3RyaW5nIGRpc3RyaWJ1dGlvbklkID0gZGlzdFJlc3BvbnNlLmxlZnQoKS52YWx1ZSgpOw0KLSAgICAgICAgICAgICAgICBPYmplY3QgcmVzdWx0ID0gUmVwcmVzZW50YXRpb25VdGlscy50b1JlcHJlc2VudGF0aW9uKG5ldyBTZXJ2aWNlRGlzdHJpYnV0aW9uUmVzcEluZm8oZGlzdHJpYnV0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5IHsNCi0gICAgICAgICAgICByZXR1cm4gbWFwcGVyLnJlYWRWYWx1ZShkYXRhLCBTZXJ2aWNlRGlzdHJpYnV0aW9uUmVxSW5mby5jbGFzcyk7DQotICAgICAgICB9IGNhdGNoIChJT0V4Y2VwdGlvbiBlKSB7DQotICAgICAgICAgICAgbG9nLmVycm9yKCIjY29udmVydEpzb25Ub0FjdGl2YXRpb25NZXRhZGF0YSAtIGpzb24gZGVzZXJpYWxpemF0aW9uIGZhaWxlZCB3aXRoIGVycm9yOiAiLCBlKTsNCi0gICAgICAgICAgICByZXR1cm4gbmV3IFNlcnZpY2VEaXN0cmlidXRpb25SZXFJbmZvKG51bGwpOw0KLSAgICAgICAgfQ0KLSAgICB9DQotDQotICAgIEBPdmVycmlkZQ0KLSAgICBwcm90ZWN0ZWQgdm9pZCB2YWxpZGF0ZUh0dHBDc3BVc2VySWRIZWFkZXIoU3RyaW5nIGhlYWRlciwgV3JhcHBlcjxSZXNwb25zZUZvcm1hdD4gcmVzcG9uc2VXcmFwcGVyKSB7DQotICAgICAgICBSZXNwb25zZUZvcm1hdCByZXNwb25zZUZvcm1hdDsNCi0gICAgICAgIGlmKCBTdHJpbmdVdGlscy5pc0VtcHR5KGhlYWRlcikpew0KLSAgICAgICAgICAgIGxvZy5kZWJ1ZygiTWlzc2luZ1VTRVJfSUQiKTsNCi0gICAgICAgICAgICByZXNwb25zZUZvcm1hdCA9IGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5BVVRIX0ZBSUxFRCk7DQotICAgICAgICAgICAgcmVzcG9uc2VXcmFwcGVyLnNldElubmVyRWxlbWVudChyZXNwb25zZUZvcm1hdCk7DQotICAgICAgICB9DQotICAgIH0NCi19DQotDQotDQotDQorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDE5IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgorICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0CisgKiAKKyAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wCisgKiAKKyAqIFVubGVzcyByZXF1aXJlZCBieSBhcHBsaWNhYmxlIGxhdyBvciBhZ3JlZWQgdG8gaW4gd3JpdGluZywgc29mdHdhcmUKKyAqIGRpc3RyaWJ1dGVkIHVuZGVyIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1dGVkIG9uIGFuICJBUyBJUyIgQkFTSVMsCisgKiBXSVRIT1VUIFdBUlJBTlRJRVMgT1IgQ09ORElUSU9OUyBPRiBBTlkgS0lORCwgZWl0aGVyIGV4cHJlc3Mgb3IgaW1wbGllZC4KKyAqIFNlZSB0aGUgTGljZW5zZSBmb3IgdGhlIHNwZWNpZmljIGxhbmd1YWdlIGdvdmVybmluZyBwZXJtaXNzaW9ucyBhbmQKKyAqIGxpbWl0YXRpb25zIHVuZGVyIHRoZSBMaWNlbnNlLgorICogPT09PT09PT09PT09TElDRU5TRV9FTkQ9PT09PT09P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c2VydmljZSBkaXN0cmlidXRpb24iKTsKKyAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2VGb3JtYXQgPSBkaXN0UmVzcG9uc2UucmlnaHQoKS52YWx1ZSgpOworICAgICAgICAgICAgICAgICAgICByZXR1cm4gYnVpbGRFcnJvclJlc3BvbnNlKHJlc3BvbnNlRm9ybWF0KTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgU3RyaW5nIGRpc3RyaWJ1dGlvbklkID0gZGlzdFJlc3BvbnNlLmxlZnQoKS52YWx1ZSgpOworICAgICAgICAgICAgICAgIE9iamVjdCByZXN1bHQgPSBSZXByZXNlbnRhdGlvblV0aWxzLnRvUmVwcmVzZW50YXRpb24obmV3IFNlcnZpY2VEaXN0cmlidXRpb25SZXNwSW5mbyhkaXN0cmlidXRpb25JZCkpOworICAgICAgICAgICAgICAgIHJlc3BvbnNlRm9ybWF0ID0gZ2V0Q29tcG9uZW50c1V0aWxzKCkuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLkFDQ0VQVEVEKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gYnVpbGRPa1Jlc3BvbnNlKHJlc3BvbnNlRm9ybWF0LCByZXN1bHQpOworICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICBsb2cuZGVidWcoInJlcXVlc3QgaW5zdGFuY2VJZC91c2VySWQgaGVhZGVyIHZhbGlkYXRpb24gZmFpbGVkIik7CisgICAgICAgICAgICAgICAgcmVzcG9uc2VGb3JtYXQgPSByZXNwb25zZVdyYXBwZXIuZ2V0SW5uZXJFbGVtZW50KCk7CisgICAgICAgICAgICAgICAgcmV0dXJuIGJ1aWxkRXJyb3JSZXNwb25zZShyZXNwb25zZUZvcm1hdCk7CisgICAgICAgICAgICB9CisgICAgICAgIH0gY2F0Y2ggKEV4Y2VwdGlvbiBlKSB7CisgICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3Rhb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AgIHJlc3BvbnNlV3JhcHBlci5zZXRJbm5lckVsZW1lbnQocmVzcG9uc2VGb3JtYXQpOworICAgICAgICB9CisgICAgfQorfQorCisKKwpkaWZmIC0tZ2l0IGEvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2ZhY2FkZS9vcGVyYXRpb25zL0NhdGFsb2dPcGVyYXRpb24uamF2YSBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9mYWNhZGUvb3BlcmF0aW9ucy9DYXRhbG9nT3BlcmF0aW9uLmphdmEKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uNzgzNmZjYwotLS0gL2Rldi9udWxsCisrKyBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9mYWNhZGUvb3BlcmF0aW9ucy9DYXRhbG9nT3BlcmF0aW9uLmphdmEKQEAgLTAsMCArMSw4MyBAQAorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDIwIEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaX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uLjBjYzRhMWMKLS0tIC9kZXYvbnVsbAorKysgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvZmFjYWRlL29wZXJhdGlvbnMvRmFjYWRlT3BlcmF0aW9uVXRpbHMuamF2YQpAQCAtMCwwICsxLDQxIEBACisvKi0KKyAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBTREMKKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBDb3B5cmlnaHQgKEMpIDIwMjAgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7CisgKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCisgKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKKyAqCisgKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAorICoKKyAqIFVubGVzcyByZXF1aXJlZCBieSBhcHBsaWNhYmxlIGxhdyBvciBhZ3JlZWQgdG8gaW4gd3JpdGluZywgc29mdHdhcmUKKyAqIGRpc3RyaWJ1dGVkIHVuZGVyIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1dGVkIG9uIGFuICJBUyBJUyI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XN1bHQgPSBBY3Rpb25TdGF0dXMuT0s7CisgICAgICAgIGlmIChzdGF0dXMuZ2V0UmVzdWx0U3RhdHVzKCkgIT0gUmVzdWx0U3RhdHVzRW51bS5TVUNDRVNTKXsKKyAgICAgICAgICAgIGxvZy5kZWJ1ZygidXBkYXRlQ2F0YWxvZyAtIGZhaWxlZCB0byAgc2VuZCBub3RpZmljYXRpb24ge30iLCBzdGF0dXMpOworICAgICAgICB9CisgICAgICAgIHJldHVybiByZXN1bHQ7CisgICAgfQorfQpkaWZmIC0tZ2l0IGEvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2ZhY2FkZS9vcGVyYXRpb25zL1VzZXJPcGVyYXRpb24uamF2YSBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9mYWNhZGUvb3BlcmF0aW9ucy9Vc2VyT3BlcmF0aW9uLmphdmEKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uYzgzMDczNAotLS0gL2Rldi9udWxsCisrKyBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9mYWNhZGUvb3BlcmF0aW9ucy9Vc2VyT3BlcmF0aW9uLmphdmEKQEAgLTAsMCArMSw2MSBAQAorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDIwIEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09P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mRpZmYgLS1naXQgYS9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvZmlsdGVycy9CZUNhZGlTZXJ2bGV0RmlsdGVyLmphdmEgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvZmlsdGVycy9CZUNhZGlTZXJ2bGV0RmlsdGVyLmphdmEKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uNDliOWZiZgotLS0gL2Rldi9udWxsCisrKyBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9maWx0ZXJzL0JlQ2FkaVNlcnZsZXRGaWx0ZXIuamF2YQpAQCAtMCwwICsxLDE4MCBAQAorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDIwIEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgorICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0CisgKgorICogICA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YXBwZXIgd2ViQXBwbGljYXRpb25Db250ZXh0V3JhcHBlciA9IChXZWJBcHBDb250ZXh0V3JhcHBlcikgY29udGV4dC5nZXRBdHRyaWJ1dGUoQ29uc3RhbnRzLldFQl9BUFBMSUNBVElPTl9DT05URVhUX1dSQVBQRVJfQVRUUik7CisgICAgICAgIFdlYkFwcGxpY2F0aW9uQ29udGV4dCB3ZWJBcHBsaWNhdGlvbkNvbnRleHQgPSB3ZWJBcHBsaWNhdGlvbkNvbnRleHRXcmFwcGVyLmdldFdlYkFwcENvbnRleHQoY29udGV4dCk7CisgICAgICAgIHJldHVybiB3ZWJBcHBsaWNhdGlvbkNvbnRleHQuZ2V0QmVhbihidXNpbmVzc0xvZ2ljQ2xhc3NHZW4uZ2V0KCkpOworICAgIH0KKworCit9CisKKworCisKKworCisKKworCisKKworCisKKworCmRpZmYgLS1naXQgYS9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvZmlsdGVycy9CZVJlc3RyaWN0aW9uQWNjZXNzRmlsdGVyLmphdmEgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvZmlsdGVycy9CZVJlc3RyaWN0aW9uQWNjZXNzRmlsdGVyLmphdmEKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uZGU4OTY5YQotLS0gL2Rldi9udWxsCisrKyBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9maWx0ZXJzL0JlUmVzdHJpY3Rpb25BY2Nlc3NGaWx0ZXIuamF2YQpAQCAtMCwwICsxLDU0IEBACisvKi0KKyAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBTREMKKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09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Mb2NhbHNIb2xkZXIuZ2V0UmVxdWVzdFN0YXJ0VGltZSgpOwotICAgICAgICAgICAgICAgIGlmIChzdGFydFRpbWUgIT0gbnVsbCkgewotICAgICAgICAgICAgICAgICAgICBsb25nIGVuZFRpbWUgPSBTeXN0ZW0uY3VycmVudFRpbWVNaWxsaXMoKTsKLSAgICAgICAgICAgICAgICAgICAgTURDLnB1dCgidGltZXIiLCBMb25nLnRvU3RyaW5nKGVuZFRpbWUgLSBzdGFydFRpbWUpKTsKKyAgICAgICAgaWYgKGlzTG9nZ2VkUmVxdWVzdCgpKSB7CisgICAgICAgICAgICB0cnkgeworICAgICAgICAgICAgICAgIHN1cGVyLmZpbHRlcihyZXF1ZXN0Q29udGV4dCwgcmVzcG9uc2VDb250ZXh0KTsKKyAgICAgICAgICAgICAgICAvLyBGb3JtYXR0aW5nIHRoZSByZXNwb25zZSBpbiBjYXNlIG9mIDQwNQorICAgICAgICAgICAgICAgIGlmIChyZXNwb25zZUNvbnRleHQuZ2V0U3RhdHVzKCkgPT0gUmVzcG9uc2UuU3RhdHVzLk1FVEhPRF9OT1RfQUxMT1dFRC5nZXRTdGF0dXNDb2RlKCkpIHsKKyAgICAgICAgICAgICAgICAgICAgUmVzcG9uc2VGb3JtYXQgcmVzcG9uc2VGb3JtYXQgPSBnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuTk9UX0FMTE9XRUQpOworICAgICAgICAgICAgICAgICAgICByZXNwb25zZUNvbnRleHQuc2V0RW50aXR5KG5ldyBHc29uQnVpbGRlcigpLnNldFByZXR0eVByaW50aW5nKCkuY3JlYXRlKCkudG9Kc29uKHJlc3BvbnNlRm9ybWF0LmdldFJlcXVlc3RFcnJvcigpKSk7CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAvLyB0aGlzIGlzIHRoZSA0MDUgcmVzcG9uc2UgY29kZSBjYXNlCi0gICAgICAgICAgICAgICAgLy8gd2UgaGF2ZSBubyBNREMgZmllbGRzIHNpbmNlIGZpbHRlcigpIHdhc24ndCBleGVjdXRlZCBkdXJpbmcKLSAgICAgICAgICAgICAgICAvLyByZXF1ZXN0Ci0gICAgICAgICAgICAgICAgU3RyaW5nIHV1aWQgPSBwcm9jZXNzTWRjRmllbGRzKHJlcXVlc3RDb250ZXh0KTsKIAotICAgICAgICAgICAgICAgIHJlc3BvbnNlQ29udGV4dC5nZXRIZWFkZXJzKCkuYWRkKENvbnN0YW50cy5YX0VDT01QX1JFUVVFU1RfSURfSEVBREVSLCB1dWlkKTsKLSAgICAgICAgICAgICAgICAvLyBjYWxsIHRvIHN0YXJ0LWxvZyBtZXRob2QgdG8gZmlsbCBtYW5kYXRvcnkgZmllbGRzCi0gICAgICAgICAgICAgICAgYXVkaXQuc3RhcnRMb2cocmVxdWVzdENvbnRleHQpOworICAgICAgICAgICAgICAgIGlmIChUaHJlYWRMb2NhbHNIb2xkZXIuaXNNZGNQcm9jZXNzZWQoKSkgeworICAgICAgICAgICAgICAgICAgICAvLyBmaWx0ZXIoKSB3YXMgZXhlY3V0ZWQgZHVyaW5nIHJlcXVlc3QgLSB0aGlzIGlzIHRoZSByZWd1bGFyCisgICAgICAgICAgICAgICAgICAgIC8vIGZsb3cKKyAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2VDb250ZXh0LmdldEhlYWRlcnMoKS5hZGQoQ29uc3RhbnRzLlhfRUNPTVBfUkVRVUVTVF9JRF9IRUFERVIsIFRocmVhZExvY2Fsc0hvbGRlci5nZXRVdWlkKCkpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICB3cml0ZVRvSmFudXNHcmFwaChyZXNwb25zZUNvbnRleHQpOworCisgICAgICAgICAgICAgICAgb3V0SHR0cFJlc3BvbnNlKHJlc3BvbnNlQ29udGV4dCk7CisKKyAgICAgICAgICAgIH0gY2F0Y2ggKEV4Y2VwdGlvbiBlKSB7CisgICAgICAgICAgICAgICAgQmVFY29tcEVycm9yTWFuYWdlci5nZXRJbnN0YW5jZSgpLmxvZ0JlUmVzdEFwaUdlbmVyYWxFcnJvcigiRXJyb3IgZHVyaW5nIHJlcXVlc3QgZmlsdGVyIik7CisgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJFcnJvciBkdXJpbmcgcmVzcG9uc2UgZmlsdGVyOiB7fSAiLCBlKTsKKyAgICAgICAgICAgIH0gZmluYWxseSB7CisgICAgICAgICAgICAgICAgLy8gQ2xlYW5pbmcgdXAKKyAgICAgICAgICAgICAgICBNREMuY2xlYXIoKTsKKyAgICAgICAgICAgICAgICBUaHJlYWRMb2NhbHNIb2xkZXIuY2xlYW51cCgpOwogICAgICAgICAgICAgfQotCi0gICAgICAgICAgICB3cml0ZVRvSmFudXNHcmFwaChyZXNwb25zZUNvbnRleHQpOwotCi0gICAgICAgICAgICAvL3dyaXRlIHRvIEF1ZGl0IGxvZyBpbiBjYXNlIGl0J3MgdmFsdWFibGUgYWN0aW9uCi0gICAgICAgICAgICAvLyAoZS5nLiBpZ25vcmluZyBoZWFsdGhDaGVjayBhbmQgYW55IG90aGVyIHVubG9nZ2VkIHVybHMgYXMgaW4geWFtbAotICAgICAgICAgICAgaWYgKGlzSW5mb0xvZygpKSB7Ci0gICAgICAgICAgICAgICAgYXVkaXQubG9nKHNyLmdldFJlbW90ZUFkZHIoKSwKLSAgICAgICAgICAgICAgICAgICAgICAgIHJlcXVlc3RDb250ZXh0LAotICAgICAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2VDb250ZXh0LmdldFN0YXR1c0luZm8oKSwKLSAgICAgICAgICAgICAgICAgICAgICAgIExvZ0xldmVsLklORk8sCi0gICAgICAgICAgICAgICAgICAgICAgICBTZXZlcml0eS5PSywKLSAgICAgICAgICAgICAgICAgICAgICAgIExvZ0ZpZWxkc01kY0hhbmRsZXIuZ2V0SW5zdGFuY2UoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0QXVkaXRNZXNzYWdlKCkpOwotICAgICAgICAgICAgfQotCi0gICAgICAgICAgICBvdXRIdHRwUmVzcG9uc2UocmVzcG9uc2VDb250ZXh0KTsKLQotICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZSkgewotICAgICAgICAgICAgQmVFY29tcEVycm9yTWFuYWdlci5nZXRJbnN0YW5jZSgpLmxvZ0JlUmVzdEFwaUdlbmVyYWxFcnJvcigiRXJyb3IgZHVyaW5nIHJlcXVlc3QgZmlsdGVyIik7Ci0gICAgICAgICAgICBsb2cuZGVidWcoIkVycm9yIGR1cmluZyByZXNwb25zZSBmaWx0ZXI6IHt9ICIsIGUpOwotICAgICAgICB9IGZpbmFsbHkgewotICAgICAgICAgICAgLy8gQ2xlYW5pbmcgdXAKLSAgICAgICAgICAgIE1EQy5jbGVhcigpOwotICAgICAgICAgICAgVGhyZWFkTG9jYWxzSG9sZGVyLmNsZWFudXAoKTsKICAgICAgICAgfQogICAgIH0KIApAQCAtMTYxLDM3ICsxMzMsMTYgQEAKICAgICAgICAgfQogICAgIH0KIAotICAgIHByaXZhdGUgU3RyaW5nIHByb2Nlc3NNZGNGaWVsZHMoQ29udGFpbmVyUmVxdWVzdENvbnRleHQgcmVxdWVzdENvbnRleHQpIHsKKyAgICBwcml2YXRlIHZvaWQgcHJvY2Vzc01kY0ZpZWxkcyhDb250YWluZXJSZXF1ZXN0Q29udGV4dCByZXF1ZXN0Q29udGV4dCkgewogICAgICAgICAvLyBVc2VySWQgZm9yIGxvZ2dpbmcKICAgICAgICAgU3RyaW5nIHVzZXJJZCA9IHJlcXVlc3RDb250ZXh0LmdldEhlYWRlclN0cmluZyhDb25zdGFudHMuVVNFUl9JRF9IRUFERVIpOwogICAgICAgICBNREMucHV0KCJ1c2VySWQiLCB1c2VySWQpOwogCiAgICAgICAgIFN0cmluZyBzZXJ2aWNlSW5zdGFuY2VJRCA9IHJlcXVlc3RDb250ZXh0LmdldEhlYWRlclN0cmluZyhDb25zdGF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NzaW9uSWRsZVRpbWVPdXQoKSB7CisgICAgICAgIHJldHVybiBjb25maWcuZ2V0QXV0aENvb2tpZSgpLmdldFNlc3Npb25JZGxlVGltZU91dCgpOworICAgIH0KKworICAgIEBPdmVycmlkZQorICAgIHB1YmxpYyBTdHJpbmcgZ2V0UmVkaXJlY3RVUkwoKSB7CisgICAgICAgIHJldHVybiBjb25maWcuZ2V0QXV0aENvb2tpZSgpLmdldFJlZGlyZWN0VVJMKCk7CisgICAgfQorCisgICAgQE92ZXJyaWRlCisgICAgcHVibGljIExpc3Q8U3RyaW5nPiBnZXRFeGNsdWRlZFVybHMoKSB7CisgICAgICAgIHJldHVybiBjb25maWcuZ2V0QXV0aENvb2tpZSgpLmdldEV4Y2x1ZGVkVXJscygpOworICAgIH0KKworICAgIEBPdmVycmlkZQorICAgIHB1YmxpYyBTdHJpbmcgZ2V0Q29va2llTmFtZSgpIHsKKyAgICAgICAgcmV0dXJuIGNvbmZpZy5nZXRBdXRoQ29va2llKCkuZ2V0Q29va2llTmFtZSgpOworICAgIH0KKworICAgIEBPdmVycmlkZQorICAgIHB1YmxpYyBTdHJpbmcgZ2V0Q29va2llRG9tYWluKCkgeworICAgICAgICByZXR1cm4gY29uZmlnLmdldEF1dGhDb29raWUoKS5nZXREb21haW4oKTsKKyAgICB9CisKKyAgICBAT3ZlcnJpZGUKKyAgICBwdWJsaWMgU3RyaW5nIGdldENvb2tpZVBhdGgoKSB7CisgICAgICAgIHJldHVybiBjb25maWcuZ2V0QXV0aENvb2tpZSgpLmdldFBhdGgoKTsKKyAgICB9CisKKyAgICBAT3ZlcnJpZGUKKyAgICBwdWJsaWMgYm9vbGVhbiBpc0Nvb2tpZUh0dHBPbmx5KCkgeworICAgICAgICByZXR1cm4gY29uZmlnLmdldEF1dGhDb29raWUoKS5pc0h0dHBPbmx5KCk7CisgICAgfQorfQpkaWZmIC0tZ2l0IGEvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2ZpbHRlcnMvR2F0ZXdheUZpbHRlci5qYXZhIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2ZpbHRlcnMvR2F0ZXdheUZpbHRlci5qYXZhCm5ldyBmaWxlIG1vZGUgMTAwNjQ0CmluZGV4IDAwMDAwMDAuLjNlZDE0ZjEKLS0tIC9kZXYvbnVsbAorKysgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvZmlsdGVycy9HYXRld2F5RmlsdGVyLmphdmEKQEAgLTAsMCArMSwxNDcgQEAKKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAxNyBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKKyAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KKyAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAorICoKKyAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wCisgKgorICogVW5sZ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zdCBodHRwUmVxdWVzdCA9IChIdHRwU2VydmxldFJlcXVlc3QpIHJlcTsKKyAgICAgICAgSHR0cFNlcnZsZXRSZXNwb25zZSBodHRwUmVzcG9uc2UgPSAoSHR0cFNlcnZsZXRSZXNwb25zZSkgcmVzOworICAgICAgICB0cnkgeworICAgICAgICAgICAgaWYgKGlzVXJsRnJvbVdoaXRlTGlzdChodHRwUmVxdWVzdCkgfHwgaXNDb25zdW1lckJ1c2luZXNzTG9naWMoKSkgeworICAgICAgICAgICAgICAgIFRocmVhZExvY2Fsc0hvbGRlci5zZXRBcGlUeXBlKEZpbHRlckRlY2lzaW9uRW51bS5OQSk7CisgICAgICAgICAgICAgICAgdGhyZWFkTG9jYWxVdGlscy5zZXRVc2VyQ29udGV4dEZyb21EQihodHRwUmVxdWVzdCk7CisgICAgICAgICAgICAgICAgZmlsdGVyQ2hhaW4uZG9GaWx0ZXIoaHR0cFJlcXVlc3QsIHJlcyk7CisvLyAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNDb29raWVFeGlzdChodHRwUmVxdWVzdCwgYXV0aENvb2tpZUNvbmYuZ2V0Q29va2llTmFtZSgpKSkgeworLy8gICAgICAgICAgICAgICAgVGhyZWFkTG9jYWxzSG9sZGVyLnNldEFwaVR5cGUoRmlsdGVyRGVjaXNpb25FbnVtLklOVEVSTkFMKTsKKy8vICAgICAgICAgICAgICAgIGZpbHRlckNoYWluLmRvRmlsdGVyKGh0dHBSZXF1ZXN0LCByZXMpOworLy8gICAgICAgICAgICB9IGVsc2UgeworLy8gICAgICAgICAgICAgICAgdmFsaWRhdGVBdXRoSGVhZGVyRXhpc3QoaHR0cFJlcXVlc3QpOworLy8gICAgICAgICAgICAgICAgVGhyZWFkTG9jYWxzSG9sZGVyLnNldEFwaVR5cGUoRmlsdGVyRGVjaXNpb25FbnVtLkVYVEVSTkFMKTsKKy8vICAgICAgICAgICAgICAgIGZpbHRlckNoYWluLmRvRmlsdGVyKGh0dHBSZXF1ZXN0LCByZX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GV0UmVxdWVzdCBodHRwUmVxdWVzdCwgU3RyaW5nIGNvb2tpZU5hbWUpIHsKKyAgICAgICAgQ29va2llW10gY29va2llcyA9IGh0dHBSZXF1ZXN0LmdldENvb2tpZXMoKTsKKyAgICAgICAgaWYgKGNvb2tpZXMgIT0gbnVsbCkgeworICAgICAgICAgICAgZm9yIChDb29raWUgY29va2llIDogY29va2llcykgeworICAgICAgICAgICAgICAgIGlmIChjb29raWUuZ2V0TmFtZSgpLmVxdWFscyhjb29raWVOYW1lKSkgeworICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICAgICAgcmV0dXJuIGZhbHNlOworICAgIH0KKworICAgIHByaXZhdGUgYm9vbGVhbiBpc0hlYWRlckV4aXN0KEh0dHBTZXJ2bGV0UmVxdWVzdCByZXEsIFN0cmluZyBoZWFkZXJOYW1lKSB7CisgICAgICAgIHJldHVybiByZXEuZ2V0SGVhZGVyKGhlYWRlck5hbWUpICE9IG51bGw7CisgICAgfQorCisgICAgcHJpdmF0ZSB2b2lkIHZhbGlkYXRlQXV0aEhlYWRlckV4aXN0KEh0dHBTZXJ2bGV0UmVxdWVzdCByZXEpIHsKKyAgICAgICAgYm9vbGVhbiBhdXRoSGVhZGVyID0gaXNIZWFkZXJFeGlzdChyZXEsIEh0dHBIZWFkZXJzLkFVVEhPUklaQVRJT04pOworICAgICAgICBpZiAoIWF1dGhIZWFkZXIpIHRocm93IG5ldyBCeUFjdGlvblN0YXR1c0NvbXBvbmVudEV4Y2VwdGlvbihBY3Rpb25TdGF0dXMuQVVUSF9GQUlMRUQpOworICAgIH0KKworICAgIHByaXZhdGUgYm9vbGVhbiBpc1VybEZyb21XaGl0ZUxpc3QoSHR0cFNlcnZsZXRSZXF1ZXN0IGh0dHBSZXF1ZXN0KSB7CisgICAgICAgIFN0cmluZyBwYXRoSW5mbzsKKyAgICAgICAgTGlzdDxTdH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xDb25maWd1cmF0aW9uLmphdmEKQEAgLTAsMCArMSwxNTAgQEAKKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAyMCBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKKyAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KKyAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAorICoKKyAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wCisgKgorICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZQorICogZGlzdHJpYnV0ZWQgdW5kZXIgdGhlIExpY2Vuc2UgaXMgZGlzdHJpYnV0ZWQgb24gYW4gIkFTIElTIiBCQVNJUywKKyAqIFdJVEhPVVQgV0FSUkFOVElFUyBPUiBDT05ESVRJT05TIE9GIEFOWSBLSU5ELCBlaXRoZXIgZXhwcmVzcyBvciBpbXBsaWVkLgorICogU2VlIHRoZSBMaWNlbnNlIGZv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pIHsKKyAgICAgICAgcmV0dXJuIGZhbHNlOworICAgIH0KKworICAgIEBPdmVycmlkZQorICAgIHB1YmxpYyBTdHJpbmcgZ2V0UG9ydGFsQXBpSW1wbENsYXNzKCkgeworICAgICAgICByZXR1cm4gbnVsbDsKKyAgICB9CisKKyAgICBAT3ZlcnJpZGUKKyAgICBwdWJsaWMgU3RyaW5nIGdldFJvbGVBY2Nlc3NDZW50cmFsaXplZCgpIHsKKyAgICAgICAgcmV0dXJuIG51bGw7CisgICAgfQorCisgICAgQE92ZXJyaWRlCisgICAgcHVibGljIGJvb2xlYW4gZ2V0VWViTGlzdGVuZXJzRW5hYmxlKCkgeworICAgICAgICByZXR1cm4gZmFsc2U7CisgICAgfQorCisgICAgQE92ZXJyaWRlCisgICAgcHVibGljIFN0cmluZyBnZXRFY29tcFJlZGlyZWN0VXJsKCkgeworICAgICAgICByZXR1cm4gbnVsbDsKKyAgICB9CisKKyAgICBAT3ZlcnJpZGUKKyAgICBwdWJsaWMgU3RyaW5nIGdldEVjb21wUmVzdFVybCgpIHsKKyAgICAgICAgcmV0dXJuIGVjb21wUG9ydGFsUmVzdFVSTDsKKyAgICB9CisKKyAgICBAT3ZlcnJpZGUKKyAgICBwdWJsaWMgU3RyaW5nIGdldFBvcnRhbFVzZXIoKSB7CisgICAgICAgIHJldHVybiBwb3J0YWxVc2VyOworICAgIH0KKworICAgIEBPdmVycmlkZQorICAgIHB1YmxpYyBTdHJpbmcgZ2V0UG9ydGFsUGFzcygpIHsKKyAgICAgICAgcmV0dXJuIHBvcnRhbFBhc3N3b3JkOworICAgIH0KKworICAgIEBPdmVycmlkZQorICAgIHB1YmxpYyBTdHJpbmcgZ2V0UG9ydGFsQXBwTmFtZSgpIHsKKyAgICAgICAgcmV0dXJuIHBvcnRhbEFwcE5hbWU7CisgICAgfQorCisgICAgQE92ZXJyaWRlCisgICAgcHVibGljIFN0cmluZyBnZXRVZWJBcHBLZXkoKSB7CisgICAgICAgIHJldHVybiB1ZWJLZ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9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvZmlsdGVycy9SZXFWYWxpZGF0aW9uRmlsdGVyLmphdmEKQEAgLTAsMCArMSw4NSBAQAorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDIwIEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgorICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0CisgKgorICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKKyAqCisgKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlCisgKiBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0cmlidXRlZCBvbiBhbiAiQVMgSVMiIEJBU0lTLAorICogV0lUSE9VVCBXQVJSQU5USUVTIE9SIENPTkRJVElPTlMgT0YgQU5ZIEtJTkQsIGVpdGhlciBleHByZXNzIG9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KKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAyMCBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKKyAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KKyAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAorICoKKyAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wCisgKgorICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZQorICogZGlzdHJpYnV0ZWQgdW5kZXIgdGhlIExpY2Vuc2UgaXMgZGlzdHJpYnV0ZWQgb24gYW4gIkFTIElTIiBCQVNJUywKKyAqIFdJVEhPVVQgV0FSUkFOVElFUyBPUiBDT05ESVRJT05TIE9GIEFOWSBLSU5ELCBlaXRoZXIgZXhwcmVzcyBvciBpbXBsaWVkLgorICogU2VlIHRoZSBMaWNlbnNlIGZvciB0aGUgc3BlY2lmaWMgbGFuZ3VhZ2UgZ292ZXJuaW5n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dldEhlYWRlcihDb25zdGFudHMuVVNFUl9JRF9IRUFERVIpOworICAgICAgICBpZiAodXNlcl9pZCAhPSBudWxsKSB7CisgICAgICAgICAgICBTdHJpbmcgdXNlclJvbGVzRnJvbVBvcnRhbCA9IG51bGw7CisgICAgICAgICAgICBTZXQ8U3RyaW5nPiByb2xlcyA9IG51bGw7CisgICAgICAgICAgICB0cnkgeworICAgICAgICAgICAgICAgIHVzZXJSb2xlc0Zyb21Qb3J0YWwgPSBwb3J0YWxDbGllbnQuZmV0Y2hVc2VyUm9sZXNGcm9tUG9ydGFsKHVzZXJfaWQpOworICAgICAgICAgICAgICAgIHJvbGVzID0gbmV3IEhhc2hTZXQ8PihBcnJheXMuYXNMaXN0KHVzZXJSb2xlc0Zyb21Qb3J0YWwpKTsKKyAgICAgICAgICAgIH0gY2F0Y2ggKFJlc3RyaWN0aW9uQWNjZXNzRmlsdGVyRXhjZXB0aW9uIGUpIHsKKyAgICAgICAgICAgICAgICBsb2cuZGVidWcoIkZhaWxlZCB0byBmZXRjaCB1c2VyIElEIC0ge30gZnJvbSBwb3J0YWwiLCB1c2VyX2lkKTsKKyAgICAgICAgICAgICAgICBsb2cuZGVidWcoZS5nZXRNZXNzYWdlKCkpOworICAgICAgICAgICAgfQorICAgICAgICAgICAgVXNlckNvbnRleHQgdXNlckNvbnRleHQgPSBuZXcgVXNlckNvbnRleHQodXNlcl9pZCwgcm9sZXMsIG51bGwsIG51bGwpOworICAgICAgICAgICAgVGhyZWFkTG9jYWxzSG9sZGVyLnNldFVzZXJDb250ZXh0KHVzZXJDb250ZXh0KTsKKyAgICAgICAgfSBlbHNlIGxvZy5kZWJ1ZygidXNlcl9pZCB2YWx1ZSBpbiByZXEgaGVhZGVyIGlzIG51bGwsIHVzZXJDb250ZXh0IHdpbGwgbm90IGJlIGluaXRpYWxpemVkIik7CisgICAgfQorCisgICAgcHJvdGVjdGVkIHZvaWQgc2V0VXNlckNvbnRleHRGcm9tREIoSHR0cFNlcnZsZXRS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dGFuY2VJZCkKLSAgICAgICAgICAgICAgICAgICAgLnJlcXVlc3RJZChyZXF1ZXN0SWQpCi0gICAgICAgICAgICAgICAgICAgIC5kZXNjcmlwdGlvbihnZXRNZXNzYWdlU3RyaW5nKHJlc3BvbnNlRm9ybWF0KSkKLSAgICAgICAgICAgICAgICAgICAgLnN0YXR1cyhyZXNwb25zZUZvcm1hdC5nZXRTdGF0dXMoKSkKLSAgICAgICAgICAgICAgICAgICAgLmJ1aWxkKCksCisgICAgICAgICAgICAgICAgICAgICAgICAuc2VydmljZUluc3RhbmNlSWQoc2VydmljZUluc3RhbmNlSWQpCisgICAgICAgICAgICAgICAgICAgICAgICAucmVxdWVzdElkKHJlcXVlc3RJZCkKKyAgICAgICAgICAgICAgICAgICAgICAgIC5kZXNjcmlwdGlvbihnZXRNZXNzYWdlU3RyaW5nKHJlc3BvbnNlRm9ybWF0KSkKKyAgICAgICAgICAgICAgICAgICAgICAgIC5zdGF0dXMocmVzcG9uc2VGb3JtYXQuZ2V0U3RhdHVzKCkpCisgICAgICAgICAgICAgICAgICAgICAgICAuYnVpbGQoKSwKICAgICAgICAgICAgICAgICByZXNvdXJjZUNvbW1vbkluZm8sIGRpc3RyaWJ1dGlvbkRhdGEsCiAgICAgICAgICAgICAgICAgcHJldlJlc291cmNlVmVyc2lvbkluZm8sIGN1cnJSZXNvdXJjZVZlcnNpb25JbmZvLAogICAgICAgICAgICAgICAgIGludmFyaWFudFV1aWQsIG1vZGlmaWVyKTsKQEAgLTU1OSwxMCArNjA2LDEwIEBACiAgICAgICAgIH0KICAgICAgICAgQXVkaXRFdmVudEZhY3RvcnkgZmFjdG9yeSA9IG5ldyBBdWRpdENydWRFeHRlcm5hbEFwaUFydGlmYWN0RXZlbnRGYWN0b3J5KGFjdGlvbkVudW0sCiAgICAgICAgICAgICAgICAgQ29tbW9uQXVkaXREYXRhLm5ld0J1aWxkZXIoKQotICAgICAgICAgICAgICAgICAgICAuc3RhdHVzKHJlc3BvbnNlRm9ybWF0LmdldFN0YXR1cygpKQotICAgICAgICAgICAgICAgICAgICAuZGVzY3JpcHRpb24oZ2V0TWVzc2FnZVN0cmluZyhyZXNwb25zZUZvcm1hdCkpCi0gICAgICAgICAgICAgICAgICAgIC5yZXF1ZXN0SWQocmVxdWVzdElkKQotICAgICAgICAgICAgICAgICAgICAuYnVpbGQoKSwKKyAgICAgICAgICAgICAgICAgICAgICAgIC5zdGF0dXMocmVzcG9uc2VGb3JtYXQuZ2V0U3RhdHVzKCkpCisgICAgICAgICAgICAgICAgICAgICAgICAuZGVzY3JpcHRpb24oZ2V0TWVzc2FnZVN0cmluZyhyZXNwb25zZUZvcm1hdCkpCisgICAgICAgICAgICAgICAgICAgICAgICAucmVxdWVzdElkKHJlcXVlc3RJZCkKKyAgICAgICAgICAgICAgICAgICAgICAgIC5idWlsZCgpLAogICAgICAgICAgICAgICAgIHJlc291cmNlQ29tbW9uSW5mbywgZGlzdHJpYnV0aW9uRGF0YSwgUmVzb3VyY2VWZXJzaW9uSW5mby5uZXdCdWlsZGVyKCkuYnVpbGQoKSwgY3VyclJlc291cmNlVmVyc2lvbkluZm8sCiAgICAgICAgICAgICAgICAgbnVsbCwgbW9kaWZpZXIsIGFydGlmYWN0RGF0YSk7CiAKQEAgLTY0NCwxMSArNjkxLDExIEBACiAgICAgcHVibGljIHZvaWQgYXVkaXRFeHRlcm5hbEFjdGl2YXRlU2VydmljZShSZXNwb25zZUZvcm1hdCByZXNwb25zZUZvcm1hdCwgRGlzdHJpYnV0aW9uRGF0YSBkaXN0cmlidXRpb25EYXRhLCBTdHJpbmcgcmVxdWVzdElkLCBTdHJpbmcgc2VydmljZUluc3RhbmNlVXVpZCwgVXNlciBtb2RpZmllcikgewogICAgICAgICBBdWRpdEV2ZW50RmFjdG9yeSBmYWN0b3J5ID0gbmV3IEF1ZGl0QWN0aXZhdGVTZXJ2aWNlRXh0ZXJuYWxBcGlFdmVudEZhY3RvcnkoCiAgICAgICAgICAgICAgICAgQ29tbW9uQXVkaXREYXRhLm5ld0J1aWxkZXIoKQotICAgICAgICAgICAgICAgICAgICAuc2VydmljZUluc3RhbmNlSWQoc2VydmljZUluc3RhbmNlVXVpZCkKLSAgICAgICAgICAgICAgICAgICAgLmRlc2NyaXB0aW9uKGdldE1lc3NhZ2VTdHJpbmcocmVzcG9uc2VGb3JtYXQpKQotICAgICAgICAgICAgICAgICAgICAuc3RhdHVzKHJlc3BvbnNlRm9ybWF0LmdldFN0YXR1cygpKQotICAgICAgICAgICAgICAgICAgICAucmVxdWVzdElkKHJlcXVlc3RJZCkKLSAgICAgICAgICAgICAgICAgICAgLmJ1aWxkKCksCisgICAgICAgICAgICAgICAgICAgICAgICAuc2VydmljZUluc3RhbmNlSWQoc2VydmljZUluc3RhbmNlVXVpZCkKKyAgICAgICAgICAgICAgICAgICAgICAgIC5kZXNjcmlwdGlvbihnZXRNZXNzYWdlU3RyaW5nKHJlc3BvbnNlRm9ybWF0KSkKKyAgICAgICAgICAgICAgICAgICAgICAgIC5zdGF0dXMocmVzcG9uc2VGb3JtYXQuZ2V0U3RhdHVzKCkpCisgICAgICAgICAgICAgICAgICAgICAgICAucmVxdWVzdElkKHJlcXVlc3RJZCkKKyAgICAgICAgICAgICAgICAgICAgICAgIC5idWlsZCgpLAogICAgICAgICAgICAgICAgIG5ldyBSZXNvdXJjZUNvbW1vbkluZm8oQ29tcG9uZW50VHlwZUVudW0uU0VSVklDRS5uYW1lKCkpLCBkaXN0cmlidXRpb25EYXRhLCAiIiwgbW9kaWZpZXIpOwogICAgICAgICBnZXRBdWRpdGluZ01hbmFnZXIoKS5hdWRpdEV2ZW50KGZhY3RvcnkpOwogICAgIH0KQEAgLTcyMyw3OSArNzcwLDc5IEBACiAgICAgICAgICAgICByZXR1cm4gcmVzcG9uc2VFbnVtOwogICAgICAgICB9CiAgICAgICAgIHN3aXRjaCAoc3RvcmFnZVJlc3BvbnNlKSB7Ci0gICAgICAgIGNhc2UgT0s6Ci0gICAgICAgICAgICByZXNwb25z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Y3Rpb25TdGF0dXMuRElTVFJJQlVUSU9OX0VOVklST05NRU5UX0lOVkFMSUQ7Ci0gICAgICAgICAgICBicmVhazsKLSAgICAgICAgY2FzZSBJTlZBTElEX1RZUEU6Ci0gICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuSU5WQUxJRF9DT05URU5UOwotICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgIGNhc2UgSU5WQUxJRF9WQUxVRToKLSAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5JTlZBTElEX0NPTlRFTlQ7Ci0gICAgICAgICAgICBicmVhazsKLSAgICAgICAgY2FzZSBDU0FSX05PVF9GT1VORDoKLSAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5DU0FSX05PVF9GT1VORDsKLSAgICAgICAgICAgIGJyZWFrOwotICAgICAgICBjYXNlIFBST1BFUlRZX05BTUVfQUxSRUFEWV9FWElTVFM6Ci0gICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuUFJPUEVSVFlfTkFNRV9BTFJFQURZX0VYSVNUUzsKLSAgICAgICAgICAgIGJyZWFrOwotICAgICAgICBjYXNlIE1BVENIX05PVF9GT1VORDoKLSAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5DT01QT05FTlRfU1VCX0NBVEVHT1JZX05PVF9GT1VORF9GT1JfQ0FURUdPUlk7Ci0gICAgICAgICAgICBicmVhazsKLSAgICAgICAgY2FzZSBDQVRFR09SWV9OT1RfRk9VTkQ6Ci0gICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuQ09NUE9ORU5UX0NBVEVHT1JZX05PVF9GT1VORDsKLSAgICAgICAgICAgIGJyZWFrOwotICAgICAgICBjYXNlIElOVkFMSURfUFJPUEVSVFk6Ci0gICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuSU5WQUxJRF9QUk9QRVJUWTsKLSAgICAgICAgICAgIGJyZWFrOwotICAgICAgICBjYXNlIENPTVBPTkVOVF9JU19BUkNISVZFRDoKLSAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5DT01QT05FTlRfSVNfQVJDSElWRUQ7Ci0gICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgT0s6CisgICAgICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLk9LOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBDT05ORUNUSU9OX0ZBSUxVUkU6CisgICAgICAgICAgICBjYXNlIEdSQVBIX0lTX0xPQ0s6CisgICAgICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLkdFTkVSQUxfRVJST1I7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIEJBRF9SRVFVRVNUOgorICAgICAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5JTlZBTElEX0NPTlRFTlQ7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIEVOVElUWV9BTFJFQURZX0VYSVNUUzoKKyAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuQ09NUE9ORU5UX05BTUVfQUxSRUFEWV9FWElTVDsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgUEFSRU5UX1JFU09VUkNFX05PVF9GT1VORDoKKyAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuUEFSRU5UX1JFU09VUkNFX05PVF9GT1VORDsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgTVVMVElQTEVfUEFSRU5UX1JFU09VUkNFX0ZPVU5EOgorICAgICAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5NVUxUSVBMRV9QQVJFTlRfUkVTT1VSQ0VfRk9VTkQ7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIE5PVF9GT1VORDoKKyAgICAgICAgICAgICAgICBpZiAoQ29tcG9uZW50VHlwZUVudW0uUkVTT1VSQ0UgPT0gdHlwZSkgeworICAgICAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuUkVTT1VSQ0VfTk9UX0ZPVU5EOworICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoQ29tcG9uZW50VHlwZUVudW0uUFJPRFVDVCA9PSB0eXBlKSB7CisgICAgICAgICAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5QUk9EVUNUX05PVF9GT1VORDsKKyAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuU0VSVklDRV9OT1RfRk9VTkQ7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBGQUlMRURfVE9fTE9DS19FTEVNRU5UOgorICAgICAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5DT01QT05FTlRfSU5fVVNFOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBBUlRJRkFDVF9OT1RfRk9VTkQ6CisgICAgICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLkFSVElGQUNUX05PVF9GT1VORDsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgRElTVFJfRU5WSVJPTk1FTlRfTk9UX0FWQUlMQUJMRToKKyAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuRElTVFJJQlVUSU9OX0VOVklST05NRU5UX05PVF9BVkFJTEFCTEU7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIERJU1RSX0VOVklST05NRU5UX05PVF9GT1VORDoKKyAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuRElTVFJJQlVUSU9OX0VOVklST05NRU5UX05PVF9GT1VORDsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgRElTVFJfRU5WSVJPTk1FTlRfU0VOVF9JU19JTlZBTElEOgorICAgICAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5ESVNUUklCVVRJT05fRU5WSVJPTk1FTlRfSU5WQUxJRDsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgSU5WQUxJRF9UWVBFOgorICAgICAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5JTlZBTElEX0NPTlRFTlQ7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIElOVkFMSURfVkFMVUU6CisgICAgICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLklOVkFMSURfQ09OVEVOVDsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgQ1NBUl9OT1RfRk9VTkQ6CisgICAgICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLkNTQVJfTk9UX0ZPVU5EOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBQUk9QRVJUWV9OQU1FX0FMUkVBRFlfRVhJU1RTOgorICAgICAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5QUk9QRVJUWV9OQU1FX0FMUkVBRFlfRVhJU1RTOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBNQVRDSF9OT1RfRk9VTkQ6CisgICAgICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLkNPTVBPTkVOVF9TVUJfQ0FURUdPUllfTk9UX0ZPVU5EX0ZPUl9DQVRFR09SWTsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgQ0FURUdPUllfTk9UX0ZPVU5EOgorICAgICAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5DT01QT05FTlRfQ0FURUdPUllfTk9UX0ZPVU5EOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBJTlZBTElEX1BST1BFUlRZOgorICAgICAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5JTlZBTElEX1BST1BFUlRZOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBDT01QT05FTlRfSVNfQVJDSElWRUQ6CisgICAgICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLkNPTVBPTkVOVF9JU19BUkNISVZFRDsKKyAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgY2FzZSBERUNMQVJFRF9JTlBVVF9VU0VEX0JZX09QRVJBVElPTjoKICAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5ERUNMQVJFRF9JTlBVVF9VU0VEX0JZX09QRVJBVElPTjsKICAgICAgICAgICAgIGJyZWFrOwotICAgICAgIGRlZmF1bHQ6Ci0gICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUjsKLSAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUjsKKyAgICAgIC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U3RhdHVzLkNBUEFCSUxJVFlfVFlQRV9BTFJFQURZX0VYSVNUOwotICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgIGNhc2UgU0NIRU1BX1ZJT0xBVElPTjoKLSAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5DQVBBQklMSVRZX1RZUEVfQUxSRUFEWV9FWElTVDsKLSAgICAgICAgICAgIGJyZWFrOwotICAgICAgICBkZWZhdWx0OgotICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLkdFTkVSQUxfRVJST1I7Ci0gICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgT0s6CisgICAgICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLk9LOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBDT05ORUNUSU9OX0ZBSUxVUkU6CisgICAgICAgICAgICBjYXNlIEdSQVBIX0lTX0xPQ0s6CisgICAgICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLkdFTkVSQUxfRVJST1I7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIEJBRF9SRVFVRVNUOgorICAgICAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5JTlZBTElEX0NPTlRFTlQ7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIEVOVElUWV9BTFJFQURZX0VYSVNUUzoKKyAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuQ0FQQUJJTElUWV9UWVBFX0FMUkVBRFlfRVhJU1Q7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIFNDSEVNQV9WSU9MQVRJT046CisgICAgICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLkNBUEFCSUxJVFlfVFlQRV9BTFJFQURZX0VYSVNUOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUjsKKyAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogICAgICAgICBsb2cuZGVidWcoQ09OVkVSVF9TVE9SQUdFX1JFU1BPTlNFX1RPX0FDVElPTl9SRVNQT05TRSwgc3RvcmFnZVJlc3BvbnNlLCByZXNwb25zZUVudW0pOwogICAgICAgICByZXR1cm4gcmVzcG9uc2VFbnVtOwogICAgIH0KIAogICAgIHB1YmxpYyBBY3Rpb25TdGF0dXMgY29udmVydEZyb21TdG9yYWdlUmVzcG9uc2VGb3JMaWZlY3ljbGVUeXBlKFN0b3JhZ2VPcGVyYXRpb25TdGF0dXMgc3RvcmFnZVJlc3BvbnNlKSB7Ci0gICAgICAgIEFjdGlvblN0YXR1cyByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUjsKKyAgICAgICAgQWN0aW9uU3RhdHVzIHJlc3BvbnNlRW51bTsKIAogICAgICAgICBzd2l0Y2ggKHN0b3JhZ2VSZXNwb25zZSkgewotICAgICAgICBjYXNlIE9LOgotICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLk9LOwotICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgIGNhc2UgQ09OTkVDVElPTl9GQUlMVVJFOgotICAgICAgICBjYXNlIEdSQVBIX0lTX0xPQ0s6Ci0gICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUjsKLSAgICAgICAgICAgIGJyZWFrOwotICAgICAgICBjYXNlIEJBRF9SRVFVRVNUOgotICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLklOVkFMSURfQ09OVEVOVDsKLSAgICAgICAgICAgIGJyZWFrOwotICAgICAgICBjYXNlIEVOVElUWV9BTFJFQURZX0VYSVNUUzoKLSAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5MSUZFQ1lDTEVfVFlQRV9BTFJFQURZX0VYSVNUOwotICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgIGNhc2UgU0NIRU1BX1ZJT0xBVElPTjoKLSAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5MSUZFQ1lDTEVfVFlQRV9BTFJFQURZX0VYSVNUOwotICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgIGRlZmF1bHQ6Ci0gICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUjsKLSAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBPSzoKKyAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuT0s7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIENPTk5FQ1RJT05fRkFJTFVSRToKKyAgICAgICAgICAgIGNhc2UgR1JBUEhfSVNfTE9DSzoKKyAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUjsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgQkFEX1JFUVVFU1Q6CisgICAgICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLklOVkFMSURfQ09OVEVOVDsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgRU5USVRZX0FMUkVBRFlfRVhJU1RTOgorICAgICAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5MSUZFQ1lDTEVfVFlQRV9BTFJFQURZX0VYSVNUOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBTQ0hFTUFfVklPTEFUSU9OOgorICAgICAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5MSUZFQ1lDTEVfVFlQRV9BTFJFQURZX0VYSVNUOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUjsKKyAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogICAgICAgICBsb2cuZGVidWcoQ09OVkVSVF9TVE9SQUdFX1JFU1BPTlNFX1RPX0FDVElPTl9SRVNQT05TRSwgc3RvcmFnZVJlc3BvbnNlLCByZXNwb25zZUVudW0pOwogICAgICAgICByZXR1cm4gcmVzcG9uc2VFbnVtOwogICAgIH0KIAogICAgIHB1YmxpYyBBY3Rpb25TdGF0dXMgY29udmVydEZyb21TdG9yYWdlUmVzcG9uc2VGb3JSZXNvdXJjZUluc3RhbmNlKFN0b3JhZ2VPcGVyYXRpb25TdGF0dXMgc3RvcmFnZVJlc3BvbnNlLCBib29sZWFuIGlzUmVsYXRpb24pIHsKLSAgICAgICAgQWN0aW9uU3RhdHVzIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5HRU5FUkFMX0VSUk9SOworICAgICAgICBBY3Rpb25TdGF0dXMgcmVzcG9uc2VFbnVtOwogCiAgICAgICAgIHN3aXRjaCAoc3RvcmFnZVJlc3BvbnNlKSB7Ci0gICAgICAgIGNhc2UgT0s6Ci0gICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuT0s7Ci0gICAgICAgICAgICBicmVhazsKLSAgICAgICAgY2FzZSBJTlZBTElEX0lEOgotICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLlJFU09VUkNFX0lOU1RB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1VORDsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGJyZWFrOwotICAgICAgICBkZWZhdWx0OgotICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLkdFTkVSQUxfRVJST1I7Ci0gICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgT0s6CisgICAgICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLk9LOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBJTlZBTElEX0lEOgorICAgICAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5SRVNPVVJDRV9JTlNUQU5DRV9CQURfUkVRVUVTVDsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgSU5WQUxJRF9QUk9QRVJUWToKKyAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuSU5WQUxJRF9QUk9QRVJUWTsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgR1JBUEhfSVNfTE9DSzoKKyAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUjsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgQkFEX1JFUVVFU1Q6CisgICAgICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLklOVkFMSURfQ09OVEVOVDsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgTUFUQ0hfTk9UX0ZPVU5EOgorICAgICAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5SRVNPVVJDRV9JTlNUQU5DRV9NQVRDSF9OT1RfRk9VTkQ7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIFNDSEVNQV9WSU9MQVRJT046CisgICAgICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLlJFU09VUkNFX0lOU1RBTkNFX0FMUkVBRFlfRVhJU1Q7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIE5PVF9GT1VORDoKKyAgICAgICAgICAgICAgICBpZiAoaXNSZWxhdGlvbikgeworICAgICAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuUkVTT1VSQ0VfSU5TVEFOQ0VfUkVMQVRJT05fTk9UX0ZPVU5EOworICAgICAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5SRVNPVVJDRV9JTlNUQU5DRV9OT1RfRk9VTkQ7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUjsKKyAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogICAgICAgICBsb2cuZGVidWcoQ09OVkVSVF9TVE9SQUdFX1JFU1BPTlNFX1RPX0FDVElPTl9SRVNQT05TRSwgc3RvcmFnZVJlc3BvbnNlLCByZXNwb25zZUVudW0pOwogICAgICAgICByZXR1cm4gcmVzcG9uc2VFbnVtOwpAQCAtOTM5LDMzICs5ODYsMzMgQEAKICAgICB9CiAKICAgICBwdWJsaWMgQWN0aW9uU3RhdHVzIGNvbnZlcnRGcm9tU3RvcmFnZVJlc3BvbnNlRm9yUmVzb3VyY2VJbnN0YW5jZVByb3BlcnR5KFN0b3JhZ2VPcGVyYXRpb25TdGF0dXMgc3RvcmFnZVJlc3BvbnNlKSB7Ci0gICAgICAgIEFjdGlvblN0YXR1cyByZXNwb25zZUVudW0gPSBBY3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5TVEFOQ0VfTk9UX0ZPVU5EOwotICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgIGRlZmF1bHQ6Ci0gICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUjsKLSAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBPSzoKKyAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuT0s7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIElOVkFMSURfSUQ6CisgICAgICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLlJFU09VUkNFX0lOU1RBTkNFX0JBRF9SRVFVRVNUOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBHUkFQSF9JU19MT0NLOgorICAgICAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5HRU5FUkFMX0VSUk9SOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBCQURfUkVRVUVTVDoKKyAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuSU5WQUxJRF9DT05URU5UOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBNQVRDSF9OT1RfRk9VTkQ6CisgICAgICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLlJFU09VUkNFX0lOU1RBTkNFX01BVENIX05PVF9GT1VORDsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgU0NIRU1BX1ZJT0xBVElPTjoKKyAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuUkVTT1VSQ0VfSU5TVEFOQ0VfQUxSRUFEWV9FWElTVDsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAg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dWRpdEV2ZW50KGZhY3RvcnksIGF1ZGl0KTsKICAgICB9CiAKICAgICBwdWJsaWMgdm9pZCBhdWRpdERpc3RyaWJ1dGlvbk5vdGlmaWNhdGlvbihTdHJpbmcgc2VydmljZVVVSUQsIFN0cmluZyByZXNvdXJjZU5hbWUsIFN0cmluZyByZXNvdXJjZVR5cGUsIFN0cmluZyBjdXJyVmVyc2lvbiwgVXNlciBtb2RpZmllciwgU3RyaW5nIGVudmlyb25tZW50TmFtZSwgU3RyaW5nIGN1cnJTdGF0ZSwKQEAgLTEwODQsMTYgKzExMzQsMTYgQEAKIAogICAgICAgICBBdWRpdEV2ZW50RmFjdG9yeSBmYWN0b3J5ID0gbmV3IEF1ZGl0RGlzdHJpYnV0aW9uTm90aWZpY2F0aW9uRXZlbnRGYWN0b3J5KAogICAgICAgICAgICAgICAgIENvbW1vbkF1ZGl0RGF0YS5uZXdCdWlsZGVyKCkKLSAgICAgICAgICAgICAgICAgICAgLnNlcnZpY2VJbnN0YW5jZUlkKHNlcnZpY2VVVUlEKQotICAgICAgICAgICAgICAgICAgICAuc3RhdHVzKHN0YXR1cykKLSAgICAgICAgICAgICAgICAgICAgLmRlc2NyaXB0aW9uKGRlc2NyaXB0aW9uKQotICAgICAgICAgICAgICAgICAgICAucmVxdWVzdElkKFRocmVhZExvY2Fsc0hvbGRlci5nZXRVdWlkKCkpCi0gICAgICAgICAgICAgICAgICAgIC5idWlsZCgpLAorICAgICAgICAgICAgICAgICAgICAgICAgLnNlcnZpY2VJbnN0YW5jZUlkKHNlcnZpY2VVVUlEKQorICAgICAgICAgICAgICAgICAgICAgICAgLnN0YXR1cyhzdGF0dXMpCisgICAgICAgICAgICAgICAgICAgICAgICAuZGVzY3JpcHRpb24oZGVzY3JpcHRpb24pCisgICAgICAgICAgICAgICAgICAgICAgICAucmVxdWVzdElkKFRocmVhZExvY2Fsc0hvbGRlci5nZXRVdWlkKCkpCisgICAgICAgICAgICAgICAgICAgICAgICAuYnVpbGQoKSwKICAgICAgICAgICAgICAgICBuZXcgUmVzb3VyY2VDb21tb25JbmZvKHJlc291cmNlTmFtZSwgcmVzb3VyY2VUeXBlKSwKICAgICAgICAgICAgICAgICBSZXNvdXJjZVZlcnNpb25JbmZvLm5ld0J1aWxkZXIoKQotICAgICAgICAgICAgICAgICAgICAuc3RhdGUoY3VyclN0YXRlKQotICAgICAgICAgICAgICAgICAgICAudmVyc2lvbihjdXJyVmVyc2lvbikKLSAgICAgICAgICAgICAgICAgICAgLmJ1aWxkKCksCisgICAgICAgICAgICAgICAgICAgICAgICAuc3RhdGUoY3VyclN0YXRlKQorICAgICAgICAgICAgICAgICAgICAgICAgLnZlcnNpb24oY3VyclZlcnNpb24pCisgICAgICAgICAgICAgICAgICAgICAgICAuYnVpbGQoKSwKICAgICAgICAgICAgICAgICBkaXN0cmlidXRpb25JZCwgbW9kaWZpZXIsIHRvcGljTmFtZSwKICAgICAgICAgICAgICAgICBuZXcgT3BlcmF0aW9uYWxFbnZBdWRpdERhdGEoZW52aXJvbm1lbnROYW1lLCB3b3JrbG9hZENvbnRleHQsIHRlbmFudCkpOwogCkBAIC0xMTAzLDI1ICsxMTUzLDI1IEBACiAgICAgcHVibGljIHZvaWQgYXVkaXRBdXRoRXZlbnQoU3RyaW5nIHVybCwgU3RyaW5nIHVzZXIsIFN0cmluZyBhdXRoU3RhdHVzLCBTdHJpbmcgcmVhbG0pIHsKICAgICAgICAgQXVkaXRFdmVudEZhY3RvcnkgZmFjdG9yeSA9IG5ldyBBdWRpdEF1dGhSZXF1ZXN0RXZlbnRGYWN0b3J5KAogICAgICAgICAgICAgICAgIENvbW1vbkF1ZGl0RGF0YS5uZXdCdWlsZGVyKCkKLSAgICAgICAgICAgICAgICAucmVxdWVzdElkKFRocmVhZExvY2Fsc0hvbGRlci5nZXRVdWlkKCkpCi0gICAgICAgICAgICAgICAgLmJ1aWxkKCksCisgICAgICAgICAgICAgICAgICAgICAgICAucmVxdWVzdElkKFRocmVhZExvY2Fsc0hvb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IoKQotICAgICAgICAgICAgICAgIC5kZXNjcmlwdGlvbihlcnJvclJlYXNvbikKLSAgICAgICAgICAgICAgICAuc3RhdHVzKHN0YXR1cykKLSAgICAgICAgICAgICAgICAucmVxdWVzdElkKGRpc3RyaWJ1dGlvbklkKQotICAgICAgICAgICAgICAgIC5idWlsZCgpLAorICAgICAgICAgICAgICAgICAgICAgICAgLmRlc2NyaXB0aW9uKGVycm9yUmVhc29uKQorICAgICAgICAgICAgICAgICAgICAgICAgLnN0YXR1cyhzdGF0dXMpCisgICAgICAgICAgICAgICAgICAgICAgICAucmVxdWVzdElkKGRpc3RyaWJ1dGlvbklkKQorICAgICAgICAgICAgICAgICAgICAgICAgLmJ1aWxkKCksCiAgICAgICAgICAgICAgICAgbmV3IERpc3RyaWJ1dGlvbkRhdGEoY29uc3VtZXJJZCwgcmVzb3VyY2VVcmwpLAogICAgICAgICAgICAgICAgIGRpc3RyaWJ1dGlvbklkLCB0b3BpY05hbWUsIHN0YXR1c1RpbWUpOwogCi0gICAgICAgIGdldEF1ZGl0aW5nTWFuYWdlcigpLmF1ZGl0RXZlbnQoZmFjdG9yeSk7CisgICAgICAgIGdldEF1ZGl0aW5nTWFuYWdlcigpLmF1ZGl0RXZlbnQoZmFjdG9yeSwgYXVkaXQpOwogICAgIH0KIAogICAgIHB1YmxpYyB2b2lkIGF1ZGl0R2V0VWViQ2x1c3RlcihTdHJpbmcgY29uc3VtZXJJZCwgU3RyaW5nIHN0YXR1cywgU3RyaW5nIGRlc2NyaXB0aW9uKSB7CkBAIC0xMTUwLDEzICsxMjAwLDEzIEBACiAKICAgICAgICAgQXVkaXRFdmVudEZhY3RvcnkgZmFjdG9yeSA9IG5ldyBBdWRpdFJlZ1VucmVnRGlzdHJpYnV0aW9uRW5naW5lRXZlbnRGYWN0b3J5KGFjdGlvbiwKICAgICAgICAgICAgICAgICBDb21tb25BdWRpdERhdGEubmV3QnVpbGRlcigpCi0gICAgICAgICAgICAgICAgICAgIC5yZXF1ZXN0SWQoVGhyZWFkTG9jYWxzSG9sZGVyLmdldFV1aWQoKSkKLSAgICAgICAgICAgICAgICAgICAgLnN0YXR1cyhhcHBsaWVkU3RhdHVzKQotICAgICAgICAgICAgICAgICAgICAuYnVpbGQoKSwKKyAgICAgICAgICAgICAgICAgICAgICAgIC5yZXF1ZXN0SWQoVGhyZWFkTG9jYWxzSG9sZGVyLmdldFV1aWQoKSkKKyAgICAgICAgICAgICAgICAgICAgICAgIC5zdGF0dXMoYXBwbGllZFN0YXR1cykKKyAgICAgICAgICAgICAgICAgICAgICAgIC5idWlsZCgpLAogICAgICAgICAgICAgICAgIERpc3RyaWJ1dGlvblRvcGljRGF0YS5uZXdCdWlsZGVyKCkKLSAgICAgICAgICAgICAgICAgICAgLnN0YXR1c1RvcGljKHN0YXR1c1RvcGljTmFtZSkKLSAgICAgICAgICAgICAgICAgICAgLm5vdGlmaWNhdGlvblRvcGljKG5vdGlmVG9waWNOYW1lKQotICAgICAgICAgICAgICAgICAgICAuYnVpbGQoKSwKKyAgICAgICAgICAgICAgICAgICAgICAgIC5zdGF0dXNUb3BpYyhzdGF0dXNUb3BpY05hbWUpCisgICAgICAgICAgICAgICAgICAgICAgICAubm90aWZpY2F0aW9uVG9waWMobm90aWZUb3BpY05hbWUpCisgICAgICAgICAgICAgICAgICAgICAgICAuYnVpbGQoKSwKICAgICAgICAgICAgICAgICBjb25zdW1lcklkLCBhcGlQdWJsaWNLZXksIGVudk5hbWUpOwogCiAgICAgICAgIGdldEF1ZGl0aW5nTWFuYWdlcigpLmF1ZGl0RXZlbnQoZmFjdG9yeSk7CkBAIC0xMTY2LDExICsxMjE2LDExIEBACiAKICAgICAgICAgQXVkaXRFdmVudEZhY3RvcnkgZmFjdG9yeSA9IG5ldyBBdWRpdERpc3RyaWJ1dGlvbkRlcGxveUV2ZW50RmFjdG9yeSgKICAgICAgICAgICAgICAgICBDb21tb25BdWRpdERhdGEubmV3QnVpbGRlcigpCi0gICAgICAgICAgICAgICAgICAgIC5yZXF1ZXN0SWQoVGhyZWFkTG9jYWxzSG9sZGVyLmdldFV1aWQoKSkKLSAgICAgICAgICAgICAgICAgICAgLnNlcnZpY2VJbnN0YW5jZUlkKHNlcnZpY2VVVUlEKQotICAgICAgICAgICAgICAgICAgICAuc3RhdHVzKHN0YXR1cykKLSAgICAgICAgICAgICAgICAgICAgLmRlc2NyaXB0aW9uKGRlc2MpCi0gICAgICAgICAgICAgICAgICAgIC5idWlsZCgpLAorICAgICAgICAgICAgICAgICAgICAgICAgLnJlcXVlc3RJZChUaHJlYWRMb2NhbHNIb2xkZXIuZ2V0VXVpZCgpKQorICAgICAgICAgICAgICAgICAgICAgICAgLnNlcnZpY2VJbnN0YW5jZUlkKHNlcnZpY2VVVUlEKQorICAgICAgICAgICAgICAgICAgICAgICAgLnN0YXR1cyhzdGF0dXMpCisgICAgICAgICAgICAgICAgICAgICAgICAuZGVzY3JpcHRpb24oZGVzYykKKyAgICAgICAgICAgICAgICAgICAgICAgIC5idWlsZCgpLAogICAgICAgICAgICAgICAgIG5ldyBSZXNvdXJjZUNvbW1vbkluZm8oc2VydmljZU5hbWUsICJTZXJ2aWNlIiksCiAgICAgICAgICAgICAgICAgZGlzdHJpYnV0aW9uSWQsCiAgICAgICAgICAgICAgICAgbW9kaWZpZXIsCkBAIC0xMTgzLDEwICsxMjMzLDEwIEBACiAgICAgcHVibGljIHZvaWQgYXVkaXRDb25zdW1lckNyZWRlbnRpYWxzRXZlbnQoQXVkaXRpbmdBY3Rpb25FbnVtIGFjdGlvbkVudW0sIENvbnN1bWVyRGVmaW5pdGlvbiBjb25zdW1lciwgUmVzcG9uc2VGb3JtYXQgcmVzcG9uc2VGb3JtYXQsIFVzZXIgbW9kaWZpZXIpIHsKICAgICAgICAgQXVkaXRFdmVudEZhY3RvcnkgZmFjdG9yeSA9IG5ldyBBdWRpdENvbnN1bWVyRXZlbnRGYWN0b3J5KGFjdGlvbkVudW0sCiAgICAgICAgICAgICAgICAgQ29tbW9uQXVkaXREYXRhLm5ld0J1aWxkZXIoKQotICAgICAgICAgICAgICAgIC5kZXNjcmlwdGlvbihnZXRNZXNzYWdlU3RyaW5nKHJlc3BvbnNlRm9ybWF0KSkKLSAgICAgICAgICAgICAgICAuc3RhdHVzKHJlc3BvbnNlRm9ybWF0LmdldFN0YXR1cygpKQotICAgICAgICAgICAgICAgIC5yZXF1ZXN0SWQoVGhyZWFkTG9jYWxzSG9sZGVyLmdldFV1aWQoKSkKLSAgICAgICAgICAgICAgICAuYnVpbGQoKSwKKyAgICAgICAgICAgICAgICAgICAgICAgIC5kZXNjcmlwdGlvbihnZXRNZXNzYWdlU3RyaW5nKHJlc3BvbnNlRm9ybWF0KSkKKyAgICAgICAgICAgICAgICAgICAgICAgIC5zdGF0dXMocmVzcG9uc2VGb3JtYXQuZ2V0U3RhdHVzKCkpCisgICAgICAgICAgICAgICAgICAgICAgICAucmVxdWVzdElkKFRocmVhZExvY2Fsc0hvbGRlci5nZXRVdWlkKCkpCisgICAgICAgICAgICAgICAgICAgICAgICAuYnVpbGQoKSwKICAgICAgICAgICAgICAgICBtb2RpZmllciwgY29uc3VtZXIpOwogCiAgICAgICAgIGdldEF1ZGl0aW5nTWFuYWdlcigpLmF1ZGl0RXZlbnQoZmFjdG9yeSk7CkBAIC0xMjA0LDYgKzEyNTQsMTMgQEAKICAgICAgICAgZ2V0QXVkaXRpbmdNYW5hZ2VyKCkuYXVkaXRFdmVudChmYWN0b3J5KTsKICAgICB9CiAKKyAgICBwdWJsaWMgdm9pZCBhdWRpdEFkbWluVXNlckFjdGlvbkFuZFRocm93RXhjZXB0aW9uKEF1ZGl0aW5nQWN0aW9uRW51bSBhY3Rpb25FbnVtLCBVc2VyIG1vZGlmaWVyLCBVc2VyIHVzZXJCZWZvcmUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBVc2VyIHVzZXJBZnRlciwgQWN0aW9uU3RhdHVzIHN0YXR1cywgU3RyaW5nLi4u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YXVkaXRFdmVudChmYWN0b3J5KTsKQEAgLTEyNzgsMTggKzEzMzksMTggQEAKICAgICAgICAgQWN0aW9uU3RhdHVzIHJlc3BvbnNlRW51bTsKIAogICAgICAgICBzd2l0Y2ggKHN0b3JhZ2VSZXNwb25zZSkgewotICAgICAgICBjYXNlIE9LOgotICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLk9LOwotICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgIGNhc2UgRU5USVRZX0FMUkVBRFlfRVhJU1RTOgotICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLkNPTVBPTkVOVF9OQU1FX0FMUkVBRFlfRVhJU1Q7Ci0gICAgICAgICAgICBicmVhazsKLSAgICAgICAgY2FzZSBJTlZBTElEX0lEOgotICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLkFERElUSU9OQUxfSU5GT1JNQVRJT05fTk9UX0ZPVU5EOwotICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgIGRlZmF1bHQ6Ci0gICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUjsKLSAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBPSzoKKyAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuT0s7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIEVOVElUWV9BTFJFQURZX0VYSVNUUzoKKyAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuQ09NUE9ORU5UX05BTUVfQUxSRUFEWV9FWElTVDsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgSU5WQUxJRF9JRDoKKyAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuQURESVR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gICAgIGNhc2UgSU5WQUxJRF9QUk9QRVJUWV9ERUZBVUxUX1ZBTFVFOgotICAgICAgICBjYXNlIElOVkFMSURfUFJPUEVSVFlfVFlQRToKLSAgICAgICAgY2FzZSBJTlZBTElEX1BST1BFUlRZX1ZBTFVFOgotICAgICAgICBjYXNlIElOVkFMSURfUFJPUEVSVFlfTkFNRToKLSAgICAgICAgY2FzZSBNSVNTSU5HX0VOVFJZX1NDSEVNQV9UWVBFOgotICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLklOVkFMSURfUFJPUEVSVFk7Ci0gICAgICAgICAgICBicmVhazsKLSAgICAgICAgZGVmYXVsdDoKLSAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5HRU5FUkFMX0VSUk9SOwotICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIE9LOgorICAgICAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5PSzsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgRUxFTUVOVF9OT1RfRk9VTkQ6CisgICAgICAgICAgICAgICAgaWYoZWxlbWVudFR5cGUhPSBudWxsICYmIGVsZW1lbnRUeXBlID09IEpzb25QcmVzZW50YXRpb25GaWVsZHMuUFJPUEVSVFkpeworICAgICAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuUFJPUEVSVFlfTk9UX0ZPVU5EOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgSU5WQUxJRF9QUk9QRVJUWV9ERUZBVUxUX1ZBTFVFOgorICAgICAgICAgICAgY2FzZSBJTlZBTElEX1BST1BFUlRZX1RZUEU6CisgICAgICAgICAgICBjYXNlIElOVkFMSURfUFJPUEVSVFlfVkFMVUU6CisgICAgICAgICAgICBjYXNlIElOVkFMSURfUFJPUEVSVFlfTkFNRToKKyAgICAgICAgICAgIGNhc2UgTUlTU0lOR19FTlRSWV9TQ0hFTUFfVFlQRToKKyAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuSU5WQUxJRF9QUk9QRVJUWTsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLkdFTkVSQUxfRVJST1I7CisgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIH0KICAgICAgICAgcmV0dXJuIHJlc3BvbnNlRW51bTsKICAgICB9CkBAIC0xMzY4LDg3ICsxNDI5LDg3IEBACiAgICAgICAgIEFjdGlvblN0YXR1cyByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUjsKIAogICAgICAgICBzd2l0Y2ggKHN0b3JhZ2VSZXNwb25zZSkgewotICAgICAgICBjYXNlIE9LOgotICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLk9LOwotICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgIGNhc2UgQ09OTkVDVElPTl9GQUlMVVJFOgotICAgICAgICBjYXNlIEdSQVBIX0lTX0xPQ0s6Ci0gICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUjsKLSAgICAgICAgICAgIGJyZWFrOwotICAgICAgICBjYXNlIEJBRF9SRVFVRVNUOgotICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLklOVkFMSURfQ09OVEVOVDsKLSAgICAgICAgICAgIGJyZWFrOwotICAgICAgICBjYXNlIEVOVElUWV9BTFJFQURZX0VYSVNUUzoKLSAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5DT05TVU1FUl9BTFJFQURZX0VYSVNUUzsKLSAgICAgICAgICAgIGJyZWFrOwotICAgICAgICBjYXNlIFNDSEVNQV9WSU9MQVRJT046Ci0gICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuQ09OU1VNRVJfQUxSRUFEWV9FWElTVFM7Ci0gICAgICAgICAgICBicmVhazsKLSAgICAgICAgY2FzZSBOT1RfRk9VTkQ6Ci0gICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuRUNPTVBfVVNFUl9OT1RfRk9VTkQ7Ci0gICAgICAgICAgICBicmVhazsKLSAgICAgICAgZGVmYXVsdDoKLSAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5HRU5FUkFMX0VSUk9SOwotICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIE9LOgorICAgICAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5PSzsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgQ09OTkVDVElPTl9GQUlMVVJFOgorICAgICAgICAgICAgY2FzZSBHUkFQSF9JU19MT0NLOgorICAgICAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5HRU5FUkFMX0VSUk9SOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBCQURfUkVRVUVTVDoKKyAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuSU5WQUxJRF9DT05URU5UOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBFTlRJVFlfQUxSRUFEWV9FWElTVFM6CisgICAgICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLkNPTlNVTUVSX0FMUkVBRFlfRVhJU1RTOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBTQ0hFTUFfVklPT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jYXNlIEdSQVBIX0lTX0xPQ0s6Ci0gICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUjsKLSAgICAgICAgICAgIGJyZWFrOwotICAgICAgICBjYXNlIEJBRF9SRVFVRVNUOgotICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLklOVkFMSURfQ09OVEVOVDsKLSAgICAgICAgICAgIGJyZWFrOwotICAgICAgICBjYXNlIEVOVElUWV9BTFJFQURZX0VYSVNUUzoKLSAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5HUk9VUF9UWVBFX0FMUkVBRFlfRVhJU1Q7Ci0gICAgICAgICAgICBicmVhazsKLSAgICAgICAgY2FzZSBTQ0hFTUFfVklPTEFUSU9OOgotICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLkdST1VQX1RZUEVfQUxSRUFEWV9FWElTVDsKLSAgICAgICAgICAgIGJyZWFrOwotICAgICAgICBkZWZhdWx0OgotICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLkdFTkVSQUxfRVJST1I7Ci0gICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgT0s6CisgICAgICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLk9LOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBDT05ORUNUSU9OX0ZBSUxVUkU6CisgICAgICAgICAgICBjYXNlIEdSQVBIX0lTX0xPQ0s6CisgICAgICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLkdFTkVSQUxfRVJST1I7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIEJBRF9SRVFVRVNUOgorICAgICAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5JTlZBTElEX0NPTlRFTlQ7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIEVOVElUWV9BTFJFQURZX0VYSVNUUzoKKyAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuR1JPVVBfVFlQRV9BTFJFQURZX0VYSVNUOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBTQ0hFTUFfVklPTEFUSU9OOgorICAgICAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5HUk9VUF9UWVBFX0FMUkVBRFlfRVhJU1Q7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5HRU5FUkFMX0VSUk9SOworICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICB9CiAgICAgICAgIGxvZy5kZWJ1ZyhDT05WRVJUX1NUT1JBR0VfUkVTUE9OU0VfVE9fQUNUSU9OX1JFU1BPTlNFLCBzdG9yYWdlUmVzcG9uc2UsIHJlc3BvbnNlRW51bSk7CiAgICAgICAgIHJldHVybiByZXNwb25zZUVudW07CiAgICAgfQogCiAgICAgcHVibGljIEFjdGlvblN0YXR1cyBjb252ZXJ0RnJvbVN0b3JhZ2VSZXNwb25zZUZvckRhdGFUeXBlKFN0b3JhZ2VPcGVyYXRpb25TdGF0dXMgc3RvcmFnZVJlc3BvbnNlKSB7Ci0gICAgICAgIEFjdGlvblN0YXR1cyByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUjsKKyAgICAgICAgQWN0aW9uU3RhdHVzIHJlc3BvbnNlRW51bTsKIAogICAgICAgICBzd2l0Y2ggKHN0b3JhZ2VSZXNwb25zZSkgewotICAgICAgICBjYXNlIE9LOgotICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLk9LOwotICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgIGNhc2UgQ09OTkVDVElPTl9GQUlMVVJFOgotICAgICAgICBjYXNlIEdSQVBIX0lTX0xPQ0s6Ci0gICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUjsKLSAgICAgICAgICAgIGJyZWFrOwotICAgICAgICBjYXNlIEJBRF9SRVFVRVNUOgotICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLklOVkFMSURfQ09OVEVOVDsKLSAgICAgICAgICAgIGJyZWFrOwotICAgICAgICBjYXNlIEVOVElUWV9BTFJFQURZX0VYSVNUUzoKLSAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5EQVRBX1RZUEVfQUxSRUFEWV9FWElTVDsKLSAgICAgICAgICAgIGJyZWFrOwotICAgICAgICBjYXNlIFNDSEVNQV9WSU9MQVRJT046Ci0gICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuREFUQV9UWVBFX0FMUkVBRFlfRVhJU1Q7Ci0gICAgICAgICAgICBicmVhazsKLSAgICAgICAgY2FzZSBDQU5OT1RfVVBEQVRFX0VYSVNUSU5HX0VOVElUWToKLSAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5EQVRBX1RZUEVfQ0FOTk9UX0JFX1VQREFURURfQkFEX1JFUVVFU1Q7Ci0gICAgICAgICAgICBicmVhazsKLSAgICAgICAgZGVmYXVsdDoKLSAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5HRU5FUkFMX0VSUk9SOwotICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIE9LOgorICAgICAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5PSzsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgQ09OTkVDVElPTl9GQUlMVVJFOgorICAgICAgICAgICAgY2FzZSBHUkFQSF9JU19MT0NLOgorICAgICAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5HRU5FUkFMX0VSUk9SOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBCQURfUkVRVUVTVDoKKyAgICAgICAgICAgICAgICByZXNwb25zZUVudW0gPSBBY3Rpb25TdGF0dXMuSU5WQUxJRF9DT05URU5UOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBFTlRJVFlfQUxSRUFEWV9FWElTVFM6CisgICAgICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLkRBVEFfVFlQRV9BTFJFQURZX0VYSVNUOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBTQ0hFTUFfVklPTEFUSU9OOgorICAgICAgICAgICAgICAgIHJlc3BvbnNlRW51bSA9IEFjdGlvblN0YXR1cy5EQVRBX1RZUEVfQUxSRUFEWV9FWElTVDsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgQ0FOTk9UX1VQREFURV9FWElTVElOR19FTlRJVFk6CisgICAgICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLkRBVEFfVFlQRV9DQU5OT1RfQkVfVVBEQVRFRF9CQURfUkVRVUVTVDsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgcmVzcG9uc2VFbnVtID0gQWN0aW9uU3RhdHVzLkdFTkVSQUxfRVJST1I7CisgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIH0KICAgICAgICAgbG9nLmRlYnVnKENPTlZFUlRfU1RPUkFHRV9SRVNQT05TRV9UT19BQ1RJT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CiB9CmRpZmYgLS1naXQgYS9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvaW1wbC9Eb3dubG9hZEFydGlmYWN0TG9naWMuamF2YSBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9pbXBsL0Rvd25sb2FkQXJ0aWZhY3RMb2dpYy5qYXZhCmRlbGV0ZWQgZmlsZSBtb2RlIDEwMDY0NAppbmRleCBmZWY1Zjg2Li4wMDAwMDAwCi0tLSBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9pbXBsL0Rvd25sb2FkQXJ0aWZhY3RMb2dpYy5qYXZhCisrKyAvZGV2L251bGwKQEAgLTEsMTQwICswLDAgQEAKLS8qLQotICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIFNEQwotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIENvcHlyaWdodCAoQykgMjAxNyBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKLSAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KLSAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZ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gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKiBMaXN0IDwgPyBleHRlbmRzIElSZXNvdXJjZURhdGE+IGFydGlmYWN0c0xpc3QKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqLywgU3RyaW5nIHNlcnZsZXRQYXRoKSB7Ci0gICAgICAgIFJlc3BvbnNlIHJlc3BvbnNlOwotICAgICAgICBMaXN0PEFydGlmYWN0QWNjZXNzSW5mbz4gYXJ0aWZhY3RBY2Nlc3NJbmZvczsKLSAgICAgICAgaWYgKGdldEFydGlmYWN0c1N0YXR1cy5pc1JpZ2h0KCkpIHsKLSAgICAgICAgICAgIC8vIGlmIHRoZXJlIGFyZSBubyBhcnRpZmFjdHMgLSByZXR1cm4gTm8tQ29udGVudAotICAgICAgICAgICAgUmVzb3VyY2VVcGxvYWRTdGF0dXMgc3RhdHVzID0gZ2V0QXJ0aWZhY3RzU3RhdHVzLnJpZ2h0KCkudmFsdWUoKTsKLSAgICAgICAgICAgIGlmIChzdGF0dXMgPT0gUmVzb3VyY2VVcGxvYWRTdGF0dXMuQ09NUE9ORU5UX05PVF9FWElTVCB8fCBzdGF0dXMgPT0gUmVzb3VyY2VVcGxvYWRTdGF0dXMuU0VSVklDRV9OT1RfRVhJU1QpIHsKLSAgICAgICAgICAgICAgICBsb2cuZGVidWcoInJlc291cmNlIHt9IGRvZXMgbm90IGV4aXN0Iiwgc2VydmljZU5hbWUpOwotICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gUmVzcG9uc2Uuc3RhdHVzKEh0dHBTdGF0dXMuU0NfTk9UX0ZPVU5EKS5lbnRpdHkoIltdIikuYnVpbGQoKTsKLQotICAgICAgIC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9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvaW5mby9BcnRpZmFjdEFjY2Vzc0luZm8uamF2YQpkZWxldGVkIGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggNDkwNjg0ZS4uMDAwMDAwMAotLS0gYS9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvaW5mby9BcnRpZmFjdEFjY2Vzc0luZm8uamF2YQorKysgL2Rldi9udWxsCkBAIC0xLDEzMiArMCwwIEBACi0vKi0KLSAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBTREMKLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBDb3B5cmlnaHQgKEMpIDIwMTcgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7Ci0gKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCi0gKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKLSAqIAotICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKLSAqIAotICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9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i0vKi0KLSAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBTREMKLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBDb3B5cmlnaHQgKEMpIDIwMTcgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7Ci0gKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCi0gKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKLSAqIAotICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKLSAqIAotICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZQotICogZGlzdHJpYnV0ZWQgdW5kZXIgdGhlIExpY2Vuc2UgaXMgZGlzdHJpYnV0ZWQgb24gYW4gIkFTIElTIiBCQVNJUywKLSAqIFdJVEhPVVQgV0FSUkFOVElFUyBPUiBDT05ESVRJT05TIE9GIEFOWSBLSU5ELCBlaXRoZXIgZXhwcmVzcyBvciBpbXBsaWVkLgotICogU2VlIHRoZSBMaWNlbnNlIGZvciB0aGUgc3BlY2lmaWMgbGFuZ3VhZ2UgZ292ZXJuaW5nIHBlcm1pc3Npb25zIGFuZAotICogbGltaXRhdGlvbnMgdW5kZXIgdGhlIExpY2Vuc2UuCi0gKiA9PT09PT09PT09PT1MSUNFTlNFX0VORD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogTW9kaWZpY2F0aW9ucyBjb3B5cmlnaHQgKGMpIDIwMTkgTm9raWEKLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKi8KLQotcGFja2FnZSBvcmcub3BlbmVjb21wLnNkYy5iZS5pbmZvOwotCi1pbXBvcnQgamF2YS51dGlsLkxpc3Q7Ci0KLXB1YmxpYyBjbGFzcyBBcnRpZmFjdEFjY2Vzc0xpc3QgewotCi0gICAgQXJ0aWZhY3RBY2Nlc3NMaXN0KCkge30KLQotICAgIHByaXZhdGUgTGlzdDxBcnRpZmFjdEFjY2Vzc0luZm8+IGFydGlmYWN0czsKLQotICAgIHB1YmxpYyBBcnRpZmFjdEFjY2Vzc0xpc3QoTGlzdDxBcnRpZmFjdEFjY2Vzc0luZm8+IGFydGlmYWN0cykgewotICAgICAgICB0aGlzLmFydGlmYWN0cyA9IGFydGlmYWN0czsKLSAgICB9Ci0KLSAgICBwdWJsaWMgTGlzdDxBcnRpZmFjdEFjY2Vzc0luZm8+IGdldEFydGlmYWN0cygpIHsKLSAgICAgICAgcmV0dXJuIGFydGlmYWN0czsKLSAgICB9Ci0KLSAgICBwdWJsaWMgdm9pZCBzZXRBcnRpZmFjdHMoTGlzdDxBcnRpZmFjdEFjY2Vzc0luZm8+IGFydGlmYWN0cykgewotICAgICAgICB0aGlzLmFydGlmYWN0cyA9IGFydGlmYWN0czsKLSAgICB9Ci19CmRpZmYgLS1naXQgYS9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvaW5mby9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8gTW9uaXRvcmluZyBzZXJ2aWNlCmRpZmYgLS1naXQgYS9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvbWl4aW4vQ29tcG9uZW50SW5zdGFuY2VJbnB1dE1peGluLmphdmEgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvbWl4aW4vQ29tcG9uZW50SW5zdGFuY2VJbnB1dE1peGluLmphdmEKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uNTQ3YWUxNwotLS0gL2Rldi9udWxsCisrKyBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9taXhpbi9Db21wb25lbnRJbnN0YW5jZUlucHV0TWl4aW4uamF2YQpAQCAtMCwwICsxLDQyIEBACisvKi0KKyAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBTREMKKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBDb3B5cmlnaHQgKEMpIDIwMjAgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7CisgKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCisgKiBZb3UgbWF5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PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAyMCBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKKyAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KKyAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAorICoKKyAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wCisgKgorICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZQorICogZGlzdHJpYnV0ZWQgdW5kZXIgdGhlIExpY2Vuc2UgaXMgZGlzdHJpYnV0ZWQgb24gYW4gIkFTIElTIiBCQVNJUywKKyAqIFdJVEhPVVQgV0FSUkFOVElFUyBPUiBDT05ESVRJT05TIE9GIEFOWSBLSU5ELCBlaXRoZXIgZXhwcmVzcyBvciBpbXBsaWVkLgorICogU2VlIHRoZSBMaWNlbnNlIGZvciB0aGUgc3BlY2lmaWMgbGFuZ3VhZ2UgZ292ZXJuaW5nIHBlcm1pc3Npb25zIGFuZAorICogbGltaXRhdGlvbnMgdW5k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N0cmluZyBnZXRWYWx1ZVVuaXF1ZVVpZCgpOworfQpkaWZmIC0tZ2l0IGEvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL21peGluL0lucHV0RGVmaW5pdGlvbk1peGluLmphdmEgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvbWl4aW4vSW5wdXREZWZpbml0aW9uTWl4aW4uamF2YQpuZXcgZmlsZSBtb2RlIDEwMDY0NAppbmRleCAwMDAwMDAwLi5kYmE3ZmY1Ci0tLSAvZGV2L251bGwKKysrIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL21peGluL0lucHV0RGVmaW5pdGlvbk1peGluLmphdmEKQEAgLTAsMCArMSwzOCBAQAorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDIwIEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgorICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIH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0cmluZyBnZXRUeXBlKCk7CisgICAgQEpzb25Qcm9wZXJ0eQorICAgIGFic3RyYWN0IFN0cmluZyBnZXRVbmlxdWVJZCgpOworICAgIEBKc29uUHJvcGVydHkKKyAgICBhYnN0cmFjdCBTdHJpbmcgZ2V0VmFsdWUoKTsKKyAgICBASnNvblByb3BlcnR5CisgICAgYWJzdHJhY3QgYm9vbGVhbiBpc0dldElucHV0UHJvcGVydHkoKTsKKyAgICBASnNvblByb3BlcnR5CisgICAgYWJzdHJhY3QgTGlzdDxQcm9wZXJ0eUNvbnN0cmFpbnQ+IGdldENvbnN0cmFpbnRzKCk7Cit9CmRpZmYgLS1naXQgYS9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvbW9uaXRvcmluZy9Fc0dhdGV3YXkuamF2YSBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9tb25pdG9yaW5nL0VzR2F0ZXdheS5qYXZhCmRlbGV0ZWQgZmlsZSBtb2RlIDEwMDY0NAppbmRleCBiZmRhMDRlLi4wMDAwMDAwCi0tLSBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9tb25pdG9yaW5nL0VzR2F0ZXdheS5qYXZhCisrKyAvZGV2L251bGwKQEAgLTEsOTAgKzAsMCBAQAotLyotCi0gKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogU0RDCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgotICogPT09PT09PT09PT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udW0uU0VSVklDRV9QQVJBTV9OQU1FLmVxdWFsc0lnbm9yZUNhc2UoY29tcG9uZW50VHlwZSkpIHsKLSAgICAgICAgICAgICAgICBpc1ZhbGlkID0gdHJ1ZTsKLSAgICAgICAgICAgICAgICBjb21wb25lbnRUeXBlV3JhcHBlci5zZXRJbm5lckVsZW1lbnQoQ29tcG9uZW50VHlwZUVudW0uU0VSVklDRSk7Ci0gICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgIGlzVmFsaWQgPSBmYWxzZTsKLSAgICAgICAgICAgIH0KKyAgICAgICAgICAgIHRocm93IG5ldyBCeUFjdGlvblN0YXR1c0NvbXBvbmVudEV4Y2VwdGlvbihBY3Rpb25TdGF0dXMuVU5TVVBQT1JURURfRVJST1IpOwogICAgICAgICB9Ci0gICAgICAgIGlmICghaXNWYWxpZCkgewotICAgICAgICAgICAgbG9nLmRlYnVnKCJJbnZhbGlkIGNvbXBvbmVudFR5cGU6e30iLCBjb21wb25lbnRUeXBlKTsKLSAgICAgICAgICAgIHJlc3BvbnNlV3JhcHBlci5zZXRJbm5lckVsZW1lbnQoYnVpbGRFcnJvclJlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5VTlNVUFBPUlRFRF9FUlJPUiwgY29tcG9uZW50VHlwZSkpKTsKKyAgICAgICAgaWYgKENvbXBvbmVudFR5cGVFbnVtLlJFU09VUkNFX1BBUkFNX05BTUUuZXF1YWxzSWdub3JlQ2FzZShjb21wb25lbnRUeXBlKSkgeworICAgICAgICAgICAgcmV0dXJuIENvbXBvbmVudFR5cGVFbnVtLlJFU09VUkNFOwogICAgICAgICB9CisgICAgICAgIGlmIChDb21wb25lbnRUeXBlRW51bS5TRVJWSUNFX1BBUkFNX05BTUUuZXF1YWxzSWdub3JlQ2FzZShjb21wb25lbnRUeXBlKSkgeworICAgICAgICAgICAgcmV0dXJuIENvbXBvbmVudFR5cGVFbn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nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvQWRkaXRpb25hbEluZm9ybWF0aW9uU2VydmxldC5qYXZhIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL3NlcnZsZXRzL0FkZGl0aW9uYWxJbmZvcm1hdGlvblNlcnZsZXQuamF2YQppbmRleCBjMTM3ZTZmLi5iNzc2ZjdlIDEwMDY0NAotLS0gYS9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvQWRkaXRpb25hbEluZm9ybWF0aW9uU2VydmxldC5qYXZhCisrKyBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9BZGRpdGlvbmFsSW5mb3JtYXRpb25TZXJ2bGV0LmphdmEKQEAgLTEsNjA5ICsxLDYzNyBAQAotLyotDQotICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NCi0gKiBTREMNCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLSAqIENvcHlyaWdodCAoQykgMjAxNyBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLSAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOw0KLSAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIG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SQUxfRVJST1IpOw0KLSAgICAgICAgICAgIHJldHVybiBidWlsZEVycm9yUmVzcG9uc2UocmVzcG9uc2VGb3JtYXQpOw0KLSAgICAgICAgfQ0KLQ0KLSAgICB9DQotDQotfQ0KKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAxNyBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKKyAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KKyAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAorICogCisgKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAorICogCisgKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlCisgKiBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0cmlidXRlZCBvbiBhbiAiQVMgSVMiIEJBU0lTLAorICogV0lUSE9VVCBXQVJSQU5USUVTIE9SIENPTkRJVElPTlMgT0YgQU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KKworICAgICAgICBTZXJ2bGV0Q29udGV4dCBjb250ZXh0ID0gcmVxdWVzdC5nZXRTZXNzaW9uKCkuZ2V0U2VydmxldENvbnRleHQoKTsKKworICAgICAgICBTdHJpbmcgdXJsID0gcmVxdWVzdC5nZXRNZXRob2QoKSArICIgIiArIHJlcXVlc3QuZ2V0UmVxdWVzdFVSSSgpOworICAgICAgICBsb2cuZGVidWcoU1RBUlRfSEFORExFX1JFUVVFU1RfT0YsIHVybCk7CisgICAgICAgIGxvZy5kZWJ1ZyhNT0RJRklFUl9JRF9JUywgdXNlcklkKTsKKworICAgICAgICB0cnkgeworCisgICAgICAgICAgICBBZGRpdGlvbmFsSW5mb1BhcmFtZXRlckluZm8gYWRkaXRpb25hbEluZm9QYXJhbWV0ZXJJbmZvID0gbmV3IEFkZGl0aW9uYWxJbmZvUGFyYW1ldGVySW5mbygpOworICAgICAgICAgICAgYWRkaXRpb25hbEluZm9QYXJhbWV0ZXJJbmZvLnNldFVuaXF1ZUlkKGxhYmVsSWQpOworCisgICAgICAgICAgICBFaXRoZXI8QWRkaXRpb25hbEluZm9QYXJhbWV0ZXJJbmZvLCBSZXNwb25zZUZvcm1hdD4gZWl0aGVyID0gYnVzaW5lc3NMb2dpYy5kZWxldGVBZGRpdGlvbmFsSW5mb3JtYXRpb24obm9kZVR5cGUsIHVuaXF1ZUlkLCBhZGRpdGlvbmFsSW5mb1BhcmFtZXRlckluZm8sIHVzZXJJZCk7CisKKyAgICAgICAgICAgIGlmIChlaXRoZXIuaXNSaWdodCgpKSB7CisgICAgICAgICAgICAgICAgUmVzcG9uc2VGb3JtYXQgcmVzcG9uc2VGb3JtYXQgPSBlaXRoZXIucmlnaHQoKS52YWx1ZSgpOworICAgICAgICAgICAgICAgIGxvZy5pbmZvKEZBSUxFRF9UT19VUERBVEVfQURESVRJT05BTF9JTkZPX1BST1BFUlRZLCByZXNwb25zZUZvcm1hdCk7CisgICAgICAgICAgICAgICAgcmV0dXJuIGJ1aWxkRXJyb3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sSW5mb3JtYXRpb25EZWZpbml0aW9uID0gZWl0aGVyLmxlZnQoKS52YWx1ZSgpOworCisgICAgICAgICAgICBsb2cuZGVidWcoIkFsbCBBZGRpdGlvbmFsIGluZm9ybWF0aW9uIHJldHJpZXZlZCBmb3IgY29tcG9uZW50IHt9IGlzIHt9IiwgdW5pcXVlSWQsIGFkZGl0aW9uYWxJbmZvcm1hdGlvbkRlZmluaXRpb24pOworCisgICAgICAgICAgICBSZXNwb25zZUZvcm1hdCByZXNwb25zZUZvcm1hdCA9IGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5PSyk7CisgICAgICAgICAgICByZXR1cm4gYnVpbGRPa1Jlc3BvbnNlKHJlc3BvbnNlRm9ybWF0LCBhZGRpdGlvbmFsSW5mb3JtYXRpb25EZWZpbml0aW9uKTsKKworICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZSkgeworICAgICAgICAgICAgQmVFY29tcEVycm9yTWFuYWdlci5nZXRJbnN0YW5jZSgpLmxvZ0JlUmVzdEFwaUdlbmVyYWxFcnJvcigiR2V0IEFsbCBBZGRpdGlvbmFsIEluZm9ybWF0aW9uIik7CisgICAgICAgICAgICBsb2cuZGVidWcoIkdldCBhbGwgYWRkaW90YW5sIGluZm9ybWF0aW9uIHByb3BlcnRpZXMgZmFpbGVkIHdpdGggZXhjZXB0aW9uIiwgZSk7CisgICAgICAgICAgICBSZXNwb25zZUZvcm1hdCByZXNwb25zZUZvcm1hdCA9IGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5HRU5FUkFMX0VSUk9SKTsKKyAgICAgICAgICAgIHJldHVybiBidWlsZEVycm9yUmVzcG9uc2UocmVzcG9uc2VGb3JtYXQpOworICAgICAgICB9CisKKyAgICB9CisKK30KZGlmZiAtLWdpdCBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9BcmNoaXZlRW5kcG9pbnQuamF2YSBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9BcmNoaXZlRW5kcG9pbnQuamF2YQppbmRleCAzZGQ1ODJjLi44YzNjYTM3IDEwMDY0NAotLS0gYS9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvQXJjaGl2ZUVuZHBvaW50LmphdmEKKysrIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL3NlcnZsZXRzL0FyY2hpdmVFbmRwb2ludC5qYXZhCkBAIC0xLDE4NiArMSwyMTkgQEAKLS8qLQ0KLSAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogU0RDDQotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NCi0gKiBDb3B5cmlnaHQgKEMpIDIwMTkgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NCi0gKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsNCi0gKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuDQotICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZ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YXJJZHMpOw0KLSAgICAgICAgICAgIHJldHVybiBSZXNwb25zZS5zdGF0dXMoUmVzcG9uc2UuU3RhdHVzLklOVEVSTkFMX1NFUlZFUl9FUlJPUikNCi0gICAgICAgICAgICAgICAgICAgIC5lbnRpdHkoZW50aXR5KQ0KLSAgICAgICAgICAgICAgICAgICAgLmJ1aWxkKCk7DQotICAgICAgICB9DQotICAgICAgICByZXR1cm4gUmVzcG9uc2Uub2soKS5idWlsZCgpOw0KLSAgICB9DQotDQotfQ0KKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAxOSBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKKyAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KKyAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAorICogCisgKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAorICogCisgKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3Y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KKyAgICAgICAgICAgIGVudGl0eS5wdXQoImZhaWxlZElkcyIsIGZhaWxlZENzYXJJZHMpOworICAgICAgICAgICAgcmV0dXJuIFJlc3BvbnNlLnN0YXR1cyhSZXNwb25zZS5TdGF0dXMuSU5URVJOQUxfU0VSVkVSX0VSUk9SKQorICAgICAgICAgICAgICAgICAgICAuZW50aXR5KGVudGl0eSkKKyAgICAgICAgICAgICAgICAgICAgLmJ1aWxkKCk7CisgICAgICAgIH0KKyAgICAgICAgcmV0dXJuIFJlc3BvbnNlLm9rKCkuYnVpbGQoKTsKKyAgICB9CisKK30KZGlmZiAtLWdpdCBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9BcnRpZmFjdFNlcnZsZXQuamF2YSBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9BcnRpZmFjdFNlcnZsZXQuamF2YQppbmRleCAyYjU1ZmZhLi5lYmI1NzZmIDEwMDY0NAotLS0gYS9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvQXJ0aWZhY3RTZXJ2bGV0LmphdmEKKysrIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL3NlcnZsZXRzL0FydGlmYWN0U2VydmxldC5qYXZhCkBAIC0xLDc5NiArMSw4MTYgQEAKLS8qLQ0KLSAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogU0RDDQotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NCi0gKiBDb3B5cmlnaHQgKEMpIDIwMTcgQV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Sk7DQotICAgICAgICAgICAgfQ0KLSAgICAgICAgfQ0KLSAgICAgICAgcmV0dXJuIHJlc3BvbnNlOw0KLQ0KLSAgICB9DQotDQotICAgIHByaXZhdGUgUmVzcG9uc2UgaGFuZGxlQXJ0aWZhY3RSZXF1ZXN0KFN0cmluZyBkYXRhLCBTdHJpbmcgY29tcG9uZW50SWQsIFN0cmluZyBhcnRpZmFjdElkLCBDb21wb25lbnRUeXBlRW51bSBjb21wb25lbnRUeXBlLCBBcnRpZmFjdE9wZXJhdGlvbkVudW0gb3BlcmF0aW9uKSB7DQotICAgICAgICByZXR1cm4gaGFuZGxlQXJ0aWZhY3RSZXF1ZXN0KGRhdGEsIHNlcnZsZXRSZXF1ZXN0LCBjb21wb25lbnRJZCwgbnVsbCwgbnVsbCwgYXJ0aWZhY3RJZCwgY29tcG9uZW50VHlwZSwgb3BlcmF0aW9uLCBudWxsLCBudWxsKTsNCi0gICAgfQ0KLQ0KLX0NCisvKi0KKyAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBTREMKKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBDb3B5cmlnaHQgKEMpIDIwMTcgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7CisgKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggd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BoYW5kbGVBcnRpZmFjdFJlcXVlc3QoZGF0YSwgc2VydmxldFJlcXVlc3QsIGNvbXBvbmVudElkLCBudWxsLCBudWxsLCBhcnRpZmFjdElkLCBjb21wb25lbnRUeXBlLCBvcGVyYXRpb24sIG51bGwsIG51bGwsIGZhbHNlKTsKKyAgICB9CisKK30KZGlmZiAtLWdpdCBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9BdHRyaWJ1dGVTZXJ2bGV0LmphdmEgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvQXR0cmlidXRlU2VydmxldC5qYXZhCmluZGV4IDFlZDFlNDAuLmFhZDdmMWEgMTAwNjQ0Ci0tLSBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9BdHRyaWJ1dGVTZXJ2bGV0LmphdmEKKysrIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL3NlcnZsZXRzL0F0dHJpYnV0ZVNlcnZsZXQuamF2YQpAQCAtMSwzMjAgKzEsMzE0IEBACi0vKi0NCi0gKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLSAqIFNEQw0KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT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0cmlidXRlQnVzaW5lc3NMb2dpYy5jbGFzcyk7DQotICAgICAgICAgICAgICAgIEVpdGhlcjxQcm9wZXJ0eURlZmluaXRpb24sIFJlc3BvbnNlRm9ybWF0PiBjcmVhdGVBdHRyaWJ1dGUgPQ0KLSAgICAgICAgICAgICAgICAgICAgICAgIGJ1c2luZXNzTG9naWMuY3JlYXRlQXR0cmlidXRlKHJlc291cmNlSWQsIGF0dHJpYnV0ZXNXcmFwcGVyLmdldElubmVyRWxlbWVudCgpLCB1c2VySWQpOw0KLSAgICAgICAgICAgICAgICBpZiAoY3JlYXRlQXR0cmlidXRlLmlzUmlnaHQoKSkgew0KLSAgICAgICAgICAgICAgICAgICAgZXJyb3JXcmFwcGVyLnNldElubmVyRWxlbWVudChjcmVhdGVBdHRyaWJ1dGUucmlnaHQoKS52YWx1ZSgpKTsNCi0gICAgICAgICAgICAgICAgfSBlbHNlIHsNCi0gICAgICAgICAgICAgICAgICAgIGF0dHJpYnV0ZXNXcmFwcGVyLnNldElubmVyRWxlbWVudChjcmVhdGVBdHRyaWJ1dGUubGVmdCgpLnZhbHVlKCkpOw0KLSAgICAgICAgICAgICAgICB9DQotICAgICAgICAgICAgfQ0KLQ0KLSAgICAgICAgICAgIFJlc3BvbnNlIHJlc3BvbnNlOw0KLSAgICAgICAgICAgIGlmICghZXJyb3JXcmFwcGVyLmlzRW1wdHkoKSkgew0KLSAgICAgICAgICAgICAgICBsb2cuaW5mbygiRmFpbGVkIHRvIGNyZWF0ZSBBdHRyaWJ1dGUuIFJlYXNvbiAtICIsIGVycm9yV3JhcHBlci5nZXRJbm5lckVsZW1lbnQoKSk7DQotICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gYnVpbGRFcnJvclJlc3BvbnNlKGVycm9yV3JhcHBlci5nZXRJbm5lckVsZW1lbnQoKSk7DQotICAgICAgICAgICAgfSBlbHNlIHsNCi0gICAgICAgICAgICAgICAgUHJvcGVydHlEZWZpbml0aW9uIGNyZWF0ZWRBdHREZW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0ZXNXcmFwcGVyLnNldElubmVyRWxlbWVudChhdHRyaWJ1dGUpOw0KLSAgICAgICAgICAgIH0NCi0NCi0gICAgICAgIH0gY2F0Y2ggKEV4Y2VwdGlvbiBlKSB7DQotICAgICAgICAgICAgUmVzcG9uc2VGb3JtYXQgcmVzcG9uc2VGb3JtYXQgPSBnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuSU5WQUxJRF9DT05URU5UKTsNCi0gICAgICAgICAgICBlcnJvcldyYXBwZXIuc2V0SW5uZXJFbGVtZW50KHJlc3BvbnNlRm9ybWF0KTsNCi0gICAgICAgICAgICBsb2cuZGVidWcoIkF0dHJpYnV0ZSBjb250ZW50IGlzIGludmFsaWQgLSB7fSIsIGRhdGEsIGUpOw0KLSAgICAgICAgICAgIGxvZy5pbmZvKCJBdHRyaWJ1dGUgY29udGVudCBpcyBpbnZhbGlkIC0ge30iLCBkYXRhKTsNCi0gICAgICAgIH0NCi0gICAgfQ0KLX0NCisvKi0KKyAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBTREMKKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBDb3B5cmlnaHQgKEMpIDIwMTcgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7CisgKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyB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0ZUJ1c2luZXNzTG9naWMgYnVzaW5lc3NMb2dpYyA9IGdldENsYXNzRnJvbVdlYkFwcENvbnRleHQoY29udGV4dCwgKCkgLT4gQXR0cmlidXRlQnVzaW5lc3NMb2dpYy5jbGFzcyk7CisgICAgICAgICAgICAgICAgRWl0aGVyPFByb3BlcnR5RGVmaW5pdGlvbiwgUmVzcG9uc2VGb3JtYXQ+IGNyZWF0ZUF0dHJpYnV0ZSA9IGJ1c2luZXNzTG9naWMuY3JlYXRlQXR0cmlidXRlKHJlc291cmNlSWQsIGF0dHJpYnV0ZXNXcmFwcGVyLmdldElubmVyRWxlbWVudCgpLCB1c2VySWQpOworICAgICAgICAgICAgICAgIGlmIChjcmVhdGVBdHRyaWJ1dGUuaXNSaWdodCgpKSB7CisgICAgICAgICAgICAgICAgICAgIGVycm9yV3JhcHBlci5zZXRJbm5lckVsZW1lbnQoY3JlYXRlQXR0cmlidXRlLnJpZ2h0KCkudmFsdWUoKSk7CisgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgYXR0cmlidXRlc1dyYXBwZXIuc2V0SW5uZXJFbGVtZW50KGNyZWF0ZUF0dHJpYnV0ZS5sZWZ0KCkudmFsdWUoKSk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfQorCisgICAgICAgICAgICBSZXNwb25zZSByZXNwb25zZTsKKyAgICAgICAgICAgIGlmICghZXJyb3JXcmFwcGVyLmlzRW1wdHkoKSkgeworICAgICAgICAgICAgICAgIGxvZy5pbmZvKCJGYWlsZWQgdG8gY3JlYXRlIEF0dHJpYnV0ZS4gUmVhc29uIC0gIiwgZXJyb3JXcmFwcGVyLmdldElubmVyRWxlbWVudCgpKTsKKyAgICAgICAgICAgICAgICByZXNwb25zZSA9IGJ1aWxkRXJyb3JSZXNwb25zZShlcnJvcldyYXBwZXIuZ2V0SW5uZXJFbGVtZW50KCkpOworICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAg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hdGVBdHRyaWJ1dGUgPSBidXNpbmVzc0xvZ2ljLnVwZGF0ZUF0dHJpYnV0ZShyZXNvdXJjZUlkLCBhdHRyaWJ1dGVJZCwgYXR0cmlidXRlc1dyYXBwZXIuZ2V0SW5uZXJFbGVtZW50KCksIHVzZXJJZCk7CisgICAgICAgICAgICAgICAgLy8gdXBkYXRlIHByb3BlcnR5CisgICAgICAgICAgICAgICAgaWYgKGVpdGhlclVwZGF0ZUF0dHJpYnV0ZS5pc1JpZ2h0KCkpIHsKKyAgICAgICAgICAgICAgICAgICAgZXJyb3JXcmFwcGVyLnNldElubmVyRWxlbWVudChlaXRoZXJVcGRhdGVBdHRyaWJ1dGUucmlnaHQoKS52YWx1ZSgpKTsKKyAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICBhdHRyaWJ1dGVzV3JhcHBlci5zZXRJbm5lckVsZW1lbnQoZWl0aGVyVXBkYXRlQXR0cmlidXRlLmxlZnQoKS52YWx1ZSgpKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIFJlc3BvbnNlIHJlc3BvbnNlOworICAgICAgICAgICAgaWYgKCFlcnJvcldyYXBwZXIuaXNFbXB0eSgpKSB7CisgICAgICAgICAgICAgICAgbG9nLmluZm8oIkZhaWxlZCB0byB1cGRhdGUgQXR0cmlidXRlLiBSZWFzb24gLSAiLCBlcnJvcldyYXBwZXIuZ2V0SW5uZXJFbGVtZW50KCkpOworICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gYnVpbGRFcnJvclJlc3BvbnNlKGVycm9yV3JhcHBlci5nZXRJbm5lckVsZW1lbnQoKSk7CisgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgIFByb3BlcnR5RGVmaW5pdGlvbiB1cGRhdGVkQXR0cmlidXRlID0gYXR0cmlidXRlc1dyYXBwZXIuZ2V0SW5uZXJFbGVtZW50KCk7CisgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJBdHRyaWJ1dGUgaWQge30gdXBkYXRlZCBzdWNjZXNzZnVsbHkgIiwgdXBkYXRlZEF0dHJpYnV0ZS5nZXRVbmlxdWVJZCgpKTsKKyAgICAgICAgICAgICAgICBSZXNwb25zZUZvcm1hdCByZXNwb25zZUZvcm1hdCA9IGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5PSyk7CisgICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBidWlsZE9rUmVzcG9uc2UocmVzcG9uc2VGb3JtYXQsIFJlcHJlc2VudGF0aW9uVXRpbHMudG9SZXByZXNlbnRhdGlvbih1cGRhdGVkQXR0cmlidXRlKSk7CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIHJldHVybiByZXNwb25zZTsKKworICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZSkgeworICAgICAgICAgICAgQmVFY29tcEVycm9yTWFuYWdlci5nZXRJbnN0YW5jZSgpLmxvZ0JlUmVzdEFwaUdlbmVyYWxFcnJvcigiVXBkYXRlIEF0dHJpYnV0ZSIpOworICAgICAgICAgICAgbG9nLmRlYnVnKCJ1cGRhdGUgYXR0cmlidXRlIGZhaWxlZCB3aXRoIGV4Y2VwdGlvbiIsIGUpOworICAgICAgICAgICAgdGhyb3cgZTsKKyAgICAgICAgfQorICAgIH0KKworICAgIC8qKgorICAgICAqIERlbGV0ZXMgZXhpc3RpbmcgQXR0cmlidXRlIHdpdGggZ2l2ZW4gYXR0cmlidXRlSUQgb24gYSByZXNvdXJjZSB3aXRoIGdpdmVuIHJlc291cmNlSUQKKyAgICAgKgorICAgICAqIEBwYXJhbSByZXNvdXJjZUlkCisgICAgICogQHBhcmFtIGF0dHJpYnV0ZUlkCisgICAgICogQHBhcmFtIHJlcXVlc3QKKyAgICAgKiBAcGFyYW0gdXNlcklkCisgICAgICogQHJldHVybgorICAgICAqLworICAgIEBERUxFVEUKKyAgICBAUGF0aCgicmVzb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dG9tYXRlZFVwZ3JhZGVFbmRwb2ludC5qYXZhCmluZGV4IGNlNGRmZGQuLjQ0MGI3MmEgMTAwNjQ0Ci0tLSBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9BdXRvbWF0ZWRVcGdyYWRlRW5kcG9pbnQuamF2YQorKysgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvQXV0b21hdGVkVXBncmFkZUVuZHBvaW50LmphdmEKQEAgLTEsMTM3ICsxLDE0MiBAQAotLyotDQotICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NCi0gKiBTREMNCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLSAqIENvcHlyaWdodCAoQykgMjAxOSBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLSAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOw0KLSAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4NCi0gKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQNCi0gKiANCi0gKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIu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AgICAgbG9nLmRlYnVnKCIoR0VUKSBTdGFydCBoYW5kbGUgcmVxdWVzdCBvZiB7fSIsIHVybCk7DQotDQotICAgICAgICB0cnkgew0KLSAgICAgICAgICAgIHJldHVybiAgYnVzaW5lc3NMb2dpYy5nZXRDb21wb25lbnREZXBlbmRlbmNpZXMoY29tcG9uZW50SWQsIHVzZXJJZCkNCi0gICAgICAgICAgICAgICAgICAgIC5laXRoZXIodGhpczo6YnVpbGRPa1Jlc3BvbnNlLCB0aGlzOjpidWlsZEVycm9yUmVzcG9uc2UpOyAgDQotICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZSkgew0KLSAgICAgICAgICAgIGxvZy5lcnJvcigiI2dldFNlcnZpY2VzRm9yQ29tcG9uZW50IC0gRXhjZXB0aW9uIG9jY3VycmVkIGR1cmluZyBhdXRvbWV0ZWQgVXBncmFkZSIsIGUpOw0KLSAgICAgICAgICAgIHJldHVybiBidWlsZEdlbmVyYWxFcnJvclJlc3BvbnNlKCk7DQotICAgICAgICB9DQotICAgICANCi0gICAgICAgIA0KLSAgICB9DQotfQ0KKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAxOSBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKKyAqIHl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cyhAUGF0aFBhcmFtKCJjb21wb25lbnRUeXBlIikgZmluYWwgU3RyaW5nIGNvbXBvbmVudFR5cGUsCisgICAgICAgICAgICBAQ29udGV4dCBmaW5hbCBIdHRwU2VydmxldFJlcXVlc3QgcmVxdWVzdCwgQFBhdGhQYXJhbSgiY29tcG9uZW50SWQiKSBmaW5hbCBTdHJpbmcgY29tcG9uZW50SWQsCisgICAgICAgICAgICBASGVhZGVyUGFyYW0odmFsdWUgPSBDb25zdGFudHMuVVNFUl9JRF9IRUFERVIpIFN0cmluZyB1c2VySWQsCisgICAgICAgICAgICBAUGFyYW1ldGVyKGRlc2NyaXB0aW9uID0gIkNvbnN1bWVyIE9iamVjdCB0byBiZSBjcmVhdGVkIiwgcmVxdWlyZWQgPSB0cnVlKSBMaXN0PFN0cmluZz4gZGF0YSkgeworICAgICAgICBTdHJpbmcgdXJsID0gcmVxdWVzdC5nZXRNZXRob2QoKSArICIgIiArIHJlcXVlc3QuZ2V0UmVxdWVzdFVSSSgpOworICAgICAgICBsb2cuZGVidWcoIihHRVQpIFN0YXJ0IGhhbmRsZSByZXF1ZXN0IG9mIHt9IiwgdXJsKTsKKworICAgICAgICB0cnkgeworICAgICAgICAgICAgcmV0dXJuICBidXNpbmVzc0xvZ2ljLmdldENvbXBvbmVudERlcGVuZGVuY2llcyhjb21wb25lbnRJZCwgdXNlcklkKQorICAgICAgICAgICAgICAgICAgICAuZWl0aGVyKHRoaXM6OmJ1aWxkT2tSZXNwb25zZSwgdGhpczo6YnVpbGRFcnJvclJlc3BvbnNlKTsgIAorICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZSkgeworICAgICAgICAgICAgbG9nLmVycm9yKCIjZ2V0U2VydmljZXNGb3JDb21wb25lbnQgLSBFeGNlcHRpb24gb2NjdXJyZWQgZHVyaW5nIGF1dG9tZXRlZCBVcGdyYWRlIiwgZSk7CisgICAgICAgICAgICB0aHJvdyBlOworICAgICAgICB9CisgICAgIAorICAgICAgICAKKyAgICB9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BwZW5kKGFydGlmYWN0RmlsZU5hbWUpLmFwcGVuZCgiXCIiKS50b1N0cmluZygpOwogICAgIH0KIAotICAgIDxUPiB2b2lkIGNvbnZlcnRKc29uVG9PYmplY3RPZkNsYXNzKFN0cmluZyBqc29uLCBXcmFwcGVyPFQ+IHBvbGljeVdyYXBwZXIsIENsYXNzPFQ+IGNsYXp6LCBXcmFwcGVyPFJlc3BvbnNlPiBlcnJvcldyYXBwZXIpIHsKKworCisgICAgcHJvdGVjdGVkIENvbXBvbmVudEJ1c2luZXNzTG9naWMgZ2V0Q29tcG9uZW50QkwoQ29tcG9uZW50VHlwZUVudW0gY29tcG9uZW50VHlwZUVudW0sIFNlcnZsZXRDb250ZXh0IGNvbnRleHQpIHsKKyAgICAgICAgQ29tcG9uZW50QnVzaW5lc3NMb2dpYyBidXNpbmVzc0xvZ2ljOworICAgICAgICBzd2l0Y2ggKGNvbXBvbmVudFR5cGVFbnVtKSB7CisgICAgICAgICAgICBjYXNlIFJFU09VUkNFOgorICAgICAgICAgICAgICAgIGJ1c2luZXNzTG9naWMgPSBnZXRSZXNvdXJjZUJMKGNvbnRleHQpOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBTRVJWSUNFOgorICAgICAgICAgICAgICAgIGJ1c2luZXNzTG9naWMgPSBnZXRTZXJ2aWNlQkwoY29udGV4dCk7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIFBST0RVQ1Q6CisgICAgICAgICAgICAgICAgYnVzaW5lc3NMb2dpYyA9IGdldFByb2R1Y3RCTChjb250ZXh0KTsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgUkVTT1VSQ0VfSU5TVEFOQ0U6CisgICAgICAgICAgICAgICAgYnVzaW5lc3NMb2dpYyA9IGdldFJlc291cmNlQkwoY29udGV4dCk7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgIEJlRWNvbXBFcnJvck1hbmFnZXIuZ2V0SW5zdGFuY2UoKS5sb2dCZVN5c3RlbUVycm9yKCJnZXRDb21wb25lbnRCTCIpOworICAgICAgICAgICAgICAgIHRocm93IG5ldyBJbGxlZ2FsQXJndW1lbnRFeGNlcHRpb24oIklsbGVnYWwgY29tcG9uZW50IHR5cGU6IiArIGNvbXBvbmVudFR5cGVFbnVtLmdldFZhbHVlKCkpOworICAgICAgICB9CisgICAgICAgIHJldHVybiBidXNpbmVzc0xvZ2ljOworICAgIH0KKworICAgIDxUPiBUIGNvbnZlcnRKc29uVG9PYmplY3RPZkNsYXNzKFN0cmluZyBqc29uLCBDbGFzczxUPiBjbGF6eikgewogICAgICAgICBUIG9iamVjdCA9IG51bGw7CiAgICAgICAgIE9iamVjdE1hcHBlciBtYXBwZXIgPSBuZXcgT2JqZWN0TWFwcGVyKCkKICAgICAgICAgICAgIC5jb25maWd1cmUoRGVzZXJpYWxpemF0aW9uRmVhdHVyZS5GQUlMX09OX1VOS05PV05fUFJPUEVSVElFUywgZmFsc2UpCkBAIC0xOTMsMTYgKzMyMCwxNiBAQAogCiAgICAgICAgICAgICBvYmplY3QgPSBtYXBwZXIucmVhZFZhbHVlKGpzb24sIGNsYXp6KTsKICAgICAgICAgICAgIGlmIChvYmplY3QgIT0gbnVsbCkgewotICAgICAgICAgICAgICAgIHBvbGljeVdyYXBwZXIuc2V0SW5uZXJFbGVtZW50KG9iamVjdCk7CisgICAgICAgICAgICAgICAgcmV0dXJuIG9iamVjdDsKICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgQmVFY29tcEVycm9yTWFuYWdlci5nZXRJbnN0YW5jZSgpLmxvZ0JlSW52YWxpZEpzb25JbnB1dCgiY29udmVydEpzb25Ub09iamVjdCIpOwogICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiVGhlIG9iamVjdCBvZiBjbGFzcyB7fSBpcyBudWxsIGFmdGVyIGNvbnZ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aW9uQ29udGV4dCA9IHdlYkFwcGxpY2F0aW9uQ29udGV4dFdyYXBwZXIuZ2V0V2ViQXBwQ29udGV4dChjb250ZXh0KTsKZGlmZiAtLWdpdCBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9CZU1vbml0b3JpbmdTZXJ2bGV0LmphdmEgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvQmVNb25pdG9yaW5nU2VydmxldC5qYXZhCmluZGV4IDU0MzNiZDUuLmUzNDAzNDYgMTAwNjQ0Ci0tLSBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9CZU1vbml0b3JpbmdTZXJ2bGV0LmphdmEKKysrIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL3NlcnZsZXRzL0JlTW9uaXRvcmluZ1NlcnZsZXQuamF2YQpAQCAtMSwxOTQgKzEsMTU2IEBACi0vKi0NCi0gKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLSAqIFNEQw0KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLC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IHRyeSB7DQotICAgICAgICAgICAgb2JqZWN0ID0gZ3Nvbi5mcm9tSnNvbihjb250ZW50LCBjbGF6eik7DQotICAgICAgICAgICAgb2JqZWN0LnNldEZpZWxkcyhudWxsKTsNCi0gICAgICAgIH0gY2F0Y2ggKEV4Y2VwdGlvbiBlKSB7DQotICAgICAgICAgICAgbG9nLmRlYnVnKCJGYWlsZWQgdG8gY29udmVydCB0aGUgY29udGVudCB7fSB0byBvYmplY3QuIiwgY29udGVudC5zdWJzdHJpbmcoMCwgTWF0aC5taW4oNTAsIGNvbnRlbnQubGVuZ3RoKCkpKSwgZSk7DQotICAgICAgICB9DQotDQotICAgICAgICByZXR1cm4gb2JqZWN0Ow0KLSAgICB9DQotDQotfQ0KKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAxNyBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKKyAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KKyAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAorICogCisgKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9sa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mxldFJlcXVlc3QgcmVxdWVzdCwNCi0gICAgICAgICAgICBASGVhZGVyUGFyYW0odmFsdWUgPSBDb25zdGFudHMuVVNFUl9JRF9IRUFERVIpIFN0cmluZyB1c2VySWQpIHsNCi0gICAgICAgIHJldHVybiBkZWxldGUoY2FwYWJpbGl0eUlkLCBzZXJ2aWNlSWQsIHJlcXVlc3QsIHVzZXJJZCk7DQotICAgIH0NCi0NCi0gICAgcHJpdmF0ZSBSZXNwb25zZSBjcmVhdGVPclVwZGF0ZSAoU3RyaW5nIGRhdGEsIFN0cmluZyBjb21wb25lbnRUeXBlLCBTdHJpbmcgY29tcG9uZW50SWQsDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEh0dHBTZXJ2bGV0UmVxdWVzdCByZXF1ZXN0LA0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmcgdXNlcklkLA0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sZWFuIGlzVXBkYXRlLA0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmcgZXJyb3JDb250ZXh0KSB7DQotICAgICAgICBTdHJpbmcgdXJsID0gcmVxdWVzdC5nZXRNZXRob2QoKSArICIgIiArIHJlcXVlc3QuZ2V0UmVxdWVzdFVSSSgpOw0KLQ0KLSAgICAgICAgVXNlciBtb2RpZmllciA9IG5ldyBVc2VyKCk7DQotICAgICAgICBtb2RpZmllci5zZXRVc2VySWQodXNlcklkKTsNCi0gICAgICAgIExPR0dFUi5kZWJ1ZygiU3RhcnQgY3JlYXRlIG9yIHVwZGF0ZSByZXF1ZXN0IG9mIHt9IHdpdGggbW9kaWZpZXIgaWQge30iLCB1cmwsIHVzZXJJZCk7DQotICAgICAgICB0cnkgew0KLSAgICAgICAgICAgIFN0cmluZyBjb21wb25lbnRJZExvd2VyID0gY29tcG9uZW50SWQudG9Mb3dlckNhc2UoKTsNCi0NCi0gICAgICAg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B1c2VySWQpOworICAgIH0KKworICAgIHByaXZhdGUgUmVzcG9uc2UgY3JlYXRlT3JVcGRhdGUgKFN0cmluZyBkYXRhLCBTdHJpbmcgY29tcG9uZW50VHlwZSwgU3RyaW5nIGNvbXBvbmVudElkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEh0dHBTZXJ2bGV0UmVxdWVzdCByZXF1ZXN0LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZyB1c2VySWQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbGVhbiBpc1VwZGF0ZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmcgZXJyb3JDb250ZXh0KSB7CisgICAgICAgIFNlcnZsZXRDb250ZXh0IGNvbnRleHQgPSByZXF1ZXN0LmdldFNlc3Npb24oKS5nZXRTZXJ2bGV0Q29udGV4dCgpOworICAgICAgICBTdHJpbmcgdXJsID0gcmVxdWVzdC5nZXRNZXRob2QoKSArICIgIiArIHJlcXVlc3QuZ2V0UmVxdWVzdFVSSSgpOworCisgICAgICAgIFVzZXIgbW9kaWZpZXIgPSBuZXcgVXNlcigpOworICAgICAgICBtb2RpZmllci5zZXRVc2VySWQodXNlcklkKTsKKyAgICAgICAgTE9HR0VSLmRlYnVnKCJTdGFydCBjcmVhdGUgb3IgdXBkYXRlIHJlcXVlc3Qgb2Yge30gd2l0aCBtb2RpZmllciBpZCB7fSIsIHVybCwgdXNlcklkKTsKKyAgICAgICAgdHJ5IHsKKyAgICAgICAgICAgIFN0cmluZyBjb21wb25lbnRJZExvd2VyID0gY29tcG9uZW50SWQudG9Mb3dlckNhc2UoKTsKKworICAgICAgICAgICAgRWl0aGVyPExpc3Q8Q2FwYWJpbGl0eURlZmluaXRpb24+LCBSZXNwb25zZUZvcm1hdD4gbWFwcGVkQ2FwYWJpbGl0aWVzRGF0YUVpdGhlcgorICAgICAgICAgICAgICAgICAgIC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YXR1cy5PSyksIHJlc3VsdCk7CisgICAgICAgIH0gY2F0Y2ggKEV4Y2VwdGlvbiBlKSB7CisgICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nQmVSZXN0QXBpR2VuZXJhbEVycm9yKCJEZWxldGUgY2FwYWJpbGl0eSIpOworICAgICAgICAgICAgTE9HR0VSLmVycm9yKCJEZWxldGUgY2FwYWJpbGl0eSBmYWlsZWQgd2l0aCBhbiBlcnJvciIsIGUpOworICAgICAgICAgICAgcmV0dXJuIGJ1aWxkRXJyb3JSZXNwb25zZShnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUikpOworICAgICAgICB9CisgICAgfQorCisgICAgcHJpdmF0ZSBFaXRoZXI8TGlzdDxDYXBhYmlsaXR5RGVmaW5pdGlvbj4sIFJlc3BvbnNlRm9ybWF0PiBnZXRNYXBwZWRDYXBhYmlsaXRpZXNEYXRhKFN0cmluZyBpbnB1dEpzb24sIFVzZXIgdXNlciwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29tcG9uZW50VHlwZUVudW0gY29tcG9uZW50VHlwZUVudW0peworICAgICAgICBFaXRoZXI8VWlDb21wb25lbnREYXRhVHJhbnNmZXIsIFJlc3BvbnNlRm9ybWF0PiBtYXBwZWREYXRhID0gZ2V0Q29tcG9uZW50c1V0aWxzKCkKKyAgICAgICAgICAgICAgICAuY29udmVydEpzb25Ub09iamVjdFVzaW5nT2JqZWN0TWFwcGVyKGlucHV0SnNvbiwgdXNlciwgVWlDb21wb25lbnREYXRhVHJhbnNmZXIuY2xhc3MsCisgICAgICAgICAgICAgICAgICAgICAgICBBdWRpdGluZ0FjdGlvbkVudW0uQ1JFQVRFX1JFU09VUkNFLCBjb21wb25lbnRUeXBlRW51bSk7CisgICAgICAgIE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EAgLTEsMTYzOSArMSwxNTc3IEBACi0vKi0NCi0gKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLSAqIFNEQw0KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7DQotICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLg0KLSAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdA0KLSAqIA0KLSAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wDQotICogDQotICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZQ0KLSAqIGRpc3RyaWJ1dGVkIHVuZGVyIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1dGVkIG9uIGFuICJBUyBJUyIgQkFTSVMsDQotICogV0lUSE9VVCBXQVJSQU5USUVTIE9SIENPTkRJVElPTlMgT0YgQU5ZIEtJTkQsIGVpdGhlciBleHByZXNzIG9yIGltcGxpZWQuDQotICogU2VlIHRoZSBMaWNlbnNlIGZv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gICBsb2cuaW5mbyhFTVBUWV9CT0RZX1dBU19TRU5UKTsNCi0gICAgICAgICAgICAgICAgcmV0dXJuIGJ1aWxkRXJyb3JSZXNwb25zZShnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuSU5WQUxJRF9DT05URU5UKSk7DQotICAgICAgICAgICAgfQ0KLQ0KLSAgICAgICAgICAgIFN0cmluZyB1c2VySWQgPSByZXF1ZXN0LmdldEhlYWRlcihDb25zdGFudHMuVVNFUl9JRF9IRUFERVIpOw0KLQ0KLSAgICAgICAgICAgIFN0cmluZyBkYXRhID0gbmV3IFN0cmluZyhieXRlcyk7DQotICAgICAgICAgICAgQ29tcG9uZW50VHlwZUVudW0gY29tcG9uZW50VHlwZUVudW0gPSBDb21wb25lbnRUeXBlRW51bS5maW5kQnlQYXJhbU5hbWUoY29udGFpbmVyQ29tcG9uZW50VHlwZSk7DQotICAgICAgICAgICAgaWYgKGNvbXBvbmVudEluc3RhbmNlQnVzaW5lc3NMb2dpYyA9PSBudWxsKSB7DQotICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZyhVTlNVUFBPUlRFRF9DT01QT05FTlRfVFlQRSwgY29udGFpbmVyQ29tcG9uZW50VHlwZSk7DQotICAgICAgICAgICAgICAgIHJldHVybiBidWlsZEVycm9yUmVzcG9uc2UoDQotICAgICAgICAgICAgICAgICAgICAgICAgZ2V0Q29tcG9uZW50c1V0aWxzKCkuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLlVOU1VQUE9SVEVEX0VSUk9SLCBjb250YWluZXJDb21wb25lbnRUeXBlKSk7DQotICAgICAgICAgICAgfQ0KLSAgICAgICAgICAgIEVpdGhlcjxDb21wb25lbnRJbnN0YW5jZSwgUmVzcG9uc2VGb3JtYXQ+IGNvbnZlcnRSZXNwb25zZSA9IGNvbnZlcnRUb1Jlc291cmNlSW5zdGFuY2UoZGF0YSk7DQotDQotICAgICA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ICAgICAgICAgICAgICAgIGxvZy5pbmZvKCJFbXB0eSBKU09OIGxpc3Qgd2FzIHNlbnQuIik7DQotICAgICAgICAgICAgICAgIHJldHVybiBidWlsZEVycm9yUmVzcG9uc2UoZ2V0Q29tcG9uZW50c1V0aWxzKCkuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLklOVkFMSURfQ09OVEVOVCkpOw0KLSAgICAgICAgICAgIH0NCi0NCi0gICAgICAgICAgICBTdHJpbmcgdXNlcklkID0gcmVxdWVzdC5nZXRIZWFkZXIoQ29uc3RhbnRzLlVTRVJfSURfSEVBREVSKTsNCi0NCi0gICAgICAgICAgICBDb21wb25lbnRUeXBlRW51bSBjb21wb25lbnRUeXBlRW51bSA9IENvbXBvbmVudFR5cGVFbnVtLmZpbmRCeVBhcmFtTmFtZShjb250YWluZXJDb21wb25lbnRUeXBlKTsNCi0gICAgICAgICAgICBpZiAoY29tcG9uZW50SW5zdGFuY2VCdXNpbmVzc0xvZ2ljID09IG51bGwpIHsNCi0gICAgICAgICAgICAgICAgbG9nLmRlYnVnKFVOU1VQUE9SVEVEX0NPTVBPTkVOVF9UWVBFLCBjb250YWluZXJDb21wb25lbnRUeXBlKTsNCi0gICAgICAgICAgICAgICAgcmV0dXJuIGJ1aWxkRXJyb3JSZXNwb25zZSgNCi0gICAgICAgICAgICAgICAgICAgICAgICBnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuVU5TVVBQT1JURURfRVJST1IsIGNvbnRhaW5lckNvbXBvbmVudFR5cGUpKTsNCi0gICAgICAgICAgICB9DQotDQotICAgICAgICAgICAgRWl0aGVyPExpc3Q8Q29tcG9uZW50SW5zdGFuY2U+LCBSZXNwb25zZUZvcm1hdD4gY29udmVydFJlc3BvbnNlID0NCi0gICAgICAgICAgICAgICAgICAgIGNvbnZlcnRUb011bHRpcGxlUmVzb3VyY2VJbnN0YW5jZShjb21wb25lbnRJb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ZXMgPSB7Q29tcG9uZW50VHlwZUVudW0uUkVTT1VSQ0VfUEFSQU1fTkFNRSwNCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29tcG9uZW50VHlwZUVudW0uU0VSVklDRV9QQVJBTV9OQU1FLA0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb21wb25lbnRUeXBlRW51bS5QUk9EVUNUX1BBUkFNX05BTUV9KSkgQFBhdGhQYXJhbSgiY29udGFpbmVyQ29tcG9uZW50VHlwZSIpIGZpbmFsIFN0cmluZyBjb250YWluZXJDb21wb25lbnRUeXBlLA0KLSAgICAgICAgICAgIEBDb250ZXh0IGZpbmFsIEh0dHBTZXJ2bGV0UmVxdWVzdCByZXF1ZXN0KSB7DQotICAgICAgICBTZXJ2bGV0Q29udGV4dCBjb250ZXh0ID0gcmVxdWVzdC5nZXRTZXNzaW9uKCkuZ2V0U2VydmxldENvbnRleHQoKTsNCi0gICAgICAgIFN0cmluZyB1cmwgPSByZXF1ZXN0LmdldE1ldGhvZCgpICsgIiAiICsgcmVxdWVzdC5nZXRSZXF1ZXN0VVJJKCk7DQotICAgICAgICBSZXNwb25zZSByZXNwb25zZSA9IG51bGw7DQotICAgICAgICB0cnkgew0KLSAgICAgICAgICAgIGxvZy5kZWJ1ZyhTVEFSVF9IQU5ETEVfUkVRVUVTVF9PRiwgdXJsKTsNCi0gICAgICAgICAgICBDb21wb25lbnRUeXBlRW51bSBjb21wb25lbnRUeXBlRW51bSA9IENvbXBvbmVudFR5cGVFbnVtLmZpbmRCeVBhcmFtTmFtZShjb250YWluZXJDb21wb25lbnRUeXBlKTsNCi0gICAgICAgICAgICBpZiAoY29tcG9uZW50SW5zdGFuY2VCdXNpbmVzc0xvZ2ljID09IG51bGwpIHsNCi0gICAgICAgICAgICAgICAgbG9nLmRlYnVnKFVOU1VQUE9SVEVEX0NPTVBPTkVOVF9UWVBFLCBjb250YWluZXJDb21wb25lbnRUeXBlKTsNCi0gICAgICAgICAgICAgICAgcmV0dXJuIGJ1aWxkRXJyb3JSZXNwb25zZSgNCi0gICAgICAgICAgICAgICAgICAgICAgICBnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuVU5TVVBQT1JURURfRVJST1IsIGNvbnRhaW5lckNvbXBvbmVudFR5cGUpKTsNCi0gICAgICAgICAgICB9DQotICAgICAgICAgICAgU3RyaW5nIHVzZXJJZCA9IHJlcXVlc3QuZ2V0SGVhZGVyKENvbnN0YW50cy5VU0VSX0lEX0hFQURFUik7DQotICAgICAgICAgICAgRWl0aGVyPENvbXBvbmVudEluc3RhbmNlLCBSZXNwb25zZUZvcm1hdD4gYWN0aW9uUmVzcG9uc2UgPSBjb21wb25lbnRJbnN0YW5jZUJ1c2luZXNzTG9naWMNCi0gICAgICAgICAgICAgICAgICAgIC5kZWxldGVDb21wb25lbnRJbnN0YW5jZShjb250YWluZXJDb21wb25lbnRUeXBlLCBjb21wb25lbnRJZCwgcmVzb3VyY2VJbnN0YW5jZUlkLCB1c2VySWQpOw0KLQ0KLSAgICAgICAgICAgIGlmIChhY3Rpb25SZXNwb25zZS5pc1JpZ2h0KCkpIHsNCi0gICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBidWlsZEVycm9yUmVzcG9uc2UoYWN0aW9uUmVzcG9uc2UucmlnaHQoKS52YWx1ZSgpKTsNCi0gICAgICAgICAgICB9IGVsc2Ugew0KLSAgICAgICAgICAgICAgICByZXNwb25zZSA9IGJ1aWxkT2tSZXNwb25zZShnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuTk9fQ09OVEVOVCksIG51bGwpOw0KLSAgICAgICAgICAgIH0NCi0gICAgICAgICAgICByZXR1cm4gcmVzcG9uc2U7DQotICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZSkgew0KLSAgICAgICAgICAgIEJlRWNvbXBFcnJvck1hbmFnZXIuZ2V0SW5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c2luZXNzTG9naWMgY29tcG9uZW50SW5zdGFuY2VMb2dpYyA9IGJsV3JhcHBlci5nZXRJbm5lckVsZW1lbnQoKTsNCi0gICAgICAgICAgICAgICAgQ29tcG9uZW50VHlwZUVudW0gY29tcG9uZW50VHlwZUVudW0gPSBDb21wb25lbnRUeXBlRW51bS5maW5kQnlQYXJhbU5hbWUoY29udGFpbmVyQ29tcG9uZW50VHlwZSk7DQotICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiU3RhcnQgaGFuZGxlIHJlcXVlc3Qgb2YgQ29tcG9uZW50SW5zdGFuY2VBdHRyaWJ1dGUuIFJlY2VpdmVkIGF0dHJpYnV0ZSBpcyB7fSIsDQotICAgICAgICAgICAgICAgICAgICAgICAgYXR0cmlidXRlV3JhcHBlci5nZXRJbm5lckVsZW1lbnQoKSk7DQotICAgICAgICAgICAgICAgIEVpdGhlcjxDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5LCBSZXNwb25zZUZvcm1hdD4gZWl0aGVyQXR0cmlidXRlID0NCi0gICAgICAgICAgICAgICAgICAgICAgICBjb21wb25lbnRJbnN0YW5jZUxvZ2ljLmNyZWF0ZU9yVXBkYXRlQXR0cmlidXRlVmFsdWUoY29tcG9uZW50VHlwZUVudW0sIGNvbXBvbmVudElkLA0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tcG9uZW50SW5zdGFuY2VJZCwgYXR0cmlidXRlV3JhcHBlci5nZXRJbm5lckVsZW1lbnQoKSwgdXNlcklkKTsNCi0gICAgICAgICAgICAgICAgaWYgKGVpdGhlckF0dHJpYnV0ZS5pc1JpZ2h0KCkpIHsNCi0gICAgICAgICAgICAgICAgICAgIGVycm9yV3JhcHBlci5zZXRJbm5lckVsZW1lbnQoZWl0aGVyQXR0cmlidXRlLnJpZ2h0KCkudmFsdWUoKSk7DQotICAgICAgICAgICAgICAgIH0gZWxzZSB7DQotICAgICAgICAgICAgICAgICAgICBhdHRyaWJ1dGVXcmFwcGV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9uZW50SW5zdGFuY2VCdXNpbmVzc0xvZ2ljID09IG51bGwpIHsNCi0gICAgICAgICAgICAgICAgbG9nLmRlYnVnKFVOU1VQUE9SVEVEX0NPTVBPTkVOVF9UWVBFLCBjb250YWluZXJDb21wb25lbnRUeXBlKTsNCi0gICAgICAgICAgICAgICAgcmV0dXJuIGJ1aWxkRXJyb3JSZXNwb25zZSgNCi0gICAgICAgICAgICAgICAgICAgICAgICBnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuVU5TVVBQT1JURURfRVJST1IsIGNvbnRhaW5lckNvbXBvbmVudFR5cGUpKTsNCi0gICAgICAgICAgICB9DQotDQotICAgICAgICAgICAgRWl0aGVyPENvbXBvbmVudEluc3RhbmNlUHJvcGVydHksIFJlc3BvbnNlRm9ybWF0PiBhY3Rpb25SZXNwb25zZSA9IGNvbXBvbmVudEluc3RhbmNlQnVzaW5lc3NMb2dpYw0KLSAgICAgICAgICAgICAgICAgICAgLmRlbGV0ZVByb3BlcnR5VmFsdWUoY29tcG9uZW50VHlwZUVudW0sIGNvbXBvbmVudElkLCBjb21wb25lbnRJbnN0YW5jZUlkLCBwcm9wZXJ0eUlkLCB1c2VySWQpOw0KLSAgICAgICAgICAgIGlmIChhY3Rpb25SZXNwb25zZS5pc1JpZ2h0KCkpIHsNCi0gICAgICAgICAgICAgICAgcmV0dXJuIGJ1aWxkRXJyb3JSZXNwb25zZShhY3Rpb25SZXNwb25zZS5yaWdodCgpLnZhbHVlKCkpOw0KLSAgICAgICAgICAgIH0NCi0gICAgICAgICAgICByZXR1cm4gYnVpbGRPa1Jlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5OT19DT05URU5UKSwgbnVsbCk7DQotICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZSkgew0KLSAgICAgICAgICAgIGxvZy5lcnJvcigiY3JlYXRl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luZyBjb250YWluZXJDb21wb25lbnRJZCwNCi0gICAgICAgICAgICBAUGFyYW1ldGVyKGRlc2NyaXB0aW9uID0gInZhbGlkIHZhbHVlczogcmVzb3VyY2VzIC8gc2VydmljZXMiLA0KLSAgICAgICAgICAgICAgICAgICAgc2NoZW1hID0gQFNjaGVtYShhbGxvd2FibGVWYWx1ZXMgPSB7Q29tcG9uZW50VHlwZUVudW0uUkVTT1VSQ0VfUEFSQU1fTkFNRSwNCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29tcG9uZW50VHlwZUVudW0uU0VSVklDRV9QQVJBTV9OQU1FfSkpIEBQYXRoUGFyYW0oImNvbnRhaW5lckNvbXBvbmVudFR5cGUiKSBmaW5hbCBTdHJpbmcgY29udGFpbmVyQ29tcG9uZW50VHlwZSwNCi0gICAgICAgICAgICBASGVhZGVyUGFyYW0odmFsdWUgPSBDb25zdGFudHMuVVNFUl9JRF9IRUFERVIpIEBQYXJhbWV0ZXIoZGVzY3JpcHRpb24gPSAiVVNFUl9JRCBvZiBtb2RpZmllciB1c2VyIiwNCi0gICAgICAgICAgICAgICAgICAgIHJlcXVpcmVkID0gdHJ1ZSkgU3RyaW5nIHVzZXJJZCwNCi0gICAgICAgICAgICBAQ29udGV4dCBmaW5hbCBIdHRwU2VydmxldFJlcXVlc3QgcmVxdWVzdCkgew0KLSAgICAgICAgU2VydmxldENvbnRleHQgY29udGV4dCA9IHJlcXVlc3QuZ2V0U2Vzc2lvbigpLmdldFNlcnZsZXRDb250ZXh0KCk7DQotDQotICAgICAgICB0cnkgew0KLQ0KLSAgICAgICAgICAgIENvbXBvbmVudEluc3RhbmNlIGNvbXBvbmVudEluc3RhbmNlID0gUmVwcmVzZW50YXRpb25VdGlscy5mcm9tUmVwcmVzZW50YXRpb24oZGF0YSwgQ29tcG9uZW50SW5zdGFuY2UuY2xhc3MpOw0KLSAgICAgICAgICAgIGNvbXBvbmVudEluc3RhbmNlLnNldEludmFyaWFudE5hbWUobnVsbCk7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JvZHVjdHMiLA0KLSAgICAgICAgICAgICAgICAgICAgc2NoZW1hID0gQFNjaGVtYShhbGxvd2FibGVWYWx1ZXMgPSB7Q29tcG9uZW50VHlwZUVudW0uUkVTT1VSQ0VfUEFSQU1fTkFNRSwNCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29tcG9uZW50VHlwZUVudW0uU0VSVklDRV9QQVJBTV9OQU1FfSkpIEBQYXRoUGFyYW0oImNvbnRhaW5lckNvbXBvbmVudFR5cGUiKSBmaW5hbCBTdHJpbmcgY29udGFpbmVyQ29tcG9uZW50VHlwZSwNCi0gICAgICAgICAgICBAQ29udGV4dCBmaW5hbCBIdHRwU2VydmxldFJlcXVlc3QgcmVxdWVzdCkgew0KLSAgICAgICAgU2VydmxldENvbnRleHQgY29udGV4dCA9IHJlcXVlc3QuZ2V0U2Vzc2lvbigpLmdldFNlcnZsZXRDb250ZXh0KCk7DQotICAgICAgICBTdHJpbmcgdXJsID0gcmVxdWVzdC5nZXRNZXRob2QoKSArICIgIiArIHJlcXVlc3QuZ2V0UmVxdWVzdFVSSSgpOw0KLSAgICAgICAgUmVzcG9uc2UgcmVzcG9uc2UgPSBudWxsOw0KLSAgICAgICAgdHJ5IHsNCi0gICAgICAgICAgICBsb2cuZGVidWcoU1RBUlRfSEFORExFX1JFUVVFU1RfT0YsIHVybCk7DQotICAgICAgICAgICAgQ29tcG9uZW50VHlwZUVudW0gY29tcG9uZW50VHlwZUVudW0gPSBDb21wb25lbnRUeXBlRW51bS5maW5kQnlQYXJhbU5hbWUoY29udGFpbmVyQ29tcG9uZW50VHlwZSk7DQotICAgICAgICAgICAgaWYgKGNvbXBvbmVudEluc3RhbmNlQnVzaW5lc3NMb2dpYyA9PSBudWxsKSB7DQotICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZyhVTlNVUFBPUlRFRF9DT01QT05FTlRfVFlQRSwgY29udGFpbmVyQ29tcG9uZW50VHlwZSk7DQotICAgICAgICAgICAgICAgIHJldHVybiBid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4ganNvbj1cbiB7fSIsIGRhdGEpOw0KLSAgICAgICAgICAgIFQgdDsNCi0gICAgICAgICAgICB0ID0gZ3NvbkRlc2VyaWFsaXplci5mcm9tSnNvbihkYXRhLCBjbGF6eik7DQotICAgICAgICAgICAgaWYgKHQgPT0gbnVsbCkgew0KLSAgICAgICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nQmVJbnZhbGlkSnNvbklucHV0KCJjb252ZXJ0SnNvblRvT2JqZWN0Iik7DQotICAgICAgICAgICAgICAgIGxvZy5kZWJ1Zygib2JqZWN0IGlzIG51bGwgYWZ0ZXIgY29udmVydGluZyBmcm9tIGpzb24iKTsNCi0gICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChBY3Rpb25TdGF0dXMuSU5WQUxJRF9DT05URU5UKTsNCi0gICAgICAgICAgICB9DQotICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5sZWZ0KHQpOw0KLSAgICAgICAgfSBjYXRjaCAoRXhjZXB0aW9uIGUpIHsNCi0gICAgICAgICAgICAvLyBJTlZBTElEIEpTT04NCi0gICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nQmVJbnZhbGlkSnNvbklucHV0KCJjb252ZXJ0SnNvblRvT2JqZWN0Iik7DQotICAgICAgICAgICAgbG9nLmRlYnVnKCJmYWlsZWQgdG8gY29udmVydCBmcm9tIGpzb24iLCBlKTsNCi0gICAgICAgICAgICByZXR1cm4gRWl0aGVyLnJpZ2h0KEFjdGlvblN0YXR1cy5JTlZBTElEX0NPTlRFTlQpOw0KLSAgICAgICAgfQ0KLSAgICB9DQotDQotDQotICAgIEBHRVQNCi0gICAgQFBhdGgoIi97Y29udGFpbmVyQ29tcG9uZW50VHlwZX0ve2NvbXBvbmVudElkfS9wYXRocy10by1kZWxldGUiKQ0KLSAgICBAUHJvZHVjZXMoTWVkaWFUeXBlLkFQUExJQ0FU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VyLmxlZnQoQXJyYXlzLmFzTGlzdChjb252ZXJ0U3RhdHVzLmxlZnQoKS52YWx1ZSgpKSk7DQotICAgIH0NCi0NCi0gICAgcHJpdmF0ZSBFaXRoZXI8TGlzdDxSZXF1aXJlbWVudENhcGFiaWxpdHlSZWxEZWY+LCBSZXNwb25zZUZvcm1hdD4gY29udmVydFRvUmVxdWlyZW1lbnRDYXBhYmlsaXR5UmVsRGVmTGlzdChTdHJpbmcgZGF0YSkgew0KLSAgICAgICAgRWl0aGVyPFJlcXVpcmVtZW50Q2FwYWJpbGl0eVJlbERlZltdLCBSZXNwb25zZUZvcm1hdD4gY29udmVydFN0YXR1cyA9IGdldENvbXBvbmVudHNVdGlscygpLmNvbnZlcnRKc29uVG9PYmplY3RVc2luZ09iamVjdE1hcHBlcihkYXRhLCBuZXcgVXNlcigpLCBSZXF1aXJlbWVudENhcGFiaWxpdHlSZWxEZWZbXS5jbGFzcywgbnVsbCwgbnVsbCk7DQotDQotICAgICAgICBpZiAoY29udmVydFN0YXR1cy5pc1JpZ2h0KCkpIHsNCi0gICAgICAgICAgICByZXR1cm4gRWl0aGVyLnJpZ2h0KGNvbnZlcnRTdGF0dXMucmlnaHQoKS52YWx1ZSgpKTsNCi0gICAgICAgIH0NCi0NCi0gICAgICAgIHJldHVybiBFaXRoZXIubGVmdChBcnJheXMuYXNMaXN0KGNvbnZlcnRTdGF0dXMubGVmdCgpLnZhbHVlKCkpKTsNCi0gICAgfQ0KLQ0KLX0NCisvKi0KKyAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBTREMKKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBDb3B5cmlnaHQgKEMpIDIwMTcgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIE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dDsKK2ltcG9ydCBqYXZheC53cy5ycy5Db25zdW1lczsKK2ltcG9ydCBqYXZheC53cy5ycy5ERUxFVEU7CitpbXBvcnQgamF2YXgud3MucnMuR0VUOworaW1wb3J0IGphdmF4LndzLnJzLkhlYWRlclBhcmFtOworaW1wb3J0IGphdmF4LndzLnJzLlBPU1Q7CitpbXBvcnQgamF2YXgud3MucnMuUFVUOworaW1wb3J0IGphdmF4LndzLnJzLlBhdGg7CitpbXBvcnQgamF2YXgud3MucnMuUGF0aFBhcmFtOworaW1wb3J0IGphdmF4LndzLnJzLlByb2R1Y2VzOworaW1wb3J0IGphdmF4LndzLnJzLlF1ZXJ5UGFyYW07CitpbXBvcnQgamF2YXgud3MucnMuY29yZS5Db250ZXh0OworaW1wb3J0IGphdmF4LndzLnJzLmNvcmUuTWVkaWFUeXBlOworaW1wb3J0IGphdmF4LndzLnJzLmNvcmUuUmVzcG9uc2U7CitpbXBvcnQgamF2YS5pby5JT0V4Y2VwdGlvbjsKK2ltcG9ydCBqYXZhLmlvLklucHV0U3RyZWFtOworaW1wb3J0IGphdmEubGFuZy5yZWZsZWN0LlR5cGU7CitpbXBvcnQgamF2YS51dGlsLkFycmF5TGlzdDsKK2ltcG9ydCBqYXZhLnV0aWwuQXJyYXlzOworaW1wb3J0IGphdmEudXRpbC5MaXN0OworaW1wb3J0IGphdmEudXRpbC5NYXA7CitpbXBvcnQgamF2YS51dGlsLlNldDsKKworLyoqCisgKiBSb290IHJlc291cmNlIChleHBvc2VkIGF0ICIvIiBwYXRoKSAuanNvbgorICovCitATG9nZ2FibGUocHJlcGVuZCA9IHRydWUsIHZhbHVlID0gTG9nZ2FibGUuREVCVUcsIHRyaW0gPSBmYWxzZSkKK0BQYXRoKCIvdjEvY2F0YWxvZyIpCitAT3BlbkFQSURlZmluaXRpb24oaW5mbyA9IEBJbmZvKHRpdGxlID0gIlJlc291cmNlIEluc3RhbmNlIFNlcnZsZXQiKSkKK0BDb250cm9sbGVyCitwdWJsaWMgY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cyAvIHNlcnZpY2VzIiwKKyAgICAgICAgICAgICAgICAgICAgc2NoZW1hID0gQFNjaGVtYShhbGxvd2FibGVWYWx1ZXMgPSB7Q29tcG9uZW50VHlwZUVudW0uUkVTT1VSQ0VfUEFSQU1fTkFNRSAsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29tcG9uZW50VHlwZUVudW0uU0VSVklDRV9QQVJBTV9OQU1FfSkpIEBQYXRoUGFyYW0oImNvbnRhaW5lckNvbXBvbmVudFR5cGUiKSBmaW5hbCBTdHJpbmcgY29udGFpbmVyQ29tcG9uZW50VHlwZSwKKyAgICAgICAgICAgIEBIZWFkZXJQYXJhbSh2YWx1ZSA9IENvbnN0YW50cy5VU0VSX0lEX0hFQURFUikgQFBhcmFtZXRlcihkZXNjcmlwdGlvbiA9ICJVU0VSX0lEIG9mIG1vZGlmaWVyIHVzZXIiLAorICAgICAgICAgICAgICAgICAgICByZXF1aXJlZCA9IHRydWUpIFN0cmluZyB1c2VySWQsCisgICAgICAgICAgICBAQ29udGV4dCBmaW5hbCBIdHRwU2VydmxldFJlcXVlc3QgcmVxdWVzdCkgeworICAgICAgICAKKyAgICAgICAgdmFsaWRhdGVOb3RFbXB0eUJvZHkoZGF0YSk7CisgICAgICAgIENvbXBvbmVudEluc3RhbmNlIGNvbXBvbmVudEluc3RhbmNlID0gbnVsbDsKKyAgICAgICAgdHJ5IHsKKyAgICAgICAgICAgIGNvbXBvbmVudEluc3RhbmNlID0gUmVwcmVzZW50YXRpb25VdGlscy5mcm9tUmVwcmVzZW50YXRpb24oZGF0YSwgQ29tcG9uZW50SW5zdGFuY2UuY2xhc3MpOworICAgICAgICAgICAgY29tcG9uZW50SW5zdGFuY2Uuc2V0SW52YXJpYW50TmFtZShudWxsKTsKKyAgICAgICAgICAgIGNvbXBvbmVudEluc3RhbmNlLnNldENyZWF0ZWRGcm9tKENyZWF0ZWRGcm9tLlVJKTsKKyAgICAgICAgfSBjYXRjaCAoRXhjZXB0aW9uIGU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HJldHVybiBidWlsZEVycm9yUmVzcG9uc2UoZ2V0Q29tcG9uZW50c1V0aWxzKCkuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLklOVkFMSURfQ09OVEVOVCkpOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICBTdHJpbmcgdXNlcklkID0gcmVxdWVzdC5nZXRIZWFkZXIoQ29uc3RhbnRzLlVTRVJfSURfSEVBREVSKTsKKworICAgICAgICAgICAgU3RyaW5nIGRhdGEgPSBuZXcgU3RyaW5nKGJ5dGVzKTsKKyAgICAgICAgICAgIENvbXBvbmVudFR5cGVFbnVtIGNvbXBvbmVudFR5cGVFbnVtID0gQ29tcG9uZW50VHlwZUVudW0uZmluZEJ5UGFyYW1OYW1lKGNvbnRhaW5lckNvbXBvbmVudFR5cGUpOworICAgICAgICAgICAgaWYgKGNvbXBvbmVudEluc3RhbmNlQnVzaW5lc3NMb2dpYyA9PSBudWxsKSB7CisgICAgICAgICAgICAgICAgbG9nLmRlYnVnKFVOU1VQUE9SVEVEX0NPTVBPTkVOVF9UWVBFLCBjb250YWluZXJDb21wb25lbnRUeXBlKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gYnVpbGRFcnJvclJlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5VTlNVUFBPUlRFRF9FUlJPUiwgY29udGFpbmVyQ29tcG9uZW50VHlwZSkpOworICAgICAgICAgICAgfQorICAgICAgICAgICAgRWl0aGVyPENvbXBvbmVudEluc3RhbmNlLCBSZXNwb25zZUZvcm1hdD4gY29udmVydFJlc3BvbnNlID0gY29udmVydFRvUmVzb3VyY2VJbnN0YW5jZShkYXRhKTsKKworICAgICAgICAgICAgaWYgKGNvbnZlcnRSZXNwb25zZS5pc1JpZ2h0KCkpIHsKKyAgICAgICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nQmVT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gICByZXR1cm4gYnVpbGRFcnJvclJlc3BvbnNlKGFjdGlvblJlc3BvbnNlLnJpZ2h0KCkudmFsdWUoKSk7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBDb21wb25lbnRJbnN0YW5jZSByZXN1bHRWYWx1ZSA9IGFjdGlvblJlc3BvbnNlLmxlZnQoKS52YWx1ZSgpOworICAgICAgICAgICAgaWYgKGNvbXBvbmVudFR5cGVFbnVtLmVxdWFscyhDb21wb25lbnRUeXBlRW51bS5TRVJWSUNFKSl7CisgICAgICAgICAgICAgICAgYm9vbGVhbiBzaG91bGRDcmVhdGVTZXJ2aWNlRmlsdGVyID0gcmVzb3VyY2VJbnN0YW5jZS5nZXREaXJlY3RpdmVzKCkgIT0gbnVsbCAmJiByZXNvdXJjZUluc3RhbmNlLmdldERpcmVjdGl2ZXMoKS5jb250YWlucygKKyAgICAgICAgICAgICAgICAgICAgICAgIERpcmVjdGl2ZXNVdGlscy5TRUxFQ1RBQkxFKTsKKworICAgICAgICAgICAgICAgIGlmKHNob3VsZENyZWF0ZVNlcnZpY2VGaWx0ZXIpIHsKKyAgICAgICAgICAgICAgICAgICAgRWl0aGVyPENJTm9kZUZpbHRlckRhdGFEZWZpbml0aW9uLCBSZXNwb25zZUZvcm1hdD4gZWl0aGVyID0KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXJ2aWNlQnVzaW5lc3NMb2dpYy5jcmVhdGVJZk5vdEFscmVhZHlFeGlzdFNlcnZpY2VGaWx0ZXIoY29tcG9uZW50SWQsIGNvbXBvbmVudEluc3RhbmNlSWQsIHVzZXJJZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRydWUpOworICAgICAgICAgICAgICAgICAgICBpZiAoZWl0aGVyLmlzUmlnaHQoKSl7CisgICAgICAgICAgICAgICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nQmVTeXN0ZW1FcnJvcigiUmVzb3VyY2UgSW5zdGFuY2UgLSB1cGRhdGVSZXNvdXJjZUluc3RhbmNlIEZhaWxlZCB0byBjcmVhdGUgc2VydmljZSBmaWx0ZXIuIik7CisgICAgICAgICAgICAgICAgICAgICAgICBsb2cuZGVidWcoIkZhaWxlZCB0byBjcmVhdGUgc2VydmljZSBmaWx0ZXIuIik7CisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYnVpbGRFcnJvclJlc3BvbnNlKGNvbnZlcnRSZXNwb25zZS5yaWdodCgpLnZhbHVlKCkpOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIHJlc3VsdFZhbHVlLnNldE5vZGVGaWx0ZXIoZWl0aGVyLmxlZnQoKS52YWx1ZSgpKTsKKyAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICBFaXRoZXI8U3RyaW5nLCBSZXNwb25zZUZvcm1hdD4gZWl0aGVyID0gc2VydmljZUJ1c2luZXNzTG9naWMuZGVsZXRlSWZOb3RBbHJlYWR5RGVsZXRlZFNlcnZpY2VGaWx0ZXIoY29tcG9uZW50SWQsIGNvbXBvbmVudEluc3RhbmNlSWQsICB1c2VySWQsdHJ1ZSk7CisgICAgICAgICAgICAgICAgICAgIGlmIChlaXRoZXIuaXNSaWdodCgpKXsKKyAgICAgICAgICAgICAgICAgICAgICAgIEJlRWNvbXBFcnJvck1hbmFnZXIuZ2V0SW5zdGFuY2UoKS5sb2dCZVN5c3RlbUVycm9yKCJSZXNvdXJjZSBJbnN0YW5jZSAtIHVwZGF0ZVJlc291cmNlSW5zdGFuY2UgRmFpbGVkIHRvIGRlbGV0ZSBzZXJ2aWNlIGZpbHRlci4iKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiRmFpbGVkIHRvIGRlbGV0ZSBzZXJ2aWNlIGZpbHRlci4iKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBidWlsZEVycm9yUmVzcG9uc2UoY29udmV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gICAgICAgICAgICB9CisKKyAgICAgICAgICAgIFN0cmluZyB1c2VySWQgPSByZXF1ZXN0LmdldEhlYWRlcihDb25zdGFudHMuVVNFUl9JRF9IRUFERVIpOworCisgICAgICAgICAgICBDb21wb25lbnRUeXBlRW51bSBjb21wb25lbnRUeXBlRW51bSA9IENvbXBvbmVudFR5cGVFbnVtLmZpbmRCeVBhcmFtTmFtZShjb250YWluZXJDb21wb25lbnRUeXBlKTsKKyAgICAgICAgICAgIGlmIChjb21wb25lbnRJbnN0YW5jZUJ1c2luZXNzTG9naWMgPT0gbnVsbCkgeworICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZyhVTlNVUFBPUlRFRF9DT01QT05FTlRfVFlQRSwgY29udGFpbmVyQ29tcG9uZW50VHlwZSk7CisgICAgICAgICAgICAgICAgcmV0dXJuIGJ1aWxkRXJyb3JSZXNwb25zZShnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuVU5TVVBQT1JURURfRVJST1IsIGNvbnRhaW5lckNvbXBvbmVudFR5cGUpKTsKKyAgICAgICAgICAgIH0KKworICAgICAgICAgICAgRWl0aGVyPExpc3Q8Q29tcG9uZW50SW5zdGFuY2U+LCBSZXNwb25zZUZvcm1hdD4gY29udmVydFJlc3BvbnNlID0gY29udmVydFRvTXVsdGlwbGVSZXNvdXJjZUluc3RhbmNlKGNvbXBvbmVudEluc3RhbmNlSnNvbkFycmF5KTsKKworICAgICAgICAgICAgaWYgKGNvbnZlcnRSZXNwb25zZS5pc1JpZ2h0KCkpIHsKKyAgICAgICAgICAgICAgICAvLyBVc2luZyBib3RoIEVDT01QIGVycm9yIG1ldGhvZHMsIHNob3cgdG8gU29mZXIKKyAgICAgICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nQmVTeXN0ZW1FcnJvcihSRVNPVVJDRV9JTlNUQU5DRV9VUERBVEVfUkVTT1VSQ0V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gICAgICBASGVhZGVyUGFyYW0odmFsdWUgPSBDb25zdGFudHMuVVNFUl9JRF9IRUFERVIpIFN0cmluZyB1c2VySWQsCisgICAgICAgICAgICBAUGFyYW1ldGVyKGRlc2NyaXB0aW9uID0gIlJlbGF0aW9uc2hpcEluZm8iLCByZXF1aXJlZCA9IHRydWUpIFN0cmluZyBkYXRhLAorICAgICAgICAgICAgQENvbnRleHQgZmluYWwgSHR0cFNlcnZsZXRSZXF1ZXN0IHJlcXVlc3QpIHsKKworICAgICAgICBTdHJpbmcgdXJsID0gcmVxdWVzdC5nZXRNZXRob2QoKSArICIgIiArIHJlcXVlc3QuZ2V0UmVxdWVzdFVSSSgpOworICAgICAgICBsb2cuZGVidWcoU1RBUlRfSEFORExFX1JFUVVFU1RfT0YsIHVybCk7CisgICAgICAgIGxvZ2dlclN1cHBvcnRhYmlsaXR5LmxvZyhMb2dnZXJTdXBwb3J0YWJpbGl0eUFjdGlvbnMuVU5fQVNTT0NJQVRFX1JJX1RPX1JJLCBTdGF0dXNDb2RlLlNUQVJURUQsIlN0YXJ0aW5nIHRvIHVuZG8gYXNzb2NpYXRlIFJJIFRvIFJJIGZvciBjb21wb25lbnQge30gIixjb21wb25lbnRJZCArICIgYnkgIiArICB1c2VySWQgKTsKKyAgICAgICAgdHJ5IHsKKworICAgICAgICAgICAgbG9nLmRlYnVnKFNUQVJUX0hBTkRMRV9SRVFVRVNUX09GLCB1cmwpOworCisgICAgICAgICAgICBDb21wb25lbnRUeXBlRW51bSBjb21wb25lbnRUeXBlRW51bSA9IENvbXBvbmVudFR5cGVFbnVtLmZpbmRCeVBhcmFtTmFtZShjb250YWluZXJDb21wb25lbnRUeXBlKTsKKyAgICAgICAgICAgIGlmIChjb21wb25lbnRJbnN0YW5jZUJ1c2luZXNzTG9naWMgPT0gbnVsbCkgeworICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZyhVTlNVUFBPUlRFRF9DT01QT05FTlRfVFlQRSwgY29udGFpbmVyQ29tcG9u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ZXRNZXRob2QoKSArICIgIiArIHJlcXVlc3QuZ2V0UmVxdWVzdFVSSSgpOworICAgICAgICBsb2cuZGVidWcoU1RBUlRfSEFORExFX1JFUVVFU1RfT0YsIHVybCk7CisgICAgICAgIHRyeSB7CisKKyAgICAgICAgICAgIGxvZy5kZWJ1ZyhTVEFSVF9IQU5ETEVfUkVRVUVTVF9PRiwgdXJsKTsKKworICAgICAgICAgICAgSW5wdXRTdHJlYW0gaW5wdXRTdHJlYW0gPSByZXF1ZXN0LmdldElucHV0U3RyZWFtKCk7CisKKyAgICAgICAgICAgIGJ5dGVbXSBieXRlcyA9IElPVXRpbHMudG9CeXRlQXJyYXkoaW5wdXRTdHJlYW0pOworCisgICAgICAgICAgICBpZiAoYnl0ZXMgPT0gbnVsbCB8fCBieXRlcy5sZW5ndGggPT0gMCkgeworICAgICAgICAgICAgICAgIGxvZy5pbmZvKEVNUFRZX0JPRFlfV0FTX1NFTlQpOworICAgICAgICAgICAgICAgIHJldHVybiBidWlsZEVycm9yUmVzcG9uc2UoZ2V0Q29tcG9uZW50c1V0aWxzKCkuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLklOVkFMSURfQ09OVEVOVCkpOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICBTdHJpbmcgdXNlcklkID0gcmVxdWVzdC5nZXRIZWFkZXIoQ29uc3RhbnRzLlVTRVJfSURfSEVBREVSKTsKKworICAgICAgICAgICAgU3RyaW5nIGRhdGEgPSBuZXcgU3RyaW5nKGJ5dGVzKTsKKworICAgICAgICAgICAgQ29tcG9uZW50VHlwZUVudW0gY29tcG9uZW50VHlwZUVudW0gPSBDb21wb25lbnRUeXBlRW51bS5maW5kQnlQYXJhbU5hbWUoY29udGFpbmVyQ29tcG9uZW50VHlwZSk7CisgICAgICAgICAgICBpZiAoY29tcG9uZW50SW5zdGFuY2VCdXNpbmVzc0xvZ2ljID09IG51bGwpIHsKKyAgICAgICAgICAgICAgICBsb2cuZGVidWcoV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pOworICAgICAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgICAgIGlucHV0c1RvVXBkYXRlID0gaW5wdXRzVG9VcGRhdGVFaXRoZXIubGVmdCgpLnZhbHVlKCk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgICAgIGlmICghZXJyb3JXcmFwcGVyLmlzRW1wdHkoKSkgeworICAgICAgICAgICAgICAgIHJldHVybiBidWlsZEVycm9yUmVzcG9uc2UoZXJyb3JXcmFwcGVyLmdldElubmVyRWxlbWVudCgpKTsKKyAgICAgICAgfQorICAgICAgICBsb2cuZGVidWcoU1RBUlRfSEFORExFX1JFUVVFU1RfT0ZfVVBEQVRFX1JFU09VUkNFX0lOU1RBTkNFX1BST1BFUlRZX1JFQ0VJVkVEX1BST1BFUlRZX0lTLCBpbnB1dHNUb1VwZGF0ZSk7CisgICAgICAgIAorICAgICAgICBDb21wb25lbnRUeXBlRW51bSBjb21wb25lbnRUeXBlRW51bSA9IENvbXBvbmVudFR5cGVFbnVtLmZpbmRCeVBhcmFtTmFtZShjb250YWluZXJDb21wb25lbnRUeXBlKTsKKyAgICAgICAgaWYgKGNvbXBvbmVudEluc3RhbmNlQnVzaW5lc3NMb2dpYyA9PSBudWxsKSB7CisgICAgICAgICAgICAgICAgbG9nLmRlYnVnKFVOU1VQUE9SVEVEX0NPTVBPTkVOVF9UWVBFLCBjb250YWluZXJDb21wb25lbnRUeXBlKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gYnVpbGRFcnJvclJlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5VTlNVUFBPUlRFRF9FUlJPUiwgY29udGFpbmVyQ29tcG9uZW50VHlwZSkpOworICAgICAgICB9CisgICAgICAgIEVpdGhlcjxMaXN0PENvbXBvbmVudEluc3RhbmNlSW5wdXQ+LCBSZXNwb25zZUZvcm1hdD4gYWN0aW9uUmVzcG9uc2UgPQorIC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UX1RZUEUsIGNvbnRhaW5lckNvbXBvbmVudFR5cGUpOworICAgICAgICAgICAgICAgIHJldHVybiBidWlsZEVycm9yUmVzcG9uc2UoZ2V0Q29tcG9uZW50c1V0aWxzKCkuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLlVOU1VQUE9SVEVEX0VSUk9SLCBjb250YWluZXJDb21wb25lbnRUeXBlKSk7CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIEVpdGhlcjxDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5LCBSZXNwb25zZUZvcm1hdD4gYWN0aW9uUmVzcG9uc2UgPSBjb21wb25lbnRJbnN0YW5jZUJ1c2luZXNzTG9naWMuZGVsZXRlUHJvcGVydHlWYWx1ZShjb21wb25lbnRUeXBlRW51bSwgY29tcG9uZW50SWQsIGNvbXBvbmVudEluc3RhbmNlSWQsIHByb3BlcnR5SWQsIHVzZXJJZCk7CisgICAgICAgICAgICBpZiAoYWN0aW9uUmVzcG9uc2UuaXNSaWdodCgpKSB7CisgICAgICAgICAgICAgICAgcmV0dXJuIGJ1aWxkRXJyb3JSZXNwb25zZShhY3Rpb25SZXNwb25zZS5yaWdodCgpLnZhbHVlKCkpOworICAgICAgICAgICAgfQorICAgICAgICAgICAgcmV0dXJuIGJ1aWxkT2tSZXNwb25zZShnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuTk9fQ09OVEVOVCksIG51bGwpOworICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZSkgeworICAgICAgICAgICAgbG9nLmVycm9yKENSRUFURV9BTkRfQVNTT0NJQVRFX1JJX0ZBSUxFRF9XSVRIX0VYQ0VQVElPTiwgZS5nZXRNZXNzYWdlKCksIGUpOworICAgICAgICAgICAgdGhyb3cgZTsKKyAgICAgICAgfQorCisgICAgfQorCisgICAgQFBPU1QKKyAgICBAUGF0aCgiL3tjb250YWluZXJDb21wb25lbnRUeX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cyA9PSBudWxsIHx8IGJ5dGVzLmxlbmd0aCA9PSAwKSB7CisgICAgICAgICAgICAgICAgbG9nLmluZm8oRU1QVFlfQk9EWV9XQVNfU0VOVCk7CisgICAgICAgICAgICAgICAgcmV0dXJuIGJ1aWxkRXJyb3JSZXNwb25zZShnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuSU5WQUxJRF9DT05URU5UKSk7CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIFN0cmluZyB1c2VySWQgPSByZXF1ZXN0LmdldEhlYWRlcihDb25zdGFudHMuVVNFUl9JRF9IRUFERVIpOworCisgICAgICAgICAgICBTdHJpbmcgZGF0YSA9IG5ldyBTdHJpbmcoYnl0ZXMpOworCisgICAgICAgICAgICBDb21wb25lbnRUeXBlRW51bSBjb21wb25lbnRUeXBlRW51bSA9IENvbXBvbmVudFR5cGVFbnVtLmZpbmRCeVBhcmFtTmFtZShjb250YWluZXJDb21wb25lbnRUeXBlKTsKKyAgICAgICAgICAgIGlmIChjb21wb25lbnRJbnN0YW5jZUJ1c2luZXNzTG9naWMgPT0gbnVsbCkgeworICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZyhVTlNVUFBPUlRFRF9DT01QT05FTlRfVFlQRSwgY29udGFpbmVyQ29tcG9uZW50VHlwZSk7CisgICAgICAgICAgICAgICAgcmV0dXJuIGJ1aWxkRXJyb3JSZXNwb25zZShnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuVU5TVVBQT1JURURfRVJST1IsIGNvbnRhaW5lckNvbXBvbmVudFR5cGUpKTsKKyAgICAgICAgICAgIH0KKworICAgICAgICAgICAgRWl0aGVyPENvbXBvbmVudEluc3RhbmNlLCBSZXNwb25zZUZvcm1hdD4gY29udmVydFJlc3BvbnNlID0gY29udmVydFRvUmVzb3VyY2VJbnN0YW5jZShkYXRhKTsKKworICAgICAgIC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FwcGVyPENvbXBvbmVudEluc3RhbmNlUHJvcGVydHk+IHByb3BlcnR5V3JhcHBlciA9IG5ldyBXcmFwcGVyPD4oKTsKKworICAgICAgICAgICAgdmFsaWRhdGVJbnB1dFN0cmVhbShyZXF1ZXN0LCBkYXRhV3JhcHBlciwgZXJyb3JXcmFwcGVyKTsKKworICAgICAgICAgICAgaWYgKGVycm9yV3JhcHBlci5pc0VtcHR5KCkpIHsKKyAgICAgICAgICAgICAgICB2YWxpZGF0ZUNsYXNzUGFyc2UoZGF0YVdyYXBwZXIuZ2V0SW5uZXJFbGVtZW50KCksIHByb3BlcnR5V3JhcHBlciwgKCkgLT4gQ29tcG9uZW50SW5zdGFuY2VQcm9wZXJ0eS5jbGFzcywgZXJyb3JXcmFwcGVyKTsKKyAgICAgICAgICAgIH0KKworICAgICAgICAgICAgaWYgKCFlcnJvcldyYXBwZXIuaXNFbXB0eSgpKSB7CisgICAgICAgICAgICAgICAgcmV0dXJuIGJ1aWxkRXJyb3JSZXNwb25zZShlcnJvcldyYXBwZXIuZ2V0SW5uZXJFbGVtZW50KCkpOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICBDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5IHByb3BlcnR5ID0gcHJvcGVydHlXcmFwcGVyLmdldElubmVyRWxlbWVudCgpOworCisgICAgICAgICAgICBsb2cuZGVidWcoU1RBUlRfSEFORExFX1JFUVVFU1RfT0ZfVVBEQVRFX1JFU09VUkNFX0lOU1RBTkNFX1BST1BFUlRZX1JFQ0VJVkVEX1BST1BFUlRZX0lTLCBwcm9wZXJ0eSk7CisKKyAgICAgICAgICAgIAorCisgICAgICAgICAgICBDb21wb25lbnRUeXBlRW51bSBjb21wb25lbnRUeXBlRW51bSA9IENvbXBvbmVudFR5cGVFbnVtLmZpbmRCeVBhcmFtTmFtZShjb250YWluZXJDb21wb25lbnRUeXBlKTsKKyAgICAgICAgICAgIGlmIChjb21wb25lbnRJbnN0YW5jZUJ1c2luZXNzTG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c2UgY3JlYXRlU2VydmljZVByb3h5KEBQYXJhbWV0ZXIoZGVzY3JpcHRpb24gPSAiUkkgb2JqZWN0IHRvIGJlIGNyZWF0ZWQiLCByZXF1aXJlZCA9IHRydWUpIFN0cmluZyBkYXRhLAorICAgICAgICAgICAgQFBhdGhQYXJhbSgiY29udGFpbmVyQ29tcG9uZW50SWQiKSBmaW5hbCBTdHJpbmcgY29udGFpbmVyQ29tcG9uZW50SWQsCisgICAgICAgICAgICBAUGFyYW1ldGVyKGRlc2NyaXB0aW9uID0gInZhbGlkIHZhbHVlczogcmVzb3VyY2VzIC8gc2VydmljZXMiLAorICAgICAgICAgICAgICAgICAgICBzY2hlbWEgPSBAU2NoZW1hKGFsbG93YWJsZVZhbHVlcyA9IHtDb21wb25lbnRUeXBlRW51bS5SRVNPVVJDRV9QQVJBTV9OQU1FLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbXBvbmVudFR5cGVFbnVtLlNFUlZJQ0VfUEFSQU1fTkFNRX0pKSBAUGF0aFBhcmFtKCJjb250YWluZXJDb21wb25lbnRUeXBlIikgZmluYWwgU3RyaW5nIGNvbnRhaW5lckNvbXBvbmVudFR5cGUsCisgICAgICAgICAgICBASGVhZGVyUGFyYW0odmFsdWUgPSBDb25zdGFudHMuVVNFUl9JRF9IRUFERVIpIEBQYXJhbWV0ZXIoZGVzY3JpcHRpb24gPSAiVVNFUl9JRCBvZiBtb2RpZmllciB1c2VyIiwKKyAgICAgICAgICAgICAgICAgICAgcmVxdWlyZWQgPSB0cnVlKSBTdHJpbmcgdXNlcklkLAorICAgICAgICAgICAgQENvbnRleHQgZmluYWwgSHR0cFNlcnZsZXRSZXF1ZXN0IHJlcXVlc3QpIHsKKworICAgICAgICB0cnkgeworCisgICAgICAgICAgICBDb21wb25lbnRJbnN0YW5jZSBjb21wb25lbnRJbnN0YW5jZSA9IFJlcHJlc2VudGF0aW9uVXRpbHMuZnJvbVJlcHJlc2VudGF0aW9uKGRhdGEsIENvbXBvbmVudEluc3RhbmNlLmNsYXNzKTsKKyAgICAgICAgICAgIGNvbXBvbmVudEluc3RhbmNlLnNldEludmFyaWFudE5hbWUobnVsbCk7CisgICAgICAgICAgICBDb21wb25lbnRUeXBlRW51bSBjb21wb25lbnRUeXBlRW51bSA9IENvbXBvbmVudFR5cGVFbnVtLmZpbmRCeVBhcmFtTmFtZShjb250YWluZXJDb21wb25lbnRUeXBlKTsKKyAgICAgICAgICAgIGlmIChjb21wb25lbnRUeXBlRW51bSAhPSBDb21wb25lbnRUeXBlRW51bS5TRVJWSUNFKSB7CisgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJVbnN1cHBvcnRlZCBjb250YWluZXIgY29tcG9uZW50IHR5cGUge30iLCBjb250YWluZXJDb21wb25lbnRUeXBlKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gYnVpbGRFcnJvclJlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5VTlNVUFBPUlRFRF9FUlJPUiwgY29udGFpbmVyQ29tcG9uZW50VHlwZSkpOworICAgICAgICAgICAgfQorICAgICAgICAgICAgaWYgKGNvbXBvbmVudEluc3RhbmNlQnVzaW5lc3NMb2dpYyA9PSBudWxsKSB7CisgICAgICAgICAgICAgICAgbG9nLmRlYnVnKFVOU1VQUE9SVEVEX0NPTVBPTkVOVF9UWVBFLCBjb250YWluZXJDb21wb25lbnRUeXBlKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gYnVpbGRFcnJvclJlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5VTlNVUFBPUlRFRF9FUlJPUiwgY29udGFpbmVyQ29tcG9uZW50VHlwZSkpOworICAgICAgICAgICAgfQorICAgICAgICAgICAgRWl0aGVyPENvbXBvbmVudEluc3RhbmNlLCBSZXNwb25zZUZvcm1hdD4gYWN0aW9uUmVzcG9uc2UgP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U3RyaW5nIHVzZXJJZCA9IHJlcXVlc3QuZ2V0SGVhZGVyKENvbnN0YW50cy5VU0VSX0lEX0hFQURFUik7CisgICAgICAgICAgICBFaXRoZXI8Q29tcG9uZW50SW5zdGFuY2UsIFJlc3BvbnNlRm9ybWF0PiBhY3Rpb25SZXNwb25zZSA9IGNvbXBvbmVudEluc3RhbmNlQnVzaW5lc3NMb2dpYy5kZWxldGVTZXJ2aWNlUHJveHkoKTsKKworICAgICAgICAgICAgaWYgKGFjdGlvblJlc3BvbnNlLmlzUmlnaHQoKSkgeworICAgICAgICAgICAgICAgIHJldHVybiBidWlsZEVycm9yUmVzcG9uc2UoYWN0aW9uUmVzcG9uc2UucmlnaHQoKS52YWx1ZSgpKTsKKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgcmV0dXJuIGJ1aWxkT2tSZXNwb25zZShnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuTk9fQ09OVEVOVCksIG51bGwpOworICAgICAgICAgICAgfQorICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZSkgeworICAgICAgICAgICAgQmVFY29tcEVycm9yTWFuYWdlci5nZXRJbnN0YW5jZSgpLmxvZ0JlUmVzdEFwaUdlbmVyYWxFcnJvcigiRGVsZXRlIHNlcnZpY2UgcHJveHkiKTsKKyAgICAgICAgICAgIGxvZy5kZWJ1ZygiRGVsZXRlIHNlcnZpY2UgcHJveHkgZmFpbGVkIHdpdGggZXhjZXB0aW9uIiwgZSk7CisgICAgICAgICAgICB0aHJvdyBlOworICAgICAgICB9CisgICAgfQorCisgICAgQFBPU1QKKyAgICBAUGF0aCgiL3tjb250YWluZXJDb21wb25lbnRUeXBlfS97Y29udGFpbmVyQ29tcG9uZW50SWR9L3NlcnZpY2VQcm94eS97c2VydmljZVByb3h5SWR9L2NoYW5nZVZlcnNpb24ve25ld1NlcnZpY2VJZH0iKQorICAgIEBDb25zdW1l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b21wb25lbnRJZCwKKyAgICAgICAgICAgIEBQYXRoUGFyYW0oInNlcnZpY2VQcm94eUlkIikgZmluYWwgU3RyaW5nIHNlcnZpY2VQcm94eUlkLAorICAgICAgICAgICAgQFBhcmFtZXRlcihkZXNjcmlwdGlvbiA9ICJ2YWxpZCB2YWx1ZXM6IHJlc291cmNlcyAvIHNlcnZpY2VzIiwKKyAgICAgICAgICAgICAgICAgICAgc2NoZW1hID0gQFNjaGVtYShhbGxvd2FibGVWYWx1ZXMgPSB7Q29tcG9uZW50VHlwZUVudW0uUkVTT1VSQ0VfUEFSQU1fTkFNRSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb21wb25lbnRUeXBlRW51bS5TRVJWSUNFX1BBUkFNX05BTUV9KSkgQFBhdGhQYXJhbSgiY29udGFpbmVyQ29tcG9uZW50VHlwZSIpIGZpbmFsIFN0cmluZyBjb250YWluZXJDb21wb25lbnRUeXBlLAorICAgICAgICAgICAgQENvbnRleHQgZmluYWwgSHR0cFNlcnZsZXRSZXF1ZXN0IHJlcXVlc3QpIHsKKyAgICAgICAgCisKKyAgICAgICAgU3RyaW5nIHVybCA9IHJlcXVlc3QuZ2V0TWV0aG9kKCkgKyAiICIgKyByZXF1ZXN0LmdldFJlcXVlc3RVUkkoKTsKKyAgICAgICAgbG9nLmRlYnVnKFNUQVJUX0hBTkRMRV9SRVFVRVNUX09GLCB1cmwpOworICAgICAgICB0cnkgeworCisgICAgICAgICAgICBTdHJpbmcgdXNlcklkID0gcmVxdWVzdC5nZXRIZWFkZXIoQ29uc3RhbnRzLlVTRVJfSURfSEVBREVSKTsKKworICAgICAgICAgICAgQ29tcG9uZW50VHlwZUVudW0gY29tcG9uZW50VHlwZUVudW0gPSBDb21wb25lbnRUeXBlRW51bS5maW5kQnlQYXJhbU5hbWUoY29udGFpbmVyQ29tcG9uZW50VHlwZSk7CisgICAgICAgICAgICBpZiAoY29tcG9uZW50SW5zdGFuY2VCdXNpbmVzc0xvZ2ljID09IG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ICAgQ29tcG9uZW50VHlwZUVudW0gY29tcG9uZW50VHlwZUVudW0gPSBDb21wb25lbnRUeXBlRW51bS5maW5kQnlQYXJhbU5hbWUoY29udGFpbmVyQ29tcG9uZW50VHlwZSk7CisgICAgICAgICAgICBpZiAoY29tcG9uZW50VHlwZUVudW0gPT0gbnVsbCkgeworICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZyhVTlNVUFBPUlRFRF9DT01QT05FTlRfVFlQRSwgY29udGFpbmVyQ29tcG9uZW50VHlwZSk7CisgICAgICAgICAgICAgICAgcmV0dXJuIGJ1aWxkRXJyb3JSZXNwb25zZShnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuVU5TVVBQT1JURURfRVJST1IsIGNvbnRhaW5lckNvbXBvbmVudFR5cGUpKTsKKyAgICAgICAgICAgIH0KKworICAgICAgICAgICAgRWl0aGVyPFJlcXVpcmVtZW50Q2FwYWJpbGl0eVJlbERlZiwgUmVzcG9uc2VGb3JtYXQ+IGFjdGlvblJlc3BvbnNlID0gY29tcG9uZW50SW5zdGFuY2VCdXNpbmVzc0xvZ2ljLmdldFJlbGF0aW9uQnlJZChjb21wb25lbnRJZCwgcmVsYXRpb25JZCwgdXNlcklkLCBjb21wb25lbnRUeXBlRW51bSk7CisgICAgICAgICAgICBpZiAoYWN0aW9uUmVzcG9uc2UuaXNSaWdodCgpKSB7CisgICAgICAgICAgICAgICAgcmV0dXJuIGJ1aWxkRXJyb3JSZXNwb25zZShhY3Rpb25SZXNwb25zZS5yaWdodCgpLnZhbHVlKCkpOworICAgICAgICAgICAgfQorICAgICAgICAgICAgcmV0dXJuIGJ1aWxkT2tSZXNwb25zZShnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuT0spLCBhY3Rpb25SZXNwb25zZS5sZWZ0KCkudmFsdWUoKSk7CisgICAgICAgIH0gY2F0Y2ggKEV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gICAgICB0cnkgeworICAgICAgICAgICAgbG9nLnRyYWNlKCJjb252ZXJ0IGpzb24gdG8gb2JqZWN0LiBqc29uPVxuIHt9IiwgZGF0YSk7CisgICAgICAgICAgICBUIHQ7CisgICAgICAgICAgICB0ID0gZ3NvbkRlc2VyaWFsaXplci5mcm9tSnNvbihkYXRhLCBjbGF6eik7CisgICAgICAgICAgICBpZiAodCA9PSBudWxsKSB7CisgICAgICAgICAgICAgICAgQmVFY29tcEVycm9yTWFuYWdlci5nZXRJbnN0YW5jZSgpLmxvZ0JlSW52YWxpZEpzb25JbnB1dCgiY29udmVydEpzb25Ub09iamVjdCIpOworICAgICAgICAgICAgICAgIGxvZy5kZWJ1Zygib2JqZWN0IGlzIG51bGwgYWZ0ZXIgY29udmVydGluZyBmcm9tIGpzb24iKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gRWl0aGVyLnJpZ2h0KEFjdGlvblN0YXR1cy5JTlZBTElEX0NPTlRFTlQpOworICAgICAgICAgICAgfQorICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5sZWZ0KHQpOworICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZSkgeworICAgICAgICAgICAgLy8gSU5WQUxJRCBKU09OCisgICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nQmVJbnZhbGlkSnNvbklucHV0KCJjb252ZXJ0SnNvblRvT2JqZWN0Iik7CisgICAgICAgICAgICBsb2cuZGVidWcoImZhaWxlZCB0byBjb252ZXJ0IGZyb20ganNvbiIsIGUpOworICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChBY3Rpb25TdGF0dXMuSU5WQUxJRF9DT05URU5UKTsKKyAgICAgICAgfQorICAgIH0KKworCisgICAgQEdFVAorICAgIEBQYXRoKCIve2NvbnRhaW5lckNvbXBvbmVudFR5cGV9L3tjb21wb25lbnRJZH0vcGF0aHMtdG8tZGVsZXRlIikKKyAgICBAUHJvZHVjZXMoTWV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N0YW50cy5VU0VSX0lEX0hFQURFUik7CisgICAgICAgIGZpbmFsIFN0cmluZyBDTlRBSU5FUl9DTVBUX1RZUEUgPSAic2VydmljZXMiOworCisgICAgICAgIHRyeSB7CisgICAgICAgICAgICBDb21wb25lbnRJbnN0YW5jZSBpbnB1dENvbXBvbmVudEluc3RhbmNlID0gUmVwcmVzZW50YXRpb25VdGlscy5mcm9tUmVwcmVzZW50YXRpb24oZGF0YSwgQ29tcG9uZW50SW5zdGFuY2UuY2xhc3MpOworICAgICAgICAgICAgaW5wdXRDb21wb25lbnRJbnN0YW5jZS5zZXRJbnZhcmlhbnROYW1lKG51bGwpOworICAgICAgICAgICAgQ29tcG9uZW50VHlwZUVudW0gY29tcG9uZW50VHlwZUVudW0gPSBDb21wb25lbnRUeXBlRW51bS5maW5kQnlQYXJhbU5hbWUoQ05UQUlORVJfQ01QVF9UWVBFKTsKKyAgICAgICAgICAgIGlmIChjb21wb25lbnRJbnN0YW5jZUJ1c2luZXNzTG9naWMgPT0gbnVsbCkgeworICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZyhVTlNVUFBPUlRFRF9DT01QT05FTlRfVFlQRSwgY29tcG9uZW50VHlwZUVudW0pOworICAgICAgICAgICAgICAgIHJldHVybiBidWlsZEVycm9yUmVzcG9uc2UoZ2V0Q29tcG9uZW50c1V0aWxzKCkuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLlVOU1VQUE9SVEVEX0VSUk9SLCAic2VydmljZXMiKSk7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBFaXRoZXI8TWFwPFN0cmluZywgQ29tcG9uZW50SW5zdGFuY2U+LCBSZXNwb25zZUZvcm1hdD4gY29weUNvbXBvbmVudEluc3RhbmNlID0gY29tcG9uZW50SW5zdGFuY2VCdXNpbmVzc0xvZ2ljLmNvcHlDb21wb25lbnRJbnN0YW5jZSgKKyAgICAgICAgICAgICAgICAgICAgaW5wdXRDb21wb25lbnRJbnN0YW5jZSwgY29udGFpbmVyQ29tcG9uZW50SWQsIGNvbXBvbmVudEluc3RhbmNlSWQsIHVzZXJJZCk7CisKKyAgICAgICAgICAgIGlmIChjb3B5Q29tcG9uZW50SW5zdGFuY2UuaXNSaWdodCgpKSB7CisgICAgICAgICAgICAgICAgbG9nLmVycm9yKCJGYWlsZWQgdG8gY29weSBDb21wb25lbnRJbnN0YW5jZSB7fSIsIGNvcHlDb21wb25lbnRJbnN0YW5jZS5yaWdodCgpLnZhbHVlKCkpOworICAgICAgICAgICAgICAgIHJldHVybiBidWlsZEVycm9yUmVzcG9uc2UoY29weUNvbXBvbmVudEluc3RhbmNlLnJpZ2h0KCkudmFsdWUoKSk7CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIHJldHVybiBidWlsZE9rUmVzcG9uc2UoZ2V0Q29tcG9uZW50c1V0aWxzKCkuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLk9LKSwKKyAgICAgICAgICAgICAgICAgICAgY29weUNvbXBvbmVudEluc3RhbmNlLmxlZnQoKS52YWx1ZSgpKTsKKyAgICAgICAgfSBjYXRjaCAoRXhjZXB0aW9uIGUpIHsKKyAgICAgICAgICAgIGxvZy5lcnJvcigiRmFpbGVkIHRvIGNvbnZlcnQganNvbiB0byBNYXAgeyB9IiwgZGF0YSwgZSk7CisgICAgICAgICAgICByZXR1cm4gYnVpbGRFcnJvclJlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5VU0VSX0RFRklORUQsCisgICAgICAgICAgICAgICAgICAgICJGYWlsZWQgdG8gZ2V0IHRoZSBjb3BpZWQgY29tcG9uZW50IGluc3RhbmNlIGluZm9ybWF0aW9uIikpOworICAgICAgICB9CisgICAgfQorCisgICAgQFBPU1QKKyAgICBAUGF0aCgiL3tjb250YWluZXJDb21wb25lbnRUeXBlfS97Y29tcG9uZW50SWR9L2JhdGNoRGVsZXRlUmVzb3VyY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AgICAgICAgQFBhdGhQYXJhbSgiY29udGFpbmVyQ29tcG9uZW50VHlwZSIpIGZpbmFsIFN0cmluZyBjb250YWluZXJDb21wb25lbnRUeXBlLAorICAgICAgICAgICAgQFBhdGhQYXJhbSgiY29tcG9uZW50SWQiKSBmaW5hbCBTdHJpbmcgY29tcG9uZW50SWQsCisgICAgICAgICAgICBAQ29udGV4dCBmaW5hbCBIdHRwU2VydmxldFJlcXVlc3QgcmVxdWVzdCwKKyAgICAgICAgICAgIEBQYXJhbWV0ZXIoZGVzY3JpcHRpb24gPSAiQ29tcG9uZW50IEluc3RhbmNlIElkIExpc3QiLCByZXF1aXJlZCA9IHRydWUpIGZpbmFsIFN0cmluZyBjb21wb25lbnRJbnN0YW5jZUlkTGlzU3RyKSB7CisgICAgICAgIHRyeSB7CisgICAgICAgICAgICBpZiAoY29tcG9uZW50SW5zdGFuY2VJZExpc1N0ciA9PSBudWxsIHx8IGNvbXBvbmVudEluc3RhbmNlSWRMaXNTdHIuaXNFbXB0eSgpKSB7CisgICAgICAgICAgICAgICAgbG9nLmVycm9yKCJFbXB0eSBKU09OIExpc3Qgd2FzIHNlbnQiLGNvbXBvbmVudEluc3RhbmNlSWRMaXNTdHIpOworICAgICAgICAgICAgICAgIHJldHVybiBidWlsZEVycm9yUmVzcG9uc2UoZ2V0Q29tcG9uZW50c1V0aWxzKCkuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLklOVkFMSURfQ09OVEVOVCkpOworICAgICAgICAgICAgfQorCisKKyAgICAgICAgICAgIGlmIChjb21wb25lbnRJbnN0YW5jZUJ1c2luZXNzTG9naWMgPT0gbnVsbCkgeworICAgICAgICAgICAgICAgIGxvZy5lcnJvcigiVW5zdXBwb3J0ZWQgY29tcG9uZW50IHR5cGUge30iLCBjb250YWluZXJDb21wb25lbnRUeXBlKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gYnVpbGRFcnJvclJlc3BvbnNlKGdldENvbXBvbmVudHNVdGl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0uU0VSVklDRV9QQVJBTV9OQU1FLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbXBvbmVudFR5cGVFbnVtLlBST0RVQ1RfUEFSQU1fTkFNRX0pLAorICAgICAgICAgICAgICAgICAgICByZXF1aXJlZCA9IHRydWUpIEBQYXRoUGFyYW0oImNvbnRhaW5lckNvbXBvbmVudFR5cGUiKSBmaW5hbCBTdHJpbmcgY29udGFpbmVyQ29tcG9uZW50VHlwZSwKKyAgICAgICAgICAgIEBQYXJhbWV0ZXIoCisgICAgICAgICAgICAgICAgICAgIGRlc2NyaXB0aW9uID0gInVuaXF1ZSBpZCBvZiB0aGUgY29udGFpbmVyIGNvbXBvbmVudCIpIEBQYXRoUGFyYW0oImNvbXBvbmVudElkIikgZmluYWwgU3RyaW5nIGNvbXBvbmVudElkLAorICAgICAgICAgICAgQEhlYWRlclBhcmFtKHZhbHVlID0gQ29uc3RhbnRzLlVTRVJfSURfSEVBREVSKSBTdHJpbmcgdXNlcklkLAorICAgICAgICAgICAgQFBhcmFtZXRlcihkZXNjcmlwdGlvbiA9ICJSZWxhdGlvbnNoaXBJbmZvIiwgcmVxdWlyZWQgPSB0cnVlKSBTdHJpbmcgZGF0YSwKKyAgICAgICAgICAgIEBDb250ZXh0IGZpbmFsIEh0dHBTZXJ2bGV0UmVxdWVzdCByZXF1ZXN0KSB7CisgICAgICAgIAorCisgICAgICAgIHRyeSB7CisgICAgICAgICAgICBpZiAoZGF0YSA9PSBudWxsIHx8IGRhdGEubGVuZ3RoKCkgPT0gMCkgeworICAgICAgICAgICAgICAgIGxvZy5pbmZvKCJFbXB0eSBKU09OIGxpc3Qgd2FzIHNlbnQiKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gYnVpbGRFcnJvclJlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5JTlZBTElEX0NPTlRFTlQpKTsKKyAgICAgICAgICAgIH0KKworICAgICAg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1MjAgMTAwNjQ0Ci0tLSBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9Db21wb25lbnRTZXJ2bGV0LmphdmEKKysrIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL3NlcnZsZXRzL0NvbXBvbmVudFNlcnZsZXQuamF2YQpAQCAtMSw0NjYgKzEsNDY0IEBACi0vKi0NCi0gKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLSAqIFNEQw0KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7DQotICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLg0KLSAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdA0KLSAqIA0KLSAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wDQotICogDQotICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2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UmVzcG9uc2UoYWN0aW9uUmVzcG9uc2UucmlnaHQoKS52YWx1ZSgpKTsNCi0gICAgICAgICAgICAgICAgcmV0dXJuIHJlc3BvbnNlOw0KLSAgICAgICAgICAgIH0NCi0gICAgICAgICAgICBPYmplY3QgcmVzb3VyY2UgPSBSZXByZXNlbnRhdGlvblV0aWxzLnRvUmVwcmVzZW50YXRpb24oYWN0aW9uUmVzcG9uc2UubGVmdCgpLnZhbHVlKCkpOw0KLSAgICAgICAgICAgIHJldHVybiBidWlsZE9rUmVzcG9uc2UoZ2V0Q29tcG9uZW50c1V0aWxzKCkuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLk9LKSwgcmVzb3VyY2UpOw0KLQ0KLSAgICAgICAgfSBjYXRjaCAoRXhjZXB0aW9uIGUpIHsNCi0gICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nQmVSZXN0QXBpR2VuZXJhbEVycm9yKCJHZXQgRmlsdGVyZWQgQ29tcG9uZW50IEluc3RhbmNlIFByb3BlcnRpZXMiKTsNCi0gICAgICAgICAgICBsb2cuZGVidWcoIkdldHRpbmcgb2YgZmlsdGVyZWQgY29tcG9uZW50IGluc3RhbmNlIHByb3BlcnRpZXMgZmFpbGVkIHdpdGggZXhjZXB0aW9uIiwgZSk7DQotICAgICAgICAgICAgcmV0dXJuIGJ1aWxkRXJyb3JSZXNwb25zZShnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUikpOw0KLQ0KLSAgICAgICAgfQ0KLSAgICB9DQotfQ0KKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAxNyBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKKyAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KKyAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAorICogCisgKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAorICogCisgKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlCisgKiBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0cmlidXRlZCBvbiBhbiAiQVMgSVMiIEJBU0lTLAorICogV0lUSE9VVCBXQVJSQU5USUVTIE9SIENPTkRJVElPTlMgT0YgQU5ZIEtJTkQsIGVpdGhlciBleHByZXNzIG9yIGltcGxpZWQuCisgKiBTZWUgdGhlIExpY2Vuc2UgZm9yIHRoZSBzcGVjaWZpYyBsYW5ndWFnZSBnb3Zlcm5pbmcgcGVybWlzc2lvbnMgYW5kCisgKiBsaW1pdGF0aW9ucyB1bmRlciB0aGUgTGljZW5zZS4KKyAqID09PT09PT09PT09PUxJQ0VOU0VfRU5EPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKi8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wU2VydmxldFJlcXVlc3QgcmVxdWVzdCwKKyAgICAgICAgICAgIEBIZWFkZXJQYXJhbSh2YWx1ZSA9IENvbnN0YW50cy5VU0VSX0lEX0hFQURFUikgU3RyaW5nIHVzZXJJZCkgeworICAgICAgICBSZXNwb25zZSByZXNwb25zZTsKKworICAgICAgICBTdHJpbmcgdXJsID0gcmVxdWVzdC5nZXRNZXRob2QoKSArICIgIiArIHJlcXVlc3QuZ2V0UmVxdWVzdFVSSSgpOworICAgICAgICBsb2cuZGVidWcoU1RBUlRfSEFORExFX1JFUVVFU1RfT0YsIHVybCk7CisKKyAgICAgICAgQ29tcG9uZW50VHlwZUVudW0gY29tcG9uZW50VHlwZUVudW0gPSBDb21wb25lbnRUeXBlRW51bS5maW5kQnlQYXJhbU5hbWUoY29tcG9uZW50VHlwZSk7CisgICAgICAgIGlmIChjb21wb25lbnRUeXBlRW51bSAhPSBudWxsKSB7CisgICAgICAgICAgICBDb21wb25lbnRCdXNpbmVzc0xvZ2ljIGNvbXBCTCA9IGNvbXBvbmVudEJ1c2luZXNzTG9naWNQcm92aWRlci5nZXRJbnN0YW5jZShjb21wb25lbnRUeXBlRW51bSk7CisgICAgICAgICAgICBFaXRoZXI8Qm9vbGVhbiwgUmVzcG9uc2VGb3JtYXQ+IGVpdGhlckNvbmZvcm1hbmNlTGV2ZWwgPSBjb21wQkwudmFsaWRhdGVDb25mb3JtYW5jZUxldmVsKGNvbXBvbmVudFV1aWQsIGNvbXBvbmVudFR5cGVFbnVtLCB1c2VySWQpOworICAgICAgICAgICAgaWYgKGVpdGhlckNvbmZvcm1hbmNlTGV2ZWwuaXNSaWdodCgpKSB7CisgICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBidWlsZEVycm9yUmVzcG9uc2UoZWl0aGVyQ29uZm9ybWFuY2VMZXZlbC5yaWdodCgpLnZhbHVlKCkpOworICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICByZXNwb25zZSA9IGJ1aWxkT2t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ZpbmRCeVBhcmFtTmFtZShjb21wb25lbnRUeXBlKTsKKyAgICAgICAgaWYgKGNvbXBvbmVudFR5cGVFbnVtICE9IG51bGwpIHsKKyAgICAgICAgICAgIHRyeSB7CisgICAgICAgICAgICAgICAgQ29tcG9uZW50QnVzaW5lc3NMb2dpYyBjb21wQkwgPSBjb21wb25lbnRCdXNpbmVzc0xvZ2ljUHJvdmlkZXIuZ2V0SW5zdGFuY2UoY29tcG9uZW50VHlwZUVudW0pOworICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gYnVpbGRPa1Jlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5PSyksCisgICAgICAgICAgICAgICAgICAgICAgICBSZXByZXNlbnRhdGlvblV0aWxzLnRvUmVwcmVzZW50YXRpb24oY29tcEJMLmdldFJlcXVpcmVtZW50c0FuZENhcGFiaWxpdGllcyhjb21wb25lbnRJZCwgY29tcG9uZW50VHlwZUVudW0sIHVzZXJJZCkpKTsKKyAgICAgICAgICAgIH0gY2F0Y2ggKElPRXhjZXB0aW9uIGUpIHsKKyAgICAgICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nQmVSZXN0QXBpR2VuZXJhbEVycm9yKCJHZXQgQ2FwYWJpbGl0aWVzIGFuZCByZXF1aXJlbWVudHMgZm9yICIgKyBjb21wb25lbnRJZCk7CisgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJnZXRSZXF1aXJlbWVudEFuZENhcGFiaWxpdGllcyBmYWlsZWQgd2l0aCBleGNlcHRpb24iLCBlKTsKKyAgICAgICAgICAgICAgICB0aHJvdyBlOworICAgICAgICAgICAgfQorICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgcmVzcG9uc2UgPSBidWlsZEVycm9yUmVzcG9uc2UoZ2V0Q29tcG9uZW50c1V0aWxzKCkuZ2V0UmVzcG9uc2VGb3JtYXQoQWN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vbXBvbmVudFR5cGVFbnVtKTsKKworICAgICAgICAgICAgbG9nLmRlYnVnKCJSZWNlaXZlZCBjb21wb25lbnRVaWRzIHNpemUgaXMge30iLCBjb21wb25lbnRVaWRzID09IG51bGwgPyAwIDogY29tcG9uZW50VWlkcy5zaXplKCkpOworCisgICAgICAgICAgICBFaXRoZXI8TGlzdDxDb21wb25lbnQ+LCBSZXNwb25zZUZvcm1hdD4gYWN0aW9uUmVzcG9uc2UgPSBidXNpbmVzc0xvZ2ljLmdldExhdGVzdFZlcnNpb25Ob3RBYnN0cmFjdENvbXBvbmVudHMoZmFsc2UsIGNvbXBvbmVudFR5cGVFbnVtLCBpbnRlcm5hbENvbXBvbmVudFR5cGUsIGNvbXBvbmVudFVpZHMsIHVzZXJJZCk7CisKKyAgICAgICAgICAgIGlmIChhY3Rpb25SZXNwb25zZS5pc1JpZ2h0KCkpIHsKKyAgICAgICAgICAgICAgICBsb2cuZGVidWcoRkFJTEVEX1RPX0dFVF9BTExfTk9OX0FCU1RSQUNULCBjb21wb25lbnRUeXBlKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gYnVpbGRFcnJvclJlc3BvbnNlKGFjdGlvblJlc3BvbnNlLnJpZ2h0KCkudmFsdWUoKSk7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBPYmplY3QgY29tcG9uZW50cyA9IFJlcHJlc2VudGF0aW9uVXRpbHMudG9SZXByZXNlbnRhdGlvbihhY3Rpb25SZXNwb25zZS5sZWZ0KCkudmFsdWUoKSk7CisgICAgICAgICAgICByZXR1cm4gYnVpbGRPa1Jlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5PSyksIGNvbXBvbmVudHMpOworCisgICAgICAgIH0gY2F0Y2ggKEV4Y2VwdGlvbiBlKSB7CisgICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nQmVSZXN0QXBpR2V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9uZW50VHlwZUVudW0gY29tcG9uZW50VHlwZUVudW0gPSBDb21wb25lbnRUeXBlRW51bS5maW5kQnlQYXJhbU5hbWUoY29tcG9uZW50VHlwZSk7CisgICAgICAgICAgICBDb21wb25lbnRCdXNpbmVzc0xvZ2ljIGJ1c2luZXNzTG9naWMgPSBjb21wb25lbnRCdXNpbmVzc0xvZ2ljUHJvdmlkZXIuZ2V0SW5zdGFuY2UoY29tcG9uZW50VHlwZUVudW0pOworICAgICAgICAgICAgaWYgKGxvZy5pc0RlYnVnRW5hYmxlZCgpKSB7CisgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJSZWNlaXZlZCBjb21wb25lbnRVaWRzIHNpemUgaXMge30iLCBkYXRhID09IG51bGwgPyAwIDogZGF0YS5zaXplKCkpOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICBFaXRoZXI8TGlzdDxDb21wb25lbnQ+LCBSZXNwb25zZUZvcm1hdD4gYWN0aW9uUmVzcG9uc2UgPSBidXNpbmVzc0xvZ2ljLmdldExhdGVzdFZlcnNpb25Ob3RBYnN0cmFjdENvbXBvbmVudHMoZmFsc2UsIGNvbXBvbmVudFR5cGVFbnVtLCBpbnRlcm5hbENvbXBvbmVudFR5cGUsIGRhdGEsIHVzZXJJZCk7CisKKyAgICAgICAgICAgIGlmIChhY3Rpb25SZXNwb25zZS5pc1JpZ2h0KCkpIHsKKyAgICAgICAgICAgICAgICBsb2cuZGVidWcoRkFJTEVEX1RPX0dFVF9BTExfTk9OX0FCU1RSQUNULCBjb21wb25lbnRUeXBlKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gYnVpbGRFcnJvclJlc3BvbnNlKGFjdGlvblJlc3BvbnNlLnJpZ2h0KCkudmFsdWUoKSk7CisKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIE9iamVjdCBjb21wb25lbnRzID0gUmVwcmVzZW50YXRpb25VdGlscy50b1JlcHJlc2VudGF0aW9uKGFjdGlvblJlc3BvbnNlLmxlZnQoKS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0IG9mIHN0cmluZ3MgYW5kIHJldHVybiB0aGUgZGF0YSBvbiB0aGUgY29tcG9uZW50IGFjY29yZGluZyB0byB0byBsaXN0LgorICAgICAqIGZvciBleGFtcGxlOiBsaXN0IG9mIHRoZSBzdHJpbmcgInByb3BlcnRpZXMsIGlucHV0cyIgd2lsbCByZXR1cm4gY29tcG9uZW50IHdpdGggdGhlIGxpc3Qgb2YgcHJvcGVydGllcyBhbmQgaW5wdXRzLgorICAgICAqCisgICAgICogQHBhcmFtIGNvbXBvbmVudFR5cGUKKyAgICAgKiBAcGFyYW0gY29tcG9uZW50SWQKKyAgICAgKiBAcGFyYW0gZGF0YVBhcmFtc1RvUmV0dXJuCisgICAgICogQHBhcmFtIHJlcXVlc3QKKyAgICAgKiBAcGFyYW0gdXNlcklkCisgICAgICogQHJldHVybgorICAgICAqLworCisKKyAgICBAR0VUCisgICAgQFBhdGgoIi97Y29tcG9uZW50VHlwZX0ve2NvbXBvbmVudElkfS9maWx0ZXJlZERhdGFCeVBhcmFtcyIpCisgICAgQENvbnN1bWVzKE1lZGlhVHlwZS5BUFBMSUNBVElPTl9KU09OKQorICAgIEBQcm9kdWNlcyhNZWRpYVR5cGUuQVBQTElDQVRJT05fSlNPTikKKyAgICBAT3BlcmF0aW9uKGRlc2NyaXB0aW9uID0gIlJldHJpZXZlIFJlc291cmNlIiwgbWV0aG9kID0gIkdFVCIsIHN1bW1hcnkgPSAiUmV0dXJucyByZXNvdXJjZSBhY2NvcmRpbmcgdG8gcmVzb3VyY2VJZCIsCisgICAgICAgICAgICByZXNwb25zZXMgPSBAQXBpUmVzcG9uc2UoCisgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQgPSBAQ29udGVudChhcnJheSA9IEBBcnJheVNjaGVtYShzY2hlbWEgPSBAU2NoZW1hKGltcGxlbWVudGF0aW9uID0gUmVzb3VyY2UuY2xhc3MpKSkpKQorICAgIEBSZXNwb25zZVZpZXcobWl4aW4gPSB7R3JvdXBDb21wb3NpdGlv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XVlc3QuZ2V0UmVxdWVzdFVSSSgpOworICAgICAgICBsb2cuZGVidWcoU1RBUlRfSEFORExFX1JFUVVFU1RfT0YgLCB1cmwpOworCisgICAgICAgIC8vIGdldCBtb2RpZmllciBpZAorICAgICAgICBVc2VyIG1vZGlmaWVyID0gbmV3IFVzZXIoKTsKKyAgICAgICAgbW9kaWZpZXIuc2V0VXNlcklkKHVzZXJJZCk7CisgICAgICAgIGxvZy5kZWJ1ZygibW9kaWZpZXIgaWQgaXMge30iICwgdXNlcklkKTsKKworICAgICAgICB0cnkgeworICAgICAgICAgICAgU3RyaW5nIHJlc291cmNlSWRMb3dlciA9IGNvbXBvbmVudElkLnRvTG93ZXJDYXNlKCk7CisgICAgICAgICAgICBDb21wb25lbnRUeXBlRW51bSBjb21wb25lbnRUeXBlRW51bSA9IENvbXBvbmVudFR5cGVFbnVtLmZpbmRCeVBhcmFtTmFtZShjb21wb25lbnRUeXBlKTsKKyAgICAgICAgICAgIENvbXBvbmVudEJ1c2luZXNzTG9naWMgYnVzaW5lc3NMb2dpYyA9IGNvbXBvbmVudEJ1c2luZXNzTG9naWNQcm92aWRlci5nZXRJbnN0YW5jZShjb21wb25lbnRUeXBlRW51bSk7CisKKyAgICAgICAgICAgIGxvZy50cmFjZSgiZ2V0IGNvbXBvbmVudCB3aXRoIGlkIHt9IGZpbHRlcmVkIGJ5IHVpIHBhcmFtcyIsIGNvbXBvbmVudElkKTsKKyAgICAgICAgICAgIEVpdGhlcjxVaUNvbXBvbmVudERhdGFUcmFuc2ZlciwgUmVzcG9uc2VGb3JtYXQ+IGFjdGlvblJlc3BvbnNlID0gYnVzaW5lc3NMb2dpYy5nZXRDb21wb25lbnREYXRhRmlsdGVyZWRCeVBhcmFtcyhyZXNvdXJjZUlkTG93ZXIsIG1vZGlmaWVyLCBkYXRhUGFyYW1zVG9SZXR1cm4pOworCisgICAgICAgICAgICBpZiAoYWN0aW9uUmVzcG9uc2UuaXNSaWdodCgpKSB7CisgICAgICAgICAg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vbXBvbmVudFR5cGUiKSBmaW5hbCBTdHJpbmcgY29tcG9uZW50VHlwZSwKKyAgICAgICAgICAgIEBQYXRoUGFyYW0oImNvbXBvbmVudElkIikgZmluYWwgU3RyaW5nIGNvbXBvbmVudElkLAorICAgICAgICAgICAgQFBhdGhQYXJhbSgicHJvcGVydHlOYW1lRnJhZ21lbnQiKSBmaW5hbCBTdHJpbmcgcHJvcGVydHlOYW1lRnJhZ21lbnQsCisgICAgICAgICAgICBAUXVlcnlQYXJhbSgicmVzb3VyY2VUeXBlIikgTGlzdDxTdHJpbmc+IHJlc291cmNlVHlwZXMsCisgICAgICAgICAgICBAQ29udGV4dCBmaW5hbCBIdHRwU2VydmxldFJlcXVlc3QgcmVxdWVzdCwKKyAgICAgICAgICAgIEBIZWFkZXJQYXJhbSh2YWx1ZSA9IENvbnN0YW50cy5VU0VSX0lEX0hFQURFUikgU3RyaW5nIHVzZXJJZCkgdGhyb3dzIElPRXhjZXB0aW9uIHsKKworICAgICAgICBVc2VyIHVzZXIgPSBuZXcgVXNlcigpOworICAgICAgICB1c2VyLnNldFVzZXJJZCh1c2VySWQpOworICAgICAgICBsb2cuZGVidWcoIlVzZXIgSWQgaXMge30iICwgdXNlcklkKTsKKyAgICAgICAgUmVzcG9uc2UgcmVzcG9uc2U7CisgICAgICAgIHRyeSB7CisgICAgICAgICAgICBDb21wb25lbnRUeXBlRW51bSBjb21wb25lbnRUeXBlRW51bSA9IENvbXBvbmVudFR5cGVFbnVtLmZpbmRCeVBhcmFtTmFtZShjb21wb25lbnRUeXBlKTsKKyAgICAgICAgICAgIENvbXBvbmVudEJ1c2luZXNzTG9naWMgYnVzaW5lc3NMb2dpYyA9IGNvbXBvbmVudEJ1c2luZXNzTG9naWNQcm92aWRlci5nZXRJbnN0YW5jZShjb21wb25lbnRUeXBlRW51bSk7CisgICAgICAgICAgICBNYXA8RmlsdGVyS2V5RW51bSwgTGlzdDxTdHJpbmc+PiBmaWx0ZXJzID0gbmV3IEVudW1NY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G51bGw7CmRpZmYgLS1naXQgYS9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvQ29uc3VtZXJTZXJ2bGV0LmphdmEgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvQ29uc3VtZXJTZXJ2bGV0LmphdmEKaW5kZXggMmVjYmFiNy4uNDRiMjJhNSAxMDA2NDQKLS0tIGEvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL3NlcnZsZXRzL0NvbnN1bWVyU2VydmxldC5qYXZhCisrKyBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9Db25zdW1lclNlcnZsZXQuamF2YQpAQCAtMSwyMzMgKzEsMjM1IEBACi0vKi0NCi0gKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLSAqIFNEQw0KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7DQotICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRo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B9IGNhdGNoIChFeGNlcHRpb24gZSkgew0KLSAgICAgICAgICAgIC8vIElOVkFMSUQgSlNPTg0KLSAgICAgICAgICAgIEJlRWNvbXBFcnJvck1hbmFnZXIuZ2V0SW5zdGFuY2UoKS5sb2dCZUludmFsaWRKc29uSW5wdXQoImNvbnZlcnRKc29uVG9PYmplY3QiKTsNCi0gICAgICAgICAgICBsb2cuZGVidWcoImZhaWxlZCB0byBjb252ZXJ0IGZyb20ganNvbiB7fSIsIGRhdGEsIGUpOw0KLSAgICAgICAgICAgIFJlc3BvbnNlRm9ybWF0IHJlc3BvbnNlRm9ybWF0ID0gZ2V0Q29tcG9uZW50c1V0aWxzKCkuZ2V0SW52YWxpZENvbnRlbnRFcnJvckZvckNvbnN1bWVyQW5kQXVkaXQodXNlciwgbnVsbCwgYWN0aW9uRW51bSk7DQotICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChyZXNwb25zZUZvcm1hdCk7DQotICAgICAgICB9DQotICAgICAgICByZXR1cm4gRWl0aGVyLmxlZnQoY29uc3VtZXIpOw0KLSAgICB9DQotDQotfQ0KKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAxNyBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsK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TdHJpbmcgdXJsID0gcmVxdWVzdC5nZXRNZXRob2QoKSArICIgIiArIHJlcXVlc3QuZ2V0UmVxdWVzdFVSSSgpOworICAgICAgICBsb2cuZGVidWcoU1RBUlRfSEFORExFX1JFUVVFU1RfT0YsIHVybCk7CisKKyAgICAgICAgVXNlciBtb2RpZmllciA9IG5ldyBVc2VyKCk7CisgICAgICAgIG1vZGlmaWVyLnNldFVzZXJJZCh1c2VySWQpOworICAgICAgICBsb2cuZGVidWcoTU9ESUZJRVJfSURfSVMsIHVzZXJJZCk7CisKKyAgICAgICAgUmVzcG9uc2UgcmVzcG9uc2UgPSBudWxsOworICAgICAgICB0cnkgeworICAgICAgICAgICAgRWl0aGVyPENvbnN1bWVyRGVmaW5pdGlvbiwgUmVzcG9uc2VGb3JtYXQ+IGFjdGlvblJlc3BvbnNlID0gYnVzaW5lc3NMb2dpYy5nZXRDb25zdW1lcihjb25zdW1lcklkLCBtb2RpZmllcik7CisKKyAgICAgICAgICAgIGlmIChhY3Rpb25SZXNwb25zZS5pc1JpZ2h0KCkpIHsKKyAgICAgICAgICAgICAgICBsb2cuZGVidWcoImZhaWxlZCB0byBnZXQgY29uc3VtZXIiKTsKKyAgICAgICAgICAgICAgICByZXNwb25zZSA9IGJ1aWxkRXJyb3JSZXNwb25zZShhY3Rpb25SZXNwb25zZS5yaWdodCgpLnZhbHVlKCkpOworICAgICAgICAgICAgICAgIHJldHVybiByZXNwb25zZTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIHJldHVybiBidWlsZE9rUmVzcG9uc2UoZ2V0Q29tcG9uZW50c1V0aWxzKCkuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLk9LKSwgYWN0aW9uUmVzcG9uc2UubGVmdCgpLnZhbHVlKCkpOworCisgICAgICAgIH0gY2F0Y2ggKEV4Y2VwdGlvbiBlKSB7CisgICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9n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PSBuZXcgR3NvbigpOworICAgICAgICB0cnkgeworICAgICAgICAgICAgbG9nLnRyYWNlKCJjb252ZXJ0IGpzb24gdG8gb2JqZWN0LiBqc29uPVxuIHt9IiwgZGF0YSk7CisgICAgICAgICAgICBjb25zdW1lciA9IGdzb24uZnJvbUpzb24oZGF0YSwgQ29uc3VtZXJEZWZpbml0aW9uLmNsYXNzKTsKKyAgICAgICAgICAgIGlmIChjb25zdW1lciA9PSBudWxsKSB7CisgICAgICAgICAgICAgICAgQmVFY29tcEVycm9yTWFuYWdlci5nZXRJbnN0YW5jZSgpLmxvZ0JlSW52YWxpZEpzb25JbnB1dCgiY29udmVydEpzb25Ub09iamVjdCIpOworICAgICAgICAgICAgICAgIGxvZy5kZWJ1Zygib2JqZWN0IGlzIG51bGwgYWZ0ZXIgY29udmVydGluZyBmcm9tIGpzb24iKTsKKyAgICAgICAgICAgICAgICBSZXNwb25zZUZvcm1hdCByZXNwb25zZUZvcm1hdCA9IGdldENvbXBvbmVudHNVdGlscygpLmdldEludmFsaWRDb250ZW50RXJyb3JGb3JDb25zdW1lckFuZEF1ZGl0KHVzZXIsIG51bGwsIGFjdGlvbkVudW0pOworICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQocmVzcG9uc2VGb3JtYXQpOworICAgICAgICAgICAgfQorICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZSkgeworICAgICAgICAgICAgLy8gSU5WQUxJRCBKU09OCisgICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nQmVJbnZhbGlkSnNvbklucHV0KCJjb252ZXJ0SnNvblRvT2JqZWN0Iik7CisgICAgICAgICAgICBsb2cuZGVidWcoImZhaWxlZCB0byBjb252ZXJ0IGZyb20ganNvbiB7fSIsIGRhdGEsIGUpOworICAgICAgICAgICAgUmVzcG9uc2VGb3JtYXQgcmVzcG9uc2VGb3JtYXQgPSBnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRJbnZhbGlkQ29udGVudEVycm9yRm9yQ29uc3VtZXJBbmRBdWRpdCh1c2VyLCBudWxsLCBhY3Rpb25FbnVtKTsKKyAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQocmVzcG9uc2VGb3JtYXQpOworICAgICAgICB9CisgICAgICAgIHJldHVybiBFaXRoZXIubGVmdChjb25zdW1lcik7CisgICAgfQorCit9CmRpZmYgLS1naXQgYS9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvQ3NhckJ1aWxkU2VydmxldC5qYXZhIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL3NlcnZsZXRzL0NzYXJCdWlsZFNlcnZsZXQuamF2YQpkZWxldGVkIGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggOGM1YTIyNC4uMDAwMDAwMAotLS0gYS9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvQ3NhckJ1aWxkU2VydmxldC5qYXZhCisrKyAvZGV2L251bGwKQEAgLTEsMTIzICswLDAgQEAKLS8qLQotICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIFNEQwotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIENvcHlyaWdodCAoQykgMjAxNyBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBMaWNlbnNlZCB1bmRlciB0aGUgQX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ICJ4LXNoIjsKLSAgICAgICAgfSBlbHNlIGlmIChmaWxlTmFtZS5jb250YWlucygiLnlhbmciKSkgewotICAgICAgICAgICAgbWltZVR5cGUgPSAieWFuZyI7Ci0gICAgICAgIH0KLQotICAgICAgICBlbHNlIGlmIChmaWxlTmFtZS5jb250YWlucygiLnJhciIpKSB7Ci0gICAgICAgICAgICBtaW1lVHlwZSA9ICJ4LXJhci1jb21wcmVzc2VkIjsKLSAgICAgICAgfQotCi0gICAgICAgIGVsc2UgaWYgKGZpbGVOYW1lLmNvbnRhaW5zKCIuemlwIikpIHsKLSAgICAgICAgICAgIG1pbWVUeXBlID0gInppcCI7Ci0gICAgICAgIH0KLQotICAgICAgICBlbHNlIGlmIChmaWxlTmFtZS5jb250YWlucygiLnRhciIpKSB7Ci0gICAgICAgICAgICBtaW1lVHlwZSA9ICJ4LXRhciI7Ci0gICAgICAgIH0KLQotICAgICAgICBlbHNlIGlmIChmaWxlTmFtZS5jb250YWlucygiLjd6IikpIHsKLSAgICAgICAgICAgIG1pbWVUeXBlID0gIngtN3otY29tcHJlc3NlZCI7Ci0gICAgICAgIH0KLQotICAgICAgICBlbHNlIHsKLSAgICAgICAgICAgIC8vIFVuZGVmaW5lZAotICAgICAgICAgICAgbWltZVR5cGUgPSAidW5kZWZpbmVkIjsKLSAgICAgICAgfQotICAgICAgICByZXR1cm4gbWltZVR5cGU7Ci0gICAgfQotCi0gICAgcHJvdGVjdGVkIFN0cmluZyBnZXRBcnRpZmFjdFBhdGgoU3RyaW5nIG5vZGVUYW1wbGF0ZU5hbWUsIEVTQXJ0aWZhY3REYXRhIGFydGlmYWN0RGF0YSkgewotICAgICAgICByZXR1cm4gIlNjcmlwdHMvIiArIG5vZGVUYW1wbGF0ZU5hbWUgKyAiLyIgKyBhcnRpZmFjdERhdGEuZ2V0SWQoKTsKLSAgICB9Ci0KLSAgICBwcm90ZWN0ZWQgU3RyaW5nIGdldFJlc291cmNlUGF0aChTdHJpbmcgcmVzb3VyY2VOYW1lKSB7Ci0gICAgICAgIHJldHVybiAiRGVmaW5pdGlvbnMvIiArIHJlc291cmNlTmFtZSArICIueWFtbCI7Ci0gICAgfQotCi0gICAgQE92ZXJyaWRlCi0gICAgcHVibGljIExvZ2dlciBnZXRMb2dnZXIoKSB7Ci0gICAgICAgIHJldHVybiBsb2c7Ci0gICAgfQotCi19CmRpZmYgLS1naXQgYS9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvRGlzdHJpYnV0aW9uU2VydmljZVNlcnZsZXQuamF2YSBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9EaXN0cmlidXRpb25TZXJ2aWNlU2VydmxldC5qYXZhCmluZGV4IGZjNmMyOGMuLmE1YTI3NjggMTAwNjQ0Ci0tLSBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9EaXN0cmlidXRpb25TZXJ2aWNlU2VydmxldC5qYXZhCisrKyBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9EaXN0cmlidXRpb25TZXJ2aWNlU2VydmxldC5qYXZhCkBAIC0xLDE2OSArMSwxNjggQEAKLS8qLQ0KLSAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogU0RDDQotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NCi0gKiBDb3B5cmlnaHQgKEMpIDIwMTcgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQotICogPT09PT09P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AgcmVzcG9uc2UgPSBidWlsZE9rUmVzcG9uc2UocmVzcG9uc2VGb3JtYXQsIGFjdGlvblJlc3BvbnNlLmxlZnQoKS52YWx1ZSgpKTsNCi0NCi0gICAgICAgICAgICB9DQotDQotICAgICAgICAgICAgcmV0dXJuIHJlc3BvbnNlOw0KLQ0KLSAgICAgICAgfSBjYXRjaCAoRXhjZXB0aW9uIGUpIHsNCi0gICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nQmVSZXN0QXBpR2VuZXJhbEVycm9yKCJHZXQgRGlzdHJpYnV0aW9uIFN0YXR1cyIpOw0KLSAgICAgICAgICAgIGxvZy5kZWJ1ZygiZmFpbGVkIHRvIGdldCBkaXN0cmlidXRpb24gc3RhdHVzICIsIGUpOw0KLSAgICAgICAgICAgIHJlc3BvbnNlRm9ybWF0ID0gZ2V0Q29tcG9uZW50c1V0aWxzKCkuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLkdFTkVSQUxfRVJST1IpOw0KLQ0KLSAgICAgICAgICAgIHJlc3BvbnNlID0gYnVpbGRFcnJvclJlc3BvbnNlKHJlc3BvbnNlRm9ybWF0KTsNCi0gICAgICAgICAgICByZXR1cm4gcmVzcG9uc2U7DQotICAgICAgICB9DQotDQotICAgIH0NCi0NCi19DQorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09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7CisKKyAgICAgICAgfSBjYXRjaCAoRXhjZXB0aW9uIGUpIHsKKyAgICAgICAgICAgIEJlRWNvbXBFcnJvck1hbmFnZXIuZ2V0SW5zdGFuY2UoKS5sb2dCZVJlc3RBcGlHZW5lcmFsRXJyb3IoIkdldCBEaXN0cmlidXRpb24gU3RhdHVzIik7CisgICAgICAgICAgICBsb2cuZGVidWcoImZhaWxlZCB0byBnZXQgZGlzdHJpYnV0aW9uIHN0YXR1cyAiLCBlKTsKKyAgICAgICAgICAgIHRocm93IGU7CisgICAgICAgIH0KKworICAgIH0KKworfQpkaWZmIC0tZ2l0IGEvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL3NlcnZsZXRzL0VsZW1lbnRTZXJ2bGV0LmphdmEgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvRWxlbWVudFNlcnZsZXQuamF2YQppbmRleCAwYzgxYWQzLi40MjQ1ZmM4IDEwMDY0NAotLS0gYS9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvRWxlbWVudFNlcnZsZXQuamF2YQorKysgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvRWxlbWVudFNlcnZsZXQuamF2YQpAQCAtMSw3MzUgKzEsNzgwIEBACi0vKi0NCi0gKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLSAqIFNEQw0KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWF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5qZWN0DQotICAgIHB1YmxpYyBFbGVtZW50U2VydmxldChVc2VyQnVzaW5lc3NMb2dpYyB1c2VyQnVzaW5lc3NMb2dpYywNCi0gICAgICAgIENvbXBvbmVudHNVdGlscyBjb21wb25lbnRzVXRpbHMsDQotICAgICAgICBDb21wb25lbnRzQ2xlYW5CdXNpbmVzc0xvZ2ljIGNvbXBvbmVudHNDbGVhbkJ1c2luZXNzTG9naWMsDQotICAgICAgICBFbGVtZW50QnVzaW5lc3NMb2dpYyBlbGVtZW50QnVzaW5lc3NMb2dpYykgew0KLSAgICAgICAgc3VwZXIodXNlckJ1c2luZXNzTG9naWMsIGNvbXBvbmVudHNVdGlscyk7DQotICAgICAgICB0aGlzLmNvbXBvbmVudHNDbGVhbkJ1c2luZXNzTG9naWMgPSBjb21wb25lbnRzQ2xlYW5CdXNpbmVzc0xvZ2ljOw0KLSAgICAgICAgdGhpcy5lbGVtZW50QnVzaW5lc3NMb2dpYyA9IGVsZW1lbnRCdXNpbmVzc0xvZ2ljOw0KLSAgICAgICAgdGhpcy51c2VyQnVzaW5lc3NMb2dpYyA9IHVzZXJCdXNpbmVzc0xvZ2ljOw0KLSAgICB9DQotDQotICAgIC8qDQotICAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioNCi0gICAgICogTkVXIENBVEVHT1JJRVMgY2F0ZWdvcnkgLyBcIHN1YmNhdGVnb3J5IHN1YmNhdGVnb3J5IC8gZ3JvdXBpbmcNCi0gICAgICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8NCi0NCi0gICAgLyoNCi0gICAgICoNCi0gICAgICoNCi0gICAgICogQ0FURUdPUklFUw0KLSAgICAgKi8NCi0gICAgLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8v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ZXBsb3ltZW50IiwgZGVwbG95bWVudEVpdGhlci5sZWZ0KCkudmFsdWUoKSk7DQotICAgICAgICAgICAgICAgIGNvbmZpZ3VyYXRpb24ucHV0KCJhcnRpZmFjdHMiLCBhcnRpZmFjdHMpOw0KLSAgICAgICAgICAgICAgICBjb25maWd1cmF0aW9uLnB1dCgiZGVmYXVsdEhlYXRUaW1lb3V0IiwgZGVmYXVsdEhlYXRUaW1lb3V0LmxlZnQoKS52YWx1ZSgpKTsNCi0gICAgICAgICAgICAgICAgY29uZmlndXJhdGlvbi5wdXQoImNvbXBvbmVudFR5cGVzIiwgZWxlbWVudEJ1c2luZXNzTG9naWMuZ2V0QWxsQ29tcG9uZW50VHlwZXNQYXJhbU5hbWVzKCkpOw0KLSAgICAgICAgICAgICAgICBjb25maWd1cmF0aW9uLnB1dCgicm9sZXMiLCBlbGVtZW50QnVzaW5lc3NMb2dpYy5nZXRBbGxTdXBwb3J0ZWRSb2xlcygpKTsNCi0gICAgICAgICAgICAgICAgY29uZmlndXJhdGlvbi5wdXQoInJlc291cmNlVHlwZXMiLCByZXNvdXJjZVR5cGVzTWFwLmxlZnQoKS52YWx1ZSgpKTsNCi0gICAgICAgICAgICAgICAgY29uZmlndXJhdGlvbi5wdXQoImVudmlyb25tZW50Q29udGV4dCIsDQotICAgICAgICAgICAgICAgICAgICAgICAgQ29uZmlndXJhdGlvbk1hbmFnZXIuZ2V0Q29uZmlndXJhdGlvbk1hbmFnZXIoKS5nZXRDb25maWd1cmF0aW9uKCkuZ2V0RW52aXJvbm1lbnRDb250ZXh0KCkpOw0KLSAgICAgICAgICAgICAgICBjb25maWd1cmF0aW9uLnB1dCgiZ2FiIiwNCi0gICAgICAgICAgICAgICAgICAgICAgICBDb25maWd1cmF0aW9uTWFuYWdlci5nZXRDb25maWd1cmF0aW9uTWFuYWdlcigpLmdldENvbmZpZ3VyYXRpb24oKS5nZXRHYWJDb25maWcoKSk7DQotDQotICAgICAgICAgICAgICAgIHJldHVybiBidWl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1dfV0iKTsNCi0gICAgfQ0KLQ0KLX0NCisvKi0KKyAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBTREMKKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBDb3B5cmlnaHQgKEMpIDIwMTcgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7CisgKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCisgKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKKyAqIAorICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKKyAqIAorICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZQorICogZGlzdHJpYnV0ZWQgdW5kZXIgdGhlIExpY2Vuc2UgaXMgZGlzdHJpYnV0ZWQgb24gYW4gIkFTIElTIiBCQVNJUywKKyAqIFdJVEhPVVQgV0FSUkFOVElFUyBPUiBDT05ESVRJT05TIE9GIEFOWSBLSU5ELCBlaXRoZXIgZXhwcmVzcyBvciBpbXBsaWVkLgorICogU2VlIHRoZSBMaWNlbnNlIGZvciB0aGUgc3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Q2xlYW5CdXNpbmVzc0xvZ2ljID0gY29tcG9uZW50c0NsZWFuQnVzaW5lc3NMb2dpYzsKKyAgICAgICAgdGhpcy5lbGVtZW50QnVzaW5lc3NMb2dpYyA9IGVsZW1lbnRCdXNpbmVzc0xvZ2ljOworICAgICAgICB0aGlzLnVzZXJCdXNpbmVzc0xvZ2ljID0gdXNlckJ1c2luZXNzTG9naWM7CisgICAgfQorCisgICAgLyoKKyAgICAgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgICAgICogTkVXIENBVEVHT1JJRVMgY2F0ZWdvcnkgLyBcIHN1YmNhdGVnb3J5IHN1YmNhdGVnb3J5IC8gZ3JvdXBpbmcKKyAgICAgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCisgICAgLyoKKyAgICAgKgorICAgICAqCisgICAgICogQ0FURUdPUklFUworICAgICAqLworICAgIC8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vCisgICAgLy8gcmV0cmlldmUgYWxsIGNvbXBvbmVudCBjYXRlZ29yaWVzCisgICAgQEdFVAorICAgIEBQYXRoKCIvY2F0ZWdvcmllcy97Y29tcG9uZW50VHlwZX0iKQorICAgIEBDb25zdW1lcyhNZWRpYVR5cGUuQVBQTElDQVRJT05fSlNPTikKKyAgICBAUHJvZHVjZXMoTWVkaWFUeXBlLkFQUExJQ0FUSU9OX0pTT04pCisgICAgQE9wZXJhdGlvbihkZXNjcmlwdGlvbiA9ICJSZXRyaWV2ZSB0aGUgbGlzdCBvZiBhbGwgcmVzb3VyY2Uvc2VydmljZS9wcm9kdWN0IGNhdGVnb3JpZ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BDb25maWd1cmF0aW9uTWFuYWdlci5nZXRDb25maWd1cmF0aW9uTWFuYWdlcigpLmdldENvbmZpZ3VyYXRpb24oKS5nZXRIZWF0QXJ0aWZhY3REZXBsb3ltZW50VGltZW91dCgpLmdldERlZmF1bHRNaW51dGVzKCk7CisgICAgICAgICAgICAgICAgQXJ0aWZhY3RUeXBlc0luZm8gdHlwZXNSZXNwb25zZSA9IG5ldyBBcnRpZmFjdFR5cGVzSW5mbygpOworICAgICAgICAgICAgICAgIHR5cGVzUmVzcG9uc2Uuc2V0QXJ0aWZhY3RUeXBlcyhlaXRoZXIubGVmdCgpLnZhbHVlKCkpOworICAgICAgICAgICAgICAgIHR5cGVzUmVzcG9uc2Uuc2V0SGVhdERlZmF1bHRUaW1lb3V0KGRlZmF1bHRIZWF0VGltZW91dCk7CisKKyAgICAgICAgICAgICAgICByZXR1cm4gYnVpbGRPa1Jlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5PSyksIHR5cGVzUmVzcG9uc2UpOworICAgICAgICAgICAgfQorICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZSkgeworICAgICAgICAgICAgQmVFY29tcEVycm9yTWFuYWdlci5nZXRJbnN0YW5jZSgpLmxvZ0JlUmVzdEFwaUdlbmVyYWxFcnJvcigiR2V0IEFydGlmYWN0IFR5cGVzIik7CisgICAgICAgICAgICBsb2cuZGVidWcoImdldEFydGlmYWN0VHlwZXMgZmFpbGVkIHdpdGggZXhjZXB0aW9uIiwgZSk7CisgICAgICAgICAgICB0aHJvdyBlOworICAgICAgICB9CisgICAgfQorCisKKyAgICAvLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLworICAgIC8vIHJldHJpZXZlIGFsbCBmb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V0aG9kKCkgKyAiICIgKyByZXF1ZXN0LmdldFJlcXVlc3RVUkkoKTsKKyAgICAgICAgbG9nLmRlYnVnKFNUQVJUX0hBTkRMRV9SRVFVRVNUX09GLCB1cmwpOworCisgICAgICAgIC8vIGdldCBtb2RpZmllciBpZAorICAgICAgICBTdHJpbmcgdXNlcklkID0gcmVxdWVzdC5nZXRIZWFkZXIoQ29uc3RhbnRzLlVTRVJfSURfSEVBREVSKTsKKyAgICAgICAgVXNlciBtb2RpZmllciA9IG5ldyBVc2VyKCk7CisgICAgICAgIG1vZGlmaWVyLnNldFVzZXJJZCh1c2VySWQpOworICAgICAgICBsb2cuZGVidWcoIm1vZGlmaWVyIGlkIGlzIHt9IiwgdXNlcklkKTsKKworICAgICAgICBSZXNwb25zZSByZXNwb25zZSA9IG51bGw7CisKKyAgICAgICAgTm9kZVR5cGVFbnVtIG5vZGVUeXBlID0gTm9kZVR5cGVFbnVtLmdldEJ5TmFtZUlnbm9yZUNhc2UoY29tcG9uZW50VHlwZSk7CisgICAgICAgIGlmIChub2RlVHlwZSA9PSBudWxsKSB7CisgICAgICAgICAgICBsb2cuaW5mbygiY29tcG9uZW50VHlwZSBpcyBub3QgdmFsaWQ6IHt9IiwgY29tcG9uZW50VHlwZSk7CisgICAgICAgICAgICByZXR1cm4gYnVpbGRFcnJvclJlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5JTlZBTElEX0NPTlRFTlQpKTsKKyAgICAgICAgfQorCisgICAgICAgIExpc3Q8Tm9kZVR5cGVFbnVtPiBjb21wb25lbnRzTGlzdCA9IG5ldyBBcnJheUxpc3Q8PigpOworICAgICAgICBjb21wb25lbnRzTGlzdC5hZGQobm9kZVR5cGUpOworICAgICAgICB0cnkgeworICAgICAgICAgICAgTWFwPE5vZGVUeXBlRW51bSwgRWl0aGVyPExpc3Q8U3RyaW5nPiwgUmVzcG9uc2VGb3JtYXQ+PiBjb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b25TdGF0dXM+IG90aGVyRWl0aGVyID0gZWxlbWVudEJMLmdldEFsbEFydGlmYWN0VHlwZXModXNlcklkKTsKKworICAgICAgICBNYXA8U3RyaW5nLCBPYmplY3Q+IGNvbmZpZ3VyYXRpb24gPSBuZXcgSGFzaE1hcDw+KCk7CisKKyAgICAgICAgaWYgKG90aGVyRWl0aGVyLmlzUmlnaHQoKSB8fCBvdGhlckVpdGhlci5sZWZ0KCkudmFsdWUoKSA9PSBudWxsKSB7CisgICAgICAgICAgICBsb2cuZGVidWcoIk5vIG90aGVyIGFydGlmYWN0IHR5cGVzIHdlcmUgZm91bmQiKTsKKyAgICAgICAgICAgIHJldHVybiBjb25maWd1cmF0aW9uOworICAgICAgICB9CisgICAgICAgIGlmIChkZXBsb3ltZW50RWl0aGVyLmlzUmlnaHQoKSB8fCBkZXBsb3ltZW50RWl0aGVyLmxlZnQoKS52YWx1ZSgpID09IG51bGwpIHsKKyAgICAgICAgICAgIGxvZy5kZWJ1ZygiTm8gZGVwbG95bWVudCBhcnRpZmFjdCB0eXBlcyB3ZXJlIGZvdW5kIik7CisgICAgICAgICAgICByZXR1cm4gY29uZmlndXJhdGlvbjsKKyAgICAgICAgfQorICAgICAgICBpZiAoZGVmYXVsdEhlYXRUaW1lb3V0LmlzUmlnaHQoKSB8fCBkZWZhdWx0SGVhdFRpbWVvdXQubGVmdCgpLnZhbHVlKCkgPT0gbnVsbCkgeworICAgICAgICAgICAgbG9nLmRlYnVnKCJoZWF0IGRlZmF1bHQgdGltZW91dCB3YXMgbm90IGZvdW5kIik7CisgICAgICAgICAgICByZXR1cm4gY29uZmlndXJhdGlvbjsKKyAgICAgICAgfQorICAgICAgICBpZiAocmVzb3VyY2VUeXBlc01hcC5pc1JpZ2h0KCkgfHwgcmVzb3VyY2VUeXBlc01hcC5sZWZ0KCkudmFsdWUoKSA9PSBudWxsKSB7CisgICAgICAgICAgICBsb2cuZGVidWcoIk5vIHJlc291cmNlIHR5cGVzIHdlcmUgZm91bm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W5hZ2VyKCkuZ2V0Q29uZmlndXJhdGlvbigpLmdldEdhYkNvbmZpZygpKTsKKworICAgICAgICByZXR1cm4gY29uZmlndXJhdGlvbjsKKyAgICB9CisKKworfQpkaWZmIC0tZ2l0IGEvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL3NlcnZsZXRzL0V4Y2VwdGlvbkhhbmRsZXJFbmRwb2ludC5qYXZhIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL3NlcnZsZXRzL0V4Y2VwdGlvbkhhbmRsZXJFbmRwb2ludC5qYXZhCm5ldyBmaWxlIG1vZGUgMTAwNjQ0CmluZGV4IDAwMDAwMDAuLjBhODdjZGQKLS0tIC9kZXYvbnVsbAorKysgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvRXhjZXB0aW9uSGFuZGxlckVuZHBvaW50LmphdmEKQEAgLTAsMCArMSw2OSBAQAorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDIwIEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heS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Z2l0IGEvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL3NlcnZsZXRzL0dlbmVyaWNBcnRpZmFjdEJyb3dzZXJTZXJ2bGV0LmphdmEgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvR2VuZXJpY0FydGlmYWN0QnJvd3NlclNlcnZsZXQuamF2YQppbmRleCA1ODAzNjJjLi4wNDViNTA2IDEwMDY0NAotLS0gYS9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvR2VuZXJpY0FydGlmYWN0QnJvd3NlclNlcnZsZXQuamF2YQorKysgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvR2VuZXJpY0FydGlmYWN0QnJvd3NlclNlcnZsZXQuamF2YQpAQCAtMSwxMTIgKzEsMTEwIEBACi0vKi0NCi0gKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLSAqIFNEQw0KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogQ29weXJpZ2h0IChDKSAyMDE5IE5va2lhIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLSAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOw0KLSAqIHlvdSB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5IHByZXBhcmVHYWJRdWVyeShHZW5lcmljQXJ0aWZhY3RRdWVyeUluZm8gcXVlcnksDQotICAgICAgICBFaXRoZXI8SW1tdXRhYmxlUGFpcjxTdHJpbmcsIGJ5dGVbXT4sIFJlc3BvbnNlRm9ybWF0PiBpbW11dGFibGVQYWlyUmVzcG9uc2VGb3JtYXRFaXRoZXIpIHsNCi0gICAgICAgIGJ5dGVbXSBjb250ZW50ID0gaW1tdXRhYmxlUGFpclJlc3BvbnNlRm9ybWF0RWl0aGVyLmxlZnQoKS52YWx1ZSgpLmdldFJpZ2h0KCk7DQotICAgICAgICBTZXQ8U3RyaW5nPiBxdWVyeUZpZWxkcyA9IHF1ZXJ5LmdldEZpZWxkcygpLnN0cmVhbSgpLm1hcChFU0FQSS5lbmNvZGVyKCk6OmNhbm9uaWNhbGl6ZSkuY29sbGVjdChDb2xsZWN0b3JzLnRvU2V0KCkpOw0KLSAgICAgICAgcmV0dXJuIG5ldyBHQUJRdWVyeShxdWVyeUZpZWxkcywgbmV3IFN0cmluZyhjb250ZW50KSwgR0FCUXVlcnlUeXBlLkNPTlRFTlQpOw0KLSAgICB9DQotfQ0KKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAxOSBOb2tpYSBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDI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2xsZWN0b3JzLnRvU2V0KCkpOworICAgICAgICByZXR1cm4gbmV3IEdBQlF1ZXJ5KHF1ZXJ5RmllbGRzLCBuZXcgU3RyaW5nKGNvbnRlbnQpLCBHQUJRdWVyeVR5cGUuQ09OVEVOVCk7CisgICAgfQorCit9CmRpZmYgLS1naXQgYS9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvR3JvdXBFbmRwb2ludC5qYXZhIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL3NlcnZsZXRzL0dyb3VwRW5kcG9pbnQuamF2YQppbmRleCAzODdmYWFlLi5kZDU2YjQ3IDEwMDY0NAotLS0gYS9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvR3JvdXBFbmRwb2ludC5qYXZhCisrKyBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9Hcm91cEVuZHBvaW50LmphdmEKQEAgLTEsMTIwICsxLDEzNiBAQAotLyotDQotICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NCi0gKiBTREMNCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLSAqIENvcHlyaWdodCAoQykgMjAxOSBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLSAqIExpY2Vuc2VkIHVuZGVyIH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pYy51cGRhdGVQcm9wZXJ0aWVzKGNvbXBvbmVudElkLCBjb21wb25lbnRUeXBlRW51bSwgdXNlcklkLCBncm91cFVuaXF1ZUlkLCBwcm9wZXJ0aWVzKTsNCi0gICAgfQ0KLQ0KLX0NCisvKi0KKyAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBTREMKKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBDb3B5cmlnaHQgKEMpIDIwMTkgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7CisgKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCisgKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKKyAqIAorICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKKyAqIAorICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZQorICogZGlzdHJpYnV0ZWQgdW5kZXIgdGhlIExpY2Vuc2UgaXMgZGlzdHJpYnV0ZWQgb24gYW4gIkFTIElTIiBCQVNJUywKKyAqIFdJVEhPVVQgV0FSUkFOVElFUyBPUi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9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvR3JvdXBTZXJ2bGV0LmphdmEgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvR3JvdXBTZXJ2bGV0LmphdmEKaW5kZXggYmJjNDFmMi4uM2VhZjkzNyAxMDA2NDQKLS0tIGEvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL3NlcnZsZXRzL0dyb3VwU2VydmxldC5qYXZhCisrKyBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9Hcm91cFNlcnZsZXQuamF2YQpAQCAtMSwyNDcgKzEsMjU2IEBACi0vKi0NCi0gKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLSAqIFNEQw0KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7DQotICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLg0KLSAqIFlvdSBtYXkgb2J0YWluIGEgY29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pb25SZXNwb25zZSA9DQotICAgICAgICAgICAgICAgICAgICBncm91cEJMLmdldEdyb3VwV2l0aEFydGlmYWN0c0J5SWQoY29tcG9uZW50VHlwZUVudW0sIGNvbXBvbmVudElkLCBncm91cElkLCB1c2VySWQsIGZhbHNlKTsNCi0NCi0gICAgICAgICAgICBpZiAoYWN0aW9uUmVzcG9uc2UuaXNSaWdodCgpKSB7DQotICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiZmFpbGVkIHRvIGdldCBhbGwgbm9uIGFic3RyYWN0IHt9IiwgY29udGFpbmVyQ29tcG9uZW50VHlwZSk7DQotICAgICAgICAgICAgICAgIHJldHVybiBidWlsZEVycm9yUmVzcG9uc2UoYWN0aW9uUmVzcG9uc2UucmlnaHQoKS52YWx1ZSgpKTsNCi0gICAgICAgICAgICB9DQotDQotICAgICAgICAgICAgcmV0dXJuIGJ1aWxkT2tSZXNwb25zZShnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuT0spLA0KLSAgICAgICAgICAgICAgICAgICAgYWN0aW9uUmVzcG9uc2UubGVmdCgpLnZhbHVlKCkpOw0KLQ0KLSAgICAgICAgfSBjYXRjaCAoRXhjZXB0aW9uIGUpIHsNCi0gICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nQmVSZXN0QXBpR2VuZXJhbEVycm9yKCJnZXRHcm91cEFydGlmYWN0QnlJZCIpOw0KLSAgICAgICAgICAgIGxvZy5kZWJ1ZygiZ2V0R3JvdXBBcnRpZmFjdEJ5SWQgdW5leHBlY3RlZCBleGNlcHRpb24iLCBlKTsNCi0gICAgICAgICAgICByZXR1cm4gYnVpbGRFcnJvclJlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5HRU5FUkFMX0VSUk9SKSk7DQotICAgICAgICB9DQotDQotICAgI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DQotICAgICAgICAgICAgICAgIHJldHVybiByZXNwb25zZTsNCi0gICAgICAgICAgICB9DQotDQotICAgICAgICAgICAgR3JvdXBEZWZpbml0aW9uIGdyb3VwID0gYWN0aW9uUmVzcG9uc2UubGVmdCgpLnZhbHVlKCk7DQotICAgICAgICAgICAgT2JqZWN0IHJlc3VsdCA9IFJlcHJlc2VudGF0aW9uVXRpbHMudG9SZXByZXNlbnRhdGlvbihncm91cCk7DQotICAgICAgICAgICAgcmV0dXJuIGJ1aWxkT2tSZXNwb25zZShnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuT0spLCByZXN1bHQpOw0KLQ0KLSAgICAgICAgfSBjYXRjaCAoRXhjZXB0aW9uIGUpIHsNCi0gICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nQmVSZXN0QXBpR2VuZXJhbEVycm9yKCJVcGRhdGUgR3JvdXAgTWV0YWRhdGEiKTsNCi0gICAgICAgICAgICBsb2cuZGVidWcoInVwZGF0ZSBncm91cCBtZXRhZGF0YSBmYWlsZWQgd2l0aCBleGNlcHRpb24iLCBlKTsNCi0gICAgICAgICAgICByZXNwb25zZSA9IGJ1aWxkRXJyb3JSZXNwb25zZShnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUikpOw0KLSAgICAgICAgICAgIHJldHVybiByZXNwb25zZTsNCi0NCi0gICAgICAgIH0NCi0gICAgfQ0KLQ0KLX0NCisvKi0KKyAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBTREMKKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09C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b21wb25lbnRJZCwgQFBhdGhQYXJhbSgiZ3JvdXBJZCIpIGZpbmFsIFN0cmluZyBncm91cElkLAorICAgICAgICAgICAgQENvbnRleHQgZmluYWwgSHR0cFNlcnZsZXRSZXF1ZXN0IHJlcXVlc3QsIEBIZWFkZXJQYXJhbSh2YWx1ZSA9IENvbnN0YW50cy5VU0VSX0lEX0hFQURFUikgU3RyaW5nIHVzZXJJZCkgeworICAgICAgICBTdHJpbmcgdXJsID0gcmVxdWVzdC5nZXRNZXRob2QoKSArICIgIiArIHJlcXVlc3QuZ2V0UmVxdWVzdFVSSSgpOworICAgICAgICBsb2cuZGVidWcoIihnZXQpIFN0YXJ0IGhhbmRsZSByZXF1ZXN0IG9mIHt9IiwgdXJsKTsKKworICAgICAgICB0cnkgeworCisgICAgICAgICAgICBDb21wb25lbnRUeXBlRW51bSBjb21wb25lbnRUeXBlRW51bSA9IENvbXBvbmVudFR5cGVFbnVtLmZpbmRCeVBhcmFtTmFtZShjb250YWluZXJDb21wb25lbnRUeXBlKTsKKyAgICAgICAgICAgIEVpdGhlcjxHcm91cERlZmluaXRpb25JbmZvLCBSZXNwb25zZUZvcm1hdD4gYWN0aW9uUmVzcG9uc2UgPQorICAgICAgICAgICAgICAgICAgICBncm91cEJMLmdldEdyb3VwV2l0aEFydGlmYWN0c0J5SWQoY29tcG9uZW50VHlwZUVudW0sIGNvbXBvbmVudElkLCBncm91cElkLCB1c2VySWQsIGZhbHNlKTsKKworICAgICAgICAgICAgaWYgKGFjdGlvblJlc3BvbnNlLmlzUmlnaHQoKSkgeworICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiZmFpbGVkIHRvIGdldCBhbGwgbm9uIGFic3RyYWN0IHt9IiwgY29udGFpbmVyQ29tcG9uZW50VHlwZSk7CisgICAgICAgICAgICAgICAgcmV0dXJuIGJ1aWxkRXJyb3JSZXNwb25zZShhY3Rpb25SZXNwb25zZS5yaWdodCgpLnZhbHVlKCkpOworICAgICAgICAgICAgfQorCisg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JfSURfSEVBREVSKSBTdHJpbmcgdXNlcklkKSB0aHJvd3MgSU9FeGNlcHRpb24geworCisgICAgICAgIFN0cmluZyB1cmwgPSByZXF1ZXN0LmdldE1ldGhvZCgpICsgIiAiICsgcmVxdWVzdC5nZXRSZXF1ZXN0VVJJKCk7CisgICAgICAgIGxvZy5kZWJ1ZyhTVEFSVF9IQU5ETEVfUkVRVUVTVCwgdXJsKTsKKworICAgICAgICBVc2VyIHVzZXIgPSBuZXcgVXNlcigpOworICAgICAgICB1c2VyLnNldFVzZXJJZCh1c2VySWQpOworICAgICAgICBsb2cuZGVidWcoIm1vZGlmaWVyIGlkIGlzIHt9IiwgdXNlcklkKTsKKworICAgICAgICBSZXNwb25zZSByZXNwb25zZSA9IG51bGw7CisKKyAgICAgICAgdHJ5IHsKKyAgICAgICAgICAgIEVpdGhlcjxHcm91cERlZmluaXRpb24sIFJlc3BvbnNlRm9ybWF0PiBjb252ZXJ0UmVzcG9uc2UgPSBwYXJzZVRvT2JqZWN0KGRhdGEsICgpIC0+IEdyb3VwRGVmaW5pdGlvbi5jbGFzcyk7CisgICAgICAgICAgICBpZiAoY29udmVydFJlc3BvbnNlLmlzUmlnaHQoKSkgeworICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiZmFpbGVkIHRvIHBhcnNlIGdyb3VwIik7CisgICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBidWlsZEVycm9yUmVzcG9uc2UoY29udmVydFJlc3BvbnNlLnJpZ2h0KCkudmFsdWUoKSk7CisgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3BvbnNlOworICAgICAgICAgICAgfQorICAgICAgICAgICAgR3JvdXBEZWZpbml0aW9uIHVwZGF0ZWRHcm91cCA9IGNvbnZlcnRSZXNwb25zZS5sZWZ0KCkudmFsdWUoKTsKKworICAgICAgICAgICAgLy8gVXBkYXRlIEdyb3VwRGVmaW5pdGlvbgorICAgICAgICAgICAgQ29tcG9uZW50VHlwZUVudW0gY29tcG9uZW50VHlwZUVudW0gPSBDb21wb25lbnRUeXBlRW51bS5maW5kQnlQYXJhbU5hbWUoY29udGFpbmVyQ29tcG9uZW50VHlwZSk7CisgICAgICAgICAgICBFaXRoZXI8R3JvdXBEZWZpbml0aW9uLCBSZXNwb25zZUZvcm1hdD4gYWN0aW9uUmVzcG9uc2UgPSBncm91cEJMCisgICAgICAgICAgICAgICAgICAgIC52YWxpZGF0ZUFuZFVwZGF0ZUdyb3VwTWV0YWRhdGEoY29tcG9uZW50SWQsIHVzZXIsIGNvbXBvbmVudFR5cGVFbnVtLCB1cGRhdGVkR3JvdXAsIHRydWUgLHRydWUpOworCisgICAgICAgICAgICBpZiAoYWN0aW9uUmVzcG9uc2UuaXNSaWdodCgpKSB7CisgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJmYWlsZWQgdG8gdXBkYXRlIEdyb3VwRGVmaW5pdGlvbiIpOworICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gYnVpbGRFcnJvclJlc3BvbnNlKGFjdGlvblJlc3BvbnNlLnJpZ2h0KCkudmFsdWUoKSk7CisgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3BvbnNlOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICBHcm91cERlZmluaXRpb24gZ3JvdXAgPSBhY3Rpb25SZXNwb25zZS5sZWZ0KCkudmFsdWUoKTsKKyAgICAgICAgICAgIE9iamVjdCByZXN1bHQgPSBSZXByZXNlbnRhdGlvblV0aWxzLnRvUmVwcmVzZW50YXRpb24oZ3JvdXApOworICAgICAgICAgICAgcmV0dXJuIGJ1aWxkT2tSZXNwb25zZShnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuT0spLCByZXN1bHQpOworCisgICAgICAgIH0gY2F0Y2ggKEV4Y2VwdGlvbiBlKSB7CisgICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nQmVSZXN0QXBpR2VuZXJhbEVycm9yKCJVcGRhdGUgR3JvdXAgTWV0YWRhdGEiKTsKKyAgICAgICAgICAgIGxvZy5kZWJ1ZygidXBkYXRlIGdyb3VwIG1ldGFkYXRhIGZhaWxlZCB3aXRoIGV4Y2VwdGlvbiIsIGUpOworICAgICAgICAgICAgdGhyb3cgZTsKKyAgICAgICAgfQorICAgIH0KKworfQpkaWZmIC0tZ2l0IGEvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL3NlcnZsZXRzL0dyb3VwVHlwZXNFbmRwb2ludC5qYXZhIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL3NlcnZsZXRzL0dyb3VwVHlwZXNFbmRwb2ludC5qYXZhCmluZGV4IDc5YTgyMDguLjczNzNjNTggMTAwNjQ0Ci0tLSBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9Hcm91cFR5cGVzRW5kcG9pbnQuamF2YQorKysgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvR3JvdXBUeXBlc0VuZHBvaW50LmphdmEKQEAgLTEsNzkgKzEsODcgQEAKLS8qLQ0KLSAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogU0RDDQotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NCi0gKiBDb3B5cmlnaHQgKEMpIDIwMTkgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09P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SA9IENvbnN0YW50cy5VU0VSX0lEX0hFQURFUikgU3RyaW5nIHVzZXJJZCwNCi0gICAgICAgICAgICBAUGFyYW1ldGVyKA0KLSAgICAgICAgICAgICAgICAgICAgZGVzY3JpcHRpb24gPSAiQW4gb3B0aW9uYWwgcGFyYW1ldGVyIHRvIGluZGljYXRlIHRoZSB0eXBlIG9mIHRoZSBjb250YWluZXIgZnJvbSB3aGVyZSB0aGlzIGNhbGwgaXMgZXhlY3V0ZWQiKSBAUXVlcnlQYXJhbSgiaW50ZXJuYWxDb21wb25lbnRUeXBlIikgU3RyaW5nIGludGVybmFsQ29tcG9uZW50VHlwZSkgew0KLSAgICAgICAgcmV0dXJuIGdyb3VwVHlwZUJ1c2luZXNzTG9naWMuZ2V0QWxsR3JvdXBUeXBlcyh1c2VySWQsIGludGVybmFsQ29tcG9uZW50VHlwZSk7DQotICAgIH0NCi0NCi19DQorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDE5IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgorICogWW91IG1heSBvYnRhaW4gYSB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QuamF2YQorKysgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvSW5wdXRzU2VydmxldC5qYXZhCkBAIC0xLDU4MCArMSw1NzQgQEAKLS8qLQ0KLSAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogU0RDDQotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NCi0gKiBDb3B5cmlnaHQgKEMpIDIwMTcgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NCi0gKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsNCi0gKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuDQotICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0DQotICogDQotICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjANCi0gKiANCi0gKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlDQotICogZGlzdHJpYnV0ZWQgdW5kZXIgdGhlIExpY2Vuc2UgaXMgZGlzdHJpYnV0ZWQgb24gYW4gIkFTIElTIiBCQVNJUywNCi0gKiBXSVRIT1VUIFd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QotICAgICAgICAgICAgICAgICAgICBwYXJzZVRvQ29tcG9uZW50SW5zdExpc3RJbnB1dChjb21wb25lbnRJbnN0SW5wdXRzTWFwT2JqLCBtb2RpZmllcik7DQotICAgICAgICAgICAgaWYgKGNvbXBvbmVudEluc3RJbnB1dHNNYXBSZXMuaXNSaWdodCgpKSB7DQotICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiZmFpbGVkIHRvIHBhcnNlIGNvbXBvbmVudEluc3RJbnB1dHNNYXAiKTsNCi0gICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBidWlsZEVycm9yUmVzcG9uc2UoY29tcG9uZW50SW5zdElucHV0c01hcFJlcy5yaWdodCgpLnZhbHVlKCkpOw0KLSAgICAgICAgICAgICAgICByZXR1cm4gcmVzcG9uc2U7DQotICAgICAgICAgICAgfQ0KLQ0KLSAgICAgICAgICAgIENvbXBvbmVudFR5cGVFbnVtIGNvbXBvbmVudFR5cGVFbnVtID0gQ29tcG9uZW50VHlwZUVudW0uZmluZEJ5UGFyYW1OYW1lKGNvbXBvbmVudFR5cGUpOw0KLSAgICAgICAgICAgIENvbXBvbmVudEluc3RMaXN0SW5wdXQgY29tcG9uZW50SW5zdElucHV0c01hcCA9IGNvbXBvbmVudEluc3RJbnB1dHNNYXBSZXMubGVmdCgpLnZhbHVlKCk7DQotICAgICAgICAgICAgaWYgKGxvZy5pc0RlYnVnRW5hYmxlZCgpKSB7DQotICAgICAgICAgICAgICAgIC8vIGZvciBpbnNwZWN0aW9uIG9uIGRlYnVnDQotICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygicGFyc2VkIGNvbXBvbmVudEluc3RJbnB1dHNNYXA9e30iLA0KLSAgICAgICAgICAgICAgICAgICAgICAgIFJlZmxlY3Rpb25Ub1N0cmluZ0J1aWxkZXIudG9TdHJpbmcoY29tcG9uZW50SW5zdElucHV0c01hcCkpOw0KLSAgICAgICAgICAgIH0NCi0NCi0gICAgICAgICAgICBFaXRoZXI8TGlzdDxJb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ZSBkYXRhIHR5cGUgZm9yIHNlcnZpY2UgKyAiICsgY29tcG9uZW50SWQgKyAiICsgd2l0aCBuYW1lOiAiICsgZGF0YVR5cGVOYW1lKTsNCi0gICAgICAgICAgICBsb2cuZGVidWcoIkRlbGV0ZSBkYXRhIHR5cGUgZmFpbGVkIHdpdGggZXhjZXB0aW9uIiwgZSk7DQotICAgICAgICAgICAgcmVzcG9uc2UgPSBidWlsZEVycm9yUmVzcG9uc2UoY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5HRU5FUkFMX0VSUk9SKSk7DQotICAgICAgICAgICAgcmV0dXJuIHJlc3BvbnNlOw0KLSAgICAgICAgfQ0KLSAgICB9DQotfQ0KKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAxNyBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKKyAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KKyAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAorICogCisgKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm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ICAgIENvbXBvbmVudFR5cGVFbnVtIGNvbXBvbmVudFR5cGUgPSBDb21wb25lbnRUeXBlRW51bS5maW5kQnlQYXJhbU5hbWUoY29udGFpbmVyQ29tcG9uZW50VHlwZSk7CisKKyAgICAgICAgICAgIGlmIChidXNpbmVzc0xvZ2ljID09IG51bGwpIHsKKyAgICAgICAgICAgICAgICBsb2cuZGVidWcoIlVuc3VwcG9ydGVkIGNvbXBvbmVudCB0eXBlIHt9IiwgY29udGFpbmVyQ29tcG9uZW50VHlwZSk7CisgICAgICAgICAgICAgICAgcmV0dXJuIGJ1aWxkRXJyb3JSZXNwb25zZShnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuVU5TVVBQT1JURURfRVJST1IpKTsKKyAgICAgICAgICAgIH0KKworICAgICAgICAgICAgRWl0aGVyPExpc3Q8SW5wdXREZWZpbml0aW9uPiwgUmVzcG9uc2VGb3JtYXQ+IGFjdGlvblJlc3BvbnNlID0gaW5wdXRzQnVzaW5lc3NMb2dpYy51cGRhdGVJbnB1dHNWYWx1ZShjb21wb25lbnRUeXBlLCBjb21wb25lbnRJZCwgaW5wdXRzVG9VcGRhdGUsIHVzZXJJZCwgdHJ1ZSwgZmFsc2UpOworCisgICAgICAgICAgICBpZiAoYWN0aW9uUmVzcG9uc2UuaXNSaWdodCgpKSB7CisgICAgICAgICAgICAgICAgcmV0dXJuIGJ1aWxkRXJyb3JSZXNwb25zZShhY3Rpb25SZXNwb25zZS5yaWdodCgpLnZhbHVlKCkpOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICBMaXN0PElucHV0RGVmaW5pdGlvbj4gY29tcG9uZW50SW5wdXRzID0gYWN0aW9uUmVzcG9uc2UubGVmdCgpLnZhbHVlKCk7CisgICAgICAgICAgICBPYmplY3RNYXBwZXIgbWFwcGVyID0gbmV3IE9iamVjdE1hcHBlcigpOworICAgICAgICAgICAgU3RyaW5nIHJlc3VsdCA9IG1h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5kUHJvcGVydGllc0ZvckNvbXBvbmVudElucHV0KEBQYXRoUGFyYW0oImNvbXBvbmVudFR5cGUiKSBmaW5hbCBTdHJpbmcgY29tcG9uZW50VHlwZSwKKyAgICAgICAgICAgIEBQYXRoUGFyYW0oImNvbXBvbmVudElkIikgZmluYWwgU3RyaW5nIGNvbXBvbmVudElkLCBAUGF0aFBhcmFtKCJpbnB1dElkIikgZmluYWwgU3RyaW5nIGlucHV0SWQsCisgICAgICAgICAgICBAQ29udGV4dCBmaW5hbCBIdHRwU2VydmxldFJlcXVlc3QgcmVxdWVzdCwgQEhlYWRlclBhcmFtKHZhbHVlID0gQ29uc3RhbnRzLlVTRVJfSURfSEVBREVSKSBTdHJpbmcgdXNlcklkKSB0aHJvd3MgSU9FeGNlcHRpb24geworCisgICAgICAgIFNlcnZsZXRDb250ZXh0IGNvbnRleHQgPSByZXF1ZXN0LmdldFNlc3Npb24oKS5nZXRTZXJ2bGV0Q29udGV4dCgpOworICAgICAgICBTdHJpbmcgdXJsID0gcmVxdWVzdC5nZXRNZXRob2QoKSArICIgIiArIHJlcXVlc3QuZ2V0UmVxdWVzdFVSSSgpOworICAgICAgICBsb2cuZGVidWcoU1RBUlRfSEFORExFX1JFUVVFU1RfT0YsIHVybCk7CisgICAgICAgIFJlc3BvbnNlIHJlc3BvbnNlOworCisgICAgICAgIHRyeSB7CisgICAgICAgICAgICBFaXRoZXI8SW5wdXREZWZpbml0aW9uLCBSZXNwb25zZUZvcm1hdD4gaW5wdXRzUmVzID0KKyAgICAgICAgICAgICAgICAgICAgaW5wdXRzQnVzaW5lc3NMb2dpYy5nZXRJbnB1dHNBbmRQcm9wZXJ0aWVzRm9yQ29tcG9uZW50SW5wdXQodXNlcklkLCBjb21wb25lbnRJZCwgaW5wdXRJZCwgZmFsc2UpOworCisgICAgICAgICAgICBpZiAoaW5wdXRzUmVzLmlzUmlnaHQoKSkgeworICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiZmFpbGVkIHRvIGd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ICAgICAgQFBhcmFtZXRlcihkZXNjcmlwdGlvbiA9ICJDb21wb25lbnRJbnMgSW5wdXRzIE9iamVjdCB0byBiZSBjcmVhdGVkIiwKKyAgICAgICAgICAgICAgICAgICAgcmVxdWlyZWQgPSB0cnVlKSBTdHJpbmcgY29tcG9uZW50SW5zdElucHV0c01hcE9iaikgeworCisgICAgICAgIFNlcnZsZXRDb250ZXh0IGNvbnRleHQgPSByZXF1ZXN0LmdldFNlc3Npb24oKS5nZXRTZXJ2bGV0Q29udGV4dCgpOworICAgICAgICBTdHJpbmcgdXJsID0gcmVxdWVzdC5nZXRNZXRob2QoKSArICIgIiArIHJlcXVlc3QuZ2V0UmVxdWVzdFVSSSgpOworICAgICAgICBsb2cuZGVidWcoIiNjcmVhdGVMaXN0SW5wdXQ6IFN0YXJ0IGhhbmRsZSByZXF1ZXN0IG9mIHt9IiwgdXJsKTsKKyAgICAgICAgUmVzcG9uc2UgcmVzcG9uc2UgPSBudWxsOworCisgICAgICAgIHRyeSB7CisgICAgICAgICAgICAvLyBnZXQgbW9kaWZpZXIgaWQKKyAgICAgICAgICAgIFVzZXIgbW9kaWZpZXIgPSBuZXcgVXNlcigpOworICAgICAgICAgICAgbW9kaWZpZXIuc2V0VXNlcklkKHVzZXJJZCk7CisgICAgICAgICAgICBsb2cuZGVidWcoIm1vZGlmaWVyIGlkIGlzIHt9IiwgdXNlcklkKTsKKworICAgICAgICAgICAgRWl0aGVyPENvbXBvbmVudEluc3RMaXN0SW5wdXQsIFJlc3BvbnNlRm9ybWF0PiBjb21wb25lbnRJbnN0SW5wdXRzTWFwUmVzID0KKyAgICAgICAgICAgICAgICBwYXJzZVRvQ29tcG9uZW50SW5zdExpc3RJbnB1dChjb21wb25lbnRJbnN0SW5wdXRzTWFwT2JqLCBtb2RpZmllcik7CisgICAgICAgICAgICBpZiAoY29tcG9uZW50SW5zdElucHV0c01hcFJlcy5pc1JpZ2h0KCkpIHsKKyAgICAgICAgICAgICAgICBsb2cuZGVidWcoImZhaWxlZCB0byBwYXJzZSBjb21wb25lbnRJbnN0SW5wdXRzTWFwIik7CisgICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBidWlsZEVycm9yUmVzcG9uc2UoY29tcG9uZW50SW5zdElucHV0c01hcFJlcy5yaWdodCgpLnZhbHVlKCkpOworICAgICAgICAgICAgICAgIHJldHVybiByZXNwb25zZTsKKyAgICAgICAgICAgIH0KKworICAgICAgICAgICAgQ29tcG9uZW50VHlwZUVudW0gY29tcG9uZW50VHlwZUVudW0gPSBDb21wb25lbnRUeXBlRW51bS5maW5kQnlQYXJhbU5hbWUoY29tcG9uZW50VHlwZSk7CisgICAgICAgICAgICBDb21wb25lbnRJbnN0TGlzdElucHV0IGNvbXBvbmVudEluc3RJbnB1dHNNYXAgPSBjb21wb25lbnRJbnN0SW5wdXRzTWFwUmVzLmxlZnQoKS52YWx1ZSgpOworICAgICAgICAgICAgaWYgKGxvZy5pc0RlYnVnRW5hYmxlZCgpKSB7CisgICAgICAgICAgICAgICAgLy8gZm9yIGluc3BlY3Rpb24gb24gZGVidWcKKyAgICAgICAgICAgICAgICBsb2cuZGVidWcoInBhcnNlZCBjb21wb25lbnRJbnN0SW5wdXRzTWFwPXt9IiwKKyAgICAgICAgICAgICAgICAgICAgICAgIFJlZmxlY3Rpb25Ub1N0cmluZ0J1aWxkZXIudG9TdHJpbmcoY29tcG9uZW50SW5zdElucHV0c01hcCkpOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICBFaXRoZXI8TGlzdDxJbnB1dERlZmluaXRpb24+LCBSZXNwb25zZUZvcm1hdD4gaW5wdXRQcm9wZXJ0aWVzUmVzID0gaW5wdXRzQnVzaW5lc3NMb2dpYworICAgICAgICAgICAgICAgICAgICAuY3JlYXRlTGlzdElucHV0KHVzZXJJZCwgY29tcG9uZW50SWQsIGNvbXBvbmVudFR5cGVFbnVtLCBjb21wb25lbnRJbnN0SW5wdXRzTWFwLCB0cnVlLCBmYWxzZSk7CisgICAgICAgICAgICB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PTVBMRVRFLCJFbmRlZCBkZWxldGUgSW5wdXRzIGZvciBjb21wb25lbnQge30gIixjb21wb25lbnRJZCArICIgYnkgIiArICB1c2VySWQgKTsKKyAgICAgICAgICAgIHJldHVybiBidWlsZE9rUmVzcG9uc2UoZ2V0Q29tcG9uZW50c1V0aWxzKCkuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLk9LKSwgZGVsZXRlSW5wdXQpOworICAgICAgICB9IGNhdGNoIChDb21wb25lbnRFeGNlcHRpb24gZSl7CisgICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nQmVSZXN0QXBpR2VuZXJhbEVycm9yKCJEZWxldGUgaW5wdXQgZm9yIHNlcnZpY2UgKyAiICsgY29tcG9uZW50SWQgKyAiICsgd2l0aCBpZDogIiArIGlucHV0SWQpOworICAgICAgICAgICAgbG9nLmRlYnVnKCJEZWxldGUgaW5wdXQgZmFpbGVkIHdpdGggZXhjZXB0aW9uIiwgZSk7CisgICAgICAgICAgICB0aHJvdyBlOworICAgICAgICB9CisgICAgfQorCisgICAgLyoqCisgICAgICogR2V0cyBhIHNwZWNpZmljIGRhdGEgdHlwZSBhc3NvY2lhdGVkIHdpdGggYSBjb21wb25lbnQuCisgICAgICogQHBhcmFtIGNvbXBvbmVudFR5cGUgdGhlIGNvbnRhaW5lciB0eXBlIChzZXJ2aWNlLCByZXNvdXJjZSwgLi4uKQorICAgICAqIEBwYXJhbSBjb21wb25lbnRJZCB0aGUgY29udGFpbmVyIElECisgICAgICogQHBhcmFtIGRhdGFUeXBlTmFtZSB0aGUgZGF0YSB0eXBlIG5hbWUKKyAgICAgKiBAcGFyYW0gcmVxdWVzdCBIdHRwU2VydmxldFJlcXVlc3Qgb2JqZWN0CisgICAgICogQHJldHVybiB0aGUgZGF0YSB0eXBlIGluZm8KKyAgICAgKi8KKyAgICBAR0VUCisgICAgQFBhdGgoIi97Y29tcG9uZW50VHlwZX0ve2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b25lbnRJZCwKKyAgICAgICAgICAgIEBQYXRoUGFyYW0oImRhdGFUeXBlTmFtZSIpIGZpbmFsIFN0cmluZyBkYXRhVHlwZU5hbWUsCisgICAgICAgICAgICBAQ29udGV4dCBmaW5hbCBIdHRwU2VydmxldFJlcXVlc3QgcmVxdWVzdAorICAgICkgeworICAgICAgICBTdHJpbmcgdXJsID0gcmVxdWVzdC5nZXRNZXRob2QoKSArICIgIiArIHJlcXVlc3QuZ2V0UmVxdWVzdFVSSSgpOworICAgICAgICBsb2cuZGVidWcoIihnZXREYXRhVHlwZSkgU3RhcnQgaGFuZGxlIHJlcXVlc3Qgb2Yge30iLCB1cmwpOworICAgICAgICBSZXNwb25zZSByZXNwb25zZTsKKworICAgICAgICB0cnkgeworICAgICAgICAgICAgRWl0aGVyPERhdGFUeXBlRGVmaW5pdGlvbiwgU3RvcmFnZU9wZXJhdGlvblN0YXR1cz4gZ2V0UmVzdWx0ID0gYnVzaW5lc3NMb2dpYy5nZXRQcml2YXRlRGF0YVR5cGUoY29tcG9uZW50SWQsIGRhdGFUeXBlTmFtZSk7CisgICAgICAgICAgICBpZiAoZ2V0UmVzdWx0LmlzUmlnaHQoKSkgeworICAgICAgICAgICAgICAgIEFjdGlvblN0YXR1cyBhY3Rpb25TdGF0dXMgPSBjb21wb25lbnRzVXRpbHMuY29udmVydEZyb21TdG9yYWdlUmVzcG9uc2UoZ2V0UmVzdWx0LnJpZ2h0KCkudmFsdWUoKSk7CisgICAgICAgICAgICAgICAgcmV0dXJuIGJ1aWxkRXJyb3JSZXNwb25zZShjb21wb25lbnRzVXRpbHMuZ2V0UmVzcG9uc2VGb3JtYXQoYWN0aW9uU3RhdHVzKSk7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBPYmplY3QganNvbiA9IFJlcHJlc2VudGF0aW9uVXRpbHMudG9SZXByZXNlbnRhdGlvbihnZXRSZXN1bHQubGVmdCgpLnZhbHVlKCkpOworICAgICAgICAgICAgcmV0dXJuIGJ1aWxkT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dHRwU2VydmxldFJlcXVlc3QgcmVxdWVzdAorICAgICkgeworICAgICAgICBTZXJ2bGV0Q29udGV4dCBjb250ZXh0ID0gcmVxdWVzdC5nZXRTZXNzaW9uKCkuZ2V0U2VydmxldENvbnRleHQoKTsKKyAgICAgICAgQ29tcG9uZW50c1V0aWxzIGNvbXBvbmVudHNVdGlscyA9IGdldENvbXBvbmVudHNVdGlscygpOworICAgICAgICBTdHJpbmcgdXJsID0gcmVxdWVzdC5nZXRNZXRob2QoKSArICIgIiArIHJlcXVlc3QuZ2V0UmVxdWVzdFVSSSgpOworICAgICAgICBsb2cuZGVidWcoIihnZXREYXRhVHlwZSkgU3RhcnQgaGFuZGxlIHJlcXVlc3Qgb2Yge30iLCB1cmwpOworICAgICAgICBSZXNwb25zZSByZXNwb25zZTsKKworICAgICAgICB0cnkgeworICAgICAgICAgICAgRWl0aGVyPExpc3Q8RGF0YVR5cGVEZWZpbml0aW9uPiwgU3RvcmFnZU9wZXJhdGlvblN0YXR1cz4gZ2V0UmVzdWx0ID0gYnVzaW5lc3NMb2dpYy5nZXRQcml2YXRlRGF0YVR5cGVzKGNvbXBvbmVudElkKTsKKyAgICAgICAgICAgIGlmIChnZXRSZXN1bHQuaXNSaWdodCgpKSB7CisgICAgICAgICAgICAgICAgQWN0aW9uU3RhdHVzIGFjdGlvblN0YXR1cyA9IGNvbXBvbmVudHNVdGlscy5jb252ZXJ0RnJvbVN0b3JhZ2VSZXNwb25zZShnZXRSZXN1bHQucmlnaHQoKS52YWx1ZSgpKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gYnVpbGRFcnJvclJlc3BvbnNlKGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChhY3Rpb25TdGF0dXMpKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIE9iamVjdCBqc29uID0gUmVwcmVzZW50YXRpb25VdGlscy50b1JlcHJlc2VudGF0aW9uKGdldFJlc3VsdC5sZWZ0KCkudmFsdWUoKS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Ci0gICAgICAgICAgICBpZiAoaXNVcGRhdGUpIHsNCi0gICAgICAgICAgICAgICAgYWN0aW9uUmVzcG9uc2UgPQ0KLSAgICAgICAgICAgICAgICAgICAgaW50ZXJmYWNlT3BlcmF0aW9uQnVzaW5lc3NMb2dpYw0KLSAgICAgICAgICAgICAgICAgICAgICAgIC51cGRhdGVJbnRlcmZhY2VPcGVyYXRpb24oY29tcG9uZW50SWRMb3dlciwgbWFwcGVkSW50ZXJmYWNlRGF0YSwgbW9kaWZpZXIsIHRydWUpOw0KLSAgICAgICAgICAgIH0gZWxzZSB7DQotICAgICAgICAgICAgICAgIGFjdGlvblJlc3BvbnNlID0NCi0gICAgICAgICAgICAgICAgICAgIGludGVyZmFjZU9wZXJhdGlvbkJ1c2luZXNzTG9naWMNCi0gICAgICAgICAgICAgICAgICAgICAgICAuY3JlYXRlSW50ZXJmYWNlT3BlcmF0aW9uKGNvbXBvbmVudElkTG93ZXIsIG1hcHBlZEludGVyZmFjZURhdGEsIG1vZGlmaWVyLCB0cnVlKTsNCi0gICAgICAgICAgICB9DQotDQotICAgICAgICAgICAgaWYgKGFjdGlvblJlc3BvbnNlLmlzUmlnaHQoKSkgew0KLSAgICAgICAgICAgICAgICBsb2cuZXJyb3IoImZhaWxlZCB0byBjcmVhdGUgb3IgdXBkYXRlIGludGVyZmFjZSBvcGVyYXRpb24iKTsNCi0gICAgICAgICAgICAgICAgcmV0dXJuIGJ1aWxkRXJyb3JSZXNwb25zZShhY3Rpb25SZXNwb25zZS5yaWdodCgpLnZhbHVlKCkpOw0KLSAgICAgICAgICAgIH0NCi0NCi0gICAgICAgICAgICByZXR1cm4gYnVpbGRPa1Jlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5PSyksDQotICAgICAgICAgICAgICAgICAgICBnZXRGb3JtYXR0ZWRSZXNwb25zZShhY3Rpb25SZXNwb25zZS5sZWZ0KCkudmFsdWUoKSk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ZmllciwgY29tcG9uZW50VHlwZSk7CisgICAgICAgICAgICBFaXRoZXI8TGlzdDxJbnRlcmZhY2VEZWZpbml0aW9uPiwgUmVzcG9uc2VGb3JtYXQ+IGFjdGlvblJlc3BvbnNlOworICAgICAgICAgICAgaWYgKGlzVXBkYXRlKSB7CisgICAgICAgICAgICAgICAgYWN0aW9uUmVzcG9uc2UgPQorICAgICAgICAgICAgICAgICAgICAgICAgaW50ZXJmYWNlT3BlcmF0aW9uQnVzaW5lc3NMb2dpYy51cGRhdGVJbnRlcmZhY2VPcGVyYXRpb24oY29tcG9uZW50SWRMb3dlciwgbWFwcGVkSW50ZXJmYWNlRGF0YSwgbW9kaWZpZXIsIHRydWUpOworICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICBhY3Rpb25SZXNwb25zZSA9CisgICAgICAgICAgICAgICAgICAgICAgICBpbnRlcmZhY2VPcGVyYXRpb25CdXNpbmVzc0xvZ2ljLmNyZWF0ZUludGVyZmFjZU9wZXJhdGlvbihjb21wb25lbnRJZExvd2VyLCBtYXBwZWRJbnRlcmZhY2VEYXRhLCBtb2RpZmllciwgdHJ1ZSk7CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIGlmIChhY3Rpb25SZXNwb25zZS5pc1JpZ2h0KCkpIHsKKyAgICAgICAgICAgICAgICBsb2cuZXJyb3IoImZhaWxlZCB0byBjcmVhdGUgb3IgdXBkYXRlIGludGVyZmFjZSBvcGVyYXRpb24iKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gYnVpbGRFcnJvclJlc3BvbnNlKGFjdGlvblJlc3BvbnNlLnJpZ2h0KCkudmFsdWUoKSk7CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIHJldHVybiBidWlsZE9rUmVzcG9uc2UoZ2V0Q29tcG9uZW50c1V0aWxzKCkuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLk9LKSwKKyAgICAgICAgICAgICAgICAgICAgZ2V0Rm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ICAgICAgIHJldHVybiBuZXcgQXJyYXlMaXN0PD4odWlDb21wb25lbnRFaXRoZXIubGVmdCgpLnZhbHVlKCkuZ2V0SW50ZXJmYWNlcygpLnZhbHVlcygpKTsKKyAgICB9CisKKyAgICBwcml2YXRlIE9iamVjdCBnZXRGb3JtYXR0ZWRSZXNwb25zZShMaXN0PEludGVyZmFjZURlZmluaXRpb24+IGludGVyZmFjZURlZmluaXRpb25zKSB0aHJvd3MgSU9FeGNlcHRpb24geworICAgICAgICBNYXA8U3RyaW5nLCBMaXN0PEludGVyZmFjZURlZmluaXRpb24+PiBhbGxJbnRlcmZhY2VzID0KKyAgICAgICAgICAgICAgICBJbW11dGFibGVNYXAub2YoSnNvblByZXNlbnRhdGlvbkZpZWxkcy5JTlRFUkZBQ0VTLmdldFByZXNlbnRhdGlvbigpLCBpbnRlcmZhY2VEZWZpbml0aW9ucyk7CisgICAgICAgIHJldHVybiBSZXByZXNlbnRhdGlvblV0aWxzLnRvRmlsdGVyZWRSZXByZXNlbnRhdGlvbihhbGxJbnRlcmZhY2VzKTsKKyAgICB9CisKKyAgICBAUFVUCisgICAgQENvbnN1bWVzKE1lZGlhVHlwZS5BUFBMSUNBVElPTl9KU09OKQorICAgIEBQcm9kdWNlcyhNZWRpYVR5cGUuQVBQTElDQVRJT05fSlNPTikKKyAgICBAUGF0aCgiL3Jlc291cmNlcy97cmVzb3VyY2VJZH0vaW50ZXJmYWNlT3BlcmF0aW9ucyIpCisgICAgQE9wZXJhdGlvbihkZXNjcmlwdGlvbiA9ICJVcGRhdGUgSW50ZXJmYWNlIE9wZXJhdGlvbnMgb24gUmVzb3VyY2UiLCBtZXRob2QgPSAiUFVUIiwKKyAgICAgICAgICAgIHN1bW1hcnkgPSAiVXBkYXRlIEludGVyZmFjZSBPcGVyYXRpb25zIG9uIFJlc291cmNlIixyZXNwb25zZXMgPSBAQXBpUmVzcG9uc2UoY29udGVudCA9IEBDb250ZW50KAorICAgICAgICAgICAgICAgICAgICBhcnJhe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aWZlY3ljbGVTZXJ2bGV0LmphdmEKQEAgLTEsMTk3ICsxLDE5OCBAQAotLyotDQotICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NCi0gKiBTREMNCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLSAqIENvcHlyaWdodCAoQykgMjAxNyBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLSAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOw0KLSAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4NCi0gKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQNCi0gKiANCi0gKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMA0KLSAqIA0KLSAqIFVubGVzcyByZXF1aXJlZCBieSBhcHBsaWNhYmxlIGxhdyBvciBhZ3JlZWQgdG8gaW4gd3JpdGluZywgc29mdHdhcmUNCi0gKiBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0cmlidXRlZCBvbiBhbiAiQVMgSVMiIEJBU0lTLA0KLSAqIFdJVEhPVVQgV0FSUkFOVElFUyBPUiBDT05ESVRJT05TIE9GIEFOWSBLSU5ELCBlaXRoZXIgZXhwcmVzcyBv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zIC8gcHJvZHVjdHMiLA0KLSAgICAgICAgICAgICAgICAgICAgc2NoZW1hID0gQFNjaGVtYShhbGxvd2FibGVWYWx1ZXMgPSB7Q29tcG9uZW50VHlwZUVudW0uUkVTT1VSQ0VfUEFSQU1fTkFNRSwNCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29tcG9uZW50VHlwZUVudW0uU0VSVklDRV9QQVJBTV9OQU1FLCBDb21wb25lbnRUeXBlRW51bS5QUk9EVUNUX1BBUkFNX05BTUV9KSkgQFBhdGhQYXJhbSgNCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9ICJjb21wb25lbnRDb2xsZWN0aW9uIikgZmluYWwgU3RyaW5nIGNvbXBvbmVudENvbGxlY3Rpb24sDQotICAgICAgICAgICAgQFBhcmFtZXRlcihzY2hlbWEgPSBAU2NoZW1hKGFsbG93YWJsZVZhbHVlcyA9IHsNCi0gICAgICAgICAgICAgICAgICAgICJjaGVja291dCwgdW5kb0NoZWNrb3V0LCBjaGVja2luLCBjZXJ0aWZpY2F0aW9uUmVxdWVzdCwgc3RhcnRDZXJ0aWZpY2F0aW9uLCBmYWlsQ2VydGlmaWNhdGlvbiwgIGNhbmNlbENlcnRpZmljYXRpb24sIGNlcnRpZnkifSksDQotICAgICAgICAgICAgICAgICAgICByZXF1aXJlZCA9IHRydWUpIEBQYXRoUGFyYW0odmFsdWUgPSAibGlmZWN5Y2xlT3BlcmF0aW9uIikgZmluYWwgU3RyaW5nIGxpZmVjeWNsZVRyYW5zaXRpb24sDQotICAgICAgICAgICAgQFBhcmFtZXRlcihkZXNjcmlwdGlvbiA9ICJpZCBvZiBjb21wb25lbnQgdG8gYmUgY2hhbmdlZCIpIEBQYXRoUGFyYW0oDQotICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9ICJjb21wb25lbnRJZCIpIGZpbmFsIFN0cmluZyBjb21wb25lbnRJZCwNCi0gICAgICAgICAgICBAQ29udGV4dCBmaW5hbC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SW5mbywgZmFsc2UsIHRydWUpOw0KLQ0KLSAgICAgICAgICAgICAgICBpZiAoYWN0aW9uUmVzcG9uc2UuaXNSaWdodCgpKSB7DQotICAgICAgICAgICAgICAgICAgICBsb2cuaW5mbygiZmFpbGVkIHRvIGNoYW5nZSByZXNvdXJjZSBzdGF0ZSIpOw0KLSAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBidWlsZEVycm9yUmVzcG9uc2UoYWN0aW9uUmVzcG9uc2UucmlnaHQoKS52YWx1ZSgpKTsNCi0gICAgICAgICAgICAgICAgICAgIHJldHVybiByZXNwb25zZTsNCi0gICAgICAgICAgICAgICAgfQ0KLQ0KLSAgICAgICAgICAgICAgICBsb2cuZGVidWcoImNoYW5nZSBzdGF0ZSBzdWNjZXNzZnVsICEhISIpOw0KLSAgICAgICAgICAgICAgICBVaUNvbXBvbmVudE1ldGFkYXRhIGNvbXBvbmVudE1ldGF0ZGF0YSA9DQotICAgICAgICAgICAgICAgICAgICAgICAgVWlDb21wb25lbnREYXRhQ29udmVydGVyLmNvbnZlcnRUb1VpQ29tcG9uZW50TWV0YWRhdGEoYWN0aW9uUmVzcG9uc2UubGVmdCgpLnZhbHVlKCkpOw0KLSAgICAgICAgICAgICAgICBPYmplY3QgdmFsdWUgPSBSZXByZXNlbnRhdGlvblV0aWxzLnRvUmVwcmVzZW50YXRpb24oY29tcG9uZW50TWV0YXRkYXRhKTsNCi0gICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBidWlsZE9rUmVzcG9uc2UoZ2V0Q29tcG9uZW50c1V0aWxzKCkuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLk9LKSwgdmFsdWUpOw0KLSAgICAgICAgICAgICAgICByZXR1cm4gcmVzcG9uc2U7DQotICAgICAgICAgICAgfSBlbHNlIHsNCi0gICAgICAgICAgICAgICAgbG9nLmluZm8oDQotICAgICAgICAgICAgICAgICAgICAgICAgImNvbXBvbmVudENvbGxlY3Rpb24gXC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TsNCi0gICAgfQ0KLQ0KLX0NCisvKi0KKyAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBTREMKKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBDb3B5cmlnaHQgKEMpIDIwMTcgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7CisgKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCisgKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKKyAqCisgKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAorICoKKyAqIFVubGVzcyByZXF1aXJlZCBieSBhcHBsaWNhYmxlIGxhdyBvciBhZ3JlZWQgdG8gaW4gd3JpdGluZywgc29mdHdhcmUKKyAqIGRpc3RyaWJ1dGVkIHVuZGVyIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1dGVkIG9uIGFuICJBUyBJUyIgQkFTSVMsCisgKiBXSVRIT1VUIFdBUlJBTlRJRVMgT1IgQ09ORElUSU9OUyBPRiBBTlkgS0lORCwgZWl0aGVyIGV4cHJlc3Mgb3IgaW1wbGllZC4KKyAqIFNlZSB0aGUgTGljZW5zZSBmb3IgdGhlIH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sKKyAgICAgICAgICAgIHJldHVybiB2YWxpZGF0ZUVudW0ucmlnaHQoKS52YWx1ZSgpOworICAgICAgICB9CisKKyAgICAgICAgTGlmZWN5Y2xlQ2hhbmdlSW5mb1dpdGhBY3Rpb24gY2hhbmdlSW5mbyA9IG5ldyBMaWZlY3ljbGVDaGFuZ2VJbmZvV2l0aEFjdGlvbigpOworCisgICAgICAgIHRyeSB7CisgICAgICAgICAgICBpZiAoanNvbkNoYW5nZUluZm8gIT0gbnVsbCAmJiAhanNvbkNoYW5nZUluZm8uaXNFbXB0eSgpKSB7CisgICAgICAgICAgICAgICAgT2JqZWN0TWFwcGVyIG1hcHBlciA9IG5ldyBPYmplY3RNYXBwZXIoKTsKKyAgICAgICAgICAgICAgICBjaGFuZ2VJbmZvID0gbmV3IExpZmVjeWNsZUNoYW5nZUluZm9XaXRoQWN0aW9uKG1hcHBlci5yZWFkVmFsdWUoanNvbkNoYW5nZUluZm8sIExpZmVjeWNsZUNoYW5nZUluZm9CYXNlLmNsYXNzKS5nZXRVc2VyUmVtYXJrcygpKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorCisgICAgICAgIGNhdGNoIChFeGNlcHRpb24gZSkgeworICAgICAgICAgICAgQmVFY29tcEVycm9yTWFuYWdlci5nZXRJbnN0YW5jZSgpLmxvZ0JlSW52YWxpZEpzb25JbnB1dCgiY29udmVydEpzb25Ub09iamVjdCIpOworICAgICAgICAgICAgbG9nLmRlYnVnKCJmYWlsZWQgdG8gY29udmVydCBmcm9tIGpzb24ge30iLCBqc29uQ2hhbmdlSW5mbywgZSk7CisgICAgICAgICAgICBnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRJbnZhbGlkQ29udGVudEVycm9yQW5kQXVkaXQodXNlciwgY29tcG9uZW50SWQsIEF1ZGl0aW5nQWN0aW9uRW51bS5DSEVDS09VVF9SRVNPVVJDRSk7CisgICAgICAgICAgICB0aHJvdyBlOworICAgICAgICB9CisKKyAgICAgICAgTGlmZUN5Y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W1ldGVyKGRlc2NyaXB0aW9uID0gIlVTRVJfSUQgb2YgbW9kaWZpZXIgdXNlciIsDQotICAgICAgICAgICAgICAgICAgICByZXF1aXJlZCA9IHRydWUpIFN0cmluZyB1c2VySWQsDQotICAgICAgICAgICAgQENvbnRleHQgZmluYWwgSHR0cFNlcnZsZXRSZXF1ZXN0IHJlcXVlc3QpIHsNCi0gICAgICAgIGluaXQoKTsNCi0NCi0gICAgICAgIFdyYXBwZXI8UmVzcG9uc2U+IHJlc3BvbnNlV3JhcHBlciA9IG5ldyBXcmFwcGVyPD4oKTsNCi0gICAgICAgIHRyeSB7DQotICAgICAgICAgICAgV3JhcHBlcjxDb21wb25lbnRUeXBlRW51bT4gY29tcG9uZW50VHlwZVdyYXBwZXIgPQ0KLSAgICAgICAgICAgICAgICAgICAgdmFsaWRhdGVDb21wb25lbnRUeXBlQW5kVXNlcklkKGNvbnRhaW5lckNvbXBvbmVudFR5cGUsIHVzZXJJZCwgcmVzcG9uc2VXcmFwcGVyKTsNCi0gICAgICAgICAgICBpZiAocmVzcG9uc2VXcmFwcGVyLmlzRW1wdHkoKSkgew0KLSAgICAgICAgICAgICAgICByZXNwb25zZVdyYXBwZXIuc2V0SW5uZXJFbGVtZW50KHBvbGljeUJ1c2luZXNzTG9naWMNCi0gICAgICAgICAgICAgICAgICAgICAgICAuY3JlYXRlUG9saWN5KGNvbXBvbmVudFR5cGVXcmFwcGVyLmdldElubmVyRWxlbWVudCgpLCBjb250YWluZXJDb21wb25lbnRJZCwgcG9saWN5VHlwZU5hbWUsDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2VySWQsIHRydWUpDQotICAgICAgICAgICAgICAgICAgICAgICAgLmVpdGhlcihsIC0+IGJ1aWxkT2tSZXNwb25zZShnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuQ1JFQVRFRCksIGwpLA0KLSAgICAgICAgICAgICAgICAgICAgICAgICA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HJlc3BvbnNlV3JhcHBlcik7DQotICAgICAgICAgICAgICAgIGlmIChwb2xpY3lXcmFwcGVyLmlzRW1wdHkoKSkgew0KLSAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2VXcmFwcGVyLnNldElubmVyRWxlbWVudCgNCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVpbGRFcnJvclJlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5JTlZBTElEX0NPTlRFTlQpKSk7DQotICAgICAgICAgICAgICAgIH0NCi0gICAgICAgICAgICB9DQotICAgICAgICAgICAgaWYgKCFwb2xpY3lXcmFwcGVyLmlzRW1wdHkoKSkgew0KLSAgICAgICAgICAgICAgICBwb2xpY3lXcmFwcGVyLmdldElubmVyRWxlbWVudCgpLnNldFVuaXF1ZUlkKHBvbGljeUlkKTsNCi0gICAgICAgICAgICAgICAgcmVzcG9uc2VXcmFwcGVyLnNldElubmVyRWxlbWVudChwb2xpY3lCdXNpbmVzc0xvZ2ljDQotICAgICAgICAgICAgICAgICAgICAgICAgLnVwZGF0ZVBvbGljeShjb21wb25lbnRUeXBlV3JhcHBlci5nZXRJbm5lckVsZW1lbnQoKSwgY29udGFpbmVyQ29tcG9uZW50SWQsDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2xpY3lXcmFwcGVyLmdldElubmVyRWxlbWVudCgpLCB1c2VySWQsIHRydWUpDQotICAgICAgICAgICAgICAgICAgICAgICAgLmVpdGhlcih0aGlzOjpidWlsZE9rUmVzcG9uc2UsIHRoaXM6OmJ1aWxkRXJyb3JSZXNwb25zZSkpOw0KLSAgICAgICAgICAgIH0NCi0NCi0gICAgICAgIH0gY2F0Y2ggKEV4Y2VwdGlvbiBlKSB7DQotICAgICAgICAgICAgQmVFY29tcEVycm9yTWFuYWdlci5nZXRJbnN0YW5jZSgpLmxvZ0JlUmVzdEFwaUdlbmVyYWxFcnJvcigiVX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gICAgICAgICAgIEBBcGlSZXNwb25zZShyZXNwb25zZUNvZGUgPSAiNDAwIiwgZGVzY3JpcHRpb24gPSAiSW52YWxpZCBjb250ZW50IC8gTWlzc2luZyBjb250ZW50IiksDQotICAgICAgICAgICAgQEFwaVJlc3BvbnNlKHJlc3BvbnNlQ29kZSA9ICI0MDQiLCBkZXNjcmlwdGlvbiA9ICJjb21wb25lbnQgLyBwb2xpY3kgTm90IGZvdW5kIil9KQ0KLSAgICBwdWJsaWMgUmVzcG9uc2UgZ2V0UG9saWN5KEBQYXRoUGFyYW0oImNvbXBvbmVudElkIikgZmluYWwgU3RyaW5nIGNvbnRhaW5lckNvbXBvbmVudElkLCBAUGFyYW1ldGVyKA0KLSAgICAgICAgICAgIGRlc2NyaXB0aW9uID0gInZhbGlkIHZhbHVlczogcmVzb3VyY2VzIC8gc2VydmljZXMiLA0KLSAgICAgICAgICAgICAgICAgICAgc2NoZW1hID0gQFNjaGVtYShhbGxvd2FibGVWYWx1ZXMgPSB7Q29tcG9uZW50VHlwZUVudW0uUkVTT1VSQ0VfUEFSQU1fTkFNRSAsDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbXBvbmVudFR5cGVFbnVtLlNFUlZJQ0VfUEFSQU1fTkFNRX0pKSBAUGF0aFBhcmFtKCJjb250YWluZXJDb21wb25lbnRUeXBlIikgZmluYWwgU3RyaW5nIGNvbnRhaW5lckNvbXBvbmVudFR5cGUsDQotICAgICAgICAgICAgQFBhdGhQYXJhbSgicG9saWN5SWQiKSBmaW5hbCBTdHJpbmcgcG9saWN5SWQsDQotICAgICAgICAgICAgQEhlYWRlclBhcmFtKHZhbHVlID0gQ29uc3RhbnRzLlVTRVJfSURfSEVBREVSKSBAUGFyYW1ldGVyKGRlc2NyaXB0aW9uID0gIlVTRVJfSUQgb2YgbW9kaWZpZXIgdXNlciIsDQotICAgICAgICAgICAgICAgICAgICByZXF1aXJlZCA9IHRydWUpIFN0cmluZyB1c2VySWQsDQotICAgICAgICA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AgICAgaW5pdCgpOw0KLQ0KLSAgICAgICAgV3JhcHBlcjxSZXNwb25zZT4gcmVzcG9uc2VXcmFwcGVyID0gbmV3IFdyYXBwZXI8PigpOw0KLSAgICAgICAgdHJ5IHsNCi0gICAgICAgICAgICBXcmFwcGVyPENvbXBvbmVudFR5cGVFbnVtPiBjb21wb25lbnRUeXBlV3JhcHBlciA9DQotICAgICAgICAgICAgICAgICAgICB2YWxpZGF0ZUNvbXBvbmVudFR5cGVBbmRVc2VySWQoY29udGFpbmVyQ29tcG9uZW50VHlwZSwgdXNlcklkLCByZXNwb25zZVdyYXBwZXIpOw0KLSAgICAgICAgICAgIGlmIChyZXNwb25zZVdyYXBwZXIuaXNFbXB0eSgpKSB7DQotICAgICAgICAgICAgICAgIHJlc3BvbnNlV3JhcHBlcg0KLSAgICAgICAgICAgICAgICAgICAgICAgIC5zZXRJbm5lckVsZW1lbnQoDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2xpY3lCdXNpbmVzc0xvZ2ljDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5kZWxldGVQb2xpY3koY29tcG9uZW50VHlwZVdyYXBwZXIuZ2V0SW5uZXJFbGVtZW50KCksIGNvbnRhaW5lckNvbXBvbmVudElkLA0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvbGljeUlkLCB1c2VySWQsIHRydWUpDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5laXRoZXIodGhpczo6YnVpbGRPa1Jlc3BvbnNlLCB0aGlzOjpidWlsZEVycm9yUmVzcG9uc2UpKTsNCi0gICAgICAgICAgICB9DQotDQotICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZSkgew0KLSAgICAgICAgICAgIEJlRWNvbXBFcnJvck1hbmFnZXIuZ2V0SW5zdGFuY2UoKS5sb2dCZVJlc3RBcGlHZW5lcmFsRXJyb3IoIkRlbGV0ZS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gdHJ1ZSkgU3RyaW5nIHVzZXJJZCwNCi0gICAgICAgICAgICBAQ29udGV4dCBmaW5hbCBIdHRwU2VydmxldFJlcXVlc3QgcmVxdWVzdCkgew0KLSAgICAgICAgaW5pdCgpOw0KLQ0KLSAgICAgICAgV3JhcHBlcjxSZXNwb25zZT4gcmVzcG9uc2VXcmFwcGVyID0gbmV3IFdyYXBwZXI8PigpOw0KLSAgICAgICAgdHJ5IHsNCi0gICAgICAgICAgICBXcmFwcGVyPENvbXBvbmVudFR5cGVFbnVtPiBjb21wb25lbnRUeXBlV3JhcHBlciA9DQotICAgICAgICAgICAgICAgICAgICB2YWxpZGF0ZUNvbXBvbmVudFR5cGVBbmRVc2VySWQoY29udGFpbmVyQ29tcG9uZW50VHlwZSwgdXNlcklkLCByZXNwb25zZVdyYXBwZXIpOw0KLSAgICAgICAgICAgIGlmIChyZXNwb25zZVdyYXBwZXIuaXNFbXB0eSgpKSB7DQotICAgICAgICAgICAgICAgIHJlc3BvbnNlV3JhcHBlcg0KLSAgICAgICAgICAgICAgICAgICAgICAgIC5zZXRJbm5lckVsZW1lbnQoDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2xpY3lCdXNpbmVzc0xvZ2ljDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC51bmRlY2xhcmVQb2xpY3koY29tcG9uZW50VHlwZVdyYXBwZXIuZ2V0SW5uZXJFbGVtZW50KCksIGNvbnRhaW5lckNvbXBvbmVudElkLA0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvbGljeUlkLCB1c2VySWQsIHRydWUpDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5laXRoZXIodGhpczo6YnVpbGRPa1Jlc3BvbnNlLCB0aGlzOjpidWlsZEVycm9yUmVzcG9uc2UpKTsNCi0gICAgICAgICAgICB9DQotDQotICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24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cyIsDQotICAgICAgICAgICAgICAgICAgICBzY2hlbWEgPSBAU2NoZW1hKGFsbG93YWJsZVZhbHVlcyA9IHtDb21wb25lbnRUeXBlRW51bS5SRVNPVVJDRV9QQVJBTV9OQU1FICwNCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29tcG9uZW50VHlwZUVudW0uU0VSVklDRV9QQVJBTV9OQU1FfSkpIEBQYXRoUGFyYW0oImNvbnRhaW5lckNvbXBvbmVudFR5cGUiKSBmaW5hbCBTdHJpbmcgY29udGFpbmVyQ29tcG9uZW50VHlwZSwNCi0gICAgICAgICAgICBAUGFyYW1ldGVyKA0KLSAgICAgICAgICAgICAgICAgICAgZGVzY3JpcHRpb24gPSAidGhlIGlkIG9mIHRoZSBwb2xpY3kgd2hpY2ggaXRzIHByb3BlcnRpZXMgYXJlIHRvIHJldHVybiIpIEBQYXRoUGFyYW0oInBvbGljeUlkIikgZmluYWwgU3RyaW5nIHBvbGljeUlkLA0KLSAgICAgICAgICAgIEBQYXJhbWV0ZXIoZGVzY3JpcHRpb24gPSAidGhlIHVzZXJpZCIsDQotICAgICAgICAgICAgICAgICAgICByZXF1aXJlZCA9IHRydWUpIEBIZWFkZXJQYXJhbSh2YWx1ZSA9IENvbnN0YW50cy5VU0VSX0lEX0hFQURFUikgU3RyaW5nIHVzZXJJZCwNCi0gICAgICAgICAgICBAQ29udGV4dCBmaW5hbCBIdHRwU2VydmxldFJlcXVlc3QgcmVxdWVzdCkgew0KLSAgICAgICAgaW5pdCgpOw0KLSAgICAgICAgdHJ5IHsNCi0gICAgICAgICAgICByZXR1cm4gY29udmVydFRvQ29tcG9uZW50VHlwZShjb250YWluZXJDb21wb25lbnRUeXBlKS5sZWZ0KCkuYmluZChjbXB0VHlwZSAtPiBwb2xpY3lCdXNpbmVzc0xvZ2ljDQotICAgICAgICAgICAgICAgICAgICAuZ2V0UG9saWN5UHJvcGVydGllcyhjbXB0VHlwZSwgY29udGFpbmVyQ29tcG9uZW50SWQsIHB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lZmluaXRpb25bXS5jbGFzcywNCi0gICAgICAgICAgICAgICAgICAgICAgICByZXNwb25zZVdyYXBwZXIpOw0KLSAgICAgICAgICAgICAgICBpZiAocHJvcGVydGllc1dyYXBwZXIuaXNFbXB0eSgpKSB7DQotICAgICAgICAgICAgICAgICAgICByZXNwb25zZVdyYXBwZXIuc2V0SW5uZXJFbGVtZW50KA0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBidWlsZEVycm9yUmVzcG9uc2UoZ2V0Q29tcG9uZW50c1V0aWxzKCkuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLklOVkFMSURfQ09OVEVOVCkpKTsNCi0gICAgICAgICAgICAgICAgfQ0KLSAgICAgICAgICAgIH0NCi0gICAgICAgICAgICBpZiAoIXByb3BlcnRpZXNXcmFwcGVyLmlzRW1wdHkoKSkgew0KLSAgICAgICAgICAgICAgICByZXNwb25zZVdyYXBwZXIuc2V0SW5uZXJFbGVtZW50KHBvbGljeUJ1c2luZXNzTG9naWMNCi0gICAgICAgICAgICAgICAgICAgICAgICAudXBkYXRlUG9saWN5UHJvcGVydGllcyhjb21wb25lbnRUeXBlV3JhcHBlci5nZXRJbm5lckVsZW1lbnQoKSwgY29udGFpbmVyQ29tcG9uZW50SWQsIHBvbGljeUlkLA0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvcGVydGllc1dyYXBwZXIuZ2V0SW5uZXJFbGVtZW50KCksIHVzZXJJZCwgdHJ1ZSkNCi0gICAgICAgICAgICAgICAgICAgICAgICAuZWl0aGVyKHRoaXM6OmJ1aWxkT2tSZXNwb25zZSwgdGhpczo6YnVpbGRFcnJvclJlc3BvbnNlKSk7DQotICAgICAgICAgICAgfQ0KLSAgICAgICAgfSBjYXRjaCAoRXhjZXB0aW9uIGUpIHsNCi0gICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nQmVSZXN0QXBpR2VuZXJhbEVyc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BlKTsNCi0gICAgICAgIGlmKHRhcmdldFR5cGVFbnVtICE9IG51bGwpew0KLSAgICAgICAgICAgIHBvbGljeVRhcmdldC5wdXQodGFyZ2V0VHlwZUVudW0sIHZhbGlkYXRlVW5pcXVlbmVzc09mSWRzKHVuaXF1ZUlkcykpOw0KLSAgICAgICAgICAgIHJldHVybiB0cnVlOw0KLSAgICAgICAgfQ0KLSAgICAgICAgZWxzZXsNCi0gICAgICAgICAgICByZXR1cm4gZmFsc2U7DQotICAgICAgICB9DQotICAgIH0NCi0NCi0gICAgcHJpdmF0ZSBMaXN0PFN0cmluZz4gdmFsaWRhdGVVbmlxdWVuZXNzT2ZJZHMoTGlzdDxTdHJpbmc+IHVuaXF1ZUlkcykgew0KLSAgICAgICAgcmV0dXJuIHVuaXF1ZUlkcy5zdHJlYW0oKS5kaXN0aW5jdCgpLmNvbGxlY3QoQ29sbGVjdG9ycy50b0xpc3QoKSk7DQotICAgIH0NCi19DQorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDE5IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNl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yaXB0aW9uID0gIkludmFsaWQgY29udGVudCAvIE1pc3NpbmcgY29udGVudCIpLAorICAgICAgICAgICAgQEFwaVJlc3BvbnNlKHJlc3BvbnNlQ29kZSA9ICI0MDQiLCBkZXNjcmlwdGlvbiA9ICJjb21wb25lbnQgLyBwb2xpY3kgTm90IGZvdW5kIil9KQorICAgIEBQZXJtaXNzaW9uQWxsb3dlZChBYWZQZXJtaXNzaW9uLlBlcm1OYW1lcy5JTlRFUk5BTF9BTExfVkFMVUUpCisgICAgcHVibGljIFJlc3BvbnNlIHVuZGVjbGFyZVBvbGljeShAUGF0aFBhcmFtKCJjb21wb25lbnRJZCIpIGZpbmFsIFN0cmluZyBjb250YWluZXJDb21wb25lbnRJZCwgQFBhcmFtZXRlcigKKyAgICAgICAgICAgIGRlc2NyaXB0aW9uID0gInZhbGlkIHZhbHVlczogcmVzb3VyY2VzIC8gc2VydmljZXMiLAorICAgICAgICAgICAgICAgICAgICBzY2hlbWEgPSBAU2NoZW1hKGFsbG93YWJsZVZhbHVlcyA9IHtDb21wb25lbnRUeXBlRW51bS5SRVNPVVJDRV9QQVJBTV9OQU1FICwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb21wb25lbnRUeXBlRW51bS5TRVJWSUNFX1BBUkFNX05BTUV9KSkgQFBhdGhQYXJhbSgiY29udGFpbmVyQ29tcG9uZW50VHlwZSIpIGZpbmFsIFN0cmluZyBjb250YWluZXJDb21wb25lbnRUeXBlLAorICAgICAgICAgICAgQFBhdGhQYXJhbSgicG9saWN5SWQiKSBmaW5hbCBTdHJpbmcgcG9saWN5SWQsCisgICAgICAgICAgICBASGVhZGVyUGFyYW0odmFsdWUgPSBDb25zdGFudHMuVVNFUl9JRF9IRUFERVIpIEBQYXJhbWV0ZXIoZGVzY3JpcHRpb24gPSAiVVNFUl9JRCBvZiBtb2RpZmllciB1c2VyIiwKKyAgICAgICAgICAgICAgICAgICAgcmVxdWlyZWQgPSB0cnVlKSBTdHJpbmcgdXNlckl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pb24ge30gb2NjdXJyZWQuICIsIGUpOworICAgICAgICB9CisgICAgICAgIHJldHVybiByZXNwb25zZTsKKyAgICB9CisKKyAgICBAR0VUCisgICAgQFBhdGgoIi97Y29udGFpbmVyQ29tcG9uZW50VHlwZX0ve2NvbXBvbmVudElkfS9wb2xpY2llcy97cG9saWN5SWR9L3Byb3BlcnRpZXMiKQorICAgIEBPcGVyYXRpb24oZGVzY3JpcHRpb24gPSAiR2V0IGNvbXBvbmVudCBwb2xpY3kgcHJvcGVydGllcyIsIG1ldGhvZCA9ICJHRVQiLAorICAgICAgICAgICAgc3VtbWFyeSA9ICJSZXR1cm5zIGNvbXBvbmVudCBwb2xpY3kgcHJvcGVydGllcyIscmVzcG9uc2VzID0gQEFwaVJlc3BvbnNlKAorICAgICAgICAgICAgICAgICAgICBjb250ZW50ID0gQENvbnRlbnQoYXJyYXkgPSBAQXJyYXlTY2hlbWEoc2NoZW1hID0gQFNjaGVtYShpbXBsZW1lbnRhdGlvbiA9IFByb3BlcnR5RGF0YURlZmluaXRpb24uY2xhc3MpKSkpKQorICAgIEBBcGlSZXNwb25zZXModmFsdWUgPSB7QEFwaVJlc3BvbnNlKHJlc3BvbnNlQ29kZSA9ICIyMDAiLCBkZXNjcmlwdGlvbiA9ICJQcm9wZXJ0aWVzIGZvdW5kIiksCisgICAgICAgICAgICBAQXBpUmVzcG9uc2UocmVzcG9uc2VDb2RlID0gIjQwMCIsCisgICAgICAgICAgICAgICAgICAgIGRlc2NyaXB0aW9uID0gImludmFsaWQgY29udGVudCAtIEVycm9yOiBjb250YWluZXJDb21wb25lbnRUeXBlIGlzIGludmFsaWQiKSwKKyAgICAgICAgICAgIEBBcGlSZXNwb25zZShyZXNwb25zZUNvZGUgPSAiNDAzIiwgZGVzY3JpcHRpb24gPSAiUmVzdHJpY3RlZCBvcGVyYXRpb24iKSwKKyAgICAgICAgICAgIEBBcGlSZXNwb25zZShyZXNwb25zZUNvZGUgPSAiNDA0IiwgZGVzY3JpcHRpb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Byb3BlcnRpZXMgYXJlIHRvIHJldHVybiIpIEBQYXRoUGFyYW0oInBvbGljeUlkIikgZmluYWwgU3RyaW5nIHBvbGljeUlkLAorICAgICAgICAgICAgQFBhcmFtZXRlcihkZXNjcmlwdGlvbiA9ICJ0aGUgdXNlcmlkIiwKKyAgICAgICAgICAgICAgICAgICAgcmVxdWlyZWQgPSB0cnVlKSBASGVhZGVyUGFyYW0odmFsdWUgPSBDb25zdGFudHMuVVNFUl9JRF9IRUFERVIpIFN0cmluZyB1c2VySWQsCisgICAgICAgICAgICBAQ29udGV4dCBmaW5hbCBIdHRwU2VydmxldFJlcXVlc3QgcmVxdWVzdCkgeworICAgICAgICBpbml0KCk7CisgICAgICAgIExpc3Q8UHJvcGVydHlEYXRhRGVmaW5pdGlvbj4gcHJvcGVydHlEYXRhRGVmaW5pdGlvbkxpc3QgPSBwb2xpY3lCdXNpbmVzc0xvZ2ljLmdldFBvbGljeVByb3BlcnRpZXMoCisgICAgICAgICAgICAgICAgY29udmVydFRvQ29tcG9uZW50VHlwZShjb250YWluZXJDb21wb25lbnRUeXBlKSwgY29udGFpbmVyQ29tcG9uZW50SWQsIHBvbGljeUlkLCB1c2VySWQpOworICAgICAgICByZXR1cm4gYnVpbGRPa1Jlc3BvbnNlKHByb3BlcnR5RGF0YURlZmluaXRpb25MaXN0KTsKKyAgICB9CisKKyAgICBAUFVUCisgICAgQFBhdGgoIi97Y29udGFpbmVyQ29tcG9uZW50VHlwZX0ve2NvbXBvbmVudElkfS9wb2xpY2llcy97cG9saWN5SWR9L3Byb3BlcnRpZXMiKQorICAgIEBPcGVyYXRpb24oZGVzY3JpcHRpb24gPSAiVXBkYXRlIFBvbGljeSBwcm9wZXJ0aWVzIiwgbWV0aG9kID0gIlBVVCIsIHN1bW1hcnkgPSAiUmV0dXJucyB1cGRhdGVkIFBvbGljeSIsCisgICAgICAgICAgICByZXNwb25zZXMgPSBAQXBpUmVzcG9uc2UoCisgICAgICAgICAgICAgICAgICAgIGNvb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PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogQ29weXJpZ2h0IChDKSAyMDE5IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7DQotICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLg0KLSAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdA0KLSAqIA0KLSAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wDQotICogDQotICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZQ0KLSAqIGRpc3RyaWJ1dGVkIHVuZGVyIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1dGVkIG9uIGFuICJBUyBJUyIgQkFTSVMsDQotICogV0lUSE9VVCBXQVJSQU5USUVTIE9SIENPTkRJVElPTlMgT0YgQU5ZIEtJTkQsIGVpdGhlciBleHByZXNzIG9yIGltcGxpZWQuDQotICogU2VlIHRoZSBMaWNlbnNlIGZvciB0aGUgc3BlY2lmaWMgbGFuZ3VhZ2UgZ292ZXJuaW5nIHBlcm1pc3Npb25zIGFuZA0KLSAqIGxpbWl0YXRpb25zIHVuZGVyIHRoZSBMaWNlbnNlLg0KLSAqID09PT09PT09PT09PUxJQ0VOU0VfRU5EPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09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09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDE5IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgorICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0CisgKiAKKyAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wCisgKiAKKyAqIFVubGVzcyByZXF1aXJlZCBieSBhcHBsaWNhYmxlIGxhdyBvciBhZ3JlZWQgdG8gaW4gd3JpdGluZywgc29mdHdhcmUKKyAqIGRpc3RyaWJ1dGVkIHVuZGVyIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1dGVkIG9uIGFuICJBUyBJUyIgQkFTSVMsCisgKiBXSVRIT1VUIFdBUlJBTlRJRVMgT1IgQ09ORElUSU9OUyBPRiBBTlkgS0lORCwgZWl0aGVyIGV4cHJlc3Mgb3IgaW1wbGllZC4KKyAqIFNlZSB0aGUgTGljZW5zZSBmb3IgdGhlIHNwZWNpZmljIGxhbmd1YWdlIGdvdmVybmluZyBwZXJtaXNzaW9ucyBhbmQKKyAqIGxpbWl0YXRpb25zIHVuZGVyIHRoZSBMaWNlbnNlLgorICogPT09PT09PT09PT09TElDRU5TRV9FTkQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09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VzZXJJZCkgew0KLSAgICAgICAgcmV0dXJuIGRlbGV0ZShyZXF1aXJlbWVudElkLCBzZXJ2aWNlSWQsIHJlcXVlc3QsIHVzZXJJZCk7DQotICAgIH0NCi0NCi0NCi0gICAgcHJpdmF0ZSBSZXNwb25zZSBjcmVhdGVPclVwZGF0ZSAoU3RyaW5nIGRhdGEsIFN0cmluZyBjb21wb25lbnRUeXBlLCBTdHJpbmcgY29tcG9uZW50SWQsDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEh0dHBTZXJ2bGV0UmVxdWVzdCByZXF1ZXN0LCBTdHJpbmcgdXNlcklkLA0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sZWFuIGlzVXBkYXRlLCBTdHJpbmcgZXJyb3JDb250ZXh0KSB7DQotICAgICAgICBTdHJpbmcgdXJsID0gcmVxdWVzdC5nZXRNZXRob2QoKSArICIgIiArIHJlcXVlc3QuZ2V0UmVxdWVzdFVSSSgpOw0KLQ0KLSAgICAgICAgVXNlciBtb2RpZmllciA9IG5ldyBVc2VyKCk7DQotICAgICAgICBtb2RpZmllci5zZXRVc2VySWQodXNlcklkKTsNCi0gICAgICAgIExPR0dFUi5kZWJ1ZygiU3RhcnQgY3JlYXRlIG9yIHVwZGF0ZSByZXF1ZXN0IG9mIHt9IHdpdGggbW9kaWZpZXIgaWQge30iLCB1cmwsIHVzZXJJZCk7DQotDQotICAgICAgICB0cnkgew0KLSAgICAgICAgICAgIFN0cmluZyBjb21wb25lbnRJZExvd2VyID0gY29tcG9uZW50SWQudG9Mb3dlckNhc2UoKTsNCi0NCi0gICAgICAgICAgICBFaXRoZXI8TGlzdDxSZXF1aXJlbWVudERlZmluaXRpb24+LCBSZXNwb25zZUZvcm1hdD4gbWFwcGVkUmVxdWlyZW1lbnREYXRhRWl0aGVyID0NCi0gICAgICAgICAgICAgICAgICAgIGdldE1hcHBlZFJlcXVpcmVtZW50RGF0YShkYXRhLCBtb2RpZmllci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AgICAgSHR0cFNlcnZsZXRSZXF1ZXN0IHJlcXVlc3QsIFN0cmluZyB1c2VySWQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbGVhbiBpc1VwZGF0ZSwgU3RyaW5nIGVycm9yQ29udGV4dCkgeworICAgICAgICBTdHJpbmcgdXJsID0gcmVxdWVzdC5nZXRNZXRob2QoKSArICIgIiArIHJlcXVlc3QuZ2V0UmVxdWVzdFVSSSgpOworCisgICAgICAgIFVzZXIgbW9kaWZpZXIgPSBuZXcgVXNlcigpOworICAgICAgICBtb2RpZmllci5zZXRVc2VySWQodXNlcklkKTsKKyAgICAgICAgTE9HR0VSLmRlYnVnKCJTdGFydCBjcmVhdGUgb3IgdXBkYXRlIHJlcXVlc3Qgb2Yge30gd2l0aCBtb2RpZmllciBpZCB7fSIsIHVybCwgdXNlcklkKTsKKworICAgICAgICB0cnkgeworICAgICAgICAgICAgU3RyaW5nIGNvbXBvbmVudElkTG93ZXIgPSBjb21wb25lbnRJZC50b0xvd2VyQ2FzZSgpOworCisgICAgICAgICAgICBFaXRoZXI8TGlzdDxSZXF1aXJlbWVudERlZmluaXRpb24+LCBSZXNwb25zZUZvcm1hdD4gbWFwcGVkUmVxdWlyZW1lbnREYXRhRWl0aGVyID0KKyAgICAgICAgICAgICAgICAgICAgZ2V0TWFwcGVkUmVxdWlyZW1lbnREYXRhKGRhdGEsIG1vZGlmaWVyLCBDb21wb25lbnRUeXBlRW51bS5maW5kQnlQYXJhbU5hbWUoY29tcG9uZW50VHlwZSkpOworICAgICAgICAgICAgaWYobWFwcGVkUmVxdWlyZW1lbnREYXRhRWl0aGVyLmlzUmlnaHQoKSkgeworICAgICAgICAgICAgICAgIExPR0dFUi5lcnJvcigiRmFpbGVkIHRvIGNyZWF0ZSBvciB1cGRhdGUgcmVxdWlyZW1lbnRzIik7CisgICAgICAgICAgICAgICAgcmV0dXJuIGJ1aWxkRXJyb3JSZXNwb25zZShtYXBwZWRSZXF1aXJlbWVudERhdGFFaXRoZXIucmlnaHQoKS52YWx1ZSgpKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIExpc3Q8UmVxdWlyZW1lbnREZWZpbml0aW9uPiBtYXBwZWRSZXF1aXJlbWVudERhdGEgPSBtYXBwZWRSZXF1aXJlbWVudERhdGFFaXRoZXIubGVmdCgpLnZhbHVlKCk7CisgICAgICAgICAgICBFaXRoZXI8TGlzdDxSZXF1aXJlbWVudERlZmluaXRpb24+LCBSZXNwb25zZUZvcm1hdD4gYWN0aW9uUmVzcG9uc2U7CisgICAgICAgICAgICBpZihpc1VwZGF0ZSkgeworICAgICAgICAgICAgICAgIGFjdGlvblJlc3BvbnNlID0gcmVxdWlyZW1lbnRCdXNpbmVzc0xvZ2ljLnVwZGF0ZVJlcXVpcmVtZW50cyhjb21wb25lbnRJZExvd2VyLCBtYXBwZWRSZXF1aXJlbWVudERhdGEsIG1vZGlmaWVyLAorICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3JDb250ZXh0LCB0cnVlKTsKKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgYWN0aW9uUmVzcG9uc2UgPSByZXF1aXJlbWVudEJ1c2luZXNzTG9naWMuY3JlYXRlUmVxdWlyZW1lbnRzKGNvbXBvbmVudElkTG93ZXIsIG1hcHBlZFJlcXVpcmVtZW50RGF0YSwgbW9kaWZpZXIsCisgICAgICAgICAgICAgICAgICAgICAgICBlcnJvckNvbnRleHQsIHRydWUpOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICBpZiAoYWN0aW9uUmVzcG9uc2UuaXNSaWdodCgpKSB7CisgICAgICAgICAgICAgICAgTE9HR0VSLmVycm9yKCJGYWlsZWQgdG8gY3JlYXRlIG9yIHVwZGF0ZSByZXF1aXJlbWVudHMiKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gYnVpbGRFcnJvclJlc3BvbnNlKGFjdGlvblJlc3BvbnNlLnJpZ2h0KCkudmFsdWUoKSk7Cis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WZpbml0aW9uPiwgUmVzcG9uc2VGb3JtYXQ+IGdldE1hcHBlZFJlcXVpcmVtZW50RGF0YShTdHJpbmcgaW5wdXRKc29uLCBVc2VyIHVzZXIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbXBvbmVudFR5cGVFbnVtIGNvbXBvbmVudFR5cGVFbnVtKXsKKyAgICAgICAgRWl0aGVyPFVpQ29tcG9uZW50RGF0YVRyYW5zZmVyLCBSZXNwb25zZUZvcm1hdD4gbWFwcGVkRGF0YSA9IGdldENvbXBvbmVudHNVdGlscygpCisgICAgICAgICAgICAgICAgLmNvbnZlcnRKc29uVG9PYmplY3RVc2luZ09iamVjdE1hcHBlcihpbnB1dEpzb24sIHVzZXIsIFVpQ29tcG9uZW50RGF0YVRyYW5zZmVyLmNsYXNzLAorICAgICAgICAgICAgICAgICAgICAgICAgQXVkaXRpbmdBY3Rpb25FbnVtLkNSRUFURV9SRVNPVVJDRSwgY29tcG9uZW50VHlwZUVudW0pOworICAgICAgICBPcHRpb25hbDxMaXN0PFJlcXVpcmVtZW50RGVmaW5pdGlvbj4+IHJlcXVpcmVtZW50RGVmaW5pdGlvbkxpc3QgPSBtYXBwZWREYXRhLmxlZnQoKS52YWx1ZSgpCisgICAgICAgICAgICAgICAgLmdldFJlcXVpcmVtZW50cygpLnZhbHVlcygpLnN0cmVhbSgpLmZpbmRGaXJzdCgpOworICAgICAgICByZXR1cm4gcmVxdWlyZW1lbnREZWZpbml0aW9uTGlzdC48RWl0aGVyPExpc3Q8UmVxdWlyZW1lbnREZWZpbml0aW9uPiwgUmVzcG9uc2VGb3JtYXQ+PgorICAgICAgICAgICAgICAgIG1hcChFaXRoZXI6OmxlZnQpLm9yRWxzZUdldCgoKSAtPiBFaXRoZXIucmlnaHQoZ2V0Q29tcG9uZW50c1V0aWxzKCkKKyAgICAgICAgICAgICAgICAuZ2V0UmVzcG9uc2VGb3JtYXQoQWN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mVzcG9uc2UocmVzcG9uc2VGb3JtYXQpOw0KLSAgICAgICAgfQ0KLSAgICB9DQotfQ0KZGlmZiAtLWdpdCBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9SZXNvdXJjZUFydGlmYWN0RG93bmxvYWRTZXJ2bGV0LmphdmEgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvUmVzb3VyY2VBcnRpZmFjdERvd25sb2FkU2VydmxldC5qYXZhCmRlbGV0ZWQgZmlsZSBtb2RlIDEwMDY0NAppbmRleCA5MzJkYzUxLi4wMDAwMDAwCi0tLSBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9SZXNvdXJjZUFydGlmYWN0RG93bmxvYWRTZXJ2bGV0LmphdmEKKysrIC9kZXYvbnVsbApAQCAtMSwxMzggKzAsMCBAQAotLyotCi0gKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogU0RDCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOwotICogeW91IG1heSBub3QgdXNlIHRoaXM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VlLnRvU3RyaW5nKCkpOw0KLSAgICAgICAgICAgICAgICBzZXJ2aWNlQ29uc3VtcHRpb25EYXRhTWFwLnB1dElmQWJzZW50KG9wZXJhdGlvbklkLCBuZXcgQXJyYXlMaXN0PD4oKSk7DQotICAgICAgICAgICAgICAgIGZvciAoT2JqZWN0IGNvbnN1bXB0aW9uT2JqZWN0IDogaW5wdXRzQXJyYXkpIHsNCi0gICAgICAgICAgICAgICAgICAgIEVpdGhlcjxTZXJ2aWNlQ29uc3VtcHRpb25EYXRhLCBSZXNwb25zZUZvcm1hdD4gc2VydmljZURhdGFFaXRoZXIgPQ0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXRDb21wb25lbnRzVXRpbHMoKS5jb252ZXJ0SnNvblRvT2JqZWN0VXNpbmdPYmplY3RNYXBwZXIoY29uc3VtcHRpb25PYmplY3QudG9TdHJpbmcoKSwNCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2VyLCBTZXJ2aWNlQ29uc3VtcHRpb25EYXRhLmNsYXNzLCBBdWRpdGluZ0FjdGlvbkVudW0uQ1JFQVRFX1JFU09VUkNFLA0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbXBvbmVudFR5cGVFbnVtLlNFUlZJQ0UpOw0KLSAgICAgICAgICAgICAgICAgICAgaWYgKHNlcnZpY2VEYXRhRWl0aGVyLmlzUmlnaHQoKSkgew0KLSAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQoc2VydmljZURhdGFFaXRoZXIucmlnaHQoKS52YWx1ZSgpKTsNCi0gICAgICAgICAgICAgICAgICAgIH0NCi0NCi0gICAgICAgICAgICAgICAgICAgIHNlcnZpY2VDb25zdW1wdGlvbkRhdGFNYXAuZ2V0KG9wZXJhdGlvbklkKS5hZGQoc2VydmljZURhdGFFaXRoZXIubGVmdCgpLnZhbHVlKCkpOw0KLSAgICAgICAgICAgICAgICB9DQotICAgICAgICAg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AgICAgICAgaWYgKGNvbnZlcnRSZXNwb25zZS5pc1JpZ2h0KCkpIHsNCi0gICAgICAgICAgICAgICAgbG9nLmRlYnVnKEZBSUxFRF9UT19QQVJTRV9TRVJWSUNFKTsNCi0gICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBidWlsZEVycm9yUmVzcG9uc2UoY29udmVydFJlc3BvbnNlLnJpZ2h0KCkudmFsdWUoKSk7DQotICAgICAgICAgICAgICAgIHJldHVybiByZXNwb25zZTsNCi0gICAgICAgICAgICB9DQotICAgICAgICAgICAgVUlDb25zdHJhaW50IHVpQ29uc3RyYWludCA9IGNvbnZlcnRSZXNwb25zZS5sZWZ0KCkudmFsdWUoKTsNCi0gICAgICAgICAgICBpZiAodWlDb25zdHJhaW50ID09IG51bGwpIHsNCi0gICAgICAgICAgICAgICAgbG9nLmRlYnVnKEZBSUxFRF9UT19QQVJTRV9TRVJWSUNFKTsNCi0gICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBidWlsZEVycm9yUmVzcG9uc2UoY29udmVydFJlc3BvbnNlLnJpZ2h0KCkudmFsdWUoKSk7DQotICAgICAgICAgICAgICAgIHJldHVybiByZXNwb25zZTsNCi0gICAgICAgICAgICB9DQotICAgICAgICAgICAgRWl0aGVyPENJTm9kZUZpbHRlckRhdGFEZWZpbml0aW9uLCBSZXNwb25zZUZvcm1hdD4gYWN0aW9uUmVzcG9uc2U7DQotICAgICAgICAgICAgU3RyaW5nIGNvbnN0cmFpbnQgPSBuZXcgQ29uc3RyYWludENvbnZlcnRvcigpLmNvbnZlcnQodWlDb25zdHJhaW50KTsNCi0gICAgICAgICAgICBhY3Rpb25SZXNwb25zZSA9IHNlcnZpY2VCdXNpbmVzc0xvZ2ljDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5hZGRPckRlbGV0ZVNlcnZpY2VGaWx0ZXIoc2VydmljZUlkTG93ZXIsIGNpSWQsIE5vZGVGaWx0ZXJDb25zdHJhaW50QWN0aW9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Rpb25SZXNwb25zZTsNCi0gICAgICAgICAgICBhY3Rpb25SZXNwb25zZSA9IHNlcnZpY2VCdXNpbmVzc0xvZ2ljDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5hZGRPckRlbGV0ZVNlcnZpY2VGaWx0ZXIoc2VydmljZUlkTG93ZXIsIGNpSWQsIE5vZGVGaWx0ZXJDb25zdHJhaW50QWN0aW9uLkRFTEVURSwNCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBudWxsLCBudWxsLCAgaW5kZXgsIG1vZGlmaWVyLCB0cnVlKTsNCi0NCi0gICAgICAgICAgICBpZiAoYWN0aW9uUmVzcG9uc2UuaXNSaWdodCgpKSB7DQotDQotICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZyhGQUlMRURfVE9fVVBEQVRFX09SX0NSRUFURV9OT0RFX0ZJTFRFUik7DQotICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gYnVpbGRFcnJvclJlc3BvbnNlKGFjdGlvblJlc3BvbnNlLnJpZ2h0KCkudmFsdWUoKSk7DQotICAgICAgICAgICAgICAgIHJldHVybiByZXNwb25zZTsNCi0gICAgICAgICAgICB9DQotDQotICAgICAgICAgICAgZmluYWwgQ0lOb2RlRmlsdGVyRGF0YURlZmluaXRpb24gdmFsdWUgPSBhY3Rpb25SZXNwb25zZS5sZWZ0KCkudmFsdWUoKTsNCi0gICAgICAgICAgICByZXR1cm4gYnVpbGRPa1Jlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5PSyksDQotICAgICAgICAgICAgICAgICAgICBuZXcgTm9kZUZpbHRlckNvbnZlcnRlcigpLmNvbnZlcnRUb1VpKHZhbHVlKSk7DQotDQotICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZSkgew0KLSAgICAgICAgICAgIEJlRWNvbXBFcnJvck1hbmFnZXIuZ2V0SW5zdGF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ICAgICAgICBBdWRpdGluZ0FjdGlvbkVudW0uQ1JFQVRFX1JFU09VUkNFLCBDb21wb25lbnRUeXBlRW51bS5TRVJWSUNFKTsNCi0gICAgfQ0KLX0NCisvKi0KKyAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBTREMKKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBDb3B5cmlnaHQgKEMpIDIwMTkgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7CisgKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCisgKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKKyAqIAorICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKKyAqIAorICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZQorICogZGlzdHJpYnV0ZWQgdW5kZXIgdGhlIExpY2Vuc2UgaXMgZGlzdHJpYnV0ZWQgb24gYW4gIkFTIElTIiBCQVNJUywKKyAqIFdJVEhPVVQgV0FSUkFOVElFUyBPUiBDT05ESVRJT05TIE9GIEFOWSBLSU5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A9IHJlcXVlc3QuZ2V0U2Vzc2lvbigpOworICAgICAgICBTZXJ2bGV0Q29udGV4dCBjb250ZXh0ID0gc2Vzc2lvbi5nZXRTZXJ2bGV0Q29udGV4dCgpOworICAgICAgICBVc2VyIG1vZGlmaWVyID0gbmV3IFVzZXIoKTsKKyAgICAgICAgbW9kaWZpZXIuc2V0VXNlcklkKHVzZXJJZCk7CisgICAgICAgIGxvZy5kZWJ1ZyhNT0RJRklFUl9JRF9JUywgdXNlcklkKTsKKworICAgICAgICBSZXNwb25zZSByZXNwb25zZTsKKworICAgICAgICB0cnkgeworICAgICAgICAgICAgU3RyaW5nIHNlcnZpY2VJZExvd2VyID0gc2VydmljZUlkLnRvTG93ZXJDYXNlKCk7CisKKyAgICAgICAgICAgIEVpdGhlcjxVSUNvbnN0cmFpbnQsIFJlc3BvbnNlRm9ybWF0PiBjb252ZXJ0UmVzcG9uc2UgPSBwYXJzZVRvQ29uc3RyYWludChkYXRhLCBtb2RpZmllcik7CisgICAgICAgICAgICBpZiAoY29udmVydFJlc3BvbnNlLmlzUmlnaHQoKSkgeworICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZyhGQUlMRURfVE9fUEFSU0VfU0VSVklDRSk7CisgICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBidWlsZEVycm9yUmVzcG9uc2UoY29udmVydFJlc3BvbnNlLnJpZ2h0KCkudmFsdWUoKSk7CisgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3BvbnNlOworICAgICAgICAgICAgfQorICAgICAgICAgICAgVUlDb25zdHJhaW50IHVpQ29uc3RyYWludCA9IGNvbnZlcnRSZXNwb25zZS5sZWZ0KCkudmFsdWUoKTsKKyAgICAgICAgICAgIGlmICh1aUNvbnN0cmFpbnQgPT0gbnVsbCkgeworICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZyhGQUlMRURfVE9fUEFSU0VfU0VSVklDRSk7CisgICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBidWlsZEVycm9yUmVzcG9uc2UoY29udmVydFJlc3BvbnNlLnJpZ2h0KCkudmFsdWUoKSk7CisgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3BvbnNlOworICAgICAgICAgICAgfQorICAgICAgICAgICAgRWl0aGVyPENJTm9kZUZpbHRlckRhdGFEZWZpbml0aW9uLCBSZXNwb25zZUZvcm1hdD4gYWN0aW9uUmVzcG9uc2U7CisgICAgICAgICAgICBTdHJpbmcgY29uc3RyYWludCA9IG5ldyBDb25zdHJhaW50Q29udmVydG9yKCkuY29udmVydCh1aUNvbnN0cmFpbnQpOworICAgICAgICAgICAgYWN0aW9uUmVzcG9uc2UgPSBzZXJ2aWNlQnVzaW5lc3NMb2dpYworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5hZGRPckRlbGV0ZVNlcnZpY2VGaWx0ZXIoc2VydmljZUlkTG93ZXIsIGNpSWQsIE5vZGVGaWx0ZXJDb25zdHJhaW50QWN0aW9uLkFERCwgdWlDb25zdHJhaW50LmdldFNlcnZpY2VQcm9wZXJ0eU5hbWUoKSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0cmFpbnQsIC0xLCBtb2RpZmllciwgdHJ1ZSk7CisKKyAgICAgICAgICAgIGlmIChhY3Rpb25SZXNwb25zZS5pc1JpZ2h0KCkpIHsKKyAgICAgICAgICAgICAgICBsb2cuZGVidWcoRkFJTEVEX1RPX1VQREFURV9PUl9DUkVBVEVfTk9ERV9GSUxURVIpOworICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gYnVpbGRFcnJvclJlc3BvbnNlKGFjdGlvblJlc3BvbnNlLnJpZ2h0KCkudmFsdWUoKSk7CisgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3BvbnNlOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICBDSU5vZGVGaWx0ZXJEYXRhRGVmaW5pdGlvbiB2YWx1ZSA9IGFjdGlvblJlc3BvbnNlLmxlZnQoKS52Y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IGNpSWQsCisgICAgICAgICAgICBAQ29udGV4dCBmaW5hbCBIdHRwU2VydmxldFJlcXVlc3QgcmVxdWVzdCwgQEhlYWRlclBhcmFtKHZhbHVlID0gQ29uc3RhbnRzLlVTRVJfSURfSEVBREVSKSBTdHJpbmcgdXNlcklkKSB7CisgICAgICAgIFNlcnZsZXRDb250ZXh0IGNvbnRleHQgPSByZXF1ZXN0LmdldFNlc3Npb24oKS5nZXRTZXJ2bGV0Q29udGV4dCgpOworICAgICAgICBTdHJpbmcgdXJsID0gcmVxdWVzdC5nZXRNZXRob2QoKSArICIgIiArIHJlcXVlc3QuZ2V0UmVxdWVzdFVSSSgpOworICAgICAgICBsb2cuZGVidWcoU1RBUlRfSEFORExFX1JFUVVFU1RfT0YsIHVybCk7CisKKyAgICAgICAgVXNlciBtb2RpZmllciA9IG5ldyBVc2VyKCk7CisgICAgICAgIG1vZGlmaWVyLnNldFVzZXJJZCh1c2VySWQpOworICAgICAgICBsb2cuZGVidWcoTU9ESUZJRVJfSURfSVMsIHVzZXJJZCk7CisKKyAgICAgICAgUmVzcG9uc2UgcmVzcG9uc2U7CisKKyAgICAgICAgdHJ5IHsKKyAgICAgICAgICAgIFN0cmluZyBzZXJ2aWNlSWRMb3dlciA9IHNlcnZpY2VJZC50b0xvd2VyQ2FzZSgpOworCisgICAgICAgICAgICBFaXRoZXI8TGlzdCwgUmVzcG9uc2VGb3JtYXQ+IGNvbnZlcnRSZXNwb25zZSA9IHBhcnNlVG9Db25zdHJhaW50cyhkYXRhLCBtb2RpZmllcik7CisgICAgICAgICAgICBpZiAoY29udmVydFJlc3BvbnNlLmlzUmlnaHQoKSkgeworICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZyhGQUlMRURfVE9fUEFSU0VfU0VSVklDRSk7CisgICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBidWlsZEVycm9yUmVzcG9uc2UoY29udmVydFJlc3BvbnNlLnJpZ2h0KCkudmFsdWUoKSk7CisgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3BvbnNlOworICAgICAgICAgICAgfQorICAgICAgICAgICAgTGlzdDxNYXA8U3RyaW5nLFN0cmluZz4+IHVpQ29uc3RyYWludHNNYXBzID0gKExpc3Q8TWFwPFN0cmluZyxTdHJpbmc+PikgY29udmVydFJlc3BvbnNlLmxlZnQoKS52YWx1ZSgpOworICAgICAgICAgICAgaWYgKHVpQ29uc3RyYWludHNNYXBzID09IG51bGwpIHsKKyAgICAgICAgICAgICAgICBsb2cuZGVidWcoImZhaWxlZCB0byBwYXJzZSBkYXRhIik7CisgICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBidWlsZEVycm9yUmVzcG9uc2UoY29udmVydFJlc3BvbnNlLnJpZ2h0KCkudmFsdWUoKSk7CisgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3BvbnNlOworICAgICAgICAgICAgfQorICAgICAgICAgICAgZmluYWwgT2JqZWN0TWFwcGVyIG9iamVjdE1hcHBlciA9IG5ldyBPYmplY3RNYXBwZXIoKTsKKyAgICAgICAgICAgIExpc3Q8VUlDb25zdHJhaW50PiB1aUNvbnN0cmFpbnRzID0gdWlDb25zdHJhaW50c01hcHMuc3RyZWFtKCkubWFwKGRhdGFNYXAgLT4gb2JqZWN0TWFwcGVyLmNvbnZlcnRWYWx1ZShkYXRhTWFwLCBVSUNvbnN0cmFpbnQuY2xhc3MpKS5jb2xsZWN0KAorICAgICAgICAgICAgICAgICAgICBDb2xsZWN0b3JzLnRvTGlzdCgpKTsKKyAgICAgICAgICAgIGlmICh1aUNvbnN0cmFpbnRzID09IG51bGwpIHsKKyAgICAgICAgICAgICAgICBsb2cuZGVidWcoImZhaWxlZCB0byBwYXJzZSBkYXRhIik7CisgICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBidWlsZEVycm9yUmVzcG9uc2UoY29udmVydFJlc3BvbnNlLnJpZ2h0KCkudmFsdWUoKSk7CisgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3BvbnNlOworICAgICAgICAg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ICAgIGxvZy5kZWJ1ZyhTVEFSVF9IQU5ETEVfUkVRVUVTVF9PRiwgdXJsKTsKKworICAgICAgICBVc2VyIG1vZGlmaWVyID0gbmV3IFVzZXIoKTsKKyAgICAgICAgbW9kaWZpZXIuc2V0VXNlcklkKHVzZXJJZCk7CisgICAgICAgIGxvZy5kZWJ1ZyhNT0RJRklFUl9JRF9JUywgdXNlcklkKTsKKworICAgICAgICBSZXNwb25zZSByZXNwb25zZTsKKworICAgICAgICB0cnkgeworICAgICAgICAgICAgU3RyaW5nIHNlcnZpY2VJZExvd2VyID0gc2VydmljZUlkLnRvTG93ZXJDYXNlKCk7CisKKyAgICAgICAgICAgIEVpdGhlcjxDSU5vZGVGaWx0ZXJEYXRhRGVmaW5pdGlvbiwgUmVzcG9uc2VGb3JtYXQ+IGFjdGlvblJlc3BvbnNlOworICAgICAgICAgICAgYWN0aW9uUmVzcG9uc2UgPSBzZXJ2aWNlQnVzaW5lc3NMb2dpYworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5hZGRPckRlbGV0ZVNlcnZpY2VGaWx0ZXIoc2VydmljZUlkTG93ZXIsIGNpSWQsIE5vZGVGaWx0ZXJDb25zdHJhaW50QWN0aW9uLkRFTEVURSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG51bGwsIG51bGwsICBpbmRleCwgbW9kaWZpZXIsIHRydWUpOworCisgICAgICAgICAgICBpZiAoYWN0aW9uUmVzcG9uc2UuaXNSaWdodCgpKSB7CisKKyAgICAgICAgICAgICAgICBsb2cuZGVidWcoRkFJTEVEX1RPX1VQREFURV9PUl9DUkVBVEVfTk9ERV9GSUxURVIpOworICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gYnVpbGRFcnJvclJlc3BvbnNlKGFjdGlvblJlc3BvbnNlLnJpZ2h0KCkudmFsdWUoKSk7CisgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3BvbnNlOworICAgICAgICAgICAgfQor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yotDQotICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NCi0gKiBTREMNCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLSAqIENvcHlyaWdodCAoQykgMjAxOSBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLSAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOw0KLSAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4NCi0gKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQNCi0gKiANCi0gKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMA0KLSAqIA0KLSAqIFVubGVzcyByZXF1aXJlZCBieSBhcHBsaWNhYmxlIGxhdyBvciBhZ3JlZWQgdG8gaW4gd3JpdGluZywgc29mdHdhcmUNCi0gKiBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0cmlidXRlZCBvbiBhbiAiQVMgSVMiIEJBU0lTLA0KLSAqIFdJVEhPVVQgV0FSUkFOVElFUyBPUiBDT05ESVRJT05TIE9GIEFOWSBLSU5ELCBlaXRoZXIgZXhwcmVzcyBvciBpbXBsaWVkLg0KLSAqIFNlZSB0aGUgTGljZW5zZSBmb3IgdGhlIHNwZW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GlscygpLmNvbnZlcnRKc29uVG9PYmplY3RVc2luZ09iamVjdE1hcHBlcihzZXJ2aWNlSnNvbiwgdXNlciwgU2VydmljZS5jbGFzcywgQXVkaXRpbmdBY3Rpb25FbnVtLkNSRUFURV9SRVNPVVJDRSwgQ29tcG9uZW50VHlwZUVudW0uU0VSVklDRSk7Ly9UT0RPOiBjaGFuZ2Ugc1NFUlZJQ0UgY29uc3RhbnQNCi0gICAgfQ0KLX0NCisvKi0KKyAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBTREMKKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBDb3B5cmlnaHQgKEMpIDIwMTkgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7CisgKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCisgKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKKyAqIAorICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKKyAqIAorICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZQorICogZGlzdHJpYnV0ZWQ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coU1RBUlRfSEFORExFX1JFUVVFU1RfT0YsIHVybCk7CisKKyAgICAgICAgVXNlciBtb2RpZmllciA9IG5ldyBVc2VyKCk7CisgICAgICAgIG1vZGlmaWVyLnNldFVzZXJJZCh1c2VySWQpOworICAgICAgICBsb2cuZGVidWcoTU9ESUZJRVJfSURfSVMsIHVzZXJJZCk7CisKKworICAgICAgICB0cnkgeworICAgICAgICAgICAgRWl0aGVyPFVpQ29tcG9uZW50RGF0YVRyYW5zZmVyLCBSZXNwb25zZUZvcm1hdD4gc2VydmljZVJlc3BvbnNlID0gc2VydmljZUJ1c2luZXNzTG9naWMuZ2V0Q29tcG9uZW50RGF0YUZpbHRlcmVkQnlQYXJhbXMoc2VydmljZUlkLCBtb2RpZmllciwgQ29sbGVjdGlvbnMuc2luZ2xldG9uTGlzdChDb21wb25lbnRGaWVsZHNFbnVtLkZPUldBUkRJTkdfUEFUSFMuZ2V0VmFsdWUoKSkpOworICAgICAgICAgICAgaWYgKHNlcnZpY2VSZXNwb25zZS5pc1JpZ2h0KCkpIHsKKyAgICAgICAgICAgICAgICByZXR1cm4gYnVpbGRFcnJvclJlc3BvbnNlKHNlcnZpY2VSZXNwb25zZS5yaWdodCgpLnZhbHVlKCkpOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICBVaVNlcnZpY2VEYXRhVHJhbnNmZXIgdWlTZXJ2aWNlRGF0YVRyYW5zZmVyID0gKFVpU2VydmljZURhdGFUcmFuc2Zlcikgc2VydmljZVJlc3BvbnNlLmxlZnQoKS52YWx1ZSgpOworCisgICAgICAgICAgICBGb3J3YXJkaW5nUGF0aERhdGFEZWZpbml0aW9uIGZvcndhcmRpbmdQYXRoRGF0YURlZmluaXRpb24gPSBuZXcgRm9yd2FyZGluZ1BhdGhEYXRhRGVmaW5pdGlvbigpOworICAgICAgICAgICAgaWYgKCFNYXBVdGlscy5pc0VtcHR5KHVpU2VydmljZURhdGFUcmFuc2Zlci5nZXRGb3J3YXJkaW5nUGF0aHMoKSk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U2VydmljZVNlcnZsZXQuamF2YQorKysgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvU2VydmljZVNlcnZsZXQuamF2YQpAQCAtMSw3NzAgKzEsNzI0IEBACi0vKi0NCi0gKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLSAqIFNEQw0KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7DQotICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLg0KLSAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdA0KLSAqIA0KLSAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wDQotICogDQotICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZQ0KLSAqIGRpc3RyaWJ1dGVkIHVuZGVyIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1dGVkIG9uIGFuICJBUyBJUyIgQkFTSVMsDQotIC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JhcHBlcjxDb21wb25lbnRUeXBlRW51bT4gY29tcG9uZW50V3JhcHBlciA9IG5ldyBXcmFwcGVyPD4oKTsNCi0gICAgICAgIHRyeSB7DQotICAgICAgICAgICAgdmFsaWRhdGVVc2VyRXhpc3QocmVzcG9uc2VXcmFwcGVyLCB1c2VyV3JhcHBlciwgdXNlcklkKTsNCi0NCi0gICAgICAgICAgICBpZiAocmVzcG9uc2VXcmFwcGVyLmlzRW1wdHkoKSkgew0KLSAgICAgICAgICAgICAgICB2YWxpZGF0ZUNvbXBvbmVudFR5cGUocmVzcG9uc2VXcmFwcGVyLCBjb21wb25lbnRXcmFwcGVyLCBjb21wb25lbnRUeXBlKTsNCi0gICAgICAgICAgICB9DQotDQotICAgICAgICAgICAgaWYgKHJlc3BvbnNlV3JhcHBlci5pc0VtcHR5KCkpIHsNCi0gICAgICAgICAgICAgICAgZmlsbFVVSURBbmRWZXJzaW9uKHJlc3BvbnNlV3JhcHBlciwgdXVpZFdyYXBwZXIsIHZlcnNpb25XcmFwcGVyLCB1c2VyV3JhcHBlci5nZXRJbm5lckVsZW1lbnQoKSwNCi0gICAgICAgICAgICAgICAgICAgICAgICBjb21wb25lbnRXcmFwcGVyLmdldElubmVyRWxlbWVudCgpLCBjb21wb25lbnRVbmlxdWVJZCwgY29udGV4dCk7DQotICAgICAgICAgICAgfQ0KLQ0KLSAgICAgICAgICAgIGlmIChyZXNwb25zZVdyYXBwZXIuaXNFbXB0eSgpKSB7DQotICAgICAgICAgICAgICAgIEVpdGhlcjxMaXN0PE1hcDxTdHJpbmcsIE9iamVjdD4+LCBSZXNwb25zZUZvcm1hdD4gZWl0aGVyU2VydmljZUF1ZGl0ID0NCi0gICAgICAgICAgICAgICAgICAgICAgICBzZXJ2aWNlQnVzaW5lc3NMb2dpYy5nZXRDb21wb25lbnRBdWRpdFJlY29yZHModmVyc2lvbldyYXBwZXIuZ2V0SW5uZXJFbGVtZW50KCksDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICA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DQotDQotfQ0KKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAxNyBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKKyAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KKyAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAorICoKKyAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wCisgKgorICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZQorICogZGlzdHJpYnV0ZWQgdW5kZXIgdGhlIExpY2Vuc2UgaXMgZGlzdHJpYnV0ZWQgb24gYW4gIkFTIElTIiBCQVNJUywKKyAqIFdJVEhPVVQgV0FSUkFOVElFUyBPUiBDT05ESVRJT05TIE9GIEFOWSBLSU5ELCBlaXRoZXIgZXhwcmVzcyBvciBpbXBsaWVkLgorICogU2VlIHRoZSBMaWNlbnNlIGZvciB0aGUgc3BlY2lmaWMgbGFuZ3VhZ2UgZ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ZCwgU2VydmxldENvbnRleHQgY29udGV4dCkgeworCisgICAgICAgIGlmIChjb21wb25lbnRUeXBlRW51bSA9PSBDb21wb25lbnRUeXBlRW51bS5SRVNPVVJDRSkgeworICAgICAgICAgICAgRWl0aGVyPFJlc291cmNlLCBSZXNwb25zZUZvcm1hdD4gZWl0aGVyUmVzb3VyY2UgPSBnZXRSZXNvdXJjZUJMKGNvbnRleHQpLmdldFJlc291cmNlKGNvbXBvbmVudFVuaXF1ZUlkLCB1c2VyKTsKKyAgICAgICAgICAgIGlmIChlaXRoZXJSZXNvdXJjZS5pc0xlZnQoKSkgeworICAgICAgICAgICAgICAgIHV1aWRXcmFwcGVyLnNldElubmVyRWxlbWVudChlaXRoZXJSZXNvdXJjZS5sZWZ0KCkudmFsdWUoKS5nZXRVVUlEKCkpOworICAgICAgICAgICAgICAgIHZlcnNpb25XcmFwcGVyLnNldElubmVyRWxlbWVudChlaXRoZXJSZXNvdXJjZS5sZWZ0KCkudmFsdWUoKS5nZXRWZXJzaW9uKCkpOworICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICByZXNwb25zZVdyYXBwZXIuc2V0SW5uZXJFbGVtZW50KGJ1aWxkRXJyb3JSZXNwb25zZShlaXRoZXJSZXNvdXJjZS5yaWdodCgpLnZhbHVlKCkpKTsKKyAgICAgICAgICAgIH0KKworICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgRWl0aGVyPFNlcnZpY2UsIFJlc3BvbnNlRm9ybWF0PiBlaXRoZXJTZXJ2aWNlID0gZ2V0U2VydmljZUJMKGNvbnRleHQpLmdldFNlcnZpY2UoY29tcG9uZW50VW5pcXVlSWQsIHVzZXIpOworICAgICAgICAgICAgaWYgKGVpdGhlclNlcnZpY2UuaXNMZWZ0KCkpIHsKKyAgICAgICAgICAgICAgICB1dWlkV3JhcHBlci5zZXRJbm5lckVsZW1lbnQoZWl0aGVyU2VydmljZS5sZWZ0KCkudmFsdWUoKS5nZXRVVUlEKCkpOwor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c2luZyBjb250ZW50IiksCisgICAgICAgICAgICBAQXBpUmVzcG9uc2UocmVzcG9uc2VDb2RlID0gIjQwNCIsIGRlc2NyaXB0aW9uID0gIlNlcnZpY2Ugbm90IGZvdW5kIikgfSkKKyAgICBAUGVybWlzc2lvbkFsbG93ZWQoQWFmUGVybWlzc2lvbi5QZXJtTmFtZXMuSU5URVJOQUxfQUxMX1ZBTFVFKQorICAgIHB1YmxpYyBSZXNwb25zZSBkZWxldGVTZXJ2aWNlQnlOYW1lQW5kVmVyc2lvbihAUGF0aFBhcmFtKCJzZXJ2aWNlTmFtZSIpIGZpbmFsIFN0cmluZyBzZXJ2aWNlTmFtZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQFBhdGhQYXJhbSgidmVyc2lvbiIpIGZpbmFsIFN0cmluZyB2ZXJzaW9uLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBAQ29udGV4dCBmaW5hbCBIdHRwU2VydmxldFJlcXVlc3QgcmVxdWVzdCkgeworICAgICAgICBTdHJpbmcgdXJsID0gcmVxdWVzdC5nZXRNZXRob2QoKSArICIgIiArIHJlcXVlc3QuZ2V0UmVxdWVzdFVSSSgpOworICAgICAgICBsb2cuZGVidWcoU1RBUlRfSEFORExFX1JFUVVFU1RfT0YsIHVybCk7CisKKyAgICAgICAgLy8gZ2V0IG1vZGlmaWVyIGlkCisgICAgICAgIFN0cmluZyB1c2VySWQgPSByZXF1ZXN0LmdldEhlYWRlcihDb25zdGFudHMuVVNFUl9JRF9IRUFERVIpOworICAgICAgICBVc2VyIG1vZGlmaWVyID0gbmV3IFVzZXIoKTsKKyAgICAgICAgbW9kaWZpZXIuc2V0VXNlcklkKHVzZXJJZCk7CisgICAgICAgIGxvZy5kZWJ1ZyhNT0RJRklFUl9JRF9JUywgdXNlcklkKTsKKworICAgICAgICBSZXNwb25zZSByZXNwb25zZSA9IG51bGw7CisKKyAgICA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ZSgpOworICAgICAgICAgICAgQXJyYXlMaXN0PEdyb3VwSW5zdGFuY2VQcm9wZXJ0eT4gbmV3UHJvcGVydGllcyA9IGdzb24uZnJvbUpzb24oZGF0YSwgbGlzdFR5cGUpOworICAgICAgICAgICAgaWYgKG5ld1Byb3BlcnRpZXMgPT0gbnVsbCkgeworICAgICAgICAgICAgICAgIGFjdGlvblJlc3BvbnNlID0gRWl0aGVyLnJpZ2h0KGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5JTlZBTElEX0NPTlRFTlQpKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGlmKGFjdGlvblJlc3BvbnNlID09IG51bGwpeworICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiU3RhcnQgaGFuZGxlIHVwZGF0ZSBncm91cCBpbnN0YW5jZSBwcm9wZXJ0eSB2YWx1ZXMgcmVxdWVzdC4gUmVjZWl2ZWQgZ3JvdXAgaW5zdGFuY2UgaXMge30iLCBncm91cEluc3RhbmNlSWQpOworICAgICAgICAgICAgICAgIGFjdGlvblJlc3BvbnNlID0gc2VydmljZUJ1c2luZXNzTG9naWMudXBkYXRlR3JvdXBJbnN0YW5jZVByb3BlcnR5VmFsdWVzKG1vZGlmaWVyLCBzZXJ2aWNlSWQsIGNvbXBvbmVudEluc3RhbmNlSWQsIGdyb3VwSW5zdGFuY2VJZCwgbmV3UHJvcGVydGllcyk7CisgICAgICAgICAgICAgICAgaWYoYWN0aW9uUmVzcG9uc2UuaXNSaWdodCgpKXsKKyAgICAgICAgICAgICAgICAgICAgYWN0aW9uUmVzcG9uc2UgPSBFaXRoZXIucmlnaHQoYWN0aW9uUmVzcG9uc2UucmlnaHQoKS52YWx1ZSgpKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9CisgICAgICAgICAgICBpZihhY3Rpb25SZXNwb25zZS5pc0xlZnQoKSl7CisgICAgICAgICAgICAgICAgdXBkYXRl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VzdC5nZXRSZXF1ZXN0VVJJKCk7CisgICAgICAgIGxvZy5kZWJ1ZyhTVEFSVF9IQU5ETEVfUkVRVUVTVF9PRiwgdXJsKTsKKworICAgICAgICAvLyBnZXQgbW9kaWZpZXIgaWQKKyAgICAgICAgVXNlciBtb2RpZmllciA9IG5ldyBVc2VyKCk7CisgICAgICAgIG1vZGlmaWVyLnNldFVzZXJJZCh1c2VySWQpOworICAgICAgICBsb2cuZGVidWcoTU9ESUZJRVJfSURfSVMsIHVzZXJJZCk7CisKKyAgICAgICAgUmVzcG9uc2UgcmVzcG9uc2UgPSBudWxsOworICAgICAgICB0cnkgeworICAgICAgICAgICAgU3RyaW5nIHNlcnZpY2VJZExvd2VyID0gc2VydmljZUlkLnRvTG93ZXJDYXNlKCk7CisgICAgICAgICAgICBsb2cuZGVidWcoImdldCBzZXJ2aWNlIHdpdGggaWQge30iLCBzZXJ2aWNlSWQpOworICAgICAgICAgICAgRWl0aGVyPFNlcnZpY2UsIFJlc3BvbnNlRm9ybWF0PiBhY3Rpb25SZXNwb25zZSA9IHNlcnZpY2VCdXNpbmVzc0xvZ2ljLmdldFNlcnZpY2Uoc2VydmljZUlkTG93ZXIsIG1vZGlmaWVyKTsKKworICAgICAgICAgICAgaWYgKGFjdGlvblJlc3BvbnNlLmlzUmlnaHQoKSkgeworICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiZmFpbGVkIHRvIGdldCBzZXJ2aWNlIik7CisgICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBidWlsZEVycm9yUmVzcG9uc2UoYWN0aW9uUmVzcG9uc2UucmlnaHQoKS52YWx1ZSgpKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gcmVzcG9uc2U7CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIFNlcnZpY2Ugc2VydmljZSA9IGFjdGlvblJlc3BvbnNlLmxlZnQoKS52YWx1ZSgpOworICAgICAgICAgICAgT2JqZWN0IHJlc3VsdCA9IFJlcHJlc2VudGF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MgSU9FeGNlcHRpb24geworCisgICAgICAgIFN0cmluZyB1cmwgPSByZXF1ZXN0LmdldE1ldGhvZCgpICsgIiAiICsgcmVxdWVzdC5nZXRSZXF1ZXN0VVJJKCk7CisgICAgICAgIGxvZy5kZWJ1ZyhTVEFSVF9IQU5ETEVfUkVRVUVTVF9PRiwgdXJsKTsKKworICAgICAgICAvLyBnZXQgbW9kaWZpZXIgaWQKKyAgICAgICAgVXNlciBtb2RpZmllciA9IG5ldyBVc2VyKCk7CisgICAgICAgIG1vZGlmaWVyLnNldFVzZXJJZCh1c2VySWQpOworICAgICAgICBsb2cuZGVidWcoTU9ESUZJRVJfSURfSVMsIHVzZXJJZCk7CisKKyAgICAgICAgUmVzcG9uc2UgcmVzcG9uc2UgPSBudWxsOworICAgICAgICB0cnkgeworICAgICAgICAgICAgU3RyaW5nIHNlcnZpY2VJZExvd2VyID0gc2VydmljZUlkLnRvTG93ZXJDYXNlKCk7CisgICAgICAgICAgICBsb2cuZGVidWcoImdldCBzZXJ2aWNlIGNvbXBvbmVudHMgcmVsYXRpb25zIHdpdGggaWQge30iLCBzZXJ2aWNlSWQpOworICAgICAgICAgICAgRWl0aGVyPFNlcnZpY2VSZWxhdGlvbnMsIFJlc3BvbnNlRm9ybWF0PiBhY3Rpb25SZXNwb25zZSA9IHNlcnZpY2VCdXNpbmVzc0xvZ2ljLmdldFNlcnZpY2VDb21wb25lbnRzUmVsYXRpb25zKHNlcnZpY2VJZExvd2VyLCBtb2RpZmllcik7CisKKyAgICAgICAgICAgIGlmIChhY3Rpb25SZXNwb25zZS5pc1JpZ2h0KCkpIHsKKyAgICAgICAgICAgICAgICBsb2cuZGVidWcoImZhaWxlZCB0byBnZXQgc2VydmljZSByZWxhdGlvbnMgZGF0YSIpOworICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gYnVpbGRFcnJvclJlc3BvbnNlKGFjdGlvblJlc3BvbnNlLnJpZ2h0KCkudmFsdWUoKSk7CisgICAgICAgICAgICAgICAgcm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rvc2NhRGFvU2VydmxldC5qYXZhCisrKyAvZGV2L251bGwKQEAgLTEsNTkgKzAsMCBAQAotLyotCi0gKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogU0RDCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOwotICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgotICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0Ci0gKiAKLSAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wCi0gKiAKLSAqIFVubGVzcyByZXF1aXJlZCBieSBhcHBsaWNhYmxlIGxhdyBvciBhZ3JlZWQgdG8gaW4gd3JpdGluZywgc29mdHdhcmUKLSAqIGRpc3RyaWJ1dGVkIHVuZGVyIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1dGVkIG9uIGFuICJBUyBJUyIgQkFTSVMsCi0gKiBXSVRIT1VUIFdBUlJBTlRJRVMgT1IgQ09ORElUSU9OUyBPRiBBTlkgS0lORCwgZWl0aGVyIGV4cHJlc3Mgb3IgaW1wbGllZC4KL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RpZXNCdXNpbmVzc0xvZ2ljLmdldEFsbENhcGFiaWxpdHlUeXBlcygpOw0KLQ0KLSAgICAgICAgICAgICAgICBpZiAoYWxsRGF0YVR5cGVzLmlzUmlnaHQoKSkgew0KLSAgICAgICAgICAgICAgICAgICAgbG9nLmluZm8oIkZhaWxlZCB0byBnZXQgYWxsIGNhcGFiaWxpdHkgdHlwZXMuIFJlYXNvbiAtIHt9IiwgYWxsRGF0YVR5cGVzLnJpZ2h0KCkudmFsdWUoKSk7DQotICAgICAgICAgICAgICAgICAgICBSZXNwb25zZSBlcnJvclJlc3BvbnNlID0gYnVpbGRFcnJvclJlc3BvbnNlKGFsbERhdGFUeXBlcy5yaWdodCgpLnZhbHVlKCkpOw0KLSAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2VXcmFwcGVyLnNldElubmVyRWxlbWVudChlcnJvclJlc3BvbnNlKTsNCi0NCi0gICAgICAgICAgICAgICAgfSBlbHNlIHsNCi0NCi0gICAgICAgICAgICAgICAgICAgIE1hcDxTdHJpbmcsIENhcGFiaWxpdHlUeXBlRGVmaW5pdGlvbj4gZGF0YVR5cGVzID0gYWxsRGF0YVR5cGVzLmxlZnQoKS52YWx1ZSgpOw0KLSAgICAgICAgICAgICAgICAgICAgU3RyaW5nIGRhdGFUeXBlSnNvbiA9IGdzb24udG9Kc29uKGRhdGFUeXBlcyk7DQotICAgICAgICAgICAgICAgICAgICBSZXNwb25zZSBva1Jlc3BvbnNlID0NCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVpbGRPa1Jlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5PSyksIGRhdGFUeXBlSnNvbik7DQotICAgICAgICAgICAgICAgICAgICByZXNwb25zZVdyYXBwZXIuc2V0SW5uZXJFbGVtZW50KG9rUmVzcG9uc2UpOw0KLQ0KLSAgICAgICAgICAgICAgICB9DQotICAgICAgICAgICAgfQ0KLQ0KL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CkudmFsdWUoKTsNCi0gICAgICAgICAgICAgICAgICAgIFN0cmluZyBkYXRhVHlwZUpzb24gPSBnc29uLnRvSnNvbihkYXRhVHlwZXMpOw0KLSAgICAgICAgICAgICAgICAgICAgUmVzcG9uc2Ugb2tSZXNwb25zZSA9DQotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ1aWxkT2tSZXNwb25zZShnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuT0spLCBkYXRhVHlwZUpzb24pOw0KLSAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2VXcmFwcGVyLnNldElubmVyRWxlbWVudChva1Jlc3BvbnNlKTsNCi0NCi0gICAgICAgICAgICAgICAgfQ0KLSAgICAgICAgICAgIH0NCi0NCi0gICAgICAgICAgICByZXR1cm4gcmVzcG9uc2VXcmFwcGVyLmdldElubmVyRWxlbWVudCgpOw0KLSAgICAgICAgfSBjYXRjaCAoRXhjZXB0aW9uIGUpIHsNCi0gICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nQmVSZXN0QXBpR2VuZXJhbEVycm9yKCJHZXQgUmVsYXRpb25zaGlwIFR5cGVzIik7DQotICAgICAgICAgICAgbG9nLmRlYnVnKCJnZXQgYWxsIHJlbGF0aW9uc2hpcCB0eXBlcyBmYWlsZWQgd2l0aCBleGNlcHRpb24iLCBlKTsNCi0gICAgICAgICAgICBSZXNwb25zZUZvcm1hdCByZXNwb25zZUZvcm1hdCA9IGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5HRU5FUkFMX0VSUk9SKTsNCi0gICAgICAgICAgICByZXR1cm4gYnVpbGRFcnJvclJlc3BvbnNlKHJlc3BvbnNlRm9ybWF0KTsNCi0gICAgICAgIH0NCi0gICAgfQ0KLQ0KLSAgICBAR0VUDQotICAgIEBQYXRoKCJub2RlVHlwZX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HVybiByZXNwb25zZS5yaWdodCgpLnZhbHVlKCk7DQotICAgICAgICAgICAgICAgIH0NCi0gICAgICAgICAgICAgICAgY29tcG9uZW50TWFwID0gbmV3IEhhc2hNYXA8PihyZXNwb25zZS5sZWZ0KCkudmFsdWUoKSk7DQotDQotICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gZ2V0Q29tcG9uZW50KHJlc291cmNlQnVzaW5lc3NMb2dpYywgZmFsc2UsIHVzZXJJZCk7DQotICAgICAgICAgICAgICAgIGlmIChyZXNwb25zZS5pc1JpZ2h0KCkpIHsNCi0gICAgICAgICAgICAgICAgICAgIHJldHVybiByZXNwb25zZS5yaWdodCgpLnZhbHVlKCk7DQotICAgICAgICAgICAgICAgIH0NCi0gICAgICAgICAgICAgICAgY29tcG9uZW50TWFwLnB1dEFsbChyZXNwb25zZS5sZWZ0KCkudmFsdWUoKSk7DQotDQotICAgICAgICAgICAgICAgIFN0cmluZyBub2RlVHlwZXNKc29uID0gZ3Nvbi50b0pzb24oY29tcG9uZW50TWFwKTsNCi0gICAgICAgICAgICAgICAgUmVzcG9uc2Ugb2tSZXNwb25zZSA9DQotICAgICAgICAgICAgICAgICAgICAgICAgYnVpbGRPa1Jlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5PSyksIG5vZGVUeXBlc0pzb24pOw0KLSAgICAgICAgICAgICAgICByZXNwb25zZVdyYXBwZXIuc2V0SW5uZXJFbGVtZW50KG9rUmVzcG9uc2UpOw0KLSAgICAgICAgICAgIH0NCi0NCi0gICAgICAgICAgICByZXR1cm4gcmVzcG9uc2VXcmFwcGVyLmdldElubmVyRWxlbWVudCgpOw0KLSAgICAgICAgfSBjYXRjaCAoRXhjZXB0aW9uIGUpIHsNCi0gICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nQmVSZXN0QXBpR2VuZXJhbEVycm9yKCJHZX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N0aW9uUmVzcG9uc2UuaXNSaWdodCgpKSB7DQotICAgICAgICAgICAgbG9nLmRlYnVnKEZBSUxFRF9UT19HRVRfQUxMX05PTl9BQlNUUkFDVCwgQ29tcG9uZW50VHlwZUVudW0uUkVTT1VSQ0UuZ2V0VmFsdWUoKSk7DQotICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChidWlsZEVycm9yUmVzcG9uc2UoYWN0aW9uUmVzcG9uc2UucmlnaHQoKS52YWx1ZSgpKSk7DQotICAgICAgICB9DQotDQotICAgICAgICBjb21wb25lbnRMaXN0ID0gYWN0aW9uUmVzcG9uc2UubGVmdCgpLnZhbHVlKCk7DQotDQotICAgICAgICByZXR1cm4gRWl0aGVyLmxlZnQoTGlzdFV0aWxzLmVtcHR5SWZOdWxsKGNvbXBvbmVudExpc3QpLnN0cmVhbSgpDQotICAgICAgICAgICAgICAgIC5maWx0ZXIoY29tcG9uZW50IC0+ICgoUmVzb3VyY2VNZXRhZGF0YURhdGFEZWZpbml0aW9uKSBjb21wb25lbnQNCi0gICAgICAgICAgICAgICAgICAgICAgICAuZ2V0Q29tcG9uZW50TWV0YWRhdGFEZWZpbml0aW9uKCkuZ2V0TWV0YWRhdGFEYXRhRGVmaW5pdGlvbigpKS5nZXRUb3NjYVJlc291cmNlTmFtZSgpICE9IG51bGwpDQotICAgICAgICAgICAgICAgIC5jb2xsZWN0KENvbGxlY3RvcnMudG9NYXAoDQotICAgICAgICAgICAgICAgICAgICAgICAgY29tcG9uZW50IC0+ICgoUmVzb3VyY2VNZXRhZGF0YURhdGFEZWZpbml0aW9uKSBjb21wb25lbnQNCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRDb21wb25lbnRNZXRhZGF0YURlZmluaXRpb24oKS5nZXRNZXRhZGF0YURhdGFEZWZpbml0aW9uKCkpLmdldFRvc2NhUmVzb3VyY2VOYW1lKCksDQotICAgICAgICAgICAgICAgICAgICAgICAgY29tcG9uZW50IC0+IGNvbXBvbmVudCwgKGNvbXBvbmVudDEsIGNvbXBvbmVudDIpIC0+IGNvbXBvbmVudDEpKSk7DQotICAgIH0NCi19DQorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgorICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0CisgKiAKKyAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wCisgKiAKKyAqIFVubGVzcyByZXF1aXJlZCBieSBhcHBsaWNhYmxlIGxhdyBvciBhZ3JlZWQgdG8gaW4gd3JpdGluZywgc29mdHdhcmUKKyAqIGRpc3RyaWJ1dGVkIHVuZGVyIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1dGVkIG9uIGFuICJBUyBJUyIgQkFTSVMsCisgKiBXSVRIT1VUIFdBUlJBTlRJRVMgT1IgQ09ORElUSU9OUyBPRiBBTlkgS0lORCwgZWl0aGVyIGV4cHJlc3Mgb3IgaW1wbG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WNlTGlmZWN5Y2xlVHlwZXMgPQorICAgICAgICAgICAgICAgICAgICAgICAgaW50ZXJmYWNlT3BlcmF0aW9uQnVzaW5lc3NMb2dpYy5nZXRBbGxJbnRlcmZhY2VMaWZlY3ljbGVUeXBlcygpOworCisgICAgICAgICAgICAgICAgaWYgKGFsbEludGVyZmFjZUxpZmVjeWNsZVR5cGVzLmlzUmlnaHQoKSkgeworICAgICAgICAgICAgICAgICAgICBsb2cuaW5mbygiRmFpbGVkIHRvIGdldCBhbGwgaW50ZXJmYWNlIGxpZmVjeWNsZSB0eXBlcy4gUmVhc29uIC0ge30iLAorICAgICAgICAgICAgICAgICAgICAgICAgYWxsSW50ZXJmYWNlTGlmZWN5Y2xlVHlwZXMucmlnaHQoKS52YWx1ZSgpKTsKKyAgICAgICAgICAgICAgICAgICAgUmVzcG9uc2UgZXJyb3JSZXNwb25zZSA9IGJ1aWxkRXJyb3JSZXNwb25zZShhbGxJbnRlcmZhY2VMaWZlY3ljbGVUeXBlcy5yaWdodCgpLnZhbHVlKCkpOworICAgICAgICAgICAgICAgICAgICByZXNwb25zZVdyYXBwZXIuc2V0SW5uZXJFbGVtZW50KGVycm9yUmVzcG9uc2UpOworCisgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgU3RyaW5nIGludGVyZmFjZUxpZmVjeWNsZVR5cGVKc29uID0gZ3Nvbi50b0pzb24oYWxsSW50ZXJmYWNlTGlmZWN5Y2xlVHlwZXMubGVmdCgpLnZhbHVlKCkpOworICAgICAgICAgICAgICAgICAgICBSZXNwb25zZSBva1Jlc3BvbnNlID0gYnVpbGRPa1Jlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5PSyksIGludGVyZmFjZUxpZmVjeWNsZVR5cGVKc29uKTsKKyAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2VXcmFwcGVyLnNldElubmVyRWxlbWVudChva1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c0VtcHR5KCkpIHsKKyAgICAgICAgICAgICAgICBTdHJpbmcgdXJsID0gcmVxdWVzdC5nZXRNZXRob2QoKSArICIgIiArIHJlcXVlc3QuZ2V0UmVxdWVzdFVSSSgpOworICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiU3RhcnQgaGFuZGxlIHJlcXVlc3Qgb2Yge30gfCBtb2RpZmllciBpZCBpcyB7fSIsIHVybCwgdXNlcklkKTsKKworICAgICAgICAgICAgICAgIEVpdGhlcjxNYXA8U3RyaW5nLCBDYXBhYmlsaXR5VHlwZURlZmluaXRpb24+LCBSZXNwb25zZUZvcm1hdD4gYWxsRGF0YVR5cGVzID0KKyAgICAgICAgICAgICAgICAgICAgY2FwYWJpbGl0aWVzQnVzaW5lc3NMb2dpYy5nZXRBbGxDYXBhYmlsaXR5VHlwZXMoKTsKKworICAgICAgICAgICAgICAgIGlmIChhbGxEYXRhVHlwZXMuaXNSaWdodCgpKSB7CisgICAgICAgICAgICAgICAgICAgIGxvZy5pbmZvKCJGYWlsZWQgdG8gZ2V0IGFsbCBjYXBhYmlsaXR5IHR5cGVzLiBSZWFzb24gLSB7fSIsIGFsbERhdGFUeXBlcy5yaWdodCgpLnZhbHVlKCkpOworICAgICAgICAgICAgICAgICAgICBSZXNwb25zZSBlcnJvclJlc3BvbnNlID0gYnVpbGRFcnJvclJlc3BvbnNlKGFsbERhdGFUeXBlcy5yaWdodCgpLnZhbHVlKCkpOworICAgICAgICAgICAgICAgICAgICByZXNwb25zZVdyYXBwZXIuc2V0SW5uZXJFbGVtZW50KGVycm9yUmVzcG9uc2UpOworCisgICAgICAgICAgICAgICAgfSBlbHNlIHsKKworICAgICAgICAgICAgICAgICAgICBNYXA8U3RyaW5nLCBDYXBhYmlsaXR5VHlwZURlZmluaXRpb24+IGRhdGFUeXBlcyA9IGFsbERhdGFUeXBlcy5sZWZ0KCkudmFsdWUoKTsKKyAgICAgICAgICAgICAgICAgICAgU3RyaW5nIGRhdGFUeXBlSnNvbiA9IGdzb24udG9Kc29uKGRhdGFUeXBlcyk7CisgICAgICAgICAgICAgICAgICAgIFJlc3BvbnNlIG9rUmVzcG9uc2UgPQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ1aWxkT2tSZXNwb25zZShnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuT0spLCBkYXRhVHlwZUpzb24pOworICAgICAgICAgICAgICAgICAgICByZXNwb25zZVdyYXBwZXIuc2V0SW5uZXJFbGVtZW50KG9rUmVzcG9uc2UpOworCisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfQorCisgICAgICAgICAgICByZXR1cm4gcmVzcG9uc2VXcmFwcGVyLmdldElubmVyRWxlbWVudCgpOworICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZSkgeworICAgICAgICAgICAgQmVFY29tcEVycm9yTWFuYWdlci5nZXRJbnN0YW5jZSgpLmxvZ0JlUmVzdEFwaUdlbmVyYWxFcnJvcigiR2V0IENhcGFiaWxpdHkgVHlwZXMiKTsKKyAgICAgICAgICAgIGxvZy5kZWJ1ZygiZ2V0IGFsbCBjYXBhYmlsaXR5IHR5cGVzIGZhaWxlZCB3aXRoIGV4Y2VwdGlvbiIsIGUpOworICAgICAgICAgICAgUmVzcG9uc2VGb3JtYXQgcmVzcG9uc2VGb3JtYXQgPSBnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUik7CisgICAgICAgICAgICByZXR1cm4gYnVpbGRFcnJvclJlc3BvbnNlKHJlc3BvbnNlRm9ybWF0KTsKKyAgICAgICAgfQorICAgIH0KKworICAgIEBHRVQKKyAgICBAUGF0aCgicmVsYXRpb25zaGlwVHlwZXMiKQorICAgIEBDb25zdW1lcyhNZWRpYVR5cGUuQVBQTElDQVRJT05fSlNPTikKKyAgICBAUHJvZHVjZXMoTWVkaWFUeXBlLkFQU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lKCkpOworICAgICAgICAgICAgICAgICAgICBSZXNwb25zZSBlcnJvclJlc3BvbnNlID0gYnVpbGRFcnJvclJlc3BvbnNlKGFsbERhdGFUeXBlcy5yaWdodCgpLnZhbHVlKCkpOworICAgICAgICAgICAgICAgICAgICByZXNwb25zZVdyYXBwZXIuc2V0SW5uZXJFbGVtZW50KGVycm9yUmVzcG9uc2UpOworCisgICAgICAgICAgICAgICAgfSBlbHNlIHsKKworICAgICAgICAgICAgICAgICAgICBNYXA8U3RyaW5nLCBSZWxhdGlvbnNoaXBUeXBlRGVmaW5pdGlvbj4gZGF0YVR5cGVzID0gYWxsRGF0YVR5cGVzLmxlZnQoKS52YWx1ZSgpOworICAgICAgICAgICAgICAgICAgICBTdHJpbmcgZGF0YVR5cGVKc29uID0gZ3Nvbi50b0pzb24oZGF0YVR5cGVzKTsKKyAgICAgICAgICAgICAgICAgICAgUmVzcG9uc2Ugb2tSZXNwb25zZSA9CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVpbGRPa1Jlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5PSyksIGRhdGFUeXBlSnNvbik7CisgICAgICAgICAgICAgICAgICAgIHJlc3BvbnNlV3JhcHBlci5zZXRJbm5lckVsZW1lbnQob2tSZXNwb25zZSk7CisKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIHJldHVybiByZXNwb25zZVdyYXBwZXIuZ2V0SW5uZXJFbGVtZW50KCk7CisgICAgICAgIH0gY2F0Y2ggKEV4Y2VwdGlvbiBlKSB7CisgICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nQmVSZXN0QXBpR2VuZXJhbEVycm9yKCJHZXQgUmVsYXRpb25zaGlwIFR5cGVzIik7CisgICAgICAgICAgICBsb2cuZGVidWcoImdldCBhbGwgcmVsYXRpb25zaGlwIHR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jb250ZW50IiksCisgICAgICAgICAgICBAQXBpUmVzcG9uc2UocmVzcG9uc2VDb2RlID0gIjQwNCIsIGRlc2NyaXB0aW9uID0gIk5vZGUgdHlwZXMgbm90IGZvdW5kIil9KQorICAgIEBQZXJtaXNzaW9uQWxsb3dlZChBYWZQZXJtaXNzaW9uLlBlcm1OYW1lcy5JTlRFUk5BTF9BTExfVkFMVUUpCisgICAgcHVibGljIFJlc3BvbnNlIGdldEFsbE5vZGVUeXBlc1NlcnZsZXQoQENvbnRleHQgZmluYWwgSHR0cFNlcnZsZXRSZXF1ZXN0IHJlcXVlc3QsIEBIZWFkZXJQYXJhbSh2YWx1ZSA9CisgICAgICAgICAgICBDb25zdGFudHMuVVNFUl9JRF9IRUFERVIpIFN0cmluZyB1c2VySWQpIHsKKworICAgICAgICBXcmFwcGVyPFJlc3BvbnNlPiByZXNwb25zZVdyYXBwZXIgPSBuZXcgV3JhcHBlcjw+KCk7CisgICAgICAgIFdyYXBwZXI8VXNlcj4gdXNlcldyYXBwZXIgPSBuZXcgV3JhcHBlcjw+KCk7CisgICAgICAgIFNlcnZsZXRDb250ZXh0IGNvbnRleHQgPSByZXF1ZXN0LmdldFNlc3Npb24oKS5nZXRTZXJ2bGV0Q29udGV4dCgpOworICAgICAgICBFaXRoZXI8TWFwPFN0cmluZywgQ29tcG9uZW50PiwgUmVzcG9uc2U+IHJlc3BvbnNlOworICAgICAgICBNYXA8U3RyaW5nLCBDb21wb25lbnQ+IGNvbXBvbmVudE1hcDsKKworICAgICAgICB0cnkgeworICAgICAgICAgICAgaW5pdCgpOworICAgICAgICAgICAgdmFsaWRhdGVVc2VyRXhpc3QocmVzcG9uc2VXcmFwcGVyLCB1c2VyV3JhcHBlciwgdXNlcklkKTsKKworICAgICAgICAgICAgaWYgKHJlc3BvbnNlV3JhcHBlci5pc0VtcHR5KCkpIHsKKyAgICAgICAgICAgICAgICBTdHJpbmcgdXJsID0gcmVxdWVzdC5nZXRNZXRob2QoKSArICIgIiArIHJlcXVlc3QuZ2V0UmVxdWVzdFVSSSgpOworICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiU3RhcnQgaGFuZGxlIHJlcXVlc3Qgb2Yge30gfCBtb2RpZmllciBpZCBpcyB7fSIsIHVybCwgdXNlcklkKTsKKworICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gZ2V0Q29tcG9uZW50KHJlc291cmNlQnVzaW5lc3NMb2dpYywgdHJ1ZSwgdXNlcklkKTsKKyAgICAgICAgICAgICAgICBpZiAocmVzcG9uc2UuaXNSaWdodCgpKSB7CisgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXNwb25zZS5yaWdodCgpLnZhbHVlKCk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGNvbXBvbmVudE1hcCA9IG5ldyBIYXNoTWFwPD4ocmVzcG9uc2UubGVmdCgpLnZhbHVlKCkpOworCisgICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBnZXRDb21wb25lbnQocmVzb3VyY2VCdXNpbmVzc0xvZ2ljLCBmYWxzZSwgdXNlcklkKTsKKyAgICAgICAgICAgICAgICBpZiAocmVzcG9uc2UuaXNSaWdodCgpKSB7CisgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXNwb25zZS5yaWdodCgpLnZhbHVlKCk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGNvbXBvbmVudE1hcC5wdXRBbGwocmVzcG9uc2UubGVmdCgpLnZhbHVlKCkpOworCisgICAgICAgICAgICAgICAgU3RyaW5nIG5vZGVUeXBlc0pzb24gPSBnc29uLnRvSnNvbihjb21wb25lbnRNYXApOworICAgICAgICAgICAgICAgIFJlc3BvbnNlIG9rUmVzcG9uc2UgPQorICAgICAgICAgICAgICAgICAgICAgICAgYnVpbGRPa1Jlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5PSyksIG5vZGVUeXBlc0pzb24pOworICAgICAgICAgICAgICAgIHJlc3BvbnNlV3JhcHBlci5zZXRJbm5lckVsZW1lbnQob2tSZXNwb25zZSk7CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIHJldHVybiByZXNwb25zZVdyYXBwZXIuZ2V0SW5uZXJFbGVtZW50KCk7CisgICAgICAgIH0gY2F0Y2ggKEV4Y2VwdGlvbiBlKSB7CisgICAgICAgICAgICBCZUVjb21wRXJyb3JNYW5hZ2VyLmdldEluc3RhbmNlKCkubG9nQmVSZXN0QXBpR2VuZXJhbEVycm9yKCJHZXQgTm9kZSBUeXBlcyIpOworICAgICAgICAgICAgbG9nLmRlYnVnKCJnZXQgYWxsIG5vZGUgdHlwZXMgZmFpbGVkIHdpdGggZXhjZXB0aW9uIiwgZSk7CisgICAgICAgICAgICBSZXNwb25zZUZvcm1hdCByZXNwb25zZUZvcm1hdCA9IGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5HRU5FUkFMX0VSUk9SKTsKKyAgICAgICAgICAgIHJldHVybiBidWlsZEVycm9yUmVzcG9uc2UocmVzcG9uc2VGb3JtYXQpOworICAgICAgICB9CisgICAgfQorCisgICAgcHJpdmF0ZSBFaXRoZXI8TWFwPFN0cmluZywgQ29tcG9uZW50PiwgUmVzcG9uc2U+IGdldENvbXBvbmVudChDb21wb25lbnRCdXNpbmVzc0xvZ2ljIHJlc291cmNlQkwsIGJvb2xlYW4gaXNBYnN0cmFjdCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZyB1c2VySWQpIHsKKyAgICAgICAgRWl0aGVyPExpc3Q8Q29tcG9uZW50PiwgUmVzcG9uc2VGb3JtYXQ+IGFjdGlvblJlc3BvbnNlOworICAgICAgICBMaXN0PENvbXBvbmVudD4gY29tcG9uZW50TGlzdDsKKworICAgICAgICBhY3Rpb25SZXNwb25zZSA9CisgICAgICAgICAgICAgICAgcmVzb3VyY2VCTC5nZXRMYXRlc3RWZXJzaW9uTm90QWJzdHJhY3RDb21wb25lbnRzTWV0YWRhdGEoaXNBYnN0cmFjdCwgSGlnaGVzdEZpbHRlckVudW0uSElHSEVTVF9PTkxZCisgICAgICAgICAgICAgICAgICAgICAgICAsIENvbXBvbmVudFR5cGVFbnVtLlJFU09VUkNFLCBudWxsLCB1c2VySWQpOworICAgICAgICBpZiAoYWN0aW9uUmVzcG9uc2UuaXNSaWdodCgpKSB7CisgICAgICAgICAgICBsb2cuZGVidWcoRkFJTEVEX1RPX0dFVF9BTExfTk9OX0FCU1RSQUNULCBDb21wb25lbnRUeXBlRW51bS5SRVNPVVJDRS5nZXRWYWx1ZSgpKTsKKyAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQoYnVpbGRFcnJvclJlc3BvbnNlKGFjdGlvblJlc3BvbnNlLnJpZ2h0KCkudmFsdWUoKSkpOworICAgICAgICB9CisKKyAgICAgICAgY29tcG9uZW50TGlzdCA9IGFjdGlvblJlc3BvbnNlLmxlZnQoKS52YWx1ZSgpOworCisgICAgICAgIHJldHVybiBFaXRoZXIubGVmdChMaXN0VXRpbHMuZW1wdHlJZk51bGwoY29tcG9uZW50TGlzdCkuc3RyZWFtKCkKKyAgICAgICAgICAgICAgICAuZmlsdGVyKGNvbXBvbmVudCAtPiAoKFJlc291cmNlTWV0YWRhdGFEYXRhRGVmaW5pdGlvbikgY29tcG9uZW50CisgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0Q29tcG9uZW50TWV0YWRhdGFEZWZpbml0aW9uKCkuZ2V0TWV0YWRhdGFEYXRhRGVmaW5pdGlvbigpKS5nZXRUb3NjYVJlc291cmNlTmFtZSgpICE9IG51bGwpCisgICAgICAgICAgICAgICAgLmNvbGxlY3QoQ29sbGVjdG9ycy50b01hcCgKKyAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBvbmVudCAtPiAoKFJlc291cmNlTWV0YWRhdGFEYXRhR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lL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvVHlwZXNVcGxvYWRTZXJ2bGV0LmphdmEKaW5kZXggZDFlZWY0OS4uZWQwZTI3YiAxMDA2NDQKLS0tIGEvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL3NlcnZsZXRzL1R5cGVzVXBsb2FkU2VydmxldC5qYXZhCisrKyBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9UeXBlc1VwbG9hZFNlcnZsZXQuamF2YQpAQCAtMSw0MDcgKzEsNDE3IEBACi0vKi0NCi0gKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLSAqIFNEQw0KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7DQotICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLg0KLSAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdA0KLSAqIA0KLSAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xp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I8RWxlbWVudFR5cGVEZWZpbml0aW9uLCBCb29sZWFuPj4gbGlzdCA9IGVpdGhlclJlc3VsdC5sZWZ0KCkudmFsdWUoKTsNCi0gICAgICAgICAgICAgICAgQWN0aW9uU3RhdHVzIHN0YXR1cyA9IEFjdGlvblN0YXR1cy5PSzsNCi0gICAgICAgICAgICAgICAgaWYgKGxpc3QgIT0gbnVsbCkgew0KLQ0KLSAgICAgICAgICAgICAgICAgICAgLy8gR3JvdXAgcmVzdWx0IGJ5IHRoZSByaWdodCB2YWx1ZSAtIHRydWUgb3IgZmFsc2UuDQotICAgICAgICAgICAgICAgICAgICAvLyBJLmUuLCBnZXQgdGhlIG51bWJlciBvZiBkYXRhIHR5cGVzIHdoaWNoIGFyZSBuZXcgYW5kDQotICAgICAgICAgICAgICAgICAgICAvLyB3aGljaCBhcmUgb2xkLg0KLSAgICAgICAgICAgICAgICAgICAgTWFwPEJvb2xlYW4sIExpc3Q8SW1tdXRhYmxlUGFpcjxFbGVtZW50VHlwZURlZmluaXRpb24sIEJvb2xlYW4+Pj4gY29sbGVjdCA9IGxpc3Quc3RyZWFtKCkuY29sbGVjdChDb2xsZWN0b3JzLmdyb3VwaW5nQnkoSW1tdXRhYmxlUGFpcjxFbGVtZW50VHlwZURlZmluaXRpb24sIEJvb2xlYW4+OjpnZXRSaWdodCkpOw0KLSAgICAgICAgICAgICAgICAgICAgaWYgKGNvbGxlY3QgIT0gbnVsbCkgew0KLSAgICAgICAgICAgICAgICAgICAgICAgIFNldDxCb29sZWFuPiBrZXlTZXQgPSBjb2xsZWN0LmtleVNldCgpOw0KLSAgICAgICAgICAgICAgICAgICAgICAgIGlmIChrZXlTZXQuc2l6ZSgpID09IDEpIHsNCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgQm9vbGVhbiBpc05ldyA9IGtleVNldC5pdGVyYXRvcigpLm5leHQoKTsNCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzTmV3LmJvb2xlYW5WYWx1ZSgpKSB7DQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBhbGwgZGF0YSB0eXBlcyBjcmVhdGVkIGF0IHRoZSBmaXJzdCB0aW1lDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0dXMgPSBBY3Rpb25TdGF0dXMuQ1JFQVRFRDsNCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsNCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIEFsbCBkYXRhIHR5cGVzIGFscmVhZHkgZXhpc3RzDQotDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0dXMgPSBhbHJlYWR5RXhpc3RTdGF0dXM7DQotICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCi0gICAgICAgICAgICAgICAgICAgICAgICB9DQotICAgICAgICAgICAgICAgICAgICB9DQotICAgICAgICAgICAgICAgIH0NCi0gICAgICAgICAgICAgICAgcmVwcmVzZW50YXRpb24gPSBSZXByZXNlbnRhdGlvblV0aWxzLnRvUmVwcmVzZW50YXRpb24oZWl0aGVyUmVzdWx0LmxlZnQoKS52YWx1ZSgpKTsNCi0NCi0gICAgICAgICAgICAgICAgUmVzcG9uc2UgcmVzcG9uc2UgPSBidWlsZE9rUmVzcG9uc2UoZ2V0Q29tcG9uZW50c1V0aWxzKCkuZ2V0UmVzcG9uc2VGb3JtYXQoc3RhdHVzKSwgcmVwcmVzZW50YXRpb24pOw0KLSAgICAgICAgICAgICAgICByZXNwb25zZVdyYXBwZXIuc2V0SW5uZXJFbGVtZW50KHJlc3BvbnNlKTsNCi0NCi0gICAgICAgICAgICB9IGNhdGNoIChJT0V4Y2VwdGlvbiBlKSB7DQotICAgICAgICAgICAgICAgIEJlRWNvbXBFcnJvck1hbmFnZXIuZ2V0SW5zdGFuY2UoKS5sb2dCZVJlc3RBcGlHZW5lcmFsRXJyb3IoQ1JFQVRFICsgZWxlbWVudFR5cGVOYW1lKTsNCi0gICA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OU0hJUF9UWVBFX0FMUkVBRFlfRVhJU1QsIE5vZGVUeXBlRW51bS5SZWxhdGlvbnNoaXBUeXBlLm5hbWUoKSk7DQotICAgIH0NCi0NCi19DQorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgorICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0CisgKiAKKyAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wCisgKiAKKyAqIFVubGVzcyByZXF1aXJlZCBieSBhcHBsaWNhYmxlIGxhdyBvciBhZ3JlZWQgdG8gaW4gd3JpdGluZywgc29mdHdhcmUKKyAqIGRpc3RyaWJ1dGVkIHVuZGVyIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1dGVkIG9uIGFuICJBUyBJUyIgQkFTSVMsCisgKiBXSVRIT1VUIFdBUlJBTlRJRVMgT1IgQ09ORElUSU9OUyBPRiBBTlkgS0lORCwgZWl0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AgICAgIGluaXQoKTsKKyAgICAgICAgU3RyaW5nIHVzZXJJZCA9IGluaXRIZWFkZXJQYXJhbShjcmVhdG9yLCByZXF1ZXN0LCBDb25zdGFudHMuVVNFUl9JRF9IRUFERVIpOworICAgICAgICB0cnkgeworICAgICAgICAgICAgV3JhcHBlcjxTdHJpbmc+IHlhbWxTdHJpbmdXcmFwcGVyID0gbmV3IFdyYXBwZXI8PigpOworCisgICAgICAgICAgICBTdHJpbmcgdXJsID0gcmVxdWVzdC5nZXRNZXRob2QoKSArICIgIiArIHJlcXVlc3QuZ2V0UmVxdWVzdFVSSSgpOworICAgICAgICAgICAgbG9nLmRlYnVnKCJTdGFydCBoYW5kbGUgcmVxdWVzdCBvZiB7fSIsIHVybCk7CisgICAgICAgICAgICBXcmFwcGVyPFJlc3BvbnNlPiByZXNwb25zZVdyYXBwZXIgPSBkb1VwbG9hZFR5cGVWYWxpZGF0aW9ucyhyZXF1ZXN0LCB1c2VySWQsIGZpbGUpOworICAgICAgICAgICAgaWYgKHJlc3BvbnNlV3JhcHBlci5pc0VtcHR5KCkpIHsKKyAgICAgICAgICAgICAgICBmaWxsWmlwQ29udGVudHMoeWFtbFN0cmluZ1dyYXBwZXIsIGZpbGUpOworICAgICAgICAgICAgfQorICAgICAgICAgICAgaWYgKHJlc3BvbnNlV3JhcHBlci5pc0VtcHR5KCkpIHsKKyAgICAgICAgICAgICAgICBjcmVhdGVFbGVtZW50c01ldGhvZC5hY2NlcHQocmVzcG9uc2VXcmFwcGVyLCB5YW1sU3RyaW5nV3JhcHBlci5nZXRJbm5lckVsZW1lbnQoKSk7CisgICAgICAgICAgICB9CisgICAgICAgICAgICByZXR1cm4gcmVzcG9uc2VXcmFwcGVyLmdldElubmVyRWxlbWVudCgpOworICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZSkgeworICAgICAgICAgICAgbG9nLmRlYnVnKCJjcmVhdGUge30gZmFpbGVkIHdpdGggZXhjZXB0aW9uOiIsIGVsZW1lbnRUe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YgKGVpdGhlclJlc3VsdC5pc1JpZ2h0KCkpIHsKKyAgICAgICAgICAgIFJlc3BvbnNlIHJlc3BvbnNlID0gYnVpbGRFcnJvclJlc3BvbnNlKGVpdGhlclJlc3VsdC5yaWdodCgpLnZhbHVlKCkpOworICAgICAgICAgICAgcmVzcG9uc2VXcmFwcGVyLnNldElubmVyRWxlbWVudChyZXNwb25zZSk7CisgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICB0cnkgeworICAgICAgICAgICAgICAgIFJlc3BvbnNlIHJlc3BvbnNlID0gYnVpbGRPa1Jlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5DUkVBVEVEKSwgUmVwcmVzZW50YXRpb25VdGlscy50b1JlcHJlc2VudGF0aW9uKGVpdGhlclJlc3VsdC5sZWZ0KCkudmFsdWUoKSkpOworICAgICAgICAgICAgICAgIHJlc3BvbnNlV3JhcHBlci5zZXRJbm5lckVsZW1lbnQocmVzcG9uc2UpOworICAgICAgICAgICAgfSBjYXRjaCAoRXhjZXB0aW9uIGUpIHsKKyAgICAgICAgICAgICAgICBSZXNwb25zZSByZXNwb25zZSA9IGJ1aWxkRXJyb3JSZXNwb25zZShnZXRDb21wb25lbnRzVXRpbHMoKS5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUikpOworICAgICAgICAgICAgICAgIHJlc3BvbnNlV3JhcHBlci5zZXRJbm5lckVsZW1lbnQocmVzcG9uc2UpOworICAgICAgICAgICAgICAgIGxvZy5lcnJvcigiI2NyZWF0ZUVsZW1lbnRzVHlwZSAtIGpzb24gc2VyaWFsaXphdGlvbiBmYWlsZWQgd2l0aCBlcnJvcjogIiwgZSk7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICB9CisKKyAgICAvLyBkYXRhIHR5cGVzCisgICAgcHJpdmF0ZSB2b2lkIGNyZWF0ZURhdGFUeXBl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CB2YWx1ZSAtIHRydWUgb3IgZmFsc2UuCisgICAgICAgICAgICAgICAgICAgIC8vIEkuZS4sIGdldCB0aGUgbnVtYmVyIG9mIGRhdGEgdHlwZXMgd2hpY2ggYXJlIG5ldyBhbmQKKyAgICAgICAgICAgICAgICAgICAgLy8gd2hpY2ggYXJlIG9sZC4KKyAgICAgICAgICAgICAgICAgICAgTWFwPEJvb2xlYW4sIExpc3Q8SW1tdXRhYmxlUGFpcjxFbGVtZW50VHlwZURlZmluaXRpb24sIEJvb2xlYW4+Pj4gY29sbGVjdCA9IGxpc3Quc3RyZWFtKCkuY29sbGVjdChDb2xsZWN0b3JzLmdyb3VwaW5nQnkoSW1tdXRhYmxlUGFpcjxFbGVtZW50VHlwZURlZmluaXRpb24sIEJvb2xlYW4+OjpnZXRSaWdodCkpOworICAgICAgICAgICAgICAgICAgICBpZiAoY29sbGVjdCAhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBTZXQ8Qm9vbGVhbj4ga2V5U2V0ID0gY29sbGVjdC5rZXlTZXQoKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChrZXlTZXQuc2l6ZSgpID09IDEpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBCb29sZWFuIGlzTmV3ID0ga2V5U2V0Lml0ZXJhdG9yKCkubmV4dCgpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpc05ldykgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBhbGwgZGF0YSB0eXBlcyBjcmVhdGVkIGF0IHRoZSBmaXJzdCB0aW1lCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXR1cyA9IEFjdGlvblN0YXR1cy5DUkVBVEVEOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIEFsbCBkYXRhIHR5cGVzIGFscmVhZHkgZXhpc3RzCisKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzID0gYWxyZWFkeUV4aXN0U3RhdHVzOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICByZXByZXNlbnRhdGlvbiA9IFJlcHJlc2VudGF0aW9uVXRpbHMudG9SZXByZXNlbnRhdGlvbihlaXRoZXJSZXN1bHQubGVmdCgpLnZhbHVlKCkpOworCisgICAgICAgICAgICAgICAgUmVzcG9uc2UgcmVzcG9uc2UgPSBidWlsZE9rUmVzcG9uc2UoZ2V0Q29tcG9uZW50c1V0aWxzKCkuZ2V0UmVzcG9uc2VGb3JtYXQoc3RhdHVzKSwgcmVwcmVzZW50YXRpb24pOworICAgICAgICAgICAgICAgIHJlc3BvbnNlV3JhcHBlci5zZXRJbm5lckVsZW1lbnQocmVzcG9uc2UpOworCisgICAgICAgICAgICB9IGNhdGNoIChJT0V4Y2VwdGlvbiBlKSB7CisgICAgICAgICAgICAgICAgQmVFY29tcEVycm9yTWFuYWdlci5nZXRJbnN0YW5jZSgpLmxvZ0JlUmVzdEFwaUdlbmVyYWxFcnJvcihDUkVBVEUgKyBlbGVtZW50VHlwZU5hbWUpOworICAgICAgICAgICAgICAgIGxvZy5kZWJ1ZygiZmFpbGVkIHRvIGNvbnZlcnQge30gdG8ganNvbiIsIGVsZW1lbnRUeXBlTmFtZSwgZSk7CisgICAgICAgICAgICAgICAgUmVzcG9uc2UgcmVzcG9uc2UgPSBidWlsZEVycm9yUmVzcG9uc2UoZ2V0Q29tcG9uZW50c1V0aWxzKCkuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLkdFTkVSQUxfRVJST1IpKTsKKyAgICAgICAgICAgICAgICByZXNwb25zZVdyYXBwZXIuc2V0SW5uZXJFbGVtZW50KHJlc3BvbnNlKTsKKyAgICAgICAgICA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LS0tIGEvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL3NlcnZsZXRzL1VzZXJBZG1pblNlcnZsZXQuamF2YQorKysgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvVXNlckFkbWluU2VydmxldC5qYXZhCkBAIC0xLDQ1NSArMSwyNzUgQEAKLS8qLQ0KLSAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotICogU0RDDQotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NCi0gKiBDb3B5cmlnaHQgKEMpIDIwMTcgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NCi0gKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsNCi0gKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuDQotICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0DQotICogDQotICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjANCi0gKiANCi0gKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlDQotICogZGl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9ICJTdGFydCBoYW5kbGUgcmVxdWVzdCBvZiB7fSI7DQotCXByaXZhdGUgc3RhdGljIGZpbmFsIFN0cmluZyBST0xFX0RFTElNSVRFUiA9ICIsIjsNCi0gICAgcHJpdmF0ZSBzdGF0aWMgZmluYWwgTG9nZ2VyIGxvZyA9IExvZ2dlci5nZXRMb2dnZXIoVXNlckFkbWluU2VydmxldC5jbGFzcyk7DQotICAgIHByaXZhdGUgZmluYWwgVXNlckJ1c2luZXNzTG9naWMgdXNlckJ1c2luZXNzTG9naWM7DQotDQotICAgIEBJbmplY3QNCi0gICAgcHVibGljIFVzZXJBZG1pblNlcnZsZXQoVXNlckJ1c2luZXNzTG9naWMgdXNlckJ1c2luZXNzTG9naWMsDQotICAgICAgICBDb21wb25lbnRzVXRpbHMgY29tcG9uZW50c1V0aWxzKSB7DQotICAgICAgICBzdXBlcih1c2VyQnVzaW5lc3NMb2dpYywgY29tcG9uZW50c1V0aWxzKTsNCi0gICAgICAgIHRoaXMudXNlckJ1c2luZXNzTG9naWMgPSB1c2VyQnVzaW5lc3NMb2dpYzsNCi0gICAgfQ0KLQ0KLSAgICAvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqDQotICAgICAqIEFQSSBzdGFydA0KLSAgICAgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8NCi0NCi0gICAgLyogVXNlciBieSB1c2VySWQgQ1JVRCBzdGFydCAqLw0KLQ0KLSAgICAvLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLw0KLSAgICAvLyByZXRyaWV2ZSBhbGwgdXNlciBkZXRhaWxzDQotICAgIEBHRVQNCi0gICAgQFBhdGgoIi97dXNlcklkfSIpDQotICAgIEBDb25zdW1lcyhNZ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cih1c2VySWQsIGZhbHNlKTsNCi0gICAgICAgICAgICBpZiAoZWl0aGVyLmlzUmlnaHQoKSkgew0KLSAgICAgICAgICAgICAgICByZXR1cm4gYnVpbGRFcnJvclJlc3BvbnNlKA0KLSAgICAgICAgICAgICAgICAgICAgICAgIGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0QnlVc2VySWQoZWl0aGVyLnJpZ2h0KCkudmFsdWUoKSwgdXNlcklkKSk7DQotICAgICAgICAgICAgfSBlbHNlIHsNCi0gICAgICAgICAgICAgICAgaWYgKGVpdGhlci5sZWZ0KCkudmFsdWUoKSAhPSBudWxsKSB7DQotICAgICAgICAgICAgICAgICAgICBTdHJpbmcgcm9sZUpzb24gPSAieyBcInJvbGVcIiA6IFwiIiArIGVpdGhlci5sZWZ0KCkudmFsdWUoKS5nZXRSb2xlKCkgKyAiXCIgfSI7DQotICAgICAgICAgICAgICAgICAgICByZXR1cm4gYnVpbGRPa1Jlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5PSyksIHJvbGVKc29uKTsNCi0gICAgICAgICAgICAgICAgfSBlbHNlIHsNCi0gICAgICAgICAgICAgICAgICAgIHJldHVybiBidWlsZEVycm9yUmVzcG9uc2UoZ2V0Q29tcG9uZW50c1V0aWxzKCkuZ2V0UmVzcG9uc2VGb3JtYXQoQWN0aW9uU3RhdHVzLkdFTkVSQUxfRVJST1IpKTsNCi0gICAgICAgICAgICAgICAgfQ0KLSAgICAgICAgICAgIH0NCi0gICAgICAgIH0gY2F0Y2ggKEV4Y2VwdGlvbiBlKSB7DQotICAgICAgICAgICAgQmVFY29tcEVycm9yTWFuYWdlci5nZXRJbnN0YW5jZSgpLmxvZ0JlUmVzdEFwaUdlbmVyYWxFcnJvcigiR2V0IFVzZXIgUm9sZSIpOw0KLSAgICAgICAgICAgIGxvZy5kZWJ1ZygiR2V0IHVzZXIgcm9sZSB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FkbWluVXNlcnMoKTsNCi0NCi0gICAgICAgICAgICBpZiAoZWl0aGVyLmlzUmlnaHQoKSkgew0KLSAgICAgICAgICAgICAgICBsb2cuZGVidWcoIkZhaWxlZCB0byBnZXQgYWxsIGFkbWluIHVzZXJzIik7DQotICAgICAgICAgICAgICAgIHJldHVybiBidWlsZEVycm9yUmVzcG9uc2UoZWl0aGVyLnJpZ2h0KCkudmFsdWUoKSk7DQotICAgICAgICAgICAgfSBlbHNlIHsNCi0gICAgICAgICAgICAgICAgaWYgKGVpdGhlci5sZWZ0KCkudmFsdWUoKSAhPSBudWxsKSB7DQotICAgICAgICAgICAgICAgICAgICByZXR1cm4gYnVpbGRPa1Jlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5PSyksDQotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVpdGhlci5sZWZ0KCkudmFsdWUoKSk7DQotICAgICAgICAgICAgICAgIH0gZWxzZSB7DQotICAgICAgICAgICAgICAgICAgICByZXR1cm4gYnVpbGRFcnJvclJlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5HRU5FUkFMX0VSUk9SKSk7DQotICAgICAgICAgICAgICAgIH0NCi0gICAgICAgICAgICB9DQotICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZSkgew0KLSAgICAgICAgICAgIEJlRWNvbXBFcnJvck1hbmFnZXIuZ2V0SW5zdGFuY2UoKS5sb2dCZVJlc3RBcGlHZW5lcmFsRXJyb3IoIkdldCBBbGwgQWRtaW5pc3RyYXRvcnMiKTsNCi0gICAgICAgICAgICBsb2cuZGVidWcoImdldCBhbGwgYWRtaW5zIGZhaWxlZCB3aXRoIHVuZXhwZWN0ZWQgZXJyb3I6IHt9IiwgZSk7DQotICAgICAgICAgICAgcmV0dXJuIGJ1aWxkRXJyb3JSZXNwb25zZShnZXRDb21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yksIGRlYWN0aXZlVXNlclJlc3BvbnNlLmxlZnQoKS52YWx1ZSgpKTsNCi0gICAgICAgICAgICByZXR1cm4gcmVzcG9uc2U7DQotDQotICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZSkgew0KLSAgICAgICAgICAgIEJlRWNvbXBFcnJvck1hbmFnZXIuZ2V0SW5zdGFuY2UoKS5sb2dCZVJlc3RBcGlHZW5lcmFsRXJyb3IoIkdldCBBU0RDIHVzZXJzIik7DQotICAgICAgICAgICAgbG9nLmRlYnVnKCJkZWFjdGl2YXRlIHVzZXIgZmFpbGVkIHdpdGggdW5leHBlY3RlZCBlcnJvcjoge30iLCBlKTsNCi0gICAgICAgICAgICByZXR1cm4gYnVpbGRFcnJvclJlc3BvbnNlKGdldENvbXBvbmVudHNVdGlscygpLmdldFJlc3BvbnNlRm9ybWF0KEFjdGlvblN0YXR1cy5HRU5FUkFMX0VSUk9SKSk7DQotICAgICAgICB9DQotICAgIH0NCi19DQorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIH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ZyB1c2VySWQsCisgICAgICAgICAgICBAUGFyYW1ldGVyKAorICAgICAgICAgICAgICAgICAgICBkZXNjcmlwdGlvbiA9ICJURVNURVIsREVTSUdORVIsUFJPRFVDVF9TVFJBVEVHSVNULE9QUyxQUk9EVUNUX01BTkFHRVIsR09WRVJOT1IsIEFETUlOIE9SIGFsbCB1c2VycyBieSBub3QgdHlwaW5nIGFueXRoaW5nIikgQFF1ZXJ5UGFyYW0oInJvbGVzIikgZmluYWwgU3RyaW5nIHJvbGVzKSB7CisKKyAgICAgICAgU3RyaW5nIHVybCA9IHJlcXVlc3QuZ2V0TWV0aG9kKCkgKyAiICIgKyByZXF1ZXN0LmdldFJlcXVlc3RVUkkoKTsKKyAgICAgICAgbG9nLmRlYnVnKCJTdGFydCBoYW5kbGUgcmVxdWVzdCBvZiB7fSBtb2RpZmllciBpZCBpcyB7fSIsIHVybCwgdXNlcklkKTsKKworICAgICAgICBMaXN0PFN0cmluZz4gcm9sZXNMaXN0ID0gbmV3IEFycmF5TGlzdDw+KCk7CisgICAgICAgIGlmIChyb2xlcyAhPSBudWxsICYmICFyb2xlcy50cmltKCkuaXNFbXB0eSgpKSB7CisgICAgICAgICAgICBTdHJpbmdbXSByb2xlc0FyciA9IHJvbGVzLnNwbGl0KFJPTEVfREVMSU1JVEVSKTsKKyAgICAgICAgICAgIGZvciAoU3RyaW5nIHJvbGUgOiByb2xlc0FycikgeworICAgICAgICAgICAgICAgIHJvbGVzTGlzdC5hZGQocm9sZS50cmltKCkpOworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgICAgIHJldHVybiB1c2VyQnVzaW5lc3NMb2dpYy5nZXRVc2Vyc0xpc3QodXNlcklkLCByb2xlc0xpc3QsIHJvbGVzKTsKKyAgICB9CisKKyAgICBAREVMRVRFCisgICAgQFBhdGgoIi97dXNlcklkfSIpCisgICAgQENvbnN1bWVzKE1lZGlhVHlwZS5BUFBMSUNBVElPTl9KU09OKQorICAgIEBQcm9kdWNlcyhNZWRpY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F2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9leGNlcHRpb24vQ29uc3RyYWludFZpb2xhdGlvbkV4Y2VwdGlvbk1hcHBlci5qYXZhIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL3NlcnZsZXRzL2V4Y2VwdGlvbi9Db25zdHJhaW50VmlvbGF0aW9uRXhjZXB0aW9uTWFwcGVyLmphdmEKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uNTE2YWI1ZAotLS0gL2Rldi9udWxsCisrKyBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9leGNlcHRpb24vQ29uc3RyYWludFZpb2xhdGlvbkV4Y2VwdGlvbk1hcHBlci5qYXZhCkBAIC0wLDAgKzEsNDkgQEAKKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAyMCBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKKyAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5z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L2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9leGNlcHRpb24vUHJvcGVydHlDb25zdHJhaW50RXhjZXB0aW9uTWFwcGVyLmphdmEKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uY2M5MGVjZgotLS0gL2Rldi9udWxsCisrKyBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9leGNlcHRpb24vUHJvcGVydHlDb25zdHJhaW50RXhjZXB0aW9uTWFwcGVyLmphdmEKQEAgLTAsMCArMSw1NyBAQAorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDIwIEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgorICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0CisgKgorICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKKyAqC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cGVuZWNvbXAvc2RjL2JlL3RvZ2dsei9DYXNzYW5kcmFDdXN0b21TdGF0ZVJlcG9zaXRvcnkuamF2YSBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS90b2dnbHovQ2Fzc2FuZHJhQ3VzdG9tU3RhdGVSZXBvc2l0b3J5LmphdmEKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uYTY3YmY0YgotLS0gL2Rldi9udWxsCisrKyBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS90b2dnbHovQ2Fzc2FuZHJhQ3VzdG9tU3RhdGVSZXBvc2l0b3J5LmphdmEKQEAgLTAsMCArMSw5MiBAQAorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDIwIEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgorICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0CisgKgorICogICAgICBodHRwOi8vd3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0dXJlU3RhdGUge30gaXMgc2V0IHdpdGggc3RhdHVzIHt9IiwgZmVhdHVyZVN0YXRlLmdldEZlYXR1cmUoKSwgc3RhdHVzKTsKKyAgICB9CisKK30KZGlmZiAtLWdpdCBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS90b2dnbHovVG9nZ2xlQ29uZmlndXJhdGlvbi5qYXZhIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL3RvZ2dsei9Ub2dnbGVDb25maWd1cmF0aW9uLmphdmEKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uNTJiYmY4NgotLS0gL2Rldi9udWxsCisrKyBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS90b2dnbHovVG9nZ2xlQ29uZmlndXJhdGlvbi5qYXZhCkBAIC0wLDAgKzEsNTIgQEAKKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAyMCBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKKyAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZ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xkIiArIFdPUkRfUEFUVEVSTjsKKyAgICBwcml2YXRlIHN0YXRpYyBmaW5hbCBTdHJpbmcgQVJUSUZBQ1RfTkFNRV9VTklRVUVfSUQgPSAiQXJ0aWZhY3ROYW1lIHt9LCB1bmlxdWUgSUQge30iOwogCi0JcHVibGljIHN0YXRpYyBmaW5hbCBTdHJpbmcgVkZDX05PREVfVFlQRV9BUlRJRkFDVFNfUEFUSF9QQVRURVJOID0gQVJUSUZBQ1RTICsgREVMX1BBVFRFUk4KLQkJCSsgSW1wb3J0VXRpbHMuQ29uc3RhbnRzLlVTRVJfREVGSU5FRF9SRVNPVVJDRV9OQU1FU1BBQ0VfUFJFRklYICsgIihbXFxkXFx3XFxfXFwtXFwuXFxzXSspIiArIERFTF9QQVRURVJOCi0JCQkrICIoW1xcZFxcd1xcX1xcLVxcLlxcc10rKSIgKyBERUxfUEFUVEVSTiArICIoW1xcZFxcd1xcX1xcLVxcLlxcc10rKSIgKyBERUxfUEFUVEVSTgotCQkJKyAiKFtcXGRcXHdcXF9cXC1cXC5cXHNdKykiOworICAgIHByaXZhdGUgc3RhdGljIGZpbmFsIFN0cmluZyBWRkNfTk9ERV9UWVBFX0FSVElGQUNUU19QQVRIX1BBVFRFUk4gPSBBUlRJRkFDVFMgKyBERUxfUEFUVEVSTiArCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbXBvcnRVdGlscy5Db25zdGFudHMuVVNFUl9ERUZJTkVEX1JFU09VUkNFX05BTUVTUEFDRV9QUkVGSVggKworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVkFMSURfRU5HTElTSF9BUlRJRkFDVF9OQU1FX1dJVEhfRElHSVRTICsgREVMX1BBVFRFUk4gKworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVkFMSURfRU5HTElTSF9BUlRJRkFDVF9OQU1FX1dJVEhfRElHSVRTICsgREVMX1BBVFRFUk4gKworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVkFMSURfRU5HTElTSF9BUlRJRkFDVF9OQU1FX1dJVEhfRElHSVRTICsgREVMX1BBVFRFUk4gKworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVkFMSURfRU5HTElTSF9BUlRJRkFDVF9OQU1FX1dJVEhfRElHSVRTOwogCi0JcHVibGljIHN0YXRpYyBmaW5hbCBTdHJpbmcgVkZfTk9ERV9UWVBFX0FSVElGQUNUU19QQVRIX1BBVFRFUk4gPSBBUlRJRkFDVFMgKyBERUxfUEFUVEVSTiArCi0JLy8gQXJ0aWZhY3QgR3JvdXAgKGkuZSBEZXBsb3ltZW50L0luZm9ybWF0aW9uYWwpCi0JCQkiKFtcXHdcXF9cXC1cXC5cXHNdKykiICsgREVMX1BBVFRFUk4gKwotCQkJLy8gQXJ0aWZhY3QgVHlwZQotCQkJIihbXFx3XFxfXFwtXFwuXFxzXSspIiArIERFTF9QQVRURVJOICsKLQkJCS8vIEFydGlmYWN0IEFueSBGaWxlIE5hbWUKLQkJCSIuKyI7Ci0JcHVibGljIHN0YXRpYyBmaW5hbCBTdHJpbmcgVkFMSURfRU5HTElTSF9BUlRJRkFDVF9OQU1FID0gIihbXFx3XFxfXFwtXFwuXFxzXSspIjsKLQlwdWJsaWMgc3RhdGljIGZpbmFsIFN0cmluZyBTRVJWSUNFX1RFTVBMQVRFX1BBVEhfUEFUVEVSTiA9IERFRklOSVRJT04gKyBERUxfUEFUVEVSTiArCi0JLy8gU2VydmljZSBUZW1wbGF0ZSBGaWxlIE5hbWUKLQkJCSIoW1xcd1xcX1xcLVxcLlxcc10rKSI7CisgICAgcHVibGljIHN0YXRpYyBmaW5hbCBTdHJpbmcgVkZfTk9ERV9UWVBFX0FSVElGQUNUU19QQVRIX1BBVFRFUk4gPSBBUlRJRkFDVFMgKyBERUxfUEFUVEVSTisKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gQXJ0aWZhY3QgR3JvdXAgKGkuZSBEZXBsb3ltZW50L0luZm9ybWF0aW9uYWwpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFZBTElEX0VOR0xJU0hfQVJUSUZBQ1RfTkFNRSArIERFTF9QQVRURVJOICsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gQXJ0aWZhY3QgVHlwZQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWQUxJRF9FTkdMSVNIX0FSVElGQUNUX05BTUUgICsgREVMX1BBVFRFUk4gKworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBBcnRpZmFjdCBBbnkgRmlsZSBOYW1lCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICIuKyI7CiAKLQlwdWJsaWMgc3RhdGljIGZpbmFsIFN0cmluZyBBUlRJRkFDVF9DUkVBVEVEX0ZST01fQ1NBUiA9ICJBcnRpZmFjdCBjcmVhdGVkIGZyb20gY3NhciI7CisgICAgcHVibGljIHN0YXRpYyBmaW5hbCBTdHJpbmcgU0VSVklDRV9URU1QTEFURV9QQVRIX1B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ICAgICAgICAgICAgICAgIH0KKworICAgICAgICAgICAgICAgIC8vZmlsbCBpbm5lckNvbXBvbmVudHNDYWNoZQorICAgICAgICAgICAgICAgIGZpbGVOYW1lID0gZC5nZXRMZWZ0KCk7CisgICAgICAgICAgICAgICAgYWRkQ29tcG9uZW50VG9DYWNoZShpbm5lckNvbXBvbmVudHNDYWNoZSwgY2Fzc2FuZHJhSWQsIGZpbGVOYW1lLCBjaGlsZENvbXBvbmVudCk7CisgICAgICAgICAgICAgICAgYWRkSW5uZXJDb21wb25lbnRzVG9DYWNoZShpbm5lckNvbXBvbmVudHNDYWNoZSwgY2hpbGRDb21wb25lbnQpOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICAvL2FkZCBpbm5lciBjb21wb25lbnRzIHRvIENTQVIKKyAgICAgICAgICAgIEVpdGhlcjxaaXBPdXRwdXRTdHJlYW0sIFJlc3BvbnNlRm9ybWF0PiByZXNwb25zZUZvcm1hdCA9IGFkZElubmVyQ29tcG9uZW50c1RvQ1NBUih6aXAsIGlubmVyQ29tcG9uZW50c0NhY2hlKTsKKyAgICAgICAgICAgIGlmIChyZXNwb25zZUZvcm1hdCAhPSBudWxsKSByZXR1cm4gcmVzcG9uc2VGb3JtYXQ7CisgICAgICAgIH0KKyAgICAgICAgcmV0dXJuIG51bGw7CisgICAgfQorCisgICAgcHJpdmF0ZSBFaXRoZXI8WmlwT3V0cHV0U3RyZWFtLCBSZXNwb25zZUZvcm1hdD4gYWRkSW5uZXJDb21wb25lbnRzVG9DU0FSKFppcE91dHB1dFN0cmVhbSB6aXAsIE1hcDxTdHJpbmcsIEltbXV0YWJsZVRyaXBsZTxTdHJpbmcsIFN0cmluZywgQ29tcG9uZW50Pj4gaW5uZXJDb21wb25lbnRzQ2FjaGUpIHRocm93cyBJT0V4Y2VwdGlvbiB7CisgICAgICAgIGZvciAoRW50cnk8U3RyaW5nLCBJbW11dGFibGVUcmlwbGU8U3RyaW5nLCBTdHJpbmcsIENvbXBvbmVudD4+I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gIFppcEVudHJ5IGVudHJ5OworICAgICAgICAgICAgICAgIHdoaWxlICgoZW50cnkgPSB6aXBTdHJlYW0uZ2V0TmV4dEVudHJ5KCkpICE9IG51bGwpIHsKKyAgICAgICAgICAgICAgICAgICAgWmlwVXRpbHMuY2hlY2tGb3JaaXBTbGlwSW5SZWFkKGVudHJ5KTsKKyAgICAgICAgICAgICAgICAgICAgZmluYWwgU3RyaW5nIGVudHJ5TmFtZSA9IGVudHJ5LmdldE5hbWUoKTsKKyAgICAgICAgICAgICAgICAgICAgaW50IHJlYWRTaXplID0gaW5pdFNpemU7CisgICAgICAgICAgICAgICAgICAgIGZpbmFsIGJ5dGVbXSBlbnRyeURhdGEgPSBuZXcgYnl0ZVtpbml0U2l6ZV07CiAKLQkJRWl0aGVyPENzYXJEZWZpbml0aW9uLCBSZXNwb25zZUZvcm1hdD4gY29sbGVjdGVkQ29tcG9uZW50Q3NhckRlZmluaXRpb24gPSBjb2xsZWN0Q29tcG9uZW50Q3NhckRlZmluaXRpb24oCi0JCQkJY29tcG9uZW50KTsKKyAgICAgICAgICAgICAgICAgICAgd2hpbGUgKChyZWFkU2l6ZSA9IHppcFN0cmVhbS5yZWFkKGVudHJ5RGF0YSwgMCwgcmVhZFNpemUpKSAhPSAtMSkgeworICAgICAgICAgICAgICAgICAgICAgICAgYm9zLndyaXRlKGVudHJ5RGF0YSwgMCwgcmVhZFNpemUpOworICAgICAgICAgICAgICAgICAgICB9CiAKLQkJaWYgKGNvbGxlY3RlZENvbXBvbmVudENzYXJEZWZpbml0aW9uLmlzUmlnaHQoKSkgewotCQkJcmV0dXJuIEVpdGhlci5yaWdodChjb2xsZWN0ZWRDb21wb25lbnRDc2FyRGVmaW5pdGlvbi5yaWdodCgpLnZhbHVlKCkpOwotCQl9CisgICAgICAgICAgICAgICAgICAgIGJvcy5mbHVzaCgpOworICAgICAgICAgICAgICAgICAgICBvdXQuZmx1c2goKTsKKyAgICAgICAgICAgICAgICAgICAgemlwLnB1dE5leHR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aGUuZ2V0KGNpLmdldENvbXBvbmVudFVpZCgpKTsKKyAgICAgICAgICAgICAgICBpZiAoY29tcG9uZW50UmVjb3JkID09IG51bGwpIHsKKyAgICAgICAgICAgICAgICAgICAgLy8gYWxsIHJlc291cmNlIG11c3QgYmUgb25seSBvbmNlIQorICAgICAgICAgICAgICAgICAgICBFaXRoZXI8UmVzb3VyY2UsIFN0b3JhZ2VPcGVyYXRpb25TdGF0dXM+IHJlc291cmNlID0gdG9zY2FPcGVyYXRpb25GYWNhZGUuZ2V0VG9zY2FFbGVtZW50KGNpLmdldENvbXBvbmVudFVpZCgpKTsKKyAgICAgICAgICAgICAgICAgICAgQ29tcG9uZW50IGNvbXBvbmVudFJJID0gY2hlY2tBbmRBZGRDb21wb25lbnQoY29tcG9uZW50Q2FjaGUsIGNpLCByZXNvdXJjZSk7CiAKLQlwcml2YXRlIHZvaWQgYWRkSW5uZXJDb21wb25lbnRzVG9DYWNoZShNYXA8U3RyaW5nLCBJbW11dGFibGVUcmlwbGU8U3RyaW5nLCBTdHJpbmcsIENvbXBvbmVudD4+IGNvbXBvbmVudENhY2hlLAotCQkJQ29tcG9uZW50IGNoaWxkQ29tcG9uZW50KSB7CisgICAgICAgICAgICAgICAgICAgIC8vaWYgbm90IGF0b21pYyAtIGluc2VydCBpbm5lciBjb21wb25lbnRzIGFzIHdlbGwKKyAgICAgICAgICAgICAgICAgICAgaWYoIU1vZGVsQ29udmVydGVyLmlzQXRvbWljQ29tcG9uZW50KGNvbXBvbmVudFJJKSkgeworICAgICAgICAgICAgICAgICAgICAgICAgYWRkSW5uZXJDb21wb25lbnRzVG9DYWNoZShjb21wb25lbnRDYWNoZSwgY29tcG9uZW50UkkpOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfSk7CisgICAgICAgIH0KKyAgICB9CiAKLQkJTGlzdDxDb21wb25lbnRJbnN0YW5jZT4gaW5zdGFuY2VzID0gY2hpbGRDb21wb25lbnQ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uZW50cnlTZXQoKS5zdHJlYW0oKQotCQkJCS8vIGZvciBlYWNoIHZmYwotCQkJCS5mb3JFYWNoKGUgLT4gZS5nZXRWYWx1ZSgpLnN0cmVhbSgpCi0JCQkJCQkvLyBhZGQgZWFjaCB3YXJuaW5nIG1lc3NhZ2UgdG8gbG9nCi0JCQkJCQkuZm9yRWFjaChhcmdzIC0+IGxvZy53YXJuKGUuZ2V0S2V5KCksIGFyZ3MudG9BcnJheSgpKSkpOworICAgIC8qKgorICAgICAqIFByaW50IHdhcm5pbmdzIHRvIGxvZworICAgICAqCisgICAgICogQHBhcmFtIGNvbGxlY3RlZFdhcm5pbmdNZXNzYWdlcworICAgICAqLworICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBoYW5kbGVXYXJuaW5nTWVzc2FnZXMoTWFwPFN0cmluZywgU2V0PExpc3Q8U3RyaW5nPj4+IGNvbGxlY3RlZFdhcm5pbmdNZXNzYWdlcykgeworICAgICAgICBjb2xsZWN0ZWRXYXJuaW5nTWVzc2FnZXMuZW50cnlTZXQoKS5zdHJlYW0oKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBmb3IgZWFjaCB2ZmMKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmZvckVhY2goZSAtPiBlLmdldFZhbHVlKCkuc3RyZWFtKCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gYWRkIGVhY2ggd2FybmluZyBtZXNzYWdlIHRvIGxvZworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZm9yRWFjaChhcmdzIC0+IGxvZy53YXJuKGUuZ2V0S2V5KCksIGFyZ3MudG9BcnJheSgpKSkpOwogCi0JfQorICAgIH0KIAotCXByaXZhdGUgc3RhdGljIHZvaWQgYWRkRXh0cmFjdGVkVmZjQXJ0aWZhY3QoSW1tdXRhYmxlUGFpcjxTdHJpbmcsIEFydGlmYWN0RGVmaW5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KyAgICAgICAgcHVibGljIFN0cmluZyBnZXRQYXRoKCkgeworICAgICAgICAgICAgcmV0dXJuIHBhdGg7CisgICAgICAgIH0KIAotCQlwdWJsaWMgU3RyaW5nIGdldEFydGlmYWN0TmFtZSgpIHsKLQkJCXJldHVybiBhcnRpZmFjdE5hbWU7Ci0JCX0KKyAgICAgICAgcHVibGljIFN0cmluZyBnZXRBcnRpZmFjdE5hbWUoKSB7CisgICAgICAgICAgICByZXR1cm4gYXJ0aWZhY3ROYW1lOworICAgICAgICB9CiAKLQkJcHVibGljIEFydGlmYWN0VHlwZUVudW0gZ2V0QXJ0aWZhY3RUeXBlKCkgewotCQkJcmV0dXJuIGFydGlmYWN0VHlwZTsKLQkJfQorICAgICAgICBwdWJsaWMgQXJ0aWZhY3RUeXBlRW51bSBnZXRBcnRpZmFjdFR5cGUoKSB7CisgICAgICAgICAgICByZXR1cm4gYXJ0aWZhY3RUeXBlOworICAgICAgICB9CiAKLQkJcHVibGljIFN0cmluZyBnZXREaXNwbGF5TmFtZSgpIHsKLQkJCXJldHVybiBkaXNwbGF5TmFtZTsKLQkJfQorICAgICAgICBwdWJsaWMgU3RyaW5nIGdldERpc3BsYXlOYW1lKCkgeworICAgICAgICAgICAgcmV0dXJuIGRpc3BsYXlOYW1lOworICAgICAgICB9CiAKLQkJcHVibGljIEFydGlmYWN0R3JvdXBUeXBlRW51bSBnZXRBcnRpZmFjdEdyb3VwVHlwZSgpIHsKLQkJCXJldHVybiBhcnRpZmFjdEdyb3VwVHlwZTsKLQkJfQorICAgICAgICBwdWJsaWMgQXJ0aWZhY3RHcm91cFR5cGVFbnVtIGdldEFydGlmYWN0R3JvdXBUeXBlKCkgeworICAgICAgICAgICAgcmV0dXJuIGFydGlmYWN0R3JvdXBUeXBlOworICAgICAgICB9CiAKLQkJcHVibGljIFN0cmluZyBnZXRBcnRpZmFjdExhYmVsKCkgewotCQkJcmV0dXJuIGFydGlmYWN0TGFiZWw7Ci0JCX0KKyAgICAgICAgcHV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AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0UmVzb3VyY2VJbmZvcm1hdGlvbmFsQXJ0aWZhY3RzKCk7CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgREVQTE9ZTUVOVDoKKyAgICAgICAgICAgICAgICAgICAgcmVzb3VyY2VWYWxpZFR5cGVBcnRpZmFjdHMgPSBDb25maWd1cmF0aW9uTWFuYWdlci5nZXRDb25maWd1cmF0aW9uTWFuYWdlcigpLmdldENvbmZpZ3VyYXRpb24oKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldFJlc291cmNlRGVwbG95bWVudEFydGlmYWN0cygpOworICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQogCi0JCVNldDxTdHJpbmc+IHZhbGlkQXJ0aWZhY3RUeXBlcyA9IG51bGw7Ci0JCWlmIChyZXNvdXJjZVZhbGlkVHlwZUFydGlmYWN0cyAhPSBudWxsKSB7Ci0JCQl2YWxpZEFydGlmYWN0VHlwZXMgPSByZXNvdXJjZVZhbGlkVHlwZUFydGlmYWN0cy5rZXlTZXQoKTsKLQkJfQorICAgICAgICBTZXQ8U3RyaW5nPiB2YWxpZEFydGlmYWN0VHlwZXMgPSBudWxsOworICAgICAgICBpZihyZXNvdXJjZVZhbGlkVHlwZUFydGlmYWN0cyAhPSBudWxsKXsKKyAgICAgICAgICAgIHZhbGlkQXJ0aWZhY3RUeXBlcyA9IHJlc291cmNlVmFsaWRUeXBlQXJ0aWZhY3RzLmtleVNldCgpOworICAgICAgICB9CiAKLQkJaWYgKHZhbGlkQXJ0aWZhY3RUeXBlcyA9PSBudWxsIHx8IGFydGlmY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HRvIGdldCB7fSBwYXlsb2FkIGZyb20gREIgcmVhc29uOiB7fSIsIGFydGlmYWN0TmFtZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJ0aWZhY3RGcm9tQ2Fzc2FuZHJhLnJpZ2h0KCkudmFsdWUoKSk7CisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gRWl0aGVyLnJpZ2h0KGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdCgKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQWN0aW9uU3RhdHVzLkFSVElGQUNUX1BBWUxPQURfTk9UX0ZPVU5EX0RVUklOR19DU0FSX0NSRUFUSU9OLCAiUmVzb3VyY2UiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21wb25lbnQuZ2V0VW5pcXVlSWQoKSwgYXJ0aWZhY3ROYW1lLCBhcnRpZmFjdFVVSUQpKTsKKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICBmaW5hbCBieXRlW10gcGF5bG9hZERhdGEgPSBhcnRpZmFjdEZyb21DYXNzYW5kcmEubGVmdCgpLnZhbHVlKCk7CisgICAgICAgICAgICAgICAgICAgIHppcHN0cmVhbS5wdXROZXh0RW50cnkobmV3IFppcEVudHJ5KE9wZXJhdGlvbkFydGlmYWN0VXRpbC5jcmVhdGVPcGVyYXRpb25BcnRpZmFjdFBhdGgoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tcG9uZW50LCBudWxsLCBvcGVyYXRpb24sdHJ1ZSkpKTsKKyAgICAgICAgICAgICAgICAgICAgemlwc3RyZWFtLndyaXRlKHBheWxvYWREYXRhKTsKKyAgICAgICAgICAgICAgICB9IGNhdGNoIChJT0V4Y2VwdGlvbiBlKSB7CisgICAgICAgICAgICAgICAgICAgIGxvZy5lcnJvcigiQ29tcG9uZW50IE5hbWUge30sICBJbnRlcmZhY2UgTmFtZSB7fSwgT3BlcmF0aW9uIE5hbWUge30iLCBjb21wb25lbnQuZ2V0Tm9ybWFsaXplZE5hbWUoKSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlcmZhY2VFbnRyeS5nZXRLZXkoKSwgb3BlcmF0aW9uLmdldE5hbWUoKSk7CisgICAgICAgICAgICAgICAgICAgIGxvZy5lcnJvcigiRXJyb3Igd2hpbGUgd3JpdGluZyB0aGUgb3BlcmF0aW9uJ3MgYXJ0aWZhY3RzIHRvIHRoZSBDU0FSICIgKyAie30iLCBlKTsKKyAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChjb21wb25lbnRzVXRpbHMKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuRVJST1JfRFVSSU5HX0NTQVJfQ1JFQVRJT04sICJSZXNvdXJjZSIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBvbmVudC5nZXRVbmlxdWVJZCgpKSk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgICAgIHJldHVybiBFaXRoZXIubGVmdCh6aXBzdHJlYW0pOworICAgIH0KIAotCQlyZXR1cm4gRWl0aGVyLmxlZnQoemlwc3RyZWFtKTsKLQl9CisgICAgcHJpdmF0ZSBib29sZWFuIGNoZWNrQ29tcG9uZW50QmVmb3JlV3JpdGUoQ29tcG9uZW50IGNvbXBvbmVudCwgRW50cnk8U3RyaW5nLCBJbnRlcmZhY2VEZWZpbml0aW9uPiBpbnRlcmZhY2VFbnRyeSwgT3BlcmF0aW9uRGF0YURlZmluaXRpb24gb3BlcmF0aW9uKSB7CisgICAgICAgIGlmIChPYmplY3RzLmlzTnVsbChvcGVyYXRpb24uZ2V0SW1wbGVtZW50YXRpb24oKSkpIHsKKyAgICAgICAgICAgIGxvZy5kZWJ1ZygiQ29tcG9uZW50IE5hbWUge30sIEludGVyZmFjZSBJZCB7fSwgT3BlcmF0aW9uIE5hbWUge30gLSBubyBPcGVyYXRpb24gSW1wbGVtZW50YXRpb24gZm91bmQiLAorICAgICAgICAgICAgICAgICAgICBjb21wb25lbnQuZ2V0Tm9ybWFsaXplZE5hbWUoKSwgaW50ZXJmYWNlRW50cnkuZ2V0VmFsdWUoKS5nZXRVbmlxdWVJZCgpLAorICAgICAgICAgICAgICAgICAgICBvcGVyYXRpb24uZ2V0TmFtZSgpKTsKKyAgICAgICAgICAgIHJldHVybiB0cnVlOworICAgICAgICB9CisgICAgICAgIGlmIChPYmplY3RzLmlzTnVsbChvcGVyYXRpb24uZ2V0SW1wbGVtZW50YXRpb24oKS5nZXRBcnRpZmFjdE5hbWUoKSkpIHsKKyAgICAgICAgICAgIGxvZy5kZWJ1ZygiQ29tcG9uZW50IE5hbWUge30sIEludGVyZmFjZSBJZCB7fSwgT3BlcmF0aW9uIE5hbWUge30gLSBubyBhcnRpZmFjdCBmb3VuZCIsCisgICAgICAgICAgICAgICAgICAgIGNvbXBvbmVudC5nZXROb3JtYWxpemVkTmFtZSgpLCBpbnRlcmZhY2VFbnRyeS5nZXRWYWx1ZSgpLmdldFVuaXF1ZUlkKCksCisgICAgICAgICAgICAgICAgICAgIG9wZXJhdGlvbi5nZXROYW1lKCkpOworICAgICAgICAgICAgcmV0dXJuIHRydWU7CisgICAgICAgIH0KKyAgICAgICAgcmV0dXJuIGZhbHNlOworICAgIH0KIAotCXByaXZhdGUgRWl0aGVyPFppcE91dHB1dFN0cmVhbSwgUmVzcG9uc2VGb3JtYXQ+IHdyaXRlQXJ0aWZhY3RzSW5mb1RvU3BlY2lmaWVkUGF0aChDb21wb25lbnQgbWFpbkNvbXBvbmVudCwKLQkJCUFydGlmYWN0c0luZm8gY3VyckFydGlmYWN0c0luZm8sIFppcE91dHB1dFN0cmVhbSB6aXAsIFN0cmluZyBwYXRoLCBib29sZWFuIGlzSW5DZXJ0aWZ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KTsKKyAgICAgICAgfQogCi0JCXJldHVybiBFaXRoZXIubGVmdCh6aXApOwotCX0KKyAgICAgICAgcmV0dXJuIEVpdGhlci5sZWZ0KHppcCk7CisgICAgfQogCi0JLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgotCSAqIEFydGlmYWN0cyBTdHJ1Y3R1cmUKLQkgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwotCS8qKgotCSAqIFRoZSBhcnRpZmFjdHMgRGVmaW5pdGlvbiBzYXZlZCBieSB0aGVpciBzdHJ1Y3R1cmUKLQkgKi8KLQlwcml2YXRlIGNsYXNzIEFydGlmYWN0c0luZm8gewotCQkvLyBLZXkgaXMgdGhlIHR5cGUgb2YgYXJ0aWZhY3RzKEluZm9ybWF0aW9uYWwvRGVwbG95bWVudCkKLQkJLy8gVmFsdWUgaXMgYSBtYXAgYmV0d2VlbiBhbiBhcnRpZmFjdCB0eXBlIGFuZCBhIGxpc3Qgb2YgYWxsIGFydGlmYWN0cyBvZiB0aGlzCi0JCS8vIHR5cGUKLQkJcHJpdmF0ZSBNYXA8QXJ0aWZhY3RHcm91cFR5cGVFbnVtLCBNYXA8QXJ0aWZhY3RUeXBlRW51bSwgTGlzdDxBcnRpZmFjdERlZmluaXRpb24+Pj4gYXJ0aWZhY3RzSW5mb0ZpZWxkOworICAgIC8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiogQXJ0aWZhY3RzIFN0cnVjdHVyZSAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisgICAgLyoqCisgICAgICogVGhlIGFydGlmYWN0cyBEZWZpbml0aW9uIHNhdmVkIGJ5IHRoZWlyIHN0cnVjdHVyZQorICAgICAqLworICAgIHByaXZhdGUgY2xhc3MgQXJ0aWZhY3RzSW5mbyB7CisgICAgICAgIC8vS2V5IGlzIHR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3RyaW5nLCBDb21wb25lbnRUeXBlQXJ0aWZhY3RzPiBjb21wb25lbnRUeXBlQXJ0aWZhY3RzKSB7Ci0JCQl0aGlzLmNvbXBvbmVudFR5cGVBcnRpZmFjdHMgPSBjb21wb25lbnRUeXBlQXJ0aWZhY3RzOwotCQl9Ci0JfQorICAgICAgICBwdWJsaWMgQ3NhckRlZmluaXRpb24oQ29tcG9uZW50QXJ0aWZhY3RzIGNvbXBvbmVudEFydGlmYWN0cykgeworICAgICAgICAgICAgdGhpcy5jb21wb25lbnRBcnRpZmFjdHMgPSBjb21wb25lbnRBcnRpZmFjdHM7CisgICAgICAgIH0KIAotCXByaXZhdGUgY2xhc3MgQ3NhckRlZmluaXRpb24gewotCQlwcml2YXRlIENvbXBvbmVudEFydGlmYWN0cyBjb21wb25lbnRBcnRpZmFjdHM7CisgICAgICAgIHB1YmxpYyBDb21wb25lbnRBcnRpZmFjdHMgZ2V0Q29tcG9uZW50QXJ0aWZhY3RzKCkgeworICAgICAgICAgICAgcmV0dXJuIGNvbXBvbmVudEFydGlmYWN0czsKKyAgICAgICAgfQorICAgIH0KIAotCQkvLyBhZGQgbGlzdCBvZiB0b3NjYSBhcnRpZmFjdHMgYW5kIG1ldGEgZGVzY3JpYmVzIENTQVIgemlwIHJvb3QKKyAgICAvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqIEFydGlmYWN0cyBTdHJ1Y3R1cmUgRU5EKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwogCi0JCXB1YmxpYyBDc2FyRGVmaW5pdGlvbihDb21wb25lbnRBcnRpZmFjdHMgY29tcG9uZW50QXJ0aWZhY3RzKSB7Ci0JCQl0aGlzLmNvbXBvbmVudEFydGlmYWN0cyA9IGNvbXBvbmVudEFydGlmYWN0czsKLQkJfQorICAgIHByaXZhdGUgRWl0aGVyPENzYXJEZWZpbml0aW9uLFJlc3BvbnNlRm9ybWF0PiBjb2xsZWN0Q29tcG9uZW50Q3NhckRlZmluaXRpb24oQ29tcG9uZW50IGNvbXBvbmVudCl7CisgICAgICAgIENvbXBvbmVudEFydGlmYWN0cyBjb21wb25lbnRBcnRpZmFjdHMgPSBuZXcgQ29tcG9uZW50QXJ0aWZhY3RzKCk7CisgICAgICAgIENvbXBvbmVudCB1cGRhdGVkQ29tcG9uZW50ID0gY29tcG9uZW50OwogCi0JCXB1YmxpYyBDb21wb25lbnRBcnRpZmFjdHMgZ2V0Q29tcG9uZW50QXJ0aWZhY3RzKCkgewotCQkJcmV0dXJuIGNvbXBvbmVudEFydGlmYWN0czsKLQkJfQotCX0KKyAgICAgICAgLy9nZXQgc2VydmljZSB0byByZWNlaXZlIHRoZSBBSUkgYXJ0aWZhY3RzIHVwbG9hZGVkIHRvIHRoZSBzZXJ2aWNlCisgICAgICAgIGlmICh1cGRhdGVkQ29tcG9uZW50LmdldENvbXBvbmVudFR5cGUoKSA9PSBDb21wb25lbnRUeXBlRW51bS5TRVJWSUNFKSB7CisgICAgICAgICAgICBFaXRoZXI8U2VydmljZSwgU3RvcmFnZU9wZXJhdGlvblN0YXR1cz4gZ2V0U2VydmljZVJlc3BvbnNlID0gdG9zY2FPcGVyYXRpb25GYWNhZGUuZ2V0VG9zY2FFbGVtZW50KHVwZGF0ZWRDb21wb25lbnQuZ2V0VW5pcXVlSWQoKSk7CiAKLQkvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCi0JICogQXJ0aWZhY3RzIFN0cnVjdHVyZSBFTkQKLQkgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworICAgICAgICAgICAgaWYoZ2V0U2VydmljZVJlc3BvbnNlLmlzUmlnaHQoKSl7CisgICAgICAgICAgICAgICAgQWN0aW9uU3RhdHVzIGFjdGlvblN0YXR1cyA9IGNvbXBvbmVudHNVdGlscy5jb252ZXJ0RnJvbVN0b3JhZ2VSZXN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aW5zdGFuY2VzCisgICAgICAgIExpc3Q8Q29tcG9uZW50SW5zdGFuY2U+IGNvbXBvbmVudEluc3RhbmNlcyA9IHVwZGF0ZWRDb21wb25lbnQuZ2V0Q29tcG9uZW50SW5zdGFuY2VzKCk7CisgICAgICAgIGlmIChjb21wb25lbnRJbnN0YW5jZXMhPW51bGwpeworICAgICAgICAgICAgZm9yIChDb21wb25lbnRJbnN0YW5jZSBjb21wb25lbnRJbnN0YW5jZTpjb21wb25lbnRJbnN0YW5jZXMpeworICAgICAgICAgICAgICAgIC8vY2FsbCByZWN1cnNpdmUgdG8gZmluZCBhcnRpZmFjdHMgZm9yIGFsbCB0aGUgcGF0aAorICAgICAgICAgICAgICAgIEVpdGhlcjxCb29sZWFuLCBSZXNwb25zZUZvcm1hdD4gY29sbGVjdENvbXBvbmVudEluc3RhbmNlQXJ0aWZhY3RzID0gY29sbGVjdENvbXBvbmVudEluc3RhbmNlQXJ0aWZhY3RzKAorICAgICAgICAgICAgICAgICAgICAgICAgdXBkYXRlZENvbXBvbmVudCwgY29tcG9uZW50SW5zdGFuY2UsIHJlc291cmNlVHlwZUFydGlmYWN0cywgY29tcG9uZW50SW5zdGFuY2VBcnRpZmFjdHMpOworICAgICAgICAgICAgICAgIGlmIChjb2xsZWN0Q29tcG9uZW50SW5zdGFuY2VBcnRpZmFjdHMuaXNSaWdodCgpKXsKKyAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChjb2xsZWN0Q29tcG9uZW50SW5zdGFuY2VBcnRpZmFjdHMucmlnaHQoKS52YWx1ZSgpKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9CisgICAgICAgIH0KIAotCQkJdXBkYXRlZENvbXBvbmVudCA9IGdldFNlcnZpY2VSZXNwb25zZS5sZWZ0KCkudmFsdWUoKTsKLQkJfQorICAgICAgICBpZihsb2cuaXNEZWJ1Z0VuYWJsZWQoKSl7CisgICAgICAgICAgICBwcmludFJlc3VsdChjb21wb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V3IEVudW1NYXA8PihBcnRpZmFjdFR5cGVFbnVtLmNsYXNzKTsKKyAgICAgICAgaWYgKGNvbXBvbmVudEFydGlmYWN0cyE9bnVsbCl7CisgICAgICAgICAgICBmb3IgKEFydGlmYWN0RGVmaW5pdGlvbiBhcnRpZmFjdDpjb21wb25lbnRBcnRpZmFjdHMudmFsdWVzKCkpeworICAgICAgICAgICAgICAgIEFydGlmYWN0VHlwZUVudW0gYXJ0aWZhY3RUeXBlID0gQXJ0aWZhY3RUeXBlRW51bS5maW5kVHlwZShhcnRpZmFjdC5nZXRBcnRpZmFjdFR5cGUoKSk7CisgICAgICAgICAgICAgICAgTGlzdDxBcnRpZmFjdERlZmluaXRpb24+IHBhcmVudEFydGlmYWN0c0J5VHlwZSA9IG51bGw7CisgICAgICAgICAgICAgICAgaWYgKHBhcmVudEFydGlmYWN0cyE9bnVsbCl7CisgICAgICAgICAgICAgICAgICAgIHBhcmVudEFydGlmYWN0c0J5VHlwZSA9IHBhcmVudEFydGlmYWN0cy5nZXQoYXJ0aWZhY3RUeXBlKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgLy90aGUgYXJ0aWZhY3QgaXMgb2YgaW5zdGFuY2UKKyAgICAgICAgICAgICAgICBpZiAocGFyZW50QXJ0aWZhY3RzQnlUeXBlID09IG51bGwgfHwgIXBhcmVudEFydGlmYWN0c0J5VHlwZS5jb250YWlucyhhcnRpZmFjdCkpeworICAgICAgICAgICAgICAgICAgICBMaXN0PEFydGlmYWN0RGVmaW5pdGlvbj4gdHlwZUFydGlmYWN0cyA9IGFydGlmYWN0c0J5VHlwZU9mQ29tcG9uZW50SW5zdGFuY2UuZ2V0KGFydGlmYWN0VHlwZSk7CisgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlQXJ0aWZhY3RzID09IG51bGwpeworICAgICAgICAgICAgICAgICAgICAgICAgdHlwZUFydGlmYWN0cyA9IG5ldyBBcnJheUxpc3Q8PigpOworICAgICAgICAgICAgICAgIC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L29wZW5lY29tcC9zZGMvYmUvdG9zY2EvVG9zY2FFeHBvcnRIYW5kbGVyLmphdmEKKysrIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL3Rvc2NhL1Rvc2NhRXhwb3J0SGFuZGxlci5qYXZhCkBAIC0xLDIyICsxLDIyIEBACiAvKi0KLSAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBTREMKLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBDb3B5cmlnaHQgKEMpIDIwMTcgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7Ci0gKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCi0gKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKLSAqCisqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisqIFNEQworKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorKiBDb3B5cmlnaHQgKEMpIDIwMTcgQVQmV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HsKLSAgICAgICAgICAgIGNhc2UgUkVTT1VSQ0U6Ci0gICAgICAgICAgICAgICAgdG9zY2FSZXNvdXJjZU5hbWUgPSAoKFJlc291cmNlTWV0YWRhdGFEYXRhRGVmaW5pdGlvbikgY29tcG9uZW50LmdldENvbXBvbmVudE1ldGFkYXRhRGVmaW5pdGlvbigpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldE1ldGFkYXRhRGF0YURlZmluaXRpb24oKSkuZ2V0VG9zY2FSZXNvdXJjZU5hbWUoKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIGNhc2UgU0VSVklDRToKLSAgICAgICAgICAgICAgICB0b3NjYVJlc291cmNlTmFtZSA9IFNFUlZJQ0VfTk9ERV9UWVBFX1BSRUZJWAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArIGNvbXBvbmVudC5nZXRDb21wb25lbnRNZXRhZGF0YURlZmluaXRpb24oKS5nZXRNZXRhZGF0YURhdGFEZWZpbml0aW9uKCkuZ2V0U3lzdGVtTmFtZSgpOwotICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgZGVmYXVsdDoKLSAgICAgICAgICAgICAgICBsb2cuZGVidWcoTk9UX1NVUFBPUlRFRF9DT01QT05FTlRfVFlQRSwgY29tcG9uZW50LmdldENvbXBvbmVudFR5cGUoKSk7Ci0gICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChUb3NjYUVycm9yLk5PVF9TVVBQT1JURURfVE9TQ0FfVFlQRSk7CisgICAgICAgIGNhc2UgUkVTT1VSQ0U6CisgICAgICAgICAgICB0b3NjYVJlc291cmNlTmFtZSA9ICgoUmVzb3VyY2VNZXRhZGF0YURhdGFEZWZpbml0aW9uKSBjb21wb25lbnQuZ2V0Q29tcG9uZW50TWV0YWRhdGFEZWZpbml0aW9uKCkKKyAgICAgICAgICAgICAgICAgICAgLmdldE1ldGFkYXRhRGF0YURlZmluaXRpb24oKSkuZ2V0VG9zY2FSZXNvdXJjZU5hbWUoKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIFNFUlZJQ0U6CisgICAgICAgICAgICB0b3NjYVJlc291cmNlTmFtZSA9IFNFUlZJQ0VfTk9ERV9UWVBFX1BSRUZJWAorICAgICAgICAgICAgICAgICAgICArIGNvbXBvbmVudC5nZXRDb21wb25lbnRNZXRhZGF0YURlZmluaXRpb24oKS5nZXRNZXRhZGF0YURhdGFEZWZpbml0aW9uKCkuZ2V0U3lzdGVtTmFtZSgpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICBsb2cuZGVidWcoTk9UX1NVUFBPUlRFRF9DT01QT05FTlRfVFlQRSwgY29tcG9uZW50LmdldENvbXBvbmVudFR5cGUoKSk7CisgICAgICAgICAgICByZXR1cm4gRWl0aGVyLnJpZ2h0KFRvc2NhRXJyb3IuTk9UX1NVUFBPUlRFRF9UT1NDQV9UWVBFKTsKICAgICAgICAgfQogICAgICAgICBzdWJzdGl0dXRpb25NYXBwaW5nLnNldE5vZGVfdHlwZSh0b3NjYVJlc291cmNlTmFtZSk7CiAKQEAgLTMxNyw3ICszNjMsNyBAQAogICAgICAgICBzdWJzdGl0dXRpb25NYXBwaW5nID0gY2FwYWJpbGl0aWVzLmxlZnQoKS52YWx1ZSgpOwogCiAgICAgICAgIEVpdGhlcjxTdWJzdGl0dXRpb25NYXBwaW5nLCBUb3NjYUVycm9yPiByZXF1aXJlbWVudHMgPSBjYXBhYmlsaXR5UmVxdWlyZW1lbnRDb252ZXJ0ZXIKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmNvbnZlcnRTdWJzdGl0dXRpb25NYXBwaW5nUmVxdWlyZW1lbnRzKGNvbXBvbm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yhjb21wb25lbnQpOwotICAgICAgICBpZihwb2xpY2llcyE9IG51bGwpIHsKLSAgICAgICAgICAgIHRvcG9sb2d5VGVtcGxhdGUuYWRkUG9saWNpZXMocG9saWNpZXMpOwotICAgICAgICB9Ci0gICAgfQorICAgICAgcHJpdmF0ZSB2b2lkIGFkZFBvbGljaWVzVG9Ub3BvbG9neVRlbXBsYXRlKENvbXBvbmVudCBjb21wb25lbnQsIFRvc2NhVG9wb2xneVRlbXBsYXRlIHRvcG9sb2d5VGVtcGxhdGUpCisgICAgICAgICAgICAgICAgICB0aHJvd3MgU2RjUmVzb3VyY2VOb3RGb3VuZEV4Y2VwdGlvbiB7CisgICAgICAgICAgICBNYXA8U3RyaW5nLCBUb3NjYVBvbGljeVRlbXBsYXRlPiBwb2xpY2llcyA9IHBvbGljeUV4cG9ydFBhcnNlci5nZXRQb2xpY2llcyhjb21wb25lbnQpOworICAgICAgICAgICAgaWYocG9saWNpZXMhPSBudWxsKSB7CisgICAgICAgICAgICAgICAgICB0b3BvbG9neVRlbXBsYXRlLmFkZFBvbGljaWVzKHBvbGljaWVzKTsKKyAgICAgICAgICAgIH0KKyAgICAgIH0KIAogICAgIHByaXZhdGUgVG9zY2FNZXRhZGF0YSBjb252ZXJ0TWV0YWRhdGEoQ29tcG9uZW50IGNvbXBvbmVudCkgewogICAgICAgICByZXR1cm4gY29udmVydE1ldGFkYXRhKGNvbXBvbmVudCwgZmFsc2UsIG51bGwpOwpAQCAtMzY3LDcgKzQxMSw3IEBACiAgICAgICAgICAgICB0b3NjYU1ldGFkYXRhLnNldFZlcnNpb24oY29tcG9uZW50LmdldFZlcnNpb24oKSk7CiAgICAgICAgICAgICB0b3NjYU1ldGFkYXRhLnNldEN1c3RvbWl6YXRpb25VVUlEKGNvbXBvbmVudEluc3RhbmNlLmdldEN1c3RvbWl6YXRpb25VVUlEKCkpOwogICAgICAgICAgICAgaWYgKGNvbXBvbmVudEluc3RhbmNlLmdldFNvdXJjZU1vZGVsSW52YXJpYW50KCkgIT0gbnVsbAotICAgICAgICAgICAgICAgICAgICAgICAgJiYgIWNvbXBvbmVudEluc3RhbmNlLmdldFNvdXJjZU1vZGVsSW52YXJpYW50KCkuaXNFbXB0eSgpKSB7CisgICAgICAgICAgICAgICAgICAgICYmICFjb21wb25lbnRJbnN0YW5jZS5nZXRTb3VyY2VNb2RlbEludmFyaWFudCgpLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgIHRvc2NhTWV0YWRhdGEuc2V0VmVyc2lvbihjb21wb25lbnRJbnN0YW5jZS5nZXRDb21wb25lbnRWZXJzaW9uKCkpOwogICAgICAgICAgICAgICAgIHRvc2NhTWV0YWRhdGEuc2V0U291cmNlTW9kZWxJbnZhcmlhbnQoY29tcG9uZW50SW5zdGFuY2UuZ2V0U291cmNlTW9kZWxJbnZhcmlhbnQoKSk7CiAgICAgICAgICAgICAgICAgdG9zY2FNZXRhZGF0YS5zZXRTb3VyY2VNb2RlbFV1aWQoY29tcG9uZW50SW5zdGFuY2UuZ2V0U291cmNlTW9kZWxVdWlkKCkpOwpAQCAtMzc5LDM1ICs0MjMsMzYgQEAKIAogICAgICAgICB9CiAgICAgICAgIHN3aXRjaCAoY29tcG9uZW50LmdldENvbXBvbmVudFR5cGUoKSkgewotICAgICAgICAgICAgY2FzZSBSRVNPVVJDRToKLSAgICAgICAgICAgICAgICBSZXNvdXJjZSByZXNvdXJjZSA9IChSZXNvdXJjZSkgY29tcG9uZW50OworICAgICAgICBjYXNlIFJFU09VUkNFOgorICAgICAgICAgICAgUmVzb3VyY2UgcmVzb3VyY2UgPSAoUmVzb3VyY2UpIGNvbXBvbmVudDsKIAotICAgICAgICAgICAgICAgIGlmIChpc0luc3RhbmNlICYmIGNvbXBvbmVudEluc3RhbmNlLmdldE9yaWdpblR5cGUoKSA9PSBPcmlnaW5UeXBlRW51bS5TZXJ2aWNlUHJveHkpIHsKLSAgICAgICAgICAgICAgICAgICAgdG9zY2FNZXRhZGF0YS5zZXRUeXBlKG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pY2VSb2xlKHNlcnZpY2UuZ2V0U2VydmljZVJvbGUoKSk7Ci0gICAgICAgICAgICAgICAgdG9zY2FNZXRhZGF0YS5zZXRFbnZpcm9ubWVudENvbnRleHQoc2VydmljZS5nZXRFbnZpcm9ubWVudENvbnRleHQoKSk7Ci0gICAgICAgICAgICAgICAgcmVzb2x2ZUluc3RhbnRpYXRpb25UeXBlQW5kU2V0SXRUb1Rvc2NhTWV0YURhdGEodG9zY2FNZXRhZGF0YSwgc2VydmljZSk7Ci0gICAgICAgICAgICAgICAgaWYgKCFpc0luc3RhbmNlKSB7Ci0gICAgICAgICAgICAgICAgICAgIC8vIERFMjY4NTQ2Ci0gICAgICAgICAgICAgICAgICAgIHRvc2NhTWV0YWRhdGEuc2V0U2VydmljZUVjb21wTmFtaW5nKCgoU2VydmljZSkgY29tcG9uZW50KS5pc0Vjb21wR2VuZXJhdGVkTmFtaW5nKCkpOwotICAgICAgICAgICAgICAgICAgICB0b3NjYU1ldGFkYXRhLnNldEVjb21wR2VuZXJhdGVkTmFtaW5nKCgoU2VydmljZSkgY29tcG9uZW50KS5pc0Vjb21wR2VuZXJhdGVkTmFtaW5nKCkpOwotICAgICAgICAgICAgICAgICAgICB0b3NjYU1ldGFkYXRhLnNldE5hbWluZ1BvbGljeSgoKFNlcnZpY2UpIGNvbXBvbmVudCkuZ2V0TmFtaW5nUG9saWN5KCkpOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIGRlZmF1bHQ6Ci0gICAgICAgICAgICAgICAgbG9nLmRlYnVnKE5PVF9TVVBQT1JURURfQ09NUE9ORU5UX1RZUEUsIGNvbXBvbmVudC5nZXRDb21wb25lbnRUeXBlKCkpOworICAgICAgICAgICAgaWYgKGlzSW5zdGFuY2UgJiYgY29tcG9uZW50SW5zdGFuY2UuZ2V0T3JpZ2luVHlwZSgpID09IE9yaWdpblR5cGVFbnVtLlNlcnZpY2VQcm94eSkgeworICAgICAgICA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xlKHNlcnZpY2UuZ2V0U2VydmljZVJvbGUoKSk7CisgICAgICAgICAgICB0b3NjYU1ldGFkYXRhLnNldFNlcnZpY2VGdW5jdGlvbihzZXJ2aWNlLmdldFNlcnZpY2VGdW5jdGlvbigpKTsKKyAgICAgICAgICAgIHRvc2NhTWV0YWRhdGEuc2V0RW52aXJvbm1lbnRDb250ZXh0KHNlcnZpY2UuZ2V0RW52aXJvbm1lbnRDb250ZXh0KCkpOworICAgICAgICAgICAgcmVzb2x2ZUluc3RhbnRpYXRpb25UeXBlQW5kU2V0SXRUb1Rvc2NhTWV0YURhdGEodG9zY2FNZXRhZGF0YSwgc2VydmljZSk7CisgICAgICAgICAgICBpZiAoIWlzSW5zdGFuY2UpIHsKKyAgICAgICAgICAgICAgICAvLyBERTI2ODU0NgorICAgICAgICAgICAgICAgIHRvc2NhTWV0YWRhdGEuc2V0U2VydmljZUVjb21wTmFtaW5nKCgoU2VydmljZSkgY29tcG9uZW50KS5pc0Vjb21wR2VuZXJhdGVkTmFtaW5nKCkpOworICAgICAgICAgICAgICAgIHRvc2NhTWV0YWRhdGEuc2V0RWNvbXBHZW5lcmF0ZWROYW1pbmcoKChTZXJ2aWNlKSBjb21wb25lbnQpLmlzRWNvbXBHZW5lcmF0ZWROYW1pbmcoKSk7CisgICAgICAgICAgICAgICAgdG9zY2FNZXRhZGF0YS5zZXROYW1pbmdQb2xpY3koKChTZXJ2aWNlKSBjb21wb25lbnQpLmdldE5hbWluZ1BvbGljeSgpKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgbG9nLmRlYnVnKE5PVF9TVVBQT1JURURfQ09NUE9ORU5UX1RZUEUsIGNvbXBvbmVudC5nZXRDb21wb25lbnRUeXBlKCkpOwogICAgICAgICB9CiAgICAgICAgIHJldHVybiB0b3NjYU1ldGFkYXRhOwogICAgIH0KQEAgLTQ3Miw3ICs1MTcsNyBAQAogICAgICAgICBpZiAoY29tcG9uZW50UkkgPT0gbnVsbCkgewogICAgICAgICAgICAgLy8gYWxsIHJlc291cmNlIG11c3QgYmUgb25seSBvbmNlIQogICAgICAgICAgICAgRWl0aGVyPENvbXBvbmVudCwgU3RvcmFnZU9wZXJhdGlvblN0YXR1cz4gcmVzb3VyY2UgPSB0b3NjYU9wZXJhdGlvbkZhY2FkZQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRUb3NjYUZ1bGxFbGVtZW50KGNpLmdldENvbXBvbmVudFVpZCgpKTsKKyAgICAgICAgICAgICAgICAgICAgLmdldFRvc2NhRnVsbEVsZW1lbnQoY2kuZ2V0Q29tcG9uZW50VWlkKCkpOwogICAgICAgICAgICAgaWYgKChyZXNvdXJjZS5pc1JpZ2h0KCkpICYmIChsb2cuaXNEZWJ1Z0VuYWJsZWQoKSkpIHsKICAgICAgICAgICAgICAgICBsb2cuZGVidWcoIkZhaWxlZCB0byBmZXRjaCByZXNvdXJjZSB3aXRoIGlkIHt9IGZvciBpbnN0YW5jZSB7fSIsY2kuZ2V0Q29tcG9uZW50VWlkKCkgLGNpLmdldFVuaXF1ZUlkKCkpOwogICAgICAgICAgICAgICAgIHJldHVybiA7CkBAIC00ODMsNyArNTI4LDcgQEAKIAogICAgICAgICAgICAgaWYgKGNpLmdldE9yaWdpblR5cGUoKSA9PSBPcmlnaW5UeXBlRW51bS5TZXJ2aWNlUHJveHkpewogICAgICAgICAgICAgICAgIEVpdGhlcjxDb21wb25lbnQsIFN0b3JhZ2VPcGVyYXRpb25TdGF0dXM+IHNvdXJjZVNlcnZpY2UgPSB0b3NjYU9wZXJhdGlvbkZhY2FkZQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRUb3NjYUZ1bGxFbGVtZW50KGNpLmdldFNvdXJjZU1vZGVsVWlkKCkpOworICAgICAgICAgICAgICAgICAgICAgICAgLmdldFRvc2NhRnVsbEVsZW1lbnQoY2kuZ2V0U291cmNlTW9kZWxVaWQoKSk7CiAgICAgICAgICAgICAgICAgaWYgKHNvdXJjZVNlcnZpY2UuaXNSaWdodCgpICYmIChsb2cuaXNEZWJ1Z0VuYWJsZWQoKSkpIHsKICAgICAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCJGYWlsZWQgdG8gZmV0Y2ggc291cmNlIHNlcnZpY2Ugd2l0aCBpZCB7fSBmb3IgcHJveHkge30iLCBjaS5nZXRTb3VyY2VNb2RlbFVpZCgpLCBjaS5nZXRVbmlxdWVJZCgpKTsKICAgICAgICAgICAgICAgICB9CkBAIC01MjksOCArNTc0LDggQEAKICAgICB9CiAKICAgICBwcml2YXRlIEVpdGhlcjxUb3NjYVRlbXBsYXRlLCBUb3NjYUVycm9yPiBjb252ZXJ0SW50ZXJmYWNlTm9kZVR5cGUoTWFwPFN0cmluZywgQ29tcG9uZW50PiBjb21wb25lbnRzQ2FjaGUsCi0gICAgICAgICAgICBDb21wb25lbnQgY29tcG9uZW50LCBUb3NjYVRlbXBsYXRlIHRvc2NhTm9kZSwKLSAgICAgICAgICAgIE1hcDxTdHJpbmcsIFRvc2NhTm9kZVR5cGU+IG5vZGVUeXBlcywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29tcG9uZW50IGNvbXBvbmVudCwgVG9zY2FUZW1wbGF0ZSB0b3NjYU5vZGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1hcDxTdHJpbmcsIFRvc2NhTm9kZVR5cGU+IG5vZGVUeXBlcywKICAgICAgICAgICAgIGJvb2xlYW4gaXNBc3NvY2lhdGVkQ29tcG9uZW50KSB7CiAgICAgICAgIGxvZy5kZWJ1Zygic3RhcnQgY29udmVydCBub2RlIHR5cGUgZm9yIHt9IiwgY29tcG9uZW50LmdldFVuaXF1ZUlkKCkpOwogICAgICAgICBUb3NjYU5vZGVUeXBlIHRvc2NhTm9kZVR5cGUgPSBjcmVhdGVOb2RlVHlwZShjb21wb25lbnQpOwpAQCAtNTQyLDEwICs1ODcsMTAgQEAKICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQoVG9zY2FFcnJvci5HRU5FUkFMX0VSUk9SKTsKICAgICAgICAgfQogICAgICAgICBMaXN0PFN0cmluZz4gYWxsR2xvYmFsSW50ZXJmYWNlVHlwZXMgPSBsaWZlY3ljbGVUeXBlRWl0aGVyLmxlZnQoKS52YWx1ZSgpCi0gICAgICAgICAgICAgICAgLnZhbHVlcygpCi0gICAgICAgICAgICAgICAgLnN0cmVhbSgpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnZhbHVlcygpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnN0cmVhbSgpCiAgICAgICAgICAgICAgICAgLm1hcChJbnRlcmZhY2VEYXRhRGVmaW5pdGlvbjo6Z2V0VHlwZSkKLSAgICAgICAgICAgICAgICAuY29sbGVjdChDb2xsZWN0b3JzLnRvTGlzdCgpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuY29sbGVjdChDb2xsZWN0b3JzLnRvTGlzdCgpKTsKICAgICAgICAgdG9zY2FOb2RlLnNldEludGVyZmFjZV90eXBlcyhhZGRJbnRlcmZhY2VUeXBlRWxlbWVudChjb21wb25lbnQsIGFsbEdsb2JhbEludGVyZmFjZVR5cGVzKSk7CiAKICAgICAgICAgRWl0aGVyPE1hcDxTdHJpbmcsIERhdGFUeXBlRGVmaW5pdGlvbj4sIEphbnVzR3JhcGhPcGVyYXRpb25TdGF0dXM+IGRhdGFUeXBlc0VpdGhlciA9IGRhdGFUeXBlQ2FjaGUuZ2V0QWxsKCk7CkBAIC02MjIsMTcgKzY2NywxNyBAQAogCiAgICAgICAgIFN0cmluZyB0b3NjYVJlc291cmNlTmFtZTsKICAgICAgICAgc3dpdGNoIChjb21wb25lbnQuZ2V0Q29tcG9uZW50VHlwZSgpKSB7Ci0gICAgICAgICAgICBjYXNlIFJFU09VUkNFOgotICAgICAgICAgICAgICAgIHRvc2NhUmVzb3VyY2VOYW1lID0gKChSZXNvdXJjZU1ldGFkYXRhRGF0YURlZmluaXRpb24pIGNvbXBvbmVudC5nZXRDb21wb25lbnRNZXRhZGF0YURlZmluaXRpb24oKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRNZXRhZGF0YURhdGFEZWZpbml0aW9uKCkpLmdldFRvc2NhUmVzb3VyY2VOYW1lKCk7Ci0gICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICBjYXNlIFNFUlZJQ0U6Ci0gICAgICAgICAgICAgICAgdG9zY2FSZXNvdXJjZU5hbWUgPSBTRVJWSUNFX05PREVfVFlQRV9QUkVGSVgKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyBjb21wb25lbnQuZ2V0Q29tcG9uZW50TWV0YWRhdGFEZWZpbml0aW9uKCkuZ2V0TWV0YWRhdGFEYXRhRGVmaW5pdGlvbigpLmdldFN5c3RlbU5hbWUoKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIGRlZmF1bHQ6Ci0gICAgICAgICAgICAgICAgbG9nLmRlYnVnKE5PVF9TVVBQT1JURURfQ09NUE9ORU5UX1RZUEUsIGNvbXBvbmVudC5nZXRDb21wb25lbnRUeXBlKCkpOwotICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQoVG9zY2FFcnJvci5OT1RfU1VQUE9SVEVEX1RPU0NBX1RZUEUpOworICAgICAgICBjYXNlIFJFU09VUkNFOgorICAgICAgICAgICAgdG9zY2FSZXNvdXJjZU5hbWUgPSAoKFJlc291cmNlTWV0YWRhdGFEYXRhRGVmaW5pdGlvbikgY29tcG9uZW50LmdldENvbXBvbmVudE1ldGFkYXRhRGVmaW5pdGlvbigpCisgICAgICAgICAgICAgICAgICAgIC5nZXRNZXRhZGF0YURhdGFEZWZpbml0aW9uKCkpLmdldFRvc2NhUmVzb3VyY2VOYW1lKCk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBTRVJWSUNFOgorICAgICAgICAgICAgdG9zY2FSZXNvdXJjZU5hbWUgPSBTRVJWSUNFX05PREVfVFlQRV9QUkVGSVgKKyAgICAgICAgICAgICAgICAgICAgKyBjb21wb25lbnQuZ2V0Q29tcG9uZW50TWV0YWRhdGFEZWZpbml0aW9uKCkuZ2V0TWV0YWRhdGFEYXRhRGVmaW5pdGlvbigpLmdldFN5c3RlbU5hbWUoKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgbG9nLmRlYnVnKE5PVF9TVVBQT1JURURfQ09NUE9ORU5UX1RZUEUsIGNvbXBvbmVudC5nZXRDb21wb25lbnRUeXBlKCkpOworICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChUb3NjYUVycm9yLk5PVF9TVVBQT1JURURfVE9TQ0FfVFlQRSk7CiAgICAgICAgIH0KIAogICAgICAgICBub2RlVHlwZXMucHV0KHRvc2NhUmVzb3VyY2VOYW1lLCB0b3NjYU5vZGVUeXBlKTsKQEAgLTY2Niw3ICs3MTEsNyBAQAogICAgICAgICAgICAgbm9kZVRlbXBsYXRlLnNldE5vZGVfZmlsdGVyKGNvbnZlcnRUb05vZGVUZW1wbGF0ZU5vZGVGaWx0ZXJDb21wb25lbnQoY29tcG9uZW50SW5zdGFuY2UuZ2V0Tm9kZUZpbHRlcigpKSk7CiAKICAgICAgICAgICAgIEVpdGhlcjxDb21wb25lbnQsIEJvb2xlYW4+IG9yaWdpbkNvbXBvbmVudFJlcyA9IGNhcGFiaWxpdHlSZXF1aXJlbWVudENvbnZlcnRlcgotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZ2V0T3JpZ2luQ29tcG9uZW50KGNvbXBvbmVudENhY2hlLCBjb21wb25lbnRJbnN0YW5jZSk7CisgICAgICAgICAgICAgICAgICAgIC5nZXRPcmlnaW5Db21wb25lbnQoY29tcG9uZW50Q2FjaGUsIGNvbXBvbmVudEluc3RhbmNlKTsKICAgICAgICAgICAgIGlmIChvcmlnaW5Db21wb25lbnRSZXMuaXNSaWdodCgpKSB7CiAgICAgICAgICAgICAgICAgY29udmVydE5vZGVUZW1wbGF0ZXNSZXMgPSBFaXRoZXIucmlnaHQoVG9zY2FFcnJvci5OT0RFX1RZUEVfUkVRVUlSRU1FTlRfRVJST1IpOwogICAgICAgICAgICAgICAgIGJyZWFrOwpAQCAtNjkzLDcgKzczOCw3IEBACiAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgIEVpdGhlcjxUb3NjYU5vZGVUZW1wbGF0ZSwgVG9zY2FFcnJvcj4gY2FwYWJpbGl0aWVzID0gY2FwYWJpbGl0eVJlcXVpcmVtZW50Q29udmVydGVyCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmNvbnZlcnRDb21wb25lbnRJbnN0YW5jZUNhcGFiaWxpdGllcyhjb21wb25lbnRJbnN0YW5jZSwgZGF0YVR5cGVzLCBub2RlVGVtcGxhdGUpOworICAgICAgICAgICAgICAgICAgICAuY29udmVydENvbXBvbmVudEluc3RhbmNlQ2FwYWJpbGl0aWVzKGNvbXBvbmVudEluc3RhbmNlLCBkYXRhVHlwZXMsIG5vZGVUZW1wbGF0ZSk7CiAgICAgICAgICAgICBpZiAoY2FwYWJpbGl0aWVzLmlzUmlnaHQoKSkgewogICAgICAgICAgICAgICAgIGNvbnZlcnROb2RlVGVtcGxhdGVzUmVzID0gRWl0aGVyLnJpZ2h0KGNhcGFiaWxpdGllcy5yaWdodCgpLnZhbHVlKCkpOwogICAgICAgICAgICAgICAgIGJyZWFrOwpAQCAtODMyLDggKzg3Nyw4IEBACiAgICAgfQogCiAgICAgcHJpdmF0ZSB2b2lkIGFkZENvbXBvbmVudEluc3RhbmNlSW5wdXRzKE1hcDxTdHJpbmcsIERhdGFUeXBlRGVmaW5pdGlvbj4gZGF0YVR5cGVzLAotICAgICAgICAgICAgTWFwPFN0cmluZywgTGlzdDxDb21wb25lbnRJbnN0YW5jZUlucHV0Pj4gY29tcG9uZW50SW5zdGFuY2VzSW5wdXRzLAotICAgICAgICAgICAgU3RyaW5nIGluc3RhbmNlVW5pcXVlSWQsIE1hcDxTdHJpbmcsIE9iamVjdD4gcHJvcHMpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTWFwPFN0cmluZywgTGlzdDxDb21wb25lbnRJbnN0YW5jZUlucHV0Pj4gY29tcG9uZW50SW5zdGFuY2VzSW5wdXRzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmcgaW5zdGFuY2VVbmlxdWVJZCwgTWFwPFN0cmluZywgT2JqZWN0PiBwcm9wcykgewogCiAgICAgICAgIExpc3Q8Q29tcG9uZW50SW5zdGFuY2VJbnB1dD4gaW5zdGFuY2VJbnB1dHNMaXN0ID0gY29tcG9uZW50SW5zdGFuY2VzSW5wdXRzLmdldChpbnN0YW5jZVVuaXF1ZUlkKTsKICAgICAgICAgaWYgKGluc3RhbmNlSW5wdXRzTGlzdCAhPSBudWxsKSB7CkBAIC04NDEsNyArODg2LDcgQEAKIAogICAgICAgICAgICAgICAgIFN1cHBsaWVyPFN0cmluZz4gc3VwcGxpZXIgPSAoKSAtPiBpbnB1dC5nZXRWYWx1ZSgpICE9IG51bGwgJiYgIU9iamVjdHMuaXNOdWxsKGlucHV0LmdldFZhbHVlKCkpCiAgICAgICAgICAgICAgICAgICAgICAgICA/IGlucHV0LmdldFZhbHVlKCkgOiBpbnB1dC5nZXREZWZhdWx0VmFsdWUoKTsKLSAgICAgICAgICAgICAgICBwcm9wZXJ0eUNvbnZlcnRvci5jb252ZXJ0QW5kQWRkVmFsdWUoZGF0YVR5cGVzLCBwcm9wcywgaW5wdXQsIHN1cHBsaWVyKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHByb3BlcnR5Q29udmVydG9yLmNvbnZlcnRBbmRBZGRWYWx1ZShkYXRhVHlwZXMsIHByb3BzLCBpbnB1dCwgc3VwcGxpZXIpOwogICAgICAgICAgICAgfSk7CiAgICAgICAgIH0KICAgICB9CkBAIC04NTMsMTQgKzg5OCwxNCBAQAogCiAgICAgICAgIGlmIChpc05vdEVtcHR5KGNvbXBvbmVudEluc3RhbmNlc1Byb3BlcnRpZXMpKSB7CiAgICAgICAgICAgICBjb21wb25lbnRJbnN0YW5jZXNQcm9wZXJ0aWVzLmdldChpbnN0YW5jZVVuaXF1ZUlkKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIENvbnZlcnRzIGFuZCBhZGRzIGVhY2ggdmFsdWUgdG8gcHJvcGVydHkgbWFwCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmZvckVhY2gocHJvcCAtPiBwcm9wZXJ0eUNvbnZlcnRvci5jb252ZXJ0QW5kQWRkVmFsdWUoZGF0YVR5cGVzLCBwcm9wcywgcHJvcCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb3A6OmdldFZhbHVlKSk7CisgICAgICAgICAgICAgICAgICAgIC8vIENvbnZlcnRzIGFuZCBhZGRzIGVhY2ggdmFsdWUgdG8gcHJvcGVydHkgbWFwCisgICAgICAgICAgICAgICAgICAgIC5mb3JFYWNoKHByb3AgLT4gcHJvcGVydHlDb252ZXJ0b3IuY29udmVydEFuZEFkZFZhbHVlKGRhdGFUeXBlcywgcHJvcHMsIHByb3AsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvcDo6Z2V0VmFsdWUpKTsKICAgICAgICAgfQogICAgIH0KIAogICAgIHByaXZhdGUgdm9pZCBhZGRQcm9wZXJ0aWVzT2ZQYXJlbnRDb21wb25lbnQoTWFwPFN0cmluZywgRGF0YVR5cGVEZWZpbml0aW9uPiBkYXRhVHlwZXMsCi0gICAgICAgICAgICBDb21wb25lbnQgY29tcG9uZW50T2ZJbnN0YW5jZSwgTWFwPFN0cmluZywgT2JqZWN0PiBwcm9wcykgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29tcG9uZW50IGNvbXBvbmVudE9mSW5zdGFuY2UsIE1hcDxTdHJpbmcsIE9iamVjdD4gcHJvcHMpIHsKIAogICAgICAgICBMaXN0PFByb3BlcnR5RGVmaW5pdGlvbj4gY29tcG9uZW50UHJvcGVydGllcyA9IGNvbXBvbmVudE9mSW5zdGFuY2UuZ2V0UHJvcGVydGllcygpOwogICAgICAgICBpZiAoaXNOb3RFbXB0eShjb21wb25lbnRQcm9wZXJ0aWVzKSkgewpAQCAtODY5LDcgKzkxNCw3IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmZpbHRlcihwcm9wIC0+IFN0cmluZ1V0aWxzLmlzTm90RW1wdHkocHJvcC5nZXREZWZhdWx0VmFsdWUoKSkpCiAgICAgICAgICAgICAgICAgICAgIC8vIENvbnZlcnRzIGFuZCBhZGRzIGVhY2ggdmFsdWUgdG8gcHJvcGVydHkgbWFwCiAgICAgICAgICAgICAgICAgICAgIC5mb3JFYWNoKHByb3AgLT4gcHJvcGVydHlDb252ZXJ0b3IuY29udmVydEFuZEFkZFZhbHVlKGRhdGFUeXBlcywgcHJvcHMsIHByb3AsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm9wOjpnZXREZWZhdWx0VmFsdWUpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm9wOjpnZXREZWZhdWx0VmFsdWUpKTsKICAgICAgICAgfQogICAgIH0KIApAQCAtOTEwLDcgKzk1NSw3IEBACiAgICAgICAgICAgICB0b3NjYU5vZGVUeXBlLnNldERlc2NyaXB0aW9uKGNvbXBvbmVudC5nZXREZXNjcmlwdGlvbigpKTsKICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIFN0cmluZyBkZXJpdmVkRnJvbSA9IG51bGwgIT0gY29tcG9uZW50LmdldERlcml2ZWRGcm9tR2VuZXJpY1R5cGUoKSA/IGNvbXBvbmVudC5nZXREZXJpdmVkRnJvbUdlbmVyaWNUeXBlKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOiAidG9zY2Eubm9kZXMuUm9vdCI7CisgICAgICAgICAgICAgICAgICAgIDogInRvc2NhLm5vZGVzLlJvb3QiOwogICAgICAgICAgICAgdG9zY2FOb2RlVHlwZS5zZXREZXJpdmVkX2Zyb20oZGVyaXZlZEZyb20pOwogICAgICAgICB9CiAgICAgICAgIHJldHVybiB0b3NjYU5vZGVUeXBlOwpAQCAtOTgwLDggKzEwMjUsOCBAQAogICAgICAgICB9CiAgICAgICAgIE1hcDxTdHJpbmcsIENvbXBvbmVudEluc3RhbmNlPiBzZXJ2aWNlUHJveHlJbnN0YW5jZUxpc3QgPSBuZXcgSGFzaE1hcDw+KCk7CiAgICAgICAgIExpc3Q8Q29tcG9uZW50SW5zdGFuY2U+IHByb3h5SW5zdCA9IGNvbXBvbmVudEluc3RhbmNlcy5zdHJlYW0oKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZmlsdGVyKHAgLT4gcC5nZXRPcmlnaW5UeXBlKCkubmFtZSgpLmVxdWFscyhPcmlnaW5UeXBlRW51bS5TZXJ2aWNlUHJveHkubmFtZSgpKSkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmNvbGxlY3QoQ29sbGVjdG9ycy50b0xpc3QoKSk7CisgICAgICAgICAgICAgICAgLmZpbHRlcihwIC0+IHAuZ2V0T3JpZ2luVHlwZSgpLm5hbWUoKS5lcXVhbHMoT3JpZ2luVHlwZUVudW0uU2VydmljZVByb3h5Lm5hbWUoKSkpCisgICAgICAgICAgICAgICAgLmNvbGxlY3QoQ29sbGVjdG9ycy50b0xpc3QoKSk7CiAgICAgICAgIGlmIChwcm94eUluc3QgIT0gbnVsbCAmJiAhcHJveHlJbnN0LmlzRW1wdHkoKSkgewogICAgICAgICAgICAgZm9yIChDb21wb25lbnRJbnN0YW5jZSBpbnN0IDogcHJveHlJbnN0KSB7CiAgICAgICAgICAgICAgICAgc2VydmljZVByb3h5SW5zdGFuY2VMaXN0LnB1dChpbnN0LmdldFRvc2NhQ29tcG9uZW50TmFtZSgpLCBpbnN0KTsKQEAgLTk5Miw3ICsxMDM3LDcgQEAKICAgICAgICAgICAgIHJldHVybiByZXM7CiAgICAgICAgIH0KICAgICAgICAgRWl0aGVyPFJlc291cmNlLCBTdG9yYWdlT3BlcmF0aW9uU3RhdHVzPiBzZXJ2aWNlUHJveHlPcmlnaW4gPSB0b3NjYU9wZXJhdGlvbkZhY2FkZQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmdldExhdGVzdEJ5TmFtZSgic2VydmljZVByb3h5Iik7CisgICAgICAgICAgICAgICAgLmdldExhdGVzdEJ5TmFtZSgic2VydmljZVByb3h5Iik7CiAgICAgICAgIGlmIChzZXJ2aWNlUHJveHlPcmlnaW4uaXNSaWdodCgpKSB7CiAgICAgICAgICAgICBsb2cuZGVidWcoIkZhaWxlZCB0byBmZXR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ewpAQCAtMTA3NywxMCArMTEyMiwxMCBAQAogICAgICAgICAgICAgTGlzdDxSZXF1aXJlbWVudENhcGFiaWxpdHlSZWxEZWY+IHJlbGF0aW9ucywgQ29tcG9uZW50IG9yaWdpbkNvbXBvbmVudCwKICAgICAgICAgICAgIExpc3Q8TWFwPFN0cmluZywgVG9zY2FUZW1wbGF0ZVJlcXVpcmVtZW50Pj4gdG9zY2FSZXF1aXJlbWVudHMsIE1hcDxTdHJpbmcsIENvbXBvbmVudD4gY29tcG9uZW50Q2FjaGUpIHsKICAgICAgICAgTGlzdDxSZXF1aXJlbWVudENhcGFiaWxpdHlSZWxEZWY+IGZpbHRlcmVkUmVsYXRpb25zID0gcmVsYXRpb25zLnN0cmVhbSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5maWx0ZXIocCAtPiBjb21wb25lbnRJbnN0YW5jZS5nZXRVbmlxdWVJZCgpLmVxdWFscyhwLmdldEZyb21Ob2RlKCkpKS5jb2xsZWN0KENvbGxlY3RvcnMudG9MaXN0KCkpOworICAgICAgICAgICAgICAgIC5maWx0ZXIocCAtPiBjb21wb25lbnRJbnN0YW5jZS5nZXRVbmlxdWVJZCgpLmVxdWFscyhwLmdldEZyb21Ob2RlKCkpKS5jb2xsZWN0KENvbGxlY3RvcnMudG9MaXN0KCkpOwogICAgICAgICByZXR1cm4gaXNFbXB0eShmaWx0ZXJlZFJlbGF0aW9ucykgfHwKLSAgICAgICAgICAgICAgICAgICAgICAgZmlsdGVyZWRSZWxhdGlvbnMuc3RyZWFtKCkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuYWxsTWF0Y2gocmVsIC0+IGFkZFJlcXVpcmVtZW50KGNvbXBvbmVudEluc3RhbmNlLCBvcmlnaW5Db21wb25lbnQsIGNvbXBvbmVudC5nZXRDb21wb25lbnRJbnN0YW5jZXMoKSwgcmVsLCB0b3Nj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ICAgICAgICByZXFBbmRSZWxhdGlvbnNoaXBQYWlyLmdldENhcGFiaWxpdHkoKSwgZnJvbU9yaWdpbkNvbXBvbmVudC5nZXRVbmlxdWVJZCgpKTsKKyAgICAgICAgICAgICAgICByZXN1bHQgPSBmYWxzZTsKKyAgICAgICAgICAgICAgICBsb2cuZGVidWcoIkZhaWxlZCB0byBmaW5kIGEgY2FwYWJpbGl0eSB3aXRoIG5hbWUge30gb24gYSBjb21wb25lbnQgd2l0aCB1bmlxdWVJZCB7fSIsCisgICAgICAgICAgICAgICAgICAgICAgICByZXFBbmRSZWxhdGlvbnNoaXBQYWlyLmdldENhcGFiaWxpdHkoKSwgZnJvbU9yaWdpbkNvbXBvbmVudC5nZXRVbmlxdWVJZCgpKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KQEAgLTEyMDksNyArMTI1NCw3IEBACiAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgIH0KICAgICAgICAgcmV0dXJuIE1vZGVsQ29udmVydGVyLmlzQXRvbWljQ29tcG9uZW50KG9yaWdpbkNvbXBvbmVudCkgfHwKLSAgICAgICAgICAgICAgICAgICAgICAgaXNSZXF1aXJlbWVudEJlbG9uZ1RvT3duZXIocmVxQW5kUmVsYXRpb25zaGlwUGFpciwgcmVxdWlyZW1lbnQsIGZyb21JbnN0YW5jZUlkLCBvcmlnaW5Db21wb25lbnQpOworICAgICAgICAgICAgICAgIGlzUmVxdWlyZW1lbnRCZWxvbmdUb093bmVyKHJlcUFuZFJlbGF0aW9uc2hpcFBhaXIsIHJlcXVpcmVtZW50LCBmcm9tSW5zdGFuY2VJZCwgb3JpZ2luQ29tcG9uZW50KTsKICAgICB9CiAKICAgICBwcml2YXRlIGJvb2xlYW4gaXNSZXF1aXJlbWVudEJlbG9uZ1RvT3duZXIoUmVsYXRpb25zaGlwSW5mbyByZXFBbmRSZWxhdGlvbnNoaXBQYWlyLCBSZXF1aXJlbWVudERlZmluaXRpb24gcmVxdWlyZW1lbnQsIFN0cmluZyBmcm9tSW5zdGFuY2VJZCwgQ29tcG9uZW50IG9yaWdpbkNvbXBvbmVudCkgewpAQCAtMTIyMCw3ICsxMjY1LDcgQEAKIAogICAgIHByaXZhdGUgYm9vbGVhbiBpc0N2ZmMoQ29tcG9uZW50IGNvbXBvbmVudCkgewogICAgICAgICByZXR1cm4gY29tcG9uZW50LmdldENvbXBvbmVudFR5cGUoKSA9PSBDb21wb25lbnRUeXBlRW51bS5SRVNPVVJDRSAmJgotICAgICAgICAgICAgICAgICAgICAgICAoKFJlc291cmNlKSBjb21wb25lbnQpLmdldFJlc291cmNlVHlwZSgpID09IFJlc291cmNlVHlwZUVudW0uQ1ZGQzsKKyAgICAgICAgICAgICAgICAoKFJlc291cmNlKSBjb21wb25lbnQpLmdldFJlc291cmNlVHlwZSgpID09IFJlc291cmNlVHlwZUVudW0uQ1ZGQzsKICAgICB9CiAKICAgICBwcml2YXRlIEVpdGhlcjxTdWJzdGl0dXRpb25NYXBwaW5nLCBUb3NjYUVycm9yPiBjb252ZXJ0Q2FwYWJpbGl0aWVzKENvbXBvbmVudCBjb21wb25lbnQsCkBAIC0xMjI4LDcgKzEyNzMsNyBAQAogCiAgICAgICAgIEVpdGhlcjxTdWJzdGl0dXRpb25NYXBwaW5nLCBUb3NjYUVycm9yPiByZXN1bHQgPSBFaXRoZXIubGVmdChzdWJzdGl0dXRpb25NYXBwaW5ncyk7CiAgICAgICAgIEVpdGhlcjxNYXA8U3RyaW5nLCBTdHJpbmdbXT4sIFRvc2NhRXJyb3I+IHRvc2NhQ2FwYWJpbGl0aWVzUmVzID0gY2FwYWJpbGl0eVJlcXVpcmVtZW50Q29udmVydGVyCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuY29udmVydFN1YnN0aXR1dGlvbk1hcHBpbmdDYXBhYmlsaXRpZXMoY29tcG9u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RpbmcobW9kaWZpZXIsIG51bGwsIG51bGwsIHJlc3BvbnNlRm9ybWF0LCBBdWRpdGluZ0FjdGlvbkVudW0uQUREX1VTRVIpOwotICAgICAgICAgICAgICAgIHJldHVybiBFaXRoZXIucmlnaHQocmVzcG9uc2VGb3JtYXQpOwotICAgICAgICAgICAgfQotICAgICAgICB9CisgICAgICAgIHZhbGlkYXRlUm9sZShuZXdVc2VyKTsKIAogICAgICAgICAvLyBoYW5kbGUgbGFzdCBsb2dpbiBpZiB1c2VyIGlzIGltcG9ydAogICAgICAgICBpZiAobmV3VXNlci5nZXRMYXN0TG9naW5UaW1lKCkgPT0gbnVsbCkgewogICAgICAgICAgICAgbmV3VXNlci5zZXRMYXN0TG9naW5UaW1lKDBMKTsKICAgICAgICAgfQogCi0gICAgICAgIEVpdGhlcjxVc2VyLCBTdG9yYWdlT3BlcmF0aW9uU3RhdHVzPiBhZGRPclVwZGF0ZVVzZXJSZXE7Ci0KLSAgICAgICAgaWYgKEFjdGlvblN0YXR1cy5VU0VSX0lOQUNUSVZFLmVxdWFscyhlaXRoZXJVc2VySW5EQi5yaWdodCgpLnZhbHVlKCkpKSB7IC8vIHVzZXIKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGV4aXN0Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyB3aXRoCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBpbmFjdGl2ZQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gc3RhdGUKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIC0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHVwZGF0ZQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gdXNlcgotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gZGF0YQorICAgICAgICBVc2VyIGNyZWF0ZWRVc2VyOworICAgICAgICBpZiAoQWN0aW9uU3RhdHVzLlVTRVJfSU5BQ1RJVkUuZXF1YWxzKGVpdGhlclVzZXJJbkRCLnJpZ2h0KCkudmFsdWUoKSkpIHsgLy8gdXNlciBpbmFjdGl2ZSAtIHVwZGF0ZSBzdGF0ZSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBleGlzdAogICAgICAgICAgICAgbmV3VXNlci5zZXRMYXN0TG9naW5UaW1lKDBMKTsKLSAgICAgICAgICAgIGFkZE9yVXBkYXRlVXNlclJlcSA9IHVzZXJBZG1pbk9wZXJhdGlvbi51cGRhdGVVc2VyRGF0YShuZXdVc2VyKTsKLQotICAgICAgICB9IGVsc2UgeyAvLyB1c2VyIG5vdCBleGlzdCAtIGNyZWF0ZSBuZXcgdXNlcgotCi0gICAgICAgICAgICBpZiAobmV3VXNlci5nZXRVc2VySWQoKSAhPSBudWxsICYmICF1c2VyQWRtaW5WYWxpZGF0b3IudmFsaWRhdGVVc2VySWQobmV3VXNlci5nZXRVc2VySWQoKSkpIHsKLSAgICAgICAgICAgICAgICBsb2cuZGVidWcoImNyZWF0ZVV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gdXNlckxpc3QgPSBuZXcgQXJyYXlMaXN0PD4oKTsKKyAgICAgICAgaWYgKCFDb2xsZWN0aW9uVXRpbHMuaXNFbXB0eShyb2xlcykpIHsKICAgICAgICAgICAgIGZvciAoU3RyaW5nIHJvbGUgOiByb2xlcykgewogICAgICAgICAgICAgICAgIGlmICghdXNlckFkbWluVmFsaWRhdG9yLnZhbGlkYXRlUm9sZShyb2xlKSkgewotICAgICAgICAgICAgICAgICAgICByZXNwb25zZUZvcm1hdCA9IGNvbXBvbmVudHNVdGlscy5nZXRSZXNwb25zZUZvcm1hdChBY3Rpb25TdGF0dXMuSU5WQUxJRF9ST0xFLCByb2xlKTsKLSAgICAgICAgICAgICAgICAgICAgaGFuZGxlR2V0VXNlcnNMaXN0QXVkaXRpbmcodXNlciwgcmVzcG9uc2VGb3JtYXQsIHJvbGVzU3RyKTsKLSAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEVpdGhlci5yaWdodChyZXNwb25zZUZvcm1hdCk7CisgICAgICAgICAgICAgICAgICAgIGNvbXBvbmVudHNVdGlscy5hdWRpdEFkbWluVXNlckFjdGlvbkFuZFRocm93RXhjZXB0aW9uKEdFVF9VU0VSU19MSVNULCB1c2VyLCBudWxsLCBudWxsLCBBY3Rpb25TdGF0dXMuSU5WQUxJRF9ST0xFLCByb2xlKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgZ2V0UmVzcG9uc2UgPSBnZXRVc2Vyc1BlclJvbGUocm9sZSwgdXNlciwgcm9sZXNTdHIpOwotICAgICAgICAgICAgICAgIHJlc3VsdExpc3QuYWRkQWxsKGdldFJlc3BvbnNlLmxlZnQoKS52YWx1ZSgpKTsKKyAgICAgICAgICAgICAgICB1c2VyTGlzdC5hZGRBbGwoZ2V0UmVzcG9uc2UubGVmdCgpLnZhbHVlKCkpOwogICAgICAgICAgICAgfQogICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgcm9sZXNTdHIgPSAiQWxsIjsKICAgICAgIC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5lc3NMb2dpY0V4dC5qYXZhCm5ldyBmaWxlIG1vZGUgMTAwNjQ0CmluZGV4IDAwMDAwMDAuLjM4YjQzMzkKLS0tIC9kZXYvbnVsbAorKysgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvdXNlci9Vc2VyQnVzaW5lc3NMb2dpY0V4dC5qYXZhCkBAIC0wLDAgKzEsMTMwIEBACisvKi0KKyAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBTREMKKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBDb3B5cmlnaHQgKEMpIDIwMjAgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7CisgKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCisgKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKKyAqCisgKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAorICoKKyAqIFVubGVzcyByZXF1aXJlZCBieSBhcHBsaWNhYmxlIGxhdyBvciBhZ3JlZWQgdG8gaW4gd3JpdGluZywgc29mdHdhcmUKKyAqIGRpc3RyaWJ1dGVkIHVuZGV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F0ZSA9IGNvbXBvbmVudC5nZXRMaWZlY3ljbGVTdGF0ZSgpOworICAgICAgICAgICAgTGlmZUN5Y2xlVHJhbnNpdGlvbkVudW0gdHJhbnNpdGlvbiA9IGdldExpZmVDeWNsZVRyYW5zaXRpb24oY3VycmVudFN0YXRlKTsKKyAgICAgICAgICAgIGlmICh0cmFuc2l0aW9uID09IG51bGwpIHsKKyAgICAgICAgICAgICAgICBsb2cuZGVidWcoIkVycm9uZW91cyBjb21wb25lbnQgc3RhdGUgd2hlbiBkZWFjdGl2YXRpbmcgdXNlciBmb3IgY29tcG9uZW50IHt9IHN0YXRlIGlzIHt9IiwgY29tcG9uZW50SWQsIGN1cnJlbnRTdGF0ZSk7CisgICAgICAgICAgICAgICAgY29udGludWU7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBFaXRoZXI8PyBleHRlbmRzIENvbXBvbmVudCwgUmVzcG9uc2VGb3JtYXQ+IHJlc3VsdCA9IGxpZmVjeWNsZUJ1c2luZXNzTG9naWMuY2hhbmdlQ29tcG9uZW50U3RhdGUoY29tcG9uZW50LmdldENvbXBvbmVudFR5cGUoKSwgY29tcG9uZW50SWQsIHVzZXJUb0RlYWN0aXZhdGUsCisgICAgICAgICAgICAgICAgICAgIHRyYW5zaXRpb24sIGNoYW5nZUluZm8sIGZhbHNlLCB0cnVlKTsKKyAgICAgICAgICAgIGlmIChyZXN1bHQuaXNSaWdodCgpKSB7CisgICAgICAgICAgICAgICAgZmFpbGVkQ29tcG9uZW50cy5hZGQoY29tcG9uZW50LmdldE5hbWUoKSk7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICAgICAgaWYgKENvbGxlY3Rpb25VdGlscy5pc05vdEVtcHR5KGZhaWxlZENvbXBvbmVudHMpKSB7CisgICAgICAgICAgICBTdHJpbmcgY29tcG9uZW50TGlzdCA9IGZhaWxlZENvbXBvbmVudHMudG9TdHJpbmcoKTsKKyAgICAgICAgICAgIGxvZy5lcnJvcihFY29tcExvZ2dlckV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F2YQpAQCAtMCwwICsxLDcwIEBACisvKi0KKyAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBTREMKKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBDb3B5cmlnaHQgKEMpIDIwMjAgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7CisgKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCisgKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKKyAqCisgKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAorICoKKyAqIFVubGVzcyByZXF1aXJlZCBieSBhcHBsaWNhYmxlIGxhdyBvciBhZ3JlZWQgdG8gaW4gd3JpdGluZywgc29mdHdhcmUKKyAqIGRpc3RyaWJ1dGVkIHVuZGVyIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1dGVkIG9uIGFuICJBUyBJUyIgQkFTSVMsCisgKiBXSVRIT1VUIFdBUlJBTlRJRVMgT1IgQ09ORElUSU9OUyBPRiBBTlkgS0lORCwgZWl0aGVyIGV4cHJlc3Mgb3IgaW1wbGllZC4KKyAqIFNlZSB0aGUgTGljZW5zZSBmb3IgdGhlIHNwZWNpZmljIGxhbmd1YWdlIGdvdmVybmluZyBwZXJtaXNzaW9ucyBhbmQKKyAqIGxpbWl0YXRpb25zIHVuZGVyIHRoZSBMaWNlbnNlLgorICogPT09PT09PT09PT09TElDRU5TRV9FTkQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqLworCitwYWNrYWdlIG9yZy5vcGVuZWNvbXAuc2RjLmJlLnVzZXI7CisKK2ltcG9ydCBvcmcub3BlbmVjb21wLnNkYy5iZS5jYXRhbG9nLmFwaS5JVHlwZU1lc3NhZ2U7CisKK3B1YmxpYyBjbGFzcyBVc2VyTWVzc2FnZSBpbXBsZW1lbnRzIElUeXBlTWVzc2FnZXsKKyAgICBwcml2YXRlIFVzZXJPcGVyYXRpb25FbnVtIG9wZXJhdGlvbjsKKyAgICBwcml2YXRlIFN0cmluZyB1c2VySWQ7CisgICAgcHJpdmF0ZSBTdHJpbmcgcm9sZTsKKworICAgIHB1YmxpYyBVc2VyTWVzc2FnZShVc2VyT3BlcmF0aW9uRW51bSBvcGVyYXRpb24sIFN0cmluZyB1c2VySWQsIFN0cmluZyByb2xlKSB7CisgICAgICAgIHRoaXMuc2V0T3BlcmF0aW9uKG9wZXJhdGlvbik7CisgICAgICAgIHRoaXMuc2V0VXNlcklkKHVzZXJJZCk7CisgICAgICAgIHRoaXMuc2V0Um9sZShyb2xlKTsKKyAgICB9CisKKyAgICBwdWJsaWMgVXNlck9wZXJhdGlvbkVudW0gZ2V0T3BlcmF0aW9uKCkgeworICAgICAgICByZXR1cm4gb3BlcmF0aW9uOworICAgIH0KKworICAgIHB1YmxpYyB2b2lkIHNldE9wZXJhdGlvbihVc2VyT3BlcmF0aW9uRW51bSBvcGVyYXRpb24pIHsKKyAgICAgICAgdGhpcy5vcGVyYXRpb24gPSBvcGVyYXRpb247CisgICAgfQorCisgICAgcHVibGljIFN0cmluZyBnZXRVc2VySWQoKSB7CisgICAgICAgIHJldHVybi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9iZS91c2VyL1VzZXJPcGVyYXRpb25FbnVtLmphdmEKaW5kZXggMjA3NjNkMC4uYzRjYzYyZCAxMDA2NDQKLS0tIGEvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2NvbW1vbi90cmFuc2FjdGlvbi9hcGkvSURCQWN0aW9uLmphdmEKKysrIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL3VzZXIvVXNlck9wZXJhdGlvbkVudW0uamF2YQpAQCAtMiwxNCArMiwxNCBAQAogICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KICAqIFNEQwogICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIENvcHlyaWdodCAoQykgMjAxNyBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqIENvcHlyaWdodCAoQykgMjAyMCBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KICAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CiAgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKICAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KICAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAotICogCisgKgogICogICAgICBodHRwOi8vd3d3L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PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIFNEQwotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIENvcHlyaWdodCAoQykgMjAxNyBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKLSAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KLSAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAotICogCi0gKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAotICogCi0gKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlCi0gKiBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0cmlidXRlZCBvbiBhbiAiQVMgSVMiIEJBU0lTLAotICogV0lUSE9VVCBXQVJSQU5USUVTIE9SIENPTkRJVElPTlMgT0YgQU5ZIEtJTkQsIGVpdGhlciBleHByZXNzIG9yIGltcGxpZWQuCi0gKiBTZWUgdGhlIExpY2Vuc2UgZm9yIHRoZSBzcGVjaWZpYyBsYW5ndWFnZSBnb3Zlcm5pbmcgcGVybWlzc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Ci0gICAgcHVibGljIHN0YXRpYyB2b2lkIHNldExvZyhMb2dnZXIgbG9nKSB7Ci0gICAgICAgIFJvbGxiYWNrSGFuZGxlci5sb2cgPSBsb2c7Ci0gICAgfQotfQpkaWZmIC0tZ2l0IGEvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2NvbW1vbi90cmFuc2FjdGlvbi9hcGkvVHJhbnNhY3Rpb25VdGlscy5qYXZhIGIvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2NvbW1vbi90cmFuc2FjdGlvbi9hcGkvVHJhbnNhY3Rpb25VdGlscy5qYXZhCmRlbGV0ZWQgZmlsZSBtb2RlIDEwMDY0NAppbmRleCA2MGY4OWNlLi4wMDAwMDAwCi0tLSBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9jb21tb24vdHJhbnNhY3Rpb24vYXBpL1RyYW5zYWN0aW9uVXRpbHMuamF2YQorKysgL2Rldi9udWxsCkBAIC0xLDg1ICswLDAgQEAKLS8qLQotICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIFNEQwotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIENvcHlyaWdodCAoQykgMjAxNyBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIk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RU5FUkFMOwotICAgICAgICAgICAgbG9nLmVycm9yKCIjZG9BY3Rpb24gLSB7fSwgZXMgYWN0aW9uIGZhaWxlZCB3aXRoIGVycm9yIDogIiwgcmVzdWx0LCBkYW9FeGNlcHRpb24pOwotICAgICAgICB9Ci0gICAgICAgIHJldHVybiByZXN1bHQ7Ci0gICAgfQotCi19CmRpZmYgLS1naXQgYS9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvY29tbW9uL3RyYW5zYWN0aW9uL2ltcGwvRVNSb2xsYmFja0hhbmRsZXIuamF2YSBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9jb21tb24vdHJhbnNhY3Rpb24vaW1wbC9FU1JvbGxiYWNrSGFuZGxlci5qYXZhCmRlbGV0ZWQgZmlsZSBtb2RlIDEwMDY0NAppbmRleCBkYTFkYjgwLi4wMDAwMDAwCi0tLSBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9jb21tb24vdHJhbnNhY3Rpb24vaW1wbC9FU1JvbGxiYWNrSGFuZGxlci5qYXZhCisrKyAvZGV2L251bGwKQEAgLTEsOTYgKzAsMCBAQAotLyotCi0gKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogU0RDCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIExp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uZWNvbXAvc2RjL2NvbW1vbi90cmFuc2FjdGlvbi9pbXBsL0phbnVzR3JhcGhDb21taXRIYW5kbGVyLmphdmEKKysrIC9kZXYvbnVsbApAQCAtMSw1MiArMCwwIEBACi0vKi0KLSAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBTREMKLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBDb3B5cmlnaHQgKEMpIDIwMTcgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7Ci0gKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCi0gKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKLSAqIAotICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKLSAqIAotICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZQotICogZGlzdHJpYnV0ZWQgdW5kZXIgdGhlIExpY2Vuc2UgaXMgZGlzdHJpYnV0ZWQgb24gYW4gIkFTIElTIiBCQVNJUywKLSAqIFdJVEhPVVQgV0FSUkFOVElFUyBPUiBDT05ESV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VkMjYzM2YuLjAwMDAwMDAKLS0tIGEvY2F0YWxvZy1iZS9zcmMvbWFpbi9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2NvbW1vbi90cmFuc2FjdGlvbi9pbXBsL0phbnVzR3JhcGhSb2xsYmFja0hhbmRsZXIuamF2YQorKysgL2Rldi9udWxsCkBAIC0xLDU1ICswLDAgQEAKLS8qLQotICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIFNEQwotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIENvcHlyaWdodCAoQykgMjAxNyBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKLSAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KLSAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAotICogCi0gKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAotICogCi0gKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlCi0gKiBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0cmlidXRlZCB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ZGlmZiAtLWdpdCBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9jb21tb24vdHJhbnNhY3Rpb24vbW5nci9Db21taXRNYW5hZ2VyLmphdmEgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvY29tbW9uL3RyYW5zYWN0aW9uL21uZ3IvQ29tbWl0TWFuYWdlci5qYXZhCmRlbGV0ZWQgZmlsZSBtb2RlIDEwMDY0NAppbmRleCBhYmU0YzM3Li4wMDAwMDAwCi0tLSBhL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9jb21tb24vdHJhbnNhY3Rpb24vbW5nci9Db21taXRNYW5hZ2VyLmphdmEKKysrIC9kZXYvbnVsbApAQCAtMSw4NiArMCwwIEBACi0vKi0KLSAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBTREMKLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBDb3B5cmlnaHQgKEMpIDIwMTcgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7Ci0gKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCi0gKiBZb3UgbWF5IG9idGFp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ogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIFNEQwotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIENvcHlyaWdodCAoQykgMjAxNyBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKLSAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KLSAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAotICogCi0gKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAotICogCi0gKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlCi0gKiBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0cmlidXRlZCBvbiBhbiAiQVMgSVMiIEJBU0lTLAotICogV0lUSE9VVCBXQVJSQU5USUVTIE9SIENPTkRJVElPTlMgT0YgQU5ZIEtJTkQsIGVpdGhlciBleHByZXNzIG9yIGltcGxpZWQuCi0gKiBTZWUgdGhlIExpY2Vuc2UgZm9yIHRoZSBzcGVjaWZpYyBsYW5ndWFnZSBnb3Zlcm5pbmcgcGVyb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ltcGwoZ2VuZXJhdGVUcmFuc2FjdGlvbklEKCksIHVzZXJJZCwgYWN0aW9uVHlwZSwgZXNDYXRhbG9nRGFvLAotICAgICAgICAgICAgamFudXNHcmFwaEdlbmVyaWNEYW8pOwotICAgICAgICB0cmFuc2FjdGlvbnMuYWRkKHR4KTsKLQotICAgICAgICByZXR1cm4gdHg7Ci0KLSAgICB9Ci0KLSAgICBwcml2YXRlIEludGVnZXIgZ2VuZXJhdGVUcmFuc2FjdGlvbklEKCkgewotICAgICAgICBib29sZWFuIGdlbmVyYXRlZFN1Y2Nlc3NmdWxseSA9IGZhbHNlOwotICAgICAgICBpbnQgbmV4dElkID0gMDsKLQotICAgICAgICB3aGlsZSAoIWdlbmVyYXRlZFN1Y2Nlc3NmdWxseSkgewotICAgICAgICAgICAgaW50IHByZXZJZCA9IHRyYW5zYWN0aW9uSURDb3VudGVyLmdldCgpOwotICAgICAgICAgICAgaWYgKHByZXZJZCA+IFRyYW5zYWN0aW9uVXRpbHMuVFJBTlNBQ1RJT05fSURfUkVTRVRfTElNSVQpIHsKLSAgICAgICAgICAgICAgICByZXNldFRyYW5zYWN0aW9uSWQoKTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIG5leHRJZCA9IHByZXZJZCArIDE7Ci0gICAgICAgICAgICBnZW5lcmF0ZWRTdWNjZXNzZnVsbHkgPSB0cmFuc2FjdGlvbklEQ291bnRlci5jb21wYXJlQW5kU2V0KHByZXZJZCwgbmV4dElkKTsKLSAgICAgICAgfQotICAgICAgICByZXR1cm4gbmV4dElkOwotICAgIH0KLQotICAgIHByaXZhdGUgdm9pZCByZXNldFRyYW5zYWN0aW9uSWQoKSB7Ci0KLSAgICAgICAgYm9vbGVhbiByZXNldFN1Y2Nlc3NmdWxseSA9IGZhbHNlOwotICAgICAgICB3aGlsZSAoIXJlc2V0U3VjY2Vzc2Z1bGx5KSB7Ci0gICAgICAgICAgICBpbnQgcHJldklkID0gdHJhbnNhY3Rpb25JRENvdW50ZX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9jb21tb24vdHJhbnNhY3Rpb24vbW5nci9UcmFuc2FjdGlvblNkbmNJbXBsLmphdmEKKysrIC9kZXYvbnVsbApAQCAtMSwyOTggKzAsMCBAQAotLyotCi0gKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogU0RDCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOwotICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgotICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0Ci0gKiAKLSAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wCi0gKiAKLSAqIFVubGVzcyByZXF1aXJlZCBieSBhcHBsaWNhYmxlIGxhdyBvciBhZ3JlZWQgdG8gaW4gd3JpdGluZywgc29mdHdhcmUKLSAqIGRpc3RyaWJ1dGVkIHVuZGVyIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1dGVkIG9uIGFuICJBUyBJUyIgQkFTSVMsCi0gKiBXSVRIT1VUIFdBUlJBTlRJRVMgT1IgQ09ORElUSU9OUyBPRiBBTlkgS0lORCwg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iA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDIwIEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgorICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0CisgKgorICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKKyAqCisgKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlCisgKiBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0cmlidXRlZCBvbiBhbiAiQVMgSVMiIEJBU0lTLAorICogV0lUSE9VVCBXQVJSQU5USUVTIE9SIENPTkRJVElPTlMgT0YgQU5ZIEtJTkQsIGVpdGhlciBleHByZXNzIG9yIGltcGxpZWQuCisgKiBTZWUgdGhlIExpY2Vuc2UgZm9yIHRoZSBzcGVjaWZpYyBsYW5ndWFnZSBnb3Zlcm5pbmcgcGVybWlzc2lvbnMgYW5kCisgKiBsaW1pdGF0aW9ucyB1bmRlciB0aGUgTGljZW5zZS4KKyAqID09PT09PT09PT09PUxJQ0VOU0VfRU5EPT09PT09PT09PT09PT09PT09PT09PT09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cgSHR0cENsaWVudENvbmZpZ0ltbXV0YWJsZShodHRwQ2xpZW50Q29uZmlnKTsKKyAgICAgICAgUmVxdWVzdENvbmZpZyByZXF1ZXN0Q29uZmlnID0gY3JlYXRlQ2xpZW50VGltZW91dENvbmZpZ3VyYXRpb24oaW1tdXRhYmxlSHR0cENsaWVudENvbmZpZyk7CisgICAgICAgIHJldHVybiBIdHRwQ2xpZW50cy5jdXN0b20oKQorICAgICAgICAgICAgICAgIC5zZXRDb25uZWN0aW9uTWFuYWdlcihjb25uTWFuYWdlcikKKyAgICAgICAgICAgICAgICAuc2V0RGVmYXVsdFJlcXVlc3RDb25maWcocmVxdWVzdENvbmZpZykKKyAgICAgICAgICAgICAgICAuc2V0VXNlclRva2VuSGFuZGxlcih1c2VyVG9rZW5IYW5kbGVyKQorICAgICAgICAgICAgICAgIC5zZXRSZXRyeUhhbmRsZXIocmVzb2x2ZVJldHJ5SGFuZGxlcihpbW11dGFibGVIdHRwQ2xpZW50Q29uZmlnKSkKKyAgICAgICAgICAgICAgICAuYnVpbGQoKTsKKyAgICB9CisKKyAgICBwcml2YXRlICBSZXF1ZXN0Q29uZmlnIGNyZWF0ZUNsaWVudFRpbWVvdXRDb25maWd1cmF0aW9uKEh0dHBDbGllbnRDb25maWdJbW11dGFibGUgY29uZmlnKSB7CisgICAgICAgIHJldHVybiBSZXF1ZXN0Q29uZmlnLmN1c3RvbSgpCisgICAgICAgICAgICAgICAgLnNldENvbm5lY3RUaW1lb3V0KGNvbmZpZy5nZXRDb25uZWN0VGltZW91dE1zKCkpCisgICAgICAgICAgICAgICAgLnNldFNvY2tldFRpbWVvdXQoY29uZmlnLmdldFJlYWRUaW1lb3V0TXMoKSkKKyAgICAgICAgICAgICAgICAuc2V0Q29ubmVjdGlvblJlcXVlc3RUaW1lb3V0KGNvbmZpZy5nZXRDb25uZWN0UG9vbFRpbWVvdXRNcygpKQorICAgICAgICAgICAgICAgIC5idWlsZCgpOworICAgIH0KKworICAgIHByaXZhdGUgSHR0cFJlcXVlc3RSZXRyeUhhbmRsZXIgcmVzb2x2ZVJldHJ5SGFuZGxlcihIdHRwQ2xpZW50Q29uZmlnSW1tdXRhYmxlIGNvbmZpZykgeworICAgICAgICByZXR1cm4gY29uZmlnLmdldE51bU9mUmV0cmllcygpID4gMCA/IGNvbmZpZy5nZXRSZXRyeUhhbmRsZXIoKSA6IG51bGw7CisgICAgfQorCit9CmRpZmYgLS1naXQgYS9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvY29uZmlnL09iamVjdE1hcHBlclByb3ZpZGVyLmphdmEgYi9jYXRhbG9nLWJlL3NyYy9tYWluL2phdmEvb3JnL29wZW5lY29tcC9zZGMvY29uZmlnL09iamVjdE1hcHBlclByb3ZpZGVyLmphdmEKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uOGI1ZjdlZAotLS0gL2Rldi9udWxsCisrKyBiL2NhdGFsb2ctYmUvc3JjL21haW4vamF2YS9vcmcvb3BlbmVjb21wL3NkYy9jb25maWcvT2JqZWN0TWFwcGVyUHJvdmlkZXIuamF2YQpAQCAtMCwwICsxLDUxIEBACisvKi0KKyAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBTREMKKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBDb3B5cmlnaHQgKEMpIDIwMjAgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMa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246ICJDRFMgZGVwbG95bWVudCBhcnRpZmFjdCIKLSAgICAgIGZpbGVFeHRlbnNpb246ICJ6aXAiCiAjICBoZWF0OgogIyAgICAgIGRpc3BsYXlOYW1lOiAiQmFzZSBIRUFUIFRlbXBsYXRlIgogIyAgICAgIHR5cGU6IEhFQVQKQEAgLTMyMSw3ICszMDQsMTAgQEAKICAgICBpc1Byb3h5OiBmYWxzZQogICAgIHByb2JlSW50ZXJ2YWxJblNlY29uZHM6IDE1CiAKLWRlZmF1bHRIZWF0QXJ0aWZhY3RUaW1lb3V0TWludXRlczogNjAKK2hlYXRBcnRpZmFjdERlcGxveW1lbnRUaW1lb3V0OgorICBkZWZhdWx0TWludXRlczogMzAKKyAgbWluTWludXRlczogMQorICBtYXhNaW51dGVzOiAxMjAKIAogc2VydmljZURlcGxveW1lbnRBcnRpZmFjdHM6CiAgICAgQ09OVFJPTExFUl9CTFVFUFJJTlRfQVJDSElWRToKQEAgLTM1Miw3ICszMzgsNyBAQAogICAgICAgICAgICAgLSB4bWwKICAgICBBQUlfVkZfSU5TVEFOQ0VfTU9ERUw6CiAgICAgICAgIGFjY2VwdGVkVHlwZXM6Ci0gICAgICAgICAgICAtIHhtbCAKKyAgICAgICAgICAgIC0geG1sCiAgICAgQ0xPVURfVEVDSE5PTE9HWV9TUEVDSUZJQ19BUlRJRkFDVDoKICAgICAgICAgYWNjZXB0ZWRUeXBlczoKICAgICAgICAgICAgIC0gemlwCkBAIC00NjUsNyArNDUxLDcgQEAKICAgICAgICAgYWNjZXB0ZWRUeXBlczoKICAgICAgICAgdmFsaWRGb3JSZXNvdXJjZVR5cGVzOgogICAgICAgICAgICAgLSBWRgotICAgICAgICAgICAgLSBWRkNNVCAgICAgICAKKyAgICAgICAgICAgIC0gVkZDTVQKICAgICBEQ0FFX0VWRU5UOgogICAgICAgICBhY2NlcHRlZFR5cGVzOgogICAgICAgICB2YWxpZEZvclJlc291cmNlVHlwZXM6CkBAIC01MjEsNyArNTA3LDYgQEAKIC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jbGFzc2ljLmJvb2xleC5Pbk1hcmtlckV2YWx1YXRvciI+CisgICAgICAgICAgICAgICAgPG1hcmtlcj5JTlZPS0U8L21hcmtlcj4KKyAgICAgICAgICAgICAgICA8bWFya2VyPklOVk9LRS1SRVRVUk48L21hcmtlcj4KKyAgICAgICAgICAgICAgICA8bWFya2VyPklOVk9LRS1TWU5DSFJPTk9VUzwvbWFya2VyPgorICAgICAgICAgICAgPC9ldmFsdWF0b3I+CisgICAgICAgICAgICA8b25NaXNtYXRjaD5ERU5ZPC9vbk1pc21hdGNoPgorICAgICAgICAgICAgPG9uTWF0Y2g+QUNDRVBUPC9vbk1hdGNoPgorICAgICAgICA8L2ZpbHRlcj4KKworICAgICAgICA8cm9sbGluZ1BvbGljeSBjbGFzcz0iY2gucW9zLmxvZ2JhY2suY29yZS5yb2xsaW5nLkZpeGVkV2luZG93Um9sbGluZ1BvbGljeSI+CisgICAgICAgICAgICA8ZmlsZU5hbWVQYXR0ZXJuPiR7bG9nLmhvbWV9LyR7RUNPTVAtY29tcG9uZW50LW5hbWV9LyR7RUNPTVAtc3ViY29tcG9uZW50LW5hbWV9L21ldHJpY3MubG9nLiVpCisgICAgICAgICAgICA8L2ZpbGVOYW1lUGF0dGVybj4KKyAgICAgICAgICAgIDxtaW5JbmRleD4xPC9taW5JbmRleD4KKyAgICAgICAgICAgIDxtYXhJbmRleD4xMDwvbWF4SW5kZXg+CisgICAgICAgIDwvcm9sbGluZ1BvbGljeT4KKworICAgICAgICA8dHJpZ2dlcmluZ1BvbGljeSBjbGFzcz0iY2gucW9zLmxvZ2JhY2suY29yZS5yb2xsaW5nLlNpemVCYXNlZFRyaWdnZXJpbmdQb2xpY3kiPgorICAgICAgICAgICAgPG1heEZpbGVTaXplPjIwTUI8L21heEZpbGVTaXplPgorICAgICAgICA8L3RyaWdnZXJpbmdQb2xpY3k+CisKKyAgICAgICAgPGVuY29kZXI+CisgICAgICAgICAgICA8cGF0dGVybj4ke21ldHJpYy1sb2ctcGF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GxpY2F0aW9uL2pzb24nLCAnQWNjZXB0OiBhcHBsaWNhdGlvbi9qc29uJywgYWRtaW5IZWFkZXJdKQorCQljLnNldG9wdChweWN1cmwuSFRUUEhFQURFUiwgW2FkbWluSGVhZGVyXSkKIAotICAgICAgICBhZG1pbkhlYWRlciA9ICdVU0VSX0lEOiAnICsgYWRtaW5Vc2VyCi0gICAgICAgICMgYy5zZXRvcHQocHljdXJsLkhUVFBIRUFERVIsIFsnQ29udGVudC1UeXBlOiBhcHBsaWNhdGlvbi9qc29uJywgJ0FjY2VwdDogYXBwbGljYXRpb24vanNvbicsIGFkbWluSGVhZGVyXSkKLSAgICAgICAgYy5zZXRvcHQocHljdXJsLkhUVFBIRUFERVIsIFthZG1pbkhlYWRlcl0pCisJCXltbF9wYXRoID0gZmlsZURpciArIEVMRU1FTlRfTkFNRSArICIvIiArIEVMRU1FTlRfTkFNRSArICIueW1sIgorCQlwYXRoID0gZmlsZURpciArIEVMRU1FTlRfTkFNRSArICIvIiArIEVMRU1FTlRfTkFNRSArICIuemlwIgogCi0gICAgICAgIHltbF9wYXRoID0gZmlsZURpciArIEVMRU1FTlRfTkFNRSArICIvIiArIEVMRU1FTlRfTkFNRSArICIueW1sIgotICAgICAgICBwYXRoID0gZmlsZURpciArIEVMRU1FTlRfTkFNRSArICIvIiArIEVMRU1FTlRfTkFNRSArICIuemlwIgorCQl6ZiA9IHppcGZpbGUuWmlwRmlsZShwYXRoLCAidyIpCisJCXpmLndyaXRlKHltbF9wYXRoLCBFTEVNRU5UX05BTUUgKyAnLnltbCcpCisJCXpmLmNsb3NlKCkKIAotICAgICAgICB6ZiA9IHppcGZpbGUuWmlwRmlsZShwYXRoLCAidyIpCi0gICAgICAgIHpmLndyaXRlKHltbF9wYXRoLCBFTEVNRU5UX05BTUUgKyAnLnltbCcpCi0gICAgICAgIHpmLmNsb3NlKCkKKwkJZGVidWcocGF0aCkKKyAgICAgICAgCUNVUlJFTlRfSlNPTl9GSUxFPWZpbGVEaXI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HX1NUUik7CmRpZmYgLS1naXQgYS9jYXRhbG9nLWJlL3NyYy90ZXN0L2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvY2F0YWxvZy9pbXBsL0RtYWFwUHJvZHVjZXJUZXN0LmphdmEgYi9jYXRhbG9nLWJlL3NyYy90ZXN0L2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvY2F0YWxvZy9pbXBsL0RtYWFwUHJvZHVjZXJUZXN0LmphdmEKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uYWYwNjg3YwotLS0gL2Rldi9udWxsCisrKyBiL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jYXRhbG9nL2ltcGwvRG1hYXBQcm9kdWNlclRlc3QuamF2YQpAQCAtMCwwICsxLDE0MCBAQAorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDIwIEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgorICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZS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uYW55KFVzZXIuY2xhc3MpLCBNb2NraXRvLmFueUJvb2xlYW4oKSwgTW9ja2l0by5hbnlCb29sZWFuKCksIE1vY2tpdG8uYW55Qm9vbGVhbigpLCBNb2NraXRvLmVxKG51bGwpLCBNb2NraXRvLmVxKG51bGwpLCBNb2NraXRvLmVxKGZhbHNlKSkpCi0gICAgICAgICAgICAgICAgLnRoZW5BbnN3ZXIobmV3IEFuc3dlcjxJbW11dGFibGVQYWlyPFJlc291cmNlLCBBY3Rpb25TdGF0dXM+PigpIHsKLSAgICAgICAgICAgICAgICAgICAgcHVibGljIEltbXV0YWJsZVBhaXI8UmVzb3VyY2UsIEFjdGlvblN0YXR1cz4gYW5zd2VyKEludm9jYXRpb25Pbk1vY2sgaW52b2NhdGlvbikgdGhyb3dzIFRocm93YWJsZSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBPYmplY3RbXSBhcmdzID0gaW52b2NhdGlvbi5nZXRBcmd1bWVudHMoKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgSW1tdXRhYmxlUGFpcjw+KChSZXNvdXJjZSkgYXJnc1swXSwgQWN0aW9uU3RhdHVzLkNSRUFURUQpOworICAgICAgICAgICAgICAgIC50aGVuQW5zd2VyKChBbnN3ZXI8SW1tdXRhYmxlUGFpcjxSZXNvdXJjZSwgQWN0aW9uU3RhdHVzPj4pIGludm9jYXRpb24gLT4geworICAgICAgICAgICAgICAgICAgICBPYmplY3RbXSBhcmdzID0gaW52b2NhdGlvbi5nZXRBcmd1bWVudHMoKTsKKyAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBJbW11dGFibGVQYWlyPD4oKFJlc291cmNlKSBhcmdzWzBdLCBBY3Rpb25TdGF0dXMuQ1JFQVRFRCk7CiAKLSAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0pOwogICAgICAgICB3aGVuKHJlc291cmNlQnVzaW5lc3NMb2dpYy5wcm9wYWdhdGVTdGF0ZVRvQ2VydGlmaWVkKE1vY2tpdG8uYW55KFVzZXIuY2xhc3MpLCBNb2NraXRvLmFueShSZXNvdXJjZS5jbGFzcyksIE1vY2tpdG8uYW55KExpZmVjeWNsZUNoYW5nZUluZm9XaXRoQWN0aW9uLmNsYXNzKSwgTW9ja2l0by5lcShmYWxzZSksIE1vY2tpdG8uZXEodHJ1ZSksIE1vY2tpdG8uZXEoZmFsc2UpKSkKLSAgICAgICAgICAgICAgICAudGhlbkFuc3dlcihuZXcgQW5zd2VyPEVpdGhlcjxSZXNvdXJjZSwgUmVzcG9uc2VGb3JtYXQ+PigpIHsKLSAgICAgICAgICAgICAgICAgICAgcHVibGljIEVpdGhlcjxSZXNvdXJjZSwgUmVzcG9uc2VGb3JtYXQ+IGFuc3dlcihJbnZvY2F0aW9uT25Nb2NrIGludm9jYXRpb24pIHRocm93cyBUaHJvd2FibGUgewotICAgICAgICAgICAgICAgICAgICAgICAgT2JqZWN0W10gYXJncyA9IGludm9jYXRpb24uZ2V0QXJndW1lbnRzKCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gRWl0aGVyLmxlZnQoKFJlc291cmNlKSBhcmdzWzFdKTsKKyAgICAgICAgICAgICAgICAudGhlbkFuc3dlcigoQW5zd2VyPFJlc291cmNlPikgaW52b2NhdGlvbiAtPiB7CisgICAgICAgICAgICAgICAgICAgIE9iamVjdFtdIGFyZ3MgPSBpbnZvY2F0aW9uLmdldEFyZ3VtZW50cygpOworICAgICAgICAgICAgICAgICAgICByZXR1cm4gKFJlc291cmNlKSBhcmdzWzFdOwogCi0gICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9KTsKLSAgICAgICAgd2hlbihyZXNvdXJjZUJ1c2luZXNzTG9naWMuY3JlYXRlUmVzb3VyY2VCeURhbyhNb2NraXRvLmFueShSZXNvdXJjZS5jbGFzcyksIE1vY2tpdG8uYW55KFVzZXIuY2xhc3MpLCBNb2NraXRvLmFueShBdWRpdGluZ0FjdG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W5naW5lLmFkZFRvTWFwKG9wRW52RW50cnkpOworICAgICAgICBlbnZFbmdpbmUuYWRkVG9NYXAob3BFbnZFbnRyeTIpOworICAgICAgICBhc3NlcnRUaGF0VGhyb3duQnkoKCkgLT4geworICAgICAgICAgICAgZW52RW5naW5lLmdldEVudmlyb25tZW50QnlEbWFhcFVlYkFkZHJlc3MobmV3IEFycmF5TGlzdDw+KCkpO30pCisgICAgICAgICAgICAgICAgLmlzSW5zdGFuY2VPZihDb21wb25lbnRFeGNlcHRpb24uY2xhc3MpOworICAgIH0KKworICAgIEBUZXN0CisgICAgcHVibGljIHZvaWQgZ2V0RW52aXJvbm1lbnRCeURtYWFwVWViQWRkcmVzc0xpc3QoKSB7CisgICAgICAgIE9wZXJhdGlvbmFsRW52aXJvbm1lbnRFbnRyeSBvcEVudkVudHJ5ID0gY3JlYXRlT3BFbnZFbnRyeSgiMSIpOworICAgICAgICBvcEVudkVudHJ5LnNldERtYWFwVWViQWRkcmVzcyhuZXcgSGFzaFNldDw+KEFycmF5cy5hc0xpc3QoIjExIiwiMjIiKSkpOworICAgICAgICBPcGVyYXRpb25hbEVudmlyb25tZW50RW50cnkgb3BFbnZFbnRyeTIgPSBjcmVhdGVPcEVudkVudHJ5KCIyIik7CisgICAgICAgIG9wRW52RW50cnkyLnNldERtYWFwVWViQWRkcmVzcyhuZXcgSGFzaFNldDw+KEFycmF5cy5hc0xpc3QoIjMzIiwiNDQiLCI1NSIpKSk7CisgICAgICAgIGVudkVuZ2luZS5hZGRUb01hcChvcEVudkVudHJ5KTsKKyAgICAgICAgZW52RW5naW5lLmFkZFRvTWFwKG9wRW52RW50cnkyKTsKKyAgICAgICAgYXNzZXJ0VGhhdChlbnZFbmdpbmUuZ2V0RW52aXJvbm1lbnRCeURtYWFwVWViQWRkcmVzcyhBcnJheXMuYXNMaXN0KCI3NyIsIjIyIikpCisgICAgICAgICAgICAgICAgLmdldEVudmlyb25tZW50SWQoKSkuaXNFcXVhbFRvKCIxIik7CisKKyAgICAgICAgYXNzZXJ0VGhhdChlbnZFbmdpbmUuZ2V0RW52aXJvbm1lbnRCeURtYWFwVWViQWRkcmVzcyhBcnJheXMuYXNMaXN0KCI3NyIsIjU1IikpCisgICAgICAgICAgICAgICAgLmdldEVudmlyb25tZW50SWQoKSkuaXNFcXVhbFRvKCIyIik7CisKKyAgICAgICAgYXNzZXJ0VGhhdChlbnZFbmdpbmUuZ2V0RW52aXJvbm1lbnRCeURtYWFwVWViQWRkcmVzcyhBcnJheXMuYXNMaXN0KCIxMSIsIjQ0IikpCisgICAgICAgICAgICAgICAgLmdldEVudmlyb25tZW50SWQoKSkuaXNFcXVhbFRvKCIxIik7CisgICAgfQorCisKKworCiAgICAgcHJpdmF0ZSBTdHJpbmcgZ2V0Q29ycnVwdGVkT3BlcmF0aW9uYWxFbnZKc29uKCkgewogICAgICAgICByZXR1cm4gIntcIk9QRVJBVElPTkFMLWVudmlyb25tZW50LW5hbWVcIjpcIk9wIEVudiBOYW1lXCIsIgogICAgICAgICAgICAgICAgICsgIlwiT1BFUkFUSU9OQUwtZW52aXJvbm1lbnQtdHlwZVwiOlwiVk5GXCIsIgpAQCAtMTgzLDcgKzIzMyw3IEBACiAgICAgICAgICAgICAgICAgIlwicmVsYXRpb25zaGlwLWxpc3RcIjp7IiArCiAgICAgICAgICAgICAgICAgIlwicmVsYXRpb25zaGlwXCI6W10iICsKICAgICAgICAgICAgICAgICAifSIgKwotICAgICAgICAgICAgICJ9IjsKKyAgICAgICAgICAgICAgICAifSI7CiAgICAgfQogCiAgICAgcHJpdmF0ZSBTdHJpbmcgZ2V0RnVsbE9wZXJhdGlvbmFsRW52SnNvbigpIHsKQEAgLTIxMyw3ICsyNjMsNyBAQAogICAgICAgICAgICAgICAgICJcInByb3BlcnR5LXZhbHVlXCI6XCJPRW5hbWUzXCIiICsKICAgICAgICAgICAgICAgICAifV19XX19IjsKICAgICB9Ci0gICAgCisKICAgICBwcml2YXRlIE9wZXJhdGlvbmFsRW52aXJvb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y9kaXN0cmlidXRpb24vZW5naW5lL3Jlc3QvTXNvUmVzdENsaWVudFRlc3QuamF2YQorKysgL2Rldi9udWxsCkBAIC0xLDE2MSArMCwwIEBACi0vKi0KLSAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBTREMKLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBDb3B5cmlnaHQgKEMpIDIwMTkgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7Ci0gKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCi0gKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKLSAqIAotICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKLSAqIAotICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZQotICogZGlzdHJpYnV0ZWQgdW5kZXIgdGhlIExpY2Vuc2UgaXMgZGlzdHJpYnV0ZWQgb24gYW4gIkFTIElTIiBCQVNJUywKLSAqIFdJVEhPVVQgV0FSUkFOVElFUyBPUiBDT05ESVRJT05TIE9GIEFOWSBLSU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RoQ2hlY2tCdXNpbmVzc0xvZ2ljSGVhbHRoVGVzdC5qYXZhCkBAIC0wLDAgKzEsMzI4IEBACisvKi0KKyAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBTREMKKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBDb3B5cmlnaHQgKEMpIDIwMjAgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7CisgKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCisgKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKKyAqCisgKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAorICoKKyAqIFVubGVzcyByZXF1aXJlZCBieSBhcHBsaWNhYmxlIGxhdyBvciBhZ3JlZWQgdG8gaW4gd3JpdGluZywgc29mdHdhcmUKKyAqIGRpc3RyaWJ1dGVkIHVuZGVyIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1dGVkIG9uIGFuICJBUyBJUyIgQkFTSVMsCisgKiBXSVRIT1VUIFdBUlJBTlRJRVMgT1IgQ09ORElUSU9OUyBPRiBBTlkgS0lORCwgZWl0aGVyIGV4cHJlc3Mgb3Iga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BvbmVudHMvaGVhbHRoL0hlYWx0aENoZWNrQnVzaW5lc3NMb2dpY1Rlc3QuamF2YQpkZWxldGVkIGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggYTA1MTg0Zi4uMDAwMDAwMAotLS0gYS9jYXRhbG9nLWJlL3NyYy90ZXN0L2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvY29tcG9uZW50cy9oZWFsdGgvSGVhbHRoQ2hlY2tCdXNpbmVzc0xvZ2ljVGVzdC5qYXZhCisrKyAvZGV2L251bGwKQEAgLTEsMjg2ICswLDAgQEAKLS8qLQotICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIFNEQwotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIENvcHlyaWdodCAoQykgMjAxOSBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKLSAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KLSAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAotICogCi0gKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAotICogCi0gKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcg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QXJ0aWZhY3QuZ2V0QXNKc29uT2JqZWN0KCkuYWRkUHJvcGVydHkoInRpbWVvdXQiLCAiIDgwIik7CisgICAgICAgIGpzb25BcnRpZmFjdC5nZXRBc0pzb25PYmplY3QoKS5hZGQoImFydGlmYWN0VHlwZSIsIG51bGwpOworICAgICAgICB0cnkgeworICAgICAgICAgICAgUmVwcmVzZW50YXRpb25VdGlscy5jb252ZXJ0SnNvblRvQXJ0aWZhY3REZWZpbml0aW9uKGpzb25BcnRpZmFjdC50b1N0cmluZygpLAorICAgICAgICAgICAgICAgICAgICBBcnRpZmFjdERlZmluaXRpb24uY2xhc3MsIHRydWUpOworICAgICAgICAgICAgZmFpbCgpOworICAgICAgICB9IGNhdGNoIChDb21wb25lbnRFeGNlcHRpb24gZXhwKSB7CisgICAgICAgICAgICBhc3NlcnRUaGF0KGV4cC5nZXRBY3Rpb25TdGF0dXMoKSkuaXNFcXVhbFRvKEFjdGlvblN0YXR1cy5NQU5EQVRPUllfUFJPUEVSVFlfTUlTU0lOR19WQUxVRSk7CisgICAgICAgICAgICBhc3NlcnRUaGF0KGV4cC5nZXRQYXJhbXMoKVswXSkuaXNFcXVhbFRvKCJhcnRpZmFjdFR5cGUiKTsKKyAgICAgICAgfQorICAgIH0KKworICAgIEBUZXN0CisgICAgcHVibGljIHZvaWQgdGVzdE1pc3NpbmdBcnRpZmFjdExhYmVsKCkgeworICAgICAgICBBcnRpZmFjdERlZmluaXRpb24gYWQgPSBuZXcgQXJ0aWZhY3REZWZpbml0aW9uKCk7CisKKyAgICAgICAgSnNvbkVsZW1lbnQganNvbkFydGlmYWN0ID0gZ3Nvbi50b0pzb25UcmVlKGFkKTsKKyAgICAgICAganNvbkFydGlmYWN0LmdldEFzSnNvbk9iamVjdCgpLmFkZFByb3BlcnR5KCJhcnRpZmFjdEdyb3VwVHlwZSIsIEFydGlmYWN0R3JvdXBUeXBlRW51bS5ERVBMT1lNRU5ULnRvU3RyaW5nKCkpOworICAgICAgICBqc29uQXJ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G9TdHJpbmcoKSk7CisgICAgICAgIGpzb25BcnRpZmFjdC5nZXRBc0pzb25PYmplY3QoKS5hZGRQcm9wZXJ0eSgiYXJ0aWZhY3RMYWJlbCIsICIgbGFiZWwiKTsKKyAgICAgICAganNvbkFydGlmYWN0LmdldEFzSnNvbk9iamVjdCgpLmFkZFByb3BlcnR5KCJhcnRpZmFjdFR5cGUiLCAiIEhFQVQiKTsKKworICAgICAgICB0cnkgeworICAgICAgICAgICAgUmVwcmVzZW50YXRpb25VdGlscy5jb252ZXJ0SnNvblRvQXJ0aWZhY3REZWZpbml0aW9uKGpzb25BcnRpZmFjdC50b1N0cmluZygpLAorICAgICAgICAgICAgICAgICAgICBBcnRpZmFjdERlZmluaXRpb24uY2xhc3MsIHRydWUpOworICAgICAgICAgICAgZmFpbCgpOworICAgICAgICB9IGNhdGNoIChDb21wb25lbnRFeGNlcHRpb24gZXhwKSB7CisgICAgICAgICAgICBhc3NlcnRUaGF0KGV4cC5nZXRBY3Rpb25TdGF0dXMoKSkuaXNFcXVhbFRvKEFjdGlvblN0YXR1cy5NSVNTSU5HX01BTkRBVE9SWV9QUk9QRVJUWSk7CisgICAgICAgICAgICBhc3NlcnRUaGF0KGV4cC5nZXRQYXJhbXMoKVswXSkuaXNFcXVhbFRvKCJ0aW1lb3V0Iik7CisgICAgICAgIH0KKyAgICB9CisKKworICAgIEBUZXN0CiAgICAgcHVibGljIHZvaWQgdGVzdEludmFsaWRHcm91cFR5cGVXaXRoU3BhY2UoKSB7CiAgICAgICAgIEFydGlmYWN0RGVmaW5pdGlvbiBhZCA9IG5ldyBBcnRpZmFjdERlZmluaXRpb24oKTsKICAgICAgICAgYWQuc2V0QXJ0aWZhY3ROYW1lKCJhcnRpZmFjdDEiKTsKQEAgLTM2MSw5ICs2MzYsMTIgQEAKIAogICAgICAgICBKc29uRWxlbWVudCBqc29uQXJ0aWZhY3QgPSBnc29uLnRvSnNvblRyZWUoYWQpOwogICAgICAgICBqc29uQXJ0aWZhY3Q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WUxPQUQpLApAQCAtNTE1LDcgKzc5Myw3IEBACiAKICAgICAgICAgd2hlbihncmFwaExvY2tPcGVyYXRpb24ubG9ja0NvbXBvbmVudChhbnkoKSwgYW55KCkpKS50aGVuUmV0dXJuKFN0b3JhZ2VPcGVyYXRpb25TdGF0dXMuT0spOwogICAgICAgICB3aGVuKGFydGlmYWN0VG9zY2FPcGVyYXRpb24udXBkYXRlQXJ0aWZhY3RPblJlc291cmNlKGFueShBcnRpZmFjdERlZmluaXRpb24uY2xhc3MpLCBhbnkoKSwgYW55KCksCi0gICAgICAgICAgICAgICAgYW55KE5vZGVUeXBlRW51bS5jbGFzcyksIGFueShTdHJpbmcuY2xhc3MpKSkudGhlblJldHVybihFaXRoZXIubGVmdChhcnRpZmFjdERlZmluaXRpb24pKTsKKyAgICAgICAgICAgICAgICBhbnkoTm9kZVR5cGVFbnVtLmNsYXNzKSwgYW55KFN0cmluZy5jbGFzcyksIGVxKHRydWUpKSkudGhlblJldHVybihFaXRoZXIubGVmdChhcnRpZmFjdERlZmluaXRpb24pKTsKICAgICAgICAgd2hlbihhcnRpZmFjdENhc3NhbmRyYURhby5zYXZlQXJ0aWZhY3QoYW55KCkpKS50aGVuUmV0dXJuKENhc3NhbmRyYU9wZXJhdGlvblN0YXR1cy5PSyk7CiAgICAgICAgIHdoZW4oY29tcG9uZW50c1V0aWxzLmdldFJlc3BvbnNlRm9ybWF0KGFueShBY3Rpb25TdGF0dXMuY2xhc3MpKSkudGhlblJldHVybihuZXcgUmVzcG9uc2VGb3JtYXQoKSk7CiAgICAgICAgIGFydGlmYWN0QkwuZ2VuZXJhdGVBbmRTYXZlSGVhdEVudkFydGlmYWN0KGFydGlmYWN0RGVmaW5pdGlvbiwgU3RyaW5nLnZhbHVlT2YoUEFZTE9BRCksCkBAIC01MzQsNyArODEyLDcgQEAKIAogICAgICAgICB3aGVuKGdyYXBoTG9ja09wZXJhdGlvbi5sb2NrQ29tcG9uZW50KGFueSgpLCBhbnkoKSkpLnR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0aWZhY3RPblJlc291cmNlKGFueShBcnRpZmFjdERlZmluaXRpb24uY2xhc3MpLCBhbnkoKSwgYW55U3RyaW5nKCksIGFueShOb2RlVHlwZUVudW0uY2xhc3MpLCBhbnkoKSwgYW55Qm9vbGVhbigpKSkKICAgICAgICAgICAgICAgICAudGhlblJldHVybihFaXRoZXIubGVmdChhcnRpZmFjdERlZmluaXRpb24pKTsKLSAgICAgICAgd2hlbihhcnRpZmFjdENhc3NhbmRyYURhby5zYXZlQXJ0aWZhY3QoYW55KEVTQXJ0aWZhY3REYXRhLmNsYXNzKSkpCisgICAgICAgIHdoZW4oYXJ0aWZhY3RDYXNzYW5kcmFEYW8uc2F2ZUFydGlmYWN0KGFueShEQU9BcnRpZmFjdERhdGEuY2xhc3MpKSkKICAgICAgICAgICAgICAgICAudGhlblJldHVybihDYXNzYW5kcmFPcGVyYXRpb25TdGF0dXMuT0spOwogICAgICAgICB3aGVuKHRvc2NhT3BlcmF0aW9uRmFjYWRlLmdldFRvc2NhRWxlbWVudChhbnlTdHJpbmcoKSkpCiAgICAgICAgICAgICAgICAgLnRoZW5SZXR1cm4oRWl0aGVyLmxlZnQocmVzb3VyY2UpKTsKICAgICAgICAgd2hlbihpbnRlcmZhY2VPcGVyYXRpb24udXBkYXRlSW50ZXJmYWNlcyhhbnlTdHJpbmcoKSwgYW55TGlzdCgpKSkKICAgICAgICAgICAgICAgICAudGhlblJldHVybihFaXRoZXIubGVmdChpbnRlcmZhY2VEZWZpbml0aW9uc0xpc3QpKTsKKyAgICAgICAgd2hlbihhcnRpZmFjdFRvc2NhT3BlcmF0aW9uLmdldEFsbEluc3RhbmNlQXJ0aWZhY3RzKHJlc291cmNlLmdldFVuaXF1ZUlkKCksIGNvbXBvbmVudElkKSkudGhlblJldHVybihFaXRoZXIubGVmdChhcnRpZmFjdERlZmluaXRpb25NYXApKTsKKyAgICAgICAgd2hlbih0b3NjYU9wZXJhdGlvbkZhY2FkZS5nZW5lcmF0ZUN1c3RvbWl6Y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KKyAgICAgICAgQ29tcG9uZW50SW5zdGFuY2VQcm9wZXJ0eSBwcm9wZXJ0eSA9IG5ldyBDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5KCk7CisgICAgICAgIHByb3BlcnR5LnNldE5hbWUoInByb3BlcnR5Iik7CisgICAgICAgIHByb3BlcnR5LnNldFZhbHVlKCJuZXdWYWwiKTsKKyAgICAgICAgcHJvcGVydHkuc2V0VHlwZSgic3RyaW5nIik7CisgICAgICAgIHByb3BlcnRpZXMuYWRkKHByb3BlcnR5KTsKKworICAgICAgICBMaXN0PENvbXBvbmVudEluc3RhbmNlUHJvcGVydHk+IG9yaWdQcm9wZXJ0aWVzID0gbmV3IEFycmF5TGlzdDw+KCk7CisgICAgICAgIENvbXBvbmVudEluc3RhbmNlUHJvcGVydHkgb3JpZ1Byb3BlcnR5ID0gbmV3IENvbXBvbmVudEluc3RhbmNlUHJvcGVydHkoKTsKKyAgICAgICAgb3JpZ1Byb3BlcnR5LnNldE5hbWUoInByb3BlcnR5Iik7CisgICAgICAgIG9yaWdQcm9wZXJ0eS5zZXRWYWx1ZSgidmFsdWUiKTsKKyAgICAgICAgb3JpZ1Byb3BlcnR5LnNldFR5cGUoInN0cmluZyIpOworICAgICAgICBvcmlnUHJvcGVydGllcy5hZGQob3JpZ1Byb3BlcnR5KTsKKworICAgICAgICBNYXA8U3RyaW5nLCBEYXRhVHlwZURlZmluaXRpb24+IHR5cGVzID0gbmV3IEhhc2hNYXA8PigpOworICAgICAgICBEYXRhVHlwZURlZmluaXRpb24gZGF0YVR5cGVEZWYgPSBuZXcgRGF0YVR5cGVEZWZpbml0aW9uKCk7CisgICAgICAgIHR5cGVzLnB1dCgic3RyaW5nIiwgZGF0YVR5cGVEZWYpOworCisgICAgICAgIENvbXBvbmVudCBjb21wb25lbnQgPSBuZXcgU2VydmljZSgpOworICAgICAgICBjb21wb25lbnQuc2V0TGFzdFVwZGF0ZXJVc2VySWQoInVzZXJJZCIpOworICAgICAgICBjb21wb25lbnQuc2V0TGlmZWN5Y2xlU3RhdGUoTGlmZWN5Y2xlU3RhdGVFbnVtLk5PVF9DRVJUSUZJRURfQ0hFQ0tPVVQpOworICAgICAgICBNYXA8U3RyaW5nLCBMaXN0PENvbXBvbmVudEluc3RhbmNlUHJvcGVydHk+PiBjb21wb25lbnRJbnN0YW5jZVByb3BzID0gbmV3IEhhc2hNYXA8PigpOworICAgICAgICBjb21wb25lbnRJbnN0YW5jZVByb3BzLnB1dCgicmVzb3VyY2VJZCIsIG9yaWdQcm9wZXJ0aWVzKTsKKyAgICAgICAgY29tcG9uZW50LnNldENvbXBvbmVudEluc3RhbmNlc1Byb3BlcnRpZXMoY29tcG9uZW50SW5zdGFuY2VQcm9wcyk7CisgICAgICAgIENvbXBvbmVudEluc3RhbmNlIGNpID0gY3JlYXRlQ29tcG9uZW50SW5zdGFuY2UoImNpMSIpOworICAgICAgICBjaS5zZXRVbmlxdWVJZCgicmVzb3VyY2VJZCIpOworICAgICAgICBjb21wb25lbnQuc2V0Q29tcG9uZW50SW5zdGFuY2VzKEFycmF5cy5hc0xpc3QoY2ksIGNyZWF0ZUNvbXBvbmVudEluc3RhbmNlKCJjaTIiKSwKKyAgICAgICAgICAgICAgICBjcmVhdGVDb21wb25lbnRJbnN0YW5jZShjb21wb25lbnRJbnN0YW5jZUlEKSkpOworICAgICAgICBIYXNoTWFwPFN0cmluZywgRGF0YVR5cGVEZWZpbml0aW9uPiBkYXRhVHlwZURlZmluaXRpb25IYXNoTWFwID0gbmV3IEhhc2hNYXA8PigpOworICAgICAgICBEYXRhVHlwZURlZmluaXRpb24gZGF0YVR5cGVEZWZpbml0aW9uID0gbmV3IERhdGFUeXBlRGVmaW5pdGlvbigpOworICAgICAgICBkYXRhVHlwZURlZmluaXRpb24uc2V0TmFtZSgic3RyaW5nIik7CisgICAgICAgIGRhdGFUeXBlRGVmaW5pdGlvbkhhc2hNYXAucHV0KCJzdHJpbmciLCBkYXRhVHlwZURlZmluaXRpb24pOworCisgIC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TsKKyAgICAgICAgcHJvcGVydHkuc2V0VHlwZSgic3RyaW5nIik7CisgICAgICAgIHByb3BlcnRpZXMuYWRkKHByb3BlcnR5KTsKKworICAgICAgICBMaXN0PENvbXBvbmVudEluc3RhbmNlUHJvcGVydHk+IG9yaWdQcm9wZXJ0aWVzID0gbmV3IEFycmF5TGlzdDw+KCk7CisgICAgICAgIENvbXBvbmVudEluc3RhbmNlUHJvcGVydHkgb3JpZ1Byb3BlcnR5ID0gbmV3IENvbXBvbmVudEluc3RhbmNlUHJvcGVydHkoKTsKKyAgICAgICAgb3JpZ1Byb3BlcnR5LnNldE5hbWUoInByb3BlcnR5Iik7CisgICAgICAgIG9yaWdQcm9wZXJ0eS5zZXRWYWx1ZSgidmFsdWUiKTsKKyAgICAgICAgb3JpZ1Byb3BlcnR5LnNldFR5cGUoInN0cmluZyIpOworICAgICAgICBvcmlnUHJvcGVydGllcy5hZGQob3JpZ1Byb3BlcnR5KTsKKworICAgICAgICBNYXA8U3RyaW5nLCBEYXRhVHlwZURlZmluaXRpb24+IHR5cGVzID0gbmV3IEhhc2hNYXA8PigpOworICAgICAgICBEYXRhVHlwZURlZmluaXRpb24gZGF0YVR5cGVEZWYgPSBuZXcgRGF0YVR5cGVEZWZpbml0aW9uKCk7CisgICAgICAgIHR5cGVzLnB1dCgic3RyaW5nIiwgZGF0YVR5cGVEZWYpOworCisgICAgICAgIENvbXBvbmVudCBjb21wb25lbnQgPSBuZXcgU2VydmljZSgpOworICAgICAgICBjb21wb25lbnQuc2V0TGFzdFVwZGF0ZXJVc2VySWQoInVzZXJJZCIpOworICAgICAgICBjb21wb25lbnQuc2V0TGlmZWN5Y2xlU3RhdGUoTGlmZWN5Y2xlU3RhdGVFbnVtLk5PVF9DRVJUSUZJRURfQ0hFQ0tPVVQpOworICAgICAgICBNYXA8U3RyaW5nLCBMaXN0PENvbXBvbmVudEluc3RhbmNlUHJvcGVydHk+PiBjb21wb25lbnRJbnN0YW5jZVByb3BzID0gbmV3IEhhc2hNYXA8PigpOworICAgICAgICBjb21wb25lbnRJbnN0YW5jZVByb3BzLnB1dCgicmVzb3VyY2VJZCIsIG9yaWdQcm9wZXJ0aWVzKTsKKyAgICAgICAgY29tcG9uZW50LnNldENvbXBvbmVudEluc3RhbmNlc1Byb3BlcnRpZXMoY29tcG9uZW50SW5zdGFuY2VQcm9wcyk7CisgICAgICAgIENvbXBvbmVudEluc3RhbmNlIGNpID0gY3JlYXRlQ29tcG9uZW50SW5zdGFuY2UoImNpMSIpOworICAgICAgICBjaS5zZXRVbmlxdWVJZCgicmVzb3VyY2VJZCIpOworICAgICAgICBjb21wb25lbnQuc2V0Q29tcG9uZW50SW5zdGFuY2VzKEFycmF5cy5hc0xpc3QoY2ksIGNyZWF0ZUNvbXBvbmVudEluc3RhbmNlKCJjaTIiKSwKKyAgICAgICAgICAgICAgICBjcmVhdGVDb21wb25lbnRJbnN0YW5jZShjb21wb25lbnRJbnN0YW5jZUlEKSkpOworICAgICAgICBIYXNoTWFwPFN0cmluZywgRGF0YVR5cGVEZWZpbml0aW9uPiBkYXRhVHlwZURlZmluaXRpb25IYXNoTWFwID0gbmV3IEhhc2hNYXA8PigpOworICAgICAgICBEYXRhVHlwZURlZmluaXRpb24gZGF0YVR5cGVEZWZpbml0aW9uID0gbmV3IERhdGFUeXBlRGVmaW5pdGlvbigpOworICAgICAgICBkYXRhVHlwZURlZmluaXRpb24uc2V0TmFtZSgic3RyaW5nIik7CisgICAgICAgIGRhdGFUeXBlRGVmaW5pdGlvbkhhc2hNYXAucHV0KCJzdHJpbmciLCBkYXRhVHlwZURlZmluaXRpb24pOworCisgICAgICAgIC8vd2hlbih1c2VyVmFsaWRhdGlvbnMudmFsaWRhdGVVc2VyRXhpc3RzKHVzZXIuZ2V0VXNlcklkKCksIGZhbHNlKSkudGhlblJldHVybih1c2VyKTsKKyAgICAgICAgd2hlbih0b3NjYU9wZXJhdGlvbkZhY2FkZS5nZXRUb3NjYUVsZW1lbnQoY29udGFpbmVyQ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ZSgicHJvcGVydHkiKTsKKyAgICAgICAgb3JpZ1Byb3BlcnR5LnNldFZhbHVlKCJ2YWx1ZSIpOworICAgICAgICBvcmlnUHJvcGVydHkuc2V0VHlwZSgic3RyaW5nIik7CisgICAgICAgIG9yaWdQcm9wZXJ0aWVzLmFkZChvcmlnUHJvcGVydHkpOworCisgICAgICAgIENvbXBvbmVudCBjb21wb25lbnQgPSBuZXcgU2VydmljZSgpOworICAgICAgICBjb21wb25lbnQuc2V0TGFzdFVwZGF0ZXJVc2VySWQoInVzZXJJZCIpOworICAgICAgICBjb21wb25lbnQuc2V0TGlmZWN5Y2xlU3RhdGUoTGlmZWN5Y2xlU3RhdGVFbnVtLk5PVF9DRVJUSUZJRURfQ0hFQ0tPVVQpOworICAgICAgICBNYXA8U3RyaW5nLCBMaXN0PENvbXBvbmVudEluc3RhbmNlUHJvcGVydHk+PiBjb21wb25lbnRJbnN0YW5jZVByb3BzID0gbmV3IEhhc2hNYXA8PigpOworICAgICAgICBjb21wb25lbnRJbnN0YW5jZVByb3BzLnB1dCgicmVzb3VyY2VJZCIsIG9yaWdQcm9wZXJ0aWVzKTsKKyAgICAgICAgY29tcG9uZW50LnNldENvbXBvbmVudEluc3RhbmNlc1Byb3BlcnRpZXMoY29tcG9uZW50SW5zdGFuY2VQcm9wcyk7CisgICAgICAgIENvbXBvbmVudEluc3RhbmNlIGNpID0gY3JlYXRlQ29tcG9uZW50SW5zdGFuY2UoImNpMSIpOworICAgICAgICBjaS5zZXRVbmlxdWVJZCgicmVzb3VyY2VJZCIpOworICAgICAgICBjb21wb25lbnQuc2V0Q29tcG9uZW50SW5zdGFuY2VzKEFycmF5cy5hc0xpc3QoY2ksIGNyZWF0ZUNvbXBvbmVudEluc3RhbmNlKCJjaTIiKSwKKyAgICAgICAgICAgICAgICBjcmVhdGVDb21wb25lbnRJbnN0YW5jZShjb21wb25lbnRJbnN0YW5jZUlEKSkpOworCisgICAgICAgIEhhc2hNYXA8U3RyaW5nLCBEYXRhV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250YWluZXJDb21wb25lbnRUeXBlLCBjaSk7CisgICAgICAgIGFzc2VydFRoYXQoIXJlc3BvbnNlRm9ybWF0RWl0aGVyLmlzRW1wdHkoKSkuaXNFcXVhbFRvKHRydWUpOwogCiAgICAgfQogCi0gICAgcHJpdmF0ZSBDb21wb25lbnRJbnN0YW5jZSBjcmVhdGVDb21wb25lbnRJc3RhbmNlKFN0cmluZyBwYXRoMSkgeworICAgIEBUZXN0CisgICAgcHVibGljIHZvaWQgdGVzdEFkZENvbXBvbmVudEluc3RhbmNlRGVwbG95bWVudEFydGlmYWN0cygpIHsKKworICAgICAgICBDb21wb25lbnQgY29udGFpbmVyQ29tcG9uZW50ID0gbmV3IFNlcnZpY2UoKTsKKyAgICAgICAgQ29tcG9uZW50SW5zdGFuY2UgY29tcG9uZW50SW5zdGFuY2UgPSBuZXcgQ29tcG9uZW50SW5zdGFuY2UoKTsKKyAgICAgICAgY29tcG9uZW50SW5zdGFuY2Uuc2V0VW5pcXVlSWQoQ09NUE9ORU5UX0lOU1RBTkNFX0lEKTsKKyAgICAgICAgQ29tcG9uZW50IG9yaWdpbkNvbXBvbmVudCA9IGZpbGxPcmlnaW5Db21wb25lbnQobmV3IFJlc291cmNlKCkpOworCisgICAgICAgIE1hcDxTdHJpbmcsIEFydGlmYWN0RGVmaW5pdGlvbj4gYXJ0aWZhY3RzID0gbmV3IEhhc2hNYXA8PigpOworICAgICAgICBBcnRpZmFjdERlZmluaXRpb24gZGVwbG95bWVudEFydGlmYWN0MSA9IGdldEFydGlmYWN0KCJkZXBsb3ltZW50QXJ0aWZhY3QxIiwgQXJ0aWZhY3RUeXBlRW51bS5IRUFULmdldFR5cGUoKSk7CisgICAgICAgIGFydGlmYWN0cy5wdXQoZGVwbG95bWVudEFydGlmYWN0MS5nZXRBcnRpZmFjdExhYmVsKCksIGRlcGxveW1lbnRBcnRpZmFjdDEpOworICAgICAgICBBcnRpZmFjdERlZmluaXRpb24gZGVwbG95bWVudEFydGlmYWN0MiA9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sZVN0YXRlRW51bS5DRVJUSUZJRUQpOworICAgICAgICByZXR1cm4gb3JpZ2luQ29tcG9uZW50OworICAgIH0KKworICAgIHByaXZhdGUgQXJ0aWZhY3REZWZpbml0aW9uIGdldEFydGlmYWN0KFN0cmluZyBhcnRpZmFjdExhYmVsLCBTdHJpbmcgYXJ0aWZhY3RUeXBlKSB7CisgICAgICAgIEFydGlmYWN0RGVmaW5pdGlvbiBhcnRpZmFjdERlZmluaXRpb24gPSBuZXcgQXJ0aWZhY3REZWZpbml0aW9uKCk7CisgICAgICAgIGFydGlmYWN0RGVmaW5pdGlvbi5zZXRBcnRpZmFjdExhYmVsKGFydGlmYWN0TGFiZWwpOworICAgICAgICBhcnRpZmFjdERlZmluaXRpb24uc2V0QXJ0aWZhY3RHcm91cFR5cGUoQXJ0aWZhY3RHcm91cFR5cGVFbnVtLkRFUExPWU1FTlQpOworICAgICAgICBhcnRpZmFjdERlZmluaXRpb24uc2V0RXNJZCgiZXNJZCIgKyBhcnRpZmFjdExhYmVsKTsKKyAgICAgICAgYXJ0aWZhY3REZWZpbml0aW9uLnNldEFydGlmYWN0VHlwZShhcnRpZmFjdFR5cGUpOworICAgICAgICByZXR1cm4gYXJ0aWZhY3REZWZpbml0aW9uOworICAgIH0KKworICAgIHByaXZhdGUgQ29tcG9uZW50SW5zdGFuY2UgY3JlYXRlQ29tcG9uZW50SW5zdGFuY2UoU3RyaW5nIHBhdGgxKSB7CiAgICAgICAgIENvbXBvbmVudEluc3RhbmNlIGNvbXBvbmVudEluc3RhbmNlID0gbmV3IENvbXBvbmVudEluc3RhbmNlKCk7CiAgICAgICAgIGNvbXBvbmVudEluc3RhbmNlLnNldE5hbWUocGF0aDEpOwogICAgICAgICByZXR1cm4gY29tcG9uZW50SW5zdGFuY2U7CkBAIC0yOTksNyArNTk1LDcgQEAKICAgICAgICAgZm9yd2FyZGluZ1BhdGguc2V0RGVzdGluYXRpb25Qb3J0TnVtYmVyKCJEZXN0aW5hdGlvblBvcnROdW1iZXIiKTsKICAgICAgICAgZm9yd2FyZGluZ1BhdGguc2V0VW5pcXVlSWQoIkZQLUlELTEiKTsKICAgICAgICAgTGlzdERhdGFEZWZpbml0aW9uPEZvcndhcmRpbmdQYXRoRWxlbWVudERhdGFEZWZpbml0aW9uPiBmb3J3YXJkaW5nUGF0aEVsZW1lbnRMaXN0RGF0YURlZmluaXRpb24gPQotICAgICAgICAgICAgICAgIG5ldyBMaXN0RGF0YURlZmluaXRpb248PigpOworICAgICAgICAgICAgbmV3IExpc3REYXRhRGVmaW5pdGlvbjw+KCk7CiAgICAgICAgIGZvcndhcmRpbmdQYXRoRWxlbWVudExpc3REYXRhRGVmaW5pdGlvbgogICAgICAgICAgICAgICAgIC5hZGQobmV3IEZvcndhcmRpbmdQYXRoRWxlbWVudERhdGFEZWZpbml0aW9uKGNvbXBvbmVudEluc3RhbmNlSUQsICJub2RlQiIsICJub2RlQV9GT1JXQVJERVJfQ0FQQUJJTElUWSIsCiAgICAgICAgICAgICAgICAgICAgICAgICAibm9kZUJjcFR5cGUiLCAibm9kZURjcE5hbWUiLCAibm9kZUJjcE5hbWUiKSk7CkBAIC0zMDksOCArNjA1LDggQEAKICAgICAgICAgcmV0dXJuIGZvcndhcmRpbmdQYXRoczsKICAgICB9CiAKLSAgICBAU3VwcHJlc3NXYXJuaW5ncygidW5jaGVja2VkIikKLSAgICBwcml2YXRlIHZvaWQgZ2V0U2VydmljZVJlbGF0aW9uQnlJZFN1Y2Nlc3MoQ29tcG9uZW50IGNvbXBvbmVudCkgeworICBAU3VwcHJlc3NXYXJuaW5ncygidW5jaGVja2VkIikKKyAgICBwcml2YXRlIHZvaWQgZ2V0U2VydmljZVJlbGF0aW9uQnlJZFN1Y2Nlc3MoQ29tcG9uZW50IGNvbXBvbmVudCl7CiAgICAgICAgIEVpdGhlcjxDb21wb25lbnQsIFN0b3JhZ2VPcGVyYXRpb25TdGF0dXM+IGdldENvbXBvbmVudFJlcyA9IEVpdGhlci5sZWZ0KGNv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hYmlsaXR5UHJvcGVydGllcyhjb21wb25lbnRUeXBlRW51bSwgY29udGFpbmVyQ29tcG9uZW50SWQsCi0gICAgICAgICAgICAgICAgY29tcG9uZW50SW5zdGFuY2VVbmlxdWVJZCwgY2FwYWJpbGl0eVR5cGUsIGNhcGFiaWxpdHlOYW1lLCBvd25lcklkLCBwcm9wZXJ0aWVzLCB1c2VySWQpOwotCi0KLSAgICB9Ci0KLQogICAgIEBUZXN0CiAgICAgcHVibGljIHZvaWQgdGVzdFVwZGF0ZUluc3RhbmNlQ2FwYWJpbGl0eVByb3BlcnRpZXNfMSgpIHRocm93cyBFeGNlcHRpb24gewogICAgICAgICBDb21wb25lbnRJbnN0YW5jZUJ1c2luZXNzTG9naWMgdGVzdFN1YmplY3Q7CkBAIC0xMjQxLDE1ICsxMTE5LDkgQEAKICAgICAgICAgd2hlbihncmFwaExvY2tPcGVyYXRpb24ubG9ja0NvbXBvbmVudChNb2NraXRvLmFueVN0cmluZygpLCBlcShOb2RlVHlwZUVudW0uU2VydmljZSkpKQogICAgICAgICAgICAgICAgIC50aGVuUmV0dXJuKFN0b3JhZ2VPcGVyYXRpb25TdGF0dXMuT0spOwogICAgICAgICBFaXRoZXI8Q29tcG9uZW50LCBTdG9yYWdlT3BlcmF0aW9uU3RhdHVzPiBnZXRDb21wb25lbnRSZXMgPSBFaXRoZXIubGVmdChyZXNvdXJjZSk7Ci0gICAgICAgIHdoZW4odG9zY2FPcGVyYXRpb25GYWNhZGUuZ2V0VG9zY2FGdWxsRWxlbWVudChpbnB1dENvbXBvbmVudEluc3RhbmNlLmdldENvbXBvbmVudFVpZCgpKSkKLSAgICAgICAgICAgICAgICAudGhlblJldHVybihnZXRDb21wb25lbnRSZXMpOwotCiAgICAgICAgIHJlc3VsdCA9IGNvbXBvbmVudEluc3RhbmNlQnVzaW5lc3NMb2dpYwotICAgICAgICAgICAgICAgICAgICAgICAgIC5jb3B5Q29tcG9uZW50SW5zdGFuY2UoaW5wdXRDb21wb25lbnRJbnN0YW5jZSwgY29udGFpbmVyQ29tcG9uZW50SWQsIGNvbXBvbmVudEluc3RhbmNlSWQsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBVU0VSX0lEKTsKLQorICAgICAgICAgICAgICAgIC5jb3B5Q29tcG9uZW50SW5zdGFuY2UoaW5wdXRDb21wb25lbnRJbnN0YW5jZSwgY29udGFpbmVyQ29tcG9uZW50SWQsIGNvbXBvbmVudEluc3RhbmNlSWQsIFVTRVJfSUQpOwogICAgICAgICBzZXJ2aWNlLnNldExhc3RVcGRhdGVyVXNlcklkKG9sZFNlcnZpY2VMYXN0VXBkYXRlZFVzZXJJZCk7Ci0KICAgICAgICAgYXNzZXJ0VGhhdChyZXN1bHQuaXNSaWdodCgpKTsKICAgICB9CiAKQEAgLTEyNzMsMjEgKzExNDUsMTEgQEAKICAgICAgICAgd2hlbihncmFwaExvY2tPcGVyYXRpb24ubG9ja0NvbXBvbmVudChNb2NraXRvLmFueVN0cmluZygpLCBlcShOb2RlVHlwZUVudW0uU2VydmljZSkpKQogICAgICAgICAgICAgICAgIC50aGVuUmV0dXJuKFN0b3JhZ2VPcGVyYXRpb25TdGF0dXMuT0spOwogICAgICAgICBFaXRoZXI8Q29tcG9uZW50LCBTdG9yYWdlT3BlcmF0aW9uU3RhdHVzPiBnZXRDb21wb25lbnRSZXMgPSBFaXRoZXIubGVmdChyZXNvdXJjZSk7Ci0gICAgICAgIHdoZW4odG9zY2FPcGVyYXRpb25GYWNhZGUuZ2V0VG9zY2FGdWxsRWxlbWVudChpbnB1dENvbXBvbmVudEluc3RhbmNlLmdldENvbXBvbmVudFVpZCgpKSkKLSAgICAgICAgICAgICAgICAudGhlblJldHVybihnZXRDb21wb25lbnRSZXMpOwogICAgICAgICBJbW11dGFibGVQYWlyPENvbXBvbmVudCwgU3RyaW5nPiBwYWlyID0gbmV3IEltbXV0YWJsZVBhaXI8PihyZXNvdXJjZSwgVE9fSU5TVEFOQ0VfSUQpOwogICAgICAgIC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KTsKKyAgICAgICAgd2hlbihjb21wb25lbnRzVXRpbHMuY29udmVydEZyb21TdG9yYWdlUmVzcG9uc2UoZXEoU3RvcmFnZU9wZXJhdGlvblN0YXR1cy5OT1RfRk9VTkQpLGVxKG51bGwpKSkKKyAgICAgICAgICAgICAgICAudGhlblJldHVybihBY3Rpb25TdGF0dXMuR0VORVJBTF9FUlJPUik7CisgICAgICAgIHdoZW4odG9zY2FPcGVyYXRpb25GYWNhZGUuZ2V0VG9zY2FFbGVtZW50KGFueShTdHJpbmcuY2xhc3MpLCBhbnkoQ29tcG9uZW50UGFyYW1ldGVyc1ZpZXcuY2xhc3MpKSkKKyAgICAgICAgICAgICAgICAudGhlblJldHVybihjb250KTsKIAorICAgICAgICB0cnl7CiAgICAgICAgIHJlc3VsdCA9IGNvbXBvbmVudEluc3RhbmNlQnVzaW5lc3NMb2dpYwotICAgICAgICAgICAgICAgICAgICAgICAgIC5iYXRjaERlbGV0ZUNvbXBvbmVudEluc3RhbmNlKGNvbnRhaW5lckNvbXBvbmVudFBhcmFtLCBjb250YWluZXJDb21wb25lbnRJZCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBvbmVudEluc3RhbmNlSWRMaXN0LCB1c2VySWQpOworICAgICAgICAgICAgICAgIC5iYXRjaERlbGV0ZUNvbXBvbmVudEluc3RhbmNlKGNvbnRhaW5lckNvbXBvbmVudFBhcmFtLCBjb250YWluZXJDb21wb25lbnRJZCwgY29tcG9uZW50SW5zdGFuY2VJZExpc3QsCisgICAgICAgICAgICAgICAgICAgICAgICB1c2VySWQpOworICAgICAgICAgICAgfWNhdGNoIChDb21wb25lbnRFeGNlcHRpb24gZSl7CisgICAgICAgICAgICAgICAgYXNzZXJ0RXF1YWxzKGUuZ2V0QWN0aW9uU3RhdHVzKCkudG9TdHJpbmcoKSwgU3RvcmFnZU9wZXJhdGlvblN0YXR1cy5HRU5FUkFMX0VSUk9SLnRvU3RyaW5nKCkpOworICAgICAgICAgICAgfQogCi0gICAgICAgIGFzc2VydEVxdWFscyhkZWxldGVFcnJvck1hcCwgcmVzdWx0KTsKKy8vICAgICAgICBhc3NlcnRFcXVhbHMoZGVsZXRlRXJyb3JNYXAsIHJlc3VsdCk7CiAgICAgfQogCiAgICAgQFRlc3QKICAgICBwdWJsaWMgdm9pZCB0ZXN0QmF0Y2hEZWxldGVDb21wb25lbnRJbnN0YW5jZUZhaWx1cmVDb21wSWRzKCkgewotICAgICAgICBNYXA8U3RyaW5nLCBMaXN0PFN0cmluZz4+IHJlc3VsdDsKKyAgICAgICAgTWFwPFN0cmluZywgTGlzdDxTdHJpbmc+PiByZXN1bHQgPSBuZXcgSGFzaE1hcDw+KCk7CiAgICAgICAgIFN0cmluZyBjb250YWluZXJDb21wb25lbnRQYXJhbSA9IENvbXBvbmVudFR5cGVFbnVtLlNFUlZJQ0VfUEFSQU1fTkFNRTsKICAgICAgICAgU3RyaW5nIGNvbnRhaW5lckNvbXBvbmVudElkID0gImNvbnRhaW5lckNvbXBvbmVudElkIjsKICAgICAgICAgU3RyaW5nIGNvbXBvbmVudEluc3RhbmNlSWQgPSAiY29tcG9uZW50SW5zdGFuY2VJZCI7CkBAIC0xNDI5LDExICsxMzAwLDE0IEBACiAgICAgICAgIHdoZW4odG9zY2FPcGVyYXRpb25GYWNhZGUuZ2V0VG9zY2FFbGVtZW50KGVxKGNvbnRhaW5lckNvbXBvbmVudElkKSwgYW55KENvbXBvbmVudFBhcmFtZXRlcnNWaWV3LmNsYXNzKSkpCiAgICAgICAgICAgICAgICAgLnRoZW5SZXR1cm4oZXJyKTsKIAotICAgICAgICByZXN1bHQgPSBjb21wb25lbnRJbnN0YW5jZUJ1c2luZXNzTG9naWMKLSAgICAgICAgICAgICAgICAgICAgICAgICAuYmF0Y2hEZWxldGVDb21wb25lbnRJbnN0YW5jZShjb250YWluZXJDb21wb25lbnRQYXJhbSwgY29udGFpbmVyQ29tcG9uZW50SWQsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21wb25lbnRJbnN0YW5jZUlkTGlzdCwgdXNlcklkKTsKLQotICAgICAgICBhc3NlcnRFcXVhbHMoZGVsZXRlRXJyb3JNYXAsIHJlc3VsdCk7CisgICAgICAgIHRyeSB7CisgICAgICAgICAgICByZXN1bHQgPSBjb21wb25lbnRJbnN0YW5jZUJ1c2luZXNzTG9naWMKKyAgICAgICAgICAgICAgICAgICAgLmJhdGNoRGVsZXRlQ29tcG9uZW50SW5zdGFuY2UoY29udGFpbmVyQ29tcG9uZW50UGFyYW0sIGNvbnRhaW5lckNvbXBvbmVudElkLCBjb21wb25lbnRJbnN0YW5jZUlkTGlzdCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2VySWQpOworICAgICAgICB9Y2F0Y2ggKENvbXBvbmVudEV4Y2VwdGlvbiBlKXsKKyAgICAgICAgICAgIGFzc2VydEVxdWFscyhlLmdldEFjdGlvblN0YXR1cygpLnRvU3RyaW5nKCksIFN0b3JhZ2VPcGVyYXRpb25TdGF0dXMuR0VORVJBTF9FUlJPUi50b1N0cmluZygpKTsKKyAgICAgICAgfQorLy8gICAgICAgIGFzc2VydEVxdWFscyhkZWxldGVFcnJvck1hcCwgcmVzdWx0KTsKICAgICB9CiAKICAgICBAVGVzdApAQCAtMTUwOCwxNSArMTM4MiwyMSBAQAogICAgICAgICAgICAgICAgIC50aGVuUmV0dXJuKFN0b3JhZ2VPcGVyYXRpb25TdGF0dXMuT0spOwogICAgICAgICBFaXRoZXI8UmVxdWlyZW1lbnRDYXBhYmlsaXR5UmVsRGVmLCBTdG9yYWdlT3BlcmF0aW9uU3RhdHVzPiByZXN1bHRFaXRoZXI7CiAgICAgICAgIHJlc3VsdEVpdGhlciA9IEVpdGhlci5yaWdodChTdG9yYWdlT3BlcmF0aW9uU3RhdHVzLk9LKTsKKyAgICAgICAgd2hlbihjb21wb25lbnRzVXRpbHMuY29udmVydEZyb21TdG9yYWdlUmVzcG9uc2VGb3JSZXNvdXJjZUluc3Rh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ICAgICAgICAgICAgICAgIC5kZWNsYXJlUHJvcGVydGllcyhVU0VSX0lELAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTk9OX0VYSVNUX0NPTVBPTkVOVF9JRCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbXBvbmVudFR5cGVFbnVtLlJFU09VUkNFLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2V0SW5wdXRGb3JQcm9wZXJ0eVRvUG9saWN5RGVjbGFyYXRpb24oKSk7Ci0KLSAgICAgICAgYXNzZXJ0VHJ1ZShkZWNsYXJlZFBvbGljaWVzRWl0aGVyLmlzUmlnaHQoKSk7Ci0gICAgICAgIGFzc2VydEVxdWFscyhuZXcgSW50ZWdlcig0MDQpLCBkZWNsYXJlZFBvbGljaWVzRWl0aGVyLnJpZ2h0KCkudmFsdWUoKS5nZXRTdGF0dXMoKSk7CisgICAgICAgIHRyeSB7CisgICAgICAgICAgICBidXNpbmVzc0xvZ2ljCisgICAgICAgICAgICAgICAgICAgIC5kZWNsYXJlUHJvcGVydGllcyhVU0VSX0lELAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIE5PTl9FWElTVF9DT01QT05FTlRfSUQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29tcG9uZW50VHlwZUVudW0uUkVTT1VSQ0UsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2V0SW5wdXRGb3JQcm9wZXJ0eVRvUG9saWN5RGVjbGFyYXRpb24oKSk7CisgICAgICAgIH0gY2F0Y2ggKENvbXBvbmVudEV4Y2VwdGlvbiBlKSB7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c3NMb2dpYyByZXNvdXJjZUJ1c2luZXNzTG9naWM7Ci0KLSAgICBAQmVmb3JlCi0gICAgcHVibGljIHZvaWQgc2V0VXAoKSB0aHJvd3MgRXhjZXB0aW9uIHsKLSAgICAgICAgcmVzb3VyY2VCdXNpbmVzc0xvZ2ljID0gbmV3IFJlc291cmNlQnVzaW5lc3NMb2dpYyhlbGVtZW50RGFvLAotICAgICAgICAgICAgZ3JvdXBPcGVyYXRpb24sCi0gICAgICAgICAgICBncm91cEluc3RhbmNlT3BlcmF0aW9uLAotICAgICAgICAgICAgZ3JvdXBUeXBlT3BlcmF0aW9uLAotICAgICAgICAgICAgZ3JvdXBCdXNpbmVzc0xvZ2ljLAotICAgICAgICAgICAgaW50ZXJmYWNlT3BlcmF0aW9uLAotICAgICAgICAgICAgaW50ZXJmYWNlTGlmZWN5Y2xlVHlwZU9wZXJhdGlvbiwKLSAgICAgICAgICAgIGFydGlmYWN0c0J1c2luZXNzTG9naWMsCi0gICAgICAgICAgICBjb21wb25lbnRJbnN0YW5jZUJ1c2luZXNzTG9naWMsCi0gICAgICAgICAgICByZXNvdXJjZUltcG9ydE1hbmFnZXIsCi0gICAgICAgICAgICBpbnB1dHNCdXNpbmVzc0xvZ2ljLAotICAgICAgICAgICAgY29tcG9zaXRpb25CdXNpbmVzc0xvZ2ljLAotICAgICAgICAgICAgcmVzb3VyY2VEYXRhTWVyZ2VCdXNpbmVzc0xvZ2ljLAotICAgICAgICAgICAgY3NhckFydGlmYWN0c0FuZEdyb3Vwc0J1c2luZXNzTG9naWMsCi0gICAgICAgICAgICBtZXJnZUluc3RhbmNlVXRpbHMsCi0gICAgICAgICAgICB1aUNvbXBvbmVudERhdGFDb252ZXJ0ZXIsCi0gICAgICAgICAgICBjc2FyQnVzaW5lc3NMb2dpYywKLSAgICAgICAgICAgIGFydGlmYWN0VG9zY2FPcGVyYXRpb24sCi0gICAgICAgICAgICBwcm9wZXJ0eUJ1c2luZXNzTG9naWMsCi0gICAgICAgICAg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y8vCisvLyAgICBAQmVmb3JlCisvLyAgICBwdWJsaWMgdm9pZCBzZXRVcCgpIHRocm93cyBFeGNlcHRpb24geworLy8gICAgICAgIHJlc291cmNlQnVzaW5lc3NMb2dpYyA9IG5ldyBSZXNvdXJjZUJ1c2luZXNzTG9naWMoZWxlbWVudERhbywKKy8vICAgICAgICAgICAgZ3JvdXBPcGVyYXRpb24sCisvLyAgICAgICAgICAgIGdyb3VwSW5zdGFuY2VPcGVyYXRpb24sCisvLyAgICAgICAgICAgIGdyb3VwVHlwZU9wZXJhdGlvbiwKKy8vICAgICAgICAgICAgZ3JvdXBCdXNpbmVzc0xvZ2ljLAorLy8gICAgICAgICAgICBpbnRlcmZhY2VPcGVyYXRpb24sCisvLyAgICAgICAgICAgIGludGVyZmFjZUxpZmVjeWNsZVR5cGVPcGVyYXRpb24sCisvLyAgICAgICAgICAgIGFydGlmYWN0c0J1c2luZXNzTG9naWMsCisvLyAgICAgICAgICAgIGNvbXBvbmVudEluc3RhbmNlQnVzaW5lc3NMb2dpYywKKy8vICAgICAgICAgICAgcmVzb3VyY2VJbXBvcnRNYW5hZ2VyLAorLy8gICAgICAgICAgICBpbnB1dHNCdXNpbmVzc0xvZ2ljLAorLy8gICAgICAgICAgICBjb21wb3NpdGlvbkJ1c2luZXNzTG9naWMsCisvLyAgICAgICAgICAgIHJlc291cmNlRGF0YU1lcmdlQnVzaW5lc3NMb2dpYywKKy8vICAgICAgICAgICAgY3NhckFydGlmYWN0c0FuZEdyb3Vwc0J1c2luZXNzTG9naWMsCisvLyAgICAgICAgICAgIG1lcmdlSW5zdGFuY2VVdGlscywKKy8vICAgICAgICAgICAgdWlDb21wb25lbnREYXRhQ29udmVydGVyLAorLy8gICAgICAgICAgICBjc2FyQnVzaW5lc3NMb2dpYywKKy8vICAgICAgICAgICAgYXJ0aWZhY3RUb3NjYU9wZXJhdGlvbik7CisvLworLy8gICAgICAgIHJlc291cmNlQnVzaW5lc3NMb2dpYy5zZXRMaWZlY3ljb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ZXIgZGVmaW5lZCBpbnB1dCBleGlzdHMKLSAgICAgICAgYXNzZXJ0RXF1YWxzKDEsIHJlc291cmNlLmdldElucHV0cygpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5zdHJlYW0oKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZmlsdGVyKHAgLT4gbnVsbCA9PSBwLmdldE93bmVySWQoKSkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmNvbGxlY3QoQ29sbGVjdG9ycy50b0xpc3QoKSkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnNpemUoKSk7Ci0gICAgICAgIGFzc2VydEVxdWFscygiaW50ZWdlciIsIHJlc291cmNlLmdldElucHV0cygpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnN0cmVhbSgpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmZpbHRlcihwIC0+IG51bGwgPT0gcC5nZXRPd25lcklkKCkpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmZpbmRBbnkoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXQoKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5nZXRUeXBlKCkpOwotICAgIH0KKwlwcml2YXRlIFJlc291cmNlIGNyZWF0ZVBORigpIHsKIAotICAgIEBUZXN0Ci0gICAgcHVibGljIHZvaWQgdGVzdFBORkdlbmVyYXRlZElucHV0c05vR2VuZXJhdGVkSW5mb3JtYXRpb25hbEFydGlmYWN0cygpIHsKLSAgICAgICAgdmFsaWRhdGVVc2VyUm9sZXMoUm9sZS5BRE1JTiwgUm9sZS5ERVNJR05FUik7Ci0gICAgICAgIFJlc291cmNlIHJlc291cmNlID0gY3JlYXRlUE5GKCk7Ci0gICAgICAgIExpc3Q8SW5wdXREZWZpbml0aW9uPiBpbnB1dHMgPSBy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ogICAgICAgICAgICAgYmwuY3JlYXRlU2VydmljZShyZXNvdXJjZUV4aXN0LCB1c2VyKTsKLSAgICAgICAgfSBjYXRjaChCeUFjdGlvblN0YXR1c0NvbXBvbmVudEV4Y2VwdGlvbiBlKSB7CisgICAgICAgIH0gY2F0Y2goQ29tcG9uZW50RXhjZXB0aW9uIGUpIHsKICAgICAgICAgICAgIGFzc2VydENvbXBvbmVudEV4Y2VwdGlvbihlLCBBY3Rpb25TdGF0dXMuQ09NUE9ORU5UX01JU1NJTkdfQ09OVEFDVCwgQ29tcG9uZW50VHlwZUVudW0uU0VSVklDRS5nZXRWYWx1ZSgpKTsKKyAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgfQorICAgICAgICBmYWlsKCk7CiAgICAgfQogCiAgICAgLy8gU2VydmljZSBjb250YWN0SWQgLSBzdG9wCkBAIC01MTksOSArNDE1LDExIEBACiAgICAgICAgIHNlcnZpY2VFeGlzdC5zZXRDYXRlZ29yaWVzKG51bGwpOwogICAgICAgICB0cnl7CiAgICAgICAgICAgICBibC5jcmVhdGVTZXJ2aWNlKHNlcnZpY2VFeGlzdCwgdXNlcik7Ci0gICAgICAgIH0gY2F0Y2goQnlBY3Rpb25TdGF0dXNDb21wb25lbnRFeGNlcHRpb24gZSkgewotICAgICAgICAgICAgYXNzZXJ0Q29tcG9uZW50RXhjZXB0aW9uKGUsIEFjdGlvblN0YXR1cy5DT01QT05FTlRfSU5WQUxJRF9DT05UQUNULCBDb21wb25lbnRUeXBlRW51bS5TRVJWSUNFLmdldFZhbHVlKCkpOworICAgICAgICB9IGNhdGNoKENvbXBvbmVudEV4Y2VwdGlvbiBlKSB7CisgICAgICAgICAgICBhc3NlcnRDb21wb25lbnRFeGNlcHRpb24oZSwgQWN0aW9uU3RhdHVzLkNPTVBPTkVOVF9NSVNTSU5HX0NBVEVHT1JZLCBDb21wb25lbnRUeXBlRW51bS5TRVJWSUNFLmdldFZhbHVlKCkpOworICAgICAgICAgICAgcmV0dXJuOwog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G9ycywgc2VydmljZUZpZWxkVmFsaWRhdG9ycyk7CisgICAgfQorCisKKworICAgIEBCZWZvcmUKKyAgICBwdWJsaWMgdm9pZCBzZXR1cCgpIHsKKworICAgICAgICAvLyBFbGVtZW50cworICAgICAgICBJRWxlbWVudE9wZXJhdGlvbiBtb2NrRWxlbWVudERhbyA9IG5ldyBFbGVtZW50T3BlcmF0aW9uTW9jaygpOworCisgICAgICAgIC8vIFVzZXIgZGF0YSBhbmQgbWFuYWdlbWVudAorICAgICAgICB1c2VyID0gbmV3IFVzZXIoKTsKKyAgICAgICAgdXNlci5zZXRVc2VySWQoImpoMDAwMyIpOworICAgICAgICB1c2VyLnNldEZpcnN0TmFtZSgiSmltbWkiKTsKKyAgICAgICAgdXNlci5zZXRMYXN0TmFtZSgiSGVuZHJpeCIpOworICAgICAgICB1c2VyLnNldFJvbGUoUm9sZS5BRE1JTi5uYW1lKCkpOworCisgICAgICAgIHdoZW4obW9ja1VzZXJBZG1pbi5nZXRVc2VyKCJqaDAwMDMiLCBmYWxzZSkpLnRoZW5SZXR1cm4odXNlcik7CisgICAgICAgIHdoZW4odXNlclZhbGlkYXRpb25zLnZhbGlkYXRlVXNlckV4aXN0cyhlcSgiamgwMDAzIikpKS50aGVuUmV0dXJuKHVzZXIpOworICAgICAgICB3aGVuKHVzZXJWYWxpZGF0aW9ucy52YWxpZGF0ZVVzZXJOb3RFbXB0eShlcSh1c2VyKSwgYW55U3RyaW5nKCkpKS50aGVuUmV0dXJuKHVzZXIpOworLy8gICAgICAgIHdoZW4odXNlclZhbGlkYXRpb25zLnZhbGlkYXRlVXNlclJvbGUodXNlcikpCisgICAgICAgIC8vIFNlcnZsZXQgQ29udGV4dCBhdHRyaWJ1dGVzCisgICAgICAgIHdoZW4oc2VydmxldENvbnRleHQuZ2V0QXR0cmlidXRlKENvbnN0YW50cy5DT05GSUdVUkFUSU9OX01BTkFHRVJfQVRUUikpLnRoZW5SZXR1cm4oY29uZmlndXJhdGlvbk1hbmFnZ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idXRpb25FbmdpbmUsIGNvbXBvbmVudEluc3RhbmNlQnVzaW5lc3NMb2dpYywKKyAgICAgICAgICAgICAgICBzZXJ2aWNlRGlzdHJpYnV0aW9uVmFsaWRhdGlvbiwgZm9yd2FyZGluZ1BhdGhWYWxpZGF0b3IsIHVpQ29tcG9uZW50RGF0YUNvbnZlcnRlciwKKyAgICAgICAgICAgICAgICBzZXJ2aWNlRmlsdGVyT3BlcmF0aW9uLCBzZXJ2aWNlRmlsdGVyVmFsaWRhdG9yLCBhcnRpZmFjdFRvc2NhT3BlcmF0aW9uLCBjb21wb25lbnRDb250YWN0SWRWYWxpZGF0b3IsCisgICAgICAgICAgICAgICAgY29tcG9uZW50TmFtZVZhbGlkYXRvciwgY29tcG9uZW50VGFnc1ZhbGlkYXRvciwgY29tcG9uZW50VmFsaWRhdG9yLAorICAgICAgICAgICAgICAgIGNvbXBvbmVudEljb25WYWxpZGF0b3IsIGNvbXBvbmVudFByb2plY3RDb2RlVmFsaWRhdG9yLCBjb21wb25lbnREZXNjcmlwdGlvblZhbGlkYXRvcik7CisgICAgICAgIGJsLnNldENvbXBvbmVudENvbnRhY3RJZFZhbGlkYXRvcihjb21wb25lbnRDb250YWN0SWRWYWxpZGF0b3IpOworICAgICAgICBibC5zZXRDb21wb25lbnRJY29uVmFsaWRhdG9yKGNvbXBvbmVudEljb25WYWxpZGF0b3IpOworICAgICAgICBibC5zZXRDb21wb25lbnRUYWdzVmFsaWRhdG9yKGNvbXBvbmVudFRhZ3NWYWxpZGF0b3IpOworICAgICAgICBibC5zZXRDb21wb25lbnROYW1lVmFsaWRhdG9yKGNvbXBvbmVudE5hbWVWYWxpZGF0b3IpOworICAgICAgICBibC5zZXRDb21wb25lbnREZXNjcmlwdGlvblZhbGlkYXRvcihjb21wb25lbnREZXNjcmlwdGlvblZhbGlkYXRvcik7CisgICAgICAgIGJsLnNldENvbXBvbmVudFByb2plY3RDb2RlVmFsaWRhdG9yKGNvbXBvbmVudFByb2plY3RDb2Rl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Y3JlYXRlUmVzb3VyY2VBdWRpdCk7YWRkKGNoZWNrSW5SZXNvdXJjZUF1ZGl0KTsqL2FkZChjaGVja091dFJlc291cmNlQXVkaXQpO319OworICAgICAgICAvLyBlaXRoZXIgPSBFaXRoZXIubGVmdChsaXN0KTsKKyAgICAgICAgLy8gfQorICAgICAgICAvLyBlbHNleworICAgICAgICAvLyBlaXRoZXIgPSBudWxsOworICAgICAgICAvLyB9CisgICAgICAgIC8vIHJldHVybiBlaXRoZXI7CisgICAgICAgIC8vIH0KKyAgICAgICAgLy8gfSkud2hlbihhdWRpdGluZ0RhbykuZ2V0RmlsdGVyZWRSZXNvdXJjZUFkbWluQXVkaXRpbmdFdmVudHMoTW9ja2l0by5hbnlNYXAoKSk7CisgICAgICAgIC8vCisgICAgICAgIC8vCisgICAgICAgIExpc3Q8UmVzb3VyY2VBZG1pbkV2ZW50PiBsaXN0ID0gbmV3IEFycmF5TGlzdDxSZXNvdXJjZUFkbWluRXZlbnQ+KCkgeworICAgICAgICAgICAgeworICAgICAgICAgICAgICAgIGFkZChjcmVhdGVSZXNvdXJjZUF1ZGl0KTsKKyAgICAgICAgICAgICAgICBhZGQoY2hlY2tJblJlc291cmNlQXVkaXQpOworICAgICAgICAgICAgICAgIGFkZChjaGVja091dFJlc291cmNlQXVkaXQpOworICAgICAgICAgICAgfQorICAgICAgICB9OworICAgICAgICBFaXRoZXI8TGlzdDxSZXNvdXJjZUFkbWluRXZlbnQ+LCBBY3Rpb25TdGF0dXM+IHJlc3VsdCA9IEVpdGhlci5sZWZ0KGxpc3QpOworICAgICAgICBNb2NraXRvLndoZW4oYXVkaXRpbmdEYW8uZ2V0QnlTZXJ2aWNlSW5zdGFuY2VJZChNb2NraXRvLmFueVN0cmluZygpKSkudGhlblJldHVybihyZXN1bHQpOworCisgICAgICAgIExpc3Q8UmVzb3VyY2VBZG1pbkV2ZW50PiBsaXN0UHJldiA9IG5ldyBBcnJheUxpc3Q8PigpOworICAgICAgICBFaXRoZXI8T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2F0YWxvZy1iZS9zcmMvdGVzdC9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2NvbXBvbmVudHMvaW1wbC9TZXJ2aWNlVmFsaWRhdGlvbnNUZXN0LmphdmEKQEAgLTAsMCArMSwyMDkgQEAKKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAyMCBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKKyAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KKyAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAorICoKKyAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wCisgKgorICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZQorICogZGlzdHJpYnV0ZWQgdW5kZXIgdGhlIExpY2Vuc2UgaXMgZGlzdHJpYnV0ZWQgb24gYW4gIkFTIElTIiBCQVNJUywKKyAqIFdJVEhPVVQgV0FSUkFOVElFUyBP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VGVzdFNldHVwIHsKKworICAgIEBUZXN0CisgICAgcHVibGljIHZvaWQgdGVzdEludmFsaWRFbnZpcm9ubWVudENvbnRleHQoKSB7CisgICAgICAgIFNlcnZpY2UgbmV3U2VydmljZSA9IGNyZWF0ZVNlcnZpY2VPYmplY3QoZmFsc2UpOworICAgICAgICBuZXdTZXJ2aWNlLnNldEVudmlyb25tZW50Q29udGV4dCgibm90IHZhbGlkIik7CisgICAgICAgIHRyeSB7CisgICAgICAgICAgICBibC5jcmVhdGVTZXJ2aWNlKG5ld1NlcnZpY2UsIHVzZXIpOworICAgICAgICB9IGNhdGNoIChDb21wb25lbnRFeGNlcHRpb24gZXhwKSB7CisgICAgICAgICAgICBhc3NlcnRDb21wb25lbnRFeGNlcHRpb24oZXhwLCBBY3Rpb25TdGF0dXMuSU5WQUxJRF9FTlZJUk9OTUVOVF9DT05URVhULCAibm90IHZhbGlkIik7CisgICAgICAgICAgICByZXR1cm47CisgICAgICAgIH0KKyAgICAgICAgZmFpbCgpOworICAgIH0KKworICAgIEBUZXN0CisgICAgcHVibGljIHZvaWQgdGVzdFZhbGlkRW52aXJvbm1lbnRDb250ZXh0KCkgeworICAgICAgICBTZXJ2aWNlIG5ld1NlcnZpY2UgPSBjcmVhdGVTZXJ2aWNlT2JqZWN0KGZhbHNlKTsKKyAgICAgICAgbmV3U2VydmljZS5zZXRFbnZpcm9ubWVudENvbnRleHQoIkNyaXRpY2FsX1JldmVudWUtQmVhcmluZyIpOworICAgICAgICBFaXRoZXI8U2VydmljZSwgUmVzcG9uc2VGb3JtYXQ+IHNlcnZpY2UgPSBibC52YWxpZGF0ZVNlcnZpY2VCZWZvcmVDcmVhdGUobmV3U2VydmljZSwgdXNlciwgQXVkaXRpbmdBY3Rpb25FbnVtLkNSRUFURV9SRVNPVVJDRSk7CisgICAgICAgIGFzc2VydFRoYXQoc2VydmljZS5sZWZ0KCkudmFsdWUoKS5nZXRFbnZpcm9ubWVudENvbnRleHQoKSkuaXNFcXVhbFR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MDAKLS0tIGEvY2F0YWxvZy1iZS9zcmMvdGVzdC9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2NvbXBvbmVudHMvbGlmZWN5Y2xlL0NlcnRpZmljYXRpb25DaGFuZ2VUcmFuc2l0aW9uVGVzdC5qYXZhCisrKyAvZGV2L251bGwKQEAgLTEsMTgwICswLDAgQEAKLS8qLQotICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIFNEQwotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIENvcHlyaWdodCAoQykgMjAxNyBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKLSAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KLSAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAotICogCi0gKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAotICogCi0gKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlCi0gKiBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0cmlidXRlZCBvbiB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ZVRyYW5zaXRpb25UZXN0cy5qYXZhIGIvY2F0YWxvZy1iZS9zcmMvdGVzdC9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2NvbXBvbmVudHMvbGlmZWN5Y2xlL0NlcnRpZmljYXRpb25DaGFuZ2VUcmFuc2l0aW9uVGVzdHMuamF2YQpuZXcgZmlsZSBtb2RlIDEwMDY0NAppbmRleCAwMDAwMDAwLi4yYWY0MTNlCi0tLSAvZGV2L251bGwKKysrIGIvY2F0YWxvZy1iZS9zcmMvdGVzdC9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2NvbXBvbmVudHMvbGlmZWN5Y2xlL0NlcnRpZmljYXRpb25DaGFuZ2VUcmFuc2l0aW9uVGVzdHMuamF2YQpAQCAtMCwwICsxLDI2OSBAQAorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgorICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0CisgKgorICogICAgICBodHRwOi8vd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hdGVUb3NjYUFydGlmYWN0cyhzZXJ2aWNlLCBvd25lciwgdHJ1ZSwgZmFsc2UsIGZhbHNlKSkudGhlblJldHVybihyZXN1bHRBcnRpZmFjdHMpOworICAgICAgICBjaGFuZ2VTdGF0ZVJlc3VsdCA9IGNoYW5nZVRyYW5zaXRpb24uY2hhbmdlU3RhdGUoQ29tcG9uZW50VHlwZUVudW0uU0VSVklDRSwgc2VydmljZSwgc2VydmljZUJ1c2luZXNzTG9naWMsIHVzZXIsIG93bmVyLCBmYWxzZSwgdHJ1ZSk7CisgICAgICAgIGFzc2VydFRydWUoY2hhbmdlU3RhdGVSZXN1bHQuaXNMZWZ0KCkpOworICAgIH0KKworICAgIHByaXZhdGUgdm9pZCBzaW11bGF0ZUNlcnRpZmllZFZlcnNpb25FeGlzdEZvclJJKCkgeworICAgICAgICBDb21wb25lbnQgZHVtbXlSZXNvdXJjZSA9IG5ldyBSZXNvdXJjZSgpOworICAgICAgICBFaXRoZXI8Q29tcG9uZW50LCBTdG9yYWdlT3BlcmF0aW9uU3RhdHVzPiByZXN1bHQgPSBFaXRoZXIubGVmdChkdW1teVJlc291cmNlKTsKKyAgICAgICAgTW9ja2l0by53aGVuKHRvc2NhT3BlcmF0aW9uRmFjYWRlLmdldFRvc2NhRWxlbWVudChNb2NraXRvLmFueVN0cmluZygpKSkudGhlblJldHVybihFaXRoZXIubGVmdChkdW1teVJlc291cmNlKSk7CisgICAgICAgIE1vY2tpdG8ud2hlbih0b3NjYU9wZXJhdGlvbkZhY2FkZS5maW5kTGFzdENlcnRpZmllZFRvc2NhRWxlbWVudEJ5VVVJRChNb2NraXRvLmFueShDb21wb25lbnQuY2xhc3MpKSkudGhlblJldHVybihyZXN1bHQpOworICAgIH0KKworICAgIHByaXZhdGUgUmVzb3VyY2UgY3JlYXRlVkZXaXRoUkkoU3RyaW5nIHJpVmVyc2lvbikgeworICAgICAgICBSZXNvdXJjZSByZXNvdXJjZSA9IG5ldyBSZXNvdXJjZSgpOworICAg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Q9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBTREMKKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBDb3B5cmlnaHQgKEMpIDIwMTcgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7CisgKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCisgKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKKyAqIAorICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKKyAqIAorICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZQorICogZGlzdHJpYnV0ZWQgdW5kZXIgdGhlIExpY2Vuc2UgaXMgZGlzdHJpYnV0ZWQgb24gYW4gIkFTIElTIiBCQVNJUywKKyAqIFdJVEhPVVQgV0FSUkFOVElFUyBPUiBDT05ESVRJT05TIE9GIEFOWSBLSU5ELCBlaXRoZXIgZXhwcmVzcyBvciBpbXBsaWVkLgorICogU2VlIHRoZSBMaWNlbnNlIGZvciB0aGUgc3BlY2lmaWMgbGFuZ3VhZ2UgZ292ZXJuaW5nIHBlcm1pc3Npb25zIGFuZAorICogbGltaXRhdGlvb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mcvb3BlbmVjb21wL3NkYy9iZS9jb21wb25lbnRzL2xpZmVjeWNsZS9DZXJ0aWZpY2F0aW9uUmVxdWVzdFRlc3QuamF2YQpkZWxldGVkIGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggNzA4MzNmNC4uMDAwMDAwMAotLS0gYS9jYXRhbG9nLWJlL3NyYy90ZXN0L2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvY29tcG9uZW50cy9saWZlY3ljbGUvQ2VydGlmaWNhdGlvblJlcXVlc3RUZXN0LmphdmEKKysrIC9kZXYvbnVsbApAQCAtMSwyNzIgKzAsMCBAQAotLyotCi0gKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogU0RDCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOwotICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgotICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0Ci0gKiAKLSAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wCi0gKiAKLSAqIFVubGVzcyByZXF1aXJlZCBieSB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lYzMzMAotLS0gL2Rldi9udWxsCisrKyBiL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jb21wb25lbnRzL2xpZmVjeWNsZS9MaWZlY3ljbGVCdXNpbmVzc0xvZ2ljVGVzdC5qYXZhCkBAIC0wLDAgKzEsMTY0IEBACisvKi0KKyAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBTREMKKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBDb3B5cmlnaHQgKEMpIDIwMjAgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7CisgKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCisgKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKKyAqCisgKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAorICoKKyAqIFVubGVzcyByZXF1aXJlZCBieSBhcHBsaWNhYmxlIGxhdyBvciBhZ3JlZWQgdG8gaW4gd3JpdGluZywgc29mdHdhcmUKKyAqIGRpc3RyaWJ1dGVkIHVuZGVyIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1dGVkIG9uIG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LS1naXQgYS9jYXRhbG9nLWJlL3NyYy90ZXN0L2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvY29tcG9uZW50cy9tZXJnZS9pbnN0YW5jZS9Db21wb25lbnRJbnN0YW5jZUhlYXRFbnZNZXJnZVRlc3QuamF2YSBiL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jb21wb25lbnRzL21lcmdlL2luc3RhbmNlL0NvbXBvbmVudEluc3RhbmNlSGVhdEVudk1lcmdlVGVzdC5qYXZhCmluZGV4IDNmNjA1NGQuLmY1MzE3YmIgMTAwNjQ0Ci0tLSBhL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jb21wb25lbnRzL21lcmdlL2luc3RhbmNlL0NvbXBvbmVudEluc3RhbmNlSGVhdEVudk1lcmdlVGVzdC5qYXZhCisrKyBiL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jb21wb25lbnRzL21lcmdlL2luc3RhbmNlL0NvbXBvbmVudEluc3RhbmNlSGVhdEVudk1lcmdlVGVzdC5qYXZhCkBAIC05Miw3ICs5Miw3IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNb2NraXRvLmVxKFVTRVIpLCBNb2NraXRvLmVxKGpzb24pLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTW9ja2l0by5yZWZFcShhcnRpZmFjdFVwZGF0ZU9wZXJhdGlvbiksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc051bGwoKSkpCi0gICAgICAgIC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icHJvcDIyXCI6e1wicHJvcDIyMVwiOjQ1LFwicHJvcDIyMlwiOlwidmFsMjIyXCIsXCJwcm9wMjIzXCI6XCJmYWxzZVwifX1dIik7CisKKyAgICAgICAgTWFwPFN0cmluZywgRGF0YVR5cGVEZWZpbml0aW9uPiBkYXRhVHlwZXMgPSBidWlsZERhdGFUeXBlcygpOworICAgICAgICB3aGVuKGFwcGxpY2F0aW9uRGF0YVR5cGVDYWNoZS5nZXRBbGwoKSkudGhlblJldHVybihFaXRoZXIubGVmdChkYXRhVHlwZXMpKTsKKyAgICAgICAgdGVzdEluc3RhbmNlLm1lcmdlUHJvcGVydHlWYWx1ZShvbGRQcm9wLCBuZXdQcm9wLCBDb2xsZWN0aW9ucy5lbXB0eUxpc3QoKSk7CisgICAgICAgIGFzc2VydEVxdWFscygidmFsdWVfc3BlYyIsICJbe1wicHJvcDIyXCI6e1wicHJvcDIyM1wiOlwiZmFsc2VcIixcInByb3AyMjFcIjo0NSxcInByb3AyMjJcIjpcInZhbDIyMlwifX1dIiwgbmV3UHJvcC5nZXRWYWx1ZSgpKTsKKyAgICB9CisKKworCiAgICAgLyoKICAgICAgKiBPbGQgUHJvcGVydHk6ICAgICAgICAgICAgICAgICAgICAgICAgICBOZXcgUHJvcGVydHk6ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEV4cGVjdGVkOiAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICogeyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CmRpZmYgLS1naXQgYS9jYXRhbG9nLWJlL3NyYy90ZXN0L2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvY29tcG9uZW50cy9tZXJnZS9yZXNvdXJjZS9SZXNvdXJjZURhdGFNZXJnZUJ1c2luZXNzTG9naWNUZXN0LmphdmEgYi9jYXRhbG9nLWJlL3NyYy90ZXN0L2phdmEvb3JnL29wZW5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pbXBsZW1lbnRzIElEaXN0cmlidXRpb25FbmdpbmUgewogICAgIEBPdmVycmlkZQogICAgIHB1YmxpYyBib29sZWFuIGlzQWN0aXZlKCkgewpAQCAtNzQsNCArNzYsOSBAQAogICAgICAgICByZXR1cm4gbnVsbDsKICAgICB9CiAKKyAgICBAT3ZlcnJpZGUKKyAgICBwdWJsaWMgT3BlcmF0aW9uYWxFbnZpcm9ubWVudEVudHJ5IGdldEVudmlyb25tZW50QnlEbWFhcFVlYkFkZHJlc3MoTGlzdDxTdHJpbmc+IGRtYWFwVWViQWRkcmVzcykgeworICAgICAgICByZXR1cm4gbnVsbDsKKyAgICB9CisKIH0KZGlmZiAtLWdpdCBhL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jb21wb25lbnRzL3BhdGgvYmVhbnMvRmVhdHVyZVRvZ2dsZURhb01vY2suamF2YSBiL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jb21wb25lbnRzL3BhdGgvYmVhbnMvRmVhdHVyZVRvZ2dsZURhb01vY2suamF2YQpuZXcgZmlsZSBtb2RlIDEwMDY0NAppbmRleCAwMDAwMDAwLi5hN2Y3YTc2Ci0tLSAvZGV2L251bGwKKysrIGIvY2F0YWxvZy1iZS9zcmMvdGVzdC9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2NvbXBvbmVudHMvcGF0aC9iZWFucy9GZWF0dXJlVG9nZ2xlRGFvTW9jay5qYXZhCkBAIC0wLDAgKzEsNTcgQEAKKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcH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lMaXN0KCIxIiwiMiIpKTsKKyAgICAgICAgaW5SYW5nZUNvbnN0ID0gbmV3IEluUmFuZ2VDb25zdHJhaW50KCk7CisgICAgICAgIHBhdHRlcm5Db25zdHJhaW50ICA9IG5ldyBQYXR0ZXJuQ29uc3RyYWludCgpOworICAgICAgICBwcm9wMV91cGRhdGUuc2V0Q29uc3RyYWludHMoTGlzdHMubmV3QXJyYXlMaXN0KHZ2Q29uc3QsIGluUmFuZ2VDb25zdCwgcGF0dGVybkNvbnN0cmFpbnQpKTsKKworICAgICAgICBMaXN0PFByb3BlcnR5RGVmaW5pdGlvbj4gb2xkUHJvcGVydGllcyA9IExpc3RzLm5ld0FycmF5TGlzdChwcm9wMSk7CisgICAgICAgIExpc3Q8UHJvcGVydHlEZWZpbml0aW9uPiBuZXdQcm9wZXJ0aWVzID0gTGlzdHMubmV3QXJyYXlMaXN0KHByb3AxX3VwZGF0ZSk7CisgICAgICAgIG9sZFJlc291cmNlLnNldFByb3BlcnRpZXMob2xkUHJvcGVydGllcyk7CisgICAgICAgIG5ld1Jlc291cmNlLnNldFByb3BlcnRpZXMobmV3UHJvcGVydGllcyk7CisgICAgICAgIHRyeSB7CisgICAgICAgICAgICBQcm9wZXJ0eUNvbnN0cmFpbnRzVXRpbHMudmFsaWRhdGVQcm9wZXJ0aWVzQ29uc3RyYWludHMobmV3UmVzb3VyY2UsIG9sZFJlc291cmNlKTsKKyAgICAgICAgfSBjYXRjaCAoQ29tcG9uZW50RXhjZXB0aW9uIGUpeworICAgICAgICAgICAgYXNzZXJ0VGhhdChlLmdldEFjdGlvblN0YXR1cygpKQorICAgICAgICAgICAgICAgICAgICAuaXNOb3ROdWxsKCkKKyAgICAgICAgICAgICAgICAgICAgLmlzRXF1YWxUbyhBY3Rpb25TdGF0dXMuQ0FOTk9UX0RFTEVURV9WQUxJRF9WQUxVRVMpOworCisgICAgICAgICAgICBhc3NlcnRUaGF0KGUuZ2V0UGFyYW1zKCkpCisgICAgICAgICAgICAgICAg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DNfdXBkYXRlLnNldENvbnN0cmFpbnRzKExpc3RzLm5ld0FycmF5TGlzdCh2dkNvbnN0LCBpblJhbmdlQ29uc3QsIHBhdHRlcm5Db25zdHJhaW50KSk7CisKKyAgICAgICAgTGlzdDxQcm9wZXJ0eURlZmluaXRpb24+IG9sZFByb3BlcnRpZXMgPSBMaXN0cy5uZXdBcnJheUxpc3QocHJvcDMpOworICAgICAgICBMaXN0PFByb3BlcnR5RGVmaW5pdGlvbj4gbmV3UHJvcGVydGllcyA9IExpc3RzLm5ld0FycmF5TGlzdChwcm9wM191cGRhdGUpOworICAgICAgICBvbGRSZXNvdXJjZS5zZXRQcm9wZXJ0aWVzKG9sZFByb3BlcnRpZXMpOworICAgICAgICBuZXdSZXNvdXJjZS5zZXRQcm9wZXJ0aWVzKG5ld1Byb3BlcnRpZXMpOworICAgICAgICB0cnkgeworICAgICAgICAgICAgUHJvcGVydHlDb25zdHJhaW50c1V0aWxzLnZhbGlkYXRlUHJvcGVydGllc0NvbnN0cmFpbnRzKG5ld1Jlc291cmNlLCBvbGRSZXNvdXJjZSk7CisgICAgICAgIH0gY2F0Y2ggKENvbXBvbmVudEV4Y2VwdGlvbiBlKXsKKyAgICAgICAgICAgIGFzc2VydFRoYXQoZS5nZXRBY3Rpb25TdGF0dXMoKSkKKyAgICAgICAgICAgICAgICAgICAgLmlzTm90TnVsbCgpCisgICAgICAgICAgICAgICAgICAgIC5pc0VxdWFsVG8oQWN0aW9uU3RhdHVzLkNBTk5PVF9ERUxFVEVfVkFMSURfVkFMVUVTKTsKKworICAgICAgICAgICAgYXNzZXJ0VGhhdChlLmdldFBhcmFtcygpKQorICAgICAgICAgICAgICAgICAgICAuY29udGFpbnNFeGFjdGx5SW5BbnlPcmRlcihDb25zdHJhaW50VHlwZS5WQUxJRF9WQUxVRVMubmFtZSgpLExpc3RzLm5ld0FycmF5TGlzdCgiYTEiKS50b1N0cmluZygpKTsKKworICAgICAgICB9CisKKyAgICB9Cit9CmRpZmYgLS1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IGIvY2F0YWxvZy1iZS9zcmMvdGVzdC9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2NvbXBvbmVudHMvcHJvcGVydHkvUHJvcGVydHlEZXNlcmlhbGl6YXRpb25PcmNoZXN0cmF0b3JUZXN0LmphdmEKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uZDFjZjMwMwotLS0gL2Rldi9udWxsCisrKyBiL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9jb21wb25lbnRzL3Byb3BlcnR5L1Byb3BlcnR5RGVzZXJpYWxpemF0aW9uT3JjaGVzdHJhdG9yVGVzdC5qYXZhCkBAIC0wLDAgKzEsMTQwIEBACisvKi0KKyAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBTREMKKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBDb3B5cmlnaHQgKEMpIDIwMjAgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7CisgKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCisgKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKKyAqCisgKiAgICAgIGh0dHA6Ly93d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ENhbWJyaWFFcnJvclJlc3BvbnNlKENhbWJyaWFPcGVyYXRpb25TdGF0dXMuT0ssIEh0dHBTdGF0dXMuU0NfT0spOworCisgICAgICAgIHdoZW4oY2FtYnJpYUhhbmRsZXIudW5SZWdpc3RlckZyb21Ub3BpYyhNb2NraXRvLmFueUNvbGxlY3Rpb24oKSwgZXEoIjExIiksCisgICAgICAgICAgICAgICAgZXEoIjIyIiksIGVxKCJteVB1YmxpY0tleSIpLCBNb2NraXRvLmFueShTdWJzY3JpYmVyVHlwZUVudW0uY2xhc3MpLCBNb2NraXRvLmFueVN0cmluZygpKSkKKyAgICAgICAgICAgICAgICAudGhlblJldHVybihva1Jlc3BvbnNlKTsKKyAgICAgICAgd2hlbihkaXN0cmlidXRpb25FbmdpbmUuZ2V0RW52aXJvbm1lbnRCeURtYWFwVWViQWRkcmVzcyh1ZWJzKSkKKyAgICAgICAgICAgICAgICAudGhlblJldHVybihlbnZpcm9ubWVudCk7CisKKyAgICAgICAgZGlzdHJpYnV0aW9uQnVzaW5lc3NMb2dpYy5oYW5kbGVVblJlZ2lzdHJhdGlvbihyZXNwb25zZVdyYXBwZXIsIHJlZ2lzdHJhdGlvblJlcXVlc3QsIGF1ZGl0SGFuZGxlcik7CisKKyAgICAgICAgTW9ja2l0by52ZXJpZnkoZGlzdHJpYnV0aW9uQnVzaW5lc3NMb2dpYywgTW9ja2l0by50aW1lcygwKSkucmVnaXN0ZXJEaXN0cmlidXRpb25DbGllbnRUb1RvcGljKAorICAgICAgICAgICAgICAgIGVxKHJlc3BvbnNlV3JhcHBlciksIGVxKHJlZ2lzdHJhdGlvblJlcXVlc3QpLCBlcShTdWJzY3JpYmVyVHlwZUVudW0uUFJPRFVDRVIpLAorICAgICAgICAgICAgICAgIE1vY2tpdG8uYW55U3RyaW5nKCkpOworICAgICAgICBNb2NraXRvLnZlcmlmeShkaXN0cmlidXRpb25CdXNpbmVzc0xvZ2ljLCBNb2NraXRvLnRpbWVzKDApKS5yZWdpc3RlckRpc3RyaWJ1dGlvbkNsaWVudFRvVG9waWMoCisgICAgICAgICAgICAgICAgZXEocmVzcG9uc2VXcmFwcGVyKSwgZXEocmVnaXN0cmF0aW9uUmVxdWVzdCksIGVxKFN1YnNjcmliZXJUeXBlRW51bS5DT05TVU1FUiksCisgICAgICAgICAgICAgICAgTW9ja2l0by5hbnlTdHJpbmcoKSk7CisgICAgICAgIE1vY2tpdG8udmVyaWZ5KGRpc3RyaWJ1dGlvbkJ1c2luZXNzTG9naWMsIE1vY2tpdG8udGltZXMoMSkpLnVuUmVnaXN0ZXJEaXN0cmlidXRpb25DbGllbnRGcm9tVG9waWMoCisgICAgICAgICAgICAgICAgZXEocmVnaXN0cmF0aW9uUmVxdWVzdCksIGVxKFN1YnNjcmliZXJUeXBlRW51bS5QUk9EVUNFUiksIE1vY2tpdG8uYW55U3RyaW5nKCkpOworICAgICAgICBNb2NraXRvLnZlcmlmeShkaXN0cmlidXRpb25CdXNpbmVzc0xvZ2ljLCBNb2NraXRvLnRpbWVzKDEpKS51blJlZ2lzdGVyRGlzdHJpYnV0aW9uQ2xpZW50RnJvbVRvcGljKAorICAgICAgICAgICAgICAgIGVxKHJlZ2lzdHJhdGlvblJlcXVlc3QpLCBlcShTdWJzY3JpYmVyVHlwZUVudW0uQ09OU1VNRVIpLCBNb2NraXRvLmFueVN0cmluZygpKTsKKworICAgICAgICBNb2NraXRvLnZlcmlmeShjYW1icmlhSGFuZGxlciwgTW9ja2l0by50aW1lcygyKSkudW5SZWdpc3RlckZyb21Ub3BpYyhNb2NraXRvLmFueUNvbGxlY3Rpb24oKSwKKyAgICAgICAgICAgICAgICBNb2NraXRvLmFueVN0cmluZygpLCBNb2NraXRvLmFueVN0cmluZygpLCBNb2NraXRvLmFueVN0cmluZygpLCBNb2NraXRvLmFueShTdWJzY3JpYmVyVHlwZUVudW0uY2xhc3MpLAorICAgICAgICAgICAgICAgIE1vY2tpdG8uYW55U3RyaW5nKCkpOworCisgICAgICAgIGFzc2VydFRyd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2VydFRydWUoZG93bmxvYWRlZFBheWxvYWRNYXRjaGVzRXhwZWN0ZWQocmVzcG9uc2UsIEJZVEVfQVJSQVkpKTsKLSAgICB9Ci0KLSAgICBAT3ZlcnJpZGUKLSAgICBwcm90ZWN0ZWQgQXBwbGljYXRpb24gY29uZmlndXJlKCkgewotICAgICAgICBBcHBsaWNhdGlvbkNvbnRleHQgY29udGV4dCA9IG5ldyBBbm5vdGF0aW9uQ29uZmlnQXBwbGljYXRpb25Db250ZXh0KFNwcmluZ0NvbmZpZy5jbGFzcyk7Ci0gICAgICAgIHJldHVybiBuZXcgUmVzb3VyY2VDb25maWcoRGlzdHJpYnV0aW9uQ2F0YWxvZ1NlcnZsZXQuY2xhc3MpCi0gICAgICAgICAgICAgICAgLnJlZ2lzdGVyKG5ldyBBYnN0cmFjdEJpbmRlcigpIHsKLQotICAgICAgICAgICAgICAgICAgICBAT3ZlcnJpZGUKLSAgICAgICAgICAgICAgICAgICAgcHJvdGVjdGVkIHZvaWQgY29uZmlndXJlKCkgewotICAgICAgICAgICAgICAgICAgICAgICAgYmluZChIVFRQX1NFUlZMRVRfUkVRVUVTVCkudG8oSHR0cFNlcnZsZXRSZXF1ZXN0LmNsYXNzKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGJpbmQoVVNFUl9CVVNJTkVTU19MT0dJQykudG8oVXNlckJ1c2luZXNzTG9naWMuY2xhc3MpOwotICAgICAgICAgICAgICAgICAgICAgICAgYmluZChDT01QT05FTlRfVVRJTFMpLnRvKENvbXBvbmVudHNVdGlscy5jbGFzcyk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBiaW5kKEFSVElGQUNUU19CVVNJTkVTU19MT0dJQykudG8oQXJ0aWZhY3RzQnVzaW5lc3NMb2dpYy5jbGFzcyk7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICB9KQotICAgICAgICAgICAgICAgIC5wcm9wZXJ0eSgiY29udGV4dENvbmZpZyIsIGNvbnRleHQpO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GFydHNXaXRoKCJGYWlsZWQgdG8gY3JlYXRlIHVzZXIiKSk7CisgICAgICAgICAgICByZXR1cm47CisgICAgICAgIH0KKyAgICAgICAgQXNzZXJ0LmZhaWwoKTsKICAgICB9CiAKICAgICBAVGVzdAotICAgIHB1YmxpYyB2b2lkIHRlc3RQdXNoVXNlck51bGxSb2xlcygpIHRocm93cyBFeGNlcHRpb24geworICAgIHB1YmxpYyB2b2lkIHRlc3RQdXNoVXNlck11bHRpcGxlUm9sZXMoKSB7CisgICAgICAgIEVjb21wVXNlciB1c2VyID0gbmV3IEVjb21wVXNlcigpOworICAgICAgICBTZXQ8RWNvbXBSb2xlPiByb2xlU2V0ID0gbmV3IEhhc2hTZXQ8PigpOworICAgICAgICBFY29tcFJvbGUgcm9sZSA9IG5ldyBFY29tcFJvbGUoKTsKKyAgICAgICAgcm9sZS5zZXRJZCgxTCk7CisgICAgICAgIHJvbGUuc2V0TmFtZSgiRGVzaWduZXIiKTsKKyAgICAgICAgcm9sZVNldC5hZGQocm9sZSk7CisgICAgICAgIEVjb21wUm9sZSByb2xlMSA9IG5ldyBFY29tcFJvbGUoKTsKKyAgICAgICAgcm9sZS5zZXRJZCgyTCk7CisgICAgICAgIHJvbGVTZXQuYWRkKHJvbGUxKTsKKyAgICAgICAgcm9sZS5zZXROYW1lKCJUZXN0ZXIiKTsKKyAgICAgICAgdXNlci5zZXRSb2xlcyhyb2xlU2V0KTsKKyAgICAgICAgdHJ5IHsKKyAgICAgICAgICAgIHRlc3RTdWJqZWN0LnB1c2hVc2VyKHVzZXIpOworICAgICAgICB9IGNhdGNoIChQb3J0YWxBUElFeGNlcHRpb24gZSkgeworICAgICAgICAgICAgQXNzZXJ0LmFzc2VydFRydWUoZS5nZXRNZXNzYWdlKCkuc3RhcnRzV2l0aCgiUmVjZWl2ZWQgbXVsdGlwbGUgcm9sZXMgZm9yIHVzZXIiKSk7CisgICAgICAgICAgICByZXR1cm47CisgICAgICAgIH0KKyAgICAgICAgQXNzZXJ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LCBudWxsKTsKKyAgICAgICAgfSBjYXRjaCAoUG9ydGFsQVBJRXhjZXB0aW9uIGUpIHsKKyAgICAgICAgICAgIEFzc2VydC5hc3NlcnRUcnVlKGUuZ2V0TWVzc2FnZSgpLmVxdWFscygiUmVjZWl2ZWQgbnVsbCBmb3IgYXJndW1lbnQgdXNlciIpKTsKKyAgICAgICAgICAgIHJldHVybjsKKyAgICAgICAgfQorICAgICAgICBBc3NlcnQuZmFpbCgpOworICAgIH0KKworICAgIEBUZXN0CisgICAgcHVibGljIHZvaWQgdGVzdEVkaXRVc2VySWROdWxsKCkgeworICAgICAgICB0cnkgeworICAgICAgICAgICAgdGVzdFN1YmplY3QuZWRpdFVzZXIobnVsbCwgbmV3IEVjb21wVXNlcigpKTsKKyAgICAgICAgfSBjYXRjaCAoUG9ydGFsQVBJRXhjZXB0aW9uIGUpIHsKKyAgICAgICAgICAgIEFzc2VydC5hc3NlcnRUcnVlKGUuZ2V0TWVzc2FnZSgpLmVxdWFscygiUmVjZWl2ZWQgbnVsbCBmb3IgYXJndW1lbnQgbG9naW5JZCIpKTsKKyAgICAgICAgICAgIHJldHVybjsKKyAgICAgICAgfQorICAgICAgICBBc3NlcnQuZmFpbCgpOworICAgIH0KKworICAgIEBUZXN0CisgICAgcHVibGljIHZvaWQgdGVzdEVkaXRVc2VyRmFpbE9uVXBkYXRlKCkgeworICAgICAgICBNb2NraXRvLndoZW4odWJsLnVwZGF0ZVVzZXJDcmVkZW50aWFscyhNb2NraXRvLmFueShVc2VyLmNsYXNzKSkpLnRoZW5SZXR1cm4oRWl0aGVyLnJpZ2h0KG5ldyBSZXNwb25zZUZvcm1hdCgpKSk7CisgICAgICAgIE1vY2tpdG8ud2hlbih1YmwudmVyaWZ5TmV3VXNlckZvclBvcnRhbChNb2NraXRvLmFueVN0cmluZygpKSkudGhlblJldHVybihFaXRoZXIubGVmdChuZXcgVXNlcigpKSk7CisgICAgICAgIEVjb21wVXNlciB1c2VyID0gbmV3IEVjb21wVX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eGNlcHRpb24gZSkgeworICAgICAgICAgICAgQXNzZXJ0LmZhaWwoKTsKKyAgICAgICAgfQorICAgIH0KKworICAgIEBUZXN0CisgICAgcHVibGljIHZvaWQgdGVzdEVkaXRVc2VyRmFpbFVwZGF0ZSgpIHsKKyAgICAgICAgTW9ja2l0by53aGVuKHVibC51cGRhdGVVc2VyQ3JlZGVudGlhbHMoTW9ja2l0by5hbnkoVXNlci5jbGFzcykpKS50aGVuUmV0dXJuKEVpdGhlci5sZWZ0KG5ldyBVc2VyKCkpKTsKKyAgICAgICAgTW9ja2l0by53aGVuKHVibC51cGRhdGVVc2VyUm9sZShNb2NraXRvLmFueVN0cmluZygpLCBNb2NraXRvLmFueVN0cmluZygpLCBNb2NraXRvLmFueVN0cmluZygpKSkudGhlblRocm93KG5ldyBSdW50aW1lRXhjZXB0aW9uKCkpOworICAgICAgICBNb2NraXRvLndoZW4odWJsLnZlcmlmeU5ld1VzZXJGb3JQb3J0YWwoTW9ja2l0by5hbnlTdHJpbmcoKSkpLnRoZW5SZXR1cm4oRWl0aGVyLmxlZnQobmV3IFVzZXIoKSkpOworICAgICAgICBFY29tcFVzZXIgdXNlciA9IG5ldyBFY29tcFVzZXIoKTsKKyAgICAgICAgU2V0PEVjb21wUm9sZT4gcm9sZVNldCA9IG5ldyBIYXNoU2V0PD4oKTsKKyAgICAgICAgRWNvbXBSb2xlIHJvbGUgPSBuZXcgRWNvbXBSb2xlKCk7CisgICAgICAgIHJvbGUuc2V0SWQoMUwpOworICAgICAgICByb2xlLnNldE5hbWUoIkRlc2lnbmVyIik7CisgICAgICAgIHJvbGVTZXQuYWRkKHJvbGUpOworICAgICAgICB1c2VyLnNldFJvbGVzKHJvbGVTZXQpOworICAgICAgICB0cnkgeworICAgICAgICAgICAgdGVzdFN1YmplY3QuZWRpdFVzZXIoIm1vY2tfaWQiLCB1c2VyKTsKKyAgICAgICAgfSBjYXRjaCAoUG9ydGFsQVBJRXhjZXB0aW9uIGUpIHsKKyAgICAgICAgICAgIEFzc2VydC5hc3NlcnRUcnVlKGUuZ2V0TWVzc2FnZSgpLnN0YXJ0c1dpdGgoIkVycm9yOiBGYWlsZWQgdG8gdXBkYXRlIHVzZXIgcm9sZSIpKTsKKyAgICAgICAgICAgIHJldHVybjsKKyAgICAgICAgfQorICAgICAgICBBc3NlcnQuZmFpbCgpOworICAgIH0KKworICAgIEBUZXN0CisgICAgcHVibGljIHZvaWQgdGVzdEVkaXRVc2VyRmFpbERlYWN0aXZhdGUoKSB7CisgICAgICAgIE1vY2tpdG8ud2hlbih1YmwudXBkYXRlVXNlckNyZWRlbnRpYWxzKE1vY2tpdG8uYW55KFVzZXIuY2xhc3MpKSkudGhlblJldHVybihFaXRoZXIubGVmdChuZXcgVXNlcigpKSk7CisgICAgICAgIE1vY2tpdG8ud2hlbih1YmxlLmRlQWN0aXZhdGVVc2VyKE1vY2tpdG8uYW55U3RyaW5nKCksIE1vY2tpdG8uYW55U3RyaW5nKCkpKS50aGVuVGhyb3cobmV3IFJ1bnRpbWVFeGNlcHRpb24oKSk7CisgICAgICAgIE1vY2tpdG8ud2hlbih1YmwudmVyaWZ5TmV3VXNlckZvclBvcnRhbChNb2NraXRvLmFueVN0cmluZygpKSkudGhlblJldHVybihFaXRoZXIubGVmdChuZXcgVXNlcigpKSk7CisgICAgICAgIEVjb21wVXNlciB1c2VyID0gbmV3IEVjb21wVXNlcigpOworICAgICAgICB0cnkgeworICAgICAgICAgICAgdGVzdFN1YmplY3QuZWRpdFVzZXIoIm1vY2tfaWQiLCB1c2VyKTsKKyAgICAgICAgfSBjYXRjaCAoUG9ydGFsQVBJRXhjZXB0aW9uIGUpIHsKKyAgICAgICAgICAgIEFzc2VydC5hc3NlcnRUcnVlKGUuZ2V0TWVzc2FnZSgpLnN0YXJ0c1dpdGgoIkVycm9yOiBGYWlsZWQgdG8gZGVhY3RpdmF0ZSB1c2VyIikpOworICAgICAgICAgICAgcmV0dXJuOworICAgICAgICB9CisgICAgICAgIEFzc2VydC5mYWlsKCk7CisgICAgfQorCisgICAgQFRlc3QKKyAgICBwdWJsaWMgdm9pZCB0ZXN0RWRpdFVzZXIoKSB7CisgICAgICAgIE1vY2tpdG8ud2hlbih1YmwudXBkYXRlVXNlckNyZWRlbnRpYWxzKE1vY2tpdG8uYW55KFVzZXIuY2xhc3MpKSkudGhlblJldHVybihFaXRoZXIubGVmdChuZXcgVXNlcigpKSk7CisgICAgICAgIE1vY2tpdG8ud2hlbih1YmwudmVyaWZ5TmV3VXNlckZvclBvcnRhbChNb2NraXRvLmFueVN0cmluZygpKSkudGhlblJldHVybihFaXRoZXIubGVmdChuZXcgVXNlcigpKSk7CisgICAgICAgIEVjb21wVXNlciB1c2VyID0gbmV3IEVjb21wVXNlcigpOworICAgICAgICBTZXQ8RWNvbXBSb2xlPiByb2xlU2V0ID0gbmV3IEhhc2hTZXQ8PigpOworICAgICAgICBFY29tcFJvbGUgcm9sZSA9IG5ldyBFY29tcFJvbGUoKTsKKyAgICAgICAgcm9sZS5zZXRJZCgxTCk7CisgICAgICAgIHJvbGUuc2V0TmFtZSgiRGVzaWduZXIiKTsKKyAgICAgICAgcm9sZVNldC5hZGQocm9sZSk7CisgICAgICAgIHVzZXIuc2V0Um9sZXMocm9sZVNldCk7CisgICAgICAgIHRyeSB7CisgICAgICAgICAgICB0ZXN0U3ViamVjdC5lZGl0VXNlcigibW9ja19pZCIsIHVzZXIpOworICAgICAgICB9IGNhdGNoIChQb3J0YWxBUElFeGNlcHRpb24gZSkgeworICAgICAgICAgICAgQXNzZXJ0LmZhaWwoKTsKKyAgICAgICAgfQorICAgIH0KKworICAgIEBUZXN0CisgICAgcHVibGljIHZvaWQgdGVzdEdldFVzZXJJZCgpIHsKKyAgICAgICAgSHR0cFNlcnZsZXRSZXF1ZXN0IGh0dHBTZXJ2bGV0UmVxdWVzdE1vY2sgPSBNb2NraXRvLm1vY2soSHR0cFNlcnZsZXRSZXF1ZXN0LmNsYXNzKTsKKyAgICAgICAgU3RyaW5nIG1vY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ZWNvbXAvc2RjL2JlL2V4Y2VwdGlvbi9Db21wb25lbnRFeGNlcHRpb25NYXRjaGVyLmphdmEKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uMzIzMDE5NgotLS0gL2Rldi9udWxsCisrKyBiL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9leGNlcHRpb24vQ29tcG9uZW50RXhjZXB0aW9uTWF0Y2hlci5qYXZhCkBAIC0wLDAgKzEsNTIgQEAKKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAyMCBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKKyAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KKyAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAorICoKKyAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wCisgKgorICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbi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otICAgICAgICBBcnRpZmFjdERlZmluaXRpb24gYXJ0aWZhY3REZWZpbml0aW9uID0gbmV3IEFydGlmYWN0RGVmaW5pdGlvbigpOwotICAgICAgICBFaXRoZXI8QXJ0aWZhY3REZWZpbml0aW9uLCBSZXNwb25zZUZvcm1hdD4gdXBsb2FkQXJ0aWZhY3RFaXRoZXIgPSBFaXRoZXIubGVmdChhcnRpZmFjdERlZmluaXRpb24pOwotICAgICAgICB3aGVuKGFydGlmYWN0c0J1c2luZXNzTG9naWMKLSAgICAgICAgICAgICAgICAudXBkYXRlQXJ0aWZhY3RPbkludGVyZmFjZU9wZXJhdGlvbkJ5UmVzb3VyY2VVVUlEKGFueVN0cmluZygpLCBhbnkoKSwKLSAgICAgICAgICAgICAgICAgICAgICAgIGFueSgpLCBhbnkoKSwgYW55KCksCi0gICAgICAgICAgICAgICAgICAgICAgICBhbnkoKSwgYW55KCksIGFueSgpLAotICAgICAgICAgICAgICAgICAgICAgICAgYW55KCkpKQotICAgICAgICAgICAgICAgIC50aGVuUmV0dXJuKHVwbG9hZEFydGlmYWN0RWl0aGVyKTsKLQotICAgICAgICBSZXNwb25zZSByZXNwb25zZSA9IHRhcmdldCgpCi0gICAgICAgICAgICAgICAgLnBhdGgocGF0aCkKLSAgICAgICAgICAgICAgICAucmVxdWVzdCgpCi0gICAgICAgICAgICAgICAgLmFjY2VwdChNZWRpYVR5cGUuQVBQTElDQVRJT05fSlNPTikKLSAgICAgICAgICAgICAgICAuaGVhZGVyKENvbnN0YW50cy5YX0VDT01QX0lOU1RBTkNFX0lEX0hFQURFUiwgIm1vY2tYRWNvbXBJbnN0YW5jZUlkIikKLSAgICAgICAgICAgICAgICAuaGVhZGVyKENvbnN0YW50cy5VU0VSX0lEX0hFQURFUiwgZGVzaWduZXJVc2VyLmdldFVzZXJJZCgpKQotICAgICAgICAgICAgICAgIC5wb3N0KEVudGl0eS5qc29uKEVNUFRZX0pTT04pKTsKLQotICAgICAgICBhc3NlcnRUaGF0KHJl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XIucmlnaHQobmV3IFJlc3BvbnNlRm9ybWF0KEh0dHBTdGF0dXMuU0NfQ09ORkxJQ1QpKTsKLQotICAgICAgICB3aGVuKGFydGlmYWN0c0J1c2luZXNzTG9naWMKLSAgICAgICAgICAgICAgICAudXBkYXRlQXJ0aWZhY3RPbkludGVyZmFjZU9wZXJhdGlvbkJ5UmVzb3VyY2VVVUlEKGFueVN0cmluZygpLCBhbnkoKSwKLSAgICAgICAgICAgICAgICAgICAgICAgIGFueSgpLCBhbnkoKSwgYW55KCksCi0gICAgICAgICAgICAgICAgICAgICAgICBhbnkoKSwgYW55KCksIGFueSgpLAotICAgICAgICAgICAgICAgICAgICAgICAgYW55KCkpKQotICAgICAgICAgICAgICAgIC50aGVuUmV0dXJuKHVwbG9hZEFydGlmYWN0RWl0aGVyKTsKLQotICAgICAgICBSZXNwb25zZSByZXNwb25zZSA9IHRhcmdldCgpCi0gICAgICAgICAgICAgICAgLnBhdGgocGF0aCkKLSAgICAgICAgICAgICAgICAucmVxdWVzdCgpCi0gICAgICAgICAgICAgICAgLmFjY2VwdChNZWRpYVR5cGUuQVBQTElDQVRJT05fSlNPTikKLSAgICAgICAgICAgICAgICAuaGVhZGVyKENvbnN0YW50cy5YX0VDT01QX0lOU1RBTkNFX0lEX0hFQURFUiwgIm1vY2tYRWNvbXBJbnN0YW5jZUlkIikKLSAgICAgICAgICAgICAgICAuaGVhZGVyKENvbnN0YW50cy5VU0VSX0lEX0hFQURFUiwgZGVzaWduZXJVc2VyLmdldFVzZXJJZCgpKQotICAgICAgICAgICAgICAgIC5wb3N0KEVudGl0eS5qc29uKEVNUFRZX0pTT04pKTsKLQotICAgICAgICBhc3NlcnRUaGF0KHJlc3BvbnNlLmdldFN0YXR1cygpKS5pc0VxdWFsVG8oSHR0cFN0YXR1cy5TQ19DT05GTElDVCk7Ci0gICAgfQotCi0gICAgQFRlc3QKLSAgICBwdWJsaWMgdm9pZCB1cGxvYWRJbnRlcmZhY2VPcGVyYXRpb25BcnR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YW55KCksIGFueSgpLAotICAgICAgICAgICAgICAgICAgICAgICAgYW55KCksIGFueSgpLCBhbnkoKSwKLSAgICAgICAgICAgICAgICAgICAgICAgIGFueSgpKSkKLSAgICAgICAgICAgICAgICAudGhlblRocm93KG5ldyBSdW50aW1lRXhjZXB0aW9uKCJUZXh0IGV4Y2VwdGlvbiIpKTsKLQotICAgICAgICBSZXNwb25zZSByZXNwb25zZSA9IHRhcmdldCgpCi0gICAgICAgICAgICAgICAgLnBhdGgocGF0aCkKLSAgICAgICAgICAgICAgICAucmVxdWVzdCgpCi0gICAgICAgICAgICAgICAgLmFjY2VwdChNZWRpYVR5cGUuQVBQTElDQVRJT05fSlNPTikKLSAgICAgICAgICAgICAgICAuaGVhZGVyKENvbnN0YW50cy5YX0VDT01QX0lOU1RBTkNFX0lEX0hFQURFUiwgIm1vY2tYRWNvbXBJbnN0YW5jZUlkIikKLSAgICAgICAgICAgICAgICAuaGVhZGVyKENvbnN0YW50cy5VU0VSX0lEX0hFQURFUiwgZGVzaWduZXJVc2VyLmdldFVzZXJJZCgpKQotICAgICAgICAgICAgICAgIC5wb3N0KEVudGl0eS5qc29uKEVNUFRZX0pTT04pKTsKLQotICAgICAgICBhc3NlcnRUaGF0KHJlc3BvbnNlLmdldFN0YXR1cygpKS5pc0VxdWFsVG8oSHR0cFN0YXR1cy5TQ19JTlRFUk5BTF9TRVJWRVJfRVJST1IpOwotICAgIH0KLQotICAgIEBUZXN0Ci0gICAgcHVibGljIHZvaWQgdXBsb2FkQXJ0aWZhY3RVbmtub3duQ29tcG9uZW50VHlwZVRlc3QoKSB7Ci0gICAgICAgIE1hcDxTdHJpbmcsU3RyaW5nPiBwYXJhbWV0ZXJzTWFwID0gbmV3IEhhc2hNYXA8PigpOwotICAgICAgICBwYXJhbWV0ZXJzTWFwLnB1dChBU1NFVF9UWVBFLCAic29tZXRoaW5nX25ldyIpOwotICAgICAgICBwYXJhbWV0ZXJzTWFwLnB1dChVVUlELCAidXVpZCIpOwotC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REZWZpbml0aW9uKTsKLQotICAgICAgICBnaXZlbihhcnRpZmFjdHNCdXNpbmVzc0xvZ2ljLmRlbGV0ZUFydGlmYWN0T25Db21wb25lbnRCeVVVSUQoYW55KCksIGFueSgpLCBhbnkoKSwgYW55KCksCi0gICAgICAgICAgICAgICAgYW55KCksIGFueSgpKSkKLSAgICAgICAgICAgICAgICAud2lsbEFuc3dlciggaW52b2NhdGlvbiAtPiBkZWxldGVBcnRpZmFjdE9uQ29tcG9uZW50QnlVVUlERWl0aGVyKTsKLQotICAgICAgICBSZXNwb25zZSByZXNwb25zZSA9IHRhcmdldCgpCi0gICAgICAgICAgICAgICAgLnBhdGgocGF0aCkKLSAgICAgICAgICAgICAgICAucmVxdWVzdCgpCi0gICAgICAgICAgICAgICAgLmFjY2VwdChNZWRpYVR5cGUuQVBQTElDQVRJT05fSlNPTikKLSAgICAgICAgICAgICAgICAuaGVhZGVyKENvbnN0YW50cy5YX0VDT01QX0lOU1RBTkNFX0lEX0hFQURFUiwgIm1vY2tYRWNvbXBJbnN0YW5jZUlkIikKLSAgICAgICAgICAgICAgICAuaGVhZGVyKENvbnN0YW50cy5VU0VSX0lEX0hFQURFUiwgZGVzaWduZXJVc2VyLmdldFVzZXJJZCgpKQotICAgICAgICAgICAgICAgIC5kZWxldGUoKTsKLQotICAgICAgICBhc3NlcnRUaGF0KHJlc3BvbnNlLmdldFN0YXR1cygpKS5pc0VxdWFsVG8oSHR0cFN0YXR1cy5TQ19PSyk7Ci0gICAgfQotCi0gICAgQFRlc3QKLSAgICBwdWJsaWMgdm9pZCBkZWxldGVBcnRpZmFjdE9uUmVzb3VyY2VFcnJvckR1cmluZ0RlbGV0ZVByb2Nlc3NpbmdUZXN0KCkgewotICAgICAgICBNYXA8U3RyaW5nLFN0cmluZz4gcGFyYW1ldGVyc01hcCA9IG5ldyBIYXNoTWFwPD4oKTsKLSAgICAgICAgcGFyYW1ldGVyc01hcC5wdXQoQVNTRVRfVFlQRSwgQ29tcG9uZW50V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cgcGF0aCA9IFN0clN1YnN0aXR1dG9yLnJlcGxhY2UoZm9ybWF0RW5kcG9pbnQsIHBhcmFtZXRlcnNNYXAsICJ7IiwifSIpOwotCi0gICAgICAgIEFydGlmYWN0RGVmaW5pdGlvbiBhcnRpZmFjdERlZmluaXRpb24gPSBuZXcgQXJ0aWZhY3REZWZpbml0aW9uKCk7Ci0gICAgICAgIEVpdGhlcjxBcnRpZmFjdERlZmluaXRpb24sIFJlc3BvbnNlRm9ybWF0PiBkZWxldGVBcnRpZmFjdE9uUmlCeVVVSURFaXRoZXIgPSBFaXRoZXIubGVmdChhcnRpZmFjdERlZmluaXRpb24pOwotCi0gICAgICAgIGdpdmVuKGFydGlmYWN0c0J1c2luZXNzTG9naWMuZGVsZXRlQXJ0aWZhY3RPblJpQnlVVUlEKGFueSgpLCBhbnkoKSwgYW55KCksIGFueSgpLAotICAgICAgICAgICAgICAgIGFueSgpLCBhbnkoKSkpCi0gICAgICAgICAgICAgICAgLndpbGxBbnN3ZXIoIGludm9jYXRpb24gLT4gZGVsZXRlQXJ0aWZhY3RPblJpQnlVVUlERWl0aGVyKTsKLQotICAgICAgICBSZXNwb25zZSByZXNwb25zZSA9IHRhcmdldCgpCi0gICAgICAgICAgICAgICAgLnBhdGgocGF0aCkKLSAgICAgICAgICAgICAgICAucmVxdWVzdCgpCi0gICAgICAgICAgICAgICAgLmFjY2VwdChNZWRpYVR5cGUuQVBQTElDQVRJT05fSlNPTikKLSAgICAgICAgICAgICAgICAuaGVhZGVyKENvbnN0YW50cy5YX0VDT01QX0lOU1RBTkNFX0lEX0hFQURFUiwgIm1vY2tYRWNvbXBJbnN0YW5jZUlkIikKLSAgICAgICAgICAgICAgICAuaGVhZGVyKENvbnN0YW50cy5VU0VSX0lEX0hFQURFUiwgZGVzaWduZXJVc2VyLmdldFVzZXJJZCgpKQotICAgICAgICAgICAgICAgIC5kZWxldGUoKTsKLQotICAgICAgICBhc3NlcnRUaGF0KHJlc3BvbnNlLmdldFN0YX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otICAgICAgICAgICAgICAgIC5oZWFkZXIoQ29uc3RhbnRzLlVTRVJfSURfSEVBREVSLCBkZXNpZ25lclVzZXIuZ2V0VXNlcklkKCkpCi0gICAgICAgICAgICAgICAgLmdldCgpOwotCi0gICAgICAgIGFzc2VydFRoYXQocmVzcG9uc2UuZ2V0U3RhdHVzKCkpLmlzRXF1YWxUbyhIdHRwU3RhdHVzLlNDX09LKTsKLSAgICB9Ci0KLSAgICBAT3ZlcnJpZGUKLSAgICBwcm90ZWN0ZWQgQXBwbGljYXRpb24gY29uZmlndXJlKCkgewotICAgICAgICBBcHBsaWNhdGlvbkNvbnRleHQgY29udGV4dCA9IG5ldyBBbm5vdGF0aW9uQ29uZmlnQXBwbGljYXRpb25Db250ZXh0KFNwcmluZ0NvbmZpZy5jbGFzcyk7Ci0gICAgICAgIHJldHVybiBuZXcgUmVzb3VyY2VDb25maWcoQXJ0aWZhY3RFeHRlcm5hbFNlcnZsZXQuY2xhc3MpCi0gICAgICAgICAgICAgICAgLnJlZ2lzdGVyKG5ldyBBYnN0cmFjdEJpbmRlcigpIHsKLQotICAgICAgICAgICAgICAgICAgICBAT3ZlcnJpZGUKLSAgICAgICAgICAgICAgICAgICAgcHJvdGVjdGVkIHZvaWQgY29uZmlndXJlKCkgewotICAgICAgICAgICAgICAgICAgICAgICAgYmluZChyZXF1ZXN0KS50byhIdHRwU2VydmxldFJlcXVlc3QuY2xhc3MpOwotICAgICAgICAgICAgICAgICAgICAgICAgYmluZCh1c2VyQnVzaW5lc3NMb2dpYykudG8oVXNlckJ1c2luZXNzTG9naWMuY2xhc3MpOwotICAgICAgICAgICAgICAgICAgICAgICAgYmluZChjb21wb25lbnRJbnN0YW5jZUJ1c2luZXNzTG9naWMpLnRvKENvbXBvbmVudEluc3RhbmNlQnVzaW5lc3NMb2dpYy5jbGFzcyk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBiaW5kKGNvbXBvbmVudFV0aWxzKS50byhDb21wb25lbnRzVXRpbHMuY2x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W5lc3NMb2dpYy5jbGFzcyk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBiaW5kKGNvbXBvbmVudEluc3RhbmNlQnVzaW5lc3NMb2dpYykudG8oQ29tcG9uZW50SW5zdGFuY2VCdXNpbmVzc0xvZ2ljLmNsYXNzKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGJpbmQoY29tcG9uZW50c1V0aWxzKS50byhDb21wb25lbnRzVXRpbHMuY2xhc3MpOwotICAgICAgICAgICAgICAgICAgICAgICAgYmluZChzZXJ2bGV0VXRpbHMpLnRvKFNlcnZsZXRVdGlscy5jbGFzcyk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBiaW5kKHJlc291cmNlSW1wb3J0TWFuYWdlcikudG8oUmVzb3VyY2VJbXBvcnRNYW5hZ2VyLmNsYXNzKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGJpbmQoZWxlbWVudEJ1c2luZXNzTG9naWMpLnRvKEVsZW1lbnRCdXNpbmVzc0xvZ2ljLmNsYXNzKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGJpbmQoYXNzZXRNZXRhZGF0YUNvbnZlcnRlcikudG8oQXNzZXRNZXRhZGF0YUNvbnZlcnRlci5jbGFzcyk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBiaW5kKGxpZmVjeWNsZUJ1c2luZXNzTG9naWMpLnRvKExpZmVjeWNsZUJ1c2luZXNzTG9naWMuY2xhc3MpOwotICAgICAgICAgICAgICAgICAgICAgICAgYmluZChyZXNvdXJjZUJ1c2luZXNzTG9naWMpLnRvKFJlc291cmNlQnVzaW5lc3NMb2dpYy5jbGFzcyk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBiaW5kKHNlcnZpY2VCdXNpbmVzc0xvZ2ljKS50byhTZXJ2aWNlQnVzaW5lc3NMb2dpYy5jbGFzcyk7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9KQogICAgICAgICAgICAgICAgIC5wcm9wZXJ0eSgi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ZXR1cm4ocmVzcG9uc2VGb3JtYXQpOwogICAgICAgICBkb1Rocm93KGNlKS53aGVuKGFjY2Vzc1ZhbGlkYXRpb25zTW9jaykKLSAgICAgICAgICAgICAgICAgICAudmFsaWRhdGVVc2VyQ2FuV29ya09uQ29tcG9uZW50KGFueSgpLCBlcShvdGhlckRlc2lnbmVyVXNlci5nZXRVc2VySWQoKSksIGFueSgpKTsKKyAgICAgICAgICAgICAgICAudmFsaWRhdGVVc2VyQ2FuV29ya09uQ29tcG9uZW50KGFueSgpLCBhbnkoKSwgZXEob3RoZXJEZXNpZ25lclVzZXIuZ2V0VXNlcklkKCkpLCBhbnkoKSk7CiAgICAgICAgIGRvVGhyb3coY2UpLndoZW4oYWNjZXNzVmFsaWRhdGlvbnNNb2NrKQotICAgICAgICAgICAgICAgICAgIC52YWxpZGF0ZVVzZXJDYW5Xb3JrT25Db21wb25lbnQoYW55KCksIGVxKG90aGVyVXNlci5nZXRVc2VySWQoKSksIGFueSgpKTsKKyAgICAgICAgICAgICAgICAudmFsaWRhdGVVc2VyQ2FuV29ya09uQ29tcG9uZW50KGFueSgpLCBhbnkoKSwgZXEob3RoZXJVc2VyLmdldFVzZXJJZCgpKSwgYW55KCkpOwogCiAgICAgICAgIC8vTmVlZGVkIGZvciBlcnJvciBjb25maWd1cmF0aW9uCiAgICAgICAgIHdoZW4obm90Rm91bmRSZXNwb25zZUZvcm1hdC5nZXRTdGF0dXMoKSkudGhlblJldHVybihIdHRwU3RhdHVzLk5PVF9GT1VORC52YWx1ZSgpKTsKQEAgLTMyOSwxNSArMzM2LDkgQEAKICAgICAgICAgd2hlbihjb21wb25lbnRVdGlscy5nZXRSZXNwb25zZUZvcm1hdChlcShBY3Rpb25TdGF0dXMuQ09NUE9ORU5UX0lOU1RBTkNFX05PVF9GT1VORCksIChTdHJpbmdbXSkgYW55KCkpKS50aGVuUmV0dXJuKG5vdEZvdW5kUmVzcG9uc2VGb3JtYXQpOwogICAgICAgICB3aGVuKGNvbXBv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KSwgZmFsc2UpKS50aGVuUmV0dXJuKGFkbWluVXNlcik7CisgICAgICAgIHdoZW4odXNlckFkbWluLmdldFVzZXIoZGVzaWduZXJVc2VyLmdldFVzZXJJZCgpLCBmYWxzZSkpLnRoZW5SZXR1cm4oZGVzaWduZXJVc2VyKTsKKyAgICAgICAgd2hlbih1c2VyQWRtaW4uZ2V0VXNlcihvdGhlclVzZXIuZ2V0VXNlcklkKCksIGZhbHNlKSkudGhlblJldHVybihvdGhlclVzZXIpOwogICAgICAgICAvLz09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQogCiAgICAgICAgIFN0cmluZyBhcHBDb25maWdEaXIgPSAic3JjL3Rlc3QvcmVzb3VyY2VzL2NvbmZpZyI7CkBAIC0zNDYsNyArMzQ3LDkgQEAKIAogICAgICAgICBvcmcub3BlbmVjb21wLnNkYy5iZS5jb25maWcuQ29uZmlndXJhdGlvbiBjb25maWd1cmF0aW9uID0gbmV3IG9yZy5vcGVuZWNvbXAuc2RjLmJlLmNvbmZpZy5Db25maWd1cmF0aW9uKCk7CiAgICAgICAgIGNvbmZpZ3VyYXRpb24uc2V0SmFudXNHcmFwaEluTWVtb3J5R3JhcGgodHJ1ZSk7Ci0KKyAgICAgICAgb3JnLm9wZW5lY29tcC5zZGMuYmUuY29uZmlnLkNvbmZpZ3VyYXRpb24uSGVhdERlcGxveW1lbnRBcnRpZmFjdFRpbWVvdXQgaGVhdERlcGxveW1lbnRBcnRpZmFjdFRpbWVvdXQgPSBuZXcgb3JnLm9wZW5lY29tcC5zZGMuYmUuY29uZmlnLkNvbmZpZ3VyYXRpb24uSGVhdERlcGxveW1lbnRBcnRpZmFjdFRpbWVvdXQoKTsKKyAgICAgICAgaGVhdERlcGxveW1lbnRBcnRpZmFjdFRpbWVvdXQuc2V0RGVmYXVsdE1pbn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nZpY2VBc3NldERldGFpbGVkTWV0YWRhdGFUZXN0IHsKIApkaWZmIC0tZ2l0IGEvY2F0YWxvZy1iZS9zcmMvdGVzdC9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2ZhY2FkZS9vcGVyYXRpb25zL0ZhY2FkZVVzZXJDYWNoZU9wZXJhdGlvblRlc3QuamF2YSBiL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9mYWNhZGUvb3BlcmF0aW9ucy9GYWNhZGVVc2VyQ2FjaGVPcGVyYXRpb25UZXN0LmphdmEKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uYzE5NDdkNQotLS0gL2Rldi9udWxsCisrKyBiL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9mYWNhZGUvb3BlcmF0aW9ucy9GYWNhZGVVc2VyQ2FjaGVPcGVyYXRpb25UZXN0LmphdmEKQEAgLTAsMCArMSw2MyBAQAorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDIwIEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlI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2FwdG9yLmNhcHR1cmUoKSk7CisgICAgICAgIAorICAgICAgICBVc2VyTWVzc2FnZSBtZXNzYWdlID0gbWVzc2FnZUNhcHRvci5nZXRWYWx1ZSgpOworICAgICAgICAKKyAgICAgICAgYXNzZXJ0VGhhdChtZXNzYWdlLmdldE9wZXJhdGlvbigpKS5pc0VxdWFsVG8oVXNlck9wZXJhdGlvbkVudW0uQ1JFQVRFKTsKKyAgICAgICAgYXNzZXJ0VGhhdChtZXNzYWdlLmdldFVzZXJJZCgpKS5pc0VxdWFsVG8oImlkIik7CisgICAgICAgIGFzc2VydFRoYXQobWVzc2FnZS5nZXRSb2xlKCkpLmlzRXF1YWxUbygicm9sZSIpOworICAgIH0KKworfQpkaWZmIC0tZ2l0IGEvY2F0YWxvZy1iZS9zcmMvdGVzdC9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2ZpbHRlcnMvR2F0ZXdheUZpbHRlclRlc3QuamF2YSBiL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9maWx0ZXJzL0dhdGV3YXlGaWx0ZXJUZXN0LmphdmEKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uN2E1NWJjYgotLS0gL2Rldi9udWxsCisrKyBiL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9maWx0ZXJzL0dhdGV3YXlGaWx0ZXJUZXN0LmphdmEKQEAgLTAsMCArMSwxNTIgQEAKKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAyMCBBVCZUIElud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zOworICAgIEBNb2NrCisgICAgcHJpdmF0ZSBDb25maWd1cmF0aW9uLkNvb2tpZUNvbmZpZyBhdXRoQ29va2llQ29uZjsKKyAgICBATW9jaworICAgIHByaXZhdGUgQ29uZmlndXJhdGlvbiBjb25maWd1cmF0aW9uOworICAgIEBNb2NrCisgICAgcHJpdmF0ZSBIdHRwU2VydmxldFJlcXVlc3QgcmVxdWVzdDsKKyAgICBATW9jaworICAgIHByaXZhdGUgRmlsdGVyQ2hhaW4gZmlsdGVyQ2hhaW47CisgICAgQE1vY2sKKyAgICBwcml2YXRlIEh0dHBTZXJ2bGV0UmVzcG9uc2UgcmVzcG9uc2U7CisgICAgQE1vY2sKKyAgICBwcml2YXRlIENvbXBvbmVudEV4Y2VwdGlvbk1hcHBlciBjb21wb25lbnRFeGNlcHRpb25NYXBwZXI7CisKKworCisgICAgQEJlZm9yZQorICAgIHB1YmxpYyB2b2lkIGluaXRNb2NrcygpeworICAgICAgICBNb2NraXRvQW5ub3RhdGlvbnMuaW5pdE1vY2tzKHRoaXMpOworICAgIH0KKworICAgIEBCZWZvcmUKKyAgICBwdWJsaWMgdm9pZCBzZXRVcCgpIHRocm93cyBTZXJ2bGV0RXhjZXB0aW9uIHsKKyAgICAgICAgZG9Ob3RoaW5nKCkud2hlbih0aHJlYWRMb2NhbFV0aWxzKS5zZXRVc2VyQ29udGV4dEZyb21EQihyZXF1ZXN0KTsKKyAgICAgICAgd2hlbihjb25maWd1cmF0aW9uLmdldEF1dGhDb29raWUoKSkudGhlblJldHVybihhdXRoQ29va2llQ29uZik7CisgICAgICAgIHRoaXMuZmlsdGVyID0gbmV3IEdhdGV3YXlGaWx0ZXIoY29uZmlndXJhdGlvbik7CisgICAgICAgIFRocmVhZExvY2Fsc0hvbGRlci5zZXRBcGlUeXBlKG51bGwpOworICAgICAgICBhc3NlcnROb3ROdWxsKGZpbHRlcik7CisgICAgfQorCisgICAgQFRlc3QKKyAgICBwdWJsaWMgdm9pZCB2YWxpZGF0ZVJlcXVlc3RGcm9tV2hpdGVMaXN0KCkgdGhyb3dzIFNlcnZsZXRFeGNlcHRpb24sIElPRXhjZXB0aW9uIHsKKyAgICAgICAgd2hlbihhdXRoQ29va2llQ29uZi5nZXRFeGNsdWRlZFVybHMoKSkudGhlblJldHVybihleGNsdWRlZFVybHMpOworICAgICAgICB3aGVuKHJlcXVlc3QuZ2V0UGF0aEluZm8oKSkudGhlblJldHVybigidGVzdDEiKTsKKyAgICAgICAgZmlsdGVyLmRvRmlsdGVyKHJlcXVlc3QsIHJlc3BvbnNlLCBmaWx0ZXJDaGFpbik7CisgICAgICAgIGFzc2VydFRydWUoVGhyZWFkTG9jYWxzSG9sZGVyLmdldEFwaVR5cGUoKS5lcXVhbHMoRmlsdGVyRGVjaXNpb25FbnVtLk5BKSk7CisgICAgICAgIE1vY2tpdG8udmVyaWZ5KGZpbHRlckNoYWluLCB0aW1lcygxKSkuZG9GaWx0ZXIocmVxdWVzdCwgcmVzcG9uc2UpOworICAgIH0KKworICAgIHByaXZhdGUgRW51bWVyYXRpb24gZ2V0SGVhZGVyRW51bWVyYXRpb25PYmooTGlzdDxTdHJpbmc+IGFycmxpc3QpeworCisgICAgICAgIC8vIGNyZWF0aW5nIG9iamVjdCBvZiB0eXBlIEVudW1lcmF0aW9uPFN0cmluZz4KKyAgICAgICAgRW51bWVyYXRpb248U3RyaW5nPiBlbnVtZXIgPSBDb2xsZWN0aW9ucy5lbnVtZXJhdGlvbihhcnJsaXN0KTsKKyAgICAgICAgcmV0dXJuIGVudW1lcjsKKyAgICB9CisKKworCisKKworCisgICAgcHJpdmF0ZSBDb29raWVbXSBnZXRDb29raWVzRnJvbVJlcShib29sZWFuIGlzRnJvbVJlcXVlc3QpIHsKKyAgICAgICAgQ29va2llW10gY29va2llcyA9IG5ldyBDb29raWUgWzFdOworICAgICAgICBpZiAoaXNGcm9tUmVxdWVzdCkgeworICAgICAgICAgICAgY29va2llc1swXSA9IG5ldyBDb29raWUoY29va2llTmFtZSwgImNvb2tpZURhdGEiKTsKKyAgICAgICAgfQorICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgIGNvb2tpZXNbMF0gPSBuZXcgQ29va2llKCJkdW1teSIsICJjb29raWVEYXRhIik7CisgICAgICAgIH0KKyAgICAgICAgcmV0dXJuIGNvb2tpZXM7CisgICAgfQorCisgICAgcHJpdmF0ZSBTdHJpbmcgZ2V0Q29va2llTmFtZUZyb21Db25mKGJvb2xlYW4gaXNGcm9tQ29uZmlndXJhdGlvbikgeworICAgICAgICBDb29raWVbXSBjb29raWVzID0gbmV3IENvb2tpZSBbMV07CisgICAgICAgIGlmIChpc0Zyb21Db25maWd1cmF0aW9uKSB7CisgICAgICAgICAgICBjb29raWVzWzBdID0gbmV3IENvb2tpZShjb29raWVOYW1lLCAiY29va2llRGF0YSIpOworICAgICAgICB9CisgICAgICAgIGVsc2UgeworICAgICAgICAgICAgY29va2llc1swXSA9IG5ldyBDb29raWUoImR1bW15IiwgImNvb2tpZURhdGEiKTsKKyAgICAgICAgfQorICAgICAgICByZXR1cm4gY29va2llc1swXS5nZXROYW1lKCk7CisgICAgfQorfQpcIE5vIG5ld2xpbmUgYXQgZW5kIG9mIGZpbGUKZGlmZiAtLWdpdCBhL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9maWx0ZXJzL1JlcVZhbGlkYXRpb25GaWx0ZXJUZXN0LmphdmEgYi9jYXRhbG9nLWJlL3NyYy90ZXN0L2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvZmlsdGVycy9SZXFWYWxpZGF0aW9uRmlsdGVyVGVzdC5qYXZhCm5ldyBmaWxlIG1vZGUgMTAwNjQ0CmluZGV4IDAwMDAwMDAuLjg2NTY1NjAKLS0tIC9kZXYvbnVsbAorKysgYi9jYXRhbG9nLWJlL3NyYy90ZXN0L2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvZmlsdGVycy9SZXFWYWxpZGF0aW9uRmlsdGVyVGVzdC5qYXZhCkBAIC0wLDAgKzEsMTMwIEBACisvKi0KKyAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBTREMKKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBDb3B5cmlnaHQgKEMpIDIwMjAgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7CisgKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCisgKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKKyAqCisgKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAorICoKKyAqIFVubGVzcyByZXF1aXJlZCBieSBhcHBsaWNhYmxlIGxhdyBvciBhZ3JlZWQgdG8gaW4gd3JpdGluZywgc29mdHdhcmUKKyAqIGRpc3RyaWJ1dGVkIHVuZGVyIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1dGVkIG9uIGFuICJBUyBJUyIgQkFTSVMsCisgKiBXSVRIT1VUIFdBUlJBTlRJRVMgT1IgQ09ORElUSU9OUyBPRiBBTlkgS0lORCwgZWl0aGVyIGV4cHJlc3Mgb3IgaW1wbGllZC4KKyAqIFNlZSB0aGUgTGljZW5zZ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KyBiL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9pbXBsL2FhZi9Sb2xlQXV0aG9yaXphdGlvbkhhbmRsZXJUZXN0LmphdmEKQEAgLTAsMCArMSwxMTkgQEAKKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAyMCBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKKyAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KKyAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAorICoKKyAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wCisgKgorICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZQorICogZGlzdHJpYnV0ZWQgdW5kZXIgdGhlIExpY2Vuc2UgaXMgZGlzdHJpYnV0ZWQgb24gYW4gIkFTIElTIiBCQVNJUywKKyAqIFdJVEhPVVQgV0FSUkFOVEl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7CisgICAgICAgIGFzc2VydFRoYXQodGhyb3duLmdldEFjdGlvblN0YXR1cygpKS5pc0VxdWFsVG8oQWN0aW9uU3RhdHVzLkFVVEhfRkFJTEVEKTsKKyAgICB9Cit9CmRpZmYgLS1naXQgYS9jYXRhbG9nLWJlL3NyYy90ZXN0L2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvaW5mby9BcnRpZmFjdEFjY2Vzc0luZm9UZXN0LmphdmEgYi9jYXRhbG9nLWJlL3NyYy90ZXN0L2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvaW5mby9BcnRpZmFjdEFjY2Vzc0luZm9UZXN0LmphdmEKZGVsZXRlZCBmaWxlIG1vZGUgMTAwNjQ0CmluZGV4IDAzZDMwNWIuLjAwMDAwMDAKLS0tIGEvY2F0YWxvZy1iZS9zcmMvdGVzdC9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL2luZm8vQXJ0aWZhY3RBY2Nlc3NJbmZvVGVzdC5qYXZhCisrKyAvZGV2L251bGwKQEAgLTEsNTAgKzAsMCBAQAotLyotCi0gKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogU0RDCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOwotICogeW91IG1heSBub3QgdX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Iik7Ci0gICAgICAgIGFzc2VydFRoYXQoYXJ0aWZhY3RBY2Nlc3NJbmZvLmdldFVybCgpLCBpcygiaHR0cDovL2xvY2FsaG9zdC90ZXN0L3Jlc291cmNlcy9hcnRpZmFjdHMvIikpOwotICAgIH0KLQotfQpcIE5vIG5ld2xpbmUgYXQgZW5kIG9mIGZpbGUKZGlmZiAtLWdpdCBhL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9pbmZvL0FydGlmYWN0QWNjZXNzTGlzdFRlc3QuamF2YSBiL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9pbmZvL0FydGlmYWN0QWNjZXNzTGlzdFRlc3QuamF2YQpkZWxldGVkIGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggYWQ3MzYzNi4uMDAwMDAwMAotLS0gYS9jYXRhbG9nLWJlL3NyYy90ZXN0L2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvaW5mby9BcnRpZmFjdEFjY2Vzc0xpc3RUZXN0LmphdmEKKysrIC9kZXYvbnVsbApAQCAtMSw0NiArMCwwIEBACi0vKi0KLSAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBTREMKLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBDb3B5cmlnaHQgKEMpIDIwMTggQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogTGljZW5zZWQgdW5kZXIgdGhlIEFwY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vb2dsZS5jb2RlLmJlYW5tYXRjaGVycy5CZWFuTWF0Y2hlcnMuaGFzVmFsaWRCZWFuQ29uc3RydWN0b3I7CiBpbXBvcnQgc3RhdGljIG9yZy5oYW1jcmVzdC5NYXRjaGVyQXNzZXJ0LmFzc2VydFRoYXQ7CmRpZmYgLS1naXQgYS9jYXRhbG9nLWJlL3NyYy90ZXN0L2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvbW9uaXRvcmluZy9Fc0dhdGV3YXlUZXN0LmphdmEgYi9jYXRhbG9nLWJlL3NyYy90ZXN0L2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvbW9uaXRvcmluZy9Fc0dhdGV3YXlUZXN0LmphdmEKZGVsZXRlZCBmaWxlIG1vZGUgMTAwNjQ0CmluZGV4IDcxZWUxNGYuLjAwMDAwMDAKLS0tIGEvY2F0YWxvZy1iZS9zcmMvdGVzdC9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL21vbml0b3JpbmcvRXNHYXRld2F5VGVzdC5qYXZhCisrKyAvZGV2L251bGwKQEAgLTEsMTA3ICswLDAgQEAKLS8qLQotICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIFNEQwotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIENvcHlyaWdodCAoQykgMjAxOSBOb2tpYSBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNl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MTgwLDcgKzE5Miw3IEBACiAKICAgICAgICAgQEJlYW4KICAgICAgICAgVG9zY2FPcGVyYXRpb25GYWNhZGUgdG9zY2FPcGVyYXRpb25GYWNhZGUoKSB7Ci0gICAgICAgICAgICByZXR1cm4gbmV3IFRvc2NhT3BlcmF0aW9uRmFjYWRlKCk7CisgICAgICAgICAgICByZXR1cm4gdG9zY2FPcGVyYXRpb25GYWNhZGU7CiAgICAgICAgIH0KIAogICAgICAgICBAQmVhbgpAQCAtMjgxLDcgKzI5Myw3IEBACiAgICAgcHJpdmF0ZSBzdGF0aWMgZmluYWwgVXNlciBhZG1pblVzZXIgPSBuZXcgVXNlcigiYWRtaW4iLCAiYWRtaW4iLCAiYWRtaW4iLCAiYWRtaW5AZW1haWwuY29tIiwgUm9sZS5BRE1JTi5uYW1lKCksIFN5c3RlbS5jdXJyZW50VGltZU1pbGxpcygpKTsKICAgICBwcml2YXRlIHN0YXRpYyBmaW5hbCBVc2VyIGRlc2lnbmVyVXNlciA9IG5ldyBVc2VyKCJkZXNpZ25lciIsICJkZXNpZ25lciIsICJkZXNpZ25lciIsICJkZXNpZ25lckBlbWFpbC5jb20iLCBSb2xlLkRFU0lHTkVSLm5hbWUoKSwgU3lzdGVtCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmN1cnJlbnRUaW1lTWlsbGlzKCkpOwotICAgIHByaXZhdGUgc3RhdGljIGZpbmFsIFVzZXIgb3RoZXJVc2VyID0gbmV3IFVzZXIoIm90aGVyIiwgIm90aGVyIiwgIm90aGVyIiwgIm90aGVyQGVtYWlsLmNvbSIsIFJvbGUuT1BTLm5hbWUoKSwgU3lzdGVtLmN1cnJlbnRUaW1lTWlsbGlzKCkpOworICAgIHByaXZhdGUgc3RhdGljIGZpbmFsIF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Z2V0VXNlcihkZXNpZ25lclVzZXIuZ2V0VXNlcklkKCksIGZhbHNlKSkudGhlblJldHVybihkZXNpZ25lckVpdGhlcik7Ci0gICAgICAgIHdoZW4odXNlckFkbWluLmdldFVzZXIob3RoZXJVc2VyLmdldFVzZXJJZCgpLCBmYWxzZSkpLnRoZW5SZXR1cm4ob3RoZXJFaXRoZXIpOworICAgICAgICB3aGVuKHVzZXJBZG1pbi5nZXRVc2VyKGFkbWluVXNlci5nZXRVc2VySWQoKSwgZmFsc2UpKS50aGVuUmV0dXJuKGFkbWluVXNlcik7CisgICAgICAgIHdoZW4odXNlckFkbWluLmdldFVzZXIoZGVzaWduZXJVc2VyLmdldFVzZXJJZCgpLCBmYWxzZSkpLnRoZW5SZXR1cm4oZGVzaWduZXJVc2VyKTsKKyAgICAgICAgd2hlbih1c2VyQWRtaW4uZ2V0VXNlcihvdGhlclVzZXIuZ2V0VXNlcklkKCksIGZhbHNlKSkudGhlblJldHVybihvdGhlclVzZXIpOwogICAgICAgICAvLz09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQogCi0gICAgICAgIFN0cmluZyBhcHBDb25maWdEaXIgPSAic3JjL3Rlc3QvcmVzb3VyY2VzL2NvbmZpZy9jYXRhbG9nLWJlIjsKKyAgICAgICAgU3RyaW5nIGFwcENvbmZpZ0RpciA9ICJzcmMvdGVzdC9yZXNvdXJjZXMvY29uZmlnIjsKICAgICAgICAgQ29uZmlndXJhdGlvblNvdXJjZSBjb25maWd1cmF0aW9uU291cmNlID0gbmV3IEZTQ29uZmlndXJhdGlvblNvdXJjZShFeHRlcm5hbENvbmZpZ3VyYXRpb24uZ2V0Q2hhbmdlTGlzdGVuZXIoKSwgYXBwQ29uZmlnRGlyKTsKICAgICAgICAgQ29uZmlndXJhdGlvbk1hbmFnZXIgY29uZml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ZWY7CiAgICAgICAgIHdoZW4oY29tcG9uZW50SW5zdGFuY2VCdXNpbmVzc0xvZ2ljCiAgICAgICAgICAgICAgICAgLmRpc3NvY2lhdGVSSUZyb21SSShjb21wb25lbnRJZCwgVVNFUl9JRCwgcmVmLCBDb21wb25lbnRUeXBlRW51bS5maW5kQnlQYXJhbU5hbWUoY29udGFpbmVyQ29tcG9uZW50VHlwZSkpKQogICAgICAgICAgICAgICAgIC50aGVuUmV0dXJuKGFjdGlvblJlc3BvbnNlRWl0aGVyKTsKQEAgLTMxNyw0ICsyOTIsMTQyIEBACiAgICAgICAgIHdoZW4od2ViQXBwbGljYXRpb25Db250ZXh0LmdldEJlYW4oU2VydmxldFV0aWxzLmNsYXNzKSkudGhlblJldHVybihzZXJ2bGV0VXRpbHMpOwogICAgICAgICB3aGVuKHNlcnZsZXRVdGlscy5nZXRDb21wb25lbnRzVXRpbHMoKSkudGhlblJldHVybihjb21wb25lbnRzVXRpbHMpOwogICAgIH0KKworICAgIEBUZXN0CisgICAgcHVibGljIHZvaWQgdGVzdFVwZGF0ZVJlc291cmNlSW5zdGFuY2VQcm9wZXJ0aWVzU3VjY2VzcygpeworCisgICAgICAgIFN0cmluZyBjb250YWluZXJDb21wb25lbnRUeXBlID0gInNlcnZpY2VzIjsKKyAgICAgICAgU3RyaW5nIGNvbXBvbmVudElkID0gImNvbXBvbmVudElkIjsKKyAgICAgICAgU3RyaW5nIHJlc291cmNlSW5zdGFuY2VJZCA9ICJyZXNvdXJjZUluc3RhbmNlSWQiOworICAgICAgICBDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5IFtdIHByb3BlcnRpZXMgPSBuZXcgQ29tcG9uZW50SW5zdGFuY2VQcm9wZXJ0eVsxXTsKKyAgICAgICAgQ29tcG9uZW50SW5zdGFuY2VQcm9wZXJ0eSBwcm9wZXJ0eSA9IG5ldyBDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5KCk7CisgICAgICAgIHByb3BlcnR5LnNldE5hbWUoInByb3BlcnR5Iik7CisgICAgICAgIHByb3BlcnR5LnNldFZhbHVlKCJ2YWx1ZSIpOworICAgICAgICBwcm9wZXJ0eS5zZXRUeXBlKCJTdHJpbmciKTsKKyAgICAgICAgcHJvcGVydGllc1swXSA9IChwcm9wZXJ0eSk7CisgICAgICAgIE9iamVjdE1hcHBlciBtYXBwZXIgPSBuZXcgT2JqZWN0TWFwcGVyKCk7CisgICAgICAgIFN0cmluZyBwcm9wZXJ0eUpzb24gPSBudWxsOworICAgICAgICB0cnkgeworICAgICAgICAgICAgcHJvcGVydHlKc29uID0gbWFwcGVyLndyaXRlVmFsdWVBc1N0cmluZyhwcm9wZXJ0aWVzKTsKKyAgICAgICAgfSBjYXRjaCAoSnNvblByb2Nlc3NpbmdFeGNlcHRpb24gZSkgeworICAgICAgICAgICAgZS5wcmludFN0YWNrVHJhY2UoKTsKKyAgICAgICAgfQorICAgICAgICBTdHJpbmcgcGF0aCA9ICIvdjEvY2F0YWxvZy8iICsgY29udGFpbmVyQ29tcG9uZW50VHlwZSArICIvIiArIGNvbXBvbmVudElkICsgIi9yZXNvdXJjZUluc3RhbmNlIiArICIvIiArCisgICAgICAgICAgICAgICAgcmVzb3VyY2VJbnN0YW5jZUlkICsgIi9wcm9wZXJ0aWVzIjsKKyAgICAgICAgd2hlbihjb21wb25lbnRzVXRpbHMuY29udmVydEpzb25Ub09iamVjdFVzaW5nT2JqZWN0TWFwcGVyKHByb3BlcnR5SnNvbiwgbmV3IFVzZXIoKSwgQ29tcG9uZW50SW5zdGFuY2VQcm9wZXJ0eVtdLmNsYXNzLAorICAgICAgICAgICAgICAgIG51bGwsIENvbXBvbmVudFR5cGVFbnVtLlJFU09VUkNFX0lOU1RBTkNFKSkudGhlblJldHVybihFaXRoZXIubGVmdChwcm9wZXJ0aWVzKSk7CisgICAgICAgIHdoZW4oY29tcG9uZW50SW5zdGFuY2VCdXNpbmVzc0xvZ2ljLmNyZWF0ZU9yVXBkYXRlUHJvcGVydGllc1ZhbH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JZCA9ICJjb21wb25lbnRJZCI7CisgICAgICAgIFN0cmluZyByZXNvdXJjZUluc3RhbmNlSWQgPSAicmVzb3VyY2VJbnN0YW5jZUlkIjsKKyAgICAgICAgQ29tcG9uZW50SW5zdGFuY2VJbnB1dFtdIGlucHV0cyA9IG5ldyBDb21wb25lbnRJbnN0YW5jZUlucHV0WzFdOworICAgICAgICBDb21wb25lbnRJbnN0YW5jZUlucHV0IGlucHV0ID0gbmV3IENvbXBvbmVudEluc3RhbmNlSW5wdXQoKTsKKyAgICAgICAgaW5wdXQuc2V0TmFtZSgiaW5wdXQiKTsKKyAgICAgICAgaW5wdXQuc2V0VmFsdWUoInZhbHVlIik7CisgICAgICAgIGlucHV0LnNldFR5cGUoIlN0cmluZyIpOworICAgICAgICBpbnB1dHNbMF0gPSAoaW5wdXQpOworICAgICAgICBPYmplY3RNYXBwZXIgbWFwcGVyID0gbmV3IE9iamVjdE1hcHBlcigpOworICAgICAgICBTdHJpbmcgaW5wdXRKc29uID0gbnVsbDsKKyAgICAgICAgdHJ5IHsKKyAgICAgICAgICAgIGlucHV0SnNvbiA9IG1hcHBlci53cml0ZVZhbHVlQXNTdHJpbmcoaW5wdXRzKTsKKyAgICAgICAgfSBjYXRjaCAoSnNvblByb2Nlc3NpbmdFeGNlcHRpb24gZSkgeworICAgICAgICAgICAgZS5wcmludFN0YWNrVHJhY2UoKTsKKyAgICAgICAgfQorICAgICAgICBTdHJpbmcgcGF0aCA9ICIvdjEvY2F0YWxvZy8iICsgY29udGFpbmVyQ29tcG9uZW50VHlwZSArICIvIiArIGNvbXBvbmVudElkICsgIi9yZXNvdXJjZUluc3RhbmNlIiArICIvIiArCisgICAgICAgICAgICAgICAgcmVzb3VyY2VJbnN0YW5jZUlkICsgIi9pbnB1dHMiOworICAgICAgICB3aGVuKGNvbXBvbmVudHNVdGlscy5jb252ZXJ0SnNvblRvT2JqZWN0VXNpbmdPYmplY3RNYXBwZXIoaW5wdXRKc29uLCBuZXcgVXNlcigpL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LmdldFN0YXR1cygpKS5pc0VxdWFsVG8oSHR0cFN0YXR1cy5PS18yMDApOworICAgIH0KKworICAgIEBUZXN0CisgICAgcHVibGljIHZvaWQgdGVzdFVwZGF0ZVJlc291cmNlSW5zdGFuY2VQcm9wZXJ0aWVzRmFpbHVyZSgpeworCisgICAgICAgIFN0cmluZyBjb250YWluZXJDb21wb25lbnRUeXBlID0gInNlcnZpY2VzIjsKKyAgICAgICAgU3RyaW5nIGNvbXBvbmVudElkID0gImNvbXBvbmVudElkIjsKKyAgICAgICAgU3RyaW5nIHJlc291cmNlSW5zdGFuY2VJZCA9ICJyZXNvdXJjZUluc3RhbmNlSWQiOworICAgICAgICBDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5IFtdIHByb3BlcnRpZXMgPSBuZXcgQ29tcG9uZW50SW5zdGFuY2VQcm9wZXJ0eVsxXTsKKyAgICAgICAgQ29tcG9uZW50SW5zdGFuY2VQcm9wZXJ0eSBwcm9wZXJ0eSA9IG5ldyBDb21wb25lbnRJbnN0YW5jZVByb3BlcnR5KCk7CisgICAgICAgIHByb3BlcnR5LnNldE5hbWUoInByb3BlcnR5Iik7CisgICAgICAgIHByb3BlcnR5LnNldFZhbHVlKCJ2YWx1ZSIpOworICAgICAgICBwcm9wZXJ0eS5zZXRUeXBlKCJTdHJpbmciKTsKKyAgICAgICAgcHJvcGVydGllc1swXSA9IChwcm9wZXJ0eSk7CisgICAgICAgIE9iamVjdE1hcHBlciBtYXBwZXIgPSBuZXcgT2JqZWN0TWFwcGVyKCk7CisgICAgICAgIFN0cmluZyBwcm9wZXJ0eUpzb24gPSBudWxsOworICAgICAgICB0cnkgeworICAgICAgICAgICAgcHJvcGVydHlKc29uID0gbWFwcGVyLndyaXRlVmFsdWVBc1N0cmluZyhwcm9wZXJ0aWVzKTsKKyAgICAgICAgfSBjYXRjaCAoSnNvblByb2Nlc3NpbmdFeGNlcHRpb24gZSkgeworICAgICAgICAgICAgZS5wcmludFN0YWNrVHJhY2UoKT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lvblN0YXR1cy5SRVNPVVJDRV9OT1RfRk9VTkQpKS50aGVuUmV0dXJuKHJlc3BvbnNlRm9ybWF0KTsKKyAgICAgICAgUmVzcG9uc2UgcmVzcG9uc2UgPSB0YXJnZXQoKQorICAgICAgICAgICAgICAgIC5wYXRoKHBhdGgpCisgICAgICAgICAgICAgICAgLnJlcXVlc3QoTWVkaWFUeXBlLkFQUExJQ0FUSU9OX0pTT04pCisgICAgICAgICAgICAgICAgLmhlYWRlcigiVVNFUl9JRCIsIFVTRVJfSUQpLnBvc3QoRW50aXR5LmVudGl0eShwcm9wZXJ0aWVzLCBNZWRpYVR5cGUuQVBQTElDQVRJT05fSlNPTikpOworICAgICAgICBhc3NlcnRUaGF0KHJlc3BvbnNlLmdldFN0YXR1cygpKS5pc0VxdWFsVG8oSHR0cFN0YXR1cy5OT1RfRk9VTkRfNDA0KTsKKyAgICB9CisKKyAgICBAVGVzdAorICAgIHB1YmxpYyB2b2lkIHRlc3RVcGRhdGVSZXNvdXJjZUluc3RhbmNlSW5wdXRzRmFpbHVyZSgpeworCisgICAgICAgIFN0cmluZyBjb250YWluZXJDb21wb25lbnRUeXBlID0gInNlcnZpY2VzIjsKKyAgICAgICAgU3RyaW5nIGNvbXBvbmVudElkID0gImNvbXBvbmVudElkIjsKKyAgICAgICAgU3RyaW5nIHJlc291cmNlSW5zdGFuY2VJZCA9ICJyZXNvdXJjZUluc3RhbmNlSWQiOworICAgICAgICBDb21wb25lbnRJbnN0YW5jZUlucHV0IFtdIGlucHV0cyA9IG5ldyBDb21wb25lbnRJbnN0YW5jZUlucHV0WzFdOworICAgICAgICBDb21wb25lbnRJbnN0YW5jZUlucHV0IGlucHV0ID0gbmV3IENvbXBvbmVudEluc3RhbmNlSW5wdXQoKTsKKyAgICAgICAgaW5wdXQuc2V0TmFtZSgiaW5wdXQiKTsKKyAgICAgICAgaW5wdXQuc2V0VmFsdWUoInZhbHVlIik7CisgICAgICAgIGlucHV0LnNldFR5cGUoIlN0cmluZyIpOworICAgICAgICBpbnB1dHNbMF0gPSAoaW5wdXQpOworICAgICAgICBPYmplY3RNYXBwZXIgbWFwcGVyID0gbmV3IE9iamVjdE1hcHBlcigpOworICAgICAgICBTdHJpbmcgaW5wdXRKc29uID0gbnVsbDsKKyAgICAgICAgdHJ5IHsKKyAgICAgICAgICAgIGlucHV0SnNvbiA9IG1hcHBlci53cml0ZVZhbHVlQXNTdHJpbmcoaW5wdXRzKTsKKyAgICAgICAgfSBjYXRjaCAoSnNvblByb2Nlc3NpbmdFeGNlcHRpb24gZSkgeworICAgICAgICAgICAgZS5wcmludFN0YWNrVHJhY2UoKTsKKyAgICAgICAgfQorICAgICAgICBTdHJpbmcgcGF0aCA9ICIvdjEvY2F0YWxvZy8iICsgY29udGFpbmVyQ29tcG9uZW50VHlwZSArICIvIiArIGNvbXBvbmVudElkICsgIi9yZXNvdXJjZUluc3RhbmNlIiArICIvIiArCisgICAgICAgICAgICAgICAgcmVzb3VyY2VJbnN0YW5jZUlkICsgIi9pbnB1dHMiOworICAgICAgICB3aGVuKGNvbXBvbmVudHNVdGlscy5jb252ZXJ0SnNvblRvT2JqZWN0VXNpbmdPYmplY3RNYXBwZXIoaW5wdXRKc29uLCBuZXcgVXNlcigpLCBDb21wb25lbnRJbnN0YW5jZUlucHV0W10uY2xhc3MsCisgICAgICAgICAgICAgICAgbnVsbCwgQ29tcG9uZW50VHlwZUVudW0uUkVTT1VSQ0VfSU5TVEFOQ0UpKS50aGVuUmV0dXJuKEVpdGhlci5sZWZ0KGlucHV0cykpOworICAgICAgICB3aGVuKGNvbXBvbmVudEluc3RhbmNlQnVzaW5lc3NMb2dpYy5jcmVhdGVPclVwZGF0ZUluc3RhbmNlSW5wdXRWYWx1ZXMoZXEoQ29tcG9uZW50VHlwZUVudW0uZmluZEJ5UGFyYW1OYW1lKFNFUlZJQ0VfUEFSQU1fTkFNRSkpLAorICAgICAgICAgICAgICAgIGVxKGNvbXBvbmVudElkKSwgZXEocmVzb3VyY2VJbn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L2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9Db25zdW1lclNlcnZsZXRUZXN0LmphdmEgYi9jYXRhbG9nLWJlL3NyYy90ZXN0L2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvQ29uc3VtZXJTZXJ2bGV0VGVzdC5qYXZhCmRlbGV0ZWQgZmlsZSBtb2RlIDEwMDY0NAppbmRleCA2YWExMWE2Li4wMDAwMDAwCi0tLSBhL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9Db25zdW1lclNlcnZsZXRUZXN0LmphdmEKKysrIC9kZXYvbnVsbApAQCAtMSwxMTMgKzAsMCBAQAotLyotCi0gKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogU0RDCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogQ29weXJpZ2h0IChDKSAyMDE5IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOwotICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgotICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0Ci0gKiA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lIDEwMDY0NAppbmRleCA2ZDgyMDg0Li4wMDAwMDAwCi0tLSBhL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9Dc2FyQnVpbGRTZXJ2bGV0VGVzdC5qYXZhCisrKyAvZGV2L251bGwKQEAgLTEsODEgKzAsMCBAQAotLyotCi0gKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogU0RDCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogQ29weXJpZ2h0IChDKSAyMDE5IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOwotICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgotICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0Ci0gKiAKLSAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wCi0gKiAKLSAqIFVubGVzcyByZXF1aXJlZCBieSBhcHBsaWNhYmxlIGxhdyBvciBhZ3JlZWQgdG8gaW4gd3JpdGluZywgc29mdHdhcmUKLSAqIGRpc3RyaWJ1dGVkIHVuZGVyIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1d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wkJU3RyaW5nIHBhdGggPSAiL3YxL3NldHVwL3VpIjsKIAkJd2hlbihlbGVtZW50QnVzaW5lc3NMb2dpYy5nZXRBbGxBcnRpZmFjdFR5cGVzKGRlc2lnbmVyVXNlci5nZXRVc2VySWQoKSkpCiAJCQkJLnRoZW5UaHJvdyhuZXcgUnVudGltZUV4Y2VwdGlvbigiVGVzdCBleGNlcHRpb246IGFydGlmYWN0VHlwZXMiKSk7CiAKZGlmZiAtLWdpdCBhL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9FeGNlcHRpb25IYW5kbGVyRW5kcG9pbnRUZXN0LmphdmEgYi9jYXRhbG9nLWJlL3NyYy90ZXN0L2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvRXhjZXB0aW9uSGFuZGxlckVuZHBvaW50VGVzdC5qYXZhCm5ldyBmaWxlIG1vZGUgMTAwNjQ0CmluZGV4IDAwMDAwMDAuLjA3NDM1YzQKLS0tIC9kZXYvbnVsbAorKysgYi9jYXRhbG9nLWJlL3NyYy90ZXN0L2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvRXhjZXB0aW9uSGFuZGxlckVuZHBvaW50VGVzdC5qYXZhCkBAIC0wLDAgKzEsNzcgQEAKKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAyMCBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT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worICAgIHByaXZhdGUgc3RhdGljIENvbXBvbmVudHNVdGlscyBjb21wb25lbnRVdGlsczsKKworICAgIEBvcmcuc3ByaW5nZnJhbWV3b3JrLmNvbnRleHQuYW5ub3RhdGlvbi5Db25maWd1cmF0aW9uCisgICAgQEltcG9ydChCYXNlVGVzdENvbmZpZy5jbGFzcykKKyAgICBzdGF0aWMgY2xhc3MgRXhjZXB0aW9uSGFuZGxlckNvbmZpZyB7CisKKyAgICAgICAgQEJlYW4KKyAgICAgICAgRXhjZXB0aW9uSGFuZGxlckVuZHBvaW50IGV4Y2VwdGlvbkhhbmRsZXJFbmRwb2ludCgpIHsKKyAgICAgICAgICAgIHJldHVybiBuZXcgRXhjZXB0aW9uSGFuZGxlckVuZHBvaW50KGNvbXBvbmVudFV0aWxzKTsKKyAgICAgICAgfQorICAgIH0KKworICAgIEBPdmVycmlkZQorICAgIHByb3RlY3RlZCB2b2lkIGNvbmZpZ3VyZUNsaWVudChDbGllbnRDb25maWcgY29uZmlnKSB7CisgICAgICAgIGZpbmFsIEphY2tzb25Kc29uUHJvdmlkZXIgamFja3Nvbkpzb25Qcm92aWRlciA9IG5ldyBKYWNrc29uSmF4Ykpzb25Qcm92aWRlcigpCisgICAgICAgICAgICAgICAgLmNvbmZpZ3VyZShEZXNlcmlhbGl6YXRpb25GZWF0dXJlLkZBSUxfT05fVU5LTk9XTl9QUk9QRVJUSUVTLCBmYWxzZSk7CisgICAgICAgIGNvbmZpZy5yZWdpc3RlcihqYWNrc29uSnNvblByb3ZpZGVyKTsKKyAgICB9CisKKyAgICBAT3ZlcnJpZGUKKyAgICBwcm90ZWN0ZWQgUmVzb3VyY2VDb25maWcgY29uZmlndXJlKCkgeworICAgICAgICBjb21wb25lbnRVdGlscyA9IG1vY2soQ29tcG9uZW50c1V0aWxzLmNsYXNzKTsKKworICAgICAgICByZXR1cm4gc3VwZXIuY29uZmlndXJlKEV4Y2VwdGlvbkhhbmRsZXJDb25maWcuY2xhc3MpCisgICAgICAgIC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WdlciA9IG5ldyBDb25maWd1cmF0aW9uTWFuYWdlcihjb25maWd1cmF0aW9uU291cmNlKTsKKwogICAgIEBCZWZvcmVDbGFzcwogICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBjb25maWd1cmVNb2NrcygpIHsKICAgICAgICAgcmVxdWVzdCA9IG1vY2soSHR0cFNlcnZsZXRSZXF1ZXN0LmNsYXNzKTsKQEAgLTEyMCw2ICsxMzYsOCBAQAogICAgICAgICBjb21wb25lbnRzVXRpbHMgPSBtb2NrKENvbXBvbmVudHNVdGlscy5jbGFzcyk7CiAgICAgICAgIHNlcnZsZXRVdGlscyA9IG1vY2soU2VydmxldFV0aWxzLmNsYXNzKTsKICAgICAgICAgcmVzb3VyY2VJbXBvcnRNYW5hZ2VyID0gbW9jayhSZXNvdXJjZUltcG9ydE1hbmFnZXIuY2xhc3MpOworCisKICAgICB9CiAKICAgICBAQmVmb3JlCkBAIC0xNTIsNiArMTcwLDcgQEAKICAgICAgICAgICAgIHNlcnZsZXRVdGlscywgcmVzb3VyY2VJbXBvcnRNYW5hZ2VyLCBkYXRhVHlwZUJ1c2luZXNzTG9naWMpOwogICAgICAgICBSZXNvdXJjZUNvbmZpZyByZXNvdXJjZUNvbmZpZyA9IG5ldyBSZXNvdXJjZUNvbmZpZygpCiAgICAgICAgICAgICAucmVnaXN0ZXIoaW5wdXRzU2VydmxldCkKKyAgICAgICAgICAgIC5yZWdpc3RlcihuZXcgQ29tcG9uZW50RXhjZXB0aW9uTWFwcGVyKGNvbXBvbmVudHNVdGlscykpCiAgICAgICAgICAgICAucmVnaXN0ZXIobmV3IEFic3RyYWN0QmluZGVyKCkgewogICAgICAgICAgICAgICAgIEBPdmVycmlkZQogICAgICAgICAgICAgICAgIHByb3RlY3RlZCB2b2lkIGNvbmZpZ3VyZSgpIHsKQEAgLTE2NCw2ICsxODMsOSBAQAogICAgICAgICByZXR1cm4gcmVzb3VyY2VDb25maWc7CiAgICAgfQogCisKKworCiAgICAgcHJpdmF0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TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIFNEQwotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIENvcHlyaWdodCAoQykgMjAxOSBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKLSAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KLSAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAotICogCi0gKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAotICogCi0gKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlCi0gKiBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0cmlidXRlZCBvbiBhbiAiQVMgSVMiIEJBU0lTLAotICogV0lUSE9VVCBXQVJSQU5USUVTIE9SIENPTkRJVElPTlMgT0YgQU5ZIEtJTkQsIGVpdGhlciBleHByZXNzIG9yIGltcGxpZWQuCi0gKiBTZWUgdGhlIExpY2Vuc2UgZm9yIHRoZSBzcGVjaWZpYyBsYW5ndWFnZSBnb3Zlcm5pbmcgcGVybWlzc2lvbnMgYW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gICAgICAgICAgICAgLnJlZ2lzdGVyKG5ldyBQb2xpY3lUeXBlc0VuZHBvaW50KHVzZXJCdXNpbmVzc0xvZ2ljLCBjb21wb25lbnRzVXRpbHMsIHBvbGljeVR5cGVCdXNpbmVzc0xvZ2ljKSk7CiAgICAgfQogCiAgICAgQFRlc3QKZGlmZiAtLWdpdCBhL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9Qcm9kdWN0U2VydmxldFRlc3QuamF2YSBiL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9iZS9zZXJ2bGV0cy9Qcm9kdWN0U2VydmxldFRlc3QuamF2YQpkZWxldGVkIGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMzUyYzc2YS4uMDAwMDAwMAotLS0gYS9jYXRhbG9nLWJlL3NyYy90ZXN0L2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvUHJvZHVjdFNlcnZsZXRUZXN0LmphdmEKKysrIC9kZXYvbnVsbApAQCAtMSwxMjMgKzAsMCBAQAotLyotCi0gKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogU0RDCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogQ29weXJpZ2h0IChDKSAyMDE5IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2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PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogU0RDCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogQ29weXJpZ2h0IChDKSAyMDE5IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOwotICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgotICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0Ci0gKiAKLSAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wCi0gKiAKLSAqIFVubGVzcyByZXF1aXJlZCBieSBhcHBsaWNhYmxlIGxhdyBvciBhZ3JlZWQgdG8gaW4gd3JpdGluZywgc29mdHdhcmUKLSAqIGRpc3RyaWJ1dGVkIHVuZGVyIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1dGVkIG9uIGFuICJBUyBJUyIgQkFTSVMsCi0gKiBXSVRIT1VUIFdBUlJBTlRJRVMgT1IgQ09ORElUSU9OUyBPRiBBTlkgS0lORCwgZWl0aGVyIGV4cHJlc3Mgb3IgaW1wbGllZC4KLSAqIFNlZSB0aGUgTGljZW5zZSBmb3IgdGhlIHNwZWNpZmljIGxhbmd1YWdlIGdvdmVybmluZyBwZXJtaXNzaW9ucyBhbmQKLSAqIGxpbWl0YXRpb25zIHVuZGVyI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2VBcnRpZmFjdERvd25sb2FkU2VydmxldFRlc3QuamF2YQorKysgL2Rldi9udWxsCkBAIC0xLDg3ICswLDAgQEAKLS8qLQotICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIFNEQwotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIENvcHlyaWdodCAoQykgMjAxOSBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKLSAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KLSAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAotICogCi0gKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAotICogCi0gKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlCi0gKiBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0cmlidXRlZCBvbiBhbiAiQVMgSVMiIEJBU0lTLAotICogV0lUSE9VVCBXQVJSQU5USUVTIE9SIENPTkRJVElPTlMgT0YgQU5ZIEtJTkQsIGVpdGhlciBleHByZXNzIG9yIGltcGx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GFzdGVkIHRvIGhlcmUgZnJvbSBzZXR1cCgpIGJlY2F1c2UKLSAgICAgICAgICAgICAgICAgICAgICAgIC8vIGR1ZSB0byBpdCBub3cgaGFzCi0gICAgICAgICAgICAgICAgICAgICAgICAvLyB0byBiZSBleGVjdXRlZCBkdXJpbmcgc2VydmxldCBpbml0aWFsaXphdGlvbgotICAgICAgICAgICAgICAgICAgICAgICAgYmluZChyZXF1ZXN0KS50byhIdHRwU2VydmxldFJlcXVlc3QuY2xhc3MpOwotICAgICAgICAgICAgICAgICAgICAgICAgd2hlbihyZXF1ZXN0LmdldFNlc3Npb24oKSkudGhlblJldHVybihzZXNzaW9uKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIHdoZW4oc2Vzc2lvbi5nZXRTZXJ2bGV0Q29udGV4dCgpKS50aGVuUmV0dXJuKHNlcnZsZXRDb250ZXh0KTsKLSAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZyBhcHBDb25maWdEaXIgPSAic3JjL3Rlc3QvcmVzb3VyY2VzL2NvbmZpZy9jYXRhbG9nLWJlIjsKLSAgICAgICAgICAgICAgICAgICAgICAgIENvbmZpZ3VyYXRpb25Tb3VyY2UgY29uZmlndXJhdGlvblNvdXJjZSA9IG5ldyBGU0NvbmZpZ3VyYXRpb25Tb3VyY2UoRXh0ZXJuYWxDb25maWd1cmF0aW9uLmdldENoYW5nZUxpc3RlbmVyKCksIGFwcENvbmZpZ0Rpcik7Ci0gICAgICAgICAgICAgICAgICAgICAgICBDb25maWd1cmF0aW9uTWFuYWdlciBjb25maWd1cmF0aW9uTWFuYWdlciA9IG5ldyBDb25maWd1cmF0aW9uTWFuYWdlcihjb25maWd1cmF0aW9uU291cmNlKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoU3RyaW5nIG1hbmRhdG9yeUhlYWRlciA6IGNvbmZpZ3VyYXRpb25NYW5hZ2VyLmdldENvbmZpZ3VyYXRpb24oKS5nZXRJZGVudGlmaWNhdGlvbkhlYWR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9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2JlL3NlcnZsZXRzL1NlcnZpY2VTZXJ2bGV0VGVzdC5qYXZhCisrKyAvZGV2L251bGwKQEAgLTEsMzAwICswLDAgQEAKLS8qLQotICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIFNEQwotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIENvcHlyaWdodCAoQykgMjAxOSBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKLSAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KLSAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAotICogCi0gKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAotICogCi0gKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlCi0gKiBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0cmlidXRlZCBvbiBhbiAiQVMgSVMiIEJBU0lTLAotICogV0lUSE9VVCBXQVJSQU5USUVTIE9SIENPTkRJVElPTlMgT0YgQ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W5lY29tcC9zZGMvYmUvc2VydmxldHMvVXNlckFkbWluU2VydmxldFRlc3QuamF2YQpkZWxldGVkIGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggYWYwODk5Mi4uMDAwMDAwMAotLS0gYS9jYXRhbG9nLWJlL3NyYy90ZXN0L2phdmEvb3JnL29wZW5lY29tcC9zZGMvYmUvc2VydmxldHMvVXNlckFkbWluU2VydmxldFRlc3QuamF2YQorKysgL2Rldi9udWxsCkBAIC0xLDEyMiArMCwwIEBACi0vKi0KLSAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBTREMKLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBDb3B5cmlnaHQgKEMpIDIwMTcgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7Ci0gKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCi0gKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKLSAqIAotICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKLSAqIAotICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5n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bGV0cy9Vc2VyRW5kcG9pbnRUZXN0LmphdmEKQEAgLTAsMCArMSwyNDQgQEAKKy8qLQorICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIFNEQworICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIENvcHlyaWdodCAoQykgMjAyMCBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKKyAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS4KKyAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdAorICoKKyAqICAgICAgaHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4wCisgKgorICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZQorICogZGlzdHJpYnV0ZWQgdW5kZXIgdGhlIExpY2Vuc2UgaXMgZGlzdHJpYnV0ZWQgb24gYW4gIkFTIElTIiBCQVNJUywKKyAqIFdJVEhPVVQgV0FSUkFOVElFUyBPUiBDT05ESVRJT05TIE9GIEFOWSBLSU5ELCBlaXRoZXIgZXhwcmVzcyBvciBpbXBsaWVkLgorICogU2VlIHRoZSB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nZnJhbWV3b3JrLmNvbnRleHQuYW5ub3RhdGlvbi5Db25maWd1cmF0aW9uCisgICAgQEltcG9ydChCYXNlVGVzdENvbmZpZy5jbGFzcykKKyAgICBzdGF0aWMgY2xhc3MgVXNlclRlc3RDb25maWcgeworCisgICAgICAgIEBCZWFuCisgICAgICAgIFVzZXJBZG1pblNlcnZsZXQgdXNlckVuZHBvaW50KCkgeworICAgICAgICAgICAgQ29tcG9uZW50c1V0aWxzIGNvbXBvbmVudHNVdGlscyA9IG1vY2soQ29tcG9uZW50c1V0aWxzLmNsYXNzKTsKKyAgICAgICAgICAgIHJldHVybiBuZXcgVXNlckFkbWluU2VydmxldCh1c2VyQnVzaW5lc3NMb2dpYygpLCBjb21wb25lbnRzVXRpbHMsIHVzZXJCdXNpbmVzc0xvZ2ljRXh0KCkpOworICAgICAgICB9CisKKyAgICAgICAgQEJlYW4KKyAgICAgICAgVXNlckJ1c2luZXNzTG9naWMgdXNlckJ1c2luZXNzTG9naWMoKSB7CisgICAgICAgICAgICByZXR1cm4gbmV3IFVzZXJCdXNpbmVzc0xvZ2ljKHVzZXJBZG1pbk9wZXJhdGlvbigpLCBjb21wb25lbnRVdGlscywgZmFjYWRlVXNlck9wZXJhdGlvbik7CisgICAgICAgIH0KKworICAgICAgICBAQmVhbgorICAgICAgICBVc2VyQnVzaW5lc3NMb2dpY0V4dCB1c2VyQnVzaW5lc3NMb2dpY0V4dCgpIHsKKyAgICAgICAgICAgIHJldHVybiBuZXcgVXNlckJ1c2luZXNzTG9naWNFeHQodXNlckJ1c2luZXNzTG9naWMoKSwgdXNlckFkbWluT3BlcmF0aW9uKCksIGxpZmVjeWNsZUJ1c2luZXNzTG9naWMsIGNvbXBvbmVudFV0aWxzKTsKKyAgICAgICAgfQorCisgICAgICAgIEBCZWFuCisgICAgICAgIFVzZXJBZG1pbk9wZXJhdGlvbiB1c2VyQWRtaW5PcGVyYXRpb24oKSB7CisgICAgICAgICAgICByZXR1cm4gbmV3IFVzZXJBZG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ZW5lY29tcC9zZGMvYmUvdG9nZ2x6L0Nhc3NhbmRyYUN1c3RvbVN0YXRlUmVwb3NpdG9yeVRlc3QuamF2YQpAQCAtMCwwICsxLDE0NSBAQAorLyotCisgKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogU0RDCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogQ29weXJpZ2h0IChDKSAyMDIwIEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOworICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgorICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0CisgKgorICogICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKKyAqCisgKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlCisgKiBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0cmlidXRlZCBvbiBhbiAiQVMgSVMiIEJBU0lTLAorICogV0lUSE9VVCBXQVJSQU5USUVTIE9SIENPTkRJVElPTlMgT0YgQU5ZIEtJTkQsIGVpdGhlciBleHByZXN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b3BlbmVjb21wL3NkYy9iZS91c2VyL1VzZXJCdXNpbmVzc0xvZ2ljRXh0VGVzdC5qYXZhCkBAIC0wLDAgKzEsMzExIEBACisvKi0KKyAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBTREMKKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiBDb3B5cmlnaHQgKEMpIDIwMjAgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCisgKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7CisgKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCisgKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKKyAqCisgKiAgICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAorICoKKyAqIFVubGVzcyByZXF1aXJlZCBieSBhcHBsaWNhYmxlIGxhdyBvciBhZ3JlZWQgdG8gaW4gd3JpdGluZywgc29mdHdhcmUKKyAqIGRpc3RyaWJ1dGVkIHVuZGVyIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1dGVkIG9uIGFuICJBUyBJUyIgQkFTSVMsCisgKiBXSVRIT1VUIFdBUlJBTlRJRVMgT1IgQ09ORElUSU9OUyBPRiBBTlkgS0lORCwgZWl0aGVy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YWlsVG9DaGVja0luX3Nob3VsZEZhaWwoKSB7CisgICAgICAgIFVzZXIgbW9kaWZpZXIgPSBuZXcgVXNlcigpOworICAgICAgICBtb2RpZmllci5zZXRVc2VySWQoTU9DS19NT0RJRklFUik7CisgICAgICAgIG1vZGlmaWVyLnNldFJvbGUoVXNlclJvbGVFbnVtLkFETUlOLmdldE5hbWUoKSk7CisgICAgICAgIFN0cmluZyB1c2VyVW5pcXVlSWRUb0RlYWN0aXZhdGUgPSAibW9ja0RVIjsKKyAgICAgICAgVXNlciBkZWFjVXNlciA9IG5ldyBVc2VyKCk7CisgICAgICAgIGRlYWNVc2VyLnNldFN0YXR1cyhVc2VyU3RhdHVzRW51bS5BQ1RJVkUpOworICAgICAgICBkZWFjVXNlci5zZXRSb2xlKFVzZXJSb2xlRW51bS5ERVNJR05FUi5uYW1lKCkpOworCisgICAgICAgIHdoZW4odXNlckFkbWluT3BlcmF0aW9uLmdldFVzZXJEYXRhKE1PQ0tfTU9ESUZJRVIsIGZhbHNlKSkudGhlblJldHVybihFaXRoZXIubGVmdChtb2RpZmllcikpOworICAgICAgICB3aGVuKHVzZXJBZG1pbk9wZXJhdGlvbi5nZXRVc2VyRGF0YSgibW9ja0RVIiwgZmFsc2UpKS50aGVuUmV0dXJuKEVpdGhlci5sZWZ0KGRlYWNVc2VyKSk7CisgICAgICAgIExpc3Q8Q29tcG9uZW50PiBjb21wb25lbnRzID0gbmV3IEFycmF5TGlzdDw+KCk7CisgICAgICAgIENvbXBvbmVudCBjb21wb25lbnRDaGVja2VkT3V0ID0gY3JlYXRlQ29tcG9uZW50KElEMSwgTGlmZWN5Y2xlU3RhdGVFbnVtLk5PVF9DRVJUSUZJRURfQ0hFQ0tPVVQpOworICAgICAgICBjb21wb25lbnRzLmFkZChjb21wb25lbnRDaGVja2VkT3V0KTsKKyAgICAgICAgd2hlbih1c2VyQWRtaW5PcGVyYXRpb24uZ2V0VXNlckFjdGl2ZUNvbXBvbmVudHMoYW55KCksIGFueSg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LCBpdGVyYWJsZV9lbGVtZW50KTsKLQkJfQotCX0KKyAgICAgICAgICAgIGFzc2VydFRoYXQodGVzdFN1YmplY3QuaGFzQWN0aXZlVXNlcihudWxsKSkuaXNGYWxzZSgpOworICAgICAgICB9IGZpbmFsbHkgeworICAgICAgICAgICAgVGhyZWFkTG9jYWxzSG9sZGVyLnNldFVzZXJDb250ZXh0KG9yaWdpbmFsVXNlckNvbnRleHQpOworICAgICAgICB9CisgICAgfQogfQpkaWZmIC0tZ2l0IGEvY2F0YWxvZy1iZS9zcmMvdGVzdC9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2NvbW1vbi90cmFuc2FjdGlvbi9pbXBsL0VTQWN0aW9uVGVzdC5qYXZhIGIvY2F0YWxvZy1iZS9zcmMvdGVzdC9qYXZhL29yZy9vcGVuZWNvbXAvc2RjL2NvbW1vbi90cmFuc2FjdGlvbi9pbXBsL0VTQWN0aW9uVGVzdC5qYXZhCmRlbGV0ZWQgZmlsZSBtb2RlIDEwMDY0NAppbmRleCBhNWVhN2MzLi4wMDAwMDAwCi0tLSBhL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9jb21tb24vdHJhbnNhY3Rpb24vaW1wbC9FU0FjdGlvblRlc3QuamF2YQorKysgL2Rldi9udWxsCkBAIC0xLDQ5ICswLDAgQEAKLS8qLQotICogPT09PT09PT09PT09TElDRU5TRV9TVEFSVD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIFNEQwotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIENvcHlyaWdodCAoQykgMjAxOSBBVCZUIEludGVsbGVjdHVhbCBQcm9wZXJ0eS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09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UkVNT1ZFX0FSVElGQUNUKTs7Ci0JCURCQWN0aW9uQ29kZUVudW0gcmVzdWx0OwotCi0JCS8vIGRlZmF1bHQgdGVzdAotCQlyZXN1bHQgPSB0ZXN0U3ViamVjdC5kb0FjdGlvbigpOwotCX0KLX0KZGlmZiAtLWdpdCBhL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9jb21tb24vdHJhbnNhY3Rpb24vaW1wbC9FU1JvbGxiYWNrSGFuZGxlclRlc3QuamF2YSBiL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9jb21tb24vdHJhbnNhY3Rpb24vaW1wbC9FU1JvbGxiYWNrSGFuZGxlclRlc3QuamF2YQpkZWxldGVkIGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggZGU4NWI1Yy4uMDAwMDAwMAotLS0gYS9jYXRhbG9nLWJlL3NyYy90ZXN0L2phdmEvb3JnL29wZW5lY29tcC9zZGMvY29tbW9uL3RyYW5zYWN0aW9uL2ltcGwvRVNSb2xsYmFja0hhbmRsZXJUZXN0LmphdmEKKysrIC9kZXYvbnVsbApAQCAtMSwxMTcgKzAsMCBAQAotLyotCi0gKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogU0RDCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogQ29weXJpZ2h0IChDKSAyMDE5IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIExpY2Vuc2VkIHVuZGVy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b24vbW5nci9Sb2xsYmFja01hbmFnZXJUZXN0LmphdmEgYi9jYXRhbG9nLWJlL3NyYy90ZXN0L2phdmEvb3JnL29wZW5lY29tcC9zZGMvY29tbW9uL3RyYW5zYWN0aW9uL21uZ3IvUm9sbGJhY2tNYW5hZ2VyVGVzdC5qYXZhCmRlbGV0ZWQgZmlsZSBtb2RlIDEwMDY0NAppbmRleCA5MDliYTY0Li4wMDAwMDAwCi0tLSBhL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9jb21tb24vdHJhbnNhY3Rpb24vbW5nci9Sb2xsYmFja01hbmFnZXJUZXN0LmphdmEKKysrIC9kZXYvbnVsbApAQCAtMSw2NSArMCwwIEBACi0vKi0KLSAqID09PT09PT09PT09PUxJQ0VOU0VfU1RBUlQ9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBTREMKLSAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0gKiBDb3B5cmlnaHQgKEMpIDIwMTkgQVQmVCBJbnRlbGxlY3R1YWwgUHJvcGVydHkuIEFsbCByaWdodHMgcmVzZXJ2ZWQuCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlICJMaWNlbnNlIik7Ci0gKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCi0gKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKLSAqIAotICogICAgICBodHRwOi8vd3d3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CX0KLX0KZGlmZiAtLWdpdCBhL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9jb21tb24vdHJhbnNhY3Rpb24vbW5nci9TZG5jVHJhbnNhY3Rpb25UZXN0LmphdmEgYi9jYXRhbG9nLWJlL3NyYy90ZXN0L2phdmEvb3JnL29wZW5lY29tcC9zZGMvY29tbW9uL3RyYW5zYWN0aW9uL21uZ3IvU2RuY1RyYW5zYWN0aW9uVGVzdC5qYXZhCmRlbGV0ZWQgZmlsZSBtb2RlIDEwMDY0NAppbmRleCBmOTAyZjUyLi4wMDAwMDAwCi0tLSBhL2NhdGFsb2ctYmUvc3JjL3Rlc3QvamF2YS9vcmcvb3BlbmVjb21wL3NkYy9jb21tb24vdHJhbnNhY3Rpb24vbW5nci9TZG5jVHJhbnNhY3Rpb25UZXN0LmphdmEKKysrIC9kZXYvbnVsbApAQCAtMSw0MTAgKzAsMCBAQAotLyotCi0gKiA9PT09PT09PT09PT1MSUNFTlNFX1NUQVJUPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogU0RDCi0gKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotICogQ29weXJpZ2h0IChDKSAyMDE3IEFUJlQgSW50ZWxsZWN0dWFsIFByb3BlcnR5LiBBbGwgcmlnaHRzIHJlc2VydmVkLgotICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLSAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOwotICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaW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GVydGllcworamFudXNHcmFwaEluTWVtb3J5R3JhcGg6IGZhbHNlCitqYW51c0dyYXBoTG9ja1RpbWVvdXQ6IDE4MDAKKworIyBUaGUgaW50ZXJ2YWwgdG8gdHJ5IGFuZCByZWNvbm5lY3QgdG8gamFudXNHcmFwaCBEQiB3aGVuIGl0IGlzIGRvd24gZHVyaW5nIEFTREMgc3RhcnR1cDoKK2phbnVzR3JhcGhSZWNvbm5lY3RJbnRlcnZhbEluU2Vjb25kczogMworCisjIFRoZSByZWFkIHRpbWVvdXQgdG93YXJkcyBUaXRhbiBEQiB3aGVuIGhlYWx0aCBjaGVjayBpcyBpbnZva2VkOgoramFudXNHcmFwaEhlYWx0aENoZWNrUmVhZFRpbWVvdXQ6IDEKKwordWViSGVhbHRoQ2hlY2tSZWNvbm5lY3RJbnRlcnZhbEluU2Vjb25kczogMTUKK3VlYkhlYWx0aENoZWNrUmVhZFRpbWVvdXQ6IDQKKworIyBQcm90b2NvbHMKK3Byb3RvY29sczoKKyAgIC0gaHR0cAorICAgLSBodHRwcworCisjIERlZmF1bHQgaW1wb3J0cworZGVmYXVsdEltcG9ydHM6CisgICAtIG5vZGVzOgorICAgICAgICBmaWxlOiBub2Rlcy55bWwKKyAgIC0gZGF0YXR5cGVzOgorICAgICAgICBmaWxlOiBkYXRhLnltbAorICAgLSBjYXBhYmlsaXRpZXM6CisgICAgICAgIGZpbGU6IGNhcGFiaWxpdGllcy55bWwKKyAgIC0gcmVsYXRpb25zaGlwczoKKyAgICAgICAgZmlsZTogcmVsYXRpb25zaGlwcy55bWwKKyAgIC0gZ3JvdXBzOgorICAgICAgICBmaWxlOiBncm91cHMueW1sCisgICAtIHBvbGljaWVzOgorICAgICAgICBmaWxlOiBwb2xpY2llcy55bWwKKworIyBVc2VycwordXNlcnM6CisgICAgdG9tOiBwYXNzd2QKKyAgICBib2I6IHBhc3N3ZAorCituZW80ajoKKyAgICBob3N0OiBuZW80amhvc3QKKyAgICBwb3J0OiA3NDc0CisgICAg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bHRzCisgICAgICB0eXBlOiBPVEhFUgorICBkZXBsb3ltZW50Vm90aW5nUmVjb3JkOgorICAgICAgZGlzcGxheU5hbWU6IERlcGxveW1lbnQgVm90aW5nIFJlY29yZAorICAgICAgdHlwZTogT1RIRVIKKyAgc2VydmljZVF1ZXN0aW9ubmFpcmU6CisgICAgICBkaXNwbGF5TmFtZTogU2VydmljZSBRdWVzdGlvbm5haXJlCisgICAgICB0eXBlOiBPVEhFUgorICBzZXJ2aWNlU2VjdXJpdHlUZW1wbGF0ZToKKyAgICAgIGRpc3BsYXlOYW1lOiBTZXJ2aWNlIFNlY3VyaXR5IFRlbXBsYXRlCisgICAgICB0eXBlOiBPVEhFUgorCitzZXJ2aWNlQXBpQXJ0aWZhY3RzOgorICBjb25maWd1cmF0aW9uOgorICAgICAgZGlzcGxheU5hbWU6IENvbmZpZ3VyYXRpb24KKyAgICAgIHR5cGU6IE9USEVSCisgIGluc3RhbnRpYXRpb246CisgICAgICBkaXNwbGF5TmFtZTogSW5zdGFudGlhdGlvbgorICAgICAgdHlwZTogT1RIRVIKKyAgbW9uaXRvcmluZzoKKyAgICAgIGRpc3BsYXlOYW1lOiBNb25pdG9yaW5nCisgICAgICB0eXBlOiBPVEhFUgorICByZXBvcnRpbmc6CisgICAgICBkaXNwbGF5TmFtZTogUmVwb3J0aW5nCisgICAgICB0eXBlOiBPVEhFUgorICBsb2dnaW5nOgorICAgICAgZGlzcGxheU5hbWU6IExvZ2dpbmcKKyAgICAgIHR5cGU6IE9USEVSCisgIHRlc3Rpbmc6CisgICAgICBkaXNwbGF5TmFtZTogVGVzdGluZworICAgICAgdHlwZTogT1RIRVIKKworYWRkaXRpb25hbEluZm9ybWF0aW9uTWF4TnVtYmVyT2ZLZXlzOiA1MAorCitzeXN0ZW1Nb25pdG9yaW5nOgorICAgIGVuYWJsZWQ6IGZhbHNlCisgICAgaXNQcm94eTogZmFsc2UKKyAgICBwcm9iZUludGVydmFsSW5TZWNvbmRzOiAxNQorCitoZWF0QXJ0aWZhY3REZXBsb3ltZW50VGltZW91dDoKKyAgZGVmYXVsdE1pbnV0ZXM6IDMwCisgIG1pbk1pbnV0ZXM6IDEKKyAgbWF4TWludXRlczogMTIwCisKK3NlcnZpY2VEZXBsb3ltZW50QXJ0aWZhY3RzOgorICAgIFlBTkdfWE1MOgorICAgICAgICBhY2NlcHRlZFR5cGVzOgorICAgICAgICAgICAgLSB4bWwKKyAgICBWTkZfQ0FUQUxPRzoKKyAgICAgICAgYWNjZXB0ZWRUeXBlczoKKyAgICAgICAgICAgIC0geG1sCisgICAgTU9ERUxfSU5WRU5UT1JZX1BST0ZJTEU6CisgICAgICAgIGFjY2VwdGVkVHlwZXM6CisgICAgICAgICAgICAtIHhtbAorICAgIE1PREVMX1FVRVJZX1NQRUM6CisgICAgICAgIGFjY2VwdGVkVHlwZXM6CisgICAgICAgICAgICAtIHhtbAorICAgIFVDUEVfTEFZRVJfMl9DT05GSUdVUkFUSU9OOgorICAgICAgICBhY2NlcHRlZFR5cGVzOgorICAgICAgICAgICAgLSB4bWwKKworI0FBSSBBcnRpZmFjdHMKKyAgICBBQUlfU0VSVklDRV9NT0RFTDoKKyAgICAgICAgYWNjZXB0ZWRUeXBlczoKKyAgICAgICAgICAgIC0geG1sCisgICAgQUFJX1ZGX01PRFVMRV9NT0RFTDoKKyAgICAgICAgYWNjZXB0ZWRUeXBlczoKKyAgICAgICAgICAgIC0geG1sCisgICAgQUFJX1ZGX0lOU1RBTkNFX01PREVMOgorICAgICAgICBhY2NlcHRlZFR5cGVzOgorICAgICAgICAgICAgLSB4bWwgCisgICAgT1RIRVI6CisgICAgICAgIGFjY2VwdGVkVHlwZXM6CisKK3Jlc291cmNlRGVwbG95bWVudEFydGlmYWN0czoKKyAgICBIRUFUOgorICAgICAgICBhY2NlcHRlZFR5cGVzOgorICAgICAgICAgICAgLSB5YW1sCisgICAgICAgICAgICAtIHltbAorICAgICAgICB2YWxpZEZvclJlc291cmNlVHlwZXM6ICphbGxSZXNvdXJjZVR5cGVzCisgICAgSEVBVF9WT0w6CisgICAgICAgIGFjY2VwdGVkVHlwZXM6CisgICAgICAgICAgICAtIHlhbWwKKyAgICAgICAgICAgIC0geW1sCisgICAgICAgIHZhbGlkRm9yUmVzb3VyY2VUeXBlczogKmFsbFJlc291cmNlVHlwZXMKKyAgICBIRUFUX05FVDoKKyAgICAgICAgYWNjZXB0ZWRUeXBlczoKKyAgICAgICAgICAgIC0geWFtbAorICAgICAgICAgICAgLSB5bWwKKyAgICAgICAgdmFsaWRGb3JSZXNvdXJjZVR5cGVzOiAqYWxsUmVzb3VyY2VUeXBlcworICAgIEhFQVRfTkVTVEVEOgorICAgICAgICBhY2NlcHRlZFR5cGVzOgorICAgICAgICAgICAgLSB5YW1sCisgICAgICAgICAgICAtIHltbAorICAgICAgICB2YWxpZEZvclJlc291cmNlVHlwZXM6ICphbGxSZXNvdXJjZVR5cGVzCisgICAgSEVBVF9BUlRJRkFDVDoKKyAgICAgICAgYWNjZXB0ZWRUeXBlczoKKyAgICAgICAgdmFsaWRGb3JSZXNvdXJjZVR5cGVzOiAqYWxsUmVzb3VyY2VUeXBlcworICAgIFlBTkdfWE1MOgorICAgICAgICBhY2NlcHRlZFR5cGVzOgorICAgICAgICAgICAgLSB4bWwKKyAgICAgICAgdmFsaWRGb3JSZXNvdXJjZVR5cGVzOiAqYWxsUmVzb3VyY2VUeXBlcworICAgIFZORl9DQVRBTE9HOgorICAgICAgICBhY2NlcHRlZFR5cGVzOgorICAgICAgICAgICAgLSB4bWwKKyAgICAgICAgdmFsaWRGb3JSZXNvdXJjZVR5cGVzOiAqYWxsUmVzb3VyY2VUeXBlcworICAgIFZGX0xJQ0VOU0U6CisgICAgICAgIGFjY2VwdGVkVHlwZXM6CisgICAgICAgICAgICAtIHhtbAorICAgICAgICB2YWxpZEZvclJlc291cmNlVHlwZXM6ICphbGxSZXNvdXJjZVR5cGVzCisgICAgVkVORE9SX0xJQ0VOU0U6CisgICAgICAgIGFjY2VwdGVkVHlwZXM6CisgICAgICAgICAgICAtIHhtbAorICAgICAgICB2YWxpZEZvclJlc291cmNlVHlwZXM6ICphbGxSZXNvdXJjZVR5cGVzCisgICAgTU9ERUxfSU5WRU5UT1JZX1BST0ZJTEU6CisgICAgICAgIGFjY2VwdGVkVHlwZXM6CisgICAgICAgICAgICAtIHhtbAorICAgICAgICB2YWxpZEZvclJlc291cmNlVHlwZXM6ICphbGxSZXNvdXJjZVR5cGVzCisgICAgTU9ERUxfUVVFUllfU1BFQzoKKyAgICAgICAgYWNjZXB0ZWRUeXBlczoKKyAgICAgICAgICAgIC0geG1sCisgICAgICAgIHZhbGlkRm9yUmVzb3VyY2VUeXBlczogKmFsbFJlc291cmNlVHlwZXMKKyAgICBMSUZFQ1lDTEVfT1BFUkFUSU9OUzoKKyAgICAgICAgYWNjZXB0ZWRUeXBlczoKKyAgICAgICAgICAgIC0geWFtbAorICAgICAgICAgICAgLSB5bWwKKyAgICAgICAgdmFsaWRGb3JSZXNvdXJjZVR5cGVzOgorICAgICAgICAgICAgLSBWRgorICAgICAgICAgICAgLSBWRkMKKyAgICBWRVNfRVZFTlRTOgorICAgICAgICBhY2NlcHRlZFR5cGVzOgorICAgICAgICAgICAgLSB5YW1sCisgICAgICAgICAgICAtIHltbAorICAgICAgICB2YWxpZEZvclJlc291cmNlVHlwZXM6ICphbGxSZXNvdXJjZVR5cGVzCisgICAgUEVSRk9STUFOQ0VfQ09VTlRFUjoKKyAgICAgICAgYWNjZXB0ZWRUeXBlczoKKyAgICAgICAgICAgIC0gY3N2CisgICAgICAgIHZhbGlkRm9yUmVzb3VyY2VUeXBlczogKmFsbFJlc291cmNlVHlwZXMKKyAgICBBUFBDX0NPTkZJRzoKKyAgICAgICAgYWNjZXB0ZWRUeXBlczoKKyAgICAgICAgdmFsaWRGb3JSZXNvdXJjZVR5cGVzOgorICAgICAgICAgICAgLSBWRgorICAgIERDQUVfVE9TQ0E6CisgICAgICAgIGFjY2VwdGVkVHlwZXM6CisgICAgICAgICAgICAtIHltbAorICAgICAgICAgICAgLSB5YW1sCisgICAgICAgIHZhbGlkRm9yUmVzb3VyY2VUeXBlczoKKyAgICAgICAgICAgIC0gVkYKKyAgICAgICAgICAgIC0gVkZDTVQKKyAgICBEQ0FFX0pTT046CisgICAgICAgIGFjY2VwdGVkVHlwZXM6CisgICAgICAgICAgICAtIGpzb24KKyAgICAgICAgdmFsaWRGb3JSZXNvdXJjZVR5cGVzOgorICAgICAgICAgICAgLSBWRgorICAgICAgICAgICAgLSBWRkNNVAorICAgIERDQUVfUE9MSUNZOgorICAgICAgICBhY2NlcHRlZFR5cGVzOgorICAgICAgICAgICAgLSBlbWYKKyAgICAgICAgdmFsaWRGb3JSZXNvdXJjZVR5cGVzOgorICAgICAgICAgICAgLSBWRgorICAgICAgICAgICAgLSBWRkNNVAorICAgIERDQUVfRE9DOgorICAgICAgICBhY2NlcHRlZFR5cGVzOgorICAgICAgICB2YWxpZEZvclJlc291cmNlVHlwZXM6CisgICAgICAgICAgICAtIFZGIAorICAgICAgICAgICAgLSBWRkNNVCAgICAgICAKKyAgICBEQ0FFX0VWRU5UOgorICAgICAgICBhY2NlcHRlZFR5cGVzOgorICAgICAgICB2YWxpZEZvclJlc291cmNlVHlwZXM6CisgICAgICAgICAgICAtIFZGCisgICAgICAgICAgICAtIFZGQ01UCisgICAgQUFJX1ZGX01PREVMOgorICAgICAgICBhY2NlcHRlZFR5cGVzOgorICAgICAgICAgICAgLSB4bWwKKyAgICAgICAgdmFsaWRGb3JSZXNvdXJjZVR5cGVzOgorICAgICAgICAgICAgLSBWRgorICAgIEFBSV9WRl9NT0RVTEVfTU9ERUw6CisgICAgICAgIGFjY2VwdGVkVHlwZXM6CisgICAgICAgICAgICAtIHhtbAorICAgICAgICB2YWxpZEZvclJlc291cmNlVHlwZXM6CisgICAgICAgICAgICAtIFZGCisgICAgT1RIRVI6CisgICAgICAgIGFjY2VwdGVkVHlwZXM6CisgICAgICAgIHZhbGlkRm9yUmVzb3VyY2VUeXBlczogKmFsbFJlc291cmNlVHlwZXMKKyAgICBTTk1QX1BPTEw6CisgICAgICAgIGFjY2VwdGVkVHlwZXM6CisgICAgICAgIHZhbGlkRm9yUmVzb3VyY2VUeXBlczogKmFsbFJlc291cmNlVHlwZXMKKyAgICBTTk1QX1RSQVA6CisgICAgICAgIGFjY2VwdGVkVHlwZXM6CisgICAgICAgIHZhbGlkRm9yUmVzb3VyY2VUeXBlczogKmFsbFJlc291cmNlVHlwZXMKKworcmVzb3VyY2VJbnN0YW5jZURlcGxveW1lbnRBcnRpZmFjdHM6CisgICAgSEVBVF9FTlY6CisgICAgICAgIGFjY2VwdGVkVHlwZXM6CisgICAgICAgICAgICAtIGVudgorICAgIFZGX01PRFVMRVNfTUVUQURBVEE6CisgICAgICAgIGFjY2VwdGVkVHlwZXM6CisgICAgICAgICAgICAtIGpzb24KKyAgICBWRVNfRVZFTlRTOgorICAgICAgICBhY2NlcHRlZFR5cGVzOgorICAgICAgICAgICAgLSB5YW1sCisgICAgICAgICAgICAtIHltbAorICAgIFBFUkZPUk1BTkNFX0NPVU5URVI6CisgICAgICAgIGFjY2VwdGVkVHlwZXM6CisgICAgICAgICAgICAtIGNzdgorICAgIERDQUVfSU5WRU5UT1JZX1RPU0NBOgorICAgICAgICBhY2NlcHRlZFR5cGVzOgorICAgICAgICAgICAgLSB5bWwKKyAgICAgICAgICAgIC0geWFtbAorICAgIERDQUVfSU5WRU5UT1JZX0pTT046CisgICAgICAgIGFjY2VwdGVkVHlwZXM6CisgICAgICAgICAgICAtIGpzb24KKyAgICBEQ0FFX0lOVkVOVE9SWV9QT0xJQ1k6CisgICAgICBhY2NlcHRlZFR5cGVzOgorICAgICAgICAgICAgLSBlbWYKKyAgICBEQ0FFX0lOVkVOVE9SWV9ET0M6CisgICAgICBhY2NlcHRlZFR5cGVzOgorICAgIERDQUVfSU5WRU5UT1JZX0JMVUVQUklOVDoKKyAgICAgIGFjY2VwdGVkVHlwZXM6CisgICAgRENBRV9JTlZF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ogKmFsbFJlc291cmNlVHlwZXMKKyAgICBER19YTUw6CisgICAgICAgIGFjY2VwdGVkVHlwZXM6CisgICAgICAgIHZhbGlkRm9yUmVzb3VyY2VUeXBlczogKmFsbFJlc291cmNlVHlwZXMKKyAgICBNVVJBTk9fUEtHOgorICAgICAgICBhY2NlcHRlZFR5cGVzOgorICAgICAgICB2YWxpZEZvclJlc291cmNlVHlwZXM6ICphbGxSZXNvdXJjZVR5cGVzCisgICAgT1RIRVI6CisgICAgICAgIGFjY2VwdGVkVHlwZXM6CisgICAgICAgIHZhbGlkRm9yUmVzb3VyY2VUeXBlczogCisgICAgICAgICAgICAtIFZGQworICAgICAgICAgICAgLSBDVkZDCisgICAgICAgICAgICAtIENQCisgICAgICAgICAgICAtIFZMCisgICAgICAgICAgICAtIFZGCisgICAgICAgICAgICAtIFZGQ01UCisgICAgICAgICAgICAtIEFic3RyYWN0CisgICAgICAgICAgICAtIFBORgorICAgIFNOTVBfUE9MTDoKKyAgICAgICAgYWNjZXB0ZWRUeXBlczoKKyAgICAgICAgdmFsaWRGb3JSZXNvdXJjZVR5cGVzOiAqYWxsUmVzb3VyY2VUeXBlcworICAgIFNOTVBfVFJBUDoKKyAgICAgICAgYWNjZXB0ZWRUeXBlczoKKyAgICAgICAgdmFsaWRGb3JSZXNvdXJjZVR5cGVzOiAqYWxsUmVzb3VyY2VUeXBlcworICAgIEdVSURFOgorICAgICAgICBhY2NlcHRlZFR5cGVzOgorICAgICAgICB2YWxpZEZvclJlc291cmNlVHlwZXM6CisgICAgICAgICAgICAtIFZGCisgICAgICAgICAgICAtIFZGQworICAgICAgICAgICAgLSBDVkZDCisKK3Jlc291cmNlSW5mb3JtYXRpb25hbERlcGxveWVkQXJ0aWZhY3RzOgorCit1bkxvZ2dlZFVybHM6CisgICAtIC9zZGMyL3Jlc3QvaGVhbHRoQ2hlY2sKKworY2xlYW5Db21wb25lbnRzQ29uZmlndXJhdGlvbjoKKyAgICBjbGVhbkludGVydmFsSW5NaW51d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XM6IFNVUFBPUlRFRAorICAgICAgc3RhdGljX3JvdXRlc19saXN0OgorICAgICAgICB0eXBlOiBsaXN0CisgICAgICAgIGRlc2NyaXB0aW9uOiBTdGF0aWMgcm91dGVzIGVuYWJsZWQKKyAgICAgICAgcmVxdWlyZWQ6IGZhbHNlCisgICAgICAgIHN0YXR1czogU1VQUE9SVEVECisgICAgICAgIGVudHJ5X3NjaGVtYToKKyAgICAgICAgICB0eXBlOiBib29sZWFuCisgICAgICBhdmFpbGFiaWxpdHlfem9uZV9lbmFibGU6CisgICAgICAgIHR5cGU6IGJvb2xlYW4KKyAgICAgICAgZGVzY3JpcHRpb246IEluZGljYXRlcyBhdmFpbGFiaWxpdHkgem9uZSBpcyBlbmFibGVkCisgICAgICAgIHJlcXVpcmVkOiBmYWxzZQorICAgICAgICBkZWZhdWx0OiBmYWxzZQorICAgICAgICBzdGF0dXM6IFNVUFBPUlRFRAorICAgICAgc2VydmljZV90ZW1wbGF0ZV9uYW1lOgorICAgICAgICB0eXBlOiBzdHJpbmcKKyAgICAgICAgZGVzY3JpcHRpb246IFNlcnZpY2UgdGVtcGxhdGUgbmFtZQorICAgICAgICByZXF1aXJlZDogZmFsc2UKKyAgICAgICAgc3RhdHVzOiBTVVBQT1JURUQKKyAgICAgIG9yZGVyZWRfaW50ZXJmYWNlczoKKyAgICAgICAgdHlwZTogYm9vbGVhbgorICAgICAgICBkZXNjcmlwdGlvbjogSW5kaWNhdGVzIGlmIHNlcnZpY2UgaW50ZXJmYWNlIGFyZSBvcmRlcmVkCisgICAgICAgIHJlcXVpcmVkOiBmYWxzZQorICAgICAgICBkZWZhdWx0OiBmYWxzZQorICAgICAgICBzdGF0dXM6IFNVUFBPUlRFRAorICAgICAgZmxhdm9yOgorICAgICAgICB0eXBlOiBzdHJpbmcKKyAgICAgICAgZGVzY3JpcHRpb246IGZsYXZvcgorICAgICAgICByZXF1aXJlZDogZmFsc2UKKyAgICAgICAgc3RhdHVzOiBTVVBQT1JURUQKKyAgICAgIGltYWdlX25hbWU6CisgICAgICAgIHR5cGU6IHN0cmluZworICAgICAgICBkZXNjcmlwdGlvbjogSW1hZ2UgbmFtZQorICAgICAgICByZXF1aXJlZDogdHJ1ZQorICAgICAgICBzdGF0dXM6IFNVUFBPUlRFRAorICAgICAgc2VydmljZV90eXBlOgorICAgICAgICB0eXBlOiBzdHJpbmcKKyAgICAgICAgZGVzY3JpcHRpb246IFNlcnZpY2UgdHlwZQorICAgICAgICByZXF1aXJlZDogdHJ1ZQorICAgICAgICBzdGF0dXM6IFNVUFBPUlRFRAorICAgICAgICBjb25zdHJhaW50czoKKyAgICAgICAgLSB2YWxpZF92YWx1ZXM6CisgICAgICAgICAgLSBmaXJld2FsbAorICAgICAgICAgIC0gYW5hbHl6ZXIKKyAgICAgICAgICAtIHNvdXJjZS1uYXQKKyAgICAgICAgICAtIGxvYWRiYWxhbmNlcgorICAgICAgc2VydmljZV9pbnRlcmZhY2VfdHlwZV9saXN0OgorICAgICAgICB0eXBlOiBsaXN0CisgICAgICAgIGRlc2NyaXB0aW9uOiBMaXN0IG9mIGludGVyZmFjZSB0eXBlcworICAgICAgICByZXF1aXJlZDogdHJ1ZQorICAgICAgICBzdGF0dXM6IFNVUFBPUlRFRAorICAgICAgICBlbnRyeV9zY2hlbWE6CisgICAgICAgICAgdHlwZTogc3RyaW5nCisgICAgICAgICAgY29uc3RyYWludHM6CisgICAgICAgICAgLSB2YWxpZF92YWx1ZXM6CisgICAgICAgICAgICAtIG1hbmFnZW1lbnQKKyAgICAgICAgICAgIC0gbGVmdAorICAgICAgICAgICAgLSByaWdodAorICAgICAgICAgICAgLSBvdGhlcgorICAgICAgc2VydmljZV9pbnN0YW5jZV9uYW1lOgorICAgICAgICB0eXBlOiBzdHJpbmcKKyAgICAgICAgZGVzY3JpcHRpb246IFNlcnZpY2UgaW5zdGFuY2UgbmFtZQorICAgICAgICByZXF1aXJlZDogdHJ1ZQorICAgICAgICBzdGF0dXM6IFNVUFBPUlRFRAorICAgICAgaW50ZXJmYWNlX2xpc3Q6CisgICAgICAgIHR5cGU6IGxpc3QKKyAgICAgICAgZGVzY3JpcHRpb246IExpc3Qgb2YgaW50ZXJmYWNlcworICAgICAgICByZXF1aXJlZDogZmFsc2UKKyAgICAgICAgc3RhdHVzOiBTVVBQT1JURUQKKyAgICAgICAgZW50cnlfc2NoZW1hOgorICAgICAgICAgIHR5cGU6IG9yZy5vcGVuZWNvbXAuZGF0YXR5cGVzLmhlYXQubmV0d29yay5jb250cmFpbC5JbnRlcmZhY2VEYXRhCisgICAgICBzZXJ2aWNlX21vZGU6CisgICAgICAgIHR5cGU6IHN0cmluZworICAgICAgICBkZXNjcmlwdGlvbjogU2VydmljZSBtb2RlCisgICAgICAgIHJlcXVpcmVkOiB0cnVlCisgICAgICAgIHN0YXR1czogU1VQUE9SVEVECisgICAgICAgIGNvbnN0cmFpbnRzOgorICAgICAgICAtIHZhbGlkX3ZhbHVlczoKKyAgICAgICAgICAtIHRyYW5zcGFyZW50CisgICAgICAgICAgLSBpbi1uZXR3b3JrCisgICAgICAgICAgLSBpbi1uZXR3b3JrLW5hdAorICAgICAgc2hhcmVkX2lwX2xpc3Q6CisgICAgICAgIHR5cGU6IGxpc3QKKyAgICAgICAgZGVzY3JpcHRpb246IFNoYXJlZCBpcHMgZW5hYmxlZAorICAgICAgICByZXF1aXJlZDogZmFsc2UKKyAgICAgICAgc3RhdHVzOiBTVVBQT1JURUQKKyAgICAgICAgZW50cnlfc2NoZW1hOgorICAgICAgICAgIHR5cGU6IGJvb2xlYW4KKyAgICBhdHRyaWJ1dGVzOgorICAgICAgdGVuYW50X2lkOgorICAgICAgICB0eXBlOiBzdHJpbmcKKyAgICAgICAgZGVzY3JpcHRpb246IFRlbmFudCBpZCBvZiB0aGUgU2VydmljZSBJbnN0YW5jZQorICAgICAgICBzdGF0dXM6IFNVUFBPUlRFRAorICAgICAgZnFfbmFtZToKKyAgICAgICAgdHlwZTogc3RyaW5nCisgICAgICAgIGRlc2NyaXB0aW9uOiBUaGUgRlEgbmFtZSBvZiB0aGUgc2VydmljZSBpbnN0YW5jZQorICAgICAgICBzdGF0dXM6IFNVUFBPUlRFRAorICAgICAgc2VydmljZV90ZW1wbGF0ZV9uYW1lOgorICAgICAgICB0eXBlOiBzdHJpbmcKKyAgICAgICAgZGVzY3JpcHRpb246IFNlcnZpY2UgVGVtcGxhdGUgb2YgdGhlIFNlcnZpY2UgSW5zdGFuY2UKKyAgICAgICAgc3RhdHVzOiBTVVBQT1JURUQKKyAgICAgIHNob3c6CisgICAgICAgIHR5cGU6IHN0cmluZworICAgICAgICBkZXNjcmlwdGlvbjogQWxsIGF0dHJpYnV0ZXMKKyAgICAgICAgc3RhdHVzOiBTVVBQT1JURUQKKyAgICAgIGFjdGl2ZV92bXM6CisgICAgICAgIHR5cGU6IHN0cmluZworICAgICAgICBkZXNjcmlwdGlvbjogTnVtYmVyIG9mIHNlcnZpY2UgVk1zIGFjdGl2ZSBmb3IgdGhpcyBTZXJ2aWNlIEluc3RhbmNlCisgICAgICAgIHN0YXR1czogU1VQUE9SVEVECisgICAgICBzZXJ2aWNlX2luc3RhbmNlX25hbWU6CisgICAgICAgIHR5cGU6IHN0cmluZworICAgICAgICBkZXNjcmlwdGlvbjogVGhlIG5hbWUgb2YgdGhlIHNlcnZpY2UgaW5zdGFuY2UKKyAgICAgICAgc3RhdHVzOiBTVVBQT1JURUQKKyAgICAgIHZpcnR1YWxfbWFjaGluZXM6CisgICAgICAgIHR5cGU6IHN0cmluZworICAgICAgICBkZXNjcmlwdGlvbjogU2VydmljZSBWTXMgZm9yIHRoZSBTZXJ2aWNlIEluc3RhbmNlCisgICAgICAgIHN0YXR1czogU1VQUE9SVEVECisgICAgICBzdGF0dXM6CisgICAgICAgIHR5cGU6IHN0cmluZworICAgICAgICBkZXNjcmlwdGlvbjogU3RhdHVzIG9mIHRoZSBzZXJ2aWNlIGluc3RhbmNlCisgICAgICAgIHN0YXR1czogU1VQUE9SVEVEClwgTm8gbmV3b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FN0YXJ0IHBvcnQKICAgICAgICAgcmVxdWlyZWQ6IGZhbHNlCi0gICAgICAgIHN0YXR1czogc3VwcG9ydGVkCisgICAgICAgIHN0YXR1czogU1VQUE9SVEVECiAgICAgICBlbmRfcG9ydDoKICAgICAgICAgdHlwZTogc3RyaW5nCiAgICAgICAgIGRlc2NyaXB0aW9uOiBFbmQgcG9ydAogICAgICAgICByZXF1aXJlZDogZmFsc2UKLSAgICAgICAgc3RhdHVzOiBzdXBwb3J0ZWQKKyAgICAgICAgc3RhdHVzOiBTVVBQT1JURUQKIAogb3JnLm9wZW5lY29tcC5kYXRhdHlwZXMuaGVhdC5jb250cmFpbC5uZXR3b3JrLnJ1bGUuUnVsZToKICAgICBkZXJpdmVkX2Zyb206IHRvc2NhLmRhdGF0eXBlcy5Sb290CkBAIC0zOTMsNDUgKzM5Myw0NSBAQAogICAgICAgICB0eXBlOiBsaXN0CiAgICAgICAgIGRlc2NyaXB0aW9uOiBTb3VyY2UgcG9ydHMKICAgICAgICAgcmVxdWlyZWQ6IGZhbHNlCi0gICAgICAgIHN0YXR1czogc3VwcG9ydGVkCisgICAgICAgIHN0YXR1czogU1VQUE9SVEVECiAgICAgICAgIGVudHJ5X3NjaGVtYToKICAgICAgICAgICB0eXBlOiBvcmcub3BlbmVjb21wLmRhdGF0eXBlcy5oZWF0LmNvbnRyYWlsLm5ldHdvcmsucnVsZS5Qb3J0UGFpcnMKICAgICAgIHByb3RvY29sOgogICAgICAgICB0eXBlOiBzdHJpbmcKICAgICAgICAgZGVzY3JpcHRpb246IFByb3RvY29sCiAgICAgICAgIHJlcXVpcmVkOiBmYWxzZQotICAgICAgICBzdGF0dXM6IHN1cHBvcnRlZAorICAgICAgICBzdGF0dXM6IFNVUFBPUlRFRAogICAgICAgZHN0X2FkZHJlc3NlczoKICAgICAgICAgdHlwZTogbGlzdAogICAgICAgICBkZXNjcmlwdGlvbjogRGVzdGluYXRpb24gYWRkcmVzc2VzCiAgICAgICAgIHJlcXVpcmVkOiBmYWxzZQotICAgICAgICBzdGF0dXM6IHN1cHBvcnRlZAorICAgICAgICBzdGF0dXM6IFNVUFBPUlRFRAogICAgICAgICBlbnRyeV9zY2hlbWE6CiAgICAgICAgICAgdHlwZTogb3JnLm9wZW5lY29tcC5kYXRhdHlwZXMuaGVhdC5jb250cmFpbC5uZXR3b3JrLnJ1bGUuVmlydHVhbE5ldHdvcmsKICAgICAgIGFwcGx5X3NlcnZpY2U6CiAgICAgICAgIHR5cGU6IHN0cmluZwogICAgICAgICBkZXNjcmlwdGlvbjogU2VydmljZSB0byBhcHBseQogICAgICAgICByZXF1aXJlZDogZmFsc2UKLSAgICAgICAgc3RhdHVzOiBzdXBwb3J0ZWQKKyAgICAgICAgc3RhdHVzOiBTVVBQT1JURUQKICAgICAgIGRzdF9wb3J0czoKICAgICAgICAgdHlwZTogbGlzdAogICAgICAgICBkZXNjcmlwdGlvbjogRGVzdGluYXRpb24gcG9ydHMKICAgICAgICAgcmVxdWlyZWQ6IGZhbHNlCi0gICAgICAgIHN0YXR1czogc3VwcG9ydGVkCisgICAgICAgIHN0YXR1czogU1VQUE9SVEVECiAgICAgICAgIGVudHJ5X3NjaGVtYToKICAgICAgICAgICB0eXBlOiBvcmcub3BlbmVjb21wLmRhdGF0eXBlcy5oZWF0LmNvbnRyYWlsLm5ldHdvcmsucnVsZS5Qb3J0UGFpcnMKICAgICAgIHNyY19hZGRyZXNzZXM6CiAgICAgICAgIHR5cGU6IGxpc3QKICAgICAgICAgZGVzY3JpcHRpb246IFNvdXJjZSBhZGRyZXNzZXMKICAgICAgICAgcmVxdWlyZWQ6IGZhbHNlCi0gICAgICAgIHN0YXR1czogc3VwcG9ydGVkCisgICAgICAgIHN0YXR1czogU1VQUE9SVEVECiAgICAgICAgIGVudHJ5X3NjaGVtYToKICAgICAgICAgICB0eXBlOiBvcmcub3BlbmVjb21wLmRhdGF0eXBlcy5oZWF0LmNvbnRyYWlsLm5ldHdvcmsucnVsZS5WaXJ0dWFsTmV0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zdXBwb3J0ZWQKKyAgICAgICAgc3RhdHVzOiBTVVBQT1JURUQKICAgICAgICAgY29uc3RyYWludHM6CiAgICAgICAgIC0gaW5fcmFuZ2U6CiAgICAgICAgICAgLSAwCkBAIC00OTgsMTMgKzQ5OCwxMyBAQAogICAgICAgICB0eXBlOiBzdHJpbmcKICAgICAgICAgZGVzY3JpcHRpb246IFRoZSByZW1vdGUgSVAgcHJlZml4IChDSURSKSB0byBiZSBhc3NvY2lhdGVkIHdpdGggdGhpcyBzZWN1cml0eSBncm91cCBydWxlCiAgICAgICAgIHJlcXVpcmVkOiBmYWxzZQotICAgICAgICBzdGF0dXM6IHN1cHBvcnRlZAorICAgICAgICBzdGF0dXM6IFNVUFBPUlRFRAogICAgICAgcmVtb3RlX21vZGU6CiAgICAgICAgIHR5cGU6IHN0cmluZwogICAgICAgICBkZXNjcmlwdGlvbjogV2hldGhlciB0byBzcGVjaWZ5IGEgcmVtb3RlIGdyb3VwIG9yIGEgcmVtb3RlIElQIHByZWZpeAogICAgICAgICByZXF1aXJlZDogZmFsc2UKICAgICAgICAgZGVmYXVsdDogcmVtb3RlX2lwX3ByZWZpeAotICAgICAgICBzdGF0dXM6IHN1cHBvcnRlZAorICAgICAgICBzdGF0dXM6IFNVUFBPUlRFRAogICAgICAgICBjb25zdHJhaW50czoKICAgICAgICAgLSB2YWxpZF92YWx1ZXM6CiAgICAgICAgICAgLSByZW1vdGVfaXBfcHJlZml4CkBAIC01MTQsNyArNTE0LDcgQEAKICAgICAgICAgZGVzY3JpcHRpb246IFRoZSBkaXJlY3Rpb24gaW4gd2hpY2ggdGhlIHNlY3VyaXR5IGdyb3VwIHJ1bGUgaXMgYXBwbGllZAogICAgICAgICByZXF1aXJlZDogZmFsc2UKICAgICAgICAgZGVmYXVsdDogaW5ncmVzcwotICAgICAgICBzdGF0dXM6IHN1cHBvcnRlZAorICAgICAgICBzdGF0dXM6IFNVUFBPUlRFRAogICAgICAgICBjb25zdHJhaW50czoKICAgICAgICAgLSB2YWxpZF92YWx1ZXM6CiAgICAgICAgICAgLSBlZ3Jlc3MKQEAgLTUyMyw3ICs1MjMsNyBAQAogICAgICAgICB0eXBlOiBpbnRlZ2VyCiAgICAgICAgIGRlc2NyaXB0aW9uOiBUaGUgbWluaW11bSBwb3J0IG51bWJlciBpbiB0aGUgcmFuZ2UgdGhhdCBpcyBtYXRjaGVkIGJ5IHRoZSBzZWN1cml0eSBncm91cCBydWxlLgogICAgICAgICByZXF1aXJlZDogZmFsc2UKLSAgICAgICAgc3RhdHVzOiBzdXBwb3J0ZWQKKyAgICAgICAgc3RhdHVzOiBTVVBQT1JURUQKICAgICAgICAgY29uc3RyYWludHM6CiAgICAgICAgIC0gaW5fcmFuZ2U6CiAgICAgICAgICAgLSAwCkBAIC01MzcsMTMgKzUzNywxMyBAQAogICAgICAgICB0eXBlOiBzdHJpbmcKICAgICAgICAgZGVzY3JpcHRpb246IFN1YnN0aXR1dGUgU2VydmljZSBUZW1wbGF0ZQogICAgICAgICByZXF1aXJlZDogdHJ1ZQotICAgICAgICBzdGF0dXM6IHN1cHBvcnRlZAorICAgICAgICBzdGF0dXM6IFNVUFBPUlRFRAogICAgICAgaW5kZXhfdmFsdWU6CiAgICAgICAgIHR5cGU6IGludGVnZXIKICAgICAgICAgZGVzY3JpcHRpb246IEluZGV4IHZhbHVlIG9mIHRoZSBzdWJzdGl0dXRpb24gc2VydmljZSB0ZW1wbGF0ZSBydW50aW1lIGluc3RhbmNlCiAgICAgICAgIHJlcXVpcmVkOiBmYWxzZQogICAgICAgICBkZWZhdWx0OiAwCi0gICAgICAgIHN0YXR1czogc3VwcG9ydGVkCisgICAgICAgIHN0YXR1czogU1VQUE9SVEVECiAgICAgICAgIGNvbnN0cmFpbnRzOgogICAgICAgICAtIGdyZWF0ZXJfb3JfZXF1YWw6IDAKICAgICAgIGNvdW50OgpAQCAtNTUxLDE5ICs1NTEsMTkgQEAKICAgICAgICAgZGVzY3JpcHRpb246IENvdW50CiAgICAgICAgIHJlcXVpcmVkOiBmYWxzZQogICAgICAgICBkZWZhdWx0OiAxCi0gICAgICAgIHN0YXR1czogc3VwcG9ydGVkCisgICAgICAgIHN0YXR1czogU1VQUE9SVEVECiAgICAgICBzY2FsaW5nX2VuYWJsZWQ6CiAgICAgICAgIHR5cGU6IGJvb2xlYW4KICAgICAgICAgZGVzY3JpcHRpb246IEluZGljYXRlcyB3aGV0aGVyIHNlcnZpY2Ugc2NhbGluZyBpcyBlbmFibGVkCiAgICAgICAgIHJlcXVpcmVkOiBmYWxzZQogICAgICAgICBkZWZhdWx0OiB0cnVlCi0gICAgICAgIHN0YXR1czogc3VwcG9ydGVkCisgICAgICAgIHN0YXR1czogU1VQUE9SVEVECiAgICAgICBtYW5kYXRvcnk6CiAgICAgICAgIHR5cGU6IGJvb2xlYW4KICAgICAgICAgZGVzY3JpcHRpb246IE1hbmRhdG9yeQogICAgICAgICByZXF1aXJlZDogZmFsc2UKICAgICAgICAgZGVmYXVsdDogdHJ1ZQotICAgICAgICBzdGF0dXM6IHN1cHBvcnRlZAorICAgICAgICBzdGF0dXM6IFNVUFBPUlRFRAogCiBvcmcub3BlbmVjb21wLmRhdGF0eXBlcy5oZWF0LmNvbnRyYWlsVjIudmlydHVhbC5uZXR3b3JrLnJ1bGUuUmVmRGF0YVNlcXVlbmNlOgogICAgIGRlcml2ZWRfZnJvbTogdG9zY2EuZGF0YXR5cGVzLlJvb3QKQEAgLTU3MywxMiArNTczLDEyIEBACiAgICAgICAgIHR5cGU6IGludGVnZXIKICAgICAgICAgZGVzY3JpcHRpb246IE5ldHdvcmsgUG9saWN5IHJlZiBkYXRhIHNlcXVlbmNlIE1ham9yCiAgICAgICAgIHJlcXVpcmVkOiBmYWxzZQotICAgICAgICBzdGF0dXM6IHN1cHBvcnRlZAorICAgICAgICBzdGF0dXM6IFNVUFBPUlRFRAogICAgICAgbmV0d29ya19wb2xpY3lfcmVmc19kYXRhX3NlcXVlbmNlX21pbm9yOgogICAgICAgICB0eXBlOiB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