I have a Java library which calls Matcher#group(String), i.e. retrieves a group from a matcher by its name.
This works in the test harness for that library, which runs on JRE 17. When I run the same code on Anbox (based on Android 7 and with an API equivalent to Java 7), I get an UnsupportedOperationException.
This exception is not mentioned in the documentation, which only has IllegalStateException (if the previous match failed or no match was attempted yet) or IllegalArgumentException (if no group by that name exists in the pattern).
Android supports named capture groups only from API 26 onwards, which corresponds to Android 8. Once again, Android 7 is the last version which lacks this feature.
Workaround is to reference capture groups by number. Downside is that numbers can change as capture groups change. That can somewhat be alleviated by using unnamed capture groups if parentheses are just needed for grouping, but that particular group is not meant to be retrieved. Simply append ?: to the opening parenthesis, i.e. (?:expression) instead of (expression).
Related
A few years ago, I created two bots, using telegrambots-3.6.1-jar-with-dependencies.
My bots extend the class TelegramLongPollingBot.
Both of them, now, suffer the very same problem.
Every time that a user with user_ID>2147483647 joins the group, the bots stop working for several days, reporting continuously the following error:
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Numeric value (5042963863) out of range of int
at [Source: {"ok":true,"result":[{"update_id":412942830,
"message":{"message_id":306587,"from":{"id":5042963863,"is_bot"
I've tried to use a newer version of libraries (telegrambots-5.1.1-jar-with-dependencies), but in this case, I get many compilation errors, because of missing types (many imports don't work anymore).
I've also tried to use Webhook, but I can't find a complete example that explains how to use the Webhook variable after having set it.
This wouldn't solve the 'out of range error', but at least the bot would still remain active (while now with PollingBot, the bot remains in error-state for many days: even after having shut it down and turned it on again, the bot doesn't work).
I also faced that issued. But I'm not sure you're using rubenlagus telegram bot library or not. If you use may it's old version of telegram bot. Just update to latest telegram bot.
https://github.com/rubenlagus/TelegramBots/issues/1017#issuecomment-1143168283
There are some change on version from lower version. Read more on https://github.com/rubenlagus/TelegramBots/wiki/How-To-Update
Currently I am working on Java Project where trying to use QuickFIX engine.
But every time getting below message:
MsgSeqNum too low, expecting 3 but received 2
For some security reason, can't share the whole Java file and config, but code portion can be shared in customized way.
What I want from here is, if there is any Java sample using QuickFIX where above error point has been fixed.
NB:
Apologies if the same question is there.
Please help me to find that one also.
You can manually set the sequence numbers using APIs:
Session.lookupSession(session_).setNextSenderMsgSeqNum();
Session.lookupSession(session_).setNextTargetMsgSeqNum();
You can also refer: How to set sequence numbers manually in QuickFixJ?
I use the AclFileAttributeView from Java7 to read the folder permissions of a Windows directory. The problem is that I'm not able to get a complete overview because the AclFileAttributeView doesn't return generic permissions like GENERIC_ALL, GENERIC_WRITE, GENERIC_READ and GENERIC_EXECUTE (the four high-order bits in the access mask). In fact, when it comes to generic permissions it gives me wrong information about other AclEntries for the same member. Let me give an example:
When I use a tool like AccessChk to list the AclEntries of c:\windows for the System account I get the following:
[2] ACCESS_ALLOWED_ACE_TYPE: NT AUTHORITY\SYSTEM
FILE_ADD_FILE
FILE_ADD_SUBDIRECTORY
FILE_LIST_DIRECTORY
FILE_READ_ATTRIBUTES
FILE_READ_EA
FILE_TRAVERSE
FILE_WRITE_ATTRIBUTES
FILE_WRITE_EA
DELETE
SYNCHRONIZE
READ_CONTROL
[3] ACCESS_ALLOWED_ACE_TYPE: NT AUTHORITY\SYSTEM
[OBJECT_INHERIT_ACE]
[CONTAINER_INHERIT_ACE]
[INHERIT_ONLY_ACE]
GENERIC_ALL
As you can see the first AclEntry only applies to the folder itself and has not the special permissions WRITE_ACL and WRITE_OWNER.
The second AclEntry applies only to subfolders and files and contains the generic permission GENERIC_ALL. This is exactly how I see it in the Security tab of Windows Explorer. Two records for the System account, one applies only to the folder (with a subset of permissions) and one applies to subfolders/files with Full control.
Now I run my java program using the following code:
AclFileAttributeView view = Files.getFileAttributeView(path, AclFileAttributeView.class);
System.out.println(view.getAcl());
This gives my the following results for the System account:
NT AUTHORITY\SYSTEM:READ_DATA/WRITE_DATA/APPEND_DATA/READ_NAMED_ATTRS/WRITE_NAMED_ATTRS/EXECUTE/DELETE_CHILD/READ_ATTRIBUTES/WRITE_ATTRIBUTES/DELETE/READ_ACL/WRITE_ACL/WRITE_OWNER/SYNCHRONIZE:ALLOW
NT
AUTHORITY\SYSTEM:FILE_INHERIT/DIRECTORY_INHERIT/INHERIT_ONLY:ALLOW
The first AclEntry applies only to the folder itself and contains all the special permissions, including WRITE_ACL and WRITE_OWNER, which is not correct! The second AclEntry doesn't show any permissions, because it has GENERIC_ALL on it!
I'm not sure where this goes wrong, it seems the JRE just decodes the ACE bitmask given by the OS (sun.nio.fs.WindowsSecurityDescriptor.decode).
Has anyone experienced these same issues? I will try some other JRE's, perhaps that makes a difference.
I too ran into this same issue. As it turns out the spec for AclFileAttributeView states it is designed to be compatible with RFC 3530: Network File System (NFS) version 4 Protocol. In RFC 3530, there is no support for GENERIC_* values. I also looked at the JDK code source (From OpenJDK project downloaded from here) which runs the JVM. While it seems to me that there would be a way to make the JVM compatible by mapping from the appropriate RFC 3530 flags to and from GENERIC_*, the maintainers clearly have not. This is the reason for your empty entry NT AUTHORITY\SYSTEM:FILE_INHERIT/DIRECTORY_INHERIT/INHERIT_ONLY:ALLOW
Worse yet, the JVM does NOT support the SE_DACL_PROTECTED and SE_SACL_PROTECTED flags from Windows Security descriptors (which are set via the meta flags (UN)PROTECTED_(S/D)ACL_SECURITY_INFORMATION as indicated in comments here. If you use the tool AccessChk, it actually shows you the effective ACE list not the actual ACE list, which AclFileAttributeView and other Windows tools do (look at FileTest.) This is the reason why the number of ACEs are different. In my case, I had 9 ACEs but AccessChk showed 5. 4 out of those 9 where really duplicates on the SID (the user or group) value where the 1st ACE for a given SID had permissions and the 2nd ACE for a given SID had NO permissions, but just the SE_DACL_PROTECTED set or not set.
I'm not entirely sure what it is you wanted to DO with these ACLs, but I may have a solution for you depending upon your intent. I went ahead and made changes to the JNA project to start allowing one to modify Windows Security Descriptors in a more direct way. You can see my merged pull request here. I don't know how often they publish versions to the Maven public repo, so you may have to download and compile the source directly to get those changes. See the GetNamedSecurityInfo for how to get the SD of an object. Then, you can use the help APIs in AdvApi32Util to maninuplate the SECURITY_DESCRIPTOR objects. See public static SECURITY_DESCRIPTOR_RELATIVE getFileSecurityDescriptor(File file, boolean getSACL) for a way to get the SD into self relative format and then that object allows you to walk the ACEs in the ACL.
I ended up using reflection to get the ACE's access mask (using
sun.nio.fs.WindowsNativeDispatcher.GetAce). With the access mask I check the four high order bits to determine the generic permissions.
It also allows me to get the INHERITED_ACE bit, which is not available in the JRE spec. I get the 'raw' ACL information, which is a lot more then the Windows Security tab. For example, my c:\ drive gives me two ACE's for the BUILT-IN\Administrators, one with GENERIC_ALL permissions and propagation to subfolders and files (not the container itself), and one with the applied special permissions having no flags at all (only applied on the current container). That's how Windows uses these Generic permissions. The same applies for the subfolders, like the Program Files directory, Generic permissions are propagated and every sub container has a separate ACE for the actual special permissions that apply only to the container itself.
About the tool AccessChck, are you sure you use the -l parameter? This gives a lot more information and the 'raw' ACL information.
I already use the JNA Project to retrieve local groups from a server. Thanks for the tip about the AdvApi32Util! I will look into it. How was your experience with the setACL method in the JRE?
I use all this to release a tool that combines group membership from a LDAP with the ACL information found in the directories and files. All this information is saved in a local database (or external) and can be used to create overviews. This overview offers a lot of filter options and displays permission info for a specific user or a group of users (including nested group membership). Because everything is saved in a database, it gives you overviews in seconds instead of scanning the whole network every time. You can also trace permissions, it displays where permissions come from, from what group membership or from what folder, etc. It will contain a feature to modify a single ACE, but the focus is on viewing permissions.
The tool is ready for testing ;) Let me know if you're interested... The tool won't be for free because it took me a hell of a lot time to write, but let me know if you're interested. I can get you a license. See the following links for a quick impression. Don't mind the website, it still mentions an old version of the tool.
Scan screenshot
Overview screenshot
Permission Analyzer 64bit
Permission Analyzer 32bit
Permission Analyzer 64bit with embedded JRE
Permission Analyzer 32bit with embedded JRE
I want to develop a java application for scanning and parsing (OCR) documents.
I have downloaded sample code from here. But My canon scanner is not working with the sample code.Have anyone know about any simulators or virtual scanners for testing the CSSN OCR SDK. (application or online services)?
You didn't mention your use case, I wanted to make sure you're aware that CSSN is a specialized OCR for "structured" card-type documents such as driver's licenses, medical insurance cards, etc.
Let's take the issues one by one:
Java support
Of the modules making up the CSSN SDK, there is full Java support for these:
ID Card Scan
ID Card Barcode
Passports
Medical Card Scan
Check Scan
Magnetic Stripe Reader
The API for (1), (2), and (3) is documented here: http://id-reader.com/ftp/applications/sdk/docs/SDK_Java_API.pdf.
The API for Medical Card Scan (4) is covered here: http://id-reader.com/ftp/applications/sdk/docs/MedicSDK_Java_API.pdf
For (5) and (6), there is no documentation yet, only sample code, at the location you mentioned.
Canon (and other) scanners
The CSSN SDK comes bundled and works seamlessly with the ScanShell and SnapShell scanners (read more here:http://www.card-reader.com/id_scanners.htm).
However, the CSSN SDK will work with practically any scanner, your Canon included.
This is what you do to get it to work:
Submit the Developer Contact Form here: https://store.card-reader.com/leadform.aspx. Make sure you mention the scanner type you are working with (Canon, in your case).
Two things happen next:
An automated email is sent back to you containing a 60-day free trial SDK demo key.
Support will follow up with a separate call (they commit to respond within one work day) and provide the activation key you need.
Install the SDK, following the instructions here: http://id-reader.com/Support/Installation_Guides/CSSNSDKInstallationGuide.pdf
In Screen 6, you unselect the "I don't have Activation Key" check-box, then type in the activation key you received and proceed to the end of the installation process.
When initializing the library you require (see Java support, above), you pass in the SDK demo key to the relevant Init*() function.
For example, to initialize the Barcode library, call the InitBCLib() function, which takes a single parameter, license, of type String.
HTH. Feel free to ask any more questions you may have.
Also, is creating an applet that uses the java 6 plugin 2 thing any different than creating a normal applet?
See the Java documentation for the Applet and Object tags. Especially look at the documentation of the "class ID" attribute of the object tag. You want to use a classid tag like this:
classid="clsid:CAFEEFAC-xxxx-yyyy-zzzz-ABCDEFFEDCBA"
where
xxxx = 0016
yyyy = 0000
zzzz = 0002
and this will specify that exact version. No, specifying any specific Java version is no different than asking for the "latest version intalled" except for the value of the classid attribute and perhaps the value of the codebase attribute.
See also Deployment Advice from Java 6 update 10. Note that Java 6 update 10 adds a number of significant features that allow you, for example, to run an Applet outside of a browser.