Configures the protected private resources.

@param http HTTP sec object
@throws Exception ex
162245
@Override
	protected void configure(HttpSecurity http) throws Exception {
		ConfigObject protectedResources = Config.getConfig().getObject("security.protected");
		ConfigValue apiSec = Config.getConfig().getValue("security.api_security");
		boolean enableRestFilter = apiSec != null && Boolean.TRUE.equals(apiSec.unwrapped());
		String signinPath = Config.getConfigParam("security.signin", "/signin");
		String signoutPath = Config.getConfigParam("security.signout", "/signout");
		String accessDeniedPath = Config.getConfigParam("security.access_denied", "/403");
		String signoutSuccessPath = Config.getConfigParam("security.signout_success", signinPath);

		// If API security is disabled don't add the API endpoint to the list of protected resources
		if (enableRestFilter) {
			http.authorizeRequests().requestMatchers(RestRequestMatcher.INSTANCE);
		}

		parseProtectedResources(http, protectedResources);

		if (Config.getConfigBoolean("security.csrf_protection", true)) {
			http.csrf().requireCsrfProtectionMatcher(CsrfProtectionRequestMatcher.INSTANCE).
					csrfTokenRepository(csrfTokenRepository);
		} else {
			http.csrf().disable();
		}

		http.sessionManagement().enableSessionUrlRewriting(false);
		http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER);
		http.sessionManagement().sessionAuthenticationStrategy(new NullAuthenticatedSessionStrategy());
		http.exceptionHandling().authenticationEntryPoint(new SimpleAuthenticationEntryPoint(signinPath));
		http.exceptionHandling().accessDeniedHandler(new SimpleAccessDeniedHandler(accessDeniedPath));
		http.requestCache().requestCache(new SimpleRequestCache());
		http.logout().logoutUrl(signoutPath).logoutSuccessUrl(signoutSuccessPath);
		http.rememberMe().rememberMeServices(rememberMeServices);

		registerAuthFilters(http);

		if (enableRestFilter) {
			if (jwtFilter != null) {
				jwtFilter.setAuthenticationManager(authenticationManager());
				http.addFilterBefore(jwtFilter, RememberMeAuthenticationFilter.class);
			}
			RestAuthFilter restFilter = new RestAuthFilter();
			http.addFilterAfter(restFilter, JWTRestfulAuthFilter.class);
		}
	}
865029
@Override
    public void configure(String parameters) {
        if (parameters.isEmpty()) {
            return;
        }
        List<String> values = Op.split(parameters, " ");
        int required = 4;
        if (values.size() < required) {
            throw new RuntimeException(String.format(
                    "[configuration error] term <%s> requires <%d> parameters",
                    this.getClass().getSimpleName(), required));
        }
        Iterator<String> it = values.iterator();
        setBottomLeft(Op.toDouble(it.next()));
        setTopLeft(Op.toDouble(it.next()));
        setTopRight(Op.toDouble(it.next()));
        setBottomRight(Op.toDouble(it.next()));
        if (values.size() > required) {
            setHeight(Op.toDouble(it.next()));
        }
    }
734030
private TeaServletContextSource createContextSource(boolean http)
        throws Exception {

        return new TeaServletContextSource(getClass().getClassLoader(), 
                                           this, 
                                           mEngine.getServletContext(), 
                                           mEngine.getLog(), 
                                           http,
                                           mEngine.getProperties().getBoolean("management.httpcontext", false),
                                           mEngine.getProperties().getInt("management.httpcontext.readUrlCacheSize", 500),
                                           mEngine.getProperties().getBoolean("profiling.enabled", true));
    }
638339
public void configureWebApp() throws Exception
    {
        //cannot configure if the context is already started
        if (_context.isStarted())
        {
            if (log.isDebugEnabled()){log.debug("Cannot configure webapp after it is started");};
            return;
        }
        
        Resource webInf=getWebApplicationContext().getWebInf();
        // handle any WEB-INF descriptors
        if(webInf!=null&&webInf.isDirectory())
        {
            // do web.xml file
            Resource web=webInf.addPath("web.xml");
            if(!web.exists())
            {
                log.info("No WEB-INF/web.xml in "+getWebApplicationContext().getWAR()
                        +". Serving files and default/dynamic servlets only");
            }
            else
            {
                XmlParser.Node config=null;
                config=xmlParser.parse(web.getURL());
                initialize(config);
            }
        }
    }
