Package aQute.bnd.url
Class BndAuthentication
- java.lang.Object
-
- aQute.bnd.url.DefaultURLConnectionHandler
-
- aQute.bnd.url.BndAuthentication
-
- All Implemented Interfaces:
Plugin
,RegistryPlugin
,URLConnectionHandler
,Report
,Reporter
public class BndAuthentication extends DefaultURLConnectionHandler
bnd has a builtin delegated authentication mechanism, seeSettings
. This URL Connection Handler plugin will use this information to add signing information to the URL.We add a
X_A_QUTE_AUTHORIZATION
header with a formatted string that contains the email of the user, the machine name (for documentation), the public key, and a signed date header (SHA1WithRSA). This information can be parameterized with the following plugin properties or the default settings can be used.MATCH
— URL matcheremail
— Email address of the account holderprivateKey
— Hex private RSA keypublicKey
— Hex public RSA keymachine
— Machine name (defaults to the internet name of this machine as returned by invokingInetAddress.getHostName()
on theInetAddress
returned byInetAddress.getLocalHost()
)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static interface
BndAuthentication.Config
-
Nested classes/interfaces inherited from interface aQute.service.reporter.Report
Report.Location
-
Nested classes/interfaces inherited from interface aQute.service.reporter.Reporter
Reporter.SetLocation
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
email
private static java.lang.String
EMAIL
private java.lang.String
identity
private static org.slf4j.Logger
logger
private java.lang.String
machine
private static java.lang.String
MACHINE
private static java.lang.String
PRIVATE_KEY
private java.security.PrivateKey
privateKey
private static java.lang.String
PUBLIC_KEY
private java.security.PublicKey
publicKey
private static java.lang.String
X_A_QUTE_AUTHORIZATION
-
Fields inherited from class aQute.bnd.url.DefaultURLConnectionHandler
registry
-
Fields inherited from interface aQute.bnd.service.url.URLConnectionHandler
MATCH
-
-
Constructor Summary
Constructors Constructor Description BndAuthentication()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
credentials(java.lang.String email, byte[] publicKey, byte[] privateKey)
void
handle(java.net.URLConnection connection)
Not doing anything is perfect okprivate void
init()
void
setProperties(java.util.Map<java.lang.String,java.lang.String> map)
Set the properties for this plugin.-
Methods inherited from class aQute.bnd.url.DefaultURLConnectionHandler
addMatcher, error, exception, getErrors, getLocation, getWarnings, isOk, isPedantic, matches, matches, progress, setRegistry, setReporter, trace, warning
-
-
-
-
Field Detail
-
logger
private static final org.slf4j.Logger logger
-
MACHINE
private static final java.lang.String MACHINE
- See Also:
- Constant Field Values
-
PRIVATE_KEY
private static final java.lang.String PRIVATE_KEY
- See Also:
- Constant Field Values
-
PUBLIC_KEY
private static final java.lang.String PUBLIC_KEY
- See Also:
- Constant Field Values
-
EMAIL
private static final java.lang.String EMAIL
- See Also:
- Constant Field Values
-
X_A_QUTE_AUTHORIZATION
private static final java.lang.String X_A_QUTE_AUTHORIZATION
- See Also:
- Constant Field Values
-
identity
private java.lang.String identity
-
email
private java.lang.String email
-
machine
private java.lang.String machine
-
privateKey
private java.security.PrivateKey privateKey
-
publicKey
private java.security.PublicKey publicKey
-
-
Method Detail
-
handle
public void handle(java.net.URLConnection connection) throws java.lang.Exception
Description copied from class:DefaultURLConnectionHandler
Not doing anything is perfect ok- Specified by:
handle
in interfaceURLConnectionHandler
- Overrides:
handle
in classDefaultURLConnectionHandler
- Parameters:
connection
- The connection to modify- Throws:
java.lang.Exception
-
init
private void init() throws java.net.UnknownHostException
- Throws:
java.net.UnknownHostException
-
setProperties
public void setProperties(java.util.Map<java.lang.String,java.lang.String> map) throws java.lang.Exception
Description copied from class:DefaultURLConnectionHandler
Set the properties for this plugin. Subclasses should call this method before they handle their own properties.- Specified by:
setProperties
in interfacePlugin
- Overrides:
setProperties
in classDefaultURLConnectionHandler
- Parameters:
map
- attributes and directives for this plugin's clause- Throws:
java.lang.Exception
-
credentials
private void credentials(java.lang.String email, byte[] publicKey, byte[] privateKey) throws java.security.spec.InvalidKeySpecException, java.security.NoSuchAlgorithmException
- Throws:
java.security.spec.InvalidKeySpecException
java.security.NoSuchAlgorithmException
-
-