Tag: Java

Android WebView – JWT身份validation

我有一个Android应用程序,我正在从基本身份validation切换到JWT,所以,除了其他原因,我不必在本地存储用户的密码。 这对我所有的API请求都很有效,但我的应用程序的一部分使用WebView来显示托管在我的服务器上的自定义内容。 此内容还需要身份validation,目前我使用WebViewClient类中的用户名/密码组合来提供凭据。 现在我要去智威汤逊我不再有这些凭据,只有令牌。 有没有办法提供替代身份validation的WebViewClient ? 我的代码是Kotlin,但同样的原则适用于Java。 inner class WVClient : WebViewClient() { override fun onReceivedHttpAuthRequest(view: WebView, handler: HttpAuthHandler, host: String, realm: String) { // WHAT DO I DO HERE INSTEAD? handler.proceed(username, password) } }

将多个方法合并为一个函数的方法

我是function风格编程的世界相当新的我正在尝试在Kotlin的一些代码,下面给出的代码片段是我所做的,但看起来这么强迫我 @EmailTemplate(“onCallTemplate”) fun retrieveNextOnCallCreateMailRecipientAndSendMail(time: LocalDateTime, trial: Boolean = true) { val emailTemplateID = extractEmailTemplateValue( “retrieveNextOnCallAndSendMail”) val messageTemplate = emailTemplateID?.let { messageTemplateAccessPoint.findByID(it) } val lisOfOnCalls = dataHubCommunicator .listOfOnCallToSendNotificationFromDataHub(time) val listOfMailRecipient = lisOfOnCalls ?.let { onCallListToMailRecipient.buildMailRecipientFromOnCalls(it) } listOfMailRecipient ?.let { messageTemplate ?.let { it1 -> emailSender .sendNotificationToOnCallPersons(it, it1, trial) } } log.info(“Message Has been sent Successfully”) } […]

在SpringBoot中,Firebase连接在Linux上不起作用

我想要实现的是打开一个连接到我的firebase数据库,并获得一些我需要解析的数据。 我正在使用Spring Boot框架,firebase,kotlin和gradle的admin sdk。 在Windows 10上,它是像预期的那样工作,但是当我尝试在我的Linux服务器上运行.jar文件时,它不会得到任何数据或错误。 它被困在ValueEventListener中。 我有ufw安装,但禁用它或添加端口5228:5230(tcp / udp),没有解决问题。 val dataMinifiedRef = database.reference.child(“minifiedData”).child(“areas”) dataMinifiedRef.addListenerForSingleValueEvent(object : ValueEventListener { override fun onCancelled(error: DatabaseError?) { log.info(error!!.message) } override fun onDataChange(dataSnapshot: DataSnapshot) { log.info(“Got data”) } }) 编辑:这是我解析服务帐户。 val str = “{\n” + … “}\n” // convert String into InputStream val serviceAccount = ByteArrayInputStream(str.toByteArray()) val options = FirebaseOptions.Builder() […]

使用Kapt和Dagger2进行注释处理时出错

我花了一些时间与我的错误,但没有任何积极的结果,所以我可能有人可以帮助。 我的项目中有3个模块:应用程序(android),数据,域 – 都是纯kotlin。 所有DI都在应用程序模块中。 ApplicationComponent&ApplicationModule: @Singleton @Component(modules = arrayOf(ApplicationModule::class, NavigatorModule::class, RepositoryModule::class, FirebaseModule::class, SchedulerModule::class, UseCaseModule::class)) interface ApplicationComponent { fun injectApplication(application: Application) fun loginSubComponent() : LoginSubComponent } @Module class ApplicationModule(private val application: Application) { @Provides @Singleton fun provideApplication() = application } @Module class UseCaseModule { @Provides @Singleton fun provideLoginAccountUseCase(scheduler: ComposeScheduler, repository: AccountRepository) = LoginAccountUseCase(scheduler, repository) @Provides […]

TornadoFX找不到JavaFx

我正在尝试使用TotrnadoFx的第一个应用程序,所以我开始使用这个代码: package no.tornado.fxsample.workspace import javafx.application.Application import tornadofx.* fun main(args: Array) = launch(args) class MyApp: App(MyView::class) class MyView: View() { override val root = VBox() init { with(root) { this += Button(“Press Me”) this += Label(“Waiting”) } } } 但显然它充满了错误,并没有能够findJavaFX 我的gradle.build是: // set up the kotlin-gradle plugin buildscript { ext.kotlin_version = ‘1.1.60’ repositories { mavenLocal() // […]

SpringBoot ArrayIndexOutOfBoundsException MethodParameter.getGenericParameterType

我正在使用spring引导,我试图建立一个测试场景,我调用一个bean,调用一个模拟JPARepository使用mockito。 这是相关的代码: 存储库 @Repository interface FooRepository : JpaRepository 服务 @Service class FooService( private val FooRepository: FooRepository ) { @Transactional fun call(input: String) = FooRepository.saveAndFlush( Foo(input) ) } 和测试 @SpringBootTest @RunWith(SpringRunner::class) @Import(FooServiceTest.MockFooRepositoryConfiguration::class) class FooServiceTest { @Autowired private lateinit var fooService: FooService @Autowired private lateinit var fooRepository: FooRepository @Test fun test1() { FooService.call(“xxx”) Mockito.verify(FooRepository, Mockito.times(1)).saveAndFlush(“xxx”) } @Configuration […]

在@Transactional方法调用期间,初始化期间Bean属性不为null变为null

我遇到了一个问题,在调用@Transactional方法期间bean的属性变为null。 UserService是在@Configuration类中声明的一个bean userRepository和passwordService在初始化期间是非空的(afterPropertiesSet) 在调用registerUser( @Transactional )期间,这些属性将变为null 这些属性具有不可空的types 用户服务的相同实例/ bean已根据打印使用 删除@Transactional似乎解决了这个问题 添加或删除@EnableTransactionManagement似乎什么都不做 服务: open class UserService (val userRepository: UserRepository, val passwordService: PasswordService) : InitializingBean { override fun afterPropertiesSet() { println(“### this.afterPropertiesSet”) println(“### this: ” + this) println(“### userRepository: ” + userRepository) println(“### passwordService: ” + passwordService) } @Transactional fun registerUser(request: UserRegistrationRequest): User { println(“### this.registerUser”) println(“### […]

防止Android应用程序中的内存值更改

美好的一天。 我正在开发应用程序,并遇到了安全测量。 可能导致安全漏洞的问题: •设备已根植 •用户可以将黑客应用程序附加到应用程序进程 •应用程序可以隐藏黑客应用程序进程 •用户可以更改应用程序的内存值(假设更改布尔值为false) 期望的解决方案: •部署后更改内存中的值时捕获该操作 理想情况下,我不能想到任何现有的API可以提供这样的解决方案在Java / Kotlin,任何建议将是有益的。 谢谢

Spring数据mongodb和集合模式设计

朋友,我有一个问题,如何组织和注释我的实体和弹簧数据配置为不同的关系? 我有关系的用户,钱包和余额实体: 一对一:用户钱包 一对多:钱包余额 我想在MongoDB中有下一个模式: > db.users.findOne() { _id : ObjectID(‘UUUU’), name : ‘Jason Statham’ } > db.wallets.findOne() { _id : ObjectID(‘WWWW’), user : ObjectID(‘UUUU’) balances : [ { currency: ‘USD’, balance: 100}, { currency: ‘EUR’, balance: 530.50 } ] } 电子钱包应该包含对ObjectID的引用,并且User被存储在单独的集合中 电子钱包应包含作为嵌入实体的余额 实体: data class User(val id: String, val name: String) data class Wallet(val […]

在java类中调用扩展函数作为任何RX操作符

我创建了一个扩展函数, fun Observable.subscribeWithErrorHandling(onNext: (T) -> Unit ,onError: ((throwable: Throwable) -> Unit)? = null): Subscription { //doing stuff } 在kotlin类中,我将能够以这种方式使用它 observable.subscribeWithErrorHandling(…) 现在,我想在我的java类中使用这个函数。 我已经看到,你可以静态调用它: MyExtensionFile.subscribeWithErrorHandling 但在我的情况下,你需要别的东西,因为它是一个RX流的中间部分。 这是我坚持的部分。 这甚至可能吗? 或没有办法做这样的事情,从Java代码?