Liferay variable $user vs $realuser - java

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)

Related

Java application auto fill username and password

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();

Fixing Unsuccessful Transaction on Payment Gateway using Midtrans (Android)

So I recently just trying to understand deeper into Payment Gateway (Android). I already read the documentation and try to implement it into my Android project. So here's the thing, couple times even until now, I'm always getting a message "Transaction unsuccessful. Please try again with another card or with a different payment method" when I try to click a button called Pay. So this Pay button when I clicked it, it supposed to open a new tab (page) to show all of the Payment Method. But again that page never showed up, and showing those errors only.
Can anyone help me fixing this problem? I'm gonna send u guys the code if u guys need it. BIG THANKS :)
This is my button code looks like. How did I can get a page that showing PaymentUiFlow (Payment Method Page)? I already try to configure it out with many different ways but still showing the same error.
private void actionButton() {
MidtransSDK.getInstance().setTransactionRequest(DataCustomer.transactionRequest(
"1",
getIntent().getIntExtra("price", 0),
getIntent().getIntExtra("qty", 0),
getIntent().getStringExtra("name")));
MidtransSDK.getInstance().startPaymentUiFlow(ProductOrderActivity.this, PaymentMethod.BANK_TRANSFER_MANDIRI);
}

Install4j - combo box component configuration conditions

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.

controlclick return true but actual click on windows doesn;t happen-AutoItX4Java

i am using AutoItX4Java and trying to click the Next button on installer.
The return of the method "controlClick" is True but even then i can see that the click doesn't happen on the installer window.
Below is the code used for vlc installer[as example] where it asks to select language , default provide is English.
File file = new File("lib", "jacob-1.18-M2-x64.dll");
System.setProperty(LibraryLoader.JACOB_DLL_PATH, file.getAbsolutePath());
AutoItX x = new AutoItX();
x.run("vlc-2.1.3-win32.exe");
x.winActivate("[TITLE:Installer Language;]");
x.winWaitActive("[TITLE:Installer Language;]");
x.controlClick("[TITLE:Installer Language;]", "", "[CLASS:Button;INSTANCE:1;Text:OK;]")
When manipulating external application windows, always use #RequireAdmin in order to get the permission elevation. Also use Opt("WinSearchChildren", 1) in order to search child windows too. Play with "WinTitleMatchMode".
#RequireAdmin ;Will give your script a permission elevation (sometimes its needed)
Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("WinSearchChildren", 1) ;0=no, 1=search children also
For my case I have just closed my eclipse session and relaunched it by saying run as administrator. This will elevate your session.
It worked for me.
You can check if you have admin rights for eclipse session by using command isAdmin(); returns true if you have rights.

How to check access level of user on any system

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

Categories

Resources