0N/A/*
0N/A * reserved comment block
0N/A * DO NOT REMOVE OR ALTER!
0N/A */
0N/A/*
0N/A * Copyright 1999-2005 The Apache Software Foundation.
0N/A *
0N/A * Licensed under the Apache License, Version 2.0 (the "License");
0N/A * you may not use this file except in compliance with the License.
0N/A * You may obtain a copy of the License at
0N/A *
0N/A * http://www.apache.org/licenses/LICENSE-2.0
0N/A *
0N/A * Unless required by applicable law or agreed to in writing, software
0N/A * distributed under the License is distributed on an "AS IS" BASIS,
0N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0N/A * See the License for the specific language governing permissions and
0N/A * limitations under the License.
0N/A *
0N/A */
0N/A/*
2362N/A * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
661N/A */
661N/A/*
661N/A * $Id: SignerOutputStream.java,v 1.2 2008/07/24 15:20:31 mullan Exp $
0N/A */
0N/Apackage org.jcp.xml.dsig.internal;
0N/A
0N/Aimport java.io.ByteArrayOutputStream;
0N/Aimport java.security.Signature;
0N/Aimport java.security.SignatureException;
0N/A
0N/A/**
0N/A * Derived from Apache sources and changed to use java.security.Signature
661N/A * objects as input instead of com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithm
0N/A * objects.
0N/A *
0N/A * @author raul
661N/A * @author Sean Mullan
0N/A */
0N/Apublic class SignerOutputStream extends ByteArrayOutputStream {
0N/A private final Signature sig;
0N/A
0N/A public SignerOutputStream(Signature sig) {
0N/A this.sig=sig;
0N/A }
0N/A
0N/A /** @inheritDoc */
0N/A public void write(byte[] arg0) {
0N/A super.write(arg0, 0, arg0.length);
0N/A try {
0N/A sig.update(arg0);
0N/A } catch (SignatureException e) {
0N/A throw new RuntimeException(""+e);
0N/A }
0N/A }
0N/A
0N/A /** @inheritDoc */
0N/A public void write(int arg0) {
0N/A super.write(arg0);
0N/A try {
0N/A sig.update((byte)arg0);
0N/A } catch (SignatureException e) {
0N/A throw new RuntimeException(""+e);
0N/A }
0N/A }
0N/A
0N/A /** @inheritDoc */
0N/A public void write(byte[] arg0, int arg1, int arg2) {
0N/A super.write(arg0, arg1, arg2);
0N/A try {
0N/A sig.update(arg0,arg1,arg2);
0N/A } catch (SignatureException e) {
0N/A throw new RuntimeException(""+e);
0N/A }
0N/A }
0N/A}