更改 java 的 Kerberos 票证缓存位置
Change Kerberos ticket cache location for java
我已经为 windows 设置了 kerberos
,用 kerberos
保护了 hadoop-2.6.0
。
提交作业或执行任何用户命令时,Hadoop 从默认位置引用 Kerberos 票证缓存 c:\users\username\krb5cc_username.
我想在运行时更改此位置。是否可以更改 java 的默认 属性 以从我系统中的某处引用票证缓存位置。
已更新
可以使用以下命令更改默认位置
kinit -c cache_name username
但是当我对 hadoop 进行任何操作时,它只为用户信息采用默认的票证缓存位置。如何将默认位置更改为用户特定的缓存位置?
不胜感激。
首先,你可以。但你应该问问自己为什么?
打开 PrintWriter
,构建您的 login.conf
,在您的代码中设置 JAAS conf 文件 属性,您就完成了。
示例代码如下:
PrintWriter writer = new PrintWriter(new FileOutputSteam("..."));
writer.println("client {");
writer.println("com.sun.security.auth.module.Krb5LoginModule required doNotPrompt=true useTicketCache=true");
writer.print("ticketCache=\"");
writer.print(path);
writer.println("\";");
writer.println("};");
System.setProperty("java.security.auth.login.config", ...);
现在应该这样做并使用 JAAS 来获取缓存的内存中表示。
我刚刚通过设置以下环境变量解决了这个问题,
set KRB5CCNAME=ticketlocation
设置以上变量使Hadoop从指定位置获取票证。
我已经为 windows 设置了 kerberos
,用 kerberos
保护了 hadoop-2.6.0
。
提交作业或执行任何用户命令时,Hadoop 从默认位置引用 Kerberos 票证缓存 c:\users\username\krb5cc_username.
我想在运行时更改此位置。是否可以更改 java 的默认 属性 以从我系统中的某处引用票证缓存位置。
已更新
可以使用以下命令更改默认位置
kinit -c cache_name username
但是当我对 hadoop 进行任何操作时,它只为用户信息采用默认的票证缓存位置。如何将默认位置更改为用户特定的缓存位置?
不胜感激。
首先,你可以。但你应该问问自己为什么?
打开 PrintWriter
,构建您的 login.conf
,在您的代码中设置 JAAS conf 文件 属性,您就完成了。
示例代码如下:
PrintWriter writer = new PrintWriter(new FileOutputSteam("..."));
writer.println("client {");
writer.println("com.sun.security.auth.module.Krb5LoginModule required doNotPrompt=true useTicketCache=true");
writer.print("ticketCache=\"");
writer.print(path);
writer.println("\";");
writer.println("};");
System.setProperty("java.security.auth.login.config", ...);
现在应该这样做并使用 JAAS 来获取缓存的内存中表示。
我刚刚通过设置以下环境变量解决了这个问题,
set KRB5CCNAME=ticketlocation
设置以上变量使Hadoop从指定位置获取票证。