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; 10 import java.security.cert.X509Certificate; 11 import java.math.BigInteger; 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 toPrinicipal(X509Certificate[] certs) 31 { 32 BigInteger serialNumber = certs[0].getSerialNumber(); 33 Principal issuer = certs[0].getIssuerDN(); 34 SimplePrincipal principal = new SimplePrincipal(serialNumber+" "+issuer); 35 return principal; 36 } 37 } 38