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


Java EnvironmentContext.setSubject方法代码示例

本文整理汇总了Java中org.eclipse.che.commons.env.EnvironmentContext.setSubject方法的典型用法代码示例。如果您正苦于以下问题:Java EnvironmentContext.setSubject方法的具体用法?Java EnvironmentContext.setSubject怎么用?Java EnvironmentContext.setSubject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.che.commons.env.EnvironmentContext的用法示例。


在下文中一共展示了EnvironmentContext.setSubject方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldRedirectIfRequestWithoutNamespace

import org.eclipse.che.commons.env.EnvironmentContext; //导入方法依赖的package包/类
@Test(dataProvider = "nonNamespacePathProvider")
public void shouldRedirectIfRequestWithoutNamespace(String uri, String url) throws Exception {
  // given
  when(request.getMethod()).thenReturn("GET");
  when(request.getRequestURI()).thenReturn(uri);
  when(request.getRequestURL()).thenReturn(new StringBuffer(url));
  EnvironmentContext context = new EnvironmentContext();
  context.setSubject(new SubjectImpl("id123", "name", "token123", false));
  EnvironmentContext.setCurrent(context);

  // when
  filter.doFilter(request, response, chain);

  // then
  verify(response).sendRedirect(eq("/dashboard/"));
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:17,代码来源:DashboardRedirectionFilterTest.java

示例2: shouldAddPermissions

import org.eclipse.che.commons.env.EnvironmentContext; //导入方法依赖的package包/类
@Test
public void shouldAddPermissions() throws Exception {
  final EnvironmentContext ctx = new EnvironmentContext();
  ctx.setSubject(new SubjectImpl("test-user-name", "test-user-id", "test-token", false));
  EnvironmentContext.setCurrent(ctx);
  final StackImpl stack = createStack();

  permProvider.onEvent(new StackPersistedEvent(stack));

  final ArgumentCaptor<StackPermissionsImpl> captor =
      ArgumentCaptor.forClass(StackPermissionsImpl.class);
  verify(permManager).storePermission(captor.capture());
  final StackPermissionsImpl perm = captor.getValue();
  assertEquals(perm.getInstanceId(), stack.getId());
  assertEquals(perm.getUserId(), "test-user-id");
  assertEquals(perm.getDomainId(), StackDomain.DOMAIN_ID);
  assertEquals(perm.getActions(), StackDomain.getActions());
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:StackCreatorPermissionsProviderTest.java

示例3: doFilter

import org.eclipse.che.commons.env.EnvironmentContext; //导入方法依赖的package包/类
@Override
public final void doFilter(
    ServletRequest request, ServletResponse response, FilterChain filterChain)
    throws IOException, ServletException {
  final HttpServletRequest httpRequest = (HttpServletRequest) request;
  Subject subject = new SubjectImpl("che", "che", "dummy_token", false);
  HttpSession session = httpRequest.getSession();
  session.setAttribute("codenvy_user", subject);

  final EnvironmentContext environmentContext = EnvironmentContext.getCurrent();

  try {
    environmentContext.setSubject(subject);
    filterChain.doFilter(addUserInRequest(httpRequest, subject), response);
  } finally {
    EnvironmentContext.reset();
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:EnvironmentInitializationFilter.java

示例4: setUp

import org.eclipse.che.commons.env.EnvironmentContext; //导入方法依赖的package包/类
@BeforeMethod
public void setUp() throws Exception {
  keysInjector = new KeysInjector(sshManager, workspaceManager, execAgentClientFactory);

  when(execAgentClientFactory.create(anyString())).thenReturn(client);
  when(client.startProcess(anyString(), anyString(), anyString(), anyString()))
      .thenReturn(newDto(ProcessStartResponseDto.class).withPid(100));
  when(client.getProcess(anyString(), anyInt()))
      .thenReturn(
          newDto(GetProcessResponseDto.class).withAlive(false).withPid(100).withExitCode(0));
  prepareAndMockServers();

  EnvironmentContext context = new EnvironmentContext();
  context.setSubject(new SubjectImpl("name", OWNER, "token123", false));
  EnvironmentContext.setCurrent(context);
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:KeysInjectorTest.java

示例5: DummyProjectManager

import org.eclipse.che.commons.env.EnvironmentContext; //导入方法依赖的package包/类
public DummyProjectManager(String workspacePath, EventService eventService) {

    EnvironmentContext context = new EnvironmentContext();
    context.setSubject(new SubjectImpl(vfsUser, "", "", false));
    EnvironmentContext.setCurrent(context);
    //        localFileSystemProvider = new LocalFileSystemProvider("", new LocalFSMountStrategy() {
    //            @Override
    //            public File getMountPath(String workspaceId) throws ServerException {
    //                return new File(workspacePath);
    //            }
    //
    //            @Override
    //            public File getMountPath() throws ServerException {
    //                return new File(workspacePath);
    //            }
    //        }, eventService, null, SystemPathsFilter.ANY, null);
  }
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:DummyProjectManager.java

示例6: handleValidToken

import org.eclipse.che.commons.env.EnvironmentContext; //导入方法依赖的package包/类
@Override
public void handleValidToken(
    HttpServletRequest request,
    HttpServletResponse response,
    FilterChain chain,
    HttpSession session,
    SsoClientPrincipal principal)
    throws IOException, ServletException {
  LOG.debug(
      "User {} left filter with session id {} token {}",
      principal.getName(),
      session.getId(),
      principal.getToken());
  if ("GET".equals(request.getMethod()) && request.getParameter("cookiePresent") != null) {
    response.sendRedirect(
        UriBuilder.fromUri(request.getRequestURL().toString())
            .replaceQuery(request.getQueryString())
            .replaceQueryParam("cookiePresent")
            .build()
            .toString());
  } else {
    try {
      Subject subject = principal.getUser();
      EnvironmentContext environmentContext = EnvironmentContext.getCurrent();
      environmentContext.setSubject(subject);
      chain.doFilter(requestWrapper.wrapRequest(session, request, subject), response);
    } finally {
      EnvironmentContext.reset();
    }
  }
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:32,代码来源:DefaultTokenHandler.java

示例7: setup

import org.eclipse.che.commons.env.EnvironmentContext; //导入方法依赖的package包/类
@BeforeMethod
public void setup() throws Exception {
  publicPermissionsRemoveChecker = new PublicPermissionsRemoveChecker(defaultChecker, manager);
  final EnvironmentContext ctx = new EnvironmentContext();
  ctx.setSubject(subj);
  EnvironmentContext.setCurrent(ctx);
}
 
开发者ID:eclipse,项目名称:che,代码行数:8,代码来源:PublicPermissionsRemoveCheckerTest.java

示例8: setup

import org.eclipse.che.commons.env.EnvironmentContext; //导入方法依赖的package包/类
@BeforeMethod
public void setup() throws Exception {
  stackSetPermChecker = new StackDomainSetPermissionsChecker(defaultChecker);
  final EnvironmentContext ctx = new EnvironmentContext();
  ctx.setSubject(subj);
  EnvironmentContext.setCurrent(ctx);
}
 
开发者ID:eclipse,项目名称:che,代码行数:8,代码来源:StackDomainSetPermissionsCheckerTest.java

示例9: doFilter

import org.eclipse.che.commons.env.EnvironmentContext; //导入方法依赖的package包/类
@Override
public final void doFilter(
    ServletRequest request, ServletResponse response, FilterChain filterChain)
    throws IOException, ServletException {
  Subject subject = new SubjectImpl("che", "che", "dummy_token", false);
  final EnvironmentContext environmentContext = EnvironmentContext.getCurrent();
  try {
    environmentContext.setSubject(subject);
    filterChain.doFilter(request, response);
  } finally {
    EnvironmentContext.reset();
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:14,代码来源:EnvironmentInitializationFilter.java

示例10: shouldUseTokenFromCurrentContextForAuthorization

import org.eclipse.che.commons.env.EnvironmentContext; //导入方法依赖的package包/类
@Test
public void shouldUseTokenFromCurrentContextForAuthorization(ITestContext ctx) throws Exception {
  final EnvironmentContext context = new EnvironmentContext();
  context.setSubject(TEST_SUBJECT);
  EnvironmentContext.setCurrent(context);

  new DefaultHttpJsonRequest(getUrl(ctx) + "/token").usePostMethod().request();
}
 
开发者ID:eclipse,项目名称:che,代码行数:9,代码来源:DefaultHttpJsonRequestTest.java

示例11: setUp

import org.eclipse.che.commons.env.EnvironmentContext; //导入方法依赖的package包/类
@BeforeMethod
public void setUp() throws Exception {
  // let tests pass faster
  HostedMachineProviderImpl.SWARM_WAIT_BEFORE_REPEAT_WORKAROUND_TIME_MS = 10;

  when(dockerConnectorProviderMock.get()).thenReturn(dockerConnector);
  when(dockerConnectorConfiguration.getDockerHostIp()).thenReturn("123.123.123.123");

  EnvironmentContext envCont = new EnvironmentContext();
  envCont.setSubject(new SubjectImpl(USER_NAME, "userId", USER_TOKEN, false));
  EnvironmentContext.setCurrent(envCont);

  when(dockerMachineFactory.createNode(anyString(), anyString())).thenReturn(dockerNode);
  when(dockerConnector.createContainer(any(CreateContainerParams.class)))
      .thenReturn(new ContainerCreated(CONTAINER_ID, new String[0]));
  when(dockerConnector.inspectContainer(any(InspectContainerParams.class)))
      .thenReturn(containerInfo);
  when(containerInfo.getState()).thenReturn(containerState);
  when(dockerConnector.inspectContainer(anyString())).thenReturn(containerInfo);
  when(containerState.getStatus()).thenReturn("running");
  when(dockerConnector.inspectImage(anyString())).thenReturn(imageInfo);
  when(imageInfo.getConfig()).thenReturn(imageConfig);
  when(imageConfig.getCmd()).thenReturn(new String[] {"tail", "-f", "/dev/null"});

  provider =
      new HostedMachineProviderImpl(
          dockerConnectorProviderMock,
          credentialsReader,
          dockerMachineFactory,
          dockerInstanceStopDetector,
          windowsPathEscaper,
          requestTransmitter,
          endpointIdsHolder,
          emptySet(),
          emptySet(),
          emptySet(),
          emptySet(),
          false,
          false,
          securityOptProvider,
          -1,
          emptySet(),
          emptySet(),
          SNAPSHOT_USE_REGISTRY,
          MEMORY_SWAP_MULTIPLIER,
          machineTokenRegistry,
          emptySet(),
          null,
          null,
          null,
          0,
          0,
          emptySet(),
          null,
          emptyMap());
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:57,代码来源:HostedMachineProviderImplTest.java

示例12: doFilter

import org.eclipse.che.commons.env.EnvironmentContext; //导入方法依赖的package包/类
public void doFilter(GenericContainerRequest request) {
  EnvironmentContext context = EnvironmentContext.getCurrent();
  context.setSubject(new SubjectImpl(ADMIN_USER_NAME, USER_ID, ADMIN_USER_PASSWORD, false));
}
 
开发者ID:eclipse,项目名称:che,代码行数:5,代码来源:FactoryServiceTest.java

示例13: doFilter

import org.eclipse.che.commons.env.EnvironmentContext; //导入方法依赖的package包/类
public void doFilter(GenericContainerRequest request) {
  EnvironmentContext context = EnvironmentContext.getCurrent();
  context.setSubject(
      new SubjectImpl(JettyHttpServer.ADMIN_USER_NAME, "id-2314", "token-2323", false));
}
 
开发者ID:eclipse,项目名称:che,代码行数:6,代码来源:OAuthAuthenticationServiceTest.java


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