Java 类javax.xml.crypto.dsig.keyinfo.KeyInfo 实例源码

项目:jetfuel    文件:X509CertificateKeySelector.java   
@Override
public KeySelectorResult select(KeyInfo keyInfo, Purpose purpose, AlgorithmMethod method, XMLCryptoContext context)
        throws KeySelectorException {

    for (Object o : keyInfo.getContent()) {
        if (o instanceof X509Data) {
            for (Object o2 : ((X509Data) o).getContent()) {
                if (o2 instanceof X509Certificate) {
                    final X509Certificate cert = (X509Certificate) o2;
                    return new KeySelectorResult() {
                        public Key getKey() {
                            return cert.getPublicKey();
                        }
                    };
                }
            }
        }
    }

    return null;
}
项目:oscm    文件:X509KeySelectorTest.java   
@Test()
public void select_wrong_structType() throws Exception {
    // given
    KeyInfo keyinfo = mock(KeyInfo.class);
    ArrayList<XMLStructure> list = new ArrayList<XMLStructure>();
    KeyName struct = mock(KeyName.class);
    list.add(struct);
    doReturn(list).when(keyinfo).getContent();

    // when
    try {
        selector.select(keyinfo, null, null, null);
        fail();
    } catch (KeySelectorException e) {
        assertTrue(e.getMessage().contains("No X509Data element found."));
    }
}
项目:oscm    文件:X509KeySelectorTest.java   
@Test()
public void select_x509Data_empty() throws Exception {
    // given
    KeyInfo keyinfo = mock(KeyInfo.class);
    ArrayList<XMLStructure> list = new ArrayList<XMLStructure>();
    X509Data x509Data = mock(X509Data.class);
    list.add(x509Data);
    doReturn(list).when(keyinfo).getContent();
    doReturn(new ArrayList<Object>()).when(x509Data).getContent();

    // when
    try {
        selector.select(keyinfo, null, null, null);
        fail();
    } catch (KeySelectorException e) {
        assertTrue(e.getMessage().contains("No X509Data element found."));
    }
}
项目:oscm    文件:X509KeySelectorTest.java   
@Test()
public void select_x509Data_noCertificate() throws Exception {
    // given
    KeyInfo keyinfo = mock(KeyInfo.class);
    ArrayList<XMLStructure> list = new ArrayList<XMLStructure>();
    X509Data x509Data = mock(X509Data.class);
    list.add(x509Data);
    doReturn(list).when(keyinfo).getContent();
    ArrayList<Object> x509DataContent = new ArrayList<Object>();
    x509DataContent.add(new String());
    doReturn(x509DataContent).when(x509Data).getContent();

    // when
    try {
        selector.select(keyinfo, null, null, null);
        fail();
    } catch (KeySelectorException e) {
        assertTrue(e.getMessage().contains("No X509Data element found."));
    }
}
项目:oscm    文件:X509KeySelectorTest.java   
@Test()
public void select_publicKey_exception() throws Exception {
    // given
    selector = spy(new X509KeySelector(keystore));
    KeyInfo keyinfo = mock(KeyInfo.class);
    ArrayList<XMLStructure> list = new ArrayList<XMLStructure>();
    X509Data x509Data = mock(X509Data.class);
    list.add(x509Data);
    doReturn(list).when(keyinfo).getContent();
    ArrayList<Object> x509DataContent = new ArrayList<Object>();
    x509DataContent.add(mock(X509Certificate.class));
    doReturn(x509DataContent).when(x509Data).getContent();
    doThrow(new KeyStoreException("key exception")).when(selector)
            .getPublicKeyFromKeystore(any(X509Certificate.class),
                    any(SignatureMethod.class));

    // when
    try {
        selector.select(keyinfo, null, null, null);
        fail();
    } catch (KeySelectorException e) {
        assertTrue(e.getCause().getMessage().contains("key exception"));
    }
}
项目:oscm    文件:KeyValueKeySelectorTest.java   
@Test()
public void select_wrong_structType() throws Exception {
    // given
    KeyInfo keyinfo = mock(KeyInfo.class);
    ArrayList<XMLStructure> list = new ArrayList<XMLStructure>();
    KeyName struct = mock(KeyName.class);
    list.add(struct);
    doReturn(list).when(keyinfo).getContent();

    // when
    try {
        selector.select(keyinfo, null, null, null);
        fail();
    } catch (KeySelectorException e) {
        assertTrue(e.getMessage().contains(
                "No RSA/DSA KeyValue element found"));
    }
}
项目:oscm    文件:KeyValueKeySelectorTest.java   
@Test()
public void select_publicKey_exception() throws Exception {
    // given
    KeyInfo keyinfo = mock(KeyInfo.class);
    ArrayList<XMLStructure> list = new ArrayList<XMLStructure>();
    KeyValue struct = mock(KeyValue.class);
    list.add(struct);
    doReturn(list).when(keyinfo).getContent();
    doThrow(new KeyException("test")).when(struct).getPublicKey();

    // when
    try {
        selector.select(keyinfo, null, null, null);
        fail();
    } catch (KeySelectorException e) {
        assertTrue(e.getCause().getMessage().contains("test"));
    }
}
项目:OpenJSharp    文件:DOMKeyInfo.java   
@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }

    if (!(o instanceof KeyInfo)) {
        return false;
    }
    KeyInfo oki = (KeyInfo)o;

    boolean idsEqual = (id == null ? oki.getId() == null
                                   : id.equals(oki.getId()));

    return (keyInfoTypes.equals(oki.getContent()) && idsEqual);
}
项目:OpenJSharp    文件:DOMXMLSignature.java   
/**
 * Creates a <code>DOMXMLSignature</code> from the specified components.
 *
 * @param si the <code>SignedInfo</code>
 * @param ki the <code>KeyInfo</code>, or <code>null</code> if not specified
 * @param objs a list of <code>XMLObject</code>s or <code>null</code>
 *  if not specified. The list is copied to protect against subsequent
 *  modification.
 * @param id an optional id (specify <code>null</code> to omit)
 * @param signatureValueId an optional id (specify <code>null</code> to
 *  omit)
 * @throws NullPointerException if <code>si</code> is <code>null</code>
 */
