Skip to content

Commit

Permalink
Merge remote branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Niggemann committed Dec 13, 2016
2 parents c25f87d + fa624df commit bd62ccd
Show file tree
Hide file tree
Showing 104 changed files with 1,384 additions and 722 deletions.
33 changes: 33 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
image: java:8-jdk

stages:
- build
- test
- deploy

before_script:
# - echo `pwd` # debug
# - echo "$CI_BUILD_NAME, $CI_BUILD_REF_NAME $CI_BUILD_STAGE" # debug
- export GRADLE_USER_HOME=`pwd`/.gradle

cache:
paths:
- .gradle/wrapper
- .gradle/caches

build:
stage: build
script:
- ./gradlew assemble
artifacts:
paths:
- build/libs/*.jar
expire_in: 1 week
only:
- master

test:
stage: test
script:
- ./gradlew check

1 change: 0 additions & 1 deletion src/it/java/SmbjTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ public void testRpc() throws IOException, SMBApiException, URISyntaxException {
}
}


//@Test
public void manualTestNotify() throws IOException {

Expand Down
2 changes: 1 addition & 1 deletion src/it/resources/logback-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
</root>

<logger name="com.hierynomus" level="info"/>
<logger name="com.hierynomus.smbj.transport" level="info" />
<logger name="com.hierynomus.smbj.transport" level="trace" />

</configuration>
15 changes: 7 additions & 8 deletions src/main/java/com/hierynomus/msdtyp/ACL.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
*/
package com.hierynomus.msdtyp;

import java.util.Arrays;
import com.hierynomus.msdtyp.ace.ACE;
import com.hierynomus.protocol.commons.buffer.Buffer;
import com.hierynomus.smbj.common.SMBBuffer;

import java.util.Arrays;

