|
|
|
@ -1,15 +1,17 @@ |
|
|
|
package samples.gae.users; |
|
|
|
package samples.gae.users; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.Collection; |
|
|
|
import com.google.appengine.api.datastore.DatastoreService; |
|
|
|
import java.util.EnumSet; |
|
|
|
import com.google.appengine.api.datastore.DatastoreServiceFactory; |
|
|
|
import java.util.Set; |
|
|
|
import com.google.appengine.api.datastore.Entity; |
|
|
|
|
|
|
|
import com.google.appengine.api.datastore.EntityNotFoundException; |
|
|
|
import com.google.appengine.api.datastore.*; |
|
|
|
import com.google.appengine.api.datastore.Key; |
|
|
|
|
|
|
|
import com.google.appengine.api.datastore.KeyFactory; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.security.core.GrantedAuthority; |
|
|
|
|
|
|
|
import samples.gae.security.AppRole; |
|
|
|
import samples.gae.security.AppRole; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* UserRegistry implementation which uses GAE's low-level Datastore APIs. |
|
|
|
* UserRegistry implementation which uses GAE's low-level Datastore APIs. |
|
|
|
* |
|
|
|
* |
|
|
|
@ -70,12 +72,12 @@ public class GaeDatastoreUserRegistry implements UserRegistry { |
|
|
|
user.setProperty(USER_SURNAME, newUser.getSurname()); |
|
|
|
user.setProperty(USER_SURNAME, newUser.getSurname()); |
|
|
|
user.setUnindexedProperty(USER_ENABLED, newUser.isEnabled()); |
|
|
|
user.setUnindexedProperty(USER_ENABLED, newUser.isEnabled()); |
|
|
|
|
|
|
|
|
|
|
|
Collection<? extends GrantedAuthority> roles = newUser.getAuthorities(); |
|
|
|
Collection<AppRole> roles = newUser.getAuthorities(); |
|
|
|
|
|
|
|
|
|
|
|
long binaryAuthorities = 0; |
|
|
|
long binaryAuthorities = 0; |
|
|
|
|
|
|
|
|
|
|
|
for (GrantedAuthority r : roles) { |
|
|
|
for (AppRole r : roles) { |
|
|
|
binaryAuthorities |= 1 << ((AppRole)r).getBit(); |
|
|
|
binaryAuthorities |= 1 << r.getBit(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
user.setUnindexedProperty(USER_AUTHORITIES, binaryAuthorities); |
|
|
|
user.setUnindexedProperty(USER_AUTHORITIES, binaryAuthorities); |
|
|
|
|