init: CasSsoService CAS 5.3 overlay (cas.war via LFS)

This commit is contained in:
chenxing
2026-08-05 09:53:49 +08:00
commit 3bd14554ec
93 changed files with 19827 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
import zipfile, os, shutil
PROJ = "D:/SoftProject/yunhai/CasSso/cas-overlay-template-5.3"
WAR = os.path.join(PROJ, "docker/cas.war")
# (entry_name_in_war, local_source_file)
REPL = [
("WEB-INF/classes/org/apereo/cas/web/custom/controller/LoginController.class",
os.path.join(PROJ, "target/cas/WEB-INF/classes/org/apereo/cas/web/custom/controller/LoginController.class")),
("WEB-INF/classes/org/apereo/cas/web/custom/controller/LoginController$LocalAuthenticationResult.class",
os.path.join(PROJ, "target/cas/WEB-INF/classes/org/apereo/cas/web/custom/controller/LoginController$LocalAuthenticationResult.class")),
("front/index.html",
os.path.join(PROJ, "src/main/webapp/front/index.html")),
]
repl_map = {name: open(src, "rb").read() for name, src in REPL}
tmp = WAR + ".tmp"
zin = zipfile.ZipFile(WAR)
zout = zipfile.ZipFile(tmp, "w", zipfile.ZIP_DEFLATED)
for item in zin.infolist():
if item.filename in repl_map:
zout.writestr(item, repl_map[item.filename])
else:
zout.writestr(item, zin.read(item.filename))
zin.close()
zout.close()
shutil.move(tmp, WAR)
z = zipfile.ZipFile(WAR)
print("testzip:", z.testzip())
html = z.read("front/index.html").decode("utf-8", "replace")
print("has pwdMgrForm:", "pwdMgrForm" in html)
print("has name=\"username\":", 'name="username"' in html)
print("has name=\"password\":", 'name="password"' in html)
cls = z.read("WEB-INF/classes/org/apereo/cas/web/custom/controller/LoginController.class")
print("default url in class:", b"front/index.html" in cls)
print("entries replaced OK")