本文整理汇总了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());
}
};
}
示例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);
}
示例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"));
}
};
}