public Object get( String name, ObjectFactory objectFactory ) { IPentahoSession session = SpringScopeSessionHolder.SESSION.get(); if ( session == null ) { return null; } Object object = session.getAttribute( name ); if ( object == null ) { object = objectFactory.getObject(); session.setAttribute( name, object ); } return object; }
public void onApplicationEvent( final ApplicationEvent event ) { if ( event instanceof AuthenticationSuccessEvent ) { logger.debug( "received " + event.getClass().getSimpleName() ); //$NON-NLS-1$ logger.debug( "synchronizing current IPentahoSession with SecurityContext" ); //$NON-NLS-1$ try { Authentication authentication = ( (AbstractAuthenticationEvent) event ).getAuthentication(); IPentahoSession pentahoSession = PentahoSessionHolder.getSession(); Assert.notNull( pentahoSession, "PentahoSessionHolder doesn't have a session" ); pentahoSession.setAuthenticated( authentication.getName() ); pentahoSession.setAttribute( IPentahoSession.SESSION_ROLES, authentication.getAuthorities() ); // audit session creation AuditHelper.audit( pentahoSession.getId(), pentahoSession.getName(), pentahoSession.getActionName(), pentahoSession.getObjectName(), "", MessageTypes.SESSION_START, "", "", 0, null ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ logger.info( "The user \"" + pentahoSession.getName() + "\"" + " connected to server with session ID " + pentahoSession.getId() ); } catch ( Exception e ) { logger.error( e.getLocalizedMessage(), e ); } } }
session.setAttribute( interfaceClass.getSimpleName(), object );
public Object getSessionInstance( String key, IPentahoSession session ) throws ObjectFactoryException { if ( null == session ) { throw new IllegalArgumentException( Messages.getInstance().getErrorString( "SessionObjectCreator.ERROR_0001_INVALID_SESSION" ) ); //$NON-NLS-1$ } Object instance = session.getAttribute( key ); if ( ( instance == null ) ) { instance = createObject(); if ( instance instanceof IPentahoInitializer ) { ( (IPentahoInitializer) instance ).init( session ); } session.setAttribute( key, instance ); } return instance; }
if ( tenantId == null ) { ITenant tenant = JcrTenantUtils.getTenant( username, true ); session.setAttribute( IPentahoSession.TENANT_ID_KEY, tenant.getId() );
if ( data != null ) { session.removeAttribute( attributeName ); session.setAttribute( attributeName, data ); session.setAttribute( "StartupActionsFired", true );
/** * Returns the tenant ID of the current user. */ public static ITenant getCurrentTenant() { IPentahoSession pentahoSession = PentahoSessionHolder.getSession(); if ( pentahoSession == null ) { throw new IllegalStateException(); } String tenantId = (String) pentahoSession.getAttribute( IPentahoSession.TENANT_ID_KEY ); if ( tenantId == null ) { ITenantedPrincipleNameResolver tenantedUserNameUtils = PentahoSystem.get( ITenantedPrincipleNameResolver.class, "tenantedUserNameUtils", pentahoSession ); if ( tenantedUserNameUtils != null ) { ITenant tenant = tenantedUserNameUtils.getTenant( pentahoSession.getId() ); pentahoSession.setAttribute( IPentahoSession.TENANT_ID_KEY, tenant.getId() ); return new Tenant( tenant.getId(), true ); } } return new Tenant( tenantId, true ); }
/** * Hi-jacks the system for the named user. <p/> <p> This is for unit tests only. </p> */ @Override public void becomeUser( final String principalName, final IParameterProvider paramProvider ) { UserSession session = null; tenantedUserNameUtils = getTenantedUserNameUtils(); if ( tenantedUserNameUtils != null ) { session = new UserSession( principalName, null, false, paramProvider ); ITenant tenant = tenantedUserNameUtils.getTenant( principalName ); session.setAttribute( IPentahoSession.TENANT_ID_KEY, tenant.getId() ); session.setAuthenticated( tenant.getId(), principalName ); } else { session = new UserSession( principalName, null, false, paramProvider ); session.setAuthenticated( principalName ); } PentahoSessionHolder.setSession( session ); Authentication auth = createAuthentication( principalName ); // TODO We need to figure out how to inject this // Get the tenant id from the principle name and set it as an attribute of the pentaho session // Clearing the SecurityContext to force the subsequent call to getContext() to generate a new SecurityContext. // This prevents us from modifying the Authentication on a SecurityContext isntance which may be shared between // threads. PentahoSessionHolder.getSession().setAttribute( IPentahoSession.SESSION_ROLES, auth.getAuthorities() ); SecurityContextHolder.clearContext(); SecurityContextHolder.getContext().setAuthentication( auth ); PentahoSystem.sessionStartup( PentahoSessionHolder.getSession(), paramProvider ); }
private String getUrl( final String url ) { StringBuffer content = new StringBuffer(); try { // check to see if this URL failed before thia session if ( ( getSession() != null ) && ( getSession().getAttribute( "pentaho-HtmlComponent-failed-url-" + url ) != null ) ) { //$NON-NLS-1$ return errorMessage; } if ( BaseUIComponent.debug ) { debug( Messages.getInstance().getString( "Html.DEBUG_GETTING_CONTENT", url ) ); //$NON-NLS-1$ } if ( HttpUtil.getURLContent( url, content ) ) { return content.toString(); } else { getSession().setAttribute( "pentaho-HtmlComponent-failed-url-" + url, "" ); //$NON-NLS-1$ //$NON-NLS-2$ return errorMessage; } } catch ( Exception e ) { if ( errorMessage != null ) { return errorMessage; } else { error( Messages.getInstance().getErrorString( "Html.ERROR_0001_COULD_NOT_GET_CONTENT", url ) ); //$NON-NLS-1$ return Messages.getInstance().getErrorString( "Html.ERROR_0001_COULD_NOT_GET_CONTENT", url ); //$NON-NLS-1$ } } }
session.setAttribute( TRANS_SESSION_ATTR, trans );
} else { if ( IParameterProvider.SCOPE_SESSION.equals( returnParam.destinationName ) ) { session.setAttribute( returnParam.destinationParameter, returnParam.value ); if ( RuntimeContext.debug ) { debug( paramName + " - session - " + returnParam.destinationParameter ); //$NON-NLS-1$
session.setAttribute( "MONDRIAN_SCHEMA_XML_CONTENT", mondrianSchema ); String catConnectStr = "Provider=mondrian;DataSource=\"" + getMondrianDatasource( domain ) + "\""; //$NON-NLS-1$ addCatalog( catName, catConnectStr, session );
pentahoSession.setAttribute( statsKey, stats ); CsvTransformGenerator csvTransformGenerator = new CsvTransformGenerator( modelInfo, AgileHelper.getDatabaseMeta() );