1113251
public void setPrivateSkillIds(java.util.Collection<String> privateSkillIds) {
        if (privateSkillIds == null) {
            this.privateSkillIds = null;
            return;
        }

        this.privateSkillIds = new java.util.ArrayList<String>(privateSkillIds);
    }
1096336
public void configure() throws Exception {

        final String hostname = host.startsWith("http") ? host : "http://" + host;

        /**
         * A generic error handler (specific to this RouteBuilder)
         */
        onException(Exception.class)
            .maximumRedeliveries("{{error.maxRedeliveries}}")
            .log("Index Routing Error: ${routeId}");

        /**
         * Expose a RESTful endpoint for re-indexing
         */
        from("jetty:" + hostname + ":" + port + "{{rest.prefix}}?matchOnUriPrefix=true&httpMethodRestrict=GET,POST")
            .routeId("FcrepoReindexingRest")
            .routeDescription("Expose the reindexing endpoint over HTTP")
            .setHeader(FCREPO_URI).simple("{{fcrepo.baseUrl}}${headers.CamelHttpPath}")
            .choice()
                .when(header(HTTP_METHOD).isEqualTo("GET")).to("direct:usage")
                .otherwise().to("direct:reindex");

        from("direct:usage").routeId("FcrepoReindexingUsage")
            .setHeader(REINDEXING_PREFIX).simple("{{rest.prefix}}")
            .setHeader(REINDEXING_PORT).simple(port)
            .setHeader(FCREPO_BASE_URL).simple("{{fcrepo.baseUrl}}")
            .process(exchange -> {
                exchange.getIn().setHeader(REINDEXING_HOST, getLocalHost().getHostName());
            })
            .to("mustache:org/fcrepo/camel/reindexing/usage.mustache");

        /**
         * A Re-indexing endpoint, setting where in the fcrepo hierarchy
         * a re-indexing operation should begin.
         */
        from("direct:reindex").routeId("FcrepoReindexingReindex")
            .process(new RestProcessor())
            .removeHeaders("CamelHttp*")
            .removeHeader("JMSCorrelationID")
            .setBody(constant(null))
            .choice()
                .when(header(HTTP_RESPONSE_CODE).isGreaterThanOrEqualTo(BAD_REQUEST))
                    .endChoice()
                .when(header(REINDEXING_RECIPIENTS).isEqualTo(""))
                    .transform().simple("No endpoints configured for indexing")
                    .endChoice()
                .otherwise()
                    .log(INFO, LOGGER, "Initial indexing path: ${headers[CamelFcrepoUri]}")
                    .inOnly("{{reindexing.stream}}?disableTimeToLive=true")
                    .setHeader(CONTENT_TYPE).constant("text/plain")
                    .transform().simple("Indexing started at ${headers[CamelFcrepoUri]}");

        /**
         *  A route that traverses through a fedora heirarchy
         *  indexing nodes, as appropriate.
         */
        from("{{reindexing.stream}}?asyncConsumer=true").routeId("FcrepoReindexingTraverse")
            .inOnly("direct:recipients")
            .removeHeaders("CamelHttp*")
            .setHeader(HTTP_METHOD).constant(GET)
            .to("fcrepo:{{fcrepo.baseUrl}}?preferInclude=PreferContainment" +
                    "&preferOmit=ServerManaged&accept=application/n-triples")
            // split the n-triples stream on line breaks so that each triple is split into a separate message
            .split(body().tokenize("\\n")).streaming()
                .removeHeader(FCREPO_URI)
                .removeHeader("JMSCorrelationID")
                .process(exchange -> {
                    // This is a simple n-triples parser, spliting nodes on whitespace according to
                    // https://www.w3.org/TR/n-triples/#n-triples-grammar
                    // If the body is not null and the predicate is ldp:contains and the object is a URI,
                    // then set the CamelFcrepoUri header (if that header is not set, the processing stops
                    // at the filter() line below.
                    final String body = exchange.getIn().getBody(String.class);
                    if (body != null) {
                        final String parts[] = body.split("\\s+");
                        if (parts.length > 2 && parts[1].equals(LDP_CONTAINS) && parts[2].startsWith("<")) {
                            exchange.getIn().setHeader(FCREPO_URI, parts[2].substring(1, parts[2].length() - 1));
                        }
                        exchange.getIn().setBody(null);
                    }
                })
                .filter(header(FCREPO_URI).isNotNull())
                    .inOnly("{{reindexing.stream}}?disableTimeToLive=true");

        /**
         *  Send the message to all of the pre-determined endpoints
         */
        from("direct:recipients").routeId("FcrepoReindexingRecipients")
            .recipientList(header(REINDEXING_RECIPIENTS))
            .ignoreInvalidEndpoints();
    }
