-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
111 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,5 @@ | |
.classpath | ||
.settings/ | ||
/target/ | ||
#/src/main/todo/todo.tmp | ||
/src/main/todo/todo.tmp | ||
/src/main/todo/todo.txt.bak |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
###################################### | ||
# - todo.txt-wicket | ||
# - bin | ||
# - run.sh | ||
# - webapp | ||
# - `unzip todo.txt-wicket-*.war` | ||
###################################### | ||
MAINPATH=".." | ||
CONTEXTPATH="/" | ||
WARPATH="$MAINPATH/webapp" | ||
LIBRARY="$WARPATH/WEB-INF/lib" | ||
CLASSES="$WARPATH/WEB-INF/classes" | ||
KEYSTORE="$CLASSES/keystore" | ||
SSLPORT="8443" | ||
KEYSTOREPASSWORD="somepass" | ||
|
||
CLASSPATH="$CLASSES" | ||
for a in $LIBRARY/*.jar; do CLASSPATH=$CLASSPATH:$a; done | ||
|
||
/usr/bin/java -Dkeystore=$KEYSTORE -Dkeystorepassword=$KEYSTOREPASSWORD -Dcontextpath_0=$CONTEXTPATH -Dwarpath_0=$WARPATH -Dsslport=$SSLPORT -cp $CLASSPATH com.todotxt.todotxtwicket.common.StartJettySsl |
77 changes: 77 additions & 0 deletions
77
src/main/java/com/todotxt/todotxtwicket/common/StartJettySsl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package com.todotxt.todotxtwicket.common; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.mortbay.jetty.Connector; | ||
import org.mortbay.jetty.Handler; | ||
import org.mortbay.jetty.Server; | ||
import org.mortbay.jetty.security.SslSocketConnector; | ||
import org.mortbay.jetty.webapp.WebAppContext; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import com.todotxt.todotxtjava.Util; | ||
|
||
public class StartJettySsl { | ||
|
||
private static final String KEYSTORE = "keystore"; | ||
private static final String KEYSTOREPASSWORD = "keystorepassword"; | ||
private static final String SSLPORT = "sslport"; | ||
private static final String HANDLERS = "handlers"; | ||
private static final String WARPATH = "warpath_"; | ||
private static final String CONTEXTPATH = "contextpath_"; | ||
|
||
private final static Logger log = LoggerFactory.getLogger(StartJettySsl.class); | ||
|
||
public static void main(String[] args) { | ||
//server specific | ||
String password = System.getProperty(KEYSTOREPASSWORD, "jetty6"); | ||
String keystore = System.getProperty(KEYSTORE, "src/main/resources/keystore"); | ||
int sslPort = Integer.parseInt(System.getProperty(SSLPORT, "8443")); | ||
int handlers = Integer.parseInt(System.getProperty(HANDLERS, "10")); | ||
|
||
Server jettyServer = null; | ||
try { | ||
jettyServer = new Server(); | ||
|
||
SslSocketConnector sslConn = new SslSocketConnector(); | ||
sslConn.setPort(sslPort); | ||
sslConn.setPassword(password); | ||
sslConn.setKeystore(keystore); | ||
sslConn.setKeyPassword(password); | ||
|
||
jettyServer.setConnectors(new Connector[] { sslConn }); | ||
|
||
List<WebAppContext> contexts = new ArrayList<WebAppContext>(); | ||
for (int i = 0; i < handlers; i++) { | ||
String war = System.getProperty(WARPATH+i); | ||
String contextPath = System.getProperty(CONTEXTPATH+i); | ||
if(!Util.isEmpty(war) && !Util.isEmpty(contextPath)){ | ||
contexts.add(new WebAppContext(war, contextPath)); | ||
} | ||
} | ||
int ncxt = contexts.size(); | ||
if(ncxt == 0){ | ||
contexts.add(new WebAppContext("src/main/webapp", "/")); | ||
ncxt = 1; | ||
} | ||
|
||
jettyServer.setHandlers(contexts.toArray(new Handler[0])); | ||
|
||
jettyServer.start(); | ||
log.info("SSL Server started on port=" + sslPort + ", keystore=" | ||
+ keystore + " webapps=" + ncxt); | ||
} catch (Exception e) { | ||
log.error("Could not start the Jetty server: " + e, e); | ||
if (jettyServer != null) { | ||
try { | ||
jettyServer.stop(); | ||
} catch (Exception e1) { | ||
log.error("Unable to stop the jetty server: " + e1, e1); | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters