Had an opendj installed on a Debian64 machine, just needed to reset the password for cn=Directory Manager
Followed http://allidm.com/blog/2012/09/change-password-for-directory-manager-in-forgerock-opendj/ just make sure when you copy into vi you ensure to delete the trailing white space heh.
Then I could run /opt/opendj/bin/status and enter the credentials successfully.
Tested connecting with Ldap admin using cn=Directory Manager
Connected. To set a user password under ou=Users, right click set Password, chose plain text and enter the password. Right click user again and select "copy dn to clipboard." Open another instance of the LDAP Admin tool, new connection, enter the IP and paste the dn of the user, enter the password, and verify with test connection.
In Java project create test class to connect following http://www.codejava.net/coding/connecting-to-ldap-server-using-jndi-in-java
Test same using and verify connected using dn and "simple" for the java.naming.security.authentication.
Installed MySQL and created a database and user on the Debian Wheezy VM per https://www.rackspace.com/knowledge_center/article/installing-mysql-server-on-debian
Following http://people.cis.ksu.edu/~hankley/d764/tut07/Nigusse_Spring.pdf now to populate a user info object from session. Get right maven dependencies from http://www.mkyong.com/spring/maven-spring-jdbc-example/ and http://examples.javacodegeeks.com/enterprise-java/spring/jdbc/spring-jdbctemplate-example/
Modify my.cnf to set bind-address to static ip. then /etc/init.d/mysql restart
Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts
Monday, January 18, 2016
Wednesday, July 9, 2014
Bit shift operators
Experimentation in Java Snippet Runner to learn about bit shift operator and binary operators based on http://stackoverflow.com/questions/2534116/how-to-convert-get-rgbx-y-integer-pixel-to-colorr-g-b-a-in-java. >>> shifts all bits to the right with the bits falling off the right and zero filling from the left (as opposed to >> which fills from left based on sign (in this case 1 ... 0xAABBCCDD = -1430532899).
int argb = 0xAABBCCDD;
int r = (argb)&0xFF;
int g = (argb>>8)&0xFF;
int b = (argb>>16)&0xFF;
int a = (argb>>24)&0xFF;
int r_ = (argb)&0xFF;
int g_ = (argb>>8)&0xFF;
int b_ = (argb>>16)&0xFF;
int a_ = (argb>>24)&0xFF;
int r_1 = (argb)&0xFFFFFFFF;
int g_1 = (argb>>8)&0xFFFFFFFF;
int b_1 = (argb>>16)&0xFFFFFFFF;
int a_1 = (argb>>24)&0xFFFFFFFF;
System.out.println(Integer.toBinaryString(argb));
System.out.println(r + " red " + Integer.toBinaryString(r_) + "\n" + Integer.toBinaryString(r_1));
System.out.println(g + " green " + Integer.toBinaryString(g_) + "\n" + Integer.toBinaryString(g_1));
System.out.println(b + " blue " + Integer.toBinaryString(b_) + "\n" + Integer.toBinaryString(b_1));
System.out.println(a + " alpha " + Integer.toBinaryString(a_) + "\n" + Integer.toBinaryString(a_1));
System.out.println("righters");
System.out.println((argb>>8));
System.out.println((argb>>16));
System.out.println((argb>>24));
System.out.println(argb +"color methods");
java.awt.Color c = new java.awt.Color(argb, true);
System.out.println("red " + c.getRed());
System.out.println("green " + c.getGreen());
System.out.println("blue " + c.getBlue());
System.out.println("alpha " + c.getAlpha());
10101010101110111100110011011101 221 red 11011101 10101010101110111100110011011101 204 green 11001100 11111111101010101011101111001100 187 blue 10111011 11111111111111111010101010111011 170 alpha 10101010 11111111111111111111111110101010 righters -5588020 -21829 -86 -1430532899color methods red 187 green 204 blue 221 alpha 170 OK
Saturday, April 26, 2014
JSF CRUD Tutorial
Following instructions at https://netbeans.org/kb/docs/web/jsf20-crud.html
at end of "Creating the Web Application Project" was curious so in Libraries - GlassFish Server 4, expanded javax.servlet.jsp.jstl.jar - org.apache.taglibs.standard.tag.common.xml - ParseSupport.class it opened a generated source file. I noticed the button "Attach Sources"
I then used https://blogs.oracle.com/geertjan/entry/how_to_set_up_glassfish1 as a guide to download the sources. I did Team - Subversion -Checkout - Repository URL: https://svn.java.net/svn/jstl~svn and downloaded to a new folder java.net-src\jstl in the NetBeans projects folder. Then I clicked the "Attach Sources..." button and added the folder %USERPROFILE%\Documents\NetBeansProjects\java.net-src\jstl\javax.servlet.jsp.jstl-1.2.1\src\main\java.
Going back to the .class files under the javax.servlet.jsp.jstl.jar file I am now able to double-click one and see the source.
at end of "Creating the Web Application Project" was curious so in Libraries - GlassFish Server 4, expanded javax.servlet.jsp.jstl.jar - org.apache.taglibs.standard.tag.common.xml - ParseSupport.class it opened a generated source file. I noticed the button "Attach Sources"
I then used https://blogs.oracle.com/geertjan/entry/how_to_set_up_glassfish1 as a guide to download the sources. I did Team - Subversion -Checkout - Repository URL: https://svn.java.net/svn/jstl~svn and downloaded to a new folder java.net-src\jstl in the NetBeans projects folder. Then I clicked the "Attach Sources..." button and added the folder %USERPROFILE%\Documents\NetBeansProjects\java.net-src\jstl\javax.servlet.jsp.jstl-1.2.1\src\main\java.
Going back to the .class files under the javax.servlet.jsp.jstl.jar file I am now able to double-click one and see the source.
Wednesday, April 23, 2014
Standalone JAX-WS Lab
This question made me curious: http://stackoverflow.com/questions/5166269/what-happens-when-a-java-class-is-annotated-webservice?rq=1
Thus I created the standalone server per: http://stackoverflow.com/questions/1792737/in-process-soap-service-server-for-java
basically set up the .java files per the answer and do:
C:\Work\Testing\java\webservices\standalone_ws>mkdir buildsvc
C:\Work\Testing\java\webservices\standalone_ws>javac -d buildsvc helloservice/endpoint/*java
C:\Work\Testing\java\webservices\standalone_ws>java -cp buildsvc helloservice.endpoint.Server
Starting Server
Server ready...
package simpleclient;
import helloservice.endpoint.*;
import javax.xml.ws.WebServiceRef;
Thus I created the standalone server per: http://stackoverflow.com/questions/1792737/in-process-soap-service-server-for-java
basically set up the .java files per the answer and do:
C:\Work\Testing\java\webservices\standalone_ws>mkdir buildsvc
C:\Work\Testing\java\webservices\standalone_ws>javac -d buildsvc helloservice/endpoint/*java
C:\Work\Testing\java\webservices\standalone_ws>java -cp buildsvc helloservice.endpoint.Server
Starting Server
Server ready...
Then, create a client:
package simpleclient;
import helloservice.endpoint.*;
import javax.xml.ws.WebServiceRef;
import javax.xml.namespace.QName;
public class HelloClient {
@WebServiceRef(wsdlLocation="http://localhost:9000/SoapContext/SoapPort?WSDL")
static HelloService service;
public static void main(String[] args) {
try {
HelloClient client = new HelloClient();
client.doTest(args);
} catch(Exception e) {
e.printStackTrace();
}
}
public void doTest(String[] args) {
try {
QName qname = new QName("http://endpoint.helloservice/", "HelloService");
HelloService service = new HelloService(null, qname);
System.out.println("Retrieving the port from the following service: " + service);
Hello port = service.getHelloPort();
System.out.println("Invoking the sayHello operation on the port.");
String name;
if (args.length > 0) {
name = args[0];
} else {
name = "No Name";
}
String response = port.sayHello(name);
System.out.println(response);
} catch(Exception e) {
e.printStackTrace();
}
}
}
Test:
mkdir build
wsimport -d build -keep -verbose http://localhost:9000/SoapContext/SoapPort?WSDL
javac -cp build simpleclient/HelloClient.java
java -cp build;. simpleclient.HelloClient bah
Then to make things interesting and to see the full stack trace to see how the WebService annotation is processed on the server or at least for clues, change the sayHello method:
public String sayHello(String name) {
return message + name + "." + (1/(1-1));
}
to throw an ArithmeticException. Redo above steps and see the stacktrace coming from the cmd window for the running server:
Starting Server
Server ready...
Apr 23, 2014 10:42:41 PM com.sun.xml.internal.ws.server.sei.TieHandler createResponse
SEVERE: / by zero
java.lang.ArithmeticException: / by zero
at helloservice.endpoint.Hello.sayHello(Hello.java:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.Trampoline.invoke(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.MethodUtil.invoke(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.xml.internal.ws.api.server.MethodUtil.invoke(Unknown Source)
at com.sun.xml.internal.ws.api.server.InstanceResolver$1.invoke(Unknown Source)
at com.sun.xml.internal.ws.server.InvokerTube$2.invoke(Unknown Source)
at com.sun.xml.internal.ws.server.sei.SEIInvokerTube.processRequest(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Unknown Source)
at com.sun.xml.internal.ws.server.WSEndpointImpl$2.process(Unknown Source)
at com.sun.xml.internal.ws.transport.http.HttpAdapter$HttpToolkit.handle(Unknown Source)
at com.sun.xml.internal.ws.transport.http.HttpAdapter.handle(Unknown Source)
at com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handleExchange(Unknown Source)
at com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handle(Unknown Source)
at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source)
at sun.net.httpserver.AuthFilter.doFilter(Unknown Source)
at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source)
at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(Unknown Source)
at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source)
at sun.net.httpserver.ServerImpl$Exchange.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
From there you can go look up these methods on grepcode for OpenJDK and see what's actually happening.
Tuesday, April 22, 2014
JAX-RS Labs
doing http://www.vogella.com/tutorials/REST/article.html
To view HTTP headers in Fiddler, add to vm arguments of run configuration
-DproxyHost=localhost
-DproxyPort=8888
then restart fiddler
Discovered that Jersey 1.x is deprecated in favor of Jersey 2 which uses Moxy instead of Jackson. The catch is that the latter don't play well with Tomcat, so I'll be abandoning tutorials on JAX-RS prior to 2011, and sticking to Glassfish.
To view HTTP headers in Fiddler, add to vm arguments of run configuration
-DproxyHost=localhost
-DproxyPort=8888
then restart fiddler
Discovered that Jersey 1.x is deprecated in favor of Jersey 2 which uses Moxy instead of Jackson. The catch is that the latter don't play well with Tomcat, so I'll be abandoning tutorials on JAX-RS prior to 2011, and sticking to Glassfish.
Monday, March 17, 2014
Tomcat Mutual Authentication
This worked: https://sites.google.com/site/paratumignempetere/software-development/security/mutually-authenticated-secure-socket-layer
Initially was following http://www.maximporges.com/2009/11/18/configuring-tomcat-ssl-clientserver-authentication/ but it used an outdated version of HttpClient.
This also looks interesting: https://github.com/skprasadu/enable-ssl-in-tomcat
Initially was following http://www.maximporges.com/2009/11/18/configuring-tomcat-ssl-clientserver-authentication/ but it used an outdated version of HttpClient.
This also looks interesting: https://github.com/skprasadu/enable-ssl-in-tomcat
Subscribe to:
Comments (Atom)