@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; } }
repository.connect( PentahoSessionHolder.getSession().getName(), "password" );
log.logDebug( BaseMessages.getString( PKG, "PurRepositoryConnector.ConnectInProgress.Begin" ) ); String name = PentahoSessionHolder.getSession().getName(); user1 = new EEUserInfo(); user1.setLogin( name );
@Override public void onLogout( IPentahoSession iPentahoSession ) { log.debug( "Flushing ACL Entries due to logout for session: " + iPentahoSession.getName() ); flushCachesOfSession( iPentahoSession ); } } );
private static String getUsername() { IPentahoSession pentahoSession = PentahoSessionHolder.getSession(); Assert.state( pentahoSession != null ); return pentahoSession.getName(); }
@Override public boolean hasAccess( RepositoryFile file, RepositoryFilePermission operation, RepositoryFileAcl repositoryFileAcl, IPentahoSession session ) { if ( voters != null && !authorizationPolicy.isAllowed( AdministerSecurityAction.NAME ) && ( session.getName() != null && !session.getName().equals( repositoryAdminUsername ) ) ) { for ( IRepositoryAccessVoter voter : voters ) { if ( !voter.hasAccess( file, operation, repositoryFileAcl, session ) ) { return false; } } } return true; }
@Override public Object getParameter( final String name ) { if ( "name".equals( name ) ) { //$NON-NLS-1$ return session.getName(); } return session.getAttribute( name ); }
@Override protected String getValue( String path ) { // apply templates to the part if ( session != null ) { path = path.replace( "{$user}", session.getName() ); //$NON-NLS-1$ } return SystemSettingsParameterProvider.getSystemSetting( "components/" + path ); //$NON-NLS-1$ }
private List<String> getEffectivePermittedUserList( boolean securityEnabled ) { ArrayList<String> permittedUserList = getPermittedUserList() == null ? new ArrayList<String>() : new ArrayList<String>( getPermittedUserList() ); if ( securityEnabled ) { if ( !permittedUserList.contains( PentahoSessionHolder.getSession().getName() ) ) { permittedUserList.add( PentahoSessionHolder.getSession().getName() ); } } return permittedUserList; }
private String getUserId() { IPentahoSession pentahoSession = PentahoSessionHolder.getSession(); Assert.state( pentahoSession != null, "this method cannot be called with a null IPentahoSession" ); return JcrTenantUtils.getTenantedUser( pentahoSession.getName() ); } }
private List<String> getEffectivePermittedUserList( boolean securityEnabled ) { ArrayList<String> permittedUserList = getPermittedUserList() == null ? new ArrayList<String>() : new ArrayList<String>( getPermittedUserList() ); if ( securityEnabled ) { if ( !permittedUserList.contains( PentahoSessionHolder.getSession().getName() ) ) { permittedUserList.add( PentahoSessionHolder.getSession().getName() ); } } return permittedUserList; }
private void setUserName( String newUserName ) { when( pentahoSession.getName() ).thenReturn( newUserName ); }
public void deleteUserSettings() { String homePath = ClientRepositoryPaths.getUserHomeFolderPath( PentahoSessionHolder.getSession().getName() ); Serializable id = repository.getFile( homePath ).getId(); Map<String, Serializable> fileMetadata = repository.getFileMetadata( id ); Map<String, Serializable> finalMetadata = new HashMap<String, Serializable>( fileMetadata.size() ); for ( Map.Entry<String, Serializable> entry : fileMetadata.entrySet() ) { String key = entry.getKey(); if ( !key.startsWith( SETTING_PREFIX ) ) { finalMetadata.put( key, entry.getValue() ); } } repository.setFileMetadata( id, finalMetadata ); }
private String getUserHomeDirectoryPath() { try { IClientRepositoryPathsStrategy pathsStrategy = PentahoSystem.get( IClientRepositoryPathsStrategy.class, getScheduleCreatorSession() ); return pathsStrategy.getUserHomeFolderPath( getScheduleCreatorSession().getName() ); } catch ( Exception e ) { logger.warn( e.getMessage(), e ); } return null; }
/** * {@inheritDoc} */ public List<RepositoryFile> getDeletedFiles( final Session session, final PentahoJcrConstants pentahoJcrConstants ) throws RepositoryException { String user = PentahoSessionHolder.getSession().getName(); Node trashNode = getOrCreateTrashInternalFolderNode( session, pentahoJcrConstants ); return getDeletedFiles( session, pentahoJcrConstants, trashNode, user ); }
/** {@inheritDoc} */ public Job[] getJobs() throws SchedulerException { IScheduler scheduler = PentahoSystem.get( IScheduler.class, "IScheduler2", null ); //$NON-NLS-1$ IPentahoSession session = PentahoSessionHolder.getSession(); String principalName = session.getName(); Boolean canAdminister = PentahoSystem.get( IAuthorizationPolicy.class ).isAllowed( ADMIN_PERM ); return scheduler.getJobs( job -> { if ( canAdminister ) { return !IBlockoutManager.BLOCK_OUT_JOB_NAME.equals( job.getJobName() ); } return principalName.equals( job.getUserName() ); } ).toArray( new Job[0] ); }
public void testGetSystemInput() { final String USER_NAME = "userName"; IRuntimeContext mockRuntimeContext = mock( IRuntimeContext.class ); IPentahoSession mockSession = mock( IPentahoSession.class ); when( mockRuntimeContext.getSession() ).thenReturn( mockSession ); when( mockSession.getName() ).thenReturn( USER_NAME ); assertEquals( USER_NAME, TemplateUtil.getSystemInput( "$user", mockRuntimeContext ) ); }
/** * @return */ @Override public RepositoryFileAcl createDefaultAcl( RepositoryFile repositoryFile ) { return new RepositoryFileAcl.Builder( PentahoSessionHolder.getSession().getName() ).entriesInheriting( true ) .build(); } }
public static void audit( final IRuntimeContext runtimeContext, final IPentahoSession session, final String messageType, final String message, final String value, final float duration, final ILogger logger ) { String instanceId = ( runtimeContext == null ) ? "" : runtimeContext.getInstanceId(); //$NON-NLS-1$ String userId = session.getName(); String actionName = ( runtimeContext == null ) ? null : runtimeContext.getActionName(); String objectType = ( runtimeContext == null ) ? "" : runtimeContext.getCurrentComponentName(); //$NON-NLS-1$ String processId = ( runtimeContext == null ) ? null : runtimeContext.getProcessId(); AuditHelper.audit( instanceId, userId, actionName, objectType, processId, messageType, message, value, duration, logger ); }
private IRuntimeElement createChild( boolean persisted ) { IRuntimeElement childRuntimeData = null; IRuntimeRepository runtimeRepository = PentahoSystem.get( IRuntimeRepository.class, session ); // the runtime repository is optional if ( runtimeRepository != null ) { runtimeRepository.setLoggingLevel( loggingLevel ); childRuntimeData = runtimeRepository.newRuntimeElement( instanceId, "instance", !persisted ); //$NON-NLS-1$ String childInstanceId = childRuntimeData.getInstanceId(); // audit the creation of this against the parent instance AuditHelper.audit( instanceId, session.getName(), getActionName(), getObjectName(), processId, MessageTypes.INSTANCE_START, childInstanceId, "", 0, this ); //$NON-NLS-1$ } return childRuntimeData; }