小编o_b*_*_b7的帖子

使用JGit和JSCH时无效的privateKey

我正在使用以下代码在Java应用程序中使用Git.我有一个有效的密钥(一直使用它),这个特定的代码以前使用相同的密钥和git存储库,但现在我得到以下异常:无效的私钥:[B @ 59c40796.

jSch.addIdentity("<key_path>/private_key.pem");
Run Code Online (Sandbox Code Playgroud)

在线搜索后,我将createDefaultJSch更改为使用pemWriter:

    String remoteURL = "ssh://git@<git_repository>";
    TransportConfigCallback transportConfigCallback = new SshTransportConfigCallback();
    File gitFolder = new File(workingDirectory);
    if (gitFolder.exists()) FileUtils.delete(gitFolder, FileUtils.RECURSIVE);

    Git git = Git.cloneRepository()
            .setURI(remoteURL)
            .setTransportConfigCallback(transportConfigCallback)
            .setDirectory(new File(workingDirectory))
            .call();
}


private static class SshTransportConfigCallback implements TransportConfigCallback {
    private final SshSessionFactory sshSessionFactory = new JschConfigSessionFactory() {
        @Override
        protected void configure(OpenSshConfig.Host hc, Session session) {
            session.setConfig("StrictHostKeyChecking", "no");
        }

        @Override
        protected JSch createDefaultJSch(FS fs) throws JSchException {
            JSch jSch = super.createDefaultJSch(fs);
            jSch.addIdentity("<key_path>/private_key.pem");

            return jSch;
        }
    };
Run Code Online (Sandbox Code Playgroud)

但仍然得到无效的privateKey异常.

java ssh jsch

25
推荐指数
4
解决办法
8343
查看次数

Android地理围栏应用程序在启动时崩溃

我正在尝试创建一个具有单个按钮的新地理围栏应用程序(Toast消息"inside"或"outside"),但应用程序在启动时崩溃.

这是代码:

MainActivity.java

package com.example.geofencing;

import java.util.ArrayList;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.Geofence;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.IntentSender;
import android.location.Location;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;

public class MainActivity extends Activity implements
    GoogleApiClient.ConnectionCallbacks,
    GoogleApiClient.OnConnectionFailedListener {

// save the string that represent the geofence status
private static String DWELL = "Default";

private GoogleApiClient mGoogleClient;

// mock laoctions variables
private static final String PROVIDER = "flp";
private static final double LAT …
Run Code Online (Sandbox Code Playgroud)

crash android geofencing

6
推荐指数
1
解决办法
2837
查看次数

标签 统计

android ×1

crash ×1

geofencing ×1

java ×1

jsch ×1

ssh ×1