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; ...@@ -11,7 +11,6 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Base64;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
...@@ -21,9 +20,6 @@ import java.util.UUID; ...@@ -21,9 +20,6 @@ import java.util.UUID;
import javax.annotation.PostConstruct; 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.JSONObject;
import org.json.XML; import org.json.XML;
import org.w3c.dom.Document; import org.w3c.dom.Document;
...@@ -464,7 +460,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi ...@@ -464,7 +460,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
valueXmlString.append("<Detail2 domID='1'>"); valueXmlString.append("<Detail2 domID='1'>");
valueXmlString.append("<auth_token><![CDATA["+ authToken +"]]></auth_token>"); 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>" );
valueXmlString.append("<Detail2 domID='2'>"); valueXmlString.append("<Detail2 domID='2'>");
valueXmlString.append(retXML); valueXmlString.append(retXML);
...@@ -674,20 +670,6 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi ...@@ -674,20 +670,6 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
rs.close(); rs.close();
rs = null; 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; break;
...@@ -878,7 +860,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi ...@@ -878,7 +860,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
{ {
System.out.println("GSTDataSubmitWizEJB.handleRequest()["+e.getMessage()+"]"); System.out.println("GSTDataSubmitWizEJB.handleRequest()["+e.getMessage()+"]");
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); retResponseXML = "<root><message><![CDATA[Message : Error occured!]]></message></root>";
} }
finally finally
{ {
...@@ -916,7 +898,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi ...@@ -916,7 +898,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
gspAuthString = clientId + ":" + transactionId + ":" + timeStamp + ":" + gstinNo; gspAuthString = clientId + ":" + transactionId + ":" + timeStamp + ":" + gstinNo;
gspAuthSignature = gspSignature.sign(gspAuthString, aspPrivateKey); 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("action", action)
.queryString("gstin", gstinNo) .queryString("gstin", gstinNo)
.queryString("ret_period", periodCode) .queryString("ret_period", periodCode)
...@@ -1049,7 +1031,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi ...@@ -1049,7 +1031,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
gspAuthString = clientId + ":" + transactionId + ":" + timeStamp + ":" + gstin; gspAuthString = clientId + ":" + transactionId + ":" + timeStamp + ":" + gstin;
gspAuthSignature = gspSignature.sign(gspAuthString, aspPrivateKey); 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("action","RETSUM")
.queryString("gstin", gstin) .queryString("gstin", gstin)
.queryString("ret_period", periodCode) .queryString("ret_period", periodCode)
......
...@@ -273,110 +273,129 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -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); detail2NList = allXMLDom.getElementsByTagName("Detail2");
detail2ChildNList = detail2NList.item(0).getChildNodes();
System.out.println("560101.domId["+eachDetail2Node.getAttributes().getNamedItem("domID")+"]");
detail2ChildNList = eachDetail2Node.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(); 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); appKeyInBytes = aesEncryption.decodeBase64StringTOByte(appKey);
appKeyEncryptedAndCoded = pubKeyEncryption.encrypt(appKeyInBytes); appKeyEncryptedAndCoded = pubKeyEncryption.encrypt(appKeyInBytes);
String encryptedOTP = aesEncryption.encryptEK(otp.getBytes(), appKeyInBytes); if(authToken.trim().length() > 0 && sek.trim().length() > 0)
{
JSONObject authTokenReq = new JSONObject(); System.out.println("authToken and authSEK from detail2");
authTokenReq.put("action", "AUTHTOKEN");
authTokenReq.put("username", userName); authSEK = aesEncryption.decrypt(sek, appKeyInBytes);
authTokenReq.put("app_key", appKeyEncryptedAndCoded); System.out.println("AuthSEK = "+ aesEncryption.encodeBase64String(authSEK));
authTokenReq.put("otp", encryptedOTP); }
else
long timeStamp = new Timestamp().getDateTime(); {
gspAuthString = clientId + ":" + transactionId + ":" + timeStamp + ":" + gstin; String encryptedOTP = aesEncryption.encryptEK(otp.getBytes(), appKeyInBytes);
gspAuthSignature = gspSignature.sign(gspAuthString, aspPrivateKey);
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)) HttpResponse<JsonNode> authTokenResp = Unirest.post(String.format("%s%s", GSP_API_URL, AUTH_TOKEN_URL_V2))
.header("Content-Type",APPLICATION_JSON) .header("Content-Type",APPLICATION_JSON)
.header("clientid", clientId) .header("clientid", clientId)
.header("client-secret", clientSecret) .header("client-secret", clientSecret)
.header("state-cd", stateCode) .header("state-cd", stateCode)
.header("ip-usr", ipAddress.getHostAddress()) .header("ip-usr", ipAddress.getHostAddress())
.header("txn", transactionId) .header("txn", transactionId)
.header("app_key", appKeyEncryptedAndCoded) .header("app_key", appKeyEncryptedAndCoded)
.header("X-Asp-Auth-Token", gspAuthString) .header("X-Asp-Auth-Token", gspAuthString)
.header("X-Asp-Auth-Signature", gspAuthSignature) .header("X-Asp-Auth-Signature", gspAuthSignature)
.body(new JsonNode(authTokenReq.toString())) .body(new JsonNode(authTokenReq.toString()))
.asJson(); .asJson();
System.out.println(String.format("authTokenResp Request : Status[%s] Response[%s]", authTokenResp.getStatus(), authTokenResp.getBody())); System.out.println(String.format("authTokenResp Request : Status[%s] Response[%s]", authTokenResp.getStatus(), authTokenResp.getBody()));
if (authTokenResp.getStatus() == 200) if (authTokenResp.getStatus() == 200)
{ {
JSONObject object = authTokenResp.getBody().getObject(); JSONObject object = authTokenResp.getBody().getObject();
if (object.has("auth_token") && object.has("sek") && object.has("status_cd") && Objects.equals(object.getString("status_cd"), "1")) if (object.has("auth_token") && object.has("sek") && object.has("status_cd") && Objects.equals(object.getString("status_cd"), "1"))
{ {
authToken = object.getString("auth_token"); authToken = object.getString("auth_token");
sek = object.getString("sek"); sek = object.getString("sek");
authSEK = aesEncryption.decrypt(sek, appKeyInBytes); authSEK = aesEncryption.decrypt(sek, appKeyInBytes);
System.out.println("AuthSEK = "+ aesEncryption.encodeBase64String(authSEK)); System.out.println("AuthSEK = "+ aesEncryption.encodeBase64String(authSEK));
if("GSTR1".equalsIgnoreCase(returnsType)) }
{ else
if("SAVE".equalsIgnoreCase(action)) {
{ JSONObject errorJSON = authTokenResp.getBody().getObject().getJSONObject("error");
retString = saveGstr1(authToken, siteCode, stateCode, userName, gstin, periodCode, grossTurnover, authSEK, conn);
} if("AUTH4033".equalsIgnoreCase(errorJSON.getString("error_cd")))
else if ("RETSUM".equalsIgnoreCase(action) || "FILE".equalsIgnoreCase(action)) {
{ retString = new ITMDBAccessEJB().getErrorString("","VTINVOTP","","",conn);
retString = getGstr1Summary(authToken, stateCode, userName, gstin, periodCode, authSEK, action, conn); }
} else
else if ("SUBMIT".equalsIgnoreCase(action)) {
{ String errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = submitGstr1(authToken, stateCode, userName, gstin, periodCode, authSEK, conn); retString = getError(errMsg, "GSTAPIERR", conn);
} }
} }
else if("GSTR2".equalsIgnoreCase(returnsType)) }
{ else
if("GETINV".equalsIgnoreCase(action)) {
{ JSONObject errorJSON = authTokenResp.getBody().getObject().getJSONObject("error");
retString = getGstr2Invoices(authToken, stateCode, userName, gstin, periodCode, siteCode, authSEK, conn); String errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
} retString = getError(errMsg, "GSTAPIERR", conn);
} }
} }
else
{ if("GSTR1".equalsIgnoreCase(returnsType))
JSONObject errorJSON = authTokenResp.getBody().getObject().getJSONObject("error"); {
if("SAVE".equalsIgnoreCase(action))
if("AUTH4033".equalsIgnoreCase(errorJSON.getString("error_cd"))) {
{ retString = saveGstr1(authToken, siteCode, stateCode, userName, gstin, periodCode, grossTurnover, authSEK, conn);
retString = new ITMDBAccessEJB().getErrorString("","VTINVOTP","","",conn); }
} else if ("RETSUM".equalsIgnoreCase(action) || "FILE".equalsIgnoreCase(action))
else {
{ retString = getGstr1Summary(authToken, stateCode, userName, gstin, periodCode, authSEK, action, conn);
String errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd"); }
retString = getError(errMsg, "GSTAPIERR", conn); else if ("SUBMIT".equalsIgnoreCase(action))
} {
} retString = submitGstr1(authToken, stateCode, userName, gstin, periodCode, authSEK, conn);
} }
else }
{ else if("GSTR2".equalsIgnoreCase(returnsType))
JSONObject errorJSON = authTokenResp.getBody().getObject().getJSONObject("error"); {
String errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd"); if("GETINV".equalsIgnoreCase(action))
retString = getError(errMsg, "GSTAPIERR", conn); {
} retString = getGstr2Invoices(authToken, stateCode, userName, gstin, periodCode, siteCode, authSEK, conn);
}
}
} }
catch(Exception e) catch(Exception e)
{ {
...@@ -1514,7 +1533,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -1514,7 +1533,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
.header("ret_period", periodCode) .header("ret_period", periodCode)
.header("gstin", gstin) .header("gstin", gstin)
.header("X-Asp-Auth-Token", gspAuthString) .header("X-Asp-Auth-Token", gspAuthString)
.header("X-Asp-Auth-Signature", gspAuthSignature) .header("X-Asp-Auth-Signature", gspAuthSignature)
.body(new JsonNode(reqBody.toString())) .body(new JsonNode(reqBody.toString()))
.asJson(); .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