Java Code Examples for sun.security.krb5.internal.Krb5#KRB_ERR_GENERIC

The following examples show how to use sun.security.krb5.internal.Krb5#KRB_ERR_GENERIC . 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 File: Config.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Locate KDC using DNS
 *
 * @param realm the realm for which the master KDC is desired
 * @return the KDC
 */
private String getKDCFromDNS(String realm) throws KrbException {
    // use DNS to locate KDC
    String kdcs = "";
    String[] srvs = null;
    // locate DNS SRV record using UDP
    if (DEBUG) {
        System.out.println("getKDCFromDNS using UDP");
    }
    srvs = KrbServiceLocator.getKerberosService(realm, "_udp");
    if (srvs == null) {
        // locate DNS SRV record using TCP
        if (DEBUG) {
            System.out.println("getKDCFromDNS using TCP");
        }
        srvs = KrbServiceLocator.getKerberosService(realm, "_tcp");
    }
    if (srvs == null) {
        // no DNS SRV records
        throw new KrbException(Krb5.KRB_ERR_GENERIC,
            "Unable to locate KDC for realm " + realm);
    }
    if (srvs.length == 0) {
        return null;
    }
    for (int i = 0; i < srvs.length; i++) {
        kdcs += srvs[i].trim() + " ";
    }
    kdcs = kdcs.trim();
    if (kdcs.equals("")) {
        return null;
    }
    return kdcs;
}
 
Example 2
Source File: DflCache.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void checkAndStore(KerberosTime currTime, AuthTimeWithHash time)
        throws KrbApErrException {
    try {
        checkAndStore0(currTime, time);
    } catch (IOException ioe) {
        KrbApErrException ke = new KrbApErrException(Krb5.KRB_ERR_GENERIC);
        ke.initCause(ioe);
        throw ke;
    }
}
 
Example 3
Source File: KdcComm.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public KdcComm(String realm) throws KrbException {
    if (realm == null) {
       realm = Config.getInstance().getDefaultRealm();
        if (realm == null) {
            throw new KrbException(Krb5.KRB_ERR_GENERIC,
                                   "Cannot find default realm");
        }
    }
    this.realm = realm;
}
 
Example 4
Source File: Config.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Locate KDC using DNS
 *
 * @param realm the realm for which the master KDC is desired
 * @return the KDC
 */
private String getKDCFromDNS(String realm) throws KrbException {
    // use DNS to locate KDC
    String kdcs = "";
    String[] srvs = null;
    // locate DNS SRV record using UDP
    if (DEBUG) {
        System.out.println("getKDCFromDNS using UDP");
    }
    srvs = KrbServiceLocator.getKerberosService(realm, "_udp");
    if (srvs == null) {
        // locate DNS SRV record using TCP
        if (DEBUG) {
            System.out.println("getKDCFromDNS using TCP");
        }
        srvs = KrbServiceLocator.getKerberosService(realm, "_tcp");
    }
    if (srvs == null) {
        // no DNS SRV records
        throw new KrbException(Krb5.KRB_ERR_GENERIC,
            "Unable to locate KDC for realm " + realm);
    }
    if (srvs.length == 0) {
        return null;
    }
    for (int i = 0; i < srvs.length; i++) {
        kdcs += srvs[i].trim() + " ";
    }
    kdcs = kdcs.trim();
    if (kdcs.equals("")) {
        return null;
    }
    return kdcs;
}
 
Example 5
Source File: Config.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Locate Kerberos realm using DNS
 *
 * @return the Kerberos realm
 */
