From: <jos...@us...> - 2009-12-11 15:16:57
|
Revision: 5617 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=5617&view=rev Author: josegar74 Date: 2009-12-11 15:16:41 +0000 (Fri, 11 Dec 2009) Log Message: ----------- Enabled authToken, changed in Axis2 to use in SOAP Header Modified Paths: -------------- sandbox/3.0.x/geonetwork-domain-ebrim/src/main/java/org/geonetwork/domain/csw202/discovery/GetRecordById.java sandbox/3.0.x/geonetwork-domain-ebrim/src/main/java/org/geonetwork/domain/csw202/discovery/GetRecords.java sandbox/3.0.x/geonetwork-web-ebrim/src/main/java/org/geonetwork/webservices/ebrim/csw202/CSWEBRIMSOAPServiceMessageReceiverInOut.java sandbox/3.0.x/geonetwork-web-ebrim/src/main/java/org/geonetwork/webservices/ebrim/csw202/CswEbrimGETService.java Modified: sandbox/3.0.x/geonetwork-domain-ebrim/src/main/java/org/geonetwork/domain/csw202/discovery/GetRecordById.java =================================================================== --- sandbox/3.0.x/geonetwork-domain-ebrim/src/main/java/org/geonetwork/domain/csw202/discovery/GetRecordById.java 2009-12-11 14:23:20 UTC (rev 5616) +++ sandbox/3.0.x/geonetwork-domain-ebrim/src/main/java/org/geonetwork/domain/csw202/discovery/GetRecordById.java 2009-12-11 15:16:41 UTC (rev 5617) @@ -39,6 +39,8 @@ private String version; + private String authToken; + // // Basic Retrieval Options // @@ -115,6 +117,14 @@ this.elementSetName = elementSetName; } + public String getAuthToken() { + return authToken; + } + + public void setAuthToken(String authToken) { + this.authToken = authToken; + } + /** * For Jixb binding. * @@ -150,6 +160,7 @@ result = prime * result + ((outputSchema == null) ? 0 : outputSchema.hashCode()); result = prime * result + ((version == null) ? 0 : version.hashCode()); result = prime * result + ((service == null) ? 0 : service.hashCode()); + result = prime * result + ((authToken == null) ? 0 : authToken.hashCode()); return result; } @@ -208,6 +219,14 @@ } else if (!service .equals(other.service)) return false; + + if (authToken == null) { + if (other.authToken != null) + return false; + } else if (!authToken + .equals(other.authToken)) + return false; + return true; } } Modified: sandbox/3.0.x/geonetwork-domain-ebrim/src/main/java/org/geonetwork/domain/csw202/discovery/GetRecords.java =================================================================== --- sandbox/3.0.x/geonetwork-domain-ebrim/src/main/java/org/geonetwork/domain/csw202/discovery/GetRecords.java 2009-12-11 14:23:20 UTC (rev 5616) +++ sandbox/3.0.x/geonetwork-domain-ebrim/src/main/java/org/geonetwork/domain/csw202/discovery/GetRecords.java 2009-12-11 15:16:41 UTC (rev 5617) @@ -34,6 +34,8 @@ private List<String> namespace; + private String authToken; + // // Namespace // @@ -65,6 +67,15 @@ this.version = version; } + public String getAuthToken() { + return authToken; + } + + public void setAuthToken(String authToken) { + this.authToken = authToken; + } + + /** * the media type of the response message */ @@ -259,7 +270,8 @@ result = prime * result + ((storedQuery == null) ? 0 : storedQuery.hashCode()); result = prime * result + ((version == null) ? 0 : version.hashCode()); - return result; + result = prime * result + ((authToken == null) ? 0 : authToken.hashCode()); + return result; } @Override @@ -336,6 +348,11 @@ return false; } else if (!version.equals(other.version)) return false; + if (authToken == null) { + if (other.authToken != null) + return false; + } else if (!authToken.equals(other.authToken)) + return false; return true; } Modified: sandbox/3.0.x/geonetwork-web-ebrim/src/main/java/org/geonetwork/webservices/ebrim/csw202/CSWEBRIMSOAPServiceMessageReceiverInOut.java =================================================================== --- sandbox/3.0.x/geonetwork-web-ebrim/src/main/java/org/geonetwork/webservices/ebrim/csw202/CSWEBRIMSOAPServiceMessageReceiverInOut.java 2009-12-11 14:23:20 UTC (rev 5616) +++ sandbox/3.0.x/geonetwork-web-ebrim/src/main/java/org/geonetwork/webservices/ebrim/csw202/CSWEBRIMSOAPServiceMessageReceiverInOut.java 2009-12-11 15:16:41 UTC (rev 5617) @@ -9,11 +9,14 @@ import org.apache.log4j.Logger; import org.apache.axis2.AxisFault; import org.apache.axiom.soap.*; +import org.apache.axiom.om.OMNode; +import org.apache.axiom.om.impl.llom.OMElementImpl; import org.geonetwork.domain.csw202.exception.ExceptionReport; import org.geonetwork.services.ebrim.csw202.CSW202ExceptionReportGenerator; import java.lang.Exception; +import java.util.Iterator; /** @@ -33,6 +36,7 @@ // get the implementation class for the Web Service Object obj = getTheImplementationObject(msgContext); + String authToken = retrieveAuthToken(msgContext.getEnvelope().getHeader()); CSWEBRIMSOAPServiceSkeleton skel = (CSWEBRIMSOAPServiceSkeleton) obj; // Out Envelop @@ -55,6 +59,7 @@ org.geonetwork.domain.csw202.discovery.GetRepositoryItem.class, getEnvelopeNamespaces(msgContext.getEnvelope())); + //if (authToken != null) wrappedParam.setAuthToken(authToken); GetRepositoryItemResponse = skel.GetRepositoryItem(wrappedParam); @@ -68,6 +73,7 @@ org.geonetwork.domain.csw202.discovery.GetRecords.class, getEnvelopeNamespaces(msgContext .getEnvelope())); + if (authToken != null) wrappedParam.setAuthToken(authToken); GetRecordsResponse = skel.GetRecords(wrappedParam); @@ -94,6 +100,7 @@ org.geonetwork.domain.csw202.discovery.GetRecordById.class, getEnvelopeNamespaces(msgContext.getEnvelope())); + if (authToken != null) wrappedParam.setAuthToken(authToken); GetRecordByIdResponse = skel.GetRecordById(wrappedParam); @@ -159,7 +166,7 @@ newMsgContext.setEnvelope(envelope); } - + } catch (java.lang.Exception e) { log.error("CSWEBRIMSOAPServiceMessageReceiverInOut", e); // document: OGC 07-110r2: 7.9.2 Fault handling @@ -631,4 +638,47 @@ return f; } + /** + * Retrieves authToken from SOAP Header (if present) + * + * <wsse:Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" + * xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" + * xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" + * xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" + * xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + * xsi:schemaLocation="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd + * http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> + * + * <authToken xmlns="http://geonetwork.org/gaap/services/AuthenticationService">XXXXXXXXXXXXXXXXXX</authToken> + * + * </wsse:Security> + * + * @param header + * @return + */ + private String retrieveAuthToken(SOAPHeader header) { + String authToken = null; + + if (header != null) { + Iterator it = header.examineAllHeaderBlocks(); + + while (it.hasNext()) { + SOAPHeaderBlock n = (SOAPHeaderBlock) it.next(); + + Iterator it2 = n.getChildrenWithLocalName("authToken"); + while (it2.hasNext()) { + OMNode n1 = (OMNode) it2.next(); + if (n1 instanceof OMElementImpl) { + OMElementImpl el = (OMElementImpl) n1; + if (el.getLocalName() == "authToken") { + authToken = el.getText(); + } + } + } + + } + } + + return authToken; + } }// end of class Modified: sandbox/3.0.x/geonetwork-web-ebrim/src/main/java/org/geonetwork/webservices/ebrim/csw202/CswEbrimGETService.java =================================================================== --- sandbox/3.0.x/geonetwork-web-ebrim/src/main/java/org/geonetwork/webservices/ebrim/csw202/CswEbrimGETService.java 2009-12-11 14:23:20 UTC (rev 5616) +++ sandbox/3.0.x/geonetwork-web-ebrim/src/main/java/org/geonetwork/webservices/ebrim/csw202/CswEbrimGETService.java 2009-12-11 15:16:41 UTC (rev 5617) @@ -346,8 +346,8 @@ // // authToken: custom extension for security validation // - //String authToken = RequestUtil.getParameter(request, AUTH_TOKEN); - //getRecords.setAuthToken(authToken); + String authToken = RequestUtil.getParameter(request, AUTH_TOKEN); + getRecords.setAuthToken(authToken); // // namespace @@ -674,8 +674,8 @@ // // authToken: custom extension for security validation // - //String authToken = RequestUtil.getParameter(request, AUTH_TOKEN); - //getRecordById.setAuthToken(authToken); + String authToken = RequestUtil.getParameter(request, AUTH_TOKEN); + getRecordById.setAuthToken(authToken); // // ElementSetName This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |