jaulib v1.3.0
Jau Support Library (C++, Java, ..)
DynamicLinker.java
Go to the documentation of this file.
1/**
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright (c) 2020 Gothel Software e.K.
4 * Copyright (c) 2013 Gothel Software e.K.
5 * Copyright (c) 2013 JogAmp Community.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining
8 * a copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sublicense, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27package org.jau.sys.dl;
28
29/** Low level secure dynamic linker access. */
30public interface DynamicLinker {
31 public static final boolean DEBUG = NativeLibrary.DEBUG;
32 public static final boolean DEBUG_LOOKUP = NativeLibrary.DEBUG_LOOKUP;
33
34 /**
35 * @throws SecurityException if user is not granted global access
36 */
37 public void claimAllLinkPermission() throws SecurityException;
38
39 /**
40 * @throws SecurityException if user is not granted global access
41 */
42 public void releaseAllLinkPermission() throws SecurityException;
43
44 /**
45 * If a {@link SecurityManager} is installed, user needs link permissions
46 * for the named library.
47 * <p>
48 * Opens the named library, allowing system wide access for other <i>users</i>.
49 * </p>
50 *
51 * @param pathname the full pathname for the library to open
52 * @param debug set to true to enable debugging
53 * @return the library handle, maybe 0 if not found.
54 * @throws SecurityException if user is not granted access for the named library.
55 */
56 public long openLibraryGlobal(String pathname, boolean debug) throws SecurityException;
57
58 /**
59 * If a {@link SecurityManager} is installed, user needs link permissions
60 * for the named library.
61 * <p>
62 * Opens the named library, restricting access to this process.
63 * </p>
64 *
65 * @param pathname the full pathname for the library to open
66 * @param debug set to true to enable debugging
67 * @return the library handle, maybe 0 if not found.
68 * @throws SecurityException if user is not granted access for the named library.
69 */
70 public long openLibraryLocal(String pathname, boolean debug) throws SecurityException;
71
72 /**
73 * If a {@link SecurityManager} is installed, user needs link permissions
74 * for <b>all</b> libraries, i.e. for <code>new RuntimePermission("loadLibrary.*");</code>!
75 *
76 * @param symbolName global symbol name to lookup up system wide.
77 * @return the library handle, maybe 0 if not found.
78 * @throws SecurityException if user is not granted access for all libraries.
79 */
80 public long lookupSymbolGlobal(String symbolName) throws SecurityException;
81
82 /**
83 * Security checks are implicit by previous call of
84 * {@link #openLibraryLocal(String, boolean)} or {@link #openLibraryGlobal(String, boolean)}
85 * retrieving the <code>librarHandle</code>.
86 *
87 * @param libraryHandle a library handle previously retrieved via {@link #openLibraryLocal(String, boolean)} or {@link #openLibraryGlobal(String, boolean)}.
88 * @param symbolName global symbol name to lookup up system wide.
89 * @return the library handle, maybe 0 if not found.
90 * @throws IllegalArgumentException in case case <code>libraryHandle</code> is unknown.
91 * @throws SecurityException if user is not granted access for the given library handle
92 */
93 public long lookupSymbol(long libraryHandle, String symbolName) throws SecurityException, IllegalArgumentException;
94
95 /**
96 * Security checks are implicit by previous call of
97 * {@link #openLibraryLocal(String, boolean)} or {@link #openLibraryGlobal(String, boolean)}
98 * retrieving the <code>librarHandle</code>.
99 *
100 * @param libraryHandle a library handle previously retrieved via {@link #openLibraryLocal(String, boolean)} or {@link #openLibraryGlobal(String, boolean)}.
101 * @param debug set to true to enable debugging
102 * @throws IllegalArgumentException in case case <code>libraryHandle</code> is unknown.
103 * @throws SecurityException if user is not granted access for the given library handle
104 */
105 public void closeLibrary(long libraryHandle, boolean debug) throws SecurityException, IllegalArgumentException;
106
107 /**
108 * Returns a string containing the last error.
109 * Maybe called for debuging purposed if any method fails.
110 * @return error string, maybe null. A null or non-null value has no semantics.
111 */
112 public String getLastError();
113}
Provides low-level, relatively platform-independent access to shared ("native") libraries.
Low level secure dynamic linker access.
long lookupSymbol(long libraryHandle, String symbolName)
Security checks are implicit by previous call of openLibraryLocal(String, boolean) or openLibraryGlob...
void closeLibrary(long libraryHandle, boolean debug)
Security checks are implicit by previous call of openLibraryLocal(String, boolean) or openLibraryGlob...
static final boolean DEBUG
long openLibraryLocal(String pathname, boolean debug)
If a SecurityManager is installed, user needs link permissions for the named library.
long openLibraryGlobal(String pathname, boolean debug)
If a SecurityManager is installed, user needs link permissions for the named library.
String getLastError()
Returns a string containing the last error.
long lookupSymbolGlobal(String symbolName)
If a SecurityManager is installed, user needs link permissions for all libraries, i....
static final boolean DEBUG_LOOKUP