private void deleteCredentialByAccountId(KapuaId scopeId, KapuaId accountId) throws KapuaException { KapuaLocator locator = KapuaLocator.getInstance(); CredentialFactory credentialFactory = locator.getFactory(CredentialFactory.class); CredentialQuery query = credentialFactory.newQuery(accountId); CredentialListResult credentialsToDelete = query(query); for (Credential c : credentialsToDelete.getItems()) { delete(c.getScopeId(), c.getId()); } }
private void deleteCredentialByAccountId(KapuaId scopeId, KapuaId accountId) throws KapuaException { KapuaLocator locator = KapuaLocator.getInstance(); CredentialFactory credentialFactory = locator.getFactory(CredentialFactory.class); CredentialQuery query = credentialFactory.newQuery(accountId); CredentialListResult credentialsToDelete = query(query); for (Credential c : credentialsToDelete.getItems()) { delete(c.getScopeId(), c.getId()); } }
private void deleteCredentialByUserId(KapuaId scopeId, KapuaId userId) throws KapuaException { KapuaLocator locator = KapuaLocator.getInstance(); CredentialFactory credentialFactory = locator.getFactory(CredentialFactory.class); CredentialQuery query = credentialFactory.newQuery(scopeId); query.setPredicate(new AttributePredicateImpl<>(CredentialAttributes.USER_ID, userId)); CredentialListResult credentialsToDelete = query(query); for (Credential c : credentialsToDelete.getItems()) { delete(c.getScopeId(), c.getId()); } }
private void deleteCredentialByUserId(KapuaId scopeId, KapuaId userId) throws KapuaException { KapuaLocator locator = KapuaLocator.getInstance(); CredentialFactory credentialFactory = locator.getFactory(CredentialFactory.class); CredentialQuery query = credentialFactory.newQuery(scopeId); query.setPredicate(new AttributePredicateImpl<>(CredentialAttributes.USER_ID, userId)); CredentialListResult credentialsToDelete = query(query); for (Credential c : credentialsToDelete.getItems()) { delete(c.getScopeId(), c.getId()); } }
@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(AuthenticationDomains.CREDENTIAL_DOMAIN, Actions.read, scopeId)); // // Build query CredentialQuery query = new CredentialQueryImpl(scopeId); QueryPredicate predicate = new AttributePredicateImpl<>(CredentialAttributes.USER_ID, userId); query.setPredicate(predicate); // // Query and return result return query(query); }
@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(AuthenticationDomains.CREDENTIAL_DOMAIN, Actions.read, scopeId)); // // Build query CredentialQuery query = new CredentialQueryImpl(scopeId); QueryPredicate predicate = new AttributePredicateImpl<>(CredentialAttributes.USER_ID, userId); query.setPredicate(predicate); // // Query and return result return query(query); }