_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q20400 | ForwardingClient.requestRemoteForwarding | train | public boolean requestRemoteForwarding(String addressToBind,
int portToBind, String hostToConnect, int portToConnect)
throws SshException {
if (ssh.requestRemoteForwarding(addressToBind, portToBind,
hostToConnect, portToConnect, forwardinglistener)) {
String key = generateKey(addressToBind, portToBind);
... | java | {
"resource": ""
} |
q20401 | ForwardingClient.cancelRemoteForwarding | train | public void cancelRemoteForwarding(String bindAddress, int bindPort,
boolean killActiveTunnels) throws SshException {
String key = generateKey(bindAddress, bindPort);
boolean killedTunnels = false;
if (killActiveTunnels) {
try {
ActiveTunnel[] tunnels = getRemoteForwardingTunnels(
bindAddress, b... | java | {
"resource": ""
} |
q20402 | ForwardingClient.cancelAllRemoteForwarding | train | public synchronized void cancelAllRemoteForwarding(boolean killActiveTunnels)
throws SshException {
if (remoteforwardings == null) {
return;
}
for (Enumeration<String> e = remoteforwardings.keys(); e
.hasMoreElements();) {
String host = (String) e.nextElement();
if (host == null)
return;
... | java | {
"resource": ""
} |
q20403 | ForwardingClient.stopAllLocalForwarding | train | public synchronized void stopAllLocalForwarding(boolean killActiveTunnels)
throws SshException {
for (Enumeration<String> e = socketlisteners.keys(); e
.hasMoreElements();) {
stopLocalForwarding((String) e.nextElement(), killActiveTunnels);
}
} | java | {
"resource": ""
} |
q20404 | ForwardingClient.stopLocalForwarding | train | public synchronized void stopLocalForwarding(String bindAddress,
int bindPort, boolean killActiveTunnels) throws SshException {
String key = generateKey(bindAddress, bindPort);
stopLocalForwarding(key, killActiveTunnels);
} | java | {
"resource": ""
} |
q20405 | ForwardingClient.stopLocalForwarding | train | public synchronized void stopLocalForwarding(String key,
boolean killActiveTunnels) throws SshException {
if (key == null)
return;
boolean killedTunnels = false;
if (killActiveTunnels) {
try {
ActiveTunnel[] tunnels = getLocalForwardingTunnels(key);
if (tunnels != null) {
for (int i = 0;... | java | {
"resource": ""
} |
q20406 | Ssh2DsaPublicKey.verifySignature | train | public boolean verifySignature(byte[] signature, byte[] data)
throws SshException {
ByteArrayReader bar = new ByteArrayReader(signature);
try {
if (signature.length != 40 // 160 bits
&& signature.length != 56 // 224 bits
&& signature.length != 64) { // 256 bits
byte[] sig = bar.readBinaryStr... | java | {
"resource": ""
} |
q20407 | ComponentManager.getInstance | train | public static ComponentManager getInstance() throws SshException {
synchronized (ComponentManager.class) {
if (instance == null) {
instance = new JCEComponentManager();
instance.init();
}
return instance;
}
} | java | {
"resource": ""
} |
q20408 | Ssh2PasswordAuthentication.authenticate | train | public void authenticate(AuthenticationProtocol authentication,
String servicename) throws SshException, AuthenticationResult {
try {
if (getUsername() == null || getPassword() == null) {
throw new SshException("Username or password not set!",
SshException.BAD_API_USAGE);
}
if (passwordChangeR... | java | {
"resource": ""
} |
q20409 | ScpClient.put | train | public void put(String localFileRegExp, String remoteFile,
boolean recursive, FileTransferProgress progress)
throws SshException, ChannelOpenException {
GlobRegExpMatching globMatcher = new GlobRegExpMatching();
String parentDir;
int fileSeparatorIndex;
parentDir = cwd.getAbsolutePath();
String relative... | java | {
"resource": ""
} |
q20410 | Ssh2Channel.open | train | protected void open(int remoteid, long remotewindow, int remotepacket)
throws IOException {
this.remoteid = remoteid;
this.remotewindow = new DataWindow(remotewindow, remotepacket);
this.state = CHANNEL_OPEN;
synchronized (listeners) {
for (Enumeration<ChannelEventListener> e = listeners.elements(); e
... | java | {
"resource": ""
} |
q20411 | Ssh2Channel.open | train | protected void open(int remoteid, long remotewindow, int remotepacket,
byte[] responsedata) throws IOException {
open(remoteid, remotewindow, remotepacket);
} | java | {
"resource": ""
} |
q20412 | Ssh2Channel.close | train | public void close() {
boolean performClose = false;
;
synchronized (this) {
if (!closing && state == CHANNEL_OPEN) {
performClose = closing = true;
}
}
if (performClose) {
synchronized (listeners) {
for (Enumeration<ChannelEventListener> e = listeners.elements(); e
.hasMoreElements(... | java | {
"resource": ""
} |
q20413 | Ssh2Channel.channelRequest | train | protected void channelRequest(String requesttype, boolean wantreply,
byte[] requestdata) throws SshException {
if (wantreply) {
ByteArrayWriter msg = new ByteArrayWriter();
try {
msg.write((byte) SSH_MSG_CHANNEL_FAILURE);
msg.writeInt(remoteid);
connection.sendMessage(msg.toByteArray(), true);
... | java | {
"resource": ""
} |
q20414 | Ssh2Context.setPreferredCipherCS | train | public void setPreferredCipherCS(String name) throws SshException {
if (name == null)
return;
if (ciphersCS.contains(name)) {
prefCipherCS = name;
setCipherPreferredPositionCS(name, 0);
} else {
throw new SshException(name + " is not supported",
SshException.UNSUPPORTED_ALGORITHM);
}
} | java | {
"resource": ""
} |
q20415 | Ssh2Context.setPreferredCipherSC | train | public void setPreferredCipherSC(String name) throws SshException {
if (name == null)
return;
if (ciphersSC.contains(name)) {
prefCipherSC = name;
setCipherPreferredPositionSC(name, 0);
} else {
throw new SshException(name + " is not supported",
SshException.UNSUPPORTED_ALGORITHM);
}
} | java | {
"resource": ""
} |
q20416 | Ssh2Context.setPreferredMacCS | train | public void setPreferredMacCS(String name) throws SshException {
if (name == null)
return;
if (macCS.contains(name)) {
prefMacCS = name;
setMacPreferredPositionCS(name, 0);
} else {
throw new SshException(name + " is not supported",
SshException.UNSUPPORTED_ALGORITHM);
}
} | java | {
"resource": ""
} |
q20417 | Ssh2Context.setPreferredMacSC | train | public void setPreferredMacSC(String name) throws SshException {
if (name == null)
return;
if (macSC.contains(name)) {
prefMacSC = name;
setMacPreferredPositionSC(name, 0);
} else {
throw new SshException(name + " is not supported",
SshException.UNSUPPORTED_ALGORITHM);
}
} | java | {
"resource": ""
} |
q20418 | Ssh2Context.setPreferredCompressionCS | train | public void setPreferredCompressionCS(String name) throws SshException {
if (name == null)
return;
if (compressionsCS.contains(name)) {
prefCompressionCS = name;
} else {
throw new SshException(name + " is not supported",
SshException.UNSUPPORTED_ALGORITHM);
}
} | java | {
"resource": ""
} |
q20419 | Ssh2Context.setPreferredCompressionSC | train | public void setPreferredCompressionSC(String name) throws SshException {
if (name == null)
return;
if (compressionsSC.contains(name)) {
prefCompressionSC = name;
} else {
throw new SshException(name + " is not supported",
SshException.UNSUPPORTED_ALGORITHM);
}
} | java | {
"resource": ""
} |
q20420 | Ssh2Context.setPreferredKeyExchange | train | public void setPreferredKeyExchange(String name) throws SshException {
if (name == null)
return;
if (keyExchanges.contains(name)) {
prefKeyExchange = name;
setKeyExchangePreferredPosition(name, 0);
} else {
throw new SshException(name + " is not supported",
SshException.UNSUPPORTED_ALGORITHM);
... | java | {
"resource": ""
} |
q20421 | Ssh2Context.setPreferredPublicKey | train | public void setPreferredPublicKey(String name) throws SshException {
if (name == null)
return;
if (publicKeys.contains(name)) {
prefPublicKey = name;
setPublicKeyPreferredPosition(name, 0);
} else {
throw new SshException(name + " is not supported",
SshException.UNSUPPORTED_ALGORITHM);
}
} | java | {
"resource": ""
} |
q20422 | SftpFileInputStream.close | train | public void close() throws IOException {
try {
file.close();
UnsignedInteger32 requestid;
while (outstandingRequests.size() > 0) {
requestid = (UnsignedInteger32) outstandingRequests
.elementAt(0);
outstandingRequests.removeElementAt(0);
sftp.getResponse(requestid);
}
} catch (SshExce... | java | {
"resource": ""
} |
q20423 | Log.debug | train | public static void debug(Object source, String message, Throwable t) {
LoggerFactory.getInstance().log(LoggerLevel.DEBUG, source, message, t);
} | java | {
"resource": ""
} |
q20424 | Log.debug | train | public static void debug(Object source, String message) {
LoggerFactory.getInstance().log(LoggerLevel.INFO, source, message);
} | java | {
"resource": ""
} |
q20425 | Log.error | train | public static void error(Object source, String message, Throwable t) {
LoggerFactory.getInstance().log(LoggerLevel.ERROR, source, message, t);
} | java | {
"resource": ""
} |
q20426 | UserPasswordAuthentication.formRequest | train | private void formRequest(){
byte[] user_bytes = userName.getBytes();
byte[] password_bytes = password.getBytes();
request = new byte[3+user_bytes.length+password_bytes.length];
request[0] = (byte) 1;
request[1] = (byte) user_bytes.length;
System.arraycopy(user_bytes,0,request,2,use... | java | {
"resource": ""
} |
q20427 | TransportProtocol.startTransportProtocol | train | public void startTransportProtocol(SshTransport provider,
Ssh2Context context, String localIdentification,
String remoteIdentification, Ssh2Client client) throws SshException {
try {
this.transportIn = new DataInputStream(provider.getInputStream());
this.transportOut = provider.getOutputStream();
this... | java | {
"resource": ""
} |
q20428 | TransportProtocol.disconnect | train | public void disconnect(int reason, String disconnectReason) {
ByteArrayWriter baw = new ByteArrayWriter();
try {
this.disconnectReason = disconnectReason;
baw.write(SSH_MSG_DISCONNECT);
baw.writeInt(reason);
baw.writeString(disconnectReason);
baw.writeString("");
Log.info(this, "Sending SSH_MS... | java | {
"resource": ""
} |
q20429 | TransportProtocol.nextMessage | train | public byte[] nextMessage() throws SshException {
if (Log.isDebugEnabled()) {
if (verbose) {
Log.debug(this, "transport next message");
}
}
synchronized (transportIn) {
byte[] msg;
do {
msg = readMessage();
} while (processMessage(msg));
return msg;
}
} | java | {
"resource": ""
} |
q20430 | TransportProtocol.startService | train | public void startService(String servicename) throws SshException {
ByteArrayWriter baw = new ByteArrayWriter();
try {
baw.write(SSH_MSG_SERVICE_REQUEST);
baw.writeString(servicename);
if (Log.isDebugEnabled()) {
Log.debug(this, "Sending SSH_MSG_SERVICE_REQUEST");
}
sendMessage(baw.toByteArray... | java | {
"resource": ""
} |
q20431 | TransportProtocol.processMessage | train | public boolean processMessage(byte[] msg) throws SshException {
try {
if (msg.length < 1) {
disconnect(TransportProtocol.PROTOCOL_ERROR,
"Invalid message received");
throw new SshException("Invalid transport protocol message",
SshException.INTERNAL_ERROR);
}
switch (msg[0]) {
case SS... | java | {
"resource": ""
} |
q20432 | SshKeyFingerprint.getFingerprint | train | public static String getFingerprint(byte[] encoded, String algorithm)
throws SshException {
Digest md5 = (Digest) ComponentManager.getInstance().supportedDigests()
.getInstance(algorithm);
md5.putBytes(encoded);
byte[] digest = md5.doFinal();
StringBuffer buf = new StringBuffer();
int ch;
for (in... | java | {
"resource": ""
} |
q20433 | SftpFile.canWrite | train | public boolean canWrite() throws SftpStatusException, SshException {
// This is long hand because gcj chokes when it is not? Investigate why
if ((getAttributes().getPermissions().longValue() & SftpFileAttributes.S_IWUSR) == SftpFileAttributes.S_IWUSR
|| (getAttributes().getPermissions().longValue() & SftpFileAt... | java | {
"resource": ""
} |
q20434 | SftpFile.canRead | train | public boolean canRead() throws SftpStatusException, SshException {
// This is long hand because gcj chokes when it is not? Investigate why
if ((getAttributes().getPermissions().longValue() & SftpFileAttributes.S_IRUSR) == SftpFileAttributes.S_IRUSR
|| (getAttributes().getPermissions().longValue() & SftpFileAtt... | java | {
"resource": ""
} |
q20435 | SftpFile.getAttributes | train | public SftpFileAttributes getAttributes() throws SftpStatusException,
SshException {
if (attrs == null) {
attrs = sftp.getAttributes(getAbsolutePath());
}
return attrs;
} | java | {
"resource": ""
} |
q20436 | SftpFile.isFifo | train | public boolean isFifo() throws SftpStatusException, SshException {
// This is long hand because gcj chokes when it is not? Investigate why
if ((getAttributes().getPermissions().longValue() & SftpFileAttributes.S_IFIFO) == SftpFileAttributes.S_IFIFO)
return true;
return false;
} | java | {
"resource": ""
} |
q20437 | SftpFile.isBlock | train | public boolean isBlock() throws SftpStatusException, SshException {
// This is long hand because gcj chokes when it is not? Investigate why
if ((getAttributes().getPermissions().longValue() & SftpFileAttributes.S_IFBLK) == SftpFileAttributes.S_IFBLK) {
return true;
}
return false;
} | java | {
"resource": ""
} |
q20438 | SftpFile.isCharacter | train | public boolean isCharacter() throws SftpStatusException, SshException {
// This is long hand because gcj chokes when it is not? Investigate why
if ((getAttributes().getPermissions().longValue() & SftpFileAttributes.S_IFCHR) == SftpFileAttributes.S_IFCHR) {
return true;
}
return false;
} | java | {
"resource": ""
} |
q20439 | SftpFile.isSocket | train | public boolean isSocket() throws SftpStatusException, SshException {
// This is long hand because gcj chokes when it is not? Investigate why
if ((getAttributes().getPermissions().longValue() & SftpFileAttributes.S_IFSOCK) == SftpFileAttributes.S_IFSOCK) {
return true;
}
return false;
} | java | {
"resource": ""
} |
q20440 | DynamicBuffer.write | train | protected synchronized void write(int b) throws IOException {
if (closed) {
throw new IOException("The buffer is closed");
}
verifyBufferSize(1);
buf[writepos] = (byte) b;
writepos++;
notifyAll();
} | java | {
"resource": ""
} |
q20441 | DynamicBuffer.read | train | protected synchronized int read() throws IOException {
try {
block();
} catch (InterruptedException ex) {
throw new InterruptedIOException(
"The blocking operation was interrupted");
}
if (closed && available() <= 0) {
return -1;
}
return buf[readpos++];
} | java | {
"resource": ""
} |
q20442 | DynamicBuffer.read | train | protected synchronized int read(byte[] data, int offset, int len)
throws IOException {
try {
block();
} catch (InterruptedException ex) {
throw new InterruptedIOException(
"The blocking operation was interrupted");
}
if (closed && available() <= 0) {
return -1;
}
int read = (len > (write... | java | {
"resource": ""
} |
q20443 | ComponentFactory.add | train | public synchronized void add(String name, Class<?> cls) {
if (locked) {
throw new IllegalStateException(
"Component factory is locked. Components cannot be added");
}
supported.put(name, cls);
// add name to end of order vector
if (!order.contains(name))
order.addElement(name);
} | java | {
"resource": ""
} |
q20444 | ComponentFactory.getInstance | train | public Object getInstance(String name) throws SshException {
if (supported.containsKey(name)) {
try {
return createInstance(name, (Class<?>) supported.get(name));
} catch (Throwable t) {
throw new SshException(t.getMessage(),
SshException.INTERNAL_ERROR);
}
}
throw new SshException(name + "... | java | {
"resource": ""
} |
q20445 | ComponentFactory.createDelimitedList | train | private synchronized String createDelimitedList(String preferred) {
StringBuffer listBuf = new StringBuffer();
int prefIndex = order.indexOf(preferred);
// remove preferred and add it back at the end to ensure it is not
// duplicated in the list returned
if (prefIndex != -1) {
listBuf.append(preferred);
... | java | {
"resource": ""
} |
q20446 | SocksServerSocket.accept | train | public Socket accept() throws IOException{
Socket s;
if(!doing_direct){
if(proxy == null) return null;
ProxyMessage msg = proxy.accept();
s = msg.ip == null? new SocksSocket(msg.host,msg.port,proxy)
: new SocksSocket(msg.ip,msg.port,proxy);
... | java | {
"resource": ""
} |
q20447 | SocksServerSocket.getInetAddress | train | public InetAddress getInetAddress(){
if(localIP == null){
try{
localIP = InetAddress.getByName(localHost);
}catch(UnknownHostException e){
return null;
}
}
return localIP;
} | java | {
"resource": ""
} |
q20448 | SocksServerSocket.setSoTimeout | train | public void setSoTimeout(int timeout) throws SocketException{
super.setSoTimeout(timeout);
if(!doing_direct) proxy.proxySocket.setSoTimeout(timeout);
} | java | {
"resource": ""
} |
q20449 | SftpStatusException.getStatusText | train | public static String getStatusText(int status) {
switch (status) {
case SSH_FX_OK:
return "OK";
case SSH_FX_EOF:
return "EOF";
case SSH_FX_NO_SUCH_FILE:
return "No such file.";
case SSH_FX_PERMISSION_DENIED:
return "Permission denied.";
case SSH_FX_FAILURE:
return "Server responded with an un... | java | {
"resource": ""
} |
q20450 | SshPublicKeyFileFactory.parse | train | public static SshPublicKeyFile parse(byte[] formattedkey)
throws IOException {
try {
try {
return new OpenSSHPublicKeyFile(formattedkey);
} catch (IOException ex) {
try {
return new SECSHPublicKeyFile(formattedkey);
} catch (IOException ex2) {
throw new IOException(
"Unable to pa... | java | {
"resource": ""
} |
q20451 | DiffieHellmanGroups.getSafePrime | train | public static BigInteger getSafePrime(UnsignedInteger32 maximumSize) {
BigInteger prime = group1;
for(Iterator<BigInteger> it = safePrimes.iterator(); it.hasNext(); ) {
BigInteger p = it.next();
int len = p.bitLength();
if(len > maximumSize.intValue()) {
break;
}
prime = p;
}
return prime... | java | {
"resource": ""
} |
q20452 | Socks5Message.read | train | public void read(InputStream in,boolean clientMode) throws SocksException,
IOException{
data = null;
ip = null;
DataInputStream di = new DataInputStream(in);
version = di.readUnsignedByte();
command = di.readUnsignedByte();
if(clientMode &... | java | {
"resource": ""
} |
q20453 | Socks5Message.write | train | public void write(OutputStream out)throws SocksException,
IOException{
if(data == null){
Socks5Message msg;
if(addrType == SOCKS_ATYP_DOMAINNAME)
msg = new Socks5Message(command,host,port);
else{
if(ip == null){
try... | java | {
"resource": ""
} |
q20454 | Socks5Message.getInetAddress | train | public InetAddress getInetAddress() throws UnknownHostException{
if(ip!=null) return ip;
return (ip=InetAddress.getByName(host));
} | java | {
"resource": ""
} |
q20455 | SocksDialog.run | train | public void run() {
if (!initProxy()) {
// Check if we have been aborted
if (mode != OK_MODE)
return;
if (net_thread != Thread.currentThread())
return;
mode = COMMAND_MODE;
warning_label.setText("Look up failed.");
warning_label.invalidate();
return;
}
// System.out.println("Done!"... | java | {
"resource": ""
} |
q20456 | SftpClient.cdup | train | public void cdup() throws SftpStatusException, SshException {
SftpFile cd = sftp.getFile(cwd);
SftpFile parent = cd.getParent();
if (parent != null)
cwd = parent.getAbsolutePath();
} | java | {
"resource": ""
} |
q20457 | SftpClient.startsWithCustomRoot | train | private boolean startsWithCustomRoot(String path) {
for (Enumeration<String> it = customRoots.elements(); it != null
&& it.hasMoreElements();) {
if (path.startsWith(it.nextElement())) {
return true;
}
}
return false;
} | java | {
"resource": ""
} |
q20458 | SftpClient.isDirectoryOrLinkedDirectory | train | public boolean isDirectoryOrLinkedDirectory(SftpFile file)
throws SftpStatusException, SshException {
return file.isDirectory()
|| (file.isLink() && stat(file.getAbsolutePath()).isDirectory());
} | java | {
"resource": ""
} |
q20459 | SftpClient.get | train | public SftpFileAttributes get(String remote, String local, boolean resume)
throws FileNotFoundException, SftpStatusException, SshException,
TransferCancelledException {
return get(remote, local, null, resume);
} | java | {
"resource": ""
} |
q20460 | SftpClient.getInputStream | train | public InputStream getInputStream(String remotefile, long position)
throws SftpStatusException, SshException {
String remotePath = resolveRemotePath(remotefile);
sftp.getAttributes(remotePath);
return new SftpFileInputStream(sftp.openFile(remotePath,
SftpSubsystemChannel.OPEN_READ), position);
} | java | {
"resource": ""
} |
q20461 | SftpClient.get | train | public SftpFileAttributes get(String remote, OutputStream local,
long position) throws SftpStatusException, SshException,
TransferCancelledException {
return get(remote, local, null, position);
} | java | {
"resource": ""
} |
q20462 | SftpClient.getOutputStream | train | public OutputStream getOutputStream(String remotefile)
throws SftpStatusException, SshException {
String remotePath = resolveRemotePath(remotefile);
return new SftpFileOutputStream(sftp.openFile(remotePath,
SftpSubsystemChannel.OPEN_CREATE
| SftpSubsystemChannel.OPEN_TRUNCATE
| SftpSubsystemChan... | java | {
"resource": ""
} |
q20463 | SftpClient.put | train | public void put(InputStream in, String remote, long position)
throws SftpStatusException, SshException,
TransferCancelledException {
put(in, remote, null, position);
} | java | {
"resource": ""
} |
q20464 | SftpClient.rm | train | public void rm(String path, boolean force, boolean recurse)
throws SftpStatusException, SshException {
String actual = resolveRemotePath(path);
SftpFileAttributes attrs = null;
attrs = sftp.getAttributes(actual);
SftpFile file;
if (attrs.isDirectory()) {
SftpFile[] list = ls(path);
if (!force &&... | java | {
"resource": ""
} |
q20465 | SftpClient.getAbsolutePath | train | public String getAbsolutePath(String path) throws SftpStatusException,
SshException {
String actual = resolveRemotePath(path);
return sftp.getAbsolutePath(actual);
} | java | {
"resource": ""
} |
q20466 | SftpClient.putFiles | train | public void putFiles(String local, String remote,
FileTransferProgress progress, boolean resume)
throws FileNotFoundException, SftpStatusException, SshException,
TransferCancelledException {
putFileMatches(local, remote, progress, resume);
} | java | {
"resource": ""
} |
q20467 | AuthenticationProtocol.authenticate | train | public int authenticate(AuthenticationClient auth, String servicename)
throws SshException {
try {
auth.authenticate(this, servicename);
readMessage();
transport
.disconnect(TransportProtocol.PROTOCOL_ERROR,
"Unexpected response received from Authentication Protocol");
throw new SshExceptio... | java | {
"resource": ""
} |
q20468 | AuthenticationProtocol.sendRequest | train | public void sendRequest(String username, String servicename,
String methodname, byte[] requestdata) throws SshException {
ByteArrayWriter msg = new ByteArrayWriter();
try {
msg.write(SSH_MSG_USERAUTH_REQUEST);
msg.writeString(username);
msg.writeString(servicename);
msg.writeString(methodname);
... | java | {
"resource": ""
} |
q20469 | UnsignedInteger32.add | train | public static UnsignedInteger32 add(UnsignedInteger32 x, UnsignedInteger32 y) {
return new UnsignedInteger32(x.longValue() + y.longValue());
} | java | {
"resource": ""
} |
q20470 | Socks5Proxy.setAuthenticationMethod | train | public boolean setAuthenticationMethod(int methodId, Authentication method) {
if (methodId < 0 || methodId > 255)
return false;
if (method == null) {
// Want to remove a particular method
return (authMethods.remove(new Integer(methodId)) != null);
} else {// Add the method, or rewrite old one
authMeth... | java | {
"resource": ""
} |
q20471 | Socks5Proxy.getAuthenticationMethod | train | public Authentication getAuthenticationMethod(int methodId) {
Object method = authMethods.get(new Integer(methodId));
if (method == null)
return null;
return (Authentication) method;
} | java | {
"resource": ""
} |
q20472 | JCEComponentManager.installCBCCiphers | train | public void installCBCCiphers(ComponentFactory ciphers) {
if (testJCECipher("3des-cbc", TripleDesCbc.class)) {
ciphers.add("3des-cbc", TripleDesCbc.class);
}
if (testJCECipher("blowfish-cbc", BlowfishCbc.class)) {
ciphers.add("blowfish-cbc", BlowfishCbc.class);
}
if (testJCECipher("aes128-cbc", AES128... | java | {
"resource": ""
} |
q20473 | JCEComponentManager.installArcFourCiphers | train | public void installArcFourCiphers(ComponentFactory ciphers) {
if (testJCECipher("arcfour", ArcFour.class)) {
ciphers.add("arcfour", ArcFour.class);
}
if (testJCECipher("arcfour128", ArcFour128.class)) {
ciphers.add("arcfour128", ArcFour128.class);
}
if (testJCECipher("arcfour256", ArcFour256.class)... | java | {
"resource": ""
} |
q20474 | Event.addAttribute | train | public Event addAttribute(String key, Object value) {
eventAttributes.put(key, (value == null ? "null" : value));
return this;
} | java | {
"resource": ""
} |
q20475 | SocksSocket.getInetAddress | train | public InetAddress getInetAddress(){
if(remoteIP == null){
try{
remoteIP = InetAddress.getByName(remoteHost);
}catch(UnknownHostException e){
return null;
}
}
return remoteIP;
} | java | {
"resource": ""
} |
q20476 | Indexer.run | train | public void run(Iterable<Item> items, Context cx) {
Function prepareFunc = (Function) indexResults.getPrototype().get("prepare", indexResults);
prepareFunc.call(cx, scope, indexResults, NO_ARGS);
Object args[] = new Object[] { null, mapFunction };
for (Item item : items) {
a... | java | {
"resource": ""
} |
q20477 | Indexer.create | train | public static Indexer create(String mapTxt) {
Context cx = Context.enter();
try {
return new Indexer(mapTxt, cx);
} finally {
Context.exit();
}
} | java | {
"resource": ""
} |
q20478 | Authenticator.isAuthorizedForBucket | train | public boolean isAuthorizedForBucket(AuthContext ctx, Bucket bucket) {
if (ctx.getUsername().equals(adminName)) {
return ctx.getPassword().equals(adminPass);
}
if (bucket.getName().equals(ctx.getUsername())) {
return bucket.getPassword().equals(ctx.getPassword());
... | java | {
"resource": ""
} |
q20479 | Authenticator.isAdministrator | train | public boolean isAdministrator(AuthContext ctx) {
return ctx.getUsername() != null && ctx.getUsername().equals(adminName) &&
ctx.getPassword() != null && ctx.getPassword().equals(adminPass);
} | java | {
"resource": ""
} |
q20480 | BinaryConfigResponse.create | train | public static BinaryResponse create(BinaryCommand command, MemcachedServer server, ErrorCode errOk, ErrorCode errNotSupp) {
if (!server.isCccpEnabled()) {
return new BinaryResponse(command, errNotSupp);
}
String config = server.getBucket().getJSON();
config = config.replaceA... | java | {
"resource": ""
} |
q20481 | DocumentLoader.loadDocuments | train | public void loadDocuments(String docsFile) throws IOException {
ZipFile zipFile = new ZipFile(docsFile);
Enumeration<? extends ZipEntry> entries = zipFile.entries();
int numDocs = 0;
int numDesigns = 0;
while (entries.hasMoreElements()) {
ZipEntry ent = entries.next... | java | {
"resource": ""
} |
q20482 | DocumentLoader.main | train | public static void main(String[] args) throws Exception {
String input = args[0];
File outputFile = new File(input.replace(".zip", "") + ".serialized.xz");
// Get the base name
FileOutputStream fos = new FileOutputStream(outputFile);
LZMA2Options options = new LZMA2Options(9);
... | java | {
"resource": ""
} |
q20483 | MockCommandDispatcher.processInput | train | public String processInput(String input) {
JsonObject object;
try {
object = gs.fromJson(input, JsonObject.class);
} catch (Throwable t) {
return "{ \"status\" : \"fail\", \"error\" : \"Failed to parse input\" }";
}
String command = object.get("command")... | java | {
"resource": ""
} |
q20484 | MemcachedServer.main | train | public static void main(String[] args) {
try {
VBucketInfo vbi[] = new VBucketInfo[1024];
for (int ii = 0; ii < vbi.length; ++ii) {
vbi[ii] = new VBucketInfo();
}
MemcachedServer server = new MemcachedServer(null, null, 11211, vbi, false);
... | java | {
"resource": ""
} |
q20485 | DesignDocument.create | train | public static DesignDocument create(String body, String name) throws DesignParseException {
DesignDocument doc = new DesignDocument(body);
doc.id = "_design/" + name;
doc.load();
return doc;
} | java | {
"resource": ""
} |
q20486 | Getopt.parse | train | public List<Entry> parse(String[] argv) {
optind = -1;
List<Entry> ret = new ArrayList<Entry>();
int idx = 0;
while (idx < argv.length) {
if (argv[idx].equals("--")) {
// End of options!
++idx;
break;
}
... | java | {
"resource": ""
} |
q20487 | Bucket.create | train | public static Bucket create(CouchbaseMock mock, BucketConfiguration config) throws IOException {
switch (config.type) {
case MEMCACHED:
return new MemcachedBucket(mock, config);
case COUCHBASE:
return new CouchbaseBucket(mock, config);
... | java | {
"resource": ""
} |
q20488 | Bucket.getCommonConfig | train | protected Map<String,Object> getCommonConfig() {
Map<String,Object> mm = new HashMap<String, Object>();
mm.put("replicaNumber", numReplicas);
Map<String,Object> ramQuota = new HashMap<String, Object>();
ramQuota.put("rawRAM", 1024 * 1024 * 100);
ramQuota.put("ram", 1024 * 1024 * ... | java | {
"resource": ""
} |
q20489 | Bucket.respawn | train | public void respawn(int index) {
configurationRwLock.writeLock().lock();
try {
if (index >= 0 && index < servers.length) {
servers[index].startup();
}
rebalance();
} finally {
Info.incrementConfigRevision();
configuratio... | java | {
"resource": ""
} |
q20490 | Bucket.rebalance | train | final void rebalance() {
// Let's start distribute the vbuckets across the servers
configurationRwLock.writeLock().lock();
try {
Info.incrementConfigRevision();
List<MemcachedServer> nodes = activeServers();
for (int ii = 0; ii < numVBuckets; ++ii) {
... | java | {
"resource": ""
} |
q20491 | HandlerUtil.getJsonQuery | train | public static JsonObject getJsonQuery(URL url) throws MalformedURLException {
String query = url.getQuery();
JsonObject payload = new JsonObject();
JsonParser parser = new JsonParser();
if (query == null) {
return null;
}
for (String kv : query.split("&")) {... | java | {
"resource": ""
} |
q20492 | HandlerUtil.getQueryParams | train | public static Map<String,String> getQueryParams(String s) throws MalformedURLException {
Map<String,String> params = new HashMap<String, String>();
for (String kv : s.split("&")) {
String[] parts = kv.split("=");
if (parts.length != 2) {
throw new MalformedURLExc... | java | {
"resource": ""
} |
q20493 | HandlerUtil.makeStringResponse | train | public static void makeStringResponse(HttpResponse response, String s) {
StringEntity entity = new StringEntity(s, ContentType.TEXT_PLAIN);
entity.setContentEncoding("utf-8");
response.setEntity(entity);
} | java | {
"resource": ""
} |
q20494 | HandlerUtil.makeResponse | train | public static void makeResponse(HttpResponse response, String msg, int status) {
response.setStatusCode(status);
makeStringResponse(response, msg);
} | java | {
"resource": ""
} |
q20495 | HandlerUtil.make400Response | train | public static void make400Response(HttpResponse response, String msg) {
makeResponse(response, msg, HttpStatus.SC_BAD_REQUEST);
} | java | {
"resource": ""
} |
q20496 | HandlerUtil.bailResponse | train | public static void bailResponse(HttpContext cx, HttpResponse response) throws IOException, HttpException {
HttpServerConnection conn = getConnection(cx);
conn.sendResponseHeader(response);
conn.sendResponseEntity(response);
conn.flush();
} | java | {
"resource": ""
} |
q20497 | HandlerUtil.getAuth | train | public static AuthContext getAuth(HttpContext cx, HttpRequest req) throws IOException {
AuthContext auth = (AuthContext) cx.getAttribute(HttpServer.CX_AUTH);
if (auth == null) {
Header authHdr = req.getLastHeader(HttpHeaders.AUTHORIZATION);
if (authHdr == null) {
... | java | {
"resource": ""
} |
q20498 | Reducer.create | train | public static Reducer create(String txt) {
Context cx = Context.enter();
try {
return new Reducer(txt, cx);
} finally {
Context.exit();
}
} | java | {
"resource": ""
} |
q20499 | HttpServer.stopServer | train | public void stopServer() {
shouldRun = false;
try {
listener.close();
} catch (IOException ex) {
// Don't care
}
while (true) {
synchronized (allWorkers) {
if (allWorkers.isEmpty()) {
break;
}... | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.