1 22 package org.jboss.test.securitymgr.ejb; 23 24 import java.security.Principal ; 25 import javax.ejb.SessionBean ; 26 import javax.ejb.SessionContext ; 27 import javax.security.auth.Subject ; 28 29 import org.jboss.logging.Logger; 30 31 import org.jboss.security.SecurityAssociation; 32 import org.jboss.security.RunAsIdentity; 33 34 40 public class BadBean implements SessionBean 41 { 42 static final Logger log = Logger.getLogger(BadBean.class); 43 44 public void ejbCreate() 45 { 46 } 47 public void ejbActivate() 48 { 49 } 50 public void ejbPassivate() 51 { 52 } 53 public void ejbRemove() 54 { 55 } 56 57 public void setSessionContext(SessionContext context) 58 { 59 } 60 61 62 public BadBean() 63 { 64 } 65 66 public void accessSystemProperties() 67 { 68 System.getProperty("java.home"); 69 System.setProperty("java.home","tjo"); 70 } 71 72 public Principal getPrincipal() 73 { 74 return SecurityAssociation.getPrincipal(); 75 } 76 public Object getCredential() 77 { 78 return SecurityAssociation.getCredential(); 79 } 80 public void setPrincipal(Principal user) 81 { 82 SecurityAssociation.setPrincipal(user); 83 } 84 public void setCredential(char[] password) 85 { 86 SecurityAssociation.setCredential(password); 87 } 88 public void getSubject() 89 { 90 Subject s = SecurityAssociation.getSubject(); 92 } 93 public void getSubjectCredentials() 94 { 95 Subject s = SecurityAssociation.getSubject(); 97 s.getPrivateCredentials(); 99 } 100 public void setSubject() 101 { 102 Subject s = new Subject (); 103 SecurityAssociation.pushSubjectContext(s, null, null); 104 } 105 public void popRunAsRole() 106 { 107 SecurityAssociation.popRunAsIdentity(); 108 } 109 public void pushRunAsRole() 110 { 111 RunAsIdentity runAs = new RunAsIdentity("SuperUser", "admin"); 112 SecurityAssociation.pushRunAsIdentity(runAs); 113 } 114 115 } 116 | Popular Tags |