Return a list of Subject Alternative Name values for the given x509
        extension object.
169726
def _get_subject_alternative_names(self, ext):
        
        values = []
        for san in ext.value:
            if isinstance(san.value, string):
                # Pass on simple string SAN values
                values.append(san.value)
            elif isinstance(san.value, x509.Name):
                # In theory there there could be >1 RDN here...
                values.extend(
                    self._name_attribute_to_string(rdn) for rdn in san.value.rdns
                )
        return values
1275447
public Collection<XAttribute> getAttributesForExtension(XExtension extension) {
		if(extension == null) {
			return getAttributesWithoutExtension();
		} else {
			Set<XAttribute> extensionSet = extensionMap.get(extension);
			if(extensionSet == null) {
				extensionSet = new HashSet<XAttribute>(0);
			}
			return Collections.unmodifiableCollection(extensionSet);
		}
	}
822125
def custom_object_extension_prefix_lax(instance):
    
    for key, obj in instance['objects'].items():
        if not ('extensions' in obj and 'type' in obj and
                obj['type'] in enums.OBSERVABLE_EXTENSIONS):
            continue
        for ext_key in obj['extensions']:
            if (ext_key not in enums.OBSERVABLE_EXTENSIONS[obj['type']] and
                    not CUSTOM_TYPE_LAX_PREFIX_RE.match(ext_key)):
                yield JSONError("Custom Cyber Observable Object extension type"
                                " '%s' should start with 'x-'."
                                % ext_key, instance['id'],
                                'custom-prefix-lax')
359169
def _list_fields(self):
        

        response = self.__proxy__.list_fields()
        return [s for s in response['value'] if not s.startswith("_")]
1252293
def iter_extensions(self):
        """"""
        return iter(sorted(self.extensions.values(),
                           key=lambda x: x.priority))
776664
def _get_gecos(name):
    '''
    
    '''
    gecos_field = pwd.getpwnam(name).pw_gecos.split(',', 3)
    if not gecos_field:
        return {}
    else:
        # Assign empty strings for any unspecified trailing GECOS fields
        while len(gecos_field) < 4:
            gecos_field.append('')
        return {'fullname': six.text_type(gecos_field[0]),
                'roomnumber': six.text_type(gecos_field[1]),
                'workphone': six.text_type(gecos_field[2]),
                'homephone': six.text_type(gecos_field[3])}
548716
def list_extensions(request):
    
    neutron_api = neutronclient(request)
    try:
        extensions_list = neutron_api.list_extensions()
    except exceptions.ServiceCatalogException:
        return {}
    if 'extensions' in extensions_list:
        return tuple(extensions_list['extensions'])
    else:
        return ()
