Skip to Content.
Sympa Menu

perfsonar-dev - [pS-dev] [GEANT/SA2/ps-java-services] r6037 - in trunk/perfsonar_base: . src/main/java/org/perfsonar/client/base/authn src/main/java/org/perfsonar/client/testHarness

Subject: perfsonar development work

List archive

[pS-dev] [GEANT/SA2/ps-java-services] r6037 - in trunk/perfsonar_base: . src/main/java/org/perfsonar/client/base/authn src/main/java/org/perfsonar/client/testHarness


Chronological Thread 
  • From:
  • To:
  • Subject: [pS-dev] [GEANT/SA2/ps-java-services] r6037 - in trunk/perfsonar_base: . src/main/java/org/perfsonar/client/base/authn src/main/java/org/perfsonar/client/testHarness
  • Date: Tue, 27 Nov 2012 11:15:25 +0000 (GMT)

Author: nordunet.behrmann
Date: 2012-11-27 11:15:25 +0000 (Tue, 27 Nov 2012)
New Revision: 6037

Removed:
trunk/perfsonar_base/src/main/java/org/perfsonar/client/base/authn/saslca/

trunk/perfsonar_base/src/main/java/org/perfsonar/client/testHarness/SOAPUbCClient.java

trunk/perfsonar_base/src/main/java/org/perfsonar/client/testHarness/UbCSaslTest.java
Modified:
trunk/perfsonar_base/pom.xml
Log:
perfsonar_base: Update dependencies

jar-repository was deleted in a recent cleanup of SVN. perfsonar_base failed
to compile after this since external dependencies were missing.

This patch updates repository references and the dependencies. Some have
been uploaded to the Geant Artifactory, but most dependencies are pulled in
from other sources.

The SASL client has been deleted. It did not appear to be used and deleting
the code allowed us to drop a number of dependencies.

The maven group id and artifact id of perfsonar_base has been adjusted to
follow Geant best-pratice.



Modified: trunk/perfsonar_base/pom.xml
===================================================================
--- trunk/perfsonar_base/pom.xml 2012-11-26 14:41:24 UTC (rev 6036)
+++ trunk/perfsonar_base/pom.xml 2012-11-27 11:15:25 UTC (rev 6037)
@@ -2,11 +2,11 @@
<project xmlns="http://maven.apache.org/POM/4.0.0";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd";>
<modelVersion>4.0.0</modelVersion>
- <groupId>perfsonar</groupId>
- <artifactId>perfsonar-base</artifactId>
+ <groupId>net.geant2.perfsonar</groupId>
+ <artifactId>perfsonar_base</artifactId>
<packaging>jar</packaging>
<name>Perfsonar Base package</name>
- <version>1.1.0</version>
+ <version>1.1.1</version>
<description>
The perfSONAR base provides a number of common, shared classes which
can be used by
MA, MP and Clients.
@@ -67,30 +67,56 @@
<url>http://repository.codehaus.org</url>
</repository>
<repository>
- <id>shibboleth</id>
+ <id>shibboleth.internet2.edu</id>
<name>shibboleth repository</name>

<url>https://build.shibboleth.net/nexus/content/repositories/releases/</url>
</repository>
+ <repository>
+ <id>shibboleth-3rd-party</id>
+ <name>shibboleth 3rd party</name>
+
<url>https://build.shibboleth.net/nexus/content/repositories/thirdparty/</url>
+ </repository>
<repository>
- <id>personar</id>
- <name>personar repository</name>
-
<url>http://svn.geant.net/GEANT/SA2/ps-java-services/trunk/jar-repository</url>
- </repository>
- <repository>
<id>geant-repository</id>
<name>perfSONAR repository</name>
- <url>https://artifactory.geant.net/artifactory/geant-repo/</url>
+ <url>https://artifactory.geant.net/artifactory/repo/</url>
</repository>
+ <repository>
+ <id>geant-repository-3rd-party</id>
+ <name>GEANT repository</name>
+
<url>https://artifactory.geant.net/artifactory/geant-repo/net/geant/3rdparty/</url>
+ </repository>
</repositories>

