use of org.eclipse.kapua.service.user.UserService in project kapua by eclipse.
the class GwtUserServiceImpl method find.
public GwtUser find(String accountId, String userIdString) throws GwtKapuaException {
KapuaId scopeId = KapuaEid.parseShortId(accountId);
KapuaId userId = KapuaEid.parseShortId(userIdString);
GwtUser gwtUser = null;
try {
KapuaLocator locator = KapuaLocator.getInstance();
UserService userService = locator.getService(UserService.class);
User user = userService.find(scopeId, userId);
if (user != null) {
gwtUser = KapuaGwtConverter.convert(user);
}
} catch (Throwable t) {
KapuaExceptionHandler.handle(t);
}
return gwtUser;
}
use of org.eclipse.kapua.service.user.UserService in project kapua by eclipse.
the class DeviceCommandManagementServiceTest method setUpTest.
@Ignore
@Before
public void setUpTest() throws Exception {
//
// User creation
String userName = String.format("test-usr-%d", (new Date()).getTime());
UserService userService = locator.getService(UserService.class);
UserFactory userFactory = locator.getFactory(UserFactory.class);
UserCreator userCreator = userFactory.newCreator(account.getId(), userName);
user = userService.create(userCreator);
//
// User permission creation
UserPermissionService userPermissionService = locator.getService(UserPermissionService.class);
UserPermissionFactory userPermissionFactory = locator.getFactory(UserPermissionFactory.class);
UserPermissionCreator userPermissionCreator = userPermissionFactory.newCreator(account.getId());
PermissionFactory permissionFactory = locator.getFactory(PermissionFactory.class);
userPermissionCreator.setUserId(user.getId());
userPermissionCreator.setPermission(permissionFactory.newPermission(DeviceLifecycleDomain.DEVICE_LIFECYCLE, Actions.connect, account.getId()));
userPermissionService.create(userPermissionCreator);
//
// User credentials creation
CredentialService credentialService = locator.getService(CredentialService.class);
CredentialFactory credentialFactory = locator.getFactory(CredentialFactory.class);
CredentialCreator credentialCreator = credentialFactory.newCreator(account.getId(), user.getId(), CredentialType.PASSWORD, "kapua-password");
credentialService.create(credentialCreator);
}
Aggregations