class SshUtil {

    public static Session getSessionObject( String userName, String password, String hostName, int port,
                                            Properties sessionConfig )
    {

        Session session = null;

        // logger.debug("In getSessionObject");
        if ( userName != null && !"".equals( userName ) && password != null && hostName != null
            && !"".equals( hostName ) )
        {
            JSch jsch = new JSch();
            try
            {
                session = jsch.getSession( userName, hostName, port );
                session.setPassword( password );

                if ( sessionConfig != null )
                {
                    session.setConfig( sessionConfig );
                }

                // logger.debug("COnfig set");
            }
            catch ( Exception e )
            {
                logger.error( "Creating SSH session failed", e );
            }
            return session;
        }
        // logger.debug("Before returning Session object");
        return null;
    }

}