public DOMXMLSignature(SignedInfo si, KeyInfo ki,
                       List<? extends XMLObject> objs,
                       String id, String signatureValueId)
{
    if (si == null) {
        throw new NullPointerException("signedInfo cannot be null");
    }
    this.si = si;
    this.id = id;
    this.sv = new DOMSignatureValue(signatureValueId);
    if (objs == null) {
        this.objects = Collections.emptyList();
    } else {
        this.objects =
            Collections.unmodifiableList(new ArrayList<XMLObject>(objs));
        for (int i = 0, size = this.objects.size(); i < size; i++) {
            if (!(this.objects.get(i) instanceof XMLObject)) {
                throw new ClassCastException
                    ("objs["+i+"] is not an XMLObject");
            }
        }
    }
    this.ki = ki;
}
项目:jdk8u-jdk    文件:DOMKeyInfo.java   
@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }

    if (!(o instanceof KeyInfo)) {
        return false;
    }
    KeyInfo oki = (KeyInfo)o;

    boolean idsEqual = (id == null ? oki.getId() == null
                                   : id.equals(oki.getId()));

    return (keyInfoTypes.equals(oki.getContent()) && idsEqual);
}
项目:jdk8u-jdk    文件:DOMXMLSignature.java   
/**
 * Creates a <code>DOMXMLSignature</code> from the specified components.
 *
 * @param si the <code>SignedInfo</code>
 * @param ki the <code>KeyInfo</code>, or <code>null</code> if not specified
 * @param objs a list of <code>XMLObject</code>s or <code>null</code>
 *  if not specified. The list is copied to protect against subsequent
 *  modification.
 * @param id an optional id (specify <code>null</code> to omit)
 * @param signatureValueId an optional id (specify <code>null</code> to
 *  omit)
 * @throws NullPointerException if <code>si</code> is <code>null</code>
 */
