1*b1cdbd2cSJim Jagielski/**************************************************************
2*b1cdbd2cSJim Jagielski *
3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski * or more contributor license agreements.  See the NOTICE file
5*b1cdbd2cSJim Jagielski * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski * regarding copyright ownership.  The ASF licenses this file
7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski * with the License.  You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski *
11*b1cdbd2cSJim Jagielski *   http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski *
13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski * KIND, either express or implied.  See the License for the
17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski * under the License.
19*b1cdbd2cSJim Jagielski *
20*b1cdbd2cSJim Jagielski *************************************************************/
21*b1cdbd2cSJim Jagielski
22*b1cdbd2cSJim Jagielski
23*b1cdbd2cSJim Jagielski#ifndef __com_sun_star_security_XAccessController_idl__
24*b1cdbd2cSJim Jagielski#define __com_sun_star_security_XAccessController_idl__
25*b1cdbd2cSJim Jagielski
26*b1cdbd2cSJim Jagielski#ifndef __com_sun_star_uno_XInterface_idl__
27*b1cdbd2cSJim Jagielski#include <com/sun/star/uno/XInterface.idl>
28*b1cdbd2cSJim Jagielski#endif
29*b1cdbd2cSJim Jagielski#ifndef __com_sun_star_security_XAccessControlContext_idl__
30*b1cdbd2cSJim Jagielski#include <com/sun/star/security/XAccessControlContext.idl>
31*b1cdbd2cSJim Jagielski#endif
32*b1cdbd2cSJim Jagielski
33*b1cdbd2cSJim Jagielski#ifndef __com_sun_star_security_XAction_idl__
34*b1cdbd2cSJim Jagielski#include <com/sun/star/security/XAction.idl>
35*b1cdbd2cSJim Jagielski#endif
36*b1cdbd2cSJim Jagielski
37*b1cdbd2cSJim Jagielski#ifndef __com_sun_star_security_AccessControlException_idl__
38*b1cdbd2cSJim Jagielski#include <com/sun/star/security/AccessControlException.idl>
39*b1cdbd2cSJim Jagielski#endif
40*b1cdbd2cSJim Jagielski
41*b1cdbd2cSJim Jagielski
42*b1cdbd2cSJim Jagielski//=============================================================================
43*b1cdbd2cSJim Jagielski
44*b1cdbd2cSJim Jagielskimodule com {  module sun {  module star {  module security {
45*b1cdbd2cSJim Jagielski
46*b1cdbd2cSJim Jagielski//=============================================================================
47*b1cdbd2cSJim Jagielski
48*b1cdbd2cSJim Jagielski/** Interface for checking permissions and invoking privileged or restricted
49*b1cdbd2cSJim Jagielski    actions.
50*b1cdbd2cSJim Jagielski
51*b1cdbd2cSJim Jagielski    @since OpenOffice 1.1.2
52*b1cdbd2cSJim Jagielski*/
53*b1cdbd2cSJim Jagielskipublished interface XAccessController : com::sun::star::uno::XInterface
54*b1cdbd2cSJim Jagielski{
55*b1cdbd2cSJim Jagielski	/** Determines whether the access request indicated by the specified
56*b1cdbd2cSJim Jagielski		permission should be allowed or denied, based on the security policy
57*b1cdbd2cSJim Jagielski		currently in effect.
58*b1cdbd2cSJim Jagielski        The semantics are equivalent to the security permission classes of
59*b1cdbd2cSJim Jagielski        the Java platform.
60*b1cdbd2cSJim Jagielski		<p>
61*b1cdbd2cSJim Jagielski        You can also pass a sequence of permissions (sequence< any >) to check
62*b1cdbd2cSJim Jagielski        a set of permissions, e.g. for performance reasons.
63*b1cdbd2cSJim Jagielski		This method quietly returns if the access request is permitted,
64*b1cdbd2cSJim Jagielski		or throws a suitable AccessControlException otherwise.
65*b1cdbd2cSJim Jagielski		</p>
66*b1cdbd2cSJim Jagielski
67*b1cdbd2cSJim Jagielski		@param perm
68*b1cdbd2cSJim Jagielski               permission to be checked
69*b1cdbd2cSJim Jagielski
70*b1cdbd2cSJim Jagielski		@throws AccessControlException
71*b1cdbd2cSJim Jagielski				thrown if access is denied
72*b1cdbd2cSJim Jagielski
73*b1cdbd2cSJim Jagielski        @see ::com::sun::star::security::AccessControlException
74*b1cdbd2cSJim Jagielski        @see ::com::sun::star::security::AllPermission
75*b1cdbd2cSJim Jagielski        @see ::com::sun::star::security::RuntimePermission
76*b1cdbd2cSJim Jagielski        @see ::com::sun::star::io::FilePermission
77*b1cdbd2cSJim Jagielski        @see ::com::sun::star::connection::SocketPermission
78*b1cdbd2cSJim Jagielski	*/
79*b1cdbd2cSJim Jagielski	void checkPermission(
80*b1cdbd2cSJim Jagielski        [in] any perm )
81*b1cdbd2cSJim Jagielski		raises (AccessControlException);
82*b1cdbd2cSJim Jagielski
83*b1cdbd2cSJim Jagielski	/** Perform the specified action restricting permissions to the given
84*b1cdbd2cSJim Jagielski        XAccessControlContext.
85*b1cdbd2cSJim Jagielski		The action is performed with the intersection of the permissions of the currently installed
86*b1cdbd2cSJim Jagielski        XAccessControlContext, the given XAccessControlContext and the security policy currently
87*b1cdbd2cSJim Jagielski        in effect.  The latter includes static security, e.g. based on user credentials.
88*b1cdbd2cSJim Jagielski		<p>
89*b1cdbd2cSJim Jagielski		If the specified XAccessControlContext is null, then the action is performed
90*b1cdbd2cSJim Jagielski		with unmodified permissions, i.e. the call makes no sense.
91*b1cdbd2cSJim Jagielski		</p>
92*b1cdbd2cSJim Jagielski
93*b1cdbd2cSJim Jagielski		@param action
94*b1cdbd2cSJim Jagielski			   action object to be executed
95*b1cdbd2cSJim Jagielski		@param restriction
96*b1cdbd2cSJim Jagielski			   access control context to restrict permission; null for no restriction
97*b1cdbd2cSJim Jagielski		@return
98*b1cdbd2cSJim Jagielski				result
99*b1cdbd2cSJim Jagielski		@throws com::sun::star::uno::Exception
100*b1cdbd2cSJim Jagielski				any UNO exception may be thrown
101*b1cdbd2cSJim Jagielski	*/
102*b1cdbd2cSJim Jagielski	any doRestricted(
103*b1cdbd2cSJim Jagielski		[in] XAction action,
104*b1cdbd2cSJim Jagielski		[in] XAccessControlContext restriction )
105*b1cdbd2cSJim Jagielski		raises (com::sun::star::uno::Exception);
106*b1cdbd2cSJim Jagielski
107*b1cdbd2cSJim Jagielski	/** Perform the specified action adding a set of permissions defined by the given
108*b1cdbd2cSJim Jagielski        XAccessControlContext.
109*b1cdbd2cSJim Jagielski		The action is performed with the union of the permissions of the currently installed
110*b1cdbd2cSJim Jagielski        XAccessControlContext, the given XAccessControlContext and the security policy currently
111*b1cdbd2cSJim Jagielski        in effect.  The latter includes static security, e.g. based on user credentials.
112*b1cdbd2cSJim Jagielski		<p>
113*b1cdbd2cSJim Jagielski		If the given XAccessControlContext is null, then the action is performed
114*b1cdbd2cSJim Jagielski		<b>only</b> with the permissions of the security policy currently in effect.
115*b1cdbd2cSJim Jagielski		</p>
116*b1cdbd2cSJim Jagielski
117*b1cdbd2cSJim Jagielski        @attention
118*b1cdbd2cSJim Jagielski        Do carefully use this method only for well known use-cases to avoid exploits!
119*b1cdbd2cSJim Jagielski        Script engines executing sandboxed scripts should generally deny calling this
120*b1cdbd2cSJim Jagielski        method.
121*b1cdbd2cSJim Jagielski
122*b1cdbd2cSJim Jagielski		@param action
123*b1cdbd2cSJim Jagielski			   action object to be executed
124*b1cdbd2cSJim Jagielski		@param restriction
125*b1cdbd2cSJim Jagielski			   access control context to restrict permission; null for no restriction
126*b1cdbd2cSJim Jagielski		@return
127*b1cdbd2cSJim Jagielski				result
128*b1cdbd2cSJim Jagielski		@throws com::sun::star::uno::Exception
129*b1cdbd2cSJim Jagielski				any UNO exception may be thrown
130*b1cdbd2cSJim Jagielski	*/
131*b1cdbd2cSJim Jagielski	any doPrivileged(
132*b1cdbd2cSJim Jagielski		[in] XAction action,
133*b1cdbd2cSJim Jagielski		[in] XAccessControlContext restriction )
134*b1cdbd2cSJim Jagielski		raises (com::sun::star::uno::Exception);
135*b1cdbd2cSJim Jagielski
136*b1cdbd2cSJim Jagielski	/** This method takes a "snapshot" of the current calling context
137*b1cdbd2cSJim Jagielski		and returns it.
138*b1cdbd2cSJim Jagielski		<p>
139*b1cdbd2cSJim Jagielski		This context may then be checked at a later point, possibly in another thread.
140*b1cdbd2cSJim Jagielski		</p>
141*b1cdbd2cSJim Jagielski		@return
142*b1cdbd2cSJim Jagielski				snapshot of context
143*b1cdbd2cSJim Jagielski	*/
144*b1cdbd2cSJim Jagielski	XAccessControlContext getContext();
145*b1cdbd2cSJim Jagielski};
146*b1cdbd2cSJim Jagielski
147*b1cdbd2cSJim Jagielski//=============================================================================
148*b1cdbd2cSJim Jagielski
149*b1cdbd2cSJim Jagielski}; }; }; };
150*b1cdbd2cSJim Jagielski
151*b1cdbd2cSJim Jagielski#endif
152