You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by be...@apache.org on 2008/08/18 00:39:56 UTC
svn commit: r686656 -
/incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth/OAuthResponseParams.java
Author: beaton
Date: Sun Aug 17 15:39:56 2008
New Revision: 686656
URL: http://svn.apache.org/viewvc?rev=686656&view=rev
Log:
Forgot a file in last checkin.
Added:
incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth/OAuthResponseParams.java
Added: incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth/OAuthResponseParams.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth/OAuthResponseParams.java?rev=686656&view=auto
==============================================================================
--- incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth/OAuthResponseParams.java (added)
+++ incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth/OAuthResponseParams.java Sun Aug 17 15:39:56 2008
@@ -0,0 +1,109 @@
+/*
+ * 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.shindig.gadgets.oauth;
+
+import org.apache.shindig.common.crypto.BlobCrypter;
+import org.apache.shindig.common.crypto.BlobCrypterException;
+import org.apache.shindig.gadgets.http.HttpResponse;
+
+/**
+ * Container for OAuth specific data to include in the response to the client.
+ */
+public class OAuthResponseParams {
+
+ // names for the JSON values we return to the client
+ public static final String CLIENT_STATE = "oauthState";
+ public static final String APPROVAL_URL = "oauthApprovalUrl";
+ public static final String ERROR_CODE = "oauthError";
+ public static final String ERROR_TEXT = "oauthErrorText";
+
+ /**
+ * Transient state we want to cache client side.
+ */
+ private OAuthClientState newClientState;
+
+ /**
+ * Authorization URL for the client.
+ */
+ private String aznUrl;
+
+ /**
+ * Error code for the client.
+ */
+ private OAuthError error;
+
+ /**
+ * Error text for the client.
+ */
+ private String errorText;
+
+ public OAuthResponseParams(BlobCrypter stateCrypter) {
+ newClientState = new OAuthClientState(stateCrypter);
+ }
+
+ public void addToResponse(HttpResponse response) {
+ if (!newClientState.isEmpty()) {
+ try {
+ response.getMetadata().put(CLIENT_STATE, newClientState.getEncryptedState());
+ } catch (BlobCrypterException e) {
+ // Configuration error somewhere, this should never happen.
+ throw new RuntimeException(e);
+ }
+ }
+ if (aznUrl != null) {
+ response.getMetadata().put(APPROVAL_URL, aznUrl);
+ }
+ if (error != null) {
+ response.getMetadata().put(ERROR_CODE, error.toString());
+ }
+ if (errorText != null) {
+ response.getMetadata().put(ERROR_TEXT, errorText);
+ }
+ }
+
+ public OAuthClientState getNewClientState() {
+ return newClientState;
+ }
+
+ public String getAznUrl() {
+ return aznUrl;
+ }
+
+ public void setAznUrl(String aznUrl) {
+ this.aznUrl = aznUrl;
+ }
+
+ public OAuthError getError() {
+ return error;
+ }
+
+ public void setError(OAuthError error) {
+ this.error = error;
+ }
+
+ public String getErrorText() {
+ return errorText;
+ }
+
+ public void setErrorText(String errorText) {
+ this.errorText = errorText;
+ }
+
+}