use of com.beanit.asn1bean.compiler.modules.module1.Name in project jasn1 by openmuc.
the class GeneralName method decode.
public int decode(InputStream is, BerTag berTag) throws IOException {
int tlvByteCount = 0;
boolean tagWasPassed = (berTag != null);
if (berTag == null) {
berTag = new BerTag();
tlvByteCount += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
otherName = new AnotherName();
tlvByteCount += otherName.decode(is, false);
return tlvByteCount;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
rfc822Name = new BerIA5String();
tlvByteCount += rfc822Name.decode(is, false);
return tlvByteCount;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
dNSName = new BerIA5String();
tlvByteCount += dNSName.decode(is, false);
return tlvByteCount;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
x400Address = new ORAddress();
tlvByteCount += x400Address.decode(is, false);
return tlvByteCount;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) {
BerLength length = new BerLength();
tlvByteCount += length.decode(is);
directoryName = new Name();
tlvByteCount += directoryName.decode(is, null);
tlvByteCount += length.readEocIfIndefinite(is);
return tlvByteCount;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 5)) {
ediPartyName = new EDIPartyName();
tlvByteCount += ediPartyName.decode(is, false);
return tlvByteCount;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 6)) {
uniformResourceIdentifier = new BerIA5String();
tlvByteCount += uniformResourceIdentifier.decode(is, false);
return tlvByteCount;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 7)) {
iPAddress = new BerOctetString();
tlvByteCount += iPAddress.decode(is, false);
return tlvByteCount;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 8)) {
registeredID = new BerObjectIdentifier();
tlvByteCount += registeredID.decode(is, false);
return tlvByteCount;
}
if (tagWasPassed) {
return 0;
}
throw new IOException("Error decoding CHOICE: Tag " + berTag + " matched to no item.");
}
use of com.beanit.asn1bean.compiler.modules.module1.Name in project XobotOS by xamarin.
the class X509CRLSelector method setIssuerNames.
/**
* <b>Do not use:</b> use {@link #setIssuers(Collection)} or one of
* {@link #addIssuerName} instead. Sets the criterion for the issuer
* distinguished names.
* <p>
* The CRL issuer must match at least one of the specified distinguished
* names.
* <p>
* The specified parameter {@code names} is a collection with an entry for
* each name to be included in the criterion. The name is specified as a
* {@code String} or a byte array specifying the name (in RFC 2253 or ASN.1
* DER encoded form)
*
* @param names
* the list of issuer distinguished names to match, or {@code
* null} if any issuer distinguished name will do.
* @throws IOException
* if parsing fails.
*/
public void setIssuerNames(Collection<?> names) throws IOException {
if (names == null) {
issuerNames = null;
issuerPrincipals = null;
return;
}
if (names.size() == 0) {
return;
}
issuerNames = new ArrayList<String>(names.size());
for (Object name : names) {
if (name instanceof String) {
issuerNames.add(new Name((String) name).getName(X500Principal.CANONICAL));
} else if (name instanceof byte[]) {
issuerNames.add(new Name((byte[]) name).getName(X500Principal.CANONICAL));
} else {
throw new IOException("name neither a String nor a byte[]");
}
}
}
use of com.beanit.asn1bean.compiler.modules.module1.Name in project ORCID-Source by ORCID.
the class OrcidSecurityManager_generalTest method testName_ThrowException_When_TokenIsForOtherUser.
@Test(expected = OrcidUnauthorizedException.class)
public void testName_ThrowException_When_TokenIsForOtherUser() {
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.ORCID_BIO_UPDATE);
Name name = createName(Visibility.PUBLIC);
orcidSecurityManager.checkAndFilter(ORCID_2, name, ScopePathType.ORCID_BIO_READ_LIMITED);
fail();
}
use of com.beanit.asn1bean.compiler.modules.module1.Name in project ORCID-Source by ORCID.
the class OrcidSecurityManager_generalTest method testPersonalDetails_When_AllPrivate_NoSource_ReadLimitedToken.
@Test
public void testPersonalDetails_When_AllPrivate_NoSource_ReadLimitedToken() {
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.ORCID_BIO_READ_LIMITED);
Name name = createName(Visibility.PRIVATE);
Biography bio = createBiography(Visibility.PRIVATE);
OtherName o1 = createOtherName(Visibility.PRIVATE, CLIENT_2);
OtherName o2 = createOtherName(Visibility.PRIVATE, CLIENT_2);
OtherName o3 = createOtherName(Visibility.PRIVATE, CLIENT_2);
OtherNames otherNames = new OtherNames();
otherNames.setOtherNames(new ArrayList<OtherName>(Arrays.asList(o1, o2, o3)));
PersonalDetails p = new PersonalDetails();
p.setBiography(bio);
p.setName(name);
p.setOtherNames(otherNames);
orcidSecurityManager.checkAndFilter(ORCID_1, p);
assertNotNull(p);
assertNull(p.getName());
assertNull(p.getBiography());
assertNotNull(p.getOtherNames());
assertNotNull(p.getOtherNames().getOtherNames());
assertTrue(p.getOtherNames().getOtherNames().isEmpty());
}
use of com.beanit.asn1bean.compiler.modules.module1.Name in project ORCID-Source by ORCID.
the class OrcidSecurityManager_generalTest method testPersonalDetails_When_AllPublic_NoSource_ReadLimitedToken.
@Test
public void testPersonalDetails_When_AllPublic_NoSource_ReadLimitedToken() {
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.ORCID_BIO_READ_LIMITED);
Name name = createName(Visibility.PUBLIC);
Biography bio = createBiography(Visibility.PUBLIC);
OtherName o1 = createOtherName(Visibility.PUBLIC, CLIENT_2);
OtherName o2 = createOtherName(Visibility.PUBLIC, CLIENT_2);
OtherName o3 = createOtherName(Visibility.PUBLIC, CLIENT_2);
OtherNames otherNames = new OtherNames();
otherNames.setOtherNames(new ArrayList<OtherName>(Arrays.asList(o1, o2, o3)));
PersonalDetails p = new PersonalDetails();
p.setBiography(bio);
p.setName(name);
p.setOtherNames(otherNames);
orcidSecurityManager.checkAndFilter(ORCID_1, p);
assertNotNull(p);
assertEquals(name, p.getName());
assertEquals(bio, p.getBiography());
assertNotNull(p.getOtherNames());
assertNotNull(p.getOtherNames().getOtherNames());
assertEquals(3, p.getOtherNames().getOtherNames().size());
assertTrue(p.getOtherNames().getOtherNames().contains(o1));
assertTrue(p.getOtherNames().getOtherNames().contains(o2));
assertTrue(p.getOtherNames().getOtherNames().contains(o3));
}
Aggregations