Extract Certificate information attributes

in Java, how to extract certificate info to retreive the CN attribute.
The certificate is store on a TN Profile

Thanks