@Override
    public String map(String authcid) {
        if(authcid.contains("@")) {
            String realm = authcid.substring(authcid.lastIndexOf('@')+1);
            String authzid = authcid.substring(0,authcid.lastIndexOf('@'));

            if(!realm.isEmpty()) {
                if(realm.equals(XMPPServerInfo.XMPP_DOMAIN.getValue())) {
                    Log.debug("DefaultAuthorizationMapping: realm = " + XMPPServerInfo.XMPP_DOMAIN.getKey());
                    return authzid;
                } else if(realm.equals(SASLAuthentication.REALM.getValue())) {
                    Log.debug("DefaultAuthorizationMapping: ream = sasl.realm");
                    return authzid;
                } else {
                    for(String approvedRealm : SASLAuthentication.APPROVED_REALMS.getValue()) {
                        if(realm.equals(approvedRealm)) {
                            Log.debug("DefaultAuthorizationMapping: realm ("+realm+") = "+approvedRealm+" which is approved");
                            return authzid;
                        } else {
                            Log.debug("DefaultAuthorizationPolicy: realm ("+realm+") != "+approvedRealm+" which is approved");
                        }
                    }
                }
                Log.debug("DefaultAuthorizationMapping: No approved mappings found.");
                return authcid;
            } else {
                Log.debug("DefaultAuthorizationMapping: Realm has no length");
            }
        } else {
            Log.debug("DefaultAuthorizationMapping: No realm found");
        }
        return authcid;
    }
Returns the default authorization identity (the identity to act as) for a provided authentication identity
(or 'principal' - whose password is used).

@param authcid authentication identity (or 'principal' whose password is used)
@return The name of the default authorization identity to use.
xmppserver/src/main/java/org/jivesoftware/openfire/auth/DefaultAuthorizationMapping.java