Craftercms: Setting custom headers in email when using EmailFactoryImpl - crafter-cms

I am using the Crafter class EmailFactoryImpl to send emails.
I need to be able to send a custom header to the email server. This header (X-SES-CONFIGURATION-SET) is needed in the email server we use: AWS.
Taking a look at EmailFactoryImpl API, the MimeMessage is being created inside the class and there is no way to specify custom headers via parameters.
Is there any work around for this?

Right now at this time you can't. EmailFactory is more of an utility class to easily and quickly create and send emails, but it doesn't allow for heavy customization like adding a header. In this case you're better just using the MimeMessage class directly or Spring's MimeMessageHelper.

Related

Using ServiceStack REST to receive data without a POCO on the server

We're trying to write a ServiceStack Rest method to received data from the NLOG WebService Target.
https://github.com/NLog/NLog/wiki/WebService-target
It appears that Nlog will send a WCF formatted Json POST based on the class NlogEvents
http://sourcebrowser.io/Browse/nlog/nlog/src/NLog/LogReceiverService/NLogEvents.cs
We can resolve this object as an argument to a post method. But how do we specify the ROUTE as we cant decorate it with an ROUTE attribute?
Also, it appears that this object already has a several attributes that were added from the WCF support. Is there another way to specify the Poco recieve object?
Also, The Nlog webservice has flags to format the data as Rfc3986 or Rfc2396 but im nor sure if that does anything for us.
Any suggestions would be appreciated.
Have a look at ServiceStack's routing docs, you can register routes on DTOs you don't own using the Fluent API, or dynamically attach attributes to Types.
You don't need to use NLog's exact Types in Services, i.e. you can just use a copy of the DTOs for your Service contract and annotate them freely. If needed you can use Auto Mapping to easily copy data from DTOs to NLog Types.

How to insert a DEFAULT custom header value to all SoapUI projects?

We have SoapUI (Open Source Edition) installed on a windows jumpbox. Many users can login with their accounts, open soapui, import a wadl/wsdl from a dozen of projects and perform testing.
Since the IP is always same, we are unable to find who has sent a request and that is a problem when some destructive requests are made that causes lots of recovery issues (Only authorized users have the access).
Now we want to add http header like user : ${=System.getenv("USERNAME")} to the request. It can be a new header property or even a part of user agent.
We tried to put the property inside HTTP Preferences as a part of user agent string, but it passes the parameter as a string
We also set a global property but couldn't find a way to insert it as one of HTTP calls by default.
The only ways we found so far was:
going to soapui setting of each user and add headers to all requests one by one. (problem: what if user imports more wsdl/wadl later)
adding a startup script to created projects, so it adds the header by default to everything (problem: users can create new projects any time - please note that each soapui instance is individual)
This requirement can easily be fulfilled by the SoapUI's pro software using the feature called Events.
For example, add the header for each request before submitting the web service / rest service call.
However, you mentioned that free version is being used. Wrote an extension some time ago, which allows us to do the same in the free edition of SoapUI. There is a readme available explaining how to use this. Basically this extension implemented the some of the listeners of SaopUI's API while providing the flexibility to the end users what code should they run(in the form of external file) when the respective event occurs.
Complete the instructions mentioned in the readme.
Then you need to do is write a groovy script(already given below) to implement your requirement i.e., add the header to the request. That needs to be done in a file with specific file name located in specific directory(details available there).
In your case, the required code(mostly working sample below) should go into file called RequestStepBeforeSubmit.groovy, in order add the user name into each request's header automatically.
Below code snippet should work even if you use the pro software for the same requirement when SubmitListener.beforeSubmit event happens.
//change the condition if required, should be working for soap/rest types
if (context.getProperty("wsdlRequest")){
def request = context.getProperty("wsdlRequest").testStep.httpRequest
def existingHeaders = request.requestHeaders
def username = System.getProperty('user.name')
existingHeaders['user'] = [(username)]
request.requestHeaders = existingHeaders
}

Method not allowed when trying to access API methods via SOAP integration

Good day,
I'm having trouble calling DSAPI methods via SOAP ( C# Integration ). I keep getting 405 Method not allowed errors. So far I've tried calling the RequestTemplate and CreateEnvelopeFromTemplates methods, both of which fail. I was able to successfully retrieve the DSAPIServiceSoapClient object and also successfully login via the login method of the credential API. If you need more information, i'm ready to provide them. Thank you.
You're succeeding with the login, which is good.
My guess is that the other calls are not well formed. Perhaps they're missing the right base url (which you receive from the login call).
Are you switching to the different base url for your subsequent calls? (Different server name?)
I suggest that you try the API logging feature and see what it reports. It enables you to see a log of your API requests. See the Request Logging article for the classic DocuSign experience, or the new DocuSign UI.
i just needed to add the in the X-DocuSign-Authentication http header whenever i try to get a DSAPIClient object.

How to Secure an SOA style Symfony2 Application

So we're developing a web application in Symfony2 (brief editorial: Symfony2 is freaking awesome) along the lines of an SOA. All data is farted back and forth between our jQuery powered frontend and the Symfony2 backend formatted a la JSON, and therein lies the rub.
Symfony2 provides for a robust security system, but it seems to hinge on the "Security Layer" intercepting form submissions and using the form-encoded POST data to process an authentication attempt. This is problematic for our application because we use JSON exclusively. From where I'm standing, using JSON for every single request and response except authentication is... the sheet of the bool, frankly. Bad smell, bad juju, whatever you call it.
Now, Symfony2 allows for the creation of event listeners that hook into a series of events related to the lifecycle of a request and the consumate response. We use one of these hooks to decode the JSON that comes in with every POST request so that the relevant controller only ever has to worry about working directly with a php array and not do any decoding or de-serializing or whatever.
So the crux of our issue is that the "Security Layer" expects that form-encoded POST data that it gets from a form submission (generally on a page that the backend served in the first place). We're set up to feed it a PHP array created from JSONified data. So what do? Should we:
Create a custom authentication service that is built to deal with an array made from le JSON?
Tweak our request hook to check the target uri of each request and subsequently massage the request's JSON into the form-encoded string the "Security Layer" expects?
Tweak the "Security Layer" so that it can work the the JSON turned php array?
It's fairly simple to create your own authentication provider. You can follow this cookbook article and modify it slightly to handle your JSON request instead of the WSSE used in that example.

Can I capture JSON data already being sent with a userscript/Chrome extension?

I'm trying to write a userscript/Chrome extension to capture JSON data being sent while using a web service so that I can reformat it and display selected portion on page. Currently the JSON is sent as the application loads (as I've observed from watching traffic with Fiddler 2). Is my only option to request the JSON again or is capture possible? As I'm not providing a code example, a requested answer is even some guidance on what method / topic to research or if I'm barking up the wrong tree.
No easy way.
If it is for a specific site you might look into intercepting and overwriting part of a code which sends a request. For example if it is sent on a button click you can replace existing click handler with your own implementation.
You can also try to make a proxy for XMLHttpRequest. Not sure if this even possible, never seen a working example. You can look at some attempts here.
For all these tasks you probably would need to run your javascript code out of sandboxed content script to be able to access parent page variables, so you would need to inject <script> tag with your code right into the page from a content script:

Resources