diff --git a/pom.xml b/pom.xml index 45f368be0..86425e496 100644 --- a/pom.xml +++ b/pom.xml @@ -2005,7 +2005,8 @@ org.irods.jargon jargon-core - 4.3.2.5-RELEASE + + 4.3.4.0-RELEASE com.fasterxml.jackson.core @@ -3004,7 +3005,7 @@ 1.1.2 5.5.5 4.1.63.Final - 2.4.1 + 2.7.1 3.1.0 2.4.2 4.0.3 diff --git a/src/main/java/com/researchspace/netfiles/NfsFactory.java b/src/main/java/com/researchspace/netfiles/NfsFactory.java index 239684429..a14602807 100644 --- a/src/main/java/com/researchspace/netfiles/NfsFactory.java +++ b/src/main/java/com/researchspace/netfiles/NfsFactory.java @@ -12,7 +12,13 @@ import com.researchspace.netfiles.samba.SmbjClient; import com.researchspace.netfiles.sftp.SftpClient; import org.apache.commons.lang.StringUtils; +import org.irods.jargon.core.connection.AuthScheme; +import org.irods.jargon.core.connection.ClientServerNegotiationPolicy; +import org.irods.jargon.core.connection.ClientServerNegotiationPolicy.SslNegotiationPolicy; import org.irods.jargon.core.connection.IRODSAccount; +import org.irods.jargon.core.connection.IRODSSession; +import org.irods.jargon.core.connection.SettableJargonProperties; +import org.irods.jargon.core.pub.IRODSFileSystem; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -23,6 +29,12 @@ @Component public class NfsFactory { + private static final int IRODS_DEFAULT_PORT = 1247; + + private static final String IRODS_DEFAULT_CSNEG = "CS_NEG_REFUSE"; + + private static final String IRODS_DEFAULT_AUTH = "NATIVE"; + private static final Logger log = LoggerFactory.getLogger(NfsFactory.class); @Autowired private NfsUserPasswordAuthentication userPasswordAuthentication; @@ -89,16 +101,53 @@ public NfsClient getNfsClient(String nfsusername, String nfspassword, NfsFileSys fileSystem.getClientOption(NfsFileSystemOption.SFTP_SERVER_PUBLIC_KEY)); } if (NfsClientType.IRODS.equals(clientType)) { - return new IRODSClient( + + int irodsPort; + String irodsCSNeg; + String irodsAuth; + + irodsPort = + (StringUtils.isBlank(fileSystem.getClientOption(NfsFileSystemOption.IRODS_PORT))) + ? IRODS_DEFAULT_PORT + : Integer.parseInt(fileSystem.getClientOption(NfsFileSystemOption.IRODS_PORT)); + irodsCSNeg = + (StringUtils.isBlank(fileSystem.getClientOption(NfsFileSystemOption.IRODS_CSNEG))) + ? IRODS_DEFAULT_CSNEG + : fileSystem.getClientOption(NfsFileSystemOption.IRODS_CSNEG); + + IRODSAccount ia = new IRODSAccount( fileSystem.getUrl(), - Integer.parseInt(fileSystem.getClientOption(NfsFileSystemOption.IRODS_PORT)), + irodsPort, nfsusername, nfspassword, fileSystem.getClientOption(NfsFileSystemOption.IRODS_HOME_DIR), fileSystem.getClientOption(NfsFileSystemOption.IRODS_ZONE), - ""), - new JargonFacade()); + ""); + JargonFacade jf = new JargonFacade(); + + // set up iRODS CS NEG + // here you could set all jargon/irods props + // see + // jargon-core/src/main/java/org/irods/jargon/core/connection/SettableJargonProperties.java + IRODSFileSystem iRODSFs = jf.iRODSFs; + IRODSSession session = iRODSFs.getIrodsSession(); + SettableJargonProperties props = new SettableJargonProperties(session.getJargonProperties()); + SslNegotiationPolicy sslNegPolicy = + ClientServerNegotiationPolicy.findSslNegotiationPolicyFromString(irodsCSNeg); + props.setNegotiationPolicy(sslNegPolicy); + session.setJargonProperties(props); + + // set iRODS auth scheme + irodsAuth = + (StringUtils.isBlank(fileSystem.getClientOption(NfsFileSystemOption.IRODS_AUTH))) + ? IRODS_DEFAULT_AUTH + : fileSystem.getClientOption(NfsFileSystemOption.IRODS_AUTH); + + AuthScheme ias = (irodsAuth.equals("NATIVE")) ? AuthScheme.STANDARD : AuthScheme.PAM; + ia.setAuthenticationScheme(ias); + + return new IRODSClient(ia, jf); } return null; diff --git a/src/main/java/com/researchspace/netfiles/irods/JargonFacade.java b/src/main/java/com/researchspace/netfiles/irods/JargonFacade.java index 66141c7b6..93050bed2 100644 --- a/src/main/java/com/researchspace/netfiles/irods/JargonFacade.java +++ b/src/main/java/com/researchspace/netfiles/irods/JargonFacade.java @@ -26,6 +26,7 @@ public class JargonFacade { private IRODSAccessObjectFactory accessObjectFactory; + public IRODSFileSystem iRODSFs; private enum IRODSFileSystemSingletonHolder { INSTANCE(); @@ -46,8 +47,8 @@ public IRODSFileSystem getIRodFileSystem() { public JargonFacade() { try { - this.accessObjectFactory = - IRODSFileSystemSingletonHolder.INSTANCE.getIRodFileSystem().getIRODSAccessObjectFactory(); + this.iRODSFs = IRODSFileSystemSingletonHolder.INSTANCE.getIRodFileSystem(); + this.accessObjectFactory = iRODSFs.getIRODSAccessObjectFactory(); } catch (JargonException e) { log.error("Error Constructing JargonFacade: ", e); } diff --git a/src/main/resources/bundles/system/system.properties b/src/main/resources/bundles/system/system.properties index 5abb56c0f..ea7b464b9 100644 --- a/src/main/resources/bundles/system/system.properties +++ b/src/main/resources/bundles/system/system.properties @@ -277,8 +277,12 @@ system.netfilesystem.details.client.sftp.server.public.key=SFTP server public ke system.netfilesystem.details.client.sftp.server.dir.choice=User subdirectory required system.netfilesystem.details.client.irods=iRODS system.netfilesystem.details.client.irods.zone=iRODS Zone -system.netfilesystem.details.client.irods.homedir=Home Directory +system.netfilesystem.details.client.irods.homedir=iRODS Search Path system.netfilesystem.details.client.irods.port= iRODS Port +system.netfilesystem.details.client.irods.csneg=iRODS CS_NEG +system.netfilesystem.details.client.irods.auth=Password Type +system.netfilesystem.details.client.irods.auth.native=Native +system.netfilesystem.details.client.irods.auth.pam=PAM system.netfilesystem.details.auth=Authentication Type system.netfilesystem.details.auth.password=Username/Password system.netfilesystem.details.auth.pubkey=Public Key Authentication diff --git a/src/main/webapp/WEB-INF/pages/system/netfilesystem_ajax.jsp b/src/main/webapp/WEB-INF/pages/system/netfilesystem_ajax.jsp index a6720bf80..1842083fb 100644 --- a/src/main/webapp/WEB-INF/pages/system/netfilesystem_ajax.jsp +++ b/src/main/webapp/WEB-INF/pages/system/netfilesystem_ajax.jsp @@ -123,18 +123,30 @@ - + - + + + + + + + + + + + + @@ -152,8 +164,8 @@ - + @@ -162,6 +174,18 @@ + + + + + + + + + + diff --git a/src/main/webapp/scripts/pages/system/netfilesystem_mod.js b/src/main/webapp/scripts/pages/system/netfilesystem_mod.js index 1fe87d0cd..58e1533db 100644 --- a/src/main/webapp/scripts/pages/system/netfilesystem_mod.js +++ b/src/main/webapp/scripts/pages/system/netfilesystem_mod.js @@ -1,5 +1,8 @@ define(function() { + var sysNetFileSysDetUrl; + var sysNetfileSysDetAuthPasswd; + var fileSystemsArray; function loadNetFileSystemsList() { @@ -33,6 +36,7 @@ define(function() { } function setFileSystemClientTypeLabels() { + $.each(fileSystemsArray, function(i, fs) { if (fs.clientType === 'SAMBA') { fs.clientTypeLabel = 'SMBv1'; @@ -137,7 +141,7 @@ define(function() { $('#fileSystemDetailsSftpDirChoiceNo').prop('checked', isSftpClient && !fileSystemRequiresUserDirs(fileSystem)); refreshClientTypeRows(); - + $('#fileSystemName').val(fileSystem.name || ""); $('#fileSystemUrl').val(fileSystem.url || ""); @@ -153,12 +157,12 @@ define(function() { $('#fileSystemSambaDomain').val(clientOptions.SAMBA_DOMAIN); $('#fileSystemSambaShare').val(clientOptions.SAMBA_SHARE_NAME); } else if (isSftpClient) { - // $('#fileSystemDetailsSftpDirChoiceRow').show(); $('#fileSystemSftpServerPublicKey').val(clientOptions.SFTP_SERVER_PUBLIC_KEY); } else if(isIrodsClient) { $('#fileSystemIrodsZone').val(clientOptions.IRODS_ZONE); $('#fileSystemIrodsHomeDir').val(clientOptions.IRODS_HOME_DIR); $('#fileSystemIrodsPort').val(clientOptions.IRODS_PORT); + $('#fileSystemIrodsCsneg').val(clientOptions.IRODS_CSNEG); } var isPasswordAuth = isExistingFileSystem && fileSystem.authType === 'PASSWORD'; @@ -170,6 +174,19 @@ define(function() { $('#fileSystemPubKeyRegistrationUrl').val(""); + + if (fileSystem.clientType === 'IRODS'){ + var rows = fileSystem.clientOptions.split('\n'); + for (var i = 0; i < rows.length; i++) { + var currRow = rows[i]; + var currRowValue = currRow.substring(currRow.indexOf('=') + 1); + if (currRow.indexOf('IRODS_AUTH') === 0) { + $('#iRODSfileSystemAuthTypeNative').prop('checked', currRowValue === 'NATIVE'); + $('#iRODSfileSystemAuthTypePAM').prop('checked', currRowValue === 'PAM'); + } + } + } + if (fileSystem.authOptions) { if (isPubKeyAuth) { var rows = fileSystem.authOptions.split('\n'); @@ -232,9 +249,7 @@ define(function() { clientOptions +="\nUSER_DIRS_REQUIRED=" + dirsRequired; } } else if (clientType === 'IRODS') { - clientOptions = "IRODS_ZONE=" + $('#fileSystemIrodsZone').val() - + "\nIRODS_HOME_DIR=" + $('#fileSystemIrodsHomeDir').val() - + "\nIRODS_PORT=" + $('#fileSystemIrodsPort').val(); + clientOptions = "IRODS_ZONE=" + $('#fileSystemIrodsZone').val() + "\nIRODS_HOME_DIR=" + $('#fileSystemIrodsHomeDir').val() + "\nIRODS_PORT=" + $('#fileSystemIrodsPort').val()+"\nIRODS_CSNEG=" + $('#fileSystemIrodsCsneg').val()+"\nIRODS_AUTH=" + $('input[name="iRODSfileSystemAuthType"]:checked').val()+"\n"; } var fileSystem = { @@ -247,7 +262,7 @@ define(function() { clientOptions: clientOptions, authOptions: authOptions }; - console.log("File System:", fileSystem); + //console.log("File System:", fileSystem); RS.blockPage("Saving..."); var jqxhr = RS.sendJsonPostRequestToUrl('/system/netfilesystem/save', fileSystem); jqxhr.done(function() { @@ -268,6 +283,15 @@ define(function() { //therefore we hide the choice from non SFTP clients but we also //have to give it a value in the UI else the UI framework throws an error on save function refreshClientTypeRows() { + + // retrieve default label values from system.properties + if (sysNetFileSysDetUrl === undefined) { + sysNetFileSysDetUrl = $("label[for='fileSystemUrl']").text(); + } + if (sysNetfileSysDetAuthPasswd === undefined) { + sysNetfileSysDetAuthPasswd = $('#fileSystemAuthTypePasswordSpan').text(); + } + const isSambaClient = $('#fileSystemClientTypeSamba').prop('checked'); const isSambaSmbjClient = isSambaClient && $('#fileSystemClientTypeSambaSmbj').prop('checked'); const isSftpClient = $('#fileSystemClientTypeSftp').prop('checked'); @@ -291,18 +315,35 @@ define(function() { $('.fileSystemDetailsIrodsZoneRow').toggle(isIrodsClient); $('.fileSystemDetailsIrodsHomeDirRow').toggle(isIrodsClient); $('.fileSystemDetailsIrodsPortRow').toggle(isIrodsClient); - + $('.fileSystemDetailsIrodsCsnegRow').toggle(isIrodsClient); + $('.fileSystemDetailsIrodsAuthRow').toggle(isIrodsClient); + $('#fileSystemAuthTypePubKey').prop('disabled', isSambaClient); if (isSambaClient) { $('#fileSystemAuthTypePassword').click(); } - + if (isSambaClient || isSambaSmbjClient) { $('#fileSystemUrl') .attr('title', 'Samba server URL should start with smb://') .attr('pattern', '^smb://.*'); + $("label[for='fileSystemAuthTypePubKey']").show(); + $('#fileSystemAuthTypePasswordSpan').text(sysNetfileSysDetAuthPasswd); + $("label[for='fileSystemUrl']").text(sysNetFileSysDetUrl); + } else if (isIrodsClient) { + $('#fileSystemAuthTypePassword').click(); + $('#fileSystemUrl') + .removeAttr('pattern') + .attr('title', 'iRODS hostname or IP without protocol'); + $("label[for='fileSystemUrl']").text('iRODS Host'); + $("label[for='fileSystemAuthTypePubKey']").hide(); + //$('#fileSystemAuthTypePasswordSpan').text('Native'); + $('#fileSystemAuthTypePasswordSpan').text(sysNetfileSysDetAuthPasswd); } else { - $('#fileSystemUrl').removeAttr('title').removeAttr('pattern') + $('#fileSystemUrl').removeAttr('title').removeAttr('pattern'); + $("label[for='fileSystemAuthTypePubKey']").show(); + $('#fileSystemAuthTypePasswordSpan').text(sysNetfileSysDetAuthPasswd); + $("label[for='fileSystemUrl']").text(sysNetFileSysDetUrl); } } @@ -313,7 +354,8 @@ define(function() { $('#fileSystemPubKeyRegistrationUrl').prop('required', isPubKeyAuth); } - $(document).ready(function() { + $(document).ready(function() { + $(document).on('click', '#netFileSystemLink', loadNetFileSystemsList); $(document).on('click', '.fileSystemDetailsButton', showFileSystemDetails); $(document).on('click', '.fileSystemDeleteButton', deleteFileSystem); @@ -324,4 +366,4 @@ define(function() { $(document).on('submit', '#fileSystemDetailsForm', saveFileSystem); }); -}); \ No newline at end of file +});