sun.security.jgss.krb5.Krb5NameElement Java Examples

The following examples show how to use sun.security.jgss.krb5.Krb5NameElement. 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: GSSUtil.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Note: The current impl only works with Sun's impl of
 * GSSName and GSSCredential since it depends on package
 * private APIs.
 */
public static Subject getSubject(GSSName name,
                                 GSSCredential creds) {

    HashSet<Object> privCredentials = null;
    HashSet<Object> pubCredentials = new HashSet<Object>(); // empty Set

    Set<GSSCredentialSpi> gssCredentials = null;

    Set<KerberosPrincipal> krb5Principals =
                            new HashSet<KerberosPrincipal>();

    if (name instanceof GSSNameImpl) {
        try {
            GSSNameSpi ne = ((GSSNameImpl) name).getElement
                (GSS_KRB5_MECH_OID);
            String krbName = ne.toString();
            if (ne instanceof Krb5NameElement) {
                krbName =
                    ((Krb5NameElement) ne).getKrb5PrincipalName().getName();
            }
            KerberosPrincipal krbPrinc = new KerberosPrincipal(krbName);
            krb5Principals.add(krbPrinc);
        } catch (GSSException ge) {
            debug("Skipped name " + name + " due to " + ge);
        }
    }

    if (creds instanceof GSSCredentialImpl) {
        gssCredentials = ((GSSCredentialImpl) creds).getElements();
        privCredentials = new HashSet<Object>(gssCredentials.size());
        populateCredentials(privCredentials, gssCredentials);
    } else {
        privCredentials = new HashSet<Object>(); // empty Set
    }
    debug("Created Subject with the following");
    debug("principals=" + krb5Principals);
    debug("public creds=" + pubCredentials);
    debug("private creds=" + privCredentials);

    return new Subject(false, krb5Principals, pubCredentials,
                       privCredentials);

}
 
Example #2
Source File: GSSUtil.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Note: The current impl only works with Sun's impl of
 * GSSName and GSSCredential since it depends on package
 * private APIs.
 */
public static Subject getSubject(GSSName name,
                                 GSSCredential creds) {

    HashSet<Object> privCredentials = null;
    HashSet<Object> pubCredentials = new HashSet<Object>(); // empty Set

    Set<GSSCredentialSpi> gssCredentials = null;

    Set<KerberosPrincipal> krb5Principals =
                            new HashSet<KerberosPrincipal>();

    if (name instanceof GSSNameImpl) {
        try {
            GSSNameSpi ne = ((GSSNameImpl) name).getElement
                (GSS_KRB5_MECH_OID);
            String krbName = ne.toString();
            if (ne instanceof Krb5NameElement) {
                krbName =
                    ((Krb5NameElement) ne).getKrb5PrincipalName().getName();
            }
            KerberosPrincipal krbPrinc = new KerberosPrincipal(krbName);
            krb5Principals.add(krbPrinc);
        } catch (GSSException ge) {
            debug("Skipped name " + name + " due to " + ge);
        }
    }

    if (creds instanceof GSSCredentialImpl) {
        gssCredentials = ((GSSCredentialImpl) creds).getElements();
        privCredentials = new HashSet<Object>(gssCredentials.size());
        populateCredentials(privCredentials, gssCredentials);
    } else {
        privCredentials = new HashSet<Object>(); // empty Set
    }
    debug("Created Subject with the following");
    debug("principals=" + krb5Principals);
    debug("public creds=" + pubCredentials);
    debug("private creds=" + privCredentials);

    return new Subject(false, krb5Principals, pubCredentials,
                       privCredentials);

}
 
Example #3
Source File: GSSUtil.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Note: The current impl only works with Sun's impl of
 * GSSName and GSSCredential since it depends on package
 * private APIs.
 */
