- final OsAuthenticationToken authen = (OsAuthenticationToken) super
- .authenticate(authentication);
- try {
- // WARNING: at this stage we assume that the java properties
- // will have the same value
- String username = System.getProperty("user.name");
- Node userProfile = JcrUtils.createUserProfileIfNeeded(
- securitySession, username);
- JcrUserDetails.checkAccountStatus(userProfile);
-
- // each user should have a writable area in the default workspace of
- // the node
- Node userNodeHome = JcrUtils.createUserHomeIfNeeded(nodeSession,
- username);
- // FIXME how to set user home privileges *before* it is created ?
- // JcrUtils.addPrivilege(nodeSession, userNodeHome.getPath(),
- // username, Privilege.JCR_ALL);
- // if (nodeSession.hasPendingChanges())
- // nodeSession.save();
-
- // user details
- JcrUserDetails userDetails = new JcrUserDetails(userProfile, authen
- .getCredentials().toString(), getBaseAuthorities());
+ if (authentication instanceof UsernamePasswordAuthenticationToken) {
+ // deal with remote access to internal server
+ // FIXME very primitive and unsecure at this sSession adminSession
+ // =tage
+ // consider using the keyring for username / password authentication
+ // or certificate
+ UsernamePasswordAuthenticationToken upat = (UsernamePasswordAuthenticationToken) authentication;
+ if (!upat.getPrincipal().toString().equals(JVM_OSUSER))
+ throw new BadCredentialsException("Wrong credentials");
+ UsernamePasswordAuthenticationToken authen = new UsernamePasswordAuthenticationToken(
+ authentication.getPrincipal(),
+ authentication.getCredentials(), getBaseAuthorities());