本文整理汇总了Java中org.jasig.cas.authentication.UsernamePasswordCredential.getUsername方法的典型用法代码示例。如果您正苦于以下问题:Java UsernamePasswordCredential.getUsername方法的具体用法?Java UsernamePasswordCredential.getUsername怎么用?Java UsernamePasswordCredential.getUsername使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jasig.cas.authentication.UsernamePasswordCredential
的用法示例。
在下文中一共展示了UsernamePasswordCredential.getUsername方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: authenticateUsernamePasswordInternal
import org.jasig.cas.authentication.UsernamePasswordCredential; //导入方法依赖的package包/类
@Override
protected final HandlerResult authenticateUsernamePasswordInternal(final UsernamePasswordCredential credential)
throws GeneralSecurityException, PreventedException {
if (this.kerberosKdcSystemProperty != null) {
logger.debug("Setting kerberos system property {} to {}", SYS_PROP_KERB5_KDC, this.kerberosKdcSystemProperty);
System.setProperty(SYS_PROP_KERB5_KDC, this.kerberosKdcSystemProperty);
}
if (this.kerberosRealmSystemProperty != null) {
logger.debug("Setting kerberos system property {} to {}", SYS_PROP_KRB5_REALM, this.kerberosRealmSystemProperty);
System.setProperty(SYS_PROP_KRB5_REALM, this.kerberosRealmSystemProperty);
}
final String username = credential.getUsername();
final String password = getPasswordEncoder().encode(credential.getPassword());
final LoginContext lc = new LoginContext(
this.realm,
new UsernamePasswordCallbackHandler(username, password));
try {
logger.debug("Attempting authentication for: {}", username);
lc.login();
} finally {
lc.logout();
}
Principal principal = null;
final Set<java.security.Principal> principals = lc.getSubject().getPrincipals();
if (principals != null && !principals.isEmpty()) {
final java.security.Principal secPrincipal = principals.iterator().next();
principal = this.principalFactory.createPrincipal(secPrincipal.getName());
}
return createHandlerResult(credential, principal, null);
}
示例2: doAuthentication
import org.jasig.cas.authentication.UsernamePasswordCredential; //导入方法依赖的package包/类
/**
* {@inheritDoc}
**/
@Override
protected final HandlerResult doAuthentication(final Credential credential)
throws GeneralSecurityException, PreventedException {
final UsernamePasswordCredential userPass = (UsernamePasswordCredential) credential;
if (userPass.getUsername() == null) {
throw new AccountNotFoundException("Username is null.");
}
final String transformedUsername= this.principalNameTransformer.transform(userPass.getUsername());
if (transformedUsername == null) {
throw new AccountNotFoundException("Transformed username is null.");
}
userPass.setUsername(transformedUsername);
return authenticateUsernamePasswordInternal(userPass);
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:19,代码来源:AbstractUsernamePasswordAuthenticationHandler.java
示例3: authenticateUsernamePasswordInternal
import org.jasig.cas.authentication.UsernamePasswordCredential; //导入方法依赖的package包/类
@Override
protected final HandlerResult authenticateUsernamePasswordInternal(final UsernamePasswordCredential credential)
throws GeneralSecurityException, PreventedException {
try {
if (this.fileName == null || !this.fileName.exists()) {
throw new FileNotFoundException("Filename does not exist");
}
final String username = credential.getUsername();
final String passwordOnRecord = getPasswordOnRecord(username);
if (StringUtils.isBlank(passwordOnRecord)) {
throw new AccountNotFoundException(username + " not found in backing file.");
}
final String password = credential.getPassword();
if (StringUtils.isNotBlank(password) && this.getPasswordEncoder().encode(password).equals(passwordOnRecord)) {
return createHandlerResult(credential, this.principalFactory.createPrincipal(username), null);
}
} catch (final IOException e) {
throw new PreventedException("IO error reading backing file", e);
}
throw new FailedLoginException();
}
示例4: authenticateUsernamePasswordInternal
import org.jasig.cas.authentication.UsernamePasswordCredential; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected final HandlerResult authenticateUsernamePasswordInternal(final UsernamePasswordCredential credential)
throws GeneralSecurityException, PreventedException {
final String username = credential.getUsername();
final String encyptedPassword = getPasswordEncoder().encode(credential.getPassword());
final int count;
try {
count = getJdbcTemplate().queryForObject(this.sql, Integer.class, username, encyptedPassword);
} catch (final DataAccessException e) {
throw new PreventedException("SQL exception while executing query for " + username, e);
}
if (count == 0) {
throw new FailedLoginException(username + " not found with SQL query.");
}
return createHandlerResult(credential, this.principalFactory.createPrincipal(username), null);
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:21,代码来源:SearchModeSearchDatabaseAuthenticationHandler.java
示例5: authenticateUsernamePasswordInternal
import org.jasig.cas.authentication.UsernamePasswordCredential; //导入方法依赖的package包/类
@Override
protected final HandlerResult authenticateUsernamePasswordInternal(final UsernamePasswordCredential credential)
throws GeneralSecurityException, PreventedException {
final String username = credential.getUsername();
for (final RadiusServer radiusServer : this.servers) {
logger.debug("Attempting to authenticate {} at {}", username, radiusServer);
try {
if (radiusServer.authenticate(username, credential.getPassword())) {
return createHandlerResult(credential, new SimplePrincipal(username), null);
}
if (!this.failoverOnAuthenticationFailure) {
throw new FailedLoginException();
}
logger.debug("failoverOnAuthenticationFailure enabled -- trying next server");
} catch (final PreventedException e) {
if (!this.failoverOnException) {
throw e;
}
logger.warn("failoverOnException enabled -- trying next server.", e);
}
}
throw new FailedLoginException();
}
示例6: authenticate
import org.jasig.cas.authentication.UsernamePasswordCredential; //导入方法依赖的package包/类
@Override
public HandlerResult authenticate(final Credential credential)
throws GeneralSecurityException, PreventedException {
final UsernamePasswordCredential usernamePasswordCredential = (UsernamePasswordCredential) credential;
final String username = usernamePasswordCredential.getUsername();
final String password = usernamePasswordCredential.getPassword();
final Exception exception = this.usernameErrorMap.get(username);
if (exception instanceof GeneralSecurityException) {
throw (GeneralSecurityException) exception;
} else if (exception instanceof PreventedException) {
throw (PreventedException) exception;
} else if (exception instanceof RuntimeException) {
throw (RuntimeException) exception;
} else if (exception != null) {
logger.debug("Cannot throw checked exception {} since it is not declared by method signature.", exception);
}
if (StringUtils.hasText(username) && StringUtils.hasText(password) && username.equals(password)) {
logger.debug("User [{}] was successfully authenticated.", username);
return new DefaultHandlerResult(this, new BasicCredentialMetaData(credential));
}
logger.debug("User [{}] failed authentication", username);
throw new FailedLoginException();
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:27,代码来源:SimpleTestUsernamePasswordAuthenticationHandler.java
示例7: authenticateUsernamePasswordInternal
import org.jasig.cas.authentication.UsernamePasswordCredential; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected final HandlerResult authenticateUsernamePasswordInternal(final UsernamePasswordCredential credential)
throws GeneralSecurityException, PreventedException {
try {
final String username = credential.getUsername();
final String passwordOnRecord = getPasswordOnRecord(username);
if (StringUtils.isBlank(passwordOnRecord)) {
throw new AccountNotFoundException(username + " not found in backing file.");
}
final String password = credential.getPassword();
if (StringUtils.isNotBlank(password) && this.getPasswordEncoder().encode(password).equals(passwordOnRecord)) {
return createHandlerResult(credential, this.principalFactory.createPrincipal(username), null);
}
} catch (final IOException e) {
throw new PreventedException("IO error reading backing file", e);
}
throw new FailedLoginException();
}
示例8: doAuthentication
import org.jasig.cas.authentication.UsernamePasswordCredential; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
protected final HandlerResult doAuthentication(final Credential credential)
throws GeneralSecurityException, PreventedException {
final UsernamePasswordCredential userPass = (UsernamePasswordCredential) credential;
if (userPass.getUsername() == null) {
throw new AccountNotFoundException("Username is null.");
}
final String transformedUsername= this.principalNameTransformer.transform(userPass.getUsername());
if (transformedUsername == null) {
throw new AccountNotFoundException("Transformed username is null.");
}
userPass.setUsername(transformedUsername);
return authenticateUsernamePasswordInternal(userPass);
}
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:17,代码来源:AbstractUsernamePasswordAuthenticationHandler.java
示例9: authenticate
import org.jasig.cas.authentication.UsernamePasswordCredential; //导入方法依赖的package包/类
@Override
public HandlerResult authenticate(final Credential credential)
throws GeneralSecurityException, PreventedException {
final UsernamePasswordCredential usernamePasswordCredential = (UsernamePasswordCredential) credential;
final String username = usernamePasswordCredential.getUsername();
final String password = usernamePasswordCredential.getPassword();
final Exception exception = this.usernameErrorMap.get(username);
if (exception instanceof GeneralSecurityException) {
throw (GeneralSecurityException) exception;
} else if (exception instanceof PreventedException) {
throw (PreventedException) exception;
} else if (exception instanceof RuntimeException) {
throw (RuntimeException) exception;
} else if (exception != null) {
logger.debug("Cannot throw checked exception {} since it is not declared by method signature.", exception);
}
if (StringUtils.hasText(username) && StringUtils.hasText(password) && username.equals(password)) {
logger.debug("User [{}] was successfully authenticated.", username);
return new DefaultHandlerResult(this, new BasicCredentialMetaData(credential),
this.principalFactory.createPrincipal(username));
}
logger.debug("User [{}] failed authentication", username);
throw new FailedLoginException();
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:28,代码来源:SimpleTestUsernamePasswordAuthenticationHandler.java
示例10: authenticateUsernamePasswordInternal
import org.jasig.cas.authentication.UsernamePasswordCredential; //导入方法依赖的package包/类
@Override
protected final HandlerResult authenticateUsernamePasswordInternal(final UsernamePasswordCredential credential)
throws GeneralSecurityException, PreventedException {
final String username = credential.getUsername();
if (this.users.contains(username)) {
throw new FailedLoginException();
}
return createHandlerResult(credential, this.principalFactory.createPrincipal(username), null);
}
示例11: authenticateUsernamePasswordInternal
import org.jasig.cas.authentication.UsernamePasswordCredential; //导入方法依赖的package包/类
/**
* {@inheritDoc}
* Attempts to authenticate the received credentials using the Yubico cloud validation platform.
* In this implementation, the {@link UsernamePasswordCredential#getUsername()}
* is mapped to the {@code uid} which will be used by the plugged-in instance of the
* {@link YubiKeyAccountRegistry}
* and the {@link UsernamePasswordCredential#getPassword()} is the received
* one-time password token issued by the YubiKey device.
*/
@Override
protected HandlerResult authenticateUsernamePasswordInternal(final UsernamePasswordCredential transformedCredential)
throws GeneralSecurityException, PreventedException {
final String uid = transformedCredential.getUsername();
final String otp = transformedCredential.getPassword();
if (!YubicoClient.isValidOTPFormat(otp)) {
logger.debug("Invalid OTP format [{}]", otp);
throw new FailedLoginException("OTP format is invalid");
}
final String publicId = YubicoClient.getPublicId(otp);
if (this.registry != null
&&!this.registry.isYubiKeyRegisteredFor(uid, publicId)) {
logger.debug("YubiKey public id [{}] is not registered for user [{}]", publicId, uid);
throw new AccountNotFoundException("YubiKey id is not recognized in registry");
}
try {
final VerificationResponse response = this.client.verify(otp);
final ResponseStatus status = response.getStatus();
if (status.compareTo(ResponseStatus.OK) == 0) {
logger.debug("YubiKey response status {} at {}", status, response.getTimestamp());
return createHandlerResult(transformedCredential,
this.principalFactory.createPrincipal(uid), null);
}
throw new FailedLoginException("Authentication failed with status: " + status);
} catch (final YubicoVerificationException | YubicoValidationFailure e) {
logger.error(e.getMessage(), e);
throw new FailedLoginException("YubiKey validation failed: " + e.getMessage());
}
}
示例12: authenticateUsernamePasswordInternal
import org.jasig.cas.authentication.UsernamePasswordCredential; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected final HandlerResult authenticateUsernamePasswordInternal(final UsernamePasswordCredential credential)
throws GeneralSecurityException, PreventedException {
if (this.kerberosKdcSystemProperty != null) {
logger.debug("Setting kerberos system property {} to {}", SYS_PROP_KERB5_KDC, this.kerberosKdcSystemProperty);
System.setProperty(SYS_PROP_KERB5_KDC, this.kerberosKdcSystemProperty);
}
if (this.kerberosRealmSystemProperty != null) {
logger.debug("Setting kerberos system property {} to {}", SYS_PROP_KRB5_REALM, this.kerberosRealmSystemProperty);
System.setProperty(SYS_PROP_KRB5_REALM, this.kerberosRealmSystemProperty);
}
final String username = credential.getUsername();
final String password = getPasswordEncoder().encode(credential.getPassword());
final LoginContext lc = new LoginContext(
this.realm,
new UsernamePasswordCallbackHandler(username, password));
try {
logger.debug("Attempting authentication for: {}", username);
lc.login();
} finally {
lc.logout();
}
Principal principal = null;
final Set<java.security.Principal> principals = lc.getSubject().getPrincipals();
if (principals != null && principals.size() > 0) {
principal = this.principalFactory.createPrincipal(principals.iterator().next().getName());
}
return createHandlerResult(credential, principal, null);
}
示例13: authenticateUsernamePasswordInternal
import org.jasig.cas.authentication.UsernamePasswordCredential; //导入方法依赖的package包/类
@Override
protected final HandlerResult authenticateUsernamePasswordInternal(final UsernamePasswordCredential credential)
throws GeneralSecurityException, PreventedException {
final String password = getPasswordEncoder().encode(credential.getPassword());
final String username = credential.getUsername();
for (final RadiusServer radiusServer : this.servers) {
logger.debug("Attempting to authenticate {} at {}", username, radiusServer);
try {
final RadiusResponse response = radiusServer.authenticate(username, password);
if (response != null) {
return createHandlerResult(credential, this.principalFactory.createPrincipal(username), null);
}
if (!this.failoverOnAuthenticationFailure) {
throw new FailedLoginException("Radius authentication failed for user " + username);
}
logger.debug("failoverOnAuthenticationFailure enabled -- trying next server");
} catch (final PreventedException e) {
if (!this.failoverOnException) {
throw e;
}
logger.warn("failoverOnException enabled -- trying next server.", e);
}
}
throw new FailedLoginException("Radius authentication failed for user " + username);
}
示例14: authenticateUsernamePasswordInternal
import org.jasig.cas.authentication.UsernamePasswordCredential; //导入方法依赖的package包/类
/**
* 认证用户名和密码是否正确
* @see UsernamePasswordCredential参数包含了前台页面输入的用户信息
*/
@Override
protected HandlerResult authenticateUsernamePasswordInternal(UsernamePasswordCredential transformedCredential) throws GeneralSecurityException, PreventedException {
String username = transformedCredential.getUsername();
String password = transformedCredential.getPassword();
if(userDaoJdbc.verifyAccount(username, password)){
return createHandlerResult(transformedCredential, new SimplePrincipal(username), null);
}
throw new FailedLoginException();
}
示例15: authenticateUsernamePasswordInternal
import org.jasig.cas.authentication.UsernamePasswordCredential; //导入方法依赖的package包/类
protected final HandlerResult authenticateUsernamePasswordInternal(final UsernamePasswordCredential credential)
throws GeneralSecurityException, PreventedException {
final String username = credential.getUsername();
if (this.users.contains(username)) {
throw new FailedLoginException();
}
return createHandlerResult(credential, new SimplePrincipal(username), null);
}