当前位置: 首页>>代码示例>>Java>>正文


Java AbstractHttpContextInjectable类代码示例

本文整理汇总了Java中com.sun.jersey.server.impl.inject.AbstractHttpContextInjectable的典型用法代码示例。如果您正苦于以下问题:Java AbstractHttpContextInjectable类的具体用法?Java AbstractHttpContextInjectable怎么用?Java AbstractHttpContextInjectable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AbstractHttpContextInjectable类属于com.sun.jersey.server.impl.inject包,在下文中一共展示了AbstractHttpContextInjectable类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getInjectable

import com.sun.jersey.server.impl.inject.AbstractHttpContextInjectable; //导入依赖的package包/类
@Override
public Injectable<ParsedQuery<? extends QuerySpec>> getInjectable(ComponentContext ic, final BindQuery a, Parameter c) {
  return new AbstractHttpContextInjectable<ParsedQuery<? extends QuerySpec>>() {
    @Override
    public ParsedQuery<? extends QuerySpec> getValue(HttpContext context) {
      return QueryParser.newBuilder(a.value()).build().parse(context.getUriInfo().getQueryParameters());
    }
  };
}
 
开发者ID:HubSpot,项目名称:httpQL,代码行数:10,代码来源:BindQueryInjectableProvider.java

示例2: testAuthenticate

import com.sun.jersey.server.impl.inject.AbstractHttpContextInjectable; //导入依赖的package包/类
public OsiamContext testAuthenticate(String usersGroup, String restrictedGroup) {
    OsiamDropwizard od = mock(OsiamDropwizard.class);

    OsiamContext octx = mock(OsiamContext.class);

    // return osiam context mock, when supplied with user and password
    when(od.getContextWithAccessToken(eq("myAccessToken"))).thenReturn(octx);
    List<GroupRef> groups = new ArrayList<GroupRef>();


    if(usersGroup != null) {
        // if group is supplied, we add this group to the users groups
        groups.add(new GroupRef.Builder().setDisplay(restrictedGroup).build());
    }

    // mock getCurrentUser
    when(octx.getCurrentUser()).thenReturn(new User.Builder("marissa").setGroups(groups).build());

    OsiamRoleAuthOAuthProvider orap = new OsiamRoleAuthOAuthProvider(od, "realm");

    RestrictedTo rt = mock(RestrictedTo.class);
    if(restrictedGroup != null) {
        // if restrictedTo group is supplied, we mock this
        when(rt.value()).thenReturn(new String[]{restrictedGroup});
    }

    AbstractHttpContextInjectable<OsiamContext> inj = (AbstractHttpContextInjectable) orap.getInjectable(null, rt, null);

    HttpContext ctx = mock(HttpContext.class);
    HttpRequestContext rctx = mock(HttpRequestContext.class);
    when(ctx.getRequest()).thenReturn(rctx);
    // mock header: username/password: marissa/koala
    when(rctx.getHeaderValue(HttpHeaders.AUTHORIZATION)).thenReturn("bearer myAccessToken");

    return inj.getValue(ctx);
}
 
开发者ID:osiam,项目名称:osiam-dropwizard,代码行数:37,代码来源:OsiamRoleAuthOAuthProviderTest.java

示例3: getInjectable

import com.sun.jersey.server.impl.inject.AbstractHttpContextInjectable; //导入依赖的package包/类
@Override
public Injectable<User> getInjectable(ComponentContext ic, CustomContext a) {

    return new AbstractHttpContextInjectable<User>() {
        @Override
        public User getValue(HttpContext c) {
            return new User(c.getRequest().getQueryParameters().getFirst("user"));
        }
    };
}
 
开发者ID:szymex,项目名称:jetty-jersey-guice-example,代码行数:11,代码来源:UserProvider.java


注:本文中的com.sun.jersey.server.impl.inject.AbstractHttpContextInjectable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。