harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r378390 - in /incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth: ./ auth_copyright.c authwin32.c authwin32.h hyauth.def hyauth.rc makefile
Date Thu, 16 Feb 2006 23:00:26 GMT
Author: tellison
Date: Thu Feb 16 15:00:22 2006
New Revision: 378390

URL: http://svn.apache.org/viewcvs?rev=378390&view=rev
Log:
Just stashing this code in svn,
not included in the build.

Added:
    incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/
    incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/auth_copyright.c
    incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/authwin32.c
    incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/authwin32.h
    incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/hyauth.def
    incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/hyauth.rc
    incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/makefile

Added: incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/auth_copyright.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/auth_copyright.c?rev=378390&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/auth_copyright.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/auth_copyright.c Thu
Feb 16 15:00:22 2006
@@ -0,0 +1,19 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* A copyright string included in each DLL and executable */
+
+const char hyCopyright[] =
+  "(c) Copyright 2005, 2006 The Apache Software Foundation or its licensors, as applicable.";

Added: incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/authwin32.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/authwin32.c?rev=378390&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/authwin32.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/authwin32.c Thu Feb
16 15:00:22 2006
@@ -0,0 +1,527 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+#undef _WIN32_WINNT
+#define _WIN32_WINNT 0x0500
+
+#define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
+#include <windows.h>
+#include <sddl.h>
+
+//#include <winbase.h>
+#include "authwin32.h"
+
+#include <assert.h>
+
+#include "harmony.h"
+#include "jni.h"
+
+#pragma warning(disable:4311)
+
+void error(LPVOID lpJEnv, LPCSTR msg, DWORD dwErr);
+
+jfieldID jf_user = NULL;
+jfieldID jf_domainSid = NULL;
+    
+jfieldID jf_mainGroup = NULL;
+jfieldID jf_groups = NULL;
+jfieldID jf_token = NULL;
+
+jfieldID jf_debugNative = NULL;
+
+
+BOOLEAN
+getDebugNative( JNIEnv * jenv, jobject thiz )
+{
+	return (*jenv)->GetBooleanField (jenv, thiz, jf_debugNative) ? TRUE : FALSE;
+}
+
+
+JNIEXPORT void JNICALL 
+Java_org_apache_harmony_security_x_security_auth_module_NTSystem_initNatives
+(JNIEnv * jenv, jclass klass)
+{
+	jclass klassErr = NULL;
+
+	if( NULL == (jf_user = (*jenv)->GetFieldID (jenv, klass, "user", "Lorg/apache/harmony/security/x/security/auth/NTSidUserPrincipal;")))
{
+		klassErr = (*jenv)->FindClass (jenv, "java/lang/Error");
+		assert(klassErr);
+		(*jenv)->ThrowNew (jenv, klassErr, "Could not find field \"user\" of type NTSidUserPrincipal");
+		return;
+	}
+
+	if( NULL == (jf_domainSid = (*jenv)->GetFieldID (jenv, klass, "domainSid", "Ljava/lang/String;"))
) {
+		klassErr = (*jenv)->FindClass (jenv, "java/lang/Error");
+		assert(klassErr);
+		(*jenv)->ThrowNew (jenv, klassErr, "Could not find field \"domainSid\" of type String");
+		return;
+	}
+
+	if( NULL == (jf_mainGroup = (*jenv)->GetFieldID (jenv, klass, "mainGroup", "Lorg/apache/harmony/security/x/security/auth/NTSidPrimaryGroupPrincipal;"))
) {
+		klassErr = (*jenv)->FindClass (jenv, "java/lang/Error");
+		assert(klassErr);
+		(*jenv)->ThrowNew (jenv, klassErr, "Could not find field \"mainGroup\" of type NTSidPrimaryGroupPrincipal");
+		return;
+	}
+
+	if( NULL == (jf_groups = (*jenv)->GetFieldID (jenv, klass, "groups", "[Lorg/apache/harmony/security/x/security/auth/NTSidGroupPrincipal;"))
) {
+		klassErr = (*jenv)->FindClass (jenv, "java/lang/Error");
+		assert(klassErr);
+		(*jenv)->ThrowNew (jenv, klassErr, "Could not find field \"groups\" of type NTSidPrimaryGroupPrincipal");
+		return;
+	}
+
+	if( NULL == (jf_token = (*jenv)->GetFieldID (jenv, klass, "token", "J")) ) {
+		klassErr = (*jenv)->FindClass (jenv, "java/lang/Error");
+		assert(klassErr);
+		(*jenv)->ThrowNew (jenv, klassErr, "Could not find field \"token\" of type NTSidPrimaryGroupPrincipal");
+		return;
+	}
+
+	if( NULL == (jf_debugNative = (*jenv)->GetFieldID (jenv, klass, "debugNative", "Z"))
) {
+		if ( (*jenv)->ExceptionCheck (jenv) ) {
+			(*jenv)->ExceptionDescribe (jenv);
+			return;
+		}
+		klassErr = (*jenv)->FindClass (jenv, "java/lang/Error");
+		assert(klassErr);
+		(*jenv)->ThrowNew (jenv, klassErr, "Could not find field \"debugNative\" of type boolean.");
+		return;
+	}
+}
+
+
+LPVOID QueryInfo
+(JNIEnv * jenv, HANDLE hToken, TOKEN_INFORMATION_CLASS klass) 
+{
+	PORT_ACCESS_FROM_ENV (jenv);
+
+	DWORD dwSize;
+	LPVOID pData = NULL;
+
+	if( !GetTokenInformation(hToken, klass, NULL, 0, &dwSize) ) {
+		DWORD dwErr = GetLastError();
+		if( ERROR_INSUFFICIENT_BUFFER != dwErr ) {
+			return NULL;
+		}
+	}
+
+	pData = hymem_allocate_memory(dwSize);
+	if( !GetTokenInformation(hToken, klass, pData, dwSize, &dwSize) ) {
+		DWORD dwErr = GetLastError();
+		hymem_free_memory(pData);
+		SetLastError(dwErr);
+		return NULL;
+	}
+	return pData;
+}
+
+
+BOOLEAN GetInfo
+(JNIEnv * jenv, PSID sid, LPSTR* ppName, LPSTR* ppDomain) 
+{
+	PORT_ACCESS_FROM_ENV (jenv);
+
+	DWORD dwNameSize = 0;
+	DWORD dwDomainNameSize = 0;
+	SID_NAME_USE snu;
+	if( !LookupAccountSid(NULL, sid, NULL, &dwNameSize, NULL, &dwDomainNameSize, &snu))
{
+		if( ERROR_INSUFFICIENT_BUFFER != GetLastError() ) {
+			return FALSE;
+		}
+	}
+	*ppName = (LPSTR)hymem_allocate_memory(dwNameSize);
+	if( NULL == ppName ) {
+		return FALSE;
+	}
+	*ppDomain = (LPSTR)hymem_allocate_memory(dwDomainNameSize);
+	if( NULL == ppName ) {
+		DWORD err = GetLastError();
+		hymem_free_memory(*ppName);
+		SetLastError(err);
+		return FALSE;
+	}
+	if( !LookupAccountSid(NULL, sid, *ppName, &dwNameSize, *ppDomain, &dwDomainNameSize,
&snu)) {
+		DWORD err = GetLastError();
+		hymem_free_memory(*ppName);
+		hymem_free_memory(*ppDomain);
+		SetLastError(err);
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+
+JNIEXPORT void JNICALL
+Java_org_apache_harmony_security_x_security_auth_module_NTSystem_load
+(JNIEnv * jenv, jobject thiz)
+{
+	DWORD i; /* tmp */
+
+	DWORD dwError = -1; /* presume unknown error */
+	LPCSTR errMsg = NULL;
+	DWORD dwSaveError = -1;
+
+	HANDLE hUser = INVALID_HANDLE_VALUE;
+	HANDLE iToken= INVALID_HANDLE_VALUE;
+
+	LPVOID lpUserData = NULL, lpGroupData = NULL, lpAllGroupsData = NULL;
+	LPSTR lpStr0 = NULL, lpStr1 = NULL, lpStr2 = NULL;
+	LPSTR lpUserSid = NULL, lpDomainName = NULL;
+	PSID domainSid = NULL;
+
+	SID_IDENTIFIER_AUTHORITY sia = SECURITY_NT_AUTHORITY;
+
+	TOKEN_USER * ptu = NULL;
+	PSID userSid = NULL;
+
+	jclass jkl = NULL;
+	jmethodID ctor = NULL;
+
+	jstring jstrSid = NULL;
+	jstring jstrUser = NULL;
+	jstring jstrDomain = NULL;
+	jobject obj = NULL;
+
+	jstring jstrDomainSid = NULL;
+
+	PTOKEN_PRIMARY_GROUP ptpg = NULL;
+	PSID groupSid = NULL;
+
+	jclass jklassPrimaryGroup = NULL;
+	jobject jobj = NULL;
+
+	PTOKEN_GROUPS ptgs = NULL;
+
+	jclass klassGroup = NULL;
+	jmethodID groupCtor3 = NULL;
+	jmethodID groupCtor1 = NULL;
+	jobjectArray jgroups = NULL;
+
+	jobject jobj1 = NULL;
+
+	//
+	// Get the token for the user currently running this Thread
+	//
+	if( !OpenThreadToken(GetCurrentThread(), TOKEN_QUERY|TOKEN_DUPLICATE, TRUE, &hUser)
) {
+		// failed to open thread token. well, let's try process' one
+		if( !OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY|TOKEN_DUPLICATE, &hUser) ) {
+			errMsg = "Unable to obtain user token";
+			goto exit;
+		}
+	}
+
+	//
+	// Obtain the User's info
+	//
+	if( NULL == (lpUserData = (TOKEN_USER*)QueryInfo(jenv, hUser, TokenUser)) ) {
+		errMsg = "Unable to obtain user's token info";
+		goto exit;
+	}
+
+	ptu = (TOKEN_USER*)lpUserData;
+
+	if( !IsValidSid(ptu->User.Sid) ) {
+		errMsg = "Got invalid user's SID";
+		goto exit;
+	}
+
+	userSid = ptu->User.Sid;
+
+	ConvertSidToStringSid(userSid, &lpStr0);
+	lpUserSid = lpStr0;
+	lpStr0 = NULL;
+
+	//
+    // step +n:  Retrieve user name and domain name basing on user's SID.
+	//
+	if( !GetInfo(jenv, userSid, &lpStr0, &lpStr1) ) {
+		errMsg = "Unable to retrieve user's name and domain";
+		goto exit;
+	};
+
+	jkl = (*jenv)->FindClass (jenv, "org/apache/harmony/security/x/security/auth/NTSidUserPrincipal");
+	if( NULL == jkl || (*jenv)->ExceptionCheck (jenv) ) {
+		errMsg = "Could not find class NTSidUserPrincipal";
+		goto exit;
+	}
+	ctor = (*jenv)->GetMethodID (jenv, jkl, "<init>", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
+	if( NULL == ctor || (*jenv)->ExceptionCheck (jenv) ) {
+		errMsg = "Could not find ctor at NTSidUserPrincipal class";
+		goto exit;
+	}
+
+	jstrSid = (*jenv)->NewStringUTF (jenv, lpUserSid);
+	jstrUser = (*jenv)->NewStringUTF (jenv, lpStr0);
+	jstrDomain = (*jenv)->NewStringUTF (jenv, lpStr1);
+	obj = (*jenv)->NewObject (jenv, jkl, ctor, jstrSid, jstrUser, jstrDomain);
+	if( (*jenv)->ExceptionCheck (jenv) ) {
+		goto exit;
+	}
+	(*jenv)->SetObjectField (jenv, thiz, jf_user, obj);
+	if( (*jenv)->ExceptionCheck (jenv) ) {
+		goto exit;
+	}
+	
+	LocalFree(lpStr0); lpStr0 = NULL;
+	lpDomainName = lpStr1; 
+	lpStr1 = NULL;
+
+	//
+	// Step +1: Obtain domain SID
+	//
+	if( !AllocateAndInitializeSid(
+		&sia, 4, 
+		*GetSidSubAuthority(userSid, 0), 
+		*GetSidSubAuthority(userSid, 1), 
+		*GetSidSubAuthority(userSid, 2),
+		*GetSidSubAuthority(userSid, 3), 
+		0, 0, 0, 0, 
+		&domainSid)) {
+
+		errMsg = "Unable to allocate domain SID";
+		goto exit;
+	}
+
+	if( !IsValidSid(domainSid) ) {
+		errMsg = "Got invalid domain SID";
+		goto exit;
+	}
+
+	ConvertSidToStringSid(domainSid, &lpStr0);
+
+	jstrDomainSid = (*jenv)->NewStringUTF (jenv, lpStr0);
+	(*jenv)->SetObjectField (jenv, thiz, jf_domainSid, jstrDomainSid);
+	if( (*jenv)->ExceptionCheck (jenv) ) {
+		goto exit;
+	}
+	LocalFree(lpStr0); lpStr0 = NULL;
+
+	//
+	// step +1: get primary group sid
+	//
+	if( NULL == (lpGroupData = QueryInfo(jenv, hUser, TokenPrimaryGroup)) ) {
+		errMsg = "Unable to get primaty group";
+		goto exit;
+	};
+
+	ptpg = (PTOKEN_PRIMARY_GROUP)lpGroupData;
+	groupSid = ptpg->PrimaryGroup;
+
+	if( !IsValidSid(groupSid) ) {
+		errMsg = "Got invalid primary groups' SID";
+		goto exit;
+	}
+
+	if( !GetInfo(jenv, groupSid, &lpStr0, &lpStr1) ) {
+		errMsg = "Unable to get primary group's info";
+		goto exit;
+	}
+	ConvertSidToStringSid(groupSid, &lpStr2);
+
+	jklassPrimaryGroup = (*jenv)->FindClass (jenv, "org/apache/harmony/security/x/security/auth/NTSidPrimaryGroupPrincipal");
+	if( NULL == jklassPrimaryGroup || (*jenv)->ExceptionCheck (jenv) ) {
+		errMsg = "Could not find class NTSidPrimaryGroupPrincipal";
+		goto exit;
+	}
+
+	ctor = (*jenv)->GetMethodID (jenv, jklassPrimaryGroup, "<init>", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
+	if( NULL == ctor ) {
+		errMsg = "Could not find appropriate ctor at NTSidPrimaryGroupPrincipal";
+		goto exit;
+	}
+
+	jobj = (*jenv)->NewObject (jenv, jklassPrimaryGroup, ctor, 
+		(*jenv)->NewStringUTF (jenv, lpStr2), (*jenv)->NewStringUTF (jenv, lpStr0), (*jenv)->NewStringUTF
(jenv, lpStr1));
+
+	LocalFree(lpStr0); lpStr0 = NULL;
+	LocalFree(lpStr1); lpStr1 = NULL;
+	LocalFree(lpStr2); lpStr2 = NULL;
+
+
+	if( (*jenv)->ExceptionCheck (jenv) ) {
+		goto exit;
+	}
+	(*jenv)->SetObjectField (jenv, thiz, jf_mainGroup, jobj);
+
+	//
+	// step +1: get groups
+	//
+	if( NULL== (lpAllGroupsData = QueryInfo(jenv, hUser, TokenGroups)) ) {
+		errMsg = "Unable to query user's groups";
+		goto exit;
+	}
+
+	ptgs = (PTOKEN_GROUPS)lpAllGroupsData;
+
+	klassGroup = (*jenv)->FindClass (jenv, "org/apache/harmony/security/x/security/auth/NTSidGroupPrincipal");
+	if( NULL == klassGroup || (*jenv)->ExceptionCheck (jenv) ) {
+		errMsg = "Could not find NTSidGroupPrincipal";
+		goto exit;
+	};
+
+	groupCtor3 = (*jenv)->GetMethodID (jenv, klassGroup, "<init>", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
+	if( NULL == groupCtor3 || (*jenv)->ExceptionCheck (jenv) ) {
+		errMsg = "Could not find appropriate ctor with 3 Strings at NTSidGroupPrincipal";
+		goto exit;
+	};
+	groupCtor1 = (*jenv)->GetMethodID (jenv, klassGroup, "<init>", "(Ljava/lang/String;)V");
+	if( NULL == groupCtor1 || (*jenv)->ExceptionCheck (jenv) ) {
+		errMsg = "Could not find appropriate ctor at NTSidGroupPrincipal";
+		goto exit;
+	};
+
+	// allocate an array 
+	jgroups = (*jenv)->NewObjectArray (jenv, ptgs->GroupCount, klassGroup, NULL);
+
+	if( NULL == jgroups || (*jenv)->ExceptionCheck (jenv) ) {
+		errMsg = "Could not create array of NTSidGroupPrincipal";
+		goto exit;
+	};
+
+	for( i=0; i<ptgs->GroupCount; i++ ) {
+
+		ConvertSidToStringSid(ptgs->Groups[i].Sid, &lpStr2);
+
+		if( !GetInfo(jenv, ptgs->Groups[i].Sid, &lpStr0, &lpStr1) ) {
+			jobj1 = (*jenv)->NewObject (jenv, klassGroup, groupCtor1, (*jenv)->NewStringUTF
(jenv, lpStr2));
+			//printf("SET_FIELD: %d] Simple Group: %s\n", i, lpStr2 );
+		}
+		else {
+			jobj1 = (*jenv)->NewObject (jenv, klassGroup, groupCtor3, 
+				(*jenv)->NewStringUTF (jenv, lpStr2), (*jenv)->NewStringUTF (jenv, lpStr0), (*jenv)->NewStringUTF
(jenv, lpStr1));
+//			printf("SET_FIELD: %d] Group: %s@%s \n\t %s\n", i, lpStr0, lpStr1, lpStr2 );
+		}
+		if( NULL != lpStr0 ) { LocalFree(lpStr0); lpStr0 = NULL; }
+		if( NULL != lpStr1 ) { LocalFree(lpStr1); lpStr1 = NULL; }
+		if( NULL != lpStr2 ) { LocalFree(lpStr2); lpStr2 = NULL; }
+		if( NULL == jobj1 || (*jenv)->ExceptionCheck (jenv) ) {
+			goto exit;
+		}
+		(*jenv)->SetObjectArrayElement (jenv, jgroups, i, jobj1);
+		if( (*jenv)->ExceptionCheck (jenv) ) {
+			goto exit;
+		}
+	};
+	(*jenv)->SetObjectField (jenv, thiz, jf_groups, jgroups);
+	if( (*jenv)->ExceptionCheck (jenv) ) {
+		goto exit;
+	}
+
+	//
+	// step +1: get itoken
+	//
+
+	//FIXME: on NT 'SecurityImpersonation'  is not supported. 
+	// Check whether we support NT - just to be sure.
+	if (!DuplicateToken (hUser, SecurityImpersonation, &iToken)) {
+		errMsg = "Unable to duplicate impersonation token";
+		goto exit;
+	};
+
+	// printf("_SET_FIELD: iToken: %d \n", ((long)iToken) );
+	(*jenv)->SetLongField (jenv, thiz, jf_token, ((jlong)iToken));
+	if( (*jenv)->ExceptionCheck (jenv) ) {
+		goto exit;
+	}
+
+	dwError = 0;
+exit:
+	dwSaveError = GetLastError();
+
+	if( NULL != lpUserData )		LocalFree(lpUserData);
+	if( NULL != lpGroupData )		LocalFree(lpGroupData);
+	if( NULL != lpAllGroupsData )	LocalFree(lpAllGroupsData);
+	if( NULL != lpStr0 )			LocalFree(lpStr0);
+	if( NULL != lpStr1 )			LocalFree(lpStr1);
+	if( NULL != lpStr2 )			LocalFree(lpStr2);
+	if( NULL != lpUserSid )			LocalFree(lpUserSid);
+	if( NULL != lpDomainName)		LocalFree(lpDomainName);
+	//
+	if( NULL != domainSid )			FreeSid(domainSid);
+
+	if( INVALID_HANDLE_VALUE != hUser ) CloseHandle(hUser);
+
+	if( (*jenv)->ExceptionCheck (jenv) ) {
+		(*jenv)->ExceptionDescribe (jenv);
+	}
+	else {
+		if( (0 != dwError) || (NULL!=errMsg) ) {
+			if( dwError == -1 ) {
+				dwError = dwSaveError;
+			}
+			error((LPVOID)jenv, (LPCSTR)errMsg, dwError);
+		}
+	}
+	return;
+}
+
+/*
+* Class:     org_apache_harmony_security_x_security_auth_module_NTSystem
+* Method:    free
+* Signature: ()V
+*/
+JNIEXPORT void JNICALL
+Java_org_apache_harmony_security_x_security_auth_module_NTSystem_free
+(JNIEnv * jenv, jobject thiz)
+{
+	HANDLE hTok = (HANDLE)(*jenv)->GetLongField (jenv, thiz, jf_token);
+	if( !(0 == hTok || INVALID_HANDLE_VALUE == hTok) ) {
+		if( !CloseHandle(hTok) ) {
+			error((LPVOID)jenv, (LPCSTR) "Unable to close handle", GetLastError());
+		}
+	}
+}
+
+void
+error
+(LPVOID lpJEnv, LPCSTR msg, DWORD dwErr)
+{
+	JNIEnv * jenv = (JNIEnv*)lpJEnv;
+	LPVOID lpMsg = NULL;
+	LPVOID lpFullMsg = NULL;
+	DWORD args[3];
+	jclass excl = NULL;
+
+	if (!FormatMessage(
+		FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+        NULL, dwErr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+		(LPTSTR)&lpMsg, 0, NULL )) {
+			// error in error(). 
+		//assert(false);
+	}
+
+	args[0] = (DWORD)msg;
+	args[1] = dwErr;
+	args[2] = (DWORD)lpMsg;
+	
+	if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY,
+		"%1!s! (#%2!d!): \"%3!s!\"", 0, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+		(LPTSTR)&lpFullMsg, 0, (va_list*)args)) {
+			// error in error(). 
+	}
+
+	excl = (*jenv)->FindClass (jenv, "java/lang/Error");
+	if( NULL == excl ) {
+		return;
+	}
+	(*jenv)->ThrowNew (jenv, excl, (LPCSTR)lpFullMsg);
+
+	// Free the buffer.
+	LocalFree( lpMsg );
+	LocalFree( lpFullMsg );
+}

Added: incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/authwin32.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/authwin32.h?rev=378390&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/authwin32.h (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/authwin32.h Thu Feb
16 15:00:22 2006
@@ -0,0 +1,32 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+// The following ifdef block is the standard way of creating macros which make exporting

+// from a DLL simpler. All files within this DLL are compiled with the JAASWIN_EXPORTS
+// symbol defined on the command line. this symbol should not be defined on any project
+// that uses this DLL. This way any other project whose source files include this file see

+// JAASWIN_API functions as being imported from a DLL, whereas this DLL sees symbols
+// defined with this macro as being exported.
+#ifdef JAASWIN_EXPORTS
+#define JAASWIN_API __declspec(dllexport)
+#else
+#define JAASWIN_API __declspec(dllimport)
+#endif
+
+//JAASWIN_API void fillitup(LPVOID lpJEnv, LPVOID lpJObj);
+//JAASWIN_API void error(LPVOID lpJEnv, LPCSTR msg, DWORD dwErr );
+
+

Added: incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/hyauth.def
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/hyauth.def?rev=378390&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/hyauth.def (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/hyauth.def Thu Feb
16 15:00:22 2006
@@ -0,0 +1,10 @@
+LIBRARY	HYAUTH
+
+SECTIONS
+	.data	READ WRITE
+	.text	EXECUTE READ
+
+EXPORTS
+	Java_org_apache_harmony_security_x_security_auth_module_NTSystem_free
+	Java_org_apache_harmony_security_x_security_auth_module_NTSystem_initNatives
+	Java_org_apache_harmony_security_x_security_auth_module_NTSystem_load

Added: incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/hyauth.rc
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/hyauth.rc?rev=378390&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/hyauth.rc (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/hyauth.rc Thu Feb 16
15:00:22 2006
@@ -0,0 +1,47 @@
+;
+; Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+; 
+; Licensed under the Apache License, Version 2.0 (the "License");
+; you may not use this file except in compliance with the License.
+; You may obtain a copy of the License at
+; 
+;     http://www.apache.org/licenses/LICENSE-2.0
+; 
+; Unless required by applicable law or agreed to in writing, software
+; distributed under the License is distributed on an "AS IS" BASIS,
+; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+; See the License for the specific language governing permissions and
+; limitations under the License.
+;
+
+#include <windows.h>
+#include <winver.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 0,1,0,0
+ PRODUCTVERSION 0,1,0,0
+ FILEFLAGSMASK 0x3fL
+ FILEFLAGS 0x0L
+ FILEOS VOS_NT_WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE 0x0L
+BEGIN
+	BLOCK "StringFileInfo"
+	BEGIN
+		BLOCK "040904b0"
+		BEGIN
+			VALUE "CompanyName", "The Apache Software Foundation.\0"
+			VALUE "FileDescription", "Auth native code\0"
+			VALUE "FileVersion", "0.1\0"
+			VALUE "InternalName", "hyauth\0"
+			VALUE "LegalCopyright", "(c) Copyright 2005, 2006 The Apache Software Foundation or its
licensors, as applicable.\0"
+			VALUE "OriginalFilename", "hyauth.dll\0"
+			VALUE "ProductName", "Apache Harmony\0"
+			VALUE "ProductVersion", "0.1\0"
+		END
+	END
+	BLOCK "VarFileInfo"
+	BEGIN
+		VALUE "Translation", 0x0409, 1200
+	END
+END

Added: incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/makefile
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/makefile?rev=378390&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/makefile (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/win.IA32/auth/makefile Thu Feb 16
15:00:22 2006
@@ -0,0 +1,85 @@
+# Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+# 
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+# 
+#     http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# Makefile for module 'auth'
+#
+
+APPVER=4.0
+TARGETOS=WIN95
+SEHMAP = TRUE
+!include <win32.mak>
+
+DLLFILENAME=hyauth.dll# declaration
+
+DLLNAME=..\hyauth.dll# declaration
+
+LIBNAME=hyauth# declaration
+
+LIBPATH=..\lib\# declaration
+
+.c.obj:
+	$(cc) -DWINVER=0x0400 -D_WIN32_WINNT=0x0400 $(cflags) -D_MT -D_DLL -MD -D_WINSOCKAPI_ -DWIN32
-Ogityb1 -Gs -GF -Zm400 -Zi -WX  /I..\include /I..\auth $(VMDEBUG) $*.c
+
+.cpp.obj:
+	$(cc) -DWINVER=0x0400 -D_WIN32_WINNT=0x0400 $(cflags) -D_MT -D_DLL -MD -D_WINSOCKAPI_ -DWIN32
-Ogityb1 -Gs -GF -Zm400 -Zi -WX /I..\include /I..\auth $(VMDEBUG) $*.cpp
+
+.asm.obj:
+	ml /c /Cp /W3 /nologo /coff /Zm /Zd /Zi /Gd $(VMASMDEBUG) -DWIN32   $<
+
+.rc.res:
+	rc -I..\include $<
+
+BUILDFILES1 = auth_copyright.obj authwin32.obj
+
+VIRTFILES1 = hyauth.res
+
+SYSLIBFILES1 = ws2_32.lib Iphlpapi.lib
+
+MDLLIBFILES1 = ..\lib\hycommon.lib ..\lib\hysig.lib ..\lib\hyzip.lib ..\lib\hyzlib.lib
+MDLLIBFILES2 = ..\lib\hypool.lib ..\lib\hyfdlibm.lib ..\lib\hythr.lib ..\lib\vmi.lib
+
+all: \
+	 ..\lib\$(LIBNAME).lib $(DLLNAME)
+	
+BUILDLIB: $(LIBPATH)$(LIBNAME).lib
+
+$(LIBPATH)$(LIBNAME).lib:\
+	$(BUILDFILES1) $(BUILDFILES2) $(VIRTFILES1) \
+	$(MDLLIBFILES1) $(MDLLIBFILES2) 
+	$(implib) /NOLOGO -subsystem:windows -out:$(LIBPATH)$(LIBNAME).lib -def:$(LIBNAME).def -machine:$(CPU)
\
+	$(BUILDFILES1) $(BUILDFILES2) $(VIRTFILES1) \
+	$(MDLLIBFILES1) $(MDLLIBFILES2) 
+
+
+$(DLLNAME): $(LIBPATH)$(LIBNAME).lib \
+	$(BUILDFILES1) $(BUILDFILES2) $(VIRTFILES1) \
+	$(MDLLIBFILES1) $(MDLLIBFILES2) 
+	link $(VMLINK) /debug /opt:icf /opt:ref /INCREMENTAL:NO /NOLOGO -entry:_DllMainCRTStartup@12
-dll /BASE:0x13300000 -machine:$(CPU) \
+	/comment:"Auth component native code. (c) Copyright 2005, 2006 The Apache Software Foundation
or its licensors, as applicable." \
+	-subsystem:windows -out:$(DLLNAME) -map:$(LIBNAME).map  \
+	$(BUILDFILES1) $(BUILDFILES2) $(VIRTFILES1) \
+	$(MDLLIBFILES1) $(MDLLIBFILES2) $(SYSLIBFILES1)  \
+	kernel32.lib  ws2_32.lib advapi32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib  $(LIBPATH)$(LIBNAME).exp
+
+
+clean:
+	-del *.map
+	-del *.obj
+	-del *.res
+	-del *.pdb
+	-del ..\lib\$(LIBNAME).lib
+	-del ..\lib\$(LIBNAME).exp
+	-del ..\$(LIBNAME).pdb
+	-del $(DLLNAME)



Mime
View raw message