GenTux\Jwt\Drivers\JwtDriverInterface is not instantiable - jwt

BindingResolutionException
Target [GenTux\Jwt\Drivers\JwtDriverInterface] is not instantiable while building [App\Services\AuthService, GenTux\Jwt\JwtToken]

By adding the below line in bootstrap/app.php at register service provider section solved my issue:
$app->register(GenTux\Jwt\Support\LumenServiceProvider::class);

Related

Apache Meecrowave OAuth2 JPA

I succeedeed in creating my own OAuth2 server using JCache as token store but I'm facing an issue when moving to JPA.
My configuration is :
"--users","test=test",
"--roles","test=test",
"--oauth2-provider","jpa",
"--oauth2-jpa-database-driver","org.h2.Driver",
"--oauth2-jpa-database-url","jdbc:h2:mem:oauth",
"--oauth2-jpa-database-username","sa",
"--oauth2-jpa-database-password",""
But I got exception below during OpenJPA bootstrap :
here was an error while setting up the configuration plugin option "MetaDataFactory".
The plugin was of type "org.apache.openjpa.persistence.jdbc.PersistenceMappingFactory".
Setter methods for the following plugin properties were not available in that type: [
org.apache.cxf.rs.security.oauth2.tokens.bearer.BearerAccessToken,
org.apache.cxf.rs.security.oauth2.common.OAuthPermission,
org.apache.cxf.rs.security.oauth2.tokens.refresh.RefreshToken,
org.apache.cxf.rs.security.oauth2.grants.code.ServerAuthorizationCodeGrant,
org.apache.cxf.rs.security.oauth2.common.UserSubject].
Possible plugin properties are:
[AnnotationParser, ClasspathScan, FieldOverride, Files, JAR_FILE_URLS, MAPPING_FILE_NAMES, MODE_ALL, MODE_ANN_MAPPING, MODE_MAPPING, MODE_MAPPING_INIT, MODE_META, MODE_NONE, MODE_QUERY, PERSISTENCE_UNIT_ROOT_URL, Repository, Resources, STORE_DEFAULT, STORE_PER_CLASS, STORE_VERBOSE, StoreDirectory, StoreMode, Strict, Types, URLs, XMLAnnotationParser, XMLParser].
Ensure that your plugin configuration string uses key values that correspond to setter methods in the plugin class.
I suppose I missed something in configuration...
Any help would be appreciated.
Tx
Using --oauth2-jpa-properties you can set any persistence unit properties you want, I guess you will have to override openjpa.MetaDataFactory default value which is set to jpa(Types=org.apache.cxf.rs.security.oauth2.common.Client,org.apache.cxf.rs.security.oauth2.common.OAuthPermission,org.apache.cxf.rs.security.oauth2.common.UserSubject,org.apache.cxf.rs.security.oauth2.grants.code.ServerAuthorizationCodeGrant,org.apache.cxf.rs.security.oauth2.tokens.bearer.BearerAccessToken,org.apache.cxf.rs.security.oauth2.tokens.refresh.RefreshToken).
You can also check if your configuration is properly propagated and if there is no classpath conflict (another persistence.xml with an oauth2 unit?) because I just retested and your configuration seems to work.
Romain

None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' in builder.RegisterType<ContentItemMetadataProvider>

Detailed error is as below
None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'KMVC12.Controllers.HomeController' can be invoked with the available services and parameters:
Cannot resolve parameter 'KMVC12.Repositories.IPromotedContentRepository repository' of constructor 'Void .ctor(KMVC12.Repositories.IPromotedContentRepository, KMVC12.Repositories.IHomeRepository, KMVC12.Infrastructure.IOutputCacheDependencies)'.
Have removed set .PreserveExistingDefaults() in the builder.RegisterType which is i found it in one solution
I have below code in DependencyResolverConfig.cs file is this cause of the error?
builder.RegisterType<ContentItemMetadataProvider>()
.AsImplementedInterfaces()
.SingleInstance()
Unable to run the home page because of the above exception
Need to run it without any exception in the front end.

How can I load a vendor class as a Service in Symfony 4?

