-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
88c8cff
commit 21ddc9a
Showing
4 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
95 changes: 95 additions & 0 deletions
95
...src/main/java/br/com/kibutx/minhabufunfa/services/bank/santander/SantanderImportador.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package br.com.kibutx.minhabufunfa.services.bank.santander; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.FileOutputStream; | ||
import java.io.InputStream; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.apache.http.HttpResponse; | ||
import org.apache.http.client.methods.HttpGet; | ||
import org.apache.http.impl.cookie.BasicClientCookie; | ||
import org.mozilla.javascript.Context; | ||
import org.mozilla.javascript.Script; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import br.com.kibutx.minhabufunfa.services.bank.BancoImportador; | ||
import br.com.kibutx.minhabufunfa.services.bank.BancoRegistro; | ||
import br.com.quintoandar.consultasbr.core.SimpleHttpQuerier; | ||
|
||
public class SantanderImportador extends SimpleHttpQuerier implements BancoImportador { | ||
protected static final Logger log = LoggerFactory.getLogger(SantanderImportador.class); | ||
|
||
protected static final String ENCODING = "UTF-8"; | ||
|
||
String begining = "http://m.santander.com.br/santandermovel/"; | ||
|
||
@Override | ||
protected boolean shouldPersistCookie(BasicClientCookie ck) { | ||
return true; | ||
} | ||
|
||
public void login(String agencia, String cc, String dv, String password) { | ||
HttpGet httpGet = new HttpGet(begining); | ||
try { | ||
HttpResponse resp = client.execute(httpGet); | ||
// if (codes.contains(resp.getStatusLine().getStatusCode())) { | ||
ByteArrayOutputStream baos = new ByteArrayOutputStream(); | ||
FileOutputStream faos = new FileOutputStream("C:/Users/Moacyr/Desktop/bla.html"); | ||
resp.getEntity().writeTo(baos); | ||
String html = new String(baos.toByteArray(), ENCODING); | ||
baos.close(); | ||
baos = null; | ||
faos.write(html.getBytes(ENCODING)); | ||
faos.close(); | ||
|
||
// if(html.contains(URL_MENU)){ | ||
// menuUrl = extrairUrl(html, URL_MENU, ""); | ||
// } | ||
// this.extratoUrl = | ||
// html.replaceAll("(\n|\r)","").replaceAll("^.*\"(http([^\"]+?)M/SaldoExtratoLancamentos([^\"]+?)\").*$", | ||
// "$1"); | ||
|
||
// return URL_DOIS+param; | ||
// return html; | ||
// } | ||
} catch (Throwable e) { | ||
log.error("Erro", e); | ||
// throw new | ||
// ServicoExternoException("Error chamarUrlESeguirParaLocationSeHouver", | ||
// e); | ||
} finally { | ||
httpGet.abort(); | ||
connMan.closeIdleConnections(1, TimeUnit.MILLISECONDS); | ||
} | ||
// return null; | ||
} | ||
|
||
public List<BancoRegistro> carregarLancamentosExtrato() { | ||
return new ArrayList<BancoRegistro>(); | ||
} | ||
|
||
public static void main(String[] args) throws Throwable { | ||
SantanderImportador si = new SantanderImportador(); | ||
si.login("ag", "cc", "dv", "password"); | ||
|
||
Context ctx = Context.enter(); | ||
ByteArrayOutputStream baos = new ByteArrayOutputStream(); | ||
InputStream is = SantanderImportador.class.getResourceAsStream("/jcrypto.js"); | ||
copy(is, baos, 1); | ||
String source = new String(baos.toByteArray(),"utf-8"); | ||
Script script = ctx.compileString(source, "sharedScript", 1, null); | ||
// String javaScriptExpression = "sayHello(name);"; | ||
// Reader javaScriptFile = new StringReader("function sayHello(name) {\n" + " println('Hello, '+name+'!');\n" + "}"); | ||
|
||
// ScriptEngineManager factory = new ScriptEngineManager(); | ||
// ScriptEngine engine = factory.getEngineByName("JavaScript"); | ||
// ScriptContext context = engine.getContext(); | ||
// context.setAttribute("name", "JavaScript", ScriptContext.ENGINE_SCOPE); | ||
|
||
// engine.eval(javaScriptFile); | ||
// engine.eval(javaScriptExpression); | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...importer/src/main/resources/br/com/kibutx/minhabufunfa/services/bank/santander/jcrypto.js
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.