351680
private static Collection<List<?>> cloneAltNames(Collection<List<?>> altNames) {
        boolean mustClone = false;
        for (List<?> nameEntry : altNames) {
            if (nameEntry.get(1) instanceof byte[]) {
                // must clone names
                mustClone = true;
            }
        }
        if (mustClone) {
            List<List<?>> namesCopy = new ArrayList<>();
            for (List<?> nameEntry : altNames) {
                Object nameObject = nameEntry.get(1);
                if (nameObject instanceof byte[]) {
                    List<Object> nameEntryCopy =
                                        new ArrayList<>(nameEntry);
                    nameEntryCopy.set(1, ((byte[])nameObject).clone());
                    namesCopy.add(Collections.unmodifiableList(nameEntryCopy));
                } else {
                    namesCopy.add(nameEntry);
                }
            }
            return Collections.unmodifiableCollection(namesCopy);
        } else {
            return altNames;
        }
    }

    /**
     * This method are the overridden implementation of
     * getSubjectAlternativeNames method in X509Certificate in the Sun
     * provider. It is better performance-wise since it returns cached
     * values.
     */
    public synchronized Collection<List<?>> getSubjectAlternativeNames()
        throws CertificateParsingException {
        // return cached value if we can
        if (readOnly && subjectAlternativeNames != null)  {
            return cloneAltNames(subjectAlternativeNames);
        }
        SubjectAlternativeNameExtension subjectAltNameExt =
            getSubjectAlternativeNameExtension();
        if (subjectAltNameExt == null) {
            return null;
        }
        GeneralNames names;
        try {
            names = subjectAltNameExt.get(
                    SubjectAlternativeNameExtension.SUBJECT_NAME);
        } catch (IOException ioe) {
            // should not occur
            return Collections.<List<?>>emptySet();
        }
        subjectAlternativeNames = makeAltNames(names);
        return subjectAlternativeNames;
    }

    /**
     * This static method is the default implementation of the
     * getSubjectAlternaitveNames method in X509Certificate. A
     * X509Certificate provider generally should overwrite this to
     * provide among other things caching for better performance.
     */
    public static Collection<List<?>> getSubjectAlternativeNames(X509Certificate cert)
        throws CertificateParsingException {
        try {
            byte[] ext = cert.getExtensionValue(SUBJECT_ALT_NAME_OID);
            if (ext == null) {
                return null;
            }
            DerValue val = new DerValue(ext);
            byte[] data = val.getOctetString();

            SubjectAlternativeNameExtension subjectAltNameExt =
                new SubjectAlternativeNameExtension(Boolean.FALSE,
                                                    data);

            GeneralNames names;
            try {
                names = subjectAltNameExt.get(
                        SubjectAlternativeNameExtension.SUBJECT_NAME);
            }  catch (IOException ioe) {
                // should not occur
                return Collections.<List<?>>emptySet();
            }
            return makeAltNames(names);
        } catch (IOException ioe) {
            throw new CertificateParsingException(ioe);
        }
    }

    /**
     * This method are the overridden implementation of
     * getIssuerAlternativeNames method in X509Certificate in the Sun
     * provider. It is better performance-wise since it returns cached
     * values.
     */
    public synchronized Collection<List<?>> getIssuerAlternativeNames()
        throws CertificateParsingException {
        // return cached value if we can
        if (readOnly && issuerAlternativeNames != null) {
            return cloneAltNames(issuerAlternativeNames);
        }
        IssuerAlternativeNameExtension issuerAltNameExt =
            getIssuerAlternativeNameExtension();
        if (issuerAltNameExt == null) {
            return null;
        }
        GeneralNames names;
        try {
            names = issuerAltNameExt.get(
                    IssuerAlternativeNameExtension.ISSUER_NAME);
        } catch (IOException ioe) {
            // should not occur
            return Collections.<List<?>>emptySet();
        }
        issuerAlternativeNames = makeAltNames(names);
        return issuerAlternativeNames;
    }

    /**
     * This static method is the default implementation of the
     * getIssuerAlternaitveNames method in X509Certificate. A
     * X509Certificate provider generally should overwrite this to
     * provide among other things caching for better performance.
     */
    public static Collection<List<?>> getIssuerAlternativeNames(X509Certificate cert)
        throws CertificateParsingException {
        try {
            byte[] ext = cert.getExtensionValue(ISSUER_ALT_NAME_OID);
            if (ext == null) {
                return null;
            }

            DerValue val = new DerValue(ext);
            byte[] data = val.getOctetString();

            IssuerAlternativeNameExtension issuerAltNameExt =
                new IssuerAlternativeNameExtension(Boolean.FALSE,
                                                    data);
            GeneralNames names;
            try {
                names = issuerAltNameExt.get(
                        IssuerAlternativeNameExtension.ISSUER_NAME);
            }  catch (IOException ioe) {
                // should not occur
                return Collections.<List<?>>emptySet();
            }
            return makeAltNames(names);
        } catch (IOException ioe) {
            throw new CertificateParsingException(ioe);
        }
    }

    public AuthorityInfoAccessExtension getAuthorityInfoAccessExtension() {
        return (AuthorityInfoAccessExtension)
            getExtension(PKIXExtensions.AuthInfoAccess_Id);
    }

    /************************************************************/

    /*
     * Cert is a SIGNED ASN.1 macro, a three elment sequence:
     *
     *  - Data to be signed (ToBeSigned) -- the "raw" cert
     *  - Signature algorithm (SigAlgId)
     *  - The signature bits
     *
     * This routine unmarshals the certificate, saving the signature
     * parts away for later verification.
     */
    private void parse(DerValue val)
    throws CertificateException, IOException {
        parse(
            val,
            null // use re-encoded form of val as the encoded form
            );
    }

    /*
     * Cert is a SIGNED ASN.1 macro, a three elment sequence:
     *
     *  - Data to be signed (ToBeSigned) -- the "raw" cert
     *  - Signature algorithm (SigAlgId)
     *  - The signature bits
     *
     * This routine unmarshals the certificate, saving the signature
     * parts away for later verification.
     */
    private void parse(DerValue val, byte[] originalEncodedForm)
    throws CertificateException, IOException {
        // check if can over write the certificate
        if (readOnly)
            throw new CertificateParsingException(
                      "cannot over-write existing certificate");

        if (val.data == null || val.tag != DerValue.tag_Sequence)
            throw new CertificateParsingException(
                      "invalid DER-encoded certificate data");

        signedCert =
                (originalEncodedForm != null)
                        ? originalEncodedForm : val.toByteArray();
        DerValue[] seq = new DerValue[3];

        seq[0] = val.data.getDerValue();
        seq[1] = val.data.getDerValue();
        seq[2] = val.data.getDerValue();

        if (val.data.available() != 0) {
            throw new CertificateParsingException("signed overrun, bytes = "
                                     + val.data.available());
        }
        if (seq[0].tag != DerValue.tag_Sequence) {
            throw new CertificateParsingException("signed fields invalid");
        }

        algId = AlgorithmId.parse(seq[1]);
        signature = seq[2].getBitString();

        if (seq[1].data.available() != 0) {
            throw new CertificateParsingException("algid field overrun");
        }
        if (seq[2].data.available() != 0)
            throw new CertificateParsingException("signed fields overrun");

        // The CertificateInfo
        info = new X509CertInfo(seq[0]);

        // the "inner" and "outer" signature algorithms must match
        AlgorithmId infoSigAlg = (AlgorithmId)info.get(
                                              CertificateAlgorithmId.NAME
                                              + DOT +
                                              CertificateAlgorithmId.ALGORITHM);
        if (! algId.equals(infoSigAlg))
            throw new CertificateException("Signature algorithm mismatch");
        readOnly = true;
    }
