Feeds:
Posts
Comments

For example
find /Users/xxx/Desktop/directory|grep customtext$|awk ‘{print “sed -i -e ‘\”s/aaa/bbb/g’\” ” $1}’|sh

cd ~/wildfly-10.1.0.Final/modules/

~/jdk1.8.0_131/bin/java -cp ./system/layers/base/org/jboss/logging/main/jboss-logging-3.3.0.Final.jar:./system/layers/base/org/picketbox/main/picketbox-4.9.6.Final.jar org.picketbox.datasource.security.SecureIdentityLoginModule your-password-string

Encoded password:

-224b0dffed3998dfd6eb091793d10850b2ef7287d7b50175

 

edit wildfly configuration file such as standalone.xml as follows:

  1. add security domain with the above generated encoded password

                <security-domain name=”encrypted-ds-name” cache-type=”default”>

                    <authentication>

                        <login-module code=”org.picketbox.datasource.security.SecureIdentityLoginModule” flag=”required”>

                            <module-option name=”username” value=”user-name”/>

                            <module-option name=”password” value=”

-224b0dffed3998dfd6eb091793d10850b2ef7287d7b50175

“/>

                        </login-module>

                    </authentication>

                </security-domain>

2. add data source

                <datasource jndi-name=”java:jboss/datasources/db-oracle” pool-name=”db-oracle” enabled=”true” use-java-context=”true”>

                    <connection-url>jdbc:oracle:thin:@xxx.com:1521/testdb</connection-url>

                    <driver>oracle</driver>

                    <security>

                        <security-domain>encrypted-ds-name</security-domain>

                    </security>

                </datasource>

host:~ zcai$ /usr/libexec/java_home -v 1.8

/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home

keytool -list -keystore jre/lib/security/cacerts > ~/java_cacerts.txt

Enter keystore password:  changeit
Take a look at java_cacerts.txt. See if it includes the same certificate that is present in the browser by searching for a matching serial number. In the java_cacerts.txt file, the serial number will be in lowercase and without the ":" colon character. If it is not present, then this could be the reason for the error, and we can fix this by adding the certificate found in the browser.

Show certificate and save it to ~/Downloads/ldaps_ca.txt

openssl s_client -showcerts -connect shdc2.seres.local:636

vi ~/Downloads/ldaps_ca.txt

keytool -import -alias ldaps_ca -keystore ./jre/lib/security/cacerts -file 

You will be prompted for a password, use ‘changeit’

~/Downloads/ldaps_ca.txt 

reference:

http://magicmonster.com/kb/prg/java/ssl/pkix_path_building_failed.html

ssh-keyscan -H remote-host-domain-or-ip >> ~/.ssh/known_hosts

public class MyConfig {

public static Properties appProperties() throws IOException {

//method 1: in application configuration, the configuration file my-config.properties is in src/main/resources

//refer to https://stackoverflow.com/questions/2161054/where-to-place-and-how-to-read-configuration-resource-files-in-servlet-based-app

ClassLoader classLoader = Thread.currentThread().getContextClassLoader();

InputStream inStream = classLoader.getResourceAsStream(“ngs16s-config.properties”);

Properties properties = new Properties();

properties.load(inStream);

//method 2: in container configuration, the configuration file my-config.properties is in $WILDFLY_HOME/standalone/configuration
//https://stackoverflow.com/questions/27953261/wildfly-reading-properties-from-configuration-directory

String fileName = System.getProperty(“jboss.server.config.dir”) + “/my-config.properties”;

Properties properties = new Properties();

FileInputStream fis = new FileInputStream(fileName);

properties.load(fis);

}

}

my-config.properties file has key-value pairs separated by tab, such as
my_property_name  my_property_value

How to use it:

String myProperty = MyConfig.appProperties().getProperty(“my_property_name”)

my SQL note

  1. modify Oracle table column example
    alter table batch modify(column_name number(3,0));

List<InputPart> inPart = formParts.get(“file”);

// “file” should

// match the name

// attribute of your

// HTML file input

for (InputPart inputPart : inPart) {

// Retrieve headers, read the Content-Disposition header to

// obtain the original name of the file

MultivaluedMap<String, String> headers = inputPart.getHeaders();

String[] contentDispositionHeader = headers.getFirst(“Content-Disposition”).split(“;”);

for (String name : contentDispositionHeader) {

if ((name.trim().startsWith(“filename”))) {

String[] tmp = name.split(“=”);

fileName = tmp[1].trim().replaceAll(“\””, “”);

}

}

}

working example:

String [] cmd ={“/bin/sh”,“-c”,“sleep 60;nohup ls -l /Users/zcai/Downloads > /Users/zcai/Downloads/tmp.txt &”};

ProcessBuilder builder = new ProcessBuilder(cmd);

use the -F option of curl:
-F/--form <name=value> Specify HTTP multipart POST data

if there are multiple form fields, use multiple -F options.

for more details, refer to https://curl.haxx.se/docs/manpage.html#-F

example curl command line to upload a file:

curl -F “testFieldName=testFieldValue” -F “file=@/Users/zcai/Downloads/test_file.txt” –header “Authorization: Bearer your_token_string” http://hostname:port/webapp/rest/file/upload/testMethod

You can set any header information. The example above shows the Authorization token.

