Merge branch 'master' of ssh://lhoward@moonshot.suchdamage.org:822/srv/git/moonshot
[mech_eap.git] / util_radius.h
index 6d89c1b..30ac07e 100644 (file)
@@ -66,86 +66,92 @@ public:
     bool initFromBuffer(const gss_eap_attr_ctx *ctx,
                         const gss_buffer_t buffer);
 
-    bool getAttribute(unsigned int attribute,
+    bool getAttribute(int attribute,
                       int *authenticated,
                       int *complete,
                       gss_buffer_t value,
                       gss_buffer_t display_value,
                       int *more) const;
+    bool getAttribute(int attribute,
+                      int vendor,
+                      int *authenticated,
+                      int *complete,
+                      gss_buffer_t value,
+                      gss_buffer_t display_value,
+                      int *more) const;
+
+    bool getFragmentedAttribute(int attribute,
+                                int vendor,
+                                int *authenticated,
+                                int *complete,
+                                gss_buffer_t value) const;
+
+    bool authenticated(void) const { return m_authenticated; }
 
-    bool authenticated() const { return m_authenticated; }
+    time_t getExpiryTime(void) const;
 
-    static bool init();
-    static void finalize();
+    static bool init(void);
+    static void finalize(void);
 
     static gss_eap_attr_provider *createAttrContext(void);
 
 private:
+    bool initFromGssCred(const gss_cred_id_t cred);
+    static VALUE_PAIR *copyAvps(const VALUE_PAIR *in);
+    const VALUE_PAIR *getAvps(void) const {
+        return m_avps;
+    }
+
+    rc_handle *m_rh;
+    VALUE_PAIR *m_avps;
     bool m_authenticated;
 };
 
 /* For now */
-#define PW_SAML_ASSERTION           1936
-
 extern "C" {
 #endif
 
-static inline OM_uint32
+OM_uint32
 addAvpFromBuffer(OM_uint32 *minor,
                  rc_handle *rh,
                  VALUE_PAIR **vp,
                  int type,
-                 gss_buffer_t buffer)
-{
-    if (rc_avpair_add(rh, vp, type, buffer->value, buffer->length, 0) == NULL) {
-        return GSS_S_FAILURE;
-    }
-
-    return GSS_S_COMPLETE;
-}
+                 int vendor,
+                 gss_buffer_t buffer);
 
-static inline OM_uint32
+OM_uint32
 getBufferFromAvps(OM_uint32 *minor,
                   VALUE_PAIR *vps,
                   int type,
+                  int vendor,
                   gss_buffer_t buffer,
-                  int concat)
-{
-    VALUE_PAIR *vp;
-    unsigned char *p;
-
-    buffer->length = 0;
-    buffer->value = NULL;
-
-    vp = rc_avpair_get(vps, type, 0);
-    if (vp == NULL)
-        return GSS_S_UNAVAILABLE;
-
-    do {
-        buffer->length += vp->lvalue;
-    } while (concat && (vp = rc_avpair_get(vp->next, type, 0)) != NULL);
-    
-    buffer->value = GSSEAP_MALLOC(buffer->length);
-    if (buffer->value == NULL) {
-        *minor = ENOMEM;
-        return GSS_S_FAILURE;
-    }
+                  int concat);
 
-    p = (unsigned char *)buffer->value;
+OM_uint32 gssEapRadiusAttrProviderInit(OM_uint32 *minor);
+OM_uint32 gssEapRadiusAttrProviderFinalize(OM_uint32 *minor);
 
-    for (vp = rc_avpair_get(vps, type, 0);
-         concat && vp != NULL;
-         vp = rc_avpair_get(vp->next, type, 0)) {
-        memcpy(p, vp->strvalue, vp->lvalue);
-        p += vp->lvalue;
-    }
+OM_uint32
+gssEapRadiusAllocHandle(OM_uint32 *minor,
+                        const gss_cred_id_t cred,
+                        rc_handle **pHandle);
 
-    *minor = 0;
-    return GSS_S_COMPLETE;
-}
+#define RC_CONFIG_FILE      SYSCONFDIR "/radiusclient/radiusclient.conf"
 
-OM_uint32 gssEapRadiusAttrProviderInit(OM_uint32 *minor);
-OM_uint32 gssEapRadiusAttrProviderFinalize(OM_uint32 *minor);
+/* RFC 2548 - Microsoft Vendor-specific RADIUS Attributes */
+#define VENDOR_ID_MICROSOFT 311
+
+enum { VENDOR_ATTR_MS_MPPE_SEND_KEY = 16,
+       VENDOR_ATTR_MS_MPPE_RECV_KEY = 17
+};
+
+#define VENDOR_ID_UKERNA    25622
+
+enum { VENDOR_ATTR_GSS_ACCEPTOR_SERVICE_NAME = 128,
+       VENDOR_ATTR_GSS_ACCEPTOR_HOST_NAME,
+       VENDOR_ATTR_GSS_ACCEPTOR_SERVICE_SPECIFIC,
+       VENDOR_ATTR_GSS_ACCEPTOR_REALM_NAME,
+       VENDOR_ATTR_SAML_AAA_ASSERTION
+};
 
 #ifdef __cplusplus
 }