424271
public XExtension getByName(String name) {
                for (XExtension ext : extensionList) {
                        if (ext.getName().equals(name)) {
                                return ext;
                        }
                }
                return null;
        }
906017
def valid_ips(self):
        

        if self._valid_ips is None:
            self._valid_ips = []

            if self.subject_alt_name_value:
                for general_name in self.subject_alt_name_value:
                    if general_name.name == 'ip_address':
                        self._valid_ips.append(general_name.native)

        return self._valid_ips
770807
def extension(names):
    """"""
    for name in names:
        if not NAME_PATTERN.match(name):
            raise ValueError('invalid extension name: %s' % name)
    def decorator(f, names=names):
        return Extension(f, names=names)
    return decorator
32947
def get_index_text(self, prefix, name_obj):
        """"""
        (name, _) = name_obj
        msg = '{name} ({obj_type})'
        parts = {
            'name': name,
            'prefix': prefix,
            'obj_type': self.long_name,
        }
        try:
            (obj_ns, obj_name) = name.rsplit('.', 1)
            parts['name'] = obj_name
            parts['namespace'] = obj_ns
            msg = '{name} ({namespace} {obj_type})'
        except ValueError:
            pass

        return msg.format(**parts)
82098
def get_extension_name(ext):
    """"""

    # In cryptography 2.2, SCTs return "Unknown OID"
    if ext.oid == ExtensionOID.PRECERT_SIGNED_CERTIFICATE_TIMESTAMPS:
        return 'SignedCertificateTimestampList'

    # Until at least cryptography 2.6.1, PrecertPoison has no name
    #   https://github.com/pyca/cryptography/issues/4817
    elif ca_settings.CRYPTOGRAPHY_HAS_PRECERT_POISON:  # pragma: no branch, pragma: only cryptography>=2.4
        if ext.oid == ExtensionOID.PRECERT_POISON:
            return 'PrecertPoison'

    # uppercase the FIRST letter only ("keyUsage" -> "KeyUsage")
    return re.sub('^([a-z])', lambda x: x.groups()[0].upper(), ext.oid._name)
548103
public static List<X509GeneralName> getX509GeneralNames(GeneralNames genNames)
    {
        if (genNames == null) {
            return null;
        }

        GeneralName[] names = genNames.getNames();
        List<X509GeneralName> x509names = new ArrayList<X509GeneralName>(names.length);

        for (GeneralName name : names) {
            switch (name.getTagNo()) {
                case GeneralName.rfc822Name:
                    x509names.add(new X509Rfc822Name(name));
                    break;
                case GeneralName.dNSName:
                    x509names.add(new X509DnsName(name));
                    break;
                case GeneralName.directoryName:
                    x509names.add(new X509DirectoryName(name));
                    break;
                case GeneralName.uniformResourceIdentifier:
                    x509names.add(new X509URI(name));
                    break;
                case GeneralName.iPAddress:
                    x509names.add(new X509IpAddress(name));
                    break;
                default:
                    x509names.add(new X509GenericName(name));
                    break;
            }
        }

        return x509names;
    }
433606
def _get_ext_namespaces(config):
    '''
    
    '''
    namespaces = {}
    if not config:
        return namespaces

    for ns in config:
        constraint_version = tuple(config[ns].get('py-version', []))
        if not constraint_version:
            raise salt.exceptions.SaltSystemExit("An alternative version is configured, but not defined "
                                                 "to what Python's major/minor version it should be constrained.")
        else:
            namespaces[ns] = constraint_version

    return namespaces
342170
def to_(self, attrvals):
        
        attributes = []
        for key, value in attrvals.items():
            name = self._to.get(key.lower())
            if name:
                if name == "urn:oid:1.3.6.1.4.1.5923.1.1.1.10":
                    # special case for eduPersonTargetedID
                    attr_value = []
                    for v in value:
                        extension_element = ExtensionElement("NameID", NAMESPACE,
                                                             attributes={'Format': NAMEID_FORMAT_PERSISTENT}, text=v)
                        attrval = saml.AttributeValue(extension_elements=[extension_element])
                        attr_value.append(attrval)
                else:
                    attr_value = do_ava(value)
                attributes.append(factory(saml.Attribute,
                                          name=name,
                                          name_format=self.name_format,
                                          friendly_name=key,
                                          attribute_value=attr_value))
            else:
                attributes.append(factory(saml.Attribute,
                                          name=key,
                                          attribute_value=do_ava(value)))

        return attributes
1049145
def subject(self):
        """"""
        return Subject([(s.oid, s.value) for s in self.x509.subject])