8228659: Record which Java methods are called by native codes in JGSS and JAAS
Reviewed-by: mullan
This commit is contained in:
parent
83b11a570a
commit
12c278c3e3
@ -43,7 +43,6 @@
|
||||
* Statics for this module
|
||||
*/
|
||||
|
||||
static jclass derValueClass = NULL;
|
||||
static jclass ticketClass = NULL;
|
||||
static jclass principalNameClass = NULL;
|
||||
static jclass encryptionKeyClass = NULL;
|
||||
@ -54,7 +53,6 @@ static jclass javaLangIntegerClass = NULL;
|
||||
static jclass hostAddressClass = NULL;
|
||||
static jclass hostAddressesClass = NULL;
|
||||
|
||||
static jmethodID derValueConstructor = 0;
|
||||
static jmethodID ticketConstructor = 0;
|
||||
static jmethodID principalNameConstructor = 0;
|
||||
static jmethodID encryptionKeyConstructor = 0;
|
||||
@ -108,9 +106,6 @@ JNIEXPORT jint JNICALL DEF_JNI_OnLoad(JavaVM *jvm, void *reserved)
|
||||
principalNameClass = FindClass(env, "sun/security/krb5/PrincipalName");
|
||||
if (principalNameClass == NULL) return JNI_ERR;
|
||||
|
||||
derValueClass = FindClass(env, "sun/security/util/DerValue");
|
||||
if (derValueClass == NULL) return JNI_ERR;
|
||||
|
||||
encryptionKeyClass = FindClass(env, "sun/security/krb5/EncryptionKey");
|
||||
if (encryptionKeyClass == NULL) return JNI_ERR;
|
||||
|
||||
@ -132,13 +127,7 @@ JNIEXPORT jint JNICALL DEF_JNI_OnLoad(JavaVM *jvm, void *reserved)
|
||||
hostAddressesClass = FindClass(env,"sun/security/krb5/internal/HostAddresses");
|
||||
if (hostAddressesClass == NULL) return JNI_ERR;
|
||||
|
||||
derValueConstructor = (*env)->GetMethodID(env, derValueClass, "<init>", "([B)V");
|
||||
if (derValueConstructor == 0) {
|
||||
printf("Couldn't find DerValue constructor\n");
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
ticketConstructor = (*env)->GetMethodID(env, ticketClass, "<init>", "(Lsun/security/util/DerValue;)V");
|
||||
ticketConstructor = (*env)->GetMethodID(env, ticketClass, "<init>", "([B)V");
|
||||
if (ticketConstructor == 0) {
|
||||
printf("Couldn't find Ticket constructor\n");
|
||||
return JNI_ERR;
|
||||
@ -204,9 +193,6 @@ JNIEXPORT void JNICALL DEF_JNI_OnUnload(JavaVM *jvm, void *reserved)
|
||||
if (ticketClass != NULL) {
|
||||
(*env)->DeleteWeakGlobalRef(env,ticketClass);
|
||||
}
|
||||
if (derValueClass != NULL) {
|
||||
(*env)->DeleteWeakGlobalRef(env,derValueClass);
|
||||
}
|
||||
if (principalNameClass != NULL) {
|
||||
(*env)->DeleteWeakGlobalRef(env,principalNameClass);
|
||||
}
|
||||
@ -421,11 +407,9 @@ cleanup:
|
||||
|
||||
jobject BuildTicket(JNIEnv *env, krb5_data *encodedTicket)
|
||||
{
|
||||
/* 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.
|
||||
*/
|
||||
// To build a Ticket, we need to make a byte array out of the EncodedTicket.
|
||||
|
||||
jobject derValue, ticket;
|
||||
jobject ticket;
|
||||
jbyteArray ary;
|
||||
|
||||
ary = (*env)->NewByteArray(env, encodedTicket->length);
|
||||
@ -439,19 +423,12 @@ jobject BuildTicket(JNIEnv *env, krb5_data *encodedTicket)
|
||||
return (jobject) NULL;
|
||||
}
|
||||
|
||||
derValue = (*env)->NewObject(env, derValueClass, derValueConstructor, ary);
|
||||
ticket = (*env)->NewObject(env, ticketClass, ticketConstructor, ary);
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
(*env)->DeleteLocalRef(env, ary);
|
||||
return (jobject) NULL;
|
||||
}
|
||||
|
||||
(*env)->DeleteLocalRef(env, ary);
|
||||
ticket = (*env)->NewObject(env, ticketClass, ticketConstructor, derValue);
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
(*env)->DeleteLocalRef(env, derValue);
|
||||
return (jobject) NULL;
|
||||
}
|
||||
(*env)->DeleteLocalRef(env, derValue);
|
||||
return ticket;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -61,6 +61,7 @@ public class GSSCredElement implements GSSCredentialSpi {
|
||||
}
|
||||
|
||||
// Construct delegation cred using the actual context mech and srcName
|
||||
// Warning: called by NativeUtil.c
|
||||
GSSCredElement(long pCredentials, GSSNameElement srcName, Oid mech)
|
||||
throws GSSException {
|
||||
pCred = pCredentials;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -43,7 +43,7 @@ import sun.security.jgss.GSSUtil;
|
||||
class GSSLibStub {
|
||||
|
||||
private Oid mech;
|
||||
private long pMech;
|
||||
private long pMech; // Warning: used by NativeUtil.c
|
||||
|
||||
/**
|
||||
* Initialization routine to dynamically load function pointers.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -97,6 +97,7 @@ public class GSSNameElement implements GSSNameSpi {
|
||||
printableName = "<DEFAULT ACCEPTOR>";
|
||||
}
|
||||
|
||||
// Warning: called by NativeUtil.c
|
||||
GSSNameElement(long pNativeName, GSSLibStub stub) throws GSSException {
|
||||
assert(stub != null);
|
||||
if (pNativeName == 0) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -59,20 +59,22 @@ class NativeGSSContext implements GSSContextSpi {
|
||||
|
||||
private static final int NUM_OF_INQUIRE_VALUES = 6;
|
||||
|
||||
// Warning: The following 9 fields are used by NativeUtil.c
|
||||
private long pContext = 0; // Pointer to the gss_ctx_id_t structure
|
||||
private GSSNameElement srcName;
|
||||
private GSSNameElement targetName;
|
||||
private GSSCredElement cred;
|
||||
private GSSCredElement disposeCred;
|
||||
private boolean isInitiator;
|
||||
private boolean isEstablished;
|
||||
private Oid actualMech; // Assigned during context establishment
|
||||
|
||||
private ChannelBinding cb;
|
||||
private GSSCredElement delegatedCred;
|
||||
private GSSCredElement disposeDelegatedCred;
|
||||
private int flags;
|
||||
private int lifetime = GSSCredential.DEFAULT_LIFETIME;
|
||||
private Oid actualMech; // Assigned during context establishment
|
||||
|
||||
private GSSCredElement cred;
|
||||
private GSSCredElement disposeCred;
|
||||
|
||||
private ChannelBinding cb;
|
||||
private GSSCredElement disposeDelegatedCred;
|
||||
private final GSSLibStub cStub;
|
||||
|
||||
private boolean skipDelegPermCheck;
|
||||
@ -231,6 +233,7 @@ class NativeGSSContext implements GSSContextSpi {
|
||||
}
|
||||
|
||||
// Constructor for imported context
|
||||
// Warning: called by NativeUtil.c
|
||||
NativeGSSContext(long pCtxt, GSSLibStub stub) throws GSSException {
|
||||
assert(pContext != 0);
|
||||
pContext = pCtxt;
|
||||
|
@ -88,6 +88,7 @@ public class Credentials {
|
||||
this.authzData = authzData;
|
||||
}
|
||||
|
||||
// Warning: called by NativeCreds.c and nativeccache.c
|
||||
public Credentials(Ticket new_ticket,
|
||||
PrincipalName new_client,
|
||||
PrincipalName new_client_alias,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -218,8 +218,8 @@ public class EncryptionKey
|
||||
* credential cache file.
|
||||
*
|
||||
*/
|
||||
// Used in JSSE (KerberosWrapper), Credentials,
|
||||
// javax.security.auth.kerberos.KeyImpl
|
||||
// Used in Credentials, and javax.security.auth.kerberos.KeyImpl
|
||||
// Warning: called by NativeCreds.c and nativeccache.c
|
||||
public EncryptionKey(int keyType,
|
||||
byte[] keyValue) {
|
||||
this(keyValue, keyType, null);
|
||||
|
@ -158,7 +158,7 @@ public class PrincipalName implements Cloneable {
|
||||
this.realmDeduced = false;
|
||||
}
|
||||
|
||||
// This method is called by Windows NativeCred.c
|
||||
// Warning: called by NativeCreds.c
|
||||
public PrincipalName(String[] nameParts, String realm) throws RealmException {
|
||||
this(KRB_NT_UNKNOWN, nameParts, new Realm(realm));
|
||||
}
|
||||
@ -484,6 +484,7 @@ public class PrincipalName implements Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
// Warning: called by nativeccache.c
|
||||
public PrincipalName(String name, int type) throws RealmException {
|
||||
this(name, type, (String)null);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -165,6 +165,8 @@ public class HostAddress implements Cloneable {
|
||||
/**
|
||||
* Creates a HostAddress from the specified address and address type.
|
||||
*
|
||||
* Warning: called by nativeccache.c.
|
||||
*
|
||||
* @param new_addrType the value of the address type which matches the defined
|
||||
* address family constants in the Berkeley Standard
|
||||
* Distributions of Unix.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -68,6 +68,7 @@ public class HostAddresses implements Cloneable {
|
||||
private HostAddress[] addresses = null;
|
||||
private volatile int hashCode = 0;
|
||||
|
||||
// Warning: called by nativeccache.c
|
||||
public HostAddresses(HostAddress[] new_addresses) throws IOException {
|
||||
if (new_addresses != null) {
|
||||
addresses = new HostAddress[new_addresses.length];
|
||||
|
@ -88,8 +88,7 @@ public class KerberosTime {
|
||||
this(time, 0);
|
||||
}
|
||||
|
||||
// This constructor is used in the native code
|
||||
// src/windows/native/sun/security/krb5/NativeCreds.c
|
||||
// Warning: called by NativeCreds.c and nativeccache.c
|
||||
public KerberosTime(String time) throws Asn1Exception {
|
||||
this(toKerberosTime(time), 0);
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ public class Krb5 {
|
||||
return errMsgList.get(i);
|
||||
}
|
||||
|
||||
|
||||
// Warning: used by NativeCreds.c
|
||||
public static final boolean DEBUG = GetBooleanAction
|
||||
.privilegedGetProperty("sun.security.krb5.debug");
|
||||
|
||||
|
@ -83,6 +83,7 @@ public class Ticket implements Cloneable {
|
||||
encPart = new_encPart;
|
||||
}
|
||||
|
||||
// Warning: called by NativeCreds.c and nativeccache.c
|
||||
public Ticket(byte[] data) throws Asn1Exception,
|
||||
RealmException, KrbApErrException, IOException {
|
||||
init(new DerValue(data));
|
||||
|
@ -67,6 +67,7 @@ public class TicketFlags extends KerberosFlags {
|
||||
}
|
||||
}
|
||||
|
||||
// Warning: called by NativeCreds.c and nativeccache.c
|
||||
public TicketFlags(int size, byte[] data) throws Asn1Exception {
|
||||
super(size, data);
|
||||
if ((size > data.length * BITS_PER_UNIT) || (size > Krb5.TKT_OPTS_MAX + 1))
|
||||
|
@ -54,7 +54,6 @@
|
||||
* Library-wide static references
|
||||
*/
|
||||
|
||||
jclass derValueClass = NULL;
|
||||
jclass ticketClass = NULL;
|
||||
jclass principalNameClass = NULL;
|
||||
jclass encryptionKeyClass = NULL;
|
||||
@ -62,7 +61,6 @@ jclass ticketFlagsClass = NULL;
|
||||
jclass kerberosTimeClass = NULL;
|
||||
jclass javaLangStringClass = NULL;
|
||||
|
||||
jmethodID derValueConstructor = 0;
|
||||
jmethodID ticketConstructor = 0;
|
||||
jmethodID principalNameConstructor = 0;
|
||||
jmethodID encryptionKeyConstructor = 0;
|
||||
@ -172,24 +170,6 @@ JNIEXPORT jint JNICALL DEF_JNI_OnLoad(
|
||||
printf("LSA: Made NewWeakGlobalRef\n");
|
||||
}
|
||||
|
||||
cls = (*env)->FindClass(env,"sun/security/util/DerValue");
|
||||
|
||||
if (cls == NULL) {
|
||||
printf("LSA: Couldn't find DerValue\n");
|
||||
return JNI_ERR;
|
||||
}
|
||||
if (native_debug) {
|
||||
printf("LSA: Found DerValue\n");
|
||||
}
|
||||
|
||||
derValueClass = (*env)->NewWeakGlobalRef(env,cls);
|
||||
if (derValueClass == NULL) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
if (native_debug) {
|
||||
printf("LSA: Made NewWeakGlobalRef\n");
|
||||
}
|
||||
|
||||
cls = (*env)->FindClass(env,"sun/security/krb5/EncryptionKey");
|
||||
|
||||
if (cls == NULL) {
|
||||
@ -262,18 +242,8 @@ JNIEXPORT jint JNICALL DEF_JNI_OnLoad(
|
||||
printf("LSA: Made NewWeakGlobalRef\n");
|
||||
}
|
||||
|
||||
derValueConstructor = (*env)->GetMethodID(env, derValueClass,
|
||||
"<init>", "([B)V");
|
||||
if (derValueConstructor == 0) {
|
||||
printf("LSA: Couldn't find DerValue constructor\n");
|
||||
return JNI_ERR;
|
||||
}
|
||||
if (native_debug) {
|
||||
printf("LSA: Found DerValue constructor\n");
|
||||
}
|
||||
|
||||
ticketConstructor = (*env)->GetMethodID(env, ticketClass,
|
||||
"<init>", "(Lsun/security/util/DerValue;)V");
|
||||
"<init>", "([B)V");
|
||||
if (ticketConstructor == 0) {
|
||||
printf("LSA: Couldn't find Ticket constructor\n");
|
||||
return JNI_ERR;
|
||||
@ -347,9 +317,6 @@ JNIEXPORT void JNICALL DEF_JNI_OnUnload(
|
||||
if (ticketClass != NULL) {
|
||||
(*env)->DeleteWeakGlobalRef(env,ticketClass);
|
||||
}
|
||||
if (derValueClass != NULL) {
|
||||
(*env)->DeleteWeakGlobalRef(env,derValueClass);
|
||||
}
|
||||
if (principalNameClass != NULL) {
|
||||
(*env)->DeleteWeakGlobalRef(env,principalNameClass);
|
||||
}
|
||||
@ -897,11 +864,9 @@ InitUnicodeString(
|
||||
|
||||
jobject BuildTicket(JNIEnv *env, PUCHAR encodedTicket, ULONG encodedTicketSize) {
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
// To build a Ticket, we need to make a byte array out of the EncodedTicket.
|
||||
|
||||
jobject derValue, ticket;
|
||||
jobject ticket;
|
||||
jbyteArray ary;
|
||||
|
||||
ary = (*env)->NewByteArray(env,encodedTicketSize);
|
||||
@ -916,19 +881,12 @@ jobject BuildTicket(JNIEnv *env, PUCHAR encodedTicket, ULONG encodedTicketSize)
|
||||
return (jobject) NULL;
|
||||
}
|
||||
|
||||
derValue = (*env)->NewObject(env, derValueClass, derValueConstructor, ary);
|
||||
ticket = (*env)->NewObject(env, ticketClass, ticketConstructor, ary);
|
||||
if ((*env)->ExceptionOccurred(env)) {
|
||||
(*env)->DeleteLocalRef(env, ary);
|
||||
return (jobject) NULL;
|
||||
}
|
||||
|
||||
(*env)->DeleteLocalRef(env, ary);
|
||||
ticket = (*env)->NewObject(env, ticketClass, ticketConstructor, derValue);
|
||||
if ((*env)->ExceptionOccurred(env)) {
|
||||
(*env)->DeleteLocalRef(env, derValue);
|
||||
return (jobject) NULL;
|
||||
}
|
||||
(*env)->DeleteLocalRef(env, derValue);
|
||||
return ticket;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -35,12 +35,14 @@ public class NTSystem {
|
||||
private native void getCurrent(boolean debug);
|
||||
private native long getImpersonationToken0();
|
||||
|
||||
// Warning: the next 6 fields are used by nt.c
|
||||
private String userName;
|
||||
private String domain;
|
||||
private String domainSID;
|
||||
private String userSID;
|
||||
private String[] groupIDs;
|
||||
private String primaryGroupID;
|
||||
|
||||
private long impersonationToken;
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -33,6 +33,7 @@ public class UnixSystem {
|
||||
|
||||
private native void getUnixInfo();
|
||||
|
||||
// Warning: the following 4 fields are used by Unix.c
|
||||
protected String username;
|
||||
protected long uid;
|
||||
protected long gid;
|
||||
|
Loading…
Reference in New Issue
Block a user