net.jsign.asn1.authenticode.SpcUuid Maven / Gradle / Ivy
The newest version!
/**
* Copyright 2014 Emmanuel Bourg
*
* 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 net.jsign.asn1.authenticode;
import java.math.BigInteger;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.DEROctetString;
/**
*
* SpcUuid ::= OCTETSTRING
*
*
* @author Emmanuel Bourg
* @since 1.3
*/
public class SpcUuid extends ASN1Object {
private byte[] uuid = new byte[16];
public SpcUuid(String uuid) {
byte[] tmp = new BigInteger(uuid.replaceAll("-", ""), 16).toByteArray();
System.arraycopy(tmp, tmp.length - this.uuid.length, this.uuid, 0, this.uuid.length);
}
@Override
public ASN1Primitive toASN1Primitive() {
return new DEROctetString(uuid);
}
}