You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oltu.apache.org by si...@apache.org on 2010/07/11 10:48:38 UTC
svn commit: r963016 - in
/incubator/amber/trunk/signature-api/src/main/java/org/apache/amber/signature/rsa:
./ AbstractRsaSha1Key.java
Author: simonetripodi
Date: Sun Jul 11 08:48:38 2010
New Revision: 963016
URL: http://svn.apache.org/viewvc?rev=963016&view=rev
Log:
first checkin of AbstractRsaSha1Key class
Added:
incubator/amber/trunk/signature-api/src/main/java/org/apache/amber/signature/rsa/
incubator/amber/trunk/signature-api/src/main/java/org/apache/amber/signature/rsa/AbstractRsaSha1Key.java (with props)
Added: incubator/amber/trunk/signature-api/src/main/java/org/apache/amber/signature/rsa/AbstractRsaSha1Key.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/signature-api/src/main/java/org/apache/amber/signature/rsa/AbstractRsaSha1Key.java?rev=963016&view=auto
==============================================================================
--- incubator/amber/trunk/signature-api/src/main/java/org/apache/amber/signature/rsa/AbstractRsaSha1Key.java (added)
+++ incubator/amber/trunk/signature-api/src/main/java/org/apache/amber/signature/rsa/AbstractRsaSha1Key.java Sun Jul 11 08:48:38 2010
@@ -0,0 +1,88 @@
+/*
+ * 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.apache.amber.signature.rsa;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.apache.amber.signature.Key;
+import org.apache.amber.signature.SignatureException;
+
+/**
+ * Abstract implementation of RSA-SHA1 key.
+ *
+ * @version $Id$
+ */
+abstract class AbstractRsaSha1Key implements Key {
+
+ private static final String[] METHODS = { "RSA-SHA1" };
+
+ private final byte[] byteValue;
+
+ public AbstractRsaSha1Key(String certificateClasspathLocation) throws SignatureException {
+ this(Thread.currentThread().getContextClassLoader().getResource(certificateClasspathLocation));
+ }
+
+ public AbstractRsaSha1Key(URL certificateURL) throws SignatureException {
+ if (certificateURL == null) {
+ throw new SignatureException("parameter 'certificateURL' must not be null");
+ }
+
+ URLConnection urlConnection = null;
+ InputStream input = null;
+
+ try {
+ urlConnection = certificateURL.openConnection();
+ input = urlConnection.getInputStream();
+
+ this.byteValue = this.readCertificate(input);
+ } catch (Exception e) {
+ throw new SignatureException("Impossible to read the certificate from '"
+ + certificateURL
+ + "' URL", e);
+ } finally {
+ if (urlConnection != null && urlConnection instanceof HttpURLConnection) {
+ ((HttpURLConnection) urlConnection).disconnect();
+ }
+
+ if (input != null) {
+ try {
+ input.close();
+ } catch (IOException e) {
+ // close quietly
+ }
+ }
+ }
+ }
+
+ public final byte[] getByteValue() {
+ return this.byteValue;
+ }
+
+ protected abstract byte[] readCertificate(InputStream input) throws Exception;
+
+ /**
+ * {@inheritDoc}
+ */
+ public final String[] getAlgorithmMethods() {
+ return METHODS;
+ }
+
+}
Propchange: incubator/amber/trunk/signature-api/src/main/java/org/apache/amber/signature/rsa/AbstractRsaSha1Key.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/amber/trunk/signature-api/src/main/java/org/apache/amber/signature/rsa/AbstractRsaSha1Key.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: incubator/amber/trunk/signature-api/src/main/java/org/apache/amber/signature/rsa/AbstractRsaSha1Key.java
------------------------------------------------------------------------------
svn:mime-type = text/plain