Source Code Cross Referenced for EncryptContainerOperation.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » impl » store » raw » data » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database DBMS » db derby 10.2 » org.apache.derby.impl.store.raw.data 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derby.impl.store.raw.data.EncryptContainerOperation
004:
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to you under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           the License.  You may obtain a copy of the License at
011:
012:              http://www.apache.org/licenses/LICENSE-2.0
013:
014:           Unless required by applicable law or agreed to in writing, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:
020:         */
021:
022:        package org.apache.derby.impl.store.raw.data;
023:
024:        import org.apache.derby.iapi.services.io.StoredFormatIds;
025:        import org.apache.derby.iapi.services.sanity.SanityManager;
026:        import org.apache.derby.iapi.store.raw.Compensation;
027:        import org.apache.derby.iapi.store.raw.Transaction;
028:        import org.apache.derby.iapi.store.raw.Undoable;
029:        import org.apache.derby.iapi.store.raw.Loggable;
030:        import org.apache.derby.iapi.store.raw.data.RawContainerHandle;
031:        import org.apache.derby.iapi.store.raw.xact.RawTransaction;
032:        import org.apache.derby.iapi.store.raw.log.LogInstant;
033:        import org.apache.derby.iapi.store.raw.ContainerKey;
034:        import org.apache.derby.iapi.error.StandardException;
035:
036:        import org.apache.derby.iapi.util.ByteArray;
037:
038:        import java.io.ObjectOutput;
039:        import java.io.ObjectInput;
040:        import java.io.IOException;
041:        import org.apache.derby.iapi.services.io.LimitObjectInput;
042:
043:        /**
044:         * Log operation to encrypt a container with a new encryption key or to encrypt
045:         * an unencrypted container while configuring the database for
046:         * encryption. Container is  synced to the disk when encryption is 
047:         * is successfull, there is nothing to do on a redo. If there is crash/error
048:         * while configuring a database for encryption; original version of the
049:         * container is put backup during undo. 
050:         *
051:         * <PRE>
052:         *  @format_id	LOGOP_ENCRYPT_CONTAINER
053:         * 	the formatId is written by FormatIdOutputStream when this object is
054:         *	written out by writeObject
055:         * @purpose to record enctyption of container with a new encryption key.
056:         * @upgrade
057:         * @disk_layout
058:         *      containerId(ContainerKey)  the id of the container this operation applies to
059:         *	@end_format
060:         *  </PRE>
061:         *
062:         *	@author  Suresh Thalamati
063:         *  @see Undoable
064:         */
065:        public class EncryptContainerOperation implements  Undoable {
066:
067:            private ContainerKey containerId;
068:
069:            protected EncryptContainerOperation(RawContainerHandle hdl)
070:                    throws StandardException {
071:                containerId = hdl.getId();
072:            }
073:
074:            /*
075:             * Formatable methods
076:             */
077:
078:            // no-arg constructor, required by Formatable
079:            public EncryptContainerOperation() {
080:                super ();
081:            }
082:
083:            public void writeExternal(ObjectOutput out) throws IOException {
084:                containerId.writeExternal(out);
085:            }
086:
087:            public void readExternal(ObjectInput in) throws IOException,
088:                    ClassNotFoundException {
089:                containerId = ContainerKey.read(in);
090:            }
091:
092:            /**
093:            	Loggable methods
094:             */
095:
096:            /**
097:               the default for prepared log is always null for all the operations
098:               that don't have optionalData.  If an operation has optional data,
099:               the operation need to prepare the optional data for this method.
100:               
101:               Encrypt Operation has no optional data to write out
102:             */
103:            public ByteArray getPreparedLog() {
104:                return (ByteArray) null;
105:            }
106:
107:            public void releaseResource(Transaction tran) {
108:                // no resources held to release.
109:            }
110:
111:            /**
112:               A space operation is a RAWSTORE log record
113:             */
114:            public int group() {
115:                return Loggable.RAWSTORE;
116:            }
117:
118:            /**
119:             * Check if this operation needs to be redone during recovery redo. 
120:             * Returns true if this op should be redone during recovery redo,
121:             * @param xact	the transaction that is doing the rollback
122:             * @return  true, if this operation needs to be redone during recovery.       
123:             * @exception StandardException Standard Derby error policy
124:             */
125:            public boolean needsRedo(Transaction xact) throws StandardException {
126:                // this opeation should not be redone during recovery. Encrypted version
127:                // of the container are synced to the disk when it is complete. In case 
128:                // rollback containers are replaced with the origincal version. 
129:                return false;
130:            }
131:
132:            /**
133:               Return my format identifier.
134:             */
135:            public int getTypeFormatId() {
136:                return StoredFormatIds.LOGOP_ENCRYPT_CONTAINER;
137:            }
138:
139:            /**
140:             * Containers are not encryped on a redo. Nothing to do in this method.
141:             * @param tran      transaction doing the operation.
142:             * @param instant   log instant for this operation.
143:             * @param in        unused by this log operation.
144:             *
145:             * @exception StandardException Standard Cloudscape error policy
146:             */
147:            public final void doMe(Transaction tran, LogInstant instant,
148:                    LimitObjectInput in) throws StandardException {
149:
150:                // nothing to do here, containers are not encrypted on redo, 
151:                // if confuring the database for encryption fails. it is  
152:                // undone during  recovery. Encryption of the container is done 
153:                // after the log record is flushed to the disk. 
154:
155:                releaseResource(tran);
156:            }
157:
158:            /**
159:               Undo of encrytpion of the container. Original version of the container
160:               that existed before the start of the database encryption is put back.
161:                
162:               @param tran the transaction that is undoing this operation
163:               @exception StandardException Standard Cloudscape error policy
164:             */
165:            public void undoMe(Transaction tran) throws StandardException {
166:                // restore the container to the state it was before the encrytpion.
167:                BaseDataFileFactory bdff = (BaseDataFileFactory) ((RawTransaction) tran)
168:                        .getDataFactory();
169:                EncryptData ed = new EncryptData(bdff);
170:                ed.restoreContainer(containerId);
171:                releaseResource(tran);
172:
173:            }
174:
175:            /**
176:             * Generate a Compensation (EncryptContainerUndoOperation) that 
177:             * will rollback the changes made to the container during container 
178:             * encryption.
179:             * @param tran	the transaction doing the compensating
180:             * @param in	optional input; not used by this operation.
181:             * @exception StandardException Standard Cloudscape error policy
182:             */
183:            public Compensation generateUndo(Transaction tran,
184:                    LimitObjectInput in) throws StandardException {
185:                return new EncryptContainerUndoOperation(this );
186:            }
187:
188:            /** debug */
189:            public String toString() {
190:                if (SanityManager.DEBUG) {
191:                    return "Encrypt container " + containerId;
192:                }
193:
194:                return null;
195:            }
196:        }
w_w__w___.j__a_v__a2_s__.__co___m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.