Java X500Principal getDNField(String fieldID, X500Principal principal)

Here you can find the source of getDNField(String fieldID, X500Principal principal)

Description

Return the commonName of the past in X.500 principal.

License

Open Source License

Declaration

static public String getDNField(String fieldID, X500Principal principal) 

Method Source Code

//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;
    }
}

Related

  1. convX509Name(X500Principal principal)
  2. createSubject(GSSName principals, GSSCredential credentials)
  3. extractName(final X500Principal dname)
  4. extractRDN(String rdn, X500Principal dn)
  5. isTGSPrincipal(KerberosPrincipal principal)
  6. isTicketGrantingServerPrincipal(KerberosPrincipal principal)
  7. serverLogin(final String serverPrincipal, final String serverPassword)
  8. toGlobusID(X500Principal principal)