private String getRealmFromDNS() throws KrbException {
    // use DNS to locate Kerberos realm
    String realm = null;
    String hostName = null;
    try {
        hostName = InetAddress.getLocalHost().getCanonicalHostName();
    } catch (UnknownHostException e) {
        KrbException ke = new KrbException(Krb5.KRB_ERR_GENERIC,
            "Unable to locate Kerberos realm: " + e.getMessage());
        ke.initCause(e);
        throw (ke);
    }
    // get the domain realm mapping from the configuration
    String mapRealm = PrincipalName.mapHostToRealm(hostName);
    if (mapRealm == null) {
        // No match. Try search and/or domain in /etc/resolv.conf
        List<String> srchlist = ResolverConfiguration.open().searchlist();
        for (String domain: srchlist) {
            realm = checkRealm(domain);
            if (realm != null) {
                break;
            }
        }
    } else {
        realm = checkRealm(mapRealm);
    }
    if (realm == null) {
        throw new KrbException(Krb5.KRB_ERR_GENERIC,
                            "Unable to locate Kerberos realm");
    }
    return realm;
}
 
Example 6
Source File: DflCache.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void checkAndStore(KerberosTime currTime, AuthTimeWithHash time)
        throws KrbApErrException {
    try {
        checkAndStore0(currTime, time);
    } catch (IOException ioe) {
        KrbApErrException ke = new KrbApErrException(Krb5.KRB_ERR_GENERIC);
        ke.initCause(ioe);
        throw ke;
    }
}
 
Example 7
Source File: Config.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Locate Kerberos realm using DNS
 *
 * @return the Kerberos realm
 */
private String getRealmFromDNS() throws KrbException {
    // use DNS to locate Kerberos realm
    String realm = null;
    String hostName = null;
    try {
        hostName = InetAddress.getLocalHost().getCanonicalHostName();
    } catch (UnknownHostException e) {
        KrbException ke = new KrbException(Krb5.KRB_ERR_GENERIC,
            "Unable to locate Kerberos realm: " + e.getMessage());
        ke.initCause(e);
        throw (ke);
    }
    // get the domain realm mapping from the configuration
    String mapRealm = PrincipalName.mapHostToRealm(hostName);
    if (mapRealm == null) {
        // No match. Try search and/or domain in /etc/resolv.conf
        List<String> srchlist = ResolverConfiguration.open().searchlist();
        for (String domain: srchlist) {
            realm = checkRealm(domain);
            if (realm != null) {
                break;
            }
        }
    } else {
        realm = checkRealm(mapRealm);
    }
    if (realm == null) {
        throw new KrbException(Krb5.KRB_ERR_GENERIC,
                            "Unable to locate Kerberos realm");
    }
    return realm;
}
 
Example 8
Source File: Config.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Locate KDC using DNS
 *
 * @param realm the realm for which the master KDC is desired
 * @return the KDC
 */
private String getKDCFromDNS(String realm) throws KrbException {
    // use DNS to locate KDC
    String kdcs = "";
    String[] srvs = null;
    // locate DNS SRV record using UDP
    if (DEBUG) {
        System.out.println("getKDCFromDNS using UDP");
    }
    srvs = KrbServiceLocator.getKerberosService(realm, "_udp");
    if (srvs == null) {
        // locate DNS SRV record using TCP
        if (DEBUG) {
            System.out.println("getKDCFromDNS using TCP");
        }
        srvs = KrbServiceLocator.getKerberosService(realm, "_tcp");
    }
    if (srvs == null) {
        // no DNS SRV records
        throw new KrbException(Krb5.KRB_ERR_GENERIC,
            "Unable to locate KDC for realm " + realm);
    }
    if (srvs.length == 0) {
        return null;
    }
    for (int i = 0; i < srvs.length; i++) {
        kdcs += srvs[i].trim() + " ";
    }
    kdcs = kdcs.trim();
    if (kdcs.equals("")) {
        return null;
    }
    return kdcs;
}
 
Example 9
Source File: DflCache.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void checkAndStore(KerberosTime currTime, AuthTimeWithHash time)
        throws KrbApErrException {
    try {
        checkAndStore0(currTime, time);
    } catch (IOException ioe) {
        KrbApErrException ke = new KrbApErrException(Krb5.KRB_ERR_GENERIC);
        ke.initCause(ioe);
        throw ke;
    }
}
 
Example 10
Source File: DflCache.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void checkAndStore(KerberosTime currTime, AuthTimeWithHash time)
        throws KrbApErrException {
    try {
        checkAndStore0(currTime, time);
    } catch (IOException ioe) {
        KrbApErrException ke = new KrbApErrException(Krb5.KRB_ERR_GENERIC);
        ke.initCause(ioe);
        throw ke;
    }
}
 
