Exemplo n.º 1
0
  /**
   * Performs a logout operation by making a remote request based on the Sessions service URL.
   *
   * @param session Session to logout.
   */
  public void logout(Session session) throws SessionException {
    if (debug.messageEnabled()) {
      debug.message(MessageFormat.format("Remote logout {0}", session.getID().toString()));
    }

    SessionRequest sreq =
        new SessionRequest(SessionRequest.Logout, session.getID().toString(), false);
    requests.sendRequestWithRetry(session.getSessionServiceURL(), sreq, session);
  }
Exemplo n.º 2
0
  /**
   * Destroys the Session via the Session remote service URL.
   *
   * @param requester {@inheritDoc}
   * @param session {@inheritDoc}
   * @throws SessionException {@inheritDoc}
   */
  public void destroy(Session requester, Session session) throws SessionException {
    if (debug.messageEnabled()) {
      debug.message(MessageFormat.format("Remote destroy {0}", session));
    }

    SessionRequest sreq =
        new SessionRequest(SessionRequest.DestroySession, requester.getID().toString(), false);
    sreq.setDestroySessionID(session.getID().toString());
    requests.sendRequestWithRetry(session.getSessionServiceURL(), sreq, session);
  }
Exemplo n.º 3
0
  /**
   * Perform a remote setProperty on the Session using the remote Service URL.
   *
   * <p>{@inheritDoc}
   */
  public void setProperty(Session session, String name, String value) throws SessionException {
    if (debug.messageEnabled()) {
      debug.message(MessageFormat.format("Remote setProperty {0} {1}={2}", session, name, value));
    }

    SessionID sessionID = session.getID();
    SessionRequest sreq =
        new SessionRequest(SessionRequest.SetProperty, sessionID.toString(), false);
    sreq.setPropertyName(name);
    sreq.setPropertyValue(value);
    if (SystemProperties.isServerMode() && InternalSession.isProtectedProperty(name)) {
      try {
        SSOToken admSSOToken = SessionUtils.getAdminToken();
        sreq.setRequester(RestrictedTokenContext.marshal(admSSOToken));
      } catch (SSOException e) {
        throw new SessionException(e);
      } catch (Exception e) {
        throw new SessionException(e);
      }

      if (debug.messageEnabled()) {
        debug.message(
            "Session.setProperty: "
                + "added admSSOToken in sreq to set "
                + "externalProtectedProperty in remote server");
      }
    }
    requests.sendRequestWithRetry(session.getSessionServiceURL(), sreq, session);
  }
Exemplo n.º 4
0
  private void initAuthSessions() throws SSOException, SessionException {
    if (authSession == null) {
      authSession = getSS().getAuthenticationSession(defaultOrg, null);
      if (authSession == null) {
        debug.error("AuthD failed to get auth session");
        throw new SessionException(BUNDLE_NAME, "gettingSessionFailed", null);
      }

      String clientID = authSession.getClientID();
      authSession.setProperty("Principal", clientID);
      authSession.setProperty("Organization", defaultOrg);
      authSession.setProperty("Host", authSession.getID().getSessionServer());
      DN dn = new DN(clientID);
      if (dn.isDN()) {
        String[] tokens = dn.explodeDN(true);
        String id = "id=" + tokens[0] + ",ou=user," + ServiceManager.getBaseDN();
        authSession.setProperty(Constants.UNIVERSAL_IDENTIFIER, id);
      }
      SSOTokenManager ssoManager = SSOTokenManager.getInstance();
      ssoAuthSession = ssoManager.createSSOToken(authSession.getID().toString());
    }
  }
Exemplo n.º 5
0
  /**
   * @param session The Session to update.
   * @param reset If true, then update the last modified timestamp of the Session.
   * @return
   * @throws SessionException
   */
  public SessionInfo refresh(Session session, boolean reset) throws SessionException {
    SessionID sessionID = session.getID();
    if (debug.messageEnabled()) {
      debug.message(
          MessageFormat.format(
              "Remote fetch SessionInfo for {0}\n" + "Reset: {1}", sessionID, reset));
    }

    SessionRequest sreq =
        new SessionRequest(SessionRequest.GetSession, sessionID.toString(), reset);
    SessionResponse sres =
        requests.sendRequestWithRetry(session.getSessionServiceURL(), sreq, session);

    if (sres.getException() != null) {
      throw new SessionException(SessionBundle.rbName, INVALID_SESSION_STATE, null);
    }

    List<SessionInfo> infos = sres.getSessionInfo();
    if (infos.size() != 1) {
      throw new SessionException(SessionBundle.rbName, UNEXPECTED_SESSION, null);
    }
    return infos.get(0);
  }