Java Code Examples for org.glassfish.jersey.server.model.Parameter#isAnnotationPresent()
The following examples show how to use
org.glassfish.jersey.server.model.Parameter#isAnnotationPresent() .
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: FernetTokenValueParamProvider.java From fernet-java8 with Apache License 2.0 | 6 votes |
public Function<ContainerRequest, Token> getValueProvider(final Parameter parameter) { return request -> { if (parameter.getRawType().equals(Token.class) && parameter.isAnnotationPresent(FernetToken.class)) { final Token xAuthorizationToken = getTokenHeaderUtility().getXAuthorizationToken(request); if (xAuthorizationToken != null) { return xAuthorizationToken; } final Token authorizationToken = getTokenHeaderUtility().getAuthorizationToken(request); if (authorizationToken != null) { return authorizationToken; } throw new NotAuthorizedException("Bearer error=\"invalid_token\", error_description=\"no token found in Authorization or X-Authorization header\""); } throw new IllegalStateException("misconfigured annotation"); }; }
Example 2
Source File: FernetSecretValueParamProvider.java From fernet-java8 with Apache License 2.0 | 6 votes |
public Function<ContainerRequest, T> getValueProvider(final Parameter parameter) { return request -> { if (parameter.isAnnotationPresent(FernetSecret.class)) { final Collection<? extends Key> keys = getKeySupplier().get(); final Token xAuthorizationToken = getHeaderUtility().getXAuthorizationToken(request); if (xAuthorizationToken != null) { return getValidator().validateAndDecrypt(keys, xAuthorizationToken); } final Token authorizationToken = getHeaderUtility().getAuthorizationToken(request); if (authorizationToken != null) { return getValidator().validateAndDecrypt(keys, authorizationToken); } throw new NotAuthorizedException("Bearer error=\"invalid_token\", error_description=\"no token found in Authorization or X-Authorization header\""); } throw new IllegalStateException("misconfigured annotation"); }; }
Example 3
Source File: Pac4JValueFactoryProvider.java From jax-rs-pac4j with Apache License 2.0 | 5 votes |
@Override protected Factory<?> createValueFactory(Parameter parameter) { if (parameter.isAnnotationPresent(Pac4JProfileManager.class)) { if (ProfileManager.class.isAssignableFrom(parameter.getRawType())) { return manager.get(); } throw new IllegalStateException("Cannot inject a Pac4J profile manager into a parameter of type " + parameter.getRawType().getName()); } if (parameter.isAnnotationPresent(Pac4JProfile.class)) { if (CommonProfile.class.isAssignableFrom(parameter.getRawType())) { return profile.get(); } if (Optional.class.isAssignableFrom(parameter.getRawType())) { List<ClassTypePair> ctps = ReflectionHelper.getTypeArgumentAndClass(parameter.getRawType()); ClassTypePair ctp = (ctps.size() == 1) ? ctps.get(0) : null; if (ctp == null || CommonProfile.class.isAssignableFrom(ctp.rawClass())) { return optProfile.get(); } } throw new IllegalStateException( "Cannot inject a Pac4J profile into a parameter of type " + parameter.getRawType().getName()); } return null; }
Example 4
Source File: Pac4JValueFactoryProvider.java From jax-rs-pac4j with Apache License 2.0 | 5 votes |
@Override protected Function<ContainerRequest, ?> createValueProvider(Parameter parameter) { if (parameter.isAnnotationPresent(Pac4JProfileManager.class)) { if (ProfileManager.class.isAssignableFrom(parameter.getRawType())) { return manager.get(); } throw new IllegalStateException("Cannot inject a Pac4J profile manager into a parameter of type " + parameter.getRawType().getName()); } if (parameter.isAnnotationPresent(Pac4JProfile.class)) { if (CommonProfile.class.isAssignableFrom(parameter.getRawType())) { return profile.get(); } if (Optional.class.isAssignableFrom(parameter.getRawType())) { List<ClassTypePair> ctps = ReflectionHelper.getTypeArgumentAndClass(parameter.getRawType()); ClassTypePair ctp = (ctps.size() == 1) ? ctps.get(0) : null; if (ctp == null || CommonProfile.class.isAssignableFrom(ctp.rawClass())) { return optProfile.get(); } } throw new IllegalStateException( "Cannot inject a Pac4J profile into a parameter of type " + parameter.getRawType().getName()); } return null; }
Example 5
Source File: Pac4JValueFactoryProvider.java From jax-rs-pac4j with Apache License 2.0 | 5 votes |
@Override protected Function<ContainerRequest, ?> createValueProvider(Parameter parameter) { if (parameter.isAnnotationPresent(Pac4JProfileManager.class)) { if (ProfileManager.class.isAssignableFrom(parameter.getRawType())) { return manager.get(); } throw new IllegalStateException("Cannot inject a Pac4J profile manager into a parameter of type " + parameter.getRawType().getName()); } if (parameter.isAnnotationPresent(Pac4JProfile.class)) { if (CommonProfile.class.isAssignableFrom(parameter.getRawType())) { return profile.get(); } if (Optional.class.isAssignableFrom(parameter.getRawType())) { List<ClassTypePair> ctps = ReflectionHelper.getTypeArgumentAndClass(parameter.getRawType()); ClassTypePair ctp = (ctps.size() == 1) ? ctps.get(0) : null; if (ctp == null || CommonProfile.class.isAssignableFrom(ctp.rawClass())) { return optProfile.get(); } } throw new IllegalStateException( "Cannot inject a Pac4J profile into a parameter of type " + parameter.getRawType().getName()); } return null; }
Example 6
Source File: TypeFactory.java From shiro-jersey with Apache License 2.0 | 5 votes |
@Override public Factory<?> getValueFactory(Parameter parameter) { if (type.equals(parameter.getRawType()) && parameter.isAnnotationPresent(Auth.class)) { return this; } return null; }
Example 7
Source File: TypeFactory.java From shiro-jersey with Apache License 2.0 | 5 votes |
@Override public Factory<?> getValueFactory(Parameter parameter) { if (type.equals(parameter.getRawType()) && parameter.isAnnotationPresent(Auth.class)) { return this; } return null; }
Example 8
Source File: DummyAuth.java From dropwizard-experiment with MIT License | 5 votes |
@Override protected Factory<?> createValueFactory(Parameter parameter) { if (!parameter.isAnnotationPresent(Auth.class)) { return null; } return new AbstractContainerRequestValueFactory<Principal>() { public Principal provide() { return user; } }; }