List of usage examples for org.bouncycastle.asn1 DEROctetString DEROctetString
public DEROctetString(ASN1Encodable obj) throws IOException
From source file:org.globus.gsi.proxy.ext.ProxyPolicy.java
License:Apache License
/** * Creates a new instance of the ProxyPolicy object. * * @param policyLanguageOid the language policy Oid. * @param policy the policy./*w w w .j a v a 2 s. c o m*/ */ public ProxyPolicy(String policyLanguageOid, byte[] policy) { if (policyLanguageOid == null) { throw new IllegalArgumentException(); } this.policyLanguage = new ASN1ObjectIdentifier(policyLanguageOid); if (policy != null) { this.policy = new DEROctetString(policy); } checkConstraints(); }
From source file:org.globus.security.proxyExtension.ProxyPolicy.java
License:Apache License
/** * Creates a new instance of the ProxyPolicy object. * * @param policyLanguage the language policy Oid. * @param policy the policy.//w ww .j a v a2s . c o m */ public ProxyPolicy(DERObjectIdentifier policyLanguage, byte[] policy) { if (policyLanguage == null) { throw new IllegalArgumentException(); } this.policyLanguage = policyLanguage; if (policy != null) { this.policy = new DEROctetString(policy); } checkConstraints(); }
From source file:org.globus.security.proxyExtension.ProxyPolicy.java
License:Apache License
/** * Creates a new instance of the ProxyPolicy object. * * @param policyLanguageOid the language policy Oid. * @param policy the policy.//www .j a va 2 s . c om */ public ProxyPolicy(String policyLanguageOid, byte[] policy) { if (policyLanguageOid == null) { throw new IllegalArgumentException(); } this.policyLanguage = new DERObjectIdentifier(policyLanguageOid); if (policy != null) { this.policy = new DEROctetString(policy); } checkConstraints(); }
From source file:org.hyperledger.fabric.sdk.helper.ChainUtils.java
License:Open Source License
/** * used asn1 and get hash//www . j a v a 2 s. com * @param blockNumber * @param previousHash * @param dataHash * @return byte[] * @throws IOException * @throws InvalidArgumentException */ public static byte[] calculateBlockHash(long blockNumber, byte[] previousHash, byte[] dataHash) throws IOException, InvalidArgumentException { if (previousHash == null) { throw new InvalidArgumentException("previousHash parameter is null."); } if (dataHash == null) { throw new InvalidArgumentException("dataHash parameter is null."); } if (null == suite) { suite = CryptoSuite.Factory.getCryptoSuite(); } ByteArrayOutputStream s = new ByteArrayOutputStream(); DERSequenceGenerator seq = new DERSequenceGenerator(s); seq.addObject(new ASN1Integer(blockNumber)); seq.addObject(new DEROctetString(previousHash)); seq.addObject(new DEROctetString(dataHash)); seq.close(); return suite.hash(s.toByteArray()); }
From source file:org.italiangrid.voms.asn1.VOMSACGenerator.java
License:Apache License
private ASN1Encodable buildFQANsAttributeContent(List<String> fqans, GeneralName policyAuthorityInfo) { ASN1EncodableVector container = new ASN1EncodableVector(); ASN1EncodableVector encodedFQANs = new ASN1EncodableVector(); // Policy authority info DERTaggedObject pai = new DERTaggedObject(0, policyAuthorityInfo); container.add(pai);//from w w w .j a va 2 s . com for (String s : fqans) encodedFQANs.add(new DEROctetString(s.getBytes())); container.add(new DERSequence(encodedFQANs)); return new DERSequence(container); }
From source file:org.italiangrid.voms.asn1.VOMSACGenerator.java
License:Apache License
private DEROctetString getDEROctetString(String s) { return new DEROctetString(s.getBytes()); }
From source file:org.jboss.as.test.integration.security.common.negotiation.KerberosTestUtils.java
License:Open Source License
/** * Generates SPNEGO init token with given initial ticket and supported mechanisms. * * @param ticket initial ticket for the preferred (the first) mechanism. * @param supMechOids object identifiers (OIDs) of supported mechanisms for the SPNEGO. * @return ASN.1 encoded SPNEGO init token *//* w w w. j av a2 s. com*/ public static byte[] generateSpnegoTokenInit(byte[] ticket, String... supMechOids) throws IOException { DEROctetString ticketForPreferredMech = new DEROctetString(ticket); ASN1EncodableVector mechSeq = new ASN1EncodableVector(); for (String mech : supMechOids) { mechSeq.add(new ASN1ObjectIdentifier(mech)); } DERTaggedObject taggedMechTypes = new DERTaggedObject(0, new DERSequence(mechSeq)); DERTaggedObject taggedMechToken = new DERTaggedObject(2, ticketForPreferredMech); ASN1EncodableVector v = new ASN1EncodableVector(); v.add(taggedMechTypes); v.add(taggedMechToken); DERSequence seqNegTokenInit = new DERSequence(v); DERTaggedObject taggedSpnego = new DERTaggedObject(0, seqNegTokenInit); ASN1EncodableVector appVec = new ASN1EncodableVector(); appVec.add(new ASN1ObjectIdentifier(OID_SPNEGO)); appVec.add(taggedSpnego); DERApplicationSpecific app = new DERApplicationSpecific(0, appVec); return app.getEncoded(); }
From source file:org.jboss.as.test.integration.security.common.negotiation.KerberosTestUtils.java
License:Open Source License
/** * Generates SPNEGO response (to a "select mechanism challenge") with given bytes as the ticket for selected mechanism. * * @param ticket/*from www . jav a 2 s . co m*/ * @return ASN.1 encoded SPNEGO response */ public static byte[] generateSpnegoTokenResp(byte[] ticket) throws IOException { DEROctetString ourKerberosTicket = new DEROctetString(ticket); DERTaggedObject taggedNegState = new DERTaggedObject(0, new ASN1Enumerated(1)); // accept-incomplete DERTaggedObject taggedResponseToken = new DERTaggedObject(2, ourKerberosTicket); ASN1EncodableVector v = new ASN1EncodableVector(); v.add(taggedNegState); v.add(taggedResponseToken); DERSequence seqNegTokenResp = new DERSequence(v); DERTaggedObject taggedSpnego = new DERTaggedObject(1, seqNegTokenResp); return taggedSpnego.getEncoded(); }
From source file:org.jboss.audit.log.tamper.detecting.TrustedLocation.java
License:Open Source License
private byte[] generateASN1Block(String logFileName, int sequenceNumber, byte[] accumulatedHash) { ByteArrayOutputStream bout = new ByteArrayOutputStream(); try {/*w w w .ja va 2 s . com*/ DERSequenceGenerator gen = new DERSequenceGenerator(bout); gen.addObject(new DERIA5String(logFileName)); gen.addObject(new ASN1Integer(sequenceNumber)); gen.addObject(new DEROctetString(accumulatedHash)); gen.close(); } catch (IOException e) { throw new RuntimeException(e); } return bout.toByteArray(); }
From source file:org.jmrtd.lds.CardSecurityFile.java
License:Open Source License
private static ContentInfo toContentInfo(String contentTypeOID, Collection<SecurityInfo> securityInfos) { try {/*from w w w . j a v a 2 s .c om*/ ASN1EncodableVector vector = new ASN1EncodableVector(); for (SecurityInfo si : securityInfos) { vector.add(si.getDERObject()); } ASN1Set derSet = new DLSet(vector); return new ContentInfo(new ASN1ObjectIdentifier(contentTypeOID), new DEROctetString(derSet)); } catch (IOException ioe) { LOGGER.log(Level.SEVERE, "Error creating signedData: " + ioe.getMessage()); throw new IllegalArgumentException("Error DER encoding the security infos"); } }