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


Java IPentahoSession类代码示例

本文整理汇总了Java中org.pentaho.platform.api.engine.IPentahoSession的典型用法代码示例。如果您正苦于以下问题:Java IPentahoSession类的具体用法?Java IPentahoSession怎么用?Java IPentahoSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: filter

import org.pentaho.platform.api.engine.IPentahoSession; //导入依赖的package包/类
@Override
public String filter(String schemaUrl, Util.PropertyList connectInfo, InputStream stream)
	throws Exception {
		String schema = super.filter(schemaUrl, connectInfo, stream);
		System.out.println("[CUSTOM.DSP] *********** Started DSP Custom ***********");
		IPentahoSession session = PentahoSessionHolder.getSession();
		// if you need only the default Pentaho username session var, not a specific one,
		// you can change the code with: String usercode = session.getName().toString();
		// this avoid to use a startup kettle job
		String usercode = (String) session.getAttribute("USERNAME");
		try {
			System.out.println("[CUSTOM.DSP] Trying to replace '%USER_NAME%' with session value: "+usercode);
			LOG.info("Trying to replace '%USER_NAME%' with session value: "+usercode);
			schema = schema.replaceAll("%USER_NAME%", usercode);
		}
		catch (PatternSyntaxException pse) {
			System.out.println("[CUSTOM.DSP] Some error during custom schema processing: "+usercode);
			LOG.error("Some error during custom schema processing. " , pse);
			pse.printStackTrace();
		}
	LOG.info("DSP Ended correctly for "+usercode);
	System.out.println("[CUSTOM.DSP] *********** DSP Ended correctly for "+usercode+" ***********");
	return schema;
}
 
开发者ID:gioma68,项目名称:mondrian-dsp,代码行数:25,代码来源:DynamicSchemaProcessor.java

示例2: logout

import org.pentaho.platform.api.engine.IPentahoSession; //导入依赖的package包/类
@Override public void logout( HttpServletRequest request, HttpServletResponse response, Authentication auth ) {

    if( request != null && request.getAttribute( SPRING_SECURITY_CONTEXT_KEY ) != null ){
      logger.info( "Removing SPRING_SECURITY_CONTEXT_KEY from HttpServletRequest" );
      request.removeAttribute( SPRING_SECURITY_CONTEXT_KEY );
    }

    IPentahoSession pentahoSession = PentahoSessionHolder.getSession();

    if( pentahoSession != null ) {

      if( pentahoSession.getAttribute( IPentahoSession.SESSION_ROLES ) != null ) {
        logger.info( "Removing IPentahoSession.SESSION_ROLES from IPentahoSession" );
        pentahoSession.removeAttribute( IPentahoSession.SESSION_ROLES );
      }

      logger.info( "Marking IPentahoSession as *not* authenticated" );
      pentahoSession.setNotAuthenticated();
    }
  }
 
开发者ID:pentaho,项目名称:pentaho-engineering-samples,代码行数:21,代码来源:PentahoSamlSingleLogoutHandler.java

示例3: getRepository

import org.pentaho.platform.api.engine.IPentahoSession; //导入依赖的package包/类
@Override public Repository getRepository() {
  IPentahoSession session = pentahoSessionSupplier.get();
  if ( session == null ) {
    LOGGER.debug( "No active Pentaho Session, attempting to load PDI repository unauthenticated." );
    return null;
  }
  ICacheManager cacheManager = cacheManagerFunction.apply( session );

  String sessionName = session.getName();
  Repository repository = (Repository) cacheManager.getFromRegionCache( REGION, sessionName );
  if ( repository == null ) {
    LOGGER.debug( "Repository not cached for user: " + sessionName + "." );
    return null;
  }
  return repository;
}
 
开发者ID:pentaho,项目名称:pentaho-osgi-bundles,代码行数:17,代码来源:PentahoSessionHolderRepositoryProvider.java

示例4: init

import org.pentaho.platform.api.engine.IPentahoSession; //导入依赖的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

示例5: connect

