Пример #1
0
  private SSLContext getSslContext(final Client client, final Configuration config) {
    final SslConfigurator sslConfigurator =
        PropertiesHelper.getValue(
            config.getProperties(), JettyClientProperties.SSL_CONFIG, SslConfigurator.class, null);

    return sslConfigurator != null ? sslConfigurator.createSSLContext() : client.getSslContext();
  }
  @Override
  public boolean configure(FeatureContext context) {
    if (oAuth1Provider != null) {
      context.register(oAuth1Provider);
    }

    context.register(OAuth1ServerFilter.class);

    if (!context.getConfiguration().isRegistered(OAuth1SignatureFeature.class)) {
      context.register(OAuth1SignatureFeature.class);
    }

    final Map<String, Object> properties = context.getConfiguration().getProperties();
    final Boolean propertyResourceEnabled =
        PropertiesHelper.getValue(
            properties, OAuth1ServerProperties.ENABLE_TOKEN_RESOURCES, null, Boolean.class);

    boolean registerResources =
        propertyResourceEnabled != null
            ? propertyResourceEnabled
            : requestTokenUri != null & accessTokenUri != null;

    if (registerResources) {
      String requestUri =
          PropertiesHelper.getValue(
              properties, OAuth1ServerProperties.REQUEST_TOKEN_URI, null, String.class);
      if (requestUri == null) {
        requestUri = requestTokenUri == null ? "requestToken" : requestTokenUri;
      }

      String accessUri =
          PropertiesHelper.getValue(
              properties, OAuth1ServerProperties.ACCESS_TOKEN_URI, null, String.class);
      if (accessUri == null) {
        accessUri = accessTokenUri == null ? "accessToken" : accessTokenUri;
      }

      final Resource requestResource =
          Resource.builder(RequestTokenResource.class).path(requestUri).build();
      final Resource accessResource =
          Resource.builder(AccessTokenResource.class).path(accessUri).build();

      context.register(new OAuthModelProcessor(requestResource, accessResource));
    }
    return true;
  }
Пример #3
0
 /**
  * Get the value of the specified property.
  *
  * <p>If the property is not set or the real value type is not compatible with the specified value
  * type, returns {@code defaultValue}.
  *
  * @param properties Map of properties to get the property value from.
  * @param runtime Runtime type which is used to check whether there is a property with the same
  *     {@code key} but post-fixed by runtime type (<tt>.server</tt> or {@code .client}) which
  *     would override the {@code key} property.
  * @param propertyName Name of the property.
  * @param defaultValue Default value if property is not registered
  * @param type Type to retrieve the value as.
  * @param <T> Type of the property value.
  * @return Value of the property or {@code null}.
  * @since 2.8
  */
 public static <T> T getValue(
     Map<String, ?> properties,
     RuntimeType runtime,
     String propertyName,
     T defaultValue,
     Class<T> type) {
   return PropertiesHelper.getValue(
       properties,
       runtime,
       propertyName,
       defaultValue,
       type,
       CommonProperties.LEGACY_FALLBACK_MAP);
 }
Пример #4
0
 /**
  * Get the value of the specified property.
  *
  * <p>If the property is not set or the real value type is not compatible with the specified value
  * type, returns {@code defaultValue}.
  *
  * @param properties Map of properties to get the property value from.
  * @param key Name of the property.
  * @param defaultValue Default value if property is not registered
  * @param type Type to retrieve the value as.
  * @param <T> Type of the property value.
  * @return Value of the property or {@code null}.
  * @since 2.8
  */
 public static <T> T getValue(
     Map<String, ?> properties, String key, T defaultValue, Class<T> type) {
   return PropertiesHelper.getValue(properties, key, defaultValue, type, null);
 }
Пример #5
0
 /**
  * Get the value of the specified property.
  *
  * <p>If the property is not set or the real value type is not compatible with {@code
  * defaultValue} type, the specified {@code defaultValue} is returned. Calling this method is
  * equivalent to calling {@code CommonProperties.getValue(properties, key, defaultValue,
  * (Class<T>) defaultValue.getClass())}
  *
  * @param properties Map of properties to get the property value from.
  * @param propertyName Name of the property.
  * @param defaultValue Default value if property is not registered
  * @param <T> Type of the property value.
  * @return Value of the property or {@code null}.
  * @since 2.8
  */
 public static <T> T getValue(Map<String, ?> properties, String propertyName, T defaultValue) {
   return PropertiesHelper.getValue(
       properties, propertyName, defaultValue, CommonProperties.LEGACY_FALLBACK_MAP);
 }
Пример #6
0
 public static Object getValue(Map<String, ?> properties, String propertyName, Class<?> type) {
   return PropertiesHelper.getValue(
       properties, propertyName, type, CommonProperties.LEGACY_FALLBACK_MAP);
 }