2012-07-26 97 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基本認證參數的特定端點?是否有某種配置文件或什麼?我不能在互聯網上找到什麼...

回答