當前位置: 首頁>>代碼示例>>Java>>正文


Java GSSException.toString方法代碼示例

本文整理匯總了Java中org.ietf.jgss.GSSException.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java GSSException.toString方法的具體用法?Java GSSException.toString怎麽用?Java GSSException.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.ietf.jgss.GSSException的用法示例。


在下文中一共展示了GSSException.toString方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: create

import org.ietf.jgss.GSSException; //導入方法依賴的package包/類
public void create(String user, String host) throws JSchException{
  try{
    // RFC 1964
    Oid krb5=new Oid("1.2.840.113554.1.2.2");
    // Kerberos Principal Name Form
    Oid principalName=new Oid("1.2.840.113554.1.2.2.1");

    GSSManager mgr=GSSManager.getInstance();

    GSSCredential crd=null;
    /*
    try{
      GSSName _user=mgr.createName(user, principalName);
      crd=mgr.createCredential(_user,
                               GSSCredential.DEFAULT_LIFETIME,
                               krb5,
                               GSSCredential.INITIATE_ONLY);
    }
    catch(GSSException crdex){
    }
    */

    String cname=host;
    try{
      cname=InetAddress.getByName(cname).getCanonicalHostName();
    }
    catch(UnknownHostException e){
    }
    GSSName _host=mgr.createName("host/"+cname, principalName);

    context=mgr.createContext(_host,
                              krb5,
                              crd,
                              GSSContext.DEFAULT_LIFETIME);

    // RFC4462  3.4.  GSS-API Session
    //
    // When calling GSS_Init_sec_context(), the client MUST set
    // integ_req_flag to "true" to request that per-message integrity
    // protection be supported for this context.  In addition,
    // deleg_req_flag MAY be set to "true" to request access delegation, if
    // requested by the user.
    //
    // Since the user authentication process by its nature authenticates
    // only the client, the setting of mutual_req_flag is not needed for
    // this process.  This flag SHOULD be set to "false".

    // TODO: OpenSSH's sshd does accepts 'false' for mutual_req_flag
    //context.requestMutualAuth(false);
    context.requestMutualAuth(true);
    context.requestConf(true);
    context.requestInteg(true);             // for MIC
    context.requestCredDeleg(true);
    context.requestAnonymity(false);

    return;
  }
  catch(GSSException ex){
    throw new JSchException(ex.toString());
  }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:62,代碼來源:GSSContextKrb5.java


注:本文中的org.ietf.jgss.GSSException.toString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。