本文整理匯總了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;
}
示例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);
}
示例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, "");
}
示例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);
}
示例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);
}
示例6: setSession
import org.apache.sshd.server.session.ServerSession; //導入方法依賴的package包/類
@Override
public void setSession(final ServerSession session) {
this.user = session.getAttribute(BaseGitCommand.SUBJECT_KEY);
}