|
Java example source code file (DOMRetrievalMethod.java)
The DOMRetrievalMethod.java Java example source code/* * reserved comment block * DO NOT REMOVE OR ALTER! */ /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. */ /* * =========================================================================== * * (C) Copyright IBM Corp. 2003 All Rights Reserved. * * =========================================================================== */ /* * $Id: DOMRetrievalMethod.java 1333415 2012-05-03 12:03:51Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; import java.io.ByteArrayInputStream; import java.net.URI; import java.net.URISyntaxException; import java.security.Provider; import java.util.*; import javax.xml.XMLConstants; import javax.xml.crypto.*; import javax.xml.crypto.dsig.*; import javax.xml.crypto.dom.DOMCryptoContext; import javax.xml.crypto.dom.DOMURIReference; import javax.xml.crypto.dsig.keyinfo.RetrievalMethod; import javax.xml.parsers.*; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; /** * DOM-based implementation of RetrievalMethod. * * @author Sean Mullan * @author Joyce Leung */ public final class DOMRetrievalMethod extends DOMStructure implements RetrievalMethod, DOMURIReference { private final List<Transform> transforms; private String uri; private String type; private Attr here; /** * Creates a <code>DOMRetrievalMethod containing the specified * URIReference and List of Transforms. * * @param uri the URI * @param type the type * @param transforms a list of {@link Transform}s. The list is defensively * copied to prevent subsequent modification. May be <code>null * or empty. * @throws IllegalArgumentException if the format of <code>uri is * invalid, as specified by Reference's URI attribute in the W3C * specification for XML-Signature Syntax and Processing * @throws NullPointerException if <code>uriReference * is <code>null * @throws ClassCastException if <code>transforms contains any * entries that are not of type {@link Transform} */ public DOMRetrievalMethod(String uri, String type, List<? extends Transform> transforms) { if (uri == null) { throw new NullPointerException("uri cannot be null"); } if (transforms == null || transforms.isEmpty()) { this.transforms = Collections.emptyList(); } else { this.transforms = Collections.unmodifiableList( new ArrayList<Transform>(transforms)); for (int i = 0, size = this.transforms.size(); i < size; i++) { if (!(this.transforms.get(i) instanceof Transform)) { throw new ClassCastException ("transforms["+i+"] is not a valid type"); } } } this.uri = uri; if (!uri.equals("")) { try { new URI(uri); } catch (URISyntaxException e) { throw new IllegalArgumentException(e.getMessage()); } } this.type = type; } /** * Creates a <code>DOMRetrievalMethod from an element. * * @param rmElem a RetrievalMethod element */ public DOMRetrievalMethod(Element rmElem, XMLCryptoContext context, Provider provider) throws MarshalException { // get URI and Type attributes uri = DOMUtils.getAttributeValue(rmElem, "URI"); type = DOMUtils.getAttributeValue(rmElem, "Type"); // get here node here = rmElem.getAttributeNodeNS(null, "URI"); boolean secVal = Utils.secureValidation(context); // get Transforms, if specified List<Transform> transforms = new ArrayList Other Java examples (source code examples)Here is a short list of links related to this Java DOMRetrievalMethod.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.