public String getCurrentHttpPrincipalUsername(Subject subject) { final AuthMethod authMethod = AuthenticationUtil.getAuthMethod(subject); String username; if ((authMethod != null) && (authMethod != AuthMethod.ANON)) { final Set curPrincipals = subject.getPrincipals(HttpPrincipal.class); HttpPrincipal[] principalArray = new HttpPrincipal[curPrincipals.size()]; username = ((HttpPrincipal[]) curPrincipals .toArray(principalArray))[0].getName(); } else { username = null; } return username; } }
private void doGet() { try { Set<Principal> ps = new HashSet<Principal>(); if (userID != null) ps.add(new HttpPrincipal(userID)); else // userDN ps.add(new X500Principal(userDN)); Subject target = new Subject(true, ps, new HashSet<Object>(), new HashSet<Object>()); double dur = 0.0; if (daysValid != null) dur = daysValid; X509CertificateChain chain = client.getProxyCertificate(target, dur); CertUtil.writePEMCertificateAndKey(chain, outPEM); } catch(Exception e) { logger.error("failed to get", e); System.exit(NET_STATUS); } }
public String toString() { String proxyUserStr = ""; if (StringUtil.hasText(getProxyUser())) { proxyUserStr = getProxyUser() + " as "; } return getClass().getSimpleName() + "[" + proxyUserStr + getName() + "]"; }
client.addUserMember(group, new HttpPrincipal(member)); client.removeUserMember(group, new HttpPrincipal(member)); hp = new HttpPrincipal(member); if (hp.equals(ahp)) hp = new HttpPrincipal(member); if (hp.equals(ahp))
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("DelegationToken(").append(USER_LABEL).append("="); if (StringUtil.hasText(getUser().getProxyUser())) { sb.append(",").append(PROXY_LABEL).append("="); sb.append(getUser().getProxyUser()); } sb.append(getUser()); sb.append(",").append(SCOPE_LABEL).append("="); sb.append(getScope()); sb.append(",startTime="); sb.append(getExpiryTime()); for (String domain : domains) { sb.append(",").append(DOMAIN_LABEL).append("=").append(domain); } sb.append(")"); return sb.toString(); }
if (StringUtil.hasText(user.getProxyUser())) { sb.append(FIELD_DELIM); sb.append(PROXY_LABEL); sb.append(VALUE_DELIM); sb.append(user.getProxyUser());
/** * Get corresponding user IDs from Subject's HttpPrincipals * * @return set of user ids extracted from the HttpPrincipals */ public static Set<String> getUseridsFromSubject() { AccessControlContext acc = AccessController.getContext(); Subject subject = Subject.getSubject(acc); Set<String> userids = new HashSet<String>(); if (subject != null) { final Set<HttpPrincipal> httpPrincipals = subject.getPrincipals(HttpPrincipal.class); final Set<CookiePrincipal> cookiePrincipals = subject.getPrincipals(CookiePrincipal.class); String userId; for (final HttpPrincipal principal : httpPrincipals) { userId = principal.getName(); userids.add(userId); } } return userids; }
protected String getUser(Subject subject) { try { if (subject != null) { final Set<HttpPrincipal> httpPrincipals = subject.getPrincipals(HttpPrincipal.class); if (!httpPrincipals.isEmpty()) { HttpPrincipal principal = httpPrincipals.iterator().next(); this.proxyUser = principal.getProxyUser(); return principal.getName(); } final Set<X500Principal> x500Principals = subject.getPrincipals(X500Principal.class); if (!x500Principals.isEmpty()) { X500Principal principal = x500Principals.iterator().next(); return principal.getName(); } } } catch (Throwable t) { // ignore - can't throw exceptions here } return ANONYMOUS_USER; }
public static Principal createPrincipal(String userID, String idType) { if (IdentityType.X500.getValue().equalsIgnoreCase(idType)) { return new X500Principal( AuthenticationUtil.canonizeDistinguishedName(userID)); } if (IdentityType.USERNAME.getValue().equalsIgnoreCase(idType)) { return new HttpPrincipal(userID); } if (IdentityType.CADC.getValue().equalsIgnoreCase(idType)) { return new NumericPrincipal(UUID.fromString(userID)); } return null; }
public String toPrettyString() { HttpPrincipal p1 = this.getHttpPrincipal(); if (p1 != null) return p1.getName(); X500Principal p2 = this.getX500Principal(); if (p2 != null) return p2.getName(); return toString(); }
principalSet.add(new HttpPrincipal(userid, proxyUser)); } else if (userid != null) { principalSet.add(new HttpPrincipal(userid));
path.append("/userid/").append(httpPrincipal.getName());
principals.add(new HttpPrincipal(httpUser)); else if (token != null) // user from token principals.add(token.getUser());
principal = new HttpPrincipal(identity);
if (StringUtil.hasText(httpUser)) // user from HTTP AUTH principals.add(new HttpPrincipal(httpUser)); } else if (token != null) // user from token