|
18 | 18 | */ |
19 | 19 | package org.firebirdsql.fbjava.impl; |
20 | 20 |
|
| 21 | +import java.security.AccessController; |
| 22 | +import java.security.PrivilegedActionException; |
| 23 | +import java.security.PrivilegedExceptionAction; |
21 | 24 | import java.sql.SQLException; |
22 | 25 |
|
23 | 26 | import org.firebirdsql.gds.DatabaseParameterBuffer; |
@@ -48,29 +51,43 @@ public JnaDatabase connect(IConnectionProperties connectionProperties) throws SQ |
48 | 51 |
|
49 | 52 | Main.library.fb_get_database_handle(statusVector, attachmentHandle, internalContext.getAttachment()); |
50 | 53 |
|
51 | | - JnaDatabaseConnection jnaDatabaseConnection = new JnaDatabaseConnection( |
52 | | - getClientLibrary(), connectionProperties) |
| 54 | + try |
53 | 55 | { |
54 | | - @Override |
55 | | - public JnaDatabase identify() throws SQLException |
| 56 | + JnaDatabaseConnection jnaDatabaseConnection = |
| 57 | + AccessController.doPrivileged(new PrivilegedExceptionAction<JnaDatabaseConnection>() |
56 | 58 | { |
57 | | - return new JnaDatabase(this) { |
58 | | - @Override |
59 | | - protected void attachOrCreate(DatabaseParameterBuffer dpb, boolean create) throws SQLException |
60 | | - { |
61 | | - handle.setValue(attachmentHandle.getValue()); |
62 | | - setAttached(); |
63 | | - afterAttachActions(); |
64 | | - } |
| 59 | + @Override |
| 60 | + public JnaDatabaseConnection run() throws Exception |
| 61 | + { |
| 62 | + return new JnaDatabaseConnection(getClientLibrary(), connectionProperties) { |
| 63 | + @Override |
| 64 | + public JnaDatabase identify() throws SQLException |
| 65 | + { |
| 66 | + return new JnaDatabase(this) { |
| 67 | + @Override |
| 68 | + protected void attachOrCreate(DatabaseParameterBuffer dpb, boolean create) |
| 69 | + throws SQLException |
| 70 | + { |
| 71 | + handle.setValue(attachmentHandle.getValue()); |
| 72 | + setAttached(); |
| 73 | + afterAttachActions(); |
| 74 | + } |
65 | 75 |
|
66 | | - @Override |
67 | | - protected void internalDetach() |
68 | | - { |
69 | | - } |
70 | | - }; |
71 | | - } |
72 | | - }; |
| 76 | + @Override |
| 77 | + protected void internalDetach() |
| 78 | + { |
| 79 | + } |
| 80 | + }; |
| 81 | + } |
| 82 | + }; |
| 83 | + } |
| 84 | + }); |
73 | 85 |
|
74 | | - return jnaDatabaseConnection.identify(); |
| 86 | + return jnaDatabaseConnection.identify(); |
| 87 | + } |
| 88 | + catch (PrivilegedActionException e) |
| 89 | + { |
| 90 | + throw new SQLException(e.getCause()); |
| 91 | + } |
75 | 92 | } |
76 | 93 | } |
0 commit comments