public static Subject getSubject(GSSName name,
                                 GSSCredential creds) {

    HashSet<Object> privCredentials = null;
    HashSet<Object> pubCredentials = new HashSet<Object>(); // empty Set

    Set<GSSCredentialSpi> gssCredentials = null;

    Set<KerberosPrincipal> krb5Principals =
                            new HashSet<KerberosPrincipal>();

    if (name instanceof GSSNameImpl) {
        try {
            GSSNameSpi ne = ((GSSNameImpl) name).getElement
                (GSS_KRB5_MECH_OID);
            String krbName = ne.toString();
            if (ne instanceof Krb5NameElement) {
                krbName =
                    ((Krb5NameElement) ne).getKrb5PrincipalName().getName();
            }
            KerberosPrincipal krbPrinc = new KerberosPrincipal(krbName);
            krb5Principals.add(krbPrinc);
        } catch (GSSException ge) {
            debug("Skipped name " + name + " due to " + ge);
        }
    }

    if (creds instanceof GSSCredentialImpl) {
        gssCredentials = ((GSSCredentialImpl) creds).getElements();
        privCredentials = new HashSet<Object>(gssCredentials.size());
        populateCredentials(privCredentials, gssCredentials);
    } else {
        privCredentials = new HashSet<Object>(); // empty Set
    }
    debug("Created Subject with the following");
    debug("principals=" + krb5Principals);
    debug("public creds=" + pubCredentials);
    debug("private creds=" + privCredentials);

    return new Subject(false, krb5Principals, pubCredentials,
                       privCredentials);

}
 
Example #4
Source File: GSSUtil.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Note: The current impl only works with Sun's impl of
 * GSSName and GSSCredential since it depends on package
 * private APIs.
 */
public static Subject getSubject(GSSName name,
                                 GSSCredential creds) {

    HashSet<Object> privCredentials = null;
    HashSet<Object> pubCredentials = new HashSet<Object>(); // empty Set

    Set<GSSCredentialSpi> gssCredentials = null;

    Set<KerberosPrincipal> krb5Principals =
                            new HashSet<KerberosPrincipal>();

    if (name instanceof GSSNameImpl) {
        try {
            GSSNameSpi ne = ((GSSNameImpl) name).getElement
                (GSS_KRB5_MECH_OID);
            String krbName = ne.toString();
            if (ne instanceof Krb5NameElement) {
                krbName =
                    ((Krb5NameElement) ne).getKrb5PrincipalName().getName();
            }
            KerberosPrincipal krbPrinc = new KerberosPrincipal(krbName);
            krb5Principals.add(krbPrinc);
        } catch (GSSException ge) {
            debug("Skipped name " + name + " due to " + ge);
        }
    }

    if (creds instanceof GSSCredentialImpl) {
        gssCredentials = ((GSSCredentialImpl) creds).getElements();
        privCredentials = new HashSet<Object>(gssCredentials.size());
        populateCredentials(privCredentials, gssCredentials);
    } else {
        privCredentials = new HashSet<Object>(); // empty Set
    }
    debug("Created Subject with the following");
    debug("principals=" + krb5Principals);
    debug("public creds=" + pubCredentials);
    debug("private creds=" + privCredentials);

    return new Subject(false, krb5Principals, pubCredentials,
                       privCredentials);

}
 
Example #5
Source File: GSSUtil.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Note: The current impl only works with Sun's impl of
 * GSSName and GSSCredential since it depends on package
 * private APIs.
 */
public static Subject getSubject(GSSName name,
                                 GSSCredential creds) {

    HashSet<Object> privCredentials = null;
    HashSet<Object> pubCredentials = new HashSet<Object>(); // empty Set

    Set<GSSCredentialSpi> gssCredentials = null;

    Set<KerberosPrincipal> krb5Principals =
                            new HashSet<KerberosPrincipal>();

    if (name instanceof GSSNameImpl) {
        try {
            GSSNameSpi ne = ((GSSNameImpl) name).getElement
                (GSS_KRB5_MECH_OID);
            String krbName = ne.toString();
            if (ne instanceof Krb5NameElement) {
                krbName =
                    ((Krb5NameElement) ne).getKrb5PrincipalName().getName();
            }
            KerberosPrincipal krbPrinc = new KerberosPrincipal(krbName);
            krb5Principals.add(krbPrinc);
        } catch (GSSException ge) {
            debug("Skipped name " + name + " due to " + ge);
        }
    }

    if (creds instanceof GSSCredentialImpl) {
        gssCredentials = ((GSSCredentialImpl) creds).getElements();
        privCredentials = new HashSet<Object>(gssCredentials.size());
        populateCredentials(privCredentials, gssCredentials);
    } else {
        privCredentials = new HashSet<Object>(); // empty Set
    }
    debug("Created Subject with the following");
    debug("principals=" + krb5Principals);
    debug("public creds=" + pubCredentials);
    debug("private creds=" + privCredentials);

    return new Subject(false, krb5Principals, pubCredentials,
                       privCredentials);

}
 
Example #6
Source File: GSSUtil.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Note: The current impl only works with Sun's impl of
 * GSSName and GSSCredential since it depends on package
 * private APIs.
 */
