KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > security > auth > certs > SerialNumberIssuerDNMapping


1 /*
2 * JBoss, the OpenSource J2EE webOS
3 *
4 * Distributable under LGPL license.
5 * See terms of license at gnu.org.
6 */

7 package org.jboss.security.auth.certs;
8
9 import java.security.Principal JavaDoc;
10 import java.security.cert.X509Certificate JavaDoc;
11 import java.math.BigInteger JavaDoc;
12 import org.jboss.security.CertificatePrincipal;
13 import org.jboss.security.SimplePrincipal;
14
15 /** A CertificatePrincipal implementation that builds the principal name
16  * based on the cert serialNumber and issuerDN
17  *
18  * @author Scott.Stark@jboss.org
19  * @version $Revision: 1.1.8.1 $
20  */

21 public class SerialNumberIssuerDNMapping
22    implements CertificatePrincipal
23 {
24    /** Create a SimplePrincipal with the name composed from
25     * certs[0].getSerialNumber() + " " + certs[0].getIssuerDN()
26     *
27     * @param certs Array of client certificates, with the first one in
28     * the array being the certificate of the client itself.
29     */

30    public Principal JavaDoc toPrinicipal(X509Certificate JavaDoc[] certs)
31    {
32       BigInteger JavaDoc serialNumber = certs[0].getSerialNumber();
33       Principal JavaDoc issuer = certs[0].getIssuerDN();
34       SimplePrincipal principal = new SimplePrincipal(serialNumber+" "+issuer);
35       return principal;
36    }
37 }
38
Popular Tags