Java Code Examples for org.glassfish.jersey.server.model.Parameter#getAnnotation()

The following examples show how to use org.glassfish.jersey.server.model.Parameter#getAnnotation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RateLimitBundle.java    From ratelimitj with Apache License 2.0 5 votes vote down vote up
@Override
protected Factory<RequestRateLimiterFactory> createValueFactory(final Parameter parameter) {
    final RateLimiting annotation = parameter.getAnnotation(RateLimiting.class);
    if (null == annotation) {
        return null;
    } else {
        return new AbstractContainerRequestValueFactory<RequestRateLimiterFactory>() {
            @Override
            public RequestRateLimiterFactory provide() {
                return requestRateLimiterFactory;
            }
        };
    }
}
 
Example 2
Source File: RateLimit429EnforcerFilterTest.java    From ratelimitj with Apache License 2.0 5 votes vote down vote up
@Override
protected Factory<?> createValueFactory(final Parameter parameter) {
    final RateLimiting annotation = parameter.getAnnotation(RateLimiting.class);
    if (null == annotation) {
        return null;
    } else {
        return new AbstractContainerRequestValueFactory<RequestRateLimiterFactory>() {
            @Override
            public RequestRateLimiterFactory provide() {
                return requestRateLimiterFactory;
            }
        };
    }
}
 
Example 3
Source File: AuthResolver.java    From keywhiz with Apache License 2.0 5 votes vote down vote up
@Override protected Factory<?> createValueFactory(final Parameter parameter) {
  final Class<?> classType = parameter.getRawType();
  final Auth auth = parameter.getAnnotation(Auth.class);

  if (auth == null) {
    return null;
  }

  if (classType.equals(Client.class)) {
    return new AbstractContainerRequestValueFactory<Client>() {
      @Override public Client provide() {
        return clientAuthFactory.provide(getContainerRequest());
      }
    };
  }

  if (classType.equals(AutomationClient.class)) {
    return new AbstractContainerRequestValueFactory<AutomationClient>() {
      @Override public AutomationClient provide() {
        return automationClientAuthFactory.provide(getContainerRequest());
      }
    };
  }

  if (classType.equals(User.class)) {
    return new AbstractContainerRequestValueFactory<User>() {
      @Override public User provide() {
        return userAuthFactory.provide(getContainerRequest());
      }
    };
  }

  return null;
}
 
Example 4
Source File: AuthValueFactoryProvider.java    From dropwizard-simpleauth with Apache License 2.0 5 votes vote down vote up
@Override
public AbstractContainerRequestValueFactory<?> createValueFactory(final Parameter parameter) {
  if (parameter.getAnnotation(Auth.class) == null) {
    return null;
  }

  if (parameter.getRawType() == Optional.class) {
    return new OptionalContainerRequestValueFactory(parameter);
  } else {
    return new StandardContainerReqeustValueFactory(parameter);
  }
}
 
Example 5
Source File: SearchFactoryProvider.java    From robe with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected Factory<?> createValueFactory(Parameter parameter) {
    Class<?> paramType = parameter.getRawType();
    SearchParam annotation = parameter.getAnnotation(SearchParam.class);
    if (annotation != null && paramType.isAssignableFrom(SearchModel.class)) {
        return new SearchFactory();
    }
    return null;
}
 
Example 6
Source File: TokenFactoryProvider.java    From robe with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected Factory<?> createValueFactory(Parameter parameter) {
    Class<?> paramType = parameter.getRawType();
    RobeAuth annotation = parameter.getAnnotation(RobeAuth.class);
    if (annotation != null && paramType.isAssignableFrom(BasicToken.class)) {
        return new TokenFactory<>(annotation.required());
    }
    return null;
}
 
Example 7
Source File: PrincipalValueFactoryProvider.java    From jersey-hmac-auth with Apache License 2.0 5 votes vote down vote up
protected Factory<? extends P> createValueFactory(final Parameter parameter) {
    final HmacAuth auth = parameter.getAnnotation(HmacAuth.class);
    if (auth != null) {
        // TODO introduce type checking
        return getFactory();
    }
    return null;
}
 
Example 8
Source File: DSLContextValueParamProvider.java    From droptools with Apache License 2.0 5 votes vote down vote up
@Override
public Function<ContainerRequest, ?> getValueProvider(Parameter parameter) {
    final Class<?> classType = parameter.getRawType();
    final JooqInject jooqInjectParam = parameter.getAnnotation(JooqInject.class);

    return (classType == null || !classType.equals(DSLContext.class) || jooqInjectParam == null)
            ? null // return null when parameter not supported
            : (req) -> DSL.using(getConfiguration(jooqInjectParam.value()));
}
 
Example 9
Source File: SingularityAuthFactoryProvider.java    From Singularity with Apache License 2.0 5 votes vote down vote up
@Override
protected Factory<?> createValueFactory(Parameter parameter) {
  Class<?> paramType = parameter.getRawType();
  Auth annotation = parameter.getAnnotation(Auth.class);
  if (annotation != null && paramType.isAssignableFrom(SingularityUser.class)) {
    return authFactory;
  }
  return null;
}
 
Example 10
Source File: SessionHelperFactoryProvider.java    From commafeed with Apache License 2.0 5 votes vote down vote up
@Override
protected Factory<?> createValueFactory(final Parameter parameter) {
	final Class<?> classType = parameter.getRawType();

	Context context = parameter.getAnnotation(Context.class);
	if (context == null)
		return null;

	if (classType.isAssignableFrom(SessionHelper.class)) {
		return new SessionHelperFactory();
	} else {
		return null;
	}
}
 
Example 11
Source File: SecurityCheckFactoryProvider.java    From commafeed with Apache License 2.0 5 votes vote down vote up
@Override
protected Factory<?> createValueFactory(final Parameter parameter) {
	final Class<?> classType = parameter.getRawType();

	SecurityCheck securityCheck = parameter.getAnnotation(SecurityCheck.class);
	if (securityCheck == null)
		return null;

	if (classType.isAssignableFrom(User.class)) {
		return new SecurityCheckFactory(securityCheck.value(), securityCheck.apiKeyAllowed());
	} else {
		return null;
	}
}