Here you can find the source of writeJaasConfig(File krbDir, String princ, String keytabPath)
private static String writeJaasConfig(File krbDir, String princ, String keytabPath) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileOutputStream; import java.nio.charset.Charset; public class Main { private static String writeJaasConfig(File krbDir, String princ, String keytabPath) throws Exception { File file = File.createTempFile("jaas_", ".conf", krbDir); file.deleteOnExit();// ww w . ja v a2 s. co m String jaasData; jaasData = "Client {\n"; jaasData += "com.sun.security.auth.module.Krb5LoginModule required\n"; jaasData += "principal=\"" + princ + "\"\n"; jaasData += "useKeyTab=true\n"; jaasData += "keyTab=\"" + keytabPath + "\"\n"; jaasData += "doNotPrompt=true\n"; jaasData += "useTicketCache=false;\n"; jaasData += "};\n"; jaasData += "com.sun.security.jgss.initiate {\n"; jaasData += "com.sun.security.auth.module.Krb5LoginModule required\n"; jaasData += "principal=\"" + princ + "\"\n"; jaasData += "useKeyTab=true\n"; jaasData += "keyTab=\"" + keytabPath + "\"\n"; jaasData += "doNotPrompt=true\n"; jaasData += "useTicketCache=false;\n"; jaasData += "};\n"; FileOutputStream os = new FileOutputStream(file); os.write(jaasData.getBytes(Charset.forName("UTF-8"))); os.close(); return file.getCanonicalPath(); } }