{
LoginState state = null;
String url = this.buildUrl(user, img);
try {
URL doUrl = new URL(url);
HttpsURLConnection conn = (HttpsURLConnection) doUrl.openConnection();
int status = conn.getResponseCode();
logger.debug("SSISignV4:status="+status);
switch(status){
case 401:
logger.debug("Invalid password...");
state = LoginState.SSI_AUTH_FAIL;
break;
case 421:
Element e = XMLHelper.build(conn.getErrorStream());
Element vn = XMLHelper.find(e, "/results/verification");
this.processVerifyAction(vn.getAttributeValue("algorithm"), vn.getAttributeValue("type"),
vn.getAttributeValue("text"), vn.getAttributeValue("tips"));
return LoginState.SSI_NEED_VERIFY;
case 420:
logger.debug("SSISignV4: invalid verify code.");
Element e1 = XMLHelper.build(conn.getErrorStream());
Element vn1 = XMLHelper.find(e1, "/results/verification");
this.processVerifyAction(vn1.getAttributeValue("algorithm"), vn1.getAttributeValue("type"),
vn1.getAttributeValue("text"), vn1.getAttributeValue("tips"));
state = LoginState.SSI_VERIFY_FAIL;
break;
case 433:
logger.debug("SSISignV4: User account suspend.");
state = LoginState.SSI_ACCOUNT_SUSPEND;
break;
case 404:
logger.debug("SSISignV4: User not found..");
state = LoginState.SSI_ACCOUNT_NOT_FOUND;
break;
case 503:
logger.debug("SSISignV4: SSIServer overload...");
state = LoginState.SSI_CONNECT_FAIL;
break;
case 200:
logger.debug("SSISignIn: sign in success.");
state = LoginState.SSI_SIGN_IN_SUCCESS;
String h = conn.getHeaderField("Set-Cookie");
int s = h.indexOf("ssic=");
int m = h.indexOf(';');
user.setSsiCredential( h.substring(s+5,m) );
Element root = XMLHelper.build(conn.getInputStream());
Element userEl = XMLHelper.find(root, "/results/user");
user.setUri(userEl.getAttributeValue("uri"));
user.setUserId(Integer.parseInt(userEl.getAttributeValue("user-id")));
String mobileStr = userEl.getAttributeValue("mobile-no");
if(mobileStr!=null && mobileStr.length()>0)