Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
Source Code for Connector/J 8.0.31 - Core Impl
Where to get the Java source code for Connector/J 8.0 Core Impl module?
✍: FYIcenter.com
Java source code files for Connector/J 8.0 Core Impl module are:
⏎ com/mysql/cj/sasl/ScramShaSaslClientFactory.java
/* * Copyright (c) 2020, Oracle and/or its affiliates. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License, version 2.0, as published by the * Free Software Foundation. * * This program is also distributed with certain software (including but not * limited to OpenSSL) that is licensed under separate terms, as designated in a * particular file or component or in included license documentation. The * authors of MySQL hereby grant you an additional permission to link the * program and your derivative works with the separately licensed software that * they have included with MySQL. * * Without limiting anything contained in the foregoing, this file, which is * part of MySQL Connector/J, is also subject to the Universal FOSS Exception, * version 1.0, a copy of which can be found at * http://oss.oracle.com/licenses/universal-foss-exception. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0, * for more details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.mysql.cj.sasl; import java.io.IOException; import java.util.Map; 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 javax.security.sasl.SaslClient; import javax.security.sasl.SaslClientFactory; import javax.security.sasl.SaslException; import com.mysql.cj.util.StringUtils; /** * A {@link SaslClientFactory} for {@link ScramSha1SaslClient} and {@link ScramSha256SaslClient} instances. */ public class ScramShaSaslClientFactory implements SaslClientFactory { private static final String[] SUPPORTED_MECHANISMS = { ScramSha1SaslClient.MECHANISM_NAME, ScramSha256SaslClient.MECHANISM_NAME }; @Override public SaslClient createSaslClient(String[] mechanisms, String authorizationId, String protocol, String serverName, Map<String, ?> props, CallbackHandler cbh) throws SaslException { for (String mech : mechanisms) { if (mech.equals(ScramSha1SaslClient.MECHANISM_NAME)) { return new ScramSha1SaslClient(authorizationId, getUsername(mech, authorizationId, cbh), getPassword(mech, cbh)); } if (mech.equals(ScramSha256SaslClient.MECHANISM_NAME)) { return new ScramSha256SaslClient(authorizationId, getUsername(mech, authorizationId, cbh), getPassword(mech, cbh)); } } return null; } @Override public String[] getMechanismNames(Map<String, ?> props) { return SUPPORTED_MECHANISMS.clone(); } /** * Gets the authentication id, which is provided by a {@link CallbackHandler} to be implemented by the requester of this service. * * @param prefix * the prefix to use in the prompt. * @param authorizationId * the authorization id that can be used as default authentication id if none is provided. * @param cbh * the callback handler to use. * @return * an authentication id * @throws SaslException * if the callback handler is null or not supported by the callback handler implementer. */ private String getUsername(String prefix, String authorizationId, CallbackHandler cbh) throws SaslException { if (cbh == null) { throw new SaslException("Callback handler required to get username."); } try { String prompt = prefix + " authentication id:"; NameCallback ncb = StringUtils.isNullOrEmpty(authorizationId) ? new NameCallback(prompt) : new NameCallback(prompt, authorizationId); cbh.handle(new Callback[] { ncb }); String userName = ncb.getName(); return userName; } catch (IOException | UnsupportedCallbackException e) { throw new SaslException("Cannot get username", e); } } /** * Gets the password, which is provided by a {@link CallbackHandler} to be implemented by the requester of this service. * * @param prefix * the prefix to use in the prompt. * @param cbh * the callback handler to use. * @return * a password * @throws SaslException * if the callback handler is null or not supported by the callback handler implementer. */ private String getPassword(String prefix, CallbackHandler cbh) throws SaslException { if (cbh == null) { throw new SaslException("Callback handler required to get password."); } try { String prompt = prefix + " password:"; PasswordCallback pcb = new PasswordCallback(prompt, false); cbh.handle(new Callback[] { pcb }); String password = new String(pcb.getPassword()); pcb.clearPassword(); return password; } catch (IOException | UnsupportedCallbackException e) { throw new SaslException("Cannot get password", e); } } }
⏎ com/mysql/cj/sasl/ScramShaSaslClientFactory.java
Or download all of them as a single archive file:
File name: mysql-connector-java-core-impl-8.0.31.zip File size: 201048 bytes Release date: 2022-09-03 Download
⇒ Source Code for Connector/J 8.0.31 - Protocol Impl
⇐ Source Code for Connector/J 8.0.31 - Core API
2023-05-31, 11799👍, 0💬
Popular Posts:
commons-fileupload-1.3.3 -sources.jaris the source JAR file for Apache Commons FileUpload 1.3., whic...
What JAR files are required to run dom\Writer.java provided in the Apache Xerces package? 3 JAR file...
What Is activation.jar? I heard it's related to JAF (JavaBeans Activation Framework) 1.0.2? The if y...
JLayer is a library that decodes/plays/converts MPEG 1/2/2.5 Layer 1/2/3 (i.e. MP3) in real time for...
JDK 11 jdk.jshell.jmod is the JMOD file for JDK 11 JShell tool, which can be invoked by the "jshell"...