Java Code Examples for sun.security.jgss.krb5.Krb5Util#credsToTicket()
The following examples show how to use
sun.security.jgss.krb5.Krb5Util#credsToTicket() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KerberosTest.java From jcifs with GNU Lesser General Public License v2.1 | 6 votes |
private static KerberosTicket getKerberosTicket ( KerberosPrincipal principal, String password, Long expire ) throws Exception { PrincipalName principalName = convertPrincipal(principal); KrbAsReqBuilder builder = new KrbAsReqBuilder(principalName, password != null ? password.toCharArray() : new char[0]); if ( expire != null ) { System.out.println("Request expires " + expire); KerberosTime till = new KerberosTime(expire); Field tillF = builder.getClass().getDeclaredField("till"); tillF.setAccessible(true); tillF.set(builder, till); } Credentials creds = builder.action().getCreds(); builder.destroy(); KerberosTicket ticket = Krb5Util.credsToTicket(creds); System.out.println("Ends " + ticket.getEndTime().getTime()); return ticket; }
Example 2
Source File: KerberosTest.java From jcifs-ng with GNU Lesser General Public License v2.1 | 6 votes |
private static KerberosTicket getKerberosTicket ( KerberosPrincipal principal, String password, Long expire ) throws Exception { PrincipalName principalName = convertPrincipal(principal); KrbAsReqBuilder builder = new KrbAsReqBuilder(principalName, password != null ? password.toCharArray() : new char[0]); if ( expire != null ) { System.out.println("Request expires " + expire); KerberosTime till = new KerberosTime(expire); Field tillF = builder.getClass().getDeclaredField("till"); tillF.setAccessible(true); tillF.set(builder, till); } Credentials creds = builder.action().getCreds(); builder.destroy(); KerberosTicket ticket = Krb5Util.credsToTicket(creds); System.out.println("Ends " + ticket.getEndTime().getTime()); return ticket; }
Example 3
Source File: KerberosTest.java From jcifs with GNU Lesser General Public License v2.1 | 5 votes |
private static KerberosTicket getKerberosTicket ( KeyTab keytab, final KerberosPrincipal principal ) throws Asn1Exception, KrbException, IOException { PrincipalName principalName = convertPrincipal(principal); EncryptionKey[] keys = Krb5Util.keysFromJavaxKeyTab(keytab, principalName); if ( keys == null || keys.length == 0 ) { throw new KrbException("Could not find any keys in keytab for " + principalName); //$NON-NLS-1$ } KrbAsReqBuilder builder = new KrbAsReqBuilder(principalName, keytab); Credentials creds = builder.action().getCreds(); builder.destroy(); return Krb5Util.credsToTicket(creds); }
Example 4
Source File: KerberosTest.java From jcifs-ng with GNU Lesser General Public License v2.1 | 5 votes |
private static KerberosTicket getKerberosTicket ( KeyTab keytab, final KerberosPrincipal principal ) throws Asn1Exception, KrbException, IOException { PrincipalName principalName = convertPrincipal(principal); EncryptionKey[] keys = Krb5Util.keysFromJavaxKeyTab(keytab, principalName); if ( keys == null || keys.length == 0 ) { throw new KrbException("Could not find any keys in keytab for " + principalName); //$NON-NLS-1$ } KrbAsReqBuilder builder = new KrbAsReqBuilder(principalName, keytab); Credentials creds = builder.action().getCreds(); builder.destroy(); return Krb5Util.credsToTicket(creds); }