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


Java Credential类代码示例

本文整理汇总了Java中org.eclipse.jetty.util.security.Credential的典型用法代码示例。如果您正苦于以下问题:Java Credential类的具体用法?Java Credential怎么用?Java Credential使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Credential类属于org.eclipse.jetty.util.security包,在下文中一共展示了Credential类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: basicAuth

import org.eclipse.jetty.util.security.Credential; //导入依赖的package包/类
private static final SecurityHandler basicAuth(String username, String password, String realm) {

    HashLoginService l = new HashLoginService();
    l.putUser(username, Credential.getCredential(password), new String[] {"user"});
    l.setName(realm);

    Constraint constraint = new Constraint();
    constraint.setName(Constraint.__BASIC_AUTH);
    constraint.setRoles(new String[] {"user"});
    constraint.setAuthenticate(true);

    ConstraintMapping cm = new ConstraintMapping();
    cm.setConstraint(constraint);
    cm.setPathSpec("/*");

    ConstraintSecurityHandler csh = new ConstraintSecurityHandler();
    csh.setAuthenticator(new ProxyAuthenticator());
    csh.setRealmName("myrealm");
    csh.addConstraintMapping(cm);
    csh.setLoginService(l);

    return csh;

  }
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:25,代码来源:Proxy.java

示例2: basicAuth

import org.eclipse.jetty.util.security.Credential; //导入依赖的package包/类
private static final SecurityHandler basicAuth(String username, String password, String realm) {
  HashLoginService l = new HashLoginService();
    l.putUser(username, Credential.getCredential(password), new String[] {"user"});
    l.setName(realm);
    
    Constraint constraint = new Constraint();
    constraint.setName(Constraint.__BASIC_AUTH);
    constraint.setRoles(new String[]{"user"});
    constraint.setAuthenticate(true);
     
    ConstraintMapping cm = new ConstraintMapping();
    cm.setConstraint(constraint);
    cm.setPathSpec("/*");
    
    ConstraintSecurityHandler csh = new ConstraintSecurityHandler();
    csh.setAuthenticator(new BasicAuthenticator());
    csh.setRealmName("myrealm");
    csh.addConstraintMapping(cm);
    csh.setLoginService(l);
    
    return csh;      
}
 
开发者ID:ppkpub,项目名称:javatool,代码行数:23,代码来源:JsonRpcServletEngine.java

示例3: basicAuth

import org.eclipse.jetty.util.security.Credential; //导入依赖的package包/类
private SecurityHandler basicAuth(String username, String password, String realm) {

        HashLoginService l = new HashLoginService();
        l.putUser(username, Credential.getCredential(password), new String[]{"user"});
        l.setName(realm);

        Constraint constraint = new Constraint();
        constraint.setName(Constraint.__BASIC_AUTH);
        constraint.setRoles(new String[]{"user"});
        constraint.setAuthenticate(true);

        ConstraintMapping cm = new ConstraintMapping();
        cm.setConstraint(constraint);
        cm.setPathSpec("/*");

        ConstraintSecurityHandler csh = new ConstraintSecurityHandler();
        csh.setAuthenticator(new BasicAuthenticator());
        csh.setRealmName("myrealm");
        csh.addConstraintMapping(cm);
        csh.setLoginService(l);

        return csh;

    }
 
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:JettyTestServer.java

示例4: basicAuth