/**
* [MS-DTYP].pdf 2.4.5 ACL
*/
Expand Down Expand Up @@ -84,11 +83,11 @@ public int getAclSize() {
@Override
public String toString() {
return "ACL{" +
"revision=" + revision +
", aceCount=" + aceCount +
", sidIdentifierAuthority=" + Arrays.toString(sidIdentifierAuthority) +
", subAuthorities=" + Arrays.toString(subAuthorities) +
", aces=" + Arrays.toString(aces) +
'}';
"revision=" + revision +
", aceCount=" + aceCount +
", sidIdentifierAuthority=" + Arrays.toString(sidIdentifierAuthority) +
", subAuthorities=" + Arrays.toString(subAuthorities) +
", aces=" + Arrays.toString(aces) +
'}';
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/hierynomus/msdtyp/AccessMask.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

/**
* MS-DTYP 2.4.3 ACCESS_MASK
*
* <p>
* Its ok to find multiple names pointing to the same values, Since the
* same access mask when applied to File, Folder or other object are just
* named/called differently.
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/hierynomus/msdtyp/MsDataTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
*/
package com.hierynomus.msdtyp;

import com.hierynomus.protocol.commons.buffer.Buffer;
import com.hierynomus.protocol.commons.buffer.Endian;

import java.util.Date;
import java.util.UUID;
import com.hierynomus.protocol.commons.buffer.Buffer;
import com.hierynomus.protocol.commons.buffer.Endian;

/**
* Utility class that can read and write data types from the [MS-DTYP].pdf specification document from buffers.
Expand All @@ -28,7 +27,8 @@ public class MsDataTypes {
public static final int NANO100_TO_MILLI = 10000;
public static final long WINDOWS_TO_UNIX_EPOCH = 0x19DB1DED53E8000L;

private MsDataTypes() {}
private MsDataTypes() {
}

/**
* [MS-DTYP].pdf 2.3.4.2 GUID Packet representation
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/com/hierynomus/msdtyp/SID.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import com.hierynomus.protocol.commons.buffer.Buffer;
import com.hierynomus.smbj.common.SMBBuffer;

import java.util.Arrays;

/**
* [MS-DTYP].pdf 2.4.2 SecurityIdentifier SID
*/
Expand Down Expand Up @@ -134,4 +136,29 @@ public byte[] getSidIdentifierAuthority() {
public long[] getSubAuthorities() {
return subAuthorities;
}

@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;

SID sid = (SID) o;

if (revision != sid.revision)
return false;
if (!Arrays.equals(sidIdentifierAuthority, sid.sidIdentifierAuthority))
return false;
return Arrays.equals(subAuthorities, sid.subAuthorities);

}

@Override
public int hashCode() {
int result = (int) revision;
result = 31 * result + Arrays.hashCode(sidIdentifierAuthority);
result = 31 * result + Arrays.hashCode(subAuthorities);
return result;
}
}
17 changes: 8 additions & 9 deletions src/main/java/com/hierynomus/msdtyp/SecurityDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
*/
package com.hierynomus.msdtyp;

import java.util.EnumSet;
import com.hierynomus.protocol.commons.EnumWithValue;
import com.hierynomus.protocol.commons.buffer.Buffer;
import com.hierynomus.smbj.common.SMBBuffer;

import java.util.EnumSet;

/**
* [MS-DTYP].pdf 2.4.6 SecurityDescriptor
*/
Expand All @@ -35,7 +34,7 @@ public class SecurityDescriptor {
public SecurityDescriptor() {
}

// public SecurityDescriptor(EnumSet<Control> control, SID ownerSid, SID groupSid, ACL sacl, ACL dacl) {
// public SecurityDescriptor(EnumSet<Control> control, SID ownerSid, SID groupSid, ACL sacl, ACL dacl) {
// this.control = control;
// this.ownerSid = ownerSid;
// this.groupSid = groupSid;
Expand Down Expand Up @@ -120,12 +119,12 @@ public ACL getDacl() {
@Override
public String toString() {
return "SecurityDescriptor{" +
"control=" + control +
", ownerSid=" + ownerSid +
", groupSid=" + groupSid +
", sacl=" + sacl +
", dacl=" + dacl +
'}';
"control=" + control +
", ownerSid=" + ownerSid +
", groupSid=" + groupSid +
", sacl=" + sacl +
", dacl=" + dacl +
'}';
}

// SecurityDescriptor Control bits
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/hierynomus/msdtyp/ace/ACE.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ public static ACE factory(SMBBuffer buffer) throws Buffer.BufferException {
@Override
public String toString() {
return "ACE{" +
"aceHeader=" + aceHeader +
", accessMask=" + EnumWithValue.EnumUtils.toEnumSet(accessMask, AccessMask.class) +
", sid=" + sid +
'}';
"aceHeader=" + aceHeader +
", accessMask=" + EnumWithValue.EnumUtils.toEnumSet(accessMask, AccessMask.class) +
", sid=" + sid +
'}';
}

protected abstract void readMessage(SMBBuffer buffer) throws Buffer.BufferException;
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/com/hierynomus/msdtyp/ace/AceHeader.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
*/
package com.hierynomus.msdtyp.ace;

import java.util.EnumSet;
import com.hierynomus.protocol.commons.EnumWithValue;
import com.hierynomus.protocol.commons.buffer.Buffer;
import com.hierynomus.smbj.common.SMBBuffer;

import java.util.EnumSet;

import static com.hierynomus.protocol.commons.EnumWithValue.EnumUtils.toEnumSet;
import static com.hierynomus.protocol.commons.EnumWithValue.EnumUtils.valueOf;

Expand Down Expand Up @@ -73,9 +72,9 @@ public EnumSet<AceFlags> getAceFlags() {
@Override
public String toString() {
return "AceHeader{" +
"aceType=" + aceType +
", aceFlags=" + aceFlags +
", aceSize=" + aceSize +
'}';
"aceType=" + aceType +
", aceFlags=" + aceFlags +
", aceSize=" + aceSize +
'}';
}
}
6 changes: 3 additions & 3 deletions src/main/java/com/hierynomus/msdtyp/ace/AceType1.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@
*/
package com.hierynomus.msdtyp.ace;

import java.util.EnumSet;
import com.hierynomus.msdtyp.AccessMask;
import com.hierynomus.msdtyp.SID;
import com.hierynomus.protocol.commons.buffer.Buffer;
import com.hierynomus.smbj.common.SMBBuffer;

import java.util.EnumSet;

import static com.hierynomus.protocol.commons.EnumWithValue.EnumUtils.toLong;

// Type 1 - Header/Mask/SID (ACCESS_ALLOWED_ACE, ACCESS_DENIED_ACE, SYSTEM_AUDIT_ACE, SYSTEM_MANDATORY_LABEL_ACE,
Expand All @@ -30,9 +29,10 @@ class AceType1 extends ACE {

AceType1() {
}

AceType1(AceType aceType, EnumSet<AceFlags> aceFlags, EnumSet<AccessMask> accessMask, SID sid) {
super(new AceHeader(aceType, aceFlags, ACE.HEADER_STRUCTURE_SIZE + 4 + sid.byteCount()),
toLong(accessMask), sid);
toLong(accessMask), sid);
}

@Override
Expand Down
17 changes: 8 additions & 9 deletions src/main/java/com/hierynomus/msdtyp/ace/AceType2.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
*/
package com.hierynomus.msdtyp.ace;

import java.util.EnumSet;
import java.util.UUID;
import com.hierynomus.msdtyp.AccessMask;
import com.hierynomus.msdtyp.MsDataTypes;
import com.hierynomus.msdtyp.SID;
import com.hierynomus.protocol.commons.buffer.Buffer;
import com.hierynomus.smbj.common.SMBBuffer;

import java.util.EnumSet;
import java.util.UUID;

import static com.hierynomus.protocol.commons.EnumWithValue.EnumUtils.toEnumSet;
import static com.hierynomus.protocol.commons.EnumWithValue.EnumUtils.toLong;

Expand All @@ -35,9 +34,9 @@ class AceType2 extends ACE {
private UUID inheritedObjectType;

AceType2(AceType aceType, EnumSet<AceFlags> aceFlags, EnumSet<AccessMask> accessMask,
EnumSet<AceObjectFlags> flags, UUID objectType, UUID inheritedObjectType, SID sid) {
EnumSet<AceObjectFlags> flags, UUID objectType, UUID inheritedObjectType, SID sid) {
super(new AceHeader(aceType, aceFlags, ACE.HEADER_STRUCTURE_SIZE + 4 + 4 + 16 + 16 + sid.byteCount()),
toLong(accessMask), sid);
toLong(accessMask), sid);
this.flags = flags;
this.objectType = objectType;
this.inheritedObjectType = inheritedObjectType;
Expand Down Expand Up @@ -83,9 +82,9 @@ protected void readMessage(SMBBuffer buffer) throws Buffer.BufferException {
@Override
public String toString() {
return "AceType2{" +
"flags=" + flags +
", objectType=" + objectType +
", inheritedObjectType=" + inheritedObjectType +
"} " + super.toString();
"flags=" + flags +
", objectType=" + objectType +
", inheritedObjectType=" + inheritedObjectType +
"} " + super.toString();
}
}
15 changes: 7 additions & 8 deletions src/main/java/com/hierynomus/msdtyp/ace/AceType3.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
*/
package com.hierynomus.msdtyp.ace;

import java.util.Arrays;
import java.util.EnumSet;
import com.hierynomus.msdtyp.AccessMask;
import com.hierynomus.msdtyp.SID;
import com.hierynomus.protocol.commons.buffer.Buffer;
import com.hierynomus.smbj.common.SMBBuffer;

import java.util.Arrays;
import java.util.EnumSet;

import static com.hierynomus.protocol.commons.EnumWithValue.EnumUtils.toLong;

// Type 3 - Header/Mask/SID/ApplicationData
Expand All @@ -35,10 +34,10 @@ class AceType3 extends ACE {
}

AceType3(AceType aceType, EnumSet<AceFlags> aceFlags, EnumSet<AccessMask> accessMask, SID sid, byte[]
applicationData) {
applicationData) {
super(new AceHeader(aceType, aceFlags, ACE.HEADER_STRUCTURE_SIZE + 4 + 4 + sid.byteCount() +
applicationData.length),
toLong(accessMask), sid);
applicationData.length),
toLong(accessMask), sid);
this.applicationData = applicationData;
}

Expand All @@ -59,7 +58,7 @@ protected void readMessage(SMBBuffer buffer) throws Buffer.BufferException {
@Override
public String toString() {
return "AceType3{" +
"applicationData=" + Arrays.toString(applicationData) +
"} " + super.toString();
"applicationData=" + Arrays.toString(applicationData) +
"} " + super.toString();
}
}
15 changes: 7 additions & 8 deletions src/main/java/com/hierynomus/msdtyp/ace/AceType4.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
*/
package com.hierynomus.msdtyp.ace;

import java.util.Arrays;
import java.util.EnumSet;
import java.util.UUID;
import com.hierynomus.msdtyp.AccessMask;
import com.hierynomus.msdtyp.SID;
import com.hierynomus.protocol.commons.buffer.Buffer;
import com.hierynomus.smbj.common.SMBBuffer;

import java.util.Arrays;
import java.util.EnumSet;
import java.util.UUID;

// Type 4 - Header/Mask/Flags/ObjectType/InheritedObjectType/Sid/ApplicationData
// ACCESS_ALLOWED_CALLBACK_OBJECT_ACE, ACCESS_DENIED_CALLBACK_OBJECT_ACE, SYSTEM_AUDIT_OBJECT_ACE,
// SYSTEM_AUDIT_CALLBACK_OBJECT_ACE,
Expand All @@ -35,8 +34,8 @@ class AceType4 extends AceType2 {
}

AceType4(AceType aceType, EnumSet<AceFlags> aceFlags, EnumSet<AccessMask> accessMask,
EnumSet<AceObjectFlags> flags, UUID objectType, UUID inheritedObjectType, SID sid, byte[]
applicationData) {
EnumSet<AceObjectFlags> flags, UUID objectType, UUID inheritedObjectType, SID sid, byte[]
applicationData) {
super(aceType, aceFlags, accessMask, flags, objectType, inheritedObjectType, sid);
aceHeader.setAceSize(aceHeader.getAceSize() + applicationData.length);
this.applicationData = applicationData;
Expand All @@ -58,7 +57,7 @@ protected void readMessage(SMBBuffer buffer) throws Buffer.BufferException {
@Override
public String toString() {
return "AceType4{" +
"applicationData=" + Arrays.toString(applicationData) +
"} " + super.toString();
"applicationData=" + Arrays.toString(applicationData) +
"} " + super.toString();
}
}
Loading

0 comments on commit bd62ccd

Please sign in to comment.