1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.jboss.as.quickstarts.ejb_security_interceptors;
18
19 import static org.jboss.as.quickstarts.ejb_security_interceptors.EJBUtil.lookupSecuredEJB;
20
21 import javax.annotation.security.PermitAll;
22 import javax.ejb.Remote;
23 import javax.ejb.Stateless;
24
25 import org.jboss.ejb3.annotation.SecurityDomain;
26
27
28
29
30
31
32 @Stateless
33 @Remote(IntermediateEJBRemote.class)
34 @SecurityDomain("quickstart-domain")
35 @PermitAll
36 public class IntermediateEJB implements IntermediateEJBRemote {
37
38 public String makeTestCalls() {
39 try {
40 StringBuilder sb = new StringBuilder("* * IntermediateEJB - Begin Testing * * \n");
41 SecuredEJBRemote remote = lookupSecuredEJB();
42
43 sb.append("SecuredEJBRemote.getSecurityInformation()=").append(remote.getSecurityInformation()).append("\n");
44
45 try {
46 sb.append("Can call roleOneMethod=");
47 remote.roleOneMethod();
48 sb.append("true\n");
49 } catch (Exception e) {
50 sb.append("false\n");
51 }
52
53 try {
54 sb.append("Can call roleTwoMethod=");
55 remote.roleTwoMethod();
56 sb.append("true\n");
57 } catch (Exception e) {
58 sb.append("false\n");
59 }
60
61 sb.append("* * IntermediateEJB - End Testing * * ");
62 return sb.toString();
63 } catch (Exception e) {
64 if (e instanceof RuntimeException) {
65 throw (RuntimeException) e;
66 }
67 throw new RuntimeException("Teasting failed.", e);
68 }
69 }
70
71 }