I have just cut out everything not needed to show the foul behaviour and wanted 
to attach it to an issue in bug trackin system but I see that you don't welcome 
zipped projects. It is relatively simple so I am attaching it here.

import org.jboss.aop.joinpoint.Invocation;
  | import org.jboss.aop.joinpoint.MethodInvocation;
  | 
  | public class SecurityAspect {
  | 
  |     Invocation invocation;
  | 
  |     public Object authenticationAdvice(Invocation inv) throws Throwable {
  |             this.invocation = inv;
  |             System.out.print("authentication advice: ");
  |             
  |             if (inv instanceof MethodInvocation) {
  |                     MethodInvocation mi = (MethodInvocation)inv;
  |                     show_login_form("Please sign in.");                     
  |             }               
  |             
  |             return null;
  |     }
  |     
  |     private void show_login_form(String message) {
  |             LoginFrame loginDialog = new LoginFrame(this, message);
  |             loginDialog.setVisible(true);
  |     }
  |     
  |     //callback method for login dialog
  |     public void authenticate(String userName,String passwd) throws 
Throwable {
  |             
  |                     
  |                     System.out.println("before invoke next");
  |                     invocation.invokeNext();
  |                     System.out.println("after invoke next");
  |     }
  | 
  | }


  | @SuppressWarnings("serial")
  | public class LoginFrame extends JDialog {
  |     JTextField userName = new JTextField();
  |     JTextField password = new JPasswordField();
  |     JButton okButton = new JButton("OK");
  |     JButton cancelButton = new JButton("Cancel");
  |     public LoginFrame(final SecurityAspect securityInterceptor, String 
message) {
  |             
  |             this.setTitle("Authentication");
  |             
  |             userName.setPreferredSize(new Dimension(150,20));
  |             password.setPreferredSize(new Dimension(160,20));
  |             this.setPreferredSize(new Dimension(400,100));
  |             
  |             this.setLayout(new FlowLayout());
  |             this.add(new JLabel(message));
  |             this.add(new JLabel("User Name:"));
  |             
  |             this.add(userName);
  |             this.add(new JLabel("Password:"));
  |             
  |             add(password);
  |             
  |             
  |             add(okButton);
  |             add(cancelButton);
  |             
  |             
  |             final JDialog thisDialog = this;
  |             
  |             okButton.addActionListener(new ActionListener() {
  | 
  |                     public void actionPerformed(ActionEvent arg0) {
  |                             try {
  |                                     thisDialog.setVisible(false);
  |                                     thisDialog.setEnabled(false);
  |                                     //make call back to security interceptor
  |                                     
securityInterceptor.authenticate(noNull(userName.getText()), 
noNull(password.getText()));
  |                             } catch (Throwable e) {
  |                                     e.printStackTrace();
  |                             }                               
  |                     }
  | 
  |                     private String noNull(String text) {
  |                             return text==null?"":text;
  |                     }
  |             });
  |             
  |     }
  | }
  | 


  | <aop>
  |     <aspect name="SecurityAspect" 
class="com.siemens.smarthome.aspects.security.SecurityAspect"/>
  |     <bind pointcut="execution(public void 
com.siemens.smarthome.MainApplication->start()) AND 
!within(com.siemens.smarthome.aspects.security.SecurityAspect) AND 
!withincode(public void 
com.siemens.smarthome.aspects.security.SecurityAspect->authenticate(..))">
  |         <advice name="authenticationAdvice" aspect="SecurityAspect"/>
  |     </bind>       
  | </aop>

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3932256#3932256

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3932256


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to