I'm using the jwt firebase class in a project, it's path in vendor is:
vendor\firebase\php-jwt\src\jwt
I'm trying to define the class as a service to be able to inject in another class, but I'm not able to do it.
I'm to do this in the service.yml file:
#services.yaml
services:
Firebase:
class: '../vendor\firebase\php-jwt\JWT'
An this is the class I have created:
<?php
namespace App\Helpers;
use Firebase\JWT\JWT;
use Symfony\Component\HttpKernel\KernelInterface;
class simpleJwt
{
private $encrypt = 'RS256';
function __construct(KernelInterface $kernel, JWT $JWT )
{
$this->rootDir = $kernel->getProjectDir();
$this->jwt = $JWT;
}
}
When I try to load it I get this error:
Cannot autowire service "App\Helpers\simpleJwt": argument "$JWT" of method "__construct()" references class "Firebase\JWT\JWT" but no such service exists.
Thanks
Just add full namespace in config.yaml
services:
Firebase\JWT\JWT:
You can also provide to your service constructor requirements, using arguments:
services:
Namespace\Domain\ServiceName:
arguments:
- '#Another\Namespace\Class'
- '#service.name'
- '%parameter%'
More details and features in the official documentation :
Service Container (Symfony Docs)
Note you'll access your service through AutoWiring and that you won't access to it directly through the container, cause service public argument is set to false by default (public: true is not recommended according to Symfony documentation).
Try adding ‘autowire: true’ in your services.yaml, right under ‘class: ../vendor\firebase\php-jwt\JWT’
It could be that the bundle you are trying to import might not be compatible with Symfony’s autowire. Be sure to use the latest version of the bundle (newer versions might be compatible). In case you’re already using the lastest version, you might need to create an alias for that bundle in your services.yaml so you can use it later on your classes. You can use bin/console debug:container to check what services are available and manually create an alias for the service you need. It happens that autowire is commonly turned off in most of the vendor bundles.

Kamailio-Asterisk - route "FROMASTERISK" not found

I'm trying to implement Kamailio 4.1 with Asterisk 12.1.0 regarging this tutorial:
http://kb.asipto.com/asterisk:realtime:kamailio-4.0.x-asterisk-11.3.0-astdb
And when I try to compile kamaili.cfg, I still got this error:
Apr 19 16:59:31 debian /usr/local/sbin/kamailio[5751]: ERROR: <core> [route.c:1137]: fix_actions(): route "FROMASTERISK" not found at /usr/local/etc/kamailio/kamailio.cfg:780
I have loaded all modules like in tutorial.
I tried to find some solve this issue, but with no result.
Thank you for help!
That error mean in your kamailio.cfg file not found section with route "FROMASTERISK"
Also note, that your kamailio config file is /usr/local/etc/kamailio/kamailio.cfg
You have add section or remove route.

NoClassDefFoundError in openid4java

I have downloaded openid4java-0.9.6.662 and implemented a class using it. When I execute:
List discoveries = manager.discover("https://www.google.com/accounts/o8/id");
I get a
java.lang.NoClassDefFoundError: org/apache/http/protocol/ImmutableHttpProcessor
at org.apache.http.impl.client.AbstractHttpClient.getProtocolProcessor(AbstractHttpClient.java:656)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:804)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
at org.openid4java.util.HttpCache.head(HttpCache.java:335)
at org.openid4java.discovery.yadis.YadisResolver.retrieveXrdsLocation(YadisResolver.java:400)
at org.openid4java.discovery.yadis.YadisResolver.discover(YadisResolver.java:248)
at org.openid4java.discovery.yadis.YadisResolver.discover(YadisResolver.java:232)
at org.openid4java.discovery.yadis.YadisResolver.discover(YadisResolver.java:166)
at org.openid4java.discovery.Discovery.discover(Discovery.java:147)
at org.openid4java.discovery.Discovery.discover(Discovery.java:129)
at org.openid4java.consumer.ConsumerManager.discover(ConsumerManager.java:542)
at com.sugra.openid.helper.OpenIDConsumer.authRequest(OpenIDConsumer.java:90)
the funny thing is this class cannot be found in any of the jars, thought it is supposed to be found in httpcore-4.0.1.jar, as it contains classes of the same package. This class is available in httpcore-4.2.1.jar. But I've tried it and got
org.openid4java.discovery.yadis.YadisException: 0x704: I/O transport error: hostname in certificate didn't match: <www.google.com/173.194.35.144> != <www.google.com>
that is reported to be an error of portability and a previous version should be used
What is supposed to be the right approach to use this method?
I found it. There was a conflict with another jar (httpclient.jar) I had in my app. I just had to upgrade it