Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 69997a004fc65673922ff59e9235ec0d3e621d7e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//
//  ========================================================================
//  Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
//  ------------------------------------------------------------------------
//  All rights reserved. This program and the accompanying materials
//  are made available under the terms of the Eclipse Public License v1.0
//  and Apache License v2.0 which accompanies this distribution.
//
//      The Eclipse Public License is available at
//      http://www.eclipse.org/legal/epl-v10.html
//
//      The Apache License v2.0 is available at
//      http://www.opensource.org/licenses/apache2.0.php
//
//  You may elect to redistribute this code under either of these licenses.
//  ========================================================================
//

package org.eclipse.jetty.gcloud.session;




import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AllowSymLinkAliasChecker;
import org.eclipse.jetty.server.session.SessionHandler;
import org.eclipse.jetty.webapp.WebAppContext;

public class GCloudSessionTester
{
    public static void main( String[] args ) throws Exception
    {
        if (args.length < 4)
            System.err.println("Usage: GCloudSessionTester projectid p12file password serviceaccount");
        
        System.setProperty("org.eclipse.jetty.server.session.LEVEL", "DEBUG");
        
        Server server = new Server(8080);
        HashLoginService loginService = new HashLoginService();
        loginService.setName( "Test Realm" );
        loginService.setConfig( "../../jetty-distribution/target/distribution/demo-base/resources/realm.properties" );
        server.addBean( loginService );

        GCloudConfiguration config = new GCloudConfiguration();
        config.setProjectId(args[0]);
        config.setP12File(args[1]);
        config.setPassword(args[2]);
        config.setServiceAccount(args[3]);

        GCloudSessionIdManager idmgr = new GCloudSessionIdManager(server);
        idmgr.setConfig(config);
        idmgr.setWorkerName("w1");
        server.setSessionIdManager(idmgr);

 
        WebAppContext webapp = new WebAppContext();
        webapp.setContextPath("/");
        webapp.setResourceBase("../../jetty-distribution/target/distribution/demo-base/webapps/test/");
        webapp.addAliasCheck(new AllowSymLinkAliasChecker());
        GCloudSessionManager mgr = new GCloudSessionManager();
        mgr.setSessionIdManager(idmgr);
        webapp.setSessionHandler(new SessionHandler(mgr));

        // A WebAppContext is a ContextHandler as well so it needs to be set to
        // the server so it is aware of where to send the appropriate requests.
        server.setHandler(webapp);

        // Start things up! 
        server.start();

    
        server.join();
    }
}

Back to the top