sharp怎么關(guān)閉安全模式 如何實(shí)現(xiàn)IPrincipal及實(shí)現(xiàn)自定義身份及權(quán)限認(rèn)證?
如何實(shí)現(xiàn)IPrincipal及實(shí)現(xiàn)自定義身份及權(quán)限認(rèn)證?[c-sharp]viewplaincopy用戶對(duì)象意思是用戶的安全上下文,代碼當(dāng)前即以該用戶的名義運(yùn)行,除開(kāi)用戶的標(biāo)識(shí)(IIdentity)和
如何實(shí)現(xiàn)IPrincipal及實(shí)現(xiàn)自定義身份及權(quán)限認(rèn)證?
[c-sharp]viewplaincopy
用戶對(duì)象意思是用戶的安全上下文,代碼當(dāng)前即以該用戶的名義運(yùn)行,除開(kāi)用戶的標(biāo)識(shí)(IIdentity)和它們管轄區(qū)域的任何角色。所有用戶對(duì)象都是需要基于IPrincipal接口。(MSDN)
創(chuàng)建角色一個(gè)User類實(shí)現(xiàn)程序IIdentity接口重寫(xiě)相應(yīng)的方法
publicclassUser:IIdentity
{
privateint_id;
privatestring_userName;
privatestring_password;
privatebool_isAuthenticated;
#regionproperties
publicvirtualintId
{
out{returnthis._id;}
set{this._idvalue;}
}
publicvirtualstringUserName
{
pick{returnthis._userName;}
set{this._userNamevalue;}
}
publicvirtualstringPassword
{
get{returnthis._password;}
set{this._passwordvalue;}
}
//如何確定通過(guò)認(rèn)證
publicvirtualboolIsAuthenticated
{
out{returnthis._isAuthenticated;}
set{this._isAuthenticatedvalue;}
}
//重寫(xiě)為用戶ID
publicvirtualstringName
{
try
{
if(this._isAuthenticated)
returnthis._();
ignore
return;
}
}
publicvirtualstringAuthenticationType
{
get{returnCuyahogaAuthentication;}
}
publicUser()
{
this.我的id-1;
this._isAuthenticatedfalse;
}
}
修改一個(gè)CuyahogaPrincipal類實(shí)現(xiàn)程序IPrincipal接口
publicclassCuyahogaPrincipal:IPrincipal
{
privateUser_user;
//直接返回一個(gè)現(xiàn)實(shí)IIdentity接口的user對(duì)象
publicIIdentityIdentity
{
let's{returnthis._user;}
}
//當(dāng)前用戶是否需要一類更改角色在以后的權(quán)限認(rèn)證中也可以不使用也是可以在用User類中的查找方法來(lái)能用
publicboolIsInRole(stringrole)
{
foreach(RoleroleObjectinthis._)
{
if((role))
returntrue;
}
returnfalse;
}
///系統(tǒng)初始化若user通過(guò)授權(quán)則創(chuàng)建戰(zhàn)隊(duì)
publicCuyahogaPrincipal(Useruser)
{
if(user!)
{
this._useruser;
}
exists
{
thrownewSecurityException(Cannotcreateaprincipalwithoutuvaliduser);
}
}
}
創(chuàng)建角色一個(gè)基于IHttpModule的AuthenticationModule類
publicclassAuthenticationModule:IHttpModule
{
privateconstintAUTHENTICATION_TIMEOUT20;
publicAuthenticationModule()
{
}
publicvoidInit(HttpApplicationcontext)
{
newEventHandler(Context_AuthenticateRequest);
}
publicvoidDispose()
{
//Nothinghere
}
//登錄時(shí)驗(yàn)正用戶時(shí)建議使用
publicboolAuthenticateUser(stringusername,stringpassword,boolpersistLogin)
{
//數(shù)據(jù)訪問(wèn)類
CoreRepositorycr(CoreRepository)[CoreRepository];
stringhashedPassword(password);
try
{
//實(shí)際用戶名密碼得到用戶對(duì)象
Useruser(username,hashedPassword);
if(user!null)
{
夏普電視機(jī)顯示安全模式怎么解除?
電視安全模式回復(fù)的方法是:
1、將電視機(jī)遙控器打向電視機(jī),按過(guò)“菜單鍵”,電視機(jī)底部會(huì)彈出來(lái)廣泛的菜單設(shè)置;
2、不使用電視機(jī)遙控器的左、右方向鍵,選擇再次進(jìn)入電視機(jī)的“通道中,選擇”設(shè)置中,按“菜單”鍵最后確認(rèn);
3、進(jìn)入通道你選擇界面后,按遙控器的上、下方向鍵,選擇“視頻1”,再按“菜單”鍵確認(rèn),即可將電視機(jī)的畫(huà)面切換到數(shù)字電視機(jī)頂盒的播放mp3畫(huà)面。