本文整理了Java中java.security.Principal.equals()
方法的一些代码示例,展示了Principal.equals()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Principal.equals()
方法的具体详情如下:
包路径:java.security.Principal
类名称:Principal
方法名:equals
[英]Compares the specified object with this Principal for equality and returns true if the specified object is equal, falseotherwise.
[中]将指定对象与此主体进行相等比较,如果指定对象相等,则返回true,否则返回False。
代码示例来源:origin: square/okhttp
/** Returns true if {@code toVerify} was signed by {@code signingCert}'s public key. */
private boolean verifySignature(X509Certificate toVerify, X509Certificate signingCert) {
if (!toVerify.getIssuerDN().equals(signingCert.getSubjectDN())) return false;
try {
toVerify.verify(signingCert.getPublicKey());
return true;
} catch (GeneralSecurityException verifyFailed) {
return false;
}
}
代码示例来源:origin: spring-projects/spring-security
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof JaasGrantedAuthority) {
JaasGrantedAuthority jga = (JaasGrantedAuthority) obj;
return this.role.equals(jga.role) && this.principal.equals(jga.principal);
}
return false;
}
代码示例来源:origin: prestodb/presto
/** Returns true if {@code toVerify} was signed by {@code signingCert}'s public key. */
private boolean verifySignature(X509Certificate toVerify, X509Certificate signingCert) {
if (!toVerify.getIssuerDN().equals(signingCert.getSubjectDN())) return false;
try {
toVerify.verify(signingCert.getPublicKey());
return true;
} catch (GeneralSecurityException verifyFailed) {
return false;
}
}
代码示例来源:origin: wildfly/wildfly
/**
* Determine whether this principal is equal to the given object.
*
* @param obj the object
* @return {@code true} if they are equal, {@code false} otherwise
*/
public boolean equals(final RealmNestedPrincipal obj) {
return this == obj || obj != null && r.equals(obj.r) && p.equals(obj.p);
}
代码示例来源:origin: robovm/robovm
private static X509Certificate findCert(Principal issuer, X509Certificate[] candidates) {
for (int i = 0; i < candidates.length; i++) {
if (issuer.equals(candidates[i].getSubjectDN())) {
return candidates[i];
}
}
return null;
}
代码示例来源:origin: org.springframework.security/spring-security-core
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof JaasGrantedAuthority) {
JaasGrantedAuthority jga = (JaasGrantedAuthority) obj;
return this.role.equals(jga.role) && this.principal.equals(jga.principal);
}
return false;
}
代码示例来源:origin: wildfly/wildfly
private static boolean issuedBy(final X509Certificate certificate, X509Certificate issuer) {
if (issuer.getSubjectDN().equals(certificate.getIssuerDN())) {
try {
certificate.verify(issuer.getPublicKey());
return true;
} catch (Exception e) {
return false;
}
}
return false;
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
/** Returns true if {@code toVerify} was signed by {@code signingCert}'s public key. */
private boolean verifySignature(X509Certificate toVerify, X509Certificate signingCert) {
if (!toVerify.getIssuerDN().equals(signingCert.getSubjectDN())) return false;
try {
toVerify.verify(signingCert.getPublicKey());
return true;
} catch (GeneralSecurityException verifyFailed) {
return false;
}
}
代码示例来源:origin: apache/storm
/**
* @return true if this request is an impersonation request.
*/
public boolean isImpersonating() {
return this.realPrincipal != null && !this.realPrincipal.equals(this.principal());
}
代码示例来源:origin: dropwizard/dropwizard
/**
* Discards any cached role associations for the given principal.
*
* @param principal
*/
public void invalidate(P principal) {
final Set<ImmutablePair<P, String>> keys = cache.asMap().keySet().stream()
.filter(cacheKey -> cacheKey.getLeft().equals(principal))
.collect(Collectors.toSet());
cache.invalidateAll(keys);
}
代码示例来源:origin: wildfly/wildfly
/**
* Determine whether this composite principal contains the given nested principal.
*
* @param principal the nested principal (must not be {@code null})
* @return {@code true} if this principal contains the nested principal, {@code false} otherwise
*/
public boolean contains(final Principal principal) {
Assert.checkNotNullParam("principal", principal);
for (Principal test : p) {
if (test.equals(principal)) {
return true;
}
}
return false;
}
代码示例来源:origin: robovm/robovm
private static X509Certificate[] createChain(X509Certificate signer, X509Certificate[] candidates) {
LinkedList chain = new LinkedList();
chain.add(0, signer);
// Signer is self-signed
if (signer.getSubjectDN().equals(signer.getIssuerDN())){
return (X509Certificate[])chain.toArray(new X509Certificate[1]);
}
Principal issuer = signer.getIssuerDN();
X509Certificate issuerCert;
int count = 1;
while (true) {
issuerCert = findCert(issuer, candidates);
if( issuerCert == null) {
break;
}
chain.add(issuerCert);
count++;
if (issuerCert.getSubjectDN().equals(issuerCert.getIssuerDN())) {
break;
}
issuer = issuerCert.getIssuerDN();
}
return (X509Certificate[])chain.toArray(new X509Certificate[count]);
}
代码示例来源:origin: ankidroid/Anki-Android
boolean foundNext = false;
for (int nextIndex = currIndex + 1; nextIndex < certificates.length; ++nextIndex) {
if (certificates[currIndex].getIssuerDN().equals(certificates[nextIndex].getSubjectDN())) {
foundNext = true;
X509Certificate lastCertificate = certificates[chainLength - 1];
Date now = new Date();
if (lastCertificate.getSubjectDN().equals(lastCertificate.getIssuerDN())
&& now.after(lastCertificate.getNotAfter())) {
--chainLength;
代码示例来源:origin: stackoverflow.com
++nextIndex)
if (certificates[currIndex].getIssuerDN().equals(
certificates[nextIndex].getSubjectDN()))
X509Certificate lastCertificate = certificates[chainLength - 1];
Date now = new Date();
if (lastCertificate.getSubjectDN().equals(lastCertificate.getIssuerDN())
&& now.after(lastCertificate.getNotAfter()))
代码示例来源:origin: wildfly/wildfly
@Override
boolean isSamePrincipal(Principal principal) {
final SecurityDomain domain = capturedIdentity.getSecurityDomain();
principal = rewriteAll(principal, mechanismRealmConfiguration.getPreRealmRewriter(), mechanismConfiguration.getPreRealmRewriter(), domain.getPreRealmRewriter());
return authenticationPrincipal.equals(principal);
}
代码示例来源:origin: wildfly/wildfly
@Override
boolean isSamePrincipal(Principal principal) {
final SecurityDomain domain = authorizedIdentity.getSecurityDomain();
principal = rewriteAll(principal, mechanismRealmConfiguration.getPreRealmRewriter(), mechanismConfiguration.getPreRealmRewriter(), domain.getPreRealmRewriter());
return authenticationPrincipal.equals(principal);
}
代码示例来源:origin: wildfly/wildfly
case SET_PRINCIPAL:
if (this.principal != null && ! this.principal.equals(AnonymousPrincipal.getInstance())) {
this.userCallbackKinds.remove(CallbackKind.PRINCIPAL);
代码示例来源:origin: spring-projects/spring-framework
if (principal != null && !principal.equals(request.getPrincipal())) {
logger.debug("The user for the session does not match the user for the request.");
response.setStatusCode(HttpStatus.NOT_FOUND);
代码示例来源:origin: wildfly/wildfly
if (!callerPrincipal.equals(identity.getPrincipal())) {
identity = identity.createRunAsIdentity(callerPrincipal.getName());
代码示例来源:origin: wildfly/wildfly
if (securityIdentity != null) {
if (callerPrincipal != null) {
boolean authorizationRequired = (integrated && !securityIdentity.getPrincipal().equals(callerPrincipal));
内容来源于网络,如有侵权,请联系作者删除!