Tabnine Logo
GeoServerRole.setUserName
Code IndexAdd Tabnine to your IDE (free)

How to use
setUserName
method
in
org.geoserver.security.impl.GeoServerRole

Best Java code snippets using org.geoserver.security.impl.GeoServerRole.setUserName (Showing top 5 results out of 315)

origin: geoserver/geoserver

@Override
public GeoServerRole convertRoleFromString(String roleString, String userName) {
  if (roleString == null) return null;
  roleString = roleString.trim();
  if (roleString.isEmpty()) return null;
  checkDelimiters();
  List<String> working = splitString(roleString.trim(), getRoleParameterStartString());
  GeoServerRole result = new GeoServerRole(working.get(0));
  if (working.size() == 1) {
    return result;
  }
  // we have role parameters
  result.setUserName(userName);
  if (working.get(1).endsWith(getRoleParameterEndString()) == false)
    throw createExcpetion(roleString + " does not end with " + getRoleParameterEndString());
  int index = working.get(1).lastIndexOf(getRoleParameterEndString());
  String roleParamString = working.get(1).substring(0, index).trim();
  working = splitString(roleParamString, getRoleParameterDelimiterString());
  for (String kvp : working) {
    List<String> tmp = splitString(kvp.trim(), getRoleParameterAssignmentString());
    if (tmp.size() != 2)
      throw createExcpetion(roleString + " Invalid role string:  " + roleString);
    result.getProperties().put(tmp.get(0).trim(), tmp.get(1).trim());
  }
  return result;
}
origin: geoserver/geoserver

  /**
   * Takes the role set for a user and personalizes the roles (matching user properties and role
   * parameters)
   *
   * @param user
   * @param roles
   * @throws IOException
   */
  public SortedSet<GeoServerRole> personalizeRoles(
      GeoServerUser user, Collection<GeoServerRole> roles) throws IOException {
    SortedSet<GeoServerRole> set = new TreeSet<GeoServerRole>();
    for (GeoServerRole role : roles) {
      Properties personalizedProps =
          getRoleService()
              .personalizeRoleParams(
                  role.getAuthority(), role.getProperties(),
                  user.getUsername(), user.getProperties());
      if (personalizedProps == null) {
        set.add(role);
      } else { // create personalized role
        GeoServerRole pRole = getRoleService().createRoleObject(role.getAuthority());
        pRole.setUserName(user.getUsername());
        for (Object key : personalizedProps.keySet())
          pRole.getProperties().put(key, personalizedProps.get(key));
        set.add(pRole);
      }
    }
    return set;
  }
}
origin: org.geoserver.web/web-sec-core

@Override
protected void onFormSubmit(GeoServerRole role) throws IOException {
  
  GeoServerRoleStore store = null;
  try {
    store = new RoleStoreValidationWrapper(getRoleStore(roleServiceName));
    //copy into a new one so we can set the name properly
    GeoServerRole newRole= store.createRoleObject(get("form:name").getDefaultModelObjectAsString());
    newRole.setUserName(role.getUserName());
    newRole.getProperties().putAll(role.getProperties());
    role = newRole;                        
    store.addRole(role);
    String parentRoleName = get("form:parent").getDefaultModelObjectAsString();
    if (parentRoleName != null) {
      GeoServerRole parentRole = store.getRoleByName(parentRoleName);
      store.setParentRole(role, parentRole);
    }
    store.store();
  } catch (IOException ex) {
    try {store.load(); } catch (IOException ex2) {};
    throw ex;
  }
}
origin: org.geoserver.web/web-security

@Override
protected void onFormSubmit(GeoServerRole role) throws IOException {
  
  GeoServerRoleStore store = null;
  try {
    //copy into a new one so we can set the name properly
    GeoServerRole newRole = 
      new GeoServerRole(get("form:name").getDefaultModelObjectAsString());
    newRole.setUserName(role.getUserName());
    newRole.getProperties().putAll(role.getProperties());
    role = newRole;
    store = new RoleStoreValidationWrapper(getRoleStore(roleServiceName));
    store.addRole(role);
    String parentRoleName = get("form:parent").getDefaultModelObjectAsString();
    if (parentRoleName != null) {
      GeoServerRole parentRole = store.getRoleByName(parentRoleName);
      store.setParentRole(role, parentRole);
    }
    store.store();
  } catch (IOException ex) {
    try {store.load(); } catch (IOException ex2) {};
    throw ex;
  }
}
origin: org.geoserver.web/gs-web-sec-core

newRole.setUserName(role.getUserName());
newRole.getProperties().putAll(role.getProperties());
role = newRole;
org.geoserver.security.implGeoServerRolesetUserName

Popular methods of GeoServerRole

  • getAuthority
  • <init>
  • getProperties
  • getUserName
  • equals
  • toString
  • compareTo
  • equalsWithoutUserName
  • isAnonymous

Popular in Java

  • Start an intent from android
  • requestLocationUpdates (LocationManager)
  • compareTo (BigDecimal)
  • getResourceAsStream (ClassLoader)
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • Socket (java.net)
    Provides a client-side TCP socket.
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • Top 17 PhpStorm Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now