@Override public void initializeFromConfig(SecurityNamedServiceConfig config) throws IOException { super.initializeFromConfig(config); try { digest = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("No MD5 algorithm available!"); } aep = new BasicAuthenticationEntryPoint(); aep.setRealmName(GeoServerSecurityManager.REALM); try { aep.afterPropertiesSet(); } catch (Exception e) { throw new IOException(e); } BasicAuthenticationFilterConfig authConfig = (BasicAuthenticationFilterConfig) config; BasicAuthenticationFilter filter = new BasicAuthenticationFilter(getSecurityManager().authenticationManager(), aep); if (authConfig.isUseRememberMe()) { filter.setRememberMeServices(securityManager.getRememberMeService()); GeoServerWebAuthenticationDetailsSource s = new GeoServerWebAuthenticationDetailsSource(); filter.setAuthenticationDetailsSource(s); } filter.afterPropertiesSet(); getNestedFilters().add(filter); }
/** * Allows easily changing the realm, but leaving the remaining defaults in place. If * {@link #authenticationEntryPoint(AuthenticationEntryPoint)} has been invoked, * invoking this method will result in an error. * * @param realmName the HTTP Basic realm to use * @return {@link HttpBasicConfigurer} for additional customization * @throws Exception */ public HttpBasicConfigurer<B> realmName(String realmName) throws Exception { this.basicAuthEntryPoint.setRealmName(realmName); this.basicAuthEntryPoint.afterPropertiesSet(); return this; }
@SuppressWarnings("unchecked") private void registerDefaultAuthenticationEntryPoint(HttpSecurity http) { ExceptionHandlingConfigurer<HttpSecurity> exceptionHandling = http .getConfigurer(ExceptionHandlingConfigurer.class); if (exceptionHandling == null) { return; } if (authenticationEntryPoint==null) { BasicAuthenticationEntryPoint basicEntryPoint = new BasicAuthenticationEntryPoint(); basicEntryPoint.setRealmName(realm); authenticationEntryPoint = basicEntryPoint; } ContentNegotiationStrategy contentNegotiationStrategy = http.getSharedObject(ContentNegotiationStrategy.class); if (contentNegotiationStrategy == null) { contentNegotiationStrategy = new HeaderContentNegotiationStrategy(); } MediaTypeRequestMatcher preferredMatcher = new MediaTypeRequestMatcher(contentNegotiationStrategy, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_FORM_URLENCODED, MediaType.APPLICATION_JSON, MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_XML, MediaType.MULTIPART_FORM_DATA, MediaType.TEXT_XML); preferredMatcher.setIgnoredMediaTypes(Collections.singleton(MediaType.ALL)); exceptionHandling.defaultAuthenticationEntryPointFor(postProcess(authenticationEntryPoint), preferredMatcher); }
@Override public void afterPropertiesSet() throws Exception { setRealmName("Fediz"); super.afterPropertiesSet(); }
.anyRequest().authenticated() .and().anonymous().disable() .exceptionHandling().authenticationEntryPoint(new BasicAuthenticationEntryPoint() { @Override public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException, ServletException {
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException ex) throws IOException, ServletException { if (ex instanceof AuthenticationServiceException) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); response.flushBuffer(); } else { super.commence(request, response, ex); } }
public BasicAuthenticationEntryPoint getAuthenticationEntryPoint() { BasicAuthenticationEntryPoint basicAuthenticationEntryPoint = new BasicAuthenticationEntryPoint(); basicAuthenticationEntryPoint.setRealmName("atlas.com"); return basicAuthenticationEntryPoint; }
/** * Allows easily changing the realm, but leaving the remaining defaults in place. If * {@link #authenticationEntryPoint(AuthenticationEntryPoint)} has been invoked, * invoking this method will result in an error. * * @param realmName the HTTP Basic realm to use * @return {@link HttpBasicConfigurer} for additional customization * @throws Exception */ public HttpBasicConfigurer<B> realmName(String realmName) throws Exception { this.basicAuthEntryPoint.setRealmName(realmName); this.basicAuthEntryPoint.afterPropertiesSet(); return this; }
@Override public void afterPropertiesSet() throws Exception { setRealmName("Contact Big Data Infrastructure Team to get available accounts."); super.afterPropertiesSet(); }
@Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { final String requestedWithValue = request.getHeader("X-Requested-With"); if (requestedWithValue != null && requestedWithValue.equals("XMLHttpRequest")) { response.sendError(HttpServletResponse.SC_UNAUTHORIZED, authException.getMessage()); } else { super.commence(request, response, authException); } } }
/** * Shortcut for {@link #authenticationEntryPoint(AuthenticationEntryPoint)} * specifying a {@link BasicAuthenticationEntryPoint} with the specified * realm name. * * @param realmName * the HTTP Basic realm to use * @return {@link HttpBasicConfigurer} for additional customization * @throws Exception */ public HttpBasicConfigurer<B> realmName(String realmName) throws Exception { BasicAuthenticationEntryPoint basicAuthEntryPoint = new BasicAuthenticationEntryPoint(); basicAuthEntryPoint.setRealmName(realmName); basicAuthEntryPoint.afterPropertiesSet(); return authenticationEntryPoint(basicAuthEntryPoint); }
@Bean BasicAuthenticationEntryPoint basicAuthEntryPoint() { BasicAuthenticationEntryPoint bauth = new BasicAuthenticationEntryPoint(); bauth.setRealmName("GAURAVBYTES"); return bauth; }
/** * Allows easily changing the realm, but leaving the remaining defaults in place. If * {@link #authenticationEntryPoint(AuthenticationEntryPoint)} has been invoked, * invoking this method will result in an error. * * @param realmName the HTTP Basic realm to use * @return {@link HttpBasicConfigurer} for additional customization * @throws Exception */ public HttpBasicConfigurer<B> realmName(String realmName) throws Exception { this.basicAuthEntryPoint.setRealmName(realmName); this.basicAuthEntryPoint.afterPropertiesSet(); return this; }
@Override public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException, ServletException { response.addHeader(RESTHeaders.ERROR_INFO, authException.getMessage()); super.commence(request, response, authException); }
@Override public void initializeFromConfig(SecurityNamedServiceConfig config) throws IOException { super.initializeFromConfig(config); // anything to set here? maybe the cache config aep = new BasicAuthenticationEntryPoint(); aep.setRealmName(GeoServerSecurityManager.REALM); try { aep.afterPropertiesSet(); } catch (Exception e) { throw new IOException(e); } // BasicAuthenticationFilterConfig authConfig = (BasicAuthenticationFilterConfig) config; SecurityNamedServiceConfig authCfg = securityManager.loadAuthenticationProviderConfig("geofence"); GeoFenceAuthenticationProvider geofenceAuthProvider = geofenceAuth.createAuthenticationProvider(authCfg); BasicAuthenticationFilter filter = new BasicAuthenticationFilter(geofenceAuthProvider, aep); // if (authConfig.isUseRememberMe()) { // filter.setRememberMeServices(securityManager.getRememberMeService()); // GeoServerWebAuthenticationDetailsSource s = new // GeoServerWebAuthenticationDetailsSource(); // filter.setAuthenticationDetailsSource(s); // } filter.afterPropertiesSet(); getNestedFilters().add(filter); }
@Override protected void configure(HttpSecurity http) throws Exception { http.httpBasic().authenticationEntryPoint(getBasicAuthenticationEntryPoint()); } @Bean public BasicAuthenticationEntryPoint getBasicAuthenticationEntryPoint(){ BasicAuthenticationEntryPoint basicAuthenticationEntryPoint = new BasicAuthenticationEntryPoint(); basicAuthenticationEntryPoint.setRealmName("Basic Authentication"); return basicAuthenticationEntryPoint; } @Bean @Override public AuthenticationManager authenticationManagerBean() throws Exception { return super.authenticationManagerBean(); } @Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { auth .userDetailsService(userDetailsService) .passwordEncoder(passwordEncoder()); }
@Override public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException, ServletException { response.addHeader(RESTHeaders.ERROR_INFO, authException.getMessage()); super.commence(request, response, authException); }
@Override public void initializeFromConfig(SecurityNamedServiceConfig config) throws IOException { super.initializeFromConfig(config); GeoFenceAuthFilterConfig cfg = (GeoFenceAuthFilterConfig) config; // anything to set here? maybe the cache config aep = new BasicAuthenticationEntryPoint(); aep.setRealmName(GeoServerSecurityManager.REALM); try { aep.afterPropertiesSet(); } catch (Exception e) { throw new IOException(e); } // BasicAuthenticationFilterConfig authConfig = (BasicAuthenticationFilterConfig) config; SecurityNamedServiceConfig authCfg = securityManager.loadAuthenticationProviderConfig("geofence"); GeoFenceAuthenticationProvider geofenceAuthProvider = geofenceAuth.createAuthenticationProvider(authCfg); BasicAuthenticationFilter filter = new BasicAuthenticationFilter(geofenceAuthProvider, aep); // if (authConfig.isUseRememberMe()) { // filter.setRememberMeServices(securityManager.getRememberMeService()); // GeoServerWebAuthenticationDetailsSource s = new // GeoServerWebAuthenticationDetailsSource(); // filter.setAuthenticationDetailsSource(s); // } filter.afterPropertiesSet(); getNestedFilters().add(filter); }
final BasicAuthenticationEntryPoint wsAuthenticationEntryPoint = new BasicAuthenticationEntryPoint(); wsAuthenticationEntryPoint.setRealmName("My Realm"); return wsAuthenticationEntryPoint;
@Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { URI url=null; try { url = new URI(request.getRequestURI()); } catch (URISyntaxException e) { // TODO Auto-generated catch block LOGGER.error("Invalid URI:"+ request.getRequestURI()); super.commence(request, response, authException); return; } if(url == null){ super.commence(request, response, authException); return; } if( url.getPath().contains(LOGIN_PATH) || url.getPath().contains(SESSION_LOGIN_PATH)){ response.setHeader("WWW-Authenticate", "FormBased"); response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); } else{ super.commence(request, response, authException); } } }