sun.security.krb5.PrincipalName Java Examples
The following examples show how to use
sun.security.krb5.PrincipalName.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: Krb5KeyExchangeService.java License: GNU General Public License v2.0 | 6 votes |
@Override public String getServiceHostName(Principal principal) { if (principal == null) { return null; } String hostName = null; try { PrincipalName princName = new PrincipalName(principal.getName(), PrincipalName.KRB_NT_SRV_HST); String[] nameParts = princName.getNameStrings(); if (nameParts.length >= 2) { hostName = nameParts[1]; } } catch (Exception e) { // ignore } return hostName; }
Example #2
Source Project: openjdk-jdk8u-backup Author: AdoptOpenJDK File: KeyTabIndex.java License: GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { KeyTab kt = KeyTab.create("ktab"); // Two entries with very different length, so that it's easy to // observice the abnormal change of "index" field. kt.addEntry(new PrincipalName( "[email protected]"), "x".toCharArray(), 1, true); kt.addEntry(new PrincipalName("[email protected]"), "x".toCharArray(), 1, true); kt.save(); Runnable t = new Runnable() { @Override public void run() { KeyTab.getInstance("ktab").getClass(); } }; for (int i=0; i<10; i++) { new Thread(t).start(); } }
Example #3
Source Project: jdk8u60 Author: chenghanpeng File: KeyTabIndex.java License: GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { KeyTab kt = KeyTab.create("ktab"); // Two entries with very different length, so that it's easy to // observice the abnormal change of "index" field. kt.addEntry(new PrincipalName( "[email protected]"), "x".toCharArray(), 1, true); kt.addEntry(new PrincipalName("[email protected]"), "x".toCharArray(), 1, true); kt.save(); Runnable t = new Runnable() { @Override public void run() { KeyTab.getInstance("ktab").getClass(); } }; for (int i=0; i<10; i++) { new Thread(t).start(); } }
Example #4
Source Project: jdk8u-dev-jdk Author: frohoff File: Krb5ProxyImpl.java License: GNU General Public License v2.0 | 6 votes |
@Override public String getPrincipalHostName(Principal principal) { if (principal == null) { return null; } String hostName = null; try { PrincipalName princName = new PrincipalName(principal.getName(), PrincipalName.KRB_NT_SRV_HST); String[] nameParts = princName.getNameStrings(); if (nameParts.length >= 2) { hostName = nameParts[1]; } } catch (Exception e) { // ignore } return hostName; }
Example #5
Source Project: jdk8u-jdk Author: lambdalab-mirror File: KeyTabIndex.java License: GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { KeyTab kt = KeyTab.create("ktab"); // Two entries with very different length, so that it's easy to // observice the abnormal change of "index" field. kt.addEntry(new PrincipalName( "[email protected]"), "x".toCharArray(), 1, true); kt.addEntry(new PrincipalName("[email protected]"), "x".toCharArray(), 1, true); kt.save(); Runnable t = new Runnable() { @Override public void run() { KeyTab.getInstance("ktab").getClass(); } }; for (int i=0; i<10; i++) { new Thread(t).start(); } }
Example #6
Source Project: openjdk-8-source Author: keerath File: HostAddresses.java License: GNU General Public License v2.0 | 6 votes |
public HostAddresses(PrincipalName serverPrincipal) throws UnknownHostException, KrbException { String[] components = serverPrincipal.getNameStrings(); if (serverPrincipal.getNameType() != PrincipalName.KRB_NT_SRV_HST || components.length < 2) throw new KrbException(Krb5.KRB_ERR_GENERIC, "Bad name"); String host = components[1]; InetAddress addr[] = InetAddress.getAllByName(host); HostAddress hAddrs[] = new HostAddress[addr.length]; for (int i = 0; i < addr.length; i++) { hAddrs[i] = new HostAddress(addr[i]); } addresses = hAddrs; }
Example #7
Source Project: openjdk-jdk8u-backup Author: AdoptOpenJDK File: KerberosPrincipal.java License: GNU General Public License v2.0 | 6 votes |
/** * Reads this object from a stream (i.e., deserializes it) */ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { byte[] asn1EncPrincipal = (byte [])ois.readObject(); byte[] encRealm = (byte [])ois.readObject(); try { Realm realmObject = new Realm(new DerValue(encRealm)); PrincipalName krb5Principal = new PrincipalName( new DerValue(asn1EncPrincipal), realmObject); realm = realmObject.toString(); fullName = krb5Principal.toString(); nameType = krb5Principal.getNameType(); } catch (Exception e) { throw new IOException(e); } }
Example #8
Source Project: Java8CN Author: Java8-CNAPI-Team File: KerberosPrincipal.java License: Apache License 2.0 | 6 votes |
/** * Reads this object from a stream (i.e., deserializes it) */ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { byte[] asn1EncPrincipal = (byte [])ois.readObject(); byte[] encRealm = (byte [])ois.readObject(); try { Realm realmObject = new Realm(new DerValue(encRealm)); PrincipalName krb5Principal = new PrincipalName( new DerValue(asn1EncPrincipal), realmObject); realm = realmObject.toString(); fullName = krb5Principal.toString(); nameType = krb5Principal.getNameType(); } catch (Exception e) { throw new IOException(e); } }
Example #9
Source Project: dragonwell8_jdk Author: alibaba File: KeyTabIndex.java License: GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { KeyTab kt = KeyTab.create("ktab"); // Two entries with very different length, so that it's easy to // observice the abnormal change of "index" field. kt.addEntry(new PrincipalName( "[email protected]"), "x".toCharArray(), 1, true); kt.addEntry(new PrincipalName("[email protected]"), "x".toCharArray(), 1, true); kt.save(); Runnable t = new Runnable() { @Override public void run() { KeyTab.getInstance("ktab").getClass(); } }; for (int i=0; i<10; i++) { new Thread(t).start(); } }
Example #10
Source Project: jdk8u60 Author: chenghanpeng File: FileKeyTab.java License: GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { String name = "ktab"; KeyTab kt = KeyTab.create(name); kt.addEntry(new PrincipalName("[email protected]"), "x".toCharArray(), 1, true); kt.save(); check(name); check("FILE:" + name); name = new File(name).getAbsolutePath().toString(); check(name); check("FILE:" + name); // The bug reporter uses this style, should only work for // absolute path check("FILE:/" + name); }
Example #11
Source Project: openjdk-8 Author: bpupadhyaya File: Krb5ProxyImpl.java License: GNU General Public License v2.0 | 6 votes |
@Override public String getPrincipalHostName(Principal principal) { if (principal == null) { return null; } String hostName = null; try { PrincipalName princName = new PrincipalName(principal.getName(), PrincipalName.KRB_NT_SRV_HST); String[] nameParts = princName.getNameStrings(); if (nameParts.length >= 2) { hostName = nameParts[1]; } } catch (Exception e) { // ignore } return hostName; }
Example #12
Source Project: hottub Author: dsrg-uoft File: Krb5ProxyImpl.java License: GNU General Public License v2.0 | 6 votes |
@Override public String getPrincipalHostName(Principal principal) { if (principal == null) { return null; } String hostName = null; try { PrincipalName princName = new PrincipalName(principal.getName(), PrincipalName.KRB_NT_SRV_HST); String[] nameParts = princName.getNameStrings(); if (nameParts.length >= 2) { hostName = nameParts[1]; } } catch (Exception e) { // ignore } return hostName; }
Example #13
Source Project: JDKSourceCode1.8 Author: wupeixuan File: KerberosPrincipal.java License: MIT License | 6 votes |
/** * Reads this object from a stream (i.e., deserializes it) */ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { byte[] asn1EncPrincipal = (byte [])ois.readObject(); byte[] encRealm = (byte [])ois.readObject(); try { Realm realmObject = new Realm(new DerValue(encRealm)); PrincipalName krb5Principal = new PrincipalName( new DerValue(asn1EncPrincipal), realmObject); realm = realmObject.toString(); fullName = krb5Principal.toString(); nameType = krb5Principal.getNameType(); } catch (Exception e) { throw new IOException(e); } }
Example #14
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: KeyTabIndex.java License: GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { KeyTab kt = KeyTab.create("ktab"); // Two entries with very different length, so that it's easy to // observice the abnormal change of "index" field. kt.addEntry(new PrincipalName( "[email protected]"), "x".toCharArray(), 1, true); kt.addEntry(new PrincipalName("[email protected]"), "x".toCharArray(), 1, true); kt.save(); Runnable t = new Runnable() { @Override public void run() { KeyTab.getInstance("ktab").getClass(); } }; for (int i=0; i<10; i++) { new Thread(t).start(); } }
Example #15
Source Project: openjdk-8 Author: bpupadhyaya File: KerberosPrincipal.java License: GNU General Public License v2.0 | 6 votes |
/** * Reads this object from a stream (i.e., deserializes it) */ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { byte[] asn1EncPrincipal = (byte [])ois.readObject(); byte[] encRealm = (byte [])ois.readObject(); try { Realm realmObject = new Realm(new DerValue(encRealm)); PrincipalName krb5Principal = new PrincipalName( new DerValue(asn1EncPrincipal), realmObject); realm = realmObject.toString(); fullName = krb5Principal.toString(); nameType = krb5Principal.getNameType(); } catch (Exception e) { throw new IOException(e); } }
Example #16
Source Project: jdk8u-jdk Author: frohoff File: FileKeyTab.java License: GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { String name = "ktab"; KeyTab kt = KeyTab.create(name); kt.addEntry(new PrincipalName("[email protected]"), "x".toCharArray(), 1, true); kt.save(); check(name); check("FILE:" + name); name = new File(name).getAbsolutePath().toString(); check(name); check("FILE:" + name); // The bug reporter uses this style, should only work for // absolute path check("FILE:/" + name); }
Example #17
Source Project: TencentKona-8 Author: Tencent File: PrincipalNameEquals.java License: GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { OneKDC kdc = new OneKDC(null); kdc.writeJAASConf(); kdc.setOption(KDC.Option.RESP_NT, PrincipalName.KRB_NT_PRINCIPAL); Context c, s; c = Context.fromJAAS("client"); s = Context.fromJAAS("server"); c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID); s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID); Context.handshake(c, s); Context.transmit("i say high --", c, s); Context.transmit(" you say low", s, c); s.dispose(); c.dispose(); }
Example #18
Source Project: jdk8u-jdk Author: lambdalab-mirror File: HostAddresses.java License: GNU General Public License v2.0 | 6 votes |
public HostAddresses(PrincipalName serverPrincipal) throws UnknownHostException, KrbException { String[] components = serverPrincipal.getNameStrings(); if (serverPrincipal.getNameType() != PrincipalName.KRB_NT_SRV_HST || components.length < 2) throw new KrbException(Krb5.KRB_ERR_GENERIC, "Bad name"); String host = components[1]; InetAddress addr[] = InetAddress.getAllByName(host); HostAddress hAddrs[] = new HostAddress[addr.length]; for (int i = 0; i < addr.length; i++) { hAddrs[i] = new HostAddress(addr[i]); } addresses = hAddrs; }
Example #19
Source Project: jdk8u-jdk Author: lambdalab-mirror File: FileKeyTab.java License: GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { String name = "ktab"; KeyTab kt = KeyTab.create(name); kt.addEntry(new PrincipalName("[email protected]"), "x".toCharArray(), 1, true); kt.save(); check(name); check("FILE:" + name); name = new File(name).getAbsolutePath().toString(); check(name); check("FILE:" + name); // The bug reporter uses this style, should only work for // absolute path check("FILE:/" + name); }
Example #20
Source Project: openjdk-8 Author: bpupadhyaya File: PrincipalNameEquals.java License: GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { OneKDC kdc = new OneKDC(null); kdc.writeJAASConf(); kdc.setOption(KDC.Option.RESP_NT, PrincipalName.KRB_NT_PRINCIPAL); Context c, s; c = Context.fromJAAS("client"); s = Context.fromJAAS("server"); c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID); s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID); Context.handshake(c, s); Context.transmit("i say high --", c, s); Context.transmit(" you say low", s, c); s.dispose(); c.dispose(); }
Example #21
Source Project: openjdk-jdk8u Author: AdoptOpenJDK File: HostAddresses.java License: GNU General Public License v2.0 | 6 votes |
public HostAddresses(PrincipalName serverPrincipal) throws UnknownHostException, KrbException { String[] components = serverPrincipal.getNameStrings(); if (serverPrincipal.getNameType() != PrincipalName.KRB_NT_SRV_HST || components.length < 2) throw new KrbException(Krb5.KRB_ERR_GENERIC, "Bad name"); String host = components[1]; InetAddress addr[] = InetAddress.getAllByName(host); HostAddress hAddrs[] = new HostAddress[addr.length]; for (int i = 0; i < addr.length; i++) { hAddrs[i] = new HostAddress(addr[i]); } addresses = hAddrs; }
Example #22
Source Project: dragonwell8_jdk Author: alibaba File: Krb5NameElement.java License: GNU General Public License v2.0 | 5 votes |
private Krb5NameElement(PrincipalName principalName, String gssNameStr, Oid gssNameType) { this.krb5PrincipalName = principalName; this.gssNameStr = gssNameStr; this.gssNameType = gssNameType; }
Example #23
Source Project: jdk8u-jdk Author: lambdalab-mirror File: MoreKvno.java License: GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { OneKDC kdc = new OneKDC(null); kdc.writeJAASConf(); // Rewrite keytab, 3 set of keys with different kvno KeyTab ktab = KeyTab.create(OneKDC.KTAB); p = new PrincipalName( OneKDC.SERVER+"@"+OneKDC.REALM, PrincipalName.KRB_NT_SRV_HST); ktab.addEntry(p, "pass1".toCharArray(), 1, true); ktab.addEntry(p, "pass3".toCharArray(), 3, true); ktab.addEntry(p, "pass2".toCharArray(), 2, true); ktab.save(); char[] pass = "pass2".toCharArray(); kdc.addPrincipal(OneKDC.SERVER, pass); go(OneKDC.SERVER, "com.sun.security.jgss.krb5.accept", pass); pass = "pass3".toCharArray(); kdc.addPrincipal(OneKDC.SERVER, pass); // "server" initiate also, check pass2 is used at authentication go(OneKDC.SERVER, "server", pass); try { pass = "pass4".toCharArray(); kdc.addPrincipal(OneKDC.SERVER, pass); go(OneKDC.SERVER, "com.sun.security.jgss.krb5.accept", pass); throw new Exception("This test should fail"); } catch (GSSException gsse) { // Since 7197159, different kvno is accepted, this return code // will never be thrown out again. //KrbException ke = (KrbException)gsse.getCause(); //if (ke.returnCode() != Krb5.KRB_AP_ERR_BADKEYVER) { // throw new Exception("Not expected failure code: " + // ke.returnCode()); //} } }
Example #24
Source Project: jdk8u-jdk Author: frohoff File: KvnoNA.java License: GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { OneKDC kdc = new OneKDC(null); kdc.writeJAASConf(); // In KDC, it's 2 char[] pass = "pass2".toCharArray(); kdc.addPrincipal(OneKDC.SERVER, pass); // In ktab, kvno is 1 or 3, 3 has the same password KeyTab ktab = KeyTab.create(OneKDC.KTAB); PrincipalName p = new PrincipalName( OneKDC.SERVER+"@"+OneKDC.REALM, PrincipalName.KRB_NT_SRV_HST); ktab.addEntry(p, "pass1".toCharArray(), 1, true); ktab.addEntry(p, "pass2".toCharArray(), 3, true); ktab.save(); Context c, s; c = Context.fromUserPass("dummy", "bogus".toCharArray(), false); s = Context.fromJAAS("server"); c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID); s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID); Context.handshake(c, s); s.dispose(); c.dispose(); }
Example #25
Source Project: jdk8u_jdk Author: JetBrains File: TGSRep.java License: GNU General Public License v2.0 | 5 votes |
public TGSRep( PAData[] new_pAData, PrincipalName new_cname, Ticket new_ticket, EncryptedData new_encPart ) throws IOException { super(new_pAData, new_cname, new_ticket, new_encPart, Krb5.KRB_TGS_REP); }
Example #26
Source Project: jdk8u-dev-jdk Author: frohoff File: KeyImpl.java License: GNU General Public License v2.0 | 5 votes |
/** * Constructs a KeyImpl from a password. * * @param principal the principal from which to derive the salt * @param password the password that should be used to compute the * key. * @param algorithm the name for the algorithm that this key wil be * used for. This parameter may be null in which case "DES" will be * assumed. */ public KeyImpl(KerberosPrincipal principal, char[] password, String algorithm) { try { PrincipalName princ = new PrincipalName(principal.getName()); EncryptionKey key = new EncryptionKey(password, princ.getSalt(), algorithm); this.keyBytes = key.getBytes(); this.keyType = key.getEType(); } catch (KrbException e) { throw new IllegalArgumentException(e.getMessage()); } }
Example #27
Source Project: jdk8u60 Author: chenghanpeng File: Ticket.java License: GNU General Public License v2.0 | 5 votes |
public Object clone() { Ticket new_ticket = new Ticket(); new_ticket.sname = (PrincipalName)sname.clone(); new_ticket.encPart = (EncryptedData)encPart.clone(); new_ticket.tkt_vno = tkt_vno; return new_ticket; }
Example #28
Source Project: dragonwell8_jdk Author: alibaba File: ReferralsCache.java License: GNU General Public License v2.0 | 5 votes |
static synchronized void put(PrincipalName cname, PrincipalName service, String fromRealm, String toRealm, Credentials creds) { ReferralCacheKey k = new ReferralCacheKey(cname, service); pruneExpired(k); if (creds.getEndTime().before(new Date())) { return; } Map<String, ReferralCacheEntry> entries = referralsMap.get(k); if (entries == null) { entries = new HashMap<String, ReferralCacheEntry>(); referralsMap.put(k, entries); } entries.remove(fromRealm); ReferralCacheEntry newEntry = new ReferralCacheEntry(creds, toRealm); entries.put(fromRealm, newEntry); // Remove loops within the cache ReferralCacheEntry current = newEntry; List<ReferralCacheEntry> seen = new LinkedList<>(); while (current != null) { if (seen.contains(current)) { // Loop found. Remove the first referral to cut the loop. entries.remove(newEntry.getToRealm()); break; } seen.add(current); current = entries.get(current.getToRealm()); } }
Example #29
Source Project: jdk8u60 Author: chenghanpeng File: KeyImpl.java License: GNU General Public License v2.0 | 5 votes |
/** * Constructs a KeyImpl from a password. * * @param principal the principal from which to derive the salt * @param password the password that should be used to compute the * key. * @param algorithm the name for the algorithm that this key wil be * used for. This parameter may be null in which case "DES" will be * assumed. */ public KeyImpl(KerberosPrincipal principal, char[] password, String algorithm) { try { PrincipalName princ = new PrincipalName(principal.getName()); EncryptionKey key = new EncryptionKey(password, princ.getSalt(), algorithm); this.keyBytes = key.getBytes(); this.keyType = key.getEType(); } catch (KrbException e) { throw new IllegalArgumentException(e.getMessage()); } }
Example #30
Source Project: jdk8u-jdk Author: frohoff File: KeyImpl.java License: GNU General Public License v2.0 | 5 votes |
/** * Constructs a KeyImpl from a password. * * @param principal the principal from which to derive the salt * @param password the password that should be used to compute the * key. * @param algorithm the name for the algorithm that this key wil be * used for. This parameter may be null in which case "DES" will be * assumed. */ public KeyImpl(KerberosPrincipal principal, char[] password, String algorithm) { try { PrincipalName princ = new PrincipalName(principal.getName()); EncryptionKey key = new EncryptionKey(password, princ.getSalt(), algorithm); this.keyBytes = key.getBytes(); this.keyType = key.getEType(); } catch (KrbException e) { throw new IllegalArgumentException(e.getMessage()); } }