/** * {@inheritDoc} * * forwards to older method {@link #matches(String, String)} */ @Override public boolean matches(ServerObjs serverObjs, MatchValues matchValues) { return implementation.matches(matchValues.getId(), matchValues.getAclExpr()); }
/** * {@inheritDoc} * * forwards to older method {@link #handleAuthentication(ServerCnxn, byte[])} */ @Override public KeeperException.Code handleAuthentication(ServerObjs serverObjs, byte[] authData) { return implementation.handleAuthentication(serverObjs.getCnxn(), authData); }
static ServerAuthenticationProvider wrap(AuthenticationProvider provider) { if (provider == null) { return null; } return (provider instanceof ServerAuthenticationProvider) ? (ServerAuthenticationProvider)provider : new WrappedAuthenticationProvider(provider); }
/** Call with a single argument of user:pass to generate authdata. * Authdata output can be used when setting superDigest for example. * @param args single argument of user:pass * @throws NoSuchAlgorithmException */ public static void main(String args[]) throws NoSuchAlgorithmException { for (int i = 0; i < args.length; i++) { System.out.println(args[i] + "->" + generateDigest(args[i])); } } }
public static void main(String[] args) throws Exception { for(String arg: args) { KerberosName name = new KerberosName(arg); System.out.println("Name: " + name + " to " + name.getShortName()); } } }
/** * Get the translation of the principal name into an operating system * user name. * @return the short name * @throws IOException */ public String getShortName() throws IOException { String[] params; if (hostName == null) { // if it is already simple, just return it if (realm == null) { return serviceName; } params = new String[]{realm, serviceName}; } else { params = new String[]{realm, serviceName, hostName}; } for(Rule r: rules) { String result = r.apply(params); if (result != null) { return result; } } throw new NoMatchingRule("No rules applied to " + toString()); }
private boolean shouldAppendHost(KerberosName kerberosName) { return !isSystemPropertyTrue(SYSPROP_REMOVE_HOST) && kerberosName.getHostName() != null; }
public boolean isValid(String id) { // Since the SASL authenticator will usually be used with Kerberos authentication, // it should enforce that these names are valid according to Kerberos's // syntax for principals. // // Use the KerberosName(id) constructor to define validity: // if KerberosName(id) throws IllegalArgumentException, then id is invalid. // otherwise, it is valid. // try { new KerberosName(id); return true; } catch (IllegalArgumentException e) { return false; } }
public void handle(Callback[] callbacks) throws UnsupportedCallbackException { for (Callback callback : callbacks) { if (callback instanceof NameCallback) { handleNameCallback((NameCallback) callback); } else if (callback instanceof PasswordCallback) { handlePasswordCallback((PasswordCallback) callback); } else if (callback instanceof RealmCallback) { handleRealmCallback((RealmCallback) callback); } else if (callback instanceof AuthorizeCallback) { handleAuthorizeCallback((AuthorizeCallback) callback); } } }
private boolean shouldAppendRealm(KerberosName kerberosName) { return !isSystemPropertyTrue(SYSPROP_REMOVE_REALM) && kerberosName.getRealm() != null; }
public static ServerAuthenticationProvider getServerProvider(String scheme) { return WrappedAuthenticationProvider.wrap(getProvider(scheme)); }
private byte[] addr2Bytes(String addr) { byte b[] = v4addr2Bytes(addr); // TODO Write the v6addr2Bytes return b; }
@Override public boolean isValid(String id) { return implementation.isValid(id); } }
@Override public boolean isAuthenticated() { return implementation.isAuthenticated(); }
@Override public String getScheme() { return implementation.getScheme(); }
public static AuthenticationProvider getProvider(String scheme) { if(!initialized) initialize(); return authenticationProviders.get(scheme); }
@Override public boolean matches(ServerObjs serverObjs, MatchValues matchValues) { return matchValues.getId().equals(matchValues.getAclExpr()); }
/** * Set the static configuration to get the rules. * @param conf the new configuration * @throws IOException */ public static void setConfiguration() throws IOException { String ruleString = System.getProperty("zookeeper.security.auth_to_local", "DEFAULT"); rules = parseRules(ruleString); }
private boolean shouldAppendHost(KerberosName kerberosName) { return !isSystemPropertyTrue(SYSPROP_REMOVE_HOST) && kerberosName.getHostName() != null; }
private boolean shouldAppendRealm(KerberosName kerberosName) { return !isSystemPropertyTrue(SYSPROP_REMOVE_REALM) && kerberosName.getRealm() != null; }