Java X500Principal toGlobusID(X500Principal principal)

Here you can find the source of toGlobusID(X500Principal principal)

Description

Converts DN of the form "CN=A, OU=B, O=C" into Globus format "/O=C/OU=B/CN=A"
This function might return incorrect Globus-formatted ID when one of the RDNs in the DN contains commas.

License

Apache License

Return

the converted DN in Globus format.

Declaration

public static String toGlobusID(X500Principal principal) 

Method Source Code

//package com.java2s;
/*//from ww w  . ja v  a2s . c  o m
 * Copyright 1999-2010 University of Chicago
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
 * compliance with the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is
 * distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied.
 *
 * See the License for the specific language governing permissions and limitations under the License.
 */

import java.util.StringTokenizer;
import javax.security.auth.x500.X500Principal;

public class Main {
    /**
     * Converts DN of the form "CN=A, OU=B, O=C" into Globus format
     * "/O=C/OU=B/CN=A" <BR> This function might return incorrect
     * Globus-formatted ID when one of the RDNs in the DN contains commas.
     *
     * @return the converted DN in Globus format.
     */
    public static String toGlobusID(X500Principal principal) {

        if (principal == null) {
            return null;
        }

        String dn = principal.getName();

        StringTokenizer tokens = new StringTokenizer(dn, ",");
        StringBuffer buf = new StringBuffer();
        String token;

        while (tokens.hasMoreTokens()) {
            token = tokens.nextToken().trim();
            buf.insert(0, token);
            buf.insert(0, "/");
        }
        return buf.toString();
    }
}

Related

  1. extractRDN(String rdn, X500Principal dn)
  2. getDNField(String fieldID, X500Principal principal)
  3. isTGSPrincipal(KerberosPrincipal principal)
  4. isTicketGrantingServerPrincipal(KerberosPrincipal principal)
  5. serverLogin(final String serverPrincipal, final String serverPassword)
  6. toPrincipal(String globusID)
  7. toPrincipal(String globusID)