Skip to content

Commit

Permalink
#87 Add generics to the API
Browse files Browse the repository at this point in the history
Signed-off-by: arjantijms <arjan.tijms@gmail.com>
  • Loading branch information
arjantijms committed Nov 28, 2021
1 parent 5b44640 commit c5436c9
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 36 deletions.
Expand Up @@ -69,6 +69,6 @@ public interface MessageInfo {
* @return the Map object of this MessageInfo. This method never returns null. If a Map has not been associated with the
* MessageInfo, this method instantiates a Map, associates it with this MessageInfo, and then returns it.
*/
Map getMap();
Map<String, Object> getMap();

}
Expand Up @@ -66,10 +66,10 @@
* <li>The fully qualified name of the provider implementation class (or null)
* <li>The list of provider initialization properties (which could be empty)
* </ul>
*
*
* Any provider initialization properties must be specified in a form that can be passed to the provider constructor
* within a Map of key, value pairs, and where all keys and values within the Map are of type String.
*
*
* <p>
* The entry syntax must also provide for the optional inclusion of information sufficient to define a
* RegistrationContext. This information would only be present when the factory will register the provider. For example,
Expand All @@ -79,11 +79,11 @@
* <li>The application context identifier (or null)
* <li>The registration description (or null)
* </ul>
*
*
* When a RegistrationContext is not included, the factory must make it convenient for the provider to self-register
* with the factory during the provider construction (see
* <code>registerConfigProvider(AuthConfigProvider provider, ...)</code>).
*
*
* <p>
* An AuthConfigFactory implementation is free to choose is own persistent declarative syntax as long as it conforms to
* the requirements defined by this class.
Expand Down Expand Up @@ -171,11 +171,11 @@ private static void checkPermission(Permission permission) throws SecurityExcept
* class is obtained from the value of the {@link #DEFAULT_FACTORY_SECURITY_PROPERTY} security property. When an
* instance of the default factory implementation class is successfully constructed by this method, this method will set
* it as the system-wide factory instance.
*
*
* <p>
* The absolute pathname of the Java security properties file is JAVA_HOME/lib/security/java.security, where JAVA_HOME
* refers to the directory where the JDK was installed.
*
*
* <p>
* When a SecurityManager is enabled, the {@link #getFactorySecurityPermission} will be required to call this method. If
* at the time of the call, a system-wide factory instance has not already been defined, then the
Expand All @@ -193,19 +193,20 @@ private static void checkPermission(Permission permission) throws SecurityExcept
*/
public static synchronized AuthConfigFactory getFactory() {
checkPermission(getFactorySecurityPermission);

if (AuthConfigFactory.factory == null) {
final String className = Security.getProperty(DEFAULT_FACTORY_SECURITY_PROPERTY);
if (className != null) {
checkPermission(setFactorySecurityPermission);
try {
AuthConfigFactory.factory = AccessController.doPrivileged(new PrivilegedExceptionAction<AuthConfigFactory>() {


@Override
public AuthConfigFactory run() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
return (AuthConfigFactory)
return (AuthConfigFactory)
Class.forName(
className,
true,
className,
true,
Thread.currentThread().getContextClassLoader())
.newInstance();
}
Expand All @@ -215,7 +216,7 @@ public AuthConfigFactory run() throws ClassNotFoundException, InstantiationExcep
}
}
}

return AuthConfigFactory.factory;
}

Expand Down Expand Up @@ -280,14 +281,14 @@ public static synchronized void setFactory(AuthConfigFactory factory) {
* Registers within the factory and records within the factory's persistent declarative representation of provider
* registrations a provider of ServerAuthConfig and/or ClientAuthConfig objects for a message layer and application
* context identifier.
*
*
* This method typically constructs an instance of the provider before registering it with the factory. Factories may
* extend or modify the persisted registrations of existing provider instances, if those instances were registered with
* ClassName and properties arguments equivalent to those passed in the current call.
* <P>
* This method employs the two argument constructor required to be supported by every implementation of the
* AuthConfigProvider interface, and this method must pass a null value for the factory argument of the constructor.
* <code>AuthConfigProviderImpl AuthConfigProviderImpl(Map properties,
* <code>AuthConfigProviderImpl AuthConfigProviderImpl(Map properties,
* AuthConfigFactory factory)</code>.
*
* <P>
Expand All @@ -300,7 +301,7 @@ public static synchronized void setFactory(AuthConfigFactory factory) {
* Within the lifetime of its Java process, a factory must assign unique registration identifiers to registrations, and
* must never assign a previously used registration identifier to a registration whose message layer and or appContext
* identifier differ from the previous use.
*
*
* <p>
* Programmatic registrations performed by using this method must update (according to the replacement rules described
* above) the persistent declarative representation of provider registrations employed by the factory constructor.
Expand All @@ -309,15 +310,14 @@ public static synchronized void setFactory(AuthConfigFactory factory) {
* When a SecurityManager is enabled, before loading the argument provider, and before making any changes to the
* factory, this method must confirm that the calling access control context has been granted the
* {@link #providerRegistrationSecurityPermission}
*
*
*
*
* @param className The fully qualified name of an AuthConfigProvider implementation class (or null). Calling this
* method with a null value for this parameter shall cause <code>getConfigProvider</code> to return null when it is
* called with layer and appContext values for which the resulting registration is the best match.
*
* @param properties A Map object containing the initialization properties to be passed to the properties argument of
* the provider constructor. This argument may be null. When this argument is not null, all the values and keys
* occurring in the Map must be of type String.
* the provider constructor. This argument may be null.
*
* @param layer A String identifying the message layer for which the provider will be registered at the factory. A null
* value may be passed as an argument for this parameter, in which case the provider is registered at all layers.
Expand All @@ -335,7 +335,7 @@ public static synchronized void setFactory(AuthConfigFactory factory) {
* the provider construction (given a non-null <code>className</code>) or registration fails.
*
*/
public abstract String registerConfigProvider(String className, Map properties, String layer, String appContext, String description);
public abstract String registerConfigProvider(String className, Map<String, String> properties, String layer, String appContext, String description);

/**
* Registers within the (in-memory) factory, a provider of ServerAuthConfig and/or ClientAuthConfig objects for a
Expand All @@ -352,11 +352,11 @@ public static synchronized void setFactory(AuthConfigFactory factory) {
* Within the lifetime of its Java process, a factory must assign unique registration identifiers to registrations, and
* must never assign a previously used registration identifier to a registration whose message layer and or appContext
* identifier differ from the previous use.
*
*
* <P>
* When a SecurityManager is enabled, and before making any changes to the factory, this method must confirm that the
* calling access control context has been granted the {@link #providerRegistrationSecurityPermission}
*
*
* @param provider The AuthConfigProvider to be registered at the factory (or null). Calling this method with a null
* value for this parameter shall cause <code>getConfigProvider</code> to return null when it is called with layer and
* appContext values for which the resulting registration is the best match.
Expand All @@ -381,7 +381,7 @@ public static synchronized void setFactory(AuthConfigFactory factory) {
/**
* Remove the identified provider registration from the factory (and from the persistent declarative representation of
* provider registrations, if appropriate) and invoke any listeners associated with the removed registration.
*
*
* <P>
* When a SecurityManager is enabled, and before making any changes to the factory, this method must confirm that the
* calling access control context has been granted the {@link #providerRegistrationSecurityPermission}
Expand All @@ -401,7 +401,7 @@ public static synchronized void setFactory(AuthConfigFactory factory) {
* corresponding arguments to this method.
* <p>
* Factories should periodically notify Listeners to effectively detach listeners that are no longer in use.
*
*
* <P>
* When a SecurityManager is enabled, and before making any changes to the factory, this method must confirm that the
* calling access control context has been granted the {@link #providerRegistrationSecurityPermission}
Expand Down Expand Up @@ -450,7 +450,7 @@ public static synchronized void setFactory(AuthConfigFactory factory) {
* <p>
* A factory should only replace an existing registration when a change of provider implementation class or
* initialization properties has occurred.
*
*
* <P>
* When a SecurityManager is enabled, and before the point where this method could have caused any changes to the
* factory, this method must confirm that the calling access control context has been granted the
Expand Down
Expand Up @@ -54,12 +54,12 @@ public interface ClientAuthConfig extends AuthConfig {
* <p>
* Specifically, this method accesses this ClientAuthConfig object with the argument <i>authContextID</i> to determine
* the ClientAuthModules that are to be encapsulated in the returned ClientAuthContext instance.
*
*
* <P>
* The ClientAuthConfig object establishes the request and response MessagePolicy objects that are passed to the
* encapsulated modules when they are initialized by the returned ClientAuthContext instance. It is the modules'
* responsibility to enforce these policies when invoked.
*
*
* @param authContextID An String identifier used to index the provided <i>config</i>, or null. This value must be
* identical to the value returned by the <code>getAuthContextID</code> method for all <code>MessageInfo</code> objects
* passed to the <code>secureRequest</code> method of the returned ClientAuthContext.
Expand All @@ -78,6 +78,6 @@ public interface ClientAuthConfig extends AuthConfig {
*
* @exception AuthException If this method fails.
*/
ClientAuthContext getAuthContext(String authContextID, Subject clientSubject, Map properties) throws AuthException;
ClientAuthContext getAuthContext(String authContextID, Subject clientSubject, Map<String, Object> properties) throws AuthException;

}
Expand Up @@ -54,12 +54,12 @@ public interface ServerAuthConfig extends AuthConfig {
* <p>
* Specifically, this method accesses this ServerAuthConfig object with the argument <i>authContextID</i> to determine
* the ServerAuthModules that are to be encapsulated in the returned ServerAuthContext instance.
*
*
* <P>
* The ServerAuthConfig object establishes the request and response MessagePolicy objects that are passed to the
* encapsulated modules when they are initialized by the returned ServerAuthContext instance. It is the modules'
* responsibility to enforce these policies when invoked.
*
*
* @param authContextID An identifier used to index the provided <i>config</i>, or null. This value must be identical to
* the value returned by the <code>getAuthContextID</code> method for all <code>MessageInfo</code> objects passed to the
* <code>validateRequest</code> method of the returned ServerAuthContext.
Expand All @@ -78,6 +78,6 @@ public interface ServerAuthConfig extends AuthConfig {
*
* @exception AuthException If this method fails.
*/
ServerAuthContext getAuthContext(String authContextID, Subject serviceSubject, Map properties) throws AuthException;
ServerAuthContext getAuthContext(String authContextID, Subject serviceSubject, Map<String, Object> properties) throws AuthException;

}
Expand Up @@ -59,7 +59,7 @@ public interface ClientAuthModule extends ClientAuth {
* @exception AuthException If module initialization fails, including for the case where the options argument contains
* elements that are not supported by the module.
*/
void initialize(MessagePolicy requestPolicy, MessagePolicy responsePolicy, CallbackHandler handler, Map options) throws AuthException;
void initialize(MessagePolicy requestPolicy, MessagePolicy responsePolicy, CallbackHandler handler, Map<String, Object> options) throws AuthException;

/**
* Get the one or more Class objects representing the message types supported by the module.
Expand All @@ -68,6 +68,6 @@ public interface ClientAuthModule extends ClientAuth {
* return an array containing at least one element. An empty array indicates that the module will attempt to support any
* message type. This method never returns null.
*/
Class[] getSupportedMessageTypes();
Class<?>[] getSupportedMessageTypes();

}
Expand Up @@ -59,13 +59,13 @@ public interface ServerAuthModule extends ServerAuth {
* @exception AuthException If module initialization fails, including for the case where the options argument contains
* elements that are not supported by the module.
*/
void initialize(MessagePolicy requestPolicy, MessagePolicy responsePolicy, CallbackHandler handler, Map options) throws AuthException;
void initialize(MessagePolicy requestPolicy, MessagePolicy responsePolicy, CallbackHandler handler, Map<String, Object> options) throws AuthException;

/**
* Get the one or more Class objects representing the message types supported by the module.
*
* @return An array of Class objects, with at least one element defining a message type supported by the module.
*/
Class[] getSupportedMessageTypes();
Class<?>[] getSupportedMessageTypes();

}

0 comments on commit c5436c9

Please sign in to comment.