jcifs.smb.NtStatus Java Examples
The following examples show how to use
jcifs.smb.NtStatus.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServerMessageBlock2Response.java From jcifs with GNU Lesser General Public License v2.1 | 6 votes |
/** * * {@inheritDoc} * * @see jcifs.util.transport.Response#verifySignature(byte[], int, int) */ @Override public boolean verifySignature ( byte[] buffer, int i, int size ) { // observed too that signatures on error responses are sometimes wrong?? // Looks like the failure case also is just reflecting back the signature we sent // with SMB3's negotiation validation it's no longer possible to ignore this (on the validation response) // make sure that validation is performed in any case Smb2SigningDigest dgst = getDigest(); if ( dgst != null && !isAsync() && ( getConfig().isRequireSecureNegotiate() || getErrorCode() == NtStatus.NT_STATUS_OK ) ) { // TODO: SMB2 - do we need to check the MIDs? // We only read what we were waiting for, so first guess would be no. boolean verify = dgst.verify(buffer, i, size, 0, this); this.verifyFailed = verify; return !verify; } return true; }
Example #2
Source File: ConcurrencyTest.java From jcifs-ng with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testOpenReadLocked () throws IOException { String fname = makeRandomName(); try ( SmbFile sr = getDefaultShareRoot(); SmbResource exclFile = new SmbFile(sr, fname) ) { exclFile.createNewFile(); try { try ( InputStream is = exclFile.openInputStream(SmbConstants.FILE_NO_SHARE); InputStream is2 = exclFile.openInputStream(SmbConstants.FILE_NO_SHARE) ) { fail("No sharing violation"); } catch ( SmbException e ) { if ( e.getNtStatus() == NtStatus.NT_STATUS_SHARING_VIOLATION ) { return; } throw e; } } finally { exclFile.delete(); } } }
Example #3
Source File: ConcurrencyTest.java From jcifs-ng with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testOpenLocked () throws IOException { String fname = makeRandomName(); try ( SmbFile sr = getDefaultShareRoot(); SmbResource exclFile = new SmbFile(sr, fname) ) { try ( OutputStream s = exclFile.openOutputStream(false, SmbConstants.FILE_NO_SHARE); InputStream is = exclFile.openInputStream(SmbConstants.FILE_NO_SHARE) ) { fail("No sharing violation"); } catch ( SmbException e ) { if ( e.getNtStatus() == NtStatus.NT_STATUS_SHARING_VIOLATION ) { return; } throw e; } finally { exclFile.delete(); } } }
Example #4
Source File: ConcurrencyTest.java From jcifs with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testDeleteLocked () throws IOException { String fname = makeRandomName(); try ( SmbFile sr = getDefaultShareRoot(); SmbResource exclFile = new SmbFile(sr, fname) ) { try ( OutputStream s = exclFile.openOutputStream(false, SmbConstants.FILE_NO_SHARE) ) { try { exclFile.delete(); fail("Could remove locked file"); } catch ( SmbException e ) { if ( e.getNtStatus() == NtStatus.NT_STATUS_SHARING_VIOLATION ) { return; } throw e; } } finally { exclFile.delete(); } } }
Example #5
Source File: ConcurrencyTest.java From jcifs with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testOpenLocked () throws IOException { String fname = makeRandomName(); try ( SmbFile sr = getDefaultShareRoot(); SmbResource exclFile = new SmbFile(sr, fname) ) { try ( OutputStream s = exclFile.openOutputStream(false, SmbConstants.FILE_NO_SHARE); InputStream is = exclFile.openInputStream(SmbConstants.FILE_NO_SHARE) ) { fail("No sharing violation"); } catch ( SmbException e ) { if ( e.getNtStatus() == NtStatus.NT_STATUS_SHARING_VIOLATION ) { return; } throw e; } finally { exclFile.delete(); } } }
Example #6
Source File: ConcurrencyTest.java From jcifs with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testOpenReadLocked () throws IOException { String fname = makeRandomName(); try ( SmbFile sr = getDefaultShareRoot(); SmbResource exclFile = new SmbFile(sr, fname) ) { exclFile.createNewFile(); try { try ( InputStream is = exclFile.openInputStream(SmbConstants.FILE_NO_SHARE); InputStream is2 = exclFile.openInputStream(SmbConstants.FILE_NO_SHARE) ) { fail("No sharing violation"); } catch ( SmbException e ) { if ( e.getNtStatus() == NtStatus.NT_STATUS_SHARING_VIOLATION ) { return; } throw e; } } finally { exclFile.delete(); } } }
Example #7
Source File: ConcurrencyTest.java From jcifs-ng with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testDeleteLocked () throws IOException { String fname = makeRandomName(); try ( SmbFile sr = getDefaultShareRoot(); SmbResource exclFile = new SmbFile(sr, fname) ) { try ( OutputStream s = exclFile.openOutputStream(false, SmbConstants.FILE_NO_SHARE) ) { try { exclFile.delete(); fail("Could remove locked file"); } catch ( SmbException e ) { if ( e.getNtStatus() == NtStatus.NT_STATUS_SHARING_VIOLATION ) { return; } throw e; } } finally { exclFile.delete(); } } }
Example #8
Source File: ServerMessageBlock2Response.java From jcifs-ng with GNU Lesser General Public License v2.1 | 6 votes |
/** * * {@inheritDoc} * * @see jcifs.util.transport.Response#verifySignature(byte[], int, int) */ @Override public boolean verifySignature ( byte[] buffer, int i, int size ) { // observed too that signatures on error responses are sometimes wrong?? // Looks like the failure case also is just reflecting back the signature we sent // with SMB3's negotiation validation it's no longer possible to ignore this (on the validation response) // make sure that validation is performed in any case Smb2SigningDigest dgst = getDigest(); if ( dgst != null && !isAsync() && ( getConfig().isRequireSecureNegotiate() || getErrorCode() == NtStatus.NT_STATUS_OK ) ) { // TODO: SMB2 - do we need to check the MIDs? // We only read what we were waiting for, so first guess would be no. boolean verify = dgst.verify(buffer, i, size, 0, this); this.verifyFailed = verify; return !verify; } return true; }
Example #9
Source File: Smb2IoctlResponse.java From jcifs with GNU Lesser General Public License v2.1 | 5 votes |
/** * {@inheritDoc} * * @see jcifs.internal.smb2.ServerMessageBlock2#isErrorResponseStatus() */ @Override protected boolean isErrorResponseStatus () { int status = getStatus(); return status != NtStatus.NT_STATUS_INVALID_PARAMETER && ! ( status == NtStatus.NT_STATUS_INVALID_PARAMETER && ( this.ctlCode == Smb2IoctlRequest.FSCTL_SRV_COPYCHUNK || this.ctlCode == Smb2IoctlRequest.FSCTL_SRV_COPYCHUNK_WRITE ) ) && ! ( status == NtStatus.NT_STATUS_BUFFER_OVERFLOW && ( this.ctlCode == Smb2IoctlRequest.FSCTL_PIPE_TRANSCEIVE || this.ctlCode == Smb2IoctlRequest.FSCTL_PIPE_PEEK || this.ctlCode == Smb2IoctlRequest.FSCTL_DFS_GET_REFERRALS ) ) && super.isErrorResponseStatus(); }
Example #10
Source File: ServerMessageBlock2Response.java From jcifs with GNU Lesser General Public License v2.1 | 5 votes |
/** * {@inheritDoc} * * @see jcifs.util.transport.Response#received() */ @Override public final void received () { if ( isAsync() && getStatus() == NtStatus.NT_STATUS_PENDING ) { synchronized ( this ) { notifyAll(); } return; } this.received = true; synchronized ( this ) { notifyAll(); } }
Example #11
Source File: Smb2IoctlResponse.java From jcifs-ng with GNU Lesser General Public License v2.1 | 5 votes |
/** * {@inheritDoc} * * @see jcifs.internal.smb2.ServerMessageBlock2#isErrorResponseStatus() */ @Override protected boolean isErrorResponseStatus () { int status = getStatus(); return status != NtStatus.NT_STATUS_INVALID_PARAMETER && ! ( status == NtStatus.NT_STATUS_INVALID_PARAMETER && ( this.ctlCode == Smb2IoctlRequest.FSCTL_SRV_COPYCHUNK || this.ctlCode == Smb2IoctlRequest.FSCTL_SRV_COPYCHUNK_WRITE ) ) && ! ( status == NtStatus.NT_STATUS_BUFFER_OVERFLOW && ( this.ctlCode == Smb2IoctlRequest.FSCTL_PIPE_TRANSCEIVE || this.ctlCode == Smb2IoctlRequest.FSCTL_PIPE_PEEK || this.ctlCode == Smb2IoctlRequest.FSCTL_DFS_GET_REFERRALS ) ) && super.isErrorResponseStatus(); }
Example #12
Source File: ServerMessageBlock2Response.java From jcifs-ng with GNU Lesser General Public License v2.1 | 5 votes |
/** * {@inheritDoc} * * @see jcifs.util.transport.Response#received() */ @Override public final void received () { if ( isAsync() && getStatus() == NtStatus.NT_STATUS_PENDING ) { synchronized ( this ) { notifyAll(); } return; } this.received = true; synchronized ( this ) { notifyAll(); } }
Example #13
Source File: SMBOperationHandler.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 4 votes |
private static List<SmbFile> expand(SmbFile base, String part, boolean directory) throws IOException { if (base == null) { throw new NullPointerException("base"); //$NON-NLS-1$ } if (!base.isDirectory()) { throw new IllegalArgumentException(MessageFormat.format(FileOperationMessages.getString("IOperationHandler.not_a_directory"), base)); //$NON-NLS-1$ } base = ensureTrailingSlash(base); part = URIUtils.urlDecode(part); if (hasWildcards(part)) { SmbFile[] children; try { // Let's use cool SmbFile.listFiles(String) method which resolves exactly our (DOS) wildcards... children = base.listFiles(part); } catch (SmbException e) { // ... but it uses not so cool way of letting know that there are no files matching the pattern if (e.getNtStatus() == NtStatus.NT_STATUS_NO_SUCH_FILE) { return Collections.emptyList(); // maybe this could be done on any SmbException } else { throw e; } } if (!directory) { return Arrays.asList(children); } else { List<SmbFile> dirsOnly = new ArrayList<SmbFile>(children.length); for (SmbFile child : children) { if (child.isDirectory()) { dirsOnly.add(child); } } return dirsOnly; } } else { SmbFile file = new SmbFile(base, part); if (file.exists()) { return Arrays.asList(file); } else { return new ArrayList<SmbFile>(0); } } }
Example #14
Source File: Smb2ChangeNotifyResponse.java From jcifs-ng with GNU Lesser General Public License v2.1 | 2 votes |
/** * {@inheritDoc} * * @see jcifs.internal.smb2.ServerMessageBlock2#isErrorResponseStatus() */ @Override protected boolean isErrorResponseStatus () { return getStatus() != NtStatus.NT_STATUS_NOTIFY_ENUM_DIR && super.isErrorResponseStatus(); }
Example #15
Source File: Smb2ReadResponse.java From jcifs-ng with GNU Lesser General Public License v2.1 | 2 votes |
/** * {@inheritDoc} * * @see jcifs.internal.smb2.ServerMessageBlock2#isErrorResponseStatus() */ @Override protected boolean isErrorResponseStatus () { return getStatus() != NtStatus.NT_STATUS_BUFFER_OVERFLOW && super.isErrorResponseStatus(); }
Example #16
Source File: Smb2SessionSetupResponse.java From jcifs-ng with GNU Lesser General Public License v2.1 | 2 votes |
/** * {@inheritDoc} * * @see jcifs.internal.smb2.ServerMessageBlock2#isErrorResponseStatus() */ @Override protected boolean isErrorResponseStatus () { return getStatus() != NtStatus.NT_STATUS_MORE_PROCESSING_REQUIRED && super.isErrorResponseStatus(); }
Example #17
Source File: Smb2ReadResponse.java From jcifs with GNU Lesser General Public License v2.1 | 2 votes |
/** * {@inheritDoc} * * @see jcifs.internal.smb2.ServerMessageBlock2#isErrorResponseStatus() */ @Override protected boolean isErrorResponseStatus () { return getStatus() != NtStatus.NT_STATUS_BUFFER_OVERFLOW && super.isErrorResponseStatus(); }
Example #18
Source File: Smb2ChangeNotifyResponse.java From jcifs with GNU Lesser General Public License v2.1 | 2 votes |
/** * {@inheritDoc} * * @see jcifs.internal.smb2.ServerMessageBlock2#isErrorResponseStatus() */ @Override protected boolean isErrorResponseStatus () { return getStatus() != NtStatus.NT_STATUS_NOTIFY_ENUM_DIR && super.isErrorResponseStatus(); }
Example #19
Source File: Smb2SessionSetupResponse.java From jcifs with GNU Lesser General Public License v2.1 | 2 votes |
/** * {@inheritDoc} * * @see jcifs.internal.smb2.ServerMessageBlock2#isErrorResponseStatus() */ @Override protected boolean isErrorResponseStatus () { return getStatus() != NtStatus.NT_STATUS_MORE_PROCESSING_REQUIRED && super.isErrorResponseStatus(); }