Source Code Cross Referenced for XWSSPipelineAssemblerFactory.java in  » 6.0-JDK-Modules-com.sun » xws-security » com » sun » xml » xwss » 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 » 6.0 JDK Modules com.sun » xws security » com.sun.xml.xwss 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * XWSSPipelineAssemblerFactory.java
003:         *
004:         * Created on October 30, 2006, 3:39 PM
005:         *
006:         * To change this template, choose Tools | Template Manager
007:         * and open the template in the editor.
008:         */
009:
010:        package com.sun.xml.xwss;
011:
012:        import com.sun.xml.ws.api.BindingID;
013:        import com.sun.xml.ws.api.WSBinding;
014:        import com.sun.xml.ws.api.WSService;
015:        import com.sun.xml.ws.api.model.wsdl.WSDLPort;
016:        import com.sun.xml.ws.api.pipe.ClientPipeAssemblerContext;
017:        import com.sun.xml.ws.api.pipe.Pipe;
018:        import com.sun.xml.ws.api.addressing.AddressingVersion;
019:        import com.sun.xml.ws.api.pipe.PipelineAssembler;
020:        import com.sun.xml.ws.api.pipe.PipelineAssemblerFactory;
021:        import com.sun.xml.ws.api.pipe.ServerPipeAssemblerContext;
022:        import com.sun.xml.ws.api.server.Container;
023:        import com.sun.xml.ws.api.server.WSEndpoint;
024:        import com.sun.xml.wss.impl.misc.SecurityUtil;
025:        import java.io.InputStream;
026:        import java.net.URL;
027:        import javax.servlet.ServletContext;
028:        import javax.xml.namespace.QName;
029:
030:        /**
031:         *
032:         * @author kumar.jayanti
033:         */
034:        public class XWSSPipelineAssemblerFactory extends
035:                PipelineAssemblerFactory {
036:
037:            private static final String SERVLET_CONTEXT_CLASSNAME = "javax.servlet.ServletContext";
038:            private BindingID bindingId;
039:
040:            private static class XWSSPipelineAssembler implements 
041:                    PipelineAssembler {
042:                private BindingID bindingId;
043:
044:                /** Creates a new instance of XWSSPipelineAssemblerFactory */
045:                public XWSSPipelineAssembler(final BindingID bindingId) {
046:                    this .bindingId = bindingId;
047:                }
048:
049:                public Pipe createClient(ClientPipeAssemblerContext context) {
050:
051:                    // Transport pipe ALWAYS exist
052:                    Pipe p = context.createTransportPipe();
053:
054:                    if (isSecurityConfigPresent(context)) {
055:                        p = initializeXWSSClientPipe(context.getWsdlModel(),
056:                                context.getService(), context.getBinding(), p);
057:                    }
058:
059:                    p = context.createClientMUPipe(p);
060:                    p = context.createHandlerPipe(p);
061:                    // check for WS-Addressing
062:                    if (isAddressingEnabled(context.getWsdlModel(), context
063:                            .getBinding())) {
064:                        p = context.createWsaPipe(p);
065:                    }
066:
067:                    return p;
068:                }
069:
070:                public Pipe createServer(ServerPipeAssemblerContext context) {
071:
072:                    Pipe p = context.getTerminalPipe();
073:                    p = context.createHandlerPipe(p);
074:                    p = context.createServerMUPipe(p);
075:                    p = context.createMonitoringPipe(p);
076:
077:                    // check for WS-Addressing
078:                    if (isAddressingEnabled(context.getWsdlModel(), context
079:                            .getEndpoint().getBinding())) {
080:                        p = context.createWsaPipe(p);
081:                    }
082:                    //look for XWSS 2.0 Style Security
083:                    if (isSecurityConfigPresent(context)) {
084:                        p = initializeXWSSServerPipe(context.getEndpoint(),
085:                                context.getWsdlModel(), p);
086:                    }
087:
088:                    return p;
089:                }
090:
091:                private boolean isAddressingEnabled(WSDLPort port,
092:                        WSBinding binding) {
093:                    if (AddressingVersion.isEnabled(binding)) {
094:                        return true;
095:                    }
096:                    return false;
097:                }
098:
099:                private static boolean isSecurityConfigPresent(
100:                        ClientPipeAssemblerContext context) {
101:                    //returning true by default for now, because the Client Side Security Config is
102:                    //only accessible as a Runtime Property on BindingProvider.RequestContext
103:                    return true;
104:                }
105:
106:                private static boolean isSecurityConfigPresent(
107:                        ServerPipeAssemblerContext context) {
108:
109:                    QName serviceQName = context.getEndpoint().getServiceName();
110:                    //TODO: not sure which of the two above will give the service name as specified in DD
111:                    String serviceLocalName = serviceQName.getLocalPart();
112:                    Container container = context.getEndpoint().getContainer();
113:
114:                    Object ctxt = null;
115:                    if (container != null) {
116:                        try {
117:                            final Class<?> contextClass = Class
118:                                    .forName(SERVLET_CONTEXT_CLASSNAME);
119:                            ctxt = container.getSPI(contextClass);
120:                        } catch (ClassNotFoundException e) {
121:                            //log here at FINE Level : that the ServletContext was not found
122:                        }
123:                    }
124:                    String serverName = "server";
125:                    if (ctxt != null) {
126:                        String serverConfig = "/WEB-INF/" + serverName + "_"
127:                                + "security_config.xml";
128:                        URL url = SecurityUtil.loadFromContext(serverConfig,
129:                                ctxt);
130:
131:                        if (url == null) {
132:                            serverConfig = "/WEB-INF/" + serviceLocalName + "_"
133:                                    + "security_config.xml";
134:                            url = SecurityUtil.loadFromContext(serverConfig,
135:                                    ctxt);
136:                        }
137:
138:                        if (url != null) {
139:                            return true;
140:                        }
141:                    } else {
142:                        //this could be an EJB or JDK6 endpoint
143:                        //so let us try to locate the config from META-INF classpath
144:                        String serverConfig = "META-INF/" + serverName + "_"
145:                                + "security_config.xml";
146:                        URL url = SecurityUtil.loadFromClasspath(serverConfig);
147:                        if (url == null) {
148:                            serverConfig = "META-INF/" + serviceLocalName + "_"
149:                                    + "security_config.xml";
150:                            url = SecurityUtil.loadFromClasspath(serverConfig);
151:                        }
152:
153:                        if (url != null) {
154:                            return true;
155:                        }
156:                    }
157:                    return false;
158:                }
159:
160:                private static Pipe initializeXWSSClientPipe(WSDLPort prt,
161:                        WSService svc, WSBinding bnd, Pipe nextP) {
162:                    Pipe ret = new XWSSClientPipe(prt, svc, bnd, nextP);
163:                    return ret;
164:                }
165:
166:                private static Pipe initializeXWSSServerPipe(WSEndpoint epoint,
167:                        WSDLPort prt, Pipe nextP) {
168:                    Pipe ret = new XWSSServerPipe(epoint, prt, nextP);
169:                    return ret;
170:                }
171:            }
172:
173:            public PipelineAssembler doCreate(BindingID bindingID) {
174:                return new XWSSPipelineAssembler(bindingID);
175:            }
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.