📄 rawstore.java
字号:
{ if (databaseEncrypted == false || encryptionEngine == null) { throw StandardException.newException( SQLState.STORE_FEATURE_NOT_IMPLEMENTED); } counter_encrypt++; return encryptionEngine.encrypt(cleartext, offset, length, ciphertext, outputOffset); } /** Decrypt cleartext from ciphertext. @see CipherProvider#decrypt @exception StandardException Standard Cloudscape Error Policy */ public int decrypt(byte[] ciphertext, int offset, int length, byte[] cleartext, int outputOffset) throws StandardException { if (databaseEncrypted == false || decryptionEngine == null) { throw StandardException.newException( SQLState.STORE_FEATURE_NOT_IMPLEMENTED); } counter_decrypt++; return decryptionEngine.decrypt(ciphertext, offset, length, cleartext, outputOffset); } /** Returns the encryption block size used by the algorithm at time of creation of an encrypted database */ public int getEncryptionBlockSize() { return encryptionBlockSize; } public int random() { // don't synchronize it, the more random the better. return databaseEncrypted ? random.nextInt() : 0; } public Serializable changeBootPassword(Properties properties, Serializable changePassword) throws StandardException { if (isReadOnly()) throw StandardException.newException(SQLState.DATABASE_READ_ONLY); if (!databaseEncrypted) throw StandardException.newException(SQLState.DATABASE_NOT_ENCRYPTED); if (changePassword == null) throw StandardException.newException(SQLState.NULL_BOOT_PASSWORD); if (!(changePassword instanceof String)) throw StandardException.newException(SQLState.NON_STRING_BP); // the new bootPassword is expected to be of the form // oldkey , newkey. String changeString = (String)changePassword; return cipherFactory.changeBootPassword((String)changePassword, properties, encryptionEngine); } /* ** */ public StandardException markCorrupt(StandardException originalError) { logFactory.markCorrupt(originalError); dataFactory.markCorrupt(originalError); xactFactory.markCorrupt(originalError); return originalError; } /* * class specific methods */ /* subclass can override this method to load different submodules */ public String getTransactionFactoryModule() { return TransactionFactory.MODULE; } public String getDataFactoryModule() { return DataFactory.MODULE; } public String getLogFactoryModule() { return LogFactory.MODULE; } private void logHistory(OutputStreamWriter historyFile, String msg) throws IOException { Date d = new Date(); historyFile.write(d.toString() + ":" + msg + "\n"); historyFile.flush(); } protected boolean privCopyDirectory(StorageFile from, File to) { return privCopyDirectory(from, to, (byte[])null, (String[])null); } protected boolean privCopyDirectory(File from, StorageFile to) { return privCopyDirectory(from, to, (byte[])null, (String[])null); } /** * Return an id which can be used to create a container. * <p> * Return an id number with is greater than any existing container * in the current database. Caller will use this to allocate future * container numbers - most likely caching the value and then incrementing * it as it is used. * <p> * * @return The an id which can be used to create a container. * * @exception StandardException Standard exception policy. **/ public long getMaxContainerId() throws StandardException { return(dataFactory.getMaxContainerId()); } /* These methods require Priv Blocks when run under a security manager. */ private synchronized OutputStreamWriter privFileWriter( StorageFile fileName, boolean append) throws IOException { actionCode = FILE_WRITER_ACTION; actionStorageFile = fileName; actionAppend = append; try{ return (OutputStreamWriter) java.security.AccessController.doPrivileged( this); }catch (java.security.PrivilegedActionException pae) { throw (IOException) pae.getException(); } finally { actionStorageFile = null; } } private synchronized boolean privExists( File file) { actionCode = REGULAR_FILE_EXISTS_ACTION; actionRegularFile = file; try { Object ret = AccessController.doPrivileged( this); return ((Boolean) ret).booleanValue(); } catch( PrivilegedActionException pae) { return false;} // does not throw an exception finally { actionRegularFile = null; } } private synchronized boolean privExists(final StorageFile file) { actionCode = STORAGE_FILE_EXISTS_ACTION; actionStorageFile = file; try { Object ret = AccessController.doPrivileged( this); return ((Boolean) ret).booleanValue(); } catch( PrivilegedActionException pae) { return false;} // does not throw an exception finally { actionStorageFile = null; } } private synchronized boolean privDelete( File file) { actionCode = REGULAR_FILE_DELETE_ACTION; actionRegularFile = file; try { Object ret = AccessController.doPrivileged( this); return ((Boolean) ret).booleanValue(); } catch( PrivilegedActionException pae) { return false;} // does not throw an exception finally { actionRegularFile = null; } } private synchronized boolean privMkdirs( File file) { actionCode = REGULAR_FILE_MKDIRS_ACTION; actionRegularFile = file; try { Object ret = AccessController.doPrivileged( this); return ((Boolean) ret).booleanValue(); } catch( PrivilegedActionException pae) { return false;} // does not throw an exception finally { actionRegularFile = null; } } private synchronized boolean privIsDirectory( File file) { actionCode = REGULAR_FILE_IS_DIRECTORY_ACTION; actionRegularFile = file; try { Object ret = AccessController.doPrivileged( this); return ((Boolean) ret).booleanValue(); } catch( PrivilegedActionException pae) { return false;} // does not throw an exception finally { actionRegularFile = null; } } private synchronized boolean privRemoveDirectory( File file) { actionCode = REGULAR_FILE_REMOVE_DIRECTORY_ACTION; actionRegularFile = file; try { Object ret = AccessController.doPrivileged( this); return ((Boolean) ret).booleanValue(); } catch( PrivilegedActionException pae) { return false;} // does not throw an exception finally { actionRegularFile = null; } } private synchronized boolean privRenameTo( File file1, File file2) { actionCode = REGULAR_FILE_RENAME_TO_ACTION; actionRegularFile = file1; actionRegularFile2 = file2; try { Object ret = AccessController.doPrivileged( this); return ((Boolean) ret).booleanValue(); } catch( PrivilegedActionException pae) { return false;} // does not throw an exception finally { actionRegularFile = null; actionRegularFile2 = null; } } private synchronized boolean privCopyDirectory( StorageFile from, File to, byte[] buffer, String[] filter) { actionCode = COPY_STORAGE_DIRECTORY_TO_REGULAR_ACTION; actionStorageFile = from; actionRegularFile = to; actionBuffer = buffer; actionFilter = filter; try { Object ret = AccessController.doPrivileged( this); return ((Boolean) ret).booleanValue(); } catch( PrivilegedActionException pae) { return false;} // does not throw an exception finally { actionStorageFile = null; actionRegularFile = null; actionBuffer = null; actionFilter = null; } } private synchronized boolean privCopyDirectory( File from, StorageFile to, byte[] buffer, String[] filter) { actionCode = COPY_REGULAR_DIRECTORY_TO_STORAGE_ACTION; actionStorageFile = to; actionRegularFile = from; actionBuffer = buffer; actionFilter = filter; try { Object ret = AccessController.doPrivileged( this); return ((Boolean) ret).booleanValue(); } catch( PrivilegedActionException pae) { return false;} // does not throw an exception finally { actionStorageFile = null; actionRegularFile = null; actionBuffer = null; actionFilter = null; } } private synchronized boolean privCopyFile( File from, StorageFile to) { actionCode = COPY_REGULAR_FILE_TO_STORAGE_ACTION; actionStorageFile = to; actionRegularFile = from; try { Object ret = AccessController.doPrivileged( this); return ((Boolean) ret).booleanValue(); } catch( PrivilegedActionException pae) { return false;} // does not throw an exception finally { actionStorageFile = null; actionRegularFile = null; } } private synchronized String[] privList(final File file) { actionCode = REGULAR_FILE_LIST_DIRECTORY_ACTION; actionRegularFile = file; try { return (String[]) AccessController.doPrivileged( this); } catch( PrivilegedActionException pae) { return null;} // does not throw an exception finally { actionRegularFile = null; } } // PrivilegedExceptionAction method public final Object run() throws IOException { switch(actionCode) { case FILE_WRITER_ACTION: // SECURITY PERMISSION - MP1 return new OutputStreamWriter( actionStorageFile.getOutputStream( actionAppend)); case REGULAR_FILE_EXISTS_ACTION: return ReuseFactory.getBoolean(actionRegularFile.exists()); case STORAGE_FILE_EXISTS_ACTION: return ReuseFactory.getBoolean(actionStorageFile.exists()); case REGULAR_FILE_DELETE_ACTION: return ReuseFactory.getBoolean(actionRegularFile.delete()); case REGULAR_FILE_MKDIRS_ACTION: // SECURITY PERMISSION - OP4 return ReuseFactory.getBoolean(actionRegularFile.mkdirs()); case REGULAR_FILE_IS_DIRECTORY_ACTION: // SECURITY PERMISSION - MP1 return ReuseFactory.getBoolean(actionRegularFile.isDirectory()); case REGULAR_FILE_REMOVE_DIRECTORY_ACTION: // SECURITY PERMISSION - MP1, OP5 return ReuseFactory.getBoolean(FileUtil.removeDirectory(actionRegularFile)); case REGULAR_FILE_RENAME_TO_ACTION: // SECURITY PERMISSION - OP4 return ReuseFactory.getBoolean(actionRegularFile.renameTo(actionRegularFile2)); case COPY_STORAGE_DIRECTORY_TO_REGULAR_ACTION: // SECURITY PERMISSION - MP1, OP4 return ReuseFactory.getBoolean(FileUtil.copyDirectory(storageFactory, actionStorageFile, actionRegularFile, actionBuffer, actionFilter)); case COPY_REGULAR_DIRECTORY_TO_STORAGE_ACTION: // SECURITY PERMISSION - MP1, OP4 return ReuseFactory.getBoolean(FileUtil.copyDirectory((WritableStorageFactory)storageFactory, actionRegularFile, actionStorageFile, actionBuffer, actionFilter)); case COPY_REGULAR_FILE_TO_STORAGE_ACTION: // SECURITY PERMISSION - MP1, OP4 return ReuseFactory.getBoolean(FileUtil.copyFile((WritableStorageFactory) storageFactory, actionRegularFile, actionStorageFile)); case REGULAR_FILE_LIST_DIRECTORY_ACTION: // SECURITY PERMISSION - MP1 return (String[])(actionRegularFile.list()); } return null; } // end of run}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -