/** * Validate that the client should be registered. * @param client */ private void validateClient(Client client) throws RegistrationException { Set<Contract> contracts = client.getContracts(); if (contracts.isEmpty()) { throw new NoContractFoundException(Messages.i18n.format("ESRegistry.NoContracts")); //$NON-NLS-1$ } for (Contract contract : contracts) { validateContract(contract); } }
/** * Validate that the client should be registered. * @param client */ private void validateClient(Client client) throws RegistrationException { Set<Contract> contracts = client.getContracts(); if (contracts.isEmpty()) { throw new NoContractFoundException(Messages.i18n.format("ESRegistry.NoContracts")); //$NON-NLS-1$ } for (Contract contract : contracts) { validateContract(contract); } }
/** * Validate that the client should be registered. * @param client * @param connection */ private void validateClient(Client client, Connection connection) throws RegistrationException { Set<Contract> contracts = client.getContracts(); if (contracts.isEmpty()) { throw new RegistrationException(Messages.i18n.format("JdbcRegistry.NoContracts")); //$NON-NLS-1$ } for (Contract contract : contracts) { validateContract(contract, connection); } }
/** * Validate that the client should be registered. * @param client * @param connection */ private void validateClient(Client client, Connection connection) throws RegistrationException { Set<Contract> contracts = client.getContracts(); if (contracts.isEmpty()) { throw new RegistrationException(Messages.i18n.format("JdbcRegistry.NoContracts")); //$NON-NLS-1$ } for (Contract contract : contracts) { validateContract(contract, connection); } }
@Override public void getClient(String organizationId, String clientId, String clientVersion, IAsyncResultHandler<Client> handler) { delegate.getClient(organizationId, clientId, clientVersion, result -> { if (result.isSuccess()) { Client client = result.getResult(); if (client != null) { for (Contract contract : client.getContracts()) { decryptPolicies(client.getOrganizationId(), client.getClientId(), client.getVersion(), EntityType.ClientApp, contract.getPolicies()); } } } handler.handle(result); }); }
@Override public void getClient(String organizationId, String clientId, String clientVersion, IAsyncResultHandler<Client> handler) { delegate.getClient(organizationId, clientId, clientVersion, result -> { if (result.isSuccess()) { Client client = result.getResult(); if (client != null) { for (Contract contract : client.getContracts()) { decryptPolicies(client.getOrganizationId(), client.getClientId(), client.getVersion(), EntityType.ClientApp, contract.getPolicies()); } } } handler.handle(result); }); }
/** * @see io.apiman.gateway.engine.IRegistry#getClient(java.lang.String, io.apiman.gateway.engine.async.IAsyncResultHandler) */ @Override public void getClient(String apiKey, IAsyncResultHandler<Client> handler) { delegate.getClient(apiKey, result -> { if (result.isSuccess()) { Client client = result.getResult(); if (client != null) { for (Contract contract : client.getContracts()) { decryptPolicies(client.getOrganizationId(), client.getClientId(), client.getVersion(), EntityType.ClientApp, contract.getPolicies()); } } } handler.handle(result); }); }
/** * @see io.apiman.gateway.engine.IRegistry#getClient(java.lang.String, io.apiman.gateway.engine.async.IAsyncResultHandler) */ @Override public void getClient(String apiKey, IAsyncResultHandler<Client> handler) { delegate.getClient(apiKey, result -> { if (result.isSuccess()) { Client client = result.getResult(); if (client != null) { for (Contract contract : client.getContracts()) { decryptPolicies(client.getOrganizationId(), client.getClientId(), client.getVersion(), EntityType.ClientApp, contract.getPolicies()); } } } handler.handle(result); }); }
/** * @see io.apiman.gateway.engine.IRegistry#registerClient(io.apiman.gateway.engine.beans.Client, io.apiman.gateway.engine.async.IAsyncResultHandler) */ @Override public void registerClient(Client client, IAsyncResultHandler<Void> handler) { Exception error = null; synchronized (mutex) { // Validate the client first - we need to be able to resolve all the contracts. for (Contract contract : client.getContracts()) { String apiIdx = getApiIndex(contract.getApiOrgId(), contract.getApiId(), contract.getApiVersion()); if (!getMap().containsKey(apiIdx)) { error = new ApiNotFoundException(Messages.i18n.format("InMemoryRegistry.ApiNotFoundInOrg", //$NON-NLS-1$ contract.getApiId(), contract.getApiOrgId())); break; } } if (error == null) { // Unregister the client (if it exists) unregisterClientInternal(client, true); // Now, register the client. String clientIdx = getClientIndex(client); getMap().put(clientIdx, client); getMap().put(client.getApiKey(), client); handler.handle(AsyncResultImpl.create((Void) null)); } else { handler.handle(AsyncResultImpl.create(error, Void.class)); } } }
/** * @see io.apiman.gateway.engine.IRegistry#registerClient(io.apiman.gateway.engine.beans.Client, io.apiman.gateway.engine.async.IAsyncResultHandler) */ @Override public void registerClient(Client client, IAsyncResultHandler<Void> handler) { Exception error = null; synchronized (mutex) { // Validate the client first - we need to be able to resolve all the contracts. for (Contract contract : client.getContracts()) { String apiIdx = getApiIndex(contract.getApiOrgId(), contract.getApiId(), contract.getApiVersion()); if (!getMap().containsKey(apiIdx)) { error = new ApiNotFoundException(Messages.i18n.format("InMemoryRegistry.ApiNotFoundInOrg", //$NON-NLS-1$ contract.getApiId(), contract.getApiOrgId())); break; } } if (error == null) { // Unregister the client (if it exists) unregisterClientInternal(client, true); // Now, register the client. String clientIdx = getClientIndex(client); getMap().put(clientIdx, client); getMap().put(client.getApiKey(), client); handler.handle(AsyncResultImpl.create((Void) null)); } else { handler.handle(AsyncResultImpl.create(error, Void.class)); } } }
handler.handle(AsyncResultImpl.create(error, ApiContract.class)); } else { Optional<Contract> matchedOpt = client.getContracts().stream() .filter(contract -> contract.matches(apiOrganizationId, apiId, apiVersion)) .findFirst();
handler.handle(AsyncResultImpl.create(error, ApiContract.class)); } else { Optional<Contract> matchedOpt = client.getContracts().stream() .filter(contract -> contract.matches(apiOrganizationId, apiId, apiVersion)) .findFirst();
/** * @see io.apiman.gateway.engine.IRegistry#registerClient(io.apiman.gateway.engine.beans.Client, io.apiman.gateway.engine.async.IAsyncResultHandler) */ @Override public void registerClient(Client client, IAsyncResultHandler<Void> handler) { Set<Contract> contracts = client.getContracts(); if (contracts != null) { for (Contract contract : contracts) { List<Policy> policies = contract.getPolicies(); encryptPolicies(client.getOrganizationId(), client.getClientId(), client.getVersion(), EntityType.ClientApp, policies); } } delegate.registerClient(client, handler); if (contracts != null) { for (Contract contract : contracts) { List<Policy> policies = contract.getPolicies(); decryptPolicies(client.getOrganizationId(), client.getClientId(), client.getVersion(), EntityType.ClientApp, policies); } } }
/** * @see io.apiman.gateway.engine.IRegistry#registerClient(io.apiman.gateway.engine.beans.Client, io.apiman.gateway.engine.async.IAsyncResultHandler) */ @Override public void registerClient(Client client, IAsyncResultHandler<Void> handler) { Set<Contract> contracts = client.getContracts(); if (contracts != null) { for (Contract contract : contracts) { List<Policy> policies = contract.getPolicies(); encryptPolicies(client.getOrganizationId(), client.getClientId(), client.getVersion(), EntityType.ClientApp, policies); } } delegate.registerClient(client, handler); if (contracts != null) { for (Contract contract : contracts) { List<Policy> policies = contract.getPolicies(); decryptPolicies(client.getOrganizationId(), client.getClientId(), client.getVersion(), EntityType.ClientApp, policies); } } }
for (Contract contract : client.getContracts()) { if (contract.matches(apiOrganizationId, apiId, apiVersion)) { matchedContract = contract;
for (Contract contract : client.getContracts()) { if (contract.matches(apiOrganizationId, apiId, apiVersion)) { matchedContract = contract;
for (Contract contract : client.getContracts()) { if (contract.matches(apiOrganizationId, apiId, apiVersion)) { matchedContract = contract;
for (Contract contract : client.getContracts()) { if (contract.matches(apiOrganizationId, apiId, apiVersion)) { matchedContract = contract;
for (Contract contract : client.getContracts()) { if (contract.matches(apiOrganizationId, apiId, apiVersion)) { matchedContract = contract;
for (Contract contract : client.getContracts()) { if (contract.matches(apiOrganizationId, apiId, apiVersion)) { matchedContract = contract;