public static void validateModules(List<String> moduleNames) { var invalidModules = moduleNames.stream() .filter(module -> JavaFXModule.fromModuleName(module).isEmpty()) .collect(Collectors.toList()); if (! invalidModules.isEmpty()) { throw new GradleException("Found one or more invalid JavaFX module names: " + invalidModules); } }
@Override protected String extractPrincipalId(final Credential credential, final Optional<Principal> currentPrincipal) { LOGGER.debug("Attempting to extract principal id for principal [{}]", currentPrincipal); if (!credential.getClass().equals(SurrogateUsernamePasswordCredential.class)) { LOGGER.trace("Provided credential is not one of [{}]", SurrogateUsernamePasswordCredential.class.getName()); return super.extractPrincipalId(credential, currentPrincipal); } if (currentPrincipal.isEmpty()) { throw new IllegalArgumentException("Current principal resolved cannot be null"); } val id = currentPrincipal.get().getId(); LOGGER.debug("Resolving principal id for surrogate authentication as [{}]", id); return id; } }
/** * Gets authenticated profile. * * @param request the request * @param response the response * @return the authenticated profile */ protected CommonProfile getAuthenticatedProfile(final HttpServletRequest request, final HttpServletResponse response) { val manager = Pac4jUtils.getPac4jProfileManager(request, response); val profile = (Optional<CommonProfile>) manager.get(true); if (profile.isEmpty()) { throw new IllegalArgumentException("Unable to determine the user profile from the context"); } return profile.get(); }
protected abstract void send(Message message, Deferred<Message, Exception> deferred);
/** Returns the subset of nodes that are parents */ public NodeList parents() { return filter(n -> n.parentHostname().isEmpty()); }
@Override public boolean isExpired(final TicketState ticketState) { val match = getExpirationPolicyFor(ticketState); if (match.isEmpty()) { LOGGER.warn("No expiration policy was found for ticket state [{}]. " + "Consider configuring a predicate that delegates to an expiration policy.", ticketState); return super.isExpired(ticketState); } val policy = match.get(); LOGGER.trace("Activating expiration policy [{}] for ticket [{}]", policy.getName(), ticketState); return policy.isExpired(ticketState); }
private void validateNamedOrQualifierAnnotationPresent(Field field, Class<?> serviceType) { if(getNamedOrQualifierValue(field).isEmpty() || !getNamedOrQualifierValue(field).orElseThrow().equals(serviceListFactoryBeanName(serviceType))) { LOGGER.log(ERROR, "Injecting a list of " + serviceType.getName() + " requires a Qualifier or Named annotation with value " + serviceListFactoryBeanName(serviceType)); throw new IllegalStateException("Injecting a list of " + serviceType.getName() + " requires a Qualifier or Named annotation with value " + serviceListFactoryBeanName(serviceType)); } }
@Override protected boolean isCaseInsensitive(final JdbcEnvironment jdbcEnvironment) { val propsResult = ApplicationContextProvider.getCasProperties(); if (propsResult.isEmpty()) { LOGGER.error("Could not load configuration settings to determine case insensitivity."); return super.isCaseInsensitive(jdbcEnvironment); } val casProperties = propsResult.get(); return casProperties.getJdbc().isCaseInsensitive(); } }
@Override public final Promise<Message, Exception> sendWithAck(@NonNull Message message) { if (message.getRoutingId().isEmpty()) { throw new IllegalArgumentException("Message must contain not-null routingId"); } Deferred<Message, Exception> deferred = createDeferred(); this.send(message, deferred); return deferred.promise(); } }
private void configureEncryptionParametersForEncoding() { if (httpsJkws.isEmpty()) { LOGGER.debug("No JWKS endpoint is defined. Configuration of encryption parameters and keys are skipped"); } else { try { val keys = this.httpsJkws.get().getJsonWebKeys(); val encKeyResult = findRsaJsonWebKey(keys, Predicates.alwaysTrue()); if (encKeyResult.isEmpty()) { throw new IllegalArgumentException("Could not locate RSA JSON web key from endpoint"); } val encKey = encKeyResult.get(); if (encKey.getPublicKey() == null) { throw new IllegalArgumentException("Public key located from endpoint for key id " + encKey.getKeyId() + " is undefined"); } setSecretKeyEncryptionKey(encKey.getPublicKey()); setContentEncryptionAlgorithmIdentifier(ContentEncryptionAlgorithmIdentifiers.AES_128_CBC_HMAC_SHA_256); setEncryptionAlgorithm(KeyManagementAlgorithmIdentifiers.RSA_OAEP_256); } catch (final Exception e) { throw new RuntimeException(e.getMessage(), e); } } }
/** * Checks the given ticketState and gets the timeToLive for the relevant expiration policy. * * @param ticketState The ticketState to get the delegated expiration policy for * @return The TTL for the relevant expiration policy */ @Override public Long getTimeToLive(final TicketState ticketState) { val match = getExpirationPolicyFor(ticketState); if (match.isEmpty()) { LOGGER.warn("No expiration policy was found for ticket state [{}]. " + "Consider configuring a predicate that delegates to an expiration policy.", ticketState); return super.getTimeToLive(ticketState); } val policy = match.get(); LOGGER.trace("Getting TTL from policy [{}] for ticket [{}]", policy.getName(), ticketState); return policy.getTimeToLive(ticketState); }
@Override public Pair<Boolean, Optional<MultifactorAuthenticationProvider>> validateAuthenticationContext(final Assertion assertion, final HttpServletRequest request) { LOGGER.debug("Locating the primary authentication associated with this service request [{}]", assertion.getService()); val registeredService = servicesManager.findServiceBy(assertion.getService()); val authentication = assertion.getPrimaryAuthentication(); val requestedContext = multifactorTriggerSelectionStrategy.resolve(request, registeredService, authentication, assertion.getService()); if (requestedContext.isEmpty()) { LOGGER.debug("No particular authentication context is required for this request"); return Pair.of(Boolean.TRUE, Optional.empty()); } return authenticationContextValidator.validate(authentication, requestedContext.get(), registeredService); } }
private void configureSigningParametersForDecoding() { val result = findRsaJsonWebKeyByProvidedKeyId(webKeySet.getJsonWebKeys()); if (result.isEmpty()) { throw new IllegalArgumentException("Could not locate RSA JSON web key from keystore"); } val key = result.get(); if (key.getPublicKey() == null) { throw new IllegalArgumentException("Public key located from keystore for key id " + key.getKeyId() + " is undefined"); } setSigningKey(key.getPublicKey()); }
private void configureSigningParametersForEncoding() { val result = findRsaJsonWebKeyByProvidedKeyId(webKeySet.getJsonWebKeys()); if (result.isEmpty()) { throw new IllegalArgumentException("Could not locate RSA JSON web key from keystore"); } val key = result.get(); if (key.getPrivateKey() == null) { throw new IllegalArgumentException("Private key located from keystore for key id " + key.getKeyId() + " is undefined"); } setSigningKey(key.getPrivateKey()); }
@Override protected String getExpirationPolicyNameFor(final TicketState ticketState) { val attrs = ticketState.getAuthentication().getAttributes(); val rememberMeRes = CollectionUtils.firstElement(attrs.get(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME)); if (rememberMeRes.isEmpty()) { return PolicyTypes.DEFAULT.name(); } val b = (Boolean) rememberMeRes.get(); if (b.equals(Boolean.FALSE)) { LOGGER.trace("Ticket is not associated with a remember-me authentication."); return PolicyTypes.DEFAULT.name(); } return PolicyTypes.REMEMBER_ME.name(); }
private static boolean shouldGenerateDeviceFlowResponse(final OAuth20AccessTokenResponseResult result) { val generatedToken = result.getGeneratedToken(); return OAuth20ResponseTypes.DEVICE_CODE == result.getResponseType() && generatedToken.getDeviceCode().isPresent() && generatedToken.getUserCode().isPresent() && generatedToken.getAccessToken().isEmpty(); }
@Override public void populateAttributes(final AuthenticationBuilder builder, final AuthenticationTransaction transaction) { val credential = transaction.getPrimaryCredential(); if (credential.isEmpty()) { throw new SurrogateAuthenticationException("The authentication transaction does not have a primary principal associated with it"); } val current = SurrogateUsernamePasswordCredential.class.cast(credential.get()); LOGGER.debug("Recording surrogate username [{}] as an authentication attribute", current.getSurrogateUsername()); builder.addAttribute(SurrogateAuthenticationService.AUTHENTICATION_ATTR_SURROGATE_USER, current.getSurrogateUsername()); builder.addAttribute(SurrogateAuthenticationService.AUTHENTICATION_ATTR_SURROGATE_PRINCIPAL, current.getId()); builder.addAttribute(SurrogateAuthenticationService.AUTHENTICATION_ATTR_SURROGATE_ENABLED, Boolean.TRUE.toString()); }
/** * check if payload not null, payload's id is empty, then set payload's id by * value generated from idGenerator if presented * * @param payload the payload */ protected void ensurePayloadId(Payload payload) { if (payload != null && payload.getId().isEmpty()) { payload.setId(context.getIdGenerator().generateId()); } }
@Override public boolean validate(final J2EContext context) { val request = context.getRequest(); val response = context.getResponse(); val grantType = request.getParameter(OAuth20Constants.GRANT_TYPE); if (!isGrantTypeSupported(grantType, OAuth20GrantTypes.values())) { LOGGER.warn("Grant type is not supported: [{}]", grantType); return false; } val manager = Pac4jUtils.getPac4jProfileManager(request, response); val profile = (Optional<CommonProfile>) manager.get(true); if (profile.isEmpty()) { LOGGER.warn("Could not locate authenticated profile for this request. Request is not authenticated"); return false; } val uProfile = profile.get(); return validateInternal(context, grantType, manager, uProfile); }
@Override public void visit(final FieldDeclaration field, final ConfigurationMetadataProperty property) { if (field.getVariables().isEmpty()) { throw new IllegalArgumentException("Field " + field + " has no variable definitions"); } val var = field.getVariable(0); if (field.getModifiers().contains(Modifier.STATIC)) { LOGGER.debug("Field [{}] is static and will be ignored for metadata generation", var.getNameAsString()); return; } if (field.getJavadoc().isEmpty()) { LOGGER.error("Field [{}] has no Javadoc defined", field); } val creator = new ConfigurationMetadataPropertyCreator(indexNameWithBrackets, properties, groups, parentClass); val prop = creator.createConfigurationProperty(field, property.getName()); processNestedClassOrInterfaceTypeIfNeeded(field, prop); }