Class SpotifyAuthorizationServer
java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
az.araezarzosa.spotifyoverlay.spotify_in_game_overlay.SpotifyAuthorizationServer
- All Implemented Interfaces:
jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,java.io.Serializable
public class SpotifyAuthorizationServer
extends jakarta.servlet.http.HttpServlet
Stores the server that assists in app authorization.
- Author:
- Arae
- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classSpotifyAuthorizationServer.AuthorizationHandlerThe handler that runs after callback from the authorization page. -
Field Summary
Fields Modifier and Type Field Description static java.lang.StringcodeThe authorization code that is retrieved after authorization.private static intPORTPort number the server will connect to locally.private static java.lang.StringREDIRECT_URIRedirect URI formed from the port numberprivate static longserialVersionUID -
Constructor Summary
Constructors Constructor Description SpotifyAuthorizationServer() -
Method Summary
Modifier and Type Method Description static java.lang.StringgetAuthorizationUrl()The getter for the URL that opens for authorization.static voidinitiateAuthorizationFlow()Opens the URL generated by getAuthorizationUrl.static voidopenWebpage(java.lang.String url)Opens the specified webpage in the user's desktop's default browser.static voidstartServer()Starts the server on the designated port number.static voidstopServer(org.eclipse.jetty.server.Server server)Stops the specified server.Methods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, serviceMethods inherited from class jakarta.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, logMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
- Constant Field Values
-
PORT
private static final int PORTPort number the server will connect to locally.- See Also:
- Constant Field Values
-
REDIRECT_URI
private static final java.lang.String REDIRECT_URIRedirect URI formed from the port number- See Also:
- Constant Field Values
-
code
public static java.lang.String codeThe authorization code that is retrieved after authorization.
-
-
Constructor Details
-
SpotifyAuthorizationServer
public SpotifyAuthorizationServer()
-
-
Method Details
-
startServer
public static void startServer() throws java.lang.ExceptionStarts the server on the designated port number.- Throws:
java.lang.Exception
-
getAuthorizationUrl
public static java.lang.String getAuthorizationUrl()The getter for the URL that opens for authorization.- Returns:
- The URL.
-
initiateAuthorizationFlow
public static void initiateAuthorizationFlow()Opens the URL generated by getAuthorizationUrl. -
openWebpage
public static void openWebpage(java.lang.String url)Opens the specified webpage in the user's desktop's default browser.- Parameters:
url- The URL to be opened.
-
stopServer
public static void stopServer(org.eclipse.jetty.server.Server server) throws java.lang.ExceptionStops the specified server.- Parameters:
server- The server to be stopped.- Throws:
java.lang.Exception
-