KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > proactive > ext > security > Policy


1 /*
2 * ################################################################
3 *
4 * ProActive: The Java(TM) library for Parallel, Distributed,
5 * Concurrent computing with Security and Mobility
6 *
7 * Copyright (C) 1997-2002 INRIA/University of Nice-Sophia Antipolis
8 * Contact: proactive-support@inria.fr
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
24 *
25 * Initial developer(s): The ProActive Team
26 * http://www.inria.fr/oasis/ProActive/contacts.html
27 * Contributor(s):
28 *
29 * ################################################################
30 */

31 package org.objectweb.proactive.ext.security;
32
33 import java.io.Serializable JavaDoc;
34
35 import java.util.ArrayList JavaDoc;
36
37
38 public class Policy implements Serializable JavaDoc {
39     protected ArrayList JavaDoc from;
40     protected ArrayList JavaDoc to;
41     protected Communication communicationReply;
42     protected Communication communicationRequest;
43     protected boolean migration = false;
44     protected boolean aocreation = false;
45
46     /**
47      * Default constructor, initialize a policy with communication attribute sets to allowed and
48      * authentication,confidentiality and integrity set to optional
49      */

50     public Policy() {
51           from = new ArrayList JavaDoc();
52           from.add(new DefaultEntity());
53           to = new ArrayList JavaDoc();
54           to.add(new DefaultEntity());
55           communicationReply = new Communication();
56           communicationRequest = new Communication();
57           
58     }
59
60     /**
61      * @param object
62      */

63     public void setEntitiesFrom(ArrayList JavaDoc object) {
64         from = object;
65     }
66
67     /**
68      * @param object
69      */

70     public void setEntitiesTo(ArrayList JavaDoc object) {
71         to = object;
72     }
73
74     /**
75      * @param object
76      */

77     public void setCommunicationRulesRequest(Communication object) {
78         communicationRequest = object;
79     }
80
81     /**
82      * @param object
83      */

84     public void setCommunicationRulesReply(Communication object) {
85         communicationReply = object;
86     }
87
88     public String JavaDoc toString() {
89         String JavaDoc vnFrom;
90         String JavaDoc vnTo;
91         vnFrom = vnTo = null;
92         if (from == null) {
93             vnFrom = null;
94         } else {
95             Entity[] f = new Entity[0];
96             Entity[] eF = (Entity[]) from.toArray(f);
97             for (int i = 0; i < eF.length; i++)
98                 vnFrom = eF[i].getName() + ",";
99         }
100         if (to == null) {
101             vnTo = null;
102         } else {
103             Entity[] f = new Entity[0];
104             Entity[] eT = (Entity[]) to.toArray(f);
105             for (int i = 0; i < eT.length; i++)
106                 vnTo = eT[i].getName() + ",";
107         }
108
109         return vnFrom + "-->" + vnTo +"|| Request:" + communicationRequest + " :: Reply : " + communicationReply
110         + " || Migration :" + migration + "|| AOCreation:" + aocreation;
111     }
112
113     /**
114      * @param ArrayLists
115      */

116     public void setCommunicationRules(Communication[] arrayLists) {
117         setCommunicationRulesReply(arrayLists[0]);
118         setCommunicationRulesRequest(arrayLists[1]);
119     }
120
121     public Communication getCommunicationReply() {
122         return communicationReply;
123     }
124
125     public Communication getCommunicationRequest() {
126         return communicationRequest;
127     }
128
129     public ArrayList JavaDoc getEntitiesFrom() {
130         return from;
131     }
132
133     public ArrayList JavaDoc getEntitiesTo() {
134         return to;
135     }
136     /**
137      * @return true if object creation is authorized
138      */

139     public boolean isAocreation() {
140         return aocreation;
141     }
142
143     /**
144      * @return true if migration is authorized
145      */

146     public boolean isMigration() {
147         return migration;
148     }
149
150     /**
151      * @param b
152      */

153     public void setAocreation(boolean b) {
154         aocreation = b;
155     }
156
157     /**
158      * @param b
159      */

160     public void setMigration(boolean b) {
161         migration = b;
162     }
163
164 }
165
Popular Tags