private PublicKey getPublicKey(ClientSync request) throws GeneralSecurityException { PublicKey endpointKey = null; if (request.getProfileSync() != null && request.getProfileSync().getEndpointPublicKey() != null) { byte[] publicKeySrc = request.getProfileSync().getEndpointPublicKey().array(); endpointKey = KeyUtil.getPublic(publicKeySrc); } if (endpointKey == null) { EndpointObjectHash hash = getEndpointObjectHash(request); endpointKey = cacheService.getEndpointKey(hash); } return endpointKey; }
/** * Return true if client sync information is valid or false if not. * * @return true if valid, false if not */ public boolean isValid() { ClientSyncMetaData md = this.getClientSyncMetaData(); // TODO: validate if public key hash matches hash of public key during // profile registration command. if (md.getProfileHash() == null) { ProfileClientSync profileRequest = this.getProfileSync(); if (profileRequest == null || profileRequest.getEndpointPublicKey() == null) { return false; } } return true; }
private EndpointProfileDto registerEndpoint(String endpointId, int requestHash, ClientSyncMetaData metaData, ProfileClientSync request) { LOG.debug("[{}][{}] register endpoint. request: {}", endpointId, requestHash, request); byte[] endpointKey = toByteArray(request.getEndpointPublicKey()); byte[] profileBody = toByteArray(request.getProfileBody()); RegisterProfileRequest registerProfileRequest = new RegisterProfileRequest( metaData.getApplicationToken(), endpointKey, metaData.getSdkToken(), profileBody, request.getEndpointAccessToken()); EndpointProfileDto endpointProfile = profileService.registerProfile(registerProfileRequest); LOG.debug("profile registered. id: {}, endpointKeyHash: {}", endpointProfile.getId(), endpointProfile.getEndpointKeyHash()); return endpointProfile; }
if (profileSyncRequest != null) { ProfileServerSync profileSyncResponse; if (profileSyncRequest.getEndpointPublicKey() != null) { LOG.debug("[{}][{}] registration of endpoint started.", context.getEndpointKey(), context.getRequestHash());