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
Related
iam using this code to get the currently active tab open URL from Google Chrome browser.
public static string GetActiveTabUrl()
{
Process[] procsChrome = Process.GetProcessesByName("chrome");
if (procsChrome.Length <= 0)
return null;
foreach (Process proc in procsChrome)
{
// the chrome process must have a window
if (proc.MainWindowHandle == IntPtr.Zero)
continue;
// to find the tabs we first need to locate something reliable - the 'New Tab' button
AutomationElement root = AutomationElement.FromHandle(proc.MainWindowHandle);
var SearchBar = root.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "Address and search bar"));
if (SearchBar != null)
return (string)SearchBar.GetCurrentPropertyValue(ValuePatternIdentifiers.ValueProperty);
}
return null;
}
is there any way that I can return the current Profile name too? the profile name which I mean is found on the upper right part of the google chrome browser so it maybe has more than a profile with different names I want only to get the current name with the URL it comes from this function. I can open or use many profiles at the same time in google chrome, so I want to get the active Tab URL and the profile name with it or the email of that profile.
this an image of the profile name i want it from chrome to be sent with the currently active tab URL.
so i expect something like that for example to be done in c# to get the profile name
var SearchBar = root.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "profile email"));
last thing it can be c# or java codes if it can be better do in it also any solution that can get it in any programming language, please help with any information.
Thanks in advance.
You are going to have to dive into the HTML a little bit. Use chrome's developer features and inspect the HTML. You will find what class the username is under and the text is stored as the title find an example below.
<a class="gb_b gb_ib gb_R" href="https://accounts.google.com/" role="button" tabindex="0" title="Google Account: FillerFirstName FillerLastName (fillerEmail#gmail.com)" aria-expanded="false"><span class="gb_db gbii"></span></a>
You can accomplish this in many different ways with C#. I would recommend Selenium.
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 have a problem and I need to know how does the firebase config gets the region/country for a user, is the region based on google account, or what ? also how does it get the region without any permission ?
I have met the problem when I try to get the device region. Here are many ways to get this region, you can use below ways:
use "ro.carrier" get the cid;
use Locale.getDefault().getCountry() get the short country name;
use (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE) to get the region of SIM card.
you may use all of them and given priority.
For Firebase, I have met a short code below, maybe this can help you:
String feature_url = "feature_config";
Log.d(TAG, "init, feature_url: " + feature_url);
mRootReference = FirebaseDatabase.getInstance().getReference();
mRootReference.child(feature_url).child(BuildConfiguration.DEBUG ? "debug" : "release")
.addValueEventListener(new ValueEventListener() {
#Override
public void onDataChange(DataSnapshot dataSnapshot) {
Log.d(TAG, "onDataChange");
FeatureConfig.getInstance().updateConfig(dataSnapshot);
}
#Override
public void onCancelled(DatabaseError databaseError) {
Log.d(TAG, "onCancelled");
}
});
this ie a method used to get the DataSnapShot and then get the region information from it.
Since I dont know whether this could help you, I dont past to much code here.
Hope it helps.
This may give you some idea!!!
You have your own FCM key is strictly required for native implementation.
While setup to get FCM key user should provide region/country
How to set up your own FCM keys:
1) Log in with your Google Account
Open https://console.firebase.google.com/ and log in using your Google account (if the page asks you to do so).
2) Click on Create New Project
In the next box that appears, click on Create New project.
3) Compose the Project Name and select your country/region
You’ll now be prompted with a modal box like the one shown below. Under Project name, write the name you want and below that, select your Country/region. Once you’ve done this, click on the Create Project.
For detail go through this
This is happening in several places for multiple class types but I'll stick with a button example for now.
So I have a button which I want talkback to announce as "Play". The content description is set to "Play". However, talkback is also announcing the class too, so it reads as "Play Button".
I tried a solution I found elsewhere by overloading the onInitializeAccessibilityNodeInfo method
private void setupContentDescriptors() {
mPlayPauseButton.setAccessibilityDelegate(new View.AccessibilityDelegate() {
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info)
{
super.onInitializeAccessibilityNodeInfo(host, info);
//blanked to prevent talkback from announcing class/type
info.setClassName("");
info.setContentDescription("Play");
}
});
}
Setting the class name to "" worked perfectly, but I soon found out this solution only worked for API 23 and above.
According to the docs, "Starting in API 23, delegate methods are called after host methods, which all properties to be modified without being overwritten by the host class."
I've tried several other methods to no avail.
Ideas?
Prior to API 23, you will need to create a subclass and implement onInitializeAccessibilityNodeInfo() if you need to override the class name. You cannot override it by using a delegate.
That said, TalkBack is attempting to provide a consistent and high-quality experience for your user by speaking role descriptions. In the vast majority of cases, you should not attempt to override this behavior.
If you have a small and well-known user circle, maybe this is another alternative to the answer of alanv.
In Talkback 5.2.1(*) you can do this:
Under "Settings -> Accessibility -> Talkback -> Settings -> Verbosity
There you can switch on / off the entry "Speak element type".
With this the user itself can decide if he wants to hear the element type or not. This is another argument NOT to tinker with the way Talkback reads elements.
(*) I did not find any documentation about when the verbosity-setting for speaking elements was introduced. On my Android devices with Talkback 5.2.1 it's working, while devices with Talkback 5.0.3 dont have this setting. So anywhere in between it had to be introduced.
have you tried
ViewCompat.setAccessibilityDelegate(mPlayPauseButton, new
AccessibilityDelegateCompat() {
#Override
public void onInitializeAccessibilityNodeInfo(View host,
AccessibilityNodeInfoCompat info) {
super.onInitializeAccessibilityNodeInfo(host, info);
info.setClassName(null);
info.setContentDescription("your label");
}
})
ViewCompat should take care of the version handling.
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)