This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal


Sep 23, 2015, 2:56 PM
4 Posts

JCIFS for Accessing Files on File Server

  • Category: Application Development
  • Platform: Windows
  • Release: 9.0.1
  • Role: Developer
  • Tags: jcifs,java,samba,smb,agent,ubuntu
  • Replies: 0

Has anyone successfully used JCIFS library in a Java agent to access files in a shared folder on a Windows file server? The file server is actually a Linux server, but it is running Samba to create a Windows file share and a scheduled agent will put files up on it.

Here is the code I'm using as a proof of concept:

import lotus.domino.*;
import jcifs.smb.NtlmPasswordAuthentication;
import jcifs.smb.SmbFile;
import jcifs.smb.SmbFileInputStream;
import jcifs.smb.SmbFileOutputStream;

public class JavaAgent extends AgentBase
{
    private static final String USERNAME = "username";  //obviously changed
    private static final String PASSWORD = "password";
    private static final String SERVER = "fileservername";


    public void NotesMain()
    {

        try
        {
            Session session = getSession();
            AgentContext agentContext = session.getAgentContext();

            // (Your code goes here)
            SmbFile smbDir = connect("smb://" + SERVER + "/secured", USERNAME, PASSWORD);
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
    public static SmbFile connect(String smbServer, String userName, String pwd) throws Exception
    {  
        NtlmPasswordAuthentication ntml = new NtlmPasswordAuthentication("", userName, pwd);  
        SmbFile client = new SmbFile(smbServer, ntml);  

        return client;  
    }  
}

 

It seems to be a permission problem on the Domino side. I have the agent running level "3. Allow restricted operations with full administration rights".

Here is the error I'm getting:

java.security.AccessControlException: Access denied (java.net.NetPermission specifyStreamHandler)
    at java.security.AccessController.throwACE(AccessController.java:100)
    at java.security.AccessController.checkPermission(AccessController.java:174)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:544)
    at COM.ibm.JEmpower.applet.AppletSecurity.superDotCheckPermission(AppletSecurity.java:1449)
    at COM.ibm.JEmpower.applet.AppletSecurity.checkPermission(AppletSecurity.java:1617)
    at COM.ibm.JEmpower.applet.AppletSecurity.checkPermission(AppletSecurity.java:1464)
    at java.net.URL.checkSpecifyHandler(URL.java:641)
    at java.net.URL.<init>(URL.java:513)
    at jcifs.smb.SmbFile.<init>(SmbFile.java:500)
    at JavaAgent.connect(JavaAgent.java:33)
    at JavaAgent.NotesMain(JavaAgent.java:23)
    at lotus.domino.AgentBase.runNotes(Unknown Source)
    at lotus.domino.NotesThread.run(Unknown Source)

From some of my searching about security errors when using Java agents, I saw some notes talking about modifying a "java.policy" file. Is this what needs to be done to get this to work?

 


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal