(String url, WebBrowser web, final ActionListener<ActionEvent> al, final Form frm, final Form backToForm, final Dialog progress)
| 545 | } |
| 546 | |
| 547 | private void handleURL(String url, WebBrowser web, final ActionListener<ActionEvent> al, final Form frm, final Form backToForm, final Dialog progress) { |
| 548 | if ((url.startsWith(redirectURI))) { |
| 549 | if (progress != null && Display.getInstance().getCurrent() == progress) { //NOPMD CompareObjectsWithEquals |
| 550 | progress.dispose(); |
| 551 | } |
| 552 | |
| 553 | if (web != null) { |
| 554 | web.stop(); |
| 555 | } |
| 556 | |
| 557 | //remove the browser component. |
| 558 | if (login != null) { |
| 559 | login.removeAll(); |
| 560 | login.revalidate(); |
| 561 | } |
| 562 | |
| 563 | if (url.indexOf("code=") > -1) { |
| 564 | Hashtable params = getParamsFromURL(url); |
| 565 | handleRedirectURLParams(params); |
| 566 | class TokenRequest extends ConnectionRequest { |
| 567 | boolean callbackCalled; |
| 568 | |
| 569 | @Override |
| 570 | protected void readResponse(InputStream input) throws IOException { |
| 571 | byte[] tok = Util.readInputStream(input); |
| 572 | String t = StringUtil.newString(tok); |
| 573 | if (t.startsWith("{")) { |
| 574 | JSONParser p = new JSONParser(); |
| 575 | Map map = p.parseJSON(new StringReader(t)); |
| 576 | handleTokenRequestResponse(map); |
| 577 | } else { |
| 578 | handleTokenRequestResponse(t); |
| 579 | } |
| 580 | if (login != null) { |
| 581 | login.dispose(); |
| 582 | } |
| 583 | } |
| 584 | |
| 585 | @Override |
| 586 | protected void handleException(Exception err) { |
| 587 | if (backToForm != null && !callbackCalled) { |
| 588 | backToForm.showBack(); |
| 589 | } |
| 590 | if (al != null) { |
| 591 | if (!callbackCalled) { |
| 592 | callbackCalled = true; |
| 593 | al.actionPerformed(new ActionEvent(err, ActionEvent.Type.Exception)); |
| 594 | } |
| 595 | } |
| 596 | } |
| 597 | |
| 598 | @Override |
| 599 | public final boolean equals(Object o) { |
| 600 | if (!(o instanceof TokenRequest)) { |
| 601 | return false; |
| 602 | } |
| 603 | if (!super.equals(o)) { |
| 604 | return false; |
no test coverage detected