+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.opensaml</groupId>
+ <artifactId>xmltooling</artifactId>
+ <version>1.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl104-over-slf4j</artifactId>
+ <version>1.5.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>1.5.2</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
<dependencies>
<dependency>
- <groupId>nmwg</groupId>
+ <groupId>net.geant2.perfsonar</groupId>
<artifactId>nmwg</artifactId>
<version>1.0.20090304</version>
</dependency>
<dependency>
- <groupId>perfsonar</groupId>
+ <groupId>net.geant2.perfsonar</groupId>
<artifactId>perfsonar-authr</artifactId>
<version>0.5</version>
</dependency>
@@ -121,19 +147,14 @@
<version>1.5.1</version>
</dependency>
<dependency>
- <groupId>xerces</groupId>
+ <groupId>org.apache.xerces</groupId>
<artifactId>xercesImpl</artifactId>
- <version>2.8.0</version>
+ <version>2.9.1</version>
</dependency>
<dependency>
- <groupId>xerces</groupId>
- <artifactId>xerces-xml-apis</artifactId>
- <version>2.8.0</version>
- </dependency>
- <dependency>
- <groupId>xml-apis</groupId>
+ <groupId>org.apache.xerces</groupId>
<artifactId>xml-apis</artifactId>
- <version>1.3.02</version>
+ <version>2.9.1</version>
</dependency>
<dependency>
<groupId>jdom</groupId>
@@ -152,20 +173,36 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>xalan</groupId>
+ <groupId>org.apache.xalan</groupId>
<artifactId>xalan</artifactId>
- <version>2.7.0</version>
+ <version>2.7.1</version>
</dependency>

<dependency>
<groupId>commons-discovery</groupId>
<artifactId>commons-discovery</artifactId>
<version>0.2</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
<version>1.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
@@ -176,62 +213,78 @@
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.7.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>commons-digester</groupId>
<artifactId>commons-digester</artifactId>
<version>1.7</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.0.4</version>
- </dependency>

<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
- <version>1.0.2</version>
+ <version>1.1.1</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
- <version>1.3.2</version>
+ <version>1.4.5</version>
</dependency>

<dependency>
- <groupId>tomcat</groupId>
+ <groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
- <version>5.0.28</version>
- <scope>provided</scope>
+ <version>2.5</version>
</dependency>

<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
- <version>1.2.9</version>
+ <version>1.2.17</version>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.5.2</version>
+ </dependency>

<dependency>
- <groupId>exist</groupId>
- <artifactId>exist-xmldb</artifactId>
- <version>1.0rc</version>
+ <groupId>xmldb</groupId>
+ <artifactId>xmldb-api</artifactId>
+ <version>exist-1.2.6</version>
</dependency>
<dependency>
<groupId>exist</groupId>
- <artifactId>exist-db</artifactId>
- <version>1.0rc</version>
+ <artifactId>exist</artifactId>
+ <version>1.2.6</version>
</dependency>
- <dependency>
- <groupId>exist</groupId>
- <artifactId>exist-xmlrpc</artifactId>
- <version>1.0rc</version>
- </dependency>
- <dependency>
- <groupId>exist</groupId>
- <artifactId>exist-optional</artifactId>
- <version>1.0rc</version>
- </dependency>
+ <dependency>
+ <artifactId>xmlrpc-client</artifactId>
+ <groupId>org.apache.xmlrpc</groupId>
+ <version>3.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>

<dependency>
<groupId>antlr</groupId>
@@ -240,14 +293,14 @@
</dependency>

<dependency>
- <groupId>xml-security</groupId>
- <artifactId>xmlsec</artifactId>
- <version>1.3.0</version>
+ <groupId>org.apache.xml.security</groupId>
+ <artifactId>xml-security</artifactId>
+ <version>1.4.1</version>
</dependency>
<dependency>
- <groupId>bouncycastle</groupId>
+ <groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15</artifactId>
- <version>124</version>
+ <version>1.40</version>
</dependency>
<dependency>
<groupId>wss4j</groupId>
@@ -255,35 +308,32 @@
<version>1.5.1</version>
</dependency>
<dependency>
- <groupId>javolution</groupId>
- <artifactId>javolution</artifactId>
- <version>3.7</version>
- </dependency>
- <dependency>
- <groupId>opensaml</groupId>
+ <groupId>org.opensaml</groupId>
<artifactId>opensaml</artifactId>
- <version>2.0-TP2-jdk-1.5</version>
+ <version>2.1.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>log4j-over-slf4j</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
- <groupId>xmltooling</groupId>
+ <groupId>org.opensaml</groupId>
<artifactId>xmltooling</artifactId>
- <version>1.0-TP2-jdk-1.5</version>
+ <version>1.1.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>log4j-over-slf4j</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
- <groupId>opensaml</groupId>
+ <groupId>org.opensaml</groupId>
<artifactId>opensaml1</artifactId>
<version>1.1</version>
</dependency>
- <dependency>
- <groupId>sasl-ca</groupId>
- <artifactId>sasl-ca</artifactId>
- <version>1.0</version>
- </dependency>
- <dependency>
- <groupId>codec</groupId>
- <artifactId>codec</artifactId>
- <version>1.0</version>
- </dependency>

