sun.security.krb5.internal.ccache.CredentialsCache Java Examples

The following examples show how to use sun.security.krb5.internal.ccache.CredentialsCache. 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: Context.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Saves the tickets to a ccache file.
 *
 * @param file pathname of the ccache file
 * @return true if created, false otherwise.
 */
public boolean ccache(String file) throws Exception {
    Set<KerberosTicket> tickets
            = s.getPrivateCredentials(KerberosTicket.class);
    if (tickets != null && !tickets.isEmpty()) {
        CredentialsCache cc = null;
        for (KerberosTicket t : tickets) {
            Credentials cred = Krb5Util.ticketToCreds(t);
            if (cc == null) {
                cc = CredentialsCache.create(cred.getClient(), file);
            }
            cc.update(cred.toCCacheCreds());
        }
        if (cc != null) {
            cc.save();
            return true;
        }
    }
    return false;
}
 
Example #2
Source File: Context.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Saves the tickets to a ccache file.
 *
 * @param file pathname of the ccache file
 * @return true if created, false otherwise.
 */
public boolean ccache(String file) throws Exception {
    Set<KerberosTicket> tickets
            = s.getPrivateCredentials(KerberosTicket.class);
    if (tickets != null && !tickets.isEmpty()) {
        CredentialsCache cc = null;
        for (KerberosTicket t : tickets) {
            Credentials cred = Krb5Util.ticketToCreds(t);
            if (cc == null) {
                cc = CredentialsCache.create(cred.getClient(), file);
            }
            cc.update(cred.toCCacheCreds());
        }
        if (cc != null) {
            cc.save();
            return true;
        }
    }
    return false;
}
 
Example #3
Source File: Context.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Saves the tickets to a ccache file.
 *
 * @param file pathname of the ccache file
 * @return true if created, false otherwise.
 */
public boolean ccache(String file) throws Exception {
    Set<KerberosTicket> tickets
            = s.getPrivateCredentials(KerberosTicket.class);
    if (tickets != null && !tickets.isEmpty()) {
        CredentialsCache cc = null;
        for (KerberosTicket t : tickets) {
            Credentials cred = Krb5Util.ticketToCreds(t);
            if (cc == null) {
                cc = CredentialsCache.create(cred.getClient(), file);
            }
            cc.update(cred.toCCacheCreds());
        }
        if (cc != null) {
            cc.save();
            return true;
        }
    }
    return false;
}
 
Example #4
Source File: Context.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Saves the tickets to a ccache file.
 *
 * @param file pathname of the ccache file
 * @return true if created, false otherwise.
 */
public boolean ccache(String file) throws Exception {
    Set<KerberosTicket> tickets
            = s.getPrivateCredentials(KerberosTicket.class);
    if (tickets != null && !tickets.isEmpty()) {
        CredentialsCache cc = null;
        for (KerberosTicket t : tickets) {
            Credentials cred = Krb5Util.ticketToCreds(t);
            if (cc == null) {
                cc = CredentialsCache.create(cred.getClient(), file);
            }
            cc.update(cred.toCCacheCreds());
        }
        if (cc != null) {
            cc.save();
            return true;
        }
    }
    return false;
}
 
Example #5
Source File: EmptyCC.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    final PrincipalName pn = new PrincipalName("[email protected]");
    final String ccache = args[0];

    if (args.length == 1) {
        // Main process, write the ccache and launch sub process
        CredentialsCache cache = CredentialsCache.create(pn, ccache);
        cache.save();
        Proc p = Proc.create("EmptyCC").args(ccache, "readcc")
                .env("KRB5CCNAME", ccache).start();
        p.waitFor();
    } else {
        // Sub process, read the ccache
        String cc = System.getenv("KRB5CCNAME");
        if (!cc.equals(ccache)) {
            throw new Exception("env not set correctly");
        }
        // 8001208: Fix for KRB5CCNAME not complete
        // Make sure the ccache is created with bare file name
        if (CredentialsCache.getInstance() == null) {
            throw new Exception("Cache not instantiated");
        }
        if (!new File("tmpcc").exists()) {
            throw new Exception("File not found");
        }
        Credentials.acquireTGTFromCache(pn, null);
    }
}
 
Example #6
Source File: CorruptedCC.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    for (int i=0; i<TimeInCCache.ccache.length; i++) {
        byte old = TimeInCCache.ccache[i];
        TimeInCCache.ccache[i] = 0x7f;
        Files.write(Paths.get("tmpcc"), TimeInCCache.ccache);
        // The next line will return null for I/O issues. That's OK.
        CredentialsCache.getInstance("tmpcc");
        TimeInCCache.ccache[i] = old;
    }
}
 
Example #7
Source File: EmptyRealmCC.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    byte[] ccache = TimeInCCache.ccache;

    // The service name starts at 0x52:
    //
    //    0050:    00 00 00 02 00 00 00 0A 4D 41 58 49 2E 4C
    //             ----------- -----------
    //    0060: 4F 43 41 4C 00 00 00 06 6B 72 62 74 67 74 00 00
    //                      -----------                   -----
    //    0070: 00 0A 4D 41 58 49 2E 4C 4F 43 41 4C
    //          -----
    //
    // which contains 2 (the length of names), a 10-byte realm, a 6-byte
    // name[0], and a 10-byte name[1].

    // We will empty the realm, and pack the realm string to another
    // name (6-byte ".LOCAL"). Finally "krbtgt/[email protected]"
    // becomes ".LOCAL/krbtgt/MAXI.LOCAL@".

    // length of names is now 3
    ccache[0x55] = 3;
    // The empty realm
    System.arraycopy(new byte[4], 0, ccache, 0x56, 4);
    // Length of inserted name is 6
    System.arraycopy(new byte[]{0,0,0,6}, 0, ccache, 0x5A, 4);

    Files.write(Paths.get("tmpcc"), TimeInCCache.ccache);
    if (CredentialsCache.getInstance("tmpcc").getCredsList() != null) {
        throw new Exception("Nothing should be there");
    }
}
 
Example #8
Source File: EmptyRealmCC.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    byte[] ccache = TimeInCCache.ccache;

    // The service name starts at 0x52:
    //
    //    0050:    00 00 00 02 00 00 00 0A 4D 41 58 49 2E 4C
    //             ----------- -----------
    //    0060: 4F 43 41 4C 00 00 00 06 6B 72 62 74 67 74 00 00
    //                      -----------                   -----
    //    0070: 00 0A 4D 41 58 49 2E 4C 4F 43 41 4C
    //          -----
    //
    // which contains 2 (the length of names), a 10-byte realm, a 6-byte
    // name[0], and a 10-byte name[1].

    // We will empty the realm, and pack the realm string to another
    // name (6-byte ".LOCAL"). Finally "krbtgt/[email protected]"
    // becomes ".LOCAL/krbtgt/MAXI.LOCAL@".

    // length of names is now 3
    ccache[0x55] = 3;
    // The empty realm
    System.arraycopy(new byte[4], 0, ccache, 0x56, 4);
    // Length of inserted name is 6
    System.arraycopy(new byte[]{0,0,0,6}, 0, ccache, 0x5A, 4);

    Files.write(Paths.get("tmpcc"), TimeInCCache.ccache);
    if (CredentialsCache.getInstance("tmpcc").getCredsList() != null) {
        throw new Exception("Nothing should be there");
    }
}
 
Example #9
Source File: EmptyCC.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    final PrincipalName pn = new PrincipalName("[email protected]");
    final String ccache = args[0];

    if (args.length == 1) {
        // Main process, write the ccache and launch sub process
        CredentialsCache cache = CredentialsCache.create(pn, ccache);
        cache.save();
        Proc p = Proc.create("EmptyCC").args(ccache, "readcc")
                .env("KRB5CCNAME", ccache).start();
        p.waitFor();
    } else {
        // Sub process, read the ccache
        String cc = System.getenv("KRB5CCNAME");
        if (!cc.equals(ccache)) {
            throw new Exception("env not set correctly");
        }
        // 8001208: Fix for KRB5CCNAME not complete
        // Make sure the ccache is created with bare file name
        if (CredentialsCache.getInstance() == null) {
            throw new Exception("Cache not instantiated");
        }
        if (!new File("tmpcc").exists()) {
            throw new Exception("File not found");
        }
        Credentials.acquireTGTFromCache(pn, null);
    }
}
 
