ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1643290 - /webservices/wss4j/trunk/integration/src/test/java/org/apache/wss4j/integration/test/kerberos/KerberosTest.java
Date Fri, 05 Dec 2014 14:09:06 GMT
Author: coheigea
Date: Fri Dec  5 14:09:06 2014
New Revision: 1643290

URL: http://svn.apache.org/r1643290
Log:
Minor fix to only write the kdc port out to the krb5.conf once

Modified:
    webservices/wss4j/trunk/integration/src/test/java/org/apache/wss4j/integration/test/kerberos/KerberosTest.java

Modified: webservices/wss4j/trunk/integration/src/test/java/org/apache/wss4j/integration/test/kerberos/KerberosTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/integration/src/test/java/org/apache/wss4j/integration/test/kerberos/KerberosTest.java?rev=1643290&r1=1643289&r2=1643290&view=diff
==============================================================================
--- webservices/wss4j/trunk/integration/src/test/java/org/apache/wss4j/integration/test/kerberos/KerberosTest.java
(original)
+++ webservices/wss4j/trunk/integration/src/test/java/org/apache/wss4j/integration/test/kerberos/KerberosTest.java
Fri Dec  5 14:09:06 2014
@@ -85,6 +85,7 @@ import org.apache.xml.security.stax.secu
 import org.apache.xml.security.utils.Base64;
 import org.junit.AfterClass;
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -141,6 +142,7 @@ public class KerberosTest extends Abstra
     private static DocumentBuilderFactory dbf;
     
     private static boolean runTests;
+    private static boolean portUpdated;
     
     @BeforeClass
     public static void setUp() throws Exception {
@@ -159,7 +161,7 @@ public class KerberosTest extends Abstra
                 basedir += "/..";
             }
 
-            System.setProperty("sun.security.krb5.debug", "true");
+            // System.setProperty("sun.security.krb5.debug", "true");
             System.setProperty("java.security.auth.login.config", basedir + "/integration/src/test/resources/kerberos/kerberos.jaas");
             
         }
@@ -179,26 +181,31 @@ public class KerberosTest extends Abstra
         SecurityTestUtil.cleanup();
     }
     
-    public KerberosTest() throws Exception {
-        String basedir = System.getProperty("basedir");
-        if (basedir == null) {
-            basedir = new File(".").getCanonicalPath();
+    @Before
+    public void updatePort() throws Exception {
+        if (!portUpdated) {
+            String basedir = System.getProperty("basedir");
+            if (basedir == null) {
+                basedir = new File(".").getCanonicalPath();
+            }
+            
+            // Read in krb5.conf and substitute in the correct port
+            File f = new File(basedir + "/src/test/resources/kerberos/krb5.conf");
+            
+            FileInputStream inputStream = new FileInputStream(f);
+            String content = IOUtils.toString(inputStream, "UTF-8");
+            inputStream.close();
+            content = content.replaceAll("port", "" + super.getKdcServer().getTransports()[0].getPort());
+            
+            File f2 = new File(basedir + "/target/test-classes/kerberos/krb5.conf");
+            FileOutputStream outputStream = new FileOutputStream(f2);
+            IOUtils.write(content, outputStream, "UTF-8");
+            outputStream.close();
+            
+            System.setProperty("java.security.krb5.conf", f2.getPath());
+            
+            portUpdated = true;
         }
-        
-        // Read in krb5.conf and substitute in the correct port
-        File f = new File(basedir + "/src/test/resources/kerberos/krb5.conf");
-        
-        FileInputStream inputStream = new FileInputStream(f);
-        String content = IOUtils.toString(inputStream, "UTF-8");
-        inputStream.close();
-        content = content.replaceAll("port", "" + super.getKdcServer().getTransports()[0].getPort());
-        
-        File f2 = new File(basedir + "/target/test-classes/kerberos/krb5.conf");
-        FileOutputStream outputStream = new FileOutputStream(f2);
-        IOUtils.write(content, outputStream, "UTF-8");
-        outputStream.close();
-        
-        System.setProperty("java.security.krb5.conf", f2.getPath());
     }
     
     //



Mime
View raw message