Update
This commit is contained in:
@@ -6,16 +6,19 @@ import jaasNativeHandlers from './cheerpj/natives/jaas.js';
|
||||
*/
|
||||
const screen=document.getElementById('display');
|
||||
const notice=document.getElementById('state');
|
||||
const BRIDGE_JAR='/app/backend/hmi/cheerpj/workplace-window-monitor-v4.jar';
|
||||
const CREDENTIAL_BRIDGE_JAR='/app/backend/hmi/cheerpj/workplace-credential-bridge.jar';
|
||||
const CREDENTIAL_BRIDGE_URL='/backend/hmi/cheerpj/workplace-credential-bridge.jar';
|
||||
let credentialWaiter=null;
|
||||
const BRIDGE_JAR='/app/backend/hmi/cheerpj/workplace-window-monitor-v3.jar';
|
||||
// JS implementation for OpenJDK UnixSystem.getUnixInfo. Register the handler via
|
||||
// cheerpjInit({natives}) AND keep the JS native library for System.loadLibrary.
|
||||
// Note: registration cannot repair a missing CheerpJ JVM_LoadLibrary import.
|
||||
const JAAS_JS_URL='/backend/hmi/cheerpj/natives/jaas.js';
|
||||
const JAAS_NATIVE_PATH='/app/backend/hmi/cheerpj/natives';
|
||||
const JAAS_BRIDGE_JAR='/app/backend/hmi/cheerpj/jaas-identity-bridge.jar';
|
||||
// Optional, experimentally isolated Java 11 fallback for iTAC SysParameter.
|
||||
// MUST come before vendor JARs; class loading/signature conflicts are checked
|
||||
// separately and MUST NOT be silently ignored.
|
||||
const SYSPARAM_PATCH_URL='/backend/hmi/cheerpj/sysparameter-jaas-fallback-java11.jar';
|
||||
const SYSPARAM_PATCH_JAR='/app'+SYSPARAM_PATCH_URL;
|
||||
|
||||
// JSON-P 1.1 provider required by iTAC ParameterType; NOT included in Workplace.jnlp.
|
||||
// Maven packages this dependency as a static WAR resource.
|
||||
const JSONP_PROVIDER_URL='/backend/hmi/cheerpj-libs/javax.json-1.1.4.jar';
|
||||
@@ -214,13 +217,13 @@ async function attachWorkplaceRuntimeMonitor(container, lib, windowMode, display
|
||||
if(!lib)throw Error('CheerpJ Library Mode für Fensterüberwachung nicht verfügbar.');
|
||||
const bridge=await lib.com.widgetworkbench.cheerpj.WorkplaceResizeBridge;
|
||||
if(typeof bridge.startRuntimeMonitor!=='function')
|
||||
throw Error('Workplace Window Monitor v4 fehlt: startRuntimeMonitor nicht vorhanden. JAR V5.10.22 prüfen.');
|
||||
throw Error('Workplace Window Monitor v3 fehlt: startRuntimeMonitor nicht vorhanden. JAR V5.10.21 prüfen.');
|
||||
const panel=document.getElementById('window-diagnostics');
|
||||
const output=document.getElementById('window-diagnostics-output');
|
||||
const bounds=container.getBoundingClientRect();
|
||||
const width=displayMode==='original'?1280:Math.max(200,Math.floor(bounds.width));
|
||||
const height=displayMode==='original'?1024:Math.max(150,Math.floor(bounds.height));
|
||||
// This is the LAST library-mode method call before cheerpjRunMain().
|
||||
// This sequential library-mode call completes before cheerpjRunMain().
|
||||
// startRuntimeMonitor returns immediately; Java then polls independently.
|
||||
const started=await bridge.startRuntimeMonitor(width,height,windowMode);
|
||||
if(Number(started)!==1&&Number(started)!==2)
|
||||
@@ -229,45 +232,13 @@ async function attachWorkplaceRuntimeMonitor(container, lib, windowMode, display
|
||||
if(panel)panel.hidden=false;
|
||||
if(output)output.textContent='Java-11-Fensterdiagnose aktiv ('+windowMode+').\n'
|
||||
+'Ausgabe in der Browser-Konsole: [WidgetWorkbench/WindowGeometry]\n'
|
||||
+'Die Abfragen laufen im Java-Hintergrundthread, ohne parallele CheerpJ-Library-Aufrufe.\n'
|
||||
+'MES_LOGIN: NOT_SEEN / CREATED_HIDDEN / VISIBLE_ONSCREEN / VISIBLE_OFFSCREEN.\n'
|
||||
+'MES_LOGIN_OWNER zeigt das iTAC-Besitzerfenster; COMPONENT_TREE erfasst JInternalFrame/MyDoggy.\n'
|
||||
+'Eine JAAS UnsatisfiedLinkError kann die Dialogerzeugung verhindern und wird hier NICHT umgangen.';
|
||||
+'Die Abfragen laufen im Java-Hintergrundthread, ohne parallele CheerpJ-Library-Aufrufe.';
|
||||
}
|
||||
console.info('[WidgetWorkbench/WindowGeometry] Java-interner Monitor gestartet; '
|
||||
+width+'x'+height+'; Modus='+windowMode+'; keine JS-Library-Polling-Aufrufe.');
|
||||
return {stop(){ /* Monitor lebt als Java-Daemon bis zum Ende der JVM. */ }};
|
||||
}
|
||||
|
||||
// Request secrets only after the JVM has initialized and immediately before
|
||||
// main(). No URL/query parameters, storage or server-side password endpoint.
|
||||
async function requestBrowserCredentials(requestId){
|
||||
if(window.parent===window)return null; // standalone window has no trusted parent
|
||||
return new Promise(resolve=>{
|
||||
const waiter={requestId,resolve};credentialWaiter=waiter;
|
||||
const timeout=setTimeout(()=>{
|
||||
if(credentialWaiter===waiter){credentialWaiter=null;resolve(null);}
|
||||
},5000);
|
||||
waiter.finish=value=>{
|
||||
clearTimeout(timeout);
|
||||
if(credentialWaiter===waiter)credentialWaiter=null;
|
||||
resolve(value);
|
||||
};
|
||||
window.parent.postMessage({type:'hmi-cheerpj-credential-request',requestId},location.origin);
|
||||
});
|
||||
}
|
||||
function credentialNativeHandlers(requestId){
|
||||
return {
|
||||
...jaasNativeHandlers,
|
||||
// Direct JNI, not System.loadLibrary(). Results contain codes only.
|
||||
async Java_com_widgetworkbench_cheerpj_WorkplaceCredentialBridge_nativeReport(_lib,_self,code){
|
||||
const result=Number(code);
|
||||
const labels={1:'MES_LOGIN_SUCCESS',2:'MES_LOGIN_REJECTED',3:'ALREADY_AUTHENTICATED',4:'EXPIRED',5:'BRIDGE_ERROR'};
|
||||
console.info('[WidgetWorkbench/WorkplaceAuth]',labels[result]||'UNKNOWN_RESULT');
|
||||
if(window.parent!==window)window.parent.postMessage({type:'hmi-cheerpj-auth-result',requestId,code:result},location.origin);
|
||||
}
|
||||
};
|
||||
}
|
||||
function status(requestId,state,message){
|
||||
const text=String(message).slice(0,350);
|
||||
notice.textContent=text;notice.className=state==='error'?'fail':'';
|
||||
@@ -300,8 +271,12 @@ async function start(e,data){
|
||||
}
|
||||
// Keep a single JVM library context for tmp, optional JAAS diagnostics and
|
||||
// ResizeBridge: CheerpJ allows only one library thread in this configuration.
|
||||
const cp=manifest.paths.join(':')+(isWorkplace
|
||||
? ':'+JSONP_PROVIDER_JAR+':'+JAAS_BRIDGE_JAR+':'+CREDENTIAL_BRIDGE_JAR+':'+BRIDGE_JAR : '');
|
||||
const sysparamPatchEnabled=isWorkplace && params.get('sysparam')==='on';
|
||||
// Put the patch FIRST, before the vendor JNLP JARs, for both the one
|
||||
// CheerpJ Library Mode context and main(). When off, retain the old classpath.
|
||||
const cp=(sysparamPatchEnabled ? SYSPARAM_PATCH_JAR+':' : '')
|
||||
+manifest.paths.join(':')+(isWorkplace
|
||||
? ':'+JSONP_PROVIDER_JAR+':'+JAAS_BRIDGE_JAR+':'+BRIDGE_JAR : '');
|
||||
const diag=new URL(location.href).searchParams.get('diagnose');
|
||||
// Explicitly verify native JavaScript is delivered before VM initialization;
|
||||
// a successful HTTP response alone does NOT guarantee System.loadLibrary works.
|
||||
@@ -312,6 +287,16 @@ async function start(e,data){
|
||||
if(typeof jaasNativeHandlers?.Java_com_sun_security_auth_module_UnixSystem_getUnixInfo!=='function')
|
||||
throw Error('JAAS-JavaScript enthält keine gültige UnixSystem-JNI-Implementierung.');
|
||||
}
|
||||
// Verify delivery before starting the JVM. This is a same-origin immutable
|
||||
// build asset, never a dynamic/JNLP-defined classpath entry.
|
||||
if(sysparamPatchEnabled){
|
||||
boot('SysParameter-JAAS-Fallback-JAR prüfen');
|
||||
const patchResponse=await fetch(SYSPARAM_PATCH_URL,{
|
||||
credentials:'same-origin',cache:'no-store',headers:{Range:'bytes=0-0'}
|
||||
});
|
||||
if(patchResponse.status!==206)throw Error('SysParameter-JAAS-Fallback-JAR nicht mit HTTP 206 abrufbar '
|
||||
+'(HTTP '+patchResponse.status+'). Build/Deployment prüfen oder mit ?sysparam=off isoliert testen.');
|
||||
}
|
||||
// JNLP URL query parameters are not Java system properties.
|
||||
// CheerpJ supplies -D equivalents through javaProperties.
|
||||
const javaProperties=isWorkplace && manifest.clusterNodes
|
||||
@@ -320,18 +305,40 @@ async function start(e,data){
|
||||
// writable subdirectory after probing, before launching the application.
|
||||
if(isWorkplace){
|
||||
javaProperties.push('java.io.tmpdir=/files');
|
||||
if(params.get('identity')!=='native')javaProperties.push('os.name=CheerpJ Browser','user.name=cheerpj-client');
|
||||
// Must be present at VM initialization: UnixSystem() calls loadLibrary("jaas")
|
||||
// before running its private native method getUnixInfo().
|
||||
javaProperties.push('java.library.path='+JAAS_NATIVE_PATH);
|
||||
}
|
||||
boot('CheerpJ-Initialisierung');
|
||||
await window.cheerpjInit({version,status:'none',javaProperties,
|
||||
...(isWorkplace ? {natives:credentialNativeHandlers(id)} : {})});
|
||||
...(isWorkplace ? {natives:jaasNativeHandlers} : {})});
|
||||
boot('CheerpJ initialisiert');
|
||||
let sharedLib=null;
|
||||
if(isWorkplace){
|
||||
boot('Gemeinsamen Java-Library-Kontext starten');
|
||||
sharedLib=await window.cheerpjRunLibrary(cp);
|
||||
if(sysparamPatchEnabled){
|
||||
// Force resolution of this exact class BEFORE the vendor main launches.
|
||||
// An absent marker means an original iTAC class shadowed our patch.
|
||||
// SecurityException / NoClassDefFoundError here may signal signed-package
|
||||
// conflict and are NEVER suppressed as an apparent successful patch.
|
||||
boot('SysParameter-Ersatzklasse verifizieren');
|
||||
try{
|
||||
const SysParameter=await sharedLib.com.itac.util.system.SysParameter;
|
||||
if(typeof SysParameter?.widgetWorkbenchJaasFallbackLevel!=='function')
|
||||
throw Error('Originalklasse aktiv: Patch-Marker nicht gefunden. Klassenpfad-Reihenfolge prüfen.');
|
||||
const level=await SysParameter.widgetWorkbenchJaasFallbackLevel();
|
||||
if(Number(level)!==1)throw Error('Unerwartete SysParameter-Patchversion.');
|
||||
console.info('[WidgetWorkbench/SysParameter] JAAS-Fallback-Ersatzklasse v1 aktiviert; '
|
||||
+'iTAC PersonService-Authentifizierung unverändert.');
|
||||
}catch(error){
|
||||
const original=await describeThrowable(error);
|
||||
throw Error('SysParameter-Patch konnte nicht geladen oder verifiziert werden: '+original+
|
||||
'. Möglicher Signatur-/Split-Package-Konflikt mit iTAC-JARs. '
|
||||
+'Für den unveränderten Klassenpfad ?sysparam=off verwenden.');
|
||||
}
|
||||
}
|
||||
status(id,'loading','Virtuelles Workplace-Temp-Verzeichnis wird vorbereitet …');
|
||||
boot('Temp-Verzeichnis prüfen');
|
||||
const tempDir=await ensureWorkplaceTempDirectory(sharedLib);
|
||||
@@ -384,32 +391,6 @@ async function start(e,data){
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(data.browserCredentials===true){
|
||||
boot('Einmalige Browser-Anmeldung vorbereiten');
|
||||
const credentials=await requestBrowserCredentials(id);
|
||||
if(credentials){
|
||||
// Probe only when a one-time offer was made. Server must support Range.
|
||||
const credentialProbe=await fetch(CREDENTIAL_BRIDGE_URL,{
|
||||
credentials:'same-origin',cache:'no-store',headers:{Range:'bytes=0-0'}
|
||||
});
|
||||
if(credentialProbe.status!==206){
|
||||
status(id,'loading','Workplace-Anmeldebridge ist nicht verfügbar; normaler Login bleibt aktiv.');
|
||||
}else{
|
||||
try{
|
||||
const authBridge=await sharedLib.com.widgetworkbench.cheerpj.WorkplaceCredentialBridge;
|
||||
const accepted=await authBridge.offer(credentials.username,credentials.password,credentials.client);
|
||||
if(Number(accepted)!==1)throw Error('Einmalige Anmeldung wurde von der Java-Bridge abgelehnt.');
|
||||
// No success claim until the Java nativeReport callback reports code 1.
|
||||
console.info('[WidgetWorkbench/WorkplaceAuth] One-shot offer accepted; waiting for PersonService');
|
||||
}catch(error){
|
||||
console.warn('[WidgetWorkbench/WorkplaceAuth] Übergabe fehlgeschlagen (Zugangsdaten und Exception werden nicht protokolliert).');
|
||||
status(id,'loading','Workplace-Übergabe fehlgeschlagen; manueller MES-Login bleibt möglich.');
|
||||
}
|
||||
}
|
||||
}else{
|
||||
console.info('[WidgetWorkbench/WorkplaceAuth] Keine Browser-Zugangsdaten angeboten; normaler MES-Login.');
|
||||
}
|
||||
}
|
||||
boot('Java-internen Swing-Fenstermonitor starten ('+windowMode+')');
|
||||
try{
|
||||
windowMonitor=await attachWorkplaceRuntimeMonitor(screen,sharedLib,windowMode,displayMode);
|
||||
@@ -418,6 +399,16 @@ async function start(e,data){
|
||||
manifest.warnings.push('Fenstermonitor nicht verfügbar; Workplace-Start wird fortgesetzt.');
|
||||
}
|
||||
}
|
||||
if(isWorkplace && params.get('identity')!=='native'){
|
||||
// Browser JVM has no host OS identity. The original signed SysParameter
|
||||
// explicitly falls back to user.name for non-desktop OS names. Set this
|
||||
// in the library context too; init properties also cover runMain.
|
||||
// Manufacturer bytecode remains unchanged.
|
||||
boot('Browser-Identität ohne Desktop-JAAS vorbereiten');
|
||||
const System=await sharedLib.java.lang.System;
|
||||
await System.setProperty('os.name','CheerpJ Browser');
|
||||
await System.setProperty('user.name','cheerpj-client');
|
||||
}
|
||||
boot('iTAC Workplace main(): '+(manifest.main?'Startklasse vorhanden':'JAR-Start'));
|
||||
status(id,'running','Java-Anwendungsstart wird versucht. '+manifest.warnings.join(' '));
|
||||
try{
|
||||
@@ -432,18 +423,8 @@ async function start(e,data){
|
||||
window.addEventListener('message',event=>{
|
||||
if(event.source!==window.parent||event.origin!==location.origin)return;
|
||||
const data=event.data;
|
||||
if(!data||typeof data.requestId!=='string'||data.requestId.length>150)return;
|
||||
if(data.type==='hmi-cheerpj-credentials'||data.type==='hmi-cheerpj-credentials-unavailable'){
|
||||
const waiter=credentialWaiter;
|
||||
if(!waiter||waiter.requestId!==data.requestId)return;
|
||||
if(data.type==='hmi-cheerpj-credentials-unavailable'){waiter.finish(null);return;}
|
||||
if(typeof data.username!=='string'||!data.username||data.username.length>120
|
||||
||typeof data.password!=='string'||!data.password||data.password.length>1024
|
||||
||typeof data.client!=='string'||!data.client||data.client.length>120)return;
|
||||
waiter.finish({username:data.username,password:data.password,client:data.client});
|
||||
return;
|
||||
}
|
||||
if(data.type==='hmi-cheerpj-launch')void start(event,data);
|
||||
if(!data||data.type!=='hmi-cheerpj-launch'||typeof data.requestId!=='string'||data.requestId.length>150)return;
|
||||
void start(event,data);
|
||||
});
|
||||
|
||||
// Direct, full-window workplace mode. This URL is deliberately limited to the
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user