<commit_before>/*
 *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
 *
 *  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.
 */

/**
* @author <NAME>
* @version $Revision$
*/

package javax.security.auth.kerberos;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Arrays;

import javax.crypto.SecretKey;
import javax.security.auth.DestroyFailedException;
import javax.security.auth.Destroyable;

import org.apache.harmony.security.utils.Array;

/**
 * @com.intel.drl.spec_ref
 * 
 */
public class KerberosKey implements SecretKey, Destroyable {

    private static final long serialVersionUID = -4625402278148246993L;
    
    //principal    
    private KerberosPrincipal principal;

    //key version number
    private int versionNum;
    
    //raw bytes for the sicret key
    private KeyImpl key;
    
    // indicates the ticket state
    private transient boolean destroyed;
    
    
    
    /**
     * @com.intel.drl.spec_ref
     */
    public KerberosKey(KerberosPrincipal principal, byte[] keyBytes,
                       int keyType, int versionNumber) {

        if (keyBytes == null) {
            throw new NullPointerException("key is null");
        }

        this.principal = principal;
        this.versionNum = versionNumber;
        
        this.key = new KeyImpl(keyBytes, keyType);
        
    }
    
    /**
     * @com.intel.drl.spec_ref
     */
    public KerberosKey(KerberosPrincipal principal, char[] password,
                       String algorithm) {
        
        this.principal = principal;

        this.key = new KeyImpl(principal, password, algorithm);
    }
    
    /**
     * @com.intel.drl.spec_ref
     */
    public final KerberosPrincipal getPrincipal() {
        checkState();
        return principal;
    }
    
    /**
     * @com.intel.drl.spec_ref
     */
    public final String getAlgorithm() {
        checkState();
        return key.getAlgorithm();
    }

    /**
     * @com.intel.drl.spec_ref
     */
    public final String getFormat() {
        checkState();
        return key.getFormat();
    }

    /**
     * @com.intel.drl.spec_ref
     */
    public final int getKeyType() {
        checkState();
        return key.getKeyType();
    }  
    /**
     * @com.intel.drl.spec_ref
     */
    public final byte[] getEncoded() {
        checkState();
        return key.getEncoded();
    }
    
    /**
     * @com.intel.drl.spec_ref
     */
    public final int getVersionNumber()  {
        checkState();
        return versionNum;
    } 

    /**
     * @com.intel.drl.spec_ref
     */
    public void destroy() throws DestroyFailedException {
        if (!destroyed) {
            this.principal = null;
            key.destroy();
            this.destroyed = true;
        }
    }

    /**
     * @com.intel.drl.spec_ref
     */
    public boolean isDestroyed() {
        return destroyed;
    }<commit_msg>Remove redundant checks.<commit_after>/*
 *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
 *
 *  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.
 */

/**
* @author <NAME>
* @version $Revision$
*/

package javax.security.auth.kerberos;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Arrays;

import javax.crypto.SecretKey;
import javax.security.auth.DestroyFailedException;
import javax.security.auth.Destroyable;

import org.apache.harmony.security.utils.Array;

/**
 * @com.intel.drl.spec_ref
 * 
 */
public class KerberosKey implements SecretKey, Destroyable {

    private static final long serialVersionUID = -4625402278148246993L;
    
    //principal    
    private KerberosPrincipal principal;

    //key version number
    private int versionNum;
    
    //raw bytes for the sicret key
    private KeyImpl key;
    
    // indicates the ticket state
    private transient boolean destroyed;
    
    
    
    /**
     * @com.intel.drl.spec_ref
     */
    public KerberosKey(KerberosPrincipal principal, byte[] keyBytes,
                       int keyType, int versionNumber) {

        if (keyBytes == null) {
            throw new NullPointerException("key is null");
        }

        this.principal = principal;
        this.versionNum = versionNumber;
        
        this.key = new KeyImpl(keyBytes, keyType);
        
    }
    
    /**
     * @com.intel.drl.spec_ref
     */
    public KerberosKey(KerberosPrincipal principal, char[] password,
                       String algorithm) {
        
        this.principal = principal;

        this.key = new KeyImpl(principal, password, algorithm);
    }
    
    /**
     * @com.intel.drl.spec_ref
     */
    public final KerberosPrincipal getPrincipal() {
        checkState();
        return principal;
    }
    
    /**
     * @com.intel.drl.spec_ref
     */
    public final String getAlgorithm() {
        return key.getAlgorithm();
    }

    /**
     * @com.intel.drl.spec_ref
     */
    public final String getFormat() {
        return key.getFormat();
    }

    /**
     * @com.intel.drl.spec_ref
     */
    public final int getKeyType() {
        return key.getKeyType();
    }  
    /**
     * @com.intel.drl.spec_ref
     */
    public final byte[] getEncoded() {
        return key.getEncoded();
    }
    
    /**
     * @com.intel.drl.spec_ref
     */
    public final int getVersionNumber()  {
        checkState();
        return versionNum;
    } 

    /**
     * @com.intel.drl.spec_ref
     */
    public void destroy() throws DestroyFailedException {
        if (!destroyed) {
            this.principal = null;
            key.destroy();
            this.destroyed = true;
        }
    }

    /**
     * @com.intel.drl.spec_ref
     */
    public boolean isDestroyed() {
        return destroyed;
    }
{'fraction_non_alphanumeric': 0.10156586697313605, 'fraction_numerical': 0.00775750610544462, 'mean_word_length': 2.141696750902527, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2564752', 'n_tokens_mistral': 2065, 'n_tokens_neox': 1995, 'n_words': 522}