Example #10
Source File: EmptyRealmCC.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    byte[] ccache = TimeInCCache.ccache;

    // The service name starts at 0x52:
    //
    //    0050:    00 00 00 02 00 00 00 0A 4D 41 58 49 2E 4C
    //             ----------- -----------
    //    0060: 4F 43 41 4C 00 00 00 06 6B 72 62 74 67 74 00 00
    //                      -----------                   -----
    //    0070: 00 0A 4D 41 58 49 2E 4C 4F 43 41 4C
    //          -----
    //
    // which contains 2 (the length of names), a 10-byte realm, a 6-byte
    // name[0], and a 10-byte name[1].

    // We will empty the realm, and pack the realm string to another
    // name (6-byte ".LOCAL"). Finally "krbtgt/[email protected]"
    // becomes ".LOCAL/krbtgt/MAXI.LOCAL@".

    // length of names is now 3
    ccache[0x55] = 3;
    // The empty realm
    System.arraycopy(new byte[4], 0, ccache, 0x56, 4);
    // Length of inserted name is 6
    System.arraycopy(new byte[]{0,0,0,6}, 0, ccache, 0x5A, 4);

    Files.write(Paths.get("tmpcc"), TimeInCCache.ccache);
    if (CredentialsCache.getInstance("tmpcc").getCredsList() != null) {
        throw new Exception("Nothing should be there");
    }
}
 
Example #11
Source File: EmptyCC.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    final PrincipalName pn = new PrincipalName("[email protected]");
    final String ccache = args[0];

    if (args.length == 1) {
        // Main process, write the ccache and launch sub process
        CredentialsCache cache = CredentialsCache.create(pn, ccache);
        cache.save();
        Proc p = Proc.create("EmptyCC").args(ccache, "readcc")
                .env("KRB5CCNAME", ccache).start();
        p.waitFor();
    } else {
        // Sub process, read the ccache
        String cc = System.getenv("KRB5CCNAME");
        if (!cc.equals(ccache)) {
            throw new Exception("env not set correctly");
        }
        // 8001208: Fix for KRB5CCNAME not complete
        // Make sure the ccache is created with bare file name
        if (CredentialsCache.getInstance() == null) {
            throw new Exception("Cache not instantiated");
        }
        if (!new File("tmpcc").exists()) {
            throw new Exception("File not found");
        }
        Credentials.acquireTGTFromCache(pn, null);
    }
}
 
Example #12
Source File: EmptyCC.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    final PrincipalName pn = new PrincipalName("[email protected]");
    final String ccache = args[0];

    if (args.length == 1) {
        // Main process, write the ccache and launch sub process
        CredentialsCache cache = CredentialsCache.create(pn, ccache);
        cache.save();
        Proc p = Proc.create("EmptyCC").args(ccache, "readcc")
                .env("KRB5CCNAME", ccache).start();
        p.waitFor();
    } else {
        // Sub process, read the ccache
        String cc = System.getenv("KRB5CCNAME");
        if (!cc.equals(ccache)) {
            throw new Exception("env not set correctly");
        }
        // 8001208: Fix for KRB5CCNAME not complete
        // Make sure the ccache is created with bare file name
        if (CredentialsCache.getInstance() == null) {
            throw new Exception("Cache not instantiated");
        }
        if (!new File("tmpcc").exists()) {
            throw new Exception("File not found");
        }
        Credentials.acquireTGTFromCache(pn, null);
    }
}
 
Example #13
Source File: EmptyRealmCC.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    byte[] ccache = TimeInCCache.ccache;

    // The service name starts at 0x52:
    //
    //    0050:    00 00 00 02 00 00 00 0A 4D 41 58 49 2E 4C
    //             ----------- -----------
    //    0060: 4F 43 41 4C 00 00 00 06 6B 72 62 74 67 74 00 00
    //                      -----------                   -----
    //    0070: 00 0A 4D 41 58 49 2E 4C 4F 43 41 4C
    //          -----
    //
    // which contains 2 (the length of names), a 10-byte realm, a 6-byte
    // name[0], and a 10-byte name[1].

    // We will empty the realm, and pack the realm string to another
    // name (6-byte ".LOCAL"). Finally "krbtgt/[email protected]"
    // becomes ".LOCAL/krbtgt/MAXI.LOCAL@".

    // length of names is now 3
    ccache[0x55] = 3;
    // The empty realm
    System.arraycopy(new byte[4], 0, ccache, 0x56, 4);
    // Length of inserted name is 6
    System.arraycopy(new byte[]{0,0,0,6}, 0, ccache, 0x5A, 4);

    Files.write(Paths.get("tmpcc"), TimeInCCache.ccache);
    if (CredentialsCache.getInstance("tmpcc").getCredsList() != null) {
        throw new Exception("Nothing should be there");
    }
}
 