public DOMXMLSignature(SignedInfo si, KeyInfo ki,
                       List<? extends XMLObject> objs,
                       String id, String signatureValueId)
{
    if (si == null) {
        throw new NullPointerException("signedInfo cannot be null");
    }
    this.si = si;
    this.id = id;
    this.sv = new DOMSignatureValue(signatureValueId);
    if (objs == null) {
        this.objects = Collections.emptyList();
    } else {
        this.objects =
            Collections.unmodifiableList(new ArrayList<XMLObject>(objs));
        for (int i = 0, size = this.objects.size(); i < size; i++) {
            if (!(this.objects.get(i) instanceof XMLObject)) {
                throw new ClassCastException
                    ("objs["+i+"] is not an XMLObject");
            }
        }
    }
    this.ki = ki;
}
项目:openjdk-jdk10    文件:DOMKeyInfo.java   
@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }

    if (!(o instanceof KeyInfo)) {
        return false;
    }
    KeyInfo oki = (KeyInfo)o;

    boolean idsEqual = (id == null ? oki.getId() == null
                                   : id.equals(oki.getId()));

    return (keyInfoTypes.equals(oki.getContent()) && idsEqual);
}
项目:openjdk-jdk10    文件:DOMXMLSignature.java   
/**
 * Creates a <code>DOMXMLSignature</code> from the specified components.
 *
 * @param si the <code>SignedInfo</code>
 * @param ki the <code>KeyInfo</code>, or <code>null</code> if not specified
 * @param objs a list of <code>XMLObject</code>s or <code>null</code>
 *  if not specified. The list is copied to protect against subsequent
 *  modification.
 * @param id an optional id (specify <code>null</code> to omit)
 * @param signatureValueId an optional id (specify <code>null</code> to
 *  omit)
 * @throws NullPointerException if <code>si</code> is <code>null</code>
 */
public DOMXMLSignature(SignedInfo si, KeyInfo ki,
                       List<? extends XMLObject> objs,
                       String id, String signatureValueId)
{
    if (si == null) {
        throw new NullPointerException("signedInfo cannot be null");
    }
    this.si = si;
    this.id = id;
    this.sv = new DOMSignatureValue(signatureValueId);
    List<XMLObject> tempList =
        Collections.checkedList(new ArrayList<XMLObject>(),
                                XMLObject.class);
    if (objs != null) {
        tempList.addAll(objs);
    }
    this.objects = Collections.unmodifiableList(tempList);
    this.ki = ki;
}
项目:openjdk9    文件:DOMKeyInfo.java   
@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }

    if (!(o instanceof KeyInfo)) {
        return false;
    }
    KeyInfo oki = (KeyInfo)o;

    boolean idsEqual = (id == null ? oki.getId() == null
                                   : id.equals(oki.getId()));

    return (keyInfoTypes.equals(oki.getContent()) && idsEqual);
}
项目:openjdk9    文件:DOMXMLSignature.java   
/**
 * Creates a <code>DOMXMLSignature</code> from the specified components.
 *
 * @param si the <code>SignedInfo</code>
 * @param ki the <code>KeyInfo</code>, or <code>null</code> if not specified
 * @param objs a list of <code>XMLObject</code>s or <code>null</code>
 *  if not specified. The list is copied to protect against subsequent
 *  modification.
 * @param id an optional id (specify <code>null</code> to omit)
 * @param signatureValueId an optional id (specify <code>null</code> to
 *  omit)
 * @throws NullPointerException if <code>si</code> is <code>null</code>
 */
public DOMXMLSignature(SignedInfo si, KeyInfo ki,
                       List<? extends XMLObject> objs,
                       String id, String signatureValueId)
{
    if (si == null) {
        throw new NullPointerException("signedInfo cannot be null");
    }
    this.si = si;
    this.id = id;
    this.sv = new DOMSignatureValue(signatureValueId);
    List<XMLObject> tempList =
        Collections.checkedList(new ArrayList<XMLObject>(),
                                XMLObject.class);
    if (objs != null) {
        tempList.addAll(objs);
    }
    this.objects = Collections.unmodifiableList(tempList);
    this.ki = ki;
}
项目:xmlsec-gost    文件:DOMKeyInfo.java   
private static void marshalInternal(XmlWriter xwriter, KeyInfo ki,
    String dsPrefix, XMLCryptoContext context, boolean declareNamespace) throws MarshalException {

    xwriter.writeStartElement(dsPrefix, "KeyInfo", XMLSignature.XMLNS);
    if (declareNamespace) {
        xwriter.writeNamespace(dsPrefix, XMLSignature.XMLNS);
    }

    xwriter.writeIdAttribute("", "", "Id", ki.getId());
    // create and append KeyInfoType elements
    List<XMLStructure> keyInfoTypes = getContent(ki);
    for (XMLStructure kiType : keyInfoTypes) {
        xwriter.marshalStructure(kiType, dsPrefix, context);
    }

    xwriter.writeEndElement(); // "KeyInfo"
}
项目:xmlsec-gost    文件:DOMKeyInfo.java   
@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }

    if (!(o instanceof KeyInfo)) {
        return false;
    }
    KeyInfo oki = (KeyInfo)o;

    boolean idsEqual = id == null ? oki.getId() == null
                                   : id.equals(oki.getId());

    return keyInfoTypes.equals(oki.getContent()) && idsEqual;
}
项目:xmlsec-gost    文件:DOMXMLSignature.java   
/**
 * Creates a <code>DOMXMLSignature</code> from the specified components.
 *
 * @param si the <code>SignedInfo</code>
 * @param ki the <code>KeyInfo</code>, or <code>null</code> if not specified
 * @param objs a list of <code>XMLObject</code>s or <code>null</code>
 *  if not specified. The list is copied to protect against subsequent
 *  modification.
 * @param id an optional id (specify <code>null</code> to omit)
 * @param signatureValueId an optional id (specify <code>null</code> to
 *  omit)
 * @throws NullPointerException if <code>si</code> is <code>null</code>
 */
