juddi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jfa...@apache.org
Subject svn commit: r709604 [2/2] - in /webservices/juddi/branches/v3_trunk/juddi-core/src/main: java/org/apache/juddi/api/impl/ java/org/apache/juddi/auth/ java/org/apache/juddi/config/ java/org/apache/juddi/cryptor/ java/org/apache/juddi/error/ java/org/apac...
Date Fri, 31 Oct 2008 23:54:23 GMT
Propchange: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/uuidgen/UUIDGen.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/uuidgen/UUIDGenFactory.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/uuidgen/UUIDGenFactory.java?rev=709604&view=auto
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/uuidgen/UUIDGenFactory.java
(added)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/uuidgen/UUIDGenFactory.java
Fri Oct 31 16:54:22 2008
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2001-2008 The Apache Software Foundation.
+ * 
+ * Licensed 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.juddi.uuidgen;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.juddi.config.AppConfig;
+import org.apache.juddi.config.Property;
+import org.apache.juddi.util.Loader;
+import org.apache.log4j.Logger;
+
+/**
+ * Used to create the org.apache.juddi.uuidgen.UUIDGen implementation
+ * as specified by the 'juddi.uuidgen.impl' property. Defaults to
+ * org.apache.juddi.uuidgen.SecureUUIDGen if an implementation is not
+ * specified.
+ *
+ * @author Steve Viens (sviens@apache.org)
+ * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
+ */
+public abstract class UUIDGenFactory {
+	private static Logger log = Logger.getLogger(UUIDGenFactory.class);
+
+	// UUIDGen default implementation
+	private static final String DEFAULT_IMPL = "org.apache.juddi.uuidgen.DefaultUUIDGen";
+
+	// the shared UUIDGen instance
+	private static UUIDGen uuidgen = null;
+
+	/*
+	 * Returns a new instance of a UUIDGenFactory.
+	 * 
+	 * @return UUIDGen
+	 */
+	public static UUIDGen getUUIDGen() {
+		if (uuidgen == null)
+			uuidgen = createUUIDGen();
+		return uuidgen;
+	}
+
+  /**
+   * Returns a new instance of a UUIDGen.
+   *
+   * @return UUIDGen
+   */
+
+	
+	private static synchronized UUIDGen createUUIDGen() {
+		if (uuidgen != null)
+			return uuidgen;
+
+		// grab class name of the UUIDGen implementation to create
+		String className = DEFAULT_IMPL;
+		try {
+			// grab class name of the Authenticator implementation to create
+			className = AppConfig.getConfiguration().getString(Property.JUDDI_UUID_GENERATOR, DEFAULT_IMPL);
+		}
+		catch(ConfigurationException ce) {
+			log.error("Configuration exception occurred retrieving: " + Property.JUDDI_UUID_GENERATOR);
+		}
+
+		
+		// write the UUIDGen implementation name to the log
+		log.debug("UUIDGen Implementation = " + className);
+
+		Class<?> uuidgenClass = null;
+		try {
+			// Use Loader to locate & load the UUIDGen implementation
+			uuidgenClass = Loader.getClassForName(className);
+		}
+		catch(ClassNotFoundException e) {
+			log.error("The specified UUIDGen class '" + className + "' was not found in classpath.");
+			log.error(e);
+		}
+
+		try {
+			// try to instantiate the UUIDGen implementation
+			uuidgen = (UUIDGen)uuidgenClass.newInstance();
+		}
+		catch(Exception e) {
+			log.error("Exception while attempting to instantiate the implementation of UUIDGen: "
+ uuidgenClass.getName() + "\n" + e.getMessage());
+			log.error(e);
+		}
+
+		return uuidgen;
+	}
+}
\ No newline at end of file

