Skip to content

Commit

Permalink
Moved some classes into common package.
Browse files Browse the repository at this point in the history
  • Loading branch information
endisd committed Feb 17, 2009
1 parent a2a055d commit c4a9ec4
Show file tree
Hide file tree
Showing 59 changed files with 544 additions and 245 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import org.slf4j.LoggerFactory;
import org.safehaus.penrose.client.BaseClient;
import org.safehaus.penrose.client.PenroseClient;
import org.safehaus.penrose.connection.ConnectionServiceMBean;

/**
* @author Endi Sukma Dewata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.safehaus.penrose.partition.PartitionManagerClient;
import org.safehaus.penrose.client.PenroseClient;
import org.safehaus.penrose.client.BaseClient;
import org.safehaus.penrose.ldap.DN;
import org.apache.log4j.Level;
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.PatternLayout;
Expand Down Expand Up @@ -70,6 +71,14 @@ public void validateConnection(ConnectionConfig connectionConfig) throws Excepti
);
}

public Collection<DN> getNamingContexts(ConnectionConfig connectionConfig) throws Exception {
return (Collection<DN>)invoke(
"getNamingContexts",
new Object[] { connectionConfig },
new String[] { ConnectionConfig.class.getName() }
);
}

public void createConnection(ConnectionConfig connectionConfig) throws Exception {
invoke(
"createConnection",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.safehaus.penrose.ldap.connection;

import org.safehaus.penrose.client.PenroseClient;
import org.safehaus.penrose.connection.ConnectionClient;
import org.safehaus.penrose.ldap.SearchResult;
import org.safehaus.penrose.ldap.DN;
import org.safehaus.penrose.ldap.SearchResponse;
import org.safehaus.penrose.ldap.SearchRequest;
import org.safehaus.penrose.schema.Schema;

/**
* @author Endi Sukma Dewata
*/
public class LDAPConnectionClient extends ConnectionClient implements LDAPConnectionServiceMBean {

public LDAPConnectionClient(PenroseClient client, String partitionName, String connectionName) throws Exception {
super(client, partitionName, connectionName);
}

public SearchResult find(String dn) throws Exception {
return (SearchResult)invoke(
"find",
new Object[] { dn },
new String[] { String.class.getName() }
);
}

public SearchResult find(DN dn) throws Exception {
return (SearchResult)invoke(
"find",
new Object[] { dn },
new String[] { DN.class.getName() }
);
}

public SearchResponse search(SearchRequest request, SearchResponse response) throws Exception {
return (SearchResponse)invoke(
"search",
new Object[] { request, response },
new String[] { SearchRequest.class.getName(), SearchResponse.class.getName() }
);
}

public Schema getSchema() throws Exception {
return (Schema)getAttribute("Schema");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.safehaus.penrose.schema.Schema;
import org.safehaus.penrose.schema.ObjectClass;
import org.safehaus.penrose.schema.AttributeType;
import org.safehaus.penrose.schema.attributeSyntax.AttributeSyntax;

import java.util.Collection;

Expand Down Expand Up @@ -121,4 +122,12 @@ public Collection<String> getAllObjectClassNames(String ocName) throws Exception
public Schema getMergedSchema() throws Exception {
return (Schema)getAttribute("MergedSchema");
}

public AttributeSyntax getAttributeSyntax(String oid) throws Exception {
return (AttributeSyntax) invoke(
"getAttributeSyntax",
new Object[] { oid },
new String[] { String.class.getName() }
);
}
}
8 changes: 7 additions & 1 deletion common/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,16 @@
<target name="javacc" depends="init">
<attrib file="src/java/org/safehaus/penrose/filter/*.java" readonly="false"/>
<javacc
target="../common/src/java/org/safehaus/penrose/filter/FilterParser.jj"
target="src/java/org/safehaus/penrose/filter/FilterParser.jj"
javacchome="../lib/javacc"
outputdirectory="src/java/org/safehaus/penrose/filter"
/>
<attrib file="src/java/org/safehaus/penrose/schema/*.java" readonly="false"/>
<javacc
target="src/java/org/safehaus/penrose/schema/LDAPv3Schema.jj"
javacchome="../lib/javacc"
outputdirectory="src/java/org/safehaus/penrose/schema"
/>
</target>

<target name="compile" depends="init">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.safehaus.penrose.connection;

import org.safehaus.penrose.ldap.DN;

import java.util.Collection;
import java.util.Map;

Expand All @@ -9,7 +11,10 @@
public interface ConnectionManagerServiceMBean {

public Collection<String> getConnectionNames() throws Exception;

public void validateConnection(ConnectionConfig connectionConfig) throws Exception;
public Collection<DN> getNamingContexts(ConnectionConfig connectionConfig) throws Exception;

public void createConnection(ConnectionConfig connectionConfig) throws Exception;
public void renameConnection(String name, String newName) throws Exception;
public void updateConnection(ConnectionConfig connectionConfig) throws Exception;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.safehaus.penrose.connection;

import org.safehaus.penrose.connection.ConnectionConfig;

/**
* @author Endi Sukma Dewata
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.safehaus.penrose.federation.module;
package org.safehaus.penrose.federation;

import org.safehaus.penrose.ldap.Attributes;
import org.safehaus.penrose.ldap.DN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ final public Filter Item() throws ParseException {
filter = new SimpleFilter(attr, "=", FilterTool.unescape(value));

} else {
Collection<Object> values = new ArrayList<Object>();
Collection values = new ArrayList();
StringTokenizer st = new StringTokenizer(value, "*", true);
while (st.hasMoreTokens()) {
String token = st.nextToken();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ Filter Item() :
filter = new SimpleFilter(attr, "=", FilterTool.unescape(value));

} else {
Collection<Object> values = new ArrayList<Object>();
Collection values = new ArrayList();
StringTokenizer st = new StringTokenizer(value, "*", true);
while (st.hasMoreTokens()) {
String token = st.nextToken();
Expand Down
35 changes: 35 additions & 0 deletions common/src/java/org/safehaus/penrose/jdbc/JDBC.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.safehaus.penrose.jdbc;

/**
* @author Endi Sukma Dewata
*/
public class JDBC {

public final static String DRIVER = "driver";
public final static String URL = "url";
public final static String USER = "user";
public final static String PASSWORD = "password";

public final static String BASE_DN = "baseDn";
public final static String CATALOG = "catalog";
public final static String SCHEMA = "schema";
public final static String TABLE = "table";
public final static String FILTER = "filter";

public final static String SIZE_LIMIT = "sizeLimit";
public final static String CREATE = "create";

public final static String AUTHENTICATION = "authentication";
public final static String AUTHENTICATION_DEFAULT = "default";
public final static String AUTHENTICATION_FULL = "full";
public final static String AUTHENTICATION_DISABLED = "disabled";

public final static String ADD = "add";
public final static String BIND = "bind";
public final static String COMPARE = "compare";
public final static String DELETE = "delete";
public final static String MODIFY = "modify";
public final static String MODRDN = "modrdn";
public final static String SEARCH = "search";
public final static String UNBIND = "unbind";
}
15 changes: 15 additions & 0 deletions common/src/java/org/safehaus/penrose/ldap/LDAP.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ public class LDAP {

public static Logger log = LoggerFactory.getLogger(LDAP.class);

public final static String BASE_DN = "baseDn";
public final static String NEW_BASE_DN = "newBaseDn";
public final static String SCOPE = "scope";
public final static String FILTER = "filter";
public final static String OBJECT_CLASSES = "objectClasses";

public final static String SIZE_LIMIT = "sizeLimit";
public final static String TIME_LIMIT = "timeLimit";
public final static String ATTRIBUTES = "attributes";

public final static String AUTHENTICATION = "authentication";
public final static String AUTHENTICATION_DEFAULT = "default";
public final static String AUTHENTICATION_FULL = "full";
public final static String AUTHENTICATION_DISABLED = "disabled";

public final static DN ROOT_DSE_DN = new DN("");
public final static DN SCHEMA_DN = new DN("cn=Subschema");

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.safehaus.penrose.ldap.connection;

import org.safehaus.penrose.ldap.SearchResult;
import org.safehaus.penrose.ldap.DN;
import org.safehaus.penrose.ldap.SearchResponse;
import org.safehaus.penrose.ldap.SearchRequest;
import org.safehaus.penrose.schema.Schema;

/**
* @author Endi Sukma Dewata
*/
public interface LDAPConnectionServiceMBean {

public SearchResult find(String dn) throws Exception;
public SearchResult find(DN dn) throws Exception;

public SearchResponse search(SearchRequest request, SearchResponse response) throws Exception;

public Schema getSchema() throws Exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
package org.safehaus.penrose.mapping;

import java.io.ByteArrayInputStream;
import java.util.*;

import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ PARSER_BEGIN(SchemaParser)
package org.safehaus.penrose.schema;

import java.util.*;
import org.safehaus.penrose.config.*;

/**
* LDAP Schema Parser.
Expand Down Expand Up @@ -93,14 +92,14 @@ import org.safehaus.penrose.config.*;
*/
public class SchemaParser {

List schema = new ArrayList();
Schema schema = new Schema();
List errors = new ArrayList();

/**
* Start parsing
* @return the list of schema
*/
public List parse() throws ParseException {
public Schema parse() throws ParseException {
try {
Schema();
} catch (ParseException ex) {
Expand All @@ -111,7 +110,7 @@ public class SchemaParser {
/**
* Get the list of schema from parsing
*/
public List getSchema() {
public Schema getSchema() {
return this.schema;
}

Expand Down Expand Up @@ -200,9 +199,9 @@ void Schema() :
{
(
LOOKAHEAD( <ATTRIBUTETYPE> )
at = AttributeType() { schema.add(at); }
at = AttributeType() { schema.addAttributeType(at); }
| LOOKAHEAD( <OBJECTCLASS> )
oc = ObjectClass() { schema.add(oc); }
oc = ObjectClass() { schema.addObjectClass(oc); }
)*
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public String getMessage() {
* string literal.
*/
protected String add_escapes(String str) {
StringBuilder retval = new StringBuilder();
StringBuffer retval = new StringBuffer();
char ch;
for (int i = 0; i < str.length(); i++) {
switch (str.charAt(i))
Expand Down
3 changes: 3 additions & 0 deletions common/src/java/org/safehaus/penrose/schema/Schema.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public class Schema implements Serializable, Cloneable {
protected Set<ObjectClass> objectClasses = new LinkedHashSet<ObjectClass>();
protected Map<String,ObjectClass> objectClassesByNameOrOid = new TreeMap<String,ObjectClass>();

public Schema() {
}

public Schema(String name) {
this.name = name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.safehaus.penrose.schema.Schema;
import org.safehaus.penrose.schema.ObjectClass;
import org.safehaus.penrose.schema.AttributeType;
import org.safehaus.penrose.schema.attributeSyntax.AttributeSyntax;

import java.util.Collection;

Expand Down Expand Up @@ -31,4 +32,6 @@ public interface SchemaManagerServiceMBean {
public Collection<ObjectClass> getAllObjectClasses(String ocName) throws Exception;
public Collection<String> getAllObjectClassNames(String ocName) throws Exception;
public Schema getMergedSchema() throws Exception;

public AttributeSyntax getAttributeSyntax(String oid) throws Exception;
}
Loading

0 comments on commit c4a9ec4

Please sign in to comment.