com.pryv.auth.AuthBrowserView Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons Show documentation
Show all versions of commons Show documentation
Common library shared among Java and Android.
The newest version!
package com.pryv.auth;
import java.applet.Applet;
import java.awt.Desktop;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
/**
* Web view that is displayed to enter credentials
*/
public class AuthBrowserView extends Applet implements AuthView {
public AuthBrowserView() {
}
public static void openWebpage(URI uri) {
Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
try {
desktop.browse(uri);
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Override
public void displayLoginView(String loginURL) {
try {
URL url = new URL(loginURL);
openWebpage(url.toURI());
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
// unused
@Override
public void onAuthSuccess(String username, String token) {
}
// unused
@Override
public void onAuthError(String message) {
}
// unused
@Override
public void onAuthRefused(int reasonId, String message, String detail) {
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy