@Override public Collection<Class<? extends Annotation>> supportedAnnotations() { //Order of the annotations matters because of annotation handling. return CollectionsHelper.listOf(RolesAllowed.class, Roles.class, RolesContainer.class, PermitAll.class, DenyAll.class); }
/** * Keys expected in configuration. This may be used in integrations that can * be fully configured through a file (e.g. integration with web server). * This is a configuration of a specific resource access (e.g. GET on /my/resource) and * is to be used by this provider to evaluate security. * * @return name of the configuration key or empty (default) * @see EndpointConfig#config(String) */ default Collection<String> supportedConfigKeys() { return CollectionsHelper.setOf(); }
@Override public Map<Class<?>, Function<Config, ?>> mappers() { return CollectionsHelper.mapOf(); }
private static OutboundSecurityResponse toBasicAuthOutbound(UserStore.User user) { String b64 = Base64.getEncoder() .encodeToString((user.login() + ":" + new String(user.password())).getBytes(StandardCharsets.UTF_8)); String basicAuthB64 = "basic " + b64; return OutboundSecurityResponse .withHeaders(CollectionsHelper.mapOf("Authorization", CollectionsHelper.listOf(basicAuthB64))); }
.start(); Set<String> rolesSet = rolesAllowed.orElse(CollectionsHelper.setOf()); abortRequest(res, null, Http.Status.FORBIDDEN_403.code(), CollectionsHelper.mapOf()); future.complete(AtxResult.STOP); atzSpan.finish(); abortRequest(res, null, Http.Status.FORBIDDEN_403.code(), CollectionsHelper.mapOf()); future.complete(AtxResult.STOP); atzSpan.finish(); abortRequest(res, response, defaultStatus, CollectionsHelper.mapOf()); future.complete(AtxResult.STOP); return; case FAILURE: atzSpan.finish(); abortRequest(res, response, Http.Status.FORBIDDEN_403.code(), CollectionsHelper.mapOf()); future.complete(AtxResult.STOP); return;
private boolean atnAbstainFailure(ServerResponse res, CompletableFuture<AtxResult> future, AuthenticationResponse response) { if (authenticationOptional.orElse(false)) { LOGGER.finest("Authentication failed, but was optional, so assuming anonymous"); return false; } abortRequest(res, response, Http.Status.UNAUTHORIZED_401.code(), CollectionsHelper.mapOf(Http.Header.WWW_AUTHENTICATE, CollectionsHelper.listOf("Basic realm=\"Security Realm\""))); future.complete(AtxResult.STOP); return true; }
.start(); Set<String> rolesSet = rolesAllowed.orElse(CollectionsHelper.setOf()); abortRequest(res, null, Http.Status.FORBIDDEN_403.code(), CollectionsHelper.mapOf()); future.complete(AtxResult.STOP); atzSpan.finish(); abortRequest(res, null, Http.Status.FORBIDDEN_403.code(), CollectionsHelper.mapOf()); future.complete(AtxResult.STOP); atzSpan.finish(); abortRequest(res, response, defaultStatus, CollectionsHelper.mapOf()); future.complete(AtxResult.STOP); return; case FAILURE: atzSpan.finish(); abortRequest(res, response, Http.Status.FORBIDDEN_403.code(), CollectionsHelper.mapOf()); future.complete(AtxResult.STOP); return;
/** * Add a single-value header. Note that if method {@link #requestHeaders(Map)} is called after * this method, it will remove changes by this method. * * @param header header name * @param value header value * @return this instance */ public T requestHeader(String header, String value) { requestHeaders.put(header, CollectionsHelper.listOf(value)); return myInstance; }
/** * Provide extension annotations supported by this provider (e.g. {@code javax.annotation.security.RolesAllowed}). * Annotations will be collected according to framework in use. For JAX-RS, annotations from application class, resource * class and resource methods will be collected. * * @return Collection of annotations this provider expects. * @see EndpointConfig#annotations(EndpointConfig.AnnotationScope...) * @see EndpointConfig#combineAnnotations(Class, EndpointConfig.AnnotationScope...) */ default Collection<Class<? extends Annotation>> supportedAnnotations() { return CollectionsHelper.setOf(); }
@Override public Map<Class<?>, Function<Config, ?>> mappers() { return CollectionsHelper.mapOf(); }
/** * Add a single-value header. Note that if method {@link #headers(Map)} is called after * this method, it will remove changes by this method. * * @param header header name * @param value header value * @return this instance */ public Builder header(String header, String value) { this.headers.put(header, CollectionsHelper.listOf(value)); return this; }
/** * Class of the configuration type. * The provider may use a POJO implementing a {@link ProviderConfig} to * configure it. When configuring security, you user can provide an instance * of such a class to configure that provider. * * @return class of the type or empty (default) * @see EndpointConfig#instance(Class) */ default Collection<Class<? extends ProviderConfig>> supportedCustomObjects() { return CollectionsHelper.setOf(); }
@Override public Map<Class<?>, Function<Config, ?>> mappers() { return CollectionsHelper.mapOf(); }
/** * Add a single-value header. Note that if method {@link #responseHeaders(Map)} is called after * this method, it will remove changes by this method. * * @param header header name * @param value header value * @return this instance */ public T responseHeader(String header, String value) { responseHeaders.put(header, CollectionsHelper.listOf(value)); return myInstance; }
/** * A collection of attribute names expected by this provider to override endpoint * configuration. * * @return collection of supported attribute names * @see EndpointConfig#abacAttribute(String) */ default Collection<String> supportedAttributes() { return CollectionsHelper.setOf(); }
/** * Returns a map of mapper functions associated with appropriate target type ({@code GenericType<?>}. * <p> * Mappers will by automatically registered by {@link Config.Builder} during * bootstrapping of {@link Config} unless * {@link Config.Builder#disableMapperServices() disableld}. * * @return a map of config mapper functions, never {@code null}, though this may return an empty map if * {@link #mapper(Class)} is used instead */ default Map<GenericType<?>, BiFunction<Config, ConfigMapper, ?>> genericTypeMappers() { return CollectionsHelper.mapOf(); }
/** * Get all grants of a specific type determined by type's name. * * @param grantType type of grant (e.g. "role" or "scope") * @return list of grants of the specific type associated with this subject (may be empty) */ public List<Grant> grantsByType(String grantType) { return Collections.unmodifiableList(grantsByType.getOrDefault(grantType, CollectionsHelper.listOf())); }
/** * Get set of roles the user is in. * * @return roles of this user (or empty if not supported). */ default Collection<String> roles() { return CollectionsHelper.setOf(); } }