本文整理匯總了Java中org.ietf.jgss.GSSException.printStackTrace方法的典型用法代碼示例。如果您正苦於以下問題:Java GSSException.printStackTrace方法的具體用法?Java GSSException.printStackTrace怎麽用?Java GSSException.printStackTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.ietf.jgss.GSSException
的用法示例。
在下文中一共展示了GSSException.printStackTrace方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: closeSession
import org.ietf.jgss.GSSException; //導入方法依賴的package包/類
/**
* Closes the session. If any {@link GSSContext} is present in the session
* then it is closed.
*
* @param message the error message
*/
@Override
protected void closeSession(String message) {
GSSContext ctx = (GSSContext) getSession().getAttribute(GSS_CONTEXT);
if (ctx != null) {
try {
ctx.dispose();
} catch (GSSException e) {
e.printStackTrace();
super.closeSession(message, e);
return;
}
}
super.closeSession(message);
}
示例2: NegotiatorImpl
import org.ietf.jgss.GSSException; //導入方法依賴的package包/類
/**
* Constructor
* @throws java.io.IOException If negotiator cannot be constructed
*/
public NegotiatorImpl(HttpCallerInfo hci) throws IOException {
try {
init(hci);
} catch (GSSException e) {
if (DEBUG) {
System.out.println("Negotiate support not initiated, will " +
"fallback to other scheme if allowed. Reason:");
e.printStackTrace();
}
IOException ioe = new IOException("Negotiate support not initiated");
ioe.initCause(e);
throw ioe;
}
}
示例3: nextToken
import org.ietf.jgss.GSSException; //導入方法依賴的package包/類
/**
* Return the rest tokens of GSS, in SPNEGO, it's called NegTokenTarg
* @param token the token received from server
* @return the next token
* @throws java.io.IOException if the token cannot be created successfully
*/
@Override
public byte[] nextToken(byte[] token) throws IOException {
try {
return context.initSecContext(token, 0, token.length);
} catch (GSSException e) {
if (DEBUG) {
System.out.println("Negotiate support cannot continue. Reason:");
e.printStackTrace();
}
IOException ioe = new IOException("Negotiate support cannot continue");
ioe.initCause(e);
throw ioe;
}
}
示例4: main
import org.ietf.jgss.GSSException; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
// msoid.txt is a NegTokenInit packet sent from Internet Explorer to
// IIS server on a test machine. No sensitive info included.
byte[] header = Files.readAllBytes(
Paths.get(System.getProperty("test.src"), "msoid.txt"));
byte[] token = Base64.getMimeDecoder().decode(
Arrays.copyOfRange(header, 10, header.length));
GSSCredential cred = null;
GSSContext ctx = GSSManager.getInstance().createContext(cred);
try {
ctx.acceptSecContext(token, 0, token.length);
// Before the fix, GSS_KRB5_MECH_OID_MS is not recognized
// and acceptor chooses another mech and goes on
throw new Exception("Should fail");
} catch (GSSException gsse) {
// After the fix, GSS_KRB5_MECH_OID_MS is recognized but the token
// cannot be accepted because we don't have any krb5 credential.
gsse.printStackTrace();
if (gsse.getMajor() != GSSException.NO_CRED) {
throw gsse;
}
for (StackTraceElement st: gsse.getStackTrace()) {
if (st.getClassName().startsWith("sun.security.jgss.krb5.")) {
// Good, it is already in krb5 mech's hand.
return;
}
}
throw gsse;
}
}
示例5: main
import org.ietf.jgss.GSSException; //導入方法依賴的package包/類
public static void main(String[] args)
throws Exception {
new OneKDC(null);
System.setProperty("sun.security.krb5.rcache", "none");
System.setProperty("sun.security.krb5.acceptor.subkey", "true");
Context c, s;
c = Context.fromUserPass(OneKDC.USER, OneKDC.PASS, false);
s = Context.fromUserKtab(OneKDC.SERVER, OneKDC.KTAB, true);
c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID);
s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
byte[] first = c.take(new byte[0]);
c.take(s.take(first));
byte[] msg = c.wrap("hello".getBytes(), true);
s.unwrap(msg, true);
s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
s.take(first); // apreq replay not detectable
try {
s.unwrap(msg, true); // msg replay detectable
throw new Exception("This method should fail");
} catch (GSSException gsse) {
gsse.printStackTrace();
}
}
示例6: main
import org.ietf.jgss.GSSException; //導入方法依賴的package包/類
public static void main(String[] args)
throws Exception {
new OneKDC(null);
if (args[0].equals("dfl")) {
// Store file in scratch directory
args[0] = "dfl:" + System.getProperty("user.dir") + File.separator;
System.setProperty("sun.security.krb5.rcache", args[0]);
}
Context c, s;
c = Context.fromUserPass(OneKDC.USER, OneKDC.PASS, false);
s = Context.fromUserKtab(OneKDC.SERVER, OneKDC.KTAB, true);
c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID);
s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
byte[] first = c.take(new byte[0]);
c.take(s.take(first));
s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
try {
s.take(first); // Replay the last apreq sent
throw new Exception("This method should fail");
} catch (GSSException gsse) {
gsse.printStackTrace();
KrbException ke = (KrbException)gsse.getCause();
if (ke.returnCode() != Krb5.KRB_AP_ERR_REPEAT) {
throw gsse;
}
}
}
示例7: refresh
import org.ietf.jgss.GSSException; //導入方法依賴的package包/類
private Hbase.Client refresh(Hbase.Client client, THttpClient httpClient) {
httpClient.setCustomHeader("doAs", doAsUser);
if(secure) {
try {
httpClient.setCustomHeader("Authorization", generateTicket());
} catch (GSSException e) {
e.printStackTrace();
}
}
return client;
}
示例8: main
import org.ietf.jgss.GSSException; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
OneKDC kdc = new OneKDC(null);
kdc.writeJAASConf();
// USER can impersonate someone else
kdc.setOption(KDC.Option.ALLOW_S4U2SELF,
Arrays.asList(OneKDC.USER + "@" + OneKDC.REALM));
// USER2 is sensitive
kdc.setOption(KDC.Option.SENSITIVE_ACCOUNTS,
Arrays.asList(OneKDC.USER2 + "@" + OneKDC.REALM));
Context c;
// USER2 is sensitive but it's still able to get a normal ticket
c = Context.fromUserPass(OneKDC.USER2, OneKDC.PASS2, false);
// ... and connect to another account
c.startAsClient(OneKDC.USER, GSSUtil.GSS_KRB5_MECH_OID);
c.x().requestCredDeleg(true);
c.x().requestMutualAuth(false);
c.take(new byte[0]);
if (!c.x().isEstablished()) {
throw new Exception("Context should have been established");
}
// ... but will not be able to delegate itself
if (c.x().getCredDelegState()) {
throw new Exception("Impossible");
}
// Although USER is allowed to impersonate other people,
// it cannot impersonate USER2 coz it's sensitive.
c = Context.fromUserPass(OneKDC.USER, OneKDC.PASS, false);
try {
c.impersonate(OneKDC.USER2);
throw new Exception("Should fail");
} catch (GSSException e) {
e.printStackTrace();
}
}