Statistics
| Branch: | Tag: | Revision:

root / src / org / gss_project / gss / server / webdav / milton / GssMiltonServlet.java @ 1205:fbeae20462e6

History | View | Annotate | Download (3.8 kB)

1
/*
2
 * Copyright 2011 Electronic Business Systems Ltd.
3
 *
4
 * This file is part of GSS.
5
 *
6
 * GSS is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * GSS is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with GSS.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19
package org.gss_project.gss.server.webdav.milton;
20

    
21
import javax.servlet.ServletConfig;
22
import javax.servlet.ServletException;
23

    
24
import org.slf4j.Logger;
25
import org.slf4j.LoggerFactory;
26

    
27
import com.bradmcevoy.http.AuthenticationService;
28
import com.bradmcevoy.http.MiltonServlet;
29
import com.bradmcevoy.http.ServletHttpManager;
30
import com.bradmcevoy.http.webdav.DefaultWebDavResponseHandler;
31

    
32
/**
33
 * @author kman
34
 *
35
 */
36
public class GssMiltonServlet extends MiltonServlet {
37
        private Logger log = LoggerFactory.getLogger( GssMiltonServlet.class );
38
        private ServletConfig config;
39
        
40
        public void init( ServletConfig config ) throws ServletException {
41
        try {
42
            this.config = config;
43
            GssLockManager lockManager = new GssLockManager();
44
            //SimpleMemoryNonceProvider nonce = new SimpleMemoryNonceProvider( 60*60*24 );
45
            GssNonceProvider nonce = new GssNonceProvider( 60*60*24 );
46
            GssSecurityManager securityManager = new GssSecurityManager("Pithos WebDAV");
47
            AuthenticationService authService = new AuthenticationService(nonce);
48
            authService.setDisableBasic(true);
49
            authService.setDisableDigest(false);
50
            DefaultWebDavResponseHandler responseHandler = new DefaultWebDavResponseHandler(authService);
51
            GssWebDavResponseHandler compressHandler = new GssWebDavResponseHandler(responseHandler);
52
            //CompressingResponseHandler compressHandler = new CompressingResponseHandler(responseHandler);
53
            GSSResourceFactory resourceFactory = new GSSResourceFactory();
54
            resourceFactory.setSecurityManager(securityManager);
55
            resourceFactory.setLockManager(lockManager);
56
            resourceFactory.setMaxAgeSeconds(3600l);
57
            resourceFactory.setContextPath("webdav");
58
            //PreAuthenticationFilter filter = new PreAuthenticationFilter(compressHandler, securityManager,nonce);
59
            /*ConsoleResourceFactory consoleResourceFactory = new ConsoleResourceFactory(resourceFactory, "/console", "/webdav", Arrays.asList(new com.ettrema.console.LsFactory(),
60
                        new com.ettrema.console.CdFactory(),
61
                        new com.ettrema.console.RmFactory(),
62
                        new com.ettrema.console.HelpFactory(),
63
                        new com.ettrema.console.CpFactory(),
64
                        new com.ettrema.console.MkFactory(),
65
                        new com.ettrema.console.MkdirFactory()), "webdav");
66
            */
67
            httpManager = new ServletHttpManager(resourceFactory,compressHandler,authService);
68
            
69
            
70
                    
71
            /*if(httpManager.getFilters()==null)
72
                    httpManager.setFilters(new ArrayList<Filter>());
73
            httpManager.getFilters().add(filter);*/
74
            //List<AuthenticationHandler> list = new ArrayList();
75
            //list.add(new DigestAuthenticationHandler(authService));
76
           // httpManager.addFilter(0, filter);
77
            
78
        }catch( Throwable ex ) {
79
            log.error( "Exception starting milton servlet", ex );
80
            throw new RuntimeException( ex );
81
        }
82
    }
83
}