This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Criar nova chave SSH | |
1- Gerar chave: | |
ssh-keygen -t ed25519 -C "[email protected]" | |
2- Adicionar chave ao agente: | |
#macOS | |
eval "$(ssh-agent -s)" | |
ssh-add ~/.ssh/id_ed25519 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun getUnsafeOkHttpClientBuilder(): OkHttpClient.Builder { | |
try { | |
val trustAllCerts = arrayOf<TrustManager>(object : X509TrustManager { | |
override fun checkClientTrusted( | |
chain: Array<java.security.cert.X509Certificate>, | |
authType: String | |
) { | |
} | |
override fun checkServerTrusted( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Throws( | |
CertificateException::class, | |
KeyStoreException::class, | |
NoSuchAlgorithmException::class, | |
KeyManagementException::class | |
) | |
private fun getSSLConfig(context: Context): SSLContext { | |
val certificateFactory = CertificateFactory.getInstance("X.509") | |
context.resources.openRawResource(R.raw.tpv_certificate).use { inputStream -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context | |
import android.text.Editable | |
import android.text.TextWatcher | |
import android.util.AttributeSet | |
import android.view.LayoutInflater | |
import android.widget.EditText | |
import android.widget.LinearLayout | |
import kotlinx.coroutines.CoroutineScope | |
import kotlinx.coroutines.Dispatchers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Throws(java.lang.Exception::class) | |
fun convertStreamToString(input: InputStream?): String? { | |
input ?: return null | |
val reader = BufferedReader(InputStreamReader(input)) | |
val sb = StringBuilder() | |
var line: String? | |
while (reader.readLine().also { line = it } != null) { | |
sb.append(line).append("\n") | |
} | |
reader.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
InputStream inputStream = context.getContentResolver().openInputStream(urifont); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Uri fontUri = new Uri.Builder() | |
.scheme(ContentResolver.SCHEME_ANDROID_RESOURCE) | |
.authority(BuildConfig.APPLICATION_ID) | |
.path(String.valueOf(R.font.roboto_regular)) | |
.build(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@JvmStatic | |
fun retrieveAllManifestPermissions(context: Context): Array<String> { | |
return try { | |
context | |
.packageManager | |
.getPackageInfo(context.packageName, PackageManager.GET_PERMISSIONS) | |
.requestedPermissions | |
} catch (e: Exception) { | |
emptyArray() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun generateHashWithHmac256(message: String): String? { | |
try { | |
val key = BuildConfig.HASH | |
val bytes = hmac(key.toByteArray(), message.toByteArray()) | |
if (bytes != null) return bytesToHex(bytes) | |
} catch (e: Exception) { | |
e.printStackTrace() | |
} | |
return null | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Throws(IOException::class) | |
override fun intercept(chain: Interceptor.Chain): Response { | |
val firebaseToken = Utils.getFirebaseToken(context) | |
val originalRequest: Request = chain.request() | |
var newRequest = originalRequest.newBuilder() | |
.addHeader("content-type", "application/json;charset=UTF-8") | |
.addHeader("accept", "application/json") | |
.addHeader("api-version", "1.0") | |
.addHeader("authorization", "Bearer $firebaseToken") |
NewerOlder