Package jcifs.smb

Examples of jcifs.smb.ACE


    verify(smbFile);
  }

  public void testACLForPresenceOfDenyFileLevelACE () throws IOException {
    SmbFileDelegate smbFile = createMock(SmbFileDelegate.class);
    ACE fileAce = createACE("accountants", false /*group ACE*/, true /*Deny ACE*/);
    ACE [] fileAces = {fileAce};
    expect(smbFile.getSecurity()).andReturn(fileAces);
    expect(smbFile.getURL()).andReturn(new URL("file","host","file"));
    expectLastCall().anyTimes();
    replay(smbFile);
View Full Code Here


  }

  public void testACLForSAMLTypeACL () throws IOException {
    SmbFileDelegate smbFile = createMock(SmbFileDelegate.class);
    String samlAceFormat = AclFormat.USER_AT_DOMAIN.getFormat();
    ACE shareAce = createACE("google\\accountants", false /* this will create a group ACE*/);
    ACE [] shareAces = {shareAce};
    expect(smbFile.getShareSecurity(true)).andReturn(shareAces);
    expect(smbFile.getURL()).andReturn(new URL("file","host","file"));
    expectLastCall().anyTimes();
    replay(smbFile);
View Full Code Here

  }

  public void testACLForHTTPBasicTypeACL () throws IOException {
    SmbFileDelegate smbFile = createMock(SmbFileDelegate.class);
    String httpAceFormat = AclFormat.DOMAIN_BACKSLASH_USER.getFormat();
    ACE shareAce = createACE("google\\accountants", false /* this will create a group ACE*/);
    ACE [] shareAces = {shareAce};
    expect(smbFile.getShareSecurity(true)).andReturn(shareAces);
    expect(smbFile.getURL()).andReturn(new URL("file","host","file"));
    expectLastCall().anyTimes();
    replay(smbFile);
View Full Code Here

    verify(smbFile);
  }

  public void testACLForHTTPBasicUserAceAndSAMLGroupAce () throws IOException {
    SmbFileDelegate smbFile = createMock(SmbFileDelegate.class);
    ACE fileAce = createACE("google\\superUser", true);
    ACE fileAce1 = createACE("user2", true);
    ACE [] fileAces = {fileAce, fileAce1};
    expect(smbFile.getSecurity()).andReturn(fileAces);
    //To ensure that we get same SID for checking equality
    ACE shareAce = fileAce;
    ACE shareAce1 = createACE("google\\employees", false);
    ACE [] shareAces = {shareAce, shareAce1};
    expect(smbFile.getShareSecurity(true)).andReturn(shareAces);
    expect(smbFile.getURL()).andReturn(new URL("file","host","file"));
    expectLastCall().anyTimes();
    replay(smbFile);
View Full Code Here

   * @param userOrGroupName Name of the user ACE
   * @param isUser if true then user ACE will be created otherwise Group ACE
   */
  private ACE createACE(String userOrGroupName, boolean isUser, boolean isDeny) {
    //TODO : Add enums instead of booleans to avoid comments in the calls.
    ACE ace = createMock(ACE.class);
    SID sid = createMock(SID.class);
    expect(sid.toDisplayString()).andReturn(userOrGroupName);
    expectLastCall().anyTimes();
    if (isUser) {
      expect(sid.getType()).andReturn(SID.SID_TYPE_USER);
    } else {
        expect(sid.getType()).andReturn(SID.SID_TYPE_DOM_GRP);
    }
    expectLastCall().anyTimes();
    expect(ace.getSID()).andReturn(sid);
    //For most of these calls, it doesn't matter how many times they get called
    //as long as they return the given value; some of these calls are made in a
    //loop so its good enough to say that they will be called at least once.
    expectLastCall().atLeastOnce();
    if (isDeny) {
      expect(ace.isAllow()).andReturn(false);
      expectLastCall().atLeastOnce();
      expect(ace.getAccessMask())
          .andReturn(LegacySmbAclBuilder.READ_ACCESS_MASK);
      expectLastCall().atLeastOnce();
    } else {
      expect(ace.isAllow()).andReturn(true);
      expectLastCall().atLeastOnce();
      expect(ace.getFlags()).andReturn(0);
      expectLastCall().anyTimes();
      expect(ace.getAccessMask())
          .andReturn(LegacySmbAclBuilder.READ_ACCESS_MASK);
      expectLastCall().atLeastOnce();
    }
    replay(sid);
    replay(ace);
View Full Code Here

   * @throws IOException
   */
  private boolean checkAndAddAces(List<ACE> aceList, boolean isShare)
      throws IOException {
    try {
      ACE securityAces[];
      String operation;
      if (isShare) {
        securityAces = file.getShareSecurity(true);
        operation = "getShareSecurity()";
      } else {
View Full Code Here

          allowCount = 0;
          denyCount = 0;
          j = 0;
          while (j < aces.length)
          {
            ACE ace = aces[j++];
            if ((ace.getAccessMask() & ACE.FILE_READ_DATA) != 0)
            {
              if (ace.isAllow())
                allowCount++;
              else
                denyCount++;
            }
          }

          shareAllowAcls = new String[allowCount];
          shareDenyAcls = new String[denyCount+1];
          j = 0;
          allowCount = 0;
          denyCount = 0;
          shareDenyAcls[denyCount++] = defaultAuthorityDenyToken;
          while (j < aces.length)
          {
            ACE ace = aces[j++];
            if ((ace.getAccessMask() & ACE.FILE_READ_DATA) != 0)
            {
              if (ace.isAllow())
                shareAllowAcls[allowCount++] = useSIDs ? ace.getSID().toString() : ace.getSID().getAccountName();
              else
                shareDenyAcls[denyCount++] = useSIDs ? ace.getSID().toString() : ace.getSID().getAccountName();
            }
          }
        }
      }
      else
      {
        shareAllowAcls = forcedShareAcls;
        if (forcedShareAcls.length == 0)
          shareDenyAcls = new String[0];
        else
          shareDenyAcls = new String[]{defaultAuthorityDenyToken};
      }
      java.util.Arrays.sort(shareAllowAcls);
      java.util.Arrays.sort(shareDenyAcls);
      // Stuff the acls into the description string.
      packList(description,shareAllowAcls,'+');
      packList(description,shareDenyAcls,'+');
    }
    else
      description.append('-');

    if (forcedParentFolderAcls!=null)
    {
      description.append("+");

      if (forcedParentFolderAcls.length==0)
      {
        aces = getFileSecurity(parentFolder, useSIDs);
        if (aces == null)
        {
          if (Logging.connectors.isDebugEnabled())
            Logging.connectors.debug("JCIFS: Parent folder has no ACL for '"+getFileCanonicalPath(parentFolder)+"'");

          // Parent folder is "public", meaning we want S-1-1-0 and the deny token
          parentAllowAcls = new String[]{"S-1-1-0"};
          parentDenyAcls = new String[]{defaultAuthorityDenyToken};
        }
        else
        {
          if (Logging.connectors.isDebugEnabled())
            Logging.connectors.debug("JCIFS: Found "+Integer.toString(aces.length)+" parent folder access tokens for '"+getFileCanonicalPath(parentFolder)+"'");

          // We are interested in the read permission, and take
          // a keen interest in allow/deny
          allowCount = 0;
          denyCount = 0;
          j = 0;
          while (j < aces.length)
          {
            ACE ace = aces[j++];
            if ((ace.getAccessMask() & ACE.FILE_READ_DATA) != 0)
            {
              if (ace.isAllow())
                allowCount++;
              else
                denyCount++;
            }
          }

          parentAllowAcls = new String[allowCount];
          parentDenyAcls = new String[denyCount+1];
          j = 0;
          allowCount = 0;
          denyCount = 0;
          parentDenyAcls[denyCount++] = defaultAuthorityDenyToken;
          while (j < aces.length)
          {
            ACE ace = aces[j++];
            if ((ace.getAccessMask() & ACE.FILE_READ_DATA) != 0)
            {
              if (ace.isAllow())
                parentAllowAcls[allowCount++] = useSIDs ? ace.getSID().toString() : ace.getSID().getAccountName();
              else
                parentDenyAcls[denyCount++] = useSIDs ? ace.getSID().toString() : ace.getSID().getAccountName();
            }
          }
        }
      }
      else
      {
        parentAllowAcls = forcedParentFolderAcls;
        if (forcedParentFolderAcls.length == 0)
          parentDenyAcls = new String[0];
        else
          parentDenyAcls = new String[]{defaultAuthorityDenyToken};
      }
      java.util.Arrays.sort(parentAllowAcls);
      java.util.Arrays.sort(parentDenyAcls);
      packList(description,parentAllowAcls,'+');
      packList(description,parentDenyAcls,'+');
    }
    else
      description.append('-');

    if (forcedacls!=null)
    {
      description.append("+");

      if (forcedacls.length==0)
      {
        aces = getFileSecurity(file, useSIDs);
        if (aces == null)
        {
          if (Logging.connectors.isDebugEnabled())
            Logging.connectors.debug("JCIFS: Document has no ACL for '"+getFileCanonicalPath(file)+"'");

          // Document is "public", meaning we want S-1-1-0 and the deny token
          allowAcls = new String[]{"S-1-1-0"};
          denyAcls = new String[]{defaultAuthorityDenyToken};
        }
        else
        {
          if (Logging.connectors.isDebugEnabled())
            Logging.connectors.debug("JCIFS: Found "+Integer.toString(aces.length)+" document access tokens for '"+getFileCanonicalPath(file)+"'");

          // We are interested in the read permission, and take
          // a keen interest in allow/deny
          allowCount = 0;
          denyCount = 0;
          j = 0;
          while (j < aces.length)
          {
            ACE ace = aces[j++];
            if ((ace.getAccessMask() & ACE.FILE_READ_DATA) != 0)
            {
              if (ace.isAllow())
                allowCount++;
              else
                denyCount++;
            }
          }

          allowAcls = new String[allowCount];
          denyAcls = new String[denyCount+1];
          j = 0;
          allowCount = 0;
          denyCount = 0;
          denyAcls[denyCount++] = defaultAuthorityDenyToken;
          while (j < aces.length)
          {
            ACE ace = aces[j++];
            if ((ace.getAccessMask() & ACE.FILE_READ_DATA) != 0)
            {
              if (ace.isAllow())
                allowAcls[allowCount++] = useSIDs ? ace.getSID().toString() : ace.getSID().getAccountName();
              else
                denyAcls[denyCount++] = useSIDs ? ace.getSID().toString() : ace.getSID().getAccountName();
            }
          }
        }
      }
      else
View Full Code Here

          allowCount = 0;
          denyCount = 0;
          j = 0;
          while (j < aces.length)
          {
            ACE ace = aces[j++];
            if ((ace.getAccessMask() & ACE.FILE_READ_DATA) != 0)
            {
              if (ace.isAllow())
                allowCount++;
              else
                denyCount++;
            }
          }

          shareAllowAcls = new String[allowCount];
          shareDenyAcls = new String[denyCount+1];
          j = 0;
          allowCount = 0;
          denyCount = 0;
          shareDenyAcls[denyCount++] = defaultAuthorityDenyToken;
          while (j < aces.length)
          {
            ACE ace = aces[j++];
            if ((ace.getAccessMask() & ACE.FILE_READ_DATA) != 0)
            {
              if (ace.isAllow())
                shareAllowAcls[allowCount++] = ace.getSID().toString();
              else
                shareDenyAcls[denyCount++] = ace.getSID().toString();
            }
          }
        }
      }
      else
      {
        shareAllowAcls = forcedShareAcls;
        if (forcedShareAcls.length == 0)
          shareDenyAcls = new String[0];
        else
          shareDenyAcls = new String[]{defaultAuthorityDenyToken};
      }
      java.util.Arrays.sort(shareAllowAcls);
      java.util.Arrays.sort(shareDenyAcls);
      // Stuff the acls into the description string.
      packList(description,shareAllowAcls,'+');
      packList(description,shareDenyAcls,'+');
    }
    else
      description.append('-');

    if (forcedacls!=null)
    {
      description.append("+");

      if (forcedacls.length==0)
      {
        aces = getFileSecurity(file);
        if (aces == null)
        {
          if (Logging.connectors.isDebugEnabled())
            Logging.connectors.debug("JCIFS: Document has no ACL for '"+getFileCanonicalPath(file)+"'");

          // Document is "public", meaning we want S-1-1-0 and the deny token
          allowAcls = new String[]{"S-1-1-0"};
          denyAcls = new String[]{defaultAuthorityDenyToken};
        }
        else
        {
          if (Logging.connectors.isDebugEnabled())
            Logging.connectors.debug("JCIFS: Found "+Integer.toString(aces.length)+" document access tokens for '"+getFileCanonicalPath(file)+"'");

          // We are interested in the read permission, and take
          // a keen interest in allow/deny
          allowCount = 0;
          denyCount = 0;
          j = 0;
          while (j < aces.length)
          {
            ACE ace = aces[j++];
            if ((ace.getAccessMask() & ACE.FILE_READ_DATA) != 0)
            {
              if (ace.isAllow())
                allowCount++;
              else
                denyCount++;
            }
          }

          allowAcls = new String[allowCount];
          denyAcls = new String[denyCount+1];
          j = 0;
          allowCount = 0;
          denyCount = 0;
          denyAcls[denyCount++] = defaultAuthorityDenyToken;
          while (j < aces.length)
          {
            ACE ace = aces[j++];
            if ((ace.getAccessMask() & ACE.FILE_READ_DATA) != 0)
            {
              if (ace.isAllow())
                allowAcls[allowCount++] = ace.getSID().toString();
              else
                denyAcls[denyCount++] = ace.getSID().toString();
            }
          }
        }
      }
      else
View Full Code Here

TOP

Related Classes of jcifs.smb.ACE

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.