cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: Adding a grant MBW
Date Fri, 19 Jun 2015 16:50:58 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 0abaf3cbe -> fb39ed65c


Adding a grant MBW


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/fb39ed65
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/fb39ed65
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/fb39ed65

Branch: refs/heads/3.0.x-fixes
Commit: fb39ed65c83655763208755383b66f739b50ba92
Parents: 0abaf3c
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Fri Jun 19 17:49:15 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Fri Jun 19 17:50:41 2015 +0100

----------------------------------------------------------------------
 .../oauth2/client/AccessTokenGrantWriter.java   | 58 ++++++++++++++++++++
 1 file changed, 58 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/fb39ed65/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/AccessTokenGrantWriter.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/AccessTokenGrantWriter.java
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/AccessTokenGrantWriter.java
new file mode 100644
index 0000000..5654a71
--- /dev/null
+++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/AccessTokenGrantWriter.java
@@ -0,0 +1,58 @@
+/**
+ * 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.cxf.rs.security.oauth2.client;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Form;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+
+import org.apache.cxf.jaxrs.utils.FormUtils;
+import org.apache.cxf.rs.security.oauth2.common.AccessTokenGrant;
+
+@Produces(MediaType.APPLICATION_FORM_URLENCODED)
+public class AccessTokenGrantWriter implements MessageBodyWriter<AccessTokenGrant>
{
+
+    @Override
+    public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations,
MediaType mediaType) {
+        return true;
+    }
+
+    @Override
+    public long getSize(AccessTokenGrant t, Class<?> type, Type genericType, Annotation[]
annotations,
+                        MediaType mediaType) {
+        return -1;
+    }
+
+    @Override
+    public void writeTo(AccessTokenGrant t, Class<?> type, Type genericType, Annotation[]
annotations,
+                        MediaType mediaType, MultivaluedMap<String, Object> httpHeaders,
+                        OutputStream entityStream) throws IOException, WebApplicationException
{
+        String form = FormUtils.formToString(new Form(t.toMap()));    
+        entityStream.write(form.getBytes());
+    }
+
+}


Mime
View raw message