Java Code Examples for javax.portlet.PortletRequest#getRemoteUser()
The following examples show how to use
javax.portlet.PortletRequest#getRemoteUser() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PortletHelper.java From sakai with Educational Community License v2.0 | 6 votes |
public static String snoopPortlet(PortletRequest request) { String retval = "==== Portlet Request Snoop:\n"; String remoteUser = request.getRemoteUser(); retval += "getRemoteUser()="+remoteUser+"\n"; Map userInfo = (Map) request.getAttribute(PortletRequest.USER_INFO); retval += "UserInfo (needs Pluto 1.1.1 or later)\n"+userInfo+"\n"; retval += "isUserInRole(admin)="+request.isUserInRole("admin")+"\n"; retval += "isUserInRole(access)="+request.isUserInRole("access")+"\n"; retval += "isUserInRole(maintain)="+request.isUserInRole("maintain")+"\n"; retval += "isUserInRole(student)="+request.isUserInRole("student")+"\n"; retval += "isUserInRole(instructor)="+request.isUserInRole("instructor")+"\n"; retval += "isUserInRole(site.upd)="+request.isUserInRole("site.upd")+"\n"; retval += "isUserInRole(content.read)="+request.isUserInRole("content.read")+"\n"; return retval; }
Example 2
Source File: PortletHelper.java From sakai with Educational Community License v2.0 | 6 votes |
public static String snoopPortlet(PortletRequest request) { String retval = "==== Portlet Request Snoop:\n"; String remoteUser = request.getRemoteUser(); retval += "getRemoteUser()="+remoteUser+"\n"; Map userInfo = (Map) request.getAttribute(PortletRequest.USER_INFO); retval += "UserInfo (needs Pluto 1.1.1 or later)\n"+userInfo+"\n"; retval += "isUserInRole(admin)="+request.isUserInRole("admin")+"\n"; retval += "isUserInRole(access)="+request.isUserInRole("access")+"\n"; retval += "isUserInRole(maintain)="+request.isUserInRole("maintain")+"\n"; retval += "isUserInRole(student)="+request.isUserInRole("student")+"\n"; retval += "isUserInRole(instructor)="+request.isUserInRole("instructor")+"\n"; retval += "isUserInRole(site.upd)="+request.isUserInRole("site.upd")+"\n"; retval += "isUserInRole(content.read)="+request.isUserInRole("content.read")+"\n"; return retval; }
Example 3
Source File: FrameworkPortlet.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Determine the username for the given request. * <p>The default implementation first tries the UserPrincipal. * If that does not exist, then it checks the USER_INFO map. * Can be overridden in subclasses. * @param request current portlet request * @return the username, or {@code null} if none found * @see javax.portlet.PortletRequest#getUserPrincipal() * @see javax.portlet.PortletRequest#getRemoteUser() * @see javax.portlet.PortletRequest#USER_INFO * @see #setUserinfoUsernameAttributes */ protected String getUsernameForRequest(PortletRequest request) { // Try the principal. Principal userPrincipal = request.getUserPrincipal(); if (userPrincipal != null) { return userPrincipal.getName(); } // Try the remote user name. String userName = request.getRemoteUser(); if (userName != null) { return userName; } // Try the Portlet USER_INFO map. Map<?, ?> userInfo = (Map<?, ?>) request.getAttribute(PortletRequest.USER_INFO); if (userInfo != null) { for (int i = 0, n = this.userinfoUsernameAttributes.length; i < n; i++) { userName = (String) userInfo.get(this.userinfoUsernameAttributes[i]); if (userName != null) { return userName; } } } // Nothing worked... return null; }
Example 4
Source File: PortalUser.java From sakai with Educational Community License v2.0 | 5 votes |
public String getUsername(PortletRequest request) { fixPortalType(request); String username = null; Map userInfo = (Map) request.getAttribute(PortletRequest.USER_INFO); switch (portalType) { case GRIDSPHERE: if (userInfo != null) { username = (String) userInfo.get("user.name"); } break; case ORACLEPORTAL: log.debug("userInfo {}", userInfo); // Changes by Venkatesh for Oracle Portal log.debug("Remote User={}", username); // Oracle portal is populating user name with [1] at the end // the following code will get rid of the unnecessary characters username = request.getRemoteUser(); if(username != null && username.indexOf("[") != -1) { log.debug("Modifying user name for Oracle Portal={}", username); int corruptIndex = username.indexOf('['); username = username.substring(0,corruptIndex); } break; case PLUTO: case UPORTAL: username = request.getRemoteUser(); break; } log.debug("Remote User={}", username); return username; }
Example 5
Source File: PortletHelper.java From sakai with Educational Community License v2.0 | 5 votes |
public static String getUsername(PortletRequest request) { String username = null; Map userInfo = (Map) request.getAttribute(PortletRequest.USER_INFO); switch (lookupPortalType(request)) { case GRIDSPHERE: if (userInfo != null) { username = (String) userInfo.get("user.name"); } break; case ORACLEPORTAL: log.debug("userInfo {}", userInfo); // Changes by Venkatesh for Oracle Portal log.debug("Remote User={}", username); // Oracle portal is populating user name with [1] at the end // the following code will get rid of the unnecessary characters username = request.getRemoteUser(); if(username != null && username.indexOf("[") != -1) { debugPrint(request,"Modifying user name for Oracle Portal=" + username); int corruptIndex = username.indexOf('['); username = username.substring(0,corruptIndex); } break; case PLUTO: case UPORTAL: username = request.getRemoteUser(); break; } debugPrint(request,"Remote User=" + username); return username; }
Example 6
Source File: SecurityMappingTest.java From portals-pluto with Apache License 2.0 | 5 votes |
private TestResult isUserLoggedIn(PortletRequest request) { TestResult result = new TestResult(); if (request.getRemoteUser() == null) { result.setReturnCode(TestResult.WARNING); result.setResultMessage("User is not logged in."); } return result; }
Example 7
Source File: DefaultUserInfoService.java From portals-pluto with Apache License 2.0 | 5 votes |
public Map<String, String> getUserInfo(PortletRequest request, PortletWindow window) throws PortletContainerException { if ( request.getRemoteUser() != null ) { return Collections.emptyMap(); } return null; }
Example 8
Source File: PortalUser.java From sakai with Educational Community License v2.0 | 5 votes |
public String getUsername(PortletRequest request) { fixPortalType(request); String username = null; Map userInfo = (Map) request.getAttribute(PortletRequest.USER_INFO); switch (portalType) { case GRIDSPHERE: if (userInfo != null) { username = (String) userInfo.get("user.name"); } break; case ORACLEPORTAL: log.debug("userInfo {}", userInfo); // Changes by Venkatesh for Oracle Portal log.debug("Remote User={}", username); // Oracle portal is populating user name with [1] at the end // the following code will get rid of the unnecessary characters username = request.getRemoteUser(); if(username != null && username.indexOf("[") != -1) { log.debug("Modifying user name for Oracle Portal={}", username); int corruptIndex = username.indexOf('['); username = username.substring(0,corruptIndex); } break; case PLUTO: case UPORTAL: username = request.getRemoteUser(); break; } log.debug("Remote User={}", username); return username; }
Example 9
Source File: PortletHelper.java From sakai with Educational Community License v2.0 | 5 votes |
public static String getUsername(PortletRequest request) { String username = null; Map userInfo = (Map) request.getAttribute(PortletRequest.USER_INFO); switch (lookupPortalType(request)) { case GRIDSPHERE: if (userInfo != null) { username = (String) userInfo.get("user.name"); } break; case ORACLEPORTAL: log.debug("userInfo {}", userInfo); // Changes by Venkatesh for Oracle Portal log.debug("Remote User={}", username); // Oracle portal is populating user name with [1] at the end // the following code will get rid of the unnecessary characters username = request.getRemoteUser(); if(username != null && username.indexOf("[") != -1) { debugPrint(request,"Modifying user name for Oracle Portal=" + username); int corruptIndex = username.indexOf('['); username = username.substring(0,corruptIndex); } break; case PLUTO: case UPORTAL: username = request.getRemoteUser(); break; } debugPrint(request,"Remote User=" + username); return username; }