當前位置: 首頁>>代碼示例>>Java>>正文


Java ServerSession.getAttribute方法代碼示例

本文整理匯總了Java中org.apache.sshd.server.session.ServerSession.getAttribute方法的典型用法代碼示例。如果您正苦於以下問題:Java ServerSession.getAttribute方法的具體用法?Java ServerSession.getAttribute怎麽用?Java ServerSession.getAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.sshd.server.session.ServerSession的用法示例。


在下文中一共展示了ServerSession.getAttribute方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: validateIdentity

import org.apache.sshd.server.session.ServerSession; //導入方法依賴的package包/類
@Override
public boolean validateIdentity(ServerSession session, String identity) {
  final SshSession sd = session.getAttribute(SshSession.KEY);
  int at = identity.indexOf('@');
  String username;
  if (at == -1) {
    username = identity;
  } else {
    username = identity.substring(0, at);
  }
  if (config.getBoolean("auth", "userNameToLowerCase", false)) {
    username = username.toLowerCase(Locale.US);
  }
  AccountState state = accounts.getByUsername(username);
  Account account = state == null ? null : state.getAccount();
  boolean active = account != null && account.isActive();
  if (active) {
    return SshUtil.success(
        username,
        session,
        sshScope,
        sshLog,
        sd,
        SshUtil.createUser(sd, userFactory, account.getId()));
  }
  return false;
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:28,代碼來源:GerritGSSAuthenticator.java

示例2: setSession

import org.apache.sshd.server.session.ServerSession; //導入方法依賴的package包/類
@Override
public void setSession(final ServerSession session) {
    final String username = session.getAttribute(OpenEJBJaasPasswordAuthenticator.USERNAME_KEY);
    if (username == null) {
        throw new IllegalStateException("No username in the session");
    }

    setUsername(username);
    loginContext = session.getAttribute(OpenEJBJaasPasswordAuthenticator.LOGIN_CONTEXT_KEY);
}
 
開發者ID:apache,項目名稱:tomee,代碼行數:11,代碼來源:OpenEJBCommands.java

示例3: setSession

import org.apache.sshd.server.session.ServerSession; //導入方法依賴的package包/類
@Override
public void setSession(ServerSession session) {
  SshSession s = session.getAttribute(SshSession.KEY);
  this.context = sshScope.newContext(schemaFactory, s, "");
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:6,代碼來源:NoShell.java

示例4: authenticate

import org.apache.sshd.server.session.ServerSession; //導入方法依賴的package包/類
@Override
public boolean authenticate(String username, PublicKey suppliedKey, ServerSession session) {
  SshSession sd = session.getAttribute(SshSession.KEY);
  Preconditions.checkState(sd.getUser() == null);
  if (PeerDaemonUser.USER_NAME.equals(username)) {
    if (myHostKeys.contains(suppliedKey) || getPeerKeys().contains(suppliedKey)) {
      PeerDaemonUser user = peerFactory.create(sd.getRemoteAddress());
      return SshUtil.success(username, session, sshScope, sshLog, sd, user);
    }
    sd.authenticationError(username, "no-matching-key");
    return false;
  }

  if (config.getBoolean("auth", "userNameToLowerCase", false)) {
    username = username.toLowerCase(Locale.US);
  }

  Iterable<SshKeyCacheEntry> keyList = sshKeyCache.get(username);
  SshKeyCacheEntry key = find(keyList, suppliedKey);
  if (key == null) {
    String err;
    if (keyList == SshKeyCacheImpl.NO_SUCH_USER) {
      err = "user-not-found";
    } else if (keyList == SshKeyCacheImpl.NO_KEYS) {
      err = "key-list-empty";
    } else {
      err = "no-matching-key";
    }
    sd.authenticationError(username, err);
    return false;
  }

  // Double check that all of the keys are for the same user account.
  // This should have been true when the cache factory method loaded
  // the list into memory, but we want to be extra paranoid about our
  // security check to ensure there aren't two users sharing the same
  // user name on the server.
  //
  for (SshKeyCacheEntry otherKey : keyList) {
    if (!key.getAccount().equals(otherKey.getAccount())) {
      sd.authenticationError(username, "keys-cross-accounts");
      return false;
    }
  }

  IdentifiedUser cu = SshUtil.createUser(sd, userFactory, key.getAccount());
  if (!cu.getAccount().isActive()) {
    sd.authenticationError(username, "inactive-account");
    return false;
  }

  return SshUtil.success(username, session, sshScope, sshLog, sd, cu);
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:54,代碼來源:DatabasePubKeyAuth.java

示例5: setSession

import org.apache.sshd.server.session.ServerSession; //導入方法依賴的package包/類
@Override
public void setSession(ServerSession session) {
  final SshSession s = session.getAttribute(SshSession.KEY);
  this.ctx = sshScope.newContext(schemaFactory, s, commandLine);
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:6,代碼來源:CommandFactoryProvider.java

示例6: setSession

import org.apache.sshd.server.session.ServerSession; //導入方法依賴的package包/類
@Override
public void setSession(final ServerSession session) {
    this.user = session.getAttribute(BaseGitCommand.SUBJECT_KEY);
}
 
開發者ID:kiegroup,項目名稱:appformer,代碼行數:5,代碼來源:BaseGitCommand.java


注:本文中的org.apache.sshd.server.session.ServerSession.getAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。