本文整理汇总了Java中org.eclipse.jetty.util.security.Credential.getCredential方法的典型用法代码示例。如果您正苦于以下问题:Java Credential.getCredential方法的具体用法?Java Credential.getCredential怎么用?Java Credential.getCredential使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.util.security.Credential
的用法示例。
在下文中一共展示了Credential.getCredential方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUserInfo
import org.eclipse.jetty.util.security.Credential; //导入方法依赖的package包/类
/**
* get the available information about the user
* <p/>
* for this LoginModule, the credential can be null which will result in a
* binding ldap authentication scenario
* <p/>
* roles are also an optional concept if required
*
* @param username
* @return the userinfo for the username
* @throws Exception
*/
@Override
public UserInfo getUserInfo(String username) throws Exception
{
LdapEntry entry = getEntryWithCredential(username);
if (entry == null)
{
return null;
}
String pwdCredential = getUserCredential(entry);
pwdCredential = convertCredentialLdapToJetty(pwdCredential);
Credential credential = Credential.getCredential(pwdCredential);
List<String> roles = getUserRoles(username, entry.getDn());
return new UserInfo(username, credential, roles);
}
示例2: login
import org.eclipse.jetty.util.security.Credential; //导入方法依赖的package包/类
@Override
public UserIdentity login(String username, Object creds) {
UserIdentity user = null;
// HERE IS THE HARDCODING
boolean validUser = "admin".equals(username) && "s3cr3t".equals(creds);
if (validUser) {
Credential credential = (creds instanceof Credential)?(Credential)creds:Credential.getCredential(creds.toString());
Principal userPrincipal = new MappedLoginService.KnownUser(username,credential);
Subject subject = new Subject();
subject.getPrincipals().add(userPrincipal);
subject.getPrivateCredentials().add(creds);
subject.setReadOnly();
user=identityService.newUserIdentity(subject,userPrincipal, ACCESS_ROLE);
users.put(user.getUserPrincipal().getName(), true);
}
return (user != null) ? user : null;
}
示例3: configureServer
import org.eclipse.jetty.util.security.Credential; //导入方法依赖的package包/类
private void configureServer(Server server, WebAuthConfig authConfig,
Handler servletHandler) throws BaleenException {
Handler serverHandler;
if (authConfig == null || authConfig.getType() == AuthType.NONE) {
LOGGER.warn("No security applied to API");
// No security
serverHandler = servletHandler;
} else if (authConfig.getType() == AuthType.BASIC) {
// Basic authentication
LOGGER.info("Using Basic HTTP authentication for API");
HashLoginService loginService = new HashLoginService(
authConfig.getName());
for (WebUser user : authConfig.getUsers()) {
Credential credential = Credential.getCredential(user
.getPassword());
loginService.putUser(user.getUsername(), credential,
user.getRolesAsArray());
}
server.addBean(loginService);
ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
securityHandler.setHandler(servletHandler);
securityHandler.setConstraintMappings(constraintMappings);
securityHandler.setAuthenticator(new BasicAuthenticator());
securityHandler.setLoginService(loginService);
serverHandler = securityHandler;
} else {
throw new InvalidParameterException(
"Configuration of authentication failed");
}
server.setHandler(serverHandler);
}
示例4: update
import org.eclipse.jetty.util.security.Credential; //导入方法依赖的package包/类
public void update(String username, String credentials, Boolean isAdmin) {
String[] roleArray = isAdmin ? new String[] { "ADMIN", "VIEWER" } : new String[] { "VIEWER" };
Credential credential = Credential.getCredential(credentials);
Principal userPrincipal = new KnownUser(username,credential);
Subject subject = new Subject();
subject.getPrincipals().add(userPrincipal);
subject.getPrivateCredentials().add(credential);
_users.put(username, _identityService.newUserIdentity(subject,userPrincipal,roleArray));
for (String role : roleArray) {
subject.getPrincipals().add(new RolePrincipal(role));
}
}
示例5: ZicoUser
import org.eclipse.jetty.util.security.Credential; //导入方法依赖的package包/类
public ZicoUser(String username, String password, boolean admin) {
this.username = username;
credential = Credential.getCredential(password != null ? password : "");
this.admin = admin;
}