Element reason = root.getChild("reason");
String text = reason.getAttributeValue("text"); //原因
String tips = reason.getAttributeValue("tips"); //一些提示
//解析一些获取验证图片的参数
SipcHeader wwwHeader = response.getHeader(SipcHeader.WWWAUTHENTICATE);
Pattern pt = Pattern.compile("Verify algorithm=\"(.*?)\",type=\"(.*?)\"");
Matcher mc = pt.matcher(wwwHeader.getValue());
if(mc.matches()) {
String alg = mc.group(1); //验证图片算法
String type = mc.group(2); //类型???啥意思。。。
VerifyImage verifyImage = null;
try {
verifyImage = HttpApplication.fetchVerifyImage(context.getFetionUser(),
context.getLocaleSetting(), alg, type);
} catch (IOException e) {
throw new IllegalStateException("fetch verify image failed.", e);
}
//通知设置的通知监听器处理这个验证码事件,如果没有设置监听器,将抛出异常
NotifyEventListener listener = this.context.getNotifyEventListener();
if(listener!=null) {
listener.fireEvent(new ImageVerifyEvent(ImageVerifyEvent.SIPC_VERIFY,
verifyImage, text, tips, response.getRequest(),
this.dialog, this.listener));
}else{
throw new IllegalArgumentException("action need verify, but found no NotifyEventListener" +
" to handle verify action, please set NotifyEventListener first.");
}
}else {
throw new IllegalStateException("parse verify info failed. wwwHeader="+wwwHeader.getValue());
}
return null; //返回null,表明处理这个回复事件
}