コード例 #1
0
    /// <summary>
    /// Refreshes the list of granted authorizations and returns true if any were found.
    /// </summary>
    /// <returns></returns>
    public bool Refresh()
    {
        IEnumerable <MFBOauthClientAuth> lstAuths = MFBOauthClientAuth.GrantedAuthsForUser(Page.User.Identity.Name);

        gvOAuthClients.DataSource = lstAuths;
        gvOAuthClients.DataBind();
        return(lstAuths.Count() > 0);
    }
コード例 #2
0
 protected void gvOAuthClients_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     if (e == null)
     {
         throw new ArgumentNullException("e");
     }
     MFBOauthClientAuth.RevokeAuthorization(Page.User.Identity.Name, e.Keys[0].ToString());
     Refresh();
 }
コード例 #3
0
 protected void gvOAuthClients_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e == null)
     {
         throw new ArgumentNullException("e");
     }
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         MFBOauthClientAuth oauth = (MFBOauthClientAuth)e.Row.DataItem;
         if (oauth.Scope != null)
         {
             IEnumerable <string> lstScopes = MFBOauthServer.ScopeDescriptions(MFBOauthServer.ScopesFromString(oauth.Scope));
             ((MultiView)e.Row.FindControl("mvScopesRequested")).SetActiveView(lstScopes.Count() == 0 ? ((View)e.Row.FindControl("vwNoScopes")) : ((View)e.Row.FindControl("vwRequestedScopes")));
             Repeater rpt = (Repeater)e.Row.FindControl("rptPermissions");
             rpt.DataSource = lstScopes;
             rpt.DataBind();
         }
     }
 }
コード例 #4
0
    protected void btnYes_Click(object sender, EventArgs e)
    {
        if (m_pendingRequest == null)
        {
            throw new HttpException((int)HttpStatusCode.BadRequest, Resources.LocalizedText.oAuthErrMissingRequest);
        }

        MFBOauthClientAuth ca = new MFBOauthClientAuth {
            Scope = OAuthUtilities.JoinScopes(m_pendingRequest.Scope), ClientId = m_pendingRequest.ClientIdentifier, UserId = Page.User.Identity.Name, ExpirationDateUtc = DateTime.UtcNow.AddDays(14)
        };

        if (ca.fCommit())
        {
            EndUserAuthorizationSuccessResponseBase resp = authorizationServer.PrepareApproveAuthorizationRequest(m_pendingRequest, Page.User.Identity.Name);
            OutgoingWebResponse wr = authorizationServer.Channel.PrepareResponse(resp);
            wr.Send();
        }
        else
        {
            RejectWithError(Resources.LocalizedText.oAuthErrCreationFailed);
        }
    }