850016
public void setHttpProxy(String host) {
    setProxyValue(HTTP_SERVER, host);
    setProxyValue(USE_HTTP, host != null);
  }
740734
@Override
	public void configure(WebSecurity web) throws Exception {
		web.ignoring().requestMatchers(IgnoredRequestMatcher.INSTANCE);
		DefaultHttpFirewall firewall = new DefaultHttpFirewall();
		firewall.setAllowUrlEncodedSlash(true);
		web.httpFirewall(firewall);
		//web.debug(true);
	}
1365590
public HttpRequest setSSLProtocol(String protocol) {
		if (null == this.ssf) {
			try {
				this.ssf = SSLSocketFactoryBuilder.create().setProtocol(protocol).build();
			} catch (Exception e) {
				throw new HttpException(e);
			}
		}
		return this;
	}
836600
protected void createGoogleAppsPrivateKey() throws Exception {
        if (!isValidConfiguration()) {
            LOGGER.debug("Google Apps private key bean will not be created, because it's not configured");
            return;
        }

        val bean = new PrivateKeyFactoryBean();

        if (this.privateKeyLocation.startsWith(ResourceUtils.CLASSPATH_URL_PREFIX)) {
            bean.setLocation(new ClassPathResource(StringUtils.removeStart(this.privateKeyLocation, ResourceUtils.CLASSPATH_URL_PREFIX)));
        } else if (this.privateKeyLocation.startsWith(ResourceUtils.FILE_URL_PREFIX)) {
            bean.setLocation(new FileSystemResource(StringUtils.removeStart(this.privateKeyLocation, ResourceUtils.FILE_URL_PREFIX)));
        } else {
            bean.setLocation(new FileSystemResource(this.privateKeyLocation));
        }

        bean.setAlgorithm(this.keyAlgorithm);
        LOGGER.debug("Loading Google Apps private key from [{}] with key algorithm [{}]",
            bean.getLocation(), bean.getAlgorithm());
        bean.afterPropertiesSet();
        LOGGER.debug("Creating Google Apps private key instance via [{}]", this.privateKeyLocation);
        this.privateKey = bean.getObject();
    }
439979
public void setManagedResource(Object o,String s)
        throws MBeanException, InstanceNotFoundException, InvalidTargetObjectTypeException
    {
        if (o!=null)
            ((HttpServer)o).addEventListener(this);
        super.setManagedResource(o,s);
    }
12045
@Override
    protected void configure() {

        // Bind the vertx and container instances
        bind(vertx).to(Vertx.class);

        // Request and read stream
        bindFactory(VertxRequestReferencingFactory.class).to(HttpServerRequest.class).in(PerLookup.class);
        bindFactory(VertxRequestReferencingFactory.class).to(new TypeLiteral<ReadStream<HttpServerRequest>>() {
        }).in(PerLookup.class);
        bindFactory(ReferencingFactory.<HttpServerRequest>referenceFactory()).to(new TypeLiteral<Ref<HttpServerRequest>>() {
        }).in(RequestScoped.class);

        // Response
        bindFactory(VertxResponseReferencingFactory.class).to(HttpServerResponse.class).in(PerLookup.class);
        bindFactory(ReferencingFactory.<HttpServerResponse>referenceFactory()).to(new TypeLiteral<Ref<HttpServerResponse>>() {
        }).in(RequestScoped.class);

    }
