<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>Ricky's Hodgepodge</title>
    <link>http://blogs.nologin.es/rickyepoderi/</link>
    <description>···A little of everything···</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.3.1 - http://www.s9y.org/</generator>
    <pubDate>Sat, 18 May 2013 15:48:25 GMT</pubDate>

    <image>
        <url>http://blogs.nologin.es/rickyepoderi/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: Ricky's Hodgepodge - ···A little of everything···</title>
        <link>http://blogs.nologin.es/rickyepoderi/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>OCSP Java Bug (Part II)</title>
    <link>http://blogs.nologin.es/rickyepoderi/index.php?/archives/79-OCSP-Java-Bug-Part-II.html</link>
            <category>Java</category>
            <category>Security</category>
    
    <comments>http://blogs.nologin.es/rickyepoderi/index.php?/archives/79-OCSP-Java-Bug-Part-II.html#comments</comments>
    <wfw:comment>http://blogs.nologin.es/rickyepoderi/wfwcomment.php?cid=79</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blogs.nologin.es/rickyepoderi/rss.php?version=2.0&amp;type=comments&amp;cid=79</wfw:commentRss>
    

    <author>nospam@example.com (rickyepoderi)</author>
    <content:encoded>
    &lt;p&gt;As you have already seen in the previous entry, Debian 7.0 is now public and therefore I am using Jessie in testing. Openjdk 7 package is now update 21 (icedtea 2.3.9) and, as I promised, I finally upgraded from openjdk-6 to 7. Taking advantage of the situation I tested &lt;a href=&quot;http://blogs.nologin.es/rickyepoderi/index.php?/archives/77-BUG-in-Java-OCSP-Implementation-PKIX.html&quot;&gt;the previous OCSP issue I commented in this blog&lt;/a&gt; but with the new version.&lt;/p&gt;

