/** * Return <code>true</code> if the specified Principal has the specified * security role, within the context of this Realm; otherwise return * <code>false</code>. This method can be overridden by Realm * implementations. The default implementation is to forward to * hasRole(Principal principal, String role). * * @param request Request we are processing * @param response Response we are creating * @param principal Principal for whom the role is to be checked * @param role Security role to be checked */ public boolean hasRole(HttpRequest request, HttpResponse response, Principal principal, String role) { return hasRole(principal, role); } //END SJSAS 6232464
String md5a2) { String md5a1 = getDigest(username, realm); if (md5a1 == null) return null; if(getDigestEncoding() == null) { valueBytes = serverDigestValue.getBytes(); } else { try { valueBytes = serverDigestValue.getBytes(getDigestEncoding()); } catch (UnsupportedEncodingException uee) { log.error("Illegal digestEncoding: " + getDigestEncoding(), uee); throw new IllegalArgumentException(uee.getMessage()); return getPrincipal(username); else return null;
/** * 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 */ public Principal authenticate(String username, char[] credentials) { char[] serverCredentials = getPassword(username); boolean validated ; if ( serverCredentials == null ) { validated = false; } else if(hasMessageDigest()) { validated = equalsIgnoreCase(serverCredentials, digest(credentials)); } else { validated = Arrays.equals(serverCredentials, credentials); } if(! validated ) { return null; } return getPrincipal(username); }
/** * Return the digest associated with given principal's user name. * @param username the user name * @param realmName the realm name * @return the digest for the specified user */ protected String getDigest(String username, String realmName) { if (hasMessageDigest()) { // Use pre-generated digest return getPassword(username); } String digestValue = username + ":" + realmName + ":" + getPassword(username); byte[] valueBytes = null; try { valueBytes = digestValue.getBytes(getDigestCharset()); } catch (UnsupportedEncodingException uee) { throw new IllegalArgumentException(sm.getString("realmBase.invalidDigestEncoding", getDigestEncoding()), uee); } return MD5Encoder.encode(ConcurrentMessageDigest.digestMD5(valueBytes)); }
/** * Set the Container with which this Realm has been associated. * * @param container The associated Container */ @Override public void setContainer(Container container) { for(Realm realm : realms) { // Set the realmPath for JMX naming if (realm instanceof RealmBase) { ((RealmBase) realm).setRealmPath( getRealmPath() + "/realm" + realms.indexOf(realm)); } // Set the container for sub-realms. Mainly so logging works. realm.setContainer(container); } super.setContainer(container); }
String md5a2) { String md5a1 = getDigest(username, realm); if (md5a1 == null) return null; valueBytes = serverDigestValue.getBytes(getDigestCharset()); } catch (UnsupportedEncodingException uee) { log.error("Illegal digestEncoding: " + getDigestEncoding(), uee); throw new IllegalArgumentException(uee.getMessage()); return getPrincipal(username);
/** * Return the Principal associated with the given certificate. */ protected Principal getPrincipal(X509Certificate usercert) { return(getPrincipal(usercert.getSubjectDN().getName())); }
return resultsToArray(results); return resultsToArray(results); return resultsToArray(results); log.debug(" No applicable constraint located"); return resultsToArray(results);
if (hasMessageDigest() == false) return (credentials); bytes = credentials.getBytes(getDigestCharset()); } catch (UnsupportedEncodingException uee) { log.error("Illegal digestEncoding: " + getDigestEncoding(), uee); throw new IllegalArgumentException(uee.getMessage());
public void setContainer(Container container) { super.setContainer(container); String name=container.getName(); if( appName==null ) { appName=name; if (log.isLoggable(Level.INFO)) { log.log(Level.INFO, LogFacade.SETTING_JAAS_INFO, appName); } } }
protected String getRealmSuffix() { return ",realmPath=" + getRealmPath(); }
protected String digest(final String credentials) { return RealmBase.Digest(credentials, ((String) options.get("digest")), ((String) options.get("encoding"))); }
/** * 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) { String serverCredentials = getPassword(username); boolean validated = compareCredentials(credentials, serverCredentials); if (!validated) { if (containerLog.isTraceEnabled()) { containerLog.trace(sm.getString("realmBase.authenticateFailure", username)); } return null; } if (containerLog.isTraceEnabled()) { containerLog.trace(sm.getString("realmBase.authenticateSuccess", username)); } return getPrincipal(username); }
private Charset getDigestCharset() throws UnsupportedEncodingException { String charset = getDigestEncoding(); if (charset == null) { return StandardCharsets.ISO_8859_1; } else { return B2CConverter.getCharset(charset); } }
/** * Return the digest associated with given principal's user name. * @param username the user name * @param realmName the realm name * @return the digest for the specified user */ protected String getDigest(String username, String realmName) { if (hasMessageDigest()) { // Use pre-generated digest return getPassword(username); } String digestValue = username + ":" + realmName + ":" + getPassword(username); byte[] valueBytes = null; try { valueBytes = digestValue.getBytes(getDigestCharset()); } catch (UnsupportedEncodingException uee) { log.error("Illegal digestEncoding: " + getDigestEncoding(), uee); throw new IllegalArgumentException(uee.getMessage()); } return MD5Encoder.encode(ConcurrentMessageDigest.digestMD5(valueBytes)); }
String md5a1 = getDigest(username, realm); if (md5a1 == null) return null; valueBytes = serverDigestValue.getBytes(getDigestCharset()); } catch (UnsupportedEncodingException uee) { log.error("Illegal digestEncoding: " + getDigestEncoding(), uee); throw new IllegalArgumentException(uee.getMessage()); return getPrincipal(username);
/** * Return the Principal associated with the given user name. */ protected abstract Principal getPrincipal(String username);
return resultsToArray(results); return resultsToArray(results); return resultsToArray(results); return resultsToArray(results);
if (hasMessageDigest() == false) return (credentials); bytes = credentials.getBytes(getDigestCharset()); } catch (UnsupportedEncodingException uee) { log.error("Illegal digestEncoding: " + getDigestEncoding(), uee); throw new IllegalArgumentException(uee.getMessage());
public void setContainer(Container container) { super.setContainer(container); if( appName==null ) { String name=container.getName(); name = makeLegalForJAAS(name); appName=name; log.info("Set JAAS app name " + appName); } }