Commit 5e060c4d authored by steurwadkar's avatar steurwadkar

F17ABAS001 source code commit


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@106134 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 2dca37c7
......@@ -11,7 +11,6 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
......@@ -21,9 +20,6 @@ import java.util.UUID;
import javax.annotation.PostConstruct;
import org.bouncycastle.crypto.digests.SHA256Digest;
import org.bouncycastle.crypto.macs.HMac;
import org.bouncycastle.crypto.params.KeyParameter;
import org.json.JSONObject;
import org.json.XML;
import org.w3c.dom.Document;
......@@ -464,7 +460,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
valueXmlString.append("<Detail2 domID='1'>");
valueXmlString.append("<auth_token><![CDATA["+ authToken +"]]></auth_token>");
valueXmlString.append("<auth_sek><![CDATA["+ authSEK +"]]></auth_sek>");
valueXmlString.append("<auth_sek><![CDATA["+ sek +"]]></auth_sek>");
valueXmlString.append("</Detail2>" );
valueXmlString.append("<Detail2 domID='2'>");
valueXmlString.append(retXML);
......@@ -674,20 +670,6 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
rs.close();
rs = null;
}
/*sql = "SELECT COUNT(1) AS CNT FROM GST_DATA_HDR WHERE REC_TYPE = '1' AND SUBMIT_STATUS = 'P' AND PRD_CODE = ? AND SITE_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, periodCode);
pstmt.setString(2, loginSiteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
if(rs.getInt("CNT") > 0)
{
errList.add( "VTRECSAPEN" );
errFields.add("returns_type");
}
}*/
}
}
break;
......@@ -878,7 +860,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
{
System.out.println("GSTDataSubmitWizEJB.handleRequest()["+e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
retResponseXML = "<root><message><![CDATA[Message : Error occured!]]></message></root>";
}
finally
{
......@@ -916,7 +898,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
gspAuthString = clientId + ":" + transactionId + ":" + timeStamp + ":" + gstinNo;
gspAuthSignature = gspSignature.sign(gspAuthString, aspPrivateKey);
HttpResponse<JsonNode> getDataResp = Unirest.get(String.format("%s%s", GSP_API_URL,GSTR1_URL_V2))//TODO need to change URL to v0.3
HttpResponse<JsonNode> getDataResp = Unirest.get(String.format("%s%s", GSP_API_URL,GSTR1_URL_V3))
.queryString("action", action)
.queryString("gstin", gstinNo)
.queryString("ret_period", periodCode)
......@@ -1049,7 +1031,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
gspAuthString = clientId + ":" + transactionId + ":" + timeStamp + ":" + gstin;
gspAuthSignature = gspSignature.sign(gspAuthString, aspPrivateKey);
HttpResponse<JsonNode> getGstr1SumryResp = Unirest.get(String.format("%s%s", GSP_API_URL, GSTR1_URL_V2))//TODO need to change with version 0.3
HttpResponse<JsonNode> getGstr1SumryResp = Unirest.get(String.format("%s%s", GSP_API_URL, GSTR1_URL_V3))
.queryString("action","RETSUM")
.queryString("gstin", gstin)
.queryString("ret_period", periodCode)
......
......@@ -273,110 +273,129 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
}
}
detail2NList = allXMLDom.getElementsByTagName("Detail2");
System.out.println("returnsType["+returnsType+"] action ["+action+"]");
for(int i=0; i<detail2NList.getLength(); i++)
if("SUBMIT".equalsIgnoreCase(action))
{
Node eachDetail2Node = detail2NList.item(i);
System.out.println("560101.domId["+eachDetail2Node.getAttributes().getNamedItem("domID")+"]");
detail2ChildNList = eachDetail2Node.getChildNodes();
detail2NList = allXMLDom.getElementsByTagName("Detail2");
detail2ChildNList = detail2NList.item(0).getChildNodes();
for(int j=0; j<detail1ChildNList.getLength();j++)
for(int i=0; i<detail2ChildNList.getLength();i++)
{
Node eachDetail2Element = detail2ChildNList.item(j);
Node eachDetail2Element = detail2ChildNList.item(i);
nodeName = eachDetail2Element.getNodeName();
if(!"#text".equalsIgnoreCase(nodeName) && !"attribute".equals(nodeName))
{
if("auth_token".equalsIgnoreCase(nodeName))
{
authToken = eachDetail2Element.getTextContent();
}
else if("auth_sek".equalsIgnoreCase(nodeName))
{
sek = eachDetail2Element.getTextContent();
}
}
}
System.out.println("authToken["+authToken+"] sek["+sek+"]");
}
System.out.println("returnsType["+returnsType+"] action ["+action+"]");
appKeyInBytes = aesEncryption.decodeBase64StringTOByte(appKey);
appKeyEncryptedAndCoded = pubKeyEncryption.encrypt(appKeyInBytes);
String encryptedOTP = aesEncryption.encryptEK(otp.getBytes(), appKeyInBytes);
JSONObject authTokenReq = new JSONObject();
authTokenReq.put("action", "AUTHTOKEN");
authTokenReq.put("username", userName);
authTokenReq.put("app_key", appKeyEncryptedAndCoded);
authTokenReq.put("otp", encryptedOTP);
long timeStamp = new Timestamp().getDateTime();
gspAuthString = clientId + ":" + transactionId + ":" + timeStamp + ":" + gstin;
gspAuthSignature = gspSignature.sign(gspAuthString, aspPrivateKey);
if(authToken.trim().length() > 0 && sek.trim().length() > 0)
{
System.out.println("authToken and authSEK from detail2");
authSEK = aesEncryption.decrypt(sek, appKeyInBytes);
System.out.println("AuthSEK = "+ aesEncryption.encodeBase64String(authSEK));
}
else
{
String encryptedOTP = aesEncryption.encryptEK(otp.getBytes(), appKeyInBytes);
JSONObject authTokenReq = new JSONObject();
authTokenReq.put("action", "AUTHTOKEN");
authTokenReq.put("username", userName);
authTokenReq.put("app_key", appKeyEncryptedAndCoded);
authTokenReq.put("otp", encryptedOTP);
long timeStamp = new Timestamp().getDateTime();
gspAuthString = clientId + ":" + transactionId + ":" + timeStamp + ":" + gstin;
gspAuthSignature = gspSignature.sign(gspAuthString, aspPrivateKey);
HttpResponse<JsonNode> authTokenResp = Unirest.post(String.format("%s%s", GSP_API_URL, AUTH_TOKEN_URL_V2))
.header("Content-Type",APPLICATION_JSON)
.header("clientid", clientId)
.header("client-secret", clientSecret)
.header("state-cd", stateCode)
.header("ip-usr", ipAddress.getHostAddress())
.header("txn", transactionId)
.header("app_key", appKeyEncryptedAndCoded)
.header("X-Asp-Auth-Token", gspAuthString)
.header("X-Asp-Auth-Signature", gspAuthSignature)
.body(new JsonNode(authTokenReq.toString()))
.asJson();
HttpResponse<JsonNode> authTokenResp = Unirest.post(String.format("%s%s", GSP_API_URL, AUTH_TOKEN_URL_V2))
.header("Content-Type",APPLICATION_JSON)
.header("clientid", clientId)
.header("client-secret", clientSecret)
.header("state-cd", stateCode)
.header("ip-usr", ipAddress.getHostAddress())
.header("txn", transactionId)
.header("app_key", appKeyEncryptedAndCoded)
.header("X-Asp-Auth-Token", gspAuthString)
.header("X-Asp-Auth-Signature", gspAuthSignature)
.body(new JsonNode(authTokenReq.toString()))
.asJson();
System.out.println(String.format("authTokenResp Request : Status[%s] Response[%s]", authTokenResp.getStatus(), authTokenResp.getBody()));
if (authTokenResp.getStatus() == 200)
{
JSONObject object = authTokenResp.getBody().getObject();
if (object.has("auth_token") && object.has("sek") && object.has("status_cd") && Objects.equals(object.getString("status_cd"), "1"))
{
authToken = object.getString("auth_token");
sek = object.getString("sek");
System.out.println(String.format("authTokenResp Request : Status[%s] Response[%s]", authTokenResp.getStatus(), authTokenResp.getBody()));
if (authTokenResp.getStatus() == 200)
{
JSONObject object = authTokenResp.getBody().getObject();
if (object.has("auth_token") && object.has("sek") && object.has("status_cd") && Objects.equals(object.getString("status_cd"), "1"))
{
authToken = object.getString("auth_token");
sek = object.getString("sek");
authSEK = aesEncryption.decrypt(sek, appKeyInBytes);
System.out.println("AuthSEK = "+ aesEncryption.encodeBase64String(authSEK));
if("GSTR1".equalsIgnoreCase(returnsType))
{
if("SAVE".equalsIgnoreCase(action))
{
retString = saveGstr1(authToken, siteCode, stateCode, userName, gstin, periodCode, grossTurnover, authSEK, conn);
}
else if ("RETSUM".equalsIgnoreCase(action) || "FILE".equalsIgnoreCase(action))
{
retString = getGstr1Summary(authToken, stateCode, userName, gstin, periodCode, authSEK, action, conn);
}
else if ("SUBMIT".equalsIgnoreCase(action))
{
retString = submitGstr1(authToken, stateCode, userName, gstin, periodCode, authSEK, conn);
}
}
else if("GSTR2".equalsIgnoreCase(returnsType))
{
if("GETINV".equalsIgnoreCase(action))
{
retString = getGstr2Invoices(authToken, stateCode, userName, gstin, periodCode, siteCode, authSEK, conn);
}
}
}
else
{
JSONObject errorJSON = authTokenResp.getBody().getObject().getJSONObject("error");
if("AUTH4033".equalsIgnoreCase(errorJSON.getString("error_cd")))
{
retString = new ITMDBAccessEJB().getErrorString("","VTINVOTP","","",conn);
}
else
{
String errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
}
}
}
else
{
JSONObject errorJSON = authTokenResp.getBody().getObject().getJSONObject("error");
String errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
}
authSEK = aesEncryption.decrypt(sek, appKeyInBytes);
System.out.println("AuthSEK = "+ aesEncryption.encodeBase64String(authSEK));
}
else
{
JSONObject errorJSON = authTokenResp.getBody().getObject().getJSONObject("error");
if("AUTH4033".equalsIgnoreCase(errorJSON.getString("error_cd")))
{
retString = new ITMDBAccessEJB().getErrorString("","VTINVOTP","","",conn);
}
else
{
String errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
}
}
}
else
{
JSONObject errorJSON = authTokenResp.getBody().getObject().getJSONObject("error");
String errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
}
}
if("GSTR1".equalsIgnoreCase(returnsType))
{
if("SAVE".equalsIgnoreCase(action))
{
retString = saveGstr1(authToken, siteCode, stateCode, userName, gstin, periodCode, grossTurnover, authSEK, conn);
}
else if ("RETSUM".equalsIgnoreCase(action) || "FILE".equalsIgnoreCase(action))
{
retString = getGstr1Summary(authToken, stateCode, userName, gstin, periodCode, authSEK, action, conn);
}
else if ("SUBMIT".equalsIgnoreCase(action))
{
retString = submitGstr1(authToken, stateCode, userName, gstin, periodCode, authSEK, conn);
}
}
else if("GSTR2".equalsIgnoreCase(returnsType))
{
if("GETINV".equalsIgnoreCase(action))
{
retString = getGstr2Invoices(authToken, stateCode, userName, gstin, periodCode, siteCode, authSEK, conn);
}
}
}
catch(Exception e)
{
......@@ -1514,7 +1533,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
.header("ret_period", periodCode)
.header("gstin", gstin)
.header("X-Asp-Auth-Token", gspAuthString)
.header("X-Asp-Auth-Signature", gspAuthSignature)
.header("X-Asp-Auth-Signature", gspAuthSignature)
.body(new JsonNode(reqBody.toString()))
.asJson();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment