Using jtweet portlet behind a proxy for twittering #liferay contents

Recently Sandeep Nair developed a portlet that commits the blog entries and other contents in a Twitter account. This portlet is configurable by groupId and it can manage several Twitter accounts by Group (Organization,Community etc..). The portlet use the jtweet library to interact with

We are testing this portlet and we find a problem if Liferay is behind a proxy. The reason is that jtweet uses the instead of the HttpImpl provided by Liferay, which is clear because jtweet is a general purpose library. So, if you want to use this cool portlet you have to configure the JVM for the proxy and set the user credentials.

To set the user and password, you have to register an Authenticator, and set it as default.

package net.zylk.proxy.auth;

public class StartupAction extends SimpleAction{

    public void run(String[] arg0) throws ActionException {
        // TODO Auto-generated method stub
        Authenticator.setDefault(new SimpleAuthenticator("PROXY_USER","PROXY_PASSWORD"));

    public class SimpleAuthenticator extends Authenticator {
        private String username, password;

        public SimpleAuthenticator(String username, String password) {
            this.username = username;
            this.password = password;

        protected PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication(username, password.toCharArray());

On liferay startup:, net.zylk.proxy.auth.StartupAction

It is also useful for the RSS portlet behind proxy with authentication. I don't know if this is the best way to do this but is one way.


More Blog Entries