1 23 24 package com.sun.enterprise.config.serverbeans.validation.tests; 25 26 import java.util.Locale ; 27 import java.util.logging.Level ; 28 29 import com.sun.enterprise.config.serverbeans.validation.GenericValidator; 30 import com.sun.enterprise.config.serverbeans.validation.ValidationDescriptor; 31 import com.sun.enterprise.config.serverbeans.validation.Result; 32 import com.sun.enterprise.config.serverbeans.Ssl; 33 import com.sun.enterprise.config.serverbeans.IiopListener; 34 import com.sun.enterprise.config.serverbeans.ServerTags; 35 import com.sun.enterprise.config.serverbeans.validation.tests.StaticTest; 36 37 import com.sun.enterprise.config.ConfigBean; 38 import com.sun.enterprise.config.ConfigContextEvent; 39 import com.sun.enterprise.config.ConfigException; 40 41 47 48 public class SslTest extends GenericValidator { 49 50 public SslTest(ValidationDescriptor desc) { 51 super(desc); 52 } 53 54 public Result validate(final ConfigContextEvent cce) { 55 _logger.log(Level.CONFIG, "SslTest validation"); 56 57 final Result result = super.validate(cce); 59 final String choice = cce.getChoice(); 60 if(choice.equals(StaticTest.UPDATE)) { 61 return performUpdateChecks(result, cce); 62 } else if (choice.equals(StaticTest.SET)) { 63 return performSetChecks(result,cce); 64 } 65 return result; 66 } 67 68 private Result performUpdateChecks(final Result result, final ConfigContextEvent cce){ 69 _logger.log(Level.CONFIG, "SslTest performing update check"); 70 final ConfigBean co = (ConfigBean) cce.getClassObject(); 71 final String parentsDtdName = ((ConfigBean) co.parent()).dtdName(); 72 _logger.log(Level.FINER, "SslTest update - parent's DTD name is \""+parentsDtdName+"\""); 73 74 _logger.log(Level.FINER, "SslTest update - attribute name is \""+cce.getName()+"\""); 75 _logger.log(Level.FINER, "SslTest update - attribute value is \""+cce.getObject()+"\""); 76 77 if (parentsDtdName.equals(ServerTags.IIOP_LISTENER) 78 && cce.getName().equals(ServerTags.SSL2_ENABLED) 79 && ((String ) cce.getObject()).equalsIgnoreCase("true")){ 80 _logger.log(Level.FINER, "SslTest update check - parent is an iiop-listener, and ssl2enabled attribute is being set to true"); 81 ssl2NotAllowed(result); 82 } 83 return result; 84 } 85 private Result performSetChecks(final Result result, final ConfigContextEvent cce){ 86 _logger.log(Level.CONFIG, "SsltTest performing set check"); 87 _logger.log(Level.FINER, "SsltTest set - parent's class is \""+cce.getClassObject().getClass().getName()+"\""); 88 _logger.log(Level.FINER, "SsltTest set - ssl objects ssl2enabled attribute is set: \""+((Ssl) cce.getObject()).isSsl2Enabled()+"\""); 89 if (cce.getClassObject() instanceof IiopListener 90 && ((Ssl) cce.getObject()).isSsl2Enabled()){ 91 _logger.log(Level.FINER, "SsltTest set check - parent is an iiop-listener, and ssl2enabled attribute is being set to true"); 92 ssl2NotAllowed(result); 93 } 94 return result; 95 } 96 97 private void ssl2NotAllowed(final Result result){ 98 _logger.log(Level.CONFIG, "SslTest - an invalid attempt to enable ssl2 has been found. Returning an error"); 99 result.failed(smh.getLocalString(getClass().getName()+".ssl2NotAllowed", 100 "ssl2 cannot be enabled for an iiop-listener")); 101 } 102 103 } 104 | Popular Tags |