public DOMXMLSignature(SignedInfo si, KeyInfo ki,
                       List<? extends XMLObject> objs,
                       String id, String signatureValueId)
{
    if (si == null) {
        throw new NullPointerException("signedInfo cannot be null");
    }
    this.si = si;
    this.id = id;
    this.sv = new DOMSignatureValue(signatureValueId);
    if (objs == null) {
        this.objects = Collections.emptyList();
    } else {
        this.objects =
            Collections.unmodifiableList(new ArrayList<XMLObject>(objs));
        for (int i = 0, size = this.objects.size(); i < size; i++) {
            if (!(this.objects.get(i) instanceof XMLObject)) {
                throw new ClassCastException
                    ("objs["+i+"] is not an XMLObject");
            }
        }
    }
    this.ki = ki;
}
项目:xmlsec-gost    文件:KeyInfoTest.java   
@org.junit.Test
@SuppressWarnings("unchecked")
public void testgetContent() {
    KeyInfo[] infos = new KeyInfo[2];
    infos[0] = fac.newKeyInfo
        (Collections.singletonList(fac.newKeyName("foo")), "skeleton");
    infos[1] = fac.newKeyInfo
        (Collections.singletonList(fac.newKeyName("foo")));
    for (int j = 0; j < infos.length; j++) {
        KeyInfo ki = infos[j];
        List<XMLStructure> li = ki.getContent();
        assertNotNull(ki.getContent());
        Object[] content = li.toArray();
        for (int i = 0; i < content.length; i++) {
            if (!(content[i] instanceof XMLStructure)) {
                fail("KeyInfo element has the wrong type");
            }
        }
    }
}
项目:jdk8u_jdk    文件:DOMKeyInfo.java   
@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }

    if (!(o instanceof KeyInfo)) {
        return false;
    }
    KeyInfo oki = (KeyInfo)o;

    boolean idsEqual = (id == null ? oki.getId() == null
                                   : id.equals(oki.getId()));

    return (keyInfoTypes.equals(oki.getContent()) && idsEqual);
}
项目:jdk8u_jdk    文件:DOMXMLSignature.java   
/**
 * Creates a <code>DOMXMLSignature</code> from the specified components.
 *
 * @param si the <code>SignedInfo</code>
 * @param ki the <code>KeyInfo</code>, or <code>null</code> if not specified
 * @param objs a list of <code>XMLObject</code>s or <code>null</code>
 *  if not specified. The list is copied to protect against subsequent
 *  modification.
 * @param id an optional id (specify <code>null</code> to omit)
 * @param signatureValueId an optional id (specify <code>null</code> to
 *  omit)
 * @throws NullPointerException if <code>si</code> is <code>null</code>
 */
public DOMXMLSignature(SignedInfo si, KeyInfo ki,
                       List<? extends XMLObject> objs,
                       String id, String signatureValueId)
{
    if (si == null) {
        throw new NullPointerException("signedInfo cannot be null");
    }
    this.si = si;
    this.id = id;
    this.sv = new DOMSignatureValue(signatureValueId);
    if (objs == null) {
        this.objects = Collections.emptyList();
    } else {
        this.objects =
            Collections.unmodifiableList(new ArrayList<XMLObject>(objs));
        for (int i = 0, size = this.objects.size(); i < size; i++) {
            if (!(this.objects.get(i) instanceof XMLObject)) {
                throw new ClassCastException
                    ("objs["+i+"] is not an XMLObject");
            }
        }
    }
    this.ki = ki;
}
项目:lookaside_java-1.8.0-openjdk    文件:DOMKeyInfo.java   
@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }

    if (!(o instanceof KeyInfo)) {
        return false;
    }
    KeyInfo oki = (KeyInfo)o;

    boolean idsEqual = (id == null ? oki.getId() == null
                                   : id.equals(oki.getId()));

    return (keyInfoTypes.equals(oki.getContent()) && idsEqual);
}
项目:lookaside_java-1.8.0-openjdk    文件:DOMXMLSignature.java   
/**
 * Creates a <code>DOMXMLSignature</code> from the specified components.
 *
 * @param si the <code>SignedInfo</code>
 * @param ki the <code>KeyInfo</code>, or <code>null</code> if not specified
 * @param objs a list of <code>XMLObject</code>s or <code>null</code>
 *  if not specified. The list is copied to protect against subsequent
 *  modification.
 * @param id an optional id (specify <code>null</code> to omit)
 * @param signatureValueId an optional id (specify <code>null</code> to
 *  omit)
 * @throws NullPointerException if <code>si</code> is <code>null</code>
 */
