01: /*
02: * Copyright 2007 Pentaho Corporation. All rights reserved.
03: * This software was developed by Pentaho Corporation and is provided under the terms
04: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
05: * this file except in compliance with the license. If you need a copy of the license,
06: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
07: * BI Platform. The Initial Developer is Pentaho Corporation.
08: *
09: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11: * the license for the specific language governing your rights and limitations.
12: */
13: package org.pentaho.repository.cwm;
14:
15: import java.util.ArrayList;
16: import java.util.Iterator;
17: import java.util.List;
18: import java.util.Map;
19:
20: import org.acegisecurity.GrantedAuthorityImpl;
21: import org.pentaho.pms.schema.concept.ConceptUtilityInterface;
22: import org.pentaho.pms.schema.security.Security;
23: import org.pentaho.pms.schema.security.SecurityOwner;
24:
25: import com.pentaho.security.acls.IAclHolder;
26: import com.pentaho.security.acls.PentahoAclEntry;
27:
28: public class CWMAclHolder implements IAclHolder {
29:
30: List accessControls = new ArrayList();
31:
32: public CWMAclHolder(ConceptUtilityInterface aclHolder) {
33: try {
34: Security sec = aclHolder.getSecurity();
35: if (sec != null) {
36: Map securityMap = sec.getOwnerAclMap();
37: Map.Entry entry = null;
38: SecurityOwner secOwn = null;
39: Iterator it = securityMap.entrySet().iterator();
40: while (it.hasNext()) {
41: entry = (Map.Entry) it.next();
42: // We now have the SecurityOwner and the Rights in there.
43: secOwn = (SecurityOwner) entry.getKey();
44: int rights = ((Integer) entry.getValue())
45: .intValue();
46: if (secOwn.getOwnerType() == SecurityOwner.OWNER_TYPE_USER) {
47: accessControls.add(new PentahoAclEntry(secOwn
48: .getOwnerName(), rights));
49: } else {
50: accessControls.add(new PentahoAclEntry(
51: new GrantedAuthorityImpl(secOwn
52: .getOwnerName()), rights));
53: }
54: }
55: }
56: } catch (Throwable th) {
57: // Just being paranoid here in case something doesn't support it.
58: }
59:
60: }
61:
62: public List getAccessControls() {
63: return accessControls;
64: }
65:
66: public List getEffectiveAccessControls() {
67: return accessControls;
68: }
69:
70: public void resetAccessControls(List acls) {
71: throw new UnsupportedOperationException(
72: "Cannot set CWM Acls yet"); //$NON-NLS-1$
73: }
74:
75: public void setAccessControls(List acls) {
76: throw new UnsupportedOperationException(
77: "Cannot set CWM Acls yet"); //$NON-NLS-1$
78: }
79:
80: }
|