Este contenido no está disponible en el idioma seleccionado.
Chapter 10. Security Configuration
This chapter discusses the
SecurityConfiguration class, which configures various managers in the Security Context. SecurityConfiguration has the following static methods:
package org.jboss.security.config;
import java.security.Key;
import java.security.spec.AlgorithmParameterSpec;
import java.util.HashMap;
/**
* Class that provides the Configuration for authentication,
* authorization, mapping information, etc.
* It also holds the information like JSSE keystores, keytypes and
* other crypto configuration
*/
public class SecurityConfiguration
{
/**
* Map of Application Policies keyed in by name
*/
private static HashMap appPolicies = new HashMap();
private static String cipherAlgorithm;
private static int iterationCount;
private static String salt;
private static String keyStoreType;
private static String keyStoreURL;
private static String keyStorePass;
private static String trustStoreType;
private static String trustStorePass;
private static String trustStoreURL;
private static Key cipherKey;
private static AlgorithmParameterSpec cipherSpec;
public static void addApplicationPolicy(ApplicationPolicy aP)
{
if(aP == null)
throw new IllegalArgumentException("application policy is null");
appPolicies.put(aP.getName(), aP);
}
public static ApplicationPolicy getApplicationPolicy(String policyName)
{
return (ApplicationPolicy)appPolicies.get(policyName);
}
public static String getCipherAlgorithm()
{
return cipherAlgorithm;
}
public static void setCipherAlgorithm(String ca)
{
cipherAlgorithm = ca;
}
public static Key getCipherKey()
{
return cipherKey;
}
public static void setCipherKey(Key ca)
{
cipherKey = ca;
}
public static AlgorithmParameterSpec getCipherSpec()
{
return cipherSpec;
}
public static void setCipherSpec(AlgorithmParameterSpec aps)
{
cipherSpec = aps;
}
public static int getIterationCount()
{
return iterationCount;
}
/** Set the iteration count used with PBE based on the keystore password.
* @param count - an iteration count randomization value
*/
public static void setIterationCount(int count)
{
iterationCount = count;
}
public static String getSalt()
{
return salt;
}
/** Set the salt used with PBE based on the keystore password.
* @param salt - an 8 char randomization string
*/
public static void setSalt(String s)
{
salt = s;
}
/** KeyStore implementation type being used.
@return the KeyStore implementation type being used.
*/
public static String getKeyStoreType()
{
return keyStoreType;
}
/** Set the type of KeyStore implementation to use. This is
passed to the KeyStore.getInstance() factory method.
*/
public static void setKeyStoreType(String type)
{
keyStoreType = type;
}
/** Get the KeyStore database URL string.
*/
public static String getKeyStoreURL()
{
return keyStoreURL;
}
/** Set the KeyStore database URL string. This is used to obtain
an InputStream to initialize the KeyStore.
*/
public static void setKeyStoreURL(String storeURL)
{
keyStoreURL = storeURL;
}
/** Get the credential string for the KeyStore.
*/
public static String getKeyStorePass()
{
return keyStorePass ;
}
/** Set the credential string for the KeyStore.
*/
public static void setKeyStorePass(String password)
{
keyStorePass = password;
}
/** Get the type of the trust store
* @return the type of the trust store
*/
public static String getTrustStoreType()
{
return trustStoreType;
}
/** Set the type of the trust store
* @param type - the trust store implementation type
*/
public static void setTrustStoreType(String type)
{
trustStoreType = type;
}
/** Set the credential string for the trust store.
*/
public static String getTrustStorePass()
{
return trustStorePass;
}
/** Set the credential string for the trust store.
*/
public static void setTrustStorePass(String password)
{
trustStorePass = password;
}
/** Get the trust store database URL string.
*/
public static String getTrustStoreURL()
{
return trustStoreURL;
}
/** Set the trust store database URL string. This is used to obtain
an InputStream to initialize the trust store.
*/
public static void setTrustStoreURL(String storeURL)
{
trustStoreURL = storeURL;
}
}
package org.jboss.security.config;
import java.security.Key;
import java.security.spec.AlgorithmParameterSpec;
import java.util.HashMap;
/**
* Class that provides the Configuration for authentication,
* authorization, mapping information, etc.
* It also holds the information like JSSE keystores, keytypes and
* other crypto configuration
*/
public class SecurityConfiguration
{
/**
* Map of Application Policies keyed in by name
*/
private static HashMap appPolicies = new HashMap();
private static String cipherAlgorithm;
private static int iterationCount;
private static String salt;
private static String keyStoreType;
private static String keyStoreURL;
private static String keyStorePass;
private static String trustStoreType;
private static String trustStorePass;
private static String trustStoreURL;
private static Key cipherKey;
private static AlgorithmParameterSpec cipherSpec;
public static void addApplicationPolicy(ApplicationPolicy aP)
{
if(aP == null)
throw new IllegalArgumentException("application policy is null");
appPolicies.put(aP.getName(), aP);
}
public static ApplicationPolicy getApplicationPolicy(String policyName)
{
return (ApplicationPolicy)appPolicies.get(policyName);
}
public static String getCipherAlgorithm()
{
return cipherAlgorithm;
}
public static void setCipherAlgorithm(String ca)
{
cipherAlgorithm = ca;
}
public static Key getCipherKey()
{
return cipherKey;
}
public static void setCipherKey(Key ca)
{
cipherKey = ca;
}
public static AlgorithmParameterSpec getCipherSpec()
{
return cipherSpec;
}
public static void setCipherSpec(AlgorithmParameterSpec aps)
{
cipherSpec = aps;
}
public static int getIterationCount()
{
return iterationCount;
}
/** Set the iteration count used with PBE based on the keystore password.
* @param count - an iteration count randomization value
*/
public static void setIterationCount(int count)
{
iterationCount = count;
}
public static String getSalt()
{
return salt;
}
/** Set the salt used with PBE based on the keystore password.
* @param salt - an 8 char randomization string
*/
public static void setSalt(String s)
{
salt = s;
}
/** KeyStore implementation type being used.
@return the KeyStore implementation type being used.
*/
public static String getKeyStoreType()
{
return keyStoreType;
}
/** Set the type of KeyStore implementation to use. This is
passed to the KeyStore.getInstance() factory method.
*/
public static void setKeyStoreType(String type)
{
keyStoreType = type;
}
/** Get the KeyStore database URL string.
*/
public static String getKeyStoreURL()
{
return keyStoreURL;
}
/** Set the KeyStore database URL string. This is used to obtain
an InputStream to initialize the KeyStore.
*/
public static void setKeyStoreURL(String storeURL)
{
keyStoreURL = storeURL;
}
/** Get the credential string for the KeyStore.
*/
public static String getKeyStorePass()
{
return keyStorePass ;
}
/** Set the credential string for the KeyStore.
*/
public static void setKeyStorePass(String password)
{
keyStorePass = password;
}
/** Get the type of the trust store
* @return the type of the trust store
*/
public static String getTrustStoreType()
{
return trustStoreType;
}
/** Set the type of the trust store
* @param type - the trust store implementation type
*/
public static void setTrustStoreType(String type)
{
trustStoreType = type;
}
/** Set the credential string for the trust store.
*/
public static String getTrustStorePass()
{
return trustStorePass;
}
/** Set the credential string for the trust store.
*/
public static void setTrustStorePass(String password)
{
trustStorePass = password;
}
/** Get the trust store database URL string.
*/
public static String getTrustStoreURL()
{
return trustStoreURL;
}
/** Set the trust store database URL string. This is used to obtain
an InputStream to initialize the trust store.
*/
public static void setTrustStoreURL(String storeURL)
{
trustStoreURL = storeURL;
}
}
The
SecurityConfiguration can hold a map of ApplicationPolicy objects that are identified with names associated with that of the Security Domain. The SecurityConfiguration class also provides commonly-used Java Cryptography Architecture (JCA) information where required.
The
ApplicationPolicy class combines the AuthenticationInfo, AuthorizationInfo, MappingInfo and AuditInfo classes, which drive the configuration of individual context managers in the Security Context.
package org.jboss.security.config;
import org.jboss.security.auth.login.BaseAuthenticationInfo;
/**
* Application Policy Information Holder
* - Authentication
* - Authorization
* - Audit
* - Mapping
*/
public class ApplicationPolicy
{
private String name;
private BaseAuthenticationInfo authenticationInfo;
private AuthorizationInfo authorizationInfo;
private AuditInfo auditInfo;
private MappingInfo roleMappingInfo;
//Parent PolicyConfig
private PolicyConfig policyConfig;
public ApplicationPolicy(String theName)
{
if(theName == null)
throw new IllegalArgumentException("name is null");
this.name = theName;
}
public ApplicationPolicy(String theName,BaseAuthenticationInfo info)
{
this(theName);
authenticationInfo = info;
}
public ApplicationPolicy(String theName,AuthorizationInfo info)
{ :p
this(theName);
authorizationInfo = info;
}
public ApplicationPolicy(String theName,
BaseAuthenticationInfo info, AuthorizationInfo info2)
{
this(theName);
authenticationInfo = info;
authorizationInfo = info2;
}
public BaseAuthenticationInfo getAuthenticationInfo()
{
return authenticationInfo;
}
public void setAuthenticationInfo(BaseAuthenticationInfo authenticationInfo)
{
this.authenticationInfo = authenticationInfo;
}
public AuthorizationInfo getAuthorizationInfo()
{
return authorizationInfo;
}
public void setAuthorizationInfo(AuthorizationInfo authorizationInfo)
{
this.authorizationInfo = authorizationInfo;
}
public MappingInfo getRoleMappingInfo()
{
return roleMappingInfo;
}
public void setRoleMappingInfo(MappingInfo roleMappingInfo)
{
this.roleMappingInfo = roleMappingInfo;
}
public AuditInfo getAuditInfo()
{
return auditInfo;
}
public void setAuditInfo(AuditInfo auditInfo)
{
this.auditInfo = auditInfo;
}
public String getName()
{
return name;
}
public PolicyConfig getPolicyConfig()
{
return policyConfig;
}
public void setPolicyConfig(PolicyConfig policyConfig)
{
this.policyConfig = policyConfig;
}
}
package org.jboss.security.config;
import org.jboss.security.auth.login.BaseAuthenticationInfo;
/**
* Application Policy Information Holder
* - Authentication
* - Authorization
* - Audit
* - Mapping
*/
public class ApplicationPolicy
{
private String name;
private BaseAuthenticationInfo authenticationInfo;
private AuthorizationInfo authorizationInfo;
private AuditInfo auditInfo;
private MappingInfo roleMappingInfo;
//Parent PolicyConfig
private PolicyConfig policyConfig;
public ApplicationPolicy(String theName)
{
if(theName == null)
throw new IllegalArgumentException("name is null");
this.name = theName;
}
public ApplicationPolicy(String theName,BaseAuthenticationInfo info)
{
this(theName);
authenticationInfo = info;
}
public ApplicationPolicy(String theName,AuthorizationInfo info)
{ :p
this(theName);
authorizationInfo = info;
}
public ApplicationPolicy(String theName,
BaseAuthenticationInfo info, AuthorizationInfo info2)
{
this(theName);
authenticationInfo = info;
authorizationInfo = info2;
}
public BaseAuthenticationInfo getAuthenticationInfo()
{
return authenticationInfo;
}
public void setAuthenticationInfo(BaseAuthenticationInfo authenticationInfo)
{
this.authenticationInfo = authenticationInfo;
}
public AuthorizationInfo getAuthorizationInfo()
{
return authorizationInfo;
}
public void setAuthorizationInfo(AuthorizationInfo authorizationInfo)
{
this.authorizationInfo = authorizationInfo;
}
public MappingInfo getRoleMappingInfo()
{
return roleMappingInfo;
}
public void setRoleMappingInfo(MappingInfo roleMappingInfo)
{
this.roleMappingInfo = roleMappingInfo;
}
public AuditInfo getAuditInfo()
{
return auditInfo;
}
public void setAuditInfo(AuditInfo auditInfo)
{
this.auditInfo = auditInfo;
}
public String getName()
{
return name;
}
public PolicyConfig getPolicyConfig()
{
return policyConfig;
}
public void setPolicyConfig(PolicyConfig policyConfig)
{
this.policyConfig = policyConfig;
}
}
ApplicationPolicy objects must be generated and established in the SecurityConfiguration by the system integrators, using JBossXB, JAXB, or other preferred mechanism.