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


001:        package org.bouncycastle.jce.provider;
002:
003:        import org.bouncycastle.jce.X509LDAPCertStoreParameters;
004:        import org.bouncycastle.util.Selector;
005:        import org.bouncycastle.util.StoreException;
006:        import org.bouncycastle.x509.X509CertPairStoreSelector;
007:        import org.bouncycastle.x509.X509CertStoreSelector;
008:        import org.bouncycastle.x509.X509CertificatePair;
009:        import org.bouncycastle.x509.X509StoreParameters;
010:        import org.bouncycastle.x509.X509StoreSpi;
011:        import org.bouncycastle.x509.util.LDAPStoreHelper;
012:
013:        import java.util.Collection;
014:        import java.util.Collections;
015:        import java.util.HashSet;
016:        import java.util.Iterator;
017:        import java.util.Set;
018:
019:        /**
020:         * A SPI implementation of Bouncy Castle <code>X509Store</code> for getting
021:         * certificates form a LDAP directory.
022:         *
023:         * @see org.bouncycastle.x509.X509Store
024:         */
025:        public class X509StoreLDAPCerts extends X509StoreSpi {
026:
027:            private LDAPStoreHelper helper;
028:
029:            public X509StoreLDAPCerts() {
030:            }
031:
032:            /**
033:             * Initializes this LDAP cert store implementation.
034:             *
035:             * @param params <code>X509LDAPCertStoreParameters</code>.
036:             * @throws IllegalArgumentException if <code>params</code> is not an instance of
037:             *                                  <code>X509LDAPCertStoreParameters</code>.
038:             */
039:            public void engineInit(X509StoreParameters params) {
040:                if (!(params instanceof  X509LDAPCertStoreParameters)) {
041:                    throw new IllegalArgumentException(
042:                            "Initialization parameters must be an instance of "
043:                                    + X509LDAPCertStoreParameters.class
044:                                            .getName() + ".");
045:                }
046:                helper = new LDAPStoreHelper(
047:                        (X509LDAPCertStoreParameters) params);
048:            }
049:
050:            /**
051:             * Returns a collection of matching certificates from the LDAP location.
052:             * <p/>
053:             * The selector must be a of type <code>X509CertStoreSelector</code>. If
054:             * it is not an empty collection is returned.
055:             * <p/>
056:             * The implementation searches only for CA certificates, if the method
057:             * {@link java.security.cert.X509CertSelector#getBasicConstraints()} is
058:             * greater or equal to 0. If it is -2 only end certificates are searched.
059:             * <p/>
060:             * The subject and the serial number for end certificates should be
061:             * reasonable criterias for a selector.
062:             *
063:             * @param selector The selector to use for finding.
064:             * @return A collection with the matches.
065:             * @throws StoreException if an exception occurs while searching.
066:             */
067:            public Collection engineGetMatches(Selector selector)
068:                    throws StoreException {
069:                if (!(selector instanceof  X509CertStoreSelector)) {
070:                    return Collections.EMPTY_SET;
071:                }
072:                X509CertStoreSelector xselector = (X509CertStoreSelector) selector;
073:                Set set = new HashSet();
074:                // test if only CA certificates should be selected
075:                if (xselector.getBasicConstraints() > 0) {
076:                    set.addAll(helper.getCACertificates(xselector));
077:                    set
078:                            .addAll(getCertificatesFromCrossCertificatePairs(xselector));
079:                }
080:                // only end certificates should be selected
081:                else if (xselector.getBasicConstraints() == -2) {
082:                    set.addAll(helper.getUserCertificates(xselector));
083:                }
084:                // nothing specified
085:                else {
086:                    set.addAll(helper.getUserCertificates(xselector));
087:                    set.addAll(helper.getCACertificates(xselector));
088:                    set
089:                            .addAll(getCertificatesFromCrossCertificatePairs(xselector));
090:                }
091:                return set;
092:            }
093:
094:            private Collection getCertificatesFromCrossCertificatePairs(
095:                    X509CertStoreSelector xselector) throws StoreException {
096:                Set set = new HashSet();
097:                X509CertPairStoreSelector ps = new X509CertPairStoreSelector();
098:
099:                ps.setForwardSelector(xselector);
100:                ps.setReverseSelector(new X509CertStoreSelector());
101:
102:                Set crossCerts = new HashSet(helper
103:                        .getCrossCertificatePairs(ps));
104:                Set forward = new HashSet();
105:                Set reverse = new HashSet();
106:                Iterator it = crossCerts.iterator();
107:                while (it.hasNext()) {
108:                    X509CertificatePair pair = (X509CertificatePair) it.next();
109:                    if (pair.getForward() != null) {
110:                        forward.add(pair.getForward());
111:                    }
112:                    if (pair.getReverse() != null) {
113:                        reverse.add(pair.getReverse());
114:                    }
115:                }
116:                set.addAll(forward);
117:                set.addAll(reverse);
118:                return set;
119:            }
120:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.