You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2006/01/14 16:13:53 UTC
svn commit: r369027 - in /myfaces/commons/trunk: pom.xml
src/main/java/org/apache/myfaces/util/StateUtils.java
Author: bommel
Date: Sat Jan 14 07:13:33 2006
New Revision: 369027
URL: http://svn.apache.org/viewcvs?rev=369027&view=rev
Log:
added javadoc for assembly generate javadoc artifact with profile generate-assembly mvn -Pgenerate-assembly
added separate xsl for generate separate tld for the tlddoc
added tlddoc to site enable with profile generate-site mvn -Pgenerate-site
fixed missing java.lang in type of some attributes.xml in sandbox
Modified:
myfaces/commons/trunk/pom.xml
myfaces/commons/trunk/src/main/java/org/apache/myfaces/util/StateUtils.java
Modified: myfaces/commons/trunk/pom.xml
URL: http://svn.apache.org/viewcvs/myfaces/commons/trunk/pom.xml?rev=369027&r1=369026&r2=369027&view=diff
==============================================================================
--- myfaces/commons/trunk/pom.xml (original)
+++ myfaces/commons/trunk/pom.xml Sat Jan 14 07:13:33 2006
@@ -127,7 +127,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.1.2</version>
- <configuration>
+ <configuration>
<excludes>
<exclude>**/*StateUtilsAES_CBCTestCase*</exclude>
</excludes>
@@ -191,6 +191,26 @@
</plugins>
</reporting>
+
+ <profiles>
+ <profile>
+ <id>generate-assembly</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-javadoc</id>
+ <goals><goal>jar</goal></goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
<scm>
<connection>scm:svn:http://svn.apache.org/repos/asf/myfaces/commons/trunk</connection>
Modified: myfaces/commons/trunk/src/main/java/org/apache/myfaces/util/StateUtils.java
URL: http://svn.apache.org/viewcvs/myfaces/commons/trunk/src/main/java/org/apache/myfaces/util/StateUtils.java?rev=369027&r1=369026&r2=369027&view=diff
==============================================================================
--- myfaces/commons/trunk/src/main/java/org/apache/myfaces/util/StateUtils.java (original)
+++ myfaces/commons/trunk/src/main/java/org/apache/myfaces/util/StateUtils.java Sat Jan 14 07:13:33 2006
@@ -102,47 +102,52 @@
static
{
- try {
+
FacesContext ctx = FacesContext.getCurrentInstance();
String _secret;
String _algorithm;
String _algorithmParams;
String _iv; // initialization vector
- if(ctx != null){
- _secret = ctx.getExternalContext().getInitParameter(INIT_SECRET);
- _algorithm = ctx.getExternalContext().getInitParameter(INIT_ALGORITHM);
- _algorithmParams = ctx.getExternalContext().getInitParameter(INIT_ALGORITHM_PARAM);
- _iv = ctx.getExternalContext().getInitParameter(INIT_ALGORITHM_IV);
- } else{ // not recommended for users ... mostly here for testing
- _secret = System.getProperty(INIT_SECRET);
- _algorithm = System.getProperty(INIT_ALGORITHM);
- _algorithmParams = System.getProperty(INIT_ALGORITHM_PARAM);
- _iv = System.getProperty(INIT_ALGORITHM_IV);
- }
-
- if (_secret == null){
- log.debug("secret for " + INIT_SECRET + " not located, encryption disabled");
- } else{
- if(_algorithmParams != null && _algorithmParams.startsWith("CBC") & _iv == null){
- throw new FacesException(INIT_ALGORITHM_PARAM +
+ if (ctx != null)
+ {
+ _secret = ctx.getExternalContext().getInitParameter(INIT_SECRET);
+ _algorithm = ctx.getExternalContext().getInitParameter(INIT_ALGORITHM);
+ _algorithmParams = ctx.getExternalContext().getInitParameter(INIT_ALGORITHM_PARAM);
+ _iv = ctx.getExternalContext().getInitParameter(INIT_ALGORITHM_IV);
+ } else {
+ // TODO remove this
+ // not recommended for users ... mostly here for testing
+ _secret = System.getProperty(INIT_SECRET);
+ _algorithm = System.getProperty(INIT_ALGORITHM);
+ _algorithmParams = System.getProperty(INIT_ALGORITHM_PARAM);
+ _iv = System.getProperty(INIT_ALGORITHM_IV);
+ }
+
+ if (_secret == null)
+ {
+ log.debug("secret for " + INIT_SECRET + " not located, encryption disabled");
+ }
+ else
+ {
+ if (_algorithmParams != null && _algorithmParams.startsWith("CBC") & _iv == null )
+ {
+ throw new FacesException(INIT_ALGORITHM_PARAM +
" parameter has been set with CBC mode," +
" but no initialization vector has been set " +
" with " + INIT_ALGORITHM_IV);
- }
- secret = new Base64().decode(_secret.getBytes());
- if(_algorithm != null)
- algorithm = _algorithm;
- if(_algorithmParams != null)
- algorithmParams = _algorithmParams;
- if(_iv != null)
- iv = new Base64().decode(_iv.getBytes());
- secure = true;
- log.debug("encryption enabled using " + algorithm + "/" + algorithmParams);
- }
- } catch (Throwable t) {
- t.printStackTrace();
+ }
+ secret = new Base64().decode(_secret.getBytes());
+ if (_algorithm != null)
+ algorithm = _algorithm;
+ if (_algorithmParams != null)
+ algorithmParams = _algorithmParams;
+ if (_iv != null)
+ iv = new Base64().decode(_iv.getBytes());
+ secure = true;
+ log.debug("encryption enabled using " + algorithm + "/" + algorithmParams);
}
+
}
public static boolean isSecure()
@@ -172,7 +177,7 @@
public static final byte[] getAsByteArray(Object object)
{
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try
{
ObjectOutputStream writer = new ObjectOutputStream(outputStream);
@@ -234,7 +239,7 @@
public static final byte[] encode(byte[] bytes)
{
- return new Base64().encode(bytes);
+ return new Base64().encode(bytes);
}
/**
@@ -242,7 +247,7 @@
*/
public static final Object reconstruct(String string){
- byte[] bytes;
+ byte[] bytes;
try
{
bytes = string.getBytes(ZIP_CHARSET);
@@ -260,14 +265,14 @@
public static final byte[] decode(byte[] bytes)
{
- return new Base64().decode(bytes);
+ return new Base64().decode(bytes);
}
public static final byte[] decompress(byte[] bytes)
{
- ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- byte[] buffer = new byte[2048];
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ byte[] buffer = new byte[2048];
int length;
try
@@ -319,9 +324,9 @@
public static final Object getAsObject(byte[] bytes)
{
- ByteArrayInputStream input = new ByteArrayInputStream(bytes);
+ ByteArrayInputStream input = new ByteArrayInputStream(bytes);
- try
+ try
{
ObjectInputStream s = new ObjectInputStream(input);
Object object = s.readObject();
@@ -358,46 +363,57 @@
}
}
- public static byte[] getSecret() {
- return secret;
+
+ public static byte[] getSecret()
+ {
+ return secret;
}
- public static void setSecret(String _secret) {
- secret =new Base64().decode(_secret.getBytes());
+ public static void setSecret(String _secret)
+ {
+ secret = new Base64().decode(_secret.getBytes());
}
- public static void setSecret(byte[] secret) {
- StateUtils.secret = secret;
+ public static void setSecret(byte[] secret)
+ {
+ StateUtils.secret = secret;
}
- public static String getAlgorithm() {
- return algorithm;
+ public static String getAlgorithm()
+ {
+ return algorithm;
}
- public static void setAlgorithm(String algorithm) {
- StateUtils.algorithm = algorithm;
+ public static void setAlgorithm(String algorithm)
+ {
+ StateUtils.algorithm = algorithm;
}
- public static String getAlgorithmParams() {
- return algorithmParams;
+ public static String getAlgorithmParams()
+ {
+ return algorithmParams;
}
- public static void setAlgorithmParams(String algorithmParams) {
- StateUtils.algorithmParams = algorithmParams;
+ public static void setAlgorithmParams(String algorithmParams)
+ {
+ StateUtils.algorithmParams = algorithmParams;
}
- public static byte[] getIv() {
- return iv;
+ public static byte[] getIv()
+ {
+ return iv;
}
- public static void setIv(String _iv) {
- iv = new Base64().decode(_iv.getBytes());
+ public static void setIv(String _iv)
+ {
+ iv = new Base64().decode(_iv.getBytes());
}
- public static void setIv(byte[] iv) {
- StateUtils.iv = iv;
+ public static void setIv(byte[] iv)
+ {
+ StateUtils.iv = iv;
}
- public static void main (String[] args) throws UnsupportedEncodingException
+ public static void main (String[] args) throws UnsupportedEncodingException
{
- byte[] bytes = encode(args[0].getBytes(ZIP_CHARSET));
- System.out.println(new String(bytes, ZIP_CHARSET));
+ byte[] bytes = encode(args[0].getBytes(ZIP_CHARSET));
+ System.out.println(new String(bytes, ZIP_CHARSET));
}
}