You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.0 KiB
60 lines
2.0 KiB
package com.tptj.course.hg.login.expand; |
|
|
|
|
|
import com.fr.decision.authority.data.User; |
|
import com.fr.decision.webservice.exception.user.UserNotAvailableException; |
|
import com.fr.decision.webservice.utils.ControllerFactory; |
|
import com.fr.stable.web.Device; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
import java.util.HashMap; |
|
import java.util.Map; |
|
import java.util.Set; |
|
|
|
/** |
|
* @author 秃破天际 |
|
* @version 10.0 |
|
* Created by 秃破天际 on 2021/6/23 |
|
**/ |
|
public class SpPassport{ |
|
|
|
private String markType(){ |
|
return this.getClass().getName(); |
|
} |
|
|
|
public boolean auth(HttpServletRequest request, User user, String password ){ |
|
return false; |
|
} |
|
|
|
public String getRealUsername(HttpServletRequest request,String username, String inputPassword ){ |
|
return username; |
|
} |
|
|
|
private static Map<String,SpPassport> passports = new HashMap<String,SpPassport>(); |
|
|
|
public static void register( SpPassport passport ){ |
|
passports.put(passport.markType(),passport); |
|
} |
|
|
|
public static String transform( HttpServletRequest request,String username, String inputPassword ){ |
|
Set<Map.Entry<String, SpPassport>> entries = passports.entrySet(); |
|
for( Map.Entry<String, SpPassport> entry : entries ){ |
|
username = entry.getValue().getRealUsername( request,username, inputPassword ); |
|
} |
|
return username; |
|
} |
|
|
|
public static boolean check( HttpServletRequest request,User user, String password, Device device )throws Exception{ |
|
if( !user.isEnable() ){ |
|
throw new UserNotAvailableException(); |
|
} |
|
ControllerFactory.getInstance().getAuthenticController(user.getId()).checkUserTypeAvailable(user, device); |
|
Set<Map.Entry<String, SpPassport>> entries = passports.entrySet(); |
|
for( Map.Entry<String, SpPassport> entry : entries ){ |
|
if( entry.getValue().auth( request,user, password ) ){ |
|
return true; |
|
} |
|
} |
|
return false; |
|
} |
|
}
|
|
|