?? spnegocredentials.java
字號(hào):
/* * Copyright 2007 The JA-SIG Collaborative. All rights reserved. See license * distributed with this file and available online at * http://www.uportal.org/license.html */package org.jasig.cas.support.spnego.authentication.principal;import org.jasig.cas.authentication.principal.Credentials;import org.jasig.cas.authentication.principal.Principal;import org.jasig.cas.support.spnego.util.SpnegoConstants;import org.springframework.util.Assert;/** * Credentials that are a holder for Spnego init token. * * @author Arnaud Lesueur * @author Marc-Antoine Garrigue * @version $Revision: 42058 $ $Date: 2007-06-11 11:59:18 -0400 (Mon, 11 Jun 2007) $ * @since 3.1 */public final class SpnegoCredentials implements Credentials { /** * Unique id for serialization. */ private static final long serialVersionUID = -4908976823931528L; /** * The Spnego Init Token. */ private final byte[] initToken; /** * The Spnego Next Token. */ private byte[] nextToken; /** * The Principal. */ private Principal principal; /** * The authentication type should be Kerberos or NTLM. */ private boolean isNtlm; public SpnegoCredentials(final byte[] initToken) { Assert.notNull(initToken, "The initToken cannot be null."); this.initToken = initToken; this.isNtlm = isTokenNtlm(this.initToken); } public byte[] getInitToken() { return this.initToken; } public byte[] getNextToken() { return this.nextToken; } public void setNextToken(final byte[] nextToken) { this.nextToken = nextToken; } public Principal getPrincipal() { return this.principal; } public void setPrincipal(final Principal principal) { this.principal = principal; } public boolean IsNtlm() { return this.isNtlm; } private boolean isTokenNtlm(final byte[] token) { if (token == null || token.length < 8) return false; for (int i = 0; i < 8; i++) { if (SpnegoConstants.NTLMSSP_SIGNATURE[i] != token[i]) return false; } return true; } public String toString() { return this.principal!=null?this.principal.getId():"Principal is null"; } public boolean equals(final Object obj) { if (obj == null || !obj.getClass().equals(this.getClass())) { return false; } final SpnegoCredentials c = (SpnegoCredentials) obj; return this.initToken.equals(c.getInitToken()) && this.principal.equals(c.getPrincipal()) && this.nextToken.equals(c.getNextToken()); } public int hashCode() { return this.initToken.hashCode() ^ this.nextToken.hashCode() ^ this.principal.hashCode(); } }
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -