Skip to content

Commit 12c278c

Browse files
committed
8228659: Record which Java methods are called by native codes in JGSS and JAAS
Reviewed-by: mullan
1 parent 83b11a5 commit 12c278c

File tree

17 files changed

+43
-94
lines changed

17 files changed

+43
-94
lines changed

src/java.security.jgss/macosx/native/libosxkrb5/nativeccache.c

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
* Statics for this module
4444
*/
4545

46-
static jclass derValueClass = NULL;
4746
static jclass ticketClass = NULL;
4847
static jclass principalNameClass = NULL;
4948
static jclass encryptionKeyClass = NULL;
@@ -54,7 +53,6 @@ static jclass javaLangIntegerClass = NULL;
5453
static jclass hostAddressClass = NULL;
5554
static jclass hostAddressesClass = NULL;
5655

57-
static jmethodID derValueConstructor = 0;
5856
static jmethodID ticketConstructor = 0;
5957
static jmethodID principalNameConstructor = 0;
6058
static jmethodID encryptionKeyConstructor = 0;
@@ -108,9 +106,6 @@ JNIEXPORT jint JNICALL DEF_JNI_OnLoad(JavaVM *jvm, void *reserved)
108106
principalNameClass = FindClass(env, "sun/security/krb5/PrincipalName");
109107
if (principalNameClass == NULL) return JNI_ERR;
110108

111-
derValueClass = FindClass(env, "sun/security/util/DerValue");
112-
if (derValueClass == NULL) return JNI_ERR;
113-
114109
encryptionKeyClass = FindClass(env, "sun/security/krb5/EncryptionKey");
115110
if (encryptionKeyClass == NULL) return JNI_ERR;
116111

@@ -132,13 +127,7 @@ JNIEXPORT jint JNICALL DEF_JNI_OnLoad(JavaVM *jvm, void *reserved)
132127
hostAddressesClass = FindClass(env,"sun/security/krb5/internal/HostAddresses");
133128
if (hostAddressesClass == NULL) return JNI_ERR;
134129

135-
derValueConstructor = (*env)->GetMethodID(env, derValueClass, "<init>", "([B)V");
136-
if (derValueConstructor == 0) {
137-
printf("Couldn't find DerValue constructor\n");
138-
return JNI_ERR;
139-
}
140-
141-
ticketConstructor = (*env)->GetMethodID(env, ticketClass, "<init>", "(Lsun/security/util/DerValue;)V");
130+
ticketConstructor = (*env)->GetMethodID(env, ticketClass, "<init>", "([B)V");
142131
if (ticketConstructor == 0) {
143132
printf("Couldn't find Ticket constructor\n");
144133
return JNI_ERR;
@@ -204,9 +193,6 @@ JNIEXPORT void JNICALL DEF_JNI_OnUnload(JavaVM *jvm, void *reserved)
204193
if (ticketClass != NULL) {
205194
(*env)->DeleteWeakGlobalRef(env,ticketClass);
206195
}
207-
if (derValueClass != NULL) {
208-
(*env)->DeleteWeakGlobalRef(env,derValueClass);
209-
}
210196
if (principalNameClass != NULL) {
211197
(*env)->DeleteWeakGlobalRef(env,principalNameClass);
212198
}
@@ -421,11 +407,9 @@ JNIEXPORT jobject JNICALL Java_sun_security_krb5_Credentials_acquireDefaultNativ
421407

422408
jobject BuildTicket(JNIEnv *env, krb5_data *encodedTicket)
423409
{
424-
/* To build a Ticket, we first need to build a DerValue out of the EncodedTicket.
425-
* But before we can do that, we need to make a byte array out of the ET.
426-
*/
410+
// To build a Ticket, we need to make a byte array out of the EncodedTicket.
427411

428-
jobject derValue, ticket;
412+
jobject ticket;
429413
jbyteArray ary;
430414

431415
ary = (*env)->NewByteArray(env, encodedTicket->length);
@@ -439,19 +423,12 @@ jobject BuildTicket(JNIEnv *env, krb5_data *encodedTicket)
439423
return (jobject) NULL;
440424
}
441425

442-
derValue = (*env)->NewObject(env, derValueClass, derValueConstructor, ary);
426+
ticket = (*env)->NewObject(env, ticketClass, ticketConstructor, ary);
443427
if ((*env)->ExceptionCheck(env)) {
444428
(*env)->DeleteLocalRef(env, ary);
445429
return (jobject) NULL;
446430
}
447-
448431
(*env)->DeleteLocalRef(env, ary);
449-
ticket = (*env)->NewObject(env, ticketClass, ticketConstructor, derValue);
450-
if ((*env)->ExceptionCheck(env)) {
451-
(*env)->DeleteLocalRef(env, derValue);
452-
return (jobject) NULL;
453-
}
454-
(*env)->DeleteLocalRef(env, derValue);
455432
return ticket;
456433
}
457434

src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSCredElement.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -61,6 +61,7 @@ void doServicePermCheck() throws GSSException {
6161
}
6262

