private Buffer getFunctionAddress(final String name) { try { return getFunctionAddress0(moduleHandle, new ZSTR(name)); } catch (final NativeException e) { throw new RuntimeException("Error getting function address: moduleHandle=" + moduleHandle + ",name=" + name, e); } }
/** * Retrieves the data for the value with the specified name, within the * specified open key. */ public String wfmQueryValue(final HKEY hKey, final String valueName) throws XfsException { final ZSTR data = new ZSTR(SIZE_LIMIT, true); final DWORD cchData = new DWORD(data.getSize()); final int errorCode = wfmQueryValue0(hKey, new ZSTR(valueName), data, cchData); XfsException.throwFor(errorCode); return data.toString(); }
public ZSTR(final int length, final boolean allocate) { super(length); if (length < 1) { throw new IllegalArgumentException("Illegal length: " + length + ", must be >= 1"); } if (allocate) { allocate(); } }
/** * Enumerates the values of the specified open key. Retrieves the name and * data for one value each time it is called. */ public Map.Entry<String, String> wfmEnumValue(final HKEY hKey, final DWORD iValue) throws XfsException { ZSTR value = new ZSTR(SIZE_LIMIT, true); ZSTR data = new ZSTR(SIZE_LIMIT, true); DWORD cchValue = new DWORD(SIZE_LIMIT); DWORD cchData = new DWORD(SIZE_LIMIT); final int errorCode = wfmEnumValue0(hKey, iValue, value, cchValue, data, cchData); XfsException.throwFor(errorCode); return new ValuePair(value.toString(), data.toString()); }
public String getDescription() { return description.toString(); }
@Override public byte[] get() { return getBytes(); }
/** * Enumerates the subkeys of the specified open key. Retrieves information * about one subkey each time it is called. * * @param key * Handle to a currently open key, or the predefined handle * value: {@link #WFS_CFG_HKEY_XFS_ROOT} * @return the name of the subkey */ public String wfmEnumKey(final HKEY key, final DWORD iSubKey) throws XfsException { final ZSTR name = new ZSTR(SIZE_LIMIT, true); DWORD cchName = new DWORD(name.length); FILETIME lastWrite = new FILETIME(); final int errorCode = wfmEnumKey0(key, iSubKey, name, cchName, lastWrite); XfsException.throwFor(errorCode); return name.toString(); }
public String getSystemStatus() { return systemStatus.toString(); }
@Override public String toString() { String result = new String(getBytes(), StandardCharsets.US_ASCII); if (result.indexOf(NUL) != -1) { result = result.substring(0, result.indexOf(NUL)); } return result; } }
/** * {@link #hsmVendor} */ public void setHSMVendor(final String hsmVendor) { this.hsmVendor.pointTo(new ZSTR(hsmVendor)); }
private static ZSTR toZZString(final Map<String, String> map, final char separator) { StringBuilder zzString = new StringBuilder(); if (map.isEmpty()) { zzString.append(NUL); } else { for (Map.Entry<String, String> entry : map.entrySet()) { final String key = entry.getKey(); final String value = entry.getValue(); if (key.indexOf(separator) != -1) { throw new IllegalArgumentException("Key '" + key + "' contains separator " + separator); } zzString.append(key); zzString.append(separator); zzString.append(value); zzString.append(NUL); } } return new ZSTR(zzString.toString()); } }
public void setExpiryDate(String expiryDate) { if (expiryDate == null) { this.expiryDate.pointTo(Pointer.NULL); } else { this.expiryDate.pointTo(new ZSTR(expiryDate)); } }
/** * Opens the specified key. */ public HKEY wfmOpenKey(final HKEY hKey, final String subKey) throws XfsException { HKEY hkResult = new HKEY(); final int errorCode = wfmOpenKey0(hKey, (subKey == null ? null : new ZSTR(subKey)), hkResult); XfsException.throwFor(errorCode); synchronized (openKeys) { openKeys.add(hkResult); } return hkResult; }
/** * Makes this <code>Pointer</code> point to a {@link ZSTR} with the * specified <code>String</code> value or points to <code>NULL</code> if no * <code>String</code> is given. * * @param value * a <code>String</code> or <code>null</code> */ @Override public void set(String value) { if (value == null) { pointToNULL(); return; } pointTo(new ZSTR(value)); }
private void loadLibrary(final String fileName) { final String method = "loadLibrary(String)"; if (LOG.isDebugEnabled()) { LOG.debug(method, "fileName=" + fileName); } if (moduleHandle != null) { throw new IllegalStateException(); } try { moduleHandle = new Pointer(loadLibrary0(new ZSTR(fileName))); initFunctionAddress = new Pointer(getFunctionAddress("CT_init")); dataFunctionAddress = new Pointer(getFunctionAddress("CT_data")); closeFunctionAddress = new Pointer(getFunctionAddress("CT_close")); } catch (final NativeException e) { throw new RuntimeException("Error loading library: " + fileName, e); } }
private RequestId open(final XfsOpenCommand openCommand, final XfsEventNotification eventNotification) throws XfsException { final String method = "open(XFSOpenCommand, IXfsEventNotification)"; if (LOG.isDebugEnabled()) { LOG.debug(method, "openCommand=" + openCommand + ",eventNotification=" + eventNotification); } final XfsService xfsService = openCommand.getXFSService(); final DWORD dwTraceLevel = null; final DWORD timeOut = new DWORD(0L); final RequestId requestId = xfsAPI.wfsAsyncOpen(new ZSTR(xfsService.getLogicalName()), hApp, null, dwTraceLevel, timeOut, xfsService.getService(), hWnd, xfsService.getSrvcVersionsRequired(), xfsService.getSrvcVersion(), xfsService.getSPIVersion()); requestQueue.addRequest(requestId, eventNotification, openCommand, Long.valueOf(timeOut.longValue())); return requestId; }