JDK 11 java.security.jgss.jmod - Security JGSS Module

JDK 11 java.security.jgss.jmod is the JMOD file for JDK 11 Security JGSS (Java Generic Security Service) module.

JDK 11 Security JGSS module compiled class files are stored in \fyicenter\jdk-11.0.1\jmods\java.security.jgss.jmod.

JDK 11 Security JGSS module compiled class files are also linked and stored in the \fyicenter\jdk-11.0.1\lib\modules JImage file.

JDK 11 Security JGSS module source code files are stored in \fyicenter\jdk-11.0.1\lib\src.zip\java.security.jgss.

You can click and view the content of each source code file in the list below.

✍: FYIcenter

sun/net/www/protocol/http/spnego/NegotiateCallbackHandler.java

/*
 * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */

package sun.net.www.protocol.http.spnego;

import java.io.IOException;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.util.Arrays;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.NameCallback;
import javax.security.auth.callback.PasswordCallback;
import javax.security.auth.callback.UnsupportedCallbackException;
import sun.net.www.protocol.http.HttpCallerInfo;
import sun.security.jgss.LoginConfigImpl;

/**
 * @since 1.6
 * Special callback handler used in JGSS for the HttpCaller.
 */
public class NegotiateCallbackHandler implements CallbackHandler {

    private String username;
    private char[] password;

    /**
     * Authenticator asks for username and password in a single prompt,
     * but CallbackHandler checks one by one. So, no matter which callback
     * gets handled first, make sure Authenticator is only called once.
     */
    private boolean answered;

    private final HttpCallerInfo hci;

    public NegotiateCallbackHandler(HttpCallerInfo hci) {
        this.hci = hci;
    }

    private void getAnswer() {
        if (!answered) {
            answered = true;
            Authenticator auth;
            if (hci.authenticator != null) {
                auth = hci.authenticator;
            } else {
                auth = LoginConfigImpl.HTTP_USE_GLOBAL_CREDS ?
                        Authenticator.getDefault() : null;
            }

            if (auth != null) {
                PasswordAuthentication passAuth =
                        auth.requestPasswordAuthenticationInstance(
                                hci.host, hci.addr, hci.port, hci.protocol,
                                hci.prompt, hci.scheme, hci.url, hci.authType);
                /**
                 * To be compatible with existing callback handler implementations,
                 * when the underlying Authenticator is canceled, username and
                 * password are assigned null. No exception is thrown.
                 */
                if (passAuth != null) {
                    username = passAuth.getUserName();
                    password = passAuth.getPassword();
                }
            }
        }
    }

    public void handle(Callback[] callbacks) throws
            UnsupportedCallbackException, IOException {
        for (int i=0; i<callbacks.length; i++) {
            Callback callBack = callbacks[i];

            if (callBack instanceof NameCallback) {
                getAnswer();
                ((NameCallback)callBack).setName(username);
            } else if (callBack instanceof PasswordCallback) {
                getAnswer();
                ((PasswordCallback)callBack).setPassword(password);
                if (password != null) Arrays.fill(password, ' ');
            } else {
                throw new UnsupportedCallbackException(callBack,
                        "Call back not supported");
            }
        }
    }
}

sun/net/www/protocol/http/spnego/NegotiateCallbackHandler.java

 

Or download all of them as a single archive file:

File name: java.security.jgss-11.0.1-src.zip
File size: 216236 bytes
Release date: 2018-11-04
Download 

 

JDK 11 java.security.sasl.jmod - Security SASL Module

JDK 11 java.se.jmod - SE Module

Download and Use JDK 11

⇑⇑ FAQ for JDK (Java Development Kit)

2020-09-15, 26262👍, 0💬