public static Subject getSubject(GSSName name,
                                 GSSCredential creds) {

    HashSet<Object> privCredentials = null;
    HashSet<Object> pubCredentials = new HashSet<Object>(); // empty Set

    Set<GSSCredentialSpi> gssCredentials = null;

    Set<KerberosPrincipal> krb5Principals =
                            new HashSet<KerberosPrincipal>();

    if (name instanceof GSSNameImpl) {
        try {
            GSSNameSpi ne = ((GSSNameImpl) name).getElement
                (GSS_KRB5_MECH_OID);
            String krbName = ne.toString();
            if (ne instanceof Krb5NameElement) {
                krbName =
                    ((Krb5NameElement) ne).getKrb5PrincipalName().getName();
            }
            KerberosPrincipal krbPrinc = new KerberosPrincipal(krbName);
            krb5Principals.add(krbPrinc);
        } catch (GSSException ge) {
            debug("Skipped name " + name + " due to " + ge);
        }
    }

    if (creds instanceof GSSCredentialImpl) {
        gssCredentials = ((GSSCredentialImpl) creds).getElements();
        privCredentials = new HashSet<Object>(gssCredentials.size());
        populateCredentials(privCredentials, gssCredentials);
    } else {
        privCredentials = new HashSet<Object>(); // empty Set
    }
    debug("Created Subject with the following");
    debug("principals=" + krb5Principals);
    debug("public creds=" + pubCredentials);
    debug("private creds=" + privCredentials);

    return new Subject(false, krb5Principals, pubCredentials,
                       privCredentials);

}
 
Example #7
Source File: GSSUtil.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Note: The current impl only works with Sun's impl of
 * GSSName and GSSCredential since it depends on package
 * private APIs.
 */
public static Subject getSubject(GSSName name,
                                 GSSCredential creds) {

    HashSet<Object> privCredentials = null;
    HashSet<Object> pubCredentials = new HashSet<Object>(); // empty Set

    Set<GSSCredentialSpi> gssCredentials = null;

    Set<KerberosPrincipal> krb5Principals =
                            new HashSet<KerberosPrincipal>();

    if (name instanceof GSSNameImpl) {
        try {
            GSSNameSpi ne = ((GSSNameImpl) name).getElement
                (GSS_KRB5_MECH_OID);
            String krbName = ne.toString();
            if (ne instanceof Krb5NameElement) {
                krbName =
                    ((Krb5NameElement) ne).getKrb5PrincipalName().getName();
            }
            KerberosPrincipal krbPrinc = new KerberosPrincipal(krbName);
            krb5Principals.add(krbPrinc);
        } catch (GSSException ge) {
            debug("Skipped name " + name + " due to " + ge);
        }
    }

    if (creds instanceof GSSCredentialImpl) {
        gssCredentials = ((GSSCredentialImpl) creds).getElements();
        privCredentials = new HashSet<Object>(gssCredentials.size());
        populateCredentials(privCredentials, gssCredentials);
    } else {
        privCredentials = new HashSet<Object>(); // empty Set
    }
    debug("Created Subject with the following");
    debug("principals=" + krb5Principals);
    debug("public creds=" + pubCredentials);
    debug("private creds=" + privCredentials);

    return new Subject(false, krb5Principals, pubCredentials,
                       privCredentials);

}
 
Example #8
Source File: GSSUtil.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Note: The current impl only works with Sun's impl of
 * GSSName and GSSCredential since it depends on package
 * private APIs.
 */
public static Subject getSubject(GSSName name,
                                 GSSCredential creds) {

    HashSet<Object> privCredentials = null;
    HashSet<Object> pubCredentials = new HashSet<Object>(); // empty Set

    Set<GSSCredentialSpi> gssCredentials = null;

    Set<KerberosPrincipal> krb5Principals =
                            new HashSet<KerberosPrincipal>();

    if (name instanceof GSSNameImpl) {
        try {
            GSSNameSpi ne = ((GSSNameImpl) name).getElement
                (GSS_KRB5_MECH_OID);
            String krbName = ne.toString();
            if (ne instanceof Krb5NameElement) {
                krbName =
                    ((Krb5NameElement) ne).getKrb5PrincipalName().getName();
            }
            KerberosPrincipal krbPrinc = new KerberosPrincipal(krbName);
            krb5Principals.add(krbPrinc);
        } catch (GSSException ge) {
            debug("Skipped name " + name + " due to " + ge);
        }
    }

    if (creds instanceof GSSCredentialImpl) {
        gssCredentials = ((GSSCredentialImpl) creds).getElements();
        privCredentials = new HashSet<Object>(gssCredentials.size());
        populateCredentials(privCredentials, gssCredentials);
    } else {
        privCredentials = new HashSet<Object>(); // empty Set
    }
    debug("Created Subject with the following");
    debug("principals=" + krb5Principals);
    debug("public creds=" + pubCredentials);
    debug("private creds=" + privCredentials);

    return new Subject(false, krb5Principals, pubCredentials,
                       privCredentials);

}
 
