private void commonConst(Class<? extends IPResource> resourceClass, String resourceType, boolean isEmbedded, Collection<String> primaryKeyProperties, Collection<String> searchableProperties) { AssertTools.assertNotNull(resourceClass, "ResourceClass cannot be null"); AssertTools.assertNotNull(resourceType, "ResourceType cannot be null"); AssertTools.assertFalse(resourceType.isEmpty(), "ResourceType cannot be empty"); this.resourceClass = resourceClass; this.resourceType = resourceType; AssertTools.assertTrue(getterMethodByPropertyName.containsKey(propertyName), "The property " + propertyName + " does not exists");
@Override public Tuple2<Order, Dns01Challenge> challengeInit(String domainName) { AssertTools.assertNotNull(account, "You need to log in first"); Order order; try { order = account.newOrder() // .domains(domainName) // .create(); } catch (AcmeException e) { LOGGER.error("Could not ask for domain {}", domainName, e); throw new LetsencryptException("Could not ask for domain " + domainName, e); } // Get the DNS challenge Dns01Challenge challenge = null; List<String> availableChallenges = new ArrayList<>(); for (Authorization auth : order.getAuthorizations()) { auth.getChallenges().stream().map(it -> it.getType()).forEach(it -> availableChallenges.add(it)); challenge = auth.findChallenge(Dns01Challenge.TYPE); } if (challenge == null) { throw new LetsencryptException("DNS Challenge not found for " + domainName + " ; Available challenges are: [" + Joiner.on(", ").join(availableChallenges) + "]"); } return new Tuple2<>(order, challenge); }
@Override public void loadPlugins(CommonServicesContext commonServicesContext, InternalServicesContext internalServicesContext) { AssertTools.assertNull(availablePlugins, "Plugin service already loaded");
/** * Add tags to check and they must all be present on the item (AND). * * @param tags * the exact names or like with "%" wildcard * @return this */ public IPResourceQuery<T> tagAddAnd(String... tags) { tagsAnd.addAll(Arrays.asList(tags)); AssertTools.assertTrue(tagsOr.isEmpty(), "There can be only tags check as AND or OR, but not both at the same time"); return this; }
@Override public void challengeComplete(Dns01Challenge challenge) { AssertTools.assertNotNull(account, "You need to log in first"); // Trigger the challenge try { LOGGER.info("Triggering the challenge"); challenge.trigger(); } catch (AcmeException e) { LOGGER.error("Problem triggering the challenge", e); throw new LetsencryptException("Problem triggering the challenge: " + challenge.getError().getDetail(), e); } // Wait until completed while (challenge.getStatus() != Status.VALID) { if (challenge.getStatus() == Status.INVALID) { throw new LetsencryptException("The challenge failed: " + challenge.getError().getDetail()); } ThreadTools.sleep(5 * 1000); // 5 secs try { LOGGER.info("Updating the status"); challenge.update(); } catch (AcmeException e) { LOGGER.error("Problem updating the challenge status", e); throw new LetsencryptException("Problem updating the challenge status: " + challenge.getError().getDetail(), e); } LOGGER.info("Current status: {}", challenge.getStatus()); } }
@Override public void loadPlugins(CommonServicesContext commonServicesContext, InternalServicesContext internalServicesContext) { AssertTools.assertNull(availablePlugins, "Plugin service already loaded");
/** * Add tags to check and at least one must be present on the item (OR). * * @param tags * the exact names or like with "%" wildcard * @return this */ public IPResourceQuery<T> tagAddOr(String... tags) { tagsOr.addAll(Arrays.asList(tags)); AssertTools.assertTrue(tagsAnd.isEmpty(), "There can be only tags check as AND or OR, but not both at the same time"); return this; }
@Override public RSACertificate requestCertificate(Order order, byte[] certificateRequest) { AssertTools.assertNotNull(account, "You need to log in first");