本文整理汇总了Java中sun.security.util.DerInputStream.getSet方法的典型用法代码示例。如果您正苦于以下问题:Java DerInputStream.getSet方法的具体用法?Java DerInputStream.getSet怎么用?Java DerInputStream.getSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.security.util.DerInputStream
的用法示例。
在下文中一共展示了DerInputStream.getSet方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractAuthenticationTicketFromAPREQ
import sun.security.util.DerInputStream; //导入方法依赖的package包/类
private Ticket extractAuthenticationTicketFromAPREQ(DerInputStream APREQStream, int APREQLength) throws Exception {
//Structure of AP-REQ from RFC 1510
// AP-REQ ::=
// pvno[0] INTEGER,
// msg-type[1] INTEGER,
// ap-options[2] APOptions,
// ticket[3] Ticket,
// authenticator[4] EncryptedData
DerValue authenticationTicket = null;
DerValue[] values = APREQStream.getSet(APREQLength, true);
for (int i=0; i<values.length; i++) {
DerValue value = values[i];
if (value.isContextSpecific((byte)3)) {
authenticationTicket = value.getData().getDerValue();
}
}
if ( authenticationTicket == null) {
throw new Exception("No Ticket found in AP-REQ PDU");
}
return new Ticket(authenticationTicket);
}
示例2: extractAPREQ
import sun.security.util.DerInputStream; //导入方法依赖的package包/类
private DerValue extractAPREQ(byte[] serviceTicket) throws Exception {
//Decode the service ticket into a set of DER values.
DerInputStream ticketStream = new DerInputStream(serviceTicket);
DerValue[] values = ticketStream.getSet(serviceTicket.length, true);
//Now extract the AP-REQ part from RFC 1510 this is found at...
//AP-REQ ::= [APPLICATION 14] SEQUENCE
for (int i=0; i<values.length; i++) {
DerValue value = values[i];
if (value.isConstructed((byte)14)) {
value.resetTag( DerValue.tag_Set);
return value;
}
}
throw new Exception( "AP-REQ not found in service ticket.");
}
示例3: decodeAuthorizationData
import sun.security.util.DerInputStream; //导入方法依赖的package包/类
private Map<String, Object> decodeAuthorizationData(AuthorizationData authorizationData) throws Exception{
Map<String, Object> clientDetailsFromPac = new HashMap<String, Object>();
//Iterate through the authorizationData and find adData with adType = AD-IF-RELEVANT (1) - see RFC 4210 section 7.5.4
for( int i = 0; i < authorizationData.count(); i++) {
if (authorizationData.item(i).adType == 1){
DerInputStream adDataStream = new DerInputStream(authorizationData.item(i).adData);
DerValue[] values = adDataStream.getSet(authorizationData.item(i).adData.length, true);
//values[0] contains authorizationData entry with adType = AD-WIN2k-PAC (128) - see RFC 4210 section 7.5.4
DerValue pacDerValue = values[0];
AuthorizationDataEntry pacAuthorizationDataEntry = new AuthorizationDataEntry(pacDerValue);
if (pacAuthorizationDataEntry.adType != 128){
throw new IOException("PAC not found within authorization data as expected. Was expecting adType=128 (AD-WIN2K-PAC) within AD-IF-RELEVANT");
}
Pac pac = new Pac(pacAuthorizationDataEntry.adData, this.serverPrivateKey);
clientDetailsFromPac.put("pac", pac);
clientDetailsFromPac.put("fullName", pac.getFullName());
clientDetailsFromPac.put("groupMemberships", pac.getGroupMemberships());
clientDetailsFromPac.put("homeDirectory", pac.getHomeDirectory());
clientDetailsFromPac.put("groupCount", pac.getiGroupCount());
clientDetailsFromPac.put("kdc", pac.getKdc());
clientDetailsFromPac.put("logonCount", pac.getLogonCount());
clientDetailsFromPac.put("logonDomainName", pac.getLogonDomainName());
clientDetailsFromPac.put("passwordExpiryDateTime", pac.getPasswordExpiresDateTime());
clientDetailsFromPac.put("passwordSetDateTime", pac.getPasswordSetDateTime());
clientDetailsFromPac.put("primaryGroup", pac.getPrimaryGroup());
clientDetailsFromPac.put("profilePath", pac.getProfilePath());
}
}
return clientDetailsFromPac;
}
示例4: decode
import sun.security.util.DerInputStream; //导入方法依赖的package包/类
/**
* Decode this set of PKCS9 attributes from the contents of its
* DER encoding. Ignores unsupported attributes when directed.
*
* @param in
* the contents of the DER encoding of the attribute set.
*
* @exception IOException
* on i/o error, encoding syntax error, unacceptable or
* unsupported attribute, or duplicate attribute.
*/
private byte[] decode(DerInputStream in) throws IOException {
DerValue val = in.getDerValue();
// save the DER encoding with its proper tag byte.
byte[] derEncoding = val.toByteArray();
derEncoding[0] = DerValue.tag_SetOf;
DerInputStream derIn = new DerInputStream(derEncoding);
DerValue[] derVals = derIn.getSet(3,true);
PKCS9Attribute attrib;
ObjectIdentifier oid;
boolean reuseEncoding = true;
for (int i=0; i < derVals.length; i++) {
try {
attrib = new PKCS9Attribute(derVals[i]);
} catch (ParsingException e) {
if (ignoreUnsupportedAttributes) {
reuseEncoding = false; // cannot reuse supplied DER encoding
continue; // skip
} else {
throw e;
}
}
oid = attrib.getOID();
if (attributes.get(oid) != null)
throw new IOException("Duplicate PKCS9 attribute: " + oid);
if (permittedAttributes != null &&
!permittedAttributes.containsKey(oid))
throw new IOException("Attribute " + oid +
" not permitted in this attribute set");
attributes.put(oid, attrib);
}
return reuseEncoding ? derEncoding : generateDerEncoding();
}
示例5: SignerInfo
import sun.security.util.DerInputStream; //导入方法依赖的package包/类
/**
* Parses a PKCS#7 signer info.
*
* <p>This constructor is used only for backwards compatibility with
* PKCS#7 blocks that were generated using JDK1.1.x.
*
* @param derin the ASN.1 encoding of the signer info.
* @param oldStyle flag indicating whether or not the given signer info
* is encoded according to JDK1.1.x.
*/
public SignerInfo(DerInputStream derin, boolean oldStyle)
throws IOException, ParsingException
{
// version
version = derin.getBigInteger();
// issuerAndSerialNumber
DerValue[] issuerAndSerialNumber = derin.getSequence(2);
byte[] issuerBytes = issuerAndSerialNumber[0].toByteArray();
issuerName = new X500Name(new DerValue(DerValue.tag_Sequence,
issuerBytes));
certificateSerialNumber = issuerAndSerialNumber[1].getBigInteger();
// digestAlgorithmId
DerValue tmp = derin.getDerValue();
digestAlgorithmId = AlgorithmId.parse(tmp);
// authenticatedAttributes
if (oldStyle) {
// In JDK1.1.x, the authenticatedAttributes are always present,
// encoded as an empty Set (Set of length zero)
derin.getSet(0);
} else {
// check if set of auth attributes (implicit tag) is provided
// (auth attributes are OPTIONAL)
if ((byte)(derin.peekByte()) == (byte)0xA0) {
authenticatedAttributes = new PKCS9Attributes(derin);
}
}
// digestEncryptionAlgorithmId - little RSA naming scheme -
// signature == encryption...
tmp = derin.getDerValue();
digestEncryptionAlgorithmId = AlgorithmId.parse(tmp);
// encryptedDigest
encryptedDigest = derin.getOctetString();
// unauthenticatedAttributes
if (oldStyle) {
// In JDK1.1.x, the unauthenticatedAttributes are always present,
// encoded as an empty Set (Set of length zero)
derin.getSet(0);
} else {
// check if set of unauth attributes (implicit tag) is provided
// (unauth attributes are OPTIONAL)
if (derin.available() != 0
&& (byte)(derin.peekByte()) == (byte)0xA1) {
unauthenticatedAttributes =
new PKCS9Attributes(derin, true);// ignore unsupported attrs
}
}
// all done
if (derin.available() != 0) {
throw new ParsingException("extra data at the end");
}
}
示例6: testDN
import sun.security.util.DerInputStream; //导入方法依赖的package包/类
private static void testDN(String dn) throws Exception {
X500Principal p = new X500Principal(dn);
byte[] encoded = p.getEncoded();
// name is a sequence of RDN's
DerInputStream dis = new DerInputStream(encoded);
DerValue[] nameseq = dis.getSequence(3);
boolean passed = false;
for (int i = 0; i < nameseq.length; i++) {
// each RDN is a set of AttributeTypeAndValue
DerInputStream is = new DerInputStream(nameseq[i].toByteArray());
DerValue[] ava = is.getSet(3);
for (int j = 0; j < ava.length; j++) {
ObjectIdentifier oid = ava[j].data.getOID();
if (oid.equals(X500Name.DOMAIN_COMPONENT_OID)) {
DerValue value = ava[j].data.getDerValue();
if (value.getTag() == DerValue.tag_IA5String) {
passed = true;
break;
} else {
throw new SecurityException
("Test failed, expected DOMAIN_COMPONENT tag '" +
DerValue.tag_IA5String +
"', got '" +
value.getTag() + "'");
}
}
}
if (passed) {
break;
}
}
if (passed) {
System.out.println("Test passed");
} else {
throw new SecurityException("Test failed");
}
}