Source Code Cross Referenced for Server.java in  » Collaboration » JacORB » demo » ssl » 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 » Collaboration » JacORB » demo.ssl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package demo.ssl;
002:
003:        import java.io.*;
004:
005:        import java.security.cert.X509Certificate;
006:
007:        import org.omg.PortableServer.POA;
008:        import org.omg.SecurityLevel2.*;
009:        import org.omg.Security.*;
010:        import org.omg.CORBA.ORB;
011:
012:        import org.jacorb.security.level2.*;
013:
014:        /**
015:         * This is the server part of the ssl demo. It demonstrates 
016:         * how to get access to the certificates that the client sent 
017:         * for mutual authentication. The certificate chain can be 
018:         * accessed via the Security Level 2 interfaces.
019:         *
020:         * @author Nicolas Noffke
021:         * @version $Id: Server.java,v 1.3 2002/01/22 10:56:39 nicolas Exp $
022:         */
023:
024:        public class Server extends SSLDemoPOA {
025:            //the Security Level 2 Current
026:            private Current current = null;
027:
028:            /*
029:             * This class from package org.jacorb.security.level2
030:             * contains the actual contents of the security attributes
031:             */
032:            private SecAttributeManager attrib_mgr = null;
033:
034:            //the single attribute type array, that is used 
035:            //for getting the SecAttributes from the Credentials
036:            private AttributeType[] access_id = null;
037:
038:            public Server(Current current) {
039:                this .current = current;
040:
041:                attrib_mgr = SecAttributeManager.getInstance();
042:
043:                AttributeType attribute_type = new AttributeType(
044:                        new ExtensibleFamily((short) 0, (short) 1),
045:                        AccessId.value);
046:
047:                access_id = new AttributeType[] { attribute_type };
048:            }
049:
050:            /**
051:             * This method retrievs the received client certificate 
052:             * from the Credentials.
053:             */
054:            private X509Certificate getClientCert() {
055:                //get the ReceivedCredentials
056:                ReceivedCredentials creds = current.received_credentials();
057:
058:                if (creds == null) {
059:                    return null;
060:                }
061:
062:                //get the SecAttributes we're interested in
063:                SecAttribute[] attribs = creds.get_attributes(access_id);
064:
065:                if (attribs.length == 0) {
066:                    return null;
067:                }
068:
069:                //get the actual contents of the SecAttributes via
070:                //the SecAttributeManager
071:                KeyAndCert kac = attrib_mgr.getAttributeCertValue(attribs[0]);
072:
073:                if (kac == null) {
074:                    return null;
075:                }
076:
077:                //return the first (self-signed) certificate of the chain
078:                return (X509Certificate) kac.chain[0];
079:            }
080:
081:            /**
082:             * This method is from the IDL--interface. It prints out the 
083:             * received client cert (if available).
084:             */
085:            public void printCert() {
086:                X509Certificate client_cert = getClientCert();
087:
088:                if (client_cert == null) {
089:                    System.out.println("No client certificate available");
090:                } else {
091:                    System.out.println("Received a client certificate:");
092:                    System.out.println(client_cert);
093:                }
094:            }
095:
096:            public static void main(String[] args) {
097:                if (args.length != 1) {
098:                    System.out
099:                            .println("Usage: java demo.ssl.Server <ior_file>");
100:                    System.exit(-1);
101:                }
102:
103:                try {
104:                    ORB orb = ORB.init(args, null);
105:
106:                    POA poa = (POA) orb.resolve_initial_references("RootPOA");
107:
108:                    poa.the_POAManager().activate();
109:
110:                    Current current = (org.omg.SecurityLevel2.Current) orb
111:                            .resolve_initial_references("SecurityCurrent");
112:
113:                    org.omg.CORBA.Object demo = poa
114:                            .servant_to_reference(new Server(current));
115:
116:                    PrintWriter pw = new PrintWriter(new FileWriter(args[0]));
117:
118:                    // print stringified object reference to file
119:                    pw.println(orb.object_to_string(demo));
120:
121:                    pw.flush();
122:                    pw.close();
123:
124:                    // wait for requests
125:                    orb.run();
126:                } catch (Exception e) {
127:                    e.printStackTrace();
128:                }
129:            }
130:        } // Server
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.