cesarhernandezgt commented on a change in pull request #1:
URL: https://github.com/apache/geronimo-javamail/pull/1#discussion_r498997323



##########
File path: geronimo-javamail_1.6/NOTICE
##########
@@ -0,0 +1,8 @@
+
+Geronimo JavaMail 1.5

Review comment:
       Fixed in 
   c6cb739

##########
File path: geronimo-javamail_1.6/NOTICE
##########
@@ -0,0 +1,8 @@
+
+Geronimo JavaMail 1.5
+Copyright 2003-2016 The Apache Software Foundation

Review comment:
       Fixed in 
   c6cb739

##########
File path: geronimo-javamail_1.6/geronimo-javamail_1.6_provider/pom.xml
##########
@@ -0,0 +1,353 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 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. -->
+
+<!-- $Rev$ $Date: 2014-07-20 09:36:35 +0200 (So, 20. Jul 2014) 

Review comment:
       Fixed in 
   c6cb739

##########
File path: 
geronimo-javamail_1.6/geronimo-javamail_1.6_provider/src/main/java/org/apache/geronimo/javamail/authentication/XOAUTH2Authenticator.java
##########
@@ -0,0 +1,97 @@
+/**
+ * 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.geronimo.javamail.authentication;
+
+import javax.mail.MessagingException;
+import java.nio.charset.StandardCharsets;
+import java.util.Properties;
+
+public class XOAUTH2Authenticator implements ClientAuthenticator {
+
+    //The user we're authenticating
+    protected String username;
+    //The user's password (the "shared secret")
+    protected String password;
+    protected boolean complete = false;
+
+    /**
+     * Main constructor.
+     *
+     * @param username The login user name.
+     * @param password The Oauth2 token.
+     */
+    public XOAUTH2Authenticator(String[] mechanisms, Properties properties, 
String protocol, String host, String realm,
+                                String authorizationID, String username, 
String password) throws MessagingException {
+        this.username = username;
+        this.password = password;
+    }
+
+    /**
+     * Respond to the hasInitialResponse query.
+     *
+     * @return The SaslClient response to the same query.
+     */
+    public boolean hasInitialResponse() {
+        return true;
+    }
+
+    /**
+     * Indicate whether the challenge/response process is complete.
+     *
+     * @return True if the last challenge has been processed, false otherwise.
+     */
+    public boolean isComplete() {
+        return complete;
+    }
+
+    /**
+     * Retrieve the authenticator mechanism name.
+     *
+     * @return Will returns the string "XOAUTH2"
+     */
+    public String getMechanismName() {
+        return "XOAUTH2";
+    }
+
+    /**
+     * Evaluate a login challenge, returning the a result string that
+     * should satisfy the challenge.  This use the CallBackHandler to retrieve 
the
+     * information it needs for the given protocol.
+     *
+     * @param challenge The decoded challenge data, as byte array.
+     * @return A formatted challenge response, as an array of bytes.
+     * @throws MessagingException
+     */
+    public byte[] evaluateChallenge(final byte[] challenge) {
+        if (complete) {
+            return new byte[0];
+        }
+
+        final String response = new StringBuilder()
+                .append("user=")
+                .append(this.username)
+                .append("\001auth=Bearer ")
+                .append(this.password)
+                .append("\001\001")
+                .toString();
+
+
+        complete = true;
+        return response.getBytes(StandardCharsets.UTF_8);

Review comment:
       Fixed in 
   c6cb739
   Following the same aproach 
[LoginAuthenticator.java](https://github.com/apache/geronimo-javamail/blob/trunk/geronimo-javamail_1.5/geronimo-javamail_1.5_provider/src/main/java/org/apache/geronimo/javamail/authentication/LoginAuthenticator.java#L109)
 and 
[PlainAuthenticator.java](https://github.com/apache/geronimo-javamail/blob/trunk/geronimo-javamail_1.5/geronimo-javamail_1.5_provider/src/main/java/org/apache/geronimo/javamail/authentication/PlainAuthenticator.java#L119)
 has in 1.3, 1.4 and 1.5
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to