Example 11
Source File: Config.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Locate Kerberos realm using DNS
 *
 * @return the Kerberos realm
 */
private String getRealmFromDNS() throws KrbException {
    // use DNS to locate Kerberos realm
    String realm = null;
    String hostName = null;
    try {
        hostName = InetAddress.getLocalHost().getCanonicalHostName();
    } catch (UnknownHostException e) {
        KrbException ke = new KrbException(Krb5.KRB_ERR_GENERIC,
            "Unable to locate Kerberos realm: " + e.getMessage());
        ke.initCause(e);
        throw (ke);
    }
    // get the domain realm mapping from the configuration
    String mapRealm = PrincipalName.mapHostToRealm(hostName);
    if (mapRealm == null) {
        // No match. Try search and/or domain in /etc/resolv.conf
        List<String> srchlist = ResolverConfiguration.open().searchlist();
        for (String domain: srchlist) {
            realm = checkRealm(domain);
            if (realm != null) {
                break;
            }
        }
    } else {
        realm = checkRealm(mapRealm);
    }
    if (realm == null) {
        throw new KrbException(Krb5.KRB_ERR_GENERIC,
                            "Unable to locate Kerberos realm");
    }
    return realm;
}
 
Example 12
Source File: Config.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Locate Kerberos realm using DNS
 *
 * @return the Kerberos realm
 */
private String getRealmFromDNS() throws KrbException {
    // use DNS to locate Kerberos realm
    String realm = null;
    String hostName = null;
    try {
        hostName = InetAddress.getLocalHost().getCanonicalHostName();
    } catch (UnknownHostException e) {
        KrbException ke = new KrbException(Krb5.KRB_ERR_GENERIC,
            "Unable to locate Kerberos realm: " + e.getMessage());
        ke.initCause(e);
        throw (ke);
    }
    // get the domain realm mapping from the configuration
    String mapRealm = PrincipalName.mapHostToRealm(hostName);
    if (mapRealm == null) {
        // No match. Try search and/or domain in /etc/resolv.conf
        List<String> srchlist = ResolverConfiguration.open().searchlist();
        for (String domain: srchlist) {
            realm = checkRealm(domain);
            if (realm != null) {
                break;
            }
        }
    } else {
        realm = checkRealm(mapRealm);
    }
    if (realm == null) {
        throw new KrbException(Krb5.KRB_ERR_GENERIC,
                            "Unable to locate Kerberos realm");
    }
    return realm;
}
 
Example 13
Source File: Config.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Locate KDC using DNS
 *
 * @param realm the realm for which the master KDC is desired
 * @return the KDC
 */
private String getKDCFromDNS(String realm) throws KrbException {
    // use DNS to locate KDC
    String kdcs = "";
    String[] srvs = null;
    // locate DNS SRV record using UDP
    if (DEBUG) {
        System.out.println("getKDCFromDNS using UDP");
    }
    srvs = KrbServiceLocator.getKerberosService(realm, "_udp");
    if (srvs == null) {
        // locate DNS SRV record using TCP
        if (DEBUG) {
            System.out.println("getKDCFromDNS using TCP");
        }
        srvs = KrbServiceLocator.getKerberosService(realm, "_tcp");
    }
    if (srvs == null) {
        // no DNS SRV records
        throw new KrbException(Krb5.KRB_ERR_GENERIC,
            "Unable to locate KDC for realm " + realm);
    }
    if (srvs.length == 0) {
        return null;
    }
    for (int i = 0; i < srvs.length; i++) {
        kdcs += srvs[i].trim() + " ";
    }
    kdcs = kdcs.trim();
    if (kdcs.equals("")) {
        return null;
    }
    return kdcs;
}
 
Example 14
Source File: KdcComm.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public KdcComm(String realm) throws KrbException {
    if (realm == null) {
       realm = Config.getInstance().getDefaultRealm();
        if (realm == null) {
            throw new KrbException(Krb5.KRB_ERR_GENERIC,
                                   "Cannot find default realm");
        }
    }
    this.realm = realm;
}
 
