Java Code Examples for javax.ws.rs.core.Configuration#getProperty()
The following examples show how to use
javax.ws.rs.core.Configuration#getProperty() .
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: PropertyHelper.java From dremio-oss with Apache License 2.0 | 5 votes |
/** * Get the property value as boolean * * @param configuration the web configuration * @param name the property name * @return */ public static Boolean getProperty(Configuration configuration, String name) { Object property = configuration.getProperty(name); if (property == null) { return null; } if (property instanceof Boolean && (boolean) property) { return (boolean) property; } return Boolean.parseBoolean(property.toString()); }
Example 2
Source File: AgRuntime.java From agrest with Apache License 2.0 | 5 votes |
/** * Returns a service of a specified type present in Agrest container that * is stored in JAX RS Configuration. */ public static <T> T service(Class<T> type, Configuration config) { if (config == null) { throw new NullPointerException("Null config"); } Injector injector = (Injector) config.getProperty(AGREST_CONTAINER_PROPERTY); if (injector == null) { throw new IllegalStateException( "Agrest is misconfigured. No injector found for property: " + AGREST_CONTAINER_PROPERTY); } return injector.getInstance(type); }
Example 3
Source File: AssetsFeature.java From ameba with MIT License | 5 votes |
/** * <p>getAssetMap.</p> * * @param configuration a {@link javax.ws.rs.core.Configuration} object. * @return a {@link java.util.Map} object. */ public static Map<String, String[]> getAssetMap(Configuration configuration) { Map<String, String[]> assetsMap = Maps.newLinkedHashMap(); for (String key : configuration.getPropertyNames()) { if (key.startsWith(ASSETS_CONF_PREFIX) || key.equals("resource.assets")) { String routePath = key.replaceFirst("^resource\\.assets", ""); if (routePath.startsWith(".")) { routePath = routePath.substring(1); } else if (StringUtils.isBlank(routePath)) { routePath = "assets"; } if (routePath.endsWith("/")) { routePath = routePath.substring(0, routePath.lastIndexOf("/")); } String value = (String) configuration.getProperty(key); String[] uris = value.split(","); List<String> uriList = Lists.newArrayList(); for (String uri : uris) { uriList.add(uri.endsWith("/") ? uri : uri + "/"); } if (StringUtils.isNotBlank(value)) { String[] _uris = assetsMap.get(routePath); if (_uris == null) { assetsMap.put(routePath, uriList.toArray(uris)); } else { assetsMap.put(routePath, ArrayUtils.addAll(_uris, uriList.toArray(uris))); } } } } return assetsMap; }
Example 4
Source File: JerseyUnixSocketConnectorProvider.java From tessera with Apache License 2.0 | 4 votes |
@Override public Connector getConnector(Client client, Configuration runtimeConfig) { URI unixfile = (URI) runtimeConfig.getProperty("unixfile"); return new JerseyUnixSocketConnector(unixfile); }
Example 5
Source File: ShiroAuthenticationFeature.java From aries-jax-rs-whiteboard with Apache License 2.0 | 4 votes |
@Override public boolean configure(FeatureContext fc) { Configuration configuration = fc.getConfiguration(); if(_LOG.isInfoEnabled()) { @SuppressWarnings("unchecked") Map<String, Object> applicationProps = (Map<String, Object>) configuration.getProperty(JAX_RS_APPLICATION_SERVICE_PROPERTIES); _LOG.info("Registering the Shiro Authentication feature with application {}", applicationProps.getOrDefault(JAX_RS_NAME, "<No Name found in application configuration>")); } if(realms.isEmpty()) { _LOG.warn("There are no authentication realms available. Users may not be able to authenticate."); } else { _LOG.debug("Using the authentication realms {}.", realms); } _LOG.debug("Registering the Shiro SecurityManagerAssociatingFilter"); fc.register(new SecurityManagerAssociatingFilter(manager), AUTHENTICATION); Map<Class<?>, Integer> contracts = configuration.getContracts(ExceptionMapper.class); if(contracts.isEmpty()) { _LOG.debug("Registering the Shiro ExceptionMapper"); // Only register the ExceptionMapper if it isn't already registered fc.register(ExceptionMapper.class, AUTHENTICATION); } else if(AUTHENTICATION < contracts.getOrDefault(javax.ws.rs.ext.ExceptionMapper.class, USER)) { _LOG.debug("Updating the priority of the Shiro ExceptionMapper from {} to {}", contracts.getOrDefault(javax.ws.rs.ext.ExceptionMapper.class, USER), AUTHORIZATION); // Update the priority if it's registered too low contracts.put(javax.ws.rs.ext.ExceptionMapper.class, AUTHENTICATION); } contracts = configuration.getContracts(SubjectPrincipalRequestFilter.class); if(contracts.isEmpty()) { _LOG.debug("Registering the Shiro SubjectPrincipalRequestFilter"); // Only register the SubjectPrincipalRequestFilter if it isn't already registered // and make sure it always comes after the SecurityManagerAssociatingFilter fc.register(SubjectPrincipalRequestFilter.class, AUTHENTICATION + 1); } else if(AUTHENTICATION < contracts.getOrDefault(ContainerRequestFilter.class, USER)) { _LOG.debug("Updating the priority of the Shiro SubjectPrincipalRequestFilter from {} to {}", contracts.getOrDefault(ContainerRequestFilter.class, USER), AUTHENTICATION + 1); // Update the priority if it's registered too low contracts.put(ContainerRequestFilter.class, AUTHENTICATION + 1); } return true; }
Example 6
Source File: ShiroAuthorizationFeature.java From aries-jax-rs-whiteboard with Apache License 2.0 | 4 votes |
@Override public boolean configure(FeatureContext fc) { Configuration configuration = fc.getConfiguration(); if(_LOG.isInfoEnabled()) { @SuppressWarnings("unchecked") Map<String, Object> applicationProps = (Map<String, Object>) configuration.getProperty(JAX_RS_APPLICATION_SERVICE_PROPERTIES); _LOG.info("Registering the Shiro Authorization feature with application {}", applicationProps.getOrDefault(JAX_RS_NAME, "<No Name found in application configuration>")); } Map<Class<?>, Integer> contracts = configuration.getContracts(ExceptionMapper.class); if(contracts.isEmpty()) { _LOG.debug("Registering the Shiro ExceptionMapper"); // Only register the ExceptionMapper if it isn't already registered fc.register(ExceptionMapper.class, AUTHORIZATION); } else if(AUTHORIZATION < contracts.getOrDefault(javax.ws.rs.ext.ExceptionMapper.class, USER)) { _LOG.debug("Updating the priority of the Shiro ExceptionMapper from {} to {}", contracts.getOrDefault(javax.ws.rs.ext.ExceptionMapper.class, USER), AUTHORIZATION); // Update the priority if it's registered too low contracts.put(javax.ws.rs.ext.ExceptionMapper.class, AUTHORIZATION); } contracts = configuration.getContracts(SubjectPrincipalRequestFilter.class); if(contracts.isEmpty()) { _LOG.debug("Registering the Shiro SubjectPrincipalRequestFilter"); // Only register the SubjectPrincipalRequestFilter if it isn't already registered fc.register(SubjectPrincipalRequestFilter.class, AUTHORIZATION); } else if(AUTHORIZATION < contracts.getOrDefault(ContainerRequestFilter.class, USER)) { _LOG.debug("Updating the priority of the Shiro SubjectPrincipalRequestFilter from {} to {}", contracts.getOrDefault(ContainerRequestFilter.class, USER), AUTHORIZATION); // Update the priority if it's registered too low contracts.put(ContainerRequestFilter.class, AUTHORIZATION); } _LOG.debug("Registering the Shiro ShiroAnnotationFilterFeature"); fc.register(ShiroAnnotationFilterFeature.class, Priorities.AUTHORIZATION); return true; }
Example 7
Source File: TemplateEngineSupplierProducer.java From portals-pluto with Apache License 2.0 | 4 votes |
@ApplicationScoped @Produces public TemplateEngineSupplier getTemplateEngineSupplier(PortletConfig portletConfig, ServletContext servletContext, MvcContext mvcContext) { TemplateEngine templateEngine = new TemplateEngine(); templateEngine.setMessageResolver(new PortletMessageResolver(portletConfig)); Configuration configuration = mvcContext.getConfig(); String templateLocation = (String) configuration.getProperty(ViewEngine.VIEW_FOLDER); if (templateLocation == null) { templateLocation = ViewEngine.DEFAULT_VIEW_FOLDER; } templateEngine.setTemplateResolver(new PortletTemplateResolver(servletContext, new CDITemplateLocationSupplier(templateLocation))); return new DefaultTemplateEngineSupplier(templateEngine); }
Example 8
Source File: DefaultTrimouConfiguration.java From trimou with Apache License 2.0 | 4 votes |
public static Object getProperty(Configuration config, String name, Object defaultValue) { final Object value = config.getProperty(name); return value != null ? value : defaultValue; }
Example 9
Source File: PropertyUtils.java From krazo with Apache License 2.0 | 2 votes |
/** * Search for a property and return a default value if not found. Value * returned is of same type as default value. * * @param config configuration to search for property. * @param name property name. * @param defaultValue default value. * @param <T> type of default and return value. * @return property or default value. */ @SuppressWarnings("unchecked") public static <T> T getProperty(Configuration config, String name, T defaultValue) { final Object obj = config.getProperty(name); return obj != null ? (T) obj : defaultValue; }
Example 10
Source File: PropertyUtils.java From ozark with Apache License 2.0 | 2 votes |
/** * Search for a property and return a default value if not found. Value * returned is of same type as default value. * * @param config configuration to search for property. * @param name property name. * @param defaultValue default value. * @param <T> type of default and return value. * @return property or default value. */ @SuppressWarnings("unchecked") public static <T> T getProperty(Configuration config, String name, T defaultValue) { final Object obj = config.getProperty(name); return obj != null ? (T) obj : defaultValue; }