@Override public void nullSafeSet( PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { if ( value == null ) { log.debugv("Binding null to parameter {0} ",index); st.setNull( index, Types.VARCHAR ); } else { String stringValue = BitSetTypeDescriptor.INSTANCE.toString( (BitSet) value ); log.debugv("Binding {0} to parameter {1} ", stringValue, index); st.setString( index, stringValue ); } }
@Override public Object nullSafeGet( ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException { String columnName = names[0]; String columnValue = (String) rs.getObject( columnName ); log.debugv("Result set column {0} value is {1}", columnName, columnValue); return columnValue == null ? null : BitSetTypeDescriptor.INSTANCE.fromString( columnValue ); }
@Override public boolean onFlushDirty( Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) { LOGGER.debugv( "Entity {0}#{1} changed from {2} to {3}", entity.getClass().getSimpleName(), id, Arrays.toString( previousState ), Arrays.toString( currentState ) ); return super.onFlushDirty( entity, id, currentState, previousState, propertyNames, types ); } }
private File writeProperties(Properties properties, String fileName) throws IOException { File result = new File(tempFolder, fileName); LOGGER.debugv("Creating property file {0}", result); try (FileOutputStream fos = new FileOutputStream(result)) { // comment $REALM_NAME is just a workaround for https://issues.jboss.org/browse/WFLY-7104 properties.store(fos, "$REALM_NAME=" + name + "$"); } return result; }
private File writeProperties(Properties properties, String fileName) throws IOException { File result = new File(tempFolder, fileName); LOGGER.debugv("Creating property file {0}", result); try (FileOutputStream fos = new FileOutputStream(result)) { // comment $REALM_NAME is just a workaround for https://issues.jboss.org/browse/WFLY-7104 properties.store(fos, "$REALM_NAME=" + name + "$"); } return result; }
protected static String moduleNameFor(String componentFQN) { String moduleName = MODULE_NAME_BY_COMPONENT_FQN.getProperty(componentFQN); if (StringUtil.isBlank(moduleName)) { int index = componentFQN.lastIndexOf("."); moduleName = index != -1 ? componentFQN.substring(0, index) : componentFQN; } LOG.debugv("Module name for {0} has been resolved to {1}", componentFQN, moduleName); return moduleName; } }
public ConstraintBuilder constraint(String pattern) { log.debugv("add constraint: {0}", pattern); return new ConstraintBuilder(pattern); }
protected void handleFile(File file, BeanArchiveBuilder builder) throws IOException { log.debugv("Handle archive file: {0}", file); try (ZipFile zip = new ZipFile(file)) { Enumeration<? extends ZipEntry> entries = zip.entries(); ZipFileEntry entry = new ZipFileEntry(PROCOTOL_JAR + ":" + file.toURI().toURL().toExternalForm() + JAR_URL_SEPARATOR); while (entries.hasMoreElements()) { add(entry.setName(entries.nextElement().getName()), builder); } } }
protected void handleFile(File file, BeanArchiveBuilder builder) throws IOException { log.debugv("Handle archive file: {0}", file); try (ZipFile zip = new ZipFile(file)) { Enumeration<? extends ZipEntry> entries = zip.entries(); ZipFileEntry entry = new ZipFileEntry(PROCOTOL_JAR + ":" + file.toURI().toURL().toExternalForm() + JAR_URL_SEPARATOR); while (entries.hasMoreElements()) { add(entry.setName(entries.nextElement().getName()), builder); } } }
protected void handleFile(File file, BeanArchiveBuilder builder) throws IOException { log.debugv("Handle archive file: {0}", file); try (ZipFile zip = new ZipFile(file)) { Enumeration<? extends ZipEntry> entries = zip.entries(); ZipFileEntry entry = new ZipFileEntry(PROCOTOL_JAR + ":" + file.toURI().toURL().toExternalForm() + JAR_URL_SEPARATOR); while (entries.hasMoreElements()) { add(entry.setName(entries.nextElement().getName()), builder); } } }
protected void handleFile(File file, BeanArchiveBuilder builder) throws IOException { log.debugv("Handle archive file: {0}", file); try (ZipFile zip = new ZipFile(file)) { Enumeration<? extends ZipEntry> entries = zip.entries(); ZipFileEntry entry = new ZipFileEntry(PROCOTOL_JAR + ":" + file.toURI().toURL().toExternalForm() + JAR_URL_SEPARATOR); while (entries.hasMoreElements()) { add(entry.setName(entries.nextElement().getName()), builder); } } }
protected void handleFile(File file, BeanArchiveBuilder builder) throws IOException { log.debugv("Handle archive file: {0}", file); try (ZipFile zip = new ZipFile(file)) { Enumeration<? extends ZipEntry> entries = zip.entries(); ZipFileEntry entry = new ZipFileEntry(PROCOTOL_JAR + ":" + file.toURI().toURL().toExternalForm() + JAR_URL_SEPARATOR); while (entries.hasMoreElements()) { add(entry.setName(entries.nextElement().getName()), builder); } } }
protected void handleFile(File file, BeanArchiveBuilder builder) throws IOException { log.debugv("Handle archive file: {0}", file); try (ZipFile zip = new ZipFile(file)) { Enumeration<? extends ZipEntry> entries = zip.entries(); ZipFileEntry entry = new ZipFileEntry(PROCOTOL_JAR + ":" + file.toURI().toURL().toExternalForm() + JAR_URL_SEPARATOR); while (entries.hasMoreElements()) { add(entry.setName(entries.nextElement().getName()), builder); } } }
protected void ensureIndex(String name, String[] fields, boolean unique, boolean sparse) { DBCollection col = db.getCollection(name); BasicDBObject o = new BasicDBObject(); for (String f : fields) { o.append(f, 1); } col.createIndex(o, new BasicDBObject("unique", unique).append("sparse", sparse)); log.debugv("Created index {0}, fields={1}, unique={2}, sparse={3}", name, Arrays.toString(fields), unique, sparse); }
private void convertOAuthClientsToClients() { DBCollection clients = db.getCollection("clients"); DBCollection oauthClients = db.getCollection("oauthClients"); oauthClients.dropIndex("realmId_1_name_1"); oauthClients.update(new BasicDBObject(), new BasicDBObject("$rename", new BasicDBObject("name", "clientId")), false, true); oauthClients.update(new BasicDBObject(), new BasicDBObject("$set", new BasicDBObject("consentRequired", true)), false, true); DBCursor curs = oauthClients.find(); while (curs.hasNext()) { clients.insert(curs.next()); } oauthClients.drop(); log.debugv("Converted oauthClients to clients"); }
public boolean handledRequest() { log.debugv("AuthenticatedActionsValve.invoke {0}", facade.getRequest().getURI()); if (corsRequest()) return true; String requestUri = facade.getRequest().getURI(); if (requestUri.endsWith(AdapterConstants.K_QUERY_BEARER_TOKEN)) { queryBearerToken(); return true; } if (!isAuthorized()) { return true; } return false; }
protected void queryBearerToken() { log.debugv("queryBearerToken {0}",facade.getRequest().getURI()); if (abortTokenResponse()) return; facade.getResponse().setStatus(200); facade.getResponse().setHeader("Content-Type", "text/plain"); try { facade.getResponse().getOutputStream().write(facade.getSecurityContext().getTokenString().getBytes()); } catch (IOException e) { throw new RuntimeException(e); } facade.getResponse().end(); }
protected void completeAuthentication(BearerTokenRequestAuthenticator bearer, String method) { RefreshableKeycloakSecurityContext session = new RefreshableKeycloakSecurityContext(deployment, null, bearer.getTokenString(), bearer.getToken(), null, null, null); final KeycloakPrincipal<RefreshableKeycloakSecurityContext> principal = new KeycloakPrincipal<RefreshableKeycloakSecurityContext>(AdapterUtils.getPrincipalName(deployment, bearer.getToken()), session); completeBearerAuthentication(principal, method); log.debugv("User ''{0}'' invoking ''{1}'' on client ''{2}''", principal.getName(), facade.getRequest().getURI(), deployment.getResourceName()); }
private void addRealmCodeSecret() { DBCollection realms = db.getCollection("realms"); DBObject query = new QueryBuilder() .and("codeSecret").is(null).get(); DBCursor objects = realms.find(query); while (objects.hasNext()) { DBObject object = objects.next(); object.put("codeSecret", KeycloakModelUtils.generateCodeSecret()); realms.save(object); log.debugv("Added realm.codeSecret, id={0}", object.get("id")); } }
protected void completeAuthentication(OAuthRequestAuthenticator oauth) { RefreshableKeycloakSecurityContext session = new RefreshableKeycloakSecurityContext(deployment, tokenStore, oauth.getTokenString(), oauth.getToken(), oauth.getIdTokenString(), oauth.getIdToken(), oauth.getRefreshToken()); final KeycloakPrincipal<RefreshableKeycloakSecurityContext> principal = new KeycloakPrincipal<RefreshableKeycloakSecurityContext>(AdapterUtils.getPrincipalName(deployment, oauth.getToken()), session); completeOAuthAuthentication(principal); log.debugv("User ''{0}'' invoking ''{1}'' on client ''{2}''", principal.getName(), facade.getRequest().getURI(), deployment.getResourceName()); }