felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard S. Hall" <he...@ungoverned.org>
Subject Re: Password protected OBR?
Date Tue, 29 Jul 2008 14:55:18 GMT
Interesting. You should attach all code patches to a Felix JIRA issue 
for consideration for inclusion:

    http://cwiki.apache.org/FELIX/issue-tracking.html

If people think this would be a useful addition, it is likely we could 
include it. Make sure to tick the "grant" box when you fill out the JIRA 
issue.

Thanks.

-> richard

Remco Poortinga wrote:
> Hello,
>
> Not sure if this is already possible (or indeed wanted), but I couldn't
> find anything on the web or the mail archives about this.
>
> For a project I would like to configure a 'private' OBR (somewhat
> against the federated idea of OBR I guess, but anyway). In other words:
> username/password protected access. Https OBR are possible, but I have
> no idea if there is an 'official' way (from Felix' point of view) for
> specifying credentials for the specified OBR URLs.
>
> Just to see whether it would work I created a test version where
> username/password can be specified in a RFC1738 compliant way, e.g.
> https://user:password@server:port/rest and added an Authenticator to the
> bundlerepository bundle, which gets the username/password from the URL
> if it is set (see
> http://java.sun.com/javase/6/docs/api/java/net/URL.html#getUserInfo()).
>
> This seems to work OK; would this be interesting for others as well?
>
> Only changes:
>
> Add the following line to
> org.apache.felix.bundlerepository.Activator.start():
>
> Authenticator.setDefault(new UrlEmbeddedCredentialsAuthenticator());
>
> Add this UrlEmbeddedCredentialsAuthenticator to the same package:
>
> /**
>  *
>  */
> package org.apache.felix.bundlerepository;
>
> import java.net.Authenticator;
> import java.net.PasswordAuthentication;
>
> /**
>  * @author Remco Poortinga
>  *
>  */
> public class UrlEmbeddedCredentialsAuthenticator extends Authenticator {
> 	protected PasswordAuthentication getPasswordAuthentication() {
> 		// See if something is encoded in the URL
> 		String userInfo = getRequestingURL().getUserInfo();
> 		if ((userInfo != null) && (userInfo.indexOf(':') > 0)) {
> 			String userName = userInfo.substring(0,
> userInfo.indexOf(':'));
> 			String password =
> userInfo.substring(userInfo.indexOf(':')+1);
> 			return new PasswordAuthentication(userName,
> password.toCharArray());
> 		}
>
> 		return null;
> 	}
> }
>
>
> Best regards,
>
> Remco
>
>
> Remco Poortinga - van Wijnen
> Senior Application Engineer / Software Architect
>
> Telematica Instituut
> The Netherlands
> www.telin.nl
> ------------------------------------
> An expert is a person who avoids the small errors as he sweeps on to the
> grand fallacy.
>   -- Benjamin Stolberg
>
>   

Mime
View raw message