目前支持的有
At the moment the Tigase server offers following authentication connectors:
http://www.tigase.org/content/custom-authentication-connectors
需要处理:只需通过init.properties,配置用户数据库和对应的sql语句(或者存储过程)
缺点:很多业务系统都服务化,包括用户系统,直接sql访问有违服务化目的,也不易做进一步处理;
Tigase Custom Auth connector
http://www.tigase.org/content/tigase-custom-auth-connector
至上需要写2个存储过程,
The absolute minimum of stored procedures you have to implement is:
http://www.tigase.org/content/tigase-auth-connector
需要有LDAP服务,目前没有,对LDAP也不熟悉,也不做选择;
http://www.tigase.org/content/ldap-authentication-connector
看下jdbc的处理JDBCRepository.java;因为我们有统一的用户系统,选择使用rpc服务做验证;
http://www.tigase.org/node/1324,
tigase默认用的是 TigaseCustomAuth,在getAuthRepository里被创建;
currently Tigase use "tigase.db.jdbc.TigaseCustomAuth" if no --auth-db was configured
处理之前,先要了解下auth的机制,参考http://www.tigase.org/content/sasl-custom-mechanisms-and-configurationhttp://www.tigase.org/content/sasl-custom-mechanisms-and-configuration,tigase默认
The factory which is available and registered by default is 'tigase.auth.TigaseSaslServerFactory' which provides PLAIN and ANONYMOUS mechanisms.
也没太搞明白匿名认证的作用,所以就把他先禁用了
http://my.oschina.net/greki/blog/213312
纠结的是里面*Auth的3个方法;5.1的release说明,其他2个以备抛弃,全走otherAuth,
所有主要实现otherAuth方法。
但是如果你是覆盖TigaseCustomAuth,那就要注意跟其他方法数据库操作的兼容
主要是登录的时候,online_status要+1;看下原先的存储过程
http://www.tigase.org/content/tigase-xmpp-server-510-beta-3
添加autoCreateUser=true
user-db-uri=jdbc:mysql://192.168.1.15:3306/tigasedb?user=tigase&password=tigase&useUnicode=true&characterEncoding=UTF-8&autoCreateUser=true
tigase自动创建流程在,JDBCRepository.java
(这里有个问题,主要默认创建的密码,密码为空的话,tig_users.account-status的状态为-1,禁用)
private long getUserUID(DataRepository repo, BareJID user_id, boolean autoCreate) throws SQLException, UserNotFoundException { // OK long result = getUserUID(repo, user_id); if (result <= 0) { if (autoCreate) { // OK result = addUserRepo(repo, user_id); } else { throw new UserNotFoundException("User does not exist: " + user_id); } // end of if (autoCreate) else } // end of if (isnext) else return result; }
客户端登录成功,发送设置昵称等信息,主要通过iq设置vcard
<iq xmlns="jabber:client" type="set" id="aac6a"> <vCard xmlns="vcard-temp"> <NICKNAME>admin swr</NICKNAME> </vCard> </iq>
以为要调用外部服务验证,也许你需要配置验证服务的地址等;
直接在init.properties里配置,如--my-config-xxx=xxxx
通过System.getProperty("my-config-xxx");//调试发现的,不一定是最好的方式
借用--auth-db-uri=http://xxxxxx配置自定义;
通过initRepository(final String connection_str, Map<String, String> params)
参数connection_str获取,当然这样就不能再根据connection_str创建连接user_db的repository了;
所以我采用的是第一种,来配置验证的,user_db依然保留,来实现查询用户数等其他方法;
新建maven工程,依赖tigaseserver,配置启动类为Xmppserver.
需要拷贝几个cert、etc、scripts(可选)、jars到目录下;
设置参考:http://my.oschina.net/greki/blog/209538
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.greenline.im</groupId> <artifactId>tigase-ext</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>tigase</name> <url>http://maven.apache.org</url> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <version>2.4.0</version> <extensions>true</extensions> <configuration> <instructions combine.inherited="append"> <Implementation-Title>${project.name}</Implementation-Title> <Implementation-Version>${project.version}-b${gitVersion}/${buildNumber}</Implementation-Version> <Implementation-Build>${gitVersion}/${buildNumber} (${maven.build.timestamp})</Implementation-Build> <Bundle-Activator>tigase.archive.Activator</Bundle-Activator> <Bundle-SymbolicName>${project.artifactId};singleton=true</Bundle-SymbolicName> </instructions> </configuration> </plugin> </plugins> <resources> <resource> <directory>src/main/resources</directory> </resource> </resources> <extensions> <extension> <groupId>org.apache.maven.wagon</groupId> <artifactId>wagon-ssh-external</artifactId> <version>2.2</version> </extension> <extension> <groupId>org.apache.maven.wagon</groupId> <artifactId>wagon-ssh</artifactId> <version>2.2</version> </extension> </extensions> </build> <!-- <dependencyManagement>--> <dependencies> <dependency> <groupId>tigase</groupId> <artifactId>tigase-server</artifactId> <version>5.2.1-SNAPSHOT</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.6.4</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.felix</groupId> <artifactId>org.osgi.core</artifactId> <version>1.4.0</version> <scope>provided</scope> <type>bundle</type> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> <repositories> <repository> <id>tigase</id> <name>Tigase repository</name> <url>http://maven.tigase.org</url> </repository> <repository> <id>tigase-snapshot</id> <name>Tigase repository</name> <url>http://build.xmpp-test.net/maven/</url> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <distributionManagement> <repository> <id>tigase</id> <name>Tigase repository</name> <url>scp://maven.tigase.org:/home/webapp/maven-repository</url> </repository> <snapshotRepository> <id>tigase-snapshot</id> <name>Tigase snapshot repository</name> <url>scp://build.xmpp-test.net:/home/maven/repository</url> </snapshotRepository> </distributionManagement> </project>
--debug=xmpp.XMPPIOService
http://www.tigase.org/tigase-debuging