/** * Get the value of the property with a given name converted to {@code boolean}. Returns {@code false} if the value is * not convertible. * * @param properties key-value map of properties. * @param name property name. * @return {@code boolean} property value or {@code false} if the property is not convertible. */ public static boolean isProperty(final Map<String, Object> properties, final String name) { return properties.containsKey(name) && isProperty(properties.get(name)); }
/** * Get the value of the property with a given name converted to {@code boolean}. Returns {@code false} if the value is * not convertible. * * @param properties key-value map of properties. * @param name property name. * @return {@code boolean} property value or {@code false} if the property is not convertible. */ public static boolean isProperty(final Map<String, Object> properties, final String name) { return properties.containsKey(name) && isProperty(properties.get(name)); }
/** * Determines whether the {@value MessageProperties#XML_SECURITY_DISABLE} property is disabled for this factory. * * @return {@code true} if the xml security is disabled for this factory, {@code false} otherwise. */ boolean isXmlSecurityDisabled() { return PropertiesHelper.isProperty(config.getProperty(MessageProperties.XML_SECURITY_DISABLE)); } }
/** * Create a new message body factory. * * @param configuration configuration. Optional - can be null. */ public MessageBodyFactory(Configuration configuration) { this.legacyProviderOrdering = configuration != null && PropertiesHelper.isProperty(configuration.getProperty(MessageProperties.LEGACY_WORKERS_ORDERING)); }
@Override public Boolean get() { return PropertiesHelper.isProperty(config.getProperty(MessageProperties.XML_FORMAT_OUTPUT)); } });
private boolean isValidateOnExecutableOverrideCheckDisabled() { return PropertiesHelper.isProperty( jaxRsConfig.getProperty(ServerProperties.BV_DISABLE_VALIDATE_ON_EXECUTABLE_OVERRIDE_CHECK)); } }
@Override public Boolean get() { return PropertiesHelper.isProperty(config.getProperty(MessageProperties.JAXB_PROCESS_XML_ROOT_ELEMENT)); } });
/** * Create a new message body factory. * * @param configuration configuration. Optional - can be null. */ public MessageBodyFactory(Configuration configuration) { this.legacyProviderOrdering = configuration != null && PropertiesHelper.isProperty(configuration.getProperty(MessageProperties.LEGACY_WORKERS_ORDERING)); }
@Override public boolean isProperty(final String name) { return PropertiesHelper.isProperty(getProperty(name)); }
@Override public boolean isProperty(final String name) { return PropertiesHelper.isProperty(getProperty(name)); }
@Override public boolean configure(FeatureContext context) { final boolean disabled = PropertiesHelper.isProperty(context.getConfiguration().getProperty(ServerProperties .WADL_FEATURE_DISABLE)); if (disabled) { return false; } context.register(WadlModelProcessor.class); context.register(new AbstractBinder() { @Override protected void configure() { bind(WadlApplicationContextImpl.class).to(WadlApplicationContext.class).in(Singleton.class); } }); return true; } }
@Override public boolean configure(FeatureContext context) { final boolean disabled = PropertiesHelper.isProperty(context.getConfiguration().getProperty(ServerProperties .WADL_FEATURE_DISABLE)); if (disabled) { return false; } context.register(WadlModelProcessor.class); context.register(new AbstractBinder() { @Override protected void configure() { bind(WadlApplicationContextImpl.class).to(WadlApplicationContext.class).in(Singleton.class); } }); return true; } }
@Override public ResourceModel processSubResource(ResourceModel resourceModel, Configuration configuration) { final boolean disabled = PropertiesHelper.isProperty(configuration.getProperty(ServerProperties.WADL_FEATURE_DISABLE)); if (disabled) { return resourceModel; } return ModelProcessorUtil.enhanceResourceModel(resourceModel, true, methodList, true).build(); } }
@Override public ResourceModel processSubResource(ResourceModel resourceModel, Configuration configuration) { final boolean disabled = PropertiesHelper.isProperty(configuration.getProperty(ServerProperties.WADL_FEATURE_DISABLE)); if (disabled) { return resourceModel; } return ModelProcessorUtil.enhanceResourceModel(resourceModel, true, methodList, true).build(); } }
@Override public boolean configure(final FeatureContext context) { final Configuration config = context.getConfiguration(); // Validation disabled? if (PropertiesHelper.isProperty(config.getProperty(ServerProperties.BV_FEATURE_DISABLE))) { return false; } context.register(new ValidationBinder()); // Set ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR to make sure no sendError is called on servlet container // when ServerProperties.BV_SEND_ERROR_IN_RESPONSE is enabled. if (PropertiesHelper.isProperty(config.getProperty(ServerProperties.BV_SEND_ERROR_IN_RESPONSE)) && config.getProperty(ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR) == null) { context.property(ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR, true); } return true; } }
private void validateHttpMethodAndEntity(final ClientRequest request) { boolean suppressExceptions; suppressExceptions = PropertiesHelper.isProperty( request.getConfiguration().getProperty(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION)); final Object shcvProperty = request.getProperty(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION); if (shcvProperty != null) { // override global configuration with request-specific suppressExceptions = PropertiesHelper.isProperty(shcvProperty); } final String method = request.getMethod(); final EntityPresence entityPresence = METHODS.get(method.toUpperCase()); if (entityPresence == EntityPresence.MUST_BE_NULL && request.hasEntity()) { if (suppressExceptions) { LOGGER.warning(LocalizationMessages.ERROR_HTTP_METHOD_ENTITY_NOT_NULL(method)); } else { throw new IllegalStateException(LocalizationMessages.ERROR_HTTP_METHOD_ENTITY_NOT_NULL(method)); } } else if (entityPresence == EntityPresence.MUST_BE_PRESENT && !request.hasEntity()) { if (suppressExceptions) { LOGGER.warning(LocalizationMessages.ERROR_HTTP_METHOD_ENTITY_NULL(method)); } else { throw new IllegalStateException(LocalizationMessages.ERROR_HTTP_METHOD_ENTITY_NULL(method)); } } }
private void validateHttpMethodAndEntity(final ClientRequest request) { boolean suppressExceptions; suppressExceptions = PropertiesHelper.isProperty( request.getConfiguration().getProperty(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION)); final Object shcvProperty = request.getProperty(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION); if (shcvProperty != null) { // override global configuration with request-specific suppressExceptions = PropertiesHelper.isProperty(shcvProperty); } final String method = request.getMethod(); final EntityPresence entityPresence = METHODS.get(method.toUpperCase()); if (entityPresence == EntityPresence.MUST_BE_NULL && request.hasEntity()) { if (suppressExceptions) { LOGGER.warning(LocalizationMessages.ERROR_HTTP_METHOD_ENTITY_NOT_NULL(method)); } else { throw new IllegalStateException(LocalizationMessages.ERROR_HTTP_METHOD_ENTITY_NOT_NULL(method)); } } else if (entityPresence == EntityPresence.MUST_BE_PRESENT && !request.hasEntity()) { if (suppressExceptions) { LOGGER.warning(LocalizationMessages.ERROR_HTTP_METHOD_ENTITY_NULL(method)); } else { throw new IllegalStateException(LocalizationMessages.ERROR_HTTP_METHOD_ENTITY_NULL(method)); } } }
@Override public ResourceModel processResourceModel(final ResourceModel resourceModel, final Configuration configuration) { final boolean disabled = PropertiesHelper.isProperty(configuration.getProperty(ServerProperties.WADL_FEATURE_DISABLE)); if (disabled) { return resourceModel; } final ResourceModel.Builder builder = ModelProcessorUtil.enhanceResourceModel(resourceModel, false, methodList, true); // Do not add WadlResource if already present in the classes (i.e. added during scanning). if (!configuration.getClasses().contains(WadlResource.class)) { final Resource wadlResource = Resource.builder(WadlResource.class).build(); builder.addResource(wadlResource); } return builder.build(); }
@Override public ResourceModel processResourceModel(final ResourceModel resourceModel, final Configuration configuration) { final boolean disabled = PropertiesHelper.isProperty(configuration.getProperty(ServerProperties.WADL_FEATURE_DISABLE)); if (disabled) { return resourceModel; } final ResourceModel.Builder builder = ModelProcessorUtil.enhanceResourceModel(resourceModel, false, methodList, true); // Do not add WadlResource if already present in the classes (i.e. added during scanning). if (!configuration.getClasses().contains(WadlResource.class)) { final Resource wadlResource = Resource.builder(WadlResource.class).build(); builder.addResource(wadlResource); } return builder.build(); }
/** * Create a new filter. * @param rc Resource config. */ @Inject public OAuth1ServerFilter(Configuration rc) { // establish supported OAuth protocol versions HashSet<String> v = new HashSet<String>(); v.add(null); v.add("1.0"); versions = Collections.unmodifiableSet(v); // optional initialization parameters (defaulted) String realm = OAuth1ServerProperties.getValue(rc.getProperties(), OAuth1ServerProperties.REALM, "default", String.class); /* Maximum age (in milliseconds) of timestamp to accept in incoming messages. */ int maxAge = OAuth1ServerProperties.getValue(rc.getProperties(), OAuth1ServerProperties.MAX_AGE, 300000); /* Average requests to process between nonce garbage collection passes. */ int gcPeriod = OAuth1ServerProperties.getValue(rc.getProperties(), OAuth1ServerProperties.GC_PERIOD, 100); ignorePathPattern = pattern( OAuth1ServerProperties.getValue(rc.getProperties(), OAuth1ServerProperties.IGNORE_PATH_PATTERN, null, String.class)); // no pattern optional = PropertiesHelper.isProperty(rc.getProperties(), OAuth1ServerProperties.NO_FAIL); final String timeUnitStr = OAuth1ServerProperties.getValue(rc.getProperties(), OAuth1ServerProperties.TIMESTAMP_UNIT, String.class); final TimeUnit timeUnit = timeUnitStr != null ? TimeUnit.valueOf(timeUnitStr) : TimeUnit.SECONDS; final int maxCacheSize = OAuth1ServerProperties.getValue(rc.getProperties(), OAuth1ServerProperties.MAX_NONCE_CACHE_SIZE, 2000000); nonces = new NonceManager(maxAge, gcPeriod, timeUnit, maxCacheSize); // www-authenticate header for the life of the object wwwAuthenticateHeader = "OAuth realm=\"" + realm + "\""; }