&lt;p&gt;In 7u21 the issue is exactly the same but presenting different error messages. In the error cases the message presented is the following &lt;em&gt;Signature length not correct: got 256 but was expecting 128&lt;/em&gt;. Much more cryptic I have to say than the previous messages (&lt;em&gt;Error verifying OCSP Responder&#039;s signature&lt;/em&gt; or &lt;em&gt;Responder&#039;s certificate not valid for signing OCSP responses&lt;/em&gt;).&lt;/p&gt;

&lt;p&gt;Checking again the code the problem is still the same. Just the issuer certificate or the configured certificate is passed to the &lt;em&gt;OCSPResponse&lt;/em&gt;, so the cases 1 and 3 cannot be mixed with the case 2. But there is a good new, since &lt;a href=&quot;http://hg.openjdk.java.net/jdk7u/jdk7u/jdk/diff/52ab0f489dab/src/share/classes/sun/security/provider/certpath/OCSPChecker.java&quot;&gt;the following commit&lt;/a&gt; the &lt;em&gt;OCSP&lt;/em&gt; and &lt;em&gt;OCSPResponse&lt;/em&gt; classes accept a list of responder certificates (previously it was only one) and therefore now the fix is even easier. It just consists in adding both certs (issuer cert and configured responder if it is the case) to the list. so now the fix is &lt;a href=&quot;http://blogs.nologin.es/rickyepoderi/uploads/OCSPJavaBugPartII/OCSPChecker.patch&quot;&gt;a simpler patch that only changes the OCSPChecker class&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Talking about the bug I received an answer from Oracle telling me that the BUG has been accepted (it was around two months ago) but I have no more news since then. There is not a public link in the java database either. I am going to try to contact with icedtea guys to see what they think about that.&lt;/p&gt;

&lt;p&gt;Keep on trying!&lt;/p&gt; 
    </content:encoded>

    <pubDate>Sat, 18 May 2013 17:31:00 +0200</pubDate>
    <guid isPermaLink="false">http://blogs.nologin.es/rickyepoderi/index.php?/archives/79-guid.html</guid>
    
</item>
<item>
    <title>Debian 7.0 released!</title>
    <link>http://blogs.nologin.es/rickyepoderi/index.php?/archives/78-Debian-7.0-released!.html</link>
            <category>Debian</category>
    
    <comments>http://blogs.nologin.es/rickyepoderi/index.php?/archives/78-Debian-7.0-released!.html#comments</comments>
    <wfw:comment>http://blogs.nologin.es/rickyepoderi/wfwcomment.php?cid=78</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blogs.nologin.es/rickyepoderi/rss.php?version=2.0&amp;type=comments&amp;cid=78</wfw:commentRss>
    

    <author>nospam@example.com (rickyepoderi)</author>
    <content:encoded>
    &lt;p&gt;&lt;a href=&quot;http://www.debian.org/News/2013/20130504&quot;&gt;The Debian community has released today the next version of their famous Linux distribution&lt;/a&gt;. Following a two-year cycle and after ten months frozen the new version 7.0 (codename &lt;em&gt;wheezy&lt;/em&gt;) can be downloaded now from &lt;a href=&quot;http://www.debian.org/&quot;&gt;their website&lt;/a&gt;. As always it comes to light once all the critical bugs were fixed (something that never stops to amaze me):&lt;/p&gt;

&lt;div style=&quot;text-align:center;&quot;&gt;
&lt;a href=&quot;http://bugs.debian.org/release-critical/&quot;&gt;
&lt;img class=&quot;serendipity_image_center&quot; src=&quot;http://blogs.nologin.es/rickyepoderi/uploads/Debian7.0released/graph.png&quot; alt=&quot;debian bugs at 5 of May 2012&quot; /&gt;
&lt;/a&gt;
&lt;/div&gt;

&lt;p&gt;Good job guys and time to meet &lt;em&gt;Jessie&lt;/em&gt;!&lt;/p&gt; 
    </content:encoded>

    <pubDate>Sun, 05 May 2013 12:13:00 +0200</pubDate>
    <guid isPermaLink="false">http://blogs.nologin.es/rickyepoderi/index.php?/archives/78-guid.html</guid>
    
</item>
<item>
    <title>Glassfish HA using EJB</title>
    <link>http://blogs.nologin.es/rickyepoderi/index.php?/archives/76-Glassfish-HA-using-EJB.html</link>
            <category>Java</category>
    
    <comments>http://blogs.nologin.es/rickyepoderi/index.php?/archives/76-Glassfish-HA-using-EJB.html#comments</comments>
    <wfw:comment>http://blogs.nologin.es/rickyepoderi/wfwcomment.php?cid=76</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blogs.nologin.es/rickyepoderi/rss.php?version=2.0&amp;type=comments&amp;cid=76</wfw:commentRss>
    

    <author>nospam@example.com (rickyepoderi)</author>
    <content:encoded>
    &lt;p&gt;I have received some comments about &lt;a href=&quot;http://blogs.nologin.es/rickyepoderi/index.php?/archives/53-Simple-but-Full-Glassfish-HA-Using-Debian.html&quot;&gt;the old entry that installed a full glassfish HA solution using debian&lt;/a&gt;, people complain that the post did not deal with Stateful EJBs. A &lt;a href=&quot;http://www.jguru.com/faq/view.jsp?EID=917&quot;&gt;Stateful EJB&lt;/a&gt; is a enterprise bean that acts as a server-side extension of the client maintaining its state during calls (the bean object maintains its properties). Obviously this type of EJB has to also be replicated between the application server instances in case of an HA architecture. The reason for that oversight is clear, I am not a fan of remote EJBs, I always recommend to use local ones (which are deployed and called inside the same JVM and their performance is much better) or Web Services.&lt;/p&gt;

&lt;p&gt;Stateful EJBs should work smoothly in glassfish and today I am going to present a little example (and, as you will see later, I faced a very nasty issue). The first thing I did was installing the solution with glassfish 3.1.2.2, I repeated  the same steps explained in the previous entry one by one. When the (in)famous clusterjsp was running I started to develop and deploy a simple stateful EJB following &lt;a href=&quot;http://java.dzone.com/articles/clustering-stateful-session&quot;&gt;Markus Eisele&#039;s blog entry&lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The remote interface was created. The sample bean is just a counter with the count as the state to maintain/replicate:&lt;/p&gt;

&lt;pre&gt;
@Remote
public interface Sample {
    
    public String increment();
    
    public String reset();
    
    public String stop();
}
&lt;/pre&gt;
&lt;/li&gt;

&lt;li&gt;&lt;p&gt;The real EJB implementation is coded. The &lt;em&gt;increment&lt;/em&gt; method returns the instance name which is processing the call and the current value. The &lt;em&gt;stop&lt;/em&gt; method finishes the count and removes the EJB (the &lt;em&gt;@Remove&lt;/em&gt; annotation means that, when the client calls this method, the EJB can be destroyed).&lt;/p&gt;

&lt;pre&gt;
@Stateful(name=&quot;SampleBean&quot;)
@Remote(Sample.class)
public class SampleBean implements Sample, Serializable {

    private int count = 0;
     
    @Override
    public String increment() {
        return new StringBuilder(System.getProperty(&quot;com.sun.aas.instanceName&quot;))
                .append(&quot;: &quot;)
                .append(++count)
                .toString();
    }

    @Override
    public String reset() {
        count = 0;
        return new StringBuilder(System.getProperty(&quot;com.sun.aas.instanceName&quot;))
                .append(&quot;: reset to &quot;)
                .append(count)
                .toString();
    }

    @Override
    @Remove
    public String stop() {
        return new StringBuilder(System.getProperty(&quot;com.sun.aas.instanceName&quot;))
                .append(&quot;: releasing count on &quot;)
                .append(count)
                .toString();
    }   
}
&lt;/pre&gt;
&lt;/li&gt;

&lt;li&gt;&lt;p&gt;The EJB is packed in a JAR and the JAR inside an EAR, then it is deployed with availability enabled (exactly as a web WAR application file).&lt;/p&gt;

&lt;pre&gt;
$ ./asadmin deploy --availabilityenabled=true --target cluster1 ~/clusterejb.ear 
Application deployed with name clusterejb.
Command deploy executed successfully.
&lt;/pre&gt;

&lt;p&gt;At this point the JNDI name for the EJB should be available (the relative path depends on the names used in ear and ejb-jar files):&lt;/p&gt;

&lt;pre&gt;
$ ./asadmin list-jndi-entries --context &quot;java:global/clusterejb/clusterejb-ejb&quot; cluster1
debian1-gf:
SampleBean__3_x_Internal_RemoteBusinessHome__: javax.naming.Reference
SampleBean: javax.naming.Reference
SampleBean!es.rickyepoderi.sample.Sample: javax.naming.Reference

debian2-gf:
SampleBean__3_x_Internal_RemoteBusinessHome__: javax.naming.Reference
SampleBean: javax.naming.Reference
SampleBean!es.rickyepoderi.sample.Sample: javax.naming.Reference
&lt;/pre&gt;
&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Finally I created a simple test client that connects to the remote EJB and calls the &lt;em&gt;increment&lt;/em&gt; method. The client performs two iterations, the internal one increments the EJB and the outer loop just creates another EJB (so you can repeat the counting loop as many times as you want).&lt;/p&gt;

&lt;pre&gt;
public class Test {
    static public void main(String[] args) throws Exception {
        InitialContext ic = null;
        Sample sample = null;
        Properties env = new Properties();
        String ans;
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        do {
            try {
                ic = new InitialContext(env);
                String lookup = &quot;java:global/clusterejb/clusterejb-ejb/&quot; +
                    &quot;SampleBean!es.rickyepoderi.sample.Sample&quot;;
                System.out.println(&quot;Retrieving &quot; + lookup);
                sample = (Sample) ic.lookup(lookup);
                do {
                    System.out.println(sample.increment());
                    System.out.print(&quot;More (Y/n): &quot;);
                    ans = in.readLine();
                } while (!ans.equalsIgnoreCase(&quot;n&quot;));
            } finally {
                if (sample != null) {
                    System.out.println(&quot;Stoping count!!!&quot;);
                    try {System.out.println(sample.stop());} catch (Exception e) {}
                }
                if (ic != null) {
                    System.out.println(&quot;Closing context!!!&quot;);
                    try {ic.close();} catch (Exception e) {}
                }                
            }
            System.out.print(&quot;New EJB (Y/n): &quot;);
            ans = in.readLine();
        } while (!ans.equalsIgnoreCase(&quot;n&quot;));
    }
}
&lt;/pre&gt;
&lt;/li&gt;

&lt;li&gt;&lt;p&gt;The client is executed in the following way:&lt;/p&gt;

&lt;pre&gt;
$ java -Dcom.sun.appserv.iiop.endpoints=debian1.demo.kvm:23700,debian2.demo.kvm:23700 \
  -cp .:/home/ricky/glassfish3/glassfish/lib/gf-client.jar es.rickyepoderi.client.Test
&lt;/pre&gt;

&lt;p&gt;In theory the glassfish provider gets the specified property (&lt;em&gt;com.sun.appserv.iiop.endpoints&lt;/em&gt;) and constructs a specific environment for the JNDI lookup similar to the following (that environment can be used directly in the code too):&lt;/p&gt;

&lt;pre&gt;
Properties env = new Properties();
env.put(&quot;java.naming.factory.initial&quot;, 
  &quot;com.sun.enterprise.naming.impl.SerialInitContextFactory&quot;);
env.put(&quot;java.naming.factory.state&quot;, 
  &quot;com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl&quot;);
env.put(&quot;com.sun.appserv.ee.iiop.endpointslist&quot;,
  &quot;corbaloc:iiop:1.2@debian1.demo.kvm:23700,iiop:1.2@debian2.demo.kvm:23700&quot;);
&lt;/pre&gt;

&lt;p&gt;It uses the &lt;em&gt;SerialInitContextFactory&lt;/em&gt; and constructs the corbaloc URL using both servers. Besides it randomizes the order (sometimes &lt;em&gt;debian1&lt;/em&gt; will be the primary and &lt;em&gt;debian2&lt;/em&gt; the alternative and sometimes the other way around) so the solution gets some balancing over the servers (take in mind the order is assigned at context creation).&lt;/p&gt;

&lt;p&gt;At this point the client should just work but I faced a very weird problem. When the test application was connected to the &lt;em&gt;debian1-gf&lt;/em&gt; instance everything worked as expected, but when the client connected to the &lt;em&gt;debian2-gf&lt;/em&gt; one no failover was done. The client application hung trying to always connect to the second instance even thought that server was down. I spent all the morning trying to find what the hell was happening and finally I understood the situation.&lt;/p&gt;

&lt;p&gt;In RMI/IIOP it seems that the server architecture is managed during conversation, I mean, although I set both servers in the property (and in turn in the corbaloc URL), when the client contacts with the primary server the servers are defined again using the &lt;a href=&quot;http://en.wikipedia.org/wiki/Interoperable_Object_Reference&quot;&gt;IOR field (Interoperable Object Reference)&lt;/a&gt;. And my problem was that &lt;em&gt;debian1&lt;/em&gt; returned both (&lt;em&gt;debian1&lt;/em&gt; and &lt;em&gt;debian2&lt;/em&gt;) in the reference but &lt;em&gt;debian2&lt;/em&gt; returned itself twice (no &lt;em&gt;debian1&lt;/em&gt; was answered as a valid alternative server). Finally (and with a big headache as a result) the problem was that glassfish uses nodes as the corba servers and, if you re-check how they were created, I created &lt;em&gt;debian1-ssh&lt;/em&gt; node as localhost and &lt;em&gt;debian2-ssh&lt;/em&gt; with the real hostname (I thought the nodes were only used for management purposes). So &lt;em&gt;debian1&lt;/em&gt; used &lt;em&gt;localhost&lt;/em&gt; and &lt;em&gt;debian2&lt;/em&gt; (&lt;em&gt;debian1&lt;/em&gt; and &lt;em&gt;debian2&lt;/em&gt;) and &lt;em&gt;debian2&lt;/em&gt; &lt;em&gt;localhost&lt;/em&gt; and &lt;em&gt;debian2&lt;/em&gt; (&lt;em&gt;debian2&lt;/em&gt; and &lt;em&gt;debian2&lt;/em&gt;), that produced the annoying issue explained before. So I changed the node directly in the &lt;em&gt;domain.xml&lt;/em&gt; configuration file:&lt;/p&gt;

&lt;pre&gt;
&amp;lt;node node-host=&quot;debian1.demo.kvm&quot; name=&quot;debian1-ssh&quot; 
 type=&quot;SSH&quot; install-dir=&quot;${com.sun.aas.productRoot}&quot;&amp;gt;
  &amp;lt;ssh-connector&amp;gt;
    &amp;lt;ssh-auth&amp;gt;&amp;lt;/ssh-auth&amp;gt;
  &amp;lt;/ssh-connector&amp;gt;
&amp;lt;/node&amp;gt;
&lt;/pre&gt;

&lt;p&gt;But obviously the correct solution would have been creating the &lt;em&gt;debian1-ssh&lt;/em&gt; node using the real hostname:&lt;/p&gt;

&lt;pre&gt;
$ ./asadmin create-node-ssh --nodehost debian1.demo.kvm debian1-ssh
&lt;/pre&gt;

&lt;p&gt;I confess that I do not know if those names can be forced somehow (maybe some configuration in glassfish let use specific names and not the names of the nodes, but it does not matter much right now). As usual it was much more complicated realizing what was going on than fixing the issue.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;&lt;p&gt;After that I successfully tested the EJB. Iterating over the first loop the server changes (randomly the client provider change the primary server from &lt;em&gt;debian1&lt;/em&gt; to &lt;em&gt;debian2&lt;/em&gt;). When I was being served by a specific server (&lt;em&gt;debian1&lt;/em&gt;) and that server was shutting down, the alternate (&lt;em&gt;debian2&lt;/em&gt;) continued the counting. The count is preserved without problem cos replication is maintaining the state of the EJB. Here it is the video that shows the previous explanation.&lt;/p&gt;

&lt;video src=&quot;http://blogs.nologin.es/rickyepoderi/uploads/GlassfishHAusingEJB/out.webm&quot; autobuffer controls&gt;
&lt;img src=&quot;http://blogs.nologin.es/rickyepoderi/uploads/categories/error.png&quot; alt=&quot;Error!&quot; /&gt;
Your browser doesn&#039;t support the video tag. See this &lt;a href=&quot;http://blogs.nologin.es/rickyepoderi/index.php?/archives/41-Videos-Are-About-to-Change-Second-Time-Lucky.html&quot;&gt;entry&lt;/a&gt; for more information about how to see the videos in this blog. You can &lt;a href=&quot;http://blogs.nologin.es/rickyepoderi/uploads/GlassfishHAusingEJB/out.webm&quot;&gt;download the file&lt;/a&gt; instead.
&lt;/video&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Today&#039;s entry complements a previous one of the blog (simple but full glassfish HA using debian), that entry tested only the web part but some people have commented to me what happened with a Stateful EJB. Usually that type of EJB should work in the HA scenario smoothly but a weird problem happened to me, using localhost instead of the real hostname for node creation complicated my solution. Once that issue was fixed the solution worked smoothly and EJB HA was assured by the glassfish cluster. Here I upload &lt;a href=&quot;http://blogs.nologin.es/rickyepoderi/uploads/GlassfishHAusingEJB/clusterejb.zip&quot;&gt;the clusterejb project&lt;/a&gt; I used in the entry. The moral is glassfish replication also works with stateful EJBs. &lt;img src=&quot;http://blogs.nologin.es/rickyepoderi/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt; &lt;/p&gt;

&lt;p&gt;Replicated regards!&lt;/p&gt; 
    </content:encoded>

    <pubDate>Sun, 07 Apr 2013 11:24:00 +0200</pubDate>
    <guid isPermaLink="false">http://blogs.nologin.es/rickyepoderi/index.php?/archives/76-guid.html</guid>
    
</item>
<item>
    <title>BUG in Java OCSP Implementation (PKIX)?</title>
    <link>http://blogs.nologin.es/rickyepoderi/index.php?/archives/77-BUG-in-Java-OCSP-Implementation-PKIX.html</link>
            <category>Java</category>
            <category>Security</category>
    
    <comments>http://blogs.nologin.es/rickyepoderi/index.php?/archives/77-BUG-in-Java-OCSP-Implementation-PKIX.html#comments</comments>
    <wfw:comment>http://blogs.nologin.es/rickyepoderi/wfwcomment.php?cid=77</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blogs.nologin.es/rickyepoderi/rss.php?version=2.0&amp;type=comments&amp;cid=77</wfw:commentRss>
    

    <author>nospam@example.com (rickyepoderi)</author>
    <content:encoded>
    &lt;p&gt;Today&#039;s entry is going to explain an issue I had some weeks ago with an &lt;a href=&quot;http://en.wikipedia.org/wiki/Online_Certificate_Status_Protocol&quot;&gt;OCSP (Online Certificate Status Protocol)&lt;/a&gt; responder. I had to use a specific responder which worked in such a way that I was not able to make Java work against it. I did not understand what was happening and I decided to test the problem more deeply in this entry.&lt;/p&gt;

&lt;p&gt;Let&#039;s start explaining how an OCSP responder works: the server receives requests from clients which want to check if a specific certificate is revoked; the responder checks the status of the certificate and answers if it is &lt;em&gt;good&lt;/em&gt;, &lt;em&gt;revoked&lt;/em&gt; or &lt;em&gt;unknown&lt;/em&gt;; cos the protocol is affected by man in the middle attacks the response is signed; usually the response is signed by the same CA that issued the certificate being checked. And here my issue appears, my specific OCSP server checked certificates issued by different CAs, and to do that it followed two rules:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If the certificate to be checked is issued by one of their CAs, the response was signed by the same CA (common situation).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;But if the certificate was issued by a partner authority it was signed by a special certificate issued by themselves.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I could not configure Java to work against that OCSP responder. So I decided to read what &lt;a href=&quot;http://www.ietf.org/rfc/rfc2560.txt&quot;&gt;RFC2560&lt;/a&gt; (the standard that defines OCSP protocol) says, and this is the important part:&lt;/p&gt;

&lt;blockquote&gt;
All definitive response messages SHALL be digitally signed. The key
   used to sign the response MUST belong to one of the following:

&lt;ol&gt;&lt;li&gt;the CA who issued the certificate in question&lt;/li&gt;
   &lt;li&gt;a Trusted Responder whose public key is trusted by the requester&lt;/li&gt;
   &lt;li&gt;a CA Designated Responder (Authorized Responder) who holds a specially marked certificate issued directly by the CA, indicating that the responder may issue OCSP responses for that CA&lt;/li&gt;
&lt;/blockquote&gt;

&lt;p&gt;There are three possibilities or cases, which I will try to explain a bit more:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Case 1&lt;/strong&gt;: The certificate used to sign the response is the same certificate which issued the certificate being checked. This is the most common situation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Case 2&lt;/strong&gt;: The response is signed by a trusted certificate for the client. That means the requester should know before that certificate and configure it someway to trust in the OCSP responses.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Case 3&lt;/strong&gt;: The response is signed by a certificate which has a special extension (&lt;em&gt;OCSPSigning&lt;/em&gt;) to inform that it is able to sign OCSP responses, besides it must be issued by the same CA which issued the certificate being checked. This case is used to delegate OCSP responders to a partner CA.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you recheck what my responder was doing, it was using case 1 for its own certificates (common case) and case 2 for foreign certificates (the one in which the client should know the certificate used in order to trust in the responses). Therefore I understand that the OCSP responder was working well, its behavior is covered by the standard.&lt;/p&gt;

&lt;p&gt;OCSP in Java is part of its Public-Key Infrastructure (PKIX) implementation. It has &lt;a href=&quot;http://docs.oracle.com/javase/6/docs/technotes/guides/security/certpath/CertPathProgGuide.html#AppC&quot;&gt;several properties defined in the Security configuration for controlling the checking process&lt;/a&gt;. Let&#039;s summarize the most important:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ocsp.enable&lt;/strong&gt;. Setting this property to true the OCSP checking is used for validating certificates (CRL is always enabled but not OCSP).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ocsp.responderURL&lt;/strong&gt;. Property that fixes the use of an OCSP server instead the one provided by the certificate extended properties.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ocsp.responderCertSubjectName&lt;/strong&gt;. Property to fix the certificate used by the responder to sing responses (there are other properties for doing the same thing). This option is used for the case 2 defined in the standard.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;At this point I decided to create an openssl ocsp environment which tested the three possibilities, for that I need a client certificate and three certificates for the OCSP responder (I followed similar commands to the ones I used in &lt;a href=&quot;http://blogs.nologin.es/rickyepoderi/index.php?/archives/46-Certificate-Security-in-JavaEE-Demo-Setup.html&quot;&gt;this previous entry&lt;/a&gt;):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;cakey.pem/cacert.pem&lt;/strong&gt;: RSA key and certificate of the demo CA (self-signed). If it is used in the OCSP responder the case 1 is tested (password &lt;em&gt;Kiosko_00&lt;/em&gt; to be used).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ocsp-trusted.key/ocsp-trusted.pem&lt;/strong&gt;: The certificate is signed by the CA but with no special &lt;em&gt;OCSPSigning&lt;/em&gt; extension. The pair will be used as the responder certificate for the case 2, the client should be configured to trust in that certificate.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ocsp-signing.key/ocsp-signing.pem&lt;/strong&gt;: The pair used for case 3, the certificate is signed by the CA and has the &lt;em&gt;OCSPSigning&lt;/em&gt; extension (see &lt;a href=&quot;http://isrlabs.net/wordpress/?p=169&quot;&gt;this blog entry to see how I did it&lt;/a&gt;). Cos it is signed by the same CA it works without any configuration at client side.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;client1.pem&lt;/strong&gt;: The certificate to be checked (signed by the same demo CA).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This &lt;a href=&quot;http://blogs.nologin.es/rickyepoderi/uploads/BUGinJavaOCSPImplementationPKIX/demoCA.zip&quot;&gt;zip file contains the demoCA directory&lt;/a&gt; with all the openssl configuration to launch the ocsp responder. I developed a &lt;a href=&quot;http://blogs.nologin.es/rickyepoderi/uploads/BUGinJavaOCSPImplementationPKIX/CertificateChecker.java&quot;&gt;simple Java&lt;/a&gt; to test PKIX validation in the three scenarios. The program sets to true &lt;em&gt;ocsp.enable&lt;/em&gt; and uses the fourth and fifth argument to set the &lt;em&gt;ocsp.responderURL&lt;/em&gt; and the &lt;em&gt;ocsp.responderCertSubjectName&lt;/em&gt; (this argument is optional). Previous arguments are the client certificate to check, the cacerts keystore to use and the password of the keystore. I tested the three possible scenarios:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Case 1&lt;/strong&gt;: The program checks &lt;em&gt;client1&lt;/em&gt; certificate against openssl OCSP launched with demo CA as the response signer.&lt;/p&gt;

&lt;pre&gt;
$ openssl ocsp -index demoCA/index.txt -CA demoCA/cert/cacert.pem \
  -rsigner demoCA/cert/cacert.pem -rkey demoCA/private/cakey.pem -port 3456 -text
&lt;/pre&gt;

&lt;p&gt;In order to work in this case the Java program should be launched with no certificate fixed as the responder one:&lt;/p&gt;

&lt;pre&gt;
$ java -cp . CertificateChecker client1.pem cacerts.demo changeme http://localhost:3456
Loading certificate...
Loading cacerts...
Performing PKIX validation...
Result: OK
&lt;/pre&gt;

&lt;p&gt;The demo CA should be imported in the &lt;em&gt;cacerts.demo&lt;/em&gt; keystore (our demo CA must be trusted for the Java program).&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;strong&gt;Case 2&lt;/strong&gt;: Now the ocsp server is started using the &lt;em&gt;ocsp-trusted&lt;/em&gt; key and certificate, remember this one has no special extension.&lt;/p&gt;

&lt;pre&gt;
$ openssl ocsp -index demoCA/index.txt -CA demoCA/cert/cacert.pem \
  -rsigner demoCA/cert/ocsp-trusted.pem -rkey demoCA/private/ocsp-trusted.key \
  -port 3456 -text
&lt;/pre&gt;

&lt;p&gt;In the second scenario Java should be configured in such a way that the client knows the certificate used in the responses. The &lt;em&gt;ocsp-trusted&lt;/em&gt; certificate was added to the keystore and the fifth argument was passed to mark that this specified subject is used to sign the responses.&lt;/p&gt;

&lt;pre&gt;
$ java -cp . CertificateChecker client1.pem cacerts.demo changeme \
  http://localhost:3456 &quot;CN=OCSP-TRUSTED, O=demo.kvm, ST=demo, C=ES&quot;
Loading certificate...
Loading cacerts...
Performing PKIX validation...
Result: OK
&lt;/pre&gt;

&lt;p&gt;So it works, if the subject of the responder certificate is specified the Java program trusts in its responses.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;strong&gt;Case 3&lt;/strong&gt;: The ocsp server is launched using the &lt;em&gt;ocsp-signing&lt;/em&gt; key and certificate, that certificate is signed with the &lt;em&gt;OCSPSigning&lt;/em&gt; extension.&lt;/p&gt;

&lt;pre&gt;
$ openssl ocsp -index demoCA/index.txt -CA demoCA/cert/cacert.pem \
  -rsigner demoCA/cert/ocsp-signing.pem -rkey demoCA/private/ocsp-signing.key \
  -port 3456 -text
&lt;/pre&gt;

&lt;p&gt;Now in order to work the client program it should be started again but without any specific certificate set as an argument.&lt;/p&gt;

&lt;pre&gt;
$ java -cp . CertificateChecker client1.pem cacerts.demo changeme http://localhost:3456 
Loading certificate...
Loading cacerts...
Performing PKIX validation...
Result: OK
&lt;/pre&gt;

&lt;p&gt;It works again. Java PKIX implementation checks that the certificate used has the &lt;em&gt;OCSPSigning&lt;/em&gt; extension and the issuer of that certificate is the same that the issuer of &lt;em&gt;client1&lt;/em&gt; certificate.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I know, now you are saying but what the hell, Java supports all the possibilities. Where is the problem? A different configuration is needed to accomplish the three cases. Case 2 only works if the property &lt;em&gt;ocsp.responderCertSubjectName&lt;/em&gt; is set (or any other option that fixes the certificate used for signing responses) but case 1 and 3 only works with that property not set. There is no way to configure the Java Security in a way that handles the three scenarios at the same time. What happens if there is an OCSP server whose responses use mixed cases? You are in a big problem if case 2 is involved. If you remember the responder I commented in the introduction, it works using cases 1 and 2, I would have never got it working no matter the time I had spent. It was absolutely impossible.&lt;/p&gt;

&lt;p&gt;First question, does the standard support that an OCSP responder uses all the scenarios at the same time? Or does it force the responder to not mix case 2 with the other two? I have not read anything against the first sentence and Java supports cases 1 and 3 at the same time, so why not case 2. Second question, is mixing case 2 with any of the other cases useful for a responder? I think it is, it is quite reasonable that the responder uses case 1 (the common method) for their own certificates and case 2 for certificates issued by other authorities (case 3 is also valid but you need the partner authority to sign a certificate for you). Remember that case 1 does not need client configuration and case 2 does need it, so it is logical to minimize the use of case 2. I think this is a BUG in the Java implementation and I will try to report it. If any of you is an expert in OCSP please let me know your thoughts.&lt;/p&gt;

&lt;p&gt;As you know I try to be a good neighbor and I checked why Java worked that way. Looking the code for &lt;a href=&quot;http://download.java.net/openjdk/jdk6/&quot;&gt;openjdk6 b27 (last bundle released for version 6 at the moment)&lt;/a&gt; I checked that class &lt;em&gt;sun.security.provider.certpath.OCSPChecker&lt;/em&gt; chooses the responder certificate from the properties defined in the Security configuration or from the issuer of the certificate that is going to be validated. It is one or the other. Then the class &lt;em&gt;sun.security.provider.certpath.OCSPResponse&lt;/em&gt; receives that certificate as a parameter and validates the sign. &lt;em&gt;OCSPResponse&lt;/em&gt; covers cases 1 and 3, the certificate used for signing can be the one passed as an argument or another certificate which has the &lt;em&gt;OCSPSigning&lt;/em&gt; extension and was issued by the argument cert. That is the reason Java/PKIX isolates case 2 from the other two scenarios.&lt;/p&gt;

&lt;p&gt;Because I spent so much time guessing all of this I decided to make a patch. The fix involves the two classes commented in the previous paragraph and another one which is an intermediary class between them (&lt;em&gt;OCSP&lt;/em&gt; class in the same package). In my solution &lt;em&gt;OCSPResponse&lt;/em&gt; class receives two arguments: the issuer cert (the certificate which issues the client certificate to be checked) and the responder cert (the certificate defined in the Security properties, it can be null). With both certs the class can check the three cases at the same OCSP response, including the reviled scenario 2. Here it is &lt;a href=&quot;http://blogs.nologin.es/rickyepoderi/uploads/BUGinJavaOCSPImplementationPKIX/ocsp.patch&quot;&gt;my patch&lt;/a&gt;. With the new classes no matter how the openssl ocsp responder is started (any case) the same configuration for the Java program works:&lt;/p&gt;

&lt;pre&gt;
$ java -Xbootclasspath/p:/home/ricky/Desktop/jdk-patch/src/share/classes/ \
  -Djava.security.debug=certpath -cp . CertificateChecker client1.pem cacerts.demo \
  changeme http://localhost:3456 &quot;CN=OCSP-TRUSTED, O=demo.kvm, ST=demo, C=ES&quot;
&lt;/pre&gt;

&lt;p&gt;The previous command works for the three certificates (&lt;em&gt;demoCA&lt;/em&gt; case 1, &lt;em&gt;ocsp-trusted&lt;/em&gt; case 2 and &lt;em&gt;ocsp-signing&lt;/em&gt; case 3) cos I am prepending my modified classes to the boot classpath. The same arguments, the same configuration works no matter which case the responder uses. Cos explanation for this issue is so long and complex I posted the entry before reporting the BUG (I will link this entry from the BUG explanation). I opened another BUG before but I had not understood the problem completely and people at Java team did not say anything to me (I was half wrong so it is fair).&lt;/p&gt;

&lt;p&gt;Let&#039;s see what happens now!&lt;/p&gt;
 
    </content:encoded>

    <pubDate>Fri, 15 Mar 2013 21:04:00 +0100</pubDate>
    <guid isPermaLink="false">http://blogs.nologin.es/rickyepoderi/index.php?/archives/77-guid.html</guid>
    
</item>
<item>
    <title>SPNEGO/Kerberos in JavaEE (spnego.java.net)</title>
    <link>http://blogs.nologin.es/rickyepoderi/index.php?/archives/74-SPNEGOKerberos-in-JavaEE-spnego.java.net.html</link>
            <category>Java</category>
            <category>Security</category>
    
    <comments>http://blogs.nologin.es/rickyepoderi/index.php?/archives/74-SPNEGOKerberos-in-JavaEE-spnego.java.net.html#comments</comments>
    <wfw:comment>http://blogs.nologin.es/rickyepoderi/wfwcomment.php?cid=74</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blogs.nologin.es/rickyepoderi/rss.php?version=2.0&amp;type=comments&amp;cid=74</wfw:commentRss>
    

    <author>nospam@example.com (rickyepoderi)</author>
    <content:encoded>
    &lt;p&gt;Two previous entries of the blog were dedicated to the SPNEGO/Kerberos login. The first one just &lt;a href=&quot;http://blogs.nologin.es/rickyepoderi/index.php?/archives/72-SPNEGOKerberos-in-JavaEE.html&quot;&gt;used the Java Filter SPNEGO project to perform a silent login using windows native authentication&lt;/a&gt;. The second one &lt;a href=&quot;http://blogs.nologin.es/rickyepoderi/index.php?/archives/73-SPNEGOKerberos-in-JavaEE-PAC.html&quot;&gt;extended the solution adding the group SIDs to the principal using the Microsoft PAC extension&lt;/a&gt;. Remember that the solution for the second entry consisted in a horrible JAR which used several other projects (or part of projects) like &lt;em&gt;SPNEGO&lt;/em&gt;, &lt;em&gt;BouncyCastle&lt;/em&gt;, &lt;em&gt;jaaslounge&lt;/em&gt; or &lt;em&gt;Spring&lt;/em&gt; to read the SIDs. Finally I had the time to perform a better and cleaner integration.&lt;/p&gt;

&lt;p&gt;Instead of the SPNEGO filter that I have used in the two entries I changed to the &lt;a href=&quot;http://spnego.java.net&quot;&gt;spnego.java.net project&lt;/a&gt;. This project is a standard &lt;a href=&quot;http://docs.oracle.com/javaee/6/api/javax/security/auth/message/module/ServerAuthModule.html&quot;&gt;ServerAuthModule&lt;/a&gt; for Glassfish that performs the SPNEGO protocol and injects the principal (it works in a way very similar to the SPNEGO filter). But as it is integrated more deeply in the application server, group principals are much easier to integrate. The last version 1.1 of the library is two years old (it seems that that is a common rule for all the projects related to SPNEGO in Java).&lt;/p&gt;

&lt;p&gt;The first thing I did was installing the module in glassfish and modifying the hello application to use it. Following &lt;a href=&quot;http://spnego.java.net/documentation/configuring_spnego_in_glassfish.html&quot;&gt;the installation instructions&lt;/a&gt; the task was done smoothly. Although the documentation always talks abouts v2 it also runs in v3 with no change (cos &lt;em&gt;ServerAuthModule&lt;/em&gt; is a standard interface in JavaEE some kind of integration is assured). At the end, the Kerberos principal was injected in the hello WAR application as in the first entry of this series.

&lt;p&gt;If you check the code of the &lt;a href=&quot;http://java.net/projects/spnego/sources/svn/content/trunk/core/src/main/java/net/java/spnego/ExampleSpnegoServerAuthModule.java&quot;&gt;ExampleSpnegoServerAuthModule&lt;/a&gt;, the class overrides the &lt;em&gt;getGroupsForCaller&lt;/em&gt; method to inject two hardcoded group names (&lt;em&gt;authenticated&lt;/em&gt; and &lt;em&gt;allowed&lt;/em&gt;). So in order to add the real group SIDs from PAC that method should be overridden. Besides I decided to not use &lt;em&gt;Bouncy Castle&lt;/em&gt; ASN.1 implementation (it is an enormous JAR I wanted to avoid) and restrict to the minimum the &lt;em&gt;jaaslounge&lt;/em&gt; classes (do you remember my frankenjar of the previous entry?). So in summary the main points of the new implementation are the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The &lt;em&gt;getGroupsForCaller&lt;/em&gt; method was changed to receive more arguments (original abstract method only had the Principal as argument). In order to parse the PAC more inputs are needed. So I decided to include everything in the method:&lt;/p&gt;

&lt;pre&gt;
public abstract String[] getGroupsForCaller(MessageInfo messageInfo, 
            GSSContext gssContext) throws AuthException;
&lt;/pre&gt;

&lt;p&gt;Now the method receive the &lt;em&gt;MessageInfo&lt;/em&gt; and the &lt;em&gt;GSSContext&lt;/em&gt;, which has just validated the Kerberos token. This way any extension class will have all the needed inputs.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;A new &lt;em&gt;PACSpnegoServerAuth&lt;/em&gt; class was implemented. It obviously extends the &lt;em&gt;SpnegoServerAuthModule&lt;/em&gt; and implements the new version of the &lt;em&gt;getGroupsForCaller&lt;/em&gt; method. &lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;The ASN.1 parsing uses &lt;a href=&quot;http://javasourcecode.org/html/open-source/jdk/jdk-6u23/sun/security/util/&quot;&gt;the internal sun.security.util package&lt;/a&gt;. Take into account that as &lt;em&gt;DerInputStream&lt;/em&gt; or &lt;em&gt;DerValue&lt;/em&gt; classes are internal they can change (for example in a future version or in other JavaSE implementations -IBM for example-). Although this decision is not perfect I prefer it better than the &lt;em&gt;Bouncy Castle&lt;/em&gt; option.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Part of the kerberos data should be decrypted to get the PAC and, for that, the server keys are needed. In turn a logged subject is needed to get the keys. So the new module performs a login at initialization (using defined krb5 login module) and a logout at finalize (there is no dispose or similar method in the &lt;em&gt;ServerAuthModule&lt;/em&gt; interface so I was forced to add it in the finalize method).&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Finally only a few classes (six) of the &lt;em&gt;jaaslounge&lt;/em&gt; project were added, only the classes that deals with the PAC, more specifically the login info part (where the groups SIDs are). I renamed the package to &lt;em&gt;net.java.spnego.pac&lt;/em&gt; and did some minor changes.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;The module keeps on just parsing the token in the first access and storing the group SIDs in the Java session, where they are retrieved from in the following requests.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;With all these changes the final library only depends in Sun JavaSE (remember the &lt;em&gt;sun.security.util&lt;/em&gt; utilization) and &lt;em&gt;commons-codec&lt;/em&gt;. And the beautiful result of all this work is that now the SIDs can be mapped in &lt;em&gt;web.xml&lt;/em&gt; and &lt;em&gt;glassfish-web.xml&lt;/em&gt; configuration files. For example the new hello application &lt;em&gt;web.xml&lt;/em&gt; defines some groups as roles:&lt;/p&gt;

&lt;pre&gt;
    &amp;lt;security-role&amp;gt;
        &amp;lt;role-name&amp;gt;Domain Users&amp;lt;/role-name&amp;gt;
    &amp;lt;/security-role&amp;gt;
    &amp;lt;security-role&amp;gt;
        &amp;lt;role-name&amp;gt;Domain Admins&amp;lt;/role-name&amp;gt;
    &amp;lt;/security-role&amp;gt;
    &amp;lt;security-role&amp;gt;
        &amp;lt;role-name&amp;gt;group1&amp;lt;/role-name&amp;gt;
    &amp;lt;/security-role&amp;gt;
    &amp;lt;security-role&amp;gt;
        &amp;lt;role-name&amp;gt;group2&amp;lt;/role-name&amp;gt;
    &amp;lt;/security-role&amp;gt;
    &amp;lt;security-role&amp;gt;
        &amp;lt;role-name&amp;gt;group3&amp;lt;/role-name&amp;gt;
    &amp;lt;/security-role&amp;gt;
&lt;/pre&gt;

&lt;p&gt;And only users in the domain can access the application:&lt;/p&gt;

&lt;pre&gt;
    &amp;lt;security-constraint&amp;gt;
        &amp;lt;web-resource-collection&amp;gt;
            &amp;lt;web-resource-name&amp;gt;Authentication Required&amp;lt;/web-resource-name&amp;gt;
            &amp;lt;url-pattern&amp;gt;/*&amp;lt;/url-pattern&amp;gt;
            &amp;lt;http-method&amp;gt;GET&amp;lt;/http-method&amp;gt;
            &amp;lt;http-method&amp;gt;POST&amp;lt;/http-method&amp;gt;
        &amp;lt;/web-resource-collection&amp;gt;
        &amp;lt;auth-constraint&amp;gt;
            &amp;lt;role-name&amp;gt;Domain Users&amp;lt;/role-name&amp;gt;
        &amp;lt;/auth-constraint&amp;gt;
    &amp;lt;/security-constraint&amp;gt;
&lt;/pre&gt;

&lt;p&gt;But the new solution lets us map the SIDs in the &lt;em&gt;glassfish-web.xml&lt;/em&gt; (proprietary) file:&lt;/p&gt;

&lt;pre&gt;
    &amp;lt;security-role-mapping&amp;gt;
        &amp;lt;role-name&amp;gt;Domain Users&amp;lt;/role-name&amp;gt;
        &amp;lt;group-name&amp;gt;S-1-5-21-2145774160-2038213957-1596523949-513&amp;lt;/group-name&amp;gt;
    &amp;lt;/security-role-mapping&amp;gt;
    &amp;lt;security-role-mapping&amp;gt;
        &amp;lt;role-name&amp;gt;Domain Admins&amp;lt;/role-name&amp;gt;
        &amp;lt;group-name&amp;gt;S-1-5-21-2145774160-2038213957-1596523949-512&amp;lt;/group-name&amp;gt;
    &amp;lt;/security-role-mapping&amp;gt;
    &amp;lt;security-role-mapping&amp;gt;
        &amp;lt;role-name&amp;gt;group1&amp;lt;/role-name&amp;gt;
        &amp;lt;group-name&amp;gt;S-1-5-21-2145774160-2038213957-1596523949-1106&amp;lt;/group-name&amp;gt;
    &amp;lt;/security-role-mapping&amp;gt;
    &amp;lt;security-role-mapping&amp;gt;
        &amp;lt;role-name&amp;gt;group2&amp;lt;/role-name&amp;gt;
        &amp;lt;group-name&amp;gt;S-1-5-21-2145774160-2038213957-1596523949-1107&amp;lt;/group-name&amp;gt;
    &amp;lt;/security-role-mapping&amp;gt;
    &amp;lt;security-role-mapping&amp;gt;
        &amp;lt;role-name&amp;gt;group3&amp;lt;/role-name&amp;gt;
        &amp;lt;group-name&amp;gt;S-1-5-21-2145774160-2038213957-1596523949-1108&amp;lt;/group-name&amp;gt;
    &amp;lt;/security-role-mapping&amp;gt;
&lt;/pre&gt;

&lt;p&gt;The group (or user) SIDs can be obtained using &lt;em&gt;WMIC&lt;/em&gt; command in the Windows machine:&lt;/p&gt;

&lt;pre style=&quot;white-space:pre-wrap&quot;&gt;
&amp;gt; wmic group where &quot;name=&#039;Domain Users&#039;&quot;
Caption Description Domain InstallDate LocalAccount Name SID SIDType Status
KVM\Domain Users All domain users KVM FALSE Domain Users S-1-5-21-2145774160-2038213957-1596523949-513 2 OK

&amp;gt; wmic group where &quot;name=&#039;group1&#039;&quot;
Caption Description Domain InstallDate LocalAccount Name SID SIDType Status
KVM\group1 KVM FALSE group1 S-1-5-21-2145774160-2038213957-1596523949-1106 2 OK

&amp;gt; wmic useraccount where &quot;name=&#039;ricky&#039;&quot;
AccountType Caption Description Disabled Domain FullName InstallDate LocalAccount Lockout Name PasswordChangeable PasswordExpires PasswordRequired SID SIDType Status
512 KVM\ricky FALSE KVM FALSE FALSE ricky TRUE TRUE TRUE S-1-5-21-2145774160-2038213957-1596523949-1104 1 OK
&lt;/pre&gt;

&lt;p&gt;And that&#039;s all, now the video presents how the user &lt;em&gt;ricky&lt;/em&gt; accesses to the new hello application and standard &lt;em&gt;isUserInRole&lt;/em&gt; is used (the beautiful mapped name is passed as argument, not the horrible SID). &lt;/p&gt;

&lt;video src=&quot;http://blogs.nologin.es/rickyepoderi/uploads/SPNEGOKerberosinJavaEEJavaEEGlassfish/out.webm&quot; autobuffer controls&gt;
&lt;img src=&quot;http://blogs.nologin.es/rickyepoderi/uploads/categories/error.png&quot; alt=&quot;Error!&quot; /&gt;
Your browser doesn&#039;t support the video tag. See this &lt;a href=&quot;http://blogs.nologin.es/rickyepoderi/index.php?/archives/41-Videos-Are-About-to-Change-Second-Time-Lucky.html&quot;&gt;entry&lt;/a&gt; for more information about how to see the videos in this blog. You can &lt;a href=&quot;http://blogs.nologin.es/rickyepoderi/uploads/SPNEGOKerberosinJavaEEJavaEEGlassfish/out.webm&quot;&gt;download the file&lt;/a&gt; instead.
&lt;/video&gt;

&lt;p&gt;Today&#039;s entry improves the &lt;em&gt;spenego.java.net&lt;/em&gt; project to add the SIDs as user groups inside a new &lt;em&gt;ServerAuthModule&lt;/em&gt;. The new module is the &lt;em&gt;PACSpnegoServerAuth&lt;/em&gt; class. It requires a little modification in the definition of the abstract method &lt;em&gt;getGroupsForCaller&lt;/em&gt; (more arguments). Besides I tried to minimize the dependencies of previous solutions and now it only depends on &lt;em&gt;commons-codec&lt;/em&gt; (original version 1.1 already depended on that and I did not want to change it). ASN.1 parsing is performed with the internal &lt;em&gt;sun.security.util JavaSE&lt;/em&gt; package (take care when other JavaSE  implementations is used). Six classes from &lt;em&gt;jaaslounge&lt;/em&gt; decoding were integrated in the JAR with minimal changes. The &lt;a href=&quot;http://blogs.nologin.es/rickyepoderi/uploads/SPNEGOKerberosinJavaEEJavaEEGlassfish/hello-spnego-java-net.zip&quot;&gt;hello-spnego-java-net&lt;/a&gt; sample application project and the &lt;a href=&quot;http://blogs.nologin.es/rickyepoderi/uploads/SPNEGOKerberosinJavaEEJavaEEGlassfish/spnego-java-net.zip&quot;&gt;spnego-java-net&lt;/a&gt; new library project can be downloaded from the corresponding links. The whole implementation was not very tested but, with no doubt, it is much better than the one presented in the previous entry. What do you think? Do I have to email to the &lt;em&gt;dev@spnego.java.net&lt;/em&gt; list explaining my changes?&lt;/p&gt;

&lt;p&gt;Comments below!&lt;/p&gt; 
    </content:encoded>

    <pubDate>Sun, 03 Mar 2013 13:30:00 +0100</pubDate>
    <guid isPermaLink="false">http://blogs.nologin.es/rickyepoderi/index.php?/archives/74-guid.html</guid>
    
</item>

</channel>
</rss>