/* * (non-Javadoc) * * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app. * IApplicationContext) */ @Override public Object start(IApplicationContext context) throws Exception { while (initApp() == false) { ConfigUtil config = ConfigUtil.getInstance(); ConfigDialog configDialog = new ConfigDialog(shell, config); if (configDialog.open() == Window.CANCEL) { return EXIT_OK; } } // Setup login context String configName = Activator.getConfigurationName(); URL configUrl = Activator.getContext().getBundle().getEntry(JAAS_CONFIG_FILE); loginContext = LoginContextFactory.createContext(configName, configUrl); Integer result = null; final Display display = PlatformUI.createDisplay(); try { // Run app in secure context result = (Integer) Subject.doAs(loginContext.getSubject(), getRunAction(display)); } finally { display.dispose(); loginContext.logout(); } // TBD handle javax.security.auth.login.LoginException if (result != null && PlatformUI.RETURN_RESTART == result.intValue()) return EXIT_RESTART; return EXIT_OK; }
public void testRemoteLogin() throws LoginException { // set the userid,password that the authenticating callback handler will set (as user input) TestLocalCallbackHandler.setSuppliedCredentials("testuser", "testpass"); final URL configUrl = Activator.getDefault().getContext().getBundle().getEntry(JAAS_CONFIG_FILE); final ILoginContext secureContext = LoginContextFactory.createContext("RemoteTest", configUrl); secureContext.login(); assertNotNull(secureContext.getSubject()); assertNotNull(secureContext.getSubject().getPrincipals()); assertTrue(secureContext.getSubject().getPrincipals().size() > 0); System.out.println("subject:" + secureContext.getSubject()); System.out.println("login in sucessful"); secureContext.logout(); System.out.println("logoff sucessful"); }