Example #9
Source File: GSSUtil.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Note: The current impl only works with Sun's impl of
 * GSSName and GSSCredential since it depends on package
 * private APIs.
 */
public static Subject getSubject(GSSName name,
                                 GSSCredential creds) {

    HashSet<Object> privCredentials = null;
    HashSet<Object> pubCredentials = new HashSet<Object>(); // empty Set

    Set<GSSCredentialSpi> gssCredentials = null;

    Set<KerberosPrincipal> krb5Principals =
                            new HashSet<KerberosPrincipal>();

    if (name instanceof GSSNameImpl) {
        try {
            GSSNameSpi ne = ((GSSNameImpl) name).getElement
                (GSS_KRB5_MECH_OID);
            String krbName = ne.toString();
            if (ne instanceof Krb5NameElement) {
                krbName =
                    ((Krb5NameElement) ne).getKrb5PrincipalName().getName();
            }
            KerberosPrincipal krbPrinc = new KerberosPrincipal(krbName);
            krb5Principals.add(krbPrinc);
        } catch (GSSException ge) {
            debug("Skipped name " + name + " due to " + ge);
        }
    }

    if (creds instanceof GSSCredentialImpl) {
        gssCredentials = ((GSSCredentialImpl) creds).getElements();
        privCredentials = new HashSet<Object>(gssCredentials.size());
        populateCredentials(privCredentials, gssCredentials);
    } else {
        privCredentials = new HashSet<Object>(); // empty Set
    }
    debug("Created Subject with the following");
    debug("principals=" + krb5Principals);
    debug("public creds=" + pubCredentials);
    debug("private creds=" + privCredentials);

    return new Subject(false, krb5Principals, pubCredentials,
                       privCredentials);

}
 
Example #10
Source File: GSSUtil.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Note: The current impl only works with Sun's impl of
 * GSSName and GSSCredential since it depends on package
 * private APIs.
 */
public static Subject getSubject(GSSName name,
                                 GSSCredential creds) {

    HashSet<Object> privCredentials = null;
    HashSet<Object> pubCredentials = new HashSet<Object>(); // empty Set

    Set<GSSCredentialSpi> gssCredentials = null;

    Set<KerberosPrincipal> krb5Principals =
                            new HashSet<KerberosPrincipal>();

    if (name instanceof GSSNameImpl) {
        try {
            GSSNameSpi ne = ((GSSNameImpl) name).getElement
                (GSS_KRB5_MECH_OID);
            String krbName = ne.toString();
            if (ne instanceof Krb5NameElement) {
                krbName =
                    ((Krb5NameElement) ne).getKrb5PrincipalName().getName();
            }
            KerberosPrincipal krbPrinc = new KerberosPrincipal(krbName);
            krb5Principals.add(krbPrinc);
        } catch (GSSException ge) {
            debug("Skipped name " + name + " due to " + ge);
        }
    }

    if (creds instanceof GSSCredentialImpl) {
        gssCredentials = ((GSSCredentialImpl) creds).getElements();
        privCredentials = new HashSet<Object>(gssCredentials.size());
        populateCredentials(privCredentials, gssCredentials);
    } else {
        privCredentials = new HashSet<Object>(); // empty Set
    }
    debug("Created Subject with the following");
    debug("principals=" + krb5Principals);
    debug("public creds=" + pubCredentials);
    debug("private creds=" + privCredentials);

    return new Subject(false, krb5Principals, pubCredentials,
                       privCredentials);

}
 
Example #11
Source File: GSSUtil.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Note: The current impl only works with Sun's impl of
 * GSSName and GSSCredential since it depends on package
 * private APIs.
 */