public DOMXMLSignature(SignedInfo si, KeyInfo ki,
                       List<? extends XMLObject> objs,
                       String id, String signatureValueId)
{
    if (si == null) {
        throw new NullPointerException("signedInfo cannot be null");
    }
    this.si = si;
    this.id = id;
    this.sv = new DOMSignatureValue(signatureValueId);
    if (objs == null) {
        this.objects = Collections.emptyList();
    } else {
        this.objects =
            Collections.unmodifiableList(new ArrayList<XMLObject>(objs));
        for (int i = 0, size = this.objects.size(); i < size; i++) {
            if (!(this.objects.get(i) instanceof XMLObject)) {
                throw new ClassCastException
                    ("objs["+i+"] is not an XMLObject");
            }
        }
    }
    this.ki = ki;
}
项目:nfce    文件:X509KeySelector.java   
@Override
public KeySelectorResult select(final KeyInfo keyInfo, final KeySelector.Purpose purpose, final AlgorithmMethod method, final XMLCryptoContext context) throws KeySelectorException {
    for (final Object object : keyInfo.getContent()) {
        final XMLStructure info = (XMLStructure) object;
        if (info instanceof X509Data) {
            final X509Data x509Data = (X509Data) info;
            for (final Object certificado : x509Data.getContent()) {
                if (certificado instanceof X509Certificate) {
                    final X509Certificate x509Certificate = (X509Certificate) certificado;
                    if (this.algEquals(method.getAlgorithm(), x509Certificate.getPublicKey().getAlgorithm())) {
                        return new KeySelectorResult() {
                            @Override
                            public Key getKey() {
                                return x509Certificate.getPublicKey();
                            }
                        };
                    }
                }
            }
        }
    }
    throw new KeySelectorException("N\u00e3o foi localizada a chave do certificado.");
}
项目:Camel    文件:ECDSASignatureTest.java   
static KeyAccessor getKeyAccessor() {
    KeyAccessor accessor = new KeyAccessor() {

        @Override
        public KeySelector getKeySelector(Message message) throws Exception {
            return KeySelector.singletonKeySelector(getKeyFromKeystore());
        }

        @Override
        public KeyInfo getKeyInfo(Message mess, Node messageBody,
                                  KeyInfoFactory keyInfoFactory) throws Exception {
            return null;
        }
    };
    return accessor;
}
项目:development    文件:X509KeySelectorTest.java   
@Test()
public void select_wrong_structType() throws Exception {
    // given
    KeyInfo keyinfo = mock(KeyInfo.class);
    ArrayList<XMLStructure> list = new ArrayList<XMLStructure>();
    KeyName struct = mock(KeyName.class);
    list.add(struct);
    doReturn(list).when(keyinfo).getContent();

    // when
    try {
        selector.select(keyinfo, null, null, null);
        fail();
    } catch (KeySelectorException e) {
        assertTrue(e.getMessage().contains("No X509Data element found."));
    }
}
项目:development    文件:X509KeySelectorTest.java   
@Test()
public void select_x509Data_empty() throws Exception {
    // given
    KeyInfo keyinfo = mock(KeyInfo.class);
    ArrayList<XMLStructure> list = new ArrayList<XMLStructure>();
    X509Data x509Data = mock(X509Data.class);
    list.add(x509Data);
    doReturn(list).when(keyinfo).getContent();
    doReturn(new ArrayList<Object>()).when(x509Data).getContent();

    // when
    try {
        selector.select(keyinfo, null, null, null);
        fail();
    } catch (KeySelectorException e) {
        assertTrue(e.getMessage().contains("No X509Data element found."));
    }
}
项目:development    文件:X509KeySelectorTest.java   
@Test()
public void select_x509Data_noCertificate() throws Exception {
    // given
    KeyInfo keyinfo = mock(KeyInfo.class);
    ArrayList<XMLStructure> list = new ArrayList<XMLStructure>();
    X509Data x509Data = mock(X509Data.class);
    list.add(x509Data);
    doReturn(list).when(keyinfo).getContent();
    ArrayList<Object> x509DataContent = new ArrayList<Object>();
    x509DataContent.add(new String());
    doReturn(x509DataContent).when(x509Data).getContent();

    // when
    try {
        selector.select(keyinfo, null, null, null);
        fail();
    } catch (KeySelectorException e) {
        assertTrue(e.getMessage().contains("No X509Data element found."));
    }
}
项目:development    文件:X509KeySelectorTest.java   
@Test()
public void select_publicKey_exception() throws Exception {
    // given
    selector = spy(new X509KeySelector(keystore));
    KeyInfo keyinfo = mock(KeyInfo.class);
    ArrayList<XMLStructure> list = new ArrayList<XMLStructure>();
    X509Data x509Data = mock(X509Data.class);
    list.add(x509Data);
    doReturn(list).when(keyinfo).getContent();
    ArrayList<Object> x509DataContent = new ArrayList<Object>();
    x509DataContent.add(mock(X509Certificate.class));
    doReturn(x509DataContent).when(x509Data).getContent();
    doThrow(new KeyStoreException("key exception")).when(selector)
            .getPublicKeyFromKeystore(any(X509Certificate.class),
                    any(SignatureMethod.class));

    // when
    try {
        selector.select(keyinfo, null, null, null);
        fail();
    } catch (KeySelectorException e) {
        assertTrue(e.getCause().getMessage().contains("key exception"));
    }
}
项目:development    文件:KeyValueKeySelectorTest.java   
@Test()
public void select_wrong_structType() throws Exception {
    // given
    KeyInfo keyinfo = mock(KeyInfo.class);
    ArrayList<XMLStructure> list = new ArrayList<XMLStructure>();
    KeyName struct = mock(KeyName.class);
    list.add(struct);
    doReturn(list).when(keyinfo).getContent();

    // when
    try {
        selector.select(keyinfo, null, null, null);
        fail();
    } catch (KeySelectorException e) {
        assertTrue(e.getMessage().contains(
                "No RSA/DSA KeyValue element found"));
    }
}
项目:development    文件:KeyValueKeySelectorTest.java   
@Test()
public void select_publicKey_exception() throws Exception {
    // given
    KeyInfo keyinfo = mock(KeyInfo.class);
    ArrayList<XMLStructure> list = new ArrayList<XMLStructure>();
    KeyValue struct = mock(KeyValue.class);
    list.add(struct);
    doReturn(list).when(keyinfo).getContent();
    doThrow(new KeyException("test")).when(struct).getPublicKey();

    // when
    try {
        selector.select(keyinfo, null, null, null);
        fail();
    } catch (KeySelectorException e) {
        assertTrue(e.getCause().getMessage().contains("test"));
    }
}
项目:infobip-open-jdk-8    文件:DOMKeyInfo.java   
@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }

    if (!(o instanceof KeyInfo)) {
        return false;
    }
    KeyInfo oki = (KeyInfo)o;

    boolean idsEqual = (id == null ? oki.getId() == null
                                   : id.equals(oki.getId()));

    return (keyInfoTypes.equals(oki.getContent()) && idsEqual);
}
项目:infobip-open-jdk-8    文件:DOMXMLSignature.java   
/**
 * Creates a <code>DOMXMLSignature</code> from the specified components.
 *
 * @param si the <code>SignedInfo</code>
 * @param ki the <code>KeyInfo</code>, or <code>null</code> if not specified
 * @param objs a list of <code>XMLObject</code>s or <code>null</code>
 *  if not specified. The list is copied to protect against subsequent
 *  modification.
 * @param id an optional id (specify <code>null</code> to omit)
 * @param signatureValueId an optional id (specify <code>null</code> to
 *  omit)
 * @throws NullPointerException if <code>si</code> is <code>null</code>
 */
