Package org.pentaho.platform.engine.core.system

Examples of org.pentaho.platform.engine.core.system.StandaloneSession


  @Override
  public <T> T runAsAnonymous( final Callable<T> callable ) throws Exception {
    IPentahoSession origSession = PentahoSessionHolder.getSession();
    Authentication origAuth = SecurityContextHolder.getContext().getAuthentication();
    try {
      PentahoSessionHolder.setSession( new StandaloneSession() );

      // get anonymous username/role defined in pentaho.xml
      String user = PentahoSystem
        .getSystemSetting( "anonymous-authentication/anonymous-user", "anonymousUser" ); //$NON-NLS-1$//$NON-NLS-2$
      String role = PentahoSystem
View Full Code Here


    String singleTenantAdmin = PentahoSystem.get( String.class, "singleTenantAdminUserName", null );
    IPentahoSession origSession = PentahoSessionHolder.getSession();

    Authentication origAuth = SecurityContextHolder.getContext().getAuthentication();

    StandaloneSession session = null;
    try {
      session = new StandaloneSession( singleTenantAdmin );
      session.setAuthenticated( singleTenantAdmin );

      // Set the session first or else the call to
      // createAuthentication will fail
      PentahoSessionHolder.setSession( session );

      // Now create the authentication
      Authentication auth = createAuthentication( singleTenantAdmin ); //$NON-NLS-1$
      SecurityContextHolder.getContext().setAuthentication( auth );

      // Invoke the delta.
      return callable.call();
    } finally {
      // Make sure to destroy the system session so we don't leak anything.
      if ( session != null ) {
        try {
          session.destroy();
        } catch ( Exception e ) {
          // We can safely ignore this.
          e.printStackTrace();
        }
      }
View Full Code Here

      tenantManager.deleteTenant( tenant );
    }
  }

  protected void loginAsRepositoryAdmin() {
    StandaloneSession pentahoSession = new StandaloneSession( repositoryAdminUsername );
    pentahoSession.setAuthenticated( repositoryAdminUsername );
    final GrantedAuthority[] repositoryAdminAuthorities =
        new GrantedAuthority[]{new GrantedAuthorityImpl( sysAdminRoleName )};
    final String password = "ignored";
    UserDetails repositoryAdminUserDetails =
        new User( repositoryAdminUsername, password, true, true, true, true, repositoryAdminAuthorities );
View Full Code Here

    PentahoSessionHolder.removeSession();
    SecurityContextHolder.getContext().setAuthentication( null );
  }

  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() );
    final String password = "password";

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

    for ( String roleName : roles ) {
View Full Code Here

    // This should succeed
    String url = "http://www.pentaho.org/demo/news.html"; //$NON-NLS-1$
    SimpleUrlFactory urlFactory = new SimpleUrlFactory( "/testurl?" ); //$NON-NLS-1$
    ArrayList messages = new ArrayList();
    HtmlComponent component = new HtmlComponent( HtmlComponent.TYPE_URL, url, "", urlFactory, messages ); //$NON-NLS-1$
    StandaloneSession session =
        new StandaloneSession( Messages.getInstance().getString( "BaseTest.DEBUG_JUNIT_SESSION" ) ); //$NON-NLS-1$
    try {
      OutputStream outputStream = getOutputStream( "HTMLComponentTest.testComponent1", ".html" ); //$NON-NLS-1$//$NON-NLS-2$
      component.validate( session, null );
      String content = component.getContent( "text/html" ); //$NON-NLS-1$
      outputStream.write( content.getBytes() );
View Full Code Here

    SimpleParameterProvider sessionParameters = new SimpleParameterProvider();

    HashMap parameterProviders = new HashMap();
    parameterProviders.put( IParameterProvider.SCOPE_REQUEST, requestParameters );
    parameterProviders.put( IParameterProvider.SCOPE_SESSION, sessionParameters );
    StandaloneSession session =
        new StandaloneSession( Messages.getInstance().getString( "BaseTest.DEBUG_JUNIT_SESSION" ) ); //$NON-NLS-1$

    SimpleOutputHandler outputHandler = new SimpleOutputHandler( outputStream, false );
    BaseRequestHandler requestHandler = new BaseRequestHandler( session, null, outputHandler, null, urlFactory );

    try {
View Full Code Here

    SimpleParameterProvider sessionParameters = new SimpleParameterProvider();

    HashMap parameterProviders = new HashMap();
    parameterProviders.put( IParameterProvider.SCOPE_REQUEST, requestParameters );
    parameterProviders.put( IParameterProvider.SCOPE_SESSION, sessionParameters );
    StandaloneSession session =
        new StandaloneSession( Messages.getInstance().getString( "BaseTest.DEBUG_JUNIT_SESSION" ) ); //$NON-NLS-1$

    SimpleOutputHandler outputHandler = new SimpleOutputHandler( outputStream, false );
    BaseRequestHandler requestHandler = new BaseRequestHandler( session, null, outputHandler, null, urlFactory );

    try {
View Full Code Here

public class AggregateObjectFactoryTest {

  @Test
  public void testByKey() throws Exception {

    StandaloneSession session = new StandaloneSession();
    StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory();
    factory.init( "test-res/solution/system/pentahoObjects.spring.xml", null );

    AggregateObjectFactory aggFactory = new AggregateObjectFactory();
    aggFactory.registerObjectFactory( factory );
View Full Code Here

  }

  @Test
  public void testCombined() throws Exception {

    StandaloneSession session = new StandaloneSession();
    StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory();

    ConfigurableApplicationContext context =
      new FileSystemXmlApplicationContext( "test-res/solution/system/pentahoObjects.spring.xml" );
View Full Code Here

  }

  @Test
  public void testRePublish() throws Exception {

    StandaloneSession session = new StandaloneSession();
    StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory();
    factory.init( "test-res/solution/system/republish.spring.xml", null );

    PentahoSystem.registerObjectFactory( factory );
View Full Code Here

TOP

Related Classes of org.pentaho.platform.engine.core.system.StandaloneSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.