1 23 package com.sun.enterprise.tools.verifier.tests.ejb; 24 25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 26 import com.sun.enterprise.deployment.*; 27 import com.sun.enterprise.tools.verifier.*; 28 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck; 29 import com.sun.enterprise.deployment.MethodDescriptor; 30 import java.util.*; 31 32 40 public class MethodPermissionComponentInterface extends EjbTest implements EjbCheck { 41 Result result = null; 42 43 49 public Result check(EjbDescriptor descriptor) { 50 51 result = getInitializedResult(); 52 54 try { 55 if (descriptor instanceof EjbSessionDescriptor || descriptor instanceof EjbEntityDescriptor) { 56 57 Set methods = descriptor.getMethodDescriptors(); 58 boolean noPermissions = false; 60 61 for (Iterator i = methods.iterator(); i.hasNext();) { 62 MethodDescriptor md = (MethodDescriptor) i.next(); 63 Set permissions = descriptor.getMethodPermissionsFor(md); 64 if (permissions.isEmpty() || (permissions == null)) { 65 result.addWarningDetails(smh.getLocalString 66 (getClass().getName() + ".failed", 67 "Warning: Method [ {0} ] of EJB [ {1} ] does not have assigned security-permissions", 68 new Object [] {md.getName(), descriptor.getName()})); 69 result.setStatus(result.WARNING); 70 noPermissions = true; 71 } 72 } 73 74 if (!noPermissions) { 75 result.passed(smh.getLocalString 76 (getClass().getName() + ".passed", 77 "Valid: All [ {0} ]EJB interfaces methods have security-permissions assigned.", 78 new Object [] {descriptor.getName()})); 79 } 80 81 } else { 82 result.notApplicable(smh.getLocalString( 83 getClass().getName() + ".notApplicable", 84 "The bean [ {0} ] is neither a Session nor Entity Bean", 85 new Object [] {descriptor.getName()})); 86 return result; 87 } 88 } catch (Exception e) { 89 result.failed(smh.getLocalString( 90 getClass().getName() + ".exception", 91 "The test generated the following exception [ {0} ]", 92 new Object [] {e.getLocalizedMessage()})); 93 } 94 return result; 95 } 96 97 } 98 | Popular Tags |