BrightSide Workbench Full Report + Source Code
org.turro.auth.AuthActions Class Reference
Inheritance diagram for org.turro.auth.AuthActions:
Collaboration diagram for org.turro.auth.AuthActions:

Public Member Functions

boolean itsMe (String id)
 
boolean myTurn (HttpServletRequest request)
 
void execute (ServletContext context, HttpServletRequest request, HttpServletResponse response)
 

Static Public Member Functions

static String getAccessURL (String domain, String email, String redir)
 
static String createLogoutURL (String redir)
 
static boolean isTrustedSource (HttpServletRequest request)
 
static String mapName (String name)
 
static String getIdentifier ()
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 44 of file AuthActions.java.

Member Function Documentation

◆ createLogoutURL()

static String org.turro.auth.AuthActions.createLogoutURL ( String  redir)
static

Definition at line 68 of file AuthActions.java.

68  {
69  IContact contact = Authentication.getLoggedIContact();
70  if(contact != null && contact.isValid()) {
71  return DirectContents.createRelativeURL(getIdentifier()) + LOGOUT_URL +
72  (redir != null ? "?redir=" + redir : "");
73  } else {
74  return null;
75  }
76  }
static String getIdentifier()
Here is the call graph for this function:

◆ execute()

void org.turro.auth.AuthActions.execute ( ServletContext  context,
HttpServletRequest  request,
HttpServletResponse  response 
)

Implements org.turro.elephant.direct.IDirectContent.

Definition at line 113 of file AuthActions.java.

113  {
114  if(DirectContents.isYourTurn(request, getIdentifier() + LOGOUT_URL)) {
115  String redir = request.getParameter("redir");
116  try {
117  Authentication.doLogout(redir);
118  } catch (IOException ex) {
119  Logger.getLogger(AuthActions.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
120  }
121  } else if(DirectContents.isYourTurn(request, getIdentifier() + AUTH_URL)) {
122  if(isTrustedSource(request)) {
123  try {
124  String url = createAccessURL(request);
125  if(!Strings.isBlank(url)) {
126  ElephantResponse.writeToResponse(response, ElephantResponseType.RESPONSE_CORRECT,
127  url, null);
128  }
129  } catch (IOException ex) {
130  Logger.getLogger(AuthActions.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
131  }
132  }
133  }
134  }
static boolean isTrustedSource(HttpServletRequest request)
Here is the call graph for this function:

◆ getAccessURL()

static String org.turro.auth.AuthActions.getAccessURL ( String  domain,
String  email,
String  redir 
)
static

Definition at line 50 of file AuthActions.java.

50  {
51  try {
52  ElephantPost ep = new ElephantPost(DirectContents.createURL(domain, getIdentifier()) + AUTH_URL);
53  if(!email.contains("@")) {
54  email = mapName(email);
55  }
56  ep.addParameter("email", email);
57  ep.addParameter("redir", redir);
58  ElephantResponse er = ep.doPost();
59  if(ElephantResponse.isCorrect(er)) {
60  return domain + "?" + er.message;
61  }
62  } catch (IOException ex) {
63  Logger.getLogger(AuthActions.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
64  }
65  return null;
66  }
static String mapName(String name)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getIdentifier()

static String org.turro.auth.AuthActions.getIdentifier ( )
static

Definition at line 98 of file AuthActions.java.

98  {
99  return AuthActions.class.getAnnotation(DirectContent.class).identifier();
100  }

◆ isTrustedSource()

static boolean org.turro.auth.AuthActions.isTrustedSource ( HttpServletRequest  request)
static

Definition at line 78 of file AuthActions.java.

78  {
79  String remoteIP = request.getRemoteAddr();
80  if("127.0.0.1".equals(remoteIP)) return true;
81  if(ElephantProperties.containsContextProperty("trusted", "trusted")) {
82  Logger.getLogger(AuthActions.class.getName()).log(Level.INFO, remoteIP + " trust checked");
83  return ElephantProperties.getContextProperty("trusted", "trusted", "").contains(remoteIP);
84  }
85  return false;
86  }
Here is the call graph for this function:

◆ itsMe()

boolean org.turro.auth.AuthActions.itsMe ( String  id)

Implements org.turro.elephant.direct.IDirectContent.

Definition at line 103 of file AuthActions.java.

103  {
104  return getIdentifier().equals(id);
105  }

◆ mapName()

static String org.turro.auth.AuthActions.mapName ( String  name)
static

Definition at line 88 of file AuthActions.java.

88  {
89  if(ElephantProperties.containsContextProperty("user-map", name)) {
90  Logger.getLogger(AuthActions.class.getName()).log(Level.INFO, name + " mapped");
91  return ElephantProperties.getContextProperty("user-map", name);
92  } else {
93  Logger.getLogger(AuthActions.class.getName()).log(Level.INFO, name + " not found");
94  }
95  return null;
96  }
Here is the call graph for this function:

◆ myTurn()

boolean org.turro.auth.AuthActions.myTurn ( HttpServletRequest  request)

Implements org.turro.elephant.direct.IDirectContent.

Definition at line 108 of file AuthActions.java.

108  {
109  return DirectContents.isYourTurn(request, getIdentifier());
110  }
Here is the call graph for this function:

The documentation for this class was generated from the following file: