Hidden Design in XPages App

I’ve never been a fan of hidden design in Domino databases. If someone can read my Lotusscript code and understand what it does…. he has earned it… ­čÖé

Recently I got this XPage / Servlet app as an ntf with hidden design. I found this article.. Of course it does not work for properly removed Lotusscript code but it works for the Java code.
I created a nsf, archived it with some fake settings to my local workstation and I got the whole java code….. nice …

If you really want to protect your java code, put in a separate plugin and remove the source from it and use some obfuscators on it. But remember, everytime you hide your code, somewhere dies a young oak……

Nginx Proxy for Domino – err_connection_refused

I like the nginx server.
Easy to install, simple configuration file.

I built a new Development VM with Domino 9 and installed nginx on it.
Changed the Domino’s http port to 8088. restarted it, tested it. worked.
Removed the nginx default config. Created new config files.
I ran nginx -t, to check the config and service nginx start to startup the server. It started.

When I tried to connect to it, I got an err_connection_refused.
Checking with netstat I could not find anything listening on port 80.
Checking the nginx error log. empty.
Checked that the config file was under /etc/nginx/conf.d present.
Googled to see wether someone else had this issue before, found some hints but nothing worked.

After another cup of coffe I got back to my config file.
Sometimes the error sits in front of the screen.
I screwed the config file on purpose and restarted the nginx without getting an error.
Checking back at my config file I recognized my failure. The file extension was wrong.
Remember the extension has to be .conf ….

Session As Signer – Note to myself

If this code returns Null

public static Session getSessionAsSigner() {
 Session sessionAsSigner = null;
 try {
  FacesContext context = JSFUtil.getFacesContext();
  sessionAsSigner = (Session) context.getApplication().getVariableResolver().resolveVariable(context,"sessionAsSigner");
 } catch (Exception e) {
 Util.logError(e);
 }
 return sessionAsSigner;
 } 

Then your code might have been signed by different user / servers.. Just sign it with your user ID and try again.

Keep an X-Page in Memory

Evreybody knows that starting an XPage for the first time takes some time. Using the Notes.ini parameter for preloading the xpages can become slightly difficult if you have a lot of apps.

My solution is quite simple

 
#!/bin/bash 
USERNAME="UserName" 
PASSWORD="Password" 
BASEPATH=/opt/ibm/apps 
LOGIN_URL="https://[SERVER_NAME]/names.nsf?login" 
XPAGES_URL="https://[SERVER_NAME]/[PATH_TO_NSF]/myXpages.xsp"
if [ -f $BASEPATH/last.run ]; then
rm $BASEPATH/last.run
fi
wget --save-cookies cookies.txt --keep-session-cookies --post-data "Username=$USERNAME&Password=$PASSWORD" --delete-after $LOGIN_URL 
wget --load-cookies cookies.txt --delete-after $XPAGES_URL
if [ -f $BASEPATH/cookies.txt ] ; then 
 rm $BASEPATH/cookies.txt 
fi 
touch $BASEPATH/last.run 

Place this file on the server and call it through cron on a regular schedule and your xpages should be always loaded.

As always, use on your own risk.

Nice HTML Newsletter from a Domino Server

Requirement 1: Marketing wants to send a newsletter.

Solution: Create a new ID and a new Mailbox for marketing, teach them how they can use the mailbox. Solved.

Requirement 2: Marketing wants to send newsletters to a huge list of customers.

Solution: Improve the mailbox, so stationaries can be sent to a list of email addresses, in blocks of 100 each, so the provider does not mark us as spammers. Solved.

Requirement 3: Marketing wants to send nice looking newsletters to a huge list of customers.

Solution: Improve the agent, so it can send HTML files as MIME Mails using the NotesMime* classes. Solved.

Requirement 4: Marketing wants to send nice looking newsletters with pictures to a huge list of customers.

Analyisis: HTML from Marketing contains links to pictures on the internet/intranet. The script from requirement 3 would have to parse the html file, download all the images and replace the img src’s with the right cid’s and embedded these images in the mail.

Solution: Implementing Apache Commons Email Client the ImageHtmlEmail class does all the parsing, downloading and img tag updateing.
To run the agent on the server 2 jar files (javax.mail.jar, commons-email-1.4.jar) needs to be placed in the /jvm/lib/ext/ folder (otherwise you might have to fiddle around with the java.pol file) because the email client stores the images in the local temp directory. Restart the server/client so the jar’s get loaded.

The SMTP task needs to running and properly configured to allow connections.