Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Not able to propagate JAAS Subject(Unable to propagate JAAS Subject using RAP/OSGI or RWT Standalone application setup)
Not able to propagate JAAS Subject [message #1283775] Thu, 03 April 2014 20:19
Hsinlun Lee is currently offline Hsinlun Lee
Messages: 4
Registered: August 2013
Junior Member
I am testing the propagation of JAAS Subject in our RAP application (RAP 2.1) and having trouble to retrieve Subject from JAAS API Subject.getSubject(AccessController.getContext()).

The same code works in RAP with Workbench, but it doesn't work in RAP with OSGi or RWT Standalone. We cannot use RAP with Workbench because it is SWT compatibility mode enforced (i.e. doesn't have access to JEE contexts, unable to do JNDI lookup).

I was able to reproduce the issue using RAP Mail (RAP/Workbench) and RAP Hello World (RAP/OSGi) template projects that come with Eclipse Kepler. .

This is the code snippet in modified RAP Mail (RAP/Workbench) project:
public class Application implements IApplication {
   public Object start(IApplicationContext context) throws Exception {
      final Display display = PlatformUI.createDisplay();

      Subject subject = new Subject();
      Principal myPrincipal = new MyPrincipal("my principal");
      subject.getPrincipals().add(myPrincipal);
      System.out.println(subject);
      
      return Subject.doAs(subject, new PrivilegedAction<Integer>() {
         @Override
         public Integer run() {
            WorkbenchAdvisor advisor = new ApplicationWorkbenchAdvisor();
            return PlatformUI.createAndRunWorkbench(display, advisor);
         }
      });
   }
....
}

public class View extends ViewPart {
   public void createPartControl(Composite parent) {
      ....
      final Link link = new Link(banner, SWT.NONE);
      link.setText("<a>nicole@mail.org</a>");
      link.addSelectionListener(new SelectionAdapter() {    
         public void widgetSelected(SelectionEvent e) {
            System.out.println("link clicked");
            System.out.println(Subject.getSubject(AccessController.getContext()));
            MessageDialog.openInformation(getSite().getShell(), "Not Implemented", "Imagine the address book or a new message being created now.");
         }    
      });
      ....
   }
....
}


This is the console output produced by the code above. It shows Subject was retrieved successfully:
osgi> 2014-04-03 14:54:43.983:INFO:oejs.Server:jetty-8.1.14.v20131031
2014-04-03 14:54:44.152:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:52415
Subject:
	Principal: MyPrincipal [name=my principal]

Subject:
	Principal: MyPrincipal [name=my principal]

link clicked
Subject:
	Principal: MyPrincipal [name=my principal]


Here is the code snippet in modified RAP Hello World (RAP/OSGi) project:
public class BasicEntryPoint extends AbstractEntryPoint {

    @Override
    protected void createContents(Composite parent) {
        parent.setLayout(new GridLayout(2, false));
        Button checkbox = new Button(parent, SWT.CHECK);
        checkbox.setText("Hello");
        Button button = new Button(parent, SWT.PUSH);
        button.setText("World");
                
        button.addSelectionListener(new SelectionAdapter() {
         public void widgetSelected(SelectionEvent e) {
             System.out.println("button clicked");
             System.out.println(Subject.getSubject(AccessController.getContext()));
         }
        });
    }
    
    @Override
    public int createUI() {
      Subject subject = new Subject();
      Principal myPrincipal = new MyPrincipal("my principal");
      subject.getPrincipals().add(myPrincipal);
      System.out.println(subject);

      return Subject.doAs(subject, new PrivilegedAction<Integer>() {
         @Override
         public Integer run() {
             return createUIInternal();
         }
 
      });
    }

    private int createUIInternal() {
       return super.createUI();
    }
   ....
}


And this is the console output produced by the code above. It shows Subject was null:
2014-04-03 14:59:52.250:INFO:oejs.Server:jetty-8.1.14.v20131031
2014-04-03 14:59:52.412:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:52455
osgi> Subject:
	Principal: MyPrincipal [name=my principal]

button clicked
null


Could someone please explain to me why it could not propagate the JAAS Subject using RAP/OSGi setup? Thanks,
Previous Topic:Custom Table/Column Headers
Next Topic:RWT Standalone WAR to WebLogic contextDirectory null
Goto Forum:
  


Current Time: Mon Sep 22 10:22:18 GMT 2014

Powered by FUDForum. Page generated in 0.01580 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software