public static Subject getSubject(GSSName name,
                                 GSSCredential creds) {

    HashSet<Object> privCredentials = null;
    HashSet<Object> pubCredentials = new HashSet<Object>(); // empty Set

    Set<GSSCredentialSpi> gssCredentials = null;

    Set<KerberosPrincipal> krb5Principals =
                            new HashSet<KerberosPrincipal>();

    if (name instanceof GSSNameImpl) {
        try {
            GSSNameSpi ne = ((GSSNameImpl) name).getElement
                (GSS_KRB5_MECH_OID);
            String krbName = ne.toString();
            if (ne instanceof Krb5NameElement) {
                krbName =
                    ((Krb5NameElement) ne).getKrb5PrincipalName().getName();
            }
            KerberosPrincipal krbPrinc = new KerberosPrincipal(krbName);
            krb5Principals.add(krbPrinc);
        } catch (GSSException ge) {
            debug("Skipped name " + name + " due to " + ge);
        }
    }

    if (creds instanceof GSSCredentialImpl) {
        gssCredentials = ((GSSCredentialImpl) creds).getElements();
        privCredentials = new HashSet<Object>(gssCredentials.size());
        populateCredentials(privCredentials, gssCredentials);
    } else {
        privCredentials = new HashSet<Object>(); // empty Set
    }
    debug("Created Subject with the following");
    debug("principals=" + krb5Principals);
    debug("public creds=" + pubCredentials);
    debug("private creds=" + privCredentials);

    return new Subject(false, krb5Principals, pubCredentials,
                       privCredentials);

}
 
Example #12
Source File: GSSUtil.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Note: The current impl only works with Sun's impl of
 * GSSName and GSSCredential since it depends on package
 * private APIs.
 */
public static Subject getSubject(GSSName name,
                                 GSSCredential creds) {

    HashSet<Object> privCredentials = null;
    HashSet<Object> pubCredentials = new HashSet<Object>(); // empty Set

    Set<GSSCredentialSpi> gssCredentials = null;

    Set<KerberosPrincipal> krb5Principals =
                            new HashSet<KerberosPrincipal>();

    if (name instanceof GSSNameImpl) {
        try {
            GSSNameSpi ne = ((GSSNameImpl) name).getElement
                (GSS_KRB5_MECH_OID);
            String krbName = ne.toString();
            if (ne instanceof Krb5NameElement) {
                krbName =
                    ((Krb5NameElement) ne).getKrb5PrincipalName().getName();
            }
            KerberosPrincipal krbPrinc = new KerberosPrincipal(krbName);
            krb5Principals.add(krbPrinc);
        } catch (GSSException ge) {
            debug("Skipped name " + name + " due to " + ge);
        }
    }

    if (creds instanceof GSSCredentialImpl) {
        gssCredentials = ((GSSCredentialImpl) creds).getElements();
        privCredentials = new HashSet<Object>(gssCredentials.size());
        populateCredentials(privCredentials, gssCredentials);
    } else {
        privCredentials = new HashSet<Object>(); // empty Set
    }
    debug("Created Subject with the following");
    debug("principals=" + krb5Principals);
    debug("public creds=" + pubCredentials);
    debug("private creds=" + privCredentials);

    return new Subject(false, krb5Principals, pubCredentials,
                       privCredentials);

}
 
Example #13
Source File: GSSUtil.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Note: The current impl only works with Sun's impl of
 * GSSName and GSSCredential since it depends on package
 * private APIs.
 */
public static Subject getSubject(GSSName name,
                                 GSSCredential creds) {

    HashSet<Object> privCredentials = null;
    HashSet<Object> pubCredentials = new HashSet<Object>(); // empty Set

    Set<GSSCredentialSpi> gssCredentials = null;

    Set<KerberosPrincipal> krb5Principals =
                            new HashSet<KerberosPrincipal>();

    if (name instanceof GSSNameImpl) {
        try {
            GSSNameSpi ne = ((GSSNameImpl) name).getElement
                (GSS_KRB5_MECH_OID);
            String krbName = ne.toString();
            if (ne instanceof Krb5NameElement) {
                krbName =
                    ((Krb5NameElement) ne).getKrb5PrincipalName().getName();
            }
            KerberosPrincipal krbPrinc = new KerberosPrincipal(krbName);
            krb5Principals.add(krbPrinc);
        } catch (GSSException ge) {
            debug("Skipped name " + name + " due to " + ge);
        }
    }

    if (creds instanceof GSSCredentialImpl) {
        gssCredentials = ((GSSCredentialImpl) creds).getElements();
        privCredentials = new HashSet<Object>(gssCredentials.size());
        populateCredentials(privCredentials, gssCredentials);
    } else {
        privCredentials = new HashSet<Object>(); // empty Set
    }
    debug("Created Subject with the following");
    debug("principals=" + krb5Principals);
    debug("public creds=" + pubCredentials);
    debug("private creds=" + privCredentials);

    return new Subject(false, krb5Principals, pubCredentials,
                       privCredentials);

}