title: How to use cached ticket with KerberosRestTemplate?
body: <p>I want to implement integration test for my spring security kerberos authentication. 
  There is <strong>KerberosRestTemplate</strong> (<a href="http://docs.spring.io/autorepo/docs/spring-security-kerberos/1.0.0.RC1/reference/htmlsingle/#ssk-resttemplate" rel="nofollow">reference</a>) for this purpose. <strong>KerberosRestTemplate</strong> has got a default constructor with description "Leave keyTabLocation and userPrincipal empty if you want to use cached ticket". </p>
  
  <p>For research i wrote a trivial class: </p>
  
  <pre><code>   public static void main(String[] args) {
          KerberosRestTemplate krt = new KerberosRestTemplate();
          String result = krt.getForObject("http://testserver.testad.local:8080/", String.class);
          System.out.println(result);
      }
  </code></pre>
  
  <p>When i run it, exception has thrown:</p>
  
  <pre><code>Exception in thread "main" org.springframework.web.client.RestClientException: Error running rest call; nested exception is java.lang.IllegalArgumentException: Null name not allowed
          at org.springframework.security.kerberos.client.KerberosRestTemplate.doExecute(KerberosRestT
  emplate.java:196)
          at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:530)
          at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:237)
          at edu.mezlogo.Application.main(Application.java:9)
  Caused by: java.lang.IllegalArgumentException: Null name not allowed
          at sun.security.krb5.PrincipalName.&lt;init&gt;(Unknown Source)
          at sun.security.krb5.PrincipalName.&lt;init&gt;(Unknown Source)
          at javax.security.auth.kerberos.KerberosPrincipal.&lt;init&gt;(Unknown Source)
          at javax.security.auth.kerberos.KerberosPrincipal.&lt;init&gt;(Unknown Source)
          at org.springframework.security.kerberos.client.KerberosRestTemplate.doExecute(KerberosRestT
  emplate.java:182)
          ... 3 more
  </code></pre>
  
  <p>My <strong>klist</strong> contain correct cached ticket, for my service.</p>
  
  <pre><code>#2&gt;     Client: deniz @ TESTAD.LOCAL
          Server: HTTP/testserver.testad.local @ TESTAD.LOCAL
          KerbTicket Encryption Type: RSADSI RC4-HMAC(NT)
          Ticket Flags 0x40a10000 -&gt; forwardable renewable pre_authent name_canonicalize
          Start Time: 2/5/2016 6:17:39 (local)
          End Time:   2/5/2016 16:16:32 (local)
          Renew Time: 2/12/2016 6:16:32 (local)
          Session Key Type: RSADSI RC4-HMAC(NT)
  </code></pre>
  
  <p>And my browser (firefox) has successful authenticated with kerberos sso.</p>
  
  <p>I use Windows server 2012. And Windows 7 as client.</p>
  
  <p>How to use cached ticket? (And does ktpass can generate client keytab?)</p>
  
  <p>P.s. sorry for my English.</p>