Source Code Cross Referenced for FileService.java in  » Search-Engine » regain » net » sf » regain » ui » desktop » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Search Engine » regain » net.sf.regain.ui.desktop 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        package net.sf.regain.ui.desktop;
02:
03:        import net.sf.regain.RegainToolkit;
04:        import net.sf.regain.search.SearchToolkit;
05:        import net.sf.regain.util.sharedtag.PageRequest;
06:        import net.sf.regain.util.sharedtag.PageResponse;
07:        import net.sf.regain.util.sharedtag.simple.SharedTagResource;
08:        import net.sf.regain.util.sharedtag.simple.SimplePageRequest;
09:        import net.sf.regain.util.sharedtag.simple.SimplePageResponse;
10:        import simple.http.Request;
11:        import simple.http.Response;
12:        import simple.http.load.BasicService;
13:        import simple.http.serve.Context;
14:
15:        /**
16:         * A simpleweb service providing files. For security reasons this service only
17:         * provides files that are in the index.
18:         *
19:         * @author Til Schneider, www.murfman.de
20:         */
21:        public class FileService extends BasicService {
22:
23:            /**
24:             * Creates a new instance of FileService.
25:             * 
26:             * @param context The context of this service.
27:             */
28:            public FileService(Context context) {
29:                super (context);
30:            }
31:
32:            /**
33:             * Processes a request.
34:             * 
35:             * @param req The request.
36:             * @param resp The response.
37:             * @throws Exception If executing the JSP page failed.
38:             */
39:            public void process(Request req, Response resp) throws Exception {
40:                // Check whether this request comes from localhost
41:                boolean localhost = req.getInetAddress().isLoopbackAddress();
42:                if (!localhost) {
43:                    // This request does not come from localhost -> Send 403 Forbidden
44:                    handle(req, resp, 403);
45:                }
46:
47:                // Create a shared wrapper
48:                PageRequest request = new SimplePageRequest(req);
49:                PageResponse response = new SimplePageResponse(this , req, resp,
50:                        null, null);
51:
52:                // Get the request path (Without GET-Parameters)
53:                // NOTE: We don't use context.getRequestPath for this, because it decodes
54:                //       the URL, but we want to decode it ourselves using our encoding
55:                String requestPath = req.getURI();
56:                int paramsStart = requestPath.indexOf('?');
57:                if (paramsStart != -1) {
58:                    requestPath = requestPath.substring(0, paramsStart);
59:                }
60:
61:                // Extract the file URL
62:                String fileUrl = SearchToolkit.extractFileUrl(requestPath,
63:                        SharedTagResource.SIMPLE_TAG_ENCODING);
64:
65:                // Check the file URL
66:                if (SearchToolkit.allowFileAccess(request, fileUrl)) {
67:                    // This file is allowed -> Send it
68:                    SearchToolkit.sendFile(request, response, RegainToolkit
69:                            .urlToFile(fileUrl));
70:                } else {
71:                    // This file is not allowed -> Send 403 Forbidden
72:                    handle(req, resp, 403);
73:                }
74:            }
75:
76:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.