Java Code Examples for sun.security.jgss.GSSUtil#isKerberosMech()

The following examples show how to use sun.security.jgss.GSSUtil#isKerberosMech() . 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: NativeGSSContext.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
NativeGSSContext(GSSCredElement myCred, GSSLibStub stub)
    throws GSSException {
    cStub = stub;
    cred = myCred;

    if (cred != null) targetName = cred.getName();

    isInitiator = false;
    // Defer Service permission check for default acceptor cred
    // to acceptSecContext()
    if (GSSUtil.isKerberosMech(cStub.getMech()) && targetName != null) {
        doServicePermCheck();
    }

    // srcName and potentially targetName (when myCred is null)
    // will be set in GSSLibStub.acceptContext(...)
}
 
Example 2
Source File: NativeGSSContext.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
NativeGSSContext(long pCtxt, GSSLibStub stub) throws GSSException {
    assert(pContext != 0);
    pContext = pCtxt;
    cStub = stub;

    // Set everything except cred, cb, delegatedCred
    long[] info = cStub.inquireContext(pContext);
    if (info.length != NUM_OF_INQUIRE_VALUES) {
        throw new RuntimeException("Bug w/ GSSLibStub.inquireContext()");
    }
    srcName = new GSSNameElement(info[0], cStub);
    targetName = new GSSNameElement(info[1], cStub);
    isInitiator = (info[2] != 0);
    isEstablished = (info[3] != 0);
    flags = (int) info[4];
    lifetime = (int) info[5];

    // Do Service Permission check when importing SPNEGO context
    // just to be safe
    Oid mech = cStub.getMech();
    if (GSSUtil.isSpNegoMech(mech) || GSSUtil.isKerberosMech(mech)) {
        doServicePermCheck();
    }
}
 
Example 3
Source File: NativeGSSContext.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
NativeGSSContext(long pCtxt, GSSLibStub stub) throws GSSException {
    assert(pContext != 0);
    pContext = pCtxt;
    cStub = stub;

    // Set everything except cred, cb, delegatedCred
    long[] info = cStub.inquireContext(pContext);
    if (info.length != NUM_OF_INQUIRE_VALUES) {
        throw new RuntimeException("Bug w/ GSSLibStub.inquireContext()");
    }
    srcName = new GSSNameElement(info[0], cStub);
    targetName = new GSSNameElement(info[1], cStub);
    isInitiator = (info[2] != 0);
    isEstablished = (info[3] != 0);
    flags = (int) info[4];
    lifetime = (int) info[5];

    // Do Service Permission check when importing SPNEGO context
    // just to be safe
    Oid mech = cStub.getMech();
    if (GSSUtil.isSpNegoMech(mech) || GSSUtil.isKerberosMech(mech)) {
        doServicePermCheck();
    }
}
 
Example 4
Source File: NativeGSSContext.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
NativeGSSContext(long pCtxt, GSSLibStub stub) throws GSSException {
    assert(pContext != 0);
    pContext = pCtxt;
    cStub = stub;

    // Set everything except cred, cb, delegatedCred
    long[] info = cStub.inquireContext(pContext);
    if (info.length != NUM_OF_INQUIRE_VALUES) {
        throw new RuntimeException("Bug w/ GSSLibStub.inquireContext()");
    }
    srcName = new GSSNameElement(info[0], cStub);
    targetName = new GSSNameElement(info[1], cStub);
    isInitiator = (info[2] != 0);
    isEstablished = (info[3] != 0);
    flags = (int) info[4];
    lifetime = (int) info[5];

    // Do Service Permission check when importing SPNEGO context
    // just to be safe
    Oid mech = cStub.getMech();
    if (GSSUtil.isSpNegoMech(mech) || GSSUtil.isKerberosMech(mech)) {
        doServicePermCheck();
    }
}
 
Example 5
Source File: NativeGSSContext.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
NativeGSSContext(GSSCredElement myCred, GSSLibStub stub)
    throws GSSException {
    cStub = stub;
    cred = myCred;

    if (cred != null) targetName = cred.getName();

    isInitiator = false;
    // Defer Service permission check for default acceptor cred
    // to acceptSecContext()
    if (GSSUtil.isKerberosMech(cStub.getMech()) && targetName != null) {
        doServicePermCheck();
    }

    // srcName and potentially targetName (when myCred is null)
    // will be set in GSSLibStub.acceptContext(...)
}
 
