/*
* 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.
*/
/*
* Based largely on klist.c,
*
* Created by Scott Kovatch on 8/12/04.
*
*/
/*
* Statics for this module
*/
/*
* Function prototypes for internal routines
*/
static jobject BuildClientPrincipal(JNIEnv *env, krb5_context kcontext, krb5_principal principalName);
{
return NULL;
}
#ifdef DEBUG
#endif /* DEBUG */
return returnValue;
}
/*
* Class: sun_security_krb5_KrbCreds
* Method: JNI_OnLoad
*/
{
return JNI_EVERSION; /* JNI version not supported */
}
if (derValueConstructor == 0) {
printf("Couldn't find DerValue constructor\n");
return JNI_ERR;
}
#ifdef DEBUG
printf("Found DerValue constructor\n");
#endif /* DEBUG */
ticketConstructor = (*env)->GetMethodID(env, ticketClass, "<init>", "(Lsun/security/util/DerValue;)V");
if (derValueConstructor == 0) {
printf("Couldn't find Ticket constructor\n");
return JNI_ERR;
}
#ifdef DEBUG
printf("Found Ticket constructor\n");
#endif /* DEBUG */
principalNameConstructor = (*env)->GetMethodID(env, principalNameClass, "<init>", "(Ljava/lang/String;I)V");
if (principalNameConstructor == 0) {
printf("Couldn't find PrincipalName constructor\n");
return JNI_ERR;
}
#ifdef DEBUG
printf("Found PrincipalName constructor\n");
#endif /* DEBUG */
if (encryptionKeyConstructor == 0) {
printf("Couldn't find EncryptionKey constructor\n");
return JNI_ERR;
}
#ifdef DEBUG
printf("Found EncryptionKey constructor\n");
#endif /* DEBUG */
if (ticketFlagsConstructor == 0) {
printf("Couldn't find TicketFlags constructor\n");
return JNI_ERR;
}
#ifdef DEBUG
printf("Found TicketFlags constructor\n");
#endif /* DEBUG */
if (kerberosTimeConstructor == 0) {
printf("Couldn't find KerberosTime constructor\n");
return JNI_ERR;
}
#ifdef DEBUG
printf("Found KerberosTime constructor\n");
#endif /* DEBUG */
if (integerConstructor == 0) {
printf("Couldn't find Integer constructor\n");
return JNI_ERR;
}
#ifdef DEBUG
printf("Found Integer constructor\n");
#endif /* DEBUG */
if (hostAddressConstructor == 0) {
printf("Couldn't find HostAddress constructor\n");
return JNI_ERR;
}
#ifdef DEBUG
printf("Found HostAddress constructor\n");
#endif /* DEBUG */
hostAddressesConstructor = (*env)->GetMethodID(env, hostAddressesClass, "<init>", "([Lsun/security/krb5/internal/HostAddress;)V");
if (hostAddressesConstructor == 0) {
printf("Couldn't find HostAddresses constructor\n");
return JNI_ERR;
}
#ifdef DEBUG
printf("Found HostAddresses constructor\n");
#endif /* DEBUG */
#ifdef DEBUG
printf("Finished OnLoad processing\n");
#endif /* DEBUG */
return JNI_VERSION_1_2;
}
/*
* Class: sun_security_jgss_KrbCreds
* Method: JNI_OnUnload
*/
{
return; /* Nothing else we can do */
}
if (ticketClass != NULL) {
}
if (derValueClass != NULL) {
}
if (principalNameClass != NULL) {
}
if (encryptionKeyClass != NULL) {
}
if (ticketFlagsClass != NULL) {
}
if (kerberosTimeClass != NULL) {
}
if (javaLangStringClass != NULL) {
}
if (javaLangIntegerClass != NULL) {
}
if (hostAddressClass != NULL) {
}
if (hostAddressesClass != NULL) {
}
}
/*
* Class: sun_security_krb5_Credentials
* Method: acquireDefaultNativeCreds
* Signature: ()Lsun/security/krb5/Credentials;
*/
{
/* Initialize the Kerberos 5 context */
if (!err) {
}
if (!err) {
}
if (!err) {
}
if (!err) {
if (!err) {
}
if (!err) {
// For the default credentials we're only interested in the krbtgt server.
// Build a com.ibm.security.krb5.Ticket
// Get the encryption key
// and the ticket flags
// Get the timestamps out.
// Create the addresses object.
if (krbcredsConstructor == 0) {
"(Lsun/security/krb5/internal/Ticket;Lsun/security/krb5/PrincipalName;Lsun/security/krb5/PrincipalName;Lsun/security/krb5/EncryptionKey;Lsun/security/krb5/internal/TicketFlags;Lsun/security/krb5/internal/KerberosTime;Lsun/security/krb5/internal/KerberosTime;Lsun/security/krb5/internal/KerberosTime;Lsun/security/krb5/internal/KerberosTime;Lsun/security/krb5/internal/HostAddresses;)V");
if (krbcredsConstructor == 0) {
break;
}
}
// and now go build a KrbCreds object
env,
}
}
}
}
if (!err) {
}
if (!err) {
}
return krbCreds;
}
#pragma mark -
{
/* To build a Ticket, we first need to build a DerValue out of the EncodedTicket.
* But before we can do that, we need to make a byte array out of the ET.
*/
}
(*env)->SetByteArrayRegion(env, ary, (jsize) 0, encodedTicket->length, (jbyte *)encodedTicket->data);
}
}
}
return ticket;
}
// Get the full principal string.
if (!err) {
// Make a PrincipalName from the full string and the type. Let the PrincipalName class parse it out.
principal = (*env)->NewObject(env, principalNameClass, principalNameConstructor, principalStringObj, principalName->type);
}
return principal;
}
// First, need to build a byte array
encryptionKey = (*env)->NewObject(env, encryptionKeyClass, encryptionKeyConstructor, cryptoKey->enctype, ary);
}
return encryptionKey;
}
/*
* Convert the bytes to network byte order before copying
* them to a Java byte array.
*/
ticketFlags = (*env)->NewObject(env, ticketFlagsClass, ticketFlagsConstructor, sizeof(flags)*8, ary);
}
return ticketFlags;
}
// Kerberos time is in seconds, but the KerberosTime class assumes milliseconds, so multiply by 1000.
time *= 1000;
}
return NULL;
}
int addressCount = 0;
// See how many we have.
krb5_address **p = addresses;
while (*p != 0) {
addressCount++;
p++;
}
// Create a new HostAddress object for each address block.
// First, reset the iterator.
p = addresses;
while (*p != 0) {
// HostAddres needs a byte array of the host data.
(*env)->SetByteArrayRegion(env, ary, (jsize) 0, currAddress->length, (jbyte *)currAddress->contents);
jobject address = (*env)->NewObject(env, hostAddressClass, hostAddressConstructor, currAddress->length, ary);
// Add the HostAddress to the arrray.
index++;
p++;
}
return address_list;
}
{
if (err) {
}
}