BrightSide Workbench Full Report + Source Code
AuthParser.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2015 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.auth;
20 
21 import java.io.PrintWriter;
22 import org.turro.string.Strings;
23 import org.turro.annotation.ExternalParser;
24 import org.turro.elephant.context.IConstructor;
25 import org.turro.parser.IParser;
26 import org.turro.plugin.contacts.IContact;
27 
32 @ExternalParser
33 public class AuthParser implements IParser {
34 
35  @Override
36  public boolean execute(IConstructor constructor, PrintWriter out, String[] tokens) {
37  boolean done = false;
38  if(tokens.length > 0) {
39  if("auth-url".equals(tokens[0])) {
40  if(tokens.length == 4) { //{@auth-url:domain:mail:redir}
41  String url = AuthActions.getAccessURL(tokens[1], tokens[2], tokens[3]);
42  if(!Strings.isBlank(url)) {
43  out.write(url);
44  done = true;
45  }
46  }
47  } else if("auth-connector".equals(tokens[0])) {
48  if(tokens.length == 4) { //{@auth-connector:name}
50  if(contact.isValid()) {
51  out.write(contact.getConnector(tokens[1]));
52  done = true;
53  }
54  }
55  }
56  }
57  return done;
58  }
59 
60 }
static String getAccessURL(String domain, String email, String redir)
boolean execute(IConstructor constructor, PrintWriter out, String[] tokens)
Definition: AuthParser.java:36