feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
212
jdkSrc/jdk8/org/ietf/jgss/ChannelBinding.java
Normal file
212
jdkSrc/jdk8/org/ietf/jgss/ChannelBinding.java
Normal file
@@ -0,0 +1,212 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.ietf.jgss;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* This class encapsulates the concept of caller-provided channel
|
||||
* binding information. Channel bindings are used to strengthen the
|
||||
* quality with which peer entity authentication is provided during
|
||||
* context establishment. They enable the GSS-API callers to bind the
|
||||
* establishment of the security context to relevant characteristics
|
||||
* like addresses or to application specific data.<p>
|
||||
*
|
||||
* The caller initiating the security context must determine the
|
||||
* appropriate channel binding values to set in the GSSContext object.
|
||||
* The acceptor must provide an identical binding in order to validate
|
||||
* that received tokens possess correct channel-related characteristics.<p>
|
||||
*
|
||||
* Use of channel bindings is optional in GSS-API. ChannelBinding can be
|
||||
* set for the {@link GSSContext GSSContext} using the {@link
|
||||
* GSSContext#setChannelBinding(ChannelBinding) setChannelBinding} method
|
||||
* before the first call to {@link GSSContext#initSecContext(byte[], int, int)
|
||||
* initSecContext} or {@link GSSContext#acceptSecContext(byte[], int, int)
|
||||
* acceptSecContext} has been performed. Unless the <code>setChannelBinding</code>
|
||||
* method has been used to set the ChannelBinding for a GSSContext object,
|
||||
* <code>null</code> ChannelBinding will be assumed. <p>
|
||||
*
|
||||
* Conceptually, the GSS-API concatenates the initiator and acceptor
|
||||
* address information, and the application supplied byte array to form an
|
||||
* octet string. The mechanism calculates a MIC over this octet string and
|
||||
* binds the MIC to the context establishment token emitted by
|
||||
* <code>initSecContext</code> method of the <code>GSSContext</code>
|
||||
* interface. The same bindings are set by the context acceptor for its
|
||||
* <code>GSSContext</code> object and during processing of the
|
||||
* <code>acceptSecContext</code> method a MIC is calculated in the same
|
||||
* way. The calculated MIC is compared with that found in the token, and if
|
||||
* the MICs differ, accept will throw a <code>GSSException</code> with the
|
||||
* major code set to {@link GSSException#BAD_BINDINGS BAD_BINDINGS}, and
|
||||
* the context will not be established. Some mechanisms may include the
|
||||
* actual channel binding data in the token (rather than just a MIC);
|
||||
* applications should therefore not use confidential data as
|
||||
* channel-binding components.<p>
|
||||
*
|
||||
* Individual mechanisms may impose additional constraints on addresses
|
||||
* that may appear in channel bindings. For example, a mechanism may
|
||||
* verify that the initiator address field of the channel binding
|
||||
* contains the correct network address of the host system. Portable
|
||||
* applications should therefore ensure that they either provide correct
|
||||
* information for the address fields, or omit setting of the addressing
|
||||
* information.
|
||||
*
|
||||
* @author Mayank Upadhyay
|
||||
* @since 1.4
|
||||
*/
|
||||
public class ChannelBinding {
|
||||
|
||||
private InetAddress initiator;
|
||||
private InetAddress acceptor;
|
||||
private byte[] appData;
|
||||
|
||||
/**
|
||||
* Create a ChannelBinding object with user supplied address information
|
||||
* and data. <code>null</code> values can be used for any fields which the
|
||||
* application does not want to specify.
|
||||
*
|
||||
* @param initAddr the address of the context initiator.
|
||||
* <code>null</code> value can be supplied to indicate that the
|
||||
* application does not want to set this value.
|
||||
* @param acceptAddr the address of the context
|
||||
* acceptor. <code>null</code> value can be supplied to indicate that
|
||||
* the application does not want to set this value.
|
||||
* @param appData application supplied data to be used as part of the
|
||||
* channel bindings. <code>null</code> value can be supplied to
|
||||
* indicate that the application does not want to set this value.
|
||||
*/
|
||||
public ChannelBinding(InetAddress initAddr, InetAddress acceptAddr,
|
||||
byte[] appData) {
|
||||
|
||||
initiator = initAddr;
|
||||
acceptor = acceptAddr;
|
||||
|
||||
if (appData != null) {
|
||||
this.appData = new byte[appData.length];
|
||||
java.lang.System.arraycopy(appData, 0, this.appData, 0,
|
||||
appData.length);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a ChannelBinding object without any addressing information.
|
||||
*
|
||||
* @param appData application supplied data to be used as part of the
|
||||
* channel bindings.
|
||||
*/
|
||||
public ChannelBinding(byte[] appData) {
|
||||
this(null, null, appData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the initiator's address for this channel binding.
|
||||
*
|
||||
* @return the initiator's address. <code>null</code> is returned if
|
||||
* the address has not been set.
|
||||
*/
|
||||
public InetAddress getInitiatorAddress() {
|
||||
return initiator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the acceptor's address for this channel binding.
|
||||
*
|
||||
* @return the acceptor's address. null is returned if the address has
|
||||
* not been set.
|
||||
*/
|
||||
public InetAddress getAcceptorAddress() {
|
||||
return acceptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the application specified data for this channel binding.
|
||||
*
|
||||
* @return the application data being used as part of the
|
||||
* ChannelBinding. <code>null</code> is returned if no application data
|
||||
* has been specified for the channel binding.
|
||||
*/
|
||||
public byte[] getApplicationData() {
|
||||
|
||||
if (appData == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] retVal = new byte[appData.length];
|
||||
System.arraycopy(appData, 0, retVal, 0, appData.length);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two instances of ChannelBinding.
|
||||
*
|
||||
* @param obj another ChannelBinding to compare this one with
|
||||
* @return true if the two ChannelBinding's contain
|
||||
* the same values for the initiator and acceptor addresses and the
|
||||
* application data.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
if (this == obj)
|
||||
return true;
|
||||
|
||||
if (! (obj instanceof ChannelBinding))
|
||||
return false;
|
||||
|
||||
ChannelBinding cb = (ChannelBinding) obj;
|
||||
|
||||
if ((initiator != null && cb.initiator == null) ||
|
||||
(initiator == null && cb.initiator != null))
|
||||
return false;
|
||||
|
||||
if (initiator != null && !initiator.equals(cb.initiator))
|
||||
return false;
|
||||
|
||||
if ((acceptor != null && cb.acceptor == null) ||
|
||||
(acceptor == null && cb.acceptor != null))
|
||||
return false;
|
||||
|
||||
if (acceptor != null && !acceptor.equals(cb.acceptor))
|
||||
return false;
|
||||
|
||||
return Arrays.equals(appData, cb.appData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode value for this ChannelBinding object.
|
||||
*
|
||||
* @return a hashCode value
|
||||
*/
|
||||
public int hashCode() {
|
||||
if (initiator != null)
|
||||
return initiator.hashCode();
|
||||
else if (acceptor != null)
|
||||
return acceptor.hashCode();
|
||||
else if (appData != null)
|
||||
return new String(appData).hashCode();
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
1347
jdkSrc/jdk8/org/ietf/jgss/GSSContext.java
Normal file
1347
jdkSrc/jdk8/org/ietf/jgss/GSSContext.java
Normal file
File diff suppressed because it is too large
Load Diff
370
jdkSrc/jdk8/org/ietf/jgss/GSSCredential.java
Normal file
370
jdkSrc/jdk8/org/ietf/jgss/GSSCredential.java
Normal file
@@ -0,0 +1,370 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.ietf.jgss;
|
||||
|
||||
/**
|
||||
* This interface encapsulates the GSS-API credentials for an entity. A
|
||||
* credential contains all the necessary cryptographic information to
|
||||
* enable the creation of a context on behalf of the entity that it
|
||||
* represents. It may contain multiple, distinct, mechanism specific
|
||||
* credential elements, each containing information for a specific
|
||||
* security mechanism, but all referring to the same entity. A credential
|
||||
* may be used to perform context initiation, acceptance, or both.<p>
|
||||
*
|
||||
* Credentials are instantiated using one of the
|
||||
* <code>createCredential</code> methods in the {@link GSSManager
|
||||
* GSSManager} class. GSS-API credential creation is not
|
||||
* intended to provide a "login to the network" function, as such a
|
||||
* function would involve the creation of new credentials rather than
|
||||
* merely acquiring a handle to existing credentials. The
|
||||
* <a href=package-summary.html#useSubjectCredsOnly>section on credential
|
||||
* acquisition</a> in the package level description describes
|
||||
* how existing credentials are acquired in the Java platform. GSS-API
|
||||
* implementations must impose a local access-control policy on callers to
|
||||
* prevent unauthorized callers from acquiring credentials to which they
|
||||
* are not entitled. <p>
|
||||
*
|
||||
* Applications will create a credential object passing the desired
|
||||
* parameters. The application can then use the query methods to obtain
|
||||
* specific information about the instantiated credential object.
|
||||
* When the credential is no longer needed, the application should call
|
||||
* the {@link #dispose() dispose} method to release any resources held by
|
||||
* the credential object and to destroy any cryptographically sensitive
|
||||
* information.<p>
|
||||
*
|
||||
* This example code demonstrates the creation of a GSSCredential
|
||||
* implementation for a specific entity, querying of its fields, and its
|
||||
* release when it is no longer needed:<p>
|
||||
* <pre>
|
||||
* GSSManager manager = GSSManager.getInstance();
|
||||
*
|
||||
* // start by creating a name object for the entity
|
||||
* GSSName name = manager.createName("myusername", GSSName.NT_USER_NAME);
|
||||
*
|
||||
* // now acquire credentials for the entity
|
||||
* GSSCredential cred = manager.createCredential(name,
|
||||
* GSSCredential.ACCEPT_ONLY);
|
||||
*
|
||||
* // display credential information - name, remaining lifetime,
|
||||
* // and the mechanisms it has been acquired over
|
||||
* System.out.println(cred.getName().toString());
|
||||
* System.out.println(cred.getRemainingLifetime());
|
||||
*
|
||||
* Oid [] mechs = cred.getMechs();
|
||||
* if (mechs != null) {
|
||||
* for (int i = 0; i < mechs.length; i++)
|
||||
* System.out.println(mechs[i].toString());
|
||||
* }
|
||||
*
|
||||
* // release system resources held by the credential
|
||||
* cred.dispose();
|
||||
* </pre>
|
||||
*
|
||||
* @see GSSManager#createCredential(int)
|
||||
* @see GSSManager#createCredential(GSSName, int, Oid, int)
|
||||
* @see GSSManager#createCredential(GSSName, int, Oid[], int)
|
||||
* @see #dispose()
|
||||
*
|
||||
* @author Mayank Upadhyay
|
||||
* @since 1.4
|
||||
*/
|
||||
public interface GSSCredential extends Cloneable{
|
||||
|
||||
/**
|
||||
* Credential usage flag requesting that it be usable
|
||||
* for both context initiation and acceptance.
|
||||
*
|
||||
*/
|
||||
public static final int INITIATE_AND_ACCEPT = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Credential usage flag requesting that it be usable
|
||||
* for context initiation only.
|
||||
*
|
||||
*/
|
||||
public static final int INITIATE_ONLY = 1;
|
||||
|
||||
|
||||
/**
|
||||
* Credential usage flag requesting that it be usable
|
||||
* for context acceptance only.
|
||||
*
|
||||
*/
|
||||
public static final int ACCEPT_ONLY = 2;
|
||||
|
||||
|
||||
/**
|
||||
* A lifetime constant representing the default credential lifetime. This
|
||||
* value it set to 0.
|
||||
*/
|
||||
public static final int DEFAULT_LIFETIME = 0;
|
||||
|
||||
/**
|
||||
* A lifetime constant representing indefinite credential lifetime.
|
||||
* This value must is set to the maximum integer value in Java -
|
||||
* {@link java.lang.Integer#MAX_VALUE Integer.MAX_VALUE}.
|
||||
*/
|
||||
public static final int INDEFINITE_LIFETIME = Integer.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* Releases any sensitive information that the GSSCredential object may
|
||||
* be containing. Applications should call this method as soon as the
|
||||
* credential is no longer needed to minimize the time any sensitive
|
||||
* information is maintained.
|
||||
*
|
||||
* @throws GSSException containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public void dispose() throws GSSException;
|
||||
|
||||
/**
|
||||
* Retrieves the name of the entity that the credential asserts.
|
||||
*
|
||||
* @return a GSSName representing the entity
|
||||
*
|
||||
* @throws GSSException containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public GSSName getName() throws GSSException;
|
||||
|
||||
/**
|
||||
* Retrieves a Mechanism Name of the entity that the credential
|
||||
* asserts. This is equivalent to calling {@link
|
||||
* GSSName#canonicalize(Oid) canonicalize} on the value returned by
|
||||
* the other form of {@link #getName() getName}.
|
||||
*
|
||||
* @param mech the Oid of the mechanism for which the Mechanism Name
|
||||
* should be returned.
|
||||
* @return a GSSName representing the entity canonicalized for the
|
||||
* desired mechanism
|
||||
*
|
||||
* @throws GSSException containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#BAD_MECH GSSException.BAD_MECH},
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public GSSName getName(Oid mech) throws GSSException;
|
||||
|
||||
/**
|
||||
* Returns the remaining lifetime in seconds for a credential. The
|
||||
* remaining lifetime is the minimum lifetime amongst all of the underlying
|
||||
* mechanism specific credential elements.
|
||||
*
|
||||
* @return the minimum remaining lifetime in seconds for this
|
||||
* credential. A return value of {@link #INDEFINITE_LIFETIME
|
||||
* INDEFINITE_LIFETIME} indicates that the credential does
|
||||
* not expire. A return value of 0 indicates that the credential is
|
||||
* already expired.
|
||||
*
|
||||
* @see #getRemainingInitLifetime(Oid)
|
||||
* @see #getRemainingAcceptLifetime(Oid)
|
||||
*
|
||||
* @throws GSSException containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public int getRemainingLifetime() throws GSSException;
|
||||
|
||||
/**
|
||||
* Returns the lifetime in seconds for the credential to remain capable
|
||||
* of initiating security contexts using the specified mechanism. This
|
||||
* method queries the initiator credential element that belongs to the
|
||||
* specified mechanism.
|
||||
*
|
||||
* @return the number of seconds remaining in the life of this credential
|
||||
* element. A return value of {@link #INDEFINITE_LIFETIME
|
||||
* INDEFINITE_LIFETIME} indicates that the credential element does not
|
||||
* expire. A return value of 0 indicates that the credential element is
|
||||
* already expired.
|
||||
*
|
||||
* @param mech the Oid of the mechanism whose initiator credential element
|
||||
* should be queried.
|
||||
*
|
||||
* @throws GSSException containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#BAD_MECH GSSException.BAD_MECH},
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public int getRemainingInitLifetime(Oid mech) throws GSSException;
|
||||
|
||||
/**
|
||||
* Returns the lifetime in seconds for the credential to remain capable
|
||||
* of accepting security contexts using the specified mechanism. This
|
||||
* method queries the acceptor credential element that belongs to the
|
||||
* specified mechanism.
|
||||
*
|
||||
* @return the number of seconds remaining in the life of this credential
|
||||
* element. A return value of {@link #INDEFINITE_LIFETIME
|
||||
* INDEFINITE_LIFETIME} indicates that the credential element does not
|
||||
* expire. A return value of 0 indicates that the credential element is
|
||||
* already expired.
|
||||
*
|
||||
* @param mech the Oid of the mechanism whose acceptor credential element
|
||||
* should be queried.
|
||||
*
|
||||
* @throws GSSException containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#BAD_MECH GSSException.BAD_MECH},
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public int getRemainingAcceptLifetime(Oid mech) throws GSSException;
|
||||
|
||||
/**
|
||||
* Returns the credential usage mode. In other words, it
|
||||
* tells us if this credential can be used for initiating or accepting
|
||||
* security contexts. It does not tell us which mechanism(s) has to be
|
||||
* used in order to do so. It is expected that an application will allow
|
||||
* the GSS-API to pick a default mechanism after calling this method.
|
||||
*
|
||||
* @return The return value will be one of {@link #INITIATE_ONLY
|
||||
* INITIATE_ONLY}, {@link #ACCEPT_ONLY ACCEPT_ONLY}, and {@link
|
||||
* #INITIATE_AND_ACCEPT INITIATE_AND_ACCEPT}.
|
||||
*
|
||||
* @throws GSSException containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public int getUsage() throws GSSException;
|
||||
|
||||
/**
|
||||
* Returns the credential usage mode for a specific mechanism. In other
|
||||
* words, it tells us if this credential can be used
|
||||
* for initiating or accepting security contexts with a given underlying
|
||||
* mechanism.
|
||||
*
|
||||
* @return The return value will be one of {@link #INITIATE_ONLY
|
||||
* INITIATE_ONLY}, {@link #ACCEPT_ONLY ACCEPT_ONLY}, and {@link
|
||||
* #INITIATE_AND_ACCEPT INITIATE_AND_ACCEPT}.
|
||||
* @param mech the Oid of the mechanism whose credentials usage mode is
|
||||
* to be determined.
|
||||
*
|
||||
* @throws GSSException containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#BAD_MECH GSSException.BAD_MECH},
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public int getUsage(Oid mech) throws GSSException;
|
||||
|
||||
/**
|
||||
* Returns a list of mechanisms supported by this credential. It does
|
||||
* not tell us which ones can be used to initiate
|
||||
* contexts and which ones can be used to accept contexts. The
|
||||
* application must call the {@link #getUsage(Oid) getUsage} method with
|
||||
* each of the returned Oid's to determine the possible modes of
|
||||
* usage.
|
||||
*
|
||||
* @return an array of Oid's corresponding to the supported mechanisms.
|
||||
*
|
||||
* @throws GSSException containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public Oid[] getMechs() throws GSSException;
|
||||
|
||||
/**
|
||||
* Adds a mechanism specific credential-element to an existing
|
||||
* credential. This method allows the construction of credentials, one
|
||||
* mechanism at a time.<p>
|
||||
*
|
||||
* This routine is envisioned to be used mainly by context acceptors
|
||||
* during the creation of acceptor credentials which are to be used
|
||||
* with a variety of clients using different security mechanisms.<p>
|
||||
*
|
||||
* This routine adds the new credential element "in-place". To add the
|
||||
* element in a new credential, first call <code>clone</code> to obtain a
|
||||
* copy of this credential, then call its <code>add</code> method.<p>
|
||||
*
|
||||
* As always, GSS-API implementations must impose a local access-control
|
||||
* policy on callers to prevent unauthorized callers from acquiring
|
||||
* credentials to which they are not entitled.
|
||||
*
|
||||
* Non-default values for initLifetime and acceptLifetime cannot always
|
||||
* be honored by the underlying mechanisms, thus callers should be
|
||||
* prepared to call {@link #getRemainingInitLifetime(Oid)
|
||||
* getRemainingInitLifetime} and {@link #getRemainingAcceptLifetime(Oid)
|
||||
* getRemainingAcceptLifetime} on the credential.
|
||||
*
|
||||
* @param name the name of the principal for whom this credential is to
|
||||
* be acquired. Use <code>null</code> to specify the default
|
||||
* principal.
|
||||
* @param initLifetime the number of seconds that the credential element
|
||||
* should remain valid for initiating of security contexts. Use {@link
|
||||
* GSSCredential#INDEFINITE_LIFETIME GSSCredential.INDEFINITE_LIFETIME}
|
||||
* to request that the credentials have the maximum permitted lifetime
|
||||
* for this. Use {@link GSSCredential#DEFAULT_LIFETIME
|
||||
* GSSCredential.DEFAULT_LIFETIME} to request default credential lifetime
|
||||
* for this.
|
||||
* @param acceptLifetime the number of seconds that the credential
|
||||
* element should remain valid for accepting security contexts. Use {@link
|
||||
* GSSCredential#INDEFINITE_LIFETIME GSSCredential.INDEFINITE_LIFETIME}
|
||||
* to request that the credentials have the maximum permitted lifetime
|
||||
* for this. Use {@link GSSCredential#DEFAULT_LIFETIME
|
||||
* GSSCredential.DEFAULT_LIFETIME} to request default credential lifetime
|
||||
* for this.
|
||||
* @param mech the mechanism over which the credential is to be acquired.
|
||||
* @param usage the usage mode that this credential
|
||||
* element should add to the credential. The value
|
||||
* of this parameter must be one of:
|
||||
* {@link #INITIATE_AND_ACCEPT INITIATE_AND_ACCEPT},
|
||||
* {@link #ACCEPT_ONLY ACCEPT_ONLY}, and
|
||||
* {@link #INITIATE_ONLY INITIATE_ONLY}.
|
||||
*
|
||||
* @throws GSSException containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#DUPLICATE_ELEMENT
|
||||
* GSSException.DUPLICATE_ELEMENT},
|
||||
* {@link GSSException#BAD_MECH GSSException.BAD_MECH},
|
||||
* {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE},
|
||||
* {@link GSSException#NO_CRED GSSException.NO_CRED},
|
||||
* {@link GSSException#CREDENTIALS_EXPIRED
|
||||
* GSSException.CREDENTIALS_EXPIRED},
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public void add(GSSName name, int initLifetime, int acceptLifetime,
|
||||
Oid mech, int usage) throws GSSException;
|
||||
|
||||
/**
|
||||
* Tests if this GSSCredential asserts the same entity as the supplied
|
||||
* object. The two credentials must be acquired over the same
|
||||
* mechanisms and must refer to the same principal.
|
||||
*
|
||||
* @return <code>true</code> if the two GSSCredentials assert the same
|
||||
* entity; <code>false</code> otherwise.
|
||||
* @param another another GSSCredential for comparison to this one
|
||||
*/
|
||||
public boolean equals(Object another);
|
||||
|
||||
/**
|
||||
* Returns a hashcode value for this GSSCredential.
|
||||
*
|
||||
* @return a hashCode value
|
||||
*/
|
||||
public int hashCode();
|
||||
|
||||
}
|
||||
403
jdkSrc/jdk8/org/ietf/jgss/GSSException.java
Normal file
403
jdkSrc/jdk8/org/ietf/jgss/GSSException.java
Normal file
@@ -0,0 +1,403 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.ietf.jgss;
|
||||
|
||||
/**
|
||||
* This exception is thrown whenever a GSS-API error occurs, including
|
||||
* any mechanism specific error. It may contain both the major and the
|
||||
* minor GSS-API status codes. Major error codes are those defined at the
|
||||
* GSS-API level in this class. Minor error codes are mechanism specific
|
||||
* error codes that can provide additional information. The underlying
|
||||
* mechanism implementation is responsible for setting appropriate minor
|
||||
* status codes when throwing this exception. Aside from delivering the
|
||||
* numeric error codes to the caller, this class performs the mapping from
|
||||
* their numeric values to textual representations. <p>
|
||||
*
|
||||
* @author Mayank Upadhyay
|
||||
* @since 1.4
|
||||
*/
|
||||
public class GSSException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -2706218945227726672L;
|
||||
|
||||
/**
|
||||
* Channel bindings mismatch.
|
||||
*/
|
||||
public static final int BAD_BINDINGS = 1; //start with 1
|
||||
|
||||
/**
|
||||
* Unsupported mechanism requested.
|
||||
*/
|
||||
public static final int BAD_MECH = 2;
|
||||
|
||||
/**
|
||||
* Invalid name provided.
|
||||
*/
|
||||
public static final int BAD_NAME = 3;
|
||||
|
||||
/**
|
||||
* Name of unsupported type provided.
|
||||
*/
|
||||
public static final int BAD_NAMETYPE = 4;
|
||||
|
||||
/**
|
||||
* Invalid status code.
|
||||
*/
|
||||
/*
|
||||
* This is meant to be thrown by display_status which displays
|
||||
* major/minor status when an incorrect status type is passed in to it!
|
||||
*/
|
||||
public static final int BAD_STATUS = 5;
|
||||
|
||||
/**
|
||||
* Token had invalid integrity check.
|
||||
*/
|
||||
public static final int BAD_MIC = 6;
|
||||
|
||||
/**
|
||||
* Security context expired.
|
||||
*/
|
||||
public static final int CONTEXT_EXPIRED = 7;
|
||||
|
||||
/**
|
||||
* Expired credentials.
|
||||
*/
|
||||
public static final int CREDENTIALS_EXPIRED = 8;
|
||||
|
||||
/**
|
||||
* Defective credentials.
|
||||
*
|
||||
*/
|
||||
public static final int DEFECTIVE_CREDENTIAL = 9;
|
||||
|
||||
/**
|
||||
* Defective token.
|
||||
*
|
||||
*/
|
||||
public static final int DEFECTIVE_TOKEN = 10;
|
||||
|
||||
/**
|
||||
* General failure, unspecified at GSS-API level.
|
||||
*/
|
||||
public static final int FAILURE = 11;
|
||||
|
||||
/**
|
||||
* Invalid security context.
|
||||
*/
|
||||
public static final int NO_CONTEXT = 12;
|
||||
|
||||
/**
|
||||
* Invalid credentials.
|
||||
*/
|
||||
public static final int NO_CRED = 13;
|
||||
|
||||
/**
|
||||
* Unsupported QOP value.
|
||||
*/
|
||||
public static final int BAD_QOP = 14;
|
||||
|
||||
/**
|
||||
* Operation unauthorized.
|
||||
*/
|
||||
public static final int UNAUTHORIZED = 15;
|
||||
|
||||
/**
|
||||
* Operation unavailable.
|
||||
*/
|
||||
public static final int UNAVAILABLE = 16;
|
||||
|
||||
/**
|
||||
* Duplicate credential element requested.
|
||||
*/
|
||||
public static final int DUPLICATE_ELEMENT = 17;
|
||||
|
||||
/**
|
||||
* Name contains multi-mechanism elements.
|
||||
*/
|
||||
public static final int NAME_NOT_MN = 18;
|
||||
|
||||
/**
|
||||
* The token was a duplicate of an earlier token.
|
||||
* This is a fatal error code that may occur during
|
||||
* context establishment. It is not used to indicate
|
||||
* supplementary status values. The MessageProp object is
|
||||
* used for that purpose.
|
||||
*/
|
||||
public static final int DUPLICATE_TOKEN = 19;
|
||||
|
||||
/**
|
||||
* The token's validity period has expired. This is a
|
||||
* fatal error code that may occur during context establishment.
|
||||
* It is not used to indicate supplementary status values.
|
||||
* The MessageProp object is used for that purpose.
|
||||
*/
|
||||
public static final int OLD_TOKEN = 20;
|
||||
|
||||
|
||||
/**
|
||||
* A later token has already been processed. This is a
|
||||
* fatal error code that may occur during context establishment.
|
||||
* It is not used to indicate supplementary status values.
|
||||
* The MessageProp object is used for that purpose.
|
||||
*/
|
||||
public static final int UNSEQ_TOKEN = 21;
|
||||
|
||||
|
||||
/**
|
||||
* An expected per-message token was not received. This is a
|
||||
* fatal error code that may occur during context establishment.
|
||||
* It is not used to indicate supplementary status values.
|
||||
* The MessageProp object is used for that purpose.
|
||||
*/
|
||||
public static final int GAP_TOKEN = 22;
|
||||
|
||||
|
||||
private static String[] messages = {
|
||||
"Channel binding mismatch", // BAD_BINDINGS
|
||||
"Unsupported mechanism requested", // BAD_MECH
|
||||
"Invalid name provided", // BAD_NAME
|
||||
"Name of unsupported type provided", //BAD_NAMETYPE
|
||||
"Invalid input status selector", // BAD_STATUS
|
||||
"Token had invalid integrity check", // BAD_SIG
|
||||
"Specified security context expired", // CONTEXT_EXPIRED
|
||||
"Expired credentials detected", // CREDENTIALS_EXPIRED
|
||||
"Defective credential detected", // DEFECTIVE_CREDENTIAL
|
||||
"Defective token detected", // DEFECTIVE_TOKEN
|
||||
"Failure unspecified at GSS-API level", // FAILURE
|
||||
"Security context init/accept not yet called or context deleted",
|
||||
// NO_CONTEXT
|
||||
"No valid credentials provided", // NO_CRED
|
||||
"Unsupported QOP value", // BAD_QOP
|
||||
"Operation unauthorized", // UNAUTHORIZED
|
||||
"Operation unavailable", // UNAVAILABLE
|
||||
"Duplicate credential element requested", //DUPLICATE_ELEMENT
|
||||
"Name contains multi-mechanism elements", // NAME_NOT_MN
|
||||
"The token was a duplicate of an earlier token", //DUPLICATE_TOKEN
|
||||
"The token's validity period has expired", //OLD_TOKEN
|
||||
"A later token has already been processed", //UNSEQ_TOKEN
|
||||
"An expected per-message token was not received", //GAP_TOKEN
|
||||
};
|
||||
|
||||
/**
|
||||
* The major code for this exception
|
||||
*
|
||||
* @serial
|
||||
*/
|
||||
private int major;
|
||||
|
||||
/**
|
||||
* The minor code for this exception
|
||||
*
|
||||
* @serial
|
||||
*/
|
||||
private int minor = 0;
|
||||
|
||||
/**
|
||||
* The text string for minor code
|
||||
*
|
||||
* @serial
|
||||
*/
|
||||
private String minorMessage = null;
|
||||
|
||||
/**
|
||||
* Alternate text string for major code
|
||||
*
|
||||
* @serial
|
||||
*/
|
||||
|
||||
private String majorString = null;
|
||||
|
||||
/**
|
||||
* Creates a GSSException object with a specified major code.
|
||||
*
|
||||
* @param majorCode the The GSS error code for the problem causing this
|
||||
* exception to be thrown.
|
||||
*/
|
||||
public GSSException (int majorCode) {
|
||||
|
||||
if (validateMajor(majorCode))
|
||||
major = majorCode;
|
||||
else
|
||||
major = FAILURE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a GSSException object with a specified major code and a
|
||||
* specific major string for it.
|
||||
*
|
||||
* @param majorCode the fatal error code causing this exception.
|
||||
* @param majorString an expicit message to be included in this exception
|
||||
*/
|
||||
GSSException (int majorCode, String majorString) {
|
||||
|
||||
if (validateMajor(majorCode))
|
||||
major = majorCode;
|
||||
else
|
||||
major = FAILURE;
|
||||
this.majorString = majorString;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a GSSException object with the specified major code, minor
|
||||
* code, and minor code textual explanation. This constructor is to be
|
||||
* used when the exception is originating from the underlying mechanism
|
||||
* level. It allows the setting of both the GSS code and the mechanism
|
||||
* code.
|
||||
*
|
||||
* @param majorCode the GSS error code for the problem causing this
|
||||
* exception to be thrown.
|
||||
* @param minorCode the mechanism level error code for the problem
|
||||
* causing this exception to be thrown.
|
||||
* @param minorString the textual explanation of the mechanism error
|
||||
* code.
|
||||
*/
|
||||
public GSSException (int majorCode, int minorCode, String minorString) {
|
||||
|
||||
if (validateMajor(majorCode))
|
||||
major = majorCode;
|
||||
else
|
||||
major = FAILURE;
|
||||
|
||||
minor = minorCode;
|
||||
minorMessage = minorString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the GSS-API level major error code for the problem causing
|
||||
* this exception to be thrown. Major error codes are
|
||||
* defined at the mechanism independent GSS-API level in this
|
||||
* class. Mechanism specific error codes that might provide more
|
||||
* information are set as the minor error code.
|
||||
*
|
||||
* @return int the GSS-API level major error code causing this exception
|
||||
* @see #getMajorString
|
||||
* @see #getMinor
|
||||
* @see #getMinorString
|
||||
*/
|
||||
public int getMajor() {
|
||||
return major;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mechanism level error code for the problem causing this
|
||||
* exception to be thrown. The minor code is set by the underlying
|
||||
* mechanism.
|
||||
*
|
||||
* @return int the mechanism error code; 0 indicates that it has not
|
||||
* been set.
|
||||
* @see #getMinorString
|
||||
* @see #setMinor
|
||||
*/
|
||||
public int getMinor(){
|
||||
return minor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string explaining the GSS-API level major error code in
|
||||
* this exception.
|
||||
*
|
||||
* @return String explanation string for the major error code
|
||||
* @see #getMajor
|
||||
* @see #toString
|
||||
*/
|
||||
public String getMajorString() {
|
||||
|
||||
if (majorString != null)
|
||||
return majorString;
|
||||
else
|
||||
return messages[major - 1];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a string explaining the mechanism specific error code.
|
||||
* If the minor status code is 0, then no mechanism level error details
|
||||
* will be available.
|
||||
*
|
||||
* @return String a textual explanation of mechanism error code
|
||||
* @see #getMinor
|
||||
* @see #getMajorString
|
||||
* @see #toString
|
||||
*/
|
||||
public String getMinorString() {
|
||||
|
||||
return minorMessage;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used by the exception thrower to set the mechanism
|
||||
* level minor error code and its string explanation. This is used by
|
||||
* mechanism providers to indicate error details.
|
||||
*
|
||||
* @param minorCode the mechanism specific error code
|
||||
* @param message textual explanation of the mechanism error code
|
||||
* @see #getMinor
|
||||
*/
|
||||
public void setMinor(int minorCode, String message) {
|
||||
|
||||
minor = minorCode;
|
||||
minorMessage = message;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a textual representation of both the major and the minor
|
||||
* status codes.
|
||||
*
|
||||
* @return a String with the error descriptions
|
||||
*/
|
||||
public String toString() {
|
||||
return ("GSSException: " + getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a textual representation of both the major and the minor
|
||||
* status codes.
|
||||
*
|
||||
* @return a String with the error descriptions
|
||||
*/
|
||||
public String getMessage() {
|
||||
if (minor == 0)
|
||||
return (getMajorString());
|
||||
|
||||
return (getMajorString()
|
||||
+ " (Mechanism level: " + getMinorString() + ")");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Validates the major code in the proper range.
|
||||
*/
|
||||
private boolean validateMajor(int major) {
|
||||
|
||||
if (major > 0 && major <= messages.length)
|
||||
return (true);
|
||||
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
729
jdkSrc/jdk8/org/ietf/jgss/GSSManager.java
Normal file
729
jdkSrc/jdk8/org/ietf/jgss/GSSManager.java
Normal file
@@ -0,0 +1,729 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.ietf.jgss;
|
||||
|
||||
import java.security.Provider;
|
||||
|
||||
/**
|
||||
* This class serves as a factory for other important
|
||||
* GSS-API classes and also provides information about the mechanisms that
|
||||
* are supported. It can create instances of classes
|
||||
* implementing the following three GSS-API interfaces: {@link
|
||||
* GSSName GSSName}, {@link GSSCredential GSSCredential}, and {@link
|
||||
* GSSContext GSSContext}. It also has methods to query for the list
|
||||
* of available mechanisms and the nametypes that each mechanism
|
||||
* supports.<p>
|
||||
*
|
||||
* An instance of the default <code>GSSManager</code> subclass
|
||||
* may be obtained through the static method {@link #getInstance()
|
||||
* getInstance}, but applications are free to instantiate other subclasses
|
||||
* of <code>GSSManager</code>. The default <code>GSSManager</code> instance
|
||||
* will support the Kerberos v5 GSS-API mechanism in addition to any
|
||||
* others. This mechanism is identified by the Oid "1.2.840.113554.1.2.2"
|
||||
* and is defined in RFC 1964.<p>
|
||||
*
|
||||
* A subclass extending the <code>GSSManager</code> abstract class may be
|
||||
* implemented as a modular provider based layer that utilizes some well
|
||||
* known service provider specification. The <code>GSSManager</code> API
|
||||
* allows the application to set provider preferences on
|
||||
* such an implementation. These methods also allow the implementation to
|
||||
* throw a well-defined exception in case provider based configuration is
|
||||
* not supported. Applications that expect to be portable should be aware
|
||||
* of this and recover cleanly by catching the exception.<p>
|
||||
*
|
||||
* It is envisioned that there will be three most common ways in which
|
||||
* providers will be used:<p>
|
||||
* <ol>
|
||||
* <li> The application does not care about what provider is used (the
|
||||
* default case).
|
||||
* <li> The application wants a particular provider to be used
|
||||
* preferentially, either for a particular mechanism or all the
|
||||
* time, irrespective of mechanism.
|
||||
* <li> The application wants to use the locally configured providers
|
||||
* as far as possible but if support is missing for one or more
|
||||
* mechanisms then it wants to fall back on its own provider.
|
||||
*</ol><p>
|
||||
*
|
||||
* The <code>GSSManager</code> class has two methods that enable these modes of
|
||||
* usage: {@link #addProviderAtFront(Provider, Oid) addProviderAtFront} and
|
||||
* {@link #addProviderAtEnd(Provider, Oid) addProviderAtEnd}. These methods
|
||||
* have the effect of creating an ordered list of <i><provider,
|
||||
* oid></i> pairs where each pair indicates a preference of provider
|
||||
* for a given oid.<p>
|
||||
*
|
||||
* It is important to note that there are certain interactions
|
||||
* between the different GSS-API objects that are created by a
|
||||
* GSSManager, where the provider that is used for a particular mechanism
|
||||
* might need to be consistent across all objects. For instance, if a
|
||||
* GSSCredential contains elements from a provider <i>p</i> for a mechanism
|
||||
* <i>m</i>, it should generally be passed in to a GSSContext that will use
|
||||
* provider <i>p</i> for the mechanism <i>m</i>. A simple rule of thumb
|
||||
* that will maximize portability is that objects created from different
|
||||
* GSSManager's should not be mixed, and if possible, a different
|
||||
* GSSManager instance should be created if the application wants to invoke
|
||||
* the <code>addProviderAtFront</code> method on a GSSManager that has
|
||||
* already created an object.<p>
|
||||
*
|
||||
* Here is some sample code showing how the GSSManager might be used: <p>
|
||||
* <pre>
|
||||
* GSSManager manager = GSSManager.getInstance();
|
||||
*
|
||||
* Oid krb5Mechanism = new Oid("1.2.840.113554.1.2.2");
|
||||
* Oid krb5PrincipalNameType = new Oid("1.2.840.113554.1.2.2.1");
|
||||
*
|
||||
* // Identify who the client wishes to be
|
||||
* GSSName userName = manager.createName("duke", GSSName.NT_USER_NAME);
|
||||
*
|
||||
* // Identify the name of the server. This uses a Kerberos specific
|
||||
* // name format.
|
||||
* GSSName serverName = manager.createName("nfs/foo.sun.com",
|
||||
* krb5PrincipalNameType);
|
||||
*
|
||||
* // Acquire credentials for the user
|
||||
* GSSCredential userCreds = manager.createCredential(userName,
|
||||
* GSSCredential.DEFAULT_LIFETIME,
|
||||
* krb5Mechanism,
|
||||
* GSSCredential.INITIATE_ONLY);
|
||||
*
|
||||
* // Instantiate and initialize a security context that will be
|
||||
* // established with the server
|
||||
* GSSContext context = manager.createContext(serverName,
|
||||
* krb5Mechanism,
|
||||
* userCreds,
|
||||
* GSSContext.DEFAULT_LIFETIME);
|
||||
* </pre><p>
|
||||
*
|
||||
* The server side might use the following variation of this source:<p>
|
||||
*
|
||||
* <pre>
|
||||
* // Acquire credentials for the server
|
||||
* GSSCredential serverCreds = manager.createCredential(serverName,
|
||||
* GSSCredential.DEFAULT_LIFETIME,
|
||||
* krb5Mechanism,
|
||||
* GSSCredential.ACCEPT_ONLY);
|
||||
*
|
||||
* // Instantiate and initialize a security context that will
|
||||
* // wait for an establishment request token from the client
|
||||
* GSSContext context = manager.createContext(serverCreds);
|
||||
* </pre>
|
||||
*
|
||||
* @author Mayank Upadhyay
|
||||
* @see GSSName
|
||||
* @see GSSCredential
|
||||
* @see GSSContext
|
||||
* @since 1.4
|
||||
*/
|
||||
public abstract class GSSManager {
|
||||
|
||||
/**
|
||||
* Returns the default GSSManager implementation.
|
||||
*
|
||||
* @return a GSSManager implementation
|
||||
*/
|
||||
public static GSSManager getInstance() {
|
||||
return new sun.security.jgss.GSSManagerImpl();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of mechanisms that are available to GSS-API callers
|
||||
* through this GSSManager. The default GSSManager obtained from the
|
||||
* {@link #getInstance() getInstance()} method includes the Oid
|
||||
* "1.2.840.113554.1.2.2" in its list. This Oid identifies the Kerberos
|
||||
* v5 GSS-API mechanism that is defined in RFC 1964.
|
||||
*
|
||||
* @return an array of Oid objects corresponding to the mechanisms that
|
||||
* are available. A <code>null</code> value is returned when no
|
||||
* mechanism are available (an example of this would be when mechanism
|
||||
* are dynamically configured, and currently no mechanisms are
|
||||
* installed).
|
||||
*/
|
||||
public abstract Oid[] getMechs();
|
||||
|
||||
/**
|
||||
* Returns then name types supported by the indicated mechanism.<p>
|
||||
*
|
||||
* The default GSSManager instance includes support for the Kerberos v5
|
||||
* mechanism. When this mechanism ("1.2.840.113554.1.2.2") is indicated,
|
||||
* the returned list will contain at least the following nametypes:
|
||||
* {@link GSSName#NT_HOSTBASED_SERVICE GSSName.NT_HOSTBASED_SERVICE},
|
||||
* {@link GSSName#NT_EXPORT_NAME GSSName.NT_EXPORT_NAME}, and the
|
||||
* Kerberos v5 specific Oid "1.2.840.113554.1.2.2.1". The namespace for
|
||||
* the Oid "1.2.840.113554.1.2.2.1" is defined in RFC 1964.
|
||||
*
|
||||
* @return an array of Oid objects corresponding to the name types that
|
||||
* the mechanism supports.
|
||||
* @param mech the Oid of the mechanism to query
|
||||
*
|
||||
* @see #getMechsForName(Oid)
|
||||
*
|
||||
* @throws GSSException containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#BAD_MECH GSSException.BAD_MECH}
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public abstract Oid[] getNamesForMech(Oid mech)
|
||||
throws GSSException;
|
||||
|
||||
/**
|
||||
* Returns a list of mechanisms that support the indicated name type.<p>
|
||||
*
|
||||
* The Kerberos v5 mechanism ("1.2.840.113554.1.2.2") will always be
|
||||
* returned in this list when the indicated nametype is one of
|
||||
* {@link GSSName#NT_HOSTBASED_SERVICE GSSName.NT_HOSTBASED_SERVICE},
|
||||
* {@link GSSName#NT_EXPORT_NAME GSSName.NT_EXPORT_NAME}, or
|
||||
* "1.2.840.113554.1.2.2.1".
|
||||
*
|
||||
* @return an array of Oid objects corresponding to the mechanisms that
|
||||
* support the specified name type. <code>null</code> is returned when no
|
||||
* mechanisms are found to support the specified name type.
|
||||
* @param nameType the Oid of the name type to look for
|
||||
*
|
||||
* @see #getNamesForMech(Oid)
|
||||
*/
|
||||
public abstract Oid[] getMechsForName(Oid nameType);
|
||||
|
||||
/**
|
||||
* Factory method to convert a string name from the
|
||||
* specified namespace to a GSSName object. In general, the
|
||||
* <code>GSSName</code> object created will contain multiple
|
||||
* representations of the name, one for each mechanism that is
|
||||
* supported; two examples that are exceptions to this are when
|
||||
* the namespace type parameter indicates NT_EXPORT_NAME or when the
|
||||
* GSS-API implementation is not multi-mechanism. It is
|
||||
* not recommended to use this method with a NT_EXPORT_NAME type because
|
||||
* representing a previously exported name consisting of arbitrary bytes
|
||||
* as a String might cause problems with character encoding schemes. In
|
||||
* such cases it is recommended that the bytes be passed in directly to
|
||||
* the overloaded form of this method {@link #createName(byte[],
|
||||
* Oid) createName}.
|
||||
*
|
||||
* @param nameStr the string representing a printable form of the name to
|
||||
* create.
|
||||
* @param nameType the Oid specifying the namespace of the printable name
|
||||
* supplied. <code>null</code> can be used to specify
|
||||
* that a mechanism specific default printable syntax should
|
||||
* be assumed by each mechanism that examines nameStr.
|
||||
* It is not advisable to use the nametype NT_EXPORT_NAME with this
|
||||
* method.
|
||||
* @return a GSSName representing the indicated principal
|
||||
*
|
||||
* @see GSSName
|
||||
* @see GSSName#NT_EXPORT_NAME
|
||||
*
|
||||
* @throws GSSException containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE},
|
||||
* {@link GSSException#BAD_NAME GSSException.BAD_NAME},
|
||||
* {@link GSSException#BAD_MECH GSSException.BAD_MECH},
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public abstract GSSName createName(String nameStr, Oid nameType)
|
||||
throws GSSException;
|
||||
|
||||
/**
|
||||
* Factory method to convert a byte array containing a
|
||||
* name from the specified namespace to a GSSName object. In general,
|
||||
* the <code>GSSName</code> object created will contain multiple
|
||||
* representations of the name, one for each mechanism that is
|
||||
* supported; two examples that are exceptions to this are when the
|
||||
* namespace type parameter indicates NT_EXPORT_NAME or when the
|
||||
* GSS-API implementation is not multi-mechanism. The bytes that are
|
||||
* passed in are interpreted by each underlying mechanism according to
|
||||
* some encoding scheme of its choice for the given nametype.
|
||||
*
|
||||
* @param name the byte array containing the name to create
|
||||
* @param nameType the Oid specifying the namespace of the name supplied
|
||||
* in the byte array. <code>null</code> can be used to specify that a
|
||||
* mechanism specific default syntax should be assumed by each mechanism
|
||||
* that examines the byte array.
|
||||
* @return a GSSName representing the indicated principal
|
||||
*
|
||||
* @see GSSName
|
||||
* @see GSSName#NT_EXPORT_NAME
|
||||
*
|
||||
* @throws GSSException containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE},
|
||||
* {@link GSSException#BAD_NAME GSSException.BAD_NAME},
|
||||
* {@link GSSException#BAD_MECH GSSException.BAD_MECH},
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public abstract GSSName createName(byte name[], Oid nameType)
|
||||
throws GSSException;
|
||||
|
||||
/**
|
||||
* Factory method to convert a string name from the
|
||||
* specified namespace to a GSSName object and canonicalize it at the
|
||||
* same time for a mechanism. In other words, this method is
|
||||
* a utility that does the equivalent of two steps: the {@link
|
||||
* #createName(String, Oid) createName} and then also the {@link
|
||||
* GSSName#canonicalize(Oid) GSSName.canonicalize}.
|
||||
*
|
||||
* @param nameStr the string representing a printable form of the name to
|
||||
* create.
|
||||
* @param nameType the Oid specifying the namespace of the printable name
|
||||
* supplied. <code>null</code> can be used to specify
|
||||
* that a mechanism specific default printable syntax should
|
||||
* be assumed by each mechanism that examines nameStr.
|
||||
* It is not advisable to use the nametype NT_EXPORT_NAME with this
|
||||
* method.
|
||||
* @param mech Oid specifying the mechanism for which the name should be
|
||||
* canonicalized
|
||||
* @return a GSSName representing the indicated principal
|
||||
*
|
||||
* @see GSSName#canonicalize(Oid)
|
||||
* @see GSSName#NT_EXPORT_NAME
|
||||
*
|
||||
* @throws GSSException containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE},
|
||||
* {@link GSSException#BAD_NAME GSSException.BAD_NAME},
|
||||
* {@link GSSException#BAD_MECH GSSException.BAD_MECH},
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public abstract GSSName createName(String nameStr, Oid nameType,
|
||||
Oid mech) throws GSSException;
|
||||
|
||||
/**
|
||||
* Factory method to convert a byte array containing a
|
||||
* name from the specified namespace to a GSSName object and canonicalize
|
||||
* it at the same time for a mechanism. In other words, this method is a
|
||||
* utility that does the equivalent of two steps: the {@link
|
||||
* #createName(byte[], Oid) createName} and then also {@link
|
||||
* GSSName#canonicalize(Oid) GSSName.canonicalize}.
|
||||
*
|
||||
* @param name the byte array containing the name to create
|
||||
* @param nameType the Oid specifying the namespace of the name supplied
|
||||
* in the byte array. <code>null</code> can be used to specify that a
|
||||
* mechanism specific default syntax should be assumed by each mechanism
|
||||
* that examines the byte array.
|
||||
* @param mech Oid specifying the mechanism for which the name should be
|
||||
* canonicalized
|
||||
* @return a GSSName representing the indicated principal
|
||||
*
|
||||
* @see GSSName#canonicalize(Oid)
|
||||
* @see GSSName#NT_EXPORT_NAME
|
||||
*
|
||||
* @throws GSSException containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE},
|
||||
* {@link GSSException#BAD_NAME GSSException.BAD_NAME},
|
||||
* {@link GSSException#BAD_MECH GSSException.BAD_MECH},
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public abstract GSSName createName(byte name[], Oid nameType, Oid mech)
|
||||
throws GSSException;
|
||||
|
||||
/**
|
||||
* Factory method for acquiring default credentials. This will cause
|
||||
* the GSS-API to use system specific defaults for the set of mechanisms,
|
||||
* name, and lifetime.<p>
|
||||
*
|
||||
* GSS-API mechanism providers must impose a local access-control
|
||||
* policy on callers to prevent unauthorized callers from acquiring
|
||||
* credentials to which they are not entitled. The kinds of permissions
|
||||
* needed by different mechanism providers will be documented on a
|
||||
* per-mechanism basis. A failed permission check might cause a {@link
|
||||
* java.lang.SecurityException SecurityException} to be thrown from
|
||||
* this method.
|
||||
*
|
||||
* @param usage The intended usage for this credential object. The value
|
||||
* of this parameter must be one of:
|
||||
* {@link GSSCredential#INITIATE_AND_ACCEPT
|
||||
* GSSCredential.INITIATE_AND_ACCEPT},
|
||||
* {@link GSSCredential#ACCEPT_ONLY GSSCredential.ACCEPT_ONLY}, and
|
||||
* {@link GSSCredential#INITIATE_ONLY GSSCredential.INITIATE_ONLY}.
|
||||
* @return a GSSCredential of the requested type.
|
||||
*
|
||||
* @see GSSCredential
|
||||
*
|
||||
* @throws GSSException containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#BAD_MECH GSSException.BAD_MECH},
|
||||
* {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE},
|
||||
* {@link GSSException#BAD_NAME GSSException.BAD_NAME},
|
||||
* {@link GSSException#CREDENTIALS_EXPIRED
|
||||
* GSSException.CREDENTIALS_EXPIRED},
|
||||
* {@link GSSException#NO_CRED GSSException.NO_CRED},
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public abstract GSSCredential createCredential (int usage)
|
||||
throws GSSException;
|
||||
|
||||
/**
|
||||
* Factory method for acquiring a single mechanism credential.<p>
|
||||
*
|
||||
* GSS-API mechanism providers must impose a local access-control
|
||||
* policy on callers to prevent unauthorized callers from acquiring
|
||||
* credentials to which they are not entitled. The kinds of permissions
|
||||
* needed by different mechanism providers will be documented on a
|
||||
* per-mechanism basis. A failed permission check might cause a {@link
|
||||
* java.lang.SecurityException SecurityException} to be thrown from
|
||||
* this method. <p>
|
||||
*
|
||||
* Non-default values for lifetime cannot always be honored by the
|
||||
* underlying mechanisms, thus applications should be prepared to call
|
||||
* {@link GSSCredential#getRemainingLifetime() getRemainingLifetime}
|
||||
* on the returned credential.<p>
|
||||
*
|
||||
* @param name the name of the principal for whom this credential is to be
|
||||
* acquired. Use <code>null</code> to specify the default principal.
|
||||
* @param lifetime The number of seconds that credentials should remain
|
||||
* valid. Use {@link GSSCredential#INDEFINITE_LIFETIME
|
||||
* GSSCredential.INDEFINITE_LIFETIME} to request that the credentials
|
||||
* have the maximum permitted lifetime. Use {@link
|
||||
* GSSCredential#DEFAULT_LIFETIME GSSCredential.DEFAULT_LIFETIME} to
|
||||
* request default credential lifetime.
|
||||
* @param mech the Oid of the desired mechanism. Use <code>(Oid) null
|
||||
* </code> to request the default mechanism.
|
||||
* @param usage The intended usage for this credential object. The value
|
||||
* of this parameter must be one of:
|
||||
* {@link GSSCredential#INITIATE_AND_ACCEPT
|
||||
* GSSCredential.INITIATE_AND_ACCEPT},
|
||||
* {@link GSSCredential#ACCEPT_ONLY GSSCredential.ACCEPT_ONLY}, and
|
||||
* {@link GSSCredential#INITIATE_ONLY GSSCredential.INITIATE_ONLY}.
|
||||
* @return a GSSCredential of the requested type.
|
||||
*
|
||||
* @see GSSCredential
|
||||
*
|
||||
* @throws GSSException containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#BAD_MECH GSSException.BAD_MECH},
|
||||
* {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE},
|
||||
* {@link GSSException#BAD_NAME GSSException.BAD_NAME},
|
||||
* {@link GSSException#CREDENTIALS_EXPIRED
|
||||
* GSSException.CREDENTIALS_EXPIRED},
|
||||
* {@link GSSException#NO_CRED GSSException.NO_CRED},
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public abstract GSSCredential createCredential (GSSName name,
|
||||
int lifetime, Oid mech, int usage)
|
||||
throws GSSException;
|
||||
|
||||
/**
|
||||
* Factory method for acquiring credentials over a set of
|
||||
* mechanisms. This method attempts to acquire credentials for
|
||||
* each of the mechanisms specified in the array called mechs. To
|
||||
* determine the list of mechanisms for which the acquisition of
|
||||
* credentials succeeded, the caller should use the {@link
|
||||
* GSSCredential#getMechs() GSSCredential.getMechs} method.<p>
|
||||
*
|
||||
* GSS-API mechanism providers must impose a local access-control
|
||||
* policy on callers to prevent unauthorized callers from acquiring
|
||||
* credentials to which they are not entitled. The kinds of permissions
|
||||
* needed by different mechanism providers will be documented on a
|
||||
* per-mechanism basis. A failed permission check might cause a {@link
|
||||
* java.lang.SecurityException SecurityException} to be thrown from
|
||||
* this method.<p>
|
||||
*
|
||||
* Non-default values for lifetime cannot always be honored by the
|
||||
* underlying mechanisms, thus applications should be prepared to call
|
||||
* {@link GSSCredential#getRemainingLifetime() getRemainingLifetime}
|
||||
* on the returned credential.<p>
|
||||
*
|
||||
* @param name the name of the principal for whom this credential is to
|
||||
* be acquired. Use <code>null</code> to specify the default
|
||||
* principal.
|
||||
* @param lifetime The number of seconds that credentials should remain
|
||||
* valid. Use {@link GSSCredential#INDEFINITE_LIFETIME
|
||||
* GSSCredential.INDEFINITE_LIFETIME} to request that the credentials
|
||||
* have the maximum permitted lifetime. Use {@link
|
||||
* GSSCredential#DEFAULT_LIFETIME GSSCredential.DEFAULT_LIFETIME} to
|
||||
* request default credential lifetime.
|
||||
* @param mechs an array of Oid's indicating the mechanisms over which
|
||||
* the credential is to be acquired. Use <code>(Oid[]) null</code> for
|
||||
* requesting a system specific default set of mechanisms.
|
||||
* @param usage The intended usage for this credential object. The value
|
||||
* of this parameter must be one of:
|
||||
* {@link GSSCredential#INITIATE_AND_ACCEPT
|
||||
* GSSCredential.INITIATE_AND_ACCEPT},
|
||||
* {@link GSSCredential#ACCEPT_ONLY GSSCredential.ACCEPT_ONLY}, and
|
||||
* {@link GSSCredential#INITIATE_ONLY GSSCredential.INITIATE_ONLY}.
|
||||
* @return a GSSCredential of the requested type.
|
||||
*
|
||||
* @see GSSCredential
|
||||
*
|
||||
* @throws GSSException containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#BAD_MECH GSSException.BAD_MECH},
|
||||
* {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE},
|
||||
* {@link GSSException#BAD_NAME GSSException.BAD_NAME},
|
||||
* {@link GSSException#CREDENTIALS_EXPIRED
|
||||
* GSSException.CREDENTIALS_EXPIRED},
|
||||
* {@link GSSException#NO_CRED GSSException.NO_CRED},
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public abstract GSSCredential createCredential(GSSName name,
|
||||
int lifetime, Oid mechs[], int usage)
|
||||
throws GSSException;
|
||||
|
||||
/**
|
||||
* Factory method for creating a context on the initiator's
|
||||
* side.
|
||||
*
|
||||
* Some mechanism providers might require that the caller be granted
|
||||
* permission to initiate a security context. A failed permission check
|
||||
* might cause a {@link java.lang.SecurityException SecurityException}
|
||||
* to be thrown from this method.<p>
|
||||
*
|
||||
* Non-default values for lifetime cannot always be honored by the
|
||||
* underlying mechanism, thus applications should be prepared to call
|
||||
* {@link GSSContext#getLifetime() getLifetime} on the returned
|
||||
* context.<p>
|
||||
*
|
||||
* @param peer the name of the target peer.
|
||||
* @param mech the Oid of the desired mechanism. Use <code>null</code>
|
||||
* to request the default mechanism.
|
||||
* @param myCred the credentials of the initiator. Use
|
||||
* <code>null</code> to act as the default initiator principal.
|
||||
* @param lifetime the lifetime, in seconds, requested for the
|
||||
* context. Use {@link GSSContext#INDEFINITE_LIFETIME
|
||||
* GSSContext.INDEFINITE_LIFETIME} to request that the context have the
|
||||
* maximum permitted lifetime. Use {@link GSSContext#DEFAULT_LIFETIME
|
||||
* GSSContext.DEFAULT_LIFETIME} to request a default lifetime for the
|
||||
* context.
|
||||
* @return an unestablished GSSContext
|
||||
*
|
||||
* @see GSSContext
|
||||
*
|
||||
* @throws GSSException containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#NO_CRED GSSException.NO_CRED}
|
||||
* {@link GSSException#CREDENTIALS_EXPIRED
|
||||
* GSSException.CREDENTIALS_EXPIRED}
|
||||
* {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE}
|
||||
* {@link GSSException#BAD_MECH GSSException.BAD_MECH}
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public abstract GSSContext createContext(GSSName peer, Oid mech,
|
||||
GSSCredential myCred, int lifetime)
|
||||
throws GSSException;
|
||||
|
||||
/**
|
||||
* Factory method for creating a context on the acceptor' side. The
|
||||
* context's properties will be determined from the input token supplied
|
||||
* to the accept method.
|
||||
*
|
||||
* Some mechanism providers might require that the caller be granted
|
||||
* permission to accept a security context. A failed permission check
|
||||
* might cause a {@link java.lang.SecurityException SecurityException}
|
||||
* to be thrown from this method.
|
||||
*
|
||||
* @param myCred the credentials for the acceptor. Use
|
||||
* <code>null</code> to act as a default acceptor principal.
|
||||
* @return an unestablished GSSContext
|
||||
*
|
||||
* @see GSSContext
|
||||
*
|
||||
* @throws GSSException containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#NO_CRED GSSException.NO_CRED}
|
||||
* {@link GSSException#CREDENTIALS_EXPIRED
|
||||
* GSSException.CREDENTIALS_EXPIRED}
|
||||
* {@link GSSException#BAD_MECH GSSException.BAD_MECH}
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public abstract GSSContext createContext(GSSCredential myCred)
|
||||
throws GSSException;
|
||||
|
||||
/**
|
||||
* Factory method for creating a previously exported context. The
|
||||
* context properties will be determined from the input token and
|
||||
* cannot be modified through the set methods.<p>
|
||||
*
|
||||
* Implementations are not required to support the inter-process
|
||||
* transfer of security contexts. Before exporting a context, calling
|
||||
* the {@link GSSContext#isTransferable() GSSContext.isTransferable}
|
||||
* will indicate if the context is transferable. Calling this method in
|
||||
* an implementation that does not support it will result in a
|
||||
* <code>GSSException</code> with the error
|
||||
* code {@link GSSException#UNAVAILABLE GSSException.UNAVAILABLE}.
|
||||
*
|
||||
* Some mechanism providers might require that the caller be granted
|
||||
* permission to initiate or accept a security context. A failed
|
||||
* permission check might cause a {@link java.lang.SecurityException
|
||||
* SecurityException} to be thrown from this method.
|
||||
*
|
||||
* @param interProcessToken the token previously emitted from the
|
||||
* export method.
|
||||
* @return the previously established GSSContext
|
||||
*
|
||||
* @see GSSContext
|
||||
*
|
||||
* @throws GSSException containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#NO_CONTEXT GSSException.NO_CONTEXT},
|
||||
* {@link GSSException#DEFECTIVE_TOKEN GSSException.DEFECTIVE_TOKEN},
|
||||
* {@link GSSException#UNAVAILABLE GSSException.UNAVAILABLE},
|
||||
* {@link GSSException#UNAUTHORIZED GSSException.UNAUTHORIZED},
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public abstract GSSContext createContext(byte [] interProcessToken)
|
||||
throws GSSException;
|
||||
|
||||
/**
|
||||
* This method is used to indicate to the GSSManager that the
|
||||
* application would like a particular provider to be used ahead of all
|
||||
* others when support is desired for the given mechanism. When a value
|
||||
* of null is used instead of an <code>Oid</code> for the mechanism,
|
||||
* the GSSManager must use the indicated provider ahead of all others
|
||||
* no matter what the mechanism is. Only when the indicated provider
|
||||
* does not support the needed mechanism should the GSSManager move on
|
||||
* to a different provider.<p>
|
||||
*
|
||||
* Calling this method repeatedly preserves the older settings but
|
||||
* lowers them in preference thus forming an ordered list of provider
|
||||
* and <code>Oid</code> pairs that grows at the top.<p>
|
||||
*
|
||||
* Calling addProviderAtFront with a null <code>Oid</code> will remove
|
||||
* all previous preferences that were set for this provider in the
|
||||
* GSSManager instance. Calling addProviderAtFront with a non-null
|
||||
* <code>Oid</code> will remove any previous preference that was set
|
||||
* using this mechanism and this provider together.<p>
|
||||
*
|
||||
* If the GSSManager implementation does not support an SPI with a
|
||||
* pluggable provider architecture it should throw a GSSException with
|
||||
* the status code GSSException.UNAVAILABLE to indicate that the
|
||||
* operation is unavailable.<p>
|
||||
*
|
||||
* Suppose an application desired that the provider A always be checked
|
||||
* first when any mechanism is needed, it would call:<p>
|
||||
* <pre>
|
||||
* GSSManager mgr = GSSManager.getInstance();
|
||||
* // mgr may at this point have its own pre-configured list
|
||||
* // of provider preferences. The following will prepend to
|
||||
* // any such list:
|
||||
*
|
||||
* mgr.addProviderAtFront(A, null);
|
||||
* </pre>
|
||||
* Now if it also desired that the mechanism of Oid m1 always be
|
||||
* obtained from the provider B before the previously set A was checked,
|
||||
* it would call:<p>
|
||||
* <pre>
|
||||
* mgr.addProviderAtFront(B, m1);
|
||||
* </pre>
|
||||
* The GSSManager would then first check with B if m1 was needed. In
|
||||
* case B did not provide support for m1, the GSSManager would continue
|
||||
* on to check with A. If any mechanism m2 is needed where m2 is
|
||||
* different from m1 then the GSSManager would skip B and check with A
|
||||
* directly.<p>
|
||||
*
|
||||
* Suppose at a later time the following call is made to the same
|
||||
* GSSManager instance:<p>
|
||||
* <pre>
|
||||
* mgr.addProviderAtFront(B, null)
|
||||
* </pre>
|
||||
* then the previous setting with the pair (B, m1) is subsumed by this
|
||||
* and should be removed. Effectively the list of preferences now
|
||||
* becomes {(B, null), (A, null),
|
||||
* ... //followed by the pre-configured list.<p>
|
||||
*
|
||||
* Please note, however, that the following call:
|
||||
* <pre>
|
||||
* mgr.addProviderAtFront(A, m3)
|
||||
* </pre>
|
||||
* does not subsume the previous setting of (A, null) and the list will
|
||||
* effectively become {(A, m3), (B, null), (A, null), ...}
|
||||
*
|
||||
* @param p the provider instance that should be used whenever support
|
||||
* is needed for mech.
|
||||
* @param mech the mechanism for which the provider is being set
|
||||
*
|
||||
* @throws GSSException containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#UNAVAILABLE GSSException.UNAVAILABLE},
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public abstract void addProviderAtFront(Provider p, Oid mech)
|
||||
throws GSSException;
|
||||
|
||||
/**
|
||||
* This method is used to indicate to the GSSManager that the
|
||||
* application would like a particular provider to be used if no other
|
||||
* provider can be found that supports the given mechanism. When a value
|
||||
* of null is used instead of an Oid for the mechanism, the GSSManager
|
||||
* must use the indicated provider for any mechanism.<p>
|
||||
*
|
||||
* Calling this method repeatedly preserves the older settings but
|
||||
* raises them above newer ones in preference thus forming an ordered
|
||||
* list of providers and Oid pairs that grows at the bottom. Thus the
|
||||
* older provider settings will be utilized first before this one is.<p>
|
||||
*
|
||||
* If there are any previously existing preferences that conflict with
|
||||
* the preference being set here, then the GSSManager should ignore this
|
||||
* request.<p>
|
||||
*
|
||||
* If the GSSManager implementation does not support an SPI with a
|
||||
* pluggable provider architecture it should throw a GSSException with
|
||||
* the status code GSSException.UNAVAILABLE to indicate that the
|
||||
* operation is unavailable.<p>
|
||||
*
|
||||
* Suppose an application desired that when a mechanism of Oid m1 is
|
||||
* needed the system default providers always be checked first, and only
|
||||
* when they do not support m1 should a provider A be checked. It would
|
||||
* then make the call:<p>
|
||||
* <pre>
|
||||
* GSSManager mgr = GSSManager.getInstance();
|
||||
* mgr.addProviderAtEnd(A, m1);
|
||||
* </pre>
|
||||
* Now, if it also desired that for all mechanisms the provider B be
|
||||
* checked after all configured providers have been checked, it would
|
||||
* then call:<p>
|
||||
* <pre>
|
||||
* mgr.addProviderAtEnd(B, null);
|
||||
* </pre>
|
||||
* Effectively the list of preferences now becomes {..., (A, m1), (B,
|
||||
* null)}.<p>
|
||||
*
|
||||
* Suppose at a later time the following call is made to the same
|
||||
* GSSManager instance:<p>
|
||||
* <pre>
|
||||
* mgr.addProviderAtEnd(B, m2)
|
||||
* </pre>
|
||||
* then the previous setting with the pair (B, null) subsumes this and
|
||||
* therefore this request should be ignored. The same would happen if a
|
||||
* request is made for the already existing pairs of (A, m1) or (B,
|
||||
* null).<p>
|
||||
*
|
||||
* Please note, however, that the following call:<p>
|
||||
* <pre>
|
||||
* mgr.addProviderAtEnd(A, null)
|
||||
* </pre>
|
||||
* is not subsumed by the previous setting of (A, m1) and the list will
|
||||
* effectively become {..., (A, m1), (B, null), (A, null)}
|
||||
*
|
||||
* @param p the provider instance that should be used whenever support
|
||||
* is needed for mech.
|
||||
* @param mech the mechanism for which the provider is being set
|
||||
*
|
||||
* @throws GSSException containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#UNAVAILABLE GSSException.UNAVAILABLE},
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public abstract void addProviderAtEnd(Provider p, Oid mech)
|
||||
throws GSSException;
|
||||
}
|
||||
295
jdkSrc/jdk8/org/ietf/jgss/GSSName.java
Normal file
295
jdkSrc/jdk8/org/ietf/jgss/GSSName.java
Normal file
@@ -0,0 +1,295 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.ietf.jgss;
|
||||
|
||||
import sun.security.jgss.spi.*;
|
||||
import java.util.Vector;
|
||||
import java.util.Enumeration;
|
||||
|
||||
/**
|
||||
* This interface encapsulates a single GSS-API principal entity. The
|
||||
* application obtains an implementation of this interface
|
||||
* through one of the <code>createName</code> methods that exist in the {@link
|
||||
* GSSManager GSSManager} class. Conceptually a GSSName contains many
|
||||
* representations of the entity or many primitive name elements, one for
|
||||
* each supported underlying mechanism. In GSS terminology, a GSSName that
|
||||
* contains an element from just one mechanism is called a Mechanism Name
|
||||
* (MN)<p>
|
||||
*
|
||||
* Since different authentication mechanisms may employ different
|
||||
* namespaces for identifying their principals, GSS-API's naming support is
|
||||
* necessarily complex in multi-mechanism environments (or even in some
|
||||
* single-mechanism environments where the underlying mechanism supports
|
||||
* multiple namespaces). Different name formats and their definitions are
|
||||
* identified with {@link Oid Oid's} and some standard types
|
||||
* are defined in this interface. The format of the names can be derived
|
||||
* based on the unique <code>Oid</code> of its name type.<p>
|
||||
*
|
||||
* Included below are code examples utilizing the <code>GSSName</code> interface.
|
||||
* The code below creates a <code>GSSName</code>, converts it to an MN, performs a
|
||||
* comparison, obtains a printable representation of the name, exports it
|
||||
* to a byte array and then re-imports to obtain a
|
||||
* new <code>GSSName</code>.<p>
|
||||
* <pre>
|
||||
* GSSManager manager = GSSManager.getInstance();
|
||||
*
|
||||
* // create a host based service name
|
||||
* GSSName name = manager.createName("service@host",
|
||||
* GSSName.NT_HOSTBASED_SERVICE);
|
||||
*
|
||||
* Oid krb5 = new Oid("1.2.840.113554.1.2.2");
|
||||
*
|
||||
* GSSName mechName = name.canonicalize(krb5);
|
||||
*
|
||||
* // the above two steps are equivalent to the following
|
||||
* GSSName mechName = manager.createName("service@host",
|
||||
* GSSName.NT_HOSTBASED_SERVICE, krb5);
|
||||
*
|
||||
* // perform name comparison
|
||||
* if (name.equals(mechName))
|
||||
* print("Names are equals.");
|
||||
*
|
||||
* // obtain textual representation of name and its printable
|
||||
* // name type
|
||||
* print(mechName.toString() +
|
||||
* mechName.getStringNameType().toString());
|
||||
*
|
||||
* // export and re-import the name
|
||||
* byte [] exportName = mechName.export();
|
||||
*
|
||||
* // create a new name object from the exported buffer
|
||||
* GSSName newName = manager.createName(exportName,
|
||||
* GSSName.NT_EXPORT_NAME);
|
||||
*
|
||||
* </pre>
|
||||
* @see #export()
|
||||
* @see #equals(GSSName)
|
||||
* @see GSSManager#createName(String, Oid)
|
||||
* @see GSSManager#createName(String, Oid, Oid)
|
||||
* @see GSSManager#createName(byte[], Oid)
|
||||
*
|
||||
* @author Mayank Upadhyay
|
||||
* @since 1.4
|
||||
*/
|
||||
public interface GSSName {
|
||||
|
||||
/**
|
||||
* Oid indicating a host-based service name form. It is used to
|
||||
* represent services associated with host computers. This name form
|
||||
* is constructed using two elements, "service" and "hostname", as
|
||||
* follows: service@hostname.<p>
|
||||
*
|
||||
* It represents the following Oid value:<br>
|
||||
* <code>{ iso(1) member-body(2) United
|
||||
* States(840) mit(113554) infosys(1) gssapi(2) generic(1) service_name(4)
|
||||
* }</code>
|
||||
*/
|
||||
public static final Oid NT_HOSTBASED_SERVICE
|
||||
= Oid.getInstance("1.2.840.113554.1.2.1.4");
|
||||
|
||||
/**
|
||||
* Name type to indicate a named user on a local system.<p>
|
||||
* It represents the following Oid value:<br>
|
||||
* <code>{ iso(1) member-body(2) United
|
||||
* States(840) mit(113554) infosys(1) gssapi(2) generic(1) user_name(1)
|
||||
* }</code>
|
||||
*/
|
||||
public static final Oid NT_USER_NAME
|
||||
= Oid.getInstance("1.2.840.113554.1.2.1.1");
|
||||
|
||||
/**
|
||||
* Name type to indicate a numeric user identifier corresponding to a
|
||||
* user on a local system. (e.g. Uid).<p>
|
||||
*
|
||||
* It represents the following Oid value:<br>
|
||||
* <code>{ iso(1) member-body(2) United States(840) mit(113554)
|
||||
* infosys(1) gssapi(2) generic(1) machine_uid_name(2) }</code>
|
||||
*/
|
||||
public static final Oid NT_MACHINE_UID_NAME
|
||||
= Oid.getInstance("1.2.840.113554.1.2.1.2");
|
||||
|
||||
/**
|
||||
* Name type to indicate a string of digits representing the numeric
|
||||
* user identifier of a user on a local system.<p>
|
||||
*
|
||||
* It represents the following Oid value:<br>
|
||||
* <code>{ iso(1) member-body(2) United
|
||||
* States(840) mit(113554) infosys(1) gssapi(2) generic(1)
|
||||
* string_uid_name(3) }</code>
|
||||
*/
|
||||
public static final Oid NT_STRING_UID_NAME
|
||||
= Oid.getInstance("1.2.840.113554.1.2.1.3");
|
||||
|
||||
/**
|
||||
* Name type for representing an anonymous entity.<p>
|
||||
* It represents the following Oid value:<br>
|
||||
* <code>{ 1(iso), 3(org), 6(dod), 1(internet),
|
||||
* 5(security), 6(nametypes), 3(gss-anonymous-name) }</code>
|
||||
*/
|
||||
public static final Oid NT_ANONYMOUS
|
||||
= Oid.getInstance("1.3.6.1.5.6.3");
|
||||
|
||||
/**
|
||||
* Name type used to indicate an exported name produced by the export
|
||||
* method.<p>
|
||||
*
|
||||
* It represents the following Oid value:<br> <code>{ 1(iso),
|
||||
* 3(org), 6(dod), 1(internet), 5(security), 6(nametypes),
|
||||
* 4(gss-api-exported-name) }</code>
|
||||
*/
|
||||
public static final Oid NT_EXPORT_NAME
|
||||
= Oid.getInstance("1.3.6.1.5.6.4");
|
||||
|
||||
/**
|
||||
* Compares two <code>GSSName</code> objects to determine if they refer to the
|
||||
* same entity.
|
||||
*
|
||||
* @param another the <code>GSSName</code> to compare this name with
|
||||
* @return true if the two names contain at least one primitive element
|
||||
* in common. If either of the names represents an anonymous entity, the
|
||||
* method will return false.
|
||||
*
|
||||
* @throws GSSException when the names cannot be compared, containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE},
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public boolean equals(GSSName another) throws GSSException;
|
||||
|
||||
/**
|
||||
* Compares this <code>GSSName</code> object to another Object that might be a
|
||||
* <code>GSSName</code>. The behaviour is exactly the same as in {@link
|
||||
* #equals(GSSName) equals} except that no GSSException is thrown;
|
||||
* instead, false will be returned in the situation where an error
|
||||
* occurs.
|
||||
* @return true if the object to compare to is also a <code>GSSName</code> and the two
|
||||
* names refer to the same entity.
|
||||
* @param another the object to compare this name to
|
||||
* @see #equals(GSSName)
|
||||
*/
|
||||
public boolean equals(Object another);
|
||||
|
||||
/**
|
||||
* Returns a hashcode value for this GSSName.
|
||||
*
|
||||
* @return a hashCode value
|
||||
*/
|
||||
public int hashCode();
|
||||
|
||||
/**
|
||||
* Creates a name that is canonicalized for some
|
||||
* mechanism.
|
||||
*
|
||||
* @return a <code>GSSName</code> that contains just one primitive
|
||||
* element representing this name in a canonicalized form for the desired
|
||||
* mechanism.
|
||||
* @param mech the oid for the mechanism for which the canonical form of
|
||||
* the name is requested.
|
||||
*
|
||||
* @throws GSSException containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#BAD_MECH GSSException.BAD_MECH},
|
||||
* {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE},
|
||||
* {@link GSSException#BAD_NAME GSSException.BAD_NAME},
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public GSSName canonicalize(Oid mech) throws GSSException;
|
||||
|
||||
/**
|
||||
* Returns a canonical contiguous byte representation of a mechanism name
|
||||
* (MN), suitable for direct, byte by byte comparison by authorization
|
||||
* functions. If the name is not an MN, implementations may throw a
|
||||
* GSSException with the NAME_NOT_MN status code. If an implementation
|
||||
* chooses not to throw an exception, it should use some system specific
|
||||
* default mechanism to canonicalize the name and then export
|
||||
* it. Structurally, an exported name object consists of a header
|
||||
* containing an OID identifying the mechanism that authenticated the
|
||||
* name, and a trailer containing the name itself, where the syntax of
|
||||
* the trailer is defined by the individual mechanism specification. The
|
||||
* format of the header of the output buffer is specified in RFC 2743.<p>
|
||||
*
|
||||
* The exported name is useful when used in large access control lists
|
||||
* where the overhead of creating a <code>GSSName</code> object on each
|
||||
* name and invoking the equals method on each name from the ACL may be
|
||||
* prohibitive.<p>
|
||||
*
|
||||
* Exported names may be re-imported by using the byte array factory
|
||||
* method {@link GSSManager#createName(byte[], Oid)
|
||||
* GSSManager.createName} and specifying the NT_EXPORT_NAME as the name
|
||||
* type object identifier. The resulting <code>GSSName</code> name will
|
||||
* also be a MN.<p>
|
||||
* @return a byte[] containing the exported name. RFC 2743 defines the
|
||||
* "Mechanism-Independent Exported Name Object Format" for these bytes.
|
||||
*
|
||||
* @throws GSSException containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#BAD_NAME GSSException.BAD_NAME},
|
||||
* {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE},
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public byte[] export() throws GSSException;
|
||||
|
||||
/**
|
||||
* Returns a textual representation of the <code>GSSName</code> object. To retrieve
|
||||
* the printed name format, which determines the syntax of the returned
|
||||
* string, use the {@link #getStringNameType() getStringNameType}
|
||||
* method.
|
||||
*
|
||||
* @return a String representing this name in printable form.
|
||||
*/
|
||||
public String toString();
|
||||
|
||||
/**
|
||||
* Returns the name type of the printable
|
||||
* representation of this name that can be obtained from the <code>
|
||||
* toString</code> method.
|
||||
*
|
||||
* @return an Oid representing the namespace of the name returned
|
||||
* from the toString method.
|
||||
*
|
||||
* @throws GSSException containing the following
|
||||
* major error codes:
|
||||
* {@link GSSException#FAILURE GSSException.FAILURE}
|
||||
*/
|
||||
public Oid getStringNameType() throws GSSException;
|
||||
|
||||
/**
|
||||
* Tests if this name object represents an anonymous entity.
|
||||
*
|
||||
* @return true if this is an anonymous name, false otherwise.
|
||||
*/
|
||||
public boolean isAnonymous();
|
||||
|
||||
/**
|
||||
* Tests if this name object represents a Mechanism Name (MN). An MN is
|
||||
* a GSSName the contains exactly one mechanism's primitive name
|
||||
* element.
|
||||
*
|
||||
* @return true if this is an MN, false otherwise.
|
||||
*/
|
||||
public boolean isMN();
|
||||
|
||||
}
|
||||
235
jdkSrc/jdk8/org/ietf/jgss/MessageProp.java
Normal file
235
jdkSrc/jdk8/org/ietf/jgss/MessageProp.java
Normal file
@@ -0,0 +1,235 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.ietf.jgss;
|
||||
|
||||
/**
|
||||
* This is a utility class used within the per-message GSSContext
|
||||
* methods to convey per-message properties.<p>
|
||||
*
|
||||
* When used with the GSSContext interface's wrap and getMIC methods, an
|
||||
* instance of this class is used to indicate the desired
|
||||
* Quality-of-Protection (QOP) and to request if confidentiality services
|
||||
* are to be applied to caller supplied data (wrap only). To request
|
||||
* default QOP, the value of 0 should be used for QOP.<p>
|
||||
*
|
||||
* When used with the unwrap and verifyMIC methods of the GSSContext
|
||||
* interface, an instance of this class will be used to indicate the
|
||||
* applied QOP and confidentiality services over the supplied message.
|
||||
* In the case of verifyMIC, the confidentiality state will always be
|
||||
* <code>false</code>. Upon return from these methods, this object will also
|
||||
* contain any supplementary status values applicable to the processed
|
||||
* token. The supplementary status values can indicate old tokens, out
|
||||
* of sequence tokens, gap tokens or duplicate tokens.<p>
|
||||
*
|
||||
* @see GSSContext#wrap
|
||||
* @see GSSContext#unwrap
|
||||
* @see GSSContext#getMIC
|
||||
* @see GSSContext#verifyMIC
|
||||
*
|
||||
* @author Mayank Upadhyay
|
||||
* @since 1.4
|
||||
*/
|
||||
public class MessageProp {
|
||||
|
||||
private boolean privacyState;
|
||||
private int qop;
|
||||
private boolean dupToken;
|
||||
private boolean oldToken;
|
||||
private boolean unseqToken;
|
||||
private boolean gapToken;
|
||||
private int minorStatus;
|
||||
private String minorString;
|
||||
|
||||
/**
|
||||
* Constructor which sets the desired privacy state. The QOP value used
|
||||
* is 0.
|
||||
*
|
||||
* @param privState the privacy (i.e. confidentiality) state
|
||||
*/
|
||||
public MessageProp(boolean privState) {
|
||||
this(0, privState);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor which sets the values for the qop and privacy state.
|
||||
*
|
||||
* @param qop the QOP value
|
||||
* @param privState the privacy (i.e. confidentiality) state
|
||||
*/
|
||||
public MessageProp(int qop, boolean privState) {
|
||||
this.qop = qop;
|
||||
this.privacyState = privState;
|
||||
resetStatusValues();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the QOP value.
|
||||
*
|
||||
* @return an int representing the QOP value
|
||||
* @see #setQOP
|
||||
*/
|
||||
public int getQOP() {
|
||||
return qop;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the privacy state.
|
||||
*
|
||||
* @return true if the privacy (i.e., confidentiality) state is true,
|
||||
* false otherwise.
|
||||
* @see #setPrivacy
|
||||
*/
|
||||
public boolean getPrivacy() {
|
||||
|
||||
return (privacyState);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the QOP value.
|
||||
*
|
||||
* @param qop the int value to set the QOP to
|
||||
* @see #getQOP
|
||||
*/
|
||||
public void setQOP(int qop) {
|
||||
this.qop = qop;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the privacy state.
|
||||
*
|
||||
* @param privState true is the privacy (i.e., confidentiality) state
|
||||
* is true, false otherwise.
|
||||
* @see #getPrivacy
|
||||
*/
|
||||
public void setPrivacy(boolean privState) {
|
||||
|
||||
this.privacyState = privState;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests if this is a duplicate of an earlier token.
|
||||
*
|
||||
* @return true if this is a duplicate, false otherwise.
|
||||
*/
|
||||
public boolean isDuplicateToken() {
|
||||
return dupToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if this token's validity period has expired, i.e., the token
|
||||
* is too old to be checked for duplication.
|
||||
*
|
||||
* @return true if the token's validity period has expired, false
|
||||
* otherwise.
|
||||
*/
|
||||
public boolean isOldToken() {
|
||||
return oldToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if a later token had already been processed.
|
||||
*
|
||||
* @return true if a later token had already been processed, false otherwise.
|
||||
*/
|
||||
public boolean isUnseqToken() {
|
||||
return unseqToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if an expected token was not received, i.e., one or more
|
||||
* predecessor tokens have not yet been successfully processed.
|
||||
*
|
||||
* @return true if an expected per-message token was not received,
|
||||
* false otherwise.
|
||||
*/
|
||||
public boolean isGapToken() {
|
||||
return gapToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the minor status code that the underlying mechanism might
|
||||
* have set for this per-message operation.
|
||||
*
|
||||
* @return the int minor status
|
||||
*/
|
||||
public int getMinorStatus(){
|
||||
return minorStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a string explaining the minor status code.
|
||||
*
|
||||
* @return a String corresponding to the minor status
|
||||
* code. <code>null</code> will be returned when no minor status code
|
||||
* has been set.
|
||||
*/
|
||||
public String getMinorString(){
|
||||
return minorString;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets the state for the supplementary information flags
|
||||
* and the minor status in MessageProp. It is not used by the
|
||||
* application but by the GSS implementation to return this information
|
||||
* to the caller of a per-message context method.
|
||||
*
|
||||
* @param duplicate true if the token was a duplicate of an earlier
|
||||
* token, false otherwise
|
||||
* @param old true if the token's validity period has expired, false
|
||||
* otherwise
|
||||
* @param unseq true if a later token has already been processed, false
|
||||
* otherwise
|
||||
* @param gap true if one or more predecessor tokens have not yet been
|
||||
* successfully processed, false otherwise
|
||||
* @param minorStatus the int minor status code for the per-message
|
||||
* operation
|
||||
* @param minorString the textual representation of the minorStatus value
|
||||
*/
|
||||
public void setSupplementaryStates(boolean duplicate,
|
||||
boolean old, boolean unseq, boolean gap,
|
||||
int minorStatus, String minorString) {
|
||||
this.dupToken = duplicate;
|
||||
this.oldToken = old;
|
||||
this.unseqToken = unseq;
|
||||
this.gapToken = gap;
|
||||
this.minorStatus = minorStatus;
|
||||
this.minorString = minorString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the supplementary status values to false.
|
||||
*/
|
||||
private void resetStatusValues() {
|
||||
dupToken = false;
|
||||
oldToken = false;
|
||||
unseqToken = false;
|
||||
gapToken = false;
|
||||
minorStatus = 0;
|
||||
minorString = null;
|
||||
}
|
||||
}
|
||||
216
jdkSrc/jdk8/org/ietf/jgss/Oid.java
Normal file
216
jdkSrc/jdk8/org/ietf/jgss/Oid.java
Normal file
@@ -0,0 +1,216 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.ietf.jgss;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import sun.security.util.DerValue;
|
||||
import sun.security.util.DerOutputStream;
|
||||
import sun.security.util.ObjectIdentifier;
|
||||
|
||||
/**
|
||||
* This class represents Universal Object Identifiers (Oids) and their
|
||||
* associated operations.<p>
|
||||
*
|
||||
* Oids are hierarchically globally-interpretable identifiers used
|
||||
* within the GSS-API framework to identify mechanisms and name formats.<p>
|
||||
*
|
||||
* The structure and encoding of Oids is defined in ISOIEC-8824 and
|
||||
* ISOIEC-8825. For example the Oid representation of Kerberos V5
|
||||
* mechanism is "1.2.840.113554.1.2.2"<p>
|
||||
*
|
||||
* The GSSName name class contains public static Oid objects
|
||||
* representing the standard name types defined in GSS-API.
|
||||
*
|
||||
* @author Mayank Upadhyay
|
||||
* @since 1.4
|
||||
*/
|
||||
public class Oid {
|
||||
|
||||
private ObjectIdentifier oid;
|
||||
private byte[] derEncoding;
|
||||
|
||||
/**
|
||||
* Constructs an Oid object from a string representation of its
|
||||
* integer components.
|
||||
*
|
||||
* @param strOid the dot separated string representation of the oid.
|
||||
* For instance, "1.2.840.113554.1.2.2".
|
||||
* @exception GSSException may be thrown when the string is incorrectly
|
||||
* formatted
|
||||
*/
|
||||
public Oid(String strOid) throws GSSException {
|
||||
|
||||
try {
|
||||
oid = new ObjectIdentifier(strOid);
|
||||
derEncoding = null;
|
||||
} catch (Exception e) {
|
||||
throw new GSSException(GSSException.FAILURE,
|
||||
"Improperly formatted Object Identifier String - "
|
||||
+ strOid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an Oid object from its ASN.1 DER encoding. This refers to
|
||||
* the full encoding including tag and length. The structure and
|
||||
* encoding of Oids is defined in ISOIEC-8824 and ISOIEC-8825. This
|
||||
* method is identical in functionality to its byte array counterpart.
|
||||
*
|
||||
* @param derOid stream containing the DER encoded oid
|
||||
* @exception GSSException may be thrown when the DER encoding does not
|
||||
* follow the prescribed format.
|
||||
*/
|
||||
public Oid(InputStream derOid) throws GSSException {
|
||||
try {
|
||||
DerValue derVal = new DerValue(derOid);
|
||||
derEncoding = derVal.toByteArray();
|
||||
oid = derVal.getOID();
|
||||
} catch (IOException e) {
|
||||
throw new GSSException(GSSException.FAILURE,
|
||||
"Improperly formatted ASN.1 DER encoding for Oid");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates an Oid object from its ASN.1 DER encoding. This refers to
|
||||
* the full encoding including tag and length. The structure and
|
||||
* encoding of Oids is defined in ISOIEC-8824 and ISOIEC-8825. This
|
||||
* method is identical in functionality to its InputStream conterpart.
|
||||
*
|
||||
* @param data byte array containing the DER encoded oid
|
||||
* @exception GSSException may be thrown when the DER encoding does not
|
||||
* follow the prescribed format.
|
||||
*/
|
||||
public Oid(byte [] data) throws GSSException {
|
||||
try {
|
||||
DerValue derVal = new DerValue(data);
|
||||
derEncoding = derVal.toByteArray();
|
||||
oid = derVal.getOID();
|
||||
} catch (IOException e) {
|
||||
throw new GSSException(GSSException.FAILURE,
|
||||
"Improperly formatted ASN.1 DER encoding for Oid");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Only for calling by initializators used with declarations.
|
||||
*
|
||||
* @param strOid
|
||||
*/
|
||||
static Oid getInstance(String strOid) {
|
||||
Oid retVal = null;
|
||||
try {
|
||||
retVal = new Oid(strOid);
|
||||
} catch (GSSException e) {
|
||||
// squelch it!
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the oid's integer components
|
||||
* in dot separated notation.
|
||||
*
|
||||
* @return string representation in the following format: "1.2.3.4.5"
|
||||
*/
|
||||
public String toString() {
|
||||
return oid.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if two Oid objects represent the same Object identifier
|
||||
* value.
|
||||
*
|
||||
* @return <code>true</code> if the two Oid objects represent the same
|
||||
* value, <code>false</code> otherwise.
|
||||
* @param other the Oid object that has to be compared to this one
|
||||
*/
|
||||
public boolean equals(Object other) {
|
||||
|
||||
//check if both reference the same object
|
||||
if (this == other)
|
||||
return (true);
|
||||
|
||||
if (other instanceof Oid)
|
||||
return this.oid.equals((Object)((Oid) other).oid);
|
||||
else if (other instanceof ObjectIdentifier)
|
||||
return this.oid.equals(other);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the full ASN.1 DER encoding for this oid object, which
|
||||
* includes the tag and length.
|
||||
*
|
||||
* @return byte array containing the DER encoding of this oid object.
|
||||
* @exception GSSException may be thrown when the oid can't be encoded
|
||||
*/
|
||||
public byte[] getDER() throws GSSException {
|
||||
|
||||
if (derEncoding == null) {
|
||||
DerOutputStream dout = new DerOutputStream();
|
||||
try {
|
||||
dout.putOID(oid);
|
||||
} catch (IOException e) {
|
||||
throw new GSSException(GSSException.FAILURE, e.getMessage());
|
||||
}
|
||||
derEncoding = dout.toByteArray();
|
||||
}
|
||||
|
||||
return derEncoding.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* A utility method to test if this Oid value is contained within the
|
||||
* supplied Oid array.
|
||||
*
|
||||
* @param oids the array of Oid's to search
|
||||
* @return true if the array contains this Oid value, false otherwise
|
||||
*/
|
||||
public boolean containedIn(Oid[] oids) {
|
||||
|
||||
for (int i = 0; i < oids.length; i++) {
|
||||
if (oids[i].equals(this))
|
||||
return (true);
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a hashcode value for this Oid.
|
||||
*
|
||||
* @return a hashCode value
|
||||
*/
|
||||
public int hashCode() {
|
||||
return oid.hashCode();
|
||||
}
|
||||
}
|
||||
125
jdkSrc/jdk8/org/jcp/xml/dsig/internal/DigesterOutputStream.java
Normal file
125
jdkSrc/jdk8/org/jcp/xml/dsig/internal/DigesterOutputStream.java
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* 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, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DigesterOutputStream.java, v 1.5 2005/12/20 20:02:39 mullan Exp $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.security.MessageDigest;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.utils.UnsyncByteArrayOutputStream;
|
||||
|
||||
/**
|
||||
* This class has been modified slightly to use java.security.MessageDigest
|
||||
* objects as input, rather than
|
||||
* com.sun.org.apache.xml.internal.security.algorithms.MessageDigestAlgorithm objects.
|
||||
* It also optionally caches the input bytes.
|
||||
*
|
||||
*/
|
||||
public class DigesterOutputStream extends OutputStream {
|
||||
private static final com.sun.org.slf4j.internal.Logger LOG =
|
||||
com.sun.org.slf4j.internal.LoggerFactory.getLogger(DigesterOutputStream.class);
|
||||
|
||||
private final boolean buffer;
|
||||
private UnsyncByteArrayOutputStream bos;
|
||||
private final MessageDigest md;
|
||||
|
||||
/**
|
||||
* Creates a DigesterOutputStream.
|
||||
*
|
||||
* @param md the MessageDigest
|
||||
*/
|
||||
public DigesterOutputStream(MessageDigest md) {
|
||||
this(md, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DigesterOutputStream.
|
||||
*
|
||||
* @param md the MessageDigest
|
||||
* @param buffer if true, caches the input bytes
|
||||
*/
|
||||
public DigesterOutputStream(MessageDigest md, boolean buffer) {
|
||||
this.md = md;
|
||||
this.buffer = buffer;
|
||||
if (buffer) {
|
||||
bos = new UnsyncByteArrayOutputStream();
|
||||
}
|
||||
}
|
||||
|
||||
public void write(int input) {
|
||||
if (buffer) {
|
||||
bos.write(input);
|
||||
}
|
||||
md.update((byte)input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] input, int offset, int len) {
|
||||
if (buffer) {
|
||||
bos.write(input, offset, len);
|
||||
}
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Pre-digested input:");
|
||||
StringBuilder sb = new StringBuilder(len);
|
||||
for (int i = offset; i < (offset + len); i++) {
|
||||
sb.append((char)input[i]);
|
||||
}
|
||||
LOG.debug(sb.toString());
|
||||
}
|
||||
md.update(input, offset, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the digest value
|
||||
*/
|
||||
public byte[] getDigestValue() {
|
||||
return md.digest();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an input stream containing the cached bytes, or
|
||||
* null if not cached
|
||||
*/
|
||||
public InputStream getInputStream() {
|
||||
if (buffer) {
|
||||
return new ByteArrayInputStream(bos.toByteArray());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (buffer) {
|
||||
bos.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
52
jdkSrc/jdk8/org/jcp/xml/dsig/internal/MacOutputStream.java
Normal file
52
jdkSrc/jdk8/org/jcp/xml/dsig/internal/MacOutputStream.java
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import javax.crypto.Mac;
|
||||
|
||||
/**
|
||||
* Derived from Apache sources and changed to use Mac objects instead of
|
||||
* com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithm objects.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class MacOutputStream extends ByteArrayOutputStream {
|
||||
private final Mac mac;
|
||||
|
||||
public MacOutputStream(Mac mac) {
|
||||
this.mac = mac;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int arg0) {
|
||||
super.write(arg0);
|
||||
mac.update((byte) arg0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] arg0, int arg1, int arg2) {
|
||||
super.write(arg0, arg1, arg2);
|
||||
mac.update(arg0, arg1, arg2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: SignerOutputStream.java, v 1.2 2005/09/15 14:29:02 mullan Exp $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.security.Signature;
|
||||
import java.security.SignatureException;
|
||||
|
||||
/**
|
||||
* Derived from Apache sources and changed to use java.security.Signature
|
||||
* objects as input instead of
|
||||
* com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithm objects.
|
||||
*
|
||||
*/
|
||||
public class SignerOutputStream extends ByteArrayOutputStream {
|
||||
private final Signature sig;
|
||||
|
||||
public SignerOutputStream(Signature sig) {
|
||||
this.sig = sig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int arg0) {
|
||||
super.write(arg0);
|
||||
try {
|
||||
sig.update((byte)arg0);
|
||||
} catch (SignatureException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] arg0, int arg1, int arg2) {
|
||||
super.write(arg0, arg1, arg2);
|
||||
try {
|
||||
sig.update(arg0, arg1, arg2);
|
||||
} catch (SignatureException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import java.security.Key;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.SignatureException;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import javax.xml.crypto.MarshalException;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dsig.SignatureMethod;
|
||||
import javax.xml.crypto.dsig.SignedInfo;
|
||||
import javax.xml.crypto.dsig.XMLSignature;
|
||||
import javax.xml.crypto.dsig.XMLSignatureException;
|
||||
import javax.xml.crypto.dsig.XMLSignContext;
|
||||
import javax.xml.crypto.dsig.XMLValidateContext;
|
||||
import javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* An abstract class representing a SignatureMethod. Subclasses implement
|
||||
* a specific XML DSig signature algorithm.
|
||||
*/
|
||||
abstract class AbstractDOMSignatureMethod extends DOMStructure
|
||||
implements SignatureMethod {
|
||||
|
||||
// denotes the type of signature algorithm
|
||||
enum Type { DSA, RSA, ECDSA, HMAC }
|
||||
|
||||
/**
|
||||
* Verifies the passed-in signature with the specified key, using the
|
||||
* underlying Signature or Mac algorithm.
|
||||
*
|
||||
* @param key the verification key
|
||||
* @param si the SignedInfo
|
||||
* @param sig the signature bytes to be verified
|
||||
* @param context the XMLValidateContext
|
||||
* @return {@code true} if the signature verified successfully,
|
||||
* {@code false} if not
|
||||
* @throws NullPointerException if {@code key}, {@code si} or
|
||||
* {@code sig} are {@code null}
|
||||
* @throws InvalidKeyException if the key is improperly encoded, of
|
||||
* the wrong type, or parameters are missing, etc
|
||||
* @throws SignatureException if an unexpected error occurs, such
|
||||
* as the passed in signature is improperly encoded
|
||||
* @throws XMLSignatureException if an unexpected error occurs
|
||||
*/
|
||||
abstract boolean verify(Key key, SignedInfo si, byte[] sig,
|
||||
XMLValidateContext context)
|
||||
throws InvalidKeyException, SignatureException, XMLSignatureException;
|
||||
|
||||
/**
|
||||
* Signs the bytes with the specified key, using the underlying
|
||||
* Signature or Mac algorithm.
|
||||
*
|
||||
* @param key the signing key
|
||||
* @param si the SignedInfo
|
||||
* @param context the XMLSignContext
|
||||
* @return the signature
|
||||
* @throws NullPointerException if {@code key} or
|
||||
* {@code si} are {@code null}
|
||||
* @throws InvalidKeyException if the key is improperly encoded, of
|
||||
* the wrong type, or parameters are missing, etc
|
||||
* @throws XMLSignatureException if an unexpected error occurs
|
||||
*/
|
||||
abstract byte[] sign(Key key, SignedInfo si, XMLSignContext context)
|
||||
throws InvalidKeyException, XMLSignatureException;
|
||||
|
||||
/**
|
||||
* Returns the java.security.Signature or javax.crypto.Mac standard
|
||||
* algorithm name.
|
||||
*/
|
||||
abstract String getJCAAlgorithm();
|
||||
|
||||
/**
|
||||
* Returns the type of signature algorithm.
|
||||
*/
|
||||
abstract Type getAlgorithmType();
|
||||
|
||||
/**
|
||||
* This method invokes the {@link #marshalParams marshalParams}
|
||||
* method to marshal any algorithm-specific parameters.
|
||||
*/
|
||||
@Override
|
||||
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
Document ownerDoc = DOMUtils.getOwnerDocument(parent);
|
||||
|
||||
Element smElem = DOMUtils.createElement(ownerDoc, "SignatureMethod",
|
||||
XMLSignature.XMLNS, dsPrefix);
|
||||
DOMUtils.setAttribute(smElem, "Algorithm", getAlgorithm());
|
||||
|
||||
if (getParameterSpec() != null) {
|
||||
marshalParams(smElem, dsPrefix);
|
||||
}
|
||||
|
||||
parent.appendChild(smElem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Marshals the algorithm-specific parameters to an Element and
|
||||
* appends it to the specified parent element. By default, this method
|
||||
* throws an exception since most SignatureMethod algorithms do not have
|
||||
* parameters. Subclasses should override it if they have parameters.
|
||||
*
|
||||
* @param parent the parent element to append the parameters to
|
||||
* @param paramsPrefix the algorithm parameters prefix to use
|
||||
* @throws MarshalException if the parameters cannot be marshalled
|
||||
*/
|
||||
void marshalParams(Element parent, String paramsPrefix)
|
||||
throws MarshalException
|
||||
{
|
||||
throw new MarshalException("no parameters should " +
|
||||
"be specified for the " + getAlgorithm() +
|
||||
" SignatureMethod algorithm");
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmarshals {@code SignatureMethodParameterSpec} from the specified
|
||||
* {@code Element}. By default, this method throws an exception since
|
||||
* most SignatureMethod algorithms do not have parameters. Subclasses should
|
||||
* override it if they have parameters.
|
||||
*
|
||||
* @param paramsElem the {@code Element} holding the input params
|
||||
* @return the algorithm-specific {@code SignatureMethodParameterSpec}
|
||||
* @throws MarshalException if the parameters cannot be unmarshalled
|
||||
*/
|
||||
SignatureMethodParameterSpec unmarshalParams(Element paramsElem)
|
||||
throws MarshalException
|
||||
{
|
||||
throw new MarshalException("no parameters should " +
|
||||
"be specified for the " + getAlgorithm() +
|
||||
" SignatureMethod algorithm");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified parameters are valid for this algorithm. By
|
||||
* default, this method throws an exception if parameters are specified
|
||||
* since most SignatureMethod algorithms do not have parameters. Subclasses
|
||||
* should override it if they have parameters.
|
||||
*
|
||||
* @param params the algorithm-specific params (may be {@code null})
|
||||
* @throws InvalidAlgorithmParameterException if the parameters are not
|
||||
* appropriate for this signature method
|
||||
*/
|
||||
void checkParams(SignatureMethodParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException
|
||||
{
|
||||
if (params != null) {
|
||||
throw new InvalidAlgorithmParameterException("no parameters " +
|
||||
"should be specified for the " + getAlgorithm() +
|
||||
" SignatureMethod algorithm");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(o instanceof SignatureMethod)) {
|
||||
return false;
|
||||
}
|
||||
SignatureMethod osm = (SignatureMethod)o;
|
||||
|
||||
return getAlgorithm().equals(osm.getAlgorithm()) &&
|
||||
paramsEqual(osm.getParameterSpec());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 17;
|
||||
result = 31 * result + getAlgorithm().hashCode();
|
||||
AlgorithmParameterSpec spec = getParameterSpec();
|
||||
if (spec != null) {
|
||||
result = 31 * result + spec.hashCode();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if parameters are equal; false otherwise.
|
||||
*
|
||||
* Subclasses should override this method to compare algorithm-specific
|
||||
* parameters.
|
||||
*/
|
||||
boolean paramsEqual(AlgorithmParameterSpec spec)
|
||||
{
|
||||
return getParameterSpec() == spec;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,274 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: ApacheCanonicalizer.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dsig.TransformException;
|
||||
import javax.xml.crypto.dsig.TransformService;
|
||||
import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer;
|
||||
import com.sun.org.apache.xml.internal.security.c14n.InvalidCanonicalizerException;
|
||||
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
|
||||
import com.sun.org.apache.xml.internal.security.transforms.Transform;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
public abstract class ApacheCanonicalizer extends TransformService {
|
||||
|
||||
static {
|
||||
com.sun.org.apache.xml.internal.security.Init.init();
|
||||
}
|
||||
|
||||
private static final com.sun.org.slf4j.internal.Logger LOG =
|
||||
com.sun.org.slf4j.internal.LoggerFactory.getLogger(ApacheCanonicalizer.class);
|
||||
protected Canonicalizer apacheCanonicalizer;
|
||||
private Transform apacheTransform;
|
||||
protected String inclusiveNamespaces;
|
||||
protected C14NMethodParameterSpec params;
|
||||
protected Document ownerDoc;
|
||||
protected Element transformElem;
|
||||
|
||||
public final AlgorithmParameterSpec getParameterSpec()
|
||||
{
|
||||
return params;
|
||||
}
|
||||
|
||||
public void init(XMLStructure parent, XMLCryptoContext context)
|
||||
throws InvalidAlgorithmParameterException
|
||||
{
|
||||
if (context != null && !(context instanceof DOMCryptoContext)) {
|
||||
throw new ClassCastException
|
||||
("context must be of type DOMCryptoContext");
|
||||
}
|
||||
if (parent == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (!(parent instanceof javax.xml.crypto.dom.DOMStructure)) {
|
||||
throw new ClassCastException("parent must be of type DOMStructure");
|
||||
}
|
||||
transformElem = (Element)
|
||||
((javax.xml.crypto.dom.DOMStructure)parent).getNode();
|
||||
ownerDoc = DOMUtils.getOwnerDocument(transformElem);
|
||||
}
|
||||
|
||||
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
if (context != null && !(context instanceof DOMCryptoContext)) {
|
||||
throw new ClassCastException
|
||||
("context must be of type DOMCryptoContext");
|
||||
}
|
||||
if (parent == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (!(parent instanceof javax.xml.crypto.dom.DOMStructure)) {
|
||||
throw new ClassCastException("parent must be of type DOMStructure");
|
||||
}
|
||||
transformElem = (Element)
|
||||
((javax.xml.crypto.dom.DOMStructure)parent).getNode();
|
||||
ownerDoc = DOMUtils.getOwnerDocument(transformElem);
|
||||
}
|
||||
|
||||
public Data canonicalize(Data data, XMLCryptoContext xc)
|
||||
throws TransformException
|
||||
{
|
||||
return canonicalize(data, xc, null);
|
||||
}
|
||||
|
||||
public Data canonicalize(Data data, XMLCryptoContext xc, OutputStream os)
|
||||
throws TransformException
|
||||
{
|
||||
if (apacheCanonicalizer == null) {
|
||||
try {
|
||||
apacheCanonicalizer = Canonicalizer.getInstance(getAlgorithm());
|
||||
boolean secVal = Utils.secureValidation(xc);
|
||||
apacheCanonicalizer.setSecureValidation(secVal);
|
||||
LOG.debug("Created canonicalizer for algorithm: {}", getAlgorithm());
|
||||
} catch (InvalidCanonicalizerException ice) {
|
||||
throw new TransformException
|
||||
("Couldn't find Canonicalizer for: " + getAlgorithm() +
|
||||
": " + ice.getMessage(), ice);
|
||||
}
|
||||
}
|
||||
|
||||
if (os != null) {
|
||||
apacheCanonicalizer.setWriter(os);
|
||||
} else {
|
||||
apacheCanonicalizer.setWriter(new ByteArrayOutputStream());
|
||||
}
|
||||
|
||||
try {
|
||||
Set<Node> nodeSet = null;
|
||||
if (data instanceof ApacheData) {
|
||||
XMLSignatureInput in =
|
||||
((ApacheData)data).getXMLSignatureInput();
|
||||
if (in.isElement()) {
|
||||
if (inclusiveNamespaces != null) {
|
||||
return new OctetStreamData(new ByteArrayInputStream
|
||||
(apacheCanonicalizer.canonicalizeSubtree
|
||||
(in.getSubNode(), inclusiveNamespaces)));
|
||||
} else {
|
||||
return new OctetStreamData(new ByteArrayInputStream
|
||||
(apacheCanonicalizer.canonicalizeSubtree
|
||||
(in.getSubNode())));
|
||||
}
|
||||
} else if (in.isNodeSet()) {
|
||||
nodeSet = in.getNodeSet();
|
||||
} else {
|
||||
return new OctetStreamData(new ByteArrayInputStream(
|
||||
apacheCanonicalizer.canonicalize(
|
||||
Utils.readBytesFromStream(in.getOctetStream()))));
|
||||
}
|
||||
} else if (data instanceof DOMSubTreeData) {
|
||||
DOMSubTreeData subTree = (DOMSubTreeData)data;
|
||||
if (inclusiveNamespaces != null) {
|
||||
return new OctetStreamData(new ByteArrayInputStream
|
||||
(apacheCanonicalizer.canonicalizeSubtree
|
||||
(subTree.getRoot(), inclusiveNamespaces)));
|
||||
} else {
|
||||
return new OctetStreamData(new ByteArrayInputStream
|
||||
(apacheCanonicalizer.canonicalizeSubtree
|
||||
(subTree.getRoot())));
|
||||
}
|
||||
} else if (data instanceof NodeSetData) {
|
||||
NodeSetData nsd = (NodeSetData)data;
|
||||
// convert Iterator to Set
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<Node> ns = Utils.toNodeSet(nsd.iterator());
|
||||
nodeSet = ns;
|
||||
LOG.debug("Canonicalizing {} nodes", nodeSet.size());
|
||||
} else {
|
||||
return new OctetStreamData(new ByteArrayInputStream(
|
||||
apacheCanonicalizer.canonicalize(
|
||||
Utils.readBytesFromStream(
|
||||
((OctetStreamData)data).getOctetStream()))));
|
||||
}
|
||||
if (inclusiveNamespaces != null) {
|
||||
return new OctetStreamData(new ByteArrayInputStream(
|
||||
apacheCanonicalizer.canonicalizeXPathNodeSet
|
||||
(nodeSet, inclusiveNamespaces)));
|
||||
} else {
|
||||
return new OctetStreamData(new ByteArrayInputStream(
|
||||
apacheCanonicalizer.canonicalizeXPathNodeSet(nodeSet)));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new TransformException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Data transform(Data data, XMLCryptoContext xc, OutputStream os)
|
||||
throws TransformException
|
||||
{
|
||||
if (data == null) {
|
||||
throw new NullPointerException("data must not be null");
|
||||
}
|
||||
if (os == null) {
|
||||
throw new NullPointerException("output stream must not be null");
|
||||
}
|
||||
|
||||
if (ownerDoc == null) {
|
||||
throw new TransformException("transform must be marshalled");
|
||||
}
|
||||
|
||||
if (apacheTransform == null) {
|
||||
try {
|
||||
apacheTransform =
|
||||
new Transform(ownerDoc, getAlgorithm(), transformElem.getChildNodes());
|
||||
apacheTransform.setElement(transformElem, xc.getBaseURI());
|
||||
boolean secVal = Utils.secureValidation(xc);
|
||||
apacheTransform.setSecureValidation(secVal);
|
||||
LOG.debug("Created transform for algorithm: {}", getAlgorithm());
|
||||
} catch (Exception ex) {
|
||||
throw new TransformException
|
||||
("Couldn't find Transform for: " + getAlgorithm(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
XMLSignatureInput in;
|
||||
if (data instanceof ApacheData) {
|
||||
LOG.debug("ApacheData = true");
|
||||
in = ((ApacheData)data).getXMLSignatureInput();
|
||||
} else if (data instanceof NodeSetData) {
|
||||
LOG.debug("isNodeSet() = true");
|
||||
if (data instanceof DOMSubTreeData) {
|
||||
DOMSubTreeData subTree = (DOMSubTreeData)data;
|
||||
in = new XMLSignatureInput(subTree.getRoot());
|
||||
in.setExcludeComments(subTree.excludeComments());
|
||||
} else {
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<Node> nodeSet =
|
||||
Utils.toNodeSet(((NodeSetData)data).iterator());
|
||||
in = new XMLSignatureInput(nodeSet);
|
||||
}
|
||||
} else {
|
||||
LOG.debug("isNodeSet() = false");
|
||||
try {
|
||||
in = new XMLSignatureInput
|
||||
(((OctetStreamData)data).getOctetStream());
|
||||
} catch (Exception ex) {
|
||||
throw new TransformException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
boolean secVal = Utils.secureValidation(xc);
|
||||
in.setSecureValidation(secVal);
|
||||
|
||||
try {
|
||||
in = apacheTransform.performTransform(in, os);
|
||||
if (!in.isNodeSet() && !in.isElement()) {
|
||||
return null;
|
||||
}
|
||||
if (in.isOctetStream()) {
|
||||
return new ApacheOctetStreamData(in);
|
||||
} else {
|
||||
return new ApacheNodeSetData(in);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
throw new TransformException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean isFeatureSupported(String feature) {
|
||||
if (feature == null) {
|
||||
throw new NullPointerException();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
44
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/ApacheData.java
Normal file
44
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/ApacheData.java
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: ApacheData.java 1788465 2017-03-24 15:10:51Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import javax.xml.crypto.Data;
|
||||
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
|
||||
|
||||
/**
|
||||
* XMLSignatureInput Data wrapper.
|
||||
*
|
||||
*/
|
||||
public interface ApacheData extends Data {
|
||||
|
||||
/**
|
||||
* Returns the XMLSignatureInput.
|
||||
*/
|
||||
XMLSignatureInput getXMLSignatureInput();
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* 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, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: ApacheNodeSetData.java 1496478 2013-06-25 14:01:16Z mullan $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.xml.crypto.NodeSetData;
|
||||
import org.w3c.dom.Node;
|
||||
import com.sun.org.apache.xml.internal.security.signature.NodeFilter;
|
||||
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
|
||||
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
|
||||
|
||||
public class ApacheNodeSetData implements ApacheData, NodeSetData {
|
||||
|
||||
private XMLSignatureInput xi;
|
||||
|
||||
public ApacheNodeSetData(XMLSignatureInput xi) {
|
||||
this.xi = xi;
|
||||
}
|
||||
|
||||
public Iterator<Node> iterator() {
|
||||
// If nodefilters are set, must execute them first to create node-set
|
||||
if (xi.getNodeFilters() != null && !xi.getNodeFilters().isEmpty()) {
|
||||
return Collections.unmodifiableSet
|
||||
(getNodeSet(xi.getNodeFilters())).iterator();
|
||||
}
|
||||
try {
|
||||
return Collections.unmodifiableSet(xi.getNodeSet()).iterator();
|
||||
} catch (Exception e) {
|
||||
// should not occur
|
||||
throw new RuntimeException
|
||||
("unrecoverable error retrieving nodeset", e);
|
||||
}
|
||||
}
|
||||
|
||||
public XMLSignatureInput getXMLSignatureInput() {
|
||||
return xi;
|
||||
}
|
||||
|
||||
private Set<Node> getNodeSet(List<NodeFilter> nodeFilters) {
|
||||
if (xi.isNeedsToBeExpanded()) {
|
||||
XMLUtils.circumventBug2650
|
||||
(XMLUtils.getOwnerDocument(xi.getSubNode()));
|
||||
}
|
||||
|
||||
Set<Node> inputSet = new LinkedHashSet<Node>();
|
||||
XMLUtils.getSet(xi.getSubNode(), inputSet,
|
||||
null, !xi.isExcludeComments());
|
||||
Set<Node> nodeSet = new LinkedHashSet<Node>();
|
||||
for (Node currentNode : inputSet) {
|
||||
Iterator<NodeFilter> it = nodeFilters.iterator();
|
||||
boolean skipNode = false;
|
||||
while (it.hasNext() && !skipNode) {
|
||||
NodeFilter nf = it.next();
|
||||
if (nf.isNodeInclude(currentNode) != 1) {
|
||||
skipNode = true;
|
||||
}
|
||||
}
|
||||
if (!skipNode) {
|
||||
nodeSet.add(currentNode);
|
||||
}
|
||||
}
|
||||
return nodeSet;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: ApacheOctetStreamData.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.xml.crypto.OctetStreamData;
|
||||
import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
|
||||
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
|
||||
|
||||
public class ApacheOctetStreamData extends OctetStreamData
|
||||
implements ApacheData {
|
||||
|
||||
private XMLSignatureInput xi;
|
||||
|
||||
public ApacheOctetStreamData(XMLSignatureInput xi)
|
||||
throws CanonicalizationException, IOException
|
||||
{
|
||||
super(xi.getOctetStream(), xi.getSourceURI(), xi.getMIMEType());
|
||||
this.xi = xi;
|
||||
}
|
||||
|
||||
public XMLSignatureInput getXMLSignatureInput() {
|
||||
return xi;
|
||||
}
|
||||
}
|
||||
212
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/ApacheTransform.java
Normal file
212
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/ApacheTransform.java
Normal file
@@ -0,0 +1,212 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: ApacheTransform.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import java.util.Set;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
|
||||
import com.sun.org.apache.xml.internal.security.transforms.Transform;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
|
||||
|
||||
/**
|
||||
* This is a wrapper/glue class which invokes the Apache XML-Security
|
||||
* Transform.
|
||||
*
|
||||
*/
|
||||
public abstract class ApacheTransform extends TransformService {
|
||||
|
||||
static {
|
||||
com.sun.org.apache.xml.internal.security.Init.init();
|
||||
}
|
||||
|
||||
private static final com.sun.org.slf4j.internal.Logger LOG =
|
||||
com.sun.org.slf4j.internal.LoggerFactory.getLogger(ApacheTransform.class);
|
||||
private Transform apacheTransform;
|
||||
protected Document ownerDoc;
|
||||
protected Element transformElem;
|
||||
protected TransformParameterSpec params;
|
||||
|
||||
@Override
|
||||
public final AlgorithmParameterSpec getParameterSpec() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public void init(XMLStructure parent, XMLCryptoContext context)
|
||||
throws InvalidAlgorithmParameterException
|
||||
{
|
||||
if (context != null && !(context instanceof DOMCryptoContext)) {
|
||||
throw new ClassCastException
|
||||
("context must be of type DOMCryptoContext");
|
||||
}
|
||||
if (parent == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (!(parent instanceof javax.xml.crypto.dom.DOMStructure)) {
|
||||
throw new ClassCastException("parent must be of type DOMStructure");
|
||||
}
|
||||
transformElem = (Element)
|
||||
((javax.xml.crypto.dom.DOMStructure) parent).getNode();
|
||||
ownerDoc = DOMUtils.getOwnerDocument(transformElem);
|
||||
}
|
||||
|
||||
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
if (context != null && !(context instanceof DOMCryptoContext)) {
|
||||
throw new ClassCastException
|
||||
("context must be of type DOMCryptoContext");
|
||||
}
|
||||
if (parent == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (!(parent instanceof javax.xml.crypto.dom.DOMStructure)) {
|
||||
throw new ClassCastException("parent must be of type DOMStructure");
|
||||
}
|
||||
transformElem = (Element)
|
||||
((javax.xml.crypto.dom.DOMStructure) parent).getNode();
|
||||
ownerDoc = DOMUtils.getOwnerDocument(transformElem);
|
||||
}
|
||||
|
||||
public Data transform(Data data, XMLCryptoContext xc)
|
||||
throws TransformException
|
||||
{
|
||||
if (data == null) {
|
||||
throw new NullPointerException("data must not be null");
|
||||
}
|
||||
return transformIt(data, xc, null);
|
||||
}
|
||||
|
||||
public Data transform(Data data, XMLCryptoContext xc, OutputStream os)
|
||||
throws TransformException
|
||||
{
|
||||
if (data == null) {
|
||||
throw new NullPointerException("data must not be null");
|
||||
}
|
||||
if (os == null) {
|
||||
throw new NullPointerException("output stream must not be null");
|
||||
}
|
||||
return transformIt(data, xc, os);
|
||||
}
|
||||
|
||||
private Data transformIt(Data data, XMLCryptoContext xc, OutputStream os)
|
||||
throws TransformException
|
||||
{
|
||||
if (ownerDoc == null) {
|
||||
throw new TransformException("transform must be marshalled");
|
||||
}
|
||||
|
||||
if (apacheTransform == null) {
|
||||
try {
|
||||
apacheTransform =
|
||||
new Transform(ownerDoc, getAlgorithm(), transformElem.getChildNodes());
|
||||
apacheTransform.setElement(transformElem, xc.getBaseURI());
|
||||
boolean secVal = Utils.secureValidation(xc);
|
||||
apacheTransform.setSecureValidation(secVal);
|
||||
LOG.debug("Created transform for algorithm: {}", getAlgorithm());
|
||||
} catch (Exception ex) {
|
||||
throw new TransformException("Couldn't find Transform for: " +
|
||||
getAlgorithm(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
if (Utils.secureValidation(xc)) {
|
||||
String algorithm = getAlgorithm();
|
||||
if (Policy.restrictAlg(algorithm)) {
|
||||
throw new TransformException(
|
||||
"Transform " + algorithm + " is forbidden when secure validation is enabled"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
XMLSignatureInput in;
|
||||
if (data instanceof ApacheData) {
|
||||
LOG.debug("ApacheData = true");
|
||||
in = ((ApacheData)data).getXMLSignatureInput();
|
||||
} else if (data instanceof NodeSetData) {
|
||||
LOG.debug("isNodeSet() = true");
|
||||
if (data instanceof DOMSubTreeData) {
|
||||
LOG.debug("DOMSubTreeData = true");
|
||||
DOMSubTreeData subTree = (DOMSubTreeData)data;
|
||||
in = new XMLSignatureInput(subTree.getRoot());
|
||||
in.setExcludeComments(subTree.excludeComments());
|
||||
} else {
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<Node> nodeSet =
|
||||
Utils.toNodeSet(((NodeSetData)data).iterator());
|
||||
in = new XMLSignatureInput(nodeSet);
|
||||
}
|
||||
} else {
|
||||
LOG.debug("isNodeSet() = false");
|
||||
try {
|
||||
in = new XMLSignatureInput
|
||||
(((OctetStreamData)data).getOctetStream());
|
||||
} catch (Exception ex) {
|
||||
throw new TransformException(ex);
|
||||
}
|
||||
}
|
||||
boolean secVal = Utils.secureValidation(xc);
|
||||
in.setSecureValidation(secVal);
|
||||
|
||||
try {
|
||||
if (os != null) {
|
||||
in = apacheTransform.performTransform(in, os);
|
||||
if (!in.isNodeSet() && !in.isElement()) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
in = apacheTransform.performTransform(in);
|
||||
}
|
||||
if (in.isOctetStream()) {
|
||||
return new ApacheOctetStreamData(in);
|
||||
} else {
|
||||
return new ApacheNodeSetData(in);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
throw new TransformException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean isFeatureSupported(String feature) {
|
||||
if (feature == null) {
|
||||
throw new NullPointerException();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMBase64Transform.java 1788465 2017-03-24 15:10:51Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
|
||||
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
|
||||
|
||||
/**
|
||||
* DOM-based implementation of Base64 Encoding Transform.
|
||||
* (Uses Apache XML-Sec Transform implementation)
|
||||
*
|
||||
*/
|
||||
public final class DOMBase64Transform extends ApacheTransform {
|
||||
|
||||
@Override
|
||||
public void init(TransformParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
if (params != null) {
|
||||
throw new InvalidAlgorithmParameterException("params must be null");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer;
|
||||
import com.sun.org.apache.xml.internal.security.c14n.InvalidCanonicalizerException;
|
||||
|
||||
/**
|
||||
* DOM-based implementation of CanonicalizationMethod for Canonical XML 1.1
|
||||
* (with or without comments). Uses Apache XML-Sec Canonicalizer.
|
||||
*
|
||||
*/
|
||||
public final class DOMCanonicalXMLC14N11Method extends ApacheCanonicalizer {
|
||||
|
||||
public static final String C14N_11 = "http://www.w3.org/2006/12/xml-c14n11";
|
||||
public static final String C14N_11_WITH_COMMENTS
|
||||
= "http://www.w3.org/2006/12/xml-c14n11#WithComments";
|
||||
|
||||
public void init(TransformParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
if (params != null) {
|
||||
throw new InvalidAlgorithmParameterException("no parameters " +
|
||||
"should be specified for Canonical XML 1.1 algorithm");
|
||||
}
|
||||
}
|
||||
|
||||
public Data transform(Data data, XMLCryptoContext xc)
|
||||
throws TransformException {
|
||||
|
||||
// ignore comments if dereferencing same-document URI that requires
|
||||
// you to omit comments, even if the Transform says otherwise -
|
||||
// this is to be compliant with section 4.3.3.3 of W3C Rec.
|
||||
if (data instanceof DOMSubTreeData) {
|
||||
DOMSubTreeData subTree = (DOMSubTreeData) data;
|
||||
if (subTree.excludeComments()) {
|
||||
try {
|
||||
apacheCanonicalizer = Canonicalizer.getInstance(C14N_11);
|
||||
boolean secVal = Utils.secureValidation(xc);
|
||||
apacheCanonicalizer.setSecureValidation(secVal);
|
||||
} catch (InvalidCanonicalizerException ice) {
|
||||
throw new TransformException
|
||||
("Couldn't find Canonicalizer for: " +
|
||||
C14N_11 + ": " + ice.getMessage(), ice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return canonicalize(data, xc);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMCanonicalXMLC14NMethod.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer;
|
||||
import com.sun.org.apache.xml.internal.security.c14n.InvalidCanonicalizerException;
|
||||
|
||||
/**
|
||||
* DOM-based implementation of CanonicalizationMethod for Canonical XML
|
||||
* (with or without comments). Uses Apache XML-Sec Canonicalizer.
|
||||
*
|
||||
*/
|
||||
public final class DOMCanonicalXMLC14NMethod extends ApacheCanonicalizer {
|
||||
|
||||
public void init(TransformParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
if (params != null) {
|
||||
throw new InvalidAlgorithmParameterException("no parameters " +
|
||||
"should be specified for Canonical XML C14N algorithm");
|
||||
}
|
||||
}
|
||||
|
||||
public Data transform(Data data, XMLCryptoContext xc)
|
||||
throws TransformException {
|
||||
|
||||
// ignore comments if dereferencing same-document URI that requires
|
||||
// you to omit comments, even if the Transform says otherwise -
|
||||
// this is to be compliant with section 4.3.3.3 of W3C Rec.
|
||||
if (data instanceof DOMSubTreeData) {
|
||||
DOMSubTreeData subTree = (DOMSubTreeData) data;
|
||||
if (subTree.excludeComments()) {
|
||||
try {
|
||||
apacheCanonicalizer = Canonicalizer.getInstance
|
||||
(CanonicalizationMethod.INCLUSIVE);
|
||||
boolean secVal = Utils.secureValidation(xc);
|
||||
apacheCanonicalizer.setSecureValidation(secVal);
|
||||
} catch (InvalidCanonicalizerException ice) {
|
||||
throw new TransformException
|
||||
("Couldn't find Canonicalizer for: " +
|
||||
CanonicalizationMethod.INCLUSIVE + ": " +
|
||||
ice.getMessage(), ice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return canonicalize(data, xc);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* 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, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMCanonicalizationMethod.java 1788465 2017-03-24 15:10:51Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.Provider;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
|
||||
/**
|
||||
* DOM-based abstract implementation of CanonicalizationMethod.
|
||||
*
|
||||
*/
|
||||
public class DOMCanonicalizationMethod extends DOMTransform
|
||||
implements CanonicalizationMethod {
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMCanonicalizationMethod}.
|
||||
*
|
||||
* @param spi TransformService
|
||||
*/
|
||||
public DOMCanonicalizationMethod(TransformService spi)
|
||||
throws InvalidAlgorithmParameterException
|
||||
{
|
||||
super(spi);
|
||||
if (!(spi instanceof ApacheCanonicalizer) && !isC14Nalg(spi.getAlgorithm())) {
|
||||
throw new InvalidAlgorithmParameterException("Illegal CanonicalizationMethod");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMCanonicalizationMethod} from an element. It unmarshals any
|
||||
* algorithm-specific input parameters.
|
||||
*
|
||||
* @param cmElem a CanonicalizationMethod element
|
||||
*/
|
||||
public DOMCanonicalizationMethod(Element cmElem, XMLCryptoContext context,
|
||||
Provider provider)
|
||||
throws MarshalException
|
||||
{
|
||||
super(cmElem, context, provider);
|
||||
if (!(spi instanceof ApacheCanonicalizer) && !isC14Nalg(spi.getAlgorithm())) {
|
||||
throw new MarshalException("Illegal CanonicalizationMethod");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Canonicalizes the specified data using the underlying canonicalization
|
||||
* algorithm. This is a convenience method that is equivalent to invoking
|
||||
* the {@link #transform transform} method.
|
||||
*
|
||||
* @param data the data to be canonicalized
|
||||
* @param xc the {@code XMLCryptoContext} containing
|
||||
* additional context (may be {@code null} if not applicable)
|
||||
* @return the canonicalized data
|
||||
* @throws NullPointerException if {@code data} is {@code null}
|
||||
* @throws TransformException if an unexpected error occurs while
|
||||
* canonicalizing the data
|
||||
*/
|
||||
public Data canonicalize(Data data, XMLCryptoContext xc)
|
||||
throws TransformException
|
||||
{
|
||||
return transform(data, xc);
|
||||
}
|
||||
|
||||
public Data canonicalize(Data data, XMLCryptoContext xc, OutputStream os)
|
||||
throws TransformException
|
||||
{
|
||||
return transform(data, xc, os);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(o instanceof CanonicalizationMethod)) {
|
||||
return false;
|
||||
}
|
||||
CanonicalizationMethod ocm = (CanonicalizationMethod)o;
|
||||
|
||||
return getAlgorithm().equals(ocm.getAlgorithm()) &&
|
||||
DOMUtils.paramsEqual(getParameterSpec(), ocm.getParameterSpec());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 17;
|
||||
result = 31 * result + getAlgorithm().hashCode();
|
||||
AlgorithmParameterSpec spec = getParameterSpec();
|
||||
if (spec != null) {
|
||||
result = 31 * result + spec.hashCode();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static boolean isC14Nalg(String alg) {
|
||||
return isInclusiveC14Nalg(alg) || isExclusiveC14Nalg(alg) || isC14N11alg(alg);
|
||||
}
|
||||
|
||||
private static boolean isInclusiveC14Nalg(String alg) {
|
||||
return alg.equals(CanonicalizationMethod.INCLUSIVE)
|
||||
|| alg.equals(CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS);
|
||||
}
|
||||
|
||||
private static boolean isExclusiveC14Nalg(String alg) {
|
||||
return alg.equals(CanonicalizationMethod.EXCLUSIVE)
|
||||
|| alg.equals(CanonicalizationMethod.EXCLUSIVE_WITH_COMMENTS);
|
||||
}
|
||||
|
||||
private static boolean isC14N11alg(String alg) {
|
||||
return alg.equals(DOMCanonicalXMLC14N11Method.C14N_11)
|
||||
|| alg.equals(DOMCanonicalXMLC14N11Method.C14N_11_WITH_COMMENTS);
|
||||
}
|
||||
}
|
||||
105
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMCryptoBinary.java
Normal file
105
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMCryptoBinary.java
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
/**
|
||||
* A DOM-based representation of the XML {@code CryptoBinary} simple type
|
||||
* as defined in the W3C specification for XML-Signature Syntax and Processing.
|
||||
* The XML Schema Definition is defined as:
|
||||
*
|
||||
* <pre>{@code
|
||||
* <simpleType name="CryptoBinary">
|
||||
* <restriction base = "base64Binary">
|
||||
* </restriction>
|
||||
* </simpleType>
|
||||
* }</pre>
|
||||
*
|
||||
* @author Sean Mullan
|
||||
*/
|
||||
public final class DOMCryptoBinary extends DOMStructure {
|
||||
|
||||
private final BigInteger bigNum;
|
||||
private final String value;
|
||||
|
||||
/**
|
||||
* Create a {@code DOMCryptoBinary} instance from the specified
|
||||
* {@code BigInteger}
|
||||
*
|
||||
* @param bigNum the arbitrary-length integer
|
||||
* @throws NullPointerException if {@code bigNum} is {@code null}
|
||||
*/
|
||||
public DOMCryptoBinary(BigInteger bigNum) {
|
||||
if (bigNum == null) {
|
||||
throw new NullPointerException("bigNum is null");
|
||||
}
|
||||
this.bigNum = bigNum;
|
||||
// convert to bitstring
|
||||
byte[] bytes = XMLUtils.getBytes(bigNum, bigNum.bitLength());
|
||||
value = XMLUtils.encodeToString(bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMCryptoBinary} from a node.
|
||||
*
|
||||
* @param cbNode a CryptoBinary text node
|
||||
* @throws MarshalException if value cannot be decoded (invalid format)
|
||||
*/
|
||||
public DOMCryptoBinary(Node cbNode) throws MarshalException {
|
||||
value = cbNode.getNodeValue();
|
||||
try {
|
||||
bigNum = new BigInteger(1, XMLUtils.decode(((Text) cbNode).getData()));
|
||||
} catch (Exception ex) {
|
||||
throw new MarshalException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@code BigInteger} that this object contains.
|
||||
*
|
||||
* @return the {@code BigInteger} that this object contains
|
||||
*/
|
||||
public BigInteger getBigNum() {
|
||||
return bigNum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(Node parent, String prefix, DOMCryptoContext context)
|
||||
throws MarshalException {
|
||||
parent.appendChild
|
||||
(DOMUtils.getOwnerDocument(parent).createTextNode(value));
|
||||
}
|
||||
}
|
||||
328
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMDigestMethod.java
Normal file
328
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMDigestMethod.java
Normal file
@@ -0,0 +1,328 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMDigestMethod.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
import javax.xml.crypto.dsig.spec.DigestMethodParameterSpec;
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* DOM-based abstract implementation of DigestMethod.
|
||||
*
|
||||
*/
|
||||
public abstract class DOMDigestMethod extends DOMStructure
|
||||
implements DigestMethod {
|
||||
|
||||
static final String SHA224 =
|
||||
"http://www.w3.org/2001/04/xmldsig-more#sha224"; // see RFC 4051
|
||||
static final String SHA384 =
|
||||
"http://www.w3.org/2001/04/xmldsig-more#sha384"; // see RFC 4051
|
||||
|
||||
private DigestMethodParameterSpec params;
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMDigestMethod}.
|
||||
*
|
||||
* @param params the algorithm-specific params (may be {@code null})
|
||||
* @throws InvalidAlgorithmParameterException if the parameters are not
|
||||
* appropriate for this digest method
|
||||
*/
|
||||
DOMDigestMethod(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException
|
||||
{
|
||||
if (params != null && !(params instanceof DigestMethodParameterSpec)) {
|
||||
throw new InvalidAlgorithmParameterException
|
||||
("params must be of type DigestMethodParameterSpec");
|
||||
}
|
||||
checkParams((DigestMethodParameterSpec)params);
|
||||
this.params = (DigestMethodParameterSpec)params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMDigestMethod} from an element. This constructor
|
||||
* invokes the abstract {@link #unmarshalParams unmarshalParams} method to
|
||||
* unmarshal any algorithm-specific input parameters.
|
||||
*
|
||||
* @param dmElem a DigestMethod element
|
||||
*/
|
||||
DOMDigestMethod(Element dmElem) throws MarshalException {
|
||||
Element paramsElem = DOMUtils.getFirstChildElement(dmElem);
|
||||
if (paramsElem != null) {
|
||||
params = unmarshalParams(paramsElem);
|
||||
}
|
||||
try {
|
||||
checkParams(params);
|
||||
} catch (InvalidAlgorithmParameterException iape) {
|
||||
throw new MarshalException(iape);
|
||||
}
|
||||
}
|
||||
|
||||
static DigestMethod unmarshal(Element dmElem) throws MarshalException {
|
||||
String alg = DOMUtils.getAttributeValue(dmElem, "Algorithm");
|
||||
if (alg.equals(DigestMethod.SHA1)) {
|
||||
return new SHA1(dmElem);
|
||||
} else if (alg.equals(SHA224)) {
|
||||
return new SHA224(dmElem);
|
||||
} else if (alg.equals(DigestMethod.SHA256)) {
|
||||
return new SHA256(dmElem);
|
||||
} else if (alg.equals(SHA384)) {
|
||||
return new SHA384(dmElem);
|
||||
} else if (alg.equals(DigestMethod.SHA512)) {
|
||||
return new SHA512(dmElem);
|
||||
} else if (alg.equals(DigestMethod.RIPEMD160)) {
|
||||
return new RIPEMD160(dmElem);
|
||||
} else {
|
||||
throw new MarshalException("unsupported DigestMethod algorithm: " +
|
||||
alg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified parameters are valid for this algorithm. By
|
||||
* default, this method throws an exception if parameters are specified
|
||||
* since most DigestMethod algorithms do not have parameters. Subclasses
|
||||
* should override it if they have parameters.
|
||||
*
|
||||
* @param params the algorithm-specific params (may be {@code null})
|
||||
* @throws InvalidAlgorithmParameterException if the parameters are not
|
||||
* appropriate for this digest method
|
||||
*/
|
||||
void checkParams(DigestMethodParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException
|
||||
{
|
||||
if (params != null) {
|
||||
throw new InvalidAlgorithmParameterException("no parameters " +
|
||||
"should be specified for the " + getMessageDigestAlgorithm() +
|
||||
" DigestMethod algorithm");
|
||||
}
|
||||
}
|
||||
|
||||
public final AlgorithmParameterSpec getParameterSpec() {
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmarshals {@code DigestMethodParameterSpec} from the specified
|
||||
* {@code Element}. By default, this method throws an exception since
|
||||
* most DigestMethod algorithms do not have parameters. Subclasses should
|
||||
* override it if they have parameters.
|
||||
*
|
||||
* @param paramsElem the {@code Element} holding the input params
|
||||
* @return the algorithm-specific {@code DigestMethodParameterSpec}
|
||||
* @throws MarshalException if the parameters cannot be unmarshalled
|
||||
*/
|
||||
DigestMethodParameterSpec unmarshalParams(Element paramsElem)
|
||||
throws MarshalException
|
||||
{
|
||||
throw new MarshalException("no parameters should " +
|
||||
"be specified for the " +
|
||||
getMessageDigestAlgorithm() +
|
||||
" DigestMethod algorithm");
|
||||
}
|
||||
|
||||
/**
|
||||
* This method invokes the abstract {@link #marshalParams marshalParams}
|
||||
* method to marshal any algorithm-specific parameters.
|
||||
*/
|
||||
@Override
|
||||
public void marshal(Node parent, String prefix, DOMCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
Document ownerDoc = DOMUtils.getOwnerDocument(parent);
|
||||
|
||||
Element dmElem = DOMUtils.createElement(ownerDoc, "DigestMethod",
|
||||
XMLSignature.XMLNS, prefix);
|
||||
DOMUtils.setAttribute(dmElem, "Algorithm", getAlgorithm());
|
||||
|
||||
if (params != null) {
|
||||
marshalParams(dmElem, prefix);
|
||||
}
|
||||
|
||||
parent.appendChild(dmElem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(o instanceof DigestMethod)) {
|
||||
return false;
|
||||
}
|
||||
DigestMethod odm = (DigestMethod)o;
|
||||
|
||||
boolean paramsEqual = params == null ? odm.getParameterSpec() == null :
|
||||
params.equals(odm.getParameterSpec());
|
||||
|
||||
return getAlgorithm().equals(odm.getAlgorithm()) && paramsEqual;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 17;
|
||||
if (params != null) {
|
||||
result = 31 * result + params.hashCode();
|
||||
}
|
||||
result = 31 * result + getAlgorithm().hashCode();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marshals the algorithm-specific parameters to an Element and
|
||||
* appends it to the specified parent element. By default, this method
|
||||
* throws an exception since most DigestMethod algorithms do not have
|
||||
* parameters. Subclasses should override it if they have parameters.
|
||||
*
|
||||
* @param parent the parent element to append the parameters to
|
||||
* @param the namespace prefix to use
|
||||
* @throws MarshalException if the parameters cannot be marshalled
|
||||
*/
|
||||
void marshalParams(Element parent, String prefix)
|
||||
throws MarshalException
|
||||
{
|
||||
throw new MarshalException("no parameters should " +
|
||||
"be specified for the " +
|
||||
getMessageDigestAlgorithm() +
|
||||
" DigestMethod algorithm");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the MessageDigest standard algorithm name.
|
||||
*/
|
||||
abstract String getMessageDigestAlgorithm();
|
||||
|
||||
static final class SHA1 extends DOMDigestMethod {
|
||||
SHA1(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA1(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
public String getAlgorithm() {
|
||||
return DigestMethod.SHA1;
|
||||
}
|
||||
String getMessageDigestAlgorithm() {
|
||||
return "SHA-1";
|
||||
}
|
||||
}
|
||||
|
||||
static final class SHA224 extends DOMDigestMethod {
|
||||
SHA224(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA224(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
@Override
|
||||
public String getAlgorithm() {
|
||||
return SHA224;
|
||||
}
|
||||
@Override
|
||||
String getMessageDigestAlgorithm() {
|
||||
return "SHA-224";
|
||||
}
|
||||
}
|
||||
|
||||
static final class SHA256 extends DOMDigestMethod {
|
||||
SHA256(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA256(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
public String getAlgorithm() {
|
||||
return DigestMethod.SHA256;
|
||||
}
|
||||
String getMessageDigestAlgorithm() {
|
||||
return "SHA-256";
|
||||
}
|
||||
}
|
||||
|
||||
static final class SHA384 extends DOMDigestMethod {
|
||||
SHA384(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA384(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
public String getAlgorithm() {
|
||||
return SHA384;
|
||||
}
|
||||
String getMessageDigestAlgorithm() {
|
||||
return "SHA-384";
|
||||
}
|
||||
}
|
||||
|
||||
static final class SHA512 extends DOMDigestMethod {
|
||||
SHA512(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA512(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
public String getAlgorithm() {
|
||||
return DigestMethod.SHA512;
|
||||
}
|
||||
String getMessageDigestAlgorithm() {
|
||||
return "SHA-512";
|
||||
}
|
||||
}
|
||||
|
||||
static final class RIPEMD160 extends DOMDigestMethod {
|
||||
RIPEMD160(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
RIPEMD160(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
@Override
|
||||
public String getAlgorithm() {
|
||||
return DigestMethod.RIPEMD160;
|
||||
}
|
||||
@Override
|
||||
String getMessageDigestAlgorithm() {
|
||||
return "RIPEMD160";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMEnvelopedTransform.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
|
||||
|
||||
/**
|
||||
* DOM-based implementation of Enveloped Signature Transform.
|
||||
* (Uses Apache XML-Sec Transform implementation)
|
||||
*
|
||||
*/
|
||||
public final class DOMEnvelopedTransform extends ApacheTransform {
|
||||
|
||||
public void init(TransformParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
if (params != null) {
|
||||
throw new InvalidAlgorithmParameterException("params must be null");
|
||||
}
|
||||
}
|
||||
}
|
||||
169
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java
Normal file
169
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java
Normal file
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMExcC14NMethod.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec;
|
||||
import javax.xml.crypto.dsig.spec.ExcC14NParameterSpec;
|
||||
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import java.util.*;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer;
|
||||
import com.sun.org.apache.xml.internal.security.c14n.InvalidCanonicalizerException;
|
||||
|
||||
/**
|
||||
* DOM-based implementation of CanonicalizationMethod for Exclusive
|
||||
* Canonical XML algorithm (with or without comments).
|
||||
* Uses Apache XML-Sec Canonicalizer.
|
||||
*
|
||||
*/
|
||||
public final class DOMExcC14NMethod extends ApacheCanonicalizer {
|
||||
|
||||
public void init(TransformParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException
|
||||
{
|
||||
if (params != null) {
|
||||
if (!(params instanceof ExcC14NParameterSpec)) {
|
||||
throw new InvalidAlgorithmParameterException
|
||||
("params must be of type ExcC14NParameterSpec");
|
||||
}
|
||||
this.params = (C14NMethodParameterSpec)params;
|
||||
}
|
||||
}
|
||||
|
||||
public void init(XMLStructure parent, XMLCryptoContext context)
|
||||
throws InvalidAlgorithmParameterException
|
||||
{
|
||||
super.init(parent, context);
|
||||
Element paramsElem = DOMUtils.getFirstChildElement(transformElem);
|
||||
if (paramsElem == null) {
|
||||
this.params = null;
|
||||
this.inclusiveNamespaces = null;
|
||||
return;
|
||||
}
|
||||
unmarshalParams(paramsElem);
|
||||
}
|
||||
|
||||
private void unmarshalParams(Element paramsElem) {
|
||||
String prefixListAttr = paramsElem.getAttributeNS(null, "PrefixList");
|
||||
this.inclusiveNamespaces = prefixListAttr;
|
||||
int begin = 0;
|
||||
int end = prefixListAttr.indexOf(' ');
|
||||
List<String> prefixList = new ArrayList<>();
|
||||
while (end != -1) {
|
||||
prefixList.add(prefixListAttr.substring(begin, end));
|
||||
begin = end + 1;
|
||||
end = prefixListAttr.indexOf(' ', begin);
|
||||
}
|
||||
if (begin <= prefixListAttr.length()) {
|
||||
prefixList.add(prefixListAttr.substring(begin));
|
||||
}
|
||||
this.params = new ExcC14NParameterSpec(prefixList);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> getParameterSpecPrefixList(ExcC14NParameterSpec paramSpec) {
|
||||
return paramSpec.getPrefixList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
super.marshalParams(parent, context);
|
||||
AlgorithmParameterSpec spec = getParameterSpec();
|
||||
if (spec == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String prefix = DOMUtils.getNSPrefix(context,
|
||||
CanonicalizationMethod.EXCLUSIVE);
|
||||
Element eElem = DOMUtils.createElement(ownerDoc,
|
||||
"InclusiveNamespaces",
|
||||
CanonicalizationMethod.EXCLUSIVE,
|
||||
prefix);
|
||||
if (prefix == null || prefix.length() == 0) {
|
||||
eElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns",
|
||||
CanonicalizationMethod.EXCLUSIVE);
|
||||
} else {
|
||||
eElem.setAttributeNS("http://www.w3.org/2000/xmlns/",
|
||||
"xmlns:" + prefix,
|
||||
CanonicalizationMethod.EXCLUSIVE);
|
||||
}
|
||||
|
||||
ExcC14NParameterSpec params = (ExcC14NParameterSpec)spec;
|
||||
StringBuffer prefixListAttr = new StringBuffer("");
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> prefixList = getParameterSpecPrefixList(params);
|
||||
for (int i = 0, size = prefixList.size(); i < size; i++) {
|
||||
prefixListAttr.append(prefixList.get(i));
|
||||
if (i < size - 1) {
|
||||
prefixListAttr.append(" ");
|
||||
}
|
||||
}
|
||||
DOMUtils.setAttribute(eElem, "PrefixList", prefixListAttr.toString());
|
||||
this.inclusiveNamespaces = prefixListAttr.toString();
|
||||
transformElem.appendChild(eElem);
|
||||
}
|
||||
|
||||
public String getParamsNSURI() {
|
||||
return CanonicalizationMethod.EXCLUSIVE;
|
||||
}
|
||||
|
||||
public Data transform(Data data, XMLCryptoContext xc)
|
||||
throws TransformException
|
||||
{
|
||||
// ignore comments if dereferencing same-document URI that require
|
||||
// you to omit comments, even if the Transform says otherwise -
|
||||
// this is to be compliant with section 4.3.3.3 of W3C Rec.
|
||||
if (data instanceof DOMSubTreeData) {
|
||||
DOMSubTreeData subTree = (DOMSubTreeData)data;
|
||||
if (subTree.excludeComments()) {
|
||||
try {
|
||||
apacheCanonicalizer = Canonicalizer.getInstance
|
||||
(CanonicalizationMethod.EXCLUSIVE);
|
||||
boolean secVal = Utils.secureValidation(xc);
|
||||
apacheCanonicalizer.setSecureValidation(secVal);
|
||||
} catch (InvalidCanonicalizerException ice) {
|
||||
throw new TransformException
|
||||
("Couldn't find Canonicalizer for: " +
|
||||
CanonicalizationMethod.EXCLUSIVE + ": " +
|
||||
ice.getMessage(), ice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return canonicalize(data, xc);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,339 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMHMACSignatureMethod.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
import javax.xml.crypto.dsig.spec.HMACParameterSpec;
|
||||
import javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec;
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.Key;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SignatureException;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.SecretKey;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.jcp.xml.dsig.internal.MacOutputStream;
|
||||
|
||||
/**
|
||||
* DOM-based implementation of HMAC SignatureMethod.
|
||||
*
|
||||
*/
|
||||
public abstract class DOMHMACSignatureMethod extends AbstractDOMSignatureMethod {
|
||||
|
||||
private static final com.sun.org.slf4j.internal.Logger LOG =
|
||||
com.sun.org.slf4j.internal.LoggerFactory.getLogger(DOMHMACSignatureMethod.class);
|
||||
|
||||
// see RFC 4051 for these algorithm definitions
|
||||
static final String HMAC_SHA224 =
|
||||
"http://www.w3.org/2001/04/xmldsig-more#hmac-sha224";
|
||||
static final String HMAC_SHA256 =
|
||||
"http://www.w3.org/2001/04/xmldsig-more#hmac-sha256";
|
||||
static final String HMAC_SHA384 =
|
||||
"http://www.w3.org/2001/04/xmldsig-more#hmac-sha384";
|
||||
static final String HMAC_SHA512 =
|
||||
"http://www.w3.org/2001/04/xmldsig-more#hmac-sha512";
|
||||
static final String HMAC_RIPEMD160 =
|
||||
"http://www.w3.org/2001/04/xmldsig-more#hmac-ripemd160";
|
||||
|
||||
private Mac hmac;
|
||||
private int outputLength;
|
||||
private boolean outputLengthSet;
|
||||
private SignatureMethodParameterSpec params;
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMHMACSignatureMethod} with the specified params
|
||||
*
|
||||
* @param params algorithm-specific parameters (may be {@code null})
|
||||
* @throws InvalidAlgorithmParameterException if params are inappropriate
|
||||
*/
|
||||
DOMHMACSignatureMethod(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException
|
||||
{
|
||||
checkParams((SignatureMethodParameterSpec)params);
|
||||
this.params = (SignatureMethodParameterSpec)params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMHMACSignatureMethod} from an element.
|
||||
*
|
||||
* @param smElem a SignatureMethod element
|
||||
*/
|
||||
DOMHMACSignatureMethod(Element smElem) throws MarshalException {
|
||||
Element paramsElem = DOMUtils.getFirstChildElement(smElem);
|
||||
if (paramsElem != null) {
|
||||
params = unmarshalParams(paramsElem);
|
||||
}
|
||||
try {
|
||||
checkParams(params);
|
||||
} catch (InvalidAlgorithmParameterException iape) {
|
||||
throw new MarshalException(iape);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void checkParams(SignatureMethodParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException
|
||||
{
|
||||
if (params != null) {
|
||||
if (!(params instanceof HMACParameterSpec)) {
|
||||
throw new InvalidAlgorithmParameterException
|
||||
("params must be of type HMACParameterSpec");
|
||||
}
|
||||
outputLength = ((HMACParameterSpec)params).getOutputLength();
|
||||
outputLengthSet = true;
|
||||
LOG.debug("Setting outputLength from HMACParameterSpec to: {}", outputLength);
|
||||
}
|
||||
}
|
||||
|
||||
public final AlgorithmParameterSpec getParameterSpec() {
|
||||
return params;
|
||||
}
|
||||
|
||||
SignatureMethodParameterSpec unmarshalParams(Element paramsElem)
|
||||
throws MarshalException
|
||||
{
|
||||
outputLength = Integer.parseInt(paramsElem.getFirstChild().getNodeValue());
|
||||
outputLengthSet = true;
|
||||
LOG.debug("unmarshalled outputLength: {}", outputLength);
|
||||
return new HMACParameterSpec(outputLength);
|
||||
}
|
||||
|
||||
void marshalParams(Element parent, String prefix)
|
||||
throws MarshalException
|
||||
{
|
||||
Document ownerDoc = DOMUtils.getOwnerDocument(parent);
|
||||
Element hmacElem = DOMUtils.createElement(ownerDoc, "HMACOutputLength",
|
||||
XMLSignature.XMLNS, prefix);
|
||||
hmacElem.appendChild(ownerDoc.createTextNode
|
||||
(String.valueOf(outputLength)));
|
||||
|
||||
parent.appendChild(hmacElem);
|
||||
}
|
||||
|
||||
boolean verify(Key key, SignedInfo si, byte[] sig,
|
||||
XMLValidateContext context)
|
||||
throws InvalidKeyException, SignatureException, XMLSignatureException
|
||||
{
|
||||
if (key == null || si == null || sig == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (!(key instanceof SecretKey)) {
|
||||
throw new InvalidKeyException("key must be SecretKey");
|
||||
}
|
||||
if (hmac == null) {
|
||||
try {
|
||||
hmac = Mac.getInstance(getJCAAlgorithm());
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
throw new XMLSignatureException(nsae);
|
||||
}
|
||||
}
|
||||
if (outputLengthSet && outputLength < getDigestLength()) {
|
||||
throw new XMLSignatureException
|
||||
("HMACOutputLength must not be less than " + getDigestLength());
|
||||
}
|
||||
hmac.init(key);
|
||||
((DOMSignedInfo)si).canonicalize(context, new MacOutputStream(hmac));
|
||||
byte[] result = hmac.doFinal();
|
||||
|
||||
return MessageDigest.isEqual(sig, result);
|
||||
}
|
||||
|
||||
byte[] sign(Key key, SignedInfo si, XMLSignContext context)
|
||||
throws InvalidKeyException, XMLSignatureException
|
||||
{
|
||||
if (key == null || si == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (!(key instanceof SecretKey)) {
|
||||
throw new InvalidKeyException("key must be SecretKey");
|
||||
}
|
||||
if (hmac == null) {
|
||||
try {
|
||||
hmac = Mac.getInstance(getJCAAlgorithm());
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
throw new XMLSignatureException(nsae);
|
||||
}
|
||||
}
|
||||
if (outputLengthSet && outputLength < getDigestLength()) {
|
||||
throw new XMLSignatureException
|
||||
("HMACOutputLength must not be less than " + getDigestLength());
|
||||
}
|
||||
hmac.init(key);
|
||||
((DOMSignedInfo)si).canonicalize(context, new MacOutputStream(hmac));
|
||||
return hmac.doFinal();
|
||||
}
|
||||
|
||||
boolean paramsEqual(AlgorithmParameterSpec spec) {
|
||||
if (getParameterSpec() == spec) {
|
||||
return true;
|
||||
}
|
||||
if (!(spec instanceof HMACParameterSpec)) {
|
||||
return false;
|
||||
}
|
||||
HMACParameterSpec ospec = (HMACParameterSpec)spec;
|
||||
|
||||
return outputLength == ospec.getOutputLength();
|
||||
}
|
||||
|
||||
Type getAlgorithmType() {
|
||||
return Type.HMAC;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the output length of the hash/digest.
|
||||
*/
|
||||
abstract int getDigestLength();
|
||||
|
||||
static final class SHA1 extends DOMHMACSignatureMethod {
|
||||
SHA1(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA1(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
public String getAlgorithm() {
|
||||
return SignatureMethod.HMAC_SHA1;
|
||||
}
|
||||
String getJCAAlgorithm() {
|
||||
return "HmacSHA1";
|
||||
}
|
||||
int getDigestLength() {
|
||||
return 160;
|
||||
}
|
||||
}
|
||||
|
||||
static final class SHA224 extends DOMHMACSignatureMethod {
|
||||
SHA224(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA224(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
@Override
|
||||
public String getAlgorithm() {
|
||||
return HMAC_SHA224;
|
||||
}
|
||||
@Override
|
||||
String getJCAAlgorithm() {
|
||||
return "HmacSHA224";
|
||||
}
|
||||
@Override
|
||||
int getDigestLength() {
|
||||
return 224;
|
||||
}
|
||||
}
|
||||
|
||||
static final class SHA256 extends DOMHMACSignatureMethod {
|
||||
SHA256(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA256(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
public String getAlgorithm() {
|
||||
return HMAC_SHA256;
|
||||
}
|
||||
String getJCAAlgorithm() {
|
||||
return "HmacSHA256";
|
||||
}
|
||||
int getDigestLength() {
|
||||
return 256;
|
||||
}
|
||||
}
|
||||
|
||||
static final class SHA384 extends DOMHMACSignatureMethod {
|
||||
SHA384(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA384(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
public String getAlgorithm() {
|
||||
return HMAC_SHA384;
|
||||
}
|
||||
String getJCAAlgorithm() {
|
||||
return "HmacSHA384";
|
||||
}
|
||||
int getDigestLength() {
|
||||
return 384;
|
||||
}
|
||||
}
|
||||
|
||||
static final class SHA512 extends DOMHMACSignatureMethod {
|
||||
SHA512(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA512(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
public String getAlgorithm() {
|
||||
return HMAC_SHA512;
|
||||
}
|
||||
String getJCAAlgorithm() {
|
||||
return "HmacSHA512";
|
||||
}
|
||||
int getDigestLength() {
|
||||
return 512;
|
||||
}
|
||||
}
|
||||
|
||||
static final class RIPEMD160 extends DOMHMACSignatureMethod {
|
||||
RIPEMD160(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
RIPEMD160(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
@Override
|
||||
public String getAlgorithm() {
|
||||
return HMAC_RIPEMD160;
|
||||
}
|
||||
@Override
|
||||
String getJCAAlgorithm() {
|
||||
return "HMACRIPEMD160";
|
||||
}
|
||||
@Override
|
||||
int getDigestLength() {
|
||||
return 160;
|
||||
}
|
||||
}
|
||||
}
|
||||
250
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java
Normal file
250
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java
Normal file
@@ -0,0 +1,250 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMKeyInfo.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import java.security.Provider;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.crypto.MarshalException;
|
||||
import javax.xml.crypto.XMLCryptoContext;
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dsig.XMLSignature;
|
||||
import javax.xml.crypto.dsig.dom.DOMSignContext;
|
||||
import javax.xml.crypto.dsig.keyinfo.KeyInfo;
|
||||
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* DOM-based implementation of KeyInfo.
|
||||
*
|
||||
*/
|
||||
public final class DOMKeyInfo extends DOMStructure implements KeyInfo {
|
||||
|
||||
private final String id;
|
||||
private final List<XMLStructure> keyInfoTypes;
|
||||
|
||||
/**
|
||||
* A utility function to suppress casting warnings.
|
||||
* @param ki
|
||||
* @return the content of a KeyInfo Object
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<XMLStructure> getContent(KeyInfo ki) {
|
||||
return ki.getContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMKeyInfo}.
|
||||
*
|
||||
* @param content a list of one or more {@link XMLStructure}s representing
|
||||
* key information types. The list is defensively copied to protect
|
||||
* against subsequent modification.
|
||||
* @param id an ID attribute
|
||||
* @throws NullPointerException if {@code content} is {@code null}
|
||||
* @throws IllegalArgumentException if {@code content} is empty
|
||||
* @throws ClassCastException if {@code content} contains any entries
|
||||
* that are not of type {@link XMLStructure}
|
||||
*/
|
||||
public DOMKeyInfo(List<? extends XMLStructure> content, String id) {
|
||||
if (content == null) {
|
||||
throw new NullPointerException("content cannot be null");
|
||||
}
|
||||
this.keyInfoTypes =
|
||||
Collections.unmodifiableList(new ArrayList<>(content));
|
||||
if (this.keyInfoTypes.isEmpty()) {
|
||||
throw new IllegalArgumentException("content cannot be empty");
|
||||
}
|
||||
for (int i = 0, size = this.keyInfoTypes.size(); i < size; i++) {
|
||||
if (!(this.keyInfoTypes.get(i) instanceof XMLStructure)) {
|
||||
throw new ClassCastException
|
||||
("content["+i+"] is not a valid KeyInfo type");
|
||||
}
|
||||
}
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMKeyInfo} from XML.
|
||||
*
|
||||
* @param kiElem KeyInfo element
|
||||
*/
|
||||
public DOMKeyInfo(Element kiElem, XMLCryptoContext context,
|
||||
Provider provider)
|
||||
throws MarshalException
|
||||
{
|
||||
// get Id attribute, if specified
|
||||
Attr attr = kiElem.getAttributeNodeNS(null, "Id");
|
||||
if (attr != null) {
|
||||
id = attr.getValue();
|
||||
kiElem.setIdAttributeNode(attr, true);
|
||||
} else {
|
||||
id = null;
|
||||
}
|
||||
|
||||
// get all children nodes
|
||||
List<XMLStructure> content = new ArrayList<>();
|
||||
Node firstChild = kiElem.getFirstChild();
|
||||
if (firstChild == null) {
|
||||
throw new MarshalException("KeyInfo must contain at least one type");
|
||||
}
|
||||
while (firstChild != null) {
|
||||
if (firstChild.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Element childElem = (Element)firstChild;
|
||||
String localName = childElem.getLocalName();
|
||||
String namespace = childElem.getNamespaceURI();
|
||||
if ("X509Data".equals(localName) && XMLSignature.XMLNS.equals(namespace)) {
|
||||
content.add(new DOMX509Data(childElem));
|
||||
} else if ("KeyName".equals(localName) && XMLSignature.XMLNS.equals(namespace)) {
|
||||
content.add(new DOMKeyName(childElem));
|
||||
} else if ("KeyValue".equals(localName) && XMLSignature.XMLNS.equals(namespace)) {
|
||||
content.add(DOMKeyValue.unmarshal(childElem));
|
||||
} else if ("RetrievalMethod".equals(localName) && XMLSignature.XMLNS.equals(namespace)) {
|
||||
content.add(new DOMRetrievalMethod(childElem,
|
||||
context, provider));
|
||||
} else if ("PGPData".equals(localName) && XMLSignature.XMLNS.equals(namespace)) {
|
||||
content.add(new DOMPGPData(childElem));
|
||||
} else { //may be MgmtData, SPKIData or element from other namespace
|
||||
content.add(new javax.xml.crypto.dom.DOMStructure(childElem));
|
||||
}
|
||||
}
|
||||
firstChild = firstChild.getNextSibling();
|
||||
}
|
||||
keyInfoTypes = Collections.unmodifiableList(content);
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public List<XMLStructure> getContent() {
|
||||
return keyInfoTypes;
|
||||
}
|
||||
|
||||
public void marshal(XMLStructure parent, XMLCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
if (parent == null) {
|
||||
throw new NullPointerException("parent is null");
|
||||
}
|
||||
if (!(parent instanceof javax.xml.crypto.dom.DOMStructure)) {
|
||||
throw new ClassCastException("parent must be of type DOMStructure");
|
||||
}
|
||||
|
||||
Node pNode = ((javax.xml.crypto.dom.DOMStructure)parent).getNode();
|
||||
String dsPrefix = DOMUtils.getSignaturePrefix(context);
|
||||
Element kiElem = DOMUtils.createElement
|
||||
(DOMUtils.getOwnerDocument(pNode), "KeyInfo",
|
||||
XMLSignature.XMLNS, dsPrefix);
|
||||
if (dsPrefix == null || dsPrefix.length() == 0) {
|
||||
kiElem.setAttributeNS("http://www.w3.org/2000/xmlns/",
|
||||
"xmlns", XMLSignature.XMLNS);
|
||||
} else {
|
||||
kiElem.setAttributeNS("http://www.w3.org/2000/xmlns/",
|
||||
"xmlns:" + dsPrefix, XMLSignature.XMLNS);
|
||||
}
|
||||
|
||||
Node nextSibling = null;
|
||||
if (context instanceof DOMSignContext) {
|
||||
nextSibling = ((DOMSignContext)context).getNextSibling();
|
||||
}
|
||||
marshal(pNode, kiElem, nextSibling, dsPrefix, (DOMCryptoContext)context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(Node parent, String dsPrefix,
|
||||
DOMCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
marshal(parent, null, dsPrefix, context);
|
||||
}
|
||||
|
||||
public void marshal(Node parent, Node nextSibling, String dsPrefix,
|
||||
DOMCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
Document ownerDoc = DOMUtils.getOwnerDocument(parent);
|
||||
Element kiElem = DOMUtils.createElement(ownerDoc, "KeyInfo",
|
||||
XMLSignature.XMLNS, dsPrefix);
|
||||
marshal(parent, kiElem, nextSibling, dsPrefix, context);
|
||||
}
|
||||
|
||||
private void marshal(Node parent, Element kiElem, Node nextSibling,
|
||||
String dsPrefix, DOMCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
// create and append KeyInfoType elements
|
||||
for (XMLStructure kiType : keyInfoTypes) {
|
||||
if (kiType instanceof DOMStructure) {
|
||||
((DOMStructure)kiType).marshal(kiElem, dsPrefix, context);
|
||||
} else {
|
||||
DOMUtils.appendChild(kiElem,
|
||||
((javax.xml.crypto.dom.DOMStructure)kiType).getNode());
|
||||
}
|
||||
}
|
||||
|
||||
// append id attribute
|
||||
DOMUtils.setAttributeID(kiElem, "Id", id);
|
||||
|
||||
parent.insertBefore(kiElem, nextSibling);
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 17;
|
||||
if (id != null) {
|
||||
result = 31 * result + id.hashCode();
|
||||
}
|
||||
result = 31 * result + keyInfoTypes.hashCode();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
189
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java
Normal file
189
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java
Normal file
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMKeyInfoFactory.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.KeyException;
|
||||
import java.security.PublicKey;
|
||||
import java.security.interfaces.ECPublicKey;
|
||||
import java.security.interfaces.DSAPublicKey;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.crypto.MarshalException;
|
||||
import javax.xml.crypto.URIDereferencer;
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dsig.XMLSignature;
|
||||
import javax.xml.crypto.dsig.keyinfo.KeyInfo;
|
||||
import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory;
|
||||
import javax.xml.crypto.dsig.keyinfo.KeyName;
|
||||
import javax.xml.crypto.dsig.keyinfo.KeyValue;
|
||||
import javax.xml.crypto.dsig.keyinfo.PGPData;
|
||||
import javax.xml.crypto.dsig.keyinfo.RetrievalMethod;
|
||||
import javax.xml.crypto.dsig.keyinfo.X509Data;
|
||||
import javax.xml.crypto.dsig.keyinfo.X509IssuerSerial;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* DOM-based implementation of KeyInfoFactory.
|
||||
*
|
||||
*/
|
||||
public final class DOMKeyInfoFactory extends KeyInfoFactory {
|
||||
|
||||
public DOMKeyInfoFactory() { }
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public KeyInfo newKeyInfo(List content) {
|
||||
return newKeyInfo(content, null);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public KeyInfo newKeyInfo(List content, String id) {
|
||||
return new DOMKeyInfo(content, id);
|
||||
}
|
||||
|
||||
public KeyName newKeyName(String name) {
|
||||
return new DOMKeyName(name);
|
||||
}
|
||||
|
||||
public KeyValue newKeyValue(PublicKey key) throws KeyException {
|
||||
String algorithm = key.getAlgorithm();
|
||||
if ("DSA".equals(algorithm)) {
|
||||
return new DOMKeyValue.DSA((DSAPublicKey) key);
|
||||
} else if ("RSA".equals(algorithm)) {
|
||||
return new DOMKeyValue.RSA((RSAPublicKey) key);
|
||||
} else if ("EC".equals(algorithm)) {
|
||||
return new DOMKeyValue.EC((ECPublicKey) key);
|
||||
} else {
|
||||
throw new KeyException("unsupported key algorithm: " + algorithm);
|
||||
}
|
||||
}
|
||||
|
||||
public PGPData newPGPData(byte[] keyId) {
|
||||
return newPGPData(keyId, null, null);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public PGPData newPGPData(byte[] keyId, byte[] keyPacket, List other) {
|
||||
return new DOMPGPData(keyId, keyPacket, other);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public PGPData newPGPData(byte[] keyPacket, List other) {
|
||||
return new DOMPGPData(keyPacket, other);
|
||||
}
|
||||
|
||||
public RetrievalMethod newRetrievalMethod(String uri) {
|
||||
return newRetrievalMethod(uri, null, null);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public RetrievalMethod newRetrievalMethod(String uri, String type,
|
||||
List transforms) {
|
||||
if (uri == null) {
|
||||
throw new NullPointerException("uri must not be null");
|
||||
}
|
||||
return new DOMRetrievalMethod(uri, type, transforms);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
public X509Data newX509Data(List content) {
|
||||
return new DOMX509Data(content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public X509IssuerSerial newX509IssuerSerial(String issuerName,
|
||||
BigInteger serialNumber) {
|
||||
return new DOMX509IssuerSerial(issuerName, serialNumber);
|
||||
}
|
||||
|
||||
public boolean isFeatureSupported(String feature) {
|
||||
if (feature == null) {
|
||||
throw new NullPointerException();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public URIDereferencer getURIDereferencer() {
|
||||
return DOMURIDereferencer.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyInfo unmarshalKeyInfo(XMLStructure xmlStructure)
|
||||
throws MarshalException {
|
||||
if (xmlStructure == null) {
|
||||
throw new NullPointerException("xmlStructure cannot be null");
|
||||
}
|
||||
if (!(xmlStructure instanceof javax.xml.crypto.dom.DOMStructure)) {
|
||||
throw new ClassCastException("xmlStructure must be of type DOMStructure");
|
||||
}
|
||||
Node node =
|
||||
((javax.xml.crypto.dom.DOMStructure) xmlStructure).getNode();
|
||||
node.normalize();
|
||||
|
||||
Element element = null;
|
||||
if (node.getNodeType() == Node.DOCUMENT_NODE) {
|
||||
element = ((Document) node).getDocumentElement();
|
||||
} else if (node.getNodeType() == Node.ELEMENT_NODE) {
|
||||
element = (Element) node;
|
||||
} else {
|
||||
throw new MarshalException
|
||||
("xmlStructure does not contain a proper Node");
|
||||
}
|
||||
|
||||
// check tag
|
||||
String tag = element.getLocalName();
|
||||
String namespace = element.getNamespaceURI();
|
||||
if (tag == null || namespace == null) {
|
||||
throw new MarshalException("Document implementation must " +
|
||||
"support DOM Level 2 and be namespace aware");
|
||||
}
|
||||
if ("KeyInfo".equals(tag) && XMLSignature.XMLNS.equals(namespace)) {
|
||||
try {
|
||||
return new DOMKeyInfo(element, new UnmarshalContext(), getProvider());
|
||||
} catch (MarshalException me) {
|
||||
throw me;
|
||||
} catch (Exception e) {
|
||||
throw new MarshalException(e);
|
||||
}
|
||||
} else {
|
||||
throw new MarshalException("Invalid KeyInfo tag: " + namespace + ":" + tag);
|
||||
}
|
||||
}
|
||||
|
||||
private static class UnmarshalContext extends DOMCryptoContext {
|
||||
UnmarshalContext() {}
|
||||
}
|
||||
|
||||
}
|
||||
105
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMKeyName.java
Normal file
105
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMKeyName.java
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMKeyName.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import javax.xml.crypto.MarshalException;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dsig.XMLSignature;
|
||||
import javax.xml.crypto.dsig.keyinfo.KeyName;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* DOM-based implementation of KeyName.
|
||||
*
|
||||
*/
|
||||
public final class DOMKeyName extends DOMStructure implements KeyName {
|
||||
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMKeyName}.
|
||||
*
|
||||
* @param name the name of the key identifier
|
||||
* @throws NullPointerException if {@code name} is null
|
||||
*/
|
||||
public DOMKeyName(String name) {
|
||||
if (name == null) {
|
||||
throw new NullPointerException("name cannot be null");
|
||||
}
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMKeyName} from a KeyName element.
|
||||
*
|
||||
* @param knElem a KeyName element
|
||||
*/
|
||||
public DOMKeyName(Element knElem) {
|
||||
name = knElem.getFirstChild().getNodeValue();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
Document ownerDoc = DOMUtils.getOwnerDocument(parent);
|
||||
// prepend namespace prefix, if necessary
|
||||
Element knElem = DOMUtils.createElement(ownerDoc, "KeyName",
|
||||
XMLSignature.XMLNS, dsPrefix);
|
||||
knElem.appendChild(ownerDoc.createTextNode(name));
|
||||
parent.appendChild(knElem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof KeyName)) {
|
||||
return false;
|
||||
}
|
||||
KeyName okn = (KeyName)obj;
|
||||
return name.equals(okn.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 17;
|
||||
result = 31 * result + name.hashCode();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
625
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java
Normal file
625
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java
Normal file
@@ -0,0 +1,625 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMKeyValue.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.security.KeyException;
|
||||
import java.security.KeyFactory;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.PublicKey;
|
||||
import java.security.interfaces.DSAParams;
|
||||
import java.security.interfaces.DSAPublicKey;
|
||||
import java.security.interfaces.ECPublicKey;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
import java.security.spec.DSAPublicKeySpec;
|
||||
import java.security.spec.ECField;
|
||||
import java.security.spec.ECFieldFp;
|
||||
import java.security.spec.ECParameterSpec;
|
||||
import java.security.spec.ECPoint;
|
||||
import java.security.spec.ECPublicKeySpec;
|
||||
import java.security.spec.EllipticCurve;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.security.spec.KeySpec;
|
||||
import java.security.spec.RSAPublicKeySpec;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.xml.crypto.MarshalException;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dsig.XMLSignature;
|
||||
import javax.xml.crypto.dsig.keyinfo.KeyValue;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* DOM-based implementation of KeyValue.
|
||||
*
|
||||
*/
|
||||
public abstract class DOMKeyValue<K extends PublicKey> extends DOMStructure implements KeyValue {
|
||||
|
||||
private static final String XMLDSIG_11_XMLNS
|
||||
= "http://www.w3.org/2009/xmldsig11#";
|
||||
private final K publicKey;
|
||||
|
||||
public DOMKeyValue(K key) throws KeyException {
|
||||
if (key == null) {
|
||||
throw new NullPointerException("key cannot be null");
|
||||
}
|
||||
this.publicKey = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMKeyValue} from an element.
|
||||
*
|
||||
* @param kvtElem a KeyValue child element
|
||||
*/
|
||||
public DOMKeyValue(Element kvtElem) throws MarshalException {
|
||||
this.publicKey = unmarshalKeyValue(kvtElem);
|
||||
}
|
||||
|
||||
static KeyValue unmarshal(Element kvElem) throws MarshalException {
|
||||
Element kvtElem = DOMUtils.getFirstChildElement(kvElem);
|
||||
if (kvtElem == null) {
|
||||
throw new MarshalException("KeyValue must contain at least one type");
|
||||
}
|
||||
|
||||
String namespace = kvtElem.getNamespaceURI();
|
||||
if (kvtElem.getLocalName().equals("DSAKeyValue") && XMLSignature.XMLNS.equals(namespace)) {
|
||||
return new DSA(kvtElem);
|
||||
} else if (kvtElem.getLocalName().equals("RSAKeyValue") && XMLSignature.XMLNS.equals(namespace)) {
|
||||
return new RSA(kvtElem);
|
||||
} else if (kvtElem.getLocalName().equals("ECKeyValue") && XMLDSIG_11_XMLNS.equals(namespace)) {
|
||||
return new EC(kvtElem);
|
||||
} else {
|
||||
return new Unknown(kvtElem);
|
||||
}
|
||||
}
|
||||
|
||||
public PublicKey getPublicKey() throws KeyException {
|
||||
if (publicKey == null) {
|
||||
throw new KeyException("can't convert KeyValue to PublicKey");
|
||||
} else {
|
||||
return publicKey;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
Document ownerDoc = DOMUtils.getOwnerDocument(parent);
|
||||
|
||||
// create KeyValue element
|
||||
Element kvElem = DOMUtils.createElement(ownerDoc, "KeyValue",
|
||||
XMLSignature.XMLNS, dsPrefix);
|
||||
marshalPublicKey(kvElem, ownerDoc, dsPrefix, context);
|
||||
|
||||
parent.appendChild(kvElem);
|
||||
}
|
||||
|
||||
abstract void marshalPublicKey(Node parent, Document doc, String dsPrefix,
|
||||
DOMCryptoContext context) throws MarshalException;
|
||||
|
||||
abstract K unmarshalKeyValue(Element kvtElem)
|
||||
throws MarshalException;
|
||||
|
||||
private static PublicKey generatePublicKey(KeyFactory kf, KeySpec keyspec) {
|
||||
try {
|
||||
return kf.generatePublic(keyspec);
|
||||
} catch (InvalidKeySpecException e) {
|
||||
//@@@ should dump exception to LOG
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof KeyValue)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
KeyValue kv = (KeyValue)obj;
|
||||
if (publicKey == null ) {
|
||||
if (kv.getPublicKey() != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!publicKey.equals(kv.getPublicKey())) {
|
||||
return false;
|
||||
}
|
||||
} catch (KeyException ke) {
|
||||
// no practical way to determine if the keys are equal
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static BigInteger decode(Element elem) throws MarshalException {
|
||||
try {
|
||||
String base64str = elem.getFirstChild().getNodeValue();
|
||||
return new BigInteger(1, XMLUtils.decode(base64str));
|
||||
} catch (Exception ex) {
|
||||
throw new MarshalException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 17;
|
||||
if (publicKey != null) {
|
||||
result = 31 * result + publicKey.hashCode();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static final class RSA extends DOMKeyValue<RSAPublicKey> {
|
||||
// RSAKeyValue CryptoBinaries
|
||||
private DOMCryptoBinary modulus, exponent;
|
||||
private KeyFactory rsakf;
|
||||
|
||||
RSA(RSAPublicKey key) throws KeyException {
|
||||
super(key);
|
||||
RSAPublicKey rkey = key;
|
||||
exponent = new DOMCryptoBinary(rkey.getPublicExponent());
|
||||
modulus = new DOMCryptoBinary(rkey.getModulus());
|
||||
}
|
||||
|
||||
RSA(Element elem) throws MarshalException {
|
||||
super(elem);
|
||||
}
|
||||
|
||||
void marshalPublicKey(Node parent, Document doc, String dsPrefix,
|
||||
DOMCryptoContext context) throws MarshalException {
|
||||
Element rsaElem = DOMUtils.createElement(doc, "RSAKeyValue",
|
||||
XMLSignature.XMLNS,
|
||||
dsPrefix);
|
||||
Element modulusElem = DOMUtils.createElement(doc, "Modulus",
|
||||
XMLSignature.XMLNS,
|
||||
dsPrefix);
|
||||
Element exponentElem = DOMUtils.createElement(doc, "Exponent",
|
||||
XMLSignature.XMLNS,
|
||||
dsPrefix);
|
||||
modulus.marshal(modulusElem, dsPrefix, context);
|
||||
exponent.marshal(exponentElem, dsPrefix, context);
|
||||
rsaElem.appendChild(modulusElem);
|
||||
rsaElem.appendChild(exponentElem);
|
||||
parent.appendChild(rsaElem);
|
||||
}
|
||||
|
||||
@Override
|
||||
RSAPublicKey unmarshalKeyValue(Element kvtElem)
|
||||
throws MarshalException
|
||||
{
|
||||
if (rsakf == null) {
|
||||
try {
|
||||
rsakf = KeyFactory.getInstance("RSA");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new RuntimeException
|
||||
("unable to create RSA KeyFactory: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
Element modulusElem = DOMUtils.getFirstChildElement(kvtElem,
|
||||
"Modulus",
|
||||
XMLSignature.XMLNS);
|
||||
BigInteger modulus = decode(modulusElem);
|
||||
Element exponentElem = DOMUtils.getNextSiblingElement(modulusElem,
|
||||
"Exponent",
|
||||
XMLSignature.XMLNS);
|
||||
BigInteger exponent = decode(exponentElem);
|
||||
RSAPublicKeySpec spec = new RSAPublicKeySpec(modulus, exponent);
|
||||
return (RSAPublicKey) generatePublicKey(rsakf, spec);
|
||||
}
|
||||
}
|
||||
|
||||
static final class DSA extends DOMKeyValue<DSAPublicKey> {
|
||||
// DSAKeyValue CryptoBinaries
|
||||
private DOMCryptoBinary p, q, g, y; //, seed, pgen;
|
||||
private KeyFactory dsakf;
|
||||
|
||||
DSA(DSAPublicKey key) throws KeyException {
|
||||
super(key);
|
||||
DSAPublicKey dkey = key;
|
||||
DSAParams params = dkey.getParams();
|
||||
p = new DOMCryptoBinary(params.getP());
|
||||
q = new DOMCryptoBinary(params.getQ());
|
||||
g = new DOMCryptoBinary(params.getG());
|
||||
y = new DOMCryptoBinary(dkey.getY());
|
||||
}
|
||||
|
||||
DSA(Element elem) throws MarshalException {
|
||||
super(elem);
|
||||
}
|
||||
|
||||
@Override
|
||||
void marshalPublicKey(Node parent, Document doc, String dsPrefix,
|
||||
DOMCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
Element dsaElem = DOMUtils.createElement(doc, "DSAKeyValue",
|
||||
XMLSignature.XMLNS,
|
||||
dsPrefix);
|
||||
// parameters J, Seed & PgenCounter are not included
|
||||
Element pElem = DOMUtils.createElement(doc, "P", XMLSignature.XMLNS,
|
||||
dsPrefix);
|
||||
Element qElem = DOMUtils.createElement(doc, "Q", XMLSignature.XMLNS,
|
||||
dsPrefix);
|
||||
Element gElem = DOMUtils.createElement(doc, "G", XMLSignature.XMLNS,
|
||||
dsPrefix);
|
||||
Element yElem = DOMUtils.createElement(doc, "Y", XMLSignature.XMLNS,
|
||||
dsPrefix);
|
||||
p.marshal(pElem, dsPrefix, context);
|
||||
q.marshal(qElem, dsPrefix, context);
|
||||
g.marshal(gElem, dsPrefix, context);
|
||||
y.marshal(yElem, dsPrefix, context);
|
||||
dsaElem.appendChild(pElem);
|
||||
dsaElem.appendChild(qElem);
|
||||
dsaElem.appendChild(gElem);
|
||||
dsaElem.appendChild(yElem);
|
||||
parent.appendChild(dsaElem);
|
||||
}
|
||||
|
||||
@Override
|
||||
DSAPublicKey unmarshalKeyValue(Element kvtElem)
|
||||
throws MarshalException
|
||||
{
|
||||
if (dsakf == null) {
|
||||
try {
|
||||
dsakf = KeyFactory.getInstance("DSA");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new RuntimeException
|
||||
("unable to create DSA KeyFactory: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
Element curElem = DOMUtils.getFirstChildElement(kvtElem);
|
||||
if (curElem == null) {
|
||||
throw new MarshalException("KeyValue must contain at least one type");
|
||||
}
|
||||
// check for P and Q
|
||||
BigInteger p = null;
|
||||
BigInteger q = null;
|
||||
if (curElem.getLocalName().equals("P") && XMLSignature.XMLNS.equals(curElem.getNamespaceURI())) {
|
||||
p = decode(curElem);
|
||||
curElem = DOMUtils.getNextSiblingElement(curElem, "Q", XMLSignature.XMLNS);
|
||||
q = decode(curElem);
|
||||
curElem = DOMUtils.getNextSiblingElement(curElem);
|
||||
}
|
||||
BigInteger g = null;
|
||||
if (curElem != null
|
||||
&& curElem.getLocalName().equals("G") && XMLSignature.XMLNS.equals(curElem.getNamespaceURI())) {
|
||||
g = decode(curElem);
|
||||
curElem = DOMUtils.getNextSiblingElement(curElem, "Y", XMLSignature.XMLNS);
|
||||
}
|
||||
BigInteger y = null;
|
||||
if (curElem != null) {
|
||||
y = decode(curElem);
|
||||
curElem = DOMUtils.getNextSiblingElement(curElem);
|
||||
}
|
||||
//if (curElem != null && curElem.getLocalName().equals("J")) {
|
||||
//j = new DOMCryptoBinary(curElem.getFirstChild());
|
||||
// curElem = DOMUtils.getNextSiblingElement(curElem);
|
||||
//}
|
||||
//@@@ do we care about j, pgenCounter or seed?
|
||||
DSAPublicKeySpec spec = new DSAPublicKeySpec(y, p, q, g);
|
||||
return (DSAPublicKey) generatePublicKey(dsakf, spec);
|
||||
}
|
||||
}
|
||||
|
||||
static final class EC extends DOMKeyValue<ECPublicKey> {
|
||||
// ECKeyValue CryptoBinaries
|
||||
private byte[] ecPublicKey;
|
||||
private KeyFactory eckf;
|
||||
private ECParameterSpec ecParams;
|
||||
|
||||
/* Supported curve, secp256r1 */
|
||||
private static final Curve SECP256R1 = initializeCurve(
|
||||
"secp256r1 [NIST P-256, X9.62 prime256v1]",
|
||||
"1.2.840.10045.3.1.7",
|
||||
"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF",
|
||||
"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC",
|
||||
"5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B",
|
||||
"6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296",
|
||||
"4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5",
|
||||
"FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551",
|
||||
1
|
||||
);
|
||||
|
||||
/* Supported curve secp384r1 */
|
||||
private static final Curve SECP384R1 = initializeCurve(
|
||||
"secp384r1 [NIST P-384]",
|
||||
"1.3.132.0.34",
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF",
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC",
|
||||
"B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF",
|
||||
"AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7",
|
||||
"3617DE4A96262C6F5D9E98BF9292DC29F8F41DBD289A147CE9DA3113B5F0B8C00A60B1CE1D7E819D7A431D7C90EA0E5F",
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973",
|
||||
1
|
||||
);
|
||||
|
||||
/* Supported curve secp521r1 */
|
||||
private static final Curve SECP521R1 = initializeCurve(
|
||||
"secp521r1 [NIST P-521]",
|
||||
"1.3.132.0.35",
|
||||
"01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
||||
"01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC",
|
||||
"0051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00",
|
||||
"00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66",
|
||||
"011839296A789A3BC0045C8A5FB42C7D1BD998F54449579B446817AFBD17273E662C97EE72995EF42640C550B9013FAD0761353C7086A272C24088BE94769FD16650",
|
||||
"01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409",
|
||||
1
|
||||
);
|
||||
|
||||
private static Curve initializeCurve(String name, String oid,
|
||||
String sfield, String a, String b,
|
||||
String x, String y, String n, int h) {
|
||||
BigInteger p = bigInt(sfield);
|
||||
ECField field = new ECFieldFp(p);
|
||||
EllipticCurve curve = new EllipticCurve(field, bigInt(a),
|
||||
bigInt(b));
|
||||
ECPoint g = new ECPoint(bigInt(x), bigInt(y));
|
||||
return new Curve(name, oid, curve, g, bigInt(n), h);
|
||||
}
|
||||
|
||||
EC(ECPublicKey ecKey) throws KeyException {
|
||||
super(ecKey);
|
||||
ECPoint ecPoint = ecKey.getW();
|
||||
ecParams = ecKey.getParams();
|
||||
ecPublicKey = encodePoint(ecPoint, ecParams.getCurve());
|
||||
}
|
||||
|
||||
EC(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
|
||||
private static ECPoint decodePoint(byte[] data, EllipticCurve curve)
|
||||
throws IOException {
|
||||
if (data.length == 0 || data[0] != 4) {
|
||||
throw new IOException("Only uncompressed point format " +
|
||||
"supported");
|
||||
}
|
||||
// Per ANSI X9.62, an encoded point is a 1 byte type followed by
|
||||
// ceiling(LOG base 2 field-size / 8) bytes of x and the same of y.
|
||||
int n = (data.length - 1) / 2;
|
||||
if (n != (curve.getField().getFieldSize() + 7) >> 3) {
|
||||
throw new IOException("Point does not match field size");
|
||||
}
|
||||
|
||||
byte[] xb = Arrays.copyOfRange(data, 1, 1 + n);
|
||||
byte[] yb = Arrays.copyOfRange(data, n + 1, n + 1 + n);
|
||||
|
||||
return new ECPoint(new BigInteger(1, xb), new BigInteger(1, yb));
|
||||
}
|
||||
|
||||
private static byte[] encodePoint(ECPoint point, EllipticCurve curve) {
|
||||
// get field size in bytes (rounding up)
|
||||
int n = (curve.getField().getFieldSize() + 7) >> 3;
|
||||
byte[] xb = trimZeroes(point.getAffineX().toByteArray());
|
||||
byte[] yb = trimZeroes(point.getAffineY().toByteArray());
|
||||
if (xb.length > n || yb.length > n) {
|
||||
throw new RuntimeException("Point coordinates do not " +
|
||||
"match field size");
|
||||
}
|
||||
byte[] b = new byte[1 + (n << 1)];
|
||||
b[0] = 4; // uncompressed
|
||||
System.arraycopy(xb, 0, b, n - xb.length + 1, xb.length);
|
||||
System.arraycopy(yb, 0, b, b.length - yb.length, yb.length);
|
||||
return b;
|
||||
}
|
||||
|
||||
private static byte[] trimZeroes(byte[] b) {
|
||||
int i = 0;
|
||||
while (i < b.length - 1 && b[i] == 0) {
|
||||
i++;
|
||||
}
|
||||
if (i == 0) {
|
||||
return b;
|
||||
}
|
||||
return Arrays.copyOfRange(b, i, b.length);
|
||||
}
|
||||
|
||||
private static String getCurveOid(ECParameterSpec params) {
|
||||
// Check that the params represent one of the supported
|
||||
// curves. If there is a match, return the object identifier
|
||||
// of the curve.
|
||||
Curve match;
|
||||
if (matchCurve(params, SECP256R1)) {
|
||||
match = SECP256R1;
|
||||
} else if (matchCurve(params, SECP384R1)) {
|
||||
match = SECP384R1;
|
||||
} else if (matchCurve(params, SECP521R1)) {
|
||||
match = SECP521R1;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return match.getObjectId();
|
||||
}
|
||||
|
||||
private static boolean matchCurve(ECParameterSpec params, Curve curve) {
|
||||
int fieldSize = params.getCurve().getField().getFieldSize();
|
||||
if (curve.getCurve().getField().getFieldSize() == fieldSize
|
||||
&& curve.getCurve().equals(params.getCurve())
|
||||
&& curve.getGenerator().equals(params.getGenerator())
|
||||
&& curve.getOrder().equals(params.getOrder())
|
||||
&& curve.getCofactor() == params.getCofactor()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void marshalPublicKey(Node parent, Document doc, String dsPrefix,
|
||||
DOMCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
String prefix = DOMUtils.getNSPrefix(context, XMLDSIG_11_XMLNS);
|
||||
Element ecKeyValueElem = DOMUtils.createElement(doc, "ECKeyValue",
|
||||
XMLDSIG_11_XMLNS,
|
||||
prefix);
|
||||
Element namedCurveElem = DOMUtils.createElement(doc, "NamedCurve",
|
||||
XMLDSIG_11_XMLNS,
|
||||
prefix);
|
||||
Element publicKeyElem = DOMUtils.createElement(doc, "PublicKey",
|
||||
XMLDSIG_11_XMLNS,
|
||||
prefix);
|
||||
String oid = getCurveOid(ecParams);
|
||||
if (oid == null) {
|
||||
throw new MarshalException("Invalid ECParameterSpec");
|
||||
}
|
||||
DOMUtils.setAttribute(namedCurveElem, "URI", "urn:oid:" + oid);
|
||||
String qname = prefix == null || prefix.length() == 0
|
||||
? "xmlns" : "xmlns:" + prefix;
|
||||
namedCurveElem.setAttributeNS("http://www.w3.org/2000/xmlns/",
|
||||
qname, XMLDSIG_11_XMLNS);
|
||||
ecKeyValueElem.appendChild(namedCurveElem);
|
||||
String encoded = XMLUtils.encodeToString(ecPublicKey);
|
||||
publicKeyElem.appendChild
|
||||
(DOMUtils.getOwnerDocument(publicKeyElem).createTextNode(encoded));
|
||||
ecKeyValueElem.appendChild(publicKeyElem);
|
||||
parent.appendChild(ecKeyValueElem);
|
||||
}
|
||||
|
||||
@Override
|
||||
ECPublicKey unmarshalKeyValue(Element kvtElem)
|
||||
throws MarshalException
|
||||
{
|
||||
if (eckf == null) {
|
||||
try {
|
||||
eckf = KeyFactory.getInstance("EC");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new RuntimeException
|
||||
("unable to create EC KeyFactory: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
ECParameterSpec ecParams = null;
|
||||
Element curElem = DOMUtils.getFirstChildElement(kvtElem);
|
||||
if (curElem == null) {
|
||||
throw new MarshalException("KeyValue must contain at least one type");
|
||||
}
|
||||
|
||||
if (curElem.getLocalName().equals("ECParameters")
|
||||
&& XMLDSIG_11_XMLNS.equals(curElem.getNamespaceURI())) {
|
||||
throw new UnsupportedOperationException
|
||||
("ECParameters not supported");
|
||||
} else if (curElem.getLocalName().equals("NamedCurve")
|
||||
&& XMLDSIG_11_XMLNS.equals(curElem.getNamespaceURI())) {
|
||||
String uri = DOMUtils.getAttributeValue(curElem, "URI");
|
||||
// strip off "urn:oid"
|
||||
if (uri.startsWith("urn:oid:")) {
|
||||
String oid = uri.substring("urn:oid:".length());
|
||||
ecParams = getECParameterSpec(oid);
|
||||
if (ecParams == null) {
|
||||
throw new MarshalException("Invalid curve OID");
|
||||
}
|
||||
} else {
|
||||
throw new MarshalException("Invalid NamedCurve URI");
|
||||
}
|
||||
} else {
|
||||
throw new MarshalException("Invalid ECKeyValue");
|
||||
}
|
||||
curElem = DOMUtils.getNextSiblingElement(curElem, "PublicKey", XMLDSIG_11_XMLNS);
|
||||
ECPoint ecPoint = null;
|
||||
|
||||
try {
|
||||
String content = XMLUtils.getFullTextChildrenFromNode(curElem);
|
||||
ecPoint = decodePoint(XMLUtils.decode(content),
|
||||
ecParams.getCurve());
|
||||
} catch (IOException ioe) {
|
||||
throw new MarshalException("Invalid EC Point", ioe);
|
||||
}
|
||||
|
||||
ECPublicKeySpec spec = new ECPublicKeySpec(ecPoint, ecParams);
|
||||
return (ECPublicKey) generatePublicKey(eckf, spec);
|
||||
}
|
||||
|
||||
private static ECParameterSpec getECParameterSpec(String oid) {
|
||||
if (oid.equals(SECP256R1.getObjectId())) {
|
||||
return SECP256R1;
|
||||
} else if (oid.equals(SECP384R1.getObjectId())) {
|
||||
return SECP384R1;
|
||||
} else if (oid.equals(SECP521R1.getObjectId())) {
|
||||
return SECP521R1;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static final class Curve extends ECParameterSpec {
|
||||
private final String name;
|
||||
private final String oid;
|
||||
|
||||
Curve(String name, String oid, EllipticCurve curve,
|
||||
ECPoint g, BigInteger n, int h) {
|
||||
super(curve, g, n, h);
|
||||
this.name = name;
|
||||
this.oid = oid;
|
||||
}
|
||||
|
||||
private String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
private String getObjectId() {
|
||||
return oid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static BigInteger bigInt(String s) {
|
||||
return new BigInteger(s, 16);
|
||||
}
|
||||
|
||||
static final class Unknown extends DOMKeyValue<PublicKey> {
|
||||
private javax.xml.crypto.dom.DOMStructure externalPublicKey;
|
||||
Unknown(Element elem) throws MarshalException {
|
||||
super(elem);
|
||||
}
|
||||
|
||||
@Override
|
||||
PublicKey unmarshalKeyValue(Element kvElem) throws MarshalException {
|
||||
externalPublicKey = new javax.xml.crypto.dom.DOMStructure(kvElem);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
void marshalPublicKey(Node parent, Document doc, String dsPrefix,
|
||||
DOMCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
parent.appendChild(externalPublicKey.getNode());
|
||||
}
|
||||
}
|
||||
}
|
||||
178
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMManifest.java
Normal file
178
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMManifest.java
Normal file
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMManifest.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
|
||||
import java.security.Provider;
|
||||
import java.util.*;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* DOM-based implementation of Manifest.
|
||||
*
|
||||
*/
|
||||
public final class DOMManifest extends DOMStructure implements Manifest {
|
||||
|
||||
private final List<Reference> references;
|
||||
private final String id;
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMManifest} containing the specified
|
||||
* list of {@link Reference}s and optional id.
|
||||
*
|
||||
* @param references a list of one or more {@code Reference}s. The list
|
||||
* is defensively copied to protect against subsequent modification.
|
||||
* @param id the id (may be {@code null}
|
||||
* @throws NullPointerException if {@code references} is
|
||||
* {@code null}
|
||||
* @throws IllegalArgumentException if {@code references} is empty
|
||||
* @throws ClassCastException if {@code references} contains any
|
||||
* entries that are not of type {@link Reference}
|
||||
*/
|
||||
public DOMManifest(List<? extends Reference> references, String id) {
|
||||
if (references == null) {
|
||||
throw new NullPointerException("references cannot be null");
|
||||
}
|
||||
this.references =
|
||||
Collections.unmodifiableList(new ArrayList<>(references));
|
||||
if (this.references.isEmpty()) {
|
||||
throw new IllegalArgumentException("list of references must " +
|
||||
"contain at least one entry");
|
||||
}
|
||||
for (int i = 0, size = this.references.size(); i < size; i++) {
|
||||
if (!(this.references.get(i) instanceof Reference)) {
|
||||
throw new ClassCastException
|
||||
("references["+i+"] is not a valid type");
|
||||
}
|
||||
}
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMManifest} from an element.
|
||||
*
|
||||
* @param manElem a Manifest element
|
||||
*/
|
||||
public DOMManifest(Element manElem, XMLCryptoContext context,
|
||||
Provider provider)
|
||||
throws MarshalException
|
||||
{
|
||||
this.id = DOMUtils.getIdAttributeValue(manElem, "Id");
|
||||
|
||||
boolean secVal = Utils.secureValidation(context);
|
||||
|
||||
Element refElem = DOMUtils.getFirstChildElement(manElem, "Reference", XMLSignature.XMLNS);
|
||||
List<Reference> refs = new ArrayList<>();
|
||||
refs.add(new DOMReference(refElem, context, provider));
|
||||
|
||||
refElem = DOMUtils.getNextSiblingElement(refElem);
|
||||
while (refElem != null) {
|
||||
String localName = refElem.getLocalName();
|
||||
String namespace = refElem.getNamespaceURI();
|
||||
if (!"Reference".equals(localName) || !XMLSignature.XMLNS.equals(namespace)) {
|
||||
throw new MarshalException("Invalid element name: " +
|
||||
namespace + ":" + localName + ", expected Reference");
|
||||
}
|
||||
refs.add(new DOMReference(refElem, context, provider));
|
||||
if (secVal && Policy.restrictNumReferences(refs.size())) {
|
||||
String error = "A maxiumum of " + Policy.maxReferences()
|
||||
+ " references per Manifest are allowed when"
|
||||
+ " secure validation is enabled";
|
||||
throw new MarshalException(error);
|
||||
}
|
||||
refElem = DOMUtils.getNextSiblingElement(refElem);
|
||||
}
|
||||
this.references = Collections.unmodifiableList(refs);
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<Reference> getManifestReferences(Manifest mf) {
|
||||
return mf.getReferences();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Reference> getReferences() {
|
||||
return references;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
Document ownerDoc = DOMUtils.getOwnerDocument(parent);
|
||||
Element manElem = DOMUtils.createElement(ownerDoc, "Manifest",
|
||||
XMLSignature.XMLNS, dsPrefix);
|
||||
|
||||
DOMUtils.setAttributeID(manElem, "Id", id);
|
||||
|
||||
// add references
|
||||
for (Reference ref : references) {
|
||||
((DOMReference)ref).marshal(manElem, dsPrefix, context);
|
||||
}
|
||||
parent.appendChild(manElem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(o instanceof Manifest)) {
|
||||
return false;
|
||||
}
|
||||
Manifest oman = (Manifest)o;
|
||||
|
||||
boolean idsEqual = id == null ? oman.getId() == null
|
||||
: id.equals(oman.getId());
|
||||
|
||||
return idsEqual && references.equals(oman.getReferences());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 17;
|
||||
if (id != null) {
|
||||
result = 31 * result + id.hashCode();
|
||||
}
|
||||
result = 31 * result + references.hashCode();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
261
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMPGPData.java
Normal file
261
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMPGPData.java
Normal file
@@ -0,0 +1,261 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMPGPData.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dsig.XMLSignature;
|
||||
import javax.xml.crypto.dsig.keyinfo.PGPData;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
|
||||
|
||||
/**
|
||||
* DOM-based implementation of PGPData.
|
||||
*
|
||||
*/
|
||||
public final class DOMPGPData extends DOMStructure implements PGPData {
|
||||
|
||||
private final byte[] keyId;
|
||||
private final byte[] keyPacket;
|
||||
private final List<XMLStructure> externalElements;
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMPGPData} containing the specified key packet.
|
||||
* and optional list of external elements.
|
||||
*
|
||||
* @param keyPacket a PGP Key Material Packet as defined in section 5.5 of
|
||||
* <a href="https://www.ietf.org/rfc/rfc2440.txt">RFC 2440</a>. The
|
||||
* array is cloned to prevent subsequent modification.
|
||||
* @param other a list of {@link XMLStructure}s representing elements from
|
||||
* an external namespace. The list is defensively copied to prevent
|
||||
* subsequent modification. May be {@code null} or empty.
|
||||
* @throws NullPointerException if {@code keyPacket} is
|
||||
* {@code null}
|
||||
* @throws IllegalArgumentException if the key packet is not in the
|
||||
* correct format
|
||||
* @throws ClassCastException if {@code other} contains any
|
||||
* entries that are not of type {@link XMLStructure}
|
||||
*/
|
||||
public DOMPGPData(byte[] keyPacket, List<? extends XMLStructure> other) {
|
||||
if (keyPacket == null) {
|
||||
throw new NullPointerException("keyPacket cannot be null");
|
||||
}
|
||||
if (other == null || other.isEmpty()) {
|
||||
this.externalElements = Collections.emptyList();
|
||||
} else {
|
||||
this.externalElements =
|
||||
Collections.unmodifiableList(new ArrayList<>(other));
|
||||
for (int i = 0, size = this.externalElements.size(); i < size; i++) {
|
||||
if (!(this.externalElements.get(i) instanceof XMLStructure)) {
|
||||
throw new ClassCastException
|
||||
("other["+i+"] is not a valid PGPData type");
|
||||
}
|
||||
}
|
||||
}
|
||||
this.keyPacket = (byte[])keyPacket.clone();
|
||||
checkKeyPacket(keyPacket);
|
||||
this.keyId = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMPGPData} containing the specified key id and
|
||||
* optional key packet and list of external elements.
|
||||
*
|
||||
* @param keyId a PGP public key id as defined in section 11.2 of
|
||||
* <a href="https://www.ietf.org/rfc/rfc2440.txt">RFC 2440</a>. The
|
||||
* array is cloned to prevent subsequent modification.
|
||||
* @param keyPacket a PGP Key Material Packet as defined in section 5.5 of
|
||||
* <a href="https://www.ietf.org/rfc/rfc2440.txt">RFC 2440</a> (may
|
||||
* be {@code null}). The array is cloned to prevent subsequent
|
||||
* modification.
|
||||
* @param other a list of {@link XMLStructure}s representing elements from
|
||||
* an external namespace. The list is defensively copied to prevent
|
||||
* subsequent modification. May be {@code null} or empty.
|
||||
* @throws NullPointerException if {@code keyId} is {@code null}
|
||||
* @throws IllegalArgumentException if the key id or packet is not in the
|
||||
* correct format
|
||||
* @throws ClassCastException if {@code other} contains any
|
||||
* entries that are not of type {@link XMLStructure}
|
||||
*/
|
||||
public DOMPGPData(byte[] keyId, byte[] keyPacket,
|
||||
List<? extends XMLStructure> other)
|
||||
{
|
||||
if (keyId == null) {
|
||||
throw new NullPointerException("keyId cannot be null");
|
||||
}
|
||||
// key ids must be 8 bytes
|
||||
if (keyId.length != 8) {
|
||||
throw new IllegalArgumentException("keyId must be 8 bytes long");
|
||||
}
|
||||
if (other == null || other.isEmpty()) {
|
||||
this.externalElements = Collections.emptyList();
|
||||
} else {
|
||||
this.externalElements =
|
||||
Collections.unmodifiableList(new ArrayList<>(other));
|
||||
for (int i = 0, size = this.externalElements.size(); i < size; i++) {
|
||||
if (!(this.externalElements.get(i) instanceof XMLStructure)) {
|
||||
throw new ClassCastException
|
||||
("other["+i+"] is not a valid PGPData type");
|
||||
}
|
||||
}
|
||||
}
|
||||
this.keyId = (byte[])keyId.clone();
|
||||
this.keyPacket = keyPacket == null ? null
|
||||
: (byte[])keyPacket.clone();
|
||||
if (keyPacket != null) {
|
||||
checkKeyPacket(keyPacket);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMPGPData} from an element.
|
||||
*
|
||||
* @param pdElem a PGPData element
|
||||
*/
|
||||
public DOMPGPData(Element pdElem) throws MarshalException {
|
||||
// get all children nodes
|
||||
byte[] pgpKeyId = null;
|
||||
byte[] pgpKeyPacket = null;
|
||||
|
||||
List<XMLStructure> other = new ArrayList<>();
|
||||
Node firstChild = pdElem.getFirstChild();
|
||||
while (firstChild != null) {
|
||||
if (firstChild.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Element childElem = (Element)firstChild;
|
||||
String localName = childElem.getLocalName();
|
||||
String namespace = childElem.getNamespaceURI();
|
||||
if ("PGPKeyID".equals(localName) && XMLSignature.XMLNS.equals(namespace)) {
|
||||
String content = XMLUtils.getFullTextChildrenFromNode(childElem);
|
||||
pgpKeyId = XMLUtils.decode(content);
|
||||
} else if ("PGPKeyPacket".equals(localName) && XMLSignature.XMLNS.equals(namespace)) {
|
||||
String content = XMLUtils.getFullTextChildrenFromNode(childElem);
|
||||
pgpKeyPacket = XMLUtils.decode(content);
|
||||
} else {
|
||||
other.add
|
||||
(new javax.xml.crypto.dom.DOMStructure(childElem));
|
||||
}
|
||||
}
|
||||
firstChild = firstChild.getNextSibling();
|
||||
}
|
||||
this.keyId = pgpKeyId;
|
||||
this.keyPacket = pgpKeyPacket;
|
||||
this.externalElements = Collections.unmodifiableList(other);
|
||||
}
|
||||
|
||||
public byte[] getKeyId() {
|
||||
return keyId == null ? null : keyId.clone();
|
||||
}
|
||||
|
||||
public byte[] getKeyPacket() {
|
||||
return keyPacket == null ? null : keyPacket.clone();
|
||||
}
|
||||
|
||||
public List<XMLStructure> getExternalElements() {
|
||||
return externalElements;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
Document ownerDoc = DOMUtils.getOwnerDocument(parent);
|
||||
Element pdElem = DOMUtils.createElement(ownerDoc, "PGPData",
|
||||
XMLSignature.XMLNS, dsPrefix);
|
||||
|
||||
// create and append PGPKeyID element
|
||||
if (keyId != null) {
|
||||
Element keyIdElem = DOMUtils.createElement(ownerDoc, "PGPKeyID",
|
||||
XMLSignature.XMLNS,
|
||||
dsPrefix);
|
||||
keyIdElem.appendChild
|
||||
(ownerDoc.createTextNode(XMLUtils.encodeToString(keyId)));
|
||||
pdElem.appendChild(keyIdElem);
|
||||
}
|
||||
|
||||
// create and append PGPKeyPacket element
|
||||
if (keyPacket != null) {
|
||||
Element keyPktElem = DOMUtils.createElement(ownerDoc,
|
||||
"PGPKeyPacket",
|
||||
XMLSignature.XMLNS,
|
||||
dsPrefix);
|
||||
keyPktElem.appendChild
|
||||
(ownerDoc.createTextNode(XMLUtils.encodeToString(keyPacket)));
|
||||
pdElem.appendChild(keyPktElem);
|
||||
}
|
||||
|
||||
// create and append any elements
|
||||
for (XMLStructure extElem : externalElements) {
|
||||
DOMUtils.appendChild(pdElem, ((javax.xml.crypto.dom.DOMStructure)
|
||||
extElem).getNode());
|
||||
}
|
||||
|
||||
parent.appendChild(pdElem);
|
||||
}
|
||||
|
||||
/**
|
||||
* We assume packets use the new format packet syntax, as specified in
|
||||
* section 4 of RFC 2440.
|
||||
*
|
||||
* This method only checks if the packet contains a valid tag. The
|
||||
* contents of the packet should be checked by the application.
|
||||
*/
|
||||
private void checkKeyPacket(byte[] keyPacket) {
|
||||
// length must be at least 3 (one byte for tag, one byte for length,
|
||||
// and minimally one byte of content
|
||||
if (keyPacket.length < 3) {
|
||||
throw new IllegalArgumentException("keypacket must be at least " +
|
||||
"3 bytes long");
|
||||
}
|
||||
|
||||
int tag = keyPacket[0];
|
||||
// first bit must be set
|
||||
if ((tag & 128) != 128) {
|
||||
throw new IllegalArgumentException("keypacket tag is invalid: " +
|
||||
"bit 7 is not set");
|
||||
}
|
||||
// make sure using new format
|
||||
if ((tag & 64) != 64) {
|
||||
throw new IllegalArgumentException("old keypacket tag format is " +
|
||||
"unsupported");
|
||||
}
|
||||
|
||||
// tag value must be 6, 14, 5 or 7
|
||||
if ((tag & 6) != 6 && (tag & 14) != 14 &&
|
||||
(tag & 5) != 5 && (tag & 7) != 7) {
|
||||
throw new IllegalArgumentException("keypacket tag is invalid: " +
|
||||
"must be 6, 14, 5, or 7");
|
||||
}
|
||||
}
|
||||
}
|
||||
656
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMReference.java
Normal file
656
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMReference.java
Normal file
@@ -0,0 +1,656 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*
|
||||
* Portions copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* ===========================================================================
|
||||
*
|
||||
* (C) Copyright IBM Corp. 2003 All Rights Reserved.
|
||||
*
|
||||
* ===========================================================================
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMReference.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dom.DOMURIReference;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.security.*;
|
||||
import java.util.*;
|
||||
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
|
||||
|
||||
import org.jcp.xml.dsig.internal.DigesterOutputStream;
|
||||
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
|
||||
import com.sun.org.apache.xml.internal.security.utils.UnsyncBufferedOutputStream;
|
||||
|
||||
/**
|
||||
* DOM-based implementation of Reference.
|
||||
*
|
||||
*/
|
||||
public final class DOMReference extends DOMStructure
|
||||
implements Reference, DOMURIReference {
|
||||
|
||||
/**
|
||||
* The maximum number of transforms per reference, if secure validation is enabled.
|
||||
*/
|
||||
public static final int MAXIMUM_TRANSFORM_COUNT = 5;
|
||||
|
||||
/**
|
||||
* Look up useC14N11 system property. If true, an explicit C14N11 transform
|
||||
* will be added if necessary when generating the signature. See section
|
||||
* 3.1.1 of http://www.w3.org/2007/xmlsec/Drafts/xmldsig-core/ for more info.
|
||||
*
|
||||
* If true, overrides the same property if set in the XMLSignContext.
|
||||
*/
|
||||
private static boolean useC14N11 =
|
||||
AccessController.doPrivileged((PrivilegedAction<Boolean>)
|
||||
() -> Boolean.getBoolean("com.sun.org.apache.xml.internal.security.useC14N11"));
|
||||
|
||||
private static final com.sun.org.slf4j.internal.Logger LOG =
|
||||
com.sun.org.slf4j.internal.LoggerFactory.getLogger(DOMReference.class);
|
||||
|
||||
private final DigestMethod digestMethod;
|
||||
private final String id;
|
||||
private final List<Transform> transforms;
|
||||
private List<Transform> allTransforms;
|
||||
private final Data appliedTransformData;
|
||||
private Attr here;
|
||||
private final String uri;
|
||||
private final String type;
|
||||
private byte[] digestValue;
|
||||
private byte[] calcDigestValue;
|
||||
private Element refElem;
|
||||
private boolean digested = false;
|
||||
private boolean validated = false;
|
||||
private boolean validationStatus;
|
||||
private Data derefData;
|
||||
private InputStream dis;
|
||||
private MessageDigest md;
|
||||
private Provider provider;
|
||||
|
||||
/**
|
||||
* Creates a {@code Reference} from the specified parameters.
|
||||
*
|
||||
* @param uri the URI (may be null)
|
||||
* @param type the type (may be null)
|
||||
* @param dm the digest method
|
||||
* @param transforms a list of {@link Transform}s. The list
|
||||
* is defensively copied to protect against subsequent modification.
|
||||
* May be {@code null} or empty.
|
||||
* @param id the reference ID (may be {@code null})
|
||||
* @throws NullPointerException if {@code dm} is {@code null}
|
||||
* @throws ClassCastException if any of the {@code transforms} are
|
||||
* not of type {@code Transform}
|
||||
*/
|
||||
public DOMReference(String uri, String type, DigestMethod dm,
|
||||
List<? extends Transform> transforms, String id,
|
||||
Provider provider)
|
||||
{
|
||||
this(uri, type, dm, null, null, transforms, id, null, provider);
|
||||
}
|
||||
|
||||
public DOMReference(String uri, String type, DigestMethod dm,
|
||||
List<? extends Transform> appliedTransforms,
|
||||
Data result, List<? extends Transform> transforms,
|
||||
String id, Provider provider)
|
||||
{
|
||||
this(uri, type, dm, appliedTransforms,
|
||||
result, transforms, id, null, provider);
|
||||
}
|
||||
|
||||
public DOMReference(String uri, String type, DigestMethod dm,
|
||||
List<? extends Transform> appliedTransforms,
|
||||
Data result, List<? extends Transform> transforms,
|
||||
String id, byte[] digestValue, Provider provider)
|
||||
{
|
||||
if (dm == null) {
|
||||
throw new NullPointerException("DigestMethod must be non-null");
|
||||
}
|
||||
if (appliedTransforms == null) {
|
||||
this.allTransforms = new ArrayList<>();
|
||||
} else {
|
||||
this.allTransforms = new ArrayList<>(appliedTransforms);
|
||||
for (int i = 0, size = this.allTransforms.size(); i < size; i++) {
|
||||
if (!(this.allTransforms.get(i) instanceof Transform)) {
|
||||
throw new ClassCastException
|
||||
("appliedTransforms["+i+"] is not a valid type");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (transforms == null) {
|
||||
this.transforms = Collections.emptyList();
|
||||
} else {
|
||||
this.transforms = new ArrayList<>(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.allTransforms.addAll(this.transforms);
|
||||
}
|
||||
this.digestMethod = dm;
|
||||
this.uri = uri;
|
||||
if (uri != null && !uri.equals("")) {
|
||||
try {
|
||||
new URI(uri);
|
||||
} catch (URISyntaxException e) {
|
||||
throw new IllegalArgumentException(e.getMessage());
|
||||
}
|
||||
}
|
||||
this.type = type;
|
||||
this.id = id;
|
||||
if (digestValue != null) {
|
||||
this.digestValue = (byte[])digestValue.clone();
|
||||
this.digested = true;
|
||||
}
|
||||
this.appliedTransformData = result;
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMReference} from an element.
|
||||
*
|
||||
* @param refElem a Reference element
|
||||
*/
|
||||
public DOMReference(Element refElem, XMLCryptoContext context,
|
||||
Provider provider)
|
||||
throws MarshalException
|
||||
{
|
||||
boolean secVal = Utils.secureValidation(context);
|
||||
|
||||
// unmarshal Transforms, if specified
|
||||
Element nextSibling = DOMUtils.getFirstChildElement(refElem);
|
||||
List<Transform> newTransforms = new ArrayList<>(MAXIMUM_TRANSFORM_COUNT);
|
||||
if (nextSibling.getLocalName().equals("Transforms")
|
||||
&& XMLSignature.XMLNS.equals(nextSibling.getNamespaceURI())) {
|
||||
Element transformElem = DOMUtils.getFirstChildElement(nextSibling,
|
||||
"Transform",
|
||||
XMLSignature.XMLNS);
|
||||
newTransforms.add(new DOMTransform(transformElem, context, provider));
|
||||
transformElem = DOMUtils.getNextSiblingElement(transformElem);
|
||||
while (transformElem != null) {
|
||||
String localName = transformElem.getLocalName();
|
||||
String namespace = transformElem.getNamespaceURI();
|
||||
if (!"Transform".equals(localName) || !XMLSignature.XMLNS.equals(namespace)) {
|
||||
throw new MarshalException(
|
||||
"Invalid element name: " + localName +
|
||||
", expected Transform");
|
||||
}
|
||||
newTransforms.add
|
||||
(new DOMTransform(transformElem, context, provider));
|
||||
if (secVal && Policy.restrictNumTransforms(newTransforms.size())) {
|
||||
String error = "A maximum of " + Policy.maxTransforms()
|
||||
+ " transforms per Reference are allowed when"
|
||||
+ " secure validation is enabled";
|
||||
throw new MarshalException(error);
|
||||
}
|
||||
transformElem = DOMUtils.getNextSiblingElement(transformElem);
|
||||
}
|
||||
nextSibling = DOMUtils.getNextSiblingElement(nextSibling);
|
||||
}
|
||||
if (!nextSibling.getLocalName().equals("DigestMethod")
|
||||
&& XMLSignature.XMLNS.equals(nextSibling.getNamespaceURI())) {
|
||||
throw new MarshalException("Invalid element name: " +
|
||||
nextSibling.getLocalName() +
|
||||
", expected DigestMethod");
|
||||
}
|
||||
|
||||
// unmarshal DigestMethod
|
||||
Element dmElem = nextSibling;
|
||||
this.digestMethod = DOMDigestMethod.unmarshal(dmElem);
|
||||
String digestMethodAlgorithm = this.digestMethod.getAlgorithm();
|
||||
if (secVal && Policy.restrictAlg(digestMethodAlgorithm)) {
|
||||
throw new MarshalException(
|
||||
"It is forbidden to use algorithm " + digestMethodAlgorithm +
|
||||
" when secure validation is enabled"
|
||||
);
|
||||
}
|
||||
|
||||
// unmarshal DigestValue
|
||||
Element dvElem = DOMUtils.getNextSiblingElement(dmElem, "DigestValue", XMLSignature.XMLNS);
|
||||
String content = XMLUtils.getFullTextChildrenFromNode(dvElem);
|
||||
this.digestValue = XMLUtils.decode(content);
|
||||
|
||||
// check for extra elements
|
||||
if (DOMUtils.getNextSiblingElement(dvElem) != null) {
|
||||
throw new MarshalException(
|
||||
"Unexpected element after DigestValue element");
|
||||
}
|
||||
|
||||
// unmarshal attributes
|
||||
this.uri = DOMUtils.getAttributeValue(refElem, "URI");
|
||||
|
||||
Attr attr = refElem.getAttributeNodeNS(null, "Id");
|
||||
if (attr != null) {
|
||||
this.id = attr.getValue();
|
||||
refElem.setIdAttributeNode(attr, true);
|
||||
} else {
|
||||
this.id = null;
|
||||
}
|
||||
|
||||
this.type = DOMUtils.getAttributeValue(refElem, "Type");
|
||||
this.here = refElem.getAttributeNodeNS(null, "URI");
|
||||
this.refElem = refElem;
|
||||
this.transforms = newTransforms;
|
||||
this.allTransforms = transforms;
|
||||
this.appliedTransformData = null;
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
public DigestMethod getDigestMethod() {
|
||||
return digestMethod;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getURI() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public List<Transform> getTransforms() {
|
||||
return Collections.unmodifiableList(allTransforms);
|
||||
}
|
||||
|
||||
public byte[] getDigestValue() {
|
||||
return digestValue == null ? null : digestValue.clone();
|
||||
}
|
||||
|
||||
public byte[] getCalculatedDigestValue() {
|
||||
return calcDigestValue == null ? null
|
||||
: calcDigestValue.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
LOG.debug("Marshalling Reference");
|
||||
Document ownerDoc = DOMUtils.getOwnerDocument(parent);
|
||||
|
||||
refElem = DOMUtils.createElement(ownerDoc, "Reference",
|
||||
XMLSignature.XMLNS, dsPrefix);
|
||||
|
||||
// set attributes
|
||||
DOMUtils.setAttributeID(refElem, "Id", id);
|
||||
DOMUtils.setAttribute(refElem, "URI", uri);
|
||||
DOMUtils.setAttribute(refElem, "Type", type);
|
||||
|
||||
// create and append Transforms element
|
||||
if (!allTransforms.isEmpty()) {
|
||||
Element transformsElem = DOMUtils.createElement(ownerDoc,
|
||||
"Transforms",
|
||||
XMLSignature.XMLNS,
|
||||
dsPrefix);
|
||||
refElem.appendChild(transformsElem);
|
||||
for (Transform transform : allTransforms) {
|
||||
((DOMStructure)transform).marshal(transformsElem,
|
||||
dsPrefix, context);
|
||||
}
|
||||
}
|
||||
|
||||
// create and append DigestMethod element
|
||||
((DOMDigestMethod)digestMethod).marshal(refElem, dsPrefix, context);
|
||||
|
||||
// create and append DigestValue element
|
||||
LOG.debug("Adding digestValueElem");
|
||||
Element digestValueElem = DOMUtils.createElement(ownerDoc,
|
||||
"DigestValue",
|
||||
XMLSignature.XMLNS,
|
||||
dsPrefix);
|
||||
if (digestValue != null) {
|
||||
digestValueElem.appendChild
|
||||
(ownerDoc.createTextNode(XMLUtils.encodeToString(digestValue)));
|
||||
}
|
||||
refElem.appendChild(digestValueElem);
|
||||
|
||||
parent.appendChild(refElem);
|
||||
here = refElem.getAttributeNodeNS(null, "URI");
|
||||
}
|
||||
|
||||
public void digest(XMLSignContext signContext)
|
||||
throws XMLSignatureException
|
||||
{
|
||||
Data data = null;
|
||||
if (appliedTransformData == null) {
|
||||
data = dereference(signContext);
|
||||
} else {
|
||||
data = appliedTransformData;
|
||||
}
|
||||
digestValue = transform(data, signContext);
|
||||
|
||||
// insert digestValue into DigestValue element
|
||||
String encodedDV = XMLUtils.encodeToString(digestValue);
|
||||
LOG.debug("Reference object uri = {}", uri);
|
||||
Element digestElem = DOMUtils.getLastChildElement(refElem);
|
||||
if (digestElem == null) {
|
||||
throw new XMLSignatureException("DigestValue element expected");
|
||||
}
|
||||
DOMUtils.removeAllChildren(digestElem);
|
||||
digestElem.appendChild
|
||||
(refElem.getOwnerDocument().createTextNode(encodedDV));
|
||||
|
||||
digested = true;
|
||||
LOG.debug("Reference digesting completed");
|
||||
}
|
||||
|
||||
public boolean validate(XMLValidateContext validateContext)
|
||||
throws XMLSignatureException
|
||||
{
|
||||
if (validateContext == null) {
|
||||
throw new NullPointerException("validateContext cannot be null");
|
||||
}
|
||||
if (validated) {
|
||||
return validationStatus;
|
||||
}
|
||||
Data data = dereference(validateContext);
|
||||
calcDigestValue = transform(data, validateContext);
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Expected digest: " + XMLUtils.encodeToString(digestValue));
|
||||
LOG.debug("Actual digest: " + XMLUtils.encodeToString(calcDigestValue));
|
||||
}
|
||||
|
||||
validationStatus = Arrays.equals(digestValue, calcDigestValue);
|
||||
validated = true;
|
||||
return validationStatus;
|
||||
}
|
||||
|
||||
public Data getDereferencedData() {
|
||||
return derefData;
|
||||
}
|
||||
|
||||
public InputStream getDigestInputStream() {
|
||||
return dis;
|
||||
}
|
||||
|
||||
private Data dereference(XMLCryptoContext context)
|
||||
throws XMLSignatureException
|
||||
{
|
||||
Data data = null;
|
||||
|
||||
// use user-specified URIDereferencer if specified; otherwise use deflt
|
||||
URIDereferencer deref = context.getURIDereferencer();
|
||||
if (deref == null) {
|
||||
deref = DOMURIDereferencer.INSTANCE;
|
||||
}
|
||||
try {
|
||||
data = deref.dereference(this, context);
|
||||
LOG.debug("URIDereferencer class name: {}", deref.getClass().getName());
|
||||
LOG.debug("Data class name: {}", data.getClass().getName());
|
||||
} catch (URIReferenceException ure) {
|
||||
throw new XMLSignatureException(ure);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private byte[] transform(Data dereferencedData,
|
||||
XMLCryptoContext context)
|
||||
throws XMLSignatureException
|
||||
{
|
||||
if (md == null) {
|
||||
try {
|
||||
md = MessageDigest.getInstance
|
||||
(((DOMDigestMethod)digestMethod).getMessageDigestAlgorithm());
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
throw new XMLSignatureException(nsae);
|
||||
}
|
||||
}
|
||||
md.reset();
|
||||
DigesterOutputStream dos;
|
||||
Boolean cache = (Boolean)
|
||||
context.getProperty("javax.xml.crypto.dsig.cacheReference");
|
||||
if (cache != null && cache) {
|
||||
this.derefData = copyDerefData(dereferencedData);
|
||||
dos = new DigesterOutputStream(md, true);
|
||||
} else {
|
||||
dos = new DigesterOutputStream(md);
|
||||
}
|
||||
Data data = dereferencedData;
|
||||
try (OutputStream os = new UnsyncBufferedOutputStream(dos)) {
|
||||
for (int i = 0, size = transforms.size(); i < size; i++) {
|
||||
DOMTransform transform = (DOMTransform)transforms.get(i);
|
||||
if (i < size - 1) {
|
||||
data = transform.transform(data, context);
|
||||
} else {
|
||||
data = transform.transform(data, context, os);
|
||||
}
|
||||
}
|
||||
|
||||
if (data != null) {
|
||||
XMLSignatureInput xi;
|
||||
// explicitly use C14N 1.1 when generating signature
|
||||
// first check system property, then context property
|
||||
boolean c14n11 = useC14N11;
|
||||
String c14nalg = CanonicalizationMethod.INCLUSIVE;
|
||||
if (context instanceof XMLSignContext) {
|
||||
if (!c14n11) {
|
||||
Boolean prop = (Boolean)context.getProperty
|
||||
("com.sun.org.apache.xml.internal.security.useC14N11");
|
||||
c14n11 = prop != null && prop;
|
||||
if (c14n11) {
|
||||
c14nalg = "http://www.w3.org/2006/12/xml-c14n11";
|
||||
}
|
||||
} else {
|
||||
c14nalg = "http://www.w3.org/2006/12/xml-c14n11";
|
||||
}
|
||||
}
|
||||
if (data instanceof ApacheData) {
|
||||
xi = ((ApacheData)data).getXMLSignatureInput();
|
||||
} else if (data instanceof OctetStreamData) {
|
||||
xi = new XMLSignatureInput
|
||||
(((OctetStreamData)data).getOctetStream());
|
||||
} else if (data instanceof NodeSetData) {
|
||||
TransformService spi = null;
|
||||
if (provider == null) {
|
||||
spi = TransformService.getInstance(c14nalg, "DOM");
|
||||
} else {
|
||||
try {
|
||||
spi = TransformService.getInstance(c14nalg, "DOM", provider);
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
spi = TransformService.getInstance(c14nalg, "DOM");
|
||||
}
|
||||
}
|
||||
data = spi.transform(data, context);
|
||||
xi = new XMLSignatureInput
|
||||
(((OctetStreamData)data).getOctetStream());
|
||||
} else {
|
||||
throw new XMLSignatureException("unrecognized Data type");
|
||||
}
|
||||
|
||||
boolean secVal = Utils.secureValidation(context);
|
||||
try {
|
||||
xi.setSecureValidation(secVal);
|
||||
if (context instanceof XMLSignContext && c14n11
|
||||
&& !xi.isOctetStream() && !xi.isOutputStreamSet()) {
|
||||
TransformService spi = null;
|
||||
if (provider == null) {
|
||||
spi = TransformService.getInstance(c14nalg, "DOM");
|
||||
} else {
|
||||
try {
|
||||
spi = TransformService.getInstance(c14nalg, "DOM", provider);
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
spi = TransformService.getInstance(c14nalg, "DOM");
|
||||
}
|
||||
}
|
||||
|
||||
DOMTransform t = new DOMTransform(spi);
|
||||
Element transformsElem = null;
|
||||
String dsPrefix = DOMUtils.getSignaturePrefix(context);
|
||||
if (allTransforms.isEmpty()) {
|
||||
transformsElem = DOMUtils.createElement(
|
||||
refElem.getOwnerDocument(),
|
||||
"Transforms", XMLSignature.XMLNS, dsPrefix);
|
||||
refElem.insertBefore(transformsElem,
|
||||
DOMUtils.getFirstChildElement(refElem));
|
||||
} else {
|
||||
transformsElem = DOMUtils.getFirstChildElement(refElem);
|
||||
}
|
||||
t.marshal(transformsElem, dsPrefix,
|
||||
(DOMCryptoContext) context);
|
||||
allTransforms.add(t);
|
||||
xi.updateOutputStream(os, true);
|
||||
} else {
|
||||
xi.updateOutputStream(os);
|
||||
}
|
||||
} finally {
|
||||
if(xi.getOctetStreamReal() != null) {
|
||||
xi.getOctetStreamReal().close();
|
||||
}
|
||||
}
|
||||
}
|
||||
os.flush();
|
||||
if (cache != null && cache) {
|
||||
this.dis = dos.getInputStream();
|
||||
}
|
||||
return dos.getDigestValue();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new XMLSignatureException(e);
|
||||
} catch (TransformException e) {
|
||||
throw new XMLSignatureException(e);
|
||||
} catch (MarshalException e) {
|
||||
throw new XMLSignatureException(e);
|
||||
} catch (IOException e) {
|
||||
throw new XMLSignatureException(e);
|
||||
} catch (com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException e) {
|
||||
throw new XMLSignatureException(e);
|
||||
} finally {
|
||||
if (dos != null) {
|
||||
try {
|
||||
dos.close();
|
||||
} catch (IOException e) {
|
||||
throw new XMLSignatureException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Node getHere() {
|
||||
return here;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(o instanceof Reference)) {
|
||||
return false;
|
||||
}
|
||||
Reference oref = (Reference)o;
|
||||
|
||||
boolean idsEqual = id == null ? oref.getId() == null
|
||||
: id.equals(oref.getId());
|
||||
boolean urisEqual = uri == null ? oref.getURI() == null
|
||||
: uri.equals(oref.getURI());
|
||||
boolean typesEqual = type == null ? oref.getType() == null
|
||||
: type.equals(oref.getType());
|
||||
boolean digestValuesEqual =
|
||||
Arrays.equals(digestValue, oref.getDigestValue());
|
||||
|
||||
return digestMethod.equals(oref.getDigestMethod()) && idsEqual &&
|
||||
urisEqual && typesEqual &&
|
||||
allTransforms.equals(oref.getTransforms()) && digestValuesEqual;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 17;
|
||||
if (id != null) {
|
||||
result = 31 * result + id.hashCode();
|
||||
}
|
||||
if (uri != null) {
|
||||
result = 31 * result + uri.hashCode();
|
||||
}
|
||||
if (type != null) {
|
||||
result = 31 * result + type.hashCode();
|
||||
}
|
||||
if (digestValue != null) {
|
||||
result = 31 * result + Arrays.hashCode(digestValue);
|
||||
}
|
||||
result = 31 * result + digestMethod.hashCode();
|
||||
result = 31 * result + allTransforms.hashCode();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
boolean isDigested() {
|
||||
return digested;
|
||||
}
|
||||
|
||||
private static Data copyDerefData(Data dereferencedData) {
|
||||
if (dereferencedData instanceof ApacheData) {
|
||||
// need to make a copy of the Data
|
||||
ApacheData ad = (ApacheData)dereferencedData;
|
||||
XMLSignatureInput xsi = ad.getXMLSignatureInput();
|
||||
if (xsi.isNodeSet()) {
|
||||
try {
|
||||
final Set<Node> s = xsi.getNodeSet();
|
||||
return new NodeSetData() {
|
||||
public Iterator<Node> iterator() { return s.iterator(); }
|
||||
};
|
||||
} catch (Exception e) {
|
||||
// LOG a warning
|
||||
LOG.warn("cannot cache dereferenced data: " + e);
|
||||
return null;
|
||||
}
|
||||
} else if (xsi.isElement()) {
|
||||
return new DOMSubTreeData
|
||||
(xsi.getSubNode(), xsi.isExcludeComments());
|
||||
} else if (xsi.isOctetStream() || xsi.isByteArray()) {
|
||||
try {
|
||||
return new OctetStreamData
|
||||
(xsi.getOctetStream(), xsi.getSourceURI(),
|
||||
xsi.getMIMEType());
|
||||
} catch (IOException ioe) {
|
||||
// LOG a warning
|
||||
LOG.warn("cannot cache dereferenced data: " + ioe);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return dereferencedData;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,324 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*
|
||||
* Portions copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* ===========================================================================
|
||||
*
|
||||
* (C) Copyright IBM Corp. 2003 All Rights Reserved.
|
||||
*
|
||||
* ===========================================================================
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMRetrievalMethod.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.security.Provider;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.crypto.Data;
|
||||
import javax.xml.crypto.MarshalException;
|
||||
import javax.xml.crypto.NodeSetData;
|
||||
import javax.xml.crypto.URIDereferencer;
|
||||
import javax.xml.crypto.URIReferenceException;
|
||||
import javax.xml.crypto.XMLCryptoContext;
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dom.DOMURIReference;
|
||||
import javax.xml.crypto.dsig.Transform;
|
||||
import javax.xml.crypto.dsig.XMLSignature;
|
||||
import javax.xml.crypto.dsig.keyinfo.RetrievalMethod;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
|
||||
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.
|
||||
*
|
||||
*/
|
||||
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<>(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> newTransforms = new ArrayList<>();
|
||||
Element transformsElem = DOMUtils.getFirstChildElement(rmElem);
|
||||
|
||||
if (transformsElem != null) {
|
||||
String localName = transformsElem.getLocalName();
|
||||
String namespace = transformsElem.getNamespaceURI();
|
||||
if (!"Transforms".equals(localName) || !XMLSignature.XMLNS.equals(namespace)) {
|
||||
throw new MarshalException("Invalid element name: " +
|
||||
namespace + ":" + localName + ", expected Transforms");
|
||||
}
|
||||
Element transformElem =
|
||||
DOMUtils.getFirstChildElement(transformsElem, "Transform", XMLSignature.XMLNS);
|
||||
while (transformElem != null) {
|
||||
String name = transformElem.getLocalName();
|
||||
namespace = transformElem.getNamespaceURI();
|
||||
if (!"Transform".equals(name) || !XMLSignature.XMLNS.equals(namespace)) {
|
||||
throw new MarshalException("Invalid element name: " +
|
||||
name + ", expected Transform");
|
||||
}
|
||||
newTransforms.add
|
||||
(new DOMTransform(transformElem, context, provider));
|
||||
if (secVal && Policy.restrictNumTransforms(newTransforms.size())) {
|
||||
String error = "A maximum of " + Policy.maxTransforms()
|
||||
+ " transforms per Reference are allowed when"
|
||||
+ " secure validation is enabled";
|
||||
throw new MarshalException(error);
|
||||
}
|
||||
transformElem = DOMUtils.getNextSiblingElement(transformElem);
|
||||
}
|
||||
}
|
||||
if (newTransforms.isEmpty()) {
|
||||
this.transforms = Collections.emptyList();
|
||||
} else {
|
||||
this.transforms = Collections.unmodifiableList(newTransforms);
|
||||
}
|
||||
}
|
||||
|
||||
public String getURI() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public List<Transform> getTransforms() {
|
||||
return transforms;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
Document ownerDoc = DOMUtils.getOwnerDocument(parent);
|
||||
Element rmElem = DOMUtils.createElement(ownerDoc, "RetrievalMethod",
|
||||
XMLSignature.XMLNS, dsPrefix);
|
||||
|
||||
// add URI and Type attributes
|
||||
DOMUtils.setAttribute(rmElem, "URI", uri);
|
||||
DOMUtils.setAttribute(rmElem, "Type", type);
|
||||
|
||||
// add Transforms elements
|
||||
if (!transforms.isEmpty()) {
|
||||
Element transformsElem = DOMUtils.createElement(ownerDoc,
|
||||
"Transforms",
|
||||
XMLSignature.XMLNS,
|
||||
dsPrefix);
|
||||
rmElem.appendChild(transformsElem);
|
||||
for (Transform transform : transforms) {
|
||||
((DOMTransform)transform).marshal(transformsElem,
|
||||
dsPrefix, context);
|
||||
}
|
||||
}
|
||||
|
||||
parent.appendChild(rmElem);
|
||||
|
||||
// save here node
|
||||
here = rmElem.getAttributeNodeNS(null, "URI");
|
||||
}
|
||||
|
||||
public Node getHere() {
|
||||
return here;
|
||||
}
|
||||
|
||||
public Data dereference(XMLCryptoContext context)
|
||||
throws URIReferenceException
|
||||
{
|
||||
if (context == null) {
|
||||
throw new NullPointerException("context cannot be null");
|
||||
}
|
||||
|
||||
/*
|
||||
* If URIDereferencer is specified in context; use it, otherwise use
|
||||
* built-in.
|
||||
*/
|
||||
URIDereferencer deref = context.getURIDereferencer();
|
||||
if (deref == null) {
|
||||
deref = DOMURIDereferencer.INSTANCE;
|
||||
}
|
||||
|
||||
Data data = deref.dereference(this, context);
|
||||
|
||||
// pass dereferenced data through Transforms
|
||||
try {
|
||||
for (Transform transform : transforms) {
|
||||
data = ((DOMTransform)transform).transform(data, context);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new URIReferenceException(e);
|
||||
}
|
||||
|
||||
// guard against RetrievalMethod loops
|
||||
if (data instanceof NodeSetData && Utils.secureValidation(context)
|
||||
&& Policy.restrictRetrievalMethodLoops()) {
|
||||
NodeSetData nsd = (NodeSetData)data;
|
||||
Iterator<?> i = nsd.iterator();
|
||||
if (i.hasNext()) {
|
||||
Node root = (Node)i.next();
|
||||
if ("RetrievalMethod".equals(root.getLocalName())) {
|
||||
throw new URIReferenceException(
|
||||
"It is forbidden to have one RetrievalMethod point " +
|
||||
"to another when secure validation is enabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public XMLStructure dereferenceAsXMLStructure(XMLCryptoContext context)
|
||||
throws URIReferenceException
|
||||
{
|
||||
DocumentBuilder db = null;
|
||||
boolean secVal = Utils.secureValidation(context);
|
||||
ApacheData data = (ApacheData)dereference(context);
|
||||
try (InputStream is = new ByteArrayInputStream(data.getXMLSignatureInput().getBytes())) {
|
||||
db = XMLUtils.createDocumentBuilder(false, secVal);
|
||||
Document doc = db.parse(is);
|
||||
Element kiElem = doc.getDocumentElement();
|
||||
if (kiElem.getLocalName().equals("X509Data")
|
||||
&& XMLSignature.XMLNS.equals(kiElem.getNamespaceURI())) {
|
||||
return new DOMX509Data(kiElem);
|
||||
} else {
|
||||
return null; // unsupported
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new URIReferenceException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof RetrievalMethod)) {
|
||||
return false;
|
||||
}
|
||||
RetrievalMethod orm = (RetrievalMethod)obj;
|
||||
|
||||
boolean typesEqual = type == null ? orm.getType() == null
|
||||
: type.equals(orm.getType());
|
||||
|
||||
return uri.equals(orm.getURI()) &&
|
||||
transforms.equals(orm.getTransforms()) && typesEqual;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 17;
|
||||
if (type != null) {
|
||||
result = 31 * result + type.hashCode();
|
||||
}
|
||||
result = 31 * result + uri.hashCode();
|
||||
result = 31 * result + transforms.hashCode();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,825 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMSignatureMethod.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
import javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.*;
|
||||
import java.security.interfaces.DSAKey;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import java.security.spec.MGF1ParameterSpec;
|
||||
import java.security.spec.PSSParameterSpec;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureECDSA;
|
||||
import com.sun.org.apache.xml.internal.security.utils.JavaUtils;
|
||||
import org.jcp.xml.dsig.internal.SignerOutputStream;
|
||||
import sun.security.util.KeyUtil;
|
||||
|
||||
/**
|
||||
* DOM-based abstract implementation of SignatureMethod.
|
||||
*
|
||||
*/
|
||||
public abstract class DOMSignatureMethod extends AbstractDOMSignatureMethod {
|
||||
|
||||
private static final com.sun.org.slf4j.internal.Logger LOG =
|
||||
com.sun.org.slf4j.internal.LoggerFactory.getLogger(DOMSignatureMethod.class);
|
||||
|
||||
private SignatureMethodParameterSpec params;
|
||||
private Signature signature;
|
||||
|
||||
// see RFC 4051 for these algorithm definitions
|
||||
static final String RSA_SHA224 =
|
||||
"http://www.w3.org/2001/04/xmldsig-more#rsa-sha224";
|
||||
static final String RSA_SHA256 =
|
||||
"http://www.w3.org/2001/04/xmldsig-more#rsa-sha256";
|
||||
static final String RSA_SHA384 =
|
||||
"http://www.w3.org/2001/04/xmldsig-more#rsa-sha384";
|
||||
static final String RSA_SHA512 =
|
||||
"http://www.w3.org/2001/04/xmldsig-more#rsa-sha512";
|
||||
static final String RSA_RIPEMD160 =
|
||||
"http://www.w3.org/2001/04/xmldsig-more#rsa-ripemd160";
|
||||
static final String ECDSA_SHA1 =
|
||||
"http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1";
|
||||
static final String ECDSA_SHA224 =
|
||||
"http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha224";
|
||||
static final String ECDSA_SHA256 =
|
||||
"http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256";
|
||||
static final String ECDSA_SHA384 =
|
||||
"http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha384";
|
||||
static final String ECDSA_SHA512 =
|
||||
"http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha512";
|
||||
static final String DSA_SHA256 =
|
||||
"http://www.w3.org/2009/xmldsig11#dsa-sha256";
|
||||
|
||||
// see RFC 6931 for these algorithm definitions
|
||||
static final String ECDSA_RIPEMD160 =
|
||||
"http://www.w3.org/2007/05/xmldsig-more#ecdsa-ripemd160";
|
||||
static final String RSA_SHA1_MGF1 =
|
||||
"http://www.w3.org/2007/05/xmldsig-more#sha1-rsa-MGF1";
|
||||
static final String RSA_SHA224_MGF1 =
|
||||
"http://www.w3.org/2007/05/xmldsig-more#sha224-rsa-MGF1";
|
||||
static final String RSA_SHA256_MGF1 =
|
||||
"http://www.w3.org/2007/05/xmldsig-more#sha256-rsa-MGF1";
|
||||
static final String RSA_SHA384_MGF1 =
|
||||
"http://www.w3.org/2007/05/xmldsig-more#sha384-rsa-MGF1";
|
||||
static final String RSA_SHA512_MGF1 =
|
||||
"http://www.w3.org/2007/05/xmldsig-more#sha512-rsa-MGF1";
|
||||
static final String RSA_RIPEMD160_MGF1 =
|
||||
"http://www.w3.org/2007/05/xmldsig-more#ripemd160-rsa-MGF1";
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMSignatureMethod}.
|
||||
*
|
||||
* @param params the algorithm-specific params (may be {@code null})
|
||||
* @throws InvalidAlgorithmParameterException if the parameters are not
|
||||
* appropriate for this signature method
|
||||
*/
|
||||
DOMSignatureMethod(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException
|
||||
{
|
||||
if (params != null &&
|
||||
!(params instanceof SignatureMethodParameterSpec)) {
|
||||
throw new InvalidAlgorithmParameterException
|
||||
("params must be of type SignatureMethodParameterSpec");
|
||||
}
|
||||
checkParams((SignatureMethodParameterSpec)params);
|
||||
this.params = (SignatureMethodParameterSpec)params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMSignatureMethod} from an element. This ctor
|
||||
* invokes the {@link #unmarshalParams unmarshalParams} method to
|
||||
* unmarshal any algorithm-specific input parameters.
|
||||
*
|
||||
* @param smElem a SignatureMethod element
|
||||
*/
|
||||
DOMSignatureMethod(Element smElem) throws MarshalException {
|
||||
Element paramsElem = DOMUtils.getFirstChildElement(smElem);
|
||||
if (paramsElem != null) {
|
||||
params = unmarshalParams(paramsElem);
|
||||
}
|
||||
try {
|
||||
checkParams(params);
|
||||
} catch (InvalidAlgorithmParameterException iape) {
|
||||
throw new MarshalException(iape);
|
||||
}
|
||||
}
|
||||
|
||||
static SignatureMethod unmarshal(Element smElem) throws MarshalException {
|
||||
String alg = DOMUtils.getAttributeValue(smElem, "Algorithm");
|
||||
if (alg.equals(SignatureMethod.RSA_SHA1)) {
|
||||
return new SHA1withRSA(smElem);
|
||||
} else if (alg.equals(RSA_SHA224)) {
|
||||
return new SHA224withRSA(smElem);
|
||||
} else if (alg.equals(RSA_SHA256)) {
|
||||
return new SHA256withRSA(smElem);
|
||||
} else if (alg.equals(RSA_SHA384)) {
|
||||
return new SHA384withRSA(smElem);
|
||||
} else if (alg.equals(RSA_SHA512)) {
|
||||
return new SHA512withRSA(smElem);
|
||||
} else if (alg.equals(RSA_RIPEMD160)) {
|
||||
return new RIPEMD160withRSA(smElem);
|
||||
} else if (alg.equals(RSA_SHA1_MGF1)) {
|
||||
return new SHA1withRSAandMGF1(smElem);
|
||||
} else if (alg.equals(RSA_SHA224_MGF1)) {
|
||||
return new SHA224withRSAandMGF1(smElem);
|
||||
} else if (alg.equals(RSA_SHA256_MGF1)) {
|
||||
return new SHA256withRSAandMGF1(smElem);
|
||||
} else if (alg.equals(RSA_SHA384_MGF1)) {
|
||||
return new SHA384withRSAandMGF1(smElem);
|
||||
} else if (alg.equals(RSA_SHA512_MGF1)) {
|
||||
return new SHA512withRSAandMGF1(smElem);
|
||||
} else if (alg.equals(RSA_RIPEMD160_MGF1)) {
|
||||
return new RIPEMD160withRSAandMGF1(smElem);
|
||||
} else if (alg.equals(SignatureMethod.DSA_SHA1)) {
|
||||
return new SHA1withDSA(smElem);
|
||||
} else if (alg.equals(DSA_SHA256)) {
|
||||
return new SHA256withDSA(smElem);
|
||||
} else if (alg.equals(ECDSA_SHA1)) {
|
||||
return new SHA1withECDSA(smElem);
|
||||
} else if (alg.equals(ECDSA_SHA224)) {
|
||||
return new SHA224withECDSA(smElem);
|
||||
} else if (alg.equals(ECDSA_SHA256)) {
|
||||
return new SHA256withECDSA(smElem);
|
||||
} else if (alg.equals(ECDSA_SHA384)) {
|
||||
return new SHA384withECDSA(smElem);
|
||||
} else if (alg.equals(ECDSA_SHA512)) {
|
||||
return new SHA512withECDSA(smElem);
|
||||
} else if (alg.equals(ECDSA_RIPEMD160)) {
|
||||
return new RIPEMD160withECDSA(smElem);
|
||||
} else if (alg.equals(SignatureMethod.HMAC_SHA1)) {
|
||||
return new DOMHMACSignatureMethod.SHA1(smElem);
|
||||
} else if (alg.equals(DOMHMACSignatureMethod.HMAC_SHA224)) {
|
||||
return new DOMHMACSignatureMethod.SHA224(smElem);
|
||||
} else if (alg.equals(DOMHMACSignatureMethod.HMAC_SHA256)) {
|
||||
return new DOMHMACSignatureMethod.SHA256(smElem);
|
||||
} else if (alg.equals(DOMHMACSignatureMethod.HMAC_SHA384)) {
|
||||
return new DOMHMACSignatureMethod.SHA384(smElem);
|
||||
} else if (alg.equals(DOMHMACSignatureMethod.HMAC_SHA512)) {
|
||||
return new DOMHMACSignatureMethod.SHA512(smElem);
|
||||
} else if (alg.equals(DOMHMACSignatureMethod.HMAC_RIPEMD160)) {
|
||||
return new DOMHMACSignatureMethod.RIPEMD160(smElem);
|
||||
} else {
|
||||
throw new MarshalException
|
||||
("unsupported SignatureMethod algorithm: " + alg);
|
||||
}
|
||||
}
|
||||
|
||||
public final AlgorithmParameterSpec getParameterSpec() {
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an instance of Signature from the specified Provider.
|
||||
* The algorithm is specified by the {@code getJCAAlgorithm()} method.
|
||||
*
|
||||
* @param p the Provider to use
|
||||
* @return an instance of Signature implementing the algorithm
|
||||
* specified by {@code getJCAAlgorithm()}
|
||||
* @throws NoSuchAlgorithmException if the Provider does not support the
|
||||
* signature algorithm
|
||||
*/
|
||||
Signature getSignature(Provider p)
|
||||
throws NoSuchAlgorithmException {
|
||||
return (p == null)
|
||||
? Signature.getInstance(getJCAAlgorithm())
|
||||
: Signature.getInstance(getJCAAlgorithm(), p);
|
||||
}
|
||||
|
||||
boolean verify(Key key, SignedInfo si, byte[] sig,
|
||||
XMLValidateContext context)
|
||||
throws InvalidKeyException, SignatureException, XMLSignatureException
|
||||
{
|
||||
if (key == null || si == null || sig == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
if (!(key instanceof PublicKey)) {
|
||||
throw new InvalidKeyException("key must be PublicKey");
|
||||
}
|
||||
checkKeySize(context, key);
|
||||
if (signature == null) {
|
||||
Provider p = (Provider) context.getProperty
|
||||
("org.jcp.xml.dsig.internal.dom.SignatureProvider");
|
||||
try {
|
||||
signature = getSignature(p);
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
throw new XMLSignatureException(nsae);
|
||||
}
|
||||
}
|
||||
signature.initVerify((PublicKey)key);
|
||||
LOG.debug("Signature provider: {}", signature.getProvider());
|
||||
LOG.debug("Verifying with key: {}", key);
|
||||
LOG.debug("JCA Algorithm: {}", getJCAAlgorithm());
|
||||
LOG.debug("Signature Bytes length: {}", sig.length);
|
||||
|
||||
try (SignerOutputStream outputStream = new SignerOutputStream(signature)) {
|
||||
((DOMSignedInfo)si).canonicalize(context, outputStream);
|
||||
Type type = getAlgorithmType();
|
||||
if (type == Type.DSA) {
|
||||
int size = ((DSAKey)key).getParams().getQ().bitLength();
|
||||
return signature.verify(JavaUtils.convertDsaXMLDSIGtoASN1(sig,
|
||||
size/8));
|
||||
} else if (type == Type.ECDSA) {
|
||||
return signature.verify(SignatureECDSA.convertXMLDSIGtoASN1(sig));
|
||||
} else {
|
||||
return signature.verify(sig);
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
throw new XMLSignatureException(ioe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If secure validation mode is enabled, checks that the key size is
|
||||
* restricted.
|
||||
*
|
||||
* @param context the context
|
||||
* @param key the key to check
|
||||
* @throws XMLSignatureException if the key size is restricted
|
||||
*/
|
||||
private static void checkKeySize(XMLCryptoContext context, Key key)
|
||||
throws XMLSignatureException {
|
||||
if (Utils.secureValidation(context)) {
|
||||
int size = KeyUtil.getKeySize(key);
|
||||
if (size == -1) {
|
||||
// key size cannot be determined, so we cannot check against
|
||||
// restrictions. Note that a DSA key w/o params will be
|
||||
// rejected later if the certificate chain is validated.
|
||||
LOG.debug("Size for " +
|
||||
key.getAlgorithm() + " key cannot be determined");
|
||||
return;
|
||||
}
|
||||
if (Policy.restrictKey(key.getAlgorithm(), size)) {
|
||||
throw new XMLSignatureException(key.getAlgorithm() +
|
||||
" keys less than " +
|
||||
Policy.minKeySize(key.getAlgorithm()) + " bits are" +
|
||||
" forbidden when secure validation is enabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
byte[] sign(Key key, SignedInfo si, XMLSignContext context)
|
||||
throws InvalidKeyException, XMLSignatureException
|
||||
{
|
||||
if (key == null || si == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
if (!(key instanceof PrivateKey)) {
|
||||
throw new InvalidKeyException("key must be PrivateKey");
|
||||
}
|
||||
checkKeySize(context, key);
|
||||
if (signature == null) {
|
||||
Provider p = (Provider)context.getProperty
|
||||
("org.jcp.xml.dsig.internal.dom.SignatureProvider");
|
||||
try {
|
||||
signature = getSignature(p);
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
throw new XMLSignatureException(nsae);
|
||||
}
|
||||
}
|
||||
signature.initSign((PrivateKey)key);
|
||||
LOG.debug("Signature provider: {}", signature.getProvider());
|
||||
LOG.debug("JCA Algorithm: {}", getJCAAlgorithm());
|
||||
|
||||
try (SignerOutputStream outputStream = new SignerOutputStream(signature)) {
|
||||
((DOMSignedInfo)si).canonicalize(context, outputStream);
|
||||
Type type = getAlgorithmType();
|
||||
if (type == Type.DSA) {
|
||||
int size = ((DSAKey)key).getParams().getQ().bitLength();
|
||||
return JavaUtils.convertDsaASN1toXMLDSIG(signature.sign(),
|
||||
size/8);
|
||||
} else if (type == Type.ECDSA) {
|
||||
return SignatureECDSA.convertASN1toXMLDSIG(signature.sign());
|
||||
} else {
|
||||
return signature.sign();
|
||||
}
|
||||
} catch (SignatureException se) {
|
||||
throw new XMLSignatureException(se);
|
||||
} catch (IOException ioe) {
|
||||
throw new XMLSignatureException(ioe);
|
||||
}
|
||||
}
|
||||
|
||||
abstract static class AbstractRSAPSSSignatureMethod
|
||||
extends DOMSignatureMethod {
|
||||
|
||||
AbstractRSAPSSSignatureMethod(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
|
||||
AbstractRSAPSSSignatureMethod(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
|
||||
abstract public PSSParameterSpec getPSSParameterSpec();
|
||||
|
||||
@Override
|
||||
Signature getSignature(Provider p)
|
||||
throws NoSuchAlgorithmException {
|
||||
try {
|
||||
Signature s = (p == null)
|
||||
? Signature.getInstance("RSASSA-PSS")
|
||||
: Signature.getInstance("RSASSA-PSS", p);
|
||||
try {
|
||||
s.setParameter(getPSSParameterSpec());
|
||||
} catch (InvalidAlgorithmParameterException e) {
|
||||
throw new NoSuchAlgorithmException("Should not happen", e);
|
||||
}
|
||||
return s;
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
return (p == null)
|
||||
? Signature.getInstance(getJCAAlgorithm())
|
||||
: Signature.getInstance(getJCAAlgorithm(), p);
|
||||
}
|
||||
}
|
||||
}
|
||||
static final class SHA1withRSA extends DOMSignatureMethod {
|
||||
SHA1withRSA(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA1withRSA(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
@Override
|
||||
public String getAlgorithm() {
|
||||
return SignatureMethod.RSA_SHA1;
|
||||
}
|
||||
@Override
|
||||
String getJCAAlgorithm() {
|
||||
return "SHA1withRSA";
|
||||
}
|
||||
@Override
|
||||
Type getAlgorithmType() {
|
||||
return Type.RSA;
|
||||
}
|
||||
}
|
||||
|
||||
static final class SHA224withRSA extends DOMSignatureMethod {
|
||||
SHA224withRSA(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA224withRSA(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
public String getAlgorithm() {
|
||||
return RSA_SHA224;
|
||||
}
|
||||
String getJCAAlgorithm() {
|
||||
return "SHA224withRSA";
|
||||
}
|
||||
Type getAlgorithmType() {
|
||||
return Type.RSA;
|
||||
}
|
||||
}
|
||||
|
||||
static final class SHA256withRSA extends DOMSignatureMethod {
|
||||
SHA256withRSA(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA256withRSA(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
public String getAlgorithm() {
|
||||
return RSA_SHA256;
|
||||
}
|
||||
String getJCAAlgorithm() {
|
||||
return "SHA256withRSA";
|
||||
}
|
||||
Type getAlgorithmType() {
|
||||
return Type.RSA;
|
||||
}
|
||||
}
|
||||
|
||||
static final class SHA384withRSA extends DOMSignatureMethod {
|
||||
SHA384withRSA(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA384withRSA(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
public String getAlgorithm() {
|
||||
return RSA_SHA384;
|
||||
}
|
||||
String getJCAAlgorithm() {
|
||||
return "SHA384withRSA";
|
||||
}
|
||||
Type getAlgorithmType() {
|
||||
return Type.RSA;
|
||||
}
|
||||
}
|
||||
|
||||
static final class SHA512withRSA extends DOMSignatureMethod {
|
||||
SHA512withRSA(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA512withRSA(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
public String getAlgorithm() {
|
||||
return RSA_SHA512;
|
||||
}
|
||||
String getJCAAlgorithm() {
|
||||
return "SHA512withRSA";
|
||||
}
|
||||
Type getAlgorithmType() {
|
||||
return Type.RSA;
|
||||
}
|
||||
}
|
||||
|
||||
static final class RIPEMD160withRSA extends DOMSignatureMethod {
|
||||
RIPEMD160withRSA(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
RIPEMD160withRSA(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
@Override
|
||||
public String getAlgorithm() {
|
||||
return RSA_RIPEMD160;
|
||||
}
|
||||
@Override
|
||||
String getJCAAlgorithm() {
|
||||
return "RIPEMD160withRSA";
|
||||
}
|
||||
@Override
|
||||
Type getAlgorithmType() {
|
||||
return Type.RSA;
|
||||
}
|
||||
}
|
||||
|
||||
static final class SHA1withRSAandMGF1 extends AbstractRSAPSSSignatureMethod {
|
||||
|
||||
private static PSSParameterSpec spec
|
||||
= new PSSParameterSpec("SHA-1", "MGF1", MGF1ParameterSpec.SHA1,
|
||||
20, PSSParameterSpec.TRAILER_FIELD_BC);
|
||||
|
||||
SHA1withRSAandMGF1(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA1withRSAandMGF1(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
@Override
|
||||
public String getAlgorithm() {
|
||||
return RSA_SHA1_MGF1;
|
||||
}
|
||||
@Override
|
||||
public PSSParameterSpec getPSSParameterSpec() {
|
||||
return spec;
|
||||
}
|
||||
@Override
|
||||
String getJCAAlgorithm() {
|
||||
return "SHA1withRSAandMGF1";
|
||||
}
|
||||
@Override
|
||||
Type getAlgorithmType() {
|
||||
return Type.RSA;
|
||||
}
|
||||
}
|
||||
|
||||
static final class SHA224withRSAandMGF1 extends AbstractRSAPSSSignatureMethod {
|
||||
|
||||
private static PSSParameterSpec spec
|
||||
= new PSSParameterSpec("SHA-224", "MGF1", MGF1ParameterSpec.SHA224,
|
||||
28, PSSParameterSpec.TRAILER_FIELD_BC);
|
||||
|
||||
SHA224withRSAandMGF1(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA224withRSAandMGF1(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
@Override
|
||||
public String getAlgorithm() {
|
||||
return RSA_SHA224_MGF1;
|
||||
}
|
||||
@Override
|
||||
public PSSParameterSpec getPSSParameterSpec() {
|
||||
return spec;
|
||||
}
|
||||
@Override
|
||||
String getJCAAlgorithm() {
|
||||
return "SHA224withRSAandMGF1";
|
||||
}
|
||||
@Override
|
||||
Type getAlgorithmType() {
|
||||
return Type.RSA;
|
||||
}
|
||||
}
|
||||
|
||||
static final class SHA256withRSAandMGF1 extends AbstractRSAPSSSignatureMethod {
|
||||
|
||||
private static PSSParameterSpec spec
|
||||
= new PSSParameterSpec("SHA-256", "MGF1", MGF1ParameterSpec.SHA256,
|
||||
32, PSSParameterSpec.TRAILER_FIELD_BC);
|
||||
|
||||
SHA256withRSAandMGF1(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA256withRSAandMGF1(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
@Override
|
||||
public String getAlgorithm() {
|
||||
return RSA_SHA256_MGF1;
|
||||
}
|
||||
@Override
|
||||
public PSSParameterSpec getPSSParameterSpec() {
|
||||
return spec;
|
||||
}
|
||||
@Override
|
||||
String getJCAAlgorithm() {
|
||||
return "SHA256withRSAandMGF1";
|
||||
}
|
||||
@Override
|
||||
Type getAlgorithmType() {
|
||||
return Type.RSA;
|
||||
}
|
||||
}
|
||||
|
||||
static final class SHA384withRSAandMGF1 extends AbstractRSAPSSSignatureMethod {
|
||||
|
||||
private static PSSParameterSpec spec
|
||||
= new PSSParameterSpec("SHA-384", "MGF1", MGF1ParameterSpec.SHA384,
|
||||
48, PSSParameterSpec.TRAILER_FIELD_BC);
|
||||
|
||||
SHA384withRSAandMGF1(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA384withRSAandMGF1(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
@Override
|
||||
public String getAlgorithm() {
|
||||
return RSA_SHA384_MGF1;
|
||||
}
|
||||
@Override
|
||||
public PSSParameterSpec getPSSParameterSpec() {
|
||||
return spec;
|
||||
}
|
||||
@Override
|
||||
String getJCAAlgorithm() {
|
||||
return "SHA384withRSAandMGF1";
|
||||
}
|
||||
@Override
|
||||
Type getAlgorithmType() {
|
||||
return Type.RSA;
|
||||
}
|
||||
}
|
||||
|
||||
static final class SHA512withRSAandMGF1 extends AbstractRSAPSSSignatureMethod {
|
||||
|
||||
private static PSSParameterSpec spec
|
||||
= new PSSParameterSpec("SHA-512", "MGF1", MGF1ParameterSpec.SHA512,
|
||||
64, PSSParameterSpec.TRAILER_FIELD_BC);
|
||||
|
||||
SHA512withRSAandMGF1(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA512withRSAandMGF1(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
@Override
|
||||
public String getAlgorithm() {
|
||||
return RSA_SHA512_MGF1;
|
||||
}
|
||||
@Override
|
||||
public PSSParameterSpec getPSSParameterSpec() {
|
||||
return spec;
|
||||
}
|
||||
@Override
|
||||
String getJCAAlgorithm() {
|
||||
return "SHA512withRSAandMGF1";
|
||||
}
|
||||
@Override
|
||||
Type getAlgorithmType() {
|
||||
return Type.RSA;
|
||||
}
|
||||
}
|
||||
|
||||
static final class RIPEMD160withRSAandMGF1 extends DOMSignatureMethod {
|
||||
RIPEMD160withRSAandMGF1(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
RIPEMD160withRSAandMGF1(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
@Override
|
||||
public String getAlgorithm() {
|
||||
return RSA_RIPEMD160_MGF1;
|
||||
}
|
||||
@Override
|
||||
String getJCAAlgorithm() {
|
||||
return "RIPEMD160withRSAandMGF1";
|
||||
}
|
||||
@Override
|
||||
Type getAlgorithmType() {
|
||||
return Type.RSA;
|
||||
}
|
||||
}
|
||||
|
||||
static final class SHA1withDSA extends DOMSignatureMethod {
|
||||
SHA1withDSA(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA1withDSA(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
public String getAlgorithm() {
|
||||
return SignatureMethod.DSA_SHA1;
|
||||
}
|
||||
String getJCAAlgorithm() {
|
||||
return "SHA1withDSA";
|
||||
}
|
||||
Type getAlgorithmType() {
|
||||
return Type.DSA;
|
||||
}
|
||||
}
|
||||
|
||||
static final class SHA256withDSA extends DOMSignatureMethod {
|
||||
SHA256withDSA(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA256withDSA(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
public String getAlgorithm() {
|
||||
return DSA_SHA256;
|
||||
}
|
||||
String getJCAAlgorithm() {
|
||||
return "SHA256withDSA";
|
||||
}
|
||||
Type getAlgorithmType() {
|
||||
return Type.DSA;
|
||||
}
|
||||
}
|
||||
|
||||
static final class SHA1withECDSA extends DOMSignatureMethod {
|
||||
SHA1withECDSA(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA1withECDSA(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
public String getAlgorithm() {
|
||||
return ECDSA_SHA1;
|
||||
}
|
||||
String getJCAAlgorithm() {
|
||||
return "SHA1withECDSA";
|
||||
}
|
||||
Type getAlgorithmType() {
|
||||
return Type.ECDSA;
|
||||
}
|
||||
}
|
||||
|
||||
static final class SHA224withECDSA extends DOMSignatureMethod {
|
||||
SHA224withECDSA(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA224withECDSA(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
@Override
|
||||
public String getAlgorithm() {
|
||||
return ECDSA_SHA224;
|
||||
}
|
||||
@Override
|
||||
String getJCAAlgorithm() {
|
||||
return "SHA224withECDSA";
|
||||
}
|
||||
@Override
|
||||
Type getAlgorithmType() {
|
||||
return Type.ECDSA;
|
||||
}
|
||||
}
|
||||
|
||||
static final class SHA256withECDSA extends DOMSignatureMethod {
|
||||
SHA256withECDSA(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA256withECDSA(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
public String getAlgorithm() {
|
||||
return ECDSA_SHA256;
|
||||
}
|
||||
String getJCAAlgorithm() {
|
||||
return "SHA256withECDSA";
|
||||
}
|
||||
Type getAlgorithmType() {
|
||||
return Type.ECDSA;
|
||||
}
|
||||
}
|
||||
|
||||
static final class SHA384withECDSA extends DOMSignatureMethod {
|
||||
SHA384withECDSA(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA384withECDSA(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
public String getAlgorithm() {
|
||||
return ECDSA_SHA384;
|
||||
}
|
||||
String getJCAAlgorithm() {
|
||||
return "SHA384withECDSA";
|
||||
}
|
||||
Type getAlgorithmType() {
|
||||
return Type.ECDSA;
|
||||
}
|
||||
}
|
||||
|
||||
static final class SHA512withECDSA extends DOMSignatureMethod {
|
||||
SHA512withECDSA(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
SHA512withECDSA(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
public String getAlgorithm() {
|
||||
return ECDSA_SHA512;
|
||||
}
|
||||
String getJCAAlgorithm() {
|
||||
return "SHA512withECDSA";
|
||||
}
|
||||
Type getAlgorithmType() {
|
||||
return Type.ECDSA;
|
||||
}
|
||||
}
|
||||
|
||||
static final class RIPEMD160withECDSA extends DOMSignatureMethod {
|
||||
RIPEMD160withECDSA(AlgorithmParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
super(params);
|
||||
}
|
||||
RIPEMD160withECDSA(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
@Override
|
||||
public String getAlgorithm() {
|
||||
return ECDSA_RIPEMD160;
|
||||
}
|
||||
@Override
|
||||
String getJCAAlgorithm() {
|
||||
return "RIPEMD160withECDSA";
|
||||
}
|
||||
@Override
|
||||
Type getAlgorithmType() {
|
||||
return Type.ECDSA;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMSignatureProperties.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* DOM-based implementation of SignatureProperties.
|
||||
*
|
||||
*/
|
||||
public final class DOMSignatureProperties extends DOMStructure
|
||||
implements SignatureProperties {
|
||||
|
||||
private final String id;
|
||||
private final List<SignatureProperty> properties;
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMSignatureProperties} from the specified
|
||||
* parameters.
|
||||
*
|
||||
* @param properties a list of one or more {@link SignatureProperty}s. The
|
||||
* list is defensively copied to protect against subsequent modification.
|
||||
* @param id the Id (may be {@code null})
|
||||
* @throws ClassCastException if {@code properties} contains any
|
||||
* entries that are not of type {@link SignatureProperty}
|
||||
* @throws IllegalArgumentException if {@code properties} is empty
|
||||
* @throws NullPointerException if {@code properties}
|
||||
*/
|
||||
public DOMSignatureProperties(List<? extends SignatureProperty> properties,
|
||||
String id)
|
||||
{
|
||||
if (properties == null) {
|
||||
throw new NullPointerException("properties cannot be null");
|
||||
} else if (properties.isEmpty()) {
|
||||
throw new IllegalArgumentException("properties cannot be empty");
|
||||
} else {
|
||||
this.properties = Collections.unmodifiableList(
|
||||
new ArrayList<>(properties));
|
||||
for (int i = 0, size = this.properties.size(); i < size; i++) {
|
||||
if (!(this.properties.get(i) instanceof SignatureProperty)) {
|
||||
throw new ClassCastException
|
||||
("properties["+i+"] is not a valid type");
|
||||
}
|
||||
}
|
||||
}
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMSignatureProperties} from an element.
|
||||
*
|
||||
* @param propsElem a SignatureProperties element
|
||||
* @throws MarshalException if a marshalling error occurs
|
||||
*/
|
||||
public DOMSignatureProperties(Element propsElem)
|
||||
throws MarshalException
|
||||
{
|
||||
// unmarshal attributes
|
||||
Attr attr = propsElem.getAttributeNodeNS(null, "Id");
|
||||
if (attr != null) {
|
||||
id = attr.getValue();
|
||||
propsElem.setIdAttributeNode(attr, true);
|
||||
} else {
|
||||
id = null;
|
||||
}
|
||||
|
||||
List<SignatureProperty> newProperties = new ArrayList<>();
|
||||
Node firstChild = propsElem.getFirstChild();
|
||||
while (firstChild != null) {
|
||||
if (firstChild.getNodeType() == Node.ELEMENT_NODE) {
|
||||
String name = firstChild.getLocalName();
|
||||
String namespace = firstChild.getNamespaceURI();
|
||||
if (!"SignatureProperty".equals(name) || !XMLSignature.XMLNS.equals(namespace)) {
|
||||
throw new MarshalException("Invalid element name: " + namespace + ":" + name +
|
||||
", expected SignatureProperty");
|
||||
}
|
||||
newProperties.add(new DOMSignatureProperty((Element)firstChild));
|
||||
}
|
||||
firstChild = firstChild.getNextSibling();
|
||||
}
|
||||
if (newProperties.isEmpty()) {
|
||||
throw new MarshalException("properties cannot be empty");
|
||||
} else {
|
||||
this.properties = Collections.unmodifiableList(newProperties);
|
||||
}
|
||||
}
|
||||
|
||||
public List<SignatureProperty> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
Document ownerDoc = DOMUtils.getOwnerDocument(parent);
|
||||
Element propsElem = DOMUtils.createElement(ownerDoc,
|
||||
"SignatureProperties",
|
||||
XMLSignature.XMLNS,
|
||||
dsPrefix);
|
||||
|
||||
// set attributes
|
||||
DOMUtils.setAttributeID(propsElem, "Id", id);
|
||||
|
||||
// create and append any properties
|
||||
for (SignatureProperty property : properties) {
|
||||
((DOMSignatureProperty)property).marshal(propsElem, dsPrefix,
|
||||
context);
|
||||
}
|
||||
|
||||
parent.appendChild(propsElem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(o instanceof SignatureProperties)) {
|
||||
return false;
|
||||
}
|
||||
SignatureProperties osp = (SignatureProperties)o;
|
||||
|
||||
boolean idsEqual = id == null ? osp.getId() == null
|
||||
: id.equals(osp.getId());
|
||||
|
||||
return properties.equals(osp.getProperties()) && idsEqual;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 17;
|
||||
if (id != null) {
|
||||
result = 31 * result + id.hashCode();
|
||||
}
|
||||
result = 31 * result + properties.hashCode();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMSignatureProperty.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* DOM-based implementation of SignatureProperty.
|
||||
*
|
||||
*/
|
||||
public final class DOMSignatureProperty extends DOMStructure
|
||||
implements SignatureProperty {
|
||||
|
||||
private final String id;
|
||||
private final String target;
|
||||
private final List<XMLStructure> content;
|
||||
|
||||
/**
|
||||
* Creates a {@code SignatureProperty} from the specified parameters.
|
||||
*
|
||||
* @param content a list of one or more {@link XMLStructure}s. The list
|
||||
* is defensively copied to protect against subsequent modification.
|
||||
* @param target the target URI
|
||||
* @param id the Id (may be {@code null})
|
||||
* @throws ClassCastException if {@code content} contains any
|
||||
* entries that are not of type {@link XMLStructure}
|
||||
* @throws IllegalArgumentException if {@code content} is empty
|
||||
* @throws NullPointerException if {@code content} or
|
||||
* {@code target} is {@code null}
|
||||
*/
|
||||
public DOMSignatureProperty(List<? extends XMLStructure> content,
|
||||
String target, String id)
|
||||
{
|
||||
if (target == null) {
|
||||
throw new NullPointerException("target cannot be null");
|
||||
} else if (content == null) {
|
||||
throw new NullPointerException("content cannot be null");
|
||||
} else if (content.isEmpty()) {
|
||||
throw new IllegalArgumentException("content cannot be empty");
|
||||
} else {
|
||||
this.content = Collections.unmodifiableList(
|
||||
new ArrayList<>(content));
|
||||
for (int i = 0, size = this.content.size(); i < size; i++) {
|
||||
if (!(this.content.get(i) instanceof XMLStructure)) {
|
||||
throw new ClassCastException
|
||||
("content["+i+"] is not a valid type");
|
||||
}
|
||||
}
|
||||
}
|
||||
this.target = target;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMSignatureProperty} from an element.
|
||||
*
|
||||
* @param propElem a SignatureProperty element
|
||||
*/
|
||||
public DOMSignatureProperty(Element propElem)
|
||||
throws MarshalException
|
||||
{
|
||||
// unmarshal attributes
|
||||
target = DOMUtils.getAttributeValue(propElem, "Target");
|
||||
if (target == null) {
|
||||
throw new MarshalException("target cannot be null");
|
||||
}
|
||||
Attr attr = propElem.getAttributeNodeNS(null, "Id");
|
||||
if (attr != null) {
|
||||
id = attr.getValue();
|
||||
propElem.setIdAttributeNode(attr, true);
|
||||
} else {
|
||||
id = null;
|
||||
}
|
||||
|
||||
List<XMLStructure> newContent = new ArrayList<>();
|
||||
Node firstChild = propElem.getFirstChild();
|
||||
while (firstChild != null) {
|
||||
newContent.add(new javax.xml.crypto.dom.DOMStructure(firstChild));
|
||||
firstChild = firstChild.getNextSibling();
|
||||
}
|
||||
if (newContent.isEmpty()) {
|
||||
throw new MarshalException("content cannot be empty");
|
||||
} else {
|
||||
this.content = Collections.unmodifiableList(newContent);
|
||||
}
|
||||
}
|
||||
|
||||
public List<XMLStructure> getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
Document ownerDoc = DOMUtils.getOwnerDocument(parent);
|
||||
Element propElem = DOMUtils.createElement(ownerDoc, "SignatureProperty",
|
||||
XMLSignature.XMLNS, dsPrefix);
|
||||
|
||||
// set attributes
|
||||
DOMUtils.setAttributeID(propElem, "Id", id);
|
||||
DOMUtils.setAttribute(propElem, "Target", target);
|
||||
|
||||
// create and append any elements and mixed content
|
||||
for (XMLStructure property : content) {
|
||||
DOMUtils.appendChild(propElem,
|
||||
((javax.xml.crypto.dom.DOMStructure)property).getNode());
|
||||
}
|
||||
|
||||
parent.appendChild(propElem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(o instanceof SignatureProperty)) {
|
||||
return false;
|
||||
}
|
||||
SignatureProperty osp = (SignatureProperty)o;
|
||||
|
||||
boolean idsEqual = id == null ? osp.getId() == null
|
||||
: id.equals(osp.getId());
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<XMLStructure> ospContent = osp.getContent();
|
||||
return equalsContent(ospContent) &&
|
||||
target.equals(osp.getTarget()) && idsEqual;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 17;
|
||||
if (id != null) {
|
||||
result = 31 * result + id.hashCode();
|
||||
}
|
||||
result = 31 * result + target.hashCode();
|
||||
result = 31 * result + content.hashCode();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean equalsContent(List<XMLStructure> otherContent) {
|
||||
int osize = otherContent.size();
|
||||
if (content.size() != osize) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < osize; i++) {
|
||||
XMLStructure oxs = otherContent.get(i);
|
||||
XMLStructure xs = content.get(i);
|
||||
if (oxs instanceof javax.xml.crypto.dom.DOMStructure) {
|
||||
if (!(xs instanceof javax.xml.crypto.dom.DOMStructure)) {
|
||||
return false;
|
||||
}
|
||||
Node onode = ((javax.xml.crypto.dom.DOMStructure)oxs).getNode();
|
||||
Node node = ((javax.xml.crypto.dom.DOMStructure)xs).getNode();
|
||||
if (!DOMUtils.nodesEqual(node, onode)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!(xs.equals(oxs))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
303
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java
Normal file
303
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java
Normal file
@@ -0,0 +1,303 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMSignedInfo.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
import java.security.Provider;
|
||||
import java.util.*;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import com.sun.org.apache.xml.internal.security.utils.UnsyncBufferedOutputStream;
|
||||
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
|
||||
|
||||
/**
|
||||
* DOM-based implementation of SignedInfo.
|
||||
*
|
||||
*/
|
||||
public final class DOMSignedInfo extends DOMStructure implements SignedInfo {
|
||||
|
||||
private static final com.sun.org.slf4j.internal.Logger LOG =
|
||||
com.sun.org.slf4j.internal.LoggerFactory.getLogger(DOMSignedInfo.class);
|
||||
|
||||
private List<Reference> references;
|
||||
private CanonicalizationMethod canonicalizationMethod;
|
||||
private SignatureMethod signatureMethod;
|
||||
private String id;
|
||||
private Document ownerDoc;
|
||||
private Element localSiElem;
|
||||
private InputStream canonData;
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMSignedInfo} from the specified parameters. Use
|
||||
* this constructor when the {@code Id} is not specified.
|
||||
*
|
||||
* @param cm the canonicalization method
|
||||
* @param sm the signature method
|
||||
* @param references the list of references. The list is copied.
|
||||
* @throws NullPointerException if
|
||||
* {@code cm}, {@code sm}, or {@code references} is
|
||||
* {@code null}
|
||||
* @throws IllegalArgumentException if {@code references} is empty
|
||||
* @throws ClassCastException if any of the references are not of
|
||||
* type {@code Reference}
|
||||
*/
|
||||
public DOMSignedInfo(CanonicalizationMethod cm, SignatureMethod sm,
|
||||
List<? extends Reference> references) {
|
||||
if (cm == null || sm == null || references == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
this.canonicalizationMethod = cm;
|
||||
this.signatureMethod = sm;
|
||||
this.references = Collections.unmodifiableList(
|
||||
new ArrayList<>(references));
|
||||
if (this.references.isEmpty()) {
|
||||
throw new IllegalArgumentException("list of references must " +
|
||||
"contain at least one entry");
|
||||
}
|
||||
for (int i = 0, size = this.references.size(); i < size; i++) {
|
||||
Object obj = this.references.get(i);
|
||||
if (!(obj instanceof Reference)) {
|
||||
throw new ClassCastException("list of references contains " +
|
||||
"an illegal type");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMSignedInfo} from the specified parameters.
|
||||
*
|
||||
* @param cm the canonicalization method
|
||||
* @param sm the signature method
|
||||
* @param references the list of references. The list is copied.
|
||||
* @param id an optional identifer that will allow this
|
||||
* {@code SignedInfo} to be referenced by other signatures and
|
||||
* objects
|
||||
* @throws NullPointerException if {@code cm}, {@code sm},
|
||||
* or {@code references} is {@code null}
|
||||
* @throws IllegalArgumentException if {@code references} is empty
|
||||
* @throws ClassCastException if any of the references are not of
|
||||
* type {@code Reference}
|
||||
*/
|
||||
public DOMSignedInfo(CanonicalizationMethod cm, SignatureMethod sm,
|
||||
List<? extends Reference> references, String id) {
|
||||
this(cm, sm, references);
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMSignedInfo} from an element.
|
||||
*
|
||||
* @param siElem a SignedInfo element
|
||||
*/
|
||||
public DOMSignedInfo(Element siElem, XMLCryptoContext context, Provider provider)
|
||||
throws MarshalException {
|
||||
localSiElem = siElem;
|
||||
ownerDoc = siElem.getOwnerDocument();
|
||||
|
||||
// get Id attribute, if specified
|
||||
id = DOMUtils.getAttributeValue(siElem, "Id");
|
||||
|
||||
// unmarshal CanonicalizationMethod
|
||||
Element cmElem = DOMUtils.getFirstChildElement(siElem,
|
||||
"CanonicalizationMethod",
|
||||
XMLSignature.XMLNS);
|
||||
canonicalizationMethod = new DOMCanonicalizationMethod(cmElem, context,
|
||||
provider);
|
||||
|
||||
// unmarshal SignatureMethod
|
||||
Element smElem = DOMUtils.getNextSiblingElement(cmElem,
|
||||
"SignatureMethod",
|
||||
XMLSignature.XMLNS);
|
||||
signatureMethod = DOMSignatureMethod.unmarshal(smElem);
|
||||
|
||||
boolean secVal = Utils.secureValidation(context);
|
||||
|
||||
String signatureMethodAlgorithm = signatureMethod.getAlgorithm();
|
||||
if (secVal && Policy.restrictAlg(signatureMethodAlgorithm)) {
|
||||
throw new MarshalException(
|
||||
"It is forbidden to use algorithm " + signatureMethodAlgorithm +
|
||||
" when secure validation is enabled"
|
||||
);
|
||||
}
|
||||
|
||||
// unmarshal References
|
||||
ArrayList<Reference> refList = new ArrayList<>(5);
|
||||
Element refElem = DOMUtils.getNextSiblingElement(smElem, "Reference", XMLSignature.XMLNS);
|
||||
refList.add(new DOMReference(refElem, context, provider));
|
||||
|
||||
refElem = DOMUtils.getNextSiblingElement(refElem);
|
||||
while (refElem != null) {
|
||||
String name = refElem.getLocalName();
|
||||
String namespace = refElem.getNamespaceURI();
|
||||
if (!"Reference".equals(name) || !XMLSignature.XMLNS.equals(namespace)) {
|
||||
throw new MarshalException("Invalid element name: " +
|
||||
namespace + ":" + name + ", expected Reference");
|
||||
}
|
||||
refList.add(new DOMReference(refElem, context, provider));
|
||||
if (secVal && Policy.restrictNumReferences(refList.size())) {
|
||||
String error = "A maxiumum of " + Policy.maxReferences()
|
||||
+ " references per Manifest are allowed when"
|
||||
+ " secure validation is enabled";
|
||||
throw new MarshalException(error);
|
||||
}
|
||||
refElem = DOMUtils.getNextSiblingElement(refElem);
|
||||
}
|
||||
references = Collections.unmodifiableList(refList);
|
||||
}
|
||||
|
||||
public CanonicalizationMethod getCanonicalizationMethod() {
|
||||
return canonicalizationMethod;
|
||||
}
|
||||
|
||||
public SignatureMethod getSignatureMethod() {
|
||||
return signatureMethod;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public List<Reference> getReferences() {
|
||||
return references;
|
||||
}
|
||||
|
||||
public InputStream getCanonicalizedData() {
|
||||
return canonData;
|
||||
}
|
||||
|
||||
public void canonicalize(XMLCryptoContext context, ByteArrayOutputStream bos)
|
||||
throws XMLSignatureException {
|
||||
if (context == null) {
|
||||
throw new NullPointerException("context cannot be null");
|
||||
}
|
||||
|
||||
DOMSubTreeData subTree = new DOMSubTreeData(localSiElem, true);
|
||||
try (OutputStream os = new UnsyncBufferedOutputStream(bos)) {
|
||||
((DOMCanonicalizationMethod)
|
||||
canonicalizationMethod).canonicalize(subTree, context, os);
|
||||
|
||||
os.flush();
|
||||
|
||||
byte[] signedInfoBytes = bos.toByteArray();
|
||||
|
||||
// this whole block should only be done if LOGging is enabled
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Canonicalized SignedInfo:");
|
||||
StringBuilder sb = new StringBuilder(signedInfoBytes.length);
|
||||
for (int i = 0; i < signedInfoBytes.length; i++) {
|
||||
sb.append((char)signedInfoBytes[i]);
|
||||
}
|
||||
LOG.debug(sb.toString());
|
||||
LOG.debug("Data to be signed/verified:" + XMLUtils.encodeToString(signedInfoBytes));
|
||||
}
|
||||
|
||||
this.canonData = new ByteArrayInputStream(signedInfoBytes);
|
||||
} catch (TransformException te) {
|
||||
throw new XMLSignatureException(te);
|
||||
} catch (IOException e) {
|
||||
LOG.debug(e.getMessage(), e);
|
||||
// Impossible
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
ownerDoc = DOMUtils.getOwnerDocument(parent);
|
||||
Element siElem = DOMUtils.createElement(ownerDoc, "SignedInfo",
|
||||
XMLSignature.XMLNS, dsPrefix);
|
||||
|
||||
// create and append CanonicalizationMethod element
|
||||
DOMCanonicalizationMethod dcm =
|
||||
(DOMCanonicalizationMethod)canonicalizationMethod;
|
||||
dcm.marshal(siElem, dsPrefix, context);
|
||||
|
||||
// create and append SignatureMethod element
|
||||
((DOMStructure)signatureMethod).marshal(siElem, dsPrefix, context);
|
||||
|
||||
// create and append Reference elements
|
||||
for (Reference reference : references) {
|
||||
((DOMReference)reference).marshal(siElem, dsPrefix, context);
|
||||
}
|
||||
|
||||
// append Id attribute
|
||||
DOMUtils.setAttributeID(siElem, "Id", id);
|
||||
|
||||
parent.appendChild(siElem);
|
||||
localSiElem = siElem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(o instanceof SignedInfo)) {
|
||||
return false;
|
||||
}
|
||||
SignedInfo osi = (SignedInfo)o;
|
||||
|
||||
boolean idEqual = id == null ? osi.getId() == null
|
||||
: id.equals(osi.getId());
|
||||
|
||||
return canonicalizationMethod.equals(osi.getCanonicalizationMethod())
|
||||
&& signatureMethod.equals(osi.getSignatureMethod()) &&
|
||||
references.equals(osi.getReferences()) && idEqual;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<Reference> getSignedInfoReferences(SignedInfo si) {
|
||||
return si.getReferences();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 17;
|
||||
if (id != null) {
|
||||
result = 31 * result + id.hashCode();
|
||||
}
|
||||
result = 31 * result + canonicalizationMethod.hashCode();
|
||||
result = 31 * result + signatureMethod.hashCode();
|
||||
result = 31 * result + references.hashCode();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
52
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMStructure.java
Normal file
52
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMStructure.java
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMStructure.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import javax.xml.crypto.MarshalException;
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* DOM-based abstract implementation of XMLStructure.
|
||||
*
|
||||
*/
|
||||
public abstract class DOMStructure implements XMLStructure {
|
||||
|
||||
public final boolean isFeatureSupported(String feature) {
|
||||
if (feature == null) {
|
||||
throw new NullPointerException();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void marshal(Node parent, String dsPrefix,
|
||||
DOMCryptoContext context) throws MarshalException;
|
||||
}
|
||||
182
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMSubTreeData.java
Normal file
182
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMSubTreeData.java
Normal file
@@ -0,0 +1,182 @@
|
||||
/*
|
||||
* 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, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import javax.xml.crypto.NodeSetData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.NoSuchElementException;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* This is a subtype of NodeSetData that represents a dereferenced
|
||||
* same-document URI as the root of a subdocument. The main reason is
|
||||
* for efficiency and performance, as some transforms can operate
|
||||
* directly on the subdocument and there is no need to convert it
|
||||
* first to an XPath node-set.
|
||||
*/
|
||||
public class DOMSubTreeData implements NodeSetData {
|
||||
|
||||
private boolean excludeComments;
|
||||
private Node root;
|
||||
|
||||
public DOMSubTreeData(Node root, boolean excludeComments) {
|
||||
this.root = root;
|
||||
this.excludeComments = excludeComments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Node> iterator() {
|
||||
return new DelayedNodeIterator(root, excludeComments);
|
||||
}
|
||||
|
||||
public Node getRoot() {
|
||||
return root;
|
||||
}
|
||||
|
||||
public boolean excludeComments() {
|
||||
return excludeComments;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is an Iterator that contains a backing node-set that is
|
||||
* not populated until the caller first attempts to advance the iterator.
|
||||
*/
|
||||
static class DelayedNodeIterator implements Iterator<Node> {
|
||||
private Node root;
|
||||
private List<Node> nodeSet;
|
||||
private ListIterator<Node> li;
|
||||
private boolean withComments;
|
||||
|
||||
DelayedNodeIterator(Node root, boolean excludeComments) {
|
||||
this.root = root;
|
||||
this.withComments = !excludeComments;
|
||||
}
|
||||
|
||||
public boolean hasNext() {
|
||||
if (nodeSet == null) {
|
||||
nodeSet = dereferenceSameDocumentURI(root);
|
||||
li = nodeSet.listIterator();
|
||||
}
|
||||
return li.hasNext();
|
||||
}
|
||||
|
||||
public Node next() {
|
||||
if (nodeSet == null) {
|
||||
nodeSet = dereferenceSameDocumentURI(root);
|
||||
li = nodeSet.listIterator();
|
||||
}
|
||||
if (li.hasNext()) {
|
||||
return li.next();
|
||||
} else {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Dereferences a same-document URI fragment.
|
||||
*
|
||||
* @param node the node (document or element) referenced by the
|
||||
* URI fragment. If null, returns an empty set.
|
||||
* @return a set of nodes (minus any comment nodes)
|
||||
*/
|
||||
private List<Node> dereferenceSameDocumentURI(Node node) {
|
||||
List<Node> nodes = new ArrayList<>();
|
||||
if (node != null) {
|
||||
nodeSetMinusCommentNodes(node, nodes, null);
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively traverses the subtree, and returns an XPath-equivalent
|
||||
* node-set of all nodes traversed, excluding any comment nodes,
|
||||
* if specified.
|
||||
*
|
||||
* @param node the node to traverse
|
||||
* @param nodeSet the set of nodes traversed so far
|
||||
* @param the previous sibling node
|
||||
*/
|
||||
@SuppressWarnings("fallthrough")
|
||||
private void nodeSetMinusCommentNodes(Node node, List<Node> nodeSet,
|
||||
Node prevSibling)
|
||||
{
|
||||
switch (node.getNodeType()) {
|
||||
case Node.ELEMENT_NODE :
|
||||
NamedNodeMap attrs = node.getAttributes();
|
||||
if (attrs != null) {
|
||||
for (int i = 0, len = attrs.getLength(); i < len; i++) {
|
||||
nodeSet.add(attrs.item(i));
|
||||
}
|
||||
}
|
||||
nodeSet.add(node);
|
||||
Node pSibling = null;
|
||||
for (Node child = node.getFirstChild(); child != null;
|
||||
child = child.getNextSibling()) {
|
||||
nodeSetMinusCommentNodes(child, nodeSet, pSibling);
|
||||
pSibling = child;
|
||||
}
|
||||
break;
|
||||
case Node.DOCUMENT_NODE :
|
||||
pSibling = null;
|
||||
for (Node child = node.getFirstChild(); child != null;
|
||||
child = child.getNextSibling()) {
|
||||
nodeSetMinusCommentNodes(child, nodeSet, pSibling);
|
||||
pSibling = child;
|
||||
}
|
||||
break;
|
||||
case Node.TEXT_NODE :
|
||||
case Node.CDATA_SECTION_NODE:
|
||||
// emulate XPath which only returns the first node in
|
||||
// contiguous text/cdata nodes
|
||||
if (prevSibling != null &&
|
||||
(prevSibling.getNodeType() == Node.TEXT_NODE ||
|
||||
prevSibling.getNodeType() == Node.CDATA_SECTION_NODE)) {
|
||||
return;
|
||||
}
|
||||
nodeSet.add(node);
|
||||
break;
|
||||
case Node.PROCESSING_INSTRUCTION_NODE :
|
||||
nodeSet.add(node);
|
||||
break;
|
||||
case Node.COMMENT_NODE:
|
||||
if (withComments) {
|
||||
nodeSet.add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
227
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMTransform.java
Normal file
227
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMTransform.java
Normal file
@@ -0,0 +1,227 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMTransform.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.Provider;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
|
||||
import javax.xml.crypto.Data;
|
||||
import javax.xml.crypto.MarshalException;
|
||||
import javax.xml.crypto.XMLCryptoContext;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dsig.Transform;
|
||||
import javax.xml.crypto.dsig.TransformException;
|
||||
import javax.xml.crypto.dsig.TransformService;
|
||||
import javax.xml.crypto.dsig.XMLSignature;
|
||||
import javax.xml.crypto.dsig.dom.DOMSignContext;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* DOM-based abstract implementation of Transform.
|
||||
*
|
||||
*/
|
||||
public class DOMTransform extends DOMStructure implements Transform {
|
||||
|
||||
protected TransformService spi;
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMTransform}.
|
||||
*
|
||||
* @param spi the TransformService
|
||||
*/
|
||||
public DOMTransform(TransformService spi) {
|
||||
this.spi = spi;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMTransform} from an element. It unmarshals any
|
||||
* algorithm-specific input parameters.
|
||||
*
|
||||
* @param transElem a Transform element
|
||||
*/
|
||||
public DOMTransform(Element transElem, XMLCryptoContext context,
|
||||
Provider provider)
|
||||
throws MarshalException
|
||||
{
|
||||
String algorithm = DOMUtils.getAttributeValue(transElem, "Algorithm");
|
||||
|
||||
if (provider == null) {
|
||||
try {
|
||||
spi = TransformService.getInstance(algorithm, "DOM");
|
||||
} catch (NoSuchAlgorithmException e1) {
|
||||
throw new MarshalException(e1);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
spi = TransformService.getInstance(algorithm, "DOM", provider);
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
try {
|
||||
spi = TransformService.getInstance(algorithm, "DOM");
|
||||
} catch (NoSuchAlgorithmException e2) {
|
||||
throw new MarshalException(e2);
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
spi.init(new javax.xml.crypto.dom.DOMStructure(transElem), context);
|
||||
} catch (InvalidAlgorithmParameterException iape) {
|
||||
throw new MarshalException(iape);
|
||||
}
|
||||
}
|
||||
|
||||
public final AlgorithmParameterSpec getParameterSpec() {
|
||||
return spi.getParameterSpec();
|
||||
}
|
||||
|
||||
public final String getAlgorithm() {
|
||||
return spi.getAlgorithm();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method marshals any algorithm-specific parameters.
|
||||
*/
|
||||
@Override
|
||||
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
Document ownerDoc = DOMUtils.getOwnerDocument(parent);
|
||||
|
||||
Element transformElem = null;
|
||||
if (parent.getLocalName().equals("Transforms")) {
|
||||
transformElem = DOMUtils.createElement(ownerDoc, "Transform",
|
||||
XMLSignature.XMLNS,
|
||||
dsPrefix);
|
||||
} else {
|
||||
transformElem = DOMUtils.createElement(ownerDoc,
|
||||
"CanonicalizationMethod",
|
||||
XMLSignature.XMLNS,
|
||||
dsPrefix);
|
||||
}
|
||||
DOMUtils.setAttribute(transformElem, "Algorithm", getAlgorithm());
|
||||
|
||||
spi.marshalParams(new javax.xml.crypto.dom.DOMStructure(transformElem),
|
||||
context);
|
||||
|
||||
parent.appendChild(transformElem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms the specified data using the underlying transform algorithm.
|
||||
*
|
||||
* @param data the data to be transformed
|
||||
* @param xc the {@code XMLCryptoContext} containing
|
||||
* additional context (may be {@code null} if not applicable)
|
||||
* @return the transformed data
|
||||
* @throws NullPointerException if {@code data} is {@code null}
|
||||
* @throws XMLSignatureException if an unexpected error occurs while
|
||||
* executing the transform
|
||||
*/
|
||||
public Data transform(Data data, XMLCryptoContext xc)
|
||||
throws TransformException
|
||||
{
|
||||
return spi.transform(data, xc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms the specified data using the underlying transform algorithm.
|
||||
*
|
||||
* @param data the data to be transformed
|
||||
* @param xc the {@code XMLCryptoContext} containing
|
||||
* additional context (may be {@code null} if not applicable)
|
||||
* @param os the {@code OutputStream} that should be used to write
|
||||
* the transformed data to
|
||||
* @return the transformed data
|
||||
* @throws NullPointerException if {@code data} is {@code null}
|
||||
* @throws XMLSignatureException if an unexpected error occurs while
|
||||
* executing the transform
|
||||
*/
|
||||
public Data transform(Data data, XMLCryptoContext xc, OutputStream os)
|
||||
throws TransformException
|
||||
{
|
||||
return spi.transform(data, xc, os);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(o instanceof Transform)) {
|
||||
return false;
|
||||
}
|
||||
Transform otransform = (Transform)o;
|
||||
|
||||
return getAlgorithm().equals(otransform.getAlgorithm()) &&
|
||||
DOMUtils.paramsEqual(getParameterSpec(),
|
||||
otransform.getParameterSpec());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 17;
|
||||
result = 31 * result + getAlgorithm().hashCode();
|
||||
AlgorithmParameterSpec spec = getParameterSpec();
|
||||
if (spec != null) {
|
||||
result = 31 * result + spec.hashCode();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms the specified data using the underlying transform algorithm.
|
||||
* This method invokes the {@link #marshal marshal} method and passes it
|
||||
* the specified {@code DOMSignContext} before transforming the data.
|
||||
*
|
||||
* @param data the data to be transformed
|
||||
* @param sc the {@code XMLCryptoContext} containing
|
||||
* additional context (may be {@code null} if not applicable)
|
||||
* @param context the marshalling context
|
||||
* @return the transformed data
|
||||
* @throws MarshalException if an exception occurs while marshalling
|
||||
* @throws NullPointerException if {@code data} or {@code context}
|
||||
* is {@code null}
|
||||
* @throws XMLSignatureException if an unexpected error occurs while
|
||||
* executing the transform
|
||||
*/
|
||||
Data transform(Data data, XMLCryptoContext xc, DOMSignContext context)
|
||||
throws MarshalException, TransformException
|
||||
{
|
||||
marshal(context.getParent(),
|
||||
DOMUtils.getSignaturePrefix(context), context);
|
||||
return transform(data, xc);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMURIDereferencer.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.Init;
|
||||
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
|
||||
import com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolver;
|
||||
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dom.*;
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* DOM-based implementation of URIDereferencer.
|
||||
*
|
||||
*/
|
||||
public final class DOMURIDereferencer implements URIDereferencer {
|
||||
|
||||
static final URIDereferencer INSTANCE = new DOMURIDereferencer();
|
||||
|
||||
private DOMURIDereferencer() {
|
||||
// need to call com.sun.org.apache.xml.internal.security.Init.init()
|
||||
// before calling any apache security code
|
||||
Init.init();
|
||||
}
|
||||
|
||||
public Data dereference(URIReference uriRef, XMLCryptoContext context)
|
||||
throws URIReferenceException {
|
||||
|
||||
if (uriRef == null) {
|
||||
throw new NullPointerException("uriRef cannot be null");
|
||||
}
|
||||
if (context == null) {
|
||||
throw new NullPointerException("context cannot be null");
|
||||
}
|
||||
|
||||
DOMURIReference domRef = (DOMURIReference) uriRef;
|
||||
Attr uriAttr = (Attr) domRef.getHere();
|
||||
String uri = uriRef.getURI();
|
||||
DOMCryptoContext dcc = (DOMCryptoContext) context;
|
||||
String baseURI = context.getBaseURI();
|
||||
|
||||
boolean secVal = Utils.secureValidation(context);
|
||||
|
||||
if (secVal) {
|
||||
try {
|
||||
if (Policy.restrictReferenceUriScheme(uri)) {
|
||||
throw new URIReferenceException(
|
||||
"URI " + uri + " is forbidden when secure validation is enabled");
|
||||
}
|
||||
|
||||
if (uri != null && !uri.isEmpty() && uri.charAt(0) != '#' && URI.create(uri).getScheme() == null) {
|
||||
// beseURI will be used to dereference a relative uri
|
||||
try {
|
||||
if (Policy.restrictReferenceUriScheme(baseURI)) {
|
||||
throw new URIReferenceException(
|
||||
"Base URI " + baseURI + " is forbidden when secure validation is enabled");
|
||||
}
|
||||
} catch (IllegalArgumentException e) { // thrown by Policy.restrictReferenceUriScheme
|
||||
throw new URIReferenceException("Invalid base URI " + baseURI);
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException e) { // thrown by Policy.restrictReferenceUriScheme or URI.create
|
||||
throw new URIReferenceException("Invalid URI " + uri);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if same-document URI and already registered on the context
|
||||
if (uri != null && uri.length() != 0 && uri.charAt(0) == '#') {
|
||||
String id = uri.substring(1);
|
||||
|
||||
if (id.startsWith("xpointer(id(")) {
|
||||
int i1 = id.indexOf('\'');
|
||||
int i2 = id.indexOf('\'', i1+1);
|
||||
id = id.substring(i1+1, i2);
|
||||
}
|
||||
|
||||
// check if element is registered by Id
|
||||
Node referencedElem = uriAttr.getOwnerDocument().getElementById(id);
|
||||
if (referencedElem == null) {
|
||||
// see if element is registered in DOMCryptoContext
|
||||
referencedElem = dcc.getElementById(id);
|
||||
}
|
||||
if (referencedElem != null) {
|
||||
if (secVal && Policy.restrictDuplicateIds()) {
|
||||
Element start = referencedElem.getOwnerDocument().getDocumentElement();
|
||||
if (!XMLUtils.protectAgainstWrappingAttack(start, (Element)referencedElem, id)) {
|
||||
String error = "Multiple Elements with the same ID "
|
||||
+ id + " detected when secure validation"
|
||||
+ " is enabled";
|
||||
throw new URIReferenceException(error);
|
||||
}
|
||||
}
|
||||
|
||||
XMLSignatureInput result = new XMLSignatureInput(referencedElem);
|
||||
result.setSecureValidation(secVal);
|
||||
if (!uri.substring(1).startsWith("xpointer(id(")) {
|
||||
result.setExcludeComments(true);
|
||||
}
|
||||
|
||||
result.setMIMEType("text/xml");
|
||||
if (baseURI != null && baseURI.length() > 0) {
|
||||
result.setSourceURI(baseURI.concat(uriAttr.getNodeValue()));
|
||||
} else {
|
||||
result.setSourceURI(uriAttr.getNodeValue());
|
||||
}
|
||||
return new ApacheNodeSetData(result);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
ResourceResolver apacheResolver =
|
||||
ResourceResolver.getInstance(uriAttr, baseURI, secVal);
|
||||
XMLSignatureInput in = apacheResolver.resolve(uriAttr, baseURI, secVal);
|
||||
if (in.isOctetStream()) {
|
||||
return new ApacheOctetStreamData(in);
|
||||
} else {
|
||||
return new ApacheNodeSetData(in);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new URIReferenceException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
520
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMUtils.java
Normal file
520
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMUtils.java
Normal file
@@ -0,0 +1,520 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMUtils.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import java.util.*;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
import javax.xml.crypto.dsig.spec.*;
|
||||
|
||||
/**
|
||||
* Useful static DOM utility methods.
|
||||
*
|
||||
*/
|
||||
public final class DOMUtils {
|
||||
|
||||
// class cannot be instantiated
|
||||
private DOMUtils() {}
|
||||
|
||||
/**
|
||||
* Returns the owner document of the specified node.
|
||||
*
|
||||
* @param node the node
|
||||
* @return the owner document
|
||||
*/
|
||||
public static Document getOwnerDocument(Node node) {
|
||||
if (node.getNodeType() == Node.DOCUMENT_NODE) {
|
||||
return (Document)node;
|
||||
} else {
|
||||
return node.getOwnerDocument();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a QName string from a prefix and local name.
|
||||
*
|
||||
* @param prefix The prefix, if any. Can be either null or empty.
|
||||
* @param localName The local name.
|
||||
*
|
||||
* @return The string for the qName, for example, "xsd:element".
|
||||
*/
|
||||
public static String getQNameString(String prefix, String localName) {
|
||||
String qName = prefix == null || prefix.length() == 0
|
||||
? localName : prefix + ":" + localName;
|
||||
|
||||
return qName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an element in the specified namespace, with the specified tag
|
||||
* and namespace prefix.
|
||||
*
|
||||
* @param doc the owner document
|
||||
* @param tag the tag
|
||||
* @param nsURI the namespace URI
|
||||
* @param prefix the namespace prefix
|
||||
* @return the newly created element
|
||||
*/
|
||||
public static Element createElement(Document doc, String tag,
|
||||
String nsURI, String prefix)
|
||||
{
|
||||
String qName = prefix == null || prefix.length() == 0
|
||||
? tag : prefix + ":" + tag;
|
||||
return doc.createElementNS(nsURI, qName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an element's attribute (using DOM level 2) with the
|
||||
* specified value and namespace prefix.
|
||||
*
|
||||
* @param elem the element to set the attribute on
|
||||
* @param name the name of the attribute
|
||||
* @param value the attribute value. If null, no attribute is set.
|
||||
*/
|
||||
public static void setAttribute(Element elem, String name, String value) {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
elem.setAttributeNS(null, name, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an element's attribute (using DOM level 2) with the
|
||||
* specified value and namespace prefix AND registers the ID value with
|
||||
* the specified element. This is for resolving same-document
|
||||
* ID references.
|
||||
*
|
||||
* @param elem the element to set the attribute on
|
||||
* @param name the name of the attribute
|
||||
* @param value the attribute value. If null, no attribute is set.
|
||||
*/
|
||||
public static void setAttributeID(Element elem, String name, String value) {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
elem.setAttributeNS(null, name, value);
|
||||
elem.setIdAttributeNS(null, name, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first child element of the specified node, or null if there
|
||||
* is no such element.
|
||||
*
|
||||
* @param node the node
|
||||
* @return the first child element of the specified node, or null if there
|
||||
* is no such element
|
||||
* @throws NullPointerException if {@code node == null}
|
||||
*/
|
||||
public static Element getFirstChildElement(Node node) {
|
||||
Node child = node.getFirstChild();
|
||||
while (child != null && child.getNodeType() != Node.ELEMENT_NODE) {
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
return (Element)child;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first child element of the specified node and checks that
|
||||
* the local name is equal to {@code localName}.
|
||||
*
|
||||
* @param node the node
|
||||
* @return the first child element of the specified node
|
||||
* @throws NullPointerException if {@code node == null}
|
||||
* @throws MarshalException if no such element or the local name is not
|
||||
* equal to {@code localName}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Element getFirstChildElement(Node node, String localName)
|
||||
throws MarshalException
|
||||
{
|
||||
return verifyElement(getFirstChildElement(node), localName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first child element of the specified node and checks that
|
||||
* the local name is equal to {@code localName} and the namespace is equal to
|
||||
* {@code namespaceURI}
|
||||
*
|
||||
* @param node the node
|
||||
* @return the first child element of the specified node
|
||||
* @throws NullPointerException if {@code node == null}
|
||||
* @throws MarshalException if no such element or the local name is not
|
||||
* equal to {@code localName}
|
||||
*/
|
||||
public static Element getFirstChildElement(Node node, String localName, String namespaceURI)
|
||||
throws MarshalException
|
||||
{
|
||||
return verifyElement(getFirstChildElement(node), localName, namespaceURI);
|
||||
}
|
||||
|
||||
private static Element verifyElement(Element elem, String localName)
|
||||
throws MarshalException
|
||||
{
|
||||
if (elem == null) {
|
||||
throw new MarshalException("Missing " + localName + " element");
|
||||
}
|
||||
String name = elem.getLocalName();
|
||||
if (!name.equals(localName)) {
|
||||
throw new MarshalException("Invalid element name: " +
|
||||
name + ", expected " + localName);
|
||||
}
|
||||
return elem;
|
||||
}
|
||||
|
||||
private static Element verifyElement(Element elem, String localName, String namespaceURI)
|
||||
throws MarshalException
|
||||
{
|
||||
if (elem == null) {
|
||||
throw new MarshalException("Missing " + localName + " element");
|
||||
}
|
||||
String name = elem.getLocalName();
|
||||
String namespace = elem.getNamespaceURI();
|
||||
if (!name.equals(localName) || namespace == null && namespaceURI != null
|
||||
|| namespace != null && !namespace.equals(namespaceURI)) {
|
||||
throw new MarshalException("Invalid element name: " +
|
||||
namespace + ":" + name + ", expected " + namespaceURI + ":" + localName);
|
||||
}
|
||||
return elem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last child element of the specified node, or null if there
|
||||
* is no such element.
|
||||
*
|
||||
* @param node the node
|
||||
* @return the last child element of the specified node, or null if there
|
||||
* is no such element
|
||||
* @throws NullPointerException if {@code node == null}
|
||||
*/
|
||||
public static Element getLastChildElement(Node node) {
|
||||
Node child = node.getLastChild();
|
||||
while (child != null && child.getNodeType() != Node.ELEMENT_NODE) {
|
||||
child = child.getPreviousSibling();
|
||||
}
|
||||
return (Element)child;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next sibling element of the specified node, or null if there
|
||||
* is no such element.
|
||||
*
|
||||
* @param node the node
|
||||
* @return the next sibling element of the specified node, or null if there
|
||||
* is no such element
|
||||
* @throws NullPointerException if {@code node == null}
|
||||
*/
|
||||
public static Element getNextSiblingElement(Node node) {
|
||||
Node sibling = node.getNextSibling();
|
||||
while (sibling != null && sibling.getNodeType() != Node.ELEMENT_NODE) {
|
||||
sibling = sibling.getNextSibling();
|
||||
}
|
||||
return (Element)sibling;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next sibling element of the specified node and checks that
|
||||
* the local name is equal to {@code localName}.
|
||||
*
|
||||
* @param node the node
|
||||
* @return the next sibling element of the specified node
|
||||
* @throws NullPointerException if {@code node == null}
|
||||
* @throws MarshalException if no such element or the local name is not
|
||||
* equal to {@code localName}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Element getNextSiblingElement(Node node, String localName)
|
||||
throws MarshalException
|
||||
{
|
||||
return verifyElement(getNextSiblingElement(node), localName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next sibling element of the specified node and checks that
|
||||
* the local name is equal to {@code localName} and the namespace is equal to
|
||||
* {@code namespaceURI}
|
||||
*
|
||||
* @param node the node
|
||||
* @return the next sibling element of the specified node
|
||||
* @throws NullPointerException if {@code node == null}
|
||||
* @throws MarshalException if no such element or the local name is not
|
||||
* equal to {@code localName}
|
||||
*/
|
||||
public static Element getNextSiblingElement(Node node, String localName, String namespaceURI)
|
||||
throws MarshalException
|
||||
{
|
||||
return verifyElement(getNextSiblingElement(node), localName, namespaceURI);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the attribute value for the attribute with the specified name.
|
||||
* Returns null if there is no such attribute, or
|
||||
* the empty string if the attribute value is empty.
|
||||
*
|
||||
* <p>This works around a limitation of the DOM
|
||||
* {@code Element.getAttributeNode} method, which does not distinguish
|
||||
* between an unspecified attribute and an attribute with a value of
|
||||
* "" (it returns "" for both cases).
|
||||
*
|
||||
* @param elem the element containing the attribute
|
||||
* @param name the name of the attribute
|
||||
* @return the attribute value (may be null if unspecified)
|
||||
*/
|
||||
public static String getAttributeValue(Element elem, String name) {
|
||||
Attr attr = elem.getAttributeNodeNS(null, name);
|
||||
return (attr == null) ? null : attr.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the attribute value for the attribute with the specified name.
|
||||
* Returns null if there is no such attribute, or
|
||||
* the empty string if the attribute value is empty.
|
||||
*
|
||||
* <p>This works around a limitation of the DOM
|
||||
* {@code Element.getAttributeNode} method, which does not distinguish
|
||||
* between an unspecified attribute and an attribute with a value of
|
||||
* "" (it returns "" for both cases).
|
||||
*
|
||||
* @param elem the element containing the attribute
|
||||
* @param name the name of the attribute
|
||||
* @return the attribute value (may be null if unspecified)
|
||||
*/
|
||||
public static <N> String getIdAttributeValue(Element elem, String name) {
|
||||
Attr attr = elem.getAttributeNodeNS(null, name);
|
||||
if (attr != null && !attr.isId()) {
|
||||
elem.setIdAttributeNode(attr, true);
|
||||
}
|
||||
return (attr == null) ? null : attr.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Set of {@code Node}s, backed by the specified
|
||||
* {@code NodeList}.
|
||||
*
|
||||
* @param nl the NodeList
|
||||
* @return a Set of Nodes
|
||||
*/
|
||||
public static Set<Node> nodeSet(NodeList nl) {
|
||||
return new NodeSet(nl);
|
||||
}
|
||||
|
||||
static class NodeSet extends AbstractSet<Node> {
|
||||
private NodeList nl;
|
||||
public NodeSet(NodeList nl) {
|
||||
this.nl = nl;
|
||||
}
|
||||
|
||||
public int size() { return nl.getLength(); }
|
||||
public Iterator<Node> iterator() {
|
||||
return new Iterator<Node>() {
|
||||
private int index;
|
||||
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
public Node next() {
|
||||
if (!hasNext()) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
return nl.item(index++);
|
||||
}
|
||||
public boolean hasNext() {
|
||||
return index < nl.getLength();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the prefix associated with the specified namespace URI
|
||||
*
|
||||
* @param context contains the namespace map
|
||||
* @param nsURI the namespace URI
|
||||
* @return the prefix associated with the specified namespace URI, or
|
||||
* null if not set
|
||||
*/
|
||||
public static String getNSPrefix(XMLCryptoContext context, String nsURI) {
|
||||
if (context != null) {
|
||||
return context.getNamespacePrefix
|
||||
(nsURI, context.getDefaultNamespacePrefix());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the prefix associated with the XML Signature namespace URI
|
||||
*
|
||||
* @param context contains the namespace map
|
||||
* @return the prefix associated with the specified namespace URI, or
|
||||
* null if not set
|
||||
*/
|
||||
public static String getSignaturePrefix(XMLCryptoContext context) {
|
||||
return getNSPrefix(context, XMLSignature.XMLNS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all children nodes from the specified node.
|
||||
*
|
||||
* @param node the parent node whose children are to be removed
|
||||
*/
|
||||
public static void removeAllChildren(Node node) {
|
||||
Node firstChild = node.getFirstChild();
|
||||
while (firstChild != null) {
|
||||
Node nodeToRemove = firstChild;
|
||||
firstChild = firstChild.getNextSibling();
|
||||
node.removeChild(nodeToRemove);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares 2 nodes for equality. Implementation is not complete.
|
||||
*/
|
||||
public static boolean nodesEqual(Node thisNode, Node otherNode) {
|
||||
if (thisNode == otherNode) {
|
||||
return true;
|
||||
}
|
||||
if (thisNode.getNodeType() != otherNode.getNodeType()) {
|
||||
return false;
|
||||
}
|
||||
// FIXME - test content, etc
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if child element has same owner document before
|
||||
* appending to the parent, and imports it to the parent's document
|
||||
* if necessary.
|
||||
*/
|
||||
public static void appendChild(Node parent, Node child) {
|
||||
Document ownerDoc = getOwnerDocument(parent);
|
||||
if (child.getOwnerDocument() != ownerDoc) {
|
||||
parent.appendChild(ownerDoc.importNode(child, true));
|
||||
} else {
|
||||
parent.appendChild(child);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean paramsEqual(AlgorithmParameterSpec spec1,
|
||||
AlgorithmParameterSpec spec2) {
|
||||
if (spec1 == spec2) {
|
||||
return true;
|
||||
}
|
||||
if (spec1 instanceof XPathFilter2ParameterSpec &&
|
||||
spec2 instanceof XPathFilter2ParameterSpec) {
|
||||
return paramsEqual((XPathFilter2ParameterSpec)spec1,
|
||||
(XPathFilter2ParameterSpec)spec2);
|
||||
}
|
||||
if (spec1 instanceof ExcC14NParameterSpec &&
|
||||
spec2 instanceof ExcC14NParameterSpec) {
|
||||
return paramsEqual((ExcC14NParameterSpec) spec1,
|
||||
(ExcC14NParameterSpec)spec2);
|
||||
}
|
||||
if (spec1 instanceof XPathFilterParameterSpec &&
|
||||
spec2 instanceof XPathFilterParameterSpec) {
|
||||
return paramsEqual((XPathFilterParameterSpec)spec1,
|
||||
(XPathFilterParameterSpec)spec2);
|
||||
}
|
||||
if (spec1 instanceof XSLTTransformParameterSpec &&
|
||||
spec2 instanceof XSLTTransformParameterSpec) {
|
||||
return paramsEqual((XSLTTransformParameterSpec)spec1,
|
||||
(XSLTTransformParameterSpec)spec2);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean paramsEqual(XPathFilter2ParameterSpec spec1,
|
||||
XPathFilter2ParameterSpec spec2)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
List<XPathType> types = spec1.getXPathList();
|
||||
@SuppressWarnings("unchecked")
|
||||
List<XPathType> otypes = spec2.getXPathList();
|
||||
int size = types.size();
|
||||
if (size != otypes.size()) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < size; i++) {
|
||||
XPathType type = types.get(i);
|
||||
XPathType otype = otypes.get(i);
|
||||
if (!type.getExpression().equals(otype.getExpression()) ||
|
||||
!type.getNamespaceMap().equals(otype.getNamespaceMap()) ||
|
||||
type.getFilter() != otype.getFilter()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean paramsEqual(ExcC14NParameterSpec spec1,
|
||||
ExcC14NParameterSpec spec2)
|
||||
{
|
||||
return spec1.getPrefixList().equals(spec2.getPrefixList());
|
||||
}
|
||||
|
||||
private static boolean paramsEqual(XPathFilterParameterSpec spec1,
|
||||
XPathFilterParameterSpec spec2)
|
||||
{
|
||||
return spec1.getXPath().equals(spec2.getXPath()) &&
|
||||
spec1.getNamespaceMap().equals(spec2.getNamespaceMap());
|
||||
}
|
||||
|
||||
private static boolean paramsEqual(XSLTTransformParameterSpec spec1,
|
||||
XSLTTransformParameterSpec spec2)
|
||||
{
|
||||
|
||||
XMLStructure ostylesheet = spec2.getStylesheet();
|
||||
if (!(ostylesheet instanceof javax.xml.crypto.dom.DOMStructure)) {
|
||||
return false;
|
||||
}
|
||||
Node ostylesheetElem =
|
||||
((javax.xml.crypto.dom.DOMStructure) ostylesheet).getNode();
|
||||
XMLStructure stylesheet = spec1.getStylesheet();
|
||||
Node stylesheetElem =
|
||||
((javax.xml.crypto.dom.DOMStructure) stylesheet).getNode();
|
||||
return nodesEqual(stylesheetElem, ostylesheetElem);
|
||||
}
|
||||
|
||||
public static boolean isNamespace(Node node)
|
||||
{
|
||||
final short nodeType = node.getNodeType();
|
||||
if (nodeType == Node.ATTRIBUTE_NODE) {
|
||||
final String namespaceURI = node.getNamespaceURI();
|
||||
return XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
295
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMX509Data.java
Normal file
295
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMX509Data.java
Normal file
@@ -0,0 +1,295 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMX509Data.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.security.cert.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
import javax.xml.crypto.MarshalException;
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dsig.XMLSignature;
|
||||
import javax.xml.crypto.dsig.keyinfo.X509Data;
|
||||
import javax.xml.crypto.dsig.keyinfo.X509IssuerSerial;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
|
||||
|
||||
/**
|
||||
* DOM-based implementation of X509Data.
|
||||
*
|
||||
*/
|
||||
//@@@ check for illegal combinations of data violating MUSTs in W3c spec
|
||||
public final class DOMX509Data extends DOMStructure implements X509Data {
|
||||
|
||||
private final List<Object> content;
|
||||
private CertificateFactory cf;
|
||||
|
||||
/**
|
||||
* Creates a DOMX509Data.
|
||||
*
|
||||
* @param content a list of one or more X.509 data types. Valid types are
|
||||
* {@link String} (subject names), {@code byte[]} (subject key ids),
|
||||
* {@link java.security.cert.X509Certificate}, {@link X509CRL},
|
||||
* or {@link javax.xml.dsig.XMLStructure}
|
||||
* objects or elements from an external namespace). The list is
|
||||
* defensively copied to protect against subsequent modification.
|
||||
* @throws NullPointerException if {@code content} is {@code null}
|
||||
* @throws IllegalArgumentException if {@code content} is empty
|
||||
* @throws ClassCastException if {@code content} contains any entries
|
||||
* that are not of one of the valid types mentioned above
|
||||
*/
|
||||
public DOMX509Data(List<?> content) {
|
||||
if (content == null) {
|
||||
throw new NullPointerException("content cannot be null");
|
||||
}
|
||||
List<Object> contentCopy = new ArrayList<>(content);
|
||||
if (contentCopy.isEmpty()) {
|
||||
throw new IllegalArgumentException("content cannot be empty");
|
||||
}
|
||||
for (int i = 0, size = contentCopy.size(); i < size; i++) {
|
||||
Object x509Type = contentCopy.get(i);
|
||||
if (x509Type instanceof String) {
|
||||
new X500Principal((String)x509Type);
|
||||
} else if (!(x509Type instanceof byte[]) &&
|
||||
!(x509Type instanceof X509Certificate) &&
|
||||
!(x509Type instanceof X509CRL) &&
|
||||
!(x509Type instanceof XMLStructure)) {
|
||||
throw new ClassCastException
|
||||
("content["+i+"] is not a valid X509Data type");
|
||||
}
|
||||
}
|
||||
this.content = Collections.unmodifiableList(contentCopy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMX509Data} from an element.
|
||||
*
|
||||
* @param xdElem an X509Data element
|
||||
* @throws MarshalException if there is an error while unmarshalling
|
||||
*/
|
||||
public DOMX509Data(Element xdElem) throws MarshalException {
|
||||
// get all children nodes
|
||||
List<Object> newContent = new ArrayList<>();
|
||||
Node firstChild = xdElem.getFirstChild();
|
||||
while (firstChild != null) {
|
||||
if (firstChild.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Element childElem = (Element)firstChild;
|
||||
String localName = childElem.getLocalName();
|
||||
String namespace = childElem.getNamespaceURI();
|
||||
if ("X509Certificate".equals(localName) && XMLSignature.XMLNS.equals(namespace)) {
|
||||
newContent.add(unmarshalX509Certificate(childElem));
|
||||
} else if ("X509IssuerSerial".equals(localName) && XMLSignature.XMLNS.equals(namespace)) {
|
||||
newContent.add(new DOMX509IssuerSerial(childElem));
|
||||
} else if ("X509SubjectName".equals(localName) && XMLSignature.XMLNS.equals(namespace)) {
|
||||
newContent.add(childElem.getFirstChild().getNodeValue());
|
||||
} else if ("X509SKI".equals(localName) && XMLSignature.XMLNS.equals(namespace)) {
|
||||
String content = XMLUtils.getFullTextChildrenFromNode(childElem);
|
||||
newContent.add(XMLUtils.decode(content));
|
||||
} else if ("X509CRL".equals(localName) && XMLSignature.XMLNS.equals(namespace)) {
|
||||
newContent.add(unmarshalX509CRL(childElem));
|
||||
} else {
|
||||
newContent.add(new javax.xml.crypto.dom.DOMStructure(childElem));
|
||||
}
|
||||
}
|
||||
firstChild = firstChild.getNextSibling();
|
||||
}
|
||||
this.content = Collections.unmodifiableList(newContent);
|
||||
}
|
||||
|
||||
public List<Object> getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
Document ownerDoc = DOMUtils.getOwnerDocument(parent);
|
||||
Element xdElem = DOMUtils.createElement(ownerDoc, "X509Data",
|
||||
XMLSignature.XMLNS, dsPrefix);
|
||||
|
||||
// append children and preserve order
|
||||
for (int i = 0, size = content.size(); i < size; i++) {
|
||||
Object object = content.get(i);
|
||||
if (object instanceof X509Certificate) {
|
||||
marshalCert((X509Certificate)object,xdElem,ownerDoc,dsPrefix);
|
||||
} else if (object instanceof XMLStructure) {
|
||||
if (object instanceof X509IssuerSerial) {
|
||||
((DOMX509IssuerSerial)object).marshal
|
||||
(xdElem, dsPrefix, context);
|
||||
} else {
|
||||
javax.xml.crypto.dom.DOMStructure domContent =
|
||||
(javax.xml.crypto.dom.DOMStructure)object;
|
||||
DOMUtils.appendChild(xdElem, domContent.getNode());
|
||||
}
|
||||
} else if (object instanceof byte[]) {
|
||||
marshalSKI((byte[])object, xdElem, ownerDoc, dsPrefix);
|
||||
} else if (object instanceof String) {
|
||||
marshalSubjectName((String)object, xdElem, ownerDoc,dsPrefix);
|
||||
} else if (object instanceof X509CRL) {
|
||||
marshalCRL((X509CRL)object, xdElem, ownerDoc, dsPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
parent.appendChild(xdElem);
|
||||
}
|
||||
|
||||
private void marshalSKI(byte[] skid, Node parent, Document doc,
|
||||
String dsPrefix)
|
||||
{
|
||||
Element skidElem = DOMUtils.createElement(doc, "X509SKI",
|
||||
XMLSignature.XMLNS, dsPrefix);
|
||||
skidElem.appendChild(doc.createTextNode(XMLUtils.encodeToString(skid)));
|
||||
parent.appendChild(skidElem);
|
||||
}
|
||||
|
||||
private void marshalSubjectName(String name, Node parent, Document doc,
|
||||
String dsPrefix)
|
||||
{
|
||||
Element snElem = DOMUtils.createElement(doc, "X509SubjectName",
|
||||
XMLSignature.XMLNS, dsPrefix);
|
||||
snElem.appendChild(doc.createTextNode(name));
|
||||
parent.appendChild(snElem);
|
||||
}
|
||||
|
||||
private void marshalCert(X509Certificate cert, Node parent, Document doc,
|
||||
String dsPrefix)
|
||||
throws MarshalException
|
||||
{
|
||||
Element certElem = DOMUtils.createElement(doc, "X509Certificate",
|
||||
XMLSignature.XMLNS, dsPrefix);
|
||||
try {
|
||||
certElem.appendChild(doc.createTextNode
|
||||
(XMLUtils.encodeToString(cert.getEncoded())));
|
||||
} catch (CertificateEncodingException e) {
|
||||
throw new MarshalException("Error encoding X509Certificate", e);
|
||||
}
|
||||
parent.appendChild(certElem);
|
||||
}
|
||||
|
||||
private void marshalCRL(X509CRL crl, Node parent, Document doc,
|
||||
String dsPrefix)
|
||||
throws MarshalException
|
||||
{
|
||||
Element crlElem = DOMUtils.createElement(doc, "X509CRL",
|
||||
XMLSignature.XMLNS, dsPrefix);
|
||||
try {
|
||||
crlElem.appendChild(doc.createTextNode
|
||||
(XMLUtils.encodeToString(crl.getEncoded())));
|
||||
} catch (CRLException e) {
|
||||
throw new MarshalException("Error encoding X509CRL", e);
|
||||
}
|
||||
parent.appendChild(crlElem);
|
||||
}
|
||||
|
||||
private X509Certificate unmarshalX509Certificate(Element elem)
|
||||
throws MarshalException
|
||||
{
|
||||
try (ByteArrayInputStream bs = unmarshalBase64Binary(elem)) {
|
||||
return (X509Certificate)cf.generateCertificate(bs);
|
||||
} catch (CertificateException e) {
|
||||
throw new MarshalException("Cannot create X509Certificate", e);
|
||||
} catch (IOException e) {
|
||||
throw new MarshalException("Error closing stream", e);
|
||||
}
|
||||
}
|
||||
|
||||
private X509CRL unmarshalX509CRL(Element elem) throws MarshalException {
|
||||
try (ByteArrayInputStream bs = unmarshalBase64Binary(elem)) {
|
||||
return (X509CRL)cf.generateCRL(bs);
|
||||
} catch (CRLException e) {
|
||||
throw new MarshalException("Cannot create X509CRL", e);
|
||||
} catch (IOException e) {
|
||||
throw new MarshalException("Error closing stream", e);
|
||||
}
|
||||
}
|
||||
|
||||
private ByteArrayInputStream unmarshalBase64Binary(Element elem)
|
||||
throws MarshalException {
|
||||
try {
|
||||
if (cf == null) {
|
||||
cf = CertificateFactory.getInstance("X.509");
|
||||
}
|
||||
String content = XMLUtils.getFullTextChildrenFromNode(elem);
|
||||
return new ByteArrayInputStream(XMLUtils.decode(content));
|
||||
} catch (CertificateException e) {
|
||||
throw new MarshalException("Cannot create CertificateFactory", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(o instanceof X509Data)) {
|
||||
return false;
|
||||
}
|
||||
X509Data oxd = (X509Data)o;
|
||||
|
||||
@SuppressWarnings("unchecked") List<Object> ocontent = oxd.getContent();
|
||||
int size = content.size();
|
||||
if (size != ocontent.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
Object x = content.get(i);
|
||||
Object ox = ocontent.get(i);
|
||||
if (x instanceof byte[]) {
|
||||
if (!(ox instanceof byte[]) ||
|
||||
!Arrays.equals((byte[])x, (byte[])ox)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!(x.equals(ox))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 17;
|
||||
result = 31 * result + content.hashCode();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMX509IssuerSerial.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import javax.xml.crypto.MarshalException;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dsig.XMLSignature;
|
||||
import javax.xml.crypto.dsig.keyinfo.X509IssuerSerial;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* DOM-based implementation of X509IssuerSerial.
|
||||
*
|
||||
*/
|
||||
public final class DOMX509IssuerSerial extends DOMStructure
|
||||
implements X509IssuerSerial {
|
||||
|
||||
private final String issuerName;
|
||||
private final BigInteger serialNumber;
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMX509IssuerSerial} containing the specified
|
||||
* issuer distinguished name/serial number pair.
|
||||
*
|
||||
* @param issuerName the X.509 issuer distinguished name in RFC 2253
|
||||
* String format
|
||||
* @param serialNumber the serial number
|
||||
* @throws IllegalArgumentException if the format of {@code issuerName}
|
||||
* is not RFC 2253 compliant
|
||||
* @throws NullPointerException if {@code issuerName} or
|
||||
* {@code serialNumber} is {@code null}
|
||||
*/
|
||||
public DOMX509IssuerSerial(String issuerName, BigInteger serialNumber) {
|
||||
if (issuerName == null) {
|
||||
throw new NullPointerException("issuerName cannot be null");
|
||||
}
|
||||
if (serialNumber == null) {
|
||||
throw new NullPointerException("serialNumber cannot be null");
|
||||
}
|
||||
// check that issuer distinguished name conforms to RFC 2253
|
||||
new X500Principal(issuerName);
|
||||
this.issuerName = issuerName;
|
||||
this.serialNumber = serialNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMX509IssuerSerial} from an element.
|
||||
*
|
||||
* @param isElem an X509IssuerSerial element
|
||||
*/
|
||||
public DOMX509IssuerSerial(Element isElem) throws MarshalException {
|
||||
Element iNElem = DOMUtils.getFirstChildElement(isElem,
|
||||
"X509IssuerName",
|
||||
XMLSignature.XMLNS);
|
||||
Element sNElem = DOMUtils.getNextSiblingElement(iNElem,
|
||||
"X509SerialNumber",
|
||||
XMLSignature.XMLNS);
|
||||
issuerName = iNElem.getFirstChild().getNodeValue();
|
||||
serialNumber = new BigInteger(sNElem.getFirstChild().getNodeValue());
|
||||
}
|
||||
|
||||
public String getIssuerName() {
|
||||
return issuerName;
|
||||
}
|
||||
|
||||
public BigInteger getSerialNumber() {
|
||||
return serialNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
Document ownerDoc = DOMUtils.getOwnerDocument(parent);
|
||||
|
||||
Element isElem = DOMUtils.createElement(ownerDoc, "X509IssuerSerial",
|
||||
XMLSignature.XMLNS, dsPrefix);
|
||||
Element inElem = DOMUtils.createElement(ownerDoc, "X509IssuerName",
|
||||
XMLSignature.XMLNS, dsPrefix);
|
||||
Element snElem = DOMUtils.createElement(ownerDoc, "X509SerialNumber",
|
||||
XMLSignature.XMLNS, dsPrefix);
|
||||
inElem.appendChild(ownerDoc.createTextNode(issuerName));
|
||||
snElem.appendChild(ownerDoc.createTextNode(serialNumber.toString()));
|
||||
isElem.appendChild(inElem);
|
||||
isElem.appendChild(snElem);
|
||||
parent.appendChild(isElem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof X509IssuerSerial)) {
|
||||
return false;
|
||||
}
|
||||
X509IssuerSerial ois = (X509IssuerSerial)obj;
|
||||
return issuerName.equals(ois.getIssuerName()) &&
|
||||
serialNumber.equals(ois.getSerialNumber());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 17;
|
||||
result = 31 * result + issuerName.hashCode();
|
||||
result = 31 * result + serialNumber.hashCode();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
264
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java
Normal file
264
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java
Normal file
@@ -0,0 +1,264 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMXMLObject.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
|
||||
import java.security.Provider;
|
||||
import java.util.*;
|
||||
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* DOM-based implementation of XMLObject.
|
||||
*
|
||||
*/
|
||||
public final class DOMXMLObject extends DOMStructure implements XMLObject {
|
||||
|
||||
private final String id;
|
||||
private final String mimeType;
|
||||
private final String encoding;
|
||||
private final List<XMLStructure> content;
|
||||
private Element objectElem;
|
||||
|
||||
/**
|
||||
* Creates an {@code XMLObject} from the specified parameters.
|
||||
*
|
||||
* @param content a list of {@link XMLStructure}s. The list
|
||||
* is defensively copied to protect against subsequent modification.
|
||||
* May be {@code null} or empty.
|
||||
* @param id the Id (may be {@code null})
|
||||
* @param mimeType the mime type (may be {@code null})
|
||||
* @param encoding the encoding (may be {@code null})
|
||||
* @throws ClassCastException if {@code content} contains any
|
||||
* entries that are not of type {@link XMLStructure}
|
||||
*/
|
||||
public DOMXMLObject(List<? extends XMLStructure> content, String id,
|
||||
String mimeType, String encoding)
|
||||
{
|
||||
if (content == null || content.isEmpty()) {
|
||||
this.content = Collections.emptyList();
|
||||
} else {
|
||||
this.content = Collections.unmodifiableList(
|
||||
new ArrayList<>(content));
|
||||
for (int i = 0, size = this.content.size(); i < size; i++) {
|
||||
if (!(this.content.get(i) instanceof XMLStructure)) {
|
||||
throw new ClassCastException
|
||||
("content["+i+"] is not a valid type");
|
||||
}
|
||||
}
|
||||
}
|
||||
this.id = id;
|
||||
this.mimeType = mimeType;
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an {@code XMLObject} from an element.
|
||||
*
|
||||
* @param objElem an Object element
|
||||
* @throws MarshalException if there is an error when unmarshalling
|
||||
*/
|
||||
public DOMXMLObject(Element objElem, XMLCryptoContext context,
|
||||
Provider provider)
|
||||
throws MarshalException
|
||||
{
|
||||
// unmarshal attributes
|
||||
this.encoding = DOMUtils.getAttributeValue(objElem, "Encoding");
|
||||
|
||||
Attr attr = objElem.getAttributeNodeNS(null, "Id");
|
||||
if (attr != null) {
|
||||
this.id = attr.getValue();
|
||||
objElem.setIdAttributeNode(attr, true);
|
||||
} else {
|
||||
this.id = null;
|
||||
}
|
||||
this.mimeType = DOMUtils.getAttributeValue(objElem, "MimeType");
|
||||
|
||||
List<XMLStructure> newContent = new ArrayList<>();
|
||||
Node firstChild = objElem.getFirstChild();
|
||||
while (firstChild != null) {
|
||||
if (firstChild.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Element childElem = (Element)firstChild;
|
||||
String tag = childElem.getLocalName();
|
||||
String namespace = childElem.getNamespaceURI();
|
||||
if ("Manifest".equals(tag) && XMLSignature.XMLNS.equals(namespace)) {
|
||||
newContent.add(new DOMManifest(childElem, context, provider));
|
||||
} else if ("SignatureProperties".equals(tag) && XMLSignature.XMLNS.equals(namespace)) {
|
||||
newContent.add(new DOMSignatureProperties(childElem));
|
||||
} else if ("X509Data".equals(tag) && XMLSignature.XMLNS.equals(namespace)) {
|
||||
newContent.add(new DOMX509Data(childElem));
|
||||
} else {
|
||||
//@@@FIXME: check for other dsig structures
|
||||
newContent.add(new javax.xml.crypto.dom.DOMStructure(firstChild));
|
||||
}
|
||||
} else {
|
||||
newContent.add(new javax.xml.crypto.dom.DOMStructure(firstChild));
|
||||
}
|
||||
firstChild = firstChild.getNextSibling();
|
||||
}
|
||||
|
||||
// Here we capture namespace declarations, so that when they're marshalled back
|
||||
// out, we can make copies of them. Note that attributes are NOT captured.
|
||||
NamedNodeMap nnm = objElem.getAttributes();
|
||||
for (int idx = 0 ; idx < nnm.getLength() ; idx++) {
|
||||
Node nsDecl = nnm.item(idx);
|
||||
if (DOMUtils.isNamespace(nsDecl)) {
|
||||
newContent.add(new javax.xml.crypto.dom.DOMStructure(nsDecl));
|
||||
}
|
||||
}
|
||||
|
||||
if (newContent.isEmpty()) {
|
||||
this.content = Collections.emptyList();
|
||||
} else {
|
||||
this.content = Collections.unmodifiableList(newContent);
|
||||
}
|
||||
this.objectElem = objElem;
|
||||
}
|
||||
|
||||
public List<XMLStructure> getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getMimeType() {
|
||||
return mimeType;
|
||||
}
|
||||
|
||||
public String getEncoding() {
|
||||
return encoding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
|
||||
throws MarshalException {
|
||||
Document ownerDoc = DOMUtils.getOwnerDocument(parent);
|
||||
|
||||
Element objElem = objectElem != null ? objectElem : null;
|
||||
if (objElem == null) {
|
||||
objElem = DOMUtils.createElement(ownerDoc, "Object",
|
||||
XMLSignature.XMLNS, dsPrefix);
|
||||
|
||||
// set attributes
|
||||
DOMUtils.setAttributeID(objElem, "Id", id);
|
||||
DOMUtils.setAttribute(objElem, "MimeType", mimeType);
|
||||
DOMUtils.setAttribute(objElem, "Encoding", encoding);
|
||||
|
||||
// create and append any elements and mixed content, if necessary
|
||||
for (XMLStructure object : content) {
|
||||
if (object instanceof DOMStructure) {
|
||||
((DOMStructure)object).marshal(objElem, dsPrefix, context);
|
||||
} else {
|
||||
javax.xml.crypto.dom.DOMStructure domObject =
|
||||
(javax.xml.crypto.dom.DOMStructure)object;
|
||||
DOMUtils.appendChild(objElem, domObject.getNode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
parent.appendChild(objElem);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(o instanceof XMLObject)) {
|
||||
return false;
|
||||
}
|
||||
XMLObject oxo = (XMLObject)o;
|
||||
|
||||
boolean idsEqual = id == null ? oxo.getId() == null
|
||||
: id.equals(oxo.getId());
|
||||
boolean encodingsEqual =
|
||||
encoding == null ? oxo.getEncoding() == null
|
||||
: encoding.equals(oxo.getEncoding());
|
||||
boolean mimeTypesEqual =
|
||||
mimeType == null ? oxo.getMimeType() == null
|
||||
: mimeType.equals(oxo.getMimeType());
|
||||
|
||||
return idsEqual && encodingsEqual && mimeTypesEqual &&
|
||||
equalsContent(oxo.getContent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 17;
|
||||
if (id != null) {
|
||||
result = 31 * result + id.hashCode();
|
||||
}
|
||||
if (encoding != null) {
|
||||
result = 31 * result + encoding.hashCode();
|
||||
}
|
||||
if (mimeType != null) {
|
||||
result = 31 * result + mimeType.hashCode();
|
||||
}
|
||||
result = 31 * result + content.hashCode();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean equalsContent(List<XMLStructure> otherContent) {
|
||||
if (content.size() != otherContent.size()) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0, osize = otherContent.size(); i < osize; i++) {
|
||||
XMLStructure oxs = otherContent.get(i);
|
||||
XMLStructure xs = content.get(i);
|
||||
if (oxs instanceof javax.xml.crypto.dom.DOMStructure) {
|
||||
if (!(xs instanceof javax.xml.crypto.dom.DOMStructure)) {
|
||||
return false;
|
||||
}
|
||||
Node onode = ((javax.xml.crypto.dom.DOMStructure)oxs).getNode();
|
||||
Node node = ((javax.xml.crypto.dom.DOMStructure)xs).getNode();
|
||||
if (!DOMUtils.nodesEqual(node, onode)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!(xs.equals(oxs))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
634
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java
Normal file
634
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java
Normal file
@@ -0,0 +1,634 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*
|
||||
* Portions copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* ===========================================================================
|
||||
*
|
||||
* (C) Copyright IBM Corp. 2003 All Rights Reserved.
|
||||
*
|
||||
* ===========================================================================
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMXMLSignature.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dom.*;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
import javax.xml.crypto.dsig.dom.DOMSignContext;
|
||||
import javax.xml.crypto.dsig.dom.DOMValidateContext;
|
||||
import javax.xml.crypto.dsig.keyinfo.KeyInfo;
|
||||
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.Key;
|
||||
import java.security.Provider;
|
||||
import java.util.Collections;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
|
||||
|
||||
/**
|
||||
* DOM-based implementation of XMLSignature.
|
||||
*
|
||||
*/
|
||||
public final class DOMXMLSignature extends DOMStructure
|
||||
implements XMLSignature {
|
||||
|
||||
private static final com.sun.org.slf4j.internal.Logger LOG =
|
||||
com.sun.org.slf4j.internal.LoggerFactory.getLogger(DOMXMLSignature.class);
|
||||
private String id;
|
||||
private SignatureValue sv;
|
||||
private KeyInfo ki;
|
||||
private List<XMLObject> objects;
|
||||
private SignedInfo si;
|
||||
private Document ownerDoc = null;
|
||||
private Element localSigElem = null;
|
||||
private Element sigElem = null;
|
||||
private boolean validationStatus;
|
||||
private boolean validated = false;
|
||||
private KeySelectorResult ksr;
|
||||
private Map<String, XMLStructure> signatureIdMap;
|
||||
|
||||
static {
|
||||
com.sun.org.apache.xml.internal.security.Init.init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMXMLSignature} from the specified components.
|
||||
*
|
||||
* @param si the {@code SignedInfo}
|
||||
* @param ki the {@code KeyInfo}, or {@code null} if not specified
|
||||
* @param objs a list of {@code XMLObject}s or {@code null}
|
||||
* if not specified. The list is copied to protect against subsequent
|
||||
* modification.
|
||||
* @param id an optional id (specify {@code null} to omit)
|
||||
* @param signatureValueId an optional id (specify {@code null} to
|
||||
* omit)
|
||||
* @throws NullPointerException if {@code si} is {@code null}
|
||||
*/
|
||||
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<>(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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code DOMXMLSignature} from XML.
|
||||
*
|
||||
* @param sigElem Signature element
|
||||
* @throws MarshalException if XMLSignature cannot be unmarshalled
|
||||
*/
|
||||
public DOMXMLSignature(Element sigElem, XMLCryptoContext context,
|
||||
Provider provider)
|
||||
throws MarshalException
|
||||
{
|
||||
localSigElem = sigElem;
|
||||
ownerDoc = localSigElem.getOwnerDocument();
|
||||
|
||||
// get Id attribute, if specified
|
||||
id = DOMUtils.getAttributeValue(localSigElem, "Id");
|
||||
// unmarshal SignedInfo
|
||||
Element siElem = DOMUtils.getFirstChildElement(localSigElem,
|
||||
"SignedInfo",
|
||||
XMLSignature.XMLNS);
|
||||
si = new DOMSignedInfo(siElem, context, provider);
|
||||
|
||||
// unmarshal SignatureValue
|
||||
Element sigValElem = DOMUtils.getNextSiblingElement(siElem,
|
||||
"SignatureValue",
|
||||
XMLSignature.XMLNS);
|
||||
sv = new DOMSignatureValue(sigValElem);
|
||||
|
||||
// unmarshal KeyInfo, if specified
|
||||
Element nextSibling = DOMUtils.getNextSiblingElement(sigValElem);
|
||||
if (nextSibling != null && nextSibling.getLocalName().equals("KeyInfo")
|
||||
&& XMLSignature.XMLNS.equals(nextSibling.getNamespaceURI())) {
|
||||
ki = new DOMKeyInfo(nextSibling, context, provider);
|
||||
nextSibling = DOMUtils.getNextSiblingElement(nextSibling);
|
||||
}
|
||||
|
||||
// unmarshal Objects, if specified
|
||||
if (nextSibling == null) {
|
||||
objects = Collections.emptyList();
|
||||
} else {
|
||||
List<XMLObject> tempObjects = new ArrayList<>();
|
||||
while (nextSibling != null) {
|
||||
String name = nextSibling.getLocalName();
|
||||
String namespace = nextSibling.getNamespaceURI();
|
||||
if (!"Object".equals(name) || !XMLSignature.XMLNS.equals(namespace)) {
|
||||
throw new MarshalException("Invalid element name: " + namespace + ":" + name +
|
||||
", expected KeyInfo or Object");
|
||||
}
|
||||
tempObjects.add(new DOMXMLObject(nextSibling,
|
||||
context, provider));
|
||||
nextSibling = DOMUtils.getNextSiblingElement(nextSibling);
|
||||
}
|
||||
objects = Collections.unmodifiableList(tempObjects);
|
||||
}
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public KeyInfo getKeyInfo() {
|
||||
return ki;
|
||||
}
|
||||
|
||||
public SignedInfo getSignedInfo() {
|
||||
return si;
|
||||
}
|
||||
|
||||
public List<XMLObject> getObjects() {
|
||||
return objects;
|
||||
}
|
||||
|
||||
public SignatureValue getSignatureValue() {
|
||||
return sv;
|
||||
}
|
||||
|
||||
public KeySelectorResult getKeySelectorResult() {
|
||||
return ksr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
marshal(parent, null, dsPrefix, context);
|
||||
}
|
||||
|
||||
public void marshal(Node parent, Node nextSibling, String dsPrefix,
|
||||
DOMCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
ownerDoc = DOMUtils.getOwnerDocument(parent);
|
||||
sigElem = DOMUtils.createElement(ownerDoc, "Signature",
|
||||
XMLSignature.XMLNS, dsPrefix);
|
||||
|
||||
// append xmlns attribute
|
||||
if (dsPrefix == null || dsPrefix.length() == 0) {
|
||||
sigElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns",
|
||||
XMLSignature.XMLNS);
|
||||
} else {
|
||||
sigElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:" +
|
||||
dsPrefix, XMLSignature.XMLNS);
|
||||
}
|
||||
|
||||
// create and append SignedInfo element
|
||||
((DOMSignedInfo)si).marshal(sigElem, dsPrefix, context);
|
||||
|
||||
// create and append SignatureValue element
|
||||
((DOMSignatureValue)sv).marshal(sigElem, dsPrefix, context);
|
||||
|
||||
// create and append KeyInfo element if necessary
|
||||
if (ki != null) {
|
||||
((DOMKeyInfo)ki).marshal(sigElem, null, dsPrefix, context);
|
||||
}
|
||||
|
||||
// create and append Object elements if necessary
|
||||
for (int i = 0, size = objects.size(); i < size; i++) {
|
||||
((DOMXMLObject)objects.get(i)).marshal(sigElem, dsPrefix, context);
|
||||
}
|
||||
|
||||
// append Id attribute
|
||||
DOMUtils.setAttributeID(sigElem, "Id", id);
|
||||
|
||||
parent.insertBefore(sigElem, nextSibling);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate(XMLValidateContext vc)
|
||||
throws XMLSignatureException
|
||||
{
|
||||
if (vc == null) {
|
||||
throw new NullPointerException("validateContext is null");
|
||||
}
|
||||
|
||||
if (!(vc instanceof DOMValidateContext)) {
|
||||
throw new ClassCastException
|
||||
("validateContext must be of type DOMValidateContext");
|
||||
}
|
||||
|
||||
if (validated) {
|
||||
return validationStatus;
|
||||
}
|
||||
|
||||
// validate the signature
|
||||
boolean sigValidity = sv.validate(vc);
|
||||
if (!sigValidity) {
|
||||
validationStatus = false;
|
||||
validated = true;
|
||||
return validationStatus;
|
||||
}
|
||||
|
||||
// validate all References
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Reference> refs = this.si.getReferences();
|
||||
boolean validateRefs = true;
|
||||
for (int i = 0, size = refs.size(); validateRefs && i < size; i++) {
|
||||
Reference ref = refs.get(i);
|
||||
boolean refValid = ref.validate(vc);
|
||||
LOG.debug("Reference [{}] is valid: {}", ref.getURI(), refValid);
|
||||
validateRefs &= refValid;
|
||||
}
|
||||
if (!validateRefs) {
|
||||
LOG.debug("Couldn't validate the References");
|
||||
validationStatus = false;
|
||||
validated = true;
|
||||
return validationStatus;
|
||||
}
|
||||
|
||||
// validate Manifests, if property set
|
||||
boolean validateMans = true;
|
||||
if (Boolean.TRUE.equals(vc.getProperty
|
||||
("org.jcp.xml.dsig.validateManifests")))
|
||||
{
|
||||
for (int i=0, size=objects.size(); validateMans && i < size; i++) {
|
||||
XMLObject xo = objects.get(i);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<XMLStructure> content = xo.getContent();
|
||||
int csize = content.size();
|
||||
for (int j = 0; validateMans && j < csize; j++) {
|
||||
XMLStructure xs = content.get(j);
|
||||
if (xs instanceof Manifest) {
|
||||
LOG.debug("validating manifest");
|
||||
Manifest man = (Manifest)xs;
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Reference> manRefs = man.getReferences();
|
||||
int rsize = manRefs.size();
|
||||
for (int k = 0; validateMans && k < rsize; k++) {
|
||||
Reference ref = manRefs.get(k);
|
||||
boolean refValid = ref.validate(vc);
|
||||
LOG.debug(
|
||||
"Manifest ref [{}] is valid: {}", ref.getURI(), refValid
|
||||
);
|
||||
validateMans &= refValid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
validationStatus = validateMans;
|
||||
validated = true;
|
||||
return validationStatus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sign(XMLSignContext signContext)
|
||||
throws MarshalException, XMLSignatureException
|
||||
{
|
||||
if (signContext == null) {
|
||||
throw new NullPointerException("signContext cannot be null");
|
||||
}
|
||||
DOMSignContext context = (DOMSignContext)signContext;
|
||||
marshal(context.getParent(), context.getNextSibling(),
|
||||
DOMUtils.getSignaturePrefix(context), context);
|
||||
|
||||
// generate references and signature value
|
||||
List<Reference> allReferences = new ArrayList<>();
|
||||
|
||||
// traverse the Signature and register all objects with IDs that
|
||||
// may contain References
|
||||
signatureIdMap = new HashMap<>();
|
||||
signatureIdMap.put(id, this);
|
||||
signatureIdMap.put(si.getId(), si);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Reference> refs = si.getReferences();
|
||||
for (Reference ref : refs) {
|
||||
signatureIdMap.put(ref.getId(), ref);
|
||||
}
|
||||
for (XMLObject obj : objects) {
|
||||
signatureIdMap.put(obj.getId(), obj);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<XMLStructure> content = obj.getContent();
|
||||
for (XMLStructure xs : content) {
|
||||
if (xs instanceof Manifest) {
|
||||
Manifest man = (Manifest)xs;
|
||||
signatureIdMap.put(man.getId(), man);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Reference> manRefs = man.getReferences();
|
||||
for (Reference ref : manRefs) {
|
||||
allReferences.add(ref);
|
||||
signatureIdMap.put(ref.getId(), ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// always add SignedInfo references after Manifest references so
|
||||
// that Manifest reference are digested first
|
||||
allReferences.addAll(refs);
|
||||
|
||||
// generate/digest each reference
|
||||
for (Reference ref : allReferences) {
|
||||
digestReference((DOMReference)ref, signContext);
|
||||
}
|
||||
|
||||
// do final sweep to digest any references that were skipped or missed
|
||||
for (Reference ref : allReferences) {
|
||||
if (((DOMReference)ref).isDigested()) {
|
||||
continue;
|
||||
}
|
||||
((DOMReference)ref).digest(signContext);
|
||||
}
|
||||
|
||||
Key signingKey = null;
|
||||
try {
|
||||
KeySelectorResult keySelectorResult = signContext.getKeySelector().select(ki,
|
||||
KeySelector.Purpose.SIGN,
|
||||
si.getSignatureMethod(),
|
||||
signContext);
|
||||
signingKey = keySelectorResult.getKey();
|
||||
if (signingKey == null) {
|
||||
throw new XMLSignatureException("the keySelector did not " +
|
||||
"find a signing key");
|
||||
}
|
||||
ksr = keySelectorResult;
|
||||
} catch (KeySelectorException kse) {
|
||||
throw new XMLSignatureException("cannot find signing key", kse);
|
||||
}
|
||||
|
||||
// calculate signature value
|
||||
try {
|
||||
byte[] val = ((AbstractDOMSignatureMethod)
|
||||
si.getSignatureMethod()).sign(signingKey, si, signContext);
|
||||
((DOMSignatureValue)sv).setValue(val);
|
||||
} catch (InvalidKeyException ike) {
|
||||
throw new XMLSignatureException(ike);
|
||||
}
|
||||
|
||||
this.localSigElem = sigElem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(o instanceof XMLSignature)) {
|
||||
return false;
|
||||
}
|
||||
XMLSignature osig = (XMLSignature)o;
|
||||
|
||||
boolean idEqual =
|
||||
id == null ? osig.getId() == null : id.equals(osig.getId());
|
||||
boolean keyInfoEqual =
|
||||
ki == null ? osig.getKeyInfo() == null
|
||||
: ki.equals(osig.getKeyInfo());
|
||||
|
||||
return idEqual && keyInfoEqual &&
|
||||
sv.equals(osig.getSignatureValue()) &&
|
||||
si.equals(osig.getSignedInfo()) &&
|
||||
objects.equals(osig.getObjects());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 17;
|
||||
if (id != null) {
|
||||
result = 31 * result + id.hashCode();
|
||||
}
|
||||
if (ki != null) {
|
||||
result = 31 * result + ki.hashCode();
|
||||
}
|
||||
result = 31 * result + sv.hashCode();
|
||||
result = 31 * result + si.hashCode();
|
||||
result = 31 * result + objects.hashCode();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void digestReference(DOMReference ref, XMLSignContext signContext)
|
||||
throws XMLSignatureException
|
||||
{
|
||||
if (ref.isDigested()) {
|
||||
return;
|
||||
}
|
||||
// check dependencies
|
||||
String uri = ref.getURI();
|
||||
if (Utils.sameDocumentURI(uri)) {
|
||||
String parsedId = Utils.parseIdFromSameDocumentURI(uri);
|
||||
if (parsedId != null && signatureIdMap.containsKey(parsedId)) {
|
||||
XMLStructure xs = signatureIdMap.get(parsedId);
|
||||
if (xs instanceof DOMReference) {
|
||||
digestReference((DOMReference)xs, signContext);
|
||||
} else if (xs instanceof Manifest) {
|
||||
Manifest man = (Manifest)xs;
|
||||
List<Reference> manRefs = DOMManifest.getManifestReferences(man);
|
||||
for (int i = 0, size = manRefs.size(); i < size; i++) {
|
||||
digestReference((DOMReference)manRefs.get(i),
|
||||
signContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
// if uri="" and there are XPath Transforms, there may be
|
||||
// reference dependencies in the XPath Transform - so be on
|
||||
// the safe side, and skip and do at end in the final sweep
|
||||
if (uri.length() == 0) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Transform> transforms = ref.getTransforms();
|
||||
for (Transform transform : transforms) {
|
||||
String transformAlg = transform.getAlgorithm();
|
||||
if (transformAlg.equals(Transform.XPATH) ||
|
||||
transformAlg.equals(Transform.XPATH2)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ref.digest(signContext);
|
||||
}
|
||||
|
||||
public class DOMSignatureValue extends DOMStructure
|
||||
implements SignatureValue
|
||||
{
|
||||
private String id;
|
||||
private byte[] value;
|
||||
private String valueBase64;
|
||||
private Element sigValueElem;
|
||||
private boolean validated = false;
|
||||
private boolean validationStatus;
|
||||
|
||||
DOMSignatureValue(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
DOMSignatureValue(Element sigValueElem)
|
||||
throws MarshalException
|
||||
{
|
||||
// base64 decode signatureValue
|
||||
String content = XMLUtils.getFullTextChildrenFromNode(sigValueElem);
|
||||
value = XMLUtils.decode(content);
|
||||
|
||||
Attr attr = sigValueElem.getAttributeNodeNS(null, "Id");
|
||||
if (attr != null) {
|
||||
id = attr.getValue();
|
||||
sigValueElem.setIdAttributeNode(attr, true);
|
||||
} else {
|
||||
id = null;
|
||||
}
|
||||
this.sigValueElem = sigValueElem;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public byte[] getValue() {
|
||||
return (value == null) ? null : (byte[])value.clone();
|
||||
}
|
||||
|
||||
public String getEncodedValue() {
|
||||
return valueBase64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate(XMLValidateContext validateContext)
|
||||
throws XMLSignatureException
|
||||
{
|
||||
if (validateContext == null) {
|
||||
throw new NullPointerException("context cannot be null");
|
||||
}
|
||||
|
||||
if (validated) {
|
||||
return validationStatus;
|
||||
}
|
||||
|
||||
// get validating key
|
||||
SignatureMethod sm = si.getSignatureMethod();
|
||||
Key validationKey = null;
|
||||
KeySelectorResult ksResult = null;
|
||||
try {
|
||||
KeySelector keySelector = validateContext.getKeySelector();
|
||||
if (keySelector != null) {
|
||||
ksResult = keySelector.select
|
||||
(ki, KeySelector.Purpose.VERIFY, sm, validateContext);
|
||||
if (ksResult != null) {
|
||||
validationKey = ksResult.getKey();
|
||||
}
|
||||
}
|
||||
if (validationKey == null) {
|
||||
throw new XMLSignatureException("the keyselector did not " +
|
||||
"find a validation key");
|
||||
}
|
||||
} catch (KeySelectorException kse) {
|
||||
throw new XMLSignatureException("cannot find validation " +
|
||||
"key", kse);
|
||||
}
|
||||
|
||||
// canonicalize SignedInfo and verify signature
|
||||
try {
|
||||
validationStatus = ((AbstractDOMSignatureMethod)sm).verify
|
||||
(validationKey, si, value, validateContext);
|
||||
} catch (Exception e) {
|
||||
throw new XMLSignatureException(e);
|
||||
}
|
||||
|
||||
validated = true;
|
||||
ksr = ksResult;
|
||||
return validationStatus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(o instanceof SignatureValue)) {
|
||||
return false;
|
||||
}
|
||||
SignatureValue osv = (SignatureValue)o;
|
||||
|
||||
boolean idEqual =
|
||||
id == null ? osv.getId() == null : id.equals(osv.getId());
|
||||
|
||||
//XXX compare signature values?
|
||||
return idEqual;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 17;
|
||||
if (id != null) {
|
||||
result = 31 * result + id.hashCode();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void marshal(Node parent, String dsPrefix,
|
||||
DOMCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
// create SignatureValue element
|
||||
sigValueElem = DOMUtils.createElement(ownerDoc, "SignatureValue",
|
||||
XMLSignature.XMLNS, dsPrefix);
|
||||
if (valueBase64 != null) {
|
||||
sigValueElem.appendChild(ownerDoc.createTextNode(valueBase64));
|
||||
}
|
||||
|
||||
// append Id attribute, if specified
|
||||
DOMUtils.setAttributeID(sigValueElem, "Id", id);
|
||||
parent.appendChild(sigValueElem);
|
||||
}
|
||||
|
||||
void setValue(byte[] value) {
|
||||
this.value = value;
|
||||
valueBase64 = XMLUtils.encodeToString(value);
|
||||
sigValueElem.appendChild(ownerDoc.createTextNode(valueBase64));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,385 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMXMLSignatureFactory.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
import javax.xml.crypto.dsig.dom.DOMValidateContext;
|
||||
import javax.xml.crypto.dsig.keyinfo.*;
|
||||
import javax.xml.crypto.dsig.spec.*;
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.List;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* DOM-based implementation of XMLSignatureFactory.
|
||||
*
|
||||
*/
|
||||
public final class DOMXMLSignatureFactory extends XMLSignatureFactory {
|
||||
|
||||
/**
|
||||
* Initializes a new instance of this class.
|
||||
*/
|
||||
public DOMXMLSignatureFactory() {}
|
||||
|
||||
public XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki) {
|
||||
return new DOMXMLSignature(si, ki, null, null, null);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki,
|
||||
List objects, String id, String signatureValueId) {
|
||||
return new DOMXMLSignature(si, ki, objects, id, signatureValueId);
|
||||
}
|
||||
|
||||
public Reference newReference(String uri, DigestMethod dm) {
|
||||
return newReference(uri, dm, null, null, null);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public Reference newReference(String uri, DigestMethod dm, List transforms,
|
||||
String type, String id) {
|
||||
return new DOMReference(uri, type, dm, transforms, id, getProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public Reference newReference(String uri, DigestMethod dm,
|
||||
List appliedTransforms, Data result, List transforms, String type,
|
||||
String id) {
|
||||
if (appliedTransforms == null) {
|
||||
throw new NullPointerException("appliedTransforms cannot be null");
|
||||
}
|
||||
if (appliedTransforms.isEmpty()) {
|
||||
throw new NullPointerException("appliedTransforms cannot be empty");
|
||||
}
|
||||
if (result == null) {
|
||||
throw new NullPointerException("result cannot be null");
|
||||
}
|
||||
return new DOMReference
|
||||
(uri, type, dm, appliedTransforms, result, transforms, id, getProvider());
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public Reference newReference(String uri, DigestMethod dm, List transforms,
|
||||
String type, String id, byte[] digestValue) {
|
||||
if (digestValue == null) {
|
||||
throw new NullPointerException("digestValue cannot be null");
|
||||
}
|
||||
return new DOMReference
|
||||
(uri, type, dm, null, null, transforms, id, digestValue, getProvider());
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
public SignedInfo newSignedInfo(CanonicalizationMethod cm,
|
||||
SignatureMethod sm, List references) {
|
||||
return newSignedInfo(cm, sm, references, null);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public SignedInfo newSignedInfo(CanonicalizationMethod cm,
|
||||
SignatureMethod sm, List references, String id) {
|
||||
return new DOMSignedInfo(cm, sm, references, id);
|
||||
}
|
||||
|
||||
// Object factory methods
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public XMLObject newXMLObject(List content, String id, String mimeType,
|
||||
String encoding) {
|
||||
return new DOMXMLObject(content, id, mimeType, encoding);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
public Manifest newManifest(List references) {
|
||||
return newManifest(references, null);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public Manifest newManifest(List references, String id) {
|
||||
return new DOMManifest(references, id);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public SignatureProperties newSignatureProperties(List props, String id) {
|
||||
return new DOMSignatureProperties(props, id);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public SignatureProperty newSignatureProperty
|
||||
(List info, String target, String id) {
|
||||
return new DOMSignatureProperty(info, target, id);
|
||||
}
|
||||
|
||||
public XMLSignature unmarshalXMLSignature(XMLValidateContext context)
|
||||
throws MarshalException {
|
||||
|
||||
if (context == null) {
|
||||
throw new NullPointerException("context cannot be null");
|
||||
}
|
||||
return unmarshal(((DOMValidateContext) context).getNode(), context);
|
||||
}
|
||||
|
||||
public XMLSignature unmarshalXMLSignature(XMLStructure xmlStructure)
|
||||
throws MarshalException {
|
||||
|
||||
if (xmlStructure == null) {
|
||||
throw new NullPointerException("xmlStructure cannot be null");
|
||||
}
|
||||
if (!(xmlStructure instanceof javax.xml.crypto.dom.DOMStructure)) {
|
||||
throw new ClassCastException("xmlStructure must be of type DOMStructure");
|
||||
}
|
||||
return unmarshal
|
||||
(((javax.xml.crypto.dom.DOMStructure) xmlStructure).getNode(),
|
||||
new UnmarshalContext());
|
||||
}
|
||||
|
||||
private static class UnmarshalContext extends DOMCryptoContext {
|
||||
UnmarshalContext() {}
|
||||
}
|
||||
|
||||
private XMLSignature unmarshal(Node node, XMLCryptoContext context)
|
||||
throws MarshalException {
|
||||
|
||||
node.normalize();
|
||||
|
||||
Element element = null;
|
||||
if (node.getNodeType() == Node.DOCUMENT_NODE) {
|
||||
element = ((Document) node).getDocumentElement();
|
||||
} else if (node.getNodeType() == Node.ELEMENT_NODE) {
|
||||
element = (Element) node;
|
||||
} else {
|
||||
throw new MarshalException
|
||||
("Signature element is not a proper Node");
|
||||
}
|
||||
|
||||
// check tag
|
||||
String tag = element.getLocalName();
|
||||
String namespace = element.getNamespaceURI();
|
||||
if (tag == null || namespace == null) {
|
||||
throw new MarshalException("Document implementation must " +
|
||||
"support DOM Level 2 and be namespace aware");
|
||||
}
|
||||
if ("Signature".equals(tag) && XMLSignature.XMLNS.equals(namespace)) {
|
||||
try {
|
||||
return new DOMXMLSignature(element, context, getProvider());
|
||||
} catch (MarshalException me) {
|
||||
throw me;
|
||||
} catch (Exception e) {
|
||||
throw new MarshalException(e);
|
||||
}
|
||||
} else {
|
||||
throw new MarshalException("Invalid Signature tag: " + namespace + ":" + tag);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFeatureSupported(String feature) {
|
||||
if (feature == null) {
|
||||
throw new NullPointerException();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public DigestMethod newDigestMethod(String algorithm,
|
||||
DigestMethodParameterSpec params) throws NoSuchAlgorithmException,
|
||||
InvalidAlgorithmParameterException {
|
||||
if (algorithm == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (algorithm.equals(DigestMethod.SHA1)) {
|
||||
return new DOMDigestMethod.SHA1(params);
|
||||
} else if (algorithm.equals(DOMDigestMethod.SHA224)) {
|
||||
return new DOMDigestMethod.SHA224(params);
|
||||
} else if (algorithm.equals(DigestMethod.SHA256)) {
|
||||
return new DOMDigestMethod.SHA256(params);
|
||||
} else if (algorithm.equals(DOMDigestMethod.SHA384)) {
|
||||
return new DOMDigestMethod.SHA384(params);
|
||||
} else if (algorithm.equals(DigestMethod.SHA512)) {
|
||||
return new DOMDigestMethod.SHA512(params);
|
||||
} else if (algorithm.equals(DigestMethod.RIPEMD160)) {
|
||||
return new DOMDigestMethod.RIPEMD160(params);
|
||||
} else {
|
||||
throw new NoSuchAlgorithmException("unsupported algorithm");
|
||||
}
|
||||
}
|
||||
|
||||
public SignatureMethod newSignatureMethod(String algorithm,
|
||||
SignatureMethodParameterSpec params) throws NoSuchAlgorithmException,
|
||||
InvalidAlgorithmParameterException {
|
||||
if (algorithm == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (algorithm.equals(SignatureMethod.RSA_SHA1)) {
|
||||
return new DOMSignatureMethod.SHA1withRSA(params);
|
||||
} else if (algorithm.equals(DOMSignatureMethod.RSA_SHA224)) {
|
||||
return new DOMSignatureMethod.SHA224withRSA(params);
|
||||
} else if (algorithm.equals(DOMSignatureMethod.RSA_SHA256)) {
|
||||
return new DOMSignatureMethod.SHA256withRSA(params);
|
||||
} else if (algorithm.equals(DOMSignatureMethod.RSA_SHA384)) {
|
||||
return new DOMSignatureMethod.SHA384withRSA(params);
|
||||
} else if (algorithm.equals(DOMSignatureMethod.RSA_SHA512)) {
|
||||
return new DOMSignatureMethod.SHA512withRSA(params);
|
||||
} else if (algorithm.equals(DOMSignatureMethod.RSA_RIPEMD160)) {
|
||||
return new DOMSignatureMethod.RIPEMD160withRSA(params);
|
||||
} else if (algorithm.equals(DOMSignatureMethod.RSA_SHA1_MGF1)) {
|
||||
return new DOMSignatureMethod.SHA1withRSAandMGF1(params);
|
||||
} else if (algorithm.equals(DOMSignatureMethod.RSA_SHA224_MGF1)) {
|
||||
return new DOMSignatureMethod.SHA224withRSAandMGF1(params);
|
||||
} else if (algorithm.equals(DOMSignatureMethod.RSA_SHA256_MGF1)) {
|
||||
return new DOMSignatureMethod.SHA256withRSAandMGF1(params);
|
||||
} else if (algorithm.equals(DOMSignatureMethod.RSA_SHA384_MGF1)) {
|
||||
return new DOMSignatureMethod.SHA384withRSAandMGF1(params);
|
||||
} else if (algorithm.equals(DOMSignatureMethod.RSA_SHA512_MGF1)) {
|
||||
return new DOMSignatureMethod.SHA512withRSAandMGF1(params);
|
||||
} else if (algorithm.equals(DOMSignatureMethod.RSA_RIPEMD160_MGF1)) {
|
||||
return new DOMSignatureMethod.RIPEMD160withRSAandMGF1(params);
|
||||
} else if (algorithm.equals(SignatureMethod.DSA_SHA1)) {
|
||||
return new DOMSignatureMethod.SHA1withDSA(params);
|
||||
} else if (algorithm.equals(DOMSignatureMethod.DSA_SHA256)) {
|
||||
return new DOMSignatureMethod.SHA256withDSA(params);
|
||||
} else if (algorithm.equals(SignatureMethod.HMAC_SHA1)) {
|
||||
return new DOMHMACSignatureMethod.SHA1(params);
|
||||
} else if (algorithm.equals(DOMHMACSignatureMethod.HMAC_SHA224)) {
|
||||
return new DOMHMACSignatureMethod.SHA224(params);
|
||||
} else if (algorithm.equals(DOMHMACSignatureMethod.HMAC_SHA256)) {
|
||||
return new DOMHMACSignatureMethod.SHA256(params);
|
||||
} else if (algorithm.equals(DOMHMACSignatureMethod.HMAC_SHA384)) {
|
||||
return new DOMHMACSignatureMethod.SHA384(params);
|
||||
} else if (algorithm.equals(DOMHMACSignatureMethod.HMAC_SHA512)) {
|
||||
return new DOMHMACSignatureMethod.SHA512(params);
|
||||
} else if (algorithm.equals(DOMHMACSignatureMethod.HMAC_RIPEMD160)) {
|
||||
return new DOMHMACSignatureMethod.RIPEMD160(params);
|
||||
} else if (algorithm.equals(DOMSignatureMethod.ECDSA_SHA1)) {
|
||||
return new DOMSignatureMethod.SHA1withECDSA(params);
|
||||
} else if (algorithm.equals(DOMSignatureMethod.ECDSA_SHA224)) {
|
||||
return new DOMSignatureMethod.SHA224withECDSA(params);
|
||||
} else if (algorithm.equals(DOMSignatureMethod.ECDSA_SHA256)) {
|
||||
return new DOMSignatureMethod.SHA256withECDSA(params);
|
||||
} else if (algorithm.equals(DOMSignatureMethod.ECDSA_SHA384)) {
|
||||
return new DOMSignatureMethod.SHA384withECDSA(params);
|
||||
} else if (algorithm.equals(DOMSignatureMethod.ECDSA_SHA512)) {
|
||||
return new DOMSignatureMethod.SHA512withECDSA(params);
|
||||
} else if (algorithm.equals(DOMSignatureMethod.ECDSA_RIPEMD160)) {
|
||||
return new DOMSignatureMethod.RIPEMD160withECDSA(params);
|
||||
}else {
|
||||
throw new NoSuchAlgorithmException("unsupported algorithm");
|
||||
}
|
||||
}
|
||||
|
||||
public Transform newTransform(String algorithm,
|
||||
TransformParameterSpec params) throws NoSuchAlgorithmException,
|
||||
InvalidAlgorithmParameterException {
|
||||
|
||||
TransformService spi;
|
||||
if (getProvider() == null) {
|
||||
spi = TransformService.getInstance(algorithm, "DOM");
|
||||
} else {
|
||||
try {
|
||||
spi = TransformService.getInstance(algorithm, "DOM", getProvider());
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
spi = TransformService.getInstance(algorithm, "DOM");
|
||||
}
|
||||
}
|
||||
|
||||
spi.init(params);
|
||||
return new DOMTransform(spi);
|
||||
}
|
||||
|
||||
public Transform newTransform(String algorithm,
|
||||
XMLStructure params) throws NoSuchAlgorithmException,
|
||||
InvalidAlgorithmParameterException {
|
||||
TransformService spi;
|
||||
if (getProvider() == null) {
|
||||
spi = TransformService.getInstance(algorithm, "DOM");
|
||||
} else {
|
||||
try {
|
||||
spi = TransformService.getInstance(algorithm, "DOM", getProvider());
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
spi = TransformService.getInstance(algorithm, "DOM");
|
||||
}
|
||||
}
|
||||
|
||||
if (params == null) {
|
||||
spi.init(null);
|
||||
} else {
|
||||
spi.init(params, null);
|
||||
}
|
||||
return new DOMTransform(spi);
|
||||
}
|
||||
|
||||
public CanonicalizationMethod newCanonicalizationMethod(String algorithm,
|
||||
C14NMethodParameterSpec params) throws NoSuchAlgorithmException,
|
||||
InvalidAlgorithmParameterException {
|
||||
TransformService spi;
|
||||
if (getProvider() == null) {
|
||||
spi = TransformService.getInstance(algorithm, "DOM");
|
||||
} else {
|
||||
try {
|
||||
spi = TransformService.getInstance(algorithm, "DOM", getProvider());
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
spi = TransformService.getInstance(algorithm, "DOM");
|
||||
}
|
||||
}
|
||||
|
||||
spi.init(params);
|
||||
return new DOMCanonicalizationMethod(spi);
|
||||
}
|
||||
|
||||
public CanonicalizationMethod newCanonicalizationMethod(String algorithm,
|
||||
XMLStructure params) throws NoSuchAlgorithmException,
|
||||
InvalidAlgorithmParameterException {
|
||||
TransformService spi;
|
||||
if (getProvider() == null) {
|
||||
spi = TransformService.getInstance(algorithm, "DOM");
|
||||
} else {
|
||||
try {
|
||||
spi = TransformService.getInstance(algorithm, "DOM", getProvider());
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
spi = TransformService.getInstance(algorithm, "DOM");
|
||||
}
|
||||
}
|
||||
if (params == null) {
|
||||
spi.init(null);
|
||||
} else {
|
||||
spi.init(params, null);
|
||||
}
|
||||
|
||||
return new DOMCanonicalizationMethod(spi);
|
||||
}
|
||||
|
||||
public URIDereferencer getURIDereferencer() {
|
||||
return DOMURIDereferencer.INSTANCE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*
|
||||
* ===========================================================================
|
||||
*
|
||||
* (C) Copyright IBM Corp. 2003 All Rights Reserved.
|
||||
*
|
||||
* ===========================================================================
|
||||
*/
|
||||
/*
|
||||
* Portions copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMXPathFilter2Transform.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
|
||||
import javax.xml.crypto.dsig.spec.XPathType;
|
||||
import javax.xml.crypto.dsig.spec.XPathFilter2ParameterSpec;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
|
||||
/**
|
||||
* DOM-based implementation of XPath Filter 2.0 Transform.
|
||||
* (Uses Apache XML-Sec Transform implementation)
|
||||
*
|
||||
*/
|
||||
public final class DOMXPathFilter2Transform extends ApacheTransform {
|
||||
|
||||
public void init(TransformParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException
|
||||
{
|
||||
if (params == null) {
|
||||
throw new InvalidAlgorithmParameterException("params are required");
|
||||
} else if (!(params instanceof XPathFilter2ParameterSpec)) {
|
||||
throw new InvalidAlgorithmParameterException
|
||||
("params must be of type XPathFilter2ParameterSpec");
|
||||
}
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
public void init(XMLStructure parent, XMLCryptoContext context)
|
||||
throws InvalidAlgorithmParameterException
|
||||
{
|
||||
super.init(parent, context);
|
||||
try {
|
||||
unmarshalParams(DOMUtils.getFirstChildElement(transformElem));
|
||||
} catch (MarshalException me) {
|
||||
throw new InvalidAlgorithmParameterException(me);
|
||||
}
|
||||
}
|
||||
|
||||
private void unmarshalParams(Element curXPathElem) throws MarshalException
|
||||
{
|
||||
List<XPathType> list = new ArrayList<>();
|
||||
Element currentElement = curXPathElem;
|
||||
while (currentElement != null) {
|
||||
String xPath = currentElement.getFirstChild().getNodeValue();
|
||||
String filterVal = DOMUtils.getAttributeValue(currentElement,
|
||||
"Filter");
|
||||
if (filterVal == null) {
|
||||
throw new MarshalException("filter cannot be null");
|
||||
}
|
||||
XPathType.Filter filter = null;
|
||||
if ("intersect".equals(filterVal)) {
|
||||
filter = XPathType.Filter.INTERSECT;
|
||||
} else if ("subtract".equals(filterVal)) {
|
||||
filter = XPathType.Filter.SUBTRACT;
|
||||
} else if ("union".equals(filterVal)) {
|
||||
filter = XPathType.Filter.UNION;
|
||||
} else {
|
||||
throw new MarshalException("Unknown XPathType filter type" +
|
||||
filterVal);
|
||||
}
|
||||
NamedNodeMap attributes = currentElement.getAttributes();
|
||||
if (attributes != null) {
|
||||
int length = attributes.getLength();
|
||||
Map<String, String> namespaceMap =
|
||||
new HashMap<>(length);
|
||||
for (int i = 0; i < length; i++) {
|
||||
Attr attr = (Attr)attributes.item(i);
|
||||
String prefix = attr.getPrefix();
|
||||
if (prefix != null && "xmlns".equals(prefix)) {
|
||||
namespaceMap.put(attr.getLocalName(), attr.getValue());
|
||||
}
|
||||
}
|
||||
list.add(new XPathType(xPath, filter, namespaceMap));
|
||||
} else {
|
||||
list.add(new XPathType(xPath, filter));
|
||||
}
|
||||
|
||||
currentElement = DOMUtils.getNextSiblingElement(currentElement);
|
||||
}
|
||||
this.params = new XPathFilter2ParameterSpec(list);
|
||||
}
|
||||
|
||||
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
super.marshalParams(parent, context);
|
||||
XPathFilter2ParameterSpec xp =
|
||||
(XPathFilter2ParameterSpec)getParameterSpec();
|
||||
String prefix = DOMUtils.getNSPrefix(context, Transform.XPATH2);
|
||||
String qname = prefix == null || prefix.length() == 0
|
||||
? "xmlns" : "xmlns:" + prefix;
|
||||
@SuppressWarnings("unchecked")
|
||||
List<XPathType> xpathList = xp.getXPathList();
|
||||
for (XPathType xpathType : xpathList) {
|
||||
Element elem = DOMUtils.createElement(ownerDoc, "XPath",
|
||||
Transform.XPATH2, prefix);
|
||||
elem.appendChild
|
||||
(ownerDoc.createTextNode(xpathType.getExpression()));
|
||||
DOMUtils.setAttribute(elem, "Filter",
|
||||
xpathType.getFilter().toString());
|
||||
elem.setAttributeNS("http://www.w3.org/2000/xmlns/", qname,
|
||||
Transform.XPATH2);
|
||||
|
||||
// add namespace attributes, if necessary
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<Map.Entry<String, String>> entries =
|
||||
xpathType.getNamespaceMap().entrySet();
|
||||
for (Map.Entry<String, String> entry : entries) {
|
||||
elem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:" +
|
||||
entry.getKey(),
|
||||
entry.getValue());
|
||||
}
|
||||
|
||||
transformElem.appendChild(elem);
|
||||
}
|
||||
}
|
||||
}
|
||||
113
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMXPathTransform.java
Normal file
113
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/DOMXPathTransform.java
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMXPathTransform.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
|
||||
import javax.xml.crypto.dsig.spec.XPathFilterParameterSpec;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
|
||||
/**
|
||||
* DOM-based implementation of XPath Filtering Transform.
|
||||
* (Uses Apache XML-Sec Transform implementation)
|
||||
*
|
||||
*/
|
||||
public final class DOMXPathTransform extends ApacheTransform {
|
||||
|
||||
@Override
|
||||
public void init(TransformParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException
|
||||
{
|
||||
if (params == null) {
|
||||
throw new InvalidAlgorithmParameterException("params are required");
|
||||
} else if (!(params instanceof XPathFilterParameterSpec)) {
|
||||
throw new InvalidAlgorithmParameterException
|
||||
("params must be of type XPathFilterParameterSpec");
|
||||
}
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
public void init(XMLStructure parent, XMLCryptoContext context)
|
||||
throws InvalidAlgorithmParameterException
|
||||
{
|
||||
super.init(parent, context);
|
||||
unmarshalParams(DOMUtils.getFirstChildElement(transformElem));
|
||||
}
|
||||
|
||||
private void unmarshalParams(Element paramsElem) {
|
||||
String xPath = paramsElem.getFirstChild().getNodeValue();
|
||||
// create a Map of namespace prefixes
|
||||
NamedNodeMap attributes = paramsElem.getAttributes();
|
||||
if (attributes != null) {
|
||||
int length = attributes.getLength();
|
||||
Map<String, String> namespaceMap =
|
||||
new HashMap<>(length);
|
||||
for (int i = 0; i < length; i++) {
|
||||
Attr attr = (Attr)attributes.item(i);
|
||||
String prefix = attr.getPrefix();
|
||||
if (prefix != null && "xmlns".equals(prefix)) {
|
||||
namespaceMap.put(attr.getLocalName(), attr.getValue());
|
||||
}
|
||||
}
|
||||
this.params = new XPathFilterParameterSpec(xPath, namespaceMap);
|
||||
} else {
|
||||
this.params = new XPathFilterParameterSpec(xPath);
|
||||
}
|
||||
}
|
||||
|
||||
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
super.marshalParams(parent, context);
|
||||
XPathFilterParameterSpec xp =
|
||||
(XPathFilterParameterSpec)getParameterSpec();
|
||||
Element xpathElem = DOMUtils.createElement(ownerDoc, "XPath",
|
||||
XMLSignature.XMLNS, DOMUtils.getSignaturePrefix(context));
|
||||
xpathElem.appendChild(ownerDoc.createTextNode(xp.getXPath()));
|
||||
|
||||
// add namespace attributes, if necessary
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<Map.Entry<String, String>> entries =
|
||||
xp.getNamespaceMap().entrySet();
|
||||
for (Map.Entry<String, String> entry : entries) {
|
||||
xpathElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:" +
|
||||
entry.getKey(),
|
||||
entry.getValue());
|
||||
}
|
||||
|
||||
transformElem.appendChild(xpathElem);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMXSLTTransform.java 1854026 2019-02-21 09:30:01Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
|
||||
import javax.xml.crypto.dsig.spec.XSLTTransformParameterSpec;
|
||||
|
||||
/**
|
||||
* DOM-based implementation of XSLT Transform.
|
||||
* (Uses Apache XML-Sec Transform implementation)
|
||||
*
|
||||
*/
|
||||
public final class DOMXSLTTransform extends ApacheTransform {
|
||||
|
||||
@Override
|
||||
public void init(TransformParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
if (params == null) {
|
||||
throw new InvalidAlgorithmParameterException("params are required");
|
||||
}
|
||||
if (!(params instanceof XSLTTransformParameterSpec)) {
|
||||
throw new InvalidAlgorithmParameterException("unrecognized params");
|
||||
}
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
public void init(XMLStructure parent, XMLCryptoContext context)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
|
||||
super.init(parent, context);
|
||||
unmarshalParams(DOMUtils.getFirstChildElement(transformElem));
|
||||
}
|
||||
|
||||
private void unmarshalParams(Element sheet) {
|
||||
this.params = new XSLTTransformParameterSpec
|
||||
(new javax.xml.crypto.dom.DOMStructure(sheet));
|
||||
}
|
||||
|
||||
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
|
||||
throws MarshalException {
|
||||
super.marshalParams(parent, context);
|
||||
XSLTTransformParameterSpec xp =
|
||||
(XSLTTransformParameterSpec) getParameterSpec();
|
||||
Node xsltElem =
|
||||
((javax.xml.crypto.dom.DOMStructure) xp.getStylesheet()).getNode();
|
||||
DOMUtils.appendChild(transformElem, xsltElem);
|
||||
}
|
||||
}
|
||||
196
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/Policy.java
Normal file
196
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/Policy.java
Normal file
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.security.AccessController;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.security.Security;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* The secure validation policy as specified by the
|
||||
* jdk.xml.dsig.secureValidationPolicy security property.
|
||||
*/
|
||||
public final class Policy {
|
||||
|
||||
// all restrictions are initialized to be unconstrained
|
||||
private static Set<URI> disallowedAlgs = new HashSet<>();
|
||||
private static int maxTrans = Integer.MAX_VALUE;
|
||||
private static int maxRefs = Integer.MAX_VALUE;
|
||||
private static Set<String> disallowedRefUriSchemes = new HashSet<>();
|
||||
private static Map<String, Integer> minKeyMap = new HashMap<>();
|
||||
private static boolean noDuplicateIds = false;
|
||||
private static boolean noRMLoops = false;
|
||||
|
||||
static {
|
||||
try {
|
||||
initialize();
|
||||
} catch (Exception e) {
|
||||
throw new SecurityException(
|
||||
"Cannot initialize the secure validation policy", e);
|
||||
}
|
||||
}
|
||||
|
||||
private Policy() {}
|
||||
|
||||
private static void initialize() {
|
||||
String prop =
|
||||
AccessController.doPrivileged((PrivilegedAction<String>) () ->
|
||||
Security.getProperty("jdk.xml.dsig.secureValidationPolicy"));
|
||||
if (prop == null || prop.isEmpty()) {
|
||||
// no policy specified, so don't enforce any restrictions
|
||||
return;
|
||||
}
|
||||
String[] entries = prop.split(",");
|
||||
for (String entry : entries) {
|
||||
String[] tokens = entry.split("\\s");
|
||||
String type = tokens[0];
|
||||
switch(type) {
|
||||
case "disallowAlg":
|
||||
if (tokens.length != 2) {
|
||||
error(entry);
|
||||
}
|
||||
disallowedAlgs.add(URI.create(tokens[1]));
|
||||
break;
|
||||
case "maxTransforms":
|
||||
if (tokens.length != 2) {
|
||||
error(entry);
|
||||
}
|
||||
maxTrans = Integer.parseUnsignedInt(tokens[1]);
|
||||
break;
|
||||
case "maxReferences":
|
||||
if (tokens.length != 2) {
|
||||
error(entry);
|
||||
}
|
||||
maxRefs = Integer.parseUnsignedInt(tokens[1]);
|
||||
break;
|
||||
case "disallowReferenceUriSchemes":
|
||||
if (tokens.length == 1) {
|
||||
error(entry);
|
||||
}
|
||||
for (int i = 1; i < tokens.length; i++) {
|
||||
String scheme = tokens[i];
|
||||
disallowedRefUriSchemes.add(
|
||||
scheme.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
break;
|
||||
case "minKeySize":
|
||||
if (tokens.length != 3) {
|
||||
error(entry);
|
||||
}
|
||||
minKeyMap.put(tokens[1],
|
||||
Integer.parseUnsignedInt(tokens[2]));
|
||||
break;
|
||||
case "noDuplicateIds":
|
||||
if (tokens.length != 1) {
|
||||
error(entry);
|
||||
}
|
||||
noDuplicateIds = true;
|
||||
break;
|
||||
case "noRetrievalMethodLoops":
|
||||
if (tokens.length != 1) {
|
||||
error(entry);
|
||||
}
|
||||
noRMLoops = true;
|
||||
break;
|
||||
default:
|
||||
error(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean restrictAlg(String alg) {
|
||||
try {
|
||||
URI uri = new URI(alg);
|
||||
return disallowedAlgs.contains(uri);
|
||||
} catch (URISyntaxException use) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean restrictNumTransforms(int numTrans) {
|
||||
return (numTrans > maxTrans);
|
||||
}
|
||||
|
||||
public static boolean restrictNumReferences(int numRefs) {
|
||||
return (numRefs > maxRefs);
|
||||
}
|
||||
|
||||
public static boolean restrictReferenceUriScheme(String uri) {
|
||||
if (uri != null) {
|
||||
String scheme = java.net.URI.create(uri).getScheme();
|
||||
if (scheme != null) {
|
||||
return disallowedRefUriSchemes.contains(
|
||||
scheme.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean restrictKey(String type, int size) {
|
||||
return (size < minKeyMap.getOrDefault(type, 0));
|
||||
}
|
||||
|
||||
public static boolean restrictDuplicateIds() {
|
||||
return noDuplicateIds;
|
||||
}
|
||||
|
||||
public static boolean restrictRetrievalMethodLoops() {
|
||||
return noRMLoops;
|
||||
}
|
||||
|
||||
public static Set<URI> disabledAlgs() {
|
||||
return Collections.<URI>unmodifiableSet(disallowedAlgs);
|
||||
}
|
||||
|
||||
public static int maxTransforms() {
|
||||
return maxTrans;
|
||||
}
|
||||
|
||||
public static int maxReferences() {
|
||||
return maxRefs;
|
||||
}
|
||||
|
||||
public static Set<String> disabledReferenceUriSchemes() {
|
||||
return Collections.<String>unmodifiableSet(disallowedRefUriSchemes);
|
||||
}
|
||||
|
||||
public static int minKeySize(String type) {
|
||||
return minKeyMap.getOrDefault(type, 0);
|
||||
}
|
||||
|
||||
private static void error(String entry) {
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid jdk.xml.dsig.secureValidationPolicy entry: " + entry);
|
||||
}
|
||||
}
|
||||
123
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/Utils.java
Normal file
123
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/Utils.java
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* 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, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: Utils.java 1788465 2017-03-24 15:10:51Z coheigea $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import javax.xml.crypto.XMLCryptoContext;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* Miscellaneous static utility methods for use in JSR 105 RI.
|
||||
*
|
||||
*/
|
||||
public final class Utils {
|
||||
|
||||
private Utils() {}
|
||||
|
||||
public static byte[] readBytesFromStream(InputStream is)
|
||||
throws IOException
|
||||
{
|
||||
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
||||
byte[] buf = new byte[1024];
|
||||
while (true) {
|
||||
int read = is.read(buf);
|
||||
if (read == -1) { // EOF
|
||||
break;
|
||||
}
|
||||
baos.write(buf, 0, read);
|
||||
if (read < 1024) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return baos.toByteArray();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an Iterator to a Set of Nodes, according to the XPath
|
||||
* Data Model.
|
||||
*
|
||||
* @param i the Iterator
|
||||
* @return the Set of Nodes
|
||||
*/
|
||||
static Set<Node> toNodeSet(Iterator<Node> i) {
|
||||
Set<Node> nodeSet = new HashSet<>();
|
||||
while (i.hasNext()) {
|
||||
Node n = i.next();
|
||||
nodeSet.add(n);
|
||||
// insert attributes nodes to comply with XPath
|
||||
if (n.getNodeType() == Node.ELEMENT_NODE) {
|
||||
NamedNodeMap nnm = n.getAttributes();
|
||||
for (int j = 0, length = nnm.getLength(); j < length; j++) {
|
||||
nodeSet.add(nnm.item(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
return nodeSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID from a same-document URI (ex: "#id")
|
||||
*/
|
||||
public static String parseIdFromSameDocumentURI(String uri) {
|
||||
if (uri.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
String id = uri.substring(1);
|
||||
if (id != null && id.startsWith("xpointer(id(")) {
|
||||
int i1 = id.indexOf('\'');
|
||||
int i2 = id.indexOf('\'', i1+1);
|
||||
id = id.substring(i1+1, i2);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if uri is a same-document URI, false otherwise.
|
||||
*/
|
||||
public static boolean sameDocumentURI(String uri) {
|
||||
return uri != null && (uri.length() == 0 || uri.charAt(0) == '#');
|
||||
}
|
||||
|
||||
static boolean secureValidation(XMLCryptoContext xc) {
|
||||
if (xc == null) {
|
||||
return false;
|
||||
}
|
||||
return getBoolean(xc, "org.jcp.xml.dsig.secureValidation");
|
||||
}
|
||||
|
||||
private static boolean getBoolean(XMLCryptoContext xc, String name) {
|
||||
Boolean value = (Boolean)xc.getProperty(name);
|
||||
return value != null && value.booleanValue();
|
||||
}
|
||||
}
|
||||
161
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/XMLDSigRI.java
Normal file
161
jdkSrc/jdk8/org/jcp/xml/dsig/internal/dom/XMLDSigRI.java
Normal file
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*
|
||||
* ===========================================================================
|
||||
*
|
||||
* (C) Copyright IBM Corp. 2003 All Rights Reserved.
|
||||
*
|
||||
* ===========================================================================
|
||||
*/
|
||||
/*
|
||||
* Portions copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* $Id: XMLDSigRI.java 1833618 2018-06-15 17:36:20Z mullan $
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import java.util.*;
|
||||
import java.security.*;
|
||||
|
||||
import javax.xml.crypto.dsig.*;
|
||||
|
||||
/**
|
||||
* The XMLDSig RI Provider.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Defines the XMLDSigRI provider.
|
||||
*/
|
||||
|
||||
public final class XMLDSigRI extends Provider {
|
||||
|
||||
static final long serialVersionUID = -5049765099299494554L;
|
||||
|
||||
private static final String INFO = "XMLDSig " +
|
||||
"(DOM XMLSignatureFactory; DOM KeyInfoFactory; " +
|
||||
"C14N 1.0, C14N 1.1, Exclusive C14N, Base64, Enveloped, XPath, " +
|
||||
"XPath2, XSLT TransformServices)";
|
||||
|
||||
public XMLDSigRI() {
|
||||
/* We are the XMLDSig provider */
|
||||
super("XMLDSig", 1.8d, INFO);
|
||||
|
||||
final Map<Object, Object> map = new HashMap<Object, Object>();
|
||||
map.put("XMLSignatureFactory.DOM",
|
||||
"org.jcp.xml.dsig.internal.dom.DOMXMLSignatureFactory");
|
||||
map.put("KeyInfoFactory.DOM",
|
||||
"org.jcp.xml.dsig.internal.dom.DOMKeyInfoFactory");
|
||||
|
||||
|
||||
// Inclusive C14N
|
||||
map.put("TransformService." + CanonicalizationMethod.INCLUSIVE,
|
||||
"org.jcp.xml.dsig.internal.dom.DOMCanonicalXMLC14NMethod");
|
||||
map.put("Alg.Alias.TransformService.INCLUSIVE",
|
||||
CanonicalizationMethod.INCLUSIVE);
|
||||
map.put("TransformService." + CanonicalizationMethod.INCLUSIVE +
|
||||
" MechanismType", "DOM");
|
||||
|
||||
// InclusiveWithComments C14N
|
||||
map.put("TransformService." +
|
||||
CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS,
|
||||
"org.jcp.xml.dsig.internal.dom.DOMCanonicalXMLC14NMethod");
|
||||
map.put("Alg.Alias.TransformService.INCLUSIVE_WITH_COMMENTS",
|
||||
CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS);
|
||||
map.put("TransformService." +
|
||||
CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS +
|
||||
" MechanismType", "DOM");
|
||||
|
||||
// Inclusive C14N 1.1
|
||||
map.put("TransformService.http://www.w3.org/2006/12/xml-c14n11",
|
||||
"org.jcp.xml.dsig.internal.dom.DOMCanonicalXMLC14N11Method");
|
||||
map.put("TransformService.http://www.w3.org/2006/12/xml-c14n11" +
|
||||
" MechanismType", "DOM");
|
||||
|
||||
// InclusiveWithComments C14N 1.1
|
||||
map.put("TransformService.http://www.w3.org/2006/12/xml-c14n11#WithComments",
|
||||
"org.jcp.xml.dsig.internal.dom.DOMCanonicalXMLC14N11Method");
|
||||
map.put("TransformService.http://www.w3.org/2006/12/xml-c14n11#WithComments" +
|
||||
" MechanismType", "DOM");
|
||||
|
||||
// Exclusive C14N
|
||||
map.put("TransformService." + CanonicalizationMethod.EXCLUSIVE,
|
||||
"org.jcp.xml.dsig.internal.dom.DOMExcC14NMethod");
|
||||
map.put("Alg.Alias.TransformService.EXCLUSIVE",
|
||||
CanonicalizationMethod.EXCLUSIVE);
|
||||
map.put("TransformService." + CanonicalizationMethod.EXCLUSIVE +
|
||||
" MechanismType", "DOM");
|
||||
|
||||
// ExclusiveWithComments C14N
|
||||
map.put("TransformService." +
|
||||
CanonicalizationMethod.EXCLUSIVE_WITH_COMMENTS,
|
||||
"org.jcp.xml.dsig.internal.dom.DOMExcC14NMethod");
|
||||
map.put("Alg.Alias.TransformService.EXCLUSIVE_WITH_COMMENTS",
|
||||
CanonicalizationMethod.EXCLUSIVE_WITH_COMMENTS);
|
||||
map.put("TransformService." +
|
||||
CanonicalizationMethod.EXCLUSIVE_WITH_COMMENTS +
|
||||
" MechanismType", "DOM");
|
||||
|
||||
// Base64 Transform
|
||||
map.put("TransformService." + Transform.BASE64,
|
||||
"org.jcp.xml.dsig.internal.dom.DOMBase64Transform");
|
||||
map.put("Alg.Alias.TransformService.BASE64", Transform.BASE64);
|
||||
map.put("TransformService." + Transform.BASE64 +
|
||||
" MechanismType", "DOM");
|
||||
|
||||
// Enveloped Transform
|
||||
map.put("TransformService." + Transform.ENVELOPED,
|
||||
"org.jcp.xml.dsig.internal.dom.DOMEnvelopedTransform");
|
||||
map.put("Alg.Alias.TransformService.ENVELOPED", Transform.ENVELOPED);
|
||||
map.put("TransformService." + Transform.ENVELOPED +
|
||||
" MechanismType", "DOM");
|
||||
|
||||
// XPath2 Transform
|
||||
map.put("TransformService." + Transform.XPATH2,
|
||||
"org.jcp.xml.dsig.internal.dom.DOMXPathFilter2Transform");
|
||||
map.put("Alg.Alias.TransformService.XPATH2", Transform.XPATH2);
|
||||
map.put("TransformService." + Transform.XPATH2 +
|
||||
" MechanismType", "DOM");
|
||||
|
||||
// XPath Transform
|
||||
map.put("TransformService." + Transform.XPATH,
|
||||
"org.jcp.xml.dsig.internal.dom.DOMXPathTransform");
|
||||
map.put("Alg.Alias.TransformService.XPATH", Transform.XPATH);
|
||||
map.put("TransformService." + Transform.XPATH +
|
||||
" MechanismType", "DOM");
|
||||
|
||||
// XSLT Transform
|
||||
map.put("TransformService." + Transform.XSLT,
|
||||
"org.jcp.xml.dsig.internal.dom.DOMXSLTTransform");
|
||||
map.put("Alg.Alias.TransformService.XSLT", Transform.XSLT);
|
||||
map.put("TransformService." + Transform.XSLT + " MechanismType", "DOM");
|
||||
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
putAll(map);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
86
jdkSrc/jdk8/org/omg/CORBA/ACTIVITY_COMPLETED.java
Normal file
86
jdkSrc/jdk8/org/omg/CORBA/ACTIVITY_COMPLETED.java
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
/**
|
||||
* The <code>ACTIVITY_COMPLETED</code> system exception may be raised on any
|
||||
* method for which Activity context is accessed. It indicates that the
|
||||
* Activity context in which the method call was made has been completed due
|
||||
* to a timeout of either the Activity itself or a transaction that encompasses
|
||||
* the Activity, or that the Activity completed in a manner other than that
|
||||
* originally requested.
|
||||
*
|
||||
* @see <A href="../../../../technotes/guides/idl/jidlExceptions.html">documentation on
|
||||
* Java IDL exceptions</A>
|
||||
* @since J2SE 1.5
|
||||
*/
|
||||
|
||||
public final class ACTIVITY_COMPLETED extends SystemException {
|
||||
|
||||
/**
|
||||
* Constructs an <code>ACTIVITY_COMPLETED</code> exception with
|
||||
* minor code set to 0 and CompletionStatus set to COMPLETED_NO.
|
||||
*/
|
||||
public ACTIVITY_COMPLETED() {
|
||||
this("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an <code>ACTIVITY_COMPLETED</code> exception with the
|
||||
* specified message.
|
||||
*
|
||||
* @param detailMessage string containing a detailed message.
|
||||
*/
|
||||
public ACTIVITY_COMPLETED(String detailMessage) {
|
||||
this(detailMessage, 0, CompletionStatus.COMPLETED_NO);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an <code>ACTIVITY_COMPLETED</code> exception with the
|
||||
* specified minor code and completion status.
|
||||
*
|
||||
* @param minorCode minor code.
|
||||
* @param completionStatus completion status.
|
||||
*/
|
||||
public ACTIVITY_COMPLETED(int minorCode,
|
||||
CompletionStatus completionStatus) {
|
||||
this("", minorCode, completionStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an <code>ACTIVITY_COMPLETED</code> exception with the
|
||||
* specified message, minor code, and completion status.
|
||||
*
|
||||
* @param detailMessage string containing a detailed message.
|
||||
* @param minorCode minor code.
|
||||
* @param completionStatus completion status.
|
||||
*/
|
||||
public ACTIVITY_COMPLETED(String detailMessage,
|
||||
int minorCode,
|
||||
CompletionStatus completionStatus) {
|
||||
super(detailMessage, minorCode, completionStatus);
|
||||
}
|
||||
}
|
||||
84
jdkSrc/jdk8/org/omg/CORBA/ACTIVITY_REQUIRED.java
Normal file
84
jdkSrc/jdk8/org/omg/CORBA/ACTIVITY_REQUIRED.java
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
/**
|
||||
* The <code>ACTIVITY_REQUIRED</code> system exception may be raised on any
|
||||
* method for which an Activity context is required. It indicates that an
|
||||
* Activity context was necessary to perform the invoked operation, but one
|
||||
* was not found associated with the calling thread.
|
||||
*
|
||||
* @see <A href="../../../../technotes/guides/idl/jidlExceptions.html">documentation on
|
||||
* Java IDL exceptions</A>
|
||||
* @since J2SE 1.5
|
||||
*/
|
||||
|
||||
public final class ACTIVITY_REQUIRED extends SystemException {
|
||||
|
||||
/**
|
||||
* Constructs an <code>ACTIVITY_REQUIRED</code> exception with
|
||||
* minor code set to 0 and CompletionStatus set to COMPLETED_NO.
|
||||
*/
|
||||
public ACTIVITY_REQUIRED() {
|
||||
this("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an <code>ACTIVITY_REQUIRED</code> exception with the
|
||||
* specified message.
|
||||
*
|
||||
* @param detailMessage string containing a detailed message.
|
||||
*/
|
||||
public ACTIVITY_REQUIRED(String detailMessage) {
|
||||
this(detailMessage, 0, CompletionStatus.COMPLETED_NO);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an <code>ACTIVITY_REQUIRED</code> exception with the
|
||||
* specified minor code and completion status.
|
||||
*
|
||||
* @param minorCode minor code.
|
||||
* @param completionStatus completion status.
|
||||
*/
|
||||
public ACTIVITY_REQUIRED(int minorCode,
|
||||
CompletionStatus completionStatus) {
|
||||
this("", minorCode, completionStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an <code>ACTIVITY_REQUIRED</code> exception with the
|
||||
* specified message, minor code, and completion status.
|
||||
*
|
||||
* @param detailMessage string containing a detailed message.
|
||||
* @param minorCode minor code.
|
||||
* @param completionStatus completion status.
|
||||
*/
|
||||
public ACTIVITY_REQUIRED(String detailMessage,
|
||||
int minorCode,
|
||||
CompletionStatus completionStatus) {
|
||||
super(detailMessage, minorCode, completionStatus);
|
||||
}
|
||||
}
|
||||
53
jdkSrc/jdk8/org/omg/CORBA/ARG_IN.java
Normal file
53
jdkSrc/jdk8/org/omg/CORBA/ARG_IN.java
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
/**
|
||||
* Signifies an "input" argument to an invocation,
|
||||
* meaning that the argument is being passed from the client to
|
||||
* the server.
|
||||
* <code>ARG_IN.value</code> is one of the possible values used to
|
||||
* indicate the direction in
|
||||
* which a parameter is being passed during an invocation performed
|
||||
* using the Dynamic Invocation Interface (DII).
|
||||
* <P>
|
||||
* The code fragment below shows a typical usage:
|
||||
* <PRE>
|
||||
* ORB orb = ORB.init(args, null);
|
||||
* org.omg.CORBA.NamedValue nv = orb.create_named_value(
|
||||
* "IDLArgumentIdentifier", myAny, org.omg.CORBA.ARG_IN.value);
|
||||
* </PRE>
|
||||
*
|
||||
* @see org.omg.CORBA.NamedValue
|
||||
* @since JDK1.2
|
||||
*/
|
||||
public interface ARG_IN {
|
||||
|
||||
/**
|
||||
* The value indicating an input argument.
|
||||
*/
|
||||
int value = 1;
|
||||
}
|
||||
54
jdkSrc/jdk8/org/omg/CORBA/ARG_INOUT.java
Normal file
54
jdkSrc/jdk8/org/omg/CORBA/ARG_INOUT.java
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
/**
|
||||
* Signifies an argument used for both input and output in an invocation,
|
||||
* meaning that the argument is being passed from the client to
|
||||
* the server and then back from the server to the client.
|
||||
* <code>ARG_INOUT.value</code> is one of the possible values used to
|
||||
* indicate the direction in
|
||||
* which a parameter is being passed during a dynamic invocation
|
||||
* using the Dynamic Invocation Interface (DII).
|
||||
* <P>
|
||||
* The code fragment below shows a typical usage:
|
||||
* <PRE>
|
||||
* ORB orb = ORB.init(args, null);
|
||||
* org.omg.CORBA.NamedValue nv = orb.create_named_value(
|
||||
* "argumentIdentifier", myAny, org.omg.CORBA.ARG_INOUT.value);
|
||||
* </PRE>
|
||||
*
|
||||
* @see org.omg.CORBA.NamedValue
|
||||
* @since JDK1.2
|
||||
*/
|
||||
public interface ARG_INOUT {
|
||||
|
||||
/**
|
||||
* The constant value indicating an argument used for both
|
||||
* input and output.
|
||||
*/
|
||||
int value = 3;
|
||||
}
|
||||
53
jdkSrc/jdk8/org/omg/CORBA/ARG_OUT.java
Normal file
53
jdkSrc/jdk8/org/omg/CORBA/ARG_OUT.java
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
/**
|
||||
* A constant that signifies an "output" argument to an invocation,
|
||||
* meaning that the argument is being passed from the server to
|
||||
* the client.
|
||||
* <code>ARG_OUT.value</code> is one of the possible values used
|
||||
* to indicate the direction in
|
||||
* which a parameter is being passed during a dynamic invocation
|
||||
* using the Dynamic Invocation Interface (DII).
|
||||
* <P>
|
||||
* The code fragment below shows a typical usage:
|
||||
* <PRE>
|
||||
* ORB orb = ORB.init(args, null);
|
||||
* org.omg.CORBA.NamedValue nv = orb.create_named_value(
|
||||
* "argumentIdentifier", myAny, org.omg.CORBA.ARG_OUT.value);
|
||||
* </PRE>
|
||||
*
|
||||
* @see org.omg.CORBA.NamedValue
|
||||
* @since JDK1.2
|
||||
*/
|
||||
public interface ARG_OUT {
|
||||
|
||||
/**
|
||||
* The constant value indicating an output argument.
|
||||
*/
|
||||
int value = 2;
|
||||
}
|
||||
721
jdkSrc/jdk8/org/omg/CORBA/Any.java
Normal file
721
jdkSrc/jdk8/org/omg/CORBA/Any.java
Normal file
@@ -0,0 +1,721 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
import org.omg.CORBA.portable.InputStream;
|
||||
import org.omg.CORBA.portable.OutputStream;
|
||||
import org.omg.CORBA.portable.Streamable;
|
||||
import org.omg.CORBA.portable.IDLEntity;
|
||||
|
||||
/**
|
||||
* Serves as a container for any data that can be
|
||||
* described in IDL or for any IDL primitive type.
|
||||
* An <code>Any</code> object is used as a component of a
|
||||
* <code>NamedValue</code> object, which provides information about
|
||||
* arguments or return values in requests, and which is used to define
|
||||
* name/value pairs in <code>Context</code> objects.
|
||||
<p>
|
||||
*
|
||||
* An <code>Any</code> object consists of two parts:
|
||||
* <OL>
|
||||
* <LI>a data value
|
||||
* <LI>a <code>TypeCode</code> object describing the type of the data
|
||||
* value contained in the <code>Any</code> object. For example,
|
||||
* a <code>TypeCode</code> object for an array contains
|
||||
* a field for the length of the array and a field for
|
||||
* the type of elements in the array. (Note that in this case, the
|
||||
* second field of the <code>TypeCode</code> object is itself a
|
||||
* <code>TypeCode</code> object.)
|
||||
* </OL>
|
||||
*
|
||||
* <P>
|
||||
* <a name="anyOps"</a>
|
||||
* A large part of the <code>Any</code> class consists of pairs of methods
|
||||
* for inserting values into and extracting values from an
|
||||
* <code>Any</code> object.
|
||||
* <P>
|
||||
* For a given primitive type X, these methods are:
|
||||
* <dl>
|
||||
* <dt><code><bold> void insert_X(X x)</bold></code>
|
||||
* <dd> This method allows the insertion of
|
||||
* an instance <code>x</code> of primitive type <code>X</code>
|
||||
* into the <code>value</code> field of the <code>Any</code> object.
|
||||
* Note that the method
|
||||
* <code>insert_X</code> also resets the <code>Any</code> object's
|
||||
* <code>type</code> field if necessary.
|
||||
* <dt> <code><bold>X extract_X()</bold></code>
|
||||
* <dd> This method allows the extraction of an instance of
|
||||
* type <code>X</code> from the <code>Any</code> object.
|
||||
* <BR>
|
||||
* <P>
|
||||
* This method throws the exception <code>BAD_OPERATION</code> under two conditions:
|
||||
* <OL>
|
||||
* <LI> the type of the element contained in the <code>Any</code> object is not
|
||||
* <code>X</code>
|
||||
* <LI> the method <code>extract_X</code> is called before
|
||||
* the <code>value</code> field of the <code>Any</code> object
|
||||
* has been set
|
||||
* </OL>
|
||||
* </dl>
|
||||
* <P>
|
||||
* There are distinct method pairs for each
|
||||
* primitive IDL data type (<code>insert_long</code> and <code>extract_long</code>,
|
||||
* <code>insert_string</code> and <code>extract_string</code>, and so on).<BR>
|
||||
* <P>
|
||||
* The class <code>Any</code> also has methods for
|
||||
* getting and setting the type code,
|
||||
* for testing two <code>Any</code> objects for equality,
|
||||
* and for reading an <code>Any</code> object from a stream or
|
||||
* writing it to a stream.
|
||||
* <BR>
|
||||
* @since JDK1.2
|
||||
*/
|
||||
abstract public class Any implements IDLEntity {
|
||||
|
||||
/**
|
||||
* Checks for equality between this <code>Any</code> object and the
|
||||
* given <code>Any</code> object. Two <code>Any</code> objects are
|
||||
* equal if both their values and type codes are equal.
|
||||
*
|
||||
* @param a the <code>Any</code> object to test for equality
|
||||
* @return <code>true</code> if the <code>Any</code> objects are equal;
|
||||
* <code>false</code> otherwise
|
||||
* @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
|
||||
* comments for unimplemented features</a>
|
||||
*/
|
||||
abstract public boolean equal(Any a);
|
||||
|
||||
/**
|
||||
* Returns type information for the element contained in this
|
||||
* <code>Any</code> object.
|
||||
*
|
||||
* @return the <code>TypeCode</code> object containing type information
|
||||
* about the value contained in this <code>Any</code> object
|
||||
*/
|
||||
abstract public TypeCode type();
|
||||
|
||||
/**
|
||||
* Sets this <code>Any</code> object's <code>type</code> field
|
||||
* to the given <code>TypeCode</code> object and clears its value.
|
||||
* <P>
|
||||
* Note that using this method to set the type code wipes out the
|
||||
* value if there is one. The method
|
||||
* is provided primarily so that the type may be set properly for
|
||||
* IDL <code>out</code> parameters. Generally, setting the type
|
||||
* is done by the <code>insert_X</code> methods, which will set the type
|
||||
* to X if it is not already set to X.
|
||||
*
|
||||
* @param t the <code>TypeCode</code> object giving
|
||||
* information for the value in
|
||||
* this <code>Any</code> object
|
||||
*/
|
||||
abstract public void type(TypeCode t);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// marshalling/unmarshalling routines
|
||||
|
||||
/**
|
||||
* Reads off (unmarshals) the value of an <code>Any</code> object from
|
||||
* the given input stream using the given typecode.
|
||||
*
|
||||
* @param is the <code>org.omg.CORBA.portable.InputStream</code>
|
||||
* object from which to read
|
||||
* the value contained in this <code>Any</code> object
|
||||
*
|
||||
* @param t a <code>TypeCode</code> object containing type information
|
||||
* about the value to be read
|
||||
*
|
||||
* @exception MARSHAL when the given <code>TypeCode</code> object is
|
||||
* not consistent with the value that was contained
|
||||
* in the input stream
|
||||
*/
|
||||
abstract public void read_value(InputStream is, TypeCode t)
|
||||
throws MARSHAL;
|
||||
|
||||
/**
|
||||
* Writes out the value of this <code>Any</code> object
|
||||
* to the given output stream. If both <code>typecode</code>
|
||||
* and <code>value</code> need to be written, use
|
||||
* <code>create_output_stream()</code> to create an <code>OutputStream</code>,
|
||||
* then use <code>write_any</code> on the <code>OutputStream</code>.
|
||||
* <P>
|
||||
* If this method is called on an <code>Any</code> object that has not
|
||||
* had a value inserted into its <code>value</code> field, it will throw
|
||||
* the exception <code>java.lang.NullPointerException</code>.
|
||||
*
|
||||
* @param os the <code>org.omg.CORBA.portable.OutputStream</code>
|
||||
* object into which to marshal the value
|
||||
* of this <code>Any</code> object
|
||||
*
|
||||
*/
|
||||
abstract public void write_value(OutputStream os);
|
||||
|
||||
/**
|
||||
* Creates an output stream into which this <code>Any</code> object's
|
||||
* value can be marshalled.
|
||||
*
|
||||
* @return the newly-created <code>OutputStream</code>
|
||||
*/
|
||||
abstract public OutputStream create_output_stream();
|
||||
|
||||
/**
|
||||
* Creates an input stream from which this <code>Any</code> object's value
|
||||
* can be unmarshalled.
|
||||
*
|
||||
* @return the newly-created <code>InputStream</code>
|
||||
*/
|
||||
abstract public InputStream create_input_stream();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// basic insertion/extraction methods
|
||||
|
||||
/**
|
||||
* Extracts the <code>short</code> in this
|
||||
* <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @return the <code>short</code> stored in this <code>Any</code> object
|
||||
* @exception BAD_OPERATION if this <code>Any</code> object
|
||||
* contains something other than a <code>short</code> or the
|
||||
* <code>value</code> field has not yet been set
|
||||
*/
|
||||
abstract public short extract_short() throws BAD_OPERATION;
|
||||
|
||||
/**
|
||||
* Inserts the given <code>short</code>
|
||||
* into this <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @param s the <code>short</code> to insert into this
|
||||
* <code>Any</code> object
|
||||
*/
|
||||
abstract public void insert_short(short s);
|
||||
|
||||
/**
|
||||
* Extracts the <code>int</code> in this
|
||||
* <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @return the <code>int</code> stored in this <code>Any</code> object
|
||||
* @exception BAD_OPERATION if this <code>Any</code> object
|
||||
* contains something other than an <code>int</code> or the
|
||||
* <code>value</code> field has not yet been set
|
||||
*/
|
||||
abstract public int extract_long() throws BAD_OPERATION;
|
||||
|
||||
/**
|
||||
* Inserts the given <code>int</code>
|
||||
* into this <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @param l the <code>int</code> to insert into this
|
||||
* <code>Any</code> object
|
||||
*/
|
||||
abstract public void insert_long(int l);
|
||||
|
||||
|
||||
/**
|
||||
* Extracts the <code>long</code> in this
|
||||
* <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @return the <code>long</code> stored in this <code>Any</code> object
|
||||
* @exception BAD_OPERATION if this <code>Any</code> object
|
||||
* contains something other than a <code>long</code> or the
|
||||
* <code>value</code> field has not yet been set
|
||||
*/
|
||||
abstract public long extract_longlong() throws BAD_OPERATION;
|
||||
|
||||
/**
|
||||
* Inserts the given <code>long</code>
|
||||
* into this <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @param l the <code>long</code> to insert into this
|
||||
* <code>Any</code> object
|
||||
*/
|
||||
abstract public void insert_longlong(long l);
|
||||
|
||||
/**
|
||||
* Extracts the <code>short</code> in this
|
||||
* <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @return the <code>short</code> stored in this <code>Any</code> object
|
||||
* @exception BAD_OPERATION if this <code>Any</code> object
|
||||
* contains something other than a <code>short</code> or the
|
||||
* <code>value</code> field has not yet been set
|
||||
*/
|
||||
abstract public short extract_ushort() throws BAD_OPERATION;
|
||||
|
||||
/**
|
||||
* Inserts the given <code>short</code>
|
||||
* into this <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @param s the <code>short</code> to insert into this
|
||||
* <code>Any</code> object
|
||||
*/
|
||||
abstract public void insert_ushort(short s);
|
||||
|
||||
/**
|
||||
* Extracts the <code>int</code> in this
|
||||
* <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @return the <code>int</code> stored in this <code>Any</code> object
|
||||
* @exception BAD_OPERATION if this <code>Any</code> object
|
||||
* contains something other than an <code>int</code> or the
|
||||
* <code>value</code> field has not yet been set
|
||||
*/
|
||||
abstract public int extract_ulong() throws BAD_OPERATION;
|
||||
|
||||
/**
|
||||
* Inserts the given <code>int</code>
|
||||
* into this <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @param l the <code>int</code> to insert into this
|
||||
* <code>Any</code> object
|
||||
*/
|
||||
abstract public void insert_ulong(int l);
|
||||
|
||||
/**
|
||||
* Extracts the <code>long</code> in this
|
||||
* <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @return the <code>long</code> stored in this <code>Any</code> object
|
||||
* @exception BAD_OPERATION if this <code>Any</code> object
|
||||
* contains something other than a <code>long</code> or the
|
||||
* <code>value</code> field has not yet been set
|
||||
*/
|
||||
abstract public long extract_ulonglong() throws BAD_OPERATION;
|
||||
|
||||
/**
|
||||
* Inserts the given <code>long</code>
|
||||
* into this <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @param l the <code>long</code> to insert into this
|
||||
* <code>Any</code> object
|
||||
*/
|
||||
abstract public void insert_ulonglong(long l);
|
||||
|
||||
/**
|
||||
* Extracts the <code>float</code> in this
|
||||
* <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @return the <code>float</code> stored in this <code>Any</code> object
|
||||
* @exception BAD_OPERATION if this <code>Any</code> object
|
||||
* contains something other than a <code>float</code> or the
|
||||
* <code>value</code> field has not yet been set
|
||||
*/
|
||||
abstract public float extract_float() throws BAD_OPERATION;
|
||||
|
||||
/**
|
||||
* Inserts the given <code>float</code>
|
||||
* into this <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @param f the <code>float</code> to insert into this
|
||||
* <code>Any</code> object
|
||||
*/
|
||||
abstract public void insert_float(float f);
|
||||
|
||||
/**
|
||||
* Extracts the <code>double</code> in this
|
||||
* <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @return the <code>double</code> stored in this <code>Any</code> object
|
||||
* @exception BAD_OPERATION if this <code>Any</code> object
|
||||
* contains something other than a <code>double</code> or the
|
||||
* <code>value</code> field has not yet been set
|
||||
*/
|
||||
abstract public double extract_double() throws BAD_OPERATION;
|
||||
|
||||
/**
|
||||
* Inserts the given <code>double</code>
|
||||
* into this <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @param d the <code>double</code> to insert into this
|
||||
* <code>Any</code> object
|
||||
*/
|
||||
abstract public void insert_double(double d);
|
||||
|
||||
/**
|
||||
* Extracts the <code>boolean</code> in this
|
||||
* <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @return the <code>boolean</code> stored in this <code>Any</code> object
|
||||
* @exception BAD_OPERATION if this <code>Any</code> object
|
||||
* contains something other than a <code>boolean</code> or the
|
||||
* <code>value</code> field has not yet been set
|
||||
*/
|
||||
abstract public boolean extract_boolean() throws BAD_OPERATION;
|
||||
|
||||
/**
|
||||
* Inserts the given <code>boolean</code>
|
||||
* into this <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @param b the <code>boolean</code> to insert into this
|
||||
* <code>Any</code> object
|
||||
*/
|
||||
abstract public void insert_boolean(boolean b);
|
||||
|
||||
/**
|
||||
* Extracts the <code>char</code> in this
|
||||
* <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @return the <code>char</code> stored in this <code>Any</code> object
|
||||
* @exception BAD_OPERATION if this <code>Any</code> object
|
||||
* contains something other than a <code>char</code> or the
|
||||
* <code>value</code> field has not yet been set
|
||||
*/
|
||||
abstract public char extract_char() throws BAD_OPERATION;
|
||||
|
||||
/**
|
||||
* Inserts the given <code>char</code>
|
||||
* into this <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @param c the <code>char</code> to insert into this
|
||||
* <code>Any</code> object
|
||||
* @exception DATA_CONVERSION if there is a data conversion
|
||||
* error
|
||||
*/
|
||||
abstract public void insert_char(char c) throws DATA_CONVERSION;
|
||||
|
||||
/**
|
||||
* Extracts the <code>char</code> in this
|
||||
* <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @return the <code>char</code> stored in this <code>Any</code> object
|
||||
* @exception BAD_OPERATION if this <code>Any</code> object
|
||||
* contains something other than a <code>char</code> or the
|
||||
* <code>value</code> field has not yet been set
|
||||
*/
|
||||
abstract public char extract_wchar() throws BAD_OPERATION;
|
||||
|
||||
/**
|
||||
* Inserts the given <code>char</code>
|
||||
* into this <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @param c the <code>char</code> to insert into this
|
||||
* <code>Any</code> object
|
||||
*/
|
||||
abstract public void insert_wchar(char c);
|
||||
|
||||
/**
|
||||
* Extracts the <code>byte</code> in this
|
||||
* <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @return the <code>byte</code> stored in this <code>Any</code> object
|
||||
* @exception BAD_OPERATION if this <code>Any</code> object
|
||||
* contains something other than a <code>byte</code> or the
|
||||
* <code>value</code> field has not yet been set
|
||||
*/
|
||||
abstract public byte extract_octet() throws BAD_OPERATION;
|
||||
|
||||
/**
|
||||
* Inserts the given <code>byte</code>
|
||||
* into this <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @param b the <code>byte</code> to insert into this
|
||||
* <code>Any</code> object
|
||||
*/
|
||||
abstract public void insert_octet(byte b);
|
||||
|
||||
/**
|
||||
* Extracts the <code>Any</code> object in this
|
||||
* <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @return the <code>Any</code> object stored in this <code>Any</code> object
|
||||
* @exception BAD_OPERATION if this <code>Any</code> object
|
||||
* contains something other than an <code>Any</code> object or the
|
||||
* <code>value</code> field has not yet been set
|
||||
*/
|
||||
abstract public Any extract_any() throws BAD_OPERATION;
|
||||
|
||||
/**
|
||||
* Inserts the given <code>Any</code> object
|
||||
* into this <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @param a the <code>Any</code> object to insert into this
|
||||
* <code>Any</code> object
|
||||
*/
|
||||
abstract public void insert_any(Any a);
|
||||
|
||||
/**
|
||||
* Extracts the <code>org.omg.CORBA.Object</code> in this
|
||||
* <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @return the <code>org.omg.CORBA.Object</code> stored in
|
||||
* this <code>Any</code> object
|
||||
* @exception BAD_OPERATION if this <code>Any</code> object
|
||||
* contains something other than an
|
||||
* <code>org.omg.CORBA.Object</code> or the
|
||||
* <code>value</code> field has not yet been set
|
||||
*/
|
||||
abstract public org.omg.CORBA.Object extract_Object() throws BAD_OPERATION;
|
||||
|
||||
/**
|
||||
* Inserts the given <code>org.omg.CORBA.Object</code> object
|
||||
* into this <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @param o the <code>org.omg.CORBA.Object</code> object to insert into this
|
||||
* <code>Any</code> object
|
||||
*/
|
||||
abstract public void insert_Object(org.omg.CORBA.Object o);
|
||||
|
||||
/**
|
||||
* Extracts the <code>java.io.Serializable</code> object in this
|
||||
* <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @return the <code>java.io.Serializable</code> object stored in
|
||||
* this <code>Any</code> object
|
||||
* @exception BAD_OPERATION if this <code>Any</code> object
|
||||
* contains something other than a <code>java.io.Serializable</code>
|
||||
* object or the
|
||||
* <code>value</code> field has not yet been set
|
||||
*/
|
||||
abstract public java.io.Serializable extract_Value() throws BAD_OPERATION ;
|
||||
|
||||
/**
|
||||
* Inserts the given <code>java.io.Serializable</code> object
|
||||
* into this <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @param v the <code>java.io.Serializable</code> object to insert into this
|
||||
* <code>Any</code> object
|
||||
*/
|
||||
abstract public void insert_Value(java.io.Serializable v) ;
|
||||
|
||||
/**
|
||||
* Inserts the given <code>java.io.Serializable</code> object
|
||||
* into this <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @param v the <code>java.io.Serializable</code> object to insert into this
|
||||
* <code>Any</code> object
|
||||
* @param t the <code>TypeCode</code> object that is to be inserted into
|
||||
* this <code>Any</code> object's <code>type</code> field
|
||||
* and that describes the <code>java.io.Serializable</code>
|
||||
* object being inserted
|
||||
* @throws MARSHAL if the ORB has a problem marshalling or
|
||||
* unmarshalling parameters
|
||||
*/
|
||||
abstract public void insert_Value(java.io.Serializable v, TypeCode t)
|
||||
throws MARSHAL ;
|
||||
/**
|
||||
* Inserts the given <code>org.omg.CORBA.Object</code> object
|
||||
* into this <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @param o the <code>org.omg.CORBA.Object</code> instance to insert into this
|
||||
* <code>Any</code> object
|
||||
* @param t the <code>TypeCode</code> object that is to be inserted into
|
||||
* this <code>Any</code> object and that describes
|
||||
* the <code>Object</code> being inserted
|
||||
* @exception BAD_OPERATION if this method is invalid for this
|
||||
* <code>Any</code> object
|
||||
*
|
||||
*/
|
||||
abstract public void insert_Object(org.omg.CORBA.Object o, TypeCode t)
|
||||
throws BAD_PARAM;
|
||||
|
||||
/**
|
||||
* Extracts the <code>String</code> object in this
|
||||
* <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @return the <code>String</code> object stored in this <code>Any</code> object
|
||||
* @exception BAD_OPERATION if this <code>Any</code> object
|
||||
* contains something other than a <code>String</code> object or the
|
||||
* <code>value</code> field has not yet been set
|
||||
*/
|
||||
abstract public String extract_string() throws BAD_OPERATION;
|
||||
|
||||
/**
|
||||
* Inserts the given <code>String</code> object
|
||||
* into this <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @param s the <code>String</code> object to insert into this
|
||||
* <code>Any</code> object
|
||||
* @exception DATA_CONVERSION if there is a data conversion error
|
||||
* @exception MARSHAL if the ORB has a problem marshalling or
|
||||
* unmarshalling parameters
|
||||
*/
|
||||
abstract public void insert_string(String s) throws DATA_CONVERSION, MARSHAL;
|
||||
|
||||
/**
|
||||
* Extracts the <code>String</code> object in this
|
||||
* <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @return the <code>String</code> object stored in this <code>Any</code> object
|
||||
* @exception BAD_OPERATION if this <code>Any</code> object
|
||||
* contains something other than a <code>String</code> object or the
|
||||
* <code>value</code> field has not yet been set
|
||||
*/
|
||||
abstract public String extract_wstring() throws BAD_OPERATION;
|
||||
|
||||
/**
|
||||
* Inserts the given <code>String</code> object
|
||||
* into this <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @param s the <code>String</code> object to insert into this
|
||||
* <code>Any</code> object
|
||||
* @exception MARSHAL if the ORB has a problem marshalling or
|
||||
* unmarshalling parameters
|
||||
*/
|
||||
abstract public void insert_wstring(String s) throws MARSHAL;
|
||||
|
||||
/**
|
||||
* Extracts the <code>TypeCode</code> object in this
|
||||
* <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @return the <code>TypeCode</code> object stored in this <code>Any</code> object
|
||||
* @exception BAD_OPERATION if this <code>Any</code> object
|
||||
* contains something other than a <code>TypeCode</code> object or the
|
||||
* <code>value</code> field has not yet been set
|
||||
*/
|
||||
abstract public TypeCode extract_TypeCode() throws BAD_OPERATION;
|
||||
|
||||
/**
|
||||
* Inserts the given <code>TypeCode</code> object
|
||||
* into this <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @param t the <code>TypeCode</code> object to insert into this
|
||||
* <code>Any</code> object
|
||||
*/
|
||||
abstract public void insert_TypeCode(TypeCode t);
|
||||
|
||||
/**
|
||||
* Extracts the <code>Principal</code> object in this
|
||||
* <code>Any</code> object's <code>value</code> field.
|
||||
* Note that the class <code>Principal</code> has been deprecated.
|
||||
*
|
||||
* @return the <code>Principal</code> object stored in this <code>Any</code> object
|
||||
* @exception BAD_OPERATION if this <code>Any</code> object
|
||||
* contains something other than a
|
||||
* <code>Principal</code> object or the
|
||||
* <code>value</code> field has not yet been set
|
||||
* @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
|
||||
* comments for unimplemented features</a>
|
||||
* @deprecated Deprecated by CORBA 2.2.
|
||||
*/
|
||||
@Deprecated
|
||||
public Principal extract_Principal() throws BAD_OPERATION {
|
||||
throw new org.omg.CORBA.NO_IMPLEMENT() ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts the given <code>Principal</code> object
|
||||
* into this <code>Any</code> object's <code>value</code> field.
|
||||
* Note that the class <code>Principal</code> has been deprecated.
|
||||
*
|
||||
* @param p the <code>Principal</code> object to insert into this
|
||||
* <code>Any</code> object
|
||||
* @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
|
||||
* comments for unimplemented features</a>
|
||||
* @deprecated Deprecated by CORBA 2.2.
|
||||
*/
|
||||
@Deprecated
|
||||
public void insert_Principal(Principal p) {
|
||||
throw new org.omg.CORBA.NO_IMPLEMENT() ;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// insertion/extraction of streamables
|
||||
|
||||
/**
|
||||
* Extracts a <code>Streamable</code> from this <code>Any</code> object's
|
||||
* <code>value</code> field. This method allows the extraction of
|
||||
* non-primitive IDL types.
|
||||
*
|
||||
* @return the <code>Streamable</code> stored in the <code>Any</code> object.
|
||||
* @throws BAD_INV_ORDER if the caller has invoked operations in the wrong order
|
||||
* @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
|
||||
* comments for unimplemented features</a>
|
||||
*/
|
||||
public org.omg.CORBA.portable.Streamable extract_Streamable()
|
||||
throws org.omg.CORBA.BAD_INV_ORDER {
|
||||
throw new org.omg.CORBA.NO_IMPLEMENT() ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts the given <code>Streamable</code> object
|
||||
* into this <code>Any</code> object's <code>value</code> field.
|
||||
* This method allows the insertion of non-primitive IDL types.
|
||||
*
|
||||
* @param s the <code>Streamable</code> object to insert into this
|
||||
* <code>Any</code> object; may be a non-primitive
|
||||
* IDL type
|
||||
* @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
|
||||
* comments for unimplemented features</a>
|
||||
*/
|
||||
public void insert_Streamable(Streamable s) {
|
||||
throw new org.omg.CORBA.NO_IMPLEMENT() ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the <code>java.math.BigDecimal</code> object in this
|
||||
* <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @return the <code>java.math.BigDecimal</code> object
|
||||
* stored in this <code>Any</code> object
|
||||
* @exception BAD_OPERATION if this <code>Any</code> object
|
||||
* contains something other than a
|
||||
* <code>java.math.BigDecimal</code> object or the
|
||||
* <code>value</code> field has not yet been set
|
||||
* @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
|
||||
* comments for unimplemented features</a>
|
||||
*/
|
||||
public java.math.BigDecimal extract_fixed() {
|
||||
throw new org.omg.CORBA.NO_IMPLEMENT();
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws an <a href="package-summary.html#NO_IMPLEMENT">
|
||||
* <code>org.omg.CORBA.NO_IMPLEMENT</code></a> exception.
|
||||
* <P>
|
||||
* Inserts the given <code>java.math.BigDecimal</code> object
|
||||
* into this <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @param value the <code>java.math.BigDecimal</code> object
|
||||
* to insert into this <code>Any</code> object
|
||||
* @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
|
||||
* comments for unimplemented features</a>
|
||||
*/
|
||||
public void insert_fixed(java.math.BigDecimal value) {
|
||||
throw new org.omg.CORBA.NO_IMPLEMENT();
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws an <a href="package-summary.html#NO_IMPLEMENT">
|
||||
* <code>org.omg.CORBA.NO_IMPLEMENT</code></a> exception.
|
||||
* <P>
|
||||
* Inserts the given <code>java.math.BigDecimal</code> object
|
||||
* into this <code>Any</code> object's <code>value</code> field.
|
||||
*
|
||||
* @param value the <code>java.math.BigDecimal</code> object
|
||||
* to insert into this <code>Any</code> object
|
||||
* @param type the <code>TypeCode</code> object that is to be inserted into
|
||||
* this <code>Any</code> object's <code>type</code> field
|
||||
* and that describes the <code>java.math.BigDecimal</code>
|
||||
* object being inserted
|
||||
* @throws org.omg.CORBA.BAD_INV_ORDER if this method is invoked improperly
|
||||
* @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
|
||||
* comments for unimplemented features</a>
|
||||
*/
|
||||
public void insert_fixed(java.math.BigDecimal value, org.omg.CORBA.TypeCode type)
|
||||
throws org.omg.CORBA.BAD_INV_ORDER
|
||||
{
|
||||
throw new org.omg.CORBA.NO_IMPLEMENT();
|
||||
}
|
||||
}
|
||||
107
jdkSrc/jdk8/org/omg/CORBA/AnyHolder.java
Normal file
107
jdkSrc/jdk8/org/omg/CORBA/AnyHolder.java
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
import org.omg.CORBA.portable.Streamable;
|
||||
import org.omg.CORBA.portable.InputStream;
|
||||
import org.omg.CORBA.portable.OutputStream;
|
||||
|
||||
/**
|
||||
* The Holder for <tt>Any</tt>. For more information on
|
||||
* Holder files, see <a href="doc-files/generatedfiles.html#holder">
|
||||
* "Generated Files: Holder Files"</a>.<P>
|
||||
* A Holder class for <code>Any</code> objects
|
||||
* that is used to store "out" and "inout" parameters in IDL methods.
|
||||
* If an IDL method signature has an IDL <code>any</code> as an "out"
|
||||
* or "inout" parameter, the programmer must pass an instance of
|
||||
* <code>AnyHolder</code> as the corresponding
|
||||
* parameter in the method invocation; for "inout" parameters, the programmer
|
||||
* must also fill the "in" value to be sent to the server.
|
||||
* Before the method invocation returns, the ORB will fill in the
|
||||
* value corresponding to the "out" value returned from the server.
|
||||
* <P>
|
||||
* If <code>myAnyHolder</code> is an instance of <code>AnyHolder</code>,
|
||||
* the value stored in its <code>value</code> field can be accessed with
|
||||
* <code>myAnyHolder.value</code>.
|
||||
*
|
||||
* @since JDK1.2
|
||||
*/
|
||||
public final class AnyHolder implements Streamable {
|
||||
/**
|
||||
* The <code>Any</code> value held by this <code>AnyHolder</code> object.
|
||||
*/
|
||||
|
||||
public Any value;
|
||||
|
||||
/**
|
||||
* Constructs a new <code>AnyHolder</code> object with its
|
||||
* <code>value</code> field initialized to <code>null</code>.
|
||||
*/
|
||||
public AnyHolder() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <code>AnyHolder</code> object for the given
|
||||
* <code>Any</code> object.
|
||||
* @param initial the <code>Any</code> object with which to initialize
|
||||
* the <code>value</code> field of the new
|
||||
* <code>AnyHolder</code> object
|
||||
*/
|
||||
public AnyHolder(Any initial) {
|
||||
value = initial;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads from <code>input</code> and initalizes the value in the Holder
|
||||
* with the unmarshalled data.
|
||||
*
|
||||
* @param input the InputStream containing CDR formatted data from the wire.
|
||||
*/
|
||||
public void _read(InputStream input) {
|
||||
value = input.read_any();
|
||||
}
|
||||
|
||||
/**
|
||||
* Marshals to <code>output</code> the value in
|
||||
* this <code>AnyHolder</code> object.
|
||||
*
|
||||
* @param output the OutputStream which will contain the CDR formatted data.
|
||||
*/
|
||||
public void _write(OutputStream output) {
|
||||
output.write_any(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <code>TypeCode</code> object corresponding to the value
|
||||
* held in this <code>AnyHolder</code> object.
|
||||
*
|
||||
* @return the TypeCode of the value held in
|
||||
* this <code>AnyHolder</code> object
|
||||
*/
|
||||
public TypeCode _type() {
|
||||
return ORB.init().get_primitive_tc(TCKind.tk_any);
|
||||
}
|
||||
}
|
||||
101
jdkSrc/jdk8/org/omg/CORBA/AnySeqHelper.java
Normal file
101
jdkSrc/jdk8/org/omg/CORBA/AnySeqHelper.java
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.omg.CORBA;
|
||||
|
||||
|
||||
/**
|
||||
* The Helper for <tt>AnySeq</tt>. For more information on
|
||||
* Helper files, see <a href="doc-files/generatedfiles.html#helper">
|
||||
* "Generated Files: Helper Files"</a>.<P>
|
||||
* org/omg/CORBA/AnySeqHelper.java
|
||||
* Generated by the IDL-to-Java compiler (portable), version "3.0"
|
||||
* from streams.idl
|
||||
* 13 May 1999 22:41:36 o'clock GMT+00:00
|
||||
*
|
||||
* The class definition has been modified to conform to the following
|
||||
* OMG specifications :
|
||||
* <ul>
|
||||
* <li> ORB core as defined by CORBA 2.3.1
|
||||
* (<a href="http://cgi.omg.org/cgi-bin/doc?formal/99-10-07">formal/99-10-07</a>)
|
||||
* </li>
|
||||
*
|
||||
* <li> IDL/Java Language Mapping as defined in
|
||||
* <a href="http://cgi.omg.org/cgi-bin/doc?ptc/00-01-08">ptc/00-01-08</a>
|
||||
* </li>
|
||||
* </ul>
|
||||
*/
|
||||
|
||||
public abstract class AnySeqHelper
|
||||
{
|
||||
private static String _id = "IDL:omg.org/CORBA/AnySeq:1.0";
|
||||
|
||||
public static void insert (org.omg.CORBA.Any a, org.omg.CORBA.Any[] that)
|
||||
{
|
||||
org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
|
||||
a.type (type ());
|
||||
write (out, that);
|
||||
a.read_value (out.create_input_stream (), type ());
|
||||
}
|
||||
|
||||
public static org.omg.CORBA.Any[] extract (org.omg.CORBA.Any a)
|
||||
{
|
||||
return read (a.create_input_stream ());
|
||||
}
|
||||
|
||||
private static org.omg.CORBA.TypeCode __typeCode = null;
|
||||
synchronized public static org.omg.CORBA.TypeCode type ()
|
||||
{
|
||||
if (__typeCode == null)
|
||||
{
|
||||
__typeCode = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_any);
|
||||
__typeCode = org.omg.CORBA.ORB.init ().create_sequence_tc (0, __typeCode);
|
||||
__typeCode = org.omg.CORBA.ORB.init ().create_alias_tc (org.omg.CORBA.AnySeqHelper.id (), "AnySeq", __typeCode);
|
||||
}
|
||||
return __typeCode;
|
||||
}
|
||||
|
||||
public static String id ()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public static org.omg.CORBA.Any[] read (org.omg.CORBA.portable.InputStream istream)
|
||||
{
|
||||
org.omg.CORBA.Any value[] = null;
|
||||
int _len0 = istream.read_long ();
|
||||
value = new org.omg.CORBA.Any[_len0];
|
||||
for (int _o1 = 0;_o1 < value.length; ++_o1)
|
||||
value[_o1] = istream.read_any ();
|
||||
return value;
|
||||
}
|
||||
|
||||
public static void write (org.omg.CORBA.portable.OutputStream ostream, org.omg.CORBA.Any[] value)
|
||||
{
|
||||
ostream.write_long (value.length);
|
||||
for (int _i0 = 0;_i0 < value.length; ++_i0)
|
||||
ostream.write_any (value[_i0]);
|
||||
}
|
||||
|
||||
}
|
||||
66
jdkSrc/jdk8/org/omg/CORBA/AnySeqHolder.java
Normal file
66
jdkSrc/jdk8/org/omg/CORBA/AnySeqHolder.java
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.omg.CORBA;
|
||||
|
||||
|
||||
/**
|
||||
* The Holder for <tt>AnySeq</tt>. For more information on
|
||||
* Holder files, see <a href="doc-files/generatedfiles.html#holder">
|
||||
* "Generated Files: Holder Files"</a>.<P>
|
||||
* org/omg/CORBA/AnySeqHolder.java
|
||||
* Generated by the IDL-to-Java compiler (portable), version "3.0"
|
||||
* from streams.idl
|
||||
* 13 May 1999 22:41:36 o'clock GMT+00:00
|
||||
*/
|
||||
|
||||
public final class AnySeqHolder implements org.omg.CORBA.portable.Streamable
|
||||
{
|
||||
public org.omg.CORBA.Any value[] = null;
|
||||
|
||||
public AnySeqHolder ()
|
||||
{
|
||||
}
|
||||
|
||||
public AnySeqHolder (org.omg.CORBA.Any[] initialValue)
|
||||
{
|
||||
value = initialValue;
|
||||
}
|
||||
|
||||
public void _read (org.omg.CORBA.portable.InputStream i)
|
||||
{
|
||||
value = org.omg.CORBA.AnySeqHelper.read (i);
|
||||
}
|
||||
|
||||
public void _write (org.omg.CORBA.portable.OutputStream o)
|
||||
{
|
||||
org.omg.CORBA.AnySeqHelper.write (o, value);
|
||||
}
|
||||
|
||||
public org.omg.CORBA.TypeCode _type ()
|
||||
{
|
||||
return org.omg.CORBA.AnySeqHelper.type ();
|
||||
}
|
||||
|
||||
}
|
||||
86
jdkSrc/jdk8/org/omg/CORBA/BAD_CONTEXT.java
Normal file
86
jdkSrc/jdk8/org/omg/CORBA/BAD_CONTEXT.java
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
/**
|
||||
* Exception thrown when an operation is invoked by a client but the passed
|
||||
* context does not contain the context values required by the operation.<P>
|
||||
* It contains a minor code, which gives more detailed information about
|
||||
* what caused the exception, and a completion status. It may also contain
|
||||
* a string describing the exception.
|
||||
*
|
||||
* @see <A href="../../../../technotes/guides/idl/jidlExceptions.html">documentation on
|
||||
* Java IDL exceptions</A>
|
||||
* @since JDK1.2
|
||||
*/
|
||||
|
||||
public final class BAD_CONTEXT extends SystemException {
|
||||
|
||||
/**
|
||||
* Constructs a <code>BAD_CONTEXT</code> exception
|
||||
* with a default minor code
|
||||
* of 0 and a completion state of COMPLETED_NO.
|
||||
*/
|
||||
public BAD_CONTEXT() {
|
||||
this("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>BAD_CONTEXT</code> exception
|
||||
* with the specified detail message, a minor code
|
||||
* of 0 and a completion state of COMPLETED_NO.
|
||||
* @param s a <code>String</code> object containing a detail message
|
||||
*/
|
||||
public BAD_CONTEXT(String s) {
|
||||
this(s, 0, CompletionStatus.COMPLETED_NO);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>BAD_CONTEXT</code> exception
|
||||
* with the specified
|
||||
* minor code and completion status.
|
||||
* @param minor the minor code
|
||||
* @param completed an instance of <code>CompletionStatus</code> indicating
|
||||
* the completion status
|
||||
*/
|
||||
public BAD_CONTEXT(int minor, CompletionStatus completed) {
|
||||
this("", minor, completed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>BAD_CONTEXT</code> exception
|
||||
* with the specified detail
|
||||
* message, minor code, and completion status.
|
||||
* A detail message is a String that describes this particular exception.
|
||||
* @param s the String containing a detail message
|
||||
* @param minor the minor code
|
||||
* @param completed an instance of <code>CompletionStatus</code> indicating
|
||||
* the completion status
|
||||
*/
|
||||
public BAD_CONTEXT(String s, int minor, CompletionStatus completed) {
|
||||
super(s, minor, completed);
|
||||
}
|
||||
}
|
||||
85
jdkSrc/jdk8/org/omg/CORBA/BAD_INV_ORDER.java
Normal file
85
jdkSrc/jdk8/org/omg/CORBA/BAD_INV_ORDER.java
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
/**
|
||||
* This exception indicates that the caller has invoked operations in
|
||||
* the wrong order. For example, it can be raised by an ORB if an
|
||||
* application makes an ORB-related call without having correctly
|
||||
* initialized the ORB first.<P>
|
||||
* It contains a minor code, which gives more detailed information about
|
||||
* what caused the exception, and a completion status. It may also contain
|
||||
* a string describing the exception.
|
||||
*
|
||||
* @see <A href="../../../../technotes/guides/idl/jidlExceptions.html">documentation on
|
||||
* Java IDL exceptions</A>
|
||||
* @since JDK1.2
|
||||
*/
|
||||
|
||||
public final class BAD_INV_ORDER extends SystemException {
|
||||
|
||||
/**
|
||||
* Constructs a <code>BAD_INV_ORDER</code> exception with a default
|
||||
* minor code of 0 and a completion state of COMPLETED_NO.
|
||||
*/
|
||||
public BAD_INV_ORDER() {
|
||||
this("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>BAD_INV_ORDER</code> exception with the specified detail
|
||||
* message, a minor code of 0, and a completion state of COMPLETED_NO.
|
||||
*
|
||||
* @param s the String containing a detail message
|
||||
*/
|
||||
public BAD_INV_ORDER(String s) {
|
||||
this(s, 0, CompletionStatus.COMPLETED_NO);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>BAD_INV_ORDER</code> exceptionBAD_INV_ORDER with the specified
|
||||
* minor code and completion status.
|
||||
* @param minor the minor code
|
||||
* @param completed an instance of <code>CompletionStatus</code> indicating
|
||||
* the completion status
|
||||
*/
|
||||
public BAD_INV_ORDER(int minor, CompletionStatus completed) {
|
||||
this("", minor, completed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>BAD_INV_ORDER</code> exception with the specified detail
|
||||
* message, minor code, and completion status.
|
||||
* A detail message is a String that describes this particular exception.
|
||||
* @param s the String containing a detail message
|
||||
* @param minor the minor code
|
||||
* @param completed the completion status
|
||||
*/
|
||||
public BAD_INV_ORDER(String s, int minor, CompletionStatus completed) {
|
||||
super(s, minor, completed);
|
||||
}
|
||||
|
||||
}
|
||||
82
jdkSrc/jdk8/org/omg/CORBA/BAD_OPERATION.java
Normal file
82
jdkSrc/jdk8/org/omg/CORBA/BAD_OPERATION.java
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
/**
|
||||
* Exception thrown when an object reference denotes an existing object,
|
||||
* but that the object does not support the operation that was invoked.<P>
|
||||
* It contains a minor code, which gives more detailed information about
|
||||
* what caused the exception, and a completion status. It may also contain
|
||||
* a string describing the exception.
|
||||
*
|
||||
* @see <A href="../../../../technotes/guides/idl/jidlExceptions.html">documentation on
|
||||
* Java IDL exceptions</A>
|
||||
* @since JDK1.2
|
||||
*/
|
||||
|
||||
public final class BAD_OPERATION extends SystemException {
|
||||
|
||||
/**
|
||||
* Constructs a <code>BAD_OPERATION</code> exception with a default
|
||||
* minor code of 0 and a completion state of COMPLETED_NO.
|
||||
*/
|
||||
public BAD_OPERATION() {
|
||||
this("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>BAD_OPERATION</code> exception with the specified detail
|
||||
* message, a minor code of 0, and a completion state of COMPLETED_NO.
|
||||
* @param s the String containing a detail message
|
||||
*/
|
||||
public BAD_OPERATION(String s) {
|
||||
this(s, 0, CompletionStatus.COMPLETED_NO);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>BAD_OPERATION</code> exception with the specified
|
||||
* minor code and completion status.
|
||||
* @param minor the minor code
|
||||
* @param completed an instance of <code>CompletionStatus</code> indicating
|
||||
* the completion status
|
||||
*/
|
||||
public BAD_OPERATION(int minor, CompletionStatus completed) {
|
||||
this("", minor, completed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>BAD_OPERATION</code> exception with the specified detail
|
||||
* message, minor code, and completion status.
|
||||
* A detail message is a String that describes this particular exception.
|
||||
* @param s the String containing a detail message
|
||||
* @param minor the minor code
|
||||
* @param completed an instance of <code>CompletionStatus</code> indicating
|
||||
* the completion status
|
||||
*/
|
||||
public BAD_OPERATION(String s, int minor, CompletionStatus completed) {
|
||||
super(s, minor, completed);
|
||||
}
|
||||
}
|
||||
91
jdkSrc/jdk8/org/omg/CORBA/BAD_PARAM.java
Normal file
91
jdkSrc/jdk8/org/omg/CORBA/BAD_PARAM.java
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
/**
|
||||
* Exception thrown
|
||||
* when a parameter passed to a call is out of range or
|
||||
* otherwise considered illegal. An ORB may raise this exception
|
||||
* if null values or null pointers are passed to an operation (for
|
||||
* language mappings where the concept of a null pointers or null
|
||||
* values applies). BAD_PARAM can also be raised as a result of a
|
||||
* client generating requests with incorrect parameters using the DII. <P>
|
||||
* It contains a minor code, which gives more detailed information about
|
||||
* what caused the exception, and a completion status. It may also contain
|
||||
* a string describing the exception.
|
||||
*
|
||||
* @see <A href="../../../../technotes/guides/idl/jidlExceptions.html">documentation on
|
||||
* Java IDL exceptions</A>
|
||||
* @see <A href="../../../../technotes/guides/idl/jidlExceptions.html#minorcodemeanings">meaning of
|
||||
* minor codes</A>
|
||||
* @since JDK1.2
|
||||
*/
|
||||
|
||||
public final class BAD_PARAM extends SystemException {
|
||||
|
||||
/**
|
||||
* Constructs a <code>BAD_PARAM</code> exception with a default
|
||||
* minor code of 0 and a completion state of COMPLETED_NO.
|
||||
*/
|
||||
public BAD_PARAM() {
|
||||
this("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>BAD_PARAM</code> exception with the specified detail
|
||||
* message, a minor code of 0, and a completion state of COMPLETED_NO.
|
||||
*
|
||||
* @param s the String containing a detail message describing this
|
||||
* exception
|
||||
*/
|
||||
public BAD_PARAM(String s) {
|
||||
this(s, 0, CompletionStatus.COMPLETED_NO);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>BAD_PARAM</code> exception with the specified
|
||||
* minor code and completion status.
|
||||
* @param minor the minor code
|
||||
* @param completed the completion status
|
||||
*/
|
||||
public BAD_PARAM(int minor, CompletionStatus completed) {
|
||||
this("", minor, completed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>BAD_PARAM</code> exception with the specified detail
|
||||
* message, minor code, and completion status.
|
||||
* A detail message is a <code>String</code> that describes
|
||||
* this particular exception.
|
||||
*
|
||||
* @param s the <code>String</code> containing a detail message
|
||||
* @param minor the minor code
|
||||
* @param completed the completion status
|
||||
*/
|
||||
public BAD_PARAM(String s, int minor, CompletionStatus completed) {
|
||||
super(s, minor, completed);
|
||||
}
|
||||
}
|
||||
39
jdkSrc/jdk8/org/omg/CORBA/BAD_POLICY.java
Normal file
39
jdkSrc/jdk8/org/omg/CORBA/BAD_POLICY.java
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
/**
|
||||
* A <tt>PolicyErrorCode</tt> which would be filled in
|
||||
* the <tt>PolicyError</tt> exception.
|
||||
*
|
||||
* @author rip-dev
|
||||
*/
|
||||
|
||||
public interface BAD_POLICY {
|
||||
/**
|
||||
* The Error code in PolicyError exception.
|
||||
*/
|
||||
final short value = (short) (0L);
|
||||
};
|
||||
39
jdkSrc/jdk8/org/omg/CORBA/BAD_POLICY_TYPE.java
Normal file
39
jdkSrc/jdk8/org/omg/CORBA/BAD_POLICY_TYPE.java
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
/**
|
||||
* A <tt>PolicyErrorCode</tt> which would be filled in
|
||||
* the <tt>PolicyError</tt> exception.
|
||||
*
|
||||
* @author rip-dev
|
||||
*/
|
||||
public interface BAD_POLICY_TYPE {
|
||||
/**
|
||||
* The Error code in PolicyError exception.
|
||||
*/
|
||||
final short value = (short) (2L);
|
||||
};
|
||||
41
jdkSrc/jdk8/org/omg/CORBA/BAD_POLICY_VALUE.java
Normal file
41
jdkSrc/jdk8/org/omg/CORBA/BAD_POLICY_VALUE.java
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
/**
|
||||
* Contains the value used to indicate a policy value that is
|
||||
* incorrect for a valid policy type in a call to the
|
||||
* <code>create_policy</code> method defined in the ORB class.
|
||||
*
|
||||
*/
|
||||
public interface BAD_POLICY_VALUE {
|
||||
/**
|
||||
* The value used to represent a bad policy value error
|
||||
* in a <code>PolicyError</code> exception.
|
||||
* @see org.omg.CORBA.PolicyError
|
||||
*/
|
||||
final short value = (short) (3L);
|
||||
};
|
||||
83
jdkSrc/jdk8/org/omg/CORBA/BAD_QOS.java
Normal file
83
jdkSrc/jdk8/org/omg/CORBA/BAD_QOS.java
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
/**
|
||||
* The <code>BAD_QOS</code> exception is raised whenever an object cannot
|
||||
* support the quality of service required by an invocation parameter that
|
||||
* has a quality of service semantics associated with it.
|
||||
*
|
||||
* @see <A href="../../../../technotes/guides/idl/jidlExceptions.html">documentation on
|
||||
* Java IDL exceptions</A>
|
||||
* @since J2SE 1.5
|
||||
*/
|
||||
|
||||
public final class BAD_QOS extends SystemException {
|
||||
|
||||
/**
|
||||
* Constructs an <code>BAD_QOS</code> exception with
|
||||
* minor code set to 0 and CompletionStatus set to COMPLETED_NO.
|
||||
*/
|
||||
public BAD_QOS() {
|
||||
this("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an <code>BAD_QOS</code> exception with the
|
||||
* specified message.
|
||||
*
|
||||
* @param detailMessage string containing a detailed message.
|
||||
*/
|
||||
public BAD_QOS(String detailMessage) {
|
||||
this(detailMessage, 0, CompletionStatus.COMPLETED_NO);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an <code>BAD_QOS</code> exception with the
|
||||
* specified minor code and completion status.
|
||||
*
|
||||
* @param minorCode minor code.
|
||||
* @param completionStatus completion status.
|
||||
*/
|
||||
public BAD_QOS(int minorCode,
|
||||
CompletionStatus completionStatus) {
|
||||
this("", minorCode, completionStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an <code>BAD_QOS</code> exception with the
|
||||
* specified message, minor code, and completion status.
|
||||
*
|
||||
* @param detailMessage string containing a detailed message.
|
||||
* @param minorCode minor code.
|
||||
* @param completionStatus completion status.
|
||||
*/
|
||||
public BAD_QOS(String detailMessage,
|
||||
int minorCode,
|
||||
CompletionStatus completionStatus) {
|
||||
super(detailMessage, minorCode, completionStatus);
|
||||
}
|
||||
}
|
||||
83
jdkSrc/jdk8/org/omg/CORBA/BAD_TYPECODE.java
Normal file
83
jdkSrc/jdk8/org/omg/CORBA/BAD_TYPECODE.java
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
/**
|
||||
* Exception thrown when the ORB has encountered a malformed type code
|
||||
* (for example, a type code with an invalid <tt>TCKind</tt> value).<P>
|
||||
* It contains a minor code, which gives more detailed information about
|
||||
* what caused the exception, and a completion status. It may also contain
|
||||
* a string describing the exception.
|
||||
*
|
||||
* @see <A href="../../../../technotes/guides/idl/jidlExceptions.html">documentation on
|
||||
* Java IDL exceptions</A>
|
||||
* @since JDK1.2
|
||||
*/
|
||||
|
||||
public final class BAD_TYPECODE extends SystemException {
|
||||
|
||||
/**
|
||||
* Constructs a <code>BAD_TYPECODE</code> exception with a default
|
||||
* minor code of 0 and a completion state of COMPLETED_NO.
|
||||
*/
|
||||
public BAD_TYPECODE() {
|
||||
this("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>BAD_TYPECODE</code> exception with the specified detail,
|
||||
* a minor code of 0, and a completion state of COMPLETED_NO.
|
||||
*
|
||||
* @param s the String containing a detail message
|
||||
*/
|
||||
public BAD_TYPECODE(String s) {
|
||||
this(s, 0, CompletionStatus.COMPLETED_NO);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>BAD_TYPECODE</code> exception with the specified
|
||||
* minor code and completion status.
|
||||
* @param minor the minor code
|
||||
* @param completed an instance of <code>CompletionStatus</code> indicating
|
||||
* the completion status
|
||||
*/
|
||||
public BAD_TYPECODE(int minor, CompletionStatus completed) {
|
||||
this("", minor, completed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>BAD_TYPECODE</code> exception with the specified detail
|
||||
* message, minor code, and completion status.
|
||||
* A detail message is a String that describes this particular exception.
|
||||
* @param s the String containing a detail message
|
||||
* @param minor the minor code
|
||||
* @param completed an instance of <code>CompletionStatus</code> indicating
|
||||
* the completion status
|
||||
*/
|
||||
public BAD_TYPECODE(String s, int minor, CompletionStatus completed) {
|
||||
super(s, minor, completed);
|
||||
}
|
||||
}
|
||||
109
jdkSrc/jdk8/org/omg/CORBA/BooleanHolder.java
Normal file
109
jdkSrc/jdk8/org/omg/CORBA/BooleanHolder.java
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.omg.CORBA;
|
||||
|
||||
import org.omg.CORBA.portable.Streamable;
|
||||
import org.omg.CORBA.portable.InputStream;
|
||||
import org.omg.CORBA.portable.OutputStream;
|
||||
|
||||
|
||||
/**
|
||||
* The Holder for <tt>Boolean</tt>. For more information on
|
||||
* Holder files, see <a href="doc-files/generatedfiles.html#holder">
|
||||
* "Generated Files: Holder Files"</a>.<P>
|
||||
* A Holder class for a <code>boolean</code>
|
||||
* that is used to store "out" and "inout" parameters in IDL methods.
|
||||
* If an IDL method signature has an IDL <code>boolean</code> as an "out"
|
||||
* or "inout" parameter, the programmer must pass an instance of
|
||||
* <code>BooleanHolder</code> as the corresponding
|
||||
* parameter in the method invocation; for "inout" parameters, the programmer
|
||||
* must also fill the "in" value to be sent to the server.
|
||||
* Before the method invocation returns, the ORB will fill in the
|
||||
* value corresponding to the "out" value returned from the server.
|
||||
* <P>
|
||||
* If <code>myBooleanHolder</code> is an instance of <code>BooleanHolder</code>,
|
||||
* the value stored in its <code>value</code> field can be accessed with
|
||||
* <code>myBooleanHolder.value</code>.
|
||||
*
|
||||
* @since JDK1.2
|
||||
*/
|
||||
public final class BooleanHolder implements Streamable {
|
||||
|
||||
/**
|
||||
* The <code>boolean</code> value held by this <code>BooleanHolder</code>
|
||||
* object.
|
||||
*/
|
||||
public boolean value;
|
||||
|
||||
/**
|
||||
* Constructs a new <code>BooleanHolder</code> object with its
|
||||
* <code>value</code> field initialized to <code>false</code>.
|
||||
*/
|
||||
public BooleanHolder() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <code>BooleanHolder</code> object with its
|
||||
* <code>value</code> field initialized with the given <code>boolean</code>.
|
||||
* @param initial the <code>boolean</code> with which to initialize
|
||||
* the <code>value</code> field of the newly-created
|
||||
* <code>BooleanHolder</code> object
|
||||
*/
|
||||
public BooleanHolder(boolean initial) {
|
||||
value = initial;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads unmarshalled data from <code>input</code> and assigns it to this
|
||||
* <code>BooleanHolder</code> object's <code>value</code> field.
|
||||
*
|
||||
* @param input the <code>InputStream</code> object containing
|
||||
* CDR formatted data from the wire
|
||||
*/
|
||||
public void _read(InputStream input) {
|
||||
value = input.read_boolean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Marshals the value in this <code>BooleanHolder</code> object's
|
||||
* <code>value</code> field to the output stream <code>output</code>.
|
||||
*
|
||||
* @param output the OutputStream which will contain the CDR formatted data
|
||||
*/
|
||||
public void _write(OutputStream output) {
|
||||
output.write_boolean(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the <code>TypeCode</code> object that corresponds to the
|
||||
* value held in this <code>BooleanHolder</code> object.
|
||||
*
|
||||
* @return the <code>TypeCode</code> for the value held
|
||||
* in this <code>BooleanHolder</code> object
|
||||
*/
|
||||
public TypeCode _type() {
|
||||
return ORB.init().get_primitive_tc(TCKind.tk_boolean);
|
||||
}
|
||||
}
|
||||
99
jdkSrc/jdk8/org/omg/CORBA/BooleanSeqHelper.java
Normal file
99
jdkSrc/jdk8/org/omg/CORBA/BooleanSeqHelper.java
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.omg.CORBA;
|
||||
|
||||
|
||||
/**
|
||||
* The Helper for <tt>BooleanSeq</tt>. For more information on
|
||||
* Helper files, see <a href="doc-files/generatedfiles.html#helper">
|
||||
* "Generated Files: Helper Files"</a>.<P>
|
||||
* org/omg/CORBA/BooleanSeqHelper.java
|
||||
* Generated by the IDL-to-Java compiler (portable), version "3.0"
|
||||
* from streams.idl
|
||||
* 13 May 1999 22:41:36 o'clock GMT+00:00
|
||||
*
|
||||
* The class definition has been modified to conform to the following
|
||||
* OMG specifications :
|
||||
* <ul>
|
||||
* <li> ORB core as defined by CORBA 2.3.1
|
||||
* (<a href="http://cgi.omg.org/cgi-bin/doc?formal/99-10-07">formal/99-10-07</a>)
|
||||
* </li>
|
||||
*
|
||||
* <li> IDL/Java Language Mapping as defined in
|
||||
* <a href="http://cgi.omg.org/cgi-bin/doc?ptc/00-01-08">ptc/00-01-08</a>
|
||||
* </li>
|
||||
* </ul>
|
||||
*/
|
||||
|
||||
public abstract class BooleanSeqHelper
|
||||
{
|
||||
private static String _id = "IDL:omg.org/CORBA/BooleanSeq:1.0";
|
||||
|
||||
public static void insert (org.omg.CORBA.Any a, boolean[] that)
|
||||
{
|
||||
org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
|
||||
a.type (type ());
|
||||
write (out, that);
|
||||
a.read_value (out.create_input_stream (), type ());
|
||||
}
|
||||
|
||||
public static boolean[] extract (org.omg.CORBA.Any a)
|
||||
{
|
||||
return read (a.create_input_stream ());
|
||||
}
|
||||
|
||||
private static org.omg.CORBA.TypeCode __typeCode = null;
|
||||
synchronized public static org.omg.CORBA.TypeCode type ()
|
||||
{
|
||||
if (__typeCode == null)
|
||||
{
|
||||
__typeCode = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_boolean);
|
||||
__typeCode = org.omg.CORBA.ORB.init ().create_sequence_tc (0, __typeCode);
|
||||
__typeCode = org.omg.CORBA.ORB.init ().create_alias_tc (org.omg.CORBA.BooleanSeqHelper.id (), "BooleanSeq", __typeCode);
|
||||
}
|
||||
return __typeCode;
|
||||
}
|
||||
|
||||
public static String id ()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public static boolean[] read (org.omg.CORBA.portable.InputStream istream)
|
||||
{
|
||||
boolean value[] = null;
|
||||
int _len0 = istream.read_long ();
|
||||
value = new boolean[_len0];
|
||||
istream.read_boolean_array (value, 0, _len0);
|
||||
return value;
|
||||
}
|
||||
|
||||
public static void write (org.omg.CORBA.portable.OutputStream ostream, boolean[] value)
|
||||
{
|
||||
ostream.write_long (value.length);
|
||||
ostream.write_boolean_array (value, 0, value.length);
|
||||
}
|
||||
|
||||
}
|
||||
66
jdkSrc/jdk8/org/omg/CORBA/BooleanSeqHolder.java
Normal file
66
jdkSrc/jdk8/org/omg/CORBA/BooleanSeqHolder.java
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.omg.CORBA;
|
||||
|
||||
|
||||
/**
|
||||
* The Holder for <tt>BooleanSeq</tt>. For more information on
|
||||
* Holder files, see <a href="doc-files/generatedfiles.html#holder">
|
||||
* "Generated Files: Holder Files"</a>.<P>
|
||||
* org/omg/CORBA/BooleanSeqHolder.java
|
||||
* Generated by the IDL-to-Java compiler (portable), version "3.0"
|
||||
* from streams.idl
|
||||
* 13 May 1999 22:41:36 o'clock GMT+00:00
|
||||
*/
|
||||
|
||||
public final class BooleanSeqHolder implements org.omg.CORBA.portable.Streamable
|
||||
{
|
||||
public boolean value[] = null;
|
||||
|
||||
public BooleanSeqHolder ()
|
||||
{
|
||||
}
|
||||
|
||||
public BooleanSeqHolder (boolean[] initialValue)
|
||||
{
|
||||
value = initialValue;
|
||||
}
|
||||
|
||||
public void _read (org.omg.CORBA.portable.InputStream i)
|
||||
{
|
||||
value = org.omg.CORBA.BooleanSeqHelper.read (i);
|
||||
}
|
||||
|
||||
public void _write (org.omg.CORBA.portable.OutputStream o)
|
||||
{
|
||||
org.omg.CORBA.BooleanSeqHelper.write (o, value);
|
||||
}
|
||||
|
||||
public org.omg.CORBA.TypeCode _type ()
|
||||
{
|
||||
return org.omg.CORBA.BooleanSeqHelper.type ();
|
||||
}
|
||||
|
||||
}
|
||||
54
jdkSrc/jdk8/org/omg/CORBA/Bounds.java
Normal file
54
jdkSrc/jdk8/org/omg/CORBA/Bounds.java
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
/**
|
||||
* A user exception thrown when a parameter is not within
|
||||
* the legal bounds for the object that a method is trying
|
||||
* to access.
|
||||
*
|
||||
* @see <A href="../../../../technotes/guides/idl/jidlExceptions.html">documentation on
|
||||
* Java IDL exceptions</A>
|
||||
*/
|
||||
|
||||
public final class Bounds extends org.omg.CORBA.UserException {
|
||||
|
||||
/**
|
||||
* Constructs an <code>Bounds</code> with no specified detail message.
|
||||
*/
|
||||
public Bounds() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an <code>Bounds</code> with the specified detail message.
|
||||
*
|
||||
* @param reason the detail message.
|
||||
*/
|
||||
public Bounds(String reason) {
|
||||
super(reason);
|
||||
}
|
||||
}
|
||||
110
jdkSrc/jdk8/org/omg/CORBA/ByteHolder.java
Normal file
110
jdkSrc/jdk8/org/omg/CORBA/ByteHolder.java
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
import org.omg.CORBA.portable.Streamable;
|
||||
import org.omg.CORBA.portable.InputStream;
|
||||
import org.omg.CORBA.portable.OutputStream;
|
||||
|
||||
/**
|
||||
* The Holder for <tt>Byte</tt>. For more information on
|
||||
* Holder files, see <a href="doc-files/generatedfiles.html#holder">
|
||||
* "Generated Files: Holder Files"</a>.<P>
|
||||
* A Holder class for a <code>byte</code>
|
||||
* that is used to store "out" and "inout" parameters in IDL methods.
|
||||
* If an IDL method signature has an IDL <code>octet</code> as an "out"
|
||||
* or "inout" parameter, the programmer must pass an instance of
|
||||
* <code>ByteHolder</code> as the corresponding
|
||||
* parameter in the method invocation; for "inout" parameters, the programmer
|
||||
* must also fill the "in" value to be sent to the server.
|
||||
* Before the method invocation returns, the ORB will fill in the
|
||||
* value corresponding to the "out" value returned from the server.
|
||||
* <P>
|
||||
* If <code>myByteHolder</code> is an instance of <code>ByteHolder</code>,
|
||||
* the value stored in its <code>value</code> field can be accessed with
|
||||
* <code>myByteHolder.value</code>.
|
||||
*
|
||||
* @since JDK1.2
|
||||
*/
|
||||
public final class ByteHolder implements Streamable {
|
||||
/**
|
||||
* The <code>byte</code> value held by this <code>ByteHolder</code>
|
||||
* object.
|
||||
*/
|
||||
|
||||
public byte value;
|
||||
|
||||
/**
|
||||
* Constructs a new <code>ByteHolder</code> object with its
|
||||
* <code>value</code> field initialized to 0.
|
||||
*/
|
||||
public ByteHolder() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <code>ByteHolder</code> object for the given
|
||||
* <code>byte</code>.
|
||||
* @param initial the <code>byte</code> with which to initialize
|
||||
* the <code>value</code> field of the new
|
||||
* <code>ByteHolder</code> object
|
||||
*/
|
||||
public ByteHolder(byte initial) {
|
||||
value = initial;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads from <code>input</code> and initalizes the value in
|
||||
* this <code>ByteHolder</code> object
|
||||
* with the unmarshalled data.
|
||||
*
|
||||
* @param input the InputStream containing CDR formatted data from the wire.
|
||||
*/
|
||||
public void _read(InputStream input) {
|
||||
value = input.read_octet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Marshals to <code>output</code> the value in
|
||||
* this <code>ByteHolder</code> object.
|
||||
*
|
||||
* @param output the OutputStream which will contain the CDR formatted data.
|
||||
*/
|
||||
public void _write(OutputStream output) {
|
||||
output.write_octet(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TypeCode corresponding to the value held in
|
||||
* this <code>ByteHolder</code> object.
|
||||
*
|
||||
* @return the TypeCode of the value held in
|
||||
* this <code>ByteHolder</code> object
|
||||
*/
|
||||
public org.omg.CORBA.TypeCode _type() {
|
||||
return ORB.init().get_primitive_tc(TCKind.tk_octet);
|
||||
}
|
||||
}
|
||||
82
jdkSrc/jdk8/org/omg/CORBA/CODESET_INCOMPATIBLE.java
Normal file
82
jdkSrc/jdk8/org/omg/CORBA/CODESET_INCOMPATIBLE.java
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
/**
|
||||
* This exception is raised whenever meaningful communication is not possible
|
||||
* between client and server native code sets.
|
||||
*
|
||||
* @see <A href="../../../../technotes/guides/idl/jidlExceptions.html">documentation on
|
||||
* Java IDL exceptions</A>
|
||||
* @since J2SE 1.5
|
||||
*/
|
||||
|
||||
public final class CODESET_INCOMPATIBLE extends SystemException {
|
||||
|
||||
/**
|
||||
* Constructs an <code>CODESET_INCOMPATIBLE</code> exception with
|
||||
* minor code set to 0 and CompletionStatus set to COMPLETED_NO.
|
||||
*/
|
||||
public CODESET_INCOMPATIBLE() {
|
||||
this("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an <code>CODESET_INCOMPATIBLE</code> exception with the
|
||||
* specified message.
|
||||
*
|
||||
* @param detailMessage string containing a detailed message.
|
||||
*/
|
||||
public CODESET_INCOMPATIBLE(String detailMessage) {
|
||||
this(detailMessage, 0, CompletionStatus.COMPLETED_NO);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an <code>CODESET_INCOMPATIBLE</code> exception with the
|
||||
* specified minor code and completion status.
|
||||
*
|
||||
* @param minorCode minor code.
|
||||
* @param completionStatus completion status.
|
||||
*/
|
||||
public CODESET_INCOMPATIBLE(int minorCode,
|
||||
CompletionStatus completionStatus) {
|
||||
this("", minorCode, completionStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an <code>CODESET_INCOMPATIBLE</code> exception with the
|
||||
* specified message, minor code, and completion status.
|
||||
*
|
||||
* @param detailMessage string containing a detailed message.
|
||||
* @param minorCode minor code.
|
||||
* @param completionStatus completion status.
|
||||
*/
|
||||
public CODESET_INCOMPATIBLE(String detailMessage,
|
||||
int minorCode,
|
||||
CompletionStatus completionStatus) {
|
||||
super(detailMessage, minorCode, completionStatus);
|
||||
}
|
||||
}
|
||||
90
jdkSrc/jdk8/org/omg/CORBA/COMM_FAILURE.java
Normal file
90
jdkSrc/jdk8/org/omg/CORBA/COMM_FAILURE.java
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
/**
|
||||
* This exception is raised if communication is lost while an operation
|
||||
* is in progress, after the request was sent by the client, but before
|
||||
* the reply from the server has been returned to the client.<P>
|
||||
* It contains a minor code, which gives more detailed information about
|
||||
* what caused the exception, and a completion status. It may also contain
|
||||
* a string describing the exception.
|
||||
* <P>
|
||||
* See the section <A href="../../../../technotes/guides/idl/jidlExceptions.html#minorcodemeanings">meaning
|
||||
* of minor codes</A> to see the minor codes for this exception.
|
||||
*
|
||||
* @see <A href="../../../../technotes/guides/idl/jidlExceptions.html#minorcodemeanings">meaning of
|
||||
* minor codes</A>
|
||||
* @since JDK1.2
|
||||
*/
|
||||
|
||||
public final class COMM_FAILURE extends SystemException {
|
||||
|
||||
/**
|
||||
* Constructs a <code>COMM_FAILURE</code> exception with
|
||||
* a default minor code of 0 and a completion state of COMPLETED_NO.
|
||||
*/
|
||||
public COMM_FAILURE() {
|
||||
this("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>COMM_FAILURE</code> exception with the specified detail
|
||||
* message, a minor code of 0, and a completion state of COMPLETED_NO.
|
||||
*
|
||||
* @param s the <code>String</code> containing a detail message describing
|
||||
* this exception
|
||||
*/
|
||||
public COMM_FAILURE(String s) {
|
||||
this(s, 0, CompletionStatus.COMPLETED_NO);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>COMM_FAILURE</code> exception with the specified
|
||||
* minor code and completion status.
|
||||
* @param minor the minor code
|
||||
* @param completed the completion status, which must be one of
|
||||
* <code>COMPLETED_YES</code>, <code>COMPLETED_NO</code>, or
|
||||
* <code>COMPLETED_MAYBE</code>.
|
||||
*/
|
||||
public COMM_FAILURE(int minor, CompletionStatus completed) {
|
||||
this("", minor, completed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>COMM_FAILURE</code> exception with the specified detail
|
||||
* message, minor code, and completion status.
|
||||
* A detail message is a String that describes this particular exception.
|
||||
* @param s the String containing a detail message
|
||||
* @param minor the minor code
|
||||
* @param completed the completion status, which must be one of
|
||||
* <code>COMPLETED_YES</code>, <code>COMPLETED_NO</code>, or
|
||||
* <code>COMPLETED_MAYBE</code>.
|
||||
*/
|
||||
public COMM_FAILURE(String s, int minor, CompletionStatus completed) {
|
||||
super(s, minor, completed);
|
||||
}
|
||||
}
|
||||
52
jdkSrc/jdk8/org/omg/CORBA/CTX_RESTRICT_SCOPE.java
Normal file
52
jdkSrc/jdk8/org/omg/CORBA/CTX_RESTRICT_SCOPE.java
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
/**
|
||||
* A flag that can be used as the second parameter to the method
|
||||
* <code>Context.get_values</code> to restrict the search scope.
|
||||
* When this flag is used, it restricts the search for
|
||||
* context values to this particular <code>Context</code> object
|
||||
* or to the scope specified in the first parameter to
|
||||
* <code>Context.get_values</code>.
|
||||
* <P>
|
||||
* Usage:
|
||||
* <PRE>
|
||||
* NVList props = myContext.get_values("_USER",
|
||||
* CTX_RESTRICT_SCOPE.value, "id*");
|
||||
* </PRE>
|
||||
*
|
||||
* @see org.omg.CORBA.Context#get_values(String, int, String)
|
||||
* @since JDK1.2
|
||||
*/
|
||||
public interface CTX_RESTRICT_SCOPE {
|
||||
|
||||
/**
|
||||
* The field containing the <code>int</code> value of a
|
||||
* <code>CTX_RESTRICT_SCOPE</code> flag.
|
||||
*/
|
||||
int value = 15;
|
||||
}
|
||||
111
jdkSrc/jdk8/org/omg/CORBA/CharHolder.java
Normal file
111
jdkSrc/jdk8/org/omg/CORBA/CharHolder.java
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
import org.omg.CORBA.portable.Streamable;
|
||||
import org.omg.CORBA.portable.InputStream;
|
||||
import org.omg.CORBA.portable.OutputStream;
|
||||
|
||||
/**
|
||||
* The Holder for <tt>Char</tt>. For more information on
|
||||
* Holder files, see <a href="doc-files/generatedfiles.html#holder">
|
||||
* "Generated Files: Holder Files"</a>.<P>
|
||||
* A Holder class for a <code>char</code>
|
||||
* that is used to store "out" and "inout" parameters in IDL methods.
|
||||
* If an IDL method signature has an IDL <code>char</code> as an "out"
|
||||
* or "inout" parameter, the programmer must pass an instance of
|
||||
* <code>CharHolder</code> as the corresponding
|
||||
* parameter in the method invocation; for "inout" parameters, the programmer
|
||||
* must also fill the "in" value to be sent to the server.
|
||||
* Before the method invocation returns, the ORB will fill in the
|
||||
* value corresponding to the "out" value returned from the server.
|
||||
* <P>
|
||||
* If <code>myCharHolder</code> is an instance of <code>CharHolder</code>,
|
||||
* the value stored in its <code>value</code> field can be accessed with
|
||||
* <code>myCharHolder.value</code>.
|
||||
*
|
||||
* @since JDK1.2
|
||||
*/
|
||||
public final class CharHolder implements Streamable {
|
||||
|
||||
/**
|
||||
* The <code>char</code> value held by this <code>CharHolder</code>
|
||||
* object.
|
||||
*/
|
||||
public char value;
|
||||
|
||||
/**
|
||||
* Constructs a new <code>CharHolder</code> object with its
|
||||
* <code>value</code> field initialized to <code>0</code>.
|
||||
*/
|
||||
public CharHolder() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <code>CharHolder</code> object for the given
|
||||
* <code>char</code>.
|
||||
* @param initial the <code>char</code> with which to initialize
|
||||
* the <code>value</code> field of the new
|
||||
* <code>CharHolder</code> object
|
||||
*/
|
||||
public CharHolder(char initial) {
|
||||
value = initial;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads from <code>input</code> and initalizes the value in
|
||||
* this <code>CharHolder</code> object
|
||||
* with the unmarshalled data.
|
||||
*
|
||||
* @param input the InputStream containing CDR formatted data from the wire
|
||||
*/
|
||||
public void _read(InputStream input) {
|
||||
value = input.read_char();
|
||||
}
|
||||
|
||||
/**
|
||||
* Marshals to <code>output</code> the value in
|
||||
* this <code>CharHolder</code> object.
|
||||
*
|
||||
* @param output the OutputStream which will contain the CDR formatted data
|
||||
*/
|
||||
public void _write(OutputStream output) {
|
||||
output.write_char(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <code>TypeCode</code> object corresponding
|
||||
* to the value held in
|
||||
* this <code>CharHolder</code> object.
|
||||
*
|
||||
* @return the TypeCode of the value held in
|
||||
* this <code>CharHolder</code> object
|
||||
*/
|
||||
public org.omg.CORBA.TypeCode _type() {
|
||||
return ORB.init().get_primitive_tc(TCKind.tk_char);
|
||||
}
|
||||
}
|
||||
99
jdkSrc/jdk8/org/omg/CORBA/CharSeqHelper.java
Normal file
99
jdkSrc/jdk8/org/omg/CORBA/CharSeqHelper.java
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.omg.CORBA;
|
||||
|
||||
|
||||
/**
|
||||
* The Helper for <tt>CharSeq</tt>. For more information on
|
||||
* Helper files, see <a href="doc-files/generatedfiles.html#helper">
|
||||
* "Generated Files: Helper Files"</a>.<P>
|
||||
* org/omg/CORBA/CharSeqHelper.java
|
||||
* Generated by the IDL-to-Java compiler (portable), version "3.0"
|
||||
* from streams.idl
|
||||
* 13 May 1999 22:41:36 o'clock GMT+00:00
|
||||
*
|
||||
* The class definition has been modified to conform to the following
|
||||
* OMG specifications :
|
||||
* <ul>
|
||||
* <li> ORB core as defined by CORBA 2.3.1
|
||||
* (<a href="http://cgi.omg.org/cgi-bin/doc?formal/99-10-07">formal/99-10-07</a>)
|
||||
* </li>
|
||||
*
|
||||
* <li> IDL/Java Language Mapping as defined in
|
||||
* <a href="http://cgi.omg.org/cgi-bin/doc?ptc/00-01-08">ptc/00-01-08</a>
|
||||
* </li>
|
||||
* </ul>
|
||||
*/
|
||||
|
||||
public abstract class CharSeqHelper
|
||||
{
|
||||
private static String _id = "IDL:omg.org/CORBA/CharSeq:1.0";
|
||||
|
||||
public static void insert (org.omg.CORBA.Any a, char[] that)
|
||||
{
|
||||
org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
|
||||
a.type (type ());
|
||||
write (out, that);
|
||||
a.read_value (out.create_input_stream (), type ());
|
||||
}
|
||||
|
||||
public static char[] extract (org.omg.CORBA.Any a)
|
||||
{
|
||||
return read (a.create_input_stream ());
|
||||
}
|
||||
|
||||
private static org.omg.CORBA.TypeCode __typeCode = null;
|
||||
synchronized public static org.omg.CORBA.TypeCode type ()
|
||||
{
|
||||
if (__typeCode == null)
|
||||
{
|
||||
__typeCode = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_char);
|
||||
__typeCode = org.omg.CORBA.ORB.init ().create_sequence_tc (0, __typeCode);
|
||||
__typeCode = org.omg.CORBA.ORB.init ().create_alias_tc (org.omg.CORBA.CharSeqHelper.id (), "CharSeq", __typeCode);
|
||||
}
|
||||
return __typeCode;
|
||||
}
|
||||
|
||||
public static String id ()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public static char[] read (org.omg.CORBA.portable.InputStream istream)
|
||||
{
|
||||
char value[] = null;
|
||||
int _len0 = istream.read_long ();
|
||||
value = new char[_len0];
|
||||
istream.read_char_array (value, 0, _len0);
|
||||
return value;
|
||||
}
|
||||
|
||||
public static void write (org.omg.CORBA.portable.OutputStream ostream, char[] value)
|
||||
{
|
||||
ostream.write_long (value.length);
|
||||
ostream.write_char_array (value, 0, value.length);
|
||||
}
|
||||
|
||||
}
|
||||
66
jdkSrc/jdk8/org/omg/CORBA/CharSeqHolder.java
Normal file
66
jdkSrc/jdk8/org/omg/CORBA/CharSeqHolder.java
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.omg.CORBA;
|
||||
|
||||
|
||||
/**
|
||||
* The Holder for <tt>CharSeq</tt>. For more information on
|
||||
* Holder files, see <a href="doc-files/generatedfiles.html#holder">
|
||||
* "Generated Files: Holder Files"</a>.<P>
|
||||
* org/omg/CORBA/CharSeqHolder.java
|
||||
* Generated by the IDL-to-Java compiler (portable), version "3.0"
|
||||
* from streams.idl
|
||||
* 13 May 1999 22:41:36 o'clock GMT+00:00
|
||||
*/
|
||||
|
||||
public final class CharSeqHolder implements org.omg.CORBA.portable.Streamable
|
||||
{
|
||||
public char value[] = null;
|
||||
|
||||
public CharSeqHolder ()
|
||||
{
|
||||
}
|
||||
|
||||
public CharSeqHolder (char[] initialValue)
|
||||
{
|
||||
value = initialValue;
|
||||
}
|
||||
|
||||
public void _read (org.omg.CORBA.portable.InputStream i)
|
||||
{
|
||||
value = org.omg.CORBA.CharSeqHelper.read (i);
|
||||
}
|
||||
|
||||
public void _write (org.omg.CORBA.portable.OutputStream o)
|
||||
{
|
||||
org.omg.CORBA.CharSeqHelper.write (o, value);
|
||||
}
|
||||
|
||||
public org.omg.CORBA.TypeCode _type ()
|
||||
{
|
||||
return org.omg.CORBA.CharSeqHelper.type ();
|
||||
}
|
||||
|
||||
}
|
||||
142
jdkSrc/jdk8/org/omg/CORBA/CompletionStatus.java
Normal file
142
jdkSrc/jdk8/org/omg/CORBA/CompletionStatus.java
Normal file
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2000, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.omg.CORBA;
|
||||
|
||||
/**
|
||||
* An object that indicates whether a method had completed running
|
||||
* when a <code>SystemException</code> was thrown.
|
||||
* <P>
|
||||
* The class <code>CompletionStatus</code>
|
||||
* contains three <code>CompletionStatus</code> instances, which are constants
|
||||
* representing each
|
||||
* possible completion status: <code>COMPLETED_MAYBE</code>,
|
||||
* <code>COMPLETED_NO</code>, and <code>COMPLETED_YES</code>.
|
||||
* It also contains
|
||||
* three <code>int</code> members, each a constant corresponding to one of
|
||||
* the <code>CompletionStatus</code> instances. These <code>int</code>
|
||||
* members make it possible to use a <code>switch</code> statement.
|
||||
* <P>
|
||||
* The class also contains two methods:
|
||||
* <UL>
|
||||
* <LI><code>public int <bold>value</bold>()</code> -- which accesses the
|
||||
* <code>value</code> field of a <code>CompletionStatus</code> object
|
||||
* <LI><code>public static CompletionStatus
|
||||
* <bold>from_int</bold>(int i)</code> --
|
||||
* for creating an instance from one of the <code>int</code> members
|
||||
* </UL>
|
||||
* @see org.omg.CORBA.SystemException
|
||||
* @since JDK1.2
|
||||
*/
|
||||
|
||||
public final class CompletionStatus implements org.omg.CORBA.portable.IDLEntity
|
||||
{
|
||||
/**
|
||||
* The constant indicating that a method completed running
|
||||
* before a <code>SystemException</code> was thrown.
|
||||
*/
|
||||
public static final int _COMPLETED_YES = 0,
|
||||
|
||||
/**
|
||||
* The constant indicating that a method had not completed running
|
||||
* when a <code>SystemException</code> was thrown.
|
||||
*/
|
||||
_COMPLETED_NO = 1,
|
||||
|
||||
/**
|
||||
* The constant indicating that it is unknown whether a method had
|
||||
* completed running when a <code>SystemException</code> was thrown.
|
||||
*/
|
||||
_COMPLETED_MAYBE = 2;
|
||||
|
||||
|
||||
/**
|
||||
* An instance of <code>CompletionStatus</code> initialized with
|
||||
* the constant <code>_COMPLETED_YES</code>.
|
||||
*/
|
||||
public static final CompletionStatus COMPLETED_YES = new CompletionStatus(_COMPLETED_YES);
|
||||
|
||||
/**
|
||||
* An instance of <code>CompletionStatus</code> initialized with
|
||||
* the constant <code>_COMPLETED_NO</code>.
|
||||
*/
|
||||
public static final CompletionStatus COMPLETED_NO = new CompletionStatus(_COMPLETED_NO);
|
||||
|
||||
/**
|
||||
* An instance of <code>CompletionStatus</code> initialized with
|
||||
* the constant <code>_COMPLETED_MAYBE</code>.
|
||||
*/
|
||||
public static final CompletionStatus COMPLETED_MAYBE = new CompletionStatus(_COMPLETED_MAYBE);
|
||||
|
||||
/**
|
||||
* Retrieves the value of this <code>CompletionStatus</code> object.
|
||||
*
|
||||
* @return one of the possible <code>CompletionStatus</code> values:
|
||||
* <code>_COMPLETED_YES</code>, <code>_COMPLETED_NO</code>, or
|
||||
* <code>_COMPLETED_MAYBE</code>
|
||||
*
|
||||
*/
|
||||
public int value() { return _value; }
|
||||
|
||||
/**
|
||||
* Creates a <code>CompletionStatus</code> object from the given <code>int</code>.
|
||||
*
|
||||
* @param i one of <code>_COMPLETED_YES</code>, <code>_COMPLETED_NO</code>, or
|
||||
* <code>_COMPLETED_MAYBE</code>
|
||||
*
|
||||
* @return one of the possible <code>CompletionStatus</code> objects
|
||||
* with values:
|
||||
* <code>_COMPLETED_YES</code>, <code>_COMPLETED_NO</code>, or
|
||||
* <code>_COMPLETED_MAYBE</code>
|
||||
*
|
||||
* @exception org.omg.CORBA.BAD_PARAM if the argument given is not one of the
|
||||
* <code>int</code> constants defined in <code>CompletionStatus</code>
|
||||
*/
|
||||
public static CompletionStatus from_int(int i) {
|
||||
switch (i) {
|
||||
case _COMPLETED_YES:
|
||||
return COMPLETED_YES;
|
||||
case _COMPLETED_NO:
|
||||
return COMPLETED_NO;
|
||||
case _COMPLETED_MAYBE:
|
||||
return COMPLETED_MAYBE;
|
||||
default:
|
||||
throw new org.omg.CORBA.BAD_PARAM();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a <code>CompletionStatus</code> object from the given <code>int</code>.
|
||||
*
|
||||
* @param _value one of <code>_COMPLETED_YES</code>, <code>_COMPLETED_NO</code>, or
|
||||
* <code>_COMPLETED_MAYBE</code>
|
||||
*
|
||||
*/
|
||||
private CompletionStatus(int _value) {
|
||||
this._value = _value;
|
||||
}
|
||||
|
||||
private int _value;
|
||||
}
|
||||
79
jdkSrc/jdk8/org/omg/CORBA/CompletionStatusHelper.java
Normal file
79
jdkSrc/jdk8/org/omg/CORBA/CompletionStatusHelper.java
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.omg.CORBA;
|
||||
|
||||
|
||||
/**
|
||||
* The Helper for <tt>CompletionStatus</tt>. For more information on
|
||||
* Helper files, see <a href="doc-files/generatedfiles.html#helper">
|
||||
* "Generated Files: Helper Files"</a>.<P>
|
||||
* org/omg/CORBA/CompletionStatusHelper.java
|
||||
* Generated by the IDL-to-Java compiler (portable), version "3.0"
|
||||
* 03 June 1999 11:52:03 o'clock GMT+00:00
|
||||
*/
|
||||
|
||||
abstract public class CompletionStatusHelper
|
||||
{
|
||||
private static String _id = "IDL:omg.org/CORBA/CompletionStatus:1.0";
|
||||
|
||||
public static void insert (org.omg.CORBA.Any a, org.omg.CORBA.CompletionStatus that)
|
||||
{
|
||||
org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
|
||||
a.type (type ());
|
||||
write (out, that);
|
||||
a.read_value (out.create_input_stream (), type ());
|
||||
}
|
||||
|
||||
public static org.omg.CORBA.CompletionStatus extract (org.omg.CORBA.Any a)
|
||||
{
|
||||
return read (a.create_input_stream ());
|
||||
}
|
||||
|
||||
private static org.omg.CORBA.TypeCode __typeCode = null;
|
||||
synchronized public static org.omg.CORBA.TypeCode type ()
|
||||
{
|
||||
if (__typeCode == null)
|
||||
{
|
||||
__typeCode = org.omg.CORBA.ORB.init ().create_enum_tc (org.omg.CORBA.CompletionStatusHelper.id (), "CompletionStatus", new String[] { "COMPLETED_YES", "COMPLETED_NO", "COMPLETED_MAYBE"} );
|
||||
}
|
||||
return __typeCode;
|
||||
}
|
||||
|
||||
public static String id ()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public static org.omg.CORBA.CompletionStatus read (org.omg.CORBA.portable.InputStream istream)
|
||||
{
|
||||
return org.omg.CORBA.CompletionStatus.from_int (istream.read_long ());
|
||||
}
|
||||
|
||||
public static void write (org.omg.CORBA.portable.OutputStream ostream, org.omg.CORBA.CompletionStatus value)
|
||||
{
|
||||
ostream.write_long (value.value ());
|
||||
}
|
||||
|
||||
}
|
||||
244
jdkSrc/jdk8/org/omg/CORBA/Context.java
Normal file
244
jdkSrc/jdk8/org/omg/CORBA/Context.java
Normal file
@@ -0,0 +1,244 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2000, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
/**
|
||||
* An object used in <code>Request</code> operations
|
||||
* to specify the context object in which context strings
|
||||
* must be resolved before being sent along with the request invocation.
|
||||
* A <code>Context</code> object
|
||||
* contains a list of properties in the form of <code>NamedValue</code>
|
||||
* objects. These properties represent information
|
||||
* about the client, the environment, or the circumstances of a request
|
||||
* and generally are properties that might be inconvenient
|
||||
* to pass as parameters.
|
||||
* <P>
|
||||
* A <code>Context</code> object is created by first calling the
|
||||
* <code>ORB</code> method <code>get_default_context</code>
|
||||
* and then calling the method <code>create_child</code> on the
|
||||
* default context.
|
||||
* <P>
|
||||
* Each property in a <code>Context</code> object is represented by
|
||||
* a <code>NamedValue</code> object. The property name is contained
|
||||
* in the <code>NamedValue</code> object's <code>name</code> field, and
|
||||
* the value associated with the name is contained in the <code>Any</code>
|
||||
* object that was assigned to the <code>NamedValue</code> object's
|
||||
* <code>value</code> field.
|
||||
* <P>
|
||||
* <code>Context</code> properties can represent a portion of a client's
|
||||
* or application's environment that is meant to be propagated to
|
||||
* (and made implicitly part of) a server's environment.
|
||||
* (Examples might be a window identifier or user preference information).
|
||||
* Once a server has been invoked (that is, after the properties are
|
||||
* propagated), the server may query its <code>Context</code> object
|
||||
* for these properties using the method <code>get_values</code>.
|
||||
*
|
||||
*<P>
|
||||
* When an operation declaration includes a context clause,
|
||||
* the stubs and skeletons will have an additional argument
|
||||
* added for the context. When an operation invocation occurs,
|
||||
* the ORB causes the properties that were named in the operation
|
||||
* definition in IDL and
|
||||
* that are present in the client's <code>Context</code> object
|
||||
* to be provided in the <code>Context</code> object parameter to
|
||||
* the invoked method.
|
||||
* <P>
|
||||
* <code>Context</code> property names (which are strings)
|
||||
* typically have the form of an OMG IDL identifier or
|
||||
* a series of OMG IDL identifiers separated by periods.
|
||||
* A context property name pattern is either a property name
|
||||
* or a property name followed by a single "*". A property
|
||||
* name pattern without a trailing "*" is said to match only
|
||||
* itself. A property name pattern of the form "<name>*" matches any
|
||||
* property name that starts with <name> and continues with zero
|
||||
* or more additional characters.
|
||||
* <P>
|
||||
* Property name patterns are used in the context clause of
|
||||
* an operation definition and as a parameter for the
|
||||
* method <code>Context.get_values</code>.
|
||||
* <P>
|
||||
* <code>Context</code> objects may be "chained" together to achieve a
|
||||
* particular defaulting behavior. A <code>Context</code>
|
||||
* object created with the method <code>create_child</code> will
|
||||
* be chained to its parent (the <code>Context</code> object
|
||||
* that created it), and that means that the parent will be searched
|
||||
* after the child in a search for property names.
|
||||
*<P>
|
||||
* Properties defined in a particular <code>Context</code> object
|
||||
* effectively override those properties in the next higher level.
|
||||
* The scope used in a search for properties may be restricted by specifying a
|
||||
* starting scope and by using the flag <code>CTX_RESTRICT_SCOPE</code>
|
||||
* when invoking the method <code>get_values</code>.
|
||||
* <P>
|
||||
* A <code>Context</code> object may be named for purposes of specifying
|
||||
* a starting search scope.
|
||||
*
|
||||
* @since JDK1.2
|
||||
*/
|
||||
|
||||
public abstract class Context {
|
||||
|
||||
/**
|
||||
* Retrieves the name of this <code>Context</code> object.
|
||||
*
|
||||
* @return the name of this <code>Context</code> object
|
||||
*/
|
||||
|
||||
public abstract String context_name();
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the parent of this <code>Context</code> object.
|
||||
*
|
||||
* @return the <code>Context</code> object that is the
|
||||
* parent of this <code>Context</code> object
|
||||
*/
|
||||
|
||||
public abstract Context parent();
|
||||
|
||||
/**
|
||||
* Creates a <code>Context</code> object with the given string as its
|
||||
* name and with this <code>Context</code> object set as its parent.
|
||||
* <P>
|
||||
* The new <code>Context</code> object is chained into its parent
|
||||
* <code>Context</code> object. This means that in a search for
|
||||
* matching property names, if a match is not found in this context,
|
||||
* the search will continue in the parent. If that is not successful,
|
||||
* the search will continue in the grandparent, if there is one, and
|
||||
* so on.
|
||||
*
|
||||
*
|
||||
* @param child_ctx_name the <code>String</code> object to be set as
|
||||
* the name of the new <code>Context</code> object
|
||||
* @return the newly-created child <code>Context</code> object
|
||||
* initialized with the specified name
|
||||
*/
|
||||
|
||||
public abstract Context create_child(String child_ctx_name);
|
||||
|
||||
/**
|
||||
* Creates a <code>NamedValue</code> object and adds it to this
|
||||
* <code>Context</code> object. The <code>name</code> field of the
|
||||
* new <code>NamedValue</code> object is set to the given string,
|
||||
* the <code>value</code> field is set to the given <code>Any</code>
|
||||
* object, and the <code>flags</code> field is set to zero.
|
||||
*
|
||||
* @param propname the name of the property to be set
|
||||
* @param propvalue the <code>Any</code> object to which the
|
||||
* value of the property will be set. The
|
||||
* <code>Any</code> object's <code>value</code>
|
||||
* field contains the value to be associated
|
||||
* with the given propname; the
|
||||
* <code>kind</code> field must be set to
|
||||
* <code>TCKind.tk_string</code>.
|
||||
*/
|
||||
|
||||
public abstract void set_one_value(String propname, Any propvalue);
|
||||
|
||||
/**
|
||||
I Sets one or more property values in this <code>Context</code>
|
||||
* object. The <code>NVList</code> supplied to this method
|
||||
* contains one or more <code>NamedValue</code> objects.
|
||||
* In each <code>NamedValue</code> object,
|
||||
* the <code>name</code> field holds the name of the property, and
|
||||
* the <code>flags</code> field must be set to zero.
|
||||
* The <code>NamedValue</code> object's <code>value</code> field
|
||||
* contains an <code>Any</code> object, which, in turn, contains the value
|
||||
* for the property. Since the value is always a string,
|
||||
* the <code>Any</code> object must have the <code>kind</code>
|
||||
* field of its <code>TypeCode</code> set to <code>TCKind.tk_string</code>.
|
||||
*
|
||||
* @param values an NVList containing the property
|
||||
* names and associated values to be set
|
||||
*
|
||||
* @see #get_values
|
||||
* @see org.omg.CORBA.NamedValue
|
||||
* @see org.omg.CORBA.Any
|
||||
*/
|
||||
|
||||
public abstract void set_values(NVList values);
|
||||
|
||||
/**
|
||||
* Deletes from this <code>Context</code> object the
|
||||
* <code>NamedValue</code> object(s) whose
|
||||
* <code>name</code> field matches the given property name.
|
||||
* If the <code>String</code> object supplied for
|
||||
* <code>propname</code> has a
|
||||
* trailing wildcard character ("*"), then
|
||||
* all <code>NamedValue</code> objects whose <code>name</code>
|
||||
* fields match will be deleted. The search scope is always
|
||||
* limited to this <code>Context</code> object.
|
||||
* <P>
|
||||
* If no matching property is found, an exception is returned.
|
||||
*
|
||||
* @param propname name of the property to be deleted
|
||||
*/
|
||||
|
||||
public abstract void delete_values(String propname);
|
||||
|
||||
/**
|
||||
* Retrieves the <code>NamedValue</code> objects whose
|
||||
* <code>name</code> field matches the given name or name
|
||||
* pattern. This method allows for wildcard searches,
|
||||
* which means that there can be multiple matches and
|
||||
* therefore multiple values returned. If the
|
||||
* property is not found at the indicated level, the search
|
||||
* continues up the context object tree until a match is found or
|
||||
* all <code>Context</code> objects in the chain have been exhausted.
|
||||
* <P>
|
||||
* If no match is found, an error is returned and no property list
|
||||
* is returned.
|
||||
*
|
||||
* @param start_scope a <code>String</code> object indicating the
|
||||
* context object level at which to initiate the
|
||||
* search for the specified properties
|
||||
* (for example, "_USER", "_GROUP", "_SYSTEM"). Valid scope
|
||||
* names are implementation-specific. If a
|
||||
* scope name is omitted, the search
|
||||
* begins with the specified context
|
||||
* object. If the specified scope name is
|
||||
* not found, an exception is returned.
|
||||
* @param op_flags an operation flag. The one flag
|
||||
* that may be specified is <code>CTX_RESTRICT_SCOPE</code>.
|
||||
* If this flag is specified, searching is limited to the
|
||||
* specified <code>start_scope</code> or this
|
||||
* <code>Context</code> object.
|
||||
* @param pattern the property name whose values are to
|
||||
* be retrieved. <code>pattern</code> may be a
|
||||
* name or a name with a
|
||||
* trailing wildcard character ("*").
|
||||
*
|
||||
* @return an <code>NVList</code> containing all the property values
|
||||
* (in the form of <code>NamedValue</code> objects)
|
||||
* whose associated property name matches the given name or
|
||||
* name pattern
|
||||
* @see #set_values
|
||||
* @see org.omg.CORBA.NamedValue
|
||||
*/
|
||||
|
||||
abstract public NVList get_values(String start_scope, int op_flags,
|
||||
String pattern);
|
||||
};
|
||||
106
jdkSrc/jdk8/org/omg/CORBA/ContextList.java
Normal file
106
jdkSrc/jdk8/org/omg/CORBA/ContextList.java
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1999, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
/**
|
||||
* An object containing a modifiable list of <code>String</code> objects
|
||||
* that represent property names.
|
||||
* This class is used in <code>Request</code> operations to
|
||||
* describe the contexts that need to be resolved and sent with the
|
||||
* invocation. (A context is resolved by giving a property name
|
||||
* and getting back the value associated with it.) This is done
|
||||
* by calling the <code>Context</code> method
|
||||
* <code>get_values</code> and supplying a string from a
|
||||
* <code>ContextList</code> object as the third parameter.
|
||||
* The method <code>get_values</code> returns an <code>NVList</code>
|
||||
* object containing the <code>NamedValue</code> objects that hold
|
||||
* the value(s) identified by the given string.
|
||||
* <P>
|
||||
* A <code>ContextList</code> object is created by the ORB, as
|
||||
* illustrated here:
|
||||
* <PRE>
|
||||
* ORB orb = ORB.init(args, null);
|
||||
* org.omg.CORBA.ContextList ctxList = orb.create_context_list();
|
||||
* </PRE>
|
||||
* The variable <code>ctxList</code> represents an empty
|
||||
* <code>ContextList</code> object. Strings are added to
|
||||
* the list with the method <code>add</code>, accessed
|
||||
* with the method <code>item</code>, and removed with the
|
||||
* method <code>remove</code>.
|
||||
*
|
||||
* @see Context
|
||||
* @since JDK1.2
|
||||
*/
|
||||
|
||||
public abstract class ContextList {
|
||||
|
||||
/**
|
||||
* Returns the number of <code>String</code> objects in this
|
||||
* <code>ContextList</code> object.
|
||||
*
|
||||
* @return an <code>int</code> representing the number of
|
||||
* <code>String</code>s in this <code>ContextList</code> object
|
||||
*/
|
||||
|
||||
public abstract int count();
|
||||
|
||||
/**
|
||||
* Adds a <code>String</code> object to this <code>ContextList</code>
|
||||
* object.
|
||||
*
|
||||
* @param ctx the <code>String</code> object to be added
|
||||
*/
|
||||
|
||||
public abstract void add(String ctx);
|
||||
|
||||
/**
|
||||
* Returns the <code>String</code> object at the given index.
|
||||
*
|
||||
* @param index the index of the string desired, with 0 being the
|
||||
index of the first string
|
||||
* @return the string at the given index
|
||||
* @exception org.omg.CORBA.Bounds if the index is greater than
|
||||
* or equal to the number of strings in this
|
||||
* <code>ContextList</code> object
|
||||
*/
|
||||
|
||||
public abstract String item(int index) throws org.omg.CORBA.Bounds;
|
||||
|
||||
/**
|
||||
* Removes the <code>String</code> object at the given index. Note that
|
||||
* the indices of all strings following the one removed are
|
||||
* shifted down by one.
|
||||
*
|
||||
* @param index the index of the <code>String</code> object to be removed,
|
||||
* with 0 designating the first string
|
||||
* @exception org.omg.CORBA.Bounds if the index is greater than
|
||||
* or equal to the number of <code>String</code> objects in
|
||||
* this <code>ContextList</code> object
|
||||
*/
|
||||
|
||||
public abstract void remove(int index) throws org.omg.CORBA.Bounds;
|
||||
|
||||
}
|
||||
48
jdkSrc/jdk8/org/omg/CORBA/Current.java
Normal file
48
jdkSrc/jdk8/org/omg/CORBA/Current.java
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.omg.CORBA;
|
||||
|
||||
|
||||
/**
|
||||
* Interfaces derived from the <tt>Current</tt> interface enable ORB and CORBA
|
||||
* services to provide access to information (context) associated with
|
||||
* the thread of execution in which they are running. This information
|
||||
* is accessed in a structured manner using interfaces derived from the
|
||||
* <tt>Current</tt> interface defined in the CORBA module.
|
||||
*
|
||||
* <P>Each ORB or CORBA service that needs its own context derives an
|
||||
* interface from the CORBA module's <tt>Current</tt>. Users of the
|
||||
* service can obtain an instance of the appropriate <tt>Current</tt>
|
||||
* interface by invoking <tt>ORB::resolve_initial_references</tt>.<P>
|
||||
*
|
||||
* org/omg/CORBA/Current.java
|
||||
* Generated by the IDL-to-Java compiler (portable), version "3.0"
|
||||
* from ../../../../../src/share/classes/org/omg/PortableServer/corba.idl
|
||||
* Saturday, July 17, 1999 12:26:21 AM PDT.
|
||||
*/
|
||||
|
||||
public interface Current extends CurrentOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity
|
||||
{
|
||||
} // interface Current
|
||||
87
jdkSrc/jdk8/org/omg/CORBA/CurrentHelper.java
Normal file
87
jdkSrc/jdk8/org/omg/CORBA/CurrentHelper.java
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.omg.CORBA;
|
||||
|
||||
|
||||
/**
|
||||
* The Helper for <tt>Current</tt>. For more information on
|
||||
* Helper files, see <a href="doc-files/generatedfiles.html#helper">
|
||||
* "Generated Files: Helper Files"</a>.<P>
|
||||
* org/omg/CORBA/CurrentHelper.java
|
||||
* Generated by the IDL-to-Java compiler (portable), version "3.0"
|
||||
* from ../../../../../src/share/classes/org/omg/PortableServer/corba.idl
|
||||
* Saturday, July 17, 1999 12:26:21 AM PDT
|
||||
*/
|
||||
|
||||
abstract public class CurrentHelper
|
||||
{
|
||||
private static String _id = "IDL:omg.org/CORBA/Current:1.0";
|
||||
|
||||
public static void insert (org.omg.CORBA.Any a, org.omg.CORBA.Current that)
|
||||
{
|
||||
throw new org.omg.CORBA.MARSHAL() ;
|
||||
}
|
||||
|
||||
public static org.omg.CORBA.Current extract (org.omg.CORBA.Any a)
|
||||
{
|
||||
throw new org.omg.CORBA.MARSHAL() ;
|
||||
}
|
||||
|
||||
private static org.omg.CORBA.TypeCode __typeCode = null;
|
||||
synchronized public static org.omg.CORBA.TypeCode type ()
|
||||
{
|
||||
if (__typeCode == null)
|
||||
{
|
||||
__typeCode = org.omg.CORBA.ORB.init ().create_interface_tc (org.omg.CORBA.CurrentHelper.id (), "Current");
|
||||
}
|
||||
return __typeCode;
|
||||
}
|
||||
|
||||
public static String id ()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public static org.omg.CORBA.Current read (org.omg.CORBA.portable.InputStream istream)
|
||||
{
|
||||
throw new org.omg.CORBA.MARSHAL() ;
|
||||
}
|
||||
|
||||
public static void write (org.omg.CORBA.portable.OutputStream ostream, org.omg.CORBA.Current value)
|
||||
{
|
||||
throw new org.omg.CORBA.MARSHAL() ;
|
||||
}
|
||||
|
||||
public static org.omg.CORBA.Current narrow (org.omg.CORBA.Object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
else if (obj instanceof org.omg.CORBA.Current)
|
||||
return (org.omg.CORBA.Current)obj;
|
||||
else
|
||||
throw new org.omg.CORBA.BAD_PARAM ();
|
||||
}
|
||||
|
||||
}
|
||||
65
jdkSrc/jdk8/org/omg/CORBA/CurrentHolder.java
Normal file
65
jdkSrc/jdk8/org/omg/CORBA/CurrentHolder.java
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.omg.CORBA;
|
||||
|
||||
/**
|
||||
* The Holder for <tt>Current</tt>. For more information on
|
||||
* Holder files, see <a href="doc-files/generatedfiles.html#holder">
|
||||
* "Generated Files: Holder Files"</a>.<P>
|
||||
* org/omg/CORBA/CurrentHolder.java
|
||||
* Generated by the IDL-to-Java compiler (portable), version "3.0"
|
||||
* from ../../../../../src/share/classes/org/omg/PortableServer/corba.idl
|
||||
* Saturday, July 17, 1999 12:26:21 AM PDT
|
||||
*/
|
||||
|
||||
public final class CurrentHolder implements org.omg.CORBA.portable.Streamable
|
||||
{
|
||||
public org.omg.CORBA.Current value = null;
|
||||
|
||||
public CurrentHolder ()
|
||||
{
|
||||
}
|
||||
|
||||
public CurrentHolder (org.omg.CORBA.Current initialValue)
|
||||
{
|
||||
value = initialValue;
|
||||
}
|
||||
|
||||
public void _read (org.omg.CORBA.portable.InputStream i)
|
||||
{
|
||||
value = org.omg.CORBA.CurrentHelper.read (i);
|
||||
}
|
||||
|
||||
public void _write (org.omg.CORBA.portable.OutputStream o)
|
||||
{
|
||||
org.omg.CORBA.CurrentHelper.write (o, value);
|
||||
}
|
||||
|
||||
public org.omg.CORBA.TypeCode _type ()
|
||||
{
|
||||
return org.omg.CORBA.CurrentHelper.type ();
|
||||
}
|
||||
|
||||
}
|
||||
41
jdkSrc/jdk8/org/omg/CORBA/CurrentOperations.java
Normal file
41
jdkSrc/jdk8/org/omg/CORBA/CurrentOperations.java
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.omg.CORBA;
|
||||
|
||||
|
||||
/**
|
||||
* The interface for <tt>Current</tt>. For more information on
|
||||
* Operations interfaces, see <a href="doc-files/generatedfiles.html">
|
||||
* "Generated Files"</a>.
|
||||
*
|
||||
* org/omg/CORBA/CurrentOperations.java
|
||||
* Generated by the IDL-to-Java compiler (portable), version "3.0"
|
||||
* from ../../../../../src/share/classes/org/omg/PortableServer/corba.idl
|
||||
* Saturday, July 17, 1999 12:26:21 AM PDT.
|
||||
*/
|
||||
|
||||
public interface CurrentOperations
|
||||
{
|
||||
} // interface CurrentOperations
|
||||
57
jdkSrc/jdk8/org/omg/CORBA/CustomMarshal.java
Normal file
57
jdkSrc/jdk8/org/omg/CORBA/CustomMarshal.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
import org.omg.CORBA.DataOutputStream;
|
||||
import org.omg.CORBA.DataInputStream;
|
||||
|
||||
/**
|
||||
* An abstract value type that is meant to
|
||||
* be used by the ORB, not the user. Semantically it is treated
|
||||
* as a custom value type's implicit base class, although the custom
|
||||
* valuetype does not actually inherit it in IDL. The implementer
|
||||
* of a custom value type shall provide an implementation of the
|
||||
* <tt>CustomMarshal</tt> operations. The manner in which this is done is
|
||||
* specified in the IDL to Java langauge mapping. Each custom
|
||||
* marshaled value type shall have its own implementation.
|
||||
* @see DataInputStream
|
||||
*/
|
||||
public interface CustomMarshal {
|
||||
/**
|
||||
* Marshal method has to be implemented by the Customized Marshal class.
|
||||
* This is the method invoked for Marshalling.
|
||||
*
|
||||
* @param os a DataOutputStream
|
||||
*/
|
||||
void marshal(DataOutputStream os);
|
||||
/**
|
||||
* Unmarshal method has to be implemented by the Customized Marshal class.
|
||||
* This is the method invoked for Unmarshalling.
|
||||
*
|
||||
* @param is a DataInputStream
|
||||
*/
|
||||
void unmarshal(DataInputStream is);
|
||||
}
|
||||
85
jdkSrc/jdk8/org/omg/CORBA/DATA_CONVERSION.java
Normal file
85
jdkSrc/jdk8/org/omg/CORBA/DATA_CONVERSION.java
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
/**
|
||||
* This exception is raised if an ORB cannot convert the representation
|
||||
* of data as marshaled into its native representation or vice-versa.
|
||||
* For example, DATA_CONVERSION can be raised if wide character codeset
|
||||
* conversion fails, or if an ORB cannot convert floating point values
|
||||
* between different representations.<P>
|
||||
* It contains a minor code, which gives more detailed information about
|
||||
* what caused the exception, and a completion status. It may also contain
|
||||
* a string describing the exception.
|
||||
* <P>
|
||||
* See the section <A href="../../../../technotes/guides/idl/jidlExceptions.html#minorcodemeanings">meaning
|
||||
* of minor codes</A> to see the minor codes for this exception.
|
||||
*
|
||||
* @see <A href="../../../../technotes/guides/idl/jidlExceptions.html">documentation on
|
||||
* Java IDL exceptions</A>
|
||||
* @since JDK1.2
|
||||
*/
|
||||
|
||||
public final class DATA_CONVERSION extends SystemException {
|
||||
|
||||
/**
|
||||
* Constructs a <code>DATA_CONVERSION</code> exception with a default minor code
|
||||
* of 0 and a completion state of COMPLETED_NO.
|
||||
*/
|
||||
public DATA_CONVERSION() {
|
||||
this("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>DATA_CONVERSION</code> exception with the specified detail.
|
||||
* @param s the String containing a detail message
|
||||
*/
|
||||
public DATA_CONVERSION(String s) {
|
||||
this(s, 0, CompletionStatus.COMPLETED_NO);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>DATA_CONVERSION</code> exception with the specified
|
||||
* minor code and completion status.
|
||||
* @param minor the minor code
|
||||
* @param completed the completion status
|
||||
*/
|
||||
public DATA_CONVERSION(int minor, CompletionStatus completed) {
|
||||
this("", minor, completed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>DATA_CONVERSION</code> exception with the specified detail
|
||||
* message, minor code, and completion status.
|
||||
* A detail message is a String that describes this particular exception.
|
||||
* @param s the String containing a detail message
|
||||
* @param minor the minor code
|
||||
* @param completed the completion status
|
||||
*/
|
||||
public DATA_CONVERSION(String s, int minor, CompletionStatus completed) {
|
||||
super(s, minor, completed);
|
||||
}
|
||||
}
|
||||
344
jdkSrc/jdk8/org/omg/CORBA/DataInputStream.java
Normal file
344
jdkSrc/jdk8/org/omg/CORBA/DataInputStream.java
Normal file
@@ -0,0 +1,344 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
/** Defines the methods used to read primitive data types from input streams
|
||||
* for unmarshaling custom value types. This interface is used by user
|
||||
* written custom unmarshaling code for custom value types.
|
||||
* @see org.omg.CORBA.DataOutputStream
|
||||
* @see org.omg.CORBA.CustomMarshal
|
||||
*/
|
||||
public interface DataInputStream extends org.omg.CORBA.portable.ValueBase
|
||||
{
|
||||
/** Reads an IDL <code>Any</code> value from the input stream.
|
||||
* @return the <code>Any</code> read.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
org.omg.CORBA.Any read_any ();
|
||||
|
||||
/** Reads an IDL boolean value from the input stream.
|
||||
* @return the boolean read.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
boolean read_boolean ();
|
||||
|
||||
/** Reads an IDL character value from the input stream.
|
||||
* @return the character read.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
char read_char ();
|
||||
|
||||
/** Reads an IDL wide character value from the input stream.
|
||||
* @return the wide character read.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
char read_wchar ();
|
||||
|
||||
/** Reads an IDL octet value from the input stream.
|
||||
* @return the octet value read.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
byte read_octet ();
|
||||
|
||||
/** Reads an IDL short from the input stream.
|
||||
* @return the short read.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
short read_short ();
|
||||
|
||||
/** Reads an IDL unsigned short from the input stream.
|
||||
* @return the unsigned short read.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
short read_ushort ();
|
||||
|
||||
/** Reads an IDL long from the input stream.
|
||||
* @return the long read.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
int read_long ();
|
||||
|
||||
/** Reads an IDL unsigned long from the input stream.
|
||||
* @return the unsigned long read.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
int read_ulong ();
|
||||
|
||||
/** Reads an IDL long long from the input stream.
|
||||
* @return the long long read.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
long read_longlong ();
|
||||
|
||||
/** Reads an unsigned IDL long long from the input stream.
|
||||
* @return the unsigned long long read.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
long read_ulonglong ();
|
||||
|
||||
/** Reads an IDL float from the input stream.
|
||||
* @return the float read.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
float read_float ();
|
||||
|
||||
/** Reads an IDL double from the input stream.
|
||||
* @return the double read.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
double read_double ();
|
||||
// read_longdouble not supported by IDL/Java mapping
|
||||
|
||||
/** Reads an IDL string from the input stream.
|
||||
* @return the string read.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
String read_string ();
|
||||
|
||||
/** Reads an IDL wide string from the input stream.
|
||||
* @return the wide string read.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
String read_wstring ();
|
||||
|
||||
/** Reads an IDL CORBA::Object from the input stream.
|
||||
* @return the CORBA::Object read.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
org.omg.CORBA.Object read_Object ();
|
||||
|
||||
/** Reads an IDL Abstract interface from the input stream.
|
||||
* @return the Abstract interface read.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
java.lang.Object read_Abstract ();
|
||||
|
||||
/** Reads an IDL value type from the input stream.
|
||||
* @return the value type read.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
java.io.Serializable read_Value ();
|
||||
|
||||
/** Reads an IDL typecode from the input stream.
|
||||
* @return the typecode read.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
org.omg.CORBA.TypeCode read_TypeCode ();
|
||||
|
||||
/** Reads array of IDL Anys from offset for length elements from the
|
||||
* input stream.
|
||||
* @param seq The out parameter holder for the array to be read.
|
||||
* @param offset The index into seq of the first element to read from the
|
||||
* input stream.
|
||||
* @param length The number of elements to read from the input stream.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
void read_any_array (org.omg.CORBA.AnySeqHolder seq, int offset, int length);
|
||||
|
||||
/** Reads array of IDL booleans from offset for length elements from the
|
||||
* input stream.
|
||||
* @param seq The out parameter holder for the array to be read.
|
||||
* @param offset The index into seq of the first element to read from the
|
||||
* input stream.
|
||||
* @param length The number of elements to read from the input stream.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
void read_boolean_array (org.omg.CORBA.BooleanSeqHolder seq, int offset, int length);
|
||||
|
||||
/** Reads array of IDL characters from offset for length elements from the
|
||||
* input stream.
|
||||
* @param seq The out parameter holder for the array to be read.
|
||||
* @param offset The index into seq of the first element to read from the
|
||||
* input stream.
|
||||
* @param length The number of elements to read from the input stream.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
void read_char_array (org.omg.CORBA.CharSeqHolder seq, int offset, int length);
|
||||
|
||||
/** Reads array of IDL wide characters from offset for length elements from the
|
||||
* input stream.
|
||||
* @param seq The out parameter holder for the array to be read.
|
||||
* @param offset The index into seq of the first element to read from the
|
||||
* input stream.
|
||||
* @param length The number of elements to read from the input stream.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
void read_wchar_array (org.omg.CORBA.WCharSeqHolder seq, int offset, int length);
|
||||
|
||||
/** Reads array of IDL octets from offset for length elements from the
|
||||
* input stream.
|
||||
* @param seq The out parameter holder for the array to be read.
|
||||
* @param offset The index into seq of the first element to read from the
|
||||
* input stream.
|
||||
* @param length The number of elements to read from the input stream.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
void read_octet_array (org.omg.CORBA.OctetSeqHolder seq, int offset, int length);
|
||||
|
||||
/** Reads array of IDL shorts from offset for length elements from the
|
||||
* input stream.
|
||||
* @param seq The out parameter holder for the array to be read.
|
||||
* @param offset The index into seq of the first element to read from the
|
||||
* input stream.
|
||||
* @param length The number of elements to read from the input stream.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
void read_short_array (org.omg.CORBA.ShortSeqHolder seq, int offset, int length);
|
||||
|
||||
/** Reads array of IDL unsigned shorts from offset for length elements from the
|
||||
* input stream.
|
||||
* @param seq The out parameter holder for the array to be read.
|
||||
* @param offset The index into seq of the first element to read from the
|
||||
* input stream.
|
||||
* @param length The number of elements to read from the input stream.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
void read_ushort_array (org.omg.CORBA.UShortSeqHolder seq, int offset, int length);
|
||||
|
||||
/** Reads array of IDL longs from offset for length elements from the
|
||||
* input stream.
|
||||
* @param seq The out parameter holder for the array to be read.
|
||||
* @param offset The index into seq of the first element to read from the
|
||||
* input stream.
|
||||
* @param length The number of elements to read from the input stream.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
void read_long_array (org.omg.CORBA.LongSeqHolder seq, int offset, int length);
|
||||
|
||||
/** Reads array of IDL unsigned longs from offset for length elements from the
|
||||
* input stream.
|
||||
* @param seq The out parameter holder for the array to be read.
|
||||
* @param offset The index into seq of the first element to read from the
|
||||
* input stream.
|
||||
* @param length The number of elements to read from the input stream.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
void read_ulong_array (org.omg.CORBA.ULongSeqHolder seq, int offset, int length);
|
||||
|
||||
/** Reads array of IDL unsigned long longs from offset for length elements from the
|
||||
* input stream.
|
||||
* @param seq The out parameter holder for the array to be read.
|
||||
* @param offset The index into seq of the first element to read from the
|
||||
* input stream.
|
||||
* @param length The number of elements to read from the input stream.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
void read_ulonglong_array (org.omg.CORBA.ULongLongSeqHolder seq, int offset, int length);
|
||||
|
||||
/** Reads array of IDL long longs from offset for length elements from the
|
||||
* input stream.
|
||||
* @param seq The out parameter holder for the array to be read.
|
||||
* @param offset The index into seq of the first element to read from the
|
||||
* input stream.
|
||||
* @param length The number of elements to read from the input stream.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
void read_longlong_array (org.omg.CORBA.LongLongSeqHolder seq, int offset, int length);
|
||||
|
||||
/** Reads array of IDL floats from offset for length elements from the
|
||||
* input stream.
|
||||
* @param seq The out parameter holder for the array to be read.
|
||||
* @param offset The index into seq of the first element to read from the
|
||||
* input stream.
|
||||
* @param length The number of elements to read from the input stream.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
void read_float_array (org.omg.CORBA.FloatSeqHolder seq, int offset, int length);
|
||||
|
||||
/** Reads array of IDL doubles from offset for length elements from the
|
||||
* input stream.
|
||||
* @param seq The out parameter holder for the array to be read.
|
||||
* @param offset The index into seq of the first element to read from the
|
||||
* input stream.
|
||||
* @param length The number of elements to read from the input stream.
|
||||
* @throws <code>org.omg.CORBA.MARSHAL</code>
|
||||
* If an inconsistency is detected, including not having registered
|
||||
* a streaming policy, then the standard system exception MARSHAL is raised.
|
||||
*/
|
||||
void read_double_array (org.omg.CORBA.DoubleSeqHolder seq, int offset, int length);
|
||||
} // interface DataInputStream
|
||||
283
jdkSrc/jdk8/org/omg/CORBA/DataOutputStream.java
Normal file
283
jdkSrc/jdk8/org/omg/CORBA/DataOutputStream.java
Normal file
@@ -0,0 +1,283 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
/** Defines the methods used to write primitive data types to output streams
|
||||
* for marshalling custom value types. This interface is used by user
|
||||
* written custom marshalling code for custom value types.
|
||||
* @see org.omg.CORBA.DataInputStream
|
||||
* @see org.omg.CORBA.CustomMarshal
|
||||
*/
|
||||
public interface DataOutputStream extends org.omg.CORBA.portable.ValueBase
|
||||
{
|
||||
/**
|
||||
* Writes the Any value to the output stream.
|
||||
* @param value The value to be written.
|
||||
*/
|
||||
void write_any (org.omg.CORBA.Any value);
|
||||
|
||||
/**
|
||||
* Writes the boolean value to the output stream.
|
||||
* @param value The value to be written.
|
||||
*/
|
||||
void write_boolean (boolean value);
|
||||
|
||||
/**
|
||||
* Writes the IDL character value to the output stream.
|
||||
* @param value The value to be written.
|
||||
*/
|
||||
void write_char (char value);
|
||||
|
||||
/**
|
||||
* Writes the IDL wide character value to the output stream.
|
||||
* @param value The value to be written.
|
||||
*/
|
||||
void write_wchar (char value);
|
||||
|
||||
/**
|
||||
* Writes the IDL octet value (represented as a Java byte) to the output stream.
|
||||
* @param value The value to be written.
|
||||
*/
|
||||
void write_octet (byte value);
|
||||
|
||||
/**
|
||||
* Writes the IDL short value to the output stream.
|
||||
* @param value The value to be written.
|
||||
*/
|
||||
void write_short (short value);
|
||||
|
||||
/**
|
||||
* Writes the IDL unsigned short value (represented as a Java short
|
||||
* value) to the output stream.
|
||||
* @param value The value to be written.
|
||||
*/
|
||||
void write_ushort (short value);
|
||||
|
||||
/**
|
||||
* Writes the IDL long value (represented as a Java int) to the output stream.
|
||||
* @param value The value to be written.
|
||||
*/
|
||||
void write_long (int value);
|
||||
|
||||
/**
|
||||
* Writes the IDL unsigned long value (represented as a Java int) to the output stream.
|
||||
* @param value The value to be written.
|
||||
*/
|
||||
void write_ulong (int value);
|
||||
|
||||
/**
|
||||
* Writes the IDL long long value (represented as a Java long) to the output stream.
|
||||
* @param value The value to be written.
|
||||
*/
|
||||
void write_longlong (long value);
|
||||
|
||||
/**
|
||||
* Writes the IDL unsigned long long value (represented as a Java long)
|
||||
* to the output stream.
|
||||
* @param value The value to be written.
|
||||
*/
|
||||
void write_ulonglong (long value);
|
||||
|
||||
/**
|
||||
* Writes the IDL float value to the output stream.
|
||||
* @param value The value to be written.
|
||||
*/
|
||||
void write_float (float value);
|
||||
|
||||
/**
|
||||
* Writes the IDL double value to the output stream.
|
||||
* @param value The value to be written.
|
||||
*/
|
||||
void write_double (double value);
|
||||
|
||||
// write_longdouble not supported by IDL/Java mapping
|
||||
|
||||
/**
|
||||
* Writes the IDL string value to the output stream.
|
||||
* @param value The value to be written.
|
||||
*/
|
||||
void write_string (String value);
|
||||
|
||||
/**
|
||||
* Writes the IDL wide string value (represented as a Java String) to the output stream.
|
||||
* @param value The value to be written.
|
||||
*/
|
||||
void write_wstring (String value);
|
||||
|
||||
/**
|
||||
* Writes the IDL CORBA::Object value to the output stream.
|
||||
* @param value The value to be written.
|
||||
*/
|
||||
void write_Object (org.omg.CORBA.Object value);
|
||||
|
||||
/**
|
||||
* Writes the IDL Abstract interface type to the output stream.
|
||||
* @param value The value to be written.
|
||||
*/
|
||||
void write_Abstract (java.lang.Object value);
|
||||
|
||||
/**
|
||||
* Writes the IDL value type value to the output stream.
|
||||
* @param value The value to be written.
|
||||
*/
|
||||
void write_Value (java.io.Serializable value);
|
||||
|
||||
/**
|
||||
* Writes the typecode to the output stream.
|
||||
* @param value The value to be written.
|
||||
*/
|
||||
void write_TypeCode (org.omg.CORBA.TypeCode value);
|
||||
|
||||
/**
|
||||
* Writes the array of IDL Anys from offset for length elements to the
|
||||
* output stream.
|
||||
* @param seq The array to be written.
|
||||
* @param offset The index into seq of the first element to write to the
|
||||
* output stream.
|
||||
* @param length The number of elements to write to the output stream.
|
||||
*/
|
||||
void write_any_array (org.omg.CORBA.Any[] seq, int offset, int length);
|
||||
|
||||
/**
|
||||
* Writes the array of IDL booleans from offset for length elements to the
|
||||
* output stream.
|
||||
* @param seq The array to be written.
|
||||
* @param offset The index into seq of the first element to write to the
|
||||
* output stream.
|
||||
* @param length The number of elements to write to the output stream.
|
||||
*/
|
||||
void write_boolean_array (boolean[] seq, int offset, int length);
|
||||
|
||||
/**
|
||||
* Writes the array of IDL characters from offset for length elements to the
|
||||
* output stream.
|
||||
* @param seq The array to be written.
|
||||
* @param offset The index into seq of the first element to write to the
|
||||
* output stream.
|
||||
* @param length The number of elements to write to the output stream.
|
||||
*/
|
||||
void write_char_array (char[] seq, int offset, int length);
|
||||
|
||||
/**
|
||||
* Writes the array of IDL wide characters from offset for length elements to the
|
||||
* output stream.
|
||||
* @param seq The array to be written.
|
||||
* @param offset The index into seq of the first element to write to the
|
||||
* output stream.
|
||||
* @param length The number of elements to write to the output stream.
|
||||
*/
|
||||
void write_wchar_array (char[] seq, int offset, int length);
|
||||
|
||||
/**
|
||||
* Writes the array of IDL octets from offset for length elements to the
|
||||
* output stream.
|
||||
* @param seq The array to be written.
|
||||
* @param offset The index into seq of the first element to write to the
|
||||
* output stream.
|
||||
* @param length The number of elements to write to the output stream.
|
||||
*/
|
||||
void write_octet_array (byte[] seq, int offset, int length);
|
||||
|
||||
/**
|
||||
* Writes the array of IDL shorts from offset for length elements to the
|
||||
* output stream.
|
||||
* @param seq The array to be written.
|
||||
* @param offset The index into seq of the first element to write to the
|
||||
* output stream.
|
||||
* @param length The number of elements to write to the output stream.
|
||||
*/
|
||||
void write_short_array (short[] seq, int offset, int length);
|
||||
|
||||
/**
|
||||
* Writes the array of IDL unsigned shorts (represented as Java shorts)
|
||||
* from offset for length elements to the output stream.
|
||||
* @param seq The array to be written.
|
||||
* @param offset The index into seq of the first element to write to the
|
||||
* output stream.
|
||||
* @param length The number of elements to write to the output stream.
|
||||
*/
|
||||
void write_ushort_array (short[] seq, int offset, int length);
|
||||
|
||||
/**
|
||||
* Writes the array of IDL longs from offset for length elements to the
|
||||
* output stream.
|
||||
* @param seq The array to be written.
|
||||
* @param offset The index into seq of the first element to write to the
|
||||
* output stream.
|
||||
* @param length The number of elements to write to the output stream.
|
||||
*/
|
||||
void write_long_array (int[] seq, int offset, int length);
|
||||
|
||||
/**
|
||||
* Writes the array of IDL unsigned longs (represented as Java ints)
|
||||
* from offset for length elements to the output stream.
|
||||
* @param seq The array to be written.
|
||||
* @param offset The index into seq of the first element to write to the
|
||||
* output stream.
|
||||
* @param length The number of elements to write to the output stream.
|
||||
*/
|
||||
void write_ulong_array (int[] seq, int offset, int length);
|
||||
|
||||
/**
|
||||
* Writes the array of IDL unsigned long longs (represented as Java longs)
|
||||
* from offset for length elements to the output stream.
|
||||
* @param seq The array to be written.
|
||||
* @param offset The index into seq of the first element to write to the
|
||||
* output stream.
|
||||
* @param length The number of elements to write to the output stream.
|
||||
*/
|
||||
void write_ulonglong_array (long[] seq, int offset, int length);
|
||||
|
||||
/**
|
||||
* Writes the array of IDL long longs from offset for length elements to the
|
||||
* output stream.
|
||||
* @param seq The array to be written.
|
||||
* @param offset The index into seq of the first element to write to the
|
||||
* output stream.
|
||||
* @param length The number of elements to write to the output stream.
|
||||
*/
|
||||
void write_longlong_array (long[] seq, int offset, int length);
|
||||
|
||||
/**
|
||||
* Writes the array of IDL floats from offset for length elements to the
|
||||
* output stream.
|
||||
* @param seq The array to be written.
|
||||
* @param offset The index into seq of the first element to write to the
|
||||
* output stream.
|
||||
* @param length The number of elements to write to the output stream.
|
||||
*/
|
||||
void write_float_array (float[] seq, int offset, int length);
|
||||
|
||||
/**
|
||||
* Writes the array of IDL doubles from offset for length elements to the
|
||||
* output stream.
|
||||
* @param seq The array to be written.
|
||||
* @param offset The index into seq of the first element to write to the
|
||||
* output stream.
|
||||
* @param length The number of elements to write to the output stream.
|
||||
*/
|
||||
void write_double_array (double[] seq, int offset, int length);
|
||||
} // interface DataOutputStream
|
||||
501
jdkSrc/jdk8/org/omg/CORBA/DefinitionKind.java
Normal file
501
jdkSrc/jdk8/org/omg/CORBA/DefinitionKind.java
Normal file
@@ -0,0 +1,501 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* File: ./org/omg/CORBA/DefinitionKind.java
|
||||
* From: ./ir.idl
|
||||
* Date: Fri Aug 28 16:03:31 1998
|
||||
* By: idltojava Java IDL 1.2 Aug 11 1998 02:00:18
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
/**
|
||||
* The class that provides the constants used to identify the type of an
|
||||
* Interface Repository object. This class contains two kinds of constants,
|
||||
* those that are an <code>int</code> and those that are an instance of the class
|
||||
* <code>DefinitionKind</code>. This class provides the method
|
||||
* <code>from_int</code>, which given one
|
||||
* of the <code>int</code> constants, creates the corresponding
|
||||
* <code>DefinitionKind</code> instance. It also provides the method
|
||||
* <code>value</code>, which returns the <code>int</code> constant that
|
||||
* is the value for a <code>DefinitionKind</code> instance.
|
||||
*
|
||||
* @see IRObject
|
||||
*/
|
||||
|
||||
public class DefinitionKind implements org.omg.CORBA.portable.IDLEntity {
|
||||
|
||||
/**
|
||||
* The constant that indicates that an Interface Repository object
|
||||
* does not have a definition kind.
|
||||
*/
|
||||
public static final int _dk_none = 0,
|
||||
|
||||
/**
|
||||
* The constant that indicates that the type of an Interface Repository object
|
||||
* may be any type.
|
||||
*/
|
||||
_dk_all = 1,
|
||||
|
||||
/**
|
||||
* The constant that indicates that an Interface Repository object is an
|
||||
* attribute.
|
||||
*/
|
||||
_dk_Attribute = 2,
|
||||
|
||||
/**
|
||||
* The constant that indicates that an Interface Repository object is a
|
||||
* constant.
|
||||
*/
|
||||
_dk_Constant = 3,
|
||||
|
||||
/**
|
||||
* The constant that indicates that an Interface Repository object is an
|
||||
* exception.
|
||||
*/
|
||||
|
||||
_dk_Exception = 4,
|
||||
|
||||
/**
|
||||
* The constant that indicates that an Interface Repository object is an
|
||||
* interface.
|
||||
*/
|
||||
|
||||
_dk_Interface = 5,
|
||||
|
||||
/**
|
||||
* The constant that indicates that an Interface Repository object is a
|
||||
* module.
|
||||
*/
|
||||
|
||||
_dk_Module = 6,
|
||||
|
||||
/**
|
||||
* The constant that indicates that an Interface Repository object is an
|
||||
* operation.
|
||||
*/
|
||||
|
||||
_dk_Operation = 7,
|
||||
|
||||
/**
|
||||
* The constant that indicates that an Interface Repository object is a
|
||||
* Typedef.
|
||||
*/
|
||||
|
||||
_dk_Typedef = 8,
|
||||
|
||||
/**
|
||||
* The constant that indicates that an Interface Repository object is an
|
||||
* Alias.
|
||||
*/
|
||||
|
||||
_dk_Alias = 9,
|
||||
|
||||
/**
|
||||
* The constant that indicates that an Interface Repository object is a
|
||||
* Struct.
|
||||
*/
|
||||
|
||||
_dk_Struct = 10,
|
||||
|
||||
/**
|
||||
* The constant that indicates that an Interface Repository object is a
|
||||
* Union.
|
||||
*/
|
||||
|
||||
_dk_Union = 11,
|
||||
|
||||
/**
|
||||
* The constant that indicates that an Interface Repository object is an
|
||||
* Enum.
|
||||
*/
|
||||
|
||||
_dk_Enum = 12,
|
||||
|
||||
/**
|
||||
* The constant that indicates that an Interface Repository object is a
|
||||
* Primitive.
|
||||
*/
|
||||
|
||||
_dk_Primitive = 13,
|
||||
|
||||
/**
|
||||
* The constant that indicates that an Interface Repository object is a
|
||||
* String.
|
||||
*/
|
||||
|
||||
_dk_String = 14,
|
||||
|
||||
/**
|
||||
* The constant that indicates that an Interface Repository object is a
|
||||
* Sequence.
|
||||
*/
|
||||
|
||||
_dk_Sequence = 15,
|
||||
|
||||
/**
|
||||
* The constant that indicates that an Interface Repository object is an
|
||||
* Array.
|
||||
*/
|
||||
|
||||
_dk_Array = 16,
|
||||
|
||||
/**
|
||||
* The constant that indicates that an Interface Repository object is a
|
||||
* Repository.
|
||||
*/
|
||||
|
||||
_dk_Repository = 17,
|
||||
|
||||
/**
|
||||
* The constant that indicates that an Interface Repository object is a
|
||||
* Wstring.
|
||||
*/
|
||||
|
||||
_dk_Wstring = 18,
|
||||
|
||||
/**
|
||||
* The constant that indicates that an Interface Repository object is of type
|
||||
* Fixed.
|
||||
*/
|
||||
|
||||
_dk_Fixed = 19,
|
||||
|
||||
/**
|
||||
* The constant that indicates that an Interface Repository object is a
|
||||
* Value.
|
||||
*/
|
||||
|
||||
_dk_Value = 20,
|
||||
|
||||
/**
|
||||
* The constant that indicates that an Interface Repository object is a
|
||||
* ValueBox.
|
||||
*/
|
||||
|
||||
_dk_ValueBox = 21,
|
||||
|
||||
/**
|
||||
* The constant that indicates that an Interface Repository object is a
|
||||
* ValueMember.
|
||||
*/
|
||||
|
||||
_dk_ValueMember = 22,
|
||||
|
||||
/**
|
||||
* The constant that indicates that an Interface Repository object is of type
|
||||
* Native.
|
||||
*/
|
||||
|
||||
_dk_Native = 23,
|
||||
|
||||
/**
|
||||
* The constant that indicates that an Interface Repository object
|
||||
* is representing an abstract interface.
|
||||
*/
|
||||
_dk_AbstractInterface = 24;
|
||||
|
||||
/**
|
||||
* The static instance of <code>DefinitionKind</code> indicating that an
|
||||
* Interface Repository object has no definition kind.
|
||||
*/
|
||||
|
||||
public static final DefinitionKind dk_none = new DefinitionKind(_dk_none);
|
||||
|
||||
/**
|
||||
* The wildcard <code>DefinitionKind</code> constant, useful
|
||||
* in all occasions where any
|
||||
* <code>DefinitionKind</code> is appropriate. The Container's
|
||||
* <code>contents</code> method
|
||||
* makes use of this constant to return all contained definitions of any kind.
|
||||
*/
|
||||
|
||||
public static final DefinitionKind dk_all = new DefinitionKind(_dk_all);
|
||||
|
||||
/**
|
||||
* The static instance of <code>DefinitionKind</code> indicating that an
|
||||
* Interface Repository object is an Attribute.
|
||||
*/
|
||||
|
||||
public static final DefinitionKind dk_Attribute = new DefinitionKind(_dk_Attribute);
|
||||
|
||||
/**
|
||||
* The static instance of <code>DefinitionKind</code> indicating that an
|
||||
* Interface Repository object is a constant.
|
||||
*/
|
||||
|
||||
public static final DefinitionKind dk_Constant = new DefinitionKind(_dk_Constant);
|
||||
|
||||
|
||||
/**
|
||||
* The static instance of <code>DefinitionKind</code> indicating that an
|
||||
* Interface Repository object is an Exception.
|
||||
*/
|
||||
|
||||
public static final DefinitionKind dk_Exception = new DefinitionKind(_dk_Exception);
|
||||
|
||||
/**
|
||||
* The static instance of <code>DefinitionKind</code> indicating that an
|
||||
* Interface Repository object is an Interface.
|
||||
*/
|
||||
|
||||
public static final DefinitionKind dk_Interface = new DefinitionKind(_dk_Interface);
|
||||
|
||||
/**
|
||||
* The static instance of <code>DefinitionKind</code> indicating that an
|
||||
* Interface Repository object is a Module.
|
||||
*/
|
||||
|
||||
public static final DefinitionKind dk_Module = new DefinitionKind(_dk_Module);
|
||||
|
||||
/**
|
||||
* The static instance of <code>DefinitionKind</code> indicating that an
|
||||
* Interface Repository object is an Operation.
|
||||
*/
|
||||
|
||||
public static final DefinitionKind dk_Operation = new DefinitionKind(_dk_Operation);
|
||||
|
||||
/**
|
||||
* The static instance of <code>DefinitionKind</code> indicating that an
|
||||
* Interface Repository object is a Typedef.
|
||||
*/
|
||||
|
||||
public static final DefinitionKind dk_Typedef = new DefinitionKind(_dk_Typedef);
|
||||
|
||||
/**
|
||||
* The static instance of <code>DefinitionKind</code> indicating that an
|
||||
* Interface Repository object is an Alias.
|
||||
*/
|
||||
|
||||
public static final DefinitionKind dk_Alias = new DefinitionKind(_dk_Alias);
|
||||
|
||||
/**
|
||||
* The static instance of <code>DefinitionKind</code> indicating that an
|
||||
* Interface Repository object is a Struct.
|
||||
*/
|
||||
|
||||
public static final DefinitionKind dk_Struct = new DefinitionKind(_dk_Struct);
|
||||
|
||||
/**
|
||||
* The static instance of <code>DefinitionKind</code> indicating that an
|
||||
* Interface Repository object is a Union.
|
||||
*/
|
||||
|
||||
public static final DefinitionKind dk_Union = new DefinitionKind(_dk_Union);
|
||||
|
||||
/**
|
||||
* The static instance of <code>DefinitionKind</code> indicating that an
|
||||
* Interface Repository object is an Enum.
|
||||
*/
|
||||
|
||||
public static final DefinitionKind dk_Enum = new DefinitionKind(_dk_Enum);
|
||||
|
||||
/**
|
||||
* The static instance of <code>DefinitionKind</code> indicating that an
|
||||
* Interface Repository object is a Primitive.
|
||||
*/
|
||||
|
||||
public static final DefinitionKind dk_Primitive = new DefinitionKind(_dk_Primitive);
|
||||
|
||||
/**
|
||||
* The static instance of <code>DefinitionKind</code> indicating that an
|
||||
* Interface Repository object is a String.
|
||||
*/
|
||||
|
||||
public static final DefinitionKind dk_String = new DefinitionKind(_dk_String);
|
||||
|
||||
/**
|
||||
* The static instance of <code>DefinitionKind</code> indicating that an
|
||||
* Interface Repository object is a Sequence.
|
||||
*/
|
||||
|
||||
public static final DefinitionKind dk_Sequence = new DefinitionKind(_dk_Sequence);
|
||||
|
||||
/**
|
||||
* The static instance of <code>DefinitionKind</code> indicating that an
|
||||
* Interface Repository object is an Array.
|
||||
*/
|
||||
|
||||
public static final DefinitionKind dk_Array = new DefinitionKind(_dk_Array);
|
||||
|
||||
|
||||
/**
|
||||
* The static instance of <code>DefinitionKind</code> indicating that an
|
||||
* Interface Repository object is a Repository.
|
||||
*/
|
||||
|
||||
public static final DefinitionKind dk_Repository = new DefinitionKind(_dk_Repository);
|
||||
|
||||
|
||||
/**
|
||||
* The static instance of <code>DefinitionKind</code> indicating that an
|
||||
* Interface Repository object is a Wstring.
|
||||
*/
|
||||
|
||||
public static final DefinitionKind dk_Wstring = new DefinitionKind(_dk_Wstring);
|
||||
|
||||
/**
|
||||
* The static instance of <code>DefinitionKind</code> indicating that an
|
||||
* Interface Repository object is a Fixed value.
|
||||
*/
|
||||
|
||||
public static final DefinitionKind dk_Fixed = new DefinitionKind(_dk_Fixed);
|
||||
|
||||
/**
|
||||
* The static instance of <code>DefinitionKind</code> indicating that an
|
||||
* Interface Repository object is a Value.
|
||||
*/
|
||||
|
||||
public static final DefinitionKind dk_Value = new DefinitionKind(_dk_Value);
|
||||
|
||||
/**
|
||||
* The static instance of <code>DefinitionKind</code> indicating that an
|
||||
* Interface Repository object is a ValueBox.
|
||||
*/
|
||||
|
||||
public static final DefinitionKind dk_ValueBox = new DefinitionKind(_dk_ValueBox);
|
||||
|
||||
/**
|
||||
* The static instance of <code>DefinitionKind</code> indicating that an
|
||||
* Interface Repository object is a ValueMember.
|
||||
*/
|
||||
|
||||
public static final DefinitionKind dk_ValueMember = new DefinitionKind(_dk_ValueMember);
|
||||
|
||||
|
||||
/**
|
||||
* The static instance of <code>DefinitionKind</code> indicating that an
|
||||
* Interface Repository object is a Native value.
|
||||
*/
|
||||
|
||||
public static final DefinitionKind dk_Native = new DefinitionKind(_dk_Native);
|
||||
|
||||
|
||||
/**
|
||||
* The static instance of <code>DefinitionKind</code> indicating that an
|
||||
* Interface Repository object represents an abstract interface.
|
||||
*/
|
||||
public static final DefinitionKind dk_AbstractInterface = new DefinitionKind(_dk_AbstractInterface);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the <code>int</code> constant identifying the type of an IR object.
|
||||
* @return the <code>int</code> constant from the class
|
||||
* <code>DefinitionKind</code> that is the value of this
|
||||
* <code>DefinitionKind</code> instance
|
||||
*/
|
||||
|
||||
public int value() {
|
||||
return _value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a <code>DefinitionKind</code> instance corresponding to the given code
|
||||
.
|
||||
* @param i one of the <code>int</code> constants from the class
|
||||
* <code>DefinitionKind</code>
|
||||
* @return the <code>DefinitionKind</code> instance corresponding
|
||||
* to the given code
|
||||
* @throws org.omg.CORBA.BAD_PARAM if the given parameter is not
|
||||
one
|
||||
* of the <code>int</code> constants from the class
|
||||
* <code>DefinitionKind</code>
|
||||
*/
|
||||
|
||||
public static DefinitionKind from_int(int i) {
|
||||
switch (i) {
|
||||
case _dk_none:
|
||||
return dk_none;
|
||||
case _dk_all:
|
||||
return dk_all;
|
||||
case _dk_Attribute:
|
||||
return dk_Attribute;
|
||||
case _dk_Constant:
|
||||
return dk_Constant;
|
||||
case _dk_Exception:
|
||||
return dk_Exception;
|
||||
case _dk_Interface:
|
||||
return dk_Interface;
|
||||
case _dk_Module:
|
||||
return dk_Module;
|
||||
case _dk_Operation:
|
||||
return dk_Operation;
|
||||
case _dk_Typedef:
|
||||
return dk_Typedef;
|
||||
case _dk_Alias:
|
||||
return dk_Alias;
|
||||
case _dk_Struct:
|
||||
return dk_Struct;
|
||||
case _dk_Union:
|
||||
return dk_Union;
|
||||
case _dk_Enum:
|
||||
return dk_Enum;
|
||||
case _dk_Primitive:
|
||||
return dk_Primitive;
|
||||
case _dk_String:
|
||||
return dk_String;
|
||||
case _dk_Sequence:
|
||||
return dk_Sequence;
|
||||
case _dk_Array:
|
||||
return dk_Array;
|
||||
case _dk_Repository:
|
||||
return dk_Repository;
|
||||
case _dk_Wstring:
|
||||
return dk_Wstring;
|
||||
case _dk_Fixed:
|
||||
return dk_Fixed;
|
||||
case _dk_Value:
|
||||
return dk_Value;
|
||||
case _dk_ValueBox:
|
||||
return dk_ValueBox;
|
||||
case _dk_ValueMember:
|
||||
return dk_ValueMember;
|
||||
case _dk_Native:
|
||||
return dk_Native;
|
||||
default:
|
||||
throw new org.omg.CORBA.BAD_PARAM();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>DefinitionKind</code> object with its <code>_value</code>
|
||||
* field initialized with the given value.
|
||||
* @param _value one of the <code>int</code> constants defined in the
|
||||
* class <code>DefinitionKind</code>
|
||||
*/
|
||||
|
||||
protected DefinitionKind(int _value){
|
||||
this._value = _value;
|
||||
}
|
||||
|
||||
/**
|
||||
* The field that holds a value for a <code>DefinitionKind</code> object.
|
||||
* @serial
|
||||
*/
|
||||
|
||||
private int _value;
|
||||
}
|
||||
80
jdkSrc/jdk8/org/omg/CORBA/DefinitionKindHelper.java
Normal file
80
jdkSrc/jdk8/org/omg/CORBA/DefinitionKindHelper.java
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.omg.CORBA;
|
||||
|
||||
|
||||
/**
|
||||
* The Helper for <tt>DefinitionKind</tt>. For more information on
|
||||
* Helper files, see <a href="doc-files/generatedfiles.html#helper">
|
||||
* "Generated Files: Helper Files"</a>.<P>
|
||||
* org/omg/CORBA/DefinitionKindHelper.java
|
||||
* Generated by the IDL-to-Java compiler (portable), version "3.0"
|
||||
* from ir.idl
|
||||
* 03 June 1999 11:33:43 o'clock GMT+00:00
|
||||
*/
|
||||
|
||||
abstract public class DefinitionKindHelper
|
||||
{
|
||||
private static String _id = "IDL:omg.org/CORBA/DefinitionKind:1.0";
|
||||
|
||||
public static void insert (org.omg.CORBA.Any a, org.omg.CORBA.DefinitionKind that)
|
||||
{
|
||||
org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
|
||||
a.type (type ());
|
||||
write (out, that);
|
||||
a.read_value (out.create_input_stream (), type ());
|
||||
}
|
||||
|
||||
public static org.omg.CORBA.DefinitionKind extract (org.omg.CORBA.Any a)
|
||||
{
|
||||
return read (a.create_input_stream ());
|
||||
}
|
||||
|
||||
private static org.omg.CORBA.TypeCode __typeCode = null;
|
||||
synchronized public static org.omg.CORBA.TypeCode type ()
|
||||
{
|
||||
if (__typeCode == null)
|
||||
{
|
||||
__typeCode = org.omg.CORBA.ORB.init ().create_enum_tc (org.omg.CORBA.DefinitionKindHelper.id (), "DefinitionKind", new String[] { "dk_none", "dk_all", "dk_Attribute", "dk_Constant", "dk_Exception", "dk_Interface", "dk_Module", "dk_Operation", "dk_Typedef", "dk_Alias", "dk_Struct", "dk_Union", "dk_Enum", "dk_Primitive", "dk_String", "dk_Sequence", "dk_Array", "dk_Repository", "dk_Wstring", "dk_Fixed", "dk_Value", "dk_ValueBox", "dk_ValueMember", "dk_Native"} );
|
||||
}
|
||||
return __typeCode;
|
||||
}
|
||||
|
||||
public static String id ()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public static org.omg.CORBA.DefinitionKind read (org.omg.CORBA.portable.InputStream istream)
|
||||
{
|
||||
return org.omg.CORBA.DefinitionKind.from_int (istream.read_long ());
|
||||
}
|
||||
|
||||
public static void write (org.omg.CORBA.portable.OutputStream ostream, org.omg.CORBA.DefinitionKind value)
|
||||
{
|
||||
ostream.write_long (value.value ());
|
||||
}
|
||||
|
||||
}
|
||||
43
jdkSrc/jdk8/org/omg/CORBA/DomainManager.java
Normal file
43
jdkSrc/jdk8/org/omg/CORBA/DomainManager.java
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
/** Provides mechanisms for establishing and navigating relationships to
|
||||
* superior and subordinate domains, as well as for creating and accessing
|
||||
* policies. The <tt>DomainManager</tt> has associated with it the policy
|
||||
* objects for a
|
||||
* particular domain. The domain manager also records the membership of
|
||||
* the domain and provides the means to add and remove members. The domain
|
||||
* manager is itself a member of a domain, possibly the domain it manages.
|
||||
* The domain manager provides mechanisms for establishing and navigating
|
||||
* relationships to superior and subordinate domains and
|
||||
* creating and accessing policies.
|
||||
*/
|
||||
|
||||
public interface DomainManager extends DomainManagerOperations,
|
||||
org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity
|
||||
{
|
||||
}
|
||||
49
jdkSrc/jdk8/org/omg/CORBA/DomainManagerOperations.java
Normal file
49
jdkSrc/jdk8/org/omg/CORBA/DomainManagerOperations.java
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
/**
|
||||
* Provides the <tt>DomainManager</tt> with the means to access policies.
|
||||
* <P>
|
||||
* The <tt>DomainManager</tt> has associated with it the policy objects for a
|
||||
* particular domain. The domain manager also records the membership of
|
||||
* the domain and provides the means to add and remove members. The domain
|
||||
* manager is itself a member of a domain, possibly the domain it manages.
|
||||
* The domain manager provides mechanisms for establishing and navigating
|
||||
* relationships to superior and subordinate domains and
|
||||
* creating and accessing policies.
|
||||
*/
|
||||
|
||||
public interface DomainManagerOperations
|
||||
{
|
||||
/** This returns the policy of the specified type for objects in
|
||||
* this domain. The types of policies available are domain specific.
|
||||
* See the CORBA specification for a list of standard ORB policies.
|
||||
*
|
||||
*@param policy_type Type of policy to request
|
||||
*/
|
||||
public org.omg.CORBA.Policy get_domain_policy(int policy_type);
|
||||
}
|
||||
109
jdkSrc/jdk8/org/omg/CORBA/DoubleHolder.java
Normal file
109
jdkSrc/jdk8/org/omg/CORBA/DoubleHolder.java
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.omg.CORBA;
|
||||
|
||||
import org.omg.CORBA.portable.Streamable;
|
||||
import org.omg.CORBA.portable.InputStream;
|
||||
import org.omg.CORBA.portable.OutputStream;
|
||||
|
||||
/**
|
||||
* The Holder for <tt>Double</tt>. For more information on
|
||||
* Holder files, see <a href="doc-files/generatedfiles.html#holder">
|
||||
* "Generated Files: Holder Files"</a>.<P>
|
||||
* A Holder class for a <code>double</code>
|
||||
* that is used to store "out" and "inout" parameters in IDL methods.
|
||||
* If an IDL method signature has an IDL <code>double</code> as an "out"
|
||||
* or "inout" parameter, the programmer must pass an instance of
|
||||
* <code>DoubleHolder</code> as the corresponding
|
||||
* parameter in the method invocation; for "inout" parameters, the programmer
|
||||
* must also fill the "in" value to be sent to the server.
|
||||
* Before the method invocation returns, the ORB will fill in the
|
||||
* value corresponding to the "out" value returned from the server.
|
||||
* <P>
|
||||
* If <code>myDoubleHolder</code> is an instance of <code>DoubleHolder</code>,
|
||||
* the value stored in its <code>value</code> field can be accessed with
|
||||
* <code>myDoubleHolder.value</code>.
|
||||
*
|
||||
* @since JDK1.2
|
||||
*/
|
||||
public final class DoubleHolder implements Streamable {
|
||||
|
||||
/**
|
||||
* The <code>double</code> value held by this <code>DoubleHolder</code>
|
||||
* object.
|
||||
*/
|
||||
|
||||
public double value;
|
||||
|
||||
/**
|
||||
* Constructs a new <code>DoubleHolder</code> object with its
|
||||
* <code>value</code> field initialized to 0.0.
|
||||
*/
|
||||
public DoubleHolder() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <code>DoubleHolder</code> object for the given
|
||||
* <code>double</code>.
|
||||
* @param initial the <code>double</code> with which to initialize
|
||||
* the <code>value</code> field of the new
|
||||
* <code>DoubleHolder</code> object
|
||||
*/
|
||||
public DoubleHolder(double initial) {
|
||||
value = initial;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a double value from the input stream and store it in the
|
||||
* value member.
|
||||
*
|
||||
* @param input the <code>InputStream</code> to read from.
|
||||
*/
|
||||
public void _read(InputStream input) {
|
||||
value = input.read_double();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the double value stored in this holder to an
|
||||
* <code>OutputStream</code>.
|
||||
*
|
||||
* @param output the <code>OutputStream</code> to write into.
|
||||
*/
|
||||
public void _write(OutputStream output) {
|
||||
output.write_double(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the <code>TypeCode</code> of this holder object.
|
||||
*
|
||||
* @return the <code>TypeCode</code> object.
|
||||
*/
|
||||
public org.omg.CORBA.TypeCode _type() {
|
||||
return ORB.init().get_primitive_tc(TCKind.tk_double);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user