Example #14
Source File: EmptyRealmCC.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    byte[] ccache = TimeInCCache.ccache;

    // The service name starts at 0x52:
    //
    //    0050:    00 00 00 02 00 00 00 0A 4D 41 58 49 2E 4C
    //             ----------- -----------
    //    0060: 4F 43 41 4C 00 00 00 06 6B 72 62 74 67 74 00 00
    //                      -----------                   -----
    //    0070: 00 0A 4D 41 58 49 2E 4C 4F 43 41 4C
    //          -----
    //
    // which contains 2 (the length of names), a 10-byte realm, a 6-byte
    // name[0], and a 10-byte name[1].

    // We will empty the realm, and pack the realm string to another
    // name (6-byte ".LOCAL"). Finally "krbtgt/[email protected]"
    // becomes ".LOCAL/krbtgt/MAXI.LOCAL@".

    // length of names is now 3
    ccache[0x55] = 3;
    // The empty realm
    System.arraycopy(new byte[4], 0, ccache, 0x56, 4);
    // Length of inserted name is 6
    System.arraycopy(new byte[]{0,0,0,6}, 0, ccache, 0x5A, 4);

    Files.write(Paths.get("tmpcc"), TimeInCCache.ccache);
    if (CredentialsCache.getInstance("tmpcc").getCredsList() != null) {
        throw new Exception("Nothing should be there");
    }
}
 
Example #15
Source File: CorruptedCC.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    for (int i=0; i<TimeInCCache.ccache.length; i++) {
        byte old = TimeInCCache.ccache[i];
        TimeInCCache.ccache[i] = 0x7f;
        Files.write(Paths.get("tmpcc"), TimeInCCache.ccache);
        // The next line will return null for I/O issues. That's OK.
        CredentialsCache.getInstance("tmpcc");
        TimeInCCache.ccache[i] = old;
    }
}
 
Example #16
Source File: EmptyCC.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    final PrincipalName pn = new PrincipalName("[email protected]");
    final String ccache = args[0];

    if (args.length == 1) {
        // Main process, write the ccache and launch sub process
        CredentialsCache cache = CredentialsCache.create(pn, ccache);
        cache.save();
        Proc p = Proc.create("EmptyCC").args(ccache, "readcc")
                .env("KRB5CCNAME", ccache).start();
        p.waitFor();
    } else {
        // Sub process, read the ccache
        String cc = System.getenv("KRB5CCNAME");
        if (!cc.equals(ccache)) {
            throw new Exception("env not set correctly");
        }
        // 8001208: Fix for KRB5CCNAME not complete
        // Make sure the ccache is created with bare file name
        if (CredentialsCache.getInstance() == null) {
            throw new Exception("Cache not instantiated");
        }
        if (!new File("tmpcc").exists()) {
            throw new Exception("File not found");
        }
        Credentials.acquireTGTFromCache(pn, null);
    }
}
 
Example #17
Source File: EmptyRealmCC.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    byte[] ccache = TimeInCCache.ccache;

    // The service name starts at 0x52:
    //
    //    0050:    00 00 00 02 00 00 00 0A 4D 41 58 49 2E 4C
    //             ----------- -----------
    //    0060: 4F 43 41 4C 00 00 00 06 6B 72 62 74 67 74 00 00
    //                      -----------                   -----
    //    0070: 00 0A 4D 41 58 49 2E 4C 4F 43 41 4C
    //          -----
    //
    // which contains 2 (the length of names), a 10-byte realm, a 6-byte
    // name[0], and a 10-byte name[1].

    // We will empty the realm, and pack the realm string to another
    // name (6-byte ".LOCAL"). Finally "krbtgt/[email protected]"
    // becomes ".LOCAL/krbtgt/MAXI.LOCAL@".

    // length of names is now 3
    ccache[0x55] = 3;
    // The empty realm
    System.arraycopy(new byte[4], 0, ccache, 0x56, 4);
    // Length of inserted name is 6
    System.arraycopy(new byte[]{0,0,0,6}, 0, ccache, 0x5A, 4);

    Files.write(Paths.get("tmpcc"), TimeInCCache.ccache);
    if (CredentialsCache.getInstance("tmpcc").getCredsList() != null) {
        throw new Exception("Nothing should be there");
    }
}
 
