You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by cs...@apache.org on 2017/08/17 14:30:08 UTC
[16/27] karaf git commit: Use simple PrintStream
Use simple PrintStream
Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/e973e3c7
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/e973e3c7
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/e973e3c7
Branch: refs/heads/model_features
Commit: e973e3c73cd431492bfc6ed6f1fb336f4f71ceaa
Parents: 71b136e
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Wed Aug 16 11:50:58 2017 +0200
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Wed Aug 16 11:50:58 2017 +0200
----------------------------------------------------------------------
.../modules/ldap/GSSAPILdapLoginModuleTest.java | 77 +++++++++-----------
1 file changed, 33 insertions(+), 44 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf/blob/e973e3c7/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java
----------------------------------------------------------------------
diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java
index b0152f1..11daa72 100644
--- a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java
+++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java
@@ -14,9 +14,24 @@
*/
package org.apache.karaf.jaas.modules.ldap;
-import org.apache.commons.io.FileUtils;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.security.Principal;
+import java.util.Collections;
+
+import javax.security.auth.Subject;
+import javax.security.auth.kerberos.KerberosPrincipal;
+import javax.security.auth.kerberos.KerberosTicket;
+import javax.security.auth.login.LoginException;
+
import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.SystemUtils;
import org.apache.directory.api.ldap.model.constants.SupportedSaslMechanisms;
import org.apache.directory.api.ldap.model.entry.DefaultEntry;
import org.apache.directory.api.ldap.model.entry.Entry;
@@ -53,22 +68,6 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import javax.security.auth.Subject;
-import javax.security.auth.kerberos.KerberosPrincipal;
-import javax.security.auth.kerberos.KerberosTicket;
-import javax.security.auth.login.LoginException;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.security.Principal;
-import java.util.Collections;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
@RunWith(FrameworkRunner.class)
@CreateDS(name = "GSSAPILdapLoginModuleTest-class",
partitions =
@@ -317,34 +316,24 @@ public class GSSAPILdapLoginModuleTest extends AbstractKerberosITest {
private String createKrb5Conf(ChecksumType checksumType, EncryptionType encryptionType, boolean isTcp) throws IOException {
File file = folder.newFile("krb5.conf");
-
- String data = "";
-
- data += "[libdefaults]" + SystemUtils.LINE_SEPARATOR;
- data += "default_realm = " + REALM + SystemUtils.LINE_SEPARATOR;
- data += "default_tkt_enctypes = " + encryptionType.getName() + SystemUtils.LINE_SEPARATOR;
- data += "default_tgs_enctypes = " + encryptionType.getName() + SystemUtils.LINE_SEPARATOR;
- data += "permitted_enctypes = " + encryptionType.getName() + SystemUtils.LINE_SEPARATOR;
- // data += "default_checksum = " + checksumType.getName() + SystemUtils.LINE_SEPARATOR;
- // data += "ap_req_checksum_type = " + checksumType.getName() + SystemUtils.LINE_SEPARATOR;
- data += "default-checksum_type = " + checksumType.getName() + SystemUtils.LINE_SEPARATOR;
-
+ PrintStream out = new PrintStream(file);
+ out.println("[libdefaults]");
+ out.println("default_realm = " + REALM);
+ out.println("default_tkt_enctypes = " + encryptionType.getName());
+ out.println("default_tgs_enctypes = " + encryptionType.getName());
+ out.println("permitted_enctypes = " + encryptionType.getName());
+ out.println("default-checksum_type = " + checksumType.getName());
if (isTcp) {
- data += "udp_preference_limit = 1" + SystemUtils.LINE_SEPARATOR;
+ out.println("udp_preference_limit = 1");
}
-
-
- data += "[realms]" + SystemUtils.LINE_SEPARATOR;
- data += REALM + " = {" + SystemUtils.LINE_SEPARATOR;
- data += "kdc = " + HOSTNAME + ":" + kdcServer.getTransports()[0].getPort() + SystemUtils.LINE_SEPARATOR;
- data += "}" + SystemUtils.LINE_SEPARATOR;
-
- data += "[domain_realm]" + SystemUtils.LINE_SEPARATOR;
- data += "." + Strings.lowerCaseAscii(REALM) + " = " + REALM + SystemUtils.LINE_SEPARATOR;
- data += Strings.lowerCaseAscii(REALM) + " = " + REALM + SystemUtils.LINE_SEPARATOR;
-
- FileUtils.writeStringToFile(file, data, Charset.defaultCharset());
-
+ out.println("[realms]");
+ out.println(REALM + " = {");
+ out.println("kdc = " + HOSTNAME + ":" + kdcServer.getTransports()[0].getPort());
+ out.println("}");
+ out.println("[domain_realm]");
+ out.println("." + Strings.lowerCaseAscii(REALM) + " = " + REALM);
+ out.println(Strings.lowerCaseAscii(REALM) + " = " + REALM);
+ out.close();
return file.getAbsolutePath();
}