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


Java PentahoSessionHolder.setSession方法代码示例

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


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

示例1: init

import org.pentaho.platform.engine.core.system.PentahoSessionHolder; //导入方法依赖的package包/类
@Before
public void init() throws PlatformInitializationException {
  System.setProperty( "java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory" );
  System.setProperty( "org.osjava.sj.root", "test-src/simple-jndi" );
  System.setProperty( "org.osjava.sj.delimiter", "/" );
  System.setProperty( "PENTAHO_SYS_CFG_PATH", new File( SOLUTION_REPOSITORY + "/pentaho.xml" ).getAbsolutePath() );

  IPentahoSession session = new StandaloneSession();
  PentahoSessionHolder.setSession( session );

  mp.define( IUserRoleListService.class, StubUserRoleListService.class );
  mp.define( UserDetailsService.class, StubUserDetailService.class );
  mp.defineInstance( IAuthorizationPolicy.class, new TestAuthorizationPolicy() );
  mp.setSettingsProvider( new PathBasedSystemSettings() );
  mp.define( ISolutionEngine.class, SolutionEngine.class );
  FileSystemBackedUnifiedRepository repo =  new FileSystemBackedUnifiedRepository( SOLUTION_REPOSITORY );
  mp.defineInstance(  IUnifiedRepository.class, repo );

  mp.start();

  SecurityHelper.getInstance().becomeUser( TEST_USER );
}
 
开发者ID:pentaho,项目名称:pdi-platform-plugin,代码行数:23,代码来源:UserParametersTest.java

示例2: testCachingFactoryConnect

