I have a Swing base Java application that requires ldap user and password for login. I would like to automate the login so that each time the application is launched, it fills the user and password.
I have seen library robot for java but could not make it.
Is there a way to pass through the JVM / or read Swing component in JVM?
I believe you want to add the remember me feature If you use a database like SQL or oracle then keep the checkbox option in the database with boolean. Otherwise, the checkbox is selected then store your password in some hidden file on the user path. Next time before login look at that password.
Sample code
String file_path=System.getProperty("user.home")+"/.myapp";
FileWriter obj=new FileWriter(file_path);
obj.write("Your Password Here ");
obj.close();
Related
I am currently working on a chat type window in eclipse rcp application.
I have created a StyledText where user will type some message and a system generated message will be visible to StyledText. I want to capture what user has typed in the current line. Especilly, I want to grab the test line entered by the user in StyledText not the whole text.
The example is given below.
System: Welcome
User: Hi
System: Log the ticket
User: where to log
In the above case, I want to track each sentence written by user like "Hi", "where to log" etc. Please help me in this regard.
Thanks in advance.
We are using Installer 6.1.6.
Today we support SQL server authentication and I wish to add a new ability of Windows authentication mode.
Our database configuration is set as configuration form and I want to add a new combo-box form component which will include the 2 server authentications options.
Is it possible to define the combo-box's Windows Authentication option with a condition expression for Windows OS only? (it doesn't make sense to display it for Linux users)
Some of the form components are "username" & "password". In case the user chooses the windows authentication mode these fields aren't relevant anymore. Is it possible to conceal them in that case?
Is the combo-box option could lead to a conflict when running the installer with a quite mode? Is it set the 1st option as a default?
Is it possible to define the combo-box's Windows Authentication option
with a condition expression for Windows OS only? (it doesn't make
sense to display it for Linux users)
You can set the "Drop-down list entries" property of the "Drop-down list" form component to an installer variable that contains a string array:
${installer:authenticationOptions}
In the pre-activation script of the form, you can set the variable with code like:
List<String> options = new ArrayList<>();
options.add("One");
options.add("Two");
if (Util.isWindows()) {
options.add("Three");
}
context.setVariable("authenticationOptions", options.toArray(new String[0]));
Some of the form components are "username" & "password". In case the
user chooses the windows authentication mode these fields aren't
relevant anymore. Is it possible to conceal them in that case?
Yes, by disabling the components in the "Selection change script" property with code like this:
// to disable
formEnvironment.getFormComponentById("123").setEnabled(!selectedItem.equals("Windows authentication"));
// or to hide
formEnvironment.getFormComponentById("123").setVisible(!selectedItem.equals("Windows authentication"));
Is the combo-box option could lead to a conflict when running the installer
with a quite mode?
By default, the first index is selected. This is configurable with the "Initially selected index" property of the "Drop-down list" form component.
Alternative solution:
I would consider using "Single radio button" form components for your authentication options. They are all bound to the same variable name in order to form a group and have the same effect as a drop-down list. With the "Visibility script" property you can hide some options depending on the OS, for example with
Util.isWindows()
and option is only visible on Windows. With the "Coupled form components" tab in the configuration area, you can select other form components that are disabled or enabled depending on the selection.
I'm creating a Java log-in screen for a scheduling program that uses one-way encryption. The program should work as follows:
If it's the first time opening the program, ever, a window will show up asking the user to enter a username and password, as well as a security question. This first time, the password will not be hidden by black circles. Instead, it will be shown in plain text.
Then, the three fields will be encrypted using a caesar/shift cipher of 3 spots, and the 'encrypted' values will be saved into a file called info.txt in the source folder of the program.
The user will then be redirected to a log-in page, where they will re-enter their username and password to log in. Here, the password field is fixed so that the letters show up as black circles(not sure what this is called). A new int variable called loginAttempts is declared and initialized with the value 0.
After the user hits 'log-in', the system will use the same encryption method for the log-in details entered and compare them to the encrypted information in the text file. If both values match, then the user will be re-directed to the main screen of the program, having been granted access.
If not, then loginAttempts increments. After the 5th time, this happens, the user will be asked their security question. If the answer this wrong the first time, they will be booted from the program.
I have a few questions, as I'm having trouble creating this.
The dialog boxes I'm using to produce error messages are very confusing, and not seeming to work. I got the code to use them straight from the Oracle website and I'm still having trouble-- NetBeans has informed me that it 'cannot find symbol' for showInputDialog(the method I'm using to display the error message), but it's not suggesting that I'm missing any imports.
String errorMessage = "Security Question: What was your favorite class in college?";
String s = (String) JTextField.showInputDialog(
null,
errorMessage,
"ERROR",
JOptionPane.PLAIN_MESSAGE,
JOptionPane.WARNING_MESSAGE,
null,
securityAnswer);
The part that's given me an error is the word 'showInputDialog' itself, and I'm unsure why..? I would like for this particular dialog to appear with a text field in it so that the user can enter the answer to the security question in there. However, the code doesn't even seem to be working.
On the Oracle page, this is the code that is given that is supposed to show a dialog box with an input field:
String s = (String)JOptionPane.showInputDialog(
frame,
"Complete the sentence:\n"
+ "\"Green eggs and...\"",
"Customized Dialog",
JOptionPane.PLAIN_MESSAGE,
icon,
null,
"ham");
//If a string was returned, say so.
if ((s != null) && (s.length() > 0)) {
setLabel("Green eggs and... " + s + "!");
return;
}
//If you're here, the return value was null/empty.
setLabel("Come on, finish the sentence!");
But the word frame creates an error in the Netbeans GUI, and I'm not sure why it doesn't work. All I want is to create a text box that looks like this:
but I don't know how to do that in a way that would work.
The way that I've set up my program, I've made multiple jFrame components(different classes), and I've set it up so that if you were to try and access a different frame, the frame you were currently on would turn invisible. For example:
(a user is on the main screen, and they click on a button that says 'Add Appointment.')
addAppointment a = new addAppointment();
a.setVisible(true);
a.setAlwaysOnTop(true);
this.dispose();
And this works for literally all of my program except for the log-in page!
public createUserPass() throws IOException {
String path="\\src\\Schedulemanager\\pkg\\info.txt";
file = new File(path); //creates new File
if (file.exists()) { //make a new file if it's not already existent
logIn loginPage = new logIn();
loginPage.setVisible(true);
loginPage.setAlwaysOnTop(true);
this.dispose();
this.setVisible(false);
} else {
file.createNewFile(); //creates the new file
initComponents();
}
}
This is the 'main' class in the program that will run if the .jar file is clicked. What it's supposed to do is check if the info.txt file exists. If it does, then obviously the user has already set login information, and it should close itself and open an instance of the logIn class, which is the jFrame that handles the log-in functions once the information has been set. However, it doesn't work! It opens the new logIn class, but it doesn't dispose of the original one where you set the information, to begin with.
It's crucial that the original jFrame is hidden so that the user can't just set a new password every single time they run the program! How can I fix this?
Please let me know if I need to clarify anything.
There are number of variables available in liferay for custom TPL files.I have found that on below link of liferay.
http://www.liferay.com/documentation/liferay-portal/6.2/development/-/ai/variables-available-to-layout-a-template-liferay-portal-6-2-dev-guide-09-en
But I have confusion on below variables.I am not able understand differrent between $user and $realuser.
can anybody help on this?
Thank you.
When you have proper permissions, you can "impersonate" other users. Try it: Log in as administrators, go to the user management screen and the "Action" button will have an "impersonate" option. With this active, the permission checks will be done for ${user}, even though you gave the permissions of ${realuser} when you logged in (realuser would be your admin account).
The dockbar will also show you both user names (aka "you are impersonating... be yourself again" - with a link to stop impersonating)
While impersonating another user acount:
user -> user has been supplanted (regular).
realuser -> user that has impersonated the other one (Administrator)
In our RCP application we have newly added a menu as command under menu contributions. Now that we want to enable or disable this new menu depending the user who has logged on to the system. Basically we want to enable the menu only for the Administrator login and not for any other user.
How can this be accomplished?
Thanks in advance !!
You can retrieve the logged in user's name as :
String user=System.getProperty("user.name");
You can retrieve the logged in user detail as described in java-forums.org:
public static void ntSystemDetails() {
com.sun.security.auth.module.NTSystem NTSystem = new com.sun.security.auth.module.NTSystem();
System.out.println(NTSystem.getName());
System.out.println(NTSystem.getDomain());
System.out.println(NTSystem.getDomainSID());
System.out.println(NTSystem.getImpersonationToken());
System.out.println(NTSystem.getPrimaryGroupID());
System.out.println(NTSystem.getUserSID());
for (String group : NTSystem.getGroupIDs()) {
System.out.println("Groups " + group);
}
}
If you get an error like this :
NTSystem is not accessible due to restriction on required library ...
then , follow the following steps as described in https://stackoverflow.com/a/2174607/607637
To know about Well-known security identifiers in Windows operating systems, see this page http://support.microsoft.com/kb/243330
Then
I hope that you get enough hints.
You may try using the activities mechanism for this. Have a look at this