本文整理汇总了Java中de.duenndns.ssl.MemorizingTrustManager类的典型用法代码示例。如果您正苦于以下问题:Java MemorizingTrustManager类的具体用法?Java MemorizingTrustManager怎么用?Java MemorizingTrustManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MemorizingTrustManager类属于de.duenndns.ssl包,在下文中一共展示了MemorizingTrustManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Settings
import de.duenndns.ssl.MemorizingTrustManager; //导入依赖的package包/类
private Settings(Context context) {
this.preferences = PreferenceManager.getDefaultSharedPreferences(context);
mMemorizingTrustManager = new MemorizingTrustManager(context.getApplicationContext());
mXiotBluetoothManager = XiotBluetoothLeManager.getInstance(context);
IOT_CLAIM_ENABLED_KEY = context.getResources().getString(R.string.iot_claim_enabled_pref_key);
MUTUAL_SUBSCRIPTION_MODE_KEY = context.getResources().getString(R.string.mutual_subscription_mode_pref_key);
preferences.registerOnSharedPreferenceChangeListener((p, k) -> {
switch (k) {
case IDENTIY_MODE_KEY:
String newIdentityMode = p.getString(IDENTIY_MODE_KEY, "");
switch (newIdentityMode) {
case "thing":
break;
case "app":
mXiotBluetoothManager.disableManager();
break;
default:
throw new AssertionError();
}
break;
}
});
}
示例2: getTlsFactoryVerifier
import de.duenndns.ssl.MemorizingTrustManager; //导入依赖的package包/类
private TlsFactoryVerifier getTlsFactoryVerifier() throws NoSuchAlgorithmException, KeyManagementException, IOException {
final SSLContext sc = SSLSocketHelper.getSSLContext();
MemorizingTrustManager trustManager = this.mXmppConnectionService.getMemorizingTrustManager();
KeyManager[] keyManager;
if (account.getPrivateKeyAlias() != null && account.getPassword().isEmpty()) {
keyManager = new KeyManager[]{mKeyManager};
} else {
keyManager = null;
}
sc.init(keyManager, new X509TrustManager[]{mInteractive ? trustManager : trustManager.getNonInteractive()}, mXmppConnectionService.getRNG());
final SSLSocketFactory factory = sc.getSocketFactory();
final HostnameVerifier verifier;
if (mInteractive) {
verifier = trustManager.wrapHostnameVerifier(new XmppDomainVerifier());
} else {
verifier = trustManager.wrapHostnameVerifierNonInteractive(new XmppDomainVerifier());
}
return new TlsFactoryVerifier(factory, verifier);
}
示例3: onCreate
import de.duenndns.ssl.MemorizingTrustManager; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login_anim);
mLoginState = (TextView) findViewById(R.id.loginanim_status_text);
mLogo = (ImageView) findViewById(R.id.loginanim_logo_anim);
mRotateAnim = AnimationUtils.loadAnimation(this, R.anim.rotate_and_scale);
mCancelBt = (Button) findViewById(R.id.loginanim_cancel_button);
mCancelBt.setOnClickListener(new ClickListener());
mSslReceiver = new BroadcastReceiver() {
public void onReceive(Context ctx, Intent i) {
try {
Log.i(TAG, "Interception the SSL notification");
PendingIntent pi = i.getParcelableExtra(MemorizingTrustManager.INTERCEPT_DECISION_INTENT_LAUNCH);
pi.send();
abortBroadcast();
} catch (PendingIntent.CanceledException e) {
Log.e(TAG, "Error while displaying the SSL dialog", e);
}
}
};
}
示例4: onCreate
import de.duenndns.ssl.MemorizingTrustManager; //导入依赖的package包/类
/** Creates the Activity and registers a MemorizingTrustManager. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
JULHandler.initialize();
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.mtmexample);
// set up gui elements
findViewById(R.id.connect).setOnClickListener(this);
content = (TextView)findViewById(R.id.content);
urlinput = (EditText)findViewById(R.id.url);
// register handler for background thread
hdlr = new Handler();
// Here, the MemorizingTrustManager is activated for HTTPS
try {
// set location of the keystore
MemorizingTrustManager.setKeyStoreFile("private", "sslkeys.bks");
// register MemorizingTrustManager for HTTPS
SSLContext sc = SSLContext.getInstance("TLS");
mtm = new MemorizingTrustManager(this);
sc.init(null, new X509TrustManager[] { mtm },
new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
HttpsURLConnection.setDefaultHostnameVerifier(
mtm.wrapHostnameVerifier(HttpsURLConnection.getDefaultHostnameVerifier()));
// disable redirects to reduce possible confusion
HttpsURLConnection.setFollowRedirects(false);
} catch (Exception e) {
e.printStackTrace();
}
}
示例5: getTlsFactoryVerifier
import de.duenndns.ssl.MemorizingTrustManager; //导入依赖的package包/类
private TlsFactoryVerifier getTlsFactoryVerifier() throws NoSuchAlgorithmException, KeyManagementException, IOException {
final SSLContext sc = SSLSocketHelper.getSSLContext();
MemorizingTrustManager trustManager = this.mXmppConnectionService.getMemorizingTrustManager();
KeyManager[] keyManager;
if (account.getPrivateKeyAlias() != null && account.getPassword().isEmpty()) {
keyManager = new KeyManager[]{new MyKeyManager()};
} else {
keyManager = null;
}
String domain = account.getJid().getDomainpart();
sc.init(keyManager, new X509TrustManager[]{mInteractive ? trustManager.getInteractive(domain) : trustManager.getNonInteractive(domain)}, mXmppConnectionService.getRNG());
final SSLSocketFactory factory = sc.getSocketFactory();
final DomainHostnameVerifier verifier = trustManager.wrapHostnameVerifier(new XmppDomainVerifier(), mInteractive);
return new TlsFactoryVerifier(factory, verifier);
}
示例6: getTlsFactoryVerifier
import de.duenndns.ssl.MemorizingTrustManager; //导入依赖的package包/类
private TlsFactoryVerifier getTlsFactoryVerifier() throws NoSuchAlgorithmException, KeyManagementException, IOException {
final SSLContext sc = SSLSocketHelper.getSSLContext();
MemorizingTrustManager trustManager = this.mXmppConnectionService.getMemorizingTrustManager();
KeyManager[] keyManager;
if (account.getPrivateKeyAlias() != null && account.getPassword().isEmpty()) {
keyManager = new KeyManager[]{new MyKeyManager()};
} else {
keyManager = null;
}
String domain = account.getJid().getDomainpart();
sc.init(keyManager, new X509TrustManager[]{mInteractive ? trustManager.getInteractive(domain) : trustManager.getNonInteractive(domain)}, mXmppConnectionService.getRNG());
final SSLSocketFactory factory = sc.getSocketFactory();
final DomainHostnameVerifier verifier = trustManager.wrapHostnameVerifier(new XmppDomainVerifier(), mInteractive);
return new TlsFactoryVerifier(factory, verifier);
}
示例7: sendMTMDecision
import de.duenndns.ssl.MemorizingTrustManager; //导入依赖的package包/类
void sendMTMDecision(int decisionId, int decision) {
Log.d(TAG, "Sending decision to MTM");
Intent i = new Intent(MemorizingTrustManager.DECISION_INTENT + "/" + getPackageName());
i.putExtra(MemorizingTrustManager.DECISION_INTENT_ID, decisionId);
i.putExtra(MemorizingTrustManager.DECISION_INTENT_CHOICE, decision);
sendBroadcast(i);
}
示例8: makeDecision
import de.duenndns.ssl.MemorizingTrustManager; //导入依赖的package包/类
public void makeDecision(int decisionId, String certMessage) {
Log.d(TAG, String.format("MTM is asking for decision on id = %d", decisionId));
if (mSettings.getBoolean(Constants.PREFERENCE_SSLCERT, false))
MemorizingTrustManager.interactResult(decisionId, MTMDecision.DECISION_ONCE);
else
showCertificateDialog(decisionId, certMessage);
}
示例9: makeDecision
import de.duenndns.ssl.MemorizingTrustManager; //导入依赖的package包/类
public void makeDecision(int decisionId, String certMessage) {
Log.d(TAG, String.format("MTM is asking for decision on id = %d", decisionId));
if (mSettings.getBoolean("default_openhab_sslcert", false))
MemorizingTrustManager.interactResult(decisionId, MTMDecision.DECISION_ONCE);
else
showCertificateDialog(decisionId, certMessage);
}
示例10: MyAsyncHttpClient
import de.duenndns.ssl.MemorizingTrustManager; //导入依赖的package包/类
public MyAsyncHttpClient(Context ctx) {
super(ctx);
try {
sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, MemorizingTrustManager.getInstanceList(ctx), new java.security.SecureRandom());
sslSocketFactory = new MySSLSocketFactory(sslContext);
if (PreferenceManager.getDefaultSharedPreferences(ctx).getBoolean("default_openhab_sslhost", false))
sslSocketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
this.setSSLSocketFactory(sslSocketFactory);
} catch (Exception ex) {
}
}
示例11: onCreate
import de.duenndns.ssl.MemorizingTrustManager; //导入依赖的package包/类
@SuppressLint("TrulyRandom")
@Override
public void onCreate() {
ExceptionHelper.init(getApplicationContext());
PRNGFixes.apply();
this.mRandom = new SecureRandom();
this.mMemorizingTrustManager = new MemorizingTrustManager(
getApplicationContext());
final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
final int cacheSize = maxMemory / 8;
this.mBitmapCache = new LruCache<String, Bitmap>(cacheSize) {
@Override
protected int sizeOf(final String key, final Bitmap bitmap) {
return bitmap.getByteCount() / 1024;
}
};
this.databaseBackend = DatabaseBackend.getInstance(getApplicationContext());
this.accounts = databaseBackend.getAccounts();
for (final Account account : this.accounts) {
account.initOtrEngine(this);
this.databaseBackend.readRoster(account.getRoster());
}
initConversations();
PhoneHelper.loadPhoneContacts(getApplicationContext(),new CopyOnWriteArrayList<Bundle>(), this);
getContentResolver().registerContentObserver(ContactsContract.Contacts.CONTENT_URI, true, contactObserver);
this.fileObserver.startWatching();
this.pgpServiceConnection = new OpenPgpServiceConnection(getApplicationContext(), "org.sufficientlysecure.keychain");
this.pgpServiceConnection.bindToService();
this.pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
this.wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"XmppConnectionService");
toggleForegroundService();
}
示例12: onStart
import de.duenndns.ssl.MemorizingTrustManager; //导入依赖的package包/类
@Override
protected void onStart() {
super.onStart();
mLogo.startAnimation(mRotateAnim);
if (mTask == null)
mTask = new LoginTask();
if (!mBinded)
mBinded = bindService(LoginAnim.SERVICE_INTENT, mServConn, BIND_AUTO_CREATE);
IntentFilter filter = new IntentFilter(MemorizingTrustManager.INTERCEPT_DECISION_INTENT
+ "/" + getPackageName());
filter.setPriority(RECEIVER_PRIORITY);
registerReceiver(mSslReceiver, filter);
}
示例13: initMemorizingTrustManager
import de.duenndns.ssl.MemorizingTrustManager; //导入依赖的package包/类
/**
* Install the MemorizingTrustManager in the ConnectionConfiguration of Smack.
*/
private void initMemorizingTrustManager() {
try {
sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, MemorizingTrustManager.getInstanceList(this),
new java.security.SecureRandom());
} catch (GeneralSecurityException e) {
Log.w(TAG, "Unable to use MemorizingTrustManager", e);
}
}
示例14: getMemorizingTrustManager
import de.duenndns.ssl.MemorizingTrustManager; //导入依赖的package包/类
public MemorizingTrustManager getMemorizingTrustManager() {
return this.mMemorizingTrustManager;
}
示例15: setMemorizingTrustManager
import de.duenndns.ssl.MemorizingTrustManager; //导入依赖的package包/类
public void setMemorizingTrustManager(MemorizingTrustManager trustManager) {
this.mMemorizingTrustManager = trustManager;
}