I tried to compile a Spring Boot project (Java 8 + Kotlin 1.5) using Gradle 6.8 and found the error below in Java class.
error: package sun.security.provider.certpath.ldap does not exist
import sun.security.provider.certpath.ldap.LDAPCertStoreHelper;
^
I found a solution to Maven project from:
https://stackoverflow.com/a/43894257/13790777 by adding this config in pom.xml which is work.
<configuration>
<fork>true</fork>
<compilerArgument>-XDignore.symbol.file</compilerArgument>
</configuration>
But I when can't config something like this in build.gradle.kts (Gradle Project). So, I want to know the ways to solve this problem.
If you want to reproduce this problem, you can clone this project: https://github.com/ETDA/PDFSigningAndTimestamp and try to compile this project, and you will encounter the problem immediately.
I encountered the same problem and I discovered the following solutions.
Download and install Java Development Kit 8 https://www.oracle.com/java/technologies/downloads/#java8-mac
Open TestSignAndStamp.java
https://github.com/ETDA/PDFSigningAndTimestamp/blob/master/src/sample/TestSignAndStamp.java
Change the certificate file and comment the timestamp server (the existing one has expired).
/**** Sample Input ****/
String passwordP12 = "password";
String inputFileP12 = "cert_sign_01_new.p12"; // Change the certificate file; the existing one has expired.
String inputFileName = "pdfA3.pdf";
String outputFile = "tsa_signed.pdf";
String filePath = "resources/";
String tsaUrl = ""; // "https://time-test.teda.th"; // Comment the timestamp server; the existing one has expired.
String keystorePath = "KeystorePath";
String keystorePassword = "KeystorePassword";
String keystoreType = "PKCS12";
// String passwordP12 = args[0];
// String inputFileP12 = args[1];
// String inputFileName = args[2];
// String outputFile = args[3];
// String filePath = args[4];
// String tsaUrl = args[5];
// String keystorePath = args[6];
// String keystorePassword = args[7];
// String keystoreType = args[8];
Run TestSignAndStamp.java
Related
I would like to know if it's possible to check if two protos in my entire schema have the same filename with buf linter/breaking change detector rules. This may be interesting to me for preventing future issues on my project.
For example, if I have:
syntax = "proto3";
package example.protos.foo;
option csharp_namespace = "Example.Modules.Foo";
option objc_class_prefix = "CMS";
message Foo {
// My foo_id.
string foo_id = 1;
// My string example filed.
string foo_string = 2;
}
And another proto with same filename and another package:
syntax = "proto3";
package example.protos.bar
option csharp_namespace = "Example.Modules.Foo";
option objc_class_prefix = "CMS";
message Foo {
// My foo id.
string foo_id = 1;
// Example string field.
string bar_string = 2;
}
It's possible to prevent this in generation protos time?
I couldn't find a rule to prevent this in the defined linter and breaking change detector rules provided by documentation.
Is there a way to access the JUnit5 version during runtime?
E.g.
...
System.out.printf( "JUnit: %s\n", junit.runner.Version.id() );
...
worked fine for JUnit4.
I am looking for the "counterpart" for JUnit5
THANKS :-)
There is no single "JUnit 5" version number.
There are three of them. They are listed on junit.org:
All artifacts of these three groups contain version information packaged
a) into their module descriptor and
b) into their manifest files.
For Jupiter for example, you may use
a) org.junit.jupiter.api.Test.class.getModule().getDescriptor().getVersion()
or b) org.junit.jupiter.api.Test.class.getPackage().getImplementationVersion()
to access Jupiter's version information at runtime.
Thanks for your answer, but I am still having problems.
E.g. I can not access ".getVersion()"
Anyway
...
import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleDescriptor.Version;
import java.util.Optional;
import org.junit.jupiter.api.Test;
import org.junit.platform.runner.JUnitPlatform;
...
String getJupiterVersionFromModuleDescriptor(){
final Class<Test> clazz = org.junit.jupiter.api.Test.class;
final Module module = clazz.getModule();
final ModuleDescriptor moduleDescriptor = module.getDescriptor();
final Optional<Version> optionalVersion = moduleDescriptor.version();
final Version version = optionalVersion.get();
return version.toString();
}
String String getPlatformVersionFromModuleDescriptor(){
final Class<JUnitPlatform> clazz = org.junit.platform.runner.JUnitPlatform.class;
final Module module = clazz.getModule();
final ModuleDescriptor moduleDescriptor = module.getDescriptor();
final Optional<Version> optionalVersion = moduleDescriptor.version();
final Version version = optionalVersion.get();
return version.toString();
}
String getJupiterVersionFromManifest(){
final Class<Test> clazz = org.junit.jupiter.api.Test.class;
final Package pakage = clazz.getPackage();
final String version = pakage.getImplementationVersion();
return version;
}
String getPlatformVersionFromManifest(){
final Class<JUnitPlatform> clazz = org.junit.platform.runner.JUnitPlatform.class;
final Package pakage = clazz.getPackage();
final String version = pakage.getImplementationVersion();
return version;
}// delivers null in my case - getPlatformVersionFromModuleDescriptor() reports 1.5.1 on my machine
works and of course:
org.junit.jupiter.api.Test.class.getModule().getDescriptor().version()
org.junit.platform.runner.JUnitPlatform.class.getModule().getDescriptor().version()
org.junit.jupiter.api.Test.class.getPackage().getImplementationVersion()
org.junit.platform.runner.JUnitPlatform.class.getPackage().getImplementationVersion()
works also.
Currently I am using:
String getJupiterVersion(){
final Class<Test> testClass = org.junit.jupiter.api.Test.class;
final Optional<Version> optionalVersion = testClass.getModule().getDescriptor().version();
return optionalVersion.isPresent() ? optionalVersion.get().toString() : testClass.getPackage().getImplementationVersion();
}
String getPlatformVersion(){
final Class<JUnitPlatform> jUnitPlatformClass = org.junit.platform.runner.JUnitPlatform.class;
final Optional<Version> optionalVersion = jUnitPlatformClass.getModule().getDescriptor().version();
return optionalVersion.isPresent() ? optionalVersion.get().toString() : jUnitPlatformClass.getPackage().getImplementationVersion();
}
Further: Get jar version in runtime might be helpful.
Anyway, I am still having problems to access the vintage version.
E.g. org.junit.vintage.engine.VintageTestEngine is not accessible ???
And just recently on some machine running JUnit 5.4 getDescriptor() resp. e.g. org.junit.jupiter.api.Test.class.getModule().getDescriptor() delivered null.
I like to have a way of identifying the JUnit version that runs on any JUnit 5 installation.
I need help for my project i have a scenario, where i will get one verification code on my mail id i want to get that verification code and use in my script.
Please let me know anybody has done something like that, thanks in advance
Yes i have done that.
Once you send OTP from the application. You have to use javax.mail and have to write the code to read the email from mailbox for provided emailid. and then extract the OTP using suitable regex from content you get.
First add these dependency if you are using Maven project otherwise you have to add same libraries in your project
<!-- https://mvnrepository.com/artifact/javax.mail/mail -->
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</dependency>
Create one class and use this code :
String hostName = "smtp.gmail.com";
String username = "email username"
String password = "email passeord"
int messageCount;
int unreadMsgCount;
String emailSubject;
Message emailMessage;
public MailReader() {
Properties sysProps = System.getProperties();
sysProps.setProperty("mail.store.protocol", "imaps");
try {
Session session = Session.getInstance(sysProps, null);
Store store = session.getStore();
store.connect(hostName, username, password);
Folder emailInbox = store.getFolder("INBOX");
emailInbox.open(Folder.READ_WRITE);
messageCount = emailInbox.getMessageCount();
System.out.println("Total Message Count: " + messageCount);
unreadMsgCount = emailInbox.getNewMessageCount();
System.out.println("Unread Emails count:" + unreadMsgCount);
emailMessage = emailInbox.getMessage(messageCount);
emailSubject = emailMessage.getSubject();
Pattern linkPattern = Pattern.compile("href=\"(.*)\" target"); // here you need to define regex as per you need
Matcher pageMatcher =
linkPattern.matcher(emailMessage.getContent().toString());
while (pageMatcher.find()) {
System.out.println("Found OTP " + pageMatcher.group(1));
}
emailMessage.setFlag(Flags.Flag.SEEN, true);
emailInbox.close(true);
store.close();
} catch (Exception mex) {
mex.printStackTrace();
}
}
I am using Apache flume for log collection. This is my config file
httpagent.sources = http-source
httpagent.sinks = local-file-sink
httpagent.channels = ch3
#Define source properties
httpagent.sources.http-source.type = org.apache.flume.source.http.HTTPSource
httpagent.sources.http-source.channels = ch3
httpagent.sources.http-source.port = 8082
# Local File Sink
httpagent.sinks.local-file-sink.type = file_roll
httpagent.sinks.local-file-sink.channel = ch3
httpagent.sinks.local-file-sink.sink.directory = /home/avinash/log_dir
httpagent.sinks.local-file-sink.sink.rollInterval = 21600
# Channels
httpagent.channels.ch3.type = memory
httpagent.channels.ch3.capacity = 1000
My application is working fine.My problem is that in the log_dir the files are using some random number (I guess its timestamp) timestamp as by default.
How to give a proper filename suffix for logfiles ?
Having a look on the documentation it seems there is no parameter for configuring the name of the files that are going to be created. I've gone to the sources looking for some hidden parameter, but there is no one :)
Going into the details of the implementation, it seems the name of the file is managed by the PathManager class:
private PathManager pathController;
...
#Override
public Status process() throws EventDeliveryException {
...
if (outputStream == null) {
File currentFile = pathController.getCurrentFile();
logger.debug("Opening output stream for file {}", currentFile);
try {
outputStream = new BufferedOutputStream(new FileOutputStream(currentFile));
...
}
Which, as you already noticed, is based on the current timestamp (showing the constructor and the next file getter):
public PathManager() {
seriesTimestamp = System.currentTimeMillis();
fileIndex = new AtomicInteger();
}
public File nextFile() {
currentFile = new File(baseDirectory, seriesTimestamp + "-" + fileIndex.incrementAndGet());
return currentFile;
}
So, I think the only possibility you have is to extend the File Roll sink and override the process() method in order to use a custom path controller.
For sources you have execute commands to tail and pre-pend or append details, based on shell scripting. Below is a sample:
# Describe/configure the source for tailing file
httpagent.sources.source.type = exec
httpagent.sources.source.shell = /bin/bash -c
httpagent.sources.source.command = tail -F /path/logs/*_details.log
httpagent.sources.source.restart = true
httpagent.sources.source.restartThrottle = 1000
httpagent.sources.source.logStdErr = true
I want to read conf.properties file but but not by giving a hard coded path, so how can I fins it? I have use the below line but its written a null value but the path was correct.
InputStream inputStream = ReadPropertyFile.class.getResourceAsStream("configuration/conf.properties");
Assuming you have configuration folder in your project & that folder contains conf.properties
Use following in your function -
String projdir = System.getProperty("user.dir");
String propfilepath = projdir+"\\config\\"+"conf.properties";
Properties p = new Properties();
p.load(new FileInputStream(propfilepath ));
String value = p.getProperty("test");
System.out.println(value); // It is returning me a value corresponding to key "test"