ฉันพยายามที่จะดำเนิ logining ผ่านลายเซ็นดิจิตอลกับการล็อกอินหน้าฉันต้องการข้อมูลที่ถูกสร้างขึ้นทุกการล็อกอินความพยายามแล้วซึ่งผมจะเซ็นชื่อแล้วส่งบนเซิร์ฟเวอร์ดังนั้นฉันกำลังมองหาทางวิธีการนำข้อมูลเซิร์ฟเวอร์อยู่ที่ล็อกอินหน้าที่ฉันจะไปตรวจสอบนเซิร์ฟเวอร์หลังจากรูปแบบส่งข้อมูลการ
ไหลเวียนไม่จบลงไม่ค่อยได้เห็น แต่บางทีอาจจะมีทางที่ authote ต้องการล็อกอินหน้า?
public class ExtAuthenticator extends UsernamePasswordForm {
private static final Logger logger = Logger.getLogger(ExtAuthenticatorclass);
private static final String LOGIN_FTL = "login-eds.ftl";
@Override
public void action(AuthenticationFlowContext context) {
logger.infof("EDSAuthenticator action entry");
MultivaluedMap<String, String> formData = context.getHttpRequest().getDecodedFormParameters();
if (!validateForm(context, formData)) {
return;
}
KeycloakSession session = context.getSession();
RealmModel realm = context.getRealm();
UserModel user = session.users().getUserByUsername(realm, "user");
context.setUser(user);
context.success();
}
@Override
protected boolean validateForm(AuthenticationFlowContext context, MultivaluedMap<String, String> formData) {
logger.infof("EDSAuthenticator validateForm entry");
logger.infof(context.getAuthenticationSession().getAuthNote("signdata"));
formData.forEach((key, value) ->{
System.out.println(key + ":" + value.size()) ;
System.out.println(key + ":" + value.toString());
}
);
return true;
}
@Override
public boolean requiresUser() {
return false;
}
@Override
protected Response challenge(AuthenticationFlowContext context, MultivaluedMap<String, String> formData) {
LoginFormsProvider forms = context.form();
**//maybe there is a way to place this note to login page?**
context.getAuthenticationSession().setAuthNote("signdata", "signdatavalue");
if (!formData.isEmpty()) forms.setFormData(formData);
return forms.createForm(LOGIN_FTL);
}
@Override
protected Response createLoginForm(LoginFormsProvider form) {
return form.createForm(LOGIN_FTL);
}
@Override
protected String getDefaultChallengeMessage(AuthenticationFlowContext context) {
return Messages.INVALID_USERNAME;
}
}
ล็อกอิน ftl FYI มีบา js สคริปต์อยู่เบื้องหลังเรื่องนี้รูปแบบซึ่งทำงานกับ cert
<#import "template.ftl" as layout>
<@layout.registrationLayout displayInfo=(realm.password && realm.registrationAllowed && !registrationDisabled??); section>
<#if section = "header">
Enter
<#elseif section = "form">
<div id="kc-form">
<div id="kc-form-wrapper">
<#if realm.password>
<form id="kc-form-login" onsubmit="login.disabled = true; return true;" action="${url.loginAction}"
method="post">
<div class="${properties.kcFormGroupClass!}" style="display:none">
<label for="signedXML" class="${properties.kcLabelClass!}">signedXML</label>
<input id="signedXML" class="${properties.kcInputClass!}" value="signed xml test text" name="signedXML" type="hidden"/>
</div>
<div id="kc-form-buttons" class="${properties.kcFormGroupClass!}">
<input tabindex="4"
class="${properties.kcButtonClass!} ${properties.kcButtonPrimaryClass!} ${properties.kcButtonBlockClass!} ${properties.kcButtonLargeClass!}"
name="login" id="kc-login" onClick="signXmlCall()" type="button" value="choose cert"/>
</div>
</form>
</#if>
</div>
</div>
</#if>
</@layout.registrationLayout>