Java Code Examples for sun.security.krb5.internal.ccache.CredentialsCache#getInstance()
The following examples show how to use
sun.security.krb5.internal.ccache.CredentialsCache#getInstance() .
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: EmptyCC.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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 2
Source File: CorruptedCC.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
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 3
Source File: CorruptedCC.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
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 4
Source File: EmptyCC.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
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 5
Source File: CorruptedCC.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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 6
Source File: CorruptedCC.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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: EmptyCC.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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 8
Source File: CorruptedCC.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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 9
Source File: CorruptedCC.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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 10
Source File: EmptyCC.java From hottub with GNU General Public License v2.0 | 5 votes |
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 11
Source File: Credentials.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
/** * Acquires default credentials. * <br>The possible locations for default credentials cache is searched in * the following order: * <ol> * <li> The directory and cache file name specified by "KRB5CCNAME" system. * property. * <li> The directory and cache file name specified by "KRB5CCNAME" * environment variable. * <li> A cache file named krb5cc_{user.name} at {user.home} directory. * </ol> * @return a <code>KrbCreds</code> object if the credential is found, * otherwise return null. */ // this method is intentionally changed to not check if the caller's // principal name matches cache file's principal name. // It assumes that the GSS call has // the privilege to access the default cache file. // This method is only called on Windows and Mac OS X, the native // acquireDefaultNativeCreds is also available on these platforms. public static synchronized Credentials acquireDefaultCreds() { Credentials result = null; if (cache == null) { cache = CredentialsCache.getInstance(); } if (cache != null) { Credentials temp = cache.getInitialCreds(); if (temp != null) { if (DEBUG) { System.out.println(">>> KrbCreds found the default ticket" + " granting ticket in credential cache."); } if (EType.isSupported(temp.key.getEType())) { result = temp; } else { if (DEBUG) { System.out.println( ">>> unsupported key type found the default TGT: " + temp.key.getEType()); } } } } if (result == null) { // Doesn't seem to be a default cache on this system or // TGT has unsupported encryption type if (!alreadyTried) { // See if there's any native code to load try { ensureLoaded(); } catch (Exception e) { if (DEBUG) { System.out.println("Can not load credentials cache"); e.printStackTrace(); } alreadyTried = true; } } if (alreadyLoaded) { // There is some native code if (DEBUG) { System.out.println(">> Acquire default native Credentials"); } try { result = acquireDefaultNativeCreds( EType.getDefaults("default_tkt_enctypes")); } catch (KrbException ke) { // when there is no default_tkt_enctypes. } } } return result; }
Example 12
Source File: Credentials.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Returns a TGT for the given client principal from a ticket cache. * * @param princ the client principal. A value of null means that the * default principal name in the credentials cache will be used. * @param ticketCache the path to the tickets file. A value * of null will be accepted to indicate that the default * path should be searched * @returns the TGT credentials or null if none were found. If the tgt * expired, it is the responsibility of the caller to determine this. */ public static Credentials acquireTGTFromCache(PrincipalName princ, String ticketCache) throws KrbException, IOException { if (ticketCache == null) { // The default ticket cache on Windows and Mac is not a file. String os = java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction("os.name")); if (os.toUpperCase(Locale.ENGLISH).startsWith("WINDOWS") || os.toUpperCase(Locale.ENGLISH).contains("OS X")) { Credentials creds = acquireDefaultCreds(); if (creds == null) { if (DEBUG) { System.out.println(">>> Found no TGT's in LSA"); } return null; } if (princ != null) { if (creds.getClient().equals(princ)) { if (DEBUG) { System.out.println(">>> Obtained TGT from LSA: " + creds); } return creds; } else { if (DEBUG) { System.out.println(">>> LSA contains TGT for " + creds.getClient() + " not " + princ); } return null; } } else { if (DEBUG) { System.out.println(">>> Obtained TGT from LSA: " + creds); } return creds; } } } /* * Returns the appropriate cache. If ticketCache is null, it is the * default cache otherwise it is the cache filename contained in it. */ CredentialsCache ccache = CredentialsCache.getInstance(princ, ticketCache); if (ccache == null) { return null; } sun.security.krb5.internal.ccache.Credentials tgtCred = ccache.getDefaultCreds(); if (tgtCred == null) { return null; } if (EType.isSupported(tgtCred.getEType())) { return tgtCred.setKrbCreds(); } else { if (DEBUG) { System.out.println( ">>> unsupported key type found the default TGT: " + tgtCred.getEType()); } return null; } }
Example 13
Source File: Credentials.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * Returns a TGT for the given client principal from a ticket cache. * * @param princ the client principal. A value of null means that the * default principal name in the credentials cache will be used. * @param ticketCache the path to the tickets file. A value * of null will be accepted to indicate that the default * path should be searched * @returns the TGT credentials or null if none were found. If the tgt * expired, it is the responsibility of the caller to determine this. */ public static Credentials acquireTGTFromCache(PrincipalName princ, String ticketCache) throws KrbException, IOException { if (ticketCache == null) { // The default ticket cache on Windows and Mac is not a file. String os = java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction("os.name")); if (os.toUpperCase(Locale.ENGLISH).startsWith("WINDOWS") || os.toUpperCase(Locale.ENGLISH).contains("OS X")) { Credentials creds = acquireDefaultCreds(); if (creds == null) { if (DEBUG) { System.out.println(">>> Found no TGT's in LSA"); } return null; } if (princ != null) { if (creds.getClient().equals(princ)) { if (DEBUG) { System.out.println(">>> Obtained TGT from LSA: " + creds); } return creds; } else { if (DEBUG) { System.out.println(">>> LSA contains TGT for " + creds.getClient() + " not " + princ); } return null; } } else { if (DEBUG) { System.out.println(">>> Obtained TGT from LSA: " + creds); } return creds; } } } /* * Returns the appropriate cache. If ticketCache is null, it is the * default cache otherwise it is the cache filename contained in it. */ CredentialsCache ccache = CredentialsCache.getInstance(princ, ticketCache); if (ccache == null) { return null; } sun.security.krb5.internal.ccache.Credentials tgtCred = ccache.getDefaultCreds(); if (tgtCred == null) { return null; } if (EType.isSupported(tgtCred.getEType())) { return tgtCred.setKrbCreds(); } else { if (DEBUG) { System.out.println( ">>> unsupported key type found the default TGT: " + tgtCred.getEType()); } return null; } }
Example 14
Source File: Credentials.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * Acquires default credentials. * <br>The possible locations for default credentials cache is searched in * the following order: * <ol> * <li> The directory and cache file name specified by "KRB5CCNAME" system. * property. * <li> The directory and cache file name specified by "KRB5CCNAME" * environment variable. * <li> A cache file named krb5cc_{user.name} at {user.home} directory. * </ol> * @return a <code>KrbCreds</code> object if the credential is found, * otherwise return null. */ // this method is intentionally changed to not check if the caller's // principal name matches cache file's principal name. // It assumes that the GSS call has // the privilege to access the default cache file. // This method is only called on Windows and Mac OS X, the native // acquireDefaultNativeCreds is also available on these platforms. public static synchronized Credentials acquireDefaultCreds() { Credentials result = null; if (cache == null) { cache = CredentialsCache.getInstance(); } if (cache != null) { Credentials temp = cache.getInitialCreds(); if (temp != null) { if (DEBUG) { System.out.println(">>> KrbCreds found the default ticket" + " granting ticket in credential cache."); } if (EType.isSupported(temp.key.getEType())) { result = temp; } else { if (DEBUG) { System.out.println( ">>> unsupported key type found the default TGT: " + temp.key.getEType()); } } } } if (result == null) { // Doesn't seem to be a default cache on this system or // TGT has unsupported encryption type if (!alreadyTried) { // See if there's any native code to load try { ensureLoaded(); } catch (Exception e) { if (DEBUG) { System.out.println("Can not load credentials cache"); e.printStackTrace(); } alreadyTried = true; } } if (alreadyLoaded) { // There is some native code if (DEBUG) { System.out.println(">> Acquire default native Credentials"); } try { result = acquireDefaultNativeCreds( EType.getDefaults("default_tkt_enctypes")); } catch (KrbException ke) { // when there is no default_tkt_enctypes. } } } return result; }
Example 15
Source File: Credentials.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
/** * Returns a TGT for the given client principal from a ticket cache. * * @param princ the client principal. A value of null means that the * default principal name in the credentials cache will be used. * @param ticketCache the path to the tickets file. A value * of null will be accepted to indicate that the default * path should be searched * @returns the TGT credentials or null if none were found. If the tgt * expired, it is the responsibility of the caller to determine this. */ public static Credentials acquireTGTFromCache(PrincipalName princ, String ticketCache) throws KrbException, IOException { if (ticketCache == null) { // The default ticket cache on Windows and Mac is not a file. String os = java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction("os.name")); if (os.toUpperCase(Locale.ENGLISH).startsWith("WINDOWS") || os.toUpperCase(Locale.ENGLISH).contains("OS X")) { Credentials creds = acquireDefaultCreds(); if (creds == null) { if (DEBUG) { System.out.println(">>> Found no TGT's in LSA"); } return null; } if (princ != null) { if (creds.getClient().equals(princ)) { if (DEBUG) { System.out.println(">>> Obtained TGT from LSA: " + creds); } return creds; } else { if (DEBUG) { System.out.println(">>> LSA contains TGT for " + creds.getClient() + " not " + princ); } return null; } } else { if (DEBUG) { System.out.println(">>> Obtained TGT from LSA: " + creds); } return creds; } } } /* * Returns the appropriate cache. If ticketCache is null, it is the * default cache otherwise it is the cache filename contained in it. */ CredentialsCache ccache = CredentialsCache.getInstance(princ, ticketCache); if (ccache == null) { return null; } sun.security.krb5.internal.ccache.Credentials tgtCred = ccache.getDefaultCreds(); if (tgtCred == null) { return null; } if (EType.isSupported(tgtCred.getEType())) { return tgtCred.setKrbCreds(); } else { if (DEBUG) { System.out.println( ">>> unsupported key type found the default TGT: " + tgtCred.getEType()); } return null; } }
Example 16
Source File: Credentials.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * Returns a TGT for the given client principal from a ticket cache. * * @param princ the client principal. A value of null means that the * default principal name in the credentials cache will be used. * @param ticketCache the path to the tickets file. A value * of null will be accepted to indicate that the default * path should be searched * @returns the TGT credentials or null if none were found. If the tgt * expired, it is the responsibility of the caller to determine this. */ public static Credentials acquireTGTFromCache(PrincipalName princ, String ticketCache) throws KrbException, IOException { if (ticketCache == null) { // The default ticket cache on Windows and Mac is not a file. String os = java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction("os.name")); if (os.toUpperCase(Locale.ENGLISH).startsWith("WINDOWS") || os.toUpperCase(Locale.ENGLISH).contains("OS X")) { Credentials creds = acquireDefaultCreds(); if (creds == null) { if (DEBUG) { System.out.println(">>> Found no TGT's in LSA"); } return null; } if (princ != null) { if (creds.getClient().equals(princ)) { if (DEBUG) { System.out.println(">>> Obtained TGT from LSA: " + creds); } return creds; } else { if (DEBUG) { System.out.println(">>> LSA contains TGT for " + creds.getClient() + " not " + princ); } return null; } } else { if (DEBUG) { System.out.println(">>> Obtained TGT from LSA: " + creds); } return creds; } } } /* * Returns the appropriate cache. If ticketCache is null, it is the * default cache otherwise it is the cache filename contained in it. */ CredentialsCache ccache = CredentialsCache.getInstance(princ, ticketCache); if (ccache == null) { return null; } sun.security.krb5.internal.ccache.Credentials tgtCred = ccache.getDefaultCreds(); if (tgtCred == null) { return null; } if (EType.isSupported(tgtCred.getEType())) { return tgtCred.setKrbCreds(); } else { if (DEBUG) { System.out.println( ">>> unsupported key type found the default TGT: " + tgtCred.getEType()); } return null; } }
Example 17
Source File: Credentials.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
/** * Returns a TGT for the given client principal from a ticket cache. * * @param princ the client principal. A value of null means that the * default principal name in the credentials cache will be used. * @param ticketCache the path to the tickets file. A value * of null will be accepted to indicate that the default * path should be searched * @return the TGT credentials or null if none were found. If the tgt * expired, it is the responsibility of the caller to determine this. */ public static Credentials acquireTGTFromCache(PrincipalName princ, String ticketCache) throws KrbException, IOException { if (ticketCache == null) { // The default ticket cache on Windows and Mac is not a file. String os = java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction("os.name")); if (os.toUpperCase(Locale.ENGLISH).startsWith("WINDOWS") || os.toUpperCase(Locale.ENGLISH).contains("OS X")) { Credentials creds = acquireDefaultCreds(); if (creds == null) { if (DEBUG) { System.out.println(">>> Found no TGT's in LSA"); } return null; } if (princ != null) { if (creds.getClient().equals(princ)) { if (DEBUG) { System.out.println(">>> Obtained TGT from LSA: " + creds); } return creds; } else { if (DEBUG) { System.out.println(">>> LSA contains TGT for " + creds.getClient() + " not " + princ); } return null; } } else { if (DEBUG) { System.out.println(">>> Obtained TGT from LSA: " + creds); } return creds; } } } /* * Returns the appropriate cache. If ticketCache is null, it is the * default cache otherwise it is the cache filename contained in it. */ CredentialsCache ccache = CredentialsCache.getInstance(princ, ticketCache); if (ccache == null) { return null; } Credentials tgtCred = ccache.getInitialCreds(); if (tgtCred == null) { return null; } if (EType.isSupported(tgtCred.key.getEType())) { return tgtCred; } else { if (DEBUG) { System.out.println( ">>> unsupported key type found the default TGT: " + tgtCred.key.getEType()); } return null; } }
Example 18
Source File: Credentials.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Acquires default credentials. * <br>The possible locations for default credentials cache is searched in * the following order: * <ol> * <li> The directory and cache file name specified by "KRB5CCNAME" system. * property. * <li> The directory and cache file name specified by "KRB5CCNAME" * environment variable. * <li> A cache file named krb5cc_{user.name} at {user.home} directory. * </ol> * @return a <code>KrbCreds</code> object if the credential is found, * otherwise return null. */ // this method is intentionally changed to not check if the caller's // principal name matches cache file's principal name. // It assumes that the GSS call has // the privilege to access the default cache file. // This method is only called on Windows and Mac OS X, the native // acquireDefaultNativeCreds is also available on these platforms. public static synchronized Credentials acquireDefaultCreds() { Credentials result = null; if (cache == null) { cache = CredentialsCache.getInstance(); } if (cache != null) { Credentials temp = cache.getInitialCreds(); if (temp != null) { if (DEBUG) { System.out.println(">>> KrbCreds found the default ticket" + " granting ticket in credential cache."); } if (EType.isSupported(temp.key.getEType())) { result = temp; } else { if (DEBUG) { System.out.println( ">>> unsupported key type found the default TGT: " + temp.key.getEType()); } } } } if (result == null) { // Doesn't seem to be a default cache on this system or // TGT has unsupported encryption type if (!alreadyTried) { // See if there's any native code to load try { ensureLoaded(); } catch (Exception e) { if (DEBUG) { System.out.println("Can not load credentials cache"); e.printStackTrace(); } alreadyTried = true; } } if (alreadyLoaded) { // There is some native code if (DEBUG) { System.out.println(">> Acquire default native Credentials"); } try { result = acquireDefaultNativeCreds( EType.getDefaults("default_tkt_enctypes")); } catch (KrbException ke) { // when there is no default_tkt_enctypes. } } } return result; }
Example 19
Source File: Credentials.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Acquires default credentials. * <br>The possible locations for default credentials cache is searched in * the following order: * <ol> * <li> The directory and cache file name specified by "KRB5CCNAME" system. * property. * <li> The directory and cache file name specified by "KRB5CCNAME" * environment variable. * <li> A cache file named krb5cc_{user.name} at {user.home} directory. * </ol> * @return a <code>KrbCreds</code> object if the credential is found, * otherwise return null. */ // this method is intentionally changed to not check if the caller's // principal name matches cache file's principal name. // It assumes that the GSS call has // the privilege to access the default cache file. // This method is only called on Windows and Mac OS X, the native // acquireDefaultNativeCreds is also available on these platforms. public static synchronized Credentials acquireDefaultCreds() { Credentials result = null; if (cache == null) { cache = CredentialsCache.getInstance(); } if (cache != null) { sun.security.krb5.internal.ccache.Credentials temp = cache.getDefaultCreds(); if (temp != null) { if (DEBUG) { System.out.println(">>> KrbCreds found the default ticket" + " granting ticket in credential cache."); } if (EType.isSupported(temp.getEType())) { result = temp.setKrbCreds(); } else { if (DEBUG) { System.out.println( ">>> unsupported key type found the default TGT: " + temp.getEType()); } } } } if (result == null) { // Doesn't seem to be a default cache on this system or // TGT has unsupported encryption type if (!alreadyTried) { // See if there's any native code to load try { ensureLoaded(); } catch (Exception e) { if (DEBUG) { System.out.println("Can not load credentials cache"); e.printStackTrace(); } alreadyTried = true; } } if (alreadyLoaded) { // There is some native code if (DEBUG) { System.out.println(">> Acquire default native Credentials"); } try { result = acquireDefaultNativeCreds( EType.getDefaults("default_tkt_enctypes")); } catch (KrbException ke) { // when there is no default_tkt_enctypes. } } } return result; }
Example 20
Source File: Credentials.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
/** * Acquires default credentials. * <br>The possible locations for default credentials cache is searched in * the following order: * <ol> * <li> The directory and cache file name specified by "KRB5CCNAME" system. * property. * <li> The directory and cache file name specified by "KRB5CCNAME" * environment variable. * <li> A cache file named krb5cc_{user.name} at {user.home} directory. * </ol> * @return a <code>KrbCreds</code> object if the credential is found, * otherwise return null. */ // this method is intentionally changed to not check if the caller's // principal name matches cache file's principal name. // It assumes that the GSS call has // the privilege to access the default cache file. // This method is only called on Windows and Mac OS X, the native // acquireDefaultNativeCreds is also available on these platforms. public static synchronized Credentials acquireDefaultCreds() { Credentials result = null; if (cache == null) { cache = CredentialsCache.getInstance(); } if (cache != null) { Credentials temp = cache.getInitialCreds(); if (temp != null) { if (DEBUG) { System.out.println(">>> KrbCreds found the default ticket" + " granting ticket in credential cache."); } if (EType.isSupported(temp.key.getEType())) { result = temp; } else { if (DEBUG) { System.out.println( ">>> unsupported key type found the default TGT: " + temp.key.getEType()); } } } } if (result == null) { // Doesn't seem to be a default cache on this system or // TGT has unsupported encryption type if (!alreadyTried) { // See if there's any native code to load try { ensureLoaded(); } catch (Exception e) { if (DEBUG) { System.out.println("Can not load credentials cache"); e.printStackTrace(); } alreadyTried = true; } } if (alreadyLoaded) { // There is some native code if (DEBUG) { System.out.println(">> Acquire default native Credentials"); } try { result = acquireDefaultNativeCreds( EType.getDefaults("default_tkt_enctypes")); } catch (KrbException ke) { // when there is no default_tkt_enctypes. } } } return result; }