Example 15
Source File: Config.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Locate Kerberos realm using DNS
 *
 * @return the Kerberos realm
 */
private String getRealmFromDNS() throws KrbException {
    // use DNS to locate Kerberos realm
    String realm = null;
    String hostName = null;
    try {
        hostName = InetAddress.getLocalHost().getCanonicalHostName();
    } catch (UnknownHostException e) {
        KrbException ke = new KrbException(Krb5.KRB_ERR_GENERIC,
            "Unable to locate Kerberos realm: " + e.getMessage());
        ke.initCause(e);
        throw (ke);
    }
    // get the domain realm mapping from the configuration
    String mapRealm = PrincipalName.mapHostToRealm(hostName);
    if (mapRealm == null) {
        // No match. Try search and/or domain in /etc/resolv.conf
        List<String> srchlist = ResolverConfiguration.open().searchlist();
        for (String domain: srchlist) {
            realm = checkRealm(domain);
            if (realm != null) {
                break;
            }
        }
    } else {
        realm = checkRealm(mapRealm);
    }
    if (realm == null) {
        throw new KrbException(Krb5.KRB_ERR_GENERIC,
                            "Unable to locate Kerberos realm");
    }
    return realm;
}
 
Example 16
Source File: Config.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Locate KDC using DNS
 *
 * @param realm the realm for which the master KDC is desired
 * @return the KDC
 */
private String getKDCFromDNS(String realm) throws KrbException {
    // use DNS to locate KDC
    String kdcs = "";
    String[] srvs = null;
    // locate DNS SRV record using UDP
    if (DEBUG) {
        System.out.println("getKDCFromDNS using UDP");
    }
    srvs = KrbServiceLocator.getKerberosService(realm, "_udp");
    if (srvs == null) {
        // locate DNS SRV record using TCP
        if (DEBUG) {
            System.out.println("getKDCFromDNS using TCP");
        }
        srvs = KrbServiceLocator.getKerberosService(realm, "_tcp");
    }
    if (srvs == null) {
        // no DNS SRV records
        throw new KrbException(Krb5.KRB_ERR_GENERIC,
            "Unable to locate KDC for realm " + realm);
    }
    if (srvs.length == 0) {
        return null;
    }
    for (int i = 0; i < srvs.length; i++) {
        kdcs += srvs[i].trim() + " ";
    }
    kdcs = kdcs.trim();
    if (kdcs.equals("")) {
        return null;
    }
    return kdcs;
}
 
Example 17
Source File: KdcComm.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private byte[] send(byte[] obuf, boolean useTCP)
    throws IOException, KrbException {

    if (obuf == null)
        return null;
    Config cfg = Config.getInstance();

    if (realm == null) {
        realm = cfg.getDefaultRealm();
        if (realm == null) {
            throw new KrbException(Krb5.KRB_ERR_GENERIC,
                                   "Cannot find default realm");
        }
    }

    String kdcList = cfg.getKDCList(realm);
    if (kdcList == null) {
        throw new KrbException("Cannot get kdc for realm " + realm);
    }
    // tempKdc may include the port number also
    Iterator<String> tempKdc = KdcAccessibility.list(kdcList).iterator();
    if (!tempKdc.hasNext()) {
        throw new KrbException("Cannot get kdc for realm " + realm);
    }
    byte[] ibuf = null;
    try {
        ibuf = sendIfPossible(obuf, tempKdc.next(), useTCP);
    } catch(Exception first) {
        boolean ok = false;
        while(tempKdc.hasNext()) {
            try {
                ibuf = sendIfPossible(obuf, tempKdc.next(), useTCP);
                ok = true;
                break;
            } catch(Exception ignore) {}
        }
        if (!ok) throw first;
    }
    if (ibuf == null) {
        throw new IOException("Cannot get a KDC reply");
    }
    return ibuf;
}
 
