Here you can find the source of getDNField(String fieldID, X500Principal principal)
static public String getDNField(String fieldID, X500Principal principal)
//package com.java2s; /*//from w w w . j a v a2s .c o m * @(#)CoreAdminHelper.java * * Copyright 2004 by EkoLiving Pty Ltd. All Rights Reserved. * * This software is the proprietary information of EkoLiving Pty Ltd. * Use is subject to license terms. */ import java.util.StringTokenizer; import javax.security.auth.x500.X500Principal; public class Main { /** * Return the commonName of the past in X.500 principal. */ static public String getDNField(String fieldID, X500Principal principal) { StringTokenizer st = new StringTokenizer(principal.toString(), "=,"); while (st.hasMoreTokens()) { String tok = st.nextToken().trim(); if (tok.equalsIgnoreCase(fieldID)) { return st.nextToken().trim(); } } return null; } }