fpompermaier / onvif

Java ONVIF library
Apache License 2.0
191 stars 88 forks source link

SimpleSecurityHandler example usage? #13

Closed Bhlowe closed 5 years ago

Bhlowe commented 5 years ago

Looking at the source code, it appears that the OnvifDevice doesn't properly use the username and password for the camera. Do you have an example of wiring in the SimpleSecurityHandler?

Also, the exception thrown when the camera returns 401 Unauthorized is also really unclear-- the exception simply says "org.apache.cxf.interceptor.Fault: Could not send Message." A better exception message would be the HTTPException...

fpompermaier commented 5 years ago

Hi @Bhlowe, this part is taken as-is from the original code. If you want to submit a PR to fix this I'll be happy to merge it

Bhlowe commented 5 years ago

Somewhere in getServiceProxy you'll need to attach the SimpleSecurityHandler to the proxyFactory.

proxyFactory.getHandlers().add(securityHandler);

I'll try to get a PR pushed-- but my code is diverging from yours a bit..

Wondering if you've considered adding the project to https://mvnrepository.com/ so it can be used in any java project.

fpompermaier commented 5 years ago

Of course this could be done. Just issue a PR and then I would register a first public version on mvnrepository.com!

Thanks Flavio

On Sat, 27 Jul 2019 at 03:00, Bhlowe notifications@github.com wrote:

Somewhere in getServiceProxy you'll need to attach the SimpleSecurityHandler to the proxyFactory.

proxyFactory.getHandlers().add(securityHandler);

I'll try to get a PR pushed-- but my code is diverging from yours a bit..

Wondering if you've considered adding the project to https://mvnrepository.com/ so it can be used in any java project.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/fpompermaier/onvif/issues/13?email_source=notifications&email_token=AA4Z4JOHBBASYH3WLZ75JM3QBOM4PA5CNFSM4IG7KB22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD26AMJY#issuecomment-515638823, or mute the thread https://github.com/notifications/unsubscribe-auth/AA4Z4JOEOGY735JVJXOPUDTQBOM4PANCNFSM4IG7KB2Q .

Bhlowe commented 5 years ago

Hi, OK... I've made a bunch of changes to my fork. I'm not sure the best way to merge them with your code. But take a look and feel free to use any or suggest a PR.. https://github.com/bhlowe/onvif

Give the new discovery a try. The first should just show the URLs. The second DiscoverAndTest should attempt to log into all discovered devices. You'll need a user and password, generally. I've added a routine to use what's passed as an argument or in environment/property settings.

This build should build with java 8.. and run on any newer java if you added the commented java 9+ dependencies.

Maven would be nice..

Bhlowe commented 5 years ago

I posted a massive PR. Fixes security.