Java JAS-RS backend:

@POST

@Consumes(MediaType.MULTIPART_FORM_DATA)

@Path(“/upload/testMethod)

public Response uploadFile(MultipartFormDataInput multipart) {

InputStream is = null;

    BufferedReader in = null;

    String testFieldName = “”;

    String fileName = “”;

   

try {

//get original file name, refer to https://stackoverflow.com/questions/26333298/multipartform-how-to-get-the-original-file-name

    Map<String, List<InputPart>> formParts = multipart.getFormDataMap();

    List<InputPart> inPart = formParts.get(“file”); 

    for (InputPart inputPart : inPart) {

        MultivaluedMap<String, String> headers = inputPart.getHeaders();

        String[] contentDispositionHeader = headers.getFirst(“Content-Disposition”).split(“;”);

        for (String name : contentDispositionHeader) {

          if ((name.trim().startsWith(“filename”))) {

            String[] tmp = name.split(“=”);

            fileName = tmp[1].trim().replaceAll(“\””,“”);          

          }

        }

    }

//get form file inputstream   

is = multipart.getFormDataPart(“file”, InputStream.class, null);

in = new BufferedReader(new InputStreamReader(is));

//get form input field

testFieldName = multipart.getFormDataPart(testFieldName, String.class, null);

    String line = in.readLine();

       List<String> fileContent = new ArrayList<String>();

    while ((line = in.readLine()) != null) {

    System.out.println(line);

    }

} catch (IOException e) {

e.printStackTrace();

} finally {

try {

in.close();

is.close();

} catch (IOException e) {

e.printStackTrace();

}

}

return Response.ok().entity(fileName + ” has been uploaded to database successfully.\n”).build();

}

in root pom.xml

<build>

<pluginManagement>

<plugins>

<plugin>

</plugin>

<plugin>

<groupId>external.atlassian.jgitflow</groupId>

<artifactId>jgitflowmavenplugin</artifactId>

<version>1.0-m5.1</version>

<configuration>

<enableSshAgent>false</enableSshAgent>

<autoVersionSubmodules>true</autoVersionSubmodules>

<pushFeatures>true</pushFeatures>

<pushReleases>true</pushReleases>

<pushHotfixes>true</pushHotfixes>

<noDeploy>true</noDeploy>

<allowUntracked>true</allowUntracked>

<username>git (or bitbucket ) name</username>

<password>password</password>

<flowInitContext>

<masterBranchName>master</masterBranchName>

<developBranchName>development</developBranchName>

<featureBranchPrefix>feature-</featureBranchPrefix>

<releaseBranchPrefix>release-</releaseBranchPrefix>

<hotfixBranchPrefix>hotfix-</hotfixBranchPrefix>

<versionTagPrefix>your-web-app-</versionTagPrefix>

</flowInitContext>

</configuration>

</plugin>

</plugins>

</pluginManagement>

</build>

 

in ear pom.xml

<profiles>

<profile>

<!– When built in OpenShift the ‘openshift‘ profile will be used when

invoking mvn. –>

<!– Use this profile for any OpenShift specific customization your app

will need. –>

<!– By default that is to put the resulting archive into the ‘deployments’

folder. –>

<!– http://maven.apache.org/guides/mini/guide-building-for-different-environments.html –>

<id>openshift</id>

<build>

<plugins>

<plugin>

<artifactId>maven-ear-plugin</artifactId>

<version>${version.ear.plugin}</version>

<configuration>

<outputDirectory>deployments</outputDirectory>

</configuration>

</plugin>

<plugin>

<groupId>external.atlassian.jgitflow</groupId>

<artifactId>jgitflowmavenplugin</artifactId>

<configuration>

<enableSshAgent>false</enableSshAgent>

<autoVersionSubmodules>true</autoVersionSubmodules>

<pushFeatures>true</pushFeatures>

<pushReleases>false</pushReleases>

<pushHotfixes>true</pushHotfixes>

<noDeploy>true</noDeploy>

<allowUntracked>true</allowUntracked>

<username>git (or bitbucket ) name</username>

<password>password</password>

<flowInitContext>

<masterBranchName>master</masterBranchName>

<developBranchName>development</developBranchName>

<featureBranchPrefix>feature-</featureBranchPrefix>

<releaseBranchPrefix>release-</releaseBranchPrefix>

<hotfixBranchPrefix>hotfix-</hotfixBranchPrefix>

<versionTagPrefix>your-web-app-</versionTagPrefix>

</flowInitContext>

</configuration>

</plugin>

</plugins>

</build>

</profile>

</profiles>

when running it in eclipse, jgitflow:release-start -DallowSnapshots=true worked well, but jgitflow:release-finish -DallowSnapshots=true had the error like ” EMBEDDED/bin/mvn: No such file or directory”. .

The solution is to download a standalone maven and run it using command lines:

apache-maven-3.3.9/bin/mvn jgitflow:release-start -DallowSnapshots=true

apache-maven-3.3.9/bin/mvn jgitflow:release-finish -DallowSnapshots=true

Another solution is to user external maven instead of embedded one:

In eclipse, click on “Run configuration…”,  configure Maven runtime, add external maven.

After successfully running release-finish, go to bitbucket, under the “tag” tab you will find the release your-web-app-versionNumber