Example 6
Source File: NativeGSSContext.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
NativeGSSContext(GSSCredElement myCred, GSSLibStub stub)
    throws GSSException {
    cStub = stub;
    cred = myCred;

    if (cred != null) targetName = cred.getName();

    isInitiator = false;
    // Defer Service permission check for default acceptor cred
    // to acceptSecContext()
    if (GSSUtil.isKerberosMech(cStub.getMech()) && targetName != null) {
        doServicePermCheck();
    }

    // srcName and potentially targetName (when myCred is null)
    // will be set in GSSLibStub.acceptContext(...)
}
 
Example 7
Source File: NativeGSSContext.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
NativeGSSContext(GSSCredElement myCred, GSSLibStub stub)
    throws GSSException {
    cStub = stub;
    cred = myCred;

    if (cred != null) targetName = cred.getName();

    isInitiator = false;
    // Defer Service permission check for default acceptor cred
    // to acceptSecContext()
    if (GSSUtil.isKerberosMech(cStub.getMech()) && targetName != null) {
        doServicePermCheck();
    }

    // srcName and potentially targetName (when myCred is null)
    // will be set in GSSLibStub.acceptContext(...)
}
 
Example 8
Source File: GSSCredElement.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
void doServicePermCheck() throws GSSException {
    if (GSSUtil.isKerberosMech(cStub.getMech())) {
        if (System.getSecurityManager() != null) {
            if (isInitiatorCredential()) {
                String tgsName = Krb5Util.getTGSName(name);
                Krb5Util.checkServicePermission(tgsName, "initiate");
            }
            if (isAcceptorCredential() &&
                name != GSSNameElement.DEF_ACCEPTOR) {
                String krbName = name.getKrbName();
                Krb5Util.checkServicePermission(krbName, "accept");
            }
        }
    }
}
 
Example 9
Source File: GSSCredElement.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
void doServicePermCheck() throws GSSException {
    if (GSSUtil.isKerberosMech(cStub.getMech())) {
        if (System.getSecurityManager() != null) {
            if (isInitiatorCredential()) {
                String tgsName = Krb5Util.getTGSName(name);
                Krb5Util.checkServicePermission(tgsName, "initiate");
            }
            if (isAcceptorCredential() &&
                name != GSSNameElement.DEF_ACCEPTOR) {
                String krbName = name.getKrbName();
                Krb5Util.checkServicePermission(krbName, "accept");
            }
        }
    }
}
 
Example 10
Source File: NativeGSSContext.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public byte[] acceptSecContext(InputStream is, int mechTokenLen)
    throws GSSException {
    byte[] outToken = null;
    if ((!isEstablished) && (!isInitiator)) {
        byte[] inToken = retrieveToken(is, mechTokenLen);
        SunNativeProvider.debug("acceptSecContext=> inToken len=" +
                                inToken.length);
        long pCred = (cred == null? 0 : cred.pCred);
        outToken = cStub.acceptContext(pCred, cb, inToken, this);
        SunNativeProvider.debug("acceptSecContext=> outToken len=" +
                                (outToken == null? 0 : outToken.length));

        if (targetName == null) {
            targetName = new GSSNameElement
                (cStub.getContextName(pContext, false), cStub);
            // Replace the current default acceptor cred now that
            // the context acceptor name is available
            if (cred != null) cred.dispose();
            cred = new GSSCredElement(targetName, lifetime,
                                      GSSCredential.ACCEPT_ONLY, cStub);
        }

        // Only inspect token when the permission check has not
        // been performed
        if (GSSUtil.isSpNegoMech(cStub.getMech()) &&
            (outToken != null) && !skipServicePermCheck) {
            if (GSSUtil.isKerberosMech(getMechFromSpNegoToken
                                       (outToken, false))) {
                doServicePermCheck();
            }
        }
    }
    return outToken;
}
 
