/*
* 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.
*/
#include "sun_security_jgss_wrapper_GSSLibStub.h"
#include "NativeUtil.h"
#include "NativeFunc.h"
/* Constants for indicating what type of info is needed for inqueries */
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: init
*/
const char *libName;
return JNI_FALSE;
}
/* initialize global function table */
return JNI_TRUE;
} else {
return JNI_FALSE;
}
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: getMechPtr
* Signature: ([B)J
*/
jbyteArray jbytes) {
int i, len;
// Found a match
break;
}
}
}
return NULL;
} else return cOid;
} else return GSS_C_NO_OID;
}
/*
* Utility routine which creates a gss_channel_bindings_t structure
* using the specified org.ietf.jgss.ChannelBinding object.
*/
return GSS_C_NO_CHANNEL_BINDINGS;
}
/* set up initiator address */
} else {
}
/* set up acceptor address */
} else {
}
/* set up application data */
} else {
}
return cb;
}
/*
* Utility routine which releases the specified gss_channel_bindings_t
* structure.
*/
if (cb == GSS_C_NO_CHANNEL_BINDINGS) return;
/* release initiator address */
}
/* release acceptor address */
}
/* release application data */
}
}
/*
* Utility routine for storing the supplementary information
* into the specified org.ietf.jgss.MessageProp object.
*/
if (suppInfo != GSS_S_COMPLETE) {
minorMsg);
}
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: indicateMechs
*/
{
} else return NULL;
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: inquireNamesForMech
*/
{
/* gss_inquire_names_for_mech(...) => N/A */
/* release intermediate buffers */
return result;
} else return NULL;
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: releaseName
* Signature: (J)V
*/
{
if (nameHdl != GSS_C_NO_NAME) {
/* gss_release_name(...) => GSS_S_BAD_NAME */
}
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: importName
*/
{
/* gss_import_name(...) => GSS_S_BAD_NAMETYPE, GSS_S_BAD_NAME,
GSS_S_BAD_MECH */
/* release intermediate buffers */
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: compareName
* Signature: (JJ)Z
*/
{
int isEqual;
isEqual = 0;
(long) pName2);
/* gss_compare_name(...) => GSS_S_BAD_NAMETYPE, GSS_S_BAD_NAME(!) */
}
return (isEqual != 0);
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: canonicalizeName
* Signature: (J)J
*/
{
if (nameHdl != GSS_C_NO_NAME) {
/* gss_canonicalize_name(...) may return GSS_S_BAD_NAMETYPE,
GSS_S_BAD_NAME, GSS_S_BAD_MECH */
(long)mnNameHdl);
/* release intermediate buffers */
} else mnNameHdl = GSS_C_NO_NAME;
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: exportName
* Signature: (J)[B
*/
/* gss_export_name(...) => GSS_S_NAME_NOT_MN, GSS_S_BAD_NAMETYPE,
GSS_S_BAD_NAME */
/* canonicalize the internal name to MN and retry */
if (major == GSS_S_NAME_NOT_MN) {
mNameHdl = (gss_name_t)
/* return immediately if an exception has occurred */
return NULL;
}
/* return immediately if an exception has occurred */
return NULL;
}
}
/* release intermediate buffers */
return jresult;
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: displayName
*/
if (nameHdl == GSS_C_NO_NAME) {
return NULL;
}
/* gss_display_name(...) => GSS_S_BAD_NAME */
/* release intermediate buffers */
/* return immediately if an exception has occurred */
return NULL;
}
return jresult;
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: acquireCred
* Signature: (JII)J
*/
{
/* gss_acquire_cred(...) => GSS_S_BAD_MECH, GSS_S_BAD_NAMETYPE,
GSS_S_BAD_NAME, GSS_S_CREDENTIALS_EXPIRED, GSS_S_NO_CRED */
major =
/* release intermediate buffers */
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: releaseCred
* Signature: (J)J
*/
{
if (credHdl != GSS_C_NO_CREDENTIAL) {
/* gss_release_cred(...) => GSS_S_NO_CRED(!) */
}
}
/*
* Utility routine for obtaining info about a credential.
*/
/* gss_inquire_cred(...) => GSS_S_DEFECTIVE_CREDENTIAL(!),
GSS_S_CREDENTIALS_EXPIRED(!), GSS_S_NO_CRED(!) */
if (type == TYPE_CRED_NAME) {
} else if (type == TYPE_CRED_TIME) {
} else if (type == TYPE_CRED_USAGE) {
}
/* release intermediate buffers */
if (routineErr == GSS_S_CREDENTIALS_EXPIRED) {
/* ignore GSS_S_CREDENTIALS_EXPIRED for query */
} else if (routineErr == GSS_S_NO_CRED) {
/* twik since Java API throws BAD_MECH instead of NO_CRED */
}
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: getCredName
* Signature: (J)J
*/
{
/* return immediately if an exception has occurred */
return 0;
}
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: getCredTime
* Signature: (J)I
*/
{
lifetime = 0;
/* return immediately if an exception has occurred */
return 0;
}
return getJavaTime(lifetime);
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: getCredUsage
* Signature: (J)I
*/
{
/* return immediately if an exception has occurred */
return -1;
}
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: importContext
* Signature: ([B)Lsun/security/jgss/wrapper/NativeGSSContext;
*/
{
/* gss_import_sec_context(...) => GSS_S_NO_CONTEXT, GSS_S_DEFECTIVE_TOKEN,
GSS_S_UNAVAILABLE, GSS_S_UNAUTHORIZED */
(long) contextHdl);
/* release intermediate buffers */
/* return immediately if an exception has occurred */
return NULL;
}
/* now that the context has been imported, proceed to find out
its mech */
/* return immediately if an exception has occurred */
return NULL;
}
/* mech match - return the context object */
} else {
/* mech mismatch - clean up then return null */
"[GSSLibStub_importContext] cleanup");
return NULL;
}
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: initContext
* Signature: (JJLorg/ietf/jgss/ChannelBinding;[BLsun/security/jgss/wrapper/NativeGSSContext;)[B
*/
{
/* UNCOMMENT after SEAM bug#6287358 is backported to S10
gss_OID aMech;
jobject jMech;
*/
"[GSSLibStub_initContext] before: pCred=%ld, pContext=%ld",
(long)credHdl, (long)contextHdl);
/* gss_init_sec_context(...) => GSS_S_CONTINUE_NEEDED(!),
GSS_S_DEFECTIVE_TOKEN, GSS_S_NO_CRED, GSS_S_DEFECTIVE_CREDENTIAL(!),
GSS_S_CREDENTIALS_EXPIRED, GSS_S_BAD_BINDINGS, GSS_S_BAD_MIC,
GSS_S_OLD_TOKEN, GSS_S_DUPLICATE_TOKEN, GSS_S_NO_CONTEXT(!),
GSS_S_BAD_NAMETYPE, GSS_S_BAD_NAME(!), GSS_S_BAD_MECH */
(long)contextHdl);
/* update member values if needed */
(jlong) contextHdl);
if (major == GSS_S_COMPLETE) {
getJavaTime(aTime));
JNI_TRUE);
/* UNCOMMENT after SEAM bug#6287358 is backported to S10
jMech = getJavaOID(env, aMech);
(*env)->SetObjectField(env, jcontextSpi,
FID_NativeGSSContext_actualMech, jMech);
*/
} else if (major & GSS_S_CONTINUE_NEEDED) {
}
}
/* release intermediate buffers */
return jresult;
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: acceptContext
* Signature: (JLorg/ietf/jgss/ChannelBinding;[BLsun/security/jgss/wrapper/NativeGSSContext;)[B
*/
{
aFlags = 0;
"[GSSLibStub_acceptContext] before: pCred=%ld, pContext=%ld",
(long) credHdl, (long) contextHdl);
/* gss_accept_sec_context(...) => GSS_S_CONTINUE_NEEDED(!),
GSS_S_DEFECTIVE_TOKEN, GSS_S_DEFECTIVE_CREDENTIAL(!),
GSS_S_NO_CRED, GSS_S_CREDENTIALS_EXPIRED, GSS_S_BAD_BINDINGS,
GSS_S_NO_CONTEXT(!), GSS_S_BAD_MIC, GSS_S_OLD_TOKEN,
GSS_S_DUPLICATE_TOKEN, GSS_S_BAD_MECH */
major =
"[GSSLibStub_acceptContext] after: pCred=%ld, pContext=%ld, pDelegCred=%ld",
/* update member values if needed */
(jlong) contextHdl);
(long)contextHdl);
// WORKAROUND for a Heimdal bug
if (delCred == GSS_C_NO_CREDENTIAL) {
aFlags &= 0xfffffffe;
}
aFlags);
if (setTarget) {
/* return immediately if an exception has occurred */
return NULL;
}
(long)targetName);
}
if (srcName != GSS_C_NO_NAME) {
/* return immediately if an exception has occurred */
return NULL;
}
(long)srcName);
jsrcName);
}
if (major == GSS_S_COMPLETE) {
getJavaTime(aTime));
JNI_TRUE);
if (delCred != GSS_C_NO_CREDENTIAL) {
/* return immediately if an exception has occurred */
return NULL;
}
jdelCred);
(long) delCred);
}
} else if (major & GSS_S_CONTINUE_NEEDED) {
if (aFlags & GSS_C_PROT_READY_FLAG) {
getJavaTime(aTime));
}
}
}
/* release intermediate buffers */
return jresult;
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: inquireContext
* Signature: (J)[J
*/
{
time = 0;
/* gss_inquire_context(...) => GSS_S_NO_CONTEXT(!) */
&isInitiator, &isEstablished);
/* update member values if needed */
(long)targetName);
/* release intermediate buffers */
return jresult;
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: getContextMech
*/
{
/* return immediately if an exception has occurred */
return NULL;
}
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: getContextName
* Signature: (JZ)J
*/
{
(long)contextHdl, isSrc);
} else {
}
/* return immediately if an exception has occurred */
return (long)NULL;
}
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: getContextTime
* Signature: (J)I
*/
if (contextHdl == GSS_C_NO_CONTEXT) return 0;
/* gss_context_time(...) => GSS_S_CONTEXT_EXPIRED(!),
GSS_S_NO_CONTEXT(!) */
}
return getJavaTime(time);
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: deleteContext
* Signature: (J)J
*/
{
/* gss_delete_sec_context(...) => GSS_S_NO_CONTEXT(!) */
return (jlong) contextHdl;
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: wrapSizeLimit
* Signature: (JIII)I
*/
{
// Check context handle??
maxInSize = 0;
/* gss_wrap_size_limit(...) => GSS_S_NO_CONTEXT(!), GSS_S_CONTEXT_EXPIRED,
GSS_S_BAD_QOP */
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: exportContext
* Signature: (J)[B
*/
{
if (contextHdl == GSS_C_NO_CONTEXT) {
// Twik per javadoc
return NULL;
}
/* gss_export_sec_context(...) => GSS_S_CONTEXT_EXPIRED,
GSS_S_NO_CONTEXT, GSS_S_UNAVAILABLE */
major =
/* release intermediate buffers */
return jresult;
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: getMic
* Signature: (JI[B)[B
*/
{
if (contextHdl == GSS_C_NO_CONTEXT) {
// Twik per javadoc
return NULL;
}
/* gss_get_mic(...) => GSS_S_CONTEXT_EXPIRED, GSS_S_NO_CONTEXT(!),
GSS_S_BAD_QOP */
major =
/* release intermediate buffers */
return jresult;
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: verifyMic
* Signature: (J[B[BLorg/ietf/jgss/MessageProp;)V
*/
{
if (contextHdl == GSS_C_NO_CONTEXT) {
// Twik per javadoc
"[GSSLibStub_verifyMic]");
return;
}
/* gss_verify_mic(...) => GSS_S_DEFECTIVE_TOKEN, GSS_S_BAD_MIC,
GSS_S_CONTEXT_EXPIRED, GSS_S_DUPLICATE_TOKEN(!), GSS_S_OLD_TOKEN(!),
GSS_S_UNSEQ_TOKEN(!), GSS_S_GAP_TOKEN(!), GSS_S_NO_CONTEXT(!) */
major =
/* release intermediate buffers */
minor);
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: wrap
* Signature: (J[BLorg/ietf/jgss/MessageProp;)[B
*/
{
int confState;
if (contextHdl == GSS_C_NO_CONTEXT) {
// Twik per javadoc
return NULL;
}
confFlag =
/* gss_wrap(...) => GSS_S_CONTEXT_EXPIRED, GSS_S_NO_CONTEXT(!),
GSS_S_BAD_QOP */
&msgToken);
/* release intermediate buffers */
return jresult;
}
/*
* Class: sun_security_jgss_wrapper_GSSLibStub
* Method: unwrap
* Signature: (J[BLorg/ietf/jgss/MessageProp;)[B
*/
{
int confState;
if (contextHdl == GSS_C_NO_CONTEXT) {
// Twik per javadoc
return NULL;
}
confState = 0;
/* gss_unwrap(...) => GSS_S_DEFECTIVE_TOKEN, GSS_S_BAD_MIC,
GSS_S_CONTEXT_EXPIRED, GSS_S_DUPLICATE_TOKEN(!), GSS_S_OLD_TOKEN(!),
GSS_S_UNSEQ_TOKEN(!), GSS_S_GAP_TOKEN(!), GSS_S_NO_CONTEXT(!) */
major =
/* update the message prop with relevant info */
(confState != 0));
minor);
/* release intermediate buffers */
return jresult;
}