6363
// Construct delegation cred using the actual context mech and srcName
64+
// Warning: called by NativeUtil.c
6465
GSSCredElement(long pCredentials, GSSNameElement srcName, Oid mech)
6566
throws GSSException {
6667
pCred = pCredentials;

src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSLibStub.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,7 @@
4343
class GSSLibStub {
4444

4545
private Oid mech;
46-
private long pMech;
46+
private long pMech; // Warning: used by NativeUtil.c
4747

4848
/**
4949
* Initialization routine to dynamically load function pointers.

src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSNameElement.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -97,6 +97,7 @@ private GSSNameElement() {
9797
printableName = "<DEFAULT ACCEPTOR>";
9898
}
9999

100+
// Warning: called by NativeUtil.c
100101
GSSNameElement(long pNativeName, GSSLibStub stub) throws GSSException {
101102
assert(stub != null);
102103
if (pNativeName == 0) {

src/java.security.jgss/share/classes/sun/security/jgss/wrapper/NativeGSSContext.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -59,20 +59,22 @@ class NativeGSSContext implements GSSContextSpi {
5959

6060
private static final int NUM_OF_INQUIRE_VALUES = 6;
6161

62+
// Warning: The following 9 fields are used by NativeUtil.c
6263
private long pContext = 0; // Pointer to the gss_ctx_id_t structure
6364
private GSSNameElement srcName;
6465
private GSSNameElement targetName;
65-
private GSSCredElement cred;
66-
private GSSCredElement disposeCred;
6766
private boolean isInitiator;
6867
private boolean isEstablished;
68+
private GSSCredElement delegatedCred;
69+
private int flags;
70+
private int lifetime = GSSCredential.DEFAULT_LIFETIME;
6971
private Oid actualMech; // Assigned during context establishment
7072

73+
private GSSCredElement cred;
74+
private GSSCredElement disposeCred;
75+
7176
private ChannelBinding cb;
72-
private GSSCredElement delegatedCred;
7377
private GSSCredElement disposeDelegatedCred;
74-
private int flags;
75-
private int lifetime = GSSCredential.DEFAULT_LIFETIME;
7678
private final GSSLibStub cStub;
7779

7880
private boolean skipDelegPermCheck;
@@ -231,6 +233,7 @@ private byte[] retrieveToken(InputStream is, int mechTokenLen)
231233
}
232234

233235
// Constructor for imported context
236+
// Warning: called by NativeUtil.c
234237
NativeGSSContext(long pCtxt, GSSLibStub stub) throws GSSException {
235238
assert(pContext != 0);
236239
pContext = pCtxt;

src/java.security.jgss/share/classes/sun/security/krb5/Credentials.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public Credentials(Ticket new_ticket,
8888
this.authzData = authzData;
8989
}
9090

91+
// Warning: called by NativeCreds.c and nativeccache.c
9192
public Credentials(Ticket new_ticket,
9293
PrincipalName new_client,
9394
PrincipalName new_client_alias,

src/java.security.jgss/share/classes/sun/security/krb5/EncryptionKey.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -218,8 +218,8 @@ public EncryptionKey(byte[] keyValue,
218218
* credential cache file.
219219
*
220220
*/
221-
// Used in JSSE (KerberosWrapper), Credentials,
222-
// javax.security.auth.kerberos.KeyImpl
221+
// Used in Credentials, and javax.security.auth.kerberos.KeyImpl
222+
// Warning: called by NativeCreds.c and nativeccache.c
223223
public EncryptionKey(int keyType,
224224
byte[] keyValue) {
225225
this(keyValue, keyType, null);

src/java.security.jgss/share/classes/sun/security/krb5/PrincipalName.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public PrincipalName(int nameType, String[] nameStrings, Realm nameRealm) {
158158
this.realmDeduced = false;
159159
}
160160

161-
// This method is called by Windows NativeCred.c
161+
// Warning: called by NativeCreds.c
162162
public PrincipalName(String[] nameParts, String realm) throws RealmException {
163163
this(KRB_NT_UNKNOWN, nameParts, new Realm(realm));
164164
}
@@ -484,6 +484,7 @@ public PrincipalName(String name, int type, String realm)
484484
}
485485
}
486486

487+
// Warning: called by nativeccache.c
487488
public PrincipalName(String name, int type) throws RealmException {
488489
this(name, type, (String)null);
489490
}

src/java.security.jgss/share/classes/sun/security/krb5/internal/HostAddress.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -165,6 +165,8 @@ public HostAddress() throws UnknownHostException {
165165
/**
166166
* Creates a HostAddress from the specified address and address type.
167167
*
168+
* Warning: called by nativeccache.c.
169+
*
168170
* @param new_addrType the value of the address type which matches the defined
169171
* address family constants in the Berkeley Standard
170172
* Distributions of Unix.

src/java.security.jgss/share/classes/sun/security/krb5/internal/HostAddresses.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -68,6 +68,7 @@ public class HostAddresses implements Cloneable {
6868
private HostAddress[] addresses = null;
6969
private volatile int hashCode = 0;
7070

71+
// Warning: called by nativeccache.c
7172
public HostAddresses(HostAddress[] new_addresses) throws IOException {
7273
if (new_addresses != null) {
7374
addresses = new HostAddress[new_addresses.length];

0 commit comments

Comments
 (0)