2012-07-26 70 views
1

我有一个OSGi捆绑包,它被部署到Apache Karaf 2.2.8中。在此捆绑中,我使用CXFCamel路线。我写了一个CXF拦截器,它执行基本身份验证:从数据库获取所有现有用户并进行验证。Apache Karaf中的基本身份验证

问题是当调用方法handleMessage时,AuthorizationPolicy对象为空。它不提供任何凭据。这里是我的代码:

@Override 
public void handleMessage(Message message) 
     throws Fault { 
     AuthorizationPolicy policy = message.get(AuthorizationPolicy.class); 
    if (users == null) { 
     setLastAccessedTime(Calendar.getInstance()); 
    } 
    if (!wasRecentlyAccessed()) { 
     users = this.loadUsers(); 
     setLastAccessedTime(Calendar.getInstance()); 
    } 
    for (String user : users.values()) { 
     LOGGER.debug("Existing user: " + user); 
    } 
    if (policy == null) { 
     LOGGER.error("User attempted to log in with no credentials"); 
     sendErrorResponse(message, HttpURLConnection.HTTP_UNAUTHORIZED); 
     return; 
    } 
    String password = users.get(policy.getUserName()); 
    if (password == null || !policy.getPassword().equals(password)) { 
     LOGGER.error("Invalid login authentication for user: " + policy.getUserName()); 
     sendErrorResponse(message, HttpURLConnection.HTTP_FORBIDDEN);    
    } 
} 

反正我有可以设置在Karaf基本认证参数的特定端点?是否有某种配置文件或什么?我不能在互联网上找到什么...

回答