<dependency>
<groupId>joda-time</groupId>
@@ -292,7 +342,7 @@
</dependency>

<dependency>
- <groupId>com.ibatis</groupId>
+ <groupId>net.geant2.perfsonar</groupId>
<artifactId>ibatis-common</artifactId>
<version>2.1.7.597</version>
</dependency>
@@ -313,10 +363,24 @@
<version>8.7</version>
</dependency>
<dependency>
- <groupId>edugain</groupId>
+ <groupId>net.geant2.edugain</groupId>
<artifactId>edugain</artifactId>
- <version>1.0-RC2</version>
+ <version>1.0-RC4</version>
<optional>false</optional>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>opensaml</groupId>
+ <artifactId>opensaml</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
</dependencies>
<reporting>

Deleted:
trunk/perfsonar_base/src/main/java/org/perfsonar/client/testHarness/SOAPUbCClient.java
===================================================================
---
trunk/perfsonar_base/src/main/java/org/perfsonar/client/testHarness/SOAPUbCClient.java
2012-11-26 14:41:24 UTC (rev 6036)
+++
trunk/perfsonar_base/src/main/java/org/perfsonar/client/testHarness/SOAPUbCClient.java
2012-11-27 11:15:25 UTC (rev 6037)
@@ -1,229 +0,0 @@
-package org.perfsonar.client.testHarness;
-
-import java.io.File;
-import java.io.StringWriter;
-import java.net.URL;
-import java.security.KeyPair;
-import java.security.KeyStore;
-import java.security.PrivateKey;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateParsingException;
-import java.security.cert.X509Certificate;
-import java.text.DateFormat;
-import java.util.Collection;
-import java.util.List;
-import java.util.Vector;
-
-import javax.xml.namespace.QName;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.apache.axis.client.Call;
-import org.apache.axis.client.Service;
-import org.apache.axis.message.SOAPBodyElement;
-import org.apache.axis.message.SOAPEnvelope;
-import org.apache.ws.security.SOAPConstants;
-import org.apache.ws.security.WSConstants;
-import org.apache.ws.security.WSEncryptionPart;
-import org.apache.ws.security.components.crypto.Crypto;
-import org.apache.ws.security.message.WSSecHeader;
-import org.apache.ws.security.message.WSSecSignature;
-import org.apache.ws.security.message.WSSecTimestamp;
-import org.apache.ws.security.util.WSSecurityUtil;
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.XMLSerializer;
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.perfsonar.base.auxiliary.components.authn.DynamicCrypto;
-import org.perfsonar.base.auxiliary.components.authn.SOAPUtil;
-import org.perfsonar.base.exceptions.PerfSONARException;
-import org.perfsonar.client.base.authn.saslca.SASLCAClient;
-import org.perfsonar.client.base.authn.saslca.SASLCAClientConfiguration;
-import org.perfsonar.client.base.authn.saslca.UserID;
-import org.w3c.dom.Document;
-
-public class SOAPUbCClient
-{
- private UserID userID;
-
- private SASLCAClientConfiguration clientConfig;
-
- private SASLCAClient client;
-
- public void test(String[] args)
- {
- try {
- String saslCAServer;
- String saslCAPort;
- String tsFile;
- String tsPassword;
- String tsType;
- String username;
- String userpassword;
- String endPoint;
- String messageFile;
-
- if (args.length == 9) {
- saslCAServer = args[0];
- saslCAPort = args[1];
- tsFile = args[2];
- tsPassword = args[3];
- tsType = args[4];
- username = args[5];
- userpassword = args[6];
- endPoint = args[7];
- messageFile = args[8];
- } else {
- System.out.println("Error: Wrong number (" + args.length +
"!= 9) of parameters!!!");
- return;
- }
- System.out.println("SASL CA Server: " + saslCAServer);
- System.out.println("SASL CA Port: " + saslCAPort);
- System.out.println("TrustStore File: " + tsFile);
- System.out.println("TrustStore Password: " + tsPassword);
- System.out.println("TrustStore Type: " + tsType);
- System.out.println("Username: " + username);
- System.out.println("Password: " + userpassword);
- System.out.println("End Point: " + endPoint);
- System.out.println("Message file: " + messageFile);
-
- System.setProperty("javax.net.ssl.trustStore", tsFile);
- System.setProperty("javax.net.ssl.trustStorePassword",
tsPassword);
- System.setProperty("javax.net.ssl.trustStoreType", tsType);
-
- userID = new UserID(username, userpassword);
- clientConfig = new SASLCAClientConfiguration(saslCAServer,
Integer.parseInt(saslCAPort), "RSA", 1024,
- "auth-only");
- client = new SASLCAClient(userID, clientConfig);
-
- KeyPair keyPair = client.generateKeyPair();
- checkCertificate(keyPair);
- sendRequest(keyPair, endPoint, messageFile);
- } catch (PerfSONARException e) {
- e.printStackTrace();
- } catch (CertificateParsingException e) {
- e.printStackTrace();
- }
- }
-
- public void checkCertificate(KeyPair keyPair) throws
CertificateParsingException, PerfSONARException
- {
- X509Certificate certificate = client.getCertficate(keyPair);
- System.out.println("Issuer DN: " +
certificate.getIssuerDN().toString());
- System.out.println("Subject DN: " +
certificate.getSubjectDN().toString());
- Collection<List<?>> collection =
certificate.getSubjectAlternativeNames();
- for (List<?> list : collection) {
- for (Object aList : list) {
- if (aList.toString().startsWith("http")) {
- System.out.println("Subject Alternative Name:" +
aList.toString());
- }
- }
- }
- System.out.println("Valid from: " +
DateFormat.getInstance().format(certificate.getNotBefore()));
- System.out.println("Valid until: " +
DateFormat.getInstance().format(certificate.getNotAfter()));
- }
-
- public void sendRequest(KeyPair keyPair, String endPoint, String
messageFile) throws PerfSONARException
- {
- try {
- // prepare to call - set service elements
- Service service = new Service();
- Call call = (Call) service.createCall();
- call.setTargetEndpointAddress(new URL(endPoint));
- call.setOperationName(new QName("http://soapinterop.org/";,
"submit"));
-
- Document request;
- DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
-
- DocumentBuilder builder = factory.newDocumentBuilder();
- request = builder.parse(new File(messageFile));
-
- // build a SOAPBodyElement from the document
- SOAPBodyElement requestMessage = new
SOAPBodyElement(request.getDocumentElement());
- SOAPEnvelope envelope = new SOAPEnvelope();
- envelope.addBodyElement(requestMessage);
-
- // add the security provider
- BouncyCastleProvider bcp = new BouncyCastleProvider();
- java.security.Security.addProvider(bcp);
-
- Crypto crypto = new DynamicCrypto();
- KeyStore ks = crypto.getKeyStore();
-
- Document doc = envelope.getAsDocument();
- WSSecHeader secHeader = new WSSecHeader();
- secHeader.setActor("test");
- secHeader.insertSecurityHeader(doc);
-
- PrivateKey privateKey = keyPair.getPrivate();
- X509Certificate cert = client.getCertficate(keyPair);
- ks.setKeyEntry("xmlsec", privateKey, "security".toCharArray(),
new Certificate[]{cert});
- WSSecSignature sec509 = new WSSecSignature();
- sec509.setUserInfo("xmlsec", "security");
- SOAPConstants soapConstants =
WSSecurityUtil.getSOAPConstants(envelope.getAsDOM());
- Vector<WSEncryptionPart> parts = new Vector<WSEncryptionPart>(1,
1);
-
- // Set up to use STRTransorm to sign the signature token
- WSEncryptionPart encP = new WSEncryptionPart("STRTransform",
soapConstants.getEnvelopeURI(), "Content");
- parts.add(encP);
-
-// Adding timestamp information
- WSSecTimestamp timestamp = new WSSecTimestamp();
- timestamp.setTimeToLive(900);
- timestamp.prepare(doc);
- WSSecurityUtil.prependChildElement(doc,
secHeader.getSecurityHeader(), timestamp.getElement(), false);
- parts.add(new WSEncryptionPart(timestamp.getId()));
-
- sec509.setParts(parts);
- sec509.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
-
- // Signing the message
- Document signedDoc = sec509.build(doc, crypto, secHeader);
-
- org.apache.axis.Message signedMsg = (org.apache.axis.Message)
SOAPUtil.toSOAPMessage(signedDoc);
- envelope = signedMsg.getSOAPEnvelope();
-
- // call on the end point
- Object resultObject = call.invoke(envelope);
-
- SOAPEnvelope envelopeResult;
- SOAPBodyElement resultSBE;
- Document result;
-
- envelopeResult = (SOAPEnvelope) resultObject;
- resultSBE = envelopeResult.getFirstBody();
-
- // change it to document - here is where validity
- // can be checked..
- result = resultSBE.getAsDocument();
-
- // output it to a string
- StringWriter 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();
-
- System.out.println("---- Response message");
- System.out.println(outWriter.toString());
- System.out.println("---------------------");
- } catch (Exception e) {
- throw new PerfSONARException(e.getMessage());
- }
- }
-
- public static void main(String[] args)
- {
- SOAPUbCClient client = new SOAPUbCClient();
- client.test(args);
- }
-
-
-}