1355970
public void configure() throws Exception {

        final Namespaces ns = new Namespaces("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
        ns.add("indexing", "http://fedora.info/definitions/v4/indexing#");
        ns.add("ldp", "http://www.w3.org/ns/ldp#");


        /*
         * A generic error handler (specific to this RouteBuilder)
         */
        onException(Exception.class)
            .maximumRedeliveries("{{error.maxRedeliveries}}")
            .log("Index Routing Error: ${routeId}");

        /*
         * route a message to the proper queue, based on whether
         * it is a DELETE or UPDATE operation.
         */
        from("{{input.stream}}")
            .routeId("FcrepoSolrRouter")
            .process(new EventProcessor())
            .choice()
                .when(or(header(FCREPO_EVENT_TYPE).contains(RESOURCE_DELETION),
                            header(FCREPO_EVENT_TYPE).contains(DELETE)))
                    .to("direct:delete.solr")
                .otherwise()
                    .to("direct:index.solr");

        /*
         * Handle re-index events
         */
        from("{{solr.reindex.stream}}")
            .routeId("FcrepoSolrReindex")
            .to("direct:index.solr");

        /*
         * Based on an item's metadata, determine if it is indexable.
         */
        from("direct:index.solr")
            .routeId("FcrepoSolrIndexer")
            .removeHeaders("CamelHttp*")
            .filter(not(in(tokenizePropertyPlaceholder(getContext(), "{{filter.containers}}", ",").stream()
                        .map(uri -> or(
                            header(FCREPO_URI).startsWith(constant(uri + "/")),
                            header(FCREPO_URI).isEqualTo(constant(uri))))
                        .collect(toList()))))
            .choice()
                .when(and(simple("{{indexing.predicate}} != 'true'"),
                          simple("{{fcrepo.checkHasIndexingTransformation}} != 'true'")))
                    .setHeader(INDEXING_TRANSFORMATION).simple("{{fcrepo.defaultTransform}}")
                    .to("direct:update.solr")
                .otherwise()
                    .to("fcrepo:{{fcrepo.baseUrl}}?preferOmit=PreferContainment&accept=application/rdf+xml")
                    .setHeader(INDEXING_TRANSFORMATION).xpath(hasIndexingTransformation, String.class, ns)
                    .choice()
                        .when(or(header(INDEXING_TRANSFORMATION).isNull(),
                                 header(INDEXING_TRANSFORMATION).isEqualTo("")))
                            .setHeader(INDEXING_TRANSFORMATION).simple("{{fcrepo.defaultTransform}}").end()
                    .removeHeaders("CamelHttp*")
                    .choice()
                        .when(or(simple("{{indexing.predicate}} != 'true'"),
                                 header(FCREPO_RESOURCE_TYPE).contains(INDEXABLE)))
                            .to("direct:update.solr")
                        .otherwise()
                            .to("direct:delete.solr");


        /*
         * Remove an item from the solr index.
         */
        from("direct:delete.solr").routeId("FcrepoSolrDeleter")
            .removeHeaders("CamelHttp*")
            .to("mustache:org/fcrepo/camel/indexing/solr/delete.mustache")
            .log(LoggingLevel.INFO, logger, "Deleting Solr Object ${headers[CamelFcrepoUri]}")
            .setHeader(HTTP_METHOD).constant("POST")
            .setHeader(CONTENT_TYPE).constant("application/json")
            .setHeader(HTTP_QUERY).simple("commitWithin={{solr.commitWithin}}")
            .to("{{solr.baseUrl}}/update?useSystemProperties=true");

        from("direct:external.ldpath").routeId("FcrepoSolrLdpathFetch")
            .removeHeaders("CamelHttp*")
            .setHeader(HTTP_URI).header(INDEXING_TRANSFORMATION)
            .setHeader(HTTP_METHOD).constant("GET")
            .to("http4://localhost/ldpath");

        from("direct:transform.ldpath").routeId("FcrepoSolrTransform")
            .removeHeaders("CamelHttp*")
            .setHeader(HTTP_URI).simple("{{ldpath.service.baseUrl}}")
            .setHeader(HTTP_QUERY).simple("context=${headers.CamelFcrepoUri}")
            .to("http4://localhost/ldpath");

        /*
         * Handle update operations
         */
        from("direct:update.solr").routeId("FcrepoSolrUpdater")
            .log(LoggingLevel.INFO, logger, "Indexing Solr Object ${header.CamelFcrepoUri}")
            .setBody(constant(null))
            .setHeader(INDEXING_URI).simple("${header.CamelFcrepoUri}")
            // Don't index the transformation itself
            .filter().simple("${header.CamelIndexingTransformation} != ${header.CamelIndexingUri}")
                .choice()
                    .when(header(INDEXING_TRANSFORMATION).startsWith("http"))
                        .log(LoggingLevel.INFO, logger,
                                "Fetching external LDPath program from ${header.CamelIndexingTransformation}")
                        .to("direct:external.ldpath")
                        .setHeader(HTTP_METHOD).constant("POST")
                        .to("direct:transform.ldpath")
                        .to("direct:send.to.solr")
                    .when(or(header(INDEXING_TRANSFORMATION).isNull(), header(INDEXING_TRANSFORMATION).isEqualTo("")))
                        .setHeader(HTTP_METHOD).constant("GET")
                        .to("direct:transform.ldpath")
                        .to("direct:send.to.solr")
                    .otherwise()
                        .log(LoggingLevel.INFO, logger, "Skipping ${header.CamelFcrepoUri}");

        /*
         * Send the transformed resource to Solr
         */
        from("direct:send.to.solr").routeId("FcrepoSolrSend")
            .removeHeaders("CamelHttp*")
            .setHeader(HTTP_METHOD).constant("POST")
            .setHeader(HTTP_QUERY).simple("commitWithin={{solr.commitWithin}}")
            .to("{{solr.baseUrl}}/update?useSystemProperties=true");
    }
1288330
public void configure() throws Exception {

        /**
         * Expose a RESTful endpoint for LDPath processing
         */
        from("jetty:http://{{rest.host}}:{{rest.port}}{{rest.prefix}}?" +
                "&httpMethodRestrict=GET,POST,OPTIONS" +
                "&sendServerVersion=false")
            .routeId("FcrepoLDPathRest")
            .routeDescription("Expose the ldpath endpoint over HTTP")
            .choice()
                .when(header(HTTP_METHOD).isEqualTo("OPTIONS"))
                    .setHeader(CONTENT_TYPE).constant("text/turtle")
                    .setHeader("Allow").constant("GET,POST,OPTIONS")
                    .to("language:simple:resource:classpath:org/fcrepo/camel/ldpath/options.ttl")
                // make sure the required context parameter is present
                .when(not(and(header("context").isNotNull(), header("context").regex("^https?://.+"))))
                    .setHeader(HTTP_RESPONSE_CODE).constant(400)
                    .setHeader(CONTENT_TYPE).constant("text/plain")
                    .transform(constant("Missing context parameter"))
                .when(header(HTTP_METHOD).isEqualTo("GET"))
                    .to("direct:get")
                .when(header(HTTP_METHOD).isEqualTo("POST"))
                    .to("direct:ldpathPrepare");

        from("direct:get")
            .routeId("FcrepoLDPathGet")
            .choice()
                .when(and(header("ldpath").isNotNull(), header("ldpath").regex("^https?://.*")))
                    .removeHeaders("CamelHttp*")
                    .setHeader(HTTP_URI).header("ldpath")
                    .to("http4://localhost?useSystemProperties=true")
                    .to("direct:ldpathPrepare")
                .otherwise()
                    .to("language:simple:resource:classpath:org/fcrepo/camel/ldpath/default.ldpath")
                    .to("direct:ldpathPrepare");

        from("direct:ldpathPrepare").routeId("FcrepoLDPathPrepare")
            .to("direct:ldpath")
            .to("direct:format");

        from("direct:format").routeId("FcrepoLDPathFormat")
            .marshal().json(Jackson)
            .removeHeaders("*")
            .setHeader(CONTENT_TYPE).constant("application/json");
    }
594476
protected void initSecurityConstraint(XmlParser.Node node)
    {
        try
        {
            SecurityConstraint scBase = new SecurityConstraint();
            XmlParser.Node auths = node.get("auth-constraint");
            if (auths != null)
            {
                scBase.setAuthenticate(true);
                // auth-constraint
                Iterator iter = auths.iterator("role-name");
                while (iter.hasNext())
                {
                    String role = ((XmlParser.Node) iter.next()).toString(false, true);
                    scBase.addRole(role);
                }
            }
            XmlParser.Node data = node.get("user-data-constraint");
            if (data != null)
            {
                data = data.get("transport-guarantee");
                String guarantee = data.toString(false, true).toUpperCase();
                if (guarantee == null || guarantee.length() == 0 || "NONE".equals(guarantee))
                    scBase.setDataConstraint(SecurityConstraint.DC_NONE);
                else if ("INTEGRAL".equals(guarantee))
                    scBase.setDataConstraint(SecurityConstraint.DC_INTEGRAL);
                else if ("CONFIDENTIAL".equals(guarantee))
                    scBase.setDataConstraint(SecurityConstraint.DC_CONFIDENTIAL);
                else
                {
                    log.warn("Unknown user-data-constraint:" + guarantee);
                    scBase.setDataConstraint(SecurityConstraint.DC_CONFIDENTIAL);
                }
            }
            Iterator iter = node.iterator("web-resource-collection");
            while (iter.hasNext())
            {
                XmlParser.Node collection = (XmlParser.Node) iter.next();
                String name = collection.getString("web-resource-name", false, true);
                SecurityConstraint sc = (SecurityConstraint) scBase.clone();
                sc.setName(name);
                Iterator iter2 = collection.iterator("http-method");
                while (iter2.hasNext())
                    sc.addMethod(((XmlParser.Node) iter2.next()).toString(false, true));
                iter2 = collection.iterator("url-pattern");
                while (iter2.hasNext())
                {
                    String url = ((XmlParser.Node) iter2.next()).toString(false, true);
                    getWebApplicationContext().addSecurityConstraint(url, sc);
                }
            }
        }
        catch (CloneNotSupportedException e)
        {
            log.fatal(e);
        }
    }
307275
public static function configure($param = array('key' => null, 'secret' => null))
    {

        if (!$param['key'] && !$param['secret']) {
            Throw new \Exception('Api Key and Secret must be defined');
        }

        self::$API_SECRET = $param['secret'];
        self::$API_KEY = $param['key'];
    }
748916
@Override
    protected void configure(HttpSecurity http) throws Exception {
        // Gets a secure random key for the remember be token key
        SecureRandom random = new SecureRandom();
        byte[] randomBytes = new byte[64];
        random.nextBytes(randomBytes);
        String rememberBeKey = new String(Hex.encode(randomBytes));
        // @formatter:off
        http.antMatcher("/**")
            // Only BASIC authentication
            .httpBasic()
                .authenticationEntryPoint(apiBasicAuthenticationEntryPoint)
                .realmName("ontrack")
                .and()
            // Logout set-up
            .logout()
                .logoutUrl("/user/logout")
                .logoutSuccessUrl("/user/logged-out")
                .addLogoutHandler(basicRememberMeUserDetailsService())
                .and()
            // FIXME CSRF protection for a stateless API?
            //.csrf().requireCsrfProtectionMatcher(new CSRFRequestMatcher()).and()
            .csrf().disable()
            // Allows all at Web level
            .authorizeRequests()
                .antMatchers("/**").permitAll()
            // Remember be authentication token
            .and().rememberMe()
                .rememberMeServices(rememberMeServices(rememberBeKey))
                .key(rememberBeKey)
                .tokenValiditySeconds(604800)
            // Cache enabled
            .and().headers().cacheControl().disable()
        ;
        // @formatter:on
    }