Package org.h2.server.web
Class WebServer
- java.lang.Object
-
- org.h2.server.web.WebServer
-
-
Constructor Summary
Constructors Constructor Description WebServer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringaddSession(java.sql.Connection conn)Create a session with a given connection.static java.lang.StringencodeAdminPassword(java.lang.String password)Generates a random salt and returns it with a hash of specified password with this salt.booleangetAllowOthers()Check if remote connections are allowed.java.util.ArrayList<java.lang.String>getCommandHistoryList()java.lang.StringgetHost()java.lang.StringgetName()Get the human readable name of the service.intgetPort()Gets the port this service is listening on.java.lang.StringgetType()Get the human readable short name of the service.java.lang.StringgetURL()Get the URL of this service in a human readable formvoidinit(java.lang.String... args)Initialize the service from command line options.booleanisCommandHistoryAllowed()booleanisDaemon()Check if a daemon thread should be used.booleanisRunning(boolean traceError)Check if the service is running.booleanisStopped()voidlisten()Listen for incoming connections.voidsaveCommandHistoryList(java.util.ArrayList<java.lang.String> commandHistory)Save the command history to the properties file.voidsetAllowSecureCreation(boolean allowSecureCreation)voidsetCommandHistoryAllowed(boolean allowed)voidsetKey(java.lang.String key)Sets the key for privileged connections.voidsetShutdownHandler(ShutdownHandler shutdownHandler)voidstart()Start the service.voidstop()Stop the service.
-
-
-
Method Detail
-
setKey
public void setKey(java.lang.String key)
Sets the key for privileged connections.- Parameters:
key- key, or null
-
setAllowSecureCreation
public void setAllowSecureCreation(boolean allowSecureCreation)
- Parameters:
allowSecureCreation- whether creation of databases using the key should be allowed
-
init
public void init(java.lang.String... args)
Description copied from interface:ServiceInitialize the service from command line options.
-
getURL
public java.lang.String getURL()
Description copied from interface:ServiceGet the URL of this service in a human readable form
-
getHost
public java.lang.String getHost()
- Returns:
- host name
-
start
public void start()
Description copied from interface:ServiceStart the service. This usually means create the server socket. This method must not block.
-
listen
public void listen()
Description copied from interface:ServiceListen for incoming connections. This method blocks.
-
isRunning
public boolean isRunning(boolean traceError)
Description copied from interface:ServiceCheck if the service is running.
-
isStopped
public boolean isStopped()
-
stop
public void stop()
Description copied from interface:ServiceStop the service.
-
getType
public java.lang.String getType()
Description copied from interface:ServiceGet the human readable short name of the service.
-
getName
public java.lang.String getName()
Description copied from interface:ServiceGet the human readable name of the service.
-
getAllowOthers
public boolean getAllowOthers()
Description copied from interface:ServiceCheck if remote connections are allowed.- Specified by:
getAllowOthersin interfaceService- Returns:
- true if remote connections are allowed
-
getPort
public int getPort()
Description copied from interface:ServiceGets the port this service is listening on.
-
isCommandHistoryAllowed
public boolean isCommandHistoryAllowed()
-
setCommandHistoryAllowed
public void setCommandHistoryAllowed(boolean allowed)
-
getCommandHistoryList
public java.util.ArrayList<java.lang.String> getCommandHistoryList()
-
saveCommandHistoryList
public void saveCommandHistoryList(java.util.ArrayList<java.lang.String> commandHistory)
Save the command history to the properties file.- Parameters:
commandHistory- the history
-
setShutdownHandler
public void setShutdownHandler(ShutdownHandler shutdownHandler)
-
addSession
public java.lang.String addSession(java.sql.Connection conn) throws java.sql.SQLExceptionCreate a session with a given connection.- Parameters:
conn- the connection- Returns:
- the URL of the web site to access this connection
- Throws:
java.sql.SQLException- on failure
-
isDaemon
public boolean isDaemon()
Description copied from interface:ServiceCheck if a daemon thread should be used.
-
encodeAdminPassword
public static java.lang.String encodeAdminPassword(java.lang.String password)
Generates a random salt and returns it with a hash of specified password with this salt.- Parameters:
password- the password- Returns:
- a salt and hash of salted password as a hex encoded string to be used in configuration file
- Throws:
java.lang.IllegalArgumentException- when password is too short
-
-