public DOMXMLSignature(SignedInfo si, KeyInfo ki,
                       List<? extends XMLObject> objs,
                       String id, String signatureValueId)
{
    if (si == null) {
        throw new NullPointerException("signedInfo cannot be null");
    }
    this.si = si;
    this.id = id;
    this.sv = new DOMSignatureValue(signatureValueId);
    if (objs == null) {
        this.objects = Collections.emptyList();
    } else {
        this.objects =
            Collections.unmodifiableList(new ArrayList<XMLObject>(objs));
        for (int i = 0, size = this.objects.size(); i < size; i++) {
            if (!(this.objects.get(i) instanceof XMLObject)) {
                throw new ClassCastException
                    ("objs["+i+"] is not an XMLObject");
            }
        }
    }
    this.ki = ki;
}
项目:jdk8u-dev-jdk    文件:DOMKeyInfo.java   
@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }

    if (!(o instanceof KeyInfo)) {
        return false;
    }
    KeyInfo oki = (KeyInfo)o;

    boolean idsEqual = (id == null ? oki.getId() == null
                                   : id.equals(oki.getId()));

    return (keyInfoTypes.equals(oki.getContent()) && idsEqual);
}
项目:jdk8u-dev-jdk    文件:DOMXMLSignature.java   
/**
 * Creates a <code>DOMXMLSignature</code> from the specified components.
 *
 * @param si the <code>SignedInfo</code>
 * @param ki the <code>KeyInfo</code>, or <code>null</code> if not specified
 * @param objs a list of <code>XMLObject</code>s or <code>null</code>
 *  if not specified. The list is copied to protect against subsequent
 *  modification.
 * @param id an optional id (specify <code>null</code> to omit)
 * @param signatureValueId an optional id (specify <code>null</code> to
 *  omit)
 * @throws NullPointerException if <code>si</code> is <code>null</code>
 */
public DOMXMLSignature(SignedInfo si, KeyInfo ki,
                       List<? extends XMLObject> objs,
                       String id, String signatureValueId)
{
    if (si == null) {
        throw new NullPointerException("signedInfo cannot be null");
    }
    this.si = si;
    this.id = id;
    this.sv = new DOMSignatureValue(signatureValueId);
    if (objs == null) {
        this.objects = Collections.emptyList();
    } else {
        this.objects =
            Collections.unmodifiableList(new ArrayList<XMLObject>(objs));
        for (int i = 0, size = this.objects.size(); i < size; i++) {
            if (!(this.objects.get(i) instanceof XMLObject)) {
                throw new ClassCastException
                    ("objs["+i+"] is not an XMLObject");
            }
        }
    }
    this.ki = ki;
}
项目:jdk7-jdk    文件:DOMXMLSignature.java   
/**
 * Creates a <code>DOMXMLSignature</code> from the specified components.
 *
 * @param si the <code>SignedInfo</code>
 * @param ki the <code>KeyInfo</code>, or <code>null</code> if not specified
 * @param objs a list of <code>XMLObject</code>s or <code>null</code>
 *  if not specified. The list is copied to protect against subsequent
 *  modification.
 * @param id an optional id (specify <code>null</code> to omit)
 * @param signatureValueId an optional id (specify <code>null</code> to
 *  omit)
 * @throws NullPointerException if <code>si</code> is <code>null</code>
 */
public DOMXMLSignature(SignedInfo si, KeyInfo ki, List objs, String id,
    String signatureValueId)
{
    if (si == null) {
        throw new NullPointerException("signedInfo cannot be null");
    }
    this.si = si;
    this.id = id;
    this.sv = new DOMSignatureValue(signatureValueId);
    if (objs == null) {
        this.objects = Collections.EMPTY_LIST;
    } else {
        List objsCopy = new ArrayList(objs);
        for (int i = 0, size = objsCopy.size(); i < size; i++) {
            if (!(objsCopy.get(i) instanceof XMLObject)) {
                throw new ClassCastException
                    ("objs["+i+"] is not an XMLObject");
            }
        }
        this.objects = Collections.unmodifiableList(objsCopy);
    }
    this.ki = ki;
}
项目:openjdk-source-code-learn    文件:DOMXMLSignature.java   
/**
 * Creates a <code>DOMXMLSignature</code> from the specified components.
 *
 * @param si the <code>SignedInfo</code>
 * @param ki the <code>KeyInfo</code>, or <code>null</code> if not specified
 * @param objs a list of <code>XMLObject</code>s or <code>null</code>
 *  if not specified. The list is copied to protect against subsequent
 *  modification.
 * @param id an optional id (specify <code>null</code> to omit)
 * @param signatureValueId an optional id (specify <code>null</code> to
 *  omit)
 * @throws NullPointerException if <code>si</code> is <code>null</code>
 */
