mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-08 01:48:33 +08:00
FormBased password
This commit is contained in:
parent
bccb47086f
commit
b5decd3a6a
@ -25,6 +25,8 @@ public class SubStr {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
String browser="Chrome/44.0.2369.0";
|
String browser="Chrome/44.0.2369.0";
|
||||||
System.out.println(browser.indexOf('.'));
|
System.out.println(browser.indexOf('.'));
|
||||||
|
String passwordAlgorithm = "MD5-HEX";
|
||||||
|
System.out.println(passwordAlgorithm.substring(0,passwordAlgorithm.indexOf("-HEX")));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,6 +19,7 @@ package org.maxkey.authz.formbased.endpoint.adapter;
|
|||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter;
|
import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter;
|
||||||
import org.maxkey.constants.ConstsBoolean;
|
import org.maxkey.constants.ConstsBoolean;
|
||||||
import org.maxkey.crypto.DigestUtils;
|
import org.maxkey.crypto.DigestUtils;
|
||||||
@ -27,6 +28,8 @@ import org.springframework.web.servlet.ModelAndView;
|
|||||||
|
|
||||||
public class FormBasedDefaultAdapter extends AbstractAuthorizeAdapter {
|
public class FormBasedDefaultAdapter extends AbstractAuthorizeAdapter {
|
||||||
|
|
||||||
|
static String _HEX = "_HEX";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object generateInfo() {
|
public Object generateInfo() {
|
||||||
return null;
|
return null;
|
||||||
@ -38,11 +41,16 @@ public class FormBasedDefaultAdapter extends AbstractAuthorizeAdapter {
|
|||||||
AppsFormBasedDetails details=(AppsFormBasedDetails)app;
|
AppsFormBasedDetails details=(AppsFormBasedDetails)app;
|
||||||
|
|
||||||
String password = account.getRelatedPassword();
|
String password = account.getRelatedPassword();
|
||||||
if(null==details.getPasswordAlgorithm()||details.getPasswordAlgorithm().equals("")){
|
String passwordAlgorithm = details.getPasswordAlgorithm();
|
||||||
}else if(details.getPasswordAlgorithm().indexOf("HEX")>-1){
|
|
||||||
password = DigestUtils.digestHex(account.getRelatedPassword(),details.getPasswordAlgorithm().substring(0, details.getPasswordAlgorithm().indexOf("HEX")));
|
if(StringUtils.isBlank(passwordAlgorithm)
|
||||||
|
|| passwordAlgorithm.equalsIgnoreCase("NONE")){
|
||||||
|
//do nothing
|
||||||
|
}else if(passwordAlgorithm.indexOf(_HEX) > -1){
|
||||||
|
passwordAlgorithm = passwordAlgorithm.substring(0,passwordAlgorithm.indexOf(_HEX));
|
||||||
|
password = DigestUtils.digestHex(account.getRelatedPassword(),passwordAlgorithm);
|
||||||
}else{
|
}else{
|
||||||
password = DigestUtils.digestBase64(account.getRelatedPassword(),details.getPasswordAlgorithm());
|
password = DigestUtils.digestBase64(account.getRelatedPassword(),passwordAlgorithm);
|
||||||
}
|
}
|
||||||
|
|
||||||
modelAndView.addObject("id", details.getId());
|
modelAndView.addObject("id", details.getId());
|
||||||
@ -62,7 +70,7 @@ public class FormBasedDefaultAdapter extends AbstractAuthorizeAdapter {
|
|||||||
modelAndView.addObject("isExtendAttr", false);
|
modelAndView.addObject("isExtendAttr", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(details.getAuthorizeView()!=null&&!details.getAuthorizeView().equals("")){
|
if(StringUtils.isNotBlank(details.getAuthorizeView())){
|
||||||
modelAndView.setViewName("authorize/"+details.getAuthorizeView());
|
modelAndView.setViewName("authorize/"+details.getAuthorizeView());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user