perfsonar-dev - perfsonar: r2661 - in trunk/perfsonar/src/org/perfsonar: commons/auxiliary/components/authn/wssec service/commons/authn
Subject: perfsonar development work
List archive
perfsonar: r2661 - in trunk/perfsonar/src/org/perfsonar: commons/auxiliary/components/authn/wssec service/commons/authn
Chronological Thread
- From:
- To:
- Subject: perfsonar: r2661 - in trunk/perfsonar/src/org/perfsonar: commons/auxiliary/components/authn/wssec service/commons/authn
- Date: Thu, 16 Aug 2007 03:58:56 -0400
Author: rodriguez
Date: 2007-08-16 03:58:55 -0400 (Thu, 16 Aug 2007)
New Revision: 2661
Modified:
trunk/perfsonar/src/org/perfsonar/commons/auxiliary/components/authn/wssec/WSSecAuthNComponent.java
trunk/perfsonar/src/org/perfsonar/service/commons/authn/AADispatchSOAPProtocol.java
trunk/perfsonar/src/org/perfsonar/service/commons/authn/AuthNRequest.java
Log:
Adding more debug messages
Modified:
trunk/perfsonar/src/org/perfsonar/commons/auxiliary/components/authn/wssec/WSSecAuthNComponent.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/commons/auxiliary/components/authn/wssec/WSSecAuthNComponent.java
2007-08-15 15:00:15 UTC (rev 2660)
+++
trunk/perfsonar/src/org/perfsonar/commons/auxiliary/components/authn/wssec/WSSecAuthNComponent.java
2007-08-16 07:58:55 UTC (rev 2661)
@@ -9,6 +9,7 @@
import org.perfsonar.commons.auxiliary.ComponentNames;
import org.perfsonar.commons.auxiliary.components.authn.AuthNComponent;
import
org.perfsonar.commons.auxiliary.components.configuration.ConfigurationComponent;
+import org.perfsonar.commons.auxiliary.components.logger.LoggerComponent;
import org.perfsonar.service.commons.authn.AADispatchManager;
import org.perfsonar.service.commons.authn.AADispatchProtocolFactory;
import org.perfsonar.service.commons.authn.AuthNRequest;
@@ -19,6 +20,7 @@
public class WSSecAuthNComponent implements AuthNComponent,
AuxiliaryComponent {
private String componentName = null;
+ private LoggerComponent logger;
private ConfigurationComponent configuration;
private boolean checkAuthN;
private Set<String> messageTypes;
@@ -33,8 +35,20 @@
}
public void initComponent() throws PerfSONARException {
- configuration = (ConfigurationComponent)AuxiliaryComponentManager.
- getInstance().getComponent(ComponentNames.CONFIG);
+ try {
+ logger = (LoggerComponent)
AuxiliaryComponentManager.getInstance()
+ .getComponent(ComponentNames.LOGGER);
+ } catch (PerfSONARException e) {
+ String m = "WSSecAuthNComponent: Can't obtain Logger
component ";
+ throw new PerfSONARException(m);
+ }
+ try {
+ configuration =
(ConfigurationComponent)AuxiliaryComponentManager.
+ getInstance().getComponent(ComponentNames.CONFIG);
+ } catch (PerfSONARException e) {
+ String m = "WSSecAuthNComponent: Can't obtain
Configuration component ";
+ throw new PerfSONARException(m);
+ }
try {
String
checkAuthNParam=configuration.getProperty(AuthNComponent.CHECK_AUTHN_PARAM);
if (checkAuthNParam.equals(AuthNComponent.YES_CHECK_AUTHN)) {
@@ -62,21 +76,18 @@
public void requestAuthN(String messageType) throws
PerfSONARException {
if (isRequiredAuthN()) {
if (messageTypes.contains(messageType)) {
- try {
- SecurityToken st=new
SecurityToken(SecTokenManagerFactory.getDefaultSecTokenManager());
- if (!st.hasSecTokenInRequest()) {
- throw new
PerfSONARException("error.authn.not_sectoken","WSSecAuthNComponent: It has
not sent any Security Token");
- }
- st.setSecTokenFromRequest();
- AuthNRequest authnReq=new
AuthNRequest(st);
- AADispatchManager aadm=new
AADispatchManager(AADispatchProtocolFactory.getDefaultAADispatchProtocol());
- AuthNResponse
authnRes=aadm.getAuthentication(authnReq);
- if
(authnRes.getStatus()!=AuthNResponse.AUTHENTICATED) {
- throw new
PerfSONARException(authnRes.getResultCode(),"Authentication failed");
- }
- } catch (PerfSONARException e) {
- throw new
PerfSONARException(e.getResultCode(),e.getResultDescription());
+ SecurityToken st=new
SecurityToken(SecTokenManagerFactory.getDefaultSecTokenManager());
+ if (!st.hasSecTokenInRequest()) {
+ throw new
PerfSONARException("error.authn.not_sectoken","WSSecAuthNComponent: It has
not sent any Security Token");
}
+ st.setSecTokenFromRequest();
+ AuthNRequest authnReq=new AuthNRequest(st);
+ AADispatchManager aadm=new
AADispatchManager(AADispatchProtocolFactory.getDefaultAADispatchProtocol());
+ AuthNResponse
authnRes=aadm.getAuthentication(authnReq);
+ if
(authnRes.getStatus()!=AuthNResponse.AUTHENTICATED) {
+ logger.debug("WSSecAuthNComponent:
Authentication failed ("+authnRes.getResultCode()+")");
+ throw new
PerfSONARException(authnRes.getResultCode(),"Authentication failed");
+ }
}
}
}
Modified:
trunk/perfsonar/src/org/perfsonar/service/commons/authn/AADispatchSOAPProtocol.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/commons/authn/AADispatchSOAPProtocol.java
2007-08-15 15:00:15 UTC (rev 2660)
+++
trunk/perfsonar/src/org/perfsonar/service/commons/authn/AADispatchSOAPProtocol.java
2007-08-16 07:58:55 UTC (rev 2661)
@@ -15,8 +15,6 @@
import org.apache.axis.message.SOAPBodyElement;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.utils.XMLUtils;
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.XMLSerializer;
import org.ggf.ns.nmwg.base.v2_0.Message;
import org.perfsonar.commons.auxiliary.AuxiliaryComponentManager;
import org.perfsonar.commons.auxiliary.ComponentNames;
@@ -24,8 +22,12 @@
import org.perfsonar.commons.auxiliary.components.logger.LoggerComponent;
import org.perfsonar.service.commons.exceptions.PerfSONARException;
import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
public class AADispatchSOAPProtocol implements AADispatchProtocol {
+ public static final String
WSS_X509="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3";
+ public static final String
WSS_SAML="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1";
private final String AS_POINT_PARAM = "service.as.point";
private final String FILE_AUTHN_PARAM = "service.as.authnRequest";
private final String SAX_PARSER_CONFIG = "service.sax_parser.config";
@@ -93,6 +95,13 @@
DocumentBuilder builder =
factory.newDocumentBuilder();
request = builder.parse(new File(fileAuthnRequest));
+
+ // get the parameter which specifies the format of
the security token
+ Element parameter=null;
+ NodeList nodelist =
org.apache.xpath.XPathAPI.selectNodeList(request,
"//nmwg:parameter[@name='SecurityToken']");
+ if (nodelist.getLength()>0) {
+ parameter=(Element)nodelist.item(0);
+ }
// build a SOAPBodyElement from the document
SOAPBodyElement requestMessage =
@@ -103,6 +112,13 @@
Iterator it=header.examineAllHeaderElements();
while (it.hasNext()) {
SOAPHeaderElement
he=(SOAPHeaderElement)it.next();
+
+ // if there is any assertion, it should be a
saml security token
+ NodeList nodelist2 =
org.apache.xpath.XPathAPI.selectNodeList(he, "//Assertion");
+ if (parameter!=null&&nodelist2.getLength()>0) {
+
parameter.setTextContent(AADispatchSOAPProtocol.WSS_SAML);
+ }
+
envelope.getHeader().addChildElement(he);
}
@@ -123,24 +139,11 @@
// can be checked..
result = resultSBE.getAsDocument();
- // output it to a string
- outWriter = new StringWriter();
-
- OutputFormat format = new OutputFormat( result );
- format.setIndent(4);
- format.setIndenting(true);
- format.setLineSeparator("\n");
-
- XMLSerializer serial = new XMLSerializer(outWriter,
format );
- serial.asDOMSerializer();
- serial.serialize( result.getDocumentElement() );
-
- outWriter.close();
-
Message responseNmwg =
org.perfsonar.commons.util.XMLUtils.convertToMessage(
result, saxParser);
resp=AuthNResponse.getAuthNResponse(responseNmwg);
+ logger.debug("Authentication response:
("+resp.getResultCode()+","+resp.getStatus()+")");
} catch (ClassCastException e) {
e.printStackTrace();
Modified:
trunk/perfsonar/src/org/perfsonar/service/commons/authn/AuthNRequest.java
===================================================================
--- trunk/perfsonar/src/org/perfsonar/service/commons/authn/AuthNRequest.java
2007-08-15 15:00:15 UTC (rev 2660)
+++ trunk/perfsonar/src/org/perfsonar/service/commons/authn/AuthNRequest.java
2007-08-16 07:58:55 UTC (rev 2661)
@@ -6,12 +6,9 @@
public class AuthNRequest {
private SecurityToken st;
- private Message message;
public AuthNRequest() {
st=null;
- message=new Message();
- message.setType(ActionType.AUTHN_CLIENT);
}
public AuthNRequest(SecurityToken st) {
@@ -27,12 +24,4 @@
this.st = st;
}
- public Message getMessage() {
- return message;
- }
-
- public void setMessage(Message message) {
- this.message = message;
- }
-
}
- perfsonar: r2661 - in trunk/perfsonar/src/org/perfsonar: commons/auxiliary/components/authn/wssec service/commons/authn, svnlog, 08/16/2007
Archive powered by MHonArc 2.6.16.