Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: Service
-
Labels:None
Description
The encryption mechanism breaks 3rd party code because it breaks the UserAdmin contract by implicitly encrypting values and, in case of String, even changing type into byte[]. The latter also happens when no encryption is used. For example, the second line below causes a ClassCastException because a byte[] is returned instead of the expected String.
> ((User) r).getCredentials().put("password", "secret");
> String pwd = (String) ((User) r).getCredentials().get("password");
From the spec I get that access to plain text credentials should be protected through a UserAdminPermission. Probably should leave encryption of persisted data to the storage provider or make it part of the spi.

Yes: that the value type is changed even when not using encryption is definitely a bug.
However if values should be encrypted I see no other way than to change the type - otherwise a getCredentials() call would have to return a String with non-ascii characters. Moving the encryption logic to the SPI would IMHO not change this behaviour.
The encryption feature is just something I saw in the Felix implementation of the UserAdmin service (https://github.com/apache/felix/tree/trunk/useradmin). It seemed a nice-to-have feature at that time, but I'm not so sure anymore.
The getCredentials() call is protected by the UserAdminPermission.GET_CREDENTIAL. Maybe encryption should be left out of this implementation at all, as a result leaving the responsibility to protect the value to the user.
WDYT?