<commit_before>/*
 * Copyright 2002-2008 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.security.extensions.kerberos;

import java.util.List;

import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

/**
 * Holds the Kerberos/SPNEGO token for requesting a kerberized service Will
 * mostly be created in ...Filter and authenticated in
 * KerberosServiceAuthenticationProvider
 * 
 * @author <NAME>
 * @since 1.0
 * @version $Id: $
 */

public class KerberosServiceRequestToken extends AbstractAuthenticationToken {

	public KerberosServiceRequestToken(Object principal, List<GrantedAuthority> authorities, byte[] token) {
		super(authorities);
		this.token = token;
		this.principal = principal;
		super.setAuthenticated(true);
	}

	private static final long serialVersionUID = 395488921064775014L;
	private final byte[] token;
	private final Object principal;

	/**
	 * Creates an unauthenticated instance which should then be authenticated by
	 * KerberosServiceAuthenticationProvider
	 * 
	 * @param token
	 *            Kerberos/SPNEGO token
	 */
	public KerberosServiceRequestToken(byte[] token) {
		super(null);
		this.token = token;
		this.principal = null;
	}

	@Override
	public Object getCredentials() {
		return this.token;
	}

	@Override
	public Object getPrincipal() {
		return this.principal;
	}

	public byte[] getToken() {
		return this.token;
	}

}<commit_msg>SES-1: added equals() and hashCode() in KerberosServiceRequestToken<commit_after>/*
 * Copyright 2002-2008 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.security.extensions.kerberos;

import java.util.Arrays;
import java.util.List;

import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

/**
 * Holds the Kerberos/SPNEGO token for requesting a kerberized service Will
 * mostly be created in ...Filter and authenticated in
 * KerberosServiceAuthenticationProvider
 * 
 * @author <NAME>
 * @since 1.0
 * @version $Id: $
 */

public class KerberosServiceRequestToken extends AbstractAuthenticationToken {

	public KerberosServiceRequestToken(Object principal, List<GrantedAuthority> authorities, byte[] token) {
		super(authorities);
		this.token = token;
		this.principal = principal;
		super.setAuthenticated(true);
	}

	private static final long serialVersionUID = 395488921064775014L;
	private final byte[] token;
	private final Object principal;

	/**
	 * Creates an unauthenticated instance which should then be authenticated by
	 * KerberosServiceAuthenticationProvider
	 * 
	 * @param token
	 *            Kerberos/SPNEGO token
	 */
	public KerberosServiceRequestToken(byte[] token) {
		super(null);
		this.token = token;
		this.principal = null;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + Arrays.hashCode(token);
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		KerberosServiceRequestToken other = (KerberosServiceRequestToken) obj;
		if (!Arrays.equals(token, other.token))
			return false;
		return true;
	}

	@Override
	public Object getCredentials() {
		return null;
	}

	@Override
	public Object getPrincipal() {
		return this.principal;
	}

	public byte[] getToken() {
		return this.token;
	}

}
{'fraction_non_alphanumeric': 0.08765884126642257, 'fraction_numerical': 0.014430325220762439, 'mean_word_length': 4.22972972972973, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5402218', 'n_tokens_mistral': 1406, 'n_tokens_neox': 1282, 'n_words': 437}