GroupsAndRolesUI.java 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  1. /**
  2. Licensed Materials - Property of IBM
  3. IBM Cognos Products: DOCS
  4. (C) Copyright IBM Corp. 2005, 2008
  5. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with
  6. IBM Corp.
  7. */
  8. /**
  9. * GroupsAndRolesUI.java
  10. *
  11. * Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  12. * Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  13. *
  14. */
  15. import java.awt.BorderLayout;
  16. import java.awt.Dimension;
  17. import java.awt.GridLayout;
  18. import java.awt.event.ActionEvent;
  19. import java.awt.event.ActionListener;
  20. import java.awt.event.WindowAdapter;
  21. import java.awt.event.WindowEvent;
  22. import java.io.File;
  23. import java.net.URL;
  24. import javax.swing.BorderFactory;
  25. import javax.swing.ImageIcon;
  26. import javax.swing.JButton;
  27. import javax.swing.JComboBox;
  28. import javax.swing.JEditorPane;
  29. import javax.swing.JFrame;
  30. import javax.swing.JLabel;
  31. import javax.swing.JMenu;
  32. import javax.swing.JMenuBar;
  33. import javax.swing.JMenuItem;
  34. import javax.swing.JOptionPane;
  35. import javax.swing.JPanel;
  36. import javax.swing.JScrollPane;
  37. import javax.swing.JTextArea;
  38. import javax.swing.JTextField;
  39. import com.cognos.developer.schemas.bibus._3.BaseClass;
  40. // This Java class extends the JFrame class so that you can display a window.
  41. public class GroupsAndRolesUI extends JFrame
  42. {
  43. private CRNConnect connect;
  44. // The following variables represent the dialog components.
  45. private JTextArea textAreaPane;
  46. private JTextField cmURL;
  47. private JButton cmdOption;
  48. private JComboBox cboOption;
  49. private static Logon sessionLogon;
  50. private static GroupsAndRoles groupHandler = new GroupsAndRoles();
  51. private static CSHandlers csHandler = new CSHandlers();
  52. private static String createGroup = "Create Group";
  53. private static String createRole = "Create Role";
  54. private static String deleteGroup = "Delete Group";
  55. private static String deleteRole = "Delete Role";
  56. private static String addUserToGroup = "Add User to Group";
  57. private static String addUserToRole = "Add User to Role";
  58. private static String removeFromGroup = "Remove from Group";
  59. private static String removeFromRole = "Remove from Role";
  60. // This is the constructor.
  61. public GroupsAndRolesUI(String title, CRNConnect connection)
  62. {
  63. // Set the title of the frame, even before the variables are declared.
  64. super(title);
  65. connect = connection;
  66. addComponents();
  67. }
  68. // Add all components to the frame's panel.
  69. private void addComponents()
  70. {
  71. JMenuBar mBar = new JMenuBar();
  72. this.setJMenuBar(mBar);
  73. //declare menuItems
  74. JMenuItem exit;
  75. JMenuItem about;
  76. JMenuItem overview;
  77. //Add and populate the File menu.
  78. JMenu fileMenu = new JMenu("File");
  79. mBar.add(fileMenu);
  80. exit = new JMenuItem("Exit");
  81. fileMenu.add(exit);
  82. exit.addActionListener(new MenuHandler());
  83. //Add and populate the Help menu.
  84. JMenu helpMenu = new JMenu("Help");
  85. mBar.add(helpMenu);
  86. about = new JMenuItem("About");
  87. helpMenu.add(about);
  88. about.addActionListener(new MenuHandler());
  89. overview = new JMenuItem("Overview");
  90. helpMenu.add(overview);
  91. overview.addActionListener(new MenuHandler());
  92. JPanel mainPanel = new JPanel(new GridLayout(2, 0));
  93. // create a cmURL panel
  94. JPanel cmURLPanel = new JPanel();
  95. // Add the URL text field and label
  96. cmURL = new JTextField(CRNConnect.CM_URL.length() + 10);
  97. cmURL.setText(CRNConnect.CM_URL);
  98. cmURL.setEditable(false);
  99. cmURLPanel.add(new JLabel("Server URL:"), BorderLayout.WEST);
  100. cmURLPanel.add(cmURL, BorderLayout.EAST);
  101. // Create the buttonPanel
  102. JPanel buttonPanel = new JPanel();
  103. // Create and add the option combo box
  104. String cmdList[] =
  105. { createGroup,
  106. createRole,
  107. deleteGroup,
  108. deleteRole,
  109. addUserToGroup,
  110. addUserToRole,
  111. removeFromGroup,
  112. removeFromRole };
  113. cboOption = new JComboBox(cmdList);
  114. buttonPanel.add(new JLabel("Select Option:"), BorderLayout.WEST);
  115. buttonPanel.add(cboOption, BorderLayout.CENTER);
  116. // Create and add the Button
  117. cmdOption = new JButton("Run Option");
  118. cmdOption.addActionListener(new allButtonsHandler());
  119. buttonPanel.add(cmdOption, BorderLayout.EAST);
  120. // Add the status text pane.
  121. textAreaPane = new JTextArea();
  122. // Add the panels to the mainPanel
  123. mainPanel.add(cmURLPanel);
  124. mainPanel.add(buttonPanel);
  125. mainPanel.add(textAreaPane);
  126. //Add the ScrollPane to outputPanel
  127. JScrollPane areaScrollPane = new JScrollPane(textAreaPane);
  128. areaScrollPane.setVerticalScrollBarPolicy(
  129. JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  130. areaScrollPane.setPreferredSize(new Dimension(300, 275));
  131. areaScrollPane.setBorder(
  132. BorderFactory.createCompoundBorder(
  133. BorderFactory.createCompoundBorder(
  134. BorderFactory.createTitledBorder("Output"),
  135. BorderFactory.createEmptyBorder(5, 5, 5, 5)),
  136. areaScrollPane.getBorder()));
  137. JPanel outputPanel = new JPanel(new GridLayout(0, 1));
  138. outputPanel.add(areaScrollPane);
  139. JPanel panel = new JPanel(new BorderLayout());
  140. panel.add(mainPanel, BorderLayout.NORTH);
  141. panel.add(outputPanel);
  142. setContentPane(panel);
  143. }
  144. private class MenuHandler implements ActionListener
  145. {
  146. public void actionPerformed(ActionEvent e)
  147. {
  148. if (e.getActionCommand().startsWith("http://"))
  149. {
  150. connect.connectionChange(e.getActionCommand());
  151. }
  152. try
  153. {
  154. JMenuItem menuClicked = (JMenuItem)e.getSource();
  155. if (menuClicked.getText() == "Exit")
  156. {
  157. System.exit(0);
  158. }
  159. if (menuClicked.getText() == "About")
  160. {
  161. JOptionPane.showMessageDialog(
  162. ((JMenuItem)e.getSource()).getParent(),
  163. "IBM Cognos Sample Application\n\n"
  164. + "Version 1.0.0\n"
  165. + "This application uses the IBM Cognos Software Development Kit",
  166. "About IBM Cognos Samples",
  167. JOptionPane.INFORMATION_MESSAGE,
  168. new ImageIcon("../Common/about.gif"));
  169. System.out.println(System.getProperties());
  170. }
  171. if (menuClicked.getText().compareTo("Overview") == 0)
  172. {
  173. JFrame explainWindow =
  174. new JFrame("Overview for Groups and Roles Sample");
  175. File explainFile = new File("Java_GroupsAndRolesGUI_Explain.html");
  176. if (! explainFile.exists())
  177. {
  178. JOptionPane.showMessageDialog(null, "Explain file not found");
  179. return;
  180. }
  181. URL explainURL =
  182. new URL("file:///" + explainFile.getAbsolutePath());
  183. JEditorPane explainPane = new JEditorPane();
  184. explainPane.setPage(explainURL);
  185. explainPane.setEditable(false);
  186. JScrollPane explainScroll =
  187. new JScrollPane(
  188. explainPane,
  189. JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
  190. JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  191. explainWindow.getContentPane().add(explainScroll);
  192. explainWindow.setSize(640, 480);
  193. explainWindow.setVisible(true);
  194. }
  195. }
  196. catch (Exception ex)
  197. {}
  198. }
  199. }
  200. // The following is the button event handler.
  201. // Note: A SWITCH statement cannot be used here because we are comparing
  202. // objects.
  203. private class allButtonsHandler implements ActionListener
  204. {
  205. public void actionPerformed(ActionEvent e)
  206. {
  207. if (!Logon.loggedIn(connect))
  208. {
  209. try
  210. {
  211. sessionLogon.logon(connect);
  212. }
  213. catch (Exception logonException)
  214. {}
  215. }
  216. JButton buttonPressed = ((JButton)e.getSource());
  217. String output = new String();
  218. if (buttonPressed == cmdOption)
  219. {
  220. String cboOptionText = (String)cboOption.getSelectedItem();
  221. GroupsAndRoles groupHandler = new GroupsAndRoles();
  222. try
  223. {
  224. String selectedNamespace =
  225. selectNamespace(connect);
  226. if (cboOptionText == "Create Group")
  227. {
  228. String theName =
  229. JOptionPane.showInputDialog(
  230. null,
  231. "Please enter the name of the group to create",
  232. "New Group",
  233. JOptionPane.INFORMATION_MESSAGE);
  234. if ((theName == null) || (theName.length() == 0))
  235. {
  236. output = "The group name is invalid.";
  237. }
  238. else
  239. {
  240. output = groupHandler.createGroup(connect, theName, selectedNamespace);
  241. }
  242. }
  243. else if (cboOptionText == "Create Role")
  244. {
  245. String theName =
  246. JOptionPane.showInputDialog(
  247. null,
  248. "Please enter the name of the role to create",
  249. "New Role",
  250. JOptionPane.INFORMATION_MESSAGE);
  251. if ((theName == null) || (theName.length() == 0))
  252. {
  253. output = "The role name is invalid.";
  254. }
  255. else
  256. {
  257. output = groupHandler.createRole(connect, theName, selectedNamespace);
  258. }
  259. }
  260. else if (cboOptionText == "Delete Group")
  261. {
  262. String groupSearchPath = selectGroup(connect, selectedNamespace);
  263. if ((groupSearchPath == null) || (groupSearchPath.length() == 0))
  264. {
  265. output = "Unable to select group in " + selectedNamespace + " .";
  266. }
  267. else
  268. {
  269. output = groupHandler.deleteGroup(connect, groupSearchPath);
  270. }
  271. }
  272. else if (cboOptionText == "Delete Role")
  273. {
  274. String roleSearchPath = selectRole(connect, selectedNamespace);
  275. if ((roleSearchPath == null) || (roleSearchPath.length() == 0))
  276. {
  277. output = "Unable to select role in " + selectedNamespace + " .";
  278. }
  279. else
  280. {
  281. output = groupHandler.deleteRole(connect, roleSearchPath);
  282. }
  283. }
  284. else if (cboOptionText == "Add User to Group")
  285. {
  286. String theName =
  287. Logon
  288. .getLogonAccount(connect)
  289. .getSearchPath()
  290. .getValue();
  291. String theGroup = selectGroup(connect, selectedNamespace);
  292. if ((theGroup == null) || (theGroup.length() == 0))
  293. {
  294. output = "The group name is invalid.";
  295. }
  296. else
  297. {
  298. output =
  299. groupHandler.addUserToGroup(
  300. connect,
  301. theName,
  302. theGroup);
  303. }
  304. }
  305. else if (cboOptionText == "Add User to Role")
  306. {
  307. String theName =
  308. Logon
  309. .getLogonAccount(connect)
  310. .getSearchPath()
  311. .getValue();
  312. String theRoleSearchPath = selectRole(connect, selectedNamespace);
  313. if ((theRoleSearchPath == null) || (theRoleSearchPath.length() == 0))
  314. {
  315. output = "Unable to select role in " + selectedNamespace + " .";
  316. }
  317. else
  318. {
  319. output =
  320. groupHandler.addUserToRole(
  321. connect,
  322. theName,
  323. theRoleSearchPath);
  324. }
  325. }
  326. else if (cboOptionText == "Remove from Group")
  327. {
  328. String groupSearchPath = selectGroup(connect, selectedNamespace);
  329. if ((groupSearchPath == null) || (groupSearchPath.length() == 0))
  330. {
  331. output = "Unable to select group in " + selectedNamespace + " .";
  332. }
  333. else
  334. {
  335. String userSearchPath = selectMemberInGroup(connect, groupSearchPath);
  336. if ((userSearchPath == null) || (userSearchPath.length() == 0))
  337. {
  338. output = "Unable to select member in " + groupSearchPath + " .";
  339. }
  340. else
  341. {
  342. output =
  343. groupHandler.deleteUserFromGroup(connect, groupSearchPath, userSearchPath);
  344. }
  345. }
  346. }
  347. else if (cboOptionText == "Remove from Role")
  348. {
  349. String role = selectRole(connect, selectedNamespace);
  350. String user = selectMemberInRole(connect, role);
  351. output =
  352. groupHandler.deleteUserFromRole(connect,role, user);
  353. }
  354. else
  355. {
  356. output = "Invalid option selected, please try again.";
  357. }
  358. }
  359. catch (java.rmi.RemoteException remoteEx)
  360. {
  361. remoteEx.printStackTrace();
  362. output = cboOptionText + ":\n\tAn Error occurred.";
  363. }
  364. }
  365. if (output.compareTo("") != 0)
  366. {
  367. textAreaPane.setText("");
  368. textAreaPane.append(output);
  369. }
  370. }
  371. }
  372. /**
  373. * Displays a list of available members to select from.
  374. *
  375. * @param connection connection to server
  376. * @param selectedRole Name of role to select a member from.
  377. *
  378. * @return Search path to selected member
  379. *
  380. */
  381. public String selectMemberInRole(
  382. CRNConnect connection,
  383. String selectedRole)
  384. throws java.rmi.RemoteException
  385. {
  386. // Get the current role membership.
  387. BaseClass[] memberInfo =
  388. groupHandler.getAvailableMembers(connection, selectedRole);
  389. com.cognos.developer.schemas.bibus._3.Role role = (com.cognos.developer.schemas.bibus._3.Role)memberInfo[0];
  390. if (role.getMembers().getValue() == null)
  391. {
  392. return null;
  393. }
  394. String[] memberSearchPaths =
  395. new String[role.getMembers().getValue().length];
  396. String[] memberDefaultNames =
  397. new String[role.getMembers().getValue().length];
  398. BaseClass obj = null;
  399. for (int i = 0; i < role.getMembers().getValue().length; i++)
  400. {
  401. obj = role.getMembers().getValue()[i];
  402. BaseClass[] members =
  403. csHandler.queryObjectInCS(connection, obj.getSearchPath().getValue());
  404. memberSearchPaths[i] = members[0].getSearchPath().getValue();
  405. memberDefaultNames[i] = members[0].getDefaultName().getValue();
  406. }
  407. // Prompt the user to select a member.
  408. Object selectedValue =
  409. JOptionPane.showInputDialog(
  410. null,
  411. "Select a member from the " + selectedRole + " role",
  412. "Select Member from Role",
  413. JOptionPane.INFORMATION_MESSAGE,
  414. null,
  415. memberDefaultNames,
  416. memberDefaultNames[0]);
  417. if (selectedValue == null)
  418. {
  419. return null;
  420. }
  421. boolean found = false;
  422. int selectedMember = 0;
  423. while (!found && selectedMember < memberDefaultNames.length)
  424. for (int i = 0; i < memberDefaultNames.length; i++)
  425. {
  426. if (((String)selectedValue)
  427. .compareToIgnoreCase(memberDefaultNames[i])
  428. == 0)
  429. {
  430. return memberSearchPaths[i];
  431. }
  432. }
  433. return null;
  434. }
  435. /**
  436. * Displays a list of available members to select from.
  437. *
  438. * @param connection connection to server.
  439. * selectedGroup group from which to show members
  440. *
  441. * @return search path for selected member
  442. *
  443. */
  444. public String selectMemberInGroup(
  445. CRNConnect connection,
  446. String selectedGroup)
  447. throws java.rmi.RemoteException
  448. {
  449. // Get the current group membership.
  450. BaseClass[] memberInfo =
  451. groupHandler.getAvailableMembers(connection, selectedGroup);
  452. com.cognos.developer.schemas.bibus._3.Group group = (com.cognos.developer.schemas.bibus._3.Group)memberInfo[0];
  453. if (group.getMembers().getValue() == null)
  454. {
  455. return null;
  456. }
  457. String[] memberSearchPaths =
  458. new String[group.getMembers().getValue().length];
  459. String[] memberDefaultNames =
  460. new String[group.getMembers().getValue().length];
  461. BaseClass obj = null;
  462. for (int i = 0; i < group.getMembers().getValue().length; i++)
  463. {
  464. obj = group.getMembers().getValue()[i];
  465. BaseClass[] members =
  466. csHandler.queryObjectInCS(connection, obj.getSearchPath().getValue());
  467. memberSearchPaths[i] = members[0].getSearchPath().getValue();
  468. memberDefaultNames[i] = members[0].getDefaultName().getValue();
  469. }
  470. // Prompt the user to select a member.
  471. Object selectedValue =
  472. JOptionPane.showInputDialog(
  473. null,
  474. "Select a member from the "
  475. + selectedGroup
  476. + " group",
  477. "Select Member from Group",
  478. JOptionPane.INFORMATION_MESSAGE,
  479. null,
  480. memberDefaultNames,
  481. memberDefaultNames[0]);
  482. if (selectedValue == null)
  483. {
  484. return null;
  485. }
  486. for (int i = 0; i < memberDefaultNames.length; i++)
  487. {
  488. if (((String)selectedValue)
  489. .compareToIgnoreCase(memberDefaultNames[i])
  490. == 0)
  491. {
  492. return memberSearchPaths[i];
  493. }
  494. }
  495. return null;
  496. }
  497. /**
  498. * Displays a list of available groups to select from.
  499. *
  500. * @param connection connection to server
  501. * @param selectedNamespace Namespace from which to select a group
  502. *
  503. */
  504. public String selectGroup(
  505. CRNConnect connection,
  506. String selectedNamespace)
  507. throws java.rmi.RemoteException
  508. {
  509. BaseClass[] groupInfo =
  510. groupHandler.getAvailableGroups(connection, selectedNamespace);
  511. String[] groupSearchPath = new String[groupInfo.length];
  512. String[] groupDefaultName = new String[groupInfo.length];
  513. for (int i = 0; i < groupInfo.length; i++)
  514. {
  515. groupSearchPath[i] = groupInfo[i].getSearchPath().getValue();
  516. groupDefaultName[i] = groupInfo[i].getDefaultName().getValue();
  517. }
  518. Object selectedValue = null;
  519. // Prompt the user to select a group or role.
  520. selectedValue =
  521. JOptionPane.showInputDialog(
  522. null,
  523. "Please select a group",
  524. "Select a Group",
  525. JOptionPane.INFORMATION_MESSAGE,
  526. null,
  527. groupDefaultName,
  528. groupDefaultName[0]);
  529. if (selectedValue == null)
  530. {
  531. return null;
  532. }
  533. for (int i = 0; i < groupDefaultName.length; i++)
  534. {
  535. if (((String)selectedValue)
  536. .compareToIgnoreCase(groupDefaultName[i])
  537. == 0)
  538. {
  539. return groupSearchPath[i];
  540. }
  541. }
  542. return null;
  543. }
  544. /**
  545. * Displays a list of available roles to select from.
  546. *
  547. * @param connection connection to server
  548. * @param selectedNamespace Namespace from which to select a role
  549. *
  550. */
  551. public String selectRole(
  552. CRNConnect connection,
  553. String selectedNamespace)
  554. throws java.rmi.RemoteException
  555. {
  556. BaseClass[] roleInfo =
  557. groupHandler.getAvailableRoles(connection, selectedNamespace);
  558. if (roleInfo.length == 0)
  559. {
  560. return null;
  561. }
  562. String[] roleSearchPath = new String[roleInfo.length];
  563. String[] roleDefaultName = new String[roleInfo.length];
  564. for (int i = 0; i < roleInfo.length; i++)
  565. {
  566. roleSearchPath[i] = roleInfo[i].getSearchPath().getValue();
  567. roleDefaultName[i] = roleInfo[i].getDefaultName().getValue();
  568. }
  569. Object selectedValue = null;
  570. // Prompt the user to select a group or role.
  571. selectedValue =
  572. JOptionPane.showInputDialog(
  573. null,
  574. "Please select a role",
  575. "Select a Role",
  576. JOptionPane.INFORMATION_MESSAGE,
  577. null,
  578. roleDefaultName,
  579. roleDefaultName[0]);
  580. if (selectedValue == null)
  581. {
  582. return null;
  583. }
  584. for (int i = 0; i < roleDefaultName.length; i++)
  585. {
  586. if (((String)selectedValue).compareToIgnoreCase(roleDefaultName[i])
  587. == 0)
  588. {
  589. return roleSearchPath[i];
  590. }
  591. }
  592. return null;
  593. }
  594. /**
  595. * Displays a list of available namespaces to select from.
  596. *
  597. * @param connection connection to server
  598. *
  599. */
  600. public String selectNamespace(CRNConnect connection)
  601. throws java.rmi.RemoteException
  602. {
  603. BaseClass[] namespaceInfo = groupHandler.getAvailableNamespaces(connection);
  604. String[] namespaceSearchPath = new String[namespaceInfo.length];
  605. String[] namespaceDefaultName = new String[namespaceInfo.length];
  606. for (int i = 0; i < namespaceInfo.length; i++)
  607. {
  608. namespaceSearchPath[i] =
  609. namespaceInfo[i].getSearchPath().getValue();
  610. namespaceDefaultName[i] =
  611. namespaceInfo[i].getDefaultName().getValue();
  612. }
  613. Object selectedValue = null;
  614. // Prompt the user to select a namespace.
  615. selectedValue =
  616. JOptionPane.showInputDialog(
  617. null,
  618. "Please select a namespace",
  619. "Select Namespace",
  620. JOptionPane.INFORMATION_MESSAGE,
  621. null,
  622. namespaceDefaultName,
  623. namespaceDefaultName[0]);
  624. if (selectedValue == null)
  625. {
  626. return null;
  627. }
  628. for (int i = 0; i < namespaceDefaultName.length; i++)
  629. {
  630. if (((String)selectedValue)
  631. .compareToIgnoreCase(namespaceDefaultName[i])
  632. == 0)
  633. {
  634. return namespaceSearchPath[i];
  635. }
  636. }
  637. return null;
  638. }
  639. // Create the main method to execute the application.
  640. public static void main(String args[])
  641. {
  642. CRNConnect connection = new CRNConnect();
  643. connection.connectToCognosServer();
  644. sessionLogon = new Logon();
  645. String output = "";
  646. while (!Logon.loggedIn(connection))
  647. {
  648. output = sessionLogon.logon(connection);
  649. if (!Logon.loggedIn(connection))
  650. {
  651. int retry =
  652. JOptionPane.showConfirmDialog(
  653. null,
  654. "Login Failed. Please try again.",
  655. "Login Failed",
  656. JOptionPane.OK_CANCEL_OPTION);
  657. if (retry != JOptionPane.OK_OPTION)
  658. {
  659. System.exit(0);
  660. }
  661. }
  662. }
  663. GroupsAndRolesUI frame = new GroupsAndRolesUI("IBM Cognos Sample", connection);
  664. frame.textAreaPane.setText(output);
  665. // Create a WindowAdapter so the application
  666. // is exited when the window is closed.
  667. frame.addWindowListener(new WindowAdapter()
  668. {
  669. public void windowClosing(WindowEvent e)
  670. {
  671. System.exit(0);
  672. }
  673. });
  674. // Set the size of the frame and display it.
  675. frame.setSize(750, 440);
  676. frame.setVisible(true);
  677. frame.setResizable(true);
  678. }
  679. }