Ejemplo n.º 1
0
 protected void importHostPublicKey(String hostId, String publicKey, boolean rh) {
   KeyManager keyManager = securityManager.getKeyManager();
   keyManager.savePublicKeyRing(
       hostId,
       rh ? SecurityKeyType.RESOURCE_HOST_KEY.getId() : SecurityKeyType.CONTAINER_HOST_KEY.getId(),
       publicKey);
 }
Ejemplo n.º 2
0
  @Override
  public ContainerToken verifyToken(final String token, String containerHostId, String publicKey)
      throws HostRegistrationException {

    ContainerTokenImpl containerToken = containerTokenDataService.find(token);

    if (containerToken == null) {
      throw new HostRegistrationException("Couldn't verify container token");
    }

    if (containerToken.getDateCreated().getTime() + containerToken.getTtl()
        < System.currentTimeMillis()) {
      throw new HostRegistrationException("Container token expired");
    }

    try {
      securityManager
          .getKeyManager()
          .savePublicKeyRing(
              containerHostId, SecurityKeyType.CONTAINER_HOST_KEY.getId(), publicKey);
    } catch (Exception e) {
      LOG.error("Error verifying token", e);

      throw new HostRegistrationException("Failed to store container pubkey", e);
    }

    return containerToken;
  }