Source Code Cross Referenced for PGPObjectFactory.java in  » Security » Bouncy-Castle » org » bouncycastle » openpgp » 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 » Security » Bouncy Castle » org.bouncycastle.openpgp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.bouncycastle.openpgp;
002:
003:        import org.bouncycastle.bcpg.BCPGInputStream;
004:        import org.bouncycastle.bcpg.PacketTags;
005:
006:        import java.io.ByteArrayInputStream;
007:        import java.io.IOException;
008:        import java.io.InputStream;
009:        import java.util.ArrayList;
010:        import java.util.List;
011:
012:        /**
013:         * General class for reading a PGP object stream.
014:         * <p>
015:         * Note: if this class finds a PGPPublicKey or a PGPSecretKey it
016:         * will create a PGPPublicKeyRing, or a PGPSecretKeyRing for each
017:         * key found. If all you are trying to do is read a key ring file use
018:         * either PGPPublicKeyRingCollection or PGPSecretKeyRingCollection.
019:         */
020:        public class PGPObjectFactory {
021:            BCPGInputStream in;
022:
023:            public PGPObjectFactory(InputStream in) {
024:                this .in = new BCPGInputStream(in);
025:            }
026:
027:            public PGPObjectFactory(byte[] bytes) {
028:                this (new ByteArrayInputStream(bytes));
029:            }
030:
031:            /**
032:             * Return the next object in the stream, or null if the end is reached.
033:             * 
034:             * @return Object
035:             * @throws IOException on a parse error
036:             */
037:            public Object nextObject() throws IOException {
038:                List l;
039:
040:                switch (in.nextPacketTag()) {
041:                case -1:
042:                    return null;
043:                case PacketTags.SIGNATURE:
044:                    l = new ArrayList();
045:
046:                    while (in.nextPacketTag() == PacketTags.SIGNATURE) {
047:                        try {
048:                            l.add(new PGPSignature(in));
049:                        } catch (PGPException e) {
050:                            throw new IOException(
051:                                    "can't create signature object: " + e);
052:                        }
053:                    }
054:
055:                    return new PGPSignatureList((PGPSignature[]) l
056:                            .toArray(new PGPSignature[l.size()]));
057:                case PacketTags.SECRET_KEY:
058:                    try {
059:                        return new PGPSecretKeyRing(in);
060:                    } catch (PGPException e) {
061:                        throw new IOException(
062:                                "can't create secret key object: " + e);
063:                    }
064:                case PacketTags.PUBLIC_KEY:
065:                    return new PGPPublicKeyRing(in);
066:                case PacketTags.COMPRESSED_DATA:
067:                    return new PGPCompressedData(in);
068:                case PacketTags.LITERAL_DATA:
069:                    return new PGPLiteralData(in);
070:                case PacketTags.PUBLIC_KEY_ENC_SESSION:
071:                case PacketTags.SYMMETRIC_KEY_ENC_SESSION:
072:                    return new PGPEncryptedDataList(in);
073:                case PacketTags.ONE_PASS_SIGNATURE:
074:                    l = new ArrayList();
075:
076:                    while (in.nextPacketTag() == PacketTags.ONE_PASS_SIGNATURE) {
077:                        try {
078:                            l.add(new PGPOnePassSignature(in));
079:                        } catch (PGPException e) {
080:                            throw new IOException(
081:                                    "can't create one pass signature object: "
082:                                            + e);
083:                        }
084:                    }
085:
086:                    return new PGPOnePassSignatureList(
087:                            (PGPOnePassSignature[]) l
088:                                    .toArray(new PGPOnePassSignature[l.size()]));
089:                case PacketTags.MARKER:
090:                    return new PGPMarker(in);
091:                case PacketTags.EXPERIMENTAL_1:
092:                case PacketTags.EXPERIMENTAL_2:
093:                case PacketTags.EXPERIMENTAL_3:
094:                case PacketTags.EXPERIMENTAL_4:
095:                    return in.readPacket();
096:                }
097:
098:                throw new IOException("unknown object in stream "
099:                        + in.nextPacketTag());
100:            }
101:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.