Bug 231331. Pass correct parameter to native code.
This commit is contained in:
parent
17b3766285
commit
0b4d751ef2
@ -1,3 +1,8 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Jan 2 12:33:19 MST 2007 - jnorman@novell.com
|
||||
|
||||
- Bug 231331. Pass correct parameter from JNI to native code.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Dec 5 22:12:04 US/Mountain 2006 - cmashayekhi@novell.com
|
||||
|
||||
|
@ -20,235 +20,233 @@
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
#include "com_novell_casa_MiCasa.h"
|
||||
|
||||
#include <jni.h>
|
||||
#include <micasa_mgmd.h>
|
||||
#include <sscs_utf8.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_novell_casa_MiCasa_jmiCASASetCredential
|
||||
(JNIEnv *env, jobject notused,
|
||||
jint ssFlags,
|
||||
jstring jsAppSecretID,
|
||||
jstring jsSharedSecretID,
|
||||
jint jUsernameType,
|
||||
jstring jsUsername,
|
||||
jstring jsPassword
|
||||
)
|
||||
{
|
||||
int rcode = 0;
|
||||
SSCS_SECRET_ID_T appSecretId = {0};
|
||||
SSCS_SECRET_ID_T sharedSecretId = {0};
|
||||
SSCS_BASIC_CREDENTIAL credential = {0};
|
||||
|
||||
const char* utf_string;
|
||||
jboolean isCopy;
|
||||
utf_string = (*env)->GetStringUTFChars(env, jsAppSecretID, &isCopy);
|
||||
|
||||
sscs_Utf8Strcpy((char*)appSecretId.id, utf_string);
|
||||
appSecretId.len = sscs_Utf8Strlen(utf_string) + 1;
|
||||
|
||||
if (isCopy == JNI_TRUE)
|
||||
(*env)->ReleaseStringUTFChars(env,jsAppSecretID, utf_string);
|
||||
|
||||
// handle sharedsecretid
|
||||
if (jsSharedSecretID)
|
||||
{
|
||||
utf_string = (*env)->GetStringUTFChars(env, jsSharedSecretID, &isCopy);
|
||||
sscs_Utf8Strcpy((char*)sharedSecretId.id, utf_string);
|
||||
sharedSecretId.len = sscs_Utf8Strlen(utf_string)+1;
|
||||
|
||||
if (isCopy == JNI_TRUE)
|
||||
(*env)->ReleaseStringUTFChars(env, jsSharedSecretID, utf_string);
|
||||
}
|
||||
|
||||
// setup credential
|
||||
utf_string = (*env)->GetStringUTFChars(env, jsUsername, &isCopy);
|
||||
sscs_Utf8Strcpy((char*)credential.username, utf_string);
|
||||
credential.unLen = sscs_Utf8Strlen(utf_string)+1;
|
||||
credential.unFlags = jUsernameType;
|
||||
if (isCopy == JNI_TRUE)
|
||||
(*env)->ReleaseStringUTFChars(env, jsUsername, utf_string);
|
||||
|
||||
// password
|
||||
utf_string = (*env)->GetStringUTFChars(env, jsPassword, &isCopy);
|
||||
sscs_Utf8Strcpy((char*)credential.password, utf_string);
|
||||
credential.pwordLen = sscs_Utf8Strlen(utf_string)+1;
|
||||
if (isCopy == JNI_TRUE)
|
||||
(*env)->ReleaseStringUTFChars(env, jsPassword, utf_string);
|
||||
|
||||
|
||||
// make the call
|
||||
if (jsSharedSecretID)
|
||||
rcode = miCASASetCredential(
|
||||
ssFlags,
|
||||
&appSecretId,
|
||||
&sharedSecretId,
|
||||
SSCS_CRED_TYPE_BASIC_F,
|
||||
&credential,
|
||||
NULL
|
||||
);
|
||||
else
|
||||
rcode = miCASASetCredential(
|
||||
ssFlags,
|
||||
&appSecretId,
|
||||
NULL,
|
||||
SSCS_CRED_TYPE_BASIC_F,
|
||||
&credential,
|
||||
NULL
|
||||
);
|
||||
|
||||
return rcode;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: com_novell_casa_micasa_SecretStore
|
||||
* Method: jmiCASAGetCredential
|
||||
* Signature: (I[B[BILcom/novell/casa/micasa/Secret;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_novell_casa_MiCasa_jmiCASAGetCredential
|
||||
(JNIEnv *env, jobject unused,
|
||||
jint ssFlags,
|
||||
jstring jsAppSecretID,
|
||||
jstring jsSharedSecretID,
|
||||
jint jUsernameType,
|
||||
jobject jcred)
|
||||
{
|
||||
int rcode = 0;
|
||||
int iCredType = SSCS_CRED_TYPE_BASIC_F;
|
||||
SSCS_SECRET_ID_T appSecretId = {0};
|
||||
SSCS_SECRET_ID_T sharedSecretId = {0};
|
||||
SSCS_BASIC_CREDENTIAL credential = {0};
|
||||
|
||||
const char* utf_string;
|
||||
jboolean isCopy;
|
||||
int unType = jUsernameType;
|
||||
|
||||
utf_string = (*env)->GetStringUTFChars(env, jsAppSecretID, &isCopy);
|
||||
sscs_Utf8Strcpy((char*)appSecretId.id, utf_string);
|
||||
appSecretId.len = sscs_Utf8Strlen(utf_string) + 1;
|
||||
if (isCopy == JNI_TRUE)
|
||||
(*env)->ReleaseStringUTFChars(env, jsAppSecretID, utf_string);
|
||||
|
||||
// handle sharedsecretid
|
||||
if (jsSharedSecretID)
|
||||
{
|
||||
utf_string = (*env)->GetStringUTFChars(env, jsSharedSecretID, &isCopy);
|
||||
sscs_Utf8Strcpy((char*)sharedSecretId.id, utf_string);
|
||||
sharedSecretId.len = sscs_Utf8Strlen(utf_string)+1;
|
||||
|
||||
if (isCopy == JNI_TRUE)
|
||||
(*env)->ReleaseStringUTFChars(env, jsSharedSecretID, utf_string);
|
||||
}
|
||||
|
||||
// make the call
|
||||
if (jsSharedSecretID)
|
||||
rcode = miCASAGetCredential(
|
||||
ssFlags,
|
||||
&appSecretId,
|
||||
&sharedSecretId,
|
||||
&iCredType,
|
||||
&credential,
|
||||
NULL
|
||||
);
|
||||
else
|
||||
rcode = miCASAGetCredential(
|
||||
ssFlags,
|
||||
&appSecretId,
|
||||
NULL,
|
||||
&iCredType,
|
||||
&credential,
|
||||
NULL
|
||||
);
|
||||
|
||||
|
||||
if (rcode == 0)
|
||||
{
|
||||
// we have a credential
|
||||
jclass theclazz;
|
||||
jmethodID mid;
|
||||
|
||||
theclazz = (*env)->GetObjectClass(env, jcred);
|
||||
mid = (*env)->GetMethodID(env, theclazz, "setUsername", "(Ljava/lang/String;)V");
|
||||
if (mid != NULL)
|
||||
{
|
||||
//printf("The Username: %s\r\n", credential.username);
|
||||
jstring jusername = (*env)->NewStringUTF(env, (char *)credential.username);
|
||||
(*env)->CallObjectMethod(env, jcred, mid, jusername);
|
||||
}
|
||||
|
||||
mid = (*env)->GetMethodID(env, theclazz, "setPassword", "(Ljava/lang/String;)V");
|
||||
{
|
||||
jstring jpassword = (*env)->NewStringUTF(env, (char *)credential.password);
|
||||
(*env)->CallObjectMethod(env, jcred, mid, jpassword);
|
||||
}
|
||||
}
|
||||
return rcode;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: com_novell_casa_micasa_SecretStore
|
||||
* Method: jmiCASARemoveCredential
|
||||
* Signature: (I[B[B)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_novell_casa_MiCasa_jmiCASARemoveCredential
|
||||
(JNIEnv *env, jobject unused,
|
||||
jint ssFlags,
|
||||
jstring jsAppSecretID,
|
||||
jstring jsSharedSecretID)
|
||||
{
|
||||
int rcode = 0;
|
||||
SSCS_SECRET_ID_T appSecretId = {0};
|
||||
SSCS_SECRET_ID_T sharedSecretId = {0};
|
||||
|
||||
const char* utf_string;
|
||||
jboolean isCopy;
|
||||
|
||||
utf_string = (*env)->GetStringUTFChars(env, jsAppSecretID, &isCopy);
|
||||
sscs_Utf8Strcpy((char*)appSecretId.id, utf_string);
|
||||
appSecretId.len = sscs_Utf8Strlen(utf_string) + 1;
|
||||
if (isCopy == JNI_TRUE)
|
||||
(*env)->ReleaseStringUTFChars(env, jsAppSecretID, utf_string);
|
||||
|
||||
// handle sharedsecretid
|
||||
if (jsSharedSecretID)
|
||||
{
|
||||
utf_string = (*env)->GetStringUTFChars(env, jsSharedSecretID, &isCopy);
|
||||
sscs_Utf8Strcpy((char*)sharedSecretId.id, utf_string);
|
||||
sharedSecretId.len = sscs_Utf8Strlen(utf_string)+1;
|
||||
|
||||
if (isCopy == JNI_TRUE)
|
||||
(*env)->ReleaseStringUTFChars(env, jsSharedSecretID, utf_string);
|
||||
}
|
||||
|
||||
// make the call
|
||||
if (jsSharedSecretID)
|
||||
rcode = miCASARemoveCredential(
|
||||
ssFlags,
|
||||
&appSecretId,
|
||||
&sharedSecretId,
|
||||
NULL);
|
||||
|
||||
else
|
||||
rcode = miCASARemoveCredential(
|
||||
ssFlags,
|
||||
&appSecretId,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
return rcode;
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "com_novell_casa_MiCasa.h"
|
||||
|
||||
#include <jni.h>
|
||||
#include <micasa_mgmd.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_novell_casa_MiCasa_jmiCASASetCredential
|
||||
(JNIEnv *env, jobject notused,
|
||||
jint ssFlags,
|
||||
jstring jsAppSecretID,
|
||||
jstring jsSharedSecretID,
|
||||
jint jUsernameType,
|
||||
jstring jsUsername,
|
||||
jstring jsPassword
|
||||
)
|
||||
{
|
||||
int rcode = 0;
|
||||
SSCS_SECRET_ID_T appSecretId = {0};
|
||||
SSCS_SECRET_ID_T sharedSecretId = {0};
|
||||
SSCS_BASIC_CREDENTIAL credential = {0};
|
||||
|
||||
const char* utf_string;
|
||||
jboolean isCopy;
|
||||
utf_string = (*env)->GetStringUTFChars(env, jsAppSecretID, &isCopy);
|
||||
|
||||
sscs_Utf8Strcpy((char*)appSecretId.id, utf_string);
|
||||
appSecretId.len = sscs_Utf8Strlen(utf_string) + 1;
|
||||
|
||||
if (isCopy == JNI_TRUE)
|
||||
(*env)->ReleaseStringUTFChars(env,jsAppSecretID, utf_string);
|
||||
|
||||
// handle sharedsecretid
|
||||
if (jsSharedSecretID)
|
||||
{
|
||||
utf_string = (*env)->GetStringUTFChars(env, jsSharedSecretID, &isCopy);
|
||||
sscs_Utf8Strcpy((char*)sharedSecretId.id, utf_string);
|
||||
sharedSecretId.len = sscs_Utf8Strlen(utf_string)+1;
|
||||
|
||||
if (isCopy == JNI_TRUE)
|
||||
(*env)->ReleaseStringUTFChars(env, jsSharedSecretID, utf_string);
|
||||
}
|
||||
|
||||
// setup credential
|
||||
utf_string = (*env)->GetStringUTFChars(env, jsUsername, &isCopy);
|
||||
sscs_Utf8Strcpy((char*)credential.username, utf_string);
|
||||
credential.unLen = sscs_Utf8Strlen(utf_string)+1;
|
||||
credential.unFlags = jUsernameType;
|
||||
if (isCopy == JNI_TRUE)
|
||||
(*env)->ReleaseStringUTFChars(env, jsUsername, utf_string);
|
||||
|
||||
// password
|
||||
utf_string = (*env)->GetStringUTFChars(env, jsPassword, &isCopy);
|
||||
sscs_Utf8Strcpy((char*)credential.password, utf_string);
|
||||
credential.pwordLen = sscs_Utf8Strlen(utf_string)+1;
|
||||
if (isCopy == JNI_TRUE)
|
||||
(*env)->ReleaseStringUTFChars(env, jsPassword, utf_string);
|
||||
|
||||
|
||||
// make the call
|
||||
if (jsSharedSecretID)
|
||||
rcode = miCASASetCredential(
|
||||
ssFlags,
|
||||
&appSecretId,
|
||||
&sharedSecretId,
|
||||
SSCS_CRED_TYPE_BASIC_F,
|
||||
&credential,
|
||||
NULL
|
||||
);
|
||||
else
|
||||
rcode = miCASASetCredential(
|
||||
ssFlags,
|
||||
&appSecretId,
|
||||
NULL,
|
||||
SSCS_CRED_TYPE_BASIC_F,
|
||||
&credential,
|
||||
NULL
|
||||
);
|
||||
|
||||
return rcode;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: com_novell_casa_micasa_SecretStore
|
||||
* Method: jmiCASAGetCredential
|
||||
* Signature: (I[B[BILcom/novell/casa/micasa/Secret;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_novell_casa_MiCasa_jmiCASAGetCredential
|
||||
(JNIEnv *env, jobject unused,
|
||||
jint ssFlags,
|
||||
jstring jsAppSecretID,
|
||||
jstring jsSharedSecretID,
|
||||
jint jUsernameType,
|
||||
jobject jcred)
|
||||
{
|
||||
int rcode = 0;
|
||||
uint32_t iCredType = SSCS_CRED_TYPE_BASIC_F;
|
||||
SSCS_SECRET_ID_T appSecretId = {0};
|
||||
SSCS_SECRET_ID_T sharedSecretId = {0};
|
||||
SSCS_BASIC_CREDENTIAL credential = {0};
|
||||
|
||||
const char* utf_string;
|
||||
jboolean isCopy;
|
||||
|
||||
utf_string = (*env)->GetStringUTFChars(env, jsAppSecretID, &isCopy);
|
||||
sscs_Utf8Strcpy((char*)appSecretId.id, utf_string);
|
||||
appSecretId.len = sscs_Utf8Strlen(utf_string) + 1;
|
||||
if (isCopy == JNI_TRUE)
|
||||
(*env)->ReleaseStringUTFChars(env, jsAppSecretID, utf_string);
|
||||
|
||||
// handle sharedsecretid
|
||||
if (jsSharedSecretID)
|
||||
{
|
||||
utf_string = (*env)->GetStringUTFChars(env, jsSharedSecretID, &isCopy);
|
||||
sscs_Utf8Strcpy((char*)sharedSecretId.id, utf_string);
|
||||
sharedSecretId.len = sscs_Utf8Strlen(utf_string)+1;
|
||||
|
||||
if (isCopy == JNI_TRUE)
|
||||
(*env)->ReleaseStringUTFChars(env, jsSharedSecretID, utf_string);
|
||||
}
|
||||
|
||||
// make the call
|
||||
if (jsSharedSecretID)
|
||||
rcode = miCASAGetCredential(
|
||||
ssFlags,
|
||||
&appSecretId,
|
||||
&sharedSecretId,
|
||||
&iCredType,
|
||||
&credential,
|
||||
NULL
|
||||
);
|
||||
else
|
||||
rcode = miCASAGetCredential(
|
||||
ssFlags,
|
||||
&appSecretId,
|
||||
NULL,
|
||||
&iCredType,
|
||||
&credential,
|
||||
NULL
|
||||
);
|
||||
|
||||
|
||||
if (rcode == 0)
|
||||
{
|
||||
// we have a credential
|
||||
jclass theclazz;
|
||||
jmethodID mid;
|
||||
|
||||
theclazz = (*env)->GetObjectClass(env, jcred);
|
||||
mid = (*env)->GetMethodID(env, theclazz, "setUsername", "(Ljava/lang/String;)V");
|
||||
if (mid != NULL)
|
||||
{
|
||||
//printf("The Username: %s\r\n", credential.username);
|
||||
jstring jusername = (*env)->NewStringUTF(env, (char *)credential.username);
|
||||
(*env)->CallObjectMethod(env, jcred, mid, jusername);
|
||||
}
|
||||
|
||||
mid = (*env)->GetMethodID(env, theclazz, "setPassword", "(Ljava/lang/String;)V");
|
||||
{
|
||||
jstring jpassword = (*env)->NewStringUTF(env, (char *)credential.password);
|
||||
(*env)->CallObjectMethod(env, jcred, mid, jpassword);
|
||||
}
|
||||
}
|
||||
return rcode;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: com_novell_casa_micasa_SecretStore
|
||||
* Method: jmiCASARemoveCredential
|
||||
* Signature: (I[B[B)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_novell_casa_MiCasa_jmiCASARemoveCredential
|
||||
(JNIEnv *env, jobject unused,
|
||||
jint ssFlags,
|
||||
jstring jsAppSecretID,
|
||||
jstring jsSharedSecretID)
|
||||
{
|
||||
int rcode = 0;
|
||||
SSCS_SECRET_ID_T appSecretId = {0};
|
||||
SSCS_SECRET_ID_T sharedSecretId = {0};
|
||||
|
||||
const char* utf_string;
|
||||
jboolean isCopy;
|
||||
|
||||
utf_string = (*env)->GetStringUTFChars(env, jsAppSecretID, &isCopy);
|
||||
sscs_Utf8Strcpy((char*)appSecretId.id, utf_string);
|
||||
appSecretId.len = sscs_Utf8Strlen(utf_string) + 1;
|
||||
if (isCopy == JNI_TRUE)
|
||||
(*env)->ReleaseStringUTFChars(env, jsAppSecretID, utf_string);
|
||||
|
||||
// handle sharedsecretid
|
||||
if (jsSharedSecretID)
|
||||
{
|
||||
utf_string = (*env)->GetStringUTFChars(env, jsSharedSecretID, &isCopy);
|
||||
sscs_Utf8Strcpy((char*)sharedSecretId.id, utf_string);
|
||||
sharedSecretId.len = sscs_Utf8Strlen(utf_string)+1;
|
||||
|
||||
if (isCopy == JNI_TRUE)
|
||||
(*env)->ReleaseStringUTFChars(env, jsSharedSecretID, utf_string);
|
||||
}
|
||||
|
||||
// make the call
|
||||
if (jsSharedSecretID)
|
||||
rcode = miCASARemoveCredential(
|
||||
ssFlags,
|
||||
&appSecretId,
|
||||
&sharedSecretId,
|
||||
NULL);
|
||||
|
||||
else
|
||||
rcode = miCASARemoveCredential(
|
||||
ssFlags,
|
||||
&appSecretId,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
return rcode;
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user