]>
Commit | Line | Data |
---|---|---|
0fa4da98 JP |
1 | --- a/common/autoconf/libraries.m4 |
2 | +++ b/common/autoconf/libraries.m4 | |
3 | @@ -926,6 +926,53 @@ AC_DEFUN_ONCE([LIB_SETUP_MISC_LIBS], | |
991454fa JK |
4 | |
5 | ############################################################################### | |
6 | # | |
7 | + # Check for the pcsclite library | |
8 | + # | |
9 | + | |
10 | + AC_ARG_WITH(libpcsclite, [AS_HELP_STRING([--with-libpcsclite], | |
11 | + [use libpcsclite from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])]) | |
12 | + | |
13 | + AC_CHECK_LIB(pcsclite, SCardConnect, | |
14 | + [ LIBPCSCLITE_FOUND=yes ], | |
15 | + [ LIBPCSCLITE_FOUND=no ]) | |
16 | + | |
17 | + AC_MSG_CHECKING([for which libpcsclite to use]) | |
18 | + | |
19 | + DEFAULT_LIBPCSCLITE=bundled | |
20 | + | |
21 | + if test "x${LIBPCSCLITE_FOUND}" != "xyes"; then | |
22 | + # | |
23 | + # If we don't find any system...set default to bundled | |
24 | + # | |
25 | + DEFAULT_LIBPCSCLITE=bundled | |
26 | + fi | |
27 | + | |
28 | + # | |
29 | + # If user didn't specify, use DEFAULT_PCSC | |
30 | + # | |
31 | + if test "x${with_libpcsclite}" = "x"; then | |
32 | + with_libpcsclite=${DEFAULT_LIBPCSCLITE} | |
33 | + fi | |
34 | + | |
35 | + if test "x${with_libpcsclite}" = "xbundled"; then | |
36 | + USE_EXTERNAL_LIBPCSCLITE=false | |
37 | + AC_MSG_RESULT([bundled]) | |
38 | + elif test "x${with_libpcsclite}" = "xsystem"; then | |
39 | + if test "x${LIBPCSCLITE_FOUND}" = "xyes"; then | |
40 | + USE_EXTERNAL_LIBPCSCLITE=true | |
41 | + AC_MSG_RESULT([system]) | |
42 | + else | |
43 | + AC_MSG_RESULT([system not found]) | |
44 | + AC_MSG_ERROR([--with-libpcsclite=system specified, but no libpcsclite found!]) | |
45 | + fi | |
46 | + else | |
47 | + AC_MSG_ERROR([Invalid value for --with-libpcsclite: ${with_libpcsclite}, use 'system' or 'bundled']) | |
48 | + fi | |
49 | + | |
50 | + AC_SUBST(USE_EXTERNAL_LIBPCSCLITE) | |
51 | + | |
52 | + ############################################################################### | |
53 | + # | |
54 | # Check for the zlib library | |
55 | # | |
56 | ||
0fa4da98 JP |
57 | --- a/common/autoconf/spec.gmk.in |
58 | +++ b/common/autoconf/spec.gmk.in | |
59 | @@ -605,6 +605,7 @@ ENABLE_INTREE_EC=@ENABLE_INTREE_EC@ | |
991454fa JK |
60 | USE_EXTERNAL_LIBJPEG:=@USE_EXTERNAL_LIBJPEG@ |
61 | USE_EXTERNAL_LIBPNG:=@USE_EXTERNAL_LIBPNG@ | |
62 | USE_EXTERNAL_LIBGIF:=@USE_EXTERNAL_LIBGIF@ | |
63 | +USE_EXTERNAL_LIBPCSCLITE:=@USE_EXTERNAL_LIBPCSCLITE@ | |
64 | USE_EXTERNAL_LIBZ:=@USE_EXTERNAL_LIBZ@ | |
65 | LIBZIP_CAN_USE_MMAP:=@LIBZIP_CAN_USE_MMAP@ | |
66 | MSVCR_DLL:=@MSVCR_DLL@ | |
0fa4da98 JP |
67 | --- a/jdk/make/lib/SecurityLibraries.gmk |
68 | +++ b/jdk/make/lib/SecurityLibraries.gmk | |
69 | @@ -75,11 +75,11 @@ $(eval $(call SetupNativeCompilation,BUI | |
991454fa JK |
70 | CFLAGS := $(CFLAGS_JDKLIB) \ |
71 | -I$(JDK_TOPDIR)/src/share/native/sun/security/smartcardio \ | |
72 | -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/smartcardio \ | |
73 | - -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/smartcardio/MUSCLE, \ | |
74 | + -I/usr/include/PCSC -DUSE_SYSTEM_LIBPCSCLITE, \ | |
75 | MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libj2pcsc/mapfile-vers, \ | |
76 | LDFLAGS := $(LDFLAGS_JDKLIB) \ | |
77 | $(call SET_SHARED_LIBRARY_ORIGIN), \ | |
78 | - LDFLAGS_SUFFIX_posix := $(LIBDL), \ | |
79 | + LDFLAGS_SUFFIX_posix := -lpcsclite $(LIBDL), \ | |
80 | LDFLAGS_SUFFIX_windows := winscard.lib, \ | |
81 | LDFLAGS_SUFFIX_solaris := -lc, \ | |
82 | VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \ | |
0fa4da98 JP |
83 | --- a/jdk/src/solaris/native/sun/security/smartcardio/pcsc_md.c |
84 | +++ b/jdk/src/solaris/native/sun/security/smartcardio/pcsc_md.c | |
991454fa JK |
85 | @@ -36,6 +36,7 @@ |
86 | ||
87 | #include "pcsc_md.h" | |
88 | ||
89 | +#ifndef USE_SYSTEM_LIBPCSCLITE | |
90 | void *hModule; | |
91 | FPTR_SCardEstablishContext scardEstablishContext; | |
92 | FPTR_SCardConnect scardConnect; | |
0fa4da98 | 93 | @@ -47,6 +48,7 @@ FPTR_SCardListReaders scardListReaders; |
991454fa JK |
94 | FPTR_SCardBeginTransaction scardBeginTransaction; |
95 | FPTR_SCardEndTransaction scardEndTransaction; | |
96 | FPTR_SCardControl scardControl; | |
97 | +#endif | |
98 | ||
99 | /* | |
100 | * Throws a Java Exception by name | |
0fa4da98 | 101 | @@ -75,7 +77,9 @@ void throwIOException(JNIEnv *env, const |
991454fa JK |
102 | throwByName(env, "java/io/IOException", msg); |
103 | } | |
104 | ||
105 | +#ifndef USE_SYSTEM_LIBPCSCLITE | |
106 | void *findFunction(JNIEnv *env, void *hModule, char *functionName) { | |
107 | + return NULL; | |
108 | void *fAddress = dlsym(hModule, functionName); | |
109 | if (fAddress == NULL) { | |
110 | char errorMessage[256]; | |
0fa4da98 | 111 | @@ -85,9 +89,11 @@ void *findFunction(JNIEnv *env, void *hM |
991454fa JK |
112 | } |
113 | return fAddress; | |
114 | } | |
115 | +#endif | |
116 | ||
117 | JNIEXPORT void JNICALL Java_sun_security_smartcardio_PlatformPCSC_initialize | |
118 | (JNIEnv *env, jclass thisClass, jstring jLibName) { | |
119 | +#ifndef USE_SYSTEM_LIBPCSCLITE | |
120 | const char *libName = (*env)->GetStringUTFChars(env, jLibName, NULL); | |
121 | if (libName == NULL) { | |
122 | throwNullPointerException(env, "PCSC library name is null"); | |
0fa4da98 | 123 | @@ -141,4 +147,5 @@ JNIEXPORT void JNICALL Java_sun_security |
991454fa JK |
124 | #else |
125 | scardControl = (FPTR_SCardControl) findFunction(env, hModule, "SCardControl132"); | |
126 | #endif // __APPLE__ | |
127 | +#endif | |
128 | } | |
0fa4da98 JP |
129 | --- a/jdk/src/solaris/native/sun/security/smartcardio/pcsc_md.h |
130 | +++ b/jdk/src/solaris/native/sun/security/smartcardio/pcsc_md.h | |
991454fa JK |
131 | @@ -23,6 +23,8 @@ |
132 | * questions. | |
133 | */ | |
134 | ||
135 | +#ifndef USE_SYSTEM_LIBPCSCLITE | |
136 | + | |
0fa4da98 JP |
137 | typedef LONG (*FPTR_SCardEstablishContext)(DWORD dwScope, |
138 | LPCVOID pvReserved1, | |
139 | LPCVOID pvReserved2, | |
140 | @@ -111,3 +113,41 @@ extern FPTR_SCardListReaders scardListRe | |
991454fa JK |
141 | extern FPTR_SCardBeginTransaction scardBeginTransaction; |
142 | extern FPTR_SCardEndTransaction scardEndTransaction; | |
143 | extern FPTR_SCardControl scardControl; | |
144 | + | |
145 | +#else | |
146 | + | |
147 | +#define CALL_SCardEstablishContext(dwScope, pvReserved1, pvReserved2, phContext) \ | |
148 | + (SCardEstablishContext(dwScope, pvReserved1, pvReserved2, phContext)) | |
149 | + | |
150 | +#define CALL_SCardConnect(hContext, szReader, dwSharedMode, dwPreferredProtocols, phCard, pdwActiveProtocols) \ | |
151 | + (SCardConnect(hContext, szReader, dwSharedMode, dwPreferredProtocols, phCard, pdwActiveProtocols)) | |
152 | + | |
153 | +#define CALL_SCardDisconnect(hCard, dwDisposition) \ | |
154 | + (SCardDisconnect(hCard, dwDisposition)) | |
155 | + | |
156 | +#define CALL_SCardStatus(hCard, mszReaderNames, pcchReaderLen, pdwState, pdwProtocol, pbAtr, pcbAtrLen) \ | |
157 | + (SCardStatus(hCard, mszReaderNames, pcchReaderLen, pdwState, pdwProtocol, pbAtr, pcbAtrLen)) | |
158 | + | |
159 | +#define CALL_SCardGetStatusChange(hContext, dwTimeout, rgReaderStates, cReaders) \ | |
160 | + (SCardGetStatusChange(hContext, dwTimeout, rgReaderStates, cReaders)) | |
161 | + | |
162 | +#define CALL_SCardTransmit(hCard, pioSendPci, pbSendBuffer, cbSendLength, \ | |
163 | + pioRecvPci, pbRecvBuffer, pcbRecvLength) \ | |
164 | + (SCardTransmit(hCard, pioSendPci, pbSendBuffer, cbSendLength, \ | |
165 | + pioRecvPci, pbRecvBuffer, pcbRecvLength)) | |
166 | + | |
167 | +#define CALL_SCardListReaders(hContext, mszGroups, mszReaders, pcchReaders) \ | |
168 | + (SCardListReaders(hContext, mszGroups, mszReaders, pcchReaders)) | |
169 | + | |
170 | +#define CALL_SCardBeginTransaction(hCard) \ | |
171 | + (SCardBeginTransaction(hCard)) | |
172 | + | |
173 | +#define CALL_SCardEndTransaction(hCard, dwDisposition) \ | |
174 | + (SCardEndTransaction(hCard, dwDisposition)) | |
175 | + | |
176 | +#define CALL_SCardControl(hCard, dwControlCode, pbSendBuffer, cbSendLength, \ | |
177 | + pbRecvBuffer, pcbRecvLength, lpBytesReturned) \ | |
178 | + (SCardControl(hCard, dwControlCode, pbSendBuffer, cbSendLength, \ | |
179 | + pbRecvBuffer, pcbRecvLength, lpBytesReturned)) | |
180 | + | |
181 | +#endif |