當前位置: 首頁>>代碼示例>>Java>>正文


Java ResteasyProviderFactory.pushContext方法代碼示例

本文整理匯總了Java中org.jboss.resteasy.spi.ResteasyProviderFactory.pushContext方法的典型用法代碼示例。如果您正苦於以下問題:Java ResteasyProviderFactory.pushContext方法的具體用法?Java ResteasyProviderFactory.pushContext怎麽用?Java ResteasyProviderFactory.pushContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jboss.resteasy.spi.ResteasyProviderFactory的用法示例。


在下文中一共展示了ResteasyProviderFactory.pushContext方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: filter

import org.jboss.resteasy.spi.ResteasyProviderFactory; //導入方法依賴的package包/類
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
	Vertx vertx = ResteasyProviderFactory.getContextData(io.vertx.core.Vertx.class);
	ResteasyProviderFactory.pushContext(io.vertx.rxjava.core.Vertx.class, io.vertx.rxjava.core.Vertx.newInstance(vertx));
       HttpServerRequest req = ResteasyProviderFactory.getContextData(HttpServerRequest.class);
	ResteasyProviderFactory.pushContext(io.vertx.rxjava.core.http.HttpServerRequest.class, io.vertx.rxjava.core.http.HttpServerRequest.newInstance(req));
       HttpServerResponse resp = ResteasyProviderFactory.getContextData(HttpServerResponse.class);
	ResteasyProviderFactory.pushContext(io.vertx.rxjava.core.http.HttpServerResponse.class, io.vertx.rxjava.core.http.HttpServerResponse.newInstance(resp));

	ResteasyProviderFactory.pushContext(ServletContext.class, ServletContext);
}
 
開發者ID:FroMage,項目名稱:redpipe,代碼行數:12,代碼來源:RxVertxProvider.java

示例2: getEntity