import org.pentaho.platform.api.engine.IPentahoSession; //导入依赖的package包/类
@Override
public Repository connect( String repositoryName ) throws KettleException {

  IPentahoSession session = PentahoSessionHolder.getSession();
  if ( session == null ) {
    logger.debug( "No active Pentaho Session, attempting to load PDI repository unauthenticated." );
    throw new KettleException( "Attempting to create PDI Repository with no Active PentahoSession. "
        + "This is not allowed." );
  }
  ICacheManager cacheManager = PentahoSystem.getCacheManager( session );

  String sessionName = session.getName();
  Repository repository = (Repository) cacheManager.getFromRegionCache( REGION, sessionName );
  if ( repository == null ) {
    logger.debug( "Repository not cached for user: " + sessionName + ". Creating new Repository." );
    repository = delegate.connect( repositoryName );
    if ( !cacheManager.cacheEnabled( REGION ) ) {
      cacheManager.addCacheRegion( REGION );
    }
    cacheManager.putInRegionCache( REGION, sessionName, repository );
  } else {
    logger.debug( "Repository was cached for user: " + sessionName );
  }
  return repository;
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:26,代码来源:IRepositoryFactory.java

示例6: testCachingFactoryConnect

import org.pentaho.platform.api.engine.IPentahoSession; //导入依赖的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

示例7: createUserHomeFolder

import org.pentaho.platform.api.engine.IPentahoSession; //导入依赖的package包/类
private void createUserHomeFolder( final ITenant theTenant, final String theUsername ) {
  IPentahoSession origPentahoSession = PentahoSessionHolder.getSession();
  Authentication origAuthentication = SecurityContextHolder.getContext().getAuthentication();

  String principleId = userNameUtils.getPrincipleId( theTenant, theUsername );
  String authenticatedRoleId = roleNameUtils.getPrincipleId( theTenant, tenantAuthenticatedRole );
  TransactionCallbackWithoutResult callback =
      PurRepositoryTestingUtils.createUserHomeDirCallback( theTenant, theUsername, principleId, authenticatedRoleId,
          repositoryFileDao );
  try {
    loginAsRepositoryAdmin();
    txnTemplate.execute( callback );
  } finally {
    PurRepositoryTestingUtils.setSession( origPentahoSession, origAuthentication );
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:17,代码来源:PurRepositoryTestBase.java

示例8: setUpUser

import org.pentaho.platform.api.engine.IPentahoSession; //导入依赖的package包/类
protected 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 );
  SecurityContextHolder.setStrategyName( SecurityContextHolder.MODE_GLOBAL );
  PurRepositoryTestingUtils.setSession( pentahoSession, authentication );
  repositoryLifecyleManager.newTenant();
  repositoryLifecyleManager.newUser();
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:18,代码来源:PurRepositoryIT.java

示例9: loginAsTenantAdmin

import org.pentaho.platform.api.engine.IPentahoSession; //导入依赖的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

示例10: createUserHomeFolder

import org.pentaho.platform.api.engine.IPentahoSession; //导入依赖的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

示例11: setUpUser

import org.pentaho.platform.api.engine.IPentahoSession; //导入依赖的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

示例12: login

import org.pentaho.platform.api.engine.IPentahoSession; //导入依赖的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

示例13: clearMondrianCache

import org.pentaho.platform.api.engine.IPentahoSession; //导入依赖的package包/类
private boolean clearMondrianCache() {

    try {
      // @see org.pentaho.platform.web.http.api.resources.SystemRefreshResource.flushMondrianSchemaCache();

      IPentahoSession session = PentahoSessionHolder.getSession();

      // Flush the catalog helper (legacy)
      IMondrianCatalogService
          mondrianCatalogService =
          PentahoSystem.get( IMondrianCatalogService.class, "IMondrianCatalogService", session ); //$NON-NLS-1$
      mondrianCatalogService.reInit( session );

      // Flush the IOlapService
      IOlapService olapService = PentahoSystem.get( IOlapService.class, IOlapService.class.getSimpleName(), session );
      olapService.flushAll( session );

    } catch ( Throwable t ) {
      logger.error( t.getMessage(), t );
        /* Do nothing.
         * <p/>
         * This is a simple 'nice-to-have' feature, where we actually clear mondrian cache after the user
         * makes a successful mondrian file change, so that he can immediately see its changes applied.
         * <p/>
         * In some off-chance this doesn't work, user can always do it via PUC > Tools > Refresh > Mondrian Cache.
        */
    }

    return true;
  }
 
开发者ID:webdetails,项目名称:cte,代码行数:31,代码来源:MondrianSchemaProvider.java

示例14: getSessionVariable

import org.pentaho.platform.api.engine.IPentahoSession; //导入依赖的package包/类
public static Object getSessionVariable( String varName ) {
  IPentahoSession session = PentahoSessionHolder.getSession();
  if ( session != null ) {
    return session.getAttribute( varName );
  }
  return null;
}
 
开发者ID:pentaho,项目名称:pdi-platform-utils-plugin,代码行数:8,代码来源:SessionHelper.java

示例15: buildSessionSchemaKey

import org.pentaho.platform.api.engine.IPentahoSession; //导入依赖的package包/类
public static String buildSessionSchemaKey( IPentahoSession session, String schemaUrl )
{
    StringBuilder builder = new StringBuilder();
    builder.append( session.getName() ).append( "/SCHEMA_" );
    builder.append( schemaUrl );
    return builder.toString();
}
 
开发者ID:inquidia,项目名称:KettleDynamicSchemaProcessor,代码行数:8,代码来源:CacheUtils.java


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