import org.pentaho.platform.engine.core.system.PentahoSessionHolder; //导入方法依赖的package包/类
@Test
public void testCachingFactoryConnect() throws Exception {
  ICacheManager cacheManager = mock( ICacheManager.class );
  PentahoSystem.registerObject( cacheManager );
  IPentahoSession session = new StandaloneSession( "joe" );
  PentahoSessionHolder.setSession( session );

  // Delegate is just a mock. connect will be a cache miss
  IRepositoryFactory mockFactory = mock( IRepositoryFactory.class );
  IRepositoryFactory.CachingRepositoryFactory cachingRepositoryFactory =
      new IRepositoryFactory.CachingRepositoryFactory( mockFactory );

  cachingRepositoryFactory.connect( "foo" );

  verify( mockFactory, times( 1 ) ).connect( "foo" );

  // Test with Cache Hit
  Repository mockRepository = mock( Repository.class );
  when( cacheManager.cacheEnabled( IRepositoryFactory.CachingRepositoryFactory.REGION ) ).thenReturn( true );
  when( cacheManager.getFromRegionCache( IRepositoryFactory.CachingRepositoryFactory.REGION, "joe" ) ).thenReturn(
      mockRepository );

  Repository repo = cachingRepositoryFactory.connect( "foo" );
  assertThat( repo, sameInstance( mockRepository ) );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:26,代码来源:RepositoryFactoryTest.java

示例3: loginAsTenantAdmin

import org.pentaho.platform.engine.core.system.PentahoSessionHolder; //导入方法依赖的package包/类
protected void loginAsTenantAdmin() {
  StandaloneSession pentahoSession = new StandaloneSession( "joe" );
  pentahoSession.setAuthenticated( "joe" );
  pentahoSession.setAttribute( IPentahoSession.TENANT_ID_KEY, "acme" );
  final String password = "password";
  List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>( 3 );
  authorities.add( new SimpleGrantedAuthority( "Authenticated" ) );
  authorities.add( new SimpleGrantedAuthority( "acme_Authenticated" ) );
  authorities.add( new SimpleGrantedAuthority( "acme_Admin" ) );
  UserDetails userDetails = new User( "joe", password, true, true, true, true, authorities );
  Authentication auth = new UsernamePasswordAuthenticationToken( userDetails, password, authorities );
  PentahoSessionHolder.setSession( pentahoSession );
  // this line necessary for Spring Security's MethodSecurityInterceptor
  SecurityContextHolder.getContext().setAuthentication( auth );
  repositoryLifecyleManager.newTenant();
  repositoryLifecyleManager.newUser();
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:18,代码来源:PurRepositoryIT.java

示例4: createUserHomeFolder

import org.pentaho.platform.engine.core.system.PentahoSessionHolder; //导入方法依赖的package包/类
protected void createUserHomeFolder( final ITenant theTenant, final String theUsername ) {
  IPentahoSession origPentahoSession = PentahoSessionHolder.getSession();
  Authentication origAuthentication = SecurityContextHolder.getContext().getAuthentication();
  StandaloneSession pentahoSession = new StandaloneSession( repositoryAdminUsername );
  pentahoSession.setAuthenticated( null, repositoryAdminUsername );
  PentahoSessionHolder.setSession( pentahoSession );

  String principleId = userNameUtils.getPrincipleId( theTenant, theUsername );
  String authenticatedRoleId = roleNameUtils.getPrincipleId( theTenant, tenantAuthenticatedRoleName );
  TransactionCallbackWithoutResult callback =
      PurRepositoryTestingUtils.createUserHomeDirCallback( theTenant, theUsername, principleId, authenticatedRoleId,
          repositoryFileDao );
  try {
    txnTemplate.execute( callback );
  } finally {
    // Switch our identity back to the original user.
    PurRepositoryTestingUtils.setSession( origPentahoSession, origAuthentication );
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:20,代码来源:PurRepositoryIT.java

示例5: setUpUser

import org.pentaho.platform.engine.core.system.PentahoSessionHolder; //导入方法依赖的package包/类
private void setUpUser() {
  StandaloneSession pentahoSession = new StandaloneSession( userInfo.getLogin() );
  pentahoSession.setAuthenticated( userInfo.getLogin() );
  pentahoSession.setAttribute( IPentahoSession.TENANT_ID_KEY, "/pentaho/" + EXP_TENANT );
  List<GrantedAuthority> authorities = new ArrayList<>( 2 );
  authorities.add( new SimpleGrantedAuthority( "Authenticated" ) );
  authorities.add( new SimpleGrantedAuthority( "acme_Authenticated" ) );
  final String password = "ignored"; //$NON-NLS-1$
  UserDetails userDetails = new User( userInfo.getLogin(), password, true, true, true, true, authorities );
  Authentication authentication = new UsernamePasswordAuthenticationToken( userDetails, password, authorities );
  // next line is copy of SecurityHelper.setPrincipal
  pentahoSession.setAttribute( "SECURITY_PRINCIPAL", authentication );
  PentahoSessionHolder.setSession( pentahoSession );
  SecurityContextHolder.setStrategyName( SecurityContextHolder.MODE_GLOBAL );
  SecurityContextHolder.getContext().setAuthentication( authentication );
  repositoryLifecyleManager.newTenant();
  repositoryLifecyleManager.newUser();
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:19,代码来源:UIEERepositoryDirectoryIT.java

示例6: login

import org.pentaho.platform.engine.core.system.PentahoSessionHolder; //导入方法依赖的package包/类
/**
 * Logs in with given username.
 * 
 * @param username
 *          username of user
 * @param tenantId
 *          tenant to which this user belongs
 * @tenantAdmin true to add the tenant admin authority to the user's roles
 */
private void login( final String username, final ITenant tenant, String[] roles ) {
  StandaloneSession pentahoSession = new StandaloneSession( username );
  pentahoSession.setAuthenticated( tenant.getId(), username );
  PentahoSessionHolder.setSession( pentahoSession );
  pentahoSession.setAttribute( IPentahoSession.TENANT_ID_KEY, tenant.getId() );
  final String password = "password";

  List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();

  if ( roles != null ) {
    for ( String roleName : roles ) {
      authorities.add( new SimpleGrantedAuthority( roleName ) );
    }
  }
  UserDetails userDetails = new User( username, password, true, true, true, true, authorities );
  Authentication auth = new UsernamePasswordAuthenticationToken( userDetails, password, authorities );
  PentahoSessionHolder.setSession( pentahoSession );
  // this line necessary for Spring Security's MethodSecurityInterceptor
  SecurityContextHolder.getContext().setAuthentication( auth );

  createUserHomeFolder( tenant, username );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:32,代码来源:UIEERepositoryDirectoryIT.java

示例7: service

import org.pentaho.platform.engine.core.system.PentahoSessionHolder; //导入方法依赖的package包/类
@Override protected void service( HttpServletRequest req, HttpServletResponse resp )
    throws ServletException, IOException {

  // We are anonymous for now
  PentahoSessionHolder.setSession( new StandaloneSession( "bob" ) );

  IContentGenerator contentGenerator = (IContentGenerator) applicationContext.getBean( beanId );
  Thread.currentThread().setContextClassLoader( applicationContext.getClassLoader() );

  GeneratorStreamingOutput generatorStreamingOutput = new GeneratorStreamingOutput( contentGenerator,
      new ContentGeneratorDescriptor() {
        @Override public String getContentGeneratorId() {
          return null;
        }

        @Override public String getServicingFileType() {
          return null;
        }

        @Override public String getPluginId() {
          String requestURI = req.getRequestURI();
          if ( requestURI.contains( "/content" ) ) {
            return requestURI.substring( requestURI.indexOf( "/", 1 ) );
          }
          return null;
        }
      },
      req,
      resp,
      Collections.emptyList(),
      null,
      req.getPathInfo() != null ? req.getPathInfo().substring( 1 ) : beanId.substring( beanId.lastIndexOf( "." ) + 1 )
  );

  generatorStreamingOutput.write( resp.getOutputStream(), null );
}
 
开发者ID:pentaho,项目名称:pentaho-osgi-bundles,代码行数:37,代码来源:ContentGeneratorServlet.java

示例8: setUp

import org.pentaho.platform.engine.core.system.PentahoSessionHolder; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
  System.setProperty( "java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory" ); //$NON-NLS-1$ //$NON-NLS-2$
  System.setProperty( "org.osjava.sj.root", SOLUTION_REPOSITORY ); //$NON-NLS-1$ //$NON-NLS-2$
  System.setProperty( "org.osjava.sj.delimiter", "/" ); //$NON-NLS-1$ //$NON-NLS-2$

  System.setProperty( "PENTAHO_SYS_CFG_PATH", new File( SOLUTION_REPOSITORY + "/pentaho.xml" ).getAbsolutePath() ); //$NON-NLS-2$

  IPentahoSession session = new StandaloneSession();
  PentahoSessionHolder.setSession( session );

  pdiContentGenerator = new PdiContentGenerator();

  pdiAction = new PdiAction();
  pdiAction.setRepositoryName( KettleFileRepositoryMeta.REPOSITORY_TYPE_ID );
  pdiContentGenerator.setPdiAction( pdiAction );

  outputStream = mock( OutputStream.class );
  repositoryFile = mock( RepositoryFile.class );
  pdiContentGenerator.setOutputStream( outputStream );
  pdiContentGenerator.setRepositoryFile( repositoryFile );

  scheduler = new QuartzScheduler();
  scheduler.start();

  mp.define( IUserRoleListService.class, StubUserRoleListService.class );
  mp.define( UserDetailsService.class, StubUserDetailService.class );
  mp.defineInstance( IAuthorizationPolicy.class, new TestAuthorizationPolicy() );
  mp.defineInstance( IScheduler.class, scheduler );

  mp.define( ISolutionEngine.class, SolutionEngine.class );
  FileSystemBackedUnifiedRepository repo =  new FileSystemBackedUnifiedRepository( SOLUTION_REPOSITORY );
  mp.defineInstance(  IUnifiedRepository.class, repo );

  mp.start();
}
 
开发者ID:pentaho,项目名称:pdi-platform-plugin,代码行数:37,代码来源:PdiContentGeneratorTest.java

示例9: init

import org.pentaho.platform.engine.core.system.PentahoSessionHolder; //导入方法依赖的package包/类
@Before
public void init() throws SchedulerException, PlatformInitializationException {
  System.setProperty( "java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory" ); //$NON-NLS-1$ //$NON-NLS-2$
  System.setProperty( "org.osjava.sj.root", SOLUTION_REPOSITORY ); //$NON-NLS-1$ //$NON-NLS-2$
  System.setProperty( "org.osjava.sj.delimiter", "/" ); //$NON-NLS-1$ //$NON-NLS-2$
  System.setProperty( "PENTAHO_SYS_CFG_PATH", new File( SOLUTION_REPOSITORY + "/pentaho.xml" ).getAbsolutePath() ); //$NON-NLS-2$

  IPentahoSession session = new StandaloneSession();
  PentahoSessionHolder.setSession( session );

  scheduler = new QuartzScheduler();
  scheduler.start();

  mp.define( IUserRoleListService.class, StubUserRoleListService.class );
  mp.define( UserDetailsService.class, StubUserDetailService.class );
  mp.defineInstance( IAuthorizationPolicy.class, new TestAuthorizationPolicy() );
  mp.setSettingsProvider( new PathBasedSystemSettings() );
  mp.defineInstance( IScheduler.class, scheduler );

  mp.define( ISolutionEngine.class, SolutionEngine.class );
  FileSystemBackedUnifiedRepository repo =  new FileSystemBackedUnifiedRepository( SOLUTION_REPOSITORY );
  mp.defineInstance(  IUnifiedRepository.class, repo );

  mp.start();

  SecurityHelper.getInstance().becomeUser( TEST_USER );
}
 
开发者ID:pentaho,项目名称:pdi-platform-plugin,代码行数:28,代码来源:PdiActionTest.java

示例10: login

import org.pentaho.platform.engine.core.system.PentahoSessionHolder; //导入方法依赖的package包/类
/**
 * Logs in with given username.
 *
 * @param username
 *          username of user
 * @param tenant
 *          tenant to which this user belongs
 * @tenantAdmin true to add the tenant admin authority to the user's roles
 */
protected void login( final String username, final ITenant tenant, String[] roles ) {
  StandaloneSession pentahoSession = new StandaloneSession( username );
  pentahoSession.setAuthenticated( tenant.getId(), username );
  PentahoSessionHolder.setSession( pentahoSession );
  pentahoSession.setAttribute( IPentahoSession.TENANT_ID_KEY, tenant.getId() );

  Authentication auth = PurRepositoryTestingUtils.createAuthentication( username, roles );
  PurRepositoryTestingUtils.setSession( pentahoSession, auth );

  createUserHomeFolder( tenant, username );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:21,代码来源:PurRepositoryIT.java

示例11: loginAsRepositoryAdmin

import org.pentaho.platform.engine.core.system.PentahoSessionHolder; //导入方法依赖的package包/类
private void loginAsRepositoryAdmin() {
  StandaloneSession pentahoSession = new StandaloneSession( repositoryAdminUsername );
  pentahoSession.setAuthenticated( repositoryAdminUsername );
  List<GrantedAuthority> repositoryAdminAuthorities = new ArrayList<>();
  repositoryAdminAuthorities.add( new SimpleGrantedAuthority( superAdminRoleName ) );
  final String password = "ignored";
  UserDetails repositoryAdminUserDetails =
      new User( repositoryAdminUsername, password, true, true, true, true, repositoryAdminAuthorities );
  Authentication repositoryAdminAuthentication =
      new UsernamePasswordAuthenticationToken( repositoryAdminUserDetails, password, repositoryAdminAuthorities );
  PentahoSessionHolder.setSession( pentahoSession );
  // this line necessary for Spring Security's MethodSecurityInterceptor
  SecurityContextHolder.getContext().setAuthentication( repositoryAdminAuthentication );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:15,代码来源:UIEERepositoryDirectoryIT.java

示例12: testDefaultFactoryConnect

import org.pentaho.platform.engine.core.system.PentahoSessionHolder; //导入方法依赖的package包/类
@Test
public void testDefaultFactoryConnect() throws Exception {

  IRepositoryFactory.DefaultRepositoryFactory repositoryFactory = new IRepositoryFactory.DefaultRepositoryFactory();
  repositoryFactory.setRepositoryId( "KettleFileRepository" );

  IPentahoSession session = new StandaloneSession( "joe" );
  PentahoSessionHolder.setSession( session );

  repositoryFactory.connect( "foo" );

}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:13,代码来源:RepositoryFactoryTest.java

示例13: setSession

import org.pentaho.platform.engine.core.system.PentahoSessionHolder; //导入方法依赖的package包/类
/**
 * Sets Hitachi Vantara Session and authentication.
 * 
 * @param session
 *          session
 * @param authentication
 *          authentication
 */
static void setSession( IPentahoSession session, Authentication authentication ) {
  PentahoSessionHolder.setSession( session );
  SecurityContextHolder.getContext().setAuthentication( authentication );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:13,代码来源:PurRepositoryTestingUtils.java


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