This is a multi-part message in MIME format.
------_=_NextPart_001_01C9711D.AD2F41AD Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
Hello,
Attached is the suggested LDAPConnection.java to fix this issue.=20
Thanks,
Maurice ________________________________________________________________________ ________________________________________ Maurice Smulders| Firmware Engineer | Quantum Corporation | Office: 720.249.3817 | Mobile: 720.514.0310 | Maurice.Smulders@quantum.com -----Original Message----- From: openldap-its@OpenLDAP.org [mailto:openldap-its@OpenLDAP.org]=20 Sent: Wednesday, January 07, 2009 3:39 PM To: Maurice Smulders Subject: Re: (ITS#5879) LDAPConnection doesn't always uses default constraints for referral handling
*** THIS IS AN AUTOMATICALLY GENERATED REPLY ***
Thanks for your report to the OpenLDAP Issue Tracking System. Your report has been assigned the tracking number ITS#5879.
One of our support engineers will look at your report in due course. Note that this may take some time because our support engineers are volunteers. They only work on OpenLDAP when they have spare time.
If you need to provide additional information in regards to your issue report, you may do so by replying to this message. Note that any mail sent to openldap-its@openldap.org with (ITS#5879) in the subject will automatically be attached to the issue report.
mailto:openldap-its@openldap.org?subject=3D(ITS#5879)
You may follow the progress of this report by loading the following URL in a web browser: http://www.OpenLDAP.org/its/index.cgi?findid=3D5879
Please remember to retain your issue tracking number (ITS#5879) on any further messages you send to us regarding this report. If you don't then you'll just waste our time and yours because we won't be able to properly track the report.
Please note that the Issue Tracking System is not intended to be used to seek help in the proper use of OpenLDAP Software. Such requests will be closed.
OpenLDAP Software is user supported. http://www.OpenLDAP.org/support/
-------------- Copyright 1998-2007 The OpenLDAP Foundation, All Rights Reserved.
------_=_NextPart_001_01C9711D.AD2F41AD Content-Type: application/octet-stream; name="LDAPConnection.java" Content-Transfer-Encoding: base64 Content-Description: LDAPConnection.java Content-Disposition: attachment; filename="LDAPConnection.java"
LyogKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioNCiAqICRPcGVuTERBUDogcGtnL2psZGFwL2Nvb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VBTb2NrZXRGYWN0b3J5KQ0KICAgICAqLw0KICAgIHB1YmxpYyBMREFQQ29u bmVjdGlvbihMREFQU29ja2V0RmFjdG9yeSBmYWN0b3J5KQ0KICAgIHsNCiAgICAgICAgLy8gR2V0 IGEgdW5pcXVlIGNvbm5lY3Rpb24gbmFtZSBmb3IgZGVidWcNCiAgICAgICAgaWYoIERlYnVnLkxE QVBfREVCVUcpIHsNCiAgICAgICAgICAgIHN5bmNocm9uaXplZCggbmFtZUxvY2spIHsNCiAgICAg ICAgICAgICAgICBuYW1lID0gIkxEQVBDb25uZWN0aW9uKCIgKyArK2xDb25uTnVtICsgIik6ICI7 DQogICAgICAgICAgICB9DQogICAgICAgICAgICBEZWJ1Zy50cmFjZSggRGVidWcuYXBpUmVxdWVz dHMsIG5hbWUgKyAiQ3JlYXRlZCIpOw0KICAgICAgICB9DQogICAgICAgIGNvbm4gPSBuZXcgQ29u bmVjdGlvbiggZmFjdG9yeSApOw0KICAgICAgICByZXR1cm47DQogICAgfQ0KDQogICAgLyoqDQog ICAgICogQ29uc3RydWN0cyBhIG5ldyBMREFQQ29ubmVjdGlvbiBvYmplY3QsIHdoaWNoIHdpbGwg dXNlIHRoZSBzdXBwbGllZA0KICAgICAqIHRpbWVvdXQgdmFsdWUgdG8gY29uc3RydWN0IGEgc29j a2V0IGNvbm5lY3Rpb24gZHVyaW5nDQogICAgICogTERBUENvbm5lY3Rpb24uY29ubmVjdCBtZXRo b2Qgd2l0aCB0aGUgc3BlY2lmaWVkIHNvY2tldCANCiAgICAgKiBjb25uZWN0IHRpbWVvdXQgdmFs dWUuDQogICAgICoNCiAgICAgKiAgQHBhcmFtIHRpbWVvdXQgICAgIEFuIG9iamVjdCBjYXBhYmxl IG9mIHByb2R1Y2luZyBhIFNvY2tldCANCiAgICAgKiAgICAgICAgICAgICAgICAgICAgIHdpdGgg dGhlIHNwZWNpZmllZCBTb2NrZXQgQ29ubmVjdCB0aW1lb3V0IHZhbHVlLg0KICAgICAqDQogICAg ICogQHNlZSAjZ2V0U29ja2V0VGltZU91dCgpDQogICAgICogQHNlZSAjc2V0U29ja2V0VGltZU91 dChpbnQpDQogICAgICovDQogICAgDQogICAgcHVibGljIExEQVBDb25uZWN0aW9uKGludCB0aW1l b3V0KQ0KICAgIHsNCiAgICAgICAgLy8gR2V0IGEgdW5pcXVlIGNvbm5lY3Rpb24gbmFtZSBmb3Ig ZGVidWcNCiAgICAgICAgaWYoIERlYnVnLkxEQVBfREVCVUcpIHsNCiAgICAgICAgICAgIHN5bmNo cm9uaXplZCggbmFtZUxvY2spIHsNCiAgICAgICAgICAgICAgICBuYW1lID0gIkxEQVBDb25uZWN0 aW9uKCIgKyArK2xDb25uTnVtICsgIik6ICI7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBE ZWJ1Zy50cmFjZSggRGVidWcuYXBpUmVxdWVzdHMsIG5hbWUgKyAiQ3JlYXRlZCIpOw0KICAgICAg ICB9DQogICAgICAgIGNvbm4gPSBuZXcgQ29ubmVjdGlvbiggdGltZW91dCApOw0KICAgICAgICBy ZXR1cm47DQogICAgfQ0KICAgIC8qDQogICAgICogVGhlIGZvbGxvd2luZyBhcmUgbWV0aG9kcyB0 aGF0IGFmZmVjdCB0aGUgb3BlcmF0aW9uIG9mDQogICAgICogTERBUENvbm5lY3Rpb24sIGJ1dCBh cmUgbm90IExEQVAgcmVxdWVzdHMuDQogICAgICovDQoNCiAgICAvKioNCiAgICAgKiBSZXR1cm5z IGEgY29weSBvZiB0aGUgb2JqZWN0IHdpdGggYSBwcml2YXRlIGNvbnRleHQsIGJ1dCBzaGFyaW5n IHRoZQ0KICAgICAqIG5ldHdvcmsgY29ubmVjdGlvbiBpZiB0aGVyZSBpcyBvbmUuDQogICAgICoN CiAgICAgKiA8cD5UaGUgbmV0d29yayBjb25uZWN0aW9uIHJlbWFpbnMgb3BlbiB1bnRpbCBhbGwg Y2xvbmVzIGhhdmUNCiAgICAgKiBkaXNjb25uZWN0ZWQgb3IgZ29uZSBvd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IExEQVBD b25uZWN0aW9uIG5ld0Nsb25lOw0KICAgICAgICBPYmplY3QgbmV3T2JqOw0KICAgICAgICB0cnkg ew0KICAgICAgICAgICAgbmV3T2JqID0gc3VwZXIuY2xvbmUoKTsNCiAgICAgICAgICAgIG5ld0Ns b25lID0gKExEQVBDb25uZWN0aW9uKW5ld09iajsNCiAgICAgICAgfSBjYXRjaCggQ2xvbmVOb3RT dXBwb3J0ZWRFeGNlcHRpb24gY2UpIHsNCiAgICAgICAgICAgIHRocm93IG5ldyBSdW50aW1lRXhj ZXB0aW9uKCJJbnRlcm5hbCBlcnJvciwgY2Fubm90IGNyZWF0ZSBjbG9uZSIpOw0KICAgICAgICB9 DQogICAgICAgIG5ld0Nsb25lLmNvbm4gPSBjb25uOyAgIC8vIHNhbWUgdW5kZXJseWluZyBjb25u ZWN0aW9uDQogICAgICAgIGlmKCBEZWJ1Zy5MREFQX0RFQlVHKSB7DQogICAgICAgICAgICBEZWJ1 Zy50cmFjZSggRGVidWcuYXBpUmVxdWVzdHMsIG5hbWUgKw0KICAgICAgICAgICAgImNsb25lKCki KTsNCiAgICAgICAgfQ0KDQogICAgICAgIC8vbm93IGp1c3QgZHVwbGljYXRlIHRoZSBkZWZTZWFy Y2hDb25zIGFuZCByZXNwb25zZUN0bHMNCiAgICAgICAgaWYgKGRlZlNlYXJjaENvbnMgIT0gbnVs bCl7DQogICAgICAgICAgICBuZXdDbG9uZS5kZWZTZWFyY2hDb25zPShMREFQU2VhcmNoQ29uc3Ry YWludHMpZGVmU2VhcmNoQ29ucy5jbG9uZSgpOw0KICAgICAgICB9DQogICAgICAgIGVsc2V7DQog ICAgICAgICAgICBuZXdDbG9uZS5kZWZTZWFyY2hDb25zID0gbnVsbDsNCiAgICAgICAgfQ0KICAg ICAgICBpZiAocmVzcG9uc2VDdGxzICE9IG51bGwpew0KICAgICAgICAgICAgbmV3Q2xvbmUucmVz cG9uc2VDdGxzID0gbmV3IExEQVBDb250cm9sW3Jlc3BvbnNlQ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QgbmFtZSBpZiBhdXRoZW50aWNh dGVkOyBvdGhlcndpc2UsIG51bGwuDQogICAgICoNCiAgICAgKiBAc2VlICNiaW5kKCBTdHJpbmcs IFN0cmluZykNCiAgICAgKiBAc2VlICNpc0JvdW5kKCkNCiAgICAgKi8NCiAgICBwdWJsaWMgU3Ry aW5nIGdldEF1dGhlbnRpY2F0aW9uRE4oKQ0KICAgIHsNCiAgICAgICAgQmluZFByb3BlcnRpZXMg cHJvcCA9IGNvbm4uZ2V0QmluZFByb3BlcnRpZXMoKTsNCiAgICAgICAgaWYoIHByb3AgPT0gbnVs bCkgew0KICAgICAgICAgICAgcmV0dXJuIG51bGw7DQogICAgICAgIH0NCiAgICAgICAgaWYoIHBy b3AuaXNBbm9ueW1vdXMoKSkgew0KICAgICAgICAgICAgcmV0dXJuIG51bGw7DQogICAgICAgIH0N CiAgICAgICAgcmV0dXJuIHByb3AuZ2V0QXV0aGVudGljYXRpb25ETigpOw0KICAgIH0NCg0KICAg IC8qKg0KICAgICAqIFJldHVybnMgdGhlIG1ldGhvZCB1c2VkIHRvIGF1dGhlbnRpY2F0ZSB0aGUg Y29ubmVjdGlvbi4gVGhlIHJldHVybg0KICAgICAqIHZhbHVlIGlzIG9uZSBvZiB0aGUgZm9sbG93 aW5nOg0KICAgICAqDQogICAgICogIDx1bD4NCiAgICAgKiAgPGxpPiJub25lIiBpbmRpY2F0ZXMg dGhlIGNvbm5lY3Rpb24gaXMgbm90IGF1dGhlbnRpY2F0ZWQuPC9saT4NCiAgICAgKg0KICAgICAq DQogICAgICogIDxsaT4ic2ltcGxlIiBpbmRpY2F0ZXMgc2ltcGxlIGF1dGhlbnRpY2F0aW9uIHdh cyB1c2VkIG9yIHRoYXQgYSBudWxsDQogICAgICogICAgICAgICAgICAgICAgIG9yIGVtcHR5IGF1 dGhlbnRpY2F0aW9uIEROIHdhcyBzcGVjaWZpZWQuPC9saT4NCiAgICAgKg0KICAgICAqICA8bGk+ InNhc2wiIGluZGljYXRlcyB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gICBOYW1lIG9mIHRoZSBwcm9wZXJ0eSB0 byBiZSByZXR1cm5lZC4NCiAgICAgKg0KICAgICAqIDxwPlRoZSBmb2xsb3dpbmcgcmVhZC1vbmx5 IHByb3BlcnRpZXMgYXJlIGF2YWlsYWJsZQ0KICAgICAqICBmb3IgYW55IGdpdmVuIGNvbm5lY3Rp b246PC9wPg0KICAgICAqICA8dWw+DQogICAgICogIDxsaT5MREFQX1BST1BFUlRZX1NESyByZXR1 cm5zIHRoZSB2ZXJzaW9uIG9mIHRoaXMgU0RLLA0KICAgICAqICAgICAgICAgICAgICAgICAgICAg ICAgYXMgYSBGbG9hdCBkYXRhIHR5cGUuPC9saT4NCiAgICAgKg0KICAgICAqICA8bGk+TERBUF9Q Uk9QRVJUWV9QUk9UT0NPTCByZXR1cm5zIHRoZSBoaWdoZXN0IHN1cHBvcnRlZCB2ZXJzaW9uIG9m DQogICAgICogICAgICAgICAgICAgICAgICAgICAgICAgIHRoZSBMREFQIHByb3RvY29sLCBhcyBh IEZsb2F0IGRhdGEgdHlwZS48L2xpPg0KICAgICAqDQogICAgICogIDxsaT5MREFQX1BST1BFUlRZ X1NFQ1VSSVRZIHJldHVybnMgYSBjb21tYS1zZXBhcmF0ZWQgbGlzdCBvZiB0aGUNCiAgICAgKiAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZXMgb2YgYXV0aGVudGljYXRpb24gc3VwcG9y dGVkLCBhcyBhDQogICAgICogICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZy4NCiAg ICAgKiAgPC91bD4NCiAgICAgKg0KICAgICAqICA8cD5BIGRlZXAgY29weSBvZiB0aGUgcHJvcGVy dHkgaXMgcHJvdmlkZWQgd2hlcmUgYXBwbGljYWJsZTsgYQ0KICAgICAqICBjbGllbnQgZG9lcyBu b3QgbmVlZCB0byBjbG9uZSB0aGUgb2JqZWN0IHJlY2VpdmVkLjwvcD4NCiAgICAgKg0KICAgICAq ICBAcmV0dXJuIFRoZSBvYm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2Vk Lg0KICAgICAqLw0KICAgIHB1YmxpYyBib29sZWFuIGlzQ29ubmVjdGlvbkFsaXZlKCkNCiAgICB7 DQogICAgICAgICAgIHJldHVybiBjb25uLmlzQ29ubmVjdGlvbkFsaXZlKCk7DQogICAgfQ0KICAg IC8qKg0KICAgICAqIEluZGljYXRhdGVzIGlmIHRoZSBjb25uZWN0aW9uIGlzIHByb3RlY3RlZCBi eSBUTFMuDQogICAgICoNCiAgICAgKiBAcmV0dXJuIElmIHN0YXJ0VExTIGhhcyBjb21wbGV0ZWQg dGhpcyBtZXRob2QgcmV0dXJucyB0cnVlLg0KICAgICAqIElmIHN0b3BUTFMgaGFzIGNvbXBsZXRl ZCBvciBzdGFydCB0bHMgZmFpbGVkLCB0aGlzIG1ldGhvZCByZXR1cm5zIGZhbHNlLg0KICAgICAq DQogICAgICogQHJldHVybiAgVHJ1ZSBpZiB0aGUgY29ubmVjdGlvbiBpcyBwcm90ZWN0ZWQgYnkg VExTLg0KICAgICAqDQogICAgICogQHNlZSAjc3RhcnRUTFMNCiAgICAgKiBAc2VlICNzdG9wVExT DQogICAgICovDQogICAgcHVibGljIGJvb2xlYW4gaXNUTFMoKQ0KICAgIHsNCiAgICAgICByZXR1 cm4gY29ubi5pc1RMUygpOw0KICAgIH0NCg0KICAgIC8qKg0KICAgICAqIFJldHVybnMgdGhlIFNv Y2tldFRpbWVPdXQgdmFsdWUgc2V0Lg0KICAgICAqDQogICAgICogQHJldHVybiBSZXR1cm5zIHRo ZSBTb2NrZXRUaW1lT3V0IHZhbHVlIGlmIHNldCwgZWxzZSAwDQogICAgICoNCiAgICAgKkBzZWUg I3NldFNvY2tldFRpbWVPdXQoaW50KQ0KICAgICAqLw0KICAgIA0KICAgIHB1YmxpYyBpbnQgZ2V0 U29ja2V0VGltZU91dCgpDQogICAgew0KICAgICAgICByZXR1cm4gY29ubi5nZXRTb2NrZXRUaW1l T3V0KCk7DQogICAgfQ0KDQogICAgLyoqDQogICAgICogU2V0cyB0aG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haW50cyhMREFQQ29uc3RyYWludHMgY29ucykNCiAgICB7DQogICAgICAg IC8vIFNldCBhbGwgY29uc3RyYWludHMsIHJlcGxhY2UgdGhlIG9iamVjdCB3aXRoIGEgbmV3IG9u ZQ0KICAgICAgICBpZiggY29ucyBpbnN0YW5jZW9mIExEQVBTZWFyY2hDb25zdHJhaW50cykgew0K ICAgICAgICAgICAgZGVmU2VhcmNoQ29ucyA9IChMREFQU2VhcmNoQ29uc3RyYWludHMpY29ucy5j bG9uZSgpOw0KICAgICAgICAgICAgcmV0dXJuOw0KICAgICAgICB9DQoNCiAgICAgICAgLy8gV2Ug c2V0IHRoZSBjb25zdHJhaW50cyB0aGlzIHdheSwgc28gYSB0aHJlYWQgZG9lc24ndCBnZXQgYW4N CiAgICAgICAgLy8gY29uY29uc2lzdGFudCB2aWV3IG9mIHRoZSByZWZlcnJhbHMuDQogICAgICAg IExEQVBTZWFyY2hDb25zdHJhaW50cyBuZXdDb25zID0NCiAgICAgICAgICAgICAgICAgICAgKExE QVBTZWFyY2hDb25zdHJhaW50cylkZWZTZWFyY2hDb25zLmNsb25lKCk7DQogICAgICAgIG5ld0Nv bnMuc2V0SG9wTGltaXQoY29ucy5nZXRIb3BMaW1pdCgpKTsNCiAgICAgICAgbmV3Q29ucy5zZXRU aW1lTGltaXQoY29ucy5nZXRUaW1lTGltaXQoKSk7DQogICAgICAgIG5ld0NvbnMuc2V0UmVmZXJy YWxIYW5kbGVyKGNvbnMuZ2V0UmVmZXJyYWxIYW5kbGVyKCkpOw0KICAgICAgICBuZXdDb25zLnNl dFJlZmVycmFsRm9sbG93aW5nKGNvbnMuZ2V0UmVmZXJyYWxGb2xsb3dpbmcoKSk7DQogICAgICAg IExEQVBDb250cm9sW10gbHNjID0gY29ucy5nZXRDb250cm9scygpOw0KICAgICAgICBpZiggbHNj ICE9IG51bGwpIHsNCiAgICAgICAgICAgIG5ld0NvbnMuc2V0Q29udHJvbHMoIGxzYyk7DQogICAg ICAgIH0NCiAgIC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WNlKCBEZWJ1Zy5hcGlS ZXF1ZXN0cywgbmFtZSArICJzdGFydFRMUygpIik7DQogICAgICAgIH0NCg0KDQogICAgICAgIExE QVBNZXNzYWdlIHN0YXJ0VExTID0gbWFrZUV4dGVuZGVkT3BlcmF0aW9uKA0KICAgICAgICAgICAg ICAgIG5ldyBMREFQRXh0ZW5kZWRPcGVyYXRpb24oIHRoaXMuU1RBUlRfVExTX09JRCwgbnVsbCAp LCBudWxsKTsNCg0KICAgICAgICBpbnQgdGxzSUQgPSBzdGFydFRMUy5nZXRNZXNzYWdlSUQoKTsN Cg0KICAgICAgICBjb25uLmFjcXVpcmVXcml0ZVNlbWFwaG9yZSggdGxzSUQgKTsNCiAgICAgICAg dHJ5IHsNCiAgICAgICAgICAgIGlmICghY29ubi5hcmVNZXNzYWdlc0NvbXBsZXRlKCkpew0KICAg ICAgICAgICAgICAgIHRocm93IG5ldyBMREFQTG9jYWxFeGNlcHRpb24oDQogICAgICAgICAgICAg ICAgICAgICAgICBFeGNlcHRpb25NZXNzYWdlcy5PVVRTVEFORElOR19PUEVSQVRJT05TLA0KICAg ICAgICAgICAgICAgICAgICAgICAgTERBUEV4Y2VwdGlvbi5PUEVSQVRJT05TX0VSUk9SICk7DQog ICAgICAgICAgICB9DQoNCiAgICAgICAgICAgIC8vIFN0b3AgcmVhZGVyIHdoZW4gcmVzcG9uc2Ug dG8gc3RhcnRUTFMgcmVxdWVzdCByZWNlaXZlZA0KICAgICAgICAgICAgY29ubi5zdG9wUmVhZGVy T25SZXBseSggdGxzSUQgKTsNCg0KICAgICAgICAgICAgLy8gc2VuZCB0bHMgbWVzc2FnZQ0KICAg ICAgICAgICAgTERBUFJlc3BvbnNlUXVldWUgcXVldWUgPQ0KICAgICAgICAgICAgICAgICAgICBz ZW5kUmVxdWVzdFRvU2VydmVyKA0KICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRUTFMsDQog ICAgICAgICAgICAgICAgICAgICAgICBkZWZTZWFyY2hDb25zLmdldFRpbWVMaW1pdCgpLCBudWxs LCBudWxsICk7DQoNCiAgICAgICAgICAgIExEQVBFeHRlbmRlZFJlc3BvbnNlIHJlc3BvbnNlID0N CiAgICAgICAgICAgICAgICAgICAgKExEQVBFeHRlbmRlZFJlc3BvbnNlKSBxdWV1ZS5nZXRSZXNw b25zZSgpOw0KICAgICAgICAgICAgcmVzcG9uc2UuY2hrUmVzdWx0Q29kZSgpOw0KDQogICAgICAg ICAgICBjb25uLnN0YXJ0VExTKCk7DQogICAgICAgIH0NCiAgICAgICAgZmluYWxseSB7DQogICAg ICAgICAgICAvL0ZyZWUgdGhpcyBzZW1hcGhvcmUgbm8gbWF0dGVyIHdoYXQgZXhjZXB0aW9ucyBn ZXQgdGhyb3duDQogICAgICAgICAgICBjb25uLnN0YXJ0UmVhZGVyKCk7DQogICAgICAgICAgICBj b25uLmZyZWVXcml0ZVNlbWFwaG9yZSggdGxzSUQgKSA7DQogICAgICAgIH0NCiAgICAgICAgcmV0 dXJuOw0KICAgIH0NCg0KICAgIC8qKg0KICAgICAqIFN0b3BzIFRyYW5zcG9ydCBMYXllciBTZWN1 cml0eShUTFMpIG9uIHRoZSBMREFQQ29ubmVjdGlvbiBhbmQgcmV2ZXJ0cw0KICAgICAqIGJhY2sg dG8gYW4gYW5vbnltb3VzIHN0YXRlLg0KICAgICAqDQogICAgICogQHRocm93cyBMREFQRXhjZXB0 aW9uIFRoaXMgY2FuIG9jY3VyIGZvciB0aGUgZm9sbG93aW5nIHJlYXNvbnM6IDxVTD4NCiAgICAg KiAgICAgICAgICA8TEk+U3RhcnRUTFMgaGFzIG5vdCBiZWVuIGNhbGxlZCBiZWZvcmUgc3RvcFRM Uw0KICAgICAqICAgICAgICAgIDxMST5UaGVyZSBleGlzdHMgb3V0c3RhbmRpbmcgbWVzc2FnZXMg dGhhdCBoYXZlIG5vdCByZWNlaXZlZCBhbGwNCiAgICAgKiAgICAgICAgICByZXNwb25zZXMNCiAg ICAgKiAgICAgICAgICA8TEk+VG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DQog ICAgICAgICAgICAgICAgICAgICAgICBFeGNlcHRpb25NZXNzYWdlcy5PVVRTVEFORElOR19PUEVS QVRJT05TLA0KICAgICAgICAgICAgICAgICAgICAgICAgTERBUEV4Y2VwdGlvbi5PUEVSQVRJT05T X0VSUk9SICk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICAvL3N0b3BUTFMgc3RvcHMgYW5k IHN0YXJ0cyB0aGUgcmVhZGVyIHRocmVhZCBmb3IgdXMuDQogICAgICAgICAgICBjb25uLnN0b3BU TFMoKTsNCiAgICAgICAgfQ0KICAgICAgICBmaW5hbGx5IHsNCiAgICAgICAgICAgIGNvbm4uZnJl ZVdyaXRlU2VtYXBob3JlKHNlbWFwaG9yZUlEKTsNCiAgICAgICAgfQ0KICAgICAgICByZXR1cm47 DQogICAgfQ0KICAgIC8vKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIC8vIEJlbG93IGFyZSBhbGwgb2Yg dGhlIExEQVAgcHJvdG9jb2wgb3BlcmF0aW9uIG1ldGhvZHMNCiAgICAvLyoqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioNCg0KICAgIC8vKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIC8vIGFiYW5kb24gbWV0aG9kcw0KICAg IC8vKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKg0KDQogICAgLyoqDQogICAgICoNCiAgICAgKg0KICAgICAqIE5v dGlmaWVzIHRoZSBzZXJ2ZXIgbm90IHRvIHNlbmQgYWRkaXRpb25hbCByZXN1bHRzIGFzc29jaWF0 ZWQgd2l0aA0KICAgICAqIHRoaXMgTERBUFNlYXJjaFJlc3VsdHMgb2JqZWN0LCBhbmQgZGlzY2Fy ZHMgYW55IHJlc3VsdHMgYWxyZWFkeQ0KICAgICAqIHJlY2VpdmVkLg0KICAgICAqDQogICAgICog IEBwYXJhbSByZXN1bHRzICAgQW4gb2JqZWN0IHJldHVybmVkIGZyb20gYSBzZWFyY2guDQogICAg ICoNCiAgICAgKiAgQGV4Y2VwdGlvbiBMREFQRXhjZXB0aW9uIEEgZ2VuZXJhbCBleGNlcHRpb24g d2hpY2ggaW5jbHVkZXMgYW4gZXJyb3INCiAgICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAg IG1lc3NhZ2UgYW5kIGFuIExEQVAgZXJyb3IgY29kZS4NCiAgICAgKi8NCiAgICBwdWJsaWMgdm9p ZCBhYmFuZG9uKExEQVBTZWFyY2hSZXN1bHRzIHJlc3VsdHMpDQogICAgICAgIHRocm93cyBMREFQ RXhjZXB0aW9uDQogICAgew0KICAgICAgICBhYmFuZG9uKCByZXN1bHRzLCBkZWZTZWFyY2hDb25z ICk7DQogICAgICAgIHJldHVybjsNCiAgICB9DQoNCiAgICAvKioNCiAgICAgKg0KICAgICAqDQog ICAgICogTm90aWZpZXMgdGhlIHNlcnZlciBub3QgdG8gc2VuZCBhZGRpdGlvbmFsIHJlc3VsdHMg YXNzb2NpYXRlZCB3aXRoDQogICAgICogdGhpcyBMREFQU2VhcmNoUmVzdWx0cyBvYmplY3QsIGFu ZCBkaXNjYXJkcyBhbnkgcmVzdWx0cyBhbHJlYWR5DQogICAgICogcmVjZWl2ZWQuDQogICAgICoN CiAgICAgKiAgQHBhcmFtIHJlc3VsdHMgICBBbiBvYmplY3QgcmV0dXJuZWQgZnJvbSBhIHNlYXJj aC4NCiAgICAgKjxicj48YnI+DQogICAgICogIEBwYXJhbSBjb25zICAgICBUaGUgY29udHJhaW50 cyBzcGVjaWZpYyB0byB0aGUgb3BlcmF0aW9uLg0KICAgICAqDQogICAgICogIEBleGNlcHRpb24g TERBUEV4Y2VwdGlvbiBBIGdlbmVyYWwgZXhjZXB0aW9uIHdoaWNoIGluY2x1ZGVzIGFuIGVycm9y DQogICAgICogICAgICAgICAgICAgICAgICAgICAgICAgICBtZXNzYWdlIGFuZCBhbiBMREFQIGVy cm9yIGNvZGUuDQogICAgICovDQogICAgcHVibGljIHZvaWQgYWJhbmRvbihMREFQU2VhcmNoUmVz dWx0cyByZXN1bHRzLCBMREFQQ29uc3RyYWludHMgY29ucykNCiAgICAgICAgdGhyb3dzIExEQVBF eGNlcHRpb24NCiAgICB7DQogICAgICAgIHJlc3VsdHMuYWJhbmRvbigpOw0KICAgICAgICByZXR1 cm47DQogICAgfQ0KDQogICAgLyoqDQogICAgICoNCiAgICAgKiAgQWJhbmRvbnMgYW4gYXN5bmNo cm9ub3VzIG9wZXJhdGlvbi4NCiAgICAgKg0KICAgICAqICBAcGFyYW0gaWQgICAgICBUaGUgSUQg b2YgdGhlIGFzeW5jaHJvbm91cyBvcGVyYXRpb24gdG8gYWJhbmRvbi4gVGhlIElEDQogICAgICog ICAgICAgICAgICAgICAgIGNhbiBiZSBvYnRhaW5lZCBmcm9tIHRoZSByZXNwb25zZSBxdWV1ZSBm b3IgdGhlDQogICAgICogICAgICAgICAgICAgICAgIG9wZXJhdGlvbi4NCiAgICAgKg0KICAgICAq ICBAZXhjZXB0aW9uIExEQVBFeGNlcHRpb24gQSBnZW5lcmFsIGV4Y2VwdGlvbiB3aGljaCBpbmNs dWRlcyBhbiBlcnJvcg0KICAgICAqICBtZXNzYWdlIGFuZCBhbiBMREFQIGVycm9yIGNvZGUuDQog ICAgICovDQogICAgcHVibGljIHZvaWQgYWJhbmRvbihpbnQgaWQpDQogICAgICAgIHRocm93cyBM REFQRXhjZXB0aW9uDQogICAgew0KICAgICAgICBhYmFuZG9uKGlkLCBkZWZTZWFyY2hDb25zKTsN CiAgICAgICAgcmV0dXJuOw0KICAgIH0NCg0KICAgIC8qKg0KICAgICAqICBBYmFuZG9ucyBhbiBh c3luY2hyb25vdXMgb3BlcmF0aW9uLCB1c2luZyB0aGUgc3BlY2lmaWVkDQogICAgICogIGNvbnN0 cmFpbnRzLg0KICAgICAqDQogICAgICogIEBwYXJhbSBpZCBUaGUgSUQgb2YgdGhlIGFzeW5jaHJv bm91cyBvcGVyYXRpb24gdG8gYWJhbmRvbi4NCiAgICAgKiAgICAgICAgICAgIFRoZSBJRCBjYW4g YmUgb2J0YWluZWQgZnJvbSB0aGUgc2VhcmNoDQogICAgICogICAgICAgICAgICBxdWV1ZSBmb3Ig dGhlIG9wZXJhdGlvbi4NCiAgICAgKjxicj48YnI+DQogICAgICogIEBwYXJhbSBjb25zIFRoZSBj b250cmFpbnRzIHNwZWNpZmljIHRvIHRoZSBvcGVyYXRpb24uDQogICAgICoNCiAgICAgKiAgQGV4 Y2VwdGlvbiBMREFQRXhjZXB0aW9uIEEgZ2VuZXJhbCBleGNlcHRpb24gd2hpY2ggaW5jbHVkZXMg YW4gZXJyb3INCiAgICAgKiAgbWVzc2FnZSBhbmQgYW4gTERBUCBlcnJvciBjb2RlLg0KICAgICAq Lw0KICAgIHB1YmxpYyB2b2lkIGFiYW5kb24oaW50IGlkLCBMREFQQ29uc3RyYWludHMgY29ucykN CiAgICAgICAgdGhyb3dzIExEQVBFeGNlcHRpb24NCiAgICB7DQogICAgICAgIC8vIFdlIG5lZWQg dG8gaW5mb3JtIHRoZSBNZXNzYWdlIEFnZW50IHdoaWNoIG93bnMgdGhpcyBtZXNzYWdlSUQgdG8N CiAgICAgICAgLy8gcmVtb3ZlIGl0IGZyb20gdGhlIHF1ZXVlLg0KICAgICAgICB0cnkgew0KICAg ICAgICAgICAgTWVzc2FnZUFnZW50IGFnZW50ID0gY29ubi5nZXRNZXNzYWdlQWdlbnQoaWQpOw0K ICAgICAgICAgICAgaWYoIERlYnVnLkxEQVBfREVCVUcpIHsNCiAgICAgICAgICAgICAgICBEZWJ1 Zy50cmFjZSggRGVidWcuYXBpUmVxdWVzdHMsIG5hbWUgKw0KICAgICAgICAgICAgICAgICJhYmFu ZG9uKCIgKyBpZCArICIpIik7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBhZ2VudC5hYmFu ZG9uKGlkLCBjb25zKTsNCiAgICAgICAgICAgIHJldHVybjsNCiAgICAgICAgfSBjYXRjaCggTm9T dWNoRmllbGRFeGNlcHRpb24gZXgpIHsNCiAgICAgICAgICAgIGlmKCBEZWJ1Zy5MREFQX0RFQlVH KSB7DQogICAgICAgICAgICAgICAgRGVidWcudHJhY2UoIERlYnVnLmFwaVJlcXVlc3RzLCBuYW1l ICsNCiAgICAgICAgICAgICAgICAiYWJhbmRvbigiICsgaWQgKyAiKSwgYWdlbnQgbm90IGZvdW5k Iik7DQogICAgICAgICAgICB9DQogICAgICAgICAgICByZXR1cm47IC8vIElnbm9yZSBlcnJvcg0K ICAgICAgICB9DQogICAgfQ0KDQogICAgLyoqDQogICAgICogQWJhbmRvbnMgYWxsIG91dHN0YW5k aW5nIG9wZXJhdGlvbnMgbWFuYWdlZCBieSB0aGUgcXVldWUuDQogICAgICoNCiAgICAgKiA8cD5B bGwgb3BlcmF0aW9ucyBpbiBwcm9ncmVzcywgd2hpY2ggYXJlIG1hbmFnZWQgYnkgdGhlIHNwZWNp ZmllZCBxdWV1ZSwNCiAgICAgKiBhcmUgYWJhbmRvbmVkLjwvcD4NCiAgICAgKg0KICAgICAqICBA cGFyYW0gcXVldWUgICAgIFRoZSBxdWV1ZSByZXR1cm5lZCBmcm9tIGFuIGFzeW5jaHJvbm91cyBy ZXF1ZXN0Lg0KICAgICAqICAgICAgICAgICAgICAgICAgIEFsbCBvdXRzdGFuZGluZyBvcGVyYXRp b25zIG1hbmFnZWQgYnkgdGhlIHF1ZXVlDQogICAgICogICAgICAgICAgICAgICAgICAgYXJlIGFi YW5kb25lZCwgYW5kIHRoZSBxdWV1ZSBpcyBlbXB0aWVkLg0KICAgICAqDQogICAgICogIEBleGNl cHRpb24gTERBUEV4Y2VwdGlvbiBBIGdlbmVyYWwgZXhjZXB0aW9uIHdoaWNoIG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SBhbmQgYW4gTERBUCBlcnJvciBjb2RlLg0KICAgICAqLw0KICAgIHB1Ymxp YyB2b2lkIGFiYW5kb24oIExEQVBNZXNzYWdlUXVldWUgcXVldWUsIExEQVBDb25zdHJhaW50cyBj b25zKQ0KICAgICAgICB0aHJvd3MgTERBUEV4Y2VwdGlvbg0KICAgIHsNCiAgICAgICAgaWYoIERl YnVnLkxEQVBfREVCVUcpIHsNCiAgICAgICAgICAgIERlYnVnLnRyYWNlKCBEZWJ1Zy5hcGlSZXF1 ZXN0cywgbmFtZSArDQogICAgICAgICAgICAiYWJhbmRvbihxdWV1ZSkiKTsNCiAgICAgICAgfQ0K ICAgICAgICBpZihxdWV1ZSAhPSBudWxsKSB7DQogICAgICAgICAgICBNZXNzYWdlQWdlbnQgYWdl bnQ7DQogICAgICAgICAgICBpZiggcXVldWUgaW5zdGFuY2VvZiBMREFQU2VhcmNoUXVldWUpIHsN CiAgICAgICAgICAgICAgICBhZ2VudCA9IHF1ZXVlLmdldE1lc3NhZ2VBZ2VudCgpOw0KICAgICAg ICAgICAgfSBlbHNlIHsNCiAgICAgICAgICAgICAgICBhZ2VudCA9IHF1ZXVlLmdldE1lc3NhZ2VB Z2VudCgpOw0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgaW50W10gbXNnSWRzID0gYWdlbnQu Z2V0TWVzc2FnZUlEcygpOw0KICAgICAgICAgICAgZm9yKGludCBpPTA7IGk8bXNnSWRzLmxlbmd0 aDsgaSsrKSB7DQogICAgICAgICAgICAgICAgYWdlbnQuYWJhbmRvbihtc2dJZHNbaV0sIGNvbnMp Ow0KICAgICAgICAgICAgfQ0KICAgICAgICB9DQogICAgICAgIHJldHVybjsNCiAgICB9DQoNCiAg ICAvLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioNCiAgICAvLyBhZGQgbWV0aG9kcw0KICAgIC8vKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKg0KDQogICAgLyoqDQogICAgICogU3luY2hyb25vdXNseSBhZGRzIGFuIGVudHJ5IHRv IHRoZSBkaXJlY3RvcnkuDQogICAgICoNCiAgICAgKiBAcGFyYW0gZW50cnkgICAgTERBUEVudHJ5 IG9iamVjdCBzcGVjaWZ5aW5nIHRoZSBkaXN0aW5ndWlzaGVkDQogICAgICogICAgICAgICAgICAg ICAgIG5hbWUgYW5kIGF0dHJpYnV0ZXMgb2YgdGhlIG5ldyBlbnRyeS4NCiAgICAgKg0KICAgICAq ICBAZXhjZXB0aW9uIExEQVBFeGNlcHRpb24gQSBnZW5lcmFsIGV4Y2VwdGlvbiB3aGljaCBpbmNs dWRlcyBhbiBlcnJvcg0KICAgICAqICBtZXNzYWdlIGFuZCBhbiBMREFQIGVycm9yIGNvZGUuDQog ICAgICovDQogICAgcHVibGljIHZvaWQgYWRkKExEQVBFbnRyeSBlbnRyeSkNCiAgICAgICAgdGhy b3dzIExEQVBFeGNlcHRpb24NCiAgICB7DQogICAgICAgIGFkZChlbnRyeSwgZGVmU2VhcmNoQ29u cyk7DQogICAgICAgIHJldHVybjsNCiAgICB9DQoNCiAgICAgLyoqDQogICAgICoNCiAgICAgKiBT eW5jaHJvbm91c2x5IGFkZHMgYW4gZW50cnkgdG8gdGhlIGRpcmVjdG9yeSwgdXNpbmcgdGhlIHNw ZWNpZmllZA0KICAgICAqIGNvbnN0cmFpbnRzLg0KICAgICAqDQogICAgICogIEBwYXJhbSBlbnRy eSAgIExEQVBFbnRyeSBvYmplY3Qgc3BlY2lmeWluZyB0aGUgZGlzdGluZ3Vpc2hlZA0KICAgICAq ICAgICAgICAgICAgICAgICBuYW1lIGFuZCBhdHRyaWJ1dGVzIG9mIHRoZSBuZXcgZW50cnkuDQog ICAgICo8YnI+PGJyPg0KICAgICAqICBAcGFyYW0gY29ucyAgICBDb25zdHJhaW50cyBzcGVjaWZp YyB0byB0aGUgb3BlcmF0aW9uLg0KICAgICAqDQogICAgICogIEBleGNlcHRpb24gTERBUEV4Y2Vw dGlvbiBBIGdlbmVyYWwgZXhjZXB0aW9uIHdoaWNoIGluY2x1ZGVzIGFuIGVycm9yDQogICAgICog IG1lc3NhZ2UgYW5kIGFuIExEQVAgZXJyb3IgY29kZS4NCiAgICAgKi8NCg0KICAgIHB1YmxpYyB2 b2lkIGFkZChMREFQRW50cnkgZW50cnksDQogICAgICAgICAgICAgICAgICAgIExEQVBDb25zdHJh aW50cyBjb25zKQ0KICAgICAgICB0aHJvd3MgTERBUEV4Y2VwdGlvbg0KICAgIHsNCiAgICAgICAg TERBUFJlc3BvbnNlUXVldWUgcXVldWUgPSBhZGQoZW50cnksIG51bGwsIGNvbnMpOw0KDQogICAg ICAgIC8vIEdldCBhIGhhbmRsZSB0byB0aGUgYWRkIHJlc3BvbnNlDQogICAgICAgIExEQVBSZXNw b25zZSBhZGRSZXNwb25zZSA9IChMREFQUmVzcG9uc2UpKHF1ZXVlLmdldFJlc3BvbnNlKCkpOw0K DQogICAgICAgIC8vIFNldCBsb2NhbCBjb3B5IG9mIHJlc3BvbnNlQ29udHJvbHMgc3luY2hyb25v dXNseSBpZiB0aGVyZSB3ZXJlIGFueQ0KICAgICAgICBzeW5jaHJvbml6ZWQgKHJlc3BvbnNlQ3Rs U2VtYXBob3JlKSB7DQogICAgICAgICAgICByZXNwb25zZUN0bHMgPSBhZGRSZXNwb25zZS5nZXRD b250cm9scygpOw0KICAgICAgICB9DQogICAgICAgIGNoa1Jlc3VsdENvZGUoIHF1ZXVlLCBjb25z LCBhZGRSZXNwb25zZSk7DQogICAgICAgIHJldHVybjsNCiAgICB9DQoNCiAgICAvKioNCiAgICAg KiBBc3luY2hyb25vdXNseSBhZGRzIGFuIGVudHJ5IHRvIHRoZSBkaXJlY3RvcnkuDQogICAgICoN CiAgICAgKiAgQHBhcmFtIGVudHJ5ICAgTERBUEVudHJ5IG9iamVjdCBzcGVjaWZ5aW5n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lidXRlcyBvZiB0aGUgbmV3IGVudHJ5Lg0KICAgICAqPGJyPjxi cj4NCiAgICAgKiAgQHBhcmFtIHF1ZXVlICBIYW5kbGVyIGZvciBtZXNzYWdlcyByZXR1cm5lZCBm cm9tIGEgc2VydmVyIGluDQogICAgICogICAgICAgICAgICAgICAgcmVzcG9uc2UgdG8gdGhpcyBy ZXF1ZXN0LiBJZiBpdCBpcyBudWxsLCBhDQogICAgICogICAgICAgICAgICAgICAgcXVldWUgb2Jq ZWN0IGlzIGNyZWF0ZWQgaW50ZXJuYWxseS4NCiAgICAgKjxicj48YnI+DQogICAgICogIEBwYXJh bSBjb25zICAgQ29uc3RyYWludHMgc3BlY2lmaWMgdG8gdGhlIG9wZXJhdGlvbi4NCiAgICAgKg0K ICAgICAqICBAZXhjZXB0aW9uIExEQVBFeGNlcHRpb24gQSBnZW5lcmFsIGV4Y2VwdGlvbiB3aGlj aCBpbmNsdWRlcyBhbiBlcnJvcg0KICAgICAqICBtZXNzYWdlIGFuZCBhbiBMREFQIGVycm9yIGNv ZGUuDQogICAgICovDQogICAgcHVibGljIExEQVBSZXNwb25zZVF1ZXVlIGFkZChMREFQRW50cnkg ZW50cnksDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBMREFQUmVzcG9uc2VRdWV1 ZSBxdWV1ZSwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIExEQVBDb25zdHJhaW50 cyBjb25zKQ0KICAgICAgICB0aHJvd3MgTERBUEV4Y2VwdGlvbg0KICAgIHsNCiAgICAgICAgaWYo IERlYnVnLkxEQVBfREVCVUcpIHsNCiAgICAgICAgICAgIERlYnVnLnRyYWNlKCBEZWJ1Zy5hcGlS ZXF1ZXN0cywgbmFtZSArDQogICAgICAgICAgICAiYWRkKCkiKTsNCiAgICAgICAgfQ0KICAgICAg ICBpZihjb25zID09IG51bGwpDQogICAgICAgICAgICBjb25zID0gZGVmU2VhcmNoQ29uczsNCg0K ICAgICAgICAvLyBlcnJvciBjaGVjayB0aGUgcGFyYW1ldGVycw0KICAgICAgICBpZihlbnRyeSA9 PSBudWxsICkgew0KICAgICAgICAgICAgdGhyb3cgbmV3IElsbGVnYWxBcmd1bWVudEV4Y2VwdGlv bigiVGhlIExEQVBFbnRyeSBwYXJhbWV0ZXIiICsNCiAgICAgICAgICAgICAgICAgICAgICAgICIg Y2Fubm90IGJlIG51bGwiKTsNCiAgICAgICAgfQ0KICAgICAgICBpZiggZW50cnkuZ2V0RE4oKSA9 PSBudWxsKSB7DQogICAgICAgICAgICB0aHJvdyBuZXcgSWxsZWdhbEFyZ3VtZW50RXhjZXB0aW9u KCJUaGUgRE4gdmFsdWUgbXVzdCBiZSBwcmVzZW50IiArDQogICAgICAgICAgICAgICAgICAgICAg ICAiIGluIHRoZSBMREFQRW50cnkgb2JqZWN0Iik7DQogICAgICAgIH0NCg0KICAgICAgICBMREFQ TWVzc2FnZSBtc2cgPSBuZXcgTERBUEFkZFJlcXVlc3QoIGVudHJ5LCBjb25zLmdldENvbnRyb2xz KCkpOw0KDQogICAgICAgIHJldHVybiBzZW5kUmVxdWVzdFRvU2VydmVyKG1zZywgY29ucy5nZXRU aW1lTGltaXQoKSwgcXVldWUsIG51bGwpOw0KICAgIH0NCg0KICAgIC8vKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq Kg0KICAgIC8vIGJpbmQgbWV0aG9kcw0KICAgIC8vKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KDQogICAgLyoq DQogICAgICogU3luY2hyb25vdXNseSBhdXRoZW50aWNhdGVzIHRvIHRoZSBMREFQIHNlcnZlciAo dGhhdCB0aGUgb2JqZWN0IGlzDQogICAgICogY3VycmVudGx5IGNvbm5lY3RlZCB0bykgYXMgYW4g TERBUHYzIGJpbmQsIHVzaW5nIHRoZSBzcGVjaWZpZWQg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XBwbGljYXRpb24gc2hvdWxkIHVzZSBjYXJlIGluIHRoZSB1c2UNCiAgICAgKiAg ICAgICAgICAgICAgICAgb2YgU3RyaW5nIHBhc3N3b3JkIG9iamVjdHMuICBUaGVzZSBhcmUgbG9u ZyBsaXZlZA0KICAgICAqICAgICAgICAgICAgICAgICBvYmplY3RzLCBhbmQgbWF5IGV4cG9zZSBh IHNlY3VyaXR5IHJpc2ssIGVzcGVjaWFsbHkNCiAgICAgKiAgICAgICAgICAgICAgICAgaW4gb2Jq ZWN0cyB0aGF0IGFyZSBzZXJpYWxpemVkLiAgVGhlIExEQVBDb25uZWN0aW9uDQogICAgICogICAg ICAgICAgICAgICAgIGtlZXBzIG5vIGxvbmcgbGl2ZWQgaW5zdGFuY2VzIG9mIHRoZXNlIG9iamVj dHMuDQogICAgICoNCiAgICAgKiAgQGV4Y2VwdGlvbiBMREFQRXhjZXB0aW9uIEEgZ2VuZXJhbCBl eGNlcHRpb24gd2hpY2ggaW5jbHVkZXMgYW4gZXJyb3INCiAgICAgKiAgbWVzc2FnZSBhbmQgYW4g TERBUCBlcnJvciBjb2RlLg0KICAgICAqDQogICAgICogQGRlcHJlY2F0ZWQgcmVwbGFjZWQgYnkg e0BsaW5rICNiaW5kKGludCwgU3RyaW5nLCBieXRlW10pfQ0KICAgICAqLw0KICAgIHB1YmxpYyB2 b2lkIGJpbmQoU3RyaW5nIGRuLA0KICAgICAgICAgICAgICAgICAgICAgU3RyaW5nIHBhc3N3ZCkN CiAgICAgICAgdGhyb3dzIExEQVBFeGNlcHRpb24NCiAgICB7DQogICAgICAgIGJpbmQoIExEQVBf VjMsIGRuLCBwYXNzd2QsIGRlZlNlYXJjaENvbnMpOw0KICAgICAgICByZXR1cm47DQogICAgfQ0K DQogICAgLyoqDQogICAgICogU3luY2hyb25vdXNseSBhdXRoZW50aWNhdGVzIHRvIHRoZSBMREFQ IHNlcnZlciAodGhhdCB0aGUgb2JqZWN0IGlzDQogICAgICogY3VycmVudGx5IGNvb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zaG91bGQNCiAgICAgKiAgICAgICAgICAgICAgICAgYmUg YXV0aGVudGljYXRlZCB3aXRoIGRuIGFzIHRoZSBkaXN0aW5ndWlzaGVkDQogICAgICogICAgICAg ICAgICAgICAgIG5hbWUgYW5kIHBhc3N3ZCBhcyBwYXNzd29yZC4NCiAgICAgKjxicj48YnI+DQog ICAgICogICAgICAgICAgICAgICAgIE5vdGU6IHRoZSBhcHBsaWNhdGlvbiBzaG91bGQgdXNlIGNh cmUgaW4gdGhlIHVzZQ0KICAgICAqICAgICAgICAgICAgICAgICBvZiBTdHJpbmcgcGFzc3dvcmQg b2JqZWN0cy4gIFRoZXNlIGFyZSBsb25nIGxpdmVkDQogICAgICogICAgICAgICAgICAgICAgIG9i amVjdHMsIGFuZCBtYXkgZXhwb3NlIGEgc2VjdXJpdHkgcmlzaywgZXNwZWNpYWxseQ0KICAgICAq ICAgICAgICAgICAgICAgICBpbiBvYmplY3RzIHRoYXQgYXJlIHNlcmlhbGl6ZWQuICBUaGUgTERB UENvbm5lY3Rpb24NCiAgICAgKiAgICAgICAgICAgICAgICAga2VlcHMgbm8gbG9uZyBsaXZlZCBp bnN0YW5jZXMgb2YgdGhlc2Ugb2JqZWN0cy4NCiAgICAgKg0KICAgICAqICBAZXhjZXB0aW9uIExE QVBFeGNlcHRpb24gQSBnZW5lcmFsIGV4Y2VwdGlvbiB3aGljaCBpbmNsdWRlcyBhbiBlcnJvcg0K ICAgICAqICBtZXNzYWdlIGFuZCBhbiBMREFQIGVycm9yIGNvZGUuDQogICAgICoNCiAgICAgKiBA ZGVwcmVjYXRlZCByZXBsYWNlZCBieSB7QGxpbmsgI2JpbmQoaW50LCBTdHJpbmcsIGJ5dGVbXSl9 DQogICAgICovDQogICAgcHVibGljIHZvaWQgYmluZChpbnQgdmVyc2lvbiwNCiAgICAgICAgICAg ICAgICAgICAgIFN0cmluZyBkbiwNCiAgICAgICAgICAgICAgICAgICAgIFN0cmluZyBwYXNzd2Qp DQogICAgICAgIHRocm93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ZWQgcmVwbGFjZWQgYnkge0BsaW5rICNiaW5kKGludCwgU3RyaW5nLCBi eXRlW10sIExEQVBDb25zdHJhaW50cyl9DQogICAgICovDQogICAgcHVibGljIHZvaWQgYmluZChT dHJpbmcgZG4sDQogICAgICAgICAgICAgICAgICAgICBTdHJpbmcgcGFzc3dkLA0KICAgICAgICAg ICAgICAgICAgICAgTERBUENvbnN0cmFpbnRzIGNvbnMpDQogICAgICAgICAgICAgICAgICAgICB0 aHJvd3MgTERBUEV4Y2VwdGlvbg0KICAgIHsNCiAgICAgICAgYmluZCggTERBUF9WMywgZG4sIHBh c3N3ZCwgY29ucyk7DQogICAgICAgIHJldHVybjsNCiAgICB9DQoNCiAgICAvKioNCiAgICAgKiBT eW5jaHJvbm91c2x5IGF1dGhlbnRpY2F0ZXMgdG8gdGhlIExEQVAgc2VydmVyICh0aGF0IHRoZSBv YmplY3QgaXMNCiAgICAgKiBjdXJyZW50bHkgY29ubmVjdGVkIHRvKSB1c2luZyB0aGUgc3BlY2lm aWVkIG5hbWUsIHBhc3N3b3JkLCBMREFQIHZlcnNpb24sDQogICAgICogYW5kIGNvbnN0cmFpbnRz Lg0KICAgICAqDQogICAgICogPHA+SWYgdGhlIG9iamVjdCBoYXMgYmVlbiBkaXNjb25uZWN0ZWQg ZnJvbSBhbiBMREFQIHNlcnZlciwNCiAgICAgKiB0aGlzIG1ldGhvZCBhdHRlbXB0cyB0byByZWNv bm5lY3QgdG8gdGhlIHNlcnZlci4gSWYgdGhlIG9iamVjdA0KICAgICAqIGhhcyBhbHJlYWR5IGF1 dGhlbnRpY2F0ZWQsIHRoZSBvbGQgYXV0aGVudGljYXRpb24gaXMgZGlzY2FyZGVkLjwvcD4NCiAg ICAgKg0KICAgICAqICBAcGFyYW0gdmVyc2lvbiAgVGhlIExEQVAgcHJvdG9jb2wgdmVyc2lvbiwg dXNlIExEQVBfVjMuDQogICAgICogICAgICAgICAgICAgICAgICBMREFQX1YyIGlzIG5vdCBzdXBw b3J0ZWQuDQogICAgICo8YnI+PGJyPg0KICAgICAqICBAcGFyYW0gZG4gICAgICAgSWYgbm9uLW51 bGwgYW5kIG5vbi1lbXB0eSwgc3BlY2lmaWVzIHRoYXQgdGhlDQogICAgICogICAgICAgICAgICAg ICAgICBjb25uZWN0aW9uIGFuZCBhbGwgb3BlcmF0aW9ucyB0aHJvdWdoIGl0IHNob3VsZA0KICAg ICAqICAgICAgICAgICAgICAgICAgYmUgYXV0aGVudGljYXRlZCB3aXRoIGRuIGFzIHRoZSBkaXN0 aW5ndWlzaGVkDQogICAgICogICAgICAgICAgICAgICAgICBuYW1lLg0KICAgICAqPGJyPjxicj4N CiAgICAgKiAgQHBhcmFtIHBhc3N3ZCAgSWYgbm9uLW51bGwgYW5kIG5vbi1lbXB0eSwgc3BlY2lm aWVzIHRoYXQgdGhlDQogICAgICogICAgICAgICAgICAgICAgIGNvbm5lY3Rpb24gYW5kIGFsbCBv cGVyYXRpb25zIHRocm91Z2ggaXQgc2hvdWxkDQogICAgICogICAgICAgICAgICAgICAgIGJlIGF1 dGhlbnRpY2F0ZWQgd2l0aCBkbiBhcyB0aGUgZGlzdGluZ3Vpc2hlZA0KICAgICAqICAgICAgICAg ICAgICAgICBuYW1lIGFuZCBwYXNzd2QgYXMgcGFzc3dvcmQuDQogICAgICo8YnI+PGJyPg0KICAg ICAqICAgICAgICAgICAgICAgICBOb3RlOiB0aGUgYXBwbGljYXRpb24gc2hvdWxkIHVzZSBjYXJl IGluIHRoZSB1c2UNCiAgICAgKiAgICAgICAgICAgICAgICAgb2YgU3RyaW5nIHBhc3N3b3JkIG9i amVjdHMuICBUaGVzZSBhcmUgbG9uZyBsaXZlZA0KICAgICAqICAgICAgICAgICAgICAgICBvYmpl Y3RzLCBhbmQgbWF5IGV4cG9zZSBhIHNlY3VyaXR5IHJpc2ssIGVzcGVjaWFsbHkNCiAgICAgKiAg ICAgICAgICAgICAgICAgaW4gb2JqZWN0cyB0aGF0IGFyZSBzZXJpYWxpemVkLiAgVGhlIExEQVBD b25uZWN0aW9uDQogICAgICogICAgICAgICAgICAgICAgIGtlZXBzIG5vIGxvbmcgbGl2ZWQgaW5z dGFuY2VzIG9mIHRoZXNlIG9iamVjdHMuDQogICAgICo8YnI+PGJyPg0KICAgICAqICBAcGFyYW0g Y29ucyAgICBUaGUgY29uc3RyYWludHMgc3BlY2lmaWMgdG8gdGhlIG9wZXJhdGlvbi4NCiAgICAg Kg0KICAgICAqICBAZXhjZXB0aW9uIExEQVBFeGNlcHRpb24gQSBnZW5lcmFsIGV4Y2VwdGlvbiB3 aGljaCBpbmNsdWRlcyBhbiBlcnJvcg0KICAgICAqICBtZXNzYWdlIGFuZCBhbiBMREFQIGVycm9y IGNvZGUuDQogICAgICoNCiAgICAgKiBAZGVwcmVjYXRlZCByZXBsYWNlZCBieQ0KICAgICAqIHtA bGluayAjYmluZChpbnQsIFN0cmluZywgYnl0ZVtdLCBMREFQQ29uc3RyYWludHMpfQ0KICAgICAq Lw0KICAgIHB1YmxpYyB2b2lkIGJpbmQoaW50IHZlcnNpb24sDQogICAgICAgICAgICAgICAgICAg ICBTdHJpbmcgZG4sDQogICAgICAgICAgICAgICAgICAgICBTdHJpbmcgcGFzc3dkLA0KICAgICAg ICAgICAgICAgICAgICAgTERBUENvbnN0cmFpbnRzIGNvbnMpDQogICAgICAgIHRocm93cyBMREFQ RXhjZXB0aW9uDQogICAgew0KICAgICAgICBieXRlW10gcHcgPSBudWxsOw0KICAgICAgICBpZigg cGFzc3dkICE9IG51bGwpIHsNCiAgICAgICAgICAgIHRyeSB7DQogICAgICAgICAgICAgICAgcHcg PSBwYXNzd2QuZ2V0Qnl0ZXMoIlVURjgiKTsNCiAgICAgICAgICAgICAgICBwYXNzd2QgPSBudWxs OyAgLy8gS2VlcCBubyByZWZlcmVuY2UgdG8gU3RyaW5nIG9iamVjdA0KICAgICAgICAgICAgfSBj YXRjaCggVW5zdXBwb3J0ZWRFbmNvZGluZ0V4Y2VwdGlvbiBleCkgew0KICAg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wgYW5kIG5vbi1lbXB0eSwgc3BlY2lmaWVzIHRoYXQgdGhlDQogICAgICogICAg ICAgICAgICAgICAgIGNvbm5lY3Rpb24gYW5kIGFsbCBvcGVyYXRpb25zIHRocm91Z2ggaXQgc2hv dWxkDQogICAgICogICAgICAgICAgICAgICAgIGJlIGF1dGhlbnRpY2F0ZWQgd2l0aCBkbiBhcyB0 aGUgZGlzdGluZ3Vpc2hlZA0KICAgICAqICAgICAgICAgICAgICAgICBuYW1lLg0KICAgICAqPGJy Pjxicj4NCiAgICAgKiAgQHBhcmFtIHBhc3N3ZCAgSWYgbm9uLW51bGwgYW5kIG5vbi1lbXB0eSwg c3BlY2lmaWVzIHRoYXQgdGhlDQogICAgICogICAgICAgICAgICAgICAgIGNvbm5lY3Rpb24gYW5k IGFsbCBvcGVyYXRpb25zIHRocm91Z2ggaXQgc2hvdWxkDQogICAgICogICAgICAgICAgICAgICAg IGJlIGF1dGhlbnRpY2F0ZWQgd2l0aCBkbiBhcyB0aGUgZGlzdGluZ3Vpc2hlZA0KICAgICAqICAg ICAgICAgICAgICAgICBuYW1lIGFuZCBwYXNzd2QgYXMgcGFzc3dvcmQuDQogICAgICoNCiAgICAg KiAgQGV4Y2VwdGlvbiBMREFQRXhjZXB0aW9uIEEgZ2VuZXJhbCBleGNlcHRpb24gd2hpY2ggaW5j bHVkZXMgYW4gZXJyb3INCiAgICAgKiAgbWVzc2FnZSBhbmQgYW4gTERBUCBlcnJvciBjb2RlLg0K ICAgICAqLw0KICAgIHB1YmxpYyB2b2lkIGJpbmQoaW50IHZlcnNpb24sDQogICAgICAgICAgICAg ICAgICAgICBTdHJpbmcgZG4sDQogICAgICAgICAgICAgICAgICAgICBieXRlW10gcGFzc3dkKQ0K ICAgICAgICB0aHJvd3MgTERBUEV4Y2VwdGlvbg0KICAgIHsNCiAgICAgICAgYmluZCh2ZXJzaW9u LCBkbiwgcGFzc3dkLCBkZWZTZWFyY2hDb25zKTsNCiAgICAgICAgcmV0dXJuOw0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+DQogICAgICogIEBwYXJhbSBwYXNzd2QgIElmIG5vbi1u dWxsIGFuZCBub24tZW1wdHksIHNwZWNpZmllcyB0aGF0IHRoZQ0KICAgICAqICAgICAgICAgICAg ICAgICBjb25uZWN0aW9uIGFuZCBhbGwgb3BlcmF0aW9ucyB0aHJvdWdoIGl0IHNob3VsZA0KICAg ICAqICAgICAgICAgICAgICAgICBiZSBhdXRoZW50aWNhdGVkIHdpdGggZG4gYXMgdGhlIGRpc3Rp bmd1aXNoZWQNCiAgICAgKiAgICAgICAgICAgICAgICAgbmFtZSBhbmQgcGFzc3dkIGFzIHBhc3N3 b3JkLg0KICAgICAqPGJyPjxicj4NCiAgICAgKiAgQHBhcmFtIGNvbnMgICAgVGhlIGNvbnN0cmFp bnRzIHNwZWNpZmljIHRvIHRoZSBvcGVyYXRpb24uDQogICAgICoNCiAgICAgKiAgQGV4Y2VwdGlv biBMREFQRXhjZXB0aW9uIEEgZ2VuZXJhbCBleGNlcHRpb24gd2hpY2ggaW5jbHVkZXMgYW4gZXJy b3INCiAgICAgKiAgbWVzc2FnZSBhbmQgYW4gTERBUCBlcnJvciBjb2RlLg0KICAgICAqLw0KICAg IHB1YmxpYyB2b2lkIGJpbmQoaW50IHZlcnNpb24sDQogICAgICAgICAgICAgICAgICAgICBTdHJp bmcgZG4sDQogICAgICAgICAgICAgICAgICAgICBieXRlW10gcGFzc3dkLA0KICAgICAgICAgICAg ICAgICAgICAgTERBUENvbnN0cmFpbnRzIGNvbnMpDQogICAgICAgIHRocm93cyBMREFQRXhjZXB0 aW9uDQogICAgew0KICAgICAgICBMREFQUmVzcG9uc2VRdWV1ZSBxdWV1ZSA9DQogICAgICAgICAg ICBiaW5kKHZlcnNpb24sIGRuLCBwYXNzd2QsIG51bGwsIGNvbnMpOw0KICAgICAgICBMREFQUmVz cG9uc2UgcmVzID0gKExEQVBSZXNwb25zZSlxdWV1ZS5nZXRSZXNwb25zZSgpOw0KICAgICAgICBp ZiggcmVzICE9IG51bGwpI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nI+PGJyPg0KICAg ICAqICBAcGFyYW0gZG4gICAgICBJZiBub24tbnVsbCBhbmQgbm9uLWVtcHR5LCBzcGVjaWZpZXMg dGhhdCB0aGUNCiAgICAgKiAgICAgICAgICAgICAgICAgY29ubmVjdGlvbiBhbmQgYWxsIG9wZXJh dGlvbnMgdGhyb3VnaCBpdCBzaG91bGQNCiAgICAgKiAgICAgICAgICAgICAgICAgYmUgYXV0aGVu dGljYXRlZCB3aXRoIGRuIGFzIHRoZSBkaXN0aW5ndWlzaGVkDQogICAgICogICAgICAgICAgICAg ICAgIG5hbWUuDQogICAgICo8YnI+PGJyPg0KICAgICAqICBAcGFyYW0gcGFzc3dkICBJZiBub24t bnVsbCBhbmQgbm9uLWVtcHR5LCBzcGVjaWZpZXMgdGhhdCB0aGUNCiAgICAgKiAgICAgICAgICAg ICAgICAgY29ubmVjdGlvbiBhbmQgYWxsIG9wZXJhdGlvbnMgdGhyb3VnaCBpdCBzaG91bGQNCiAg ICAgKiAgICAgICAgICAgICAgICAgYmUgYXV0aGVudGljYXRlZCB3aXRoIGRuIGFzIHRoZSBkaXN0 aW5ndWlzaGVkDQogICAgICogICAgICAgICAgICAgICAgIG5hbWUgYW5kIHBhc3N3ZCBhcyBwYXNz d29yZC4NCiAgICAgKjxicj48YnI+DQogICAgICogIEBwYXJhbSBxdWV1ZSAgIEhhbmRsZXIgZm9y IG1lc3NhZ2VzIHJldHVybmVkIGZyb20gYSBzZXJ2ZXIgaW4NCiAgICAgKiAgICAgICAgICAgICAg ICAgcmVzcG9uc2UgdG8gdGhpcyByZXF1ZXN0LiBJZiBpdCBpcyBudWxsLCBhDQogICAgICogICAg ICAgICAgICAgICAgIHF1ZXVlIG9iamVjdCBpcyBjcmVhdGVkIGludGVybmFsbHkuDQogICAgICoN CiAgICAgKiAgQGV4Y2VwdGlvbiBMREFQRXhjZXB0aW9uIEEgZ2VuZXJhbCBleGNlcHRpb24gd2hp Y2ggaW5jbHVkZXMgYW4gZXJyb3INCiAgIC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Rv Y29sIHZlcnNpb24sIHVzZSBMREFQX1YzLg0KICAgICAqICAgICAgICAgICAgICAgICAgTERBUF9W MiBpcyBub3Qgc3VwcG9ydGVkLg0KICAgICAqIDxicj48YnI+DQogICAgICogIEBwYXJhbSBkbiAg ICAgIElmIG5vbi1udWxsIGFuZCBub24tZW1wdHksIHNwZWNpZmllcyB0aGF0IHRoZQ0KICAgICAq ICAgICAgICAgICAgICAgICBjb25uZWN0aW9uIGFuZCBhbGwgb3BlcmF0aW9ucyB0aHJvdWdoIGl0 IHNob3VsZA0KICAgICAqICAgICAgICAgICAgICAgICBiZSBhdXRoZW50aWNhdGVkIHdpdGggZG4g YXMgdGhlIGRpc3Rpbmd1aXNoZWQNCiAgICAgKiAgICAgICAgICAgICAgICAgbmFtZS4NCiAgICAg Kjxicj48YnI+DQogICAgICogIEBwYXJhbSBwYXNzd2QgIElmIG5vbi1udWxsIGFuZCBub24tZW1w dHksIHNwZWNpZmllcyB0aGF0IHRoZQ0KICAgICAqICAgICAgICAgICAgICAgICBjb25uZWN0aW9u IGFuZCBhbGwgb3BlcmF0aW9ucyB0aHJvdWdoIGl0IHNob3VsZA0KICAgICAqICAgICAgICAgICAg ICAgICBiZSBhdXRoZW50aWNhdGVkIHdpdGggZG4gYXMgdGhlIGRpc3Rpbmd1aXNoZWQNCiAgICAg KiAgICAgICAgICAgICAgICAgbmFtZSBhbmQgcGFzc3dkIGFzIHBhc3N3b3JkLg0KICAgICAqPGJy Pjxicj4NCiAgICAgKiAgQHBhcmFtIHF1ZXVlICAgSGFuZGxlciBmb3IgbWVzc2FnZXMgcmV0dXJu ZWQgZnJvbSBhIHNlcnZlciBpbg0KICAgICAqICAgICAgICAgICAgICAgICByZXNwb25zZSB0byB0 aGlzIHJlcXVlc3QuIElmIGl0IGlzIG51bGwsIGENCiAgICAgKiAgICAgICAgICAgICAgICAgcXVl dWUgb2JqZWN0IGlzIGNyZWF0ZWQgaW50ZXJuYWxseS4NCiAgICAgKjxicj48YnI+DQogICAgICog IEBwYXJhbSBjb25zICAgICAgQ29uc3RyYWludHMgc3BlY2lmaWMgdG8gdGhlIG9wZXJhdGlvbi4N CiAgICAgKg0KICAgICAqICBAZXhjZXB0aW9uIExEQVBFeGNlcHRpb24gQSBnZW5lcmFsIGV4Y2Vw dGlvbiB3aGljaCBpbmNsdWRlcyBhbiBlcnJvcg0KICAgICAqICBtZXNzYWdlIGFuZCBhbiBMREFQ IGVycm9yIGNvZGUuDQogICAgICovDQogICAgcHVibGljIExEQVBSZXNwb25zZVF1ZXVlIGJpbmQo aW50IHZlcnNpb24sDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nIGRu LA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVbXSBwYXNzd2QsDQogICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTERBUFJlc3BvbnNlUXVldWUgcXVldWUsDQog ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTERBUENvbnN0cmFpbnRzIGNvbnMpDQog ICAgICAgIHRocm93cyBMREFQRXhjZXB0aW9uDQogICAgew0KICAgICAgICBpZiggRGVidWcuTERB UF9ERUJVRykgew0KICAgICAgICAgICAgRGVidWcudHJhY2UoIERlYnVnLmFwaVJlcXVlc3RzLCBu YW1lICsNCiAgICAgICAgICAgICJiaW5kKFwiIiArIGRuICsgIlwiKSIpOw0KICAgICAgICB9DQog ICAgICAgIGludCBtc2dJZDsNCiAgICAgICAgQmluZFByb3BlcnRpZXMgYmluZFByb3BzOw0KICAg ICAgICBpZihjb25zID09IG51bGwpDQogICAgICAgICAgICBjb25zID0gZGVmU2VhcmNoQ29uczsN Cg0KICAgICAgICBpZihkbiA9PSBudWxsKSB7DQogICAgICAgICAgICBkbiA9ICIiOw0KICAgICAg ICB9IGVsc2Ugew0KICAgICAgICAgICAgZG4gPSBkbi50cmltKCk7DQogICAgICAgIH0NCg0KICAg ICAgICBpZihwYXNzd2QgPT0gbnVsbCkNCiAgICAgICAgICAgIHBhc3N3ZCA9IG5ldyBieXRlW10g e307DQoNCiAgICAgICAgYm9vbGVhbiBhbm9ueW1vdXMgPSBmYWxzZTsNCiAgICAgICAgaWYoIHBh c3N3ZC5sZW5ndGggPT0gMCkgew0KICAgICAgICAgICAgYW5vbnltb3VzID0gdHJ1ZTsgLy8gYW5v bnltb3VzLCBwYXNzd2QgbGVuZ3RoIHplcm8gd2l0aCBzaW1wbGUgYmluZA0KICAgICAgICAgICAg ZG4gPSAiIjsgICAgICAgICAgLy8gc2V0IHRvIG51bGwgaWYgYW5vbnltb3VzDQogICAgICAgIH0N CiAgICAgICAgTERBUE1lc3NhZ2UgbXNnID0gbmV3IExEQVBCaW5kUmVxdWVzdCggdmVyc2lvbiwg ZG4sIHBhc3N3ZCwgY29ucy5nZXRDb250cm9scygpKTsNCg0KICAgICAgICBtc2dJZCA9IG1zZy5n ZXRNZXNzYWdlSUQoKTsNCiAgICAgICAgYmluZFByb3BzID0gbmV3IEJpbmRQcm9wZXJ0aWVzKCB2 ZXJzaW9uLCBkbiwgInNpbXBsZSIsDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgYW5vbnltb3VzLCBudWxsLCBudWxsKTsNCg0KICAgICAgICAvLyBGb3IgYmluZCByZXF1 ZXN0cywgaWYgbm90IGNvbm5lY3RlZCwgYXR0ZW1wdCB0byByZWNvbm5lY3QNCiAgICAgICAgaWYo ICEgY29ubi5pc0Nvbm5lY3RlZCgpKSB7DQogICAgICAgICAgICBpZiggY29ubi5nZXRIb3N0KCkg IT0gbnVsbCkgew0KICAgICAgICAgICAgICAgIGNvbm4uY29ubmVjdCggY29ubi5nZXRIb3N0KCks IGNvbm4uZ2V0UG9ydCgpKTsNCiAgICAgICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICAgICAg dGhyb3cgbmV3IExEQVBFeGNlcHRpb24oIEV4Y2VwdGlvbk1lc3NhZ2VzLkNPTk5FQ1RJT05fSU1Q T1NTSUJMRSwNCiAgICAgICAgICAgICAgICAgICAgTERBUEV4Y2VwdGlvbi5DT05ORUNUX0VSUk9S LCBudWxsKTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfQ0KDQogICAgICAgIC8vIFRoZSBzZW1h cGhvcmUgaXMgcmVsZWFzZWQgd2hlbiB0aGUgYmluZCByZXNwb25zZSBpcyBxdWV1ZWQuDQogICAg ICAgIGNvbm4uYWNxdWlyZVdyaXRlU2VtYXBob3JlKCBtc2dJZCk7DQoNCiAgICAgICAgcmV0dXJu IHNlbmRSZXF1ZXN0VG9TZXJ2ZXIoIG1zZyxjb25zLmdldFRpbWVMaW1pdCgpLCBxdWV1ZSwgYmlu ZFByb3BzKTsNCiAgICB9DQoNCiAgICAvLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioNCiAgICAvLyBTQVNMIGJp bmQgbWV0aG9kcw0KICAgIC8vKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KDQogICAgLyoqDQogICAgICogU3lu Y2hyb25vdXNseSBhdXRoZW50aWNhdGVzIHRvIHRoZSBMREFQIHNlcnZlciAodGhhdCB0aGUgb2Jq ZWN0IGlzDQogICAgICogY3VycmVudGx5IGNvbm5lY3RlZCB0bykgdXNpbmcgdGhlIHNwZWNpZmll ZCBuYW1lIGFuZCB0aGUgc3BlY2lmaWVkIHNldCBvZg0KICAgICAqIG1lY2hhbmlzbXMuDQogICAg ICoNCiAgICAgKiA8cD5JZiBub25lIG9mIHRoZSByZXF1ZXN0ZWQgU0FTTCBtZWNoYW5pc21zIGlz IGF2YWlsYWJsZSwgYW4NCiAgICAgKiBleGNlcHRpb24gaXMgdGhyb3duLiAgSWYgdGhlIG9iamVj dCBoYXMgYmVlbiBkaXNjb25uZWN0ZWQgZnJvbSBhbg0KICAgICAqIExEQVAgc2VydmVyLC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SBhdXRoeklkDQogICAgICogICAgICAgICAgICAgICAgICB3aWxs IGJlIHRyZWF0ZWQgYXMgYW4gZW1wdHkgc3RyaW5nIGFuZCBwcm9jZXNzZWQNCiAgICAgKiAgICAg ICAgICAgICAgICAgIGFzIHBlciBSRkMgMjIyMi4NCiAgICAgKjxicj48YnI+DQogICAgICogIEBw YXJhbSBwcm9wcyAgICBUaGUgb3B0aW9uYWwgcXVhbGlmaWVycyBmb3IgdGhlIGF1dGhlbnRpY2F0 aW9uDQogICAgICogICAgICAgICAgICAgICAgICBzZXNzaW9uLg0KICAgICAqPGJyPjxicj4NCiAg ICAgKiAgQHBhcmFtIGNiaCAgICAgIEEgY2xhc3Mgd2hpY2ggbWF5IGJlIGNhbGxlZCBieSB0aGUg U0FTTCBjbGllbnQNCiAgICAgKiAgICAgICAgICAgICAgICAgIGltcGxlbWVudGF0aW9uIHRvIG9i dGFpbiBhZGRpdGlvbmFsIGluZm9ybWF0aW9uDQogICAgICogICAgICAgICAgICAgICAgICByZXF1 aXJlZCwgc3VjaCBhcyBhZGRpdGlvbmFsIGNyZWRlbnRpYWxzLg0KICAgICAqICAgICAgICAgICAg ICAgICAgSWYgY2JoIGlzIG5vdCBvZiB0eXBlDQogICAgICogICAgICAgICAgICAgICAgICBqYXZh eC5zZWN1cml0eS5hdXRoLmNhbGxiYWNrLkNhbGxiYWNrSGFuZGxlciwgYQ0KICAgICAqICAgICAg ICAgICAgICAgICAgUnVudGltZUV4Y2VwdGlvbiB3aWxsIGJlIHRocm93bi4NCiAgICAgKg0KICAg ICAqICBAZXhjZXB0aW9uIExEQVBFeGNlcHRpb24gQSBnZW5lcmFsIGV4Y2VwdGlvbiB3aGljaCBp bmNsdWRlcyBhbiBlcnJvcg0KICAgICAqICBtZXNzYWdlIGFuZCBhbiBMREFQIGVycm9yIGNvZGUu DQogICAgICovDQogICAgcHVibGljIHZvaWQgYmluZChTdHJpbmcgZG4sDQogICAgICAgICAgICAg ICAgICAgICBTdHJpbmcgYXV0aHpJZCwNCiAgICAgICAgICAgICAgICAgICAgIE1hcCBwcm9wcywN CiAgICAgICAgICAgICAgICAgICAgIE9iamVjdCBjYmgpLypqYXZheC5zZWN1cml0eS5hdXRoLmNh bGxiYWNrLkNhbGxiYWNrSGFuZGxlciovDQogICAgICAgICAgICAgICAgICAgICB0aHJvd3MgTERB UEV4Y2VwdGlvbg0KICAgIHsNCiAgICAgICAgYmluZCggZG4sIGF1dGh6SWQsIHByb3BzLCBjYmgs IGRlZlNlYXJjaENvbnMpOw0KICAgICAgICByZXR1cm47DQogICAgfQ0KDQogICAgLyoqDQogICAg ICogU3luY2hyb25vdXNseSBhdXRoZW50aWNhdGVzIHRvIHRoZSBMREFQIHNlcnZlciAodGhhdCB0 aGUgb2JqZWN0IGlzDQogICAgICogY3VycmVudGx5IGNvbm5lY3RlZCB0bykgdXNpbmcgdGhlIHNw ZWNpZmllZCBuYW1lIGFuZCB0aGUgc3BlY2lmaWVkIHNldCBvZg0KICAgICAqIG1lY2hhbmlzbXMu DQogICAgICoNCiAgICAgKiA8cD5JZiBub25lIG9mIHRoZSByZXF1ZXN0ZWQgU0FTTCBtZWNoYW5p c21zIGlzIGF2YWlsYWJsZSwgYW4NCiAgICAgKiBleGNlcHRpb24gaXMgdGhyb3duLiAgSWYgdGhl IG9iamVjdCBoYXMgYmVlbiBkaXNjb25uZWN0ZWQgZnJvbSBhbg0KICAgICAqIExEQVAgc2VydmVy LCB0aGlzIG1ldGhvZCBhdHRlbXB0cyB0byByZWNvbm5lY3QgdG8gdGhlIHNlcnZlci4gSWYgdGhl DQogICAgICogb2JqZWN0IGhhcyBhbHJlYWR5IGF1dGhlbnRpY2F0ZWQsIHRoZSBvbGQgYXV0aGVu dGljYXRpb24gaXMNCiAgICAgKiBkaXNjYXJkZWQuIElmIG1lY2hhbmlzbXMgaXMgbnVsbCwgb3Ig aWYgdGhlIGZpcnN0IHZlcnNpb24gb2YgdGhlDQogICAgICogbWV0aG9kIGlzIGNhbGxlZCwgdGhl IExEQVAgc2VydmVyIHdpbGwgYmUgaW50ZXJyb2dhdGVkIGZvciBpdHMNCiAgICAgKiBzdXBwb3J0 ZWRTYXNsTWVjaGFuaXNtcyBhdHRyaWJ1dGUgb2YgaXRzIHJvb3QgRFNFLiBTZWUgUkZDIDIyNTEg Zm9yIGENCiAgICAgKiBkaXNjdXNzaW9uIG9mIHRoZSBTQVNMIGNsYXNzZXMuIDwvcD4NCiAgICAg Kg0KICAgICAqDQogICAgICogIEBwYXJhbSBkbiAgICAgICBJZiBub24tbnVsbCBhbmQgbm9uLWVt cHR5LCBzcGVjaWZpZXMgdGhhdCB0aGUNCiAgICAgKiAgICAgICAgICAgICAgICAgIGNvbm5lY3Rp b24gYW5kIGFsbCBvcGVyYXRpb25zIHRocm91Z2ggaXQgc2hvdWxkDQogICAgICogICAgICAgICAg ICAgICAgICBiZSBhdXRoZW50aWNhdGVkIHdpdGggZG4gYXMgdGhlIGRpc3Rpbmd1aXNoZWQNCiAg ICAgKiAgICAgICAgICAgICAgICAgIG5hbWUuDQogICAgICo8YnI+PGJyPg0KICAgICAqICBAcGFy YW0gYXV0aHpJZCAgSWYgbm90IG51bGwgYW5kIG5vdCBlbXB0eSwgc3BlY2lmaWVzIGFuIExEQVAg YXV0aHpJZCB0bw0KICAgICAqICAgICAgICAgICAgICAgICAgcGFzcyB0byB0aGUgU0FTTCBsYXll ci4gIElmIG51bGwgb3IgZW1wdHksIHRoZSBhdXRoeklkDQogICAgICogICAgICAgICAgICAgICAg ICB3aWxsIGJlIHRyZWF0ZWQgYXMgYW4gZW1wdHkgc3RyaW5nIGFuZCBwcm9jZXNzZWQNCiAgICAg KiAgICAgICAgICAgICAgICAgIGFzIHBlciBSRkMgMjIyMi4NCiAgICAgKjxicj48YnI+DQogICAg ICogIEBwYXJhbSBwcm9wcyAgICBUaGUgb3B0aW9uYWwgcXVhbGlmaWVycyBmb3IgdGhlIGF1dGhl bnRpY2F0aW9uDQogICAgICogICAgICAgICAgICAgICAgICBzZXNzaW9uLg0KICAgICAqPGJyPjxi cj4NCiAgICAgKiAgQHBhcmFtIGNiaCAgICAgIEEgY2xhc3Mgd2hpY2ggbWF5IGJlIGNhbGxlZCBi eSB0aGUgU0FTTCBjbGllbnQNCiAgICAgKiAgICAgICAgICAgICAgICAgIGltcGxlbWVudGF0aW9u IHRvIG9idGFpbiBhZGRpdGlvbmFsIGluZm9ybWF0aW9uDQogICAgICogICAgICAgICAgICAgICAg ICByZXF1aXJlZCwgc3VjaCBhcyBhZGRpdGlvbmFsIGNyZWRlbnRpYWxzLg0KICAgICAqICAgICAg ICAgICAgICAgICAgSWYgY2JoIGlzIG5vdCBvZiB0eXBlDQogICAgICogICAgICAgICAgICAgICAg ICBqYXZheC5zZWN1cml0eS5hdXRoLmNhbGxiYWNrLkNhbGxiYWNrSGFuZGxlciwgYQ0KICAgICAq ICAgICAgICAgICAgICAgICAgUnVudGltZUV4Y2VwdGlvbiB3aWxsIGJlIHRocm93bi4NCiAgICAg Kjxicj48YnI+DQogICAgICogIEBwYXJhbSBjb25zICAgICBDb25zdHJhaW50cyBzcGVjaWZpYyB0 byB0aGUgb3BlcmF0aW9uLg0KICAgICAqDQogICAgICogIEBleGNlcHRpb24gTERBUEV4Y2VwdGlv biBBIGdlbmVyYWwgZXhjZXB0aW9uIHdoaWNoIGluY2x1ZGVzIGFuIGVycm9yDQogICAgICogIG1l c3NhZ2UgYW5kIGFuIExEQVAgZXJyb3IgY29kZS4NCiAgICAgKi8NCiAgICBwdWJsaWMgdm9pZCBi aW5kKFN0cmluZyBkbiwNCiAgICAgICAgICAgICAgICAgICAgIFN0cmluZyBhdXRoeklkLA0KICAg ICAgICAgICAgICAgICAgICAgTWFwIHByb3BzLA0KICAgICAgICAgICAgICAgICAgICAgT2JqZWN0 IGNiaCwvKmphdmF4LnNlY3VyaXR5LmF1dGguY2FsbGJhY2suQ2FsbGJhY2tIYW5kbGVyKi8NCiAg ICAgICAgICAgICAgICAgICAgIExEQVBDb25zdHJhaW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EFuIGFycmF5IG9mIElBTkEt cmVnaXN0ZXJlZCBTQVNMIG1lY2hhbmlzbXMgd2hpY2gNCiAgICAgKiAgICAgICAgICAgICAgICAg ICAgICAgdGhlIGNsaWVudCBpcyB3aWxsaW5nIHRvIHVzZSBmb3IgYXV0aGVudGljYXRpb24uDQog ICAgICo8YnI+PGJyPg0KICAgICAqICBAcGFyYW0gcHJvcHMgICAgVGhlIG9wdGlvbmFsIHF1YWxp ZmllcnMgZm9yIHRoZSBhdXRoZW50aWNhdGlvbg0KICAgICAqICAgICAgICAgICAgICAgICAgc2Vz c2lvbi4NCiAgICAgKjxicj48YnI+DQogICAgICogIEBwYXJhbSBjYmggICAgICBBIGNsYXNzIHdo aWNoIG1heSBiZSBjYWxsZWQgYnkgdGhlIFNBU0wgY2xpZW50DQogICAgICogICAgICAgICAgICAg ICAgICBpbXBsZW1lbnRhdGlvbiB0byBvYnRhaW4gYWRkaXRpb25hbCBpbmZvcm1hdGlvbg0KICAg ICAqICAgICAgICAgICAgICAgICAgcmVxdWlyZWQsIHN1Y2ggYXMgYWRkaXRpb25hbCBjcmVkZW50 aWFscy4NCiAgICAgKiAgICAgICAgICAgICAgICAgIElmIGNiaCBpcyBub3Qgb2YgdHlwZQ0KICAg ICAqICAgICAgICAgICAgICAgICAgamF2YXguc2VjdXJpdHkuYXV0aC5jYWxsYmFjay5DYWxsYmFj a0hhbmRsZXIsIGENCiAgICAgKiAgICAgICAgICAgICAgICAgIFJ1bnRpbWVFeGNlcHRpb24gd2ls bCBiZSB0aHJvd24uDQogICAgICoNCiAgICAgKiAgQGV4Y2VwdGlvbiBMREFQRXhjZXB0aW9uIEEg Z2VuZXJhbCBleGNlcHRpb24gd2hpY2ggaW5jbHVkZXMgYW4gZXJyb3INCiAgICAgKiAgbWVzc2Fn ZSBhbmQgYW4gTERBUCBlcnJvciBjb2RlLg0KICAgICAqLw0KICAgIHB1YmxpYyB2b2lkIGJpbmQo U3RyaW5nIGRuLA0KICAgICAgICAgICAgICAgICAgICAgU3RyaW5nIGF1dGh6SWQsDQogICAgICAg ICAgICAgICAgICAgICBTdHJpbmdbXSBtZWNoYW5pc21zLA0KICAgICAgICAgICAgICAgICAgICAg TWFwIHByb3BzLA0KICAgICAgICAgICAgICAgICAgICAgT2JqZWN0IGNiaCkvKmphdmF4LnNlY3Vy aXR5LmF1dGguY2FsbGJhY2suQ2FsbGJhY2tIYW5kbGVyKi8NCiAgICAgICAgICAgICAgICAgICAg IHRocm93cyBMREFQRXhjZXB0aW9uDQogICAgew0KICAgICAgICBiaW5kKCBkbiwgYXV0aHpJZCwg bWVjaGFuaXNtcywgcHJvcHMsIGNiaCwgZGVmU2VhcmNoQ29ucyk7DQogICAgICAgIHJldHVybjsN CiAgICB9DQogICAgLyoqDQogICAgICogU3luY2hyb25vdXNseSBhdXRoZW50aWNhdGVzIHRvIHRo ZSBMREFQIHNlcnZlciAodGhhdCB0aGUgb2JqZWN0IGlzDQogICAgICogY3VycmVudGx5IGNvbm5l Y3RlZCB0bykgdXNpbmcgdGhlIHNwZWNpZmllZCBuYW1lIGFuZCB0aGUgc3BlY2lmaWVkIHNldCBv Zg0KICAgICAqIG1lY2hhbmlzbXMuDQogICAgICoNCiAgICAgKiA8cD5JZiBub25lIG9mIHRoZSBy ZXF1ZXN0ZWQgU0FTTCBtZWNoYW5pc21zIGlzIGF2YWlsYWJsZSwgYW4NCiAgICAgKiBleGNlcHRp b24gaXMgdGhyb3duLiAgSWYgdGhlIG9iamVjdCBoYXMgYmVlbiBkaXNjb25uZWN0ZWQgZnJvbSBh bg0KICAgICAqIExEQVAgc2VydmVyLCB0aGlzIG1ldGhvZCBhdHRlbXB0cyB0byByZWNvbm5lY3Qg dG8gdGhlIHNlcnZlci4gSWYgdGhlDQogICAgICogb2JqZWN0IGhhcyBhbHJlYWR5IGF1dGhlbnRp Y2F0ZWQsIHRoZSBvbGQgYXV0aGVudGljYXRpb24gaXMNCiAgICAgKiBkaXNjYXJkZWQuIElmIG1l Y2hhbml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naXN0ZXJlZCBTQVNMIG1l Y2hhbmlzbXMgd2hpY2gNCiAgICAgKiAgICAgICAgICAgICAgICAgICAgICAgdGhlIGNsaWVudCBp cyB3aWxsaW5nIHRvIHVzZSBmb3IgYXV0aGVudGljYXRpb24uDQogICAgICo8YnI+PGJyPg0KICAg ICAqICBAcGFyYW0gcHJvcHMgICAgVGhlIG9wdGlvbmFsIHF1YWxpZmllcnMgZm9yIHRoZSBhdXRo ZW50aWNhdGlvbg0KICAgICAqICAgICAgICAgICAgICAgICAgc2Vzc2lvbi4NCiAgICAgKjxicj48 YnI+DQogICAgICogIEBwYXJhbSBjYmggICAgICBBIGNsYXNzIHdoaWNoIG1heSBiZSBjYWxsZWQg YnkgdGhlIFNBU0wgY2xpZW50DQogICAgICogICAgICAgICAgICAgICAgICBpbXBsZW1lbnRhdGlv biB0byBvYnRhaW4gYWRkaXRpb25hbCBpbmZvcm1hdGlvbg0KICAgICAqICAgICAgICAgICAgICAg ICAgcmVxdWlyZWQsIHN1Y2ggYXMgYWRkaXRpb25hbCBjcmVkZW50aWFscy4NCiAgICAgKiAgICAg ICAgICAgICAgICAgIElmIGNiaCBpcyBub3Qgb2YgdHlwZQ0KICAgICAqICAgICAgICAgICAgICAg ICAgamF2YXguc2VjdXJpdHkuYXV0aC5jYWxsYmFjay5DYWxsYmFja0hhbmRsZXIsIGENCiAgICAg KiAgICAgICAgICAgICAgICAgIFJ1bnRpbWVFeGNlcHRpb24gd2lsbCBiZSB0aHJvd24uDQogICAg ICo8YnI+PGJyPg0KICAgICAqICBAcGFyYW0gY29ucyAgICAgQ29uc3RyYWludHMgc3BlY2lmaWMg dG8gdGhlIG9wZXJhdGlvbi4NCiAgICAgKg0KICAgICAqICBAZXhjZXB0aW9uIExEQVBFeGNlcHRp b24gQSBnZW5lcmFsIGV4Y2VwdGlvbiB3aGljaCBpbmNsdWRlcyBhbiBlcnJvcg0KICAgICAqICBt ZXNzYWdlIGFuZCBhbiBMREFQIGVycm9yIGNvZGUuDQogICAgICovDQogICAgcHVibGljIHZvaWQg YmluZChTdHJpbmcgZG4sDQogICAgICAgICAgICAgICAgICAgICBTdHJpbmcgYXV0aHpJZCwNCiAg ICAgICAgICAgICAgICAgICAgIFN0cmluZ1tdIG1lY2hhbmlzbXMsDQogICAgICAgICAgICAgICAg ICAgICBNYXAgcHJvcHMsDQogICAgICAgICAgICAgICAgICAgICBPYmplY3QgY2JoLC8qamF2YXgu c2VjdXJpdHkuYXV0aC5jYWxsYmFjay5DYWxsYmFja0hhbmRsZXIqLw0KICAgICAgICAgICAgICAg ICAgICAgTERBUENvbnN0cmFpbnRzIGNvbnMpDQogICAgICAgICAgICAgICAgICAgICB0aHJvd3Mg TERBUEV4Y2VwdGlvbg0KICAgIHsNCiAgICAgICAgaWYoIERlYnVnLkxEQVBfREVCVUcpIHsNCiAg ICAgICAgICAgIERlYnVnLnRyYWNlKCBEZWJ1Zy5hcGlSZXF1ZXN0cywgbmFtZSArDQogICAgICAg ICAgICAic2FzbEJpbmQoIiArIGRuICsgIikiKTsNCiAgICAgICAgfQ0KDQogICAgICAgIGlmKGNv bnMgPT0gbnVsbCkNCiAgICAgICAgICAgIGNvbnMgPSBkZWZTZWFyY2hDb25zOw0KDQogICAgICAg IGlmKGRuID09IG51bGwpDQogICAgICAgICAgICBkbiA9ICIiOw0KDQogICAgICAgIGlmIChhdXRo eklkID09IG51bGwpDQogICAgICAgICAgICBhdXRoeklkID0gIiI7DQoNCiAgICAgICAgdHJ5DQog ICAgICAgIHsNCiAgICAgICAgICAgIFNhc2xDbGllbnQgc2FzbENsaWVudCA9IFNhc2wuY3JlYXRl U2FzbENsaWVudChtZWNoYW5pc21zLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICBhdXRoeklkLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAibGRhcCIsDQogICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ2V0SG9zdCgpLA0KICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm9wcywNCiAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKENhbGxiYWNr SGFuZGxlciljYmgpOw0KICAgICAgICAgICAgaWYgKHNhc2xDbGllbnQgPT0gbnVsbCkNCiAgICAg ICAgICAgIHsNCiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgTERBUEV4Y2VwdGlvbigNCiAgICAg ICAgICAgICAgICAgICAgICAiVW5zdXBwb3J0ZWQgU0FTTCBtZWNoYW5pc20ocykgYW5kL29yIHBy b3BlcnRpZXMiLA0KICAgICAgICAgICAgICAgICAgICAgIExEQVBFeGNlcHRpb24uQVVUSF9NRVRI T0RfTk9UX1NVUFBPUlRFRCwgbnVsbCk7DQogICAgICAgICAgICB9DQoNCg0KICAgICAgICAgICAg aWYoIERlYnVnLkxEQVBfREVCVUcpIHsNCiAgICAgICAgICAgICAgICBEZWJ1Zy50cmFjZSggRGVi dWcuc2FzbEJpbmQsIG5hbWUgKw0KICAgICAgICAgICAgICAgICAgICAic2FzbENsaWVudCBjcmVh dGVkLCBtZWNoYW5pc20gIiArDQogICAgICAgICAgICAgICAgICAgIHNhc2xDbGllbnQuZ2V0TWVj aGFuaXNtTmFtZSgpKTsNCiAgICAgICAgICAgIH0NCg0KICAgICAgICAgICAgYnl0ZVtdICBjbGll bnRSZXNwb25zZSA9IG51bGw7DQogICAgICAgICAgICBib29sZWFuIGFub255bW91cyA9IGZhbHNl Ow0KICAgICAgICAgICAgQmluZFByb3BlcnRpZXMgYmluZFByb3BzID0gbmV3IEJpbmRQcm9wZXJ0 aWVzKExEQVBfVjMsDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICBudWxsLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgInNhc2wiLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5vbnltb3VzLA0KICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbnVsbCwNCiAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG51bGwpOw0K DQogICAgICAgICAgICAvLyBBY3F1aXJlIHRoZSBiaW5kIHNlbWFwaG9yZSBhbmQgY29tbXVuaWNh dGUgaXRzIHZhbHVlIHRvDQogICAgICAgICAgICAvLyB0aGUgY29ycmVzcG9uZGluZyBDb25uZWN0 aW9uIGNsYXNzLg0KICAgICAgICAgICAgaW50IGlkID0gY29ubi5hY3F1aXJlV3JpdGVTZW1hcGhv cmUoKTsNCiAgICAgICAgICAgIGNvbm4uc2V0QmluZFNlbUlkKCBpZCk7DQoNCiAgICAgICAgICAg IGlmIChzYXNsQ2xpZW50Lmhhc0luaXRpYWxSZXNwb25zZSgpKQ0KICAgICAgICAgICAgew0KICAg ICAgICAgICAgICAgIGNsaWVudFJlc3BvbnNlID0gc2FzbENsaWVudC5ldmFsdWF0ZUNoYWxsZW5n ZShuZXcNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgYnl0ZVswXSk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICB3aGlsZSgh c2FzbENsaWVudC5pc0NvbXBsZXRlKCkpDQogICAgICAgICAgICB7DQogICAgICAgICAgICAgICAg dHJ5DQogICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgICBieXRlW10gcmVwbHlC dWYgPSBMREFQVHJhbnNwb3J0KA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgY2xpZW50UmVzcG9uc2UsDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICBzYXNsQ2xpZW50LmdldE1lY2hhbmlzbU5hbWUoKSwNCiAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgIGJpbmRQcm9wcyk7DQoNCiAgICAgICAgICAgICAgICAg ICAgaWYocmVwbHlCdWYhPW51bGwpDQogICAgICAgICAgICAgICAgICAgIHsNCiAgICAgICAgICAg ICAgICAgICAgICAgIGlmKCBEZWJ1Zy5MREFQX0RFQlVHKSB7DQogICAgICAgICAgICAgICAgICAg ICAgICAgICAgRGVidWcudHJhY2UoIERlYnVnLnNhc2xCaW5kLCBuYW1lICsNCiAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgInNhc2xDbGllbnQgcmVzcG9uc2UgIiArIHJlcGx5QnVmLmxl bmd0aCArDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICIgYnl0ZXMiKTsNCiAgICAg ICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgICAgIGNsaWVudFJlc3Bv bnNlID0gc2FzbENsaWVudC5ldmFsdWF0ZUNoYWxsZW5nZSgNCiAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXBseUJ1Zik7DQogICAg ICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgZWxzZQ0KICAgICAgICAgICAg ICAgICAgICB7DQogICAgICAgICAgICAgICAgICAgICAgICBpZiggRGVidWcuTERBUF9ERUJVRykg ew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIERlYnVnLnRyYWNlKCBEZWJ1Zy5zYXNsQmlu ZCwgbmFtZSArDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJzYXNsQ2xpZW50IHJl c3BvbnNlIGVtcHR5Iik7DQogICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAg ICAgICAgICAgICBjbGllbnRSZXNwb25zZSA9IHNhc2xDbGllbnQuZXZhbHVhdGVDaGFsbGVuZ2Uo DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgbmV3IGJ5dGVbMF0pOw0KICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAg fQ0KICAgICAgICAgICAgICAgIGNhdGNoKFNhc2xFeGNlcHRpb24gZSkNCiAgICAgICAgICAgICAg ICB7DQogICAgICAgICAgICAgICAgICAgIC8vIFRoaXMgY2FsbCB3aWxsIGZyZWUgYW55IGNsaWVu dCByZXNvdXJjZXMuDQogICAgICAgICAgICAgICAgICAgIHNhc2xDbGllbnQuZGlzcG9zZSgpOw0K ICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgTERBUEV4Y2VwdGlvbigiVW5leHBlY3RlZCBT QVNMIGVycm9yLiIsDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICBMREFQRXhjZXB0aW9uLk9USEVSLCBudWxsLCBlKTsNCiAgICAgICAgICAgICAgICB9DQogICAg ICAgICAgICAgICAgY2F0Y2goTERBUEV4Y2VwdGlvbiBsZGUpDQogICAgICAgICAgICAgICAgew0K ICAgICAgICAgICAgICAgICAgICAvLyBUaGlzIGNhbGwgd2lsbCBmcmVlIGFueSBjbGllbnQgcmVz b3VyY2VzLg0KICAgICAgICAgICAgICAgICAgICBzYXNsQ2xpZW50LmRpc3Bvc2UoKTsNCiAgICAg ICAgICAgICAgICAgICAgdGhyb3cgbGRlOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAg IH0NCiAgICAgICAgICAgIGlmKCBEZWJ1Zy5MREFQX0RFQlVHKSB7DQogICAgICAgICAgICAgICAg RGVidWcudHJhY2UoIERlYnVnLnNhc2xCaW5kLCBuYW1lICsgInNhc2xCaW5kIENvbXBsZXRlIik7 DQogICAgICAgICAgICB9DQogICAgICAgIH0NCiAgICAgICAgY2F0Y2ggKFNhc2xFeGNlcHRpb24g ZVNhc2wpDQogICAgICAgIHsNCiAgICAgICAgICAgIHRocm93IG5ldyBMREFQRXhjZXB0aW9uKCJT QVNMIEJpbmQgRXJyb3IuIiwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBM REFQRXhjZXB0aW9uLk9USEVSLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg IG51bGwsDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZVNhc2wuZ2V0Q2F1 c2UoKSk7DQogICAgICAgIH0NCg0KICAgICAgICAvL0xEQVAgQmluZCBjb21wbGV0ZQ0KICAgICAg ICByZXR1cm47DQogICAgfQ0KDQogICAgLyoqDQogICAgICogSW1wbGVtZW50cyBhIExEQVAgVHJh bnNwb3J0IG1ldGhvZCB3aGljaCByZWNpdmVzIHJlcXVlc3RzIGZyb20gdGhlDQogICAgICogc2Fz bENsaWVudCBhbmQgc2VuZCBEYXRhIHRvIHRoZSBMREFQIHNlcnZlciBhbmQgcmV0dXJucyB0aGUg cmVzcG9uc2UNCiAgICAgKiBiYWNrIHRvIHRoZSBzYXNsQ2xpZW50DQogICAgICoNCiAgICAgKiBA cGFyYW0gdG9Xcml0ZSAgIHJlcXVlc3QgcmVjZWl2ZWQgZnJvbSBzYXNsQ2xpZW50IGluIGEgYnl0 ZSBhcnJheQ0KICAgICAqIEBwYXJhbSBtZWNoYW5pc20gTmFtZSBvZiB0aGUgc2FzbENsaWVudCAg TWVjaGFuaXNtDQogICAgICogQHBhcmFtIGJpbmRQcm9wcyBCaW5kcHJvcGVydGllcw0KICAgICAq DQogICAgICogQHJldHVybiAgUmVzcG9uc2UgcmVpdmVkIGZyb20gdGhlIExEQVAgc2VydmVyIGlu IGEgYnl0ZSBhcnJheQ0KICAgICAqDQogICAgICogQGV4Y2VwdGlvbiBMREFQRXhjZXB0aW9uIEEg Z2VuZXJhbCBleGNlcHRpb24gd2hpY2ggaW5jbHVkZXMgYW4gZXJyb3INCiAgICAgKiAgbWVzc2Fn ZSBhbmQgYW4gTERBUCBlcnJvciBjb2RlLg0KICAgICAqLw0KICAgIHByaXZhdGUgYnl0ZVtdIExE QVBUcmFuc3BvcnQoIGJ5dGVbXSB0b1dyaXRlLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgIFN0cmluZyBtZWNoYW5pc20sDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgQmluZFByb3BlcnRpZXMgYmluZFByb3BzKQ0KICAgICAgICAgICAgdGhyb3dzIExEQVBFeGNl cHRpb24NCiAgICB7DQoNCiAgICAgICAgTERBUE1lc3NhZ2UgICAgIG1zZzsNCiAgICAgICAgUmZj QmluZFJlc3BvbnNlIGJpbmRSZXNwb25zZTsNCiAgICAgICAgTERBUENvbnN0cmFpbnRzIGNvbnM7 DQogICAgICAgIEFTTjFPY3RldFN0cmluZyBzZXJ2ZXJDcmVkczsNCg0KICAgICAgICBjb25zID0g ZGVmU2VhcmNoQ29uczsNCiAgICAgICAgbXNnID0gbmV3IExEQVBNZXNzYWdlKExEQVBNZXNzYWdl LkJJTkRfUkVRVUVTVCwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXcgUmZjQmlu ZFJlcXVlc3QoTERBUF9WMywNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgIiIsDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgIG1lY2hhbmlzbSwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgdG9Xcml0ZSksDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg Y29ucy5nZXRDb250cm9scygpKTsNCg0KICAgICAgICBMREFQUmVzcG9uc2VRdWV1ZSBxdWV1ZSA9 IHNlbmRSZXF1ZXN0VG9TZXJ2ZXIobXNnLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICBjb25zLmdldFRpbWVMaW1pdCgpLA0KICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBudWxsLA0KICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiaW5kUHJvcHMpOw0K ICAgICAgICBMREFQUmVzcG9uc2UgbGRhcFJlc3BvbnNlID0gKExEQVBSZXNwb25zZSlxdWV1ZS5n ZXRSZXNwb25zZSgpOw0KICAgICAgICBiaW5kUmVzcG9uc2UgPSAoUmZjQmluZFJlc3BvbnNlKWxk YXBSZXNwb25zZS5nZXRBU04xT2JqZWN0KCkuZ2V0KDEpOw0KICAgICAgICBzZXJ2ZXJDcmVkcyA9 IGJpbmRSZXNwb25zZS5nZXRTZXJ2ZXJTYXNsQ3JlZHMoKTsNCiAgICAgICAgaW50IHJlc3VsdENv ZGUgPSBsZGFwUmVzcG9uc2UuZ2V0UmVzdWx0Q29kZSgpOw0KDQogICAgICAgIGJ5dGVbXSByZXBs eUJ1ZiA9IG51bGw7DQogICAgICAgIGlmICgocmVzdWx0Q29kZSA9PSBMREFQRXhjZXB0aW9uLlNB U0xfQklORF9JTl9QUk9HUkVTUykgfHwNCiAgICAgICAgICAgIChyZXN1bHRDb2RlID09IExEQVBF eGNlcHRpb24uU1VDQ0VTUykpDQogICAgICAgIHsNCiAgICAgICAgICAgIGlmIChzZXJ2ZXJDcmVk cyAhPSBudWxsKQ0KICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgIHJlcGx5QnVmID0gc2Vy dmVyQ3JlZHMuYnl0ZVZhbHVlKCk7DQogICAgICAgICAgICB9DQogICAgICAgIH0NCiAgICAgICAg ZWxzZSB7DQogICAgICAgICAgIGxkYXBSZXNwb25zZS5jaGtSZXN1bHRDb2RlKCk7DQogICAgICAg ICAgIHRocm93IG5ldyBMREFQRXhjZXB0aW9uKCJTQVNMIEJpbmQgRXJyb3IuIiwNCiAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdENvZGUsDQogICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICBudWxsKTsNCiAgICAgICAgfQ0KICAgICAgICByZXR1cm4gcmVw bHlCdWY7DQogICAgfQ0KDQogICAgLy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqDQogICAgLy8gY29tcGFyZSBt ZXRob2RzDQogICAgLy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqDQoNCiAgICAvKioNCiAgICAgKg0KICAgICAq IFN5bmNocm9ub3VzbHkgY2hlY2tzIHRvIHNlZSBpZiBhbiBlbnRyeSBjb250YWlucyBhbiBhdHRy aWJ1dGUNCiAgICAgKiB3aXRoIGEgc3BlY2lmaWVkIHZhbHVlLg0KICAgICAqDQogICAgICogIEBw YXJhbSBkbiAgICAgIFRoZSBkaXN0aW5ndWlzaGVkIG5hbWUgb2YgdGhlIGVudHJ5IHRvIHVzZSBp biB0aGUNCiAgICAgKiAgICAgICAgICAgICAgICAgY29tcGFyaXNvbi4NCiAgICAgKjxicj48YnI+ DQogICAgICogIEBwYXJhbSBhdHRyICAgIFRoZSBhdHRyaWJ1dGUgdG8gY29tcGFyZSBhZ2FpbnN0 IHRoZSBlbnRyeS4gVGhlDQogICAgICogICAgICAgICAgICAgICAgIG1ldGhvZCBjaGVja3MgdG8g c2VlIGlmIHRoZSBlbnRyeSBoYXMgYW4NCiAgICAgKiAgICAgICAgICAgICAgICAgYXR0cmlidXRl IHdpdGggdGhlIHNhbWUgbmFtZSBhbmQgdmFsdWUgYXMgdGhpcw0KICAgICAqICAgICAgICAgICAg ICAgICBhdHRyaWJ1dGUuDQogICAgICoNCiAgICAgKiAgQHJldHVybiBUcnVlIGlmIHRoZSBlbnRy eSBoYXMgdGhlIHZhbHVlLA0KICAgICAqICAgIC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NCiAgICAgKiAgICAgICAgICAgICAgICAgYXR0cmlidXRlIHdpdGggdGhlIHNhbWUgbmFtZSBh bmQgdmFsdWUgYXMgdGhpcw0KICAgICAqICAgICAgICAgICAgICAgICBhdHRyaWJ1dGUuDQogICAg ICo8YnI+PGJyPg0KICAgICAqICBAcGFyYW0gY29ucyAgICBDb25zdHJhaW50cyBzcGVjaWZpYyB0 byB0aGUgb3BlcmF0aW9uLg0KICAgICAqDQogICAgICogIEByZXR1cm4gVHJ1ZSBpZiB0aGUgZW50 cnkgaGFzIHRoZSB2YWx1ZSwNCiAgICAgKiAgICAgICAgICBhbmQgZmFsc2UgaWYgdGhlIGVudHJ5 IGRvZXMgbm90DQogICAgICogICAgICAgICAgaGF2ZSB0aGUgdmFsdWUgb3IgdGhlIGF0dHJpYnV0 ZS4NCiAgICAgKg0KICAgICAqICBAZXhjZXB0aW9uIExEQVBFeGNlcHRpb24gQSBnZW5lcmFsIGV4 Y2VwdGlvbiB3aGljaCBpbmNsdWRlcyBhbiBlcnJvcg0KICAgICAqICAgICAgICAgICAgICAgICAg ICAgICAgICAgbWVzc2FnZSBhbmQgYW4gTERBUCBlcnJvciBjb2RlLg0KICAgICAqLw0KICAgIHB1 YmxpYyBib29sZWFuIGNvbXBhcmUoU3RyaW5nIGRuLA0KICAgICAgICAgICAgICAgICAgICAgICAg ICAgTERBUEF0dHJpYnV0ZSBhdHRyLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgTERBUENv bnN0cmFpbnRzIGNvbnMpDQogICAgICAgdGhyb3dzIExEQVBFeGNlcHRpb24NCiAgICB7DQogICAg ICAgIGJvb2xlYW4gcmV0ID0gZmFsc2U7DQoNCiAgICAgICAgaWYoIERlYnVnLkxEQVBfREVCVUcp IHsNCiAgICAgICAgICAgIERlYnVnLnRyYWNlKCBEZWJ1Zy5hcGlSZXF1ZXN0cywgbmFtZSArDQog ICAgICAgICAgICAiY29tcGFyZSgiICsgZG4gKyAiKSBpZiB2YWx1ZSIpOw0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ICAgICAgICAgICAgICAgYXR0cmlidXRlIHRvIGNvbXBhcmUuDQogICAg ICo8YnI+PGJyPg0KICAgICAqICBAcGFyYW0gYXR0ciAgICBBbiBhdHRyaWJ1dGUgdG8gY29tcGFy ZS4NCiAgICAgKjxicj48YnI+DQogICAgICogIEBwYXJhbSBxdWV1ZSAgICAgSGFuZGxlciBmb3Ig bWVzc2FnZXMgcmV0dXJuZWQgZnJvbSBhIHNlcnZlciBpbg0KICAgICAqICAgICAgICAgICAgICAg ICAgIHJlc3BvbnNlIHRvIHRoaXMgcmVxdWVzdC4gSWYgaXQgaXMgbnVsbCwgYQ0KICAgICAqICAg ICAgICAgICAgICAgICAgIHF1ZXVlIG9iamVjdCBpcyBjcmVhdGVkIGludGVybmFsbHkuDQogICAg ICo8YnI+PGJyPg0KICAgICAqICBAcGFyYW0gY29ucyAgICAgIENvbnN0cmFpbnRzIHNwZWNpZmlj IHRvIHRoZSBvcGVyYXRpb24uDQogICAgICoNCiAgICAgKiAgQGV4Y2VwdGlvbiBMREFQRXhjZXB0 aW9uIEEgZ2VuZXJhbCBleGNlcHRpb24gd2hpY2ggaW5jbHVkZXMgYW4gZXJyb3INCiAgICAgKiAg bWVzc2FnZSBhbmQgYW4gTERBUCBlcnJvciBjb2RlLg0KICAgICAqDQogICAgICogQHNlZSBMREFQ RXhjZXB0aW9uI0NPTVBBUkVfVFJVRQ0KICAgICAqIEBzZWUgTERBUEV4Y2VwdGlvbiNDT01QQVJF X0ZBTFNFDQogICAgICovDQogICAgcHVibGljIExEQVBSZXNwb25zZVF1ZXVlIGNvbXBhcmUoU3Ry aW5nIGRuLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIExEQVBBdHRyaWJ1 dGUgYXR0ciwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBMREFQUmVzcG9u c2VRdWV1ZSBxdWV1ZSwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBMREFQ Q29uc3RyYWludHMgY29ucykNCiAgICAgICAgdGhyb3dzIExEQVBFeGNlcHRpb24NCiAgICB7DQog ICAgICAgIGlmKCBEZWJ1Zy5MREFQX0RFQlVHKSB7DQogICAgICAgICAgICBEZWJ1Zy50cmFjZSgg RGVidWcuYXBpUmVxdWVzdHMsIG5hbWUgKw0KICAgICAgICAgICAgImNvbXBhcmUoIiArIGRuICsg IikgY29tcGFyZSB2YWx1ZSIpOw0KICAgICAgICB9DQoNCiAgICAgICAgaWYoIGF0dHIuc2l6ZSgp ICE9IDEpIHsNCiAgICAgICAgICAgIHRocm93IG5ldyBJbGxlZ2FsQXJndW1lbnRFeGNlcHRpb24o ImNvbXBhcmU6IEV4YWN0bHkgb25lIHZhbHVlICIgKw0KICAgICAgICAgICAgICAgICAgICAibXVz dCBiZSBwcmVzZW50IGluIHRoZSBMREFQQXR0cmlidXRlIik7DQogICAgICAgIH0NCg0KICAgICAg ICBpZihkbiA9PSBudWxsICkgew0KICAgICAgICAgICAgLy8gSW52YWxpZCBwYXJhbWV0ZXINCiAg ICAgICAgICAgIHRocm93IG5ldyBJbGxlZ2FsQXJndW1lbnRFeGNlcHRpb24oImNvbXBhcmU6IERO IGNhbm5vdCBiZSBudWxsIik7DQogICAgICAgIH0NCg0KICAgICAgICBpZihjb25zID09IG51bGwp DQogICAgICAgICAgICBjb25zID0gZGVmU2VhcmNoQ29uczsNCg0KICAgICAgICBMREFQTWVzc2Fn ZSBtc2cgPSBuZXcgTERBUENvbXBhcmVSZXF1ZXN0KCBkbiwNCiAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXR0ci5nZXROYW1lKCksDQogICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF0dHIuZ2V0Qnl0ZVZhbHVl KCksDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNv bnMuZ2V0Q29udHJvbHMoKSk7DQoNCiAgICAgICAgcmV0dXJuIHNlbmRSZXF1ZXN0VG9TZXJ2ZXIo bXNnLCBjb25zLmdldFRpbWVMaW1pdCgpLCBxdWV1ZSwgbnVsbCk7DQogICAgfQ0KDQogICAgLy8q KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqDQogICAgLy8gY29ubmVjdCBtZXRob2RzDQogICAgLy8qKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqDQoNCiAgICAvKioNCiAgICAgKg0KICAgICAqICBDb25uZWN0cyB0byB0aGUgc3BlY2lm aWVkIGhvc3QgYW5kIHBvcnQuDQogICAgICoNCiAgICAgKiAgPHA+SWYgdGhpcyBMREFQQ29ubmVj dGlvbiBvYmplY3QgcmVwcmVzZW50cyBhbiBvcGVuIGNvbm5lY3Rpb24sIHRoZQ0KICAgICAqICBj b25uZWN0aW9uIGlzIGNsb3NlZCBmaXJzdCBiZWZvcmUgdGhlIG5ldyBjb25uZWN0aW9uIGlzIG9w ZW5lZC4NCiAgICAgKiAgQXQgdGhpcyBwb2ludCwgdGhlcmUgaXMgbm8gYXV0aGVudGljYXRpb24s IGFuZCBhbnkgb3BlcmF0aW9ucyBhcmUNCiAgICAgKiAgY29uZHVjdGVkIGFzIGFuIGFub255bW91 cyBjbGllbnQuPC9wPg0KICAgICAqDQogICAgICogIDxwPiBXaGVuIG1vcmUgdGhhbiBvbmUgaG9z dCBuYW1lIGlzIHNwZWNpZmllZCwgZWFjaCBob3N0IGlzIGNvbnRhY3RlZA0KICAgICAqICBpbiB0 dXJuIHVudGlsIGEgY29ubmVjdGlvbiBjYW4gYmUgZXN0YWJsaXNoZWQuPC9wPg0KICAgICAqDQog ICAgICogIEBwYXJhbSBob3N0IEEgaG9zdCBuYW1lIG9yIGEgZG90dGVkIHN0cmluZyByZXByZXNl bnRpbmcgdGhlIElQIGFkZHJ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Ryb3lz IG9sZCBjb25uZWN0aW9uLg0KICAgICAgICBpZiggRGVidWcuTERBUF9ERUJVRykgew0KICAgICAg ICAgICAgRGVidWcudHJhY2UoIERlYnVnLmFwaVJlcXVlc3RzLCBuYW1lICsNCiAgICAgICAgICAg ICJjb25uZWN0KCIgKyBob3N0ICsgIiwgIiArIHBvcnQgKyAiKSIpOw0KICAgICAgICB9DQoNCiAg ICAgICAgLy8gU3RlcCB0aHJvdWdoIHRoZSBzcGFjZS1kZWxpbWl0ZWQgbGlzdA0KICAgICAgICBT dHJpbmdUb2tlbml6ZXIgaG9zdExpc3QgPSBuZXcgU3RyaW5nVG9rZW5pemVyKGhvc3QsIiAiKTsN CiAgICAgICAgU3RyaW5nIGFkZHJlc3MgPSBudWxsOw0KDQogICAgICAgIGludCBzcGVjaWZpZWRQ b3J0Ow0KICAgICAgICBpbnQgY29sb25JbmRleDsgLy9hZnRlciB0aGUgY29sb24gaXMgdGhlIHBv cnQNCiAgICAgICAgd2hpbGUgKGhvc3RMaXN0Lmhhc01vcmVUb2tlbnMoKSkgew0KICAgICAgICAg ICAgdHJ5ew0KICAgICAgICAgICAgICAgIHNwZWNpZmllZFBvcnQ9cG9ydDsNCiAgICAgICAgICAg ICAgICBhZGRyZXNzID0gaG9zdExpc3QubmV4dFRva2VuKCk7DQogICAgICAgICAgICAgICAgY29s b25JbmRleCA9IGFkZHJlc3MuaW5kZXhPZigoaW50KSc6Jyk7DQogICAgICAgICAgICAgICAgaWYg KGNvbG9uSW5kZXggIT0gLTEgJiYgY29sb25JbmRleCsxICE9IGFkZHJlc3MubGVuZ3RoKCkpew0K ICAgICAgICAgICAgICAgICAgICAvL3BhcnNlIFBvcnQgb3V0IG9mIGFkZHJlc3MNCiAgICAgICAg ICAgICAgICAgICAgdHJ5ew0KICAgICAgICAgICAgICAgICAgICAgICAgc3BlY2lmaWVkUG9ydCA9 IEludGVnZXIucGFyc2VJbnQoDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBh ZGRyZXNzLnN1YnN0cmluZyhjb2xvbkluZGV4KzEpKTsNCiAgICAgICAgICAgICAgICAgICAgICAg IGFkZHJlc3MgPSAgIGFkZHJlc3Muc3Vic3RyaW5nKDAsIGNvbG9uSW5kZXgpOw0KICAgICAgICAg ICAgICAgICAgICB9Y2F0Y2ggKEV4Y2VwdGlvbiBlKXsNCiAgICAgICAgICAgICAgICAgICAgICAg ICAgdGhyb3cgbmV3IElsbGVnYWxBcmd1bWVudEV4Y2VwdGlvbigNCiAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICBFeGNlcHRpb25NZXNzYWdlcy5JTlZBTElEX0FERFJFU1MpOw0K ICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAg IC8vIFRoaXMgbWF5IHJldHVybiBhIGRpZmZlcmVudCBjb25uIG9iamVjdA0KICAgICAgICAgICAg ICAgIC8vIERpc2Fzc29jaWF0ZSB0aGlzIGNsb25lIHdpdGggdGhlIHVuZGVybHlpbmcgY29ubmVj dGlvbi4NCiAgICAgICAgICAgICAgICBjb25uID0gY29ubi5kZXN0cm95Q2xvbmUoIHRydWUpOw0K ICAgICAgICAgICAgICAgIGNvbm4uY29ubmVjdCggYWRkcmVzcywgc3BlY2lmaWVkUG9ydCk7DQog ICAgICAgICAgICAgICAgYnJlYWs7DQogICAgICAgICAgICB9Y2F0Y2ggKExEQVBFeGNlcHRpb24g TEUpew0KICAgICAgICAgICAgICAgIGlmICghaG9zdExpc3QuaGFzTW9yZVRva2VucygpKQ0KICAg ICAgICAgICAgICAgICAgICB0aHJvdyBMRTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfQ0KICAg ICAgICByZXR1cm47DQogICAgfQ0KDQogICAgLy8qKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqDQogICAgLy8gZGVs ZXRlIG1ldGhvZHMNCiAgICAvLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioNCg0KICAgIC8qKg0KICAgICAqDQog ICAgICogU3luY2hyb25vdXNseSBkZWxldGVzIHRoZSBlbnRyeSB3aXRoIHRoZSBzcGVjaWZpZWQg ZGlzdGluZ3Vpc2hlZCBuYW1lDQogICAgICogZnJvbSB0aGUgZGlyZWN0b3J5Lg0KICAgICAqDQog ICAgICogPHA+Tm90ZTogQSBEZWxldGUgb3BlcmF0aW9uIHdpbGwgbm90IHJlbW92ZSBhbiBlbnRy eSB0aGF0IGNvbnRhaW5zDQogICAgICogc3Vib3JkaW5hdGUgZW50cmllcywgbm9yIHdpbGwgaXQg ZGVyZWZlcmVuY2UgYWxpYXMgZW50cmllcy4gPC9wPg0KICAgICAqDQogICAgICogIEBwYXJhbSBk biAgICAgIFRoZSBkaXN0aW5ndWlzaGVkIG5hbWUgb2YgdGhlIGVudHJ5IHRvIGRlbGV0ZS4NCiAg ICAgKg0KICAgICAqICBAZXhjZXB0aW9uIExEQVBFeGNlcHRpb24gQSBnZW5lcmFsIGV4Y2VwdGlv biB3aGljaCBpbmNsdWRlcyBhbiBlcnJvcg0KICAgICAqICBtZXNzYWdlIGFuZCBhbiBMREFQIGVy cm9yIGNvZGUuDQogICAgICovDQogICAgcHVibGljIHZvaWQgZGVsZXRlKFN0cmluZyBkbikNCiAg ICAgICAgdGhyb3dzIExEQVBFeGNlcHRpb24NCiAgICB7DQogICAgICAgIGRlbGV0ZShkbiwgZGVm U2VhcmNoQ29ucyk7DQogICAgICAgIHJldHVybjsNCiAgICB9DQoNCg0KICAgIC8qKg0KICAgICAq IFN5bmNocm9ub3VzbHkgZGVsZXRlcyB0aGUgZW50cnkgd2l0aCB0aGUgc3BlY2lmaWVkIGRpc3Rp bmd1aXNoZWQgbmFtZQ0KICAgICAqIGZyb20gdGhlIGRpcmVjdG9yeSwgdXNpbmcgdGhlIHNwZWNp ZmllZCBjb25zdHJhaW50cy4NCiAgICAgKg0KICAgICAqIDxwPk5vdGU6IEEgRGVsZXRlIG9wZXJh dGlvbiB3aWxsIG5vdCByZW1vdmUgYW4gZW50cnkgdGhhdCBjb250YWlucw0KICAgICAqIHN1Ym9y ZGluYXRlIGVudHJpZXMsIG5vciB3aWxsIGl0IGRlcmVmZXJlbmNlIGFsaWFzIGVudHJpZXMuIDwv cD4NCiAgICAgKg0KICAgICAqICBAcGFyYW0gZG4gICAgICBUaGUgZGlzdGluZ3Vpc2hlZCBuYW1l IG9mIHRoZSBlbnRyeSB0byBkZWxldGUuDQogICAgICo8YnI+PGJyPg0KICAgICAqICBAcGFyYW0g Y29ucyAgICBDb25zdHJhaW50cyBzcGVjaWZpYyB0byB0aGUgb3BlcmF0aW9uLg0KICAgICAqDQog ICAgICogIEBleGNlcHRpb24gTERBUEV4Y2VwdGlvbiBBIGdlbmVyYWwgZXhjZXB0aW9uIHdoaWNo IGluY2x1ZGVzIGFuIGVycm9yDQogICAgICogICAgICAgICAgICAgICAgICAgICAgICAgICBtZXNz YWdlIGFuZCBhbiBMREFQIGVycm9yIGNvZGUuDQogICAgICovDQogICAgcHVibGljIHZvaWQgZGVs ZXRlKFN0cmluZyBkbiwgTERBUENvbnN0cmFpbnRzIGNvbnMpDQogICAgICAgIHRocm93cyBMREFQ RXhjZXB0aW9uDQogICAgew0KICAgICAgICBMREFQUmVzcG9uc2VRdWV1ZSBxdWV1ZSA9DQogICAg ICAgICAgICBkZWxldGUoZG4sIG51bGwsIGNvbnMpOw0KDQogICAgICAgIC8vIEdldCBhIGhhbmRs ZSB0byB0aGUgZGVsZXRlIHJlc3BvbnNlDQogICAgICAgIExEQVBSZXNwb25zZSBkZWxldGVSZXNw b25zZSA9IChMREFQUmVzcG9uc2UpKHF1ZXVlLmdldFJlc3BvbnNlKCkpOw0KDQogICAgICAgIC8v IFNldCBsb2NhbCBjb3B5IG9mIHJlc3BvbnNlQ29udHJvbHMgc3luY2hyb25vdX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IGEgc2VydmVyIGluDQogICAgICogICAgICAgICAgICAgICAgICAg IHJlc3BvbnNlIHRvIHRoaXMgcmVxdWVzdC4gSWYgaXQgaXMgbnVsbCwgYQ0KICAgICAqICAgICAg ICAgICAgICAgICAgICBxdWV1ZSBvYmplY3QgaXMgY3JlYXRlZCBpbnRlcm5hbGx5Lg0KICAgICAq PGJyPjxicj4NCiAgICAgKiAgQHBhcmFtIGNvbnMgICAgVGhlIGNvbnN0cmFpbnRzIHNwZWNpZmlj IHRvIHRoZSBvcGVyYXRpb24uDQogICAgICoNCiAgICAgKiAgQGV4Y2VwdGlvbiBMREFQRXhjZXB0 aW9uIEEgZ2VuZXJhbCBleGNlcHRpb24gd2hpY2ggaW5jbHVkZXMgYW4gZXJyb3INCiAgICAgKiAg bWVzc2FnZSBhbmQgYW4gTERBUCBlcnJvciBjb2RlLg0KICAgICAqDQogICAgICovDQogICAgcHVi bGljIExEQVBSZXNwb25zZVF1ZXVlIGRlbGV0ZShTdHJpbmcgZG4sDQogICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICBMREFQUmVzcG9uc2VRdWV1ZSBxdWV1ZSwNCiAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgIExEQVBDb25zdHJhaW50cyBjb25zKQ0KICAgICAgICB0 aHJvd3MgTERBUEV4Y2VwdGlvbg0KICAgIHsNCiAgICAgICAgaWYoIERlYnVnLkxEQVBfREVCVUcp IHsNCiAgICAgICAgICAgIERlYnVnLnRyYWNlKCBEZWJ1Zy5hcGlSZXF1ZXN0cywgbmFtZSArDQog ICAgICAgICAgICAiZGVsZXRlKCIgKyBkbiArICIpIik7DQogICAgICAgIH0NCiAgICAgICAgaWYo ZG4gPT0gbnVsbCkgew0KICAgICAgICAgICAgLy8gSW52YWxpZCBETiBwYXJhbWV0ZXINCiAgICAg ICAgICAgIHRocm93IG5ldyBJbGxlZ2FsQXJndW1lbnRFeGNlcHRpb24oDQogICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgRXhjZXB0aW9uTWVzc2FnZXMuRE5fUEFSQU1fRVJST1Ip Ow0KICAgICAgICB9DQoNCiAgICAgICAgaWYoY29ucyA9PSBudWxsKQ0KICAgICAgICAgICAgY29u cyA9IGRlZlNlYXJjaENvbnM7DQoNCiAgICAgICAgTERBUE1lc3NhZ2UgbXNnID0gbmV3IExEQVBE ZWxldGVSZXF1ZXN0KCBkbiwgY29ucy5nZXRDb250cm9scygpKTsNCg0KICAgICAgICByZXR1cm4g c2VuZFJlcXVlc3RUb1NlcnZlcihtc2csIGNvbnMuZ2V0VGltZUxpbWl0KCksIHF1ZXVlLCBudWxs KTsNCiAgICB9DQoNCiAgICAvLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioNCiAgICAvLyBkaXNjb25uZWN0IG1l dGhvZA0KICAgIC8vKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KDQogICAgLyoqDQogICAgICoNCiAgICAgKiBT eW5jaHJvbm91c2x5IGRpc2Nvbm5lY3RzIGZyb20gdGhlIExEQVAgc2VydmVyLg0KICAgICAqDQog ICAgICogPHA+QmVmb3JlIHRoZSBvYmplY3QgY2FuIHBlcmZvcm0gTERBUCBvcGVyYXRpb25zIGFn YWluLCBpdCBtdXN0DQogICAgICogcmVjb25uZWN0IHRvIHRoZSBzZXJ2ZXIgYnkgY2FsbGluZyBj b25uZWN0LjwvcD4NCiAgICAgKg0KICAgICAqIDxwPlRoZSBkaXNjb25uZWN0IG1ldGhvZCBhYmFu ZG9ucyBhbnkgb3V0c3RhbmRpbmcgcmVxdWVzdHMsIGlzc3VlcyBhbg0KICAgICAqIHVuYmluZCBy ZXF1ZXN0IHRvIHRoZSBzZXJ2ZXIsIGFuZCB0aGVuIGNsb3NlcyB0aGUgc29ja2V0LjwvcD4NCiAg ICAgKg0K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uIGVycm9yDQogICAgICogIG1lc3NhZ2UgYW5kIGFu IExEQVAgZXJyb3IgY29kZS4NCiAgICAgKi8NCiAgICBwdWJsaWMgdm9pZCBkaXNjb25uZWN0KCBM REFQQ29uc3RyYWludHMgY29ucykNCiAgICAgICAgdGhyb3dzIExEQVBFeGNlcHRpb24NCiAgICB7 DQogICAgICAgIC8vIGRpc2Nvbm5lY3QgZnJvbSBBUEkgY2FsbA0KICAgICAgICBkaXNjb25uZWN0 KGNvbnMsIHRydWUpOw0KICAgICAgICByZXR1cm47DQogICAgfQ0KDQogICAgLyoqDQogICAgICog U3luY2hyb25vdXNseSBkaXNjb25uZWN0IGZyb20gdGhlIHNlcnZlcg0KICAgICAqDQogICAgICog QHBhcmFtIGhvdyB0cnVlIGlmIGFwcGxpY2F0aW9uIGNhbGwgZGlzY29ubmVjdCBBUEksIGZhbHNl IGlmIGZpbmFsaXplLg0KICAgICAqLw0KICAgIHByaXZhdGUgdm9pZCBkaXNjb25uZWN0KExEQVBD b25zdHJhaW50cyBjb25zLCBib29sZWFuIGhvdykNCiAgICAgICAgdGhyb3dzIExEQVBFeGNlcHRp b24NCiAgICB7DQogICAgICAgIC8vIGRpc2Nvbm5lY3QgZG9lc24ndCBhZmZlY3Qgb3RoZXIgY2xv bmVzDQogICAgICAgIC8vIElmIG5vdCBhIGNsb25lLCBkaXN0cm95cyBjb25uZWN0aW9uDQogICAg ICAgIGlmKCBEZWJ1Zy5MREFQX0RFQlVHKSB7DQogICAgICAgICAgICBEZWJ1Zy50cmFjZSggRGVi dWcuYXBpUmVxdWVzdHMsIG5hbWUgKw0KICAgICAgICAgICAgKGhvdz8iZGlzY29ubmVjdCgpIjoi ZmluYWxpemUoKSIpKTsNCiAgICAgICAgfQ0KICAgICAgICBjb25uID0gY29ubi5kZXN0cm95Q2xv bmUoaG93KTsNCiAgICAgICAgcmV0dXJuOw0KICAgIH0NCg0KICAgIC8vKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq Kg0KICAgIC8vIGV4dGVuZGVkT3BlcmF0aW9uIG1ldGhvZHMNCiAgICAvLyoqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioNCg0KICAgIC8qKg0KICAgICAqIFByb3ZpZGVzIGEgc3luY2hyb25vdXMgbWVhbnMgdG8gYWNj ZXNzIGV4dGVuZGVkLCBub24tbWFuZGF0b3J5DQogICAgICogb3BlcmF0aW9ucyBvZmZlcmVkIGJ5 IGEgcGFydGljdWxhciBMREFQdjMgY29tcGxpYW50IHNlcnZlci4NCiAgICAgKg0KICAgICAqIEBw YXJhbSBvcCAgVGhlIG9iamVjdCB3aGljaCBjb250YWlucyAoMSkgYW4gaWRlbnRpZmllciBvZiBh biBleHRlbmRlZA0KICAgICAqICAgICAgICAgICAgb3BlcmF0aW9uIHdoaWNoIHNob3VsZCBiZSBy ZWNvZ25pemVkIGJ5IHRoZSBwYXJ0aWN1bGFyIExEQVANCiAgICAgKiAgICAgICAgICAgIHNlcnZl ciB0aGlzIGNsaWVudCBpcyBjb25uZWN0ZWQgdG8gYW5kICgyKQ0KICAgICAqICAgICAgICAgICAg YW4gb3BlcmF0aW9uLXNwZWNpZmljIHNlcXVlbmNlIG9mIG9jdGV0IHN0cmluZ3MNCiAgICAgKiAg ICAgICAgICAgIG9yIEJFUi1lbmNvZGVkIHZhbHVlcy4NCiAgICAgKg0KICAgICAqIEByZXR1cm4g QW4gb3BlcmF0aW9uLXNwZWNpZmljIG9iamVjdCwgY29udGFpbmluZyBhbiBJRCBhbmQgZWl0aGVy IGFuIG9jdGV0DQogICAgICogc3RyaW5nIG9yIEJFUi1lbmNvZGVkIHZhbHVlcy4NCiAgICAgKg0K ICAgICAqIEBleGNlcHRpb24gTERBUEV4Y2VwdGlvbiBBIGdlbmVyYWwgZXhjZXB0aW9uIHdoaWNo IGluY2x1ZGVzIGFuIG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HN5bmNocm9ub3VzbHkgLSBpZiB0aGVyZSB3ZXJlIGFueQ0KICAgICAgICBzeW5j aHJvbml6ZWQgKHJlc3BvbnNlQ3RsU2VtYXBob3JlKSB7DQogICAgICAgICAgICByZXNwb25zZUN0 bHMgPSByZXNwb25zZS5nZXRDb250cm9scygpOw0KICAgICAgICB9DQoNCiAgICAgICAgY2hrUmVz dWx0Q29kZSggcXVldWUsIGNvbnMsIHJlc3BvbnNlKTsNCiAgICAgICAgcmV0dXJuIHJlc3BvbnNl Ow0KICAgIH0NCg0KDQogICAgLyoNCiAgICAgKiBBc3luY2hyb25vdXMgTERBUCBleHRlbmRlZCBy ZXF1ZXN0DQogICAgICovDQoNCiAgICAvKioNCiAgICAgKiBQcm92aWRlcyBhbiBhc3luY2hyb25v dXMgbWVhbnMgdG8gYWNjZXNzIGV4dGVuZGVkLCBub24tbWFuZGF0b3J5DQogICAgICogb3BlcmF0 aW9ucyBvZmZlcmVkIGJ5IGEgcGFydGljdWxhciBMREFQdjMgY29tcGxpYW50IHNlcnZlci4NCiAg ICAgKg0KICAgICAqIEBwYXJhbSBvcCAgVGhlIG9iamVjdCB3aGljaCBjb250YWlucyAoMSkgYW4g aWRlbnRpZmllciBvZiBhbiBleHRlbmRlZA0KICAgICAqICAgICAgICAgICAgb3BlcmF0aW9uIHdo aWNoIHNob3VsZCBiZSByZWNvZ25pemVkIGJ5IHRoZSBwYXJ0aWN1bGFyIExEQVANCiAgICAgKiAg ICAgICAgICAgIHNlcnZlciB0aGlzIGNsaWVudCBpcyBjb25uZWN0ZWQgdG8gYW5kICgyKSBhbg0K ICAgICAqICAgICAgICAgICAgb3BlcmF0aW9uLXNwZWNpZmljIHNlcXVlbmNlIG9mIG9jdGV0IHN0 cmluZ3MNCiAgICAgKiAgICAgICAgICAgIG9yIEJFUi1lbmNvZGVkIHZhbHVlcy4NCiAgICAgKjxi cj48YnI+DQogICAgICogQHBhcmFtIHF1ZXVlICAgICBUaGUgcXVldWUgZm9yIG1lc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og ICAgICoNCiAgICAgKiBAZXhjZXB0aW9uIExEQVBFeGNlcHRpb24gQSBnZW5lcmFsIGV4Y2VwdGlv biB3aGljaCBpbmNsdWRlcyBhbiBlcnJvcg0KICAgICAqICBtZXNzYWdlIGFuZCBhbiBMREFQIGVy cm9yIGNvZGUuDQogICAgICovDQoNCiAgICBwdWJsaWMgTERBUFJlc3BvbnNlUXVldWUgZXh0ZW5k ZWRPcGVyYXRpb24oTERBUEV4dGVuZGVkT3BlcmF0aW9uIG9wLA0KICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICBMREFQQ29uc3RyYWludHMgY29ucywNCiAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTERBUFJlc3BvbnNlUXVl dWUgcXVldWUpDQogICAgICAgIHRocm93cyBMREFQRXhjZXB0aW9uDQogICAgew0KICAgICAgICAv LyBVc2UgZGVmYXVsdCBjb25zdHJhaW50cyBpZiBub25lLXNwZWNpZmllZA0KICAgICAgICBpZihj b25zID09IG51bGwpDQogICAgICAgICAgICBjb25zID0gZGVmU2VhcmNoQ29uczsNCiAgICAgICAg TERBUE1lc3NhZ2UgbXNnID0gbWFrZUV4dGVuZGVkT3BlcmF0aW9uKG9wLCBjb25zKTsNCiAgICAg ICAgcmV0dXJuIHNlbmRSZXF1ZXN0VG9TZXJ2ZXIobXNnLCBjb25zLmdldFRpbWVMaW1pdCgpLCBx dWV1ZSwgbnVsbCk7DQogICAgfQ0KDQogICAgLyoqDQogICAgICogRm9ybXVsYXRlcyB0aGUgZXh0 ZW5kZWQgb3BlcmF0aW9uLCBjb25zdHJhaW50cyBpbnRvIGFuDQogICAgICogTERBUE1lc3NhZ2Ug YW5kIHJldHVybnMgdGhlIExEQVBNZXNzYWdlLiAgVGhpcyBpcyB1c2VkIGJ5DQogICAgICogZXh0 ZW5kZWRPcGVyYXRpb24gYW5kIHN0YXJ0VExTIHdoaWNoIG5lZWRzIHRoZSBMREFQTWVzc2FnZSB0 bw0KICAgICAqIGdldCB0aGUgTWVzc2FnZUlELg0KICAgICAqLw0KICAgIHByb3RlY3RlZCBMREFQ TWVzc2FnZSBtYWtlRXh0ZW5kZWRPcGVyYXRpb24oTERBUEV4dGVuZGVkT3BlcmF0aW9uIG9wLA0K ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTERBUENvbnN0 cmFpbnRzIGNvbnMpDQogICAgICAgIHRocm93cyBMREFQRXhjZXB0aW9uDQogICAgew0KICAgICAg ICAvLyBVc2UgZGVmYXVsdCBjb25zdHJhaW50cyBpZiBub25lLXNwZWNpZmllZA0KICAgICAgICBp Zihjb25zID09IG51bGwpDQogICAgICAgICAgICBjb25zID0gZGVmU2VhcmNoQ29uczsNCg0KICAg ICAgICAvLyBlcnJvciBjaGVjayB0aGUgcGFyYW1ldGVycw0KICAgICAgICBpZiAob3AuZ2V0SUQo KSA9PSBudWxsKSB7DQogICAgICAgICAgICAvLyBJbnZhbGlkIGV4dGVuZGVkIG9wZXJhdGlvbiBw YXJhbWV0ZXIsIG5vIE9JRCBzcGVjaWZpZWQNCiAgICAgICAgICAgIHRocm93IG5ldyBJbGxlZ2Fs QXJndW1lbnRFeGNlcHRpb24oDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg RXhjZXB0aW9uTWVzc2FnZXMuT1BfUEFSQU1fRVJST1IpOw0KICAgICAgICB9DQoNCiAgICAgICAg cmV0dXJuIG5ldyBMREFQRXh0ZW5kZWRSZXF1ZXN0KG9wLCBjb25zLmdldENvbnRyb2xzKCkpOw0K ICAgIH0NCg0KICAgIC8vKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIC8vIGdldFJlc3BvbnNlQ29udHJv bHMgbWV0aG9kDQogICAgLy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqDQoNCiAgICAgLyoqDQogICAgICogIFJl dHVybnMgdGhlIFNlcnZlciBDb250cm9scyBhc3NvY2lhdGVkIHdpdGggdGhlIG1vc3QgcmVjZW50 IHJlc3BvbnNlDQogICAgICogIHRvIGEgc3luY2hyb25vdXMgcmVxdWVzdCBvbiB0aGlzIGNvbm5l Y3Rpb24gb2JqZWN0LCBvciBudWxsDQogICAgICogIGlmIHRoZSBsYXRlc3QgcmVzcG9uc2UgY29u dGFpbmVkIG5vIFNlcnZlciBDb250cm9scy4gVGhlIG1ldGhvZA0KICAgICAqICBhbHdheXMgcmV0 dXJucyBudWxsIGZvciBhc3luY2hyb25vdXMgcmVxdWVzdHMuIEZvciBhc3luY2hyb25vdXMNCiAg ICAgKiAgcmVxdWVzdHMsIHRoZSByZXNwb25zZSBjb250cm9scyBhcmUgYXZhaWxhYmxlIGluIExE QVBNZXNzYWdlLg0KICAgICAqDQogICAgICogIEByZXR1cm4gVGhlIHNlcnZlciBjb250cm9scyBh c3NvY2lhdGVkIHdpdGggdGhlIG1vc3QgcmVjZW50IHJlc3BvbnNlDQogICAgICogIHRvIGEgc3lu Y2hyb25vdXMgcmVxdWVzdCBvciBudWxsIGlmIHRoZSByZXNwb25zZSBjb250YWlucyBubyBzZXJ2 ZXINCiAgICAgKiAgY29udHJvbHMuDQogICAgICoNCiAgICAgKiBAc2VlIExEQVBNZXNzYWdlI2dl dENvbnRyb2xzKCkNCiAgICAgKi8NCiAgICBwdWJsaWMgTERBUENvbnRyb2xbXSBnZXRSZXNwb25z ZUNvbnRyb2xzKCkNCiAgICB7DQogICAgICAgIGlmKCByZXNwb25zZUN0bHMgPT0gbnVsbCkgew0K ICAgICAgICAgICAgaWYoIERlYnVnLkxEQVBfREVCVUcpIHsNCiAgICAgICAgICAgICAgICBEZWJ1 Zy50cmFjZSggRGVidWcuYXBpUmVxdWVzdHMsIG5hbWUgKw0KICAgICAgICAgICAgICAgICJnZXRS ZXNwb25zZUNvbnRyb2xzKCkgcmV0dXJucyBudWxsIik7DQogICAgICAgICAgICB9DQogICAgICAg ICAgICByZXR1cm4gbnVsbDsNCiAgICAgICAgfQ0KDQogICAgICAgIGlmKCBEZWJ1Zy5MREFQX0RF QlVHKSB7DQogICAgICAgICAgICBEZWJ1Zy50cmFjZSggRGVidWcuYXBpUmVxdWVzdHMsIG5hbWUg Kw0KICAgICAgICAgICAgImdldFJlc3BvbnNlQ29udHJvbHMoKSIpOw0KICAgICAgICB9DQoNCiAg ICAgICAgLy8gV2UgaGF2ZSB0byBjbG9uZSB0aGUgY29udHJvbCBqdXN0IGluIGNhc2UNCiAgICAg ICAgLy8gd2UgaGF2ZSB0d28gY2xpZW50IHRocmVhZHMgdGhhdCBlbmQgdXAgcmV0cmVpdmluZyB0 aGUNCiAgICAgICAgLy8gc2FtZSBjb250cm9sLg0KICAgICAgICBMREFQQ29udHJvbCBbXSBjbG9u ZWRDb250cm9sID0gbmV3IExEQVBDb250cm9sIFtyZXNwb25zZUN0bHMubGVuZ3RoXTsNCg0KICAg ICAgICAvLyBBbHNvIG5vdGUgd2Ugc3luY2hyb25pemUgYWNjZXNzIHRvIHRoZSBsb2NhbCByZXNw b25zZQ0KICAgICAgICAvLyBjb250cm9sIG9iamVjdCBqdXN0IGluIGNhc2UgYW5vdGhlciBtZXNz YWdlIGNvbnRhaW5pbmcgY29udHJvbHMNCiAgICAgICAgLy8gY29tZXMgaW4gZnJvbSB0aGUgc2Vy dmVyIHdoaWxlIHdlIGFyZSBidXN5IGR1cGxpY2F0aW5nDQogICAgICAgIC8vIHRoaXMgb25lLg0K ICAgICAgICBzeW5jaHJvbml6ZWQgKHJlc3BvbnNlQ3RsU2VtYXBob3JlKSB7DQogICAgICAgICAg ICBmb3IoaW50IGkgPSAwOyBpIDwgcmVzcG9uc2VDdGxzLmxlbmd0aDsgaSsrKSB7DQogICAgICAg ICAgICAgICAgICAgY2xvbmVkQ29udHJvbFtpXSA9IChMREFQQ29udHJvbCkgKHJlc3BvbnNlQ3Rs c1tpXSkuY2xvbmUoKTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfQ0KDQogICAgICAgIC8vIFJl dHVybiB0aGUgY2xvbmVkIGNvcHkuICBOb3RlIHdlIGhhdmUgc3RpbGwgbGVmdCB0aGUNCiAgICAg ICAgLy8gY29udHJvbCBpbiB0aGUgbG9jYWwgcmVzcG9uc2VDdGxzIHZhcmlhYmxlIGp1c3QgaW4g Y2FzZQ0KICAgICAgICAvLyBzb21lYm9keSByZXF1ZXN0cyBpdCBhZ2Fpbi4NCiAgICAgICAgcmV0 dXJuIGNsb25lZENvbnRyb2w7DQogICAgfQ0KDQogICAgLy8qKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqDQogICAg Ly8gbW9kaWZ5IG1ldGhvZHMNCiAgICAvLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioNCg0KICAgIC8qKg0KICAg ICAqIFN5bmNocm9ub3VzbHkgbWFrZXMgYSBzaW5nbGUgY2hhbmdlIHRvIGFuIGV4aXN0aW5nIGVu dHJ5IGluIHRoZQ0KICAgICAqIGRpcmVjdG9yeS4NCiAgICAgKg0KICAgICAqIDxwPkZvciBleGFt cGxlLCB0aGlzIG1vZGlmeSBtZXRob2QgY2hhbmdlcyB0aGUgdmFsdWUgb2YgYW4gYXR0cmlidXRl LA0KICAgICAqIGFkZHMgYSBuZXcgYXR0cmlidXRlIHZhbHVlLCBvciByZW1vdmVzIGFuIGV4aXN0 aW5nIGF0dHJpYnV0ZSB2YWx1ZS4gPC9wPg0KICAgICAqDQogICAgICogPHA+VGhlIExEQVBNb2Rp ZmljYXRpb24gb2JqZWN0IHNwZWNpZmllcyBib3RoIHRoZSBjaGFuZ2UgdG8gYmUgbWFkZSBhbmQN CiAgICAgKiB0aGUgTERBUEF0dHJpYnV0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QVAgZXJyb3IgY29kZS4NCiAgICAgKi8NCiAgICBwdWJsaWMgdm9pZCBtb2RpZnkoIFN0cmlu ZyBkbiwNCiAgICAgICAgICAgICAgICAgICAgICAgIExEQVBNb2RpZmljYXRpb25bXSBtb2RzLA0K ICAgICAgICAgICAgICAgICAgICAgICAgTERBUENvbnN0cmFpbnRzIGNvbnMpDQogICAgICAgIHRo cm93cyBMREFQRXhjZXB0aW9uDQogICAgew0KICAgICAgICBMREFQUmVzcG9uc2VRdWV1ZSBxdWV1 ZSA9DQogICAgICAgICAgICBtb2RpZnkoZG4sIG1vZHMsIG51bGwsIGNvbnMpOw0KDQogICAgICAg IC8vIEdldCBhIGhhbmRsZSB0byB0aGUgbW9kaWZ5IHJlc3BvbnNlDQogICAgICAgIExEQVBSZXNw b25zZSBtb2RpZnlSZXNwb25zZSA9IChMREFQUmVzcG9uc2UpKHF1ZXVlLmdldFJlc3BvbnNlKCkp Ow0KDQogICAgICAgIC8vIFNldCBsb2NhbCBjb3B5IG9mIHJlc3BvbnNlQ29udHJvbHMgc3luY2hy b25vdXNseSAtIGlmIHRoZXJlIHdlcmUgYW55DQogICAgICAgIHN5bmNocm9uaXplZCAocmVzcG9u c2VDdGxTZW1hcGhvcmUpIHsNCiAgICAgICAgICAgIHJlc3BvbnNlQ3RscyA9IG1vZGlmeVJlc3Bv bnNlLmdldENvbnRyb2xzKCk7DQogICAgICAgIH0NCg0KICAgICAgICBjaGtSZXN1bHRDb2RlKCBx dWV1ZSwgY29ucywgbW9kaWZ5UmVzcG9uc2UpOw0KDQogICAgICAgIHJldHVybjsNCiAgICB9DQoN CiAgICAvKioNCiAgICAgKiBBc3luY2hyb25vdXNseSBtYWtlcyBhIHNpbmdsZSBjaGFuZ2UgdG8g YW4gZXhpc3RpbmcgZW50cnkgaW4gdGhlDQogICAgICogZGlyZWN0b3J5Lg0KICAgICAqDQogICAg ICogPHA+Rm9yIGV4YW1wbGUsIHRoaXMgbW9kaWZ5IG1ldGhvZCBjYW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nJvciBpcyByZXR1cm5lZC4NCiAgICAgKiBJZiB0aGUgcmVxdWVzdCBmYWlscyB3 aXRoIHtAbGluayBMREFQRXhjZXB0aW9uI0NPTk5FQ1RfRVJST1J9LA0KICAgICAqIGl0IGlzIGlu ZGV0ZXJtaW5hdGUgd2hldGhlciBvciBub3QgdGhlIHNlcnZlciBtYWRlIHRoZSBtb2RpZmljYXRp b25zLjwvcD4NCiAgICAgKg0KICAgICAqICBAcGFyYW0gZG4gICAgICAgICBUaGUgZGlzdGluZ3Vp c2hlZCBuYW1lIG9mIHRoZSBlbnRyeSB0byBtb2RpZnkuDQogICAgICo8YnI+PGJyPg0KICAgICAq ICBAcGFyYW0gbW9kcyAgICAgICBUaGUgY2hhbmdlcyB0byBiZSBtYWRlIHRvIHRoZSBlbnRyeS4N CiAgICAgKjxicj48YnI+DQogICAgICogIEBwYXJhbSBxdWV1ZSAgICAgIFRoZSBxdWV1ZSBmb3Ig bWVzc2FnZXMgcmV0dXJuZWQgZnJvbSBhIHNlcnZlciBpbg0KICAgICAqICAgICAgICAgICAgICAg ICAgICByZXNwb25zZSB0byB0aGlzIHJlcXVlc3QuIElmIGl0IGlzIG51bGwsIGENCiAgICAgKiAg ICAgICAgICAgICAgICAgICAgcXVldWUgb2JqZWN0IGlzIGNyZWF0ZWQgaW50ZXJuYWxseS4NCiAg ICAgKg0KICAgICAqIEBleGNlcHRpb24gTERBUEV4Y2VwdGlvbiBBIGdlbmVyYWwgZXhjZXB0aW9u IHdoaWNoIGluY2x1ZGVzIGFuIGVycm9yDQogICAgICogbWVzc2FnZSBhbmQgYW4gTERBUCBlcnJv ciBjb2RlLg0KICAgICAqLw0KICAgIHB1YmxpYyBMREFQUmVzcG9uc2VRdWV1ZSBtb2RpZnkoU3Ry aW5nIGRuLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTERBUE1vZGlmaWNh dGlvbltdIG1vZHMsDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB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AgICAgICAgIFRoZSBkaXN0aW5ndWlzaGVkIG5hbWUgb2YgdGhlIGVudHJ5IHRvIG1vZGlm eS4NCiAgICAgKjxicj48YnI+DQogICAgICogIEBwYXJhbSBtb2RzICAgICAgIFRoZSBjaGFuZ2Vz IHRvIGJlIG1hZGUgdG8gdGhlIGVudHJ5Lg0KICAgICAqPGJyPjxicj4NCiAgICAgKiAgQHBhcmFt IHF1ZXVlICAgICAgVGhlIHF1ZXVlIGZvciBtZXNzYWdlcyByZXR1cm5lZCBmcm9tIGEgc2VydmVy IGluDQogICAgICogICAgICAgICAgICAgICAgICAgIHJlc3BvbnNlIHRvIHRoaXMgcmVxdWVzdC4g SWYgaXQgaXMgbnVsbCwgYQ0KICAgICAqICAgICAgICAgICAgICAgICAgICBxdWV1ZSBvYmplY3Qg aXMgY3JlYXRlZCBpbnRlcm5hbGx5Lg0KICAgICAqPGJyPjxicj4NCiAgICAgKiAgQHBhcmFtIGNv bnMgICAgICAgQ29uc3RyYWludHMgc3BlY2lmaWMgdG8gdGhlIG9wZXJhdGlvbi4NCiAgICAgKg0K ICAgICAqICBAZXhjZXB0aW9uIExEQVBFeGNlcHRpb24gQSBnZW5lcmFsIGV4Y2VwdGlvbiB3aGlj aCBpbmNsdWRlcyBhbiBlcnJvcg0KICAgICAqICBtZXNzYWdlIGFuZCBhbiBMREFQIGVycm9yIGNv ZGUuDQogICAgICovDQogICAgcHVibGljIExEQVBSZXNwb25zZVF1ZXVlIG1vZGlmeShTdHJpbmcg ZG4sDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBMREFQTW9kaWZpY2F0aW9u W10gbW9kcywNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIExEQVBSZXNwb25z ZVF1ZXVlIHF1ZXVlLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTERBUENv bnN0cmFpbnRzIGNvbnMpDQogICAgICAgIHRocm93cyBMREFQRXhjZXB0aW9uDQogICAgew0KICAg ICAgICBpZiggRGVidWcuTERBUF9ERUJVRykgew0KICAgICAgICAgICAgRGVidWcudHJhY2UoIERl YnVnLmFwaVJlcXVlc3RzLCBuYW1lICsNCiAgICAgICAgICAgICJtb2RpZnkoIiArIGRuICsgIiks ICIgKyBtb2RzLmxlbmd0aCArICIgbW9kaWZpY2F0aW9ucyIpOw0KICAgICAgICB9DQogICAgICAg IGlmKGRuID09IG51bGwpIHsNCiAgICAgICAgICAgIC8vIEludmFsaWQgRE4gcGFyYW1ldGVyDQog ICAgICAgICAgICB0aHJvdyBuZXcgSWxsZWdhbEFyZ3VtZW50RXhjZXB0aW9uKA0KICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgIEV4Y2VwdGlvbk1lc3NhZ2VzLkROX1BBUkFNX0VS Uk9SKTsNCiAgICAgICAgfQ0KDQogICAgICAgIGlmKGNvbnMgPT0gbnVsbCkNCiAgICAgICAgICAg IGNvbnMgPSBkZWZTZWFyY2hDb25zOw0KDQogICAgICAgIExEQVBNZXNzYWdlIG1zZyA9IG5ldyBM REFQTW9kaWZ5UmVxdWVzdCggZG4sIG1vZHMsIGNvbnMuZ2V0Q29udHJvbHMoKSk7DQoNCiAgICAg ICAgcmV0dXJuIHNlbmRSZXF1ZXN0VG9TZXJ2ZXIobXNnLCBjb25zLmdldFRpbWVMaW1pdCgpLCBx dWV1ZSwgbnVsbCk7DQogICAgfQ0KDQogICAgLy8qKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqDQogICAgLy8gcmVh ZCBtZXRob2RzDQogICAgLy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqDQoNCiAgICAvKioNCiAgICAgKiBTeW5j aHJvbm91c2x5IHJlYWRzIHRoZSBlbnRyeSBmb3IgdGhlIHNwZWNpZmllZCBkaXN0aWd1aXNoZWQg bmFt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c2VydmVyDQogICAgICoNCiAgICAgKiAgQGV4Y2Vw dGlvbiBMREFQRXhjZXB0aW9uIGlmIHRoZSBvYmplY3Qgd2FzIG5vdCBmb3VuZA0KICAgICAqLw0K ICAgIHB1YmxpYyBMREFQRW50cnkgcmVhZChTdHJpbmcgZG4sDQogICAgICAgICAgICAgICAgICAg ICAgICAgIExEQVBTZWFyY2hDb25zdHJhaW50cyBjb25zKQ0KICAgICAgICB0aHJvd3MgTERBUEV4 Y2VwdGlvbg0KICAgIHsNCiAgICAgICAgcmV0dXJuIHJlYWQoZG4sIG51bGwsIGNvbnMpOw0KICAg IH0NCg0KICAgIC8qKg0KICAgICAqDQogICAgICogU3luY2hyb25vdXNseSByZWFkcyB0aGUgZW50 cnkgZm9yIHRoZSBzcGVjaWZpZWQgZGlzdGluZ3Vpc2hlZCBuYW1lIChETikNCiAgICAgKiBhbmQg cmV0cmlldmVzIG9ubHkgdGhlIHNwZWNpZmllZCBhdHRyaWJ1dGVzIGZyb20gdGhlIGVudHJ5Lg0K ICAgICAqDQogICAgICogIEBwYXJhbSBkbiAgICAgICAgIFRoZSBkaXN0aW5ndWlzaGVkIG5hbWUg b2YgdGhlIGVudHJ5IHRvIHJldHJpZXZlLg0KICAgICAqPGJyPjxicj4NCiAgICAgKiAgQHBhcmFt IGF0dHJzICAgICAgVGhlIG5hbWVzIG9mIHRoZSBhdHRyaWJ1dGVzIHRvIHJldHJpZXZlLg0KICAg ICAqDQogICAgICogIEByZXR1cm4gdGhlIExEQVBFbnRyeSByZWFkIGZyb20gdGhlIHNlcnZlcg0K ICAgICAqDQogICAgICogIEBleGNlcHRpb24gTERBUEV4Y2VwdGlvbiBpZiB0aGUgb2JqZWN0IHdh cyBub3QgZm91bmQNCiAgICAgKi8NCiAgICBwdWJsaWMgTERBUEVudHJ5IHJlYWQoU3RyaW5nIGRu LA0KICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmdbXSBhdHRycykNCiAgICAgICAgdGhy b3dzIExEQVBFeGNlcHRpb24NCiAgICB7DQogICAgICAgIHJldHVybiByZWFkKGRuLCBhdHRycywg ZGVmU2VhcmNoQ29ucyk7DQogICAgfQ0KDQogICAgLyoqDQogICAgICogU3luY2hyb25vdXNseSBy ZWFkcyB0aGUgZW50cnkgZm9yIHRoZSBzcGVjaWZpZWQgZGlzdGluZ3Vpc2hlZCBuYW1lIChETiks DQogICAgICogdXNpbmcgdGhlIHNwZWNpZmllZCBjb25zdHJhaW50cywgYW5kIHJldHJpZXZlcyBv bmx5IHRoZSBzcGVjaWZpZWQNCiAgICAgKiBhdHRyaWJ1dGVzIGZyb20gdGhlIGVudHJ5Lg0KICAg ICAqDQogICAgICogIEBwYXJhbSBkbiAgICAgICBUaGUgZGlzdGluZ3Vpc2hlZCBuYW1lIG9mIHRo ZSBlbnRyeSB0byByZXRyaWV2ZS4NCiAgICAgKjxicj48YnI+DQogICAgICogIEBwYXJhbSBhdHRy cyAgICBUaGUgbmFtZXMgb2YgdGhlIGF0dHJpYnV0ZXMgdG8gcmV0cmlldmUuDQogICAgICo8YnI+ PGJyPg0KICAgICAqICBAcGFyYW0gY29ucyAgICAgVGhlIGNvbnN0cmFpbnRzIHNwZWNpZmljIHRv IHRoZSBvcGVyYXRpb24uDQogICAgICoNCiAgICAgKiAgQHJldHVybiB0aGUgTERBUEVudHJ5IHJl YWQgZnJvbSB0aGUgc2VydmVyDQogICAgICoNCiAgICAgKiAgQGV4Y2VwdGlvbiBMREFQRXhjZXB0 aW9uIGlmIHRoZSBvYmplY3Qgd2FzIG5vdCBmb3VuZA0KICAgICAqLw0KICAgIHB1YmxpYyBMREFQ RW50cnkgcmVhZChTdHJpbmcgZG4sDQogICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZ1td IGF0dHJzLA0KICAgICAgICAgICAgICAgICAgICAgICAgICBMREFQU2VhcmNoQ29uc3RyYWludHMg Y29ucykNCiAgICAgICAgdGhyb3dzIExEQVBFeGNlcHRpb24NCiAgICB7DQogICAgICAgIGlmKCBE ZWJ1Zy5MREFQX0RFQlVHKSB7DQogICAgICAgICAgICBEZWJ1Zy50cmFjZSggRGVidWcuYXBpUmVx dWVzdHMsIG5hbWUgKw0KICAgICAgICAgICAgInJlYWQoIiArIGRuICsgIikiKTsNCiAgICAgICAg fQ0KICAgICAgICBMREFQU2VhcmNoUmVzdWx0cyBzciA9IHNlYXJjaChkbiwgU0NPUEVfQkFTRSwN CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbnVsbCwNCiAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgYXR0cnMsIGZhbHNlLCBjb25zKTsNCg0KICAgICAg ICBMREFQRW50cnkgcmV0ID0gbnVsbDsNCiAgICAgICAgaWYoIHNyLmhhc01vcmUoKSkgew0KICAg ICAgICAgICAgcmV0ID0gc3IubmV4dCgpOw0KICAgICAgICAgICAgaWYoIHNyLmhhc01vcmUoKSkg ew0KICAgICAgICAgICAgICAgIC8vICJSZWFkIHJlc3BvbnNlIGlzIGFtYmlndW91cywgbXVsdGlw bGUgZW50cmllcyByZXR1cm5lZCINCiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgTERBUExvY2Fs RXhjZXB0aW9uKEV4Y2VwdGlvbk1lc3NhZ2VzLlJFQURfTVVMVElQTEUsDQogICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICBMREFQRXhjZXB0aW9uLkFNQklHVU9VU19SRVNQT05TRSk7 DQogICAgICAgICAgICB9DQogICAgICAgIH0NCiAgICAgICAgcmV0dXJuIHJldDsNCiAgICB9DQoN CiAgICAvKioNCiAgICAgKiBTeW5jaHJvbm91c2x5IHJlYWRzIHRoZSBlbnRyeSBzcGVjaWZpZWQg YnkgdGhlIExEQVAgVVJMLg0KICAgICAqDQogICAgICogPHA+V2hlbiB0aGlzIHJlYWQgbWV0aG9k IGlzIGNhbGxlZCwgYSBuZXcgY29ubmVjdGlvbiBpcyBjcmVhdGVkDQogICAgICogYXV0b21hdGlj YW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50b1N0cmluZygpICsgIikiKTsNCiAgICAgICAgfQ0KICAgICAgICBM REFQQ29ubmVjdGlvbiBsY29ubiA9IG5ldyBMREFQQ29ubmVjdGlvbigpOw0KICAgICAgICBsY29u bi5jb25uZWN0KHRvR2V0LmdldEhvc3QoKSx0b0dldC5nZXRQb3J0KCkpOw0KICAgICAgICBMREFQ RW50cnkgdG9SZXR1cm4gPSBsY29ubi5yZWFkKHRvR2V0LmdldEROKCksDQogICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICB0b0dldC5nZXRBdHRyaWJ1dGVBcnJheSgpLCBjb25zKTsN CiAgICAgICAgaWYoIERlYnVnLkxEQVBfREVCVUcpIHsNCiAgICAgICAgICAgIERlYnVnLnRyYWNl KCBEZWJ1Zy5hcGlSZXF1ZXN0cywgInJlYWQ6IGRpc2Nvbm5lY3QoKSIpOw0KICAgICAgICB9DQog ICAgICAgIGxjb25uLmRpc2Nvbm5lY3QoKTsNCiAgICAgICAgcmV0dXJuIHRvUmV0dXJuOw0KICAg IH0NCg0KICAgIC8vKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIC8vIHJlbmFtZSBtZXRob2RzDQogICAg Ly8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqDQoNCiAgICAvKioNCiAgICAgKg0KICAgICAqIFN5bmNocm9ub3Vz bHkgcmVuYW1lcyBhbiBleGlzdGluZyBlbnRyeSBpbiB0aGUgZGlyZWN0b3J5Lg0KICAgICAqDQog ICAgICogIEBwYXJhbSBkbiAgICAgICBUaGUgY3VycmVudCBkaXN0aW5ndWlzaGVkIG5hbWUgb2Yg dGhlIGVudHJ5Lg0KICAgICAqPGJyPjxicj4NCiAgICAgKiAgQHBhcmFtIG5ld1JkbiAgIFRoZSBu ZXcgcmVsYXRpdmUgZGlzdGluZ3Vpc2hlZCBuYW1lIGZvciB0aGUgZW50cnkuDQogICAgICo8YnI+ PGJyPg0KICAgICAqICBAcGFyYW0gZGVsZXRlT2xkUmRuICAgSWYgdHJ1ZSwgdGhlIG9sZCBuYW1l IGlzIG5vdCByZXRhaW5lZCBhcyBhbg0KICAgICAqICAgICAgICAgICAgICAgICAgICAgICAgYXR0 cmlidXRlIHZhbHVlLiBJZiBmYWxzZSwgdGhlIG9sZCBuYW1lIGlzDQogICAgICogICAgICAgICAg ICAgICAgICAgICAgICByZXRhaW5lZCBhcyBhbiBhdHRyaWJ1dGUgdmFsdWUuDQogICAgICoNCiAg ICAgKiBAZXhjZXB0aW9uIExEQVBFeGNlcHRpb24gQSBnZW5lcmFsIGV4Y2VwdGlvbiB3aGljaCBp bmNsdWRlcyBhbiBlcnJvcg0KICAgICAqICBtZXNzYWdlIGFuZCBhbiBMREFQIGVycm9yIGNvZGUu DQogICAgICovDQogICAgcHVibGljIHZvaWQgcmVuYW1lKFN0cmluZyBkbiwNCiAgICAgICAgICAg ICAgICAgICAgICAgU3RyaW5nIG5ld1JkbiwNCiAgICAgICAgICAgICAgICAgICAgICAgYm9vbGVh biBkZWxldGVPbGRSZG4pDQogICAgICAgIHRocm93cyBMREFQRXhjZXB0aW9uDQogICAgew0KICAg ICAgICByZW5hbWUoZG4sIG5ld1JkbiwgZGVsZXRlT2xkUmRuLCBkZWZTZWFyY2hDb25zKTsNCiAg ICAgICAgcmV0dXJuOw0KICAgIH0NCg0KICAgIC8qKg0KICAgICAqDQogICAgICogU3luY2hyb25v dXNseSByZW5hbWVzIGFuIGV4aXN0aW5nIGVudHJ5IGluIHRoZSBkaXJlY3RvcnksIHVzaW5nIHRo ZQ0KICAgICAqIHNwZWNpZmllZCBjb25zdHJhaW50cy4NCiAgICAgKg0KICAgICAqICBAcGFyYW0g ZG4gICAgICAgICAgICAgVGhlIGN1cnJlbnQgZGlzdGluZ3Vpc2hlZCBuYW1lIG9mIHRoZSBlbnRy eS4NCiAgICAgKjxicj48YnI+DQogICAgICogIEBwYXJhbSBuZXdSZG4gICAgICAgICBUaGUgbmV3 IHJlbGF0aXZlIGRpc3Rpbmd1aXNoZWQgbmFtZSBmb3IgdGhlIGVudHJ5Lg0KICAgICAqPGJyPjxi cj4NCiAgICAgKiAgQHBhcmFtIGRlbGV0ZU9sZFJkbiAgIElmIHRydWUsIHRoZSBvbGQgbmFtZSBp cyBub3QgcmV0YWluZWQgYXMgYW4NCiAgICAgKiAgICAgICAgICAgICAgICAgICAgICAgIGF0dHJp YnV0ZSB2YWx1ZS4gSWYgZmFsc2UsIHRoZSBvbGQgbmFtZSBpcw0KICAgICAqICAgICAgICAgICAg ICAgICAgICAgICAgcmV0YWluZWQgYXMgYW4gYXR0cmlidXRlIHZhbHVlLg0KICAgICAqPGJyPjxi cj4NCiAgICAgKiAgQHBhcmFtIGNvbnMgICAgICAgICAgIFRoZSBjb25zdHJhaW50cyBzcGVjaWZp YyB0byB0aGUgb3BlcmF0aW9uLg0KICAgICAqDQogICAgICogQGV4Y2VwdGlvbiBMREFQRXhjZXB0 aW9uIEEgZ2VuZXJhbCBleGNlcHRpb24gd2hpY2ggaW5jbHVkZXMgYW4gZXJyb3INCiAgICAgKiBt ZXNzYWdlIGFuZCBhbiBMREFQIGVycm9yIGNvZGUuDQogICAgICovDQogICAgcHVibGljIHZvaWQg cmVuYW1lKFN0cmluZyBkbiwNCiAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nIG5ld1JkbiwN CiAgICAgICAgICAgICAgICAgICAgICAgYm9vbGVhbiBkZWxldGVPbGRSZG4sDQogICAgICAgICAg ICAgICAgICAgICAgIExEQVBDb25zdHJhaW50cyBjb25zKQ0KICAgICAgICB0aHJvd3MgTERBUEV4 Y2VwdGlvbg0KICAgIHsNCiAgICAgICAgLy8gbnVsbCBmb3IgbmV3UGFyZW50ZG4gbWVhbnMgdGhh dCB0aGlzIGlzIG9yaWdpbmF0aW5nIGFzIGFuIExEQVB2MiBjYWxsDQogICAgIC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Z2VuZXJhbCBleGNlcHRpb24gd2hpY2ggaW5jbHVkZXMg YW4gZXJyb3INCiAgICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZSBhbmQgYW4g TERBUCBlcnJvciBjb2RlLg0KICAgICAqLw0KICAgIHB1YmxpYyB2b2lkIHJlbmFtZShTdHJpbmcg ZG4sDQogICAgICAgICAgICAgICAgICAgICAgIFN0cmluZyBuZXdSZG4sDQogICAgICAgICAgICAg ICAgICAgICAgIFN0cmluZyBuZXdQYXJlbnRkbiwNCiAgICAgICAgICAgICAgICAgICAgICAgYm9v bGVhbiBkZWxldGVPbGRSZG4pDQogICAgICAgIHRocm93cyBMREFQRXhjZXB0aW9uDQogICAgew0K ICAgICAgICByZW5hbWUoZG4sIG5ld1JkbiwgbmV3UGFyZW50ZG4sIGRlbGV0ZU9sZFJkbiwgZGVm U2VhcmNoQ29ucyk7DQogICAgICAgIHJldHVybjsNCiAgICB9DQoNCiAgICAvKioNCiAgICAgKg0K ICAgICAqIFN5bmNocm9ub3VzbHkgcmVuYW1lcyBhbiBleGlzdGluZyBlbnRyeSBpbiB0aGUgZGly ZWN0b3J5LCB1c2luZyB0aGUNCiAgICAgKiBzcGVjaWZpZWQgY29uc3RyYWludHMgYW5kIHBvc3Np Ymx5IHJlcG9zaXRpb25pbmcgdGhlIGVudHJ5IGluIHRoZQ0KICAgICAqIGRpcmVjdG9yeSB0cmVl Lg0KICAgICAqDQogICAgICogIEBwYXJhbSBkbiAgICAgICAgICAgICBUaGUgY3VycmVudCBkaXN0 aW5ndWlzaGVkIG5hbWUgb2YgdGhlIGVudHJ5Lg0KICAgICAqPGJyPjxicj4NCiAgICAgKiAgQHBh cmFtIG5ld1JkbiAgICAgICAgIFRoZSBuZXcgcmVsYXRpdmUgZGlzdGluZ3Vpc2hlZCBuYW1lIGZv ciB0aGUgZW50cnkuDQogICAgICo8YnI+PGJyPg0KICAgICAqICBAcGFyYW0gbmV3UGFyZW50ZG4g ICAgVGhlIGRpc3Rpbmd1aXNoZWQgbmFtZSBvZiBhbiBleGlzdGluZyBlbnRyeSB3aGljaA0KICAg ICAqICAgICAgICAgICAgICAgICAgICAgICAgaXMgdG8gYmUgdGhlIG5ldyBwYXJlbnQgb2YgdGhl IGVudHJ5Lg0KICAgICAqPGJyPjxicj4NCiAgICAgKiAgQHBhcmFtIGRlbGV0ZU9sZFJkbiAgIElm IHRydWUsIHRoZSBvbGQgbmFtZSBpcyBub3QgcmV0YWluZWQgYXMgYW4NCiAgICAgKiAgICAgICAg ICAgICAgICAgICAgICAgIGF0dHJpYnV0ZSB2YWx1ZS4gSWYgZmFsc2UsIHRoZSBvbGQgbmFtZSBp cw0KICAgICAqICAgICAgICAgICAgICAgICAgICAgICAgcmV0YWluZWQgYXMgYW4gYXR0cmlidXRl IHZhbHVlLg0KICAgICAqPGJyPjxicj4NCiAgICAgKiAgQHBhcmFtIGNvbnMgICAgICAgICAgIFRo ZSBjb25zdHJhaW50cyBzcGVjaWZpYyB0byB0aGUgb3BlcmF0aW9uLg0KICAgICAqDQogICAgICog QGV4Y2VwdGlvbiBMREFQRXhjZXB0aW9uIEEgZ2VuZXJhbCBleGNlcHRpb24gd2hpY2ggaW5jbHVk ZXMgYW4gZXJyb3INCiAgICAgKiBtZXNzYWdlIGFuZCBhbiBMREFQIGVycm9yIGNvZGUuDQogICAg ICovDQogICAgcHVibGljIHZvaWQgcmVuYW1lKFN0cmluZyBkbiwNCiAgICAgICAgICAgICAgICAg ICAgICAgU3RyaW5nIG5ld1JkbiwNCiAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nIG5ld1Bh cmVudGRuLA0KICAgICAgICAgICAgICAgICAgICAgICBib29sZWFuIGRlbGV0ZU9sZFJkbiwNCiAg ICAgICAgICAgICAgICAgICAgICAgTERBUENvbnN0cmFpbnRzIGNvbnMpDQogICAgICAgIHRocm93 cyBMREFQRXhjZXB0aW9uDQogICAgew0KICAgICAgICBMREFQUmVzcG9uc2VRdWV1ZSBxdWV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J1ZSwgdGhlIG9sZCBuYW1lIGlzIG5vdCByZXRhaW5l ZCBhcyBhbg0KICAgICAqICAgICAgICAgICAgICAgICAgICAgICAgYXR0cmlidXRlIHZhbHVlLiBJ ZiBmYWxzZSwgdGhlIG9sZCBuYW1lIGlzDQogICAgICogICAgICAgICAgICAgICAgICAgICAgICBy ZXRhaW5lZCBhcyBhbiBhdHRyaWJ1dGUgdmFsdWUuDQogICAgICo8YnI+PGJyPg0KICAgICAqICBA cGFyYW0gcXVldWUgICAgICAgICAgVGhlIHF1ZXVlIGZvciBtZXNzYWdlcyByZXR1cm5lZCBmcm9t IGEgc2VydmVyIGluDQogICAgICogICAgICAgICAgICAgICAgICAgICAgICByZXNwb25zZSB0byB0 aGlzIHJlcXVlc3QuIElmIGl0IGlzIG51bGwsIGENCiAgICAgKiAgICAgICAgICAgICAgICAgICAg ICAgIHF1ZXVlIG9iamVjdCBpcyBjcmVhdGVkIGludGVybmFsbHkuDQogICAgICoNCiAgICAgKiBA ZXhjZXB0aW9uIExEQVBFeGNlcHRpb24gQSBnZW5lcmFsIGV4Y2VwdGlvbiB3aGljaCBpbmNsdWRl cyBhbiBlcnJvcg0KICAgICAqIG1lc3NhZ2UgYW5kIGFuIExEQVAgZXJyb3IgY29kZS4NCiAgICAg Ki8NCiAgICBwdWJsaWMgTERBUFJlc3BvbnNlUXVldWUgcmVuYW1lKFN0cmluZyBkbiwNCiAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZyBuZXdSZG4sDQogICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICBib29sZWFuIGRlbGV0ZU9sZFJkbiwNCiAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgIExEQVBSZXNwb25zZVF1ZXVlIHF1ZXVlKQ0KICAg ICAgICB0aHJvd3MgTERBUEV4Y2VwdGlvbg0KICAgIHsNCiAgICAgICAgcmV0dXJuIHJlbmFtZShk biwgbmV3UmRuLCBkZWxldGVPbGRS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cmFtIGNv bnMgICAgICAgICAgIFRoZSBjb25zdHJhaW50cyBzcGVjaWZpYyB0byB0aGUgb3BlcmF0aW9uLg0K ICAgICAqDQogICAgICogQGV4Y2VwdGlvbiBMREFQRXhjZXB0aW9uIEEgZ2VuZXJhbCBleGNlcHRp b24gd2hpY2ggaW5jbHVkZXMgYW4gZXJyb3INCiAgICAgKiBtZXNzYWdlIGFuZCBhbiBMREFQIGVy cm9yIGNvZGUuDQogICAgICovDQogICAgcHVibGljIExEQVBSZXNwb25zZVF1ZXVlIHJlbmFtZShT dHJpbmcgZG4sDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmcgbmV3 UmRuLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbGVhbiBkZWxldGVP bGRSZG4sDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBMREFQUmVzcG9uc2VR dWV1ZSBxdWV1ZSwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIExEQVBDb25z dHJhaW50cyBjb25zKQ0KICAgICAgICB0aHJvd3MgTERBUEV4Y2VwdGlvbg0KICAgIHsNCiAgICAg ICAgcmV0dXJuIHJlbmFtZShkbiwgbmV3UmRuLCBudWxsLCBkZWxldGVPbGRSZG4sIHF1ZXVlLCBj b25zKTsNCiAgICB9DQoNCiAgICAvKioNCiAgICAgKiBBc3luY2hyb25vdXNseSByZW5hbWVzIGFu IGV4aXN0aW5nIGVudHJ5IGluIHRoZSBkaXJlY3RvcnksIHBvc3NpYmx5DQogICAgICogcmVwb3Np dGlvbmluZyB0aGUgZW50cnkgaW4gdGhlIGRpcmVjdG9yeS4NCiAgICAgKg0KICAgICAqICBAcGFy YW0gZG4gICAgICAgICAgICAgVGhlIGN1cnJlbnQgZGlzdGluZ3Vpc2hlZCBuYW1lIG9mIHRoZSBl bnRyeS4NCiAgICAgKjxicj48YnI+DQogICAgICogIEBwYXJhbSBuZXdSZG4gICAgICAg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pYyBMREFQUmVzcG9uc2VRdWV1ZSByZW5hbWUoU3RyaW5n IGRuLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nIG5ld1JkbiwN CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZyBuZXdQYXJlbnRkbiwN CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2xlYW4gZGVsZXRlT2xkUmRu LA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTERBUFJlc3BvbnNlUXVldWUg cXVldWUpDQogICAgICAgIHRocm93cyBMREFQRXhjZXB0aW9uDQogICAgew0KICAgICAgICBpZigg RGVidWcuTERBUF9ERUJVRykgew0KICAgICAgICAgICAgRGVidWcudHJhY2UoIERlYnVnLmFwaVJl cXVlc3RzLCBuYW1lICsNCiAgICAgICAgICAgICJyZW5hbWUoIiArIGRuICsgIiwiICsgbmV3UmRu ICsgIiwiICsgbmV3UGFyZW50ZG4gKyAiKSIpOw0KICAgICAgICB9DQogICAgICAgIHJldHVybiBy ZW5hbWUoZG4sIG5ld1JkbiwgbmV3UGFyZW50ZG4sDQogICAgICAgICAgICAgICAgICAgICAgZGVs ZXRlT2xkUmRuLCBxdWV1ZSwgZGVmU2VhcmNoQ29ucyk7DQogICAgfQ0KDQogICAgLyoqDQogICAg ICogQXN5bmNocm9ub3VzbHkgcmVuYW1lcyBhbiBleGlzdGluZyBlbnRyeSBpbiB0aGUgZGlyZWN0 b3J5LCB1c2luZyB0aGUNCiAgICAgKiBzcGVjaWZpZWQgY29uc3RyYWludHMgYW5kIHBvc3NpYmls eSByZXBvc2l0aW9uaW5nIHRoZSBlbnRyeSBpbiB0aGUNCiAgICAgKiBkaXJlY3RvcnkuDQogICAg ICoNCiAgICAgKiAgQHBhcmFtIGRuICAgICAgICAgICAgIFRoZSBjdXJyZW50IGRpc3Rpbmd1aXNo ZWQgbmFtZSBvZiB0aGUgZW50cnkuDQogICAgICo8YnI+PGJyPg0KICAgICAqICBAcGFyYW0gbmV3 UmRuICAgICAgICAgVGhlIG5ldyByZWxhdGl2ZSBkaXN0aW5ndWlzaGVkIG5hbWUgZm9yIHRoZSBl bnRyeS4NCiAgICAgKjxicj48YnI+DQogICAgICogIEBwYXJhbSBuZXdQYXJlbnRkbiAgICBUaGUg ZGlzdGluZ3Vpc2hlZCBuYW1lIG9mIGFuIGV4aXN0aW5nIGVudHJ5IHdoaWNoDQogICAgICogICAg ICAgICAgICAgICAgICAgICAgICBpcyB0byBiZSB0aGUgbmV3IHBhcmVudCBvZiB0aGUgZW50cnku DQogICAgICo8YnI+PGJyPg0KICAgICAqICBAcGFyYW0gZGVsZXRlT2xkUmRuICAgSWYgdHJ1ZSwg dGhlIG9sZCBuYW1lIGlzIG5vdCByZXRhaW5lZCBhcyBhbg0KICAgICAqICAgICAgICAgICAgICAg ICAgICAgICAgYXR0cmlidXRlIHZhbHVlLiBJZiBmYWxzZSwgdGhlIG9sZCBuYW1lIGlzDQogICAg ICogICAgICAgICAgICAgICAgICAgICAgICByZXRhaW5lZCBhcyBhbiBhdHRyaWJ1dGUgdmFsdWUu DQogICAgICo8YnI+PGJyPg0KICAgICAqICBAcGFyYW0gcXVldWUgICAgICAgICAgVGhlIHF1ZXVl IGZvciBtZXNzYWdlcyByZXR1cm5lZCBmcm9tIGEgc2VydmVyIGluDQogICAgICogICAgICAgICAg ICAgICAgICAgICAgICByZXNwb25zZSB0byB0aGlzIHJlcXVlc3QuIElmIGl0IGlzIG51bGwsIGEN CiAgICAgKiAgICAgICAgICAgICAgICAgICAgICAgIHF1ZXVlIG9iamVjdCBpcyBjcmVhdGVkIGlu dGVybmFsbHkuDQogICAgICo8YnI+PGJyPg0KICAgICAqICBAcGFyYW0gY29ucyAgICAgICAgICAg VGhlIGNvbnN0cmFpbnRzIHNwZWNpZmljIHRvIHRoZSBvcGVyYXRpb24uDQogICAgICoNCiAgICAg KiBAZXhjZXB0aW9uIExEQVBFeGNlcHRpb24gQSBnZW5lcmFsIGV4Y2VwdGlvbiB3aGljaCBpbmNs dWRlcyBhbiBlcnJvcg0KICAgICAqIG1lc3NhZ2UgYW5kIGFuIExEQVAgZXJyb3IgY29kZS4NCiAg ICAgKi8NCiAgICBwdWJsaWMgTERBUFJlc3BvbnNlUXVldWUgcmVuYW1lKFN0cmluZyBkbiwNCiAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZyBuZXdSZG4sDQogICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmcgbmV3UGFyZW50ZG4sDQogICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sZWFuIGRlbGV0ZU9sZFJkbiwNCiAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIExEQVBSZXNwb25zZVF1ZXVlIHF1ZXVlLA0K ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTERBUENvbnN0cmFpbnRzIGNvbnMp DQogICAgICAgIHRocm93cyBMREFQRXhjZXB0aW9uDQogICAgew0KICAgICAgICBpZihkbiA9PSBu dWxsIHx8IG5ld1JkbiA9PSBudWxsKSB7DQogICAgICAgICAgICAvLyBJbnZhbGlkIEROIG9yIFJE TiBwYXJhbWV0ZXINCiAgICAgICAgICAgIHRocm93IG5ldyBJbGxlZ2FsQXJndW1lbnRFeGNlcHRp b24oDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRXhjZXB0aW9uTWVzc2Fn ZXMuUkROX1BBUkFNX0VSUk9SKTsNCiAgICAgICAgfQ0KDQogICAgICAgIGlmKCBEZWJ1Zy5MREFQ X0RFQlVHKSB7DQogICAgICAgICAgICBEZWJ1Zy50cmFjZSggRGVidWcuYXBpUmVxdWVzdHMsIG5h bWUgKw0KICAgICAgICAgICAgInJlbmFtZSgiICsgZG4gKyAiLCIgKyBuZXdSZG4gKyAiLCIgKyBu ZXdQYXJlbnRkbiArICIpIik7DQogICAgICAgIH0NCiAgICAgICAgaWYoY29ucyA9PSBudWxsKQ0K ICAgICAgICAgICAgY29ucyA9IGRlZlNlYXJjaENvbnM7DQoNCiAgICAgICAgTERBUE1lc3NhZ2Ug bXNnID0gbmV3IExEQVBNb2RpZnlETlJlcXVlc3QoIGRuLCBuZXdSZG4sIG5ld1BhcmVudGRuLA0K ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGVPbGRSZG4sIGNvbnMuZ2V0Q29u dHJvbHMoKSk7DQoNCiAgICAgICAgcmV0dXJuIHNlbmRSZXF1ZXN0VG9TZXJ2ZXIobXNnLCBjb25z LmdldFRpbWVMaW1pdCgpLCBxdWV1ZSwgbnVsbCk7DQogICAgfQ0KDQogICAgLy8qKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqDQogICAgLy8gc2VhcmNoIG1ldGhvZHMNCiAgICAvLyoqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioNCg0K ICAgIC8qKg0KICAgICAqDQogICAgICogU3luY2hyb25vdXNseSBwZXJmb3JtcyB0aGUgc2VhcmNo IHNwZWNpZmllZCBieSB0aGUgcGFyYW1ldGVycy4NCiAgICAgKg0KICAgICAqICBAcGFyYW0gYmFz ZSAgICAgICAgICAgVGhlIGJhc2UgZGlzdGluZ3Vpc2hlZCBuYW1lIHRvIHNlYXJjaCBmcm9tLg0K ICAgICAqPGJyPjxicj4NCiAgICAgKiAgQHBhcmFtIHNjb3BlICAgICAgICAgIFRoZSBzY29wZSBv ZiB0aGUgZW50cmllcyB0byBzZWFyY2guIFRoZSBmb2xsb3dpbmcNCiAgICAgKiAgICAgICAgICAg ICAgICAgICAgICAgIGFyZSB0aGUgdmFsaWQgb3B0aW9uczoNCiAgICAgKjx1bD4NCiAgICAgKiAg IDxsaT5TQ09QRV9CQVNFIC0gc2VhcmNoZXMgb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ICAgICAgICAgICAgICAgICAgICAgaW50IHNjb3BlLA0KICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgU3RyaW5nIGZpbHRlciwNCiAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgIFN0cmluZ1tdIGF0dHJzLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgYm9vbGVhbiB0eXBlc09ubHkpDQogICAgICAgIHRocm93cyBMREFQRXhjZXB0aW9u DQogICAgew0KICAgICAgICByZXR1cm4gc2VhcmNoKGJhc2UsIHNjb3BlLCBmaWx0ZXIsIGF0dHJz LCB0eXBlc09ubHksIGRlZlNlYXJjaENvbnMpOw0KICAgIH0NCg0KICAgIC8qKg0KICAgICAqDQog ICAgICogU3luY2hyb25vdXNseSBwZXJmb3JtcyB0aGUgc2VhcmNoIHNwZWNpZmllZCBieSB0aGUg cGFyYW1ldGVycywNCiAgICAgKiB1c2luZyB0aGUgc3BlY2lmaWVkIHNlYXJjaCBjb25zdHJhaW50 cyAoc3VjaCBhcyB0aGUNCiAgICAgKiBtYXhpbXVtIG51bWJlciBvZiBlbnRyaWVzIHRvIGZpbmQg b3IgdGhlIG1heGltdW0gdGltZSB0byB3YWl0IGZvcg0KICAgICAqIHNlYXJjaCByZXN1bHRzKS4N CiAgICAgKg0KICAgICAqIDxwPkFzIHBhcnQgb2YgdGhlIHNlYXJjaCBjb25zdHJhaW50cywgdGhl IG1ldGhvZCBhbGxvd3Mgc3BlY2lmeWluZw0KICAgICAqIHdoZXRoZXIgb3Igbm90IHRoZSByZXN1 bHRzIGFyZSB0byBiZSBkZWxpdmVyZWQgYWxsIGF0IG9uY2Ugb3IgaW4NCiAgICAgKiBzbWFsbGVy IGJhdGNoZXMuIElmIHNwZWNpZmllZCB0aGF0IHRoZSByZXN1bHRzIGFyZSB0byBiZSBkZWxpdmVy ZWQgaW4NCiAgICAgKiBzbWFsbGVyIGJhdGNoZXMsIGVhY2ggaXRlcmF0aW9uIGJsb2NrcyBvbmx5 IHVudGlsIHRoZSBuZXh0IGJhdGNoIG9mDQogICAgICogcmVzdWx0cyBpcyByZXR1cm5lZC48L3A+ DQogICAgICoNCiAgICAgKiAgQHBhcmFtIGJhc2UgICAgICAgICAgIFRoZSBiYXNlIGRpc3Rpbmd1 aXNoZWQgbmFtZSB0byBzZWFyY2ggZnJvbS4NCiAgICAgKjxicj48YnI+DQogICAgICogIEBwYXJh bSBzY29wZSAgICAgICAgICBUaGUgc2NvcGUgb2YgdGhlIGVudHJpZXMgdG8gc2VhcmNoLiBUaGUg Zm9sbG93aW5nDQogICAgICogICAgICAgICAgICAgICAgICAgICAgICBhcmUgdGhlIHZhbGlkIG9w dGlvbnM6DQogICAgICo8dWw+DQogICAgICogICA8bGk+U0NPUEVfQkFTRSAtIHNlYXJjaGVzIG9u bHkgdGhlIGJhc2UgRE4NCiAgICAgKg0KICAgICAqICAgPGxpPlNDT1BFX09ORSAtIHNlYXJjaGVz IG9ubHkgZW50cmllcyB1bmRlciB0aGUgYmFzZSBETg0KICAgICAqDQogICAgICogICA8bGk+U0NP UEVfU1VCIC0gc2VhcmNoZXMgdGhlIGJhc2UgRE4gYW5kIGFsbCBlbnRyaWVzDQogICAgICogICAg ICAgICAgICAgICAgICAgICAgICAgIHdpdGhpbiBpdHMgc3VidHJlZQ0KICAgICAqPC91bD48YnI+ PGJyPg0KICAgICAqICBAcGFyYW0gZmlsdGVyICAgICAgICAgVGhlIHNlYXJjaCBmaWx0ZXIgc3Bl Y2lmeWluZyB0aGUgc2VhcmNoIGNyaXRlcmlhLg0KICAgICAqPGJyPjxicj4NCiAgICAgKiAgQHBh cmFtIGF0dHJzICAgICAgICAgIFRoZSBuYW1lcyBvZiBhdHRyaWJ1dGVzIHRvIHJldHJpZXZlLg0K ICAgICAqPGJyPjxicj4NCiAgICAgKiAgQHBhcmFtIHR5cGVzT25seSAgICAgIElmIHRydWUsIHJl dHVybnMgdGhlIG5hbWVzIGJ1dCBub3QgdGhlIHZhbHVlcyBvZg0KICAgICAqICAgICAgICAgICAg ICAgICAgICAgICAgdGhlIGF0dHJpYnV0ZXMgZm91bmQuICBJZiBmYWxzZSwgcmV0dXJucyB0aGUN CiAgICAgKiAgICAgICAgICAgICAgICAgICAgICAgIG5hbWVzIGFuZCB2YWx1ZXMgZm9yIGF0dHJp YnV0ZXMgZm91bmQuDQogICAgICo8YnI+PGJyPg0KICAgICAqICBAcGFyYW0gY29ucyAgICAgICAg ICAgVGhlIGNvbnN0cmFpbnRzIHNwZWNpZmljIHRvIHRoZSBzZWFyY2guDQogICAgICoNCiAgICAg KiBAZXhjZXB0aW9uIExEQVBFeGNlcHRpb24gQSBnZW5lcmFsIGV4Y2VwdGlvbiB3aGljaCBpbmNs dWRlcyBhbiBlcnJvcg0KICAgICAqIG1lc3NhZ2UgYW5kIGFuIExEQVAgZXJyb3IgY29kZS4NCiAg ICAgKi8NCiAgICBwdWJsaWMgTERBUFNlYXJjaFJlc3VsdHMgc2VhcmNoKFN0cmluZyBiYXNlLA0K ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50IHNjb3BlLA0KICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nIGZpbHRlciwNCiAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgIFN0cmluZ1tdIGF0dHJzLA0KICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgYm9vbGVhbiB0eXBlc09ubHksDQogICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICBMREFQU2VhcmNoQ29uc3RyYWludHMgY29ucykNCiAgICAgICAgdGhy b3dzIExEQVBFeGNlcHRpb24NCiAgICB7DQogICAgICAgIExEQVBTZWFyY2hRdWV1ZSBxdWV1ZSA9 DQogICAgICAgICAgICBzZWFyY2goYmFzZSwgc2NvcGUsIGZpbHRlciwgYXR0cnMsIHR5cGVzT25s eSwgbnVsbCwgY29ucyk7DQoNCiAgICAgICAgaWYoIGNvbnMgPT0gbnVsbCApDQogICAgICAgICAg ICBjb25zID0gZGVmU2VhcmNoQ29uczsNCiAgICAgICAgcmV0dXJuIG5ldyBMREFQU2VhcmNoUmVz dWx0cyh0aGlzLCBxdWV1ZSwgY29ucyk7DQogICAgfQ0KDQogICAgLyoqDQogICAgICogQXN5bmNo cm9ub3VzbHkgcGVyZm9ybXMgdGhlIHNlYXJjaCBzcGVjaWZpZWQgYnkgdGhlIHBhcmFtZXRlcnMu DQogICAgICoNCiAgICAgKiAgQHBhcmFtIGJhc2UgICAgICAgICAgIFRoZSBiYXNlIGRpc3Rpbmd1 aXNoZWQgbmFtZSB0byBzZWFyY2ggZnJvbS4NCiAgICAgKjxicj48YnI+DQogICAgICogIEBwYXJh bSBzY29wZSAgICAgICAgICBUaGUgc2NvcGUgb2YgdGhlIGVudHJpZXMgdG8gc2VhcmNoLiBUaGUg Zm9sbG93aW5nDQogICAgICogICAgICAgICAgICAgICAgICAgICAgICBhcmUgdGhlIHZhbGlkIG9w dGlvbnM6DQogICAgICo8dWw+DQogICAgICogICA8bGk+U0NPUEVfQkFTRSAtIHNlYXJjaGVzIG9u bHkgdGhlIGJhc2UgRE4NCiAgICAgKg0KICAgICAqICAgPGxpPlNDT1BFX09ORSAtIHNlYXJjaGVz IG9ubHkgZW50cmllcyB1bmRlciB0aGUgYmFzZSBETg0KICAgICAqDQogICAgICogICA8bGk+U0NP UEVfU1VCIC0gc2VhcmNoZXMgdGhlIGJhc2UgRE4gYW5kIGFsbCBlbnRyaWVzDQogICAgICogICAg ICAgICAgICAgICAgICAgICAgICAgIHdpdGhpbiBpdHMgc3VidHJlZQ0KICAgICAqPC91bD48YnI+ PGJyPg0KICAgICAqICBAcGFyYW0gZmlsdGVyICAgICAgICAgU2VhcmNoIGZpbHRlciBzcGVjaWZ5 aW5nIHRoZSBzZWFyY2ggY3JpdGVyaWEuDQogICAgICo8YnI+PGJyPg0KICAgICAqICBAcGFyYW0g YXR0cnMgICAgICAgICAgTmFtZXMgb2YgYXR0cmlidXRlcyB0byByZXRyaWV2ZS4NCiAgICAgKjxi cj48YnI+DQogICAgICogIEBwYXJhbSB0eXBlc09ubHkgICAgICBJZiB0cnVlLCByZXR1cm5zIHRo ZSBuYW1lcyBidXQgbm90IHRoZSB2YWx1ZXMgb2YNCiAgICAgKiAgICAgICAgICAgICAgICAgICAg ICAgIHRoZSBhdHRyaWJ1dGVzIGZvdW5kLiAgSWYgZmFsc2UsIHJldHVybnMgdGhlDQogICAgICog ICAgICAgICAgICAgICAgICAgICAgICBuYW1lcyBhbmQgdmFsdWVzIGZvciBhdHRyaWJ1dGVzIGZv dW5kLg0KICAgICAqPGJyPjxicj4NCiAgICAgKiAgQHBhcmFtIHF1ZXVlICAgICAgICAgIEhhbmRs ZXIgZm9yIG1lc3NhZ2VzIHJldHVybmVkIGZyb20gYSBzZXJ2ZXIgaW4NCiAgICAgKiAgICAgICAg ICAgICAgICAgICAgICAgIHJlc3BvbnNlIHRvIHRoaXMgcmVxdWVzdC4gSWYgaXQgaXMgbnVsbCwg YQ0KICAgICAqICAgICAgICAgICAgICAgICAgICAgICAgcXVldWUgb2JqZWN0IGlzIGNyZWF0ZWQg aW50ZXJuYWxseS4NCiAgICAgKg0KICAgICAqIEBleGNlcHRpb24gTERBUEV4Y2VwdGlvbiBBIGdl bmVyYWwgZXhjZXB0aW9uIHdoaWNoIGluY2x1ZGVzIGFuIGVycm9yDQogICAgICogbWVzc2FnZSBh bmQgYW4gTERBUCBlcnJvciBjb2RlLg0KICAgICAqLw0KICAgIHB1YmxpYyBMREFQU2VhcmNoUXVl dWUgc2VhcmNoKFN0cmluZyBiYXNlLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg IGludCBzY29wZSwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmcgZmls dGVyLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZ1tdIGF0dHJzLA0K ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2xlYW4gdHlwZXNPbmx5LA0KICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIExEQVBTZWFyY2hRdWV1ZSBxdWV1ZSkNCiAg ICAgICAgdGhyb3dzIExEQVBFeGNlcHRpb24NCiAgICB7DQogICAgICAgIHJldHVybiBzZWFyY2go YmFzZSwgc2NvcGUsIGZpbHRlciwgYXR0cnMsIHR5cGVzT25seSwNCiAgICAgICAgICAgICAgICAg ICAgICBxdWV1ZSwgZGVmU2VhcmNoQ29ucyk7DQogICAgfQ0KDQogICAgLyoqDQogICAgICogQXN5 bmNocm9ub3VzbHkgcGVyZm9ybXMgdGhlIHNlYXJjaCBzcGVjaWZpZWQgYnkgdGhlIHBhcmFtZXRl cnMsDQogICAgICogYWxzbyBhbGxvd2luZyBzcGVjaWZpY2F0aW9uIG9mIGNvbnN0cmFpbnRzIGZv ciB0aGUgc2VhcmNoIChzdWNoDQogICAgICogYXMgdGhlIG1heGltdW0gbnVtYmVyIG9mIGVudHJp ZXMgdG8gZmluZCBvciB0aGUgbWF4aW11bSB0aW1lIHRvDQogICAgICogd2FpdCBmb3Igc2VhcmNo IHJlc3VsdHMpLg0KICAgICAqDQogICAgICogIEBwYXJhbSBiYXNlICAgICAgICAgICBUaGUgYmFz ZSBkaXN0aW5ndWlzaGVkIG5hbWUgdG8gc2VhcmNoIGZyb20uDQogICAgICo8YnI+PGJyPg0KICAg ICAqICBAcGFyYW0gc2NvcGUgICAgICAgICAgVGhlIHNjb3BlIG9mIHRoZSBlbnRyaWVzIHRvIHNl YXJjaC4gVGhlIGZvbGxvd2luZw0KICAgICAqICAgICAgICAgICAgICAgICAgICAgICAgYXJlIHRo ZSB2YWxpZCBvcHRpb25zOg0KICAgICAqPHVsPg0KICAgICAqICAgPGxpPlNDT1BFX0JBU0UgLSBz ZWFyY2hlcyBvbmx5IHRoZSBiYXNlIERODQogICAgICoNCiAgICAgKiAgIDxsaT5TQ09QRV9PTkUg LSBzZWFyY2hlcyBvbmx5IGVudHJpZXMgdW5kZXIgdGhlIGJhc2UgRE4NCiAgICAgKg0KICAgICAq ICAgPGxpPlNDT1BFX1NVQiAtIHNlYXJjaGVzIHRoZSBiYXNlIEROIGFuZCBhbGwgZW50cmllcw0K ICAgICAqICAgICAgICAgICAgICAgICAgICAgICAgICAgd2l0aGluIGl0cyBzdWJ0cmVlDQogICAg ICo8L3VsPjxicj48YnI+DQogICAgICogIEBwYXJhbSBmaWx0ZXIgICAgICAgICBUaGUgc2VhcmNo IGZpbHRlciBzcGVjaWZ5aW5nIHRoZSBzZWFyY2ggY3JpdGVyaWEuDQogICAgICo8YnI+PGJyPg0K ICAgICAqICBAcGFyYW0gYXR0cnMgICAgICAgICAgVGhlIG5hbWVzIG9mIGF0dHJpYnV0ZXMgdG8g cmV0cmlldmUuDQogICAgICo8YnI+PGJyPg0KICAgICAqICBAcGFyYW0gdHlwZXNPbmx5ICAgICAg SWYgdHJ1ZSwgcmV0dXJucyB0aGUgbmFtZXMgYnV0IG5vdCB0aGUgdmFsdWVzIG9mDQogICAgICog ICAgICAgICAgICAgICAgICAgICAgICB0aGUgYXR0cmlidXRlcyBmb3VuZC4gIElmIGZhbHNlLCBy ZXR1cm5zIHRoZQ0KICAgICAqICAgICAgICAgICAgICAgICAgICAgICAgbmFtZXMgYW5kIHZhbHVl cyBmb3IgYXR0cmlidXRlcyBmb3VuZC4NCiAgICAgKiA8YnI+PGJyPg0KICAgICAqICBAcGFyYW0g cXVldWUgICAgICAgICAgVGhlIHF1ZXVlIGZvciBtZXNzYWdlcyByZXR1cm5lZCBmcm9tIGEgc2Vy dmVyIGluDQogICAgICogICAgICAgICAgICAgICAgICAgICAgICByZXNwb25zZSB0byB0aGlzIHJl cXVlc3QuIElmIGl0IGlzIG51bGwsIGENCiAgICAgKiAgICAgICAgICAgICAgICAgICAgICAgIHF1 ZXVlIG9iamVjdCBpcyBjcmVhdGVkIGludGVybmFsbHkuDQogICAgICo8YnI+PGJyPg0KICAgICAq ICBAcGFyYW0gY29ucyAgICAgICAgICAgVGhlIGNvbnN0cmFpbnRzIHNwZWNpZmljIHRvIHRoZSBz ZWFyY2guDQogICAgICoNCiAgICAgKiBAZXhjZXB0aW9uIExEQVBFeGNlcHRpb24gQSBnZW5lcmFs IGV4Y2VwdGlvbiB3aGljaCBpbmNsdWRlcyBhbiBlcnJvcg0KICAgICAqIG1lc3NhZ2UgYW5kIGFu IExEQVAgZXJyb3IgY29kZS4NCiAgICAgKi8NCiAgICBwdWJsaWMgTERBUFNlYXJjaFF1ZXVlIHNl YXJjaChTdHJpbmcgYmFzZSwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQg c2NvcGUsDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nIGZpbHRlciwN CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmdbXSBhdHRycywNCiAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sZWFuIHR5cGVzT25seSwNCiAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICBMREFQU2VhcmNoUXVldWUgcXVldWUsDQogICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgTERBUFNlYXJjaENvbnN0cmFpbnRzIGNvbnMpDQog ICAgICAgIHRocm93cyBMREFQRXhjZXB0aW9uDQogICAgew0KICAgICAgICBpZiggZmlsdGVyID09 IG51bGwpIHsNCiAgICAgICAgICAgIGZpbHRlciA9ICJvYmplY3RjbGFzcz0qIjsNCiAgICAgICAg fQ0KICAgICAgICBpZiggRGVidWcuTERBUF9ERUJVRykgew0KICAgICAgICAgICAgRGVidWcudHJh Y2UoIERlYnVnLmFwaVJlcXVlc3RzLCBuYW1lICsNCiAgICAgICAgICAgICJzZWFyY2goXCIiICsg YmFzZSArICJcIiwiICsgc2NvcGUgKyAiLFwiIiArIGZpbHRlciArICJcIikiKTsNCiAgICAgICAg fQ0KICAgICAgICBpZihjb25zID09IG51bGwpDQogICAgICAgICAgICBjb25zID0gZGVmU2VhcmNo Q29uczsNCg0KICAgICAgICBMREFQTWVzc2FnZSBtc2cgPSBuZXcgTERBUFNlYXJjaFJlcXVlc3Qo IGJhc2UsIHNjb3BlLCBmaWx0ZXIsDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgYXR0cnMsIGNvbnMuZ2V0RGVyZWZlcmVuY2UoKSwNCiAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zLmdldE1heFJlc3VsdHMo KSwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25z LmdldFNlcnZlclRpbWVMaW1pdCgpLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgIHR5cGVzT25seSwgY29ucy5nZXRDb250cm9scygpKTsNCiAgICAgICAg TWVzc2FnZUFnZW50IGFnZW50Ow0KICAgICAgICBMREFQU2VhcmNoUXVldWUgbXlxdWV1ZSA9IHF1 ZXVlOw0KICAgICAgICBpZihteXF1ZXVlID09IG51bGwpIHsNCiAgICAgICAgICAgIGFnZW50ID0g bmV3IE1lc3NhZ2VBZ2VudCgpOw0KICAgICAgICAgICAgbXlxdWV1ZSA9IG5ldyBMREFQU2VhcmNo UXVldWUoIGFnZW50ICk7DQogICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICBhZ2VudCA9IHF1 ZXVlLmdldE1lc3NhZ2VBZ2VudCgpOw0KICAgICAgICB9DQoNCiAgICAgICAgdHJ5IHsNCiAgICAg ICAgICAgIGFnZW50LnNlbmRNZXNzYWdlKCBjb25uLCBtc2csIGNvbnMuZ2V0VGltZUxpbWl0KCks IG15cXVldWUsIG51bGwpOw0KICAgICAgICB9IGNhdGNoKExEQVBFeGNlcHRpb24gbGV4KSB7DQog ICAgICAgICAgICB0aHJvdyBsZXg7DQogICAgICAgIH0NCiAgICAgICAgcm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xicj4NCiAgICAgKiAgQHBhcmFtIGNvbnMgICAgICAgICAgIFRo ZSBjb25zdHJhaW50cyBzcGVjaWZpYyB0byB0aGUgc2VhcmNoLg0KICAgICAqDQogICAgICogIEBl eGNlcHRpb24gTERBUEV4Y2VwdGlvbiBBIGdlbmVyYWwgZXhjZXB0aW9uIHdoaWNoIGluY2x1ZGVz IGFuIGVycm9yDQogICAgICogIG1lc3NhZ2UgYW5kIGFuIExEQVAgZXJyb3IgY29kZS4NCiAgICAg Ki8NCiAgICBwdWJsaWMgc3RhdGljIExEQVBTZWFyY2hSZXN1bHRzIHNlYXJjaChMREFQVXJsIHRv R2V0LA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIExEQVBTZWFy Y2hDb25zdHJhaW50cyBjb25zKQ0KICAgICAgICB0aHJvd3MgTERBUEV4Y2VwdGlvbg0KICAgIHsN CiAgICAgICAgaWYoIERlYnVnLkxEQVBfREVCVUcpIHsNCiAgICAgICAgICAgIERlYnVnLnRyYWNl KCBEZWJ1Zy5hcGlSZXF1ZXN0cywNCiAgICAgICAgICAgICAgICAgICAgIkxEQVBDb25uZWN0aW9u LnNlYXJjaCgiICsgdG9HZXQudG9TdHJpbmcoKSArICIpIik7DQogICAgICAgIH0NCiAgICAgICAg TERBUENvbm5lY3Rpb24gbGNvbm4gPSBuZXcgTERBUENvbm5lY3Rpb24oKTsNCiAgICAgICAgbGNv bm4uY29ubmVjdCh0b0dldC5nZXRIb3N0KCksdG9HZXQuZ2V0UG9ydCgpKTsNCiAgICAgICAgaWYo IGNvbnMgPT0gbnVsbCkgew0KICAgICAgICAgICAgLy8gVGhpcyBpcyBhIGNsb25lLCBzbyB3ZSBh bHJlYWR5IGhhdmUgb3VyIG93biBjb3B5DQogICAgICAgICAgICBjb25zID0gbGNvbm4uZ2V0U2Vh cmNoQ29uc3RyYWludHMoKTsNCiAgICAgICAgfSBlbHNlIHsNCiAgICAgICAgICAgIC8vIGdldCBv dXIgb3duI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IHNlcnZlci4NCiAgICAgKiBAcGFyYW0gcXVldWUgICAgVGhlIHF1ZXVlIGZv ciBtZXNzYWdlcyByZXR1cm5lZCBmcm9tIGEgc2VydmVyIGluDQogICAgICogICAgICAgICAgICAg ICAgIHJlc3BvbnNlIHRvIHRoaXMgcmVxdWVzdC4gSWYgaXQgaXMgbnVsbCwgYQ0KICAgICAqICAg ICAgICAgICAgICAgICBxdWV1ZSBvYmplY3QgaXMgY3JlYXRlZCBpbnRlcm5hbGx5Lg0KICAgICAq IEBwYXJhbSBjb25zICAgIFRoZSBjb25zdHJhaW50cyB0aGF0IGFwcGx5IHRvIHRoaXMgcmVxdWVz dA0KICAgICAqIEBleGNlcHRpb24gICAgIExEQVBFeGNlcHRpb24gQSBnZW5lcmFsIGV4Y2VwdGlv biB3aGljaCBpbmNsdWRlcyBhbiBlcnJvcg0KICAgICAqICAgICAgICAgICAgICAgIG1lc3NhZ2Ug YW5kIGFuIExEQVAgZXJyb3IgY29kZS4NCiAgICAgKg0KICAgICAqIEBzZWUgTERBUE1lc3NhZ2Uj Z2V0VHlwZSgpDQogICAgICogQHNlZSBMREFQTWVzc2FnZSNpc1JlcXVlc3QoKQ0KICAgICAqLw0K ICAgIHB1YmxpYyBMREFQTWVzc2FnZVF1ZXVlIHNlbmRSZXF1ZXN0KCBMREFQTWVzc2FnZSByZXF1 ZXN0LA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBMREFQTWVzc2Fn ZVF1ZXVlIHF1ZXVlLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBM REFQQ29uc3RyYWludHMgY29ucykNCiAgICAgICAgICAgIHRocm93cyBMREFQRXhjZXB0aW9uDQog ICAgew0KDQogICAgICAgIGlmKCBEZWJ1Zy5MREFQX0RFQlVHKSB7DQogICAgICAgICAgICBEZWJ1 Zy50cmFjZSggRGVidWcuYXBpUmVxdWVzdHMsIG5hbWUgKw0KICAgICAgICAgICAgInNlbmRS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sNCiAgICAgICAgICAgICAgICBhZ2VudCA9 IHF1ZXVlLmdldE1lc3NhZ2VBZ2VudCgpOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9DQoNCiAg ICAgICAgdHJ5IHsNCiAgICAgICAgICAgIGFnZW50LnNlbmRNZXNzYWdlKCBjb25uLCByZXF1ZXN0 LCBjb25zLmdldFRpbWVMaW1pdCgpLCBteXF1ZXVlLCBudWxsKTsNCiAgICAgICAgfSBjYXRjaChM REFQRXhjZXB0aW9uIGxleCkgew0KICAgICAgICAgICAgdGhyb3cgbGV4Ow0KICAgICAgICB9DQog ICAgICAgIHJldHVybiBteXF1ZXVlOw0KICAgIH0NCg0KICAgIC8vKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0K ICAgIC8vIGhlbHBlciBtZXRob2RzDQogICAgLy8qKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqDQoNCiAgICAvKioN CiAgICAgKiBMb2NhdGVzIHRoZSBhcHByb3ByaWF0ZSBtZXNzYWdlIGFnZW50IGFuZCBzZW5kcw0K ICAgICAqIHRoZSBMREFQIHJlcXVlc3QgdG8gYSBkaXJlY3Rvcnkgc2VydmVyLg0KICAgICAqDQog ICAgICogQHBhcmFtIG1zZyB0aGUgbWVzc2FnZSB0byBzZW5kDQogICAgICo8YnI+PGJyPg0KICAg ICAqIEBwYXJhbSB0aW1lb3V0IHRoZSB0aW1lb3V0IHZhbHVlDQogICAgICo8YnI+PGJyPg0KICAg ICAqIEBwYXJhbSBxdWV1ZSB0aGUgcmVzcG9uc2UgcXVldWUgb3IgbnVsbA0KICAgICAqDQogICAg ICogQHJldHVybiB0aGUgTERBUFJlc3BvbnNlUXVldWUgZm9yIHRoaXMgcmVxdWVzdA0KICAgICAq DQogICAgICogIEBleGNlcHRpb24gTERBUEV4Y2VwdGlvbiBBIGdlbmVyYWwgZXhjZXB0aW9uIHdo aWNoIGluY2x1ZGVzIGFuIGVycm9yDQogICAgICogIG1lc3NhZ2UgYW5kIGFuIExEQVAgZXJyb3Ig Y29kZS4NCiAgICAgKi8NCiAgICBwcml2YXRlIExEQVBSZXNwb25zZVF1ZXVlIHNlbmRSZXF1ZXN0 VG9TZXJ2ZXIoIExEQVBNZXNzYWdlIG1zZywNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICBpbnQgdGltZW91dCwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICBMREFQUmVzcG9uc2VRdWV1ZSBxdWV1ZSwNCiAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICBCaW5kUHJvcGVydGllcyBiaW5kUHJvcHMpDQogICAg ICAgICAgICB0aHJvd3MgTERBUEV4Y2VwdGlvbg0KICAgIHsNCiAgICAgICAgTWVzc2FnZUFnZW50 IGFnZW50Ow0KICAgICAgICBpZihxdWV1ZSA9PSBudWxsKSB7DQogICAgICAgICAgICBhZ2VudCA9 IG5ldyBNZXNzYWdlQWdlbnQoKTsNCiAgICAgICAgICAgIHF1ZXVlID0gbmV3IExEQVBSZXNwb25z ZVF1ZXVlKCBhZ2VudCk7DQogICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICBhZ2VudCA9IHF1 ZXVlLmdldE1lc3NhZ2VBZ2VudCgpOw0KICAgICAgICB9DQoNCiAgICAgICAgYWdlbnQuc2VuZE1l c3NhZ2UoIGNvbm4sIG1zZywgdGltZW91dCwgcXVldWUsIGJpbmRQcm9wcyk7DQogICAgICAgIHJl dHVybiBxdWV1ZTsNCiAgICB9DQoNCiAgICAvKioNCiAgICAgKiBSZXR1cm4gdGhlIENvbm5lY3Rp b24gb2JqZWN0IGFzc29jaWF0ZWQgd2l0aCB0aGlzIExEQVBDb25uZWN0aW9uDQogICAgICoNCiAg ICAgKiBAcmV0dXJuIHRoZSBDb25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u ZWN0aW9uKCBTdHJpbmdbXSByZWZlcnJhbHMsIExEQVBDb25zdHJhaW50cyBjb25zKQ0KICAgICAg ICAgICAgICAgICAgICB0aHJvd3MgTERBUFJlZmVycmFsRXhjZXB0aW9uDQogICAgew0KICAgICAg ICBSZWZlcnJhbEluZm8gcmVmSW5mbyA9IG51bGw7DQogICAgICAgIFRocm93YWJsZSBleCA9IG51 bGw7DQogICAgICAgIExEQVBDb25uZWN0aW9uIHJjb25uID0gbnVsbDsNCiAgICAgICAgaWYoIGNv bnMgPT0gbnVsbCApIHsNCiAgICAgICAgICAgIGNvbnMgPSBkZWZTZWFyY2hDb25zOw0KICAgICAg ICB9DQogICAgICAgIExEQVBSZWZlcnJhbEhhbmRsZXIgcmggPSBjb25zLmdldFJlZmVycmFsSGFu ZGxlcigpOw0KICAgICAgICBpbnQgaSA9IDA7DQogICAgICAgIC8vIENoZWNrIGlmIHdlIHVzZSBM REFQUmViaW5kIHRvIGdldCBhdXRoZW50aWNhdGlvbiBjcmVkZW50aWFscw0KICAgICAgICBpZigg KHJoID09IG51bGwpIHx8ICAgICAgKHJoIGluc3RhbmNlb2YgTERBUEF1dGhIYW5kbGVyKSkgew0K ICAgICAgICAgICAgZm9yKCBpID0gMDsgaSA8IHJlZmVycmFscy5sZW5ndGg7IGkrKykgew0KICAg ICAgICAgICAgICAgIC8vIGRuLCBwdyBhcmUgbnVsbCBpbiB0aGUgZGVmYXVsdCBjYXNlIChhbm9u eW1vdXMgYmluZCkNCiAgICAgICAgICAgICAgICBTdHJpbmcgZG4gPSBudWxsOw0KICAgICAgICAg ICAgICAgIGJ5dGVbXSBwdyA9IG51bGw7DQogICAgICAgICAgICAgICAgdHJ5IHsNCiAgICAgICAg ICAgICAgICAgICAgaWYoIERlYnVnLkxEQVBfREVCVUcpIHsNCiAgICAgICAgICAgICAgICAgICAg ICAgIERlYnVnLnRyYWNlKCBEZWJ1Zy5yZWZlcnJhbHMsICAgbmFtZSArDQogICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgImdldFJlZmVycmFsQ29ubmVj dGlvbjogIiArDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgInVybD0iICsgcmVmZXJyYWxzW2ldKTsNCiAgICAgICAgICAgICAgICAgICAgfQ0KICAg ICAgICAgICAgICAgICAgICByY29ubiA9IG5ldyBMREFQQ29ubmVjdGlvbiggY29ubi5nZXRTb2Nr ZXRGYWN0b3J5KCkpOw0KICAgICAgICAgICAgICAgICAgICByY29ubi5zZXRDb25zdHJhaW50cygg ZGVmU2VhcmNoQ29ucyk7DQogICAgICAgICAgICAgICAgICAgIExEQVBVcmwgdXJsID0gbmV3IExE QVBVcmwocmVmZXJyYWxzW2ldKTsNCiAgICAgICAgICAgICAgICAgICAgcmNvbm4uY29ubmVjdCh1 cmwuZ2V0SG9zdCgpLHVybC5nZXRQb3J0KCkpOw0KICAgICAgICAgICAgICAgICAgICBpZiggcmgg IT0gbnVsbCkgew0KICAgICAgICAgICAgICAgICAgICAgICAgaWYoIHJoIGluc3RhbmNlb2YgTERB UEF1dGhIYW5kbGVyKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gR2V0IGFwcGxp Y2F0aW9uIHN1cHBsaWVkIGRuIGFuZCBwdw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIExE QVBBdXRoUHJvdmlkZXIgYXAgPQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgo TERBUEF1dGhIYW5kbGVyKXJoKS5nZXRBdXRoUHJvdmlkZXIoDQogICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgdXJsLmdldEhvc3QoKSx1cmwuZ2V0UG9ydCgpKTsNCiAgICAg ICAgICAgICAgICAgICAgICAgICAgICBkbiA9IGFwLmdldEROKCk7DQogICAgICAgICAgICAgICAg ICAgICAgICAgICAgcHcgPSBhcC5nZXRQYXNzd29yZCgpOw0KICAgICAgICAgICAgICAgICAgICAg ICAgfQ0KICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgIHJjb25uLmJp bmQoIExEQVBfVjMsIGRuLCBwdyk7DQogICAgICAgICAgICAgICAgICAgIGV4ID0gbnVsbDsNCiAg ICAgICAgICAgICAgICAgICAgcmVmSW5mbyA9IG5ldyBSZWZlcnJhbEluZm8ocmNvbm4sIHJlZmVy cmFscywgdXJsKTsNCiAgICAgICAgICAgICAgICAgICAgLy8gSW5kaWNhdGUgdGhpcyBjb25uZWN0 aW9uIGNyZWF0ZWQgdG8gZm9sbG93IHJlZmVycmFsDQogICAgICAgICAgICAgICAgICAgIHJjb25u LmdldENvbm5lY3Rpb24oKS5zZXRBY3RpdmVSZWZlcnJhbCggcmVmSW5mbyk7DQogICAgICAgICAg ICAgICAgICAgIGJyZWFrOw0KICAgICAgICAgICAgICAgIH0gY2F0Y2goIFRocm93YWJsZSBsZXgp IHsNCiAgICAgICAgICAgICAgICAgICAgaWYoIHJjb25uICE9IG51bGwpIHsNCiAgICAgICAgICAg ICAgICAgICAgICAgIHRyeSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYoIERlYnVn LkxEQVBfREVCVUcpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRGVidWcudHJh Y2UoIERlYnVnLnJlZmVycmFscywgbmFtZSArDQogICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAiZ2V0UmVmZXJyYWxDb25uZWN0aW9uLCBleGNlcHRpb24gIiArDQogICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAiYmluZGluZyBmb3IgcmVmZXJyYWwiICsgbGV4LnRv U3RyaW5nKCkpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAg ICAgICAgICAgICAgICByY29ubi5kaXNjb25uZWN0KCk7DQogICAgICAgICAgICAgICAgICAgICAg ICAgICAgcmNvbm4gPSBudWxsOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4ID0gbGV4 Ow0KICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCggTERBUEV4Y2VwdGlvbiBlKSB7DQog ICAgICAgICAgICAgICAgICAgICAgICAgICAgOyAvLyBpZ25vcmUNCiAgICAgICAgICAgICAgICAg ICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIH0NCg0KICAg ICAgICAgICAgfQ0KICAgICAgICB9DQogICAgICAgIC8vIENoZWNrIGlmIGFwcGxpY2F0aW9uIGdl dHMgY29ubmVjdGlvbiBhbmQgZG9lcyBiaW5kDQogICAgICAgIGVsc2UgeyAvLyAgcmggaW5zdGFu Y2VvZiBMREFQQmluZA0KICAgICAgICAgICAgdHJ5IHsNCiAgICAgICAgICAgICAgICBpZiggRGVi dWcuTERBUF9ERUJVRykgew0KICAgICAgICAgICAgICAgICAgICBEZWJ1Zy50cmFjZSggRGVidWcu cmVmZXJyYWxzLCBuYW1lICsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICJnZXRSZWZlcnJhbENvbm5lY3Rpb246ICIgKw0KICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIkNhbGwgTERBUEJpbmQuYmluZCgpIik7DQog ICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIHJjb25uID0gKChMREFQQmluZEhhbmRs ZXIpcmgpLmJpbmQoIHJlZmVycmFscywgdGhpcyk7DQogICAgICAgICAgICAgICAgaWYoIHJjb25u ID09IG51bGwpIHsNCiAgICAgICAgICAgICAgICAgICAgTERBUFJlZmVycmFsRXhjZXB0aW9uIHJl eCA9IG5ldyBMREFQUmVmZXJyYWxFeGNlcHRpb24oDQogICAgICAgICAgICAgICAgICAgICAgICBF eGNlcHRpb25NZXNzYWdlcy5SRUZFUlJBTF9FUlJPUik7DQogICAgICAgICAgICAgICAgICAgIHJl eC5zZXRSZWZlcnJhbHMoIHJlZmVycmFscyk7DQogICAgICAgICAgICAgICAgICAgIHRocm93IHJl eDsNCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgLy8gRmlndXJlIG91dCB3aGlj aCBVcmwgYmVsb25ncyB0byB0aGUgY29ubmVjdGlvbg0KICAgICAgICAgICAgICAgIGZvciggaW50 IGlkeCA9IDA7IGlkeCA8IHJlZmVycmFscy5sZW5ndGg7IGlkeCsrKSB7DQogICAgICAgICAgICAg ICAgICAgIHRyeSB7DQogICAgICAgICAgICAgICAgICAgICAgICBMREFQVXJsIHVybCA9IG5ldyBM REFQVXJsKCByZWZlcnJhbHNbaWR4XSk7DQogICAgICAgICAgICAgICAgICAgICAgICBpZiggRGVi dWcuTERBUF9ERUJVRykgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIERlYnVnLnRyYWNl KCBEZWJ1Zy5yZWZlcnJhbHMsIG5hbWUgKw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICJnZXRSZWZlcnJhbENvbm5lY3Rpb246ICIgKw0KICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICJDb21wYXJlIGhvc3QgcG9ydCAiICsNCiAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmwuZ2V0SG9zdCgpICsgIi0iICsgcmNvbm4u Z2V0SG9zdCgpICsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiICYg IiArDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXJsLmdldFBvcnQo KSArICItIiArIHJjb25uLmdldFBvcnQoKSk7DQogICAgICAgICAgICAgICAgICAgICAgICB9DQog ICAgICAgICAgICAgICAgICAgICAgICBpZiggdXJsLmdldEhvc3QoKS5lcXVhbHNJZ25vcmVDYXNl KHJjb25uLmdldEhvc3QoKSkgJiYNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKHVy bC5nZXRQb3J0KCkgPT0gcmNvbm4uZ2V0UG9ydCgpKSkgew0KICAgICAgICAgICAgICAgICAgICAg ICAgICAgIHJlZkluZm8gPSBuZXcgUmVmZXJyYWxJbmZvKHJjb25uLCByZWZlcnJhbHMsIHVybCk7 DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7DQogICAgICAgICAgICAgICAgICAg ICAgICB9DQogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKCBFeGNlcHRpb24gZSkgew0KICAg ICAgICAgICAgICAgICAgICAgICAgOyAvLyBpZ25vcmUNCiAgICAgICAgICAgICAgICAgICAgfQ0K ICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiggcmVmSW5mbyA9PSBudWxsKSB7 DQogICAgICAgICAgICAgICAgICAgIGlmKCBEZWJ1Zy5MREFQX0RFQlVHKSB7DQogICAgICAgICAg ICAgICAgICAgICAgICBEZWJ1Zy50cmFjZSggRGVidWcucmVmZXJyYWxzLCBuYW1lICsNCiAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJnZXRSZWZlcnJhbENvbm5lY3Rpb246ICIg Kw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIkxEQVBCaW5kLmJpbmQoKTog IiArDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiIGNvdWxkIG5vdCBtYXRj aCBjb25uZWN0aW9uIHdpdGggVVJMIiArDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICByZWZlcnJhbHMudG9TdHJpbmcoKSk7DQogICAgICAgICAgICAgICAgICAgIH0NCiAgICAg ICAgICAgICAgICAgICAgLy8gQ291bGQgbm90IG1hdGNoIExEQVBCaW5kLmJpbmQoKSBjb25uZWNj dGlvbiB3aXRoIFVSTCBsaXN0DQogICAgICAgICAgICAgICAgICAgIGV4ID0gbmV3IExEQVBMb2Nh bEV4Y2VwdGlvbigNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBFeGNlcHRpb25NZXNzYWdl cy5SRUZFUlJBTF9CSU5EX01BVENILA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIExEQVBF eGNlcHRpb24uQ09OTkVDVF9FUlJPUik7DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAg fSBjYXRjaCggVGhyb3dhYmxlIGxleCkgew0KICAgICAgICAgICAgICAgIGlmKCBEZWJ1Zy5MREFQ X0RFQlVHKSB7DQogICAgICAgICAgICAgICAgICAgIERlYnVnLnRyYWNlKCBEZWJ1Zy5yZWZlcnJh bHMsIG5hbWUgKw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiZ2V0UmVmZXJyYWxD b25uZWN0aW9uOiAiICsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIkV4Y2VwdGlv biBmcm9tIExEQVBCaW5kLmJpbmQoKTogIiArDQogICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgIGxleC50b1N0cmluZygpKTsNCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAg cmNvbm4gPSBudWxsOw0KICAgICAgICAgICAgICAgIGV4ID0gbGV4Ow0KICAgICAgICAgICAgfQ0K ICAgICAgICB9DQogICAgICAgIGlmKCBleCAhPSBudWxsKSB7DQogICAgICAgICAgICAvLyBDb3Vs ZCBub3QgY29ubmVjdCB0byBhbnkgc2VydmVyLCB0aHJvdyBhbiBleGNlcHRpb24NCiAgICAgICAg ICAgIExEQVBFeGNlcHRpb24gbGRhcGV4Ow0KICAgICAgICAgICAgaWYoIGV4IGluc3RhbmNlb2Yg TERBUFJlZmVycmFsRXhjZXB0aW9uKSB7DQogICAgICAgICAgICAgICAgdGhyb3cgKExEQVBSZWZl cnJhbEV4Y2VwdGlvbilleDsNCiAgICAgICAgICAgIH0gZWxzZQ0KICAgICAgICAgICAgaWYoIGV4 IGluc3RhbmNlb2YgTERBUEV4Y2VwdGlvbikgew0KICAgICAgICAgICAgICAgIGxkYXBleCA9IChM REFQRXhjZXB0aW9uKWV4Ow0KICAgICAgICAgICAgfSBlbHNlIHsNCiAgICAgICAgICAgICAgICBs ZGFwZXggPSBuZXcgTERBUExvY2FsRXhjZXB0aW9uKA0KICAgICAgICAgICAgICAgICAgICBFeGNl cHRpb25NZXNzYWdlcy5TRVJWRVJfQ09OTkVDVF9FUlJPUiwNCiAgICAgICAgICAgICAgICAgICAg bmV3IE9iamVjdFtdIHsgY29ubi5nZXRIb3N0KCkgfSwNCiAgICAgICAgICAgICAgICAgICAgTERB UEV4Y2VwdGlvbi5DT05ORUNUX0VSUk9SLCBleCk7DQogICAgICAgICAgICB9DQogICAgICAgICAg ICAvLyBFcnJvciBhdHRlbXB0aW5nIHRvIGZvbGxvdyBhIHJlZmVycmFsDQogICAgICAgICAgICBM REFQUmVmZXJyYWxFeGNlcHRpb24gcmV4ID0gbmV3IExEQVBSZWZlcnJhbEV4Y2VwdGlvbigNCiAg ICAgICAgICAgICAgICAgICAgRXhjZXB0aW9uTWVzc2FnZXMuUkVGRVJSQUxfRVJST1IsDQogICAg ICAgICAgICAgICAgICAgIGxkYXBleCk7DQogICAgICAgICAgICByZXguc2V0UmVmZXJyYWxzKHJl ZmVycmFscyk7DQogICAgICAgICAgICAvLyBVc2UgbGFzdCBVUkwgc3RyaW5nIGZvciB0aGUgZmFp bGVkIHJlZmVycmFsDQogICAgICAgICAgICByZXguc2V0RmFpbGVkUmVmZXJyYWwoIHJlZmVycmFs c1tyZWZlcnJhbHMubGVuZ3RoLTFdKTsNCiAgICAgICAgICAgIHRocm93IHJleDsNCiAgICAgICAg fQ0KDQogICAgICAgIC8vIFdlIG5vdyBoYXZlIGFuIGF1dGhlbnRpY2F0ZWQgY29ubmVjdGlvbg0K ICAgICAgICAvLyB0byBiZSB1c2VkIHRvIGZvbGxvdyB0aGUgcmVmZXJyYWwuDQogICAgICAgIHJl dHVybiByZWZJbmZvOw0KICAgIH0NCg0KICAgIC8qKg0KICAgICAqIENoZWNrIHRoZSByZXN1bHQg Y29kZSBhbmQgdGhyb3cgYW4gZXhjZXB0aW9uIGlmIG5lZWRlZC4NCiAgICAgKg0KICAgICAqIDxw PklmIHJlZmVycmFsIGZvbGxvd2luZyBpcyBlbmFibGVkLCBjaGVja3MgaWYgd2UgbmVlZCB0bw0K ICAgICAqIGZvbGxvdyBhIHJlZmVycmFsPC9wPg0KICAgICAqDQogICAgICogQHBhcmFtIHF1ZXVl IC0gdGhlIG1lc3NhZ2UgcXVldWUgb2YgdGhlIGN1cnJlbnQgcmVzcG9uc2UNCiAgICAgKg0KICAg ICAqIEBwYXJhbSBjb25zIC0gdGhlIGNvbnN0cmFpbnRzIHRoYXQgYXBwbHkgdG8gdGhlIHJlcXVl c3QNCiAgICAgKg0KICAgICAqIEBwYXJhbSByZXNwb25zZSAtIHRoZSBMREFQUmVzcG9uc2UgdG8g Y2hlY2sNCiAgICAgKi8NCiAgICBwcml2YXRlIHZvaWQgY2hrUmVzdWx0Q29kZSggTERBUE1lc3Nh Z2VRdWV1ZSBxdWV1ZSwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTERBUENvbnN0 cmFpbnRzIGNvbnMsDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIExEQVBSZXNwb25z ZSByZXNwb25zZSkNCiAgICAgICAgICAgICAgICB0aHJvd3MgTERBUEV4Y2VwdGlvbg0KICAgICB7 DQogICAgICAgIGlmKCAocmVzcG9uc2UuZ2V0UmVzdWx0Q29kZSgpID09IExEQVBFeGNlcHRpb24u UkVGRVJSQUwpICYmDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zLmdl dFJlZmVycmFsRm9sbG93aW5nKCkpIHsNCiAgICAgICAgICAgIC8vIFBlcmZvcm0gcmVmZXJyYWwg Zm9sbG93aW5nIGFuZCByZXR1cm4NCiAgICAgICAgICAgIEFycmF5TGlzdCByZWZDb25uID0gbnVs bDsNCiAgICAgICAgICAgIHRyeSB7DQogICAgICAgICAgICAgICA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uIG9iamVj dHMNCiAgICAgKiAgICAgICAgdXNlZCBpbiBmb2xsb3dpbmcgdGhlIHJlZmVycmFsLiAgVGhlIGxp c3Qgd2lsbCBiZSBlbXB0eQ0KICAgICAqICAgICAgICBpZiB0aGVyZSB3ZXJlIG5vbmUuDQogICAg ICoNCiAgICAgKiAgQGV4Y2VwdGlvbiBMREFQRXhjZXB0aW9uIEEgZ2VuZXJhbCBleGNlcHRpb24g d2hpY2ggaW5jbHVkZXMgYW4gZXJyb3INCiAgICAgKiAgbWVzc2FnZSBhbmQgYW4gTERBUCBlcnJv ciBjb2RlLg0KICAgICAqLw0KICAgIC8qIHBhY2thZ2UgKi8NCiAgICBBcnJheUxpc3QgY2hhc2VS ZWZlcnJhbCggTERBUE1lc3NhZ2VRdWV1ZSBxdWV1ZSwNCiAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgTERBUENvbnN0cmFpbnRzIGNvbnMsDQogICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgIExEQVBNZXNzYWdlIG1zZywNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg U3RyaW5nW10gaW5pdGlhbFJlZmVycmFscywNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgaW50IGhvcENvdW50LA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sZWFu IHNlYXJjaFJlZmVyZW5jZSwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQXJyYXlM aXN0IGNvbm5lY3Rpb25MaXN0KQ0KICAgICAgICAgICAgICAgICAgICB0aHJvd3MgTERBUEV4Y2Vw dGlvbg0KICAgIHsNCiAgICAgICAgQXJyYXlMaXN0IGNvbm5MaXN0ID0gY29ubmVjdGlvbkxpc3Q7 DQogICAgICAgIExEQVBDb25uZWN0aW9uIHJjb25uID0gbnVsbDsgLy8gbmV3IGNvbm4gZm9yIGZv bGxvd2luZyByZWZlcnJhbA0KICAgICAgICBSZWZlcnJhbEluZm8gcmluZm8gPSBudWxsOyAgIC8v IHJlZmVycmFsIGluZm8NCiAgICAgICAgTERBUE1lc3NhZ2Ugb3JpZ01zZzsNCg0KICAgICAgICBp ZiggRGVidWcuTERBUF9ERUJVRykgew0KICAgICAgICAgICAgRGVidWcudHJhY2UoIERlYnVnLnJl ZmVycmFscywgICBuYW1lICsNCiAgICAgICAgICAgICAgICAiQ2hlY2sgZm9yIHJlZmVycmFscywg cmVmZXJlbmNlID0gIiArIHNlYXJjaFJlZmVyZW5jZSk7DQogICAgICAgIH0NCiAgICAgICAgLy8g R2V0IGEgcGxhY2UgdG8gc3RvcmUgbmV3IGNvbm5lY3Rpb25zDQogICAgICAgIGlmKCBjb25uTGlz dCA9PSBudWxsKSB7DQogICAgICAgICAgICBjb25uTGlzdCA9IG5ldyBBcnJheUxpc3QoIGNvbnMu Z2V0SG9wTGltaXQoKSk7DQogICAgICAgIH0NCiAgICAgICAgLy8gRm9sbG93aW5nIHJlZmVycmFs cyBvciBzZWFyY2ggcmVmZXJlbmNlDQogICAgICAgIFN0cmluZyBbXSByZWZzOyAgICAgICAgICAg ICAvLyByZWZlcnJhbCBsaXN0DQogICAgICAgIGlmKCBpbml0aWFsUmVmZXJyYWxzICE9IG51bGwp IHsNCiAgICAgICAgICAgIC8vIFNlYXJjaCBjb250aW51YXRpb24gcmVmZXJlbmNlIGZyb20gYSBz ZWFyY2ggcmVxdWVzdA0KICAgICAgICAgICAgcmVmcyA9IGluaXRpYWxSZWZlcnJhbHM7DQogICAg ICAgICAgICBvcmlnTXNnID0gbXNnLmdldFJlcXVlc3RpbmdNZXNzYWdlKCk7DQogICAgICAgIH0g ZWxzZSB7IC8vIE5vdCBhIHNlYXJjaCByZXF1ZXN0DQogICAgICAgICAgICBMREFQUmVzcG9uc2Ug cmVzcCA9IChMREFQUmVzcG9uc2UpcXVldWUuZ2V0UmVzcG9uc2UoKTsNCiAgICAgICAgICAgIGlm KCByZXNwLmdldFJlc3VsdENvZGUoKSAhPSBMREFQRXhjZXB0aW9uLlJFRkVSUkFMKSB7DQogICAg ICAgICAgICAgICAgLy8gTm90IHJlZmVycmFsIHJlc3VsdCx0aHJvdyBFeGNlcHRpb24gaWYgbm9u emVybyByZXN1bHQNCiAgICAgICAgICAgICAgICByZXNwLmNoa1Jlc3VsdENvZGUoKTsNCiAgICAg ICAgICAgICAgICByZXR1cm4gY29ubkxpc3Q7DQogICAgICAgICAgICB9DQogICAgICAgICAgICAv LyBXZSBoYXZlIGEgcmVmZXJyYWwgcmVzcG9uc2UNCiAgICAgICAgICAgIHJlZnMgPSByZXNwLmdl dFJlZmVycmFscygpOw0KICAgICAgICAgICAgb3JpZ01zZyA9IHJlc3AuZ2V0UmVxdWVzdGluZ01l c3NhZ2UoKTsNCiAgICAgICAgfQ0KICAgICAgICBMREFQVXJsIHJlZlVybDsgICAgICAgICAgICAg Ly8gcmVmZXJyYWwgcmVwcmVzZW50ZWQgYXMgVVJMDQogICAgICAgIHRyeSB7DQogICAgICAgICAg ICAvLyBpbmNyZW1lbnQgaG9wIGNvdW50LCBjaGVjayBtYXggaG9wcw0KICAgICAgICAgICAgaWYo IGhvcENvdW50KysgPiBjb25zLmdldEhvcExpbWl0KCkpIHsNCiAgICAgICAgICAgICAgICB0aHJv dyBuZXcgTERBUExvY2FsRXhjZXB0aW9uKCJNYXggaG9wcyBleGNlZWRlZCIsDQogICAgICAgICAg ICAgICAgICAgIExEQVBFeGNlcHRpb24uUkVGRVJSQUxfTElNSVRfRVhDRUVERUQpOw0KICAgICAg ICAgICAgfQ0KICAgICAgICAgICAgLy8gR2V0IGEgY29ubmVjdGlvbiB0byBmb2xsb3cgdGhlIHJl ZmVycmFsDQogICAgICAgICAgICByaW5mbyA9IGdldFJlZmVycmFsQ29ubmVjdGlvbiggcmVmcywg Y29ucyk7DQogICAgICAgICAgICByY29ubiA9IHJpbmZvLmdldFJlZmVycmFsQ29ubmVjdGlvbigp Ow0KICAgICAgICAgICAgcmVmVXJsID0gcmluZm8uZ2V0UmVmZXJyYWxVcmwoKTsNCiAgICAgICAg ICAgIGNvbm5MaXN0LmFkZCggcmNvbm4pOw0KDQogICAgICAgICAgICBpZiggRGVidWcuTERBUF9E RUJVRykgew0KICAgICAgICAgICAgICAgIERlYnVnLnRyYWNlKCBEZWJ1Zy5yZWZlcnJhbHMsICAg bmFtZSArDQogICAgICAgICAgICAgICAgICAgICAgICAoc2VhcmNoUmVmZXJlbmNlPyJGb2xsb3dp bmcgc2VhcmNoIHJlZmVyZW5jZSBVUkwgIiA6DQogICAgICAgICAgICAgICAgICAgICAgICAiRm9s bG93aW5nIHJlZmVycmFsIFVSTCAiKSArIHJlZlVybC50b1N0cmluZygpKTsNCiAgICAgICAgICAg IH0NCg0KICAgICAgICAgICAgLy8gcmVidWlsZCBtc2cgaW50byBuZXcgbXNnIGNoYW5naW5nIG1z Z0lELGRuLHNjb3BlLGZpbHRlcg0KICAgICAgICAgICAgTERBUE1lc3NhZ2UgbmV3TXNnID0gcmVi dWlsZFJlcXVlc3QoIG9yaWdNc2csDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgcmVmVXJsLCBzZWFyY2hSZWZlcmVuY2UpOw0KDQogICAgICAgICAgICBp ZiggRGVidWcuTERBUF9ERUJVRykgew0KICAgICAgICAgICAgICAgIERlYnVnLnRyYWNlKCBEZWJ1 Zy5yZWZlcnJhbHMsICAgbmFtZSArDQogICAgICAgICAgICAgICAgICAgICJmb2xsb3dpbmcgcmVm ZXJyYWwgZm9yICIgKyByZWZVcmwudG9TdHJpbmcoKSk7DQogICAgICAgICAgICAgICAgRGVidWcu dHJhY2UoIERlYnVnLnJlZmVycmFscywgICBuYW1lICsNCiAgICAgICAgICAgICAgICAgICAgInJl cXVlc3QgIiArIG5ld01zZy50b1N0cmluZygpKTsNCiAgICAgICAgICAgIH0NCg0KICAgICAgICAg ICAgLy8gU2VuZCBuZXcgbWVzc2FnZSBvbiBuZXcgY29ubmVjdGlvbg0KICAgICAgICAgICAgdHJ5 IHsNCiAgICAgICAgICAgICAgICBNZXNzYWdlQWdlbnQgYWdlbnQ7DQogICAgICAgICAgICAgICAg aWYoIHF1ZXVlIGluc3RhbmNlb2YgTERBUFJlc3BvbnNlUXVldWUpIHsNCiAgICAgICAgICAgICAg ICAgICAgYWdlbnQ9cXVldWUuZ2V0TWVzc2FnZUFnZW50KCk7DQogICAgICAgICAgICAgICAgfSBl bHNlIHsNCiAgICAgICAgICAgICAgICAgICAgYWdlbnQ9cXVldWUuZ2V0TWVzc2FnZUFnZW50KCk7 DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIGFnZW50LnNlbmRNZXNzYWdlKCBy Y29ubi5nZXRDb25uZWN0aW9uKCksIG5ld01zZywNCiAgICAgICAgICAgICAgICAgICAgICAgIGRl ZlNlYXJjaENvbnMuZ2V0VGltZUxpbWl0KCksIHF1ZXVlLCBudWxsKTsNCiAgICAgICAgICAgIH0g Y2F0Y2goSW50ZXJUaHJlYWRFeGNlcHRpb24gZXgpIHsNCiAgICAgICAgICAgICAgICAvLyBFcnJv ciBlbmRpbmcgcmVxdWVzdCB0byByZWZlcnJlZCBzZXJ2ZXINCiAgICAgICAgICAgICAgICBMREFQ UmVmZXJyYWxFeGNlcHRpb24gcmV4ID0gbmV3IExEQVBSZWZlcnJhbEV4Y2VwdGlvbigNCiAgICAg ICAgICAgICAgICAgICAgIEV4Y2VwdGlvbk1lc3NhZ2VzLlJFRkVSUkFMX1NFTkQsDQogICAgICAg ICAgICAgICAgICAgICBMREFQRXhjZXB0aW9uLkNPTk5FQ1RfRVJST1IsIG51bGwsIGV4KTsNCiAg ICAgICAgICAgICAgICByZXguc2V0UmVmZXJyYWxzKCBpbml0aWFsUmVmZXJyYWxzKTsNCiAgICAg ICAgICAgICAgICBSZWZlcnJhbEluZm8gcmVmPXJjb25uLmdldENvbm5lY3Rpb24oKS5nZXRBY3Rp dmVSZWZlcnJhbCgpOw0KICAgICAgICAgICAgICAgIHJleC5zZXRGYWlsZWRSZWZlcnJhbCggcmVm LmdldFJlZmVycmFsVXJsKCkudG9TdHJpbmcoKSk7DQogICAgICAgICAgICAgICAgdGhyb3cgcmV4 Ow0KICAgICAgICAgICAgfQ0KDQogICAgICAgICAgICBpZiggaW5pdGlhbFJlZmVycmFscyA9PSBu dWxsKSB7DQogICAgICAgICAgICAgICAgLy8gRm9yIG9wZXJhdGlvbiByZXN1bHRzLCB3aGVuIGFs bCByZXNwb25zZXMgYXJlIGNvbXBsZXRlLA0KICAgICAgICAgICAgICAgIC8vIHRoZSBzdGFjayB1 bndpbmRzIGJhY2sgdG8gdGhlIG9yaWdpbmFsIGFuZCByZXR1cm5zDQogICAgICAgICAgICAgICAg Ly8gdG8gdGhlIGFwcGxpY2F0aW9uLg0KICAgICAgICAgICAgICAgIC8vIEFuIGV4Y2VwdGlvbiBp cyB0aHJvd24gZm9yIGFuIGVycm9yDQogICAgICAgICAgICAgICAgY29ubkxpc3QgPSBjaGFzZVJl ZmVycmFsKCBxdWV1ZSwgY29ucywgbnVsbCwgbnVsbCwNCiAgICAgICAgICAgICAgICAgICAgICAg ICAgICBob3BDb3VudCwgZmFsc2UsIGNvbm5MaXN0KTsNCiAgICAgICAgICAgIH0gZWxzZSB7DQog ICAgICAgICAgICAgICAgLy8gRm9yIHNlYXJjaCwganVzdCByZXR1cm4gdG8gTERBUFNlYXJjaFJl c3VsdHMgb2JqZWN0DQogICAgICAgICAgICAgICAgcmV0dXJuIGNvbm5MaXN0Ow0KICAgICAgICAg ICAgfQ0KICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24gZXgpIHsNCiAgICAgICAgICAgIGlmKCBE ZWJ1Zy5MREFQX0RFQlVHKSB7DQogICAgICAgICAgICAgICAgRGVidWcudHJhY2UoIERlYnVnLnJl ZmVycmFscywgbmFtZSArDQogICAgICAgICAgICAgICAgICAgICAgICAiVGhyb3cgZXhjZXB0aW9u ICIgKyBleC50b1N0cmluZygpKTsNCiAgICAgICAgICAgIH0NCg0KICAgICAgICAgICAgaWYoIGV4 IGluc3RhbmNlb2YgTERBUFJlZmVycmFsRXhjZXB0aW9uKSB7DQogICAgICAgICAgICAgICAgdGhy b3cgKExEQVBSZWZlcnJhbEV4Y2VwdGlvbilleDsNCiAgICAgICAgICAgIH0gZWxzZSB7DQoNCiAg ICAgICAgICAgICAgICAvLyBTZXQgcmVmZXJyYWwgbGlzdCBhbmQgZmFpbGVkIHJlZmVycmFsDQog ICAgICAgICAgICAgICAgTERBUFJlZmVycmFsRXhjZXB0aW9uIHJleCA9IG5ldyBMREFQUmVmZXJy YWxFeGNlcHRpb24oDQogICAgICAgICAgICAgICAgICAgIEV4Y2VwdGlvbk1lc3NhZ2VzLlJFRkVS UkFMX0VSUk9SLCBleCk7DQogICAgICAgICAgICAgICAgcmV4LnNldFJlZmVycmFscyggcmVmcyk7 DQogICAgICAgICAgICAgICAgaWYoIHJpbmZvICE9IG51bGwpIHsNCiAgICAgICAgICAgICAgICAg ICAgcmV4LnNldEZhaWxlZFJlZmVycmFsKCByaW5mby5nZXRSZWZlcnJhbFVybCgpLnRvU3RyaW5n KCkpOw0KICAgICAgICAgICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICAgICAgICAgIHJleC5z ZXRGYWlsZWRSZWZlcnJhbCggcmVmc1tyZWZzLmxlbmd0aCAtIDFdKTsNCiAgICAgICAgICAgICAg ICB9DQogICAgICAgICAgICAgICAgdGhyb3cgcmV4Ow0KICAgICAgICAgICAgfQ0KICAgICAgICB9 DQogICAgICAgIHJldHVybiBjb25uTGlzdDsNCiAgICB9DQoNCiAgICAvKioNCiAgICAgKiBCdWls ZHMgYSBuZXcgcmVxdWVzdCByZXBsYWNpbmcgZG4sIHNjb3BlLCBhbmQgZmlsdGVyIHdoZXJlIGFw cHJvcHJhdGUNCiAgICAgKg0KICAgICAqIEBwYXJhbSBtc2cgdGhlIG9yaWdpbmFsIExEQVBNZXNz YWdlIHRvIGJ1aWxkIHRoZSBuZXcgcmVxdWVzdCBmcm9tDQogICA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AgICAgaWYoIHJlZmVyZW5jZSkgew0KICAgICAgICAgICAgICAgICAgICBm aWx0ZXIgPSB1cmwuZ2V0RmlsdGVyKCk7DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAg ICAgIGJyZWFrOw0KICAgICAgICAgICAgLy8gV2UgYXJlIGFsbG93ZWQgdG8gZ2V0IGEgcmVmZXJy YWwgZm9yIHRoZSBmb2xsb3dpbmcNCiAgICAgICAgICAgIGNhc2UgTERBUE1lc3NhZ2UuQUREX1JF UVVFU1Q6DQogICAgICAgICAgICBjYXNlIExEQVBNZXNzYWdlLkJJTkRfUkVRVUVTVDoNCiAgICAg ICAgICAgIGNhc2UgTERBUE1lc3NhZ2UuQ09NUEFSRV9SRVFVRVNUOg0KICAgICAgICAgICAgY2Fz ZSBMREFQTWVzc2FnZS5ERUxfUkVRVUVTVDoNCiAgICAgICAgICAgIGNhc2UgTERBUE1lc3NhZ2Uu RVhURU5ERURfUkVRVUVTVDoNCiAgICAgICAgICAgIGNhc2UgTERBUE1lc3NhZ2UuTU9ESUZZX1JE Tl9SRVFVRVNUOg0KICAgICAgICAgICAgY2FzZSBMREFQTWVzc2FnZS5NT0RJRllfUkVRVUVTVDoN CiAgICAgICAgICAgICAgICBicmVhazsNCiAgICAgICAgICAgIC8vIFRoZSBmb2xsb3dpbmcgcmV0 dXJuIG5vIHJlc3BvbnNlDQogICAgICAgICAgICBjYXNlIExEQVBNZXNzYWdlLkFCQU5ET05fUkVR VUVTVDoNCiAgICAgICAgICAgIGNhc2UgTERBUE1lc3NhZ2UuVU5CSU5EX1JFUVVFU1Q6DQogICAg ICAgICAgICBkZWZhdWx0Og0KICAgICAgICAgICAgICAgIHRocm93IG5ldyBMREFQTG9jYWxFeGNl cHRpb24oDQogICAgICAgICAgICAgICAgICAgICAvLyAiUmVmZXJyYWwgZG9lc24ndCBtYWtlIHNl bnNlIGZvciBjb21tYW5kIg0KICAgICAgICAgICAgICAgICAgICBFeGNlcHRpb25NZXNzYWdlcy5J TVBST1BFUl9SRUZFUlJBTCwNCiAgICAgICAgICAgICAgICAgICAgbmV3IE9iamVjdFtdIHsNCiAg ICAgICAgICAgICAgICAgICAgICAgIG5ldyBJbnRlZ2VyKCBtc2cuZ2V0VHlwZSgpKQ0KICAgICAg ICAgICAgICAgICAgICB9LA0KICAgICAgICAgICAgICAgICAgICBMREFQRXhjZXB0aW9uLkxPQ0FM X0VSUk9SKTsNCiAgICAgICAgfQ0KDQogICAgICAgIHJldHVybiBtc2cuY2xvbmUoIGRuLCBmaWx0 ZXIsIHJlZmVyZW5jZSk7DQogICAgfQ0KDQogICAgLyoNCiAgICAgKiBSZWxlYXNlIGNvbm5lY3Rp b25zIGFjcXVpcmVkIGJ5IGZvbGxvd2luZyByZWZlcnJhbHMNCiAgICAgKg0KICAgICAqIEBwYXJh bSBsaXN0IHRoZSBsaXN0IG9mIHRoZSBjb25uZWN0aW9ucw0KICAgICAqLw0KICAgIC8qIHBhY2th Z2UgKi8NCiAgIHZvaWQgcmVsZWFzZVJlZmVycmFsQ29ubmVjdGlvbnMoIEFycmF5TGlzdCBsaXN0 KQ0KICAgew0KICAgICAgICBpZiggbGlzdCA9PSBudWxsKSB7DQogICAgICAgICAgICByZXR1cm47 DQogICAgICAgIH0NCiAgICAgICAgaWYoIERlYnVnLkxEQVBfREVCVUcpIHsNCiAgICAgICAgICAg IERlYnVnLnRyYWNlKCBEZWJ1Zy5yZWZlcnJhbHMsIG5hbWUgKw0KICAgICAgICAgICAgICAgICJS ZWxlYXNlIHJlZmVyYWwgY29ubmVjdGlvbnMiKTsNCiAgICAgICAgfQ0KICAgICAgICAvLyBSZWxl YXNlIHJlZmVycmFsIGNvbm5lY3Rpb25zDQogICAgICAgIGZvciggaW50IGkgPSBsaXN0LnNpemUo KS0xOyBpID49IDA7IGktLSkgew0KICAgICAgICAgICAgTERBUENvbm5lY3Rpb24gcmNvbm4gPSBu dWxsOw0KICAgICAgICAgICAgdHJ5IHsNCiAgICAgICAgICAgICAgICByY29ubiA9IChMREFQQ29u bmVjdGlvbilsaXN0LnJlbW92ZShpKTsNCiAgICAgICAgICAgICAgICBpZiggRGVidWcuTERBUF9E RUJVRykgew0KICAgICAgICAgICAgICAgICAgICBEZWJ1Zy50cmFjZSggRGVidWcucmVmZXJyYWxz LCAiXHQiICsgbmFtZSArDQogICAgICAgICAgICAgICAgICAgICAgICAiRGlzY29ubmVjdGluZyAi ICsNCiAgICAgICAgICAgICAgICAgICAgICAgIHJjb25uLmdldENvbm5lY3Rpb25OYW1lKCkpOw0K ICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICByY29ubi5kaXNjb25uZWN0KCk7DQog ICAgICAgICAgICB9IGNhdGNoKCBBcnJheUluZGV4T3V0T2ZCb3VuZHNFeGNlcHRpb24gZXgpIHsN CiAgICAgICAgICAgICAgICBpZiggRGVidWcuTERBUF9ERUJVRykgew0KICAgICAgICAgICAgICAg ICAgICBEZWJ1Zy50cmFjZSggRGVidWcucmVmZXJyYWxzLCAiXHQiICsgbmFtZSArDQogICAgICAg ICAgICAgICAgICAgICAgICAiRmFpbGVkIHRvIGdldCBjb25uIGF0IGluZGV4ICIgKyBpKTsNCiAg ICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgY29udGludWU7DQogICAgICAgICAgICB9 IGNhdGNoKCBMREFQRXhjZXB0aW9uIGxleCkgew0KICAgICAgICAgICAgICAgIGlmKCBEZWJ1Zy5M REFQX0RFQlVHKSB7DQogICAgICAgICAgICAgICAgICAgIERlYnVnLnRyYWNlKCBEZWJ1Zy5yZWZl cnJhbHMsICJcdCIgKyBuYW1lICsNCiAgICAgICAgICAgICAgICAgICAgICAgICJEaXNjb25uZWN0 IGZhaWxlZCBmb3IgIiArIHJjb25uLmdldENvbm5lY3Rpb25OYW1lKCkpOw0KICAgICAgICAgICAg ICAgIH0NCiAgICAgICAgICAgICAgICBjb250aW51ZTsNCiAgICAgICAgICAgIH0NCiAgICAgICAg fQ0KICAgICAgICByZXR1cm47DQogICAgfQ0KDQogICAgLy8qKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqDQogICAg Ly8gU2NoZW1hIFJlbGF0ZWQgbWV0aG9kcw0KICAgIC8vKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KDQogICAg LyoqDQogICAgICogUmV0cmlldmVzIHRoZSBzY2hlbWEgYXNzb2NpYXRlZCB3aXRoIGEgcGFydGlj dWxhciBzY2hlbWEgRE4gaW4gdGhlDQogICAgICogZGlyZWN0b3J5IHNlcnZlci4NCiAgICAgKiA8 cD5UaGUgc2NoZW1hIEROIGZvciBhIHBhcnRpY3VsYXIgZW50cnkgaXMgb2J0YWluZWQgYnkgY2Fs bGluZyB0aGUNCiAgICAgKiBnZXRTY2hlbWFETiBtZXRob2Qgb2YgTERBUENvbm5lY3Rpb248L3A+ DQogICAgICoNCiAgICAgKiBAcGFyYW0gICAgc2NoZW1hRE4gVGhlIHNjaGVtYSBETiB1c2VkIHRv IGZldGNoIHRoZSBzY2hlbWEuDQogICAgICoNCiAgICAgKiBAcmV0dXJuICAgIEFuIExEQVBTY2hl bWEgZW50cnkgY29udGFpbmluZyBzY2hlbWEgYXR0cmlidXRlcy4gIElmIHRoZQ0KICAgICAqIGVu dHJ5IGNvbnRhaW5zIG5vIHNjaGVtYSBhdHRyaWJ1dGVzIHRoZW4gdGhlIHJldHVybmVkIExEQVBT Y2hlbWEgb2JqZWN0DQogICAgICogd2lsbCBiZSBlbXB0eS4NCiAgICAgKg0KICAgICAqIEBleGNl cHRpb24gTERBUEV4Y2VwdGlvbiAgICAgVGhpcyBleGNlcHRpb24gb2NjdXJzIGlmIHRoZSBzY2hl bWEgZW50cnkNCiAgICAgKiAgICAgICAgICBjYW5ub3QgYmUgcmV0cmlldmVkIHdpdGggdGhpcyBj b25uZWN0aW9uLg0KICAgICAqI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ZW1hU3ViZW50cnkgYXR0cmlidXRlLiBUaHJvd3MgYW4gZXhjZXB0aW9uIGlmDQogICAgICAgICAq IG5vIGVudHJpZXMgYXJlIHJldHVybmVkLiAqLw0KICAgICAgICBMREFQRW50cnkgZW50ID0gdGhp cy5yZWFkKCBkbiwgYXR0clN1YlNjaGVtYSApOw0KDQogICAgICAgIExEQVBBdHRyaWJ1dGUgYXR0 ciA9IGVudC5nZXRBdHRyaWJ1dGUoIGF0dHJTdWJTY2hlbWFbMF0gKTsNCiAgICAgICAgU3RyaW5n IHZhbHVlc1tdID0gYXR0ci5nZXRTdHJpbmdWYWx1ZUFycmF5KCk7DQogICAgICAgIGlmKCB2YWx1 ZXMgPT0gbnVsbCB8fCB2YWx1ZXMubGVuZ3RoIDwgMSApIHsNCiAgICAgICAgICAgIHRocm93IG5l dyBMREFQTG9jYWxFeGNlcHRpb24oDQogICAgICAgICAgICAgICAgRXhjZXB0aW9uTWVzc2FnZXMu Tk9fU0NIRU1BLA0KICAgICAgICAgICAgICAgIG5ldyBPYmplY3RbXSB7IGRuIH0sDQogICAgICAg ICAgICAgICAgTERBUEV4Y2VwdGlvbi5OT19SRVNVTFRTX1JFVFVSTkVEKTsNCiAgICAgICAgfQ0K ICAgICAgICBlbHNlIGlmKCB2YWx1ZXMubGVuZ3RoID4gMSApIHsNCiAgICAgICAgICAgIHRocm93 IG5ldyBMREFQTG9jYWxFeGNlcHRpb24oDQogICAgICAgICAgICAgICAgRXhjZXB0aW9uTWVzc2Fn ZXMuTVVMVElQTEVfU0NIRU1BLA0KICAgICAgICAgICAgICAgIG5ldyBPYmplY3RbXSB7IGRuIH0s DQogICAgICAgICAgICAgICAgTERBUEV4Y2VwdGlvbi5DT05TVFJBSU5UX1ZJT0xBVElPTik7DQog ICAgICAgIH0NCiAgICAgICAgcmV0dXJuIHZhbHVlc1swXTsNCiAgIH0NCiAgIA0KfQ0K
------_=_NextPart_001_01C9711D.AD2F41AD--