Propchange: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/uuidgen/UUIDGenFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/uuidgen/Win32UUIDGen.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/uuidgen/Win32UUIDGen.java?rev=709604&view=auto
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/uuidgen/Win32UUIDGen.java
(added)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/uuidgen/Win32UUIDGen.java
Fri Oct 31 16:54:22 2008
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.juddi.uuidgen;
+
+import java.io.IOException;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+/**
+ * Used to create new universally unique identifiers or UUID's (sometimes called
+ * GUID's).  UDDI UUID's are allways formmated according to DCE UUID conventions.
+ *
+ * @author Steve Viens (sviens@apache.org)
+ */
+public final class Win32UUIDGen implements UUIDGen
+{
+  /**
+   *
+   */
+  public String uuidgen()
+  {
+    String[] uuids = this.uuidgen(1);
+    return uuids[0];
+  }
+
+  /**
+   *
+   */
+  public String[] uuidgen(int nmbr)
+  {
+    String[] uuids = new String[nmbr];
+
+    try
+    {
+      Runtime r = Runtime.getRuntime();
+      Process p = r.exec("uuidgen -n" + nmbr);
+      BufferedReader x = new BufferedReader(new InputStreamReader(p.getInputStream()));
+
+      for (int i = 0; i < nmbr; ++i)
+        uuids[i] = x.readLine();
+    }
+    catch (IOException ex)
+    {
+      ex.printStackTrace();
+      throw new RuntimeException(ex.getMessage());
+    }
+
+    return uuids;
+  }
+
+
+  /***************************************************************************/
+  /***************************** TEST DRIVER *********************************/
+  /***************************************************************************/
+
+
+  public static void main(String args[])
+  {
+    UUIDGen uuidgen = new Win32UUIDGen();
+
+    long start = System.currentTimeMillis();
+
+    // fast (3705 milliseconds)
+    for (int i = 1; i <= 250; ++i)
+      System.out.println( i + ":  " + uuidgen.uuidgen());
+
+    long end = System.currentTimeMillis();
+
+    System.out.println("Generation (and display) of 250 UUID's took "+(end-start)+" milliseconds.");
+
+
+    start = System.currentTimeMillis();
+
+    // much faster (90 milliseconds)
+    String[] ids = uuidgen.uuidgen(250);
+    for (int i = 1; i < 250; ++i)
+      System.out.println( i + ":  " + ids[i]);
+
+    end = System.currentTimeMillis();
+
+    System.out.println("Generation (and display) of 250 UUID's took "+(end-start)+" milliseconds.");
+  }
+}

Propchange: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/uuidgen/Win32UUIDGen.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/validation/ValidateAuth.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/validation/ValidateAuth.java?rev=709604&view=auto
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/validation/ValidateAuth.java
(added)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/validation/ValidateAuth.java
Fri Oct 31 16:54:22 2008
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2001-2008 The Apache Software Foundation.
+ * 
+ * Licensed 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.juddi.validation;
+
+import java.util.Date;
+import javax.persistence.EntityManager;
+
+import org.uddi.v3_service.DispositionReportFaultMessage;
+import org.apache.juddi.error.ErrorMessage;
+import org.apache.juddi.error.AuthTokenRequiredException;
+import org.apache.juddi.model.Publisher;
+
+/**
+ * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
+ */
+public class ValidateAuth {
+	
+	public static final int AUTHTOKEN_ACTIVE = 1;
+	public static final int AUTHTOKEN_RETIRED = 0;
+	
+	public static Publisher getPublisher(EntityManager em, String authInfo) throws DispositionReportFaultMessage
{
+
+		
+		if (authInfo == null || authInfo.length() == 0)
+			throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthRequired"));
+		
+		org.apache.juddi.model.AuthToken modelAuthToken = em.find(org.apache.juddi.model.AuthToken.class,
authInfo);
+		if (modelAuthToken == null)
+			throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthInvalid"));
+		
+		Publisher publisher = em.find(Publisher.class, modelAuthToken.getPublisherId());
+		if (publisher == null)
+			throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthInvalid"));
+		
+		// Auth token is being used.  Adjust appropriate values so that it's internal 'expiration
clock' is reset.
+		modelAuthToken.setLastUsed(new Date());
+		modelAuthToken.setNumberOfUses(modelAuthToken.getNumberOfUses() + 1);
+		
+		return publisher;
+			
+				   
+	}
+			
+
+}

Propchange: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/validation/ValidateAuth.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/messages_en.properties
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/messages_en.properties?rev=709604&r1=709603&r2=709604&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/messages_en.properties
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/messages_en.properties
Fri Oct 31 16:54:22 2008
@@ -112,6 +112,18 @@
 errors.findtmodel.NoInput=At least one categoryBag, identifierBag or name must be supplied
 errors.tmodelbag.NoInput=At tModel key must be supplied in the tModelBag
 
+#-- Authentication error messages
+errors.auth.AuthRequired=Authentication is required for this API call
+errors.auth.AuthInvalid=Invalid authentication information
+errors.auth.InvalidUserId=An invalid user identification was passed
+errors.auth.InvalidCredentials=Invalid credentials were passed
+errors.auth.NoPublisher=The user provided does not have a publishing account
+errors.auth.cryptor.InvalidKey=Invalid Key Exception in crypting the password
+errors.auth.cryptor.Padding=Padding Exception in crypting the password
+errors.auth.cryptor.Algorithm=Algorithm Exception in crypting the password
+errors.auth.cryptor.AlgorithmParam=Algorithm parameter Exception in crypting the password
+errors.auth.cryptor.BlockSize=Block size Exception in crypting the password
+errors.auth.cryptor.BadPadding=Bad Padding Exception in crypting the password
 
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: juddi-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: juddi-cvs-help@ws.apache.org


Mime
View raw message