< prev index next >

src/java.security.jgss/share/classes/sun/security/krb5/PrincipalName.java

Print this page
rev 54745 : 8215032: Support Kerberos cross-realm referrals (RFC 6806)
Reviewed-by: weijun
   1 /*
   2  * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  74      * Service and other unique instance (krbtgt)
  75      */
  76     public static final int KRB_NT_SRV_INST =  2;
  77 
  78     /**
  79      * Service with host name as instance (telnet, rcommands)
  80      */
  81     public static final int KRB_NT_SRV_HST =   3;
  82 
  83     /**
  84      * Service with host as remaining components
  85      */
  86     public static final int KRB_NT_SRV_XHST =  4;
  87 
  88     /**
  89      * Unique ID
  90      */
  91     public static final int KRB_NT_UID = 5;
  92 
  93     /**





  94      * TGS Name
  95      */
  96     public static final String TGS_DEFAULT_SRV_NAME = "krbtgt";
  97     public static final int TGS_DEFAULT_NT = KRB_NT_SRV_INST;
  98 
  99     public static final char NAME_COMPONENT_SEPARATOR = '/';
 100     public static final char NAME_REALM_SEPARATOR = '@';
 101     public static final char REALM_COMPONENT_SEPARATOR = '.';
 102 
 103     public static final String NAME_COMPONENT_SEPARATOR_STR = "/";
 104     public static final String NAME_REALM_SEPARATOR_STR = "@";
 105     public static final String REALM_COMPONENT_SEPARATOR_STR = ".";
 106 
 107     // Instance fields.
 108 
 109     /**
 110      * The name type, from PrincipalName's name-type field.
 111      */
 112     private final int nameType;
 113 


 448             } else {
 449                 // We will try to get realm name from the mapping in
 450                 // the configuration. If it is not specified
 451                 // we will use the default realm. This nametype does
 452                 // not allow a realm to be specified. The name string must of
 453                 // the form service@host and this is internally changed into
 454                 // service/host by Kerberos
 455                 String mapRealm =  mapHostToRealm(nameParts[1]);
 456                 if (mapRealm != null) {
 457                     nameRealm = new Realm(mapRealm);
 458                 } else {
 459                     nameRealm = Realm.getDefault();
 460                 }
 461             }
 462             break;
 463         case KRB_NT_UNKNOWN:
 464         case KRB_NT_PRINCIPAL:
 465         case KRB_NT_SRV_INST:
 466         case KRB_NT_SRV_XHST:
 467         case KRB_NT_UID:

 468             nameStrings = nameParts;
 469             nameType = type;
 470             if (realm != null) {
 471                 nameRealm = new Realm(realm);
 472             } else {
 473                 nameRealm = Realm.getDefault();
 474             }
 475             break;
 476         default:
 477             throw new IllegalArgumentException("Illegal name type");
 478         }
 479     }
 480 
 481     public PrincipalName(String name, int type) throws RealmException {
 482         this(name, type, (String)null);
 483     }
 484 
 485     public PrincipalName(String name) throws RealmException {
 486         this(name, KRB_NT_UNKNOWN);
 487     }


   1 /*
   2  * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  74      * Service and other unique instance (krbtgt)
  75      */
  76     public static final int KRB_NT_SRV_INST =  2;
  77 
  78     /**
  79      * Service with host name as instance (telnet, rcommands)
  80      */
  81     public static final int KRB_NT_SRV_HST =   3;
  82 
  83     /**
  84      * Service with host as remaining components
  85      */
  86     public static final int KRB_NT_SRV_XHST =  4;
  87 
  88     /**
  89      * Unique ID
  90      */
  91     public static final int KRB_NT_UID = 5;
  92 
  93     /**
  94      * Enterprise name (alias)
  95      */
  96     public static final int KRB_NT_ENTERPRISE = 10;
  97 
  98     /**
  99      * TGS Name
 100      */
 101     public static final String TGS_DEFAULT_SRV_NAME = "krbtgt";
 102     public static final int TGS_DEFAULT_NT = KRB_NT_SRV_INST;
 103 
 104     public static final char NAME_COMPONENT_SEPARATOR = '/';
 105     public static final char NAME_REALM_SEPARATOR = '@';
 106     public static final char REALM_COMPONENT_SEPARATOR = '.';
 107 
 108     public static final String NAME_COMPONENT_SEPARATOR_STR = "/";
 109     public static final String NAME_REALM_SEPARATOR_STR = "@";
 110     public static final String REALM_COMPONENT_SEPARATOR_STR = ".";
 111 
 112     // Instance fields.
 113 
 114     /**
 115      * The name type, from PrincipalName's name-type field.
 116      */
 117     private final int nameType;
 118 


 453             } else {
 454                 // We will try to get realm name from the mapping in
 455                 // the configuration. If it is not specified
 456                 // we will use the default realm. This nametype does
 457                 // not allow a realm to be specified. The name string must of
 458                 // the form service@host and this is internally changed into
 459                 // service/host by Kerberos
 460                 String mapRealm =  mapHostToRealm(nameParts[1]);
 461                 if (mapRealm != null) {
 462                     nameRealm = new Realm(mapRealm);
 463                 } else {
 464                     nameRealm = Realm.getDefault();
 465                 }
 466             }
 467             break;
 468         case KRB_NT_UNKNOWN:
 469         case KRB_NT_PRINCIPAL:
 470         case KRB_NT_SRV_INST:
 471         case KRB_NT_SRV_XHST:
 472         case KRB_NT_UID:
 473         case KRB_NT_ENTERPRISE:
 474             nameStrings = nameParts;
 475             nameType = type;
 476             if (realm != null) {
 477                 nameRealm = new Realm(realm);
 478             } else {
 479                 nameRealm = Realm.getDefault();
 480             }
 481             break;
 482         default:
 483             throw new IllegalArgumentException("Illegal name type");
 484         }
 485     }
 486 
 487     public PrincipalName(String name, int type) throws RealmException {
 488         this(name, type, (String)null);
 489     }
 490 
 491     public PrincipalName(String name) throws RealmException {
 492         this(name, KRB_NT_UNKNOWN);
 493     }


< prev index next >