use of com.marketo.mktows.AuthenticationHeader in project components by Talend.
the class MarketoSOAPClient method getAuthentificationHeader.
public AuthenticationHeader getAuthentificationHeader() throws NoSuchAlgorithmException, InvalidKeyException {
// Create Signature
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
String text = df.format(new Date());
String requestTimestamp = text.substring(0, 22) + ":" + text.substring(22);
String encryptString = requestTimestamp + userId;
SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey.getBytes(), "HmacSHA1");
Mac mac = getInstance("HmacSHA1");
mac.init(secretKeySpec);
byte[] rawHmac = mac.doFinal(encryptString.getBytes());
char[] hexChars = encodeHex(rawHmac);
String signature = new String(hexChars);
// Set Authentication Header
AuthenticationHeader hdr = new AuthenticationHeader();
hdr.setMktowsUserId(userId);
hdr.setRequestTimestamp(requestTimestamp);
hdr.setRequestSignature(signature);
return hdr;
}
use of com.marketo.mktows.AuthenticationHeader in project components by Talend.
the class MarketoSOAPClientTest method setUp.
@Before
public void setUp() throws Exception {
iprops = new TMarketoInputProperties("test");
iprops.schemaInput.setupProperties();
iprops.schemaInput.setupLayout();
iprops.connection.setupProperties();
iprops.connection.setupLayout();
iprops.connection.setupProperties();
iprops.connection.apiMode.setValue(APIMode.SOAP);
iprops.connection.endpoint.setValue("https://fake.io");
iprops.connection.clientAccessId.setValue("clientaccess");
iprops.connection.secretKey.setValue("sekret");
iprops.setupProperties();
iprops.setupLayout();
oprops = new TMarketoOutputProperties("test");
oprops.schemaInput.setupProperties();
oprops.schemaInput.setupLayout();
oprops.connection.setupProperties();
oprops.connection.setupLayout();
oprops.connection.setupProperties();
oprops.connection.apiMode.setValue(APIMode.SOAP);
oprops.connection.endpoint.setValue("https://fake.io");
oprops.connection.clientAccessId.setValue("clientaccess");
oprops.connection.secretKey.setValue("sekret");
oprops.setupProperties();
oprops.setupLayout();
lprops = new TMarketoListOperationProperties("test");
lprops.schemaInput.setupProperties();
lprops.schemaInput.setupLayout();
lprops.connection.setupProperties();
lprops.connection.setupLayout();
lprops.connection.setupProperties();
lprops.connection.apiMode.setValue(APIMode.SOAP);
lprops.connection.endpoint.setValue("https://fake.io");
lprops.connection.clientAccessId.setValue("clientaccess");
lprops.connection.secretKey.setValue("sekret");
lprops.setupProperties();
lprops.setupLayout();
client = spy(new MarketoSOAPClient(iprops.connection));
port = mock(MktowsPort.class);
AuthenticationHeader header = mock(AuthenticationHeader.class);
doReturn(port).when(client).getMktowsApiSoapPort();
doReturn(header).when(client).getAuthentificationHeader();
doReturn(null).when(port).listMObjects(any(ParamsListMObjects.class), any(AuthenticationHeader.class));
client.connect();
objectFactory = new ObjectFactory();
factory = DatatypeFactory.newInstance();
Date dateTest = MarketoUtils.parseDateString(DATE_EXPECTED);
gcDateTest = new GregorianCalendar();
gcDateTest.setTime(dateTest);
}
Aggregations