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


001:        /*
002:         * The contents of this file are subject to the terms
003:         * of the Common Development and Distribution License
004:         * (the License).  You may not use this file except in
005:         * compliance with the License.
006:         *
007:         * You can obtain a copy of the license at
008:         * https://glassfish.dev.java.net/public/CDDLv1.0.html.
009:         * See the License for the specific language governing
010:         * permissions and limitations under the License.
011:         *
012:         * When distributing Covered Code, include this CDDL
013:         * Header Notice in each file and include the License file
014:         * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
015:         * If applicable, add the following below the CDDL Header,
016:         * with the fields enclosed by brackets [] replaced by
017:         * you own identifying information:
018:         * "Portions Copyrighted [year] [name of copyright owner]"
019:         *
020:         * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
021:         */
022:
023:        package com.sun.xml.ws.security.opt.impl.incoming;
024:
025:        import com.sun.xml.stream.buffer.XMLStreamBuffer;
026:        import com.sun.xml.ws.security.opt.api.NamespaceContextInfo;
027:        import com.sun.xml.ws.security.opt.api.PolicyBuilder;
028:        import com.sun.xml.ws.security.opt.api.SecurityElementWriter;
029:        import com.sun.xml.ws.security.opt.api.SecurityHeaderElement;
030:        import com.sun.xml.ws.security.opt.api.TokenValidator;
031:        import com.sun.xml.wss.ProcessingContext;
032:        import com.sun.xml.wss.XWSSecurityException;
033:        import com.sun.xml.wss.impl.MessageConstants;
034:        import com.sun.xml.wss.impl.policy.mls.SignatureConfirmationPolicy;
035:        import com.sun.xml.wss.impl.policy.mls.WSSPolicy;
036:        import java.io.OutputStream;
037:        import java.util.ArrayList;
038:        import java.util.List;
039:        import javax.xml.stream.XMLStreamReader;
040:        import com.sun.xml.stream.buffer.stax.StreamReaderBufferCreator;
041:        import javax.xml.stream.XMLInputFactory;
042:        import com.sun.xml.ws.security.opt.impl.util.XMLStreamReaderFactory;
043:        import javax.xml.stream.XMLStreamException;
044:        import java.util.HashMap;
045:        import javax.xml.stream.StreamFilter;
046:        import com.sun.xml.stream.buffer.XMLStreamBufferMark;
047:        import java.util.logging.Level;
048:        import java.util.logging.Logger;
049:        import com.sun.xml.wss.logging.LogDomainConstants;
050:
051:        /**
052:         *
053:         * @author Ashutosh.Shahi@sun.com
054:         */
055:        public class SignatureConfirmation implements  SecurityHeaderElement,
056:                TokenValidator, PolicyBuilder, NamespaceContextInfo,
057:                SecurityElementWriter {
058:
059:            protected static final Logger log = Logger.getLogger(
060:                    LogDomainConstants.FILTER_DOMAIN,
061:                    LogDomainConstants.FILTER_DOMAIN_BUNDLE);
062:
063:            private String id = "";
064:            private String namespaceURI = "";
065:            private String localName = "";
066:            private String signatureValue = null;
067:
068:            private SignatureConfirmationPolicy scPolicy = null;
069:            private HashMap<String, String> nsDecls;
070:            private XMLStreamBuffer mark = null;
071:
072:            /**
073:             * Creates a new instance of SignatureConfirmation
074:             */
075:            public SignatureConfirmation(XMLStreamReader reader,
076:                    StreamReaderBufferCreator creator, HashMap nsDecls,
077:                    XMLInputFactory staxIF) throws XMLStreamException {
078:
079:                namespaceURI = reader.getNamespaceURI();
080:                localName = reader.getLocalName();
081:                id = reader.getAttributeValue(MessageConstants.WSU_NS, "Id");
082:
083:                mark = new XMLStreamBufferMark(nsDecls, creator);
084:                creator.createElementFragment(XMLStreamReaderFactory
085:                        .createFilteredXMLStreamReader(reader,
086:                                new SCProcessor()), false);
087:
088:                this .nsDecls = nsDecls;
089:
090:                scPolicy = new SignatureConfirmationPolicy();
091:                scPolicy.setSignatureValue(signatureValue);
092:            }
093:
094:            public String getSignatureValue() {
095:                return signatureValue;
096:            }
097:
098:            public boolean refersToSecHdrWithId(String id) {
099:                throw new UnsupportedOperationException();
100:            }
101:
102:            public String getId() {
103:                return id;
104:            }
105:
106:            public void setId(String id) {
107:                throw new UnsupportedOperationException();
108:            }
109:
110:            public String getNamespaceURI() {
111:                return namespaceURI;
112:            }
113:
114:            public String getLocalPart() {
115:                return localName;
116:            }
117:
118:            public javax.xml.stream.XMLStreamReader readHeader()
119:                    throws javax.xml.stream.XMLStreamException {
120:                return mark.readAsXMLStreamReader();
121:            }
122:
123:            public void writeTo(OutputStream os) {
124:                throw new UnsupportedOperationException();
125:            }
126:
127:            public void writeTo(javax.xml.stream.XMLStreamWriter streamWriter)
128:                    throws javax.xml.stream.XMLStreamException {
129:                mark.writeToXMLStreamWriter(streamWriter);
130:            }
131:
132:            public void validate(ProcessingContext context)
133:                    throws XWSSecurityException {
134:                Object temp = context
135:                        .getExtraneousProperty("SignatureConfirmation");
136:                List scList = null;
137:                if (temp != null && temp instanceof  ArrayList)
138:                    scList = (ArrayList) temp;
139:                if (scList != null) {
140:                    if (signatureValue == null) {
141:                        if (!scList.isEmpty()) {
142:                            log
143:                                    .log(Level.SEVERE,
144:                                            "Failure in SignatureConfirmation Validation");
145:                            throw new XWSSecurityException(
146:                                    "Failure in SignatureConfirmation Validation");
147:                        }
148:                    } else if (scList.contains(signatureValue)) {// match the Value in received message
149:                        //with the stored value
150:                        scList.remove(signatureValue);
151:                    } else {
152:                        log.log(Level.SEVERE,
153:                                "Failure in SignatureConfirmation Validation");
154:                        throw new XWSSecurityException(
155:                                "Mismatch in SignatureConfirmation Element");
156:                    }
157:                }
158:            }
159:
160:            public WSSPolicy getPolicy() {
161:                return scPolicy;
162:            }
163:
164:            public HashMap<String, String> getInscopeNSContext() {
165:                return nsDecls;
166:            }
167:
168:            public void writeTo(javax.xml.stream.XMLStreamWriter streamWriter,
169:                    HashMap props) throws javax.xml.stream.XMLStreamException {
170:                throw new UnsupportedOperationException();
171:            }
172:
173:            class SCProcessor implements  StreamFilter {
174:                boolean elementRead = false;
175:
176:                public boolean accept(XMLStreamReader reader) {
177:                    if (reader.getEventType() == XMLStreamReader.END_ELEMENT) {
178:                        if (reader.getLocalName() == localName
179:                                && reader.getNamespaceURI() == namespaceURI) {
180:                            elementRead = true;
181:                        }
182:                    }
183:                    if (!elementRead
184:                            && reader.getEventType() == XMLStreamReader.START_ELEMENT) {
185:                        signatureValue = reader
186:                                .getAttributeValue(null, "Value");
187:                    }
188:                    return true;
189:                }
190:            }
191:
192:        }
w__w_w__._j__a_v__a2s__._c_o_m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.