當前位置: 首頁>>代碼示例>>Java>>正文


Java ConstraintSecurityHandler.setRealmName方法代碼示例

本文整理匯總了Java中org.eclipse.jetty.security.ConstraintSecurityHandler.setRealmName方法的典型用法代碼示例。如果您正苦於以下問題:Java ConstraintSecurityHandler.setRealmName方法的具體用法?Java ConstraintSecurityHandler.setRealmName怎麽用?Java ConstraintSecurityHandler.setRealmName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jetty.security.ConstraintSecurityHandler的用法示例。


在下文中一共展示了ConstraintSecurityHandler.setRealmName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: basicAuth

import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的package包/類
private static final SecurityHandler basicAuth(String realm)
{
	HashLoginService l = new HashLoginService();
	l.setConfig(new File(PlatformData.installationDirectory, "webusers.properties").getAbsolutePath());
	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("/ui/*");
	ConstraintSecurityHandler csh = new ConstraintSecurityHandler();
	csh.setAuthenticator(new BasicAuthenticator());
	csh.setRealmName("myrealm");
	csh.addConstraintMapping(cm);
	csh.setLoginService(l);
	return csh;
}
 
開發者ID:PolyphasicDevTeam,項目名稱:NoMoreOversleeps,代碼行數:20,代碼來源:WebServer.java

示例2: InMemoryIdentityManager

import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的package包/類
public InMemoryIdentityManager() {
	loginService = new HashLoginService();
	loginService.setName(realm);

	securityHandler = new ConstraintSecurityHandler();
	securityHandler.setAuthenticator(new BasicAuthenticator());
	securityHandler.setRealmName(realm);
	securityHandler.setLoginService(loginService);

	Constraint constraint = new Constraint();
	constraint.setName(Constraint.__BASIC_AUTH);
	//		constraint.setRoles(new String[] { "getRole", "postRole", "allRole" });
	constraint.setRoles(new String[]{Constraint.ANY_AUTH, "getRole", "postRole", "allRole"});
	constraint.setAuthenticate(true);

	ConstraintMapping cm = new ConstraintMapping();
	cm.setConstraint(constraint);
	cm.setPathSpec("/*");
	securityHandler.addConstraintMapping(cm);
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:21,代碼來源:InMemoryIdentityManager.java

示例3: basicAuth

import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的package包/類
private static final SecurityHandler basicAuth(String realm) {

    	final OfMeetLoginService loginService = new OfMeetLoginService();
        loginService.setName(realm);

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

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

        final ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
        securityHandler.setAuthenticator( new BasicAuthenticator() );
        securityHandler.setRealmName( realm );
        securityHandler.addConstraintMapping( constraintMapping );
        securityHandler.setLoginService( loginService );

        return securityHandler;
    }
 
開發者ID:igniterealtime,項目名稱:ofmeet-openfire-plugin,代碼行數:23,代碼來源:OfMeetPlugin.java

示例4: configureCommonAuthentication

import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的package包/類
protected ConstraintSecurityHandler configureCommonAuthentication(Server server,
    ServerConnector connector, AvaticaServerConfiguration config, String constraintName,
    String[] allowedRoles, Authenticator authenticator, String realm,
    LoginService loginService) {

  Constraint constraint = new Constraint();
  constraint.setName(constraintName);
  constraint.setRoles(allowedRoles);
  // This is telling Jetty to not allow unauthenticated requests through (very important!)
  constraint.setAuthenticate(true);

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

  ConstraintSecurityHandler sh = new ConstraintSecurityHandler();
  sh.setAuthenticator(authenticator);
  sh.setLoginService(loginService);
  sh.setConstraintMappings(new ConstraintMapping[]{cm});
  sh.setRealmName(realm);

  return sh;
}
 
開發者ID:apache,項目名稱:calcite-avatica,代碼行數:24,代碼來源:HttpServer.java

示例5: basicAuth

import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的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

示例6: basicAuth

import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的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

示例7: basicAuth

import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的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

示例8: basicAuth

import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的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

示例9: basicAuth

import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的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

示例10: basicAuth

import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的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: basicAuth

import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的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

示例12: basicAuth

import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的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

示例13: createSecurityHandler

import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的package包/類
static ConstraintSecurityHandler createSecurityHandler(String realm, List<String> roles) {
  final ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
  Constraint constraint = new Constraint();
  constraint.setAuthenticate(true);
  constraint.setRoles(roles.toArray(new String[0]));
  ConstraintMapping constraintMapping = new ConstraintMapping();
  constraintMapping.setConstraint(constraint);
  constraintMapping.setMethod("*");
  constraintMapping.setPathSpec("/*");
  securityHandler.addConstraintMapping(constraintMapping);
  securityHandler.setAuthenticator(new BasicAuthenticator());
  securityHandler.setLoginService(new JAASLoginService(realm));
  securityHandler.setIdentityService(new DefaultIdentityService());
  securityHandler.setRealmName(realm);
  return securityHandler;
}
 
開發者ID:confluentinc,項目名稱:rest-utils,代碼行數:17,代碼來源:Application.java

示例14: basicAuthentication

import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的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.security.ConstraintSecurityHandler; //導入方法依賴的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.security.ConstraintSecurityHandler.setRealmName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。