Package jcifs.smb

Examples of jcifs.smb.SID


   * This tests that SmbAclBuilder correctly restores the BUILTIN domain
   * if it is missing.
   */
  public void testACLForBuiltInACE() throws IOException {
    SmbFileDelegate smbFile = createMock(SmbFileDelegate.class);
    SID sid = new SID(new SID("S-1-5-32-544"), SID.SID_TYPE_ALIAS,
                      "BUILTIN", "Administrators", false);
    ACE fileAce = createACE(sid, AclAccess.PERMIT, AceType.DIRECT);
    ACE[] fileAces = { fileAce };
    expect(smbFile.getSecurity()).andReturn(fileAces);
    expect(smbFile.getURL()).andReturn(new URL("file", "host", "file"));
View Full Code Here


        AclAccess.PERMIT, AceType.DIRECT);
    ACE unsupportedBuiltinAce = createACE(
        createSID("BUILTIN", "Batch", SID.SID_TYPE_ALIAS),
        AclAccess.PERMIT, AceType.DIRECT);
    ACE unresolvedAce = createACE(
        new SID(new SID("S-1-16-696969"), SID.SID_TYPE_ALIAS,
                null, "S-1-16-696969", false),
        AclAccess.PERMIT, AceType.DIRECT);
    ACE noReadAccessAce = createACE(
        createSID(null, "NoReading", SID.SID_TYPE_DOM_GRP),
        AclAccess.PERMIT, AceType.DIRECT,
View Full Code Here

   * @param aceInheritType if DIRECT then direct ACE, if INHERITED then
   *        inherited ACE and if INHERIT_ONLY inherit_only ACE will be created.
   */
  private ACE createACE(String userOrGroupName, AclScope aclScope,
      AclAccess aclAccess, AceType aceInheritType) {
    SID sid = createSID(null, userOrGroupName, (aclScope == AclScope.USER)
                        ? SID.SID_TYPE_USER : SID.SID_TYPE_DOM_GRP);
    return createACE(sid, aclAccess, aceInheritType);
  }   
View Full Code Here

   * @param domainName
   * @param displayString
   * @param sidType
   */
  private SID createSID(String domainName, String displayString, int sidType) {
    SID sid = createMock(SID.class);
    expect(sid.getDomainName()).andStubReturn(domainName);
    expect(sid.toDisplayString()).andStubReturn(displayString);
    expect(sid.getType()).andStubReturn(sidType);
    replay(sid);
    return sid;
  }
View Full Code Here

   * @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
View Full Code Here

   * @param groups Container for Group ACEs
   * @param finalAce ACE that needs to be added to the ACL
   */
  protected void addAceToSet(Set<Principal> users, Set<Principal> groups,
      ACE finalAce) {
    SID sid = finalAce.getSID();
    int sidType = sid.getType();
    String aclEntry = sid.toDisplayString();
    int ix = aclEntry.indexOf('\\');
    if (ix > 0) {
      String domain = aclEntry.substring(0, ix);
      String userOrGroup = aclEntry.substring(ix + 1);
      if (sidType == SID.SID_TYPE_USER) {
        aclEntry = AclFormat.formatString(userAclFormat, userOrGroup, domain);
      } else {
        aclEntry = AclFormat.formatString(groupAclFormat, userOrGroup, domain);
      }
    }
    switch (sidType) {
      case SID.SID_TYPE_USER:
        // TODO: I don't think SID supports local users, so assume global.
        users.add(new Principal(userAclFormat.getPrincipalType(),
                globalNamespace, aclEntry,
                CaseSensitivityType.EVERYTHING_CASE_INSENSITIVE));
        break;
      case SID.SID_TYPE_DOM_GRP:
      case SID.SID_TYPE_DOMAIN:
        groups.add(new Principal(groupAclFormat.getPrincipalType(),
                globalNamespace, aclEntry,
                CaseSensitivityType.EVERYTHING_CASE_INSENSITIVE));
        break;
      case SID.SID_TYPE_ALIAS:
      case SID.SID_TYPE_WKN_GRP:
        if (ix < 0 && !Strings.isNullOrEmpty(sid.getDomainName())) {
          aclEntry = AclFormat.formatString(groupAclFormat, aclEntry,
                                            sid.getDomainName());
        }
        groups.add(new Principal(groupAclFormat.getPrincipalType(),
                globalNamespace, aclEntry,
                CaseSensitivityType.EVERYTHING_CASE_INSENSITIVE));
        break;
View Full Code Here

   * @param aceDenyList List where the deny ACE needs to be added if it is a
   * valid ACE. May be null.
   */
  protected void checkAndAddAce(ACE ace, List<ACE> aceList,
      List<ACE> aceDenyList) {
    SID sid = ace.getSID();
    if (!isSupportedWindowsSid(sid)) {
      if (!isSupportedSidType(sid.getType())) {
        LOGGER.log(Level.FINEST, "Filtering unsupported ACE {0} for file {1}",
                   new Object[] { ace, file });
        return;
      }
      if (isBuiltin(sid)) {
        LOGGER.log(Level.FINEST, "Filtering BUILTIN ACE {0} for file {1}",
                   new Object[] { ace, file });
        return;
      }
    }
    String aclEntry = sid.toDisplayString();
    if (sid.toString().equals(aclEntry)) {
      LOGGER.log(Level.FINEST, "Filtering unresolved ACE {0} for file {1}",
                 new Object[] { ace, file });
      return;
    }
    if (!isReadAce(ace.getAccessMask())) {
View Full Code Here

TOP

Related Classes of jcifs.smb.SID

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.