import org.jboss.resteasy.spi.ResteasyProviderFactory; //導入方法依賴的package包/類
public static <T> T getEntity(ClientMessage msg, Class<T> type, Type genericType, ResteasyProviderFactory factory) {
   int size = msg.getBodySize();
   if (size <= 0)
      return null;

   byte[] body = new byte[size];
   msg.getBodyBuffer().readBytes(body);

   String contentType = msg.getStringProperty(HttpHeaderProperty.CONTENT_TYPE);
   if (contentType == null) {
      throw new UnknownMediaType("Message did not have a Content-Type header cannot extract entity");
   }
   MediaType ct = MediaType.valueOf(contentType);
   MessageBodyReader<T> reader = factory.getMessageBodyReader(type, genericType, null, ct);
   if (reader == null) {
      throw new UnmarshalException("Unable to find a JAX-RS reader for type " + type.getName() + " and media type " + contentType);
   }

   Providers current = ResteasyProviderFactory.getContextData(Providers.class);
   ResteasyProviderFactory.pushContext(Providers.class, factory);
   try {
      return reader.readFrom(type, genericType, null, ct, new Headers<String>(), new ByteArrayInputStream(body));
   } catch (IOException e) {
      throw new RuntimeException(e);
   } finally {
      ResteasyProviderFactory.popContextData(Providers.class);
      if (current != null)
         ResteasyProviderFactory.pushContext(Providers.class, current);
   }
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:31,代碼來源:ActiveMQ.java

示例3: doFilter

import org.jboss.resteasy.spi.ResteasyProviderFactory; //導入方法依賴的package包/類
@Override
public void doFilter(ServletRequest sr, ServletResponse sr1, FilterChain fc) throws IOException, ServletException {
    HttpServletRequest req = (HttpServletRequest) sr;

    //System.out.println("filter: " + req.getRequestURI() + " user: " + sr.getParameter("user"));
    if (sr.getParameter("user") != null) {
        ResteasyProviderFactory.pushContext(User.class, new User(sr.getParameter("user")));
        fc.doFilter(new UserRoleRequestWrapper("user", sr.getParameter("user"), req), sr1);
    } else {
        fc.doFilter(req, sr1);
    }

}
 
開發者ID:szymex,項目名稱:Embedded-Jetty-RESTEasy-Guice-Example,代碼行數:14,代碼來源:HelloFilter.java

示例4: filter

import org.jboss.resteasy.spi.ResteasyProviderFactory; //導入方法依賴的package包/類
@Override
public void filter(ContainerRequestContext context) throws IOException {
    SecurityContext securityContext = context.getSecurityContext();
    ResteasyProviderFactory.pushContext(Principal.class, securityContext.getUserPrincipal());
}
 
開發者ID:mapr-demos,項目名稱:mapr-music,代碼行數:6,代碼來源:UserPrincipalContextFilter.java

示例5: setSession

import org.jboss.resteasy.spi.ResteasyProviderFactory; //導入方法依賴的package包/類
@Override
	public void setSession(Session session) {
//		System.err.println("setSession: "+session);
		ResteasyProviderFactory.pushContext(io.vertx.rxjava.ext.web.Session.class, io.vertx.rxjava.ext.web.Session.newInstance(session));
		delegate.setSession(session);
	}
 
開發者ID:FroMage,項目名稱:redpipe,代碼行數:7,代碼來源:ResteasyFilterContext.java

示例6: setUser

import org.jboss.resteasy.spi.ResteasyProviderFactory; //導入方法依賴的package包/類
@Override
	public void setUser(User user) {
//		System.err.println("setUser: "+user);
		ResteasyProviderFactory.pushContext(io.vertx.rxjava.ext.auth.User.class, io.vertx.rxjava.ext.auth.User.newInstance(user));
		delegate.setUser(user);
	}
 
開發者ID:FroMage,項目名稱:redpipe,代碼行數:7,代碼來源:ResteasyFilterContext.java

示例7: injectGlobals

import org.jboss.resteasy.spi.ResteasyProviderFactory; //導入方法依賴的package包/類
public void injectGlobals() {
	for (Entry<Class<?>, Object> entry : typedGlobals.entrySet()) {
		ResteasyProviderFactory.pushContext((Class)entry.getKey(), entry.getValue());
	}
}
 
開發者ID:FroMage,項目名稱:redpipe,代碼行數:6,代碼來源:AppGlobals.java

示例8: configureRequestContext

import org.jboss.resteasy.spi.ResteasyProviderFactory; //導入方法依賴的package包/類
@Override
protected void configureRequestContext() {
    ResteasyProviderFactory.pushContext(User.class, new User("Kalle"));
}
 
開發者ID:szymex,項目名稱:Embedded-Jetty-RESTEasy-Guice-Example,代碼行數:5,代碼來源:HelloResourceTest.java

示例9: preProcess

import org.jboss.resteasy.spi.ResteasyProviderFactory; //導入方法依賴的package包/類
@Override
public ServerResponse preProcess(HttpRequest request, ResourceMethod method) throws Failure, WebApplicationException {

	boolean authenticated = false;
	String authenticationScheme = null;
	String username = null;
	String password;
	// Check http basic authentication first
	List<String> authentication = request.getHttpHeaders().getRequestHeader("Authorization");
	if (authentication != null && authentication.size() > 0) {
		for (String auth : authentication) {
			if (!auth.startsWith("Basic")) {
				continue;
			}
			String hash = auth.substring(6);

			try {
				byte[] decoded = Base64.decode(hash);
				String usernamePassword = new String(decoded);

				int colon = usernamePassword.indexOf(':');
				if (colon > 0) {
					username = usernamePassword.substring(0, colon);
					password = usernamePassword.substring(colon + 1, usernamePassword.length());

					authenticated = providerService.authenticate(username, password);
					authenticationScheme = SecurityContext.BASIC_AUTH;
					break;
				}
			} catch (IOException e) {
				log.log(Level.SEVERE, "Cannot encode authentication realm", e);
			}

		}
	}

	if (!authenticated) {
		// Check username and password as query parameters
		MultivaluedMap<String, String> queryParams = request.getUri().getQueryParameters();
		if (queryParams != null) {
			username = queryParams.getFirst("provider");
			password = queryParams.getFirst("pwd");
			if (username != null && !username.isEmpty() && password != null && !password.isEmpty()) {
				authenticated = providerService.authenticate(username, password);
				authenticationScheme = "CUSTOM";
			}
		}
	}

	if (authenticated) {
		Principal principal = new SimplePrincipal(username);
		ResteasyProviderFactory.pushContext(SecurityContext.class,
				new CustomSecurityContext(principal, providerService.isSuperProvider(username), true, authenticationScheme));
		log.log(Level.FINE, "Request authenticated. Username: {0}", username);
	}

	return null;

}
 
開發者ID:macanhhuy,項目名稱:dcp-api,代碼行數:60,代碼來源:AuthenticationInterceptor.java


注:本文中的org.jboss.resteasy.spi.ResteasyProviderFactory.pushContext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。