import org.eclipse.jetty.util.security.Credential; //导入依赖的package包/类
private SecurityHandler basicAuth(String username, String password, String realm) {
    HashLoginService l = new HashLoginService();
    l.putUser(username, Credential.getCredential(password), new String[]{"user"});
    l.setName(realm);

    Constraint constraint = new Constraint();
    constraint.setName(Constraint.__BASIC_AUTH);
    constraint.setRoles(new String[]{"user"});
    constraint.setAuthenticate(true);

    ConstraintMapping cm = new ConstraintMapping();
    cm.setConstraint(constraint);
    cm.setPathSpec("/*");

    ConstraintSecurityHandler csh = new ConstraintSecurityHandler();
    csh.setAuthenticator(new BasicAuthenticator());
    csh.setRealmName("myrealm");
    csh.addConstraintMapping(cm);
    csh.setLoginService(l);

    return csh;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:JettyTestServer.java

示例5: 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

示例6: loadUsers

import org.eclipse.jetty.util.security.Credential; //导入依赖的package包/类
private void loadUsers() throws ParseException
{
    if (config.users != null)
    {            
        for (String userSpec: config.users)
        {
            String[] tokens = userSpec.split(":|,");
            if (tokens.length < 2)
                throw new ParseException("Invalid user spec: " + userSpec, 0);
            String username = tokens[0].trim();
            String password = tokens[1].trim();
            String[] roles = new String[tokens.length-2];
            for (int i = 0; i < roles.length; i++)
                roles[i] = tokens[i+2].trim();
            loginService.putUser(username, Credential.getCredential(password), roles);
        }
    }
}
 
开发者ID:sensiasoft,项目名称:sensorhub,代码行数:19,代码来源:HttpServer.java

示例7: 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

示例8: basicAuth

import org.eclipse.jetty.util.security.Credential; //导入依赖的package包/类
private static final SecurityHandler basicAuth(String username, String password, String realm) {
	HashLoginService l = new HashLoginService();
    l.putUser(username, Credential.getCredential(password), new String[] {"user"});
    l.setName(realm);
    
    Constraint constraint = new Constraint();
    constraint.setName(Constraint.__BASIC_AUTH);
    constraint.setRoles(new String[]{"user"});
    constraint.setAuthenticate(true);
     
    ConstraintMapping cm = new ConstraintMapping();
    cm.setConstraint(constraint);
    cm.setPathSpec("/*");
    
    ConstraintSecurityHandler csh = new ConstraintSecurityHandler();
    csh.setAuthenticator(new BasicAuthenticator());
    csh.setRealmName("myrealm");
    csh.addConstraintMapping(cm);
    csh.setLoginService(l);
    
    return csh;    	
}
 
开发者ID:newbiecoin,项目名称:newbiecoinj,代码行数:23,代码来源:JsonRpcServletEngine.java

示例9: BasicAuth

import org.eclipse.jetty.util.security.Credential; //导入依赖的package包/类
public BasicAuth() {

        HashLoginService loginService = new HashLoginService();
        loginService.putUser(Main.configuration.username, Credential.getCredential(Main.configuration.password), new String[]{"user"});
        loginService.setName(Main.configuration.realm);

        Constraint constraint = new Constraint();
        constraint.setName(Constraint.__BASIC_AUTH);
        constraint.setRoles(new String[]{"user"});
        constraint.setAuthenticate(true);

        ConstraintMapping cm = new ConstraintMapping();
        cm.setConstraint(constraint);
        cm.setPathSpec("/*");

        // Configure this ConstraintSecurityHandler:
        setAuthenticator(new BasicAuthenticator());
        setRealmName("myrealm");
        addConstraintMapping(cm);
        setLoginService(loginService);
    }
 
开发者ID:davidcarboni,项目名称:restolino,代码行数:22,代码来源:BasicAuth.java

示例10: basicAuth

import org.eclipse.jetty.util.security.Credential; //导入依赖的package包/类
private static final SecurityHandler basicAuth(String username, String password, String realm) {

        HashLoginService l = new HashLoginService();
        l.putUser(username, Credential.getCredential(password), new String[] {"user"});
        l.setName(realm);

        Constraint constraint = new Constraint();
        constraint.setName(Constraint.__BASIC_AUTH);
        constraint.setRoles(new String[]{"user"});
        constraint.setAuthenticate(true);

        ConstraintMapping cm = new ConstraintMapping();
        cm.setConstraint(constraint);
        cm.setPathSpec("/*");

        ConstraintSecurityHandler csh = new ConstraintSecurityHandler();
        csh.setAuthenticator(new BasicAuthenticator());
        csh.setRealmName(realm);
        csh.addConstraintMapping(cm);
        csh.setLoginService(l);

        return csh;

    }
 
开发者ID:lucidworks,项目名称:solr-couchbase-plugin,代码行数:25,代码来源:CAPIServer.java

示例11: newSecurityHandler

import org.eclipse.jetty.util.security.Credential; //导入依赖的package包/类
private ConstraintSecurityHandler newSecurityHandler(ResourceHandler handler) {
	HashLoginService login = new HashLoginService();
	login.putUser(USERNAME, Credential.getCredential(PASSWORD), new String[] { "user" });

	Constraint constraint = new Constraint();
	constraint.setName(Constraint.__BASIC_AUTH);
	constraint.setRoles(new String[] { "user" });
	constraint.setAuthenticate(true);

	ConstraintMapping cm = new ConstraintMapping();
	cm.setConstraint(constraint);
	cm.setPathSpec("/*");

	ConstraintSecurityHandler csh = new ConstraintSecurityHandler();
	csh.setAuthenticator(new BasicAuthenticator());
	csh.addConstraintMapping(cm);
	csh.setLoginService(login);
	csh.setHandler(handler);
	return csh;
}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:21,代码来源:PassBasicHttpAuthTest.java

示例12: basicAuth

import org.eclipse.jetty.util.security.Credential; //导入依赖的package包/类
protected SecurityHandler basicAuth(String username, String password, String realm) {

        HashLoginService l = new HashLoginService();
        l.putUser(username, Credential.getCredential(password), new String[]{"user"});
        l.setName(realm);

        Constraint constraint = new Constraint();
        constraint.setName(Constraint.__BASIC_AUTH);
        constraint.setRoles(new String[]{"user"});
        constraint.setAuthenticate(true);

        ConstraintMapping cm = new ConstraintMapping();
        cm.setConstraint(constraint);
        cm.setPathSpec("/auth/*");

        ConstraintSecurityHandler csh = new ConstraintSecurityHandler();
        csh.setAuthenticator(new BasicAuthenticator());
        csh.setRealmName("myrealm");
        csh.addConstraintMapping(cm);
        csh.setLoginService(l);

        return csh;

    }
 
开发者ID:Arnauld,项目名称:bidij,代码行数:25,代码来源:SampleApp.java

示例13: basicAuth

import org.eclipse.jetty.util.security.Credential; //导入依赖的package包/类
private static SecurityHandler basicAuth(String username, String password, String realm) {
    HashLoginService loginService = new HashLoginService();
    loginService.putUser(username, Credential.getCredential(password), new String[]{"user"});
    loginService.setName(realm);

    Constraint constraint = new Constraint();
    constraint.setName(Constraint.__DIGEST_AUTH);
    constraint.setRoles(new String[]{"user"});
    constraint.setAuthenticate(true);

    ConstraintMapping constraintMapping = new ConstraintMapping();
    constraintMapping.setConstraint(constraint);
    constraintMapping.setPathSpec("/*");

    ConstraintSecurityHandler csh = new ConstraintSecurityHandler();
    csh.setAuthenticator(new BasicAuthenticator());
    csh.setRealmName("realm");
    csh.addConstraintMapping(constraintMapping);
    csh.setLoginService(loginService);
    return csh;
}
 
开发者ID:uwolfer,项目名称:gerrit-rest-java-client,代码行数:22,代码来源:GerritRestClientTest.java

示例14: basicAuthentication

import org.eclipse.jetty.util.security.Credential; //导入依赖的package包/类
static final SecurityHandler basicAuthentication(String realm, String username, String password) {
	HashLoginService loginService = new HashLoginService();
    loginService.setName(realm);
    loginService.putUser(username, Credential.getCredential(password), new String[]{"user"});
    
    Constraint constraint = new Constraint();
    constraint.setName(Constraint.__BASIC_AUTH);
    constraint.setRoles(new String[]{"user"});
    constraint.setAuthenticate(true);
     
    ConstraintMapping constraintMapping = new ConstraintMapping();
    constraintMapping.setConstraint(constraint);
    constraintMapping.setPathSpec("/*");
    
    ConstraintSecurityHandler constraintSecurityHandler = new ConstraintSecurityHandler();
    constraintSecurityHandler.setAuthenticator(new BasicAuthenticator());
    constraintSecurityHandler.setRealmName(realm);
    constraintSecurityHandler.addConstraintMapping(constraintMapping);
    constraintSecurityHandler.setLoginService(loginService);
    
    return constraintSecurityHandler;    	
}
 
开发者ID:beckchr,项目名称:musicmount,代码行数:23,代码来源:MusicMountServerJetty.java

示例15: getSecurityHandler

import org.eclipse.jetty.util.security.Credential; //导入依赖的package包/类
private SecurityHandler getSecurityHandler() {
  Constraint constraint = new Constraint();
  constraint.setName(Constraint.__BASIC_AUTH);
  constraint.setRoles(new String[] { "admin" });
  constraint.setAuthenticate(true);

  ConstraintMapping cm = new ConstraintMapping();
  cm.setConstraint(constraint);
  cm.setPathSpec("/*");

  HashLoginService loginService = new HashLoginService();
  loginService.putUser(username, Credential.getCredential(password), new String[] { "admin" });

  ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
  securityHandler.setRealmName("please password");
  securityHandler.setAuthenticator(new BasicAuthenticator());
  securityHandler.addConstraintMapping(cm);
  securityHandler.setLoginService(loginService);
  securityHandler.setHandler(this);

  return securityHandler;
}
 
开发者ID:BandwidthOnDemand,项目名称:bandwidth-on-demand,代码行数:23,代码来源:MockHttpServer.java


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