Source Code Cross Referenced for CipherSpi.java in  » Apache-Harmony-Java-SE » javax-package » javax » crypto » 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 » Apache Harmony Java SE » javax package » javax.crypto 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:
018:        /**
019:         * @author Vera Y. Petrashkova
020:         * @version $Revision$
021:         */package javax.crypto;
022:
023:        import java.security.AlgorithmParameters;
024:        import java.security.InvalidAlgorithmParameterException;
025:        import java.security.InvalidKeyException;
026:        import java.security.Key;
027:        import java.security.NoSuchAlgorithmException;
028:        import java.security.SecureRandom;
029:        import java.security.spec.AlgorithmParameterSpec;
030:        import java.nio.ByteBuffer;
031:
032:        import org.apache.harmony.crypto.internal.nls.Messages;
033:
034:        /**
035:         * @com.intel.drl.spec_ref
036:         * 
037:         */
038:
039:        public abstract class CipherSpi {
040:
041:            /**
042:             * @com.intel.drl.spec_ref
043:             *  
044:             */
045:            public CipherSpi() {
046:            }
047:
048:            /**
049:             * @com.intel.drl.spec_ref
050:             *  
051:             */
052:            protected abstract void engineSetMode(String mode)
053:                    throws NoSuchAlgorithmException;
054:
055:            /**
056:             * @com.intel.drl.spec_ref
057:             *  
058:             */
059:            protected abstract void engineSetPadding(String padding)
060:                    throws NoSuchPaddingException;
061:
062:            /**
063:             * @com.intel.drl.spec_ref
064:             *  
065:             */
066:            protected abstract int engineGetBlockSize();
067:
068:            /**
069:             * @com.intel.drl.spec_ref
070:             *  
071:             */
072:            protected abstract int engineGetOutputSize(int inputLen);
073:
074:            /**
075:             * @com.intel.drl.spec_ref
076:             *  
077:             */
078:            protected abstract byte[] engineGetIV();
079:
080:            /**
081:             * @com.intel.drl.spec_ref
082:             *  
083:             */
084:            protected abstract AlgorithmParameters engineGetParameters();
085:
086:            /**
087:             * @com.intel.drl.spec_ref
088:             *  
089:             */
090:            protected abstract void engineInit(int opmode, Key key,
091:                    SecureRandom random) throws InvalidKeyException;
092:
093:            /**
094:             * @com.intel.drl.spec_ref
095:             *  
096:             */
097:            protected abstract void engineInit(int opmode, Key key,
098:                    AlgorithmParameterSpec params, SecureRandom random)
099:                    throws InvalidKeyException,
100:                    InvalidAlgorithmParameterException;
101:
102:            /**
103:             * @com.intel.drl.spec_ref
104:             *  
105:             */
106:            protected abstract void engineInit(int opmode, Key key,
107:                    AlgorithmParameters params, SecureRandom random)
108:                    throws InvalidKeyException,
109:                    InvalidAlgorithmParameterException;
110:
111:            /**
112:             * @com.intel.drl.spec_ref
113:             *  
114:             */
115:            protected abstract byte[] engineUpdate(byte[] input,
116:                    int inputOffset, int inputLen);
117:
118:            /**
119:             * @com.intel.drl.spec_ref
120:             *  
121:             */
122:            protected abstract int engineUpdate(byte[] input, int inputOffset,
123:                    int inputLen, byte[] output, int outputOffset)
124:                    throws ShortBufferException;
125:
126:            /**
127:             * @com.intel.drl.spec_ref
128:             *  
129:             */
130:            protected int engineUpdate(ByteBuffer input, ByteBuffer output)
131:                    throws ShortBufferException {
132:                if (input == null) {
133:                    throw new NullPointerException(Messages
134:                            .getString("crypto.0C")); //$NON-NLS-1$
135:                }
136:                if (output == null) {
137:                    throw new NullPointerException(Messages
138:                            .getString("crypto.0D")); //$NON-NLS-1$
139:                }
140:                int position = input.position();
141:                int limit = input.limit();
142:                if ((limit - position) <= 0) {
143:                    return 0;
144:                }
145:                byte[] bInput;
146:                byte[] bOutput;
147:                if (input.hasArray()) {
148:                    bInput = input.array();
149:                    int offset = input.arrayOffset();
150:                    bOutput = engineUpdate(bInput, offset + position, limit
151:                            - position);
152:                    input.position(limit);
153:                } else {
154:                    bInput = new byte[limit - position];
155:                    input.get(bInput);
156:                    bOutput = engineUpdate(bInput, 0, limit - position);
157:                }
158:                if (output.remaining() < bOutput.length) {
159:                    throw new ShortBufferException(Messages
160:                            .getString("crypto.0E")); //$NON-NLS-1$
161:                }
162:                try {
163:                    output.put(bOutput);
164:                } catch (java.nio.BufferOverflowException e) {
165:                    throw new ShortBufferException(Messages.getString(
166:                            "crypto.0F", e)); //$NON-NLS-1$
167:                }
168:                return bOutput.length;
169:            }
170:
171:            /**
172:             * @com.intel.drl.spec_ref
173:             *  
174:             */
175:            protected abstract byte[] engineDoFinal(byte[] input,
176:                    int inputOffset, int inputLen)
177:                    throws IllegalBlockSizeException, BadPaddingException;
178:
179:            /**
180:             * @com.intel.drl.spec_ref
181:             *  
182:             */
183:            protected abstract int engineDoFinal(byte[] input, int inputOffset,
184:                    int inputLen, byte[] output, int outputOffset)
185:                    throws ShortBufferException, IllegalBlockSizeException,
186:                    BadPaddingException;
187:
188:            /**
189:             * @com.intel.drl.spec_ref
190:             *  
191:             */
192:            protected int engineDoFinal(ByteBuffer input, ByteBuffer output)
193:                    throws ShortBufferException, IllegalBlockSizeException,
194:                    BadPaddingException {
195:                if (input == null) {
196:                    throw new NullPointerException(Messages
197:                            .getString("crypto.0C")); //$NON-NLS-1$
198:                }
199:                if (output == null) {
200:                    throw new NullPointerException(Messages
201:                            .getString("crypto.0D")); //$NON-NLS-1$
202:                }
203:                int position = input.position();
204:                int limit = input.limit();
205:
206:                if ((limit - position) <= 0) {
207:                    return 0;
208:                }
209:                byte[] bInput;
210:                byte[] bOutput;
211:
212:                if (input.hasArray()) {
213:                    bInput = input.array();
214:                    int offset = input.arrayOffset();
215:                    bOutput = engineDoFinal(bInput, offset + position, limit
216:                            - position);
217:                    input.position(limit);
218:                } else {
219:                    bInput = new byte[limit - position];
220:                    input.get(bInput);
221:                    bOutput = engineDoFinal(bInput, 0, limit - position);
222:                }
223:                if (output.remaining() < bOutput.length) {
224:                    throw new ShortBufferException(Messages
225:                            .getString("crypto.0E")); //$NON-NLS-1$
226:                }
227:                try {
228:                    output.put(bOutput);
229:                } catch (java.nio.BufferOverflowException e) {
230:                    throw new ShortBufferException(Messages.getString(
231:                            "crypto.0F", e)); //$NON-NLS-1$
232:                }
233:                return bOutput.length;
234:            }
235:
236:            /**
237:             * @com.intel.drl.spec_ref
238:             *  
239:             */
240:            protected byte[] engineWrap(Key key)
241:                    throws IllegalBlockSizeException, InvalidKeyException {
242:                throw new UnsupportedOperationException(Messages
243:                        .getString("crypto.10")); //$NON-NLS-1$
244:            }
245:
246:            /**
247:             * @com.intel.drl.spec_ref
248:             *  
249:             */
250:            protected Key engineUnwrap(byte[] wrappedKey,
251:                    String wrappedKeyAlgorithm, int wrappedKeyType)
252:                    throws InvalidKeyException, NoSuchAlgorithmException {
253:                throw new UnsupportedOperationException(Messages
254:                        .getString("crypto.11")); //$NON-NLS-1$
255:            }
256:
257:            /**
258:             * @com.intel.drl.spec_ref
259:             *  
260:             */
261:            protected int engineGetKeySize(Key key) throws InvalidKeyException {
262:                throw new UnsupportedOperationException(Messages
263:                        .getString("crypto.12")); //$NON-NLS-1$
264:            }
265:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.