congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
GenericPrincipal
Code IndexAdd Tabnine to your IDE (free)

How to use
GenericPrincipal
in
org.apache.catalina.realm

Best Java code snippets using org.apache.catalina.realm.GenericPrincipal (Showing top 20 results out of 477)

Refine searchRefine arrow

  • Log
  • StringManager
origin: OryxProject/oryx

void addUser(String username, String password) {
 principals.put(username, new GenericPrincipal(username, password, Collections.singletonList(AUTH_ROLE)));
}
origin: OryxProject/oryx

@Override
protected String getPassword(String username) {
 GenericPrincipal principal = principals.get(username);
 return principal == null ? null : principal.getPassword();
}
origin: codefollower/Tomcat-Research

/**
 * Return the Principal associated with the specified username and
 * credentials, if there is one; otherwise return <code>null</code>.
 *
 * @param username Username of the Principal to look up
 * @param credentials Password or other credentials to use in
 *  authenticating this username
 */
@Override
public Principal authenticate(String username, String credentials) {
  GenericPrincipal principal = principals.get(username);
  boolean validated = compareCredentials(credentials, principal.getPassword());
  if (validated) {
    if (log.isDebugEnabled())
      log.debug(sm.getString("memoryRealm.authenticateSuccess", username));
    return (principal);
  } else {
    if (log.isDebugEnabled())
      log.debug(sm.getString("memoryRealm.authenticateFailure", username));
    return (null);
  }
}
origin: org.apache.geronimo.ext.tomcat/catalina

