MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / handleURL

Method handleURL

CodenameOne/src/com/codename1/io/Oauth2.java:547–699  ·  view source on GitHub ↗
(String url, WebBrowser web, final ActionListener<ActionEvent> al, final Form frm, final Form backToForm, final Dialog progress)

Source from the content-addressed store, hash-verified

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;

Callers 4

handleRedirectMethod · 0.95
onLoadMethod · 0.95
refreshTokenMethod · 0.95
actionPerformedMethod · 0.80

Calls 15

getInstanceMethod · 0.95
getParamsFromURLMethod · 0.95
containsKeyMethod · 0.95
getMethod · 0.95
getInstanceMethod · 0.95
indexOfMethod · 0.95
substringMethod · 0.95
setPostMethod · 0.80
addRequestHeaderMethod · 0.80
startsWithMethod · 0.65

Tested by

no test coverage detected