Exemplo n.º 1
0
  public static void removeStoredSession(CredentialsStoreBuilder.StorageType storageType) {
    CredentialsStore storage =
        new CredentialsStoreBuilder()
            .setContext(LiferayScreensContext.getContext())
            .setStorageType(storageType)
            .build();

    checkIfStorageTypeIsSupported(storageType, storage);

    storage.removeStoredCredentials();
  }
Exemplo n.º 2
0
  public static void loadSessionFromStore(CredentialsStoreBuilder.StorageType storageType)
      throws IllegalStateException {

    CredentialsStore storage =
        new CredentialsStoreBuilder()
            .setContext(LiferayScreensContext.getContext())
            .setStorageType(storageType)
            .build();

    checkIfStorageTypeIsSupported(storageType, storage);

    if (storage.loadStoredCredentials()) {
      _session = new SessionImpl(LiferayServerContext.getServer(), storage.getAuthentication());
      _loggedUser = storage.getUser();
    }
  }
Exemplo n.º 3
0
  public static void storeSession(CredentialsStoreBuilder.StorageType storageType) {
    if (!hasSession()) {
      throw new IllegalStateException("You must have a session created to store it");
    }

    CredentialsStore storage =
        new CredentialsStoreBuilder()
            .setContext(LiferayScreensContext.getContext())
            .setAuthentication(_session.getAuthentication())
            .setUser(getLoggedUser())
            .setStorageType(storageType)
            .build();

    checkIfStorageTypeIsSupported(storageType, storage);

    storage.storeCredentials();
  }