Search in sources :

Example 56 with Name

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.");
}
Also used : IOException(java.io.IOException) ORAddress(com.beanit.asn1bean.compiler.pkix1explicit88.ORAddress) RelativeDistinguishedName(com.beanit.asn1bean.compiler.pkix1explicit88.RelativeDistinguishedName) Name(com.beanit.asn1bean.compiler.pkix1explicit88.Name)

Example 57 with Name

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[]");
        }
    }
}
Also used : ASN1OctetString(org.apache.harmony.security.asn1.ASN1OctetString) IOException(java.io.IOException) Name(org.apache.harmony.security.x501.Name)

Example 58 with Name

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();
}
Also used : OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name) Test(org.junit.Test)

Example 59 with Name

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());
}
Also used : OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) Biography(org.orcid.jaxb.model.record_v2.Biography) OtherName(org.orcid.jaxb.model.record_v2.OtherName) PersonalDetails(org.orcid.jaxb.model.record_v2.PersonalDetails) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name) Test(org.junit.Test)

Example 60 with Name

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));
}
Also used : OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) Biography(org.orcid.jaxb.model.record_v2.Biography) OtherName(org.orcid.jaxb.model.record_v2.OtherName) PersonalDetails(org.orcid.jaxb.model.record_v2.PersonalDetails) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)77 Name (org.orcid.jaxb.model.record_v2.Name)74 OtherName (org.orcid.jaxb.model.record_v2.OtherName)62 Biography (org.orcid.jaxb.model.record_v2.Biography)46 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)41 Address (org.orcid.jaxb.model.record_v2.Address)31 Email (org.orcid.jaxb.model.record_v2.Email)30 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)30 Addresses (org.orcid.jaxb.model.record_v2.Addresses)29 Emails (org.orcid.jaxb.model.record_v2.Emails)29 Keyword (org.orcid.jaxb.model.record_v2.Keyword)29 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)29 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)29 Keywords (org.orcid.jaxb.model.record_v2.Keywords)28 Person (org.orcid.jaxb.model.record_v2.Person)28 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)28 Record (org.orcid.jaxb.model.record_v2.Record)19 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)18 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)17 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)17