@Override public SecurityContext build() { if (null == env) { env = SecurityEnvironment.builder(serverTime).build(); } if (null == ec) { ec = EndpointConfig.builder().build(); } return new SecurityContextImpl(this); }
/** * Provider has authenticated the request and created a service Subject. * * @param service Subject of requesting service (or client) * @return AuthenticationResponse with information filled */ public static AuthenticationResponse successService(Subject service) { return builder().status(SecurityStatus.SUCCESS).service(service).build(); }
/** * Construct a failed response with a throwable as a cause. * * @param message Descriptive message of what happened. This message is propagated to public API! * @param cause Throwable causing the failed authentication. This will be logged. It may reach user only in case of debug. * @return AuthenticationResponse with information filled */ public static AuthenticationResponse failed(String message, Throwable cause) { return builder().description(message).throwable(cause).status(SecurityStatus.FAILURE).build(); }
/** * Create a new subject for a principal. * If you want to configure additional details ({@link Grant Grants}, public and/or private credentials, additional * {@link Principal Principals}), please use fluent API {@link #builder()}. * * @param principal principal this subject represents * @return a new subject instance with the single principal */ public static Subject create(Principal principal) { return builder().principal(principal).build(); }
/** * Provider has authenticated the request and created a user Subject. * * @param subject Subject of the current user * @return AuthenticationResponse with information filled */ public static AuthenticationResponse success(Subject subject) { return builder().status(SecurityStatus.SUCCESS).user(subject).build(); }
/** * Create a response with these headers. Only needs additional headers (e.g. actual headers sent with * request will be existing headers + headers provided here). * * @param headers Headers to add to request to propagate identity (can also be used to delete headers, if the value list * is empty) * @return response correctly initialized */ public static OutboundSecurityResponse withHeaders(Map<String, List<String>> headers) { return builder().status(SecurityStatus.SUCCESS).requestHeaders(headers).build(); }
/** * Create a new security context with the defined id and all defaults. * * @param id id of this context * @return new security context */ public SecurityContext createContext(String id) { return contextBuilder(id).build(); }
/** * Build an instance of a security client. The client is immutable. * * @return client instance */ @Override public SecurityClient<T> build() { return factory.create(security, context, super.buildRequest(), super.providerName()); }
/** * Load this policy from config. See {@link CompositeProviderSelectionPolicy} for example. * * @param config configuration instance * @return function as expected by {@link Security.Builder#providerSelectionPolicy(Function)} */ public static Function<Providers, ProviderSelectionPolicy> create(Config config) { return builder().config(config).build(); }
/** * Synchronous complement to {@link #submit()}. * Timeout is now hardcoded to 1 minute. * * @return response of the current security operation * @throws SecurityException in case of timeout, interrupted call or exception during future processing */ default T get() { return SecurityResponse.get(submit()); }
/** * Construct a failed response with an explanatory message. * * @param message Descriptive message of what happened. This message is propagated to public API! * @return AuthenticationResponse with information filled */ public static AuthenticationResponse failed(String message) { return builder().description(message).status(SecurityStatus.FAILURE).build(); }