Database Reference
In-Depth Information
Listing 12-10. Security Admin Menu main() method and Constructor
public static void main(String[] args) {
// Put main() method right in this JFrame
new OJSAdmin(args) ;
}
public OJSAdmin(String[] args) {
try {
jbInit() ;
// Add extra init in separate method
ojsInit(args) ;
} catch (Exception e) {
e.printStackTrace();
}
}
The OJSAdmin.ojsInit() method is shown in Listing 12-11. Its primary functions are to instantiate a
new Login class, which we discussed previously, and then center itself and make itself visible.
Instantiating the Login class is all that is needed to use the security features of this topic. Note in Listing
12-11 that we call one of the Login constructors if there are two (or more) arguments to ojsInit() , and
another Login constructor if there are not. There will be arguments if we are calling the menu in order to
act on behalf of a different application (discussed later).
Listing 12-11. Additional OJSAdmin Menu Initialization
private void ojsInit(String[] args) throws Exception {
// Method for initializing OJS functionality
JPanel disablePanel = bottomMenuPanel ;
// Login does SSO, two-factor Auth and Application Authorization
if (args.length < 2)
new Login(this) ;
else {
// Call Login with alternate Application ID and Class name
new Login(this, args[0], args[1]) ;
disablePanel = topMenuPanel ;
}
// By default, we only use the top menu, so disable bottom components
// When managing alternate application, we only use bottom menu
Component[] comps = disablePanel.getComponents ();
for (int i = 0; i < comps.length; i++) {
comps[i].setEnabled(false) ;
}
// This static utility method centers any component on the screen
Login.center(this);
// Finally, to see this frame, it must be made visible
this.setVisible(true) ;
}
 
Search WWH ::




Custom Search