public DOMXMLSignature(SignedInfo si, KeyInfo ki, List objs, String id,
    String signatureValueId)
{
    if (si == null) {
        throw new NullPointerException("signedInfo cannot be null");
    }
    this.si = si;
    this.id = id;
    this.sv = new DOMSignatureValue(signatureValueId);
    if (objs == null) {
        this.objects = Collections.EMPTY_LIST;
    } else {
        List objsCopy = new ArrayList(objs);
        for (int i = 0, size = objsCopy.size(); i < size; i++) {
            if (!(objsCopy.get(i) instanceof XMLObject)) {
                throw new ClassCastException
                    ("objs["+i+"] is not an XMLObject");
            }
        }
        this.objects = Collections.unmodifiableList(objsCopy);
    }
    this.ki = ki;
}
项目:OLD-OpenJDK8    文件:DOMKeyInfo.java   
@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }

    if (!(o instanceof KeyInfo)) {
        return false;
    }
    KeyInfo oki = (KeyInfo)o;

    boolean idsEqual = (id == null ? oki.getId() == null
                                   : id.equals(oki.getId()));

    return (keyInfoTypes.equals(oki.getContent()) && idsEqual);
}
项目:OLD-OpenJDK8    文件:DOMXMLSignature.java   
/**
 * Creates a <code>DOMXMLSignature</code> from the specified components.
 *
 * @param si the <code>SignedInfo</code>
 * @param ki the <code>KeyInfo</code>, or <code>null</code> if not specified
 * @param objs a list of <code>XMLObject</code>s or <code>null</code>
 *  if not specified. The list is copied to protect against subsequent
 *  modification.
 * @param id an optional id (specify <code>null</code> to omit)
 * @param signatureValueId an optional id (specify <code>null</code> to
 *  omit)
 * @throws NullPointerException if <code>si</code> is <code>null</code>
 */
public DOMXMLSignature(SignedInfo si, KeyInfo ki,
                       List<? extends XMLObject> objs,
                       String id, String signatureValueId)
{
    if (si == null) {
        throw new NullPointerException("signedInfo cannot be null");
    }
    this.si = si;
    this.id = id;
    this.sv = new DOMSignatureValue(signatureValueId);
    if (objs == null) {
        this.objects = Collections.emptyList();
    } else {
        this.objects =
            Collections.unmodifiableList(new ArrayList<XMLObject>(objs));
        for (int i = 0, size = this.objects.size(); i < size; i++) {
            if (!(this.objects.get(i) instanceof XMLObject)) {
                throw new ClassCastException
                    ("objs["+i+"] is not an XMLObject");
            }
        }
    }
    this.ki = ki;
}
项目:openjdk-jdk7u-jdk    文件:DOMXMLSignature.java   
/**
 * Creates a <code>DOMXMLSignature</code> from the specified components.
 *
 * @param si the <code>SignedInfo</code>
 * @param ki the <code>KeyInfo</code>, or <code>null</code> if not specified
 * @param objs a list of <code>XMLObject</code>s or <code>null</code>
 *  if not specified. The list is copied to protect against subsequent
 *  modification.
 * @param id an optional id (specify <code>null</code> to omit)
 * @param signatureValueId an optional id (specify <code>null</code> to
 *  omit)
 * @throws NullPointerException if <code>si</code> is <code>null</code>
 */
public DOMXMLSignature(SignedInfo si, KeyInfo ki, List objs, String id,
    String signatureValueId)
{
    if (si == null) {
        throw new NullPointerException("signedInfo cannot be null");
    }
    this.si = si;
    this.id = id;
    this.sv = new DOMSignatureValue(signatureValueId);
    if (objs == null) {
        this.objects = Collections.EMPTY_LIST;
    } else {
        List objsCopy = new ArrayList(objs);
        for (int i = 0, size = objsCopy.size(); i < size; i++) {
            if (!(objsCopy.get(i) instanceof XMLObject)) {
                throw new ClassCastException
                    ("objs["+i+"] is not an XMLObject");
            }
        }
        this.objects = Collections.unmodifiableList(objsCopy);
    }
    this.ki = ki;
}