boolean result = gp.hasRole(role);
if (log.isDebugEnabled()) {
  String name = principal.getName();
  if (result)
    log.debug(sm.getString("realmBase.hasRoleSuccess", name, role));
  else
    log.debug(sm.getString("realmBase.hasRoleFailure", name, role));
origin: org.apache.catalina/com.springsource.org.apache.catalina

      manager.getContainer().getLogger().error
        (sm.getString("standardSession.sessionEvent"), t);
GenericPrincipal gp = (GenericPrincipal) principal;
try {
  gp.logout();
} catch (Exception e) {
  manager.getContainer().getLogger().error(
      sm.getString("standardSession.logoutfail"),
      e);
origin: org.apache.tomcat/tomcat-catalina

if (log.isDebugEnabled()) {
  log.debug("commit " + principal);
    String roles[] = ((GenericPrincipal) principal).getRoles();
    for (int i = 0; i < roles.length; i++) {
      subject.getPrincipals().add(new GenericPrincipal(roles[i], null, null));
origin: org.apache.tomcat/tomcat-catalina

  authStatus = state.serverAuthContext.validateRequest(state.messageInfo, client, null);
} catch (AuthException e) {
  log.debug(sm.getString("authenticator.loginFail"), e);
  return false;
  if (log.isDebugEnabled()) {
    log.debug("Authenticated user: " + principal);
      !principal.getUserPrincipal().equals(request.getUserPrincipal())) {
origin: codefollower/Tomcat-Research

public static GenericPrincipal readPrincipal(ObjectInput in)
    throws IOException, ClassNotFoundException {
  String name = in.readUTF();
  boolean hasPwd = in.readBoolean();
  String pwd = null;
  if ( hasPwd ) pwd = in.readUTF();
  int size = in.readInt();
  String[] roles = new String[size];
  for ( int i=0; i<size; i++ ) roles[i] = in.readUTF();
  Principal userPrincipal = null;
  boolean hasUserPrincipal = in.readBoolean();
  if (hasUserPrincipal) {
    try {
      userPrincipal = (Principal) in.readObject();
    } catch (ClassNotFoundException e) {
      log.error(sm.getString(
          "serializablePrincipal.readPrincipal.cnfe"), e);
      throw e;
    }
  }
  return new GenericPrincipal(name,pwd,Arrays.asList(roles),
      userPrincipal);
}
origin: codefollower/Tomcat-Research

log.debug("commit " + principal);
    String roles[] = ((GenericPrincipal) principal).getRoles();
    for (int i = 0; i < roles.length; i++) {
      subject.getPrincipals().add(
          new GenericPrincipal(null, roles[i], null));
origin: codefollower/Tomcat-Research

  if (containerLog.isTraceEnabled())
    containerLog.trace(
      sm.getString("dataSourceRealm.authenticateSuccess",
             username));
} else {
  if (containerLog.isTraceEnabled())
    containerLog.trace(
      sm.getString("dataSourceRealm.authenticateFailure",
             username));
  return (null);
return new GenericPrincipal(username, credentials, list);
origin: codefollower/Tomcat-Research

public static SerializablePrincipal createPrincipal(GenericPrincipal principal)
{
  if ( principal==null) return null;
  return new SerializablePrincipal(principal.getName(),
                   principal.getPassword(),
                   principal.getRoles()!=null?Arrays.asList(principal.getRoles()):null,
                   principal.getUserPrincipal()!=principal?principal.getUserPrincipal():null);
}
origin: org.apache.tomcat/tomcat-catalina

  @Override
  public String[] getRoles(Principal principal) {
    if (principal instanceof GenericPrincipal) {
      return ((GenericPrincipal) principal).getRoles();
    }

    String className = principal.getClass().getSimpleName();
    throw new IllegalStateException(sm.getString("realmBase.cannotGetRoles", className));
  }
}
origin: Waffle/waffle

  this.log.debug("roles: {}", String.join(", ", genericPrincipal.getRoles()));
  this.register(request, response, genericPrincipal, "FORM", genericPrincipal.getName(), null);
  this.log.info("successfully logged in user: {}", genericPrincipal.getName());
} finally {
  windowsIdentity.dispose();
origin: apache/meecrowave

@Override
public boolean commit() throws LoginException {
  if (!subject.getPrincipals().contains(principal)) {
    subject.getPrincipals().add(principal);
    if (GenericPrincipal.class.isInstance(principal)) {
      final String roles[] = GenericPrincipal.class.cast(principal).getRoles();
      for (final String role : roles) {
        subject.getPrincipals().add(new GenericPrincipal(role, null, null));
      }
    }
  }
  return true;
}
origin: stackoverflow.com

 private String[] getRolePrincipal() {
 final GenericPrincipal genericPrincipal = (GenericPrincipal) getUserPrincipal();
 return genericPrincipal.getRoles();
}
origin: org.codehaus.fabric3.tomcat/fabric3-tomcat-extension

  public SecuritySubject authenticate(AuthenticationToken<?, ?> token) throws AuthenticationException {
    if (delegate != null) {
      // if a security extension is installed, delegate to it
      return delegate.authenticate(token);
    }
    if (realm != null) {
      if (token instanceof UsernamePasswordToken) {
        UsernamePasswordToken usernamePassword = (UsernamePasswordToken) token;
        String username = usernamePassword.getPrincipal();
        String password = usernamePassword.getCredentials();
        Principal principal = realm.authenticate(username, password);
        if (principal instanceof GenericPrincipal) {
          GenericPrincipal generic = (GenericPrincipal) principal;
          Set<Role> roles = new HashSet<Role>();
          for (String name : generic.getRoles()) {
            roles.add(new Role(name));
          }
          return new BasicSecuritySubject(generic.getName(), generic.getPassword(), roles);
        } else {
          return new BasicSecuritySubject(username, password, Collections.<Role>emptySet());
        }

      }

    }
    throw new AuthenticationException("Unable to authenticate because a Tomcat Realm or Fabric3 Security extension has not been configured");
  }
}
origin: org.keycloak/keycloak-saml-tomcat-adapter-core

else if (samlSession.getPrincipal().getName().equals(principal.getName())){
  if (!principal.getUserPrincipal().getName().equals(samlSession.getPrincipal().getName())) {
    throw new RuntimeException("Unknown State");
    for (String role : principal.getRoles()) {
      log.debug("principal role: " + role);
origin: org.apache.geronimo.ext.tomcat/catalina

/**
 * Return the principal that has been authenticated for this Request.
 */
@Override
public Principal getUserPrincipal() {
  if (userPrincipal instanceof GenericPrincipal) {
    return ((GenericPrincipal) userPrincipal).getUserPrincipal();
  }
  return userPrincipal;
}
origin: org.glassfish.main.web/web-core

if (!(gp.getRealm() == this)) {
  if (log.isLoggable(Level.FINE)) {
    log.log(Level.FINE, "Different realm " + this + " " + gp.getRealm());
boolean result = gp.hasRole(role);
if (log.isLoggable(Level.FINE)) {
  String name = principal.getName();
origin: org.gatein.sso/spnego

String userPrincipalName = genPrincipal.getUserPrincipal().getName();
if (!genPrincipal.getName().equals(userPrincipalName))
    log.trace("GenericPrincipal name: " + genPrincipal.getName() + " will be changed to name: " + userPrincipalName);
org.apache.catalina.realmGenericPrincipal

Javadoc

Generic implementation of java.security.Principal that is available for use by Realm implementations.

Most used methods

  • <init>
    Construct a new Principal, associated with the specified Realm, for the specified username and passw
  • getRoles
  • getUserPrincipal
  • getPassword
  • hasRole
    Does the user represented by this Principal possess the specified role?
  • getName
  • logout
    Calls logout, if necessary, on any associated JAASLoginContext. May in the future be extended to cov
  • setGssCredential
  • getRealm
  • getGssCredential

Popular in Java

  • Making http requests using okhttp
  • getSystemService (Context)
  • setRequestProperty (URLConnection)
  • compareTo (BigDecimal)
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • Runner (org.openjdk.jmh.runner)
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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