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.
65 lines
1.9 KiB
65 lines
1.9 KiB
3 years ago
|
package com.fr.plugin;
|
||
|
|
||
|
import com.fanruan.api.conf.HolderKit;
|
||
|
import com.fanruan.api.decision.auth.BasePassport;
|
||
|
import com.fanruan.api.net.http.HttpKit;
|
||
|
import com.fanruan.api.util.AssistKit;
|
||
|
import com.fanruan.api.util.StringKit;
|
||
|
import com.fr.config.Identifier;
|
||
|
import com.fr.config.holder.Conf;
|
||
|
import com.fr.stable.StringUtils;
|
||
|
|
||
|
import java.io.IOException;
|
||
|
|
||
|
public class Oauth2Passport extends BasePassport {
|
||
|
@Override
|
||
|
public String markType() {
|
||
|
return FLPassportProvider.PASSPORT_TYPE;
|
||
|
}
|
||
|
|
||
|
@Identifier("emptytoken")
|
||
|
private Conf<String> emptytoken = HolderKit.simple(StringKit.EMPTY);
|
||
|
|
||
|
@Override
|
||
|
public int hashCode() {
|
||
|
return AssistKit.hashCode(emptytoken.get());
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public Object clone() throws CloneNotSupportedException {
|
||
|
return super.clone();
|
||
|
}
|
||
|
|
||
|
public String getEmptytoken() {
|
||
|
return emptytoken.get();
|
||
|
}
|
||
|
|
||
|
public void setEmptytoken(String emptytoken) {
|
||
|
this.emptytoken.set(emptytoken);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public boolean equals(Object obj) {
|
||
|
if (!(obj instanceof Oauth2Passport)) {
|
||
|
return false;
|
||
|
}
|
||
|
Oauth2Passport target = (Oauth2Passport) obj;
|
||
|
return AssistKit.equals(target.getEmptytoken(), this.getEmptytoken());
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public boolean checkTicket(String username, String inputPassword, String savedPassword, String hashPassword) {
|
||
|
//调用接口验证账号密码
|
||
|
FLConfig flConfig = FLConfig.getInstance();
|
||
|
String url = String.format("%s/am/identity/authenticate?username=%s&password=%s&uri=service=initService", flConfig.getValAddr(), username, inputPassword);
|
||
|
try {
|
||
|
String resp = HttpKit.get(url);
|
||
|
return StringUtils.contains(resp,"token.id=");
|
||
|
} catch (IOException e) {
|
||
|
e.printStackTrace();
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
}
|