Example 18
Source File: KdcComm.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private byte[] send(byte[] obuf, boolean useTCP)
    throws IOException, KrbException {

    if (obuf == null)
        return null;
    Config cfg = Config.getInstance();

    if (realm == null) {
        realm = cfg.getDefaultRealm();
        if (realm == null) {
            throw new KrbException(Krb5.KRB_ERR_GENERIC,
                                   "Cannot find default realm");
        }
    }

    String kdcList = cfg.getKDCList(realm);
    if (kdcList == null) {
        throw new KrbException("Cannot get kdc for realm " + realm);
    }
    // tempKdc may include the port number also
    Iterator<String> tempKdc = KdcAccessibility.list(kdcList).iterator();
    if (!tempKdc.hasNext()) {
        throw new KrbException("Cannot get kdc for realm " + realm);
    }
    byte[] ibuf = null;
    try {
        ibuf = sendIfPossible(obuf, tempKdc.next(), useTCP);
    } catch(Exception first) {
        boolean ok = false;
        while(tempKdc.hasNext()) {
            try {
                ibuf = sendIfPossible(obuf, tempKdc.next(), useTCP);
                ok = true;
                break;
            } catch(Exception ignore) {}
        }
        if (!ok) throw first;
    }
    if (ibuf == null) {
        throw new IOException("Cannot get a KDC reply");
    }
    return ibuf;
}
 
Example 19
Source File: KdcComm.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private byte[] send(byte[] obuf, boolean useTCP)
    throws IOException, KrbException {

    if (obuf == null)
        return null;
    Config cfg = Config.getInstance();

    if (realm == null) {
        realm = cfg.getDefaultRealm();
        if (realm == null) {
            throw new KrbException(Krb5.KRB_ERR_GENERIC,
                                   "Cannot find default realm");
        }
    }

    String kdcList = cfg.getKDCList(realm);
    if (kdcList == null) {
        throw new KrbException("Cannot get kdc for realm " + realm);
    }
    // tempKdc may include the port number also
    Iterator<String> tempKdc = KdcAccessibility.list(kdcList).iterator();
    if (!tempKdc.hasNext()) {
        throw new KrbException("Cannot get kdc for realm " + realm);
    }
    byte[] ibuf = null;
    try {
        ibuf = sendIfPossible(obuf, tempKdc.next(), useTCP);
    } catch(Exception first) {
        boolean ok = false;
        while(tempKdc.hasNext()) {
            try {
                ibuf = sendIfPossible(obuf, tempKdc.next(), useTCP);
                ok = true;
                break;
            } catch(Exception ignore) {}
        }
        if (!ok) throw first;
    }
    if (ibuf == null) {
        throw new IOException("Cannot get a KDC reply");
    }
    return ibuf;
}
 
Example 20
Source File: KdcComm.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private byte[] send(byte[] obuf, boolean useTCP)
    throws IOException, KrbException {

    if (obuf == null)
        return null;
    Config cfg = Config.getInstance();

    if (realm == null) {
        realm = cfg.getDefaultRealm();
        if (realm == null) {
            throw new KrbException(Krb5.KRB_ERR_GENERIC,
                                   "Cannot find default realm");
        }
    }

    String kdcList = cfg.getKDCList(realm);
    if (kdcList == null) {
        throw new KrbException("Cannot get kdc for realm " + realm);
    }
    // tempKdc may include the port number also
    Iterator<String> tempKdc = KdcAccessibility.list(kdcList).iterator();
    if (!tempKdc.hasNext()) {
        throw new KrbException("Cannot get kdc for realm " + realm);
    }
    byte[] ibuf = null;
    try {
        ibuf = sendIfPossible(obuf, tempKdc.next(), useTCP);
    } catch(Exception first) {
        boolean ok = false;
        while(tempKdc.hasNext()) {
            try {
                ibuf = sendIfPossible(obuf, tempKdc.next(), useTCP);
                ok = true;
                break;
            } catch(Exception ignore) {}
        }
        if (!ok) throw first;
    }
    if (ibuf == null) {
        throw new IOException("Cannot get a KDC reply");
    }
    return ibuf;
}