Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : :
21 : : #include <boost/unordered_map.hpp>
22 : :
23 : : #include <osl/diagnose.h>
24 : : #include <osl/file.h>
25 : : #include <rtl/byteseq.hxx>
26 : : #include <rtl/string.hxx>
27 : : #include <rtl/ustrbuf.hxx>
28 : :
29 : : #include <cppuhelper/access_control.hxx>
30 : : #include <cppuhelper/compbase2.hxx>
31 : : #include <cppuhelper/implementationentry.hxx>
32 : :
33 : : #include <com/sun/star/lang/XServiceInfo.hpp>
34 : : #include <com/sun/star/security/XAccessController.hpp>
35 : : #include <com/sun/star/security/XPolicy.hpp>
36 : : #include <com/sun/star/security/AllPermission.hpp>
37 : : #include <com/sun/star/security/RuntimePermission.hpp>
38 : : #include <com/sun/star/io/FilePermission.hpp>
39 : : #include <com/sun/star/connection/SocketPermission.hpp>
40 : :
41 : : #include "bootstrapservices.hxx"
42 : :
43 : : #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
44 : : #define SERVICE_NAME "com.sun.star.security.Policy"
45 : : #define IMPL_NAME "com.sun.star.security.comp.stoc.FilePolicy"
46 : :
47 : : using namespace ::osl;
48 : : using namespace ::rtl;
49 : : using namespace ::cppu;
50 : : using namespace ::com::sun::star;
51 : : using namespace ::com::sun::star::uno;
52 : :
53 : : extern ::rtl_StandardModuleCount g_moduleCount;
54 : :
55 : : namespace stoc_sec
56 : : {
57 : : //--------------------------------------------------------------------------------------------------
58 : : static inline void dispose( Reference< XInterface > const & x )
59 : : SAL_THROW( (RuntimeException) )
60 : : {
61 : : Reference< lang::XComponent > xComp( x, UNO_QUERY );
62 : : if (xComp.is())
63 : : {
64 : : xComp->dispose();
65 : : }
66 : : }
67 : :
68 : : //##################################################################################################
69 : :
70 : 0 : struct MutexHolder
71 : : {
72 : : Mutex m_mutex;
73 : : };
74 : : typedef WeakComponentImplHelper2< security::XPolicy, lang::XServiceInfo > t_helper;
75 : :
76 : : //==================================================================================================
77 : : class FilePolicy
78 : : : public MutexHolder
79 : : , public t_helper
80 : : {
81 : : Reference< XComponentContext > m_xComponentContext;
82 : : AccessControl m_ac;
83 : :
84 : : Sequence< Any > m_defaultPermissions;
85 : : typedef boost::unordered_map< OUString, Sequence< Any >, OUStringHash > t_permissions;
86 : : t_permissions m_userPermissions;
87 : : bool m_init;
88 : :
89 : : protected:
90 : : virtual void SAL_CALL disposing();
91 : :
92 : : public:
93 : : FilePolicy( Reference< XComponentContext > const & xComponentContext )
94 : : SAL_THROW(());
95 : : virtual ~FilePolicy()
96 : : SAL_THROW(());
97 : :
98 : : // XPolicy impl
99 : : virtual Sequence< Any > SAL_CALL getPermissions(
100 : : OUString const & userId )
101 : : throw (RuntimeException);
102 : : virtual Sequence< Any > SAL_CALL getDefaultPermissions()
103 : : throw (RuntimeException);
104 : : virtual void SAL_CALL refresh()
105 : : throw (RuntimeException);
106 : :
107 : : // XServiceInfo impl
108 : : virtual OUString SAL_CALL getImplementationName()
109 : : throw (RuntimeException);
110 : : virtual sal_Bool SAL_CALL supportsService( OUString const & serviceName )
111 : : throw (RuntimeException);
112 : : virtual Sequence< OUString > SAL_CALL getSupportedServiceNames()
113 : : throw (RuntimeException);
114 : : };
115 : : //__________________________________________________________________________________________________
116 : 0 : FilePolicy::FilePolicy( Reference< XComponentContext > const & xComponentContext )
117 : : SAL_THROW(())
118 : : : t_helper( m_mutex )
119 : : , m_xComponentContext( xComponentContext )
120 : : , m_ac( xComponentContext )
121 [ # # ][ # # ]: 0 : , m_init( false )
[ # # ]
122 : : {
123 [ # # ]: 0 : g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt );
124 : 0 : }
125 : : //__________________________________________________________________________________________________
126 [ # # ][ # # ]: 0 : FilePolicy::~FilePolicy()
[ # # ][ # # ]
127 : : SAL_THROW(())
128 : : {
129 [ # # ]: 0 : g_moduleCount.modCnt.release( &g_moduleCount.modCnt );
130 [ # # ]: 0 : }
131 : : //__________________________________________________________________________________________________
132 : 0 : void FilePolicy::disposing()
133 : : {
134 : 0 : m_userPermissions.clear();
135 [ # # ]: 0 : m_defaultPermissions = Sequence< Any >();
136 : 0 : m_xComponentContext.clear();
137 : 0 : }
138 : :
139 : : //__________________________________________________________________________________________________
140 : 0 : Sequence< Any > FilePolicy::getPermissions(
141 : : OUString const & userId )
142 : : throw (RuntimeException)
143 : : {
144 [ # # ]: 0 : if (! m_init)
145 : : {
146 [ # # ]: 0 : refresh();
147 : 0 : m_init = true;
148 : : }
149 : :
150 [ # # ]: 0 : MutexGuard guard( m_mutex );
151 [ # # ]: 0 : t_permissions::iterator iFind( m_userPermissions.find( userId ) );
152 [ # # ][ # # ]: 0 : if (m_userPermissions.end() == iFind)
153 : : {
154 [ # # ]: 0 : return Sequence< Any >();
155 : : }
156 : : else
157 : : {
158 [ # # ][ # # ]: 0 : return iFind->second;
159 [ # # ]: 0 : }
160 : : }
161 : : //__________________________________________________________________________________________________
162 : 0 : Sequence< Any > FilePolicy::getDefaultPermissions()
163 : : throw (RuntimeException)
164 : : {
165 [ # # ]: 0 : if (! m_init)
166 : : {
167 [ # # ]: 0 : refresh();
168 : 0 : m_init = true;
169 : : }
170 : :
171 [ # # ]: 0 : MutexGuard guard( m_mutex );
172 [ # # ][ # # ]: 0 : return m_defaultPermissions;
173 : : }
174 : :
175 : : //==================================================================================================
176 : : class PolicyReader
177 : : {
178 : : OUString m_fileName;
179 : : oslFileHandle m_file;
180 : :
181 : : sal_Int32 m_linepos;
182 : : ByteSequence m_line;
183 : : sal_Int32 m_pos;
184 : : sal_Unicode m_back;
185 : :
186 : : sal_Unicode get()
187 : : SAL_THROW( (RuntimeException) );
188 : 0 : inline void back( sal_Unicode c ) SAL_THROW(())
189 : 0 : { m_back = c; }
190 : :
191 : 0 : inline bool isWhiteSpace( sal_Unicode c ) const SAL_THROW(())
192 [ # # ][ # # ]: 0 : { return (' ' == c || '\t' == c || '\n' == c || '\r' == c); }
[ # # ][ # # ]
193 : : void skipWhiteSpace()
194 : : SAL_THROW( (RuntimeException) );
195 : :
196 : 0 : inline bool isCharToken( sal_Unicode c ) const SAL_THROW(())
197 [ # # ][ # # ]: 0 : { return (';' == c || ',' == c || '{' == c || '}' == c); }
[ # # ][ # # ]
198 : :
199 : : public:
200 : : PolicyReader( OUString const & file, AccessControl & ac )
201 : : SAL_THROW( (RuntimeException) );
202 : : ~PolicyReader()
203 : : SAL_THROW(());
204 : :
205 : : void error( OUString const & msg )
206 : : SAL_THROW( (RuntimeException) );
207 : :
208 : : OUString getToken()
209 : : SAL_THROW( (RuntimeException) );
210 : : OUString assureToken()
211 : : SAL_THROW( (RuntimeException) );
212 : : OUString getQuotedToken()
213 : : SAL_THROW( (RuntimeException) );
214 : : OUString assureQuotedToken()
215 : : SAL_THROW( (RuntimeException) );
216 : : void assureToken( sal_Unicode token )
217 : : SAL_THROW( (RuntimeException) );
218 : : };
219 : : //__________________________________________________________________________________________________
220 : 0 : void PolicyReader::assureToken( sal_Unicode token )
221 : : SAL_THROW( (RuntimeException) )
222 : : {
223 [ # # ]: 0 : skipWhiteSpace();
224 [ # # ]: 0 : sal_Unicode c = get();
225 [ # # ]: 0 : if (c == token)
226 : 0 : return;
227 : 0 : OUStringBuffer buf( 16 );
228 [ # # ]: 0 : buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("expected >") );
229 [ # # ]: 0 : buf.append( c );
230 [ # # ]: 0 : buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("<!") );
231 [ # # ][ # # ]: 0 : error( buf.makeStringAndClear() );
232 : : }
233 : : //__________________________________________________________________________________________________
234 : 0 : OUString PolicyReader::assureQuotedToken()
235 : : SAL_THROW( (RuntimeException) )
236 : : {
237 : 0 : OUString token( getQuotedToken() );
238 [ # # ]: 0 : if (token.isEmpty())
239 [ # # ][ # # ]: 0 : error( OUSTR("unexpected end of file!") );
240 : 0 : return token;
241 : : }
242 : : //__________________________________________________________________________________________________
243 : 0 : OUString PolicyReader::getQuotedToken()
244 : : SAL_THROW( (RuntimeException) )
245 : : {
246 [ # # ]: 0 : skipWhiteSpace();
247 : 0 : OUStringBuffer buf( 32 );
248 [ # # ]: 0 : sal_Unicode c = get();
249 [ # # ]: 0 : if ('\"' != c)
250 [ # # ][ # # ]: 0 : error( OUSTR("expected quoting >\"< character!") );
251 [ # # ]: 0 : c = get();
252 [ # # ][ # # ]: 0 : while ('\0' != c && '\"' != c)
[ # # ]
253 : : {
254 [ # # ]: 0 : buf.append( c );
255 [ # # ]: 0 : c = get();
256 : : }
257 [ # # ]: 0 : return buf.makeStringAndClear();
258 : : }
259 : : //__________________________________________________________________________________________________
260 : 0 : OUString PolicyReader::assureToken()
261 : : SAL_THROW( (RuntimeException) )
262 : : {
263 : 0 : OUString token( getToken() );
264 [ # # ]: 0 : if ( token.isEmpty())
265 [ # # ][ # # ]: 0 : error( OUSTR("unexpected end of file!") );
266 : 0 : return token;
267 : : }
268 : : //__________________________________________________________________________________________________
269 : 0 : OUString PolicyReader::getToken()
270 : : SAL_THROW( (RuntimeException) )
271 : : {
272 [ # # ]: 0 : skipWhiteSpace();
273 [ # # ]: 0 : sal_Unicode c = get();
274 [ # # ]: 0 : if (isCharToken( c ))
275 : 0 : return OUString( &c, 1 );
276 : 0 : OUStringBuffer buf( 32 );
277 [ # # ][ # # ]: 0 : while ('\0' != c && !isCharToken( c ) && !isWhiteSpace( c ))
[ # # ][ # # ]
278 : : {
279 [ # # ]: 0 : buf.append( c );
280 [ # # ]: 0 : c = get();
281 : : }
282 : 0 : back( c );
283 [ # # ]: 0 : return buf.makeStringAndClear();
284 : : }
285 : : //__________________________________________________________________________________________________
286 : 0 : void PolicyReader::skipWhiteSpace()
287 : : SAL_THROW( (RuntimeException) )
288 : : {
289 : : sal_Unicode c;
290 [ # # ]: 0 : do
291 : : {
292 : 0 : c = get();
293 : : }
294 : 0 : while (isWhiteSpace( c )); // seeking next non-whitespace char
295 : :
296 [ # # ]: 0 : if ('/' == c) // C/C++ like comment
297 : : {
298 : 0 : c = get();
299 [ # # ]: 0 : if ('/' == c) // C++ like comment
300 : : {
301 [ # # ][ # # ]: 0 : do
[ # # ]
302 : : {
303 : 0 : c = get();
304 : : }
305 : : while ('\n' != c && '\0' != c); // seek eol/eof
306 : 0 : skipWhiteSpace(); // cont skip on next line
307 : : }
308 [ # # ]: 0 : else if ('*' == c) // C like comment
309 : : {
310 : 0 : bool fini = true;
311 [ # # ]: 0 : do
312 : : {
313 : 0 : c = get();
314 [ # # ]: 0 : if ('*' == c)
315 : : {
316 : 0 : c = get();
317 [ # # ][ # # ]: 0 : fini = ('/' == c || '\0' == c);
318 : : }
319 : : else
320 : : {
321 : 0 : fini = ('\0' == c);
322 : : }
323 : : }
324 : 0 : while (! fini);
325 : 0 : skipWhiteSpace(); // cont skip on next line
326 : : }
327 : : else
328 : : {
329 [ # # ]: 0 : error( OUSTR("expected C/C++ like comment!") );
330 : : }
331 : : }
332 [ # # ]: 0 : else if ('#' == c) // script like comment
333 : : {
334 [ # # ][ # # ]: 0 : do
[ # # ]
335 : : {
336 : 0 : c = get();
337 : : }
338 : : while ('\n' != c && '\0' != c); // seek eol/eof
339 : 0 : skipWhiteSpace(); // cont skip on next line
340 : : }
341 : :
342 : : else // is token char
343 : : {
344 : 0 : back( c );
345 : : }
346 : 0 : }
347 : : //__________________________________________________________________________________________________
348 : 0 : sal_Unicode PolicyReader::get()
349 : : SAL_THROW( (RuntimeException) )
350 : : {
351 [ # # ]: 0 : if ('\0' != m_back) // one char push back possible
352 : : {
353 : 0 : sal_Unicode c = m_back;
354 : 0 : m_back = '\0';
355 : 0 : return c;
356 : : }
357 [ # # ]: 0 : else if (m_pos == m_line.getLength()) // provide newline as whitespace
358 : : {
359 : 0 : ++m_pos;
360 : 0 : return '\n';
361 : : }
362 [ # # ]: 0 : else if (m_pos > m_line.getLength()) // read new line
363 : : {
364 : : sal_Bool eof;
365 [ # # ]: 0 : oslFileError rc = ::osl_isEndOfFile( m_file, &eof );
366 [ # # ]: 0 : if (osl_File_E_None != rc)
367 [ # # ][ # # ]: 0 : error( OUSTR("checking eof failed!") );
368 [ # # ]: 0 : if (eof)
369 : 0 : return '\0';
370 : :
371 [ # # ]: 0 : rc = ::osl_readLine( m_file, reinterpret_cast< sal_Sequence ** >( &m_line ) );
372 [ # # ]: 0 : if (osl_File_E_None != rc)
373 [ # # ][ # # ]: 0 : error( OUSTR("read line failed!") );
374 : 0 : ++m_linepos;
375 [ # # ]: 0 : if (! m_line.getLength()) // empty line read
376 : : {
377 : 0 : m_pos = 1; // read new line next time
378 : 0 : return '\n';
379 : : }
380 : 0 : m_pos = 0;
381 : : }
382 : 0 : return (m_line.getConstArray()[ m_pos++ ]);
383 : : }
384 : : //__________________________________________________________________________________________________
385 : 0 : void PolicyReader::error( OUString const & msg )
386 : : SAL_THROW( (RuntimeException) )
387 : : {
388 : 0 : OUStringBuffer buf( 32 );
389 [ # # ]: 0 : buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("error processing file \"") );
390 [ # # ]: 0 : buf.append( m_fileName );
391 [ # # ]: 0 : buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("\" [line ") );
392 [ # # ]: 0 : buf.append( m_linepos );
393 [ # # ]: 0 : buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(", column ") );
394 [ # # ]: 0 : buf.append( m_pos );
395 [ # # ]: 0 : buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("] ") );
396 [ # # ]: 0 : buf.append( msg );
397 [ # # ][ # # ]: 0 : throw RuntimeException( buf.makeStringAndClear(), Reference< XInterface >() );
398 : : }
399 : : //__________________________________________________________________________________________________
400 : 0 : PolicyReader::PolicyReader( OUString const & fileName, AccessControl & ac )
401 : : SAL_THROW( (RuntimeException) )
402 : : : m_fileName( fileName )
403 : : , m_linepos( 0 )
404 : : , m_pos( 1 ) // force readline
405 : 0 : , m_back( '\0' )
406 : : {
407 [ # # ][ # # ]: 0 : ac.checkFilePermission( m_fileName, OUSTR("read") );
408 [ # # ][ # # ]: 0 : if (osl_File_E_None != ::osl_openFile( m_fileName.pData, &m_file, osl_File_OpenFlag_Read ))
409 : : {
410 : 0 : OUStringBuffer buf( 32 );
411 [ # # ]: 0 : buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("cannot open file \"") );
412 [ # # ]: 0 : buf.append( m_fileName );
413 [ # # ]: 0 : buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("\"!") );
414 [ # # ][ # # ]: 0 : throw RuntimeException( buf.makeStringAndClear(), Reference< XInterface >() );
415 : : }
416 : 0 : }
417 : : //__________________________________________________________________________________________________
418 : 0 : PolicyReader::~PolicyReader()
419 : : SAL_THROW(())
420 : : {
421 [ # # ]: 0 : if ( ::osl_closeFile( m_file ) != osl_File_E_None ) {
422 : : OSL_ASSERT( false );
423 : : }
424 : 0 : }
425 : :
426 : : #define s_grant "grant"
427 : : #define s_user "user"
428 : : #define s_permission "permission"
429 : : #define s_openBrace "{"
430 : : #define s_closingBrace "}"
431 : :
432 : : #define s_filePermission "com.sun.star.io.FilePermission"
433 : : #define s_socketPermission "com.sun.star.connection.SocketPermission"
434 : : #define s_runtimePermission "com.sun.star.security.RuntimePermission"
435 : : #define s_allPermission "com.sun.star.security.AllPermission"
436 : :
437 : : //__________________________________________________________________________________________________
438 : 0 : void FilePolicy::refresh()
439 : : throw (RuntimeException)
440 : : {
441 : : // read out file
442 : 0 : OUString fileName;
443 [ # # ]: 0 : m_xComponentContext->getValueByName(
444 [ # # ][ # # ]: 0 : OUSTR("/implementations/" IMPL_NAME "/file-name") ) >>= fileName;
445 [ # # ]: 0 : if ( fileName.isEmpty() )
446 : : {
447 : : throw RuntimeException(
448 : : OUSTR("name of policy file unknown!"),
449 [ # # ][ # # ]: 0 : (OWeakObject *)this );
[ # # ]
450 : : }
451 : :
452 [ # # ]: 0 : PolicyReader reader( fileName, m_ac );
453 : :
454 : : // fill these two
455 [ # # ]: 0 : Sequence< Any > defaultPermissions;
456 [ # # ]: 0 : t_permissions userPermissions;
457 : :
458 [ # # ]: 0 : OUString token( reader.getToken() );
459 [ # # ]: 0 : while (!token.isEmpty())
460 : : {
461 [ # # ]: 0 : if ( token != s_grant )
462 [ # # ][ # # ]: 0 : reader.error( OUSTR("expected >grant< token!") );
463 : 0 : OUString userId;
464 [ # # ]: 0 : token = reader.assureToken();
465 [ # # ]: 0 : if ( token == s_user ) // next token is user-id
466 : : {
467 [ # # ]: 0 : userId = reader.assureQuotedToken();
468 [ # # ]: 0 : token = reader.assureToken();
469 : : }
470 [ # # ]: 0 : if ( token != s_openBrace )
471 [ # # ][ # # ]: 0 : reader.error( OUSTR("expected opening brace >{<!") );
472 [ # # ]: 0 : token = reader.assureToken();
473 : : // permissions list
474 [ # # ]: 0 : while ( token != s_closingBrace )
475 : : {
476 [ # # ]: 0 : if ( token != s_permission )
477 [ # # ][ # # ]: 0 : reader.error( OUSTR("expected >permission< or closing brace >}<!") );
478 : :
479 [ # # ]: 0 : token = reader.assureToken(); // permission type
480 : 0 : Any perm;
481 [ # # ]: 0 : if ( token == s_filePermission ) // FilePermission
482 : : {
483 [ # # ]: 0 : OUString url( reader.assureQuotedToken() );
484 [ # # ]: 0 : reader.assureToken( ',' );
485 [ # # ]: 0 : OUString actions( reader.assureQuotedToken() );
486 [ # # ]: 0 : perm <<= io::FilePermission( url, actions );
487 : : }
488 [ # # ]: 0 : else if ( token == s_socketPermission ) // SocketPermission
489 : : {
490 [ # # ]: 0 : OUString host( reader.assureQuotedToken() );
491 [ # # ]: 0 : reader.assureToken( ',' );
492 [ # # ]: 0 : OUString actions( reader.assureQuotedToken() );
493 [ # # ]: 0 : perm <<= connection::SocketPermission( host, actions );
494 : : }
495 [ # # ]: 0 : else if ( token == s_runtimePermission ) // RuntimePermission
496 : : {
497 [ # # ]: 0 : OUString name( reader.assureQuotedToken() );
498 [ # # ]: 0 : perm <<= security::RuntimePermission( name );
499 : : }
500 [ # # ]: 0 : else if ( token == s_allPermission ) // AllPermission
501 : : {
502 [ # # ]: 0 : perm <<= security::AllPermission();
503 : : }
504 : : else
505 : : {
506 [ # # ][ # # ]: 0 : reader.error( OUSTR("expected permission type!") );
507 : : }
508 : :
509 [ # # ]: 0 : reader.assureToken( ';' );
510 : :
511 : : // insert
512 [ # # ]: 0 : if (!userId.isEmpty())
513 : : {
514 [ # # ][ # # ]: 0 : Sequence< Any > perms( userPermissions[ userId ] );
515 : 0 : sal_Int32 len = perms.getLength();
516 [ # # ]: 0 : perms.realloc( len +1 );
517 [ # # ]: 0 : perms[ len ] = perm;
518 [ # # ][ # # ]: 0 : userPermissions[ userId ] = perms;
[ # # ]
519 : : }
520 : : else
521 : : {
522 : 0 : sal_Int32 len = defaultPermissions.getLength();
523 [ # # ]: 0 : defaultPermissions.realloc( len +1 );
524 [ # # ]: 0 : defaultPermissions[ len ] = perm;
525 : : }
526 : :
527 [ # # ]: 0 : token = reader.assureToken(); // next permissions token
528 : 0 : }
529 : :
530 [ # # ]: 0 : reader.assureToken( ';' ); // semi
531 [ # # ]: 0 : token = reader.getToken(); // next grant token
532 : 0 : }
533 : :
534 : : // assign new ones
535 [ # # ]: 0 : MutexGuard guard( m_mutex );
536 [ # # ]: 0 : m_defaultPermissions = defaultPermissions;
537 [ # # ][ # # ]: 0 : m_userPermissions = userPermissions;
[ # # ][ # # ]
[ # # ]
538 : 0 : }
539 : :
540 : : //__________________________________________________________________________________________________
541 : 0 : OUString FilePolicy::getImplementationName()
542 : : throw (RuntimeException)
543 : : {
544 : 0 : return stoc_bootstrap::filepolicy_getImplementationName();
545 : : }
546 : : //__________________________________________________________________________________________________
547 : 0 : sal_Bool FilePolicy::supportsService( OUString const & serviceName )
548 : : throw (RuntimeException)
549 : : {
550 [ # # ]: 0 : Sequence< OUString > aSNL = getSupportedServiceNames();
551 : 0 : const OUString * pNames = aSNL.getConstArray();
552 [ # # ]: 0 : for ( sal_Int32 nPos = aSNL.getLength(); --nPos; )
553 : : {
554 [ # # ]: 0 : if (serviceName.equals( pNames[ nPos ] ))
555 : : {
556 : 0 : return sal_True;
557 : : }
558 : : }
559 [ # # ]: 0 : return sal_False;
560 : : }
561 : : //__________________________________________________________________________________________________
562 : 0 : Sequence< OUString > FilePolicy::getSupportedServiceNames()
563 : : throw (RuntimeException)
564 : : {
565 : 0 : return stoc_bootstrap::filepolicy_getSupportedServiceNames();
566 : : }
567 : : }
568 : : //##################################################################################################
569 : : namespace stoc_bootstrap
570 : : {
571 : : //--------------------------------------------------------------------------------------------------
572 : 0 : Reference< XInterface > SAL_CALL filepolicy_create(
573 : : Reference< XComponentContext > const & xComponentContext )
574 : : SAL_THROW( (Exception) )
575 : : {
576 [ # # ]: 0 : return (OWeakObject *)new stoc_sec::FilePolicy( xComponentContext );
577 : : }
578 : : //--------------------------------------------------------------------------------------------------
579 : 756 : Sequence< OUString > filepolicy_getSupportedServiceNames() SAL_THROW(())
580 : : {
581 : 756 : Sequence< OUString > aSNS( 1 );
582 [ + - ][ + - ]: 756 : aSNS.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICE_NAME));
583 : 756 : return aSNS;
584 : : }
585 : : //--------------------------------------------------------------------------------------------------
586 : 10036 : OUString filepolicy_getImplementationName() SAL_THROW(())
587 : : {
588 : 10036 : return OUSTR(IMPL_NAME);
589 : : }
590 : : }
591 : :
592 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|