1 7 package org.jboss.remoting.security.domain; 8 9 import java.io.IOException ; 10 import java.net.InetAddress ; 11 import java.net.ServerSocket ; 12 import javax.naming.InitialContext ; 13 import org.jboss.security.SecurityDomain; 14 import org.jboss.security.ssl.DomainServerSocketFactory; 15 16 19 public class DomainServerSocketFactoryService implements DomainServerSocketFactoryServiceMBean 20 { 21 private String securityDomain = null; 22 private DomainServerSocketFactory serverSocketFactory = null; 23 24 31 public ServerSocket createServerSocket() throws IOException 32 { 33 return serverSocketFactory.createServerSocket(); 34 } 35 36 44 public ServerSocket createServerSocket(int i) throws IOException 45 { 46 return serverSocketFactory.createServerSocket(i); 47 } 48 49 59 public ServerSocket createServerSocket(int i, int i1) throws IOException 60 { 61 return serverSocketFactory.createServerSocket(i, i1); 62 } 63 64 76 public ServerSocket createServerSocket(int i, int i1, InetAddress inetAddress) throws IOException 77 { 78 return serverSocketFactory.createServerSocket(i, i1, inetAddress); 79 } 80 81 public void setSecurityDomain(String securityDomain) 82 { 83 this.securityDomain = securityDomain; 84 } 85 86 public String getSecurityDomain() 87 { 88 return securityDomain; 89 } 90 91 94 public void start() throws Exception 95 { 96 if(securityDomain != null) 97 { 98 InitialContext ctx = new InitialContext (); 99 SecurityDomain domain = (SecurityDomain) ctx.lookup(securityDomain); 100 serverSocketFactory = new DomainServerSocketFactory(); 101 serverSocketFactory.setSecurityDomain(domain); 102 } 103 else 104 { 105 throw new Exception ("Can not create server socket factory due to the SecurityDomain not being set."); 106 } 107 } 108 109 112 public void create() throws Exception 113 { 114 } 116 117 120 public void stop() 121 { 122 } 124 125 128 public void destroy() 129 { 130 } 132 133 } | Popular Tags |