@Override public boolean isSidLoaded(List<Sid> sids) { // If loadedSides is null, this indicates all SIDs were loaded // Also return true if the caller didn't specify a SID to find if ((this.loadedSids == null) || (sids == null) || (sids.size() == 0)) { return true; } // This ACL applies to a SID subset only. Iterate to check it applies. for (Sid sid : sids) { boolean found = false; for (Sid loadedSid : loadedSids) { if (sid.equals(loadedSid)) { // this SID is OK found = true; break; // out of loadedSids for loop } } if (!found) { return false; } } return true; }
@Override public int hashCode() { int result = this.acl.hashCode(); result = 31 * result + this.permission.hashCode(); result = 31 * result + (this.id != null ? this.id.hashCode() : 0); result = 31 * result + this.sid.hashCode(); result = 31 * result + (this.auditFailure ? 1 : 0); result = 31 * result + (this.auditSuccess ? 1 : 0); result = 31 * result + (this.granting ? 1 : 0); return result; }
if ((this.owner == null && rhs.owner == null) || (this.owner != null && this.owner .equals(rhs.owner))) { if (this.entriesInheriting == rhs.entriesInheriting) { if ((this.loadedSids == null && rhs.loadedSids == null)) { .size())) { for (int i = 0; i < this.loadedSids.size(); i++) { if (!this.loadedSids.get(i).equals( rhs.loadedSids.get(i))) { return false;
@Override public int hashCode() { int result = this.parentAcl != null ? this.parentAcl.hashCode() : 0; result = 31 * result + this.aclAuthorizationStrategy.hashCode(); result = 31 * result + (this.permissionGrantingStrategy != null ? this.permissionGrantingStrategy.hashCode() : 0); result = 31 * result + (this.aces != null ? this.aces.hashCode() : 0); result = 31 * result + this.objectIdentity.hashCode(); result = 31 * result + this.id.hashCode(); result = 31 * result + (this.owner != null ? this.owner.hashCode() : 0); result = 31 * result + (this.loadedSids != null ? this.loadedSids.hashCode() : 0); result = 31 * result + (this.entriesInheriting ? 1 : 0); return result; }
@Test public void testGrantedAuthoritySidEquals() throws Exception { GrantedAuthority ga = new SimpleGrantedAuthority("ROLE_TEST"); Sid gaSid = new GrantedAuthoritySid(ga); assertThat(gaSid.equals(null)).isFalse(); assertThat(gaSid.equals("DIFFERENT_TYPE_OBJECT")).isFalse(); assertThat(gaSid.equals(gaSid)).isTrue(); assertThat(gaSid.equals(new GrantedAuthoritySid(ga))).isTrue(); assertThat(gaSid.equals(new GrantedAuthoritySid( new SimpleGrantedAuthority("ROLE_TEST")))).isTrue(); assertThat(gaSid.equals(new GrantedAuthoritySid( new SimpleGrantedAuthority("ROLE_NOT_EQUAL")))).isFalse(); assertThat(gaSid.equals(new GrantedAuthoritySid("ROLE_TEST"))).isTrue(); assertThat(gaSid.equals(new GrantedAuthoritySid("ROLE_NOT_EQUAL"))).isFalse(); }
@Test public void testGrantedAuthoritySidHashCode() throws Exception { GrantedAuthority ga = new SimpleGrantedAuthority("ROLE_TEST"); Sid gaSid = new GrantedAuthoritySid(ga); assertThat(gaSid.hashCode()).isEqualTo("ROLE_TEST".hashCode()); assertThat(gaSid.hashCode()).isEqualTo( new GrantedAuthoritySid("ROLE_TEST").hashCode()); assertThat(gaSid.hashCode()).isNotEqualTo( new GrantedAuthoritySid("ROLE_TEST_2").hashCode()); assertThat(gaSid.hashCode()).isNotEqualTo(new GrantedAuthoritySid( new SimpleGrantedAuthority("ROLE_TEST_2")).hashCode()); }
if (currentUser.equals(acl.getOwner()) && ((changeType == CHANGE_GENERAL) || (changeType == CHANGE_OWNERSHIP))) { return;
@Test public void testPrincipalSidHashCode() throws Exception { Authentication authentication = new TestingAuthenticationToken("johndoe", "password"); Sid principalSid = new PrincipalSid(authentication); assertThat(principalSid.hashCode()).isEqualTo("johndoe".hashCode()); assertThat(principalSid.hashCode()).isEqualTo( new PrincipalSid("johndoe").hashCode()); assertThat(principalSid.hashCode()).isNotEqualTo( new PrincipalSid("scott").hashCode()); assertThat(principalSid.hashCode()).isNotEqualTo(new PrincipalSid( new TestingAuthenticationToken("scott", "password")).hashCode()); }
@Test public void testPrincipalSidEquals() throws Exception { Authentication authentication = new TestingAuthenticationToken("johndoe", "password"); Sid principalSid = new PrincipalSid(authentication); assertThat(principalSid.equals(null)).isFalse(); assertThat(principalSid.equals("DIFFERENT_TYPE_OBJECT")).isFalse(); assertThat(principalSid.equals(principalSid)).isTrue(); assertThat(principalSid.equals(new PrincipalSid(authentication))).isTrue(); assertThat(principalSid.equals(new PrincipalSid( new TestingAuthenticationToken("johndoe", null)))).isTrue(); assertThat(principalSid.equals(new PrincipalSid( new TestingAuthenticationToken("scott", null)))).isFalse(); assertThat(principalSid.equals(new PrincipalSid("johndoe"))).isTrue(); assertThat(principalSid.equals(new PrincipalSid("scott"))).isFalse(); }
@Override public int hashCode() { int result = id != null ? id.hashCode() : 0; result = 31 * result + (permission != null ? permission.hashCode() : 0); result = 31 * result + (sid != null ? sid.hashCode() : 0); result = 31 * result + (granting ? 1 : 0); result = 31 * result + (auditFailure ? 1 : 0); result = 31 * result + (auditSuccess ? 1 : 0); return result; }
/** * Protect admin permission granted to acl owner. */ private void secureOwner(MutableAclRecord acl, Sid sid) { Message msg = MsgPicker.getMsg(); AclRecord record = acl.getAclRecord(); if (record.getOwner().equals(sid) == false) return; // prevent changing owner's admin permission if (BasePermission.ADMINISTRATION.equals(record.getPermission(sid))) throw new ForbiddenException(msg.getREVOKE_ADMIN_PERMISSION()); }
@Override public int hashCode() { int result = this.acl.hashCode(); result = 31 * result + this.permission.hashCode(); result = 31 * result + (this.id != null ? this.id.hashCode() : 0); result = 31 * result + this.sid.hashCode(); result = 31 * result + (this.auditFailure ? 1 : 0); result = 31 * result + (this.auditSuccess ? 1 : 0); result = 31 * result + (this.granting ? 1 : 0); return result; }
|| (this.granting != rhs.isGranting()) || !this.permission.equals(rhs.getPermission()) || !this.sid.equals(rhs.getSid())) { return false;
@Override public int hashCode() { int result = parentAcl != null ? parentAcl.hashCode() : 0; result = 31 * result + (aces != null ? aces.hashCode() : 0); result = 31 * result + (objectIdentity != null ? objectIdentity.hashCode() : 0); result = 31 * result + (id != null ? id.hashCode() : 0); result = 31 * result + (owner != null ? owner.hashCode() : 0); result = 31 * result + (loadedSids != null ? loadedSids.hashCode() : 0); result = 31 * result + (entriesInheriting ? 1 : 0); return result; }
&& ace.getSid().equals(sid)) {
@Override public int hashCode() { int result = entries != null ? entries.hashCode() : 0; result = 31 * result + (objectIdentity != null ? objectIdentity.hashCode() : 0); result = 31 * result + (owner != null ? owner.hashCode() : 0); result = 31 * result + (parentAclData != null ? parentAclData.hashCode() : 0); result = 31 * result + (entriesInheriting ? 1 : 0); return result; }
@Override protected Boolean hasPermission(Sid p, Permission permission) { for (; permission != null; permission = permission.impliedBy) { for (Entry e : entries) { if (e.permission == permission && e.sid.equals(p)) { return e.allowed; } } } return null; } private static final Logger LOGGER = Logger.getLogger(SparseACL.class.getName());
@Override public int hashCode() { int result = this.parentAcl != null ? this.parentAcl.hashCode() : 0; result = 31 * result + this.aclAuthorizationStrategy.hashCode(); result = 31 * result + (this.permissionGrantingStrategy != null ? this.permissionGrantingStrategy.hashCode() : 0); result = 31 * result + (this.aces != null ? this.aces.hashCode() : 0); result = 31 * result + this.objectIdentity.hashCode(); result = 31 * result + this.id.hashCode(); result = 31 * result + (this.owner != null ? this.owner.hashCode() : 0); result = 31 * result + (this.loadedSids != null ? this.loadedSids.hashCode() : 0); result = 31 * result + (this.entriesInheriting ? 1 : 0); return result; }
public static boolean isSidLoaded(List<Sid> loadedSids, List<Sid> sids) { // If loadedSides is null, this indicates all SIDs were loaded // Also return true if the caller didn't specify a SID to find if ((loadedSids == null) || (sids == null) || (sids.size() == 0)) { return true; } // This ACL applies to a SID subset only. Iterate to check it applies. for (Sid sid: sids) { boolean found = false; for (Sid loadedSid : loadedSids) { if (sid.equals(loadedSid)) { // this SID is OK found = true; break; // out of loadedSids for loop } } if (!found) { return false; } } return true; }
@Override public boolean isSidLoaded(List<Sid> sids) { // If loadedSides is null, this indicates all SIDs were loaded // Also return true if the caller didn't specify a SID to find if ((this.loadedSids == null) || (sids == null) || (sids.size() == 0)) { return true; } // This ACL applies to a SID subset only. Iterate to check it applies. for (Sid sid : sids) { boolean found = false; for (Sid loadedSid : loadedSids) { if (sid.equals(loadedSid)) { // this SID is OK found = true; break; // out of loadedSids for loop } } if (!found) { return false; } } return true; }