예제 #1
0
        public bool HasPermissionForResource(ResourceRequest req)
        {
            ValidateTokenRequest  treq  = createValidateTokenRequest(req);
            ValidateTokenResponse tresq = callValidateTokenEndpoint(treq);

            return(conclude(tresq));
        }
예제 #2
0
        public override ValidateTokenResponse Process_ValidateTicket(ValidateTokenRequest req, AccessTokenEntry tokenEntry)
        {
            ValidateTokenResponse resp = new ValidateTokenResponse();

            resp.access_token  = req.access_token;
            resp.client_id     = tokenEntry.Realm;
            resp.claimed_scope = tokenEntry.permissions;
            resp.scope         = req.scope;
            resp.UserID        = tokenEntry.UserID;
            resp.Realm         = tokenEntry.Realm;
            return(resp);
        }
예제 #3
0
        public ValidateTokenRequest createValidateTokenRequest(ResourceRequest res_req)
        {
            ValidateTokenRequest vtreq = new ValidateTokenRequest();

            vtreq.access_token = res_req.access_token;
            vtreq.scope        = res_req.scope;
            vtreq.UserID       = res_req.UserID;
            vtreq.client_id    = this.Realm;

            vtreq = pre_ValidateTokenRequest(vtreq);

            CST_Ops.recordme(this, res_req, vtreq);

            return(vtreq);
        }
예제 #4
0
        public override AuthTicket_Resp ValidateTicket(AuthTicket_Req vtr)
        {
            Contract.Assume(vtr == GlobalObjects_base.AuthTicket_Req);

            ValidateTokenRequest req = (ValidateTokenRequest)vtr;

            AccessTokenEntry tokenEntry = (AccessTokenEntry)AccessTokenRecs.getEntry(req.access_token, req.client_id, req.UserID);

            if (req.client_id != tokenEntry.Realm || req.UserID != tokenEntry.UserID || tokenEntry.permissions.permissionSet.IsSupersetOf(req.scope.permissionSet) == false)
            {
                return(null);
            }

            ValidateTokenResponse resp = (ValidateTokenResponse)Process_ValidateTicket(req, tokenEntry);

            CST_Ops.recordme(this, req, resp, false, false);

            return(resp);
        }
예제 #5
0
        public override ValidateTokenResponse callValidateTokenEndpoint(ValidateTokenRequest treq)
        {
            ValidateTokenResponse vtr             = new ValidateTokenResponse();
            FBPermssionData       fbPermssionData = new FBPermssionData();

            string url = TokenEndpointUrl + "/" + treq.UserID + "/permissions?access_token=" + treq.access_token.token;

            HttpWebRequest             request    = (HttpWebRequest)WebRequest.Create(url);
            HttpWebResponse            response   = (HttpWebResponse)request.GetResponse();
            DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(FBPermssionData));

            fbPermssionData = serializer.ReadObject(response.GetResponseStream()) as FBPermssionData;

            CST_Ops.recordme(new OAuth20NameSpace.AuthorizationServerImpl(), treq, vtr, typeof(AuthorizationServer).GetMethod("ValidateTicket"), "facebook.com", false, false);
            vtr.UserID       = treq.UserID;
            vtr.scope        = treq.scope;
            vtr.access_token = treq.access_token;

            return(vtr);
        }
예제 #6
0
 public abstract ValidateTokenResponse callValidateTokenEndpoint(ValidateTokenRequest treq);
예제 #7
0
 public virtual ValidateTokenRequest pre_ValidateTokenRequest(ValidateTokenRequest req)
 {
     return(req);
 }
예제 #8
0
        public virtual ValidateTokenResponse Process_ValidateTicket(ValidateTokenRequest req, AccessTokenEntry tokenEntry)
        {
            ValidateTokenResponse resp = new ValidateTokenResponse();

            resp.access_token = req.access_token;
            resp.client_id = tokenEntry.Realm;
            resp.claimed_scope = tokenEntry.permissions;
            resp.scope = req.scope;
            resp.UserID = tokenEntry.UserID;
            resp.Realm = tokenEntry.Realm;  

            return resp;
        }
예제 #9
0
 public abstract ValidateTokenResponse callValidateTokenEndpoint(ValidateTokenRequest treq);
예제 #10
0
 public virtual ValidateTokenRequest pre_ValidateTokenRequest(ValidateTokenRequest req)
 {
     return req;
 }
예제 #11
0
        public ValidateTokenRequest createValidateTokenRequest(ResourceRequest res_req)
        {
            ValidateTokenRequest vtreq = new ValidateTokenRequest();

            vtreq.access_token = res_req.access_token;
            vtreq.scope = res_req.scope;
            vtreq.UserID = res_req.UserID;
            vtreq.client_id = this.Realm;

            vtreq = pre_ValidateTokenRequest(vtreq);

            CST_Ops.recordme(this, res_req, vtreq);

            return vtreq;
        }
예제 #12
0
        public override ValidateTokenResponse callValidateTokenEndpoint(ValidateTokenRequest treq)
        {
            ValidateTokenResponse vtr = new ValidateTokenResponse();
            FBPermssionData fbPermssionData = new FBPermssionData();

            string url = TokenEndpointUrl + "/" + treq.UserID + "/permissions?access_token=" + treq.access_token.token;

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(FBPermssionData));
            fbPermssionData = serializer.ReadObject(response.GetResponseStream()) as FBPermssionData;

            CST_Ops.recordme(new OAuth20NameSpace.AuthorizationServerImpl(), treq, vtr, typeof(AuthorizationServer).GetMethod("ValidateTicket"), "facebook.com", false, false);
            vtr.UserID = treq.UserID;
            vtr.scope = treq.scope;
            vtr.access_token = treq.access_token;

            return vtr;
        }