Follow me to learn shiro as a tutorial in Chapter 2. 2. 2. There is a question, how do you get two identity information?

original code:

`ini configuration file (shiro-authenticator-all-success.ini)

Java Code

< H1 > specify the authenticator implementation of securityManager < / H1 >

authenticator=org.apache.shiro.authc.pam.ModularRealmAuthenticator
securityManager.authenticator=$authenticator

< H1 > specify the authenticationStrategy of securityManager.authenticator < / H1 >

allSuccessfulStrategy=org.apache.shiro.authc.pam.AllSuccessfulStrategy
securityManager.authenticator.authenticationStrategy=$allSuccessfulStrategy
Java Code Collection Code
myRealm1=com.github.zhangkaitao.shiro.chapter2.realm.MyRealm1
myRealm2=com.github.zhangkaitao.shiro.chapter2.realm.MyRealm2
myRealm3=com.github.zhangkaitao.shiro.chapter2.realm.MyRealm3
securityManager.realms=$myRealm1,$myRealm3 `

2.1 

Java  
private void login(String configFile) {  
    //1SecurityManagerIniSecurityManager  
    Factory<org.apache.shiro.mgt.SecurityManager> factory =  
            new IniSecurityManagerFactory(configFile);  
  
    //2SecurityManager SecurityUtils  
    org.apache.shiro.mgt.SecurityManager securityManager = factory.getInstance();  
    SecurityUtils.setSecurityManager(securityManager);  
  
    //3Subject/Token/  
    Subject subject = SecurityUtils.getSubject();  
    UsernamePasswordToken token = new UsernamePasswordToken("zhang", "123");  
  
    subject.login(token);  
}
2.2AllSuccessfulStrategy:    

Java  
@Test  
public void testAllSuccessfulStrategyWithSuccess() {  
    login("classpath:shiro-authenticator-all-success.ini");  
    Subject subject = SecurityUtils.getSubject();  
  
    //Realm  
    PrincipalCollection principalCollection = subject.getPrincipals();  
    Assert.assertEquals(2, principalCollection.asList().size());  
} 
PrincipalCollectionzhangzhang@163.com
I also got down the code on

github, which is indeed two pieces of identity information, but how can I write one along with it? Without that zhangsan@163.comzhe"tiao

original link

my own:

/**
     * 
     */
    private void login(String configFile) {
        //
        Factory<SecurityManager> factory = new IniSecurityManagerFactory(configFile);
        //securityManagersecurityUtils
        SecurityManager securityManager = factory.getInstance();
        SecurityUtils.setSecurityManager(securityManager);
        //subjecttoken
        Subject subject = SecurityUtils.getSubject();
        UsernamePasswordToken token = new UsernamePasswordToken("zhangsan", "123");
        //
        subject.login(token);
    }

    /**
     * AllSuccessfulStrategy
     */
    @Test
    public void testAllSuccessfulStrategyWithFail() {
        login("classpath:shiro-authenticator-all-success.ini");
        Subject subject = SecurityUtils.getSubject();
        //,realm
        PrincipalCollection principals = subject.getPrincipals();
        List list = principals.asList();
    }
[main]
-sharpsecurityManagerauthenticator
authenticator=org.apache.shiro.authc.pam.ModularRealmAuthenticator
securityManager.authenticator=$authenticator

-sharpsecurityManager.authenticatorauthenticationStrategy
allSuccessfulStrategy=org.apache.shiro.authc.pam.AllSuccessfulStrategy
securityManager.authenticator.authenticationStrategy=$allSuccessfulStrategy

myRealm1=com.rxiao.demo2.L2_MyRealm1
myRealm2=com.rxiao.demo2.L3_MyRealm2
myRealm3=com.rxiao.demo2.L4_MyRealm3
securityManager.realms=$myRealm1,$myRealm3
Apr.03,2021

the getAuthenticationInfo method overridden in the custom MyRealm3 ends return new SimpleAuthenticationInfo (username + "@ 163.com", password, getName ()); here, only one is returned if the username of multiple realm is the same, and

is returned if it is not the same.
Menu