Deleted:
trunk/perfsonar_base/src/main/java/org/perfsonar/client/testHarness/UbCSaslTest.java
===================================================================
---
trunk/perfsonar_base/src/main/java/org/perfsonar/client/testHarness/UbCSaslTest.java
2012-11-26 14:41:24 UTC (rev 6036)
+++
trunk/perfsonar_base/src/main/java/org/perfsonar/client/testHarness/UbCSaslTest.java
2012-11-27 11:15:25 UTC (rev 6037)
@@ -1,443 +0,0 @@
-package org.perfsonar.client.testHarness;
-
-import java.io.StringWriter;
-import java.net.URL;
-import java.security.KeyPair;
-import java.security.KeyStore;
-import java.security.PrivateKey;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateParsingException;
-import java.security.cert.X509Certificate;
-import java.text.DateFormat;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Vector;
-
-import javax.xml.namespace.QName;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import net.geant.authr.pep.RequestFactory;
-import net.geant.authr.pep.SimpleRequest;
-
-import org.apache.axis.client.Call;
-import org.apache.axis.client.Service;
-import org.apache.axis.message.SOAPBodyElement;
-import org.apache.axis.message.SOAPEnvelope;
-import org.apache.ws.security.SOAPConstants;
-import org.apache.ws.security.WSConstants;
-import org.apache.ws.security.WSEncryptionPart;
-import org.apache.ws.security.components.crypto.Crypto;
-import org.apache.ws.security.message.WSSecHeader;
-import org.apache.ws.security.message.WSSecSignature;
-import org.apache.ws.security.util.WSSecurityUtil;
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.XMLSerializer;
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.ggf.ns.nmwg.base.v2_0.Message;
-import org.ggf.ns.nmwg.tools.org.perfsonar.service.as.authr.v1_0.Subject;
-import org.perfsonar.base.auxiliary.components.authn.DynamicCrypto;
-import org.perfsonar.base.auxiliary.components.authn.SOAPUtil;
-import org.perfsonar.base.exceptions.PerfSONARException;
-import org.perfsonar.base.util.XMLUtils;
-import org.perfsonar.client.base.authn.AuthNDataFactory;
-import org.perfsonar.client.base.authn.AuthNX509Data;
-import org.perfsonar.client.base.authn.saslca.SASLCAClient;
-import org.perfsonar.client.base.authn.saslca.SASLCAClientConfiguration;
-import org.perfsonar.client.base.authn.saslca.UserID;
-import org.perfsonar.client.base.requests.authService.AttrEERequestGenerator;
-import
org.perfsonar.client.base.requests.authService.AuthNEERequestGenerator;
-import
org.perfsonar.client.base.requests.authService.AuthREERequestGenerator;
-import org.perfsonar.service.base.authn.AttrRequest;
-import org.perfsonar.service.base.authn.AuthRRequest;
-import org.w3c.dom.Document;
-
-public class UbCSaslTest
-{
- private UserID userID;
-
- private SASLCAClientConfiguration clientConfig;
-
- private SASLCAClient client;
-
- public void test(String[] args)
- {
- try {
- String saslCAServer;
- String saslCAPort;
- String tsFile;
- String tsPassword;
- String tsType;
- String username;
- String userpassword;
- String oper;
- String endPoint;
-
- if (args.length == 9) {
- saslCAServer = args[0];
- saslCAPort = args[1];
- tsFile = args[2];
- tsPassword = args[3];
- tsType = args[4];
- username = args[5];
- userpassword = args[6];
- oper = args[7];
- endPoint = args[8];
- } else {
- System.out.println("Error: Wrong number (" + args.length +
"!= 9) of parameters!!!");
- return;
- }
- System.out.println("SASL CA Server: " + saslCAServer);
- System.out.println("SASL CA Port: " + saslCAPort);
- System.out.println("TrustStore File: " + tsFile);
- System.out.println("TrustStore Password: " + tsPassword);
- System.out.println("TrustStore Type: " + tsType);
- System.out.println("Username: " + username);
- System.out.println("Password: " + userpassword);
- System.out.println("Operation: " + oper);
- System.out.println("End Point: " + endPoint);
-
- System.setProperty("javax.net.ssl.trustStore", tsFile);
- System.setProperty("javax.net.ssl.trustStorePassword",
tsPassword);
- System.setProperty("javax.net.ssl.trustStoreType", tsType);
-
- userID = new UserID(username, userpassword);
- clientConfig = new SASLCAClientConfiguration(saslCAServer,
Integer.parseInt(saslCAPort), "RSA", 1024,
- "auth-only");
- client = new SASLCAClient(userID, clientConfig);
-
- KeyPair keyPair = client.generateKeyPair();
- if (oper.equals("get")) {
- checkCertificate(keyPair);
- } else if (oper.equals("authn")) {
- sendAuthNEERequest(keyPair, endPoint);
- } else if (oper.equals("authr")) {
- sendAuthREERequest(keyPair, endPoint);
- } else if (oper.equals("attr")) {
- sendAttrEERequest(keyPair, endPoint);
- }
-
- } catch (PerfSONARException e) {
- e.printStackTrace();
- } catch (CertificateParsingException e) {
- e.printStackTrace();
- }
- }
-
- public void checkCertificate(KeyPair keyPair) throws
CertificateParsingException, PerfSONARException
- {
- X509Certificate certificate = client.getCertficate(keyPair);
- System.out.println("Issuer DN: " +
certificate.getIssuerDN().toString());
- System.out.println("Subject DN: " +
certificate.getSubjectDN().toString());
- Collection<List<?>> collection =
certificate.getSubjectAlternativeNames();
- for (List<?> list : collection) {
- for (Object aList : list) {
- if (aList.toString().startsWith("http")) {
- System.out.println("Subject Alternative Name:" +
aList.toString());
- }
- }
- }
- System.out.println("Valid from: " +
DateFormat.getInstance().format(certificate.getNotBefore()));
- System.out.println("Valid until: " +
DateFormat.getInstance().format(certificate.getNotAfter()));
- }
-
- public void sendAuthNEERequest(KeyPair keyPair, String endPoint) throws
PerfSONARException
- {
- try {
- // prepare to call - set service elements
- Service service = new Service();
- Call call = (Call) service.createCall();
- call.setTargetEndpointAddress(new URL(endPoint));
- call.setOperationName(new QName("http://soapinterop.org/";,
"submit"));
-
- // read the request into a org.w3c.DOM.Document
- DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
-
- AuthNEERequestGenerator rg = new AuthNEERequestGenerator();
- Message rm = rg.generateRequestMessage();
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document request = builder.newDocument();
- request = rm.getDOM(request);
-
- // build a SOAPBodyElement from the document
- SOAPBodyElement requestMessage = new
SOAPBodyElement(request.getDocumentElement());
- SOAPEnvelope envelope = new SOAPEnvelope();
- envelope.addBodyElement(requestMessage);
-
- // add the security provider
- BouncyCastleProvider bcp = new BouncyCastleProvider();
- java.security.Security.addProvider(bcp);
-
- Crypto crypto = new DynamicCrypto();
- KeyStore ks = crypto.getKeyStore();
-
- PrivateKey privateKey = keyPair.getPrivate();
- X509Certificate cert = client.getCertficate(keyPair);
- ks.setKeyEntry("xmlsec", privateKey, "security".toCharArray(),
new Certificate[]{cert});
- WSSecSignature sec509 = new WSSecSignature();
- sec509.setUserInfo("xmlsec", "security");
- SOAPConstants soapConstants =
WSSecurityUtil.getSOAPConstants(envelope.getAsDOM());
- Vector<WSEncryptionPart> parts = new Vector<WSEncryptionPart>(1,
1);
-
- // Set up to use STRTransorm to sign the signature token
- WSEncryptionPart encP = new WSEncryptionPart("STRTransform",
soapConstants.getEnvelopeURI(), "Content");
- parts.add(encP);
-
- sec509.setParts(parts);
- sec509.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
-
- Document doc = envelope.getAsDocument();
- WSSecHeader secHeader = new WSSecHeader();
- secHeader.setActor("test");
- secHeader.insertSecurityHeader(doc);
-
- // Signing the message
- Document signedDoc = sec509.build(doc, crypto, secHeader);
-
- org.apache.axis.Message signedMsg = (org.apache.axis.Message)
SOAPUtil.toSOAPMessage(signedDoc);
- envelope = signedMsg.getSOAPEnvelope();
-
- // get a timestamp.
- double startTime = new
Long(System.currentTimeMillis()).doubleValue();
-
- // call on the end point
- Object resultObject = call.invoke(envelope);
-
- // get another timestamp
- double endTime = new
Long(System.currentTimeMillis()).doubleValue();
-
- SOAPEnvelope envelopeResult;
- SOAPBodyElement resultSBE;
- Document result;
-
- envelopeResult = (SOAPEnvelope) resultObject;
- resultSBE = envelopeResult.getFirstBody();
-
- // change it to document - here is where validity
- // can be checked..
- result = resultSBE.getAsDocument();
-
- // output it to a string
- StringWriter 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();
-
- System.out.println("---- Response message");
- System.out.println(outWriter.toString());
- System.out.println("---------------------");
- } catch (Exception e) {
- throw new PerfSONARException(e.getMessage());
- }
- }
-
- public void sendAttrEERequest(KeyPair keyPair, String endPoint) throws
PerfSONARException
- {
- try {
- checkCertificate(keyPair);
-
- PrivateKey privateKey = keyPair.getPrivate();
- X509Certificate cert = client.getCertficate(keyPair);
-
- AttrRequest attrReq = new AttrRequest();
- attrReq.setIssuer("Issuer");
-
attrReq.setSubject("urn:geant:edugain:component:be:gidp:user:first_candido-perfSONAR.net");
- List<String> listValues = new LinkedList<String>();
- listValues.add("perfSONAR.net");
- attrReq.addAttribute("urn:oid:1.3.6.1.4.1.25178.1.2.9",
"schacHomeOrganization", listValues);
-
- // prepare to call - set service elements
- Service service = new Service();
- Call call = (Call) service.createCall();
- call.setTargetEndpointAddress(new URL(endPoint));
- call.setOperationName(new QName("http://soapinterop.org/";,
"submit"));
-
- // read the request into a org.w3c.DOM.Document
- DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
-
- AttrEERequestGenerator rg = new AttrEERequestGenerator();
- Message rm = rg.generateRequestMessage(attrReq);
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document request = builder.newDocument();
- request = rm.getDOM(request);
- System.out.println("++++++++++++++++");
- System.out.println(XMLUtils.serializeDOM(request));
-
- // build a SOAPBodyElement from the document
- SOAPBodyElement requestMessage = new
SOAPBodyElement(request.getDocumentElement());
-
- AuthNX509Data authnData =
AuthNDataFactory.getDefaultAuthNX509Data();
- Object reqRaw = authnData.addX509STInMessage(requestMessage,
privateKey, cert);
- SOAPEnvelope envelope = (SOAPEnvelope) reqRaw;
-
- Document signedDoc = envelope.getAsDocument();
- System.out.println("&&&&&&&&&&&&&");
- System.out.println(XMLUtils.serializeDOM(signedDoc));
-
- org.apache.axis.Message signedMsg = (org.apache.axis.Message)
SOAPUtil.toSOAPMessage(signedDoc);
- envelope = signedMsg.getSOAPEnvelope();
-
- // get a timestamp.
- double startTime = new
Long(System.currentTimeMillis()).doubleValue();
-
- // call on the end point
- Object resultObject = call.invoke(envelope);
-
- // get another timestamp
- double endTime = new
Long(System.currentTimeMillis()).doubleValue();
-
- SOAPEnvelope envelopeResult;
- SOAPBodyElement resultSBE;
- Document result;
-
- envelopeResult = (SOAPEnvelope) resultObject;
- resultSBE = envelopeResult.getFirstBody();
-
- // change it to document - here is where validity
- // can be checked..
- result = resultSBE.getAsDocument();
-
- // output it to a string
- StringWriter 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();
-
- System.out.println("---- Response message");
- System.out.println(outWriter.toString());
- System.out.println("---------------------");
- } catch (Exception e) {
- e.printStackTrace();
- throw new PerfSONARException(e.getMessage());
- }
- }
-
- public void sendAuthREERequest(KeyPair keyPair, String endPoint) throws
PerfSONARException
- {
- try {
- checkCertificate(keyPair);
-
- PrivateKey privateKey = keyPair.getPrivate();
- X509Certificate cert = client.getCertficate(keyPair);
-
- AuthRRequest authrReq = new AuthRRequest();
- authrReq.setAction("EchoRequest");
-
authrReq.setSubject("urn:geant:edugain:component:be:gidp:user:first_candido-perfSONAR.net");
-
authrReq.setResource("urn:geant:edugain:component:perfsonarresource:rediris:geant2-java-sql-ma-1"
- +
".0:http%3A//localhost%3A8889/geant2-java-sql-ma/services/measurementArchiveService");
-
- Message authrRequest = new
AuthREERequestGenerator().generateRequestMessage();
-
- SimpleRequest simpleRequest;
- simpleRequest = RequestFactory.getDefaultSimpleRequest();
- simpleRequest.setResource(authrReq.getResource());
- simpleRequest.setAction(authrReq.getAction());
- simpleRequest.setSubject(authrReq.getSubject());
- String reqString = simpleRequest.getMessage();
- reqString = reqString.replaceAll("\n", "");
- reqString = reqString.replaceAll("\r", "");
- reqString = reqString.replaceAll("\t", "");
- reqString = reqString.replaceAll(" ", "");
- Subject authrElement = new Subject();
- authrElement.setSubject(reqString);
-
authrRequest.getMetadata("authRmetadata").setSubject(authrElement);
-
- // prepare to call - set service elements
- Service service = new Service();
- Call call = (Call) service.createCall();
- call.setTargetEndpointAddress(new URL(endPoint));
- call.setOperationName(new QName("http://soapinterop.org/";,
"submit"));
-
- // read the request into a org.w3c.DOM.Document
- DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
-
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document request = builder.newDocument();
- request = authrRequest.getDOM(request);
- System.out.println("++++++++++++++++");
- System.out.println(XMLUtils.serializeDOM(request));
-
- // build a SOAPBodyElement from the document
- SOAPBodyElement requestMessage = new
SOAPBodyElement(request.getDocumentElement());
-
- AuthNX509Data authnData =
AuthNDataFactory.getDefaultAuthNX509Data();
- Object reqRaw = authnData.addX509STInMessage(requestMessage,
privateKey, cert);
- SOAPEnvelope envelope = (SOAPEnvelope) reqRaw;
-
- Document signedDoc = envelope.getAsDocument();
- System.out.println("&&&&&&&&&&&&&");
- System.out.println(XMLUtils.serializeDOM(signedDoc));
-
- org.apache.axis.Message signedMsg = (org.apache.axis.Message)
SOAPUtil.toSOAPMessage(signedDoc);
- envelope = signedMsg.getSOAPEnvelope();
-
- // get a timestamp.
- double startTime = new
Long(System.currentTimeMillis()).doubleValue();
-
- // call on the end point
- Object resultObject = call.invoke(envelope);
-
- // get another timestamp
- double endTime = new
Long(System.currentTimeMillis()).doubleValue();
-
- SOAPEnvelope envelopeResult;
- SOAPBodyElement resultSBE;
- Document result;
-
- envelopeResult = (SOAPEnvelope) resultObject;
- resultSBE = envelopeResult.getFirstBody();
-
- // change it to document - here is where validity
- // can be checked..
- result = resultSBE.getAsDocument();
-
- // output it to a string
- StringWriter 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();
-
- System.out.println("---- Response message");
- System.out.println(outWriter.toString());
- System.out.println("---------------------");
- } catch (Exception e) {
- e.printStackTrace();
- throw new PerfSONARException(e.getMessage());
- }
- }
-
- public static void main(String[] args)
- {
- UbCSaslTest ubcSasl = new UbCSaslTest();
- ubcSasl.test(args);
- }
-
-}



  • [pS-dev] [GEANT/SA2/ps-java-services] r6037 - in trunk/perfsonar_base: . src/main/java/org/perfsonar/client/base/authn src/main/java/org/perfsonar/client/testHarness, svn-noreply, 11/27/2012

Archive powered by MHonArc 2.6.16.

Top of Page