KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > bluecubs > xinco > core > client > XincoCoreACEClient


1 /**
2  *Copyright 2004 blueCubs.com
3  *
4  *Licensed under the Apache License, Version 2.0 (the "License");
5  *you may not use this file except in compliance with the License.
6  *You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *Unless required by applicable law or agreed to in writing, software
11  *distributed under the License is distributed on an "AS IS" BASIS,
12  *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *See the License for the specific language governing permissions and
14  *limitations under the License.
15  *
16  *************************************************************
17  * This project supports the blueCubs vision of giving back
18  * to the community in exchange for free software!
19  * More information on: http://www.bluecubs.org
20  *************************************************************
21  *
22  * Name: XincoCoreACEClient
23  *
24  * Description: access control entry
25  *
26  * Original Author: Alexander Manes
27  * Date: 2004
28  *
29  * Modifications:
30  *
31  * Who? When? What?
32  * - - -
33  *
34  *************************************************************
35  */

36
37 package com.bluecubs.xinco.core.client;
38
39 import java.util.Vector JavaDoc;
40
41 import com.bluecubs.xinco.core.*;
42
43 public class XincoCoreACEClient extends XincoCoreACE {
44
45     public XincoCoreACEClient() throws XincoException {
46     }
47     
48     //check access by comparing user / user groups to ACL and return permissions
49
public static XincoCoreACE checkAccess(XincoCoreUser attrU, Vector JavaDoc attrACL) {
50         
51         int i = 0;
52         int j = 0;
53         boolean match_ace = false;
54         XincoCoreACE core_ace = new XincoCoreACE();
55         
56         for (i=0;i<attrACL.size();i++) {
57             //reset match_ace
58
match_ace = false;
59             //check if user is mentioned in ACE
60
if (((XincoCoreACE)attrACL.elementAt(i)).getXinco_core_user_id() == attrU.getId()) { match_ace = true; }
61             //check if group of user is mentioned in ACE
62
if (!match_ace) {
63                 for (j=0;j<attrU.getXinco_core_groups().size();j++) {
64                     if (((XincoCoreACE)attrACL.elementAt(i)).getXinco_core_group_id() == ((XincoCoreGroup)attrU.getXinco_core_groups().elementAt(j)).getId()) {
65                         match_ace = true;
66                         break;
67                     }
68                 }
69             }
70             //add to rights
71
if (match_ace) {
72                 //modify read permission
73
if (!core_ace.isRead_permission()) {
74                     core_ace.setRead_permission(((XincoCoreACE)attrACL.elementAt(i)).isRead_permission());
75                 }
76                 //modify write permission
77
if (!core_ace.isWrite_permission()) {
78                     core_ace.setWrite_permission(((XincoCoreACE)attrACL.elementAt(i)).isWrite_permission());
79                 }
80                 //modify execute permission
81
if (!core_ace.isExecute_permission()) {
82                     core_ace.setExecute_permission(((XincoCoreACE)attrACL.elementAt(i)).isExecute_permission());
83                 }
84                 //modify admin permission
85
if (!core_ace.isAdmin_permission()) {
86                     core_ace.setAdmin_permission(((XincoCoreACE)attrACL.elementAt(i)).isAdmin_permission());
87                 }
88             }
89         }
90         
91         return core_ace;
92     }
93
94 }
95
Popular Tags