Example #18
Source File: EmptyRealmCC.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    byte[] ccache = TimeInCCache.ccache;

    // The service name starts at 0x52:
    //
    //    0050:    00 00 00 02 00 00 00 0A 4D 41 58 49 2E 4C
    //             ----------- -----------
    //    0060: 4F 43 41 4C 00 00 00 06 6B 72 62 74 67 74 00 00
    //                      -----------                   -----
    //    0070: 00 0A 4D 41 58 49 2E 4C 4F 43 41 4C
    //          -----
    //
    // which contains 2 (the length of names), a 10-byte realm, a 6-byte
    // name[0], and a 10-byte name[1].

    // We will empty the realm, and pack the realm string to another
    // name (6-byte ".LOCAL"). Finally "krbtgt/[email protected]"
    // becomes ".LOCAL/krbtgt/MAXI.LOCAL@".

    // length of names is now 3
    ccache[0x55] = 3;
    // The empty realm
    System.arraycopy(new byte[4], 0, ccache, 0x56, 4);
    // Length of inserted name is 6
    System.arraycopy(new byte[]{0,0,0,6}, 0, ccache, 0x5A, 4);

    Files.write(Paths.get("tmpcc"), TimeInCCache.ccache);
    if (CredentialsCache.getInstance("tmpcc").getCredsList() != null) {
        throw new Exception("Nothing should be there");
    }
}
 
Example #19
Source File: CorruptedCC.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    for (int i=0; i<TimeInCCache.ccache.length; i++) {
        byte old = TimeInCCache.ccache[i];
        TimeInCCache.ccache[i] = 0x7f;
        Files.write(Paths.get("tmpcc"), TimeInCCache.ccache);
        // The next line will return null for I/O issues. That's OK.
        CredentialsCache.getInstance("tmpcc");
        TimeInCCache.ccache[i] = old;
    }
}
 
Example #20
Source File: CorruptedCC.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    for (int i=0; i<TimeInCCache.ccache.length; i++) {
        byte old = TimeInCCache.ccache[i];
        TimeInCCache.ccache[i] = 0x7f;
        Files.write(Paths.get("tmpcc"), TimeInCCache.ccache);
        // The next line will return null for I/O issues. That's OK.
        CredentialsCache.getInstance("tmpcc");
        TimeInCCache.ccache[i] = old;
    }
}
 
Example #21
Source File: EmptyCC.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    final PrincipalName pn = new PrincipalName("[email protected]");
    final String ccache = args[0];

    if (args.length == 1) {
        // Main process, write the ccache and launch sub process
        CredentialsCache cache = CredentialsCache.create(pn, ccache);
        cache.save();
        Proc p = Proc.create("EmptyCC").args(ccache, "readcc")
                .env("KRB5CCNAME", ccache).start();
        p.waitFor();
    } else {
        // Sub process, read the ccache
        String cc = System.getenv("KRB5CCNAME");
        if (!cc.equals(ccache)) {
            throw new Exception("env not set correctly");
        }
        // 8001208: Fix for KRB5CCNAME not complete
        // Make sure the ccache is created with bare file name
        if (CredentialsCache.getInstance() == null) {
            throw new Exception("Cache not instantiated");
        }
        if (!new File("tmpcc").exists()) {
            throw new Exception("File not found");
        }
        Credentials.acquireTGTFromCache(pn, null);
    }
}
 