Example 11
Source File: NativeGSSContext.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public byte[] acceptSecContext(InputStream is, int mechTokenLen)
    throws GSSException {
    byte[] outToken = null;
    if ((!isEstablished) && (!isInitiator)) {
        byte[] inToken = retrieveToken(is, mechTokenLen);
        SunNativeProvider.debug("acceptSecContext=> inToken len=" +
                                inToken.length);
        long pCred = (cred == null? 0 : cred.pCred);
        outToken = cStub.acceptContext(pCred, cb, inToken, this);
        SunNativeProvider.debug("acceptSecContext=> outToken len=" +
                                (outToken == null? 0 : outToken.length));

        if (targetName == null) {
            targetName = new GSSNameElement
                (cStub.getContextName(pContext, false), cStub);
            // Replace the current default acceptor cred now that
            // the context acceptor name is available
            if (cred != null) cred.dispose();
            cred = new GSSCredElement(targetName, lifetime,
                                      GSSCredential.ACCEPT_ONLY, cStub);
        }

        // Only inspect token when the permission check has not
        // been performed
        if (GSSUtil.isSpNegoMech(cStub.getMech()) &&
            (outToken != null) && !skipServicePermCheck) {
            if (GSSUtil.isKerberosMech(getMechFromSpNegoToken
                                       (outToken, false))) {
                doServicePermCheck();
            }
        }
    }
    return outToken;
}
 
Example 12
Source File: GSSCredElement.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
void doServicePermCheck() throws GSSException {
    if (GSSUtil.isKerberosMech(cStub.getMech())) {
        if (System.getSecurityManager() != null) {
            if (isInitiatorCredential()) {
                String tgsName = Krb5Util.getTGSName(name);
                Krb5Util.checkServicePermission(tgsName, "initiate");
            }
            if (isAcceptorCredential() &&
                name != GSSNameElement.DEF_ACCEPTOR) {
                String krbName = name.getKrbName();
                Krb5Util.checkServicePermission(krbName, "accept");
            }
        }
    }
}
 
Example 13
Source File: GSSNameElement.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public String getKrbName() throws GSSException {
    long mName = 0;
    GSSLibStub stub = cStub;
    if (!GSSUtil.isKerberosMech(cStub.getMech())) {
        stub = GSSLibStub.getInstance(GSSUtil.GSS_KRB5_MECH_OID);
    }
    mName = stub.canonicalizeName(pName);
    Object[] printables2 = stub.displayName(mName);
    stub.releaseName(mName);
    SunNativeProvider.debug("Got kerberized name: " + printables2[0]);
    return (String) printables2[0];
}
 
Example 14
Source File: NativeGSSContext.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public byte[] acceptSecContext(InputStream is, int mechTokenLen)
    throws GSSException {
    byte[] outToken = null;
    if ((!isEstablished) && (!isInitiator)) {
        byte[] inToken = retrieveToken(is, mechTokenLen);
        SunNativeProvider.debug("acceptSecContext=> inToken len=" +
                                inToken.length);
        long pCred = (cred == null? 0 : cred.pCred);
        outToken = cStub.acceptContext(pCred, cb, inToken, this);
        SunNativeProvider.debug("acceptSecContext=> outToken len=" +
                                (outToken == null? 0 : outToken.length));

        if (targetName == null) {
            targetName = new GSSNameElement
                (cStub.getContextName(pContext, false), cStub);
            // Replace the current default acceptor cred now that
            // the context acceptor name is available
            if (cred != null) cred.dispose();
            cred = new GSSCredElement(targetName, lifetime,
                                      GSSCredential.ACCEPT_ONLY, cStub);
        }

        // Only inspect token when the permission check has not
        // been performed
        if (GSSUtil.isSpNegoMech(cStub.getMech()) &&
            (outToken != null) && !skipServicePermCheck) {
            if (GSSUtil.isKerberosMech(getMechFromSpNegoToken
                                       (outToken, false))) {
                doServicePermCheck();
            }
        }
    }
    return outToken;
}
 
