From 29ac1a3a70e5e6b1de4148214e07b117cf32dcae Mon Sep 17 00:00:00 2001
From: Justin Richer <jricher@mitre.org>
Date: Mon, 27 Aug 2012 14:45:14 -0400
Subject: [PATCH] reverse lookup for clientdetails utiltiy classes

---
 .../oauth2/model/ClientDetailsEntity.java     | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/openid-connect-common/src/main/java/org/mitre/oauth2/model/ClientDetailsEntity.java b/openid-connect-common/src/main/java/org/mitre/oauth2/model/ClientDetailsEntity.java
index d81d724bc..fc733b34d 100644
--- a/openid-connect-common/src/main/java/org/mitre/oauth2/model/ClientDetailsEntity.java
+++ b/openid-connect-common/src/main/java/org/mitre/oauth2/model/ClientDetailsEntity.java
@@ -122,6 +122,14 @@ public class ClientDetailsEntity implements ClientDetails {
 		
 		private final String value;
 		
+		// map to aid reverse lookup
+		private static final Map<String, AuthType> lookup = new HashMap<String, AuthType>();
+		static {
+			for (AuthType a : AuthType.values()) {
+				lookup.put(a.getValue(), a);
+			}
+		}
+		
 		AuthType(String value) {
 			this.value = value;
 		}
@@ -129,6 +137,10 @@ public class ClientDetailsEntity implements ClientDetails {
 		public String getValue() {
 			return value;
 		}
+		
+		public static AuthType getByValue(String value) {
+			return lookup.get(value);
+		}
 	}
 	
 	public enum AppType {
@@ -136,6 +148,14 @@ public class ClientDetailsEntity implements ClientDetails {
 		
 		private final String value;
 		
+		// map to aid reverse lookup 
+		private static final Map<String, AppType> lookup = new HashMap<String, AppType>();
+		static {
+			for (AppType a : AppType.values()) {
+	            lookup.put(a.getValue(), a);
+            }
+		}
+		
 		AppType(String value) {
 			this.value = value;
 		}
@@ -143,6 +163,10 @@ public class ClientDetailsEntity implements ClientDetails {
 		public String getValue() {
 			return value;
 		}
+		
+		public static AppType getByValue(String value) {
+			return lookup.get(value);
+		}
 	}
 	
 	/**