当前位置: 首页>>代码示例>>Java>>正文


Java Credential.getCredential方法代码示例

本文整理汇总了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);
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:30,代码来源:LdapLoginModule.java

示例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;
}
 
开发者ID:SignalK,项目名称:signalk-server-java,代码行数:23,代码来源:SignalkLoginService.java

示例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);

}
 
开发者ID:dstl,项目名称:baleen,代码行数:40,代码来源:BaleenWebApi.java

示例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));
    }
}
 
开发者ID:jitlogic,项目名称:zico,代码行数:13,代码来源:ZicoLoginService.java

示例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;
}
 
开发者ID:jitlogic,项目名称:zico,代码行数:6,代码来源:ZicoUser.java


注:本文中的org.eclipse.jetty.util.security.Credential.getCredential方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。