- URL protocol handlers in basic Ubuntu Desktop
- Update
- How do I create my own URL protocol? (e.g. so://. ) [closed]
- 8 Answers 8
- Custom url protocol linux
- About
- Topics
- Resources
- License
- Releases
- Packages 0
- Contributors 2
- Languages
- Registering and using a custom java.net.URL protocol
- 3 Answers 3
- MobaXterm URL Protocol Handler Usage
- 2 Answers 2
URL protocol handlers in basic Ubuntu Desktop
There was a way to register URL protocol handlers with Gconf, which is now obsolete and there seems to be no way to do the same with DConf (or Gsettings, its recommended wrapper).
How do one properly register an URL protocol handlers since DConf?
Additionally, something looks strange to me (as I don’t understand it), on my Ubuntu 12.04
The protocol apt:// should be handled by the apturl command. It is so with my Opera browser, but only because I added this specific association using the browser’s configuration facility. Otherwise, in the rest of the environment:
- Running xdg-open apt://foo.bar opens elinks (my www-browser alternative).
- Running gnome-open apt://foo.bar opens the Software Center.
- Opening gconf-editor , I see a key /desktop/gnome/url-handlers/apt whose value is apturl «%s» and it’s enabled. This configuration seems to be ignored, which is reasonably expected, as GConf is considered obsolete.
- Opening dconf-editor , I can’t see anything related to URL handlers or protocols in /desktop/gnome
It looks a bit messy to my eyes (just teasing with this wording, nothing bad)
Side note: I’m looking for something which preferably works even when the full desktop environment is not loaded, like when running an i3wm session with only gsettings-daemon (and other stuff unrelated to this case) loaded.
Update
Another way to “register” a protocol handler is with *.desktop files and their MIME-Type; e.g. MimeType=application/
I found a /usr/share/applications/ubuntu-software-center.desktop with this content:
This one explains why gnome-open apt://foo.bar opens the Software Center instead of apturl .
So I installed this apturl.desktop in
After update-desktop-database and even after rebooting, both xdg-open and gnome-open still do the same and ignore this user desktop file, which as usual with user desktop‑files, should override the one in /usr/share/applications/ .
Maybe there is something special with desktop files specifying x-scheme-handler MIME type and they are not handled the usual way.
The desktop‑file way does not answer the question.
Источник
How do I create my own URL protocol? (e.g. so://. ) [closed]
Want to improve this question? Update the question so it’s on-topic for Stack Overflow.
Closed 3 years ago .
What is that first section where you see http and the like called?
Can I register my own?
8 Answers 8
The portion with the HTTP:// , FTP:// , etc are called URI Schemes
You can register your own through the registry.
Open notepad and paste the code below into it. Change «YourApp» into your app’s name. Save it to YourApp.reg and execute it by clicking on it in explorer. That’s it! Cheers! Erwin Haantjes
This is different for each browser, in IE and windows you need to create what they call a pluggable protocol handler.
The basic steps are as follows:
- Implement the IInternetProtocol interface.
- Implement the IInternetProtocolRoot interface.
- Implement the IClassFactory interface.
- Optional. Implement the IInternetProtocolInfo interface. Support for the HTTP protocol is provided by the transaction handler.
- If IInternetProtocolInfo is implemented, provide support for PARSE_SECURITY_URL and PARSE_SECURITY_DOMAIN so the URL security zone manager can handle the security properly. Write the code for your protocol handler.
- Provide support for BINDF_NO_UI and BINDF_SILENTOPERATION.
- Add a subkey for your protocol handler in the registry under HKEY_CLASSES_ROOT\PROTOCOLS\Handler.
- Create a string value, CLSID, under the subkey and set the string to the CLSID of your protocol handler.
See About Asynchronous Pluggable Protocols on MSDN for more details on the windows side. There is also a sample in the windows SDK.
A quick google also showed this article on codeproject: http://www.codeproject.com/KB/IP/DataProtocol.aspx.
Finally, as a security guy I have to point out that this code needs to be battle hardened. It’s at a high risk because to do it reliably you can’t do it in managed code and have to do it in C++ (I suppose you could use VB6). You should consider whether you really need to do this and if you do, design it carefully and code it securely. An attacker can easily control the content that gets passed to you by simply including a link on a page. For example if you have a simple buffer overflow then nobody better do this: Click me for free porn
Источник
Custom url protocol linux
Resolve custom protocols using registered handlers.
This module can be used either in standalone mode or as Express middleware.
Table of Contents
Extends Error
Custom error indicating invalid, unknown or blacklisted protocol
- code ProtocolError.code Error code
- message String Error message
- ERR_PROTOCOL_INVALID Number
- ERR_PROTOCOL_UNKNOWN Number
- ERR_PROTOCOL_BLACKLISTED Number
Create protocol handler
- options ProtocolHandlerOptions protocol handler options (optional, default <> )
- options.blacklist (optional, default [] )
Registers protocol handler
- scheme String protocol scheme
- handler ProtocolCallback protocol handler
- Throws ProtocolError throws if protocol scheme is invalid or blacklisted
Returns ProtocolHandler instance to allow chaining
- protocols Set registered protocols
Asynchronously resolves url with registered protocol handler
- url String target url
- Throws ProtocolError throws if url contains invalid or unknown protocol
Returns Promise resolved url, redirect location
- param String name of query param containing target url (optional, default ‘url’ )
- cb ProtocolErrorCallback? custom error handling callback
Create new ProtocolHandler instance
- options ProtocolHandlerOptions protocol handler options (optional, default <> )
Returns ProtocolHandler instance
- blacklist Array ? array of blacklisted schemes
Resolver function for specific protocol
- url String target url
Returns (String | Promise ) resolved url redirect location
Custom error calback for Express middleware
- err ProtocolError protocol error
- url String target url
About
Node library for creating custom protocol resolver; can be used as Express middleware.
Topics
Resources
License
Releases
Packages 0
Contributors 2
Languages
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Источник
Registering and using a custom java.net.URL protocol
I was trying to invoke a custom url from my java program, hence I used something like this:
I got the below exception:
java.net.MalformedURLException: unknown protocol: CustomURI at java.net.URL.(Unknown Source) at java.net.URL.(Unknown Source) at java.net.URL.(Unknown Source) at com.demo.TestDemo.main(TestDemo.java:14)
If I trigger the URI from a browser then it works as expected but if I try to invoke it from the Java Program then I am getting the above exception.
EDIT:
Below are the steps I tried (I am missing something for sure, please let me know on that):
Step 1: Adding the Custom URI in java.protocol.handler.pkgs
Step 2: Triggering the Custom URI from URL
Code:
When I run this code, I am getting the CustomURI: printed in my console (from the add method) but then I am getting this exception when the URL is initialized with CustomURI: as a constructor:
Please advice how to make this work.
3 Answers 3
Create a custom URLConnection implementation which performs the job in connect() method.
Don’t forget to override and implement other methods like getInputStream() accordingly. More detail on that cannot be given as this information is missing in the question.
Create a custom URLStreamHandler implementation which returns it in openConnection() .
Don’t forget to override and implement other methods if necessary.
Create a custom URLStreamHandlerFactory which creates and returns it based on the protocol.
Note that protocols are always lowercase.
Finally register it during application’s startup via URL#setURLStreamHandlerFactory()
Note that the Javadoc explicitly says that you can set it at most once. So if you intend to support multiple custom protocols in the same application, you’d need to generify the custom URLStreamHandlerFactory implementation to cover them all inside the createURLStreamHandler() method.
Alternatively, if you dislike the Law of Demeter, throw it all together in anonymous classes for code minification:
If you’re on Java 8 already, replace the URLStreamHandlerFactory functional interface by a lambda for further minification:
Now you can use it as follows:
Or with lowercased protocol as per the spec:
If you don’t want to take over the one-and-only URLStreamHandlerFactory, you can actually use a hideous, but effective naming convention to get in on the default implementation.
You must name your URLStreamHandler class Handler , and the protocol it maps to is the last segment of that class’ package.
So, com.foo.myproto.Handler -> myproto:urls , provided you add your package com.foo to the list of «url stream source packages» for lookup on unknown protocol. You do this via system property «java.protocol.handler.pkgs» (which is a | delimited list of package names to search).
Here is an abstract class that performs what you need: (don’t mind the missing StringTo > or StringURLConnection , these do what their names suggest and you can use whatever abstractions you prefer)
Then, here is the actual class implementing the abstract handler (for dynamic: urls:
You made a recursion/endless-loop.
The Classloader searching for the class in different ways.
The stacktrace (URLClassPath) is like this:
Источник
MobaXterm URL Protocol Handler Usage
I am wanting to deploy a series of MobaXterm connections (SSH connections) to our users and would like to look at creating a webpage where the users can simply invoke a chosen session by clicking on a link.
I can see that MobaXterm supports this by installing (installed by default) the URL Protocol Handler but I do not know and cannot find anywhere any syntax for the HTML links to invoke the named sessions.
Can anyone help or point me in the right direction to look please?
2 Answers 2
I found that this :
allowed me to open a session, but il also created a new ‘saved session’ and saturated my quota so I am not sure it is the real solution.
But a least it looks like ‘mobaxterm’ is the protocol, if it can help anybody ending up here. This feature sure lacks documentation 🙂
I e-mailed Mobatek with the same question. It turns out if you right-click the «User Sessions» node and pick «Generate HTML web page», it will make a web page containing mobaxterm: protocol links to all your existing sessions. It looks like it’s designed for exactly your use case, making a webpage to share with other users, so you may be able to just use that generated page as-is.
If you do want to generate your own links, it’s a little trickier. I haven’t really tried to understand the encoding yet; it’s definitely not designed to be particularly user-readable, but since you can make any session you want and export it to a link it shouldn’t be too hard to reverse-engineer the fields you care about.
Источник