Example #22
Source File: EmptyRealmCC.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    byte[] ccache = TimeInCCache.ccache;

    // The service name starts at 0x52:
    //
    //    0050:    00 00 00 02 00 00 00 0A 4D 41 58 49 2E 4C
    //             ----------- -----------
    //    0060: 4F 43 41 4C 00 00 00 06 6B 72 62 74 67 74 00 00
    //                      -----------                   -----
    //    0070: 00 0A 4D 41 58 49 2E 4C 4F 43 41 4C
    //          -----
    //
    // which contains 2 (the length of names), a 10-byte realm, a 6-byte
    // name[0], and a 10-byte name[1].

    // We will empty the realm, and pack the realm string to another
    // name (6-byte ".LOCAL"). Finally "krbtgt/[email protected]"
    // becomes ".LOCAL/krbtgt/MAXI.LOCAL@".

    // length of names is now 3
    ccache[0x55] = 3;
    // The empty realm
    System.arraycopy(new byte[4], 0, ccache, 0x56, 4);
    // Length of inserted name is 6
    System.arraycopy(new byte[]{0,0,0,6}, 0, ccache, 0x5A, 4);

    Files.write(Paths.get("tmpcc"), TimeInCCache.ccache);
    if (CredentialsCache.getInstance("tmpcc").getCredsList() != null) {
        throw new Exception("Nothing should be there");
    }
}
 
Example #23
Source File: EmptyCC.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    final PrincipalName pn = new PrincipalName("[email protected]");
    final String ccache = args[0];

    if (args.length == 1) {
        // Main process, write the ccache and launch sub process
        CredentialsCache cache = CredentialsCache.create(pn, ccache);
        cache.save();
        Proc p = Proc.create("EmptyCC").args(ccache, "readcc")
                .env("KRB5CCNAME", ccache).start();
        p.waitFor();
    } else {
        // Sub process, read the ccache
        String cc = System.getenv("KRB5CCNAME");
        if (!cc.equals(ccache)) {
            throw new Exception("env not set correctly");
        }
        // 8001208: Fix for KRB5CCNAME not complete
        // Make sure the ccache is created with bare file name
        if (CredentialsCache.getInstance() == null) {
            throw new Exception("Cache not instantiated");
        }
        if (!new File("tmpcc").exists()) {
            throw new Exception("File not found");
        }
        Credentials.acquireTGTFromCache(pn, null);
    }
}
 
Example #24
Source File: CorruptedCC.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    for (int i=0; i<TimeInCCache.ccache.length; i++) {
        byte old = TimeInCCache.ccache[i];
        TimeInCCache.ccache[i] = 0x7f;
        Files.write(Paths.get("tmpcc"), TimeInCCache.ccache);
        // The next line will return null for I/O issues. That's OK.
        CredentialsCache.getInstance("tmpcc");
        TimeInCCache.ccache[i] = old;
    }
}
 
Example #25
Source File: EmptyCC.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    final PrincipalName pn = new PrincipalName("[email protected]");
    final String ccache = args[0];

    if (args.length == 1) {
        // Main process, write the ccache and launch sub process
        CredentialsCache cache = CredentialsCache.create(pn, ccache);
        cache.save();
        Proc p = Proc.create("EmptyCC").args(ccache, "readcc")
                .env("KRB5CCNAME", ccache).start();
        p.waitFor();
    } else {
        // Sub process, read the ccache
        String cc = System.getenv("KRB5CCNAME");
        if (!cc.equals(ccache)) {
            throw new Exception("env not set correctly");
        }
        // 8001208: Fix for KRB5CCNAME not complete
        // Make sure the ccache is created with bare file name
        if (CredentialsCache.getInstance() == null) {
            throw new Exception("Cache not instantiated");
        }
        if (!new File("tmpcc").exists()) {
            throw new Exception("File not found");
        }
        Credentials.acquireTGTFromCache(pn, null);
    }
}
 
Example #26
Source File: EmptyRealmCC.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    byte[] ccache = TimeInCCache.ccache;

    // The service name starts at 0x52:
    //
    //    0050:    00 00 00 02 00 00 00 0A 4D 41 58 49 2E 4C
    //             ----------- -----------
    //    0060: 4F 43 41 4C 00 00 00 06 6B 72 62 74 67 74 00 00
    //                      -----------                   -----
    //    0070: 00 0A 4D 41 58 49 2E 4C 4F 43 41 4C
    //          -----
    //
    // which contains 2 (the length of names), a 10-byte realm, a 6-byte
    // name[0], and a 10-byte name[1].

    // We will empty the realm, and pack the realm string to another
    // name (6-byte ".LOCAL"). Finally "krbtgt/[email protected]"
    // becomes ".LOCAL/krbtgt/MAXI.LOCAL@".

    // length of names is now 3
    ccache[0x55] = 3;
    // The empty realm
    System.arraycopy(new byte[4], 0, ccache, 0x56, 4);
    // Length of inserted name is 6
    System.arraycopy(new byte[]{0,0,0,6}, 0, ccache, 0x5A, 4);

    Files.write(Paths.get("tmpcc"), TimeInCCache.ccache);
    if (CredentialsCache.getInstance("tmpcc").getCredsList() != null) {
        throw new Exception("Nothing should be there");
    }
}
 
