-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #274 from GluuFederation/fido2_merge_from_jans
chore(fido2): merge from jans
- Loading branch information
Showing
12 changed files
with
510 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...script/src/main/java/org/gluu/model/custom/script/type/fido2/DummyFido2ExtensionType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* oxCore is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. | ||
* | ||
* Copyright (c) 2020, Gluu | ||
*/ | ||
|
||
package org.gluu.model.custom.script.type.fido2; | ||
|
||
import java.util.Map; | ||
|
||
import org.gluu.model.SimpleCustomProperty; | ||
import org.gluu.model.custom.script.model.CustomScript; | ||
|
||
public class DummyFido2ExtensionType implements Fido2ExtensionType { | ||
|
||
@Override | ||
public boolean init(Map<String, SimpleCustomProperty> configurationAttributes) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean init(CustomScript customScript, Map<String, SimpleCustomProperty> configurationAttributes) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean destroy(Map<String, SimpleCustomProperty> configurationAttributes) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public int getApiVersion() { | ||
return 1; | ||
} | ||
|
||
@Override | ||
public boolean registerAttestationStart(Object paramAsJsonNode, Object context) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean registerAttestationFinish(Object paramAsJsonNode, Object context) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean verifyAttestationStart(Object paramAsJsonNode, Object context) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean verifyAttestationFinish(Object paramAsJsonNode, Object context) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean authenticateAssertionStart(Object paramAsJsonNode, Object context) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean authenticateAssertionFinish(Object paramAsJsonNode, Object context) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean verifyAssertionStart(Object paramAsJsonNode, Object context) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean verifyAssertionFinish(Object paramAsJsonNode, Object context) { | ||
return false; | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
core-script/src/main/java/org/gluu/model/custom/script/type/fido2/Fido2ExtensionType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* oxCore is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. | ||
* | ||
* Copyright (c) 2020, Gluu | ||
*/ | ||
|
||
package org.gluu.model.custom.script.type.fido2; | ||
|
||
import org.gluu.model.custom.script.type.BaseExternalType; | ||
|
||
public interface Fido2ExtensionType extends BaseExternalType { | ||
|
||
boolean registerAttestationStart(Object paramAsJsonNode, Object context); | ||
boolean registerAttestationFinish(Object paramAsJsonNode, Object context); | ||
|
||
boolean verifyAttestationStart(Object paramAsJsonNode, Object context); | ||
boolean verifyAttestationFinish(Object paramAsJsonNode, Object context); | ||
|
||
boolean authenticateAssertionStart(Object paramAsJsonNode, Object context); | ||
boolean authenticateAssertionFinish(Object paramAsJsonNode, Object context); | ||
|
||
boolean verifyAssertionStart(Object paramAsJsonNode, Object context); | ||
boolean verifyAssertionFinish(Object paramAsJsonNode, Object context); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>org.gluu</groupId> | ||
<artifactId>oxcore</artifactId> | ||
<version>4.5.5-SNAPSHOT</version> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>gluu-doc</artifactId> | ||
<packaging>jar</packaging> | ||
<name>gluu-doc</name> | ||
|
||
|
||
</project> |
16 changes: 16 additions & 0 deletions
16
doc/src/main/java/org/gluu/doc/annotation/DocFeatureFlag.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.gluu.doc.annotation; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target(ElementType.FIELD) | ||
@Retention(RetentionPolicy.SOURCE) | ||
public @interface DocFeatureFlag { | ||
String description(); | ||
|
||
boolean isRequired() default false; | ||
|
||
String defaultValue(); | ||
} |
112 changes: 112 additions & 0 deletions
112
doc/src/main/java/org/gluu/doc/annotation/DocFeatureFlagProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package org.gluu.doc.annotation; | ||
|
||
import javax.annotation.processing.AbstractProcessor; | ||
import javax.annotation.processing.RoundEnvironment; | ||
import javax.annotation.processing.SupportedAnnotationTypes; | ||
import javax.annotation.processing.SupportedOptions; | ||
import javax.lang.model.element.Element; | ||
import javax.lang.model.element.TypeElement; | ||
import javax.tools.Diagnostic; | ||
import javax.tools.FileObject; | ||
import javax.tools.StandardLocation; | ||
import java.io.IOException; | ||
import java.io.PrintWriter; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
@SupportedAnnotationTypes("org.gluu.doc.annotation.DocFeatureFlag") | ||
@SupportedOptions({"module"}) | ||
public class DocFeatureFlagProcessor extends AbstractProcessor { | ||
|
||
String moduleName; | ||
@Override | ||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment env) { | ||
|
||
moduleName = processingEnv.getOptions().get("module"); | ||
|
||
for (TypeElement annotation : annotations) { | ||
Set<? extends Element> annotatedElements = env.getElementsAnnotatedWith(annotation); | ||
|
||
// sort alphabetically | ||
List<? extends Element> sortedElements = annotatedElements.stream() | ||
.sorted((prop1, prop2)->prop1.getSimpleName().toString().toLowerCase().compareTo(prop2.getSimpleName().toString().toLowerCase())) | ||
.collect(Collectors.toList()); | ||
|
||
StringBuilder docContents = new StringBuilder(); | ||
StringBuilder tableContents = new StringBuilder(); | ||
StringBuilder detailsContent = new StringBuilder(); | ||
|
||
// prepare document header | ||
prepareDocTagsAndTableHeader(docContents, tableContents); | ||
|
||
// for each feature flag add a row in table and add content for the details section | ||
for (Element element : sortedElements) | ||
{ | ||
DocFeatureFlag elementAnnotation = element.getAnnotation(DocFeatureFlag.class); | ||
addToTable(tableContents, element, elementAnnotation); | ||
addToDetails(detailsContent, element, elementAnnotation); | ||
} | ||
tableContents.append("\n\n"); | ||
createAndWriteDoc(docContents.append((tableContents.append(detailsContent.toString())))); | ||
|
||
} | ||
return false; | ||
} | ||
|
||
private void prepareDocTagsAndTableHeader(StringBuilder docContents, StringBuilder tableContents) { | ||
// add tags | ||
docContents.append("---\n") | ||
.append("tags:\n") | ||
.append("- administration\n") | ||
.append("- reference\n") | ||
.append("- json\n") | ||
.append("- feature-flags\n") | ||
.append("---\n") | ||
.append("\n") | ||
.append("# "+moduleName+" Feature Flags") // add doc header | ||
.append("\n") | ||
.append("\n"); | ||
|
||
tableContents.append("| Feature Flag Name ") // prepare table header | ||
.append("| Description ") | ||
.append("| | ") | ||
.append("\n") | ||
.append("|-----|-----|-----|") | ||
.append("\n"); | ||
} | ||
|
||
private void createAndWriteDoc(StringBuilder docContent) { | ||
|
||
FileObject docFile = null; | ||
try{ | ||
docFile = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", moduleName.toLowerCase().replaceAll("\\s", "")+"-feature-flags.md"); | ||
} | ||
catch (IOException ioe){ | ||
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, this.getClass().getName()+": Error occurred while creating annotation documentation file"); | ||
} | ||
if(docFile!=null){ | ||
try(PrintWriter docWriter = new PrintWriter(docFile.openWriter());) { | ||
docWriter.write(docContent.toString()); | ||
docWriter.flush(); | ||
} catch (IOException e) { | ||
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, this.getClass().getName()+": Error occurred while writing annotation documentation file"); | ||
} | ||
} | ||
} | ||
|
||
private static void addToDetails(StringBuilder propDetails, Element jansElement, DocFeatureFlag featureFlagAnnotation) { | ||
propDetails.append("### "+ jansElement.getSimpleName()+"\n\n"); | ||
propDetails.append("- Description: "+ featureFlagAnnotation.description()+"\n\n"); | ||
propDetails.append("- Required: "+ (featureFlagAnnotation.isRequired()?"Yes":"No")+"\n\n"); | ||
propDetails.append("- Default value: "+ featureFlagAnnotation.defaultValue()+"\n\n"); | ||
propDetails.append("\n"); | ||
} | ||
|
||
private static void addToTable(StringBuilder propTable, Element jansElement, DocFeatureFlag featureFlagAnnotation) { | ||
propTable.append("| "+ jansElement.getSimpleName()+" "); | ||
propTable.append("| "+ featureFlagAnnotation.description()+" "); | ||
propTable.append("| [Details](#"+jansElement.getSimpleName().toString().toLowerCase()+") |"); | ||
propTable.append("\n"); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
doc/src/main/java/org/gluu/doc/annotation/DocProperty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.gluu.doc.annotation; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target(ElementType.FIELD) | ||
@Retention(RetentionPolicy.SOURCE) | ||
public @interface DocProperty { | ||
String description() default "None"; | ||
|
||
boolean isRequired() default false; | ||
|
||
String defaultValue() default "None"; | ||
} |
Oops, something went wrong.