List of utility methods to do Security
String | get(Configuration configuration, String section, String key) get AppConfigurationEntry configurationEntries[] = configuration.getAppConfigurationEntry(section); if (configurationEntries == null) { String errorMessage = "Could not find a '" + section + "' entry in this configuration."; throw new IOException(errorMessage); for (AppConfigurationEntry entry : configurationEntries) { Object val = entry.getOptions().get(key); if (val != null) ... |
String | getCommonName(String name) Gets the common name (CN) component of an X.500 principal name. try { LdapName ldapName = new LdapName(name); for (Rdn rdn : ldapName.getRdns()) { if (rdn.getType().equalsIgnoreCase("cn")) { return rdn.getValue().toString(); return name; ... |
String | getDirectiveValue(HashMap A directive is a parameter of the digest authentication process. String value = directivesMap.get(directive); if (value == null) { if (mandatory) { throw new AuthenticationException("\"" + directive + "\" mandatory directive is missing"); return ""; return value; ... |
AppConfigurationEntry[] | getEntries(Configuration configuration, String section) Get configurations for a section if (configuration == null) { return null; AppConfigurationEntry configurationEntries[] = configuration.getAppConfigurationEntry(section); if (configurationEntries == null) { String errorMessage = "Could not find a '" + section + "' entry in this configuration."; throw new IOException(errorMessage); return configurationEntries; |
C | getPublicCredential(Class Get the public credential of the given type. for (Object cred : subject.getPublicCredentials()) { if (type.isInstance(cred)) { return type.cast(cred); return null; |
long | getRefreshTime(KerberosTicket ticket) get Refresh Time long start = ticket.getStartTime().getTime(); long end = ticket.getEndTime().getTime(); return start + (long) ((end - start) * TICKET_RENEW_WINDOW); |
Map | getSaslProps() get Sasl Props Map<String, String> props = new HashMap<String, String>(); props.put(Sasl.POLICY_NOPLAINTEXT, "true"); return props; |
EncryptionKey | getServerPrivateKey(Subject subject, int keyType) get Server Private Key Set<Object> serverCredentials = subject.getPrivateCredentials(Object.class); KerberosPrincipal serverPrincipal = null; KeyTab serverKeyTab = null; for (Iterator<Object> i = serverCredentials.iterator(); i.hasNext();) { Object cred = i.next(); if (cred instanceof KerberosKey) { KerberosKey key = (KerberosKey) cred; if (key.getKeyType() == keyType) { ... |
Subject | getSubject() Obtain current authenticated subject InitialContext ctx = new InitialContext(); return (Subject) ctx.lookup("java:comp/env/security/subject"); |
KerberosTicket | getTicketGrantingTicket(Subject subject) get Ticket Granting Ticket Set<KerberosTicket> tickets = subject.getPrivateCredentials(KerberosTicket.class); for (KerberosTicket ticket : tickets) { if (isOriginalTicketGrantingTicket(ticket)) { return ticket; throw new IllegalArgumentException("kerberos ticket not found in " + subject); |