Example #27
Source File: CorruptedCC.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    for (int i=0; i<TimeInCCache.ccache.length; i++) {
        byte old = TimeInCCache.ccache[i];
        TimeInCCache.ccache[i] = 0x7f;
        Files.write(Paths.get("tmpcc"), TimeInCCache.ccache);
        // The next line will return null for I/O issues. That's OK.
        CredentialsCache.getInstance("tmpcc");
        TimeInCCache.ccache[i] = old;
    }
}
 
Example #28
Source File: EmptyCC.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    final PrincipalName pn = new PrincipalName("[email protected]");
    final String ccache = args[0];

    if (args.length == 1) {
        // Main process, write the ccache and launch sub process
        CredentialsCache cache = CredentialsCache.create(pn, ccache);
        cache.save();
        Proc p = Proc.create("EmptyCC").args(ccache, "readcc")
                .env("KRB5CCNAME", ccache).start();
        p.waitFor();
    } else {
        // Sub process, read the ccache
        String cc = System.getenv("KRB5CCNAME");
        if (!cc.equals(ccache)) {
            throw new Exception("env not set correctly");
        }
        // 8001208: Fix for KRB5CCNAME not complete
        // Make sure the ccache is created with bare file name
        if (CredentialsCache.getInstance() == null) {
            throw new Exception("Cache not instantiated");
        }
        if (!new File("tmpcc").exists()) {
            throw new Exception("File not found");
        }
        Credentials.acquireTGTFromCache(pn, null);
    }
}
 
Example #29
Source File: EmptyRealmCC.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    byte[] ccache = TimeInCCache.ccache;

    // The service name starts at 0x52:
    //
    //    0050:    00 00 00 02 00 00 00 0A 4D 41 58 49 2E 4C
    //             ----------- -----------
    //    0060: 4F 43 41 4C 00 00 00 06 6B 72 62 74 67 74 00 00
    //                      -----------                   -----
    //    0070: 00 0A 4D 41 58 49 2E 4C 4F 43 41 4C
    //          -----
    //
    // which contains 2 (the length of names), a 10-byte realm, a 6-byte
    // name[0], and a 10-byte name[1].

    // We will empty the realm, and pack the realm string to another
    // name (6-byte ".LOCAL"). Finally "krbtgt/[email protected]"
    // becomes ".LOCAL/krbtgt/MAXI.LOCAL@".

    // length of names is now 3
    ccache[0x55] = 3;
    // The empty realm
    System.arraycopy(new byte[4], 0, ccache, 0x56, 4);
    // Length of inserted name is 6
    System.arraycopy(new byte[]{0,0,0,6}, 0, ccache, 0x5A, 4);

    Files.write(Paths.get("tmpcc"), TimeInCCache.ccache);
    if (CredentialsCache.getInstance("tmpcc").getCredsList() != null) {
        throw new Exception("Nothing should be there");
    }
}
 
Example #30
Source File: EmptyCC.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    final PrincipalName pn = new PrincipalName("[email protected]");
    final String ccache = args[0];

    if (args.length == 1) {
        // Main process, write the ccache and launch sub process
        CredentialsCache cache = CredentialsCache.create(pn, ccache);
        cache.save();
        Proc p = Proc.create("EmptyCC").args(ccache, "readcc")
                .env("KRB5CCNAME", ccache).start();
        p.waitFor();
    } else {
        // Sub process, read the ccache
        String cc = System.getenv("KRB5CCNAME");
        if (!cc.equals(ccache)) {
            throw new Exception("env not set correctly");
        }
        // 8001208: Fix for KRB5CCNAME not complete
        // Make sure the ccache is created with bare file name
        if (CredentialsCache.getInstance() == null) {
            throw new Exception("Cache not instantiated");
        }
        if (!new File("tmpcc").exists()) {
            throw new Exception("File not found");
        }
        Credentials.acquireTGTFromCache(pn, null);
    }
}