Example 15
Source File: GSSNameElement.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public String getKrbName() throws GSSException {
    long mName = 0;
    GSSLibStub stub = cStub;
    if (!GSSUtil.isKerberosMech(cStub.getMech())) {
        stub = GSSLibStub.getInstance(GSSUtil.GSS_KRB5_MECH_OID);
    }
    mName = stub.canonicalizeName(pName);
    Object[] printables2 = stub.displayName(mName);
    stub.releaseName(mName);
    SunNativeProvider.debug("Got kerberized name: " + printables2[0]);
    return (String) printables2[0];
}
 
Example 16
Source File: GSSNameElement.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public String getKrbName() throws GSSException {
    long mName = 0;
    GSSLibStub stub = cStub;
    if (!GSSUtil.isKerberosMech(cStub.getMech())) {
        stub = GSSLibStub.getInstance(GSSUtil.GSS_KRB5_MECH_OID);
    }
    mName = stub.canonicalizeName(pName);
    Object[] printables2 = stub.displayName(mName);
    stub.releaseName(mName);
    SunNativeProvider.debug("Got kerberized name: " + printables2[0]);
    return (String) printables2[0];
}
 
Example 17
Source File: NativeGSSContext.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public byte[] initSecContext(InputStream is, int mechTokenLen)
    throws GSSException {
    byte[] outToken = null;
    if ((!isEstablished) && (isInitiator)) {
        byte[] inToken = null;
        // Ignore the specified input stream on the first call
        if (pContext != 0) {
            inToken = retrieveToken(is, mechTokenLen);
            SunNativeProvider.debug("initSecContext=> inToken len=" +
                inToken.length);
        }

        if (!getCredDelegState()) skipDelegPermCheck = true;

        if (GSSUtil.isKerberosMech(cStub.getMech()) && !skipDelegPermCheck) {
            doDelegPermCheck();
        }

        long pCred = (cred == null? 0 : cred.pCred);
        outToken = cStub.initContext(pCred, targetName.pName,
                                     cb, inToken, this);
        SunNativeProvider.debug("initSecContext=> outToken len=" +
            (outToken == null ? 0 : outToken.length));

        // Only inspect the token when the permission check
        // has not been performed
        if (GSSUtil.isSpNegoMech(cStub.getMech()) && outToken != null) {
            // WORKAROUND for SEAM bug#6287358
            actualMech = getMechFromSpNegoToken(outToken, true);

            if (GSSUtil.isKerberosMech(actualMech)) {
                if (!skipServicePermCheck) doServicePermCheck();
                if (!skipDelegPermCheck) doDelegPermCheck();
            }
        }

        if (isEstablished) {
            if (srcName == null) {
                srcName = new GSSNameElement
                    (cStub.getContextName(pContext, true), cStub);
            }
            if (cred == null) {
                cred = new GSSCredElement(srcName, lifetime,
                                          GSSCredential.INITIATE_ONLY,
                                          cStub);
            }
        }
    }
    return outToken;
}
 
Example 18
Source File: NativeGSSContext.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public byte[] initSecContext(InputStream is, int mechTokenLen)
    throws GSSException {
    byte[] outToken = null;
    if ((!isEstablished) && (isInitiator)) {
        byte[] inToken = null;
        // Ignore the specified input stream on the first call
        if (pContext != 0) {
            inToken = retrieveToken(is, mechTokenLen);
            SunNativeProvider.debug("initSecContext=> inToken len=" +
                inToken.length);
        }

        if (!getCredDelegState()) skipDelegPermCheck = true;

        if (GSSUtil.isKerberosMech(cStub.getMech()) && !skipDelegPermCheck) {
            doDelegPermCheck();
        }

        long pCred = (cred == null? 0 : cred.pCred);
        outToken = cStub.initContext(pCred, targetName.pName,
                                     cb, inToken, this);
        SunNativeProvider.debug("initSecContext=> outToken len=" +
            (outToken == null ? 0 : outToken.length));

        // Only inspect the token when the permission check
        // has not been performed
        if (GSSUtil.isSpNegoMech(cStub.getMech()) && outToken != null) {
            // WORKAROUND for SEAM bug#6287358
            actualMech = getMechFromSpNegoToken(outToken, true);

            if (GSSUtil.isKerberosMech(actualMech)) {
                if (!skipServicePermCheck) doServicePermCheck();
                if (!skipDelegPermCheck) doDelegPermCheck();
            }
        }

        if (isEstablished) {
            if (srcName == null) {
                srcName = new GSSNameElement
                    (cStub.getContextName(pContext, true), cStub);
            }
            if (cred == null) {
                cred = new GSSCredElement(srcName, lifetime,
                                          GSSCredential.INITIATE_ONLY,
                                          cStub);
            }
        }
    }
    return outToken;
}
 
