Statistics
| Branch: | Tag: | Revision:

root / src / gr / ebs / gss / server / webdav / milton / GssMiltonServlet.java @ 21a76038

History | View | Annotate | Download (4 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 gr.ebs.gss.server.webdav.milton;
20

    
21
import java.util.Arrays;
22

    
23
import javax.servlet.ServletConfig;
24
import javax.servlet.ServletException;
25

    
26
import org.slf4j.Logger;
27
import org.slf4j.LoggerFactory;
28

    
29
import com.bradmcevoy.http.AuthenticationService;
30
import com.bradmcevoy.http.CompressingResponseHandler;
31
import com.bradmcevoy.http.MiltonServlet;
32
import com.bradmcevoy.http.ServletHttpManager;
33
import com.bradmcevoy.http.http11.auth.PreAuthenticationFilter;
34
import com.bradmcevoy.http.webdav.DefaultWebDavResponseHandler;
35
import com.ettrema.console.Console;
36
import com.ettrema.console.ConsoleResourceFactory;
37

    
38

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