<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Matt Luce &#187; java</title>
	<atom:link href="http://mattluce.com/blog/category/technology/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://mattluce.com/blog</link>
	<description>Established 1975</description>
	<lastBuildDate>Sun, 04 Oct 2009 16:37:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Weblogic Web Services With Spring Framework</title>
		<link>http://mattluce.com/blog/2006/02/27/weblogic-web-services-with-spring-framework/</link>
		<comments>http://mattluce.com/blog/2006/02/27/weblogic-web-services-with-spring-framework/#comments</comments>
		<pubDate>Tue, 28 Feb 2006 03:17:49 +0000</pubDate>
		<dc:creator>Matt Luce</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://mattluce.com/blog/2006/02/27/weblogic-web-services-with-spring-framework/</guid>
		<description><![CDATA[Recently, I was trying to connect to a web service with the Spring Framework JaxRpcPortProxyFactoryBean.  The web service and client code were generated with the weblogic servicegen and clientgen ant tasks respectively.
I found this example on the dev2dev site:
http://dev2dev.bea.com/pub/a/2005/09/spring_integration_weblogic_server.html?page=3
Unfortunately, it didn&#8217;t work for me.  I spent almost an entire day trying to get [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I was trying to connect to a web service with the <a href="http://www.springframework.org/">Spring Framework</a> <a href="http://www.springframework.org/docs/api/org/springframework/remoting/jaxrpc/JaxRpcPortProxyFactoryBean.html">JaxRpcPortProxyFactoryBean</a>.  The web service and client code were generated with the weblogic <a href="http://edocs.bea.com/wls/docs81/webserv/anttasks.html#1063540">servicegen</a> and <a href="http://edocs.bea.com/wls/docs81/webserv/anttasks.html#1080160">clientgen</a> ant tasks respectively.</p>
<p>I found this example on the dev2dev site:<br />
<a href="http://dev2dev.bea.com/pub/a/2005/09/spring_integration_weblogic_server.html?page=3">http://dev2dev.bea.com/pub/a/2005/09/spring_integration_weblogic_server.html?page=3</a></p>
<p>Unfortunately, it didn&#8217;t work for me.  I spent almost an entire day trying to get it to work.  So, in hopes of saving someone else some time, I&#8217;ve posted the correct way to make this work below.  The example in the article is incorrect in one place.  It uses the wsdlDocumentUrl attribute of the JaxRpcPortProxyFactoryBean.  However, that attribute is a java.net.URL, not a String, so setting it with a string value will not work.  The value I entered for the wsdDocumentlUrl had no effect. Instead, you need to set the wsdl URL on the Impl class generated by clientgen, by passing it into the constructor as seen in the second bean definition below.</p>
<pre>
<code>
&lt;bean id="investorWebService"
        class="org.springframework.remoting.jaxrpc.JaxRpcPortProxyFactoryBean" lazy-init="true"&gt;
   &lt;property name="portName"&gt;
            &lt;value&gt;InvestorServicePort&lt;/value&gt;
    &lt;/property&gt;
    &lt;property name="serviceInterface"&gt;
            &lt;value&gt;com.xxx.fmg.investorservice.common.ws.InvestorServicePort&lt;/value&gt;
    &lt;/property&gt;
    &lt;property name="jaxRpcService"&gt;
            &lt;ref bean="investorServiceImpl"/&gt;
    &lt;/property&gt;
&lt;/bean&gt;

&lt;!-- allows the jaxRpcService class to execute its constructor --&gt;
&lt;bean id="investorServiceImpl"
        class="com.xxx.fmg.investorservice.common.ws.InvestorService_Impl" lazy-init="true"&gt;
        &lt;constructor -arg&gt;
            &lt;value&gt;http://server:port/InvestorService/InvestorService?WSDL&lt;/value&gt;
        &lt;/constructor&gt;
&lt;/bean&gt;
</code>
</pre>
<p><a href="http://www.springframework.org/">Spring Framework 2.0</a> is coming out in the next few months.  Supposedly there are some great new Web Service tools in that release.  If that&#8217;s the case we can stop using the web service tools provided by BEA.</p>
<div class="ttag">tags: <a href="http://www.technorati.com/tag/spring+framework" rel="tag">spring framework</a>, <a href="http://www.technorati.com/tag/bea" rel="tag">bea</a>, <a href="http://www.technorati.com/tag/j2ee" rel="tag">j2ee</a>, <a href="http://www.technorati.com/tag/web+service" rel="tag">web service</a>, <a href="http://www.technorati.com/tag/weblogic" rel="tag">weblogic</a>, <a href="http://www.technorati.com/tag/java" rel="tag">java</a></div>]]></content:encoded>
			<wfw:commentRss>http://mattluce.com/blog/2006/02/27/weblogic-web-services-with-spring-framework/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Secure Passwords for Datasources in Spring</title>
		<link>http://mattluce.com/blog/2005/08/12/secure-passwords-for-datasources-in-spring/</link>
		<comments>http://mattluce.com/blog/2005/08/12/secure-passwords-for-datasources-in-spring/#comments</comments>
		<pubDate>Fri, 12 Aug 2005 21:22:54 +0000</pubDate>
		<dc:creator>Matt Luce</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://mattluce.com/blog/?p=30</guid>
		<description><![CDATA[Security requirements at my place of employment don&#8217;t allow for plain text passwords in any type of configuration files.  So we are forced to store passwords encrypted and then decrypt them in every application that needs to create a database connection.  This wasn&#8217;t an issue for applications that run in a container as [...]]]></description>
			<content:encoded><![CDATA[<p>Security requirements at my place of employment don&#8217;t allow for plain text passwords in any type of configuration files.  So we are forced to store passwords encrypted and then decrypt them in every application that needs to create a database connection.  This wasn&#8217;t an issue for applications that run in a container as Weblogic encrypts the password, but it really limited our use of <a href="http://www.springframework.org">Spring</a> in non-container apps.    To get around this, I&#8217;ve created a new subclass of the Spring implementation of javax.sql.Datasource (<a href="http://www.springframework.org/docs/api/org/springframework/jdbc/datasource/DriverManagerDataSource.html">org.springframework.jdbc.datasource.DriverManagerDataSource</a>)  : <em>SecureDriverManagerDataSource</em> which overrides the getPassword() and getConnectionFromDriverManager() methods and adds a new attribute: key.  In my implementation of this class, an encrypted password is expected, so before calling the getConnection() method, the password is decrypted using the key attribute.  Here is the source code:   </p>
<p>public class SecureDriverManagerDataSource extends DriverManagerDataSource<br />
{<br />
&nbsp;&nbsp;&nbsp; private String key;</p>
<p>&nbsp;&nbsp;&nbsp; public String getKey()<br />
&nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return key;<br />
&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp; public void setKey(String key)<br />
&nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.key = key;<br />
&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp; public String getPassword()<br />
&nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (getKey() == null)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new RuntimeException(&quot;Key Value is not set&quot;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp; // possible future enhancement, allow user to set which type of encryption to use for this class<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return SimpleAESEncrypter.decrypt(super.getPassword(),getKey());<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch (SimpleAESEncrypterException e)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new RuntimeException(e.getMessage(),e);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp; protected Connection getConnectionFromDriverManager() throws SQLException<br />
&nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return getConnectionFromDriverManager(getUrl(),getUsername(), getPassword());<br />
&nbsp;&nbsp;&nbsp; }<br />
}</p>
<p>And the Spring Bean Defininition:</p>
<p>&lt;bean id=&quot;secureDataSource&quot; class=&quot;com.mattluce.db.SecureDriverManagerDataSource&quot; lazy-init=&quot;true&quot;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;property name=&quot;driverClassName&quot;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value&gt;com.sybase.jdbc2.jdbc.SybDriver&lt;/value&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/property&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;property name=&quot;url&quot;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value&gt;jdbc:sybase:Tds:dbserver:1234&lt;/value&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/property&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;property name=&quot;username&quot;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value&gt;dbuser&lt;/value&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/property&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;property name=&quot;password&quot;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value&gt;x345sdfxxxdasdf==&lt;/value&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/property&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;property name=&quot;key&quot;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value&gt;rxxrt56xxc5uuEO/A==&lt;/value&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/property&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;/bean&gt;  This implemenation uses our AES encryption utility, but it could be modified to set the encryption implentation as another attribute of the Datasource.  You could then set that in the Spring Bean Definition  as well <img src='http://mattluce.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="ttag">tags: <a href="http://www.technorati.com/tag/spring+framework" rel="tag">spring framework</a></div>]]></content:encoded>
			<wfw:commentRss>http://mattluce.com/blog/2005/08/12/secure-passwords-for-datasources-in-spring/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
