use of org.eclipse.kapua.service.authentication.credential.CredentialQuery in project kapua by eclipse.
the class CredentialServiceImpl method findByUserId.
@Override
public CredentialListResult findByUserId(KapuaId scopeId, KapuaId userId) throws KapuaException {
//
// Argument Validation
ArgumentValidator.notNull(scopeId, "scopeId");
ArgumentValidator.notNull(userId, "userId");
//
// Check Access
KapuaLocator locator = KapuaLocator.getInstance();
AuthorizationService authorizationService = locator.getService(AuthorizationService.class);
PermissionFactory permissionFactory = locator.getFactory(PermissionFactory.class);
authorizationService.checkPermission(permissionFactory.newPermission(CredentialDomain.CREDENTIAL, Actions.read, scopeId));
//
// Build query
CredentialQuery query = new CredentialQueryImpl(scopeId);
KapuaPredicate predicate = new AttributePredicate<KapuaId>(CredentialPredicates.USER_ID, userId);
query.setPredicate(predicate);
// Query and return result
return query(query);
}
Aggregations