Example 19
Source File: NativeGSSContext.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public byte[] initSecContext(InputStream is, int mechTokenLen)
    throws GSSException {
    byte[] outToken = null;
    if ((!isEstablished) && (isInitiator)) {
        byte[] inToken = null;
        // Ignore the specified input stream on the first call
        if (pContext != 0) {
            inToken = retrieveToken(is, mechTokenLen);
            SunNativeProvider.debug("initSecContext=> inToken len=" +
                inToken.length);
        }

        if (!getCredDelegState()) skipDelegPermCheck = true;

        if (GSSUtil.isKerberosMech(cStub.getMech()) && !skipDelegPermCheck) {
            doDelegPermCheck();
        }

        long pCred = (cred == null? 0 : cred.pCred);
        outToken = cStub.initContext(pCred, targetName.pName,
                                     cb, inToken, this);
        SunNativeProvider.debug("initSecContext=> outToken len=" +
            (outToken == null ? 0 : outToken.length));

        // Only inspect the token when the permission check
        // has not been performed
        if (GSSUtil.isSpNegoMech(cStub.getMech()) && outToken != null) {
            // WORKAROUND for SEAM bug#6287358
            actualMech = getMechFromSpNegoToken(outToken, true);

            if (GSSUtil.isKerberosMech(actualMech)) {
                if (!skipServicePermCheck) doServicePermCheck();
                if (!skipDelegPermCheck) doDelegPermCheck();
            }
        }

        if (isEstablished) {
            if (srcName == null) {
                srcName = new GSSNameElement
                    (cStub.getContextName(pContext, true), cStub);
            }
            if (cred == null) {
                cred = new GSSCredElement(srcName, lifetime,
                                          GSSCredential.INITIATE_ONLY,
                                          cStub);
            }
        }
    }
    return outToken;
}
 
Example 20
Source File: NativeGSSContext.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public byte[] initSecContext(InputStream is, int mechTokenLen)
    throws GSSException {
    byte[] outToken = null;
    if ((!isEstablished) && (isInitiator)) {
        byte[] inToken = null;
        // Ignore the specified input stream on the first call
        if (pContext != 0) {
            inToken = retrieveToken(is, mechTokenLen);
            SunNativeProvider.debug("initSecContext=> inToken len=" +
                inToken.length);
        }

        if (!getCredDelegState()) skipDelegPermCheck = true;

        if (GSSUtil.isKerberosMech(cStub.getMech()) && !skipDelegPermCheck) {
            doDelegPermCheck();
        }

        long pCred = (cred == null? 0 : cred.pCred);
        outToken = cStub.initContext(pCred, targetName.pName,
                                     cb, inToken, this);
        SunNativeProvider.debug("initSecContext=> outToken len=" +
            (outToken == null ? 0 : outToken.length));

        // Only inspect the token when the permission check
        // has not been performed
        if (GSSUtil.isSpNegoMech(cStub.getMech()) && outToken != null) {
            // WORKAROUND for SEAM bug#6287358
            actualMech = getMechFromSpNegoToken(outToken, true);

            if (GSSUtil.isKerberosMech(actualMech)) {
                if (!skipServicePermCheck) doServicePermCheck();
                if (!skipDelegPermCheck) doDelegPermCheck();
            }
        }

        if (isEstablished) {
            if (srcName == null) {
                srcName = new GSSNameElement
                    (cStub.getContextName(pContext, true), cStub);
            }
            if (cred == null) {
                cred = new GSSCredElement(srcName, lifetime,
                                          GSSCredential.INITIATE_ONLY,
                                          cStub);
            }
        }
    }
    return outToken;
}