private NumericPrincipal createX500User(final X500Principal x500Principal) { PrivilegedExceptionAction<NumericPrincipal> action = new PrivilegedExceptionAction<NumericPrincipal>() { @Override public NumericPrincipal run() throws Exception { LocalAuthority localAuth = new LocalAuthority(); URI serviceURI = localAuth.getServiceURI(Standards.UMS_USERS_01.toASCIIString()); UserClient userClient = new UserClient(serviceURI); User newUser = userClient.createUser(x500Principal); Set<NumericPrincipal> set = newUser.getIdentities(NumericPrincipal.class); if (set.isEmpty()) { throw new IllegalStateException("missing internal id"); } return set.iterator().next(); } }; //Subject servopsSubject = SSLUtil.createSubject(privilegedPemFile); Subject servopsSubject = CredUtil.createOpsSubject(); try { return Subject.doAs(servopsSubject, action); } catch (Exception e) { throw new IllegalStateException("failed to create internal id for user " + x500Principal.getName(), e); } }
public void augmentSubject(final Subject subject) { if (subject == null ) { return; } // If the principal list is in the subject has aNumeric Principal // AND the list is greater than 1, then LDAP doesn't need to be // called here (subject has already been augmented) Set<Principal> principalSet = subject.getPrincipals(); Set<NumericPrincipal> nPrincipalSet = subject.getPrincipals(NumericPrincipal.class); if (principalSet.size() > 1 && !nPrincipalSet.isEmpty()) { return; } try { PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>() { public Object run() throws Exception { LocalAuthority localAuth = new LocalAuthority(); URI serviceURI = localAuth.getServiceURI(Standards.UMS_USERS_01.toASCIIString()); UserClient userClient = new UserClient(serviceURI); userClient.augmentSubject(subject); return null; } }; Subject servopsSubject = CredUtil.createOpsSubject(); Subject.doAs(servopsSubject, action); } catch (PrivilegedActionException e) { String msg = "Error augmenting subject " + subject; throw new RuntimeException(msg, e); } }
@Override public NumericPrincipal run() throws Exception { LocalAuthority localAuth = new LocalAuthority(); URI serviceURI = localAuth.getServiceURI(Standards.UMS_USERS_01.toASCIIString()); UserClient userClient = new UserClient(serviceURI); User newUser = userClient.createUser(x500Principal); Set<NumericPrincipal> set = newUser.getIdentities(NumericPrincipal.class); if (set.isEmpty()) { throw new IllegalStateException("missing internal id"); } return set.iterator().next(); } };
public Object run() throws Exception { LocalAuthority localAuth = new LocalAuthority(); URI serviceURI = localAuth.getServiceURI(Standards.UMS_USERS_01.toASCIIString()); UserClient userClient = new UserClient(serviceURI); userClient.augmentSubject(subject); return null; } };
public static CheckResource getAvailabilityCheck() { RegistryClient regClient = new RegistryClient(); LocalAuthority localAuth = new LocalAuthority(); URI serviceURI = localAuth.getServiceURI(Standards.UMS_USERS_01.toASCIIString()); URL availURL = regClient.getServiceURL(serviceURI, Standards.VOSI_AVAILABILITY, AuthMethod.ANON); return new CheckWebService(availURL.toExternalForm()); } }
/** * The returned CheckResource is the same as the one from AuthenticatorImpl. * * @return the CheckResource */ public static CheckResource getAvailabilityCheck() { RegistryClient regClient = new RegistryClient(); LocalAuthority localAuth = new LocalAuthority(); URI serviceURI = localAuth.getServiceURI(Standards.UMS_USERS_01.toASCIIString()); URL availURL = regClient.getServiceURL(serviceURI, Standards.VOSI_AVAILABILITY, AuthMethod.ANON); return new CheckWebService(availURL.toExternalForm()); } }
LocalAuthority loc = new LocalAuthority(); URI credURI = loc.getServiceURI(Standards.CRED_PROXY_10.toASCIIString()); final CredClient cred = new CredClient(credURI);