01: /**
02: * LibreSource
03: * Copyright (C) 2004-2008 Artenum SARL / INRIA
04: * http://www.libresource.org - contact@artenum.com
05: *
06: * This file is part of the LibreSource software,
07: * which can be used and distributed under license conditions.
08: * The license conditions are provided in the LICENSE.TXT file
09: * at the root path of the packaging that enclose this file.
10: * More information can be found at
11: * - http://dev.libresource.org/home/license
12: *
13: * Initial authors :
14: *
15: * Guillaume Bort / INRIA
16: * Francois Charoy / Universite Nancy 2
17: * Julien Forest / Artenum
18: * Claude Godart / Universite Henry Poincare
19: * Florent Jouille / INRIA
20: * Sebastien Jourdain / INRIA / Artenum
21: * Yves Lerumeur / Artenum
22: * Pascal Molli / Universite Henry Poincare
23: * Gerald Oster / INRIA
24: * Mariarosa Penzi / Artenum
25: * Gerard Sookahet / Artenum
26: * Raphael Tani / INRIA
27: *
28: * Contributors :
29: *
30: * Stephane Bagnier / Artenum
31: * Amadou Dia / Artenum-IUP Blois
32: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33: */package org.libresource.kernel.ejb.model;
34:
35: import java.io.Serializable;
36:
37: import java.net.URI;
38:
39: import java.util.Arrays;
40: import java.util.List;
41:
42: public class AclValue implements Serializable {
43: private URI owner;
44: private String[] permissions;
45: private List permissionsList;
46:
47: public AclValue(URI owner, String[] permissions) {
48: this .owner = owner;
49: this .permissions = permissions;
50: this .permissionsList = Arrays.asList(permissions);
51: }
52:
53: public URI getOwnerUri() {
54: return owner;
55: }
56:
57: public String[] getPermissions() {
58: return permissions;
59: }
60:
61: public void setOwnerUri(URI uri) {
62: this .owner = uri;
63: }
64:
65: public boolean equals(Object o) {
66: if (!(o instanceof AclValue)) {
67: return false;
68: }
69:
70: AclValue acl = (AclValue) o;
71:
72: if (acl.getPermissions().length != getPermissions().length) {
73: return false;
74: }
75:
76: if (!acl.getOwnerUri().equals(getOwnerUri())) {
77: return false;
78: }
79:
80: for (int i = 0; i < acl.getPermissions().length; i++) {
81: if (!permissionsList.contains(acl.getPermissions()[i])) {
82: return false;
83: }
84: }
85:
86: return true;
87: }
88: }
|