All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aliyun.oss.crypto.ContentCryptoMaterial Maven / Gradle / Ivy

There is a newer version: 3.4.2
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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 com.aliyun.oss.crypto;

import java.io.Serializable;
import java.util.Collections;
import java.util.Map;
import java.util.TreeMap;
import javax.crypto.SecretKey;

/**
 * Content crypto material used for client-side content encryption/decryption in OSS,
 * it only provide getting accessor.
 */
public class ContentCryptoMaterial implements Serializable {
    private static final long serialVersionUID = -2728152316155503945L;
    /**Prevent sensitive information serializing.*/
    protected transient SecretKey cek;
    /**Prevent sensitive information serializing.*/
    protected transient byte[] iv;
    protected String contentCryptoAlgorithm;
    protected byte[] encryptedCEK;
    protected byte[] encryptedIV;
    protected String keyWrapAlgorithm;
    protected Map matdesc;

    protected ContentCryptoMaterial() {
    };

    public ContentCryptoMaterial(SecretKey cek, 
                          byte[] iv, 
                          String contentCryptoAlgorithm,
                          byte[] encryptedCEK, 
                          byte[] encryptedIV, 
                          String keyWrapAlgorithm, 
                          MapmatDesc) {
        this.cek = cek;
        this.iv = iv.clone();
        this.contentCryptoAlgorithm = contentCryptoAlgorithm;
        this.encryptedCEK = encryptedCEK.clone();
        this.encryptedIV = encryptedIV.clone();
        this.keyWrapAlgorithm = keyWrapAlgorithm;
        this.matdesc = Collections.unmodifiableMap(new TreeMap(matDesc));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;

        if (cek != null) {
            for (int i=0; i getMaterialsDescription() {
        return matdesc;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy