Java X500Principal toPrincipal(String globusID)

Here you can find the source of toPrincipal(String globusID)

Description

to Principal

License

Apache License

Declaration

public static X500Principal toPrincipal(String globusID) 

Method Source Code

//package com.java2s;
/*//  w w  w  .j a  v  a2 s.  com
 * 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 {
    public static X500Principal toPrincipal(String globusID) {

        if (globusID == null) {
            return null;
        }
        String id = globusID.trim();
        StringTokenizer tokens = new StringTokenizer(id, "/");
        StringBuffer buf = new StringBuffer();
        String token;

        if (tokens.hasMoreTokens()) {
            token = tokens.nextToken().trim();
            buf.insert(0, token);
        }

        while (tokens.hasMoreTokens()) {
            token = tokens.nextToken().trim();

            buf.insert(0, ",");
            buf.insert(0, token);
        }

        String dn = buf.toString();

        return new X500Principal(dn);
    }
}

Related

  1. isTGSPrincipal(KerberosPrincipal principal)
  2. isTicketGrantingServerPrincipal(KerberosPrincipal principal)
  3. serverLogin(final String serverPrincipal, final String serverPassword)
  4. toGlobusID(X500Principal principal)
  5. toPrincipal(String globusID)