001    //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/tags/2.1/src/org/deegree/ogcwebservices/wass/common/GetSession.java $
002    /*----------------    FILE HEADER  ------------------------------------------
003    
004     This file is part of deegree.
005     Copyright (C) 2001-2004 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     Meckenheimer Allee 176
030     53115 Bonn
031     Germany
032     E-Mail: poth@lat-lon.de
033    
034     Prof. Dr. Klaus Greve
035     Department of Geography
036     University of Bonn
037     Meckenheimer Allee 166
038     53115 Bonn
039     Germany
040     E-Mail: greve@giub.uni-bonn.de
041    
042     ---------------------------------------------------------------------------*/
043    
044    package org.deegree.ogcwebservices.wass.common;
045    
046    import java.util.Map;
047    
048    import org.deegree.framework.log.ILogger;
049    import org.deegree.framework.log.LoggerFactory;
050    import org.deegree.framework.xml.XMLParsingException;
051    import org.deegree.ogcwebservices.OGCWebServiceException;
052    import org.deegree.ogcwebservices.OGCWebServiceRequest;
053    import org.w3c.dom.Element;
054    
055    /**
056     * Encapsulated data: GetSession element
057     * 
058     * Namespace: http://www.gdi-nrw.de/session
059     * 
060     * @author <a href="mailto:bezema@lat-lon.de">Rutger Bezema</a>
061     * @author last edited by: $Author: aschmitz $
062     * 
063     * @version $Revision: 7342 $, $Date: 2007-05-29 14:10:38 +0200 (Di, 29 Mai 2007) $
064     */
065    
066    public class GetSession extends AbstractRequest {
067    
068        private static final long serialVersionUID = 2437405317472796643L;
069    
070        /**
071         * The logger enhances the quality and simplicity of Debugging within the deegree2 framework
072         */
073        private static final ILogger LOG = LoggerFactory.getLogger( GetSession.class );
074    
075        private AuthenticationData authenticationData = null;
076    
077        /**
078         * Constructs new one from the given values.
079         * 
080         * @param id
081         *            the request id
082         * @param service
083         * @param version
084         * @param authenticationData
085         * 
086         */
087        public GetSession( String id, String service, String version, AuthenticationData authenticationData ) {
088            super( id, version, service, "GetSession" );
089            this.authenticationData = authenticationData;
090        }
091    
092        /**
093         * Constructs new one from the given key-value-pairs.
094         * 
095         * @param id
096         *            the request id
097         * @param kvp
098         *            the map
099         * @throws OGCWebServiceException
100         */
101        public GetSession( String id, Map<String, String> kvp ) throws OGCWebServiceException {
102            super( id, kvp );
103            URN method = new URN( kvp.get( "AUTHMETHOD" ) );
104            String cred = kvp.get( "CREDENTIALS" );
105            if ( !method.isWellformedGDINRW() ) {
106                throw new OGCWebServiceException( "WASS_WRONG_AUTHMETHOD" );
107            }
108            if ( cred == null || cred.length() == 0 ) {
109                throw new OGCWebServiceException( "WASS_NO_CREDENTIALS" );
110            }
111            authenticationData = new AuthenticationData( method, cred );
112        }
113    
114        /**
115         * @return Returns the authenticationData.
116         */
117        public AuthenticationData getAuthenticationData() {
118            return authenticationData;
119        }
120    
121        /**
122         * @param id
123         * @param documentElement
124         * @return a new instance of this class
125         * @throws OGCWebServiceException
126         */
127        public static OGCWebServiceRequest create( String id, Element documentElement )
128                                throws OGCWebServiceException {
129            try {
130                return new SessionOperationsDocument().parseGetSession( id, documentElement );
131            } catch ( XMLParsingException e ) {
132                LOG.logError( e.getMessage(), e );
133                throw new OGCWebServiceException( e.getMessage() );
134            }
135        }
136    
137        /**
138         * @param id
139         * @param kvp
140         * @return a new instance of this class
141         * @throws OGCWebServiceException
142         */
143        public static OGCWebServiceRequest create( String id, Map<String, String> kvp )
144                                throws OGCWebServiceException {
145            return new GetSession( id, kvp );
146        }
147    
148    }