001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/tags/2.1/src/org/deegree/ogcwebservices/wass/wss/capabilities/WSSCapabilitiesDocument.java $
002 /*---------------- FILE HEADER ------------------------------------------
003
004 This file is part of deegree.
005 Copyright (C) 2001-2006 by:
006 EXSE, Department of Geography, University of Bonn
007 http://www.giub.uni-bonn.de/exse/
008 lat/lon GmbH
009 http://www.lat-lon.de
010
011 This library is free software; you can redistribute it and/or
012 modify it under the terms of the GNU Lesser General Public
013 License as published by the Free Software Foundation; either
014 version 2.1 of the License, or (at your option) any later version.
015
016 This library is distributed in the hope that it will be useful,
017 but WITHOUT ANY WARRANTY; without even the implied warranty of
018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019 Lesser General Public License for more details.
020
021 You should have received a copy of the GNU Lesser General Public
022 License along with this library; if not, write to the Free Software
023 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024
025 Contact:
026
027 Andreas Poth
028 lat/lon GmbH
029 Aennchenstraße 19
030 53177 Bonn
031 Germany
032 E-Mail: poth@lat-lon.de
033
034 Jens Fitzke
035 lat/lon GmbH
036 Aennchenstraße 19
037 53177 Bonn
038 Germany
039 E-Mail: jens.fitzke@uni-bonn.de
040
041 ---------------------------------------------------------------------------*/
042
043 package org.deegree.ogcwebservices.wass.wss.capabilities;
044
045 import java.io.IOException;
046 import java.net.MalformedURLException;
047 import java.net.URISyntaxException;
048 import java.util.ArrayList;
049
050 import org.deegree.framework.log.ILogger;
051 import org.deegree.framework.log.LoggerFactory;
052 import org.deegree.framework.xml.XMLParsingException;
053 import org.deegree.framework.xml.XMLTools;
054 import org.deegree.i18n.Messages;
055 import org.deegree.ogcbase.CommonNamespaces;
056 import org.deegree.ogcwebservices.getcapabilities.InvalidCapabilitiesException;
057 import org.deegree.ogcwebservices.getcapabilities.OGCCapabilities;
058 import org.deegree.ogcwebservices.getcapabilities.ServiceIdentification;
059 import org.deegree.ogcwebservices.getcapabilities.ServiceProvider;
060 import org.deegree.ogcwebservices.wass.common.OWSCapabilitiesBaseDocument_1_0;
061 import org.deegree.ogcwebservices.wass.common.OperationsMetadata_1_0;
062 import org.deegree.ogcwebservices.wass.common.SupportedAuthenticationMethod;
063 import org.w3c.dom.Element;
064 import org.xml.sax.SAXException;
065
066 /**
067 * A <code>WSSCapabilitiesDocument</code> class can parse xml-based requests. The gdi-nrw access
068 * control specification 1.0 defines xml-elements of type owscommon 1.0 hence this class base class
069 * is OWSCapabilitiesBaseDocument_1_0. For creating an empty response document a
070 * XML-Response-Template is located under WSSCapablitiesTemplate.xml .
071 *
072 * @author <a href="mailto:bezema@lat-lon.de">Rutger Bezema</a>
073 * @author last edited by: $Author: aschmitz $
074 *
075 * @version 2.0, $Revision: 7341 $, $Date: 2007-05-29 14:03:14 +0200 (Di, 29 Mai 2007) $
076 *
077 * @since 2.0
078 */
079
080 public class WSSCapabilitiesDocument extends OWSCapabilitiesBaseDocument_1_0 {
081
082 private static final long serialVersionUID = 4456377564478064784L;
083
084 /**
085 * The logger enhances the quality and simplicity of Debugging within the deegree2 framework
086 */
087 private static final ILogger LOG = LoggerFactory.getLogger( WSSCapabilitiesDocument.class );
088
089 /**
090 * This is the XML template used for the GetCapabilities response document.
091 */
092 public static final String XML_TEMPLATE = "WSSCapabilitiesTemplate.xml";
093
094 private static String PRE = CommonNamespaces.GDINRWWSS_PREFIX + ":";
095
096 /*
097 * (non-Javadoc)
098 *
099 * @see org.deegree.ogcwebservices.getcapabilities.OGCCapabilitiesDocument#parseCapabilities()
100 */
101 @Override
102 public OGCCapabilities parseCapabilities()
103 throws InvalidCapabilitiesException {
104
105 WSSCapabilities wssCapabilities = null;
106 try {
107
108 ServiceIdentification sf = parseServiceIdentification();
109 ServiceProvider sp = parseServiceProvider();
110 OperationsMetadata_1_0 om = parseOperationsMetadata();
111 String version = parseVersion();
112 String updateSequence = parseUpdateSequence();
113
114 ArrayList<SupportedAuthenticationMethod> am = parseSupportedAuthenticationMethods( CommonNamespaces.GDINRWWSS_PREFIX );
115
116 String securedServiceType = parseSecuredServiceType();
117
118 wssCapabilities = new WSSCapabilities( version, updateSequence, sf, sp, om, securedServiceType, am );
119
120 } catch ( XMLParsingException e ) {
121 LOG.logError( e.getLocalizedMessage(), e );
122 throw new InvalidCapabilitiesException( Messages.getMessage( "WASS_ERROR_CAPABILITIES_NOT_PARSED", "WSS" ) );
123 } catch ( URISyntaxException e ) {
124 LOG.logError( e.getLocalizedMessage(), e );
125 throw new InvalidCapabilitiesException( Messages.getMessage( "WASS_ERROR_URI_NOT_READ",
126 new Object[] { "WSS", "(unknown)" } ) );
127 } catch ( MalformedURLException e ) {
128 LOG.logError( e.getLocalizedMessage(), e );
129 throw new InvalidCapabilitiesException( Messages.getMessage( "WASS_ERROR_URL_NOT_READ",
130 new Object[] { "WSS", "(unknown)" } ) );
131 }
132
133 return wssCapabilities;
134 }
135
136 /**
137 * @return the secured service as String
138 * @throws XMLParsingException
139 */
140 public String parseSecuredServiceType()
141 throws XMLParsingException {
142 Element capability = (Element) XMLTools.getRequiredNode( getRootElement(), PRE + "Capability", nsContext );
143 return XMLTools.getRequiredNodeAsString( capability, PRE + "SecuredServiceType", nsContext );
144 }
145
146 /**
147 * @throws SAXException
148 * @throws IOException
149 *
150 */
151 public void createEmptyDocument()
152 throws IOException, SAXException {
153 super.createEmptyDocument( XML_TEMPLATE );
154 }
155
156 }
157
158 /***************************************************************************************************
159 * Changes to this class. What the people have been up to: $Log$ Changes to this class. What the
160 * people have been up to: Revision 1.11 2006/11/27 09:07:53 poth Changes to this class. What the
161 * people have been up to: JNI integration of proj4 has been removed. The CRS functionality now will
162 * be done by native deegree code. Changes to this class. What the people have been up to: Changes
163 * to this class. What the people have been up to: Revision 1.10 2006/08/24 06:42:17 poth Changes to
164 * this class. What the people have been up to: File header corrected Changes to this class. What
165 * the people have been up to: Changes to this class. What the people have been up to: Revision 1.9
166 * 2006/06/27 13:10:47 bezema Changes to this class. What the people have been up to: Finished the
167 * last bits of the configuration of the wass. Changes to this class. What the people have been up
168 * to: Changes to this class. What the people have been up to: Revision 1.8 2006/06/23 13:53:48
169 * schmitz Changes to this class. What the people have been up to: Externalized all Strings, fixed
170 * up some exceptions and messages, reviewed/fixed some code. Changes to this class. What the people
171 * have been up to: Changes to this class. What the people have been up to: Revision 1.7 2006/06/20
172 * 15:31:04 bezema Changes to this class. What the people have been up to: It looks like the
173 * completion of wss. was needs further checking in a tomcat environment. The Strings must still be
174 * externalized. Logging is done, so is the formatting. Changes to this class. What the people have
175 * been up to: Changes to this class. What the people have been up to: Revision 1.6 2006/06/19
176 * 15:34:04 bezema Changes to this class. What the people have been up to: changed wass to handle
177 * things the right way Changes to this class. What the people have been up to: Changes to this
178 * class. What the people have been up to: Revision 1.5 2006/06/09 12:58:32 schmitz Changes to this
179 * class. What the people have been up to: Set up some tests for WAS/WSS and the URN class. Changes
180 * to this class. What the people have been up to: Commented out some of the deegree param stuff in
181 * order for the Changes to this class. What the people have been up to: tests to run. Changes to
182 * this class. What the people have been up to: Tests have hardcoded URLs in them, so they won't run
183 * just anywhere. Changes to this class. What the people have been up to: Revision 1.4 2006/05/30
184 * 10:12:02 bezema Putting the cvs asci option to -kkv which will update the $revision$ $author$ and
185 * $date$ variables in a cvs commit
186 *
187 * Revision 1.2 2006/05/30 08:44:48 bezema Reararranging the layout (again) to use features of OOP.
188 * The owscommonDocument is the real baseclass now.
189 *
190 * Revision 1.1 2006/05/29 12:00:58 bezema Refactored the security and authentication webservices
191 * into one package WASS (Web Authentication -and- Security Services), also created a common package
192 * and a saml package which could be updated to work in the future.
193 *
194 * Revision 1.2 2006/05/23 15:22:02 bezema Added configuration files to the wss and wss is able to
195 * parse a DoService Request in xml
196 *
197 * Revision 1.1 2006/05/22 15:48:16 bezema Starting the parsing of the xml request in wss
198 *
199 *
200 **************************************************************************************************/