/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* ===========================================================================
* (C) Copyright IBM Corp. 1999 All Rights Reserved.
*
* Copyright 1997 The Open Group Research Institute. All rights reserved.
* ===========================================================================
*
*/
/**
* CredentialsCache stores credentials(tickets, session keys, etc) in a
* semi-permanent store
* for later use by different program.
*
* @author Yanni Zhang
* @author Ram Marti
*/
implements FileCCacheConstants {
public int version;
try {
} else {
}
// invalid cache name or the file doesn't exist
return null;
}
}
return fcc;
} catch (IOException e) {
// we don't handle it now, instead we return a null at the end.
if (DEBUG) {
e.printStackTrace();
}
} catch (KrbException e) {
// we don't handle it now, instead we return a null at the end.
if (DEBUG) {
e.printStackTrace();
}
}
return null;
}
}
try {
// invalid cache name or the file doesn't exist
return null;
}
return fcc;
}
catch (IOException e) {
}
catch (KrbException e) {
}
return null;
}
try {
return fcc;
}
catch (IOException e) {
if (DEBUG) {
e.printStackTrace();
}
} catch (KrbException e) {
if (DEBUG) {
e.printStackTrace();
}
}
return null;
}
private FileCredentialsCache() {
}
return true;
} else return false;
}
throws IOException, KrbException {
}
if (version == KRB5_FCC_FVNO_4) {
} else {
}
}
if (primaryPrincipal != null) {
if (!(primaryPrincipal.match(p))) {
throw new IOException("Primary principals don't match.");
}
} else
primaryPrincipal = p;
}
}
}
/**
* Updates the credentials list. If the specified credentials for the
* service is new, add it to the list. If there is an entry in the list,
* replace the old credentials with the new one.
* @param c the credentials.
*/
if (credentialsList != null) {
if (credentialsList.isEmpty()) {
} else {
boolean matched = false;
matched = true;
if (DEBUG) {
+ "Ticket matched, overwrite "
+ "the old one.");
}
}
}
}
if (matched == false) {
if (DEBUG) {
+ "not exactly matched, "
+ "add new one into cache.");
}
}
}
}
}
return primaryPrincipal;
}
/**
* Saves the credentials cache file to the disk.
*/
}
}
}
return false;
} else {
return false;
}
}
}
return true;
}
/**
* Returns the list of credentials entries in the cache file.
*/
return null;
} else {
}
return tmp;
}
}
} else {
return null;
} else {
return list[i];
}
}
}
}
return null;
}
}
/**
* Gets a credentials for a specified service.
* @param sname service principal name.
* @param srealm the realm that the service belongs to.
*/
return null;
} else {
return list[i];
}
}
}
return null;
}
return null;
} else {
return list[i];
}
}
}
}
return null;
}
/*
* Returns path name of the credentials cache file.
* The path name is searched in the following order:
*
* 1. KRB5CCNAME (bare file name without FILE:)
* 3. <user.home>/krb5cc_<user.name>
* 4. <user.home>/krb5cc (if can't get <user.name>)
*/
// The env var can start with TYPE:, we only support FILE: here.
}
return cache;
}
});
if (DEBUG) {
}
return name;
}
// get cache name from system.property
/*
* For Unix platforms we use the default cache name to be
* {user_home}/krb5_cc{user_name}
* Please note that for Windows 2K we will use LSA to get
* the TGT from the the default cache even before we come here;
* however when we create cache we will create a cache under
* {user_home}/krb5_cc{user_name} for non-Unix platforms including
* Windows 2K.
*/
long uid = 0;
try {
("com.sun.security.auth.module.UnixSystem");
if (DEBUG) {
name);
}
return name;
} catch (Exception e) {
if (DEBUG) {
"for Unix platforms " +
"Using user's home directory");
e.printStackTrace();
}
}
}
}
// we did not get the uid;
}
} else {
}
if (DEBUG) {
}
return name;
}
return null;
}
try {
// get full path name
// get absolute directory
// test if the directory exists
if (!(temp.isDirectory()))
}
} catch (IOException e) {
}
return fullname;
}
while (st.hasMoreTokens()) {
}
try {
Process p =
try {
if (DEBUG) {
e.printStackTrace();
}
return null;
}
}
});
if (p == null) {
// exception occured in execing the command
return null;
}
new BufferedReader
("KRB5CCNAME=")) {
break;
}
}
}
return s1;
} catch (Exception e) {
if (DEBUG) {
e.printStackTrace();
}
}
return null;
}
}